@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
package/src/styles.css
ADDED
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
@import 'tailwindcss';
|
|
2
|
+
|
|
3
|
+
/* Enable class-based dark mode */
|
|
4
|
+
@custom-variant dark (&:where(.dark, .dark *));
|
|
5
|
+
|
|
6
|
+
/* Runtime-configured color utilities from resource definitions (not scannable in src) */
|
|
7
|
+
@source inline('{dark:,}bg-{black,white,transparent}');
|
|
8
|
+
@source inline('{dark:,}text-{black,white,transparent}');
|
|
9
|
+
@source inline('{dark:,}border-{black,white,transparent}');
|
|
10
|
+
@source inline('{dark:,}bg-{accent,success,danger,warning,muted,surface,raised,hover,input}');
|
|
11
|
+
@source inline('{dark:,}text-{accent,success,danger,warning,muted,surface,raised,hover,input}');
|
|
12
|
+
@source inline('{dark:,}border-{accent,success,danger,warning,muted,surface,raised,hover,input}');
|
|
13
|
+
@source inline('{dark:,}{bg,text,border}-{slate,gray,zinc,neutral,stone,red,orange,amber,yellow,lime,green,emerald,teal,cyan,sky,blue,indigo,violet,purple,fuchsia,pink,rose}-{50,{100..900..100},950}');
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
* Spacing & layout utilities for plugin components.
|
|
17
|
+
* Plugins ship precompiled JS — Tailwind cannot scan their sources, so
|
|
18
|
+
* padding/margin/gap/space classes must be safelisted here.
|
|
19
|
+
*/
|
|
20
|
+
@source inline('{m,p}{x,y,t,b,l,r}-{0,0.5,1,1.5,2,2.5,3,3.5,4,5,6,7,8,9,10,11,12,14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96}');
|
|
21
|
+
@source inline('-m{x,y,t,b,l,r}-{0,0.5,1,1.5,2,3,4,5,6,8}');
|
|
22
|
+
@source inline('mx-auto');
|
|
23
|
+
@source inline('ml-auto');
|
|
24
|
+
@source inline('mr-auto');
|
|
25
|
+
@source inline('gap-{0,0.5,1,1.5,2,2.5,3,4,5,6,7,8,9,10,11,12}');
|
|
26
|
+
@source inline('space-y-{0,0.5,1,1.5,2,2.5,3,4,5,6,7,8,9,10,11,12}');
|
|
27
|
+
@source inline('space-x-{0,0.5,1,1.5,2,2.5,3,4,5,6,7,8,9,10,11,12}');
|
|
28
|
+
@source inline('{sm:,md:,lg:,xl:,2xl:}{m,p}{x,y,t,b,l,r}-{0,0.5,1,1.5,2,2.5,3,3.5,4,5,6,7,8,9,10,11,12,14,16,20,24}');
|
|
29
|
+
@source inline('{sm:,md:,lg:,xl:,2xl:}gap-{0,1,2,3,4,5,6,8}');
|
|
30
|
+
@source inline('{sm:,md:,lg:,xl:,2xl:}space-y-{0,2,3,4,6,8}');
|
|
31
|
+
@source inline('{sm:,md:,lg:,xl:,2xl:}space-x-{0,2,3,4,6,8}');
|
|
32
|
+
|
|
33
|
+
/* ============================================
|
|
34
|
+
KratosJS Design Tokens
|
|
35
|
+
--------------------------------------------
|
|
36
|
+
The --kratos-* variables are the single source of truth for the panel's
|
|
37
|
+
look. Consumers can re-theme the panel (accent color, radii, surfaces)
|
|
38
|
+
by overriding these variables in their own CSS, or via
|
|
39
|
+
mountAdminPanel({ accentColor }).
|
|
40
|
+
============================================ */
|
|
41
|
+
|
|
42
|
+
:root {
|
|
43
|
+
/* Surfaces */
|
|
44
|
+
--kratos-bg: #f7f8fa;
|
|
45
|
+
--kratos-surface: #ffffff;
|
|
46
|
+
--kratos-surface-raised: #ffffff;
|
|
47
|
+
--kratos-muted: #f3f4f6;
|
|
48
|
+
--kratos-hover: #f4f5f7;
|
|
49
|
+
|
|
50
|
+
/* Lines */
|
|
51
|
+
--kratos-border: #e6e8ec;
|
|
52
|
+
--kratos-border-strong: #d4d7dd;
|
|
53
|
+
|
|
54
|
+
/* Text */
|
|
55
|
+
--kratos-fg: #18181b;
|
|
56
|
+
--kratos-fg-secondary: #52525b;
|
|
57
|
+
--kratos-fg-muted: #9ca3af;
|
|
58
|
+
|
|
59
|
+
/* Accent (configurable) */
|
|
60
|
+
--kratos-accent: #2563eb;
|
|
61
|
+
--kratos-accent-hover: #1d4ed8;
|
|
62
|
+
--kratos-accent-fg: #ffffff;
|
|
63
|
+
--kratos-accent-soft: #dbeafe;
|
|
64
|
+
--kratos-ring: color-mix(in srgb, var(--kratos-accent) 35%, transparent);
|
|
65
|
+
|
|
66
|
+
/* Status */
|
|
67
|
+
--kratos-danger: #dc2626;
|
|
68
|
+
--kratos-danger-hover: #b91c1c;
|
|
69
|
+
--kratos-danger-soft: #fee2e2;
|
|
70
|
+
--kratos-success: #059669;
|
|
71
|
+
--kratos-success-soft: #d1fae5;
|
|
72
|
+
--kratos-warning: #d97706;
|
|
73
|
+
--kratos-warning-soft: #fef3c7;
|
|
74
|
+
|
|
75
|
+
/* Shape & elevation */
|
|
76
|
+
--kratos-radius: 0.5rem;
|
|
77
|
+
--kratos-shadow-sm: 0 1px 2px 0 rgb(16 24 40 / 0.04);
|
|
78
|
+
--kratos-shadow-md: 0 2px 8px -2px rgb(16 24 40 / 0.08), 0 1px 2px 0 rgb(16 24 40 / 0.04);
|
|
79
|
+
--kratos-shadow-lg: 0 12px 24px -6px rgb(16 24 40 / 0.14), 0 2px 8px -2px rgb(16 24 40 / 0.08);
|
|
80
|
+
|
|
81
|
+
/* Inputs */
|
|
82
|
+
--kratos-input-bg: #ffffff;
|
|
83
|
+
--kratos-input-border: #d4d7dd;
|
|
84
|
+
--kratos-input-placeholder: #9ca3af;
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.dark {
|
|
89
|
+
/* Surfaces */
|
|
90
|
+
--kratos-bg: #0b0b0d;
|
|
91
|
+
--kratos-surface: #151517;
|
|
92
|
+
--kratos-surface-raised: #1c1c1f;
|
|
93
|
+
--kratos-muted: #1f1f23;
|
|
94
|
+
--kratos-hover: #232327;
|
|
95
|
+
|
|
96
|
+
/* Lines */
|
|
97
|
+
--kratos-border: rgba(255, 255, 255, 0.08);
|
|
98
|
+
--kratos-border-strong: rgba(255, 255, 255, 0.16);
|
|
99
|
+
|
|
100
|
+
/* Text */
|
|
101
|
+
--kratos-fg: #f4f4f5;
|
|
102
|
+
--kratos-fg-secondary: #a1a1aa;
|
|
103
|
+
--kratos-fg-muted: #71717a;
|
|
104
|
+
|
|
105
|
+
/* Accent */
|
|
106
|
+
--kratos-accent: #3b82f6;
|
|
107
|
+
--kratos-accent-hover: #60a5fa;
|
|
108
|
+
--kratos-accent-fg: #ffffff;
|
|
109
|
+
--kratos-accent-soft: color-mix(in srgb, var(--kratos-accent) 18%, transparent);
|
|
110
|
+
|
|
111
|
+
/* Status */
|
|
112
|
+
--kratos-danger: #ef4444;
|
|
113
|
+
--kratos-danger-hover: #f87171;
|
|
114
|
+
--kratos-danger-soft: rgba(239, 68, 68, 0.15);
|
|
115
|
+
--kratos-success: #10b981;
|
|
116
|
+
--kratos-success-soft: rgba(16, 185, 129, 0.15);
|
|
117
|
+
--kratos-warning: #f59e0b;
|
|
118
|
+
--kratos-warning-soft: rgba(245, 158, 11, 0.15);
|
|
119
|
+
|
|
120
|
+
/* Elevation */
|
|
121
|
+
--kratos-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.35);
|
|
122
|
+
--kratos-shadow-md: 0 2px 8px -2px rgb(0 0 0 / 0.45);
|
|
123
|
+
--kratos-shadow-lg: 0 12px 24px -6px rgb(0 0 0 / 0.55);
|
|
124
|
+
|
|
125
|
+
/* Inputs */
|
|
126
|
+
--kratos-input-bg: #232326;
|
|
127
|
+
--kratos-input-border: #43434a;
|
|
128
|
+
--kratos-input-placeholder: #71717a;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* ============================================
|
|
132
|
+
Tailwind theme mapping
|
|
133
|
+
--------------------------------------------
|
|
134
|
+
Exposes the tokens as first-class Tailwind utilities (bg-surface,
|
|
135
|
+
text-fg-secondary, border-border, bg-accent, ring-ring, ...) that
|
|
136
|
+
respond to .dark automatically through the variable indirection.
|
|
137
|
+
============================================ */
|
|
138
|
+
|
|
139
|
+
@theme inline {
|
|
140
|
+
--color-base: var(--kratos-bg);
|
|
141
|
+
--color-surface: var(--kratos-surface);
|
|
142
|
+
--color-raised: var(--kratos-surface-raised);
|
|
143
|
+
--color-muted: var(--kratos-muted);
|
|
144
|
+
--color-hover: var(--kratos-hover);
|
|
145
|
+
|
|
146
|
+
--color-border: var(--kratos-border);
|
|
147
|
+
--color-border-strong: var(--kratos-border-strong);
|
|
148
|
+
|
|
149
|
+
--color-fg: var(--kratos-fg);
|
|
150
|
+
--color-fg-secondary: var(--kratos-fg-secondary);
|
|
151
|
+
--color-fg-muted: var(--kratos-fg-muted);
|
|
152
|
+
|
|
153
|
+
--color-accent: var(--kratos-accent);
|
|
154
|
+
--color-accent-hover: var(--kratos-accent-hover);
|
|
155
|
+
--color-accent-fg: var(--kratos-accent-fg);
|
|
156
|
+
--color-accent-soft: var(--kratos-accent-soft);
|
|
157
|
+
--color-ring: var(--kratos-ring);
|
|
158
|
+
|
|
159
|
+
--color-danger: var(--kratos-danger);
|
|
160
|
+
--color-danger-hover: var(--kratos-danger-hover);
|
|
161
|
+
--color-danger-soft: var(--kratos-danger-soft);
|
|
162
|
+
--color-success: var(--kratos-success);
|
|
163
|
+
--color-success-soft: var(--kratos-success-soft);
|
|
164
|
+
--color-warning: var(--kratos-warning);
|
|
165
|
+
--color-warning-soft: var(--kratos-warning-soft);
|
|
166
|
+
|
|
167
|
+
--color-input: var(--kratos-input-bg);
|
|
168
|
+
--color-input-border: var(--kratos-input-border);
|
|
169
|
+
|
|
170
|
+
--shadow-soft-sm: var(--kratos-shadow-sm);
|
|
171
|
+
--shadow-soft: var(--kratos-shadow-md);
|
|
172
|
+
--shadow-soft-lg: var(--kratos-shadow-lg);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* ============================================
|
|
176
|
+
Stable plugin styling contract
|
|
177
|
+
--------------------------------------------
|
|
178
|
+
Plugins ship precompiled JS, so Tailwind cannot scan their sources;
|
|
179
|
+
arbitrary utilities are NOT guaranteed to exist in this stylesheet.
|
|
180
|
+
Standard spacing (p-*, m-*, gap-*, space-y-*) is safelisted via @source
|
|
181
|
+
inline() above; prefer those scale values over arbitrary classes.
|
|
182
|
+
These plain semantic classes (plus the exported UI primitives) are the
|
|
183
|
+
supported way for plugin components to match the panel theme.
|
|
184
|
+
============================================ */
|
|
185
|
+
|
|
186
|
+
.k-surface {
|
|
187
|
+
background-color: var(--kratos-surface);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.k-muted {
|
|
191
|
+
background-color: var(--kratos-muted);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.k-text {
|
|
195
|
+
color: var(--kratos-fg);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.k-text-secondary {
|
|
199
|
+
color: var(--kratos-fg-secondary);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.k-text-muted {
|
|
203
|
+
color: var(--kratos-fg-muted);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.k-border {
|
|
207
|
+
border-color: var(--kratos-border);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.k-accent {
|
|
211
|
+
color: var(--kratos-accent);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.k-input {
|
|
215
|
+
background-color: var(--kratos-input-bg);
|
|
216
|
+
border-color: var(--kratos-input-border);
|
|
217
|
+
color: var(--kratos-fg);
|
|
218
|
+
border-radius: var(--kratos-radius);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.k-input::placeholder {
|
|
222
|
+
color: var(--kratos-input-placeholder);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.k-input:focus {
|
|
226
|
+
border-color: var(--kratos-accent);
|
|
227
|
+
outline: none;
|
|
228
|
+
box-shadow: 0 0 0 3px var(--kratos-ring);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* Section depth in dark mode: progressively darker surfaces so each
|
|
232
|
+
nesting level is clearly distinguishable. Derived from the bg token. */
|
|
233
|
+
.dark .section-depth-bg[data-section-depth='1'] {
|
|
234
|
+
background-color: color-mix(in srgb, var(--kratos-surface-raised) 92%, white) !important;
|
|
235
|
+
}
|
|
236
|
+
.dark .section-depth-bg[data-section-depth='2'] {
|
|
237
|
+
background-color: var(--kratos-surface) !important;
|
|
238
|
+
}
|
|
239
|
+
.dark .section-depth-bg[data-section-depth='3'] {
|
|
240
|
+
background-color: color-mix(in srgb, var(--kratos-surface) 80%, black) !important;
|
|
241
|
+
}
|
|
242
|
+
.dark .section-depth-bg[data-section-depth='4'] {
|
|
243
|
+
background-color: color-mix(in srgb, var(--kratos-surface) 62%, black) !important;
|
|
244
|
+
}
|
|
245
|
+
.dark .section-depth-bg[data-section-depth='5'] {
|
|
246
|
+
background-color: color-mix(in srgb, var(--kratos-surface) 48%, black) !important;
|
|
247
|
+
}
|
|
248
|
+
.dark .section-depth-bg[data-section-depth='6'] {
|
|
249
|
+
background-color: color-mix(in srgb, var(--kratos-surface) 34%, black) !important;
|
|
250
|
+
}
|
|
251
|
+
.dark .section-depth-bg[data-section-depth='7'] {
|
|
252
|
+
background-color: color-mix(in srgb, var(--kratos-surface) 20%, black) !important;
|
|
253
|
+
}
|
|
254
|
+
.dark .section-depth-bg[data-section-depth='8'] {
|
|
255
|
+
background-color: #000000 !important;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/* ============================================
|
|
259
|
+
TipTap Rich Editor Styles
|
|
260
|
+
============================================ */
|
|
261
|
+
.rich-editor-content .tiptap {
|
|
262
|
+
outline: none;
|
|
263
|
+
color: var(--kratos-fg);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.rich-editor-content .tiptap p {
|
|
267
|
+
margin: 0.75rem 0;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.rich-editor-content .tiptap p:first-child {
|
|
271
|
+
margin-top: 0;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.rich-editor-content .tiptap p:last-child {
|
|
275
|
+
margin-bottom: 0;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.rich-editor-content .tiptap h1 {
|
|
279
|
+
font-size: 2rem;
|
|
280
|
+
font-weight: 700;
|
|
281
|
+
line-height: 2.5rem;
|
|
282
|
+
margin: 1.5rem 0 1rem 0;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.rich-editor-content .tiptap h2 {
|
|
286
|
+
font-size: 1.5rem;
|
|
287
|
+
font-weight: 600;
|
|
288
|
+
line-height: 2rem;
|
|
289
|
+
margin: 1.25rem 0 0.75rem 0;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.rich-editor-content .tiptap h3 {
|
|
293
|
+
font-size: 1.25rem;
|
|
294
|
+
font-weight: 600;
|
|
295
|
+
line-height: 1.75rem;
|
|
296
|
+
margin: 1rem 0 0.5rem 0;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.rich-editor-content .tiptap h1:first-child,
|
|
300
|
+
.rich-editor-content .tiptap h2:first-child,
|
|
301
|
+
.rich-editor-content .tiptap h3:first-child {
|
|
302
|
+
margin-top: 0;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.rich-editor-content .tiptap ul,
|
|
306
|
+
.rich-editor-content .tiptap ol {
|
|
307
|
+
padding-left: 1.5rem;
|
|
308
|
+
margin: 0.75rem 0;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.rich-editor-content .tiptap ul {
|
|
312
|
+
list-style-type: disc;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.rich-editor-content .tiptap ol {
|
|
316
|
+
list-style-type: decimal;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.rich-editor-content .tiptap li {
|
|
320
|
+
margin: 0.25rem 0;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.rich-editor-content .tiptap blockquote {
|
|
324
|
+
border-left: 4px solid var(--kratos-border);
|
|
325
|
+
padding-left: 1rem;
|
|
326
|
+
margin: 1rem 0;
|
|
327
|
+
color: var(--kratos-fg-secondary);
|
|
328
|
+
font-style: italic;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.rich-editor-content .tiptap code {
|
|
332
|
+
background-color: var(--kratos-muted);
|
|
333
|
+
border-radius: 0.25rem;
|
|
334
|
+
padding: 0.125rem 0.375rem;
|
|
335
|
+
font-family: 'Courier New', monospace;
|
|
336
|
+
font-size: 0.875rem;
|
|
337
|
+
color: var(--kratos-fg);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.rich-editor-content .tiptap pre {
|
|
341
|
+
background-color: var(--kratos-muted);
|
|
342
|
+
border-radius: 0.5rem;
|
|
343
|
+
padding: 1rem;
|
|
344
|
+
margin: 1rem 0;
|
|
345
|
+
overflow-x: auto;
|
|
346
|
+
border: 1px solid var(--kratos-border);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.rich-editor-content .tiptap pre code {
|
|
350
|
+
background: none;
|
|
351
|
+
color: var(--kratos-fg);
|
|
352
|
+
padding: 0;
|
|
353
|
+
font-size: 0.875rem;
|
|
354
|
+
line-height: 1.5;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
.rich-editor-content .tiptap strong {
|
|
358
|
+
font-weight: 700;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.rich-editor-content .tiptap em {
|
|
362
|
+
font-style: italic;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.rich-editor-content .tiptap s {
|
|
366
|
+
text-decoration: line-through;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/* Placeholder styling */
|
|
370
|
+
.rich-editor-content .tiptap p.is-editor-empty:first-child::before {
|
|
371
|
+
content: attr(data-placeholder);
|
|
372
|
+
float: left;
|
|
373
|
+
color: var(--kratos-input-placeholder);
|
|
374
|
+
pointer-events: none;
|
|
375
|
+
height: 0;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.rich-editor-content .tiptap u {
|
|
379
|
+
text-decoration: underline;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.rich-editor-content .tiptap sub {
|
|
383
|
+
vertical-align: sub;
|
|
384
|
+
font-size: 0.75em;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.rich-editor-content .tiptap sup {
|
|
388
|
+
vertical-align: super;
|
|
389
|
+
font-size: 0.75em;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
.rich-editor-content .tiptap mark {
|
|
393
|
+
background-color: #fef08a;
|
|
394
|
+
color: #854d0e;
|
|
395
|
+
padding: 0.125rem 0;
|
|
396
|
+
border-radius: 0.125rem;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
.rich-editor-content .tiptap a {
|
|
400
|
+
color: var(--kratos-accent);
|
|
401
|
+
text-decoration: underline;
|
|
402
|
+
cursor: pointer;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
.rich-editor-content .tiptap a:hover {
|
|
406
|
+
color: var(--kratos-accent-hover);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
.rich-editor-content .tiptap [style*='text-align: center'] {
|
|
410
|
+
text-align: center;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
.rich-editor-content .tiptap [style*='text-align: right'] {
|
|
414
|
+
text-align: right;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
.rich-editor-content .tiptap [style*='text-align: left'] {
|
|
418
|
+
text-align: left;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/* ============================================
|
|
422
|
+
Date/DateTime Input Icon Fix for Dark Mode
|
|
423
|
+
============================================ */
|
|
424
|
+
|
|
425
|
+
/* In dark mode, make browser's native date/time icons light-colored */
|
|
426
|
+
.dark input[type='date'],
|
|
427
|
+
.dark input[type='datetime-local'],
|
|
428
|
+
.dark input[type='time'] {
|
|
429
|
+
color-scheme: dark;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/* In light mode, ensure icons are dark */
|
|
433
|
+
input[type='date'],
|
|
434
|
+
input[type='datetime-local'],
|
|
435
|
+
input[type='time'] {
|
|
436
|
+
color-scheme: light;
|
|
437
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, { createContext, useContext } from 'react';
|
|
2
|
+
import { SerializedColumn, SerializedTable } from '@maxal_studio/kratosjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Shared table state and handlers for row-level components (TableRow,
|
|
6
|
+
* GridCard, TableView). Replaces the 15-prop drilling of v1.
|
|
7
|
+
*/
|
|
8
|
+
export interface TableContextValue {
|
|
9
|
+
schema: SerializedTable & { canCreate?: boolean; canEdit?: boolean; canDelete?: boolean; canView?: boolean };
|
|
10
|
+
visibleColumns: SerializedColumn[];
|
|
11
|
+
/** Actions filtered by the resource's can* capabilities */
|
|
12
|
+
visibleActions: any[];
|
|
13
|
+
data: any[];
|
|
14
|
+
isLoading: boolean;
|
|
15
|
+
error: string | null;
|
|
16
|
+
setError: (error: string | null) => void;
|
|
17
|
+
selectedRows: Set<any>;
|
|
18
|
+
changedRows: Map<any, any>;
|
|
19
|
+
openActionsRowId: any;
|
|
20
|
+
onToggleActions: (rowId: any) => void;
|
|
21
|
+
onRowSelect: (rowId: any) => void;
|
|
22
|
+
onSelectAll: () => void;
|
|
23
|
+
onCellChange: (rowId: any, columnName: string, value: any) => void;
|
|
24
|
+
onRowAction: (actionName: string, rowId: any) => void;
|
|
25
|
+
onSaveRow: (rowId: any) => void;
|
|
26
|
+
onResetRow: (rowId: any) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const TableContext = createContext<TableContextValue | null>(null);
|
|
30
|
+
|
|
31
|
+
export function TableProvider({ value, children }: { value: TableContextValue; children: React.ReactNode }) {
|
|
32
|
+
return <TableContext.Provider value={value}>{children}</TableContext.Provider>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function useTableContext(): TableContextValue {
|
|
36
|
+
const context = useContext(TableContext);
|
|
37
|
+
if (!context) {
|
|
38
|
+
throw new Error('useTableContext must be used within a TableRenderer');
|
|
39
|
+
}
|
|
40
|
+
return context;
|
|
41
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
6
|
+
import { TableRenderer } from './TableRenderer';
|
|
7
|
+
import { ResourceModalProvider } from '../contexts/ResourceModalContext';
|
|
8
|
+
import { mockFetch, restoreFetch, RecordedRequest } from '../test/mockFetch';
|
|
9
|
+
|
|
10
|
+
const API = 'http://api.test/admin';
|
|
11
|
+
|
|
12
|
+
const tableSchema = {
|
|
13
|
+
resource: 'users',
|
|
14
|
+
searchable: true,
|
|
15
|
+
recordsPerPage: 10,
|
|
16
|
+
columns: [
|
|
17
|
+
{ name: 'name', label: 'Name', type: 'text' },
|
|
18
|
+
{ name: 'email', label: 'Email', type: 'text' },
|
|
19
|
+
],
|
|
20
|
+
actions: [],
|
|
21
|
+
bulkActions: [],
|
|
22
|
+
} as any;
|
|
23
|
+
|
|
24
|
+
function renderTable(props: Partial<React.ComponentProps<typeof TableRenderer>> = {}) {
|
|
25
|
+
return render(
|
|
26
|
+
<MemoryRouter>
|
|
27
|
+
<ResourceModalProvider>
|
|
28
|
+
<TableRenderer isResource apiUrl={`${API}/users`} schema={tableSchema} {...props} />
|
|
29
|
+
</ResourceModalProvider>
|
|
30
|
+
</MemoryRouter>,
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
describe('TableRenderer', () => {
|
|
35
|
+
let requests: RecordedRequest[];
|
|
36
|
+
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
localStorage.clear();
|
|
39
|
+
requests = mockFetch([
|
|
40
|
+
{
|
|
41
|
+
match: '/users/list',
|
|
42
|
+
body: (_url, init) => {
|
|
43
|
+
const params = JSON.parse((init?.body as string) || '{}');
|
|
44
|
+
const rows = params.search
|
|
45
|
+
? [{ id: 1, name: 'Jane', email: 'jane@max.al' }]
|
|
46
|
+
: [
|
|
47
|
+
{ id: 1, name: 'Jane', email: 'jane@max.al' },
|
|
48
|
+
{ id: 2, name: 'Bob', email: 'bob@max.al' },
|
|
49
|
+
];
|
|
50
|
+
return {
|
|
51
|
+
data: rows,
|
|
52
|
+
pagination: {
|
|
53
|
+
page: 1,
|
|
54
|
+
limit: 10,
|
|
55
|
+
total: rows.length,
|
|
56
|
+
pages: 1,
|
|
57
|
+
hasNext: false,
|
|
58
|
+
hasPrev: false,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
]);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
afterEach(() => {
|
|
67
|
+
restoreFetch();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('loads and renders rows', async () => {
|
|
71
|
+
renderTable();
|
|
72
|
+
expect(await screen.findByText('Jane')).toBeInTheDocument();
|
|
73
|
+
expect(screen.getByText('Bob')).toBeInTheDocument();
|
|
74
|
+
|
|
75
|
+
const listRequests = requests.filter(r => r.url.includes('/users/list'));
|
|
76
|
+
expect(listRequests.length).toBeGreaterThan(0);
|
|
77
|
+
expect(listRequests[0].body).toMatchObject({ page: 1, perPage: 10 });
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('sends the search term in the request payload', async () => {
|
|
81
|
+
const user = userEvent.setup();
|
|
82
|
+
renderTable();
|
|
83
|
+
await screen.findByText('Bob');
|
|
84
|
+
|
|
85
|
+
// TableSearchBar renders separate inputs for mobile and desktop
|
|
86
|
+
const searchInput = screen.getAllByPlaceholderText(/search/i)[0];
|
|
87
|
+
await user.type(searchInput, 'jane');
|
|
88
|
+
|
|
89
|
+
await waitFor(() => {
|
|
90
|
+
const last = requests.filter(r => r.url.includes('/users/list')).pop();
|
|
91
|
+
expect(last?.body).toMatchObject({ search: 'jane', page: 1 });
|
|
92
|
+
});
|
|
93
|
+
await waitFor(() => expect(screen.queryByText('Bob')).not.toBeInTheDocument());
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('shows an empty state when there are no rows', async () => {
|
|
97
|
+
restoreFetch();
|
|
98
|
+
mockFetch([
|
|
99
|
+
{
|
|
100
|
+
match: '/users/list',
|
|
101
|
+
body: {
|
|
102
|
+
data: [],
|
|
103
|
+
pagination: { page: 1, limit: 10, total: 0, pages: 0, hasNext: false, hasPrev: false },
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
]);
|
|
107
|
+
renderTable();
|
|
108
|
+
expect(await screen.findByText('No records found')).toBeInTheDocument();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('shows the error alert when the request fails', async () => {
|
|
112
|
+
restoreFetch();
|
|
113
|
+
mockFetch([{ match: '/users/list', status: 500, body: { message: 'Database exploded' } }]);
|
|
114
|
+
renderTable();
|
|
115
|
+
expect(await screen.findByText('Database exploded')).toBeInTheDocument();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('derives view/edit/delete row actions from capabilities, with custom actions in between', async () => {
|
|
119
|
+
const user = userEvent.setup();
|
|
120
|
+
// No built-in actions declared — only a custom one. Capabilities default to true.
|
|
121
|
+
renderTable({
|
|
122
|
+
schema: {
|
|
123
|
+
...tableSchema,
|
|
124
|
+
actions: [{ type: 'action', name: 'archive', label: 'Archive', icon: 'Archive', hasHandler: true }],
|
|
125
|
+
} as any,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
await screen.findByText('Jane');
|
|
129
|
+
|
|
130
|
+
// Open the first row's actions dropdown.
|
|
131
|
+
const toggles = screen.getAllByRole('button', { name: /row actions/i });
|
|
132
|
+
await user.click(toggles[0]);
|
|
133
|
+
|
|
134
|
+
const view = await screen.findByText('View');
|
|
135
|
+
const edit = screen.getByText('Edit');
|
|
136
|
+
const archive = screen.getByText('Archive');
|
|
137
|
+
const del = screen.getByText('Delete');
|
|
138
|
+
|
|
139
|
+
expect(view).toBeInTheDocument();
|
|
140
|
+
// Order: view, edit, …custom, delete
|
|
141
|
+
expect(edit.compareDocumentPosition(archive) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
142
|
+
expect(archive.compareDocumentPosition(del) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('omits row actions disabled by capability flags', async () => {
|
|
146
|
+
const user = userEvent.setup();
|
|
147
|
+
renderTable({ canEdit: false, canDelete: false });
|
|
148
|
+
|
|
149
|
+
await screen.findByText('Jane');
|
|
150
|
+
const toggles = screen.getAllByRole('button', { name: /row actions/i });
|
|
151
|
+
await user.click(toggles[0]);
|
|
152
|
+
|
|
153
|
+
expect(await screen.findByText('View')).toBeInTheDocument();
|
|
154
|
+
expect(screen.queryByText('Edit')).not.toBeInTheDocument();
|
|
155
|
+
expect(screen.queryByText('Delete')).not.toBeInTheDocument();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('renders header actions and triggers an export download on click', async () => {
|
|
159
|
+
// jsdom does not implement object URLs; stub them for the download helper.
|
|
160
|
+
const createObjectURL = vi.fn(() => 'blob:mock');
|
|
161
|
+
const revokeObjectURL = vi.fn();
|
|
162
|
+
(URL as any).createObjectURL = createObjectURL;
|
|
163
|
+
(URL as any).revokeObjectURL = revokeObjectURL;
|
|
164
|
+
// jsdom logs "Not implemented: navigation" when the download anchor is clicked.
|
|
165
|
+
const clickSpy = vi.spyOn(HTMLAnchorElement.prototype, 'click').mockImplementation(() => {});
|
|
166
|
+
|
|
167
|
+
restoreFetch();
|
|
168
|
+
const exportRequests = mockFetch([
|
|
169
|
+
{
|
|
170
|
+
match: '/users/list',
|
|
171
|
+
body: {
|
|
172
|
+
data: [{ id: 1, name: 'Jane', email: 'jane@max.al' }],
|
|
173
|
+
pagination: { page: 1, limit: 10, total: 1, pages: 1, hasNext: false, hasPrev: false },
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
{ match: '/users/export', body: 'Name,Email\nJane,jane@max.al\n' },
|
|
177
|
+
]);
|
|
178
|
+
|
|
179
|
+
const schemaWithHeaderAction = {
|
|
180
|
+
...tableSchema,
|
|
181
|
+
headerActions: [{ type: 'action', name: 'exportCsv', label: 'Export', export: 'csv' }],
|
|
182
|
+
} as any;
|
|
183
|
+
|
|
184
|
+
const user = userEvent.setup();
|
|
185
|
+
renderTable({ schema: schemaWithHeaderAction });
|
|
186
|
+
|
|
187
|
+
const exportButton = await screen.findByRole('button', { name: /export/i });
|
|
188
|
+
await user.click(exportButton);
|
|
189
|
+
|
|
190
|
+
await waitFor(() => {
|
|
191
|
+
const exportCall = exportRequests.find(r => r.url.includes('/users/export'));
|
|
192
|
+
expect(exportCall?.body).toMatchObject({ format: 'csv' });
|
|
193
|
+
});
|
|
194
|
+
expect(createObjectURL).toHaveBeenCalled();
|
|
195
|
+
expect(clickSpy).toHaveBeenCalled();
|
|
196
|
+
});
|
|
197
|
+
});
|