@alepha/ui 0.28.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -2
- package/dist/components/account/account-connections.d.ts.map +1 -1
- package/dist/components/account/account-connections.js +4 -1
- package/dist/components/account/account-connections.js.map +1 -1
- package/dist/components/account/account-delete-dialog.d.ts.map +1 -1
- package/dist/components/account/account-delete-dialog.js +12 -15
- package/dist/components/account/account-delete-dialog.js.map +1 -1
- package/dist/components/account/account-keys.d.ts.map +1 -1
- package/dist/components/account/account-keys.js +22 -28
- package/dist/components/account/account-keys.js.map +1 -1
- package/dist/components/account/account-mfa-dialog.js +1 -4
- package/dist/components/account/account-mfa-dialog.js.map +1 -1
- package/dist/components/account/account-password-dialog.d.ts.map +1 -1
- package/dist/components/account/account-password-dialog.js +11 -14
- package/dist/components/account/account-password-dialog.js.map +1 -1
- package/dist/components/account/account-profile.js +3 -2
- package/dist/components/account/account-profile.js.map +1 -1
- package/dist/components/account/account-router-options.d.ts +38 -0
- package/dist/components/account/account-router-options.d.ts.map +1 -1
- package/dist/components/account/account-router-options.js.map +1 -1
- package/dist/components/account/account-router-page.d.ts +11 -1
- package/dist/components/account/account-router-page.d.ts.map +1 -1
- package/dist/components/account/account-router-page.js +11 -1
- package/dist/components/account/account-router-page.js.map +1 -1
- package/dist/components/account/account-router.d.ts +11 -0
- package/dist/components/account/account-router.d.ts.map +1 -1
- package/dist/components/account/account-router.js +16 -5
- package/dist/components/account/account-router.js.map +1 -1
- package/dist/components/admin/admin-audits.d.ts.map +1 -1
- package/dist/components/admin/admin-audits.js +91 -34
- package/dist/components/admin/admin-audits.js.map +1 -1
- package/dist/components/admin/admin-files.d.ts.map +1 -1
- package/dist/components/admin/admin-files.js +6 -17
- package/dist/components/admin/admin-files.js.map +1 -1
- package/dist/components/admin/admin-jobs-executions-panel.d.ts.map +1 -1
- package/dist/components/admin/admin-jobs-executions-panel.js +39 -8
- package/dist/components/admin/admin-jobs-executions-panel.js.map +1 -1
- package/dist/components/admin/admin-jobs-payload-dialog.d.ts +19 -0
- package/dist/components/admin/admin-jobs-payload-dialog.d.ts.map +1 -0
- package/dist/components/admin/admin-jobs-payload-dialog.js +33 -0
- package/dist/components/admin/admin-jobs-payload-dialog.js.map +1 -0
- package/dist/components/admin/admin-keys.d.ts.map +1 -1
- package/dist/components/admin/admin-keys.js +5 -4
- package/dist/components/admin/admin-keys.js.map +1 -1
- package/dist/components/admin/admin-notifications-channel-label.d.ts +14 -0
- package/dist/components/admin/admin-notifications-channel-label.d.ts.map +1 -0
- package/dist/components/admin/admin-notifications-channel-label.js +26 -0
- package/dist/components/admin/admin-notifications-channel-label.js.map +1 -0
- package/dist/components/admin/admin-notifications-preview-body.d.ts.map +1 -1
- package/dist/components/admin/admin-notifications-preview-body.js +23 -13
- package/dist/components/admin/admin-notifications-preview-body.js.map +1 -1
- package/dist/components/admin/admin-notifications.d.ts.map +1 -1
- package/dist/components/admin/admin-notifications.js +11 -12
- package/dist/components/admin/admin-notifications.js.map +1 -1
- package/dist/components/admin/admin-payments.d.ts.map +1 -1
- package/dist/components/admin/admin-payments.js +9 -7
- package/dist/components/admin/admin-payments.js.map +1 -1
- package/dist/components/admin/admin-router-options.d.ts +12 -0
- package/dist/components/admin/admin-router-options.d.ts.map +1 -1
- package/dist/components/admin/admin-router-options.js.map +1 -1
- package/dist/components/admin/admin-router.d.ts +5 -8
- package/dist/components/admin/admin-router.d.ts.map +1 -1
- package/dist/components/admin/admin-router.js +6 -29
- package/dist/components/admin/admin-router.js.map +1 -1
- package/dist/components/admin/admin-sessions.d.ts.map +1 -1
- package/dist/components/admin/admin-sessions.js +9 -7
- package/dist/components/admin/admin-sessions.js.map +1 -1
- package/dist/components/admin/admin-user-detail-audits-tab.d.ts.map +1 -1
- package/dist/components/admin/admin-user-detail-audits-tab.js +5 -4
- package/dist/components/admin/admin-user-detail-audits-tab.js.map +1 -1
- package/dist/components/admin/admin-user-detail-sessions-tab.d.ts.map +1 -1
- package/dist/components/admin/admin-user-detail-sessions-tab.js +7 -5
- package/dist/components/admin/admin-user-detail-sessions-tab.js.map +1 -1
- package/dist/components/admin/admin-user-detail.js +3 -2
- package/dist/components/admin/admin-user-detail.js.map +1 -1
- package/dist/components/admin/admin-users-roles-picker.d.ts.map +1 -1
- package/dist/components/admin/admin-users-roles-picker.js.map +1 -1
- package/dist/components/admin/admin-users.d.ts.map +1 -1
- package/dist/components/admin/admin-users.js +6 -4
- package/dist/components/admin/admin-users.js.map +1 -1
- package/dist/components/admin/analytics/AnalyticsChartBars.js +2 -1
- package/dist/components/admin/analytics/AnalyticsChartBars.js.map +1 -1
- package/dist/components/admin/parameter-history-item.d.ts.map +1 -1
- package/dist/components/admin/parameter-history-item.js +3 -2
- package/dist/components/admin/parameter-history-item.js.map +1 -1
- package/dist/components/alepha-table/alepha-table-bulk-menu.js +2 -1
- package/dist/components/alepha-table/alepha-table-bulk-menu.js.map +1 -1
- package/dist/components/alepha-table/alepha-table-filter-dialog.d.ts +60 -0
- package/dist/components/alepha-table/alepha-table-filter-dialog.d.ts.map +1 -0
- package/dist/components/alepha-table/alepha-table-filter-dialog.js +88 -0
- package/dist/components/alepha-table/alepha-table-filter-dialog.js.map +1 -0
- package/dist/components/alepha-table/alepha-table-filter-menu.d.ts +35 -0
- package/dist/components/alepha-table/alepha-table-filter-menu.d.ts.map +1 -0
- package/dist/components/alepha-table/alepha-table-filter-menu.js +54 -0
- package/dist/components/alepha-table/alepha-table-filter-menu.js.map +1 -0
- package/dist/components/alepha-table/alepha-table.d.ts +188 -3
- package/dist/components/alepha-table/alepha-table.d.ts.map +1 -1
- package/dist/components/alepha-table/alepha-table.js +551 -162
- package/dist/components/alepha-table/alepha-table.js.map +1 -1
- package/dist/components/alepha-table/query-filters.d.ts +73 -0
- package/dist/components/alepha-table/query-filters.d.ts.map +1 -0
- package/dist/components/alepha-table/query-filters.js +118 -0
- package/dist/components/alepha-table/query-filters.js.map +1 -0
- package/dist/components/app-actions/app-actions.d.ts +21 -0
- package/dist/components/app-actions/app-actions.d.ts.map +1 -1
- package/dist/components/app-actions/app-actions.js +11 -5
- package/dist/components/app-actions/app-actions.js.map +1 -1
- package/dist/components/app-shell/app-shell.d.ts +45 -0
- package/dist/components/app-shell/app-shell.d.ts.map +1 -1
- package/dist/components/app-shell/app-shell.js +119 -16
- package/dist/components/app-shell/app-shell.js.map +1 -1
- package/dist/components/auth/auth-register.js +31 -30
- package/dist/components/auth/auth-register.js.map +1 -1
- package/dist/components/auto-form/auto-form.d.ts.map +1 -1
- package/dist/components/auto-form/auto-form.js +68 -30
- package/dist/components/auto-form/auto-form.js.map +1 -1
- package/dist/components/button-dark/button-dark.d.ts.map +1 -1
- package/dist/components/button-dark/button-dark.js +39 -8
- package/dist/components/button-dark/button-dark.js.map +1 -1
- package/dist/components/button-inbox/button-inbox.d.ts +66 -0
- package/dist/components/button-inbox/button-inbox.d.ts.map +1 -0
- package/dist/components/button-inbox/button-inbox.js +167 -0
- package/dist/components/button-inbox/button-inbox.js.map +1 -0
- package/dist/components/button-inbox/inbox-unread-atom.d.ts +22 -0
- package/dist/components/button-inbox/inbox-unread-atom.d.ts.map +1 -0
- package/dist/components/button-inbox/inbox-unread-atom.js +29 -0
- package/dist/components/button-inbox/inbox-unread-atom.js.map +1 -0
- package/dist/components/button-theme/button-theme.d.ts +4 -3
- package/dist/components/button-theme/button-theme.d.ts.map +1 -1
- package/dist/components/button-theme/button-theme.js +8 -25
- package/dist/components/button-theme/button-theme.js.map +1 -1
- package/dist/components/button-user/button-user.d.ts +19 -0
- package/dist/components/button-user/button-user.d.ts.map +1 -1
- package/dist/components/button-user/button-user.js +1 -1
- package/dist/components/button-user/button-user.js.map +1 -1
- package/dist/components/control/control.d.ts +51 -0
- package/dist/components/control/control.d.ts.map +1 -1
- package/dist/components/control/control.js +49 -5
- package/dist/components/control/control.js.map +1 -1
- package/dist/components/control-array/control-array.js +2 -1
- package/dist/components/control-array/control-array.js.map +1 -1
- package/dist/components/control-date/control-date.d.ts +27 -0
- package/dist/components/control-date/control-date.d.ts.map +1 -1
- package/dist/components/control-date/control-date.js +15 -19
- package/dist/components/control-date/control-date.js.map +1 -1
- package/dist/components/control-date/date-only.d.ts +18 -0
- package/dist/components/control-date/date-only.d.ts.map +1 -0
- package/dist/components/control-date/date-only.js +29 -0
- package/dist/components/control-date/date-only.js.map +1 -0
- package/dist/components/control-date-range/control-date-range.d.ts +56 -0
- package/dist/components/control-date-range/control-date-range.d.ts.map +1 -0
- package/dist/components/control-date-range/control-date-range.js +148 -0
- package/dist/components/control-date-range/control-date-range.js.map +1 -0
- package/dist/components/control-object/control-object.js +2 -1
- package/dist/components/control-object/control-object.js.map +1 -1
- package/dist/components/control-select/control-select.d.ts.map +1 -1
- package/dist/components/control-select/control-select.js +177 -37
- package/dist/components/control-select/control-select.js.map +1 -1
- package/dist/components/control-upload/control-upload.d.ts.map +1 -1
- package/dist/components/control-upload/control-upload.js +1 -11
- package/dist/components/control-upload/control-upload.js.map +1 -1
- package/dist/components/detail/detail-aside.d.ts.map +1 -1
- package/dist/components/detail/detail-aside.js +4 -3
- package/dist/components/detail/detail-aside.js.map +1 -1
- package/dist/components/file-image/file-image.js +2 -1
- package/dist/components/file-image/file-image.js.map +1 -1
- package/dist/components/markdown-view/SpoilerSpan.d.ts +28 -0
- package/dist/components/markdown-view/SpoilerSpan.d.ts.map +1 -0
- package/dist/components/markdown-view/SpoilerSpan.js +53 -0
- package/dist/components/markdown-view/SpoilerSpan.js.map +1 -0
- package/dist/components/markdown-view/diagram/layoutSequence.js +13 -23
- package/dist/components/markdown-view/diagram/layoutSequence.js.map +1 -1
- package/dist/components/markdown-view/diagram/textMetrics.js +2 -2
- package/dist/components/markdown-view/diagram/textMetrics.js.map +1 -1
- package/dist/components/markdown-view/markdown-view.css +44 -0
- package/dist/components/markdown-view/markdown-view.d.ts +12 -0
- package/dist/components/markdown-view/markdown-view.d.ts.map +1 -1
- package/dist/components/markdown-view/markdown-view.js +22 -1
- package/dist/components/markdown-view/markdown-view.js.map +1 -1
- package/dist/components/markdown-view/remarkSpoiler.d.ts +17 -0
- package/dist/components/markdown-view/remarkSpoiler.d.ts.map +1 -0
- package/dist/components/markdown-view/remarkSpoiler.js +117 -0
- package/dist/components/markdown-view/remarkSpoiler.js.map +1 -0
- package/dist/components/permission-matrix/permission-matrix-group-rows.d.ts +34 -0
- package/dist/components/permission-matrix/permission-matrix-group-rows.d.ts.map +1 -0
- package/dist/components/permission-matrix/permission-matrix-group-rows.js +109 -0
- package/dist/components/permission-matrix/permission-matrix-group-rows.js.map +1 -0
- package/dist/components/permission-matrix/permission-matrix.d.ts +145 -0
- package/dist/components/permission-matrix/permission-matrix.d.ts.map +1 -0
- package/dist/components/permission-matrix/permission-matrix.js +113 -0
- package/dist/components/permission-matrix/permission-matrix.js.map +1 -0
- package/dist/components/plate-layout/plate-layout.d.ts +5 -0
- package/dist/components/plate-layout/plate-layout.d.ts.map +1 -1
- package/dist/components/plate-layout/plate-layout.js +2 -1
- package/dist/components/plate-layout/plate-layout.js.map +1 -1
- package/dist/components/plate-layout/plate-tab-bar.d.ts +10 -0
- package/dist/components/plate-layout/plate-tab-bar.d.ts.map +1 -1
- package/dist/components/plate-layout/plate-tab-bar.js +1 -1
- package/dist/components/plate-layout/plate-tab-bar.js.map +1 -1
- package/dist/components/settings/settings-nav.js +2 -1
- package/dist/components/settings/settings-nav.js.map +1 -1
- package/dist/components/time-ago/time-ago.d.ts +57 -0
- package/dist/components/time-ago/time-ago.d.ts.map +1 -0
- package/dist/components/time-ago/time-ago.js +60 -0
- package/dist/components/time-ago/time-ago.js.map +1 -0
- package/dist/components/tree-view/tree-model.d.ts +128 -0
- package/dist/components/tree-view/tree-model.d.ts.map +1 -0
- package/dist/components/tree-view/tree-model.js +226 -0
- package/dist/components/tree-view/tree-model.js.map +1 -0
- package/dist/components/tree-view/tree-view-rename-input.d.ts +31 -0
- package/dist/components/tree-view/tree-view-rename-input.d.ts.map +1 -0
- package/dist/components/tree-view/tree-view-rename-input.js +68 -0
- package/dist/components/tree-view/tree-view-rename-input.js.map +1 -0
- package/dist/components/tree-view/tree-view-resizer.d.ts +38 -0
- package/dist/components/tree-view/tree-view-resizer.d.ts.map +1 -0
- package/dist/components/tree-view/tree-view-resizer.js +73 -0
- package/dist/components/tree-view/tree-view-resizer.js.map +1 -0
- package/dist/components/tree-view/tree-view-row.d.ts +177 -0
- package/dist/components/tree-view/tree-view-row.d.ts.map +1 -0
- package/dist/components/tree-view/tree-view-row.js +241 -0
- package/dist/components/tree-view/tree-view-row.js.map +1 -0
- package/dist/components/tree-view/tree-view.d.ts +186 -0
- package/dist/components/tree-view/tree-view.d.ts.map +1 -0
- package/dist/components/tree-view/tree-view.js +112 -0
- package/dist/components/tree-view/tree-view.js.map +1 -0
- package/dist/components/tree-view/use-tree-state.d.ts +79 -0
- package/dist/components/tree-view/use-tree-state.d.ts.map +1 -0
- package/dist/components/tree-view/use-tree-state.js +93 -0
- package/dist/components/tree-view/use-tree-state.js.map +1 -0
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/select.d.ts +7 -0
- package/dist/components/ui/select.d.ts.map +1 -1
- package/dist/components/ui/select.js +7 -0
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/sidebar.js.map +1 -1
- package/dist/components/ui/table.js.map +1 -1
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/lib/i18n-fr.d.ts.map +1 -1
- package/dist/lib/i18n-fr.js +31 -47
- package/dist/lib/i18n-fr.js.map +1 -1
- package/dist/lib/utils.d.ts +22 -2
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +29 -5
- package/dist/lib/utils.js.map +1 -1
- package/dist/styles.css +255 -0
- package/package.json +13 -14
- package/src/components/account/__tests__/account-router.spec.ts +95 -0
- package/src/components/account/account-connections.tsx +14 -1
- package/src/components/account/account-delete-dialog.tsx +3 -2
- package/src/components/account/account-keys.tsx +11 -4
- package/src/components/account/account-mfa-dialog.tsx +1 -1
- package/src/components/account/account-password-dialog.tsx +3 -2
- package/src/components/account/account-profile.tsx +1 -1
- package/src/components/account/account-router-options.tsx +45 -0
- package/src/components/account/account-router-page.tsx +11 -1
- package/src/components/account/account-router.tsx +23 -6
- package/src/components/admin/__tests__/admin-jobs-payload-dialog.browser.spec.tsx +68 -0
- package/src/components/admin/__tests__/admin-notifications-preview-body.browser.spec.tsx +20 -4
- package/src/components/admin/__tests__/admin-status-labels.browser.spec.tsx +0 -31
- package/src/components/admin/admin-audits.tsx +99 -5
- package/src/components/admin/admin-files.tsx +7 -16
- package/src/components/admin/admin-jobs-executions-panel.tsx +152 -114
- package/src/components/admin/admin-jobs-payload-dialog.tsx +57 -0
- package/src/components/admin/admin-keys.tsx +7 -4
- package/src/components/admin/admin-notifications-channel-label.ts +18 -0
- package/src/components/admin/admin-notifications-preview-body.tsx +7 -2
- package/src/components/admin/admin-notifications.tsx +19 -8
- package/src/components/admin/admin-payments.tsx +7 -4
- package/src/components/admin/admin-router-options.tsx +12 -0
- package/src/components/admin/admin-router.tsx +5 -27
- package/src/components/admin/admin-sessions.tsx +10 -6
- package/src/components/admin/admin-user-detail-audits-tab.tsx +7 -4
- package/src/components/admin/admin-user-detail-sessions-tab.tsx +7 -4
- package/src/components/admin/admin-users-roles-picker.tsx +4 -0
- package/src/components/admin/admin-users.tsx +6 -3
- package/src/components/admin/parameter-history-item.tsx +4 -2
- package/src/components/alepha-table/__tests__/alepha-table-default-hidden.browser.spec.tsx +108 -0
- package/src/components/alepha-table/__tests__/alepha-table-empty-state.browser.spec.tsx +233 -0
- package/src/components/alepha-table/__tests__/alepha-table-persist-facets.browser.spec.tsx +177 -0
- package/src/components/alepha-table/__tests__/alepha-table-persisted-filters.browser.spec.tsx +182 -0
- package/src/components/alepha-table/__tests__/alepha-table-query-seed.browser.spec.tsx +170 -0
- package/src/components/alepha-table/__tests__/alepha-table-row-action-checked.browser.spec.tsx +210 -0
- package/src/components/alepha-table/__tests__/alepha-table-row-action-group.browser.spec.tsx +202 -0
- package/src/components/alepha-table/__tests__/alepha-table-scope.browser.spec.tsx +161 -0
- package/src/components/alepha-table/__tests__/alepha-table-share-filters.browser.spec.tsx +309 -0
- package/src/components/alepha-table/__tests__/query-filters.spec.ts +212 -0
- package/src/components/alepha-table/alepha-table-filter-dialog.tsx +162 -0
- package/src/components/alepha-table/alepha-table-filter-menu.tsx +77 -0
- package/src/components/alepha-table/alepha-table.tsx +1113 -207
- package/src/components/alepha-table/query-filters.ts +159 -0
- package/src/components/app-actions/app-actions.tsx +32 -3
- package/src/components/app-shell/__tests__/sidebar-nav-accordion.browser.spec.tsx +163 -0
- package/src/components/app-shell/app-shell.tsx +255 -12
- package/src/components/auto-form/__tests__/auto-form-settings-card.browser.spec.tsx +1 -1
- package/src/components/auto-form/auto-form.tsx +98 -30
- package/src/components/button-dark/button-dark.tsx +47 -8
- package/src/components/button-inbox/__tests__/button-inbox.browser.spec.tsx +247 -0
- package/src/components/button-inbox/button-inbox.tsx +303 -0
- package/src/components/button-inbox/inbox-unread-atom.ts +27 -0
- package/src/components/button-theme/button-theme.tsx +16 -29
- package/src/components/button-user/__tests__/button-user-avatar.browser.spec.tsx +88 -0
- package/src/components/button-user/button-user.tsx +24 -1
- package/src/components/control/__tests__/control-date-range.browser.spec.tsx +177 -0
- package/src/components/control/control.tsx +119 -12
- package/src/components/control-date/control-date.tsx +117 -22
- package/src/components/control-date/date-only.ts +26 -0
- package/src/components/control-date-range/control-date-range.tsx +250 -0
- package/src/components/control-select/__tests__/control-select-clear-label.browser.spec.tsx +129 -15
- package/src/components/control-select/__tests__/control-select-deselect.browser.spec.tsx +27 -6
- package/src/components/control-select/__tests__/control-select-multi.browser.spec.tsx +204 -1
- package/src/components/control-select/__tests__/control-select-size-minimal.browser.spec.tsx +77 -1
- package/src/components/control-select/control-select.tsx +317 -83
- package/src/components/control-upload/control-upload.tsx +1 -10
- package/src/components/detail/detail-aside.tsx +30 -6
- package/src/components/markdown-view/SpoilerSpan.tsx +66 -0
- package/src/components/markdown-view/__tests__/markdown-view-spoiler.browser.spec.tsx +165 -0
- package/src/components/markdown-view/diagram/textMetrics.spec.ts +1 -1
- package/src/components/markdown-view/diagram/textMetrics.ts +2 -2
- package/src/components/markdown-view/markdown-view.css +44 -0
- package/src/components/markdown-view/markdown-view.tsx +37 -1
- package/src/components/markdown-view/remarkSpoiler.ts +150 -0
- package/src/components/permission-matrix/__tests__/permission-matrix.browser.spec.tsx +237 -0
- package/src/components/permission-matrix/permission-matrix-group-rows.tsx +240 -0
- package/src/components/permission-matrix/permission-matrix.tsx +286 -0
- package/src/components/plate-layout/__tests__/plate-layout.browser.spec.tsx +22 -0
- package/src/components/plate-layout/plate-layout.tsx +6 -0
- package/src/components/plate-layout/plate-tab-bar.tsx +27 -1
- package/src/components/time-ago/time-ago.browser.spec.tsx +110 -0
- package/src/components/time-ago/time-ago.tsx +80 -0
- package/src/components/tree-view/__tests__/tree-model.spec.ts +441 -0
- package/src/components/tree-view/__tests__/tree-view-drag.browser.spec.tsx +295 -0
- package/src/components/tree-view/__tests__/tree-view-rename.browser.spec.tsx +278 -0
- package/src/components/tree-view/__tests__/tree-view-resizer.browser.spec.tsx +112 -0
- package/src/components/tree-view/__tests__/tree-view.browser.spec.tsx +260 -0
- package/src/components/tree-view/__tests__/use-tree-state.browser.spec.tsx +238 -0
- package/src/components/tree-view/tree-model.ts +369 -0
- package/src/components/tree-view/tree-view-rename-input.tsx +95 -0
- package/src/components/tree-view/tree-view-resizer.tsx +83 -0
- package/src/components/tree-view/tree-view-row.tsx +414 -0
- package/src/components/tree-view/tree-view.tsx +300 -0
- package/src/components/tree-view/use-tree-state.ts +184 -0
- package/src/components/ui/button.tsx +79 -1
- package/src/components/ui/dropdown-menu.tsx +1 -1
- package/src/components/ui/select.tsx +7 -0
- package/src/components/ui/table.tsx +1 -1
- package/src/components/ui/tooltip.tsx +1 -1
- package/src/lib/i18n-fr.ts +34 -51
- package/src/lib/utils.ts +32 -4
- package/src/styles.css +255 -0
- package/dist/components/admin/admin-workflows-execution-sheet.d.ts +0 -11
- package/dist/components/admin/admin-workflows-execution-sheet.d.ts.map +0 -1
- package/dist/components/admin/admin-workflows-execution-sheet.js +0 -190
- package/dist/components/admin/admin-workflows-execution-sheet.js.map +0 -1
- package/dist/components/admin/admin-workflows-executions-panel.d.ts +0 -9
- package/dist/components/admin/admin-workflows-executions-panel.d.ts.map +0 -1
- package/dist/components/admin/admin-workflows-executions-panel.js +0 -121
- package/dist/components/admin/admin-workflows-executions-panel.js.map +0 -1
- package/dist/components/admin/admin-workflows-status-badge.d.ts +0 -12
- package/dist/components/admin/admin-workflows-status-badge.d.ts.map +0 -1
- package/dist/components/admin/admin-workflows-status-badge.js +0 -30
- package/dist/components/admin/admin-workflows-status-badge.js.map +0 -1
- package/dist/components/admin/admin-workflows-status-labels.d.ts +0 -19
- package/dist/components/admin/admin-workflows-status-labels.d.ts.map +0 -1
- package/dist/components/admin/admin-workflows-status-labels.js +0 -48
- package/dist/components/admin/admin-workflows-status-labels.js.map +0 -1
- package/dist/components/admin/admin-workflows.d.ts +0 -4
- package/dist/components/admin/admin-workflows.d.ts.map +0 -1
- package/dist/components/admin/admin-workflows.js +0 -145
- package/dist/components/admin/admin-workflows.js.map +0 -1
- package/src/components/admin/admin-workflows-execution-sheet.tsx +0 -285
- package/src/components/admin/admin-workflows-executions-panel.tsx +0 -169
- package/src/components/admin/admin-workflows-status-badge.tsx +0 -41
- package/src/components/admin/admin-workflows-status-labels.ts +0 -51
- package/src/components/admin/admin-workflows.tsx +0 -209
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
void React;
|
|
4
|
+
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
|
|
7
|
+
export interface SpoilerSpanProps {
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A `||spoiler||`, hidden until the reader asks for it.
|
|
13
|
+
*
|
|
14
|
+
* ## ⚠️ It is not a security feature
|
|
15
|
+
*
|
|
16
|
+
* The text is in the DOM from the first paint - hidden by a colour, not by an
|
|
17
|
+
* absence. It is also in the raw markdown, in a folio export, in `folio_get`
|
|
18
|
+
* over MCP and in any search snippet. It hides a plot point from a reader's
|
|
19
|
+
* eye and nothing more, and must never be described as a way to store a
|
|
20
|
+
* secret.
|
|
21
|
+
*
|
|
22
|
+
* ## Reachable without a mouse
|
|
23
|
+
*
|
|
24
|
+
* `role="button"` with a `tabIndex`, Enter and Space, and an `aria-label`
|
|
25
|
+
* naming what it is: a screen reader that met a bare `<span>` here would
|
|
26
|
+
* simply read the hidden text aloud, which is not a failure of privacy (see
|
|
27
|
+
* above) but is a failure to say that the author meant it to be covered.
|
|
28
|
+
*
|
|
29
|
+
* Once revealed it stays revealed. Re-hiding on blur would make the thing
|
|
30
|
+
* unreadable with a keyboard, since moving on to read what is around it is
|
|
31
|
+
* exactly what a reader does next.
|
|
32
|
+
*/
|
|
33
|
+
export const SpoilerSpan = (props: SpoilerSpanProps) => {
|
|
34
|
+
const [revealed, setRevealed] = useState(false);
|
|
35
|
+
|
|
36
|
+
if (revealed) {
|
|
37
|
+
return (
|
|
38
|
+
<span data-spoiler="revealed" className="rounded-[3px] px-0.5">
|
|
39
|
+
{props.children}
|
|
40
|
+
</span>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<span
|
|
46
|
+
data-spoiler="hidden"
|
|
47
|
+
role="button"
|
|
48
|
+
tabIndex={0}
|
|
49
|
+
aria-expanded={false}
|
|
50
|
+
aria-label="Hidden text, activate to reveal"
|
|
51
|
+
className="rounded-[3px] px-0.5"
|
|
52
|
+
onClick={() => setRevealed(true)}
|
|
53
|
+
onKeyDown={(event) => {
|
|
54
|
+
// Enter and Space, because `role="button"` promises both and a `span`
|
|
55
|
+
// delivers neither on its own. `preventDefault` on Space stops the
|
|
56
|
+
// page scrolling out from under the reader who just pressed it.
|
|
57
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
setRevealed(true);
|
|
60
|
+
}
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
{props.children}
|
|
64
|
+
</span>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { fireEvent, render } from "@testing-library/react";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
import { MarkdownView } from "../markdown-view.tsx";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `||spoiler||`, and the ten cases the plugin was prototyped against.
|
|
8
|
+
*
|
|
9
|
+
* The interesting half is what must NOT become a spoiler: a table's pipes, a
|
|
10
|
+
* code span, a fence, and an unterminated marker. The naive implementation -
|
|
11
|
+
* split one text node on `/\|\|([\s\S]+?)\|\|/` - passes every case here
|
|
12
|
+
* except one, "inline markdown inside the spoiler", because once emphasis has
|
|
13
|
+
* split the paragraph the opening marker and its closer live in different
|
|
14
|
+
* mdast siblings. That case is the reason the plugin walks siblings.
|
|
15
|
+
*/
|
|
16
|
+
const hidden = (container: HTMLElement) => [
|
|
17
|
+
...container.querySelectorAll('[data-spoiler="hidden"]'),
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const covered = (container: HTMLElement) =>
|
|
21
|
+
hidden(container).map((node) => node.textContent);
|
|
22
|
+
|
|
23
|
+
describe("MarkdownView - spoilers", () => {
|
|
24
|
+
it("wraps only the marked words, leaving the rest of the line alone", () => {
|
|
25
|
+
const { container } = render(
|
|
26
|
+
<MarkdownView content="a ||so secret password|| b" />,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
expect(covered(container)).toEqual(["so secret password"]);
|
|
30
|
+
expect(container.textContent).toBe("a so secret password b");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("keeps inline markdown inside the spoiler", () => {
|
|
34
|
+
const { container } = render(
|
|
35
|
+
<MarkdownView content="||a **bold** word||" />,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const box = hidden(container)[0];
|
|
39
|
+
expect(box?.textContent).toBe("a bold word");
|
|
40
|
+
expect(box?.querySelector("strong")?.textContent).toBe("bold");
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("keeps a link inside the spoiler", () => {
|
|
44
|
+
const { container } = render(
|
|
45
|
+
<MarkdownView content="||see [docs](/d) now||" />,
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const box = hidden(container)[0];
|
|
49
|
+
expect(box?.textContent).toBe("see docs now");
|
|
50
|
+
expect(box?.querySelector("a")?.getAttribute("href")).toBe("/d");
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* ⚠️ The pipes of a GFM table are the case that would break every document
|
|
55
|
+
* in the app at once. They survive because `remarkGfm` runs first: by the
|
|
56
|
+
* time the spoiler walk sees the tree, `| a | b |` is a row with cells and
|
|
57
|
+
* the pipes are structure rather than text.
|
|
58
|
+
*/
|
|
59
|
+
it("leaves a GFM table's pipes alone", () => {
|
|
60
|
+
const { container } = render(
|
|
61
|
+
<MarkdownView content={"| a | b |\n| - | - |\n| 1 | 2 |"} />,
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
expect(hidden(container)).toHaveLength(0);
|
|
65
|
+
expect(container.querySelectorAll("td")).toHaveLength(2);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("keeps a code span literal", () => {
|
|
69
|
+
const { container } = render(<MarkdownView content="a `||x||` b" />);
|
|
70
|
+
|
|
71
|
+
expect(hidden(container)).toHaveLength(0);
|
|
72
|
+
expect(container.querySelector("code")?.textContent).toBe("||x||");
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("keeps a fenced block literal", () => {
|
|
76
|
+
const { container } = render(
|
|
77
|
+
<MarkdownView content={"```\n||nope||\n```"} />,
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
expect(hidden(container)).toHaveLength(0);
|
|
81
|
+
expect(container.querySelector("pre")?.textContent).toContain("||nope||");
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("covers two spoilers on one line, independently", () => {
|
|
85
|
+
const { container } = render(
|
|
86
|
+
<MarkdownView content="||one|| between ||two||" />,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
expect(covered(container)).toEqual(["one", "two"]);
|
|
90
|
+
expect(container.textContent).toBe("one between two");
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("works inside a heading and inside a list item", () => {
|
|
94
|
+
const { container } = render(
|
|
95
|
+
<MarkdownView content={"# a ||b|| c\n\n- d ||e|| f"} />,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
expect(container.querySelector("h1")?.textContent).toBe("a b c");
|
|
99
|
+
expect(container.querySelector("li")?.textContent).toBe("d e f");
|
|
100
|
+
expect(covered(container)).toEqual(["b", "e"]);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The failure mode a lazy regex has and a reader cannot explain: the rest
|
|
105
|
+
* of the paragraph disappears behind a box that was never closed.
|
|
106
|
+
*/
|
|
107
|
+
it("renders an unterminated marker literally", () => {
|
|
108
|
+
const { container } = render(
|
|
109
|
+
<MarkdownView content="a ||b and then some more text" />,
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
expect(hidden(container)).toHaveLength(0);
|
|
113
|
+
expect(container.textContent).toBe("a ||b and then some more text");
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("does not let a pair cross a paragraph break", () => {
|
|
117
|
+
const { container } = render(<MarkdownView content={"a ||b\n\nc|| d"} />);
|
|
118
|
+
|
|
119
|
+
expect(hidden(container)).toHaveLength(0);
|
|
120
|
+
expect(container.querySelectorAll("p")).toHaveLength(2);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("reveals on click, and stays revealed", () => {
|
|
124
|
+
const { container } = render(<MarkdownView content="a ||secret|| b" />);
|
|
125
|
+
|
|
126
|
+
fireEvent.click(hidden(container)[0]!);
|
|
127
|
+
|
|
128
|
+
expect(hidden(container)).toHaveLength(0);
|
|
129
|
+
const shown = container.querySelector('[data-spoiler="revealed"]');
|
|
130
|
+
expect(shown?.textContent).toBe("secret");
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it.each(["Enter", " "])("reveals on %s", (key) => {
|
|
134
|
+
const { container } = render(<MarkdownView content="a ||secret|| b" />);
|
|
135
|
+
|
|
136
|
+
fireEvent.keyDown(hidden(container)[0]!, { key });
|
|
137
|
+
|
|
138
|
+
expect(hidden(container)).toHaveLength(0);
|
|
139
|
+
expect(
|
|
140
|
+
container.querySelector('[data-spoiler="revealed"]')?.textContent,
|
|
141
|
+
).toBe("secret");
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("is announced as something a reader has to activate", () => {
|
|
145
|
+
const { container } = render(<MarkdownView content="a ||secret|| b" />);
|
|
146
|
+
|
|
147
|
+
const box = hidden(container)[0]!;
|
|
148
|
+
expect(box.getAttribute("role")).toBe("button");
|
|
149
|
+
expect(box.getAttribute("tabindex")).toBe("0");
|
|
150
|
+
expect(box.getAttribute("aria-expanded")).toBe("false");
|
|
151
|
+
expect(box.getAttribute("aria-label")).toBeTruthy();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* ⚠️ Pinned deliberately, because it is the thing the feature must never be
|
|
156
|
+
* mistaken for: the text is in the DOM from the first paint. Anything that
|
|
157
|
+
* made this assertion fail - rendering the covered text as dots, dropping
|
|
158
|
+
* it until revealed - would be a change of contract, not a fix.
|
|
159
|
+
*/
|
|
160
|
+
it("has the covered text in the DOM before it is revealed", () => {
|
|
161
|
+
const { container } = render(<MarkdownView content="a ||secret|| b" />);
|
|
162
|
+
|
|
163
|
+
expect(container.textContent).toContain("secret");
|
|
164
|
+
});
|
|
165
|
+
});
|
|
@@ -44,7 +44,7 @@ describe("measureLine", () => {
|
|
|
44
44
|
["the quick brown fox", 121.393],
|
|
45
45
|
])("is within 5%% of Chromium's own measurement of %s", (text, browser) => {
|
|
46
46
|
// Measured in Chromium against the real Inter woff2 by
|
|
47
|
-
// scripts/measure-font.
|
|
47
|
+
// scripts/measure-font.ts, in the same run that generated the table.
|
|
48
48
|
// The gap is rounding the ratios to three decimals, and 5% off on a box
|
|
49
49
|
// width is invisible in a boxes-and-arrows diagram.
|
|
50
50
|
const error = Math.abs(measureLine(text, 13) - browser) / browser;
|
|
@@ -44,12 +44,12 @@ export const MAX_LABEL_LINES = 8;
|
|
|
44
44
|
*
|
|
45
45
|
* ## How this was produced, and how to reproduce it
|
|
46
46
|
*
|
|
47
|
-
* `scripts/measure-font.
|
|
47
|
+
* `scripts/measure-font.ts` loads the real `@fontsource-variable/inter`
|
|
48
48
|
* woff2 into Chromium via Playwright, waits for `document.fonts.ready` and
|
|
49
49
|
* calls `canvas.measureText` on every character below, then buckets them by
|
|
50
50
|
* rounded ratio. Run it from the repo root and paste the output back here:
|
|
51
51
|
*
|
|
52
|
-
* node packages/@alepha/ui/scripts/measure-font.
|
|
52
|
+
* node packages/@alepha/ui/scripts/measure-font.ts
|
|
53
53
|
*
|
|
54
54
|
* The numbers are NOT magic and NOT hand-tuned. If the pinned face or size
|
|
55
55
|
* ever changes, regenerate rather than nudging a value.
|
|
@@ -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
|
+
}
|
|
@@ -9,6 +9,8 @@ import rehypeHighlight from "rehype-highlight";
|
|
|
9
9
|
import remarkGfm from "remark-gfm";
|
|
10
10
|
|
|
11
11
|
import { DiagramErrorBoundary } from "./diagram/DiagramErrorBoundary.tsx";
|
|
12
|
+
import { remarkSpoiler } from "./remarkSpoiler.ts";
|
|
13
|
+
import { SpoilerSpan } from "./SpoilerSpan.tsx";
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Both parsers, both layouts (`graphre` for the flowchart, arithmetic for
|
|
@@ -77,6 +79,18 @@ export interface MarkdownViewProps {
|
|
|
77
79
|
* invalid mermaid, and a red box in the middle of a document is worse than
|
|
78
80
|
* a grey fence. See `packages/@alepha/ui/DOC.md` for the full table.
|
|
79
81
|
*
|
|
82
|
+
* ## Spoilers
|
|
83
|
+
*
|
|
84
|
+
* `||text||` renders as a covered box that reveals on click, on Enter or on
|
|
85
|
+
* Space, Discord's syntax and Discord's behaviour. Inline markdown inside it
|
|
86
|
+
* survives, a code span or a fence keeps its pipes literally, and an
|
|
87
|
+
* unterminated `||` renders as the two characters the author typed rather
|
|
88
|
+
* than swallowing the rest of the paragraph.
|
|
89
|
+
*
|
|
90
|
+
* ⚠️ **It is not a security feature.** The text is in the DOM from the first
|
|
91
|
+
* paint, in the raw markdown, in an export, over MCP and in any search
|
|
92
|
+
* snippet. It hides a plot point from a reader's eye and nothing more.
|
|
93
|
+
*
|
|
80
94
|
* ## Raw HTML
|
|
81
95
|
*
|
|
82
96
|
* No raw HTML is ever rendered as markup: react-markdown's default is to
|
|
@@ -101,7 +115,11 @@ export const MarkdownView = (props: MarkdownViewProps) => {
|
|
|
101
115
|
className={`max-w-none text-sm leading-relaxed ${props.className ?? ""}`}
|
|
102
116
|
>
|
|
103
117
|
<ReactMarkdown
|
|
104
|
-
|
|
118
|
+
// ⚠️ `remarkSpoiler` runs AFTER `remarkGfm`, and the order is
|
|
119
|
+
// load-bearing: by then a `| a | b |` row is a table with cells, so
|
|
120
|
+
// the pipes are structure and the spoiler walk never sees them as
|
|
121
|
+
// text. Reversed, every two-column table would be a spoiler.
|
|
122
|
+
remarkPlugins={[remarkGfm, remarkSpoiler]}
|
|
105
123
|
rehypePlugins={[
|
|
106
124
|
// `plainText` claims the fence BEFORE highlighting runs: hljs would
|
|
107
125
|
// otherwise tokenise the diagram source, and the fallback would be a
|
|
@@ -175,6 +193,24 @@ export const MarkdownView = (props: MarkdownViewProps) => {
|
|
|
175
193
|
</DiagramErrorBoundary>
|
|
176
194
|
);
|
|
177
195
|
},
|
|
196
|
+
// The only `<span>` this renderer ever produces is a spoiler's, and
|
|
197
|
+
// the only thing that marks one is the `data-spoiler` property
|
|
198
|
+
// `remarkSpoiler` puts there.
|
|
199
|
+
//
|
|
200
|
+
// ⚠️ The cast is not laziness: react-markdown types a span's props
|
|
201
|
+
// as `HTMLAttributes<HTMLSpanElement>`, which PERMITS writing a
|
|
202
|
+
// `data-*` attribute in JSX and does not declare one for reading.
|
|
203
|
+
// The alternative - a custom `hName` with its own `components` key -
|
|
204
|
+
// needs a cast into `components`, whose type is keyed on intrinsic
|
|
205
|
+
// elements, so it buys nothing (the same note `mermaidSource`
|
|
206
|
+
// already carries).
|
|
207
|
+
span: ({ children, ...rest }) => {
|
|
208
|
+
const marked = (rest as { "data-spoiler"?: unknown })[
|
|
209
|
+
"data-spoiler"
|
|
210
|
+
];
|
|
211
|
+
if (marked) return <SpoilerSpan>{children}</SpoilerSpan>;
|
|
212
|
+
return <span {...rest}>{children}</span>;
|
|
213
|
+
},
|
|
178
214
|
blockquote: ({ children }) => (
|
|
179
215
|
<blockquote className="border-muted-foreground/30 my-3 border-l-2 pl-4 italic">
|
|
180
216
|
{children}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discord's `||spoiler||`, as a remark plugin.
|
|
3
|
+
*
|
|
4
|
+
* Rewrites every `||…||` pair in the tree into one node that
|
|
5
|
+
* `mdast-util-to-hast` renders as `<span data-spoiler="true">`, which
|
|
6
|
+
* `MarkdownView` then maps onto `SpoilerSpan`. Everything between the markers
|
|
7
|
+
* keeps its own markup: `||see [the docs](/d) **now**||` hides a link and a
|
|
8
|
+
* bold word, not the text of them.
|
|
9
|
+
*
|
|
10
|
+
* ## ⚠️ It has to span SIBLINGS, not split one text node
|
|
11
|
+
*
|
|
12
|
+
* The obvious version splits a text node on `/\|\|([\s\S]+?)\|\|/` and fails on
|
|
13
|
+
* exactly one case - markdown INSIDE the spoiler. Once emphasis has split the
|
|
14
|
+
* paragraph, the opening `||` and its closer live in different mdast siblings,
|
|
15
|
+
* so no regex over a single node can see both. This walk opens a collector on
|
|
16
|
+
* the first marker, pushes the following siblings into it, and closes on the
|
|
17
|
+
* next one.
|
|
18
|
+
*
|
|
19
|
+
* That shape is also what makes two things true for free rather than by a
|
|
20
|
+
* special case that could rot:
|
|
21
|
+
*
|
|
22
|
+
* - **`code` and `inlineCode` stay literal.** Both carry a `value` and no
|
|
23
|
+
* `children`, so a text walk cannot reach inside them. `` `||x||` `` and a
|
|
24
|
+
* fenced block are structurally out of range.
|
|
25
|
+
* - **A pair cannot cross a paragraph break.** Each parent's children are
|
|
26
|
+
* processed on their own, and the collector is discarded at the end of the
|
|
27
|
+
* list, so an unterminated `||` puts its literal text back and gives up.
|
|
28
|
+
*
|
|
29
|
+
* GFM table pipes are untouched for the same reason: by the time this runs,
|
|
30
|
+
* `remark-gfm` has already turned `| a | b |` into rows and cells, and the
|
|
31
|
+
* pipes are structure rather than text.
|
|
32
|
+
*
|
|
33
|
+
* ## ⚠️ It is not a security feature, and must never be presented as one
|
|
34
|
+
*
|
|
35
|
+
* The text sits in the DOM, in the raw markdown, in a folio export, in
|
|
36
|
+
* `folio_get` over MCP and in any search snippet. It hides a plot point from a
|
|
37
|
+
* reader's eye and nothing more.
|
|
38
|
+
*
|
|
39
|
+
* No new dependency: the walk is a plain recursion, so `unist-util-visit`
|
|
40
|
+
* never enters `package.json` and `check:deps` stays quiet.
|
|
41
|
+
*/
|
|
42
|
+
const MARKER = "||";
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The subset of a mdast node this walk touches.
|
|
46
|
+
*
|
|
47
|
+
* Declared here rather than imported from `mdast`: the plugin needs "has
|
|
48
|
+
* children" and "is a text node with a value", and nothing else. Taking the
|
|
49
|
+
* real union would pull `@types/mdast` into this package's direct types for a
|
|
50
|
+
* pair of structural checks.
|
|
51
|
+
*/
|
|
52
|
+
interface SpoilerNode {
|
|
53
|
+
type: string;
|
|
54
|
+
value?: string;
|
|
55
|
+
children?: SpoilerNode[];
|
|
56
|
+
data?: Record<string, unknown>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const remarkSpoiler = () => (tree: SpoilerNode) => {
|
|
60
|
+
walk(tree);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Rewrite this node's children, then descend into whatever survives.
|
|
65
|
+
*/
|
|
66
|
+
const walk = (node: SpoilerNode): void => {
|
|
67
|
+
if (!node.children) return;
|
|
68
|
+
node.children = rewrite(node.children);
|
|
69
|
+
for (const child of node.children) {
|
|
70
|
+
walk(child);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* One sibling list, with every `||…||` pair folded into a spoiler node.
|
|
76
|
+
*/
|
|
77
|
+
const rewrite = (children: SpoilerNode[]): SpoilerNode[] => {
|
|
78
|
+
// Nothing to do unless a marker is actually present at this level. The
|
|
79
|
+
// common case is every paragraph in every document, so it is worth the
|
|
80
|
+
// scan: without it, each one is rebuilt into a new array for nothing.
|
|
81
|
+
if (
|
|
82
|
+
!children.some(
|
|
83
|
+
(child) => child.type === "text" && child.value?.includes(MARKER),
|
|
84
|
+
)
|
|
85
|
+
) {
|
|
86
|
+
return children;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const out: SpoilerNode[] = [];
|
|
90
|
+
let open: SpoilerNode[] | undefined;
|
|
91
|
+
const target = () => open ?? out;
|
|
92
|
+
|
|
93
|
+
const push = (child: SpoilerNode) => {
|
|
94
|
+
target().push(child);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const text = (value: string) => {
|
|
98
|
+
if (value) push({ type: "text", value });
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const toggle = () => {
|
|
102
|
+
if (open) {
|
|
103
|
+
out.push(spoiler(open));
|
|
104
|
+
open = undefined;
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
open = [];
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
for (const child of children) {
|
|
111
|
+
if (child.type !== "text" || !child.value?.includes(MARKER)) {
|
|
112
|
+
push(child);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// `split` gives one more segment than there are markers, so segment 0 is
|
|
117
|
+
// whatever preceded the first one and every later segment is preceded by
|
|
118
|
+
// a toggle.
|
|
119
|
+
const segments = child.value.split(MARKER);
|
|
120
|
+
text(segments[0]!);
|
|
121
|
+
for (const segment of segments.slice(1)) {
|
|
122
|
+
toggle();
|
|
123
|
+
text(segment);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (open) {
|
|
128
|
+
// Unterminated: the marker was never a spoiler, so it goes back as the
|
|
129
|
+
// two characters the author typed, followed by everything that had been
|
|
130
|
+
// collected behind it. Swallowing the rest of the paragraph instead is
|
|
131
|
+
// what a lazy regex does, and it is the failure a reader cannot explain.
|
|
132
|
+
out.push({ type: "text", value: MARKER }, ...open);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return out;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* One spoiler, as the node `mdast-util-to-hast` turns into a `<span>`.
|
|
140
|
+
*
|
|
141
|
+
* `hName` / `hProperties` are the documented way to place an element the
|
|
142
|
+
* markdown AST has no type for: the default unknown-node handler builds a
|
|
143
|
+
* `div` from the children and `applyData` then renames it and merges the
|
|
144
|
+
* properties, so nothing invalid is ever produced inside a paragraph.
|
|
145
|
+
*/
|
|
146
|
+
const spoiler = (children: SpoilerNode[]): SpoilerNode => ({
|
|
147
|
+
type: "spoiler",
|
|
148
|
+
children,
|
|
149
|
+
data: { hName: "span", hProperties: { "data-spoiler": "true" } },
|
|
150
|
+
});
|