@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
|
@@ -4,18 +4,22 @@ import ForgetPasswordEmail from "../../../components/emails/forget-password-emai
|
|
|
4
4
|
import { eq } from "drizzle-orm";
|
|
5
5
|
import { passkey } from "@better-auth/passkey";
|
|
6
6
|
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
7
|
+
import { createAuthMiddleware } from "better-auth/api";
|
|
7
8
|
import { betterAuth } from "better-auth/minimal";
|
|
8
|
-
import {
|
|
9
|
-
import { admin, createAuthMiddleware, emailOTP } from "better-auth/plugins";
|
|
9
|
+
import { admin, emailOTP } from "better-auth/plugins";
|
|
10
10
|
|
|
11
|
-
//#region src/modules/auth/handler/
|
|
11
|
+
//#region src/modules/auth/handler/service.server.ts
|
|
12
12
|
const authCookiePrefix = "tulip";
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Create the Better Auth server instance.
|
|
15
|
+
*/
|
|
16
|
+
function createAuth(props) {
|
|
14
17
|
return betterAuth({
|
|
15
18
|
advanced: {
|
|
16
19
|
cookiePrefix: authCookiePrefix,
|
|
17
20
|
database: { generateId: () => false }
|
|
18
21
|
},
|
|
22
|
+
baseURL: { allowedHosts: props.allowedHosts },
|
|
19
23
|
database: drizzleAdapter(props.db, {
|
|
20
24
|
provider: "pg",
|
|
21
25
|
usePlural: true
|
|
@@ -43,12 +47,12 @@ function initAuth(props) {
|
|
|
43
47
|
if ((await props.db.select().from(users)).length === 1) await props.db.update(users).set({ role: "developer" }).where(eq(users.id, session.user.id));
|
|
44
48
|
}) },
|
|
45
49
|
plugins: [
|
|
46
|
-
nextCookies(),
|
|
47
50
|
passkey(),
|
|
48
51
|
admin({
|
|
49
52
|
roles: props.roles,
|
|
50
53
|
ac: props.ac,
|
|
51
|
-
adminRoles: ["admin", "developer"]
|
|
54
|
+
adminRoles: ["admin", "developer"],
|
|
55
|
+
defaultRole: props.defaultRole ?? "user"
|
|
52
56
|
}),
|
|
53
57
|
emailOTP({ sendVerificationOTP: async ({ email, otp, type }) => {
|
|
54
58
|
/**
|
|
@@ -71,7 +75,14 @@ function initAuth(props) {
|
|
|
71
75
|
]
|
|
72
76
|
});
|
|
73
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Auth service namespace.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* const auth = Auth.init({ db, email, config, ac, roles, allowedHosts });
|
|
83
|
+
*/
|
|
84
|
+
const Auth = { init: createAuth };
|
|
74
85
|
|
|
75
86
|
//#endregion
|
|
76
|
-
export {
|
|
77
|
-
//# sourceMappingURL=
|
|
87
|
+
export { Auth, authCookiePrefix };
|
|
88
|
+
//# sourceMappingURL=service.server.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.server.mjs","names":[],"sources":["../../../../src/modules/auth/handler/service.server.ts"],"sourcesContent":["import { passkey } from \"@better-auth/passkey\";\nimport { drizzleAdapter } from \"better-auth/adapters/drizzle\";\nimport { createAuthMiddleware } from \"better-auth/api\";\nimport { betterAuth } from \"better-auth/minimal\";\nimport { admin, emailOTP } from \"better-auth/plugins\";\nimport { eq } from \"drizzle-orm\";\nimport ForgetPasswordEmail from \"@/components/emails/forget-password-email\";\nimport { url } from \"@/lib/utils/url\";\nimport type { TDatabaseSchema } from \"@/modules/config/entry\";\nimport type { TulipConfig } from \"@/modules/config/lib/config\";\nimport type { Database } from \"@/modules/database/lib/service.server\";\nimport type { Email } from \"@/modules/emails/lib/service.server\";\nimport { users } from \"../entry\";\nimport type { createAccessControl, Role } from \"../lib/permissions\";\n\nexport const authCookiePrefix = \"tulip\";\n\ntype InitAuthProps<TSchema extends TDatabaseSchema> = {\n db: Database<TSchema>;\n email: Email;\n config: TulipConfig;\n ac: ReturnType<typeof createAccessControl>;\n roles: {\n [key in string]?: Role;\n };\n allowedHosts: string[];\n defaultRole?: string;\n};\n\n/**\n * Create the Better Auth server instance.\n */\nfunction createAuth<TSchema extends TDatabaseSchema>(props: InitAuthProps<TSchema>) {\n return betterAuth({\n advanced: {\n cookiePrefix: authCookiePrefix,\n database: {\n generateId: () => false,\n },\n },\n baseURL: {\n allowedHosts: props.allowedHosts,\n },\n database: drizzleAdapter(props.db, {\n provider: \"pg\",\n usePlural: true,\n }),\n emailAndPassword: {\n enabled: true,\n },\n user: {\n changeEmail: {\n enabled: true,\n },\n additionalFields: {\n firstName: {\n type: \"string\",\n required: true,\n input: true,\n },\n lastName: {\n type: \"string\",\n required: true,\n input: true,\n },\n },\n },\n hooks: {\n after: createAuthMiddleware(async (ctx) => {\n if (!ctx.path.startsWith(\"/sign-up\")) return;\n\n const session = ctx.context.newSession;\n if (!session) return;\n\n const existingUsers = await props.db.select().from(users);\n\n if (existingUsers.length === 1) {\n await props.db\n .update(users)\n .set({ role: \"developer\" })\n .where(eq(users.id, session.user.id));\n }\n }),\n },\n plugins: [\n passkey(),\n admin({\n roles: props.roles,\n ac: props.ac,\n adminRoles: [\"admin\", \"developer\"],\n defaultRole: props.defaultRole ?? \"user\",\n }),\n emailOTP({\n sendVerificationOTP: async ({ email, otp, type }) => {\n /**\n * Send a forget password mail\n */\n if (type === \"forget-password\") {\n const searchParams = new URLSearchParams();\n searchParams.set(\"email\", email);\n searchParams.set(\"otp\", otp);\n\n const resetPasswordHref = url(`/auth/reset-password?${searchParams.toString()}`);\n\n const result = await props.email.emails.send({\n from: props.config.email.defaultFrom,\n to: email,\n subject: \"Wachtwoord herstellen\",\n react: ForgetPasswordEmail({ resetPasswordHref }),\n });\n if (result.error) throw new Error(result.error.message);\n }\n },\n }),\n ],\n });\n}\n\n/**\n * Better Auth instance type returned by `Auth.init()`.\n */\nexport type Auth = ReturnType<typeof createAuth>;\n\n/**\n * Auth service namespace.\n *\n * @example\n * const auth = Auth.init({ db, email, config, ac, roles, allowedHosts });\n */\nexport const Auth = {\n init: createAuth,\n};\n"],"mappings":";;;;;;;;;;;AAeA,MAAa,mBAAmB;;;;AAiBhC,SAAS,WAA4C,OAA+B;AAClF,QAAO,WAAW;EAChB,UAAU;GACR,cAAc;GACd,UAAU,EACR,kBAAkB,OACnB;GACF;EACD,SAAS,EACP,cAAc,MAAM,cACrB;EACD,UAAU,eAAe,MAAM,IAAI;GACjC,UAAU;GACV,WAAW;GACZ,CAAC;EACF,kBAAkB,EAChB,SAAS,MACV;EACD,MAAM;GACJ,aAAa,EACX,SAAS,MACV;GACD,kBAAkB;IAChB,WAAW;KACT,MAAM;KACN,UAAU;KACV,OAAO;KACR;IACD,UAAU;KACR,MAAM;KACN,UAAU;KACV,OAAO;KACR;IACF;GACF;EACD,OAAO,EACL,OAAO,qBAAqB,OAAO,QAAQ;AACzC,OAAI,CAAC,IAAI,KAAK,WAAW,WAAW,CAAE;GAEtC,MAAM,UAAU,IAAI,QAAQ;AAC5B,OAAI,CAAC,QAAS;AAId,QAFsB,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,MAAM,EAEvC,WAAW,EAC3B,OAAM,MAAM,GACT,OAAO,MAAM,CACb,IAAI,EAAE,MAAM,aAAa,CAAC,CAC1B,MAAM,GAAG,MAAM,IAAI,QAAQ,KAAK,GAAG,CAAC;IAEzC,EACH;EACD,SAAS;GACP,SAAS;GACT,MAAM;IACJ,OAAO,MAAM;IACb,IAAI,MAAM;IACV,YAAY,CAAC,SAAS,YAAY;IAClC,aAAa,MAAM,eAAe;IACnC,CAAC;GACF,SAAS,EACP,qBAAqB,OAAO,EAAE,OAAO,KAAK,WAAW;;;;AAInD,QAAI,SAAS,mBAAmB;KAC9B,MAAM,eAAe,IAAI,iBAAiB;AAC1C,kBAAa,IAAI,SAAS,MAAM;AAChC,kBAAa,IAAI,OAAO,IAAI;KAE5B,MAAM,oBAAoB,IAAI,wBAAwB,aAAa,UAAU,GAAG;KAEhF,MAAM,SAAS,MAAM,MAAM,MAAM,OAAO,KAAK;MAC3C,MAAM,MAAM,OAAO,MAAM;MACzB,IAAI;MACJ,SAAS;MACT,OAAO,oBAAoB,EAAE,mBAAmB,CAAC;MAClD,CAAC;AACF,SAAI,OAAO,MAAO,OAAM,IAAI,MAAM,OAAO,MAAM,QAAQ;;MAG5D,CAAC;GACH;EACF,CAAC;;;;;;;;AAcJ,MAAa,OAAO,EAClB,MAAM,YACP"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ClientAuth } from "../handler/create-client.client.mjs";
|
|
2
2
|
import "../../../auth/client.mjs";
|
|
3
3
|
import * as _tanstack_react_query0 from "@tanstack/react-query";
|
|
4
|
+
import * as better_auth0 from "better-auth";
|
|
4
5
|
|
|
5
6
|
//#region src/modules/auth/hooks/use-session.d.ts
|
|
6
7
|
declare function useSession(authClient: ClientAuth<never, never>): _tanstack_react_query0.UseSuspenseQueryResult<{
|
|
7
|
-
user: {
|
|
8
|
+
user: better_auth0.StripEmptyObjects<{
|
|
8
9
|
id: string;
|
|
9
10
|
createdAt: Date;
|
|
10
11
|
updatedAt: Date;
|
|
@@ -12,14 +13,17 @@ declare function useSession(authClient: ClientAuth<never, never>): _tanstack_rea
|
|
|
12
13
|
emailVerified: boolean;
|
|
13
14
|
name: string;
|
|
14
15
|
image?: string | null | undefined;
|
|
16
|
+
} & {
|
|
15
17
|
firstName: string;
|
|
16
18
|
lastName: string;
|
|
19
|
+
} & {} & {
|
|
17
20
|
banned: boolean | null | undefined;
|
|
21
|
+
} & {
|
|
18
22
|
role?: string | null | undefined;
|
|
19
23
|
banReason?: string | null | undefined;
|
|
20
24
|
banExpires?: Date | null | undefined;
|
|
21
|
-
}
|
|
22
|
-
session: {
|
|
25
|
+
}>;
|
|
26
|
+
session: better_auth0.StripEmptyObjects<{
|
|
23
27
|
id: string;
|
|
24
28
|
createdAt: Date;
|
|
25
29
|
updatedAt: Date;
|
|
@@ -28,8 +32,9 @@ declare function useSession(authClient: ClientAuth<never, never>): _tanstack_rea
|
|
|
28
32
|
token: string;
|
|
29
33
|
ipAddress?: string | null | undefined;
|
|
30
34
|
userAgent?: string | null | undefined;
|
|
35
|
+
} & {} & {
|
|
31
36
|
impersonatedBy?: string | null | undefined;
|
|
32
|
-
}
|
|
37
|
+
} & {} & {}>;
|
|
33
38
|
} | null, Error>;
|
|
34
39
|
//#endregion
|
|
35
40
|
export { useSession };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-session.d.mts","names":[],"sources":["../../../../src/modules/auth/hooks/use-session.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-session.d.mts","names":[],"sources":["../../../../src/modules/auth/hooks/use-session.ts"],"mappings":";;;;;;iBAKgB,UAAA,CAAW,UAAA,EAAY,UAAA,wCAAwB,sBAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CreateUserSchema, UpdateUserSchema } from "./validators.mjs";
|
|
2
|
-
import { TDatabaseSchema } from "../../config/db/types.mjs";
|
|
3
2
|
import { TulipContext } from "../../config/lib/context.mjs";
|
|
4
3
|
import "../../../config.mjs";
|
|
5
4
|
import "server-cli-only";
|
|
6
5
|
import * as better_auth_plugins0 from "better-auth/plugins";
|
|
6
|
+
import { TDatabaseSchema } from "@/modules/config/db/types";
|
|
7
7
|
|
|
8
8
|
//#region src/modules/auth/lib/helpers.server.d.ts
|
|
9
9
|
/**
|
|
@@ -7,7 +7,7 @@ type Permission = Record<string, string[]>;
|
|
|
7
7
|
* Create statements
|
|
8
8
|
*/
|
|
9
9
|
declare const createStatements: <TStatements extends Parameters<typeof createAccessControl>[0]>(statements: TStatements) => TStatements & {
|
|
10
|
-
readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "delete", "set-password", "get", "update"];
|
|
10
|
+
readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "impersonate-admins", "delete", "set-password", "get", "update"];
|
|
11
11
|
readonly session: readonly ["list", "revoke", "delete"];
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { users } from "../db/schema.mjs";
|
|
2
|
-
import { userSchema } from "better-auth/db";
|
|
3
2
|
import { createInsertSchema } from "drizzle-zod";
|
|
4
3
|
import { z as z$1 } from "zod";
|
|
4
|
+
import { userSchema } from "better-auth/db";
|
|
5
5
|
|
|
6
6
|
//#region src/modules/auth/lib/validators.ts
|
|
7
7
|
/**
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { TDatabaseSchema } from "
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import "../../../config.mjs";
|
|
1
|
+
import { TDatabaseSchema } from "../../database/lib/types.mjs";
|
|
2
|
+
import { Database } from "../../database/lib/service.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
|
|
|
8
7
|
//#region src/modules/config/lib/context.d.ts
|
|
9
8
|
type TulipContext<TSchema extends TDatabaseSchema> = {
|
|
10
|
-
db:
|
|
9
|
+
db: Database<TSchema>;
|
|
11
10
|
schema: TSchema;
|
|
12
|
-
auth:
|
|
13
|
-
email:
|
|
14
|
-
storage:
|
|
11
|
+
auth: Auth;
|
|
12
|
+
email: Email;
|
|
13
|
+
storage: Storage<TSchema>;
|
|
15
14
|
};
|
|
16
15
|
declare function createContext<TSchema extends TDatabaseSchema>(props: TulipContext<TSchema>): TulipContext<TSchema>;
|
|
17
16
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.mts","names":[],"sources":["../../../../src/modules/config/lib/context.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.mts","names":[],"sources":["../../../../src/modules/config/lib/context.ts"],"mappings":";;;;;;;KAMY,YAAA,iBAA6B,eAAA;EACvC,EAAA,EAAI,QAAA,CAAS,OAAA;EACb,MAAA,EAAQ,OAAA;EACR,IAAA,EAAM,IAAA;EACN,KAAA,EAAO,KAAA;EACP,OAAA,EAAS,OAAA,CAAQ,OAAA;AAAA;AAAA,iBAGH,aAAA,iBAA8B,eAAA,CAAA,CAAiB,KAAA,EAAO,YAAA,CAAa,OAAA,IAAQ,YAAA,CAAA,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.mjs","names":[],"sources":["../../../../src/modules/config/lib/context.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"context.mjs","names":[],"sources":["../../../../src/modules/config/lib/context.ts"],"sourcesContent":["import type { Auth } from \"@/modules/auth/handler/service.server\";\nimport type { Database } from \"@/modules/database/lib/service.server\";\nimport type { TDatabaseSchema } from \"@/modules/database/lib/types\";\nimport type { Email } from \"@/modules/emails/lib/service.server\";\nimport type { Storage } from \"@/modules/storage/lib/service.server\";\n\nexport type TulipContext<TSchema extends TDatabaseSchema> = {\n db: Database<TSchema>;\n schema: TSchema;\n auth: Auth;\n email: Email;\n storage: Storage<TSchema>;\n};\n\nexport function createContext<TSchema extends TDatabaseSchema>(props: TulipContext<TSchema>) {\n return props;\n}\n"],"mappings":";AAcA,SAAgB,cAA+C,OAA8B;AAC3F,QAAO"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TableQuerySchema } from "../validators.mjs";
|
|
2
|
-
import { SQL } from "drizzle-orm";
|
|
3
2
|
import { PgColumn } from "drizzle-orm/pg-core";
|
|
3
|
+
import { SQL } from "drizzle-orm";
|
|
4
4
|
|
|
5
5
|
//#region src/modules/data-tables/lib/converters/search.d.ts
|
|
6
6
|
type ConvertSearchToQueryParamsFields = PgColumn[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TableQuerySchema } from "../validators.mjs";
|
|
2
|
-
import { AnyColumn, SQL, ValueOrArray } from "drizzle-orm";
|
|
3
2
|
import { PgTable } from "drizzle-orm/pg-core";
|
|
3
|
+
import { AnyColumn, SQL, ValueOrArray } from "drizzle-orm";
|
|
4
4
|
|
|
5
5
|
//#region src/modules/data-tables/lib/converters/sorting.d.ts
|
|
6
6
|
type ConvertSortToQueryParamsFallback = ValueOrArray<AnyColumn | SQL>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { TDatabaseSchema } from "../../config/db/types.mjs";
|
|
2
1
|
import { TulipContext } from "../../config/lib/context.mjs";
|
|
3
2
|
import "../../../config.mjs";
|
|
4
3
|
import { TableQuerySchema } from "../lib/validators.mjs";
|
|
5
4
|
import { ConvertSearchToQueryParamsFields } from "../lib/converters/search.mjs";
|
|
6
5
|
import { ConvertSortToQueryParamsFallback } from "../lib/converters/sorting.mjs";
|
|
7
|
-
import { DBQueryConfig, SQL } from "drizzle-orm";
|
|
8
6
|
import { PgTable } from "drizzle-orm/pg-core";
|
|
9
|
-
import "server-only";
|
|
7
|
+
import "server-cli-only";
|
|
8
|
+
import { DBQueryConfig, SQL } from "drizzle-orm";
|
|
9
|
+
import { TDatabaseSchema } from "@/modules/config/db/types";
|
|
10
10
|
|
|
11
11
|
//#region src/modules/data-tables/server/get-data.server.d.ts
|
|
12
12
|
type GetTableDataOptions<TTable extends PgTable> = DBQueryConfig<"many"> & {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { convertCursorToQueryParams } from "../lib/converters/cursor.mjs";
|
|
2
2
|
import { convertSearchToQueryParams } from "../lib/converters/search.mjs";
|
|
3
3
|
import { convertOrderByToQueryParams } from "../lib/converters/sorting.mjs";
|
|
4
|
+
import "server-cli-only";
|
|
4
5
|
import { and, getTableName, isTable } from "drizzle-orm";
|
|
5
|
-
import "server-only";
|
|
6
6
|
|
|
7
7
|
//#region src/modules/data-tables/server/get-data.server.ts
|
|
8
8
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-data.server.mjs","names":[],"sources":["../../../../src/modules/data-tables/server/get-data.server.ts"],"sourcesContent":["import \"server-only\";\n\nimport { and, type DBQueryConfig, getTableName, isTable, type SQL } from \"drizzle-orm\";\nimport type { PgTable } from \"drizzle-orm/pg-core\";\nimport type { RelationalQueryBuilder } from \"drizzle-orm/pg-core/query-builders/query\";\nimport type { TDatabaseSchema } from \"@/modules/config/db/types\";\nimport type { TulipContext } from \"@/modules/config/entry\";\nimport { convertCursorToQueryParams } from \"../lib/converters/cursor\";\nimport {\n type ConvertSearchToQueryParamsFields,\n convertSearchToQueryParams,\n} from \"../lib/converters/search\";\nimport {\n type ConvertSortToQueryParamsFallback,\n convertOrderByToQueryParams,\n} from \"../lib/converters/sorting\";\nimport type { TableQuerySchema } from \"../lib/validators\";\n\nexport type GetTableDataOptions<TTable extends PgTable> = DBQueryConfig<\"many\"> & {\n table: TTable;\n where?: SQL;\n columns?: keyof TTable[\"_\"][\"columns\"];\n defaultOrder: ConvertSortToQueryParamsFallback;\n searchFields: ConvertSearchToQueryParamsFields;\n};\n\n/**\n * Get data from the database for the data table\n */\nexport async function getTableData<TTable extends PgTable, TSchema extends TDatabaseSchema>(\n { db, schema }: TulipContext<TSchema>,\n query: TableQuerySchema,\n options: GetTableDataOptions<TTable>,\n): Promise<{ data: TTable[\"$inferSelect\"][]; total: number }> {\n const { table, where, defaultOrder: defaultSort, searchFields } = options;\n\n if (!isTable(table)) throw new Error(`Provided table is not a table: ${table}`);\n\n // Get the table name kay from the schema\n const tableName = Object.entries({ ...schema } as { [key: string]: PgTable })\n .filter(([, t]) => isTable(t))\n .find(([, t]) => getTableName(t) === getTableName(table))?.[0];\n\n if (!tableName) throw new Error(`Table name not found for table: ${tableName}`);\n\n // Convert the query params to DB query\n const { limit, offset } = convertCursorToQueryParams(query);\n const orderBy = convertOrderByToQueryParams(query, table, defaultSort);\n const search = convertSearchToQueryParams(query, searchFields);\n\n /**\n * Make a transaction to get the data\n */\n const { data, total } = await db.transaction(async (tx) => {\n // Check if the table exists in the query builder\n if (!(tableName in tx.query)) throw new Error(`Table not found in query builder: ${tableName}`);\n const queryBuilderKey = tableName as keyof typeof tx.query;\n\n // Get the query builder\n // biome-ignore lint/suspicious/noExplicitAny: This is needed to satisfy the system\n const queryBuilder = tx.query[queryBuilderKey] as RelationalQueryBuilder<any, any>;\n if (!queryBuilder) throw new Error(`Query builder not found for table: ${tableName}`);\n\n // Get the data\n const data = await queryBuilder.findMany({\n where: and(where, search),\n orderBy,\n limit,\n offset,\n with: options.with,\n columns: options.columns,\n extras: options.extras,\n });\n\n // Get the total\n // Get the total\n const total = await tx.$count(table, and(where, search));\n\n // Return the data\n return { data, total: total ?? 0 };\n });\n\n return { data, total };\n}\n"],"mappings":";;;;;;;;;;AA6BA,eAAsB,aACpB,EAAE,IAAI,UACN,OACA,SAC4D;CAC5D,MAAM,EAAE,OAAO,OAAO,cAAc,aAAa,iBAAiB;AAElE,KAAI,CAAC,QAAQ,MAAM,CAAE,OAAM,IAAI,MAAM,kCAAkC,QAAQ;CAG/E,MAAM,YAAY,OAAO,QAAQ,EAAE,GAAG,QAAQ,CAA+B,CAC1E,QAAQ,GAAG,OAAO,QAAQ,EAAE,CAAC,CAC7B,MAAM,GAAG,OAAO,aAAa,EAAE,KAAK,aAAa,MAAM,CAAC,GAAG;AAE9D,KAAI,CAAC,UAAW,OAAM,IAAI,MAAM,mCAAmC,YAAY;CAG/E,MAAM,EAAE,OAAO,WAAW,2BAA2B,MAAM;CAC3D,MAAM,UAAU,4BAA4B,OAAO,OAAO,YAAY;CACtE,MAAM,SAAS,2BAA2B,OAAO,aAAa;;;;CAK9D,MAAM,EAAE,MAAM,UAAU,MAAM,GAAG,YAAY,OAAO,OAAO;AAEzD,MAAI,EAAE,aAAa,GAAG,OAAQ,OAAM,IAAI,MAAM,qCAAqC,YAAY;EAC/F,MAAM,kBAAkB;EAIxB,MAAM,eAAe,GAAG,MAAM;AAC9B,MAAI,CAAC,aAAc,OAAM,IAAI,MAAM,sCAAsC,YAAY;AAkBrF,SAAO;GAAE,MAfI,MAAM,aAAa,SAAS;IACvC,OAAO,IAAI,OAAO,OAAO;IACzB;IACA;IACA;IACA,MAAM,QAAQ;IACd,SAAS,QAAQ;IACjB,QAAQ,QAAQ;IACjB,CAAC;GAOa,OAHD,MAAM,GAAG,OAAO,OAAO,IAAI,OAAO,OAAO,CAAC,IAGzB;GAAG;GAClC;AAEF,QAAO;EAAE;EAAM;EAAO"}
|
|
1
|
+
{"version":3,"file":"get-data.server.mjs","names":[],"sources":["../../../../src/modules/data-tables/server/get-data.server.ts"],"sourcesContent":["import \"server-cli-only\";\n\nimport { and, type DBQueryConfig, getTableName, isTable, type SQL } from \"drizzle-orm\";\nimport type { PgTable } from \"drizzle-orm/pg-core\";\nimport type { RelationalQueryBuilder } from \"drizzle-orm/pg-core/query-builders/query\";\nimport type { TDatabaseSchema } from \"@/modules/config/db/types\";\nimport type { TulipContext } from \"@/modules/config/entry\";\nimport { convertCursorToQueryParams } from \"../lib/converters/cursor\";\nimport {\n type ConvertSearchToQueryParamsFields,\n convertSearchToQueryParams,\n} from \"../lib/converters/search\";\nimport {\n type ConvertSortToQueryParamsFallback,\n convertOrderByToQueryParams,\n} from \"../lib/converters/sorting\";\nimport type { TableQuerySchema } from \"../lib/validators\";\n\nexport type GetTableDataOptions<TTable extends PgTable> = DBQueryConfig<\"many\"> & {\n table: TTable;\n where?: SQL;\n columns?: keyof TTable[\"_\"][\"columns\"];\n defaultOrder: ConvertSortToQueryParamsFallback;\n searchFields: ConvertSearchToQueryParamsFields;\n};\n\n/**\n * Get data from the database for the data table\n */\nexport async function getTableData<TTable extends PgTable, TSchema extends TDatabaseSchema>(\n { db, schema }: TulipContext<TSchema>,\n query: TableQuerySchema,\n options: GetTableDataOptions<TTable>,\n): Promise<{ data: TTable[\"$inferSelect\"][]; total: number }> {\n const { table, where, defaultOrder: defaultSort, searchFields } = options;\n\n if (!isTable(table)) throw new Error(`Provided table is not a table: ${table}`);\n\n // Get the table name kay from the schema\n const tableName = Object.entries({ ...schema } as { [key: string]: PgTable })\n .filter(([, t]) => isTable(t))\n .find(([, t]) => getTableName(t) === getTableName(table))?.[0];\n\n if (!tableName) throw new Error(`Table name not found for table: ${tableName}`);\n\n // Convert the query params to DB query\n const { limit, offset } = convertCursorToQueryParams(query);\n const orderBy = convertOrderByToQueryParams(query, table, defaultSort);\n const search = convertSearchToQueryParams(query, searchFields);\n\n /**\n * Make a transaction to get the data\n */\n const { data, total } = await db.transaction(async (tx) => {\n // Check if the table exists in the query builder\n if (!(tableName in tx.query)) throw new Error(`Table not found in query builder: ${tableName}`);\n const queryBuilderKey = tableName as keyof typeof tx.query;\n\n // Get the query builder\n // biome-ignore lint/suspicious/noExplicitAny: This is needed to satisfy the system\n const queryBuilder = tx.query[queryBuilderKey] as RelationalQueryBuilder<any, any>;\n if (!queryBuilder) throw new Error(`Query builder not found for table: ${tableName}`);\n\n // Get the data\n const data = await queryBuilder.findMany({\n where: and(where, search),\n orderBy,\n limit,\n offset,\n with: options.with,\n columns: options.columns,\n extras: options.extras,\n });\n\n // Get the total\n // Get the total\n const total = await tx.$count(table, and(where, search));\n\n // Return the data\n return { data, total: total ?? 0 };\n });\n\n return { data, total };\n}\n"],"mappings":";;;;;;;;;;AA6BA,eAAsB,aACpB,EAAE,IAAI,UACN,OACA,SAC4D;CAC5D,MAAM,EAAE,OAAO,OAAO,cAAc,aAAa,iBAAiB;AAElE,KAAI,CAAC,QAAQ,MAAM,CAAE,OAAM,IAAI,MAAM,kCAAkC,QAAQ;CAG/E,MAAM,YAAY,OAAO,QAAQ,EAAE,GAAG,QAAQ,CAA+B,CAC1E,QAAQ,GAAG,OAAO,QAAQ,EAAE,CAAC,CAC7B,MAAM,GAAG,OAAO,aAAa,EAAE,KAAK,aAAa,MAAM,CAAC,GAAG;AAE9D,KAAI,CAAC,UAAW,OAAM,IAAI,MAAM,mCAAmC,YAAY;CAG/E,MAAM,EAAE,OAAO,WAAW,2BAA2B,MAAM;CAC3D,MAAM,UAAU,4BAA4B,OAAO,OAAO,YAAY;CACtE,MAAM,SAAS,2BAA2B,OAAO,aAAa;;;;CAK9D,MAAM,EAAE,MAAM,UAAU,MAAM,GAAG,YAAY,OAAO,OAAO;AAEzD,MAAI,EAAE,aAAa,GAAG,OAAQ,OAAM,IAAI,MAAM,qCAAqC,YAAY;EAC/F,MAAM,kBAAkB;EAIxB,MAAM,eAAe,GAAG,MAAM;AAC9B,MAAI,CAAC,aAAc,OAAM,IAAI,MAAM,sCAAsC,YAAY;AAkBrF,SAAO;GAAE,MAfI,MAAM,aAAa,SAAS;IACvC,OAAO,IAAI,OAAO,OAAO;IACzB;IACA;IACA;IACA,MAAM,QAAQ;IACd,SAAS,QAAQ;IACjB,QAAQ,QAAQ;IACjB,CAAC;GAOa,OAHD,MAAM,GAAG,OAAO,OAAO,IAAI,OAAO,OAAO,CAAC,IAGzB;GAAG;GAClC;AAEF,QAAO;EAAE;EAAM;EAAO"}
|
|
@@ -8,7 +8,7 @@ interface UseInfiniteStrategyInput {
|
|
|
8
8
|
isFetching: boolean;
|
|
9
9
|
isFetchingNextPage: boolean;
|
|
10
10
|
}
|
|
11
|
-
type InfiniteStrategyMeta = Pick<UseInfiniteStrategyInput, "isFetching" | "isFetchingNextPage">;
|
|
11
|
+
type InfiniteStrategyMeta = Pick<UseInfiniteStrategyInput, "isFetching" | "isFetchingNextPage" | "total" | "cursor" | "fetchNextPage">;
|
|
12
12
|
declare function useInfiniteStrategy({
|
|
13
13
|
cursor,
|
|
14
14
|
total,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strategy.mjs","names":[],"sources":["../../../../../src/modules/data-tables/strategies/infinite/strategy.ts"],"sourcesContent":["\"use client\";\n\nimport type { PaginationState, Updater } from \"@tanstack/react-table\";\nimport { useQueryStates } from \"nuqs\";\nimport { tableSearchParams } from \"../../entry\";\nimport type { TableStrategy } from \"../../lib/types\";\nimport { handleSortingChange } from \"../helpers/sorting\";\n\nexport interface UseInfiniteStrategyInput {\n cursor: number | undefined;\n total: number | undefined;\n fetchNextPage: () => void;\n isFetching: boolean;\n isFetchingNextPage: boolean;\n}\n\nexport type InfiniteStrategyMeta = Pick<\n UseInfiniteStrategyInput,\n \"isFetching\" | \"isFetchingNextPage\"\n>;\n\nexport function useInfiniteStrategy({\n cursor,\n total,\n fetchNextPage,\n isFetching,\n isFetchingNextPage,\n}: UseInfiniteStrategyInput): TableStrategy {\n const [query, setQuery] = useQueryStates(tableSearchParams);\n\n // Convert pagination to table state\n const paginationState = {\n pageIndex: cursor ?? 0,\n pageSize: query.limit,\n };\n\n // Convert sorting to table state\n const sortingState = query.sort ? [{ id: query.sort, desc: query.order === \"desc\" }] : [];\n\n const resetCursor = () => null;\n\n return {\n name: \"infinite\",\n rowCount: total,\n paginationState,\n manualPagination: true,\n onPaginationChange: (updater: Updater<PaginationState>) => {\n // Get the new state from the updater function\n const newState = typeof updater === \"function\" ? updater(paginationState) : updater;\n\n // Update the search params\n setQuery({ limit: newState.pageSize });\n\n // Fetch the next page\n fetchNextPage();\n\n // Return the new state\n return newState;\n },\n resetCursor,\n tableSearchParams: tableSearchParams,\n sortingState,\n manualSorting: true,\n onSortingChange: handleSortingChange({ sortingState, setQuery, resetCursor }),\n meta: {\n isFetching,\n isFetchingNextPage,\n } satisfies InfiniteStrategyMeta,\n };\n}\n"],"mappings":";;;;;;;AAqBA,SAAgB,oBAAoB,EAClC,QACA,OACA,eACA,YACA,sBAC0C;CAC1C,MAAM,CAAC,OAAO,YAAY,eAAe,kBAAkB;CAG3D,MAAM,kBAAkB;EACtB,WAAW,UAAU;EACrB,UAAU,MAAM;EACjB;CAGD,MAAM,eAAe,MAAM,OAAO,CAAC;EAAE,IAAI,MAAM;EAAM,MAAM,MAAM,UAAU;EAAQ,CAAC,GAAG,EAAE;CAEzF,MAAM,oBAAoB;AAE1B,QAAO;EACL,MAAM;EACN,UAAU;EACV;EACA,kBAAkB;EAClB,qBAAqB,YAAsC;GAEzD,MAAM,WAAW,OAAO,YAAY,aAAa,QAAQ,gBAAgB,GAAG;AAG5E,YAAS,EAAE,OAAO,SAAS,UAAU,CAAC;AAGtC,kBAAe;AAGf,UAAO;;EAET;EACmB;EACnB;EACA,eAAe;EACf,iBAAiB,oBAAoB;GAAE;GAAc;GAAU;GAAa,CAAC;EAC7E,MAAM;GACJ;GACA;GACD;EACF"}
|
|
1
|
+
{"version":3,"file":"strategy.mjs","names":[],"sources":["../../../../../src/modules/data-tables/strategies/infinite/strategy.ts"],"sourcesContent":["\"use client\";\n\nimport type { PaginationState, Updater } from \"@tanstack/react-table\";\nimport { useQueryStates } from \"nuqs\";\nimport { tableSearchParams } from \"../../entry\";\nimport type { TableStrategy } from \"../../lib/types\";\nimport { handleSortingChange } from \"../helpers/sorting\";\n\nexport interface UseInfiniteStrategyInput {\n cursor: number | undefined;\n total: number | undefined;\n fetchNextPage: () => void;\n isFetching: boolean;\n isFetchingNextPage: boolean;\n}\n\nexport type InfiniteStrategyMeta = Pick<\n UseInfiniteStrategyInput,\n \"isFetching\" | \"isFetchingNextPage\" | \"total\" | \"cursor\" | \"fetchNextPage\"\n>;\n\nexport function useInfiniteStrategy({\n cursor,\n total,\n fetchNextPage,\n isFetching,\n isFetchingNextPage,\n}: UseInfiniteStrategyInput): TableStrategy {\n const [query, setQuery] = useQueryStates(tableSearchParams);\n\n // Convert pagination to table state\n const paginationState = {\n pageIndex: cursor ?? 0,\n pageSize: query.limit,\n };\n\n // Convert sorting to table state\n const sortingState = query.sort ? [{ id: query.sort, desc: query.order === \"desc\" }] : [];\n\n const resetCursor = () => null;\n\n return {\n name: \"infinite\",\n rowCount: total,\n paginationState,\n manualPagination: true,\n onPaginationChange: (updater: Updater<PaginationState>) => {\n // Get the new state from the updater function\n const newState = typeof updater === \"function\" ? updater(paginationState) : updater;\n\n // Update the search params\n setQuery({ limit: newState.pageSize });\n\n // Fetch the next page\n fetchNextPage();\n\n // Return the new state\n return newState;\n },\n resetCursor,\n tableSearchParams: tableSearchParams,\n sortingState,\n manualSorting: true,\n onSortingChange: handleSortingChange({ sortingState, setQuery, resetCursor }),\n meta: {\n total,\n cursor,\n fetchNextPage,\n isFetching,\n isFetchingNextPage,\n } satisfies InfiniteStrategyMeta,\n };\n}\n"],"mappings":";;;;;;;AAqBA,SAAgB,oBAAoB,EAClC,QACA,OACA,eACA,YACA,sBAC0C;CAC1C,MAAM,CAAC,OAAO,YAAY,eAAe,kBAAkB;CAG3D,MAAM,kBAAkB;EACtB,WAAW,UAAU;EACrB,UAAU,MAAM;EACjB;CAGD,MAAM,eAAe,MAAM,OAAO,CAAC;EAAE,IAAI,MAAM;EAAM,MAAM,MAAM,UAAU;EAAQ,CAAC,GAAG,EAAE;CAEzF,MAAM,oBAAoB;AAE1B,QAAO;EACL,MAAM;EACN,UAAU;EACV;EACA,kBAAkB;EAClB,qBAAqB,YAAsC;GAEzD,MAAM,WAAW,OAAO,YAAY,aAAa,QAAQ,gBAAgB,GAAG;AAG5E,YAAS,EAAE,OAAO,SAAS,UAAU,CAAC;AAGtC,kBAAe;AAGf,UAAO;;EAET;EACmB;EACnB;EACA,eAAe;EACf,iBAAiB,oBAAoB;GAAE;GAAc;GAAU;GAAa,CAAC;EAC7E,MAAM;GACJ;GACA;GACA;GACA;GACA;GACD;EACF"}
|
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
import { ContextCommandMenu, ContextCommandMenuContent, ContextCommandMenuTrigger } from "../../../../commands/menus/context-menu.client.mjs";
|
|
2
1
|
import { TableRow } from "../../../components/table.mjs";
|
|
3
|
-
import { jsx
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
3
|
|
|
5
4
|
//#region src/modules/data-tables/tables/data-table/components/row.tsx
|
|
6
5
|
function DataTableRow({ row, table, className, ...props }) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
...props,
|
|
12
|
-
"data-state": row.getIsSelected() && "selected"
|
|
13
|
-
})
|
|
14
|
-
}), /* @__PURE__ */ jsx(ContextCommandMenuContent, {
|
|
15
|
-
data: row.original,
|
|
16
|
-
commands: meta.commands || [],
|
|
17
|
-
meta,
|
|
18
|
-
className: "w-[300px]"
|
|
19
|
-
})] });
|
|
6
|
+
return /* @__PURE__ */ jsx(TableRow, {
|
|
7
|
+
...props,
|
|
8
|
+
"data-state": row.getIsSelected() && "selected"
|
|
9
|
+
});
|
|
20
10
|
}
|
|
21
11
|
|
|
22
12
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row.mjs","names":[],"sources":["../../../../../../src/modules/data-tables/tables/data-table/components/row.tsx"],"sourcesContent":["import type { Row, Table } from \"@tanstack/react-table\";\nimport type * as React from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"row.mjs","names":[],"sources":["../../../../../../src/modules/data-tables/tables/data-table/components/row.tsx"],"sourcesContent":["import type { Row, Table } from \"@tanstack/react-table\";\nimport type * as React from \"react\";\nimport { TableRow } from \"@/modules/data-tables/components/table\";\n\nexport type DataTableRowProps<TData extends { id: string }> = React.ComponentProps<\n typeof TableRow\n> & {\n row: Row<TData>;\n table: Table<TData>;\n};\n\nexport function DataTableRow<TData extends { id: string }>({\n row,\n table,\n className,\n ...props\n}: DataTableRowProps<TData>) {\n return <TableRow {...props} data-state={row.getIsSelected() && \"selected\"} />;\n}\n\n// <ContextCommandMenu>\n// <ContextCommandMenuTrigger asChild>\n// </ContextCommandMenuTrigger>\n\n// <ContextCommandMenuContent\n// data={row.original}\n// commands={meta.commands || []}\n// meta={meta as never}\n// className=\"w-[300px]\"\n// />\n// </ContextCommandMenu>\n"],"mappings":";;;;AAWA,SAAgB,aAA2C,EACzD,KACA,OACA,WACA,GAAG,SACwB;AAC3B,QAAO,oBAAC;EAAS,GAAI;EAAO,cAAY,IAAI,eAAe,IAAI;GAAc"}
|
|
@@ -17,7 +17,7 @@ function InlineTableBody({ table }) {
|
|
|
17
17
|
const { rows } = table.getRowModel();
|
|
18
18
|
const { setNodeRef } = useDroppable({ id: "inline-data-table" });
|
|
19
19
|
const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }));
|
|
20
|
-
useInlineDataTableHotkeys();
|
|
20
|
+
useInlineDataTableHotkeys(context.hotkeys);
|
|
21
21
|
if (rows?.length === 0) return /* @__PURE__ */ jsx(TableBody, { children: /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, {
|
|
22
22
|
colSpan: table.getAllFlatColumns().length + 1 + (context.isDraggable ? 1 : 0) + (table.options.enableRowSelection ? 1 : 0),
|
|
23
23
|
className: "h-24 text-center",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body.mjs","names":[],"sources":["../../../../../../src/modules/data-tables/tables/inline-table/components/body.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 { restrictToParentElement, restrictToVerticalAxis } from \"@dnd-kit/modifiers\";\nimport {\n rectSortingStrategy,\n SortableContext,\n sortableKeyboardCoordinates,\n} from \"@dnd-kit/sortable\";\nimport { flexRender, type Table } from \"@tanstack/react-table\";\nimport { Fragment } from \"react/jsx-runtime\";\nimport { Allowed } from \"@/modules/auth/components/allowed.client\";\nimport { TableBody, TableCell, TableRow } from \"@/modules/data-tables/components/table\";\nimport type { TableColumnDef } from \"../../../lib/types\";\nimport { useInlineTableContext } from \"../hooks/context.client\";\nimport { useInlineDataTableHotkeys } from \"../hooks/use-hotkeys.client\";\nimport { InlineTableRow } from \"./row.client\";\n\nexport function InlineTableBody<TData extends { id: string }>({ table }: { table: Table<TData> }) {\n const context = useInlineTableContext();\n\n const { rows } = table.getRowModel();\n\n const { setNodeRef } = useDroppable({ id: \"inline-data-table\" });\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, {\n coordinateGetter: sortableKeyboardCoordinates,\n }),\n );\n\n useInlineDataTableHotkeys();\n\n if (rows?.length === 0) {\n return (\n <TableBody>\n <TableRow>\n <TableCell\n colSpan={\n table.getAllFlatColumns().length +\n 1 +\n (context.isDraggable ? 1 : 0) +\n (table.options.enableRowSelection ? 1 : 0)\n }\n className=\"h-24 text-center\"\n >\n Geen resultaten gevonden\n </TableCell>\n </TableRow>\n </TableBody>\n );\n }\n\n function handleDragEnd(event: DragEndEvent) {\n if (!context.isDraggable) return;\n const { active, over } = event;\n\n if (active.id !== over?.id) {\n const fromIndex = rows.findIndex((item) => item.id === active.id);\n const toIndex = rows.findIndex((item) => item.id === over?.id);\n\n context.moveRow({ fromIndex, toIndex });\n }\n }\n\n return (\n <DndContext\n sensors={sensors}\n onDragEnd={handleDragEnd}\n collisionDetection={closestCenter}\n modifiers={[restrictToVerticalAxis, restrictToParentElement]}\n >\n <SortableContext items={rows.map((row) => row.id)} strategy={rectSortingStrategy}>\n <TableBody ref={setNodeRef}>\n {rows.map((row) => (\n <InlineTableRow\n key={row.id}\n row={row}\n data-row-id={row.id}\n table={table}\n className=\"relative\"\n >\n {row.getVisibleCells().map((cell) => {\n const columnDef = cell.column.columnDef as TableColumnDef<TData>;\n\n const children = flexRender(cell.column.columnDef.cell, cell.getContext());\n\n if (!columnDef.permissions) {\n return <Fragment key={cell.id}>{children}</Fragment>;\n }\n\n return (\n <Allowed key={cell.id} permission={columnDef.permissions}>\n {children}\n </Allowed>\n );\n })}\n </InlineTableRow>\n ))}\n </TableBody>\n </SortableContext>\n </DndContext>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA2BA,SAAgB,gBAA8C,EAAE,SAAkC;CAChG,MAAM,UAAU,uBAAuB;CAEvC,MAAM,EAAE,SAAS,MAAM,aAAa;CAEpC,MAAM,EAAE,eAAe,aAAa,EAAE,IAAI,qBAAqB,CAAC;CAChE,MAAM,UAAU,WACd,UAAU,cAAc,EACxB,UAAU,gBAAgB,EACxB,kBAAkB,6BACnB,CAAC,CACH;AAED,
|
|
1
|
+
{"version":3,"file":"body.mjs","names":[],"sources":["../../../../../../src/modules/data-tables/tables/inline-table/components/body.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 { restrictToParentElement, restrictToVerticalAxis } from \"@dnd-kit/modifiers\";\nimport {\n rectSortingStrategy,\n SortableContext,\n sortableKeyboardCoordinates,\n} from \"@dnd-kit/sortable\";\nimport { flexRender, type Table } from \"@tanstack/react-table\";\nimport { Fragment } from \"react/jsx-runtime\";\nimport { Allowed } from \"@/modules/auth/components/allowed.client\";\nimport { TableBody, TableCell, TableRow } from \"@/modules/data-tables/components/table\";\nimport type { TableColumnDef } from \"../../../lib/types\";\nimport { useInlineTableContext } from \"../hooks/context.client\";\nimport { useInlineDataTableHotkeys } from \"../hooks/use-hotkeys.client\";\nimport { InlineTableRow } from \"./row.client\";\n\nexport function InlineTableBody<TData extends { id: string }>({ table }: { table: Table<TData> }) {\n const context = useInlineTableContext();\n\n const { rows } = table.getRowModel();\n\n const { setNodeRef } = useDroppable({ id: \"inline-data-table\" });\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, {\n coordinateGetter: sortableKeyboardCoordinates,\n }),\n );\n\n useInlineDataTableHotkeys(context.hotkeys);\n\n if (rows?.length === 0) {\n return (\n <TableBody>\n <TableRow>\n <TableCell\n colSpan={\n table.getAllFlatColumns().length +\n 1 +\n (context.isDraggable ? 1 : 0) +\n (table.options.enableRowSelection ? 1 : 0)\n }\n className=\"h-24 text-center\"\n >\n Geen resultaten gevonden\n </TableCell>\n </TableRow>\n </TableBody>\n );\n }\n\n function handleDragEnd(event: DragEndEvent) {\n if (!context.isDraggable) return;\n const { active, over } = event;\n\n if (active.id !== over?.id) {\n const fromIndex = rows.findIndex((item) => item.id === active.id);\n const toIndex = rows.findIndex((item) => item.id === over?.id);\n\n context.moveRow({ fromIndex, toIndex });\n }\n }\n\n return (\n <DndContext\n sensors={sensors}\n onDragEnd={handleDragEnd}\n collisionDetection={closestCenter}\n modifiers={[restrictToVerticalAxis, restrictToParentElement]}\n >\n <SortableContext items={rows.map((row) => row.id)} strategy={rectSortingStrategy}>\n <TableBody ref={setNodeRef}>\n {rows.map((row) => (\n <InlineTableRow\n key={row.id}\n row={row}\n data-row-id={row.id}\n table={table}\n className=\"relative\"\n >\n {row.getVisibleCells().map((cell) => {\n const columnDef = cell.column.columnDef as TableColumnDef<TData>;\n\n const children = flexRender(cell.column.columnDef.cell, cell.getContext());\n\n if (!columnDef.permissions) {\n return <Fragment key={cell.id}>{children}</Fragment>;\n }\n\n return (\n <Allowed key={cell.id} permission={columnDef.permissions}>\n {children}\n </Allowed>\n );\n })}\n </InlineTableRow>\n ))}\n </TableBody>\n </SortableContext>\n </DndContext>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA2BA,SAAgB,gBAA8C,EAAE,SAAkC;CAChG,MAAM,UAAU,uBAAuB;CAEvC,MAAM,EAAE,SAAS,MAAM,aAAa;CAEpC,MAAM,EAAE,eAAe,aAAa,EAAE,IAAI,qBAAqB,CAAC;CAChE,MAAM,UAAU,WACd,UAAU,cAAc,EACxB,UAAU,gBAAgB,EACxB,kBAAkB,6BACnB,CAAC,CACH;AAED,2BAA0B,QAAQ,QAAQ;AAE1C,KAAI,MAAM,WAAW,EACnB,QACE,oBAAC,uBACC,oBAAC,sBACC,oBAAC;EACC,SACE,MAAM,mBAAmB,CAAC,SAC1B,KACC,QAAQ,cAAc,IAAI,MAC1B,MAAM,QAAQ,qBAAqB,IAAI;EAE1C,WAAU;YACX;GAEW,GACH,GACD;CAIhB,SAAS,cAAc,OAAqB;AAC1C,MAAI,CAAC,QAAQ,YAAa;EAC1B,MAAM,EAAE,QAAQ,SAAS;AAEzB,MAAI,OAAO,OAAO,MAAM,IAAI;GAC1B,MAAM,YAAY,KAAK,WAAW,SAAS,KAAK,OAAO,OAAO,GAAG;GACjE,MAAM,UAAU,KAAK,WAAW,SAAS,KAAK,OAAO,MAAM,GAAG;AAE9D,WAAQ,QAAQ;IAAE;IAAW;IAAS,CAAC;;;AAI3C,QACE,oBAAC;EACU;EACT,WAAW;EACX,oBAAoB;EACpB,WAAW,CAAC,wBAAwB,wBAAwB;YAE5D,oBAAC;GAAgB,OAAO,KAAK,KAAK,QAAQ,IAAI,GAAG;GAAE,UAAU;aAC3D,oBAAC;IAAU,KAAK;cACb,KAAK,KAAK,QACT,oBAAC;KAEM;KACL,eAAa,IAAI;KACV;KACP,WAAU;eAET,IAAI,iBAAiB,CAAC,KAAK,SAAS;MACnC,MAAM,YAAY,KAAK,OAAO;MAE9B,MAAM,WAAW,WAAW,KAAK,OAAO,UAAU,MAAM,KAAK,YAAY,CAAC;AAE1E,UAAI,CAAC,UAAU,YACb,QAAO,oBAAC,YAAwB,YAAV,KAAK,GAAyB;AAGtD,aACE,oBAAC;OAAsB,YAAY,UAAU;OAC1C;SADW,KAAK,GAET;OAEZ;OApBG,IAAI,GAqBM,CACjB;KACQ;IACI;GACP"}
|
|
@@ -1,38 +1,28 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { ContextCommandMenu, ContextCommandMenuContent, ContextCommandMenuTrigger } from "../../../../commands/menus/context-menu.client.mjs";
|
|
4
3
|
import { TableRow } from "../../../components/table.mjs";
|
|
5
4
|
import { InlineEditProvider } from "../../../../inline-edit/hooks/context.client.mjs";
|
|
6
|
-
import { jsx
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
6
|
import { useSortable } from "@dnd-kit/sortable";
|
|
8
7
|
import { CSS } from "@dnd-kit/utilities";
|
|
9
8
|
|
|
10
9
|
//#region src/modules/data-tables/tables/inline-table/components/row.client.tsx
|
|
11
10
|
function InlineTableRow({ row, table, children, ...props }) {
|
|
12
|
-
const meta = table.options.meta;
|
|
13
11
|
const rowId = row.original.id;
|
|
14
12
|
const { setNodeRef, transform, transition } = useSortable({ id: rowId });
|
|
15
|
-
return /* @__PURE__ */
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
children
|
|
26
|
-
id: row.original.id,
|
|
27
|
-
children
|
|
28
|
-
})
|
|
13
|
+
return /* @__PURE__ */ jsx(TableRow, {
|
|
14
|
+
...props,
|
|
15
|
+
ref: setNodeRef,
|
|
16
|
+
"data-state": row.getIsSelected() && "selected",
|
|
17
|
+
style: {
|
|
18
|
+
transform: CSS.Transform.toString(transform),
|
|
19
|
+
transition
|
|
20
|
+
},
|
|
21
|
+
children: /* @__PURE__ */ jsx(InlineEditProvider, {
|
|
22
|
+
id: row.original.id,
|
|
23
|
+
children
|
|
29
24
|
})
|
|
30
|
-
})
|
|
31
|
-
data: row.original,
|
|
32
|
-
commands: meta.commands || [],
|
|
33
|
-
meta,
|
|
34
|
-
className: "w-[300px]"
|
|
35
|
-
})] });
|
|
25
|
+
});
|
|
36
26
|
}
|
|
37
27
|
|
|
38
28
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row.client.mjs","names":[],"sources":["../../../../../../src/modules/data-tables/tables/inline-table/components/row.client.tsx"],"sourcesContent":["\"use client\";\n\nimport { useSortable } from \"@dnd-kit/sortable\";\nimport { CSS } from \"@dnd-kit/utilities\";\nimport type { Row, Table } from \"@tanstack/react-table\";\nimport type * as React from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"row.client.mjs","names":[],"sources":["../../../../../../src/modules/data-tables/tables/inline-table/components/row.client.tsx"],"sourcesContent":["\"use client\";\n\nimport { useSortable } from \"@dnd-kit/sortable\";\nimport { CSS } from \"@dnd-kit/utilities\";\nimport type { Row, Table } from \"@tanstack/react-table\";\nimport type * as React from \"react\";\nimport { TableRow } from \"@/modules/data-tables/components/table\";\nimport { InlineEditProvider } from \"@/modules/inline-edit/entry.client\";\n\nexport type InlineTableRowProps<TData extends { id: string }> =\n React.HTMLAttributes<HTMLTableRowElement> & {\n row: Row<TData>;\n table: Table<TData>;\n };\n\nexport function InlineTableRow<TData extends { id: string }>({\n row,\n table,\n children,\n ...props\n}: InlineTableRowProps<TData>) {\n const rowId = (row.original as { id: string }).id;\n\n const { setNodeRef, transform, transition } = useSortable({ id: rowId });\n\n return (\n <TableRow\n {...props}\n ref={setNodeRef}\n data-state={row.getIsSelected() && \"selected\"}\n style={{\n transform: CSS.Transform.toString(transform),\n transition,\n }}\n >\n <InlineEditProvider id={row.original.id}>{children}</InlineEditProvider>\n </TableRow>\n );\n}\n\n{\n /* <ContextCommandMenu>\n <ContextCommandMenuTrigger asChild></ContextCommandMenuTrigger>\n\n <ContextCommandMenuContent\n data={row.original}\n commands={meta.commands || []}\n meta={meta as never}\n className=\"w-[300px]\"\n />\n</ContextCommandMenu>; */\n}\n"],"mappings":";;;;;;;;;AAeA,SAAgB,eAA6C,EAC3D,KACA,OACA,UACA,GAAG,SAC0B;CAC7B,MAAM,QAAS,IAAI,SAA4B;CAE/C,MAAM,EAAE,YAAY,WAAW,eAAe,YAAY,EAAE,IAAI,OAAO,CAAC;AAExE,QACE,oBAAC;EACC,GAAI;EACJ,KAAK;EACL,cAAY,IAAI,eAAe,IAAI;EACnC,OAAO;GACL,WAAW,IAAI,UAAU,SAAS,UAAU;GAC5C;GACD;YAED,oBAAC;GAAmB,IAAI,IAAI,SAAS;GAAK;IAA8B;GAC/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.mts","names":[],"sources":["../../../../../../src/modules/data-tables/tables/inline-table/components/table.tsx"],"mappings":";;;;;;iBAagB,WAAA;EAA4B,EAAA;AAAA,EAAA,CAAA;EAC1C,eAAA;EACA,aAAA;EAAA,GACG;AAAA,GACF,cAAA,QAAsB,KAAA,IAAS,cAAA,QAAsB,mBAAA,IAAoB,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
1
|
+
{"version":3,"file":"table.d.mts","names":[],"sources":["../../../../../../src/modules/data-tables/tables/inline-table/components/table.tsx"],"mappings":";;;;;;iBAagB,WAAA;EAA4B,EAAA;AAAA,EAAA,CAAA;EAC1C,eAAA;EACA,aAAA;EACA,OAAA;EAAA,GACG;AAAA,GACF,cAAA,QAAsB,KAAA,IAAS,cAAA,QAAsB,mBAAA,IAAoB,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -11,12 +11,13 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
import { HotkeysProvider } from "react-hotkeys-hook";
|
|
12
12
|
|
|
13
13
|
//#region src/modules/data-tables/tables/inline-table/components/table.tsx
|
|
14
|
-
function InlineTable({ disabledColumns, moveRowAction, ...props }) {
|
|
14
|
+
function InlineTable({ disabledColumns, moveRowAction, hotkeys, ...props }) {
|
|
15
15
|
const table = useTable();
|
|
16
16
|
const meta = table.options.meta;
|
|
17
17
|
return /* @__PURE__ */ jsx(InlineTableProvider, {
|
|
18
18
|
disabledColumns,
|
|
19
19
|
moveRowAction,
|
|
20
|
+
hotkeys,
|
|
20
21
|
children: /* @__PURE__ */ jsxs("div", {
|
|
21
22
|
className: "space-y-4",
|
|
22
23
|
children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.mjs","names":[],"sources":["../../../../../../src/modules/data-tables/tables/inline-table/components/table.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ComponentProps } from \"react\";\nimport { HotkeysProvider } from \"react-hotkeys-hook\";\nimport { FloatingCommandMenu } from \"@/modules/commands/menus/floating-menu.client\";\nimport { TableBottombar, TableFooter } from \"@/modules/data-tables/components/footer\";\nimport { Table } from \"@/modules/data-tables/components/table\";\nimport type { TableMeta } from \"@/modules/data-tables/entry\";\nimport { useTable } from \"@/modules/data-tables/hooks/use-table.client\";\nimport { InlineTableProvider } from \"../hooks/context.client\";\nimport { InlineTableBody } from \"./body\";\nimport { InlineTableHeader } from \"./header\";\n\nexport function InlineTable<TData extends { id: string }>({\n disabledColumns,\n moveRowAction,\n ...props\n}: ComponentProps<typeof Table> & ComponentProps<typeof InlineTableProvider>) {\n const table = useTable<TData>();\n const meta = table.options.meta as TableMeta<TData>;\n\n return (\n <InlineTableProvider
|
|
1
|
+
{"version":3,"file":"table.mjs","names":[],"sources":["../../../../../../src/modules/data-tables/tables/inline-table/components/table.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ComponentProps } from \"react\";\nimport { HotkeysProvider } from \"react-hotkeys-hook\";\nimport { FloatingCommandMenu } from \"@/modules/commands/menus/floating-menu.client\";\nimport { TableBottombar, TableFooter } from \"@/modules/data-tables/components/footer\";\nimport { Table } from \"@/modules/data-tables/components/table\";\nimport type { TableMeta } from \"@/modules/data-tables/entry\";\nimport { useTable } from \"@/modules/data-tables/hooks/use-table.client\";\nimport { InlineTableProvider } from \"../hooks/context.client\";\nimport { InlineTableBody } from \"./body\";\nimport { InlineTableHeader } from \"./header\";\n\nexport function InlineTable<TData extends { id: string }>({\n disabledColumns,\n moveRowAction,\n hotkeys,\n ...props\n}: ComponentProps<typeof Table> & ComponentProps<typeof InlineTableProvider>) {\n const table = useTable<TData>();\n const meta = table.options.meta as TableMeta<TData>;\n\n return (\n <InlineTableProvider\n disabledColumns={disabledColumns}\n moveRowAction={moveRowAction}\n hotkeys={hotkeys}\n >\n <div className=\"space-y-4\">\n <div className=\"rounded-md border\">\n <Table {...props}>\n <InlineTableHeader table={table} />\n\n <HotkeysProvider initiallyActiveScopes={[\"inline-data-table\"]}>\n <InlineTableBody table={table} />\n </HotkeysProvider>\n\n <TableFooter table={table} />\n </Table>\n </div>\n\n <TableBottombar table={table} />\n\n {meta.commands && (\n <FloatingCommandMenu\n data={meta.selectedData}\n commands={meta.commands}\n meta={meta}\n state={meta.selectedData?.length ? \"open\" : \"closed\"}\n onSuccess={() => table.resetRowSelection()}\n />\n )}\n </div>\n </InlineTableProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,YAA0C,EACxD,iBACA,eACA,SACA,GAAG,SACyE;CAC5E,MAAM,QAAQ,UAAiB;CAC/B,MAAM,OAAO,MAAM,QAAQ;AAE3B,QACE,oBAAC;EACkB;EACF;EACN;YAET,qBAAC;GAAI,WAAU;;IACb,oBAAC;KAAI,WAAU;eACb,qBAAC;MAAM,GAAI;;OACT,oBAAC,qBAAyB,QAAS;OAEnC,oBAAC;QAAgB,uBAAuB,CAAC,oBAAoB;kBAC3D,oBAAC,mBAAuB,QAAS;SACjB;OAElB,oBAAC,eAAmB,QAAS;;OACvB;MACJ;IAEN,oBAAC,kBAAsB,QAAS;IAE/B,KAAK,YACJ,oBAAC;KACC,MAAM,KAAK;KACX,UAAU,KAAK;KACT;KACN,OAAO,KAAK,cAAc,SAAS,SAAS;KAC5C,iBAAiB,MAAM,mBAAmB;MAC1C;;IAEA;GACc"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { InlineDataTableHotkeysConfig } from "./use-hotkeys.client.mjs";
|
|
1
2
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
3
|
import { PropsWithChildren } from "react";
|
|
3
4
|
import { VisibilityState } from "@tanstack/react-table";
|
|
@@ -21,6 +22,7 @@ type MoveRowMethod = {
|
|
|
21
22
|
*/
|
|
22
23
|
type InlineTableContextValue = MoveRowMethod & {
|
|
23
24
|
disabledColumns?: VisibilityState;
|
|
25
|
+
hotkeys?: InlineDataTableHotkeysConfig;
|
|
24
26
|
};
|
|
25
27
|
/**
|
|
26
28
|
* Inline form table context hook
|
|
@@ -34,13 +36,15 @@ declare function InlineTableProvider<TData extends {
|
|
|
34
36
|
}>({
|
|
35
37
|
children,
|
|
36
38
|
disabledColumns,
|
|
37
|
-
moveRowAction
|
|
39
|
+
moveRowAction,
|
|
40
|
+
hotkeys
|
|
38
41
|
}: PropsWithChildren<{
|
|
39
42
|
disabledColumns?: VisibilityState;
|
|
40
43
|
moveRowAction?: (input: {
|
|
41
44
|
fromIndex: number;
|
|
42
45
|
toIndex: number;
|
|
43
46
|
}) => Promise<unknown>;
|
|
47
|
+
hotkeys?: InlineDataTableHotkeysConfig;
|
|
44
48
|
}>): react_jsx_runtime0.JSX.Element;
|
|
45
49
|
//#endregion
|
|
46
50
|
export { InlineTableContextValue, InlineTableProvider, useInlineTableContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.client.d.mts","names":[],"sources":["../../../../../../src/modules/data-tables/tables/inline-table/hooks/context.client.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.client.d.mts","names":[],"sources":["../../../../../../src/modules/data-tables/tables/inline-table/hooks/context.client.tsx"],"mappings":";;;;;;;;;KAYK,aAAA;EAEC,WAAA;EACA,OAAA;AAAA;EAGA,WAAA;EACA,OAAA,GAAU,MAAA;IAAU,SAAA;IAAmB,OAAA;EAAA;AAAA;;;;KAMjC,uBAAA,GAA0B,aAAA;EACpC,eAAA,GAAkB,eAAA;EAClB,OAAA,GAAU,4BAAA;AAAA;;;;iBAYI,qBAAA,CAAA,GAAqB,uBAAA;;;;iBAUrB,mBAAA;EAAoC,EAAA;AAAA,EAAA,CAAA;EAClD,QAAA;EACA,eAAA;EACA,aAAA;EACA;AAAA,GACC,iBAAA;EACD,eAAA,GAAkB,eAAA;EAClB,aAAA,IAAiB,KAAA;IAAS,SAAA;IAAmB,OAAA;EAAA,MAAsB,OAAA;EACnE,OAAA,GAAU,4BAAA;AAAA,KACV,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -22,7 +22,7 @@ function useInlineTableContext() {
|
|
|
22
22
|
/**
|
|
23
23
|
* Inline form table context provider
|
|
24
24
|
*/
|
|
25
|
-
function InlineTableProvider({ children, disabledColumns, moveRowAction }) {
|
|
25
|
+
function InlineTableProvider({ children, disabledColumns, moveRowAction, hotkeys }) {
|
|
26
26
|
const { queryData, setData } = useTableConfigContext();
|
|
27
27
|
const moveRowMutation = useAction({
|
|
28
28
|
mutationFn: async (params) => {
|
|
@@ -41,6 +41,7 @@ function InlineTableProvider({ children, disabledColumns, moveRowAction }) {
|
|
|
41
41
|
return /* @__PURE__ */ jsx(InlineTableContext.Provider, {
|
|
42
42
|
value: {
|
|
43
43
|
disabledColumns,
|
|
44
|
+
hotkeys,
|
|
44
45
|
...moveRowAction ? {
|
|
45
46
|
isDraggable: true,
|
|
46
47
|
moveRow: moveRowMutation.mutate
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.client.mjs","names":[],"sources":["../../../../../../src/modules/data-tables/tables/inline-table/hooks/context.client.tsx"],"sourcesContent":["\"use client\";\n\nimport type { VisibilityState } from \"@tanstack/react-table\";\nimport React, { type PropsWithChildren } from \"react\";\nimport { arrayMove } from \"@/lib/entry\";\nimport { useAction } from \"@/lib/hooks/use-action\";\nimport { useTableConfigContext } from \"@/modules/data-tables/entry.client\";\n\n/**\n * Move row method as meta\n */\ntype MoveRowMethod =\n | {\n isDraggable: false;\n moveRow: undefined;\n }\n | {\n isDraggable: true;\n moveRow: (params: { fromIndex: number; toIndex: number }) => void;\n };\n\n/**\n * Inline form table context value\n */\nexport type InlineTableContextValue = MoveRowMethod & {\n disabledColumns?: VisibilityState;\n // setData: React.Dispatch<React.SetStateAction<TData[]>>;\n};\n\n/**\n * Inline form table context\n */\nconst InlineTableContext = React.createContext({} as InlineTableContextValue);\n\n/**\n * Inline form table context hook\n */\nexport function useInlineTableContext() {\n const context = React.useContext(InlineTableContext) as InlineTableContextValue;\n if (!context) throw new Error(\"InlineTableContext not found!\");\n return context;\n}\n\n/**\n * Inline form table context provider\n */\n\nexport function InlineTableProvider<TData extends { id: string }>({\n children,\n disabledColumns,\n moveRowAction,\n}: PropsWithChildren<{\n disabledColumns?: VisibilityState;\n moveRowAction?: (input: { fromIndex: number; toIndex: number }) => Promise<unknown>;\n}>) {\n const { queryData, setData } = useTableConfigContext<TData>();\n\n const moveRowMutation = useAction({\n mutationFn: async (params: { fromIndex: number; toIndex: number }) => {\n if (!moveRowAction) return;\n await moveRowAction(params);\n },\n onMutate: (params: { fromIndex: number; toIndex: number }) => {\n if (!moveRowAction) return;\n setData((prev) => arrayMove(prev, params));\n },\n onError: () => {\n if (!moveRowAction) return;\n setData(queryData);\n },\n });\n\n return (\n <InlineTableContext.Provider\n value={{\n disabledColumns,\n ...(moveRowAction\n ? { isDraggable: true, moveRow: moveRowMutation.mutate }\n : { isDraggable: false, moveRow: undefined }),\n }}\n >\n {children}\n </InlineTableContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"context.client.mjs","names":[],"sources":["../../../../../../src/modules/data-tables/tables/inline-table/hooks/context.client.tsx"],"sourcesContent":["\"use client\";\n\nimport type { VisibilityState } from \"@tanstack/react-table\";\nimport React, { type PropsWithChildren } from \"react\";\nimport { arrayMove } from \"@/lib/entry\";\nimport { useAction } from \"@/lib/hooks/use-action\";\nimport { useTableConfigContext } from \"@/modules/data-tables/entry.client\";\nimport type { InlineDataTableHotkeysConfig } from \"./use-hotkeys.client\";\n\n/**\n * Move row method as meta\n */\ntype MoveRowMethod =\n | {\n isDraggable: false;\n moveRow: undefined;\n }\n | {\n isDraggable: true;\n moveRow: (params: { fromIndex: number; toIndex: number }) => void;\n };\n\n/**\n * Inline form table context value\n */\nexport type InlineTableContextValue = MoveRowMethod & {\n disabledColumns?: VisibilityState;\n hotkeys?: InlineDataTableHotkeysConfig;\n // setData: React.Dispatch<React.SetStateAction<TData[]>>;\n};\n\n/**\n * Inline form table context\n */\nconst InlineTableContext = React.createContext({} as InlineTableContextValue);\n\n/**\n * Inline form table context hook\n */\nexport function useInlineTableContext() {\n const context = React.useContext(InlineTableContext) as InlineTableContextValue;\n if (!context) throw new Error(\"InlineTableContext not found!\");\n return context;\n}\n\n/**\n * Inline form table context provider\n */\n\nexport function InlineTableProvider<TData extends { id: string }>({\n children,\n disabledColumns,\n moveRowAction,\n hotkeys,\n}: PropsWithChildren<{\n disabledColumns?: VisibilityState;\n moveRowAction?: (input: { fromIndex: number; toIndex: number }) => Promise<unknown>;\n hotkeys?: InlineDataTableHotkeysConfig;\n}>) {\n const { queryData, setData } = useTableConfigContext<TData>();\n\n const moveRowMutation = useAction({\n mutationFn: async (params: { fromIndex: number; toIndex: number }) => {\n if (!moveRowAction) return;\n await moveRowAction(params);\n },\n onMutate: (params: { fromIndex: number; toIndex: number }) => {\n if (!moveRowAction) return;\n setData((prev) => arrayMove(prev, params));\n },\n onError: () => {\n if (!moveRowAction) return;\n setData(queryData);\n },\n });\n\n return (\n <InlineTableContext.Provider\n value={{\n disabledColumns,\n hotkeys,\n ...(moveRowAction\n ? { isDraggable: true, moveRow: moveRowMutation.mutate }\n : { isDraggable: false, moveRow: undefined }),\n }}\n >\n {children}\n </InlineTableContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAkCA,MAAM,qBAAqB,MAAM,cAAc,EAAE,CAA4B;;;;AAK7E,SAAgB,wBAAwB;CACtC,MAAM,UAAU,MAAM,WAAW,mBAAmB;AACpD,KAAI,CAAC,QAAS,OAAM,IAAI,MAAM,gCAAgC;AAC9D,QAAO;;;;;AAOT,SAAgB,oBAAkD,EAChE,UACA,iBACA,eACA,WAKE;CACF,MAAM,EAAE,WAAW,YAAY,uBAA8B;CAE7D,MAAM,kBAAkB,UAAU;EAChC,YAAY,OAAO,WAAmD;AACpE,OAAI,CAAC,cAAe;AACpB,SAAM,cAAc,OAAO;;EAE7B,WAAW,WAAmD;AAC5D,OAAI,CAAC,cAAe;AACpB,YAAS,SAAS,UAAU,MAAM,OAAO,CAAC;;EAE5C,eAAe;AACb,OAAI,CAAC,cAAe;AACpB,WAAQ,UAAU;;EAErB,CAAC;AAEF,QACE,oBAAC,mBAAmB;EAClB,OAAO;GACL;GACA;GACA,GAAI,gBACA;IAAE,aAAa;IAAM,SAAS,gBAAgB;IAAQ,GACtD;IAAE,aAAa;IAAO,SAAS;IAAW;GAC/C;EAEA;GAC2B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Keys } from "react-hotkeys-hook/dist/types";
|
|
2
|
+
|
|
3
|
+
//#region src/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Inline input data attribute used to identify navigable cells in the data table.
|
|
6
|
+
*/
|
|
7
|
+
declare const INLINE_INPUT_ATTR = "data-inline-input";
|
|
8
|
+
/**
|
|
9
|
+
* Props for configuring the hotkeys used for navigating between inline-editable cells in a data table.
|
|
10
|
+
* Each property corresponds to a direction of navigation and accepts an array of key combinations that trigger the navigation in that direction.
|
|
11
|
+
* If a property is not provided or is an empty array, the corresponding navigation hotkeys will be disabled.
|
|
12
|
+
*/
|
|
13
|
+
type InlineDataTableHotkeysConfig = {
|
|
14
|
+
moveLeft?: Keys | undefined;
|
|
15
|
+
moveRight?: Keys | undefined;
|
|
16
|
+
moveUp?: Keys | undefined;
|
|
17
|
+
moveDown?: Keys | undefined;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Sets up hotkeys for navigating between inline-editable cells in a data table:
|
|
21
|
+
* - ArrowUp / ArrowDown: Move vertically to the next cell with an input in the same column.
|
|
22
|
+
* - ArrowLeft / ArrowRight: Move horizontally to the next cell with an input in the same row.
|
|
23
|
+
*
|
|
24
|
+
* The hotkeys only trigger when focused within a table that uses the "inline-data-table" scope,
|
|
25
|
+
* and they look for elements with the [data-inline-input] attribute to determine navigable cells.
|
|
26
|
+
*/
|
|
27
|
+
declare function useInlineDataTableHotkeys(props?: InlineDataTableHotkeysConfig): void;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { INLINE_INPUT_ATTR, InlineDataTableHotkeysConfig, useInlineDataTableHotkeys };
|
|
30
|
+
//# sourceMappingURL=use-hotkeys.client.d.mts.map
|