@questpie/admin 1.1.1 → 2.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 +245 -474
- package/dist/_virtual/rolldown_runtime.mjs +18 -0
- package/dist/augmentation.d.mts +315 -0
- package/dist/augmentation.d.mts.map +1 -0
- package/dist/client/blocks/block-registry.d.mts +199 -0
- package/dist/client/blocks/block-registry.d.mts.map +1 -0
- package/dist/client/blocks/block-registry.mjs +88 -0
- package/dist/client/blocks/block-registry.mjs.map +1 -0
- package/dist/client/blocks/block-renderer.d.mts +52 -0
- package/dist/client/blocks/block-renderer.d.mts.map +1 -0
- package/dist/client/blocks/block-renderer.mjs +71 -0
- package/dist/client/blocks/block-renderer.mjs.map +1 -0
- package/dist/client/blocks/index.d.mts +4 -0
- package/dist/client/blocks/prefetch.d.mts +45 -0
- package/dist/client/blocks/prefetch.d.mts.map +1 -0
- package/dist/client/blocks/prefetch.mjs +26 -0
- package/dist/client/blocks/prefetch.mjs.map +1 -0
- package/dist/client/blocks/types.d.mts +69 -0
- package/dist/client/blocks/types.d.mts.map +1 -0
- package/dist/client/blocks/types.mjs +20 -0
- package/dist/client/blocks/types.mjs.map +1 -0
- package/dist/client/builder/admin-builder.d.mts +112 -0
- package/dist/client/builder/admin-builder.d.mts.map +1 -0
- package/dist/client/builder/admin-builder.mjs +185 -0
- package/dist/client/builder/admin-builder.mjs.map +1 -0
- package/dist/client/builder/admin-types.d.mts +73 -0
- package/dist/client/builder/admin-types.d.mts.map +1 -0
- package/dist/client/builder/admin.d.mts +121 -0
- package/dist/client/builder/admin.d.mts.map +1 -0
- package/dist/client/builder/admin.mjs +160 -0
- package/dist/client/builder/admin.mjs.map +1 -0
- package/dist/client/builder/defaults/components.mjs +20 -0
- package/dist/client/builder/defaults/components.mjs.map +1 -0
- package/dist/client/builder/defaults/core.d.mts +354 -0
- package/dist/client/builder/defaults/core.d.mts.map +1 -0
- package/dist/client/builder/defaults/core.mjs +49 -0
- package/dist/client/builder/defaults/core.mjs.map +1 -0
- package/dist/client/builder/defaults/fields.mjs +328 -0
- package/dist/client/builder/defaults/fields.mjs.map +1 -0
- package/dist/client/builder/defaults/pages.mjs +58 -0
- package/dist/client/builder/defaults/pages.mjs.map +1 -0
- package/dist/client/builder/defaults/starter.d.mts +351 -0
- package/dist/client/builder/defaults/starter.d.mts.map +1 -0
- package/dist/client/builder/defaults/starter.mjs +28 -0
- package/dist/client/builder/defaults/starter.mjs.map +1 -0
- package/dist/client/builder/defaults/views.mjs +27 -0
- package/dist/client/builder/defaults/views.mjs.map +1 -0
- package/dist/client/builder/defaults/widgets.mjs +31 -0
- package/dist/client/builder/defaults/widgets.mjs.map +1 -0
- package/dist/client/builder/field/field.d.mts +229 -0
- package/dist/client/builder/field/field.d.mts.map +1 -0
- package/dist/client/builder/field/field.mjs +83 -0
- package/dist/client/builder/field/field.mjs.map +1 -0
- package/dist/client/builder/index.d.mts +36 -0
- package/dist/client/builder/index.d.mts.map +1 -0
- package/dist/client/builder/page/page.d.mts +36 -0
- package/dist/client/builder/page/page.d.mts.map +1 -0
- package/dist/client/builder/page/page.mjs +27 -0
- package/dist/client/builder/page/page.mjs.map +1 -0
- package/dist/client/builder/proxies.d.mts +2 -0
- package/dist/client/builder/proxies.mjs +24 -0
- package/dist/client/builder/proxies.mjs.map +1 -0
- package/dist/client/builder/qa.d.mts +50 -0
- package/dist/client/builder/qa.d.mts.map +1 -0
- package/dist/client/builder/qa.mjs +42 -0
- package/dist/client/builder/qa.mjs.map +1 -0
- package/dist/client/builder/registry.d.mts +70 -0
- package/dist/client/builder/registry.d.mts.map +1 -0
- package/dist/client/builder/types/action-registry.d.mts +2 -0
- package/dist/client/builder/types/action-registry.mjs +142 -0
- package/dist/client/builder/types/action-registry.mjs.map +1 -0
- package/dist/client/builder/types/action-types.d.mts +253 -0
- package/dist/client/builder/types/action-types.d.mts.map +1 -0
- package/dist/client/builder/types/collection-types.d.mts +199 -0
- package/dist/client/builder/types/collection-types.d.mts.map +1 -0
- package/dist/client/builder/types/collection-types.mjs +11 -0
- package/dist/client/builder/types/collection-types.mjs.map +1 -0
- package/dist/client/builder/types/common.d.mts +60 -0
- package/dist/client/builder/types/common.d.mts.map +1 -0
- package/dist/client/builder/types/field-types.d.mts +593 -0
- package/dist/client/builder/types/field-types.d.mts.map +1 -0
- package/dist/client/builder/types/field-types.mjs +19 -0
- package/dist/client/builder/types/field-types.mjs.map +1 -0
- package/dist/client/builder/types/global-types.d.mts +22 -0
- package/dist/client/builder/types/global-types.d.mts.map +1 -0
- package/dist/client/builder/types/ui-config.d.mts +160 -0
- package/dist/client/builder/types/ui-config.d.mts.map +1 -0
- package/dist/client/builder/types/views.d.mts +89 -0
- package/dist/client/builder/types/views.d.mts.map +1 -0
- package/dist/client/builder/types/widget-types.d.mts +563 -0
- package/dist/client/builder/types/widget-types.d.mts.map +1 -0
- package/dist/client/builder/validation.d.mts +3 -0
- package/dist/client/builder/validation.mjs +208 -0
- package/dist/client/builder/validation.mjs.map +1 -0
- package/dist/client/builder/view/view.d.mts +129 -0
- package/dist/client/builder/view/view.d.mts.map +1 -0
- package/dist/client/builder/view/view.mjs +109 -0
- package/dist/client/builder/view/view.mjs.map +1 -0
- package/dist/client/builder/widget/widget.d.mts +33 -0
- package/dist/client/builder/widget/widget.d.mts.map +1 -0
- package/dist/client/builder/widget/widget.mjs +26 -0
- package/dist/client/builder/widget/widget.mjs.map +1 -0
- package/dist/client/components/actions/action-button.d.mts +2 -0
- package/dist/client/components/actions/action-button.mjs +135 -0
- package/dist/client/components/actions/action-button.mjs.map +1 -0
- package/dist/client/components/actions/action-dialog.d.mts +2 -0
- package/dist/client/components/actions/action-dialog.mjs +264 -0
- package/dist/client/components/actions/action-dialog.mjs.map +1 -0
- package/dist/client/components/actions/confirmation-dialog.d.mts +2 -0
- package/dist/client/components/actions/confirmation-dialog.mjs +82 -0
- package/dist/client/components/actions/confirmation-dialog.mjs.map +1 -0
- package/dist/client/components/actions/header-actions.d.mts +2 -0
- package/dist/client/components/actions/header-actions.mjs +117 -0
- package/dist/client/components/actions/header-actions.mjs.map +1 -0
- package/dist/client/components/actions/index.d.mts +4 -0
- package/dist/client/components/admin-link.d.mts +67 -0
- package/dist/client/components/admin-link.d.mts.map +1 -0
- package/dist/client/components/admin-link.mjs +92 -0
- package/dist/client/components/admin-link.mjs.map +1 -0
- package/dist/client/components/auth/auth-guard.d.mts +51 -0
- package/dist/client/components/auth/auth-guard.d.mts.map +1 -0
- package/dist/client/components/auth/auth-guard.mjs +60 -0
- package/dist/client/components/auth/auth-guard.mjs.map +1 -0
- package/dist/client/components/auth/auth-loading.d.mts +36 -0
- package/dist/client/components/auth/auth-loading.d.mts.map +1 -0
- package/dist/client/components/auth/auth-loading.mjs +27 -0
- package/dist/client/components/auth/auth-loading.mjs.map +1 -0
- package/dist/client/components/auth/index.d.mts +2 -0
- package/dist/client/components/blocks/block-canvas.mjs +90 -0
- package/dist/client/components/blocks/block-canvas.mjs.map +1 -0
- package/dist/client/components/blocks/block-editor-context.mjs +58 -0
- package/dist/client/components/blocks/block-editor-context.mjs.map +1 -0
- package/dist/client/components/blocks/block-editor-layout.mjs +82 -0
- package/dist/client/components/blocks/block-editor-layout.mjs.map +1 -0
- package/dist/client/components/blocks/block-editor-provider.mjs +155 -0
- package/dist/client/components/blocks/block-editor-provider.mjs.map +1 -0
- package/dist/client/components/blocks/block-fields-renderer.mjs +70 -0
- package/dist/client/components/blocks/block-fields-renderer.mjs.map +1 -0
- package/dist/client/components/blocks/block-insert-button.mjs +72 -0
- package/dist/client/components/blocks/block-insert-button.mjs.map +1 -0
- package/dist/client/components/blocks/block-item-menu.mjs +161 -0
- package/dist/client/components/blocks/block-item-menu.mjs.map +1 -0
- package/dist/client/components/blocks/block-item.mjs +187 -0
- package/dist/client/components/blocks/block-item.mjs.map +1 -0
- package/dist/client/components/blocks/block-library-sidebar.mjs +190 -0
- package/dist/client/components/blocks/block-library-sidebar.mjs.map +1 -0
- package/dist/client/components/blocks/block-tree.mjs +45 -0
- package/dist/client/components/blocks/block-tree.mjs.map +1 -0
- package/dist/client/components/blocks/block-type-icon.mjs +50 -0
- package/dist/client/components/blocks/block-type-icon.mjs.map +1 -0
- package/dist/client/components/blocks/utils/tree-utils.mjs +186 -0
- package/dist/client/components/blocks/utils/tree-utils.mjs.map +1 -0
- package/dist/client/components/component-renderer.d.mts +125 -0
- package/dist/client/components/component-renderer.d.mts.map +1 -0
- package/dist/client/components/component-renderer.mjs +145 -0
- package/dist/client/components/component-renderer.mjs.map +1 -0
- package/dist/client/components/error-boundary.mjs +92 -0
- package/dist/client/components/error-boundary.mjs.map +1 -0
- package/dist/client/components/fields/array-field.d.mts +44 -0
- package/dist/client/components/fields/array-field.d.mts.map +1 -0
- package/dist/client/components/fields/array-field.mjs +231 -0
- package/dist/client/components/fields/array-field.mjs.map +1 -0
- package/dist/client/components/fields/asset-preview-field.d.mts +52 -0
- package/dist/client/components/fields/asset-preview-field.d.mts.map +1 -0
- package/dist/client/components/fields/asset-preview-field.mjs +60 -0
- package/dist/client/components/fields/asset-preview-field.mjs.map +1 -0
- package/dist/client/components/fields/blocks-field/blocks-field.d.mts +41 -0
- package/dist/client/components/fields/blocks-field/blocks-field.d.mts.map +1 -0
- package/dist/client/components/fields/blocks-field/blocks-field.mjs +101 -0
- package/dist/client/components/fields/blocks-field/blocks-field.mjs.map +1 -0
- package/dist/client/components/fields/blocks-field/index.d.mts +1 -0
- package/dist/client/components/fields/boolean-field.d.mts +30 -0
- package/dist/client/components/fields/boolean-field.d.mts.map +1 -0
- package/dist/client/components/fields/boolean-field.mjs +47 -0
- package/dist/client/components/fields/boolean-field.mjs.map +1 -0
- package/dist/client/components/fields/custom-field.d.mts +3 -0
- package/dist/client/components/fields/date-field.d.mts +22 -0
- package/dist/client/components/fields/date-field.d.mts.map +1 -0
- package/dist/client/components/fields/date-field.mjs +42 -0
- package/dist/client/components/fields/date-field.mjs.map +1 -0
- package/dist/client/components/fields/datetime-field.d.mts +23 -0
- package/dist/client/components/fields/datetime-field.d.mts.map +1 -0
- package/dist/client/components/fields/datetime-field.mjs +43 -0
- package/dist/client/components/fields/datetime-field.mjs.map +1 -0
- package/dist/client/components/fields/email-field.d.mts +19 -0
- package/dist/client/components/fields/email-field.d.mts.map +1 -0
- package/dist/client/components/fields/email-field.mjs +38 -0
- package/dist/client/components/fields/email-field.mjs.map +1 -0
- package/dist/client/components/fields/embedded-collection.d.mts +3 -0
- package/dist/client/components/fields/field-types.d.mts +571 -0
- package/dist/client/components/fields/field-types.d.mts.map +1 -0
- package/dist/client/components/fields/field-utils.d.mts +1 -0
- package/dist/client/components/fields/field-utils.mjs +65 -0
- package/dist/client/components/fields/field-utils.mjs.map +1 -0
- package/dist/client/components/fields/field-wrapper.d.mts +3 -0
- package/dist/client/components/fields/field-wrapper.mjs +49 -0
- package/dist/client/components/fields/field-wrapper.mjs.map +1 -0
- package/dist/client/components/fields/index.d.mts +33 -0
- package/dist/client/components/fields/json-field.d.mts +84 -0
- package/dist/client/components/fields/json-field.d.mts.map +1 -0
- package/dist/client/components/fields/json-field.mjs +248 -0
- package/dist/client/components/fields/json-field.mjs.map +1 -0
- package/dist/client/components/fields/locale-badge.d.mts +1 -0
- package/dist/client/components/fields/locale-badge.mjs +17 -0
- package/dist/client/components/fields/locale-badge.mjs.map +1 -0
- package/dist/client/components/fields/number-field.d.mts +23 -0
- package/dist/client/components/fields/number-field.d.mts.map +1 -0
- package/dist/client/components/fields/number-field.mjs +40 -0
- package/dist/client/components/fields/number-field.mjs.map +1 -0
- package/dist/client/components/fields/object-array-field.d.mts +2 -0
- package/dist/client/components/fields/object-array-field.mjs +313 -0
- package/dist/client/components/fields/object-array-field.mjs.map +1 -0
- package/dist/client/components/fields/object-field.d.mts +32 -0
- package/dist/client/components/fields/object-field.d.mts.map +1 -0
- package/dist/client/components/fields/object-field.mjs +128 -0
- package/dist/client/components/fields/object-field.mjs.map +1 -0
- package/dist/client/components/fields/relation/displays/cards-display.d.mts +2 -0
- package/dist/client/components/fields/relation/displays/cards-display.mjs +140 -0
- package/dist/client/components/fields/relation/displays/cards-display.mjs.map +1 -0
- package/dist/client/components/fields/relation/displays/chips-display.d.mts +2 -0
- package/dist/client/components/fields/relation/displays/chips-display.mjs +100 -0
- package/dist/client/components/fields/relation/displays/chips-display.mjs.map +1 -0
- package/dist/client/components/fields/relation/displays/grid-display.d.mts +2 -0
- package/dist/client/components/fields/relation/displays/grid-display.mjs +114 -0
- package/dist/client/components/fields/relation/displays/grid-display.mjs.map +1 -0
- package/dist/client/components/fields/relation/displays/index.d.mts +6 -0
- package/dist/client/components/fields/relation/displays/list-display.d.mts +2 -0
- package/dist/client/components/fields/relation/displays/list-display.mjs +128 -0
- package/dist/client/components/fields/relation/displays/list-display.mjs.map +1 -0
- package/dist/client/components/fields/relation/displays/table-display.d.mts +2 -0
- package/dist/client/components/fields/relation/displays/table-display.mjs +134 -0
- package/dist/client/components/fields/relation/displays/table-display.mjs.map +1 -0
- package/dist/client/components/fields/relation/displays/types.d.mts +22 -0
- package/dist/client/components/fields/relation/displays/types.d.mts.map +1 -0
- package/dist/client/components/fields/relation/displays/types.mjs +73 -0
- package/dist/client/components/fields/relation/displays/types.mjs.map +1 -0
- package/dist/client/components/fields/relation/index.d.mts +3 -0
- package/dist/client/components/fields/relation/relation-items-display.d.mts +5 -0
- package/dist/client/components/fields/relation/relation-items-display.mjs +47 -0
- package/dist/client/components/fields/relation/relation-items-display.mjs.map +1 -0
- package/dist/client/components/fields/relation-field.d.mts +134 -0
- package/dist/client/components/fields/relation-field.d.mts.map +1 -0
- package/dist/client/components/fields/relation-field.mjs +106 -0
- package/dist/client/components/fields/relation-field.mjs.map +1 -0
- package/dist/client/components/fields/relation-picker.d.mts +4 -0
- package/dist/client/components/fields/relation-picker.mjs +301 -0
- package/dist/client/components/fields/relation-picker.mjs.map +1 -0
- package/dist/client/components/fields/relation-select.d.mts +3 -0
- package/dist/client/components/fields/relation-select.mjs +219 -0
- package/dist/client/components/fields/relation-select.mjs.map +1 -0
- package/dist/client/components/fields/reverse-relation-field.d.mts +2 -0
- package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs +56 -0
- package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs.map +1 -0
- package/dist/client/components/fields/rich-text-editor/extensions.mjs +118 -0
- package/dist/client/components/fields/rich-text-editor/extensions.mjs.map +1 -0
- package/dist/client/components/fields/rich-text-editor/image-popover.mjs +196 -0
- package/dist/client/components/fields/rich-text-editor/image-popover.mjs.map +1 -0
- package/dist/client/components/fields/rich-text-editor/index.d.mts +4 -0
- package/dist/client/components/fields/rich-text-editor/index.mjs +187 -0
- package/dist/client/components/fields/rich-text-editor/index.mjs.map +1 -0
- package/dist/client/components/fields/rich-text-editor/link-popover.mjs +86 -0
- package/dist/client/components/fields/rich-text-editor/link-popover.mjs.map +1 -0
- package/dist/client/components/fields/rich-text-editor/presets.d.mts +11 -0
- package/dist/client/components/fields/rich-text-editor/presets.d.mts.map +1 -0
- package/dist/client/components/fields/rich-text-editor/presets.mjs +124 -0
- package/dist/client/components/fields/rich-text-editor/presets.mjs.map +1 -0
- package/dist/client/components/fields/rich-text-editor/slash-commands.mjs +145 -0
- package/dist/client/components/fields/rich-text-editor/slash-commands.mjs.map +1 -0
- package/dist/client/components/fields/rich-text-editor/table-controls.mjs +124 -0
- package/dist/client/components/fields/rich-text-editor/table-controls.mjs.map +1 -0
- package/dist/client/components/fields/rich-text-editor/toolbar.mjs +280 -0
- package/dist/client/components/fields/rich-text-editor/toolbar.mjs.map +1 -0
- package/dist/client/components/fields/rich-text-editor/types.d.mts +78 -0
- package/dist/client/components/fields/rich-text-editor/types.d.mts.map +1 -0
- package/dist/client/components/fields/rich-text-editor/types.mjs +31 -0
- package/dist/client/components/fields/rich-text-editor/types.mjs.map +1 -0
- package/dist/client/components/fields/rich-text-editor/utils.mjs +51 -0
- package/dist/client/components/fields/rich-text-editor/utils.mjs.map +1 -0
- package/dist/client/components/fields/rich-text-editor/variants.d.mts +2 -0
- package/dist/client/components/fields/rich-text-field.d.mts +14 -0
- package/dist/client/components/fields/rich-text-field.d.mts.map +1 -0
- package/dist/client/components/fields/rich-text-field.mjs +26 -0
- package/dist/client/components/fields/rich-text-field.mjs.map +1 -0
- package/dist/client/components/fields/select-field.d.mts +25 -0
- package/dist/client/components/fields/select-field.d.mts.map +1 -0
- package/dist/client/components/fields/select-field.mjs +53 -0
- package/dist/client/components/fields/select-field.mjs.map +1 -0
- package/dist/client/components/fields/status-field.d.mts +2 -0
- package/dist/client/components/fields/text-field.d.mts +22 -0
- package/dist/client/components/fields/text-field.d.mts.map +1 -0
- package/dist/client/components/fields/text-field.mjs +39 -0
- package/dist/client/components/fields/text-field.mjs.map +1 -0
- package/dist/client/components/fields/textarea-field.d.mts +22 -0
- package/dist/client/components/fields/textarea-field.d.mts.map +1 -0
- package/dist/client/components/fields/textarea-field.mjs +39 -0
- package/dist/client/components/fields/textarea-field.mjs.map +1 -0
- package/dist/client/components/fields/time-field.d.mts +20 -0
- package/dist/client/components/fields/time-field.d.mts.map +1 -0
- package/dist/client/components/fields/time-field.mjs +39 -0
- package/dist/client/components/fields/time-field.mjs.map +1 -0
- package/dist/client/components/fields/upload-field.d.mts +97 -0
- package/dist/client/components/fields/upload-field.d.mts.map +1 -0
- package/dist/client/components/fields/upload-field.mjs +497 -0
- package/dist/client/components/fields/upload-field.mjs.map +1 -0
- package/dist/client/components/filter-builder/columns-tab.d.mts +1 -0
- package/dist/client/components/filter-builder/columns-tab.mjs +131 -0
- package/dist/client/components/filter-builder/columns-tab.mjs.map +1 -0
- package/dist/client/components/filter-builder/filter-builder-sheet.d.mts +1 -0
- package/dist/client/components/filter-builder/filter-builder-sheet.mjs +157 -0
- package/dist/client/components/filter-builder/filter-builder-sheet.mjs.map +1 -0
- package/dist/client/components/filter-builder/filters-tab.d.mts +1 -0
- package/dist/client/components/filter-builder/filters-tab.mjs +380 -0
- package/dist/client/components/filter-builder/filters-tab.mjs.map +1 -0
- package/dist/client/components/filter-builder/index.d.mts +5 -0
- package/dist/client/components/filter-builder/saved-views-tab.d.mts +1 -0
- package/dist/client/components/filter-builder/saved-views-tab.mjs +125 -0
- package/dist/client/components/filter-builder/saved-views-tab.mjs.map +1 -0
- package/dist/client/components/index.d.mts +80 -0
- package/dist/client/components/locale-switcher.d.mts +2 -0
- package/dist/client/components/locale-switcher.mjs +128 -0
- package/dist/client/components/locale-switcher.mjs.map +1 -0
- package/dist/client/components/media/media-grid.mjs +139 -0
- package/dist/client/components/media/media-grid.mjs.map +1 -0
- package/dist/client/components/media/media-picker-dialog.mjs +255 -0
- package/dist/client/components/media/media-picker-dialog.mjs.map +1 -0
- package/dist/client/components/preview/live-preview-mode.mjs +211 -0
- package/dist/client/components/preview/live-preview-mode.mjs.map +1 -0
- package/dist/client/components/preview/preview-pane.mjs +179 -0
- package/dist/client/components/preview/preview-pane.mjs.map +1 -0
- package/dist/client/components/primitives/asset-preview.mjs +363 -0
- package/dist/client/components/primitives/asset-preview.mjs.map +1 -0
- package/dist/client/components/primitives/checkbox-input.mjs +33 -0
- package/dist/client/components/primitives/checkbox-input.mjs.map +1 -0
- package/dist/client/components/primitives/date-input.mjs +218 -0
- package/dist/client/components/primitives/date-input.mjs.map +1 -0
- package/dist/client/components/primitives/dropzone.mjs +239 -0
- package/dist/client/components/primitives/dropzone.mjs.map +1 -0
- package/dist/client/components/primitives/number-input.mjs +113 -0
- package/dist/client/components/primitives/number-input.mjs.map +1 -0
- package/dist/client/components/primitives/select-multi.mjs +256 -0
- package/dist/client/components/primitives/select-multi.mjs.map +1 -0
- package/dist/client/components/primitives/select-single.mjs +183 -0
- package/dist/client/components/primitives/select-single.mjs.map +1 -0
- package/dist/client/components/primitives/text-input.mjs +40 -0
- package/dist/client/components/primitives/text-input.mjs.map +1 -0
- package/dist/client/components/primitives/textarea-input.mjs +38 -0
- package/dist/client/components/primitives/textarea-input.mjs.map +1 -0
- package/dist/client/components/primitives/time-input.mjs +72 -0
- package/dist/client/components/primitives/time-input.mjs.map +1 -0
- package/dist/client/components/primitives/toggle-input.mjs +31 -0
- package/dist/client/components/primitives/toggle-input.mjs.map +1 -0
- package/dist/client/components/primitives/types.d.mts +14 -0
- package/dist/client/components/primitives/types.d.mts.map +1 -0
- package/dist/client/components/primitives/types.mjs +13 -0
- package/dist/client/components/primitives/types.mjs.map +1 -0
- package/dist/client/components/sheets/index.d.mts +1 -0
- package/dist/client/components/sheets/resource-sheet.d.mts +1 -0
- package/dist/client/components/sheets/resource-sheet.mjs +78 -0
- package/dist/client/components/sheets/resource-sheet.mjs.map +1 -0
- package/dist/client/components/ui/accordion.d.mts +2 -0
- package/dist/client/components/ui/accordion.mjs +50 -0
- package/dist/client/components/ui/accordion.mjs.map +1 -0
- package/dist/client/components/ui/alert.mjs +32 -0
- package/dist/client/components/ui/alert.mjs.map +1 -0
- package/dist/client/components/ui/avatar.d.mts +3 -0
- package/dist/client/components/ui/badge.d.mts +3 -0
- package/dist/client/components/ui/badge.mjs +35 -0
- package/dist/client/components/ui/badge.mjs.map +1 -0
- package/dist/client/components/ui/button.d.mts +3 -0
- package/dist/client/components/ui/button.mjs +49 -0
- package/dist/client/components/ui/button.mjs.map +1 -0
- package/dist/client/components/ui/card.d.mts +2 -0
- package/dist/{card-BKHjBQfw.mjs → client/components/ui/card.mjs} +3 -10
- package/dist/{card-BKHjBQfw.mjs.map → client/components/ui/card.mjs.map} +1 -1
- package/dist/client/components/ui/checkbox.d.mts +2 -0
- package/dist/client/components/ui/checkbox.mjs +27 -0
- package/dist/client/components/ui/checkbox.mjs.map +1 -0
- package/dist/client/components/ui/combobox.d.mts +3 -0
- package/dist/client/components/ui/command.mjs +69 -0
- package/dist/client/components/ui/command.mjs.map +1 -0
- package/dist/client/components/ui/dialog.d.mts +3 -0
- package/dist/client/components/ui/dialog.mjs +83 -0
- package/dist/client/components/ui/dialog.mjs.map +1 -0
- package/dist/client/components/ui/drawer.mjs +75 -0
- package/dist/client/components/ui/drawer.mjs.map +1 -0
- package/dist/client/components/ui/dropdown-menu.d.mts +3 -0
- package/dist/client/components/ui/dropdown-menu.mjs +89 -0
- package/dist/client/components/ui/dropdown-menu.mjs.map +1 -0
- package/dist/client/components/ui/empty-state.mjs +53 -0
- package/dist/client/components/ui/empty-state.mjs.map +1 -0
- package/dist/client/components/ui/field.d.mts +3 -0
- package/dist/client/components/ui/field.mjs +78 -0
- package/dist/client/components/ui/field.mjs.map +1 -0
- package/dist/client/components/ui/input-group.d.mts +4 -0
- package/dist/client/components/ui/input-group.mjs +68 -0
- package/dist/client/components/ui/input-group.mjs.map +1 -0
- package/dist/client/components/ui/input.d.mts +2 -0
- package/dist/client/components/ui/input.mjs +17 -0
- package/dist/client/components/ui/input.mjs.map +1 -0
- package/dist/client/components/ui/kbd.mjs +24 -0
- package/dist/client/components/ui/kbd.mjs.map +1 -0
- package/dist/client/components/ui/label.d.mts +2 -0
- package/dist/client/components/ui/label.mjs +15 -0
- package/dist/client/components/ui/label.mjs.map +1 -0
- package/dist/client/components/ui/popover.d.mts +3 -0
- package/dist/client/components/ui/popover.mjs +49 -0
- package/dist/client/components/ui/popover.mjs.map +1 -0
- package/dist/client/components/ui/responsive-dialog.mjs +102 -0
- package/dist/client/components/ui/responsive-dialog.mjs.map +1 -0
- package/dist/client/components/ui/scroll-area.d.mts +2 -0
- package/dist/client/components/ui/search-input.mjs +74 -0
- package/dist/client/components/ui/search-input.mjs.map +1 -0
- package/dist/client/components/ui/select.d.mts +3 -0
- package/dist/client/components/ui/select.mjs +85 -0
- package/dist/client/components/ui/select.mjs.map +1 -0
- package/dist/client/components/ui/separator.d.mts +2 -0
- package/dist/client/components/ui/separator.mjs +17 -0
- package/dist/client/components/ui/separator.mjs.map +1 -0
- package/dist/client/components/ui/sheet.d.mts +3 -0
- package/dist/client/components/ui/sheet.mjs +78 -0
- package/dist/client/components/ui/sheet.mjs.map +1 -0
- package/dist/client/components/ui/sidebar.d.mts +8 -0
- package/dist/client/components/ui/sidebar.mjs +256 -0
- package/dist/client/components/ui/sidebar.mjs.map +1 -0
- package/dist/client/components/ui/skeleton.d.mts +1 -0
- package/dist/client/components/ui/skeleton.mjs +15 -0
- package/dist/client/components/ui/skeleton.mjs.map +1 -0
- package/dist/client/components/ui/sonner.d.mts +14 -0
- package/dist/client/components/ui/sonner.d.mts.map +1 -0
- package/dist/client/components/ui/sonner.mjs +55 -0
- package/dist/client/components/ui/sonner.mjs.map +1 -0
- package/dist/client/components/ui/spinner.d.mts +1 -0
- package/dist/client/components/ui/spinner.mjs +18 -0
- package/dist/client/components/ui/spinner.mjs.map +1 -0
- package/dist/client/components/ui/switch.d.mts +2 -0
- package/dist/client/components/ui/switch.mjs +23 -0
- package/dist/client/components/ui/switch.mjs.map +1 -0
- package/dist/client/components/ui/table.d.mts +2 -0
- package/dist/client/components/ui/table.mjs +66 -0
- package/dist/client/components/ui/table.mjs.map +1 -0
- package/dist/client/components/ui/tabs.d.mts +3 -0
- package/dist/client/components/ui/tabs.mjs +49 -0
- package/dist/client/components/ui/tabs.mjs.map +1 -0
- package/dist/client/components/ui/textarea.d.mts +2 -0
- package/dist/client/components/ui/textarea.mjs +15 -0
- package/dist/client/components/ui/textarea.mjs.map +1 -0
- package/dist/client/components/ui/toolbar.mjs +54 -0
- package/dist/client/components/ui/toolbar.mjs.map +1 -0
- package/dist/client/components/ui/tooltip.d.mts +2 -0
- package/dist/client/components/ui/tooltip.mjs +45 -0
- package/dist/client/components/ui/tooltip.mjs.map +1 -0
- package/dist/client/components/widgets/chart-widget.d.mts +57 -0
- package/dist/client/components/widgets/chart-widget.d.mts.map +1 -0
- package/dist/client/components/widgets/chart-widget.mjs +282 -0
- package/dist/client/components/widgets/chart-widget.mjs.map +1 -0
- package/dist/client/components/widgets/progress-widget.d.mts +41 -0
- package/dist/client/components/widgets/progress-widget.d.mts.map +1 -0
- package/dist/client/components/widgets/progress-widget.mjs +110 -0
- package/dist/client/components/widgets/progress-widget.mjs.map +1 -0
- package/dist/client/components/widgets/quick-actions-widget.d.mts +29 -0
- package/dist/client/components/widgets/quick-actions-widget.d.mts.map +1 -0
- package/dist/client/components/widgets/quick-actions-widget.mjs +121 -0
- package/dist/client/components/widgets/quick-actions-widget.mjs.map +1 -0
- package/dist/client/components/widgets/recent-items-widget.d.mts +51 -0
- package/dist/client/components/widgets/recent-items-widget.d.mts.map +1 -0
- package/dist/client/components/widgets/recent-items-widget.mjs +101 -0
- package/dist/client/components/widgets/recent-items-widget.mjs.map +1 -0
- package/dist/client/components/widgets/stats-widget.d.mts +55 -0
- package/dist/client/components/widgets/stats-widget.d.mts.map +1 -0
- package/dist/client/components/widgets/stats-widget.mjs +150 -0
- package/dist/client/components/widgets/stats-widget.mjs.map +1 -0
- package/dist/client/components/widgets/table-widget.d.mts +31 -0
- package/dist/client/components/widgets/table-widget.d.mts.map +1 -0
- package/dist/client/components/widgets/table-widget.mjs +139 -0
- package/dist/client/components/widgets/table-widget.mjs.map +1 -0
- package/dist/client/components/widgets/timeline-widget.d.mts +51 -0
- package/dist/client/components/widgets/timeline-widget.d.mts.map +1 -0
- package/dist/client/components/widgets/timeline-widget.mjs +168 -0
- package/dist/client/components/widgets/timeline-widget.mjs.map +1 -0
- package/dist/client/components/widgets/value-widget.d.mts +39 -0
- package/dist/client/components/widgets/value-widget.d.mts.map +1 -0
- package/dist/client/components/widgets/value-widget.mjs +111 -0
- package/dist/client/components/widgets/value-widget.mjs.map +1 -0
- package/dist/client/components/widgets/widget-skeletons.mjs +145 -0
- package/dist/client/components/widgets/widget-skeletons.mjs.map +1 -0
- package/dist/client/context/focus-context.d.mts +88 -0
- package/dist/client/context/focus-context.d.mts.map +1 -0
- package/dist/client/context/focus-context.mjs +178 -0
- package/dist/client/context/focus-context.mjs.map +1 -0
- package/dist/client/contexts/breadcrumb-context.mjs +32 -0
- package/dist/client/contexts/breadcrumb-context.mjs.map +1 -0
- package/dist/client/hooks/typed-hooks.d.mts +84 -0
- package/dist/client/hooks/typed-hooks.d.mts.map +1 -0
- package/dist/client/hooks/typed-hooks.mjs +272 -0
- package/dist/client/hooks/typed-hooks.mjs.map +1 -0
- package/dist/client/hooks/use-action.mjs +201 -0
- package/dist/client/hooks/use-action.mjs.map +1 -0
- package/dist/client/hooks/use-admin-config.mjs +40 -0
- package/dist/client/hooks/use-admin-config.mjs.map +1 -0
- package/dist/client/hooks/use-admin-preferences.mjs +68 -0
- package/dist/client/hooks/use-admin-preferences.mjs.map +1 -0
- package/dist/client/hooks/use-admin-routes.mjs +97 -0
- package/dist/client/hooks/use-admin-routes.mjs.map +1 -0
- package/dist/client/hooks/use-auth.d.mts +98 -0
- package/dist/client/hooks/use-auth.d.mts.map +1 -0
- package/dist/{use-auth-BoLmWtmU.mjs → client/hooks/use-auth.mjs} +3 -3
- package/dist/client/hooks/use-auth.mjs.map +1 -0
- package/dist/client/hooks/use-collection-fields.mjs +32 -0
- package/dist/client/hooks/use-collection-fields.mjs.map +1 -0
- package/dist/client/hooks/use-collection-meta.mjs +121 -0
- package/dist/client/hooks/use-collection-meta.mjs.map +1 -0
- package/dist/client/hooks/use-collection-schema.mjs +67 -0
- package/dist/client/hooks/use-collection-schema.mjs.map +1 -0
- package/dist/client/hooks/use-collection-validation.mjs +74 -0
- package/dist/client/hooks/use-collection-validation.mjs.map +1 -0
- package/dist/client/hooks/use-collection.d.mts +86 -0
- package/dist/client/hooks/use-collection.d.mts.map +1 -0
- package/dist/client/hooks/use-collection.mjs +214 -0
- package/dist/client/hooks/use-collection.mjs.map +1 -0
- package/dist/client/hooks/use-current-user.d.mts +57 -0
- package/dist/client/hooks/use-current-user.d.mts.map +1 -0
- package/dist/client/hooks/use-current-user.mjs +79 -0
- package/dist/client/hooks/use-current-user.mjs.map +1 -0
- package/dist/client/hooks/use-field-hooks.mjs +191 -0
- package/dist/client/hooks/use-field-hooks.mjs.map +1 -0
- package/dist/client/hooks/use-field-options.d.mts +90 -0
- package/dist/client/hooks/use-field-options.d.mts.map +1 -0
- package/dist/client/hooks/use-field-options.mjs +184 -0
- package/dist/client/hooks/use-field-options.mjs.map +1 -0
- package/dist/client/hooks/use-global-fields.mjs +27 -0
- package/dist/client/hooks/use-global-fields.mjs.map +1 -0
- package/dist/client/hooks/use-global-meta.mjs +59 -0
- package/dist/client/hooks/use-global-meta.mjs.map +1 -0
- package/dist/client/hooks/use-global-schema.mjs +33 -0
- package/dist/client/hooks/use-global-schema.mjs.map +1 -0
- package/dist/client/hooks/use-global.d.mts +40 -0
- package/dist/client/hooks/use-global.d.mts.map +1 -0
- package/dist/client/hooks/use-global.mjs +74 -0
- package/dist/client/hooks/use-global.mjs.map +1 -0
- package/dist/client/hooks/use-locks.mjs +245 -0
- package/dist/client/hooks/use-locks.mjs.map +1 -0
- package/dist/client/hooks/use-media-query.d.mts +23 -0
- package/dist/client/hooks/use-media-query.d.mts.map +1 -0
- package/dist/client/hooks/use-media-query.mjs +62 -0
- package/dist/client/hooks/use-media-query.mjs.map +1 -0
- package/dist/client/hooks/use-prefill-params.mjs +47 -0
- package/dist/client/hooks/use-prefill-params.mjs.map +1 -0
- package/dist/client/hooks/use-questpie-query-options.mjs +28 -0
- package/dist/client/hooks/use-questpie-query-options.mjs.map +1 -0
- package/dist/client/hooks/use-reactive-fields.d.mts +75 -0
- package/dist/client/hooks/use-reactive-fields.d.mts.map +1 -0
- package/dist/client/hooks/use-reactive-fields.mjs +164 -0
- package/dist/client/hooks/use-reactive-fields.mjs.map +1 -0
- package/dist/client/hooks/use-realtime-highlight.mjs +96 -0
- package/dist/client/hooks/use-realtime-highlight.mjs.map +1 -0
- package/dist/client/hooks/use-saved-views.mjs +65 -0
- package/dist/client/hooks/use-saved-views.mjs.map +1 -0
- package/dist/client/hooks/use-search.mjs +147 -0
- package/dist/client/hooks/use-search.mjs.map +1 -0
- package/dist/client/hooks/use-server-validation.mjs +199 -0
- package/dist/client/hooks/use-server-validation.mjs.map +1 -0
- package/dist/client/hooks/use-server-widget-data.d.mts +26 -0
- package/dist/client/hooks/use-server-widget-data.d.mts.map +1 -0
- package/dist/client/hooks/use-server-widget-data.mjs +40 -0
- package/dist/client/hooks/use-server-widget-data.mjs.map +1 -0
- package/dist/client/hooks/use-setup-status.d.mts +39 -0
- package/dist/client/hooks/use-setup-status.d.mts.map +1 -0
- package/dist/client/hooks/use-setup-status.mjs +50 -0
- package/dist/client/hooks/use-setup-status.mjs.map +1 -0
- package/dist/client/hooks/use-upload-collection.mjs +32 -0
- package/dist/client/hooks/use-upload-collection.mjs.map +1 -0
- package/dist/client/hooks/use-upload.d.mts +23 -0
- package/dist/client/hooks/use-upload.d.mts.map +1 -0
- package/dist/client/hooks/use-upload.mjs +145 -0
- package/dist/client/hooks/use-upload.mjs.map +1 -0
- package/dist/client/hooks/use-validation-error-map.mjs +53 -0
- package/dist/client/hooks/use-validation-error-map.mjs.map +1 -0
- package/dist/client/hooks/use-view-state.mjs +261 -0
- package/dist/client/hooks/use-view-state.mjs.map +1 -0
- package/dist/client/i18n/hooks.mjs +160 -0
- package/dist/client/i18n/hooks.mjs.map +1 -0
- package/dist/client/i18n/intl-cache.mjs +65 -0
- package/dist/client/i18n/intl-cache.mjs.map +1 -0
- package/dist/client/i18n/messages.mjs +7 -0
- package/dist/client/i18n/messages.mjs.map +1 -0
- package/dist/client/i18n/simple.d.mts +22 -0
- package/dist/client/i18n/simple.d.mts.map +1 -0
- package/dist/client/i18n/simple.mjs +157 -0
- package/dist/client/i18n/simple.mjs.map +1 -0
- package/dist/client/i18n/types.d.mts +110 -0
- package/dist/client/i18n/types.d.mts.map +1 -0
- package/dist/client/lib/utils.d.mts +1 -0
- package/dist/client/lib/utils.mjs +28 -0
- package/dist/client/lib/utils.mjs.map +1 -0
- package/dist/client/preview/block-scope-context.d.mts +74 -0
- package/dist/client/preview/block-scope-context.d.mts.map +1 -0
- package/dist/client/preview/block-scope-context.mjs +93 -0
- package/dist/client/preview/block-scope-context.mjs.map +1 -0
- package/dist/client/preview/index.d.mts +5 -0
- package/dist/client/preview/preview-banner.d.mts +46 -0
- package/dist/client/preview/preview-banner.d.mts.map +1 -0
- package/dist/client/preview/preview-banner.mjs +95 -0
- package/dist/client/preview/preview-banner.mjs.map +1 -0
- package/dist/client/preview/preview-field.d.mts +108 -0
- package/dist/client/preview/preview-field.d.mts.map +1 -0
- package/dist/client/preview/preview-field.mjs +125 -0
- package/dist/client/preview/preview-field.mjs.map +1 -0
- package/dist/client/preview/types.d.mts +115 -0
- package/dist/client/preview/types.d.mts.map +1 -0
- package/dist/client/preview/types.mjs +21 -0
- package/dist/client/preview/types.mjs.map +1 -0
- package/dist/client/preview/use-collection-preview.d.mts +71 -0
- package/dist/client/preview/use-collection-preview.d.mts.map +1 -0
- package/dist/client/preview/use-collection-preview.mjs +114 -0
- package/dist/client/preview/use-collection-preview.mjs.map +1 -0
- package/dist/client/runtime/content-locales-provider.d.mts +1 -0
- package/dist/client/runtime/content-locales-provider.mjs +85 -0
- package/dist/client/runtime/content-locales-provider.mjs.map +1 -0
- package/dist/client/runtime/index.d.mts +7 -0
- package/dist/client/runtime/index.mjs +8 -0
- package/dist/client/runtime/locale-scope.d.mts +2 -0
- package/dist/{runtime-6VZM878K.mjs → client/runtime/locale-scope.mjs} +3 -4
- package/dist/client/runtime/locale-scope.mjs.map +1 -0
- package/dist/client/runtime/provider.d.mts +10107 -0
- package/dist/client/runtime/provider.d.mts.map +1 -0
- package/dist/client/runtime/provider.mjs +229 -0
- package/dist/client/runtime/provider.mjs.map +1 -0
- package/dist/client/runtime/routes.d.mts +49 -0
- package/dist/client/runtime/routes.d.mts.map +1 -0
- package/dist/client/runtime/routes.mjs +107 -0
- package/dist/client/runtime/routes.mjs.map +1 -0
- package/dist/client/runtime/translations-provider.d.mts +2 -0
- package/dist/client/runtime/translations-provider.mjs +181 -0
- package/dist/client/runtime/translations-provider.mjs.map +1 -0
- package/dist/client/scope/index.d.mts +3 -0
- package/dist/client/scope/picker.d.mts +54 -0
- package/dist/client/scope/picker.d.mts.map +1 -0
- package/dist/client/scope/picker.mjs +161 -0
- package/dist/client/scope/picker.mjs.map +1 -0
- package/dist/client/scope/provider.d.mts +104 -0
- package/dist/client/scope/provider.d.mts.map +1 -0
- package/dist/client/scope/provider.mjs +159 -0
- package/dist/client/scope/provider.mjs.map +1 -0
- package/dist/client/scope/types.d.mts +112 -0
- package/dist/client/scope/types.d.mts.map +1 -0
- package/dist/client/styles/index.css +80 -0
- package/dist/client/utils/auto-expand-fields.mjs +65 -0
- package/dist/client/utils/auto-expand-fields.mjs.map +1 -0
- package/dist/client/utils/build-field-definitions-from-schema.mjs +256 -0
- package/dist/client/utils/build-field-definitions-from-schema.mjs.map +1 -0
- package/dist/client/utils/detect-relations.mjs +46 -0
- package/dist/client/utils/detect-relations.mjs.map +1 -0
- package/dist/client/utils/locale-to-flag.d.mts +118 -0
- package/dist/client/utils/locale-to-flag.d.mts.map +1 -0
- package/dist/client/utils/locale-to-flag.mjs +130 -0
- package/dist/client/utils/locale-to-flag.mjs.map +1 -0
- package/dist/client/utils/routes.mjs +196 -0
- package/dist/client/utils/routes.mjs.map +1 -0
- package/dist/client/views/auth/accept-invite-form.d.mts +73 -0
- package/dist/client/views/auth/accept-invite-form.d.mts.map +1 -0
- package/dist/client/views/auth/accept-invite-form.mjs +180 -0
- package/dist/client/views/auth/accept-invite-form.mjs.map +1 -0
- package/dist/client/views/auth/auth-layout.d.mts +44 -0
- package/dist/client/views/auth/auth-layout.d.mts.map +1 -0
- package/dist/client/views/auth/auth-layout.mjs +53 -0
- package/dist/client/views/auth/auth-layout.mjs.map +1 -0
- package/dist/client/views/auth/forgot-password-form.d.mts +59 -0
- package/dist/client/views/auth/forgot-password-form.d.mts.map +1 -0
- package/dist/{forgot-password-page-Bcp-An4Y.mjs → client/views/auth/forgot-password-form.mjs} +22 -89
- package/dist/client/views/auth/forgot-password-form.mjs.map +1 -0
- package/dist/client/views/auth/index.d.mts +7 -0
- package/dist/client/views/auth/invite-form.d.mts +1 -0
- package/dist/client/views/auth/invite-form.mjs +155 -0
- package/dist/client/views/auth/invite-form.mjs.map +1 -0
- package/dist/client/views/auth/login-form.d.mts +76 -0
- package/dist/client/views/auth/login-form.d.mts.map +1 -0
- package/dist/client/views/auth/login-form.mjs +167 -0
- package/dist/client/views/auth/login-form.mjs.map +1 -0
- package/dist/client/views/auth/reset-password-form.d.mts +66 -0
- package/dist/client/views/auth/reset-password-form.d.mts.map +1 -0
- package/dist/client/views/auth/reset-password-form.mjs +188 -0
- package/dist/client/views/auth/reset-password-form.mjs.map +1 -0
- package/dist/client/views/auth/setup-form.d.mts +61 -0
- package/dist/client/views/auth/setup-form.d.mts.map +1 -0
- package/dist/{setup-page-YAP_fzqh.mjs → client/views/auth/setup-form.mjs} +46 -124
- package/dist/client/views/auth/setup-form.mjs.map +1 -0
- package/dist/client/views/collection/auto-form-fields.d.mts +4 -0
- package/dist/client/views/collection/auto-form-fields.mjs +453 -0
- package/dist/client/views/collection/auto-form-fields.mjs.map +1 -0
- package/dist/client/views/collection/bulk-action-toolbar.mjs +291 -0
- package/dist/client/views/collection/bulk-action-toolbar.mjs.map +1 -0
- package/dist/client/views/collection/cells/complex-cells.d.mts +46 -0
- package/dist/client/views/collection/cells/complex-cells.d.mts.map +1 -0
- package/dist/client/views/collection/cells/complex-cells.mjs +327 -0
- package/dist/client/views/collection/cells/complex-cells.mjs.map +1 -0
- package/dist/client/views/collection/cells/index.d.mts +7 -0
- package/dist/client/views/collection/cells/primitive-cells.d.mts +76 -0
- package/dist/client/views/collection/cells/primitive-cells.d.mts.map +1 -0
- package/dist/client/views/collection/cells/primitive-cells.mjs +165 -0
- package/dist/client/views/collection/cells/primitive-cells.mjs.map +1 -0
- package/dist/client/views/collection/cells/relation-cells.d.mts +21 -0
- package/dist/client/views/collection/cells/relation-cells.d.mts.map +1 -0
- package/dist/client/views/collection/cells/relation-cells.mjs +105 -0
- package/dist/client/views/collection/cells/relation-cells.mjs.map +1 -0
- package/dist/client/views/collection/cells/shared/asset-thumbnail.d.mts +1 -0
- package/dist/client/views/collection/cells/shared/asset-thumbnail.mjs +189 -0
- package/dist/client/views/collection/cells/shared/asset-thumbnail.mjs.map +1 -0
- package/dist/client/views/collection/cells/shared/cell-helpers.d.mts +2 -0
- package/dist/client/views/collection/cells/shared/cell-helpers.mjs +78 -0
- package/dist/client/views/collection/cells/shared/cell-helpers.mjs.map +1 -0
- package/dist/client/views/collection/cells/shared/relation-chip.d.mts +1 -0
- package/dist/client/views/collection/cells/shared/relation-chip.mjs +37 -0
- package/dist/client/views/collection/cells/shared/relation-chip.mjs.map +1 -0
- package/dist/client/views/collection/cells/upload-cells.d.mts +25 -0
- package/dist/client/views/collection/cells/upload-cells.d.mts.map +1 -0
- package/dist/client/views/collection/cells/upload-cells.mjs +20 -0
- package/dist/client/views/collection/cells/upload-cells.mjs.map +1 -0
- package/dist/client/views/collection/columns/build-columns.d.mts +2 -0
- package/dist/client/views/collection/columns/build-columns.mjs +156 -0
- package/dist/client/views/collection/columns/build-columns.mjs.map +1 -0
- package/dist/client/views/collection/columns/column-defaults.d.mts +2 -0
- package/dist/client/views/collection/columns/column-defaults.mjs +108 -0
- package/dist/client/views/collection/columns/column-defaults.mjs.map +1 -0
- package/dist/client/views/collection/columns/index.d.mts +3 -0
- package/dist/client/views/collection/columns/types.d.mts +2 -0
- package/dist/client/views/collection/field-context.mjs +127 -0
- package/dist/client/views/collection/field-context.mjs.map +1 -0
- package/dist/client/views/collection/field-renderer.mjs +171 -0
- package/dist/client/views/collection/field-renderer.mjs.map +1 -0
- package/dist/client/views/collection/form-view.d.mts +112 -0
- package/dist/client/views/collection/form-view.d.mts.map +1 -0
- package/dist/client/views/collection/form-view.mjs +903 -0
- package/dist/client/views/collection/form-view.mjs.map +1 -0
- package/dist/client/views/collection/index.d.mts +9 -0
- package/dist/client/views/collection/table-view.d.mts +102 -0
- package/dist/client/views/collection/table-view.d.mts.map +1 -0
- package/dist/client/views/collection/table-view.mjs +695 -0
- package/dist/client/views/collection/table-view.mjs.map +1 -0
- package/dist/client/views/collection/view-skeletons.mjs +121 -0
- package/dist/client/views/collection/view-skeletons.mjs.map +1 -0
- package/dist/client/views/common/global-search.d.mts +1 -0
- package/dist/client/views/common/global-search.mjs +376 -0
- package/dist/client/views/common/global-search.mjs.map +1 -0
- package/dist/client/views/common/index.d.mts +1 -0
- package/dist/client/views/dashboard/dashboard-grid.mjs +385 -0
- package/dist/client/views/dashboard/dashboard-grid.mjs.map +1 -0
- package/dist/client/views/dashboard/dashboard-widget.mjs +178 -0
- package/dist/client/views/dashboard/dashboard-widget.mjs.map +1 -0
- package/dist/client/views/dashboard/widget-card.mjs +159 -0
- package/dist/client/views/dashboard/widget-card.mjs.map +1 -0
- package/dist/client/views/globals/global-form-view.d.mts +74 -0
- package/dist/client/views/globals/global-form-view.d.mts.map +1 -0
- package/dist/client/views/globals/global-form-view.mjs +181 -0
- package/dist/client/views/globals/global-form-view.mjs.map +1 -0
- package/dist/client/views/index.d.mts +28 -0
- package/dist/client/views/layout/admin-layout-provider.d.mts +140 -0
- package/dist/client/views/layout/admin-layout-provider.d.mts.map +1 -0
- package/dist/client/views/layout/admin-layout-provider.mjs +90 -0
- package/dist/client/views/layout/admin-layout-provider.mjs.map +1 -0
- package/dist/client/views/layout/admin-layout.d.mts +151 -0
- package/dist/client/views/layout/admin-layout.d.mts.map +1 -0
- package/dist/client/views/layout/admin-layout.mjs +144 -0
- package/dist/client/views/layout/admin-layout.mjs.map +1 -0
- package/dist/client/views/layout/admin-root.d.mts +7 -0
- package/dist/client/views/layout/admin-router.d.mts +125 -0
- package/dist/client/views/layout/admin-router.d.mts.map +1 -0
- package/dist/client/views/layout/admin-router.mjs +594 -0
- package/dist/client/views/layout/admin-router.mjs.map +1 -0
- package/dist/client/views/layout/admin-sidebar.d.mts +105 -0
- package/dist/client/views/layout/admin-sidebar.d.mts.map +1 -0
- package/dist/client/views/layout/admin-sidebar.mjs +550 -0
- package/dist/client/views/layout/admin-sidebar.mjs.map +1 -0
- package/dist/client/views/layout/admin-topbar.mjs +128 -0
- package/dist/client/views/layout/admin-topbar.mjs.map +1 -0
- package/dist/client/views/layout/index.d.mts +5 -0
- package/dist/client/views/pages/accept-invite-page.d.mts +67 -0
- package/dist/client/views/pages/accept-invite-page.d.mts.map +1 -0
- package/dist/client/views/pages/accept-invite-page.mjs +143 -0
- package/dist/client/views/pages/accept-invite-page.mjs.map +1 -0
- package/dist/client/views/pages/dashboard-page.d.mts +52 -0
- package/dist/client/views/pages/dashboard-page.d.mts.map +1 -0
- package/dist/client/views/pages/dashboard-page.mjs +45 -0
- package/dist/client/views/pages/dashboard-page.mjs.map +1 -0
- package/dist/client/views/pages/forgot-password-page.d.mts +59 -0
- package/dist/client/views/pages/forgot-password-page.d.mts.map +1 -0
- package/dist/client/views/pages/forgot-password-page.mjs +80 -0
- package/dist/client/views/pages/forgot-password-page.mjs.map +1 -0
- package/dist/client/views/pages/index.d.mts +7 -0
- package/dist/client/views/pages/invite-page.d.mts +71 -0
- package/dist/client/views/pages/invite-page.d.mts.map +1 -0
- package/dist/client/views/pages/invite-page.mjs +86 -0
- package/dist/client/views/pages/invite-page.mjs.map +1 -0
- package/dist/client/views/pages/login-page.d.mts +76 -0
- package/dist/client/views/pages/login-page.d.mts.map +1 -0
- package/dist/client/views/pages/login-page.mjs +98 -0
- package/dist/client/views/pages/login-page.mjs.map +1 -0
- package/dist/client/views/pages/reset-password-page.d.mts +66 -0
- package/dist/client/views/pages/reset-password-page.d.mts.map +1 -0
- package/dist/client/views/pages/reset-password-page.mjs +105 -0
- package/dist/client/views/pages/reset-password-page.mjs.map +1 -0
- package/dist/client/views/pages/setup-page.d.mts +64 -0
- package/dist/client/views/pages/setup-page.d.mts.map +1 -0
- package/dist/client/views/pages/setup-page.mjs +91 -0
- package/dist/client/views/pages/setup-page.mjs.map +1 -0
- package/dist/client.d.mts +92 -3
- package/dist/client.d.mts.map +1 -0
- package/dist/client.mjs +54 -12
- package/dist/components/rich-text/index.d.mts +1 -0
- package/dist/components/rich-text/rich-text-renderer.d.mts +104 -0
- package/dist/components/rich-text/rich-text-renderer.d.mts.map +1 -0
- package/dist/components/rich-text/rich-text-renderer.mjs +210 -0
- package/dist/components/rich-text/rich-text-renderer.mjs.map +1 -0
- package/dist/index.d.mts +62 -3
- package/dist/index.mjs +54 -12
- package/dist/server/adapters/nextjs.d.mts +121 -0
- package/dist/server/adapters/nextjs.d.mts.map +1 -0
- package/dist/server/adapters/nextjs.mjs +111 -0
- package/dist/server/adapters/nextjs.mjs.map +1 -0
- package/dist/server/adapters/tanstack.d.mts +133 -0
- package/dist/server/adapters/tanstack.d.mts.map +1 -0
- package/dist/server/adapters/tanstack.mjs +90 -0
- package/dist/server/adapters/tanstack.mjs.map +1 -0
- package/dist/server/augmentation.d.mts +1523 -0
- package/dist/server/augmentation.d.mts.map +1 -0
- package/dist/server/auth-helpers.d.mts +143 -0
- package/dist/server/auth-helpers.d.mts.map +1 -0
- package/dist/server/auth-helpers.mjs +108 -0
- package/dist/server/auth-helpers.mjs.map +1 -0
- package/dist/server/block/block-builder.d.mts +319 -0
- package/dist/server/block/block-builder.d.mts.map +1 -0
- package/dist/server/block/block-builder.mjs +217 -0
- package/dist/server/block/block-builder.mjs.map +1 -0
- package/dist/server/block/index.d.mts +3 -0
- package/dist/server/block/introspection.d.mts +84 -0
- package/dist/server/block/introspection.d.mts.map +1 -0
- package/dist/server/block/introspection.mjs +89 -0
- package/dist/server/block/introspection.mjs.map +1 -0
- package/dist/server/block/prefetch.d.mts +78 -0
- package/dist/server/block/prefetch.d.mts.map +1 -0
- package/dist/server/block/prefetch.mjs +240 -0
- package/dist/server/block/prefetch.mjs.map +1 -0
- package/dist/server/fields/blocks.d.mts +139 -0
- package/dist/server/fields/blocks.d.mts.map +1 -0
- package/dist/server/fields/blocks.mjs +192 -0
- package/dist/server/fields/blocks.mjs.map +1 -0
- package/dist/server/fields/index.d.mts +48 -0
- package/dist/server/fields/index.d.mts.map +1 -0
- package/dist/server/fields/index.mjs +16 -0
- package/dist/server/fields/index.mjs.map +1 -0
- package/dist/server/fields/rich-text.d.mts +135 -0
- package/dist/server/fields/rich-text.d.mts.map +1 -0
- package/dist/server/fields/rich-text.mjs +188 -0
- package/dist/server/fields/rich-text.mjs.map +1 -0
- package/dist/server/i18n/index.d.mts +16 -0
- package/dist/server/i18n/index.d.mts.map +1 -0
- package/dist/server/i18n/index.mjs +44 -0
- package/dist/server/i18n/index.mjs.map +1 -0
- package/dist/server/i18n/messages/cs.mjs +461 -0
- package/dist/server/i18n/messages/cs.mjs.map +1 -0
- package/dist/server/i18n/messages/de.mjs +461 -0
- package/dist/server/i18n/messages/de.mjs.map +1 -0
- package/dist/server/i18n/messages/en.mjs +493 -0
- package/dist/server/i18n/messages/en.mjs.map +1 -0
- package/dist/server/i18n/messages/es.mjs +461 -0
- package/dist/server/i18n/messages/es.mjs.map +1 -0
- package/dist/server/i18n/messages/fr.mjs +461 -0
- package/dist/server/i18n/messages/fr.mjs.map +1 -0
- package/dist/server/i18n/messages/index.mjs +24 -0
- package/dist/server/i18n/messages/index.mjs.map +1 -0
- package/dist/server/i18n/messages/pl.mjs +461 -0
- package/dist/server/i18n/messages/pl.mjs.map +1 -0
- package/dist/server/i18n/messages/pt.mjs +464 -0
- package/dist/server/i18n/messages/pt.mjs.map +1 -0
- package/dist/server/i18n/messages/sk.mjs +490 -0
- package/dist/server/i18n/messages/sk.mjs.map +1 -0
- package/dist/server/index.d.mts +20 -0
- package/dist/server/modules/admin/functions/admin-config.mjs +348 -0
- package/dist/server/modules/admin/functions/admin-config.mjs.map +1 -0
- package/dist/server/modules/admin/functions/execute-action.d.mts +107 -0
- package/dist/server/modules/admin/functions/execute-action.d.mts.map +1 -0
- package/dist/server/modules/admin/functions/execute-action.mjs +331 -0
- package/dist/server/modules/admin/functions/execute-action.mjs.map +1 -0
- package/dist/server/modules/admin/functions/locales.mjs +80 -0
- package/dist/server/modules/admin/functions/locales.mjs.map +1 -0
- package/dist/server/modules/admin/functions/preview.d.mts +70 -0
- package/dist/server/modules/admin/functions/preview.d.mts.map +1 -0
- package/dist/server/modules/admin/functions/preview.mjs +243 -0
- package/dist/server/modules/admin/functions/preview.mjs.map +1 -0
- package/dist/server/modules/admin/functions/reactive.d.mts +99 -0
- package/dist/server/modules/admin/functions/reactive.d.mts.map +1 -0
- package/dist/server/modules/admin/functions/reactive.mjs +378 -0
- package/dist/server/modules/admin/functions/reactive.mjs.map +1 -0
- package/dist/server/modules/admin/functions/setup.d.mts +84 -0
- package/dist/server/modules/admin/functions/setup.d.mts.map +1 -0
- package/dist/server/modules/admin/functions/setup.mjs +131 -0
- package/dist/server/modules/admin/functions/setup.mjs.map +1 -0
- package/dist/server/modules/admin/functions/translations.mjs +125 -0
- package/dist/server/modules/admin/functions/translations.mjs.map +1 -0
- package/dist/server/modules/admin/functions/widget-data.d.mts +33 -0
- package/dist/server/modules/admin/functions/widget-data.d.mts.map +1 -0
- package/dist/server/modules/admin/functions/widget-data.mjs +70 -0
- package/dist/server/modules/admin/functions/widget-data.mjs.map +1 -0
- package/dist/server/modules/admin/index.d.mts +16879 -0
- package/dist/server/modules/admin/index.d.mts.map +1 -0
- package/dist/server/modules/admin/index.mjs +249 -0
- package/dist/server/modules/admin/index.mjs.map +1 -0
- package/dist/server/modules/admin-preferences/collections/admin-preferences.collection.d.mts +3 -0
- package/dist/server/modules/admin-preferences/collections/admin-preferences.collection.mjs +48 -0
- package/dist/server/modules/admin-preferences/collections/admin-preferences.collection.mjs.map +1 -0
- package/dist/server/modules/admin-preferences/collections/locks.collection.d.mts +3 -0
- package/dist/server/modules/admin-preferences/collections/locks.collection.mjs +79 -0
- package/dist/server/modules/admin-preferences/collections/locks.collection.mjs.map +1 -0
- package/dist/server/modules/admin-preferences/collections/saved-views.collection.d.mts +1490 -0
- package/dist/server/modules/admin-preferences/collections/saved-views.collection.d.mts.map +1 -0
- package/dist/server/modules/admin-preferences/collections/saved-views.collection.mjs +57 -0
- package/dist/server/modules/admin-preferences/collections/saved-views.collection.mjs.map +1 -0
- package/dist/server/patch.d.mts +100 -0
- package/dist/server/patch.d.mts.map +1 -0
- package/dist/server/patch.mjs +1062 -0
- package/dist/server/patch.mjs.map +1 -0
- package/dist/server.d.mts +21 -250
- package/dist/server.mjs +19 -832
- package/dist/shared/preview-utils.d.mts +54 -0
- package/dist/shared/preview-utils.d.mts.map +1 -0
- package/dist/{preview-utils-BKQ9-TMa.mjs → shared/preview-utils.mjs} +2 -2
- package/dist/shared/preview-utils.mjs.map +1 -0
- package/dist/{saved-views.types-BMsz5mCy.d.mts → shared/types/saved-views.types.d.mts} +7 -2
- package/dist/shared/types/saved-views.types.d.mts.map +1 -0
- package/dist/shared.d.mts +3 -57
- package/dist/shared.mjs +1 -1
- package/package.json +12 -17
- package/dist/auth-layout-M8K8_q5R.mjs +0 -181
- package/dist/auth-layout-M8K8_q5R.mjs.map +0 -1
- package/dist/bulk-upload-dialog-D7w7W1Hl.mjs +0 -273
- package/dist/bulk-upload-dialog-D7w7W1Hl.mjs.map +0 -1
- package/dist/client-D1DqawtP.d.mts +0 -13403
- package/dist/client-D1DqawtP.d.mts.map +0 -1
- package/dist/client-njX1rZmi.mjs +0 -22612
- package/dist/client-njX1rZmi.mjs.map +0 -1
- package/dist/content-locales-provider-BXvuIgfg.mjs +0 -1650
- package/dist/content-locales-provider-BXvuIgfg.mjs.map +0 -1
- package/dist/dashboard-page-B4PGEdc2.mjs +0 -2500
- package/dist/dashboard-page-B4PGEdc2.mjs.map +0 -1
- package/dist/dashboard-page-mCY0pgZv.mjs +0 -3
- package/dist/dropzone-Do3awXKd.mjs +0 -634
- package/dist/dropzone-Do3awXKd.mjs.map +0 -1
- package/dist/forgot-password-page-Bcp-An4Y.mjs.map +0 -1
- package/dist/forgot-password-page-CEwsdLwn.mjs +0 -3
- package/dist/index-B4H3amCD.d.mts +0 -2753
- package/dist/index-B4H3amCD.d.mts.map +0 -1
- package/dist/login-page-BUnpCbCa.mjs +0 -3
- package/dist/login-page-CP4gA-dl.mjs +0 -298
- package/dist/login-page-CP4gA-dl.mjs.map +0 -1
- package/dist/preview-utils-BKQ9-TMa.mjs.map +0 -1
- package/dist/reset-password-page-BqfDmLxA.mjs +0 -281
- package/dist/reset-password-page-BqfDmLxA.mjs.map +0 -1
- package/dist/reset-password-page-CufHz3h3.mjs +0 -3
- package/dist/runtime-6VZM878K.mjs.map +0 -1
- package/dist/saved-views.types-BMsz5mCy.d.mts.map +0 -1
- package/dist/server.d.mts.map +0 -1
- package/dist/server.mjs.map +0 -1
- package/dist/setup-page-BNNzt_Z6.mjs +0 -3
- package/dist/setup-page-YAP_fzqh.mjs.map +0 -1
- package/dist/shared.d.mts.map +0 -1
- package/dist/use-auth-BoLmWtmU.mjs.map +0 -1
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { useCollectionSchema } from "./use-collection-schema.mjs";
|
|
2
|
+
import { useGlobalSchema } from "./use-global-schema.mjs";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { ajvResolver } from "@hookform/resolvers/ajv";
|
|
5
|
+
|
|
6
|
+
//#region src/client/hooks/use-server-validation.ts
|
|
7
|
+
/**
|
|
8
|
+
* useServerValidation Hook
|
|
9
|
+
*
|
|
10
|
+
* Creates a react-hook-form resolver using the server's JSON Schema.
|
|
11
|
+
* Uses AJV for validation, ensuring client-side validation matches server-side exactly.
|
|
12
|
+
*
|
|
13
|
+
* This hook fetches the collection schema from the server and uses the
|
|
14
|
+
* `validation.insert` or `validation.update` JSON Schema for form validation.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Recursively strip `additionalProperties: false` and `$schema` from a JSON Schema.
|
|
18
|
+
*
|
|
19
|
+
* Zod's `z.toJSONSchema()` sets `additionalProperties: false` on every object,
|
|
20
|
+
* which causes AJV to reject form data containing extra fields such as `id`,
|
|
21
|
+
* `createdAt`, `updatedAt`, etc. that are part of the loaded document but not
|
|
22
|
+
* in the validation schema.
|
|
23
|
+
*
|
|
24
|
+
* It also sets `$schema: "https://json-schema.org/draft/2020-12/schema"` which
|
|
25
|
+
* is not supported by @hookform/resolvers/ajv out of the box.
|
|
26
|
+
*/
|
|
27
|
+
function stripAdditionalProperties(schema) {
|
|
28
|
+
if (!schema || typeof schema !== "object") return schema;
|
|
29
|
+
const s = { ...schema };
|
|
30
|
+
delete s.additionalProperties;
|
|
31
|
+
delete s.$schema;
|
|
32
|
+
if (s.properties && typeof s.properties === "object") {
|
|
33
|
+
const props = {};
|
|
34
|
+
for (const [k, v] of Object.entries(s.properties)) props[k] = stripAdditionalProperties(v);
|
|
35
|
+
s.properties = props;
|
|
36
|
+
}
|
|
37
|
+
if (s.items) s.items = stripAdditionalProperties(s.items);
|
|
38
|
+
return s;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Hook to create a react-hook-form resolver using server's JSON Schema
|
|
42
|
+
*
|
|
43
|
+
* Uses the collection's validation schema from the server for client-side
|
|
44
|
+
* validation, ensuring validation rules are consistent between client and server.
|
|
45
|
+
*
|
|
46
|
+
* @param collection - Collection name
|
|
47
|
+
* @param options - Validation options
|
|
48
|
+
* @returns Server validation result with resolver
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```tsx
|
|
52
|
+
* function CreatePostForm() {
|
|
53
|
+
* const { resolver, isLoading } = useServerValidation("posts", { mode: "create" });
|
|
54
|
+
*
|
|
55
|
+
* const form = useForm({
|
|
56
|
+
* resolver,
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* if (isLoading) return <Loading />;
|
|
60
|
+
*
|
|
61
|
+
* return <Form {...form}>...</Form>;
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```tsx
|
|
67
|
+
* // With fallback to client-side validation
|
|
68
|
+
* function PostForm({ isEditing }) {
|
|
69
|
+
* const { resolver: serverResolver, hasServerSchema } = useServerValidation(
|
|
70
|
+
* "posts",
|
|
71
|
+
* { mode: isEditing ? "update" : "create" }
|
|
72
|
+
* );
|
|
73
|
+
* const clientResolver = useCollectionValidation("posts");
|
|
74
|
+
*
|
|
75
|
+
* // Prefer server validation, fall back to client
|
|
76
|
+
* const resolver = hasServerSchema ? serverResolver : clientResolver;
|
|
77
|
+
*
|
|
78
|
+
* const form = useForm({ resolver });
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
function useServerValidation(collection, options = {}) {
|
|
83
|
+
const { mode = "create", enabled = true } = options;
|
|
84
|
+
const { data: schema, isLoading, error } = useCollectionSchema(collection, { enabled });
|
|
85
|
+
return useMemo(() => {
|
|
86
|
+
const jsonSchema = stripAdditionalProperties(mode === "create" ? schema?.validation?.insert : schema?.validation?.update);
|
|
87
|
+
if (!jsonSchema || typeof jsonSchema !== "object") return {
|
|
88
|
+
resolver: void 0,
|
|
89
|
+
hasServerSchema: false,
|
|
90
|
+
isLoading,
|
|
91
|
+
error: error ?? null
|
|
92
|
+
};
|
|
93
|
+
try {
|
|
94
|
+
return {
|
|
95
|
+
resolver: ajvResolver(jsonSchema, {
|
|
96
|
+
allErrors: true,
|
|
97
|
+
strict: false,
|
|
98
|
+
coerceTypes: true,
|
|
99
|
+
useDefaults: true,
|
|
100
|
+
formats: {}
|
|
101
|
+
}, { mode: "async" }),
|
|
102
|
+
hasServerSchema: true,
|
|
103
|
+
isLoading: false,
|
|
104
|
+
error: null
|
|
105
|
+
};
|
|
106
|
+
} catch (e) {
|
|
107
|
+
console.warn(`[useServerValidation] Failed to compile JSON Schema for ${collection}:`, e);
|
|
108
|
+
return {
|
|
109
|
+
resolver: void 0,
|
|
110
|
+
hasServerSchema: false,
|
|
111
|
+
isLoading: false,
|
|
112
|
+
error: e instanceof Error ? e : new Error(String(e))
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}, [
|
|
116
|
+
schema,
|
|
117
|
+
mode,
|
|
118
|
+
isLoading,
|
|
119
|
+
error,
|
|
120
|
+
collection
|
|
121
|
+
]);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Hook to get a combined resolver that prefers server validation
|
|
125
|
+
*
|
|
126
|
+
* This is a convenience hook that combines server and client validation,
|
|
127
|
+
* preferring server validation when available.
|
|
128
|
+
*
|
|
129
|
+
* @param collection - Collection name
|
|
130
|
+
* @param options - Validation options
|
|
131
|
+
* @param fallbackResolver - Optional client-side resolver to use as fallback
|
|
132
|
+
* @returns Resolver function for react-hook-form
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```tsx
|
|
136
|
+
* function PostForm({ isEditing }) {
|
|
137
|
+
* const clientResolver = useCollectionValidation("posts");
|
|
138
|
+
* const resolver = usePreferServerValidation("posts", {
|
|
139
|
+
* mode: isEditing ? "update" : "create"
|
|
140
|
+
* }, clientResolver);
|
|
141
|
+
*
|
|
142
|
+
* const form = useForm({ resolver });
|
|
143
|
+
* }
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
function usePreferServerValidation(collection, options = {}, fallbackResolver) {
|
|
147
|
+
const { resolver: serverResolver, hasServerSchema } = useServerValidation(collection, options);
|
|
148
|
+
return hasServerSchema ? serverResolver : fallbackResolver;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Hook to create a react-hook-form resolver for global settings using server's JSON Schema
|
|
152
|
+
*
|
|
153
|
+
* @param globalName - Global name
|
|
154
|
+
* @param options - Validation options (mode is always "update" for globals)
|
|
155
|
+
* @returns Server validation result with resolver
|
|
156
|
+
*/
|
|
157
|
+
function useGlobalServerValidation(globalName, options = {}) {
|
|
158
|
+
const { enabled = true } = options;
|
|
159
|
+
const { data: schema, isLoading, error } = useGlobalSchema(globalName, { enabled });
|
|
160
|
+
return useMemo(() => {
|
|
161
|
+
const jsonSchema = stripAdditionalProperties(schema?.validation?.update);
|
|
162
|
+
if (!jsonSchema || typeof jsonSchema !== "object") return {
|
|
163
|
+
resolver: void 0,
|
|
164
|
+
hasServerSchema: false,
|
|
165
|
+
isLoading,
|
|
166
|
+
error: error ?? null
|
|
167
|
+
};
|
|
168
|
+
try {
|
|
169
|
+
return {
|
|
170
|
+
resolver: ajvResolver(jsonSchema, {
|
|
171
|
+
allErrors: true,
|
|
172
|
+
strict: false,
|
|
173
|
+
coerceTypes: true,
|
|
174
|
+
useDefaults: true
|
|
175
|
+
}, { mode: "async" }),
|
|
176
|
+
hasServerSchema: true,
|
|
177
|
+
isLoading: false,
|
|
178
|
+
error: null
|
|
179
|
+
};
|
|
180
|
+
} catch (e) {
|
|
181
|
+
console.warn(`[useGlobalServerValidation] Failed to compile JSON Schema for ${globalName}:`, e);
|
|
182
|
+
return {
|
|
183
|
+
resolver: void 0,
|
|
184
|
+
hasServerSchema: false,
|
|
185
|
+
isLoading: false,
|
|
186
|
+
error: e instanceof Error ? e : new Error(String(e))
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
}, [
|
|
190
|
+
schema,
|
|
191
|
+
isLoading,
|
|
192
|
+
error,
|
|
193
|
+
globalName
|
|
194
|
+
]);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
//#endregion
|
|
198
|
+
export { useGlobalServerValidation, usePreferServerValidation };
|
|
199
|
+
//# sourceMappingURL=use-server-validation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-server-validation.mjs","names":["props: Record<string, unknown>"],"sources":["../../../src/client/hooks/use-server-validation.ts"],"sourcesContent":["/**\n * useServerValidation Hook\n *\n * Creates a react-hook-form resolver using the server's JSON Schema.\n * Uses AJV for validation, ensuring client-side validation matches server-side exactly.\n *\n * This hook fetches the collection schema from the server and uses the\n * `validation.insert` or `validation.update` JSON Schema for form validation.\n */\n\nimport { ajvResolver } from \"@hookform/resolvers/ajv\";\nimport type { Options as AjvOptions, JSONSchemaType } from \"ajv\";\nimport type { Questpie } from \"questpie\";\nimport { useMemo } from \"react\";\nimport type { FieldValues, Resolver } from \"react-hook-form\";\nimport type {\n\tRegisteredCMS,\n\tRegisteredCollectionNames,\n} from \"../builder/registry\";\nimport { useCollectionSchema } from \"./use-collection-schema\";\nimport { useGlobalSchema } from \"./use-global-schema\";\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\n/**\n * Recursively strip `additionalProperties: false` and `$schema` from a JSON Schema.\n *\n * Zod's `z.toJSONSchema()` sets `additionalProperties: false` on every object,\n * which causes AJV to reject form data containing extra fields such as `id`,\n * `createdAt`, `updatedAt`, etc. that are part of the loaded document but not\n * in the validation schema.\n *\n * It also sets `$schema: \"https://json-schema.org/draft/2020-12/schema\"` which\n * is not supported by @hookform/resolvers/ajv out of the box.\n */\nfunction stripAdditionalProperties(schema: unknown): unknown {\n\tif (!schema || typeof schema !== \"object\") return schema;\n\tconst s = { ...(schema as Record<string, unknown>) };\n\tdelete s.additionalProperties;\n\t// Remove $schema as AJV resolver doesn't support draft 2020-12 by default\n\tdelete s.$schema;\n\tif (s.properties && typeof s.properties === \"object\") {\n\t\tconst props: Record<string, unknown> = {};\n\t\tfor (const [k, v] of Object.entries(\n\t\t\ts.properties as Record<string, unknown>,\n\t\t)) {\n\t\t\tprops[k] = stripAdditionalProperties(v);\n\t\t}\n\t\ts.properties = props;\n\t}\n\tif (s.items) {\n\t\ts.items = stripAdditionalProperties(s.items);\n\t}\n\treturn s;\n}\n\n// ============================================================================\n// Type Helpers\n// ============================================================================\n\n/**\n * Resolved collection names (string if not registered)\n */\ntype ResolvedCollectionNames =\n\tRegisteredCMS extends Questpie<any> ? RegisteredCollectionNames : string;\n\n/**\n * Validation mode for the hook\n */\nexport type ValidationMode = \"create\" | \"update\";\n\n/**\n * Options for useServerValidation hook\n */\nexport interface UseServerValidationOptions {\n\t/** Validation mode - determines which JSON Schema to use */\n\tmode?: ValidationMode;\n\t/** Whether to enable validation (defaults to true) */\n\tenabled?: boolean;\n}\n\n/**\n * Result of useServerValidation hook\n */\nexport interface ServerValidationResult<TFieldValues extends FieldValues> {\n\t/** Resolver for react-hook-form, undefined if schema not available */\n\tresolver: Resolver<TFieldValues> | undefined;\n\t/** Whether server validation schema is available */\n\thasServerSchema: boolean;\n\t/** Whether the schema is currently loading */\n\tisLoading: boolean;\n\t/** Any error that occurred while fetching the schema */\n\terror: Error | null;\n}\n\n// ============================================================================\n// Constants\n// ============================================================================\n\n/**\n * Default AJV options for form validation\n */\nconst DEFAULT_AJV_OPTIONS: AjvOptions = {\n\tallErrors: true,\n\t// Allow additional properties by default (forms may have extra fields)\n\tstrict: false,\n\t// Coerce types for better form compatibility\n\tcoerceTypes: true,\n\t// Use defaults from schema\n\tuseDefaults: true,\n};\n\n// ============================================================================\n// Hook\n// ============================================================================\n\n/**\n * Hook to create a react-hook-form resolver using server's JSON Schema\n *\n * Uses the collection's validation schema from the server for client-side\n * validation, ensuring validation rules are consistent between client and server.\n *\n * @param collection - Collection name\n * @param options - Validation options\n * @returns Server validation result with resolver\n *\n * @example\n * ```tsx\n * function CreatePostForm() {\n * const { resolver, isLoading } = useServerValidation(\"posts\", { mode: \"create\" });\n *\n * const form = useForm({\n * resolver,\n * });\n *\n * if (isLoading) return <Loading />;\n *\n * return <Form {...form}>...</Form>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With fallback to client-side validation\n * function PostForm({ isEditing }) {\n * const { resolver: serverResolver, hasServerSchema } = useServerValidation(\n * \"posts\",\n * { mode: isEditing ? \"update\" : \"create\" }\n * );\n * const clientResolver = useCollectionValidation(\"posts\");\n *\n * // Prefer server validation, fall back to client\n * const resolver = hasServerSchema ? serverResolver : clientResolver;\n *\n * const form = useForm({ resolver });\n * }\n * ```\n */\nexport function useServerValidation<\n\tK extends ResolvedCollectionNames,\n\tTFieldValues extends FieldValues = FieldValues,\n>(\n\tcollection: K,\n\toptions: UseServerValidationOptions = {},\n): ServerValidationResult<TFieldValues> {\n\tconst { mode = \"create\", enabled = true } = options;\n\n\tconst {\n\t\tdata: schema,\n\t\tisLoading,\n\t\terror,\n\t} = useCollectionSchema(collection, {\n\t\tenabled,\n\t});\n\n\tconst result = useMemo((): ServerValidationResult<TFieldValues> => {\n\t\t// Get the appropriate JSON Schema based on mode\n\t\tconst rawSchema =\n\t\t\tmode === \"create\"\n\t\t\t\t? schema?.validation?.insert\n\t\t\t\t: schema?.validation?.update;\n\t\tconst jsonSchema = stripAdditionalProperties(rawSchema);\n\n\t\tif (!jsonSchema || typeof jsonSchema !== \"object\") {\n\t\t\treturn {\n\t\t\t\tresolver: undefined,\n\t\t\t\thasServerSchema: false,\n\t\t\t\tisLoading,\n\t\t\t\terror: error ?? null,\n\t\t\t};\n\t\t}\n\n\t\ttry {\n\t\t\t// Create resolver using AJV\n\t\t\tconst resolver = ajvResolver(\n\t\t\t\tjsonSchema as JSONSchemaType<TFieldValues>,\n\t\t\t\t{\n\t\t\t\t\t// Use our pre-configured AJV instance options\n\t\t\t\t\tallErrors: true,\n\t\t\t\t\tstrict: false,\n\t\t\t\t\tcoerceTypes: true,\n\t\t\t\t\tuseDefaults: true,\n\t\t\t\t\t// AJV formats plugin options\n\t\t\t\t\tformats: {},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tmode: \"async\",\n\t\t\t\t},\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tresolver,\n\t\t\t\thasServerSchema: true,\n\t\t\t\tisLoading: false,\n\t\t\t\terror: null,\n\t\t\t};\n\t\t} catch (e) {\n\t\t\t// If schema compilation fails, return undefined resolver\n\t\t\tconsole.warn(\n\t\t\t\t`[useServerValidation] Failed to compile JSON Schema for ${collection}:`,\n\t\t\t\te,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tresolver: undefined,\n\t\t\t\thasServerSchema: false,\n\t\t\t\tisLoading: false,\n\t\t\t\terror: e instanceof Error ? e : new Error(String(e)),\n\t\t\t};\n\t\t}\n\t}, [schema, mode, isLoading, error, collection]);\n\n\treturn result;\n}\n\n/**\n * Hook to get a combined resolver that prefers server validation\n *\n * This is a convenience hook that combines server and client validation,\n * preferring server validation when available.\n *\n * @param collection - Collection name\n * @param options - Validation options\n * @param fallbackResolver - Optional client-side resolver to use as fallback\n * @returns Resolver function for react-hook-form\n *\n * @example\n * ```tsx\n * function PostForm({ isEditing }) {\n * const clientResolver = useCollectionValidation(\"posts\");\n * const resolver = usePreferServerValidation(\"posts\", {\n * mode: isEditing ? \"update\" : \"create\"\n * }, clientResolver);\n *\n * const form = useForm({ resolver });\n * }\n * ```\n */\nexport function usePreferServerValidation<\n\tK extends ResolvedCollectionNames,\n\tTFieldValues extends FieldValues = FieldValues,\n>(\n\tcollection: K,\n\toptions: UseServerValidationOptions = {},\n\tfallbackResolver?: Resolver<TFieldValues>,\n): Resolver<TFieldValues> | undefined {\n\tconst { resolver: serverResolver, hasServerSchema } = useServerValidation<\n\t\tK,\n\t\tTFieldValues\n\t>(collection, options);\n\n\treturn hasServerSchema ? serverResolver : fallbackResolver;\n}\n\n// ============================================================================\n// Global Validation Hook\n// ============================================================================\n\n/**\n * Hook to create a react-hook-form resolver for global settings using server's JSON Schema\n *\n * @param globalName - Global name\n * @param options - Validation options (mode is always \"update\" for globals)\n * @returns Server validation result with resolver\n */\nexport function useGlobalServerValidation<\n\tTFieldValues extends FieldValues = FieldValues,\n>(\n\tglobalName: string,\n\toptions: Omit<UseServerValidationOptions, \"mode\"> = {},\n): ServerValidationResult<TFieldValues> {\n\tconst { enabled = true } = options;\n\n\tconst {\n\t\tdata: schema,\n\t\tisLoading,\n\t\terror,\n\t} = useGlobalSchema(globalName, {\n\t\tenabled,\n\t});\n\n\tconst result = useMemo((): ServerValidationResult<TFieldValues> => {\n\t\t// Globals only have update validation\n\t\tconst jsonSchema = stripAdditionalProperties(schema?.validation?.update);\n\n\t\tif (!jsonSchema || typeof jsonSchema !== \"object\") {\n\t\t\treturn {\n\t\t\t\tresolver: undefined,\n\t\t\t\thasServerSchema: false,\n\t\t\t\tisLoading,\n\t\t\t\terror: error ?? null,\n\t\t\t};\n\t\t}\n\n\t\ttry {\n\t\t\tconst resolver = ajvResolver(\n\t\t\t\tjsonSchema as JSONSchemaType<TFieldValues>,\n\t\t\t\t{\n\t\t\t\t\tallErrors: true,\n\t\t\t\t\tstrict: false,\n\t\t\t\t\tcoerceTypes: true,\n\t\t\t\t\tuseDefaults: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tmode: \"async\",\n\t\t\t\t},\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tresolver,\n\t\t\t\thasServerSchema: true,\n\t\t\t\tisLoading: false,\n\t\t\t\terror: null,\n\t\t\t};\n\t\t} catch (e) {\n\t\t\tconsole.warn(\n\t\t\t\t`[useGlobalServerValidation] Failed to compile JSON Schema for ${globalName}:`,\n\t\t\t\te,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tresolver: undefined,\n\t\t\t\thasServerSchema: false,\n\t\t\t\tisLoading: false,\n\t\t\t\terror: e instanceof Error ? e : new Error(String(e)),\n\t\t\t};\n\t\t}\n\t}, [schema, isLoading, error, globalName]);\n\n\treturn result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAS,0BAA0B,QAA0B;AAC5D,KAAI,CAAC,UAAU,OAAO,WAAW,SAAU,QAAO;CAClD,MAAM,IAAI,EAAE,GAAI,QAAoC;AACpD,QAAO,EAAE;AAET,QAAO,EAAE;AACT,KAAI,EAAE,cAAc,OAAO,EAAE,eAAe,UAAU;EACrD,MAAMA,QAAiC,EAAE;AACzC,OAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAC3B,EAAE,WACF,CACA,OAAM,KAAK,0BAA0B,EAAE;AAExC,IAAE,aAAa;;AAEhB,KAAI,EAAE,MACL,GAAE,QAAQ,0BAA0B,EAAE,MAAM;AAE7C,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyGR,SAAgB,oBAIf,YACA,UAAsC,EAAE,EACD;CACvC,MAAM,EAAE,OAAO,UAAU,UAAU,SAAS;CAE5C,MAAM,EACL,MAAM,QACN,WACA,UACG,oBAAoB,YAAY,EACnC,SACA,CAAC;AA0DF,QAxDe,cAAoD;EAMlE,MAAM,aAAa,0BAHlB,SAAS,WACN,QAAQ,YAAY,SACpB,QAAQ,YAAY,OAC+B;AAEvD,MAAI,CAAC,cAAc,OAAO,eAAe,SACxC,QAAO;GACN,UAAU;GACV,iBAAiB;GACjB;GACA,OAAO,SAAS;GAChB;AAGF,MAAI;AAkBH,UAAO;IACN,UAjBgB,YAChB,YACA;KAEC,WAAW;KACX,QAAQ;KACR,aAAa;KACb,aAAa;KAEb,SAAS,EAAE;KACX,EACD,EACC,MAAM,SACN,CACD;IAIA,iBAAiB;IACjB,WAAW;IACX,OAAO;IACP;WACO,GAAG;AAEX,WAAQ,KACP,2DAA2D,WAAW,IACtE,EACA;AACD,UAAO;IACN,UAAU;IACV,iBAAiB;IACjB,WAAW;IACX,OAAO,aAAa,QAAQ,IAAI,IAAI,MAAM,OAAO,EAAE,CAAC;IACpD;;IAEA;EAAC;EAAQ;EAAM;EAAW;EAAO;EAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;AA4BjD,SAAgB,0BAIf,YACA,UAAsC,EAAE,EACxC,kBACqC;CACrC,MAAM,EAAE,UAAU,gBAAgB,oBAAoB,oBAGpD,YAAY,QAAQ;AAEtB,QAAO,kBAAkB,iBAAiB;;;;;;;;;AAc3C,SAAgB,0BAGf,YACA,UAAoD,EAAE,EACf;CACvC,MAAM,EAAE,UAAU,SAAS;CAE3B,MAAM,EACL,MAAM,QACN,WACA,UACG,gBAAgB,YAAY,EAC/B,SACA,CAAC;AAiDF,QA/Ce,cAAoD;EAElE,MAAM,aAAa,0BAA0B,QAAQ,YAAY,OAAO;AAExE,MAAI,CAAC,cAAc,OAAO,eAAe,SACxC,QAAO;GACN,UAAU;GACV,iBAAiB;GACjB;GACA,OAAO,SAAS;GAChB;AAGF,MAAI;AAcH,UAAO;IACN,UAdgB,YAChB,YACA;KACC,WAAW;KACX,QAAQ;KACR,aAAa;KACb,aAAa;KACb,EACD,EACC,MAAM,SACN,CACD;IAIA,iBAAiB;IACjB,WAAW;IACX,OAAO;IACP;WACO,GAAG;AACX,WAAQ,KACP,iEAAiE,WAAW,IAC5E,EACA;AACD,UAAO;IACN,UAAU;IACV,iBAAiB;IACjB,WAAW;IACX,OAAO,aAAa,QAAQ,IAAI,IAAI,MAAM,OAAO,EAAE,CAAC;IACpD;;IAEA;EAAC;EAAQ;EAAW;EAAO;EAAW,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
|
|
3
|
+
//#region src/client/hooks/use-server-widget-data.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Fetches widget data from server via the fetchWidgetData RPC endpoint.
|
|
7
|
+
*
|
|
8
|
+
* @param widgetId - The widget ID to fetch data for
|
|
9
|
+
* @param options - Query options
|
|
10
|
+
* @returns TanStack Query result with the widget data
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* const { data, isLoading } = useServerWidgetData<{ count: number }>(
|
|
15
|
+
* "my-widget",
|
|
16
|
+
* { enabled: config.hasFetchFn }
|
|
17
|
+
* );
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare function useServerWidgetData<T = unknown>(widgetId: string, options?: {
|
|
21
|
+
enabled?: boolean;
|
|
22
|
+
refreshInterval?: number;
|
|
23
|
+
}): UseQueryResult<T>;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { useServerWidgetData };
|
|
26
|
+
//# sourceMappingURL=use-server-widget-data.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-server-widget-data.d.mts","names":[],"sources":["../../../src/client/hooks/use-server-widget-data.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;iBAuBgB;;;IAGb,eAAe"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { selectClient, useAdminStore } from "../runtime/provider.mjs";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
|
|
4
|
+
//#region src/client/hooks/use-server-widget-data.ts
|
|
5
|
+
/**
|
|
6
|
+
* Hook for fetching widget data from server via fetchWidgetData RPC.
|
|
7
|
+
* Used when a widget has hasFetchFn=true (server-side fetchFn).
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Fetches widget data from server via the fetchWidgetData RPC endpoint.
|
|
11
|
+
*
|
|
12
|
+
* @param widgetId - The widget ID to fetch data for
|
|
13
|
+
* @param options - Query options
|
|
14
|
+
* @returns TanStack Query result with the widget data
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* const { data, isLoading } = useServerWidgetData<{ count: number }>(
|
|
19
|
+
* "my-widget",
|
|
20
|
+
* { enabled: config.hasFetchFn }
|
|
21
|
+
* );
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
function useServerWidgetData(widgetId, options) {
|
|
25
|
+
const client = useAdminStore(selectClient);
|
|
26
|
+
return useQuery({
|
|
27
|
+
queryKey: [
|
|
28
|
+
"widget",
|
|
29
|
+
"serverData",
|
|
30
|
+
widgetId
|
|
31
|
+
],
|
|
32
|
+
queryFn: () => client.rpc.fetchWidgetData({ widgetId }),
|
|
33
|
+
enabled: options?.enabled ?? true,
|
|
34
|
+
refetchInterval: options?.refreshInterval
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { useServerWidgetData };
|
|
40
|
+
//# sourceMappingURL=use-server-widget-data.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-server-widget-data.mjs","names":[],"sources":["../../../src/client/hooks/use-server-widget-data.ts"],"sourcesContent":["/**\n * Hook for fetching widget data from server via fetchWidgetData RPC.\n * Used when a widget has hasFetchFn=true (server-side fetchFn).\n */\n\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { selectClient, useAdminStore } from \"../runtime\";\n\n/**\n * Fetches widget data from server via the fetchWidgetData RPC endpoint.\n *\n * @param widgetId - The widget ID to fetch data for\n * @param options - Query options\n * @returns TanStack Query result with the widget data\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useServerWidgetData<{ count: number }>(\n * \"my-widget\",\n * { enabled: config.hasFetchFn }\n * );\n * ```\n */\nexport function useServerWidgetData<T = unknown>(\n widgetId: string,\n options?: { enabled?: boolean; refreshInterval?: number },\n): UseQueryResult<T> {\n const client = useAdminStore(selectClient);\n\n return useQuery<T>({\n queryKey: [\"widget\", \"serverData\", widgetId],\n queryFn: () =>\n (client as any).rpc.fetchWidgetData({ widgetId }) as Promise<T>,\n enabled: options?.enabled ?? true,\n refetchInterval: options?.refreshInterval,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,oBACd,UACA,SACmB;CACnB,MAAM,SAAS,cAAc,aAAa;AAE1C,QAAO,SAAY;EACjB,UAAU;GAAC;GAAU;GAAc;GAAS;EAC5C,eACG,OAAe,IAAI,gBAAgB,EAAE,UAAU,CAAC;EACnD,SAAS,SAAS,WAAW;EAC7B,iBAAiB,SAAS;EAC3B,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as _tanstack_react_query0 from "@tanstack/react-query";
|
|
2
|
+
|
|
3
|
+
//#region src/client/hooks/use-setup-status.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Setup Status Hook
|
|
7
|
+
*
|
|
8
|
+
* Hook to check if the CMS setup is required (no users exist).
|
|
9
|
+
* Useful for redirecting to setup page on first visit.
|
|
10
|
+
*/
|
|
11
|
+
interface SetupStatus {
|
|
12
|
+
/** Whether setup is required (no users exist) */
|
|
13
|
+
required: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Check if CMS setup is required.
|
|
17
|
+
*
|
|
18
|
+
* Returns `required: true` if no users exist in the system,
|
|
19
|
+
* meaning the setup page should be shown to create the first admin.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* function App() {
|
|
24
|
+
* const { data, isLoading } = useSetupStatus();
|
|
25
|
+
*
|
|
26
|
+
* if (isLoading) return <LoadingSpinner />;
|
|
27
|
+
*
|
|
28
|
+
* if (data?.required) {
|
|
29
|
+
* return <Navigate to="/admin/setup" />;
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* return <AdminPanel />;
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare function useSetupStatus(): _tanstack_react_query0.UseQueryResult<SetupStatus, Error>;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { SetupStatus, useSetupStatus };
|
|
39
|
+
//# sourceMappingURL=use-setup-status.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-setup-status.d.mts","names":[],"sources":["../../../src/client/hooks/use-setup-status.ts"],"sourcesContent":[],"mappings":";;;;;;;AAUA;AA0BA;;AAA8B,UA1Bb,WAAA,CA0Ba;EAAA;EAAA,QAAA,EAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;iBAAd,cAAA,CAAA,GAAc,sBAAA,CAAA,eAAA,aAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { selectClient, useAdminStore } from "../runtime/provider.mjs";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
|
|
4
|
+
//#region src/client/hooks/use-setup-status.ts
|
|
5
|
+
/**
|
|
6
|
+
* Setup Status Hook
|
|
7
|
+
*
|
|
8
|
+
* Hook to check if the CMS setup is required (no users exist).
|
|
9
|
+
* Useful for redirecting to setup page on first visit.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Check if CMS setup is required.
|
|
13
|
+
*
|
|
14
|
+
* Returns `required: true` if no users exist in the system,
|
|
15
|
+
* meaning the setup page should be shown to create the first admin.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* function App() {
|
|
20
|
+
* const { data, isLoading } = useSetupStatus();
|
|
21
|
+
*
|
|
22
|
+
* if (isLoading) return <LoadingSpinner />;
|
|
23
|
+
*
|
|
24
|
+
* if (data?.required) {
|
|
25
|
+
* return <Navigate to="/admin/setup" />;
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* return <AdminPanel />;
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
function useSetupStatus() {
|
|
33
|
+
const client = useAdminStore(selectClient);
|
|
34
|
+
return useQuery({
|
|
35
|
+
queryKey: ["questpie", "setup-status"],
|
|
36
|
+
queryFn: async () => {
|
|
37
|
+
try {
|
|
38
|
+
return { required: (await client.rpc.isSetupRequired({})).required };
|
|
39
|
+
} catch {
|
|
40
|
+
return { required: false };
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
staleTime: 1e3 * 60,
|
|
44
|
+
retry: false
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
export { useSetupStatus };
|
|
50
|
+
//# sourceMappingURL=use-setup-status.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-setup-status.mjs","names":[],"sources":["../../../src/client/hooks/use-setup-status.ts"],"sourcesContent":["/**\n * Setup Status Hook\n *\n * Hook to check if the CMS setup is required (no users exist).\n * Useful for redirecting to setup page on first visit.\n */\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { selectClient, useAdminStore } from \"../runtime/provider\";\n\nexport interface SetupStatus {\n /** Whether setup is required (no users exist) */\n required: boolean;\n}\n\n/**\n * Check if CMS setup is required.\n *\n * Returns `required: true` if no users exist in the system,\n * meaning the setup page should be shown to create the first admin.\n *\n * @example\n * ```tsx\n * function App() {\n * const { data, isLoading } = useSetupStatus();\n *\n * if (isLoading) return <LoadingSpinner />;\n *\n * if (data?.required) {\n * return <Navigate to=\"/admin/setup\" />;\n * }\n *\n * return <AdminPanel />;\n * }\n * ```\n */\nexport function useSetupStatus() {\n const client = useAdminStore(selectClient);\n\n return useQuery<SetupStatus>({\n queryKey: [\"questpie\", \"setup-status\"],\n queryFn: async () => {\n try {\n const result = await (client as any).rpc.isSetupRequired({});\n return { required: result.required };\n } catch {\n // If the function doesn't exist, setup is not required\n return { required: false };\n }\n },\n staleTime: 1000 * 60, // Cache for 1 minute\n retry: false,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,iBAAiB;CAC/B,MAAM,SAAS,cAAc,aAAa;AAE1C,QAAO,SAAsB;EAC3B,UAAU,CAAC,YAAY,eAAe;EACtC,SAAS,YAAY;AACnB,OAAI;AAEF,WAAO,EAAE,WADM,MAAO,OAAe,IAAI,gBAAgB,EAAE,CAAC,EAClC,UAAU;WAC9B;AAEN,WAAO,EAAE,UAAU,OAAO;;;EAG9B,WAAW,MAAO;EAClB,OAAO;EACR,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useAdminConfig } from "./use-admin-config.mjs";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/client/hooks/use-upload-collection.ts
|
|
5
|
+
function normalizeCollectionName(value) {
|
|
6
|
+
if (typeof value !== "string") return void 0;
|
|
7
|
+
const trimmed = value.trim();
|
|
8
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
9
|
+
}
|
|
10
|
+
function resolveUploadCollection(preferred, uploads) {
|
|
11
|
+
const preferredCollection = normalizeCollectionName(preferred);
|
|
12
|
+
if (preferredCollection) return preferredCollection;
|
|
13
|
+
const defaultCollection = normalizeCollectionName(uploads?.defaultCollection);
|
|
14
|
+
if (defaultCollection) return defaultCollection;
|
|
15
|
+
if (uploads?.collections?.length === 1) return uploads.collections[0];
|
|
16
|
+
}
|
|
17
|
+
function useUploadCollection(preferred) {
|
|
18
|
+
const { data: adminConfig } = useAdminConfig();
|
|
19
|
+
const collections = adminConfig?.uploads?.collections ?? [];
|
|
20
|
+
return useMemo(() => ({
|
|
21
|
+
collection: resolveUploadCollection(preferred, adminConfig?.uploads),
|
|
22
|
+
collections
|
|
23
|
+
}), [
|
|
24
|
+
preferred,
|
|
25
|
+
collections.join("|"),
|
|
26
|
+
adminConfig?.uploads?.defaultCollection
|
|
27
|
+
]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { useUploadCollection };
|
|
32
|
+
//# sourceMappingURL=use-upload-collection.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-upload-collection.mjs","names":[],"sources":["../../../src/client/hooks/use-upload-collection.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport type { AdminConfigResponse } from \"../types/admin-config\";\nimport { useAdminConfig } from \"./use-admin-config\";\n\ntype UploadConfig = AdminConfigResponse[\"uploads\"];\n\nexport type UploadCollectionResolution = {\n\tcollection?: string;\n\tcollections: string[];\n};\n\nfunction normalizeCollectionName(value: unknown): string | undefined {\n\tif (typeof value !== \"string\") return undefined;\n\tconst trimmed = value.trim();\n\treturn trimmed.length > 0 ? trimmed : undefined;\n}\n\nexport function resolveUploadCollection(\n\tpreferred?: string,\n\tuploads?: UploadConfig,\n): string | undefined {\n\tconst preferredCollection = normalizeCollectionName(preferred);\n\tif (preferredCollection) {\n\t\treturn preferredCollection;\n\t}\n\n\tconst defaultCollection = normalizeCollectionName(uploads?.defaultCollection);\n\tif (defaultCollection) {\n\t\treturn defaultCollection;\n\t}\n\n\tif (uploads?.collections?.length === 1) {\n\t\treturn uploads.collections[0];\n\t}\n\n\treturn undefined;\n}\n\nexport function useUploadCollection(\n\tpreferred?: string,\n): UploadCollectionResolution {\n\tconst { data: adminConfig } = useAdminConfig();\n\n\tconst collections = adminConfig?.uploads?.collections ?? [];\n\tconst collectionsKey = collections.join(\"|\");\n\n\treturn useMemo(\n\t\t() => ({\n\t\t\tcollection: resolveUploadCollection(preferred, adminConfig?.uploads),\n\t\t\tcollections,\n\t\t}),\n\t\t[preferred, collectionsKey, adminConfig?.uploads?.defaultCollection],\n\t);\n}\n"],"mappings":";;;;AAWA,SAAS,wBAAwB,OAAoC;AACpE,KAAI,OAAO,UAAU,SAAU,QAAO;CACtC,MAAM,UAAU,MAAM,MAAM;AAC5B,QAAO,QAAQ,SAAS,IAAI,UAAU;;AAGvC,SAAgB,wBACf,WACA,SACqB;CACrB,MAAM,sBAAsB,wBAAwB,UAAU;AAC9D,KAAI,oBACH,QAAO;CAGR,MAAM,oBAAoB,wBAAwB,SAAS,kBAAkB;AAC7E,KAAI,kBACH,QAAO;AAGR,KAAI,SAAS,aAAa,WAAW,EACpC,QAAO,QAAQ,YAAY;;AAM7B,SAAgB,oBACf,WAC6B;CAC7B,MAAM,EAAE,MAAM,gBAAgB,gBAAgB;CAE9C,MAAM,cAAc,aAAa,SAAS,eAAe,EAAE;AAG3D,QAAO,eACC;EACN,YAAY,wBAAwB,WAAW,aAAa,QAAQ;EACpE;EACA,GACD;EAAC;EAPqB,YAAY,KAAK,IAAI;EAOf,aAAa,SAAS;EAAkB,CACpE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/client/hooks/use-upload.d.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Asset record returned from upload
|
|
5
|
+
*/
|
|
6
|
+
interface Asset {
|
|
7
|
+
id: string;
|
|
8
|
+
key: string;
|
|
9
|
+
filename: string;
|
|
10
|
+
mimeType: string;
|
|
11
|
+
size: number;
|
|
12
|
+
visibility: "public" | "private";
|
|
13
|
+
url?: string;
|
|
14
|
+
width?: number | null;
|
|
15
|
+
height?: number | null;
|
|
16
|
+
alt?: string | null;
|
|
17
|
+
caption?: string | null;
|
|
18
|
+
createdAt?: string;
|
|
19
|
+
updatedAt?: string;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { Asset };
|
|
23
|
+
//# sourceMappingURL=use-upload.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-upload.d.mts","names":[],"sources":["../../../src/client/hooks/use-upload.ts"],"sourcesContent":[],"mappings":";;;;;UA8CiB,KAAA"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { selectClient, useAdminStore } from "../runtime/provider.mjs";
|
|
2
|
+
import { useUploadCollection } from "./use-upload-collection.mjs";
|
|
3
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { useCallback, useState } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/client/hooks/use-upload.ts
|
|
7
|
+
/**
|
|
8
|
+
* useUpload Hook
|
|
9
|
+
*
|
|
10
|
+
* Handles file uploads to the CMS with progress tracking.
|
|
11
|
+
* Uses the QuestpieClient's upload method which uses XMLHttpRequest for progress.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* const { upload, uploadMany, isUploading, progress } = useUpload();
|
|
16
|
+
*
|
|
17
|
+
* // Single file upload
|
|
18
|
+
* const asset = await upload(file);
|
|
19
|
+
*
|
|
20
|
+
* // Multiple files upload
|
|
21
|
+
* const assets = await uploadMany(files, {
|
|
22
|
+
* onProgress: (p) => console.log(`${p}%`),
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Hook for uploading files to the CMS
|
|
28
|
+
*
|
|
29
|
+
* Uses the QuestpieClient's built-in upload method which provides
|
|
30
|
+
* progress tracking via XMLHttpRequest.
|
|
31
|
+
*/
|
|
32
|
+
function useUpload() {
|
|
33
|
+
const client = useAdminStore(selectClient);
|
|
34
|
+
const queryClient = useQueryClient();
|
|
35
|
+
const { collection: defaultUploadCollection, collections: uploadCollections } = useUploadCollection();
|
|
36
|
+
const [isUploading, setIsUploading] = useState(false);
|
|
37
|
+
const [progress, setProgress] = useState(0);
|
|
38
|
+
const [error, setError] = useState(null);
|
|
39
|
+
const resolveTargetCollection = useCallback((to) => {
|
|
40
|
+
const explicit = typeof to === "string" ? to.trim() : "";
|
|
41
|
+
if (explicit.length > 0) return explicit;
|
|
42
|
+
return defaultUploadCollection;
|
|
43
|
+
}, [defaultUploadCollection]);
|
|
44
|
+
const getMissingCollectionMessage = useCallback(() => {
|
|
45
|
+
if (uploadCollections.length === 0) return "No upload-enabled collection is registered. Configure a collection with .upload() and ensure it is accessible in admin config.";
|
|
46
|
+
if (uploadCollections.length > 1) return `Multiple upload collections are available (${uploadCollections.join(", ")}). Pass UploadOptions.to to select one.`;
|
|
47
|
+
return "Upload collection is not configured.";
|
|
48
|
+
}, [uploadCollections]);
|
|
49
|
+
return {
|
|
50
|
+
upload: useCallback(async (file, options = {}) => {
|
|
51
|
+
const { to, onProgress, signal } = options;
|
|
52
|
+
const targetCollection = resolveTargetCollection(to);
|
|
53
|
+
if (!targetCollection) {
|
|
54
|
+
const missingCollectionError = new Error(getMissingCollectionMessage());
|
|
55
|
+
setError(missingCollectionError);
|
|
56
|
+
throw missingCollectionError;
|
|
57
|
+
}
|
|
58
|
+
setIsUploading(true);
|
|
59
|
+
setProgress(0);
|
|
60
|
+
setError(null);
|
|
61
|
+
try {
|
|
62
|
+
const collectionApi = client.collections[targetCollection];
|
|
63
|
+
if (!collectionApi?.upload) throw new Error(`Collection "${targetCollection}" does not support uploads. Make sure .upload() is enabled on the collection.`);
|
|
64
|
+
const result = await collectionApi.upload(file, {
|
|
65
|
+
signal,
|
|
66
|
+
onProgress: (p) => {
|
|
67
|
+
setProgress(p);
|
|
68
|
+
onProgress?.(p);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
queryClient.invalidateQueries({ queryKey: [
|
|
72
|
+
"questpie",
|
|
73
|
+
"collections",
|
|
74
|
+
targetCollection
|
|
75
|
+
] });
|
|
76
|
+
return result;
|
|
77
|
+
} catch (err) {
|
|
78
|
+
const uploadError = err instanceof Error ? err : /* @__PURE__ */ new Error("Upload failed");
|
|
79
|
+
setError(uploadError);
|
|
80
|
+
throw uploadError;
|
|
81
|
+
} finally {
|
|
82
|
+
setIsUploading(false);
|
|
83
|
+
}
|
|
84
|
+
}, [
|
|
85
|
+
client,
|
|
86
|
+
queryClient,
|
|
87
|
+
resolveTargetCollection,
|
|
88
|
+
getMissingCollectionMessage
|
|
89
|
+
]),
|
|
90
|
+
uploadMany: useCallback(async (files, options = {}) => {
|
|
91
|
+
const { to, onProgress, signal } = options;
|
|
92
|
+
const targetCollection = resolveTargetCollection(to);
|
|
93
|
+
if (!targetCollection) {
|
|
94
|
+
const missingCollectionError = new Error(getMissingCollectionMessage());
|
|
95
|
+
setError(missingCollectionError);
|
|
96
|
+
throw missingCollectionError;
|
|
97
|
+
}
|
|
98
|
+
if (files.length === 0) return [];
|
|
99
|
+
setIsUploading(true);
|
|
100
|
+
setProgress(0);
|
|
101
|
+
setError(null);
|
|
102
|
+
try {
|
|
103
|
+
const collectionApi = client.collections[targetCollection];
|
|
104
|
+
if (!collectionApi?.uploadMany) throw new Error(`Collection "${targetCollection}" does not support uploads. Make sure .upload() is enabled on the collection.`);
|
|
105
|
+
const results = await collectionApi.uploadMany(files, {
|
|
106
|
+
signal,
|
|
107
|
+
onProgress: (p, fileIndex) => {
|
|
108
|
+
setProgress(p);
|
|
109
|
+
onProgress?.(p, fileIndex);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
queryClient.invalidateQueries({ queryKey: [
|
|
113
|
+
"questpie",
|
|
114
|
+
"collections",
|
|
115
|
+
targetCollection
|
|
116
|
+
] });
|
|
117
|
+
setProgress(100);
|
|
118
|
+
return results;
|
|
119
|
+
} catch (err) {
|
|
120
|
+
const uploadError = err instanceof Error ? err : /* @__PURE__ */ new Error("Upload failed");
|
|
121
|
+
setError(uploadError);
|
|
122
|
+
throw uploadError;
|
|
123
|
+
} finally {
|
|
124
|
+
setIsUploading(false);
|
|
125
|
+
}
|
|
126
|
+
}, [
|
|
127
|
+
client,
|
|
128
|
+
queryClient,
|
|
129
|
+
resolveTargetCollection,
|
|
130
|
+
getMissingCollectionMessage
|
|
131
|
+
]),
|
|
132
|
+
isUploading,
|
|
133
|
+
progress,
|
|
134
|
+
error,
|
|
135
|
+
reset: useCallback(() => {
|
|
136
|
+
setIsUploading(false);
|
|
137
|
+
setProgress(0);
|
|
138
|
+
setError(null);
|
|
139
|
+
}, [])
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
//#endregion
|
|
144
|
+
export { useUpload };
|
|
145
|
+
//# sourceMappingURL=use-upload.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-upload.mjs","names":[],"sources":["../../../src/client/hooks/use-upload.ts"],"sourcesContent":["/**\n * useUpload Hook\n *\n * Handles file uploads to the CMS with progress tracking.\n * Uses the QuestpieClient's upload method which uses XMLHttpRequest for progress.\n *\n * @example\n * ```tsx\n * const { upload, uploadMany, isUploading, progress } = useUpload();\n *\n * // Single file upload\n * const asset = await upload(file);\n *\n * // Multiple files upload\n * const assets = await uploadMany(files, {\n * onProgress: (p) => console.log(`${p}%`),\n * });\n * ```\n */\n\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { useCallback, useState } from \"react\";\nimport { selectClient, useAdminStore } from \"../runtime\";\nimport { useUploadCollection } from \"./use-upload-collection\";\n\n/**\n * Upload error with additional context\n */\nexport class UploadError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly status?: number,\n\t\tpublic readonly response?: unknown,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"UploadError\";\n\t}\n}\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Asset record returned from upload\n */\nexport interface Asset {\n\tid: string;\n\tkey: string;\n\tfilename: string;\n\tmimeType: string;\n\tsize: number;\n\tvisibility: \"public\" | \"private\";\n\turl?: string;\n\twidth?: number | null;\n\theight?: number | null;\n\talt?: string | null;\n\tcaption?: string | null;\n\tcreatedAt?: string;\n\tupdatedAt?: string;\n}\n\n/**\n * Options for upload operations\n */\nexport interface UploadOptions {\n\t/**\n\t * Target collection for upload (must have .upload() enabled)\n\t */\n\tto?: string;\n\n\t/**\n\t * Progress callback (0-100)\n\t */\n\tonProgress?: (progress: number) => void;\n\n\t/**\n\t * Abort signal for cancellation\n\t */\n\tsignal?: AbortSignal;\n}\n\n/**\n * Options for uploadMany operation\n */\nexport interface UploadManyOptions extends UploadOptions {\n\t/**\n\t * Progress callback receives overall progress (0-100)\n\t * and optionally individual file progress\n\t */\n\tonProgress?: (progress: number, fileIndex?: number) => void;\n}\n\n/**\n * Return type for useUpload hook\n */\nexport interface UseUploadReturn {\n\t/**\n\t * Upload a single file\n\t */\n\tupload: (file: File, options?: UploadOptions) => Promise<Asset>;\n\n\t/**\n\t * Upload multiple files sequentially\n\t */\n\tuploadMany: (files: File[], options?: UploadManyOptions) => Promise<Asset[]>;\n\n\t/**\n\t * Whether an upload is currently in progress\n\t */\n\tisUploading: boolean;\n\n\t/**\n\t * Current upload progress (0-100)\n\t */\n\tprogress: number;\n\n\t/**\n\t * Current error, if any\n\t */\n\terror: Error | null;\n\n\t/**\n\t * Reset state (clear error, progress)\n\t */\n\treset: () => void;\n}\n\n// ============================================================================\n// Hook Implementation\n// ============================================================================\n\n/**\n * Hook for uploading files to the CMS\n *\n * Uses the QuestpieClient's built-in upload method which provides\n * progress tracking via XMLHttpRequest.\n */\nexport function useUpload(): UseUploadReturn {\n\tconst client = useAdminStore(selectClient);\n\tconst queryClient = useQueryClient();\n\tconst {\n\t\tcollection: defaultUploadCollection,\n\t\tcollections: uploadCollections,\n\t} = useUploadCollection();\n\n\tconst [isUploading, setIsUploading] = useState(false);\n\tconst [progress, setProgress] = useState(0);\n\tconst [error, setError] = useState<Error | null>(null);\n\n\tconst resolveTargetCollection = useCallback(\n\t\t(to?: string): string | undefined => {\n\t\t\tconst explicit = typeof to === \"string\" ? to.trim() : \"\";\n\t\t\tif (explicit.length > 0) {\n\t\t\t\treturn explicit;\n\t\t\t}\n\n\t\t\treturn defaultUploadCollection;\n\t\t},\n\t\t[defaultUploadCollection],\n\t);\n\n\tconst getMissingCollectionMessage = useCallback((): string => {\n\t\tif (uploadCollections.length === 0) {\n\t\t\treturn \"No upload-enabled collection is registered. Configure a collection with .upload() and ensure it is accessible in admin config.\";\n\t\t}\n\n\t\tif (uploadCollections.length > 1) {\n\t\t\treturn `Multiple upload collections are available (${uploadCollections.join(\", \")}). Pass UploadOptions.to to select one.`;\n\t\t}\n\n\t\treturn \"Upload collection is not configured.\";\n\t}, [uploadCollections]);\n\n\t/**\n\t * Upload a single file\n\t */\n\tconst upload = useCallback(\n\t\tasync (file: File, options: UploadOptions = {}): Promise<Asset> => {\n\t\t\tconst { to, onProgress, signal } = options;\n\t\t\tconst targetCollection = resolveTargetCollection(to);\n\n\t\t\tif (!targetCollection) {\n\t\t\t\tconst missingCollectionError = new Error(getMissingCollectionMessage());\n\t\t\t\tsetError(missingCollectionError);\n\t\t\t\tthrow missingCollectionError;\n\t\t\t}\n\n\t\t\tsetIsUploading(true);\n\t\t\tsetProgress(0);\n\t\t\tsetError(null);\n\n\t\t\ttry {\n\t\t\t\t// Get the collection API from client\n\t\t\t\tconst collectionApi = (client.collections as any)[targetCollection];\n\n\t\t\t\tif (!collectionApi?.upload) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Collection \"${targetCollection}\" does not support uploads. Make sure .upload() is enabled on the collection.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst result = await collectionApi.upload(file, {\n\t\t\t\t\tsignal,\n\t\t\t\t\tonProgress: (p: number) => {\n\t\t\t\t\t\tsetProgress(p);\n\t\t\t\t\t\tonProgress?.(p);\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\t// Invalidate collection queries to refresh lists\n\t\t\t\tqueryClient.invalidateQueries({\n\t\t\t\t\tqueryKey: [\"questpie\", \"collections\", targetCollection],\n\t\t\t\t});\n\n\t\t\t\treturn result as Asset;\n\t\t\t} catch (err) {\n\t\t\t\tconst uploadError =\n\t\t\t\t\terr instanceof Error ? err : new Error(\"Upload failed\");\n\t\t\t\tsetError(uploadError);\n\t\t\t\tthrow uploadError;\n\t\t\t} finally {\n\t\t\t\tsetIsUploading(false);\n\t\t\t}\n\t\t},\n\t\t[client, queryClient, resolveTargetCollection, getMissingCollectionMessage],\n\t);\n\n\t/**\n\t * Upload multiple files sequentially\n\t */\n\tconst uploadMany = useCallback(\n\t\tasync (\n\t\t\tfiles: File[],\n\t\t\toptions: UploadManyOptions = {},\n\t\t): Promise<Asset[]> => {\n\t\t\tconst { to, onProgress, signal } = options;\n\t\t\tconst targetCollection = resolveTargetCollection(to);\n\n\t\t\tif (!targetCollection) {\n\t\t\t\tconst missingCollectionError = new Error(getMissingCollectionMessage());\n\t\t\t\tsetError(missingCollectionError);\n\t\t\t\tthrow missingCollectionError;\n\t\t\t}\n\n\t\t\tif (files.length === 0) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tsetIsUploading(true);\n\t\t\tsetProgress(0);\n\t\t\tsetError(null);\n\n\t\t\ttry {\n\t\t\t\t// Get the collection API from client\n\t\t\t\tconst collectionApi = (client.collections as any)[targetCollection];\n\n\t\t\t\tif (!collectionApi?.uploadMany) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Collection \"${targetCollection}\" does not support uploads. Make sure .upload() is enabled on the collection.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst results = await collectionApi.uploadMany(files, {\n\t\t\t\t\tsignal,\n\t\t\t\t\tonProgress: (p: number, fileIndex?: number) => {\n\t\t\t\t\t\tsetProgress(p);\n\t\t\t\t\t\tonProgress?.(p, fileIndex);\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\t// Invalidate collection queries\n\t\t\t\tqueryClient.invalidateQueries({\n\t\t\t\t\tqueryKey: [\"questpie\", \"collections\", targetCollection],\n\t\t\t\t});\n\n\t\t\t\tsetProgress(100);\n\t\t\t\treturn results as Asset[];\n\t\t\t} catch (err) {\n\t\t\t\tconst uploadError =\n\t\t\t\t\terr instanceof Error ? err : new Error(\"Upload failed\");\n\t\t\t\tsetError(uploadError);\n\t\t\t\tthrow uploadError;\n\t\t\t} finally {\n\t\t\t\tsetIsUploading(false);\n\t\t\t}\n\t\t},\n\t\t[client, queryClient, resolveTargetCollection, getMissingCollectionMessage],\n\t);\n\n\t/**\n\t * Reset hook state\n\t */\n\tconst reset = useCallback(() => {\n\t\tsetIsUploading(false);\n\t\tsetProgress(0);\n\t\tsetError(null);\n\t}, []);\n\n\treturn {\n\t\tupload,\n\t\tuploadMany,\n\t\tisUploading,\n\t\tprogress,\n\t\terror,\n\t\treset,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0IA,SAAgB,YAA6B;CAC5C,MAAM,SAAS,cAAc,aAAa;CAC1C,MAAM,cAAc,gBAAgB;CACpC,MAAM,EACL,YAAY,yBACZ,aAAa,sBACV,qBAAqB;CAEzB,MAAM,CAAC,aAAa,kBAAkB,SAAS,MAAM;CACrD,MAAM,CAAC,UAAU,eAAe,SAAS,EAAE;CAC3C,MAAM,CAAC,OAAO,YAAY,SAAuB,KAAK;CAEtD,MAAM,0BAA0B,aAC9B,OAAoC;EACpC,MAAM,WAAW,OAAO,OAAO,WAAW,GAAG,MAAM,GAAG;AACtD,MAAI,SAAS,SAAS,EACrB,QAAO;AAGR,SAAO;IAER,CAAC,wBAAwB,CACzB;CAED,MAAM,8BAA8B,kBAA0B;AAC7D,MAAI,kBAAkB,WAAW,EAChC,QAAO;AAGR,MAAI,kBAAkB,SAAS,EAC9B,QAAO,8CAA8C,kBAAkB,KAAK,KAAK,CAAC;AAGnF,SAAO;IACL,CAAC,kBAAkB,CAAC;AA+HvB,QAAO;EACN,QA3Hc,YACd,OAAO,MAAY,UAAyB,EAAE,KAAqB;GAClE,MAAM,EAAE,IAAI,YAAY,WAAW;GACnC,MAAM,mBAAmB,wBAAwB,GAAG;AAEpD,OAAI,CAAC,kBAAkB;IACtB,MAAM,yBAAyB,IAAI,MAAM,6BAA6B,CAAC;AACvE,aAAS,uBAAuB;AAChC,UAAM;;AAGP,kBAAe,KAAK;AACpB,eAAY,EAAE;AACd,YAAS,KAAK;AAEd,OAAI;IAEH,MAAM,gBAAiB,OAAO,YAAoB;AAElD,QAAI,CAAC,eAAe,OACnB,OAAM,IAAI,MACT,eAAe,iBAAiB,+EAChC;IAGF,MAAM,SAAS,MAAM,cAAc,OAAO,MAAM;KAC/C;KACA,aAAa,MAAc;AAC1B,kBAAY,EAAE;AACd,mBAAa,EAAE;;KAEhB,CAAC;AAGF,gBAAY,kBAAkB,EAC7B,UAAU;KAAC;KAAY;KAAe;KAAiB,EACvD,CAAC;AAEF,WAAO;YACC,KAAK;IACb,MAAM,cACL,eAAe,QAAQ,sBAAM,IAAI,MAAM,gBAAgB;AACxD,aAAS,YAAY;AACrB,UAAM;aACG;AACT,mBAAe,MAAM;;KAGvB;GAAC;GAAQ;GAAa;GAAyB;GAA4B,CAC3E;EA2EA,YAtEkB,YAClB,OACC,OACA,UAA6B,EAAE,KACT;GACtB,MAAM,EAAE,IAAI,YAAY,WAAW;GACnC,MAAM,mBAAmB,wBAAwB,GAAG;AAEpD,OAAI,CAAC,kBAAkB;IACtB,MAAM,yBAAyB,IAAI,MAAM,6BAA6B,CAAC;AACvE,aAAS,uBAAuB;AAChC,UAAM;;AAGP,OAAI,MAAM,WAAW,EACpB,QAAO,EAAE;AAGV,kBAAe,KAAK;AACpB,eAAY,EAAE;AACd,YAAS,KAAK;AAEd,OAAI;IAEH,MAAM,gBAAiB,OAAO,YAAoB;AAElD,QAAI,CAAC,eAAe,WACnB,OAAM,IAAI,MACT,eAAe,iBAAiB,+EAChC;IAGF,MAAM,UAAU,MAAM,cAAc,WAAW,OAAO;KACrD;KACA,aAAa,GAAW,cAAuB;AAC9C,kBAAY,EAAE;AACd,mBAAa,GAAG,UAAU;;KAE3B,CAAC;AAGF,gBAAY,kBAAkB,EAC7B,UAAU;KAAC;KAAY;KAAe;KAAiB,EACvD,CAAC;AAEF,gBAAY,IAAI;AAChB,WAAO;YACC,KAAK;IACb,MAAM,cACL,eAAe,QAAQ,sBAAM,IAAI,MAAM,gBAAgB;AACxD,aAAS,YAAY;AACrB,UAAM;aACG;AACT,mBAAe,MAAM;;KAGvB;GAAC;GAAQ;GAAa;GAAyB;GAA4B,CAC3E;EAcA;EACA;EACA;EACA,OAZa,kBAAkB;AAC/B,kBAAe,MAAM;AACrB,eAAY,EAAE;AACd,YAAS,KAAK;KACZ,EAAE,CAAC;EASL"}
|