@tulip-systems/core 0.5.2 → 0.5.3
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/dist/components/common/icons.d.mts +2 -2
- package/dist/components/common/status.d.mts +3 -3
- package/dist/components/editor/components/content.client.d.mts +2 -2
- package/dist/components/editor/components/editor.client.d.mts +2 -2
- package/dist/components/editor/components/editor.client.mjs +2 -2
- package/dist/components/editor/components/editor.client.mjs.map +1 -1
- package/dist/components/editor/components/menu.client.d.mts +3 -3
- package/dist/components/editor/components/menu.client.mjs +3 -0
- package/dist/components/editor/components/menu.client.mjs.map +1 -1
- package/dist/components/editor/extensions/file-handler/extension.d.mts +21 -0
- package/dist/components/editor/extensions/file-handler/extension.d.mts.map +1 -0
- package/dist/components/editor/extensions/file-handler/extension.mjs +40 -0
- package/dist/components/editor/extensions/file-handler/extension.mjs.map +1 -0
- package/dist/components/editor/extensions/file-handler/strategy.d.mts +29 -0
- package/dist/components/editor/extensions/file-handler/strategy.d.mts.map +1 -0
- package/dist/components/editor/extensions/file-handler/strategy.mjs +111 -0
- package/dist/components/editor/extensions/file-handler/strategy.mjs.map +1 -0
- package/dist/components/editor/extensions/file-handler/utils.mjs +50 -0
- package/dist/components/editor/extensions/file-handler/utils.mjs.map +1 -0
- package/dist/components/editor/extensions/image/extension.d.mts +8 -0
- package/dist/components/editor/extensions/image/extension.d.mts.map +1 -0
- package/dist/components/editor/extensions/image/extension.mjs +52 -0
- package/dist/components/editor/extensions/image/extension.mjs.map +1 -0
- package/dist/components/editor/extensions/skeleton/extension.mjs +41 -0
- package/dist/components/editor/extensions/skeleton/extension.mjs.map +1 -0
- package/dist/components/editor/extensions/skeleton/renderer.mjs +25 -0
- package/dist/components/editor/extensions/skeleton/renderer.mjs.map +1 -0
- package/dist/components/editor/lib/constants.d.mts +29 -26
- package/dist/components/editor/lib/constants.d.mts.map +1 -1
- package/dist/components/editor/lib/constants.mjs +14 -2
- package/dist/components/editor/lib/constants.mjs.map +1 -1
- package/dist/components/editor/lib/extensions.d.mts +5 -1
- package/dist/components/editor/lib/extensions.d.mts.map +1 -1
- package/dist/components/editor/lib/extensions.mjs.map +1 -1
- package/dist/components/editor/lib/variants.mjs +10 -2
- package/dist/components/editor/lib/variants.mjs.map +1 -1
- package/dist/components/header/back-button.client.d.mts +2 -2
- package/dist/components/header/bottom-bar.client.d.mts +3 -3
- package/dist/components/header/breadcrumbs.client.d.mts +7 -7
- package/dist/components/header/header.client.d.mts +2 -2
- package/dist/components/header/mobile-nav-switcher.client.d.mts +2 -2
- package/dist/components/header/top-bar.client.d.mts +4 -4
- package/dist/components/layouts/admin-content.client.d.mts +2 -2
- package/dist/components/layouts/admin-layout.d.mts +2 -2
- package/dist/components/layouts/admin-layout.d.mts.map +1 -1
- package/dist/components/layouts/admin-loading.d.mts +2 -2
- package/dist/components/layouts/empty-page.d.mts +4 -4
- package/dist/components/layouts/list-layout.d.mts +2 -2
- package/dist/components/layouts/not-found-page.d.mts +3 -3
- package/dist/components/layouts/providers.client.d.mts +2 -2
- package/dist/components/layouts/root-layout.server.d.mts +2 -2
- package/dist/components/layouts/root-loading.d.mts +2 -2
- package/dist/components/layouts/tab-layout.d.mts +2 -2
- package/dist/components/lists/data-list.d.mts +5 -5
- package/dist/components/lists/data-stack.d.mts +8 -8
- package/dist/components/lists/data-stack.d.mts.map +1 -1
- package/dist/components/navigation/admin-sidebar-paths.client.d.mts +10 -10
- package/dist/components/ui/accordion.d.mts +5 -5
- package/dist/components/ui/accordion.d.mts.map +1 -1
- package/dist/components/ui/alert-dialog.d.mts +12 -12
- package/dist/components/ui/alert-dialog.d.mts.map +1 -1
- package/dist/components/ui/alert.d.mts +4 -4
- package/dist/components/ui/alert.d.mts.map +1 -1
- package/dist/components/ui/aspect-ratio.d.mts +2 -2
- package/dist/components/ui/aspect-ratio.d.mts.map +1 -1
- package/dist/components/ui/avatar.client.d.mts +4 -4
- package/dist/components/ui/badge.d.mts +2 -2
- package/dist/components/ui/badge.d.mts.map +1 -1
- package/dist/components/ui/breadcrumb.d.mts +8 -8
- package/dist/components/ui/breadcrumb.d.mts.map +1 -1
- package/dist/components/ui/button.d.mts +2 -2
- package/dist/components/ui/button.d.mts.map +1 -1
- package/dist/components/ui/calendar.d.mts +3 -3
- package/dist/components/ui/calendar.d.mts.map +1 -1
- package/dist/components/ui/card.d.mts +7 -7
- package/dist/components/ui/card.d.mts.map +1 -1
- package/dist/components/ui/carousel.d.mts +6 -6
- package/dist/components/ui/carousel.d.mts.map +1 -1
- package/dist/components/ui/chart.client.d.mts +5 -5
- package/dist/components/ui/checkbox.d.mts +2 -2
- package/dist/components/ui/checkbox.d.mts.map +1 -1
- package/dist/components/ui/collapsible.client.d.mts +4 -4
- package/dist/components/ui/color-picker.client.d.mts +2 -2
- package/dist/components/ui/combobox-dropdown.client.d.mts +2 -2
- package/dist/components/ui/combobox.client.d.mts +2 -2
- package/dist/components/ui/command.d.mts +10 -10
- package/dist/components/ui/command.d.mts.map +1 -1
- package/dist/components/ui/context-menu.d.mts +16 -16
- package/dist/components/ui/context-menu.d.mts.map +1 -1
- package/dist/components/ui/date-picker.client.d.mts +2 -2
- package/dist/components/ui/dialog.client.d.mts +11 -11
- package/dist/components/ui/drawer.client.d.mts +11 -11
- package/dist/components/ui/dropdown-menu.d.mts +16 -16
- package/dist/components/ui/form.client.d.mts +7 -7
- package/dist/components/ui/hover-card.client.d.mts +4 -4
- package/dist/components/ui/input-recipient.d.mts +2 -2
- package/dist/components/ui/input.d.mts +2 -2
- package/dist/components/ui/label.d.mts +2 -2
- package/dist/components/ui/navigation-menu.d.mts +9 -9
- package/dist/components/ui/pagination.d.mts +8 -8
- package/dist/components/ui/popover.d.mts +5 -5
- package/dist/components/ui/popover.d.mts.map +1 -1
- package/dist/components/ui/progress.client.d.mts +2 -2
- package/dist/components/ui/radio-group.d.mts +3 -3
- package/dist/components/ui/resizable.client.d.mts +4 -4
- package/dist/components/ui/scroll-area.d.mts +3 -3
- package/dist/components/ui/select.client.d.mts +11 -11
- package/dist/components/ui/separator.d.mts +2 -2
- package/dist/components/ui/sheet.client.d.mts +9 -9
- package/dist/components/ui/sidebar.client.d.mts +24 -24
- package/dist/components/ui/skeleton.d.mts +2 -2
- package/dist/components/ui/slider.d.mts +2 -2
- package/dist/components/ui/sonner.client.d.mts +2 -2
- package/dist/components/ui/switch.d.mts +2 -2
- package/dist/components/ui/tabs.d.mts +5 -5
- package/dist/components/ui/textarea.d.mts +2 -2
- package/dist/components/ui/time-input.client.d.mts +2 -2
- package/dist/components/ui/toggle-group.client.d.mts +3 -3
- package/dist/components/ui/toggle.d.mts +2 -2
- package/dist/components/ui/tooltip.client.d.mts +5 -5
- package/dist/components.d.mts +2 -1
- package/dist/components.mjs +3 -2
- package/dist/data-tables.d.mts +2 -2
- package/dist/data-tables.mjs +2 -2
- package/dist/inline-edit/client.d.mts +2 -3
- package/dist/inline-edit/client.mjs +1 -2
- package/dist/lib/client.d.mts +2 -2
- package/dist/lib/client.mjs +2 -2
- package/dist/lib/hooks/use-action.d.mts +2 -2
- package/dist/lib/hooks/use-indicator.d.mts +11 -3
- package/dist/lib/hooks/use-indicator.d.mts.map +1 -1
- package/dist/lib/hooks/use-indicator.mjs +19 -8
- package/dist/lib/hooks/use-indicator.mjs.map +1 -1
- package/dist/modules/auth/components/allowed.client.d.mts +2 -2
- package/dist/modules/auth/components/allowed.client.d.mts.map +1 -1
- package/dist/modules/auth/components/auth-layout.server.d.mts +2 -2
- package/dist/modules/auth/components/auth-layout.server.d.mts.map +1 -1
- package/dist/modules/auth/components/auth-loading.d.mts +2 -2
- package/dist/modules/auth/components/create-first-user-page.client.d.mts +2 -2
- package/dist/modules/auth/components/create-first-user-page.client.d.mts.map +1 -1
- package/dist/modules/auth/components/forget-password-page.client.d.mts +2 -2
- package/dist/modules/auth/components/forget-password-page.client.d.mts.map +1 -1
- package/dist/modules/auth/components/guard-first-user.server.d.mts +2 -2
- package/dist/modules/auth/components/guard-first-user.server.d.mts.map +1 -1
- package/dist/modules/auth/components/guard.server.d.mts +2 -2
- package/dist/modules/auth/components/guard.server.d.mts.map +1 -1
- package/dist/modules/auth/components/login-page.client.d.mts +2 -2
- package/dist/modules/auth/components/login-page.client.d.mts.map +1 -1
- package/dist/modules/auth/components/reset-password-page.client.d.mts +2 -2
- package/dist/modules/auth/components/reset-password-page.client.d.mts.map +1 -1
- package/dist/modules/auth/components/update-password-command.d.mts +2 -2
- package/dist/modules/auth/components/update-password-command.d.mts.map +1 -1
- package/dist/modules/auth/db/schema.d.mts +73 -73
- package/dist/modules/auth/db/schema.d.mts.map +1 -1
- package/dist/modules/auth/handler/client.client.d.mts +6 -6
- package/dist/modules/auth/hooks/use-permission.d.mts +2 -2
- package/dist/modules/auth/hooks/use-session.d.mts +4 -4
- package/dist/modules/auth/lib/validators.d.mts +2 -2
- package/dist/modules/auth/lib/validators.d.mts.map +1 -1
- package/dist/modules/commands/components/alert-dialog-command.client.d.mts +10 -10
- package/dist/modules/commands/components/alert-dialog-command.client.d.mts.map +1 -1
- package/dist/modules/commands/components/click-command.client.d.mts +2 -2
- package/dist/modules/commands/components/click-command.client.d.mts.map +1 -1
- package/dist/modules/commands/components/command-trigger.client.d.mts +6 -6
- package/dist/modules/commands/components/command-trigger.client.d.mts.map +1 -1
- package/dist/modules/commands/components/dialog-command.client.d.mts +8 -8
- package/dist/modules/commands/components/dialog-command.client.d.mts.map +1 -1
- package/dist/modules/commands/components/dropdown-command.client.d.mts +5 -5
- package/dist/modules/commands/components/dropdown-command.client.d.mts.map +1 -1
- package/dist/modules/commands/components/empty-command.client.d.mts +2 -2
- package/dist/modules/commands/components/empty-command.client.d.mts.map +1 -1
- package/dist/modules/commands/components/form-dialog-command.client.d.mts +11 -11
- package/dist/modules/commands/components/form-dialog-command.client.d.mts.map +1 -1
- package/dist/modules/commands/hooks/use-command-mutation.client.d.mts +2 -2
- package/dist/modules/commands/menus/context-menu.client.d.mts +2 -2
- package/dist/modules/commands/menus/context-menu.client.d.mts.map +1 -1
- package/dist/modules/commands/menus/dropdown-menu.client.d.mts +3 -3
- package/dist/modules/commands/menus/dropdown-menu.client.d.mts.map +1 -1
- package/dist/modules/commands/menus/inline-menu.client.d.mts +3 -3
- package/dist/modules/commands/menus/inline-menu.client.d.mts.map +1 -1
- package/dist/modules/commands/menus/responsive-menu.client.d.mts +3 -3
- package/dist/modules/commands/menus/responsive-menu.client.d.mts.map +1 -1
- package/dist/modules/commands/utils/archive-command.client.d.mts +3 -3
- package/dist/modules/commands/utils/archive-command.client.d.mts.map +1 -1
- package/dist/modules/commands/utils/delete-command.client.d.mts +3 -3
- package/dist/modules/commands/utils/delete-command.client.d.mts.map +1 -1
- package/dist/modules/config/db/helpers.d.mts +5 -5
- package/dist/modules/config/db/helpers.d.mts.map +1 -1
- package/dist/modules/data-tables/components/cell/common.client.d.mts +5 -5
- package/dist/modules/data-tables/components/column-header.d.mts +2 -2
- package/dist/modules/data-tables/components/column-header.d.mts.map +1 -1
- package/dist/modules/data-tables/components/filters/combobox.client.d.mts +2 -2
- package/dist/modules/data-tables/components/filters/slider.client.d.mts +2 -2
- package/dist/modules/data-tables/components/header.d.mts +4 -4
- package/dist/modules/data-tables/components/header.d.mts.map +1 -1
- package/dist/modules/data-tables/components/layout.d.mts +2 -2
- package/dist/modules/data-tables/components/layout.d.mts.map +1 -1
- package/dist/modules/data-tables/components/search-input.client.d.mts +2 -2
- package/dist/modules/data-tables/components/skeleton.d.mts +2 -2
- package/dist/modules/data-tables/components/skeleton.d.mts.map +1 -1
- package/dist/modules/data-tables/components/table.d.mts +7 -7
- package/dist/modules/data-tables/components/table.d.mts.map +1 -1
- package/dist/modules/data-tables/components/toolbar.d.mts +3 -3
- package/dist/modules/data-tables/components/toolbar.d.mts.map +1 -1
- package/dist/modules/data-tables/hooks/use-context.client.d.mts +2 -2
- package/dist/modules/data-tables/lib/filters/parsers.d.mts +6 -1
- package/dist/modules/data-tables/lib/filters/parsers.d.mts.map +1 -1
- package/dist/modules/data-tables/lib/filters/parsers.mjs +6 -1
- package/dist/modules/data-tables/lib/filters/parsers.mjs.map +1 -1
- package/dist/modules/data-tables/tables/data-table/components/table.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/cells/common.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/cells/drag-handle.client.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/inputs/advanced-select.client.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/inputs/combobox.client.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/inputs/input.client.d.mts +3 -3
- package/dist/modules/data-tables/tables/inline-table/components/inputs/read-only.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/inputs/select.client.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/table.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts +2 -2
- package/dist/modules/inline-edit/components/combobox-dropdown.client.d.mts +6 -4
- package/dist/modules/inline-edit/components/combobox-dropdown.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/combobox-dropdown.client.mjs +11 -6
- package/dist/modules/inline-edit/components/combobox-dropdown.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/combobox.client.d.mts +6 -4
- package/dist/modules/inline-edit/components/combobox.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/combobox.client.mjs +7 -5
- package/dist/modules/inline-edit/components/combobox.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/date-input.client.d.mts +5 -3
- package/dist/modules/inline-edit/components/date-input.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/date-input.client.mjs +26 -13
- package/dist/modules/inline-edit/components/date-input.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/date-picker.client.d.mts +6 -4
- package/dist/modules/inline-edit/components/date-picker.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/date-picker.client.mjs +12 -7
- package/dist/modules/inline-edit/components/date-picker.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/editor.client.d.mts +6 -4
- package/dist/modules/inline-edit/components/editor.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/editor.client.mjs +11 -6
- package/dist/modules/inline-edit/components/editor.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/input-recipient.client.d.mts +6 -4
- package/dist/modules/inline-edit/components/input-recipient.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/input-recipient.client.mjs +11 -6
- package/dist/modules/inline-edit/components/input-recipient.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/input-toggle.client.d.mts +6 -4
- package/dist/modules/inline-edit/components/input-toggle.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/input-toggle.client.mjs +9 -7
- package/dist/modules/inline-edit/components/input-toggle.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/input.client.d.mts +13 -10
- package/dist/modules/inline-edit/components/input.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/input.client.mjs +35 -19
- package/dist/modules/inline-edit/components/input.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/select.client.d.mts +10 -9
- package/dist/modules/inline-edit/components/select.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/select.client.mjs +14 -7
- package/dist/modules/inline-edit/components/select.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/switch.client.d.mts +5 -3
- package/dist/modules/inline-edit/components/switch.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/switch.client.mjs +8 -6
- package/dist/modules/inline-edit/components/switch.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/toggle.client.d.mts +6 -4
- package/dist/modules/inline-edit/components/toggle.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/toggle.client.mjs +9 -7
- package/dist/modules/inline-edit/components/toggle.client.mjs.map +1 -1
- package/dist/modules/inline-edit/hooks/context.client.d.mts +2 -2
- package/dist/modules/inline-edit/hooks/context.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/hooks/use-inline.client.d.mts +35 -3
- package/dist/modules/inline-edit/hooks/use-inline.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/hooks/use-inline.client.mjs +71 -9
- package/dist/modules/inline-edit/hooks/use-inline.client.mjs.map +1 -1
- package/dist/modules/inline-edit/lib/variants.d.mts +1 -0
- package/dist/modules/inline-edit/lib/variants.d.mts.map +1 -1
- package/dist/modules/inline-edit/lib/variants.mjs +12 -4
- package/dist/modules/inline-edit/lib/variants.mjs.map +1 -1
- package/dist/modules/router/handler/init.server.d.mts +6 -6
- package/dist/modules/router/handler/init.server.d.mts.map +1 -1
- package/dist/modules/router/lib/query-client.server.d.mts +2 -2
- package/dist/modules/router/lib/query-client.server.d.mts.map +1 -1
- package/dist/modules/storage/components/dropzone-context.client.d.mts +2 -2
- package/dist/modules/storage/components/dropzone.client.d.mts +5 -5
- package/dist/modules/storage/components/dropzone.client.mjs +1 -1
- package/dist/modules/storage/components/image-grid.client.d.mts +3 -3
- package/dist/modules/storage/components/image-grid.client.mjs +3 -3
- package/dist/modules/storage/components/image-grid.client.mjs.map +1 -1
- package/dist/modules/storage/components/upload-zone-context.client.d.mts +3 -11
- package/dist/modules/storage/components/upload-zone-context.client.d.mts.map +1 -1
- package/dist/modules/storage/components/upload-zone-context.client.mjs.map +1 -1
- package/dist/modules/storage/components/upload-zone.client.d.mts +10 -33
- package/dist/modules/storage/components/upload-zone.client.d.mts.map +1 -1
- package/dist/modules/storage/components/upload-zone.client.mjs +19 -93
- package/dist/modules/storage/components/upload-zone.client.mjs.map +1 -1
- package/dist/modules/storage/config/filters.d.mts +1 -0
- package/dist/modules/storage/config/filters.d.mts.map +1 -1
- package/dist/modules/storage/config/filters.mjs +1 -0
- package/dist/modules/storage/config/filters.mjs.map +1 -1
- package/dist/modules/storage/lib/create-upload.client.d.mts +56 -0
- package/dist/modules/storage/lib/create-upload.client.d.mts.map +1 -0
- package/dist/modules/storage/lib/create-upload.client.mjs +98 -0
- package/dist/modules/storage/lib/create-upload.client.mjs.map +1 -0
- package/dist/modules/storage/lib/helpers.d.mts +1 -1
- package/dist/modules/storage/lib/router.server.d.mts +3265 -2345
- package/dist/modules/storage/lib/router.server.d.mts.map +1 -1
- package/dist/modules/storage/lib/router.server.mjs +5 -2
- package/dist/modules/storage/lib/router.server.mjs.map +1 -1
- package/dist/modules/storage/lib/schema.d.mts +124 -90
- package/dist/modules/storage/lib/schema.d.mts.map +1 -1
- package/dist/modules/storage/lib/schema.mjs +2 -1
- package/dist/modules/storage/lib/schema.mjs.map +1 -1
- package/dist/modules/storage/lib/service.server.d.mts +31 -42
- package/dist/modules/storage/lib/service.server.d.mts.map +1 -1
- package/dist/modules/storage/lib/service.server.mjs +5 -5
- package/dist/modules/storage/lib/service.server.mjs.map +1 -1
- package/dist/modules/storage/lib/validators.d.mts +170 -90
- package/dist/modules/storage/lib/validators.d.mts.map +1 -1
- package/dist/modules/storage/lib/validators.mjs +2 -1
- package/dist/modules/storage/lib/validators.mjs.map +1 -1
- package/dist/storage/client.d.mts +2 -1
- package/dist/storage/client.mjs +2 -8
- package/dist/storage.d.mts +2 -2
- package/dist/storage.mjs +1 -1
- package/package.json +4 -3
- package/src/components/editor/components/editor.client.tsx +7 -2
- package/src/components/editor/components/menu.client.tsx +26 -0
- package/src/components/editor/extensions/file-handler/extension.ts +69 -0
- package/src/components/editor/extensions/file-handler/strategy.ts +167 -0
- package/src/components/editor/extensions/file-handler/utils.ts +51 -0
- package/src/components/editor/extensions/image/extension.ts +57 -0
- package/src/components/editor/extensions/skeleton/extension.ts +35 -0
- package/src/components/editor/extensions/skeleton/renderer.tsx +14 -0
- package/src/components/editor/lib/constants.ts +16 -2
- package/src/components/editor/lib/extensions.ts +4 -1
- package/src/components/editor/lib/utils.ts +32 -0
- package/src/components/editor/lib/variants.ts +72 -1
- package/src/components/entry.ts +2 -1
- package/src/lib/hooks/use-indicator.tsx +27 -18
- package/src/modules/data-tables/lib/filters/parsers.ts +14 -0
- package/src/modules/inline-edit/components/combobox-dropdown.client.tsx +21 -12
- package/src/modules/inline-edit/components/combobox.client.tsx +13 -6
- package/src/modules/inline-edit/components/date-input.client.tsx +29 -13
- package/src/modules/inline-edit/components/date-picker.client.tsx +13 -9
- package/src/modules/inline-edit/components/editor.client.tsx +14 -14
- package/src/modules/inline-edit/components/input-recipient.client.tsx +15 -8
- package/src/modules/inline-edit/components/input-toggle.client.tsx +16 -9
- package/src/modules/inline-edit/components/input.client.tsx +38 -24
- package/src/modules/inline-edit/components/select.client.tsx +16 -9
- package/src/modules/inline-edit/components/switch.client.tsx +10 -6
- package/src/modules/inline-edit/components/toggle.client.tsx +13 -9
- package/src/modules/inline-edit/entry.client.ts +0 -1
- package/src/modules/inline-edit/hooks/use-inline.client copy.tsx +97 -0
- package/src/modules/inline-edit/hooks/use-inline.client.tsx +139 -20
- package/src/modules/inline-edit/lib/variants.ts +7 -0
- package/src/modules/storage/components/image-grid.client.tsx +2 -2
- package/src/modules/storage/components/upload-zone-context.client.tsx +3 -4
- package/src/modules/storage/components/upload-zone.client.tsx +17 -116
- package/src/modules/storage/config/filters.ts +1 -0
- package/src/modules/storage/entry.client.ts +2 -1
- package/src/modules/storage/lib/create-upload.client.ts +134 -0
- package/src/modules/storage/lib/router.server.ts +1 -0
- package/src/modules/storage/lib/schema.ts +1 -0
- package/src/modules/storage/lib/service.server.ts +10 -4
- package/src/modules/storage/lib/validators.ts +1 -0
- package/dist/modules/inline-edit/components/deprecated-editor.client.d.mts +0 -21
- package/dist/modules/inline-edit/components/deprecated-editor.client.d.mts.map +0 -1
- package/dist/modules/inline-edit/components/deprecated-editor.client.mjs +0 -37
- package/dist/modules/inline-edit/components/deprecated-editor.client.mjs.map +0 -1
- package/dist/storage/client.mjs.map +0 -1
- package/src/modules/inline-edit/components/deprecated-editor.client.tsx +0 -48
|
@@ -1,51 +1,113 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import { useLocalIndicator } from "../../../lib/hooks/use-indicator.mjs";
|
|
3
4
|
import { useAction } from "../../../lib/hooks/use-action.mjs";
|
|
4
5
|
import { usePermission } from "../../auth/hooks/use-permission.mjs";
|
|
5
6
|
import { useInlineEditContext } from "./context.client.mjs";
|
|
6
|
-
import { useState } from "react";
|
|
7
|
+
import { useCallback, useState } from "react";
|
|
7
8
|
import { toast } from "sonner";
|
|
9
|
+
import { useDebouncedCallback } from "use-debounce";
|
|
8
10
|
|
|
9
11
|
//#region src/modules/inline-edit/hooks/use-inline.client.tsx
|
|
12
|
+
const defaultUpdateStrategy = { mode: "blur" };
|
|
13
|
+
/**
|
|
14
|
+
* Use the inline edit hook.
|
|
15
|
+
*/
|
|
10
16
|
function useInlineEdit(props) {
|
|
17
|
+
/**
|
|
18
|
+
* The update strategy.
|
|
19
|
+
*/
|
|
20
|
+
const strategy = props.updateStrategy ?? defaultUpdateStrategy;
|
|
21
|
+
const delay = strategy.mode === "change" ? strategy.delay ?? 0 : 0;
|
|
11
22
|
/**
|
|
12
23
|
* The inline edit context.
|
|
13
24
|
*/
|
|
14
25
|
const context = useInlineEditContext();
|
|
15
|
-
const { data } = usePermission(props.permission ?? context.permission);
|
|
16
|
-
const isAllowed = data?.success;
|
|
17
26
|
/**
|
|
18
27
|
* The current value of the inline edit.
|
|
19
28
|
*/
|
|
20
29
|
const [value, setValue] = useState(props.initialValue);
|
|
21
30
|
/**
|
|
31
|
+
* The indicator status.
|
|
32
|
+
*/
|
|
33
|
+
const { status, setStatus } = useLocalIndicator();
|
|
34
|
+
/**
|
|
35
|
+
* Permission guard
|
|
36
|
+
*/
|
|
37
|
+
const { data } = usePermission(props.permission ?? context.permission);
|
|
38
|
+
const isAllowed = data?.success;
|
|
39
|
+
/**
|
|
22
40
|
* Execute the action to update the value.
|
|
23
41
|
*/
|
|
24
|
-
const
|
|
42
|
+
const mutation = useAction({
|
|
25
43
|
mutationFn: props.action,
|
|
44
|
+
onMutate: () => {
|
|
45
|
+
setStatus("pending");
|
|
46
|
+
},
|
|
47
|
+
onSuccess: () => {
|
|
48
|
+
setStatus("success");
|
|
49
|
+
},
|
|
26
50
|
onError: (error) => {
|
|
27
51
|
setValue(props.initialValue);
|
|
28
52
|
toast.error("Er is iets misgegaan", { description: error instanceof Error ? error.message : void 0 });
|
|
29
53
|
}
|
|
30
54
|
});
|
|
31
55
|
/**
|
|
32
|
-
* Handle
|
|
56
|
+
* Handle instant mutate
|
|
33
57
|
*/
|
|
34
|
-
const
|
|
58
|
+
const handleMutateInstant = useCallback((value$1) => {
|
|
35
59
|
if (!isAllowed) {
|
|
36
60
|
toast.error("Je hebt geen toestemming om dit te bewerken");
|
|
37
61
|
return;
|
|
38
62
|
}
|
|
39
63
|
if (value$1 === props.initialValue) return;
|
|
40
|
-
return mutate({
|
|
64
|
+
return mutation.mutate({
|
|
41
65
|
id: context.id,
|
|
42
66
|
value: value$1
|
|
43
67
|
});
|
|
44
|
-
}
|
|
68
|
+
}, [
|
|
69
|
+
isAllowed,
|
|
70
|
+
props.initialValue,
|
|
71
|
+
mutation,
|
|
72
|
+
context.id
|
|
73
|
+
]);
|
|
74
|
+
/**
|
|
75
|
+
* Handle mutate with debounce
|
|
76
|
+
*/
|
|
77
|
+
const handleMutateDebounced = useDebouncedCallback(handleMutateInstant, delay);
|
|
78
|
+
/**
|
|
79
|
+
* Handle change updates
|
|
80
|
+
*/
|
|
81
|
+
function handleChange(next) {
|
|
82
|
+
setValue(next ?? void 0);
|
|
83
|
+
if (strategy.mode !== "change") return;
|
|
84
|
+
if (props.isRequired && next === null) {
|
|
85
|
+
setValue(props.initialValue ?? void 0);
|
|
86
|
+
setStatus("error");
|
|
87
|
+
toast.error("Dit veld is verplicht");
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
handleMutateDebounced(next);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Handle blur updates
|
|
94
|
+
*/
|
|
95
|
+
function handleBlur(next) {
|
|
96
|
+
setValue(next ?? void 0);
|
|
97
|
+
if (strategy.mode !== "blur") return;
|
|
98
|
+
if (props.isRequired && next === null) {
|
|
99
|
+
setValue(props.initialValue ?? void 0);
|
|
100
|
+
setStatus("error");
|
|
101
|
+
toast.error("Dit veld is verplicht");
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
handleMutateInstant(next);
|
|
105
|
+
}
|
|
45
106
|
return {
|
|
46
107
|
value,
|
|
47
108
|
setValue,
|
|
48
|
-
|
|
109
|
+
handleChange,
|
|
110
|
+
handleBlur,
|
|
49
111
|
status,
|
|
50
112
|
isAllowed
|
|
51
113
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-inline.client.mjs","names":["value"],"sources":["../../../../src/modules/inline-edit/hooks/use-inline.client.tsx"],"sourcesContent":["\"use client\";\n\nimport { EditorJSONContent } from \"@/components/entry\";\nimport { useAction } from \"@/lib/hooks/use-action\";\nimport { usePermission } from \"@/modules/auth/hooks/use-permission\";\nimport { Permission } from \"@/modules/auth/lib/permissions\";\nimport { useState } from \"react\";\nimport { toast } from \"sonner\";\nimport { useInlineEditContext } from \"./context.client\";\n\nexport type useInlineEditOptions<TValue> = {\n initialValue?: TValue
|
|
1
|
+
{"version":3,"file":"use-inline.client.mjs","names":["defaultUpdateStrategy: UpdateStrategy","value"],"sources":["../../../../src/modules/inline-edit/hooks/use-inline.client.tsx"],"sourcesContent":["\"use client\";\n\nimport { EditorJSONContent } from \"@/components/entry\";\nimport { useLocalIndicator } from \"@/lib/entry.client\";\nimport { useAction } from \"@/lib/hooks/use-action\";\nimport { usePermission } from \"@/modules/auth/hooks/use-permission\";\nimport { Permission } from \"@/modules/auth/lib/permissions\";\nimport { useCallback, useState } from \"react\";\nimport { toast } from \"sonner\";\nimport { useDebouncedCallback } from \"use-debounce\";\nimport { useInlineEditContext } from \"./context.client\";\n\ntype UpdateStrategy =\n | {\n mode: \"change\";\n delay?: number;\n }\n | {\n mode: \"blur\";\n };\n\nconst defaultUpdateStrategy: UpdateStrategy = {\n mode: \"blur\",\n};\n\ntype MaybeValue<TValue, Required extends boolean> = Required extends true ? TValue : TValue | null;\n\n/**\n * Use the inline edit hook options.\n */\nexport type useInlineEditOptions<TValue, Required extends boolean = false> = {\n /**\n * Initial value\n */\n initialValue?: MaybeValue<TValue, Required>;\n /**\n * Action to execute on update\n */\n action: (value: { id: string; value: MaybeValue<TValue, Required> }) => Promise<unknown>;\n /**\n * Permission required to edit\n */\n permission?: Permission;\n /**\n * Update strategy\n * - trigger: when to update the value (default: \"blur\")\n * - delay: delay in milliseconds before updating the value (only for \"change\" trigger)\n * @default { trigger: \"blur\" }\n */\n updateStrategy?: UpdateStrategy;\n /**\n * Is the value required\n * @default false\n */\n isRequired?: Required;\n};\n\n/**\n * Use the inline edit hook.\n */\nexport function useInlineEdit<\n TValue extends string | number | Date | boolean | JSON | EditorJSONContent,\n Required extends boolean = false,\n>(props: useInlineEditOptions<TValue, Required>) {\n /**\n * The update strategy.\n */\n const strategy = props.updateStrategy ?? defaultUpdateStrategy;\n const delay = strategy.mode === \"change\" ? (strategy.delay ?? 0) : 0;\n\n /**\n * The inline edit context.\n */\n const context = useInlineEditContext();\n\n /**\n * The current value of the inline edit.\n */\n const [value, setValue] = useState<MaybeValue<TValue, Required> | undefined>(props.initialValue);\n\n /**\n * The indicator status.\n */\n const { status, setStatus } = useLocalIndicator();\n\n /**\n * Permission guard\n */\n const { data } = usePermission(props.permission ?? context.permission);\n const isAllowed = data?.success;\n\n /**\n * Execute the action to update the value.\n */\n const mutation = useAction({\n mutationFn: props.action,\n onMutate: () => {\n setStatus(\"pending\");\n },\n onSuccess: () => {\n setStatus(\"success\");\n },\n onError: (error) => {\n setValue(props.initialValue);\n toast.error(\"Er is iets misgegaan\", {\n description: error instanceof Error ? error.message : undefined,\n });\n },\n });\n\n /**\n * Handle instant mutate\n */\n const handleMutateInstant = useCallback(\n (value: MaybeValue<TValue, Required>) => {\n // Permission guard\n if (!isAllowed) {\n toast.error(\"Je hebt geen toestemming om dit te bewerken\");\n return;\n }\n\n // If the value is the same as the initial value, do nothing\n if (value === props.initialValue) return;\n\n // Update the value\n return mutation.mutate({ id: context.id, value });\n },\n [isAllowed, props.initialValue, mutation, context.id],\n );\n\n /**\n * Handle mutate with debounce\n */\n const handleMutateDebounced = useDebouncedCallback(handleMutateInstant, delay);\n\n /**\n * Handle change updates\n */\n function handleChange(next: MaybeValue<TValue, Required> | null) {\n // Set value in state\n setValue(next ?? undefined);\n\n // If the strategy is not change, exit\n if (strategy.mode !== \"change\") return;\n\n // If it is required and the value is null or empty, reset to initial value\n if (props.isRequired && next === null) {\n setValue(props.initialValue ?? undefined);\n setStatus(\"error\");\n toast.error(\"Dit veld is verplicht\");\n return;\n }\n\n // If the strategy is change, update the value after the delay\n handleMutateDebounced(next as MaybeValue<TValue, Required>);\n }\n\n /**\n * Handle blur updates\n */\n function handleBlur(next: MaybeValue<TValue, Required> | null) {\n // Set value in state\n setValue(next ?? undefined);\n\n // If the strategy is not blur, exit\n if (strategy.mode !== \"blur\") return;\n\n // If it is required and the value is null or empty, reset to initial value\n if (props.isRequired && next === null) {\n setValue(props.initialValue ?? undefined);\n setStatus(\"error\");\n toast.error(\"Dit veld is verplicht\");\n return;\n }\n\n // If the strategy is blur, update the value\n handleMutateInstant(next as MaybeValue<TValue, Required>);\n }\n\n return { value, setValue, handleChange, handleBlur, status, isAllowed };\n}\n"],"mappings":";;;;;;;;;;;AAqBA,MAAMA,wBAAwC,EAC5C,MAAM,QACP;;;;AAqCD,SAAgB,cAGd,OAA+C;;;;CAI/C,MAAM,WAAW,MAAM,kBAAkB;CACzC,MAAM,QAAQ,SAAS,SAAS,WAAY,SAAS,SAAS,IAAK;;;;CAKnE,MAAM,UAAU,sBAAsB;;;;CAKtC,MAAM,CAAC,OAAO,YAAY,SAAmD,MAAM,aAAa;;;;CAKhG,MAAM,EAAE,QAAQ,cAAc,mBAAmB;;;;CAKjD,MAAM,EAAE,SAAS,cAAc,MAAM,cAAc,QAAQ,WAAW;CACtE,MAAM,YAAY,MAAM;;;;CAKxB,MAAM,WAAW,UAAU;EACzB,YAAY,MAAM;EAClB,gBAAgB;AACd,aAAU,UAAU;;EAEtB,iBAAiB;AACf,aAAU,UAAU;;EAEtB,UAAU,UAAU;AAClB,YAAS,MAAM,aAAa;AAC5B,SAAM,MAAM,wBAAwB,EAClC,aAAa,iBAAiB,QAAQ,MAAM,UAAU,QACvD,CAAC;;EAEL,CAAC;;;;CAKF,MAAM,sBAAsB,aACzB,YAAwC;AAEvC,MAAI,CAAC,WAAW;AACd,SAAM,MAAM,8CAA8C;AAC1D;;AAIF,MAAIC,YAAU,MAAM,aAAc;AAGlC,SAAO,SAAS,OAAO;GAAE,IAAI,QAAQ;GAAI;GAAO,CAAC;IAEnD;EAAC;EAAW,MAAM;EAAc;EAAU,QAAQ;EAAG,CACtD;;;;CAKD,MAAM,wBAAwB,qBAAqB,qBAAqB,MAAM;;;;CAK9E,SAAS,aAAa,MAA2C;AAE/D,WAAS,QAAQ,OAAU;AAG3B,MAAI,SAAS,SAAS,SAAU;AAGhC,MAAI,MAAM,cAAc,SAAS,MAAM;AACrC,YAAS,MAAM,gBAAgB,OAAU;AACzC,aAAU,QAAQ;AAClB,SAAM,MAAM,wBAAwB;AACpC;;AAIF,wBAAsB,KAAqC;;;;;CAM7D,SAAS,WAAW,MAA2C;AAE7D,WAAS,QAAQ,OAAU;AAG3B,MAAI,SAAS,SAAS,OAAQ;AAG9B,MAAI,MAAM,cAAc,SAAS,MAAM;AACrC,YAAS,MAAM,gBAAgB,OAAU;AACzC,aAAU,QAAQ;AAClB,SAAM,MAAM,wBAAwB;AACpC;;AAIF,sBAAoB,KAAqC;;AAG3D,QAAO;EAAE;EAAO;EAAU;EAAc;EAAY;EAAQ;EAAW"}
|
|
@@ -4,6 +4,7 @@ import * as class_variance_authority_types6 from "class-variance-authority/types
|
|
|
4
4
|
//#region src/modules/inline-edit/lib/variants.d.ts
|
|
5
5
|
declare const inlineEditVariants: (props?: ({
|
|
6
6
|
variant?: "default" | "table" | null | undefined;
|
|
7
|
+
status?: "success" | "error" | "idle" | "pending" | null | undefined;
|
|
7
8
|
} & class_variance_authority_types6.ClassProp) | undefined) => string;
|
|
8
9
|
type InlineEditVariantsProps = VariantProps<typeof inlineEditVariants>;
|
|
9
10
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variants.d.mts","names":[],"sources":["../../../../src/modules/inline-edit/lib/variants.ts"],"sourcesContent":[],"mappings":";;;;cAEa
|
|
1
|
+
{"version":3,"file":"variants.d.mts","names":[],"sources":["../../../../src/modules/inline-edit/lib/variants.ts"],"sourcesContent":[],"mappings":";;;;cAEa,0BAkBX;;;AAlBF,CAAA,GAkBE,+BAAA,CAAA,SAAA,CAAA,GAAA,SAAA,EAAA,GAAA,MAAA;AAEU,KAAA,uBAAA,GAA0B,YAAoB,CAAA,OAAA,kBAAR,CAAA"}
|
|
@@ -2,10 +2,18 @@ import { cva } from "class-variance-authority";
|
|
|
2
2
|
|
|
3
3
|
//#region src/modules/inline-edit/lib/variants.ts
|
|
4
4
|
const inlineEditVariants = cva("", {
|
|
5
|
-
variants: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
variants: {
|
|
6
|
+
variant: {
|
|
7
|
+
default: "",
|
|
8
|
+
table: "min-h-9 px-3 py-1 text-base md:text-sm rounded-none h-full w-full border-none outline-none ring-0 focus:border-0 focus:outline-none focus:ring-0 focus:ring-offset-0 focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0"
|
|
9
|
+
},
|
|
10
|
+
status: {
|
|
11
|
+
idle: "",
|
|
12
|
+
pending: "opacity-70 animate-pulse",
|
|
13
|
+
success: "",
|
|
14
|
+
error: "border-destructive text-destructive"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
9
17
|
defaultVariants: { variant: "default" }
|
|
10
18
|
});
|
|
11
19
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variants.mjs","names":[],"sources":["../../../../src/modules/inline-edit/lib/variants.ts"],"sourcesContent":["import { cva, VariantProps } from \"class-variance-authority\";\n\nexport const inlineEditVariants = cva(\"\", {\n variants: {\n variant: {\n default: \"\",\n table:\n \"min-h-9 px-3 py-1 text-base md:text-sm rounded-none h-full w-full border-none outline-none ring-0 focus:border-0 focus:outline-none focus:ring-0 focus:ring-offset-0 focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n});\n\nexport type InlineEditVariantsProps = VariantProps<typeof inlineEditVariants>;\n"],"mappings":";;;AAEA,MAAa,qBAAqB,IAAI,IAAI;CACxC,UAAU
|
|
1
|
+
{"version":3,"file":"variants.mjs","names":[],"sources":["../../../../src/modules/inline-edit/lib/variants.ts"],"sourcesContent":["import { cva, VariantProps } from \"class-variance-authority\";\n\nexport const inlineEditVariants = cva(\"\", {\n variants: {\n variant: {\n default: \"\",\n table:\n \"min-h-9 px-3 py-1 text-base md:text-sm rounded-none h-full w-full border-none outline-none ring-0 focus:border-0 focus:outline-none focus:ring-0 focus:ring-offset-0 focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0\",\n },\n status: {\n idle: \"\",\n pending: \"opacity-70 animate-pulse\",\n success: \"\",\n error: \"border-destructive text-destructive\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n // status: \"idle\",\n },\n});\n\nexport type InlineEditVariantsProps = VariantProps<typeof inlineEditVariants>;\n"],"mappings":";;;AAEA,MAAa,qBAAqB,IAAI,IAAI;CACxC,UAAU;EACR,SAAS;GACP,SAAS;GACT,OACE;GACH;EACD,QAAQ;GACN,MAAM;GACN,SAAS;GACT,SAAS;GACT,OAAO;GACR;EACF;CACD,iBAAiB,EACf,SAAS,WAEV;CACF,CAAC"}
|
|
@@ -8,19 +8,19 @@ import { AuthClient } from "../../auth/handler/init.mjs";
|
|
|
8
8
|
import "../../../auth/server.mjs";
|
|
9
9
|
import { ProtectedRPCContext, RPCContext } from "./context.server.mjs";
|
|
10
10
|
import "server-cli-only";
|
|
11
|
-
import * as
|
|
11
|
+
import * as _orpc_server0 from "@orpc/server";
|
|
12
12
|
import * as next_dist_server_web_spec_extension_adapters_headers0 from "next/dist/server/web/spec-extension/adapters/headers";
|
|
13
|
-
import * as
|
|
13
|
+
import * as _orpc_contract0 from "@orpc/contract";
|
|
14
14
|
|
|
15
15
|
//#region src/modules/router/handler/init.server.d.ts
|
|
16
16
|
/**
|
|
17
17
|
* Initialize TRPC
|
|
18
18
|
*/
|
|
19
19
|
declare function initRPC<TSchema extends TDatabaseSchema>(): {
|
|
20
|
-
publicProcedure:
|
|
21
|
-
protectedProcedure:
|
|
22
|
-
authMiddleware:
|
|
23
|
-
permissionMiddleware: (permission: Permission) =>
|
|
20
|
+
publicProcedure: _orpc_server0.Builder<RPCContext<TSchema> & Record<never, never>, RPCContext<TSchema>, _orpc_contract0.Schema<unknown, unknown>, _orpc_contract0.Schema<unknown, unknown>, Record<never, never>, Record<never, never>>;
|
|
21
|
+
protectedProcedure: _orpc_server0.BuilderWithMiddlewares<_orpc_server0.MergedInitialContext<RPCContext<TSchema> & Record<never, never>, RPCContext<TSchema> & Record<never, never>, RPCContext<TSchema>>, _orpc_server0.MergedCurrentContext<RPCContext<TSchema>, ProtectedRPCContext<TSchema>>, _orpc_contract0.Schema<unknown, unknown>, _orpc_contract0.Schema<unknown, unknown>, Record<never, never>, Record<never, never>>;
|
|
22
|
+
authMiddleware: _orpc_server0.DecoratedMiddleware<RPCContext<TSchema> & Record<never, never>, ProtectedRPCContext<TSchema>, unknown, any, any, Record<never, never>>;
|
|
23
|
+
permissionMiddleware: (permission: Permission) => _orpc_server0.DecoratedMiddleware<{
|
|
24
24
|
session: {
|
|
25
25
|
session: {
|
|
26
26
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.server.d.mts","names":[],"sources":["../../../../src/modules/router/handler/init.server.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;iBAWgB,wBAAwB;;;;qCAwBI,
|
|
1
|
+
{"version":3,"file":"init.server.d.mts","names":[],"sources":["../../../../src/modules/router/handler/init.server.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;iBAWgB,wBAAwB;;;;qCAwBI,6BAAU;;;;QAxB/B,SAAA,MAAA;QAAiB,SAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAwBI,SAAA,MAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createQueryClient } from "./query-client.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
import "server-cli-only";
|
|
4
4
|
|
|
5
5
|
//#region src/modules/router/lib/query-client.server.d.ts
|
|
@@ -12,7 +12,7 @@ declare const getQueryClient: typeof createQueryClient;
|
|
|
12
12
|
*/
|
|
13
13
|
declare function HydrateClient(props: {
|
|
14
14
|
children: React.ReactNode;
|
|
15
|
-
}):
|
|
15
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
16
16
|
//#endregion
|
|
17
17
|
export { HydrateClient, getQueryClient };
|
|
18
18
|
//# sourceMappingURL=query-client.server.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-client.server.d.mts","names":[],"sources":["../../../../src/modules/router/lib/query-client.server.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AASa,cAAA,cAAc,EAAA,OAAA,iBAA2B;AAKtD;;;iBAAgB,aAAA;YAAiC,KAAA,CAAM;IAAW,
|
|
1
|
+
{"version":3,"file":"query-client.server.d.mts","names":[],"sources":["../../../../src/modules/router/lib/query-client.server.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AASa,cAAA,cAAc,EAAA,OAAA,iBAA2B;AAKtD;;;iBAAgB,aAAA;YAAiC,KAAA,CAAM;IAAW,kBAAA,CAAA,GAAA,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react98 from "react";
|
|
2
2
|
import { DropzoneOptions } from "react-dropzone";
|
|
3
3
|
|
|
4
4
|
//#region src/modules/storage/components/dropzone-context.client.d.ts
|
|
@@ -9,7 +9,7 @@ type DropzoneContextType = {
|
|
|
9
9
|
minSize?: DropzoneOptions["minSize"];
|
|
10
10
|
maxFiles?: DropzoneOptions["maxFiles"];
|
|
11
11
|
};
|
|
12
|
-
declare const DropzoneContext:
|
|
12
|
+
declare const DropzoneContext: react98.Context<DropzoneContextType | undefined>;
|
|
13
13
|
/**
|
|
14
14
|
* Dropzone context hook
|
|
15
15
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime240 from "react/jsx-runtime";
|
|
2
|
+
import * as react99 from "react";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
import { DropEvent, DropzoneOptions, FileRejection } from "react-dropzone";
|
|
5
5
|
|
|
@@ -25,7 +25,7 @@ declare function Dropzone({
|
|
|
25
25
|
className,
|
|
26
26
|
children,
|
|
27
27
|
...props
|
|
28
|
-
}: DropzoneProps):
|
|
28
|
+
}: DropzoneProps): react_jsx_runtime240.JSX.Element;
|
|
29
29
|
/**
|
|
30
30
|
* DropzoneContent
|
|
31
31
|
*/
|
|
@@ -36,7 +36,7 @@ type DropzoneContentProps = {
|
|
|
36
36
|
declare function DropzoneContent({
|
|
37
37
|
children,
|
|
38
38
|
className
|
|
39
|
-
}: DropzoneContentProps): string | number | bigint | true | Iterable<ReactNode> | Promise<string | number | bigint | boolean |
|
|
39
|
+
}: DropzoneContentProps): string | number | bigint | true | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react99.ReactPortal | react99.ReactElement<unknown, string | react99.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime240.JSX.Element | null;
|
|
40
40
|
/**
|
|
41
41
|
* DropzoneEmptyState
|
|
42
42
|
*/
|
|
@@ -47,7 +47,7 @@ type DropzoneEmptyStateProps = {
|
|
|
47
47
|
declare function DropzoneEmptyState({
|
|
48
48
|
children,
|
|
49
49
|
className
|
|
50
|
-
}: DropzoneEmptyStateProps): string | number | bigint | true | Iterable<ReactNode> | Promise<string | number | bigint | boolean |
|
|
50
|
+
}: DropzoneEmptyStateProps): string | number | bigint | true | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react99.ReactPortal | react99.ReactElement<unknown, string | react99.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime240.JSX.Element | null;
|
|
51
51
|
//#endregion
|
|
52
52
|
export { Dropzone, DropzoneContent, DropzoneContentProps, DropzoneEmptyState, DropzoneEmptyStateProps, DropzoneProps };
|
|
53
53
|
//# sourceMappingURL=dropzone.client.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { cn } from "../../../lib/utils/cn.mjs";
|
|
4
|
-
import { Button } from "../../../components/ui/button.mjs";
|
|
5
4
|
import { renderBytes } from "../lib/helpers.mjs";
|
|
5
|
+
import { Button } from "../../../components/ui/button.mjs";
|
|
6
6
|
import { DropzoneContext, useDropzoneContext } from "./dropzone-context.client.mjs";
|
|
7
7
|
import { UploadIcon } from "lucide-react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FileNode } from "../lib/validators.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime243 from "react/jsx-runtime";
|
|
3
3
|
import { ComponentProps } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/modules/storage/components/image-grid.client.d.ts
|
|
@@ -19,8 +19,8 @@ declare function ImageGrid({
|
|
|
19
19
|
moveAction,
|
|
20
20
|
disabled,
|
|
21
21
|
...props
|
|
22
|
-
}: ImageGridProps):
|
|
23
|
-
declare function ImageGridSkeleton(props: ComponentProps<"div">):
|
|
22
|
+
}: ImageGridProps): react_jsx_runtime243.JSX.Element;
|
|
23
|
+
declare function ImageGridSkeleton(props: ComponentProps<"div">): react_jsx_runtime243.JSX.Element;
|
|
24
24
|
//#endregion
|
|
25
25
|
export { ImageGrid, ImageGridSkeleton };
|
|
26
26
|
//# sourceMappingURL=image-grid.client.d.mts.map
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { Icons } from "../../../components/common/icons.mjs";
|
|
4
4
|
import { cn } from "../../../lib/utils/cn.mjs";
|
|
5
|
+
import { getFileUrl, imageLoader } from "../lib/helpers.mjs";
|
|
5
6
|
import { Skeleton } from "../../../components/ui/skeleton.mjs";
|
|
6
7
|
import { Button } from "../../../components/ui/button.mjs";
|
|
7
8
|
import { Input } from "../../../components/ui/input.mjs";
|
|
@@ -10,7 +11,6 @@ import { useAction } from "../../../lib/hooks/use-action.mjs";
|
|
|
10
11
|
import { arrayMove } from "../../../lib/utils/array-move.mjs";
|
|
11
12
|
import { Card } from "../../../components/ui/card.mjs";
|
|
12
13
|
import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from "../../../components/ui/carousel.mjs";
|
|
13
|
-
import { getFileUrl, imageLoader } from "../lib/helpers.mjs";
|
|
14
14
|
import { useUploadZone } from "./upload-zone-context.client.mjs";
|
|
15
15
|
import { GripIcon, UploadIcon } from "lucide-react";
|
|
16
16
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -114,7 +114,7 @@ function ImageGrid({ nodes, moveAction, disabled, ...props }) {
|
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
116
|
function ImageGridItem({ node, index, setCurrent }) {
|
|
117
|
-
const {
|
|
117
|
+
const { uploadClient } = useUploadZone();
|
|
118
118
|
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id: node.id });
|
|
119
119
|
return /* @__PURE__ */ jsx(Card, {
|
|
120
120
|
id: node.id,
|
|
@@ -149,7 +149,7 @@ function ImageGridItem({ node, index, setCurrent }) {
|
|
|
149
149
|
type: "button",
|
|
150
150
|
variant: "destructive",
|
|
151
151
|
size: "icon",
|
|
152
|
-
onClick: () =>
|
|
152
|
+
onClick: () => uploadClient.deleteFiles([node.id]),
|
|
153
153
|
className: "absolute left-2 top-2 hidden p-1 group-hover:flex",
|
|
154
154
|
children: /* @__PURE__ */ jsx(Icons.trash, { className: "size-4" })
|
|
155
155
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-grid.client.mjs","names":["Image"],"sources":["../../../../src/modules/storage/components/image-grid.client.tsx"],"sourcesContent":["\"use client\";\n\nimport { Icons } from \"@/components/common/icons\";\nimport { Button } from \"@/components/ui/button\";\nimport { Card } from \"@/components/ui/card\";\nimport {\n Carousel,\n CarouselContent,\n CarouselItem,\n CarouselNext,\n CarouselPrevious,\n} from \"@/components/ui/carousel\";\nimport { Dialog, DialogContent, DialogTrigger } from \"@/components/ui/dialog.client\";\nimport { Input } from \"@/components/ui/input\";\nimport { Skeleton } from \"@/components/ui/skeleton\";\nimport { useAction } from \"@/lib/entry.client\";\nimport { arrayMove } from \"@/lib/utils/array-move\";\nimport { cn } from \"@/lib/utils/cn\";\nimport {\n closestCenter,\n DndContext,\n DragEndEvent,\n KeyboardSensor,\n PointerSensor,\n useDroppable,\n useSensor,\n useSensors,\n} from \"@dnd-kit/core\";\nimport {\n rectSortingStrategy,\n SortableContext,\n sortableKeyboardCoordinates,\n useSortable,\n} from \"@dnd-kit/sortable\";\nimport { CSS } from \"@dnd-kit/utilities\";\nimport { GripIcon, UploadIcon } from \"lucide-react\";\nimport Image from \"next/image\";\nimport React, { ComponentProps } from \"react\";\nimport { getFileUrl, imageLoader } from \"../lib/helpers\";\nimport { FileNode } from \"../lib/validators\";\nimport { useUploadZone } from \"./upload-zone-context.client\";\n\n/**\n * Image Grid\n */\ntype ImageGridProps = ComponentProps<\"div\"> & {\n nodes: FileNode[];\n disabled?: boolean;\n moveAction: (params: { fromIndex: number; toIndex: number }) => Promise<void>;\n};\n\nexport function ImageGrid({ nodes, moveAction, disabled, ...props }: ImageGridProps) {\n const { onUpload, updateData, invalidateQuery } = useUploadZone();\n\n const images = nodes.flatMap((node) => ({ ...node, url: getFileUrl(node.id) }));\n\n const [current, setCurrent] = React.useState<number>(0);\n\n const { setNodeRef } = useDroppable({ id: \"image-grid\" });\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, {\n coordinateGetter: sortableKeyboardCoordinates,\n }),\n );\n\n const moveMuration = useAction({\n mutationFn: async ({ active, over }: DragEndEvent) => {\n if (!moveAction) return Promise.resolve();\n\n const activeId = active.id;\n const overId = over?.id;\n if (!activeId || !overId || activeId === overId) return Promise.resolve();\n\n const fromIndex = images.findIndex((image) => image.id === activeId);\n const toIndex = images.findIndex((image) => image.id === overId);\n\n await updateData((prev) => arrayMove(prev, { fromIndex, toIndex }));\n await moveAction({ fromIndex, toIndex });\n },\n onSuccess: async () => {\n setCurrent(0);\n await invalidateQuery();\n },\n onError: (error) => {\n console.error(\"Error moving image:\", error);\n },\n });\n\n return (\n <Dialog {...props}>\n <DndContext\n sensors={sensors}\n collisionDetection={closestCenter}\n onDragEnd={moveMuration.mutate}\n >\n <div\n ref={setNodeRef}\n className=\"grid grid-cols-[repeat(auto-fill,minmax(10rem,1fr))] gap-5\"\n >\n <SortableContext items={images.map((image) => image.id)} strategy={rectSortingStrategy}>\n {images.map((node, index) => (\n <ImageGridItem key={node.id} node={node} index={index} setCurrent={setCurrent} />\n ))}\n\n {!disabled && (\n <label className=\"border-muted-foreground bg-muted hover:border-primary relative flex aspect-square w-full cursor-pointer flex-col items-center justify-center rounded-lg border border-dashed\">\n <UploadIcon className=\"h-8 w-8\" />\n <Input\n type=\"file\"\n accept=\"image/jpeg, image/png, image/webp, image/gif\"\n className=\"absolute inset-0 z-10 h-full w-full cursor-pointer opacity-0\"\n multiple\n onChange={(e) => {\n if (!e.target.files) return;\n return Array.from(e.target.files).map(onUpload);\n }}\n />\n </label>\n )}\n </SortableContext>\n </div>\n </DndContext>\n\n <Carousel className=\"w-full\" opts={{ startIndex: current }}>\n <DialogContent className=\"border-none bg-transparent p-0 shadow-none md:max-w-[80vw] xl:max-w-[60vw]\">\n <CarouselContent className=\"md:max-h-[80vh]\">\n {images.map(({ id, url }) => (\n <CarouselItem key={id} className=\"overflow-hidden rounded-xl\">\n <Image\n src={url}\n alt=\"Image Preview\"\n width={1920}\n height={1080}\n className=\"h-full w-full rounded-xl object-contain\"\n loader={imageLoader}\n />\n </CarouselItem>\n ))}\n </CarouselContent>\n <CarouselPrevious />\n <CarouselNext />\n </DialogContent>\n </Carousel>\n </Dialog>\n );\n}\n\n/**\n * Image Grid Item\n */\ntype ImageGridItemProps = {\n node: FileNode & { url: string };\n index: number;\n setCurrent: React.Dispatch<React.SetStateAction<number>>;\n};\n\nfunction ImageGridItem({ node, index, setCurrent }: ImageGridItemProps) {\n const { deleteMutation } = useUploadZone();\n\n const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id: node.id });\n\n return (\n <Card\n id={node.id}\n ref={setNodeRef}\n style={{\n transform: CSS.Transform.toString(transform),\n transition,\n }}\n className={cn(\"group relative aspect-square w-full\", node.isPending && \"opacity-30\")}\n >\n {!node.isPending ? (\n <>\n <DialogTrigger onClick={() => setCurrent(index)}>\n <Image\n src={node.url}\n alt=\"Image Preview\"\n width={100}\n height={100}\n className=\"bg-muted absolute inset-0 h-full w-full cursor-pointer rounded-lg object-contain\"\n loader={imageLoader}\n />\n </DialogTrigger>\n\n <Button\n {...attributes}\n {...listeners}\n type=\"button\"\n variant=\"secondary\"\n size=\"icon\"\n className=\"absolute right-2 top-2 hidden p-1 group-hover:flex\"\n >\n <GripIcon className=\"size-4\" />\n </Button>\n\n <Button\n type=\"button\"\n variant=\"destructive\"\n size=\"icon\"\n onClick={() => deleteMutation({ ids: [node.id] })}\n className=\"absolute left-2 top-2 hidden p-1 group-hover:flex\"\n >\n <Icons.trash className=\"size-4\" />\n </Button>\n </>\n ) : (\n <Skeleton className=\"absolute inset-0 h-full w-full rounded-lg\" />\n )}\n </Card>\n );\n}\n\nexport function ImageGridSkeleton(props: ComponentProps<\"div\">) {\n return (\n <div\n {...props}\n className={cn(\"grid grid-cols-[repeat(auto-fill,minmax(10rem,1fr))] gap-5\", props.className)}\n >\n {Array.from({ length: 12 }).map((_, index) => (\n <Skeleton key={index} className=\"aspect-square w-full rounded-lg\" />\n ))}\n </div>\n );\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"image-grid.client.mjs","names":["Image"],"sources":["../../../../src/modules/storage/components/image-grid.client.tsx"],"sourcesContent":["\"use client\";\n\nimport { Icons } from \"@/components/common/icons\";\nimport { Button } from \"@/components/ui/button\";\nimport { Card } from \"@/components/ui/card\";\nimport {\n Carousel,\n CarouselContent,\n CarouselItem,\n CarouselNext,\n CarouselPrevious,\n} from \"@/components/ui/carousel\";\nimport { Dialog, DialogContent, DialogTrigger } from \"@/components/ui/dialog.client\";\nimport { Input } from \"@/components/ui/input\";\nimport { Skeleton } from \"@/components/ui/skeleton\";\nimport { useAction } from \"@/lib/entry.client\";\nimport { arrayMove } from \"@/lib/utils/array-move\";\nimport { cn } from \"@/lib/utils/cn\";\nimport {\n closestCenter,\n DndContext,\n DragEndEvent,\n KeyboardSensor,\n PointerSensor,\n useDroppable,\n useSensor,\n useSensors,\n} from \"@dnd-kit/core\";\nimport {\n rectSortingStrategy,\n SortableContext,\n sortableKeyboardCoordinates,\n useSortable,\n} from \"@dnd-kit/sortable\";\nimport { CSS } from \"@dnd-kit/utilities\";\nimport { GripIcon, UploadIcon } from \"lucide-react\";\nimport Image from \"next/image\";\nimport React, { ComponentProps } from \"react\";\nimport { getFileUrl, imageLoader } from \"../lib/helpers\";\nimport { FileNode } from \"../lib/validators\";\nimport { useUploadZone } from \"./upload-zone-context.client\";\n\n/**\n * Image Grid\n */\ntype ImageGridProps = ComponentProps<\"div\"> & {\n nodes: FileNode[];\n disabled?: boolean;\n moveAction: (params: { fromIndex: number; toIndex: number }) => Promise<void>;\n};\n\nexport function ImageGrid({ nodes, moveAction, disabled, ...props }: ImageGridProps) {\n const { onUpload, updateData, invalidateQuery } = useUploadZone();\n\n const images = nodes.flatMap((node) => ({ ...node, url: getFileUrl(node.id) }));\n\n const [current, setCurrent] = React.useState<number>(0);\n\n const { setNodeRef } = useDroppable({ id: \"image-grid\" });\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, {\n coordinateGetter: sortableKeyboardCoordinates,\n }),\n );\n\n const moveMuration = useAction({\n mutationFn: async ({ active, over }: DragEndEvent) => {\n if (!moveAction) return Promise.resolve();\n\n const activeId = active.id;\n const overId = over?.id;\n if (!activeId || !overId || activeId === overId) return Promise.resolve();\n\n const fromIndex = images.findIndex((image) => image.id === activeId);\n const toIndex = images.findIndex((image) => image.id === overId);\n\n await updateData((prev) => arrayMove(prev, { fromIndex, toIndex }));\n await moveAction({ fromIndex, toIndex });\n },\n onSuccess: async () => {\n setCurrent(0);\n await invalidateQuery();\n },\n onError: (error) => {\n console.error(\"Error moving image:\", error);\n },\n });\n\n return (\n <Dialog {...props}>\n <DndContext\n sensors={sensors}\n collisionDetection={closestCenter}\n onDragEnd={moveMuration.mutate}\n >\n <div\n ref={setNodeRef}\n className=\"grid grid-cols-[repeat(auto-fill,minmax(10rem,1fr))] gap-5\"\n >\n <SortableContext items={images.map((image) => image.id)} strategy={rectSortingStrategy}>\n {images.map((node, index) => (\n <ImageGridItem key={node.id} node={node} index={index} setCurrent={setCurrent} />\n ))}\n\n {!disabled && (\n <label className=\"border-muted-foreground bg-muted hover:border-primary relative flex aspect-square w-full cursor-pointer flex-col items-center justify-center rounded-lg border border-dashed\">\n <UploadIcon className=\"h-8 w-8\" />\n <Input\n type=\"file\"\n accept=\"image/jpeg, image/png, image/webp, image/gif\"\n className=\"absolute inset-0 z-10 h-full w-full cursor-pointer opacity-0\"\n multiple\n onChange={(e) => {\n if (!e.target.files) return;\n return Array.from(e.target.files).map(onUpload);\n }}\n />\n </label>\n )}\n </SortableContext>\n </div>\n </DndContext>\n\n <Carousel className=\"w-full\" opts={{ startIndex: current }}>\n <DialogContent className=\"border-none bg-transparent p-0 shadow-none md:max-w-[80vw] xl:max-w-[60vw]\">\n <CarouselContent className=\"md:max-h-[80vh]\">\n {images.map(({ id, url }) => (\n <CarouselItem key={id} className=\"overflow-hidden rounded-xl\">\n <Image\n src={url}\n alt=\"Image Preview\"\n width={1920}\n height={1080}\n className=\"h-full w-full rounded-xl object-contain\"\n loader={imageLoader}\n />\n </CarouselItem>\n ))}\n </CarouselContent>\n <CarouselPrevious />\n <CarouselNext />\n </DialogContent>\n </Carousel>\n </Dialog>\n );\n}\n\n/**\n * Image Grid Item\n */\ntype ImageGridItemProps = {\n node: FileNode & { url: string };\n index: number;\n setCurrent: React.Dispatch<React.SetStateAction<number>>;\n};\n\nfunction ImageGridItem({ node, index, setCurrent }: ImageGridItemProps) {\n const { uploadClient } = useUploadZone();\n\n const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id: node.id });\n\n return (\n <Card\n id={node.id}\n ref={setNodeRef}\n style={{\n transform: CSS.Transform.toString(transform),\n transition,\n }}\n className={cn(\"group relative aspect-square w-full\", node.isPending && \"opacity-30\")}\n >\n {!node.isPending ? (\n <>\n <DialogTrigger onClick={() => setCurrent(index)}>\n <Image\n src={node.url}\n alt=\"Image Preview\"\n width={100}\n height={100}\n className=\"bg-muted absolute inset-0 h-full w-full cursor-pointer rounded-lg object-contain\"\n loader={imageLoader}\n />\n </DialogTrigger>\n\n <Button\n {...attributes}\n {...listeners}\n type=\"button\"\n variant=\"secondary\"\n size=\"icon\"\n className=\"absolute right-2 top-2 hidden p-1 group-hover:flex\"\n >\n <GripIcon className=\"size-4\" />\n </Button>\n\n <Button\n type=\"button\"\n variant=\"destructive\"\n size=\"icon\"\n onClick={() => uploadClient.deleteFiles([node.id])}\n className=\"absolute left-2 top-2 hidden p-1 group-hover:flex\"\n >\n <Icons.trash className=\"size-4\" />\n </Button>\n </>\n ) : (\n <Skeleton className=\"absolute inset-0 h-full w-full rounded-lg\" />\n )}\n </Card>\n );\n}\n\nexport function ImageGridSkeleton(props: ComponentProps<\"div\">) {\n return (\n <div\n {...props}\n className={cn(\"grid grid-cols-[repeat(auto-fill,minmax(10rem,1fr))] gap-5\", props.className)}\n >\n {Array.from({ length: 12 }).map((_, index) => (\n <Skeleton key={index} className=\"aspect-square w-full rounded-lg\" />\n ))}\n </div>\n );\n}\n"],"mappings":"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"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FileNode, Node
|
|
1
|
+
import { FileNode, Node } from "../lib/validators.mjs";
|
|
2
|
+
import { UploadClient } from "../lib/create-upload.client.mjs";
|
|
2
3
|
import React from "react";
|
|
3
4
|
|
|
4
5
|
//#region src/modules/storage/components/upload-zone-context.client.d.ts
|
|
@@ -7,16 +8,7 @@ import React from "react";
|
|
|
7
8
|
* Upload Zone Context Value
|
|
8
9
|
*/
|
|
9
10
|
type UploadZoneContextValue = {
|
|
10
|
-
|
|
11
|
-
id: string;
|
|
12
|
-
presignedUrl: string;
|
|
13
|
-
}>;
|
|
14
|
-
confirmMutation: (params: {
|
|
15
|
-
id: string;
|
|
16
|
-
}) => Promise<Node>;
|
|
17
|
-
deleteMutation: (params: {
|
|
18
|
-
ids: string[];
|
|
19
|
-
}) => Promise<unknown>;
|
|
11
|
+
uploadClient: UploadClient;
|
|
20
12
|
updateData: (newValue: FileNode[] | ((oldValue: FileNode[]) => FileNode[])) => Promise<void>;
|
|
21
13
|
invalidateQuery: () => Promise<void> | void;
|
|
22
14
|
onUpload: (file: File) => Promise<Node>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-zone-context.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/upload-zone-context.client.tsx"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upload-zone-context.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/upload-zone-context.client.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AASA;AACgB,KADJ,sBAAA,GACI;EACS,YAAA,EADT,YACS;EAAyB,UAAA,EAAA,CAAA,QAAA,EAAzB,QAAyB,EAAA,GAAA,CAAA,CAAA,QAAA,EAAA,QAAA,EAAA,EAAA,GAAe,QAAf,EAAA,CAAA,EAAA,GAA+B,OAA/B,CAAA,IAAA,CAAA;EAAe,eAAA,EAAA,GAAA,GACxC,OADwC,CAAA,IAAA,CAAA,GAAA,IAAA;EAAgB,QAAA,EAAA,CAAA,IAAA,EAE9D,IAF8D,EAAA,GAErD,OAFqD,CAE7C,IAF6C,CAAA;CACxD;;;;AACU,cAMtB,iBANsB,EAML,KAAA,CAAA,OANK,CAML,sBANK,CAAA;AAMnC;AAKA;;iBAAgB,aAAA,CAAA,GAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-zone-context.client.mjs","names":[],"sources":["../../../../src/modules/storage/components/upload-zone-context.client.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { FileNode, Node
|
|
1
|
+
{"version":3,"file":"upload-zone-context.client.mjs","names":[],"sources":["../../../../src/modules/storage/components/upload-zone-context.client.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { UploadClient } from \"../lib/create-upload.client\";\nimport { FileNode, Node } from \"../lib/validators\";\n\n/**\n * Upload Zone Context Value\n */\nexport type UploadZoneContextValue = {\n uploadClient: UploadClient;\n updateData: (newValue: FileNode[] | ((oldValue: FileNode[]) => FileNode[])) => Promise<void>;\n invalidateQuery: () => Promise<void> | void;\n onUpload: (file: File) => Promise<Node>;\n};\n\n/**\n * Upload Zone Context\n */\nexport const UploadZoneContext = React.createContext({} as UploadZoneContextValue);\n\n/**\n * Upload Zone Hook\n */\nexport function useUploadZone() {\n const context = React.useContext(UploadZoneContext);\n if (!context) {\n throw new Error(\"useUploadZone must be used within an UploadZoneProvider\");\n }\n return context;\n}\n"],"mappings":";;;;;;;;AAmBA,MAAa,oBAAoB,MAAM,cAAc,EAAE,CAA2B;;;;AAKlF,SAAgB,gBAAgB;CAC9B,MAAM,UAAU,MAAM,WAAW,kBAAkB;AACnD,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,0DAA0D;AAE5E,QAAO"}
|
|
@@ -1,45 +1,22 @@
|
|
|
1
|
-
import { Node,
|
|
2
|
-
import
|
|
1
|
+
import { Node, UploadFileSchema } from "../lib/validators.mjs";
|
|
2
|
+
import { UploadClient, UploadHooks } from "../lib/create-upload.client.mjs";
|
|
3
|
+
import * as react_jsx_runtime245 from "react/jsx-runtime";
|
|
3
4
|
import { ComponentProps } from "react";
|
|
4
5
|
|
|
5
6
|
//#region src/modules/storage/components/upload-zone.client.d.ts
|
|
6
7
|
type UploadZoneProps = ComponentProps<"div"> & {
|
|
7
|
-
namespace: string;
|
|
8
|
-
parentId: string | null;
|
|
9
|
-
options?: Pick<UploadFileSchema, "readonly" | "hidden" | "mode">;
|
|
10
8
|
queryKey: readonly unknown[];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}>;
|
|
15
|
-
onPresignStarted?: (file: PresignFileSchema) => Promise<void> | void;
|
|
16
|
-
onPresignCompleted?: (data: {
|
|
17
|
-
id: string;
|
|
18
|
-
presignedUrl: string;
|
|
19
|
-
}) => Promise<void> | void;
|
|
20
|
-
confirmAction: (params: {
|
|
21
|
-
id: string;
|
|
22
|
-
}) => Promise<Node>;
|
|
23
|
-
onConfirmStarted?: (id: string) => Promise<void> | void;
|
|
24
|
-
onConfirmCompleted?: (node: Node) => Promise<void> | void;
|
|
25
|
-
deleteAction: (params: {
|
|
26
|
-
ids: string[];
|
|
27
|
-
}) => Promise<unknown>;
|
|
9
|
+
variables: Pick<UploadFileSchema, "namespace" | "parentId" | "mode" | "hidden" | "readonly">;
|
|
10
|
+
uploadClient: UploadClient;
|
|
11
|
+
uploadHooks?: UploadHooks;
|
|
28
12
|
onUploadCompleted?: (node: Node) => Promise<void> | void;
|
|
29
13
|
onUploadFailed?: (error: unknown) => Promise<void> | void;
|
|
30
14
|
};
|
|
31
15
|
declare function UploadZone({
|
|
32
|
-
|
|
33
|
-
parentId,
|
|
34
|
-
options,
|
|
16
|
+
variables,
|
|
35
17
|
queryKey,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
deleteAction,
|
|
39
|
-
onPresignStarted,
|
|
40
|
-
onPresignCompleted,
|
|
41
|
-
onConfirmStarted,
|
|
42
|
-
onConfirmCompleted,
|
|
18
|
+
uploadClient,
|
|
19
|
+
uploadHooks,
|
|
43
20
|
onUploadCompleted,
|
|
44
21
|
onUploadFailed,
|
|
45
22
|
children,
|
|
@@ -47,7 +24,7 @@ declare function UploadZone({
|
|
|
47
24
|
onDragOver,
|
|
48
25
|
onDragLeave,
|
|
49
26
|
...props
|
|
50
|
-
}: UploadZoneProps):
|
|
27
|
+
}: UploadZoneProps): react_jsx_runtime245.JSX.Element;
|
|
51
28
|
//#endregion
|
|
52
29
|
export { UploadZone, UploadZoneProps };
|
|
53
30
|
//# sourceMappingURL=upload-zone.client.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-zone.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/upload-zone.client.tsx"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upload-zone.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/upload-zone.client.tsx"],"sourcesContent":[],"mappings":";;;;;;KAYY,eAAA,GAAkB;;aAGjB,KAAK;EAHN,YAAA,EAII,YAJW;EAAG,WAAA,CAAA,EAKd,WALc;EAGZ,iBAAA,CAAA,EAAA,CAAA,IAAA,EAIW,IAJX,EAAA,GAIoB,OAJpB,CAAA,IAAA,CAAA,GAAA,IAAA;EAAL,cAAA,CAAA,EAAA,CAAA,KAAA,EAAA,OAAA,EAAA,GAK0B,OAL1B,CAAA,IAAA,CAAA,GAAA,IAAA;CACG;AACA,iBAMA,UAAA,CANA;EAAA,SAAA;EAAA,QAAA;EAAA,YAAA;EAAA,WAAA;EAAA,iBAAA;EAAA,cAAA;EAAA,QAAA;EAAA,SAAA;EAAA,UAAA;EAAA,WAAA;EAAA,GAAA;AAAA,CAAA,EAkBb,eAlBa,CAAA,EAkBE,oBAAA,CAAA,GAAA,CAAA,OAlBF"}
|