@maxal_studio/kratosjs-react 1.0.0
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/README.md +44 -0
- package/dist/FieldRenderer.d.ts +13 -0
- package/dist/FieldRenderer.js +62 -0
- package/dist/FormRenderer.d.ts +7 -0
- package/dist/FormRenderer.js +78 -0
- package/dist/TableRenderer.d.ts +2 -0
- package/dist/TableRenderer.js +1 -0
- package/dist/api/actionsApi.d.ts +23 -0
- package/dist/api/actionsApi.js +46 -0
- package/dist/api/authenticatedFetch.d.ts +8 -0
- package/dist/api/authenticatedFetch.js +31 -0
- package/dist/api/exportApi.d.ts +18 -0
- package/dist/api/exportApi.js +50 -0
- package/dist/api/http.d.ts +24 -0
- package/dist/api/http.js +52 -0
- package/dist/api/resourceApi.d.ts +37 -0
- package/dist/api/resourceApi.js +52 -0
- package/dist/api/tableApi.d.ts +83 -0
- package/dist/api/tableApi.js +51 -0
- package/dist/api/urls.d.ts +19 -0
- package/dist/api/urls.js +46 -0
- package/dist/app.d.ts +101 -0
- package/dist/app.js +89 -0
- package/dist/auth/AuthContext.d.ts +22 -0
- package/dist/auth/AuthContext.js +147 -0
- package/dist/auth/LoginPage.d.ts +10 -0
- package/dist/auth/LoginPage.js +179 -0
- package/dist/auth/ProtectedRoute.d.ts +12 -0
- package/dist/auth/ProtectedRoute.js +22 -0
- package/dist/auth/authApiClient.d.ts +24 -0
- package/dist/auth/authApiClient.js +95 -0
- package/dist/auth/types.d.ts +103 -0
- package/dist/auth/types.js +1 -0
- package/dist/components/ActionFormModal.d.ts +22 -0
- package/dist/components/ActionFormModal.js +8 -0
- package/dist/components/AdminPanel.d.ts +11 -0
- package/dist/components/AdminPanel.js +194 -0
- package/dist/components/Checkbox.d.ts +10 -0
- package/dist/components/Checkbox.js +8 -0
- package/dist/components/CheckboxField.d.ts +7 -0
- package/dist/components/CheckboxField.js +26 -0
- package/dist/components/ColorPickerField.d.ts +7 -0
- package/dist/components/ColorPickerField.js +26 -0
- package/dist/components/DateTimePickerField.d.ts +7 -0
- package/dist/components/DateTimePickerField.js +64 -0
- package/dist/components/FileUploadField.d.ts +9 -0
- package/dist/components/FileUploadField.js +478 -0
- package/dist/components/GlobalSearch.d.ts +22 -0
- package/dist/components/GlobalSearch.js +181 -0
- package/dist/components/GroupField.d.ts +7 -0
- package/dist/components/GroupField.js +23 -0
- package/dist/components/HiddenField.d.ts +3 -0
- package/dist/components/HiddenField.js +10 -0
- package/dist/components/ModalBreadcrumb.d.ts +5 -0
- package/dist/components/ModalBreadcrumb.js +33 -0
- package/dist/components/ModalDrawer.d.ts +15 -0
- package/dist/components/ModalDrawer.js +40 -0
- package/dist/components/RadioField.d.ts +7 -0
- package/dist/components/RadioField.js +26 -0
- package/dist/components/RepeaterField.d.ts +3 -0
- package/dist/components/RepeaterField.js +191 -0
- package/dist/components/ResourceModalRenderer.d.ts +10 -0
- package/dist/components/ResourceModalRenderer.js +80 -0
- package/dist/components/RichEditorField.d.ts +3 -0
- package/dist/components/RichEditorField.js +655 -0
- package/dist/components/SectionField.d.ts +9 -0
- package/dist/components/SectionField.js +111 -0
- package/dist/components/SelectField.d.ts +8 -0
- package/dist/components/SelectField.js +523 -0
- package/dist/components/TabsField.d.ts +10 -0
- package/dist/components/TabsField.js +214 -0
- package/dist/components/TagsInputField.d.ts +7 -0
- package/dist/components/TagsInputField.js +172 -0
- package/dist/components/TextInputField.d.ts +7 -0
- package/dist/components/TextInputField.js +44 -0
- package/dist/components/TextareaField.d.ts +7 -0
- package/dist/components/TextareaField.js +31 -0
- package/dist/components/ToggleField.d.ts +7 -0
- package/dist/components/ToggleField.js +57 -0
- package/dist/components/ViewModal.d.ts +25 -0
- package/dist/components/ViewModal.js +159 -0
- package/dist/components/blocks/BlockRenderer.d.ts +7 -0
- package/dist/components/blocks/BlockRenderer.js +36 -0
- package/dist/components/blocks/FormBlockRenderer.d.ts +6 -0
- package/dist/components/blocks/FormBlockRenderer.js +110 -0
- package/dist/components/blocks/TableBlockRenderer.d.ts +6 -0
- package/dist/components/blocks/TableBlockRenderer.js +12 -0
- package/dist/components/blocks/TabsBlockRenderer.d.ts +7 -0
- package/dist/components/blocks/TabsBlockRenderer.js +11 -0
- package/dist/components/blocks/WidgetBlockRenderer.d.ts +6 -0
- package/dist/components/blocks/WidgetBlockRenderer.js +11 -0
- package/dist/components/columns/CheckboxColumnComponent.d.ts +6 -0
- package/dist/components/columns/CheckboxColumnComponent.js +21 -0
- package/dist/components/columns/ColorColumnComponent.d.ts +3 -0
- package/dist/components/columns/ColorColumnComponent.js +11 -0
- package/dist/components/columns/DeeplinkWrapper.d.ts +15 -0
- package/dist/components/columns/DeeplinkWrapper.js +85 -0
- package/dist/components/columns/IconColumnComponent.d.ts +3 -0
- package/dist/components/columns/IconColumnComponent.js +52 -0
- package/dist/components/columns/ImageColumnComponent.d.ts +3 -0
- package/dist/components/columns/ImageColumnComponent.js +98 -0
- package/dist/components/columns/MediaColumnComponent.d.ts +3 -0
- package/dist/components/columns/MediaColumnComponent.js +160 -0
- package/dist/components/columns/SelectColumnComponent.d.ts +6 -0
- package/dist/components/columns/SelectColumnComponent.js +26 -0
- package/dist/components/columns/TagsColumnComponent.d.ts +3 -0
- package/dist/components/columns/TagsColumnComponent.js +18 -0
- package/dist/components/columns/TextColumnComponent.d.ts +11 -0
- package/dist/components/columns/TextColumnComponent.js +107 -0
- package/dist/components/columns/TextInputColumnComponent.d.ts +6 -0
- package/dist/components/columns/TextInputColumnComponent.js +18 -0
- package/dist/components/columns/ToggleColumnComponent.d.ts +6 -0
- package/dist/components/columns/ToggleColumnComponent.js +25 -0
- package/dist/components/columns/VideoColumnComponent.d.ts +3 -0
- package/dist/components/columns/VideoColumnComponent.js +125 -0
- package/dist/components/columns/ViewColumnComponent.d.ts +3 -0
- package/dist/components/columns/ViewColumnComponent.js +7 -0
- package/dist/components/errors/ErrorBoundary.d.ts +23 -0
- package/dist/components/errors/ErrorBoundary.js +33 -0
- package/dist/components/filters/CustomFilterComponent.d.ts +10 -0
- package/dist/components/filters/CustomFilterComponent.js +33 -0
- package/dist/components/filters/DateFilterComponent.d.ts +15 -0
- package/dist/components/filters/DateFilterComponent.js +132 -0
- package/dist/components/filters/QueryBuilderFilterComponent.d.ts +11 -0
- package/dist/components/filters/QueryBuilderFilterComponent.js +200 -0
- package/dist/components/layout/Header.d.ts +10 -0
- package/dist/components/layout/Header.js +70 -0
- package/dist/components/layout/PanelBrandMark.d.ts +8 -0
- package/dist/components/layout/PanelBrandMark.js +28 -0
- package/dist/components/layout/Sidebar.d.ts +35 -0
- package/dist/components/layout/Sidebar.js +125 -0
- package/dist/components/modals/RelationCreateModal.d.ts +19 -0
- package/dist/components/modals/RelationCreateModal.js +57 -0
- package/dist/components/modals/ResourceFormModal.d.ts +37 -0
- package/dist/components/modals/ResourceFormModal.js +44 -0
- package/dist/components/modals/useResourceForm.d.ts +40 -0
- package/dist/components/modals/useResourceForm.js +138 -0
- package/dist/components/modals/view/RecordActions.d.ts +17 -0
- package/dist/components/modals/view/RecordActions.js +16 -0
- package/dist/components/modals/view/RecordDetails.d.ts +13 -0
- package/dist/components/modals/view/RecordDetails.js +29 -0
- package/dist/components/modals/view/RelationPanel.d.ts +18 -0
- package/dist/components/modals/view/RelationPanel.js +16 -0
- package/dist/components/modals/view/RelationTabs.d.ts +32 -0
- package/dist/components/modals/view/RelationTabs.js +42 -0
- package/dist/components/modals/view/useRecordView.d.ts +18 -0
- package/dist/components/modals/view/useRecordView.js +114 -0
- package/dist/components/pages/PageRenderer.d.ts +6 -0
- package/dist/components/pages/PageRenderer.js +107 -0
- package/dist/components/table/ColumnTogglePopup.d.ts +11 -0
- package/dist/components/table/ColumnTogglePopup.js +16 -0
- package/dist/components/table/GridCard.d.ts +21 -0
- package/dist/components/table/GridCard.js +30 -0
- package/dist/components/table/GridView.d.ts +23 -0
- package/dist/components/table/GridView.js +49 -0
- package/dist/components/table/LayoutToggle.d.ts +7 -0
- package/dist/components/table/LayoutToggle.js +9 -0
- package/dist/components/table/TableActionsDropdown.d.ts +13 -0
- package/dist/components/table/TableActionsDropdown.js +46 -0
- package/dist/components/table/TableBulkActions.d.ts +11 -0
- package/dist/components/table/TableBulkActions.js +21 -0
- package/dist/components/table/TableHeader.d.ts +14 -0
- package/dist/components/table/TableHeader.js +23 -0
- package/dist/components/table/TablePagination.d.ts +13 -0
- package/dist/components/table/TablePagination.js +55 -0
- package/dist/components/table/TableRow.d.ts +21 -0
- package/dist/components/table/TableRow.js +32 -0
- package/dist/components/table/TableSearchBar.d.ts +11 -0
- package/dist/components/table/TableSearchBar.js +12 -0
- package/dist/components/table/TableTabs.d.ts +14 -0
- package/dist/components/table/TableTabs.js +8 -0
- package/dist/components/ui/Badge.d.ts +6 -0
- package/dist/components/ui/Badge.js +12 -0
- package/dist/components/ui/Button.d.ts +22 -0
- package/dist/components/ui/Button.js +22 -0
- package/dist/components/ui/Card.d.ts +7 -0
- package/dist/components/ui/Card.js +5 -0
- package/dist/components/ui/ConfirmDialog.d.ts +19 -0
- package/dist/components/ui/ConfirmDialog.js +45 -0
- package/dist/components/ui/EmptyState.d.ts +9 -0
- package/dist/components/ui/EmptyState.js +6 -0
- package/dist/components/ui/ErrorAlert.d.ts +7 -0
- package/dist/components/ui/ErrorAlert.js +9 -0
- package/dist/components/ui/Input.d.ts +11 -0
- package/dist/components/ui/Input.js +10 -0
- package/dist/components/ui/Label.d.ts +5 -0
- package/dist/components/ui/Label.js +5 -0
- package/dist/components/ui/PillButton.d.ts +14 -0
- package/dist/components/ui/PillButton.js +19 -0
- package/dist/components/ui/Select.d.ts +7 -0
- package/dist/components/ui/Select.js +7 -0
- package/dist/components/ui/Spinner.d.ts +8 -0
- package/dist/components/ui/Spinner.js +14 -0
- package/dist/components/ui/Toast.d.ts +21 -0
- package/dist/components/ui/Toast.js +47 -0
- package/dist/components/ui/index.d.ts +24 -0
- package/dist/components/ui/index.js +12 -0
- package/dist/components/utils/HintDisplay.d.ts +11 -0
- package/dist/components/utils/HintDisplay.js +12 -0
- package/dist/components/utils/Icon.d.ts +22 -0
- package/dist/components/utils/Icon.js +22 -0
- package/dist/components/utils/MediaPreviewModal.d.ts +14 -0
- package/dist/components/utils/MediaPreviewModal.js +32 -0
- package/dist/components/utils/ViewFieldWrapper.d.ts +11 -0
- package/dist/components/utils/ViewFieldWrapper.js +9 -0
- package/dist/components/utils/layoutHelpers.d.ts +19 -0
- package/dist/components/utils/layoutHelpers.js +257 -0
- package/dist/components/widgets/ChartWidget.d.ts +16 -0
- package/dist/components/widgets/ChartWidget.js +192 -0
- package/dist/components/widgets/StatsWidget.d.ts +16 -0
- package/dist/components/widgets/StatsWidget.js +39 -0
- package/dist/components/widgets/WidgetRenderer.d.ts +10 -0
- package/dist/components/widgets/WidgetRenderer.js +50 -0
- package/dist/components/widgets/WidgetShell.d.ts +9 -0
- package/dist/components/widgets/WidgetShell.js +7 -0
- package/dist/contexts/AuthChallengeRegistryContext.d.ts +15 -0
- package/dist/contexts/AuthChallengeRegistryContext.js +15 -0
- package/dist/contexts/BlockRegistryContext.d.ts +18 -0
- package/dist/contexts/BlockRegistryContext.js +8 -0
- package/dist/contexts/ColumnRegistryContext.d.ts +8 -0
- package/dist/contexts/ColumnRegistryContext.js +30 -0
- package/dist/contexts/FieldRegistryContext.d.ts +13 -0
- package/dist/contexts/FieldRegistryContext.js +46 -0
- package/dist/contexts/PanelMetadataContext.d.ts +26 -0
- package/dist/contexts/PanelMetadataContext.js +26 -0
- package/dist/contexts/PanelProviders.d.ts +27 -0
- package/dist/contexts/PanelProviders.js +24 -0
- package/dist/contexts/ResourceModalContext.d.ts +26 -0
- package/dist/contexts/ResourceModalContext.js +76 -0
- package/dist/contexts/SlotRegistryContext.d.ts +19 -0
- package/dist/contexts/SlotRegistryContext.js +24 -0
- package/dist/contexts/TableRefreshContext.d.ts +10 -0
- package/dist/contexts/TableRefreshContext.js +30 -0
- package/dist/contexts/WidgetRegistryContext.d.ts +17 -0
- package/dist/contexts/WidgetRegistryContext.js +14 -0
- package/dist/contexts/createRegistryContext.d.ts +19 -0
- package/dist/contexts/createRegistryContext.js +20 -0
- package/dist/hooks/useAfterStateUpdated.d.ts +6 -0
- package/dist/hooks/useAfterStateUpdated.js +62 -0
- package/dist/hooks/useValidation.d.ts +26 -0
- package/dist/hooks/useValidation.js +76 -0
- package/dist/i18n/I18nProvider.d.ts +27 -0
- package/dist/i18n/I18nProvider.js +101 -0
- package/dist/i18n/LocaleSwitcher.d.ts +10 -0
- package/dist/i18n/LocaleSwitcher.js +30 -0
- package/dist/i18n/activeLocale.d.ts +11 -0
- package/dist/i18n/activeLocale.js +34 -0
- package/dist/i18n/buildClientI18n.d.ts +28 -0
- package/dist/i18n/buildClientI18n.js +67 -0
- package/dist/i18n/index.d.ts +11 -0
- package/dist/i18n/index.js +9 -0
- package/dist/i18n/locales/core/en.d.ts +225 -0
- package/dist/i18n/locales/core/en.js +252 -0
- package/dist/i18n/locales/core/index.d.ts +2 -0
- package/dist/i18n/locales/core/index.js +4 -0
- package/dist/i18n/locales/core/sq.d.ts +253 -0
- package/dist/i18n/locales/core/sq.js +255 -0
- package/dist/i18n/useFormatter.d.ts +18 -0
- package/dist/i18n/useFormatter.js +37 -0
- package/dist/i18n/useLocale.d.ts +11 -0
- package/dist/i18n/useLocale.js +11 -0
- package/dist/i18n/useTranslation.d.ts +12 -0
- package/dist/i18n/useTranslation.js +12 -0
- package/dist/index.d.ts +106 -0
- package/dist/index.js +101 -0
- package/dist/pages/ResourceListPage.d.ts +8 -0
- package/dist/pages/ResourceListPage.js +139 -0
- package/dist/plugin.d.ts +79 -0
- package/dist/plugin.js +34 -0
- package/dist/runtime/conditions.d.ts +35 -0
- package/dist/runtime/conditions.js +97 -0
- package/dist/runtime/formTraversal.d.ts +25 -0
- package/dist/runtime/formTraversal.js +37 -0
- package/dist/runtime/serializedFunctions.d.ts +41 -0
- package/dist/runtime/serializedFunctions.js +264 -0
- package/dist/slots/Slot.d.ts +24 -0
- package/dist/slots/Slot.js +29 -0
- package/dist/slots/SlotCluster.d.ts +22 -0
- package/dist/slots/SlotCluster.js +49 -0
- package/dist/slots/index.d.ts +7 -0
- package/dist/slots/index.js +4 -0
- package/dist/slots/mergeSlots.d.ts +18 -0
- package/dist/slots/mergeSlots.js +35 -0
- package/dist/slots/types.d.ts +87 -0
- package/dist/slots/types.js +30 -0
- package/dist/styles.css +1 -0
- package/dist/table/TableContext.d.ts +36 -0
- package/dist/table/TableContext.js +13 -0
- package/dist/table/TableRenderer.d.ts +29 -0
- package/dist/table/TableRenderer.js +159 -0
- package/dist/table/components/FiltersPanel.d.ts +11 -0
- package/dist/table/components/FiltersPanel.js +52 -0
- package/dist/table/components/TableToolbar.d.ts +28 -0
- package/dist/table/components/TableToolbar.js +27 -0
- package/dist/table/components/TableToolbarButton.d.ts +6 -0
- package/dist/table/components/TableToolbarButton.js +9 -0
- package/dist/table/components/TableView.d.ts +12 -0
- package/dist/table/components/TableView.js +21 -0
- package/dist/table/defaultRowActions.d.ts +21 -0
- package/dist/table/defaultRowActions.js +37 -0
- package/dist/table/hooks/useColumnVisibility.d.ts +13 -0
- package/dist/table/hooks/useColumnVisibility.js +59 -0
- package/dist/table/hooks/useEditableRows.d.ts +22 -0
- package/dist/table/hooks/useEditableRows.js +63 -0
- package/dist/table/hooks/useTableActions.d.ts +54 -0
- package/dist/table/hooks/useTableActions.js +313 -0
- package/dist/table/hooks/useTableData.d.ts +28 -0
- package/dist/table/hooks/useTableData.js +63 -0
- package/dist/table/hooks/useTableLayout.d.ts +12 -0
- package/dist/table/hooks/useTableLayout.js +31 -0
- package/dist/table/hooks/useTableQuery.d.ts +29 -0
- package/dist/table/hooks/useTableQuery.js +135 -0
- package/dist/types/index.d.ts +224 -0
- package/dist/types/index.js +6 -0
- package/dist/utils/classNames.d.ts +7 -0
- package/dist/utils/classNames.js +9 -0
- package/dist/utils/columnMediaDimensions.d.ts +13 -0
- package/dist/utils/columnMediaDimensions.js +29 -0
- package/dist/utils/columnVisibilityStorage.d.ts +22 -0
- package/dist/utils/columnVisibilityStorage.js +56 -0
- package/dist/utils/fieldErrors.d.ts +13 -0
- package/dist/utils/fieldErrors.js +25 -0
- package/dist/utils/formatValue.d.ts +28 -0
- package/dist/utils/formatValue.js +109 -0
- package/dist/utils/layoutStorage.d.ts +23 -0
- package/dist/utils/layoutStorage.js +53 -0
- package/dist/utils/redirectHandler.d.ts +7 -0
- package/dist/utils/redirectHandler.js +25 -0
- package/dist/utils/tableFormatters.d.ts +14 -0
- package/dist/utils/tableFormatters.js +93 -0
- package/dist/utils/widgetVisibilityStorage.d.ts +11 -0
- package/dist/utils/widgetVisibilityStorage.js +39 -0
- package/package.json +101 -0
- package/src/FieldRenderer.test.tsx +44 -0
- package/src/FieldRenderer.tsx +104 -0
- package/src/FormRenderer.containers.test.tsx +121 -0
- package/src/FormRenderer.test.tsx +174 -0
- package/src/FormRenderer.tsx +140 -0
- package/src/TableRenderer.tsx +2 -0
- package/src/api/actionsApi.ts +76 -0
- package/src/api/authenticatedFetch.ts +40 -0
- package/src/api/exportApi.ts +66 -0
- package/src/api/http.test.ts +58 -0
- package/src/api/http.ts +68 -0
- package/src/api/resourceApi.ts +88 -0
- package/src/api/tableApi.test.ts +108 -0
- package/src/api/tableApi.ts +107 -0
- package/src/api/urls.ts +50 -0
- package/src/app.test.tsx +67 -0
- package/src/app.tsx +181 -0
- package/src/auth/AuthContext.tsx +188 -0
- package/src/auth/LoginPage.tsx +380 -0
- package/src/auth/ProtectedRoute.tsx +39 -0
- package/src/auth/authApiClient.ts +109 -0
- package/src/auth/authFlow.test.tsx +168 -0
- package/src/auth/types.ts +104 -0
- package/src/components/ActionFormModal.tsx +45 -0
- package/src/components/AdminPanel.tsx +368 -0
- package/src/components/Checkbox.tsx +59 -0
- package/src/components/CheckboxField.tsx +88 -0
- package/src/components/ColorPickerField.tsx +93 -0
- package/src/components/DateTimePickerField.tsx +112 -0
- package/src/components/FileUploadField.tsx +841 -0
- package/src/components/GlobalSearch.tsx +436 -0
- package/src/components/GroupField.tsx +85 -0
- package/src/components/HiddenField.tsx +14 -0
- package/src/components/ModalBreadcrumb.tsx +74 -0
- package/src/components/ModalDrawer.tsx +137 -0
- package/src/components/RadioField.tsx +80 -0
- package/src/components/RepeaterField.tsx +546 -0
- package/src/components/ResourceModalRenderer.tsx +144 -0
- package/src/components/RichEditorField.tsx +942 -0
- package/src/components/SectionField.tsx +242 -0
- package/src/components/SelectField.tsx +843 -0
- package/src/components/TabsField.test.tsx +151 -0
- package/src/components/TabsField.tsx +386 -0
- package/src/components/TagsInputField.tsx +411 -0
- package/src/components/TextInputField.tsx +91 -0
- package/src/components/TextareaField.tsx +110 -0
- package/src/components/ToggleField.tsx +126 -0
- package/src/components/ViewModal.tsx +353 -0
- package/src/components/blocks/BlockRenderer.tsx +56 -0
- package/src/components/blocks/FormBlockRenderer.tsx +160 -0
- package/src/components/blocks/TableBlockRenderer.tsx +33 -0
- package/src/components/blocks/TabsBlockRenderer.tsx +49 -0
- package/src/components/blocks/WidgetBlockRenderer.tsx +19 -0
- package/src/components/columns/CheckboxColumnComponent.tsx +38 -0
- package/src/components/columns/ColorColumnComponent.tsx +23 -0
- package/src/components/columns/CustomColumn.test.tsx +55 -0
- package/src/components/columns/DeeplinkWrapper.tsx +103 -0
- package/src/components/columns/IconColumnComponent.tsx +55 -0
- package/src/components/columns/ImageColumnComponent.tsx +220 -0
- package/src/components/columns/MediaColumnComponent.tsx +294 -0
- package/src/components/columns/SelectColumnComponent.tsx +49 -0
- package/src/components/columns/TagsColumnComponent.tsx +46 -0
- package/src/components/columns/TextColumnComponent.tsx +191 -0
- package/src/components/columns/TextInputColumnComponent.tsx +35 -0
- package/src/components/columns/ToggleColumnComponent.tsx +56 -0
- package/src/components/columns/VideoColumnComponent.tsx +236 -0
- package/src/components/columns/ViewColumnComponent.tsx +9 -0
- package/src/components/errors/ErrorBoundary.tsx +58 -0
- package/src/components/filters/CustomFilterComponent.tsx +130 -0
- package/src/components/filters/DateFilterComponent.tsx +272 -0
- package/src/components/filters/QueryBuilderFilterComponent.tsx +502 -0
- package/src/components/layout/Header.tsx +212 -0
- package/src/components/layout/PanelBrandMark.tsx +61 -0
- package/src/components/layout/Sidebar.tsx +283 -0
- package/src/components/modals/RelationCreateModal.tsx +107 -0
- package/src/components/modals/ResourceFormModal.test.tsx +119 -0
- package/src/components/modals/ResourceFormModal.tsx +128 -0
- package/src/components/modals/useResourceForm.ts +207 -0
- package/src/components/modals/view/RecordActions.tsx +69 -0
- package/src/components/modals/view/RecordDetails.tsx +60 -0
- package/src/components/modals/view/RelationPanel.tsx +76 -0
- package/src/components/modals/view/RelationTabs.tsx +145 -0
- package/src/components/modals/view/useRecordView.ts +134 -0
- package/src/components/pages/PageRenderer.tsx +173 -0
- package/src/components/table/ColumnTogglePopup.tsx +85 -0
- package/src/components/table/GridCard.tsx +155 -0
- package/src/components/table/GridView.tsx +138 -0
- package/src/components/table/LayoutToggle.tsx +24 -0
- package/src/components/table/TableActionsDropdown.tsx +114 -0
- package/src/components/table/TableBulkActions.tsx +65 -0
- package/src/components/table/TableHeader.tsx +96 -0
- package/src/components/table/TablePagination.tsx +169 -0
- package/src/components/table/TableRow.tsx +155 -0
- package/src/components/table/TableSearchBar.tsx +66 -0
- package/src/components/table/TableTabs.tsx +49 -0
- package/src/components/ui/Badge.tsx +30 -0
- package/src/components/ui/Button.test.tsx +78 -0
- package/src/components/ui/Button.tsx +102 -0
- package/src/components/ui/Card.tsx +23 -0
- package/src/components/ui/ConfirmDialog.tsx +112 -0
- package/src/components/ui/EmptyState.tsx +24 -0
- package/src/components/ui/ErrorAlert.tsx +37 -0
- package/src/components/ui/Input.tsx +48 -0
- package/src/components/ui/Label.tsx +15 -0
- package/src/components/ui/PillButton.tsx +72 -0
- package/src/components/ui/Select.tsx +33 -0
- package/src/components/ui/Spinner.tsx +39 -0
- package/src/components/ui/Toast.tsx +105 -0
- package/src/components/ui/index.ts +24 -0
- package/src/components/utils/HintDisplay.tsx +26 -0
- package/src/components/utils/Icon.tsx +36 -0
- package/src/components/utils/MediaPreviewModal.tsx +114 -0
- package/src/components/utils/ViewFieldWrapper.tsx +23 -0
- package/src/components/utils/layoutHelpers.ts +267 -0
- package/src/components/widgets/ChartWidget.tsx +247 -0
- package/src/components/widgets/StatsWidget.tsx +72 -0
- package/src/components/widgets/WidgetRenderer.tsx +108 -0
- package/src/components/widgets/WidgetShell.tsx +37 -0
- package/src/contexts/AuthChallengeRegistryContext.tsx +29 -0
- package/src/contexts/BlockRegistryContext.tsx +28 -0
- package/src/contexts/ColumnRegistryContext.tsx +38 -0
- package/src/contexts/FieldRegistryContext.tsx +56 -0
- package/src/contexts/PanelMetadataContext.tsx +60 -0
- package/src/contexts/PanelProviders.tsx +85 -0
- package/src/contexts/ResourceModalContext.tsx +137 -0
- package/src/contexts/SlotRegistryContext.tsx +35 -0
- package/src/contexts/TableRefreshContext.tsx +44 -0
- package/src/contexts/WidgetRegistryContext.tsx +34 -0
- package/src/contexts/createRegistryContext.tsx +29 -0
- package/src/hooks/useAfterStateUpdated.ts +70 -0
- package/src/hooks/useValidation.test.ts +59 -0
- package/src/hooks/useValidation.ts +95 -0
- package/src/i18n/I18nProvider.tsx +128 -0
- package/src/i18n/LocaleSwitcher.tsx +50 -0
- package/src/i18n/activeLocale.ts +39 -0
- package/src/i18n/buildClientI18n.ts +101 -0
- package/src/i18n/i18n.test.tsx +140 -0
- package/src/i18n/index.ts +12 -0
- package/src/i18n/locales/core/en.ts +274 -0
- package/src/i18n/locales/core/index.ts +5 -0
- package/src/i18n/locales/core/sq.ts +275 -0
- package/src/i18n/useFormatter.ts +42 -0
- package/src/i18n/useLocale.ts +16 -0
- package/src/i18n/useTranslation.ts +17 -0
- package/src/index.ts +244 -0
- package/src/pages/ResourceListPage.tsx +205 -0
- package/src/plugin.ts +110 -0
- package/src/runtime/conditions.test.ts +99 -0
- package/src/runtime/conditions.ts +148 -0
- package/src/runtime/formTraversal.ts +41 -0
- package/src/runtime/serializedFunctions.test.ts +59 -0
- package/src/runtime/serializedFunctions.ts +284 -0
- package/src/slots/Slot.test.tsx +89 -0
- package/src/slots/Slot.tsx +47 -0
- package/src/slots/SlotCluster.test.tsx +95 -0
- package/src/slots/SlotCluster.tsx +107 -0
- package/src/slots/index.ts +15 -0
- package/src/slots/mergeSlots.test.ts +71 -0
- package/src/slots/mergeSlots.ts +40 -0
- package/src/slots/slotNames.test.ts +21 -0
- package/src/slots/types.ts +119 -0
- package/src/styles.css +437 -0
- package/src/table/TableContext.tsx +41 -0
- package/src/table/TableRenderer.test.tsx +197 -0
- package/src/table/TableRenderer.tsx +390 -0
- package/src/table/components/FiltersPanel.tsx +193 -0
- package/src/table/components/TableToolbar.tsx +153 -0
- package/src/table/components/TableToolbarButton.tsx +14 -0
- package/src/table/components/TableView.tsx +106 -0
- package/src/table/defaultRowActions.ts +43 -0
- package/src/table/hooks/useColumnVisibility.test.ts +51 -0
- package/src/table/hooks/useColumnVisibility.ts +71 -0
- package/src/table/hooks/useEditableRows.test.ts +69 -0
- package/src/table/hooks/useEditableRows.ts +89 -0
- package/src/table/hooks/useTableActions.ts +393 -0
- package/src/table/hooks/useTableData.ts +89 -0
- package/src/table/hooks/useTableLayout.ts +45 -0
- package/src/table/hooks/useTableQuery.test.ts +116 -0
- package/src/table/hooks/useTableQuery.ts +172 -0
- package/src/test/mockFetch.ts +67 -0
- package/src/test/setup.ts +25 -0
- package/src/types/index.ts +228 -0
- package/src/utils/classNames.ts +10 -0
- package/src/utils/columnMediaDimensions.ts +45 -0
- package/src/utils/columnVisibilityStorage.ts +55 -0
- package/src/utils/fieldErrors.test.ts +35 -0
- package/src/utils/fieldErrors.ts +27 -0
- package/src/utils/formatValue.test.tsx +65 -0
- package/src/utils/formatValue.tsx +117 -0
- package/src/utils/layoutStorage.ts +52 -0
- package/src/utils/redirectHandler.ts +29 -0
- package/src/utils/tableFormatters.test.ts +54 -0
- package/src/utils/tableFormatters.ts +104 -0
- package/src/utils/widgetVisibilityStorage.ts +38 -0
- package/tailwind.config.js +9 -0
- package/vite.config.ts +17 -0
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import React, { useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { SerializedTable, SerializedForm } from '@maxal_studio/kratosjs';
|
|
3
|
+
import { cn } from '../utils/classNames';
|
|
4
|
+
import { TableApiClient } from '../api/tableApi';
|
|
5
|
+
import { getFormSchema } from '../api/resourceApi';
|
|
6
|
+
import { deriveApiBaseUrl, resourceSlugFromUrl, resourceStorageKey } from '../api/urls';
|
|
7
|
+
import { useResourceModal } from '../contexts/ResourceModalContext';
|
|
8
|
+
import { WidgetRenderer } from '../components/widgets/WidgetRenderer';
|
|
9
|
+
import { TableTabs } from '../components/table/TableTabs';
|
|
10
|
+
import { TableBulkActions } from '../components/table/TableBulkActions';
|
|
11
|
+
import { TablePagination } from '../components/table/TablePagination';
|
|
12
|
+
import { GridView } from '../components/table/GridView';
|
|
13
|
+
import { ResourceFormModal } from '../components/modals/ResourceFormModal';
|
|
14
|
+
import { ActionFormModal } from '../components/ActionFormModal';
|
|
15
|
+
import { useTableQuery } from './hooks/useTableQuery';
|
|
16
|
+
import { useTableData } from './hooks/useTableData';
|
|
17
|
+
import { useEditableRows } from './hooks/useEditableRows';
|
|
18
|
+
import { useColumnVisibility } from './hooks/useColumnVisibility';
|
|
19
|
+
import { useTableLayout } from './hooks/useTableLayout';
|
|
20
|
+
import { useTableActions } from './hooks/useTableActions';
|
|
21
|
+
import { buildRowActions } from './defaultRowActions';
|
|
22
|
+
import { TableProvider, TableContextValue } from './TableContext';
|
|
23
|
+
import { TableToolbar } from './components/TableToolbar';
|
|
24
|
+
import { Slot } from '../slots/Slot';
|
|
25
|
+
import { TableView } from './components/TableView';
|
|
26
|
+
import { FiltersPanel } from './components/FiltersPanel';
|
|
27
|
+
|
|
28
|
+
export interface TableRendererProps {
|
|
29
|
+
schema: SerializedTable & {
|
|
30
|
+
canCreate?: boolean;
|
|
31
|
+
canEdit?: boolean;
|
|
32
|
+
canDelete?: boolean;
|
|
33
|
+
canView?: boolean;
|
|
34
|
+
};
|
|
35
|
+
isResource: boolean;
|
|
36
|
+
apiUrl: string;
|
|
37
|
+
onBulkAction?: (action: string, selectedIds: any[]) => Promise<void> | void;
|
|
38
|
+
onRowAction?: (action: string, rowId: any) => Promise<void> | void;
|
|
39
|
+
className?: string;
|
|
40
|
+
// For nested tables (relations), specify the actual resource info
|
|
41
|
+
relatedResourceSlug?: string;
|
|
42
|
+
relatedResourceApiUrl?: string;
|
|
43
|
+
// Optional: Override the base API URL for modals (defaults to extracting from apiUrl)
|
|
44
|
+
apiBaseUrl?: string;
|
|
45
|
+
// Stacking depth for modals
|
|
46
|
+
depth?: number;
|
|
47
|
+
// Callback to close all stacked modals
|
|
48
|
+
onCloseAll?: () => void;
|
|
49
|
+
// Optional routing-based handlers (instead of modals)
|
|
50
|
+
onCreateClick?: () => void;
|
|
51
|
+
onEditClick?: (rowId: any) => void;
|
|
52
|
+
onViewClick?: (rowId: any) => void;
|
|
53
|
+
// Capability flags (default true)
|
|
54
|
+
canCreate?: boolean;
|
|
55
|
+
canEdit?: boolean;
|
|
56
|
+
canDelete?: boolean;
|
|
57
|
+
canView?: boolean;
|
|
58
|
+
// Refresh key - increment to trigger a data refresh
|
|
59
|
+
refreshKey?: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function TableRenderer({
|
|
63
|
+
schema,
|
|
64
|
+
isResource = true,
|
|
65
|
+
apiUrl,
|
|
66
|
+
onBulkAction,
|
|
67
|
+
onRowAction,
|
|
68
|
+
className,
|
|
69
|
+
relatedResourceSlug,
|
|
70
|
+
relatedResourceApiUrl,
|
|
71
|
+
apiBaseUrl,
|
|
72
|
+
depth = 0,
|
|
73
|
+
onCloseAll,
|
|
74
|
+
onCreateClick,
|
|
75
|
+
onEditClick,
|
|
76
|
+
onViewClick,
|
|
77
|
+
canCreate = true,
|
|
78
|
+
canEdit = true,
|
|
79
|
+
canDelete = true,
|
|
80
|
+
canView = true,
|
|
81
|
+
refreshKey,
|
|
82
|
+
}: TableRendererProps) {
|
|
83
|
+
const { openModal, closeModal } = useResourceModal();
|
|
84
|
+
|
|
85
|
+
// Derived identifiers
|
|
86
|
+
const computedApiBaseUrl = apiBaseUrl || deriveApiBaseUrl(apiUrl);
|
|
87
|
+
const resourceSlug = relatedResourceSlug || resourceSlugFromUrl(apiUrl);
|
|
88
|
+
const resourceKey = useMemo(
|
|
89
|
+
() => resourceStorageKey(apiUrl, isResource, relatedResourceSlug),
|
|
90
|
+
[apiUrl, isResource, relatedResourceSlug],
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const apiClient = useMemo(
|
|
94
|
+
() => new TableApiClient(computedApiBaseUrl, apiUrl, isResource ? '/list' : ''),
|
|
95
|
+
[computedApiBaseUrl, apiUrl, isResource],
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
// Query + data + change tracking
|
|
99
|
+
const query = useTableQuery(schema);
|
|
100
|
+
const editableRef = useRef<(rows: any[]) => void>(() => {});
|
|
101
|
+
const table = useTableData({
|
|
102
|
+
apiClient,
|
|
103
|
+
queryParams: query.queryParams,
|
|
104
|
+
refreshKey,
|
|
105
|
+
onLoaded: rows => editableRef.current(rows),
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const editable = useEditableRows({
|
|
109
|
+
data: table.data,
|
|
110
|
+
setData: table.setData,
|
|
111
|
+
saveRecord: async (rowId, changes) => {
|
|
112
|
+
// Relation tables save through the related resource's own endpoint
|
|
113
|
+
if (relatedResourceSlug) {
|
|
114
|
+
const relatedApiUrl = relatedResourceApiUrl || `${computedApiBaseUrl}/${relatedResourceSlug}`;
|
|
115
|
+
const relatedClient = new TableApiClient(computedApiBaseUrl, relatedApiUrl, '/list');
|
|
116
|
+
await relatedClient.updateRecord(rowId, changes);
|
|
117
|
+
} else {
|
|
118
|
+
await apiClient.updateRecord(rowId, changes);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
onSaveError: () => table.setError('Failed to save changes. Please try again.'),
|
|
122
|
+
});
|
|
123
|
+
editableRef.current = editable.resetTracking;
|
|
124
|
+
|
|
125
|
+
// Presentation state
|
|
126
|
+
const columns = useColumnVisibility(schema.columns, resourceKey);
|
|
127
|
+
const layoutState = useTableLayout(schema, resourceSlug);
|
|
128
|
+
const [openActionsRowId, setOpenActionsRowId] = useState<any>(null);
|
|
129
|
+
|
|
130
|
+
// Row + bulk actions
|
|
131
|
+
const actions = useTableActions({
|
|
132
|
+
schema,
|
|
133
|
+
apiClient,
|
|
134
|
+
apiBaseUrl: computedApiBaseUrl,
|
|
135
|
+
resourceSlug,
|
|
136
|
+
relatedResourceSlug,
|
|
137
|
+
relatedResourceApiUrl,
|
|
138
|
+
apiUrl,
|
|
139
|
+
canEdit,
|
|
140
|
+
canDelete,
|
|
141
|
+
canView,
|
|
142
|
+
data: table.data,
|
|
143
|
+
reload: table.reload,
|
|
144
|
+
setError: table.setError,
|
|
145
|
+
setIsLoading: table.setIsLoading,
|
|
146
|
+
getQueryParams: () => query.queryParams,
|
|
147
|
+
onRowAction,
|
|
148
|
+
onBulkAction,
|
|
149
|
+
onEditClick,
|
|
150
|
+
onViewClick,
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// Create modal
|
|
154
|
+
const [createModalOpen, setCreateModalOpen] = useState(false);
|
|
155
|
+
const [createFormSchema, setCreateFormSchema] = useState<SerializedForm | null>(null);
|
|
156
|
+
|
|
157
|
+
const handleCreateModalOpen = async () => {
|
|
158
|
+
if (!createFormSchema) {
|
|
159
|
+
try {
|
|
160
|
+
setCreateFormSchema(await getFormSchema(computedApiBaseUrl, resourceSlug));
|
|
161
|
+
} catch (err) {
|
|
162
|
+
console.error('Error loading form schema:', err);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
openModal(resourceSlug, 'create');
|
|
166
|
+
setCreateModalOpen(true);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// Reset the cached create schema when the resource changes
|
|
170
|
+
React.useEffect(() => {
|
|
171
|
+
setCreateFormSchema(null);
|
|
172
|
+
}, [apiUrl]);
|
|
173
|
+
|
|
174
|
+
const handleCloseAll = () => {
|
|
175
|
+
setCreateModalOpen(false);
|
|
176
|
+
onCloseAll?.();
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// Built-in view/edit/delete row actions are derived from capability flags;
|
|
180
|
+
// custom actions from the schema are merged in (delete stays last).
|
|
181
|
+
const visibleActions = useMemo(
|
|
182
|
+
() => buildRowActions(schema.actions, { canView, canEdit, canDelete }),
|
|
183
|
+
[schema.actions, canEdit, canDelete, canView],
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
const filtersLayout = schema.filtersLayout || 'inline';
|
|
187
|
+
const hasWidgets =
|
|
188
|
+
!relatedResourceSlug && schema.widgets && Array.isArray(schema.widgets) && schema.widgets.length > 0;
|
|
189
|
+
|
|
190
|
+
const tableContext: TableContextValue = {
|
|
191
|
+
schema,
|
|
192
|
+
visibleColumns: columns.visibleColumns,
|
|
193
|
+
visibleActions,
|
|
194
|
+
data: table.data,
|
|
195
|
+
isLoading: table.isLoading,
|
|
196
|
+
error: table.error,
|
|
197
|
+
setError: table.setError,
|
|
198
|
+
selectedRows: actions.selectedRows,
|
|
199
|
+
changedRows: editable.changedRows,
|
|
200
|
+
openActionsRowId,
|
|
201
|
+
onToggleActions: id => setOpenActionsRowId(openActionsRowId === id ? null : id),
|
|
202
|
+
onRowSelect: actions.handleRowSelect,
|
|
203
|
+
onSelectAll: actions.handleSelectAll,
|
|
204
|
+
onCellChange: editable.handleCellChange,
|
|
205
|
+
onRowAction: actions.handleRowAction,
|
|
206
|
+
onSaveRow: editable.handleSaveRow,
|
|
207
|
+
onResetRow: editable.handleResetRow,
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<TableProvider value={tableContext}>
|
|
212
|
+
<div className={cn('w-full', className)}>
|
|
213
|
+
{hasWidgets && (
|
|
214
|
+
<WidgetRenderer
|
|
215
|
+
widgets={schema.widgets}
|
|
216
|
+
widgetData={table.widgetData}
|
|
217
|
+
className={cn(layoutState.widgetsExpanded ? 'mb-4' : 'mb-0')}
|
|
218
|
+
expanded={layoutState.widgetsExpanded}
|
|
219
|
+
onExpandedChange={layoutState.setWidgetsExpanded}
|
|
220
|
+
/>
|
|
221
|
+
)}
|
|
222
|
+
|
|
223
|
+
{/* Tabs, search, filters */}
|
|
224
|
+
<div className="mb-4 space-y-4 p-1 sm:p-0">
|
|
225
|
+
{schema.tabs && Array.isArray(schema.tabs) && schema.tabs.length > 0 && (
|
|
226
|
+
<TableTabs tabs={schema.tabs} activeTab={query.activeTab} onTabChange={query.handleTabClick} />
|
|
227
|
+
)}
|
|
228
|
+
|
|
229
|
+
<TableToolbar
|
|
230
|
+
schema={schema}
|
|
231
|
+
query={query}
|
|
232
|
+
layout={layoutState.layout}
|
|
233
|
+
onLayoutChange={layoutState.setLayout}
|
|
234
|
+
visibleColumnNames={columns.visibleColumnNames}
|
|
235
|
+
onColumnToggle={columns.handleColumnToggle}
|
|
236
|
+
showCreateButton={canCreate}
|
|
237
|
+
onCreateClick={onCreateClick}
|
|
238
|
+
onCreateModalOpen={handleCreateModalOpen}
|
|
239
|
+
onHeaderAction={actions.handleHeaderAction}
|
|
240
|
+
showWidgetsToggle={hasWidgets}
|
|
241
|
+
widgetsExpanded={layoutState.widgetsExpanded}
|
|
242
|
+
onWidgetsToggle={() => layoutState.setWidgetsExpanded(!layoutState.widgetsExpanded)}
|
|
243
|
+
/>
|
|
244
|
+
|
|
245
|
+
{schema.filters && schema.filters.length > 0 && filtersLayout === 'inline' && (
|
|
246
|
+
<FiltersPanel
|
|
247
|
+
filters={schema.filters}
|
|
248
|
+
values={query.filters}
|
|
249
|
+
queryBuilderValues={query.queryBuilders}
|
|
250
|
+
onChange={query.handleFilterChange}
|
|
251
|
+
onClear={query.handleClearFilters}
|
|
252
|
+
layout="inline"
|
|
253
|
+
/>
|
|
254
|
+
)}
|
|
255
|
+
</div>
|
|
256
|
+
|
|
257
|
+
{/* Bulk actions toolbar */}
|
|
258
|
+
<TableBulkActions
|
|
259
|
+
schema={schema}
|
|
260
|
+
selectedCount={actions.selectedRows.size}
|
|
261
|
+
onBulkAction={actionName => actions.handleBulkAction(actionName, Array.from(actions.selectedRows))}
|
|
262
|
+
onClearSelection={actions.clearSelection}
|
|
263
|
+
canDelete={canDelete}
|
|
264
|
+
/>
|
|
265
|
+
|
|
266
|
+
{actions.selectedRows.size > 0 && (
|
|
267
|
+
<Slot
|
|
268
|
+
name="table.bulkActions"
|
|
269
|
+
context={{
|
|
270
|
+
schema,
|
|
271
|
+
resourceSlug: resourceSlugFromUrl(apiUrl),
|
|
272
|
+
data: {
|
|
273
|
+
selectedCount: actions.selectedRows.size,
|
|
274
|
+
selectedIds: Array.from(actions.selectedRows),
|
|
275
|
+
},
|
|
276
|
+
}}
|
|
277
|
+
as="div"
|
|
278
|
+
className="mb-4 flex flex-wrap items-center gap-2 empty:hidden"
|
|
279
|
+
/>
|
|
280
|
+
)}
|
|
281
|
+
|
|
282
|
+
<Slot
|
|
283
|
+
name="table.aboveTable"
|
|
284
|
+
context={{ schema, resourceSlug: resourceSlugFromUrl(apiUrl) }}
|
|
285
|
+
as="div"
|
|
286
|
+
className="mb-3 space-y-3 empty:hidden"
|
|
287
|
+
/>
|
|
288
|
+
|
|
289
|
+
{/* Table or Grid view with integrated pagination footer */}
|
|
290
|
+
<div className="overflow-hidden rounded-xl border border-border bg-surface">
|
|
291
|
+
{layoutState.layout === 'table' ? (
|
|
292
|
+
<TableView query={query} embedded />
|
|
293
|
+
) : (
|
|
294
|
+
<GridView
|
|
295
|
+
schema={schema}
|
|
296
|
+
data={table.data}
|
|
297
|
+
visibleColumns={columns.visibleColumns}
|
|
298
|
+
selectedRows={actions.selectedRows}
|
|
299
|
+
changedRows={editable.changedRows}
|
|
300
|
+
openActionsRowId={openActionsRowId}
|
|
301
|
+
onRowSelect={actions.handleRowSelect}
|
|
302
|
+
onCellChange={editable.handleCellChange}
|
|
303
|
+
onRowAction={actions.handleRowAction}
|
|
304
|
+
onSaveRow={editable.handleSaveRow}
|
|
305
|
+
onResetRow={editable.handleResetRow}
|
|
306
|
+
onToggleActions={id => setOpenActionsRowId(openActionsRowId === id ? null : id)}
|
|
307
|
+
isLoading={table.isLoading}
|
|
308
|
+
error={table.error}
|
|
309
|
+
visibleActions={visibleActions}
|
|
310
|
+
embedded
|
|
311
|
+
/>
|
|
312
|
+
)}
|
|
313
|
+
|
|
314
|
+
<TablePagination
|
|
315
|
+
schema={schema}
|
|
316
|
+
currentPage={query.currentPage}
|
|
317
|
+
perPage={query.perPage}
|
|
318
|
+
totalRecords={table.totalRecords}
|
|
319
|
+
onPageChange={query.handlePageChange}
|
|
320
|
+
onPageSizeChange={query.handlePageSizeChange}
|
|
321
|
+
className="border-t border-border/60"
|
|
322
|
+
/>
|
|
323
|
+
</div>
|
|
324
|
+
|
|
325
|
+
<Slot
|
|
326
|
+
name="table.belowTable"
|
|
327
|
+
context={{ schema, resourceSlug: resourceSlugFromUrl(apiUrl) }}
|
|
328
|
+
as="div"
|
|
329
|
+
className="mt-3 space-y-3 empty:hidden"
|
|
330
|
+
/>
|
|
331
|
+
|
|
332
|
+
{/* Create Modal */}
|
|
333
|
+
{createModalOpen && createFormSchema && (
|
|
334
|
+
<ResourceFormModal
|
|
335
|
+
isOpen={createModalOpen}
|
|
336
|
+
onClose={() => {
|
|
337
|
+
setCreateModalOpen(false);
|
|
338
|
+
closeModal();
|
|
339
|
+
}}
|
|
340
|
+
mode="create"
|
|
341
|
+
resourceSlug={resourceSlugFromUrl(apiUrl)}
|
|
342
|
+
resourceName={(schema.resource as string) || resourceSlugFromUrl(apiUrl)}
|
|
343
|
+
apiBaseUrl={computedApiBaseUrl}
|
|
344
|
+
formSchema={createFormSchema}
|
|
345
|
+
onSuccess={() => {
|
|
346
|
+
table.reload();
|
|
347
|
+
closeModal();
|
|
348
|
+
}}
|
|
349
|
+
depth={depth}
|
|
350
|
+
onCloseAll={handleCloseAll}
|
|
351
|
+
/>
|
|
352
|
+
)}
|
|
353
|
+
|
|
354
|
+
{/* Action Form Modal */}
|
|
355
|
+
{actions.actionFormModal && (
|
|
356
|
+
<ActionFormModal
|
|
357
|
+
isOpen={!!actions.actionFormModal}
|
|
358
|
+
onClose={() => {
|
|
359
|
+
actions.setActionFormModal(null);
|
|
360
|
+
closeModal();
|
|
361
|
+
}}
|
|
362
|
+
actionName={actions.actionFormModal.actionName}
|
|
363
|
+
actionLabel={
|
|
364
|
+
(actions.actionFormModal.isBulk
|
|
365
|
+
? schema.bulkActions?.find(a => a.name === actions.actionFormModal!.actionName)?.label
|
|
366
|
+
: schema.actions?.find(a => a.name === actions.actionFormModal!.actionName)?.label) ||
|
|
367
|
+
actions.actionFormModal.actionName
|
|
368
|
+
}
|
|
369
|
+
formSchema={actions.actionFormModal.formSchema}
|
|
370
|
+
recordIds={actions.actionFormModal.recordIds}
|
|
371
|
+
isBulk={actions.actionFormModal.isBulk}
|
|
372
|
+
requiresConfirmation={actions.actionFormModal.requiresConfirmation}
|
|
373
|
+
modalDescription={actions.actionFormModal.modalDescription}
|
|
374
|
+
apiBaseUrl={computedApiBaseUrl}
|
|
375
|
+
resourceSlug={resourceSlug}
|
|
376
|
+
onSuccess={() => {
|
|
377
|
+
if (actions.actionFormModal?.isBulk) {
|
|
378
|
+
actions.clearSelection();
|
|
379
|
+
}
|
|
380
|
+
table.reload();
|
|
381
|
+
closeModal();
|
|
382
|
+
}}
|
|
383
|
+
depth={depth}
|
|
384
|
+
onCloseAll={handleCloseAll}
|
|
385
|
+
/>
|
|
386
|
+
)}
|
|
387
|
+
</div>
|
|
388
|
+
</TableProvider>
|
|
389
|
+
);
|
|
390
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { SerializedFilter } from '@maxal_studio/kratosjs';
|
|
3
|
+
import { Filter, ChevronDown, X } from 'lucide-react';
|
|
4
|
+
import { cn } from '../../utils/classNames';
|
|
5
|
+
import { Select } from '../../components/ui/Select';
|
|
6
|
+
import { Label } from '../../components/ui/Label';
|
|
7
|
+
import { PillButton, PillIconButton } from '../../components/ui/PillButton';
|
|
8
|
+
import { QueryBuilderFilterComponent } from '../../components/filters/QueryBuilderFilterComponent';
|
|
9
|
+
import { CustomFilterComponent } from '../../components/filters/CustomFilterComponent';
|
|
10
|
+
import { DateFilterComponent } from '../../components/filters/DateFilterComponent';
|
|
11
|
+
import { TableToolbarButton } from './TableToolbarButton';
|
|
12
|
+
import { translate } from '../../i18n/activeLocale';
|
|
13
|
+
|
|
14
|
+
interface FilterFieldProps {
|
|
15
|
+
filter: SerializedFilter;
|
|
16
|
+
value: any;
|
|
17
|
+
onChange: (value: any, isQueryBuilder?: boolean) => void;
|
|
18
|
+
embedded?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function FilterField({ filter, value, onChange, embedded }: FilterFieldProps) {
|
|
22
|
+
const hasValue = value !== undefined && value !== '' && value !== null;
|
|
23
|
+
|
|
24
|
+
if (filter.type === 'select') {
|
|
25
|
+
return (
|
|
26
|
+
<div className="space-y-1.5">
|
|
27
|
+
<Label>{filter.label || filter.name}</Label>
|
|
28
|
+
<Select value={value || ''} onChange={e => onChange(e.target.value || undefined)} active={hasValue}>
|
|
29
|
+
<option value="">{filter.placeholder || `All ${filter.label || filter.name}`}</option>
|
|
30
|
+
{filter.options &&
|
|
31
|
+
Object.entries(filter.options).map(([val, label]) => (
|
|
32
|
+
<option key={val} value={val}>
|
|
33
|
+
{label as string}
|
|
34
|
+
</option>
|
|
35
|
+
))}
|
|
36
|
+
</Select>
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (filter.type === 'ternary') {
|
|
42
|
+
return (
|
|
43
|
+
<div className="space-y-1.5">
|
|
44
|
+
<Label>{filter.label || filter.name}</Label>
|
|
45
|
+
<Select
|
|
46
|
+
value={value !== undefined ? String(value) : ''}
|
|
47
|
+
onChange={e => onChange(e.target.value === '' ? undefined : e.target.value === 'true')}
|
|
48
|
+
active={hasValue}>
|
|
49
|
+
<option value="">{filter.placeholder || translate('core:common.all')}</option>
|
|
50
|
+
<option value="true">{filter.trueLabel || translate('core:common.yes')}</option>
|
|
51
|
+
<option value="false">{filter.falseLabel || translate('core:common.no')}</option>
|
|
52
|
+
</Select>
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (filter.type === 'date') {
|
|
58
|
+
return <DateFilterComponent filter={filter} value={value} onChange={onChange} embedded={embedded} />;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (filter.type === 'queryBuilder') {
|
|
62
|
+
return (
|
|
63
|
+
<div className="space-y-1.5">
|
|
64
|
+
<Label>{filter.label || translate('core:filters.advanced_search')}</Label>
|
|
65
|
+
<QueryBuilderFilterComponent
|
|
66
|
+
filter={filter}
|
|
67
|
+
value={value}
|
|
68
|
+
onChange={value => onChange(value, true)}
|
|
69
|
+
embedded={embedded}
|
|
70
|
+
/>
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (filter.type === 'custom') {
|
|
76
|
+
return (
|
|
77
|
+
<div className="space-y-1.5">
|
|
78
|
+
<Label>{filter.label || filter.name}</Label>
|
|
79
|
+
<CustomFilterComponent filter={filter} value={value} onChange={onChange} embedded={embedded} />
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface FiltersPanelProps {
|
|
88
|
+
filters: SerializedFilter[];
|
|
89
|
+
values: Record<string, any>;
|
|
90
|
+
queryBuilderValues: Record<string, any[]>;
|
|
91
|
+
onChange: (name: string, value: any, isQueryBuilder?: boolean) => void;
|
|
92
|
+
onClear: () => void;
|
|
93
|
+
layout: 'inline' | 'dropdown' | 'sidebar';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function FiltersPanel({ filters, values, queryBuilderValues, onChange, onClear, layout }: FiltersPanelProps) {
|
|
97
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
98
|
+
|
|
99
|
+
const regularCount = Object.keys(values).filter(key => values[key] !== undefined).length;
|
|
100
|
+
const queryBuilderCount = Object.keys(queryBuilderValues).filter(
|
|
101
|
+
key => queryBuilderValues[key] && queryBuilderValues[key].length > 0,
|
|
102
|
+
).length;
|
|
103
|
+
const activeCount = regularCount + queryBuilderCount;
|
|
104
|
+
|
|
105
|
+
const fields = filters.map(filter => {
|
|
106
|
+
const isQueryBuilder = filter.type === 'queryBuilder';
|
|
107
|
+
const value = isQueryBuilder ? queryBuilderValues[filter.name] : values[filter.name];
|
|
108
|
+
return (
|
|
109
|
+
<FilterField
|
|
110
|
+
key={filter.name}
|
|
111
|
+
filter={filter}
|
|
112
|
+
value={value}
|
|
113
|
+
onChange={(value, isQB) => onChange(filter.name, value, isQB)}
|
|
114
|
+
embedded={layout === 'dropdown'}
|
|
115
|
+
/>
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Inline layout — all filters visible in a card
|
|
120
|
+
if (layout === 'inline') {
|
|
121
|
+
return (
|
|
122
|
+
<div className="rounded-xl border border-border bg-surface p-4">
|
|
123
|
+
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">{fields}</div>
|
|
124
|
+
{activeCount > 0 && (
|
|
125
|
+
<div className="mt-4 flex justify-end border-t border-border/60 pt-4">
|
|
126
|
+
<button
|
|
127
|
+
type="button"
|
|
128
|
+
onClick={onClear}
|
|
129
|
+
className="text-sm font-medium text-accent transition-colors hover:text-accent-hover">
|
|
130
|
+
{translate('core:filters.clear_all_filters')}
|
|
131
|
+
</button>
|
|
132
|
+
</div>
|
|
133
|
+
)}
|
|
134
|
+
</div>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Dropdown layout — filters behind a trigger button
|
|
139
|
+
return (
|
|
140
|
+
<div className="relative">
|
|
141
|
+
<TableToolbarButton
|
|
142
|
+
onClick={() => setIsOpen(!isOpen)}
|
|
143
|
+
icon={<Filter className="h-4 w-4" />}
|
|
144
|
+
className={cn(activeCount > 0 && 'ring-2 ring-ring border-accent')}
|
|
145
|
+
aria-expanded={isOpen}>
|
|
146
|
+
<span>{translate('core:table.filters')}</span>
|
|
147
|
+
{activeCount > 0 && (
|
|
148
|
+
<span className="inline-flex h-5 min-w-[20px] items-center justify-center rounded-full bg-accent px-1.5 text-xs font-bold text-accent-fg">
|
|
149
|
+
{activeCount}
|
|
150
|
+
</span>
|
|
151
|
+
)}
|
|
152
|
+
<ChevronDown className={cn('h-4 w-4 transition-transform', isOpen && 'rotate-180')} />
|
|
153
|
+
</TableToolbarButton>
|
|
154
|
+
|
|
155
|
+
{isOpen && (
|
|
156
|
+
<>
|
|
157
|
+
{/* Backdrop */}
|
|
158
|
+
<div className="fixed inset-0 z-40" onClick={() => setIsOpen(false)} />
|
|
159
|
+
|
|
160
|
+
{/* Dropdown panel — fixed on mobile, anchored on desktop */}
|
|
161
|
+
<div className="fixed inset-x-4 top-1/2 z-50 flex max-h-[80vh] w-auto -translate-y-1/2 flex-col overflow-hidden rounded-lg border border-border bg-raised p-4 shadow-soft-lg sm:absolute sm:inset-auto sm:right-0 sm:top-full sm:left-auto sm:mt-2 sm:w-[min(480px,calc(100vw-2rem))] sm:translate-y-0">
|
|
162
|
+
<div className="mb-4 flex shrink-0 items-center justify-between">
|
|
163
|
+
<h3 className="text-base font-semibold text-fg">{translate('core:table.filters')}</h3>
|
|
164
|
+
<PillIconButton
|
|
165
|
+
aria-label={translate('core:table.close_filters')}
|
|
166
|
+
onClick={() => setIsOpen(false)}>
|
|
167
|
+
<X className="h-4 w-4" />
|
|
168
|
+
</PillIconButton>
|
|
169
|
+
</div>
|
|
170
|
+
|
|
171
|
+
<div className="flex-1 space-y-4 overflow-y-auto pr-2">{fields}</div>
|
|
172
|
+
|
|
173
|
+
<div className="mt-4 flex shrink-0 items-center justify-between border-t border-border pt-4">
|
|
174
|
+
<button
|
|
175
|
+
type="button"
|
|
176
|
+
onClick={() => {
|
|
177
|
+
onClear();
|
|
178
|
+
setIsOpen(false);
|
|
179
|
+
}}
|
|
180
|
+
disabled={activeCount === 0}
|
|
181
|
+
className="text-sm font-medium text-fg-secondary transition-colors hover:text-fg disabled:opacity-50">
|
|
182
|
+
{translate('core:common.clear_all')}
|
|
183
|
+
</button>
|
|
184
|
+
<PillButton variant="primary" onClick={() => setIsOpen(false)}>
|
|
185
|
+
{translate('core:common.done')}
|
|
186
|
+
</PillButton>
|
|
187
|
+
</div>
|
|
188
|
+
</div>
|
|
189
|
+
</>
|
|
190
|
+
)}
|
|
191
|
+
</div>
|
|
192
|
+
);
|
|
193
|
+
}
|