@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,369 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pure model behind `TreeView`: no React, no DOM, no application
|
|
3
|
+
* vocabulary. A consumer hands in one flat list and gets back a nested tree,
|
|
4
|
+
* a flattened row list for rendering, and the two helpers a drag gesture
|
|
5
|
+
* needs.
|
|
6
|
+
*
|
|
7
|
+
* Extracted from Lore's folio tree, where every rule below was earned.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* One item of the flat list a consumer builds its tree from.
|
|
12
|
+
*
|
|
13
|
+
* `branch` is the only structural distinction the model makes: a branch can
|
|
14
|
+
* hold children and takes part in cycle resolution, a leaf can do neither.
|
|
15
|
+
* Everything domain-specific travels in `data`.
|
|
16
|
+
*/
|
|
17
|
+
export interface TreeItem<T = undefined> {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
parentId?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Can hold children. Only branches take part in cycle resolution, and
|
|
23
|
+
* only a branch accepts an `inside` drop.
|
|
24
|
+
*/
|
|
25
|
+
branch: boolean;
|
|
26
|
+
data?: T;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A node of the built tree.
|
|
31
|
+
*/
|
|
32
|
+
export interface TreeNode<T = undefined> {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
parentId?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Present only on a branch whose `parentId` above was rewritten by
|
|
38
|
+
* cycle-breaking (see `resolveBranchParents`): holds the parent this
|
|
39
|
+
* item's own record actually declares, which is what the consumer's
|
|
40
|
+
* store still has. Absent everywhere else, including a genuinely
|
|
41
|
+
* root-level node, whose `parentId` already IS the true value, so a
|
|
42
|
+
* consumer can tell the two apart (both show `parentId: undefined`)
|
|
43
|
+
* without re-deriving the cycle analysis itself. Leaves never carry
|
|
44
|
+
* this: only a branch's `parentId` can chain into a cycle.
|
|
45
|
+
*/
|
|
46
|
+
declaredParentId?: string;
|
|
47
|
+
branch: boolean;
|
|
48
|
+
data?: T;
|
|
49
|
+
/**
|
|
50
|
+
* Present on every branch (`[]` when empty), absent on a leaf.
|
|
51
|
+
*/
|
|
52
|
+
children?: TreeNode<T>[];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* One visible row: a node plus the depth it is drawn at.
|
|
57
|
+
*/
|
|
58
|
+
export interface TreeRow<T = undefined> {
|
|
59
|
+
node: TreeNode<T>;
|
|
60
|
+
depth: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Where a dragged node landed relative to the row under the cursor.
|
|
65
|
+
*/
|
|
66
|
+
export type TreeDropPosition = "before" | "after" | "inside";
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The only thing a drop can change: a new parent. There is no index, because
|
|
70
|
+
* the model has no sort column to write to: sibling order is derived from the
|
|
71
|
+
* comparator, so `before` and `after` collapse to "same parent as the
|
|
72
|
+
* target".
|
|
73
|
+
*/
|
|
74
|
+
export interface TreeDropTarget {
|
|
75
|
+
parentId: string | undefined;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Sentinel bucket key for the tree root. A caller's ids come from its own
|
|
80
|
+
* store (uuids, slugs), so this never collides with a real one.
|
|
81
|
+
*/
|
|
82
|
+
const ROOT = "__root__";
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Branches sort before leaves at every level; within each group, sort
|
|
86
|
+
* alphabetically by name. Consumers whose server sorts differently pass their
|
|
87
|
+
* own comparator to `buildTree`.
|
|
88
|
+
*/
|
|
89
|
+
const compareTreeNodes = <T>(a: TreeNode<T>, b: TreeNode<T>): number => {
|
|
90
|
+
const aIsBranch = a.branch ? 0 : 1;
|
|
91
|
+
const bIsBranch = b.branch ? 0 : 1;
|
|
92
|
+
if (aIsBranch !== bIsBranch) return aIsBranch - bIsBranch;
|
|
93
|
+
return a.name.localeCompare(b.name);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The effective parent per branch, alongside the branches whose parent that
|
|
98
|
+
* rewrite actually changed.
|
|
99
|
+
*/
|
|
100
|
+
interface ResolvedBranchParents {
|
|
101
|
+
parentId: Map<string, string | undefined>;
|
|
102
|
+
promoted: Set<string>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* For every branch, resolve the parent id to actually use when building the
|
|
107
|
+
* tree.
|
|
108
|
+
*
|
|
109
|
+
* A branch's declared `parentId` is used as-is when it points at a real
|
|
110
|
+
* branch AND following it, then its parent, and so on, reaches the root
|
|
111
|
+
* without revisiting a branch already on the walk. Both other cases fall back
|
|
112
|
+
* to root, the same treatment already given to a `parentId` that points
|
|
113
|
+
* nowhere:
|
|
114
|
+
*
|
|
115
|
+
* - the declared parent does not exist among the branches (stale reference,
|
|
116
|
+
* concurrent delete);
|
|
117
|
+
* - the chain cycles. A server that guards against a direct cycle usually
|
|
118
|
+
* does it as two separate, non-atomic round-trips, and two clients each
|
|
119
|
+
* reading pre-move state can each pass that check independently and
|
|
120
|
+
* together still produce `A.parentId === B.id && B.parentId === A.id`.
|
|
121
|
+
* Bucketing a cyclic branch under its "parent" (which is itself never
|
|
122
|
+
* reachable from root through this chain) would silently drop it, and
|
|
123
|
+
* everything nested under it, leaves included, from the tree the user sees,
|
|
124
|
+
* with no error and no broken row to recover by dragging.
|
|
125
|
+
*
|
|
126
|
+
* When a cycle is found, only the branch where the walk first revisits a node
|
|
127
|
+
* is promoted to root; every other branch on the cycle keeps its own declared
|
|
128
|
+
* parent unchanged. A cycle has no correct direction once it has to be
|
|
129
|
+
* broken, so *which* member becomes the root is a choice: this implementation
|
|
130
|
+
* promotes whichever member the walk reaches first, a deterministic function
|
|
131
|
+
* of the order `items` was given in, not a random pick, but the decision that
|
|
132
|
+
* actually matters is *that* exactly one member is promoted, rather than
|
|
133
|
+
* scattering every member of the cycle to the root as unrelated top-level
|
|
134
|
+
* siblings. Cutting a single edge keeps the rest of the cycle nested exactly
|
|
135
|
+
* as declared, one level under the promoted node, discarding the least
|
|
136
|
+
* structure and leaving the tree closest to whatever was intended before it
|
|
137
|
+
* became corrupted.
|
|
138
|
+
*
|
|
139
|
+
* Returns the effective parent per branch alongside `promoted`: the set of
|
|
140
|
+
* branches where that rewrite actually happened (as opposed to a branch that
|
|
141
|
+
* was already root, or already orphaned by a missing parent). `buildTree`
|
|
142
|
+
* uses `promoted` to record each such branch's true declared parent on its
|
|
143
|
+
* node (`declaredParentId`): the tree's `parentId` alone cannot be trusted to
|
|
144
|
+
* match the store once a cycle has been broken, and callers like
|
|
145
|
+
* `resolveDrop` need to tell the difference without re-running this analysis
|
|
146
|
+
* themselves.
|
|
147
|
+
*/
|
|
148
|
+
const resolveBranchParents = <T>(
|
|
149
|
+
branches: TreeItem<T>[],
|
|
150
|
+
): ResolvedBranchParents => {
|
|
151
|
+
const branchIds = new Set(branches.map((b) => b.id));
|
|
152
|
+
const byId = new Map(branches.map((b) => [b.id, b]));
|
|
153
|
+
const rawParentOf = (id: string): string | undefined => {
|
|
154
|
+
const parentId = byId.get(id)?.parentId;
|
|
155
|
+
return parentId && branchIds.has(parentId) ? parentId : undefined;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const resolved = new Map<string, string | undefined>();
|
|
159
|
+
const promoted = new Set<string>();
|
|
160
|
+
|
|
161
|
+
for (const start of branches) {
|
|
162
|
+
if (resolved.has(start.id)) continue;
|
|
163
|
+
|
|
164
|
+
// Walk the parent chain, recording the path taken on this walk and
|
|
165
|
+
// where in it each id sits. Bounded by `branches.length`: with
|
|
166
|
+
// exactly one outgoing edge per node, a walk longer than the total
|
|
167
|
+
// branch count must have revisited one, so this cannot spin even on
|
|
168
|
+
// adversarial input.
|
|
169
|
+
const path: string[] = [];
|
|
170
|
+
const pathIndex = new Map<string, number>();
|
|
171
|
+
let cur: string | undefined = start.id;
|
|
172
|
+
let cycleAt = -1;
|
|
173
|
+
while (cur !== undefined && path.length <= branches.length) {
|
|
174
|
+
if (resolved.has(cur)) break;
|
|
175
|
+
const seenAt = pathIndex.get(cur);
|
|
176
|
+
if (seenAt !== undefined) {
|
|
177
|
+
cycleAt = seenAt;
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
pathIndex.set(cur, path.length);
|
|
181
|
+
path.push(cur);
|
|
182
|
+
cur = rawParentOf(cur);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
for (let i = 0; i < path.length; i++) {
|
|
186
|
+
if (i === cycleAt) {
|
|
187
|
+
resolved.set(path[i], undefined);
|
|
188
|
+
promoted.add(path[i]);
|
|
189
|
+
} else {
|
|
190
|
+
resolved.set(path[i], rawParentOf(path[i]));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return { parentId: resolved, promoted };
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Assemble one flat list of items into a nested tree. Branches sort before
|
|
200
|
+
* leaves at every level, each group alphabetically, unless `compare` says
|
|
201
|
+
* otherwise. Match the consumer's own server ordering and the tree does not
|
|
202
|
+
* jump after a save.
|
|
203
|
+
*
|
|
204
|
+
* Every item in the input appears exactly once in the result, reachable from
|
|
205
|
+
* the root: a leaf pointing at a parent that is not in the list, or at
|
|
206
|
+
* another leaf, falls back to the root rather than disappearing, and so does
|
|
207
|
+
* a branch whose declared parent is missing or whose parent chain cycles (see
|
|
208
|
+
* `resolveBranchParents`).
|
|
209
|
+
*/
|
|
210
|
+
export const buildTree = <T>(
|
|
211
|
+
items: TreeItem<T>[],
|
|
212
|
+
compare: (a: TreeNode<T>, b: TreeNode<T>) => number = compareTreeNodes,
|
|
213
|
+
): TreeNode<T>[] => {
|
|
214
|
+
const branches = items.filter((item) => item.branch);
|
|
215
|
+
const branchIds = new Set(branches.map((b) => b.id));
|
|
216
|
+
const { parentId: branchParents, promoted } = resolveBranchParents(branches);
|
|
217
|
+
|
|
218
|
+
const childrenByParent = new Map<string, TreeNode<T>[]>();
|
|
219
|
+
const childrenOf = (key: string): TreeNode<T>[] => {
|
|
220
|
+
const existing = childrenByParent.get(key);
|
|
221
|
+
if (existing) return existing;
|
|
222
|
+
const created: TreeNode<T>[] = [];
|
|
223
|
+
childrenByParent.set(key, created);
|
|
224
|
+
return created;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
for (const item of items) {
|
|
228
|
+
if (item.branch) {
|
|
229
|
+
const parentId = branchParents.get(item.id);
|
|
230
|
+
childrenOf(parentId ?? ROOT).push({
|
|
231
|
+
id: item.id,
|
|
232
|
+
name: item.name,
|
|
233
|
+
parentId,
|
|
234
|
+
// A promoted branch's raw `item.parentId` is always defined
|
|
235
|
+
// here: a cycle only closes through branches that exist,
|
|
236
|
+
// which is exactly what "promoted" means.
|
|
237
|
+
declaredParentId: promoted.has(item.id) ? item.parentId : undefined,
|
|
238
|
+
branch: true,
|
|
239
|
+
data: item.data,
|
|
240
|
+
children: [],
|
|
241
|
+
});
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
// A leaf's parent has to be an existing branch. Pointing at nothing
|
|
245
|
+
// and pointing at another leaf are the same failure, and both land at
|
|
246
|
+
// the root.
|
|
247
|
+
const parentId =
|
|
248
|
+
item.parentId && branchIds.has(item.parentId) ? item.parentId : undefined;
|
|
249
|
+
childrenOf(parentId ?? ROOT).push({
|
|
250
|
+
id: item.id,
|
|
251
|
+
name: item.name,
|
|
252
|
+
parentId,
|
|
253
|
+
branch: false,
|
|
254
|
+
data: item.data,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Every branch node was created with `children: []`; now that every node
|
|
259
|
+
// has been bucketed by its resolved parent, wire each branch up to its
|
|
260
|
+
// actual children and sort every level.
|
|
261
|
+
for (const siblings of childrenByParent.values()) {
|
|
262
|
+
for (const node of siblings) {
|
|
263
|
+
if (node.branch) {
|
|
264
|
+
node.children = (childrenByParent.get(node.id) ?? []).sort(compare);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return (childrenByParent.get(ROOT) ?? []).sort(compare);
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Depth-first walk producing one row per visible node. A collapsed branch
|
|
274
|
+
* contributes its own row and nothing beneath it.
|
|
275
|
+
*/
|
|
276
|
+
export const flattenTree = <T>(
|
|
277
|
+
nodes: TreeNode<T>[],
|
|
278
|
+
collapsed: ReadonlySet<string>,
|
|
279
|
+
): TreeRow<T>[] => {
|
|
280
|
+
const rows: TreeRow<T>[] = [];
|
|
281
|
+
const walk = (list: TreeNode<T>[], depth: number): void => {
|
|
282
|
+
for (const node of list) {
|
|
283
|
+
rows.push({ node, depth });
|
|
284
|
+
if (node.children?.length && !collapsed.has(node.id)) {
|
|
285
|
+
walk(node.children, depth + 1);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
walk(nodes, 0);
|
|
290
|
+
return rows;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Depth-first search for the node with the given id, anywhere in the tree.
|
|
295
|
+
*/
|
|
296
|
+
export const findNode = <T>(
|
|
297
|
+
nodes: TreeNode<T>[],
|
|
298
|
+
id: string,
|
|
299
|
+
): TreeNode<T> | undefined => {
|
|
300
|
+
for (const node of nodes) {
|
|
301
|
+
if (node.id === id) return node;
|
|
302
|
+
const hit = node.children ? findNode(node.children, id) : undefined;
|
|
303
|
+
if (hit) return hit;
|
|
304
|
+
}
|
|
305
|
+
return undefined;
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* True when `id` is `node` itself or anywhere beneath it. Guards against
|
|
310
|
+
* dropping a branch into its own subtree, which would orphan it.
|
|
311
|
+
*/
|
|
312
|
+
export const nodeHolds = <T>(node: TreeNode<T>, id: string): boolean =>
|
|
313
|
+
node.id === id || (node.children ?? []).some((child) => nodeHolds(child, id));
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Turn a drag gesture into the one mutation a store can persist: a new
|
|
317
|
+
* parent. Returns `undefined` when the move is illegal or a no-op, in which
|
|
318
|
+
* case the caller must not issue a request.
|
|
319
|
+
*
|
|
320
|
+
* `nodeHolds(dragged, targetId)` is the single cycle guard for both "inside"
|
|
321
|
+
* and "before"/"after": whichever position is used, the resolved parent is
|
|
322
|
+
* either `target` itself or `target`'s existing parent, and a node's parent
|
|
323
|
+
* is always inside that node's own subtree (or the node itself, one level
|
|
324
|
+
* up). So if the resolved parent would be `dragged` or a descendant of
|
|
325
|
+
* `dragged`, then `target` itself is already inside `dragged`'s subtree,
|
|
326
|
+
* which this single check catches regardless of `position`.
|
|
327
|
+
*
|
|
328
|
+
* The no-op check compares the resolved new parent against `dragged`'s
|
|
329
|
+
* *stored* parent, `dragged.declaredParentId ?? dragged.parentId`, not
|
|
330
|
+
* `dragged.parentId` alone. For an ordinary node the two are the same value,
|
|
331
|
+
* so this changes nothing. For a cycle-promoted branch they differ: its tree
|
|
332
|
+
* `parentId` already reads `undefined` (root) even though the store still has
|
|
333
|
+
* it parented on the cyclic value. Comparing against the tree's rewritten
|
|
334
|
+
* `parentId` would make the one drag that actually repairs the corruption,
|
|
335
|
+
* dragging the promoted node to root, which resolves to
|
|
336
|
+
* `{ parentId: undefined }`, indistinguishable from a true no-op, and
|
|
337
|
+
* silently drop the write that clears it. Using the stored parent means that
|
|
338
|
+
* drag (and, in fact, any legal destination for that node, since its true
|
|
339
|
+
* parent is the broken cyclic value and no legal destination can equal it:
|
|
340
|
+
* the cycle guard above already refuses every target that would) resolves to
|
|
341
|
+
* a real write instead.
|
|
342
|
+
*/
|
|
343
|
+
export const resolveDrop = <T>(
|
|
344
|
+
nodes: TreeNode<T>[],
|
|
345
|
+
dragId: string,
|
|
346
|
+
targetId: string,
|
|
347
|
+
position: TreeDropPosition,
|
|
348
|
+
): TreeDropTarget | undefined => {
|
|
349
|
+
if (dragId === targetId) return undefined;
|
|
350
|
+
|
|
351
|
+
const dragged = findNode(nodes, dragId);
|
|
352
|
+
const target = findNode(nodes, targetId);
|
|
353
|
+
if (!dragged || !target) return undefined;
|
|
354
|
+
|
|
355
|
+
if (nodeHolds(dragged, targetId)) return undefined;
|
|
356
|
+
|
|
357
|
+
const draggedStoredParentId = dragged.declaredParentId ?? dragged.parentId;
|
|
358
|
+
|
|
359
|
+
if (position === "inside") {
|
|
360
|
+
// Dropping "inside" only means something on a branch; a leaf cannot
|
|
361
|
+
// hold children.
|
|
362
|
+
if (!target.branch) return undefined;
|
|
363
|
+
if (target.id === draggedStoredParentId) return undefined;
|
|
364
|
+
return { parentId: target.id };
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (target.parentId === draggedStoredParentId) return undefined;
|
|
368
|
+
return { parentId: target.parentId };
|
|
369
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { useI18n } from "alepha/react/i18n";
|
|
2
|
+
import {
|
|
3
|
+
type KeyboardEvent,
|
|
4
|
+
type MouseEvent,
|
|
5
|
+
type ReactElement,
|
|
6
|
+
useEffect,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
} from "react";
|
|
10
|
+
|
|
11
|
+
export interface TreeViewRenameInputProps {
|
|
12
|
+
/**
|
|
13
|
+
* The name to open on. Read once, at mount: while the input is up the
|
|
14
|
+
* draft is the user's, not the node's.
|
|
15
|
+
*/
|
|
16
|
+
name: string;
|
|
17
|
+
onCommit: (name: string) => void;
|
|
18
|
+
onCancel: () => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The inline rename input that replaces a row's label.
|
|
23
|
+
*
|
|
24
|
+
* ⚠️ **Its own component on purpose, and it must stay one.** Two reasons, and
|
|
25
|
+
* the second is the one that bites.
|
|
26
|
+
*
|
|
27
|
+
* It calls `useI18n`, so a tree that never renames anything (a read-only
|
|
28
|
+
* navigation tree, a docs file tree) would otherwise have to mount
|
|
29
|
+
* `AlephaReactI18n` to render a single row.
|
|
30
|
+
*
|
|
31
|
+
* And mounting IS the draft reset. Inlining the input back into the row means
|
|
32
|
+
* the row stays mounted across the whole rename, so `useState(name)`'s
|
|
33
|
+
* initializer runs once for the life of the row and renaming the same row a
|
|
34
|
+
* second time reopens showing the name it had before the FIRST rename. That
|
|
35
|
+
* bug is why the row it came from carried a `wasRenamingRef` and React's
|
|
36
|
+
* "adjust state during render" dance; a component that unmounts when the
|
|
37
|
+
* rename ends needs neither. `tree-view-rename.browser.spec.tsx` pins the
|
|
38
|
+
* second rename, so the bug cannot come back quietly.
|
|
39
|
+
*/
|
|
40
|
+
export const TreeViewRenameInput = (
|
|
41
|
+
props: TreeViewRenameInputProps,
|
|
42
|
+
): ReactElement => {
|
|
43
|
+
const { tr } = useI18n();
|
|
44
|
+
const [draft, setDraft] = useState(props.name);
|
|
45
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* ⚠️ Removing a focused element from the DOM can still fire `blur` in some
|
|
49
|
+
* browsers before the fiber is torn down, so Escape would otherwise commit
|
|
50
|
+
* the very edit it cancelled. The flag is what tells a real blur-to-commit
|
|
51
|
+
* from that one.
|
|
52
|
+
*/
|
|
53
|
+
const cancelledRef = useRef(false);
|
|
54
|
+
|
|
55
|
+
// Focus and select on appear. The a11y rule that removed `autoFocus` left
|
|
56
|
+
// rename opening an input nobody could type into without clicking it first.
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
inputRef.current?.focus();
|
|
59
|
+
inputRef.current?.select();
|
|
60
|
+
}, []);
|
|
61
|
+
|
|
62
|
+
const handleBlur = (): void => {
|
|
63
|
+
if (cancelledRef.current) {
|
|
64
|
+
cancelledRef.current = false;
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
props.onCommit(draft);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>): void => {
|
|
71
|
+
if (e.key === "Enter") {
|
|
72
|
+
// Commit through blur, so Enter and clicking away are one path.
|
|
73
|
+
e.currentTarget.blur();
|
|
74
|
+
} else if (e.key === "Escape") {
|
|
75
|
+
cancelledRef.current = true;
|
|
76
|
+
props.onCancel();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<input
|
|
82
|
+
ref={inputRef}
|
|
83
|
+
data-slot="tree-view-rename-input"
|
|
84
|
+
aria-label={tr("treeView.rename", { default: "New name" })}
|
|
85
|
+
value={draft}
|
|
86
|
+
onChange={(e) => setDraft(e.target.value)}
|
|
87
|
+
onKeyDown={handleKeyDown}
|
|
88
|
+
onBlur={handleBlur}
|
|
89
|
+
// The row beneath opens the node on click; typing in the input must
|
|
90
|
+
// not also be a click on the row.
|
|
91
|
+
onClick={(e: MouseEvent) => e.stopPropagation()}
|
|
92
|
+
className="border-primary bg-background min-w-0 flex-1 rounded border px-1 text-sm outline-none"
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useI18n } from "alepha/react/i18n";
|
|
2
|
+
import { type PointerEvent, type ReactElement, useRef } from "react";
|
|
3
|
+
|
|
4
|
+
export interface TreeViewResizerProps {
|
|
5
|
+
width: number;
|
|
6
|
+
onWidth: (width: number) => void;
|
|
7
|
+
minWidth?: number;
|
|
8
|
+
maxWidth?: number;
|
|
9
|
+
/**
|
|
10
|
+
* What a double click resets to.
|
|
11
|
+
*/
|
|
12
|
+
defaultWidth?: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The drag handle on a tree pane's edge.
|
|
17
|
+
*
|
|
18
|
+
* Two decisions worth keeping.
|
|
19
|
+
*
|
|
20
|
+
* **Pointer capture rather than window listeners.** Capture keeps every
|
|
21
|
+
* subsequent `pointermove` coming to this element even when the pointer
|
|
22
|
+
* outruns it, which it does on any quick drag, and it releases automatically
|
|
23
|
+
* if the gesture is cancelled, so there is no listener left behind to leak.
|
|
24
|
+
*
|
|
25
|
+
* **A 1px line with a 5px grab target**, sitting half over the border. A 1px
|
|
26
|
+
* hit area is a cursor-precision test rather than a control.
|
|
27
|
+
*
|
|
28
|
+
* ⚠️ Persisting the width is the consumer's job. This component reports and
|
|
29
|
+
* never stores, so a pane preference survives navigation the way the
|
|
30
|
+
* consumer's other pane preferences do.
|
|
31
|
+
*/
|
|
32
|
+
export const TreeViewResizer = (props: TreeViewResizerProps): ReactElement => {
|
|
33
|
+
const { tr } = useI18n();
|
|
34
|
+
const minWidth = props.minWidth ?? TREE_VIEW_MIN_WIDTH;
|
|
35
|
+
const maxWidth = props.maxWidth ?? TREE_VIEW_MAX_WIDTH;
|
|
36
|
+
const defaultWidth = props.defaultWidth ?? TREE_VIEW_DEFAULT_WIDTH;
|
|
37
|
+
const start = useRef<{ x: number; width: number } | null>(null);
|
|
38
|
+
|
|
39
|
+
const onPointerDown = (e: PointerEvent<HTMLDivElement>): void => {
|
|
40
|
+
e.preventDefault();
|
|
41
|
+
start.current = { x: e.clientX, width: props.width };
|
|
42
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const onPointerMove = (e: PointerEvent<HTMLDivElement>): void => {
|
|
46
|
+
if (!start.current) return;
|
|
47
|
+
props.onWidth(start.current.width + (e.clientX - start.current.x));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const end = (e: PointerEvent<HTMLDivElement>): void => {
|
|
51
|
+
if (!start.current) return;
|
|
52
|
+
start.current = null;
|
|
53
|
+
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<div
|
|
58
|
+
data-slot="tree-view-resizer"
|
|
59
|
+
tabIndex={0}
|
|
60
|
+
role="separator"
|
|
61
|
+
aria-orientation="vertical"
|
|
62
|
+
aria-label={tr("treeView.resize", { default: "Resize tree" })}
|
|
63
|
+
aria-valuenow={props.width}
|
|
64
|
+
aria-valuemin={minWidth}
|
|
65
|
+
aria-valuemax={maxWidth}
|
|
66
|
+
onPointerDown={onPointerDown}
|
|
67
|
+
onPointerMove={onPointerMove}
|
|
68
|
+
onPointerUp={end}
|
|
69
|
+
onPointerCancel={end}
|
|
70
|
+
onDoubleClick={() => props.onWidth(defaultWidth)}
|
|
71
|
+
className="hover:bg-primary/40 active:bg-primary/60 -ml-[2px] w-[5px] flex-none cursor-col-resize transition-colors"
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Sane defaults for a navigation pane, overridable per consumer. These are the
|
|
78
|
+
* numbers the component was extracted with; a consumer with its own opinion
|
|
79
|
+
* passes it rather than editing these.
|
|
80
|
+
*/
|
|
81
|
+
export const TREE_VIEW_MIN_WIDTH = 180;
|
|
82
|
+
export const TREE_VIEW_MAX_WIDTH = 480;
|
|
83
|
+
export const TREE_VIEW_DEFAULT_WIDTH = 242;
|