This commit is contained in:
2025-08-31 23:27:52 -04:00
parent 23dfc171b8
commit 40f8780dec
27 changed files with 24228 additions and 0 deletions

View File

@ -0,0 +1,45 @@
import React from 'react';
import { ListItem, FilterOptions } from '../../types';
export interface TableColumn {
key: string;
label: string;
sortable?: boolean;
filterable?: boolean;
width?: string | number;
render?: (value: any, item: ListItem) => React.ReactNode;
}
export interface TableAction {
key: string;
label: string;
icon?: React.ReactNode;
color?: string;
onClick: (item: ListItem) => void;
show?: (item: ListItem) => boolean;
}
export interface DataTableProps {
data: ListItem[];
columns: TableColumn[];
loading?: boolean;
error?: string | null;
title?: string;
total?: number;
page?: number;
pageSize?: number;
onPageChange?: (page: number) => void;
onAdd?: () => void;
onEdit?: (item: ListItem) => void;
onDelete?: (item: ListItem) => Promise<void>;
onRefresh?: () => void;
customActions?: TableAction[];
searchable?: boolean;
filterable?: boolean;
filters?: FilterOptions;
onFiltersChange?: (filters: FilterOptions) => void;
withBorder?: boolean;
withColumnBorders?: boolean;
striped?: boolean;
highlightOnHover?: boolean;
emptyMessage?: string;
}
declare const DataTable: React.FC<DataTableProps>;
export default DataTable;

View File

@ -0,0 +1,17 @@
import React from 'react';
import { FormField } from '../../types';
export interface FormSidebarProps {
opened: boolean;
onClose: () => void;
onSuccess: () => void;
title: string;
editMode?: boolean;
editItem?: any;
fields: FormField[];
onSubmit: (values: any) => Promise<void>;
width?: number;
initialValues?: Record<string, any>;
validateOnSubmit?: boolean;
}
declare const FormSidebar: React.FC<FormSidebarProps>;
export default FormSidebar;

View File

@ -0,0 +1,25 @@
import { AxiosInstance } from 'axios';
import { FilterOptions } from '../types';
export interface ApiServiceConfig {
baseURL: string;
defaultHeaders?: Record<string, string>;
timeout?: number;
}
export interface UseApiServiceReturn<T> {
data: T[];
loading: boolean;
error: string | null;
total: number;
hasMore: boolean;
client: AxiosInstance;
getAll: (filters?: FilterOptions) => Promise<T[]>;
getById: (id: string) => Promise<T>;
create: (data: Partial<T>) => Promise<T>;
update: (id: string, data: Partial<T>) => Promise<T>;
delete: (id: string) => Promise<void>;
clearError: () => void;
refresh: () => Promise<void>;
}
export declare const useApiService: <T extends {
id: string;
}>(config: ApiServiceConfig, endpoint: string) => UseApiServiceReturn<T>;

View File

@ -0,0 +1,16 @@
import { FilterOptions, ListItem } from '../types';
export interface UseDataFilterOptions {
searchFields?: string[];
defaultFilters?: FilterOptions;
debounceMs?: number;
}
export interface UseDataFilterReturn {
filteredData: ListItem[];
filters: FilterOptions;
setFilter: (key: string, value: any) => void;
clearFilters: () => void;
resetFilters: () => void;
searchTerm: string;
setSearchTerm: (term: string) => void;
}
export declare const useDataFilter: (data: ListItem[], options?: UseDataFilterOptions) => UseDataFilterReturn;

13
web-components/dist/index.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
export { default as FormSidebar } from './components/FormSidebar/FormSidebar';
export { default as DataTable } from './components/DataTable/DataTable';
export * from './types';
export { useApiService } from './hooks/useApiService';
export { useDataFilter } from './hooks/useDataFilter';
export * from './utils/notifications';
export * from './utils/validation';
export { Paper, Stack, Group, Button, TextInput, Select, MultiSelect, NumberInput, Textarea, JsonInput, ActionIcon, Menu, Text, Title, Badge, Table, Pagination, LoadingOverlay, Center, Box, ScrollArea, Divider, } from '@mantine/core';
export { useDisclosure, useToggle, useLocalStorage, } from '@mantine/hooks';
export { useForm } from '@mantine/form';
export { notifications } from '@mantine/notifications';
export { modals } from '@mantine/modals';
export { IconPlus, IconEdit, IconTrash, IconSearch, IconFilter, IconRefresh, IconX, IconDots, IconChevronDown, IconChevronRight, IconUser, IconUsers, IconKey, IconSettings, IconEye, IconEyeOff, IconCopy, IconCheck, IconAlertCircle, IconInfoCircle, } from '@tabler/icons-react';

2
web-components/dist/index.esm.js vendored Normal file

File diff suppressed because one or more lines are too long

1
web-components/dist/index.esm.js.map vendored Normal file

File diff suppressed because one or more lines are too long

2
web-components/dist/index.js vendored Normal file

File diff suppressed because one or more lines are too long

1
web-components/dist/index.js.map vendored Normal file

File diff suppressed because one or more lines are too long

79
web-components/dist/types/index.d.ts vendored Normal file
View File

@ -0,0 +1,79 @@
export interface BaseEntity {
id: string;
created_at: string;
updated_at: string;
created_by?: string;
updated_by?: string;
}
export interface Owner {
type: 'individual' | 'team';
name: string;
owner: string;
}
export interface FormSidebarProps {
opened: boolean;
onClose: () => void;
onSuccess: () => void;
editItem?: any;
}
export interface ListItem {
id: string;
name?: string;
title?: string;
email?: string;
status?: string;
role?: string;
type?: string;
[key: string]: any;
}
export interface ApiResponse<T> {
data: T;
message?: string;
error?: string;
}
export interface PaginatedResponse<T> {
data: T[];
total: number;
page: number;
limit: number;
has_more: boolean;
}
export interface FilterOptions {
search?: string;
status?: string;
type?: string;
role?: string;
limit?: number;
offset?: number;
[key: string]: any;
}
export interface NotificationConfig {
title: string;
message: string;
color: 'red' | 'green' | 'blue' | 'yellow' | 'gray';
[key: string]: any;
}
export interface ValidationRule {
required?: boolean;
minLength?: number;
maxLength?: number;
pattern?: RegExp;
email?: boolean;
url?: boolean;
custom?: (value: any) => string | null;
}
export interface FormField {
name: string;
label: string;
type: 'text' | 'email' | 'number' | 'select' | 'multiselect' | 'textarea' | 'date' | 'json';
placeholder?: string;
description?: string;
required?: boolean;
disabled?: boolean;
options?: Array<{
value: string;
label: string;
}>;
validation?: ValidationRule;
defaultValue?: any;
}

View File

@ -0,0 +1,37 @@
export declare const showSuccessNotification: (message: string, title?: string) => void;
export declare const showErrorNotification: (message: string, title?: string) => void;
export declare const showWarningNotification: (message: string, title?: string) => void;
export declare const showInfoNotification: (message: string, title?: string) => void;
export declare const NotificationMessages: {
createSuccess: (entityName: string) => string;
updateSuccess: (entityName: string) => string;
deleteSuccess: (entityName: string) => string;
createError: (entityName: string) => string;
updateError: (entityName: string) => string;
deleteError: (entityName: string) => string;
loadError: (entityName: string) => string;
networkError: string;
validationError: string;
requiredFieldError: (fieldName: string) => string;
authRequired: string;
permissionDenied: string;
sessionExpired: string;
applicationCreated: string;
applicationUpdated: string;
applicationDeleted: string;
tokenCreated: string;
tokenRevoked: string;
userCreated: string;
userUpdated: string;
userDeleted: string;
functionCreated: string;
functionUpdated: string;
functionDeleted: string;
executionStarted: string;
executionCompleted: string;
executionFailed: string;
};
export declare const showCrudNotification: {
success: (operation: "create" | "update" | "delete", entityName: string) => void;
error: (operation: "create" | "update" | "delete" | "load", entityName: string, customMessage?: string) => void;
};

View File

@ -0,0 +1,37 @@
export declare const ValidationPatterns: {
email: RegExp;
url: RegExp;
duration: RegExp;
token: RegExp;
appId: RegExp;
uuid: RegExp;
};
export declare const ValidationMessages: {
required: (fieldName: string) => string;
email: string;
url: string;
duration: string;
minLength: (fieldName: string, minLength: number) => string;
maxLength: (fieldName: string, maxLength: number) => string;
pattern: (fieldName: string) => string;
token: string;
appId: string;
uuid: string;
positiveNumber: string;
range: (fieldName: string, min: number, max: number) => string;
};
export declare const validateRequired: (value: any) => string | null;
export declare const validateEmail: (value: string) => string | null;
export declare const validateUrl: (value: string) => string | null;
export declare const validateDuration: (value: string) => string | null;
export declare const validateMinLength: (value: string, minLength: number, fieldName?: string) => string | null;
export declare const validateMaxLength: (value: string, maxLength: number, fieldName?: string) => string | null;
export declare const validatePattern: (value: string, pattern: RegExp, fieldName?: string) => string | null;
export declare const validateRange: (value: number, min: number, max: number, fieldName?: string) => string | null;
export declare const validateAppId: (value: string) => string | null;
export declare const validateToken: (value: string) => string | null;
export declare const validateUuid: (value: string) => string | null;
export declare const validateJsonString: (value: string) => string | null;
export declare const parseDuration: (duration: string) => number;
export declare const formatDuration: (seconds: number) => string;
export declare const combineValidators: (...validators: Array<(value: any) => string | null>) => (value: any) => string | null;