@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,301 @@
|
|
|
1
|
+
import { useResolveText, useTranslation } from "../../i18n/hooks.mjs";
|
|
2
|
+
import { selectClient, useAdminStore } from "../../runtime/provider.mjs";
|
|
3
|
+
import { resolveIconElement } from "../component-renderer.mjs";
|
|
4
|
+
import { Button } from "../ui/button.mjs";
|
|
5
|
+
import { getAutoColumns } from "./field-utils.mjs";
|
|
6
|
+
import { useAdminConfig } from "../../hooks/use-admin-config.mjs";
|
|
7
|
+
import { SelectSingle } from "../primitives/select-single.mjs";
|
|
8
|
+
import { ResourceSheet } from "../sheets/resource-sheet.mjs";
|
|
9
|
+
import { LocaleBadge } from "./locale-badge.mjs";
|
|
10
|
+
import { RelationItemsDisplay } from "./relation/relation-items-display.mjs";
|
|
11
|
+
import { Icon } from "@iconify/react";
|
|
12
|
+
import { createQuestpieQueryOptions } from "@questpie/tanstack-query";
|
|
13
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
14
|
+
import * as React$1 from "react";
|
|
15
|
+
import { toast } from "sonner";
|
|
16
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
+
|
|
18
|
+
//#region src/client/components/fields/relation-picker.tsx
|
|
19
|
+
/**
|
|
20
|
+
* RelationPicker Component
|
|
21
|
+
*
|
|
22
|
+
* Multiple relation field (one-to-many, many-to-many) with:
|
|
23
|
+
* - Searchable select to add existing items
|
|
24
|
+
* - Plus button to create new related item (opens side sheet)
|
|
25
|
+
* - Edit button on each selected item (opens side sheet)
|
|
26
|
+
* - Remove button on each selected item
|
|
27
|
+
* - Optional drag-and-drop reordering
|
|
28
|
+
* - Multiple display modes (list, chips, table, cards, grid)
|
|
29
|
+
* - Responsive: Popover on desktop, Drawer on mobile
|
|
30
|
+
*/
|
|
31
|
+
function RelationPicker({ name, value = [], onChange, targetCollection, label, filter, required, disabled, readOnly, placeholder, error, localized, locale: localeProp, orderable = false, maxItems, display = "list", columns, fields, gridColumns, renderItem, renderOption }) {
|
|
32
|
+
const { t } = useTranslation();
|
|
33
|
+
const resolveText = useResolveText();
|
|
34
|
+
const resolvedLabel = label ? resolveText(label) : void 0;
|
|
35
|
+
const resolvedPlaceholder = placeholder ? resolveText(placeholder) : void 0;
|
|
36
|
+
const labelText = resolvedLabel || targetCollection;
|
|
37
|
+
const addLabel = t("relation.addItem", { name: labelText });
|
|
38
|
+
const noResultsLabel = t("relation.noResults", { name: labelText });
|
|
39
|
+
const emptyLabel = t("relation.noneSelected", { name: labelText });
|
|
40
|
+
const createLabel = t("relation.createNew", { name: labelText });
|
|
41
|
+
const locale = localeProp;
|
|
42
|
+
const [isSheetOpen, setIsSheetOpen] = React$1.useState(false);
|
|
43
|
+
const [editingItemId, setEditingItemId] = React$1.useState();
|
|
44
|
+
const { data: serverConfig } = useAdminConfig();
|
|
45
|
+
const targetConfig = serverConfig?.collections?.[targetCollection];
|
|
46
|
+
const collectionIconRef = targetConfig?.icon;
|
|
47
|
+
const displayColumns = React$1.useMemo(() => {
|
|
48
|
+
if (columns && columns.length > 0) return columns;
|
|
49
|
+
if (display === "table" && targetConfig) return getAutoColumns(targetConfig);
|
|
50
|
+
return ["_title"];
|
|
51
|
+
}, [
|
|
52
|
+
columns,
|
|
53
|
+
display,
|
|
54
|
+
targetConfig
|
|
55
|
+
]);
|
|
56
|
+
const selectedIds = React$1.useMemo(() => {
|
|
57
|
+
if (!value) return [];
|
|
58
|
+
if (Array.isArray(value)) return value;
|
|
59
|
+
return [value];
|
|
60
|
+
}, [value]);
|
|
61
|
+
const client = useAdminStore(selectClient);
|
|
62
|
+
const [fetchedItems, setFetchedItems] = React$1.useState(() => /* @__PURE__ */ new Map());
|
|
63
|
+
const [isLoadingItems, setIsLoadingItems] = React$1.useState(false);
|
|
64
|
+
const loadOptions = React$1.useCallback(async (search) => {
|
|
65
|
+
if (!client) return [];
|
|
66
|
+
try {
|
|
67
|
+
const options = { limit: 50 };
|
|
68
|
+
if (search) options.search = search;
|
|
69
|
+
if (filter) options.where = filter({});
|
|
70
|
+
const docs = (await client.collections[targetCollection].find(options))?.docs || [];
|
|
71
|
+
setFetchedItems((prev) => new Map([...prev, ...docs.map((doc) => [doc.id, doc])]));
|
|
72
|
+
return docs.filter((opt) => !selectedIds.includes(opt.id)).map((item) => ({
|
|
73
|
+
value: item.id,
|
|
74
|
+
label: renderOption ? String(renderOption(item)) : item._title || item.id || "",
|
|
75
|
+
icon: resolveIconElement(collectionIconRef, { className: "size-3.5 text-muted-foreground" })
|
|
76
|
+
}));
|
|
77
|
+
} catch (error$1) {
|
|
78
|
+
console.error("Failed to load relation options:", error$1);
|
|
79
|
+
toast.error("Failed to load options");
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
}, [
|
|
83
|
+
client,
|
|
84
|
+
targetCollection,
|
|
85
|
+
filter,
|
|
86
|
+
selectedIds,
|
|
87
|
+
renderOption,
|
|
88
|
+
collectionIconRef
|
|
89
|
+
]);
|
|
90
|
+
const queryClient = useQueryClient();
|
|
91
|
+
const queryOpts = React$1.useMemo(() => createQuestpieQueryOptions(client ?? {}, { keyPrefix: ["questpie", "collections"] }), [client]);
|
|
92
|
+
const refetch = React$1.useCallback(async () => {
|
|
93
|
+
setFetchedItems(/* @__PURE__ */ new Map());
|
|
94
|
+
queryClient.invalidateQueries({ queryKey: queryOpts.key([
|
|
95
|
+
"collections",
|
|
96
|
+
targetCollection,
|
|
97
|
+
"find"
|
|
98
|
+
]) });
|
|
99
|
+
selectedIds.forEach((id) => {
|
|
100
|
+
queryClient.invalidateQueries({ queryKey: queryOpts.key([
|
|
101
|
+
"collections",
|
|
102
|
+
targetCollection,
|
|
103
|
+
"findOne",
|
|
104
|
+
{ where: { id } }
|
|
105
|
+
]) });
|
|
106
|
+
});
|
|
107
|
+
}, [
|
|
108
|
+
queryClient,
|
|
109
|
+
queryOpts,
|
|
110
|
+
selectedIds,
|
|
111
|
+
targetCollection
|
|
112
|
+
]);
|
|
113
|
+
React$1.useEffect(() => {
|
|
114
|
+
if (!client || !selectedIds.length) {
|
|
115
|
+
setIsLoadingItems(false);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const missingIds = selectedIds.filter((id) => !fetchedItems.has(id));
|
|
119
|
+
if (missingIds.length === 0) {
|
|
120
|
+
setIsLoadingItems(false);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
setIsLoadingItems(true);
|
|
124
|
+
let cancelled = false;
|
|
125
|
+
(async () => {
|
|
126
|
+
try {
|
|
127
|
+
for (const id of missingIds) {
|
|
128
|
+
if (cancelled) return;
|
|
129
|
+
const response = await client.collections[targetCollection].findOne({ where: { id } });
|
|
130
|
+
if (!cancelled && response) setFetchedItems((prev) => new Map([...prev, [id, response]]));
|
|
131
|
+
}
|
|
132
|
+
} catch (error$1) {
|
|
133
|
+
console.error("Failed to fetch selected items:", error$1);
|
|
134
|
+
toast.error("Failed to load selected items");
|
|
135
|
+
} finally {
|
|
136
|
+
if (!cancelled) setIsLoadingItems(false);
|
|
137
|
+
}
|
|
138
|
+
})();
|
|
139
|
+
return () => {
|
|
140
|
+
cancelled = true;
|
|
141
|
+
};
|
|
142
|
+
}, [
|
|
143
|
+
client,
|
|
144
|
+
targetCollection,
|
|
145
|
+
selectedIds,
|
|
146
|
+
fetchedItems
|
|
147
|
+
]);
|
|
148
|
+
const selectedItems = React$1.useMemo(() => {
|
|
149
|
+
return selectedIds.map((id) => fetchedItems.get(id)).filter(Boolean);
|
|
150
|
+
}, [selectedIds, fetchedItems]);
|
|
151
|
+
const handleAdd = React$1.useCallback((itemId) => {
|
|
152
|
+
if (!itemId) return;
|
|
153
|
+
if (selectedIds.includes(itemId)) return;
|
|
154
|
+
if (maxItems && selectedIds.length >= maxItems) return;
|
|
155
|
+
onChange([...selectedIds, itemId]);
|
|
156
|
+
}, [
|
|
157
|
+
selectedIds,
|
|
158
|
+
maxItems,
|
|
159
|
+
onChange
|
|
160
|
+
]);
|
|
161
|
+
const handleRemove = React$1.useCallback((itemId) => {
|
|
162
|
+
onChange(selectedIds.filter((id) => id !== itemId));
|
|
163
|
+
}, [selectedIds, onChange]);
|
|
164
|
+
const handleOpenCreate = React$1.useCallback(() => {
|
|
165
|
+
setEditingItemId(void 0);
|
|
166
|
+
setIsSheetOpen(true);
|
|
167
|
+
}, []);
|
|
168
|
+
const handleOpenEdit = React$1.useCallback((itemId) => {
|
|
169
|
+
setEditingItemId(itemId);
|
|
170
|
+
setIsSheetOpen(true);
|
|
171
|
+
}, []);
|
|
172
|
+
const handleSheetSave = React$1.useCallback(async (result) => {
|
|
173
|
+
if (!editingItemId && result?.id) onChange([...selectedIds, result.id]);
|
|
174
|
+
await refetch();
|
|
175
|
+
}, [
|
|
176
|
+
editingItemId,
|
|
177
|
+
selectedIds,
|
|
178
|
+
onChange,
|
|
179
|
+
refetch
|
|
180
|
+
]);
|
|
181
|
+
const canAddMore = !maxItems || selectedIds.length < maxItems;
|
|
182
|
+
const displayActions = React$1.useMemo(() => ({
|
|
183
|
+
onEdit: !readOnly ? (item) => handleOpenEdit(item.id) : void 0,
|
|
184
|
+
onRemove: !readOnly && (!required || selectedIds.length > 1) ? (item) => handleRemove(item.id) : void 0
|
|
185
|
+
}), [
|
|
186
|
+
readOnly,
|
|
187
|
+
required,
|
|
188
|
+
selectedIds.length,
|
|
189
|
+
handleOpenEdit,
|
|
190
|
+
handleRemove
|
|
191
|
+
]);
|
|
192
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
193
|
+
className: "space-y-2",
|
|
194
|
+
children: [
|
|
195
|
+
label && /* @__PURE__ */ jsxs("div", {
|
|
196
|
+
className: "flex items-center gap-2",
|
|
197
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
198
|
+
htmlFor: name,
|
|
199
|
+
className: "text-sm font-medium flex items-center gap-1.5",
|
|
200
|
+
children: [
|
|
201
|
+
resolveIconElement(collectionIconRef, { className: "size-3.5 text-muted-foreground" }),
|
|
202
|
+
resolvedLabel,
|
|
203
|
+
required && /* @__PURE__ */ jsx("span", {
|
|
204
|
+
className: "text-destructive",
|
|
205
|
+
children: "*"
|
|
206
|
+
}),
|
|
207
|
+
maxItems && /* @__PURE__ */ jsxs("span", {
|
|
208
|
+
className: "ml-2 text-xs text-muted-foreground",
|
|
209
|
+
children: [
|
|
210
|
+
"(",
|
|
211
|
+
selectedIds.length,
|
|
212
|
+
"/",
|
|
213
|
+
maxItems,
|
|
214
|
+
")"
|
|
215
|
+
]
|
|
216
|
+
})
|
|
217
|
+
]
|
|
218
|
+
}), localized && /* @__PURE__ */ jsx(LocaleBadge, { locale: locale || "i18n" })]
|
|
219
|
+
}),
|
|
220
|
+
(selectedItems.length > 0 || isLoadingItems) && /* @__PURE__ */ jsx(RelationItemsDisplay, {
|
|
221
|
+
display,
|
|
222
|
+
items: selectedItems,
|
|
223
|
+
collection: targetCollection,
|
|
224
|
+
collectionIcon: collectionIconRef,
|
|
225
|
+
editable: !readOnly && !disabled,
|
|
226
|
+
orderable: orderable && !readOnly && !disabled,
|
|
227
|
+
columns: displayColumns,
|
|
228
|
+
fields,
|
|
229
|
+
gridColumns,
|
|
230
|
+
renderItem,
|
|
231
|
+
actions: displayActions,
|
|
232
|
+
collectionConfig: targetConfig,
|
|
233
|
+
isLoading: isLoadingItems,
|
|
234
|
+
loadingCount: selectedIds.length || 3
|
|
235
|
+
}),
|
|
236
|
+
!readOnly && canAddMore && /* @__PURE__ */ jsxs("div", {
|
|
237
|
+
className: "flex gap-2",
|
|
238
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
239
|
+
className: "flex-1",
|
|
240
|
+
children: /* @__PURE__ */ jsx(SelectSingle, {
|
|
241
|
+
value: null,
|
|
242
|
+
onChange: handleAdd,
|
|
243
|
+
loadOptions,
|
|
244
|
+
queryKey: (search) => queryOpts.key([
|
|
245
|
+
"collections",
|
|
246
|
+
targetCollection,
|
|
247
|
+
"find",
|
|
248
|
+
{
|
|
249
|
+
limit: 50,
|
|
250
|
+
search,
|
|
251
|
+
where: filter ? filter({}) : void 0,
|
|
252
|
+
selectedIds
|
|
253
|
+
}
|
|
254
|
+
]),
|
|
255
|
+
prefetchOnMount: true,
|
|
256
|
+
placeholder: resolvedPlaceholder || `${addLabel}...`,
|
|
257
|
+
disabled,
|
|
258
|
+
clearable: false,
|
|
259
|
+
emptyMessage: noResultsLabel,
|
|
260
|
+
drawerTitle: addLabel
|
|
261
|
+
})
|
|
262
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
263
|
+
type: "button",
|
|
264
|
+
variant: "outline",
|
|
265
|
+
size: "icon",
|
|
266
|
+
onClick: handleOpenCreate,
|
|
267
|
+
disabled,
|
|
268
|
+
title: createLabel,
|
|
269
|
+
"aria-label": createLabel,
|
|
270
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
271
|
+
icon: "ph:plus",
|
|
272
|
+
className: "h-4 w-4"
|
|
273
|
+
})
|
|
274
|
+
})]
|
|
275
|
+
}),
|
|
276
|
+
selectedIds.length === 0 && !isLoadingItems && /* @__PURE__ */ jsx("div", {
|
|
277
|
+
className: "rounded-lg border border-dashed p-4 text-center",
|
|
278
|
+
children: /* @__PURE__ */ jsx("p", {
|
|
279
|
+
className: "text-sm text-muted-foreground",
|
|
280
|
+
children: resolvedPlaceholder || emptyLabel
|
|
281
|
+
})
|
|
282
|
+
}),
|
|
283
|
+
error && /* @__PURE__ */ jsx("p", {
|
|
284
|
+
className: "text-sm text-destructive",
|
|
285
|
+
children: error
|
|
286
|
+
}),
|
|
287
|
+
/* @__PURE__ */ jsx(ResourceSheet, {
|
|
288
|
+
type: "collection",
|
|
289
|
+
collection: targetCollection,
|
|
290
|
+
itemId: editingItemId,
|
|
291
|
+
open: isSheetOpen,
|
|
292
|
+
onOpenChange: setIsSheetOpen,
|
|
293
|
+
onSave: handleSheetSave
|
|
294
|
+
})
|
|
295
|
+
]
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
//#endregion
|
|
300
|
+
export { RelationPicker };
|
|
301
|
+
//# sourceMappingURL=relation-picker.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relation-picker.mjs","names":["React","options: any","error"],"sources":["../../../../src/client/components/fields/relation-picker.tsx"],"sourcesContent":["/**\n * RelationPicker Component\n *\n * Multiple relation field (one-to-many, many-to-many) with:\n * - Searchable select to add existing items\n * - Plus button to create new related item (opens side sheet)\n * - Edit button on each selected item (opens side sheet)\n * - Remove button on each selected item\n * - Optional drag-and-drop reordering\n * - Multiple display modes (list, chips, table, cards, grid)\n * - Responsive: Popover on desktop, Drawer on mobile\n */\n\nimport { Icon } from \"@iconify/react\";\nimport { createQuestpieQueryOptions } from \"@questpie/tanstack-query\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport type { Questpie } from \"questpie\";\nimport * as React from \"react\";\nimport { toast } from \"sonner\";\nimport { useAdminConfig } from \"../../hooks/use-admin-config\";\nimport { useResolveText, useTranslation } from \"../../i18n/hooks\";\nimport { selectClient, useAdminStore } from \"../../runtime\";\nimport { resolveIconElement } from \"../component-renderer\";\nimport { SelectSingle } from \"../primitives/select-single\";\nimport type { SelectOption } from \"../primitives/types\";\nimport { ResourceSheet } from \"../sheets/resource-sheet\";\nimport { Button } from \"../ui/button\";\nimport { getAutoColumns } from \"./field-utils\";\nimport { LocaleBadge } from \"./locale-badge\";\nimport {\n\ttype RelationDisplayFields,\n\ttype RelationDisplayMode,\n\tRelationItemsDisplay,\n} from \"./relation\";\n\nexport interface RelationPickerProps<_T extends Questpie<any>> {\n\t/**\n\t * Field name\n\t */\n\tname: string;\n\n\t/**\n\t * Current value (array of IDs of related items)\n\t */\n\tvalue?: string[] | null;\n\n\t/**\n\t * Change handler\n\t */\n\tonChange: (value: string[]) => void;\n\n\t/**\n\t * Target collection name\n\t */\n\ttargetCollection: string;\n\n\t/**\n\t * Label for the field\n\t */\n\tlabel?: string;\n\n\t/**\n\t * Localized field\n\t */\n\tlocalized?: boolean;\n\n\t/**\n\t * Active locale\n\t */\n\tlocale?: string;\n\n\t/**\n\t * Filter options based on form values\n\t */\n\tfilter?: (formValues: any) => any;\n\n\t/**\n\t * Is the field required\n\t */\n\trequired?: boolean;\n\n\t/**\n\t * Is the field disabled\n\t */\n\tdisabled?: boolean;\n\n\t/**\n\t * Is the field readonly\n\t */\n\treadOnly?: boolean;\n\n\t/**\n\t * Placeholder text\n\t */\n\tplaceholder?: string;\n\n\t/**\n\t * Error message\n\t */\n\terror?: string;\n\n\t/**\n\t * Enable drag-and-drop reordering\n\t */\n\torderable?: boolean;\n\n\t/**\n\t * Maximum number of items\n\t */\n\tmaxItems?: number;\n\n\t/**\n\t * Display mode for selected items\n\t * @default \"list\"\n\t */\n\tdisplay?: RelationDisplayMode;\n\n\t/**\n\t * Columns to show in table display mode\n\t */\n\tcolumns?: string[];\n\n\t/**\n\t * Field mapping for cards/grid display modes\n\t */\n\tfields?: RelationDisplayFields;\n\n\t/**\n\t * Number of columns for grid/cards layout\n\t */\n\tgridColumns?: 1 | 2 | 3 | 4;\n\n\t/**\n\t * Custom render function for selected items (only used in list mode)\n\t */\n\trenderItem?: (item: any, index: number) => React.ReactNode;\n\n\t/**\n\t * Custom render function for dropdown options\n\t */\n\trenderOption?: (item: any) => React.ReactNode;\n}\n\nexport function RelationPicker<T extends Questpie<any>>({\n\tname,\n\tvalue = [],\n\tonChange,\n\ttargetCollection,\n\tlabel,\n\tfilter,\n\trequired,\n\tdisabled,\n\treadOnly,\n\tplaceholder,\n\terror,\n\tlocalized,\n\tlocale: localeProp,\n\torderable = false,\n\tmaxItems,\n\tdisplay = \"list\",\n\tcolumns,\n\tfields,\n\tgridColumns,\n\trenderItem,\n\trenderOption,\n}: RelationPickerProps<T>) {\n\tconst { t } = useTranslation();\n\tconst resolveText = useResolveText();\n\tconst resolvedLabel = label ? resolveText(label) : undefined;\n\tconst resolvedPlaceholder = placeholder\n\t\t? resolveText(placeholder)\n\t\t: undefined;\n\tconst labelText = resolvedLabel || targetCollection;\n\tconst addLabel = t(\"relation.addItem\", { name: labelText });\n\tconst noResultsLabel = t(\"relation.noResults\", { name: labelText });\n\tconst emptyLabel = t(\"relation.noneSelected\", { name: labelText });\n\tconst createLabel = t(\"relation.createNew\", { name: labelText });\n\tconst locale = localeProp;\n\tconst [isSheetOpen, setIsSheetOpen] = React.useState(false);\n\tconst [editingItemId, setEditingItemId] = React.useState<\n\t\tstring | undefined\n\t>();\n\n\t// Get admin config for target collection from server\n\tconst { data: serverConfig } = useAdminConfig();\n\tconst targetConfig = serverConfig?.collections?.[targetCollection];\n\tconst collectionIconRef = (targetConfig as any)?.icon;\n\tconst displayColumns = React.useMemo(() => {\n\t\tif (columns && columns.length > 0) return columns;\n\t\tif (display === \"table\" && targetConfig) {\n\t\t\treturn getAutoColumns(targetConfig);\n\t\t}\n\t\treturn [\"_title\"];\n\t}, [columns, display, targetConfig]);\n\n\t// Normalize value to array (handles prefill with single string ID)\n\tconst selectedIds = React.useMemo(() => {\n\t\tif (!value) return [];\n\t\tif (Array.isArray(value)) return value;\n\t\t// Single string ID (from prefill) - convert to array\n\t\treturn [value];\n\t}, [value]);\n\tconst client = useAdminStore(selectClient);\n\n\t// Keep track of fetched items for display\n\t// Using lazy init to avoid creating new Map on every render\n\tconst [fetchedItems, setFetchedItems] = React.useState<Map<string, any>>(\n\t\t() => new Map(),\n\t);\n\n\t// Track loading state for items\n\tconst [isLoadingItems, setIsLoadingItems] = React.useState(false);\n\n\t// Load options from server with search\n\tconst loadOptions = React.useCallback(\n\t\tasync (search: string): Promise<SelectOption<string>[]> => {\n\t\t\tif (!client) return [];\n\n\t\t\ttry {\n\t\t\t\tconst options: any = {\n\t\t\t\t\tlimit: 50,\n\t\t\t\t};\n\n\t\t\t\t// Add search filter for _title\n\t\t\t\tif (search) {\n\t\t\t\t\toptions.search = search;\n\t\t\t\t}\n\n\t\t\t\t// Add custom filter if provided\n\t\t\t\tif (filter) {\n\t\t\t\t\toptions.where = filter({});\n\t\t\t\t}\n\n\t\t\t\tconst response = await (client as any).collections[\n\t\t\t\t\ttargetCollection\n\t\t\t\t].find(options);\n\t\t\t\tconst docs = response?.docs || [];\n\n\t\t\t\t// Immutable update - create new Map with spread to avoid mutations\n\t\t\t\tsetFetchedItems(\n\t\t\t\t\t(prev) =>\n\t\t\t\t\t\tnew Map([\n\t\t\t\t\t\t\t...prev,\n\t\t\t\t\t\t\t...docs.map((doc: any) => [doc.id, doc] as const),\n\t\t\t\t\t\t]),\n\t\t\t\t);\n\n\t\t\t\t// Filter out already selected items and transform to SelectOption format\n\t\t\t\treturn docs\n\t\t\t\t\t.filter((opt: any) => !selectedIds.includes(opt.id))\n\t\t\t\t\t.map((item: any) => ({\n\t\t\t\t\t\tvalue: item.id,\n\t\t\t\t\t\tlabel: renderOption\n\t\t\t\t\t\t\t? String(renderOption(item))\n\t\t\t\t\t\t\t: item._title || item.id || \"\",\n\t\t\t\t\t\ticon: resolveIconElement(collectionIconRef, {\n\t\t\t\t\t\t\tclassName: \"size-3.5 text-muted-foreground\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t}));\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(\"Failed to load relation options:\", error);\n\t\t\t\ttoast.error(\"Failed to load options\");\n\t\t\t\treturn [];\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tclient,\n\t\t\ttargetCollection,\n\t\t\tfilter,\n\t\t\tselectedIds,\n\t\t\trenderOption,\n\t\t\tcollectionIconRef,\n\t\t],\n\t);\n\n\t// Refetch for mutations (after create/update)\n\tconst queryClient = useQueryClient();\n\tconst queryOpts = React.useMemo(\n\t\t() =>\n\t\t\tcreateQuestpieQueryOptions(\n\t\t\t\t(client ?? {}) as any,\n\t\t\t\t{\n\t\t\t\t\tkeyPrefix: [\"questpie\", \"collections\"],\n\t\t\t\t} as any,\n\t\t\t),\n\t\t[client],\n\t);\n\n\tconst refetch = React.useCallback(async () => {\n\t\t// Clear cached items to force refresh\n\t\tsetFetchedItems(new Map());\n\t\tqueryClient.invalidateQueries({\n\t\t\tqueryKey: queryOpts.key([\"collections\", targetCollection, \"find\"]),\n\t\t});\n\t\tselectedIds.forEach((id) => {\n\t\t\tqueryClient.invalidateQueries({\n\t\t\t\tqueryKey: queryOpts.key([\n\t\t\t\t\t\"collections\",\n\t\t\t\t\ttargetCollection,\n\t\t\t\t\t\"findOne\",\n\t\t\t\t\t{ where: { id } },\n\t\t\t\t]),\n\t\t\t});\n\t\t});\n\t}, [queryClient, queryOpts, selectedIds, targetCollection]);\n\n\t// Fetch selected items on mount for display\n\tReact.useEffect(() => {\n\t\tif (!client || !selectedIds.length) {\n\t\t\tsetIsLoadingItems(false);\n\t\t\treturn;\n\t\t}\n\n\t\t// Fetch any selected items that we don't have in cache\n\t\tconst missingIds = selectedIds.filter((id) => !fetchedItems.has(id));\n\t\tif (missingIds.length === 0) {\n\t\t\tsetIsLoadingItems(false);\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsLoadingItems(true);\n\n\t\tlet cancelled = false;\n\n\t\t(async () => {\n\t\t\ttry {\n\t\t\t\tfor (const id of missingIds) {\n\t\t\t\t\tif (cancelled) return;\n\t\t\t\t\tconst response = await (client as any).collections[\n\t\t\t\t\t\ttargetCollection\n\t\t\t\t\t].findOne({ where: { id } });\n\t\t\t\t\tif (!cancelled && response) {\n\t\t\t\t\t\t// Immutable update - spread prev and add new entry\n\t\t\t\t\t\tsetFetchedItems((prev) => new Map([...prev, [id, response]]));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(\"Failed to fetch selected items:\", error);\n\t\t\t\ttoast.error(\"Failed to load selected items\");\n\t\t\t} finally {\n\t\t\t\tif (!cancelled) {\n\t\t\t\t\tsetIsLoadingItems(false);\n\t\t\t\t}\n\t\t\t}\n\t\t})();\n\n\t\treturn () => {\n\t\t\tcancelled = true;\n\t\t};\n\t}, [client, targetCollection, selectedIds, fetchedItems]);\n\n\t// Get selected items from cache\n\tconst selectedItems = React.useMemo(() => {\n\t\treturn selectedIds\n\t\t\t.map((id: string) => fetchedItems.get(id))\n\t\t\t.filter(Boolean);\n\t}, [selectedIds, fetchedItems]);\n\n\tconst handleAdd = React.useCallback(\n\t\t(itemId: string | null) => {\n\t\t\tif (!itemId) return;\n\t\t\tif (selectedIds.includes(itemId)) return;\n\t\t\tif (maxItems && selectedIds.length >= maxItems) return;\n\t\t\tonChange([...selectedIds, itemId]);\n\t\t},\n\t\t[selectedIds, maxItems, onChange],\n\t);\n\n\tconst handleRemove = React.useCallback(\n\t\t(itemId: string) => {\n\t\t\tonChange(selectedIds.filter((id) => id !== itemId));\n\t\t},\n\t\t[selectedIds, onChange],\n\t);\n\n\tconst handleOpenCreate = React.useCallback(() => {\n\t\tsetEditingItemId(undefined);\n\t\tsetIsSheetOpen(true);\n\t}, []);\n\n\tconst handleOpenEdit = React.useCallback((itemId: string) => {\n\t\tsetEditingItemId(itemId);\n\t\tsetIsSheetOpen(true);\n\t}, []);\n\n\t// Handle save from ResourceSheet\n\tconst handleSheetSave = React.useCallback(\n\t\tasync (result: any) => {\n\t\t\t// Add newly created item to selection (create mode = no editingItemId)\n\t\t\tif (!editingItemId && result?.id) {\n\t\t\t\tonChange([...selectedIds, result.id]);\n\t\t\t}\n\t\t\tawait refetch();\n\t\t},\n\t\t[editingItemId, selectedIds, onChange, refetch],\n\t);\n\n\tconst canAddMore = !maxItems || selectedIds.length < maxItems;\n\n\t// Memoize actions to prevent infinite re-renders\n\tconst displayActions = React.useMemo(\n\t\t() => ({\n\t\t\tonEdit: !readOnly ? (item: any) => handleOpenEdit(item.id) : undefined,\n\t\t\tonRemove:\n\t\t\t\t!readOnly && (!required || selectedIds.length > 1)\n\t\t\t\t\t? (item: any) => handleRemove(item.id)\n\t\t\t\t\t: undefined,\n\t\t}),\n\t\t[readOnly, required, selectedIds.length, handleOpenEdit, handleRemove],\n\t);\n\n\treturn (\n\t\t<div className=\"space-y-2\">\n\t\t\t{label && (\n\t\t\t\t<div className=\"flex items-center gap-2\">\n\t\t\t\t\t<label\n\t\t\t\t\t\thtmlFor={name}\n\t\t\t\t\t\tclassName=\"text-sm font-medium flex items-center gap-1.5\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{resolveIconElement(collectionIconRef, {\n\t\t\t\t\t\t\tclassName: \"size-3.5 text-muted-foreground\",\n\t\t\t\t\t\t})}\n\t\t\t\t\t\t{resolvedLabel}\n\t\t\t\t\t\t{required && <span className=\"text-destructive\">*</span>}\n\t\t\t\t\t\t{maxItems && (\n\t\t\t\t\t\t\t<span className=\"ml-2 text-xs text-muted-foreground\">\n\t\t\t\t\t\t\t\t({selectedIds.length}/{maxItems})\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</label>\n\t\t\t\t\t{localized && <LocaleBadge locale={locale || \"i18n\"} />}\n\t\t\t\t</div>\n\t\t\t)}\n\n\t\t\t{/* Selected Items Display */}\n\t\t\t{(selectedItems.length > 0 || isLoadingItems) && (\n\t\t\t\t<RelationItemsDisplay\n\t\t\t\t\tdisplay={display}\n\t\t\t\t\titems={selectedItems}\n\t\t\t\t\tcollection={targetCollection}\n\t\t\t\t\tcollectionIcon={collectionIconRef}\n\t\t\t\t\teditable={!readOnly && !disabled}\n\t\t\t\t\torderable={orderable && !readOnly && !disabled}\n\t\t\t\t\tcolumns={displayColumns}\n\t\t\t\t\tfields={fields}\n\t\t\t\t\tgridColumns={gridColumns}\n\t\t\t\t\trenderItem={renderItem}\n\t\t\t\t\tactions={displayActions}\n\t\t\t\t\tcollectionConfig={targetConfig as any}\n\t\t\t\t\tisLoading={isLoadingItems}\n\t\t\t\t\tloadingCount={selectedIds.length || 3}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{/* Add More */}\n\t\t\t{!readOnly && canAddMore && (\n\t\t\t\t<div className=\"flex gap-2\">\n\t\t\t\t\t{/* Searchable Select to add existing items - uses server-side search */}\n\t\t\t\t\t<div className=\"flex-1\">\n\t\t\t\t\t\t<SelectSingle\n\t\t\t\t\t\t\tvalue={null}\n\t\t\t\t\t\t\tonChange={handleAdd}\n\t\t\t\t\t\t\tloadOptions={loadOptions}\n\t\t\t\t\t\t\tqueryKey={(search) =>\n\t\t\t\t\t\t\t\tqueryOpts.key([\n\t\t\t\t\t\t\t\t\t\"collections\",\n\t\t\t\t\t\t\t\t\ttargetCollection,\n\t\t\t\t\t\t\t\t\t\"find\",\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tlimit: 50,\n\t\t\t\t\t\t\t\t\t\tsearch,\n\t\t\t\t\t\t\t\t\t\twhere: filter ? filter({}) : undefined,\n\t\t\t\t\t\t\t\t\t\tselectedIds,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tprefetchOnMount\n\t\t\t\t\t\t\tplaceholder={resolvedPlaceholder || `${addLabel}...`}\n\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\tclearable={false}\n\t\t\t\t\t\t\temptyMessage={noResultsLabel}\n\t\t\t\t\t\t\tdrawerTitle={addLabel}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t{/* Create Button */}\n\t\t\t\t\t<Button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\tsize=\"icon\"\n\t\t\t\t\t\tonClick={handleOpenCreate}\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\ttitle={createLabel}\n\t\t\t\t\t\taria-label={createLabel}\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon=\"ph:plus\" className=\"h-4 w-4\" />\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t)}\n\n\t\t\t{/* Empty State - only show when not loading */}\n\t\t\t{selectedIds.length === 0 && !isLoadingItems && (\n\t\t\t\t<div className=\"rounded-lg border border-dashed p-4 text-center\">\n\t\t\t\t\t<p className=\"text-sm text-muted-foreground\">\n\t\t\t\t\t\t{resolvedPlaceholder || emptyLabel}\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t)}\n\n\t\t\t{/* Error message */}\n\t\t\t{error && <p className=\"text-sm text-destructive\">{error}</p>}\n\n\t\t\t{/* Side Sheet for Create/Edit */}\n\t\t\t<ResourceSheet\n\t\t\t\ttype=\"collection\"\n\t\t\t\tcollection={targetCollection}\n\t\t\t\titemId={editingItemId}\n\t\t\t\topen={isSheetOpen}\n\t\t\t\tonOpenChange={setIsSheetOpen}\n\t\t\t\tonSave={handleSheetSave}\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { useResolveText, useTranslation } from "../../i18n/hooks.mjs";
|
|
2
|
+
import { cn } from "../../lib/utils.mjs";
|
|
3
|
+
import { selectClient, useAdminStore } from "../../runtime/provider.mjs";
|
|
4
|
+
import { resolveIconElement } from "../component-renderer.mjs";
|
|
5
|
+
import { Button } from "../ui/button.mjs";
|
|
6
|
+
import { useAdminConfig } from "../../hooks/use-admin-config.mjs";
|
|
7
|
+
import { useCollectionItem } from "../../hooks/use-collection.mjs";
|
|
8
|
+
import { SelectSingle } from "../primitives/select-single.mjs";
|
|
9
|
+
import { ResourceSheet } from "../sheets/resource-sheet.mjs";
|
|
10
|
+
import { LocaleBadge } from "./locale-badge.mjs";
|
|
11
|
+
import { Icon } from "@iconify/react";
|
|
12
|
+
import { createQuestpieQueryOptions } from "@questpie/tanstack-query";
|
|
13
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
14
|
+
import * as React$1 from "react";
|
|
15
|
+
import { toast } from "sonner";
|
|
16
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
+
|
|
18
|
+
//#region src/client/components/fields/relation-select.tsx
|
|
19
|
+
/**
|
|
20
|
+
* RelationSelect Component
|
|
21
|
+
*
|
|
22
|
+
* Single relation field (one-to-one) with:
|
|
23
|
+
* - Searchable select dropdown to choose existing item
|
|
24
|
+
* - Plus button to create new related item (opens side sheet)
|
|
25
|
+
* - Edit button to modify selected item (opens side sheet)
|
|
26
|
+
* - Responsive: Popover on desktop, Drawer on mobile
|
|
27
|
+
*/
|
|
28
|
+
function RelationSelect({ name, value, onChange, targetCollection, label, filter, required, disabled, readOnly, placeholder, error, localized, locale, renderOption, renderValue }) {
|
|
29
|
+
const { t } = useTranslation();
|
|
30
|
+
const resolveText = useResolveText();
|
|
31
|
+
const resolvedLabel = label ? resolveText(label) : void 0;
|
|
32
|
+
const resolvedPlaceholder = placeholder ? resolveText(placeholder) : void 0;
|
|
33
|
+
const labelText = resolvedLabel || targetCollection;
|
|
34
|
+
const selectLabel = t("relation.select", { name: labelText });
|
|
35
|
+
const noResultsLabel = t("relation.noResults", { name: labelText });
|
|
36
|
+
const createLabel = t("relation.createNew", { name: labelText });
|
|
37
|
+
const [isSheetOpen, setIsSheetOpen] = React$1.useState(false);
|
|
38
|
+
const [editingItemId, setEditingItemId] = React$1.useState();
|
|
39
|
+
const { data: serverConfig } = useAdminConfig();
|
|
40
|
+
const client = useAdminStore(selectClient);
|
|
41
|
+
const collectionIconRef = (serverConfig?.collections?.[targetCollection])?.icon;
|
|
42
|
+
const loadOptions = React$1.useCallback(async (search) => {
|
|
43
|
+
if (!client) return [];
|
|
44
|
+
try {
|
|
45
|
+
const options = {
|
|
46
|
+
limit: 50,
|
|
47
|
+
locale
|
|
48
|
+
};
|
|
49
|
+
if (search) options.search = search;
|
|
50
|
+
if (filter) options.where = filter({});
|
|
51
|
+
return ((await client.collections[targetCollection].find(options))?.docs || []).map((item) => ({
|
|
52
|
+
value: item.id,
|
|
53
|
+
label: renderOption ? String(renderOption(item)) : item._title || item.id || "",
|
|
54
|
+
icon: resolveIconElement(collectionIconRef, { className: "size-3.5 text-muted-foreground" })
|
|
55
|
+
}));
|
|
56
|
+
} catch (error$1) {
|
|
57
|
+
console.error("Failed to load relation options:", error$1);
|
|
58
|
+
toast.error("Failed to load options");
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
}, [
|
|
62
|
+
client,
|
|
63
|
+
targetCollection,
|
|
64
|
+
filter,
|
|
65
|
+
renderOption,
|
|
66
|
+
collectionIconRef,
|
|
67
|
+
locale
|
|
68
|
+
]);
|
|
69
|
+
const queryClient = useQueryClient();
|
|
70
|
+
const queryOpts = React$1.useMemo(() => createQuestpieQueryOptions(client ?? {}, { keyPrefix: ["questpie", "collections"] }), [client]);
|
|
71
|
+
const refetch = React$1.useCallback(async () => {
|
|
72
|
+
queryClient.invalidateQueries({ queryKey: queryOpts.key([
|
|
73
|
+
"collections",
|
|
74
|
+
targetCollection,
|
|
75
|
+
"find"
|
|
76
|
+
]) });
|
|
77
|
+
queryClient.invalidateQueries({ queryKey: queryOpts.key([
|
|
78
|
+
"collections",
|
|
79
|
+
targetCollection,
|
|
80
|
+
"findOne",
|
|
81
|
+
{ where: { id: value || "" } }
|
|
82
|
+
]) });
|
|
83
|
+
}, [
|
|
84
|
+
queryClient,
|
|
85
|
+
queryOpts,
|
|
86
|
+
targetCollection,
|
|
87
|
+
value
|
|
88
|
+
]);
|
|
89
|
+
const { data: selectedItem } = useCollectionItem(targetCollection, value || "", void 0, { enabled: !!value });
|
|
90
|
+
const selectedOptions = React$1.useMemo(() => {
|
|
91
|
+
if (!selectedItem) return [];
|
|
92
|
+
return [{
|
|
93
|
+
value: selectedItem.id,
|
|
94
|
+
label: renderValue ? String(renderValue(selectedItem)) : selectedItem._title || selectedItem.id || "",
|
|
95
|
+
icon: resolveIconElement(collectionIconRef, { className: "size-3.5 text-muted-foreground" })
|
|
96
|
+
}];
|
|
97
|
+
}, [
|
|
98
|
+
selectedItem,
|
|
99
|
+
renderValue,
|
|
100
|
+
collectionIconRef
|
|
101
|
+
]);
|
|
102
|
+
const handleOpenCreate = () => {
|
|
103
|
+
setEditingItemId(void 0);
|
|
104
|
+
setIsSheetOpen(true);
|
|
105
|
+
};
|
|
106
|
+
const handleOpenEdit = () => {
|
|
107
|
+
if (!value) return;
|
|
108
|
+
setEditingItemId(value);
|
|
109
|
+
setIsSheetOpen(true);
|
|
110
|
+
};
|
|
111
|
+
const handleValueChange = (newValue) => {
|
|
112
|
+
onChange(newValue);
|
|
113
|
+
};
|
|
114
|
+
const handleSheetSave = React$1.useCallback(async (result) => {
|
|
115
|
+
if (!editingItemId && result?.id) onChange(result.id);
|
|
116
|
+
await refetch();
|
|
117
|
+
}, [
|
|
118
|
+
editingItemId,
|
|
119
|
+
onChange,
|
|
120
|
+
refetch
|
|
121
|
+
]);
|
|
122
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
123
|
+
className: "space-y-2",
|
|
124
|
+
children: [
|
|
125
|
+
label && /* @__PURE__ */ jsxs("div", {
|
|
126
|
+
className: "flex items-center gap-2",
|
|
127
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
128
|
+
htmlFor: name,
|
|
129
|
+
className: "text-sm font-medium flex items-center gap-1.5",
|
|
130
|
+
children: [
|
|
131
|
+
resolveIconElement(collectionIconRef, { className: "size-3.5 text-muted-foreground" }),
|
|
132
|
+
resolvedLabel,
|
|
133
|
+
required && /* @__PURE__ */ jsx("span", {
|
|
134
|
+
className: "text-destructive",
|
|
135
|
+
children: "*"
|
|
136
|
+
})
|
|
137
|
+
]
|
|
138
|
+
}), localized && /* @__PURE__ */ jsx(LocaleBadge, { locale: locale || "i18n" })]
|
|
139
|
+
}),
|
|
140
|
+
/* @__PURE__ */ jsxs("div", {
|
|
141
|
+
className: "flex items-stretch gap-0",
|
|
142
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
143
|
+
className: "min-w-0 flex-1",
|
|
144
|
+
children: /* @__PURE__ */ jsx(SelectSingle, {
|
|
145
|
+
id: name,
|
|
146
|
+
value: value || null,
|
|
147
|
+
onChange: handleValueChange,
|
|
148
|
+
options: selectedOptions,
|
|
149
|
+
loadOptions,
|
|
150
|
+
queryKey: (search) => queryOpts.key([
|
|
151
|
+
"collections",
|
|
152
|
+
targetCollection,
|
|
153
|
+
"find",
|
|
154
|
+
{
|
|
155
|
+
limit: 50,
|
|
156
|
+
locale,
|
|
157
|
+
search,
|
|
158
|
+
where: filter ? filter({}) : void 0
|
|
159
|
+
}
|
|
160
|
+
]),
|
|
161
|
+
prefetchOnMount: true,
|
|
162
|
+
placeholder: resolvedPlaceholder || `${selectLabel}...`,
|
|
163
|
+
disabled: disabled || readOnly,
|
|
164
|
+
clearable: !required,
|
|
165
|
+
emptyMessage: noResultsLabel,
|
|
166
|
+
drawerTitle: selectLabel,
|
|
167
|
+
className: cn(!readOnly && "rounded-r-none", error && "border-destructive"),
|
|
168
|
+
"aria-invalid": !!error
|
|
169
|
+
})
|
|
170
|
+
}), !readOnly && /* @__PURE__ */ jsxs("div", {
|
|
171
|
+
className: "flex",
|
|
172
|
+
children: [value && /* @__PURE__ */ jsx(Button, {
|
|
173
|
+
type: "button",
|
|
174
|
+
variant: "outline",
|
|
175
|
+
size: "icon",
|
|
176
|
+
onClick: handleOpenEdit,
|
|
177
|
+
disabled,
|
|
178
|
+
title: t("collection.edit", { name: labelText }),
|
|
179
|
+
"aria-label": t("collection.edit", { name: labelText }),
|
|
180
|
+
className: "rounded-none border-l-0",
|
|
181
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
182
|
+
icon: "ph:pencil",
|
|
183
|
+
className: "h-4 w-4"
|
|
184
|
+
})
|
|
185
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
186
|
+
type: "button",
|
|
187
|
+
variant: "outline",
|
|
188
|
+
size: "icon",
|
|
189
|
+
onClick: handleOpenCreate,
|
|
190
|
+
disabled,
|
|
191
|
+
title: createLabel,
|
|
192
|
+
"aria-label": createLabel,
|
|
193
|
+
className: "border-l-0 rounded-l-none",
|
|
194
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
195
|
+
icon: "ph:plus",
|
|
196
|
+
className: "h-4 w-4"
|
|
197
|
+
})
|
|
198
|
+
})]
|
|
199
|
+
})]
|
|
200
|
+
}),
|
|
201
|
+
error && /* @__PURE__ */ jsx("p", {
|
|
202
|
+
className: "text-sm text-destructive",
|
|
203
|
+
children: error
|
|
204
|
+
}),
|
|
205
|
+
/* @__PURE__ */ jsx(ResourceSheet, {
|
|
206
|
+
type: "collection",
|
|
207
|
+
collection: targetCollection,
|
|
208
|
+
itemId: editingItemId,
|
|
209
|
+
open: isSheetOpen,
|
|
210
|
+
onOpenChange: setIsSheetOpen,
|
|
211
|
+
onSave: handleSheetSave
|
|
212
|
+
})
|
|
213
|
+
]
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
//#endregion
|
|
218
|
+
export { RelationSelect };
|
|
219
|
+
//# sourceMappingURL=relation-select.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relation-select.mjs","names":["React","options: any","error"],"sources":["../../../../src/client/components/fields/relation-select.tsx"],"sourcesContent":["/**\n * RelationSelect Component\n *\n * Single relation field (one-to-one) with:\n * - Searchable select dropdown to choose existing item\n * - Plus button to create new related item (opens side sheet)\n * - Edit button to modify selected item (opens side sheet)\n * - Responsive: Popover on desktop, Drawer on mobile\n */\n\nimport { Icon } from \"@iconify/react\";\nimport { createQuestpieQueryOptions } from \"@questpie/tanstack-query\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport type { Questpie } from \"questpie\";\nimport * as React from \"react\";\nimport { toast } from \"sonner\";\nimport { useAdminConfig } from \"../../hooks/use-admin-config\";\nimport { useCollectionItem } from \"../../hooks/use-collection\";\nimport { useResolveText, useTranslation } from \"../../i18n/hooks\";\nimport { cn } from \"../../lib/utils\";\nimport { selectClient, useAdminStore } from \"../../runtime\";\nimport { resolveIconElement } from \"../component-renderer\";\nimport { SelectSingle } from \"../primitives/select-single\";\nimport type { SelectOption } from \"../primitives/types\";\nimport { ResourceSheet } from \"../sheets/resource-sheet\";\nimport { Button } from \"../ui/button\";\nimport { LocaleBadge } from \"./locale-badge\";\n\nexport interface RelationSelectProps<_T extends Questpie<any>> {\n\t/**\n\t * Field name\n\t */\n\tname: string;\n\n\t/**\n\t * Current value (ID of related item)\n\t */\n\tvalue?: string | null;\n\n\t/**\n\t * Change handler\n\t */\n\tonChange: (value: string | null) => void;\n\n\t/**\n\t * Target collection name\n\t */\n\ttargetCollection: string;\n\n\t/**\n\t * Label for the field\n\t */\n\tlabel?: string;\n\n\t/**\n\t * Localized field\n\t */\n\tlocalized?: boolean;\n\n\t/**\n\t * Active locale\n\t */\n\tlocale?: string;\n\n\t/**\n\t * Filter options based on form values\n\t */\n\tfilter?: (formValues: any) => any;\n\n\t/**\n\t * Is the field required\n\t */\n\trequired?: boolean;\n\n\t/**\n\t * Is the field disabled\n\t */\n\tdisabled?: boolean;\n\n\t/**\n\t * Is the field readonly\n\t */\n\treadOnly?: boolean;\n\n\t/**\n\t * Placeholder text\n\t */\n\tplaceholder?: string;\n\n\t/**\n\t * Error message\n\t */\n\terror?: string;\n\n\t/**\n\t * Custom render function for dropdown options\n\t */\n\trenderOption?: (item: any) => React.ReactNode;\n\n\t/**\n\t * Custom render function for selected value\n\t */\n\trenderValue?: (item: any) => React.ReactNode;\n}\n\nexport function RelationSelect<T extends Questpie<any>>({\n\tname,\n\tvalue,\n\tonChange,\n\ttargetCollection,\n\tlabel,\n\tfilter,\n\trequired,\n\tdisabled,\n\treadOnly,\n\tplaceholder,\n\terror,\n\tlocalized,\n\tlocale,\n\trenderOption,\n\trenderValue,\n}: RelationSelectProps<T>) {\n\tconst { t } = useTranslation();\n\tconst resolveText = useResolveText();\n\tconst resolvedLabel = label ? resolveText(label) : undefined;\n\tconst resolvedPlaceholder = placeholder\n\t\t? resolveText(placeholder)\n\t\t: undefined;\n\tconst labelText = resolvedLabel || targetCollection;\n\tconst selectLabel = t(\"relation.select\", { name: labelText });\n\tconst noResultsLabel = t(\"relation.noResults\", { name: labelText });\n\tconst createLabel = t(\"relation.createNew\", { name: labelText });\n\tconst [isSheetOpen, setIsSheetOpen] = React.useState(false);\n\tconst [editingItemId, setEditingItemId] = React.useState<\n\t\tstring | undefined\n\t>();\n\n\t// Get admin config for target collection from server\n\tconst { data: serverConfig } = useAdminConfig();\n\tconst client = useAdminStore(selectClient);\n\tconst targetConfig = serverConfig?.collections?.[targetCollection];\n\tconst collectionIconRef = (targetConfig as any)?.icon;\n\n\t// Load options from server with search\n\tconst loadOptions = React.useCallback(\n\t\tasync (search: string): Promise<SelectOption<string>[]> => {\n\t\t\tif (!client) return [];\n\n\t\t\ttry {\n\t\t\t\tconst options: any = {\n\t\t\t\t\tlimit: 50,\n\t\t\t\t\tlocale,\n\t\t\t\t};\n\n\t\t\t\t// Add search filter for _title\n\t\t\t\tif (search) {\n\t\t\t\t\toptions.search = search;\n\t\t\t\t}\n\n\t\t\t\t// Add custom filter if provided\n\t\t\t\tif (filter) {\n\t\t\t\t\toptions.where = filter({});\n\t\t\t\t}\n\n\t\t\t\tconst response = await (client as any).collections[\n\t\t\t\t\ttargetCollection\n\t\t\t\t].find(options);\n\t\t\t\tconst docs = response?.docs || [];\n\n\t\t\t\treturn docs.map((item: any) => ({\n\t\t\t\t\tvalue: item.id,\n\t\t\t\t\tlabel: renderOption\n\t\t\t\t\t\t? String(renderOption(item))\n\t\t\t\t\t\t: item._title || item.id || \"\",\n\t\t\t\t\ticon: resolveIconElement(collectionIconRef, {\n\t\t\t\t\t\tclassName: \"size-3.5 text-muted-foreground\",\n\t\t\t\t\t}),\n\t\t\t\t}));\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(\"Failed to load relation options:\", error);\n\t\t\t\ttoast.error(\"Failed to load options\");\n\t\t\t\treturn [];\n\t\t\t}\n\t\t},\n\t\t[client, targetCollection, filter, renderOption, collectionIconRef, locale],\n\t);\n\n\tconst queryClient = useQueryClient();\n\tconst queryOpts = React.useMemo(\n\t\t() =>\n\t\t\tcreateQuestpieQueryOptions(\n\t\t\t\t(client ?? {}) as any,\n\t\t\t\t{\n\t\t\t\t\tkeyPrefix: [\"questpie\", \"collections\"],\n\t\t\t\t} as any,\n\t\t\t),\n\t\t[client],\n\t);\n\n\t// Refetch for mutations (after create/update)\n\tconst refetch = React.useCallback(async () => {\n\t\tqueryClient.invalidateQueries({\n\t\t\tqueryKey: queryOpts.key([\"collections\", targetCollection, \"find\"]),\n\t\t});\n\t\tqueryClient.invalidateQueries({\n\t\t\tqueryKey: queryOpts.key([\n\t\t\t\t\"collections\",\n\t\t\t\ttargetCollection,\n\t\t\t\t\"findOne\",\n\t\t\t\t{ where: { id: value || \"\" } },\n\t\t\t]),\n\t\t});\n\t}, [queryClient, queryOpts, targetCollection, value]);\n\n\t// Fetch selected item details using the hook\n\tconst { data: selectedItem } = useCollectionItem(\n\t\ttargetCollection,\n\t\tvalue || \"\",\n\t\tundefined,\n\t\t{ enabled: !!value },\n\t);\n\n\tconst selectedOptions = React.useMemo(() => {\n\t\tif (!selectedItem) return [];\n\t\treturn [\n\t\t\t{\n\t\t\t\tvalue: selectedItem.id,\n\t\t\t\tlabel: renderValue\n\t\t\t\t\t? String(renderValue(selectedItem))\n\t\t\t\t\t: selectedItem._title || selectedItem.id || \"\",\n\t\t\t\ticon: resolveIconElement(collectionIconRef, {\n\t\t\t\t\tclassName: \"size-3.5 text-muted-foreground\",\n\t\t\t\t}),\n\t\t\t},\n\t\t];\n\t}, [selectedItem, renderValue, collectionIconRef]);\n\n\tconst handleOpenCreate = () => {\n\t\tsetEditingItemId(undefined);\n\t\tsetIsSheetOpen(true);\n\t};\n\n\tconst handleOpenEdit = () => {\n\t\tif (!value) return;\n\t\tsetEditingItemId(value);\n\t\tsetIsSheetOpen(true);\n\t};\n\n\tconst handleValueChange = (newValue: string | null) => {\n\t\tonChange(newValue);\n\t};\n\n\t// Handle save from ResourceSheet\n\tconst handleSheetSave = React.useCallback(\n\t\tasync (result: any) => {\n\t\t\t// Select newly created item (create mode = no editingItemId)\n\t\t\tif (!editingItemId && result?.id) {\n\t\t\t\tonChange(result.id);\n\t\t\t}\n\t\t\tawait refetch();\n\t\t},\n\t\t[editingItemId, onChange, refetch],\n\t);\n\n\treturn (\n\t\t<div className=\"space-y-2\">\n\t\t\t{label && (\n\t\t\t\t<div className=\"flex items-center gap-2\">\n\t\t\t\t\t<label\n\t\t\t\t\t\thtmlFor={name}\n\t\t\t\t\t\tclassName=\"text-sm font-medium flex items-center gap-1.5\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{resolveIconElement(collectionIconRef, {\n\t\t\t\t\t\t\tclassName: \"size-3.5 text-muted-foreground\",\n\t\t\t\t\t\t})}\n\t\t\t\t\t\t{resolvedLabel}\n\t\t\t\t\t\t{required && <span className=\"text-destructive\">*</span>}\n\t\t\t\t\t</label>\n\t\t\t\t\t{localized && <LocaleBadge locale={locale || \"i18n\"} />}\n\t\t\t\t</div>\n\t\t\t)}\n\n\t\t\t<div className=\"flex items-stretch gap-0\">\n\t\t\t\t{/* Searchable Select Dropdown - uses server-side search */}\n\t\t\t\t<div className=\"min-w-0 flex-1\">\n\t\t\t\t\t<SelectSingle\n\t\t\t\t\t\tid={name}\n\t\t\t\t\t\tvalue={value || null}\n\t\t\t\t\t\tonChange={handleValueChange}\n\t\t\t\t\t\toptions={selectedOptions}\n\t\t\t\t\t\tloadOptions={loadOptions}\n\t\t\t\t\t\tqueryKey={(search) =>\n\t\t\t\t\t\t\tqueryOpts.key([\n\t\t\t\t\t\t\t\t\"collections\",\n\t\t\t\t\t\t\t\ttargetCollection,\n\t\t\t\t\t\t\t\t\"find\",\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlimit: 50,\n\t\t\t\t\t\t\t\t\tlocale,\n\t\t\t\t\t\t\t\t\tsearch,\n\t\t\t\t\t\t\t\t\twhere: filter ? filter({}) : undefined,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t}\n\t\t\t\t\t\tprefetchOnMount\n\t\t\t\t\t\tplaceholder={resolvedPlaceholder || `${selectLabel}...`}\n\t\t\t\t\t\tdisabled={disabled || readOnly}\n\t\t\t\t\t\tclearable={!required}\n\t\t\t\t\t\temptyMessage={noResultsLabel}\n\t\t\t\t\t\tdrawerTitle={selectLabel}\n\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t!readOnly && \"rounded-r-none\",\n\t\t\t\t\t\t\terror && \"border-destructive\",\n\t\t\t\t\t\t)}\n\t\t\t\t\t\taria-invalid={!!error}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\n\t\t\t\t{/* Action Buttons */}\n\t\t\t\t{!readOnly && (\n\t\t\t\t\t<div className=\"flex\">\n\t\t\t\t\t\t{/* Edit button (only if value is set) */}\n\t\t\t\t\t\t{value && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\t\t\tsize=\"icon\"\n\t\t\t\t\t\t\t\tonClick={handleOpenEdit}\n\t\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\t\ttitle={t(\"collection.edit\", { name: labelText })}\n\t\t\t\t\t\t\t\taria-label={t(\"collection.edit\", { name: labelText })}\n\t\t\t\t\t\t\t\tclassName=\"rounded-none border-l-0\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Icon icon=\"ph:pencil\" className=\"h-4 w-4\" />\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t)}\n\n\t\t\t\t\t\t{/* Create button */}\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\t\tsize=\"icon\"\n\t\t\t\t\t\t\tonClick={handleOpenCreate}\n\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\ttitle={createLabel}\n\t\t\t\t\t\t\taria-label={createLabel}\n\t\t\t\t\t\t\tclassName=\"border-l-0 rounded-l-none\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon=\"ph:plus\" className=\"h-4 w-4\" />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</div>\n\n\t\t\t{/* Error message */}\n\t\t\t{error && <p className=\"text-sm text-destructive\">{error}</p>}\n\n\t\t\t{/* Side Sheet for Create/Edit */}\n\t\t\t<ResourceSheet\n\t\t\t\ttype=\"collection\"\n\t\t\t\tcollection={targetCollection}\n\t\t\t\titemId={editingItemId}\n\t\t\t\topen={isSheetOpen}\n\t\t\t\tonOpenChange={setIsSheetOpen}\n\t\t\t\tonSave={handleSheetSave}\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useTranslation } from "../../../i18n/hooks.mjs";
|
|
2
|
+
import { EDITOR_ICONS, ToolbarButton } from "./toolbar.mjs";
|
|
3
|
+
import "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { BubbleMenu } from "@tiptap/react";
|
|
6
|
+
|
|
7
|
+
//#region src/client/components/fields/rich-text-editor/bubble-menu.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Bubble menu that appears on text selection
|
|
10
|
+
*/
|
|
11
|
+
function RichTextBubbleMenu({ editor, features, disabled, onLinkClick }) {
|
|
12
|
+
const { t } = useTranslation();
|
|
13
|
+
const isEditable = !disabled;
|
|
14
|
+
return /* @__PURE__ */ jsxs(BubbleMenu, {
|
|
15
|
+
editor,
|
|
16
|
+
className: "flex items-center gap-1 rounded-md border bg-background p-1 shadow-lg",
|
|
17
|
+
children: [
|
|
18
|
+
features.bold && /* @__PURE__ */ jsx(ToolbarButton, {
|
|
19
|
+
icon: EDITOR_ICONS.bold,
|
|
20
|
+
active: editor.isActive("bold"),
|
|
21
|
+
disabled: !isEditable,
|
|
22
|
+
title: t("editor.bold"),
|
|
23
|
+
shortcut: "⌘B",
|
|
24
|
+
onClick: () => editor.chain().focus().toggleBold().run()
|
|
25
|
+
}),
|
|
26
|
+
features.italic && /* @__PURE__ */ jsx(ToolbarButton, {
|
|
27
|
+
icon: EDITOR_ICONS.italic,
|
|
28
|
+
active: editor.isActive("italic"),
|
|
29
|
+
disabled: !isEditable,
|
|
30
|
+
title: t("editor.italic"),
|
|
31
|
+
shortcut: "⌘I",
|
|
32
|
+
onClick: () => editor.chain().focus().toggleItalic().run()
|
|
33
|
+
}),
|
|
34
|
+
features.underline && /* @__PURE__ */ jsx(ToolbarButton, {
|
|
35
|
+
icon: EDITOR_ICONS.underline,
|
|
36
|
+
active: editor.isActive("underline"),
|
|
37
|
+
disabled: !isEditable,
|
|
38
|
+
title: t("editor.underline"),
|
|
39
|
+
shortcut: "⌘U",
|
|
40
|
+
onClick: () => editor.chain().focus().toggleUnderline().run()
|
|
41
|
+
}),
|
|
42
|
+
features.link && /* @__PURE__ */ jsx(ToolbarButton, {
|
|
43
|
+
icon: EDITOR_ICONS.link,
|
|
44
|
+
active: editor.isActive("link"),
|
|
45
|
+
disabled: !isEditable,
|
|
46
|
+
title: t("editor.link"),
|
|
47
|
+
shortcut: "⌘K",
|
|
48
|
+
onClick: onLinkClick
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { RichTextBubbleMenu };
|
|
56
|
+
//# sourceMappingURL=bubble-menu.mjs.map
|