@alepha/ui 0.28.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -2
- package/dist/components/account/account-connections.d.ts.map +1 -1
- package/dist/components/account/account-connections.js +4 -1
- package/dist/components/account/account-connections.js.map +1 -1
- package/dist/components/account/account-delete-dialog.d.ts.map +1 -1
- package/dist/components/account/account-delete-dialog.js +12 -15
- package/dist/components/account/account-delete-dialog.js.map +1 -1
- package/dist/components/account/account-keys.d.ts.map +1 -1
- package/dist/components/account/account-keys.js +22 -28
- package/dist/components/account/account-keys.js.map +1 -1
- package/dist/components/account/account-mfa-dialog.js +1 -4
- package/dist/components/account/account-mfa-dialog.js.map +1 -1
- package/dist/components/account/account-password-dialog.d.ts.map +1 -1
- package/dist/components/account/account-password-dialog.js +11 -14
- package/dist/components/account/account-password-dialog.js.map +1 -1
- package/dist/components/account/account-profile.js +3 -2
- package/dist/components/account/account-profile.js.map +1 -1
- package/dist/components/account/account-router-options.d.ts +38 -0
- package/dist/components/account/account-router-options.d.ts.map +1 -1
- package/dist/components/account/account-router-options.js.map +1 -1
- package/dist/components/account/account-router-page.d.ts +11 -1
- package/dist/components/account/account-router-page.d.ts.map +1 -1
- package/dist/components/account/account-router-page.js +11 -1
- package/dist/components/account/account-router-page.js.map +1 -1
- package/dist/components/account/account-router.d.ts +11 -0
- package/dist/components/account/account-router.d.ts.map +1 -1
- package/dist/components/account/account-router.js +16 -5
- package/dist/components/account/account-router.js.map +1 -1
- package/dist/components/admin/admin-audits.d.ts.map +1 -1
- package/dist/components/admin/admin-audits.js +91 -34
- package/dist/components/admin/admin-audits.js.map +1 -1
- package/dist/components/admin/admin-files.d.ts.map +1 -1
- package/dist/components/admin/admin-files.js +6 -17
- package/dist/components/admin/admin-files.js.map +1 -1
- package/dist/components/admin/admin-jobs-executions-panel.d.ts.map +1 -1
- package/dist/components/admin/admin-jobs-executions-panel.js +39 -8
- package/dist/components/admin/admin-jobs-executions-panel.js.map +1 -1
- package/dist/components/admin/admin-jobs-payload-dialog.d.ts +19 -0
- package/dist/components/admin/admin-jobs-payload-dialog.d.ts.map +1 -0
- package/dist/components/admin/admin-jobs-payload-dialog.js +33 -0
- package/dist/components/admin/admin-jobs-payload-dialog.js.map +1 -0
- package/dist/components/admin/admin-keys.d.ts.map +1 -1
- package/dist/components/admin/admin-keys.js +5 -4
- package/dist/components/admin/admin-keys.js.map +1 -1
- package/dist/components/admin/admin-notifications-channel-label.d.ts +14 -0
- package/dist/components/admin/admin-notifications-channel-label.d.ts.map +1 -0
- package/dist/components/admin/admin-notifications-channel-label.js +26 -0
- package/dist/components/admin/admin-notifications-channel-label.js.map +1 -0
- package/dist/components/admin/admin-notifications-preview-body.d.ts.map +1 -1
- package/dist/components/admin/admin-notifications-preview-body.js +23 -13
- package/dist/components/admin/admin-notifications-preview-body.js.map +1 -1
- package/dist/components/admin/admin-notifications.d.ts.map +1 -1
- package/dist/components/admin/admin-notifications.js +11 -12
- package/dist/components/admin/admin-notifications.js.map +1 -1
- package/dist/components/admin/admin-payments.d.ts.map +1 -1
- package/dist/components/admin/admin-payments.js +9 -7
- package/dist/components/admin/admin-payments.js.map +1 -1
- package/dist/components/admin/admin-router-options.d.ts +12 -0
- package/dist/components/admin/admin-router-options.d.ts.map +1 -1
- package/dist/components/admin/admin-router-options.js.map +1 -1
- package/dist/components/admin/admin-router.d.ts +5 -8
- package/dist/components/admin/admin-router.d.ts.map +1 -1
- package/dist/components/admin/admin-router.js +6 -29
- package/dist/components/admin/admin-router.js.map +1 -1
- package/dist/components/admin/admin-sessions.d.ts.map +1 -1
- package/dist/components/admin/admin-sessions.js +9 -7
- package/dist/components/admin/admin-sessions.js.map +1 -1
- package/dist/components/admin/admin-user-detail-audits-tab.d.ts.map +1 -1
- package/dist/components/admin/admin-user-detail-audits-tab.js +5 -4
- package/dist/components/admin/admin-user-detail-audits-tab.js.map +1 -1
- package/dist/components/admin/admin-user-detail-sessions-tab.d.ts.map +1 -1
- package/dist/components/admin/admin-user-detail-sessions-tab.js +7 -5
- package/dist/components/admin/admin-user-detail-sessions-tab.js.map +1 -1
- package/dist/components/admin/admin-user-detail.js +3 -2
- package/dist/components/admin/admin-user-detail.js.map +1 -1
- package/dist/components/admin/admin-users-roles-picker.d.ts.map +1 -1
- package/dist/components/admin/admin-users-roles-picker.js.map +1 -1
- package/dist/components/admin/admin-users.d.ts.map +1 -1
- package/dist/components/admin/admin-users.js +6 -4
- package/dist/components/admin/admin-users.js.map +1 -1
- package/dist/components/admin/analytics/AnalyticsChartBars.js +2 -1
- package/dist/components/admin/analytics/AnalyticsChartBars.js.map +1 -1
- package/dist/components/admin/parameter-history-item.d.ts.map +1 -1
- package/dist/components/admin/parameter-history-item.js +3 -2
- package/dist/components/admin/parameter-history-item.js.map +1 -1
- package/dist/components/alepha-table/alepha-table-bulk-menu.js +2 -1
- package/dist/components/alepha-table/alepha-table-bulk-menu.js.map +1 -1
- package/dist/components/alepha-table/alepha-table-filter-dialog.d.ts +60 -0
- package/dist/components/alepha-table/alepha-table-filter-dialog.d.ts.map +1 -0
- package/dist/components/alepha-table/alepha-table-filter-dialog.js +88 -0
- package/dist/components/alepha-table/alepha-table-filter-dialog.js.map +1 -0
- package/dist/components/alepha-table/alepha-table-filter-menu.d.ts +35 -0
- package/dist/components/alepha-table/alepha-table-filter-menu.d.ts.map +1 -0
- package/dist/components/alepha-table/alepha-table-filter-menu.js +54 -0
- package/dist/components/alepha-table/alepha-table-filter-menu.js.map +1 -0
- package/dist/components/alepha-table/alepha-table.d.ts +188 -3
- package/dist/components/alepha-table/alepha-table.d.ts.map +1 -1
- package/dist/components/alepha-table/alepha-table.js +551 -162
- package/dist/components/alepha-table/alepha-table.js.map +1 -1
- package/dist/components/alepha-table/query-filters.d.ts +73 -0
- package/dist/components/alepha-table/query-filters.d.ts.map +1 -0
- package/dist/components/alepha-table/query-filters.js +118 -0
- package/dist/components/alepha-table/query-filters.js.map +1 -0
- package/dist/components/app-actions/app-actions.d.ts +21 -0
- package/dist/components/app-actions/app-actions.d.ts.map +1 -1
- package/dist/components/app-actions/app-actions.js +11 -5
- package/dist/components/app-actions/app-actions.js.map +1 -1
- package/dist/components/app-shell/app-shell.d.ts +45 -0
- package/dist/components/app-shell/app-shell.d.ts.map +1 -1
- package/dist/components/app-shell/app-shell.js +119 -16
- package/dist/components/app-shell/app-shell.js.map +1 -1
- package/dist/components/auth/auth-register.js +31 -30
- package/dist/components/auth/auth-register.js.map +1 -1
- package/dist/components/auto-form/auto-form.d.ts.map +1 -1
- package/dist/components/auto-form/auto-form.js +68 -30
- package/dist/components/auto-form/auto-form.js.map +1 -1
- package/dist/components/button-dark/button-dark.d.ts.map +1 -1
- package/dist/components/button-dark/button-dark.js +39 -8
- package/dist/components/button-dark/button-dark.js.map +1 -1
- package/dist/components/button-inbox/button-inbox.d.ts +66 -0
- package/dist/components/button-inbox/button-inbox.d.ts.map +1 -0
- package/dist/components/button-inbox/button-inbox.js +167 -0
- package/dist/components/button-inbox/button-inbox.js.map +1 -0
- package/dist/components/button-inbox/inbox-unread-atom.d.ts +22 -0
- package/dist/components/button-inbox/inbox-unread-atom.d.ts.map +1 -0
- package/dist/components/button-inbox/inbox-unread-atom.js +29 -0
- package/dist/components/button-inbox/inbox-unread-atom.js.map +1 -0
- package/dist/components/button-theme/button-theme.d.ts +4 -3
- package/dist/components/button-theme/button-theme.d.ts.map +1 -1
- package/dist/components/button-theme/button-theme.js +8 -25
- package/dist/components/button-theme/button-theme.js.map +1 -1
- package/dist/components/button-user/button-user.d.ts +19 -0
- package/dist/components/button-user/button-user.d.ts.map +1 -1
- package/dist/components/button-user/button-user.js +1 -1
- package/dist/components/button-user/button-user.js.map +1 -1
- package/dist/components/control/control.d.ts +51 -0
- package/dist/components/control/control.d.ts.map +1 -1
- package/dist/components/control/control.js +49 -5
- package/dist/components/control/control.js.map +1 -1
- package/dist/components/control-array/control-array.js +2 -1
- package/dist/components/control-array/control-array.js.map +1 -1
- package/dist/components/control-date/control-date.d.ts +27 -0
- package/dist/components/control-date/control-date.d.ts.map +1 -1
- package/dist/components/control-date/control-date.js +15 -19
- package/dist/components/control-date/control-date.js.map +1 -1
- package/dist/components/control-date/date-only.d.ts +18 -0
- package/dist/components/control-date/date-only.d.ts.map +1 -0
- package/dist/components/control-date/date-only.js +29 -0
- package/dist/components/control-date/date-only.js.map +1 -0
- package/dist/components/control-date-range/control-date-range.d.ts +56 -0
- package/dist/components/control-date-range/control-date-range.d.ts.map +1 -0
- package/dist/components/control-date-range/control-date-range.js +148 -0
- package/dist/components/control-date-range/control-date-range.js.map +1 -0
- package/dist/components/control-object/control-object.js +2 -1
- package/dist/components/control-object/control-object.js.map +1 -1
- package/dist/components/control-select/control-select.d.ts.map +1 -1
- package/dist/components/control-select/control-select.js +177 -37
- package/dist/components/control-select/control-select.js.map +1 -1
- package/dist/components/control-upload/control-upload.d.ts.map +1 -1
- package/dist/components/control-upload/control-upload.js +1 -11
- package/dist/components/control-upload/control-upload.js.map +1 -1
- package/dist/components/detail/detail-aside.d.ts.map +1 -1
- package/dist/components/detail/detail-aside.js +4 -3
- package/dist/components/detail/detail-aside.js.map +1 -1
- package/dist/components/file-image/file-image.js +2 -1
- package/dist/components/file-image/file-image.js.map +1 -1
- package/dist/components/markdown-view/SpoilerSpan.d.ts +28 -0
- package/dist/components/markdown-view/SpoilerSpan.d.ts.map +1 -0
- package/dist/components/markdown-view/SpoilerSpan.js +53 -0
- package/dist/components/markdown-view/SpoilerSpan.js.map +1 -0
- package/dist/components/markdown-view/diagram/layoutSequence.js +13 -23
- package/dist/components/markdown-view/diagram/layoutSequence.js.map +1 -1
- package/dist/components/markdown-view/diagram/textMetrics.js +2 -2
- package/dist/components/markdown-view/diagram/textMetrics.js.map +1 -1
- package/dist/components/markdown-view/markdown-view.css +44 -0
- package/dist/components/markdown-view/markdown-view.d.ts +12 -0
- package/dist/components/markdown-view/markdown-view.d.ts.map +1 -1
- package/dist/components/markdown-view/markdown-view.js +22 -1
- package/dist/components/markdown-view/markdown-view.js.map +1 -1
- package/dist/components/markdown-view/remarkSpoiler.d.ts +17 -0
- package/dist/components/markdown-view/remarkSpoiler.d.ts.map +1 -0
- package/dist/components/markdown-view/remarkSpoiler.js +117 -0
- package/dist/components/markdown-view/remarkSpoiler.js.map +1 -0
- package/dist/components/permission-matrix/permission-matrix-group-rows.d.ts +34 -0
- package/dist/components/permission-matrix/permission-matrix-group-rows.d.ts.map +1 -0
- package/dist/components/permission-matrix/permission-matrix-group-rows.js +109 -0
- package/dist/components/permission-matrix/permission-matrix-group-rows.js.map +1 -0
- package/dist/components/permission-matrix/permission-matrix.d.ts +145 -0
- package/dist/components/permission-matrix/permission-matrix.d.ts.map +1 -0
- package/dist/components/permission-matrix/permission-matrix.js +113 -0
- package/dist/components/permission-matrix/permission-matrix.js.map +1 -0
- package/dist/components/plate-layout/plate-layout.d.ts +5 -0
- package/dist/components/plate-layout/plate-layout.d.ts.map +1 -1
- package/dist/components/plate-layout/plate-layout.js +2 -1
- package/dist/components/plate-layout/plate-layout.js.map +1 -1
- package/dist/components/plate-layout/plate-tab-bar.d.ts +10 -0
- package/dist/components/plate-layout/plate-tab-bar.d.ts.map +1 -1
- package/dist/components/plate-layout/plate-tab-bar.js +1 -1
- package/dist/components/plate-layout/plate-tab-bar.js.map +1 -1
- package/dist/components/settings/settings-nav.js +2 -1
- package/dist/components/settings/settings-nav.js.map +1 -1
- package/dist/components/time-ago/time-ago.d.ts +57 -0
- package/dist/components/time-ago/time-ago.d.ts.map +1 -0
- package/dist/components/time-ago/time-ago.js +60 -0
- package/dist/components/time-ago/time-ago.js.map +1 -0
- package/dist/components/tree-view/tree-model.d.ts +128 -0
- package/dist/components/tree-view/tree-model.d.ts.map +1 -0
- package/dist/components/tree-view/tree-model.js +226 -0
- package/dist/components/tree-view/tree-model.js.map +1 -0
- package/dist/components/tree-view/tree-view-rename-input.d.ts +31 -0
- package/dist/components/tree-view/tree-view-rename-input.d.ts.map +1 -0
- package/dist/components/tree-view/tree-view-rename-input.js +68 -0
- package/dist/components/tree-view/tree-view-rename-input.js.map +1 -0
- package/dist/components/tree-view/tree-view-resizer.d.ts +38 -0
- package/dist/components/tree-view/tree-view-resizer.d.ts.map +1 -0
- package/dist/components/tree-view/tree-view-resizer.js +73 -0
- package/dist/components/tree-view/tree-view-resizer.js.map +1 -0
- package/dist/components/tree-view/tree-view-row.d.ts +177 -0
- package/dist/components/tree-view/tree-view-row.d.ts.map +1 -0
- package/dist/components/tree-view/tree-view-row.js +241 -0
- package/dist/components/tree-view/tree-view-row.js.map +1 -0
- package/dist/components/tree-view/tree-view.d.ts +186 -0
- package/dist/components/tree-view/tree-view.d.ts.map +1 -0
- package/dist/components/tree-view/tree-view.js +112 -0
- package/dist/components/tree-view/tree-view.js.map +1 -0
- package/dist/components/tree-view/use-tree-state.d.ts +79 -0
- package/dist/components/tree-view/use-tree-state.d.ts.map +1 -0
- package/dist/components/tree-view/use-tree-state.js +93 -0
- package/dist/components/tree-view/use-tree-state.js.map +1 -0
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/select.d.ts +7 -0
- package/dist/components/ui/select.d.ts.map +1 -1
- package/dist/components/ui/select.js +7 -0
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/sidebar.js.map +1 -1
- package/dist/components/ui/table.js.map +1 -1
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/lib/i18n-fr.d.ts.map +1 -1
- package/dist/lib/i18n-fr.js +31 -47
- package/dist/lib/i18n-fr.js.map +1 -1
- package/dist/lib/utils.d.ts +22 -2
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +29 -5
- package/dist/lib/utils.js.map +1 -1
- package/dist/styles.css +255 -0
- package/package.json +13 -14
- package/src/components/account/__tests__/account-router.spec.ts +95 -0
- package/src/components/account/account-connections.tsx +14 -1
- package/src/components/account/account-delete-dialog.tsx +3 -2
- package/src/components/account/account-keys.tsx +11 -4
- package/src/components/account/account-mfa-dialog.tsx +1 -1
- package/src/components/account/account-password-dialog.tsx +3 -2
- package/src/components/account/account-profile.tsx +1 -1
- package/src/components/account/account-router-options.tsx +45 -0
- package/src/components/account/account-router-page.tsx +11 -1
- package/src/components/account/account-router.tsx +23 -6
- package/src/components/admin/__tests__/admin-jobs-payload-dialog.browser.spec.tsx +68 -0
- package/src/components/admin/__tests__/admin-notifications-preview-body.browser.spec.tsx +20 -4
- package/src/components/admin/__tests__/admin-status-labels.browser.spec.tsx +0 -31
- package/src/components/admin/admin-audits.tsx +99 -5
- package/src/components/admin/admin-files.tsx +7 -16
- package/src/components/admin/admin-jobs-executions-panel.tsx +152 -114
- package/src/components/admin/admin-jobs-payload-dialog.tsx +57 -0
- package/src/components/admin/admin-keys.tsx +7 -4
- package/src/components/admin/admin-notifications-channel-label.ts +18 -0
- package/src/components/admin/admin-notifications-preview-body.tsx +7 -2
- package/src/components/admin/admin-notifications.tsx +19 -8
- package/src/components/admin/admin-payments.tsx +7 -4
- package/src/components/admin/admin-router-options.tsx +12 -0
- package/src/components/admin/admin-router.tsx +5 -27
- package/src/components/admin/admin-sessions.tsx +10 -6
- package/src/components/admin/admin-user-detail-audits-tab.tsx +7 -4
- package/src/components/admin/admin-user-detail-sessions-tab.tsx +7 -4
- package/src/components/admin/admin-users-roles-picker.tsx +4 -0
- package/src/components/admin/admin-users.tsx +6 -3
- package/src/components/admin/parameter-history-item.tsx +4 -2
- package/src/components/alepha-table/__tests__/alepha-table-default-hidden.browser.spec.tsx +108 -0
- package/src/components/alepha-table/__tests__/alepha-table-empty-state.browser.spec.tsx +233 -0
- package/src/components/alepha-table/__tests__/alepha-table-persist-facets.browser.spec.tsx +177 -0
- package/src/components/alepha-table/__tests__/alepha-table-persisted-filters.browser.spec.tsx +182 -0
- package/src/components/alepha-table/__tests__/alepha-table-query-seed.browser.spec.tsx +170 -0
- package/src/components/alepha-table/__tests__/alepha-table-row-action-checked.browser.spec.tsx +210 -0
- package/src/components/alepha-table/__tests__/alepha-table-row-action-group.browser.spec.tsx +202 -0
- package/src/components/alepha-table/__tests__/alepha-table-scope.browser.spec.tsx +161 -0
- package/src/components/alepha-table/__tests__/alepha-table-share-filters.browser.spec.tsx +309 -0
- package/src/components/alepha-table/__tests__/query-filters.spec.ts +212 -0
- package/src/components/alepha-table/alepha-table-filter-dialog.tsx +162 -0
- package/src/components/alepha-table/alepha-table-filter-menu.tsx +77 -0
- package/src/components/alepha-table/alepha-table.tsx +1113 -207
- package/src/components/alepha-table/query-filters.ts +159 -0
- package/src/components/app-actions/app-actions.tsx +32 -3
- package/src/components/app-shell/__tests__/sidebar-nav-accordion.browser.spec.tsx +163 -0
- package/src/components/app-shell/app-shell.tsx +255 -12
- package/src/components/auto-form/__tests__/auto-form-settings-card.browser.spec.tsx +1 -1
- package/src/components/auto-form/auto-form.tsx +98 -30
- package/src/components/button-dark/button-dark.tsx +47 -8
- package/src/components/button-inbox/__tests__/button-inbox.browser.spec.tsx +247 -0
- package/src/components/button-inbox/button-inbox.tsx +303 -0
- package/src/components/button-inbox/inbox-unread-atom.ts +27 -0
- package/src/components/button-theme/button-theme.tsx +16 -29
- package/src/components/button-user/__tests__/button-user-avatar.browser.spec.tsx +88 -0
- package/src/components/button-user/button-user.tsx +24 -1
- package/src/components/control/__tests__/control-date-range.browser.spec.tsx +177 -0
- package/src/components/control/control.tsx +119 -12
- package/src/components/control-date/control-date.tsx +117 -22
- package/src/components/control-date/date-only.ts +26 -0
- package/src/components/control-date-range/control-date-range.tsx +250 -0
- package/src/components/control-select/__tests__/control-select-clear-label.browser.spec.tsx +129 -15
- package/src/components/control-select/__tests__/control-select-deselect.browser.spec.tsx +27 -6
- package/src/components/control-select/__tests__/control-select-multi.browser.spec.tsx +204 -1
- package/src/components/control-select/__tests__/control-select-size-minimal.browser.spec.tsx +77 -1
- package/src/components/control-select/control-select.tsx +317 -83
- package/src/components/control-upload/control-upload.tsx +1 -10
- package/src/components/detail/detail-aside.tsx +30 -6
- package/src/components/markdown-view/SpoilerSpan.tsx +66 -0
- package/src/components/markdown-view/__tests__/markdown-view-spoiler.browser.spec.tsx +165 -0
- package/src/components/markdown-view/diagram/textMetrics.spec.ts +1 -1
- package/src/components/markdown-view/diagram/textMetrics.ts +2 -2
- package/src/components/markdown-view/markdown-view.css +44 -0
- package/src/components/markdown-view/markdown-view.tsx +37 -1
- package/src/components/markdown-view/remarkSpoiler.ts +150 -0
- package/src/components/permission-matrix/__tests__/permission-matrix.browser.spec.tsx +237 -0
- package/src/components/permission-matrix/permission-matrix-group-rows.tsx +240 -0
- package/src/components/permission-matrix/permission-matrix.tsx +286 -0
- package/src/components/plate-layout/__tests__/plate-layout.browser.spec.tsx +22 -0
- package/src/components/plate-layout/plate-layout.tsx +6 -0
- package/src/components/plate-layout/plate-tab-bar.tsx +27 -1
- package/src/components/time-ago/time-ago.browser.spec.tsx +110 -0
- package/src/components/time-ago/time-ago.tsx +80 -0
- package/src/components/tree-view/__tests__/tree-model.spec.ts +441 -0
- package/src/components/tree-view/__tests__/tree-view-drag.browser.spec.tsx +295 -0
- package/src/components/tree-view/__tests__/tree-view-rename.browser.spec.tsx +278 -0
- package/src/components/tree-view/__tests__/tree-view-resizer.browser.spec.tsx +112 -0
- package/src/components/tree-view/__tests__/tree-view.browser.spec.tsx +260 -0
- package/src/components/tree-view/__tests__/use-tree-state.browser.spec.tsx +238 -0
- package/src/components/tree-view/tree-model.ts +369 -0
- package/src/components/tree-view/tree-view-rename-input.tsx +95 -0
- package/src/components/tree-view/tree-view-resizer.tsx +83 -0
- package/src/components/tree-view/tree-view-row.tsx +414 -0
- package/src/components/tree-view/tree-view.tsx +300 -0
- package/src/components/tree-view/use-tree-state.ts +184 -0
- package/src/components/ui/button.tsx +79 -1
- package/src/components/ui/dropdown-menu.tsx +1 -1
- package/src/components/ui/select.tsx +7 -0
- package/src/components/ui/table.tsx +1 -1
- package/src/components/ui/tooltip.tsx +1 -1
- package/src/lib/i18n-fr.ts +34 -51
- package/src/lib/utils.ts +32 -4
- package/src/styles.css +255 -0
- package/dist/components/admin/admin-workflows-execution-sheet.d.ts +0 -11
- package/dist/components/admin/admin-workflows-execution-sheet.d.ts.map +0 -1
- package/dist/components/admin/admin-workflows-execution-sheet.js +0 -190
- package/dist/components/admin/admin-workflows-execution-sheet.js.map +0 -1
- package/dist/components/admin/admin-workflows-executions-panel.d.ts +0 -9
- package/dist/components/admin/admin-workflows-executions-panel.d.ts.map +0 -1
- package/dist/components/admin/admin-workflows-executions-panel.js +0 -121
- package/dist/components/admin/admin-workflows-executions-panel.js.map +0 -1
- package/dist/components/admin/admin-workflows-status-badge.d.ts +0 -12
- package/dist/components/admin/admin-workflows-status-badge.d.ts.map +0 -1
- package/dist/components/admin/admin-workflows-status-badge.js +0 -30
- package/dist/components/admin/admin-workflows-status-badge.js.map +0 -1
- package/dist/components/admin/admin-workflows-status-labels.d.ts +0 -19
- package/dist/components/admin/admin-workflows-status-labels.d.ts.map +0 -1
- package/dist/components/admin/admin-workflows-status-labels.js +0 -48
- package/dist/components/admin/admin-workflows-status-labels.js.map +0 -1
- package/dist/components/admin/admin-workflows.d.ts +0 -4
- package/dist/components/admin/admin-workflows.d.ts.map +0 -1
- package/dist/components/admin/admin-workflows.js +0 -145
- package/dist/components/admin/admin-workflows.js.map +0 -1
- package/src/components/admin/admin-workflows-execution-sheet.tsx +0 -285
- package/src/components/admin/admin-workflows-executions-panel.tsx +0 -169
- package/src/components/admin/admin-workflows-status-badge.tsx +0 -41
- package/src/components/admin/admin-workflows-status-labels.ts +0 -51
- package/src/components/admin/admin-workflows.tsx +0 -209
|
@@ -5,6 +5,13 @@ void React;
|
|
|
5
5
|
import { Control } from "@alepha/ui/components/control/control";
|
|
6
6
|
import { Button } from "@alepha/ui/components/ui/button";
|
|
7
7
|
import { Checkbox } from "@alepha/ui/components/ui/checkbox";
|
|
8
|
+
import {
|
|
9
|
+
ContextMenu,
|
|
10
|
+
ContextMenuContent,
|
|
11
|
+
ContextMenuItem,
|
|
12
|
+
ContextMenuSeparator,
|
|
13
|
+
ContextMenuTrigger,
|
|
14
|
+
} from "@alepha/ui/components/ui/context-menu";
|
|
8
15
|
import {
|
|
9
16
|
DropdownMenu,
|
|
10
17
|
DropdownMenuCheckboxItem,
|
|
@@ -13,6 +20,9 @@ import {
|
|
|
13
20
|
DropdownMenuItem,
|
|
14
21
|
DropdownMenuLabel,
|
|
15
22
|
DropdownMenuSeparator,
|
|
23
|
+
DropdownMenuSub,
|
|
24
|
+
DropdownMenuSubContent,
|
|
25
|
+
DropdownMenuSubTrigger,
|
|
16
26
|
DropdownMenuTrigger,
|
|
17
27
|
} from "@alepha/ui/components/ui/dropdown-menu";
|
|
18
28
|
import {
|
|
@@ -39,6 +49,7 @@ import {
|
|
|
39
49
|
TooltipProvider,
|
|
40
50
|
TooltipTrigger,
|
|
41
51
|
} from "@alepha/ui/components/ui/tooltip";
|
|
52
|
+
import { useToast } from "@alepha/ui/components/use-toast/use-toast";
|
|
42
53
|
import { cn } from "@alepha/ui/lib/utils";
|
|
43
54
|
import { type Page, type ZObject, z } from "alepha";
|
|
44
55
|
import { ClientOnly, useAlepha } from "alepha/react";
|
|
@@ -48,9 +59,18 @@ import {
|
|
|
48
59
|
ArrowDown,
|
|
49
60
|
ArrowUp,
|
|
50
61
|
ChevronsUpDown,
|
|
62
|
+
ArrowDownAZ,
|
|
63
|
+
ArrowUpAZ,
|
|
64
|
+
ChevronDown,
|
|
65
|
+
ChevronLeft,
|
|
66
|
+
ChevronRight,
|
|
67
|
+
ChevronUp,
|
|
51
68
|
Columns3,
|
|
69
|
+
EyeOff,
|
|
52
70
|
FunnelX,
|
|
71
|
+
GripVertical,
|
|
53
72
|
Inbox,
|
|
73
|
+
SearchX,
|
|
54
74
|
MoreVertical,
|
|
55
75
|
RefreshCw,
|
|
56
76
|
X,
|
|
@@ -66,8 +86,16 @@ import {
|
|
|
66
86
|
useState,
|
|
67
87
|
} from "react";
|
|
68
88
|
|
|
89
|
+
import { useIsMobile } from "../../hooks/use-mobile.ts";
|
|
69
90
|
import { AlephaTableBulkMenu } from "./alepha-table-bulk-menu.tsx";
|
|
91
|
+
import { AlephaTableFilterDialog } from "./alepha-table-filter-dialog.tsx";
|
|
92
|
+
import { AlephaTableFilterMenu } from "./alepha-table-filter-menu.tsx";
|
|
70
93
|
import { paginateLocal } from "./paginate-local.ts";
|
|
94
|
+
import {
|
|
95
|
+
cleanFilterValues,
|
|
96
|
+
queryToFilters,
|
|
97
|
+
shareFiltersUrl,
|
|
98
|
+
} from "./query-filters.ts";
|
|
71
99
|
import { useTableSelection } from "./use-table-selection.ts";
|
|
72
100
|
|
|
73
101
|
type IconType = ComponentType<SVGProps<SVGSVGElement>>;
|
|
@@ -118,8 +146,44 @@ export interface RowAction<T> {
|
|
|
118
146
|
onClick: (item: T, ctx: RowActionContext) => void | Promise<void>;
|
|
119
147
|
destructive?: boolean;
|
|
120
148
|
disabled?: (item: T) => boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Whether this entry is the row's current value, for a group that picks
|
|
151
|
+
* one of several - which release the row ships in, which area it sits in.
|
|
152
|
+
* Declaring it renders the entry as a checkbox item, so the check mark and
|
|
153
|
+
* the `aria-checked` both come from the primitive rather than from a
|
|
154
|
+
* marker glued into the label.
|
|
155
|
+
*
|
|
156
|
+
* ⚠️ Omitting it is not the same as returning false. An entry with no
|
|
157
|
+
* `checked` stays an ordinary `menuitem`; one that returns false is a
|
|
158
|
+
* `menuitemcheckbox` that happens to be unchecked, which is what a query
|
|
159
|
+
* by role has to account for.
|
|
160
|
+
*
|
|
161
|
+
* `destructive` is ignored on a checked entry: nothing that picks a value
|
|
162
|
+
* out of a list is also a delete.
|
|
163
|
+
*/
|
|
164
|
+
checked?: (item: T) => boolean;
|
|
121
165
|
}
|
|
122
166
|
|
|
167
|
+
/**
|
|
168
|
+
* A row action that is a submenu: a label, an icon, and the actions it
|
|
169
|
+
* holds. One level only: a group's children are actions, never groups.
|
|
170
|
+
*
|
|
171
|
+
* The discriminant is the presence of `children`, so every caller that
|
|
172
|
+
* returns a plain `RowAction[]` keeps compiling unchanged.
|
|
173
|
+
*
|
|
174
|
+
* ⚠️ A group with no children renders nothing, and does not count towards
|
|
175
|
+
* the row menu existing at all: a row whose only entry is an empty group
|
|
176
|
+
* gets no three-dots trigger. That lets a caller build `children`
|
|
177
|
+
* conditionally without checking whether anything survived.
|
|
178
|
+
*/
|
|
179
|
+
export interface RowActionGroup<T> {
|
|
180
|
+
label: string;
|
|
181
|
+
icon?: IconType;
|
|
182
|
+
children: RowAction<T>[];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export type RowActionEntry<T> = RowAction<T> | RowActionGroup<T>;
|
|
186
|
+
|
|
123
187
|
/**
|
|
124
188
|
* Context passed to every bulk-action `onClick`. `clearSelection()`
|
|
125
189
|
* empties the checkbox set; `refresh()` re-fires the current fetch.
|
|
@@ -235,6 +299,76 @@ export interface TableAction {
|
|
|
235
299
|
primary?: boolean;
|
|
236
300
|
}
|
|
237
301
|
|
|
302
|
+
/**
|
|
303
|
+
* One of the table's two empty states: an icon, a title and a description,
|
|
304
|
+
* centred in the body.
|
|
305
|
+
*
|
|
306
|
+
* Which one is shown is decided by the table, not the caller: a page that
|
|
307
|
+
* came back empty with no filter set means "there is nothing here", and the
|
|
308
|
+
* same page with a filter set means "nothing matched". Those ask the reader
|
|
309
|
+
* for opposite things - create something, or widen the filter - so one
|
|
310
|
+
* sentence for both sends half of them the wrong way. Override the wording
|
|
311
|
+
* per mode, never the choice between them.
|
|
312
|
+
*/
|
|
313
|
+
export interface AlephaTableEmptyState {
|
|
314
|
+
icon?: IconType;
|
|
315
|
+
title?: ReactNode;
|
|
316
|
+
description?: ReactNode;
|
|
317
|
+
/**
|
|
318
|
+
* A call to action under the description, typically one `<Button>`.
|
|
319
|
+
*
|
|
320
|
+
* A slot rather than a `{ label, onClick }` pair, because the button an
|
|
321
|
+
* empty state wants is rarely just a button: it opens a dialog, it is a
|
|
322
|
+
* `<Link>`, it is disabled while a permission is loading. The table owns the
|
|
323
|
+
* layout and centring and nothing else.
|
|
324
|
+
*
|
|
325
|
+
* Most useful on {@link AlephaTableBaseProps.emptyState}, where "there is
|
|
326
|
+
* nothing here" has an obvious answer - create the first one. The no-match
|
|
327
|
+
* side takes it too, for a "Clear filters" button.
|
|
328
|
+
*/
|
|
329
|
+
action?: ReactNode;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Which of the preferences {@link AlephaTableBaseProps.persistenceKey} stores
|
|
334
|
+
* are actually stored.
|
|
335
|
+
*
|
|
336
|
+
* Every facet defaults to ON, so a table that sets a key and nothing else
|
|
337
|
+
* behaves exactly as it always has. Only name the ones you want OFF.
|
|
338
|
+
*
|
|
339
|
+
* The facets are genuinely different kinds of preference, which is why one
|
|
340
|
+
* switch over all three was the wrong shape. Column layout and sort are what
|
|
341
|
+
* a reader arranged and expects to find again; a filter is what they were
|
|
342
|
+
* looking for last time, and restoring it opens the page narrowed by a
|
|
343
|
+
* question they have already answered - the hazard
|
|
344
|
+
* {@link AlephaTableFilters.seedValues} names as "landing on last week's
|
|
345
|
+
* stored filter".
|
|
346
|
+
*
|
|
347
|
+
* ⚠️ The footer's page SIZE is not one of these and is always stored with the
|
|
348
|
+
* key. It is a fourth thing, nothing has asked to separate it, and leaving it
|
|
349
|
+
* alone is what keeps this addition invisible to every existing caller.
|
|
350
|
+
*
|
|
351
|
+
* ⚠️ Read where `persistenceKey` is, so treat it as static per call site.
|
|
352
|
+
* Turning a facet off does not delete what it previously wrote: the stored
|
|
353
|
+
* value is simply never read again, because writing on mount is the bug the
|
|
354
|
+
* column and filter effects exist to avoid.
|
|
355
|
+
*/
|
|
356
|
+
export interface AlephaTablePersistedFacets {
|
|
357
|
+
/**
|
|
358
|
+
* The filter form's values. Off means the table opens unfiltered every
|
|
359
|
+
* time, whatever the reader last typed.
|
|
360
|
+
*/
|
|
361
|
+
filters?: boolean;
|
|
362
|
+
/**
|
|
363
|
+
* Which columns are visible, and in what order.
|
|
364
|
+
*/
|
|
365
|
+
columns?: boolean;
|
|
366
|
+
/**
|
|
367
|
+
* The sorted column and its direction.
|
|
368
|
+
*/
|
|
369
|
+
sort?: boolean;
|
|
370
|
+
}
|
|
371
|
+
|
|
238
372
|
/**
|
|
239
373
|
* High-level filter slot. AlephaTable creates the `useForm` internally,
|
|
240
374
|
* wraps `render`'s output in a `<form>` element, persists values under
|
|
@@ -268,6 +402,32 @@ export interface AlephaTableFilters {
|
|
|
268
402
|
* the right moment for it: that is the reader choosing.
|
|
269
403
|
*/
|
|
270
404
|
seedValues?: Record<string, any>;
|
|
405
|
+
/**
|
|
406
|
+
* Fill the filters from the URL query on arrival.
|
|
407
|
+
*
|
|
408
|
+
* `true` reads every param whose name matches a key of `schema`; an array
|
|
409
|
+
* narrows that to the keys it names. Params the schema does not declare are
|
|
410
|
+
* ignored, so the page keeps owning its own (`?tab=`, a locale, a tracking
|
|
411
|
+
* param). Multi-value filters are comma-joined: `?status=new,triaged`.
|
|
412
|
+
*
|
|
413
|
+
* Read once, at mount, and landed in the same slot as {@link seedValues} —
|
|
414
|
+
* above the reader's stored filters, below an explicit `seedValues` the
|
|
415
|
+
* caller passes for a case of its own.
|
|
416
|
+
*
|
|
417
|
+
* ⚠️ **One-directional, and it has to stay that way.** The URL seeds the
|
|
418
|
+
* filters; the filters NEVER write back. Lore's `?view=kanban` was removed
|
|
419
|
+
* for exactly this (#156): an effect that restored a missing param keyed on
|
|
420
|
+
* the router state, which is a global store, so the render on the way *out*
|
|
421
|
+
* of the page saw the next route's query and bounced the reader straight
|
|
422
|
+
* back. A page cannot tell "nobody has chosen yet" from "we are leaving"
|
|
423
|
+
* while the state lives in the URL. The toolbar's Share item is the write
|
|
424
|
+
* side, and it writes to the clipboard on a click, never to the address bar
|
|
425
|
+
* on a keystroke.
|
|
426
|
+
*
|
|
427
|
+
* Off by default. A page's query params are not its table's filters until
|
|
428
|
+
* the page says so.
|
|
429
|
+
*/
|
|
430
|
+
fromQuery?: boolean | readonly string[];
|
|
271
431
|
render: (form: FormModel<ZObject>) => ReactNode;
|
|
272
432
|
}
|
|
273
433
|
|
|
@@ -385,8 +545,11 @@ export interface AlephaTableBaseProps<T> {
|
|
|
385
545
|
/**
|
|
386
546
|
* Per-row action menu builder. Return an array of `RowAction` per
|
|
387
547
|
* item. Each `onClick` receives `(item, { refresh })`.
|
|
548
|
+
*
|
|
549
|
+
* An entry may also be a {@link RowActionGroup}: a label, an icon and
|
|
550
|
+
* the actions it holds, rendered as a submenu one level deep.
|
|
388
551
|
*/
|
|
389
|
-
rowActions?: (item: T) =>
|
|
552
|
+
rowActions?: (item: T) => RowActionEntry<T>[];
|
|
390
553
|
/**
|
|
391
554
|
* Actions applied to selected rows (enables checkbox column). A
|
|
392
555
|
* {@link BulkAction} is a button whose `onClick` receives
|
|
@@ -454,8 +617,22 @@ export interface AlephaTableBaseProps<T> {
|
|
|
454
617
|
* persisted to `localStorage` under this key. Pick a key that's
|
|
455
618
|
* unique per page and per scope (e.g. `"admin.users"`,
|
|
456
619
|
* `\`lor.board.${campaignId}\``).
|
|
620
|
+
*
|
|
621
|
+
* Narrow what it stores with {@link persist}.
|
|
457
622
|
*/
|
|
458
623
|
persistenceKey?: string;
|
|
624
|
+
/**
|
|
625
|
+
* Which facets {@link persistenceKey} stores. All three by default, so this
|
|
626
|
+
* is only ever worth passing to turn one OFF.
|
|
627
|
+
*
|
|
628
|
+
* The case it exists for: a list whose column layout is worth remembering
|
|
629
|
+
* and whose filters are not. Lore's Apps page had to give up persistence
|
|
630
|
+
* entirely to avoid opening narrowed by last week's search, because the
|
|
631
|
+
* three were one switch.
|
|
632
|
+
*
|
|
633
|
+
* Ignored without a `persistenceKey`, which stores nothing either way.
|
|
634
|
+
*/
|
|
635
|
+
persist?: AlephaTablePersistedFacets;
|
|
459
636
|
/**
|
|
460
637
|
* Hide the built-in column visibility dropdown in the toolbar.
|
|
461
638
|
*/
|
|
@@ -489,12 +666,52 @@ export interface AlephaTableBaseProps<T> {
|
|
|
489
666
|
*/
|
|
490
667
|
className?: string;
|
|
491
668
|
/**
|
|
492
|
-
*
|
|
669
|
+
* Title shown in both empty states, replacing their defaults.
|
|
670
|
+
*
|
|
671
|
+
* Kept as the one-line escape hatch it has always been, so it also
|
|
672
|
+
* suppresses the default description: a caller who wrote the whole message
|
|
673
|
+
* in here does not want "Nothing here yet." underneath it. For a title AND
|
|
674
|
+
* a description, or for wording that differs between the two states, use
|
|
675
|
+
* {@link emptyState} and {@link noMatchState}.
|
|
493
676
|
*/
|
|
494
677
|
emptyMessage?: string;
|
|
678
|
+
/**
|
|
679
|
+
* The empty state shown when the page came back empty and NO filter is set.
|
|
680
|
+
* Defaults to an inbox icon, "No items" and "Nothing here yet.".
|
|
681
|
+
*/
|
|
682
|
+
emptyState?: AlephaTableEmptyState;
|
|
683
|
+
/**
|
|
684
|
+
* The empty state shown when the page came back empty and at least one
|
|
685
|
+
* filter IS set. Defaults to a struck-through search icon, "No match" and
|
|
686
|
+
* "Try adjusting or clearing the filters.".
|
|
687
|
+
*
|
|
688
|
+
* Only reachable when `filters` is set: with no filter form there is
|
|
689
|
+
* nothing to be filtered by, so an empty page can only mean {@link
|
|
690
|
+
* emptyState}.
|
|
691
|
+
*/
|
|
692
|
+
noMatchState?: AlephaTableEmptyState;
|
|
495
693
|
/**
|
|
496
694
|
* Rich empty-state node rendered when the page is empty — e.g. an icon +
|
|
497
|
-
* message + optional call-to-action.
|
|
695
|
+
* message + optional call-to-action. Replaces the whole thing, both states
|
|
696
|
+
* included, so it outranks every prop above.
|
|
697
|
+
*
|
|
698
|
+
* ⚠️ **Only for a table with no {@link filters}.** Replacing both states
|
|
699
|
+
* with one node makes the table structurally incapable of telling them
|
|
700
|
+
* apart, whatever the node says: a filter that matched nothing renders the
|
|
701
|
+
* "there is nothing here" message, with the filter that produced it still
|
|
702
|
+
* sitting in the toolbar above. Lore's Apps page shipped exactly that and
|
|
703
|
+
* offered to create the first app to a reader who had just searched for
|
|
704
|
+
* one (feedback #P2160); its Releases page had the same defect, unreported
|
|
705
|
+
* only because nobody had filtered it to zero.
|
|
706
|
+
*
|
|
707
|
+
* With `filters` set, reach for {@link emptyState} and {@link noMatchState}
|
|
708
|
+
* instead. They take the same three pieces - `icon`, `title`,
|
|
709
|
+
* `description` - plus an `action` slot for the button, and the table keeps
|
|
710
|
+
* the choice between the two, which is the part a caller cannot get right
|
|
711
|
+
* from the outside.
|
|
712
|
+
*
|
|
713
|
+
* Not type-enforced: the combination is a live one downstream, so the rule
|
|
714
|
+
* is stated here rather than made uncompilable.
|
|
498
715
|
*/
|
|
499
716
|
empty?: ReactNode;
|
|
500
717
|
/**
|
|
@@ -623,21 +840,124 @@ const writePersisted = (key: string, suffix: string, value: unknown): void => {
|
|
|
623
840
|
*/
|
|
624
841
|
export const PAGE_SIZES = [10, 20, 50, 100];
|
|
625
842
|
|
|
843
|
+
/**
|
|
844
|
+
* The three persisted preferences, read for one `persistenceKey`.
|
|
845
|
+
*
|
|
846
|
+
* Factored out because they are read from TWO places now: once at mount, and
|
|
847
|
+
* again whenever the key changes under a mounted table. Inline in `useState`
|
|
848
|
+
* they could only be read once, and a second copy of each rule is how the
|
|
849
|
+
* scope-change path would come to disagree with the mount path about what a
|
|
850
|
+
* stored value means.
|
|
851
|
+
*/
|
|
852
|
+
const persistedSort = (
|
|
853
|
+
key: string | undefined,
|
|
854
|
+
fallback: SortState | null | undefined,
|
|
855
|
+
): SortState | null => {
|
|
856
|
+
const stored = key ? readPersisted<SortState>(key, "sort") : undefined;
|
|
857
|
+
return stored ?? fallback ?? null;
|
|
858
|
+
};
|
|
859
|
+
|
|
860
|
+
const persistedSize = (
|
|
861
|
+
key: string | undefined,
|
|
862
|
+
fallback: number | undefined,
|
|
863
|
+
): number => {
|
|
864
|
+
const stored = key ? readPersisted<number>(key, "size") : undefined;
|
|
865
|
+
return stored ?? fallback ?? 20;
|
|
866
|
+
};
|
|
867
|
+
|
|
868
|
+
const persistedColumns = <T,>(
|
|
869
|
+
key: string | undefined,
|
|
870
|
+
columns: Record<string, ColumnDef<T>>,
|
|
871
|
+
): Set<string> => {
|
|
872
|
+
const stored = key ? readPersisted<string[]>(key, "columns") : undefined;
|
|
873
|
+
if (stored) {
|
|
874
|
+
return new Set(stored.filter((k) => k in columns));
|
|
875
|
+
}
|
|
876
|
+
return new Set(
|
|
877
|
+
Object.keys(columns).filter((k) => !columns[k]!.defaultHidden),
|
|
878
|
+
);
|
|
879
|
+
};
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* The reader's column order, reconciled against what the table actually
|
|
883
|
+
* declares.
|
|
884
|
+
*
|
|
885
|
+
* Reconciliation is the whole of this function and the reason it is not just
|
|
886
|
+
* `readPersisted`. A stored array is a snapshot of the columns as they were
|
|
887
|
+
* when somebody last dragged one, and the code has moved since: a column
|
|
888
|
+
* added in a later release is missing from it, one removed is still in it.
|
|
889
|
+
* Trusting it verbatim would drop the new column from the table entirely and
|
|
890
|
+
* try to render a dead one.
|
|
891
|
+
*
|
|
892
|
+
* New keys go to the END rather than at their declared index. That is the
|
|
893
|
+
* rule with the least surprise: the reader's layout is left exactly as they
|
|
894
|
+
* arranged it, and the new column turns up somewhere predictable where the
|
|
895
|
+
* picker can find it. Splicing it in by declaration index would put it at a
|
|
896
|
+
* position matching neither the author's intent (the rest of the order is not
|
|
897
|
+
* the declared one any more) nor the reader's.
|
|
898
|
+
*/
|
|
899
|
+
const reconcileOrder = (
|
|
900
|
+
stored: string[] | undefined,
|
|
901
|
+
declared: string[],
|
|
902
|
+
): string[] => {
|
|
903
|
+
if (!stored) return declared;
|
|
904
|
+
const known = new Set(declared);
|
|
905
|
+
const kept = stored.filter((key) => known.has(key));
|
|
906
|
+
const seen = new Set(kept);
|
|
907
|
+
return [...kept, ...declared.filter((key) => !seen.has(key))];
|
|
908
|
+
};
|
|
909
|
+
|
|
910
|
+
const persistedOrder = <T,>(
|
|
911
|
+
key: string | undefined,
|
|
912
|
+
columns: Record<string, ColumnDef<T>>,
|
|
913
|
+
): string[] =>
|
|
914
|
+
reconcileOrder(
|
|
915
|
+
key ? readPersisted<string[]>(key, "columnOrder") : undefined,
|
|
916
|
+
Object.keys(columns),
|
|
917
|
+
);
|
|
918
|
+
|
|
626
919
|
export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
920
|
+
/**
|
|
921
|
+
* `persistenceKey`, once per facet.
|
|
922
|
+
*
|
|
923
|
+
* A facet that is off gets `undefined`, which is the same value every
|
|
924
|
+
* persistence helper here already treats as "do not store" - so turning one
|
|
925
|
+
* off takes the branch a table with no key has always taken, rather than a
|
|
926
|
+
* new one. That is what keeps the default behaviour of `persistenceKey`
|
|
927
|
+
* exactly as it was: with `persist` absent, all three of these ARE
|
|
928
|
+
* `props.persistenceKey`.
|
|
929
|
+
*
|
|
930
|
+
* Primitives, so they go straight into the dependency arrays and `useState`
|
|
931
|
+
* initializers below without giving any of them a new identity per render.
|
|
932
|
+
*/
|
|
933
|
+
const filtersKey =
|
|
934
|
+
props.persist?.filters === false ? undefined : props.persistenceKey;
|
|
935
|
+
const columnsKey =
|
|
936
|
+
props.persist?.columns === false ? undefined : props.persistenceKey;
|
|
937
|
+
const sortKey =
|
|
938
|
+
props.persist?.sort === false ? undefined : props.persistenceKey;
|
|
939
|
+
|
|
627
940
|
// State, not a constant. It was `props.defaultSize ?? 20` read once, so a
|
|
628
941
|
// reader had no way to see more rows than the call site had decided for
|
|
629
942
|
// them. Already in `load`'s dependency array, so changing it refetches.
|
|
630
|
-
const [size, setSize] = useState<number>(
|
|
631
|
-
()
|
|
632
|
-
(props.persistenceKey
|
|
633
|
-
? readPersisted<number>(props.persistenceKey, "size")
|
|
634
|
-
: undefined) ??
|
|
635
|
-
props.defaultSize ??
|
|
636
|
-
20,
|
|
943
|
+
const [size, setSize] = useState<number>(() =>
|
|
944
|
+
persistedSize(props.persistenceKey, props.defaultSize),
|
|
637
945
|
);
|
|
638
946
|
const pageSizes = props.pageSizes ?? PAGE_SIZES;
|
|
639
947
|
const alepha = useAlepha();
|
|
640
948
|
const { tr } = useI18n();
|
|
949
|
+
const toast = useToast();
|
|
950
|
+
/**
|
|
951
|
+
* The whole of the phone layout, and deliberately one switch rather than a
|
|
952
|
+
* scattering of `max-md:` classes: the filter controls have to be rendered
|
|
953
|
+
* in exactly ONE of the two places (see `AlephaTableFilterDialog`), which
|
|
954
|
+
* CSS cannot express. Everything else below the breakpoint follows the same
|
|
955
|
+
* flag so the two halves of the layout cannot disagree.
|
|
956
|
+
*
|
|
957
|
+
* Safe against hydration because the whole table sits inside `ClientOnly`,
|
|
958
|
+
* and `useIsMobile` reads the same `MediaQueryList` it subscribes to.
|
|
959
|
+
*/
|
|
960
|
+
const isMobile = useIsMobile();
|
|
641
961
|
|
|
642
962
|
// -- Filter form (internal when `filters` is set, else legacy `form`) -----
|
|
643
963
|
|
|
@@ -645,20 +965,49 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
645
965
|
// first invocation. Reading inside an effect would be too late —
|
|
646
966
|
// useForm captures `initialValues` only once via useMemo.
|
|
647
967
|
const persistedFilterValues = useMemo(() => {
|
|
648
|
-
if (!
|
|
968
|
+
if (!filtersKey || !props.filters) return undefined;
|
|
649
969
|
return reconcilePersistedFilters(
|
|
650
970
|
props.filters.schema,
|
|
651
|
-
readPersisted<Record<string, any>>(
|
|
971
|
+
readPersisted<Record<string, any>>(filtersKey, "filters"),
|
|
972
|
+
);
|
|
973
|
+
}, [filtersKey, props.filters]);
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* Filter values the URL carries, when the caller opted in with `fromQuery`.
|
|
977
|
+
*
|
|
978
|
+
* Read from the store rather than through `useRouterState`, on purpose:
|
|
979
|
+
* this is a one-shot read at mount, so the subscription would only buy a
|
|
980
|
+
* re-render of the whole table on navigations it must not react to anyway.
|
|
981
|
+
* A missing store (a table mounted with no router at all) reads as no
|
|
982
|
+
* query, not as a crash.
|
|
983
|
+
*/
|
|
984
|
+
const queryFilterValues = useMemo(() => {
|
|
985
|
+
const fromQuery = props.filters?.fromQuery;
|
|
986
|
+
if (!fromQuery || !props.filters) return undefined;
|
|
987
|
+
const query = (
|
|
988
|
+
alepha.store.get("alepha.react.router.state") as
|
|
989
|
+
| { query?: Record<string, any> }
|
|
990
|
+
| undefined
|
|
991
|
+
)?.query;
|
|
992
|
+
if (!query) return undefined;
|
|
993
|
+
return queryToFilters(
|
|
994
|
+
alepha,
|
|
995
|
+
props.filters.schema,
|
|
996
|
+
query,
|
|
997
|
+
Array.isArray(fromQuery) ? fromQuery : undefined,
|
|
652
998
|
);
|
|
653
|
-
}, [
|
|
999
|
+
}, []);
|
|
654
1000
|
|
|
655
1001
|
const mergedFilterInitialValues = useMemo<Record<string, any>>(
|
|
656
1002
|
() => ({
|
|
657
1003
|
...props.filters?.initialValues,
|
|
658
1004
|
...persistedFilterValues,
|
|
659
|
-
//
|
|
660
|
-
//
|
|
661
|
-
//
|
|
1005
|
+
// Above the stored choice — see `seedValues`. A drill-through link that
|
|
1006
|
+
// lost to a filter the reader set last week would be a link that does
|
|
1007
|
+
// nothing.
|
|
1008
|
+
...queryFilterValues,
|
|
1009
|
+
// Last: an explicit `seedValues` is the caller deciding for a case of
|
|
1010
|
+
// its own, and outranks what the URL happened to carry.
|
|
662
1011
|
...props.filters?.seedValues,
|
|
663
1012
|
}),
|
|
664
1013
|
[],
|
|
@@ -716,13 +1065,9 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
716
1065
|
onChange: (_key, next) => changeSize(next as number),
|
|
717
1066
|
});
|
|
718
1067
|
|
|
719
|
-
const [sort, setSort] = useState<SortState | null>(() =>
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
if (persisted) return persisted;
|
|
723
|
-
}
|
|
724
|
-
return props.defaultSort ?? null;
|
|
725
|
-
});
|
|
1068
|
+
const [sort, setSort] = useState<SortState | null>(() =>
|
|
1069
|
+
persistedSort(sortKey, props.defaultSort),
|
|
1070
|
+
);
|
|
726
1071
|
const [fetchedData, setData] = useState<T[]>([]);
|
|
727
1072
|
const [fetchedMeta, setMeta] = useState<Page<T>["page"] | null>(null);
|
|
728
1073
|
const [loading, setLoading] = useState(false);
|
|
@@ -843,9 +1188,9 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
843
1188
|
|
|
844
1189
|
// Persist sort to localStorage on every change.
|
|
845
1190
|
useEffect(() => {
|
|
846
|
-
if (!
|
|
847
|
-
writePersisted(
|
|
848
|
-
}, [
|
|
1191
|
+
if (!sortKey) return;
|
|
1192
|
+
writePersisted(sortKey, "sort", sort);
|
|
1193
|
+
}, [sortKey, sort]);
|
|
849
1194
|
|
|
850
1195
|
// -- Refresh + reset wiring -----------------------------------------------
|
|
851
1196
|
|
|
@@ -886,6 +1231,40 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
886
1231
|
}
|
|
887
1232
|
}, [form, props.filters]);
|
|
888
1233
|
|
|
1234
|
+
/**
|
|
1235
|
+
* Copy a link that opens this table with these filters.
|
|
1236
|
+
*
|
|
1237
|
+
* The write half of `fromQuery`, and the only one: nothing puts the
|
|
1238
|
+
* filters in the address bar as the reader types, so a link out of a
|
|
1239
|
+
* filtered table has to be asked for. Built on the page's own URL, so the
|
|
1240
|
+
* params the page owns travel with it.
|
|
1241
|
+
*/
|
|
1242
|
+
/**
|
|
1243
|
+
* Whether a link out of this table would do anything on arrival.
|
|
1244
|
+
*
|
|
1245
|
+
* A table that does not read the query back would copy a URL whose params
|
|
1246
|
+
* are inert, which is worse than no Share at all: it looks like it worked.
|
|
1247
|
+
*/
|
|
1248
|
+
const canShare = Boolean(props.filters?.fromQuery);
|
|
1249
|
+
|
|
1250
|
+
const shareFilters = useCallback(async () => {
|
|
1251
|
+
if (!props.filters || !form) return;
|
|
1252
|
+
const url = shareFiltersUrl(
|
|
1253
|
+
window.location.href,
|
|
1254
|
+
Object.keys(z.schema.shape(props.filters.schema)),
|
|
1255
|
+
cleanFilterValues(form.currentValues ?? {}),
|
|
1256
|
+
);
|
|
1257
|
+
try {
|
|
1258
|
+
await navigator.clipboard.writeText(url);
|
|
1259
|
+
toast.success(
|
|
1260
|
+
tr("alephaTable.shareFiltersCopied", { default: "Link copied" }),
|
|
1261
|
+
);
|
|
1262
|
+
} catch {
|
|
1263
|
+
// A denied clipboard permission, or an insecure origin. Nothing here
|
|
1264
|
+
// is worth an error toast the reader cannot act on.
|
|
1265
|
+
}
|
|
1266
|
+
}, [form, props.filters, toast, tr]);
|
|
1267
|
+
|
|
889
1268
|
// -- Form event subscriptions ---------------------------------------------
|
|
890
1269
|
|
|
891
1270
|
// Refetch on explicit submit (manual Apply, programmatic submit, etc.).
|
|
@@ -920,31 +1299,28 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
920
1299
|
|
|
921
1300
|
// Persist filter values to localStorage on change.
|
|
922
1301
|
useEffect(() => {
|
|
923
|
-
if (!
|
|
924
|
-
const
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
clean[k] = v;
|
|
931
|
-
}
|
|
932
|
-
writePersisted(props.persistenceKey!, "filters", clean);
|
|
1302
|
+
if (!filtersKey || !form || !props.filters) return;
|
|
1303
|
+
const writeFilters = () => {
|
|
1304
|
+
writePersisted(
|
|
1305
|
+
filtersKey,
|
|
1306
|
+
"filters",
|
|
1307
|
+
cleanFilterValues(form.currentValues ?? {}),
|
|
1308
|
+
);
|
|
933
1309
|
};
|
|
934
1310
|
const unsubs = [
|
|
935
1311
|
alepha.events.on("form:change", (event) => {
|
|
936
1312
|
if (event.id !== form.id) return;
|
|
937
|
-
|
|
1313
|
+
writeFilters();
|
|
938
1314
|
}),
|
|
939
1315
|
alepha.events.on("form:submit:success", (event) => {
|
|
940
1316
|
if (event.id !== form.id) return;
|
|
941
|
-
|
|
1317
|
+
writeFilters();
|
|
942
1318
|
}),
|
|
943
1319
|
];
|
|
944
1320
|
return () => {
|
|
945
1321
|
for (const u of unsubs) u();
|
|
946
1322
|
};
|
|
947
|
-
}, [alepha, form, props.filters,
|
|
1323
|
+
}, [alepha, form, props.filters, filtersKey]);
|
|
948
1324
|
|
|
949
1325
|
// -- Polling ---------------------------------------------------------------
|
|
950
1326
|
|
|
@@ -1038,6 +1414,24 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1038
1414
|
});
|
|
1039
1415
|
};
|
|
1040
1416
|
|
|
1417
|
+
/**
|
|
1418
|
+
* Sort in a named direction, or clear it.
|
|
1419
|
+
*
|
|
1420
|
+
* The header cycles; the menu states. Both write the same state, so a
|
|
1421
|
+
* column sorted from the menu shows the header's own arrow.
|
|
1422
|
+
*/
|
|
1423
|
+
const setSortTo = (
|
|
1424
|
+
col: string,
|
|
1425
|
+
def: ColumnDef<T>,
|
|
1426
|
+
direction: "asc" | "desc" | null,
|
|
1427
|
+
) => {
|
|
1428
|
+
if (!def.sortable) return;
|
|
1429
|
+
const field = def.sortKey ?? col;
|
|
1430
|
+
const next: SortState | null = direction ? { field, direction } : null;
|
|
1431
|
+
setSort(next);
|
|
1432
|
+
props.onSortChange?.(next);
|
|
1433
|
+
};
|
|
1434
|
+
|
|
1041
1435
|
// -- Column visibility -----------------------------------------------------
|
|
1042
1436
|
|
|
1043
1437
|
const allColumnKeys = useMemo(
|
|
@@ -1045,38 +1439,162 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1045
1439
|
[props.columns],
|
|
1046
1440
|
);
|
|
1047
1441
|
|
|
1048
|
-
const [visibleColumns, setVisibleColumns] = useState<Set<string>>(() =>
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1442
|
+
const [visibleColumns, setVisibleColumns] = useState<Set<string>>(() =>
|
|
1443
|
+
persistedColumns(columnsKey, props.columns),
|
|
1444
|
+
);
|
|
1445
|
+
|
|
1446
|
+
/**
|
|
1447
|
+
* The reader's column order. Held as the raw preference and reconciled on
|
|
1448
|
+
* every read below, so a caller adding a column at runtime is handled by
|
|
1449
|
+
* the same code path as a stale stored array.
|
|
1450
|
+
*/
|
|
1451
|
+
const [columnOrder, setColumnOrder] = useState<string[]>(() =>
|
|
1452
|
+
persistedOrder(columnsKey, props.columns),
|
|
1453
|
+
);
|
|
1454
|
+
|
|
1455
|
+
const orderedKeys = useMemo(
|
|
1456
|
+
() => reconcileOrder(columnOrder, allColumnKeys),
|
|
1457
|
+
[columnOrder, allColumnKeys],
|
|
1458
|
+
);
|
|
1459
|
+
|
|
1460
|
+
/**
|
|
1461
|
+
* Move one column one slot, within the VISIBLE sequence.
|
|
1462
|
+
*
|
|
1463
|
+
* Over the visible columns and not the full order, because nudging a column
|
|
1464
|
+
* past a hidden one would look like nothing happened - the reader would
|
|
1465
|
+
* press "move left" and see the table unchanged. A swap rather than a
|
|
1466
|
+
* splice, so the hidden columns between the two keep their places.
|
|
1467
|
+
*/
|
|
1468
|
+
const moveColumn = (key: string, delta: -1 | 1) => {
|
|
1469
|
+
const visible = orderedKeys.filter((k) => visibleColumns.has(k));
|
|
1470
|
+
const at = visible.indexOf(key);
|
|
1471
|
+
const target = visible[at + delta];
|
|
1472
|
+
if (at < 0 || target === undefined) return;
|
|
1473
|
+
const next = [...orderedKeys];
|
|
1474
|
+
const from = next.indexOf(key);
|
|
1475
|
+
const to = next.indexOf(target);
|
|
1476
|
+
next[from] = target;
|
|
1477
|
+
next[to] = key;
|
|
1478
|
+
commitOrder(next);
|
|
1479
|
+
// Announced, or the change is silent for a screen reader: nothing else
|
|
1480
|
+
// about a reordered table is spoken.
|
|
1481
|
+
setOrderAnnouncement(
|
|
1482
|
+
String(
|
|
1483
|
+
tr("alephaTable.columnMoved", {
|
|
1484
|
+
default: `${String(props.columns[key]?.label ?? key)} moved to position ${at + delta + 1} of ${visible.length}`,
|
|
1485
|
+
args: [
|
|
1486
|
+
String(props.columns[key]?.label ?? key),
|
|
1487
|
+
String(at + delta + 1),
|
|
1488
|
+
String(visible.length),
|
|
1489
|
+
],
|
|
1490
|
+
}),
|
|
1491
|
+
),
|
|
1060
1492
|
);
|
|
1061
|
-
}
|
|
1493
|
+
};
|
|
1062
1494
|
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1495
|
+
/**
|
|
1496
|
+
* Drop `key` onto `target`'s slot, which is what a drag in the column
|
|
1497
|
+
* picker means. Unlike {@link moveColumn} this walks the FULL order: the
|
|
1498
|
+
* picker lists hidden columns too, so a drag there can legitimately cross
|
|
1499
|
+
* one.
|
|
1500
|
+
*/
|
|
1501
|
+
const reorderColumn = (key: string, target: string) => {
|
|
1502
|
+
if (key === target) return;
|
|
1503
|
+
const next = orderedKeys.filter((k) => k !== key);
|
|
1504
|
+
next.splice(next.indexOf(target), 0, key);
|
|
1505
|
+
commitOrder(next);
|
|
1506
|
+
};
|
|
1507
|
+
|
|
1508
|
+
const commitOrder = (next: string[]) => {
|
|
1509
|
+
setColumnOrder(next);
|
|
1510
|
+
if (columnsKey) {
|
|
1511
|
+
writePersisted(columnsKey, "columnOrder", next);
|
|
1512
|
+
}
|
|
1513
|
+
};
|
|
1514
|
+
|
|
1515
|
+
/**
|
|
1516
|
+
* What the live region says after a move. Cleared and re-set on each one,
|
|
1517
|
+
* so two moves in a row are both announced.
|
|
1518
|
+
*/
|
|
1519
|
+
const [orderAnnouncement, setOrderAnnouncement] = useState("");
|
|
1520
|
+
|
|
1521
|
+
/**
|
|
1522
|
+
* ⚠️ A changed `persistenceKey` is a changed SCOPE, and this is where that
|
|
1523
|
+
* is handled.
|
|
1524
|
+
*
|
|
1525
|
+
* Every caller encodes its scope in that key - `lor.activity.${project.id}`,
|
|
1526
|
+
* `lor.epics.${project.id}` - so switching project changes it. Nothing acted
|
|
1527
|
+
* on that before, and `load` re-runs only on `[page, size, sortParam,
|
|
1528
|
+
* refreshKey, form, alepha]`, none of which a project switch touches. The
|
|
1529
|
+
* router does not remount on a param-only navigation either, so the table
|
|
1530
|
+
* kept serving the PREVIOUS project's rows under the new project's name
|
|
1531
|
+
* (feedback #2096).
|
|
1532
|
+
*
|
|
1533
|
+
* `refreshKey` is bumped rather than relying on the re-read: two projects
|
|
1534
|
+
* can share a stored sort and size, and then no dependency of `load` would
|
|
1535
|
+
* change and nothing would refetch. That equality is the bug's whole
|
|
1536
|
+
* mechanism, so the refetch cannot be a side effect of the values moving.
|
|
1537
|
+
*
|
|
1538
|
+
* ⚠️ Adjusted during RENDER, not in an effect, and that is load-bearing.
|
|
1539
|
+
* The sort and columns effects below are keyed on `persistenceKey` too, so
|
|
1540
|
+
* on the render where it changes they would fire in the same flush and
|
|
1541
|
+
* write the OUTGOING scope's state under the INCOMING key - silently
|
|
1542
|
+
* overwriting the project you just opened with the one you just left. React
|
|
1543
|
+
* re-renders before committing this, so by the time those effects run the
|
|
1544
|
+
* state is already the new scope's and they write back what was just read.
|
|
1545
|
+
*
|
|
1546
|
+
* ⚠️ `props.fetch` is still NOT a dependency of `load`. That is the loop
|
|
1547
|
+
* `fetchRef` exists to prevent, and several callers write a store atom from
|
|
1548
|
+
* inside their fetcher.
|
|
1549
|
+
*
|
|
1550
|
+
* Filter VALUES are deliberately not reset here: `useForm` captures its
|
|
1551
|
+
* `initialValues` once, so resetting them is form surgery rather than a
|
|
1552
|
+
* state assignment. They are also not clobbered - the filter-persist effect
|
|
1553
|
+
* writes only on `form:change` / `form:submit:success`, never on mount - so
|
|
1554
|
+
* the stored filters of the project you left stay its own.
|
|
1555
|
+
*/
|
|
1556
|
+
const scopeRef = useRef(props.persistenceKey);
|
|
1557
|
+
if (scopeRef.current !== props.persistenceKey) {
|
|
1558
|
+
scopeRef.current = props.persistenceKey;
|
|
1559
|
+
setPage(0);
|
|
1560
|
+
setSize(persistedSize(props.persistenceKey, props.defaultSize));
|
|
1561
|
+
setSort(persistedSort(sortKey, props.defaultSort));
|
|
1562
|
+
setVisibleColumns(persistedColumns(columnsKey, props.columns));
|
|
1563
|
+
// Same render pass as the rest, and for the identical reason: the effects
|
|
1564
|
+
// keyed on `persistenceKey` fire in one flush, so an order left behind
|
|
1565
|
+
// here would be written back under the INCOMING key.
|
|
1566
|
+
setColumnOrder(persistedOrder(columnsKey, props.columns));
|
|
1567
|
+
setRefreshKey((k) => k + 1);
|
|
1568
|
+
}
|
|
1067
1569
|
|
|
1570
|
+
/**
|
|
1571
|
+
* Written on a TOGGLE, never on mount - the same rule the filter-persist
|
|
1572
|
+
* effect follows above, and for the same reason.
|
|
1573
|
+
*
|
|
1574
|
+
* As a mount effect this stamped the current set into storage on first
|
|
1575
|
+
* paint, which froze the column layout of every reader who had merely
|
|
1576
|
+
* OPENED the table. A `defaultHidden` added to a column afterwards then did
|
|
1577
|
+
* nothing for them, permanently and with no way to notice: the stored set
|
|
1578
|
+
* had no `defaultHidden` in it to be out of date. It also made
|
|
1579
|
+
* `defaultHidden` unusable as a controlled prop, since a remount read back
|
|
1580
|
+
* what the previous mount had written rather than the new default.
|
|
1581
|
+
*/
|
|
1068
1582
|
const toggleColumn = (id: string) => {
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1583
|
+
const next = new Set(visibleColumns);
|
|
1584
|
+
if (next.has(id)) next.delete(id);
|
|
1585
|
+
else next.add(id);
|
|
1586
|
+
setVisibleColumns(next);
|
|
1587
|
+
if (columnsKey) {
|
|
1588
|
+
writePersisted(columnsKey, "columns", [...next]);
|
|
1589
|
+
}
|
|
1075
1590
|
};
|
|
1076
1591
|
|
|
1077
1592
|
// -- Render ---------------------------------------------------------------
|
|
1078
1593
|
|
|
1079
|
-
|
|
1594
|
+
// The reader's order, not the declaration's.
|
|
1595
|
+
const cols = orderedKeys.map((key) => [key, props.columns[key]!]) as Array<
|
|
1596
|
+
[string, ColumnDef<T>]
|
|
1597
|
+
>;
|
|
1080
1598
|
const visibleCols = cols.filter(([key]) => visibleColumns.has(key));
|
|
1081
1599
|
const hasCheckbox = Boolean(props.bulkActions?.length);
|
|
1082
1600
|
const hasRowActions = Boolean(props.rowActions);
|
|
@@ -1087,16 +1605,55 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1087
1605
|
[refresh, clearSelection],
|
|
1088
1606
|
);
|
|
1089
1607
|
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
return
|
|
1608
|
+
/**
|
|
1609
|
+
* How many filters currently narrow the list — a count rather than the
|
|
1610
|
+
* boolean this used to be, because on a phone the bar is behind a button
|
|
1611
|
+
* and the trigger's badge is the only thing that says the table is
|
|
1612
|
+
* filtered at all.
|
|
1613
|
+
*/
|
|
1614
|
+
const activeFilterCount = useMemo(() => {
|
|
1615
|
+
if (!props.filters || !form) return 0;
|
|
1616
|
+
return Object.keys(cleanFilterValues(form.currentValues ?? {})).length;
|
|
1099
1617
|
}, [props.filters, form, refreshKey]);
|
|
1618
|
+
const hasActiveFilters = activeFilterCount > 0;
|
|
1619
|
+
|
|
1620
|
+
// Which empty state applies, resolved here rather than in the JSX because
|
|
1621
|
+
// the answer is one boolean and the branch is four values deep.
|
|
1622
|
+
//
|
|
1623
|
+
// `hasActiveFilters` is already false whenever `props.filters` is unset, so
|
|
1624
|
+
// a table with no filter form can only ever reach the "no items" side.
|
|
1625
|
+
const emptyOverride =
|
|
1626
|
+
(hasActiveFilters ? props.noMatchState : props.emptyState) ?? {};
|
|
1627
|
+
const EmptyIcon = emptyOverride.icon ?? (hasActiveFilters ? SearchX : Inbox);
|
|
1628
|
+
const emptyTitle =
|
|
1629
|
+
emptyOverride.title ??
|
|
1630
|
+
props.emptyMessage ??
|
|
1631
|
+
String(
|
|
1632
|
+
hasActiveFilters
|
|
1633
|
+
? tr("alephaTable.noMatchTitle", { default: "No match" })
|
|
1634
|
+
: tr("alephaTable.emptyTitle", { default: "No items" }),
|
|
1635
|
+
);
|
|
1636
|
+
// Suppressed by a bare `emptyMessage`: that prop is the whole message, and
|
|
1637
|
+
// pairing someone's "No artifacts yet" with a stock second line reads as a
|
|
1638
|
+
// component talking over its caller.
|
|
1639
|
+
// The empty state is showing, as opposed to the skeleton that also renders
|
|
1640
|
+
// on `data.length === 0`. Read by the `<Table>` height as well as the body,
|
|
1641
|
+
// so the two cannot disagree.
|
|
1642
|
+
const isEmptyState = !loading && data.length === 0;
|
|
1643
|
+
const emptyAction = emptyOverride.action;
|
|
1644
|
+
const emptyDescription =
|
|
1645
|
+
emptyOverride.description ??
|
|
1646
|
+
(props.emptyMessage
|
|
1647
|
+
? undefined
|
|
1648
|
+
: String(
|
|
1649
|
+
hasActiveFilters
|
|
1650
|
+
? tr("alephaTable.noMatchDescription", {
|
|
1651
|
+
default: "Try adjusting or clearing the filters.",
|
|
1652
|
+
})
|
|
1653
|
+
: tr("alephaTable.emptyDescription", {
|
|
1654
|
+
default: "Nothing here yet.",
|
|
1655
|
+
}),
|
|
1656
|
+
));
|
|
1100
1657
|
|
|
1101
1658
|
const showToolbar =
|
|
1102
1659
|
Boolean(props.filters) ||
|
|
@@ -1138,8 +1695,12 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1138
1695
|
// WHITE wash that leaves the field lighter than the bar. Only the
|
|
1139
1696
|
// dark-scoped rule (0,3,0) outranks it, and without it the two
|
|
1140
1697
|
// controls disagreed: the trigger went dark, the input stayed light.
|
|
1141
|
-
|
|
1142
|
-
|
|
1698
|
+
// The `--bevel` line, laid just inside the bar's own top border,
|
|
1699
|
+
// the same fold the header and the footer carry. This one is the
|
|
1700
|
+
// top edge of the whole table block, so it is the one that decides
|
|
1701
|
+
// whether the block sits ON the page or IN it.
|
|
1702
|
+
<div className="bg-muted [&_:is(input,[role=combobox])]:bg-background dark:[&_:is(input,[role=combobox])]:bg-background flex flex-wrap items-end gap-2 rounded-md rounded-b-none border p-2 shadow-[inset_0_1px_0_0_var(--bevel)]">
|
|
1703
|
+
{props.filters && form && !isMobile ? (
|
|
1143
1704
|
<form
|
|
1144
1705
|
{...form.props}
|
|
1145
1706
|
className="flex flex-1 flex-wrap items-end gap-2"
|
|
@@ -1224,14 +1785,44 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1224
1785
|
)}
|
|
1225
1786
|
</>
|
|
1226
1787
|
) : null}
|
|
1788
|
+
{isMobile && props.filters && form && (
|
|
1789
|
+
<AlephaTableFilterDialog
|
|
1790
|
+
form={form}
|
|
1791
|
+
activeCount={activeFilterCount}
|
|
1792
|
+
onReset={resetFilters}
|
|
1793
|
+
onShare={canShare ? shareFilters : undefined}
|
|
1794
|
+
>
|
|
1795
|
+
{props.filters.render(form)}
|
|
1796
|
+
</AlephaTableFilterDialog>
|
|
1797
|
+
)}
|
|
1227
1798
|
{showColumnPicker && (
|
|
1228
1799
|
<ColumnPicker<T>
|
|
1229
1800
|
columns={props.columns}
|
|
1801
|
+
order={orderedKeys}
|
|
1230
1802
|
visible={visibleColumns}
|
|
1231
1803
|
onToggle={toggleColumn}
|
|
1804
|
+
onReorder={reorderColumn}
|
|
1805
|
+
/>
|
|
1806
|
+
)}
|
|
1807
|
+
{/*
|
|
1808
|
+
Desktop only. On a phone the same two actions live in the
|
|
1809
|
+
filter dialog, beside the controls they act on, and a second
|
|
1810
|
+
copy out here would spend a slot of the very row that dialog
|
|
1811
|
+
exists to shorten.
|
|
1812
|
+
*/}
|
|
1813
|
+
{showActionsMenu && props.filters && !isMobile && canShare && (
|
|
1814
|
+
<AlephaTableFilterMenu
|
|
1815
|
+
activeCount={activeFilterCount}
|
|
1816
|
+
onShare={shareFilters}
|
|
1817
|
+
onReset={resetFilters}
|
|
1232
1818
|
/>
|
|
1233
1819
|
)}
|
|
1234
|
-
{
|
|
1820
|
+
{/*
|
|
1821
|
+
Not linkable: no Share, so no menu either. A menu of one
|
|
1822
|
+
item would cost a click to reach the button that is already
|
|
1823
|
+
here.
|
|
1824
|
+
*/}
|
|
1825
|
+
{showActionsMenu && props.filters && !isMobile && !canShare && (
|
|
1235
1826
|
<Tooltip>
|
|
1236
1827
|
<TooltipTrigger
|
|
1237
1828
|
render={
|
|
@@ -1361,14 +1952,46 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1361
1952
|
"flex min-h-0 flex-1 flex-col overflow-auto rounded-md border",
|
|
1362
1953
|
showToolbar && "-mt-2 rounded-t-none border-t-0",
|
|
1363
1954
|
"rounded-b-none border-b-0",
|
|
1955
|
+
// shadcn's `<Table>` wraps the table in a container div whose
|
|
1956
|
+
// classes it hardcodes, and `scripts/sync.ts` overwrites that file
|
|
1957
|
+
// wholesale - so the one class it needs is set from out here
|
|
1958
|
+
// instead, where sync cannot reach.
|
|
1959
|
+
//
|
|
1960
|
+
// `grow`, NOT `flex-1`: `flex-1` sets the basis to 0, and in the
|
|
1961
|
+
// ordinary case this wrapper has no height of its own, so a 0
|
|
1962
|
+
// basis with nothing to grow into collapses the table to nothing.
|
|
1963
|
+
// `grow` keeps the content basis and only spends space that is
|
|
1964
|
+
// actually free, which is the full-height case.
|
|
1965
|
+
"[&>[data-slot=table-container]]:grow",
|
|
1364
1966
|
)}
|
|
1365
1967
|
>
|
|
1366
|
-
|
|
1968
|
+
{/* `h-full` ONLY while the empty state is what is in the body.
|
|
1969
|
+
It is what lets that one row take the height the scroller grew
|
|
1970
|
+
into, so `align-middle` can centre the state in it.
|
|
1971
|
+
|
|
1972
|
+
⚠️ Never unconditionally. A CSS table given a height larger
|
|
1973
|
+
than its content does not leave the surplus at the bottom, it
|
|
1974
|
+
DISTRIBUTES IT ACROSS THE ROWS - so an unconditional `h-full`
|
|
1975
|
+
silently turns a short table into a tall one: Lore's Apps page,
|
|
1976
|
+
two rows in a full-height pane, rendered them 239px each. No
|
|
1977
|
+
unit test sees it (jsdom computes no layout) and it is invisible
|
|
1978
|
+
on a table long enough to fill its own container, which is why
|
|
1979
|
+
it reached e2e rather than review. */}
|
|
1980
|
+
<Table className={cn(isEmptyState && "h-full")}>
|
|
1367
1981
|
{/* `bg-muted`, fully opaque, NOT the base header's `bg-muted/50`:
|
|
1368
1982
|
this header is sticky, so anything translucent lets the rows
|
|
1369
1983
|
scroll visibly through the column labels. Same tint, no
|
|
1370
|
-
transparency.
|
|
1371
|
-
|
|
1984
|
+
transparency.
|
|
1985
|
+
|
|
1986
|
+
Two inset lines, not one. The bottom is the divider against the
|
|
1987
|
+
first row; the top is the `--bevel` highlight, which is what
|
|
1988
|
+
gives the band its thickness. Inset shadows rather than borders
|
|
1989
|
+
because a border on a sticky `<thead>` is dropped by the
|
|
1990
|
+
collapsed table border model, and because the two lines have to
|
|
1991
|
+
sit INSIDE the header's own height: it is pinned at `top-0`
|
|
1992
|
+
against a scrolling body, so anything painted outside it is
|
|
1993
|
+
painted over. */}
|
|
1994
|
+
<TableHeader className="bg-muted sticky top-0 z-10 shadow-[inset_0_1px_0_0_var(--bevel),inset_0_-1px_0_0_var(--border)]">
|
|
1372
1995
|
<TableRow>
|
|
1373
1996
|
{hasCheckbox && (
|
|
1374
1997
|
<TableHead className="w-10">
|
|
@@ -1382,35 +2005,50 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1382
2005
|
/>
|
|
1383
2006
|
</TableHead>
|
|
1384
2007
|
)}
|
|
1385
|
-
{visibleCols.map(([key, def]) => {
|
|
2008
|
+
{visibleCols.map(([key, def], index) => {
|
|
1386
2009
|
const sorted =
|
|
1387
2010
|
def.sortable && sort?.field === (def.sortKey ?? key);
|
|
1388
2011
|
return (
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
2012
|
+
// ⚠️ The menu is on the HEADER and never on a body cell.
|
|
2013
|
+
// Overriding the browser's own menu is acceptable on
|
|
2014
|
+
// chrome; on a data cell it breaks copy, and people copy
|
|
2015
|
+
// cell values constantly.
|
|
2016
|
+
<ContextMenu key={key}>
|
|
2017
|
+
<ContextMenuTrigger
|
|
2018
|
+
render={
|
|
2019
|
+
<TableHead
|
|
2020
|
+
// Focusable so Shift+F10 reaches the menu.
|
|
2021
|
+
// Without it the menu is mouse-only, and
|
|
2022
|
+
// right-click is already invisible and absent on
|
|
2023
|
+
// touch - which is exactly why the column picker
|
|
2024
|
+
// and not this is the primary path.
|
|
2025
|
+
tabIndex={0}
|
|
2026
|
+
className={cn(
|
|
2027
|
+
def.className,
|
|
2028
|
+
"focus-visible:ring-ring/50 outline-none focus-visible:ring-2",
|
|
2029
|
+
def.align === "right" && "text-right",
|
|
2030
|
+
def.align === "center" && "text-center",
|
|
2031
|
+
)}
|
|
2032
|
+
aria-sort={
|
|
2033
|
+
sorted
|
|
2034
|
+
? sort?.direction === "asc"
|
|
2035
|
+
? "ascending"
|
|
2036
|
+
: "descending"
|
|
2037
|
+
: undefined
|
|
2038
|
+
}
|
|
2039
|
+
/>
|
|
2040
|
+
}
|
|
2041
|
+
>
|
|
2042
|
+
{def.sortable ? (
|
|
2043
|
+
// A real button so keyboard and assistive-tech
|
|
2044
|
+
// users can sort — a th onClick is mouse-only.
|
|
2045
|
+
<button
|
|
2046
|
+
type="button"
|
|
2047
|
+
onClick={() => toggleSort(key, def)}
|
|
2048
|
+
className="group/sort hover:text-foreground inline-flex items-center gap-1 select-none"
|
|
2049
|
+
>
|
|
2050
|
+
{def.label}
|
|
2051
|
+
{/* A sortable column says so at rest. The arrow
|
|
1414
2052
|
used to appear only once a column WAS sorted,
|
|
1415
2053
|
so an unsorted sortable header and a dead one
|
|
1416
2054
|
were indistinguishable until you happened to
|
|
@@ -1425,25 +2063,96 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1425
2063
|
|
|
1426
2064
|
`aria-hidden` throughout: `aria-sort` on the
|
|
1427
2065
|
`th` already states this to assistive tech. */}
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
2066
|
+
{sorted ? (
|
|
2067
|
+
sort?.direction === "asc" ? (
|
|
2068
|
+
<ArrowUp className="size-3.5" aria-hidden />
|
|
2069
|
+
) : (
|
|
2070
|
+
<ArrowDown className="size-3.5" aria-hidden />
|
|
2071
|
+
)
|
|
1431
2072
|
) : (
|
|
1432
|
-
<
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
2073
|
+
<ChevronsUpDown
|
|
2074
|
+
className="size-3.5 opacity-40 transition-opacity group-hover/sort:opacity-100"
|
|
2075
|
+
aria-hidden
|
|
2076
|
+
/>
|
|
2077
|
+
)}
|
|
2078
|
+
</button>
|
|
2079
|
+
) : (
|
|
2080
|
+
<span className="inline-flex items-center gap-1">
|
|
2081
|
+
{def.label}
|
|
2082
|
+
</span>
|
|
2083
|
+
)}
|
|
2084
|
+
</ContextMenuTrigger>
|
|
2085
|
+
<ContextMenuContent>
|
|
2086
|
+
{/* Explicit directions rather than the header's
|
|
2087
|
+
click-cycling, which is the one item here that
|
|
2088
|
+
beats the affordance it duplicates: cycling makes
|
|
2089
|
+
you guess which of three states you are in.
|
|
2090
|
+
Hidden entirely on a column that cannot sort,
|
|
2091
|
+
rather than shown disabled - a permanently dead
|
|
2092
|
+
entry on half the columns is noise. */}
|
|
2093
|
+
{def.sortable && (
|
|
2094
|
+
<>
|
|
2095
|
+
<ContextMenuItem
|
|
2096
|
+
onClick={() => setSortTo(key, def, "asc")}
|
|
2097
|
+
>
|
|
2098
|
+
<ArrowUpAZ className="size-4" />
|
|
2099
|
+
{tr("alephaTable.sortAsc", {
|
|
2100
|
+
default: "Sort ascending",
|
|
2101
|
+
})}
|
|
2102
|
+
</ContextMenuItem>
|
|
2103
|
+
<ContextMenuItem
|
|
2104
|
+
onClick={() => setSortTo(key, def, "desc")}
|
|
2105
|
+
>
|
|
2106
|
+
<ArrowDownAZ className="size-4" />
|
|
2107
|
+
{tr("alephaTable.sortDesc", {
|
|
2108
|
+
default: "Sort descending",
|
|
2109
|
+
})}
|
|
2110
|
+
</ContextMenuItem>
|
|
2111
|
+
<ContextMenuItem
|
|
2112
|
+
disabled={!sorted}
|
|
2113
|
+
onClick={() => setSortTo(key, def, null)}
|
|
2114
|
+
>
|
|
2115
|
+
{tr("alephaTable.sortClear", {
|
|
2116
|
+
default: "Clear sort",
|
|
2117
|
+
})}
|
|
2118
|
+
</ContextMenuItem>
|
|
2119
|
+
<ContextMenuSeparator />
|
|
2120
|
+
</>
|
|
2121
|
+
)}
|
|
2122
|
+
{/* Disabled at the ends rather than hidden: the pair
|
|
2123
|
+
is a fixed landmark, and an entry that appears
|
|
2124
|
+
and disappears as you move a column is harder to
|
|
2125
|
+
aim at than one that greys out. */}
|
|
2126
|
+
<ContextMenuItem
|
|
2127
|
+
disabled={index === 0}
|
|
2128
|
+
onClick={() => moveColumn(key, -1)}
|
|
2129
|
+
>
|
|
2130
|
+
<ChevronLeft className="size-4" />
|
|
2131
|
+
{tr("alephaTable.moveLeft", { default: "Move left" })}
|
|
2132
|
+
</ContextMenuItem>
|
|
2133
|
+
<ContextMenuItem
|
|
2134
|
+
disabled={index === visibleCols.length - 1}
|
|
2135
|
+
onClick={() => moveColumn(key, 1)}
|
|
2136
|
+
>
|
|
2137
|
+
<ChevronRight className="size-4" />
|
|
2138
|
+
{tr("alephaTable.moveRight", {
|
|
2139
|
+
default: "Move right",
|
|
2140
|
+
})}
|
|
2141
|
+
</ContextMenuItem>
|
|
2142
|
+
<ContextMenuSeparator />
|
|
2143
|
+
{/* Never the last one: a table with no columns has
|
|
2144
|
+
no way back to this menu. */}
|
|
2145
|
+
<ContextMenuItem
|
|
2146
|
+
disabled={visibleCols.length <= 1}
|
|
2147
|
+
onClick={() => toggleColumn(key)}
|
|
2148
|
+
>
|
|
2149
|
+
<EyeOff className="size-4" />
|
|
2150
|
+
{tr("alephaTable.hideColumn", {
|
|
2151
|
+
default: "Hide column",
|
|
2152
|
+
})}
|
|
2153
|
+
</ContextMenuItem>
|
|
2154
|
+
</ContextMenuContent>
|
|
2155
|
+
</ContextMenu>
|
|
1447
2156
|
);
|
|
1448
2157
|
})}
|
|
1449
2158
|
{hasRowActions && <TableHead className="w-10" />}
|
|
@@ -1467,19 +2176,37 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1467
2176
|
(hasCheckbox ? 1 : 0) +
|
|
1468
2177
|
(hasRowActions ? 1 : 0)
|
|
1469
2178
|
}
|
|
1470
|
-
|
|
2179
|
+
// `h-full` and the cell's inherited `align-middle` are
|
|
2180
|
+
// what centre the state vertically. The chain is three
|
|
2181
|
+
// links long and every one is load-bearing: the scroller
|
|
2182
|
+
// above grows to the container, the `<table>` takes its
|
|
2183
|
+
// height, and this - the only body row - takes what the
|
|
2184
|
+
// header leaves. Break any of them and the state sits
|
|
2185
|
+
// tucked under the header instead of in the middle.
|
|
2186
|
+
//
|
|
2187
|
+
// `whitespace-normal` undoes the `whitespace-nowrap` every
|
|
2188
|
+
// cell carries, which is right for a data cell and wrong
|
|
2189
|
+
// for a sentence: the description would run off the side
|
|
2190
|
+
// and widen the table's own horizontal scroller.
|
|
2191
|
+
className="h-full p-0 whitespace-normal"
|
|
1471
2192
|
>
|
|
1472
2193
|
{props.empty ?? (
|
|
1473
|
-
<div className="
|
|
1474
|
-
<
|
|
1475
|
-
<p className="text-sm">
|
|
1476
|
-
{
|
|
1477
|
-
String(
|
|
1478
|
-
tr("alephaTable.empty", {
|
|
1479
|
-
default: "No results.",
|
|
1480
|
-
}),
|
|
1481
|
-
)}
|
|
2194
|
+
<div className="flex flex-col items-center justify-center gap-2 px-6 py-12 text-center">
|
|
2195
|
+
<EmptyIcon className="text-muted-foreground size-8 opacity-40" />
|
|
2196
|
+
<p className="text-foreground text-sm font-medium">
|
|
2197
|
+
{emptyTitle}
|
|
1482
2198
|
</p>
|
|
2199
|
+
{emptyDescription ? (
|
|
2200
|
+
<p className="text-muted-foreground max-w-xs text-sm text-balance">
|
|
2201
|
+
{emptyDescription}
|
|
2202
|
+
</p>
|
|
2203
|
+
) : null}
|
|
2204
|
+
{/* `pt-2` on top of the block's `gap-2`: the action is
|
|
2205
|
+
a separate beat from the sentence explaining it,
|
|
2206
|
+
and at one gap it reads as a third line of text. */}
|
|
2207
|
+
{emptyAction ? (
|
|
2208
|
+
<div className="pt-2">{emptyAction}</div>
|
|
2209
|
+
) : null}
|
|
1483
2210
|
</div>
|
|
1484
2211
|
)}
|
|
1485
2212
|
</TableCell>
|
|
@@ -1493,6 +2220,10 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1493
2220
|
key={key}
|
|
1494
2221
|
onClick={() => props.onRowClick?.(item)}
|
|
1495
2222
|
className={cn(
|
|
2223
|
+
// Stays: the global cursor rule in `styles.css` covers
|
|
2224
|
+
// controls and menu items, and a `<tr>` is neither. It
|
|
2225
|
+
// is also conditional, which no blanket rule could be -
|
|
2226
|
+
// a row is only clickable when a handler was given.
|
|
1496
2227
|
props.onRowClick && "cursor-pointer",
|
|
1497
2228
|
isSelected && "bg-muted/30",
|
|
1498
2229
|
)}
|
|
@@ -1540,46 +2271,72 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1540
2271
|
</Table>
|
|
1541
2272
|
</div>
|
|
1542
2273
|
|
|
1543
|
-
{/*
|
|
1544
|
-
|
|
2274
|
+
{/* A move is otherwise silent: nothing about a reordered table is
|
|
2275
|
+
spoken, and the visual change is the only feedback. Outside the
|
|
2276
|
+
table so it is not read as a cell. */}
|
|
2277
|
+
<span aria-live="polite" className="sr-only">
|
|
2278
|
+
{orderAnnouncement}
|
|
2279
|
+
</span>
|
|
2280
|
+
|
|
2281
|
+
{/* `bg-muted`, paired with the filter bar above, see the note there.
|
|
2282
|
+
Carries the same `--bevel` fold under its top border: the three
|
|
2283
|
+
chrome bands (filter bar, header, footer) are lit from one side, so
|
|
2284
|
+
they read as the same material at three different heights. */}
|
|
2285
|
+
<div className="bg-muted -mt-2 flex flex-wrap items-center justify-between gap-2 rounded-md rounded-t-none border p-2 shadow-[inset_0_1px_0_0_var(--bevel)]">
|
|
1545
2286
|
{/* The size picker sits with the count, not in the toolbar above:
|
|
1546
2287
|
this line already answers "how many, where am I", while the
|
|
1547
2288
|
toolbar answers "which rows". Mixing the two turns the toolbar
|
|
1548
2289
|
into a junk drawer. */}
|
|
1549
2290
|
<div className="flex items-center gap-2">
|
|
1550
|
-
{
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
2291
|
+
{/*
|
|
2292
|
+
Hidden on a phone, and the size itself is untouched: `size` is
|
|
2293
|
+
persisted per table, so a reader who chose 50 on a desktop keeps
|
|
2294
|
+
50 here — this drops the CONTROL, not the setting. Nobody picks
|
|
2295
|
+
100 rows on a 412px screen, and the picker plus the range text
|
|
2296
|
+
plus the numbered pages is exactly what made this bar wrap onto
|
|
2297
|
+
three lines (feedback #2106).
|
|
2298
|
+
*/}
|
|
2299
|
+
{pageSizes.length > 0 &&
|
|
2300
|
+
!isMobile && (
|
|
2301
|
+
// The same `Control` the filter bar is built on, so the picker
|
|
2302
|
+
// is one component with every other select in this table. It
|
|
2303
|
+
// used to be the raw `Select` underneath it, because `Control`
|
|
2304
|
+
// is form-bound and this is not a form — `sizeForm` above is
|
|
2305
|
+
// what closes that gap.
|
|
2306
|
+
<Control
|
|
2307
|
+
input={sizeForm.input.size}
|
|
2308
|
+
// The count line beside it is not a label, so the trigger has
|
|
2309
|
+
// to name itself.
|
|
2310
|
+
label=""
|
|
2311
|
+
inputProps={{
|
|
2312
|
+
"aria-label": String(
|
|
2313
|
+
tr("table.pageSize", { default: "Rows per page" }),
|
|
2314
|
+
),
|
|
2315
|
+
}}
|
|
2316
|
+
// `bg-background`, because this bar is `bg-muted` and the
|
|
2317
|
+
// trigger is `bg-transparent` by default: on a plain form
|
|
2318
|
+
// surface that blending is right, on a tinted bar it made the
|
|
2319
|
+
// picker read as part of the bar while the pagination buttons
|
|
2320
|
+
// beside it sat on their own plane. Set here rather than on
|
|
2321
|
+
// the trigger itself, which every form still wants
|
|
2322
|
+
// transparent.
|
|
2323
|
+
triggerClassName="bg-background h-7 w-auto gap-1 text-xs"
|
|
2324
|
+
items={pageSizes.map((n) => ({
|
|
2325
|
+
value: String(n),
|
|
2326
|
+
label: String(n),
|
|
2327
|
+
}))}
|
|
2328
|
+
/>
|
|
2329
|
+
)}
|
|
1580
2330
|
<p className="text-muted-foreground text-xs">
|
|
1581
2331
|
{meta
|
|
1582
|
-
?
|
|
2332
|
+
? // The row range is the half that goes on a phone: "where am
|
|
2333
|
+
// I" survives, "how many of how many" does not, and the two
|
|
2334
|
+
// together are what pushed this past one line.
|
|
2335
|
+
`Page ${meta.number + 1}${meta.totalPages ? ` of ${meta.totalPages}` : ""}${
|
|
2336
|
+
isMobile
|
|
2337
|
+
? ""
|
|
2338
|
+
: ` · ${meta.numberOfElements} of ${meta.totalElements ?? "?"}`
|
|
2339
|
+
}`
|
|
1583
2340
|
: "—"}
|
|
1584
2341
|
</p>
|
|
1585
2342
|
</div>
|
|
@@ -1599,27 +2356,35 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1599
2356
|
)}
|
|
1600
2357
|
/>
|
|
1601
2358
|
</PaginationItem>
|
|
1602
|
-
{
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
>
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
2359
|
+
{/*
|
|
2360
|
+
Previous/next only on a phone. The numbered sequence is up
|
|
2361
|
+
to seven tap targets plus two ellipses, which is the widest
|
|
2362
|
+
thing in this bar, and "Page 1 of 3" beside it already says
|
|
2363
|
+
where the reader is. Their labels are `hidden sm:block` in
|
|
2364
|
+
the primitive, so the two that remain are bare chevrons.
|
|
2365
|
+
*/}
|
|
2366
|
+
{!isMobile &&
|
|
2367
|
+
computePageItems(meta.number + 1, meta.totalPages).map(
|
|
2368
|
+
(item, idx) =>
|
|
2369
|
+
item === "ellipsis" ? (
|
|
2370
|
+
<PaginationItem key={`e-${idx}`}>
|
|
2371
|
+
<PaginationEllipsis />
|
|
2372
|
+
</PaginationItem>
|
|
2373
|
+
) : (
|
|
2374
|
+
<PaginationItem key={item}>
|
|
2375
|
+
<PaginationLink
|
|
2376
|
+
href="#"
|
|
2377
|
+
isActive={item === meta.number + 1}
|
|
2378
|
+
onClick={(e) => {
|
|
2379
|
+
e.preventDefault();
|
|
2380
|
+
setPage(item - 1);
|
|
2381
|
+
}}
|
|
2382
|
+
>
|
|
2383
|
+
{item}
|
|
2384
|
+
</PaginationLink>
|
|
2385
|
+
</PaginationItem>
|
|
2386
|
+
),
|
|
2387
|
+
)}
|
|
1623
2388
|
<PaginationItem>
|
|
1624
2389
|
<PaginationNext
|
|
1625
2390
|
href="#"
|
|
@@ -1642,13 +2407,32 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1642
2407
|
);
|
|
1643
2408
|
}
|
|
1644
2409
|
|
|
2410
|
+
/**
|
|
2411
|
+
* The single home for column state: what is shown, and in what order.
|
|
2412
|
+
*
|
|
2413
|
+
* Both live here rather than order being reachable only from the header's
|
|
2414
|
+
* context menu, and that is the shape decision. Right-click advertises
|
|
2415
|
+
* nothing and does not exist on touch, so a feature reachable only that way
|
|
2416
|
+
* is one most people never find. The menu is a fast path into this.
|
|
2417
|
+
*
|
|
2418
|
+
* Reordering is native HTML5 drag, the way Lore's folio tree does it: this
|
|
2419
|
+
* package has no drag-and-drop dependency and a column list is not worth
|
|
2420
|
+
* adding one. The arrows beside each row are not a fallback for a broken
|
|
2421
|
+
* drag - they are the keyboard and touch path, where drag does not exist.
|
|
2422
|
+
*/
|
|
1645
2423
|
function ColumnPicker<T>(props: {
|
|
1646
2424
|
columns: Record<string, ColumnDef<T>>;
|
|
2425
|
+
order: string[];
|
|
1647
2426
|
visible: Set<string>;
|
|
1648
2427
|
onToggle: (key: string) => void;
|
|
2428
|
+
onReorder: (key: string, target: string) => void;
|
|
1649
2429
|
}) {
|
|
1650
2430
|
const { tr } = useI18n();
|
|
1651
|
-
const
|
|
2431
|
+
const [dragging, setDragging] = useState<string | null>(null);
|
|
2432
|
+
// The reader's order, so the list reads like the table it controls.
|
|
2433
|
+
const entries = props.order.map(
|
|
2434
|
+
(key) => [key, props.columns[key]!] as [string, ColumnDef<T>],
|
|
2435
|
+
);
|
|
1652
2436
|
const label = tr("alephaTable.toggleColumns", {
|
|
1653
2437
|
default: "Toggle columns",
|
|
1654
2438
|
});
|
|
@@ -1690,15 +2474,64 @@ function ColumnPicker<T>(props: {
|
|
|
1690
2474
|
{tr("alephaTable.columns", { default: "Columns" })}
|
|
1691
2475
|
</DropdownMenuLabel>
|
|
1692
2476
|
<DropdownMenuSeparator />
|
|
1693
|
-
{entries.map(([key, def]) => (
|
|
1694
|
-
<
|
|
2477
|
+
{entries.map(([key, def], index) => (
|
|
2478
|
+
<div
|
|
1695
2479
|
key={key}
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
2480
|
+
draggable
|
|
2481
|
+
onDragStart={() => setDragging(key)}
|
|
2482
|
+
onDragEnd={() => setDragging(null)}
|
|
2483
|
+
onDragOver={(event) => {
|
|
2484
|
+
// Required, or the drop never fires.
|
|
2485
|
+
event.preventDefault();
|
|
2486
|
+
}}
|
|
2487
|
+
onDrop={(event) => {
|
|
2488
|
+
event.preventDefault();
|
|
2489
|
+
if (dragging && dragging !== key)
|
|
2490
|
+
props.onReorder(dragging, key);
|
|
2491
|
+
setDragging(null);
|
|
2492
|
+
}}
|
|
2493
|
+
className={cn(
|
|
2494
|
+
"flex items-center gap-1 pr-1",
|
|
2495
|
+
dragging === key && "opacity-45",
|
|
2496
|
+
)}
|
|
1699
2497
|
>
|
|
1700
|
-
|
|
1701
|
-
|
|
2498
|
+
<GripVertical
|
|
2499
|
+
className="text-muted-foreground/60 size-3.5 shrink-0 cursor-grab"
|
|
2500
|
+
aria-hidden
|
|
2501
|
+
/>
|
|
2502
|
+
<DropdownMenuCheckboxItem
|
|
2503
|
+
checked={props.visible.has(key)}
|
|
2504
|
+
closeOnClick={false}
|
|
2505
|
+
onCheckedChange={() => props.onToggle(key)}
|
|
2506
|
+
className="flex-1"
|
|
2507
|
+
>
|
|
2508
|
+
{def.label}
|
|
2509
|
+
</DropdownMenuCheckboxItem>
|
|
2510
|
+
{/* Keyboard and touch reach the order here. A drag handle alone
|
|
2511
|
+
would put reordering out of reach for both. */}
|
|
2512
|
+
<button
|
|
2513
|
+
type="button"
|
|
2514
|
+
disabled={index === 0}
|
|
2515
|
+
aria-label={String(
|
|
2516
|
+
tr("alephaTable.moveUp", { default: "Move up" }),
|
|
2517
|
+
)}
|
|
2518
|
+
onClick={() => props.onReorder(key, entries[index - 1]![0])}
|
|
2519
|
+
className="text-muted-foreground/60 hover:text-foreground rounded p-0.5 disabled:opacity-30"
|
|
2520
|
+
>
|
|
2521
|
+
<ChevronUp className="size-3.5" />
|
|
2522
|
+
</button>
|
|
2523
|
+
<button
|
|
2524
|
+
type="button"
|
|
2525
|
+
disabled={index === entries.length - 1}
|
|
2526
|
+
aria-label={String(
|
|
2527
|
+
tr("alephaTable.moveDown", { default: "Move down" }),
|
|
2528
|
+
)}
|
|
2529
|
+
onClick={() => props.onReorder(entries[index + 1]![0], key)}
|
|
2530
|
+
className="text-muted-foreground/60 hover:text-foreground rounded p-0.5 disabled:opacity-30"
|
|
2531
|
+
>
|
|
2532
|
+
<ChevronDown className="size-3.5" />
|
|
2533
|
+
</button>
|
|
2534
|
+
</div>
|
|
1702
2535
|
))}
|
|
1703
2536
|
</DropdownMenuGroup>
|
|
1704
2537
|
</DropdownMenuContent>
|
|
@@ -1742,13 +2575,25 @@ const SkeletonRows = (props: { rows: number; cols: number }) => {
|
|
|
1742
2575
|
);
|
|
1743
2576
|
};
|
|
1744
2577
|
|
|
2578
|
+
function isRowActionGroup<T>(
|
|
2579
|
+
entry: RowActionEntry<T>,
|
|
2580
|
+
): entry is RowActionGroup<T> {
|
|
2581
|
+
return "children" in entry;
|
|
2582
|
+
}
|
|
2583
|
+
|
|
1745
2584
|
function RowActionsMenu<T>(props: {
|
|
1746
|
-
actions:
|
|
2585
|
+
actions: RowActionEntry<T>[];
|
|
1747
2586
|
item: T;
|
|
1748
2587
|
ctx: RowActionContext;
|
|
1749
2588
|
}) {
|
|
1750
2589
|
const { tr } = useI18n();
|
|
1751
|
-
|
|
2590
|
+
// ⚠️ Effective entries, not entries: a group is one entry however many
|
|
2591
|
+
// children it has, so a lone empty group would otherwise render the
|
|
2592
|
+
// three-dots trigger over an empty menu.
|
|
2593
|
+
const effective = props.actions.filter((action) =>
|
|
2594
|
+
isRowActionGroup(action) ? action.children.length > 0 : true,
|
|
2595
|
+
);
|
|
2596
|
+
if (effective.length === 0) return null;
|
|
1752
2597
|
return (
|
|
1753
2598
|
<DropdownMenu>
|
|
1754
2599
|
<DropdownMenuTrigger
|
|
@@ -1765,24 +2610,43 @@ function RowActionsMenu<T>(props: {
|
|
|
1765
2610
|
<MoreVertical className="size-4" />
|
|
1766
2611
|
</DropdownMenuTrigger>
|
|
1767
2612
|
<DropdownMenuContent align="end">
|
|
1768
|
-
{
|
|
2613
|
+
{effective.map((action, idx) => {
|
|
1769
2614
|
const Icon = action.icon;
|
|
1770
|
-
|
|
2615
|
+
if (isRowActionGroup(action)) {
|
|
2616
|
+
return (
|
|
2617
|
+
<DropdownMenuSub key={action.label}>
|
|
2618
|
+
<DropdownMenuSubTrigger>
|
|
2619
|
+
{Icon && <Icon className="mr-2 size-4" />}
|
|
2620
|
+
{action.label}
|
|
2621
|
+
</DropdownMenuSubTrigger>
|
|
2622
|
+
<DropdownMenuSubContent>
|
|
2623
|
+
{action.children.map((child) => (
|
|
2624
|
+
<RowActionItem
|
|
2625
|
+
key={child.label}
|
|
2626
|
+
action={child}
|
|
2627
|
+
item={props.item}
|
|
2628
|
+
ctx={props.ctx}
|
|
2629
|
+
/>
|
|
2630
|
+
))}
|
|
2631
|
+
</DropdownMenuSubContent>
|
|
2632
|
+
</DropdownMenuSub>
|
|
2633
|
+
);
|
|
2634
|
+
}
|
|
2635
|
+
// A group is never destructive, so the previous entry being one
|
|
2636
|
+
// reads as falsy here and the separator rule needs no case for it.
|
|
2637
|
+
const previous = effective[idx - 1];
|
|
1771
2638
|
const sep =
|
|
1772
2639
|
idx > 0 &&
|
|
1773
2640
|
action.destructive &&
|
|
1774
|
-
!
|
|
2641
|
+
!(previous && !isRowActionGroup(previous) && previous.destructive);
|
|
1775
2642
|
return (
|
|
1776
2643
|
<span key={action.label}>
|
|
1777
2644
|
{sep && <DropdownMenuSeparator />}
|
|
1778
|
-
<
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
{Icon && <Icon className="mr-2 size-4" />}
|
|
1784
|
-
{action.label}
|
|
1785
|
-
</DropdownMenuItem>
|
|
2645
|
+
<RowActionItem
|
|
2646
|
+
action={action}
|
|
2647
|
+
item={props.item}
|
|
2648
|
+
ctx={props.ctx}
|
|
2649
|
+
/>
|
|
1786
2650
|
</span>
|
|
1787
2651
|
);
|
|
1788
2652
|
})}
|
|
@@ -1790,3 +2654,45 @@ function RowActionsMenu<T>(props: {
|
|
|
1790
2654
|
</DropdownMenu>
|
|
1791
2655
|
);
|
|
1792
2656
|
}
|
|
2657
|
+
|
|
2658
|
+
/**
|
|
2659
|
+
* One menu entry, wherever it sits: at the top level of the row menu or
|
|
2660
|
+
* inside a group's submenu. Both render the same way, which is what keeps a
|
|
2661
|
+
* `checked` entry from behaving differently depending on where it was put.
|
|
2662
|
+
*/
|
|
2663
|
+
function RowActionItem<T>(props: {
|
|
2664
|
+
action: RowAction<T>;
|
|
2665
|
+
item: T;
|
|
2666
|
+
ctx: RowActionContext;
|
|
2667
|
+
}) {
|
|
2668
|
+
const { action, item, ctx } = props;
|
|
2669
|
+
const Icon = action.icon;
|
|
2670
|
+
const disabled = action.disabled?.(item);
|
|
2671
|
+
if (action.checked) {
|
|
2672
|
+
return (
|
|
2673
|
+
<DropdownMenuCheckboxItem
|
|
2674
|
+
// Controlled with no `onCheckedChange`: the write is `onClick`, and
|
|
2675
|
+
// the state comes back from the row on the next render. Letting the
|
|
2676
|
+
// primitive toggle itself would show a check for a write that has
|
|
2677
|
+
// not landed, and would uncheck the current value when it is picked
|
|
2678
|
+
// again.
|
|
2679
|
+
checked={action.checked(item)}
|
|
2680
|
+
disabled={disabled}
|
|
2681
|
+
onClick={() => action.onClick(item, ctx)}
|
|
2682
|
+
>
|
|
2683
|
+
{Icon && <Icon className="mr-2 size-4" />}
|
|
2684
|
+
{action.label}
|
|
2685
|
+
</DropdownMenuCheckboxItem>
|
|
2686
|
+
);
|
|
2687
|
+
}
|
|
2688
|
+
return (
|
|
2689
|
+
<DropdownMenuItem
|
|
2690
|
+
disabled={disabled}
|
|
2691
|
+
onClick={() => action.onClick(item, ctx)}
|
|
2692
|
+
variant={action.destructive ? "destructive" : undefined}
|
|
2693
|
+
>
|
|
2694
|
+
{Icon && <Icon className="mr-2 size-4" />}
|
|
2695
|
+
{action.label}
|
|
2696
|
+
</DropdownMenuItem>
|
|
2697
|
+
);
|
|
2698
|
+
}
|