@alepha/ui 0.27.1 → 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-layout.d.ts.map +1 -1
- package/dist/components/account/account-layout.js +8 -2
- package/dist/components/account/account-layout.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-analytics.d.ts +34 -5
- package/dist/components/admin/admin-analytics.d.ts.map +1 -1
- package/dist/components/admin/admin-analytics.js +69 -51
- package/dist/components/admin/admin-analytics.js.map +1 -1
- package/dist/components/admin/admin-audits.d.ts +14 -0
- package/dist/components/admin/admin-audits.d.ts.map +1 -1
- package/dist/components/admin/admin-audits.js +121 -37
- 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 +8 -18
- 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 +40 -9
- 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-jobs.js +1 -1
- package/dist/components/admin/admin-keys.d.ts.map +1 -1
- package/dist/components/admin/admin-keys.js +7 -5
- 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 +12 -13
- package/dist/components/admin/admin-notifications.js.map +1 -1
- package/dist/components/admin/admin-parameters.d.ts.map +1 -1
- package/dist/components/admin/admin-parameters.js +108 -14
- package/dist/components/admin/admin-parameters.js.map +1 -1
- package/dist/components/admin/admin-payments.d.ts.map +1 -1
- package/dist/components/admin/admin-payments.js +10 -8
- 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 +135 -11
- package/dist/components/admin/admin-sessions.js.map +1 -1
- package/dist/components/admin/admin-user-avatar-control.d.ts +24 -0
- package/dist/components/admin/admin-user-avatar-control.d.ts.map +1 -0
- package/dist/components/admin/admin-user-avatar-control.js +84 -0
- package/dist/components/admin/admin-user-avatar-control.js.map +1 -0
- 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.d.ts.map +1 -1
- package/dist/components/admin/admin-user-detail.js +16 -4
- 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 +7 -5
- package/dist/components/admin/admin-users.js.map +1 -1
- package/dist/components/admin/analytics/AdvancedSection.d.ts +26 -0
- package/dist/components/admin/analytics/AdvancedSection.d.ts.map +1 -0
- package/dist/components/admin/analytics/AdvancedSection.js +143 -0
- package/dist/components/admin/analytics/AdvancedSection.js.map +1 -0
- package/dist/components/admin/analytics/AnalyticsChart.d.ts +20 -0
- package/dist/components/admin/analytics/AnalyticsChart.d.ts.map +1 -0
- package/dist/components/admin/analytics/AnalyticsChart.js +60 -0
- package/dist/components/admin/analytics/AnalyticsChart.js.map +1 -0
- package/dist/components/admin/analytics/AnalyticsChartBars.d.ts +19 -0
- package/dist/components/admin/analytics/AnalyticsChartBars.d.ts.map +1 -0
- package/dist/components/admin/analytics/AnalyticsChartBars.js +43 -0
- package/dist/components/admin/analytics/AnalyticsChartBars.js.map +1 -0
- package/dist/components/admin/analytics/AnalyticsChartDonut.d.ts +11 -0
- package/dist/components/admin/analytics/AnalyticsChartDonut.d.ts.map +1 -0
- package/dist/components/admin/analytics/AnalyticsChartDonut.js +78 -0
- package/dist/components/admin/analytics/AnalyticsChartDonut.js.map +1 -0
- package/dist/components/admin/analytics/AnalyticsChartHeader.d.ts +20 -0
- package/dist/components/admin/analytics/AnalyticsChartHeader.d.ts.map +1 -0
- package/dist/components/admin/analytics/AnalyticsChartHeader.js +105 -0
- package/dist/components/admin/analytics/AnalyticsChartHeader.js.map +1 -0
- package/dist/components/admin/analytics/AnalyticsChartHeat.d.ts +10 -0
- package/dist/components/admin/analytics/AnalyticsChartHeat.d.ts.map +1 -0
- package/dist/components/admin/analytics/AnalyticsChartHeat.js +58 -0
- package/dist/components/admin/analytics/AnalyticsChartHeat.js.map +1 -0
- package/dist/components/admin/analytics/AnalyticsChartLegend.d.ts +9 -0
- package/dist/components/admin/analytics/AnalyticsChartLegend.d.ts.map +1 -0
- package/dist/components/admin/analytics/AnalyticsChartLegend.js +21 -0
- package/dist/components/admin/analytics/AnalyticsChartLegend.js.map +1 -0
- package/dist/components/admin/analytics/AnalyticsChartLine.d.ts +13 -0
- package/dist/components/admin/analytics/AnalyticsChartLine.d.ts.map +1 -0
- package/dist/components/admin/analytics/AnalyticsChartLine.js +36 -0
- package/dist/components/admin/analytics/AnalyticsChartLine.js.map +1 -0
- package/dist/components/admin/analytics/AnalyticsChartRank.d.ts +13 -0
- package/dist/components/admin/analytics/AnalyticsChartRank.d.ts.map +1 -0
- package/dist/components/admin/analytics/AnalyticsChartRank.js +41 -0
- package/dist/components/admin/analytics/AnalyticsChartRank.js.map +1 -0
- package/dist/components/admin/analytics/AnalyticsChartTicks.d.ts +13 -0
- package/dist/components/admin/analytics/AnalyticsChartTicks.d.ts.map +1 -0
- package/dist/components/admin/analytics/AnalyticsChartTicks.js +26 -0
- package/dist/components/admin/analytics/AnalyticsChartTicks.js.map +1 -0
- package/dist/components/admin/analytics/AnalyticsEmpty.d.ts +16 -0
- package/dist/components/admin/analytics/AnalyticsEmpty.d.ts.map +1 -0
- package/dist/components/admin/analytics/AnalyticsEmpty.js +32 -0
- package/dist/components/admin/analytics/AnalyticsEmpty.js.map +1 -0
- package/dist/components/admin/analytics/ClauseLabel.d.ts +15 -0
- package/dist/components/admin/analytics/ClauseLabel.d.ts.map +1 -0
- package/dist/components/admin/analytics/ClauseLabel.js +19 -0
- package/dist/components/admin/analytics/ClauseLabel.js.map +1 -0
- package/dist/components/admin/analytics/CompareNote.d.ts +16 -0
- package/dist/components/admin/analytics/CompareNote.d.ts.map +1 -0
- package/dist/components/admin/analytics/CompareNote.js +33 -0
- package/dist/components/admin/analytics/CompareNote.js.map +1 -0
- package/dist/components/admin/analytics/DatasetSelect.d.ts +20 -0
- package/dist/components/admin/analytics/DatasetSelect.d.ts.map +1 -0
- package/dist/components/admin/analytics/DatasetSelect.js +63 -0
- package/dist/components/admin/analytics/DatasetSelect.js.map +1 -0
- package/dist/components/admin/analytics/FilterEditor.d.ts +24 -0
- package/dist/components/admin/analytics/FilterEditor.d.ts.map +1 -0
- package/dist/components/admin/analytics/FilterEditor.js +129 -0
- package/dist/components/admin/analytics/FilterEditor.js.map +1 -0
- package/dist/components/admin/analytics/FilterValuePicker.d.ts +19 -0
- package/dist/components/admin/analytics/FilterValuePicker.d.ts.map +1 -0
- package/dist/components/admin/analytics/FilterValuePicker.js +131 -0
- package/dist/components/admin/analytics/FilterValuePicker.js.map +1 -0
- package/dist/components/admin/analytics/GroupByChips.d.ts +26 -0
- package/dist/components/admin/analytics/GroupByChips.d.ts.map +1 -0
- package/dist/components/admin/analytics/GroupByChips.js +71 -0
- package/dist/components/admin/analytics/GroupByChips.js.map +1 -0
- package/dist/components/admin/analytics/MeasureChips.d.ts +18 -0
- package/dist/components/admin/analytics/MeasureChips.d.ts.map +1 -0
- package/dist/components/admin/analytics/MeasureChips.js +46 -0
- package/dist/components/admin/analytics/MeasureChips.js.map +1 -0
- package/dist/components/admin/analytics/QueryPanel.d.ts +27 -0
- package/dist/components/admin/analytics/QueryPanel.d.ts.map +1 -0
- package/dist/components/admin/analytics/QueryPanel.js +92 -0
- package/dist/components/admin/analytics/QueryPanel.js.map +1 -0
- package/dist/components/admin/analytics/RangeControl.d.ts +17 -0
- package/dist/components/admin/analytics/RangeControl.d.ts.map +1 -0
- package/dist/components/admin/analytics/RangeControl.js +43 -0
- package/dist/components/admin/analytics/RangeControl.js.map +1 -0
- package/dist/components/admin/analytics/RequestDialog.d.ts +24 -0
- package/dist/components/admin/analytics/RequestDialog.d.ts.map +1 -0
- package/dist/components/admin/analytics/RequestDialog.js +67 -0
- package/dist/components/admin/analytics/RequestDialog.js.map +1 -0
- package/dist/components/admin/analytics/ResultsPane.d.ts +15 -0
- package/dist/components/admin/analytics/ResultsPane.d.ts.map +1 -0
- package/dist/components/admin/analytics/ResultsPane.js +161 -0
- package/dist/components/admin/analytics/ResultsPane.js.map +1 -0
- package/dist/components/admin/analytics/ResultsTable.d.ts +17 -0
- package/dist/components/admin/analytics/ResultsTable.d.ts.map +1 -0
- package/dist/components/admin/analytics/ResultsTable.js +113 -0
- package/dist/components/admin/analytics/ResultsTable.js.map +1 -0
- package/dist/components/admin/analytics/RunFooter.d.ts +18 -0
- package/dist/components/admin/analytics/RunFooter.d.ts.map +1 -0
- package/dist/components/admin/analytics/RunFooter.js +78 -0
- package/dist/components/admin/analytics/RunFooter.js.map +1 -0
- package/dist/components/admin/analytics/SamplingBadge.d.ts +18 -0
- package/dist/components/admin/analytics/SamplingBadge.d.ts.map +1 -0
- package/dist/components/admin/analytics/SamplingBadge.js +35 -0
- package/dist/components/admin/analytics/SamplingBadge.js.map +1 -0
- package/dist/components/admin/analytics/ToggleChip.d.ts +28 -0
- package/dist/components/admin/analytics/ToggleChip.d.ts.map +1 -0
- package/dist/components/admin/analytics/ToggleChip.js +35 -0
- package/dist/components/admin/analytics/ToggleChip.js.map +1 -0
- package/dist/components/admin/analytics/TotalsCards.d.ts +19 -0
- package/dist/components/admin/analytics/TotalsCards.d.ts.map +1 -0
- package/dist/components/admin/analytics/TotalsCards.js +75 -0
- package/dist/components/admin/analytics/TotalsCards.js.map +1 -0
- package/dist/components/admin/analytics/TruncationBanner.d.ts +15 -0
- package/dist/components/admin/analytics/TruncationBanner.d.ts.map +1 -0
- package/dist/components/admin/analytics/TruncationBanner.js +52 -0
- package/dist/components/admin/analytics/TruncationBanner.js.map +1 -0
- package/dist/components/admin/analytics/analyticsModel.d.ts +98 -0
- package/dist/components/admin/analytics/analyticsModel.d.ts.map +1 -0
- package/dist/components/admin/analytics/analyticsModel.js +184 -0
- package/dist/components/admin/analytics/analyticsModel.js.map +1 -0
- package/dist/components/admin/analytics/analyticsTypes.d.ts +116 -0
- package/dist/components/admin/analytics/analyticsTypes.d.ts.map +1 -0
- package/dist/components/admin/analytics/analyticsTypes.js +0 -0
- package/dist/components/admin/analytics/chartModel.d.ts +149 -0
- package/dist/components/admin/analytics/chartModel.d.ts.map +1 -0
- package/dist/components/admin/analytics/chartModel.js +278 -0
- package/dist/components/admin/analytics/chartModel.js.map +1 -0
- package/dist/components/admin/analytics/useAnalyticsQuery.d.ts +62 -0
- package/dist/components/admin/analytics/useAnalyticsQuery.d.ts.map +1 -0
- package/dist/components/admin/analytics/useAnalyticsQuery.js +257 -0
- package/dist/components/admin/analytics/useAnalyticsQuery.js.map +1 -0
- package/dist/components/admin/analytics/useDismissable.d.ts +18 -0
- package/dist/components/admin/analytics/useDismissable.d.ts.map +1 -0
- package/dist/components/admin/analytics/useDismissable.js +37 -0
- package/dist/components/admin/analytics/useDismissable.js.map +1 -0
- package/dist/components/admin/analytics/useFilterValues.d.ts +37 -0
- package/dist/components/admin/analytics/useFilterValues.d.ts.map +1 -0
- package/dist/components/admin/analytics/useFilterValues.js +78 -0
- package/dist/components/admin/analytics/useFilterValues.js.map +1 -0
- package/dist/components/admin/analytics/usePanelWidth.d.ts +26 -0
- package/dist/components/admin/analytics/usePanelWidth.d.ts.map +1 -0
- package/dist/components/admin/analytics/usePanelWidth.js +61 -0
- package/dist/components/admin/analytics/usePanelWidth.js.map +1 -0
- package/dist/components/admin/analytics/useShapeLabels.d.ts +24 -0
- package/dist/components/admin/analytics/useShapeLabels.d.ts.map +1 -0
- package/dist/components/admin/analytics/useShapeLabels.js +41 -0
- package/dist/components/admin/analytics/useShapeLabels.js.map +1 -0
- 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.d.ts +22 -0
- package/dist/components/alepha-table/alepha-table-bulk-menu.d.ts.map +1 -0
- package/dist/components/alepha-table/alepha-table-bulk-menu.js +118 -0
- package/dist/components/alepha-table/alepha-table-bulk-menu.js.map +1 -0
- 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 +336 -16
- package/dist/components/alepha-table/alepha-table.d.ts.map +1 -1
- package/dist/components/alepha-table/alepha-table.js +630 -174
- 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 +75 -11
- package/dist/components/app-shell/app-shell.d.ts.map +1 -1
- package/dist/components/app-shell/app-shell.js +194 -83
- package/dist/components/app-shell/app-shell.js.map +1 -1
- package/dist/components/app-shell/navigation-progress.d.ts +40 -0
- package/dist/components/app-shell/navigation-progress.d.ts.map +1 -0
- package/dist/components/app-shell/navigation-progress.js +86 -0
- package/dist/components/app-shell/navigation-progress.js.map +1 -0
- package/dist/components/auth/auth-register.d.ts +35 -0
- package/dist/components/auth/auth-register.d.ts.map +1 -1
- package/dist/components/auth/auth-register.js +43 -38
- 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 +69 -28
- 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 +90 -10
- package/dist/components/control/control.d.ts.map +1 -1
- package/dist/components/control/control.js +58 -8
- 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 +35 -0
- package/dist/components/control-date/control-date.d.ts.map +1 -1
- package/dist/components/control-date/control-date.js +38 -26
- 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 +57 -6
- package/dist/components/control-select/control-select.d.ts.map +1 -1
- package/dist/components/control-select/control-select.js +275 -55
- 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/detail/detail-layout.d.ts.map +1 -1
- package/dist/components/detail/detail-layout.js +9 -6
- package/dist/components/detail/detail-layout.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/MermaidFence.d.ts.map +1 -1
- package/dist/components/markdown-view/diagram/MermaidFence.js +1 -15
- package/dist/components/markdown-view/diagram/MermaidFence.js.map +1 -1
- package/dist/components/markdown-view/diagram/diagramKind.d.ts +18 -0
- package/dist/components/markdown-view/diagram/diagramKind.d.ts.map +1 -0
- package/dist/components/markdown-view/diagram/diagramKind.js +27 -0
- package/dist/components/markdown-view/diagram/diagramKind.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 +55 -0
- package/dist/components/plate-layout/plate-layout.d.ts.map +1 -0
- package/dist/components/plate-layout/plate-layout.js +38 -0
- package/dist/components/plate-layout/plate-layout.js.map +1 -0
- package/dist/components/plate-layout/plate-tab-bar.d.ts +65 -0
- package/dist/components/plate-layout/plate-tab-bar.d.ts.map +1 -0
- package/dist/components/plate-layout/plate-tab-bar.js +52 -0
- package/dist/components/plate-layout/plate-tab-bar.js.map +1 -0
- 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 +2 -2
- 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/components/use-dialog/use-dialog.d.ts +7 -0
- package/dist/components/use-dialog/use-dialog.d.ts.map +1 -1
- package/dist/components/use-dialog/use-dialog.js +10 -1
- package/dist/components/use-dialog/use-dialog.js.map +1 -1
- package/dist/lib/i18n-fr.d.ts.map +1 -1
- package/dist/lib/i18n-fr.js +141 -54
- 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 +300 -21
- package/package.json +16 -16
- package/src/components/account/__tests__/account-layout.browser.spec.tsx +127 -0
- 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-layout.tsx +32 -2
- 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-audits-action-filter.browser.spec.tsx +53 -0
- 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-analytics.tsx +97 -83
- package/src/components/admin/admin-audits.tsx +149 -13
- package/src/components/admin/admin-files.tsx +10 -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 +9 -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-parameters.tsx +165 -12
- 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 +174 -10
- package/src/components/admin/admin-user-avatar-control.tsx +130 -0
- 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-user-detail.tsx +25 -3
- package/src/components/admin/admin-users-roles-picker.tsx +4 -0
- package/src/components/admin/admin-users.tsx +6 -3
- package/src/components/admin/analytics/AdvancedSection.tsx +162 -0
- package/src/components/admin/analytics/AnalyticsChart.tsx +69 -0
- package/src/components/admin/analytics/AnalyticsChartBars.tsx +86 -0
- package/src/components/admin/analytics/AnalyticsChartDonut.tsx +78 -0
- package/src/components/admin/analytics/AnalyticsChartHeader.tsx +135 -0
- package/src/components/admin/analytics/AnalyticsChartHeat.tsx +57 -0
- package/src/components/admin/analytics/AnalyticsChartLegend.tsx +26 -0
- package/src/components/admin/analytics/AnalyticsChartLine.tsx +37 -0
- package/src/components/admin/analytics/AnalyticsChartRank.tsx +43 -0
- package/src/components/admin/analytics/AnalyticsChartTicks.tsx +38 -0
- package/src/components/admin/analytics/AnalyticsEmpty.tsx +37 -0
- package/src/components/admin/analytics/ClauseLabel.tsx +26 -0
- package/src/components/admin/analytics/CompareNote.tsx +50 -0
- package/src/components/admin/analytics/DatasetSelect.tsx +79 -0
- package/src/components/admin/analytics/FilterEditor.tsx +173 -0
- package/src/components/admin/analytics/FilterValuePicker.tsx +154 -0
- package/src/components/admin/analytics/GroupByChips.tsx +82 -0
- package/src/components/admin/analytics/MeasureChips.tsx +53 -0
- package/src/components/admin/analytics/QueryPanel.tsx +113 -0
- package/src/components/admin/analytics/RangeControl.tsx +42 -0
- package/src/components/admin/analytics/RequestDialog.tsx +91 -0
- package/src/components/admin/analytics/ResultsPane.tsx +224 -0
- package/src/components/admin/analytics/ResultsTable.tsx +176 -0
- package/src/components/admin/analytics/RunFooter.tsx +90 -0
- package/src/components/admin/analytics/SamplingBadge.tsx +46 -0
- package/src/components/admin/analytics/ToggleChip.tsx +57 -0
- package/src/components/admin/analytics/TotalsCards.tsx +79 -0
- package/src/components/admin/analytics/TruncationBanner.tsx +60 -0
- package/src/components/admin/analytics/analyticsModel.spec.ts +266 -0
- package/src/components/admin/analytics/analyticsModel.ts +263 -0
- package/src/components/admin/analytics/analyticsTypes.ts +139 -0
- package/src/components/admin/analytics/chartModel.spec.ts +240 -0
- package/src/components/admin/analytics/chartModel.ts +427 -0
- package/src/components/admin/analytics/useAnalyticsQuery.ts +401 -0
- package/src/components/admin/analytics/useDismissable.ts +48 -0
- package/src/components/admin/analytics/useFilterValues.ts +113 -0
- package/src/components/admin/analytics/usePanelWidth.ts +85 -0
- package/src/components/admin/analytics/useShapeLabels.ts +73 -0
- package/src/components/admin/parameter-history-item.tsx +4 -2
- package/src/components/alepha-table/__tests__/alepha-table-actions.browser.spec.tsx +117 -0
- package/src/components/alepha-table/__tests__/alepha-table-bulk-menu.browser.spec.tsx +177 -0
- package/src/components/alepha-table/__tests__/alepha-table-bulk-visible.browser.spec.tsx +125 -0
- 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-bulk-menu.tsx +170 -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 +1375 -230
- 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__/navigation-progress.browser.spec.tsx +122 -0
- package/src/components/app-shell/__tests__/sidebar-nav-accordion.browser.spec.tsx +163 -0
- package/src/components/app-shell/__tests__/sidebar-nav-auto-close.browser.spec.tsx +170 -0
- package/src/components/app-shell/app-shell.tsx +390 -122
- package/src/components/app-shell/navigation-progress.tsx +110 -0
- package/src/components/auth/auth-register.tsx +72 -9
- package/src/components/auto-form/__tests__/auto-form-fill-groups.browser.spec.tsx +104 -0
- package/src/components/auto-form/__tests__/auto-form-settings-card.browser.spec.tsx +1 -1
- package/src/components/auto-form/auto-form.tsx +111 -33
- 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 +182 -26
- package/src/components/control-date/control-date.tsx +170 -36
- 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 +399 -0
- package/src/components/control-select/__tests__/control-select-searchable.browser.spec.tsx +5 -1
- package/src/components/control-select/__tests__/control-select-size-minimal.browser.spec.tsx +195 -0
- package/src/components/control-select/__tests__/control-select-trigger-props.browser.spec.tsx +89 -0
- package/src/components/control-select/control-select.tsx +554 -123
- package/src/components/control-upload/control-upload.tsx +1 -10
- package/src/components/detail/__tests__/detail-layout.browser.spec.tsx +46 -0
- package/src/components/detail/detail-aside.tsx +30 -6
- package/src/components/detail/detail-layout.tsx +37 -7
- 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/MermaidFence.tsx +1 -23
- package/src/components/markdown-view/diagram/diagramKind.ts +31 -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 +189 -0
- package/src/components/plate-layout/plate-layout.tsx +84 -0
- package/src/components/plate-layout/plate-tab-bar.tsx +148 -0
- 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 +80 -2
- 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/components/use-dialog/use-dialog.tsx +10 -0
- package/src/lib/i18n-fr.ts +155 -58
- package/src/lib/utils.ts +32 -4
- package/src/styles.css +300 -21
- package/dist/components/admin/admin-analytics-query-panel.d.ts +0 -16
- package/dist/components/admin/admin-analytics-query-panel.d.ts.map +0 -1
- package/dist/components/admin/admin-analytics-query-panel.js +0 -117
- package/dist/components/admin/admin-analytics-query-panel.js.map +0 -1
- package/dist/components/admin/admin-analytics-results.d.ts +0 -15
- package/dist/components/admin/admin-analytics-results.d.ts.map +0 -1
- package/dist/components/admin/admin-analytics-results.js +0 -56
- package/dist/components/admin/admin-analytics-results.js.map +0 -1
- 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-analytics-query-panel.tsx +0 -150
- package/src/components/admin/admin-analytics-results.tsx +0 -95
- 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
|
@@ -2,8 +2,16 @@ import * as React from "react";
|
|
|
2
2
|
|
|
3
3
|
void React;
|
|
4
4
|
|
|
5
|
+
import { Control } from "@alepha/ui/components/control/control";
|
|
5
6
|
import { Button } from "@alepha/ui/components/ui/button";
|
|
6
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";
|
|
7
15
|
import {
|
|
8
16
|
DropdownMenu,
|
|
9
17
|
DropdownMenuCheckboxItem,
|
|
@@ -12,6 +20,9 @@ import {
|
|
|
12
20
|
DropdownMenuItem,
|
|
13
21
|
DropdownMenuLabel,
|
|
14
22
|
DropdownMenuSeparator,
|
|
23
|
+
DropdownMenuSub,
|
|
24
|
+
DropdownMenuSubContent,
|
|
25
|
+
DropdownMenuSubTrigger,
|
|
15
26
|
DropdownMenuTrigger,
|
|
16
27
|
} from "@alepha/ui/components/ui/dropdown-menu";
|
|
17
28
|
import {
|
|
@@ -23,13 +34,6 @@ import {
|
|
|
23
34
|
PaginationNext,
|
|
24
35
|
PaginationPrevious,
|
|
25
36
|
} from "@alepha/ui/components/ui/pagination";
|
|
26
|
-
import {
|
|
27
|
-
Select,
|
|
28
|
-
SelectContent,
|
|
29
|
-
SelectItem,
|
|
30
|
-
SelectTrigger,
|
|
31
|
-
SelectValue,
|
|
32
|
-
} from "@alepha/ui/components/ui/select";
|
|
33
37
|
import { Skeleton } from "@alepha/ui/components/ui/skeleton";
|
|
34
38
|
import {
|
|
35
39
|
Table,
|
|
@@ -45,6 +49,7 @@ import {
|
|
|
45
49
|
TooltipProvider,
|
|
46
50
|
TooltipTrigger,
|
|
47
51
|
} from "@alepha/ui/components/ui/tooltip";
|
|
52
|
+
import { useToast } from "@alepha/ui/components/use-toast/use-toast";
|
|
48
53
|
import { cn } from "@alepha/ui/lib/utils";
|
|
49
54
|
import { type Page, type ZObject, z } from "alepha";
|
|
50
55
|
import { ClientOnly, useAlepha } from "alepha/react";
|
|
@@ -54,9 +59,18 @@ import {
|
|
|
54
59
|
ArrowDown,
|
|
55
60
|
ArrowUp,
|
|
56
61
|
ChevronsUpDown,
|
|
62
|
+
ArrowDownAZ,
|
|
63
|
+
ArrowUpAZ,
|
|
64
|
+
ChevronDown,
|
|
65
|
+
ChevronLeft,
|
|
66
|
+
ChevronRight,
|
|
67
|
+
ChevronUp,
|
|
57
68
|
Columns3,
|
|
69
|
+
EyeOff,
|
|
58
70
|
FunnelX,
|
|
71
|
+
GripVertical,
|
|
59
72
|
Inbox,
|
|
73
|
+
SearchX,
|
|
60
74
|
MoreVertical,
|
|
61
75
|
RefreshCw,
|
|
62
76
|
X,
|
|
@@ -72,7 +86,16 @@ import {
|
|
|
72
86
|
useState,
|
|
73
87
|
} from "react";
|
|
74
88
|
|
|
89
|
+
import { useIsMobile } from "../../hooks/use-mobile.ts";
|
|
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";
|
|
75
93
|
import { paginateLocal } from "./paginate-local.ts";
|
|
94
|
+
import {
|
|
95
|
+
cleanFilterValues,
|
|
96
|
+
queryToFilters,
|
|
97
|
+
shareFiltersUrl,
|
|
98
|
+
} from "./query-filters.ts";
|
|
76
99
|
import { useTableSelection } from "./use-table-selection.ts";
|
|
77
100
|
|
|
78
101
|
type IconType = ComponentType<SVGProps<SVGSVGElement>>;
|
|
@@ -123,8 +146,44 @@ export interface RowAction<T> {
|
|
|
123
146
|
onClick: (item: T, ctx: RowActionContext) => void | Promise<void>;
|
|
124
147
|
destructive?: boolean;
|
|
125
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;
|
|
126
165
|
}
|
|
127
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
|
+
|
|
128
187
|
/**
|
|
129
188
|
* Context passed to every bulk-action `onClick`. `clearSelection()`
|
|
130
189
|
* empties the checkbox set; `refresh()` re-fires the current fetch.
|
|
@@ -134,25 +193,180 @@ export interface BulkActionContext {
|
|
|
134
193
|
clearSelection: () => void;
|
|
135
194
|
}
|
|
136
195
|
|
|
196
|
+
/**
|
|
197
|
+
* A bulk action that is a button: one click, one handler over the selection.
|
|
198
|
+
*/
|
|
137
199
|
export interface BulkAction<T> {
|
|
138
200
|
label: string;
|
|
139
201
|
icon?: IconType;
|
|
140
202
|
onClick: (selected: T[], ctx: BulkActionContext) => void | Promise<void>;
|
|
141
203
|
destructive?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Whether the action is offered for this selection. Absent means always.
|
|
206
|
+
*
|
|
207
|
+
* Hide, not disable: a disabled button in a three-item pill is a question
|
|
208
|
+
* ("why can't I?"), a missing one is an answer. An action that applies to
|
|
209
|
+
* some of the rows and not others should stay visible and act on the rows
|
|
210
|
+
* it fits, which is what its `onClick` receives the whole selection for.
|
|
211
|
+
*/
|
|
212
|
+
visible?: (selected: T[]) => boolean;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* A bulk action that is a MENU: the trigger opens a list of choices, each of
|
|
217
|
+
* them a {@link BulkAction} in its own right, and picking one runs its
|
|
218
|
+
* `onClick` over the selection. For "add to release", "move to column",
|
|
219
|
+
* "assign to": one button cannot carry N targets, and the targets are not
|
|
220
|
+
* known when the table renders.
|
|
221
|
+
*
|
|
222
|
+
* `items` produces the choices, synchronously or not. It is called on open
|
|
223
|
+
* intent (pointer enter, focus, or the menu opening, so keyboard and touch
|
|
224
|
+
* are covered) and its result is kept for the life of the selection: a new
|
|
225
|
+
* selection asks again. Both the pending and the failed state are shown
|
|
226
|
+
* inside the menu, and an empty result renders a disabled "nothing to pick"
|
|
227
|
+
* row rather than an empty popup.
|
|
228
|
+
*
|
|
229
|
+
* A union with {@link BulkAction} rather than an optional `items` on it, so
|
|
230
|
+
* a button cannot also be a menu and a menu cannot also be clicked: the two
|
|
231
|
+
* are told apart by `items` being present.
|
|
232
|
+
*
|
|
233
|
+
* ```tsx
|
|
234
|
+
* const addToRelease: BulkMenuAction<Quest> = {
|
|
235
|
+
* label: "Add to release",
|
|
236
|
+
* icon: Flag,
|
|
237
|
+
* // The closure carries the target, so no item type needs a payload.
|
|
238
|
+
* items: () =>
|
|
239
|
+
* releases
|
|
240
|
+
* .filter((release) => !release.releasedAt)
|
|
241
|
+
* .map((release) => ({
|
|
242
|
+
* label: release.tag,
|
|
243
|
+
* onClick: async (quests, ctx) => {
|
|
244
|
+
* await Promise.all(
|
|
245
|
+
* quests.map((quest) => attach(quest.id, release.id)),
|
|
246
|
+
* );
|
|
247
|
+
* ctx.refresh();
|
|
248
|
+
* ctx.clearSelection();
|
|
249
|
+
* },
|
|
250
|
+
* })),
|
|
251
|
+
* };
|
|
252
|
+
*
|
|
253
|
+
* <AlephaTable<Quest> bulkActions={[shelve, addToRelease]} />
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
export interface BulkMenuAction<T> {
|
|
257
|
+
label: string;
|
|
258
|
+
icon?: IconType;
|
|
259
|
+
/**
|
|
260
|
+
* Same contract as {@link BulkAction.visible}.
|
|
261
|
+
*/
|
|
262
|
+
visible?: (selected: T[]) => boolean;
|
|
263
|
+
/**
|
|
264
|
+
* The choices, produced when the menu is about to open. An async producer
|
|
265
|
+
* shows a loading row until it settles; a rejection shows a failure row and
|
|
266
|
+
* the next open tries again.
|
|
267
|
+
*/
|
|
268
|
+
items: () => BulkAction<T>[] | Promise<BulkAction<T>[]>;
|
|
142
269
|
}
|
|
143
270
|
|
|
144
271
|
/**
|
|
145
|
-
* A standalone toolbar
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
272
|
+
* A standalone toolbar action, rendered in the right-hand icon group next to
|
|
273
|
+
* the column picker and separated from the filter area by a divider. Use for
|
|
274
|
+
* table-scoped actions (e.g. "Upload", "New") that aren't tied to a row or a
|
|
275
|
+
* selection.
|
|
276
|
+
*
|
|
277
|
+
* Two forms, chosen per action:
|
|
278
|
+
*
|
|
279
|
+
* - **secondary** (the default): a ghost icon button with the label as its
|
|
280
|
+
* tooltip, matching the built-in column-picker / refresh controls.
|
|
281
|
+
* - **primary** (`primary: true`): a solid `default` button carrying the icon
|
|
282
|
+
* AND the visible label. For the page's one main action, typically its
|
|
283
|
+
* create control: a bare `+` at the same weight as two utility toggles
|
|
284
|
+
* disappears, and the create button is what a reader looks for first.
|
|
285
|
+
* No tooltip, since the label is already on screen. Below the `sm`
|
|
286
|
+
* breakpoint the label collapses to the icon and the button keeps its
|
|
287
|
+
* primary colour, so it still reads as the action.
|
|
150
288
|
*/
|
|
151
289
|
export interface TableAction {
|
|
152
290
|
icon: IconType;
|
|
153
291
|
label: string;
|
|
154
292
|
onClick: () => void;
|
|
155
293
|
disabled?: boolean;
|
|
294
|
+
/**
|
|
295
|
+
* Render as the table's primary action: a solid labelled button rather
|
|
296
|
+
* than a ghost icon. One per table is the intent; a toolbar with two
|
|
297
|
+
* primary buttons has no primary action.
|
|
298
|
+
*/
|
|
299
|
+
primary?: boolean;
|
|
300
|
+
}
|
|
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;
|
|
156
370
|
}
|
|
157
371
|
|
|
158
372
|
/**
|
|
@@ -188,6 +402,32 @@ export interface AlephaTableFilters {
|
|
|
188
402
|
* the right moment for it: that is the reader choosing.
|
|
189
403
|
*/
|
|
190
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[];
|
|
191
431
|
render: (form: FormModel<ZObject>) => ReactNode;
|
|
192
432
|
}
|
|
193
433
|
|
|
@@ -250,6 +490,53 @@ export type AlephaTableSource<T> =
|
|
|
250
490
|
export type AlephaTableProps<T> = AlephaTableBaseProps<T> &
|
|
251
491
|
AlephaTableSource<T>;
|
|
252
492
|
|
|
493
|
+
/**
|
|
494
|
+
* ⚠️ **A page-level action goes INSIDE the table, not above it.**
|
|
495
|
+
*
|
|
496
|
+
* AlephaTable owns a toolbar, and that toolbar is the page's action bar. A
|
|
497
|
+
* "New" button, a picker, an import, an export all belong in it. Putting one
|
|
498
|
+
* in a `CardHeader` above the table produces two stacked bars saying one
|
|
499
|
+
* thing - which is exactly what the epic page's Quests tab looked like until
|
|
500
|
+
* feedback #2006, a hand-rolled header holding a title and an "Attach Quest"
|
|
501
|
+
* button, sitting directly on top of a toolbar holding the column picker and
|
|
502
|
+
* refresh.
|
|
503
|
+
*
|
|
504
|
+
* The rule is written here rather than only on the props because this is
|
|
505
|
+
* where a reader - human or agent - looks first, and the drift comes from
|
|
506
|
+
* not knowing the slot exists rather than from choosing against it.
|
|
507
|
+
*
|
|
508
|
+
* Three slots, and which one is a question about the control, not the action:
|
|
509
|
+
*
|
|
510
|
+
* - `actions` - a button that does something on click. Rendered in the
|
|
511
|
+
* right-hand icon group beside the column picker: a ghost icon with a
|
|
512
|
+
* tooltip from its own `label`, or, with `primary: true`, a solid button
|
|
513
|
+
* showing the label. The page's create action is the `primary` one.
|
|
514
|
+
* - `toolbar` - anything else: a labelled button, a popover trigger, a
|
|
515
|
+
* segmented control, a group of them. Rendered to the right of the filter
|
|
516
|
+
* inputs and vertically centred, so it does not have to match their height.
|
|
517
|
+
* - `bulkActions` - operates on the checkbox selection, and only appears
|
|
518
|
+
* while something is selected. A button, or a menu of them resolved on
|
|
519
|
+
* demand (`BulkMenuAction`, for "add to release" and its kind).
|
|
520
|
+
*
|
|
521
|
+
* ```tsx
|
|
522
|
+
* <AlephaTable<Quest>
|
|
523
|
+
* data={quests}
|
|
524
|
+
* columns={columns}
|
|
525
|
+
* // A popover trigger: `toolbar`, because it is not an icon button.
|
|
526
|
+
* toolbar={<QuestPicker onAttach={attach} />}
|
|
527
|
+
* // Buttons that act on click: `actions`. The create control is `primary`.
|
|
528
|
+
* actions={[
|
|
529
|
+
* { icon: Plus, label: "New quest", primary: true, onClick: create },
|
|
530
|
+
* { icon: Download, label: "Export", onClick: exportAll },
|
|
531
|
+
* ]}
|
|
532
|
+
* />
|
|
533
|
+
* ```
|
|
534
|
+
*
|
|
535
|
+
* The exception is a control that LEAVES the page - a back link, a tab bar,
|
|
536
|
+
* breadcrumbs. Those are navigation, not actions on this table, and belong
|
|
537
|
+
* where the page's other navigation is.
|
|
538
|
+
*/
|
|
539
|
+
|
|
253
540
|
export interface AlephaTableBaseProps<T> {
|
|
254
541
|
/**
|
|
255
542
|
* Column definitions, keyed by the property name they read from.
|
|
@@ -258,13 +545,18 @@ export interface AlephaTableBaseProps<T> {
|
|
|
258
545
|
/**
|
|
259
546
|
* Per-row action menu builder. Return an array of `RowAction` per
|
|
260
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.
|
|
261
551
|
*/
|
|
262
|
-
rowActions?: (item: T) =>
|
|
552
|
+
rowActions?: (item: T) => RowActionEntry<T>[];
|
|
263
553
|
/**
|
|
264
|
-
* Actions applied to selected rows (enables checkbox column).
|
|
265
|
-
*
|
|
554
|
+
* Actions applied to selected rows (enables checkbox column). A
|
|
555
|
+
* {@link BulkAction} is a button whose `onClick` receives
|
|
556
|
+
* `(items, { refresh, clearSelection })`; a {@link BulkMenuAction} is a
|
|
557
|
+
* button that opens a menu of such actions, produced on demand.
|
|
266
558
|
*/
|
|
267
|
-
bulkActions?: BulkAction<T>
|
|
559
|
+
bulkActions?: Array<BulkAction<T> | BulkMenuAction<T>>;
|
|
268
560
|
/**
|
|
269
561
|
* Page size the table opens on. The reader can change it from the footer;
|
|
270
562
|
* with `persistenceKey` set, their choice is remembered and wins over this.
|
|
@@ -325,8 +617,22 @@ export interface AlephaTableBaseProps<T> {
|
|
|
325
617
|
* persisted to `localStorage` under this key. Pick a key that's
|
|
326
618
|
* unique per page and per scope (e.g. `"admin.users"`,
|
|
327
619
|
* `\`lor.board.${campaignId}\``).
|
|
620
|
+
*
|
|
621
|
+
* Narrow what it stores with {@link persist}.
|
|
328
622
|
*/
|
|
329
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;
|
|
330
636
|
/**
|
|
331
637
|
* Hide the built-in column visibility dropdown in the toolbar.
|
|
332
638
|
*/
|
|
@@ -337,7 +643,9 @@ export interface AlephaTableBaseProps<T> {
|
|
|
337
643
|
hideActionsMenu?: boolean;
|
|
338
644
|
/**
|
|
339
645
|
* Extra slot rendered to the right of the filter inputs in the
|
|
340
|
-
* toolbar — typically a "New" / "Create" button
|
|
646
|
+
* toolbar — typically a "New" / "Create" button, or any page-level action
|
|
647
|
+
* that is not a bare icon button (see the note on `AlephaTableProps`: it
|
|
648
|
+
* belongs here rather than in a header above the table).
|
|
341
649
|
*
|
|
342
650
|
* Vertically centred in the bar (`self-center`) regardless of its own
|
|
343
651
|
* height, so it no longer has to match the filter inputs. It used to inherit
|
|
@@ -346,10 +654,11 @@ export interface AlephaTableBaseProps<T> {
|
|
|
346
654
|
*/
|
|
347
655
|
toolbar?: ReactNode;
|
|
348
656
|
/**
|
|
349
|
-
* Standalone
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
657
|
+
* Standalone actions rendered in the toolbar's right-hand icon group,
|
|
658
|
+
* before the column picker and separated from the filter area by a
|
|
659
|
+
* divider. The table renders the button itself, so callers only supply
|
|
660
|
+
* the icon/label/handler: a ghost icon with a tooltip by default, or a
|
|
661
|
+
* solid labelled button when the action is marked `primary`.
|
|
353
662
|
*/
|
|
354
663
|
actions?: TableAction[];
|
|
355
664
|
/**
|
|
@@ -357,12 +666,52 @@ export interface AlephaTableBaseProps<T> {
|
|
|
357
666
|
*/
|
|
358
667
|
className?: string;
|
|
359
668
|
/**
|
|
360
|
-
*
|
|
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}.
|
|
361
676
|
*/
|
|
362
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;
|
|
363
693
|
/**
|
|
364
694
|
* Rich empty-state node rendered when the page is empty — e.g. an icon +
|
|
365
|
-
* 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.
|
|
366
715
|
*/
|
|
367
716
|
empty?: ReactNode;
|
|
368
717
|
/**
|
|
@@ -409,6 +758,50 @@ const readPersisted = <V,>(key: string, suffix: string): V | undefined => {
|
|
|
409
758
|
}
|
|
410
759
|
};
|
|
411
760
|
|
|
761
|
+
/**
|
|
762
|
+
* Reshape persisted filter values that no longer match the schema.
|
|
763
|
+
*
|
|
764
|
+
* Filters are stored in localStorage per `persistenceKey`, so a filter whose
|
|
765
|
+
* shape changes meets values written by the previous shape - on the machine
|
|
766
|
+
* of anyone who has used the page, and only there, which is precisely the
|
|
767
|
+
* class of bug no test environment contains. The first case was the Quests
|
|
768
|
+
* table going from one value per filter to many (quest #1644): a stored
|
|
769
|
+
* `area: "lore/feedback"` reaching an array field.
|
|
770
|
+
*
|
|
771
|
+
* A scalar where the schema now wants an array is WRAPPED, not dropped: the
|
|
772
|
+
* reader's filter survives the change, which is what makes the migration
|
|
773
|
+
* invisible. The reverse takes the first element, since there is no honest
|
|
774
|
+
* way to keep the rest. Anything else is left alone - this reconciles a
|
|
775
|
+
* container, not a value, and the form's own validation still has the last
|
|
776
|
+
* word.
|
|
777
|
+
*/
|
|
778
|
+
const reconcilePersistedFilters = (
|
|
779
|
+
schema: ZObject | undefined,
|
|
780
|
+
values: Record<string, any> | undefined,
|
|
781
|
+
): Record<string, any> | undefined => {
|
|
782
|
+
if (!schema || !values) return values;
|
|
783
|
+
const shape = z.schema.shape(schema);
|
|
784
|
+
const out: Record<string, any> = {};
|
|
785
|
+
for (const [key, value] of Object.entries(values)) {
|
|
786
|
+
const field = shape[key];
|
|
787
|
+
if (!field) {
|
|
788
|
+
// A filter that no longer exists. Dropped rather than passed through,
|
|
789
|
+
// so a removed field cannot reappear in the fetch payload.
|
|
790
|
+
continue;
|
|
791
|
+
}
|
|
792
|
+
const wantsArray = z.schema.isArray(z.schema.unwrap(field));
|
|
793
|
+
const isArray = Array.isArray(value);
|
|
794
|
+
if (wantsArray && !isArray) {
|
|
795
|
+
out[key] = value === undefined || value === "" ? [] : [value];
|
|
796
|
+
} else if (!wantsArray && isArray) {
|
|
797
|
+
out[key] = value[0];
|
|
798
|
+
} else {
|
|
799
|
+
out[key] = value;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
return out;
|
|
803
|
+
};
|
|
804
|
+
|
|
412
805
|
/**
|
|
413
806
|
* Synchronous localStorage write. Empty objects/null delete the key.
|
|
414
807
|
*/
|
|
@@ -447,21 +840,124 @@ const writePersisted = (key: string, suffix: string, value: unknown): void => {
|
|
|
447
840
|
*/
|
|
448
841
|
export const PAGE_SIZES = [10, 20, 50, 100];
|
|
449
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
|
+
|
|
450
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
|
+
|
|
451
940
|
// State, not a constant. It was `props.defaultSize ?? 20` read once, so a
|
|
452
941
|
// reader had no way to see more rows than the call site had decided for
|
|
453
942
|
// them. Already in `load`'s dependency array, so changing it refetches.
|
|
454
|
-
const [size, setSize] = useState<number>(
|
|
455
|
-
()
|
|
456
|
-
(props.persistenceKey
|
|
457
|
-
? readPersisted<number>(props.persistenceKey, "size")
|
|
458
|
-
: undefined) ??
|
|
459
|
-
props.defaultSize ??
|
|
460
|
-
20,
|
|
943
|
+
const [size, setSize] = useState<number>(() =>
|
|
944
|
+
persistedSize(props.persistenceKey, props.defaultSize),
|
|
461
945
|
);
|
|
462
946
|
const pageSizes = props.pageSizes ?? PAGE_SIZES;
|
|
463
947
|
const alepha = useAlepha();
|
|
464
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();
|
|
465
961
|
|
|
466
962
|
// -- Filter form (internal when `filters` is set, else legacy `form`) -----
|
|
467
963
|
|
|
@@ -469,17 +965,49 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
469
965
|
// first invocation. Reading inside an effect would be too late —
|
|
470
966
|
// useForm captures `initialValues` only once via useMemo.
|
|
471
967
|
const persistedFilterValues = useMemo(() => {
|
|
472
|
-
if (!
|
|
473
|
-
return
|
|
474
|
-
|
|
968
|
+
if (!filtersKey || !props.filters) return undefined;
|
|
969
|
+
return reconcilePersistedFilters(
|
|
970
|
+
props.filters.schema,
|
|
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,
|
|
998
|
+
);
|
|
999
|
+
}, []);
|
|
475
1000
|
|
|
476
1001
|
const mergedFilterInitialValues = useMemo<Record<string, any>>(
|
|
477
1002
|
() => ({
|
|
478
1003
|
...props.filters?.initialValues,
|
|
479
1004
|
...persistedFilterValues,
|
|
480
|
-
//
|
|
481
|
-
//
|
|
482
|
-
//
|
|
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.
|
|
483
1011
|
...props.filters?.seedValues,
|
|
484
1012
|
}),
|
|
485
1013
|
[],
|
|
@@ -517,13 +1045,29 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
517
1045
|
writePersisted(props.persistenceKey, "size", next);
|
|
518
1046
|
}
|
|
519
1047
|
};
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* The footer's page-size picker, as a form of one field.
|
|
1051
|
+
*
|
|
1052
|
+
* `Control` is form-bound and this picker is not part of any form, which is
|
|
1053
|
+
* why the footer stayed on a raw `<Select>` long after everything else here
|
|
1054
|
+
* moved. One field is the whole cost of joining, and it buys the picker the
|
|
1055
|
+
* same trigger, popup and keyboard handling as every other select in the
|
|
1056
|
+
* table. `keepDirty: false` so the re-seed below actually re-seeds: `size`
|
|
1057
|
+
* can move without the picker (a persisted value on mount), and a kept
|
|
1058
|
+
* "edit" would pin the trigger to a page size the table is not using.
|
|
1059
|
+
*/
|
|
1060
|
+
const sizeForm = useForm({
|
|
1061
|
+
schema: z.object({ size: z.number() }),
|
|
1062
|
+
initialValues: { size },
|
|
1063
|
+
keepDirty: false,
|
|
1064
|
+
handler: async () => {},
|
|
1065
|
+
onChange: (_key, next) => changeSize(next as number),
|
|
526
1066
|
});
|
|
1067
|
+
|
|
1068
|
+
const [sort, setSort] = useState<SortState | null>(() =>
|
|
1069
|
+
persistedSort(sortKey, props.defaultSort),
|
|
1070
|
+
);
|
|
527
1071
|
const [fetchedData, setData] = useState<T[]>([]);
|
|
528
1072
|
const [fetchedMeta, setMeta] = useState<Page<T>["page"] | null>(null);
|
|
529
1073
|
const [loading, setLoading] = useState(false);
|
|
@@ -644,9 +1188,9 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
644
1188
|
|
|
645
1189
|
// Persist sort to localStorage on every change.
|
|
646
1190
|
useEffect(() => {
|
|
647
|
-
if (!
|
|
648
|
-
writePersisted(
|
|
649
|
-
}, [
|
|
1191
|
+
if (!sortKey) return;
|
|
1192
|
+
writePersisted(sortKey, "sort", sort);
|
|
1193
|
+
}, [sortKey, sort]);
|
|
650
1194
|
|
|
651
1195
|
// -- Refresh + reset wiring -----------------------------------------------
|
|
652
1196
|
|
|
@@ -687,6 +1231,40 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
687
1231
|
}
|
|
688
1232
|
}, [form, props.filters]);
|
|
689
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
|
+
|
|
690
1268
|
// -- Form event subscriptions ---------------------------------------------
|
|
691
1269
|
|
|
692
1270
|
// Refetch on explicit submit (manual Apply, programmatic submit, etc.).
|
|
@@ -721,31 +1299,28 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
721
1299
|
|
|
722
1300
|
// Persist filter values to localStorage on change.
|
|
723
1301
|
useEffect(() => {
|
|
724
|
-
if (!
|
|
725
|
-
const
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
clean[k] = v;
|
|
732
|
-
}
|
|
733
|
-
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
|
+
);
|
|
734
1309
|
};
|
|
735
1310
|
const unsubs = [
|
|
736
1311
|
alepha.events.on("form:change", (event) => {
|
|
737
1312
|
if (event.id !== form.id) return;
|
|
738
|
-
|
|
1313
|
+
writeFilters();
|
|
739
1314
|
}),
|
|
740
1315
|
alepha.events.on("form:submit:success", (event) => {
|
|
741
1316
|
if (event.id !== form.id) return;
|
|
742
|
-
|
|
1317
|
+
writeFilters();
|
|
743
1318
|
}),
|
|
744
1319
|
];
|
|
745
1320
|
return () => {
|
|
746
1321
|
for (const u of unsubs) u();
|
|
747
1322
|
};
|
|
748
|
-
}, [alepha, form, props.filters,
|
|
1323
|
+
}, [alepha, form, props.filters, filtersKey]);
|
|
749
1324
|
|
|
750
1325
|
// -- Polling ---------------------------------------------------------------
|
|
751
1326
|
|
|
@@ -811,6 +1386,17 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
811
1386
|
clearSelection,
|
|
812
1387
|
} = useTableSelection(data, rowKey);
|
|
813
1388
|
|
|
1389
|
+
// The bulk actions offered for THIS selection: an action's `visible`
|
|
1390
|
+
// predicate reads the selected rows. Computed once, here, so the pill's
|
|
1391
|
+
// contents and the pill's own presence come from the same list.
|
|
1392
|
+
const visibleBulkActions = useMemo(
|
|
1393
|
+
() =>
|
|
1394
|
+
(props.bulkActions ?? []).filter(
|
|
1395
|
+
(action) => action.visible?.(selectedItems) ?? true,
|
|
1396
|
+
),
|
|
1397
|
+
[props.bulkActions, selectedItems],
|
|
1398
|
+
);
|
|
1399
|
+
|
|
814
1400
|
// -- Sort ------------------------------------------------------------------
|
|
815
1401
|
|
|
816
1402
|
const toggleSort = (col: string, def: ColumnDef<T>) => {
|
|
@@ -828,6 +1414,24 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
828
1414
|
});
|
|
829
1415
|
};
|
|
830
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
|
+
|
|
831
1435
|
// -- Column visibility -----------------------------------------------------
|
|
832
1436
|
|
|
833
1437
|
const allColumnKeys = useMemo(
|
|
@@ -835,38 +1439,162 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
835
1439
|
[props.columns],
|
|
836
1440
|
);
|
|
837
1441
|
|
|
838
|
-
const [visibleColumns, setVisibleColumns] = useState<Set<string>>(() =>
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
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
|
+
),
|
|
850
1492
|
);
|
|
851
|
-
}
|
|
1493
|
+
};
|
|
852
1494
|
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
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
|
+
};
|
|
857
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
|
+
}
|
|
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
|
+
*/
|
|
858
1582
|
const toggleColumn = (id: string) => {
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
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
|
+
}
|
|
865
1590
|
};
|
|
866
1591
|
|
|
867
1592
|
// -- Render ---------------------------------------------------------------
|
|
868
1593
|
|
|
869
|
-
|
|
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
|
+
>;
|
|
870
1598
|
const visibleCols = cols.filter(([key]) => visibleColumns.has(key));
|
|
871
1599
|
const hasCheckbox = Boolean(props.bulkActions?.length);
|
|
872
1600
|
const hasRowActions = Boolean(props.rowActions);
|
|
@@ -877,16 +1605,55 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
877
1605
|
[refresh, clearSelection],
|
|
878
1606
|
);
|
|
879
1607
|
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
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;
|
|
889
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
|
+
));
|
|
890
1657
|
|
|
891
1658
|
const showToolbar =
|
|
892
1659
|
Boolean(props.filters) ||
|
|
@@ -928,8 +1695,12 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
928
1695
|
// WHITE wash that leaves the field lighter than the bar. Only the
|
|
929
1696
|
// dark-scoped rule (0,3,0) outranks it, and without it the two
|
|
930
1697
|
// controls disagreed: the trigger went dark, the input stayed light.
|
|
931
|
-
|
|
932
|
-
|
|
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 ? (
|
|
933
1704
|
<form
|
|
934
1705
|
{...form.props}
|
|
935
1706
|
className="flex flex-1 flex-wrap items-end gap-2"
|
|
@@ -963,6 +1734,28 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
963
1734
|
<>
|
|
964
1735
|
{props.actions.map((action) => {
|
|
965
1736
|
const ActionIcon = action.icon;
|
|
1737
|
+
if (action.primary) {
|
|
1738
|
+
// The visible label is the tooltip, so there is
|
|
1739
|
+
// none. `aria-label` keeps the accessible name once
|
|
1740
|
+
// the label collapses below `sm`; `h-9` lines the
|
|
1741
|
+
// button up with the ghost icons beside it.
|
|
1742
|
+
return (
|
|
1743
|
+
<Button
|
|
1744
|
+
key={action.label}
|
|
1745
|
+
type="button"
|
|
1746
|
+
size="sm"
|
|
1747
|
+
className="h-9 px-3"
|
|
1748
|
+
aria-label={action.label}
|
|
1749
|
+
disabled={action.disabled}
|
|
1750
|
+
onClick={action.onClick}
|
|
1751
|
+
>
|
|
1752
|
+
<ActionIcon className="size-4" />
|
|
1753
|
+
<span className="hidden sm:inline">
|
|
1754
|
+
{action.label}
|
|
1755
|
+
</span>
|
|
1756
|
+
</Button>
|
|
1757
|
+
);
|
|
1758
|
+
}
|
|
966
1759
|
return (
|
|
967
1760
|
<Tooltip key={action.label}>
|
|
968
1761
|
<TooltipTrigger
|
|
@@ -992,14 +1785,44 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
992
1785
|
)}
|
|
993
1786
|
</>
|
|
994
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
|
+
)}
|
|
995
1798
|
{showColumnPicker && (
|
|
996
1799
|
<ColumnPicker<T>
|
|
997
1800
|
columns={props.columns}
|
|
1801
|
+
order={orderedKeys}
|
|
998
1802
|
visible={visibleColumns}
|
|
999
1803
|
onToggle={toggleColumn}
|
|
1804
|
+
onReorder={reorderColumn}
|
|
1000
1805
|
/>
|
|
1001
1806
|
)}
|
|
1002
|
-
{
|
|
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}
|
|
1818
|
+
/>
|
|
1819
|
+
)}
|
|
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 && (
|
|
1003
1826
|
<Tooltip>
|
|
1004
1827
|
<TooltipTrigger
|
|
1005
1828
|
render={
|
|
@@ -1057,7 +1880,8 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1057
1880
|
)}
|
|
1058
1881
|
|
|
1059
1882
|
{hasCheckbox &&
|
|
1060
|
-
selection.size > 0 &&
|
|
1883
|
+
selection.size > 0 &&
|
|
1884
|
+
visibleBulkActions.length > 0 && (
|
|
1061
1885
|
// Linear-style floating action pill: fixed at the bottom-center of
|
|
1062
1886
|
// the viewport, dark surface that stays readable in both themes
|
|
1063
1887
|
// because the colors are hard-coded (theme-relative `bg-foreground`
|
|
@@ -1071,7 +1895,17 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1071
1895
|
})}
|
|
1072
1896
|
</span>
|
|
1073
1897
|
<span className="mx-1 h-4 w-px bg-white/20" />
|
|
1074
|
-
{
|
|
1898
|
+
{visibleBulkActions.map((action) => {
|
|
1899
|
+
if ("items" in action) {
|
|
1900
|
+
return (
|
|
1901
|
+
<AlephaTableBulkMenu<T>
|
|
1902
|
+
key={action.label}
|
|
1903
|
+
action={action}
|
|
1904
|
+
selected={selectedItems}
|
|
1905
|
+
ctx={bulkCtx}
|
|
1906
|
+
/>
|
|
1907
|
+
);
|
|
1908
|
+
}
|
|
1075
1909
|
const ActionIcon = action.icon;
|
|
1076
1910
|
return (
|
|
1077
1911
|
<Button
|
|
@@ -1118,14 +1952,46 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1118
1952
|
"flex min-h-0 flex-1 flex-col overflow-auto rounded-md border",
|
|
1119
1953
|
showToolbar && "-mt-2 rounded-t-none border-t-0",
|
|
1120
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",
|
|
1121
1966
|
)}
|
|
1122
1967
|
>
|
|
1123
|
-
|
|
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")}>
|
|
1124
1981
|
{/* `bg-muted`, fully opaque, NOT the base header's `bg-muted/50`:
|
|
1125
1982
|
this header is sticky, so anything translucent lets the rows
|
|
1126
1983
|
scroll visibly through the column labels. Same tint, no
|
|
1127
|
-
transparency.
|
|
1128
|
-
|
|
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)]">
|
|
1129
1995
|
<TableRow>
|
|
1130
1996
|
{hasCheckbox && (
|
|
1131
1997
|
<TableHead className="w-10">
|
|
@@ -1139,35 +2005,50 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1139
2005
|
/>
|
|
1140
2006
|
</TableHead>
|
|
1141
2007
|
)}
|
|
1142
|
-
{visibleCols.map(([key, def]) => {
|
|
2008
|
+
{visibleCols.map(([key, def], index) => {
|
|
1143
2009
|
const sorted =
|
|
1144
2010
|
def.sortable && sort?.field === (def.sortKey ?? key);
|
|
1145
2011
|
return (
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
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
|
|
1171
2052
|
used to appear only once a column WAS sorted,
|
|
1172
2053
|
so an unsorted sortable header and a dead one
|
|
1173
2054
|
were indistinguishable until you happened to
|
|
@@ -1182,25 +2063,96 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1182
2063
|
|
|
1183
2064
|
`aria-hidden` throughout: `aria-sort` on the
|
|
1184
2065
|
`th` already states this to assistive tech. */}
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
2066
|
+
{sorted ? (
|
|
2067
|
+
sort?.direction === "asc" ? (
|
|
2068
|
+
<ArrowUp className="size-3.5" aria-hidden />
|
|
2069
|
+
) : (
|
|
2070
|
+
<ArrowDown className="size-3.5" aria-hidden />
|
|
2071
|
+
)
|
|
1188
2072
|
) : (
|
|
1189
|
-
<
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
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>
|
|
1204
2156
|
);
|
|
1205
2157
|
})}
|
|
1206
2158
|
{hasRowActions && <TableHead className="w-10" />}
|
|
@@ -1224,19 +2176,37 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1224
2176
|
(hasCheckbox ? 1 : 0) +
|
|
1225
2177
|
(hasRowActions ? 1 : 0)
|
|
1226
2178
|
}
|
|
1227
|
-
|
|
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"
|
|
1228
2192
|
>
|
|
1229
2193
|
{props.empty ?? (
|
|
1230
|
-
<div className="
|
|
1231
|
-
<
|
|
1232
|
-
<p className="text-sm">
|
|
1233
|
-
{
|
|
1234
|
-
String(
|
|
1235
|
-
tr("alephaTable.empty", {
|
|
1236
|
-
default: "No results.",
|
|
1237
|
-
}),
|
|
1238
|
-
)}
|
|
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}
|
|
1239
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}
|
|
1240
2210
|
</div>
|
|
1241
2211
|
)}
|
|
1242
2212
|
</TableCell>
|
|
@@ -1250,6 +2220,10 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1250
2220
|
key={key}
|
|
1251
2221
|
onClick={() => props.onRowClick?.(item)}
|
|
1252
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.
|
|
1253
2227
|
props.onRowClick && "cursor-pointer",
|
|
1254
2228
|
isSelected && "bg-muted/30",
|
|
1255
2229
|
)}
|
|
@@ -1297,50 +2271,72 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1297
2271
|
</Table>
|
|
1298
2272
|
</div>
|
|
1299
2273
|
|
|
1300
|
-
{/*
|
|
1301
|
-
|
|
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)]">
|
|
1302
2286
|
{/* The size picker sits with the count, not in the toolbar above:
|
|
1303
2287
|
this line already answers "how many, where am I", while the
|
|
1304
2288
|
toolbar answers "which rows". Mixing the two turns the toolbar
|
|
1305
2289
|
into a junk drawer. */}
|
|
1306
2290
|
<div className="flex items-center gap-2">
|
|
1307
|
-
{
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
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
|
+
}}
|
|
1318
2316
|
// `bg-background`, because this bar is `bg-muted` and the
|
|
1319
2317
|
// trigger is `bg-transparent` by default: on a plain form
|
|
1320
|
-
// surface that blending is right, on a tinted bar it made
|
|
1321
|
-
//
|
|
1322
|
-
//
|
|
1323
|
-
//
|
|
1324
|
-
//
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
<SelectContent>
|
|
1333
|
-
{pageSizes.map((n) => (
|
|
1334
|
-
<SelectItem key={n} value={String(n)}>
|
|
1335
|
-
{n}
|
|
1336
|
-
</SelectItem>
|
|
1337
|
-
))}
|
|
1338
|
-
</SelectContent>
|
|
1339
|
-
</Select>
|
|
1340
|
-
)}
|
|
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
|
+
)}
|
|
1341
2330
|
<p className="text-muted-foreground text-xs">
|
|
1342
2331
|
{meta
|
|
1343
|
-
?
|
|
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
|
+
}`
|
|
1344
2340
|
: "—"}
|
|
1345
2341
|
</p>
|
|
1346
2342
|
</div>
|
|
@@ -1360,27 +2356,35 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1360
2356
|
)}
|
|
1361
2357
|
/>
|
|
1362
2358
|
</PaginationItem>
|
|
1363
|
-
{
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
>
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
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
|
+
)}
|
|
1384
2388
|
<PaginationItem>
|
|
1385
2389
|
<PaginationNext
|
|
1386
2390
|
href="#"
|
|
@@ -1403,13 +2407,32 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
1403
2407
|
);
|
|
1404
2408
|
}
|
|
1405
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
|
+
*/
|
|
1406
2423
|
function ColumnPicker<T>(props: {
|
|
1407
2424
|
columns: Record<string, ColumnDef<T>>;
|
|
2425
|
+
order: string[];
|
|
1408
2426
|
visible: Set<string>;
|
|
1409
2427
|
onToggle: (key: string) => void;
|
|
2428
|
+
onReorder: (key: string, target: string) => void;
|
|
1410
2429
|
}) {
|
|
1411
2430
|
const { tr } = useI18n();
|
|
1412
|
-
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
|
+
);
|
|
1413
2436
|
const label = tr("alephaTable.toggleColumns", {
|
|
1414
2437
|
default: "Toggle columns",
|
|
1415
2438
|
});
|
|
@@ -1451,15 +2474,64 @@ function ColumnPicker<T>(props: {
|
|
|
1451
2474
|
{tr("alephaTable.columns", { default: "Columns" })}
|
|
1452
2475
|
</DropdownMenuLabel>
|
|
1453
2476
|
<DropdownMenuSeparator />
|
|
1454
|
-
{entries.map(([key, def]) => (
|
|
1455
|
-
<
|
|
2477
|
+
{entries.map(([key, def], index) => (
|
|
2478
|
+
<div
|
|
1456
2479
|
key={key}
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
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
|
+
)}
|
|
1460
2497
|
>
|
|
1461
|
-
|
|
1462
|
-
|
|
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>
|
|
1463
2535
|
))}
|
|
1464
2536
|
</DropdownMenuGroup>
|
|
1465
2537
|
</DropdownMenuContent>
|
|
@@ -1503,13 +2575,25 @@ const SkeletonRows = (props: { rows: number; cols: number }) => {
|
|
|
1503
2575
|
);
|
|
1504
2576
|
};
|
|
1505
2577
|
|
|
2578
|
+
function isRowActionGroup<T>(
|
|
2579
|
+
entry: RowActionEntry<T>,
|
|
2580
|
+
): entry is RowActionGroup<T> {
|
|
2581
|
+
return "children" in entry;
|
|
2582
|
+
}
|
|
2583
|
+
|
|
1506
2584
|
function RowActionsMenu<T>(props: {
|
|
1507
|
-
actions:
|
|
2585
|
+
actions: RowActionEntry<T>[];
|
|
1508
2586
|
item: T;
|
|
1509
2587
|
ctx: RowActionContext;
|
|
1510
2588
|
}) {
|
|
1511
2589
|
const { tr } = useI18n();
|
|
1512
|
-
|
|
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;
|
|
1513
2597
|
return (
|
|
1514
2598
|
<DropdownMenu>
|
|
1515
2599
|
<DropdownMenuTrigger
|
|
@@ -1526,24 +2610,43 @@ function RowActionsMenu<T>(props: {
|
|
|
1526
2610
|
<MoreVertical className="size-4" />
|
|
1527
2611
|
</DropdownMenuTrigger>
|
|
1528
2612
|
<DropdownMenuContent align="end">
|
|
1529
|
-
{
|
|
2613
|
+
{effective.map((action, idx) => {
|
|
1530
2614
|
const Icon = action.icon;
|
|
1531
|
-
|
|
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];
|
|
1532
2638
|
const sep =
|
|
1533
2639
|
idx > 0 &&
|
|
1534
2640
|
action.destructive &&
|
|
1535
|
-
!
|
|
2641
|
+
!(previous && !isRowActionGroup(previous) && previous.destructive);
|
|
1536
2642
|
return (
|
|
1537
2643
|
<span key={action.label}>
|
|
1538
2644
|
{sep && <DropdownMenuSeparator />}
|
|
1539
|
-
<
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
{Icon && <Icon className="mr-2 size-4" />}
|
|
1545
|
-
{action.label}
|
|
1546
|
-
</DropdownMenuItem>
|
|
2645
|
+
<RowActionItem
|
|
2646
|
+
action={action}
|
|
2647
|
+
item={props.item}
|
|
2648
|
+
ctx={props.ctx}
|
|
2649
|
+
/>
|
|
1547
2650
|
</span>
|
|
1548
2651
|
);
|
|
1549
2652
|
})}
|
|
@@ -1551,3 +2654,45 @@ function RowActionsMenu<T>(props: {
|
|
|
1551
2654
|
</DropdownMenu>
|
|
1552
2655
|
);
|
|
1553
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
|
+
}
|