@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control-upload.js","names":["FileIcon"],"sources":["../../../src/components/control-upload/control-upload.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { FormField } from \"@alepha/ui/components/control-base/form-field\";\nimport { Button } from \"@alepha/ui/components/ui/button\";\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n} from \"@alepha/ui/components/ui/dialog\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"@alepha/ui/components/ui/tooltip\";\nimport { useToast } from \"@alepha/ui/components/use-toast/use-toast\";\nimport type { FileController } from \"alepha/api/files\";\nimport { useClient } from \"alepha/react\";\nimport {\n type BaseInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { File as FileIcon, Loader2, Upload, X } from \"lucide-react\";\nimport {\n type ChangeEvent,\n type DragEvent,\n useEffect,\n useId,\n useRef,\n useState,\n} from \"react\";\n\nimport {\n type ResizeImageOptions,\n resizeImage,\n} from \"../../lib/resize-image.ts\";\n\nexport interface ControlUploadProps {\n /**\n * Bound `InputField` from `useForm`. Stores the uploaded file ID(s).\n */\n input: BaseInputField;\n /**\n * Field label. Falls back to schema `title`.\n */\n label?: string;\n /**\n * Helper text shown below the dropzone.\n */\n description?: string;\n /**\n * Multi-file mode. The form value becomes an `Array<string>` of file\n * IDs. Single mode (default) stores a bare UUID string.\n */\n multi?: boolean;\n /**\n * HTML `accept` filter on the file picker (e.g. `\"image/*\"`,\n * `\".pdf,.docx\"`).\n */\n accept?: string;\n /**\n * Max size per file (bytes). Files over the limit are rejected.\n */\n maxSize?: number;\n /**\n * Downscale images to these bounds before uploading.\n *\n * Set it wherever the result is rendered small — the bytes never leave the\n * machine, so it speeds up the upload as well as every later fetch. Applied\n * before {@link maxSize}, so a photo that would have been rejected for being\n * too large is resized and accepted instead.\n *\n * Best-effort by design: a browser without `OffscreenCanvas`, an SVG, or an\n * image the decoder chokes on is uploaded as-is, and the storage's own\n * `maxSize` remains what actually bounds it. That trade is deliberate — a\n * server-side codec able to close the gap costs more bundle than the case is\n * worth on an edge runtime, and encodes worse (see `files:beforeUpload` in\n * `alepha/api/files` for where it would attach if you want it anyway).\n *\n * @example { maxWidth: 256 }\n */\n image?: ResizeImageOptions;\n /**\n * Bucket name passed to the upload endpoint.\n */\n bucket?: string;\n /**\n * Disable the dropzone.\n */\n disabled?: boolean;\n}\n\ninterface UploadedFileMeta {\n id: string;\n name: string;\n mimeType?: string;\n size?: number;\n /**\n * Object URL for image preview, when applicable.\n */\n previewUrl?: string;\n}\n\n/**\n * File upload control. Wraps `FileController.uploadFile`, stores the\n * resulting file ID(s) in the form, and renders a thumbnail preview for\n * images and a chip-style summary for everything else.\n *\n * Single-file: form value is a uuid string.\n * Multi-file: form value is an array of uuid strings.\n */\nexport const ControlUpload = (props: ControlUploadProps) => {\n const form = useFormState(props.input, [\"error\"]);\n const [value, setValue] = useFieldValue(props.input);\n const client = useClient<FileController>();\n const { tr } = useI18n();\n const toast = useToast();\n const inputId = useId();\n const fileInputRef = useRef<HTMLInputElement>(null);\n const [uploading, setUploading] = useState(false);\n const [progress, setProgress] = useState(0);\n const [meta, setMeta] = useState<Map<string, UploadedFileMeta>>(new Map());\n const [dragOver, setDragOver] = useState(false);\n const [previewId, setPreviewId] = useState<string | null>(null);\n\n /**\n * Backfill `meta` for ids that arrived from form state (e.g. after a page\n * reload) so the renderer can show a thumbnail / chip instead of the raw\n * uuid. We can't infer the real mime type without an extra request, so we\n * fall back to a stub entry pointing at `/api/files/:id` and let the\n * `<img>` `onError` swap to the generic file chip.\n */\n useEffect(() => {\n const ids: string[] = props.multi\n ? Array.isArray(value)\n ? (value as string[])\n : []\n : value\n ? [value as string]\n : [];\n // Reconciles a cache of per-file metadata against the ids the field now\n // holds, and the entries it keeps were filled in by the upload requests this\n // same effect issues. It is the cache for an external system, not derived\n // state; the updater already no-ops when nothing changed.\n // oxlint-disable-next-line react/set-state-in-effect\n setMeta((current) => {\n let changed = false;\n const next = new Map(current);\n for (const id of ids) {\n if (!next.has(id)) {\n next.set(id, {\n id,\n name: id,\n previewUrl: `/api/files/${id}`,\n });\n changed = true;\n }\n }\n return changed ? next : current;\n });\n }, [Array.isArray(value) ? value.join(\",\") : value, props.multi]);\n\n if (!props.input?.props) return null;\n\n const fieldMeta = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n\n const ids: string[] = props.multi\n ? Array.isArray(value)\n ? (value as string[])\n : []\n : value\n ? [value as string]\n : [];\n\n const handleFiles = async (files: FileList) => {\n if (!files.length) return;\n if (!props.multi && files.length > 1) {\n toast.error(\n tr(\"controlUpload.singleOnly\", { default: \"Only one file allowed\" }),\n );\n return;\n }\n\n setUploading(true);\n setProgress(0);\n const next = new Map(meta);\n const newIds: string[] = [];\n\n try {\n for (let i = 0; i < files.length; i++) {\n // Ahead of the size check on purpose: a 4 MB photo destined for a 32px\n // avatar should become a few kilobytes, not an error.\n const file = props.image\n ? await resizeImage(files[i], props.image)\n : files[i];\n\n if (props.maxSize && file.size > props.maxSize) {\n toast.error(\n tr(\"controlUpload.tooBig\", {\n default: `${file.name} exceeds ${formatBytes(props.maxSize)}`,\n args: [file.name, formatBytes(props.maxSize)],\n }),\n );\n continue;\n }\n\n const resource = await client.uploadFile({\n body: { file },\n query: props.bucket ? { bucket: props.bucket } : ({} as never),\n });\n\n const previewUrl = file.type.startsWith(\"image/\")\n ? URL.createObjectURL(file)\n : undefined;\n\n next.set(resource.id, {\n id: resource.id,\n name: resource.name ?? file.name,\n mimeType: resource.mimeType ?? file.type,\n size: resource.size ?? file.size,\n previewUrl,\n });\n newIds.push(resource.id);\n setProgress(Math.round(((i + 1) / files.length) * 100));\n }\n\n setMeta(next);\n if (props.multi) {\n setValue([...ids, ...newIds]);\n } else if (newIds[0]) {\n setValue(newIds[0]);\n }\n if (newIds.length) {\n toast.success(\n newIds.length === 1\n ? tr(\"controlUpload.uploadedOne\", { default: \"File uploaded\" })\n : tr(\"controlUpload.uploadedMany\", {\n default: `${newIds.length} files uploaded`,\n args: [String(newIds.length)],\n }),\n );\n }\n } catch (e) {\n const msg = (e as Error).message;\n toast.error(\n tr(\"controlUpload.failed\", {\n default: `Upload failed: ${msg}`,\n args: [msg],\n }),\n );\n } finally {\n setUploading(false);\n setProgress(0);\n if (fileInputRef.current) fileInputRef.current.value = \"\";\n }\n };\n\n const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {\n if (e.target.files) void handleFiles(e.target.files);\n };\n\n const handleDrop = (e: DragEvent) => {\n e.preventDefault();\n setDragOver(false);\n if (props.disabled) return;\n if (e.dataTransfer.files) void handleFiles(e.dataTransfer.files);\n };\n\n const removeOne = (id: string) => {\n const next = new Map(meta);\n const item = next.get(id);\n if (item?.previewUrl) URL.revokeObjectURL(item.previewUrl);\n next.delete(id);\n setMeta(next);\n\n if (props.multi) {\n setValue(ids.filter((it) => it !== id));\n } else {\n setValue(undefined);\n }\n };\n\n const renderItem = (id: string) => {\n const item = meta.get(id);\n const acceptsImage = (props.accept ?? \"\").includes(\"image\");\n const mimeIsImage = item?.mimeType?.startsWith(\"image/\");\n const isImage =\n mimeIsImage || (acceptsImage && !!item?.previewUrl && !item?.mimeType);\n\n const canClear = !props.disabled && !fieldMeta.required;\n\n return (\n <div\n key={id}\n className={`border-input dark:bg-input/30 relative flex h-9 cursor-zoom-in items-center rounded-md border bg-transparent pl-1 ${canClear ? \"pr-9\" : \"pr-2\"}`}\n onClick={() => setPreviewId(id)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n setPreviewId(id);\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n {isImage && item?.previewUrl ? (\n <ItemThumb url={item.previewUrl} alt={item.name ?? id} />\n ) : (\n <div className=\"bg-muted text-muted-foreground flex size-7 shrink-0 items-center justify-center rounded\">\n <FileIcon className=\"size-4\" />\n </div>\n )}\n {canClear && (\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation();\n removeOne(id);\n }}\n aria-label={tr(\"controlUpload.remove\", { default: \"Remove\" })}\n className=\"text-muted-foreground hover:text-foreground absolute top-1/2 right-2 -translate-y-1/2 p-1\"\n >\n <X className=\"size-3.5\" />\n </button>\n )}\n </div>\n );\n };\n\n const previewItem = previewId ? meta.get(previewId) : undefined;\n const previewIsImage = previewItem\n ? previewItem.mimeType?.startsWith(\"image/\") ||\n ((props.accept ?? \"\").includes(\"image\") &&\n !!previewItem.previewUrl &&\n !previewItem.mimeType)\n : false;\n const previewHasName =\n !!previewItem?.name && previewItem.name !== previewItem.id;\n\n const dragDropHint =\n tr(\"controlUpload.dragDrop\", { default: \"Upload or drag and drop here\" }) +\n (props.maxSize\n ? ` · ${tr(\"controlUpload.max\", {\n default: `max ${formatBytes(props.maxSize)}`,\n args: [formatBytes(props.maxSize)],\n })}`\n : \"\");\n\n const dropZone = (\n <Tooltip>\n <TooltipTrigger\n render={\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n disabled={props.disabled || uploading}\n onClick={() => fileInputRef.current?.click()}\n onDragOver={(e) => {\n e.preventDefault();\n setDragOver(true);\n }}\n onDragLeave={() => setDragOver(false)}\n onDrop={handleDrop}\n className={dragOver ? \"border-primary bg-primary/5\" : \"\"}\n />\n }\n >\n {uploading ? (\n <>\n <Loader2 className=\"mr-1 size-4 animate-spin\" />\n {tr(\"controlUpload.uploading\", { default: \"Uploading…\" })}\n </>\n ) : (\n <>\n <Upload className=\"mr-1 size-4\" />\n {props.multi\n ? tr(\"controlUpload.chooseFiles\", { default: \"Choose files\" })\n : tr(\"controlUpload.chooseFile\", { default: \"Choose a file\" })}\n </>\n )}\n </TooltipTrigger>\n <TooltipContent>{dragDropHint}</TooltipContent>\n </Tooltip>\n );\n\n return (\n <FormField\n id={inputId}\n label={fieldMeta.label}\n description={fieldMeta.description}\n error={fieldMeta.error}\n required={fieldMeta.required}\n >\n <input\n ref={fileInputRef}\n type=\"file\"\n id={inputId}\n name={props.input.props.name}\n className=\"hidden\"\n accept={props.accept}\n multiple={props.multi}\n disabled={props.disabled}\n onChange={handleInputChange}\n />\n\n <div className=\"flex flex-col gap-2\">\n {ids.length > 0 && (\n <div className=\"flex flex-col gap-2\">{ids.map(renderItem)}</div>\n )}\n {(props.multi || ids.length === 0) && dropZone}\n {uploading && (\n <div className=\"bg-muted h-1 w-full overflow-hidden rounded\">\n <div\n className=\"bg-primary h-full transition-all\"\n style={{ width: `${progress}%` }}\n />\n </div>\n )}\n </div>\n\n <Dialog\n open={previewId !== null}\n onOpenChange={(o) => !o && setPreviewId(null)}\n >\n <DialogContent className=\"w-fit max-w-fit p-0\">\n <DialogHeader className=\"sr-only\">\n <DialogTitle>\n {previewHasName\n ? previewItem?.name\n : tr(\"controlUpload.savedFile\", { default: \"Saved file\" })}\n </DialogTitle>\n <DialogDescription>\n {previewItem?.mimeType ?? \"uploaded\"}\n </DialogDescription>\n </DialogHeader>\n <div className=\"p-4\">\n {previewIsImage && previewItem?.previewUrl ? (\n <img\n src={previewItem.previewUrl}\n alt={previewItem.name ?? \"\"}\n className=\"size-72 rounded object-contain\"\n />\n ) : (\n <div className=\"bg-muted text-muted-foreground flex size-72 items-center justify-center rounded\">\n <FileIcon className=\"size-16\" />\n </div>\n )}\n </div>\n {(previewHasName || previewItem?.mimeType) && (\n <div className=\"bg-muted/30 flex flex-col gap-0 border-t px-4 py-2\">\n {previewHasName && (\n <span className=\"truncate text-sm font-medium\">\n {previewItem?.name}\n </span>\n )}\n {previewItem?.mimeType && (\n <span className=\"text-muted-foreground truncate text-xs\">\n {previewItem.mimeType}\n </span>\n )}\n </div>\n )}\n </DialogContent>\n </Dialog>\n </FormField>\n );\n};\n\nconst ItemThumb = (props: { url: string; alt: string }) => {\n const [broken, setBroken] = useState(false);\n if (broken) {\n return (\n <div className=\"bg-muted text-muted-foreground flex size-7 shrink-0 items-center justify-center rounded\">\n <FileIcon className=\"size-4\" />\n </div>\n );\n }\n return (\n <img\n src={props.url}\n alt={props.alt}\n className=\"size-7 shrink-0 rounded object-cover\"\n onError={() => setBroken(true)}\n />\n );\n};\n\nconst formatBytes = (n: number): string => {\n if (!n) return \"0 B\";\n const units = [\"B\", \"KB\", \"MB\", \"GB\"];\n const i = Math.min(\n units.length - 1,\n Math.floor(Math.log(n) / Math.log(1024)),\n );\n return `${(n / 1024 ** i).toFixed(1)} ${units[i]}`;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqHA,MAAa,iBAAiB,UAA8B;CAC1D,MAAM,OAAO,aAAa,MAAM,OAAO,CAAC,OAAO,CAAC;CAChD,MAAM,CAAC,OAAO,YAAY,cAAc,MAAM,KAAK;CACnD,MAAM,SAAS,UAA0B;CACzC,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,QAAQ,SAAS;CACvB,MAAM,UAAU,MAAM;CACtB,MAAM,eAAe,OAAyB,IAAI;CAClD,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,CAAC,UAAU,eAAe,SAAS,CAAC;CAC1C,MAAM,CAAC,MAAM,WAAW,yBAAwC,IAAI,IAAI,CAAC;CACzE,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAC9C,MAAM,CAAC,WAAW,gBAAgB,SAAwB,IAAI;;;;;;;;CAS9D,gBAAgB;EACd,MAAM,MAAgB,MAAM,QACxB,MAAM,QAAQ,KAAK,IAChB,QACD,CAAC,IACH,QACE,CAAC,KAAe,IAChB,CAAC;EAMP,SAAS,YAAY;GACnB,IAAI,UAAU;GACd,MAAM,OAAO,IAAI,IAAI,OAAO;GAC5B,KAAK,MAAM,MAAM,KACf,IAAI,CAAC,KAAK,IAAI,EAAE,GAAG;IACjB,KAAK,IAAI,IAAI;KACX;KACA,MAAM;KACN,YAAY,cAAc;IAC5B,CAAC;IACD,UAAU;GACZ;GAEF,OAAO,UAAU,OAAO;EAC1B,CAAC;CACH,GAAG,CAAC,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK,GAAG,IAAI,OAAO,MAAM,KAAK,CAAC;CAEhE,IAAI,CAAC,MAAM,OAAO,OAAO,OAAO;CAEhC,MAAM,YAAY,W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ACX,WAAU;EACV,eAAe,UAAU,IAAI;CAC9B,CAAA;AAEL;AAEA,MAAM,eAAe,MAAsB;CACzC,IAAI,CAAC,GAAG,OAAO;CACf,MAAM,QAAQ;EAAC;EAAK;EAAM;EAAM;CAAI;CACpC,MAAM,IAAI,KAAK,IACb,MAAM,SAAS,GACf,KAAK,MAAM,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,CACzC;CACA,OAAO,IAAI,IAAI,QAAQ,EAAA,CAAG,QAAQ,CAAC,EAAE,GAAG,MAAM;AAChD"}
|
|
1
|
+
{"version":3,"file":"control-upload.js","names":["FileIcon"],"sources":["../../../src/components/control-upload/control-upload.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { FormField } from \"@alepha/ui/components/control-base/form-field\";\nimport { Button } from \"@alepha/ui/components/ui/button\";\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n} from \"@alepha/ui/components/ui/dialog\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"@alepha/ui/components/ui/tooltip\";\nimport { useToast } from \"@alepha/ui/components/use-toast/use-toast\";\nimport { formatBytes } from \"@alepha/ui/lib/utils\";\nimport type { FileController } from \"alepha/api/files\";\nimport { useClient } from \"alepha/react\";\nimport {\n type BaseInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { File as FileIcon, Loader2, Upload, X } from \"lucide-react\";\nimport {\n type ChangeEvent,\n type DragEvent,\n useEffect,\n useId,\n useRef,\n useState,\n} from \"react\";\n\nimport {\n type ResizeImageOptions,\n resizeImage,\n} from \"../../lib/resize-image.ts\";\n\nexport interface ControlUploadProps {\n /**\n * Bound `InputField` from `useForm`. Stores the uploaded file ID(s).\n */\n input: BaseInputField;\n /**\n * Field label. Falls back to schema `title`.\n */\n label?: string;\n /**\n * Helper text shown below the dropzone.\n */\n description?: string;\n /**\n * Multi-file mode. The form value becomes an `Array<string>` of file\n * IDs. Single mode (default) stores a bare UUID string.\n */\n multi?: boolean;\n /**\n * HTML `accept` filter on the file picker (e.g. `\"image/*\"`,\n * `\".pdf,.docx\"`).\n */\n accept?: string;\n /**\n * Max size per file (bytes). Files over the limit are rejected.\n */\n maxSize?: number;\n /**\n * Downscale images to these bounds before uploading.\n *\n * Set it wherever the result is rendered small — the bytes never leave the\n * machine, so it speeds up the upload as well as every later fetch. Applied\n * before {@link maxSize}, so a photo that would have been rejected for being\n * too large is resized and accepted instead.\n *\n * Best-effort by design: a browser without `OffscreenCanvas`, an SVG, or an\n * image the decoder chokes on is uploaded as-is, and the storage's own\n * `maxSize` remains what actually bounds it. That trade is deliberate — a\n * server-side codec able to close the gap costs more bundle than the case is\n * worth on an edge runtime, and encodes worse (see `files:beforeUpload` in\n * `alepha/api/files` for where it would attach if you want it anyway).\n *\n * @example { maxWidth: 256 }\n */\n image?: ResizeImageOptions;\n /**\n * Bucket name passed to the upload endpoint.\n */\n bucket?: string;\n /**\n * Disable the dropzone.\n */\n disabled?: boolean;\n}\n\ninterface UploadedFileMeta {\n id: string;\n name: string;\n mimeType?: string;\n size?: number;\n /**\n * Object URL for image preview, when applicable.\n */\n previewUrl?: string;\n}\n\n/**\n * File upload control. Wraps `FileController.uploadFile`, stores the\n * resulting file ID(s) in the form, and renders a thumbnail preview for\n * images and a chip-style summary for everything else.\n *\n * Single-file: form value is a uuid string.\n * Multi-file: form value is an array of uuid strings.\n */\nexport const ControlUpload = (props: ControlUploadProps) => {\n const form = useFormState(props.input, [\"error\"]);\n const [value, setValue] = useFieldValue(props.input);\n const client = useClient<FileController>();\n const { tr } = useI18n();\n const toast = useToast();\n const inputId = useId();\n const fileInputRef = useRef<HTMLInputElement>(null);\n const [uploading, setUploading] = useState(false);\n const [progress, setProgress] = useState(0);\n const [meta, setMeta] = useState<Map<string, UploadedFileMeta>>(new Map());\n const [dragOver, setDragOver] = useState(false);\n const [previewId, setPreviewId] = useState<string | null>(null);\n\n /**\n * Backfill `meta` for ids that arrived from form state (e.g. after a page\n * reload) so the renderer can show a thumbnail / chip instead of the raw\n * uuid. We can't infer the real mime type without an extra request, so we\n * fall back to a stub entry pointing at `/api/files/:id` and let the\n * `<img>` `onError` swap to the generic file chip.\n */\n useEffect(() => {\n const ids: string[] = props.multi\n ? Array.isArray(value)\n ? (value as string[])\n : []\n : value\n ? [value as string]\n : [];\n // Reconciles a cache of per-file metadata against the ids the field now\n // holds, and the entries it keeps were filled in by the upload requests this\n // same effect issues. It is the cache for an external system, not derived\n // state; the updater already no-ops when nothing changed.\n // oxlint-disable-next-line react/set-state-in-effect\n setMeta((current) => {\n let changed = false;\n const next = new Map(current);\n for (const id of ids) {\n if (!next.has(id)) {\n next.set(id, {\n id,\n name: id,\n previewUrl: `/api/files/${id}`,\n });\n changed = true;\n }\n }\n return changed ? next : current;\n });\n }, [Array.isArray(value) ? value.join(\",\") : value, props.multi]);\n\n if (!props.input?.props) return null;\n\n const fieldMeta = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n\n const ids: string[] = props.multi\n ? Array.isArray(value)\n ? (value as string[])\n : []\n : value\n ? [value as string]\n : [];\n\n const handleFiles = async (files: FileList) => {\n if (!files.length) return;\n if (!props.multi && files.length > 1) {\n toast.error(\n tr(\"controlUpload.singleOnly\", { default: \"Only one file allowed\" }),\n );\n return;\n }\n\n setUploading(true);\n setProgress(0);\n const next = new Map(meta);\n const newIds: string[] = [];\n\n try {\n for (let i = 0; i < files.length; i++) {\n // Ahead of the size check on purpose: a 4 MB photo destined for a 32px\n // avatar should become a few kilobytes, not an error.\n const file = props.image\n ? await resizeImage(files[i], props.image)\n : files[i];\n\n if (props.maxSize && file.size > props.maxSize) {\n toast.error(\n tr(\"controlUpload.tooBig\", {\n default: `${file.name} exceeds ${formatBytes(props.maxSize)}`,\n args: [file.name, formatBytes(props.maxSize)],\n }),\n );\n continue;\n }\n\n const resource = await client.uploadFile({\n body: { file },\n query: props.bucket ? { bucket: props.bucket } : ({} as never),\n });\n\n const previewUrl = file.type.startsWith(\"image/\")\n ? URL.createObjectURL(file)\n : undefined;\n\n next.set(resource.id, {\n id: resource.id,\n name: resource.name ?? file.name,\n mimeType: resource.mimeType ?? file.type,\n size: resource.size ?? file.size,\n previewUrl,\n });\n newIds.push(resource.id);\n setProgress(Math.round(((i + 1) / files.length) * 100));\n }\n\n setMeta(next);\n if (props.multi) {\n setValue([...ids, ...newIds]);\n } else if (newIds[0]) {\n setValue(newIds[0]);\n }\n if (newIds.length) {\n toast.success(\n newIds.length === 1\n ? tr(\"controlUpload.uploadedOne\", { default: \"File uploaded\" })\n : tr(\"controlUpload.uploadedMany\", {\n default: `${newIds.length} files uploaded`,\n args: [String(newIds.length)],\n }),\n );\n }\n } catch (e) {\n const msg = (e as Error).message;\n toast.error(\n tr(\"controlUpload.failed\", {\n default: `Upload failed: ${msg}`,\n args: [msg],\n }),\n );\n } finally {\n setUploading(false);\n setProgress(0);\n if (fileInputRef.current) fileInputRef.current.value = \"\";\n }\n };\n\n const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {\n if (e.target.files) void handleFiles(e.target.files);\n };\n\n const handleDrop = (e: DragEvent) => {\n e.preventDefault();\n setDragOver(false);\n if (props.disabled) return;\n if (e.dataTransfer.files) void handleFiles(e.dataTransfer.files);\n };\n\n const removeOne = (id: string) => {\n const next = new Map(meta);\n const item = next.get(id);\n if (item?.previewUrl) URL.revokeObjectURL(item.previewUrl);\n next.delete(id);\n setMeta(next);\n\n if (props.multi) {\n setValue(ids.filter((it) => it !== id));\n } else {\n setValue(undefined);\n }\n };\n\n const renderItem = (id: string) => {\n const item = meta.get(id);\n const acceptsImage = (props.accept ?? \"\").includes(\"image\");\n const mimeIsImage = item?.mimeType?.startsWith(\"image/\");\n const isImage =\n mimeIsImage || (acceptsImage && !!item?.previewUrl && !item?.mimeType);\n\n const canClear = !props.disabled && !fieldMeta.required;\n\n return (\n <div\n key={id}\n className={`border-input dark:bg-input/30 relative flex h-9 cursor-zoom-in items-center rounded-md border bg-transparent pl-1 ${canClear ? \"pr-9\" : \"pr-2\"}`}\n onClick={() => setPreviewId(id)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n setPreviewId(id);\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n {isImage && item?.previewUrl ? (\n <ItemThumb url={item.previewUrl} alt={item.name ?? id} />\n ) : (\n <div className=\"bg-muted text-muted-foreground flex size-7 shrink-0 items-center justify-center rounded\">\n <FileIcon className=\"size-4\" />\n </div>\n )}\n {canClear && (\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation();\n removeOne(id);\n }}\n aria-label={tr(\"controlUpload.remove\", { default: \"Remove\" })}\n className=\"text-muted-foreground hover:text-foreground absolute top-1/2 right-2 -translate-y-1/2 p-1\"\n >\n <X className=\"size-3.5\" />\n </button>\n )}\n </div>\n );\n };\n\n const previewItem = previewId ? meta.get(previewId) : undefined;\n const previewIsImage = previewItem\n ? previewItem.mimeType?.startsWith(\"image/\") ||\n ((props.accept ?? \"\").includes(\"image\") &&\n !!previewItem.previewUrl &&\n !previewItem.mimeType)\n : false;\n const previewHasName =\n !!previewItem?.name && previewItem.name !== previewItem.id;\n\n const dragDropHint =\n tr(\"controlUpload.dragDrop\", { default: \"Upload or drag and drop here\" }) +\n (props.maxSize\n ? ` · ${tr(\"controlUpload.max\", {\n default: `max ${formatBytes(props.maxSize)}`,\n args: [formatBytes(props.maxSize)],\n })}`\n : \"\");\n\n const dropZone = (\n <Tooltip>\n <TooltipTrigger\n render={\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n disabled={props.disabled || uploading}\n onClick={() => fileInputRef.current?.click()}\n onDragOver={(e) => {\n e.preventDefault();\n setDragOver(true);\n }}\n onDragLeave={() => setDragOver(false)}\n onDrop={handleDrop}\n className={dragOver ? \"border-primary bg-primary/5\" : \"\"}\n />\n }\n >\n {uploading ? (\n <>\n <Loader2 className=\"mr-1 size-4 animate-spin\" />\n {tr(\"controlUpload.uploading\", { default: \"Uploading…\" })}\n </>\n ) : (\n <>\n <Upload className=\"mr-1 size-4\" />\n {props.multi\n ? tr(\"controlUpload.chooseFiles\", { default: \"Choose files\" })\n : tr(\"controlUpload.chooseFile\", { default: \"Choose a file\" })}\n </>\n )}\n </TooltipTrigger>\n <TooltipContent>{dragDropHint}</TooltipContent>\n </Tooltip>\n );\n\n return (\n <FormField\n id={inputId}\n label={fieldMeta.label}\n description={fieldMeta.description}\n error={fieldMeta.error}\n required={fieldMeta.required}\n >\n <input\n ref={fileInputRef}\n type=\"file\"\n id={inputId}\n name={props.input.props.name}\n className=\"hidden\"\n accept={props.accept}\n multiple={props.multi}\n disabled={props.disabled}\n onChange={handleInputChange}\n />\n\n <div className=\"flex flex-col gap-2\">\n {ids.length > 0 && (\n <div className=\"flex flex-col gap-2\">{ids.map(renderItem)}</div>\n )}\n {(props.multi || ids.length === 0) && dropZone}\n {uploading && (\n <div className=\"bg-muted h-1 w-full overflow-hidden rounded\">\n <div\n className=\"bg-primary h-full transition-all\"\n style={{ width: `${progress}%` }}\n />\n </div>\n )}\n </div>\n\n <Dialog\n open={previewId !== null}\n onOpenChange={(o) => !o && setPreviewId(null)}\n >\n <DialogContent className=\"w-fit max-w-fit p-0\">\n <DialogHeader className=\"sr-only\">\n <DialogTitle>\n {previewHasName\n ? previewItem?.name\n : tr(\"controlUpload.savedFile\", { default: \"Saved file\" })}\n </DialogTitle>\n <DialogDescription>\n {previewItem?.mimeType ?? \"uploaded\"}\n </DialogDescription>\n </DialogHeader>\n <div className=\"p-4\">\n {previewIsImage && previewItem?.previewUrl ? (\n <img\n src={previewItem.previewUrl}\n alt={previewItem.name ?? \"\"}\n className=\"size-72 rounded object-contain\"\n />\n ) : (\n <div className=\"bg-muted text-muted-foreground flex size-72 items-center justify-center rounded\">\n <FileIcon className=\"size-16\" />\n </div>\n )}\n </div>\n {(previewHasName || previewItem?.mimeType) && (\n <div className=\"bg-muted/30 flex flex-col gap-0 border-t px-4 py-2\">\n {previewHasName && (\n <span className=\"truncate text-sm font-medium\">\n {previewItem?.name}\n </span>\n )}\n {previewItem?.mimeType && (\n <span className=\"text-muted-foreground truncate text-xs\">\n {previewItem.mimeType}\n </span>\n )}\n </div>\n )}\n </DialogContent>\n </Dialog>\n </FormField>\n );\n};\n\nconst ItemThumb = (props: { url: string; alt: string }) => {\n const [broken, setBroken] = useState(false);\n if (broken) {\n return (\n <div className=\"bg-muted text-muted-foreground flex size-7 shrink-0 items-center justify-center rounded\">\n <FileIcon className=\"size-4\" />\n </div>\n );\n }\n return (\n <img\n src={props.url}\n alt={props.alt}\n className=\"size-7 shrink-0 rounded object-cover\"\n onError={() => setBroken(true)}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsHA,MAAa,iBAAiB,UAA8B;CAC1D,MAAM,OAAO,aAAa,MAAM,OAAO,CAAC,OAAO,CAAC;CAChD,MAAM,CAAC,OAAO,YAAY,cAAc,MAAM,KAAK;CACnD,MAAM,SAAS,UAA0B;CACzC,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,QAAQ,SAAS;CACvB,MAAM,UAAU,MAAM;CACtB,MAAM,eAAe,OAAyB,IAAI;CAClD,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,CAAC,UAAU,eAAe,SAAS,CAAC;CAC1C,MAAM,CAAC,MAAM,WAAW,yBAAwC,IAAI,IAAI,CAAC;CACzE,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAC9C,MAAM,CAAC,WAAW,gBAAgB,SAAwB,IAAI;;;;;;;;CAS9D,gBAAgB;EACd,MAAM,MAAgB,MAAM,QACxB,MAAM,QAAQ,KAAK,IAChB,QACD,CAAC,IACH,QACE,CAAC,KAAe,IAChB,CAAC;EAMP,SAAS,YAAY;GACnB,IAAI,UAAU;GACd,MAAM,OAAO,IAAI,IAAI,OAAO;GAC5B,KAAK,M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,oBAAC,QAAD;QAAM,WAAU;QACb,UAAA,YAAY;OACT,CAAA,CAEL;;KAEM;;GACT,CAAA;EACC;;AAEf;AAEA,MAAM,aAAa,UAAwC;CACzD,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAC1C,IAAI,QACF,OACE,oBAAC,OAAD;EAAK,WAAU;EACb,UAAA,oBAACA,MAAD,EAAU,WAAU,SAAU,CAAA;CAC3B,CAAA;CAGT,OACE,oBAAC,OAAD;EACE,KAAK,MAAM;EACX,KAAK,MAAM;EACX,WAAU;EACV,eAAe,UAAU,IAAI;CAC9B,CAAA;AAEL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detail-aside.d.ts","sourceRoot":"","sources":["../../../src/components/detail/detail-aside.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAc/B,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,cAAc,EAAE,CAAC;CACxB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,UAAW,gBAAgB,
|
|
1
|
+
{"version":3,"file":"detail-aside.d.ts","sourceRoot":"","sources":["../../../src/components/detail/detail-aside.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAc/B,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,cAAc,EAAE,CAAC;CACxB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,UAAW,gBAAgB,sBAsJlD,CAAC"}
|
|
@@ -37,9 +37,10 @@ const DetailAside = (props) => {
|
|
|
37
37
|
};
|
|
38
38
|
const initial = (props.fallback ?? props.title ?? "?").charAt(0).toUpperCase();
|
|
39
39
|
const showAvatar = props.avatar !== false;
|
|
40
|
+
const header = showAvatar || props.title;
|
|
40
41
|
return /* @__PURE__ */ jsxs("div", {
|
|
41
42
|
className: "flex flex-col gap-4",
|
|
42
|
-
children: [
|
|
43
|
+
children: [header ? /* @__PURE__ */ jsxs("div", {
|
|
43
44
|
className: "flex items-center gap-3",
|
|
44
45
|
children: [showAvatar && /* @__PURE__ */ jsxs(Avatar, {
|
|
45
46
|
className: "size-10 rounded-md after:rounded-md",
|
|
@@ -57,9 +58,9 @@ const DetailAside = (props) => {
|
|
|
57
58
|
children: props.title
|
|
58
59
|
}) : null]
|
|
59
60
|
}) : null, /* @__PURE__ */ jsx("dl", {
|
|
60
|
-
className: "flex flex-col divide-y overflow-hidden rounded-lg border text-sm",
|
|
61
|
+
className: "bg-muted flex flex-col divide-y overflow-hidden rounded-lg border text-sm",
|
|
61
62
|
children: props.rows.map((row) => /* @__PURE__ */ jsxs("div", {
|
|
62
|
-
className: "flex flex-col gap-0.5 px-3 py-2.5",
|
|
63
|
+
className: "flex flex-col gap-0.5 px-3 py-2.5 shadow-[inset_0_1px_0_0_var(--bevel)]",
|
|
63
64
|
children: [/* @__PURE__ */ jsx("dt", {
|
|
64
65
|
className: "text-muted-foreground text-[11px] font-medium tracking-wide uppercase",
|
|
65
66
|
children: row.label
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detail-aside.js","names":[],"sources":["../../../src/components/detail/detail-aside.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport {\n Avatar,\n AvatarFallback,\n AvatarImage,\n} from \"@alepha/ui/components/ui/avatar\";\nimport { Button } from \"@alepha/ui/components/ui/button\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { Check, Copy } from \"lucide-react\";\nimport { useEffect, useRef, useState } from \"react\";\n\nexport interface DetailAsideRow {\n /**\n * Doubles as the React key, so two rows in one aside must not share a label.\n */\n label: string;\n value?: React.ReactNode;\n /**\n * Renders a copy-to-clipboard button beside the value. When `value` is\n * omitted the row renders this text as the value, in mono — the shape an id\n * row wants.\n */\n copy?: string;\n}\n\nexport interface DetailAsideProps {\n /**\n * Omit when something else on screen already names the thing — a\n * breadcrumb leaf, most often. With no title and no avatar the header\n * block is not rendered at all and the list starts at the top edge.\n */\n title?: string;\n /**\n * Thumbnail or avatar source. Falls back to {@link fallback}.\n */\n image?: string;\n /**\n * Shown in place of a missing image. Defaults to the title's initial.\n */\n fallback?: string;\n /**\n * Set `false` for an entity that has no avatar concept at all, and the\n * title stands alone.\n *\n * The letter fallback earns its place when the thing *has* a picture and\n * happens to be missing one — a user without an uploaded photo is still a\n * face-shaped hole. For something that could never have had one, a large\n * square holding the first letter of a title printed beside it is the same\n * character twice at two sizes.\n */\n avatar?: boolean;\n rows: DetailAsideRow[];\n}\n\n/**\n * The identity panel of a detail page: a thumbnail and title above a dense\n * label/value list.\n *\n * Dense rather than a marketing hero — the list is what a reader scans, so it\n * is a `<dl>` of small caps labels over their values, and a row with nothing\n * to say is left out by the caller rather than rendered empty.\n *\n * Extracted from the admin user detail page and shared by every detail page\n * since, which is why the clipboard behaviour lives here: each of them wants\n * a copyable id, and each of them had reimplemented it. It moved out of\n * `components/admin/` alongside {@link DetailLayout} once a non-admin page\n * (Lore's Epic view) became a consumer.\n */\nexport const DetailAside = (props: DetailAsideProps) => {\n const { tr } = useI18n();\n\n // Which row last had its value copied, so only that row shows the tick.\n const [copiedLabel, setCopiedLabel] = useState<string>();\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n useEffect(\n () => () => {\n if (timer.current) clearTimeout(timer.current);\n },\n [],\n );\n\n const copy = async (row: DetailAsideRow) => {\n if (!row.copy) return;\n try {\n await navigator.clipboard.writeText(row.copy);\n setCopiedLabel(row.label);\n if (timer.current) clearTimeout(timer.current);\n timer.current = setTimeout(() => setCopiedLabel(undefined), 1_500);\n } catch {\n // clipboard may be unavailable (insecure context); ignore\n }\n };\n\n const initial = (props.fallback ?? props.title ?? \"?\")\n .charAt(0)\n .toUpperCase();\n\n const showAvatar = props.avatar !== false;\n const header = showAvatar || props.title;\n\n return (\n <div className=\"flex flex-col gap-4\">\n {header ? (\n <div className=\"flex items-center gap-3\">\n {showAvatar && (\n <Avatar className=\"size-10 rounded-md after:rounded-md\">\n {props.image && (\n <AvatarImage\n src={props.image}\n alt={props.title ?? \"\"}\n className=\"rounded-md\"\n />\n )}\n <AvatarFallback className=\"rounded-md\">{initial}</AvatarFallback>\n </Avatar>\n )}\n {props.title ? (\n <span\n className=\"min-w-0 flex-1 truncate text-sm font-semibold tracking-tight\"\n title={props.title}\n >\n {props.title}\n </span>\n ) : null}\n </div>\n ) : null}\n {/* The list is a bordered card whose rows are divided from each other,\n rather than a run of rows separated by whitespace.\n\n It replaced a single `border-t` above the list, which existed only\n to separate it from the header and had to be dropped when there was\n no header to separate it from (a top border with empty space above\n it reads as a clipped element). The card's own border does that job\n on every side, so the conditional is gone: the panel looks the same\n whether or not a title sits above it.\n\n `divide-y` instead of a border on each row: a border-bottom on all\n of them doubles up against the card's own bottom edge, and skipping\n the last one by hand is the rule `divide-y` already encodes.\n\n `gap-3` had to go with it. Rows that are spaced apart AND ruled show\n the rule floating in the gap rather than meeting the rows it\n divides; `py-2.5` inside each row is what carries the rhythm now.\n\n `overflow-hidden` for the corners: with nothing painting a\n background today the radius is only on the border, but the first\n and last rows sit in the rounded corners and anything they gain\n later (a hover tint, a status band) would square them off. */}\n <dl className=\"flex flex-col divide-y overflow-hidden rounded-lg border text-sm\">\n {props.rows.map((row) => (\n <div key={row.label} className=\"flex flex-col gap-0.5 px-3 py-2.5\">\n <dt className=\"text-muted-foreground text-[11px] font-medium tracking-wide uppercase\">\n {row.label}\n </dt>\n <dd className=\"min-w-0\">\n {row.copy ? (\n <div className=\"flex items-center gap-1\">\n {row.value ?? (\n <code\n className=\"text-muted-foreground min-w-0 flex-1 truncate font-mono text-xs\"\n title={row.copy}\n >\n {row.copy}\n </code>\n )}\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-xs\"\n onClick={() => copy(row)}\n aria-label={String(\n tr(\"admin.detail.copyValue\", {\n default: `Copy ${row.label}`,\n args: [row.label],\n }),\n )}\n className=\"text-muted-foreground hover:text-foreground shrink-0\"\n >\n {copiedLabel === row.label ? (\n <Check className=\"size-3.5\" />\n ) : (\n <Copy className=\"size-3.5\" />\n )}\n </Button>\n </div>\n ) : (\n row.value\n )}\n </dd>\n </div>\n ))}\n </dl>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuEA,MAAa,eAAe,UAA4B;CACtD,MAAM,EAAE,OAAO,QAAQ;CAGvB,MAAM,CAAC,aAAa,kBAAkB,SAAiB;CACvD,MAAM,QAAQ,OAAkD,KAAA,CAAS;CACzE,sBACc;EACV,IAAI,MAAM,SAAS,aAAa,MAAM,OAAO;CAC/C,GACA,CAAC,CACH;CAEA,MAAM,OAAO,OAAO,QAAwB;EAC1C,IAAI,CAAC,IAAI,MAAM;EACf,IAAI;GACF,MAAM,UAAU,UAAU,UAAU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AC,CACH;OACA,WAAU;OAET,UAAA,gBAAgB,IAAI,QACnB,oBAAC,OAAD,EAAO,WAAU,WAAY,CAAA,IAE7B,oBAAC,MAAD,EAAM,WAAU,WAAY,CAAA;MAExB,CAAA,CACL;KAEL,CAAA,IAAA,IAAI;IAEJ,CAAA,CACD;GAvCK,GAAA,IAAI,KAuCT,CACN;EACC,CAAA,CACD;;AAET"}
|
|
1
|
+
{"version":3,"file":"detail-aside.js","names":[],"sources":["../../../src/components/detail/detail-aside.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport {\n Avatar,\n AvatarFallback,\n AvatarImage,\n} from \"@alepha/ui/components/ui/avatar\";\nimport { Button } from \"@alepha/ui/components/ui/button\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { Check, Copy } from \"lucide-react\";\nimport { useEffect, useRef, useState } from \"react\";\n\nexport interface DetailAsideRow {\n /**\n * Doubles as the React key, so two rows in one aside must not share a label.\n */\n label: string;\n value?: React.ReactNode;\n /**\n * Renders a copy-to-clipboard button beside the value. When `value` is\n * omitted the row renders this text as the value, in mono — the shape an id\n * row wants.\n */\n copy?: string;\n}\n\nexport interface DetailAsideProps {\n /**\n * Omit when something else on screen already names the thing — a\n * breadcrumb leaf, most often. With no title and no avatar the header\n * block is not rendered at all and the list starts at the top edge.\n */\n title?: string;\n /**\n * Thumbnail or avatar source. Falls back to {@link fallback}.\n */\n image?: string;\n /**\n * Shown in place of a missing image. Defaults to the title's initial.\n */\n fallback?: string;\n /**\n * Set `false` for an entity that has no avatar concept at all, and the\n * title stands alone.\n *\n * The letter fallback earns its place when the thing *has* a picture and\n * happens to be missing one — a user without an uploaded photo is still a\n * face-shaped hole. For something that could never have had one, a large\n * square holding the first letter of a title printed beside it is the same\n * character twice at two sizes.\n */\n avatar?: boolean;\n rows: DetailAsideRow[];\n}\n\n/**\n * The identity panel of a detail page: a thumbnail and title above a dense\n * label/value list.\n *\n * Dense rather than a marketing hero — the list is what a reader scans, so it\n * is a `<dl>` of small caps labels over their values, and a row with nothing\n * to say is left out by the caller rather than rendered empty.\n *\n * Extracted from the admin user detail page and shared by every detail page\n * since, which is why the clipboard behaviour lives here: each of them wants\n * a copyable id, and each of them had reimplemented it. It moved out of\n * `components/admin/` alongside {@link DetailLayout} once a non-admin page\n * (Lore's Epic view) became a consumer.\n */\nexport const DetailAside = (props: DetailAsideProps) => {\n const { tr } = useI18n();\n\n // Which row last had its value copied, so only that row shows the tick.\n const [copiedLabel, setCopiedLabel] = useState<string>();\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n useEffect(\n () => () => {\n if (timer.current) clearTimeout(timer.current);\n },\n [],\n );\n\n const copy = async (row: DetailAsideRow) => {\n if (!row.copy) return;\n try {\n await navigator.clipboard.writeText(row.copy);\n setCopiedLabel(row.label);\n if (timer.current) clearTimeout(timer.current);\n timer.current = setTimeout(() => setCopiedLabel(undefined), 1_500);\n } catch {\n // clipboard may be unavailable (insecure context); ignore\n }\n };\n\n const initial = (props.fallback ?? props.title ?? \"?\")\n .charAt(0)\n .toUpperCase();\n\n const showAvatar = props.avatar !== false;\n const header = showAvatar || props.title;\n\n return (\n <div className=\"flex flex-col gap-4\">\n {header ? (\n <div className=\"flex items-center gap-3\">\n {showAvatar && (\n <Avatar className=\"size-10 rounded-md after:rounded-md\">\n {props.image && (\n <AvatarImage\n src={props.image}\n alt={props.title ?? \"\"}\n className=\"rounded-md\"\n />\n )}\n <AvatarFallback className=\"rounded-md\">{initial}</AvatarFallback>\n </Avatar>\n )}\n {props.title ? (\n <span\n className=\"min-w-0 flex-1 truncate text-sm font-semibold tracking-tight\"\n title={props.title}\n >\n {props.title}\n </span>\n ) : null}\n </div>\n ) : null}\n {/* The list is a bordered card whose rows are divided from each other,\n rather than a run of rows separated by whitespace.\n\n It replaced a single `border-t` above the list, which existed only\n to separate it from the header and had to be dropped when there was\n no header to separate it from (a top border with empty space above\n it reads as a clipped element). The card's own border does that job\n on every side, so the conditional is gone: the panel looks the same\n whether or not a title sits above it.\n\n `divide-y` instead of a border on each row: a border-bottom on all\n of them doubles up against the card's own bottom edge, and skipping\n the last one by hand is the rule `divide-y` already encodes.\n\n `gap-3` had to go with it. Rows that are spaced apart AND ruled show\n the rule floating in the gap rather than meeting the rows it\n divides; `py-2.5` inside each row is what carries the rhythm now.\n\n `overflow-hidden` for the corners: the card paints a background, so\n the first and last rows sit in the rounded corners and would square\n them off without it.\n\n That background is the table header's - `bg-muted` under a\n `--bevel` line - because this panel is the same kind of thing:\n chrome that frames the page rather than body the reader is in. Two\n adjacent lines of opposite polarity read as a fold, which is what\n lifts the surface off the page instead of leaving it drawn onto it.\n Same pair on `PlateTabBar`.\n\n The bevel is on each ROW, not once on the card, so every row is its\n own slab and the stack reads as slabs stacked rather than as one\n slab ruled into sections. Each row already has the line the bevel\n folds against: `divide-y` gives rows 2..n a `border-t`, and the\n card's own border closes the first one, which is why the same class\n on every row lands the same way on all of them. */}\n <dl className=\"bg-muted flex flex-col divide-y overflow-hidden rounded-lg border text-sm\">\n {props.rows.map((row) => (\n <div\n key={row.label}\n className=\"flex flex-col gap-0.5 px-3 py-2.5 shadow-[inset_0_1px_0_0_var(--bevel)]\"\n >\n <dt className=\"text-muted-foreground text-[11px] font-medium tracking-wide uppercase\">\n {row.label}\n </dt>\n <dd className=\"min-w-0\">\n {row.copy ? (\n <div className=\"flex items-center gap-1\">\n {row.value ?? (\n <code\n className=\"text-muted-foreground min-w-0 flex-1 truncate font-mono text-xs\"\n title={row.copy}\n >\n {row.copy}\n </code>\n )}\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-xs\"\n onClick={() => copy(row)}\n aria-label={String(\n tr(\"admin.detail.copyValue\", {\n default: `Copy ${row.label}`,\n args: [row.label],\n }),\n )}\n // No background override, even though `ghost` hovers to\n // `bg-muted` and the card is now `bg-muted` too. That\n // class does not resolve to the opaque token: `styles.css`\n // redirects it to `--state-layer`, a 10% `--foreground`\n // wash that DARKENS in light and lifts in dark, so it\n // reads over whatever surface it lands on. A literal\n // `hover:bg-background` here looked correct in dark and\n // went white-on-grey in light.\n className=\"text-muted-foreground hover:text-foreground shrink-0\"\n >\n {copiedLabel === row.label ? (\n <Check className=\"size-3.5\" />\n ) : (\n <Copy className=\"size-3.5\" />\n )}\n </Button>\n </div>\n ) : (\n row.value\n )}\n </dd>\n </div>\n ))}\n </dl>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuEA,MAAa,eAAe,UAA4B;CACtD,MAAM,EAAE,OAAO,QAAQ;CAGvB,MAAM,CAAC,aAAa,kBAAkB,SAAiB;CACvD,MAAM,QAAQ,OAAkD,KAAA,CAAS;CACzE,sBACc;EACV,IAAI,MAAM,SAAS,aAAa,MAAM,OAAO;CAC/C,GACA,CAAC,CACH;CAEA,MAAM,OAAO,OAAO,QAAwB;EAC1C,IAAI,CAAC,IAAI,MAAM;EACf,IAAI;GACF,MAAM,UAAU,UAAU,UAAU,IAAI,IAAI;GAC5C,eAAe,IAAI,KAAK;GACxB,IAAI,MAAM,SAAS,aAAa,MAAM,OAAO;GAC7C,MAAM,UAAU,iBAAiB,eAAe,KAAA,CAAS,GAAG,IAAK;EACnE,QAAQ,CAER;CACF;CAEA,MAAM,WAAW,MAAM,YAAY,MAAM,SAAS,IAAA,CAC/C,OAAO,CAAC,CAAC,CACT,YAAY;CAEf,MAAM,aAAa,MAAM,WAAW;CACpC,MAAM,SAAS,cAAc,MAAM;CAEnC,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACG,SACC,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACG,cACC,qBAAC,QAAD;IAAQ,WAAU;IAAlB,UAAA,CACG,MAAM,SACL,oBAAC,aAAD;KACE,KAAK,MAAM;KACX,KAAK,MAAM,SAAS;KACpB,WAAU;IACX,CAAA,GAEH,oBAAC,gBAAD;KAAgB,WAAU;KAAc,UAAA;IAAwB,CAAA,CAC1D;GAET,CAAA,GAAA,MAAM,QACL,oBAAC,QAAD;IACE,WAAU;IACV,OAAO,MAAM;IAEZ,UAAA,MAAM;GACH,CAAA,IACJ,IACD;EACH,CAAA,IAAA,MAoCJ,oBAAC,MAAD;GAAI,WAAU;GACX,UAAA,MAAM,KAAK,KAAK,QACf,qBAAC,OAAD;IAEE,WAAU;IAFZ,UAAA,CAIE,oBAAC,MAAD;KAAI,WAAU;KACX,UAAA,IAAI;IACH,CAAA,GACJ,oBAAC,MAAD;KAAI,WAAU;KACX,UAAA,IAAI,OACH,qBAAC,OAAD;MAAK,WAAU;MAAf,UAAA,CACG,IAAI,SACH,oBAAC,QAAD;OACE,WAAU;OACV,OAAO,IAAI;OAEV,UAAA,IAAI;MACD,CAAA,GAER,oBAAC,QAAD;OACE,MAAK;OACL,SAAQ;OACR,MAAK;OACL,eAAe,KAAK,GAAG;OACvB,cAAY,OACV,GAAG,0BAA0B;QAC3B,SAAS,QAAQ,IAAI;QACrB,MAAM,CAAC,IAAI,KAAK;OAClB,CAAC,CACH;OASA,WAAU;OAET,UAAA,gBAAgB,IAAI,QACnB,oBAAC,OAAD,EAAO,WAAU,WAAY,CAAA,IAE7B,oBAAC,MAAD,EAAM,WAAU,WAAY,CAAA;MAExB,CAAA,CACL;KAEL,CAAA,IAAA,IAAI;IAEJ,CAAA,CACD;GAjDE,GAAA,IAAI,KAiDN,CACN;EACC,CAAA,CACD;;AAET"}
|
|
@@ -13,9 +13,10 @@ const FileImage = (props) => {
|
|
|
13
13
|
const { id, public: isPublic, fallback = null, ...imgProps } = props;
|
|
14
14
|
const [erroredId, setErroredId] = useState(null);
|
|
15
15
|
if (!id || erroredId === id) return /* @__PURE__ */ jsx(Fragment$1, { children: fallback });
|
|
16
|
+
const src = isPublic ? `/api/public/files/${id}` : `/api/files/${id}`;
|
|
16
17
|
return /* @__PURE__ */ jsx("img", {
|
|
17
18
|
alt: "",
|
|
18
|
-
src
|
|
19
|
+
src,
|
|
19
20
|
loading: "lazy",
|
|
20
21
|
onError: () => setErroredId(id),
|
|
21
22
|
...imgProps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-image.js","names":[],"sources":["../../../src/components/file-image/file-image.tsx"],"sourcesContent":["import { type ComponentProps, type ReactNode, useState } from \"react\";\n\nexport interface FileImageProps extends Omit<\n ComponentProps<\"img\">,\n \"src\" | \"id\"\n> {\n /**\n * File id (uuid) served by the Alepha files module. Absent → renders\n * `fallback`. (Repurposes the `id` slot — the raw HTML `id` attribute\n * isn't forwarded.)\n */\n id?: string | null;\n /**\n * Serve via the anonymous, edge-cacheable `/api/public/files/:id` route\n * instead of the authenticated `/api/files/:id`. Only valid for files the\n * server opts into (`FileAccessProvider.assertPublic`). Default:\n * authenticated.\n */\n public?: boolean;\n /**\n * Rendered when `id` is missing OR the image fails to load (deleted, 404,\n * forbidden) — a placeholder icon/initials instead of a broken-image glyph.\n */\n fallback?: ReactNode;\n}\n\n/**\n * `<img>` for a file served by the Alepha files module, addressed by uuid.\n *\n * Resolves the src from `id` (`public` picks the anonymous edge-cacheable\n * route vs the authenticated one), lazy-loads, and renders `fallback` when\n * the id is missing or the image fails to load — so a deleted/forbidden\n * file shows a placeholder instead of a broken-image glyph.\n */\nexport const FileImage = (props: FileImageProps) => {\n const { id, public: isPublic, fallback = null, ...imgProps } = props;\n // Track the id that failed so a later id change re-attempts the load.\n const [erroredId, setErroredId] = useState<string | null>(null);\n\n if (!id || erroredId === id) {\n return <>{fallback}</>;\n }\n\n const src = isPublic ? `/api/public/files/${id}` : `/api/files/${id}`;\n return (\n <img\n alt=\"\"\n src={src}\n loading=\"lazy\"\n onError={() => setErroredId(id)}\n {...imgProps}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;AAkCA,MAAa,aAAa,UAA0B;CAClD,MAAM,EAAE,IAAI,QAAQ,UAAU,WAAW,MAAM,GAAG,aAAa;CAE/D,MAAM,CAAC,WAAW,gBAAgB,SAAwB,IAAI;CAE9D,IAAI,CAAC,MAAM,cAAc,IACvB,OAAO,oBAAA,YAAA,EAAA,UAAG,SAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"file-image.js","names":[],"sources":["../../../src/components/file-image/file-image.tsx"],"sourcesContent":["import { type ComponentProps, type ReactNode, useState } from \"react\";\n\nexport interface FileImageProps extends Omit<\n ComponentProps<\"img\">,\n \"src\" | \"id\"\n> {\n /**\n * File id (uuid) served by the Alepha files module. Absent → renders\n * `fallback`. (Repurposes the `id` slot — the raw HTML `id` attribute\n * isn't forwarded.)\n */\n id?: string | null;\n /**\n * Serve via the anonymous, edge-cacheable `/api/public/files/:id` route\n * instead of the authenticated `/api/files/:id`. Only valid for files the\n * server opts into (`FileAccessProvider.assertPublic`). Default:\n * authenticated.\n */\n public?: boolean;\n /**\n * Rendered when `id` is missing OR the image fails to load (deleted, 404,\n * forbidden) — a placeholder icon/initials instead of a broken-image glyph.\n */\n fallback?: ReactNode;\n}\n\n/**\n * `<img>` for a file served by the Alepha files module, addressed by uuid.\n *\n * Resolves the src from `id` (`public` picks the anonymous edge-cacheable\n * route vs the authenticated one), lazy-loads, and renders `fallback` when\n * the id is missing or the image fails to load — so a deleted/forbidden\n * file shows a placeholder instead of a broken-image glyph.\n */\nexport const FileImage = (props: FileImageProps) => {\n const { id, public: isPublic, fallback = null, ...imgProps } = props;\n // Track the id that failed so a later id change re-attempts the load.\n const [erroredId, setErroredId] = useState<string | null>(null);\n\n if (!id || erroredId === id) {\n return <>{fallback}</>;\n }\n\n const src = isPublic ? `/api/public/files/${id}` : `/api/files/${id}`;\n return (\n <img\n alt=\"\"\n src={src}\n loading=\"lazy\"\n onError={() => setErroredId(id)}\n {...imgProps}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;AAkCA,MAAa,aAAa,UAA0B;CAClD,MAAM,EAAE,IAAI,QAAQ,UAAU,WAAW,MAAM,GAAG,aAAa;CAE/D,MAAM,CAAC,WAAW,gBAAgB,SAAwB,IAAI;CAE9D,IAAI,CAAC,MAAM,cAAc,IACvB,OAAO,oBAAA,YAAA,EAAA,UAAG,SAAW,CAAA;CAGvB,MAAM,MAAM,WAAW,qBAAqB,OAAO,cAAc;CACjE,OACE,oBAAC,OAAD;EACE,KAAI;EACC;EACL,SAAQ;EACR,eAAe,aAAa,EAAE;EAC9B,GAAI;CACL,CAAA;AAEL"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface SpoilerSpanProps {
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* A `||spoiler||`, hidden until the reader asks for it.
|
|
7
|
+
*
|
|
8
|
+
* ## ⚠️ It is not a security feature
|
|
9
|
+
*
|
|
10
|
+
* The text is in the DOM from the first paint - hidden by a colour, not by an
|
|
11
|
+
* absence. It is also in the raw markdown, in a folio export, in `folio_get`
|
|
12
|
+
* over MCP and in any search snippet. It hides a plot point from a reader's
|
|
13
|
+
* eye and nothing more, and must never be described as a way to store a
|
|
14
|
+
* secret.
|
|
15
|
+
*
|
|
16
|
+
* ## Reachable without a mouse
|
|
17
|
+
*
|
|
18
|
+
* `role="button"` with a `tabIndex`, Enter and Space, and an `aria-label`
|
|
19
|
+
* naming what it is: a screen reader that met a bare `<span>` here would
|
|
20
|
+
* simply read the hidden text aloud, which is not a failure of privacy (see
|
|
21
|
+
* above) but is a failure to say that the author meant it to be covered.
|
|
22
|
+
*
|
|
23
|
+
* Once revealed it stays revealed. Re-hiding on blur would make the thing
|
|
24
|
+
* unreadable with a keyboard, since moving on to read what is around it is
|
|
25
|
+
* exactly what a reader does next.
|
|
26
|
+
*/
|
|
27
|
+
export declare const SpoilerSpan: (props: SpoilerSpanProps) => React.JSX.Element;
|
|
28
|
+
//# sourceMappingURL=SpoilerSpan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpoilerSpan.d.ts","sourceRoot":"","sources":["../../../src/components/markdown-view/SpoilerSpan.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,WAAW,UAAW,gBAAgB,sBAiClD,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/markdown-view/SpoilerSpan.tsx
|
|
4
|
+
/**
|
|
5
|
+
* A `||spoiler||`, hidden until the reader asks for it.
|
|
6
|
+
*
|
|
7
|
+
* ## ⚠️ It is not a security feature
|
|
8
|
+
*
|
|
9
|
+
* The text is in the DOM from the first paint - hidden by a colour, not by an
|
|
10
|
+
* absence. It is also in the raw markdown, in a folio export, in `folio_get`
|
|
11
|
+
* over MCP and in any search snippet. It hides a plot point from a reader's
|
|
12
|
+
* eye and nothing more, and must never be described as a way to store a
|
|
13
|
+
* secret.
|
|
14
|
+
*
|
|
15
|
+
* ## Reachable without a mouse
|
|
16
|
+
*
|
|
17
|
+
* `role="button"` with a `tabIndex`, Enter and Space, and an `aria-label`
|
|
18
|
+
* naming what it is: a screen reader that met a bare `<span>` here would
|
|
19
|
+
* simply read the hidden text aloud, which is not a failure of privacy (see
|
|
20
|
+
* above) but is a failure to say that the author meant it to be covered.
|
|
21
|
+
*
|
|
22
|
+
* Once revealed it stays revealed. Re-hiding on blur would make the thing
|
|
23
|
+
* unreadable with a keyboard, since moving on to read what is around it is
|
|
24
|
+
* exactly what a reader does next.
|
|
25
|
+
*/
|
|
26
|
+
const SpoilerSpan = (props) => {
|
|
27
|
+
const [revealed, setRevealed] = useState(false);
|
|
28
|
+
if (revealed) return /* @__PURE__ */ jsx("span", {
|
|
29
|
+
"data-spoiler": "revealed",
|
|
30
|
+
className: "rounded-[3px] px-0.5",
|
|
31
|
+
children: props.children
|
|
32
|
+
});
|
|
33
|
+
return /* @__PURE__ */ jsx("span", {
|
|
34
|
+
"data-spoiler": "hidden",
|
|
35
|
+
role: "button",
|
|
36
|
+
tabIndex: 0,
|
|
37
|
+
"aria-expanded": false,
|
|
38
|
+
"aria-label": "Hidden text, activate to reveal",
|
|
39
|
+
className: "rounded-[3px] px-0.5",
|
|
40
|
+
onClick: () => setRevealed(true),
|
|
41
|
+
onKeyDown: (event) => {
|
|
42
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
setRevealed(true);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
children: props.children
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { SpoilerSpan };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=SpoilerSpan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpoilerSpan.js","names":[],"sources":["../../../src/components/markdown-view/SpoilerSpan.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { useState } from \"react\";\n\nexport interface SpoilerSpanProps {\n children?: React.ReactNode;\n}\n\n/**\n * A `||spoiler||`, hidden until the reader asks for it.\n *\n * ## ⚠️ It is not a security feature\n *\n * The text is in the DOM from the first paint - hidden by a colour, not by an\n * absence. It is also in the raw markdown, in a folio export, in `folio_get`\n * over MCP and in any search snippet. It hides a plot point from a reader's\n * eye and nothing more, and must never be described as a way to store a\n * secret.\n *\n * ## Reachable without a mouse\n *\n * `role=\"button\"` with a `tabIndex`, Enter and Space, and an `aria-label`\n * naming what it is: a screen reader that met a bare `<span>` here would\n * simply read the hidden text aloud, which is not a failure of privacy (see\n * above) but is a failure to say that the author meant it to be covered.\n *\n * Once revealed it stays revealed. Re-hiding on blur would make the thing\n * unreadable with a keyboard, since moving on to read what is around it is\n * exactly what a reader does next.\n */\nexport const SpoilerSpan = (props: SpoilerSpanProps) => {\n const [revealed, setRevealed] = useState(false);\n\n if (revealed) {\n return (\n <span data-spoiler=\"revealed\" className=\"rounded-[3px] px-0.5\">\n {props.children}\n </span>\n );\n }\n\n return (\n <span\n data-spoiler=\"hidden\"\n role=\"button\"\n tabIndex={0}\n aria-expanded={false}\n aria-label=\"Hidden text, activate to reveal\"\n className=\"rounded-[3px] px-0.5\"\n onClick={() => setRevealed(true)}\n onKeyDown={(event) => {\n // Enter and Space, because `role=\"button\"` promises both and a `span`\n // delivers neither on its own. `preventDefault` on Space stops the\n // page scrolling out from under the reader who just pressed it.\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n setRevealed(true);\n }\n }}\n >\n {props.children}\n </span>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,eAAe,UAA4B;CACtD,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAE9C,IAAI,UACF,OACE,oBAAC,QAAD;EAAM,gBAAa;EAAW,WAAU;EACrC,UAAA,MAAM;CACH,CAAA;CAIV,OACE,oBAAC,QAAD;EACE,gBAAa;EACb,MAAK;EACL,UAAU;EACV,iBAAe;EACf,cAAW;EACX,WAAU;EACV,eAAe,YAAY,IAAI;EAC/B,YAAY,UAAU;GAIpB,IAAI,MAAM,QAAQ,WAAW,MAAM,QAAQ,KAAK;IAC9C,MAAM,eAAe;IACrB,YAAY,IAAI;GAClB;EACF;EAEC,UAAA,MAAM;CACH,CAAA;AAEV"}
|
|
@@ -40,8 +40,6 @@ const MAX_SEQUENCE_MESSAGES = 300;
|
|
|
40
40
|
*/
|
|
41
41
|
const GAP_LABEL_MARGIN = 1.04;
|
|
42
42
|
const DIAGRAM_PADDING = 12;
|
|
43
|
-
const PARTICIPANT_PAD_X = 14;
|
|
44
|
-
const PARTICIPANT_PAD_Y = 8;
|
|
45
43
|
const PARTICIPANT_MIN_WIDTH = 64;
|
|
46
44
|
/**
|
|
47
45
|
* Clear space between two adjacent participant boxes, before any label
|
|
@@ -62,14 +60,8 @@ const SELF_LOOP_WIDTH = 32;
|
|
|
62
60
|
const SELF_LOOP_LABEL_GAP = 8;
|
|
63
61
|
const SELF_LOOP_MIN_HEIGHT = 26;
|
|
64
62
|
const SELF_LOOP_TOP_PAD = 4;
|
|
65
|
-
const NOTE_PAD_X = 10;
|
|
66
|
-
const NOTE_PAD_Y = 7;
|
|
67
63
|
const NOTE_ROW_GAP = 14;
|
|
68
64
|
/**
|
|
69
|
-
* How far a `Note over A,B` reaches past the two lifelines it spans.
|
|
70
|
-
*/
|
|
71
|
-
const NOTE_SPAN_OVERHANG = 10;
|
|
72
|
-
/**
|
|
73
65
|
* Clearance between a note box and any lifeline it is not attached to.
|
|
74
66
|
*/
|
|
75
67
|
const NOTE_CLEARANCE = 10;
|
|
@@ -78,8 +70,6 @@ const FRAGMENT_INSET = 9;
|
|
|
78
70
|
* How far a depth-0 fragment box reaches past the widest content.
|
|
79
71
|
*/
|
|
80
72
|
const FRAGMENT_MARGIN = 14;
|
|
81
|
-
const FRAGMENT_TAB_PAD_X = 8;
|
|
82
|
-
const FRAGMENT_TAB_PAD_Y = 3;
|
|
83
73
|
const FRAGMENT_TOP_PAD = 8;
|
|
84
74
|
const FRAGMENT_BOTTOM_PAD = 10;
|
|
85
75
|
const FRAGMENT_AFTER_GAP = 6;
|
|
@@ -129,7 +119,7 @@ const layoutSequence = (model, fontSize = 13) => {
|
|
|
129
119
|
const maxX = fragments.length ? content.maxX + FRAGMENT_MARGIN : content.maxX;
|
|
130
120
|
const dx = DIAGRAM_PADDING - minX;
|
|
131
121
|
return {
|
|
132
|
-
width: maxX - minX +
|
|
122
|
+
width: maxX - minX + 24,
|
|
133
123
|
height: rows.bottom + headerHeight + DIAGRAM_PADDING,
|
|
134
124
|
fontSize,
|
|
135
125
|
participants: participants.map((participant) => ({
|
|
@@ -171,8 +161,8 @@ const measureHead = (lines, actor, fontSize) => {
|
|
|
171
161
|
lines: label.lines
|
|
172
162
|
};
|
|
173
163
|
return {
|
|
174
|
-
width: Math.max(label.width +
|
|
175
|
-
height: label.height +
|
|
164
|
+
width: Math.max(label.width + 28, PARTICIPANT_MIN_WIDTH),
|
|
165
|
+
height: label.height + 16,
|
|
176
166
|
lines: label.lines
|
|
177
167
|
};
|
|
178
168
|
};
|
|
@@ -188,8 +178,8 @@ const measureSteps = (model, fontSize) => {
|
|
|
188
178
|
if (step.kind === "note") {
|
|
189
179
|
const label = measureLabel(step.lines, fontSize);
|
|
190
180
|
return {
|
|
191
|
-
width: label.width +
|
|
192
|
-
height: label.height +
|
|
181
|
+
width: label.width + 20,
|
|
182
|
+
height: label.height + 14,
|
|
193
183
|
lines: label.lines
|
|
194
184
|
};
|
|
195
185
|
}
|
|
@@ -240,13 +230,13 @@ const columnCenters = (model, index, heads, labels) => {
|
|
|
240
230
|
widen(from, from + 1, 40 + label.width * GAP_LABEL_MARGIN + MESSAGE_LABEL_GUTTER);
|
|
241
231
|
continue;
|
|
242
232
|
}
|
|
243
|
-
widen(Math.min(from, to), Math.max(from, to), label.width * GAP_LABEL_MARGIN +
|
|
233
|
+
widen(Math.min(from, to), Math.max(from, to), label.width * GAP_LABEL_MARGIN + 20);
|
|
244
234
|
continue;
|
|
245
235
|
}
|
|
246
236
|
const anchors = step.participants.map((id) => index.get(id)).filter((at) => at !== void 0);
|
|
247
237
|
if (anchors.length === 0) continue;
|
|
248
238
|
if (step.placement === "over" && anchors.length > 1) {
|
|
249
|
-
widen(Math.min(...anchors), Math.max(...anchors), label.width -
|
|
239
|
+
widen(Math.min(...anchors), Math.max(...anchors), label.width - 20);
|
|
250
240
|
continue;
|
|
251
241
|
}
|
|
252
242
|
const anchor = anchors[0];
|
|
@@ -255,8 +245,8 @@ const columnCenters = (model, index, heads, labels) => {
|
|
|
255
245
|
widen(anchor, anchor + 1, label.width / 2 + NOTE_CLEARANCE);
|
|
256
246
|
continue;
|
|
257
247
|
}
|
|
258
|
-
if (step.placement === "left") widen(anchor - 1, anchor, label.width +
|
|
259
|
-
else widen(anchor, anchor + 1, label.width +
|
|
248
|
+
if (step.placement === "left") widen(anchor - 1, anchor, label.width + 20);
|
|
249
|
+
else widen(anchor, anchor + 1, label.width + 20);
|
|
260
250
|
}
|
|
261
251
|
const centers = [0];
|
|
262
252
|
for (const gap of gaps) centers.push(centers[centers.length - 1] + gap);
|
|
@@ -273,7 +263,7 @@ const layoutRows = (model, index, centers, labels, context) => {
|
|
|
273
263
|
const messages = [];
|
|
274
264
|
const notes = [];
|
|
275
265
|
const spans = /* @__PURE__ */ new Map();
|
|
276
|
-
const tabHeight = context.fontSize * DIAGRAM_LINE_HEIGHT +
|
|
266
|
+
const tabHeight = context.fontSize * DIAGRAM_LINE_HEIGHT + 6;
|
|
277
267
|
const opening = byStep(model, (fragment) => fragment.from, 1);
|
|
278
268
|
const closing = byStep(model, (fragment) => fragment.to, -1);
|
|
279
269
|
const dividing = dividersByStep(model);
|
|
@@ -409,7 +399,7 @@ const placeNote = (step, label, index, centers, y, out) => {
|
|
|
409
399
|
if (anchors.length === 0) return y;
|
|
410
400
|
const from = Math.min(...anchors);
|
|
411
401
|
const to = Math.max(...anchors);
|
|
412
|
-
const width = step.placement === "over" && to > from ? Math.max(label.width, centers[to] - centers[from] +
|
|
402
|
+
const width = step.placement === "over" && to > from ? Math.max(label.width, centers[to] - centers[from] + 20) : label.width;
|
|
413
403
|
const x = step.placement === "left" ? centers[from] - NOTE_CLEARANCE - width : step.placement === "right" ? centers[from] + NOTE_CLEARANCE : (centers[from] + centers[to]) / 2 - width / 2;
|
|
414
404
|
out.push({
|
|
415
405
|
placement: step.placement,
|
|
@@ -464,8 +454,8 @@ const layoutFragments = (model, rows, content, fontSize) => model.fragments.map(
|
|
|
464
454
|
y: span.top,
|
|
465
455
|
width: Math.max(right - x, FRAGMENT_MIN_WIDTH),
|
|
466
456
|
height: span.bottom - span.top,
|
|
467
|
-
tabWidth: label.width +
|
|
468
|
-
tabHeight: label.height +
|
|
457
|
+
tabWidth: label.width + 16,
|
|
458
|
+
tabHeight: label.height + 6,
|
|
469
459
|
dividers: fragment.dividers.map((divider, i) => ({
|
|
470
460
|
y: span.dividers[i] ?? span.top,
|
|
471
461
|
label: divider.label
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layoutSequence.js","names":[],"sources":["../../../../src/components/markdown-view/diagram/layoutSequence.ts"],"sourcesContent":["import type {\n SequenceArrowHead,\n SequenceFragment,\n SequenceFragmentKind,\n SequenceLineStyle,\n SequenceModel,\n SequenceNote,\n SequenceStep,\n} from \"./sequenceModel.ts\";\nimport {\n DIAGRAM_FONT_SIZE,\n DIAGRAM_LINE_HEIGHT,\n measureLabel,\n} from \"./textMetrics.ts\";\n\n/**\n * The largest diagram that gets laid out. Above either cap the caller falls\n * back to the code block.\n *\n * Unlike the flowchart caps these are NOT about time: layout here is O(n)\n * arithmetic with no ranking to compute, and 300 rows lay out in under a\n * millisecond. They are about legibility and DOM size - 30 lifelines is\n * already far past what anyone can read, and every row is a handful of SVG\n * elements on a page that may carry several diagrams.\n *\n * `MAX_SEQUENCE_MESSAGES` counts ROWS, notes included: a note occupies a\n * row and costs a box, so counting only messages would let a note-heavy\n * diagram past the cap it exists to enforce.\n */\nexport const MAX_SEQUENCE_PARTICIPANTS = 30;\nexport const MAX_SEQUENCE_MESSAGES = 300;\n\n/**\n * The safety margin applied to the width a label needs in the gap between\n * two lifelines. **Gap constraints only** - not participant boxes, which\n * stay tight, and not note boxes, which carry their own padding.\n *\n * ## Why a margin exists here and nowhere else\n *\n * `textMetrics.ts` measures text from a generated per-character width table\n * rather than from the DOM, which is what keeps this a pure function. The\n * table was measured against `canvas.measureText` on the real Inter woff2\n * and agrees **within ~1.3%**, all of it from rounding the ratios to three\n * decimals.\n *\n * The asymmetry is what makes the margin necessary at all. A flowchart\n * label sits INSIDE its box, so a 1.3% underestimate only eats padding. A\n * sequence label sits IN THE GAP between two lifelines, so the same\n * underestimate puts text on top of the neighbouring lifeline. 4% is three\n * times the measured error.\n *\n * Do not \"optimise\" this away as a magic number: it is a measured 1.3% with\n * headroom, and removing it makes long labels collide.\n */\nexport const GAP_LABEL_MARGIN = 1.04;\n\nconst DIAGRAM_PADDING = 12;\nconst PARTICIPANT_PAD_X = 14;\nconst PARTICIPANT_PAD_Y = 8;\nconst PARTICIPANT_MIN_WIDTH = 64;\n/**\n * Clear space between two adjacent participant boxes, before any label\n * widens the gap.\n */\nconst PARTICIPANT_CLEARANCE = 26;\n/**\n * The stick figure an `actor` draws above its name.\n */\nconst ACTOR_FIGURE_HEIGHT = 32;\nconst ACTOR_LABEL_GAP = 4;\nconst ACTOR_MIN_WIDTH = 40;\n\nconst LIFELINE_TOP_GAP = 14;\nconst LIFELINE_BOTTOM_GAP = 14;\n\nconst MESSAGE_LABEL_GAP = 4;\nconst MESSAGE_ROW_GAP = 16;\n/**\n * Clearance between a message label and each lifeline it is centred\n * between.\n */\nconst MESSAGE_LABEL_GUTTER = 10;\n\nconst SELF_LOOP_WIDTH = 32;\nconst SELF_LOOP_LABEL_GAP = 8;\nconst SELF_LOOP_MIN_HEIGHT = 26;\nconst SELF_LOOP_TOP_PAD = 4;\n\nconst NOTE_PAD_X = 10;\nconst NOTE_PAD_Y = 7;\nconst NOTE_ROW_GAP = 14;\n/**\n * How far a `Note over A,B` reaches past the two lifelines it spans.\n */\nconst NOTE_SPAN_OVERHANG = 10;\n/**\n * Clearance between a note box and any lifeline it is not attached to.\n */\nconst NOTE_CLEARANCE = 10;\n\nconst FRAGMENT_INSET = 9;\n/**\n * How far a depth-0 fragment box reaches past the widest content.\n */\nconst FRAGMENT_MARGIN = 14;\nconst FRAGMENT_TAB_PAD_X = 8;\nconst FRAGMENT_TAB_PAD_Y = 3;\nconst FRAGMENT_TOP_PAD = 8;\nconst FRAGMENT_BOTTOM_PAD = 10;\nconst FRAGMENT_AFTER_GAP = 6;\nconst FRAGMENT_MIN_WIDTH = 60;\nconst DIVIDER_GAP = 8;\n\nexport interface PositionedParticipant {\n id: string;\n /**\n * The lines as MEASURED - wrapped and capped. Draw exactly these.\n */\n lines: string[];\n actor: boolean;\n /**\n * TOP-LEFT corner of the header box, the same convention the flowchart\n * layout settled on. An emitter half a box off looks almost right, which\n * is the worst way for this to be wrong.\n */\n x: number;\n y: number;\n width: number;\n height: number;\n /**\n * Where the lifeline runs. `centerX` is the lifeline's x, and the box is\n * centred on it.\n */\n centerX: number;\n lifelineTop: number;\n lifelineBottom: number;\n /**\n * TOP-LEFT y of the repeated footer box. Its `x`, `width` and `height`\n * are the header's.\n */\n bottomY: number;\n}\n\nexport interface PositionedLabel {\n lines: string[];\n /**\n * TOP-LEFT corner.\n */\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface PositionedMessage {\n from: string;\n to: string;\n line: SequenceLineStyle;\n head: SequenceArrowHead;\n self: boolean;\n /**\n * Two points for a normal message, four for the loop of a self-message.\n * In from-to order, so the head marker lands on the receiver.\n */\n points: Array<{ x: number; y: number }>;\n /**\n * Already carries the `autonumber` counter when the diagram declared one.\n */\n label: PositionedLabel;\n}\n\nexport interface PositionedNoteBox extends PositionedLabel {\n placement: SequenceNote[\"placement\"];\n}\n\nexport interface PositionedFragment {\n kind: SequenceFragmentKind;\n /**\n * The condition, drawn next to the tab. May be empty.\n */\n label: string;\n depth: number;\n /**\n * TOP-LEFT corner of the box.\n */\n x: number;\n y: number;\n width: number;\n height: number;\n /**\n * The corner tab carrying the kind (`alt`, `opt`, `loop`).\n */\n tabWidth: number;\n tabHeight: number;\n dividers: Array<{ y: number; label: string }>;\n}\n\n/**\n * A laid-out sequence diagram: data, not markup. No SVG, no React, no DOM.\n */\nexport interface PositionedSequence {\n width: number;\n height: number;\n fontSize: number;\n participants: PositionedParticipant[];\n messages: PositionedMessage[];\n notes: PositionedNoteBox[];\n /**\n * Outermost first, so the emitter draws them in order and gets z-order\n * free, the way the flowchart clusters do.\n */\n fragments: PositionedFragment[];\n}\n\n/**\n * Place a `SequenceModel` on a plane.\n *\n * **No layout library is involved, and none is coming back.** `graphre`\n * ranks a node graph; here both axes are already decided by the source -\n * participants left to right in declaration order, rows top to bottom in\n * statement order - so layout is arithmetic. The only genuinely hard part\n * is the column widths, which take two passes (see `columnCenters`).\n *\n * Returns `undefined` (never throws, never a partial diagram) for an empty\n * model or one past the caps. The caller's fallback is the code block.\n */\nexport const layoutSequence = (\n model: SequenceModel,\n fontSize: number = DIAGRAM_FONT_SIZE,\n): PositionedSequence | undefined => {\n if (model.participants.length === 0 || model.steps.length === 0)\n return undefined;\n if (model.participants.length > MAX_SEQUENCE_PARTICIPANTS) return undefined;\n if (model.steps.length > MAX_SEQUENCE_MESSAGES) return undefined;\n\n const index = new Map(model.participants.map((p, i) => [p.id, i]));\n const heads = model.participants.map((participant) =>\n measureHead(participant.lines, participant.actor, fontSize),\n );\n // ⚠️ Numbering happens BEFORE anything is measured. The counter is part of\n // the label, so measuring first and numbering after makes every column\n // too narrow - and it stays invisible until a diagram reaches ten\n // messages and the labels go double-digit.\n const labels = measureSteps(model, fontSize);\n\n const centers = columnCenters(model, index, heads, labels);\n const headerHeight = Math.max(...heads.map((head) => head.height));\n\n const rows = layoutRows(model, index, centers, labels, {\n fontSize,\n top: DIAGRAM_PADDING + headerHeight + LIFELINE_TOP_GAP,\n });\n\n const participants = model.participants.map((participant, i) => ({\n id: participant.id,\n lines: heads[i].lines,\n actor: participant.actor,\n // Header boxes are bottom-aligned so every lifeline starts on the same\n // y, whatever mix of one-line names, wrapped names and actors is on the\n // row.\n x: centers[i] - heads[i].width / 2,\n y: DIAGRAM_PADDING + headerHeight - heads[i].height,\n width: heads[i].width,\n height: heads[i].height,\n centerX: centers[i],\n lifelineTop: DIAGRAM_PADDING + headerHeight,\n lifelineBottom: rows.bottom,\n bottomY: rows.bottom,\n }));\n\n const content = contentBounds(participants, rows);\n const fragments = layoutFragments(model, rows, content, fontSize);\n\n const minX = fragments.length ? content.minX - FRAGMENT_MARGIN : content.minX;\n const maxX = fragments.length ? content.maxX + FRAGMENT_MARGIN : content.maxX;\n const dx = DIAGRAM_PADDING - minX;\n\n return {\n width: maxX - minX + DIAGRAM_PADDING * 2,\n height: rows.bottom + headerHeight + DIAGRAM_PADDING,\n fontSize,\n participants: participants.map((participant) => ({\n ...participant,\n x: participant.x + dx,\n centerX: participant.centerX + dx,\n })),\n messages: rows.messages.map((message) => ({\n ...message,\n points: message.points.map((point) => ({ x: point.x + dx, y: point.y })),\n label: { ...message.label, x: message.label.x + dx },\n })),\n notes: rows.notes.map((note) => ({ ...note, x: note.x + dx })),\n fragments: fragments.map((fragment) => ({\n ...fragment,\n x: fragment.x + dx,\n })),\n };\n};\n\ninterface Measured {\n width: number;\n height: number;\n lines: string[];\n}\n\n/**\n * The header box of one participant. An `actor` is a stick figure with its\n * name underneath rather than a box around it, so it is taller and needs no\n * horizontal padding.\n */\nconst measureHead = (\n lines: string[],\n actor: boolean,\n fontSize: number,\n): Measured => {\n const label = measureLabel(lines, fontSize);\n if (actor)\n return {\n width: Math.max(label.width, ACTOR_MIN_WIDTH),\n height: ACTOR_FIGURE_HEIGHT + ACTOR_LABEL_GAP + label.height,\n lines: label.lines,\n };\n return {\n width: Math.max(label.width + PARTICIPANT_PAD_X * 2, PARTICIPANT_MIN_WIDTH),\n height: label.height + PARTICIPANT_PAD_Y * 2,\n lines: label.lines,\n };\n};\n\n/**\n * Measure every row's label once, applying `autonumber` first.\n *\n * A note's measurement is its BOX (label plus padding); a message's is its\n * bare label, because a message label is drawn straight onto the diagram.\n */\nconst measureSteps = (model: SequenceModel, fontSize: number): Measured[] => {\n let counter = model.autonumber?.start ?? 0;\n return model.steps.map((step) => {\n if (step.kind === \"note\") {\n const label = measureLabel(step.lines, fontSize);\n return {\n width: label.width + NOTE_PAD_X * 2,\n height: label.height + NOTE_PAD_Y * 2,\n lines: label.lines,\n };\n }\n if (!model.autonumber) return measureLabel(step.lines, fontSize);\n\n const number = counter;\n counter += model.autonumber.step;\n const [first, ...rest] = step.lines;\n return measureLabel(\n [first ? `${number}. ${first}` : `${number}`, ...rest],\n fontSize,\n );\n });\n};\n\n/**\n * Where each lifeline sits on the x axis, in two passes.\n *\n * **Pass one** gives every adjacent pair the room its two boxes need side\n * by side.\n *\n * **Pass two** walks every message and note and widens the span it covers\n * until its label fits. A label is centred over its whole span, so a\n * message from participant 1 to participant 5 constrains the sum of four\n * gaps rather than any one of them, and the shortfall is spread evenly\n * across the gaps it crosses. Gaps only ever grow, so one pass over the\n * constraints is enough: widening for a later label can never break an\n * earlier one.\n *\n * The centres come back starting at 0. The caller translates once, at the\n * end, after the true bounding box is known.\n */\nconst columnCenters = (\n model: SequenceModel,\n index: Map<string, number>,\n heads: Measured[],\n labels: Measured[],\n): number[] => {\n const count = model.participants.length;\n const gaps: number[] = [];\n for (let i = 0; i < count - 1; i++)\n gaps.push(\n heads[i].width / 2 + heads[i + 1].width / 2 + PARTICIPANT_CLEARANCE,\n );\n\n const widen = (from: number, to: number, required: number): void => {\n // A constraint can legitimately point off the end of the row: a note to\n // the left of the FIRST lifeline has no gap to widen, and the space it\n // needs falls out of the final bounding box instead. Clamping here\n // rather than at each call site is what keeps those cases from reading\n // `gaps[-1]` and poisoning every later width with a NaN.\n if (to <= from || from < 0 || to > gaps.length) return;\n let current = 0;\n for (let i = from; i < to; i++) current += gaps[i];\n if (current >= required) return;\n const extra = (required - current) / (to - from);\n for (let i = from; i < to; i++) gaps[i] += extra;\n };\n\n for (const [at, step] of model.steps.entries()) {\n const label = labels[at];\n if (step.kind === \"message\") {\n const from = index.get(step.from);\n const to = index.get(step.to);\n if (from === undefined || to === undefined) continue;\n\n if (step.self) {\n // The loop hangs to the RIGHT of its lifeline with the label beyond\n // it, so it eats into one gap rather than spanning several. At the\n // last participant there is no gap to eat, and the clearance falls\n // out of the final bounding box instead.\n if (from >= count - 1) continue;\n widen(\n from,\n from + 1,\n SELF_LOOP_WIDTH +\n SELF_LOOP_LABEL_GAP +\n label.width * GAP_LABEL_MARGIN +\n MESSAGE_LABEL_GUTTER,\n );\n continue;\n }\n widen(\n Math.min(from, to),\n Math.max(from, to),\n label.width * GAP_LABEL_MARGIN + MESSAGE_LABEL_GUTTER * 2,\n );\n continue;\n }\n\n const anchors = step.participants\n .map((id) => index.get(id))\n .filter((at): at is number => at !== undefined);\n if (anchors.length === 0) continue;\n\n if (step.placement === \"over\" && anchors.length > 1) {\n const from = Math.min(...anchors);\n const to = Math.max(...anchors);\n // A note box carries its own padding, so no margin is applied to it -\n // it is not text sitting in a gap.\n widen(from, to, label.width - NOTE_SPAN_OVERHANG * 2);\n continue;\n }\n\n const anchor = anchors[0];\n if (step.placement === \"over\") {\n // Centred on one lifeline, so it eats half its width into each\n // neighbouring gap.\n widen(anchor - 1, anchor, label.width / 2 + NOTE_CLEARANCE);\n widen(anchor, anchor + 1, label.width / 2 + NOTE_CLEARANCE);\n continue;\n }\n if (step.placement === \"left\")\n widen(anchor - 1, anchor, label.width + NOTE_CLEARANCE * 2);\n else widen(anchor, anchor + 1, label.width + NOTE_CLEARANCE * 2);\n }\n\n const centers = [0];\n for (const gap of gaps) centers.push(centers[centers.length - 1] + gap);\n return centers;\n};\n\ninterface RowContext {\n fontSize: number;\n top: number;\n}\n\ninterface Rows {\n messages: PositionedMessage[];\n notes: PositionedNoteBox[];\n /**\n * y where every lifeline stops, and the footer boxes start.\n */\n bottom: number;\n /**\n * Per fragment, the box top and bottom and each divider's y, keyed by the\n * fragment's position in `model.fragments`.\n */\n spans: Map<number, { top: number; bottom: number; dividers: number[] }>;\n}\n\n/**\n * One sequential pass down the rows, assigning y.\n *\n * This is the whole reason the model is flat: a nested tree would force\n * this to recurse while threading the cursor through it, and a fragment box\n * would still have to be min/max over the rows it turned out to contain.\n */\nconst layoutRows = (\n model: SequenceModel,\n index: Map<string, number>,\n centers: number[],\n labels: Measured[],\n context: RowContext,\n): Rows => {\n const messages: PositionedMessage[] = [];\n const notes: PositionedNoteBox[] = [];\n const spans = new Map<\n number,\n { top: number; bottom: number; dividers: number[] }\n >();\n const tabHeight =\n context.fontSize * DIAGRAM_LINE_HEIGHT + FRAGMENT_TAB_PAD_Y * 2;\n\n // Outermost first on the way in, innermost first on the way out, so a\n // nested box always sits strictly inside the one that contains it.\n const opening = byStep(model, (fragment) => fragment.from, 1);\n const closing = byStep(model, (fragment) => fragment.to, -1);\n const dividing = dividersByStep(model);\n\n let y = context.top;\n\n for (const [at, step] of model.steps.entries()) {\n for (const owner of opening.get(at) ?? []) {\n spans.set(owner, { top: y, bottom: y, dividers: [] });\n y += tabHeight + FRAGMENT_TOP_PAD;\n }\n for (const owner of dividing.get(at) ?? []) {\n const span = spans.get(owner);\n if (!span) continue;\n y += DIVIDER_GAP;\n span.dividers.push(y);\n // The `else` condition is drawn BELOW its divider, because that is\n // the branch it names, so the room for it goes below too.\n y += context.fontSize * DIAGRAM_LINE_HEIGHT + DIVIDER_GAP;\n }\n\n const label = labels[at];\n y =\n step.kind === \"note\"\n ? placeNote(step, label, index, centers, y, notes)\n : placeMessage(step, label, index, centers, y, messages);\n\n for (const owner of closing.get(at) ?? []) {\n const span = spans.get(owner);\n if (!span) continue;\n y += FRAGMENT_BOTTOM_PAD;\n span.bottom = y;\n y += FRAGMENT_AFTER_GAP;\n }\n }\n\n return { messages, notes, bottom: y + LIFELINE_BOTTOM_GAP, spans };\n};\n\n/**\n * Fragment indices grouped by the step they open or close at, sorted so\n * outer fragments come first on the way in and last on the way out.\n */\nconst byStep = (\n model: SequenceModel,\n pick: (fragment: SequenceFragment) => number,\n order: 1 | -1,\n): Map<number, number[]> => {\n const out = new Map<number, number[]>();\n for (const [at, fragment] of model.fragments.entries())\n push(out, pick(fragment), at);\n for (const list of out.values())\n list.sort(\n (a, b) => (model.fragments[a].depth - model.fragments[b].depth) * order,\n );\n return out;\n};\n\n/**\n * Which fragments have an `else` at each step, outermost first: a divider\n * belonging to an outer box has to be drawn above one belonging to a box\n * nested inside it, or the two branches read as swapped.\n */\nconst dividersByStep = (model: SequenceModel): Map<number, number[]> => {\n const out = new Map<number, number[]>();\n for (const [at, fragment] of model.fragments.entries())\n for (const divider of fragment.dividers) push(out, divider.at, at);\n for (const list of out.values())\n list.sort((a, b) => model.fragments[a].depth - model.fragments[b].depth);\n return out;\n};\n\nconst push = (map: Map<number, number[]>, key: number, value: number): void => {\n const list = map.get(key);\n if (list) list.push(value);\n else map.set(key, [value]);\n};\n\nconst placeMessage = (\n step: Extract<SequenceStep, { kind: \"message\" }>,\n label: Measured,\n index: Map<string, number>,\n centers: number[],\n y: number,\n out: PositionedMessage[],\n): number => {\n const from = index.get(step.from);\n const to = index.get(step.to);\n if (from === undefined || to === undefined) return y;\n\n if (step.self) {\n const height = Math.max(SELF_LOOP_MIN_HEIGHT, label.height + 6);\n const top = y + SELF_LOOP_TOP_PAD;\n const bottom = top + height;\n const x = centers[from];\n out.push({\n from: step.from,\n to: step.to,\n line: step.line,\n head: step.head,\n self: true,\n points: [\n { x, y: top },\n { x: x + SELF_LOOP_WIDTH, y: top },\n { x: x + SELF_LOOP_WIDTH, y: bottom },\n { x, y: bottom },\n ],\n label: {\n lines: label.lines,\n x: x + SELF_LOOP_WIDTH + SELF_LOOP_LABEL_GAP,\n y: (top + bottom) / 2 - label.height / 2,\n width: label.width,\n height: label.height,\n },\n });\n return bottom + MESSAGE_ROW_GAP;\n }\n\n const lineY = y + label.height + MESSAGE_LABEL_GAP;\n out.push({\n from: step.from,\n to: step.to,\n line: step.line,\n head: step.head,\n self: false,\n points: [\n { x: centers[from], y: lineY },\n { x: centers[to], y: lineY },\n ],\n label: {\n lines: label.lines,\n x: (centers[from] + centers[to]) / 2 - label.width / 2,\n y,\n width: label.width,\n height: label.height,\n },\n });\n return lineY + MESSAGE_ROW_GAP;\n};\n\nconst placeNote = (\n step: SequenceNote,\n label: Measured,\n index: Map<string, number>,\n centers: number[],\n y: number,\n out: PositionedNoteBox[],\n): number => {\n const anchors = step.participants\n .map((id) => index.get(id))\n .filter((at): at is number => at !== undefined);\n if (anchors.length === 0) return y;\n\n const from = Math.min(...anchors);\n const to = Math.max(...anchors);\n const width =\n step.placement === \"over\" && to > from\n ? Math.max(\n label.width,\n centers[to] - centers[from] + NOTE_SPAN_OVERHANG * 2,\n )\n : label.width;\n\n const x =\n step.placement === \"left\"\n ? centers[from] - NOTE_CLEARANCE - width\n : step.placement === \"right\"\n ? centers[from] + NOTE_CLEARANCE\n : (centers[from] + centers[to]) / 2 - width / 2;\n\n out.push({\n placement: step.placement,\n lines: label.lines,\n x,\n y,\n width,\n height: label.height,\n });\n return y + label.height + NOTE_ROW_GAP;\n};\n\ninterface Bounds {\n minX: number;\n maxX: number;\n}\n\n/**\n * The x extent of everything except the fragment boxes, which are sized\n * FROM it. A note hanging off the first lifeline and a self-message looping\n * off the last one are the two things that reach past the participants.\n */\nconst contentBounds = (\n participants: PositionedParticipant[],\n rows: Rows,\n): Bounds => {\n let minX = Number.POSITIVE_INFINITY;\n let maxX = Number.NEGATIVE_INFINITY;\n const cover = (from: number, to: number) => {\n minX = Math.min(minX, from);\n maxX = Math.max(maxX, to);\n };\n\n for (const participant of participants)\n cover(participant.x, participant.x + participant.width);\n for (const note of rows.notes) cover(note.x, note.x + note.width);\n for (const message of rows.messages) {\n for (const point of message.points) cover(point.x, point.x);\n cover(message.label.x, message.label.x + message.label.width);\n }\n return { minX, maxX };\n};\n\n/**\n * Fragment boxes span the whole diagram, inset by depth, exactly as mermaid\n * draws them. Fitting a box to only the participants it happens to mention\n * was considered and dropped: a box that changes width with its contents\n * reads as a shape rather than as a scope.\n */\nconst layoutFragments = (\n model: SequenceModel,\n rows: Rows,\n content: Bounds,\n fontSize: number,\n): PositionedFragment[] =>\n model.fragments\n .map((fragment, at) => {\n const span = rows.spans.get(at);\n if (!span) return undefined;\n const x =\n content.minX - FRAGMENT_MARGIN + fragment.depth * FRAGMENT_INSET;\n const right =\n content.maxX + FRAGMENT_MARGIN - fragment.depth * FRAGMENT_INSET;\n const label = measureLabel([fragment.kind], fontSize);\n return {\n kind: fragment.kind,\n label: fragment.label,\n depth: fragment.depth,\n x,\n y: span.top,\n width: Math.max(right - x, FRAGMENT_MIN_WIDTH),\n height: span.bottom - span.top,\n tabWidth: label.width + FRAGMENT_TAB_PAD_X * 2,\n tabHeight: label.height + FRAGMENT_TAB_PAD_Y * 2,\n dividers: fragment.dividers.map((divider, i) => ({\n y: span.dividers[i] ?? span.top,\n label: divider.label,\n })),\n };\n })\n .filter(\n (fragment): fragment is PositionedFragment => fragment !== undefined,\n )\n // Order IS z-order in SVG, so the outermost box goes down first and a\n // nested one draws on top of it, with no z-index anywhere.\n .sort((a, b) => a.depth - b.depth);\n"],"mappings":";;;;;;;;;;;;;;;;AA6BA,MAAa,4BAA4B;AACzC,MAAa,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;AAwBrC,MAAa,mBAAmB;AAEhC,MAAM,kBAAkB;AACxB,MAAM,oBAAoB;AAC1B,MAAM,oBAAoB;AAC1B,MAAM,wBAAwB;;;;;AAK9B,MAAM,wBAAwB;AAM9B,MAAM,kBAAkB;AAExB,MAAM,mBAAmB;AACzB,MAAM,sBAAsB;AAE5B,MAAM,oBAAoB;AAC1B,MAAM,kBAAkB;;;;;AAKxB,MAAM,uBAAuB;AAE7B,MAAM,kBAAkB;AACxB,MAAM,sBAAsB;AAC5B,MAAM,uBAAuB;AAC7B,MAAM,oBAAoB;AAE1B,MAAM,aAAa;AACnB,MAAM,aAAa;AACnB,MAAM,eAAe;;;;AAIrB,MAAM,qBAAqB;;;;AAI3B,MAAM,iBAAiB;AAEvB,MAAM,iBAAiB;;;;AAIvB,MAAM,kBAAkB;AACxB,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAC3B,MAAM,mBAAmB;AACzB,MAAM,sBAAsB;AAC5B,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAC3B,MAAM,cAAc;;;;;;;;;;;;;AAmHpB,MAAa,kBACX,OACA,WAAA,OACmC;CACnC,IAAI,MAAM,aAAa,WAAW,KAAK,MAAM,MAAM,WAAW,GAC5D,OAAO,KAAA;CACT,IAAI,MAAM,aAAa,SAAA,IAAoC,OAAO,KAAA;CAClE,IAAI,MAAM,MAAM,SAAA,KAAgC,O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AAQ,MAAM,GAAG,QAAQ,MAAM,IAAI,QAAQ,MAAM,KAAK;CAC9D;CACA,OAAO;EAAE;EAAM;CAAK;AACtB;;;;;;;AAQA,MAAM,mBACJ,OACA,MACA,SACA,aAEA,MAAM,UACH,KAAK,UAAU,OAAO;CACrB,MAAM,OAAO,KAAK,MAAM,IAAI,EAAE;CAC9B,IAAI,CAAC,MAAM,OAAO,KAAA;CAClB,MAAM,IACJ,QAAQ,OAAO,kBAAkB,SAAS,QAAQ;CACpD,MAAM,QACJ,QAAQ,OAAO,kBAAkB,SAAS,QAAQ;CACpD,MAAM,QAAQ,aAAa,CAAC,SAAS,IAAI,GAAG,QAAQ;CACpD,OAAO;EACL,MAAM,SAAS;EACf,OAAO,SAAS;EAChB,OAAO,SAAS;EAChB;EACA,GAAG,KAAK;EACR,OAAO,KAAK,IAAI,QAAQ,GAAG,kBAAkB;EAC7C,QAAQ,KAAK,SAAS,KAAK;EAC3B,UAAU,MAAM,QAAQ,qBAAqB;EAC7C,WAAW,MAAM,SAAS,qBAAqB;EAC/C,UAAU,SAAS,SAAS,KAAK,SAAS,OAAO;GAC/C,GAAG,KAAK,SAAS,MAAM,KAAK;GAC5B,OAAO,QAAQ;EACjB,EAAE;CACJ;AACF,CAAC,CAAC,CACD,QACE,aAA6C,aAAa,KAAA,CAC7D,CAAC,CAGA,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK"}
|
|
1
|
+
{"version":3,"file":"layoutSequence.js","names":[],"sources":["../../../../src/components/markdown-view/diagram/layoutSequence.ts"],"sourcesContent":["import type {\n SequenceArrowHead,\n SequenceFragment,\n SequenceFragmentKind,\n SequenceLineStyle,\n SequenceModel,\n SequenceNote,\n SequenceStep,\n} from \"./sequenceModel.ts\";\nimport {\n DIAGRAM_FONT_SIZE,\n DIAGRAM_LINE_HEIGHT,\n measureLabel,\n} from \"./textMetrics.ts\";\n\n/**\n * The largest diagram that gets laid out. Above either cap the caller falls\n * back to the code block.\n *\n * Unlike the flowchart caps these are NOT about time: layout here is O(n)\n * arithmetic with no ranking to compute, and 300 rows lay out in under a\n * millisecond. They are about legibility and DOM size - 30 lifelines is\n * already far past what anyone can read, and every row is a handful of SVG\n * elements on a page that may carry several diagrams.\n *\n * `MAX_SEQUENCE_MESSAGES` counts ROWS, notes included: a note occupies a\n * row and costs a box, so counting only messages would let a note-heavy\n * diagram past the cap it exists to enforce.\n */\nexport const MAX_SEQUENCE_PARTICIPANTS = 30;\nexport const MAX_SEQUENCE_MESSAGES = 300;\n\n/**\n * The safety margin applied to the width a label needs in the gap between\n * two lifelines. **Gap constraints only** - not participant boxes, which\n * stay tight, and not note boxes, which carry their own padding.\n *\n * ## Why a margin exists here and nowhere else\n *\n * `textMetrics.ts` measures text from a generated per-character width table\n * rather than from the DOM, which is what keeps this a pure function. The\n * table was measured against `canvas.measureText` on the real Inter woff2\n * and agrees **within ~1.3%**, all of it from rounding the ratios to three\n * decimals.\n *\n * The asymmetry is what makes the margin necessary at all. A flowchart\n * label sits INSIDE its box, so a 1.3% underestimate only eats padding. A\n * sequence label sits IN THE GAP between two lifelines, so the same\n * underestimate puts text on top of the neighbouring lifeline. 4% is three\n * times the measured error.\n *\n * Do not \"optimise\" this away as a magic number: it is a measured 1.3% with\n * headroom, and removing it makes long labels collide.\n */\nexport const GAP_LABEL_MARGIN = 1.04;\n\nconst DIAGRAM_PADDING = 12;\nconst PARTICIPANT_PAD_X = 14;\nconst PARTICIPANT_PAD_Y = 8;\nconst PARTICIPANT_MIN_WIDTH = 64;\n/**\n * Clear space between two adjacent participant boxes, before any label\n * widens the gap.\n */\nconst PARTICIPANT_CLEARANCE = 26;\n/**\n * The stick figure an `actor` draws above its name.\n */\nconst ACTOR_FIGURE_HEIGHT = 32;\nconst ACTOR_LABEL_GAP = 4;\nconst ACTOR_MIN_WIDTH = 40;\n\nconst LIFELINE_TOP_GAP = 14;\nconst LIFELINE_BOTTOM_GAP = 14;\n\nconst MESSAGE_LABEL_GAP = 4;\nconst MESSAGE_ROW_GAP = 16;\n/**\n * Clearance between a message label and each lifeline it is centred\n * between.\n */\nconst MESSAGE_LABEL_GUTTER = 10;\n\nconst SELF_LOOP_WIDTH = 32;\nconst SELF_LOOP_LABEL_GAP = 8;\nconst SELF_LOOP_MIN_HEIGHT = 26;\nconst SELF_LOOP_TOP_PAD = 4;\n\nconst NOTE_PAD_X = 10;\nconst NOTE_PAD_Y = 7;\nconst NOTE_ROW_GAP = 14;\n/**\n * How far a `Note over A,B` reaches past the two lifelines it spans.\n */\nconst NOTE_SPAN_OVERHANG = 10;\n/**\n * Clearance between a note box and any lifeline it is not attached to.\n */\nconst NOTE_CLEARANCE = 10;\n\nconst FRAGMENT_INSET = 9;\n/**\n * How far a depth-0 fragment box reaches past the widest content.\n */\nconst FRAGMENT_MARGIN = 14;\nconst FRAGMENT_TAB_PAD_X = 8;\nconst FRAGMENT_TAB_PAD_Y = 3;\nconst FRAGMENT_TOP_PAD = 8;\nconst FRAGMENT_BOTTOM_PAD = 10;\nconst FRAGMENT_AFTER_GAP = 6;\nconst FRAGMENT_MIN_WIDTH = 60;\nconst DIVIDER_GAP = 8;\n\nexport interface PositionedParticipant {\n id: string;\n /**\n * The lines as MEASURED - wrapped and capped. Draw exactly these.\n */\n lines: string[];\n actor: boolean;\n /**\n * TOP-LEFT corner of the header box, the same convention the flowchart\n * layout settled on. An emitter half a box off looks almost right, which\n * is the worst way for this to be wrong.\n */\n x: number;\n y: number;\n width: number;\n height: number;\n /**\n * Where the lifeline runs. `centerX` is the lifeline's x, and the box is\n * centred on it.\n */\n centerX: number;\n lifelineTop: number;\n lifelineBottom: number;\n /**\n * TOP-LEFT y of the repeated footer box. Its `x`, `width` and `height`\n * are the header's.\n */\n bottomY: number;\n}\n\nexport interface PositionedLabel {\n lines: string[];\n /**\n * TOP-LEFT corner.\n */\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface PositionedMessage {\n from: string;\n to: string;\n line: SequenceLineStyle;\n head: SequenceArrowHead;\n self: boolean;\n /**\n * Two points for a normal message, four for the loop of a self-message.\n * In from-to order, so the head marker lands on the receiver.\n */\n points: Array<{ x: number; y: number }>;\n /**\n * Already carries the `autonumber` counter when the diagram declared one.\n */\n label: PositionedLabel;\n}\n\nexport interface PositionedNoteBox extends PositionedLabel {\n placement: SequenceNote[\"placement\"];\n}\n\nexport interface PositionedFragment {\n kind: SequenceFragmentKind;\n /**\n * The condition, drawn next to the tab. May be empty.\n */\n label: string;\n depth: number;\n /**\n * TOP-LEFT corner of the box.\n */\n x: number;\n y: number;\n width: number;\n height: number;\n /**\n * The corner tab carrying the kind (`alt`, `opt`, `loop`).\n */\n tabWidth: number;\n tabHeight: number;\n dividers: Array<{ y: number; label: string }>;\n}\n\n/**\n * A laid-out sequence diagram: data, not markup. No SVG, no React, no DOM.\n */\nexport interface PositionedSequence {\n width: number;\n height: number;\n fontSize: number;\n participants: PositionedParticipant[];\n messages: PositionedMessage[];\n notes: PositionedNoteBox[];\n /**\n * Outermost first, so the emitter draws them in order and gets z-order\n * free, the way the flowchart clusters do.\n */\n fragments: PositionedFragment[];\n}\n\n/**\n * Place a `SequenceModel` on a plane.\n *\n * **No layout library is involved, and none is coming back.** `graphre`\n * ranks a node graph; here both axes are already decided by the source -\n * participants left to right in declaration order, rows top to bottom in\n * statement order - so layout is arithmetic. The only genuinely hard part\n * is the column widths, which take two passes (see `columnCenters`).\n *\n * Returns `undefined` (never throws, never a partial diagram) for an empty\n * model or one past the caps. The caller's fallback is the code block.\n */\nexport const layoutSequence = (\n model: SequenceModel,\n fontSize: number = DIAGRAM_FONT_SIZE,\n): PositionedSequence | undefined => {\n if (model.participants.length === 0 || model.steps.length === 0)\n return undefined;\n if (model.participants.length > MAX_SEQUENCE_PARTICIPANTS) return undefined;\n if (model.steps.length > MAX_SEQUENCE_MESSAGES) return undefined;\n\n const index = new Map(model.participants.map((p, i) => [p.id, i]));\n const heads = model.participants.map((participant) =>\n measureHead(participant.lines, participant.actor, fontSize),\n );\n // ⚠️ Numbering happens BEFORE anything is measured. The counter is part of\n // the label, so measuring first and numbering after makes every column\n // too narrow - and it stays invisible until a diagram reaches ten\n // messages and the labels go double-digit.\n const labels = measureSteps(model, fontSize);\n\n const centers = columnCenters(model, index, heads, labels);\n const headerHeight = Math.max(...heads.map((head) => head.height));\n\n const rows = layoutRows(model, index, centers, labels, {\n fontSize,\n top: DIAGRAM_PADDING + headerHeight + LIFELINE_TOP_GAP,\n });\n\n const participants = model.participants.map((participant, i) => ({\n id: participant.id,\n lines: heads[i].lines,\n actor: participant.actor,\n // Header boxes are bottom-aligned so every lifeline starts on the same\n // y, whatever mix of one-line names, wrapped names and actors is on the\n // row.\n x: centers[i] - heads[i].width / 2,\n y: DIAGRAM_PADDING + headerHeight - heads[i].height,\n width: heads[i].width,\n height: heads[i].height,\n centerX: centers[i],\n lifelineTop: DIAGRAM_PADDING + headerHeight,\n lifelineBottom: rows.bottom,\n bottomY: rows.bottom,\n }));\n\n const content = contentBounds(participants, rows);\n const fragments = layoutFragments(model, rows, content, fontSize);\n\n const minX = fragments.length ? content.minX - FRAGMENT_MARGIN : content.minX;\n const maxX = fragments.length ? content.maxX + FRAGMENT_MARGIN : content.maxX;\n const dx = DIAGRAM_PADDING - minX;\n\n return {\n width: maxX - minX + DIAGRAM_PADDING * 2,\n height: rows.bottom + headerHeight + DIAGRAM_PADDING,\n fontSize,\n participants: participants.map((participant) => ({\n ...participant,\n x: participant.x + dx,\n centerX: participant.centerX + dx,\n })),\n messages: rows.messages.map((message) => ({\n ...message,\n points: message.points.map((point) => ({ x: point.x + dx, y: point.y })),\n label: { ...message.label, x: message.label.x + dx },\n })),\n notes: rows.notes.map((note) => ({ ...note, x: note.x + dx })),\n fragments: fragments.map((fragment) => ({\n ...fragment,\n x: fragment.x + dx,\n })),\n };\n};\n\ninterface Measured {\n width: number;\n height: number;\n lines: string[];\n}\n\n/**\n * The header box of one participant. An `actor` is a stick figure with its\n * name underneath rather than a box around it, so it is taller and needs no\n * horizontal padding.\n */\nconst measureHead = (\n lines: string[],\n actor: boolean,\n fontSize: number,\n): Measured => {\n const label = measureLabel(lines, fontSize);\n if (actor)\n return {\n width: Math.max(label.width, ACTOR_MIN_WIDTH),\n height: ACTOR_FIGURE_HEIGHT + ACTOR_LABEL_GAP + label.height,\n lines: label.lines,\n };\n return {\n width: Math.max(label.width + PARTICIPANT_PAD_X * 2, PARTICIPANT_MIN_WIDTH),\n height: label.height + PARTICIPANT_PAD_Y * 2,\n lines: label.lines,\n };\n};\n\n/**\n * Measure every row's label once, applying `autonumber` first.\n *\n * A note's measurement is its BOX (label plus padding); a message's is its\n * bare label, because a message label is drawn straight onto the diagram.\n */\nconst measureSteps = (model: SequenceModel, fontSize: number): Measured[] => {\n let counter = model.autonumber?.start ?? 0;\n return model.steps.map((step) => {\n if (step.kind === \"note\") {\n const label = measureLabel(step.lines, fontSize);\n return {\n width: label.width + NOTE_PAD_X * 2,\n height: label.height + NOTE_PAD_Y * 2,\n lines: label.lines,\n };\n }\n if (!model.autonumber) return measureLabel(step.lines, fontSize);\n\n const number = counter;\n counter += model.autonumber.step;\n const [first, ...rest] = step.lines;\n return measureLabel(\n [first ? `${number}. ${first}` : `${number}`, ...rest],\n fontSize,\n );\n });\n};\n\n/**\n * Where each lifeline sits on the x axis, in two passes.\n *\n * **Pass one** gives every adjacent pair the room its two boxes need side\n * by side.\n *\n * **Pass two** walks every message and note and widens the span it covers\n * until its label fits. A label is centred over its whole span, so a\n * message from participant 1 to participant 5 constrains the sum of four\n * gaps rather than any one of them, and the shortfall is spread evenly\n * across the gaps it crosses. Gaps only ever grow, so one pass over the\n * constraints is enough: widening for a later label can never break an\n * earlier one.\n *\n * The centres come back starting at 0. The caller translates once, at the\n * end, after the true bounding box is known.\n */\nconst columnCenters = (\n model: SequenceModel,\n index: Map<string, number>,\n heads: Measured[],\n labels: Measured[],\n): number[] => {\n const count = model.participants.length;\n const gaps: number[] = [];\n for (let i = 0; i < count - 1; i++)\n gaps.push(\n heads[i].width / 2 + heads[i + 1].width / 2 + PARTICIPANT_CLEARANCE,\n );\n\n const widen = (from: number, to: number, required: number): void => {\n // A constraint can legitimately point off the end of the row: a note to\n // the left of the FIRST lifeline has no gap to widen, and the space it\n // needs falls out of the final bounding box instead. Clamping here\n // rather than at each call site is what keeps those cases from reading\n // `gaps[-1]` and poisoning every later width with a NaN.\n if (to <= from || from < 0 || to > gaps.length) return;\n let current = 0;\n for (let i = from; i < to; i++) current += gaps[i];\n if (current >= required) return;\n const extra = (required - current) / (to - from);\n for (let i = from; i < to; i++) gaps[i] += extra;\n };\n\n for (const [at, step] of model.steps.entries()) {\n const label = labels[at];\n if (step.kind === \"message\") {\n const from = index.get(step.from);\n const to = index.get(step.to);\n if (from === undefined || to === undefined) continue;\n\n if (step.self) {\n // The loop hangs to the RIGHT of its lifeline with the label beyond\n // it, so it eats into one gap rather than spanning several. At the\n // last participant there is no gap to eat, and the clearance falls\n // out of the final bounding box instead.\n if (from >= count - 1) continue;\n widen(\n from,\n from + 1,\n SELF_LOOP_WIDTH +\n SELF_LOOP_LABEL_GAP +\n label.width * GAP_LABEL_MARGIN +\n MESSAGE_LABEL_GUTTER,\n );\n continue;\n }\n widen(\n Math.min(from, to),\n Math.max(from, to),\n label.width * GAP_LABEL_MARGIN + MESSAGE_LABEL_GUTTER * 2,\n );\n continue;\n }\n\n const anchors = step.participants\n .map((id) => index.get(id))\n .filter((at): at is number => at !== undefined);\n if (anchors.length === 0) continue;\n\n if (step.placement === \"over\" && anchors.length > 1) {\n const from = Math.min(...anchors);\n const to = Math.max(...anchors);\n // A note box carries its own padding, so no margin is applied to it -\n // it is not text sitting in a gap.\n widen(from, to, label.width - NOTE_SPAN_OVERHANG * 2);\n continue;\n }\n\n const anchor = anchors[0];\n if (step.placement === \"over\") {\n // Centred on one lifeline, so it eats half its width into each\n // neighbouring gap.\n widen(anchor - 1, anchor, label.width / 2 + NOTE_CLEARANCE);\n widen(anchor, anchor + 1, label.width / 2 + NOTE_CLEARANCE);\n continue;\n }\n if (step.placement === \"left\")\n widen(anchor - 1, anchor, label.width + NOTE_CLEARANCE * 2);\n else widen(anchor, anchor + 1, label.width + NOTE_CLEARANCE * 2);\n }\n\n const centers = [0];\n for (const gap of gaps) centers.push(centers[centers.length - 1] + gap);\n return centers;\n};\n\ninterface RowContext {\n fontSize: number;\n top: number;\n}\n\ninterface Rows {\n messages: PositionedMessage[];\n notes: PositionedNoteBox[];\n /**\n * y where every lifeline stops, and the footer boxes start.\n */\n bottom: number;\n /**\n * Per fragment, the box top and bottom and each divider's y, keyed by the\n * fragment's position in `model.fragments`.\n */\n spans: Map<number, { top: number; bottom: number; dividers: number[] }>;\n}\n\n/**\n * One sequential pass down the rows, assigning y.\n *\n * This is the whole reason the model is flat: a nested tree would force\n * this to recurse while threading the cursor through it, and a fragment box\n * would still have to be min/max over the rows it turned out to contain.\n */\nconst layoutRows = (\n model: SequenceModel,\n index: Map<string, number>,\n centers: number[],\n labels: Measured[],\n context: RowContext,\n): Rows => {\n const messages: PositionedMessage[] = [];\n const notes: PositionedNoteBox[] = [];\n const spans = new Map<\n number,\n { top: number; bottom: number; dividers: number[] }\n >();\n const tabHeight =\n context.fontSize * DIAGRAM_LINE_HEIGHT + FRAGMENT_TAB_PAD_Y * 2;\n\n // Outermost first on the way in, innermost first on the way out, so a\n // nested box always sits strictly inside the one that contains it.\n const opening = byStep(model, (fragment) => fragment.from, 1);\n const closing = byStep(model, (fragment) => fragment.to, -1);\n const dividing = dividersByStep(model);\n\n let y = context.top;\n\n for (const [at, step] of model.steps.entries()) {\n for (const owner of opening.get(at) ?? []) {\n spans.set(owner, { top: y, bottom: y, dividers: [] });\n y += tabHeight + FRAGMENT_TOP_PAD;\n }\n for (const owner of dividing.get(at) ?? []) {\n const span = spans.get(owner);\n if (!span) continue;\n y += DIVIDER_GAP;\n span.dividers.push(y);\n // The `else` condition is drawn BELOW its divider, because that is\n // the branch it names, so the room for it goes below too.\n y += context.fontSize * DIAGRAM_LINE_HEIGHT + DIVIDER_GAP;\n }\n\n const label = labels[at];\n y =\n step.kind === \"note\"\n ? placeNote(step, label, index, centers, y, notes)\n : placeMessage(step, label, index, centers, y, messages);\n\n for (const owner of closing.get(at) ?? []) {\n const span = spans.get(owner);\n if (!span) continue;\n y += FRAGMENT_BOTTOM_PAD;\n span.bottom = y;\n y += FRAGMENT_AFTER_GAP;\n }\n }\n\n return { messages, notes, bottom: y + LIFELINE_BOTTOM_GAP, spans };\n};\n\n/**\n * Fragment indices grouped by the step they open or close at, sorted so\n * outer fragments come first on the way in and last on the way out.\n */\nconst byStep = (\n model: SequenceModel,\n pick: (fragment: SequenceFragment) => number,\n order: 1 | -1,\n): Map<number, number[]> => {\n const out = new Map<number, number[]>();\n for (const [at, fragment] of model.fragments.entries())\n push(out, pick(fragment), at);\n for (const list of out.values())\n list.sort(\n (a, b) => (model.fragments[a].depth - model.fragments[b].depth) * order,\n );\n return out;\n};\n\n/**\n * Which fragments have an `else` at each step, outermost first: a divider\n * belonging to an outer box has to be drawn above one belonging to a box\n * nested inside it, or the two branches read as swapped.\n */\nconst dividersByStep = (model: SequenceModel): Map<number, number[]> => {\n const out = new Map<number, number[]>();\n for (const [at, fragment] of model.fragments.entries())\n for (const divider of fragment.dividers) push(out, divider.at, at);\n for (const list of out.values())\n list.sort((a, b) => model.fragments[a].depth - model.fragments[b].depth);\n return out;\n};\n\nconst push = (map: Map<number, number[]>, key: number, value: number): void => {\n const list = map.get(key);\n if (list) list.push(value);\n else map.set(key, [value]);\n};\n\nconst placeMessage = (\n step: Extract<SequenceStep, { kind: \"message\" }>,\n label: Measured,\n index: Map<string, number>,\n centers: number[],\n y: number,\n out: PositionedMessage[],\n): number => {\n const from = index.get(step.from);\n const to = index.get(step.to);\n if (from === undefined || to === undefined) return y;\n\n if (step.self) {\n const height = Math.max(SELF_LOOP_MIN_HEIGHT, label.height + 6);\n const top = y + SELF_LOOP_TOP_PAD;\n const bottom = top + height;\n const x = centers[from];\n out.push({\n from: step.from,\n to: step.to,\n line: step.line,\n head: step.head,\n self: true,\n points: [\n { x, y: top },\n { x: x + SELF_LOOP_WIDTH, y: top },\n { x: x + SELF_LOOP_WIDTH, y: bottom },\n { x, y: bottom },\n ],\n label: {\n lines: label.lines,\n x: x + SELF_LOOP_WIDTH + SELF_LOOP_LABEL_GAP,\n y: (top + bottom) / 2 - label.height / 2,\n width: label.width,\n height: label.height,\n },\n });\n return bottom + MESSAGE_ROW_GAP;\n }\n\n const lineY = y + label.height + MESSAGE_LABEL_GAP;\n out.push({\n from: step.from,\n to: step.to,\n line: step.line,\n head: step.head,\n self: false,\n points: [\n { x: centers[from], y: lineY },\n { x: centers[to], y: lineY },\n ],\n label: {\n lines: label.lines,\n x: (centers[from] + centers[to]) / 2 - label.width / 2,\n y,\n width: label.width,\n height: label.height,\n },\n });\n return lineY + MESSAGE_ROW_GAP;\n};\n\nconst placeNote = (\n step: SequenceNote,\n label: Measured,\n index: Map<string, number>,\n centers: number[],\n y: number,\n out: PositionedNoteBox[],\n): number => {\n const anchors = step.participants\n .map((id) => index.get(id))\n .filter((at): at is number => at !== undefined);\n if (anchors.length === 0) return y;\n\n const from = Math.min(...anchors);\n const to = Math.max(...anchors);\n const width =\n step.placement === \"over\" && to > from\n ? Math.max(\n label.width,\n centers[to] - centers[from] + NOTE_SPAN_OVERHANG * 2,\n )\n : label.width;\n\n const x =\n step.placement === \"left\"\n ? centers[from] - NOTE_CLEARANCE - width\n : step.placement === \"right\"\n ? centers[from] + NOTE_CLEARANCE\n : (centers[from] + centers[to]) / 2 - width / 2;\n\n out.push({\n placement: step.placement,\n lines: label.lines,\n x,\n y,\n width,\n height: label.height,\n });\n return y + label.height + NOTE_ROW_GAP;\n};\n\ninterface Bounds {\n minX: number;\n maxX: number;\n}\n\n/**\n * The x extent of everything except the fragment boxes, which are sized\n * FROM it. A note hanging off the first lifeline and a self-message looping\n * off the last one are the two things that reach past the participants.\n */\nconst contentBounds = (\n participants: PositionedParticipant[],\n rows: Rows,\n): Bounds => {\n let minX = Number.POSITIVE_INFINITY;\n let maxX = Number.NEGATIVE_INFINITY;\n const cover = (from: number, to: number) => {\n minX = Math.min(minX, from);\n maxX = Math.max(maxX, to);\n };\n\n for (const participant of participants)\n cover(participant.x, participant.x + participant.width);\n for (const note of rows.notes) cover(note.x, note.x + note.width);\n for (const message of rows.messages) {\n for (const point of message.points) cover(point.x, point.x);\n cover(message.label.x, message.label.x + message.label.width);\n }\n return { minX, maxX };\n};\n\n/**\n * Fragment boxes span the whole diagram, inset by depth, exactly as mermaid\n * draws them. Fitting a box to only the participants it happens to mention\n * was considered and dropped: a box that changes width with its contents\n * reads as a shape rather than as a scope.\n */\nconst layoutFragments = (\n model: SequenceModel,\n rows: Rows,\n content: Bounds,\n fontSize: number,\n): PositionedFragment[] =>\n model.fragments\n .map((fragment, at) => {\n const span = rows.spans.get(at);\n if (!span) return undefined;\n const x =\n content.minX - FRAGMENT_MARGIN + fragment.depth * FRAGMENT_INSET;\n const right =\n content.maxX + FRAGMENT_MARGIN - fragment.depth * FRAGMENT_INSET;\n const label = measureLabel([fragment.kind], fontSize);\n return {\n kind: fragment.kind,\n label: fragment.label,\n depth: fragment.depth,\n x,\n y: span.top,\n width: Math.max(right - x, FRAGMENT_MIN_WIDTH),\n height: span.bottom - span.top,\n tabWidth: label.width + FRAGMENT_TAB_PAD_X * 2,\n tabHeight: label.height + FRAGMENT_TAB_PAD_Y * 2,\n dividers: fragment.dividers.map((divider, i) => ({\n y: span.dividers[i] ?? span.top,\n label: divider.label,\n })),\n };\n })\n .filter(\n (fragment): fragment is PositionedFragment => fragment !== undefined,\n )\n // Order IS z-order in SVG, so the outermost box goes down first and a\n // nested one draws on top of it, with no z-index anywhere.\n .sort((a, b) => a.depth - b.depth);\n"],"mappings":";;;;;;;;;;;;;;;;AA6BA,MAAa,4BAA4B;AACzC,MAAa,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;AAwBrC,MAAa,mBAAmB;AAEhC,MAAM,kBAAkB;AAGxB,MAAM,wBAAw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