@eifi1/ui-kit 0.34.0 → 0.36.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 +115 -41
- package/dist/admin/role-select.d.ts +3 -2
- package/dist/admin/role-select.js +2 -0
- package/dist/admin/role-select.js.map +1 -1
- package/dist/billing/billing-banner.d.ts +5 -2
- package/dist/billing/billing-banner.js.map +1 -1
- package/dist/billing/plan-limit-notice.d.ts +5 -2
- package/dist/billing/plan-limit-notice.js.map +1 -1
- package/dist/chart.js.map +1 -1
- package/dist/components/amount-input.d.ts +2 -5
- package/dist/components/amount-input.js +2 -2
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/autocomplete.d.ts +2 -2
- package/dist/components/autocomplete.js +2 -1
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/button-look.d.ts +1 -1
- package/dist/components/button-look.js +9 -4
- package/dist/components/button-look.js.map +1 -1
- package/dist/components/calculator.d.ts +1 -4
- package/dist/components/calculator.js +1 -3
- package/dist/components/calculator.js.map +1 -1
- package/dist/components/chart-zoom.d.ts +0 -37
- package/dist/components/chart-zoom.js +1 -28
- package/dist/components/chart-zoom.js.map +1 -1
- package/dist/components/checkbox-group.d.ts +5 -2
- package/dist/components/checkbox-group.js +15 -4
- package/dist/components/checkbox-group.js.map +1 -1
- package/dist/components/chip-input.d.ts +0 -4
- package/dist/components/chip-input.js +1 -5
- package/dist/components/chip-input.js.map +1 -1
- package/dist/components/column-mapper.d.ts +5 -3
- package/dist/components/column-mapper.js +2 -0
- package/dist/components/column-mapper.js.map +1 -1
- package/dist/components/combobox.d.ts +3 -3
- package/dist/components/combobox.js +2 -1
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/copy-button.d.ts +5 -1
- package/dist/components/copy-button.js.map +1 -1
- package/dist/components/country-select.d.ts +3 -3
- package/dist/components/country-select.js +3 -0
- package/dist/components/country-select.js.map +1 -1
- package/dist/components/currency-option-list.d.ts +3 -8
- package/dist/components/currency-option-list.js +1 -29
- package/dist/components/currency-option-list.js.map +1 -1
- package/dist/components/currency-select.d.ts +3 -2
- package/dist/components/currency-select.js +10 -1
- package/dist/components/currency-select.js.map +1 -1
- package/dist/components/danger-confirm.d.ts +3 -3
- package/dist/components/danger-confirm.js.map +1 -1
- package/dist/components/data-table-filter-popover.d.ts +1 -1
- package/dist/components/data-table-filter-popover.js +1 -1
- package/dist/components/data-table-filter-popover.js.map +1 -1
- package/dist/components/data-table-labels.d.ts +1 -42
- package/dist/components/data-table-labels.js +2 -31
- package/dist/components/data-table-labels.js.map +1 -1
- package/dist/components/data-table-shared.d.ts +17 -1
- package/dist/components/data-table-shared.js +22 -0
- package/dist/components/data-table-shared.js.map +1 -1
- package/dist/components/data-table.d.ts +12 -2
- package/dist/components/data-table.js +18 -14
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-field.d.ts +2 -1
- package/dist/components/date-field.js.map +1 -1
- package/dist/components/date-picker.js +3 -0
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/date-range-picker.js +3 -0
- package/dist/components/date-range-picker.js.map +1 -1
- package/dist/components/dialog-frame.d.ts +3 -1
- package/dist/components/dialog-frame.js.map +1 -1
- package/dist/components/dropdown.d.ts +18 -15
- package/dist/components/dropdown.js +11 -3
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/entity-combobox.d.ts +3 -3
- package/dist/components/entity-combobox.js +2 -1
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/field-base.d.ts +0 -5
- package/dist/components/field-base.js +0 -5
- package/dist/components/field-base.js.map +1 -1
- package/dist/components/field-parts.d.ts +69 -22
- package/dist/components/field-parts.js +33 -19
- package/dist/components/field-parts.js.map +1 -1
- package/dist/components/field-strip.d.ts +9 -23
- package/dist/components/field-strip.js +26 -23
- package/dist/components/field-strip.js.map +1 -1
- package/dist/components/field-sync.d.ts +0 -4
- package/dist/components/field-sync.js +0 -4
- package/dist/components/field-sync.js.map +1 -1
- package/dist/components/field.d.ts +7 -6
- package/dist/components/field.js +24 -15
- package/dist/components/field.js.map +1 -1
- package/dist/components/full-bleed-dialog.js +2 -2
- package/dist/components/full-bleed-dialog.js.map +1 -1
- package/dist/components/help-popover.d.ts +9 -7
- package/dist/components/help-popover.js.map +1 -1
- package/dist/components/hover-menu.d.ts +6 -13
- package/dist/components/hover-menu.js +3 -3
- package/dist/components/hover-menu.js.map +1 -1
- package/dist/components/icon-picker.d.ts +3 -2
- package/dist/components/icon-picker.js +3 -0
- package/dist/components/icon-picker.js.map +1 -1
- package/dist/components/inline-entity-combobox.d.ts +3 -3
- package/dist/components/inline-entity-combobox.js +2 -1
- package/dist/components/inline-entity-combobox.js.map +1 -1
- package/dist/components/input.d.ts +2 -2
- package/dist/components/input.js +2 -1
- package/dist/components/input.js.map +1 -1
- package/dist/components/modal.d.ts +9 -1
- package/dist/components/modal.js +7 -4
- package/dist/components/modal.js.map +1 -1
- package/dist/components/month-picker.d.ts +2 -1
- package/dist/components/month-picker.js +8 -1
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-entity-combobox.d.ts +2 -2
- package/dist/components/multi-entity-combobox.js +2 -1
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/multi-select.d.ts +7 -18
- package/dist/components/multi-select.js +8 -10
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/number-input.d.ts +2 -5
- package/dist/components/number-input.js +2 -4
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/numeric-field.d.ts +5 -2
- package/dist/components/numeric-field.js +4 -1
- package/dist/components/numeric-field.js.map +1 -1
- package/dist/components/one-time-code-input.d.ts +2 -1
- package/dist/components/one-time-code-input.js +2 -1
- package/dist/components/one-time-code-input.js.map +1 -1
- package/dist/components/phone-input.d.ts +1 -1
- package/dist/components/phone-input.js +4 -0
- package/dist/components/phone-input.js.map +1 -1
- package/dist/components/popover.js +3 -3
- package/dist/components/popover.js.map +1 -1
- package/dist/components/select.d.ts +4 -3
- package/dist/components/select.js +2 -1
- package/dist/components/select.js.map +1 -1
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/server-wake.d.ts +0 -6
- package/dist/components/server-wake.js.map +1 -1
- package/dist/components/settings-fields.d.ts +4 -2
- package/dist/components/settings-fields.js.map +1 -1
- package/dist/components/slider.d.ts +3 -2
- package/dist/components/slider.js +7 -1
- package/dist/components/slider.js.map +1 -1
- package/dist/components/stat-tile.d.ts +8 -2
- package/dist/components/stat-tile.js +2 -11
- package/dist/components/stat-tile.js.map +1 -1
- package/dist/components/swatch-picker.d.ts +3 -2
- package/dist/components/swatch-picker.js +3 -0
- package/dist/components/swatch-picker.js.map +1 -1
- package/dist/components/swipeable-row.d.ts +2 -17
- package/dist/components/swipeable-row.js +11 -16
- package/dist/components/swipeable-row.js.map +1 -1
- package/dist/components/text-link.js +3 -1
- package/dist/components/text-link.js.map +1 -1
- package/dist/components/textarea.d.ts +2 -1
- package/dist/components/textarea.js +9 -3
- package/dist/components/textarea.js.map +1 -1
- package/dist/components/toggle-group.d.ts +2 -2
- package/dist/components/toggle-group.js +7 -3
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/tooltip.d.ts +9 -1
- package/dist/components/tooltip.js +20 -5
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/translation-review.d.ts +10 -2
- package/dist/components/translation-review.js +11 -3
- package/dist/components/translation-review.js.map +1 -1
- package/dist/components/use-table-state.d.ts +31 -3
- package/dist/components/use-table-state.js +53 -8
- package/dist/components/use-table-state.js.map +1 -1
- package/dist/components/user-avatar.d.ts +2 -2
- package/dist/components/user-avatar.js.map +1 -1
- package/dist/components/wizard-stepper.d.ts +1 -4
- package/dist/components/wizard-stepper.js +2 -3
- package/dist/components/wizard-stepper.js.map +1 -1
- package/dist/currencies.d.ts +23 -0
- package/dist/currencies.js +38 -0
- package/dist/currencies.js.map +1 -0
- package/dist/demo/demo-banner.d.ts +7 -2
- package/dist/demo/demo-banner.js.map +1 -1
- package/dist/eslint/index.d.ts +83 -0
- package/dist/eslint/index.js +69 -0
- package/dist/eslint/index.js.map +1 -0
- package/dist/eslint/role-utilities.d.ts +48 -0
- package/dist/eslint/role-utilities.generated.d.ts +2 -0
- package/dist/eslint/role-utilities.generated.js +143 -0
- package/dist/eslint/role-utilities.generated.js.map +1 -0
- package/dist/eslint/role-utilities.js +43 -0
- package/dist/eslint/role-utilities.js.map +1 -0
- package/dist/feedback/feedback-menu.d.ts +2 -2
- package/dist/feedback/feedback-menu.js.map +1 -1
- package/dist/feedback/feedback-thread.d.ts +3 -8
- package/dist/feedback/feedback-thread.js +0 -2
- package/dist/feedback/feedback-thread.js.map +1 -1
- package/dist/hooks/use-dismiss.d.ts +16 -3
- package/dist/hooks/use-dismiss.js +14 -2
- package/dist/hooks/use-dismiss.js.map +1 -1
- package/dist/i18n/defaults.js +5 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.js +97 -1
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +29 -4
- package/dist/i18n/kit-labels.js +21 -1
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/en.js +104 -3
- package/dist/i18n/locales/en.js.map +3 -3
- package/dist/i18n/locales/es.js +95 -1
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.js +99 -3
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.js +95 -1
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.js +99 -3
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.js +95 -1
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.js +13 -0
- package/dist/i18n/review.js.map +1 -1
- package/dist/i18n/shared-labels.js +3 -1
- package/dist/i18n/shared-labels.js.map +1 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.js +40 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/device-settings.d.ts +72 -0
- package/dist/lib/device-settings.js +64 -0
- package/dist/lib/device-settings.js.map +1 -0
- package/dist/lib/plain-text.d.ts +11 -0
- package/dist/lib/plain-text.js +16 -0
- package/dist/lib/plain-text.js.map +1 -0
- package/dist/lib/refs.d.ts +13 -0
- package/dist/lib/refs.js +15 -0
- package/dist/lib/refs.js.map +1 -0
- package/dist/lib/safe-storage.d.ts +6 -0
- package/dist/lib/safe-storage.js +11 -0
- package/dist/lib/safe-storage.js.map +1 -1
- package/dist/notifications/notification-parts.d.ts +39 -0
- package/dist/notifications/notification-parts.js +47 -0
- package/dist/notifications/notification-parts.js.map +1 -0
- package/dist/notifications/notification-types-setting.d.ts +62 -0
- package/dist/notifications/notification-types-setting.js +192 -0
- package/dist/notifications/notification-types-setting.js.map +1 -0
- package/dist/notifications/notification-types.d.ts +75 -0
- package/dist/notifications/notification-types.js +2 -0
- package/dist/notifications/notification-types.js.map +1 -0
- package/dist/notifications/notifications-labels.d.ts +131 -0
- package/dist/notifications/notifications-labels.js +83 -0
- package/dist/notifications/notifications-labels.js.map +1 -0
- package/dist/notifications/push-device-setting.d.ts +37 -0
- package/dist/notifications/push-device-setting.js +164 -0
- package/dist/notifications/push-device-setting.js.map +1 -0
- package/dist/notifications/push-devices-setting.d.ts +44 -0
- package/dist/notifications/push-devices-setting.js +203 -0
- package/dist/notifications/push-devices-setting.js.map +1 -0
- package/dist/notifications/quiet-hours-setting.d.ts +47 -0
- package/dist/notifications/quiet-hours-setting.js +131 -0
- package/dist/notifications/quiet-hours-setting.js.map +1 -0
- package/dist/notifications/time-zone-select.d.ts +50 -0
- package/dist/notifications/time-zone-select.js +76 -0
- package/dist/notifications/time-zone-select.js.map +1 -0
- package/dist/notifications/unsubscribe-panel.d.ts +53 -0
- package/dist/notifications/unsubscribe-panel.js +139 -0
- package/dist/notifications/unsubscribe-panel.js.map +1 -0
- package/dist/notifications/use-push-device.d.ts +122 -0
- package/dist/notifications/use-push-device.js +230 -0
- package/dist/notifications/use-push-device.js.map +1 -0
- package/dist/rhf/fields.d.ts +36 -29
- package/dist/rhf/fields.js +51 -22
- package/dist/rhf/fields.js.map +1 -1
- package/dist/rhf/form-core.d.ts +5 -4
- package/dist/rhf/form-core.js.map +1 -1
- package/dist/rhf/form.d.ts +7 -36
- package/dist/rhf/form.js +1 -16
- package/dist/rhf/form.js.map +1 -1
- package/dist/rhf/line-items.d.ts +1 -1
- package/dist/rhf/line-items.js.map +1 -1
- package/dist/rhf/use-rhf-wizard-step.js.map +1 -1
- package/dist/rhf.js.map +1 -1
- package/dist/settings/device-reset-setting-labels.d.ts +3 -0
- package/dist/settings/device-reset-setting-labels.js +15 -0
- package/dist/settings/device-reset-setting-labels.js.map +1 -0
- package/dist/settings/device-reset-setting.d.ts +58 -0
- package/dist/settings/device-reset-setting.js +51 -0
- package/dist/settings/device-reset-setting.js.map +1 -0
- package/dist/shell/app-shell.js +5 -0
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/option-switcher-menu.d.ts +5 -17
- package/dist/shell/option-switcher-menu.js +1 -3
- package/dist/shell/option-switcher-menu.js.map +1 -1
- package/dist/shell/role-switcher.d.ts +1 -4
- package/dist/shell/role-switcher.js +2 -3
- package/dist/shell/role-switcher.js.map +1 -1
- package/dist/shell/topbar-action-menu.d.ts +7 -19
- package/dist/shell/topbar-action-menu.js +1 -3
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell/topbar-controls.d.ts +3 -12
- package/dist/shell/topbar-controls.js +6 -9
- package/dist/shell/topbar-controls.js.map +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +2 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/viewport.d.ts +25 -2
- package/dist/testing/viewport.js +61 -10
- package/dist/testing/viewport.js.map +1 -1
- package/dist/theme/contrast-tokens.d.ts +42 -4
- package/dist/theme/contrast-tokens.js +56 -9
- package/dist/theme/contrast-tokens.js.map +1 -1
- package/dist/theme/contrast.d.ts +4 -2
- package/dist/theme/contrast.js +13 -0
- package/dist/theme/contrast.js.map +1 -1
- package/dist/theme/palette-derive.d.ts +15 -1
- package/dist/theme/palette-derive.js +37 -8
- package/dist/theme/palette-derive.js.map +1 -1
- package/dist/theme/palette-presets.d.ts +2 -8
- package/dist/theme/palette-presets.js +5 -284
- package/dist/theme/palette-presets.js.map +1 -1
- package/dist/theme/palette-store.js +6 -0
- package/dist/theme/palette-store.js.map +1 -1
- package/dist/theme/text-size.js +6 -0
- package/dist/theme/text-size.js.map +1 -1
- package/dist/theme/theme-store.js +6 -0
- package/dist/theme/theme-store.js.map +1 -1
- package/dist/wizard/types.d.ts +0 -5
- package/dist/wizard/types.js +1 -5
- package/dist/wizard/types.js.map +1 -1
- package/package.json +9 -1
- package/src/admin/role-select.tsx +4 -1
- package/src/billing/billing-banner.tsx +5 -2
- package/src/billing/plan-limit-notice.tsx +5 -2
- package/src/chart.ts +5 -3
- package/src/components/amount-input.tsx +4 -7
- package/src/components/autocomplete.tsx +5 -2
- package/src/components/button-look.ts +15 -5
- package/src/components/calculator.tsx +2 -7
- package/src/components/chart-zoom.tsx +4 -47
- package/src/components/checkbox-group.tsx +22 -4
- package/src/components/chip-input.tsx +0 -7
- package/src/components/column-mapper.tsx +6 -2
- package/src/components/combobox.tsx +6 -3
- package/src/components/copy-button.tsx +5 -1
- package/src/components/country-select.tsx +6 -1
- package/src/components/currency-option-list.tsx +8 -42
- package/src/components/currency-select.tsx +12 -3
- package/src/components/danger-confirm.tsx +3 -3
- package/src/components/data-table-filter-popover.tsx +2 -1
- package/src/components/data-table-labels.ts +2 -84
- package/src/components/data-table-shared.tsx +55 -2
- package/src/components/data-table.tsx +29 -17
- package/src/components/date-field.tsx +2 -2
- package/src/components/date-picker.tsx +3 -0
- package/src/components/date-range-picker.tsx +3 -0
- package/src/components/dialog-frame.tsx +3 -1
- package/src/components/dropdown.tsx +42 -18
- package/src/components/entity-combobox.tsx +6 -3
- package/src/components/field-base.tsx +0 -11
- package/src/components/field-parts.tsx +112 -38
- package/src/components/field-strip.tsx +12 -27
- package/src/components/field-sync.tsx +0 -7
- package/src/components/field.tsx +32 -19
- package/src/components/full-bleed-dialog.tsx +4 -3
- package/src/components/help-popover.tsx +9 -7
- package/src/components/hover-menu.tsx +12 -16
- package/src/components/icon-picker.tsx +8 -3
- package/src/components/inline-entity-combobox.tsx +6 -3
- package/src/components/input.tsx +4 -2
- package/src/components/modal.tsx +20 -4
- package/src/components/month-picker.tsx +10 -3
- package/src/components/multi-entity-combobox.tsx +5 -2
- package/src/components/multi-select.tsx +19 -31
- package/src/components/number-input.tsx +5 -10
- package/src/components/numeric-field.ts +10 -2
- package/src/components/one-time-code-input.tsx +5 -3
- package/src/components/phone-input.tsx +4 -0
- package/src/components/popover.tsx +8 -4
- package/src/components/select.tsx +6 -3
- package/src/components/series-chart.tsx +1 -1
- package/src/components/server-wake.tsx +0 -6
- package/src/components/settings-fields.tsx +4 -2
- package/src/components/slider.tsx +10 -3
- package/src/components/stat-tile.tsx +11 -20
- package/src/components/swatch-picker.tsx +9 -4
- package/src/components/swipeable-row.tsx +15 -37
- package/src/components/text-link.tsx +3 -1
- package/src/components/textarea.tsx +11 -4
- package/src/components/toggle-group.tsx +21 -5
- package/src/components/tooltip.tsx +37 -6
- package/src/components/translation-review.tsx +25 -7
- package/src/components/use-table-state.ts +91 -10
- package/src/components/user-avatar.tsx +2 -2
- package/src/components/wizard-stepper.tsx +2 -6
- package/src/currencies.ts +70 -0
- package/src/demo/demo-banner.tsx +7 -2
- package/src/eslint/index.ts +161 -0
- package/src/eslint/role-utilities.generated.ts +146 -0
- package/src/eslint/role-utilities.ts +99 -0
- package/src/feedback/feedback-menu.tsx +2 -2
- package/src/feedback/feedback-thread.tsx +3 -8
- package/src/hooks/use-dismiss.ts +39 -4
- package/src/i18n/defaults.ts +4 -0
- package/src/i18n/german.ts +113 -0
- package/src/i18n/kit-labels.tsx +66 -6
- package/src/i18n/locales/en.ts +6 -0
- package/src/i18n/locales/es.ts +106 -0
- package/src/i18n/locales/fr.ts +109 -2
- package/src/i18n/locales/hu.ts +104 -0
- package/src/i18n/locales/it.ts +108 -2
- package/src/i18n/locales/zh.ts +96 -0
- package/src/i18n/review.ts +13 -0
- package/src/i18n/shared-labels.ts +2 -0
- package/src/index.ts +53 -1
- package/src/lib/device-settings.ts +146 -0
- package/src/lib/plain-text.ts +22 -0
- package/src/lib/refs.ts +22 -0
- package/src/lib/safe-storage.ts +16 -0
- package/src/notifications/notification-parts.tsx +83 -0
- package/src/notifications/notification-types-setting.tsx +309 -0
- package/src/notifications/notification-types.ts +80 -0
- package/src/notifications/notifications-labels.ts +238 -0
- package/src/notifications/push-device-setting.tsx +224 -0
- package/src/notifications/push-devices-setting.tsx +306 -0
- package/src/notifications/quiet-hours-setting.tsx +185 -0
- package/src/notifications/time-zone-select.tsx +126 -0
- package/src/notifications/unsubscribe-panel.tsx +203 -0
- package/src/notifications/use-push-device.ts +392 -0
- package/src/rhf/fields.tsx +87 -39
- package/src/rhf/form-core.tsx +5 -4
- package/src/rhf/form.tsx +7 -43
- package/src/rhf/line-items.tsx +1 -1
- package/src/rhf/use-rhf-wizard-step.ts +4 -4
- package/src/rhf.ts +3 -2
- package/src/settings/device-reset-setting-labels.ts +20 -0
- package/src/settings/device-reset-setting.tsx +119 -0
- package/src/shell/app-shell.tsx +8 -0
- package/src/shell/option-switcher-menu.tsx +5 -22
- package/src/shell/role-switcher.tsx +2 -6
- package/src/shell/topbar-action-menu.tsx +7 -24
- package/src/shell/topbar-controls.tsx +6 -18
- package/src/testing/index.ts +3 -1
- package/src/testing/viewport.ts +125 -19
- package/src/theme/contrast-tokens.ts +106 -12
- package/src/theme/contrast.ts +30 -4
- package/src/theme/palette-derive.ts +68 -7
- package/src/theme/palette-presets.ts +16 -299
- package/src/theme/palette-store.ts +12 -0
- package/src/theme/text-size.ts +8 -0
- package/src/theme/theme-store.ts +10 -0
- package/src/wizard/types.ts +0 -8
- package/tokens.css +38 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/shell/topbar-action-menu.tsx"],"sourcesContent":["import { useId, useLayoutEffect, useRef } from \"react\";\nimport type { KeyboardEvent as ReactKeyboardEvent, ReactNode } from \"react\";\nimport { Link } from \"react-router\";\nimport { cn } from \"../lib/cn\";\nimport { HoverMenu, type HoverMenuProps } from \"../components/hover-menu\";\nimport { MenuItem } from \"../components/menu-item\";\nimport type { MenuItemTone } from \"../components/menu-item\";\nimport { StatusDot } from \"../components/status-dot\";\nimport type { UserAvatarBadge } from \"../components/user-avatar\";\nimport { TOPBAR_TRIGGER_CLASS } from \"./topbar-controls\";\n\n/**\n * One row of a {@link TopBarActionMenu}. An `action` (default) runs `onSelect`, a\n * `link` navigates via react-router, a `divider` draws a rule, and a `heading` names\n * the rows after it. Action and link rows close the menu automatically when chosen.\n * `kind` may be omitted for actions, keeping the common case terse.\n *\n * The rows are {@link MenuItem}s, so they take its options: `tone: \"danger\"` for the\n * log-out row, `checked` (+ `checkable`) for a choice, `current` for the link to the\n * page already open, `disabled`.\n */\nexport type TopBarMenuEntry =\n | {\n kind?: \"action\";\n key: string;\n icon?: ReactNode;\n label: ReactNode;\n trailing?: ReactNode;\n onSelect: () => void;\n tone?: MenuItemTone;\n /** Makes the row a choice (`menuitemradio`, or `menuitemcheckbox` with\n * `checkable: \"checkbox\"`) and says whether it is chosen. */\n checked?: boolean;\n checkable?: \"radio\" | \"checkbox\";\n disabled?: boolean;\n }\n | {\n kind: \"link\";\n key: string;\n icon?: ReactNode;\n label: ReactNode;\n trailing?: ReactNode;\n to: string;\n tone?: MenuItemTone;\n /** The link to the page already open: `aria-current=\"page\"` and a check mark. */\n current?: boolean;\n disabled?: boolean;\n }\n | { kind: \"divider\"; key: string }\n | {\n /**\n * A group heading (0.23, keksdose's guided-tours menu): the rows after it, up to\n * the next heading, the next `divider` or the end of `entries`, are ONE group\n * named by `label`. keksdose files its tours by topic and separated the blocks\n * with bare dividers — \"the kit's menu has no heading row to name them with\"\n * (tour-menu.tsx) — so a sighted reader had to guess what each block was and a\n * screen reader was told nothing at all.\n *\n * Not a row: it takes no focus, the arrow keys (and Home/End) pass over it, and it\n * never closes the menu. It is announced the way the kit's other grouped lists\n * announce theirs (`CommandPalette`): the group's rows sit in a `role=\"group\"`\n * whose `aria-labelledby` is this heading, so a reader says \"On this page, group\"\n * when the focus enters the first row, and nothing between rows.\n *\n * A divider ENDS the group, so a closing row such as \"All tours…\" behind a rule\n * belongs to no topic. A heading with no rows under it is not drawn — an empty\n * group names nothing; build the list from data and it may well be empty.\n *\n * The menu-wide `heading` prop is the panel's title, drawn once above everything;\n * with group headings it is usually redundant (two stacked caps lines read as one),\n * and the trigger's `aria-label` already names the menu.\n */\n kind: \"heading\";\n key: string;\n /** The group's name, shown above its rows and announced as the group's name. Keep\n * it short: it is set in small caps and wraps on a narrow panel. */\n label: ReactNode;\n };\n\ntype HeadingEntry = Extract<TopBarMenuEntry, { kind: \"heading\" }>;\ntype DividerEntry = Extract<TopBarMenuEntry, { kind: \"divider\" }>;\ntype RowEntry = Exclude<TopBarMenuEntry, HeadingEntry | DividerEntry>;\n\n/** What the panel draws from `entries`: loose rows and rules, and headed groups. */\ntype Block = { kind: \"loose\"; entry: RowEntry | DividerEntry } | { kind: \"group\"; heading: HeadingEntry; rows: RowEntry[] };\n\n/**\n * Cut `entries` into blocks: a heading opens a group that takes the rows after it until\n * the next heading or divider; everything else stands alone, as it always has.\n */\nfunction toBlocks(entries: readonly TopBarMenuEntry[]): Block[] {\n const blocks: Block[] = [];\n let group: Extract<Block, { kind: \"group\" }> | null = null;\n for (const entry of entries) {\n if (entry.kind === \"heading\") {\n group = { kind: \"group\", heading: entry, rows: [] };\n blocks.push(group);\n } else if (entry.kind === \"divider\") {\n group = null;\n blocks.push({ kind: \"loose\", entry });\n } else if (group) {\n group.rows.push(entry);\n } else {\n blocks.push({ kind: \"loose\", entry });\n }\n }\n // A heading with nothing under it names nothing: not drawn (see the `heading` kind).\n return blocks.filter((block) => block.kind === \"loose\" || block.rows.length > 0);\n}\n\n/**\n * The non-interactive identity block at the top of an account menu — kastlan's name +\n * role, keksdose's display name + email + role chip. It is text, not a `menuitem`: the\n * arrow keys pass over it.\n */\nexport interface TopBarMenuHeader {\n /** The first line — the user's name. */\n title: ReactNode;\n /** The muted second line — an email, a role. */\n subtitle?: ReactNode;\n /**\n * Anything below — a role chip. A link or button here stays out of the arrow keys\n * and in the Tab order, like the footer's.\n *\n * Pass a function to get `close`, as `footer` does — keksdose F7: its admin role\n * chip links to the admin area, and a router link does not unmount the menu, so\n * without `close` the panel stayed open over the page it had just navigated to.\n */\n extra?: ReactNode | ((close: () => void) => ReactNode);\n}\n\n/** What a control is, as far as `HoverMenu` is concerned, when it lives in the header\n * or the footer: not a menu row. */\nconst SECTION_CONTROLS = \"a[href]:not([role]),button:not([role])\";\nconst TABBABLE = 'a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]';\n\n/**\n * A header or footer inside the menu panel.\n *\n * `HoverMenu` promotes EVERY role-less button and link in its panel to a `menuitem` out\n * of the Tab order, and turns every list into `role=\"none\"` — right for the rows, wrong\n * for a footer of legal links, which would join the arrow-key cycle and drop out of Tab.\n * So before it looks (a child's layout effect runs before its parent's), the controls\n * in here get their own role spelled out, which `HoverMenu` leaves alone, and any list\n * keeps its list semantics.\n */\nfunction MenuSection({ className, children }: { className: string; children: ReactNode }) {\n const ref = useRef<HTMLLIElement>(null);\n useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n for (const c of el.querySelectorAll<HTMLElement>(SECTION_CONTROLS)) {\n c.setAttribute(\"role\", c.tagName === \"A\" ? \"link\" : \"button\");\n }\n for (const l of el.querySelectorAll<HTMLElement>(\"ul:not([role]),ol:not([role])\")) l.setAttribute(\"role\", \"list\");\n for (const l of el.querySelectorAll<HTMLElement>(\"li:not([role])\")) l.setAttribute(\"role\", \"listitem\");\n });\n return (\n <li ref={ref} role=\"none\" className={className}>\n {children}\n </li>\n );\n}\n\n/**\n * `HoverMenu` closes on any Tab inside the panel — right when Tab leaves it, wrong when\n * Tab is on its way from a row to a footer link, or from one footer link to the next:\n * the panel would unmount under the focus. So a Tab whose next stop is still inside the\n * panel stops here and the browser moves focus; one that leaves reaches `HoverMenu`,\n * which closes.\n */\nfunction keepTabInsidePanel(e: ReactKeyboardEvent<HTMLUListElement>) {\n if (e.key !== \"Tab\") return;\n const from = e.target as HTMLElement;\n const stops = Array.from(e.currentTarget.querySelectorAll<HTMLElement>(TABBABLE)).filter(\n (el) => el.getAttribute(\"tabindex\") !== \"-1\",\n );\n const way = e.shiftKey ? Node.DOCUMENT_POSITION_PRECEDING : Node.DOCUMENT_POSITION_FOLLOWING;\n if (stops.some((el) => el !== from && from.compareDocumentPosition(el) & way)) e.stopPropagation();\n}\n\n/**\n * Names the trigger and the menu: one of the two spellings is required (API-1, refactor\n * audit 2026-10). `aria-label` wins when both are given. OptionSwitcherMenu has the same\n * type; both become a plain required `aria-label` when `ariaLabel` goes in 0.35.\n */\ntype RequiredMenuName =\n | {\n \"aria-label\": string;\n /** @deprecated 0.34 — use `aria-label`; removed in 0.35. */\n ariaLabel?: string;\n }\n | {\n \"aria-label\"?: string;\n /** @deprecated 0.34 — use `aria-label`; removed in 0.35. */\n ariaLabel: string;\n };\n\n/**\n * A top-bar icon button that opens a {@link HoverMenu} of actions and/or links,\n * with an optional uppercase heading and divider rules. Generic glue over the\n * shared top-bar chrome — e.g. the feedback launcher or the guided-tours menu —\n * so those call sites describe their rows as data instead of rebuilding the\n * trigger + list markup. For a checkmarked value-switcher use\n * {@link OptionSwitcherMenu} instead.\n *\n * It is also the ACCOUNT menu kastlan and keksdose each hand-build on `HoverMenu`: a\n * custom `trigger` (the avatar), a `header` (name + role / email), the rows, and a\n * free-content `footer` (the legal links).\n *\n * A long menu is grouped by topic with `{ kind: \"heading\" }` entries (0.23) — see\n * {@link TopBarMenuEntry}. There is no separate phone layout: the panel is the same\n * hover panel at 390px, kept inside the viewport by `HoverMenu`, and a heading wraps\n * rather than widening it.\n */\nexport function TopBarActionMenu({\n icon,\n iconBadge,\n trigger,\n triggerClassName,\n href,\n \"aria-label\": ariaLabelAttr,\n ariaLabel: ariaLabelProp,\n heading,\n header,\n entries,\n children,\n footer,\n footerLabel,\n align,\n panelClassName,\n}: {\n /** The trigger's face for the usual icon button. Ignored when `trigger` is given. */\n icon?: ReactNode;\n /**\n * A status dot in the top-end corner of `icon` — keksdose's unread-support dot on the\n * feedback trigger. Like `UserAvatar`'s `badge`, its `label` joins the trigger's name\n * (\"Send feedback 2 unread\"), so the dot is not something only the eye is told about.\n * Ignored with `trigger`: give the face its own badge there.\n */\n iconBadge?: UserAvatarBadge | null;\n /**\n * A face of your own for the trigger — the account menu's `UserAvatar`. It is drawn\n * INSIDE the kit's button, which keeps the wiring: `aria-haspopup`, `aria-expanded`,\n * the toggle, the keyboard. `open` is there for a chevron that turns.\n *\n * The button is named by `aria-label` followed by any readable text in the face — a\n * `UserAvatar` `badge` label reaches a screen reader that way (\"Account menu 3\n * unread\"), where an `aria-label` on the button would have hidden it. A\n * `UserAvatar`'s initials are `aria-hidden`, so the person's name is only in the\n * name if `aria-label` carries it (\"Marcel Eifert, account menu\").\n */\n trigger?: (state: { open: boolean }) => ReactNode;\n /** Extra classes for the trigger button — `rounded-full` round an avatar. */\n triggerClassName?: string;\n /**\n * Make the trigger a LINK to this route (keksdose dev #585, Marcel: \"clicking on the\n * guided tours icon shall lead to the tours page like the all tours element does\").\n * A click or Enter follows it and shuts the panel; hover still opens the panel after\n * the usual delay, and ↓/↑ on the focused trigger still open it onto the first/last\n * row, so the rows stay reachable by keyboard. A tap on a touch screen follows the\n * link — so use it where the destination offers everything the menu does. Rendered as\n * an `<a>` (the router's `Link`) with `aria-haspopup=\"menu\"` and `aria-expanded`,\n * named by `aria-label`: a link inside the kit's button would be interactive content\n * inside interactive content.\n */\n href?: string;\n heading?: string;\n /** A non-interactive identity block above the rows. */\n header?: TopBarMenuHeader;\n entries: TopBarMenuEntry[];\n /**\n * Rows the entry data cannot describe (a `Disclosure` sub-list, an app's own\n * section), after `entries`. Render `<li>`s holding `MenuItem`s or plain controls;\n * `close` shuts the menu.\n */\n children?: (close: () => void) => ReactNode;\n /**\n * Free content below the rows, behind a rule — the legal links. Its links and\n * buttons are NOT menu rows: the arrow keys skip them and Tab reaches them. Pass a\n * function to get `close` for the links' `onClick`.\n */\n footer?: ReactNode | ((close: () => void) => ReactNode);\n /** Wraps the footer in a `<nav>` with this name (\"Legal\"). Without it, a plain block. */\n footerLabel?: string;\n /** Which edge of the trigger the panel lines up with (see `HoverMenu`, whose type this\n * is: `left`/`right` are deprecated 0.34). Default `end`. */\n align?: HoverMenuProps[\"align\"];\n panelClassName?: string;\n} & RequiredMenuName) {\n // The DOM spelling wins; `ariaLabel` is the fallback for call sites not moved yet.\n const ariaLabel = ariaLabelAttr ?? ariaLabelProp;\n // Names the groups' headings for `aria-labelledby`. Positional rather than from the\n // entry's `key`, which is the caller's text and may hold a space — and a space in\n // `aria-labelledby` is a list separator.\n const uid = useId();\n return (\n <HoverMenu\n aria-label={ariaLabel}\n align={align}\n trigger={({ open, toggle, close }) => {\n // One element for both kinds: the router's link when `href` is set, else the\n // kit's button. Same classes and face either way.\n const control = (className: string, children: ReactNode, label?: string) =>\n href ? (\n <Link to={href} onClick={close} aria-label={label} className={className}>\n {children}\n </Link>\n ) : (\n <button type=\"button\" onClick={toggle} aria-label={label} className={className}>\n {children}\n </button>\n );\n if (trigger) {\n return control(\n cn(TOPBAR_TRIGGER_CLASS, \"relative\", triggerClassName),\n <>\n <span className=\"sr-only\">{ariaLabel}</span>\n {/* The space keeps the name from running into the face's text (\"Account\n menu3 unread\"); as a flex item it takes no room. */}\n {\" \"}\n {trigger({ open })}\n </>,\n );\n }\n if (iconBadge) {\n // Named by its content, like the custom-trigger branch, so the badge label is\n // part of the name; an `aria-label` would have hidden it.\n return control(\n cn(TOPBAR_TRIGGER_CLASS, \"relative\", triggerClassName),\n <>\n <span className=\"sr-only\">{ariaLabel}</span>{\" \"}\n <span aria-hidden className=\"relative inline-flex\">\n {icon}\n <StatusDot ring tone={iconBadge.tone ?? \"danger\"} className=\"absolute -end-0.5 -top-0.5\" />\n </span>{\" \"}\n <span className=\"sr-only\">{iconBadge.label}</span>\n </>,\n );\n }\n return control(cn(TOPBAR_TRIGGER_CLASS, triggerClassName), icon, ariaLabel);\n }}\n >\n {(close) => {\n const footerBody = typeof footer === \"function\" ? footer(close) : footer;\n const headerExtra = typeof header?.extra === \"function\" ? header.extra(close) : header?.extra;\n const footerClass =\n \"flex flex-wrap gap-x-3 gap-y-1 text-xs text-muted [&_a:hover]:text-primary [&_a]:rounded-sm [&_a:focus-visible]:outline-none [&_a:focus-visible]:ring-focus [&_a:focus-visible]:ring-brand\";\n /** One action or link row — loose, or inside a heading's group. */\n const row = (entry: RowEntry) => (\n <li key={entry.key}>\n {entry.kind === \"link\" ? (\n <MenuItem\n href={entry.to}\n renderLink={({ href, ...p }) => <Link to={href} {...p} />}\n onClick={close}\n leading={entry.icon}\n trailing={entry.trailing}\n tone={entry.tone}\n current={entry.current}\n disabled={entry.disabled}\n >\n {entry.label}\n </MenuItem>\n ) : (\n <MenuItem\n onClick={() => {\n entry.onSelect();\n close();\n }}\n leading={entry.icon}\n trailing={entry.trailing}\n tone={entry.tone}\n checked={entry.checked}\n checkable={entry.checkable}\n disabled={entry.disabled}\n >\n {entry.label}\n </MenuItem>\n )}\n </li>\n );\n return (\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- a Tab bubbling up from a row or footer link, see keepTabInsidePanel\n <ul className={cn(\"py-1\", panelClassName)} onKeyDown={keepTabInsidePanel}>\n {header && (\n <MenuSection className=\"mb-1 border-b border-subtle px-3 py-2\">\n <div className=\"truncate text-sm font-medium text-primary\">{header.title}</div>\n {header.subtitle != null && (\n <div className=\"truncate text-xs text-muted\">{header.subtitle}</div>\n )}\n {headerExtra != null && headerExtra !== false && <div className=\"mt-1\">{headerExtra}</div>}\n </MenuSection>\n )}\n {heading && (\n <li className=\"px-3 py-1 text-micro font-semibold uppercase tracking-wide text-placeholder\">\n {heading}\n </li>\n )}\n {toBlocks(entries).map((block, i, blocks) => {\n if (block.kind === \"loose\") {\n const entry = block.entry;\n if (entry.kind === \"divider\") {\n return <li key={entry.key} className=\"my-1 border-t border-subtle\" />;\n }\n return row(entry);\n }\n const headingId = `${uid}-group-${i}`;\n const before = blocks[i - 1];\n // Under a rule (or at the top of the rows) the rule's margin is the gap;\n // straight under another group's last row the heading makes its own.\n const tight = !before || (before.kind === \"loose\" && before.entry.kind === \"divider\");\n return (\n <li key={block.heading.key} role=\"none\">\n <div\n id={headingId}\n role=\"presentation\"\n className={cn(\n \"px-3 pb-0.5 text-caption font-semibold uppercase tracking-wide text-muted [overflow-wrap:anywhere]\",\n tight ? \"pt-1\" : \"pt-2.5\",\n )}\n >\n {block.heading.label}\n </div>\n <ul role=\"group\" aria-labelledby={headingId}>\n {block.rows.map(row)}\n </ul>\n </li>\n );\n })}\n {children?.(close)}\n {footerBody != null && footerBody !== false && (\n <MenuSection className=\"mt-1 border-t border-subtle px-3 py-2\">\n {footerLabel ? (\n <nav aria-label={footerLabel} className={footerClass}>\n {footerBody}\n </nav>\n ) : (\n <div className={footerClass}>{footerBody}</div>\n )}\n </MenuSection>\n )}\n </ul>\n );\n }}\n </HoverMenu>\n );\n}\n"],"mappings":";AA8JI,SA8JQ,UA9JR,KA8JQ,YA9JR;AA9JJ,SAAS,OAAO,iBAAiB,cAAc;AAE/C,SAAS,YAAY;AACrB,SAAS,UAAU;AACnB,SAAS,iBAAsC;AAC/C,SAAS,gBAAgB;AAEzB,SAAS,iBAAiB;AAE1B,SAAS,4BAA4B;AAiFrC,SAAS,SAAS,SAA8C;AAC9D,QAAM,SAAkB,CAAC;AACzB,MAAI,QAAkD;AACtD,aAAW,SAAS,SAAS;AAC3B,QAAI,MAAM,SAAS,WAAW;AAC5B,cAAQ,EAAE,MAAM,SAAS,SAAS,OAAO,MAAM,CAAC,EAAE;AAClD,aAAO,KAA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,OAAO,GAAG,WAAW;AAC3C,kBAAI,MAAM,SAAS,SAAS;AAC1B,sBAAM,QAAQ,MAAM;AACpB,oBAAI,MAAM,SAAS,WAAW;AAC5B,yBAAO,oBAAC,QAAmB,WAAU,iCAArB,MAAM,GAA6C;AAAA,gBACrE;AACA,uBAAO,IAAI,KAAK;AAAA,cAClB;AACA,oBAAM,YAAY,GAAG,GAAG,UAAU,CAAC;AACnC,oBAAM,SAAS,OAAO,IAAI,CAAC;AAG3B,oBAAM,QAAQ,CAAC,UAAW,OAAO,SAAS,WAAW,OAAO,MAAM,SAAS;AAC3E,qBACE,qBAAC,QAA2B,MAAK,QAC/B;AAAA;AAAA,kBAAC;AAAA;AAAA,oBACC,IAAI;AAAA,oBACJ,MAAK;AAAA,oBACL,WAAW;AAAA,sBACT;AAAA,sBACA,QAAQ,SAAS;AAAA,oBACnB;AAAA,oBAEC,gBAAM,QAAQ;AAAA;AAAA,gBACjB;AAAA,gBACA,oBAAC,QAAG,MAAK,SAAQ,mBAAiB,WAC/B,gBAAM,KAAK,IAAI,GAAG,GACrB;AAAA,mBAbO,MAAM,QAAQ,GAcvB;AAAA,YAEJ,CAAC;AAAA,YACA,WAAW,KAAK;AAAA,YAChB,cAAc,QAAQ,eAAe,SACpC,oBAAC,eAAY,WAAU,yCACpB,wBACC,oBAAC,SAAI,cAAY,aAAa,WAAW,aACtC,sBACH,IAEA,oBAAC,SAAI,WAAW,aAAc,sBAAW,GAE7C;AAAA,aAEJ;AAAA;AAAA,MAEJ;AAAA;AAAA,EACF;AAEJ;","names":["children","href"]}
|
|
1
|
+
{"version":3,"sources":["../../src/shell/topbar-action-menu.tsx"],"sourcesContent":["import { useId, useLayoutEffect, useRef } from \"react\";\nimport type { KeyboardEvent as ReactKeyboardEvent, ReactNode } from \"react\";\nimport { Link } from \"react-router\";\nimport { cn } from \"../lib/cn\";\nimport { HoverMenu, type HoverMenuProps } from \"../components/hover-menu\";\nimport { MenuItem } from \"../components/menu-item\";\nimport type { MenuItemTone } from \"../components/menu-item\";\nimport { StatusDot } from \"../components/status-dot\";\nimport type { UserAvatarBadge } from \"../components/user-avatar\";\nimport { TOPBAR_TRIGGER_CLASS } from \"./topbar-controls\";\n\n/**\n * One row of a {@link TopBarActionMenu}. An `action` (default) runs `onSelect`, a\n * `link` navigates via react-router, a `divider` draws a rule, and a `heading` names\n * the rows after it. Action and link rows close the menu automatically when chosen.\n * `kind` may be omitted for actions, keeping the common case terse.\n *\n * The rows are {@link MenuItem}s, so they take its options: `tone: \"danger\"` for the\n * log-out row, `checked` (+ `checkable`) for a choice, `current` for the link to the\n * page already open, `disabled`.\n */\nexport type TopBarMenuEntry =\n | {\n kind?: \"action\";\n key: string;\n icon?: ReactNode;\n label: ReactNode;\n trailing?: ReactNode;\n onSelect: () => void;\n tone?: MenuItemTone;\n /** Makes the row a choice (`menuitemradio`, or `menuitemcheckbox` with\n * `checkable: \"checkbox\"`) and says whether it is chosen. */\n checked?: boolean;\n checkable?: \"radio\" | \"checkbox\";\n disabled?: boolean;\n }\n | {\n kind: \"link\";\n key: string;\n icon?: ReactNode;\n label: ReactNode;\n trailing?: ReactNode;\n to: string;\n tone?: MenuItemTone;\n /** The link to the page already open: `aria-current=\"page\"` and a check mark. */\n current?: boolean;\n disabled?: boolean;\n }\n | { kind: \"divider\"; key: string }\n | {\n /**\n * A group heading (0.23, keksdose's guided-tours menu): the rows after it, up to\n * the next heading, the next `divider` or the end of `entries`, are ONE group\n * named by `label`. keksdose files its tours by topic and separated the blocks\n * with bare dividers — \"the kit's menu has no heading row to name them with\"\n * (tour-menu.tsx) — so a sighted reader had to guess what each block was and a\n * screen reader was told nothing at all.\n *\n * Not a row: it takes no focus, the arrow keys (and Home/End) pass over it, and it\n * never closes the menu. It is announced the way the kit's other grouped lists\n * announce theirs (`CommandPalette`): the group's rows sit in a `role=\"group\"`\n * whose `aria-labelledby` is this heading, so a reader says \"On this page, group\"\n * when the focus enters the first row, and nothing between rows.\n *\n * A divider ENDS the group, so a closing row such as \"All tours…\" behind a rule\n * belongs to no topic. A heading with no rows under it is not drawn — an empty\n * group names nothing; build the list from data and it may well be empty.\n *\n * The menu-wide `heading` prop is the panel's title, drawn once above everything;\n * with group headings it is usually redundant (two stacked caps lines read as one),\n * and the trigger's `aria-label` already names the menu.\n */\n kind: \"heading\";\n key: string;\n /** The group's name, shown above its rows and announced as the group's name. Keep\n * it short: it is set in small caps and wraps on a narrow panel. */\n label: ReactNode;\n };\n\ntype HeadingEntry = Extract<TopBarMenuEntry, { kind: \"heading\" }>;\ntype DividerEntry = Extract<TopBarMenuEntry, { kind: \"divider\" }>;\ntype RowEntry = Exclude<TopBarMenuEntry, HeadingEntry | DividerEntry>;\n\n/** What the panel draws from `entries`: loose rows and rules, and headed groups. */\ntype Block = { kind: \"loose\"; entry: RowEntry | DividerEntry } | { kind: \"group\"; heading: HeadingEntry; rows: RowEntry[] };\n\n/**\n * Cut `entries` into blocks: a heading opens a group that takes the rows after it until\n * the next heading or divider; everything else stands alone, as it always has.\n */\nfunction toBlocks(entries: readonly TopBarMenuEntry[]): Block[] {\n const blocks: Block[] = [];\n let group: Extract<Block, { kind: \"group\" }> | null = null;\n for (const entry of entries) {\n if (entry.kind === \"heading\") {\n group = { kind: \"group\", heading: entry, rows: [] };\n blocks.push(group);\n } else if (entry.kind === \"divider\") {\n group = null;\n blocks.push({ kind: \"loose\", entry });\n } else if (group) {\n group.rows.push(entry);\n } else {\n blocks.push({ kind: \"loose\", entry });\n }\n }\n // A heading with nothing under it names nothing: not drawn (see the `heading` kind).\n return blocks.filter((block) => block.kind === \"loose\" || block.rows.length > 0);\n}\n\n/**\n * The non-interactive identity block at the top of an account menu — kastlan's name +\n * role, keksdose's display name + email + role chip. It is text, not a `menuitem`: the\n * arrow keys pass over it.\n */\nexport interface TopBarMenuHeader {\n /** The first line — the user's name. */\n title: ReactNode;\n /** The muted second line — an email, a role. */\n subtitle?: ReactNode;\n /**\n * Anything below — a role chip. A link or button here stays out of the arrow keys\n * and in the Tab order, like the footer's.\n *\n * Pass a function to get `close`, as `footer` does — keksdose F7: its admin role\n * chip links to the admin area, and a router link does not unmount the menu, so\n * without `close` the panel stayed open over the page it had just navigated to.\n */\n extra?: ReactNode | ((close: () => void) => ReactNode);\n}\n\n/** What a control is, as far as `HoverMenu` is concerned, when it lives in the header\n * or the footer: not a menu row. */\nconst SECTION_CONTROLS = \"a[href]:not([role]),button:not([role])\";\nconst TABBABLE = 'a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]';\n\n/**\n * A header or footer inside the menu panel.\n *\n * `HoverMenu` promotes EVERY role-less button and link in its panel to a `menuitem` out\n * of the Tab order, and turns every list into `role=\"none\"` — right for the rows, wrong\n * for a footer of legal links, which would join the arrow-key cycle and drop out of Tab.\n * So before it looks (a child's layout effect runs before its parent's), the controls\n * in here get their own role spelled out, which `HoverMenu` leaves alone, and any list\n * keeps its list semantics.\n */\nfunction MenuSection({ className, children }: { className: string; children: ReactNode }) {\n const ref = useRef<HTMLLIElement>(null);\n useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n for (const c of el.querySelectorAll<HTMLElement>(SECTION_CONTROLS)) {\n c.setAttribute(\"role\", c.tagName === \"A\" ? \"link\" : \"button\");\n }\n for (const l of el.querySelectorAll<HTMLElement>(\"ul:not([role]),ol:not([role])\")) l.setAttribute(\"role\", \"list\");\n for (const l of el.querySelectorAll<HTMLElement>(\"li:not([role])\")) l.setAttribute(\"role\", \"listitem\");\n });\n return (\n <li ref={ref} role=\"none\" className={className}>\n {children}\n </li>\n );\n}\n\n/**\n * `HoverMenu` closes on any Tab inside the panel — right when Tab leaves it, wrong when\n * Tab is on its way from a row to a footer link, or from one footer link to the next:\n * the panel would unmount under the focus. So a Tab whose next stop is still inside the\n * panel stops here and the browser moves focus; one that leaves reaches `HoverMenu`,\n * which closes.\n */\nfunction keepTabInsidePanel(e: ReactKeyboardEvent<HTMLUListElement>) {\n if (e.key !== \"Tab\") return;\n const from = e.target as HTMLElement;\n const stops = Array.from(e.currentTarget.querySelectorAll<HTMLElement>(TABBABLE)).filter(\n (el) => el.getAttribute(\"tabindex\") !== \"-1\",\n );\n const way = e.shiftKey ? Node.DOCUMENT_POSITION_PRECEDING : Node.DOCUMENT_POSITION_FOLLOWING;\n if (stops.some((el) => el !== from && from.compareDocumentPosition(el) & way)) e.stopPropagation();\n}\n\n/**\n * A top-bar icon button that opens a {@link HoverMenu} of actions and/or links,\n * with an optional uppercase heading and divider rules. Generic glue over the\n * shared top-bar chrome — e.g. the feedback launcher or the guided-tours menu —\n * so those call sites describe their rows as data instead of rebuilding the\n * trigger + list markup. For a checkmarked value-switcher use\n * {@link OptionSwitcherMenu} instead.\n *\n * It is also the ACCOUNT menu kastlan and keksdose each hand-build on `HoverMenu`: a\n * custom `trigger` (the avatar), a `header` (name + role / email), the rows, and a\n * free-content `footer` (the legal links).\n *\n * A long menu is grouped by topic with `{ kind: \"heading\" }` entries (0.23) — see\n * {@link TopBarMenuEntry}. There is no separate phone layout: the panel is the same\n * hover panel at 390px, kept inside the viewport by `HoverMenu`, and a heading wraps\n * rather than widening it.\n */\nexport function TopBarActionMenu({\n icon,\n iconBadge,\n trigger,\n triggerClassName,\n href,\n \"aria-label\": ariaLabel,\n heading,\n header,\n entries,\n children,\n footer,\n footerLabel,\n align,\n panelClassName,\n}: {\n /** The trigger's face for the usual icon button. Ignored when `trigger` is given. */\n icon?: ReactNode;\n /**\n * A status dot in the top-end corner of `icon` — keksdose's unread-support dot on the\n * feedback trigger. Like `UserAvatar`'s `badge`, its `label` joins the trigger's name\n * (\"Send feedback 2 unread\"), so the dot is not something only the eye is told about.\n * Ignored with `trigger`: give the face its own badge there.\n */\n iconBadge?: UserAvatarBadge | null;\n /**\n * A face of your own for the trigger — the account menu's `UserAvatar`. It is drawn\n * INSIDE the kit's button, which keeps the wiring: `aria-haspopup`, `aria-expanded`,\n * the toggle, the keyboard. `open` is there for a chevron that turns.\n *\n * The button is named by `aria-label` followed by any readable text in the face — a\n * `UserAvatar` `badge` label reaches a screen reader that way (\"Account menu 3\n * unread\"), where an `aria-label` on the button would have hidden it. A\n * `UserAvatar`'s initials are `aria-hidden`, so the person's name is only in the\n * name if `aria-label` carries it (\"Marcel Eifert, account menu\").\n */\n trigger?: (state: { open: boolean }) => ReactNode;\n /** Extra classes for the trigger button — `rounded-full` round an avatar. */\n triggerClassName?: string;\n /**\n * Make the trigger a LINK to this route (keksdose dev #585, Marcel: \"clicking on the\n * guided tours icon shall lead to the tours page like the all tours element does\").\n * A click or Enter follows it and shuts the panel; hover still opens the panel after\n * the usual delay, and ↓/↑ on the focused trigger still open it onto the first/last\n * row, so the rows stay reachable by keyboard. A tap on a touch screen follows the\n * link — so use it where the destination offers everything the menu does. Rendered as\n * an `<a>` (the router's `Link`) with `aria-haspopup=\"menu\"` and `aria-expanded`,\n * named by `aria-label`: a link inside the kit's button would be interactive content\n * inside interactive content.\n */\n href?: string;\n /** Names the trigger and the menu. Required: the trigger is an icon (refactor audit\n * 2026-10, API-1 — the `ariaLabel` spelling went in 0.35). */\n \"aria-label\": string;\n heading?: string;\n /** A non-interactive identity block above the rows. */\n header?: TopBarMenuHeader;\n entries: TopBarMenuEntry[];\n /**\n * Rows the entry data cannot describe (a `Disclosure` sub-list, an app's own\n * section), after `entries`. Render `<li>`s holding `MenuItem`s or plain controls;\n * `close` shuts the menu.\n */\n children?: (close: () => void) => ReactNode;\n /**\n * Free content below the rows, behind a rule — the legal links. Its links and\n * buttons are NOT menu rows: the arrow keys skip them and Tab reaches them. Pass a\n * function to get `close` for the links' `onClick`.\n */\n footer?: ReactNode | ((close: () => void) => ReactNode);\n /** Wraps the footer in a `<nav>` with this name (\"Legal\"). Without it, a plain block. */\n footerLabel?: string;\n /** Which edge of the trigger the panel lines up with, `start` or `end` in the reading\n * direction (see `HoverMenu`, whose type this is). Default `end`. */\n align?: HoverMenuProps[\"align\"];\n panelClassName?: string;\n}) {\n // Names the groups' headings for `aria-labelledby`. Positional rather than from the\n // entry's `key`, which is the caller's text and may hold a space — and a space in\n // `aria-labelledby` is a list separator.\n const uid = useId();\n return (\n <HoverMenu\n aria-label={ariaLabel}\n align={align}\n trigger={({ open, toggle, close }) => {\n // One element for both kinds: the router's link when `href` is set, else the\n // kit's button. Same classes and face either way.\n const control = (className: string, children: ReactNode, label?: string) =>\n href ? (\n <Link to={href} onClick={close} aria-label={label} className={className}>\n {children}\n </Link>\n ) : (\n <button type=\"button\" onClick={toggle} aria-label={label} className={className}>\n {children}\n </button>\n );\n if (trigger) {\n return control(\n cn(TOPBAR_TRIGGER_CLASS, \"relative\", triggerClassName),\n <>\n <span className=\"sr-only\">{ariaLabel}</span>\n {/* The space keeps the name from running into the face's text (\"Account\n menu3 unread\"); as a flex item it takes no room. */}\n {\" \"}\n {trigger({ open })}\n </>,\n );\n }\n if (iconBadge) {\n // Named by its content, like the custom-trigger branch, so the badge label is\n // part of the name; an `aria-label` would have hidden it.\n return control(\n cn(TOPBAR_TRIGGER_CLASS, \"relative\", triggerClassName),\n <>\n <span className=\"sr-only\">{ariaLabel}</span>{\" \"}\n <span aria-hidden className=\"relative inline-flex\">\n {icon}\n <StatusDot ring tone={iconBadge.tone ?? \"danger\"} className=\"absolute -end-0.5 -top-0.5\" />\n </span>{\" \"}\n <span className=\"sr-only\">{iconBadge.label}</span>\n </>,\n );\n }\n return control(cn(TOPBAR_TRIGGER_CLASS, triggerClassName), icon, ariaLabel);\n }}\n >\n {(close) => {\n const footerBody = typeof footer === \"function\" ? footer(close) : footer;\n const headerExtra = typeof header?.extra === \"function\" ? header.extra(close) : header?.extra;\n const footerClass =\n \"flex flex-wrap gap-x-3 gap-y-1 text-xs text-muted [&_a:hover]:text-primary [&_a]:rounded-sm [&_a:focus-visible]:outline-none [&_a:focus-visible]:ring-focus [&_a:focus-visible]:ring-brand\";\n /** One action or link row — loose, or inside a heading's group. */\n const row = (entry: RowEntry) => (\n <li key={entry.key}>\n {entry.kind === \"link\" ? (\n <MenuItem\n href={entry.to}\n renderLink={({ href, ...p }) => <Link to={href} {...p} />}\n onClick={close}\n leading={entry.icon}\n trailing={entry.trailing}\n tone={entry.tone}\n current={entry.current}\n disabled={entry.disabled}\n >\n {entry.label}\n </MenuItem>\n ) : (\n <MenuItem\n onClick={() => {\n entry.onSelect();\n close();\n }}\n leading={entry.icon}\n trailing={entry.trailing}\n tone={entry.tone}\n checked={entry.checked}\n checkable={entry.checkable}\n disabled={entry.disabled}\n >\n {entry.label}\n </MenuItem>\n )}\n </li>\n );\n return (\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- a Tab bubbling up from a row or footer link, see keepTabInsidePanel\n <ul className={cn(\"py-1\", panelClassName)} onKeyDown={keepTabInsidePanel}>\n {header && (\n <MenuSection className=\"mb-1 border-b border-subtle px-3 py-2\">\n <div className=\"truncate text-sm font-medium text-primary\">{header.title}</div>\n {header.subtitle != null && (\n <div className=\"truncate text-xs text-muted\">{header.subtitle}</div>\n )}\n {headerExtra != null && headerExtra !== false && <div className=\"mt-1\">{headerExtra}</div>}\n </MenuSection>\n )}\n {heading && (\n <li className=\"px-3 py-1 text-micro font-semibold uppercase tracking-wide text-placeholder\">\n {heading}\n </li>\n )}\n {toBlocks(entries).map((block, i, blocks) => {\n if (block.kind === \"loose\") {\n const entry = block.entry;\n if (entry.kind === \"divider\") {\n return <li key={entry.key} className=\"my-1 border-t border-subtle\" />;\n }\n return row(entry);\n }\n const headingId = `${uid}-group-${i}`;\n const before = blocks[i - 1];\n // Under a rule (or at the top of the rows) the rule's margin is the gap;\n // straight under another group's last row the heading makes its own.\n const tight = !before || (before.kind === \"loose\" && before.entry.kind === \"divider\");\n return (\n <li key={block.heading.key} role=\"none\">\n <div\n id={headingId}\n role=\"presentation\"\n className={cn(\n \"px-3 pb-0.5 text-caption font-semibold uppercase tracking-wide text-muted [overflow-wrap:anywhere]\",\n tight ? \"pt-1\" : \"pt-2.5\",\n )}\n >\n {block.heading.label}\n </div>\n <ul role=\"group\" aria-labelledby={headingId}>\n {block.rows.map(row)}\n </ul>\n </li>\n );\n })}\n {children?.(close)}\n {footerBody != null && footerBody !== false && (\n <MenuSection className=\"mt-1 border-t border-subtle px-3 py-2\">\n {footerLabel ? (\n <nav aria-label={footerLabel} className={footerClass}>\n {footerBody}\n </nav>\n ) : (\n <div className={footerClass}>{footerBody}</div>\n )}\n </MenuSection>\n )}\n </ul>\n );\n }}\n </HoverMenu>\n );\n}\n"],"mappings":";AA8JI,SA6IQ,UA7IR,KA6IQ,YA7IR;AA9JJ,SAAS,OAAO,iBAAiB,cAAc;AAE/C,SAAS,YAAY;AACrB,SAAS,UAAU;AACnB,SAAS,iBAAsC;AAC/C,SAAS,gBAAgB;AAEzB,SAAS,iBAAiB;AAE1B,SAAS,4BAA4B;AAiFrC,SAAS,SAAS,SAA8C;AAC9D,QAAM,SAAkB,CAAC;AACzB,MAAI,QAAkD;AACtD,aAAW,SAAS,SAAS;AAC3B,QAAI,MAAM,SAAS,WAAW;AAC5B,cAAQ,EAAE,MAAM,SAAS,SAAS,OAAO,MAAM,CAAC,EAAE;AAClD,aAAO,KAAK,KAAK;AAAA,IACnB,WAAW,MAAM,SAAS,WAAW;AACnC,cAAQ;AACR,aAAO,KAAK,EAAE,MAAM,SAAS,MAAM,CAAC;AAAA,IACtC,WAAW,OAAO;AAChB,YAAM,KAAK,KAAK,KAAK;AAAA,IACvB,OAAO;AACL,aAAO,KAAK,EAAE,MAAM,SAAS,MAAM,CAAC;AAAA,IACtC;AAAA,EACF;AAEA,SAAO,OAAO,OAAO,CAAC,UAAU,MAAM,SAAS,WAAW,MAAM,KAAK,SAAS,CAAC;AACjF;AAyBA,MAAM,mBAAmB;AACzB,MAAM,WAAW;AAYjB,SAAS,YAAY,EAAE,WAAW,SAAS,GAA+C;AACxF,QAAM,MAAM,OAAsB,IAAI;AACtC,kBAAgB,MAAM;AACpB,UAAM,KAAK,IAAI;AACf,QAAI,CAAC,GAAI;AACT,eAAW,KAAK,GAAG,iBAA8B,gBAAg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AAC,QAAG,MAAK,SAAQ,mBAAiB,WAC/B,gBAAM,KAAK,IAAI,GAAG,GACrB;AAAA,mBAbO,MAAM,QAAQ,GAcvB;AAAA,YAEJ,CAAC;AAAA,YACA,WAAW,KAAK;AAAA,YAChB,cAAc,QAAQ,eAAe,SACpC,oBAAC,eAAY,WAAU,yCACpB,wBACC,oBAAC,SAAI,cAAY,aAAa,WAAW,aACtC,sBACH,IAEA,oBAAC,SAAI,WAAW,aAAc,sBAAW,GAE7C;AAAA,aAEJ;AAAA;AAAA,MAEJ;AAAA;AAAA,EACF;AAEJ;","names":["children","href"]}
|
|
@@ -7,29 +7,23 @@ export declare const TOPBAR_TRIGGER_CLASS = "size-9 rounded-md flex items-center
|
|
|
7
7
|
* wraps aligns to the reading edge in RTL too. */
|
|
8
8
|
export declare const TOPBAR_MENU_ITEM_CLASS = "flex w-full items-center justify-between gap-3 px-3 py-2 text-sm text-start text-secondary hover:bg-hover";
|
|
9
9
|
/** Sun/Moon toggle for the light/dark theme. Controlled: the app owns the mode. */
|
|
10
|
-
export declare function ThemeToggle({ mode, onToggle, "aria-label":
|
|
10
|
+
export declare function ThemeToggle({ mode, onToggle, "aria-label": ariaLabel, title, className, }: {
|
|
11
11
|
mode: ThemeMode;
|
|
12
12
|
onToggle: () => void;
|
|
13
13
|
/** Default: `topBar.theme` from the {@link UiKitProvider}, else English. */
|
|
14
14
|
"aria-label"?: string;
|
|
15
|
-
/** @deprecated 0.34 — use `aria-label`; removed in 0.35 (refactor audit 2026-10, API-1).
|
|
16
|
-
* Names the control only when `aria-label` is absent. */
|
|
17
|
-
ariaLabel?: string;
|
|
18
15
|
title?: string;
|
|
19
16
|
className?: string;
|
|
20
17
|
}): import("react").JSX.Element;
|
|
21
18
|
/** Appearance-preset switcher: a hover menu of palette presets with per-theme
|
|
22
19
|
* colour swatches. Controlled — the app owns the active id and applies it. */
|
|
23
|
-
export declare function PaletteMenu({ palettes, activeId, mode, onSelect, "aria-label":
|
|
20
|
+
export declare function PaletteMenu({ palettes, activeId, mode, onSelect, "aria-label": ariaLabel, heading, }: {
|
|
24
21
|
palettes: PalettePreset[];
|
|
25
22
|
activeId: string;
|
|
26
23
|
mode: ThemeMode;
|
|
27
24
|
onSelect: (id: string) => void;
|
|
28
25
|
/** Default: `topBar.palette` from the {@link UiKitProvider}, else English. */
|
|
29
26
|
"aria-label"?: string;
|
|
30
|
-
/** @deprecated 0.34 — use `aria-label`; removed in 0.35 (refactor audit 2026-10, API-1).
|
|
31
|
-
* Names the control only when `aria-label` is absent. */
|
|
32
|
-
ariaLabel?: string;
|
|
33
27
|
/** Optional small heading row above the list. */
|
|
34
28
|
heading?: string;
|
|
35
29
|
}): import("react").JSX.Element;
|
|
@@ -48,15 +42,12 @@ export interface LanguageOption {
|
|
|
48
42
|
* (Keksdose feedback #121). The flag also shows which language is currently on,
|
|
49
43
|
* which no icon can, and costs the same width on a crowded mobile bar. A globe
|
|
50
44
|
* covers the case where `current` matches nothing in `options`. */
|
|
51
|
-
export declare function LanguageMenu({ options, current, onChange, "aria-label":
|
|
45
|
+
export declare function LanguageMenu({ options, current, onChange, "aria-label": ariaLabel, heading, }: {
|
|
52
46
|
options: LanguageOption[];
|
|
53
47
|
current: string | undefined;
|
|
54
48
|
onChange: (code: string) => void;
|
|
55
49
|
/** Default: `topBar.language` from the {@link UiKitProvider}, else English. */
|
|
56
50
|
"aria-label"?: string;
|
|
57
|
-
/** @deprecated 0.34 — use `aria-label`; removed in 0.35 (refactor audit 2026-10, API-1).
|
|
58
|
-
* Names the control only when `aria-label` is absent. */
|
|
59
|
-
ariaLabel?: string;
|
|
60
51
|
/** Optional small heading row above the list — as on `TopBarActionMenu`,
|
|
61
52
|
* `OptionSwitcherMenu` and `PaletteMenu`. */
|
|
62
53
|
heading?: string;
|
|
@@ -13,12 +13,11 @@ function MenuHeading({ children }) {
|
|
|
13
13
|
function ThemeToggle({
|
|
14
14
|
mode,
|
|
15
15
|
onToggle,
|
|
16
|
-
"aria-label":
|
|
17
|
-
ariaLabel,
|
|
16
|
+
"aria-label": ariaLabel,
|
|
18
17
|
title,
|
|
19
18
|
className
|
|
20
19
|
}) {
|
|
21
|
-
const labels = useKitLabels("topBar", DEFAULT_TOP_BAR_LABELS, { theme:
|
|
20
|
+
const labels = useKitLabels("topBar", DEFAULT_TOP_BAR_LABELS, { theme: ariaLabel });
|
|
22
21
|
const Icon = mode === "dark" ? Moon : Sun;
|
|
23
22
|
return /* @__PURE__ */ jsx(Tooltip, { label: title, portal: true, children: /* @__PURE__ */ jsx(
|
|
24
23
|
"button",
|
|
@@ -36,11 +35,10 @@ function PaletteMenu({
|
|
|
36
35
|
activeId,
|
|
37
36
|
mode,
|
|
38
37
|
onSelect,
|
|
39
|
-
"aria-label":
|
|
40
|
-
ariaLabel,
|
|
38
|
+
"aria-label": ariaLabel,
|
|
41
39
|
heading
|
|
42
40
|
}) {
|
|
43
|
-
const labels = useKitLabels("topBar", DEFAULT_TOP_BAR_LABELS, { palette:
|
|
41
|
+
const labels = useKitLabels("topBar", DEFAULT_TOP_BAR_LABELS, { palette: ariaLabel });
|
|
44
42
|
const activeName = palettes.find((p) => p.id === activeId)?.name ?? activeId;
|
|
45
43
|
return /* @__PURE__ */ jsx(
|
|
46
44
|
HoverMenu,
|
|
@@ -98,11 +96,10 @@ function LanguageMenu({
|
|
|
98
96
|
options,
|
|
99
97
|
current,
|
|
100
98
|
onChange,
|
|
101
|
-
"aria-label":
|
|
102
|
-
ariaLabel,
|
|
99
|
+
"aria-label": ariaLabel,
|
|
103
100
|
heading
|
|
104
101
|
}) {
|
|
105
|
-
const labels = useKitLabels("topBar", DEFAULT_TOP_BAR_LABELS, { language:
|
|
102
|
+
const labels = useKitLabels("topBar", DEFAULT_TOP_BAR_LABELS, { language: ariaLabel });
|
|
106
103
|
const active = options.find((o) => o.code === current);
|
|
107
104
|
return /* @__PURE__ */ jsx(
|
|
108
105
|
HoverMenu,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/shell/topbar-controls.tsx"],"sourcesContent":["import { Check, Globe, Moon, Palette, Sun } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { HoverMenu } from \"../components/hover-menu\";\nimport type { PalettePreset } from \"../theme/palette-presets\";\nimport type { ThemeMode } from \"../theme/theme-store\";\nimport { Tooltip } from \"../components/tooltip\";\nimport { DEFAULT_TOP_BAR_LABELS, useKitLabels } from \"../i18n/kit-labels\";\n\n/** Shared square icon-button styling for top-bar triggers, so app-owned controls\n * (account/feedback menus) line up with the shared ones. */\nexport const TOPBAR_TRIGGER_CLASS =\n \"size-9 rounded-md flex items-center justify-center text-secondary hover:text-primary hover:bg-hover\";\n\n/** Shared row styling for the top-bar hover-menu items. `text-start`, so a label that\n * wraps aligns to the reading edge in RTL too. */\nexport const TOPBAR_MENU_ITEM_CLASS =\n \"flex w-full items-center justify-between gap-3 px-3 py-2 text-sm text-start text-secondary hover:bg-hover\";\n\n/** The small uppercase heading row the top-bar menus share (`heading`). */\nfunction MenuHeading({ children }: { children: string }) {\n return (\n <li className=\"px-3 py-1 text-micro font-semibold uppercase tracking-wide text-placeholder\">\n {children}\n </li>\n );\n}\n\n/** Sun/Moon toggle for the light/dark theme. Controlled: the app owns the mode. */\nexport function ThemeToggle({\n mode,\n onToggle,\n \"aria-label\": ariaLabelAttr,\n ariaLabel,\n title,\n className,\n}: {\n mode: ThemeMode;\n onToggle: () => void;\n /** Default: `topBar.theme` from the {@link UiKitProvider}, else English. */\n \"aria-label\"?: string;\n /** @deprecated 0.34 — use `aria-label`; removed in 0.35 (refactor audit 2026-10, API-1).\n * Names the control only when `aria-label` is absent. */\n ariaLabel?: string;\n title?: string;\n className?: string;\n}) {\n // This had no default at all, so a toggle rendered without `aria-label` was an\n // icon button with no name — a reader heard \"button\" and nothing else.\n const labels = useKitLabels(\"topBar\", DEFAULT_TOP_BAR_LABELS, { theme: ariaLabelAttr ?? ariaLabel });\n const Icon = mode === \"dark\" ? Moon : Sun;\n return (\n <Tooltip label={title} portal>\n <button\n type=\"button\"\n onClick={onToggle}\n aria-label={labels.theme}\n className={cn(TOPBAR_TRIGGER_CLASS, className)}\n >\n <Icon className=\"size-5\" />\n </button>\n </Tooltip>\n );\n}\n\n/** Appearance-preset switcher: a hover menu of palette presets with per-theme\n * colour swatches. Controlled — the app owns the active id and applies it. */\nexport function PaletteMenu({\n palettes,\n activeId,\n mode,\n onSelect,\n \"aria-label\": ariaLabelAttr,\n ariaLabel,\n heading,\n}: {\n palettes: PalettePreset[];\n activeId: string;\n mode: ThemeMode;\n onSelect: (id: string) => void;\n /** Default: `topBar.palette` from the {@link UiKitProvider}, else English. */\n \"aria-label\"?: string;\n /** @deprecated 0.34 — use `aria-label`; removed in 0.35 (refactor audit 2026-10, API-1).\n * Names the control only when `aria-label` is absent. */\n ariaLabel?: string;\n /** Optional small heading row above the list. */\n heading?: string;\n}) {\n const labels = useKitLabels(\"topBar\", DEFAULT_TOP_BAR_LABELS, { palette: ariaLabelAttr ?? ariaLabel });\n const activeName = palettes.find((p) => p.id === activeId)?.name ?? activeId;\n return (\n <HoverMenu\n aria-label={labels.palette}\n trigger={({ toggle }) => (\n <Tooltip label={activeName} portal>\n <button\n type=\"button\"\n onClick={toggle}\n aria-label={labels.palette}\n className={TOPBAR_TRIGGER_CLASS}\n >\n {/* A DATA colour, not a semantic one: the palette mark is the\n \"colour\" control, so it carries a colour, and which hue is\n arbitrary. `--chart-1` is the violet end of the CVD-safe\n categorical ramp and flips per theme — a fixed `violet-500` did\n not, and stayed a cool violet island on a warm page. */}\n <Palette className=\"size-5 text-[var(--chart-1)]\" />\n </button>\n </Tooltip>\n )}\n >\n {(close) => (\n <ul className=\"w-60 py-1\">\n {heading && <MenuHeading>{heading}</MenuHeading>}\n {palettes.map((p) => {\n const ts = p[mode];\n const swatches = [ts.bgPage, ts.brand, ts.moneyIncome, ts.moneyExpense, ts.moneyNet];\n return (\n <li key={p.id}>\n <button\n type=\"button\"\n onClick={() => {\n onSelect(p.id);\n close();\n }}\n className={TOPBAR_MENU_ITEM_CLASS}\n >\n <span className=\"flex min-w-0 items-center gap-2\">\n <span className=\"flex shrink-0 gap-0.5\">\n {/* Deliberately a neutral at 10% and not a token: this hairline\n sits on an ARBITRARY preset colour, so it has to read against\n whatever that preset paints, which no themed border does. */}\n {swatches.map((c, i) => (\n <span\n key={i}\n className=\"size-3.5 rounded-sm ring-1 ring-inset ring-black/10 dark:ring-white/10\"\n style={{ background: c }}\n />\n ))}\n </span>\n <span className=\"flex min-w-0 flex-col text-start\">\n <span className=\"truncate\">{p.name}</span>\n <span className=\"truncate text-caption text-placeholder\">\n {p.blurb}\n </span>\n </span>\n </span>\n {activeId === p.id && (\n <Check className=\"size-4 shrink-0 text-secondary\" />\n )}\n </button>\n </li>\n );\n })}\n </ul>\n )}\n </HoverMenu>\n );\n}\n\nexport interface LanguageOption {\n code: string;\n label: string;\n /** ISO 3166-1 alpha-2 country code (lowercase) for the flag-icons flag. */\n country: string;\n}\n\n/** Language switcher: a hover menu of options with flags and a check on the\n * active one. Controlled — the app owns the current code and change handler.\n *\n * The trigger is the *active* option's flag, not an icon: lucide's `Languages`\n * glyph (文A) is the same mark Chrome puts in the omnibox for \"translate this\n * page\", so it read as machine-translation rather than \"pick the UI language\"\n * (Keksdose feedback #121). The flag also shows which language is currently on,\n * which no icon can, and costs the same width on a crowded mobile bar. A globe\n * covers the case where `current` matches nothing in `options`. */\nexport function LanguageMenu({\n options,\n current,\n onChange,\n \"aria-label\": ariaLabelAttr,\n ariaLabel,\n heading,\n}: {\n options: LanguageOption[];\n current: string | undefined;\n onChange: (code: string) => void;\n /** Default: `topBar.language` from the {@link UiKitProvider}, else English. */\n \"aria-label\"?: string;\n /** @deprecated 0.34 — use `aria-label`; removed in 0.35 (refactor audit 2026-10, API-1).\n * Names the control only when `aria-label` is absent. */\n ariaLabel?: string;\n /** Optional small heading row above the list — as on `TopBarActionMenu`,\n * `OptionSwitcherMenu` and `PaletteMenu`. */\n heading?: string;\n}) {\n const labels = useKitLabels(\"topBar\", DEFAULT_TOP_BAR_LABELS, { language: ariaLabelAttr ?? ariaLabel });\n const active = options.find((o) => o.code === current);\n return (\n <HoverMenu\n aria-label={labels.language}\n trigger={({ toggle }) => (\n <Tooltip label={active?.label ?? labels.language} portal>\n <button\n type=\"button\"\n onClick={toggle}\n aria-label={labels.language}\n className={TOPBAR_TRIGGER_CLASS}\n >\n {active ? (\n <span\n aria-hidden\n className={`fi fi-${active.country} inline-block h-[0.9375rem] w-5 shrink-0 rounded-sm shadow-[0_0_0_1px_rgba(0,0,0,0.08)]`}\n />\n ) : (\n <Globe className=\"size-5\" />\n )}\n </button>\n </Tooltip>\n )}\n >\n {(close) => (\n <ul className=\"py-1\">\n {heading && <MenuHeading>{heading}</MenuHeading>}\n {options.map((lang) => {\n const isActive = lang.code === current;\n return (\n <li key={lang.code}>\n <button\n type=\"button\"\n onClick={() => {\n onChange(lang.code);\n close();\n }}\n className={TOPBAR_MENU_ITEM_CLASS}\n >\n <span className=\"flex items-center gap-2\">\n <span\n aria-hidden\n className={`fi fi-${lang.country} inline-block h-[0.9375rem] w-5 shrink-0 rounded-sm shadow-[0_0_0_1px_rgba(0,0,0,0.08)]`}\n />\n {lang.label}\n </span>\n {isActive && <Check className=\"size-4 text-secondary\" />}\n </button>\n </li>\n );\n })}\n </ul>\n )}\n </HoverMenu>\n );\n}\n"],"mappings":";AAqBI,cAsHgB,YAtHhB;AArBJ,SAAS,OAAO,OAAO,MAAM,SAAS,WAAW;AACjD,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAG1B,SAAS,eAAe;AACxB,SAAS,wBAAwB,oBAAoB;AAI9C,MAAM,uBACX;AAIK,MAAM,yBACX;AAGF,SAAS,YAAY,EAAE,SAAS,GAAyB;AACvD,SACE,oBAAC,QAAG,WAAU,+EACX,UACH;AAEJ;AAGO,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA;AACF,GA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AAC,UACA,qBAAC,QAAG,WAAU,QACX;AAAA,mBAAW,oBAAC,eAAa,mBAAQ;AAAA,QACjC,QAAQ,IAAI,CAAC,SAAS;AACrB,gBAAM,WAAW,KAAK,SAAS;AAC/B,iBACE,oBAAC,QACC;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,SAAS,MAAM;AACb,yBAAS,KAAK,IAAI;AAClB,sBAAM;AAAA,cACR;AAAA,cACA,WAAW;AAAA,cAEX;AAAA,qCAAC,UAAK,WAAU,2BACd;AAAA;AAAA,oBAAC;AAAA;AAAA,sBACC,eAAW;AAAA,sBACX,WAAW,SAAS,KAAK,OAAO;AAAA;AAAA,kBAClC;AAAA,kBACC,KAAK;AAAA,mBACR;AAAA,gBACC,YAAY,oBAAC,SAAM,WAAU,yBAAwB;AAAA;AAAA;AAAA,UACxD,KAjBO,KAAK,IAkBd;AAAA,QAEJ,CAAC;AAAA,SACH;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/shell/topbar-controls.tsx"],"sourcesContent":["import { Check, Globe, Moon, Palette, Sun } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { HoverMenu } from \"../components/hover-menu\";\nimport type { PalettePreset } from \"../theme/palette-presets\";\nimport type { ThemeMode } from \"../theme/theme-store\";\nimport { Tooltip } from \"../components/tooltip\";\nimport { DEFAULT_TOP_BAR_LABELS, useKitLabels } from \"../i18n/kit-labels\";\n\n/** Shared square icon-button styling for top-bar triggers, so app-owned controls\n * (account/feedback menus) line up with the shared ones. */\nexport const TOPBAR_TRIGGER_CLASS =\n \"size-9 rounded-md flex items-center justify-center text-secondary hover:text-primary hover:bg-hover\";\n\n/** Shared row styling for the top-bar hover-menu items. `text-start`, so a label that\n * wraps aligns to the reading edge in RTL too. */\nexport const TOPBAR_MENU_ITEM_CLASS =\n \"flex w-full items-center justify-between gap-3 px-3 py-2 text-sm text-start text-secondary hover:bg-hover\";\n\n/** The small uppercase heading row the top-bar menus share (`heading`). */\nfunction MenuHeading({ children }: { children: string }) {\n return (\n <li className=\"px-3 py-1 text-micro font-semibold uppercase tracking-wide text-placeholder\">\n {children}\n </li>\n );\n}\n\n/** Sun/Moon toggle for the light/dark theme. Controlled: the app owns the mode. */\nexport function ThemeToggle({\n mode,\n onToggle,\n \"aria-label\": ariaLabel,\n title,\n className,\n}: {\n mode: ThemeMode;\n onToggle: () => void;\n /** Default: `topBar.theme` from the {@link UiKitProvider}, else English. */\n \"aria-label\"?: string;\n title?: string;\n className?: string;\n}) {\n // This had no default at all, so a toggle rendered without `aria-label` was an\n // icon button with no name — a reader heard \"button\" and nothing else.\n const labels = useKitLabels(\"topBar\", DEFAULT_TOP_BAR_LABELS, { theme: ariaLabel });\n const Icon = mode === \"dark\" ? Moon : Sun;\n return (\n <Tooltip label={title} portal>\n <button\n type=\"button\"\n onClick={onToggle}\n aria-label={labels.theme}\n className={cn(TOPBAR_TRIGGER_CLASS, className)}\n >\n <Icon className=\"size-5\" />\n </button>\n </Tooltip>\n );\n}\n\n/** Appearance-preset switcher: a hover menu of palette presets with per-theme\n * colour swatches. Controlled — the app owns the active id and applies it. */\nexport function PaletteMenu({\n palettes,\n activeId,\n mode,\n onSelect,\n \"aria-label\": ariaLabel,\n heading,\n}: {\n palettes: PalettePreset[];\n activeId: string;\n mode: ThemeMode;\n onSelect: (id: string) => void;\n /** Default: `topBar.palette` from the {@link UiKitProvider}, else English. */\n \"aria-label\"?: string;\n /** Optional small heading row above the list. */\n heading?: string;\n}) {\n const labels = useKitLabels(\"topBar\", DEFAULT_TOP_BAR_LABELS, { palette: ariaLabel });\n const activeName = palettes.find((p) => p.id === activeId)?.name ?? activeId;\n return (\n <HoverMenu\n aria-label={labels.palette}\n trigger={({ toggle }) => (\n <Tooltip label={activeName} portal>\n <button\n type=\"button\"\n onClick={toggle}\n aria-label={labels.palette}\n className={TOPBAR_TRIGGER_CLASS}\n >\n {/* A DATA colour, not a semantic one: the palette mark is the\n \"colour\" control, so it carries a colour, and which hue is\n arbitrary. `--chart-1` is the violet end of the CVD-safe\n categorical ramp and flips per theme — a fixed `violet-500` did\n not, and stayed a cool violet island on a warm page. */}\n <Palette className=\"size-5 text-[var(--chart-1)]\" />\n </button>\n </Tooltip>\n )}\n >\n {(close) => (\n <ul className=\"w-60 py-1\">\n {heading && <MenuHeading>{heading}</MenuHeading>}\n {palettes.map((p) => {\n const ts = p[mode];\n const swatches = [ts.bgPage, ts.brand, ts.moneyIncome, ts.moneyExpense, ts.moneyNet];\n return (\n <li key={p.id}>\n <button\n type=\"button\"\n onClick={() => {\n onSelect(p.id);\n close();\n }}\n className={TOPBAR_MENU_ITEM_CLASS}\n >\n <span className=\"flex min-w-0 items-center gap-2\">\n <span className=\"flex shrink-0 gap-0.5\">\n {/* Deliberately a neutral at 10% and not a token: this hairline\n sits on an ARBITRARY preset colour, so it has to read against\n whatever that preset paints, which no themed border does. */}\n {swatches.map((c, i) => (\n <span\n key={i}\n className=\"size-3.5 rounded-sm ring-1 ring-inset ring-black/10 dark:ring-white/10\"\n style={{ background: c }}\n />\n ))}\n </span>\n <span className=\"flex min-w-0 flex-col text-start\">\n <span className=\"truncate\">{p.name}</span>\n <span className=\"truncate text-caption text-placeholder\">\n {p.blurb}\n </span>\n </span>\n </span>\n {activeId === p.id && (\n <Check className=\"size-4 shrink-0 text-secondary\" />\n )}\n </button>\n </li>\n );\n })}\n </ul>\n )}\n </HoverMenu>\n );\n}\n\nexport interface LanguageOption {\n code: string;\n label: string;\n /** ISO 3166-1 alpha-2 country code (lowercase) for the flag-icons flag. */\n country: string;\n}\n\n/** Language switcher: a hover menu of options with flags and a check on the\n * active one. Controlled — the app owns the current code and change handler.\n *\n * The trigger is the *active* option's flag, not an icon: lucide's `Languages`\n * glyph (文A) is the same mark Chrome puts in the omnibox for \"translate this\n * page\", so it read as machine-translation rather than \"pick the UI language\"\n * (Keksdose feedback #121). The flag also shows which language is currently on,\n * which no icon can, and costs the same width on a crowded mobile bar. A globe\n * covers the case where `current` matches nothing in `options`. */\nexport function LanguageMenu({\n options,\n current,\n onChange,\n \"aria-label\": ariaLabel,\n heading,\n}: {\n options: LanguageOption[];\n current: string | undefined;\n onChange: (code: string) => void;\n /** Default: `topBar.language` from the {@link UiKitProvider}, else English. */\n \"aria-label\"?: string;\n /** Optional small heading row above the list — as on `TopBarActionMenu`,\n * `OptionSwitcherMenu` and `PaletteMenu`. */\n heading?: string;\n}) {\n const labels = useKitLabels(\"topBar\", DEFAULT_TOP_BAR_LABELS, { language: ariaLabel });\n const active = options.find((o) => o.code === current);\n return (\n <HoverMenu\n aria-label={labels.language}\n trigger={({ toggle }) => (\n <Tooltip label={active?.label ?? labels.language} portal>\n <button\n type=\"button\"\n onClick={toggle}\n aria-label={labels.language}\n className={TOPBAR_TRIGGER_CLASS}\n >\n {active ? (\n <span\n aria-hidden\n className={`fi fi-${active.country} inline-block h-[0.9375rem] w-5 shrink-0 rounded-sm shadow-[0_0_0_1px_rgba(0,0,0,0.08)]`}\n />\n ) : (\n <Globe className=\"size-5\" />\n )}\n </button>\n </Tooltip>\n )}\n >\n {(close) => (\n <ul className=\"py-1\">\n {heading && <MenuHeading>{heading}</MenuHeading>}\n {options.map((lang) => {\n const isActive = lang.code === current;\n return (\n <li key={lang.code}>\n <button\n type=\"button\"\n onClick={() => {\n onChange(lang.code);\n close();\n }}\n className={TOPBAR_MENU_ITEM_CLASS}\n >\n <span className=\"flex items-center gap-2\">\n <span\n aria-hidden\n className={`fi fi-${lang.country} inline-block h-[0.9375rem] w-5 shrink-0 rounded-sm shadow-[0_0_0_1px_rgba(0,0,0,0.08)]`}\n />\n {lang.label}\n </span>\n {isActive && <Check className=\"size-4 text-secondary\" />}\n </button>\n </li>\n );\n })}\n </ul>\n )}\n </HoverMenu>\n );\n}\n"],"mappings":";AAqBI,cA8GgB,YA9GhB;AArBJ,SAAS,OAAO,OAAO,MAAM,SAAS,WAAW;AACjD,SAAS,UAAU;AACnB,SAAS,iBAAiB;AA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T,cAAY,OAAO;AAAA,UACnB,WAAW;AAAA,UAEV,mBACC;AAAA,YAAC;AAAA;AAAA,cACC,eAAW;AAAA,cACX,WAAW,SAAS,OAAO,OAAO;AAAA;AAAA,UACpC,IAEA,oBAAC,SAAM,WAAU,UAAS;AAAA;AAAA,MAE9B,GACF;AAAA,MAGD,WAAC,UACA,qBAAC,QAAG,WAAU,QACX;AAAA,mBAAW,oBAAC,eAAa,mBAAQ;AAAA,QACjC,QAAQ,IAAI,CAAC,SAAS;AACrB,gBAAM,WAAW,KAAK,SAAS;AAC/B,iBACE,oBAAC,QACC;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,SAAS,MAAM;AACb,yBAAS,KAAK,IAAI;AAClB,sBAAM;AAAA,cACR;AAAA,cACA,WAAW;AAAA,cAEX;AAAA,qCAAC,UAAK,WAAU,2BACd;AAAA;AAAA,oBAAC;AAAA;AAAA,sBACC,eAAW;AAAA,sBACX,WAAW,SAAS,KAAK,OAAO;AAAA;AAAA,kBAClC;AAAA,kBACC,KAAK;AAAA,mBACR;AAAA,gBACC,YAAY,oBAAC,SAAM,WAAU,yBAAwB;AAAA;AAAA;AAAA,UACxD,KAjBO,KAAK,IAkBd;AAAA,QAEJ,CAAC;AAAA,SACH;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { KIT_CSS_VARIABLES, declaredCustomProperties, undeclaredCssVariables, type UndeclaredCssVariablesOptions, } from "./css-variables.js";
|
|
2
|
-
export { stubResizeObserver, stubViewportWidth, viewportMatchMedia, type ResizeObserverStub, type StubbedBoxSize, type ViewportOptions, } from "./viewport.js";
|
|
2
|
+
export { setViewportWidth, stubResizeObserver, stubViewportWidth, viewportMatchMedia, type ResizeObserverStub, type StubbedBoxSize, type ViewportOptions, } from "./viewport.js";
|
package/dist/testing/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
undeclaredCssVariables
|
|
6
6
|
} from "./css-variables.js";
|
|
7
7
|
import {
|
|
8
|
+
setViewportWidth,
|
|
8
9
|
stubResizeObserver,
|
|
9
10
|
stubViewportWidth,
|
|
10
11
|
viewportMatchMedia
|
|
@@ -12,6 +13,7 @@ import {
|
|
|
12
13
|
export {
|
|
13
14
|
KIT_CSS_VARIABLES,
|
|
14
15
|
declaredCustomProperties,
|
|
16
|
+
setViewportWidth,
|
|
15
17
|
stubResizeObserver,
|
|
16
18
|
stubViewportWidth,
|
|
17
19
|
undeclaredCssVariables,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/testing/index.ts"],"sourcesContent":["// `@eifi1/ui-kit/testing` — helpers an app runs from its OWN test suite (0.33).\n//\n// Not part of the main barrel: nothing here renders, and an app's production bundle has\n// no business carrying it. Browser-safe like the rest of the kit (no `node:fs`): each\n// helper takes texts, so an app collects them with `import.meta.glob` or `node:fs`, as\n// its setup allows. The first content is the guard against undeclared CSS custom\n// properties (docs/colour-roles-harmonization.md §8).\nexport {\n KIT_CSS_VARIABLES,\n declaredCustomProperties,\n undeclaredCssVariables,\n type UndeclaredCssVariablesOptions,\n} from \"./css-variables\";\n// 0.34 (refactor audit 2026-10, TST-10): the environment jsdom lacks — a `matchMedia`\n// that answers from a viewport width (right at every text size) and a `ResizeObserver`\n// the test drives. Framework-free: each returns its own undo.\nexport {\n stubResizeObserver,\n stubViewportWidth,\n viewportMatchMedia,\n type ResizeObserverStub,\n type StubbedBoxSize,\n type ViewportOptions,\n} from \"./viewport\";\n"],"mappings":";AAOA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;
|
|
1
|
+
{"version":3,"sources":["../../src/testing/index.ts"],"sourcesContent":["// `@eifi1/ui-kit/testing` — helpers an app runs from its OWN test suite (0.33).\n//\n// Not part of the main barrel: nothing here renders, and an app's production bundle has\n// no business carrying it. Browser-safe like the rest of the kit (no `node:fs`): each\n// helper takes texts, so an app collects them with `import.meta.glob` or `node:fs`, as\n// its setup allows. The first content is the guard against undeclared CSS custom\n// properties (docs/colour-roles-harmonization.md §8).\nexport {\n KIT_CSS_VARIABLES,\n declaredCustomProperties,\n undeclaredCssVariables,\n type UndeclaredCssVariablesOptions,\n} from \"./css-variables\";\n// 0.34 (refactor audit 2026-10, TST-10): the environment jsdom lacks — a `matchMedia`\n// that answers from a viewport width (right at every text size) and a `ResizeObserver`\n// the test drives. Framework-free: each returns its own undo. 0.35: `setViewportWidth`,\n// a live resize of the stub in force — its lists flip and fire `change` (keksdose).\nexport {\n setViewportWidth,\n stubResizeObserver,\n stubViewportWidth,\n viewportMatchMedia,\n type ResizeObserverStub,\n type StubbedBoxSize,\n type ViewportOptions,\n} from \"./viewport\";\n"],"mappings":";AAOA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAKP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;","names":[]}
|
|
@@ -34,14 +34,37 @@ export interface ViewportOptions {
|
|
|
34
34
|
* Width queries answer from `width`: the range syntax the kit writes for `max-*`
|
|
35
35
|
* (`(width < 768px)`) and every other comparison, `(min-width: …)` and `(max-width: …)`,
|
|
36
36
|
* in px or rem; `and` and comma lists combine as in CSS. The features in `options` answer
|
|
37
|
-
* as set there; every other query is false. The lists
|
|
38
|
-
*
|
|
37
|
+
* as set there; every other query is false. The lists keep their listeners, and
|
|
38
|
+
* {@link setViewportWidth} resizes the viewport under them the way a browser window
|
|
39
|
+
* does: each list whose answer flips fires `change`.
|
|
39
40
|
*
|
|
40
41
|
* Hand it to the runner's own global stub where the suite undoes stubs that way —
|
|
41
42
|
* `vi.stubGlobal("matchMedia", viewportMatchMedia(375))` — or use
|
|
42
43
|
* {@link stubViewportWidth}.
|
|
43
44
|
*/
|
|
44
45
|
export declare function viewportMatchMedia(width: number, options?: ViewportOptions): (query: string) => MediaQueryList;
|
|
46
|
+
/**
|
|
47
|
+
* Resize the stubbed viewport to `width` CSS px, live — the window being dragged narrower,
|
|
48
|
+
* a phone turned (0.35, keksdose's 0.34 report). Every list the stub in force has handed
|
|
49
|
+
* out answers from the new width, and each one whose answer flipped fires `change` to its
|
|
50
|
+
* `addEventListener` listeners, its legacy `addListener` ones and its `onchange`, as in a
|
|
51
|
+
* browser; a list whose answer stayed the same tells nobody. So a mounted component that
|
|
52
|
+
* listens to a breakpoint (`usePhoneLayout()`, `useBreakpoint()`) switches without being
|
|
53
|
+
* rendered again.
|
|
54
|
+
*
|
|
55
|
+
* The stub in force is whatever `window.matchMedia` is now — one {@link stubViewportWidth}
|
|
56
|
+
* or `vi.stubGlobal("matchMedia", viewportMatchMedia(…))` put in; its features
|
|
57
|
+
* (`options`) stay as they were. Throws when `matchMedia` is not one of these stubs, rather
|
|
58
|
+
* than resize nothing. Synchronous: wrap it in `act()` when a listener sets state.
|
|
59
|
+
*
|
|
60
|
+
* ```ts
|
|
61
|
+
* undo = stubViewportWidth(1280);
|
|
62
|
+
* render(<Page />);
|
|
63
|
+
* act(() => setViewportWidth(375));
|
|
64
|
+
* expect(screen.getByRole("list")).toBeInTheDocument(); // the cards
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function setViewportWidth(width: number): void;
|
|
45
68
|
/**
|
|
46
69
|
* Make `window.matchMedia` answer as a viewport `width` CSS px wide (see
|
|
47
70
|
* {@link viewportMatchMedia}), and return the undo: it puts back what was there, which
|
package/dist/testing/viewport.js
CHANGED
|
@@ -48,24 +48,74 @@ function condition(part, width, options) {
|
|
|
48
48
|
return false;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
51
|
+
function answer(query, width, options) {
|
|
52
|
+
return query.split(",").some(
|
|
53
53
|
(alternative) => alternative.split(/\s+and\s+/).every((part) => condition(part, width, options))
|
|
54
54
|
);
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
}
|
|
56
|
+
const VIEWPORTS = /* @__PURE__ */ new WeakMap();
|
|
57
|
+
function mediaQueryList(query, viewport) {
|
|
58
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
59
|
+
const list = {
|
|
60
|
+
matches: answer(query, viewport.width, viewport.options),
|
|
57
61
|
media: query,
|
|
58
62
|
onchange: null,
|
|
59
|
-
addEventListener
|
|
63
|
+
addEventListener(type, listener) {
|
|
64
|
+
if (type === "change" && listener) listeners.add(listener);
|
|
60
65
|
},
|
|
61
|
-
removeEventListener
|
|
66
|
+
removeEventListener(type, listener) {
|
|
67
|
+
if (type === "change" && listener) listeners.delete(listener);
|
|
62
68
|
},
|
|
63
|
-
addListener
|
|
69
|
+
addListener(listener) {
|
|
70
|
+
if (listener) listeners.add(listener);
|
|
64
71
|
},
|
|
65
|
-
removeListener
|
|
72
|
+
removeListener(listener) {
|
|
73
|
+
if (listener) listeners.delete(listener);
|
|
66
74
|
},
|
|
67
|
-
dispatchEvent
|
|
68
|
-
|
|
75
|
+
dispatchEvent(event) {
|
|
76
|
+
if (event.type !== "change") return true;
|
|
77
|
+
const self = list;
|
|
78
|
+
list.onchange?.call(self, event);
|
|
79
|
+
for (const listener of [...listeners]) {
|
|
80
|
+
if (typeof listener === "function") listener.call(self, event);
|
|
81
|
+
else listener.handleEvent(event);
|
|
82
|
+
}
|
|
83
|
+
return !event.defaultPrevented;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
return list;
|
|
87
|
+
}
|
|
88
|
+
function changeEvent(list) {
|
|
89
|
+
const event = new Event("change");
|
|
90
|
+
for (const [key, value] of Object.entries({ matches: list.matches, media: list.media, target: list, currentTarget: list })) {
|
|
91
|
+
Object.defineProperty(event, key, { value, enumerable: true });
|
|
92
|
+
}
|
|
93
|
+
return event;
|
|
94
|
+
}
|
|
95
|
+
function viewportMatchMedia(width, options = {}) {
|
|
96
|
+
const viewport = { width, options, lists: /* @__PURE__ */ new Set() };
|
|
97
|
+
const matchMedia = (query) => {
|
|
98
|
+
const list = mediaQueryList(query, viewport);
|
|
99
|
+
viewport.lists.add(list);
|
|
100
|
+
return list;
|
|
101
|
+
};
|
|
102
|
+
VIEWPORTS.set(matchMedia, viewport);
|
|
103
|
+
return matchMedia;
|
|
104
|
+
}
|
|
105
|
+
function setViewportWidth(width) {
|
|
106
|
+
const viewport = typeof window === "undefined" ? void 0 : VIEWPORTS.get(window.matchMedia);
|
|
107
|
+
if (!viewport) {
|
|
108
|
+
throw new Error(
|
|
109
|
+
'setViewportWidth: no viewport stub is in force \u2014 put one in first with stubViewportWidth(width), or vi.stubGlobal("matchMedia", viewportMatchMedia(width)).'
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
viewport.width = width;
|
|
113
|
+
for (const list of [...viewport.lists]) {
|
|
114
|
+
const matches = answer(list.media, width, viewport.options);
|
|
115
|
+
if (matches === list.matches) continue;
|
|
116
|
+
list.matches = matches;
|
|
117
|
+
list.dispatchEvent(changeEvent(list));
|
|
118
|
+
}
|
|
69
119
|
}
|
|
70
120
|
function stubViewportWidth(width, options = {}) {
|
|
71
121
|
const before = Object.getOwnPropertyDescriptor(window, "matchMedia");
|
|
@@ -145,6 +195,7 @@ function stubResizeObserver() {
|
|
|
145
195
|
};
|
|
146
196
|
}
|
|
147
197
|
export {
|
|
198
|
+
setViewportWidth,
|
|
148
199
|
stubResizeObserver,
|
|
149
200
|
stubViewportWidth,
|
|
150
201
|
viewportMatchMedia
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/testing/viewport.ts"],"sourcesContent":["/**\n * Environment stubs for an app's own tests (0.34, refactor audit 2026-10, TST-10): the\n * two browser APIs jsdom does not have and the kit's layout reads — `matchMedia` and\n * `ResizeObserver`.\n *\n * Every suite rebuilt them by hand: the kit stubbed `matchMedia` in 25 files and defined\n * the same `stubPhone()` eight times, keksdose stubs it in 41, and most copies answer\n * one literal string. That breaks quietly at Large text, where `md` is 960 px and the\n * phone query the kit writes is `(width < 960px)`, not `(width < 768px)`. These answer\n * every width query from a WIDTH, as a browser does, so they stay right at every text\n * size (docs/text-size-harmonization.md §3.3). The reference is keksdose's\n * `frontend/src/test/viewport.ts`, which this generalises.\n *\n * Framework-free, like the rest of `@eifi1/ui-kit/testing`: nothing here imports vitest\n * or jest. Each stub returns its own undo, so it works under either runner, and a suite\n * that prefers `vi.stubGlobal` passes it {@link viewportMatchMedia} instead.\n */\n\n/** The media features a test may want besides the width. Each is off by default. */\nexport interface ViewportOptions {\n /** The primary pointer is a finger: `(pointer: coarse)`, `(any-pointer: coarse)` and\n * `(hover: none)` match; `(pointer: fine)` and `(hover: hover)` do not. */\n coarse?: boolean;\n /** The person asked for less motion: `(prefers-reduced-motion: reduce)` matches, and\n * the kit's overlays skip their exit animations. */\n reducedMotion?: boolean;\n /** `(prefers-color-scheme: dark)` matches (`light` does not). */\n dark?: boolean;\n /** `(prefers-contrast: more)` matches. */\n moreContrast?: boolean;\n}\n\n/** One length in CSS px. A media query's `rem`/`em` is the browser's default font size,\n * 16 px, never `<html>`'s — the kit's own `breakpointQuery` writes px. */\nfunction lengthPx(value: string, unit: string): number {\n return unit === \"px\" ? Number(value) : Number(value) * 16;\n}\n\nconst RANGE = /^\\(\\s*width\\s*(<=|>=|<|>)\\s*([\\d.]+)(px|r?em)\\s*\\)$/;\nconst MIN_MAX = /^\\(\\s*(min|max)-width\\s*:\\s*([\\d.]+)(px|r?em)\\s*\\)$/;\nconst FEATURE = /^\\(\\s*([a-z-]+)\\s*:\\s*([a-z-]+)\\s*\\)$/;\n\n/** One `(…)` condition, or a media type. */\nfunction condition(part: string, width: number, options: ViewportOptions): boolean {\n const q = part.trim();\n if (q === \"all\" || q === \"screen\") return true;\n const range = RANGE.exec(q);\n if (range) {\n const px = lengthPx(range[2], range[3]);\n switch (range[1]) {\n case \"<\":\n return width < px;\n case \"<=\":\n return width <= px;\n case \">\":\n return width > px;\n default:\n return width >= px;\n }\n }\n const minMax = MIN_MAX.exec(q);\n if (minMax) {\n const px = lengthPx(minMax[2], minMax[3]);\n return minMax[1] === \"min\" ? width >= px : width <= px;\n }\n const feature = FEATURE.exec(q);\n if (!feature) return false;\n const [, name, value] = feature;\n const coarse = Boolean(options.coarse);\n switch (name) {\n case \"pointer\":\n case \"any-pointer\":\n return value === (coarse ? \"coarse\" : \"fine\");\n case \"hover\":\n case \"any-hover\":\n return value === (coarse ? \"none\" : \"hover\");\n case \"prefers-reduced-motion\":\n return value === (options.reducedMotion ? \"reduce\" : \"no-preference\");\n case \"prefers-color-scheme\":\n return value === (options.dark ? \"dark\" : \"light\");\n case \"prefers-contrast\":\n return value === (options.moreContrast ? \"more\" : \"no-preference\");\n default:\n return false;\n }\n}\n\n/**\n * A `window.matchMedia` for a viewport `width` CSS px wide.\n *\n * Width queries answer from `width`: the range syntax the kit writes for `max-*`\n * (`(width < 768px)`) and every other comparison, `(min-width: …)` and `(max-width: …)`,\n * in px or rem; `and` and comma lists combine as in CSS. The features in `options` answer\n * as set there; every other query is false. The lists it returns never change, so\n * nothing fires `change`: a test that changes the width stubs again and renders again.\n *\n * Hand it to the runner's own global stub where the suite undoes stubs that way —\n * `vi.stubGlobal(\"matchMedia\", viewportMatchMedia(375))` — or use\n * {@link stubViewportWidth}.\n */\nexport function viewportMatchMedia(\n width: number,\n options: ViewportOptions = {},\n): (query: string) => MediaQueryList {\n const answer = (query: string) =>\n query\n .split(\",\")\n .some((alternative) =>\n alternative.split(/\\s+and\\s+/).every((part) => condition(part, width, options)),\n );\n return (query: string) =>\n ({\n matches: answer(query),\n media: query,\n onchange: null,\n addEventListener: () => {},\n removeEventListener: () => {},\n addListener: () => {},\n removeListener: () => {},\n dispatchEvent: () => false,\n }) as unknown as MediaQueryList;\n}\n\n/**\n * Make `window.matchMedia` answer as a viewport `width` CSS px wide (see\n * {@link viewportMatchMedia}), and return the undo: it puts back what was there, which\n * in jsdom is nothing — no `matchMedia` at all, the desktop fallback of every kit hook.\n *\n * ```ts\n * let undo = () => {};\n * afterEach(() => undo());\n * it(\"shows cards on a phone\", () => {\n * undo = stubViewportWidth(375);\n * …\n * });\n * ```\n *\n * Right at every text size: at Large the kit's phone query is `(width < 960px)`, which a\n * 375 px viewport matches and a 1280 px one does not, as in a browser.\n */\nexport function stubViewportWidth(width: number, options: ViewportOptions = {}): () => void {\n const before = Object.getOwnPropertyDescriptor(window, \"matchMedia\");\n Object.defineProperty(window, \"matchMedia\", {\n configurable: true,\n writable: true,\n value: viewportMatchMedia(width, options),\n });\n return () => {\n if (before) Object.defineProperty(window, \"matchMedia\", before);\n else Reflect.deleteProperty(window, \"matchMedia\");\n };\n}\n\n/** A box size for {@link ResizeObserverStub.resize}, in CSS px. */\nexport interface StubbedBoxSize {\n width: number;\n height: number;\n}\n\n/** What {@link stubResizeObserver} returns: the test drives the observers. */\nexport interface ResizeObserverStub {\n /**\n * Report `target` at `size` to every live observer watching it, as a browser does once\n * layout settles: one entry, with `contentRect` and the three box sizes all `size`.\n * Synchronous; wrap it in `act()` when the callback sets state.\n */\n resize(target: Element, size: StubbedBoxSize): void;\n /** The elements some live observer watches now, each once. */\n observed(): Element[];\n /** Put back the `ResizeObserver` that was there before — in jsdom, none. */\n restore(): void;\n}\n\n/**\n * Install a `ResizeObserver` the test drives. jsdom has none, and lays nothing out, so a\n * component that measures itself (a windowed list, a fitted chart, a measured grid)\n * either crashes on the missing global or never learns a size. Observers here record\n * what they watch and are called only by {@link ResizeObserverStub.resize}.\n *\n * ```ts\n * const ro = stubResizeObserver();\n * afterEach(() => ro.restore());\n * act(() => ro.resize(screen.getByRole(\"list\"), { width: 400, height: 320 }));\n * ```\n */\nexport function stubResizeObserver(): ResizeObserverStub {\n const live = new Set<StubResizeObserver>();\n\n class StubResizeObserver {\n readonly targets = new Set<Element>();\n constructor(readonly callback: ResizeObserverCallback) {\n live.add(this);\n }\n observe(target: Element) {\n this.targets.add(target);\n }\n unobserve(target: Element) {\n this.targets.delete(target);\n }\n disconnect() {\n this.targets.clear();\n live.delete(this);\n }\n }\n\n const before = Object.getOwnPropertyDescriptor(globalThis, \"ResizeObserver\");\n Object.defineProperty(globalThis, \"ResizeObserver\", {\n configurable: true,\n writable: true,\n value: StubResizeObserver,\n });\n\n return {\n resize(target, { width, height }) {\n const box = [{ inlineSize: width, blockSize: height }];\n const contentRect = {\n x: 0,\n y: 0,\n top: 0,\n left: 0,\n width,\n height,\n right: width,\n bottom: height,\n toJSON: () => ({ x: 0, y: 0, width, height }),\n };\n const entry = {\n target,\n contentRect,\n borderBoxSize: box,\n contentBoxSize: box,\n devicePixelContentBoxSize: box,\n } as unknown as ResizeObserverEntry;\n for (const observer of [...live]) {\n if (observer.targets.has(target)) {\n observer.callback([entry], observer as unknown as ResizeObserver);\n }\n }\n },\n observed() {\n const all: Element[] = [];\n for (const observer of live) for (const target of observer.targets) if (!all.includes(target)) all.push(target);\n return all;\n },\n restore() {\n live.clear();\n if (before) Object.defineProperty(globalThis, \"ResizeObserver\", before);\n else Reflect.deleteProperty(globalThis, \"ResizeObserver\");\n },\n };\n}\n"],"mappings":";AAkCA,SAAS,SAAS,OAAe,MAAsB;AACrD,SAAO,SAAS,OAAO,OAAO,KAAK,IAAI,OAAO,KAAK,IAAI;AACzD;AAEA,MAAM,QAAQ;AACd,MAAM,UAAU;AAChB,MAAM,UAAU;AAGhB,SAAS,UAAU,MAAc,OAAe,SAAmC;AACjF,QAAM,IAAI,KAAK,KAAK;AACpB,MAAI,MAAM,SAAS,MAAM,SAAU,QAAO;AAC1C,QAAM,QAAQ,MAAM,KAAK,CAAC;AAC1B,MAAI,OAAO;AACT,UAAM,KAAK,SAAS,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;AACtC,YAAQ,MAAM,CAAC,GAAG;AAAA,MAChB,KAAK;AACH,eAAO,QAAQ;AAAA,MACjB,KAAK;AACH,eAAO,SAAS;AAAA,MAClB,KAAK;AACH,eAAO,QAAQ;AAAA,MACjB;AACE,eAAO,SAAS;AAAA,IACpB;AAAA,EACF;AACA,QAAM,SAAS,QAAQ,KAAK,CAAC;AAC7B,MAAI,QAAQ;AACV,UAAM,KAAK,S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YAAY,CAAC,GAAG,IAAI,GAAG;AAChC,YAAI,SAAS,QAAQ,IAAI,MAAM,GAAG;AAChC,mBAAS,SAAS,CAAC,KAAK,GAAG,QAAqC;AAAA,QAClE;AAAA,MACF;AAAA,IACF;AAAA,IACA,WAAW;AACT,YAAM,MAAiB,CAAC;AACxB,iBAAW,YAAY,KAAM,YAAW,UAAU,SAAS,QAAS,KAAI,CAAC,IAAI,SAAS,MAAM,EAAG,KAAI,KAAK,MAAM;AAC9G,aAAO;AAAA,IACT;AAAA,IACA,UAAU;AACR,WAAK,MAAM;AACX,UAAI,OAAQ,QAAO,eAAe,YAAY,kBAAkB,MAAM;AAAA,UACjE,SAAQ,eAAe,YAAY,gBAAgB;AAAA,IAC1D;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/testing/viewport.ts"],"sourcesContent":["/**\n * Environment stubs for an app's own tests (0.34, refactor audit 2026-10, TST-10): the\n * two browser APIs jsdom does not have and the kit's layout reads — `matchMedia` and\n * `ResizeObserver`.\n *\n * Every suite rebuilt them by hand: the kit stubbed `matchMedia` in 25 files and defined\n * the same `stubPhone()` eight times, keksdose stubs it in 41, and most copies answer\n * one literal string. That breaks quietly at Large text, where `md` is 960 px and the\n * phone query the kit writes is `(width < 960px)`, not `(width < 768px)`. These answer\n * every width query from a WIDTH, as a browser does, so they stay right at every text\n * size (docs/text-size-harmonization.md §3.3). The reference is keksdose's\n * `frontend/src/test/viewport.ts`, which this generalises.\n *\n * Framework-free, like the rest of `@eifi1/ui-kit/testing`: nothing here imports vitest\n * or jest. Each stub returns its own undo, so it works under either runner, and a suite\n * that prefers `vi.stubGlobal` passes it {@link viewportMatchMedia} instead.\n */\n\n/** The media features a test may want besides the width. Each is off by default. */\nexport interface ViewportOptions {\n /** The primary pointer is a finger: `(pointer: coarse)`, `(any-pointer: coarse)` and\n * `(hover: none)` match; `(pointer: fine)` and `(hover: hover)` do not. */\n coarse?: boolean;\n /** The person asked for less motion: `(prefers-reduced-motion: reduce)` matches, and\n * the kit's overlays skip their exit animations. */\n reducedMotion?: boolean;\n /** `(prefers-color-scheme: dark)` matches (`light` does not). */\n dark?: boolean;\n /** `(prefers-contrast: more)` matches. */\n moreContrast?: boolean;\n}\n\n/** One length in CSS px. A media query's `rem`/`em` is the browser's default font size,\n * 16 px, never `<html>`'s — the kit's own `breakpointQuery` writes px. */\nfunction lengthPx(value: string, unit: string): number {\n return unit === \"px\" ? Number(value) : Number(value) * 16;\n}\n\nconst RANGE = /^\\(\\s*width\\s*(<=|>=|<|>)\\s*([\\d.]+)(px|r?em)\\s*\\)$/;\nconst MIN_MAX = /^\\(\\s*(min|max)-width\\s*:\\s*([\\d.]+)(px|r?em)\\s*\\)$/;\nconst FEATURE = /^\\(\\s*([a-z-]+)\\s*:\\s*([a-z-]+)\\s*\\)$/;\n\n/** One `(…)` condition, or a media type. */\nfunction condition(part: string, width: number, options: ViewportOptions): boolean {\n const q = part.trim();\n if (q === \"all\" || q === \"screen\") return true;\n const range = RANGE.exec(q);\n if (range) {\n const px = lengthPx(range[2], range[3]);\n switch (range[1]) {\n case \"<\":\n return width < px;\n case \"<=\":\n return width <= px;\n case \">\":\n return width > px;\n default:\n return width >= px;\n }\n }\n const minMax = MIN_MAX.exec(q);\n if (minMax) {\n const px = lengthPx(minMax[2], minMax[3]);\n return minMax[1] === \"min\" ? width >= px : width <= px;\n }\n const feature = FEATURE.exec(q);\n if (!feature) return false;\n const [, name, value] = feature;\n const coarse = Boolean(options.coarse);\n switch (name) {\n case \"pointer\":\n case \"any-pointer\":\n return value === (coarse ? \"coarse\" : \"fine\");\n case \"hover\":\n case \"any-hover\":\n return value === (coarse ? \"none\" : \"hover\");\n case \"prefers-reduced-motion\":\n return value === (options.reducedMotion ? \"reduce\" : \"no-preference\");\n case \"prefers-color-scheme\":\n return value === (options.dark ? \"dark\" : \"light\");\n case \"prefers-contrast\":\n return value === (options.moreContrast ? \"more\" : \"no-preference\");\n default:\n return false;\n }\n}\n\n/** A whole query: comma lists are alternatives, `and` joins conditions, as in CSS. */\nfunction answer(query: string, width: number, options: ViewportOptions): boolean {\n return query\n .split(\",\")\n .some((alternative) =>\n alternative.split(/\\s+and\\s+/).every((part) => condition(part, width, options)),\n );\n}\n\n/** A list {@link viewportMatchMedia} handed out: what {@link setViewportWidth} flips. */\ninterface StubMediaQueryList {\n matches: boolean;\n readonly media: string;\n onchange: ((this: MediaQueryList, event: MediaQueryListEvent) => unknown) | null;\n addEventListener(type: string, listener: EventListenerOrEventListenerObject | null): void;\n removeEventListener(type: string, listener: EventListenerOrEventListenerObject | null): void;\n addListener(listener: EventListenerOrEventListenerObject | null): void;\n removeListener(listener: EventListenerOrEventListenerObject | null): void;\n dispatchEvent(event: Event): boolean;\n}\n\n/** One stub's viewport: its width now, and every list it has handed out. */\ninterface StubViewport {\n width: number;\n readonly options: ViewportOptions;\n readonly lists: Set<StubMediaQueryList>;\n}\n\n/** Each `matchMedia` {@link viewportMatchMedia} made → its viewport. Keyed by the function,\n * so {@link setViewportWidth} finds whichever stub is in force however it was put in. */\nconst VIEWPORTS = new WeakMap<object, StubViewport>();\n\nfunction mediaQueryList(query: string, viewport: StubViewport): StubMediaQueryList {\n // One set for both APIs: in a browser `addListener(fn)` IS `addEventListener(\"change\",\n // fn)`, so adding the same function through both registers it once.\n const listeners = new Set<EventListenerOrEventListenerObject>();\n const list: StubMediaQueryList = {\n matches: answer(query, viewport.width, viewport.options),\n media: query,\n onchange: null,\n addEventListener(type, listener) {\n if (type === \"change\" && listener) listeners.add(listener);\n },\n removeEventListener(type, listener) {\n if (type === \"change\" && listener) listeners.delete(listener);\n },\n addListener(listener) {\n if (listener) listeners.add(listener);\n },\n removeListener(listener) {\n if (listener) listeners.delete(listener);\n },\n dispatchEvent(event) {\n if (event.type !== \"change\") return true;\n const self = list as unknown as MediaQueryList;\n list.onchange?.call(self, event as MediaQueryListEvent);\n for (const listener of [...listeners]) {\n if (typeof listener === \"function\") listener.call(self, event);\n else listener.handleEvent(event);\n }\n return !event.defaultPrevented;\n },\n };\n return list;\n}\n\n/** The `change` a browser fires at a list whose answer flipped: a `MediaQueryListEvent`'s\n * `matches` and `media`, on an `Event` (jsdom has no `MediaQueryListEvent`). */\nfunction changeEvent(list: StubMediaQueryList): Event {\n const event = new Event(\"change\");\n for (const [key, value] of Object.entries({ matches: list.matches, media: list.media, target: list, currentTarget: list })) {\n Object.defineProperty(event, key, { value, enumerable: true });\n }\n return event;\n}\n\n/**\n * A `window.matchMedia` for a viewport `width` CSS px wide.\n *\n * Width queries answer from `width`: the range syntax the kit writes for `max-*`\n * (`(width < 768px)`) and every other comparison, `(min-width: …)` and `(max-width: …)`,\n * in px or rem; `and` and comma lists combine as in CSS. The features in `options` answer\n * as set there; every other query is false. The lists keep their listeners, and\n * {@link setViewportWidth} resizes the viewport under them the way a browser window\n * does: each list whose answer flips fires `change`.\n *\n * Hand it to the runner's own global stub where the suite undoes stubs that way —\n * `vi.stubGlobal(\"matchMedia\", viewportMatchMedia(375))` — or use\n * {@link stubViewportWidth}.\n */\nexport function viewportMatchMedia(\n width: number,\n options: ViewportOptions = {},\n): (query: string) => MediaQueryList {\n const viewport: StubViewport = { width, options, lists: new Set() };\n const matchMedia = (query: string) => {\n const list = mediaQueryList(query, viewport);\n viewport.lists.add(list);\n return list as unknown as MediaQueryList;\n };\n VIEWPORTS.set(matchMedia, viewport);\n return matchMedia;\n}\n\n/**\n * Resize the stubbed viewport to `width` CSS px, live — the window being dragged narrower,\n * a phone turned (0.35, keksdose's 0.34 report). Every list the stub in force has handed\n * out answers from the new width, and each one whose answer flipped fires `change` to its\n * `addEventListener` listeners, its legacy `addListener` ones and its `onchange`, as in a\n * browser; a list whose answer stayed the same tells nobody. So a mounted component that\n * listens to a breakpoint (`usePhoneLayout()`, `useBreakpoint()`) switches without being\n * rendered again.\n *\n * The stub in force is whatever `window.matchMedia` is now — one {@link stubViewportWidth}\n * or `vi.stubGlobal(\"matchMedia\", viewportMatchMedia(…))` put in; its features\n * (`options`) stay as they were. Throws when `matchMedia` is not one of these stubs, rather\n * than resize nothing. Synchronous: wrap it in `act()` when a listener sets state.\n *\n * ```ts\n * undo = stubViewportWidth(1280);\n * render(<Page />);\n * act(() => setViewportWidth(375));\n * expect(screen.getByRole(\"list\")).toBeInTheDocument(); // the cards\n * ```\n */\nexport function setViewportWidth(width: number): void {\n const viewport = typeof window === \"undefined\" ? undefined : VIEWPORTS.get(window.matchMedia);\n if (!viewport) {\n throw new Error(\n \"setViewportWidth: no viewport stub is in force — put one in first with \" +\n \"stubViewportWidth(width), or vi.stubGlobal(\\\"matchMedia\\\", viewportMatchMedia(width)).\",\n );\n }\n viewport.width = width;\n for (const list of [...viewport.lists]) {\n const matches = answer(list.media, width, viewport.options);\n if (matches === list.matches) continue;\n list.matches = matches;\n list.dispatchEvent(changeEvent(list));\n }\n}\n\n/**\n * Make `window.matchMedia` answer as a viewport `width` CSS px wide (see\n * {@link viewportMatchMedia}), and return the undo: it puts back what was there, which\n * in jsdom is nothing — no `matchMedia` at all, the desktop fallback of every kit hook.\n *\n * ```ts\n * let undo = () => {};\n * afterEach(() => undo());\n * it(\"shows cards on a phone\", () => {\n * undo = stubViewportWidth(375);\n * …\n * });\n * ```\n *\n * Right at every text size: at Large the kit's phone query is `(width < 960px)`, which a\n * 375 px viewport matches and a 1280 px one does not, as in a browser.\n */\nexport function stubViewportWidth(width: number, options: ViewportOptions = {}): () => void {\n const before = Object.getOwnPropertyDescriptor(window, \"matchMedia\");\n Object.defineProperty(window, \"matchMedia\", {\n configurable: true,\n writable: true,\n value: viewportMatchMedia(width, options),\n });\n return () => {\n if (before) Object.defineProperty(window, \"matchMedia\", before);\n else Reflect.deleteProperty(window, \"matchMedia\");\n };\n}\n\n/** A box size for {@link ResizeObserverStub.resize}, in CSS px. */\nexport interface StubbedBoxSize {\n width: number;\n height: number;\n}\n\n/** What {@link stubResizeObserver} returns: the test drives the observers. */\nexport interface ResizeObserverStub {\n /**\n * Report `target` at `size` to every live observer watching it, as a browser does once\n * layout settles: one entry, with `contentRect` and the three box sizes all `size`.\n * Synchronous; wrap it in `act()` when the callback sets state.\n */\n resize(target: Element, size: StubbedBoxSize): void;\n /** The elements some live observer watches now, each once. */\n observed(): Element[];\n /** Put back the `ResizeObserver` that was there before — in jsdom, none. */\n restore(): void;\n}\n\n/**\n * Install a `ResizeObserver` the test drives. jsdom has none, and lays nothing out, so a\n * component that measures itself (a windowed list, a fitted chart, a measured grid)\n * either crashes on the missing global or never learns a size. Observers here record\n * what they watch and are called only by {@link ResizeObserverStub.resize}.\n *\n * ```ts\n * const ro = stubResizeObserver();\n * afterEach(() => ro.restore());\n * act(() => ro.resize(screen.getByRole(\"list\"), { width: 400, height: 320 }));\n * ```\n */\nexport function stubResizeObserver(): ResizeObserverStub {\n const live = new Set<StubResizeObserver>();\n\n class StubResizeObserver {\n readonly targets = new Set<Element>();\n constructor(readonly callback: ResizeObserverCallback) {\n live.add(this);\n }\n observe(target: Element) {\n this.targets.add(target);\n }\n unobserve(target: Element) {\n this.targets.delete(target);\n }\n disconnect() {\n this.targets.clear();\n live.delete(this);\n }\n }\n\n const before = Object.getOwnPropertyDescriptor(globalThis, \"ResizeObserver\");\n Object.defineProperty(globalThis, \"ResizeObserver\", {\n configurable: true,\n writable: true,\n value: StubResizeObserver,\n });\n\n return {\n resize(target, { width, height }) {\n const box = [{ inlineSize: width, blockSize: height }];\n const contentRect = {\n x: 0,\n y: 0,\n top: 0,\n left: 0,\n width,\n height,\n right: width,\n bottom: height,\n toJSON: () => ({ x: 0, y: 0, width, height }),\n };\n const entry = {\n target,\n contentRect,\n borderBoxSize: box,\n contentBoxSize: box,\n devicePixelContentBoxSize: box,\n } as unknown as ResizeObserverEntry;\n for (const observer of [...live]) {\n if (observer.targets.has(target)) {\n observer.callback([entry], observer as unknown as ResizeObserver);\n }\n }\n },\n observed() {\n const all: Element[] = [];\n for (const observer of live) for (const target of observer.targets) if (!all.includes(target)) all.push(target);\n return all;\n },\n restore() {\n live.clear();\n if (before) Object.defineProperty(globalThis, \"ResizeObserver\", before);\n else Reflect.deleteProperty(globalThis, \"ResizeObserver\");\n },\n };\n}\n"],"mappings":";AAkCA,SAAS,SAAS,OAAe,MAAsB;AACrD,SAAO,SAAS,OAAO,OAAO,KAAK,IAAI,OAAO,KAAK,IAAI;AACzD;AAEA,MAAM,QAAQ;AACd,MAAM,UAAU;AAChB,MAAM,UAAU;AAGhB,SAAS,UAAU,MAAc,OAAe,SAAmC;AACjF,QAAM,IAAI,KAAK,KAAK;AACpB,MAAI,MAAM,SAAS,MAAM,SAAU,QAAO;AAC1C,QAAM,QAAQ,MAAM,KAAK,CAAC;AAC1B,MAAI,OAAO;AACT,UAAM,KAAK,SAAS,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;AACtC,YAAQ,MAAM,CAAC,GAAG;AAAA,MAChB,KAAK;AACH,eAAO,QAAQ;AAAA,MACjB,KAAK;AACH,eAAO,SAAS;AAAA,MAClB,KAAK;AACH,eAAO,QAAQ;AAAA,MACjB;AACE,eAAO,SAAS;AAAA,IACpB;AAAA,EACF;AACA,QAAM,SAAS,QAAQ,KAAK,CAAC;AAC7B,MAAI,QAAQ;AACV,UAAM,KAAK,SAAS,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;AACxC,WAAO,OAAO,CAAC,MAAM,QAAQ,SAAS,KAAK,SAAS;AAAA,EACtD;AACA,QAAM,UAAU,QAAQ,KAAK,CAAC;AAC9B,MAAI,CAAC,QAAS,QAAO;AACrB,QAAM,CAAC,EAAE,MAAM,KAAK,IAAI;AACxB,QAAM,SAAS,QAAQ,QAAQ,MAAM;AACrC,UAAQ,MAAM;AAAA,IACZ,KAAK;AAAA,IACL,KAAK;AACH,aAAO,WAAW,SAAS,WAAW;AAAA,IACxC,KAAK;AAAA,IACL,KAAK;AACH,aAAO,WAAW,SAAS,SAAS;AAAA,IACtC,KAAK;AACH,aAAO,WAAW,QAAQ,gBAAgB,WAAW;AAAA,IACvD,KAAK;AACH,aAAO,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W,YAAY,KAAM,YAAW,UAAU,SAAS,QAAS,KAAI,CAAC,IAAI,SAAS,MAAM,EAAG,KAAI,KAAK,MAAM;AAC9G,aAAO;AAAA,IACT;AAAA,IACA,UAAU;AACR,WAAK,MAAM;AACX,UAAI,OAAQ,QAAO,eAAe,YAAY,kBAAkB,MAAM;AAAA,UACjE,SAAQ,eAAe,YAAY,gBAAgB;AAAA,IAC1D;AAAA,EACF;AACF;","names":[]}
|
|
@@ -18,15 +18,35 @@ import type { TokenSet } from "./palette-presets.js";
|
|
|
18
18
|
* - `--border` moves toward `--text-primary` until it clears 3:1 against the worst of the
|
|
19
19
|
* three surfaces (WCAG 1.4.11, a field's boundary), and never less far than
|
|
20
20
|
* `--border-strong`'s 45 % — so every border is at least as strong as a "strong" one was.
|
|
21
|
-
* `--border-strong` stays derived in tokens.css and grows with it
|
|
21
|
+
* `--border-strong` stays derived in tokens.css and grows with it;
|
|
22
|
+
* - in a LIGHT set only (0.36, docs/colour-roles-harmonization.md §13): the well
|
|
23
|
+
* (`--bg-surface-2`) becomes {@link WELL_INK_MORE} of `--text-primary` mixed into the
|
|
24
|
+
* card, and each of the four money colours that falls under 4.5:1 on that well is
|
|
25
|
+
* solved darker at its own hue and chroma. The border above is solved against the
|
|
26
|
+
* stepped well. A dark set's well stands 1.11–1.13:1 from its card already, and its
|
|
27
|
+
* money has no room: nothing of it steps.
|
|
28
|
+
*
|
|
29
|
+
* What does NOT move here, because it is not inline: the light status, hue and field-sync
|
|
30
|
+
* literals and `--bg-active` step in tokens.css's `:root[data-contrast="more"]:not(.dark)`
|
|
31
|
+
* block, solved over these stepped wells.
|
|
22
32
|
*/
|
|
23
|
-
/** The custom properties a contrast step writes. */
|
|
24
|
-
export declare const CONTRAST_STEPPED_VARS: readonly ["--text-secondary", "--text-muted", "--text-placeholder", "--border"];
|
|
33
|
+
/** The custom properties a contrast step writes. The last five only for a light set. */
|
|
34
|
+
export declare const CONTRAST_STEPPED_VARS: readonly ["--text-secondary", "--text-muted", "--text-placeholder", "--border", "--bg-surface-2", "--money-income", "--money-expense", "--money-net", "--money-neutral"];
|
|
35
|
+
/** The light well under More contrast and the money that reads on it (§13.4). */
|
|
36
|
+
export interface WellStep {
|
|
37
|
+
bgSurface2: string;
|
|
38
|
+
moneyIncome: string;
|
|
39
|
+
moneyExpense: string;
|
|
40
|
+
moneyNet: string;
|
|
41
|
+
moneyNeutral: string;
|
|
42
|
+
}
|
|
25
43
|
export interface ContrastStep {
|
|
26
44
|
textSecondary: string;
|
|
27
45
|
textMuted: string;
|
|
28
46
|
textPlaceholder: string;
|
|
29
47
|
border: string;
|
|
48
|
+
/** The stepped well and money, or null for a dark set (which does not step them). */
|
|
49
|
+
well: WellStep | null;
|
|
30
50
|
}
|
|
31
51
|
/** `color-mix(in oklab, a p, b)` as a hex — the same formula tokens.css's derived roles
|
|
32
52
|
* use, so a stepped value sits where the stylesheet would have put it. A colour that is
|
|
@@ -48,6 +68,23 @@ export declare function mix(a: string, b: string, p: number): string;
|
|
|
48
68
|
export declare const HOVER_INK = 0.055;
|
|
49
69
|
/** The card's hover fill (`--bg-hover`) for `t`, as tokens.css mixes it. */
|
|
50
70
|
export declare function hoverFill(t: Pick<TokenSet, "textPrimary" | "bgSurface">): string;
|
|
71
|
+
/**
|
|
72
|
+
* The light well under More contrast: this share of `--text-primary` mixed into the card,
|
|
73
|
+
* `--bg-hover`'s formula at a larger share (0.36, docs/colour-roles-harmonization.md §13).
|
|
74
|
+
*
|
|
75
|
+
* In light the well is the page (§5.3), 1.09–1.11:1 from the card. At 10 % it stands
|
|
76
|
+
* 1.19–1.24:1 from it, about twice that. The rule it is held to: **the stepped well stands
|
|
77
|
+
* at least 1.17:1 from the card**, two of the hover rule's 1.08 steps; 9 % is the least
|
|
78
|
+
* that clears it in every shipped preset, with no room. The step cannot ship alone: on a
|
|
79
|
+
* 10 % well money, status and two hues read 4.07–4.28:1, so the money is solved with it
|
|
80
|
+
* here and the status and hue literals in tokens.css.
|
|
81
|
+
*/
|
|
82
|
+
export declare const WELL_INK_MORE = 0.1;
|
|
83
|
+
/** The least the stepped light well stands from the card (§13.3, decision 2). */
|
|
84
|
+
export declare const WELL_STEP_MIN = 1.17;
|
|
85
|
+
/** The light well under More contrast for `t`, or null for a dark set (or one whose ink or
|
|
86
|
+
* card is not hex, which cannot be mixed). The deriver solves the brand against it. */
|
|
87
|
+
export declare function steppedWellFill(t: Pick<TokenSet, "textPrimary" | "bgSurface">): string | null;
|
|
51
88
|
/**
|
|
52
89
|
* `--brand-muted` in tokens.css: this share of `--brand` mixed into `--text-primary`.
|
|
53
90
|
*
|
|
@@ -71,7 +108,8 @@ export declare function brandSoft(t: Pick<TokenSet, "brand" | "textPrimary" | "b
|
|
|
71
108
|
brandBg: string;
|
|
72
109
|
brandBgHover: string;
|
|
73
110
|
};
|
|
74
|
-
/** The
|
|
111
|
+
/** The stepped values for `t`: the four text and line tokens, and for a light set the
|
|
112
|
+
* well and money (`well`, null in dark). Pure. */
|
|
75
113
|
export declare function contrastStep(t: TokenSet): ContrastStep;
|
|
76
114
|
/** Remember the set `applyTokenSet` wrote, so a contrast change can re-apply it. */
|
|
77
115
|
export declare function rememberTokenSet(el: HTMLElement, t: TokenSet): void;
|