@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
|
@@ -1,117 +1,145 @@
|
|
|
1
1
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
2
|
+
import type { Keys } from "react-hotkeys-hook/dist/types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Inline input data attribute used to identify navigable cells in the data table.
|
|
6
|
+
*/
|
|
7
|
+
export const INLINE_INPUT_ATTR = "data-inline-input";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Props for configuring the hotkeys used for navigating between inline-editable cells in a data table.
|
|
11
|
+
* Each property corresponds to a direction of navigation and accepts an array of key combinations that trigger the navigation in that direction.
|
|
12
|
+
* If a property is not provided or is an empty array, the corresponding navigation hotkeys will be disabled.
|
|
13
|
+
*/
|
|
14
|
+
export type InlineDataTableHotkeysConfig = {
|
|
15
|
+
moveLeft?: Keys | undefined;
|
|
16
|
+
moveRight?: Keys | undefined;
|
|
17
|
+
moveUp?: Keys | undefined;
|
|
18
|
+
moveDown?: Keys | undefined;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Sets up hotkeys for navigating between inline-editable cells in a data table:
|
|
23
|
+
* - ArrowUp / ArrowDown: Move vertically to the next cell with an input in the same column.
|
|
24
|
+
* - ArrowLeft / ArrowRight: Move horizontally to the next cell with an input in the same row.
|
|
25
|
+
*
|
|
26
|
+
* The hotkeys only trigger when focused within a table that uses the "inline-data-table" scope,
|
|
27
|
+
* and they look for elements with the [data-inline-input] attribute to determine navigable cells.
|
|
28
|
+
*/
|
|
29
|
+
export function useInlineDataTableHotkeys(props: InlineDataTableHotkeysConfig = {}) {
|
|
30
|
+
/**
|
|
31
|
+
* Move left hotkey handler
|
|
32
|
+
*/
|
|
33
|
+
useHotkeys(
|
|
34
|
+
props.moveLeft ?? [],
|
|
35
|
+
(e) => {
|
|
36
|
+
const currentCell = (e.target as HTMLElement)?.closest("td");
|
|
37
|
+
if (!currentCell) return;
|
|
38
|
+
|
|
39
|
+
let cell = currentCell.previousElementSibling;
|
|
40
|
+
|
|
41
|
+
while (cell) {
|
|
42
|
+
const input = cell.querySelector(`[${INLINE_INPUT_ATTR}]`) as HTMLElement | null;
|
|
43
|
+
if (input) {
|
|
44
|
+
input.focus();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
cell = cell.previousElementSibling;
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
enabled: !!(props.moveLeft && props.moveLeft.length > 0),
|
|
52
|
+
scopes: "inline-data-table",
|
|
53
|
+
enableOnFormTags: true,
|
|
54
|
+
enableOnContentEditable: true,
|
|
55
|
+
preventDefault: true,
|
|
56
|
+
},
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Move right hotkey handler
|
|
61
|
+
*/
|
|
62
|
+
useHotkeys(
|
|
63
|
+
props.moveRight ?? [],
|
|
64
|
+
(e) => {
|
|
65
|
+
const currentCell = (e.target as HTMLElement)?.closest("td");
|
|
66
|
+
if (!currentCell) return;
|
|
67
|
+
|
|
68
|
+
let cell = currentCell.nextElementSibling;
|
|
69
|
+
|
|
70
|
+
while (cell) {
|
|
71
|
+
const input = cell.querySelector(`[${INLINE_INPUT_ATTR}]`) as HTMLElement | null;
|
|
72
|
+
if (input) {
|
|
73
|
+
input.focus();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
cell = cell.nextElementSibling;
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
enabled: !!(props.moveRight && props.moveRight.length > 0),
|
|
81
|
+
scopes: "inline-data-table",
|
|
82
|
+
enableOnFormTags: true,
|
|
83
|
+
enableOnContentEditable: true,
|
|
84
|
+
preventDefault: true,
|
|
85
|
+
},
|
|
86
|
+
);
|
|
2
87
|
|
|
3
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Move up hotkey handler
|
|
90
|
+
*/
|
|
4
91
|
useHotkeys(
|
|
5
|
-
[
|
|
6
|
-
(e
|
|
7
|
-
const
|
|
8
|
-
|
|
92
|
+
props.moveUp ?? [],
|
|
93
|
+
(e) => {
|
|
94
|
+
const currentCell = (e.target as HTMLElement)?.closest("td") as HTMLTableCellElement | null;
|
|
95
|
+
if (!currentCell) return;
|
|
9
96
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
: currentCell?.nextElementSibling;
|
|
97
|
+
const currentRow = currentCell.closest("tr");
|
|
98
|
+
const nextRow = currentRow?.previousElementSibling;
|
|
13
99
|
|
|
14
|
-
const
|
|
100
|
+
const nextInput = nextRow
|
|
101
|
+
? ((nextRow as HTMLTableRowElement).cells?.[currentCell.cellIndex]?.querySelector(
|
|
102
|
+
`[${INLINE_INPUT_ATTR}]`,
|
|
103
|
+
) as HTMLElement | null)
|
|
104
|
+
: null;
|
|
15
105
|
|
|
16
|
-
|
|
106
|
+
nextInput?.focus();
|
|
17
107
|
},
|
|
18
108
|
{
|
|
109
|
+
enabled: !!(props.moveUp && props.moveUp.length > 0),
|
|
19
110
|
scopes: "inline-data-table",
|
|
20
111
|
enableOnFormTags: true,
|
|
112
|
+
enableOnContentEditable: true,
|
|
21
113
|
preventDefault: true,
|
|
22
114
|
},
|
|
23
115
|
);
|
|
24
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Move down hotkey handler
|
|
119
|
+
*/
|
|
25
120
|
useHotkeys(
|
|
26
|
-
[
|
|
27
|
-
(e
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
const currentRow = currentInput?.closest("tr");
|
|
121
|
+
props.moveDown ?? [],
|
|
122
|
+
(e) => {
|
|
123
|
+
const currentCell = (e.target as HTMLElement)?.closest("td") as HTMLTableCellElement | null;
|
|
124
|
+
if (!currentCell) return;
|
|
31
125
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
: currentRow?.nextElementSibling;
|
|
126
|
+
const currentRow = currentCell.closest("tr");
|
|
127
|
+
const nextRow = currentRow?.nextElementSibling;
|
|
35
128
|
|
|
36
|
-
const
|
|
37
|
-
?.querySelector(
|
|
38
|
-
|
|
129
|
+
const nextInput = nextRow
|
|
130
|
+
? ((nextRow as HTMLTableRowElement).cells?.[currentCell.cellIndex]?.querySelector(
|
|
131
|
+
`[${INLINE_INPUT_ATTR}]`,
|
|
132
|
+
) as HTMLElement | null)
|
|
133
|
+
: null;
|
|
39
134
|
|
|
40
|
-
|
|
135
|
+
nextInput?.focus();
|
|
41
136
|
},
|
|
42
137
|
{
|
|
138
|
+
enabled: !!(props.moveDown && props.moveDown.length > 0),
|
|
43
139
|
scopes: "inline-data-table",
|
|
44
140
|
enableOnFormTags: true,
|
|
141
|
+
enableOnContentEditable: true,
|
|
45
142
|
preventDefault: true,
|
|
46
143
|
},
|
|
47
144
|
);
|
|
48
|
-
|
|
49
|
-
// useHotkeys(
|
|
50
|
-
// ["mod+shift+arrowdown", "mod+shift+arrowup"],
|
|
51
|
-
// (e, handler) => {
|
|
52
|
-
// if (!meta.isDraggable) return;
|
|
53
|
-
|
|
54
|
-
// const currentInput = e.target as HTMLInputElement | null;
|
|
55
|
-
// const rowIndex = currentInput?.closest("td")?.getAttribute("data-row-index");
|
|
56
|
-
|
|
57
|
-
// const fromIndex = Number(rowIndex);
|
|
58
|
-
// const toIndex = Number(rowIndex) + (handler.keys?.includes("down") ? 1 : -1);
|
|
59
|
-
|
|
60
|
-
// meta.moveRow({ fromIndex, toIndex });
|
|
61
|
-
// },
|
|
62
|
-
// {
|
|
63
|
-
// scopes: "inline-data-table",
|
|
64
|
-
// enableOnFormTags: true,
|
|
65
|
-
// preventDefault: true,
|
|
66
|
-
// enabled: meta.isDraggable,
|
|
67
|
-
// },
|
|
68
|
-
// );
|
|
69
|
-
|
|
70
|
-
// useHotkeys(
|
|
71
|
-
// "mod+d",
|
|
72
|
-
// (e) => {
|
|
73
|
-
// if (!meta.isDeletable) return;
|
|
74
|
-
|
|
75
|
-
// const currentInput = e.target as HTMLInputElement | null;
|
|
76
|
-
// const currentCell = currentInput?.closest("td");
|
|
77
|
-
// const currentRow = currentInput?.closest("tr");
|
|
78
|
-
|
|
79
|
-
// const columnId = currentCell?.getAttribute("data-column-id");
|
|
80
|
-
// const rowId = currentRow?.getAttribute("data-row-id");
|
|
81
|
-
|
|
82
|
-
// if (rowId) meta.deleteRow({ id: rowId });
|
|
83
|
-
|
|
84
|
-
// // Focus on the next cell
|
|
85
|
-
// const nextRow = currentRow?.nextElementSibling;
|
|
86
|
-
// const nextCell = nextRow
|
|
87
|
-
// ?.querySelector(`td[data-column-id="${columnId}"]`)
|
|
88
|
-
// ?.querySelector("[data-input]") as HTMLInputElement | null;
|
|
89
|
-
|
|
90
|
-
// nextCell?.focus();
|
|
91
|
-
// },
|
|
92
|
-
// {
|
|
93
|
-
// scopes: "inline-data-table",
|
|
94
|
-
// enableOnFormTags: true,
|
|
95
|
-
// preventDefault: true,
|
|
96
|
-
// enabled: meta.isDeletable,
|
|
97
|
-
// },
|
|
98
|
-
// );
|
|
99
|
-
|
|
100
|
-
// useHotkeys(
|
|
101
|
-
// ["mod+i", "mod+u"],
|
|
102
|
-
// (e, handler) => {
|
|
103
|
-
// if (!meta.isCreatable) return;
|
|
104
|
-
|
|
105
|
-
// const currentInput = e.target as HTMLInputElement | null;
|
|
106
|
-
// const rowIndex = currentInput?.closest("td")?.getAttribute("data-row-index");
|
|
107
|
-
// const index = Number(rowIndex) + (handler.keys?.includes("i") ? 1 : 0);
|
|
108
|
-
// rowIndex && meta.addRow({ index });
|
|
109
|
-
// },
|
|
110
|
-
// {
|
|
111
|
-
// scopes: "inline-data-table",
|
|
112
|
-
// enableOnFormTags: true,
|
|
113
|
-
// preventDefault: true,
|
|
114
|
-
// enabled: meta.isCreatable,
|
|
115
|
-
// },
|
|
116
|
-
// );
|
|
117
145
|
}
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { drizzle } from "drizzle-orm/node-postgres";
|
|
2
|
+
import type { Pool } from "pg";
|
|
3
|
+
import type { TDatabaseSchema } from "./types";
|
|
4
|
+
|
|
5
|
+
type InitDatabaseProps<TSchema extends TDatabaseSchema> = {
|
|
6
|
+
schema: TSchema;
|
|
7
|
+
pool: Pool;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Create a Drizzle database client.
|
|
12
|
+
*/
|
|
13
|
+
function createDatabase<TSchema extends TDatabaseSchema>({
|
|
14
|
+
schema,
|
|
15
|
+
pool,
|
|
16
|
+
}: InitDatabaseProps<TSchema>) {
|
|
17
|
+
return drizzle({ client: pool, schema, casing: "snake_case" });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Drizzle database client type returned by `Database.init()`.
|
|
22
|
+
*/
|
|
23
|
+
export type Database<TSchema extends TDatabaseSchema> = ReturnType<typeof createDatabase<TSchema>>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Database service namespace.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* const db = Database.init<DatabaseSchema>({ schema, pool });
|
|
30
|
+
*/
|
|
31
|
+
export const Database = {
|
|
32
|
+
init: createDatabase,
|
|
33
|
+
};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import "server-cli-only";
|
|
2
|
+
|
|
3
|
+
import { Resend } from "resend";
|
|
4
|
+
|
|
5
|
+
type InitEmailProps = {
|
|
6
|
+
key: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Create a Resend email client.
|
|
11
|
+
*/
|
|
12
|
+
function createEmail({ key }: InitEmailProps) {
|
|
13
|
+
return new Resend(key);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Resend email client type returned by `Email.init()`.
|
|
18
|
+
*/
|
|
19
|
+
export type Email = ReturnType<typeof createEmail>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Email service namespace.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* const email = Email.init({ key: env.RESEND_API_KEY });
|
|
26
|
+
*/
|
|
27
|
+
export const Email = {
|
|
28
|
+
init: createEmail,
|
|
29
|
+
};
|
|
@@ -54,7 +54,7 @@ export function InlineDateInput<Required extends boolean = false>({
|
|
|
54
54
|
<Popover>
|
|
55
55
|
<div {...props} className={cn("relative h-full", className)}>
|
|
56
56
|
<Input
|
|
57
|
-
data-input
|
|
57
|
+
data-inline-input="date"
|
|
58
58
|
type="string"
|
|
59
59
|
value={stringDate}
|
|
60
60
|
className={cn(inlineEditVariants({ variant, status }), inValid && "text-destructive")}
|
|
@@ -50,6 +50,7 @@ export function InlineDatePicker<Required extends boolean = false>({
|
|
|
50
50
|
<PopoverTrigger asChild>
|
|
51
51
|
<Button
|
|
52
52
|
{...props}
|
|
53
|
+
data-inline-input="date-picker"
|
|
53
54
|
type="button"
|
|
54
55
|
variant="outline"
|
|
55
56
|
className={cn("w-full", inlineEditVariants({ variant, status }), className)}
|
|
@@ -43,6 +43,7 @@ export function InlineDateTimeInput<Required extends boolean = false>({
|
|
|
43
43
|
|
|
44
44
|
return (
|
|
45
45
|
<DateTimeInput
|
|
46
|
+
data-inline-input="date-time"
|
|
46
47
|
value={value ?? undefined}
|
|
47
48
|
className={cn(inlineEditVariants({ variant, status }), className)}
|
|
48
49
|
disabled={disabled || !isAllowed}
|
|
@@ -46,6 +46,9 @@ export function InlineEditor<Required extends boolean = false>({
|
|
|
46
46
|
className={cn(inlineEditVariants({ variant, status }), className)}
|
|
47
47
|
disabled={disabled || !isAllowed}
|
|
48
48
|
variant={variant}
|
|
49
|
+
attributes={{
|
|
50
|
+
"data-inline-input": "editor",
|
|
51
|
+
}}
|
|
49
52
|
>
|
|
50
53
|
{children}
|
|
51
54
|
</Editor>
|
|
@@ -42,6 +42,7 @@ export function InlineStringInput<Required extends boolean = false>({
|
|
|
42
42
|
return (
|
|
43
43
|
<Input
|
|
44
44
|
{...props}
|
|
45
|
+
data-inline-input="string"
|
|
45
46
|
type="text"
|
|
46
47
|
value={value ?? undefined}
|
|
47
48
|
disabled={disabled || !isAllowed}
|
|
@@ -88,6 +89,7 @@ export function InlineNumberInput<Required extends boolean = false>({
|
|
|
88
89
|
return (
|
|
89
90
|
<Input
|
|
90
91
|
{...props}
|
|
92
|
+
data-inline-input="number"
|
|
91
93
|
type="number"
|
|
92
94
|
value={value ?? undefined}
|
|
93
95
|
disabled={disabled || !isAllowed}
|
|
@@ -131,6 +133,7 @@ export function InlineDecimalInput({
|
|
|
131
133
|
return (
|
|
132
134
|
<Input
|
|
133
135
|
{...props}
|
|
136
|
+
data-inline-input="decimal"
|
|
134
137
|
type="number"
|
|
135
138
|
value={value ?? undefined}
|
|
136
139
|
disabled={disabled || !isAllowed}
|
|
@@ -55,7 +55,11 @@ export function InlineSelectTrigger({
|
|
|
55
55
|
const { status } = useIndicator();
|
|
56
56
|
|
|
57
57
|
return (
|
|
58
|
-
<SelectTrigger
|
|
58
|
+
<SelectTrigger
|
|
59
|
+
{...props}
|
|
60
|
+
data-inline-input="select"
|
|
61
|
+
className={cn(inlineEditVariants({ variant, status }), className)}
|
|
62
|
+
/>
|
|
59
63
|
);
|
|
60
64
|
}
|
|
61
65
|
|
|
@@ -33,6 +33,7 @@ export function InlineToggle<Required extends boolean = false>({
|
|
|
33
33
|
return (
|
|
34
34
|
<div {...props} className={cn("flex flex-wrap items-center justify-start gap-1", className)}>
|
|
35
35
|
<Toggle
|
|
36
|
+
data-inline-input="toggle"
|
|
36
37
|
disabled={!isAllowed}
|
|
37
38
|
variant="outline"
|
|
38
39
|
pressed={value ?? undefined}
|
|
@@ -33,7 +33,7 @@ export function initRPC<TSchema extends TDatabaseSchema>() {
|
|
|
33
33
|
/**
|
|
34
34
|
* Middleware function to check if the user has the required permission
|
|
35
35
|
*/
|
|
36
|
-
function permissionMiddleware(
|
|
36
|
+
function permissionMiddleware(permissions: Permission) {
|
|
37
37
|
/**
|
|
38
38
|
* Middleware function to check if the user has the required permission
|
|
39
39
|
*/
|
|
@@ -41,7 +41,7 @@ export function initRPC<TSchema extends TDatabaseSchema>() {
|
|
|
41
41
|
const { success, error } = await opts.context.auth.api.userHasPermission({
|
|
42
42
|
body: {
|
|
43
43
|
userId: opts.context.session.user.id,
|
|
44
|
-
|
|
44
|
+
permissions,
|
|
45
45
|
},
|
|
46
46
|
});
|
|
47
47
|
|
|
@@ -6,7 +6,7 @@ import type { DropEvent, DropzoneOptions, FileRejection } from "react-dropzone";
|
|
|
6
6
|
import { useDropzone } from "react-dropzone";
|
|
7
7
|
import { Button } from "@/components/ui/button";
|
|
8
8
|
import { cn } from "@/lib/utils/cn";
|
|
9
|
-
import { renderBytes } from "
|
|
9
|
+
import { renderBytes } from "../lib/helpers";
|
|
10
10
|
import { DropzoneContext, useDropzoneContext } from "./dropzone-context.client";
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
} from "@dnd-kit/sortable";
|
|
19
19
|
import { CSS } from "@dnd-kit/utilities";
|
|
20
20
|
import { GripIcon, UploadIcon } from "lucide-react";
|
|
21
|
-
import Image from "next/image";
|
|
22
21
|
import React, { type ComponentProps } from "react";
|
|
23
22
|
import { Icons } from "@/components/common/icons";
|
|
24
23
|
import { Button } from "@/components/ui/button";
|
|
@@ -35,15 +34,16 @@ import { Input } from "@/components/ui/input";
|
|
|
35
34
|
import { Skeleton } from "@/components/ui/skeleton";
|
|
36
35
|
import { useAction } from "@/lib/entry.client";
|
|
37
36
|
import { cn } from "@/lib/utils/cn";
|
|
38
|
-
import {
|
|
39
|
-
import type {
|
|
37
|
+
import { getAssetURL } from "../lib/helpers";
|
|
38
|
+
import type { StorageAsset } from "../lib/validators";
|
|
39
|
+
import { StorageImage } from "./image.client";
|
|
40
40
|
import { useUploadZone } from "./upload-zone-context.client";
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* Image Grid
|
|
44
44
|
*/
|
|
45
45
|
type ImageGridProps = ComponentProps<"div"> & {
|
|
46
|
-
|
|
46
|
+
assets: StorageAsset[];
|
|
47
47
|
disabled?: boolean;
|
|
48
48
|
moveAction: (params: { fromIndex: number; toIndex: number }) => Promise<void>;
|
|
49
49
|
optimistic?: {
|
|
@@ -51,10 +51,10 @@ type ImageGridProps = ComponentProps<"div"> & {
|
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
export function ImageGrid({
|
|
54
|
+
export function ImageGrid({ assets, moveAction, optimistic, disabled, ...props }: ImageGridProps) {
|
|
55
55
|
const uploadZone = useUploadZone();
|
|
56
56
|
|
|
57
|
-
const images =
|
|
57
|
+
const images = assets.flatMap((asset) => ({ ...asset, url: getAssetURL(asset.id) }));
|
|
58
58
|
|
|
59
59
|
const [current, setCurrent] = React.useState<number>(0);
|
|
60
60
|
|
|
@@ -101,8 +101,8 @@ export function ImageGrid({ nodes, moveAction, optimistic, disabled, ...props }:
|
|
|
101
101
|
className="grid grid-cols-[repeat(auto-fill,minmax(10rem,1fr))] gap-5"
|
|
102
102
|
>
|
|
103
103
|
<SortableContext items={images.map((image) => image.id)} strategy={rectSortingStrategy}>
|
|
104
|
-
{images.map((
|
|
105
|
-
<ImageGridItem key={
|
|
104
|
+
{images.map((asset, index) => (
|
|
105
|
+
<ImageGridItem key={asset.id} asset={asset} index={index} setCurrent={setCurrent} />
|
|
106
106
|
))}
|
|
107
107
|
|
|
108
108
|
{!disabled && (
|
|
@@ -133,13 +133,12 @@ export function ImageGrid({ nodes, moveAction, optimistic, disabled, ...props }:
|
|
|
133
133
|
<CarouselContent className="md:max-h-[80vh]">
|
|
134
134
|
{images.map(({ id, url }) => (
|
|
135
135
|
<CarouselItem key={id} className="overflow-hidden rounded-xl">
|
|
136
|
-
<
|
|
136
|
+
<StorageImage
|
|
137
137
|
src={url}
|
|
138
138
|
alt="Image Preview"
|
|
139
139
|
width={1920}
|
|
140
140
|
height={1080}
|
|
141
141
|
className="h-full w-full rounded-xl object-contain"
|
|
142
|
-
loader={imageLoader}
|
|
143
142
|
/>
|
|
144
143
|
</CarouselItem>
|
|
145
144
|
))}
|
|
@@ -156,36 +155,40 @@ export function ImageGrid({ nodes, moveAction, optimistic, disabled, ...props }:
|
|
|
156
155
|
* Image Grid Item
|
|
157
156
|
*/
|
|
158
157
|
type ImageGridItemProps = {
|
|
159
|
-
|
|
158
|
+
asset: StorageAsset & { url: string };
|
|
160
159
|
index: number;
|
|
161
160
|
setCurrent: React.Dispatch<React.SetStateAction<number>>;
|
|
162
161
|
};
|
|
163
162
|
|
|
164
|
-
function ImageGridItem({
|
|
163
|
+
function ImageGridItem({ asset, index, setCurrent }: ImageGridItemProps) {
|
|
165
164
|
const uploadZone = useUploadZone();
|
|
166
165
|
|
|
167
|
-
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({
|
|
166
|
+
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({
|
|
167
|
+
id: asset.id,
|
|
168
|
+
});
|
|
168
169
|
|
|
169
170
|
return (
|
|
170
171
|
<Card
|
|
171
|
-
id={
|
|
172
|
+
id={asset.id}
|
|
172
173
|
ref={setNodeRef}
|
|
173
174
|
style={{
|
|
174
175
|
transform: CSS.Transform.toString(transform),
|
|
175
176
|
transition,
|
|
176
177
|
}}
|
|
177
|
-
className={cn(
|
|
178
|
+
className={cn(
|
|
179
|
+
"group relative aspect-square w-full",
|
|
180
|
+
asset.status === "pending" && "opacity-30",
|
|
181
|
+
)}
|
|
178
182
|
>
|
|
179
|
-
{
|
|
183
|
+
{asset.status === "ready" ? (
|
|
180
184
|
<>
|
|
181
185
|
<DialogTrigger onClick={() => setCurrent(index)}>
|
|
182
|
-
<
|
|
183
|
-
src={
|
|
186
|
+
<StorageImage
|
|
187
|
+
src={asset.url}
|
|
184
188
|
alt="Image Preview"
|
|
185
189
|
width={100}
|
|
186
190
|
height={100}
|
|
187
191
|
className="absolute inset-0 h-full w-full cursor-pointer rounded-lg bg-muted object-contain"
|
|
188
|
-
loader={imageLoader}
|
|
189
192
|
/>
|
|
190
193
|
</DialogTrigger>
|
|
191
194
|
|
|
@@ -204,7 +207,7 @@ function ImageGridItem({ node, index, setCurrent }: ImageGridItemProps) {
|
|
|
204
207
|
type="button"
|
|
205
208
|
variant="destructive"
|
|
206
209
|
size="icon"
|
|
207
|
-
onClick={() => uploadZone.onRemove([
|
|
210
|
+
onClick={() => uploadZone.onRemove([asset.id])}
|
|
208
211
|
className="absolute top-2 left-2 hidden p-1 group-hover:flex"
|
|
209
212
|
>
|
|
210
213
|
<Icons.trash className="size-4" />
|
|
@@ -1,31 +1,34 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import React from "react";
|
|
4
|
-
import type { UploadClient } from "../lib/
|
|
5
|
-
import type {
|
|
4
|
+
import type { UploadClient } from "../lib/upload.client";
|
|
5
|
+
import type { StorageAsset } from "../lib/validators";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Upload Zone Context Value
|
|
9
9
|
*/
|
|
10
10
|
export type UploadZoneContextValue = {
|
|
11
11
|
uploadClient: UploadClient;
|
|
12
|
-
onUpload: (file: File) => Promise<
|
|
12
|
+
onUpload: (file: File) => Promise<StorageAsset>;
|
|
13
13
|
onRemove: (ids: string[]) => Promise<void>;
|
|
14
14
|
optimistic?: {
|
|
15
|
-
add?: (
|
|
15
|
+
add?: (
|
|
16
|
+
newValue: Omit<
|
|
17
|
+
StorageAsset,
|
|
18
|
+
"id" | "key" | "bucket" | "provider" | "createdAt" | "updatedAt"
|
|
19
|
+
>,
|
|
20
|
+
) => Promise<void> | void;
|
|
16
21
|
remove?: (ids: string[]) => Promise<void> | void;
|
|
17
22
|
invalidate?: () => Promise<void> | void;
|
|
18
23
|
cancel?: () => Promise<void> | void;
|
|
19
24
|
};
|
|
20
25
|
disabled?: boolean;
|
|
21
|
-
// updateData: (newValue: FileNode[] | ((oldValue: FileNode[]) => FileNode[])) => Promise<void>;
|
|
22
|
-
// invalidateQuery: () => Promise<void> | void;
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
/**
|
|
26
29
|
* Upload Zone Context
|
|
27
30
|
*/
|
|
28
|
-
export const UploadZoneContext = React.createContext
|
|
31
|
+
export const UploadZoneContext = React.createContext<UploadZoneContextValue | null>(null);
|
|
29
32
|
|
|
30
33
|
/**
|
|
31
34
|
* Upload Zone Hook
|
|
@@ -33,7 +36,7 @@ export const UploadZoneContext = React.createContext({} as UploadZoneContextValu
|
|
|
33
36
|
export function useUploadZone() {
|
|
34
37
|
const context = React.useContext(UploadZoneContext);
|
|
35
38
|
if (!context) {
|
|
36
|
-
throw new Error("useUploadZone must be used within an
|
|
39
|
+
throw new Error("useUploadZone must be used within an UploadZoneContext provider");
|
|
37
40
|
}
|
|
38
41
|
return context;
|
|
39
42
|
}
|