@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,42 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Icon } from '../../utils/Icon';
|
|
3
|
+
import { cn } from '../../../utils/classNames';
|
|
4
|
+
import { pillTabClass } from '../../ui/PillButton';
|
|
5
|
+
import { translate } from '../../../i18n/activeLocale';
|
|
6
|
+
import { Slot } from '../../../slots/Slot';
|
|
7
|
+
/** Group relations by groupKey; ungrouped relations become individual tabs. */
|
|
8
|
+
export function groupRelations(relations) {
|
|
9
|
+
const groups = {};
|
|
10
|
+
const ungrouped = [];
|
|
11
|
+
for (const rel of relations) {
|
|
12
|
+
if (rel.groupKey) {
|
|
13
|
+
const groupKey = `group_${rel.groupKey}`;
|
|
14
|
+
if (!groups[groupKey]) {
|
|
15
|
+
groups[groupKey] = {
|
|
16
|
+
key: groupKey,
|
|
17
|
+
label: rel.groupLabel || rel.groupKey,
|
|
18
|
+
icon: rel.groupIcon || rel.icon,
|
|
19
|
+
relations: [],
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
groups[groupKey].relations.push(rel);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
ungrouped.push(rel);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return { groups: Object.values(groups), ungrouped };
|
|
29
|
+
}
|
|
30
|
+
function TabButton({ active, onClick, icon, children, }) {
|
|
31
|
+
return (_jsxs("button", { type: "button", role: "tab", "aria-selected": active, onClick: onClick, className: pillTabClass(active), children: [icon && _jsx(Icon, { name: icon, className: "h-4 w-4 shrink-0" }), _jsx("span", { children: children })] }));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Top tab strip of the view modal — pill tabs matching table/sidebar design.
|
|
35
|
+
*/
|
|
36
|
+
export function RelationTabs({ grouped, activeTopTab, onTopTabChange, hasActionBar }) {
|
|
37
|
+
return (_jsx("div", { className: cn('sticky z-40 shrink-0 border-b border-border/60 bg-surface px-4 py-3', hasActionBar ? 'top-[60px]' : 'top-0'), children: _jsxs("div", { className: "flex gap-1 overflow-x-auto overscroll-x-contain", style: { WebkitOverflowScrolling: 'touch' }, role: "tablist", "aria-label": translate('core:modal.sections'), children: [_jsx(TabButton, { active: activeTopTab === 'details', onClick: () => onTopTabChange('details'), children: translate('core:common.details') }), grouped.groups.map(group => (_jsx(TabButton, { active: activeTopTab === group.key, onClick: () => onTopTabChange(group.key), icon: group.icon, children: group.label }, group.key))), grouped.ungrouped.map(rel => (_jsx(TabButton, { active: activeTopTab === rel.name, onClick: () => onTopTabChange(rel.name), icon: rel.icon, children: rel.pluralLabel }, rel.name))), _jsx(Slot, { name: "detail.tabs", context: { data: { activeTab: activeTopTab, setActiveTab: onTopTabChange } } })] }) }));
|
|
38
|
+
}
|
|
39
|
+
/** Inner tab strip inside a relation group. */
|
|
40
|
+
export function GroupInnerTabs({ group, current, onChange }) {
|
|
41
|
+
return (_jsx("div", { className: "mb-4 overflow-x-auto", children: _jsx("div", { className: "flex gap-1 overflow-x-auto overscroll-x-contain", style: { WebkitOverflowScrolling: 'touch' }, role: "tablist", "aria-label": `${group.label} relations`, children: group.relations.map(rel => (_jsx(TabButton, { active: current === rel.name, onClick: () => onChange(rel.name), icon: rel.icon, children: rel.pluralLabel }, rel.name))) }) }));
|
|
42
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SerializedTable } from '@maxal_studio/kratosjs';
|
|
2
|
+
import { SerializedRelation } from '../../../types';
|
|
3
|
+
export interface RecordViewApi {
|
|
4
|
+
recordData: any;
|
|
5
|
+
recordTitle: string | undefined;
|
|
6
|
+
relations: SerializedRelation[];
|
|
7
|
+
relationSchemas: Record<string, SerializedTable>;
|
|
8
|
+
loading: boolean;
|
|
9
|
+
error: string | null;
|
|
10
|
+
/** Re-fetch only the record (after edits/actions) */
|
|
11
|
+
refreshRecord: () => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Data layer of the view modal: loads the record, its relation metadata and
|
|
15
|
+
* the relation table schemas, and refreshes the record whenever a
|
|
16
|
+
* data-mutating modal (edit/create/action) above it closes.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useRecordView(isOpen: boolean, apiBaseUrl: string | undefined, resourceSlug: string, recordId: string): RecordViewApi;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { getRecord, getRelations, getTableSchema } from '../../../api/resourceApi';
|
|
3
|
+
import { useResourceModal } from '../../../contexts/ResourceModalContext';
|
|
4
|
+
import { translate } from '../../../i18n/activeLocale';
|
|
5
|
+
/**
|
|
6
|
+
* Data layer of the view modal: loads the record, its relation metadata and
|
|
7
|
+
* the relation table schemas, and refreshes the record whenever a
|
|
8
|
+
* data-mutating modal (edit/create/action) above it closes.
|
|
9
|
+
*/
|
|
10
|
+
export function useRecordView(isOpen, apiBaseUrl, resourceSlug, recordId) {
|
|
11
|
+
const { modalStack } = useResourceModal();
|
|
12
|
+
const [recordData, setRecordData] = useState(null);
|
|
13
|
+
const [recordTitle, setRecordTitle] = useState(undefined);
|
|
14
|
+
const [relations, setRelations] = useState([]);
|
|
15
|
+
const [relationSchemas, setRelationSchemas] = useState({});
|
|
16
|
+
const [loading, setLoading] = useState(true);
|
|
17
|
+
const [error, setError] = useState(null);
|
|
18
|
+
const prevModalStackRef = useRef(modalStack);
|
|
19
|
+
const fetchRecord = async () => {
|
|
20
|
+
const result = await getRecord(apiBaseUrl, resourceSlug, recordId);
|
|
21
|
+
setRecordData(result.data);
|
|
22
|
+
setRecordTitle(result.metadata?.recordTitle);
|
|
23
|
+
};
|
|
24
|
+
const refreshRecord = async () => {
|
|
25
|
+
if (!isOpen || !recordId)
|
|
26
|
+
return;
|
|
27
|
+
setLoading(true);
|
|
28
|
+
setError(null);
|
|
29
|
+
try {
|
|
30
|
+
await fetchRecord();
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
setError(err.message || translate('core:error.load_record'));
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
setLoading(false);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
// Initial load: record + relations + relation table schemas (in parallel)
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!isOpen)
|
|
42
|
+
return;
|
|
43
|
+
let cancelled = false;
|
|
44
|
+
const fetchAll = async () => {
|
|
45
|
+
setLoading(true);
|
|
46
|
+
setError(null);
|
|
47
|
+
try {
|
|
48
|
+
const recordPromise = getRecord(apiBaseUrl, resourceSlug, recordId);
|
|
49
|
+
const relationsPromise = getRelations(apiBaseUrl, resourceSlug).catch(() => []);
|
|
50
|
+
const record = await recordPromise;
|
|
51
|
+
if (cancelled)
|
|
52
|
+
return;
|
|
53
|
+
setRecordData(record.data);
|
|
54
|
+
setRecordTitle(record.metadata?.recordTitle);
|
|
55
|
+
const rels = await relationsPromise;
|
|
56
|
+
if (cancelled)
|
|
57
|
+
return;
|
|
58
|
+
setRelations(rels);
|
|
59
|
+
const schemaResults = await Promise.all(rels.map(async (relation) => {
|
|
60
|
+
try {
|
|
61
|
+
const schema = await getTableSchema(apiBaseUrl, relation.resourceSlug);
|
|
62
|
+
return { relationName: relation.name, schema: schema };
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return { relationName: relation.name, schema: null };
|
|
66
|
+
}
|
|
67
|
+
}));
|
|
68
|
+
if (cancelled)
|
|
69
|
+
return;
|
|
70
|
+
const schemas = {};
|
|
71
|
+
for (const { relationName, schema } of schemaResults) {
|
|
72
|
+
if (schema)
|
|
73
|
+
schemas[relationName] = schema;
|
|
74
|
+
}
|
|
75
|
+
setRelationSchemas(schemas);
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
if (!cancelled)
|
|
79
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
if (!cancelled)
|
|
83
|
+
setLoading(false);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
fetchAll();
|
|
87
|
+
return () => {
|
|
88
|
+
cancelled = true;
|
|
89
|
+
};
|
|
90
|
+
}, [isOpen, resourceSlug, recordId, apiBaseUrl]);
|
|
91
|
+
// Refresh the record when a data-mutating modal above this one closes.
|
|
92
|
+
// Closing a view modal is just navigation — no re-fetch needed.
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
const prevStack = prevModalStackRef.current;
|
|
95
|
+
prevModalStackRef.current = modalStack;
|
|
96
|
+
if (modalStack.length < prevStack.length) {
|
|
97
|
+
const closedModal = prevStack[prevStack.length - 1];
|
|
98
|
+
if (closedModal && closedModal.mode !== 'view') {
|
|
99
|
+
refreshRecord();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
103
|
+
}, [modalStack]);
|
|
104
|
+
// Reset when closed
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
if (!isOpen) {
|
|
107
|
+
setRecordData(null);
|
|
108
|
+
setRecordTitle(undefined);
|
|
109
|
+
setRelations([]);
|
|
110
|
+
setRelationSchemas({});
|
|
111
|
+
}
|
|
112
|
+
}, [isOpen]);
|
|
113
|
+
return { recordData, recordTitle, relations, relationSchemas, loading, error, refreshRecord };
|
|
114
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { useLocation } from 'react-router-dom';
|
|
4
|
+
import { BlockRenderer } from '../blocks/BlockRenderer';
|
|
5
|
+
import { authenticatedFetch } from '../../api/authenticatedFetch';
|
|
6
|
+
import { translate } from '../../i18n/activeLocale';
|
|
7
|
+
import { Slot } from '../../slots/Slot';
|
|
8
|
+
export function PageRenderer({ pageSlug, apiBaseUrl }) {
|
|
9
|
+
const [pageData, setPageData] = useState(null);
|
|
10
|
+
const [widgetData, setWidgetData] = useState({});
|
|
11
|
+
const [loading, setLoading] = useState(true);
|
|
12
|
+
const [error, setError] = useState(null);
|
|
13
|
+
const location = useLocation();
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const fetchPageData = async () => {
|
|
16
|
+
setLoading(true);
|
|
17
|
+
setError(null);
|
|
18
|
+
try {
|
|
19
|
+
// Extract query parameters from the URL
|
|
20
|
+
const searchParams = new URLSearchParams(location.search);
|
|
21
|
+
const queryString = searchParams.toString();
|
|
22
|
+
const url = `${apiBaseUrl}/pages/${pageSlug}${queryString ? `?${queryString}` : ''}`;
|
|
23
|
+
// Use authenticated fetch which handles token refresh automatically
|
|
24
|
+
const response = await authenticatedFetch(url, {
|
|
25
|
+
headers: {
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
},
|
|
28
|
+
}, apiBaseUrl);
|
|
29
|
+
if (!response.ok) {
|
|
30
|
+
// If still 401 after refresh attempt, user needs to login
|
|
31
|
+
if (response.status === 401) {
|
|
32
|
+
throw new Error('Unauthorized - Please login again');
|
|
33
|
+
}
|
|
34
|
+
const error = await response.json();
|
|
35
|
+
throw new Error(`Failed to fetch page: ${error.message || response.statusText}`);
|
|
36
|
+
}
|
|
37
|
+
const data = await response.json();
|
|
38
|
+
setPageData(data.page);
|
|
39
|
+
setWidgetData(data.widgetData || {});
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
setError(err.message || translate('core:error.load_page'));
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
setLoading(false);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
fetchPageData();
|
|
49
|
+
}, [pageSlug, apiBaseUrl, location.search]);
|
|
50
|
+
if (loading) {
|
|
51
|
+
return (_jsx("div", { className: "flex items-center justify-center min-h-[400px]", children: _jsx("div", { className: "text-gray-500 dark:text-gray-400", children: translate('core:page.loading') }) }));
|
|
52
|
+
}
|
|
53
|
+
if (error) {
|
|
54
|
+
return (_jsx("div", { className: "flex items-center justify-center min-h-[400px]", children: _jsx("div", { className: "text-red-500 dark:text-red-400", children: error }) }));
|
|
55
|
+
}
|
|
56
|
+
if (!pageData) {
|
|
57
|
+
return (_jsx("div", { className: "flex items-center justify-center min-h-[400px]", children: _jsx("div", { className: "text-gray-500 dark:text-gray-400", children: translate('core:state.page_not_found') }) }));
|
|
58
|
+
}
|
|
59
|
+
// Group blocks into rows based on column widths
|
|
60
|
+
const groupBlocksIntoRows = (blocks) => {
|
|
61
|
+
const rows = [];
|
|
62
|
+
let currentRow = [];
|
|
63
|
+
let currentRowWidth = 0;
|
|
64
|
+
for (const block of blocks) {
|
|
65
|
+
const blockColumns = block.columns || 12; // Default to full width if not specified
|
|
66
|
+
// If adding this block would exceed 12 columns, start a new row
|
|
67
|
+
if (currentRowWidth + blockColumns > 12 && currentRow.length > 0) {
|
|
68
|
+
rows.push(currentRow);
|
|
69
|
+
currentRow = [block];
|
|
70
|
+
currentRowWidth = blockColumns;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
currentRow.push(block);
|
|
74
|
+
currentRowWidth += blockColumns;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Add the last row if it has blocks
|
|
78
|
+
if (currentRow.length > 0) {
|
|
79
|
+
rows.push(currentRow);
|
|
80
|
+
}
|
|
81
|
+
return rows;
|
|
82
|
+
};
|
|
83
|
+
// Map column numbers to Tailwind classes (ensures classes are recognized)
|
|
84
|
+
const getColSpanClass = (columns) => {
|
|
85
|
+
const colMap = {
|
|
86
|
+
1: 'col-span-1',
|
|
87
|
+
2: 'col-span-2',
|
|
88
|
+
3: 'col-span-3',
|
|
89
|
+
4: 'col-span-4',
|
|
90
|
+
5: 'col-span-5',
|
|
91
|
+
6: 'col-span-6',
|
|
92
|
+
7: 'col-span-7',
|
|
93
|
+
8: 'col-span-8',
|
|
94
|
+
9: 'col-span-9',
|
|
95
|
+
10: 'col-span-10',
|
|
96
|
+
11: 'col-span-11',
|
|
97
|
+
12: 'col-span-12',
|
|
98
|
+
};
|
|
99
|
+
return colMap[columns] || 'col-span-12';
|
|
100
|
+
};
|
|
101
|
+
const blockRows = pageData.blocks && pageData.blocks.length > 0 ? groupBlocksIntoRows(pageData.blocks) : [];
|
|
102
|
+
return (_jsxs("div", { className: "w-full max-w-7xl mx-auto", children: [_jsx(Slot, { name: "page.top", context: { schema: pageData, location: `/page/${pageSlug}` }, as: "div", className: "mb-6 space-y-6 empty:hidden" }), blockRows.length > 0 ? (_jsx("div", { className: "space-y-6", children: blockRows.map((row, rowIndex) => (_jsx("div", { className: "grid grid-cols-12 gap-6", children: row.map((block, blockIndex) => {
|
|
103
|
+
const blockColumns = block.columns || 12;
|
|
104
|
+
const colSpanClass = getColSpanClass(blockColumns);
|
|
105
|
+
return (_jsx("div", { className: colSpanClass, children: _jsx(BlockRenderer, { block: block, blockData: widgetData, apiBaseUrl: apiBaseUrl }) }, blockIndex));
|
|
106
|
+
}) }, rowIndex))) })) : (_jsx("div", { className: "text-gray-500 dark:text-gray-400", children: translate('core:page.no_content') })), _jsx(Slot, { name: "page.bottom", context: { schema: pageData, location: `/page/${pageSlug}` }, as: "div", className: "mt-6 space-y-6 empty:hidden" })] }));
|
|
107
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SerializedColumn } from '@maxal_studio/kratosjs';
|
|
3
|
+
interface ColumnTogglePopupProps {
|
|
4
|
+
columns: SerializedColumn[];
|
|
5
|
+
visibleColumnNames: Set<string>;
|
|
6
|
+
onToggle: (columnName: string, visible: boolean) => void;
|
|
7
|
+
isOpen: boolean;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function ColumnTogglePopup({ columns, visibleColumnNames, onToggle, isOpen, onClose }: ColumnTogglePopupProps): React.JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../../utils/classNames';
|
|
3
|
+
import { Checkbox } from '../Checkbox';
|
|
4
|
+
import { translate } from '../../i18n/activeLocale';
|
|
5
|
+
export function ColumnTogglePopup({ columns, visibleColumnNames, onToggle, isOpen, onClose }) {
|
|
6
|
+
if (!isOpen) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
// Filter to only toggleable columns (exclude columns with hidden: true)
|
|
10
|
+
const toggleableColumns = columns.filter(col => col.hidden !== true && col.toggleable !== false);
|
|
11
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "fixed inset-0 z-40", onClick: onClose }), _jsxs("div", { className: "fixed inset-x-4 top-1/2 z-50 flex max-h-[80vh] w-auto -translate-y-1/2 flex-col overflow-visible rounded-xl border border-border bg-raised p-4 shadow-soft-lg sm:absolute sm:inset-auto sm:left-auto sm:right-0 sm:top-full sm:mt-2 sm:w-[400px] sm:translate-y-0", children: [_jsxs("div", { className: "mb-4 flex shrink-0 items-center justify-between", children: [_jsx("h3", { className: "text-sm font-medium text-fg", children: translate('core:table.column_visibility') }), _jsx("button", { onClick: onClose, className: "rounded-full p-1.5 text-fg-secondary transition-colors hover:bg-hover/70 hover:text-fg", children: _jsx("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) })] }), _jsx("div", { className: "space-y-2 flex-1 overflow-y-auto pr-2", children: toggleableColumns.length === 0 ? (_jsx("p", { className: "text-sm text-fg-secondary text-center py-4", children: translate('core:table.no_toggleable_columns') })) : (toggleableColumns.map(column => {
|
|
12
|
+
const isVisible = visibleColumnNames.has(column.name);
|
|
13
|
+
const isDisabled = column.hidden === true;
|
|
14
|
+
return (_jsxs("label", { className: cn('flex cursor-pointer items-center gap-3 rounded-full px-3 py-2 transition-colors hover:bg-hover/70', isDisabled && 'cursor-not-allowed opacity-50'), children: [_jsx(Checkbox, { checked: isVisible, onChange: checked => onToggle(column.name, checked), disabled: isDisabled }), _jsx("span", { className: "text-sm text-fg flex-1", children: column.label || column.name })] }, column.name));
|
|
15
|
+
})) }), _jsx("div", { className: "mt-4 flex shrink-0 justify-end border-t border-border/60 pt-4", children: _jsx("button", { onClick: onClose, className: "rounded-full bg-accent px-4 py-2 text-sm font-medium text-accent-fg transition-colors hover:bg-accent-hover", children: translate('core:common.done') }) })] })] }));
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SerializedTable } from '@maxal_studio/kratosjs';
|
|
3
|
+
interface GridCardProps {
|
|
4
|
+
schema: SerializedTable;
|
|
5
|
+
row: any;
|
|
6
|
+
rowIndex: number;
|
|
7
|
+
totalRows: number;
|
|
8
|
+
rowId: any;
|
|
9
|
+
visibleColumns: any[];
|
|
10
|
+
isSelected: boolean;
|
|
11
|
+
hasChanges: boolean;
|
|
12
|
+
openActionsRowId: any;
|
|
13
|
+
onRowSelect: (rowId: any) => void;
|
|
14
|
+
onCellChange: (rowId: any, columnName: string, value: any) => void;
|
|
15
|
+
onRowAction: (actionName: string, rowId: any) => void;
|
|
16
|
+
onSaveRow: (rowId: any) => void;
|
|
17
|
+
onResetRow: (rowId: any) => void;
|
|
18
|
+
onToggleActions: (rowId: any) => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function GridCard({ schema, row, rowIndex, totalRows, rowId, visibleColumns, isSelected, hasChanges, openActionsRowId, onRowSelect, onCellChange, onRowAction, onSaveRow, onResetRow, onToggleActions, }: GridCardProps): React.JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useColumnRegistry } from '../../contexts/ColumnRegistryContext';
|
|
3
|
+
import { cn } from '../../utils/classNames';
|
|
4
|
+
import { TableActionsDropdown } from './TableActionsDropdown';
|
|
5
|
+
import { Checkbox } from '../Checkbox';
|
|
6
|
+
import { PillButton } from '../ui/PillButton';
|
|
7
|
+
import { translate } from '../../i18n/activeLocale';
|
|
8
|
+
export function GridCard({ schema, row, rowIndex, totalRows, rowId, visibleColumns, isSelected, hasChanges, openActionsRowId, onRowSelect, onCellChange, onRowAction, onSaveRow, onResetRow, onToggleActions, }) {
|
|
9
|
+
const columnRegistry = useColumnRegistry();
|
|
10
|
+
return (_jsxs("div", { className: cn('relative overflow-hidden rounded-xl border bg-surface transition-colors hover:bg-hover/30', hasChanges ? 'border-accent/40 ring-1 ring-accent/20' : 'border-border'), children: [_jsxs("div", { className: "flex items-center justify-between border-b border-border/60 bg-muted px-3 py-2.5", children: [schema.bulkActions && schema.bulkActions.length > 0 && (_jsx("div", { className: "flex items-center", children: _jsx(Checkbox, { id: `grid-checkbox-${rowId}`, checked: isSelected, onChange: () => onRowSelect(rowId) }) })), schema.actions && schema.actions.length > 0 && (_jsx("div", { className: "ml-auto", children: _jsx(TableActionsDropdown, { schema: schema, rowId: rowId, rowIndex: rowIndex, totalRows: totalRows, isOpen: openActionsRowId === rowId, onToggle: () => onToggleActions(rowId), onAction: onRowAction }) }))] }), _jsxs(_Fragment, { children: [_jsx("style", { children: `
|
|
11
|
+
.grid-card-body-${rowId} {
|
|
12
|
+
grid-template-columns: repeat(1, minmax(0, 1fr));
|
|
13
|
+
}
|
|
14
|
+
@media (min-width: 768px) {
|
|
15
|
+
.grid-card-body-${rowId} {
|
|
16
|
+
grid-template-columns: repeat(${schema.gridColumns || 2}, minmax(0, 1fr));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
` }), _jsx("div", { className: `grid gap-4 p-4 grid-card-body-${rowId}`, children: visibleColumns.map(column => {
|
|
20
|
+
const ColumnComponent = columnRegistry[column.type];
|
|
21
|
+
if (!ColumnComponent) {
|
|
22
|
+
return (_jsxs("div", { className: "text-sm", children: [_jsx("div", { className: "mb-1 text-[11px] font-medium uppercase tracking-wider text-fg-muted", children: column.label || column.name }), _jsx("div", { className: "text-fg-secondary", children: translate('core:state.unknown_column', { type: column.type }) })] }, column.name));
|
|
23
|
+
}
|
|
24
|
+
const isEditable = ['textinput', 'select', 'checkbox', 'toggle'].includes(column.type);
|
|
25
|
+
const isFullWidth = column.gridSpanFull === true;
|
|
26
|
+
return (_jsxs("div", { className: cn('text-sm', isFullWidth && 'col-span-full'), children: [!isFullWidth && (_jsx("div", { className: "mb-1 text-[11px] font-medium uppercase tracking-wider text-fg-muted", children: column.label || column.name })), _jsx("div", { className: "text-fg", children: _jsx(ColumnComponent, { column: column, record: row, rowIndex: rowIndex, onCellChange: isEditable
|
|
27
|
+
? (value) => onCellChange(rowId, column.name, value)
|
|
28
|
+
: undefined }) })] }, column.name));
|
|
29
|
+
}) })] }), hasChanges && (_jsxs("div", { className: "flex items-center justify-end gap-2 border-t border-border/60 bg-muted px-3 py-2.5", children: [_jsx(PillButton, { variant: "primary", onClick: () => onSaveRow(rowId), title: translate('core:table.save_changes'), children: translate('core:common.save') }), _jsx(PillButton, { variant: "default", onClick: () => onResetRow(rowId), title: translate('core:table.reset_changes'), children: translate('core:common.reset') })] }))] }));
|
|
30
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SerializedTable } from '@maxal_studio/kratosjs';
|
|
3
|
+
interface GridViewProps {
|
|
4
|
+
schema: SerializedTable;
|
|
5
|
+
data: any[];
|
|
6
|
+
visibleColumns: any[];
|
|
7
|
+
selectedRows: Set<any>;
|
|
8
|
+
changedRows: Map<any, any>;
|
|
9
|
+
openActionsRowId: any;
|
|
10
|
+
onRowSelect: (rowId: any) => void;
|
|
11
|
+
onCellChange: (rowId: any, columnName: string, value: any) => void;
|
|
12
|
+
onRowAction: (actionName: string, rowId: any) => void;
|
|
13
|
+
onSaveRow: (rowId: any) => void;
|
|
14
|
+
onResetRow: (rowId: any) => void;
|
|
15
|
+
onToggleActions: (rowId: any) => void;
|
|
16
|
+
isLoading: boolean;
|
|
17
|
+
error: string | null;
|
|
18
|
+
visibleActions: any[];
|
|
19
|
+
/** When true, loading/empty/error states omit outer card wrapper. */
|
|
20
|
+
embedded?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare function GridView({ schema, data, visibleColumns, selectedRows, changedRows, openActionsRowId, onRowSelect, onCellChange, onRowAction, onSaveRow, onResetRow, onToggleActions, isLoading, error, visibleActions, embedded, }: GridViewProps): React.JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { GridCard } from './GridCard';
|
|
3
|
+
import { cn } from '../../utils/classNames';
|
|
4
|
+
import { Spinner } from '../ui/Spinner';
|
|
5
|
+
import { EmptyState } from '../ui/EmptyState';
|
|
6
|
+
import { ErrorAlert } from '../ui/ErrorAlert';
|
|
7
|
+
import { translate } from '../../i18n/activeLocale';
|
|
8
|
+
export function GridView({ schema, data, visibleColumns, selectedRows, changedRows, openActionsRowId, onRowSelect, onCellChange, onRowAction, onSaveRow, onResetRow, onToggleActions, isLoading, error, visibleActions, embedded = false, }) {
|
|
9
|
+
const generateGridClasses = () => {
|
|
10
|
+
const config = schema.contentGrid || { md: 2, xl: 3 };
|
|
11
|
+
const classes = ['grid', 'grid-cols-1'];
|
|
12
|
+
const breakpointMap = {
|
|
13
|
+
sm: 'sm:grid-cols-',
|
|
14
|
+
md: 'md:grid-cols-',
|
|
15
|
+
lg: 'lg:grid-cols-',
|
|
16
|
+
xl: 'xl:grid-cols-',
|
|
17
|
+
'2xl': '2xl:grid-cols-',
|
|
18
|
+
};
|
|
19
|
+
for (const [breakpoint, cols] of Object.entries(config)) {
|
|
20
|
+
const prefix = breakpointMap[breakpoint];
|
|
21
|
+
if (prefix) {
|
|
22
|
+
classes.push(`${prefix}${cols}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
classes.push('gap-4');
|
|
26
|
+
return classes.join(' ');
|
|
27
|
+
};
|
|
28
|
+
const gridClasses = generateGridClasses();
|
|
29
|
+
const stateWrapper = embedded ? 'px-4 py-12' : 'rounded-xl border border-border bg-surface px-4 py-12';
|
|
30
|
+
if (isLoading) {
|
|
31
|
+
return (_jsx("div", { className: stateWrapper, children: _jsx("div", { className: "flex items-center justify-center", children: _jsx(Spinner, { label: translate('core:common.loading_ellipsis') }) }) }));
|
|
32
|
+
}
|
|
33
|
+
if (error) {
|
|
34
|
+
return (_jsx("div", { className: embedded ? 'p-4' : 'rounded-xl border border-border bg-surface p-4', children: _jsx(ErrorAlert, { message: error }) }));
|
|
35
|
+
}
|
|
36
|
+
if (data.length === 0) {
|
|
37
|
+
return (_jsx("div", { className: stateWrapper, children: _jsx(EmptyState, { title: translate('core:table.no_records'), description: translate('core:table.no_records_hint') }) }));
|
|
38
|
+
}
|
|
39
|
+
return (_jsx("div", { className: cn(gridClasses, embedded && 'p-4'), children: data.map((row, rowIndex) => {
|
|
40
|
+
const rowId = row.id || row._id || rowIndex;
|
|
41
|
+
const hasChanges = changedRows.has(rowId);
|
|
42
|
+
const isSelected = selectedRows.has(rowId);
|
|
43
|
+
const filteredSchema = {
|
|
44
|
+
...schema,
|
|
45
|
+
actions: visibleActions,
|
|
46
|
+
};
|
|
47
|
+
return (_jsx(GridCard, { schema: filteredSchema, row: row, rowIndex: rowIndex, totalRows: data.length, rowId: rowId, visibleColumns: visibleColumns, isSelected: isSelected, hasChanges: hasChanges, openActionsRowId: openActionsRowId, onRowSelect: onRowSelect, onCellChange: onCellChange, onRowAction: onRowAction, onSaveRow: onSaveRow, onResetRow: onResetRow, onToggleActions: onToggleActions }, rowId));
|
|
48
|
+
}) }));
|
|
49
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Icon } from '../utils/Icon';
|
|
3
|
+
import { TableToolbarIconButton } from '../../table/components/TableToolbarButton';
|
|
4
|
+
import { translate } from '../../i18n/activeLocale';
|
|
5
|
+
export function LayoutToggle({ layout, onLayoutChange }) {
|
|
6
|
+
const isTable = layout === 'table';
|
|
7
|
+
const nextLayout = isTable ? 'grid' : 'table';
|
|
8
|
+
return (_jsx(TableToolbarIconButton, { onClick: () => onLayoutChange(nextLayout), title: isTable ? translate('core:table.switch_grid') : translate('core:table.switch_table'), "aria-label": isTable ? translate('core:table.switch_grid') : translate('core:table.switch_table'), "aria-pressed": !isTable, children: _jsx(Icon, { name: isTable ? 'Table' : 'LayoutGrid', size: 16 }) }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SerializedTable } from '@maxal_studio/kratosjs';
|
|
3
|
+
interface TableActionsDropdownProps {
|
|
4
|
+
schema: SerializedTable;
|
|
5
|
+
rowId: any;
|
|
6
|
+
rowIndex: number;
|
|
7
|
+
totalRows: number;
|
|
8
|
+
isOpen: boolean;
|
|
9
|
+
onToggle: () => void;
|
|
10
|
+
onAction: (actionName: string, rowId: any) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function TableActionsDropdown({ schema, rowId, rowIndex, totalRows, isOpen, onToggle, onAction, }: TableActionsDropdownProps): React.JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useEffect, useState } from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import { Icon } from '../utils/Icon';
|
|
5
|
+
import { cn } from '../../utils/classNames';
|
|
6
|
+
import { translate } from '../../i18n/activeLocale';
|
|
7
|
+
export function TableActionsDropdown({ schema, rowId, rowIndex, totalRows, isOpen, onToggle, onAction, }) {
|
|
8
|
+
if (!schema.actions || schema.actions.length === 0) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const buttonRef = useRef(null);
|
|
12
|
+
const [dropdownPosition, setDropdownPosition] = useState(null);
|
|
13
|
+
const opensUpward = rowIndex >= totalRows - 3;
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (isOpen && buttonRef.current) {
|
|
16
|
+
const rect = buttonRef.current.getBoundingClientRect();
|
|
17
|
+
if (opensUpward) {
|
|
18
|
+
setDropdownPosition({
|
|
19
|
+
top: rect.top - 4,
|
|
20
|
+
right: window.innerWidth - rect.right,
|
|
21
|
+
opensUpward: true,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
setDropdownPosition({
|
|
26
|
+
top: rect.bottom + 4,
|
|
27
|
+
right: window.innerWidth - rect.right,
|
|
28
|
+
opensUpward: false,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
setDropdownPosition(null);
|
|
34
|
+
}
|
|
35
|
+
}, [isOpen, opensUpward]);
|
|
36
|
+
return (_jsxs("div", { className: "relative inline-block", children: [_jsx("button", { ref: buttonRef, onClick: onToggle, className: cn('inline-flex h-8 w-8 items-center justify-center rounded-full bg-raised text-fg-secondary transition-colors', 'hover:bg-hover hover:text-fg', isOpen && 'bg-raised text-fg shadow-soft-sm ring-1 ring-border'), title: translate('core:common.actions'), "aria-label": translate('core:table.row_actions'), "aria-expanded": isOpen, children: _jsx(Icon, { name: "MoreVertical", size: 16 }) }), isOpen &&
|
|
37
|
+
createPortal(_jsxs(_Fragment, { children: [_jsx("div", { className: "fixed inset-0", style: { zIndex: 40 }, onClick: onToggle }), dropdownPosition && (_jsx("div", { className: "fixed w-48 overflow-hidden rounded-xl border border-border bg-raised shadow-soft-lg", style: {
|
|
38
|
+
zIndex: 60,
|
|
39
|
+
top: `${dropdownPosition.top}px`,
|
|
40
|
+
right: `${dropdownPosition.right}px`,
|
|
41
|
+
transform: dropdownPosition.opensUpward ? 'translateY(-100%)' : 'none',
|
|
42
|
+
}, children: _jsx("div", { className: "py-1", children: schema.actions.map(action => (_jsxs("button", { onClick: () => {
|
|
43
|
+
onToggle();
|
|
44
|
+
onAction(action.name, rowId);
|
|
45
|
+
}, className: cn('flex w-full items-center gap-2 px-4 py-2 text-left text-sm transition-colors hover:bg-hover/70', action.color || 'text-fg'), children: [action.icon && _jsx(Icon, { name: action.icon, size: 16 }), _jsx("span", { children: action.label || action.name })] }, action.name))) }) }))] }), document.body)] }));
|
|
46
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SerializedTable } from '@maxal_studio/kratosjs';
|
|
3
|
+
interface TableBulkActionsProps {
|
|
4
|
+
schema: SerializedTable;
|
|
5
|
+
selectedCount: number;
|
|
6
|
+
onBulkAction: (actionName: string, selectedIds: any[]) => void;
|
|
7
|
+
onClearSelection: () => void;
|
|
8
|
+
canDelete?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function TableBulkActions({ schema, selectedCount, onBulkAction, onClearSelection, canDelete, }: TableBulkActionsProps): React.JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Icon } from '../utils/Icon';
|
|
3
|
+
import { cn } from '../../utils/classNames';
|
|
4
|
+
import { translate } from '../../i18n/activeLocale';
|
|
5
|
+
export function TableBulkActions({ schema, selectedCount, onBulkAction, onClearSelection, canDelete = true, }) {
|
|
6
|
+
if (selectedCount === 0 || !schema.bulkActions || schema.bulkActions.length === 0) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const visibleBulkActions = schema.bulkActions.filter(action => {
|
|
10
|
+
if ((action.name === 'delete' || action.name === 'bulkDelete') && !canDelete) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return true;
|
|
14
|
+
});
|
|
15
|
+
if (visibleBulkActions.length === 0) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return (_jsxs("div", { className: "mb-4 flex items-center justify-between gap-3 rounded-full border border-border bg-raised/60 px-4 py-2.5 shadow-soft-sm", children: [_jsxs("span", { className: "text-sm font-medium text-fg", children: [selectedCount, " ", selectedCount === 1 ? 'item' : 'items', " selected"] }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [visibleBulkActions.map(action => (_jsxs("button", { onClick: () => onBulkAction(action.name, []), className: cn('inline-flex items-center gap-2 rounded-full px-3 py-1.5 text-sm font-medium transition-colors', action.color
|
|
19
|
+
? `${action.color} hover:opacity-90`
|
|
20
|
+
: 'text-fg-secondary hover:bg-hover/70 hover:text-fg'), children: [action.icon && _jsx(Icon, { name: action.icon, size: 16 }), action.label || action.name] }, action.name))), _jsx("button", { onClick: onClearSelection, className: "rounded-full px-3 py-1.5 text-sm font-medium text-fg-muted transition-colors hover:bg-hover/70 hover:text-fg", children: translate('core:common.clear') })] })] }));
|
|
21
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SerializedTable } from '@maxal_studio/kratosjs';
|
|
3
|
+
interface TableHeaderProps {
|
|
4
|
+
schema: SerializedTable;
|
|
5
|
+
visibleColumns: any[];
|
|
6
|
+
sortColumn?: string;
|
|
7
|
+
sortDirection: 'asc' | 'desc';
|
|
8
|
+
onSort: (column: string) => void;
|
|
9
|
+
selectedRowsCount: number;
|
|
10
|
+
totalRows: number;
|
|
11
|
+
onSelectAll: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function TableHeader({ schema, visibleColumns, sortColumn, sortDirection, onSort, selectedRowsCount, totalRows, onSelectAll, }: TableHeaderProps): React.JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronDown, ChevronUp } from 'lucide-react';
|
|
3
|
+
import { cn } from '../../utils/classNames';
|
|
4
|
+
import { Checkbox } from '../Checkbox';
|
|
5
|
+
import { translate } from '../../i18n/activeLocale';
|
|
6
|
+
export function TableHeader({ schema, visibleColumns, sortColumn, sortDirection, onSort, selectedRowsCount, totalRows, onSelectAll, }) {
|
|
7
|
+
return (_jsx("thead", { className: "sticky top-0 z-30 border-b border-border bg-base/80 backdrop-blur-sm", children: _jsxs("tr", { children: [schema.bulkActions && schema.bulkActions.length > 0 && (_jsx("th", { className: "w-12 px-4 py-3", children: _jsx(Checkbox, { checked: selectedRowsCount === totalRows && totalRows > 0, onChange: onSelectAll }) })), visibleColumns.map(column => {
|
|
8
|
+
const width = column.width
|
|
9
|
+
? typeof column.width === 'number'
|
|
10
|
+
? `${column.width}px`
|
|
11
|
+
: /^\d+$/.test(column.width)
|
|
12
|
+
? `${column.width}px`
|
|
13
|
+
: column.width
|
|
14
|
+
: undefined;
|
|
15
|
+
const widthStyle = width ? { width, minWidth: width, maxWidth: width } : undefined;
|
|
16
|
+
const isActiveSortColumn = sortColumn === column.name;
|
|
17
|
+
return (_jsx("th", { className: cn('px-4 py-3 text-left text-[11px] font-medium uppercase tracking-wider text-fg-muted', column.sortable && 'cursor-pointer select-none hover:text-fg-secondary'), onClick: () => column.sortable && onSort(column.name), style: widthStyle, children: _jsxs("div", { className: "flex items-center gap-1.5", children: [_jsx("span", { children: column.label || column.name }), column.sortable && (_jsxs("span", { className: "inline-flex flex-col", children: [_jsx(ChevronUp, { className: cn('-mb-1 h-3 w-3', isActiveSortColumn && sortDirection === 'asc'
|
|
18
|
+
? 'text-fg'
|
|
19
|
+
: 'text-fg-muted/60') }), _jsx(ChevronDown, { className: cn('h-3 w-3', isActiveSortColumn && sortDirection === 'desc'
|
|
20
|
+
? 'text-fg'
|
|
21
|
+
: 'text-fg-muted/60') })] }))] }) }, column.name));
|
|
22
|
+
}), _jsx("th", { className: "sticky right-0 z-20 border-l border-border bg-base px-4 py-3 text-right text-[11px] font-medium uppercase tracking-wider text-fg-muted shadow-[-6px_0_10px_-6px] shadow-black/10", children: schema.actions && schema.actions.length > 0 ? (_jsx("span", { className: "hidden sm:inline", children: translate('core:common.actions') })) : ('') })] }) }));
|
|
23
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SerializedTable } from '@maxal_studio/kratosjs';
|
|
3
|
+
interface TablePaginationProps {
|
|
4
|
+
schema: SerializedTable;
|
|
5
|
+
currentPage: number;
|
|
6
|
+
perPage: number;
|
|
7
|
+
totalRecords: number;
|
|
8
|
+
onPageChange: (page: number) => void;
|
|
9
|
+
onPageSizeChange: (size: number) => void;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function TablePagination({ schema, currentPage, perPage, totalRecords, onPageChange, onPageSizeChange, className, }: TablePaginationProps): React.JSX.Element;
|
|
13
|
+
export {};
|