@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
|
@@ -37,12 +37,12 @@ const MAX_LABEL_LINES = 8;
|
|
|
37
37
|
*
|
|
38
38
|
* ## How this was produced, and how to reproduce it
|
|
39
39
|
*
|
|
40
|
-
* `scripts/measure-font.
|
|
40
|
+
* `scripts/measure-font.ts` loads the real `@fontsource-variable/inter`
|
|
41
41
|
* woff2 into Chromium via Playwright, waits for `document.fonts.ready` and
|
|
42
42
|
* calls `canvas.measureText` on every character below, then buckets them by
|
|
43
43
|
* rounded ratio. Run it from the repo root and paste the output back here:
|
|
44
44
|
*
|
|
45
|
-
* node packages/@alepha/ui/scripts/measure-font.
|
|
45
|
+
* node packages/@alepha/ui/scripts/measure-font.ts
|
|
46
46
|
*
|
|
47
47
|
* The numbers are NOT magic and NOT hand-tuned. If the pinned face or size
|
|
48
48
|
* ever changes, regenerate rather than nudging a value.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textMetrics.js","names":[],"sources":["../../../../src/components/markdown-view/diagram/textMetrics.ts"],"sourcesContent":["import type { GraphNode } from \"./graphModel.ts\";\n\n/**\n * The font the diagram pins, and never inherits.\n *\n * Inheriting is the trap: folio view mode and the quest description set\n * prose in Literata at 16.5px and load it lazily after first paint, while\n * every other surface is Inter at `text-sm`. An SVG that inherits would\n * measure against one face and render in another, differently per surface,\n * and shift when the font file lands. So the emitter sets both explicitly\n * and the table below is generated against exactly this face and size.\n *\n * `@alepha/ui` ships Inter through `@fontsource-variable/inter`; the stack\n * degrades to the platform UI sans if it has not loaded.\n */\nexport const DIAGRAM_FONT_FAMILY =\n '\"Inter Variable\", Inter, system-ui, -apple-system, \"Segoe UI\", sans-serif';\n\n/**\n * The one size every diagram label is drawn at.\n */\nexport const DIAGRAM_FONT_SIZE = 13;\n\n/**\n * Baseline-to-baseline distance, as a multiple of the font size.\n */\nexport const DIAGRAM_LINE_HEIGHT = 1.35;\n\n/**\n * The widest a label may measure before it wraps, in pixels at\n * `DIAGRAM_FONT_SIZE`. Without a clamp a 400-character label produces a\n * 4000px box and every other node in the diagram becomes a speck.\n */\nexport const MAX_LABEL_WIDTH = 220;\n\n/**\n * How many lines a label keeps before the rest is cut with an ellipsis.\n */\nexport const MAX_LABEL_LINES = 8;\n\n/**\n * Per-character advance widths for Inter, as a RATIO of the font size, so\n * the table scales to any size.\n *\n * ## How this was produced, and how to reproduce it\n *\n * `scripts/measure-font.mjs` loads the real `@fontsource-variable/inter`\n * woff2 into Chromium via Playwright, waits for `document.fonts.ready` and\n * calls `canvas.measureText` on every character below, then buckets them by\n * rounded ratio. Run it from the repo root and paste the output back here:\n *\n * node packages/@alepha/ui/scripts/measure-font.mjs\n *\n * The numbers are NOT magic and NOT hand-tuned. If the pinned face or size\n * ever changes, regenerate rather than nudging a value.\n *\n * ## Why a table at all\n *\n * Layout needs node sizes before it can place anything, and node width comes\n * from the label. Mermaid gets this by rendering into a hidden DOM node,\n * which is precisely why mermaid cannot run without a browser. Arithmetic\n * keeps the layout core a pure function. It is an approximation: 5% off on a\n * box width is invisible in a boxes-and-arrows diagram, and it is the\n * concrete reason v1 is flowcharts rather than sequence diagrams, whose\n * layout is far more sensitive to text metrics.\n */\nconst WIDTH_BUCKETS: Array<[ratio: number, chars: string]> = [\n [0.242, \"ijl\"],\n [0.261, \"’\"],\n [0.269, \"I\"],\n [0.281, \" \"],\n [0.288, \"!,.:·\"],\n [0.3, \"'\"],\n [0.302, \";\"],\n [0.323, \"`\"],\n [0.327, \"t\"],\n [0.333, \"|\"],\n [0.36, \"/\\\\\"],\n [0.365, \"()[]\"],\n [0.37, \"f\"],\n [0.376, \"r\"],\n [0.407, \"1\"],\n [0.426, \"{}\"],\n [0.44, \"“”\"],\n [0.456, \"_\"],\n [0.46, \"-\"],\n [0.466, '\"'],\n [0.471, \"^\"],\n [0.501, \"*\"],\n [0.511, \"?\"],\n [0.528, \"s\"],\n [0.546, \"x\"],\n [0.549, \"k\"],\n [0.552, \"z\"],\n [0.562, \"avyà\"],\n [0.565, \"L\"],\n [0.566, \"7\"],\n [0.571, \"Jcç\"],\n [0.583, \"eéè\"],\n [0.59, \"F\"],\n [0.591, \"hnuüñ\"],\n [0.593, \"5\"],\n [0.6, \"oö\"],\n [0.601, \"E\"],\n [0.61, \"2\"],\n [0.612, \"bdpq\"],\n [0.613, \"g\"],\n [0.618, \"3\"],\n [0.619, \"8\"],\n [0.62, \"69\"],\n [0.629, \"Z\"],\n [0.631, \"0\"],\n [0.633, \"#\"],\n [0.639, \"P\"],\n [0.642, \"$S\"],\n [0.644, \"&R\"],\n [0.646, \"4T\"],\n [0.654, \"B\"],\n [0.662, \"+<=>~\"],\n [0.672, \"K\"],\n [0.679, \"Y\"],\n [0.682, \"X\"],\n [0.69, \"AV\"],\n [0.722, \"D\"],\n [0.73, \"C\"],\n [0.743, \"H\"],\n [0.744, \"U\"],\n [0.746, \"G\"],\n [0.753, \"N\"],\n [0.765, \"OQ\"],\n [0.818, \"w\"],\n [0.864, \"…\"],\n [0.876, \"m\"],\n [0.903, \"M\"],\n [0.966, \"@\"],\n [0.982, \"%\"],\n [0.985, \"W\"],\n [1, \"→←—\"],\n];\n\n/**\n * Anything unlisted (CJK, emoji, the rest of Unicode) measures at the\n * average of the table. Wrong, but bounded, which is the whole contract.\n */\nconst FALLBACK_RATIO = 0.57;\n\nconst RATIOS: Map<string, number> = new Map(\n WIDTH_BUCKETS.flatMap(([ratio, chars]) =>\n // Width buckets are ASCII characters; there is nothing multi-unit to split.\n // oxlint-disable-next-line typescript/no-misused-spread\n [...chars].map((char) => [char, ratio] as [string, number]),\n ),\n);\n\n/**\n * The rendered width of one line, in pixels, at `fontSize`.\n */\nexport const measureLine = (line: string, fontSize: number): number => {\n let ratio = 0;\n for (const char of line) ratio += RATIOS.get(char) ?? FALLBACK_RATIO;\n return ratio * fontSize;\n};\n\nexport interface LabelMetrics {\n /**\n * The widest line, in pixels.\n */\n width: number;\n /**\n * Total height of the line box stack, in pixels.\n */\n height: number;\n /**\n * The lines as measured - wrapped and capped, so the emitter draws these.\n */\n lines: string[];\n}\n\n/**\n * Measure a node or cluster label, wrapping and clamping it first.\n *\n * Returns the lines it actually measured, not the ones it was given: the\n * emitter must draw exactly what was measured, or text and box disagree.\n */\nexport const measureLabel = (\n lines: string[],\n fontSize: number = DIAGRAM_FONT_SIZE,\n): LabelMetrics => {\n const wrapped: string[] = [];\n for (const line of lines) {\n for (const piece of wrapLine(line, fontSize)) {\n wrapped.push(piece);\n if (wrapped.length >= MAX_LABEL_LINES) break;\n }\n if (wrapped.length >= MAX_LABEL_LINES) break;\n }\n\n const cut =\n wrapped.length >= MAX_LABEL_LINES &&\n countWrapped(lines, fontSize) > MAX_LABEL_LINES;\n if (cut)\n wrapped[MAX_LABEL_LINES - 1] = truncate(\n wrapped[MAX_LABEL_LINES - 1],\n fontSize,\n );\n\n const measured = wrapped.length > 0 ? wrapped : [\"\"];\n return {\n width: Math.max(\n ...measured.map((line) => measureLine(line, fontSize)),\n fontSize,\n ),\n height: measured.length * fontSize * DIAGRAM_LINE_HEIGHT,\n lines: measured,\n };\n};\n\n/**\n * The box a node needs: its label plus padding, per shape.\n */\nexport const measureNode = (\n node: Pick<GraphNode, \"lines\" | \"shape\">,\n fontSize: number = DIAGRAM_FONT_SIZE,\n): LabelMetrics => {\n const label = measureLabel(node.lines, fontSize);\n\n if (node.shape === \"circle\") {\n // An axis-aligned w x h box fits an ellipse exactly when\n // (w/2 / rx)^2 + (h/2 / ry)^2 <= 1, and rx = (w/2)·√2, ry = (h/2)·√2 is\n // the solution that touches all four corners. Forcing width === height\n // instead is what turned a two-word label into an enormous disc that\n // made every other node in the diagram a speck.\n const width = label.width * Math.SQRT2 + 12;\n const height = label.height * Math.SQRT2 + 12;\n return {\n // A one-line label is far wider than it is tall, so without a floor\n // the \"circle\" degenerates into a flat sliver.\n width,\n height: Math.max(height, width * 0.55),\n lines: label.lines,\n };\n }\n\n // A diamond has to be wide enough that its slanted sides clear the text.\n const padX = node.shape === \"diamond\" ? 34 : 16;\n const padY = node.shape === \"diamond\" ? 20 : 10;\n return {\n width: label.width + padX * 2,\n height: label.height + padY * 2,\n lines: label.lines,\n };\n};\n\n/**\n * Break one line to fit `MAX_LABEL_WIDTH`, at spaces where there are any.\n */\nconst wrapLine = (line: string, fontSize: number): string[] => {\n if (measureLine(line, fontSize) <= MAX_LABEL_WIDTH) return [line];\n\n const out: string[] = [];\n let current = \"\";\n for (const word of line.split(/\\s+/).filter(Boolean)) {\n const candidate = current ? `${current} ${word}` : word;\n if (current && measureLine(candidate, fontSize) > MAX_LABEL_WIDTH) {\n out.push(current);\n current = word;\n continue;\n }\n current = candidate;\n }\n if (current) out.push(current);\n\n // A single word wider than the cap cannot be wrapped, only cut.\n return out.map((piece) =>\n measureLine(piece, fontSize) > MAX_LABEL_WIDTH\n ? truncate(piece, fontSize)\n : piece,\n );\n};\n\n/**\n * How many lines the label WOULD take unwrapped-capped, so a label that\n * exactly fills the cap is not marked as cut.\n */\nconst countWrapped = (lines: string[], fontSize: number): number =>\n lines.reduce((total, line) => total + wrapLine(line, fontSize).length, 0);\n\nconst truncate = (line: string, fontSize: number): string => {\n const ellipsis = measureLine(\"\\u2026\", fontSize);\n let out = \"\";\n for (const char of line) {\n if (measureLine(out + char, fontSize) + ellipsis > MAX_LABEL_WIDTH) break;\n out += char;\n }\n return `${out}\\u2026`;\n};\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAa,sBACX;;;;AAKF,MAAa,oBAAoB;;;;AAKjC,MAAa,sBAAsB;;;;;;AAOnC,MAAa,kBAAkB;;;;AAK/B,MAAa,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4B/B,MAAM,gBAAuD;CAC3D,CAAC,MAAO,KAAK;CACb,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,OAAO;CACf,CAAC,IAAK,GAAG;CACT,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,GAAG;CACX,CAAC,KAAM,KAAK;CACZ,CAAC,MAAO,MAAM;CACd,CAAC,KAAM,GAAG;CACV,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,IAAI;C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;CAC7C,MAAM,OAAO,KAAK,UAAU,YAAY,KAAK;CAC7C,OAAO;EACL,OAAO,MAAM,QAAQ,OAAO;EAC5B,QAAQ,MAAM,SAAS,OAAO;EAC9B,OAAO,MAAM;CACf;AACF;;;;AAKA,MAAM,YAAY,MAAc,aAA+B;CAC7D,IAAI,YAAY,MAAM,QAAQ,KAAA,KAAsB,OAAO,CAAC,IAAI;CAEhE,MAAM,MAAgB,CAAC;CACvB,IAAI,UAAU;CACd,KAAK,MAAM,QAAQ,KAAK,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO,GAAG;EACpD,MAAM,YAAY,UAAU,GAAG,QAAQ,GAAG,SAAS;EACnD,IAAI,WAAW,YAAY,WAAW,QAAQ,IAAA,KAAqB;GACjE,IAAI,KAAK,OAAO;GAChB,UAAU;GACV;EACF;EACA,UAAU;CACZ;CACA,IAAI,SAAS,IAAI,KAAK,OAAO;CAG7B,OAAO,IAAI,KAAK,UACd,YAAY,OAAO,QAAQ,IAAA,MACvB,SAAS,OAAO,QAAQ,IACxB,KACN;AACF;;;;;AAMA,MAAM,gBAAgB,OAAiB,aACrC,MAAM,QAAQ,OAAO,SAAS,QAAQ,SAAS,MAAM,QAAQ,CAAC,CAAC,QAAQ,CAAC;AAE1E,MAAM,YAAY,MAAc,aAA6B;CAC3D,MAAM,WAAW,YAAY,KAAU,QAAQ;CAC/C,IAAI,MAAM;CACV,KAAK,MAAM,QAAQ,MAAM;EACvB,IAAI,YAAY,MAAM,MAAM,QAAQ,IAAI,WAAA,KAA4B;EACpE,OAAO;CACT;CACA,OAAO,GAAG,IAAI;AAChB"}
|
|
1
|
+
{"version":3,"file":"textMetrics.js","names":[],"sources":["../../../../src/components/markdown-view/diagram/textMetrics.ts"],"sourcesContent":["import type { GraphNode } from \"./graphModel.ts\";\n\n/**\n * The font the diagram pins, and never inherits.\n *\n * Inheriting is the trap: folio view mode and the quest description set\n * prose in Literata at 16.5px and load it lazily after first paint, while\n * every other surface is Inter at `text-sm`. An SVG that inherits would\n * measure against one face and render in another, differently per surface,\n * and shift when the font file lands. So the emitter sets both explicitly\n * and the table below is generated against exactly this face and size.\n *\n * `@alepha/ui` ships Inter through `@fontsource-variable/inter`; the stack\n * degrades to the platform UI sans if it has not loaded.\n */\nexport const DIAGRAM_FONT_FAMILY =\n '\"Inter Variable\", Inter, system-ui, -apple-system, \"Segoe UI\", sans-serif';\n\n/**\n * The one size every diagram label is drawn at.\n */\nexport const DIAGRAM_FONT_SIZE = 13;\n\n/**\n * Baseline-to-baseline distance, as a multiple of the font size.\n */\nexport const DIAGRAM_LINE_HEIGHT = 1.35;\n\n/**\n * The widest a label may measure before it wraps, in pixels at\n * `DIAGRAM_FONT_SIZE`. Without a clamp a 400-character label produces a\n * 4000px box and every other node in the diagram becomes a speck.\n */\nexport const MAX_LABEL_WIDTH = 220;\n\n/**\n * How many lines a label keeps before the rest is cut with an ellipsis.\n */\nexport const MAX_LABEL_LINES = 8;\n\n/**\n * Per-character advance widths for Inter, as a RATIO of the font size, so\n * the table scales to any size.\n *\n * ## How this was produced, and how to reproduce it\n *\n * `scripts/measure-font.ts` loads the real `@fontsource-variable/inter`\n * woff2 into Chromium via Playwright, waits for `document.fonts.ready` and\n * calls `canvas.measureText` on every character below, then buckets them by\n * rounded ratio. Run it from the repo root and paste the output back here:\n *\n * node packages/@alepha/ui/scripts/measure-font.ts\n *\n * The numbers are NOT magic and NOT hand-tuned. If the pinned face or size\n * ever changes, regenerate rather than nudging a value.\n *\n * ## Why a table at all\n *\n * Layout needs node sizes before it can place anything, and node width comes\n * from the label. Mermaid gets this by rendering into a hidden DOM node,\n * which is precisely why mermaid cannot run without a browser. Arithmetic\n * keeps the layout core a pure function. It is an approximation: 5% off on a\n * box width is invisible in a boxes-and-arrows diagram, and it is the\n * concrete reason v1 is flowcharts rather than sequence diagrams, whose\n * layout is far more sensitive to text metrics.\n */\nconst WIDTH_BUCKETS: Array<[ratio: number, chars: string]> = [\n [0.242, \"ijl\"],\n [0.261, \"’\"],\n [0.269, \"I\"],\n [0.281, \" \"],\n [0.288, \"!,.:·\"],\n [0.3, \"'\"],\n [0.302, \";\"],\n [0.323, \"`\"],\n [0.327, \"t\"],\n [0.333, \"|\"],\n [0.36, \"/\\\\\"],\n [0.365, \"()[]\"],\n [0.37, \"f\"],\n [0.376, \"r\"],\n [0.407, \"1\"],\n [0.426, \"{}\"],\n [0.44, \"“”\"],\n [0.456, \"_\"],\n [0.46, \"-\"],\n [0.466, '\"'],\n [0.471, \"^\"],\n [0.501, \"*\"],\n [0.511, \"?\"],\n [0.528, \"s\"],\n [0.546, \"x\"],\n [0.549, \"k\"],\n [0.552, \"z\"],\n [0.562, \"avyà\"],\n [0.565, \"L\"],\n [0.566, \"7\"],\n [0.571, \"Jcç\"],\n [0.583, \"eéè\"],\n [0.59, \"F\"],\n [0.591, \"hnuüñ\"],\n [0.593, \"5\"],\n [0.6, \"oö\"],\n [0.601, \"E\"],\n [0.61, \"2\"],\n [0.612, \"bdpq\"],\n [0.613, \"g\"],\n [0.618, \"3\"],\n [0.619, \"8\"],\n [0.62, \"69\"],\n [0.629, \"Z\"],\n [0.631, \"0\"],\n [0.633, \"#\"],\n [0.639, \"P\"],\n [0.642, \"$S\"],\n [0.644, \"&R\"],\n [0.646, \"4T\"],\n [0.654, \"B\"],\n [0.662, \"+<=>~\"],\n [0.672, \"K\"],\n [0.679, \"Y\"],\n [0.682, \"X\"],\n [0.69, \"AV\"],\n [0.722, \"D\"],\n [0.73, \"C\"],\n [0.743, \"H\"],\n [0.744, \"U\"],\n [0.746, \"G\"],\n [0.753, \"N\"],\n [0.765, \"OQ\"],\n [0.818, \"w\"],\n [0.864, \"…\"],\n [0.876, \"m\"],\n [0.903, \"M\"],\n [0.966, \"@\"],\n [0.982, \"%\"],\n [0.985, \"W\"],\n [1, \"→←—\"],\n];\n\n/**\n * Anything unlisted (CJK, emoji, the rest of Unicode) measures at the\n * average of the table. Wrong, but bounded, which is the whole contract.\n */\nconst FALLBACK_RATIO = 0.57;\n\nconst RATIOS: Map<string, number> = new Map(\n WIDTH_BUCKETS.flatMap(([ratio, chars]) =>\n // Width buckets are ASCII characters; there is nothing multi-unit to split.\n // oxlint-disable-next-line typescript/no-misused-spread\n [...chars].map((char) => [char, ratio] as [string, number]),\n ),\n);\n\n/**\n * The rendered width of one line, in pixels, at `fontSize`.\n */\nexport const measureLine = (line: string, fontSize: number): number => {\n let ratio = 0;\n for (const char of line) ratio += RATIOS.get(char) ?? FALLBACK_RATIO;\n return ratio * fontSize;\n};\n\nexport interface LabelMetrics {\n /**\n * The widest line, in pixels.\n */\n width: number;\n /**\n * Total height of the line box stack, in pixels.\n */\n height: number;\n /**\n * The lines as measured - wrapped and capped, so the emitter draws these.\n */\n lines: string[];\n}\n\n/**\n * Measure a node or cluster label, wrapping and clamping it first.\n *\n * Returns the lines it actually measured, not the ones it was given: the\n * emitter must draw exactly what was measured, or text and box disagree.\n */\nexport const measureLabel = (\n lines: string[],\n fontSize: number = DIAGRAM_FONT_SIZE,\n): LabelMetrics => {\n const wrapped: string[] = [];\n for (const line of lines) {\n for (const piece of wrapLine(line, fontSize)) {\n wrapped.push(piece);\n if (wrapped.length >= MAX_LABEL_LINES) break;\n }\n if (wrapped.length >= MAX_LABEL_LINES) break;\n }\n\n const cut =\n wrapped.length >= MAX_LABEL_LINES &&\n countWrapped(lines, fontSize) > MAX_LABEL_LINES;\n if (cut)\n wrapped[MAX_LABEL_LINES - 1] = truncate(\n wrapped[MAX_LABEL_LINES - 1],\n fontSize,\n );\n\n const measured = wrapped.length > 0 ? wrapped : [\"\"];\n return {\n width: Math.max(\n ...measured.map((line) => measureLine(line, fontSize)),\n fontSize,\n ),\n height: measured.length * fontSize * DIAGRAM_LINE_HEIGHT,\n lines: measured,\n };\n};\n\n/**\n * The box a node needs: its label plus padding, per shape.\n */\nexport const measureNode = (\n node: Pick<GraphNode, \"lines\" | \"shape\">,\n fontSize: number = DIAGRAM_FONT_SIZE,\n): LabelMetrics => {\n const label = measureLabel(node.lines, fontSize);\n\n if (node.shape === \"circle\") {\n // An axis-aligned w x h box fits an ellipse exactly when\n // (w/2 / rx)^2 + (h/2 / ry)^2 <= 1, and rx = (w/2)·√2, ry = (h/2)·√2 is\n // the solution that touches all four corners. Forcing width === height\n // instead is what turned a two-word label into an enormous disc that\n // made every other node in the diagram a speck.\n const width = label.width * Math.SQRT2 + 12;\n const height = label.height * Math.SQRT2 + 12;\n return {\n // A one-line label is far wider than it is tall, so without a floor\n // the \"circle\" degenerates into a flat sliver.\n width,\n height: Math.max(height, width * 0.55),\n lines: label.lines,\n };\n }\n\n // A diamond has to be wide enough that its slanted sides clear the text.\n const padX = node.shape === \"diamond\" ? 34 : 16;\n const padY = node.shape === \"diamond\" ? 20 : 10;\n return {\n width: label.width + padX * 2,\n height: label.height + padY * 2,\n lines: label.lines,\n };\n};\n\n/**\n * Break one line to fit `MAX_LABEL_WIDTH`, at spaces where there are any.\n */\nconst wrapLine = (line: string, fontSize: number): string[] => {\n if (measureLine(line, fontSize) <= MAX_LABEL_WIDTH) return [line];\n\n const out: string[] = [];\n let current = \"\";\n for (const word of line.split(/\\s+/).filter(Boolean)) {\n const candidate = current ? `${current} ${word}` : word;\n if (current && measureLine(candidate, fontSize) > MAX_LABEL_WIDTH) {\n out.push(current);\n current = word;\n continue;\n }\n current = candidate;\n }\n if (current) out.push(current);\n\n // A single word wider than the cap cannot be wrapped, only cut.\n return out.map((piece) =>\n measureLine(piece, fontSize) > MAX_LABEL_WIDTH\n ? truncate(piece, fontSize)\n : piece,\n );\n};\n\n/**\n * How many lines the label WOULD take unwrapped-capped, so a label that\n * exactly fills the cap is not marked as cut.\n */\nconst countWrapped = (lines: string[], fontSize: number): number =>\n lines.reduce((total, line) => total + wrapLine(line, fontSize).length, 0);\n\nconst truncate = (line: string, fontSize: number): string => {\n const ellipsis = measureLine(\"\\u2026\", fontSize);\n let out = \"\";\n for (const char of line) {\n if (measureLine(out + char, fontSize) + ellipsis > MAX_LABEL_WIDTH) break;\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S,OAAO,QAAQ,IACxB,KACN;AACF;;;;;AAMA,MAAM,gBAAgB,OAAiB,aACrC,MAAM,QAAQ,OAAO,SAAS,QAAQ,SAAS,MAAM,QAAQ,CAAC,CAAC,QAAQ,CAAC;AAE1E,MAAM,YAAY,MAAc,aAA6B;CAC3D,MAAM,WAAW,YAAY,KAAU,QAAQ;CAC/C,IAAI,MAAM;CACV,KAAK,MAAM,QAAQ,MAAM;EACvB,IAAI,YAAY,MAAM,MAAM,QAAQ,IAAI,WAAA,KAA4B;EACpE,OAAO;CACT;CACA,OAAO,GAAG,IAAI;AAChB"}
|
|
@@ -177,3 +177,47 @@
|
|
|
177
177
|
)
|
|
178
178
|
right center / 18px 100% no-repeat scroll;
|
|
179
179
|
}
|
|
180
|
+
|
|
181
|
+
/*
|
|
182
|
+
* Discord-style `||spoilers||`.
|
|
183
|
+
*
|
|
184
|
+
* ⚠️ Not a security feature. The text is in the DOM from the first paint -
|
|
185
|
+
* this covers it, it does not withhold it - and it is in the raw markdown, in
|
|
186
|
+
* an export, over MCP and in any search snippet too. See `SpoilerSpan`.
|
|
187
|
+
*
|
|
188
|
+
* Both states are painted from `--foreground` through `color-mix`, so the
|
|
189
|
+
* dark theme needs no second block: the token already flips, and a hidden
|
|
190
|
+
* spoiler is a strong wash of it while a revealed one is the faint wash every
|
|
191
|
+
* other inline surface here uses.
|
|
192
|
+
*
|
|
193
|
+
* The hidden state sets the text to `transparent` rather than hiding it,
|
|
194
|
+
* which is what keeps the line's metrics: a `display: none` would reflow the
|
|
195
|
+
* paragraph on reveal and move the sentence out from under the reader who
|
|
196
|
+
* just clicked it. `user-select: none` stops a drag-select from lifting the
|
|
197
|
+
* covered text out through the clipboard by accident.
|
|
198
|
+
*/
|
|
199
|
+
[data-slot="markdown-view"] [data-spoiler="hidden"] {
|
|
200
|
+
background-color: color-mix(in oklab, var(--foreground) 82%, transparent);
|
|
201
|
+
color: transparent;
|
|
202
|
+
user-select: none;
|
|
203
|
+
transition: background-color 120ms ease;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
[data-slot="markdown-view"] [data-spoiler="hidden"]:hover {
|
|
207
|
+
background-color: color-mix(in oklab, var(--foreground) 70%, transparent);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/*
|
|
211
|
+
* A visible focus ring, because the hidden state has nothing else to show
|
|
212
|
+
* one against: the box IS the content, so the browser's default outline on a
|
|
213
|
+
* `color: transparent` span is the only thing telling a keyboard reader where
|
|
214
|
+
* they are.
|
|
215
|
+
*/
|
|
216
|
+
[data-slot="markdown-view"] [data-spoiler="hidden"]:focus-visible {
|
|
217
|
+
outline: 2px solid var(--ring);
|
|
218
|
+
outline-offset: 1px;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
[data-slot="markdown-view"] [data-spoiler="revealed"] {
|
|
222
|
+
background-color: color-mix(in oklab, var(--foreground) 8%, transparent);
|
|
223
|
+
}
|
|
@@ -43,6 +43,18 @@ export interface MarkdownViewProps {
|
|
|
43
43
|
* invalid mermaid, and a red box in the middle of a document is worse than
|
|
44
44
|
* a grey fence. See `packages/@alepha/ui/DOC.md` for the full table.
|
|
45
45
|
*
|
|
46
|
+
* ## Spoilers
|
|
47
|
+
*
|
|
48
|
+
* `||text||` renders as a covered box that reveals on click, on Enter or on
|
|
49
|
+
* Space, Discord's syntax and Discord's behaviour. Inline markdown inside it
|
|
50
|
+
* survives, a code span or a fence keeps its pipes literally, and an
|
|
51
|
+
* unterminated `||` renders as the two characters the author typed rather
|
|
52
|
+
* than swallowing the rest of the paragraph.
|
|
53
|
+
*
|
|
54
|
+
* ⚠️ **It is not a security feature.** The text is in the DOM from the first
|
|
55
|
+
* paint, in the raw markdown, in an export, over MCP and in any search
|
|
56
|
+
* snippet. It hides a plot point from a reader's eye and nothing more.
|
|
57
|
+
*
|
|
46
58
|
* ## Raw HTML
|
|
47
59
|
*
|
|
48
60
|
* No raw HTML is ever rendered as markup: react-markdown's default is to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-view.d.ts","sourceRoot":"","sources":["../../../src/components/markdown-view/markdown-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"markdown-view.d.ts","sourceRoot":"","sources":["../../../src/components/markdown-view/markdown-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,qBAAqB,CAAC;AAiC7B,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,eAAO,MAAM,YAAY,UAAW,iBAAiB,sBAkIpD,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { SpoilerSpan } from "./SpoilerSpan.js";
|
|
1
2
|
import { DiagramErrorBoundary } from "./diagram/DiagramErrorBoundary.js";
|
|
3
|
+
import { remarkSpoiler } from "./remarkSpoiler.js";
|
|
2
4
|
import { Suspense, lazy } from "react";
|
|
3
5
|
import { jsx } from "react/jsx-runtime";
|
|
4
6
|
import "./markdown-view.css";
|
|
@@ -60,6 +62,18 @@ const MermaidFence = lazy(() => import("./diagram/MermaidFence.js"));
|
|
|
60
62
|
* invalid mermaid, and a red box in the middle of a document is worse than
|
|
61
63
|
* a grey fence. See `packages/@alepha/ui/DOC.md` for the full table.
|
|
62
64
|
*
|
|
65
|
+
* ## Spoilers
|
|
66
|
+
*
|
|
67
|
+
* `||text||` renders as a covered box that reveals on click, on Enter or on
|
|
68
|
+
* Space, Discord's syntax and Discord's behaviour. Inline markdown inside it
|
|
69
|
+
* survives, a code span or a fence keeps its pipes literally, and an
|
|
70
|
+
* unterminated `||` renders as the two characters the author typed rather
|
|
71
|
+
* than swallowing the rest of the paragraph.
|
|
72
|
+
*
|
|
73
|
+
* ⚠️ **It is not a security feature.** The text is in the DOM from the first
|
|
74
|
+
* paint, in the raw markdown, in an export, over MCP and in any search
|
|
75
|
+
* snippet. It hides a plot point from a reader's eye and nothing more.
|
|
76
|
+
*
|
|
63
77
|
* ## Raw HTML
|
|
64
78
|
*
|
|
65
79
|
* No raw HTML is ever rendered as markup: react-markdown's default is to
|
|
@@ -78,7 +92,7 @@ const MarkdownView = (props) => {
|
|
|
78
92
|
"data-slot": "markdown-view",
|
|
79
93
|
className: `max-w-none text-sm leading-relaxed ${props.className ?? ""}`,
|
|
80
94
|
children: /* @__PURE__ */ jsx(ReactMarkdown, {
|
|
81
|
-
remarkPlugins: [remarkGfm],
|
|
95
|
+
remarkPlugins: [remarkGfm, remarkSpoiler],
|
|
82
96
|
rehypePlugins: [[rehypeHighlight, {
|
|
83
97
|
detect: true,
|
|
84
98
|
plainText: ["mermaid"]
|
|
@@ -145,6 +159,13 @@ const MarkdownView = (props) => {
|
|
|
145
159
|
})
|
|
146
160
|
});
|
|
147
161
|
},
|
|
162
|
+
span: ({ children, ...rest }) => {
|
|
163
|
+
if (rest["data-spoiler"]) return /* @__PURE__ */ jsx(SpoilerSpan, { children });
|
|
164
|
+
return /* @__PURE__ */ jsx("span", {
|
|
165
|
+
...rest,
|
|
166
|
+
children
|
|
167
|
+
});
|
|
168
|
+
},
|
|
148
169
|
blockquote: ({ children }) => /* @__PURE__ */ jsx("blockquote", {
|
|
149
170
|
className: "border-muted-foreground/30 my-3 border-l-2 pl-4 italic",
|
|
150
171
|
children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-view.js","names":["pre"],"sources":["../../../src/components/markdown-view/markdown-view.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport \"./markdown-view.css\";\nimport { lazy, Suspense } from \"react\";\nimport ReactMarkdown from \"react-markdown\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport remarkGfm from \"remark-gfm\";\n\nimport { DiagramErrorBoundary } from \"./diagram/DiagramErrorBoundary.tsx\";\n\n/**\n * Both parsers, both layouts (`graphre` for the flowchart, arithmetic for\n * the sequence diagram) and both emitters, pulled in ONLY when a document\n * actually contains a mermaid fence.\n *\n * This is the constraint the whole diagram layer exists under: a document\n * with no diagram must pay nothing at all. One with a diagram pays one\n * chunk once, then it is cached. Measured on 2026-08-28 with both diagram\n * types in it: 64.5 kB raw, **22.2 kB gzip**, 19.4 kB brotli - against\n * 17.95 kB gzip when it drew flowcharts only. If it ever passes ~26 kB,\n * split the two pipelines into two chunks so a flowchart-only document\n * stops paying for the sequence one.\n *\n * ⚠️ A lazy import a bundler decides to inline fails silently: the feature\n * still works and the cost moves into the entry chunk. After changing this,\n * build and confirm the diagram code is in a chunk of its own and the entry\n * has none of it:\n *\n * yarn w lore build\n * grep -rl 'addBorderSegments\\|sequenceDiagram' apps/lore/dist/public/\n */\nconst MermaidFence = lazy(() => import(\"./diagram/MermaidFence.tsx\"));\n\nexport interface MarkdownViewProps {\n content: string;\n /**\n * Extra classes for the prose root, merged after the defaults so a caller\n * can set its own reading face or measure. The defaults it overrides are\n * `text-sm leading-relaxed` — a surface that sets prose in a display serif\n * needs both, and no parent wrapper can supply them, since they sit on\n * this element rather than being inherited.\n */\n className?: string;\n}\n\n/**\n * Renders markdown as formatted prose.\n *\n * ## Diagrams\n *\n * A ` ```mermaid ` fence containing a **`flowchart`** or a\n * **`sequenceDiagram`** is drawn as an SVG diagram instead of a code block,\n * themed from the app's own CSS variables so dark mode needs no second\n * palette. The renderer is in-house: only flowchart layout is imported\n * (`graphre`, dagre in TypeScript, ~15.5 kB gzip), and the whole thing is\n * one lazy chunk pulled in only when a document actually contains a fence,\n * so a document with no diagram pays nothing.\n *\n * The flowchart subset is `flowchart TD|TB|LR|RL|BT`; the four node shapes\n * `[rect]` `(rounded)` `{diamond}` `((circle))`, with every other mermaid\n * bracket pair consumed and mapped onto them; edges `-->` `---` `-.->`\n * `==>` `<-->` with labels in both the `-->|text|` and `-- text -->` forms;\n * chains, `&` fans, `<br/>` line breaks and nested `subgraph`.\n *\n * The sequence subset is participants and actors, the eight arrow forms,\n * notes, `autonumber`, self-messages and the `alt` / `else` / `opt` /\n * `loop` fragment boxes. Activation bars are ignored. A wide sequence\n * diagram keeps its natural size in a scroll frame rather than shrinking\n * into the prose column.\n *\n * **Everything else degrades to the code block, silently.**\n * `classDiagram`, `gantt` and mindmaps are not drawn, `style` / `classDef`\n * are ignored, and a parse failure, a refused construct or a diagram past\n * its cap renders the plain fence rather than an error. Agents write\n * invalid mermaid, and a red box in the middle of a document is worse than\n * a grey fence. See `packages/@alepha/ui/DOC.md` for the full table.\n *\n * ## Raw HTML\n *\n * No raw HTML is ever rendered as markup: react-markdown's default is to\n * escape a raw node to text, and this component deliberately mounts no\n * plugin that changes that. A narrow `rehypeSafeImg` plugin used to promote\n * a lone `<img …>` — the one thing MDXEditor emitted for a *resized* image —\n * and was deleted along with the editor that produced it, since nothing\n * writes that markup anymore.\n *\n * Do not reach for `rehype-raw` to bring the capability back: this renders\n * content authored by one user to another, so every raw tag becoming live\n * markup turns every markdown surface in every app into an injection point.\n */\nexport const MarkdownView = (props: MarkdownViewProps) => {\n return (\n <div\n // `data-slot`, matching every other block here, so a host page can\n // reach the prose root without a wrapper class. Lore's folio\n // document uses it to make this inherit the reading size instead\n // of the `text-sm` default below.\n data-slot=\"markdown-view\"\n className={`max-w-none text-sm leading-relaxed ${props.className ?? \"\"}`}\n >\n <ReactMarkdown\n remarkPlugins={[remarkGfm]}\n rehypePlugins={[\n // `plainText` claims the fence BEFORE highlighting runs: hljs would\n // otherwise tokenise the diagram source, and the fallback would be a\n // soup of spans instead of the text the author wrote.\n //\n // `ignoreMissing` is gone: it no longer exists in v7, where an\n // unknown language already produces a vfile message rather than a\n // throw.\n [rehypeHighlight, { detect: true, plainText: [\"mermaid\"] }],\n ]}\n components={{\n h1: ({ children }) => (\n <h1 className=\"mt-6 mb-3 text-2xl font-semibold tracking-tight\">\n {children}\n </h1>\n ),\n h2: ({ children }) => (\n <h2 className=\"mt-6 mb-2 text-xl font-semibold tracking-tight\">\n {children}\n </h2>\n ),\n h3: ({ children }) => (\n <h3 className=\"mt-4 mb-2 text-base font-semibold\">{children}</h3>\n ),\n p: ({ children }) => <p className=\"my-3\">{children}</p>,\n ul: ({ children }) => (\n <ul className=\"my-3 list-disc space-y-1 pl-5\">{children}</ul>\n ),\n ol: ({ children }) => (\n <ol className=\"my-3 list-decimal space-y-1 pl-5\">{children}</ol>\n ),\n li: ({ children }) => <li className=\"pl-1\">{children}</li>,\n a: ({ href, children }) => (\n <a\n href={href}\n className=\"text-primary decoration-primary/50 hover:decoration-primary underline underline-offset-4\"\n >\n {children}\n </a>\n ),\n code: ({ children, className }) => {\n const isBlock =\n className?.includes(\"language-\") || className?.includes(\"hljs\");\n if (isBlock) {\n return <code className={`${className} text-xs`}>{children}</code>;\n }\n return (\n <code className=\"bg-muted rounded px-1.5 py-0.5 font-mono text-[0.85em]\">\n {children}\n </code>\n );\n },\n pre: ({ children, node }) => {\n const block = (\n <pre className=\"border-border my-4 overflow-auto rounded-md border bg-transparent p-3 text-xs\">\n {children}\n </pre>\n );\n const source = mermaidSource(node);\n if (!source) return block;\n return (\n <DiagramErrorBoundary fallback={block}>\n {/*\n The loading state IS the code block: the fence is already on\n screen, and swapping it for the diagram when the chunk lands\n costs no spinner and no second layout.\n */}\n <Suspense fallback={block}>\n <MermaidFence source={source} fallback={block} />\n </Suspense>\n </DiagramErrorBoundary>\n );\n },\n blockquote: ({ children }) => (\n <blockquote className=\"border-muted-foreground/30 my-3 border-l-2 pl-4 italic\">\n {children}\n </blockquote>\n ),\n hr: () => <hr className=\"border-border my-6\" />,\n table: ({ children }) => (\n <table className=\"my-4 border-collapse text-xs\">{children}</table>\n ),\n th: ({ children }) => (\n <th className=\"border-border border px-2 py-1 text-left font-medium\">\n {children}\n </th>\n ),\n td: ({ children }) => (\n <td className=\"border-border border px-2 py-1\">{children}</td>\n ),\n }}\n >\n {props.content}\n </ReactMarkdown>\n </div>\n );\n};\n\n/**\n * The text of a ` ```mermaid ` fence, or `undefined` for every other `<pre>`.\n *\n * Reads the hast node rather than the rendered children because the source\n * has to arrive at the parser exactly as the author typed it, and walking React\n * children would mean reassembling it from whatever the renderer produced.\n *\n * The alternative wiring, a remark plugin, is more code for the same result:\n * `mdast-util-to-hast` applies `data.hName` to the `<code>` element BEFORE\n * wrapping it in `<pre>`, so renaming the code node still leaves the diagram\n * inside this bordered box. Going that way needs a custom node type and a\n * cast into `components`, whose type is keyed on intrinsic elements.\n */\nconst mermaidSource = (node: unknown): string | undefined => {\n const pre = node as\n | {\n children?: Array<{\n type?: string;\n tagName?: string;\n properties?: { className?: unknown };\n children?: Array<{ type?: string; value?: string }>;\n }>;\n }\n | undefined;\n const code = pre?.children?.[0];\n if (code?.type !== \"element\" || code.tagName !== \"code\") return undefined;\n\n const className = code.properties?.className;\n const names = Array.isArray(className)\n ? className.map(String)\n : typeof className === \"string\"\n ? className.split(/\\s+/)\n : [];\n if (!names.includes(\"language-mermaid\")) return undefined;\n\n const text = code.children\n ?.filter((child) => child.type === \"text\")\n .map((child) => child.value ?? \"\")\n .join(\"\");\n return text?.trim() ? text : undefined;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAM,eAAe,WAAW,OAAO,4BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DpE,MAAa,gBAAgB,UAA6B;CACxD,OACE,oBAAC,OAAD;EAKE,aAAU;EACV,WAAW,sCAAsC,MAAM,aAAa;EAEpE,UAAA,oBAAC,eAAD;GACE,eAAe,CAAC,SAAS;GACzB,eAAe,CAQb,CAAC,iBAAiB;IAAE,QAAQ;IAAM,WAAW,CAAC,SAAS;GAAE,CAAC,CAC5D;GACA,YAAY;IACV,KAAK,EAAE,eACL,oBAAC,MAAD;KAAI,WAAU;KACX;I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BAAC,MAAD;KAAI,WAAU;KACX;IACC,CAAA;IAEN,KAAK,EAAE,eACL,oBAAC,MAAD;KAAI,WAAU;KAAkC;IAAa,CAAA;GAEjE;GAEC,UAAA,MAAM;EACM,CAAA;CACZ,CAAA;AAET;;;;;;;;;;;;;;AAeA,MAAM,iBAAiB,SAAsC;CAW3D,MAAM,OAAOA,MAAK,WAAW;CAC7B,IAAI,MAAM,SAAS,aAAa,KAAK,YAAY,QAAQ,OAAO,KAAA;CAEhE,MAAM,YAAY,KAAK,YAAY;CAMnC,IAAI,EALU,MAAM,QAAQ,SAAS,IACjC,UAAU,IAAI,MAAM,IACpB,OAAO,cAAc,WACnB,UAAU,MAAM,KAAK,IACrB,CAAC,EAAA,CACI,SAAS,kBAAkB,GAAG,OAAO,KAAA;CAEhD,MAAM,OAAO,KAAK,UACd,QAAQ,UAAU,MAAM,SAAS,MAAM,CAAC,CACzC,KAAK,UAAU,MAAM,SAAS,EAAE,CAAC,CACjC,KAAK,EAAE;CACV,OAAO,MAAM,KAAK,IAAI,OAAO,KAAA;AAC/B"}
|
|
1
|
+
{"version":3,"file":"markdown-view.js","names":["pre"],"sources":["../../../src/components/markdown-view/markdown-view.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport \"./markdown-view.css\";\nimport { lazy, Suspense } from \"react\";\nimport ReactMarkdown from \"react-markdown\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport remarkGfm from \"remark-gfm\";\n\nimport { DiagramErrorBoundary } from \"./diagram/DiagramErrorBoundary.tsx\";\nimport { remarkSpoiler } from \"./remarkSpoiler.ts\";\nimport { SpoilerSpan } from \"./SpoilerSpan.tsx\";\n\n/**\n * Both parsers, both layouts (`graphre` for the flowchart, arithmetic for\n * the sequence diagram) and both emitters, pulled in ONLY when a document\n * actually contains a mermaid fence.\n *\n * This is the constraint the whole diagram layer exists under: a document\n * with no diagram must pay nothing at all. One with a diagram pays one\n * chunk once, then it is cached. Measured on 2026-08-28 with both diagram\n * types in it: 64.5 kB raw, **22.2 kB gzip**, 19.4 kB brotli - against\n * 17.95 kB gzip when it drew flowcharts only. If it ever passes ~26 kB,\n * split the two pipelines into two chunks so a flowchart-only document\n * stops paying for the sequence one.\n *\n * ⚠️ A lazy import a bundler decides to inline fails silently: the feature\n * still works and the cost moves into the entry chunk. After changing this,\n * build and confirm the diagram code is in a chunk of its own and the entry\n * has none of it:\n *\n * yarn w lore build\n * grep -rl 'addBorderSegments\\|sequenceDiagram' apps/lore/dist/public/\n */\nconst MermaidFence = lazy(() => import(\"./diagram/MermaidFence.tsx\"));\n\nexport interface MarkdownViewProps {\n content: string;\n /**\n * Extra classes for the prose root, merged after the defaults so a caller\n * can set its own reading face or measure. The defaults it overrides are\n * `text-sm leading-relaxed` — a surface that sets prose in a display serif\n * needs both, and no parent wrapper can supply them, since they sit on\n * this element rather than being inherited.\n */\n className?: string;\n}\n\n/**\n * Renders markdown as formatted prose.\n *\n * ## Diagrams\n *\n * A ` ```mermaid ` fence containing a **`flowchart`** or a\n * **`sequenceDiagram`** is drawn as an SVG diagram instead of a code block,\n * themed from the app's own CSS variables so dark mode needs no second\n * palette. The renderer is in-house: only flowchart layout is imported\n * (`graphre`, dagre in TypeScript, ~15.5 kB gzip), and the whole thing is\n * one lazy chunk pulled in only when a document actually contains a fence,\n * so a document with no diagram pays nothing.\n *\n * The flowchart subset is `flowchart TD|TB|LR|RL|BT`; the four node shapes\n * `[rect]` `(rounded)` `{diamond}` `((circle))`, with every other mermaid\n * bracket pair consumed and mapped onto them; edges `-->` `---` `-.->`\n * `==>` `<-->` with labels in both the `-->|text|` and `-- text -->` forms;\n * chains, `&` fans, `<br/>` line breaks and nested `subgraph`.\n *\n * The sequence subset is participants and actors, the eight arrow forms,\n * notes, `autonumber`, self-messages and the `alt` / `else` / `opt` /\n * `loop` fragment boxes. Activation bars are ignored. A wide sequence\n * diagram keeps its natural size in a scroll frame rather than shrinking\n * into the prose column.\n *\n * **Everything else degrades to the code block, silently.**\n * `classDiagram`, `gantt` and mindmaps are not drawn, `style` / `classDef`\n * are ignored, and a parse failure, a refused construct or a diagram past\n * its cap renders the plain fence rather than an error. Agents write\n * invalid mermaid, and a red box in the middle of a document is worse than\n * a grey fence. See `packages/@alepha/ui/DOC.md` for the full table.\n *\n * ## Spoilers\n *\n * `||text||` renders as a covered box that reveals on click, on Enter or on\n * Space, Discord's syntax and Discord's behaviour. Inline markdown inside it\n * survives, a code span or a fence keeps its pipes literally, and an\n * unterminated `||` renders as the two characters the author typed rather\n * than swallowing the rest of the paragraph.\n *\n * ⚠️ **It is not a security feature.** The text is in the DOM from the first\n * paint, in the raw markdown, in an export, over MCP and in any search\n * snippet. It hides a plot point from a reader's eye and nothing more.\n *\n * ## Raw HTML\n *\n * No raw HTML is ever rendered as markup: react-markdown's default is to\n * escape a raw node to text, and this component deliberately mounts no\n * plugin that changes that. A narrow `rehypeSafeImg` plugin used to promote\n * a lone `<img …>` — the one thing MDXEditor emitted for a *resized* image —\n * and was deleted along with the editor that produced it, since nothing\n * writes that markup anymore.\n *\n * Do not reach for `rehype-raw` to bring the capability back: this renders\n * content authored by one user to another, so every raw tag becoming live\n * markup turns every markdown surface in every app into an injection point.\n */\nexport const MarkdownView = (props: MarkdownViewProps) => {\n return (\n <div\n // `data-slot`, matching every other block here, so a host page can\n // reach the prose root without a wrapper class. Lore's folio\n // document uses it to make this inherit the reading size instead\n // of the `text-sm` default below.\n data-slot=\"markdown-view\"\n className={`max-w-none text-sm leading-relaxed ${props.className ?? \"\"}`}\n >\n <ReactMarkdown\n // ⚠️ `remarkSpoiler` runs AFTER `remarkGfm`, and the order is\n // load-bearing: by then a `| a | b |` row is a table with cells, so\n // the pipes are structure and the spoiler walk never sees them as\n // text. Reversed, every two-column table would be a spoiler.\n remarkPlugins={[remarkGfm, remarkSpoiler]}\n rehypePlugins={[\n // `plainText` claims the fence BEFORE highlighting runs: hljs would\n // otherwise tokenise the diagram source, and the fallback would be a\n // soup of spans instead of the text the author wrote.\n //\n // `ignoreMissing` is gone: it no longer exists in v7, where an\n // unknown language already produces a vfile message rather than a\n // throw.\n [rehypeHighlight, { detect: true, plainText: [\"mermaid\"] }],\n ]}\n components={{\n h1: ({ children }) => (\n <h1 className=\"mt-6 mb-3 text-2xl font-semibold tracking-tight\">\n {children}\n </h1>\n ),\n h2: ({ children }) => (\n <h2 className=\"mt-6 mb-2 text-xl font-semibold tracking-tight\">\n {children}\n </h2>\n ),\n h3: ({ children }) => (\n <h3 className=\"mt-4 mb-2 text-base font-semibold\">{children}</h3>\n ),\n p: ({ children }) => <p className=\"my-3\">{children}</p>,\n ul: ({ children }) => (\n <ul className=\"my-3 list-disc space-y-1 pl-5\">{children}</ul>\n ),\n ol: ({ children }) => (\n <ol className=\"my-3 list-decimal space-y-1 pl-5\">{children}</ol>\n ),\n li: ({ children }) => <li className=\"pl-1\">{children}</li>,\n a: ({ href, children }) => (\n <a\n href={href}\n className=\"text-primary decoration-primary/50 hover:decoration-primary underline underline-offset-4\"\n >\n {children}\n </a>\n ),\n code: ({ children, className }) => {\n const isBlock =\n className?.includes(\"language-\") || className?.includes(\"hljs\");\n if (isBlock) {\n return <code className={`${className} text-xs`}>{children}</code>;\n }\n return (\n <code className=\"bg-muted rounded px-1.5 py-0.5 font-mono text-[0.85em]\">\n {children}\n </code>\n );\n },\n pre: ({ children, node }) => {\n const block = (\n <pre className=\"border-border my-4 overflow-auto rounded-md border bg-transparent p-3 text-xs\">\n {children}\n </pre>\n );\n const source = mermaidSource(node);\n if (!source) return block;\n return (\n <DiagramErrorBoundary fallback={block}>\n {/*\n The loading state IS the code block: the fence is already on\n screen, and swapping it for the diagram when the chunk lands\n costs no spinner and no second layout.\n */}\n <Suspense fallback={block}>\n <MermaidFence source={source} fallback={block} />\n </Suspense>\n </DiagramErrorBoundary>\n );\n },\n // The only `<span>` this renderer ever produces is a spoiler's, and\n // the only thing that marks one is the `data-spoiler` property\n // `remarkSpoiler` puts there.\n //\n // ⚠️ The cast is not laziness: react-markdown types a span's props\n // as `HTMLAttributes<HTMLSpanElement>`, which PERMITS writing a\n // `data-*` attribute in JSX and does not declare one for reading.\n // The alternative - a custom `hName` with its own `components` key -\n // needs a cast into `components`, whose type is keyed on intrinsic\n // elements, so it buys nothing (the same note `mermaidSource`\n // already carries).\n span: ({ children, ...rest }) => {\n const marked = (rest as { \"data-spoiler\"?: unknown })[\n \"data-spoiler\"\n ];\n if (marked) return <SpoilerSpan>{children}</SpoilerSpan>;\n return <span {...rest}>{children}</span>;\n },\n blockquote: ({ children }) => (\n <blockquote className=\"border-muted-foreground/30 my-3 border-l-2 pl-4 italic\">\n {children}\n </blockquote>\n ),\n hr: () => <hr className=\"border-border my-6\" />,\n table: ({ children }) => (\n <table className=\"my-4 border-collapse text-xs\">{children}</table>\n ),\n th: ({ children }) => (\n <th className=\"border-border border px-2 py-1 text-left font-medium\">\n {children}\n </th>\n ),\n td: ({ children }) => (\n <td className=\"border-border border px-2 py-1\">{children}</td>\n ),\n }}\n >\n {props.content}\n </ReactMarkdown>\n </div>\n );\n};\n\n/**\n * The text of a ` ```mermaid ` fence, or `undefined` for every other `<pre>`.\n *\n * Reads the hast node rather than the rendered children because the source\n * has to arrive at the parser exactly as the author typed it, and walking React\n * children would mean reassembling it from whatever the renderer produced.\n *\n * The alternative wiring, a remark plugin, is more code for the same result:\n * `mdast-util-to-hast` applies `data.hName` to the `<code>` element BEFORE\n * wrapping it in `<pre>`, so renaming the code node still leaves the diagram\n * inside this bordered box. Going that way needs a custom node type and a\n * cast into `components`, whose type is keyed on intrinsic elements.\n */\nconst mermaidSource = (node: unknown): string | undefined => {\n const pre = node as\n | {\n children?: Array<{\n type?: string;\n tagName?: string;\n properties?: { className?: unknown };\n children?: Array<{ type?: string; value?: string }>;\n }>;\n }\n | undefined;\n const code = pre?.children?.[0];\n if (code?.type !== \"element\" || code.tagName !== \"code\") return undefined;\n\n const className = code.properties?.className;\n const names = Array.isArray(className)\n ? className.map(String)\n : typeof className === \"string\"\n ? className.split(/\\s+/)\n : [];\n if (!names.includes(\"language-mermaid\")) return undefined;\n\n const text = code.children\n ?.filter((child) => child.type === \"text\")\n .map((child) => child.value ?? \"\")\n .join(\"\");\n return text?.trim() ? text : undefined;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,eAAe,WAAW,OAAO,4BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEpE,MAAa,gBAAgB,UAA6B;CACxD,OACE,oBAAC,OAAD;EAKE,aAAU;EACV,WAAW,sCAAsC,MAAM,aAAa;EAEpE,UAAA,oBAAC,eAAD;GAKE,eAAe,CAAC,WAAW,aAAa;GACxC,eAAe,CAQb,CAAC,iBAAiB;IAAE,QAAQ;IAAM,WAAW,CAAC,SAAS;GAAE,CAAC,CAC5D;GACA,YAAY;IACV,KAAK,EAAE,eACL,oBAAC,MAAD;KAAI,WAAU;KACX;IACC,CAAA;IAEN,KAAK,EAAE,eACL,oBAAC,MAAD;KAAI,WAAU;KACX;IACC,CAAA;IAEN,KAAK,EAAE,eACL,oBAAC,MAAD;KAAI,WAAU;KAAqC;IAAa,CAAA;IAElE,IAAI,EAAE,eAAe,oBAAC,KAAD;KAAG,WAAU;KAAQ;IAAY,CAAA;IACtD,KAAK,EAAE,eACL,oBAAC,MAAD;KAAI,WAAU;KAAiC;IAAa,CAAA;IAE9D,KAAK,EAAE,eACL,oBAAC,MAAD;KAAI,WAAU;KAAoC;IAAa,CAAA;IAEjE,KAAK,EAAE,eAAe,oBAAC,MAAD;KAAI,WAAU;KAAQ;IAAa,CAAA;IACzD,IAAI,EAAE,MAAM,eACV,oBAAC,KAAD;KACQ;KACN,WAAU;KAET;IACA,CAAA;IAEL,OAAO,EAAE,UAAU,gBAAgB;KAGjC,IADE,WAAW,SAAS,WAAW,KAAK,WAAW,SAAS,MAAM,GAE9D,OAAO,oBAAC,QAAD;MAAM,WAAW,GAAG,UAAU;MAAY;KAA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G,OAAO,KAAA;CAEhD,MAAM,OAAO,KAAK,UACd,QAAQ,UAAU,MAAM,SAAS,MAAM,CAAC,CACzC,KAAK,UAAU,MAAM,SAAS,EAAE,CAAC,CACjC,KAAK,EAAE;CACV,OAAO,MAAM,KAAK,IAAI,OAAO,KAAA;AAC/B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The subset of a mdast node this walk touches.
|
|
3
|
+
*
|
|
4
|
+
* Declared here rather than imported from `mdast`: the plugin needs "has
|
|
5
|
+
* children" and "is a text node with a value", and nothing else. Taking the
|
|
6
|
+
* real union would pull `@types/mdast` into this package's direct types for a
|
|
7
|
+
* pair of structural checks.
|
|
8
|
+
*/
|
|
9
|
+
interface SpoilerNode {
|
|
10
|
+
type: string;
|
|
11
|
+
value?: string;
|
|
12
|
+
children?: SpoilerNode[];
|
|
13
|
+
data?: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export declare const remarkSpoiler: () => (tree: SpoilerNode) => void;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=remarkSpoiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remarkSpoiler.d.ts","sourceRoot":"","sources":["../../../src/components/markdown-view/remarkSpoiler.ts"],"names":[],"mappings":"AA2CA;;;;;;;GAOG;AACH,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,eAAO,MAAM,aAAa,eAAgB,WAAW,SAEpD,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
//#region src/components/markdown-view/remarkSpoiler.ts
|
|
2
|
+
/**
|
|
3
|
+
* Discord's `||spoiler||`, as a remark plugin.
|
|
4
|
+
*
|
|
5
|
+
* Rewrites every `||…||` pair in the tree into one node that
|
|
6
|
+
* `mdast-util-to-hast` renders as `<span data-spoiler="true">`, which
|
|
7
|
+
* `MarkdownView` then maps onto `SpoilerSpan`. Everything between the markers
|
|
8
|
+
* keeps its own markup: `||see [the docs](/d) **now**||` hides a link and a
|
|
9
|
+
* bold word, not the text of them.
|
|
10
|
+
*
|
|
11
|
+
* ## ⚠️ It has to span SIBLINGS, not split one text node
|
|
12
|
+
*
|
|
13
|
+
* The obvious version splits a text node on `/\|\|([\s\S]+?)\|\|/` and fails on
|
|
14
|
+
* exactly one case - markdown INSIDE the spoiler. Once emphasis has split the
|
|
15
|
+
* paragraph, the opening `||` and its closer live in different mdast siblings,
|
|
16
|
+
* so no regex over a single node can see both. This walk opens a collector on
|
|
17
|
+
* the first marker, pushes the following siblings into it, and closes on the
|
|
18
|
+
* next one.
|
|
19
|
+
*
|
|
20
|
+
* That shape is also what makes two things true for free rather than by a
|
|
21
|
+
* special case that could rot:
|
|
22
|
+
*
|
|
23
|
+
* - **`code` and `inlineCode` stay literal.** Both carry a `value` and no
|
|
24
|
+
* `children`, so a text walk cannot reach inside them. `` `||x||` `` and a
|
|
25
|
+
* fenced block are structurally out of range.
|
|
26
|
+
* - **A pair cannot cross a paragraph break.** Each parent's children are
|
|
27
|
+
* processed on their own, and the collector is discarded at the end of the
|
|
28
|
+
* list, so an unterminated `||` puts its literal text back and gives up.
|
|
29
|
+
*
|
|
30
|
+
* GFM table pipes are untouched for the same reason: by the time this runs,
|
|
31
|
+
* `remark-gfm` has already turned `| a | b |` into rows and cells, and the
|
|
32
|
+
* pipes are structure rather than text.
|
|
33
|
+
*
|
|
34
|
+
* ## ⚠️ It is not a security feature, and must never be presented as one
|
|
35
|
+
*
|
|
36
|
+
* The text sits in the DOM, in the raw markdown, in a folio export, in
|
|
37
|
+
* `folio_get` over MCP and in any search snippet. It hides a plot point from a
|
|
38
|
+
* reader's eye and nothing more.
|
|
39
|
+
*
|
|
40
|
+
* No new dependency: the walk is a plain recursion, so `unist-util-visit`
|
|
41
|
+
* never enters `package.json` and `check:deps` stays quiet.
|
|
42
|
+
*/
|
|
43
|
+
const MARKER = "||";
|
|
44
|
+
const remarkSpoiler = () => (tree) => {
|
|
45
|
+
walk(tree);
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Rewrite this node's children, then descend into whatever survives.
|
|
49
|
+
*/
|
|
50
|
+
const walk = (node) => {
|
|
51
|
+
if (!node.children) return;
|
|
52
|
+
node.children = rewrite(node.children);
|
|
53
|
+
for (const child of node.children) walk(child);
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* One sibling list, with every `||…||` pair folded into a spoiler node.
|
|
57
|
+
*/
|
|
58
|
+
const rewrite = (children) => {
|
|
59
|
+
if (!children.some((child) => child.type === "text" && child.value?.includes(MARKER))) return children;
|
|
60
|
+
const out = [];
|
|
61
|
+
let open;
|
|
62
|
+
const target = () => open ?? out;
|
|
63
|
+
const push = (child) => {
|
|
64
|
+
target().push(child);
|
|
65
|
+
};
|
|
66
|
+
const text = (value) => {
|
|
67
|
+
if (value) push({
|
|
68
|
+
type: "text",
|
|
69
|
+
value
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
const toggle = () => {
|
|
73
|
+
if (open) {
|
|
74
|
+
out.push(spoiler(open));
|
|
75
|
+
open = void 0;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
open = [];
|
|
79
|
+
};
|
|
80
|
+
for (const child of children) {
|
|
81
|
+
if (child.type !== "text" || !child.value?.includes(MARKER)) {
|
|
82
|
+
push(child);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const segments = child.value.split(MARKER);
|
|
86
|
+
text(segments[0]);
|
|
87
|
+
for (const segment of segments.slice(1)) {
|
|
88
|
+
toggle();
|
|
89
|
+
text(segment);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (open) out.push({
|
|
93
|
+
type: "text",
|
|
94
|
+
value: MARKER
|
|
95
|
+
}, ...open);
|
|
96
|
+
return out;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* One spoiler, as the node `mdast-util-to-hast` turns into a `<span>`.
|
|
100
|
+
*
|
|
101
|
+
* `hName` / `hProperties` are the documented way to place an element the
|
|
102
|
+
* markdown AST has no type for: the default unknown-node handler builds a
|
|
103
|
+
* `div` from the children and `applyData` then renames it and merges the
|
|
104
|
+
* properties, so nothing invalid is ever produced inside a paragraph.
|
|
105
|
+
*/
|
|
106
|
+
const spoiler = (children) => ({
|
|
107
|
+
type: "spoiler",
|
|
108
|
+
children,
|
|
109
|
+
data: {
|
|
110
|
+
hName: "span",
|
|
111
|
+
hProperties: { "data-spoiler": "true" }
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
//#endregion
|
|
115
|
+
export { remarkSpoiler };
|
|
116
|
+
|
|
117
|
+
//# sourceMappingURL=remarkSpoiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remarkSpoiler.js","names":[],"sources":["../../../src/components/markdown-view/remarkSpoiler.ts"],"sourcesContent":["/**\n * Discord's `||spoiler||`, as a remark plugin.\n *\n * Rewrites every `||…||` pair in the tree into one node that\n * `mdast-util-to-hast` renders as `<span data-spoiler=\"true\">`, which\n * `MarkdownView` then maps onto `SpoilerSpan`. Everything between the markers\n * keeps its own markup: `||see [the docs](/d) **now**||` hides a link and a\n * bold word, not the text of them.\n *\n * ## ⚠️ It has to span SIBLINGS, not split one text node\n *\n * The obvious version splits a text node on `/\\|\\|([\\s\\S]+?)\\|\\|/` and fails on\n * exactly one case - markdown INSIDE the spoiler. Once emphasis has split the\n * paragraph, the opening `||` and its closer live in different mdast siblings,\n * so no regex over a single node can see both. This walk opens a collector on\n * the first marker, pushes the following siblings into it, and closes on the\n * next one.\n *\n * That shape is also what makes two things true for free rather than by a\n * special case that could rot:\n *\n * - **`code` and `inlineCode` stay literal.** Both carry a `value` and no\n * `children`, so a text walk cannot reach inside them. `` `||x||` `` and a\n * fenced block are structurally out of range.\n * - **A pair cannot cross a paragraph break.** Each parent's children are\n * processed on their own, and the collector is discarded at the end of the\n * list, so an unterminated `||` puts its literal text back and gives up.\n *\n * GFM table pipes are untouched for the same reason: by the time this runs,\n * `remark-gfm` has already turned `| a | b |` into rows and cells, and the\n * pipes are structure rather than text.\n *\n * ## ⚠️ It is not a security feature, and must never be presented as one\n *\n * The text sits in the DOM, in the raw markdown, in a folio export, in\n * `folio_get` over MCP and in any search snippet. It hides a plot point from a\n * reader's eye and nothing more.\n *\n * No new dependency: the walk is a plain recursion, so `unist-util-visit`\n * never enters `package.json` and `check:deps` stays quiet.\n */\nconst MARKER = \"||\";\n\n/**\n * The subset of a mdast node this walk touches.\n *\n * Declared here rather than imported from `mdast`: the plugin needs \"has\n * children\" and \"is a text node with a value\", and nothing else. Taking the\n * real union would pull `@types/mdast` into this package's direct types for a\n * pair of structural checks.\n */\ninterface SpoilerNode {\n type: string;\n value?: string;\n children?: SpoilerNode[];\n data?: Record<string, unknown>;\n}\n\nexport const remarkSpoiler = () => (tree: SpoilerNode) => {\n walk(tree);\n};\n\n/**\n * Rewrite this node's children, then descend into whatever survives.\n */\nconst walk = (node: SpoilerNode): void => {\n if (!node.children) return;\n node.children = rewrite(node.children);\n for (const child of node.children) {\n walk(child);\n }\n};\n\n/**\n * One sibling list, with every `||…||` pair folded into a spoiler node.\n */\nconst rewrite = (children: SpoilerNode[]): SpoilerNode[] => {\n // Nothing to do unless a marker is actually present at this level. The\n // common case is every paragraph in every document, so it is worth the\n // scan: without it, each one is rebuilt into a new array for nothing.\n if (\n !children.some(\n (child) => child.type === \"text\" && child.value?.includes(MARKER),\n )\n ) {\n return children;\n }\n\n const out: SpoilerNode[] = [];\n let open: SpoilerNode[] | undefined;\n const target = () => open ?? out;\n\n const push = (child: SpoilerNode) => {\n target().push(child);\n };\n\n const text = (value: string) => {\n if (value) push({ type: \"text\", value });\n };\n\n const toggle = () => {\n if (open) {\n out.push(spoiler(open));\n open = undefined;\n return;\n }\n open = [];\n };\n\n for (const child of children) {\n if (child.type !== \"text\" || !child.value?.includes(MARKER)) {\n push(child);\n continue;\n }\n\n // `split` gives one more segment than there are markers, so segment 0 is\n // whatever preceded the first one and every later segment is preceded by\n // a toggle.\n const segments = child.value.split(MARKER);\n text(segments[0]!);\n for (const segment of segments.slice(1)) {\n toggle();\n text(segment);\n }\n }\n\n if (open) {\n // Unterminated: the marker was never a spoiler, so it goes back as the\n // two characters the author typed, followed by everything that had been\n // collected behind it. Swallowing the rest of the paragraph instead is\n // what a lazy regex does, and it is the failure a reader cannot explain.\n out.push({ type: \"text\", value: MARKER }, ...open);\n }\n\n return out;\n};\n\n/**\n * One spoiler, as the node `mdast-util-to-hast` turns into a `<span>`.\n *\n * `hName` / `hProperties` are the documented way to place an element the\n * markdown AST has no type for: the default unknown-node handler builds a\n * `div` from the children and `applyData` then renames it and merges the\n * properties, so nothing invalid is ever produced inside a paragraph.\n */\nconst spoiler = (children: SpoilerNode[]): SpoilerNode => ({\n type: \"spoiler\",\n children,\n data: { hName: \"span\", hProperties: { \"data-spoiler\": \"true\" } },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAM,SAAS;AAiBf,MAAa,uBAAuB,SAAsB;CACxD,KAAK,IAAI;AACX;;;;AAKA,MAAM,QAAQ,SAA4B;CACxC,IAAI,CAAC,KAAK,UAAU;CACpB,KAAK,WAAW,QAAQ,KAAK,QAAQ;CACrC,KAAK,MAAM,SAAS,KAAK,UACvB,KAAK,KAAK;AAEd;;;;AAKA,MAAM,WAAW,aAA2C;CAI1D,IACE,CAAC,SAAS,MACP,UAAU,MAAM,SAAS,UAAU,MAAM,OAAO,SAAS,MAAM,CAClE,GAEA,OAAO;CAGT,MAAM,MAAqB,CAAC;CAC5B,IAAI;CACJ,MAAM,eAAe,QAAQ;CAE7B,MAAM,QAAQ,UAAuB;EACnC,OAAO,CAAC,CAAC,KAAK,KAAK;CACrB;CAEA,MAAM,QAAQ,UAAkB;EAC9B,IAAI,OAAO,KAAK;GAAE,MAAM;GAAQ;EAAM,CAAC;CACzC;CAEA,MAAM,eAAe;EACnB,IAAI,MAAM;GACR,IAAI,KAAK,QAAQ,IAAI,CAAC;GACtB,OAAO,KAAA;GACP;EACF;EACA,OAAO,CAAC;CACV;CAEA,KAAK,MAAM,SAAS,UAAU;EAC5B,IAAI,MAAM,SAAS,UAAU,CAAC,MAAM,OAAO,SAAS,MAAM,GAAG;GAC3D,KAAK,KAAK;GACV;EACF;EAKA,MAAM,WAAW,MAAM,MAAM,MAAM,MAAM;EACzC,KAAK,SAAS,EAAG;EACjB,KAAK,MAAM,WAAW,SAAS,MAAM,CAAC,GAAG;GACvC,OAAO;GACP,KAAK,OAAO;EACd;CACF;CAEA,IAAI,MAKF,IAAI,KAAK;EAAE,MAAM;EAAQ,OAAO;CAAO,GAAG,GAAG,IAAI;CAGnD,OAAO;AACT;;;;;;;;;AAUA,MAAM,WAAW,cAA0C;CACzD,MAAM;CACN;CACA,MAAM;EAAE,OAAO;EAAQ,aAAa,EAAE,gBAAgB,OAAO;CAAE;AACjE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { PermissionMatrixColumn, PermissionMatrixGroup, PermissionMatrixRow } from "./permission-matrix.tsx";
|
|
2
|
+
export interface PermissionMatrixGroupRowsProps {
|
|
3
|
+
group: PermissionMatrixGroup;
|
|
4
|
+
columns: PermissionMatrixColumn[];
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
granted: (columnKey: string, permission: string) => boolean;
|
|
7
|
+
toggle: (columnKey: string, permission: string, next: boolean) => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* One group's heading row and the permission rows under it.
|
|
11
|
+
*
|
|
12
|
+
* Its own component rather than a loop body inside {@link PermissionMatrix}
|
|
13
|
+
* so the heading's `colSpan` is computed in one place: it has to span the
|
|
14
|
+
* permission column plus every rank, and a heading that stops short of the
|
|
15
|
+
* last column reads as a table with a missing cell.
|
|
16
|
+
*/
|
|
17
|
+
export declare const PermissionMatrixGroupRows: (props: PermissionMatrixGroupRowsProps) => import("react").JSX.Element;
|
|
18
|
+
export interface PermissionMatrixRowLabelProps {
|
|
19
|
+
permission: PermissionMatrixRow;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Whether one cell reads checked.
|
|
23
|
+
*
|
|
24
|
+
* Shared with {@link PermissionMatrix}, which needs the same answer for every
|
|
25
|
+
* cell in a column to size that column's coverage bar. Deriving it twice is
|
|
26
|
+
* how a bar comes to disagree with the boxes above it.
|
|
27
|
+
*
|
|
28
|
+
* ⚠️ A read-only column beats a locked row, in both directions. The ceiling
|
|
29
|
+
* says what may be GRANTED to a rank; the column that is granted nothing - an
|
|
30
|
+
* owner - is not narrowed by it, and showing that column half-ticked would say
|
|
31
|
+
* the opposite of what it means.
|
|
32
|
+
*/
|
|
33
|
+
export declare const permissionChecked: (column: PermissionMatrixColumn, permission: PermissionMatrixRow, granted: (columnKey: string, permission: string) => boolean) => boolean;
|
|
34
|
+
//# sourceMappingURL=permission-matrix-group-rows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission-matrix-group-rows.d.ts","sourceRoot":"","sources":["../../../src/components/permission-matrix/permission-matrix-group-rows.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,8BAA8B;IAC7C,KAAK,EAAE,qBAAqB,CAAC;IAE7B,OAAO,EAAE,sBAAsB,EAAE,CAAC;IAElC,QAAQ,EAAE,OAAO,CAAC;IAElB,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IAE5D,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACxE;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,UAC7B,8BAA8B,gCA+ItC,CAAC;AAEF,MAAM,WAAW,6BAA6B;IAC5C,UAAU,EAAE,mBAAmB,CAAC;CACjC;AAgCD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,WACpB,sBAAsB,cAClB,mBAAmB,WACtB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,KAC1D,OAO2C,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { cn } from "../../lib/utils.js";
|
|
2
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip.js";
|
|
3
|
+
import { Checkbox } from "../ui/checkbox.js";
|
|
4
|
+
import { TableCell, TableRow } from "../ui/table.js";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Lock } from "lucide-react";
|
|
7
|
+
//#region src/components/permission-matrix/permission-matrix-group-rows.tsx
|
|
8
|
+
/**
|
|
9
|
+
* One group's heading row and the permission rows under it.
|
|
10
|
+
*
|
|
11
|
+
* Its own component rather than a loop body inside {@link PermissionMatrix}
|
|
12
|
+
* so the heading's `colSpan` is computed in one place: it has to span the
|
|
13
|
+
* permission column plus every rank, and a heading that stops short of the
|
|
14
|
+
* last column reads as a table with a missing cell.
|
|
15
|
+
*/
|
|
16
|
+
const PermissionMatrixGroupRows = (props) => {
|
|
17
|
+
const Icon = props.group.icon;
|
|
18
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(TableRow, {
|
|
19
|
+
className: "hover:bg-transparent",
|
|
20
|
+
children: /* @__PURE__ */ jsx(TableCell, {
|
|
21
|
+
colSpan: props.columns.length + 1,
|
|
22
|
+
className: "bg-muted text-muted-foreground py-1.5 text-xs font-medium tracking-wide uppercase shadow-[inset_0_1px_0_0_var(--bevel)]",
|
|
23
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
24
|
+
className: "flex items-center gap-2",
|
|
25
|
+
children: [
|
|
26
|
+
Icon ? /* @__PURE__ */ jsx(Icon, {
|
|
27
|
+
className: "size-3.5 shrink-0",
|
|
28
|
+
"aria-hidden": true
|
|
29
|
+
}) : null,
|
|
30
|
+
props.group.label,
|
|
31
|
+
/* @__PURE__ */ jsx("span", {
|
|
32
|
+
className: "text-muted-foreground/70 font-mono text-[11px] font-normal",
|
|
33
|
+
children: props.group.permissions.length
|
|
34
|
+
})
|
|
35
|
+
]
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
}), props.group.permissions.map((permission) => /* @__PURE__ */ jsxs(TableRow, { children: [/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsxs("div", {
|
|
39
|
+
className: "flex flex-col gap-0.5",
|
|
40
|
+
children: [/* @__PURE__ */ jsx(PermissionMatrixRowLabel, { permission }), /* @__PURE__ */ jsx("code", {
|
|
41
|
+
className: "text-muted-foreground font-mono text-[11px]",
|
|
42
|
+
children: permission.name
|
|
43
|
+
})]
|
|
44
|
+
}) }), props.columns.map((column) => {
|
|
45
|
+
const checked = permissionChecked(column, permission, props.granted);
|
|
46
|
+
const locked = props.disabled || column.readOnly === true || !!permission.lock;
|
|
47
|
+
const closed = locked && !checked;
|
|
48
|
+
const box = /* @__PURE__ */ jsx(Checkbox, {
|
|
49
|
+
checked,
|
|
50
|
+
disabled: locked,
|
|
51
|
+
className: cn("mx-auto size-5 [&_svg]:size-4!", !closed && "data-disabled:opacity-50"),
|
|
52
|
+
"aria-label": permission.name,
|
|
53
|
+
onCheckedChange: (next) => props.toggle(column.key, permission.name, next === true)
|
|
54
|
+
});
|
|
55
|
+
return /* @__PURE__ */ jsx(TableCell, {
|
|
56
|
+
className: "border-border/60 border-l pr-2! text-center",
|
|
57
|
+
children: closed ? /* @__PURE__ */ jsxs("span", {
|
|
58
|
+
"data-slot": "permission-locked",
|
|
59
|
+
className: "relative mx-auto flex size-5 items-center justify-center",
|
|
60
|
+
children: [box, /* @__PURE__ */ jsx(Lock, {
|
|
61
|
+
"aria-hidden": true,
|
|
62
|
+
className: "text-muted-foreground pointer-events-none absolute size-3"
|
|
63
|
+
})]
|
|
64
|
+
}) : box
|
|
65
|
+
}, column.key);
|
|
66
|
+
})] }, permission.name))] });
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* A permission's label, carrying its `description` as a tooltip.
|
|
70
|
+
*
|
|
71
|
+
* A tooltip rather than a second line, because the mono permission name now
|
|
72
|
+
* owns that line and a third one turns a dense table into a loose one.
|
|
73
|
+
*
|
|
74
|
+
* The trigger is Base UI's default (a button) with a dotted underline rather
|
|
75
|
+
* than a bare `<span>`: a span is not focusable, so a description hung on one
|
|
76
|
+
* is reachable with a mouse and by nothing else. The underline is what keeps
|
|
77
|
+
* a focusable element from reading as an action - it is the abbreviation
|
|
78
|
+
* affordance, "there is more to know here", not "this does something".
|
|
79
|
+
*
|
|
80
|
+
* Needs a `TooltipProvider` above it, like every other tooltip in this
|
|
81
|
+
* package; `apps/ui` and `apps/lore` both mount one in their layout.
|
|
82
|
+
*/
|
|
83
|
+
const PermissionMatrixRowLabel = (props) => {
|
|
84
|
+
if (!props.permission.description) return /* @__PURE__ */ jsx("span", {
|
|
85
|
+
className: "text-sm",
|
|
86
|
+
children: props.permission.label
|
|
87
|
+
});
|
|
88
|
+
return /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
89
|
+
className: "decoration-muted-foreground/60 w-fit cursor-default text-left text-sm underline decoration-dotted underline-offset-4",
|
|
90
|
+
children: props.permission.label
|
|
91
|
+
}), /* @__PURE__ */ jsx(TooltipContent, { children: props.permission.description })] });
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Whether one cell reads checked.
|
|
95
|
+
*
|
|
96
|
+
* Shared with {@link PermissionMatrix}, which needs the same answer for every
|
|
97
|
+
* cell in a column to size that column's coverage bar. Deriving it twice is
|
|
98
|
+
* how a bar comes to disagree with the boxes above it.
|
|
99
|
+
*
|
|
100
|
+
* ⚠️ A read-only column beats a locked row, in both directions. The ceiling
|
|
101
|
+
* says what may be GRANTED to a rank; the column that is granted nothing - an
|
|
102
|
+
* owner - is not narrowed by it, and showing that column half-ticked would say
|
|
103
|
+
* the opposite of what it means.
|
|
104
|
+
*/
|
|
105
|
+
const permissionChecked = (column, permission, granted) => column.readOnly ? true : permission.lock === "on" ? true : permission.lock === "off" ? false : granted(column.key, permission.name);
|
|
106
|
+
//#endregion
|
|
107
|
+
export { PermissionMatrixGroupRows, permissionChecked };
|
|
108
|
+
|
|
109
|
+
//# sourceMappingURL=permission-matrix-group-rows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission-matrix-group-rows.js","names":[],"sources":["../../../src/components/permission-matrix/permission-matrix-group-rows.tsx"],"sourcesContent":["import { Checkbox } from \"@alepha/ui/components/ui/checkbox\";\nimport { TableCell, TableRow } from \"@alepha/ui/components/ui/table\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"@alepha/ui/components/ui/tooltip\";\nimport { cn } from \"@alepha/ui/lib/utils\";\nimport { Lock } from \"lucide-react\";\n\nimport type {\n PermissionMatrixColumn,\n PermissionMatrixGroup,\n PermissionMatrixRow,\n} from \"./permission-matrix.tsx\";\n\nexport interface PermissionMatrixGroupRowsProps {\n group: PermissionMatrixGroup;\n\n columns: PermissionMatrixColumn[];\n\n disabled: boolean;\n\n granted: (columnKey: string, permission: string) => boolean;\n\n toggle: (columnKey: string, permission: string, next: boolean) => void;\n}\n\n/**\n * One group's heading row and the permission rows under it.\n *\n * Its own component rather than a loop body inside {@link PermissionMatrix}\n * so the heading's `colSpan` is computed in one place: it has to span the\n * permission column plus every rank, and a heading that stops short of the\n * last column reads as a table with a missing cell.\n */\nexport const PermissionMatrixGroupRows = (\n props: PermissionMatrixGroupRowsProps,\n) => {\n const Icon = props.group.icon;\n\n return (\n <>\n {/* The heading is chrome, so it wears the chrome surface: `bg-muted`\n under a `--bevel` line, the pair the table header and `PlateTabBar`\n already use. Opaque rather than the `/40` it carried before, because\n a band that is nearly the row colour reads as a row with odd text\n rather than as a divider between two sets of rows. */}\n <TableRow className=\"hover:bg-transparent\">\n <TableCell\n colSpan={props.columns.length + 1}\n className=\"bg-muted text-muted-foreground py-1.5 text-xs font-medium tracking-wide uppercase shadow-[inset_0_1px_0_0_var(--bevel)]\"\n >\n <div className=\"flex items-center gap-2\">\n {Icon ? <Icon className=\"size-3.5 shrink-0\" aria-hidden /> : null}\n {props.group.label}\n {/* Derived, not a prop: it is the length of the array the caller\n already passed, and a count that could disagree with the rows\n under it is worse than no count. */}\n <span className=\"text-muted-foreground/70 font-mono text-[11px] font-normal\">\n {props.group.permissions.length}\n </span>\n </div>\n </TableCell>\n </TableRow>\n {props.group.permissions.map((permission) => (\n <TableRow key={permission.name}>\n <TableCell>\n <div className=\"flex flex-col gap-0.5\">\n <PermissionMatrixRowLabel permission={permission} />\n {/* The stored name, under the label, in mono. It is what the\n row actually grants and what a reader has to match against\n an API response or a rank's saved set, so it is worth a line\n rather than being knowable only from the DOM. */}\n <code className=\"text-muted-foreground font-mono text-[11px]\">\n {permission.name}\n </code>\n </div>\n </TableCell>\n {props.columns.map((column) => {\n const checked = permissionChecked(\n column,\n permission,\n props.granted,\n );\n\n const locked =\n props.disabled || column.readOnly === true || !!permission.lock;\n\n // A crossing that is closed rather than merely empty. An unchecked\n // box that cannot be ticked is an invitation to try; a padlock\n // inside it says the answer is settled.\n const closed = locked && !checked;\n\n const box = (\n <Checkbox\n checked={checked}\n disabled={locked}\n // ⚠️ `data-disabled`, not `disabled`. The primitive already\n // carries `disabled:opacity-50`, but Base UI renders the box\n // as a `<span data-disabled>` and puts the real `disabled` on\n // a hidden input, so that variant only ever fires for a\n // checkbox inside a `field-label` group. Standalone - which is\n // every cell here - a locked box looked exactly like an\n // editable one, and the owner column read as if someone had\n // ticked all of it by hand.\n //\n // Fixed here rather than in `components/ui/checkbox.tsx`,\n // which `yarn w @alepha/ui sync` overwrites wholesale. The\n // durable package-wide home is `styles.css`, but that is a\n // change to every checkbox in every app and not this\n // component's call to make.\n //\n // `mx-auto` because the cell's `text-center` does not reach\n // it: Base UI renders the box as a `display:flex` element,\n // which is a block-level box and ignores the inline centring a\n // `<td>` hands down. It sat left of centre in every column.\n //\n // `size-5` over the primitive's `size-4`: this table is a grid\n // of nothing but checkboxes, so they are the content rather\n // than an adornment beside a label. The tick is pushed with it\n // - `!` because the primitive sets it on the indicator at the\n // same specificity, and same-specificity rules are settled by\n // CSS source order, which is not a thing to bet on.\n className={cn(\n \"mx-auto size-5 [&_svg]:size-4!\",\n // Not on a closed cell: there the padlock carries the\n // meaning, and fading the square with it makes a 20px box\n // look smaller than the 20px box beside it.\n !closed && \"data-disabled:opacity-50\",\n )}\n // The stored name, not the label: a screen reader hears the\n // permission this cell actually grants, and a test can find\n // one cell out of a hundred without depending on copy.\n aria-label={permission.name}\n onCheckedChange={(next) =>\n props.toggle(column.key, permission.name, next === true)\n }\n />\n );\n\n return (\n <TableCell\n key={column.key}\n className=\"border-border/60 border-l pr-2! text-center\"\n >\n {closed ? (\n // The real checkbox underneath, with the padlock laid over\n // it, rather than a lock-shaped thing of its own: the box,\n // its border, its radius and its dark-mode fill stay the\n // primitive's and cannot drift from the cell beside it. It\n // also keeps the cell a labelled checkbox for a screen\n // reader instead of an unlabelled picture.\n <span\n data-slot=\"permission-locked\"\n className=\"relative mx-auto flex size-5 items-center justify-center\"\n >\n {box}\n {/* The GLYPH is muted, not the square. Fading the whole\n thing halved the border too, and a 1px border at half\n strength beside a full-strength one reads as a smaller\n box - the two are the same 20px, but they do not look\n it. The padlock already says the cell is closed, so the\n fade was saying it twice and lying about the size to do\n it. */}\n <Lock\n aria-hidden\n className=\"text-muted-foreground pointer-events-none absolute size-3\"\n />\n </span>\n ) : (\n box\n )}\n </TableCell>\n );\n })}\n </TableRow>\n ))}\n </>\n );\n};\n\nexport interface PermissionMatrixRowLabelProps {\n permission: PermissionMatrixRow;\n}\n\n/**\n * A permission's label, carrying its `description` as a tooltip.\n *\n * A tooltip rather than a second line, because the mono permission name now\n * owns that line and a third one turns a dense table into a loose one.\n *\n * The trigger is Base UI's default (a button) with a dotted underline rather\n * than a bare `<span>`: a span is not focusable, so a description hung on one\n * is reachable with a mouse and by nothing else. The underline is what keeps\n * a focusable element from reading as an action - it is the abbreviation\n * affordance, \"there is more to know here\", not \"this does something\".\n *\n * Needs a `TooltipProvider` above it, like every other tooltip in this\n * package; `apps/ui` and `apps/lore` both mount one in their layout.\n */\nconst PermissionMatrixRowLabel = (props: PermissionMatrixRowLabelProps) => {\n if (!props.permission.description) {\n return <span className=\"text-sm\">{props.permission.label}</span>;\n }\n\n return (\n <Tooltip>\n <TooltipTrigger className=\"decoration-muted-foreground/60 w-fit cursor-default text-left text-sm underline decoration-dotted underline-offset-4\">\n {props.permission.label}\n </TooltipTrigger>\n <TooltipContent>{props.permission.description}</TooltipContent>\n </Tooltip>\n );\n};\n\n/**\n * Whether one cell reads checked.\n *\n * Shared with {@link PermissionMatrix}, which needs the same answer for every\n * cell in a column to size that column's coverage bar. Deriving it twice is\n * how a bar comes to disagree with the boxes above it.\n *\n * ⚠️ A read-only column beats a locked row, in both directions. The ceiling\n * says what may be GRANTED to a rank; the column that is granted nothing - an\n * owner - is not narrowed by it, and showing that column half-ticked would say\n * the opposite of what it means.\n */\nexport const permissionChecked = (\n column: PermissionMatrixColumn,\n permission: PermissionMatrixRow,\n granted: (columnKey: string, permission: string) => boolean,\n): boolean =>\n column.readOnly\n ? true\n : permission.lock === \"on\"\n ? true\n : permission.lock === \"off\"\n ? false\n : granted(column.key, permission.name);\n"],"mappings":";;;;;;;;;;;;;;;AAoCA,MAAa,6BACX,UACG;CACH,MAAM,OAAO,MAAM,MAAM;CAEzB,OACE,qBAAA,UAAA,EAAA,UAAA,CAME,oBAAC,UA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