@alepha/ui 0.28.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -2
- package/dist/components/account/account-connections.d.ts.map +1 -1
- package/dist/components/account/account-connections.js +4 -1
- package/dist/components/account/account-connections.js.map +1 -1
- package/dist/components/account/account-delete-dialog.d.ts.map +1 -1
- package/dist/components/account/account-delete-dialog.js +12 -15
- package/dist/components/account/account-delete-dialog.js.map +1 -1
- package/dist/components/account/account-keys.d.ts.map +1 -1
- package/dist/components/account/account-keys.js +22 -28
- package/dist/components/account/account-keys.js.map +1 -1
- package/dist/components/account/account-mfa-dialog.js +1 -4
- package/dist/components/account/account-mfa-dialog.js.map +1 -1
- package/dist/components/account/account-password-dialog.d.ts.map +1 -1
- package/dist/components/account/account-password-dialog.js +11 -14
- package/dist/components/account/account-password-dialog.js.map +1 -1
- package/dist/components/account/account-profile.js +3 -2
- package/dist/components/account/account-profile.js.map +1 -1
- package/dist/components/account/account-router-options.d.ts +38 -0
- package/dist/components/account/account-router-options.d.ts.map +1 -1
- package/dist/components/account/account-router-options.js.map +1 -1
- package/dist/components/account/account-router-page.d.ts +11 -1
- package/dist/components/account/account-router-page.d.ts.map +1 -1
- package/dist/components/account/account-router-page.js +11 -1
- package/dist/components/account/account-router-page.js.map +1 -1
- package/dist/components/account/account-router.d.ts +11 -0
- package/dist/components/account/account-router.d.ts.map +1 -1
- package/dist/components/account/account-router.js +16 -5
- package/dist/components/account/account-router.js.map +1 -1
- package/dist/components/admin/admin-audits.d.ts.map +1 -1
- package/dist/components/admin/admin-audits.js +91 -34
- package/dist/components/admin/admin-audits.js.map +1 -1
- package/dist/components/admin/admin-files.d.ts.map +1 -1
- package/dist/components/admin/admin-files.js +6 -17
- package/dist/components/admin/admin-files.js.map +1 -1
- package/dist/components/admin/admin-jobs-executions-panel.d.ts.map +1 -1
- package/dist/components/admin/admin-jobs-executions-panel.js +39 -8
- package/dist/components/admin/admin-jobs-executions-panel.js.map +1 -1
- package/dist/components/admin/admin-jobs-payload-dialog.d.ts +19 -0
- package/dist/components/admin/admin-jobs-payload-dialog.d.ts.map +1 -0
- package/dist/components/admin/admin-jobs-payload-dialog.js +33 -0
- package/dist/components/admin/admin-jobs-payload-dialog.js.map +1 -0
- package/dist/components/admin/admin-keys.d.ts.map +1 -1
- package/dist/components/admin/admin-keys.js +5 -4
- package/dist/components/admin/admin-keys.js.map +1 -1
- package/dist/components/admin/admin-notifications-channel-label.d.ts +14 -0
- package/dist/components/admin/admin-notifications-channel-label.d.ts.map +1 -0
- package/dist/components/admin/admin-notifications-channel-label.js +26 -0
- package/dist/components/admin/admin-notifications-channel-label.js.map +1 -0
- package/dist/components/admin/admin-notifications-preview-body.d.ts.map +1 -1
- package/dist/components/admin/admin-notifications-preview-body.js +23 -13
- package/dist/components/admin/admin-notifications-preview-body.js.map +1 -1
- package/dist/components/admin/admin-notifications.d.ts.map +1 -1
- package/dist/components/admin/admin-notifications.js +11 -12
- package/dist/components/admin/admin-notifications.js.map +1 -1
- package/dist/components/admin/admin-payments.d.ts.map +1 -1
- package/dist/components/admin/admin-payments.js +9 -7
- package/dist/components/admin/admin-payments.js.map +1 -1
- package/dist/components/admin/admin-router-options.d.ts +12 -0
- package/dist/components/admin/admin-router-options.d.ts.map +1 -1
- package/dist/components/admin/admin-router-options.js.map +1 -1
- package/dist/components/admin/admin-router.d.ts +5 -8
- package/dist/components/admin/admin-router.d.ts.map +1 -1
- package/dist/components/admin/admin-router.js +6 -29
- package/dist/components/admin/admin-router.js.map +1 -1
- package/dist/components/admin/admin-sessions.d.ts.map +1 -1
- package/dist/components/admin/admin-sessions.js +9 -7
- package/dist/components/admin/admin-sessions.js.map +1 -1
- package/dist/components/admin/admin-user-detail-audits-tab.d.ts.map +1 -1
- package/dist/components/admin/admin-user-detail-audits-tab.js +5 -4
- package/dist/components/admin/admin-user-detail-audits-tab.js.map +1 -1
- package/dist/components/admin/admin-user-detail-sessions-tab.d.ts.map +1 -1
- package/dist/components/admin/admin-user-detail-sessions-tab.js +7 -5
- package/dist/components/admin/admin-user-detail-sessions-tab.js.map +1 -1
- package/dist/components/admin/admin-user-detail.js +3 -2
- package/dist/components/admin/admin-user-detail.js.map +1 -1
- package/dist/components/admin/admin-users-roles-picker.d.ts.map +1 -1
- package/dist/components/admin/admin-users-roles-picker.js.map +1 -1
- package/dist/components/admin/admin-users.d.ts.map +1 -1
- package/dist/components/admin/admin-users.js +6 -4
- package/dist/components/admin/admin-users.js.map +1 -1
- package/dist/components/admin/analytics/AnalyticsChartBars.js +2 -1
- package/dist/components/admin/analytics/AnalyticsChartBars.js.map +1 -1
- package/dist/components/admin/parameter-history-item.d.ts.map +1 -1
- package/dist/components/admin/parameter-history-item.js +3 -2
- package/dist/components/admin/parameter-history-item.js.map +1 -1
- package/dist/components/alepha-table/alepha-table-bulk-menu.js +2 -1
- package/dist/components/alepha-table/alepha-table-bulk-menu.js.map +1 -1
- package/dist/components/alepha-table/alepha-table-filter-dialog.d.ts +60 -0
- package/dist/components/alepha-table/alepha-table-filter-dialog.d.ts.map +1 -0
- package/dist/components/alepha-table/alepha-table-filter-dialog.js +88 -0
- package/dist/components/alepha-table/alepha-table-filter-dialog.js.map +1 -0
- package/dist/components/alepha-table/alepha-table-filter-menu.d.ts +35 -0
- package/dist/components/alepha-table/alepha-table-filter-menu.d.ts.map +1 -0
- package/dist/components/alepha-table/alepha-table-filter-menu.js +54 -0
- package/dist/components/alepha-table/alepha-table-filter-menu.js.map +1 -0
- package/dist/components/alepha-table/alepha-table.d.ts +188 -3
- package/dist/components/alepha-table/alepha-table.d.ts.map +1 -1
- package/dist/components/alepha-table/alepha-table.js +551 -162
- package/dist/components/alepha-table/alepha-table.js.map +1 -1
- package/dist/components/alepha-table/query-filters.d.ts +73 -0
- package/dist/components/alepha-table/query-filters.d.ts.map +1 -0
- package/dist/components/alepha-table/query-filters.js +118 -0
- package/dist/components/alepha-table/query-filters.js.map +1 -0
- package/dist/components/app-actions/app-actions.d.ts +21 -0
- package/dist/components/app-actions/app-actions.d.ts.map +1 -1
- package/dist/components/app-actions/app-actions.js +11 -5
- package/dist/components/app-actions/app-actions.js.map +1 -1
- package/dist/components/app-shell/app-shell.d.ts +45 -0
- package/dist/components/app-shell/app-shell.d.ts.map +1 -1
- package/dist/components/app-shell/app-shell.js +119 -16
- package/dist/components/app-shell/app-shell.js.map +1 -1
- package/dist/components/auth/auth-register.js +31 -30
- package/dist/components/auth/auth-register.js.map +1 -1
- package/dist/components/auto-form/auto-form.d.ts.map +1 -1
- package/dist/components/auto-form/auto-form.js +68 -30
- package/dist/components/auto-form/auto-form.js.map +1 -1
- package/dist/components/button-dark/button-dark.d.ts.map +1 -1
- package/dist/components/button-dark/button-dark.js +39 -8
- package/dist/components/button-dark/button-dark.js.map +1 -1
- package/dist/components/button-inbox/button-inbox.d.ts +66 -0
- package/dist/components/button-inbox/button-inbox.d.ts.map +1 -0
- package/dist/components/button-inbox/button-inbox.js +167 -0
- package/dist/components/button-inbox/button-inbox.js.map +1 -0
- package/dist/components/button-inbox/inbox-unread-atom.d.ts +22 -0
- package/dist/components/button-inbox/inbox-unread-atom.d.ts.map +1 -0
- package/dist/components/button-inbox/inbox-unread-atom.js +29 -0
- package/dist/components/button-inbox/inbox-unread-atom.js.map +1 -0
- package/dist/components/button-theme/button-theme.d.ts +4 -3
- package/dist/components/button-theme/button-theme.d.ts.map +1 -1
- package/dist/components/button-theme/button-theme.js +8 -25
- package/dist/components/button-theme/button-theme.js.map +1 -1
- package/dist/components/button-user/button-user.d.ts +19 -0
- package/dist/components/button-user/button-user.d.ts.map +1 -1
- package/dist/components/button-user/button-user.js +1 -1
- package/dist/components/button-user/button-user.js.map +1 -1
- package/dist/components/control/control.d.ts +51 -0
- package/dist/components/control/control.d.ts.map +1 -1
- package/dist/components/control/control.js +49 -5
- package/dist/components/control/control.js.map +1 -1
- package/dist/components/control-array/control-array.js +2 -1
- package/dist/components/control-array/control-array.js.map +1 -1
- package/dist/components/control-date/control-date.d.ts +27 -0
- package/dist/components/control-date/control-date.d.ts.map +1 -1
- package/dist/components/control-date/control-date.js +15 -19
- package/dist/components/control-date/control-date.js.map +1 -1
- package/dist/components/control-date/date-only.d.ts +18 -0
- package/dist/components/control-date/date-only.d.ts.map +1 -0
- package/dist/components/control-date/date-only.js +29 -0
- package/dist/components/control-date/date-only.js.map +1 -0
- package/dist/components/control-date-range/control-date-range.d.ts +56 -0
- package/dist/components/control-date-range/control-date-range.d.ts.map +1 -0
- package/dist/components/control-date-range/control-date-range.js +148 -0
- package/dist/components/control-date-range/control-date-range.js.map +1 -0
- package/dist/components/control-object/control-object.js +2 -1
- package/dist/components/control-object/control-object.js.map +1 -1
- package/dist/components/control-select/control-select.d.ts.map +1 -1
- package/dist/components/control-select/control-select.js +177 -37
- package/dist/components/control-select/control-select.js.map +1 -1
- package/dist/components/control-upload/control-upload.d.ts.map +1 -1
- package/dist/components/control-upload/control-upload.js +1 -11
- package/dist/components/control-upload/control-upload.js.map +1 -1
- package/dist/components/detail/detail-aside.d.ts.map +1 -1
- package/dist/components/detail/detail-aside.js +4 -3
- package/dist/components/detail/detail-aside.js.map +1 -1
- package/dist/components/file-image/file-image.js +2 -1
- package/dist/components/file-image/file-image.js.map +1 -1
- package/dist/components/markdown-view/SpoilerSpan.d.ts +28 -0
- package/dist/components/markdown-view/SpoilerSpan.d.ts.map +1 -0
- package/dist/components/markdown-view/SpoilerSpan.js +53 -0
- package/dist/components/markdown-view/SpoilerSpan.js.map +1 -0
- package/dist/components/markdown-view/diagram/layoutSequence.js +13 -23
- package/dist/components/markdown-view/diagram/layoutSequence.js.map +1 -1
- package/dist/components/markdown-view/diagram/textMetrics.js +2 -2
- package/dist/components/markdown-view/diagram/textMetrics.js.map +1 -1
- package/dist/components/markdown-view/markdown-view.css +44 -0
- package/dist/components/markdown-view/markdown-view.d.ts +12 -0
- package/dist/components/markdown-view/markdown-view.d.ts.map +1 -1
- package/dist/components/markdown-view/markdown-view.js +22 -1
- package/dist/components/markdown-view/markdown-view.js.map +1 -1
- package/dist/components/markdown-view/remarkSpoiler.d.ts +17 -0
- package/dist/components/markdown-view/remarkSpoiler.d.ts.map +1 -0
- package/dist/components/markdown-view/remarkSpoiler.js +117 -0
- package/dist/components/markdown-view/remarkSpoiler.js.map +1 -0
- package/dist/components/permission-matrix/permission-matrix-group-rows.d.ts +34 -0
- package/dist/components/permission-matrix/permission-matrix-group-rows.d.ts.map +1 -0
- package/dist/components/permission-matrix/permission-matrix-group-rows.js +109 -0
- package/dist/components/permission-matrix/permission-matrix-group-rows.js.map +1 -0
- package/dist/components/permission-matrix/permission-matrix.d.ts +145 -0
- package/dist/components/permission-matrix/permission-matrix.d.ts.map +1 -0
- package/dist/components/permission-matrix/permission-matrix.js +113 -0
- package/dist/components/permission-matrix/permission-matrix.js.map +1 -0
- package/dist/components/plate-layout/plate-layout.d.ts +5 -0
- package/dist/components/plate-layout/plate-layout.d.ts.map +1 -1
- package/dist/components/plate-layout/plate-layout.js +2 -1
- package/dist/components/plate-layout/plate-layout.js.map +1 -1
- package/dist/components/plate-layout/plate-tab-bar.d.ts +10 -0
- package/dist/components/plate-layout/plate-tab-bar.d.ts.map +1 -1
- package/dist/components/plate-layout/plate-tab-bar.js +1 -1
- package/dist/components/plate-layout/plate-tab-bar.js.map +1 -1
- package/dist/components/settings/settings-nav.js +2 -1
- package/dist/components/settings/settings-nav.js.map +1 -1
- package/dist/components/time-ago/time-ago.d.ts +57 -0
- package/dist/components/time-ago/time-ago.d.ts.map +1 -0
- package/dist/components/time-ago/time-ago.js +60 -0
- package/dist/components/time-ago/time-ago.js.map +1 -0
- package/dist/components/tree-view/tree-model.d.ts +128 -0
- package/dist/components/tree-view/tree-model.d.ts.map +1 -0
- package/dist/components/tree-view/tree-model.js +226 -0
- package/dist/components/tree-view/tree-model.js.map +1 -0
- package/dist/components/tree-view/tree-view-rename-input.d.ts +31 -0
- package/dist/components/tree-view/tree-view-rename-input.d.ts.map +1 -0
- package/dist/components/tree-view/tree-view-rename-input.js +68 -0
- package/dist/components/tree-view/tree-view-rename-input.js.map +1 -0
- package/dist/components/tree-view/tree-view-resizer.d.ts +38 -0
- package/dist/components/tree-view/tree-view-resizer.d.ts.map +1 -0
- package/dist/components/tree-view/tree-view-resizer.js +73 -0
- package/dist/components/tree-view/tree-view-resizer.js.map +1 -0
- package/dist/components/tree-view/tree-view-row.d.ts +177 -0
- package/dist/components/tree-view/tree-view-row.d.ts.map +1 -0
- package/dist/components/tree-view/tree-view-row.js +241 -0
- package/dist/components/tree-view/tree-view-row.js.map +1 -0
- package/dist/components/tree-view/tree-view.d.ts +186 -0
- package/dist/components/tree-view/tree-view.d.ts.map +1 -0
- package/dist/components/tree-view/tree-view.js +112 -0
- package/dist/components/tree-view/tree-view.js.map +1 -0
- package/dist/components/tree-view/use-tree-state.d.ts +79 -0
- package/dist/components/tree-view/use-tree-state.d.ts.map +1 -0
- package/dist/components/tree-view/use-tree-state.js +93 -0
- package/dist/components/tree-view/use-tree-state.js.map +1 -0
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/select.d.ts +7 -0
- package/dist/components/ui/select.d.ts.map +1 -1
- package/dist/components/ui/select.js +7 -0
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/sidebar.js.map +1 -1
- package/dist/components/ui/table.js.map +1 -1
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/lib/i18n-fr.d.ts.map +1 -1
- package/dist/lib/i18n-fr.js +31 -47
- package/dist/lib/i18n-fr.js.map +1 -1
- package/dist/lib/utils.d.ts +22 -2
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +29 -5
- package/dist/lib/utils.js.map +1 -1
- package/dist/styles.css +255 -0
- package/package.json +13 -14
- package/src/components/account/__tests__/account-router.spec.ts +95 -0
- package/src/components/account/account-connections.tsx +14 -1
- package/src/components/account/account-delete-dialog.tsx +3 -2
- package/src/components/account/account-keys.tsx +11 -4
- package/src/components/account/account-mfa-dialog.tsx +1 -1
- package/src/components/account/account-password-dialog.tsx +3 -2
- package/src/components/account/account-profile.tsx +1 -1
- package/src/components/account/account-router-options.tsx +45 -0
- package/src/components/account/account-router-page.tsx +11 -1
- package/src/components/account/account-router.tsx +23 -6
- package/src/components/admin/__tests__/admin-jobs-payload-dialog.browser.spec.tsx +68 -0
- package/src/components/admin/__tests__/admin-notifications-preview-body.browser.spec.tsx +20 -4
- package/src/components/admin/__tests__/admin-status-labels.browser.spec.tsx +0 -31
- package/src/components/admin/admin-audits.tsx +99 -5
- package/src/components/admin/admin-files.tsx +7 -16
- package/src/components/admin/admin-jobs-executions-panel.tsx +152 -114
- package/src/components/admin/admin-jobs-payload-dialog.tsx +57 -0
- package/src/components/admin/admin-keys.tsx +7 -4
- package/src/components/admin/admin-notifications-channel-label.ts +18 -0
- package/src/components/admin/admin-notifications-preview-body.tsx +7 -2
- package/src/components/admin/admin-notifications.tsx +19 -8
- package/src/components/admin/admin-payments.tsx +7 -4
- package/src/components/admin/admin-router-options.tsx +12 -0
- package/src/components/admin/admin-router.tsx +5 -27
- package/src/components/admin/admin-sessions.tsx +10 -6
- package/src/components/admin/admin-user-detail-audits-tab.tsx +7 -4
- package/src/components/admin/admin-user-detail-sessions-tab.tsx +7 -4
- package/src/components/admin/admin-users-roles-picker.tsx +4 -0
- package/src/components/admin/admin-users.tsx +6 -3
- package/src/components/admin/parameter-history-item.tsx +4 -2
- package/src/components/alepha-table/__tests__/alepha-table-default-hidden.browser.spec.tsx +108 -0
- package/src/components/alepha-table/__tests__/alepha-table-empty-state.browser.spec.tsx +233 -0
- package/src/components/alepha-table/__tests__/alepha-table-persist-facets.browser.spec.tsx +177 -0
- package/src/components/alepha-table/__tests__/alepha-table-persisted-filters.browser.spec.tsx +182 -0
- package/src/components/alepha-table/__tests__/alepha-table-query-seed.browser.spec.tsx +170 -0
- package/src/components/alepha-table/__tests__/alepha-table-row-action-checked.browser.spec.tsx +210 -0
- package/src/components/alepha-table/__tests__/alepha-table-row-action-group.browser.spec.tsx +202 -0
- package/src/components/alepha-table/__tests__/alepha-table-scope.browser.spec.tsx +161 -0
- package/src/components/alepha-table/__tests__/alepha-table-share-filters.browser.spec.tsx +309 -0
- package/src/components/alepha-table/__tests__/query-filters.spec.ts +212 -0
- package/src/components/alepha-table/alepha-table-filter-dialog.tsx +162 -0
- package/src/components/alepha-table/alepha-table-filter-menu.tsx +77 -0
- package/src/components/alepha-table/alepha-table.tsx +1113 -207
- package/src/components/alepha-table/query-filters.ts +159 -0
- package/src/components/app-actions/app-actions.tsx +32 -3
- package/src/components/app-shell/__tests__/sidebar-nav-accordion.browser.spec.tsx +163 -0
- package/src/components/app-shell/app-shell.tsx +255 -12
- package/src/components/auto-form/__tests__/auto-form-settings-card.browser.spec.tsx +1 -1
- package/src/components/auto-form/auto-form.tsx +98 -30
- package/src/components/button-dark/button-dark.tsx +47 -8
- package/src/components/button-inbox/__tests__/button-inbox.browser.spec.tsx +247 -0
- package/src/components/button-inbox/button-inbox.tsx +303 -0
- package/src/components/button-inbox/inbox-unread-atom.ts +27 -0
- package/src/components/button-theme/button-theme.tsx +16 -29
- package/src/components/button-user/__tests__/button-user-avatar.browser.spec.tsx +88 -0
- package/src/components/button-user/button-user.tsx +24 -1
- package/src/components/control/__tests__/control-date-range.browser.spec.tsx +177 -0
- package/src/components/control/control.tsx +119 -12
- package/src/components/control-date/control-date.tsx +117 -22
- package/src/components/control-date/date-only.ts +26 -0
- package/src/components/control-date-range/control-date-range.tsx +250 -0
- package/src/components/control-select/__tests__/control-select-clear-label.browser.spec.tsx +129 -15
- package/src/components/control-select/__tests__/control-select-deselect.browser.spec.tsx +27 -6
- package/src/components/control-select/__tests__/control-select-multi.browser.spec.tsx +204 -1
- package/src/components/control-select/__tests__/control-select-size-minimal.browser.spec.tsx +77 -1
- package/src/components/control-select/control-select.tsx +317 -83
- package/src/components/control-upload/control-upload.tsx +1 -10
- package/src/components/detail/detail-aside.tsx +30 -6
- package/src/components/markdown-view/SpoilerSpan.tsx +66 -0
- package/src/components/markdown-view/__tests__/markdown-view-spoiler.browser.spec.tsx +165 -0
- package/src/components/markdown-view/diagram/textMetrics.spec.ts +1 -1
- package/src/components/markdown-view/diagram/textMetrics.ts +2 -2
- package/src/components/markdown-view/markdown-view.css +44 -0
- package/src/components/markdown-view/markdown-view.tsx +37 -1
- package/src/components/markdown-view/remarkSpoiler.ts +150 -0
- package/src/components/permission-matrix/__tests__/permission-matrix.browser.spec.tsx +237 -0
- package/src/components/permission-matrix/permission-matrix-group-rows.tsx +240 -0
- package/src/components/permission-matrix/permission-matrix.tsx +286 -0
- package/src/components/plate-layout/__tests__/plate-layout.browser.spec.tsx +22 -0
- package/src/components/plate-layout/plate-layout.tsx +6 -0
- package/src/components/plate-layout/plate-tab-bar.tsx +27 -1
- package/src/components/time-ago/time-ago.browser.spec.tsx +110 -0
- package/src/components/time-ago/time-ago.tsx +80 -0
- package/src/components/tree-view/__tests__/tree-model.spec.ts +441 -0
- package/src/components/tree-view/__tests__/tree-view-drag.browser.spec.tsx +295 -0
- package/src/components/tree-view/__tests__/tree-view-rename.browser.spec.tsx +278 -0
- package/src/components/tree-view/__tests__/tree-view-resizer.browser.spec.tsx +112 -0
- package/src/components/tree-view/__tests__/tree-view.browser.spec.tsx +260 -0
- package/src/components/tree-view/__tests__/use-tree-state.browser.spec.tsx +238 -0
- package/src/components/tree-view/tree-model.ts +369 -0
- package/src/components/tree-view/tree-view-rename-input.tsx +95 -0
- package/src/components/tree-view/tree-view-resizer.tsx +83 -0
- package/src/components/tree-view/tree-view-row.tsx +414 -0
- package/src/components/tree-view/tree-view.tsx +300 -0
- package/src/components/tree-view/use-tree-state.ts +184 -0
- package/src/components/ui/button.tsx +79 -1
- package/src/components/ui/dropdown-menu.tsx +1 -1
- package/src/components/ui/select.tsx +7 -0
- package/src/components/ui/table.tsx +1 -1
- package/src/components/ui/tooltip.tsx +1 -1
- package/src/lib/i18n-fr.ts +34 -51
- package/src/lib/utils.ts +32 -4
- package/src/styles.css +255 -0
- package/dist/components/admin/admin-workflows-execution-sheet.d.ts +0 -11
- package/dist/components/admin/admin-workflows-execution-sheet.d.ts.map +0 -1
- package/dist/components/admin/admin-workflows-execution-sheet.js +0 -190
- package/dist/components/admin/admin-workflows-execution-sheet.js.map +0 -1
- package/dist/components/admin/admin-workflows-executions-panel.d.ts +0 -9
- package/dist/components/admin/admin-workflows-executions-panel.d.ts.map +0 -1
- package/dist/components/admin/admin-workflows-executions-panel.js +0 -121
- package/dist/components/admin/admin-workflows-executions-panel.js.map +0 -1
- package/dist/components/admin/admin-workflows-status-badge.d.ts +0 -12
- package/dist/components/admin/admin-workflows-status-badge.d.ts.map +0 -1
- package/dist/components/admin/admin-workflows-status-badge.js +0 -30
- package/dist/components/admin/admin-workflows-status-badge.js.map +0 -1
- package/dist/components/admin/admin-workflows-status-labels.d.ts +0 -19
- package/dist/components/admin/admin-workflows-status-labels.d.ts.map +0 -1
- package/dist/components/admin/admin-workflows-status-labels.js +0 -48
- package/dist/components/admin/admin-workflows-status-labels.js.map +0 -1
- package/dist/components/admin/admin-workflows.d.ts +0 -4
- package/dist/components/admin/admin-workflows.d.ts.map +0 -1
- package/dist/components/admin/admin-workflows.js +0 -145
- package/dist/components/admin/admin-workflows.js.map +0 -1
- package/src/components/admin/admin-workflows-execution-sheet.tsx +0 -285
- package/src/components/admin/admin-workflows-executions-panel.tsx +0 -169
- package/src/components/admin/admin-workflows-status-badge.tsx +0 -41
- package/src/components/admin/admin-workflows-status-labels.ts +0 -51
- package/src/components/admin/admin-workflows.tsx +0 -209
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { IconComponent } from "@alepha/ui/components/control-base/icon-hint";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
export interface PermissionMatrixProps {
|
|
4
|
+
/**
|
|
5
|
+
* The rows, already grouped and already filtered.
|
|
6
|
+
*
|
|
7
|
+
* ⚠️ **Filtering is the caller's job.** Lore hides the permissions of a
|
|
8
|
+
* capability that is switched off; Alepha Club has no capability concept and
|
|
9
|
+
* shows all of its groups. A `capabilities` prop here would be a
|
|
10
|
+
* Lore-shaped idea that every other consumer passes `undefined` to forever,
|
|
11
|
+
* so this component renders the groups it is handed and asks nothing about
|
|
12
|
+
* where they came from.
|
|
13
|
+
*/
|
|
14
|
+
groups: PermissionMatrixGroup[];
|
|
15
|
+
/**
|
|
16
|
+
* The columns, left to right. One per rank.
|
|
17
|
+
*/
|
|
18
|
+
columns: PermissionMatrixColumn[];
|
|
19
|
+
/**
|
|
20
|
+
* What each column currently grants, keyed by {@link PermissionMatrixColumn.key}.
|
|
21
|
+
*
|
|
22
|
+
* A column missing from the record grants nothing, which is the same thing
|
|
23
|
+
* as an empty array - a caller building this from a server response does not
|
|
24
|
+
* have to fill in the ranks that hold no permission.
|
|
25
|
+
*/
|
|
26
|
+
value: Record<string, readonly string[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Called with the WHOLE record on every tick, not with a delta.
|
|
29
|
+
*
|
|
30
|
+
* The caller owns the save, so the module's refusals ("that set is wider
|
|
31
|
+
* than your own") arrive as ordinary form errors on the page rather than as
|
|
32
|
+
* a state this component would have to model.
|
|
33
|
+
*/
|
|
34
|
+
onChange: (next: Record<string, string[]>) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Header above the permission column. A label, not a placeholder: the
|
|
37
|
+
* component carries no copy of its own.
|
|
38
|
+
*/
|
|
39
|
+
header?: ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* Shown in place of the table when {@link groups} is empty - every
|
|
42
|
+
* capability off, or a filter that matched nothing.
|
|
43
|
+
*/
|
|
44
|
+
empty?: ReactNode;
|
|
45
|
+
/**
|
|
46
|
+
* Turns every cell off, on top of whatever the columns and rows say.
|
|
47
|
+
* A save in flight, or a reader who may look and not edit.
|
|
48
|
+
*/
|
|
49
|
+
disabled?: boolean;
|
|
50
|
+
className?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Who may do what, as a table: permissions down the left, one column per rank,
|
|
54
|
+
* a checkbox at each crossing.
|
|
55
|
+
*
|
|
56
|
+
* It lives here rather than in either application because two of them need the
|
|
57
|
+
* same table. Lore renders it for a project's ranks; Alepha Club renders it for
|
|
58
|
+
* the club's. What differs between them is entirely in the props.
|
|
59
|
+
*
|
|
60
|
+
* ## What the component deliberately does not know
|
|
61
|
+
*
|
|
62
|
+
* **It does not know what an owner is.** A column that must read all-on and
|
|
63
|
+
* refuse edits is marked `readOnly` by the caller. Teaching the table about
|
|
64
|
+
* ownership would put an application's model inside a component that two
|
|
65
|
+
* applications with different models both use.
|
|
66
|
+
*
|
|
67
|
+
* **It does not know what a capability is.** See {@link PermissionMatrixProps.groups}.
|
|
68
|
+
*
|
|
69
|
+
* **It carries no copy.** Every label is a `ReactNode` the caller supplies,
|
|
70
|
+
* already translated, so an application whose only locale is French renders a
|
|
71
|
+
* French matrix without this package shipping a catalogue.
|
|
72
|
+
*
|
|
73
|
+
* ## The two kinds of locked row
|
|
74
|
+
*
|
|
75
|
+
* A permission can be non-negotiable in either direction, and both are common
|
|
76
|
+
* enough to be data rather than a caller's own rendering:
|
|
77
|
+
*
|
|
78
|
+
* - `lock: "on"` is a **floor** - the permission every rank holds, so the row
|
|
79
|
+
* is checked everywhere and cannot be unticked (Lore's `project:read`: a
|
|
80
|
+
* member who cannot read the project is not a member).
|
|
81
|
+
* - `lock: "off"` is a **ceiling** - the permission no rank may be granted, so
|
|
82
|
+
* the row is unchecked everywhere and cannot be ticked (Lore's
|
|
83
|
+
* `project:delete`, which belongs to ownership and is transferred rather
|
|
84
|
+
* than granted).
|
|
85
|
+
*
|
|
86
|
+
* A `readOnly` column beats both: an owner column reads all-on including the
|
|
87
|
+
* ceiling rows, because the ceiling describes what may be GRANTED, not what
|
|
88
|
+
* the owner has.
|
|
89
|
+
*/
|
|
90
|
+
export declare const PermissionMatrix: (props: PermissionMatrixProps) => import("react").JSX.Element;
|
|
91
|
+
export interface PermissionMatrixGroup {
|
|
92
|
+
/**
|
|
93
|
+
* Stable identity for the group. Never rendered: {@link label} is.
|
|
94
|
+
*/
|
|
95
|
+
key: string;
|
|
96
|
+
label: ReactNode;
|
|
97
|
+
/**
|
|
98
|
+
* Shown before the label on the heading row. A subject is quicker to find
|
|
99
|
+
* again by its mark than by re-reading four uppercase words, and the heading
|
|
100
|
+
* row is the only thing a reader scans past on the way down a long matrix.
|
|
101
|
+
*
|
|
102
|
+
* Optional, and a group without one simply starts at its label - the heading
|
|
103
|
+
* does not reserve the space, so a matrix that gives icons to none of its
|
|
104
|
+
* groups looks deliberate rather than short of something.
|
|
105
|
+
*/
|
|
106
|
+
icon?: IconComponent;
|
|
107
|
+
permissions: PermissionMatrixRow[];
|
|
108
|
+
}
|
|
109
|
+
export interface PermissionMatrixRow {
|
|
110
|
+
/**
|
|
111
|
+
* The permission as it is stored and sent, e.g. `quest:create`. This is the
|
|
112
|
+
* value that lands in {@link PermissionMatrixProps.value}.
|
|
113
|
+
*/
|
|
114
|
+
name: string;
|
|
115
|
+
label: ReactNode;
|
|
116
|
+
/**
|
|
117
|
+
* Supplementary prose, shown as a tooltip on the label rather than as a
|
|
118
|
+
* line of its own: the line under the label is the permission's stored name,
|
|
119
|
+
* which every row has, and a third line would loosen the whole table for the
|
|
120
|
+
* few rows that carry one.
|
|
121
|
+
*/
|
|
122
|
+
description?: ReactNode;
|
|
123
|
+
/**
|
|
124
|
+
* Pins this row in one state on every column. See the component's doc for
|
|
125
|
+
* why a floor and a ceiling are both worth expressing.
|
|
126
|
+
*/
|
|
127
|
+
lock?: "on" | "off";
|
|
128
|
+
}
|
|
129
|
+
export interface PermissionMatrixColumn {
|
|
130
|
+
/**
|
|
131
|
+
* The key this column's grants are stored under in
|
|
132
|
+
* {@link PermissionMatrixProps.value}. A rank key, for both consumers.
|
|
133
|
+
*/
|
|
134
|
+
key: string;
|
|
135
|
+
label: ReactNode;
|
|
136
|
+
description?: ReactNode;
|
|
137
|
+
/**
|
|
138
|
+
* All-on and not editable.
|
|
139
|
+
*
|
|
140
|
+
* The caller marks it; the component does not know what an owner is, or that
|
|
141
|
+
* such a column exists at all until it is handed one.
|
|
142
|
+
*/
|
|
143
|
+
readOnly?: boolean;
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=permission-matrix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission-matrix.d.ts","sourceRoot":"","sources":["../../../src/components/permission-matrix/permission-matrix.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AASlF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAOvC,MAAM,WAAW,qBAAqB;IACpC;;;;;;;;;OASG;IACH,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAEhC;;OAEG;IACH,OAAO,EAAE,sBAAsB,EAAE,CAAC;IAElC;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IAEzC;;;;;;OAMG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC;IAEnD;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;IAEnB;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAElB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,gCA4G5D,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ,KAAK,EAAE,SAAS,CAAC;IAEjB;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC;IAErB,WAAW,EAAE,mBAAmB,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb,KAAK,EAAE,SAAS,CAAC;IAEjB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IAExB;;;OAGG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,KAAK,CAAC;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ,KAAK,EAAE,SAAS,CAAC;IAEjB,WAAW,CAAC,EAAE,SAAS,CAAC;IAExB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { cn } from "../../lib/utils.js";
|
|
2
|
+
import { Table, TableBody, TableHead, TableHeader, TableRow } from "../ui/table.js";
|
|
3
|
+
import { PermissionMatrixGroupRows, permissionChecked } from "./permission-matrix-group-rows.js";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/permission-matrix/permission-matrix.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Who may do what, as a table: permissions down the left, one column per rank,
|
|
8
|
+
* a checkbox at each crossing.
|
|
9
|
+
*
|
|
10
|
+
* It lives here rather than in either application because two of them need the
|
|
11
|
+
* same table. Lore renders it for a project's ranks; Alepha Club renders it for
|
|
12
|
+
* the club's. What differs between them is entirely in the props.
|
|
13
|
+
*
|
|
14
|
+
* ## What the component deliberately does not know
|
|
15
|
+
*
|
|
16
|
+
* **It does not know what an owner is.** A column that must read all-on and
|
|
17
|
+
* refuse edits is marked `readOnly` by the caller. Teaching the table about
|
|
18
|
+
* ownership would put an application's model inside a component that two
|
|
19
|
+
* applications with different models both use.
|
|
20
|
+
*
|
|
21
|
+
* **It does not know what a capability is.** See {@link PermissionMatrixProps.groups}.
|
|
22
|
+
*
|
|
23
|
+
* **It carries no copy.** Every label is a `ReactNode` the caller supplies,
|
|
24
|
+
* already translated, so an application whose only locale is French renders a
|
|
25
|
+
* French matrix without this package shipping a catalogue.
|
|
26
|
+
*
|
|
27
|
+
* ## The two kinds of locked row
|
|
28
|
+
*
|
|
29
|
+
* A permission can be non-negotiable in either direction, and both are common
|
|
30
|
+
* enough to be data rather than a caller's own rendering:
|
|
31
|
+
*
|
|
32
|
+
* - `lock: "on"` is a **floor** - the permission every rank holds, so the row
|
|
33
|
+
* is checked everywhere and cannot be unticked (Lore's `project:read`: a
|
|
34
|
+
* member who cannot read the project is not a member).
|
|
35
|
+
* - `lock: "off"` is a **ceiling** - the permission no rank may be granted, so
|
|
36
|
+
* the row is unchecked everywhere and cannot be ticked (Lore's
|
|
37
|
+
* `project:delete`, which belongs to ownership and is transferred rather
|
|
38
|
+
* than granted).
|
|
39
|
+
*
|
|
40
|
+
* A `readOnly` column beats both: an owner column reads all-on including the
|
|
41
|
+
* ceiling rows, because the ceiling describes what may be GRANTED, not what
|
|
42
|
+
* the owner has.
|
|
43
|
+
*/
|
|
44
|
+
const PermissionMatrix = (props) => {
|
|
45
|
+
const granted = (columnKey, permission) => (props.value[columnKey] ?? []).includes(permission);
|
|
46
|
+
const toggle = (columnKey, permission, next) => {
|
|
47
|
+
const without = (props.value[columnKey] ?? []).filter((it) => it !== permission);
|
|
48
|
+
props.onChange({
|
|
49
|
+
...Object.fromEntries(Object.entries(props.value).map(([key, list]) => [key, [...list]])),
|
|
50
|
+
[columnKey]: next ? [...without, permission] : without
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
if (props.groups.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
54
|
+
className: "text-muted-foreground p-6 text-center text-sm",
|
|
55
|
+
children: props.empty
|
|
56
|
+
});
|
|
57
|
+
const rows = props.groups.flatMap((group) => group.permissions);
|
|
58
|
+
const coverageOf = (column) => rows.filter((row) => permissionChecked(column, row, granted)).length;
|
|
59
|
+
return /* @__PURE__ */ jsx("div", {
|
|
60
|
+
className: cn("w-full overflow-x-auto", props.className),
|
|
61
|
+
children: /* @__PURE__ */ jsxs(Table, { children: [/* @__PURE__ */ jsx(TableHeader, {
|
|
62
|
+
className: "bg-muted sticky top-0 z-10 shadow-[inset_0_1px_0_0_var(--bevel),inset_0_-1px_0_0_var(--border)]",
|
|
63
|
+
children: /* @__PURE__ */ jsxs(TableRow, {
|
|
64
|
+
className: "hover:bg-transparent",
|
|
65
|
+
children: [/* @__PURE__ */ jsx(TableHead, {
|
|
66
|
+
className: "min-w-56 align-bottom",
|
|
67
|
+
children: props.header
|
|
68
|
+
}), props.columns.map((column) => {
|
|
69
|
+
const held = coverageOf(column);
|
|
70
|
+
return /* @__PURE__ */ jsx(TableHead, {
|
|
71
|
+
className: "border-border/60 h-auto min-w-36 border-l py-2 text-center align-bottom",
|
|
72
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
73
|
+
className: "flex flex-col items-center gap-1",
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ jsx("span", {
|
|
76
|
+
className: "font-medium",
|
|
77
|
+
children: column.label
|
|
78
|
+
}),
|
|
79
|
+
/* @__PURE__ */ jsxs("span", {
|
|
80
|
+
className: "text-muted-foreground text-xs font-normal",
|
|
81
|
+
children: [
|
|
82
|
+
column.description ? /* @__PURE__ */ jsxs(Fragment, { children: [column.description, " · "] }) : null,
|
|
83
|
+
held,
|
|
84
|
+
"/",
|
|
85
|
+
rows.length
|
|
86
|
+
]
|
|
87
|
+
}),
|
|
88
|
+
/* @__PURE__ */ jsx("div", {
|
|
89
|
+
"aria-hidden": true,
|
|
90
|
+
className: "bg-foreground/10 h-1 w-16 overflow-hidden rounded-full",
|
|
91
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
92
|
+
className: "bg-primary h-full rounded-full transition-[width]",
|
|
93
|
+
style: { width: `${rows.length === 0 ? 0 : held / rows.length * 100}%` }
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
]
|
|
97
|
+
})
|
|
98
|
+
}, column.key);
|
|
99
|
+
})]
|
|
100
|
+
})
|
|
101
|
+
}), /* @__PURE__ */ jsx(TableBody, { children: props.groups.map((group) => /* @__PURE__ */ jsx(PermissionMatrixGroupRows, {
|
|
102
|
+
group,
|
|
103
|
+
columns: props.columns,
|
|
104
|
+
disabled: props.disabled === true,
|
|
105
|
+
granted,
|
|
106
|
+
toggle
|
|
107
|
+
}, group.key)) })] })
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
//#endregion
|
|
111
|
+
export { PermissionMatrix };
|
|
112
|
+
|
|
113
|
+
//# sourceMappingURL=permission-matrix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission-matrix.js","names":[],"sources":["../../../src/components/permission-matrix/permission-matrix.tsx"],"sourcesContent":["import type { IconComponent } from \"@alepha/ui/components/control-base/icon-hint\";\nimport {\n Table,\n TableBody,\n TableHead,\n TableHeader,\n TableRow,\n} from \"@alepha/ui/components/ui/table\";\nimport { cn } from \"@alepha/ui/lib/utils\";\nimport type { ReactNode } from \"react\";\n\nimport {\n PermissionMatrixGroupRows,\n permissionChecked,\n} from \"./permission-matrix-group-rows.tsx\";\n\nexport interface PermissionMatrixProps {\n /**\n * The rows, already grouped and already filtered.\n *\n * ⚠️ **Filtering is the caller's job.** Lore hides the permissions of a\n * capability that is switched off; Alepha Club has no capability concept and\n * shows all of its groups. A `capabilities` prop here would be a\n * Lore-shaped idea that every other consumer passes `undefined` to forever,\n * so this component renders the groups it is handed and asks nothing about\n * where they came from.\n */\n groups: PermissionMatrixGroup[];\n\n /**\n * The columns, left to right. One per rank.\n */\n columns: PermissionMatrixColumn[];\n\n /**\n * What each column currently grants, keyed by {@link PermissionMatrixColumn.key}.\n *\n * A column missing from the record grants nothing, which is the same thing\n * as an empty array - a caller building this from a server response does not\n * have to fill in the ranks that hold no permission.\n */\n value: Record<string, readonly string[]>;\n\n /**\n * Called with the WHOLE record on every tick, not with a delta.\n *\n * The caller owns the save, so the module's refusals (\"that set is wider\n * than your own\") arrive as ordinary form errors on the page rather than as\n * a state this component would have to model.\n */\n onChange: (next: Record<string, string[]>) => void;\n\n /**\n * Header above the permission column. A label, not a placeholder: the\n * component carries no copy of its own.\n */\n header?: ReactNode;\n\n /**\n * Shown in place of the table when {@link groups} is empty - every\n * capability off, or a filter that matched nothing.\n */\n empty?: ReactNode;\n\n /**\n * Turns every cell off, on top of whatever the columns and rows say.\n * A save in flight, or a reader who may look and not edit.\n */\n disabled?: boolean;\n\n className?: string;\n}\n\n/**\n * Who may do what, as a table: permissions down the left, one column per rank,\n * a checkbox at each crossing.\n *\n * It lives here rather than in either application because two of them need the\n * same table. Lore renders it for a project's ranks; Alepha Club renders it for\n * the club's. What differs between them is entirely in the props.\n *\n * ## What the component deliberately does not know\n *\n * **It does not know what an owner is.** A column that must read all-on and\n * refuse edits is marked `readOnly` by the caller. Teaching the table about\n * ownership would put an application's model inside a component that two\n * applications with different models both use.\n *\n * **It does not know what a capability is.** See {@link PermissionMatrixProps.groups}.\n *\n * **It carries no copy.** Every label is a `ReactNode` the caller supplies,\n * already translated, so an application whose only locale is French renders a\n * French matrix without this package shipping a catalogue.\n *\n * ## The two kinds of locked row\n *\n * A permission can be non-negotiable in either direction, and both are common\n * enough to be data rather than a caller's own rendering:\n *\n * - `lock: \"on\"` is a **floor** - the permission every rank holds, so the row\n * is checked everywhere and cannot be unticked (Lore's `project:read`: a\n * member who cannot read the project is not a member).\n * - `lock: \"off\"` is a **ceiling** - the permission no rank may be granted, so\n * the row is unchecked everywhere and cannot be ticked (Lore's\n * `project:delete`, which belongs to ownership and is transferred rather\n * than granted).\n *\n * A `readOnly` column beats both: an owner column reads all-on including the\n * ceiling rows, because the ceiling describes what may be GRANTED, not what\n * the owner has.\n */\nexport const PermissionMatrix = (props: PermissionMatrixProps) => {\n const granted = (columnKey: string, permission: string): boolean =>\n (props.value[columnKey] ?? []).includes(permission);\n\n const toggle = (\n columnKey: string,\n permission: string,\n next: boolean,\n ): void => {\n const held = props.value[columnKey] ?? [];\n const without = held.filter((it) => it !== permission);\n\n props.onChange({\n // Every column, not only the one that moved: the caller saves a record\n // and a partial one would silently drop the ranks nobody touched.\n ...Object.fromEntries(\n Object.entries(props.value).map(([key, list]) => [key, [...list]]),\n ),\n [columnKey]: next ? [...without, permission] : without,\n });\n };\n\n if (props.groups.length === 0) {\n return (\n <div className=\"text-muted-foreground p-6 text-center text-sm\">\n {props.empty}\n </div>\n );\n }\n\n // Every row in the table, in order, so a column's coverage is counted over\n // the same set the reader can see. Filtering is the caller's job, so a group\n // that is switched off is not in `groups` and correctly does not count\n // against the ratio.\n const rows = props.groups.flatMap((group) => group.permissions);\n\n const coverageOf = (column: PermissionMatrixColumn): number =>\n rows.filter((row) => permissionChecked(column, row, granted)).length;\n\n return (\n <div className={cn(\"w-full overflow-x-auto\", props.className)}>\n <Table>\n {/* The chrome surface, sticky, so a long matrix keeps its rank names\n while it scrolls. `bg-muted` fully opaque and the two inset lines\n are the same pair `AlephaTable`'s header wears, and for the same\n reasons: a translucent header lets rows scroll through the labels,\n and a border on a sticky `<thead>` is dropped by the collapsed\n border model. */}\n <TableHeader className=\"bg-muted sticky top-0 z-10 shadow-[inset_0_1px_0_0_var(--bevel),inset_0_-1px_0_0_var(--border)]\">\n <TableRow className=\"hover:bg-transparent\">\n <TableHead className=\"min-w-56 align-bottom\">\n {props.header}\n </TableHead>\n {props.columns.map((column) => {\n const held = coverageOf(column);\n\n return (\n <TableHead\n key={column.key}\n className=\"border-border/60 h-auto min-w-36 border-l py-2 text-center align-bottom\"\n >\n <div className=\"flex flex-col items-center gap-1\">\n <span className=\"font-medium\">{column.label}</span>\n {/* The caller's own line and the ratio share one row.\n The ratio is a count, not copy, which is what lets this\n component print it while still shipping no strings:\n `description` carries whatever the application wants\n said (\"1 membre\"), and the separator is punctuation. */}\n <span className=\"text-muted-foreground text-xs font-normal\">\n {column.description ? <>{column.description} · </> : null}\n {held}/{rows.length}\n </span>\n {/* Decorative, and `aria-hidden` for it: the ratio above\n is the same fact in text, and four `role=\"progressbar\"`\n elements announcing a number already read out is noise,\n not access. */}\n <div\n aria-hidden\n className=\"bg-foreground/10 h-1 w-16 overflow-hidden rounded-full\"\n >\n <div\n className=\"bg-primary h-full rounded-full transition-[width]\"\n style={{\n width: `${rows.length === 0 ? 0 : (held / rows.length) * 100}%`,\n }}\n />\n </div>\n </div>\n </TableHead>\n );\n })}\n </TableRow>\n </TableHeader>\n <TableBody>\n {props.groups.map((group) => (\n <PermissionMatrixGroupRows\n key={group.key}\n group={group}\n columns={props.columns}\n disabled={props.disabled === true}\n granted={granted}\n toggle={toggle}\n />\n ))}\n </TableBody>\n </Table>\n </div>\n );\n};\n\nexport interface PermissionMatrixGroup {\n /**\n * Stable identity for the group. Never rendered: {@link label} is.\n */\n key: string;\n\n label: ReactNode;\n\n /**\n * Shown before the label on the heading row. A subject is quicker to find\n * again by its mark than by re-reading four uppercase words, and the heading\n * row is the only thing a reader scans past on the way down a long matrix.\n *\n * Optional, and a group without one simply starts at its label - the heading\n * does not reserve the space, so a matrix that gives icons to none of its\n * groups looks deliberate rather than short of something.\n */\n icon?: IconComponent;\n\n permissions: PermissionMatrixRow[];\n}\n\nexport interface PermissionMatrixRow {\n /**\n * The permission as it is stored and sent, e.g. `quest:create`. This is the\n * value that lands in {@link PermissionMatrixProps.value}.\n */\n name: string;\n\n label: ReactNode;\n\n /**\n * Supplementary prose, shown as a tooltip on the label rather than as a\n * line of its own: the line under the label is the permission's stored name,\n * which every row has, and a third line would loosen the whole table for the\n * few rows that carry one.\n */\n description?: ReactNode;\n\n /**\n * Pins this row in one state on every column. See the component's doc for\n * why a floor and a ceiling are both worth expressing.\n */\n lock?: \"on\" | \"off\";\n}\n\nexport interface PermissionMatrixColumn {\n /**\n * The key this column's grants are stored under in\n * {@link PermissionMatrixProps.value}. A rank key, for both consumers.\n */\n key: string;\n\n label: ReactNode;\n\n description?: ReactNode;\n\n /**\n * All-on and not editable.\n *\n * The caller marks it; the component does not know what an owner is, or that\n * such a column exists at all until it is handed one.\n */\n readOnly?: boolean;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+GA,MAAa,oBAAoB,UAAiC;CAChE,MAAM,WAAW,WAAmB,gBACjC,MAAM,MAAM,cAAc,CAAC,EAAA,CAAG,SAAS,UAAU;CAEpD,MAAM,UACJ,WACA,YACA,SACS;EAET,MAAM,WADO,MAAM,MAAM,cAAc,CAAC,EAAA,CACnB,QAAQ,OAAO,OAAO,UAAU;EAErD,MAAM,SAAS;GAGb,GAAG,OAAO,YACR,OAAO,QAAQ,MAAM,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,UAAU,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CACnE;IACC,YAAY,OAAO,CAAC,GAAG,SAAS,UAAU,IAAI;EACjD,CAAC;CACH;CAEA,IAAI,MAAM,OAAO,WAAW,GAC1B,OACE,oBAAC,OAAD;EAAK,WAAU;EACZ,UAAA,MAAM;CACJ,CAAA;CAQT,MAAM,OAAO,MAAM,OAAO,SAAS,UAAU,MAAM,WAAW;CAE9D,MAAM,cAAc,WAClB,KAAK,QAAQ,QAAQ,kBAAkB,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC;CAEhE,OACE,oBAAC,OAAD;EAAK,WAAW,GAAG,0BAA0B,MAAM,SAAS;EAC1D,UAAA,qBAAC,OAAD,EAAA,UAAA,CAOE,oBAAC,aAAD;GAAa,WAAU;GACrB,UAAA,qBAAC,UAAD;IAAU,WAAU;IAApB,UAAA,CACE,oBAAC,WAAD;KAAW,WAAU;KAClB,UAAA,MAAM;IACE,CAAA,GACV,MAAM,QAAQ,KAAK,WAAW;KAC7B,MAAM,OAAO,WAAW,MAAM;KAE9B,OACE,oBAAC,WAAD;MAEE,WAAU;MAEV,UAAA,qBAAC,OAAD;OAAK,WAAU;OAAf,UAAA;QACE,oBAAC,QAAD;SAAM,WAAU;SAAe,UAAA,OAAO;QAAY,CAAA;QAMlD,qBAAC,QAAD;SAAM,WAAU;SAAhB,UAAA;UACG,OAAO,cAAc,qBAAA,UAAA,EAAA,UAAA,CAAG,OAAO,aAAY,KAAK,EAAA,CAAA,IAAI;UACpD;UAAK;UAAE,KAAK;SACT;;QAKN,oBAAC,OAAD;SACE,eAAA;SACA,WAAU;SAEV,UAAA,oBAAC,OAAD;UACE,WAAU;UACV,OAAO,EACL,OAAO,GAAG,KAAK,WAAW,IAAI,IAAK,OAAO,KAAK,SAAU,IAAI,GAC/D;SACD,CAAA;QACE,CAAA;OACF;;KACI,GA9BJ,OAAO,GA8BH;IAEf,CAAC,CACO;;EACC,CAAA,GACb,oBAAC,WAAD,EAAA,UACG,MAAM,OAAO,KAAK,UACjB,oBAAC,2BAAD;GAES;GACP,SAAS,MAAM;GACf,UAAU,MAAM,aAAa;GACpB;GACD;EACT,GANM,MAAM,GAMZ,CACF,EACQ,CAAA,CACN,EAAA,CAAA;CACJ,CAAA;AAET"}
|
|
@@ -8,6 +8,11 @@ export interface PlateLayoutProps {
|
|
|
8
8
|
* A slot rather than props, because there is no shape common to a release's
|
|
9
9
|
* tag and progress bar, a project's reporting period and an enrolled app's
|
|
10
10
|
* address. What the layout owns is the band, not its contents.
|
|
11
|
+
*
|
|
12
|
+
* Optional, and genuinely so since feedback #2095: a page whose plate would
|
|
13
|
+
* only reprint what the breadcrumb leaf already says is better without one.
|
|
14
|
+
* Omitting it also drops the tab bar's top rule, which exists to separate
|
|
15
|
+
* the tabs from the plate and has nothing to separate them from otherwise.
|
|
11
16
|
*/
|
|
12
17
|
plate?: ReactNode;
|
|
13
18
|
tabs: PlateTab[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plate-layout.d.ts","sourceRoot":"","sources":["../../../src/components/plate-layout/plate-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EAEd,MAAM,kDAAkD,CAAC;AAE1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,gBAAgB;IAC/B
|
|
1
|
+
{"version":3,"file":"plate-layout.d.ts","sourceRoot":"","sources":["../../../src/components/plate-layout/plate-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EAEd,MAAM,kDAAkD,CAAC;AAE1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,UAAW,gBAAgB,gCAwBlD,CAAC"}
|
|
@@ -24,7 +24,8 @@ const PlateLayout = (props) => /* @__PURE__ */ jsxs("div", {
|
|
|
24
24
|
tabs: props.tabs,
|
|
25
25
|
active: props.active,
|
|
26
26
|
onSelect: props.onSelect,
|
|
27
|
-
testId: props.tabsTestId
|
|
27
|
+
testId: props.tabsTestId,
|
|
28
|
+
divided: props.plate !== void 0
|
|
28
29
|
})]
|
|
29
30
|
}), props.scroll === false ? props.children : /* @__PURE__ */ jsx("div", {
|
|
30
31
|
className: "min-h-0 flex-1 overflow-y-auto",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plate-layout.js","names":[],"sources":["../../../src/components/plate-layout/plate-layout.tsx"],"sourcesContent":["import {\n type PlateTab,\n PlateTabBar,\n} from \"@alepha/ui/components/plate-layout/plate-tab-bar\";\nimport { cn } from \"@alepha/ui/lib/utils\";\nimport type { ReactNode } from \"react\";\n\nexport interface PlateLayoutProps {\n /**\n * The band above the tabs: what this page IS. A title, the two or three\n * facts true on every tab, and the actions that act on the whole thing.\n *\n * A slot rather than props, because there is no shape common to a release's\n * tag and progress bar, a project's reporting period and an enrolled app's\n * address. What the layout owns is the band, not its contents.\n */\n plate?: ReactNode;\n tabs: PlateTab[];\n /**\n * The active tab's `key`. For a router-driven bar, the current route name.\n */\n active: string;\n onSelect?: (key: string) => void;\n /**\n * Marks the tab bar for tests. See {@link PlateTabBarProps.testId}.\n */\n tabsTestId?: string;\n /**\n * Whether the layout wraps the body in its own scroll region. Default\n * `true`, which is what keeps the plate still while the content moves.\n *\n * Pass `false` for a tab that owns its scrolling - one with a sticky\n * toolbar of its own, or a reading measure it has to centre. Nesting a\n * scroll region inside a scroll region gives it two.\n */\n scroll?: boolean;\n children: ReactNode;\n className?: string;\n}\n\n/**\n * A full-width plate over a tab strip, and a body that scrolls under both.\n *\n * Lifted from Lore's Release view, which is the shape it names: a page whose\n * identity is several facts wide, with sections that are big enough to be\n * their own view. Distinct from the resource view's left panel and segmented\n * tabs, which is for a page whose identity is one line and whose sections are\n * fields.\n *\n * Deliberately NOT a router: a tab may be a route (`href` on the tab) or a\n * panel swap (`onSelect`), and the layout does not care which. That is what\n * lets Reports and an app's page - which are real nested routes - and the\n * Release view - which is one route with a `?tab=` - share it.\n */\nexport const PlateLayout = (props: PlateLayoutProps) => (\n <div\n className={cn(\n \"flex min-h-0 w-full flex-1 flex-col overflow-hidden\",\n props.className,\n )}\n >\n <div className=\"bg-card/30 border-border shrink-0 border-b\">\n {props.plate}\n <PlateTabBar\n tabs={props.tabs}\n active={props.active}\n onSelect={props.onSelect}\n testId={props.tabsTestId}\n />\n </div>\n\n {props.scroll === false ? (\n props.children\n ) : (\n <div className=\"min-h-0 flex-1 overflow-y-auto\">{props.children}</div>\n )}\n </div>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"plate-layout.js","names":[],"sources":["../../../src/components/plate-layout/plate-layout.tsx"],"sourcesContent":["import {\n type PlateTab,\n PlateTabBar,\n} from \"@alepha/ui/components/plate-layout/plate-tab-bar\";\nimport { cn } from \"@alepha/ui/lib/utils\";\nimport type { ReactNode } from \"react\";\n\nexport interface PlateLayoutProps {\n /**\n * The band above the tabs: what this page IS. A title, the two or three\n * facts true on every tab, and the actions that act on the whole thing.\n *\n * A slot rather than props, because there is no shape common to a release's\n * tag and progress bar, a project's reporting period and an enrolled app's\n * address. What the layout owns is the band, not its contents.\n *\n * Optional, and genuinely so since feedback #2095: a page whose plate would\n * only reprint what the breadcrumb leaf already says is better without one.\n * Omitting it also drops the tab bar's top rule, which exists to separate\n * the tabs from the plate and has nothing to separate them from otherwise.\n */\n plate?: ReactNode;\n tabs: PlateTab[];\n /**\n * The active tab's `key`. For a router-driven bar, the current route name.\n */\n active: string;\n onSelect?: (key: string) => void;\n /**\n * Marks the tab bar for tests. See {@link PlateTabBarProps.testId}.\n */\n tabsTestId?: string;\n /**\n * Whether the layout wraps the body in its own scroll region. Default\n * `true`, which is what keeps the plate still while the content moves.\n *\n * Pass `false` for a tab that owns its scrolling - one with a sticky\n * toolbar of its own, or a reading measure it has to centre. Nesting a\n * scroll region inside a scroll region gives it two.\n */\n scroll?: boolean;\n children: ReactNode;\n className?: string;\n}\n\n/**\n * A full-width plate over a tab strip, and a body that scrolls under both.\n *\n * Lifted from Lore's Release view, which is the shape it names: a page whose\n * identity is several facts wide, with sections that are big enough to be\n * their own view. Distinct from the resource view's left panel and segmented\n * tabs, which is for a page whose identity is one line and whose sections are\n * fields.\n *\n * Deliberately NOT a router: a tab may be a route (`href` on the tab) or a\n * panel swap (`onSelect`), and the layout does not care which. That is what\n * lets Reports and an app's page - which are real nested routes - and the\n * Release view - which is one route with a `?tab=` - share it.\n */\nexport const PlateLayout = (props: PlateLayoutProps) => (\n <div\n className={cn(\n \"flex min-h-0 w-full flex-1 flex-col overflow-hidden\",\n props.className,\n )}\n >\n <div className=\"bg-card/30 border-border shrink-0 border-b\">\n {props.plate}\n <PlateTabBar\n tabs={props.tabs}\n active={props.active}\n onSelect={props.onSelect}\n testId={props.tabsTestId}\n divided={props.plate !== undefined}\n />\n </div>\n\n {props.scroll === false ? (\n props.children\n ) : (\n <div className=\"min-h-0 flex-1 overflow-y-auto\">{props.children}</div>\n )}\n </div>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AA2DA,MAAa,eAAe,UAC1B,qBAAC,OAAD;CACE,WAAW,GACT,uDACA,MAAM,SACR;CAJF,UAAA,CAME,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACG,MAAM,OACP,oBAAC,aAAD;GACE,MAAM,MAAM;GACZ,QAAQ,MAAM;GACd,UAAU,MAAM;GAChB,QAAQ,MAAM;GACd,SAAS,MAAM,UAAU,KAAA;EAC1B,CAAA,CACE;CAEJ,CAAA,GAAA,MAAM,WAAW,QAChB,MAAM,WAEN,oBAAC,OAAD;EAAK,WAAU;EAAkC,UAAA,MAAM;CAAc,CAAA,CAEpE"}
|
|
@@ -42,6 +42,16 @@ export interface PlateTabBarProps {
|
|
|
42
42
|
* BODIES too, and "Settings" is also a project-level nav entry.
|
|
43
43
|
*/
|
|
44
44
|
testId?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Whether to rule off the top edge. Default `true`.
|
|
47
|
+
*
|
|
48
|
+
* The line separates the tabs from the plate above them, so it is only
|
|
49
|
+
* right when there IS one. `PlateLayout` derives this from its own `plate`
|
|
50
|
+
* slot; a bar with no plate above it would otherwise draw a stray line
|
|
51
|
+
* immediately under the container's top edge, which is what a caller
|
|
52
|
+
* omitting the plate for the first time discovered (feedback #2095).
|
|
53
|
+
*/
|
|
54
|
+
divided?: boolean;
|
|
45
55
|
}
|
|
46
56
|
/**
|
|
47
57
|
* Underlined tabs along the bottom edge of a {@link PlateLayout}'s plate.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plate-tab-bar.d.ts","sourceRoot":"","sources":["../../../src/components/plate-layout/plate-tab-bar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAIlF,MAAM,WAAW,QAAQ;IACvB;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB;;;;;;;;;OASG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"plate-tab-bar.d.ts","sourceRoot":"","sources":["../../../src/components/plate-layout/plate-tab-bar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAIlF,MAAM,WAAW,QAAQ;IACvB;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB;;;;;;;;;OASG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,UAAW,gBAAgB,gCA+ElD,CAAC"}
|
|
@@ -14,7 +14,7 @@ const PlateTabBar = (props) => {
|
|
|
14
14
|
const navigates = props.tabs.every((tab) => tab.href !== void 0);
|
|
15
15
|
return /* @__PURE__ */ jsx("div", {
|
|
16
16
|
"data-testid": props.testId,
|
|
17
|
-
className: "border-border
|
|
17
|
+
className: cn("bg-muted border-border flex gap-5 px-6 shadow-[inset_0_1px_0_0_var(--bevel)]", props.divided !== false && "border-t"),
|
|
18
18
|
role: navigates ? "navigation" : "tablist",
|
|
19
19
|
children: props.tabs.map((tab) => {
|
|
20
20
|
const active = tab.key === props.active;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plate-tab-bar.js","names":[],"sources":["../../../src/components/plate-layout/plate-tab-bar.tsx"],"sourcesContent":["import type { IconComponent } from \"@alepha/ui/components/control-base/icon-hint\";\nimport { cn } from \"@alepha/ui/lib/utils\";\nimport { Link } from \"alepha/react/router\";\n\nexport interface PlateTab {\n /**\n * Identifies the tab. Compared against {@link PlateTabBarProps.active}, and\n * handed back to {@link PlateTabBarProps.onSelect}. For a router-driven bar\n * this is the route name.\n */\n key: string;\n label: string;\n icon?: IconComponent;\n /**\n * A trailing count, in a pill of its own rather than folded into the label.\n * The pill's colour follows the tab's state - `text-foreground` active,\n * `text-muted-foreground` not - and a count written into the label would\n * carry one fixed class that is wrong on one of the two. Same reason\n * `Segmented` has a `count` prop.\n *\n * Show it only once its collection has resolved: `undefined` renders the\n * bare label rather than a confident \"0\".\n */\n count?: number;\n /**\n * Makes this tab a NAVIGATION rather than a state change. Present, the tab\n * is a router `Link` and `onSelect` is not called; absent, it is a button.\n *\n * Both shapes exist because both are real: a tab that swaps a panel inside\n * one route is state, and a tab that is its own route has to be a link -\n * middle-click, copy-link and the back button all depend on it.\n */\n href?: string;\n}\n\nexport interface PlateTabBarProps {\n tabs: PlateTab[];\n active: string;\n /**\n * Called for a tab with no `href`. A router-driven bar passes nothing.\n */\n onSelect?: (key: string) => void;\n /**\n * Marks the bar for tests. Worth setting: tab labels are ordinary words\n * (\"Overview\", \"Settings\") that a page-wide `getByRole` finds in the tab\n * BODIES too, and \"Settings\" is also a project-level nav entry.\n */\n testId?: string;\n}\n\n/**\n * Underlined tabs along the bottom edge of a {@link PlateLayout}'s plate.\n *\n * Underlines rather than `Segmented`, which sits inside a toolbar as a\n * control. This bar IS the bottom edge of a full-width band, and a pill group\n * floating on that edge reads as a widget dropped onto the header rather than\n * as the header's own last row.\n */\nexport const PlateTabBar = (props: PlateTabBarProps) => {\n // A bar of links is a NAVIGATION, not a tablist, and its items are links\n // rather than tabs. `role=\"tab\"` on an anchor overrides the implicit link\n // role, which takes it out of `getByRole(\"link\")` and tells a screen reader\n // it swaps a panel when it actually leaves the page. `aria-current=\"page\"`\n // is what marks the current one in a set of navigation links.\n const navigates = props.tabs.every((tab) => tab.href !== undefined);\n\n return (\n <div\n data-testid={props.testId}\n className
|
|
1
|
+
{"version":3,"file":"plate-tab-bar.js","names":[],"sources":["../../../src/components/plate-layout/plate-tab-bar.tsx"],"sourcesContent":["import type { IconComponent } from \"@alepha/ui/components/control-base/icon-hint\";\nimport { cn } from \"@alepha/ui/lib/utils\";\nimport { Link } from \"alepha/react/router\";\n\nexport interface PlateTab {\n /**\n * Identifies the tab. Compared against {@link PlateTabBarProps.active}, and\n * handed back to {@link PlateTabBarProps.onSelect}. For a router-driven bar\n * this is the route name.\n */\n key: string;\n label: string;\n icon?: IconComponent;\n /**\n * A trailing count, in a pill of its own rather than folded into the label.\n * The pill's colour follows the tab's state - `text-foreground` active,\n * `text-muted-foreground` not - and a count written into the label would\n * carry one fixed class that is wrong on one of the two. Same reason\n * `Segmented` has a `count` prop.\n *\n * Show it only once its collection has resolved: `undefined` renders the\n * bare label rather than a confident \"0\".\n */\n count?: number;\n /**\n * Makes this tab a NAVIGATION rather than a state change. Present, the tab\n * is a router `Link` and `onSelect` is not called; absent, it is a button.\n *\n * Both shapes exist because both are real: a tab that swaps a panel inside\n * one route is state, and a tab that is its own route has to be a link -\n * middle-click, copy-link and the back button all depend on it.\n */\n href?: string;\n}\n\nexport interface PlateTabBarProps {\n tabs: PlateTab[];\n active: string;\n /**\n * Called for a tab with no `href`. A router-driven bar passes nothing.\n */\n onSelect?: (key: string) => void;\n /**\n * Marks the bar for tests. Worth setting: tab labels are ordinary words\n * (\"Overview\", \"Settings\") that a page-wide `getByRole` finds in the tab\n * BODIES too, and \"Settings\" is also a project-level nav entry.\n */\n testId?: string;\n /**\n * Whether to rule off the top edge. Default `true`.\n *\n * The line separates the tabs from the plate above them, so it is only\n * right when there IS one. `PlateLayout` derives this from its own `plate`\n * slot; a bar with no plate above it would otherwise draw a stray line\n * immediately under the container's top edge, which is what a caller\n * omitting the plate for the first time discovered (feedback #2095).\n */\n divided?: boolean;\n}\n\n/**\n * Underlined tabs along the bottom edge of a {@link PlateLayout}'s plate.\n *\n * Underlines rather than `Segmented`, which sits inside a toolbar as a\n * control. This bar IS the bottom edge of a full-width band, and a pill group\n * floating on that edge reads as a widget dropped onto the header rather than\n * as the header's own last row.\n */\nexport const PlateTabBar = (props: PlateTabBarProps) => {\n // A bar of links is a NAVIGATION, not a tablist, and its items are links\n // rather than tabs. `role=\"tab\"` on an anchor overrides the implicit link\n // role, which takes it out of `getByRole(\"link\")` and tells a screen reader\n // it swaps a panel when it actually leaves the page. `aria-current=\"page\"`\n // is what marks the current one in a set of navigation links.\n const navigates = props.tabs.every((tab) => tab.href !== undefined);\n\n return (\n <div\n data-testid={props.testId}\n className={cn(\n // The table header's surface, and for the same reason: this strip is\n // chrome, not body. `bg-muted` under a `--bevel` line laid just inside\n // the top edge - two adjacent lines of opposite polarity read as a\n // fold - so the band looks raised out of the page rather than painted\n // onto it. Opaque like the sticky table header, not the base header's\n // `bg-muted/50`: the plate above is already translucent over the page,\n // and stacking a second wash on it makes the two bands differ by a\n // couple of percent instead of reading as one raised object.\n //\n // The border above the bevel is whichever line closes the top edge:\n // the bar's own `border-t` when there is a plate, and the shell\n // header's bottom border when there is not. Both are `--border`, so\n // the fold reads the same either way.\n \"bg-muted border-border flex gap-5 px-6 shadow-[inset_0_1px_0_0_var(--bevel)]\",\n props.divided !== false && \"border-t\",\n )}\n role={navigates ? \"navigation\" : \"tablist\"}\n >\n {props.tabs.map((tab) => {\n const active = tab.key === props.active;\n const className = cn(\n \"-mb-px inline-flex h-[42px] items-center gap-[7px] border-b-2 text-[13.5px] font-medium transition-colors\",\n active\n ? \"border-primary text-foreground\"\n : \"text-muted-foreground hover:text-foreground border-transparent\",\n );\n const body = (\n <>\n {tab.icon && <tab.icon className=\"size-[14px]\" aria-hidden />}\n {tab.label}\n {tab.count !== undefined && (\n <span\n className={cn(\n \"bg-foreground/10 inline-flex h-[18px] min-w-[18px] items-center justify-center rounded-full px-[5px] font-mono text-[10.5px]\",\n active ? \"text-foreground\" : \"text-muted-foreground\",\n )}\n >\n {tab.count}\n </span>\n )}\n </>\n );\n\n return tab.href !== undefined ? (\n <Link\n key={tab.key}\n href={tab.href}\n aria-current={active ? \"page\" : undefined}\n className={className}\n >\n {body}\n </Link>\n ) : (\n <button\n key={tab.key}\n type=\"button\"\n role=\"tab\"\n aria-selected={active}\n onClick={() => props.onSelect?.(tab.key)}\n className={className}\n >\n {body}\n </button>\n );\n })}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;AAoEA,MAAa,eAAe,UAA4B;CAMtD,MAAM,YAAY,MAAM,KAAK,OAAO,QAAQ,IAAI,SAAS,KAAA,CAAS;CAElE,OACE,oBAAC,OAAD;EACE,eAAa,MAAM;EACnB,WAAW,GAcT,gFACA,MAAM,YAAY,SAAS,UAC7B;EACA,MAAM,YAAY,eAAe;EAEhC,UAAA,MAAM,KAAK,KAAK,QAAQ;GACvB,MAAM,SAAS,IAAI,QAAQ,MAAM;GACjC,MAAM,YAAY,GAChB,6GACA,SACI,mCACA,gEACN;GACA,MAAM,OACJ,qBAAA,UAAA,EAAA,UAAA;IACG,IAAI,QAAQ,oBAAC,IAAI,MAAL;KAAU,WAAU;KAAc,eAAA;IAAa,CAAA;IAC3D,IAAI;IACJ,IAAI,UAAU,KAAA,KACb,oBAAC,QAAD;KACE,WAAW,GACT,gIACA,SAAS,oBAAoB,uBAC/B;KAEC,UAAA,IAAI;IACD,CAAA;GAER,EAAA,CAAA;GAGJ,OAAO,IAAI,SAAS,KAAA,IAClB,oBAAC,MAAD;IAEE,MAAM,IAAI;IACV,gBAAc,SAAS,SAAS,KAAA;IACrB;IAEV,UAAA;GACG,GANC,IAAI,GAML,IAEN,oBAAC,UAAD;IAEE,MAAK;IACL,MAAK;IACL,iBAAe;IACf,eAAe,MAAM,WAAW,IAAI,GAAG;IAC5B;IAEV,UAAA;GACK,GARD,IAAI,GAQH;EAEZ,CAAC;CACE,CAAA;AAET"}
|
|
@@ -43,7 +43,8 @@ import { Link } from "alepha/react/router";
|
|
|
43
43
|
* the thing to re-align.
|
|
44
44
|
*/
|
|
45
45
|
const SettingsNav = (props) => {
|
|
46
|
-
const
|
|
46
|
+
const size = props.size ?? "sm";
|
|
47
|
+
const entry = cn("flex items-center gap-2 rounded-md px-2 text-left whitespace-nowrap [&_svg]:size-4 [&_svg]:shrink-0", size === "sm" ? "h-7 text-xs" : "h-8 text-sm");
|
|
47
48
|
const groups = useMemo(() => {
|
|
48
49
|
const ordered = [];
|
|
49
50
|
const byKey = /* @__PURE__ */ new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-nav.js","names":[],"sources":["../../../src/components/settings/settings-nav.tsx"],"sourcesContent":["import { cn } from \"@alepha/ui/lib/utils\";\nimport { Link } from \"alepha/react/router\";\nimport { type ReactNode, useMemo } from \"react\";\n\nexport interface SettingsNavItem {\n /**\n * Stable key. The route name when these come from `useNavEntries`.\n */\n name: string;\n\n /**\n * Fully resolved href — every `:param` already substituted. See\n * {@link SettingsNav} for why this component refuses to resolve them itself.\n */\n href: string;\n\n label: ReactNode;\n icon?: ReactNode;\n\n /**\n * Heading this entry sits under. Entries with no group render first, in a\n * block of their own, without a heading.\n */\n group?: string;\n\n /**\n * The current route is on or under this entry.\n */\n active: boolean;\n\n /**\n * Visible but not reachable — rendered muted and inert rather than hidden,\n * so the entry can explain a capability the viewer does not currently have.\n */\n disabled?: boolean;\n}\n\nexport interface SettingsNavProps {\n /**\n * Entries in final display order. Grouping preserves first appearance, so\n * sort before passing — `useNavEntries` already returns them sorted by\n * group order then item order.\n */\n items: SettingsNavItem[];\n\n /**\n * Entry height, matching `SidebarMenuButton`'s own sizes: `sm` is `h-7` with\n * `text-xs`, `default` is `h-8` with `text-sm`.\n *\n * @default \"sm\"\n */\n size?: \"sm\" | \"default\";\n\n className?: string;\n}\n\n/**\n * The left-hand rail of a settings page: a sticky, grouped list of links.\n *\n * ⚠️ **It takes resolved `items`, not a `root` route name, and that is the\n * whole design.** Deriving entries internally from `useNavEntries({ root })`\n * would be a smaller API and works fine for a static subtree such as\n * `/account/*` — but `NavEntry.href` is `page.match`, the raw route\n * *pattern*. Point it at a parameterised subtree like\n * `/:projectSlug/settings/...` and every href in the rail comes out\n * containing a literal `:projectSlug`, which is a dead link that renders\n * perfectly.\n *\n * So resolution is the caller's job and presentation is this component's. A\n * static subtree passes `useNavEntries({ root: \"account\" })` straight through\n * ({@link SettingsNavItem} is structurally a subset of `NavEntry`, so no\n * mapping is needed); a parameterised one passes its own\n * `router.path(name, { params })` list.\n *\n * ### Why this is not built out of `SidebarMenuButton`\n *\n * It reads like the obvious reuse — this rail is a small sidebar, and the\n * sizes and metrics below are deliberately `SidebarMenuButton`'s, so the two\n * look like one family. But the component itself cannot be mounted here:\n *\n * - `SidebarMenuButton` calls `useSidebar()`, which **throws** outside a\n * `SidebarProvider`. Nothing about a static rail needs that provider — it\n * exists to hold collapse state — and mounting one to get a button also\n * registers a global ⌘B handler and starts writing the sidebar cookie. On a\n * page that already sits inside `AppShell` that is a *second* provider, so\n * ⌘B would toggle the wrong sidebar.\n * - Making `useSidebar` tolerate a missing provider, or exporting the button's\n * `cva` to share it, both mean editing `components/ui/sidebar.tsx` — which\n * `yarn w @alepha/ui sync` overwrites wholesale from the upstream registry.\n * The patch would vanish on the next refresh, silently.\n *\n * So the metrics are shared by being written the same, and the coupling is\n * not. If the sizes below ever drift from `sidebarMenuButtonVariants`, that is\n * the thing to re-align.\n */\nexport const SettingsNav = (props: SettingsNavProps) => {\n const size = props.size ?? \"sm\";\n\n /*\n `[&_svg]:size-4` is load-bearing, not cosmetic: `useNavEntries` hands over\n `createElement(Icon)` with no className, and a bare lucide icon defaults to\n 24px — half again the height of the text it sits next to.\n */\n const entry = cn(\n \"flex items-center gap-2 rounded-md px-2 text-left whitespace-nowrap [&_svg]:size-4 [&_svg]:shrink-0\",\n size === \"sm\" ? \"h-7 text-xs\" : \"h-8 text-sm\",\n );\n\n const groups = useMemo(() => {\n const ordered: Array<{ key: string; label?: string }> = [];\n const byKey = new Map<string, SettingsNavItem[]>();\n\n for (const item of props.items) {\n const key = item.group ?? \"\";\n let bucket = byKey.get(key);\n if (!bucket) {\n bucket = [];\n byKey.set(key, bucket);\n ordered.push({ key, label: item.group });\n }\n bucket.push(item);\n }\n\n return ordered.map((g) => ({ ...g, items: byKey.get(g.key) ?? [] }));\n }, [props.items]);\n\n return (\n <nav\n className={cn(\n \"flex shrink-0 flex-col gap-4 md:sticky md:top-0 md:w-48 md:self-start\",\n props.className,\n )}\n >\n {groups.map((group) => (\n <div key={group.key} className=\"flex flex-col gap-0.5\">\n {group.label ? (\n // `px-2` matches the entries below, so the heading and the labels\n // it heads share a left edge.\n <span className=\"text-muted-foreground px-2 text-[11px] font-semibold tracking-wider uppercase\">\n {group.label}\n </span>\n ) : null}\n {group.items.map((item) =>\n item.disabled ? (\n <span\n key={item.name}\n aria-disabled=\"true\"\n className={cn(entry, \"text-muted-foreground/50\")}\n >\n {item.icon}\n {item.label}\n </span>\n ) : (\n <Link\n key={item.name}\n href={item.href}\n aria-current={item.active ? \"page\" : undefined}\n className={cn(\n entry,\n \"transition-colors\",\n item.active\n ? // Same active treatment as `SidebarMenuButton`: the\n // interaction-token fill plus a left bar, not a heavier\n // fill on its own. See the \"Sidebar active item\" block in\n // `styles.css` for why the bar is the part that carries\n // the state: `--sidebar-accent` is spent on hover too, so\n // fill alone renders the current page and the hovered row\n // as one merged shape. Written as utilities here because\n // that CSS keys off `[data-slot=\"sidebar-menu-button\"]`,\n // which this rail deliberately is not (see above).\n \"bg-sidebar-accent text-sidebar-accent-foreground after:bg-sidebar-primary relative font-medium after:absolute after:top-1 after:bottom-1 after:left-0 after:w-[3px] after:rounded-full\"\n : \"text-muted-foreground hover:bg-muted/60\",\n )}\n >\n {item.icon}\n {item.label}\n </Link>\n ),\n )}\n </div>\n ))}\n </nav>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+FA,MAAa,eAAe,UAA4B;
|
|
1
|
+
{"version":3,"file":"settings-nav.js","names":[],"sources":["../../../src/components/settings/settings-nav.tsx"],"sourcesContent":["import { cn } from \"@alepha/ui/lib/utils\";\nimport { Link } from \"alepha/react/router\";\nimport { type ReactNode, useMemo } from \"react\";\n\nexport interface SettingsNavItem {\n /**\n * Stable key. The route name when these come from `useNavEntries`.\n */\n name: string;\n\n /**\n * Fully resolved href — every `:param` already substituted. See\n * {@link SettingsNav} for why this component refuses to resolve them itself.\n */\n href: string;\n\n label: ReactNode;\n icon?: ReactNode;\n\n /**\n * Heading this entry sits under. Entries with no group render first, in a\n * block of their own, without a heading.\n */\n group?: string;\n\n /**\n * The current route is on or under this entry.\n */\n active: boolean;\n\n /**\n * Visible but not reachable — rendered muted and inert rather than hidden,\n * so the entry can explain a capability the viewer does not currently have.\n */\n disabled?: boolean;\n}\n\nexport interface SettingsNavProps {\n /**\n * Entries in final display order. Grouping preserves first appearance, so\n * sort before passing — `useNavEntries` already returns them sorted by\n * group order then item order.\n */\n items: SettingsNavItem[];\n\n /**\n * Entry height, matching `SidebarMenuButton`'s own sizes: `sm` is `h-7` with\n * `text-xs`, `default` is `h-8` with `text-sm`.\n *\n * @default \"sm\"\n */\n size?: \"sm\" | \"default\";\n\n className?: string;\n}\n\n/**\n * The left-hand rail of a settings page: a sticky, grouped list of links.\n *\n * ⚠️ **It takes resolved `items`, not a `root` route name, and that is the\n * whole design.** Deriving entries internally from `useNavEntries({ root })`\n * would be a smaller API and works fine for a static subtree such as\n * `/account/*` — but `NavEntry.href` is `page.match`, the raw route\n * *pattern*. Point it at a parameterised subtree like\n * `/:projectSlug/settings/...` and every href in the rail comes out\n * containing a literal `:projectSlug`, which is a dead link that renders\n * perfectly.\n *\n * So resolution is the caller's job and presentation is this component's. A\n * static subtree passes `useNavEntries({ root: \"account\" })` straight through\n * ({@link SettingsNavItem} is structurally a subset of `NavEntry`, so no\n * mapping is needed); a parameterised one passes its own\n * `router.path(name, { params })` list.\n *\n * ### Why this is not built out of `SidebarMenuButton`\n *\n * It reads like the obvious reuse — this rail is a small sidebar, and the\n * sizes and metrics below are deliberately `SidebarMenuButton`'s, so the two\n * look like one family. But the component itself cannot be mounted here:\n *\n * - `SidebarMenuButton` calls `useSidebar()`, which **throws** outside a\n * `SidebarProvider`. Nothing about a static rail needs that provider — it\n * exists to hold collapse state — and mounting one to get a button also\n * registers a global ⌘B handler and starts writing the sidebar cookie. On a\n * page that already sits inside `AppShell` that is a *second* provider, so\n * ⌘B would toggle the wrong sidebar.\n * - Making `useSidebar` tolerate a missing provider, or exporting the button's\n * `cva` to share it, both mean editing `components/ui/sidebar.tsx` — which\n * `yarn w @alepha/ui sync` overwrites wholesale from the upstream registry.\n * The patch would vanish on the next refresh, silently.\n *\n * So the metrics are shared by being written the same, and the coupling is\n * not. If the sizes below ever drift from `sidebarMenuButtonVariants`, that is\n * the thing to re-align.\n */\nexport const SettingsNav = (props: SettingsNavProps) => {\n const size = props.size ?? \"sm\";\n\n /*\n `[&_svg]:size-4` is load-bearing, not cosmetic: `useNavEntries` hands over\n `createElement(Icon)` with no className, and a bare lucide icon defaults to\n 24px — half again the height of the text it sits next to.\n */\n const entry = cn(\n \"flex items-center gap-2 rounded-md px-2 text-left whitespace-nowrap [&_svg]:size-4 [&_svg]:shrink-0\",\n size === \"sm\" ? \"h-7 text-xs\" : \"h-8 text-sm\",\n );\n\n const groups = useMemo(() => {\n const ordered: Array<{ key: string; label?: string }> = [];\n const byKey = new Map<string, SettingsNavItem[]>();\n\n for (const item of props.items) {\n const key = item.group ?? \"\";\n let bucket = byKey.get(key);\n if (!bucket) {\n bucket = [];\n byKey.set(key, bucket);\n ordered.push({ key, label: item.group });\n }\n bucket.push(item);\n }\n\n return ordered.map((g) => ({ ...g, items: byKey.get(g.key) ?? [] }));\n }, [props.items]);\n\n return (\n <nav\n className={cn(\n \"flex shrink-0 flex-col gap-4 md:sticky md:top-0 md:w-48 md:self-start\",\n props.className,\n )}\n >\n {groups.map((group) => (\n <div key={group.key} className=\"flex flex-col gap-0.5\">\n {group.label ? (\n // `px-2` matches the entries below, so the heading and the labels\n // it heads share a left edge.\n <span className=\"text-muted-foreground px-2 text-[11px] font-semibold tracking-wider uppercase\">\n {group.label}\n </span>\n ) : null}\n {group.items.map((item) =>\n item.disabled ? (\n <span\n key={item.name}\n aria-disabled=\"true\"\n className={cn(entry, \"text-muted-foreground/50\")}\n >\n {item.icon}\n {item.label}\n </span>\n ) : (\n <Link\n key={item.name}\n href={item.href}\n aria-current={item.active ? \"page\" : undefined}\n className={cn(\n entry,\n \"transition-colors\",\n item.active\n ? // Same active treatment as `SidebarMenuButton`: the\n // interaction-token fill plus a left bar, not a heavier\n // fill on its own. See the \"Sidebar active item\" block in\n // `styles.css` for why the bar is the part that carries\n // the state: `--sidebar-accent` is spent on hover too, so\n // fill alone renders the current page and the hovered row\n // as one merged shape. Written as utilities here because\n // that CSS keys off `[data-slot=\"sidebar-menu-button\"]`,\n // which this rail deliberately is not (see above).\n \"bg-sidebar-accent text-sidebar-accent-foreground after:bg-sidebar-primary relative font-medium after:absolute after:top-1 after:bottom-1 after:left-0 after:w-[3px] after:rounded-full\"\n : \"text-muted-foreground hover:bg-muted/60\",\n )}\n >\n {item.icon}\n {item.label}\n </Link>\n ),\n )}\n </div>\n ))}\n </nav>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+FA,MAAa,eAAe,UAA4B;CACtD,MAAM,OAAO,MAAM,QAAQ;CAO3B,MAAM,QAAQ,GACZ,uGACA,SAAS,OAAO,gBAAgB,aAClC;CAEA,MAAM,SAAS,cAAc;EAC3B,MAAM,UAAkD,CAAC;EACzD,MAAM,wBAAQ,IAAI,IAA+B;EAEjD,KAAK,MAAM,QAAQ,MAAM,OAAO;GAC9B,MAAM,MAAM,KAAK,SAAS;GAC1B,IAAI,SAAS,MAAM,IAAI,GAAG;GAC1B,IAAI,CAAC,QAAQ;IACX,SAAS,CAAC;IACV,MAAM,IAAI,KAAK,MAAM;IACrB,QAAQ,KAAK;KAAE;KAAK,OAAO,KAAK;IAAM,CAAC;GACzC;GACA,OAAO,KAAK,IAAI;EAClB;EAEA,OAAO,QAAQ,KAAK,OAAO;GAAE,GAAG;GAAG,OAAO,MAAM,IAAI,EAAE,GAAG,KAAK,CAAC;EAAE,EAAE;CACrE,GAAG,CAAC,MAAM,KAAK,CAAC;CAEhB,OACE,oBAAC,OAAD;EACE,WAAW,GACT,yEACA,MAAM,SACR;EAEC,UAAA,OAAO,KAAK,UACX,qBAAC,OAAD;GAAqB,WAAU;GAA/B,UAAA,CACG,MAAM,QAGL,oBAAC,QAAD;IAAM,WAAU;IACb,UAAA,MAAM;GACH,CAAA,IACJ,MACH,MAAM,MAAM,KAAK,SAChB,KAAK,WACH,qBAAC,QAAD;IAEE,iBAAc;IACd,WAAW,GAAG,OAAO,0BAA0B;IAHjD,UAAA,CAKG,KAAK,MACL,KAAK,KACF;GANC,GAAA,KAAK,IAMN,IAEN,qBAAC,MAAD;IAEE,MAAM,KAAK;IACX,gBAAc,KAAK,SAAS,SAAS,KAAA;IACrC,WAAW,GACT,OACA,qBACA,KAAK,SAUD,2LACA,yCACN;IAnBF,UAAA,CAqBG,KAAK,MACL,KAAK,KACF;GAtBC,GAAA,KAAK,IAsBN,CAEV,CACG;EA7CK,GAAA,MAAM,GA6CX,CACN;CACE,CAAA;AAET"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { DateTime } from "alepha/datetime";
|
|
2
|
+
export interface TimeAgoProps {
|
|
3
|
+
/**
|
|
4
|
+
* The instant. The same set `useI18n().l()` takes, `DateTime` included -
|
|
5
|
+
* `DateTimeProvider.now()` returns one, so a narrower type here would make
|
|
6
|
+
* the component unusable from exactly the place that owns the clock.
|
|
7
|
+
*/
|
|
8
|
+
value: string | number | Date | DateTime;
|
|
9
|
+
/**
|
|
10
|
+
* The exact form, shown on hover and rendered on the server.
|
|
11
|
+
*
|
|
12
|
+
* ⚠️ A dayjs format string, not an `Intl` options bag.
|
|
13
|
+
* `I18nLocalizeOptions` has `date` and `number` only - there is no `time` -
|
|
14
|
+
* so `lll` is how a date AND a time are asked for.
|
|
15
|
+
*/
|
|
16
|
+
format?: string;
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* An instant, read as "2 hours ago", with the exact datetime on hover.
|
|
21
|
+
*
|
|
22
|
+
* ## Why a component and not a fifth spelling
|
|
23
|
+
*
|
|
24
|
+
* There were four ways to write this - `dt.of(x).fromNow()`,
|
|
25
|
+
* `dateFormatter.of(x).fromNow()`, `l(x, { date: "fromNow" })` and
|
|
26
|
+
* `<Localize value={x} date="fromNow" />` - and **none of them carried the
|
|
27
|
+
* exact date**. A tooltip added by hand is a tooltip added to some call sites
|
|
28
|
+
* and forgotten on the rest, which is what the Apps table's Last seen column
|
|
29
|
+
* demonstrated by rendering four rows of `Sep 9, 2026 7:00 PM` and making the
|
|
30
|
+
* reader subtract dates to see whether a copy was alive (feedback #P2174).
|
|
31
|
+
*
|
|
32
|
+
* ## ⚠️ The SSR guard is built in, and that is the point
|
|
33
|
+
*
|
|
34
|
+
* A `fromNow()` string is computed from the clock, so it differs between the
|
|
35
|
+
* server render and hydration and trips React #418. Before this component
|
|
36
|
+
* there were 11 `ClientOnly` guards against 42 relative-time call sites: most
|
|
37
|
+
* were simply unguarded. Putting the guard inside means the next call site
|
|
38
|
+
* cannot forget it.
|
|
39
|
+
*
|
|
40
|
+
* The server renders the EXACT datetime rather than nothing. A crawler, a
|
|
41
|
+
* reader with no JavaScript and the first paint all get a true answer instead
|
|
42
|
+
* of a blank, which matters on `/:projectSlug/roadmap` - the one page Lore
|
|
43
|
+
* server-renders for an audience that may never run the client. The visible
|
|
44
|
+
* swap on hydration is the price, and it is a swap from correct to more
|
|
45
|
+
* readable.
|
|
46
|
+
*
|
|
47
|
+
* ## Where NOT to use it
|
|
48
|
+
*
|
|
49
|
+
* A date somebody CHOSE, rather than one that happened: a release target
|
|
50
|
+
* date, a quest due date. "in 3 months" is not a deadline anyone can plan
|
|
51
|
+
* against, and the relative form actively destroys the information. Relative
|
|
52
|
+
* time is for events - created, updated, last seen, last reported - where the
|
|
53
|
+
* question is "how stale is this" and the answer is the gap, not the date.
|
|
54
|
+
*/
|
|
55
|
+
declare const TimeAgo: (props: TimeAgoProps) => import("react").JSX.Element;
|
|
56
|
+
export default TimeAgo;
|
|
57
|
+
//# sourceMappingURL=time-ago.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-ago.d.ts","sourceRoot":"","sources":["../../../src/components/time-ago/time-ago.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAIhD,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC;IAEzC;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,QAAA,MAAM,OAAO,UAAW,YAAY,gCAiBnC,CAAC;eAEa,OAAO"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useI18n } from "alepha/react/i18n";
|
|
3
|
+
import { ClientOnly } from "alepha/react";
|
|
4
|
+
//#region src/components/time-ago/time-ago.tsx
|
|
5
|
+
/**
|
|
6
|
+
* An instant, read as "2 hours ago", with the exact datetime on hover.
|
|
7
|
+
*
|
|
8
|
+
* ## Why a component and not a fifth spelling
|
|
9
|
+
*
|
|
10
|
+
* There were four ways to write this - `dt.of(x).fromNow()`,
|
|
11
|
+
* `dateFormatter.of(x).fromNow()`, `l(x, { date: "fromNow" })` and
|
|
12
|
+
* `<Localize value={x} date="fromNow" />` - and **none of them carried the
|
|
13
|
+
* exact date**. A tooltip added by hand is a tooltip added to some call sites
|
|
14
|
+
* and forgotten on the rest, which is what the Apps table's Last seen column
|
|
15
|
+
* demonstrated by rendering four rows of `Sep 9, 2026 7:00 PM` and making the
|
|
16
|
+
* reader subtract dates to see whether a copy was alive (feedback #P2174).
|
|
17
|
+
*
|
|
18
|
+
* ## ⚠️ The SSR guard is built in, and that is the point
|
|
19
|
+
*
|
|
20
|
+
* A `fromNow()` string is computed from the clock, so it differs between the
|
|
21
|
+
* server render and hydration and trips React #418. Before this component
|
|
22
|
+
* there were 11 `ClientOnly` guards against 42 relative-time call sites: most
|
|
23
|
+
* were simply unguarded. Putting the guard inside means the next call site
|
|
24
|
+
* cannot forget it.
|
|
25
|
+
*
|
|
26
|
+
* The server renders the EXACT datetime rather than nothing. A crawler, a
|
|
27
|
+
* reader with no JavaScript and the first paint all get a true answer instead
|
|
28
|
+
* of a blank, which matters on `/:projectSlug/roadmap` - the one page Lore
|
|
29
|
+
* server-renders for an audience that may never run the client. The visible
|
|
30
|
+
* swap on hydration is the price, and it is a swap from correct to more
|
|
31
|
+
* readable.
|
|
32
|
+
*
|
|
33
|
+
* ## Where NOT to use it
|
|
34
|
+
*
|
|
35
|
+
* A date somebody CHOSE, rather than one that happened: a release target
|
|
36
|
+
* date, a quest due date. "in 3 months" is not a deadline anyone can plan
|
|
37
|
+
* against, and the relative form actively destroys the information. Relative
|
|
38
|
+
* time is for events - created, updated, last seen, last reported - where the
|
|
39
|
+
* question is "how stale is this" and the answer is the gap, not the date.
|
|
40
|
+
*/
|
|
41
|
+
const TimeAgo = (props) => {
|
|
42
|
+
const { l } = useI18n();
|
|
43
|
+
const exact = String(l(props.value, { date: props.format ?? "lll" }));
|
|
44
|
+
return /* @__PURE__ */ jsx(ClientOnly, {
|
|
45
|
+
fallback: /* @__PURE__ */ jsx("span", {
|
|
46
|
+
className: props.className,
|
|
47
|
+
title: exact,
|
|
48
|
+
children: exact
|
|
49
|
+
}),
|
|
50
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
51
|
+
className: props.className,
|
|
52
|
+
title: exact,
|
|
53
|
+
children: String(l(props.value, { date: "fromNow" }))
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
58
|
+
export { TimeAgo as default };
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=time-ago.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-ago.js","names":[],"sources":["../../../src/components/time-ago/time-ago.tsx"],"sourcesContent":["import type { DateTime } from \"alepha/datetime\";\nimport { ClientOnly } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\n\nexport interface TimeAgoProps {\n /**\n * The instant. The same set `useI18n().l()` takes, `DateTime` included -\n * `DateTimeProvider.now()` returns one, so a narrower type here would make\n * the component unusable from exactly the place that owns the clock.\n */\n value: string | number | Date | DateTime;\n\n /**\n * The exact form, shown on hover and rendered on the server.\n *\n * ⚠️ A dayjs format string, not an `Intl` options bag.\n * `I18nLocalizeOptions` has `date` and `number` only - there is no `time` -\n * so `lll` is how a date AND a time are asked for.\n */\n format?: string;\n\n className?: string;\n}\n\n/**\n * An instant, read as \"2 hours ago\", with the exact datetime on hover.\n *\n * ## Why a component and not a fifth spelling\n *\n * There were four ways to write this - `dt.of(x).fromNow()`,\n * `dateFormatter.of(x).fromNow()`, `l(x, { date: \"fromNow\" })` and\n * `<Localize value={x} date=\"fromNow\" />` - and **none of them carried the\n * exact date**. A tooltip added by hand is a tooltip added to some call sites\n * and forgotten on the rest, which is what the Apps table's Last seen column\n * demonstrated by rendering four rows of `Sep 9, 2026 7:00 PM` and making the\n * reader subtract dates to see whether a copy was alive (feedback #P2174).\n *\n * ## ⚠️ The SSR guard is built in, and that is the point\n *\n * A `fromNow()` string is computed from the clock, so it differs between the\n * server render and hydration and trips React #418. Before this component\n * there were 11 `ClientOnly` guards against 42 relative-time call sites: most\n * were simply unguarded. Putting the guard inside means the next call site\n * cannot forget it.\n *\n * The server renders the EXACT datetime rather than nothing. A crawler, a\n * reader with no JavaScript and the first paint all get a true answer instead\n * of a blank, which matters on `/:projectSlug/roadmap` - the one page Lore\n * server-renders for an audience that may never run the client. The visible\n * swap on hydration is the price, and it is a swap from correct to more\n * readable.\n *\n * ## Where NOT to use it\n *\n * A date somebody CHOSE, rather than one that happened: a release target\n * date, a quest due date. \"in 3 months\" is not a deadline anyone can plan\n * against, and the relative form actively destroys the information. Relative\n * time is for events - created, updated, last seen, last reported - where the\n * question is \"how stale is this\" and the answer is the gap, not the date.\n */\nconst TimeAgo = (props: TimeAgoProps) => {\n const { l } = useI18n();\n const exact = String(l(props.value, { date: props.format ?? \"lll\" }));\n\n return (\n <ClientOnly\n fallback={\n <span className={props.className} title={exact}>\n {exact}\n </span>\n }\n >\n <span className={props.className} title={exact}>\n {String(l(props.value, { date: \"fromNow\" }))}\n </span>\n </ClientOnly>\n );\n};\n\nexport default TimeAgo;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,MAAM,WAAW,UAAwB;CACvC,MAAM,EAAE,MAAM,QAAQ;CACtB,MAAM,QAAQ,OAAO,EAAE,MAAM,OAAO,EAAE,MAAM,MAAM,UAAU,MAAM,CAAC,CAAC;CAEpE,OACE,oBAAC,YAAD;EACE,UACE,oBAAC,QAAD;GAAM,WAAW,MAAM;GAAW,OAAO;GACtC,UAAA;EACG,CAAA;EAGR,UAAA,oBAAC,QAAD;GAAM,WAAW,MAAM;GAAW,OAAO;GACtC,UAAA,OAAO,EAAE,MAAM,OAAO,EAAE,MAAM,UAAU,CAAC,CAAC;EACvC,CAAA;CACI,CAAA;AAEhB"}
|