@tulip-systems/core 0.7.0 → 0.8.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/dist/auth/server.d.mts +3 -3
- package/dist/auth/server.mjs +3 -3
- package/dist/components/editor/components/editor.client.d.mts +4 -3
- package/dist/components/editor/components/editor.client.d.mts.map +1 -1
- package/dist/components/editor/components/editor.client.mjs +5 -2
- package/dist/components/editor/components/editor.client.mjs.map +1 -1
- package/dist/components/editor/extensions/file-handler/extension.d.mts +4 -4
- package/dist/components/editor/extensions/file-handler/extension.d.mts.map +1 -1
- package/dist/components/editor/extensions/file-handler/extension.mjs.map +1 -1
- package/dist/components/editor/extensions/file-handler/strategy.d.mts +4 -6
- package/dist/components/editor/extensions/file-handler/strategy.d.mts.map +1 -1
- package/dist/components/editor/extensions/file-handler/strategy.mjs +11 -11
- package/dist/components/editor/extensions/file-handler/strategy.mjs.map +1 -1
- package/dist/components/editor/extensions/file-handler/utils.mjs +1 -1
- package/dist/components/editor/extensions/file-handler/utils.mjs.map +1 -1
- package/dist/components/editor/extensions/image/extension.mjs +9 -9
- package/dist/components/editor/extensions/image/extension.mjs.map +1 -1
- package/dist/components/editor/lib/constants.d.mts +1 -1
- package/dist/components/editor/lib/constants.mjs +1 -1
- package/dist/components/editor/lib/extensions.d.mts +1 -1
- package/dist/components/editor/lib/helpers.d.mts +11 -3
- package/dist/components/editor/lib/helpers.d.mts.map +1 -1
- package/dist/components/editor/lib/helpers.mjs +27 -13
- package/dist/components/editor/lib/helpers.mjs.map +1 -1
- package/dist/components/ui/badge.d.mts +1 -1
- package/dist/components/ui/button-group.d.mts +1 -1
- package/dist/components/ui/button.d.mts +2 -2
- package/dist/components/ui/combobox-dropdown.client.mjs +1 -0
- package/dist/components/ui/combobox-dropdown.client.mjs.map +1 -1
- package/dist/components/ui/combobox.client.mjs +1 -1
- package/dist/components/ui/combobox.client.mjs.map +1 -1
- package/dist/components/ui/field.client.d.mts +1 -1
- package/dist/components/ui/item.d.mts +1 -1
- package/dist/components.d.mts +2 -2
- package/dist/components.mjs +2 -2
- package/dist/config/server.d.mts +1 -3
- package/dist/config/server.mjs +1 -4
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +1 -1
- package/dist/data-tables/client.d.mts +2 -1
- package/dist/data-tables/client.mjs +2 -1
- package/dist/data-tables.d.mts +1 -1
- package/dist/database/client.d.mts +1 -0
- package/dist/database/client.mjs +1 -0
- package/dist/database/server.d.mts +2 -0
- package/dist/database/server.mjs +3 -0
- package/dist/database.d.mts +3 -0
- package/dist/database.mjs +3 -0
- package/dist/emails/client.d.mts +1 -0
- package/dist/emails/client.mjs +1 -0
- package/dist/emails/server.d.mts +2 -0
- package/dist/emails/server.mjs +3 -0
- package/dist/emails.d.mts +1 -0
- package/dist/emails.mjs +1 -0
- package/dist/lib/utils/markdown.d.mts +10 -0
- package/dist/lib/utils/markdown.d.mts.map +1 -0
- package/dist/lib/utils/markdown.mjs +15 -0
- package/dist/lib/utils/markdown.mjs.map +1 -0
- package/dist/lib/utils/url.mjs +2 -1
- package/dist/lib/utils/url.mjs.map +1 -1
- package/dist/lib/utils/user-agent.mjs +15 -0
- package/dist/lib/utils/user-agent.mjs.map +1 -1
- package/dist/lib.d.mts +2 -2
- package/dist/lib.mjs +2 -2
- package/dist/modules/auth/components/create-first-user-guard.server.d.mts +16 -0
- package/dist/modules/auth/components/create-first-user-guard.server.d.mts.map +1 -0
- package/dist/modules/auth/components/create-first-user-guard.server.mjs +16 -0
- package/dist/modules/auth/components/create-first-user-guard.server.mjs.map +1 -0
- package/dist/modules/auth/components/guard.server.d.mts +2 -2
- package/dist/modules/auth/components/guard.server.mjs +1 -1
- package/dist/modules/auth/components/guard.server.mjs.map +1 -1
- package/dist/modules/auth/db/schema.d.mts +1 -1
- package/dist/modules/auth/db/schema.mjs +2 -2
- package/dist/modules/auth/handler/create-client.client.d.mts +4838 -229
- package/dist/modules/auth/handler/create-client.client.d.mts.map +1 -1
- package/dist/modules/auth/handler/create-client.client.mjs.map +1 -1
- package/dist/modules/auth/handler/proxy.server.mjs +2 -2
- package/dist/modules/auth/handler/proxy.server.mjs.map +1 -1
- package/dist/modules/auth/handler/route.server.d.mts +2 -2
- package/dist/modules/auth/handler/route.server.d.mts.map +1 -1
- package/dist/modules/auth/handler/route.server.mjs.map +1 -1
- package/dist/modules/auth/handler/{init.d.mts → service.server.d.mts} +322 -90
- package/dist/modules/auth/handler/service.server.d.mts.map +1 -0
- package/dist/modules/auth/handler/{init.mjs → service.server.mjs} +19 -8
- package/dist/modules/auth/handler/service.server.mjs.map +1 -0
- package/dist/modules/auth/hooks/use-session.d.mts +9 -4
- package/dist/modules/auth/hooks/use-session.d.mts.map +1 -1
- package/dist/modules/auth/lib/helpers.server.d.mts +1 -1
- package/dist/modules/auth/lib/permissions.d.mts +1 -1
- package/dist/modules/auth/lib/validators.mjs +1 -1
- package/dist/modules/config/lib/context.d.mts +9 -10
- package/dist/modules/config/lib/context.d.mts.map +1 -1
- package/dist/modules/config/lib/context.mjs.map +1 -1
- package/dist/modules/data-tables/lib/converters/search.d.mts +1 -1
- package/dist/modules/data-tables/lib/converters/sorting.d.mts +1 -1
- package/dist/modules/data-tables/server/get-data.server.d.mts +3 -3
- package/dist/modules/data-tables/server/get-data.server.mjs +1 -1
- package/dist/modules/data-tables/server/get-data.server.mjs.map +1 -1
- package/dist/modules/data-tables/strategies/infinite/strategy.d.mts +1 -1
- package/dist/modules/data-tables/strategies/infinite/strategy.mjs +3 -0
- package/dist/modules/data-tables/strategies/infinite/strategy.mjs.map +1 -1
- package/dist/modules/data-tables/tables/data-table/components/row.mjs +5 -15
- package/dist/modules/data-tables/tables/data-table/components/row.mjs.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/body.mjs +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/body.mjs.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/row.client.mjs +13 -23
- package/dist/modules/data-tables/tables/inline-table/components/row.client.mjs.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/table.d.mts +1 -0
- package/dist/modules/data-tables/tables/inline-table/components/table.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/table.mjs +2 -1
- package/dist/modules/data-tables/tables/inline-table/components/table.mjs.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts +5 -1
- package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/hooks/context.client.mjs +2 -1
- package/dist/modules/data-tables/tables/inline-table/hooks/context.client.mjs.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.d.mts +30 -0
- package/dist/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.d.mts.map +1 -0
- package/dist/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.mjs +77 -9
- package/dist/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.mjs.map +1 -1
- package/dist/modules/{config/db → database/lib}/helpers.d.mts +2 -2
- package/dist/modules/database/lib/helpers.d.mts.map +1 -0
- package/dist/modules/{config/db → database/lib}/helpers.mjs +1 -1
- package/dist/modules/database/lib/helpers.mjs.map +1 -0
- package/dist/modules/database/lib/service.server.d.mts +34 -0
- package/dist/modules/database/lib/service.server.d.mts.map +1 -0
- package/dist/modules/database/lib/service.server.mjs +24 -0
- package/dist/modules/database/lib/service.server.mjs.map +1 -0
- package/dist/modules/{config/db → database/lib}/types.d.mts +1 -1
- package/dist/modules/database/lib/types.d.mts.map +1 -0
- package/dist/modules/emails/lib/service.server.d.mts +29 -0
- package/dist/modules/emails/lib/service.server.d.mts.map +1 -0
- package/dist/modules/emails/lib/service.server.mjs +21 -0
- package/dist/modules/emails/lib/service.server.mjs.map +1 -0
- package/dist/modules/inline-edit/components/date-input.client.mjs +1 -1
- package/dist/modules/inline-edit/components/date-input.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/date-picker.client.mjs +1 -0
- package/dist/modules/inline-edit/components/date-picker.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/date-time.client.mjs +1 -0
- package/dist/modules/inline-edit/components/date-time.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/editor.client.mjs +1 -0
- package/dist/modules/inline-edit/components/editor.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/input-recipient.client.mjs +1 -0
- package/dist/modules/inline-edit/components/input-recipient.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/input-toggle.client.mjs +1 -0
- package/dist/modules/inline-edit/components/input-toggle.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/input.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/input.client.mjs +3 -0
- package/dist/modules/inline-edit/components/input.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/select.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/select.client.mjs +1 -0
- package/dist/modules/inline-edit/components/select.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/switch.client.mjs +1 -0
- package/dist/modules/inline-edit/components/switch.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/toggle.client.mjs +1 -0
- package/dist/modules/inline-edit/components/toggle.client.mjs.map +1 -1
- package/dist/modules/inline-edit/lib/variants.d.mts +1 -1
- package/dist/modules/router/handler/context.server.d.mts +12 -10
- package/dist/modules/router/handler/context.server.d.mts.map +1 -1
- package/dist/modules/router/handler/init.server.d.mts +13 -11
- package/dist/modules/router/handler/init.server.d.mts.map +1 -1
- package/dist/modules/router/handler/init.server.mjs +2 -2
- package/dist/modules/router/handler/init.server.mjs.map +1 -1
- package/dist/modules/router/handler/route.server.d.mts +1 -1
- package/dist/modules/storage/components/dropzone.client.d.mts +2 -2
- package/dist/modules/storage/components/dropzone.client.d.mts.map +1 -1
- package/dist/modules/storage/components/dropzone.client.mjs.map +1 -1
- package/dist/modules/storage/components/image-grid.client.d.mts +3 -3
- package/dist/modules/storage/components/image-grid.client.d.mts.map +1 -1
- package/dist/modules/storage/components/image-grid.client.mjs +20 -22
- package/dist/modules/storage/components/image-grid.client.mjs.map +1 -1
- package/dist/modules/storage/components/image.client.d.mts +8 -0
- package/dist/modules/storage/components/image.client.d.mts.map +1 -0
- package/dist/modules/storage/components/image.client.mjs +17 -0
- package/dist/modules/storage/components/image.client.mjs.map +1 -0
- package/dist/modules/storage/components/upload-button.client.d.mts +12 -0
- package/dist/modules/storage/components/upload-button.client.d.mts.map +1 -0
- package/dist/modules/storage/components/upload-button.client.mjs +34 -0
- package/dist/modules/storage/components/upload-button.client.mjs.map +1 -0
- package/dist/modules/storage/components/upload-zone-context.client.d.mts +5 -5
- package/dist/modules/storage/components/upload-zone-context.client.d.mts.map +1 -1
- package/dist/modules/storage/components/upload-zone-context.client.mjs +2 -2
- package/dist/modules/storage/components/upload-zone-context.client.mjs.map +1 -1
- package/dist/modules/storage/components/upload-zone.client.d.mts +4 -4
- package/dist/modules/storage/components/upload-zone.client.d.mts.map +1 -1
- package/dist/modules/storage/components/upload-zone.client.mjs +16 -9
- package/dist/modules/storage/components/upload-zone.client.mjs.map +1 -1
- package/dist/modules/storage/lib/constants.d.mts +1 -5
- package/dist/modules/storage/lib/constants.d.mts.map +1 -1
- package/dist/modules/storage/lib/constants.mjs +1 -13
- package/dist/modules/storage/lib/constants.mjs.map +1 -1
- package/dist/modules/storage/lib/helpers.d.mts +14 -28
- package/dist/modules/storage/lib/helpers.d.mts.map +1 -1
- package/dist/modules/storage/lib/helpers.mjs +17 -75
- package/dist/modules/storage/lib/helpers.mjs.map +1 -1
- package/dist/modules/storage/lib/procedures.server.d.mts +1991 -0
- package/dist/modules/{auth/handler/init.d.mts.map → storage/lib/procedures.server.d.mts.map} +1 -1
- package/dist/modules/storage/lib/procedures.server.mjs +22 -0
- package/dist/modules/storage/lib/procedures.server.mjs.map +1 -0
- package/dist/modules/storage/lib/router-handlers.server.d.mts +41 -0
- package/dist/modules/storage/lib/router-handlers.server.d.mts.map +1 -0
- package/dist/modules/storage/lib/router-handlers.server.mjs +124 -0
- package/dist/modules/storage/lib/router-handlers.server.mjs.map +1 -0
- package/dist/modules/storage/lib/schema.d.mts +68 -958
- package/dist/modules/storage/lib/schema.d.mts.map +1 -1
- package/dist/modules/storage/lib/schema.mjs +28 -65
- package/dist/modules/storage/lib/schema.mjs.map +1 -1
- package/dist/modules/storage/lib/service.server.d.mts +2155 -141
- package/dist/modules/storage/lib/service.server.d.mts.map +1 -1
- package/dist/modules/storage/lib/service.server.mjs +453 -242
- package/dist/modules/storage/lib/service.server.mjs.map +1 -1
- package/dist/modules/storage/lib/upload.client.d.mts +58 -0
- package/dist/modules/storage/lib/upload.client.d.mts.map +1 -0
- package/dist/modules/storage/lib/upload.client.mjs +87 -0
- package/dist/modules/storage/lib/upload.client.mjs.map +1 -0
- package/dist/modules/storage/lib/validators.d.mts +297 -835
- package/dist/modules/storage/lib/validators.d.mts.map +1 -1
- package/dist/modules/storage/lib/validators.mjs +32 -76
- package/dist/modules/storage/lib/validators.mjs.map +1 -1
- package/dist/modules/storage/providers/adapters/s3.server.d.mts +19 -0
- package/dist/modules/storage/providers/adapters/s3.server.d.mts.map +1 -0
- package/dist/modules/storage/providers/adapters/s3.server.mjs +173 -0
- package/dist/modules/storage/providers/adapters/s3.server.mjs.map +1 -0
- package/dist/modules/storage/providers/lib/constants.d.mts +6 -0
- package/dist/modules/storage/providers/lib/constants.d.mts.map +1 -0
- package/dist/modules/storage/providers/lib/constants.mjs +6 -0
- package/dist/modules/storage/providers/lib/constants.mjs.map +1 -0
- package/dist/modules/storage/providers/lib/errors.d.mts +12 -0
- package/dist/modules/storage/providers/lib/errors.d.mts.map +1 -0
- package/dist/modules/storage/providers/lib/errors.mjs +13 -0
- package/dist/modules/storage/providers/lib/errors.mjs.map +1 -0
- package/dist/modules/storage/providers/lib/types.d.mts +21 -0
- package/dist/modules/storage/providers/lib/types.d.mts.map +1 -0
- package/dist/modules/storage/providers/lib/validators.d.mts +112 -0
- package/dist/modules/storage/providers/lib/validators.d.mts.map +1 -0
- package/dist/modules/storage/providers/lib/validators.mjs +75 -0
- package/dist/modules/storage/providers/lib/validators.mjs.map +1 -0
- package/dist/router/server.d.mts +1 -1
- package/dist/storage/client.d.mts +4 -2
- package/dist/storage/client.mjs +4 -2
- package/dist/storage/server.d.mts +5 -4
- package/dist/storage/server.mjs +5 -4
- package/dist/storage.d.mts +9 -6
- package/dist/storage.mjs +8 -6
- package/package.json +18 -5
- package/src/components/editor/components/editor.client.tsx +9 -1
- package/src/components/editor/extensions/file-handler/extension.ts +4 -4
- package/src/components/editor/extensions/file-handler/strategy.ts +15 -40
- package/src/components/editor/extensions/file-handler/utils.ts +1 -1
- package/src/components/editor/extensions/image/extension.ts +10 -10
- package/src/components/editor/lib/helpers.ts +28 -11
- package/src/components/ui/combobox-dropdown.client.tsx +1 -0
- package/src/components/ui/combobox.client.tsx +1 -1
- package/src/entry.ts +12 -51
- package/src/lib/entry.ts +1 -5
- package/src/lib/utils/markdown.ts +10 -0
- package/src/lib/utils/url.ts +2 -1
- package/src/lib/utils/user-agent.ts +15 -0
- package/src/modules/auth/components/{guard-first-user.server.tsx → create-first-user-guard.server.tsx} +8 -8
- package/src/modules/auth/components/guard.server.tsx +1 -1
- package/src/modules/auth/entry.server.ts +4 -5
- package/src/modules/auth/handler/create-client.client.ts +2 -2
- package/src/modules/auth/handler/proxy.server.ts +1 -1
- package/src/modules/auth/handler/route.server.ts +2 -2
- package/src/modules/auth/handler/{init.ts → service.server.ts} +30 -9
- package/src/modules/config/entry.server.ts +0 -9
- package/src/modules/config/entry.ts +2 -2
- package/src/modules/config/lib/context.ts +9 -9
- package/src/modules/data-tables/entry.client.ts +1 -0
- package/src/modules/data-tables/server/get-data.server.ts +1 -1
- package/src/modules/data-tables/strategies/infinite/strategy.ts +4 -1
- package/src/modules/data-tables/tables/data-table/components/row.tsx +12 -21
- package/src/modules/data-tables/tables/inline-table/components/body.tsx +1 -1
- package/src/modules/data-tables/tables/inline-table/components/row.client.tsx +24 -30
- package/src/modules/data-tables/tables/inline-table/components/table.tsx +6 -1
- package/src/modules/data-tables/tables/inline-table/hooks/context.client.tsx +5 -0
- package/src/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.ts +119 -91
- package/src/modules/database/entry.client.ts +0 -0
- package/src/modules/database/entry.server.ts +4 -0
- package/src/modules/database/entry.ts +5 -0
- package/src/modules/database/lib/service.server.ts +33 -0
- package/src/modules/emails/entry.client.ts +0 -0
- package/src/modules/emails/entry.server.ts +4 -0
- package/src/modules/emails/entry.ts +0 -0
- package/src/modules/emails/lib/service.server.ts +29 -0
- package/src/modules/inline-edit/components/date-input.client.tsx +1 -1
- package/src/modules/inline-edit/components/date-picker.client.tsx +1 -0
- package/src/modules/inline-edit/components/date-time.client.tsx +1 -0
- package/src/modules/inline-edit/components/editor.client.tsx +3 -0
- package/src/modules/inline-edit/components/input-recipient.client.tsx +1 -0
- package/src/modules/inline-edit/components/input-toggle.client.tsx +1 -0
- package/src/modules/inline-edit/components/input.client.tsx +3 -0
- package/src/modules/inline-edit/components/select.client.tsx +5 -1
- package/src/modules/inline-edit/components/switch.client.tsx +1 -0
- package/src/modules/inline-edit/components/toggle.client.tsx +1 -0
- package/src/modules/router/handler/init.server.ts +2 -2
- package/src/modules/storage/components/dropzone.client.tsx +1 -1
- package/src/modules/storage/components/image-grid.client.tsx +23 -20
- package/src/modules/storage/components/image.client.tsx +8 -0
- package/src/modules/storage/components/upload-zone-context.client.tsx +11 -8
- package/src/modules/storage/components/upload-zone.client.tsx +22 -16
- package/src/modules/storage/entry.client.ts +3 -1
- package/src/modules/storage/entry.server.ts +9 -3
- package/src/modules/storage/entry.ts +13 -1
- package/src/modules/storage/lib/constants.ts +0 -11
- package/src/modules/storage/lib/helpers.ts +18 -65
- package/src/modules/storage/lib/procedures.server.ts +60 -0
- package/src/modules/storage/lib/router-handlers.server.ts +178 -0
- package/src/modules/storage/lib/schema.ts +26 -97
- package/src/modules/storage/lib/service.server.ts +636 -374
- package/src/modules/storage/lib/upload.client.ts +156 -0
- package/src/modules/storage/lib/validators.ts +50 -111
- package/src/modules/storage/providers/adapters/s3.server.ts +281 -0
- package/src/modules/storage/providers/lib/constants.ts +3 -0
- package/src/modules/storage/providers/lib/errors.ts +21 -0
- package/src/modules/storage/providers/lib/types.ts +28 -0
- package/src/modules/storage/providers/lib/validators.ts +122 -0
- package/dist/lib/config/constants.d.mts +0 -5
- package/dist/lib/config/constants.d.mts.map +0 -1
- package/dist/lib/config/constants.mjs +0 -6
- package/dist/lib/config/constants.mjs.map +0 -1
- package/dist/modules/auth/components/guard-first-user.server.d.mts +0 -18
- package/dist/modules/auth/components/guard-first-user.server.d.mts.map +0 -1
- package/dist/modules/auth/components/guard-first-user.server.mjs +0 -16
- package/dist/modules/auth/components/guard-first-user.server.mjs.map +0 -1
- package/dist/modules/auth/handler/init.mjs.map +0 -1
- package/dist/modules/config/db/helpers.d.mts.map +0 -1
- package/dist/modules/config/db/helpers.mjs.map +0 -1
- package/dist/modules/config/db/init.d.mts +0 -20
- package/dist/modules/config/db/init.d.mts.map +0 -1
- package/dist/modules/config/db/init.mjs +0 -15
- package/dist/modules/config/db/init.mjs.map +0 -1
- package/dist/modules/config/db/types.d.mts.map +0 -1
- package/dist/modules/config/providers/email.d.mts +0 -12
- package/dist/modules/config/providers/email.d.mts.map +0 -1
- package/dist/modules/config/providers/email.mjs +0 -11
- package/dist/modules/config/providers/email.mjs.map +0 -1
- package/dist/modules/storage/config/filters.d.mts +0 -17
- package/dist/modules/storage/config/filters.d.mts.map +0 -1
- package/dist/modules/storage/config/filters.mjs +0 -17
- package/dist/modules/storage/config/filters.mjs.map +0 -1
- package/dist/modules/storage/lib/create-client.server.d.mts +0 -11
- package/dist/modules/storage/lib/create-client.server.d.mts.map +0 -1
- package/dist/modules/storage/lib/create-client.server.mjs +0 -11
- package/dist/modules/storage/lib/create-client.server.mjs.map +0 -1
- package/dist/modules/storage/lib/create-upload.client.d.mts +0 -56
- package/dist/modules/storage/lib/create-upload.client.d.mts.map +0 -1
- package/dist/modules/storage/lib/create-upload.client.mjs +0 -98
- package/dist/modules/storage/lib/create-upload.client.mjs.map +0 -1
- package/dist/modules/storage/lib/proxy.server.d.mts +0 -21
- package/dist/modules/storage/lib/proxy.server.d.mts.map +0 -1
- package/dist/modules/storage/lib/proxy.server.mjs +0 -46
- package/dist/modules/storage/lib/proxy.server.mjs.map +0 -1
- package/dist/modules/storage/lib/router.server.d.mts +0 -31002
- package/dist/modules/storage/lib/router.server.d.mts.map +0 -1
- package/dist/modules/storage/lib/router.server.mjs +0 -86
- package/dist/modules/storage/lib/router.server.mjs.map +0 -1
- package/src/lib/config/constants.ts +0 -1
- package/src/lib/utils/time-picker.ts +0 -139
- package/src/modules/config/db/init.ts +0 -21
- package/src/modules/config/providers/email.ts +0 -13
- package/src/modules/storage/config/filters.ts +0 -12
- package/src/modules/storage/lib/create-client.server.ts +0 -14
- package/src/modules/storage/lib/create-upload.client.ts +0 -134
- package/src/modules/storage/lib/proxy.server.ts +0 -63
- package/src/modules/storage/lib/router.server.ts +0 -182
- /package/src/modules/{config/db → database/lib}/helpers.ts +0 -0
- /package/src/modules/{config/db → database/lib}/types.ts +0 -0
|
@@ -22,6 +22,7 @@ function InlineToggle({ initialValue, action, children, permission, updateStrate
|
|
|
22
22
|
...props,
|
|
23
23
|
className: cn("flex flex-wrap items-center justify-start gap-1", className),
|
|
24
24
|
children: /* @__PURE__ */ jsx(Toggle, {
|
|
25
|
+
"data-inline-input": "toggle",
|
|
25
26
|
disabled: !isAllowed,
|
|
26
27
|
variant: "outline",
|
|
27
28
|
pressed: value ?? void 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle.client.mjs","names":[],"sources":["../../../../src/modules/inline-edit/components/toggle.client.tsx"],"sourcesContent":["\"use client\";\n\nimport type React from \"react\";\nimport { Toggle } from \"@/components/ui/toggle.client\";\nimport { cn } from \"@/lib/utils/cn\";\nimport { useInlineEdit, type useInlineEditOptions } from \"../hooks/use-inline.client\";\n\nexport type InlineEditToggleProps<Required extends boolean = false> =\n React.HTMLAttributes<HTMLDivElement> & useInlineEditOptions<boolean, Required>;\n\nexport function InlineToggle<Required extends boolean = false>({\n initialValue,\n action,\n children,\n permission,\n updateStrategy,\n isRequired,\n className,\n ...props\n}: InlineEditToggleProps<Required>) {\n const { value, handleChange, handleBlur, isAllowed } = useInlineEdit({\n initialValue,\n action,\n permission,\n updateStrategy,\n isRequired,\n parser: {\n decode: (value) => value,\n encode: (value) => value,\n },\n });\n\n return (\n <div {...props} className={cn(\"flex flex-wrap items-center justify-start gap-1\", className)}>\n <Toggle\n disabled={!isAllowed}\n variant=\"outline\"\n pressed={value ?? undefined}\n defaultChecked={initialValue ?? undefined}\n onPressedChange={(value) => {\n handleChange(value);\n handleBlur(value);\n }}\n >\n {children}\n </Toggle>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAUA,SAAgB,aAA+C,EAC7D,cACA,QACA,UACA,YACA,gBACA,YACA,WACA,GAAG,SAC+B;CAClC,MAAM,EAAE,OAAO,cAAc,YAAY,cAAc,cAAc;EACnE;EACA;EACA;EACA;EACA;EACA,QAAQ;GACN,SAAS,UAAU;GACnB,SAAS,UAAU;GACpB;EACF,CAAC;AAEF,QACE,oBAAC;EAAI,GAAI;EAAO,WAAW,GAAG,mDAAmD,UAAU;YACzF,oBAAC;GACC,UAAU,CAAC;GACX,SAAQ;GACR,SAAS,SAAS;GAClB,gBAAgB,gBAAgB;GAChC,kBAAkB,UAAU;AAC1B,iBAAa,MAAM;AACnB,eAAW,MAAM;;GAGlB;IACM;GACL"}
|
|
1
|
+
{"version":3,"file":"toggle.client.mjs","names":[],"sources":["../../../../src/modules/inline-edit/components/toggle.client.tsx"],"sourcesContent":["\"use client\";\n\nimport type React from \"react\";\nimport { Toggle } from \"@/components/ui/toggle.client\";\nimport { cn } from \"@/lib/utils/cn\";\nimport { useInlineEdit, type useInlineEditOptions } from \"../hooks/use-inline.client\";\n\nexport type InlineEditToggleProps<Required extends boolean = false> =\n React.HTMLAttributes<HTMLDivElement> & useInlineEditOptions<boolean, Required>;\n\nexport function InlineToggle<Required extends boolean = false>({\n initialValue,\n action,\n children,\n permission,\n updateStrategy,\n isRequired,\n className,\n ...props\n}: InlineEditToggleProps<Required>) {\n const { value, handleChange, handleBlur, isAllowed } = useInlineEdit({\n initialValue,\n action,\n permission,\n updateStrategy,\n isRequired,\n parser: {\n decode: (value) => value,\n encode: (value) => value,\n },\n });\n\n return (\n <div {...props} className={cn(\"flex flex-wrap items-center justify-start gap-1\", className)}>\n <Toggle\n data-inline-input=\"toggle\"\n disabled={!isAllowed}\n variant=\"outline\"\n pressed={value ?? undefined}\n defaultChecked={initialValue ?? undefined}\n onPressedChange={(value) => {\n handleChange(value);\n handleBlur(value);\n }}\n >\n {children}\n </Toggle>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAUA,SAAgB,aAA+C,EAC7D,cACA,QACA,UACA,YACA,gBACA,YACA,WACA,GAAG,SAC+B;CAClC,MAAM,EAAE,OAAO,cAAc,YAAY,cAAc,cAAc;EACnE;EACA;EACA;EACA;EACA;EACA,QAAQ;GACN,SAAS,UAAU;GACnB,SAAS,UAAU;GACpB;EACF,CAAC;AAEF,QACE,oBAAC;EAAI,GAAI;EAAO,WAAW,GAAG,mDAAmD,UAAU;YACzF,oBAAC;GACC,qBAAkB;GAClB,UAAU,CAAC;GACX,SAAQ;GACR,SAAS,SAAS;GAClB,gBAAgB,gBAAgB;GAChC,kBAAkB,UAAU;AAC1B,iBAAa,MAAM;AACnB,eAAW,MAAM;;GAGlB;IACM;GACL"}
|
|
@@ -4,7 +4,7 @@ import * as class_variance_authority_types0 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?: "
|
|
7
|
+
status?: "error" | "success" | "pending" | "idle" | null | undefined;
|
|
8
8
|
} & class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
9
9
|
type InlineEditVariantsProps = VariantProps<typeof inlineEditVariants>;
|
|
10
10
|
//#endregion
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import "
|
|
5
|
-
import {
|
|
6
|
-
import { AuthClient } from "../../auth/handler/init.mjs";
|
|
1
|
+
import { Database } from "../../database/lib/service.server.mjs";
|
|
2
|
+
import "../../../database/server.mjs";
|
|
3
|
+
import { Email } from "../../emails/lib/service.server.mjs";
|
|
4
|
+
import { Auth } from "../../auth/handler/service.server.mjs";
|
|
5
|
+
import { Storage } from "../../storage/lib/service.server.mjs";
|
|
7
6
|
import { TulipContext } from "../../config/lib/context.mjs";
|
|
8
7
|
import "../../../config.mjs";
|
|
9
8
|
import "../../../auth/server.mjs";
|
|
9
|
+
import "../../../emails/server.mjs";
|
|
10
|
+
import "../../../storage/server.mjs";
|
|
10
11
|
import "server-cli-only";
|
|
11
12
|
import * as next_dist_server_web_spec_extension_adapters_headers0 from "next/dist/server/web/spec-extension/adapters/headers";
|
|
13
|
+
import { TDatabaseSchema } from "@/modules/config/db/types";
|
|
12
14
|
|
|
13
15
|
//#region src/modules/router/handler/context.server.d.ts
|
|
14
16
|
/**
|
|
@@ -46,11 +48,11 @@ declare const createRPCContext: <TSchema extends TDatabaseSchema>(props: {
|
|
|
46
48
|
};
|
|
47
49
|
} | null;
|
|
48
50
|
headers: next_dist_server_web_spec_extension_adapters_headers0.ReadonlyHeaders;
|
|
49
|
-
db:
|
|
51
|
+
db: Database<TSchema>;
|
|
50
52
|
schema: TSchema;
|
|
51
|
-
auth:
|
|
52
|
-
email:
|
|
53
|
-
storage:
|
|
53
|
+
auth: Auth;
|
|
54
|
+
email: Email;
|
|
55
|
+
storage: Storage<TSchema>;
|
|
54
56
|
}>;
|
|
55
57
|
type RPCContext<TSchema extends TDatabaseSchema = any> = Awaited<ReturnType<typeof createRPCContext<TSchema>>>;
|
|
56
58
|
type ProtectedRPCContext<TSchema extends TDatabaseSchema = any> = RPCContext<TSchema> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.server.d.mts","names":[],"sources":["../../../../src/modules/router/handler/context.server.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.server.d.mts","names":[],"sources":["../../../../src/modules/router/handler/context.server.ts"],"mappings":";;;;;;;;;;;;;;;;;;cAUa,gBAAA,mBACY,eAAA,EAAe,KAAA;EAAW,OAAA,EAAS,YAAA,CAAa,OAAA;AAAA,MAAU,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KASvE,UAAA,iBAA2B,eAAA,UAAyB,OAAA,CAC9D,UAAA,QAAkB,gBAAA,CAAiB,OAAA;AAAA,KAIzB,mBAAA,iBAAoC,eAAA,UAAyB,UAAA,CAAW,OAAA;EAClF,OAAA,EAAS,WAAA,CAAY,UAAA,CAAW,OAAA;AAAA"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { Permission } from "../../auth/lib/permissions.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import "
|
|
6
|
-
import {
|
|
7
|
-
import { AuthClient } from "../../auth/handler/init.mjs";
|
|
2
|
+
import { Database } from "../../database/lib/service.server.mjs";
|
|
3
|
+
import "../../../database/server.mjs";
|
|
4
|
+
import { Email } from "../../emails/lib/service.server.mjs";
|
|
5
|
+
import { Auth } from "../../auth/handler/service.server.mjs";
|
|
6
|
+
import { Storage } from "../../storage/lib/service.server.mjs";
|
|
8
7
|
import "../../../auth/server.mjs";
|
|
8
|
+
import "../../../emails/server.mjs";
|
|
9
|
+
import "../../../storage/server.mjs";
|
|
9
10
|
import { ProtectedRPCContext, RPCContext } from "./context.server.mjs";
|
|
10
11
|
import * as _orpc_server0 from "@orpc/server";
|
|
11
12
|
import "server-cli-only";
|
|
12
13
|
import * as next_dist_server_web_spec_extension_adapters_headers0 from "next/dist/server/web/spec-extension/adapters/headers";
|
|
14
|
+
import { TDatabaseSchema } from "@/modules/config/db/types";
|
|
13
15
|
import * as _orpc_contract0 from "@orpc/contract";
|
|
14
16
|
|
|
15
17
|
//#region src/modules/router/handler/init.server.d.ts
|
|
@@ -20,7 +22,7 @@ declare function initRPC<TSchema extends TDatabaseSchema>(): {
|
|
|
20
22
|
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
23
|
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
24
|
authMiddleware: _orpc_server0.DecoratedMiddleware<RPCContext<TSchema> & Record<never, never>, ProtectedRPCContext<TSchema>, unknown, any, any, Record<never, never>>;
|
|
23
|
-
permissionMiddleware: (
|
|
25
|
+
permissionMiddleware: (permissions: Permission) => _orpc_server0.DecoratedMiddleware<{
|
|
24
26
|
session: {
|
|
25
27
|
session: {
|
|
26
28
|
id: string;
|
|
@@ -50,11 +52,11 @@ declare function initRPC<TSchema extends TDatabaseSchema>(): {
|
|
|
50
52
|
};
|
|
51
53
|
} | null;
|
|
52
54
|
headers: next_dist_server_web_spec_extension_adapters_headers0.ReadonlyHeaders;
|
|
53
|
-
db:
|
|
55
|
+
db: Database<TSchema>;
|
|
54
56
|
schema: TSchema;
|
|
55
|
-
auth:
|
|
56
|
-
email:
|
|
57
|
-
storage:
|
|
57
|
+
auth: Auth;
|
|
58
|
+
email: Email;
|
|
59
|
+
storage: Storage<TSchema>;
|
|
58
60
|
} & {
|
|
59
61
|
session: {
|
|
60
62
|
session: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.server.d.mts","names":[],"sources":["../../../../src/modules/router/handler/init.server.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.server.d.mts","names":[],"sources":["../../../../src/modules/router/handler/init.server.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;iBAWgB,OAAA,iBAAwB,eAAA,CAAA,CAAA;;;;sCAwBK,UAAA,mBAAU,mBAAA"}
|
|
@@ -24,14 +24,14 @@ function initRPC() {
|
|
|
24
24
|
/**
|
|
25
25
|
* Middleware function to check if the user has the required permission
|
|
26
26
|
*/
|
|
27
|
-
function permissionMiddleware(
|
|
27
|
+
function permissionMiddleware(permissions) {
|
|
28
28
|
/**
|
|
29
29
|
* Middleware function to check if the user has the required permission
|
|
30
30
|
*/
|
|
31
31
|
return os.$context().middleware(async (opts) => {
|
|
32
32
|
const { success, error } = await opts.context.auth.api.userHasPermission({ body: {
|
|
33
33
|
userId: opts.context.session.user.id,
|
|
34
|
-
|
|
34
|
+
permissions
|
|
35
35
|
} });
|
|
36
36
|
if (error || !success) throw new ServerError("UNAUTHORIZED", { message: "Jou hebt geen toegang om deze actie uit te voeren" });
|
|
37
37
|
return opts.next({ context: { ...opts.context } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.server.mjs","names":[],"sources":["../../../../src/modules/router/handler/init.server.ts"],"sourcesContent":["import \"server-cli-only\";\n\nimport { os } from \"@orpc/server\";\nimport type { Permission } from \"@/modules/auth/lib/permissions\";\nimport type { TDatabaseSchema } from \"@/modules/config/db/types\";\nimport { ServerError } from \"../lib/error.server\";\nimport type { ProtectedRPCContext, RPCContext } from \"./context.server\";\n\n/**\n * Initialize TRPC\n */\nexport function initRPC<TSchema extends TDatabaseSchema>() {\n /**\n * Create the router\n */\n const o = os.$context<RPCContext<TSchema>>();\n\n /**\n * Middleware function to check if the user is authenticated\n */\n const authMiddleware = o.middleware(async (opts) => {\n if (!opts.context.session) {\n throw new ServerError(\"UNAUTHORIZED\", {\n message: \"Jou hebt geen toegang om deze actie uit te voeren\",\n });\n }\n\n return opts.next({\n context: { ...opts.context, session: opts.context.session } as ProtectedRPCContext<TSchema>,\n });\n });\n\n /**\n * Middleware function to check if the user has the required permission\n */\n function permissionMiddleware(
|
|
1
|
+
{"version":3,"file":"init.server.mjs","names":[],"sources":["../../../../src/modules/router/handler/init.server.ts"],"sourcesContent":["import \"server-cli-only\";\n\nimport { os } from \"@orpc/server\";\nimport type { Permission } from \"@/modules/auth/lib/permissions\";\nimport type { TDatabaseSchema } from \"@/modules/config/db/types\";\nimport { ServerError } from \"../lib/error.server\";\nimport type { ProtectedRPCContext, RPCContext } from \"./context.server\";\n\n/**\n * Initialize TRPC\n */\nexport function initRPC<TSchema extends TDatabaseSchema>() {\n /**\n * Create the router\n */\n const o = os.$context<RPCContext<TSchema>>();\n\n /**\n * Middleware function to check if the user is authenticated\n */\n const authMiddleware = o.middleware(async (opts) => {\n if (!opts.context.session) {\n throw new ServerError(\"UNAUTHORIZED\", {\n message: \"Jou hebt geen toegang om deze actie uit te voeren\",\n });\n }\n\n return opts.next({\n context: { ...opts.context, session: opts.context.session } as ProtectedRPCContext<TSchema>,\n });\n });\n\n /**\n * Middleware function to check if the user has the required permission\n */\n function permissionMiddleware(permissions: Permission) {\n /**\n * Middleware function to check if the user has the required permission\n */\n return os.$context<ProtectedRPCContext<TSchema>>().middleware(async (opts) => {\n const { success, error } = await opts.context.auth.api.userHasPermission({\n body: {\n userId: opts.context.session.user.id,\n permissions,\n },\n });\n\n if (error || !success) {\n throw new ServerError(\"UNAUTHORIZED\", {\n message: \"Jou hebt geen toegang om deze actie uit te voeren\",\n });\n }\n\n return opts.next({ context: { ...opts.context } as ProtectedRPCContext<TSchema> });\n });\n }\n\n /**\n * Public procedures\n */\n const publicProcedure = o;\n\n /**\n * Protected procedures\n */\n const protectedProcedure = o.use(authMiddleware);\n\n /**\n * Export\n */\n return {\n publicProcedure,\n protectedProcedure,\n authMiddleware,\n permissionMiddleware,\n };\n}\n"],"mappings":";;;;;;;;AAWA,SAAgB,UAA2C;;;;CAIzD,MAAM,IAAI,GAAG,UAA+B;;;;CAK5C,MAAM,iBAAiB,EAAE,WAAW,OAAO,SAAS;AAClD,MAAI,CAAC,KAAK,QAAQ,QAChB,OAAM,IAAI,YAAY,gBAAgB,EACpC,SAAS,qDACV,CAAC;AAGJ,SAAO,KAAK,KAAK,EACf,SAAS;GAAE,GAAG,KAAK;GAAS,SAAS,KAAK,QAAQ;GAAS,EAC5D,CAAC;GACF;;;;CAKF,SAAS,qBAAqB,aAAyB;;;;AAIrD,SAAO,GAAG,UAAwC,CAAC,WAAW,OAAO,SAAS;GAC5E,MAAM,EAAE,SAAS,UAAU,MAAM,KAAK,QAAQ,KAAK,IAAI,kBAAkB,EACvE,MAAM;IACJ,QAAQ,KAAK,QAAQ,QAAQ,KAAK;IAClC;IACD,EACF,CAAC;AAEF,OAAI,SAAS,CAAC,QACZ,OAAM,IAAI,YAAY,gBAAgB,EACpC,SAAS,qDACV,CAAC;AAGJ,UAAO,KAAK,KAAK,EAAE,SAAS,EAAE,GAAG,KAAK,SAAS,EAAkC,CAAC;IAClF;;;;;AAgBJ,QAAO;EACL,iBAXsB;EAYtB,oBAPyB,EAAE,IAAI,eAAe;EAQ9C;EACA;EACD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TDatabaseSchema } from "../../config/db/types.mjs";
|
|
2
1
|
import { TulipContext } from "../../config/lib/context.mjs";
|
|
3
2
|
import { AnyRouter } from "@orpc/server";
|
|
3
|
+
import { TDatabaseSchema } from "@/modules/config/db/types";
|
|
4
4
|
|
|
5
5
|
//#region src/modules/router/handler/route.server.d.ts
|
|
6
6
|
/**
|
|
@@ -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 | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> |
|
|
39
|
+
}: DropzoneContentProps): string | number | bigint | true | react_jsx_runtime0.JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | 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 | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> |
|
|
50
|
+
}: DropzoneEmptyStateProps): string | number | bigint | true | react_jsx_runtime0.JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null;
|
|
51
51
|
//#endregion
|
|
52
52
|
export { Dropzone, DropzoneContent, DropzoneContentProps, DropzoneEmptyState, DropzoneEmptyStateProps, DropzoneProps };
|
|
53
53
|
//# sourceMappingURL=dropzone.client.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropzone.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/dropzone.client.tsx"],"mappings":";;;;;;;;;KAcY,aAAA,GAAgB,IAAA,CAAK,eAAA;EAC/B,GAAA,GAAM,IAAA;EACN,SAAA;EACA,MAAA,IAAU,aAAA,EAAe,IAAA,IAAQ,cAAA,EAAgB,aAAA,IAAiB,KAAA,EAAO,SAAA;EACzE,QAAA,GAAW,SAAA;AAAA;AAAA,iBAGG,QAAA,CAAA;EACd,MAAA;EACA,QAAA;EACA,OAAA;EACA,OAAA;EACA,MAAA;EACA,OAAA;EACA,QAAA;EACA,GAAA;EACA,SAAA;EACA,QAAA;EAAA,GACG;AAAA,GACF,aAAA,GAAa,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;KA0CJ,oBAAA;EACV,QAAA,GAAW,SAAA;EACX,SAAA;AAAA;AAAA,iBAKc,eAAA,CAAA;EAAkB,QAAA;EAAU;AAAA,GAAa,oBAAA,qCAAoB,QAAA,CAAA,SAAA,IAAA,OAAA,sCAAA,KAAA,CAAA,WAAA,GAAA,KAAA,CAAA,YAAA,mBAAA,KAAA,CAAA,qBAAA,SAAA,QAAA,CAAA,SAAA
|
|
1
|
+
{"version":3,"file":"dropzone.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/dropzone.client.tsx"],"mappings":";;;;;;;;;KAcY,aAAA,GAAgB,IAAA,CAAK,eAAA;EAC/B,GAAA,GAAM,IAAA;EACN,SAAA;EACA,MAAA,IAAU,aAAA,EAAe,IAAA,IAAQ,cAAA,EAAgB,aAAA,IAAiB,KAAA,EAAO,SAAA;EACzE,QAAA,GAAW,SAAA;AAAA;AAAA,iBAGG,QAAA,CAAA;EACd,MAAA;EACA,QAAA;EACA,OAAA;EACA,OAAA;EACA,MAAA;EACA,OAAA;EACA,QAAA;EACA,GAAA;EACA,SAAA;EACA,QAAA;EAAA,GACG;AAAA,GACF,aAAA,GAAa,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;KA0CJ,oBAAA;EACV,QAAA,GAAW,SAAA;EACX,SAAA;AAAA;AAAA,iBAKc,eAAA,CAAA;EAAkB,QAAA;EAAU;AAAA,GAAa,oBAAA,qCAAoB,kBAAA,CAAA,GAAA,CAAA,OAAA,GAAA,QAAA,CAAA,SAAA,IAAA,OAAA,sCAAA,KAAA,CAAA,WAAA,GAAA,KAAA,CAAA,YAAA,mBAAA,KAAA,CAAA,qBAAA,SAAA,QAAA,CAAA,SAAA;;;;KA8BjE,uBAAA;EACV,QAAA,GAAW,SAAA;EACX,SAAA;AAAA;AAAA,iBAGc,kBAAA,CAAA;EAAqB,QAAA;EAAU;AAAA,GAAa,uBAAA,qCAAuB,kBAAA,CAAA,GAAA,CAAA,OAAA,GAAA,QAAA,CAAA,SAAA,IAAA,OAAA,sCAAA,KAAA,CAAA,WAAA,GAAA,KAAA,CAAA,YAAA,mBAAA,KAAA,CAAA,qBAAA,SAAA,QAAA,CAAA,SAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropzone.client.mjs","names":[],"sources":["../../../../src/modules/storage/components/dropzone.client.tsx"],"sourcesContent":["\"use client\";\n\nimport { UploadIcon } from \"lucide-react\";\nimport type { ReactNode } from \"react\";\nimport type { DropEvent, DropzoneOptions, FileRejection } from \"react-dropzone\";\nimport { useDropzone } from \"react-dropzone\";\nimport { Button } from \"@/components/ui/button\";\nimport { cn } from \"@/lib/utils/cn\";\nimport { renderBytes } from \"
|
|
1
|
+
{"version":3,"file":"dropzone.client.mjs","names":[],"sources":["../../../../src/modules/storage/components/dropzone.client.tsx"],"sourcesContent":["\"use client\";\n\nimport { UploadIcon } from \"lucide-react\";\nimport type { ReactNode } from \"react\";\nimport type { DropEvent, DropzoneOptions, FileRejection } from \"react-dropzone\";\nimport { useDropzone } from \"react-dropzone\";\nimport { Button } from \"@/components/ui/button\";\nimport { cn } from \"@/lib/utils/cn\";\nimport { renderBytes } from \"../lib/helpers\";\nimport { DropzoneContext, useDropzoneContext } from \"./dropzone-context.client\";\n\n/**\n * Dropzone\n */\nexport type DropzoneProps = Omit<DropzoneOptions, \"onDrop\"> & {\n src?: File[];\n className?: string;\n onDrop?: (acceptedFiles: File[], fileRejections: FileRejection[], event: DropEvent) => void;\n children?: ReactNode;\n};\n\nexport function Dropzone({\n accept,\n maxFiles = 1,\n maxSize,\n minSize,\n onDrop,\n onError,\n disabled,\n src,\n className,\n children,\n ...props\n}: DropzoneProps) {\n const { getRootProps, getInputProps, isDragActive } = useDropzone({\n accept,\n maxFiles,\n maxSize,\n minSize,\n onError,\n disabled,\n onDrop: (acceptedFiles, fileRejections, event) => {\n if (fileRejections.length > 0) {\n const message = fileRejections.at(0)?.errors.at(0)?.message;\n onError?.(new Error(message));\n return;\n }\n onDrop?.(acceptedFiles, fileRejections, event);\n },\n ...props,\n });\n\n return (\n <DropzoneContext key={JSON.stringify(src)} value={{ src, accept, maxSize, minSize, maxFiles }}>\n <Button\n className={cn(\n \"relative h-auto w-full flex-col overflow-hidden p-8\",\n isDragActive && \"outline-none ring-1 ring-ring\",\n className,\n )}\n disabled={disabled}\n type=\"button\"\n variant=\"outline\"\n {...getRootProps()}\n >\n <input {...getInputProps()} disabled={disabled} />\n {children}\n </Button>\n </DropzoneContext>\n );\n}\n\n/**\n * DropzoneContent\n */\nexport type DropzoneContentProps = {\n children?: ReactNode;\n className?: string;\n};\n\nconst maxLabelItems = 3;\n\nexport function DropzoneContent({ children, className }: DropzoneContentProps) {\n const { src } = useDropzoneContext();\n if (!src) return null;\n\n if (children) return children;\n\n return (\n <div className={cn(\"flex flex-col items-center justify-center\", className)}>\n <div className=\"flex size-8 items-center justify-center rounded-md bg-muted text-muted-foreground\">\n <UploadIcon size={16} />\n </div>\n\n <p className=\"my-2 w-full truncate font-medium text-sm\">\n {src.length > maxLabelItems\n ? `${new Intl.ListFormat(\"en\").format(\n src.slice(0, maxLabelItems).map((file) => file.name),\n )} and ${src.length - maxLabelItems} more`\n : new Intl.ListFormat(\"en\").format(src.map((file) => file.name))}\n </p>\n\n <p className=\"w-full text-wrap text-muted-foreground text-xs\">\n Drag and drop or click to replace\n </p>\n </div>\n );\n}\n\n/**\n * DropzoneEmptyState\n */\nexport type DropzoneEmptyStateProps = {\n children?: ReactNode;\n className?: string;\n};\n\nexport function DropzoneEmptyState({ children, className }: DropzoneEmptyStateProps) {\n const { src, accept, maxSize, minSize, maxFiles } = useDropzoneContext();\n if (src) {\n return null;\n }\n if (children) {\n return children;\n }\n let caption = \"\";\n if (accept) {\n caption += \"Accepts \";\n caption += new Intl.ListFormat(\"en\").format(Object.keys(accept));\n }\n if (minSize && maxSize) {\n caption += ` between ${renderBytes(minSize)} and ${renderBytes(maxSize)}`;\n } else if (minSize) {\n caption += ` at least ${renderBytes(minSize)}`;\n } else if (maxSize) {\n caption += ` less than ${renderBytes(maxSize)}`;\n }\n return (\n <div className={cn(\"flex flex-col items-center justify-center\", className)}>\n <div className=\"flex size-8 items-center justify-center rounded-md bg-muted text-muted-foreground\">\n <UploadIcon size={16} />\n </div>\n <p className=\"my-2 w-full truncate text-wrap font-medium text-sm\">\n Upload {maxFiles === 1 ? \"a file\" : \"files\"}\n </p>\n <p className=\"w-full truncate text-wrap text-muted-foreground text-xs\">\n Drag and drop or click to upload\n </p>\n {caption && <p className=\"text-wrap text-muted-foreground text-xs\">{caption}.</p>}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AAqBA,SAAgB,SAAS,EACvB,QACA,WAAW,GACX,SACA,SACA,QACA,SACA,UACA,KACA,WACA,UACA,GAAG,SACa;CAChB,MAAM,EAAE,cAAc,eAAe,iBAAiB,YAAY;EAChE;EACA;EACA;EACA;EACA;EACA;EACA,SAAS,eAAe,gBAAgB,UAAU;AAChD,OAAI,eAAe,SAAS,GAAG;IAC7B,MAAM,UAAU,eAAe,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE;AACpD,cAAU,IAAI,MAAM,QAAQ,CAAC;AAC7B;;AAEF,YAAS,eAAe,gBAAgB,MAAM;;EAEhD,GAAG;EACJ,CAAC;AAEF,QACE,oBAAC;EAA0C,OAAO;GAAE;GAAK;GAAQ;GAAS;GAAS;GAAU;YAC3F,qBAAC;GACC,WAAW,GACT,uDACA,gBAAgB,iCAChB,UACD;GACS;GACV,MAAK;GACL,SAAQ;GACR,GAAI,cAAc;cAElB,oBAAC;IAAM,GAAI,eAAe;IAAY;KAAY,EACjD;IACM;IAdW,KAAK,UAAU,IAAI,CAevB;;AAYtB,MAAM,gBAAgB;AAEtB,SAAgB,gBAAgB,EAAE,UAAU,aAAmC;CAC7E,MAAM,EAAE,QAAQ,oBAAoB;AACpC,KAAI,CAAC,IAAK,QAAO;AAEjB,KAAI,SAAU,QAAO;AAErB,QACE,qBAAC;EAAI,WAAW,GAAG,6CAA6C,UAAU;;GACxE,oBAAC;IAAI,WAAU;cACb,oBAAC,cAAW,MAAM,KAAM;KACpB;GAEN,oBAAC;IAAE,WAAU;cACV,IAAI,SAAS,gBACV,GAAG,IAAI,KAAK,WAAW,KAAK,CAAC,OAC3B,IAAI,MAAM,GAAG,cAAc,CAAC,KAAK,SAAS,KAAK,KAAK,CACrD,CAAC,OAAO,IAAI,SAAS,cAAc,SACpC,IAAI,KAAK,WAAW,KAAK,CAAC,OAAO,IAAI,KAAK,SAAS,KAAK,KAAK,CAAC;KAChE;GAEJ,oBAAC;IAAE,WAAU;cAAiD;KAE1D;;GACA;;AAYV,SAAgB,mBAAmB,EAAE,UAAU,aAAsC;CACnF,MAAM,EAAE,KAAK,QAAQ,SAAS,SAAS,aAAa,oBAAoB;AACxE,KAAI,IACF,QAAO;AAET,KAAI,SACF,QAAO;CAET,IAAI,UAAU;AACd,KAAI,QAAQ;AACV,aAAW;AACX,aAAW,IAAI,KAAK,WAAW,KAAK,CAAC,OAAO,OAAO,KAAK,OAAO,CAAC;;AAElE,KAAI,WAAW,QACb,YAAW,YAAY,YAAY,QAAQ,CAAC,OAAO,YAAY,QAAQ;UAC9D,QACT,YAAW,aAAa,YAAY,QAAQ;UACnC,QACT,YAAW,cAAc,YAAY,QAAQ;AAE/C,QACE,qBAAC;EAAI,WAAW,GAAG,6CAA6C,UAAU;;GACxE,oBAAC;IAAI,WAAU;cACb,oBAAC,cAAW,MAAM,KAAM;KACpB;GACN,qBAAC;IAAE,WAAU;eAAqD,WACxD,aAAa,IAAI,WAAW;KAClC;GACJ,oBAAC;IAAE,WAAU;cAA0D;KAEnE;GACH,WAAW,qBAAC;IAAE,WAAU;eAA2C,SAAQ;KAAK;;GAC7E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StorageAsset } from "../lib/validators.mjs";
|
|
2
2
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
import { ComponentProps } from "react";
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ import { ComponentProps } from "react";
|
|
|
7
7
|
* Image Grid
|
|
8
8
|
*/
|
|
9
9
|
type ImageGridProps = ComponentProps<"div"> & {
|
|
10
|
-
|
|
10
|
+
assets: StorageAsset[];
|
|
11
11
|
disabled?: boolean;
|
|
12
12
|
moveAction: (params: {
|
|
13
13
|
fromIndex: number;
|
|
@@ -21,7 +21,7 @@ type ImageGridProps = ComponentProps<"div"> & {
|
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
23
|
declare function ImageGrid({
|
|
24
|
-
|
|
24
|
+
assets,
|
|
25
25
|
moveAction,
|
|
26
26
|
optimistic,
|
|
27
27
|
disabled,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-grid.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/image-grid.client.tsx"],"mappings":";;;;;;;;KA4CK,cAAA,GAAiB,cAAA;EACpB,
|
|
1
|
+
{"version":3,"file":"image-grid.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/image-grid.client.tsx"],"mappings":";;;;;;;;KA4CK,cAAA,GAAiB,cAAA;EACpB,MAAA,EAAQ,YAAA;EACR,QAAA;EACA,UAAA,GAAa,MAAA;IAAU,SAAA;IAAmB,OAAA;EAAA,MAAsB,OAAA;EAChE,UAAA;IACE,IAAA,IAAQ,MAAA;MAAU,SAAA;MAAmB,OAAA;IAAA,MAAsB,OAAA;EAAA;AAAA;AAAA,iBAI/C,SAAA,CAAA;EAAY,MAAA;EAAQ,UAAA;EAAY,UAAA;EAAY,QAAA;EAAA,GAAa;AAAA,GAAS,cAAA,GAAc,kBAAA,CAAA,GAAA,CAAA,OAAA;AAAA,iBAyKhF,iBAAA,CAAkB,KAAA,EAAO,cAAA,UAAqB,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -3,28 +3,28 @@
|
|
|
3
3
|
import { Icons } from "../../../components/common/icons.mjs";
|
|
4
4
|
import { cn } from "../../../lib/utils/cn.mjs";
|
|
5
5
|
import { Button } from "../../../components/ui/button.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { getAssetURL } from "../lib/helpers.mjs";
|
|
7
7
|
import { Skeleton } from "../../../components/ui/skeleton.mjs";
|
|
8
8
|
import { Input } from "../../../components/ui/input.mjs";
|
|
9
9
|
import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from "../../../components/ui/carousel.client.mjs";
|
|
10
10
|
import { Dialog, DialogContent, DialogTrigger } from "../../../components/ui/dialog.client.mjs";
|
|
11
11
|
import { Card } from "../../../components/ui/card.mjs";
|
|
12
12
|
import { useAction } from "../../../lib/hooks/use-action.mjs";
|
|
13
|
+
import { StorageImage } from "./image.client.mjs";
|
|
13
14
|
import { useUploadZone } from "./upload-zone-context.client.mjs";
|
|
14
15
|
import { GripIcon, UploadIcon } from "lucide-react";
|
|
15
16
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
16
17
|
import React from "react";
|
|
17
|
-
import Image$1 from "next/image";
|
|
18
18
|
import { SortableContext, rectSortingStrategy, sortableKeyboardCoordinates, useSortable } from "@dnd-kit/sortable";
|
|
19
19
|
import { DndContext, KeyboardSensor, PointerSensor, closestCenter, useDroppable, useSensor, useSensors } from "@dnd-kit/core";
|
|
20
20
|
import { CSS } from "@dnd-kit/utilities";
|
|
21
21
|
|
|
22
22
|
//#region src/modules/storage/components/image-grid.client.tsx
|
|
23
|
-
function ImageGrid({
|
|
23
|
+
function ImageGrid({ assets, moveAction, optimistic, disabled, ...props }) {
|
|
24
24
|
const uploadZone = useUploadZone();
|
|
25
|
-
const images =
|
|
26
|
-
...
|
|
27
|
-
url:
|
|
25
|
+
const images = assets.flatMap((asset) => ({
|
|
26
|
+
...asset,
|
|
27
|
+
url: getAssetURL(asset.id)
|
|
28
28
|
}));
|
|
29
29
|
const [current, setCurrent] = React.useState(0);
|
|
30
30
|
const { setNodeRef } = useDroppable({ id: "image-grid" });
|
|
@@ -66,11 +66,11 @@ function ImageGrid({ nodes, moveAction, optimistic, disabled, ...props }) {
|
|
|
66
66
|
children: /* @__PURE__ */ jsxs(SortableContext, {
|
|
67
67
|
items: images.map((image) => image.id),
|
|
68
68
|
strategy: rectSortingStrategy,
|
|
69
|
-
children: [images.map((
|
|
70
|
-
|
|
69
|
+
children: [images.map((asset, index) => /* @__PURE__ */ jsx(ImageGridItem, {
|
|
70
|
+
asset,
|
|
71
71
|
index,
|
|
72
72
|
setCurrent
|
|
73
|
-
},
|
|
73
|
+
}, asset.id)), !disabled && /* @__PURE__ */ jsxs("label", {
|
|
74
74
|
htmlFor: "file-upload",
|
|
75
75
|
className: "relative flex aspect-square w-full cursor-pointer flex-col items-center justify-center rounded-lg border border-muted-foreground border-dashed bg-muted hover:border-primary",
|
|
76
76
|
children: [/* @__PURE__ */ jsx(UploadIcon, { className: "h-8 w-8" }), /* @__PURE__ */ jsx(Input, {
|
|
@@ -97,13 +97,12 @@ function ImageGrid({ nodes, moveAction, optimistic, disabled, ...props }) {
|
|
|
97
97
|
className: "md:max-h-[80vh]",
|
|
98
98
|
children: images.map(({ id, url }) => /* @__PURE__ */ jsx(CarouselItem, {
|
|
99
99
|
className: "overflow-hidden rounded-xl",
|
|
100
|
-
children: /* @__PURE__ */ jsx(
|
|
100
|
+
children: /* @__PURE__ */ jsx(StorageImage, {
|
|
101
101
|
src: url,
|
|
102
102
|
alt: "Image Preview",
|
|
103
103
|
width: 1920,
|
|
104
104
|
height: 1080,
|
|
105
|
-
className: "h-full w-full rounded-xl object-contain"
|
|
106
|
-
loader: imageLoader
|
|
105
|
+
className: "h-full w-full rounded-xl object-contain"
|
|
107
106
|
})
|
|
108
107
|
}, id))
|
|
109
108
|
}),
|
|
@@ -114,27 +113,26 @@ function ImageGrid({ nodes, moveAction, optimistic, disabled, ...props }) {
|
|
|
114
113
|
})]
|
|
115
114
|
});
|
|
116
115
|
}
|
|
117
|
-
function ImageGridItem({
|
|
116
|
+
function ImageGridItem({ asset, index, setCurrent }) {
|
|
118
117
|
const uploadZone = useUploadZone();
|
|
119
|
-
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id:
|
|
118
|
+
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id: asset.id });
|
|
120
119
|
return /* @__PURE__ */ jsx(Card, {
|
|
121
|
-
id:
|
|
120
|
+
id: asset.id,
|
|
122
121
|
ref: setNodeRef,
|
|
123
122
|
style: {
|
|
124
123
|
transform: CSS.Transform.toString(transform),
|
|
125
124
|
transition
|
|
126
125
|
},
|
|
127
|
-
className: cn("group relative aspect-square w-full",
|
|
128
|
-
children:
|
|
126
|
+
className: cn("group relative aspect-square w-full", asset.status === "pending" && "opacity-30"),
|
|
127
|
+
children: asset.status === "ready" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
129
128
|
/* @__PURE__ */ jsx(DialogTrigger, {
|
|
130
129
|
onClick: () => setCurrent(index),
|
|
131
|
-
children: /* @__PURE__ */ jsx(
|
|
132
|
-
src:
|
|
130
|
+
children: /* @__PURE__ */ jsx(StorageImage, {
|
|
131
|
+
src: asset.url,
|
|
133
132
|
alt: "Image Preview",
|
|
134
133
|
width: 100,
|
|
135
134
|
height: 100,
|
|
136
|
-
className: "absolute inset-0 h-full w-full cursor-pointer rounded-lg bg-muted object-contain"
|
|
137
|
-
loader: imageLoader
|
|
135
|
+
className: "absolute inset-0 h-full w-full cursor-pointer rounded-lg bg-muted object-contain"
|
|
138
136
|
})
|
|
139
137
|
}),
|
|
140
138
|
/* @__PURE__ */ jsx(Button, {
|
|
@@ -150,7 +148,7 @@ function ImageGridItem({ node, index, setCurrent }) {
|
|
|
150
148
|
type: "button",
|
|
151
149
|
variant: "destructive",
|
|
152
150
|
size: "icon",
|
|
153
|
-
onClick: () => uploadZone.onRemove([
|
|
151
|
+
onClick: () => uploadZone.onRemove([asset.id]),
|
|
154
152
|
className: "absolute top-2 left-2 hidden p-1 group-hover:flex",
|
|
155
153
|
children: /* @__PURE__ */ jsx(Icons.trash, { className: "size-4" })
|
|
156
154
|
})
|
|
@@ -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 {\n closestCenter,\n DndContext,\n type 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, { type ComponentProps } from \"react\";\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.client\";\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 { cn } from \"@/lib/utils/cn\";\nimport { getFileUrl, imageLoader } from \"../lib/helpers\";\nimport type { 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 optimistic?: {\n move?: (params: { fromIndex: number; toIndex: number }) => Promise<void> | void;\n };\n};\n\nexport function ImageGrid({ nodes, moveAction, optimistic, disabled, ...props }: ImageGridProps) {\n const uploadZone = 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 optimistic?.move?.({ fromIndex, toIndex });\n await moveAction({ fromIndex, toIndex });\n },\n onSuccess: async () => {\n setCurrent(0);\n await uploadZone.optimistic?.invalidate?.();\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\n htmlFor=\"file-upload\"\n className=\"relative flex aspect-square w-full cursor-pointer flex-col items-center justify-center rounded-lg border border-muted-foreground border-dashed bg-muted hover:border-primary\"\n >\n <UploadIcon className=\"h-8 w-8\" />\n <Input\n id=\"file-upload\"\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(uploadZone.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 uploadZone = 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=\"absolute inset-0 h-full w-full cursor-pointer rounded-lg bg-muted 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 top-2 right-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={() => uploadZone.onRemove([node.id])}\n className=\"absolute top-2 left-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":[],"sources":["../../../../src/modules/storage/components/image-grid.client.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n closestCenter,\n DndContext,\n type 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 React, { type ComponentProps } from \"react\";\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.client\";\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 { cn } from \"@/lib/utils/cn\";\nimport { getAssetURL } from \"../lib/helpers\";\nimport type { StorageAsset } from \"../lib/validators\";\nimport { StorageImage } from \"./image.client\";\nimport { useUploadZone } from \"./upload-zone-context.client\";\n\n/**\n * Image Grid\n */\ntype ImageGridProps = ComponentProps<\"div\"> & {\n assets: StorageAsset[];\n disabled?: boolean;\n moveAction: (params: { fromIndex: number; toIndex: number }) => Promise<void>;\n optimistic?: {\n move?: (params: { fromIndex: number; toIndex: number }) => Promise<void> | void;\n };\n};\n\nexport function ImageGrid({ assets, moveAction, optimistic, disabled, ...props }: ImageGridProps) {\n const uploadZone = useUploadZone();\n\n const images = assets.flatMap((asset) => ({ ...asset, url: getAssetURL(asset.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 optimistic?.move?.({ fromIndex, toIndex });\n await moveAction({ fromIndex, toIndex });\n },\n onSuccess: async () => {\n setCurrent(0);\n await uploadZone.optimistic?.invalidate?.();\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((asset, index) => (\n <ImageGridItem key={asset.id} asset={asset} index={index} setCurrent={setCurrent} />\n ))}\n\n {!disabled && (\n <label\n htmlFor=\"file-upload\"\n className=\"relative flex aspect-square w-full cursor-pointer flex-col items-center justify-center rounded-lg border border-muted-foreground border-dashed bg-muted hover:border-primary\"\n >\n <UploadIcon className=\"h-8 w-8\" />\n <Input\n id=\"file-upload\"\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(uploadZone.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 <StorageImage\n src={url}\n alt=\"Image Preview\"\n width={1920}\n height={1080}\n className=\"h-full w-full rounded-xl object-contain\"\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 asset: StorageAsset & { url: string };\n index: number;\n setCurrent: React.Dispatch<React.SetStateAction<number>>;\n};\n\nfunction ImageGridItem({ asset, index, setCurrent }: ImageGridItemProps) {\n const uploadZone = useUploadZone();\n\n const { attributes, listeners, setNodeRef, transform, transition } = useSortable({\n id: asset.id,\n });\n\n return (\n <Card\n id={asset.id}\n ref={setNodeRef}\n style={{\n transform: CSS.Transform.toString(transform),\n transition,\n }}\n className={cn(\n \"group relative aspect-square w-full\",\n asset.status === \"pending\" && \"opacity-30\",\n )}\n >\n {asset.status === \"ready\" ? (\n <>\n <DialogTrigger onClick={() => setCurrent(index)}>\n <StorageImage\n src={asset.url}\n alt=\"Image Preview\"\n width={100}\n height={100}\n className=\"absolute inset-0 h-full w-full cursor-pointer rounded-lg bg-muted object-contain\"\n />\n </DialogTrigger>\n\n <Button\n {...attributes}\n {...listeners}\n type=\"button\"\n variant=\"secondary\"\n size=\"icon\"\n className=\"absolute top-2 right-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={() => uploadZone.onRemove([asset.id])}\n className=\"absolute top-2 left-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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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
|
+
import { ImageProps } from "next/image";
|
|
3
|
+
|
|
4
|
+
//#region src/modules/storage/components/image.client.d.ts
|
|
5
|
+
declare function StorageImage(props: Omit<ImageProps, "loader">): react_jsx_runtime0.JSX.Element;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { StorageImage };
|
|
8
|
+
//# sourceMappingURL=image.client.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/image.client.tsx"],"mappings":";;;;iBAKgB,YAAA,CAAa,KAAA,EAAO,IAAA,CAAK,UAAA,cAAqB,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { imageLoader } from "../lib/helpers.mjs";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import Image from "next/image";
|
|
6
|
+
|
|
7
|
+
//#region src/modules/storage/components/image.client.tsx
|
|
8
|
+
function StorageImage(props) {
|
|
9
|
+
return /* @__PURE__ */ jsx(Image, {
|
|
10
|
+
...props,
|
|
11
|
+
loader: imageLoader
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { StorageImage };
|
|
17
|
+
//# sourceMappingURL=image.client.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.client.mjs","names":[],"sources":["../../../../src/modules/storage/components/image.client.tsx"],"sourcesContent":["\"use client\";\n\nimport Image, { type ImageProps } from \"next/image\";\nimport { imageLoader } from \"../lib/helpers\";\n\nexport function StorageImage(props: Omit<ImageProps, \"loader\">) {\n return <Image {...props} loader={imageLoader} />;\n}\n"],"mappings":";;;;;;;AAKA,SAAgB,aAAa,OAAmC;AAC9D,QAAO,oBAAC;EAAM,GAAI;EAAO,QAAQ;GAAe"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Button } from "../../../components/ui/button.mjs";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
import { ComponentProps } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/modules/storage/components/upload-button.client.d.ts
|
|
6
|
+
declare function UploadButton({
|
|
7
|
+
className,
|
|
8
|
+
...props
|
|
9
|
+
}: ComponentProps<typeof Button>): react_jsx_runtime0.JSX.Element;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { UploadButton };
|
|
12
|
+
//# sourceMappingURL=upload-button.client.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-button.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/upload-button.client.tsx"],"mappings":";;;;;iBASgB,YAAA,CAAA;EAAe,SAAA;EAAA,GAAc;AAAA,GAAS,cAAA,QAAsB,MAAA,IAAO,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../../lib/utils/cn.mjs";
|
|
4
|
+
import { Button } from "../../../components/ui/button.mjs";
|
|
5
|
+
import { Input } from "../../../components/ui/input.mjs";
|
|
6
|
+
import { useUploadZone } from "./upload-zone-context.client.mjs";
|
|
7
|
+
import { UploadIcon } from "lucide-react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
|
|
10
|
+
//#region src/modules/storage/components/upload-button.client.tsx
|
|
11
|
+
function UploadButton({ className, ...props }) {
|
|
12
|
+
const { onUpload } = useUploadZone();
|
|
13
|
+
return /* @__PURE__ */ jsxs(Button, {
|
|
14
|
+
...props,
|
|
15
|
+
className: cn("relative gap-2", className),
|
|
16
|
+
children: [
|
|
17
|
+
/* @__PURE__ */ jsx(UploadIcon, { className: "h-3 w-3" }),
|
|
18
|
+
/* @__PURE__ */ jsx("span", { children: "Upload" }),
|
|
19
|
+
/* @__PURE__ */ jsx(Input, {
|
|
20
|
+
type: "file",
|
|
21
|
+
className: "absolute inset-0 z-10 h-full w-full cursor-pointer opacity-0",
|
|
22
|
+
multiple: true,
|
|
23
|
+
onChange: (e) => {
|
|
24
|
+
if (!e.target.files) return;
|
|
25
|
+
Array.from(e.target.files).forEach(onUpload);
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { UploadButton };
|
|
34
|
+
//# sourceMappingURL=upload-button.client.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-button.client.mjs","names":[],"sources":["../../../../src/modules/storage/components/upload-button.client.tsx"],"sourcesContent":["\"use client\";\n\nimport { UploadIcon } from \"lucide-react\";\nimport type { ComponentProps } from \"react\";\nimport { Button } from \"@/components/ui/button\";\nimport { Input } from \"@/components/ui/input\";\nimport { cn } from \"@/lib/utils/cn\";\nimport { useUploadZone } from \"./upload-zone-context.client\";\n\nexport function UploadButton({ className, ...props }: ComponentProps<typeof Button>) {\n const { onUpload } = useUploadZone();\n\n return (\n <Button {...props} className={cn(\"relative gap-2\", className)}>\n <UploadIcon className=\"h-3 w-3\" />\n <span>Upload</span>\n\n <Input\n type=\"file\"\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 Array.from(e.target.files).forEach(onUpload);\n }}\n />\n </Button>\n );\n}\n"],"mappings":";;;;;;;;;;AASA,SAAgB,aAAa,EAAE,WAAW,GAAG,SAAwC;CACnF,MAAM,EAAE,aAAa,eAAe;AAEpC,QACE,qBAAC;EAAO,GAAI;EAAO,WAAW,GAAG,kBAAkB,UAAU;;GAC3D,oBAAC,cAAW,WAAU,YAAY;GAClC,oBAAC,oBAAK,WAAa;GAEnB,oBAAC;IACC,MAAK;IACL,WAAU;IACV;IACA,WAAW,MAAM;AACf,SAAI,CAAC,EAAE,OAAO,MAAO;AACrB,WAAM,KAAK,EAAE,OAAO,MAAM,CAAC,QAAQ,SAAS;;KAE9C;;GACK"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { UploadClient } from "../lib/
|
|
1
|
+
import { StorageAsset } from "../lib/validators.mjs";
|
|
2
|
+
import { UploadClient } from "../lib/upload.client.mjs";
|
|
3
3
|
import React from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/modules/storage/components/upload-zone-context.client.d.ts
|
|
@@ -8,10 +8,10 @@ import React from "react";
|
|
|
8
8
|
*/
|
|
9
9
|
type UploadZoneContextValue = {
|
|
10
10
|
uploadClient: UploadClient;
|
|
11
|
-
onUpload: (file: File) => Promise<
|
|
11
|
+
onUpload: (file: File) => Promise<StorageAsset>;
|
|
12
12
|
onRemove: (ids: string[]) => Promise<void>;
|
|
13
13
|
optimistic?: {
|
|
14
|
-
add?: (newValue:
|
|
14
|
+
add?: (newValue: Omit<StorageAsset, "id" | "key" | "bucket" | "provider" | "createdAt" | "updatedAt">) => Promise<void> | void;
|
|
15
15
|
remove?: (ids: string[]) => Promise<void> | void;
|
|
16
16
|
invalidate?: () => Promise<void> | void;
|
|
17
17
|
cancel?: () => Promise<void> | void;
|
|
@@ -21,7 +21,7 @@ type UploadZoneContextValue = {
|
|
|
21
21
|
/**
|
|
22
22
|
* Upload Zone Context
|
|
23
23
|
*/
|
|
24
|
-
declare const UploadZoneContext: React.Context<UploadZoneContextValue>;
|
|
24
|
+
declare const UploadZoneContext: React.Context<UploadZoneContextValue | null>;
|
|
25
25
|
/**
|
|
26
26
|
* Upload Zone Hook
|
|
27
27
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-zone-context.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/upload-zone-context.client.tsx"],"mappings":";;;;;;;AASA;KAAY,sBAAA;EACV,YAAA,EAAc,YAAA;EACd,QAAA,GAAW,IAAA,EAAM,IAAA,KAAS,OAAA,CAAQ,
|
|
1
|
+
{"version":3,"file":"upload-zone-context.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/upload-zone-context.client.tsx"],"mappings":";;;;;;;AASA;KAAY,sBAAA;EACV,YAAA,EAAc,YAAA;EACd,QAAA,GAAW,IAAA,EAAM,IAAA,KAAS,OAAA,CAAQ,YAAA;EAClC,QAAA,GAAW,GAAA,eAAkB,OAAA;EAC7B,UAAA;IACE,GAAA,IACE,QAAA,EAAU,IAAA,CACR,YAAA,wEAGC,OAAA;IACL,MAAA,IAAU,GAAA,eAAkB,OAAA;IAC5B,UAAA,SAAmB,OAAA;IACnB,MAAA,SAAe,OAAA;EAAA;EAEjB,QAAA;AAAA;;;;cAMW,iBAAA,EAAiB,KAAA,CAAA,OAAA,CAAA,sBAAA;;;;iBAKd,aAAA,CAAA,GAAa,sBAAA"}
|
|
@@ -6,13 +6,13 @@ import React from "react";
|
|
|
6
6
|
/**
|
|
7
7
|
* Upload Zone Context
|
|
8
8
|
*/
|
|
9
|
-
const UploadZoneContext = React.createContext(
|
|
9
|
+
const UploadZoneContext = React.createContext(null);
|
|
10
10
|
/**
|
|
11
11
|
* Upload Zone Hook
|
|
12
12
|
*/
|
|
13
13
|
function useUploadZone() {
|
|
14
14
|
const context = React.useContext(UploadZoneContext);
|
|
15
|
-
if (!context) throw new Error("useUploadZone must be used within an
|
|
15
|
+
if (!context) throw new Error("useUploadZone must be used within an UploadZoneContext provider");
|
|
16
16
|
return context;
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -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 type { UploadClient } from \"../lib/
|
|
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 type { UploadClient } from \"../lib/upload.client\";\nimport type { StorageAsset } from \"../lib/validators\";\n\n/**\n * Upload Zone Context Value\n */\nexport type UploadZoneContextValue = {\n uploadClient: UploadClient;\n onUpload: (file: File) => Promise<StorageAsset>;\n onRemove: (ids: string[]) => Promise<void>;\n optimistic?: {\n add?: (\n newValue: Omit<\n StorageAsset,\n \"id\" | \"key\" | \"bucket\" | \"provider\" | \"createdAt\" | \"updatedAt\"\n >,\n ) => Promise<void> | void;\n remove?: (ids: string[]) => Promise<void> | void;\n invalidate?: () => Promise<void> | void;\n cancel?: () => Promise<void> | void;\n };\n disabled?: boolean;\n};\n\n/**\n * Upload Zone Context\n */\nexport const UploadZoneContext = React.createContext<UploadZoneContextValue | null>(null);\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 UploadZoneContext provider\");\n }\n return context;\n}\n"],"mappings":";;;;;;;;AA8BA,MAAa,oBAAoB,MAAM,cAA6C,KAAK;;;;AAKzF,SAAgB,gBAAgB;CAC9B,MAAM,UAAU,MAAM,WAAW,kBAAkB;AACnD,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,kEAAkE;AAEpF,QAAO"}
|