forlogic-core 1.15.2 → 1.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/index.d.ts +6 -0
- package/dist/auth/components/ProtectedRoute.d.ts +6 -0
- package/dist/auth/components/UserInfo.d.ts +10 -0
- package/dist/auth/contexts/AuthContext.d.ts +84 -0
- package/dist/auth/pages/CallbackPage.d.ts +1 -0
- package/dist/auth/pages/LoginPage.d.ts +2 -0
- package/dist/auth/services/AuthService.d.ts +40 -0
- package/dist/auth/services/SupabaseTokenService.d.ts +3 -0
- package/dist/auth/services/TokenManager.d.ts +51 -0
- package/dist/auth/services/TokenRegenerationService.d.ts +12 -0
- package/dist/auth/services/TokenService.d.ts +42 -0
- package/dist/auth/utils/AuthUtils.d.ts +4 -0
- package/dist/auth/utils/ErrorInterceptor.d.ts +15 -0
- package/dist/components/ErrorBoundary.d.ts +19 -0
- package/dist/components/layout/AppHeader.d.ts +63 -0
- package/dist/components/layout/AppLayout.d.ts +10 -0
- package/dist/components/layout/AppSidebar.d.ts +10 -0
- package/dist/components/layout/BodyContent.d.ts +60 -0
- package/dist/components/layout/SidebarActionTrigger.d.ts +34 -0
- package/dist/components/layout/SidebarHeader.d.ts +5 -0
- package/dist/components/layout/sidebar-utils.d.ts +12 -0
- package/dist/components/modules/ModuleGrid.d.ts +9 -0
- package/dist/components/modules/ModulesDialog.d.ts +3 -0
- package/dist/components/modules/icons/ModulesCardIcons.d.ts +19 -0
- package/dist/components/modules/index.d.ts +4 -0
- package/dist/components/modules/modulesData.d.ts +6 -0
- package/dist/components/modules/types.d.ts +35 -0
- package/dist/components/ui/accordion.d.ts +7 -0
- package/dist/components/ui/action-button.d.ts +43 -0
- package/dist/components/ui/alert-dialog.d.ts +20 -0
- package/dist/components/ui/alert.d.ts +12 -0
- package/dist/components/ui/avatar.d.ts +6 -0
- package/dist/components/ui/badge.d.ts +9 -0
- package/dist/components/ui/breadcrumb.d.ts +19 -0
- package/dist/components/ui/button-group.d.ts +9 -0
- package/dist/components/ui/button.d.ts +11 -0
- package/dist/components/ui/calendar.d.ts +8 -0
- package/dist/components/ui/card.d.ts +8 -0
- package/dist/components/ui/chart.d.ts +62 -0
- package/dist/components/ui/checkbox.d.ts +4 -0
- package/dist/components/ui/collapsible.d.ts +5 -0
- package/dist/components/ui/color-picker.d.ts +8 -0
- package/dist/components/ui/combobox.d.ts +33 -0
- package/dist/components/ui/command.d.ts +23 -0
- package/dist/components/ui/context-menu.d.ts +27 -0
- package/dist/components/ui/data-list.d.ts +86 -0
- package/dist/components/ui/date-picker.d.ts +9 -0
- package/dist/components/ui/dialog.d.ts +36 -0
- package/dist/components/ui/disabled-menu-item.d.ts +25 -0
- package/dist/components/ui/drawer.d.ts +22 -0
- package/dist/components/ui/dropdown-menu.d.ts +27 -0
- package/dist/components/ui/empty-state.d.ts +79 -0
- package/dist/components/ui/form.d.ts +23 -0
- package/dist/components/ui/grid.d.ts +53 -0
- package/dist/components/ui/hover-card.d.ts +6 -0
- package/dist/components/ui/icon-picker.d.ts +8 -0
- package/dist/components/ui/input-group.d.ts +97 -0
- package/dist/components/ui/input.d.ts +37 -0
- package/dist/components/ui/label.d.ts +23 -0
- package/dist/components/ui/loading-state.d.ts +52 -0
- package/dist/components/ui/menubar.d.ts +33 -0
- package/dist/components/ui/navigation-menu.d.ts +12 -0
- package/dist/components/ui/onboarding-dialog.d.ts +43 -0
- package/dist/components/ui/page-breadcrumb.d.ts +77 -0
- package/dist/components/ui/pagination.d.ts +28 -0
- package/dist/components/ui/popover.d.ts +49 -0
- package/dist/components/ui/progress.d.ts +22 -0
- package/dist/components/ui/radio-group.d.ts +63 -0
- package/dist/components/ui/resizable.d.ts +23 -0
- package/dist/components/ui/rich-text-editor.d.ts +45 -0
- package/dist/components/ui/scroll-area.d.ts +37 -0
- package/dist/components/ui/select.d.ts +16 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/sheet.d.ts +32 -0
- package/dist/components/ui/sidebar.d.ts +66 -0
- package/dist/components/ui/skeleton-variants.d.ts +16 -0
- package/dist/components/ui/skeleton.d.ts +2 -0
- package/dist/components/ui/slider.d.ts +4 -0
- package/dist/components/ui/sonner.d.ts +3 -0
- package/dist/components/ui/spinner.d.ts +6 -0
- package/dist/components/ui/split-button.d.ts +70 -0
- package/dist/components/ui/stack.d.ts +12 -0
- package/dist/components/ui/step-selector.d.ts +39 -0
- package/dist/components/ui/switch.d.ts +4 -0
- package/dist/components/ui/tab-page-layout.d.ts +19 -0
- package/dist/components/ui/table-resize-handle.d.ts +15 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/components/ui/tabs.d.ts +7 -0
- package/dist/components/ui/textarea.d.ts +5 -0
- package/dist/components/ui/toggle-group.d.ts +12 -0
- package/dist/components/ui/toggle.d.ts +12 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/components/ui/truncated-cell.d.ts +7 -0
- package/dist/components/ui/typography.d.ts +16 -0
- package/dist/config/index.d.ts +53 -0
- package/dist/contexts/LocaleContext.d.ts +15 -0
- package/dist/contexts/ModalStateContext.d.ts +57 -0
- package/dist/contexts/NavigationContext.d.ts +13 -0
- package/dist/contexts/PageMetadataContext.d.ts +43 -0
- package/dist/crud/components/ActionMenuItems.d.ts +17 -0
- package/dist/crud/components/BaseForm.d.ts +6 -0
- package/dist/crud/components/ContextMenu.d.ts +21 -0
- package/dist/crud/components/CrudActionBar.d.ts +38 -0
- package/dist/crud/components/CrudGrid.d.ts +43 -0
- package/dist/crud/components/CrudPagination.d.ts +12 -0
- package/dist/crud/components/CrudTable.d.ts +41 -0
- package/dist/crud/components/FilterBar.d.ts +136 -0
- package/dist/crud/components/TableFooter.d.ts +14 -0
- package/dist/crud/components/TableRowActions.d.ts +14 -0
- package/dist/crud/createCrudPage.d.ts +99 -0
- package/dist/crud/createSimpleService.d.ts +85 -0
- package/dist/crud/generateCrudConfig.d.ts +73 -0
- package/dist/crud/hooks/useBaseForm.d.ts +8 -0
- package/dist/crud/hooks/useCrud.d.ts +117 -0
- package/dist/crud/primitives/ActionMenu.d.ts +28 -0
- package/dist/crud/primitives/FilterBar.d.ts +24 -0
- package/dist/crud/primitives/Pagination.d.ts +24 -0
- package/dist/crud/primitives/Table.d.ts +26 -0
- package/dist/crud/primitives/index.d.ts +11 -0
- package/dist/crud/primitives/types.d.ts +76 -0
- package/dist/crud/utils/routingHelpers.d.ts +30 -0
- package/dist/exports/crud.d.ts +21 -0
- package/dist/exports/integrations.d.ts +13 -0
- package/dist/exports/ui.d.ts +73 -0
- package/dist/hooks/useActiveModules.d.ts +45 -0
- package/dist/hooks/useColumnResize.d.ts +21 -0
- package/dist/hooks/useDebounce.d.ts +56 -0
- package/dist/hooks/useI18nFormatters.d.ts +40 -0
- package/dist/hooks/usePageTitle.d.ts +4 -0
- package/dist/hooks/usePermissionQuery.d.ts +49 -0
- package/dist/hooks/useRowResize.d.ts +19 -0
- package/dist/hooks/useSidebarResize.d.ts +19 -0
- package/dist/hooks/useWizard.d.ts +40 -0
- package/dist/i18n/DatabaseBackend.d.ts +9 -0
- package/dist/i18n/components/TranslationLoader.d.ts +10 -0
- package/dist/i18n/config.d.ts +2 -0
- package/dist/i18n/constants.d.ts +126 -0
- package/dist/i18n/index.d.ts +21 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/leadership/components/LeaderRow.d.ts +9 -0
- package/dist/leadership/components/LeadershipDialog.d.ts +10 -0
- package/dist/leadership/components/LeadershipForm.d.ts +8 -0
- package/dist/leadership/components/LeadershipPage.d.ts +1 -0
- package/dist/leadership/hooks/useLeadershipApi.d.ts +2 -0
- package/dist/leadership/hooks/useLeadershipMutations.d.ts +30 -0
- package/dist/leadership/index.d.ts +14 -0
- package/dist/leadership/types.d.ts +17 -0
- package/dist/leadership/utils/leadershipUtils.d.ts +8 -0
- package/dist/media/components/ImageEditor.d.ts +22 -0
- package/dist/media/components/ImageRenderer.d.ts +23 -0
- package/dist/media/components/VideoEditor.d.ts +22 -0
- package/dist/media/components/VideoRenderer.d.ts +8 -0
- package/dist/media/hooks/useMediaUpload.d.ts +20 -0
- package/dist/media/index.d.ts +49 -0
- package/dist/media/types.d.ts +66 -0
- package/dist/media/utils/imageHelpers.d.ts +28 -0
- package/dist/media/utils/videoHelpers.d.ts +35 -0
- package/dist/places/components/ManageAccessModal.d.ts +11 -0
- package/dist/places/components/PlaceCard.d.ts +12 -0
- package/dist/places/components/PlacesList.d.ts +12 -0
- package/dist/places/index.d.ts +8 -0
- package/dist/places/services/PlaceService.d.ts +9 -0
- package/dist/places/types.d.ts +10 -0
- package/dist/providers/CoreProviders.d.ts +66 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/qualiex/components/QualiexUserField.d.ts +125 -0
- package/dist/qualiex/hooks/useQualiexUsers.d.ts +51 -0
- package/dist/qualiex/services/qualiexApi.d.ts +21 -0
- package/dist/qualiex/utils/QualiexErrorInterceptor.d.ts +15 -0
- package/dist/qualiex/utils/userPlaceUtils.d.ts +16 -0
- package/dist/services/BaseService.d.ts +51 -0
- package/dist/services/EmailService.d.ts +110 -0
- package/dist/services/ErrorService.d.ts +19 -0
- package/dist/services/QualiexEnrichmentService.d.ts +65 -0
- package/dist/services/QualiexFieldHelpers.d.ts +17 -0
- package/dist/services/TranslationService.d.ts +20 -0
- package/dist/setup.d.ts +14 -0
- package/dist/sign/components/D4SignWidget.d.ts +2 -0
- package/dist/sign/components/DocumentSigner.d.ts +2 -0
- package/dist/sign/components/SignConfigForm.d.ts +2 -0
- package/dist/sign/components/SignWidget.d.ts +21 -0
- package/dist/sign/hooks/useSignConfig.d.ts +6 -0
- package/dist/sign/index.d.ts +7 -0
- package/dist/sign/services/signService.d.ts +23 -0
- package/dist/sign/types.d.ts +53 -0
- package/dist/supabase/SupabaseSingleton.d.ts +3 -0
- package/dist/supabase/client.d.ts +2 -0
- package/dist/supabase/publicClient.d.ts +2 -0
- package/dist/supabase/types.d.ts +377 -0
- package/dist/types/sidebar.d.ts +49 -0
- package/dist/types.d.ts +499 -0
- package/dist/utils/formatters/currencyFormatters.d.ts +1 -0
- package/dist/utils/formatters/dateFormatters.d.ts +52 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/linkHelpers.d.ts +4 -0
- package/package.json +1 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { CrudConfig, EntityWithId } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Gera automaticamente configuração CRUD a partir de uma interface TypeScript
|
|
4
|
+
*
|
|
5
|
+
* **USO AVANÇADO:** Para a maioria dos casos, use `useMemo` direto com config manual.
|
|
6
|
+
* Esta função é útil para gerar configs dinamicamente em tempo de execução.
|
|
7
|
+
*
|
|
8
|
+
* Analisa os campos da entidade e cria colunas com tipos inteligentes baseados em:
|
|
9
|
+
* - Nome do campo (ex: "email" → type: 'email')
|
|
10
|
+
* - Tipo do valor (ex: boolean → type: 'boolean')
|
|
11
|
+
* - Padrões comuns (ex: "description" → type: 'textarea')
|
|
12
|
+
*
|
|
13
|
+
* Para exemplos completos de configuração manual, veja o README (Tutorial CRUD de Examples).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* interface Employee {
|
|
18
|
+
* id: string;
|
|
19
|
+
* name: string;
|
|
20
|
+
* email: string;
|
|
21
|
+
* is_active: boolean;
|
|
22
|
+
* description: string;
|
|
23
|
+
* created_at: string;
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* const config = generateCrudConfig<Employee>(
|
|
27
|
+
* 'Funcionários',
|
|
28
|
+
* { name: '', email: '', is_active: true, description: '' }
|
|
29
|
+
* );
|
|
30
|
+
*
|
|
31
|
+
* // Resultado:
|
|
32
|
+
* // {
|
|
33
|
+
* // title: 'Funcionários',
|
|
34
|
+
* // columns: [
|
|
35
|
+
* // { key: 'name', header: 'Name', type: 'text', sortable: true },
|
|
36
|
+
* // { key: 'email', header: 'Email', type: 'email', sortable: true },
|
|
37
|
+
* // { key: 'is_active', header: 'Is Active', type: 'boolean' },
|
|
38
|
+
* // { key: 'description', header: 'Description', type: 'textarea' }
|
|
39
|
+
* // ],
|
|
40
|
+
* // searchPlaceholder: 'Buscar funcionários...',
|
|
41
|
+
* // enableCreate: true,
|
|
42
|
+
* // enableEdit: true,
|
|
43
|
+
* // enableDelete: true
|
|
44
|
+
* // }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* // Com overrides para customizar
|
|
50
|
+
* const config = generateCrudConfig<Employee>(
|
|
51
|
+
* 'Funcionários',
|
|
52
|
+
* { name: '', email: '', status: 'active' },
|
|
53
|
+
* {
|
|
54
|
+
* enableDelete: false, // Desabilita exclusão
|
|
55
|
+
* itemsPerPage: 25, // Customiza paginação
|
|
56
|
+
* columns: [ // Sobrescreve colunas específicas
|
|
57
|
+
* { key: 'status', header: 'Status', type: 'select',
|
|
58
|
+
* options: ['active', 'inactive', 'pending'] }
|
|
59
|
+
* ]
|
|
60
|
+
* }
|
|
61
|
+
* );
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @param title Título da página/entidade (ex: 'Funcionários')
|
|
65
|
+
* @param sampleEntity Objeto com campos da entidade (valores podem ser vazios)
|
|
66
|
+
* @param overrides Sobrescreve configurações auto-geradas
|
|
67
|
+
*
|
|
68
|
+
* @returns Configuração CRUD completa pronta para usar com createCrudPage
|
|
69
|
+
*
|
|
70
|
+
* @see {@link withPreset} - Para usar presets prontos (user, product, order, category)
|
|
71
|
+
* @see {@link crudPresets} - Presets disponíveis
|
|
72
|
+
*/
|
|
73
|
+
export declare function generateCrudConfig<T extends EntityWithId>(title: string, sampleEntity: Partial<T>, overrides?: Partial<CrudConfig<T>>): CrudConfig<T>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FormField } from '../../types';
|
|
2
|
+
export declare function useBaseForm<T extends Record<string, any>>(fields: FormField[], initialData?: Partial<T>, onFormDataChange?: (data: T) => void, open?: boolean): {
|
|
3
|
+
formData: T;
|
|
4
|
+
errors: Record<string, string>;
|
|
5
|
+
updateField: (fieldName: string, value: any) => void;
|
|
6
|
+
validateForm: () => boolean;
|
|
7
|
+
handleSubmit: (onSubmit: (data: T) => void) => (e?: React.FormEvent) => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook genérico para operações CRUD com React Query
|
|
3
|
+
*
|
|
4
|
+
* **USO AVANÇADO** - Para a maioria dos casos, use `createSimpleService` que já retorna este hook.
|
|
5
|
+
*
|
|
6
|
+
* Fornece gerenciamento completo de estado para operações CRUD:
|
|
7
|
+
* - ✅ Busca, ordenação e paginação via URL params
|
|
8
|
+
* - ✅ Cache inteligente com React Query
|
|
9
|
+
* - ✅ Mutations com feedback automático (toasts)
|
|
10
|
+
* - ✅ Seleção múltipla e ações em massa
|
|
11
|
+
* - ✅ Invalidação automática de cache
|
|
12
|
+
* - ✅ Estados de loading separados por operação
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // Normalmente você NÃO usa este hook diretamente, mas sim via createSimpleService:
|
|
17
|
+
* const { useCrudHook } = createSimpleService({ tableName: 'employees', ... });
|
|
18
|
+
* const manager = useCrudHook();
|
|
19
|
+
*
|
|
20
|
+
* // manager retorna:
|
|
21
|
+
* const {
|
|
22
|
+
* entities, // Array de dados
|
|
23
|
+
* isLoading, // Loading inicial
|
|
24
|
+
* isCreating, // Loading ao criar
|
|
25
|
+
* isUpdating, // Loading ao atualizar
|
|
26
|
+
* isDeleting, // Loading ao deletar
|
|
27
|
+
*
|
|
28
|
+
* createEntity, // Função para criar
|
|
29
|
+
* updateEntity, // Função para atualizar
|
|
30
|
+
* deleteEntity, // Função para deletar
|
|
31
|
+
*
|
|
32
|
+
* pagination: {
|
|
33
|
+
* currentPage,
|
|
34
|
+
* totalPages,
|
|
35
|
+
* totalItems,
|
|
36
|
+
* hasNextPage
|
|
37
|
+
* },
|
|
38
|
+
*
|
|
39
|
+
* handleSearch, // Função para busca
|
|
40
|
+
* handleSort, // Função para ordenação
|
|
41
|
+
* handlePageChange, // Função para paginação
|
|
42
|
+
*
|
|
43
|
+
* selectedIds, // IDs selecionados (bulk)
|
|
44
|
+
* selectAll, // Selecionar todos
|
|
45
|
+
* bulkDelete // Deletar selecionados
|
|
46
|
+
* } = manager;
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @param config Configuração do hook
|
|
50
|
+
* @param config.queryKey Chave única para cache do React Query
|
|
51
|
+
* @param config.service Service com métodos getAll, create, update, delete
|
|
52
|
+
* @param config.entityName Nome da entidade para mensagens de toast
|
|
53
|
+
* @param config.searchFields Campos para busca (opcional, default no service)
|
|
54
|
+
* @param config.additionalFilters Filtros adicionais sempre aplicados
|
|
55
|
+
* @param config.onSuccess Callback executado após create/update com sucesso
|
|
56
|
+
*
|
|
57
|
+
* @returns Manager completo com dados, estados e funções de CRUD
|
|
58
|
+
*
|
|
59
|
+
* @see {@link createSimpleService} - Método recomendado que já usa este hook
|
|
60
|
+
*/
|
|
61
|
+
interface CrudService<T, TInsert = Partial<T>, TUpdate = Partial<T>> {
|
|
62
|
+
getAll: (params: any) => Promise<any>;
|
|
63
|
+
create: (data: TInsert) => Promise<T>;
|
|
64
|
+
update: (id: string, data: TUpdate) => Promise<T>;
|
|
65
|
+
delete: (id: string) => Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
interface CrudConfig<T, TInsert = Partial<T>, TUpdate = Partial<T>> {
|
|
68
|
+
queryKey: string;
|
|
69
|
+
service: CrudService<T, TInsert, TUpdate>;
|
|
70
|
+
entityName: string;
|
|
71
|
+
searchFields?: string[];
|
|
72
|
+
additionalFilters?: Record<string, any>;
|
|
73
|
+
onSuccess?: () => void;
|
|
74
|
+
}
|
|
75
|
+
export declare function useCrud<T extends {
|
|
76
|
+
id: string;
|
|
77
|
+
}, TInsert = Partial<T>, TUpdate = Partial<T>>({ queryKey, service, entityName, searchFields, additionalFilters, onSuccess }: CrudConfig<T, TInsert, TUpdate>): {
|
|
78
|
+
entities: any;
|
|
79
|
+
pagination: {
|
|
80
|
+
data: any;
|
|
81
|
+
currentPage: any;
|
|
82
|
+
totalPages: any;
|
|
83
|
+
totalItems: any;
|
|
84
|
+
itemsPerPage: any;
|
|
85
|
+
hasNextPage: any;
|
|
86
|
+
hasPreviousPage: any;
|
|
87
|
+
};
|
|
88
|
+
isLoading: boolean;
|
|
89
|
+
isCreating: boolean;
|
|
90
|
+
isUpdating: boolean;
|
|
91
|
+
isDeleting: boolean;
|
|
92
|
+
error: Error;
|
|
93
|
+
searchTerm: string;
|
|
94
|
+
sortField: string;
|
|
95
|
+
sortDirection: "desc" | "asc";
|
|
96
|
+
currentPage: number;
|
|
97
|
+
itemsPerPage: number;
|
|
98
|
+
queryKey: string;
|
|
99
|
+
createEntity: import("@tanstack/react-query").UseMutateFunction<T, any, TInsert, unknown>;
|
|
100
|
+
updateEntity: (id: string, data: TUpdate) => void;
|
|
101
|
+
deleteEntity: import("@tanstack/react-query").UseMutateFunction<void, any, string, unknown>;
|
|
102
|
+
save: (data: any, transform?: (data: any) => any) => void;
|
|
103
|
+
handleSearch: (search: string) => void;
|
|
104
|
+
handleSort: (field: string) => void;
|
|
105
|
+
handlePageChange: (newPage: number) => void;
|
|
106
|
+
handleItemsPerPageChange: (newLimit: number) => void;
|
|
107
|
+
clearFilters: () => void;
|
|
108
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<any, Error>>;
|
|
109
|
+
selectedIds: string[];
|
|
110
|
+
selectItem: (id: string) => void;
|
|
111
|
+
selectAll: () => void;
|
|
112
|
+
clearSelection: () => void;
|
|
113
|
+
isAllSelected: boolean;
|
|
114
|
+
bulkDelete: (ids: string[]) => Promise<void>;
|
|
115
|
+
isBulkDeleting: boolean;
|
|
116
|
+
};
|
|
117
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ActionMenu Primitive Component
|
|
3
|
+
*
|
|
4
|
+
* Menu de ações reutilizável que pode ser renderizado como dropdown ou inline.
|
|
5
|
+
* Suporta ações padrão (Edit, Delete, Toggle) e ações customizadas.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* // Dropdown (padrão)
|
|
10
|
+
* <ActionMenu
|
|
11
|
+
* onEdit={() => console.log('edit')}
|
|
12
|
+
* onDelete={() => console.log('delete')}
|
|
13
|
+
* renderAs="dropdown"
|
|
14
|
+
* />
|
|
15
|
+
*
|
|
16
|
+
* // Inline com ações customizadas
|
|
17
|
+
* <ActionMenu
|
|
18
|
+
* onEdit={() => console.log('edit')}
|
|
19
|
+
* customActions={[
|
|
20
|
+
* { label: 'Duplicar', icon: Copy, onClick: () => {}, variant: 'default' }
|
|
21
|
+
* ]}
|
|
22
|
+
* renderAs="inline"
|
|
23
|
+
* variant="compact"
|
|
24
|
+
* />
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
import type { ActionMenuProps } from './types';
|
|
28
|
+
export declare function ActionMenu({ onEdit, onDelete, onToggleStatus, isActive, canEdit, canDelete, customActions, renderAs, variant }: ActionMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FilterBar Primitive Component
|
|
3
|
+
*
|
|
4
|
+
* Barra de filtros reutilizável com campo de busca e slots para filtros customizados.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <FilterBar
|
|
9
|
+
* searchValue={search}
|
|
10
|
+
* onSearchChange={setSearch}
|
|
11
|
+
* customFilters={[
|
|
12
|
+
* <StatusSelect value={status} onChange={setStatus} />,
|
|
13
|
+
* <CategorySelect value={category} onChange={setCategory} />
|
|
14
|
+
* ]}
|
|
15
|
+
* onClearFilters={() => {
|
|
16
|
+
* setSearch('');
|
|
17
|
+
* setStatus('all');
|
|
18
|
+
* setCategory('all');
|
|
19
|
+
* }}
|
|
20
|
+
* />
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import type { FilterBarProps } from './types';
|
|
24
|
+
export declare function FilterBar({ searchValue, onSearchChange, customFilters, onClearFilters, showClearButton, layout }: FilterBarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pagination Primitive Component
|
|
3
|
+
*
|
|
4
|
+
* Controles de paginação reutilizáveis sem dependências de CRUD logic.
|
|
5
|
+
*
|
|
6
|
+
* Layout Visual: 3 colunas responsivas
|
|
7
|
+
* [Itens por página: 10 ▼] [1-10 de 100 itens (página 1 de 10)] [<< < | 1 de 10 | > >>]
|
|
8
|
+
* └─ Esquerda └─ Centro └─ Direita
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <Pagination
|
|
13
|
+
* currentPage={1}
|
|
14
|
+
* totalPages={10}
|
|
15
|
+
* totalItems={100}
|
|
16
|
+
* itemsPerPage={10}
|
|
17
|
+
* onPageChange={(page) => setPage(page)}
|
|
18
|
+
* onItemsPerPageChange={(limit) => setLimit(limit)}
|
|
19
|
+
* variant="full"
|
|
20
|
+
* />
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import type { PaginationProps } from "./types";
|
|
24
|
+
export declare function Pagination({ currentPage, totalPages, totalItems, itemsPerPage, onPageChange, onItemsPerPageChange, variant, }: PaginationProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Table Primitive Component
|
|
3
|
+
*
|
|
4
|
+
* Componente de tabela "puro" sem dependências de lógica CRUD.
|
|
5
|
+
* Responsável apenas por renderizar dados em formato tabular com sorting visual.
|
|
6
|
+
* Suporta redimensionamento de colunas via drag (habilitado por padrão).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <Table
|
|
11
|
+
* data={users}
|
|
12
|
+
* columns={[
|
|
13
|
+
* { key: 'name', header: 'Nome', sortable: true },
|
|
14
|
+
* { key: 'email', header: 'Email' }
|
|
15
|
+
* ]}
|
|
16
|
+
* sortField="name"
|
|
17
|
+
* sortDirection="asc"
|
|
18
|
+
* onSort={(field) => console.log('Sort by:', field)}
|
|
19
|
+
* renderActions={(user) => <button>Editar</button>}
|
|
20
|
+
* />
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import type { TableProps } from './types';
|
|
24
|
+
export declare function Table<T extends {
|
|
25
|
+
id: string;
|
|
26
|
+
}>({ data, columns, sortField, sortDirection, onSort, onRowClick, renderActions, isLoading, emptyMessage, className, enableSelection, selectedIds, onSelectItem, onSelectAll, isAllSelected, enableColumnResize, onColumnResize, storageKey }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CRUD Primitives
|
|
3
|
+
*
|
|
4
|
+
* Componentes "puros" sem dependências de lógica CRUD.
|
|
5
|
+
* Use-os quando precisar de controle total sobre o comportamento.
|
|
6
|
+
*/
|
|
7
|
+
export { Table } from './Table';
|
|
8
|
+
export { ActionMenu } from './ActionMenu';
|
|
9
|
+
export { Pagination } from './Pagination';
|
|
10
|
+
export { FilterBar } from './FilterBar';
|
|
11
|
+
export type { TableProps, TableColumn, ActionMenuProps, ActionItem, PaginationProps, FilterBarProps, } from './types';
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface TableColumn<T = any> {
|
|
3
|
+
key: keyof T;
|
|
4
|
+
header: string;
|
|
5
|
+
sortable?: boolean;
|
|
6
|
+
render?: (item: T) => React.ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
minWidth?: number;
|
|
9
|
+
maxWidth?: number;
|
|
10
|
+
weight?: number;
|
|
11
|
+
width?: number;
|
|
12
|
+
resizable?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface TableProps<T> {
|
|
15
|
+
data: T[];
|
|
16
|
+
columns: TableColumn<T>[];
|
|
17
|
+
sortField?: string;
|
|
18
|
+
sortDirection?: 'asc' | 'desc';
|
|
19
|
+
onSort?: (field: string) => void;
|
|
20
|
+
onRowClick?: (item: T) => void;
|
|
21
|
+
renderActions?: (item: T) => React.ReactNode;
|
|
22
|
+
isLoading?: boolean;
|
|
23
|
+
emptyMessage?: string;
|
|
24
|
+
className?: string;
|
|
25
|
+
enableSelection?: boolean;
|
|
26
|
+
selectedIds?: string[];
|
|
27
|
+
onSelectItem?: (id: string) => void;
|
|
28
|
+
onSelectAll?: () => void;
|
|
29
|
+
isAllSelected?: boolean;
|
|
30
|
+
enableColumnResize?: boolean;
|
|
31
|
+
columnWidths?: Record<string, number>;
|
|
32
|
+
onColumnResize?: (widths: Record<string, number>) => void;
|
|
33
|
+
storageKey?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ActionItem {
|
|
36
|
+
label: string;
|
|
37
|
+
icon?: React.ComponentType<{
|
|
38
|
+
size?: number;
|
|
39
|
+
className?: string;
|
|
40
|
+
}>;
|
|
41
|
+
onClick: () => void;
|
|
42
|
+
variant?: 'default' | 'destructive';
|
|
43
|
+
show?: boolean;
|
|
44
|
+
/** Se a ação está desabilitada */
|
|
45
|
+
disabled?: boolean;
|
|
46
|
+
/** Motivo do bloqueio (exibido em tooltip quando disabled=true) */
|
|
47
|
+
disabledReason?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface ActionMenuProps {
|
|
50
|
+
onEdit?: () => void;
|
|
51
|
+
onDelete?: () => void;
|
|
52
|
+
onToggleStatus?: () => void;
|
|
53
|
+
isActive?: boolean;
|
|
54
|
+
canEdit?: boolean;
|
|
55
|
+
canDelete?: boolean;
|
|
56
|
+
customActions?: ActionItem[];
|
|
57
|
+
renderAs?: 'dropdown' | 'inline';
|
|
58
|
+
variant?: 'default' | 'compact';
|
|
59
|
+
}
|
|
60
|
+
export interface PaginationProps {
|
|
61
|
+
currentPage: number;
|
|
62
|
+
totalPages: number;
|
|
63
|
+
totalItems: number;
|
|
64
|
+
itemsPerPage: number;
|
|
65
|
+
onPageChange: (page: number) => void;
|
|
66
|
+
onItemsPerPageChange: (limit: number) => void;
|
|
67
|
+
variant?: 'full' | 'compact';
|
|
68
|
+
}
|
|
69
|
+
export interface FilterBarProps {
|
|
70
|
+
searchValue?: string;
|
|
71
|
+
onSearchChange?: (value: string) => void;
|
|
72
|
+
customFilters?: React.ReactNode[];
|
|
73
|
+
onClearFilters?: () => void;
|
|
74
|
+
showClearButton?: boolean;
|
|
75
|
+
layout?: 'horizontal' | 'vertical';
|
|
76
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CrudEntity } from '../../types';
|
|
2
|
+
export interface RoutingConfig {
|
|
3
|
+
basePath: string;
|
|
4
|
+
newPath?: string;
|
|
5
|
+
editPath?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Creates routing handlers for CRUD operations
|
|
9
|
+
* @param config Configuration for routing paths
|
|
10
|
+
* @returns Object with onNew and onEdit handlers
|
|
11
|
+
*/
|
|
12
|
+
export declare function createRoutingHandlers<T extends CrudEntity>(config: RoutingConfig): {
|
|
13
|
+
onNew: () => void;
|
|
14
|
+
onEdit: (entity: T) => void;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Helper para configurar CRUD com routing customizado
|
|
18
|
+
* @param basePath Base path for the CRUD routes (e.g., '/articles')
|
|
19
|
+
* @param config Optional custom paths
|
|
20
|
+
* @returns Configuration object for CrudPageConfig
|
|
21
|
+
*/
|
|
22
|
+
export declare function createCrudRoutingConfig<T extends CrudEntity>(basePath: string, config?: {
|
|
23
|
+
newPath?: string;
|
|
24
|
+
editPath?: string;
|
|
25
|
+
preservePagination?: boolean;
|
|
26
|
+
}): {
|
|
27
|
+
useCustomRouting: boolean;
|
|
28
|
+
onNew: () => void;
|
|
29
|
+
onEdit: (entity: T) => void;
|
|
30
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { createSimpleService } from '../crud/createSimpleService';
|
|
2
|
+
export { createCrudPage, createSimpleSaveHandler, CrudPageInternal } from '../crud/createCrudPage';
|
|
3
|
+
export { generateCrudConfig } from '../crud/generateCrudConfig';
|
|
4
|
+
export { default as BaseForm } from '../crud/components/BaseForm';
|
|
5
|
+
export { CrudTable } from '../crud/components/CrudTable';
|
|
6
|
+
export { CrudGrid } from '../crud/components/CrudGrid';
|
|
7
|
+
export type { CrudGridProps } from '../crud/components/CrudGrid';
|
|
8
|
+
export { FilterBar } from '../crud/components/FilterBar';
|
|
9
|
+
export { CrudPagination } from '../crud/components/CrudPagination';
|
|
10
|
+
export { TableRowActions } from '../crud/components/TableRowActions';
|
|
11
|
+
export { ActionMenuItems } from '../crud/components/ActionMenuItems';
|
|
12
|
+
export { CrudActionBar } from '../crud/components/CrudActionBar';
|
|
13
|
+
export type { CrudActionBarProps, CustomAction, ViewMode as CrudViewMode } from '../crud/components/CrudActionBar';
|
|
14
|
+
export { useCrud } from '../crud/hooks/useCrud';
|
|
15
|
+
export { useBaseForm } from '../crud/hooks/useBaseForm';
|
|
16
|
+
export { Table as CrudPrimitiveTable } from '../crud/primitives/Table';
|
|
17
|
+
export { ActionMenu } from '../crud/primitives/ActionMenu';
|
|
18
|
+
export { Pagination as CrudPrimitivePagination } from '../crud/primitives/Pagination';
|
|
19
|
+
export { FilterBar as CrudPrimitiveFilterBar } from '../crud/primitives/FilterBar';
|
|
20
|
+
export type { TableProps as CrudPrimitiveTableProps, TableColumn, ActionMenuProps, ActionItem, PaginationProps as CrudPrimitivePaginationProps, FilterBarProps as CrudPrimitiveFilterBarProps, } from '../crud/primitives/types';
|
|
21
|
+
export * from '../crud/utils/routingHelpers';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { getSupabaseClient } from '../supabase/SupabaseSingleton';
|
|
2
|
+
export * from '../qualiex/components/QualiexUserField';
|
|
3
|
+
export * from '../qualiex/hooks/useQualiexUsers';
|
|
4
|
+
export * from '../qualiex/services/qualiexApi';
|
|
5
|
+
export * from '../qualiex/utils/QualiexErrorInterceptor';
|
|
6
|
+
export * from '../auth/contexts/AuthContext';
|
|
7
|
+
export * from '../auth/components/ProtectedRoute';
|
|
8
|
+
export * from '../auth/components/UserInfo';
|
|
9
|
+
export * from '../auth/pages/CallbackPage';
|
|
10
|
+
export * from '../auth/services/AuthService';
|
|
11
|
+
export { TokenManager } from '../auth/services/TokenManager';
|
|
12
|
+
export * from '../auth/services/TokenService';
|
|
13
|
+
export * from '../auth/utils/ErrorInterceptor';
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export * from '../components/ui/accordion';
|
|
2
|
+
export * from '../components/ui/alert';
|
|
3
|
+
export * from '../components/ui/alert-dialog';
|
|
4
|
+
export * from '../components/ui/avatar';
|
|
5
|
+
export * from '../components/ui/breadcrumb';
|
|
6
|
+
export * from '../components/ui/button';
|
|
7
|
+
export * from '../components/ui/button-group';
|
|
8
|
+
export * from '../components/ui/badge';
|
|
9
|
+
export * from '../components/ui/calendar';
|
|
10
|
+
export * from '../components/ui/card';
|
|
11
|
+
export * from '../components/ui/checkbox';
|
|
12
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent } from '../components/ui/collapsible';
|
|
13
|
+
export * from '../components/ui/color-picker';
|
|
14
|
+
export * from '../components/ui/command';
|
|
15
|
+
export * from '../components/ui/context-menu';
|
|
16
|
+
export * from '../components/ui/data-list';
|
|
17
|
+
export * from '../components/ui/date-picker';
|
|
18
|
+
export * from '../components/ui/dialog';
|
|
19
|
+
export * from '../components/ui/drawer';
|
|
20
|
+
export * from '../components/ui/dropdown-menu';
|
|
21
|
+
export * from '../components/ui/disabled-menu-item';
|
|
22
|
+
export * from '../components/ui/empty-state';
|
|
23
|
+
export { Combobox, type ComboboxProps } from '../components/ui/combobox';
|
|
24
|
+
export { Combobox as SelectSearch } from '../components/ui/combobox';
|
|
25
|
+
export type { ComboboxProps as SelectSearchProps } from '../components/ui/combobox';
|
|
26
|
+
export { Combobox as MultiSelect } from '../components/ui/combobox';
|
|
27
|
+
export type { ComboboxProps as MultiSelectProps } from '../components/ui/combobox';
|
|
28
|
+
export { Combobox as EntitySelect } from '../components/ui/combobox';
|
|
29
|
+
export type { ComboboxProps as EntitySelectProps } from '../components/ui/combobox';
|
|
30
|
+
export * from '../components/ui/form';
|
|
31
|
+
export * from '../components/ui/grid';
|
|
32
|
+
export * from '../components/ui/hover-card';
|
|
33
|
+
export * from '../components/ui/icon-picker';
|
|
34
|
+
export * from '../components/ui/input';
|
|
35
|
+
export * from '../components/ui/input-group';
|
|
36
|
+
export * from '../components/ui/label';
|
|
37
|
+
export { LoadingState } from '../components/ui/loading-state';
|
|
38
|
+
export * from '../components/ui/typography';
|
|
39
|
+
export * from '../components/ui/navigation-menu';
|
|
40
|
+
export * from '../components/ui/page-breadcrumb';
|
|
41
|
+
export * from '../components/ui/pagination';
|
|
42
|
+
export * from '../components/ui/popover';
|
|
43
|
+
export * from '../components/ui/progress';
|
|
44
|
+
export * from '../components/ui/radio-group';
|
|
45
|
+
export * from '../components/ui/resizable';
|
|
46
|
+
export * from '../components/ui/scroll-area';
|
|
47
|
+
export * from '../components/ui/select';
|
|
48
|
+
export * from '../components/ui/separator';
|
|
49
|
+
export * from '../components/ui/sheet';
|
|
50
|
+
export * from '../components/ui/sidebar';
|
|
51
|
+
export * from '../components/ui/skeleton';
|
|
52
|
+
export * from '../components/ui/skeleton-variants';
|
|
53
|
+
export * from '../components/ui/slider';
|
|
54
|
+
export { Toaster as SonnerToaster, toast as sonnerToast } from '../components/ui/sonner';
|
|
55
|
+
export * from '../components/ui/spinner';
|
|
56
|
+
export * from '../components/ui/switch';
|
|
57
|
+
export * from '../components/ui/stack';
|
|
58
|
+
export * from '../components/ui/table';
|
|
59
|
+
export { TableResizeHandle } from '../components/ui/table-resize-handle';
|
|
60
|
+
export * from '../components/ui/tabs';
|
|
61
|
+
export * from '../components/ui/tab-page-layout';
|
|
62
|
+
export * from '../components/ui/textarea';
|
|
63
|
+
export * from '../components/ui/toggle';
|
|
64
|
+
export * from '../components/ui/toggle-group';
|
|
65
|
+
export * from '../components/ui/tooltip';
|
|
66
|
+
export * from '../components/ui/truncated-cell';
|
|
67
|
+
export * from '../components/ui/action-button';
|
|
68
|
+
export * from '../components/ui/menubar';
|
|
69
|
+
export * from '../components/ui/chart';
|
|
70
|
+
export * from '../components/ui/rich-text-editor';
|
|
71
|
+
export * from '../components/ui/onboarding-dialog';
|
|
72
|
+
export * from '../components/ui/split-button';
|
|
73
|
+
export * from '../components/ui/step-selector';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
interface UseActiveModulesOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Hook para buscar módulos ativos da empresa/unidade atual
|
|
6
|
+
*
|
|
7
|
+
* Útil para controlar features disponíveis baseado em módulos contratados.
|
|
8
|
+
* Usa cache do React Query para evitar chamadas repetidas.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { useActiveModules } from 'forlogic-core/modular';
|
|
13
|
+
*
|
|
14
|
+
* function App() {
|
|
15
|
+
* const { data: modules, isLoading } = useActiveModules();
|
|
16
|
+
*
|
|
17
|
+
* const hasTrainingModule = modules?.some(m => m.name === 'training');
|
|
18
|
+
*
|
|
19
|
+
* return (
|
|
20
|
+
* <nav>
|
|
21
|
+
* {hasTrainingModule && <Link to="/training">Treinamentos</Link>}
|
|
22
|
+
* </nav>
|
|
23
|
+
* );
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* // Com enabled condicional
|
|
30
|
+
* function FeatureSettings() {
|
|
31
|
+
* const { isAuthenticated } = useAuth();
|
|
32
|
+
*
|
|
33
|
+
* const { data: modules } = useActiveModules({
|
|
34
|
+
* enabled: isAuthenticated
|
|
35
|
+
* });
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @param options Opções de configuração
|
|
40
|
+
* @param options.enabled Se false, não executa a query (default: true)
|
|
41
|
+
*
|
|
42
|
+
* @returns Query result com array de módulos ativos
|
|
43
|
+
*/
|
|
44
|
+
export declare const useActiveModules: (options?: UseActiveModulesOptions) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface ColumnConfig {
|
|
2
|
+
key: string;
|
|
3
|
+
minWidth?: number;
|
|
4
|
+
maxWidth?: number;
|
|
5
|
+
defaultWidth?: number;
|
|
6
|
+
}
|
|
7
|
+
interface UseColumnResizeProps {
|
|
8
|
+
columns: ColumnConfig[];
|
|
9
|
+
storageKey?: string;
|
|
10
|
+
onResize?: (widths: Record<string, number>) => void;
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface UseColumnResizeReturn {
|
|
14
|
+
columnWidths: Record<string, number>;
|
|
15
|
+
isDragging: boolean;
|
|
16
|
+
activeColumn: string | null;
|
|
17
|
+
handleMouseDown: (columnKey: string, e: React.MouseEvent) => void;
|
|
18
|
+
resetWidths: () => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function useColumnResize({ columns, storageKey, onResize, enabled }: UseColumnResizeProps): UseColumnResizeReturn;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook para aplicar debounce em um valor com capacidade de cancelamento
|
|
3
|
+
*
|
|
4
|
+
* Útil para otimizar chamadas de API em campos de busca, evitando requisições
|
|
5
|
+
* a cada tecla digitada. Aguarda o usuário parar de digitar antes de processar.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { useDebounce } from 'forlogic-core/modular';
|
|
10
|
+
*
|
|
11
|
+
* function SearchInput() {
|
|
12
|
+
* const [searchTerm, setSearchTerm] = useState('');
|
|
13
|
+
* const [debouncedSearch, cancelDebounce] = useDebounce(searchTerm, 500);
|
|
14
|
+
*
|
|
15
|
+
* // API é chamada apenas quando usuário para de digitar por 500ms
|
|
16
|
+
* const { data } = useQuery({
|
|
17
|
+
* queryKey: ['search', debouncedSearch],
|
|
18
|
+
* queryFn: () => api.search(debouncedSearch),
|
|
19
|
+
* enabled: debouncedSearch.length > 0
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* return (
|
|
23
|
+
* <input
|
|
24
|
+
* value={searchTerm}
|
|
25
|
+
* onChange={(e) => setSearchTerm(e.target.value)}
|
|
26
|
+
* />
|
|
27
|
+
* );
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* // Com cancelamento manual
|
|
34
|
+
* function AutoSave() {
|
|
35
|
+
* const [content, setContent] = useState('');
|
|
36
|
+
* const [debouncedContent, cancelAutoSave] = useDebounce(content, 2000);
|
|
37
|
+
*
|
|
38
|
+
* useEffect(() => {
|
|
39
|
+
* if (debouncedContent) {
|
|
40
|
+
* saveToServer(debouncedContent);
|
|
41
|
+
* }
|
|
42
|
+
* }, [debouncedContent]);
|
|
43
|
+
*
|
|
44
|
+
* const handleManualSave = () => {
|
|
45
|
+
* cancelAutoSave(); // Cancela auto-save pendente
|
|
46
|
+
* saveToServer(content); // Salva imediatamente
|
|
47
|
+
* };
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param value Valor a ser debounced (qualquer tipo)
|
|
52
|
+
* @param delay Delay em milissegundos antes de aplicar o valor
|
|
53
|
+
*
|
|
54
|
+
* @returns Tupla [valor com debounce, função para cancelar]
|
|
55
|
+
*/
|
|
56
|
+
export declare function useDebounce<T>(value: T, delay: number): [T, () => void];
|