@eifi1/ui-kit 0.31.1 → 0.32.1
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 +51 -28
- package/dist/account/delete-account-setting.d.ts +8 -3
- package/dist/admin/admin-action-confirm.d.ts +8 -3
- package/dist/admin/admin-action-log.d.ts +1 -1
- package/dist/admin/admin-action-log.js +4 -2
- package/dist/admin/admin-action-log.js.map +1 -1
- package/dist/admin/invitations-panel.d.ts +8 -3
- package/dist/admin/invitations-panel.js +29 -26
- package/dist/admin/invitations-panel.js.map +1 -1
- package/dist/admin/reviewer-scope-editor.d.ts +8 -3
- package/dist/admin/role-select.d.ts +10 -5
- package/dist/admin/transfer-ownership-dialog.d.ts +8 -3
- package/dist/admin/user-roster.d.ts +10 -5
- package/dist/admin/user-roster.js +8 -47
- package/dist/admin/user-roster.js.map +1 -1
- package/dist/auth/auth-errors.d.ts +43 -8
- package/dist/auth/auth-errors.js +24 -1
- package/dist/auth/auth-errors.js.map +1 -1
- package/dist/auth/register-form.d.ts +8 -3
- package/dist/billing/billing-banner.d.ts +184 -0
- package/dist/billing/billing-banner.js +98 -0
- package/dist/billing/billing-banner.js.map +1 -0
- package/dist/billing/billing-labels.d.ts +100 -0
- package/dist/billing/billing-labels.js +76 -0
- package/dist/billing/billing-labels.js.map +1 -0
- package/dist/billing/billing-lock.d.ts +158 -0
- package/dist/billing/billing-lock.js +17 -0
- package/dist/billing/billing-lock.js.map +1 -0
- package/dist/billing/billing-standing.d.ts +149 -0
- package/dist/billing/billing-standing.js +28 -0
- package/dist/billing/billing-standing.js.map +1 -0
- package/dist/billing/plan-card.d.ts +248 -0
- package/dist/billing/plan-card.js +248 -0
- package/dist/billing/plan-card.js.map +1 -0
- package/dist/billing/plan-limit-notice.d.ts +156 -0
- package/dist/billing/plan-limit-notice.js +76 -0
- package/dist/billing/plan-limit-notice.js.map +1 -0
- package/dist/billing/plan-limit.d.ts +34 -0
- package/dist/billing/plan-limit.js +20 -0
- package/dist/billing/plan-limit.js.map +1 -0
- package/dist/billing/plan-price.d.ts +61 -0
- package/dist/billing/plan-price.js +45 -0
- package/dist/billing/plan-price.js.map +1 -0
- package/dist/billing/subscription-actions.d.ts +133 -0
- package/dist/billing/subscription-actions.js +28 -0
- package/dist/billing/subscription-actions.js.map +1 -0
- package/dist/billing/subscription-status-chip.d.ts +149 -0
- package/dist/billing/subscription-status-chip.js +48 -0
- package/dist/billing/subscription-status-chip.js.map +1 -0
- package/dist/chart.d.ts +9 -3
- package/dist/chart.js.map +1 -1
- package/dist/components/account-chips.d.ts +16 -4
- package/dist/components/account-chips.js +21 -3
- package/dist/components/account-chips.js.map +1 -1
- package/dist/components/alert-banner.d.ts +6 -1
- package/dist/components/alert-banner.js +5 -4
- package/dist/components/alert-banner.js.map +1 -1
- package/dist/components/amount-input.d.ts +8 -3
- package/dist/components/amount-input.js +5 -5
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/appearance-labels.d.ts +38 -0
- package/dist/components/appearance-labels.js +19 -0
- package/dist/components/appearance-labels.js.map +1 -0
- package/dist/components/autocomplete.js +2 -2
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/breadcrumbs.js +3 -2
- package/dist/components/breadcrumbs.js.map +1 -1
- package/dist/components/bulk-action-bar.d.ts +2 -2
- package/dist/components/bulk-action-bar.js +7 -12
- package/dist/components/bulk-action-bar.js.map +1 -1
- package/dist/components/button-group.d.ts +8 -3
- package/dist/components/button-group.js +7 -1
- package/dist/components/button-group.js.map +1 -1
- package/dist/components/calculator.d.ts +8 -3
- package/dist/components/calculator.js +4 -3
- package/dist/components/calculator.js.map +1 -1
- package/dist/components/calendar-heatmap.js +5 -5
- package/dist/components/calendar-heatmap.js.map +1 -1
- package/dist/components/chart-height.d.ts +23 -0
- package/dist/components/chart-height.js +15 -0
- package/dist/components/chart-height.js.map +1 -0
- package/dist/components/chart-zoom.js +6 -1
- package/dist/components/chart-zoom.js.map +1 -1
- package/dist/components/checkbox-group.js +2 -2
- package/dist/components/checkbox-group.js.map +1 -1
- package/dist/components/checkbox.d.ts +10 -0
- package/dist/components/checkbox.js +25 -10
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/chip.d.ts +19 -3
- package/dist/components/chip.js +54 -23
- package/dist/components/chip.js.map +1 -1
- package/dist/components/choice-card.d.ts +1 -1
- package/dist/components/choice-card.js +9 -8
- package/dist/components/choice-card.js.map +1 -1
- package/dist/components/column-mapper.js +1 -1
- package/dist/components/column-mapper.js.map +1 -1
- package/dist/components/combobox-core.js +8 -7
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox.js +8 -8
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/confirm-dialog.d.ts +8 -3
- package/dist/components/copy-button.d.ts +10 -5
- package/dist/components/country-select.js +1 -1
- package/dist/components/country-select.js.map +1 -1
- package/dist/components/currency-select.js +3 -3
- package/dist/components/currency-select.js.map +1 -1
- package/dist/components/danger-confirm.d.ts +8 -3
- package/dist/components/data-table-cells.d.ts +1 -1
- package/dist/components/data-table-filter-popover.d.ts +1 -1
- package/dist/components/data-table-filter-popover.js +4 -1
- package/dist/components/data-table-filter-popover.js.map +1 -1
- package/dist/components/data-table-filters.d.ts +1 -1
- package/dist/components/data-table-labels.d.ts +1 -1
- package/dist/components/data-table-pagination.d.ts +3 -2
- package/dist/components/data-table-pagination.js +15 -6
- package/dist/components/data-table-pagination.js.map +1 -1
- package/dist/components/data-table.d.ts +1 -1
- package/dist/components/data-table.js +123 -52
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.d.ts +1 -1
- package/dist/components/date-picker.js +18 -6
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/description-list.js +2 -2
- package/dist/components/description-list.js.map +1 -1
- package/dist/components/dialog-frame.js +2 -1
- package/dist/components/dialog-frame.js.map +1 -1
- package/dist/components/disclosure.js +3 -2
- package/dist/components/disclosure.js.map +1 -1
- package/dist/components/dropdown.d.ts +1 -1
- package/dist/components/dropdown.js +7 -1
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/facing-pair.d.ts +19 -6
- package/dist/components/facing-pair.js +3 -2
- package/dist/components/facing-pair.js.map +1 -1
- package/dist/components/field-parts.d.ts +102 -6
- package/dist/components/field-parts.js +81 -6
- package/dist/components/field-parts.js.map +1 -1
- package/dist/components/field-sync.d.ts +4 -1
- package/dist/components/field-sync.js +12 -2
- package/dist/components/field-sync.js.map +1 -1
- package/dist/components/field.js +2 -2
- package/dist/components/field.js.map +1 -1
- package/dist/components/file-button.d.ts +8 -3
- package/dist/components/file-dropzone.d.ts +8 -3
- package/dist/components/floating-panel.js +7 -4
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/focus-ring.d.ts +12 -0
- package/dist/components/focus-ring.js +8 -0
- package/dist/components/focus-ring.js.map +1 -0
- package/dist/components/form-actions.d.ts +8 -3
- package/dist/components/form-actions.js +33 -19
- package/dist/components/form-actions.js.map +1 -1
- package/dist/components/full-bleed-dialog.d.ts +11 -1
- package/dist/components/full-bleed-dialog.js +3 -1
- package/dist/components/full-bleed-dialog.js.map +1 -1
- package/dist/components/iban-input.d.ts +8 -3
- package/dist/components/image-grid.js +1 -1
- package/dist/components/image-grid.js.map +1 -1
- package/dist/components/inline-edit-field.js +10 -4
- package/dist/components/inline-edit-field.js.map +1 -1
- package/dist/components/language-select.d.ts +8 -3
- package/dist/components/legal-page.d.ts +26 -5
- package/dist/components/legal-page.js +3 -1
- package/dist/components/legal-page.js.map +1 -1
- package/dist/components/legal.d.ts +8 -3
- package/dist/components/legal.js +2 -1
- package/dist/components/legal.js.map +1 -1
- package/dist/components/lightbox.js +24 -2
- package/dist/components/lightbox.js.map +1 -1
- package/dist/components/line-items.js +2 -1
- package/dist/components/line-items.js.map +1 -1
- package/dist/components/list.d.ts +5 -0
- package/dist/components/list.js +13 -9
- package/dist/components/list.js.map +1 -1
- package/dist/components/measured-grid.d.ts +3 -1
- package/dist/components/measured-grid.js +38 -20
- package/dist/components/measured-grid.js.map +1 -1
- package/dist/components/menu-item.js +2 -1
- package/dist/components/menu-item.js.map +1 -1
- package/dist/components/mini-calendar.js +8 -4
- package/dist/components/mini-calendar.js.map +1 -1
- package/dist/components/money-field.d.ts +8 -3
- package/dist/components/month-picker.js +50 -39
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/nav-pills.js +1 -1
- package/dist/components/nav-pills.js.map +1 -1
- package/dist/components/number-field.d.ts +8 -3
- package/dist/components/number-input.d.ts +11 -4
- package/dist/components/number-input.js +8 -6
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/numpad-sheet.d.ts +8 -3
- package/dist/components/numpad-sheet.js +2 -1
- package/dist/components/numpad-sheet.js.map +1 -1
- package/dist/components/one-time-code-input.js +2 -2
- package/dist/components/one-time-code-input.js.map +1 -1
- package/dist/components/page-contents.js +2 -2
- package/dist/components/page-contents.js.map +1 -1
- package/dist/components/phone-input.d.ts +8 -3
- package/dist/components/phone-input.js +4 -4
- package/dist/components/phone-input.js.map +1 -1
- package/dist/components/pie-chart.d.ts +8 -2
- package/dist/components/pie-chart.js +11 -7
- package/dist/components/pie-chart.js.map +1 -1
- package/dist/components/popover.d.ts +9 -1
- package/dist/components/popover.js +8 -4
- package/dist/components/popover.js.map +1 -1
- package/dist/components/row-actions.d.ts +100 -0
- package/dist/components/row-actions.js +231 -0
- package/dist/components/row-actions.js.map +1 -0
- package/dist/components/scroll-area.js +1 -1
- package/dist/components/scroll-area.js.map +1 -1
- package/dist/components/search-field.js +3 -2
- package/dist/components/search-field.js.map +1 -1
- package/dist/components/series-chart-budget.d.ts +30 -7
- package/dist/components/series-chart-budget.js +12 -4
- package/dist/components/series-chart-budget.js.map +1 -1
- package/dist/components/series-chart-ticks.d.ts +7 -1
- package/dist/components/series-chart-ticks.js +6 -0
- package/dist/components/series-chart-ticks.js.map +1 -1
- package/dist/components/series-chart.d.ts +58 -28
- package/dist/components/series-chart.js +42 -32
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/settings-fields.d.ts +57 -8
- package/dist/components/settings-fields.js +39 -1
- package/dist/components/settings-fields.js.map +1 -1
- package/dist/components/share-card.d.ts +11 -6
- package/dist/components/share-card.js +8 -2
- package/dist/components/share-card.js.map +1 -1
- package/dist/components/sign-chip.d.ts +4 -0
- package/dist/components/sign-chip.js +17 -4
- package/dist/components/sign-chip.js.map +1 -1
- package/dist/components/signature-pad.d.ts +3 -1
- package/dist/components/signature-pad.js +8 -5
- package/dist/components/signature-pad.js.map +1 -1
- package/dist/components/slider.js +7 -6
- package/dist/components/slider.js.map +1 -1
- package/dist/components/sparkline.d.ts +5 -1
- package/dist/components/sparkline.js +4 -2
- package/dist/components/sparkline.js.map +1 -1
- package/dist/components/stat-tile.d.ts +17 -1
- package/dist/components/stat-tile.js +48 -20
- package/dist/components/stat-tile.js.map +1 -1
- package/dist/components/status-dot.d.ts +4 -0
- package/dist/components/status-dot.js +9 -2
- package/dist/components/status-dot.js.map +1 -1
- package/dist/components/swipeable-row.js +10 -2
- package/dist/components/swipeable-row.js.map +1 -1
- package/dist/components/switch.d.ts +21 -7
- package/dist/components/switch.js +24 -11
- package/dist/components/switch.js.map +1 -1
- package/dist/components/table.js +2 -2
- package/dist/components/table.js.map +1 -1
- package/dist/components/text-link.d.ts +8 -3
- package/dist/components/text-link.js +1 -1
- package/dist/components/text-link.js.map +1 -1
- package/dist/components/text.d.ts +7 -2
- package/dist/components/text.js +5 -5
- package/dist/components/text.js.map +1 -1
- package/dist/components/tile-radio.js +2 -1
- package/dist/components/tile-radio.js.map +1 -1
- package/dist/components/time-input.d.ts +8 -3
- package/dist/components/toast.d.ts +18 -2
- package/dist/components/toast.js +8 -5
- package/dist/components/toast.js.map +1 -1
- package/dist/components/toggle-group.d.ts +25 -3
- package/dist/components/toggle-group.js +40 -11
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/toggle-legend.d.ts +10 -1
- package/dist/components/toggle-legend.js +21 -7
- package/dist/components/toggle-legend.js.map +1 -1
- package/dist/components/translation-review-editor.js +1 -1
- package/dist/components/translation-review-editor.js.map +1 -1
- package/dist/components/translation-review-parts.d.ts +4 -0
- package/dist/components/translation-review.d.ts +4 -0
- package/dist/components/translation-review.js +3 -3
- package/dist/components/translation-review.js.map +1 -1
- package/dist/components/tree-view.js +3 -2
- package/dist/components/tree-view.js.map +1 -1
- package/dist/components/treemap.d.ts +5 -2
- package/dist/components/treemap.js +33 -16
- package/dist/components/treemap.js.map +1 -1
- package/dist/components/ui.d.ts +8 -3
- package/dist/components/ui.js +207 -119
- package/dist/components/ui.js.map +1 -1
- package/dist/components/use-table-state.d.ts +1 -1
- package/dist/components/user-avatar.d.ts +5 -1
- package/dist/components/user-avatar.js +1 -1
- package/dist/components/user-avatar.js.map +1 -1
- package/dist/components/wizard-stepper.js +20 -14
- package/dist/components/wizard-stepper.js.map +1 -1
- package/dist/{data-table-labels-DUELeXpa.d.ts → data-table-labels-kpAAVi6g.d.ts} +26 -2
- package/dist/data-table.d.ts +1 -1
- package/dist/{delete-account-setting-CpIhzxxZ.d.ts → delete-account-setting-FLyJf-kZ.d.ts} +642 -60
- package/dist/demo/demo-banner.js +1 -0
- package/dist/demo/demo-banner.js.map +1 -1
- package/dist/feedback/feedback-attachment.d.ts +8 -3
- package/dist/feedback/feedback-context.d.ts +8 -3
- package/dist/feedback/feedback-crash.d.ts +8 -3
- package/dist/feedback/feedback-dialog.d.ts +8 -3
- package/dist/feedback/feedback-dialog.js +3 -3
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-inbox.d.ts +8 -3
- package/dist/feedback/feedback-inbox.js +2 -2
- package/dist/feedback/feedback-inbox.js.map +1 -1
- package/dist/feedback/feedback-labels.d.ts +8 -3
- package/dist/feedback/feedback-menu.d.ts +9 -4
- package/dist/feedback/feedback-record.d.ts +8 -3
- package/dist/feedback/feedback-row-detail.d.ts +8 -3
- package/dist/feedback/feedback-status-undo.d.ts +8 -3
- package/dist/feedback/feedback-submit.d.ts +8 -3
- package/dist/feedback/feedback-swipe.d.ts +8 -3
- package/dist/feedback/feedback-table.d.ts +8 -3
- package/dist/feedback/feedback-thread.d.ts +8 -3
- package/dist/feedback/feedback-thread.js +3 -3
- package/dist/feedback/feedback-thread.js.map +1 -1
- package/dist/feedback.d.ts +8 -3
- package/dist/hooks/use-anchored-panel.d.ts +32 -3
- package/dist/hooks/use-anchored-panel.js +21 -3
- package/dist/hooks/use-anchored-panel.js.map +1 -1
- package/dist/hooks/use-breakpoint.d.ts +88 -0
- package/dist/hooks/use-breakpoint.js +50 -0
- package/dist/hooks/use-breakpoint.js.map +1 -0
- package/dist/hooks/use-file-drop.d.ts +8 -3
- package/dist/hooks/use-large-text.d.ts +29 -0
- package/dist/hooks/use-large-text.js +20 -0
- package/dist/hooks/use-large-text.js.map +1 -0
- package/dist/hooks/use-windowed-rows.d.ts +52 -8
- package/dist/hooks/use-windowed-rows.js +94 -5
- package/dist/hooks/use-windowed-rows.js.map +1 -1
- package/dist/i18n/defaults.d.ts +8 -3
- package/dist/i18n/defaults.js +8 -0
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.d.ts +8 -3
- package/dist/i18n/german.js +94 -3
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +8 -3
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/languages.d.ts +10 -5
- package/dist/i18n/locales/de-CH.d.ts +8 -3
- package/dist/i18n/locales/en.d.ts +8 -3
- package/dist/i18n/locales/es.d.ts +8 -3
- package/dist/i18n/locales/es.js +89 -3
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +8 -3
- package/dist/i18n/locales/fr.js +91 -3
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +8 -3
- package/dist/i18n/locales/hu.js +91 -3
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +8 -3
- package/dist/i18n/locales/it.js +92 -3
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +8 -3
- package/dist/i18n/locales/zh.js +89 -3
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.d.ts +8 -3
- package/dist/i18n/review.js +15 -1
- package/dist/i18n/review.js.map +1 -1
- package/dist/index.d.ts +27 -11
- package/dist/index.js +77 -4
- package/dist/index.js.map +1 -1
- package/dist/landing/landing-actions.d.ts +8 -3
- package/dist/landing/landing-sections.d.ts +8 -3
- package/dist/landing/landing-sections.js +7 -3
- package/dist/landing/landing-sections.js.map +1 -1
- package/dist/landing/public-header.d.ts +9 -4
- package/dist/landing/public-header.js +3 -3
- package/dist/landing/public-header.js.map +1 -1
- package/dist/landing/routing.d.ts +8 -3
- package/dist/lib/cn.js +3 -2
- package/dist/lib/cn.js.map +1 -1
- package/dist/rhf/fields.d.ts +8 -3
- package/dist/rhf/fields.js +1 -1
- package/dist/rhf/fields.js.map +1 -1
- package/dist/rhf/form.d.ts +8 -3
- package/dist/rhf/form.js +2 -2
- package/dist/rhf/form.js.map +1 -1
- package/dist/rhf.d.ts +8 -3
- package/dist/search/command-palette.d.ts +1 -1
- package/dist/search/command-palette.js +9 -8
- package/dist/search/command-palette.js.map +1 -1
- package/dist/settings/settings-layout.js +2 -1
- package/dist/settings/settings-layout.js.map +1 -1
- package/dist/settings/settings-section.d.ts +8 -3
- package/dist/settings/use-account-appearance.d.ts +92 -0
- package/dist/settings/use-account-appearance.js +63 -0
- package/dist/settings/use-account-appearance.js.map +1 -0
- package/dist/settings/use-settings-route.d.ts +1 -1
- package/dist/settings/use-settings-route.js +2 -3
- package/dist/settings/use-settings-route.js.map +1 -1
- package/dist/shell/app-shell.d.ts +12 -171
- package/dist/shell/app-shell.js +144 -28
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/auth-layout.js +1 -1
- package/dist/shell/auth-layout.js.map +1 -1
- package/dist/shell/option-switcher-menu.js +1 -1
- package/dist/shell/option-switcher-menu.js.map +1 -1
- package/dist/shell/top-bar-brand.d.ts +8 -3
- package/dist/shell/top-bar-brand.js +3 -1
- package/dist/shell/top-bar-brand.js.map +1 -1
- package/dist/shell/topbar-action-menu.d.ts +4 -0
- package/dist/shell/topbar-action-menu.js +3 -3
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell/topbar-controls.js +4 -4
- package/dist/shell/topbar-controls.js.map +1 -1
- package/dist/shell.d.ts +9 -5
- package/dist/theme/contrast-tokens.d.ts +41 -0
- package/dist/theme/contrast-tokens.js +59 -0
- package/dist/theme/contrast-tokens.js.map +1 -0
- package/dist/theme/contrast.d.ts +110 -0
- package/dist/theme/contrast.js +128 -0
- package/dist/theme/contrast.js.map +1 -0
- package/dist/theme/palette-presets.d.ts +12 -1
- package/dist/theme/palette-presets.js +9 -4
- package/dist/theme/palette-presets.js.map +1 -1
- package/dist/theme/palette-store.js.map +1 -1
- package/dist/theme/text-size.d.ts +173 -0
- package/dist/theme/text-size.js +121 -0
- package/dist/theme/text-size.js.map +1 -0
- package/dist/wizard/stepper-nav.d.ts +8 -3
- package/dist/wizard/wizard-summary.js +1 -1
- package/dist/wizard/wizard-summary.js.map +1 -1
- package/dist/wizard.d.ts +8 -3
- package/package.json +1 -1
- package/src/admin/admin-action-log.tsx +6 -1
- package/src/admin/invitations-panel.tsx +36 -29
- package/src/admin/user-roster.tsx +17 -72
- package/src/auth/auth-errors.ts +68 -7
- package/src/billing/billing-banner.tsx +205 -0
- package/src/billing/billing-labels.ts +240 -0
- package/src/billing/billing-lock.ts +75 -0
- package/src/billing/billing-standing.ts +72 -0
- package/src/billing/plan-card.tsx +458 -0
- package/src/billing/plan-limit-notice.tsx +145 -0
- package/src/billing/plan-limit.ts +53 -0
- package/src/billing/plan-price.ts +101 -0
- package/src/billing/subscription-actions.tsx +76 -0
- package/src/billing/subscription-status-chip.tsx +95 -0
- package/src/chart.ts +2 -0
- package/src/components/account-chips.tsx +36 -10
- package/src/components/alert-banner.tsx +16 -7
- package/src/components/amount-input.tsx +5 -5
- package/src/components/appearance-labels.ts +47 -0
- package/src/components/autocomplete.tsx +2 -2
- package/src/components/breadcrumbs.tsx +3 -3
- package/src/components/bulk-action-bar.tsx +11 -14
- package/src/components/button-group.tsx +21 -0
- package/src/components/calculator.tsx +4 -3
- package/src/components/calendar-heatmap.tsx +5 -5
- package/src/components/chart-height.ts +30 -0
- package/src/components/chart-zoom.tsx +6 -1
- package/src/components/checkbox-group.tsx +2 -2
- package/src/components/checkbox.tsx +62 -20
- package/src/components/chip.tsx +139 -30
- package/src/components/choice-card.tsx +16 -11
- package/src/components/column-mapper.tsx +1 -1
- package/src/components/combobox-core.tsx +8 -7
- package/src/components/combobox.tsx +8 -8
- package/src/components/country-select.tsx +1 -1
- package/src/components/currency-select.tsx +3 -3
- package/src/components/data-table-filter-popover.tsx +7 -1
- package/src/components/data-table-pagination.tsx +60 -31
- package/src/components/data-table.tsx +164 -43
- package/src/components/date-picker.tsx +44 -10
- package/src/components/description-list.tsx +2 -2
- package/src/components/dialog-frame.tsx +2 -1
- package/src/components/disclosure.tsx +3 -2
- package/src/components/dropdown.tsx +10 -2
- package/src/components/facing-pair.ts +12 -5
- package/src/components/field-parts.tsx +190 -7
- package/src/components/field-sync.tsx +17 -3
- package/src/components/field.tsx +2 -2
- package/src/components/floating-panel.tsx +7 -4
- package/src/components/focus-ring.ts +12 -0
- package/src/components/form-actions.tsx +55 -18
- package/src/components/full-bleed-dialog.tsx +18 -4
- package/src/components/image-grid.tsx +1 -1
- package/src/components/inline-edit-field.tsx +26 -4
- package/src/components/legal-page.tsx +28 -2
- package/src/components/legal.tsx +19 -1
- package/src/components/lightbox.tsx +24 -2
- package/src/components/line-items.tsx +7 -1
- package/src/components/list.tsx +36 -10
- package/src/components/measured-grid.tsx +49 -24
- package/src/components/menu-item.tsx +2 -2
- package/src/components/mini-calendar.tsx +8 -4
- package/src/components/month-picker.tsx +15 -6
- package/src/components/nav-pills.tsx +1 -1
- package/src/components/number-input.tsx +14 -7
- package/src/components/numpad-sheet.tsx +2 -2
- package/src/components/one-time-code-input.tsx +2 -2
- package/src/components/page-contents.tsx +2 -2
- package/src/components/phone-input.tsx +9 -4
- package/src/components/pie-chart.tsx +19 -9
- package/src/components/popover.tsx +22 -5
- package/src/components/row-actions.tsx +450 -0
- package/src/components/scroll-area.tsx +1 -1
- package/src/components/search-field.tsx +4 -2
- package/src/components/series-chart-budget.ts +40 -8
- package/src/components/series-chart-ticks.ts +10 -0
- package/src/components/series-chart.tsx +123 -72
- package/src/components/settings-fields.tsx +89 -5
- package/src/components/share-card.tsx +31 -2
- package/src/components/sign-chip.tsx +28 -4
- package/src/components/signature-pad.tsx +13 -7
- package/src/components/slider.tsx +22 -9
- package/src/components/sparkline.tsx +11 -3
- package/src/components/stat-tile.tsx +70 -14
- package/src/components/status-dot.tsx +25 -2
- package/src/components/swipeable-row.tsx +10 -2
- package/src/components/switch.tsx +57 -23
- package/src/components/table.tsx +2 -2
- package/src/components/text-link.tsx +1 -1
- package/src/components/text.tsx +11 -6
- package/src/components/tile-radio.tsx +4 -1
- package/src/components/toast.tsx +27 -7
- package/src/components/toggle-group.tsx +115 -14
- package/src/components/toggle-legend.tsx +53 -8
- package/src/components/translation-review-editor.tsx +1 -1
- package/src/components/translation-review.tsx +11 -5
- package/src/components/tree-view.tsx +3 -2
- package/src/components/treemap.tsx +27 -10
- package/src/components/ui.tsx +353 -153
- package/src/components/user-avatar.tsx +1 -1
- package/src/components/wizard-stepper.tsx +5 -1
- package/src/demo/demo-banner.tsx +5 -0
- package/src/feedback/feedback-dialog.tsx +3 -3
- package/src/feedback/feedback-inbox.tsx +2 -2
- package/src/feedback/feedback-thread.tsx +3 -3
- package/src/hooks/use-anchored-panel.ts +67 -5
- package/src/hooks/use-breakpoint.ts +132 -0
- package/src/hooks/use-large-text.ts +41 -0
- package/src/hooks/use-windowed-rows.ts +168 -12
- package/src/i18n/defaults.ts +8 -0
- package/src/i18n/german.ts +107 -0
- package/src/i18n/kit-labels.tsx +12 -0
- package/src/i18n/locales/es.ts +98 -0
- package/src/i18n/locales/fr.ts +102 -0
- package/src/i18n/locales/hu.ts +100 -0
- package/src/i18n/locales/it.ts +103 -0
- package/src/i18n/locales/zh.ts +94 -0
- package/src/i18n/review.ts +14 -0
- package/src/index.ts +76 -6
- package/src/landing/landing-sections.tsx +7 -3
- package/src/landing/public-header.tsx +4 -4
- package/src/lib/cn.ts +13 -2
- package/src/rhf/fields.tsx +1 -1
- package/src/rhf/form.tsx +2 -2
- package/src/search/command-palette.tsx +10 -9
- package/src/settings/settings-layout.tsx +2 -1
- package/src/settings/use-account-appearance.ts +148 -0
- package/src/settings/use-settings-route.ts +3 -4
- package/src/shell/app-shell.tsx +278 -54
- package/src/shell/auth-layout.tsx +1 -1
- package/src/shell/option-switcher-menu.tsx +1 -1
- package/src/shell/top-bar-brand.tsx +3 -1
- package/src/shell/topbar-action-menu.tsx +3 -3
- package/src/shell/topbar-controls.tsx +4 -4
- package/src/theme/contrast-tokens.ts +112 -0
- package/src/theme/contrast.ts +225 -0
- package/src/theme/palette-presets.ts +24 -4
- package/src/theme/palette-store.ts +6 -1
- package/src/theme/text-size.ts +283 -0
- package/src/wizard/wizard-summary.tsx +4 -2
- package/tokens.css +158 -8
|
@@ -5,6 +5,7 @@ import { Eraser, Keyboard, PenLine, Undo2 } from "lucide-react";
|
|
|
5
5
|
import { cn } from "../lib/cn.js";
|
|
6
6
|
import { useAnnounce } from "../hooks/use-announce.js";
|
|
7
7
|
import { useKitLabels } from "../i18n/kit-labels.js";
|
|
8
|
+
import { useTextSize } from "../theme/text-size.js";
|
|
8
9
|
import { Button, FIELD_INVALID, Input } from "./ui.js";
|
|
9
10
|
const DEFAULT_SIGNATURE_PAD_LABELS = {
|
|
10
11
|
label: "Signature",
|
|
@@ -109,10 +110,12 @@ const SignaturePad = forwardRef(function SignaturePad2({
|
|
|
109
110
|
const [typedName, setTypedName] = useState("");
|
|
110
111
|
const typed = mode === "typed";
|
|
111
112
|
const isEmpty = typed ? typedName.trim() === "" : strokeCount === 0;
|
|
112
|
-
const
|
|
113
|
+
const { scale: textScale } = useTextSize();
|
|
114
|
+
const strokeWidth = lineWidth * textScale;
|
|
115
|
+
const opts = useRef({ lineWidth: strokeWidth, exportInk, exportBackground });
|
|
113
116
|
useEffect(() => {
|
|
114
|
-
opts.current = { lineWidth, exportInk, exportBackground };
|
|
115
|
-
}, [
|
|
117
|
+
opts.current = { lineWidth: strokeWidth, exportInk, exportBackground };
|
|
118
|
+
}, [strokeWidth, exportInk, exportBackground]);
|
|
116
119
|
const sceneEmpty = () => {
|
|
117
120
|
const s = scene.current;
|
|
118
121
|
return s.mode === "typed" ? s.name.trim() === "" : s.strokes.length === 0;
|
|
@@ -164,7 +167,7 @@ const SignaturePad = forwardRef(function SignaturePad2({
|
|
|
164
167
|
}, [resize]);
|
|
165
168
|
useEffect(() => {
|
|
166
169
|
repaint();
|
|
167
|
-
}, [
|
|
170
|
+
}, [strokeWidth, repaint]);
|
|
168
171
|
useEffect(() => {
|
|
169
172
|
const canvas = canvasRef.current;
|
|
170
173
|
if (!canvas) return;
|
|
@@ -396,7 +399,7 @@ const SignaturePad = forwardRef(function SignaturePad2({
|
|
|
396
399
|
),
|
|
397
400
|
onSave && /* @__PURE__ */ jsx(Button, { type: "button", variant: "brand", onClick: save, disabled: disabled || isEmpty, className: "ms-auto", children: labels.save })
|
|
398
401
|
] }),
|
|
399
|
-
hasError && /* @__PURE__ */ jsx("p", { id: errorId, className: "mt-1 text-
|
|
402
|
+
hasError && /* @__PURE__ */ jsx("p", { id: errorId, className: "mt-1 text-caption leading-tight text-[var(--danger)]", children: error }),
|
|
400
403
|
/* @__PURE__ */ jsx("div", { ...regionProps })
|
|
401
404
|
] });
|
|
402
405
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/signature-pad.tsx"],"sourcesContent":["import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, PointerEvent as ReactPointerEvent, ReactNode } from \"react\";\nimport { Eraser, Keyboard, PenLine, Undo2 } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { useAnnounce } from \"../hooks/use-announce\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { Button, FIELD_INVALID, Input } from \"./ui\";\n\n/**\n * A drawn signature, captured on a canvas and handed back as a PNG data URL.\n *\n * Kastlan wrote the first one (`features/handover/components/signature-pad.tsx`) for\n * the handover protocol, where tenant and inspector each sign on the same phone. This\n * keeps its contract — draw, get a PNG — and fixes what a copy per app would keep\n * getting wrong:\n *\n * 1. **Strokes are data, not pixels.** Each stroke is kept as a list of points, and\n * the canvas is a VIEW of them. That is what lets a resize (a phone rotating\n * mid-signature) keep the drawing instead of wiping it — setting `canvas.width`\n * clears the bitmap, so a pixels-only pad loses everything — and what makes undo\n * one `pop()`. The pixel buffer is sized to `devicePixelRatio`, so a stroke is\n * sharp on a 3× screen rather than upscaled from a 1× bitmap.\n * 2. **Smooth, and pressure-aware.** Segments are quadratic curves through the\n * midpoints between samples, so a fast stroke is a curve, not a polyline; a pen\n * that reports pressure varies the width, a mouse or finger (whose `pressure` is a\n * constant 0.5, or junk) draws at the base width.\n * 3. **Two inks.** On screen the ink is the computed `color` of the canvas, which is\n * `--text-primary` — so it reads in the dark theme, where a hard-coded near-black\n * stroke vanished into the surface. The exported PNG is re-rendered from the same\n * strokes in `exportInk` (near-black by default) on a transparent background. A\n * signature is a DOCUMENT artefact: it is printed on the protocol, shown on a white\n * card, embedded in a PDF — none of which follow the signer's theme. Exporting\n * the on-screen ink would have produced a pale-grey-on-transparent PNG for every\n * dark-mode signer, invisible on white paper.\n *\n * **Accessibility.** A canvas has no content a screen reader or a keyboard can reach,\n * and no amount of ARIA changes that — drawing is a pointer act. What the pad does:\n * the canvas is `role=\"img\"`, named by the visible label and described by the\n * instructions and by its state (\"Nothing drawn yet\" / \"Signature drawn\"), so a\n * screen-reader user knows what the box is and whether it holds anything; undo and\n * clear are real buttons, and their effect is announced. What it cannot do is let\n * someone sign without a pointer — hence `allowTypedName`, which offers a typed name\n * instead. It is OPT-IN, because whether a typed name counts as a signature is a\n * product and legal decision, not a UI one (Kastlan's handover accepts one; a flow\n * that needs a drawn mark would not). Where a drawn mark is not strictly required,\n * turn it on.\n */\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** Every string the pad renders or speaks. */\nexport interface SignaturePadLabels {\n /** Visible label above the pad, and the canvas's accessible name. The `label`\n * prop overrides it per instance. */\n label: string;\n /** Under the label, and part of the canvas's description. */\n instructions: string;\n /** Appended to the instructions when `allowTypedName` is on. */\n typedFallbackHint: string;\n /** The canvas's state for a screen reader. */\n empty: string;\n signed: string;\n undo: string;\n clear: string;\n /** Only rendered when `onSave` is given. */\n save: string;\n /** The mode switch (`allowTypedName`). */\n useTyped: string;\n useDrawn: string;\n /** Label of the typed-name field. */\n typedName: string;\n /** Live-region messages after the matching button. */\n cleared: string;\n undone: string;\n /** {@link SignatureView}: what it says when there is no signature to show. */\n viewEmpty: string;\n /** {@link SignatureView}: the saved PNG's alternative text. */\n viewDrawn: string;\n /** {@link SignatureView}: the accessible name of a typed-name signature. */\n viewTyped: (name: string) => string;\n}\n\nexport const DEFAULT_SIGNATURE_PAD_LABELS: SignaturePadLabels = {\n label: \"Signature\",\n instructions: \"Sign in the box with a mouse, your finger or a pen.\",\n typedFallbackHint: \"If you cannot draw, type your name instead.\",\n empty: \"Nothing drawn yet\",\n signed: \"Signature drawn\",\n undo: \"Undo last stroke\",\n clear: \"Clear\",\n save: \"Save signature\",\n useTyped: \"Type name instead\",\n useDrawn: \"Draw instead\",\n typedName: \"Full name\",\n cleared: \"Signature cleared\",\n undone: \"Last stroke removed\",\n viewEmpty: \"Not signed\",\n viewDrawn: \"Handwritten signature\",\n viewTyped: (name) => `Signed with the typed name ${name}`,\n};\n\n/* ── Types ───────────────────────────────────────────────────────────────── */\n\n/** How the value handed back was made. */\nexport interface SignatureDetail {\n method: \"drawn\" | \"typed\";\n /** The name as typed, when `method` is `\"typed\"` — the PNG shows it, but a host\n * that stores a typed name as TEXT (Kastlan does) wants the string. */\n typedName?: string;\n}\n\n/** The imperative handle: `ref.current.toDataURL()` at submit time, for a form that\n * does not want to mirror the value into state on every stroke. */\nexport interface SignaturePadHandle {\n /** Remove every stroke and the typed name. Fires `onChange(null)`. */\n clear: () => void;\n /** The PNG, rendered in `exportInk` — or `null` while nothing is signed. */\n toDataURL: () => string | null;\n isEmpty: () => boolean;\n}\n\nexport interface SignaturePadProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onChange\"> {\n /** Visible label; defaults to `labels.label`. */\n label?: ReactNode;\n /** Replaces `labels.instructions` for this instance (e.g. a legal note). */\n description?: ReactNode;\n /**\n * After every finished stroke, undo, clear and typed-name edit: the PNG, or `null`\n * once the pad is empty. Not called mid-stroke — encoding a PNG per pointer move\n * would stall the drawing on a phone.\n */\n onChange?: (dataUrl: string | null, detail: SignatureDetail) => void;\n /** Renders a Save button, enabled once something is signed. */\n onSave?: (dataUrl: string, detail: SignatureDetail) => void;\n disabled?: boolean;\n /** Paints the pad as wrong and sets `aria-invalid`. See {@link Input}'s `invalid`. */\n invalid?: boolean;\n /** Message under the pad; implies `invalid` and is attached with\n * `aria-describedby`, like the kit's other fields. */\n error?: ReactNode;\n /** Offer a typed name as an alternative to drawing. See the accessibility note. */\n allowTypedName?: boolean;\n /** Ink of the exported PNG. Default near-black, legible on white. */\n exportInk?: string;\n /** Fill behind the exported PNG. Default transparent. */\n exportBackground?: string;\n /** Base stroke width in CSS pixels. Default 2.5. */\n lineWidth?: number;\n /** Classes for the canvas — its height, chiefly (default `h-40`). */\n canvasClassName?: string;\n /** User-facing strings; see {@link SignaturePadLabels}. */\n labels?: Partial<SignaturePadLabels>;\n}\n\n/* ── Drawing ─────────────────────────────────────────────────────────────── */\n\ninterface Point {\n x: number;\n y: number;\n /** 0–1. A constant 0.5 for anything that is not a pen. */\n p: number;\n}\n\ntype Stroke = Point[];\n\nconst DEFAULT_EXPORT_INK = \"#111111\";\n\n// A handwriting face where the platform has one, `cursive` everywhere else. Only\n// ever used to render a typed name onto the canvas.\nconst SCRIPT_FONT = `\"Segoe Script\", \"Bradley Hand\", \"Brush Script MT\", cursive`;\n\n/** Width multiplier from pressure: 0.5 (the no-pen constant) is exactly 1. */\nconst pressureWidth = (p: number) => 0.4 + 1.2 * p;\n\nconst mid = (a: Point, b: Point): Point => ({ x: (a.x + b.x) / 2, y: (a.y + b.y) / 2, p: (a.p + b.p) / 2 });\n\n/**\n * Segment `i` (1 ≤ i < n) of a stroke: a quadratic from the midpoint before sample\n * `i - 1` to the midpoint after it, with the sample as the control point. The live\n * drawing and the full repaint both go through here, so a stroke looks the same\n * before and after a resize.\n */\nfunction drawSegment(ctx: CanvasRenderingContext2D, pts: Stroke, i: number, scale: number, width: number) {\n const a = i === 1 ? pts[0] : mid(pts[i - 2], pts[i - 1]);\n const c = pts[i - 1];\n const b = mid(pts[i - 1], pts[i]);\n ctx.lineWidth = width * scale * pressureWidth((a.p + b.p) / 2);\n ctx.beginPath();\n ctx.moveTo(a.x * scale, a.y * scale);\n ctx.quadraticCurveTo(c.x * scale, c.y * scale, b.x * scale, b.y * scale);\n ctx.stroke();\n}\n\n/** The last half-segment, from the final midpoint to the final sample. Drawn once the\n * stroke is finished — while drawing, the pen is still there and it would be redrawn\n * on every move. A single tap is a dot. */\nfunction drawTail(ctx: CanvasRenderingContext2D, pts: Stroke, scale: number, width: number) {\n const last = pts[pts.length - 1];\n if (pts.length === 1) {\n ctx.beginPath();\n ctx.arc(last.x * scale, last.y * scale, (width * scale * pressureWidth(last.p)) / 2, 0, Math.PI * 2);\n ctx.fill();\n return;\n }\n const from = pts.length === 2 ? pts[0] : mid(pts[pts.length - 2], last);\n ctx.lineWidth = width * scale * pressureWidth(last.p);\n ctx.beginPath();\n ctx.moveTo(from.x * scale, from.y * scale);\n ctx.lineTo(last.x * scale, last.y * scale);\n ctx.stroke();\n}\n\nfunction prepare(ctx: CanvasRenderingContext2D, ink: string, dpr: number) {\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n ctx.lineCap = \"round\";\n ctx.lineJoin = \"round\";\n ctx.strokeStyle = ink;\n ctx.fillStyle = ink;\n}\n\n/** A typed name, as large as fits, on the pad's baseline. */\nfunction drawName(ctx: CanvasRenderingContext2D, name: string, w: number, h: number) {\n let size = Math.min(48, h * 0.45);\n ctx.font = `italic ${size}px ${SCRIPT_FONT}`;\n const room = w * 0.85;\n const measured = ctx.measureText(name).width;\n if (measured > room) {\n size = Math.max(12, (size * room) / measured);\n ctx.font = `italic ${size}px ${SCRIPT_FONT}`;\n }\n ctx.textAlign = \"center\";\n ctx.textBaseline = \"alphabetic\";\n ctx.fillText(name, w / 2, h * 0.68);\n}\n\n/* ── The component ───────────────────────────────────────────────────────── */\n\nexport const SignaturePad = forwardRef<SignaturePadHandle, SignaturePadProps>(function SignaturePad(\n {\n label,\n description,\n onChange,\n onSave,\n disabled,\n invalid,\n error,\n allowTypedName,\n exportInk = DEFAULT_EXPORT_INK,\n exportBackground,\n lineWidth = 2.5,\n canvasClassName,\n labels: labelsProp,\n className,\n ...rest\n },\n ref,\n) {\n // Prop > <UiKitProvider> > English, like every labelled component in the kit.\n const labels = useKitLabels(\"signaturePad\", DEFAULT_SIGNATURE_PAD_LABELS, labelsProp);\n const { announce, regionProps } = useAnnounce();\n const labelId = useId();\n const descId = useId();\n const statusId = useId();\n const errorId = useId();\n\n const canvasRef = useRef<HTMLCanvasElement>(null);\n /**\n * What is on the pad lives in a ref, not in state: a pointer move must not\n * re-render, and `onChange` has to see the pad AFTER a change, from inside the\n * handler that made it — before React has rendered anything. The state below\n * mirrors the parts the markup needs (empty or not, which mode, the field's text).\n */\n const scene = useRef<{ strokes: Stroke[]; mode: \"drawn\" | \"typed\"; name: string }>({\n strokes: [],\n mode: \"drawn\",\n name: \"\",\n });\n const live = useRef<{ id: number; stroke: Stroke } | null>(null);\n /**\n * The canvas width, in CSS px, the stored points are relative to. Fixed by the\n * first stroke; a later resize scales the drawing UNIFORMLY by `width / refWidth`,\n * so a rotated phone shows the same signature larger or smaller, never stretched.\n */\n const refWidth = useRef(0);\n const [strokeCount, setStrokeCount] = useState(0);\n const [mode, setMode] = useState<\"drawn\" | \"typed\">(\"drawn\");\n const [typedName, setTypedName] = useState(\"\");\n\n const typed = mode === \"typed\";\n const isEmpty = typed ? typedName.trim() === \"\" : strokeCount === 0;\n\n // Everything the paint and export paths read that can change between renders, so\n // the observers below subscribe once instead of on every keystroke.\n const opts = useRef({ lineWidth, exportInk, exportBackground });\n useEffect(() => {\n opts.current = { lineWidth, exportInk, exportBackground };\n }, [lineWidth, exportInk, exportBackground]);\n\n const sceneEmpty = () => {\n const s = scene.current;\n return s.mode === \"typed\" ? s.name.trim() === \"\" : s.strokes.length === 0;\n };\n\n /** The whole scene, painted into `ctx` at `w`×`h` CSS px. */\n const paintInto = useCallback((ctx: CanvasRenderingContext2D, ink: string, w: number, h: number, dpr: number) => {\n const { lineWidth: width } = opts.current;\n const s = scene.current;\n prepare(ctx, ink, dpr);\n if (s.mode === \"typed\") {\n if (s.name.trim()) drawName(ctx, s.name.trim(), w, h);\n return;\n }\n const scale = refWidth.current > 0 ? w / refWidth.current : 1;\n for (const stroke of s.strokes) {\n for (let i = 1; i < stroke.length; i += 1) drawSegment(ctx, stroke, i, scale, width);\n drawTail(ctx, stroke, scale, width);\n }\n const pending = live.current?.stroke;\n if (pending) for (let i = 1; i < pending.length; i += 1) drawSegment(ctx, pending, i, scale, width);\n }, []);\n\n /** The ink on screen: the canvas's own computed `color`, i.e. `--text-primary`. */\n const screenInk = (canvas: HTMLCanvasElement) =>\n // Read as `color` rather than as the custom property: `--text-primary` is whatever\n // the palette wrote (a `color-mix()` in some presets), which a 2D context may not\n // parse; `color` has already been resolved by the browser.\n getComputedStyle(canvas).color || opts.current.exportInk;\n\n /** Repaint the visible canvas from the scene, in the theme's ink. */\n const repaint = useCallback(() => {\n const canvas = canvasRef.current;\n const ctx = canvas?.getContext(\"2d\");\n if (!canvas || !ctx) return;\n const dpr = window.devicePixelRatio || 1;\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n paintInto(ctx, screenInk(canvas), canvas.width / dpr, canvas.height / dpr, dpr);\n }, [paintInto]);\n\n /** Size the bitmap to the element × devicePixelRatio, then repaint. */\n const resize = useCallback(() => {\n const canvas = canvasRef.current;\n if (!canvas) return;\n const rect = canvas.getBoundingClientRect();\n const dpr = window.devicePixelRatio || 1;\n const w = Math.round(rect.width * dpr);\n const h = Math.round(rect.height * dpr);\n // Assigning `width` clears the bitmap even when the value is unchanged, so only\n // when it moved — and the repaint puts the strokes back either way.\n if (canvas.width !== w) canvas.width = w;\n if (canvas.height !== h) canvas.height = h;\n repaint();\n }, [repaint]);\n\n useLayoutEffect(() => {\n resize();\n }, [resize]);\n\n // A changed base width redraws what is already there.\n useEffect(() => {\n repaint();\n }, [lineWidth, repaint]);\n\n useEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas) return;\n const cleanups: Array<() => void> = [];\n if (typeof ResizeObserver !== \"undefined\") {\n const ro = new ResizeObserver(() => resize());\n ro.observe(canvas);\n cleanups.push(() => ro.disconnect());\n }\n // The ink follows the theme, and the theme is a class (`.dark`) or inline\n // variables (the palette store) on <html> — neither of which tells a canvas.\n if (typeof MutationObserver !== \"undefined\") {\n const mo = new MutationObserver(() => repaint());\n mo.observe(document.documentElement, { attributes: true, attributeFilter: [\"class\", \"style\", \"data-theme\"] });\n cleanups.push(() => mo.disconnect());\n }\n const mq = typeof window.matchMedia === \"function\" ? window.matchMedia(\"(prefers-color-scheme: dark)\") : null;\n if (mq?.addEventListener) {\n mq.addEventListener(\"change\", repaint);\n cleanups.push(() => mq.removeEventListener(\"change\", repaint));\n }\n return () => cleanups.forEach((fn) => fn());\n }, [resize, repaint]);\n\n /** The PNG, re-rendered off-screen in the export ink — `null` while empty. */\n const exportPng = useCallback((): string | null => {\n const canvas = canvasRef.current;\n if (!canvas || sceneEmpty()) return null;\n const { exportInk: ink, exportBackground: bg } = opts.current;\n const dpr = window.devicePixelRatio || 1;\n const out = document.createElement(\"canvas\");\n out.width = canvas.width;\n out.height = canvas.height;\n const ctx = out.getContext(\"2d\");\n if (!ctx) return null;\n if (bg) {\n ctx.fillStyle = bg;\n ctx.fillRect(0, 0, out.width, out.height);\n }\n paintInto(ctx, ink, out.width / dpr, out.height / dpr, dpr);\n return out.toDataURL(\"image/png\");\n }, [paintInto]);\n\n const detail = (): SignatureDetail => {\n const s = scene.current;\n return s.mode === \"typed\" ? { method: \"typed\", typedName: s.name.trim() } : { method: \"drawn\" };\n };\n\n /** After every change to the scene: sync the markup's mirror, repaint, tell the host. */\n const onChangeRef = useRef(onChange);\n useEffect(() => {\n onChangeRef.current = onChange;\n }, [onChange]);\n const commit = () => {\n const s = scene.current;\n setStrokeCount(s.strokes.length);\n setMode(s.mode);\n setTypedName(s.name);\n repaint();\n onChangeRef.current?.(exportPng(), detail());\n };\n\n const clearScene = () => {\n scene.current = { ...scene.current, strokes: [], name: \"\" };\n live.current = null;\n refWidth.current = 0;\n commit();\n };\n\n useImperativeHandle(ref, () => ({ clear: clearScene, toDataURL: exportPng, isEmpty: sceneEmpty }));\n\n /* ── Pointer ── */\n\n const toPoint = (e: { clientX: number; clientY: number; pressure: number; pointerType: string }, rect: DOMRect): Point => {\n const scale = refWidth.current > 0 && rect.width > 0 ? rect.width / refWidth.current : 1;\n return {\n x: (e.clientX - rect.left) / scale,\n y: (e.clientY - rect.top) / scale,\n // Only a pen's pressure means anything: a mouse reports 0.5 while pressed and\n // touch hardware reports 0, 1 or noise.\n p: e.pointerType === \"pen\" && e.pressure > 0 ? e.pressure : 0.5,\n };\n };\n\n const onPointerDown = (e: ReactPointerEvent<HTMLCanvasElement>) => {\n // One stroke at a time: a palm resting beside the pen is a second pointer.\n if (disabled || typed || live.current) return;\n if (e.pointerType === \"mouse\" && e.button !== 0) return;\n e.preventDefault();\n const canvas = e.currentTarget;\n canvas.setPointerCapture?.(e.pointerId);\n const rect = canvas.getBoundingClientRect();\n if (refWidth.current === 0) refWidth.current = rect.width || 1;\n live.current = { id: e.pointerId, stroke: [toPoint(e, rect)] };\n };\n\n const onPointerMove = (e: ReactPointerEvent<HTMLCanvasElement>) => {\n const pending = live.current;\n if (!pending || pending.id !== e.pointerId) return;\n e.preventDefault();\n const canvas = e.currentTarget;\n const rect = canvas.getBoundingClientRect();\n // Coalesced events: the samples the browser merged into this one move. A fast\n // flick on a 120 Hz pen is otherwise a handful of long straight chords.\n const samples = e.nativeEvent.getCoalescedEvents?.() ?? [];\n const events = samples.length > 0 ? samples : [e];\n const ctx = canvas.getContext(\"2d\");\n if (ctx) prepare(ctx, screenInk(canvas), window.devicePixelRatio || 1);\n const scale = refWidth.current > 0 && rect.width > 0 ? rect.width / refWidth.current : 1;\n for (const ev of events) {\n pending.stroke.push(toPoint(ev, rect));\n // Only the newest segment — a full repaint per move is O(ink) on every event.\n if (ctx) drawSegment(ctx, pending.stroke, pending.stroke.length - 1, scale, opts.current.lineWidth);\n }\n };\n\n const endStroke = (e: ReactPointerEvent<HTMLCanvasElement>) => {\n const pending = live.current;\n if (!pending || pending.id !== e.pointerId) return;\n e.currentTarget.releasePointerCapture?.(e.pointerId);\n live.current = null;\n scene.current = { ...scene.current, strokes: [...scene.current.strokes, pending.stroke] };\n commit();\n };\n\n /* ── Buttons ── */\n\n const undo = () => {\n if (disabled || scene.current.strokes.length === 0) return;\n const strokes = scene.current.strokes.slice(0, -1);\n if (strokes.length === 0) refWidth.current = 0;\n scene.current = { ...scene.current, strokes };\n commit();\n announce(labels.undone);\n };\n\n const clear = () => {\n if (disabled || sceneEmpty()) return;\n clearScene();\n announce(labels.cleared);\n };\n\n const switchMode = () => {\n if (disabled) return;\n scene.current = { ...scene.current, mode: scene.current.mode === \"drawn\" ? \"typed\" : \"drawn\" };\n commit();\n };\n\n const onTypedChange = (name: string) => {\n scene.current = { ...scene.current, name };\n commit();\n };\n\n const save = () => {\n if (disabled) return;\n const png = exportPng();\n if (png) onSave?.(png, detail());\n };\n\n const hasError = error !== undefined && error !== null && error !== false && error !== \"\";\n const isInvalid = Boolean(invalid) || hasError;\n const describedBy = [descId, statusId, hasError ? errorId : null].filter(Boolean).join(\" \");\n\n // `aria-disabled` rather than `disabled` on undo/clear: they disable THEMSELVES\n // (clear empties the pad, the last undo does too), and a natively disabled button\n // drops keyboard focus to <body> the moment it is activated.\n const softDisabled = \"aria-disabled:cursor-not-allowed aria-disabled:opacity-50\";\n\n return (\n <div {...rest} className={cn(\"relative space-y-1.5\", className)} data-empty={isEmpty || undefined}>\n <div>\n <span id={labelId} className=\"block text-sm font-medium text-[var(--text-primary)]\">\n {label ?? labels.label}\n </span>\n <p id={descId} className=\"text-xs text-[var(--text-muted)]\">\n {description ?? labels.instructions}\n {allowTypedName && !typed ? ` ${labels.typedFallbackHint}` : null}\n </p>\n </div>\n\n <div className=\"relative\">\n <canvas\n ref={canvasRef}\n role=\"img\"\n aria-labelledby={labelId}\n aria-describedby={describedBy}\n // No `aria-invalid` / `aria-disabled`: `img` supports neither. The error\n // reaches a screen reader through `aria-describedby`; the attributes below\n // are for styling and tests.\n data-invalid={isInvalid || undefined}\n data-disabled={disabled || undefined}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={endStroke}\n onPointerCancel={endStroke}\n className={cn(\n // `touch-none` stops the page scrolling under a finger that is signing.\n \"block h-40 w-full touch-none select-none rounded-md border border-[var(--border)] bg-[var(--bg-surface)] text-[var(--text-primary)]\",\n typed || disabled ? \"cursor-default\" : \"cursor-crosshair\",\n disabled && \"opacity-60\",\n isInvalid && FIELD_INVALID,\n canvasClassName,\n )}\n />\n {/* The signing line — where people expect to sign. Decoration only. */}\n <div\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-x-6 bottom-8 border-b border-dashed border-[var(--border-strong)]\"\n />\n <span id={statusId} className=\"sr-only\">\n {isEmpty ? labels.empty : labels.signed}\n </span>\n </div>\n\n {typed && (\n <Input\n label={labels.typedName}\n value={typedName}\n autoComplete=\"name\"\n disabled={disabled}\n onChange={(e) => onTypedChange(e.target.value)}\n />\n )}\n\n <div className=\"flex flex-wrap items-center gap-2\">\n {!typed && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n onClick={undo}\n aria-disabled={disabled || strokeCount === 0 || undefined}\n className={softDisabled}\n >\n <Undo2 aria-hidden=\"true\" className=\"size-4\" />\n {labels.undo}\n </Button>\n )}\n <Button\n type=\"button\"\n variant=\"ghost\"\n onClick={clear}\n aria-disabled={disabled || isEmpty || undefined}\n className={softDisabled}\n >\n <Eraser aria-hidden=\"true\" className=\"size-4\" />\n {labels.clear}\n </Button>\n {allowTypedName && (\n <Button\n type=\"button\"\n variant=\"secondary\"\n onClick={switchMode}\n disabled={disabled}\n >\n {typed ? <PenLine aria-hidden=\"true\" className=\"size-4\" /> : <Keyboard aria-hidden=\"true\" className=\"size-4\" />}\n {typed ? labels.useDrawn : labels.useTyped}\n </Button>\n )}\n {onSave && (\n <Button type=\"button\" variant=\"brand\" onClick={save} disabled={disabled || isEmpty} className=\"ms-auto\">\n {labels.save}\n </Button>\n )}\n </div>\n\n {hasError && (\n <p id={errorId} className=\"mt-1 text-[11px] leading-tight text-[var(--danger)]\">\n {error}\n </p>\n )}\n {/* Rendered from the start and never unmounted — see useAnnounce. */}\n <div {...regionProps} />\n </div>\n );\n});\nSignaturePad.displayName = \"SignaturePad\";\n\n/* ── Read-only ───────────────────────────────────────────────────────────── */\n\nexport interface SignatureViewProps extends ComponentPropsWithoutRef<\"figure\"> {\n /** The saved PNG — what `SignaturePad` handed to `onChange`/`onSave`, as stored. */\n value?: string | null;\n /**\n * A signature given as a typed name (`detail.typedName`), for a host that stores the\n * text rather than its PNG. Rendered in the same script face the pad draws it in.\n * Ignored while `value` is set.\n */\n typedName?: string | null;\n /** Visible caption above the signature; defaults to `labels.label`. `null` hides it\n * (the image keeps its alternative text) — for a signature block whose own heading\n * already says whose signature it is. */\n label?: ReactNode;\n /**\n * The exported PNG is dark ink on a transparent ground (`exportInk`), which is\n * invisible on the dark theme's surface. By default the image is colour-inverted\n * under `.dark`, so the ink reads light; `false` keeps the pixels as stored — for a\n * PNG exported with its own `exportBackground`, which inverting would turn black.\n */\n adaptInk?: boolean;\n /** Classes for the frame — its height, chiefly (default `h-40`, the pad's). */\n frameClassName?: string;\n /** User-facing strings; see {@link SignaturePadLabels} (`view*`). */\n labels?: Partial<SignaturePadLabels>;\n}\n\n/**\n * A saved signature, shown — the read side of {@link SignaturePad}: the same frame and\n * signing line, none of the drawing chrome (no canvas, buttons, instructions or live\n * region). A separate component rather than a `readOnly` pad because there is nothing\n * of the pad to reuse: the pad's scene is STROKES, and a stored signature is a PNG\n * (or a name) that cannot be turned back into them.\n *\n * Kastlan's handover protocol, reopened after signing, is the case: two signatures\n * that must be visible, and must not look editable.\n */\nexport function SignatureView({\n value,\n typedName,\n label,\n adaptInk = true,\n frameClassName,\n labels: labelsProp,\n className,\n ...rest\n}: SignatureViewProps) {\n const labels = useKitLabels(\"signaturePad\", DEFAULT_SIGNATURE_PAD_LABELS, labelsProp);\n const name = typedName?.trim() ?? \"\";\n const kind = value ? \"drawn\" : name ? \"typed\" : \"empty\";\n const caption = label === undefined ? labels.label : label;\n const captionId = useId();\n const captioned = caption !== null && caption !== false;\n return (\n <figure\n // Named explicitly: the figcaption-to-figure name is not computed everywhere.\n aria-labelledby={captioned ? captionId : undefined}\n {...rest}\n className={cn(\"m-0 space-y-1.5\", className)}\n data-empty={kind === \"empty\" || undefined}\n >\n {captioned && (\n <figcaption id={captionId} className=\"block text-sm font-medium text-[var(--text-primary)]\">{caption}</figcaption>\n )}\n <div\n className={cn(\n \"relative flex h-40 items-center justify-center overflow-hidden rounded-md border border-[var(--border)] bg-[var(--bg-surface)]\",\n frameClassName,\n )}\n >\n {kind === \"drawn\" && (\n <img\n src={value as string}\n alt={labels.viewDrawn}\n className={cn(\"relative max-h-full max-w-full object-contain\", adaptInk && \"dark:invert\")}\n />\n )}\n {kind === \"typed\" && (\n // One name for the whole thing: the visible text alone would be read as a bare\n // name, with nothing saying it IS the signature.\n <span\n role=\"img\"\n aria-label={labels.viewTyped(name)}\n className=\"relative max-w-[85%] truncate px-2 text-4xl italic text-[var(--text-primary)]\"\n style={{ fontFamily: SCRIPT_FONT }}\n >\n {name}\n </span>\n )}\n {kind === \"empty\" && (\n <span className=\"relative text-xs text-[var(--text-muted)]\">{labels.viewEmpty}</span>\n )}\n {/* The signing line, as on the pad. Decoration only. */}\n <div\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-x-6 bottom-8 border-b border-dashed border-[var(--border-strong)]\"\n />\n </div>\n </figure>\n );\n}\n"],"mappings":";AAshBQ,cAGA,YAHA;AAthBR,SAAS,YAAY,aAAa,WAAW,OAAO,qBAAqB,iBAAiB,QAAQ,gBAAgB;AAElH,SAAS,QAAQ,UAAU,SAAS,aAAa;AACjD,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,QAAQ,eAAe,aAAa;AA4EtC,MAAM,+BAAmD;AAAA,EAC9D,OAAO;AAAA,EACP,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,UAAU;AAAA,EACV,UAAU;AAAA,EACV,WAAW;AAAA,EACX,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW,CAAC,SAAS,8BAA8B,IAAI;AACzD;AAkEA,MAAM,qBAAqB;AAI3B,MAAM,cAAc;AAGpB,MAAM,gBAAgB,CAAC,MAAc,MAAM,MAAM;AAEjD,MAAM,MAAM,CAAC,GAAU,OAAqB,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,GAAG,IAA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ACL,cAAY,OAAO,UAAU,IAAI;AAAA,kBACjC,WAAU;AAAA,kBACV,OAAO,EAAE,YAAY,YAAY;AAAA,kBAEhC;AAAA;AAAA,cACH;AAAA,cAED,SAAS,WACR,oBAAC,UAAK,WAAU,6CAA6C,iBAAO,WAAU;AAAA,cAGhF;AAAA,gBAAC;AAAA;AAAA,kBACC,eAAY;AAAA,kBACZ,WAAU;AAAA;AAAA,cACZ;AAAA;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["SignaturePad"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/signature-pad.tsx"],"sourcesContent":["import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, PointerEvent as ReactPointerEvent, ReactNode } from \"react\";\nimport { Eraser, Keyboard, PenLine, Undo2 } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { useAnnounce } from \"../hooks/use-announce\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { useTextSize } from \"../theme/text-size\";\nimport { Button, FIELD_INVALID, Input } from \"./ui\";\n\n/**\n * A drawn signature, captured on a canvas and handed back as a PNG data URL.\n *\n * Kastlan wrote the first one (`features/handover/components/signature-pad.tsx`) for\n * the handover protocol, where tenant and inspector each sign on the same phone. This\n * keeps its contract — draw, get a PNG — and fixes what a copy per app would keep\n * getting wrong:\n *\n * 1. **Strokes are data, not pixels.** Each stroke is kept as a list of points, and\n * the canvas is a VIEW of them. That is what lets a resize (a phone rotating\n * mid-signature) keep the drawing instead of wiping it — setting `canvas.width`\n * clears the bitmap, so a pixels-only pad loses everything — and what makes undo\n * one `pop()`. The pixel buffer is sized to `devicePixelRatio`, so a stroke is\n * sharp on a 3× screen rather than upscaled from a 1× bitmap.\n * 2. **Smooth, and pressure-aware.** Segments are quadratic curves through the\n * midpoints between samples, so a fast stroke is a curve, not a polyline; a pen\n * that reports pressure varies the width, a mouse or finger (whose `pressure` is a\n * constant 0.5, or junk) draws at the base width.\n * 3. **Two inks.** On screen the ink is the computed `color` of the canvas, which is\n * `--text-primary` — so it reads in the dark theme, where a hard-coded near-black\n * stroke vanished into the surface. The exported PNG is re-rendered from the same\n * strokes in `exportInk` (near-black by default) on a transparent background. A\n * signature is a DOCUMENT artefact: it is printed on the protocol, shown on a white\n * card, embedded in a PDF — none of which follow the signer's theme. Exporting\n * the on-screen ink would have produced a pale-grey-on-transparent PNG for every\n * dark-mode signer, invisible on white paper.\n *\n * **Accessibility.** A canvas has no content a screen reader or a keyboard can reach,\n * and no amount of ARIA changes that — drawing is a pointer act. What the pad does:\n * the canvas is `role=\"img\"`, named by the visible label and described by the\n * instructions and by its state (\"Nothing drawn yet\" / \"Signature drawn\"), so a\n * screen-reader user knows what the box is and whether it holds anything; undo and\n * clear are real buttons, and their effect is announced. What it cannot do is let\n * someone sign without a pointer — hence `allowTypedName`, which offers a typed name\n * instead. It is OPT-IN, because whether a typed name counts as a signature is a\n * product and legal decision, not a UI one (Kastlan's handover accepts one; a flow\n * that needs a drawn mark would not). Where a drawn mark is not strictly required,\n * turn it on.\n */\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** Every string the pad renders or speaks. */\nexport interface SignaturePadLabels {\n /** Visible label above the pad, and the canvas's accessible name. The `label`\n * prop overrides it per instance. */\n label: string;\n /** Under the label, and part of the canvas's description. */\n instructions: string;\n /** Appended to the instructions when `allowTypedName` is on. */\n typedFallbackHint: string;\n /** The canvas's state for a screen reader. */\n empty: string;\n signed: string;\n undo: string;\n clear: string;\n /** Only rendered when `onSave` is given. */\n save: string;\n /** The mode switch (`allowTypedName`). */\n useTyped: string;\n useDrawn: string;\n /** Label of the typed-name field. */\n typedName: string;\n /** Live-region messages after the matching button. */\n cleared: string;\n undone: string;\n /** {@link SignatureView}: what it says when there is no signature to show. */\n viewEmpty: string;\n /** {@link SignatureView}: the saved PNG's alternative text. */\n viewDrawn: string;\n /** {@link SignatureView}: the accessible name of a typed-name signature. */\n viewTyped: (name: string) => string;\n}\n\nexport const DEFAULT_SIGNATURE_PAD_LABELS: SignaturePadLabels = {\n label: \"Signature\",\n instructions: \"Sign in the box with a mouse, your finger or a pen.\",\n typedFallbackHint: \"If you cannot draw, type your name instead.\",\n empty: \"Nothing drawn yet\",\n signed: \"Signature drawn\",\n undo: \"Undo last stroke\",\n clear: \"Clear\",\n save: \"Save signature\",\n useTyped: \"Type name instead\",\n useDrawn: \"Draw instead\",\n typedName: \"Full name\",\n cleared: \"Signature cleared\",\n undone: \"Last stroke removed\",\n viewEmpty: \"Not signed\",\n viewDrawn: \"Handwritten signature\",\n viewTyped: (name) => `Signed with the typed name ${name}`,\n};\n\n/* ── Types ───────────────────────────────────────────────────────────────── */\n\n/** How the value handed back was made. */\nexport interface SignatureDetail {\n method: \"drawn\" | \"typed\";\n /** The name as typed, when `method` is `\"typed\"` — the PNG shows it, but a host\n * that stores a typed name as TEXT (Kastlan does) wants the string. */\n typedName?: string;\n}\n\n/** The imperative handle: `ref.current.toDataURL()` at submit time, for a form that\n * does not want to mirror the value into state on every stroke. */\nexport interface SignaturePadHandle {\n /** Remove every stroke and the typed name. Fires `onChange(null)`. */\n clear: () => void;\n /** The PNG, rendered in `exportInk` — or `null` while nothing is signed. */\n toDataURL: () => string | null;\n isEmpty: () => boolean;\n}\n\nexport interface SignaturePadProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onChange\"> {\n /** Visible label; defaults to `labels.label`. */\n label?: ReactNode;\n /** Replaces `labels.instructions` for this instance (e.g. a legal note). */\n description?: ReactNode;\n /**\n * After every finished stroke, undo, clear and typed-name edit: the PNG, or `null`\n * once the pad is empty. Not called mid-stroke — encoding a PNG per pointer move\n * would stall the drawing on a phone.\n */\n onChange?: (dataUrl: string | null, detail: SignatureDetail) => void;\n /** Renders a Save button, enabled once something is signed. */\n onSave?: (dataUrl: string, detail: SignatureDetail) => void;\n disabled?: boolean;\n /** Paints the pad as wrong and sets `aria-invalid`. See {@link Input}'s `invalid`. */\n invalid?: boolean;\n /** Message under the pad; implies `invalid` and is attached with\n * `aria-describedby`, like the kit's other fields. */\n error?: ReactNode;\n /** Offer a typed name as an alternative to drawing. See the accessibility note. */\n allowTypedName?: boolean;\n /** Ink of the exported PNG. Default near-black, legible on white. */\n exportInk?: string;\n /** Fill behind the exported PNG. Default transparent. */\n exportBackground?: string;\n /** Base stroke width in CSS pixels at Normal text size. Default 2.5. It grows with the\n * text size (× 1.25 / × 1.5, docs/text-size-harmonization.md §10.11), as the pad's\n * rem height does, so a signature keeps its weight on a larger pad. */\n lineWidth?: number;\n /** Classes for the canvas — its height, chiefly (default `h-40`). */\n canvasClassName?: string;\n /** User-facing strings; see {@link SignaturePadLabels}. */\n labels?: Partial<SignaturePadLabels>;\n}\n\n/* ── Drawing ─────────────────────────────────────────────────────────────── */\n\ninterface Point {\n x: number;\n y: number;\n /** 0–1. A constant 0.5 for anything that is not a pen. */\n p: number;\n}\n\ntype Stroke = Point[];\n\nconst DEFAULT_EXPORT_INK = \"#111111\";\n\n// A handwriting face where the platform has one, `cursive` everywhere else. Only\n// ever used to render a typed name onto the canvas.\nconst SCRIPT_FONT = `\"Segoe Script\", \"Bradley Hand\", \"Brush Script MT\", cursive`;\n\n/** Width multiplier from pressure: 0.5 (the no-pen constant) is exactly 1. */\nconst pressureWidth = (p: number) => 0.4 + 1.2 * p;\n\nconst mid = (a: Point, b: Point): Point => ({ x: (a.x + b.x) / 2, y: (a.y + b.y) / 2, p: (a.p + b.p) / 2 });\n\n/**\n * Segment `i` (1 ≤ i < n) of a stroke: a quadratic from the midpoint before sample\n * `i - 1` to the midpoint after it, with the sample as the control point. The live\n * drawing and the full repaint both go through here, so a stroke looks the same\n * before and after a resize.\n */\nfunction drawSegment(ctx: CanvasRenderingContext2D, pts: Stroke, i: number, scale: number, width: number) {\n const a = i === 1 ? pts[0] : mid(pts[i - 2], pts[i - 1]);\n const c = pts[i - 1];\n const b = mid(pts[i - 1], pts[i]);\n ctx.lineWidth = width * scale * pressureWidth((a.p + b.p) / 2);\n ctx.beginPath();\n ctx.moveTo(a.x * scale, a.y * scale);\n ctx.quadraticCurveTo(c.x * scale, c.y * scale, b.x * scale, b.y * scale);\n ctx.stroke();\n}\n\n/** The last half-segment, from the final midpoint to the final sample. Drawn once the\n * stroke is finished — while drawing, the pen is still there and it would be redrawn\n * on every move. A single tap is a dot. */\nfunction drawTail(ctx: CanvasRenderingContext2D, pts: Stroke, scale: number, width: number) {\n const last = pts[pts.length - 1];\n if (pts.length === 1) {\n ctx.beginPath();\n ctx.arc(last.x * scale, last.y * scale, (width * scale * pressureWidth(last.p)) / 2, 0, Math.PI * 2);\n ctx.fill();\n return;\n }\n const from = pts.length === 2 ? pts[0] : mid(pts[pts.length - 2], last);\n ctx.lineWidth = width * scale * pressureWidth(last.p);\n ctx.beginPath();\n ctx.moveTo(from.x * scale, from.y * scale);\n ctx.lineTo(last.x * scale, last.y * scale);\n ctx.stroke();\n}\n\nfunction prepare(ctx: CanvasRenderingContext2D, ink: string, dpr: number) {\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n ctx.lineCap = \"round\";\n ctx.lineJoin = \"round\";\n ctx.strokeStyle = ink;\n ctx.fillStyle = ink;\n}\n\n/** A typed name, as large as fits, on the pad's baseline. */\nfunction drawName(ctx: CanvasRenderingContext2D, name: string, w: number, h: number) {\n let size = Math.min(48, h * 0.45);\n ctx.font = `italic ${size}px ${SCRIPT_FONT}`;\n const room = w * 0.85;\n const measured = ctx.measureText(name).width;\n if (measured > room) {\n size = Math.max(12, (size * room) / measured);\n ctx.font = `italic ${size}px ${SCRIPT_FONT}`;\n }\n ctx.textAlign = \"center\";\n ctx.textBaseline = \"alphabetic\";\n ctx.fillText(name, w / 2, h * 0.68);\n}\n\n/* ── The component ───────────────────────────────────────────────────────── */\n\nexport const SignaturePad = forwardRef<SignaturePadHandle, SignaturePadProps>(function SignaturePad(\n {\n label,\n description,\n onChange,\n onSave,\n disabled,\n invalid,\n error,\n allowTypedName,\n exportInk = DEFAULT_EXPORT_INK,\n exportBackground,\n lineWidth = 2.5,\n canvasClassName,\n labels: labelsProp,\n className,\n ...rest\n },\n ref,\n) {\n // Prop > <UiKitProvider> > English, like every labelled component in the kit.\n const labels = useKitLabels(\"signaturePad\", DEFAULT_SIGNATURE_PAD_LABELS, labelsProp);\n const { announce, regionProps } = useAnnounce();\n const labelId = useId();\n const descId = useId();\n const statusId = useId();\n const errorId = useId();\n\n const canvasRef = useRef<HTMLCanvasElement>(null);\n /**\n * What is on the pad lives in a ref, not in state: a pointer move must not\n * re-render, and `onChange` has to see the pad AFTER a change, from inside the\n * handler that made it — before React has rendered anything. The state below\n * mirrors the parts the markup needs (empty or not, which mode, the field's text).\n */\n const scene = useRef<{ strokes: Stroke[]; mode: \"drawn\" | \"typed\"; name: string }>({\n strokes: [],\n mode: \"drawn\",\n name: \"\",\n });\n const live = useRef<{ id: number; stroke: Stroke } | null>(null);\n /**\n * The canvas width, in CSS px, the stored points are relative to. Fixed by the\n * first stroke; a later resize scales the drawing UNIFORMLY by `width / refWidth`,\n * so a rotated phone shows the same signature larger or smaller, never stretched.\n */\n const refWidth = useRef(0);\n const [strokeCount, setStrokeCount] = useState(0);\n const [mode, setMode] = useState<\"drawn\" | \"typed\">(\"drawn\");\n const [typedName, setTypedName] = useState(\"\");\n\n const typed = mode === \"typed\";\n const isEmpty = typed ? typedName.trim() === \"\" : strokeCount === 0;\n\n // Everything the paint and export paths read that can change between renders, so\n // the observers below subscribe once instead of on every keystroke.\n // The stroke follows the text size like everything in rem around it (§10.11).\n const { scale: textScale } = useTextSize();\n const strokeWidth = lineWidth * textScale;\n const opts = useRef({ lineWidth: strokeWidth, exportInk, exportBackground });\n useEffect(() => {\n opts.current = { lineWidth: strokeWidth, exportInk, exportBackground };\n }, [strokeWidth, exportInk, exportBackground]);\n\n const sceneEmpty = () => {\n const s = scene.current;\n return s.mode === \"typed\" ? s.name.trim() === \"\" : s.strokes.length === 0;\n };\n\n /** The whole scene, painted into `ctx` at `w`×`h` CSS px. */\n const paintInto = useCallback((ctx: CanvasRenderingContext2D, ink: string, w: number, h: number, dpr: number) => {\n const { lineWidth: width } = opts.current;\n const s = scene.current;\n prepare(ctx, ink, dpr);\n if (s.mode === \"typed\") {\n if (s.name.trim()) drawName(ctx, s.name.trim(), w, h);\n return;\n }\n const scale = refWidth.current > 0 ? w / refWidth.current : 1;\n for (const stroke of s.strokes) {\n for (let i = 1; i < stroke.length; i += 1) drawSegment(ctx, stroke, i, scale, width);\n drawTail(ctx, stroke, scale, width);\n }\n const pending = live.current?.stroke;\n if (pending) for (let i = 1; i < pending.length; i += 1) drawSegment(ctx, pending, i, scale, width);\n }, []);\n\n /** The ink on screen: the canvas's own computed `color`, i.e. `--text-primary`. */\n const screenInk = (canvas: HTMLCanvasElement) =>\n // Read as `color` rather than as the custom property: `--text-primary` is whatever\n // the palette wrote (a `color-mix()` in some presets), which a 2D context may not\n // parse; `color` has already been resolved by the browser.\n getComputedStyle(canvas).color || opts.current.exportInk;\n\n /** Repaint the visible canvas from the scene, in the theme's ink. */\n const repaint = useCallback(() => {\n const canvas = canvasRef.current;\n const ctx = canvas?.getContext(\"2d\");\n if (!canvas || !ctx) return;\n const dpr = window.devicePixelRatio || 1;\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n paintInto(ctx, screenInk(canvas), canvas.width / dpr, canvas.height / dpr, dpr);\n }, [paintInto]);\n\n /** Size the bitmap to the element × devicePixelRatio, then repaint. */\n const resize = useCallback(() => {\n const canvas = canvasRef.current;\n if (!canvas) return;\n const rect = canvas.getBoundingClientRect();\n const dpr = window.devicePixelRatio || 1;\n const w = Math.round(rect.width * dpr);\n const h = Math.round(rect.height * dpr);\n // Assigning `width` clears the bitmap even when the value is unchanged, so only\n // when it moved — and the repaint puts the strokes back either way.\n if (canvas.width !== w) canvas.width = w;\n if (canvas.height !== h) canvas.height = h;\n repaint();\n }, [repaint]);\n\n useLayoutEffect(() => {\n resize();\n }, [resize]);\n\n // A changed base width — or text size — redraws what is already there.\n useEffect(() => {\n repaint();\n }, [strokeWidth, repaint]);\n\n useEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas) return;\n const cleanups: Array<() => void> = [];\n if (typeof ResizeObserver !== \"undefined\") {\n const ro = new ResizeObserver(() => resize());\n ro.observe(canvas);\n cleanups.push(() => ro.disconnect());\n }\n // The ink follows the theme, and the theme is a class (`.dark`) or inline\n // variables (the palette store) on <html> — neither of which tells a canvas.\n if (typeof MutationObserver !== \"undefined\") {\n const mo = new MutationObserver(() => repaint());\n mo.observe(document.documentElement, { attributes: true, attributeFilter: [\"class\", \"style\", \"data-theme\"] });\n cleanups.push(() => mo.disconnect());\n }\n const mq = typeof window.matchMedia === \"function\" ? window.matchMedia(\"(prefers-color-scheme: dark)\") : null;\n if (mq?.addEventListener) {\n mq.addEventListener(\"change\", repaint);\n cleanups.push(() => mq.removeEventListener(\"change\", repaint));\n }\n return () => cleanups.forEach((fn) => fn());\n }, [resize, repaint]);\n\n /** The PNG, re-rendered off-screen in the export ink — `null` while empty. */\n const exportPng = useCallback((): string | null => {\n const canvas = canvasRef.current;\n if (!canvas || sceneEmpty()) return null;\n const { exportInk: ink, exportBackground: bg } = opts.current;\n const dpr = window.devicePixelRatio || 1;\n const out = document.createElement(\"canvas\");\n out.width = canvas.width;\n out.height = canvas.height;\n const ctx = out.getContext(\"2d\");\n if (!ctx) return null;\n if (bg) {\n ctx.fillStyle = bg;\n ctx.fillRect(0, 0, out.width, out.height);\n }\n paintInto(ctx, ink, out.width / dpr, out.height / dpr, dpr);\n return out.toDataURL(\"image/png\");\n }, [paintInto]);\n\n const detail = (): SignatureDetail => {\n const s = scene.current;\n return s.mode === \"typed\" ? { method: \"typed\", typedName: s.name.trim() } : { method: \"drawn\" };\n };\n\n /** After every change to the scene: sync the markup's mirror, repaint, tell the host. */\n const onChangeRef = useRef(onChange);\n useEffect(() => {\n onChangeRef.current = onChange;\n }, [onChange]);\n const commit = () => {\n const s = scene.current;\n setStrokeCount(s.strokes.length);\n setMode(s.mode);\n setTypedName(s.name);\n repaint();\n onChangeRef.current?.(exportPng(), detail());\n };\n\n const clearScene = () => {\n scene.current = { ...scene.current, strokes: [], name: \"\" };\n live.current = null;\n refWidth.current = 0;\n commit();\n };\n\n useImperativeHandle(ref, () => ({ clear: clearScene, toDataURL: exportPng, isEmpty: sceneEmpty }));\n\n /* ── Pointer ── */\n\n const toPoint = (e: { clientX: number; clientY: number; pressure: number; pointerType: string }, rect: DOMRect): Point => {\n const scale = refWidth.current > 0 && rect.width > 0 ? rect.width / refWidth.current : 1;\n return {\n x: (e.clientX - rect.left) / scale,\n y: (e.clientY - rect.top) / scale,\n // Only a pen's pressure means anything: a mouse reports 0.5 while pressed and\n // touch hardware reports 0, 1 or noise.\n p: e.pointerType === \"pen\" && e.pressure > 0 ? e.pressure : 0.5,\n };\n };\n\n const onPointerDown = (e: ReactPointerEvent<HTMLCanvasElement>) => {\n // One stroke at a time: a palm resting beside the pen is a second pointer.\n if (disabled || typed || live.current) return;\n if (e.pointerType === \"mouse\" && e.button !== 0) return;\n e.preventDefault();\n const canvas = e.currentTarget;\n canvas.setPointerCapture?.(e.pointerId);\n const rect = canvas.getBoundingClientRect();\n if (refWidth.current === 0) refWidth.current = rect.width || 1;\n live.current = { id: e.pointerId, stroke: [toPoint(e, rect)] };\n };\n\n const onPointerMove = (e: ReactPointerEvent<HTMLCanvasElement>) => {\n const pending = live.current;\n if (!pending || pending.id !== e.pointerId) return;\n e.preventDefault();\n const canvas = e.currentTarget;\n const rect = canvas.getBoundingClientRect();\n // Coalesced events: the samples the browser merged into this one move. A fast\n // flick on a 120 Hz pen is otherwise a handful of long straight chords.\n const samples = e.nativeEvent.getCoalescedEvents?.() ?? [];\n const events = samples.length > 0 ? samples : [e];\n const ctx = canvas.getContext(\"2d\");\n if (ctx) prepare(ctx, screenInk(canvas), window.devicePixelRatio || 1);\n const scale = refWidth.current > 0 && rect.width > 0 ? rect.width / refWidth.current : 1;\n for (const ev of events) {\n pending.stroke.push(toPoint(ev, rect));\n // Only the newest segment — a full repaint per move is O(ink) on every event.\n if (ctx) drawSegment(ctx, pending.stroke, pending.stroke.length - 1, scale, opts.current.lineWidth);\n }\n };\n\n const endStroke = (e: ReactPointerEvent<HTMLCanvasElement>) => {\n const pending = live.current;\n if (!pending || pending.id !== e.pointerId) return;\n e.currentTarget.releasePointerCapture?.(e.pointerId);\n live.current = null;\n scene.current = { ...scene.current, strokes: [...scene.current.strokes, pending.stroke] };\n commit();\n };\n\n /* ── Buttons ── */\n\n const undo = () => {\n if (disabled || scene.current.strokes.length === 0) return;\n const strokes = scene.current.strokes.slice(0, -1);\n if (strokes.length === 0) refWidth.current = 0;\n scene.current = { ...scene.current, strokes };\n commit();\n announce(labels.undone);\n };\n\n const clear = () => {\n if (disabled || sceneEmpty()) return;\n clearScene();\n announce(labels.cleared);\n };\n\n const switchMode = () => {\n if (disabled) return;\n scene.current = { ...scene.current, mode: scene.current.mode === \"drawn\" ? \"typed\" : \"drawn\" };\n commit();\n };\n\n const onTypedChange = (name: string) => {\n scene.current = { ...scene.current, name };\n commit();\n };\n\n const save = () => {\n if (disabled) return;\n const png = exportPng();\n if (png) onSave?.(png, detail());\n };\n\n const hasError = error !== undefined && error !== null && error !== false && error !== \"\";\n const isInvalid = Boolean(invalid) || hasError;\n const describedBy = [descId, statusId, hasError ? errorId : null].filter(Boolean).join(\" \");\n\n // `aria-disabled` rather than `disabled` on undo/clear: they disable THEMSELVES\n // (clear empties the pad, the last undo does too), and a natively disabled button\n // drops keyboard focus to <body> the moment it is activated.\n const softDisabled = \"aria-disabled:cursor-not-allowed aria-disabled:opacity-50\";\n\n return (\n <div {...rest} className={cn(\"relative space-y-1.5\", className)} data-empty={isEmpty || undefined}>\n <div>\n <span id={labelId} className=\"block text-sm font-medium text-[var(--text-primary)]\">\n {label ?? labels.label}\n </span>\n <p id={descId} className=\"text-xs text-[var(--text-muted)]\">\n {description ?? labels.instructions}\n {allowTypedName && !typed ? ` ${labels.typedFallbackHint}` : null}\n </p>\n </div>\n\n <div className=\"relative\">\n <canvas\n ref={canvasRef}\n role=\"img\"\n aria-labelledby={labelId}\n aria-describedby={describedBy}\n // No `aria-invalid` / `aria-disabled`: `img` supports neither. The error\n // reaches a screen reader through `aria-describedby`; the attributes below\n // are for styling and tests.\n data-invalid={isInvalid || undefined}\n data-disabled={disabled || undefined}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={endStroke}\n onPointerCancel={endStroke}\n className={cn(\n // `touch-none` stops the page scrolling under a finger that is signing.\n \"block h-40 w-full touch-none select-none rounded-md border border-[var(--border)] bg-[var(--bg-surface)] text-[var(--text-primary)]\",\n typed || disabled ? \"cursor-default\" : \"cursor-crosshair\",\n disabled && \"opacity-60\",\n isInvalid && FIELD_INVALID,\n canvasClassName,\n )}\n />\n {/* The signing line — where people expect to sign. Decoration only. */}\n <div\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-x-6 bottom-8 border-b border-dashed border-[var(--border-strong)]\"\n />\n <span id={statusId} className=\"sr-only\">\n {isEmpty ? labels.empty : labels.signed}\n </span>\n </div>\n\n {typed && (\n <Input\n label={labels.typedName}\n value={typedName}\n autoComplete=\"name\"\n disabled={disabled}\n onChange={(e) => onTypedChange(e.target.value)}\n />\n )}\n\n <div className=\"flex flex-wrap items-center gap-2\">\n {!typed && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n onClick={undo}\n aria-disabled={disabled || strokeCount === 0 || undefined}\n className={softDisabled}\n >\n <Undo2 aria-hidden=\"true\" className=\"size-4\" />\n {labels.undo}\n </Button>\n )}\n <Button\n type=\"button\"\n variant=\"ghost\"\n onClick={clear}\n aria-disabled={disabled || isEmpty || undefined}\n className={softDisabled}\n >\n <Eraser aria-hidden=\"true\" className=\"size-4\" />\n {labels.clear}\n </Button>\n {allowTypedName && (\n <Button\n type=\"button\"\n variant=\"secondary\"\n onClick={switchMode}\n disabled={disabled}\n >\n {typed ? <PenLine aria-hidden=\"true\" className=\"size-4\" /> : <Keyboard aria-hidden=\"true\" className=\"size-4\" />}\n {typed ? labels.useDrawn : labels.useTyped}\n </Button>\n )}\n {onSave && (\n <Button type=\"button\" variant=\"brand\" onClick={save} disabled={disabled || isEmpty} className=\"ms-auto\">\n {labels.save}\n </Button>\n )}\n </div>\n\n {hasError && (\n <p id={errorId} className=\"mt-1 text-caption leading-tight text-[var(--danger)]\">\n {error}\n </p>\n )}\n {/* Rendered from the start and never unmounted — see useAnnounce. */}\n <div {...regionProps} />\n </div>\n );\n});\nSignaturePad.displayName = \"SignaturePad\";\n\n/* ── Read-only ───────────────────────────────────────────────────────────── */\n\nexport interface SignatureViewProps extends ComponentPropsWithoutRef<\"figure\"> {\n /** The saved PNG — what `SignaturePad` handed to `onChange`/`onSave`, as stored. */\n value?: string | null;\n /**\n * A signature given as a typed name (`detail.typedName`), for a host that stores the\n * text rather than its PNG. Rendered in the same script face the pad draws it in.\n * Ignored while `value` is set.\n */\n typedName?: string | null;\n /** Visible caption above the signature; defaults to `labels.label`. `null` hides it\n * (the image keeps its alternative text) — for a signature block whose own heading\n * already says whose signature it is. */\n label?: ReactNode;\n /**\n * The exported PNG is dark ink on a transparent ground (`exportInk`), which is\n * invisible on the dark theme's surface. By default the image is colour-inverted\n * under `.dark`, so the ink reads light; `false` keeps the pixels as stored — for a\n * PNG exported with its own `exportBackground`, which inverting would turn black.\n */\n adaptInk?: boolean;\n /** Classes for the frame — its height, chiefly (default `h-40`, the pad's). */\n frameClassName?: string;\n /** User-facing strings; see {@link SignaturePadLabels} (`view*`). */\n labels?: Partial<SignaturePadLabels>;\n}\n\n/**\n * A saved signature, shown — the read side of {@link SignaturePad}: the same frame and\n * signing line, none of the drawing chrome (no canvas, buttons, instructions or live\n * region). A separate component rather than a `readOnly` pad because there is nothing\n * of the pad to reuse: the pad's scene is STROKES, and a stored signature is a PNG\n * (or a name) that cannot be turned back into them.\n *\n * Kastlan's handover protocol, reopened after signing, is the case: two signatures\n * that must be visible, and must not look editable.\n */\nexport function SignatureView({\n value,\n typedName,\n label,\n adaptInk = true,\n frameClassName,\n labels: labelsProp,\n className,\n ...rest\n}: SignatureViewProps) {\n const labels = useKitLabels(\"signaturePad\", DEFAULT_SIGNATURE_PAD_LABELS, labelsProp);\n const name = typedName?.trim() ?? \"\";\n const kind = value ? \"drawn\" : name ? \"typed\" : \"empty\";\n const caption = label === undefined ? labels.label : label;\n const captionId = useId();\n const captioned = caption !== null && caption !== false;\n return (\n <figure\n // Named explicitly: the figcaption-to-figure name is not computed everywhere.\n aria-labelledby={captioned ? captionId : undefined}\n {...rest}\n className={cn(\"m-0 space-y-1.5\", className)}\n data-empty={kind === \"empty\" || undefined}\n >\n {captioned && (\n <figcaption id={captionId} className=\"block text-sm font-medium text-[var(--text-primary)]\">{caption}</figcaption>\n )}\n <div\n className={cn(\n \"relative flex h-40 items-center justify-center overflow-hidden rounded-md border border-[var(--border)] bg-[var(--bg-surface)]\",\n frameClassName,\n )}\n >\n {kind === \"drawn\" && (\n <img\n src={value as string}\n alt={labels.viewDrawn}\n className={cn(\"relative max-h-full max-w-full object-contain\", adaptInk && \"dark:invert\")}\n />\n )}\n {kind === \"typed\" && (\n // One name for the whole thing: the visible text alone would be read as a bare\n // name, with nothing saying it IS the signature.\n <span\n role=\"img\"\n aria-label={labels.viewTyped(name)}\n className=\"relative max-w-[85%] truncate px-2 text-4xl italic text-[var(--text-primary)]\"\n style={{ fontFamily: SCRIPT_FONT }}\n >\n {name}\n </span>\n )}\n {kind === \"empty\" && (\n <span className=\"relative text-xs text-[var(--text-muted)]\">{labels.viewEmpty}</span>\n )}\n {/* The signing line, as on the pad. Decoration only. */}\n <div\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-x-6 bottom-8 border-b border-dashed border-[var(--border-strong)]\"\n />\n </div>\n </figure>\n );\n}\n"],"mappings":";AA4hBQ,cAGA,YAHA;AA5hBR,SAAS,YAAY,a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L,GAAuB;AACrB,QAAM,SAAS,aAAa,gBAAgB,8BAA8B,UAAU;AACpF,QAAM,OAAO,WAAW,KAAK,KAAK;AAClC,QAAM,OAAO,QAAQ,UAAU,OAAO,UAAU;AAChD,QAAM,UAAU,UAAU,SAAY,OAAO,QAAQ;AACrD,QAAM,YAAY,MAAM;AACxB,QAAM,YAAY,YAAY,QAAQ,YAAY;AAClD,SACE;AAAA,IAAC;AAAA;AAAA,MAEC,mBAAiB,YAAY,YAAY;AAAA,MACxC,GAAG;AAAA,MACJ,WAAW,GAAG,mBAAmB,SAAS;AAAA,MAC1C,cAAY,SAAS,WAAW;AAAA,MAE/B;AAAA,qBACC,oBAAC,gBAAW,IAAI,WAAW,WAAU,wDAAwD,mBAAQ;AAAA,QAEvG;AAAA,UAAC;AAAA;AAAA,YACC,WAAW;AAAA,cACT;AAAA,cACA;AAAA,YACF;AAAA,YAEC;AAAA,uBAAS,WACR;AAAA,gBAAC;AAAA;AAAA,kBACC,KAAK;AAAA,kBACL,KAAK,OAAO;AAAA,kBACZ,WAAW,GAAG,iDAAiD,YAAY,aAAa;AAAA;AAAA,cAC1F;AAAA,cAED,SAAS;AAAA;AAAA,cAGR;AAAA,gBAAC;AAAA;AAAA,kBACC,MAAK;AAAA,kBACL,cAAY,OAAO,UAAU,IAAI;AAAA,kBACjC,WAAU;AAAA,kBACV,OAAO,EAAE,YAAY,YAAY;AAAA,kBAEhC;AAAA;AAAA,cACH;AAAA,cAED,SAAS,WACR,oBAAC,UAAK,WAAU,6CAA6C,iBAAO,WAAU;AAAA,cAGhF;AAAA,gBAAC;AAAA;AAAA,kBACC,eAAY;AAAA,kBACZ,WAAU;AAAA;AAAA,cACZ;AAAA;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["SignaturePad"]}
|
|
@@ -18,23 +18,24 @@ function fromLogPosition(position, min, max, zeroStop = true) {
|
|
|
18
18
|
return min * Math.pow(max / min, position);
|
|
19
19
|
}
|
|
20
20
|
const TRACK = [
|
|
21
|
-
"block h-6 w-full cursor-pointer appearance-none bg-transparent focus:outline-none disabled:cursor-not-allowed",
|
|
21
|
+
"block h-6 large:h-[48px] w-full cursor-pointer appearance-none bg-transparent focus:outline-none disabled:cursor-not-allowed",
|
|
22
22
|
// WebKit / Blink
|
|
23
23
|
"[&::-webkit-slider-runnable-track]:h-1.5 [&::-webkit-slider-runnable-track]:rounded-full",
|
|
24
24
|
"[&::-webkit-slider-runnable-track]:bg-[linear-gradient(to_right,var(--brand)_var(--slider-fill),var(--border-strong)_var(--slider-fill))]",
|
|
25
25
|
"rtl:[&::-webkit-slider-runnable-track]:bg-[linear-gradient(to_left,var(--brand)_var(--slider-fill),var(--border-strong)_var(--slider-fill))]",
|
|
26
|
-
"[&::-webkit-slider-thumb]:-mt-[
|
|
26
|
+
"[&::-webkit-slider-thumb]:-mt-[0.3125rem] [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none",
|
|
27
27
|
"[&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[var(--brand)] [&::-webkit-slider-thumb]:shadow",
|
|
28
|
-
"focus-visible:[&::-webkit-slider-thumb]:ring-
|
|
28
|
+
"focus-visible:[&::-webkit-slider-thumb]:ring-[length:var(--focus-ring-width)] focus-visible:[&::-webkit-slider-thumb]:ring-[var(--brand)]",
|
|
29
29
|
"focus-visible:[&::-webkit-slider-thumb]:ring-offset-2 focus-visible:[&::-webkit-slider-thumb]:ring-offset-[var(--bg-surface)]",
|
|
30
30
|
// Firefox
|
|
31
31
|
"[&::-moz-range-track]:h-1.5 [&::-moz-range-track]:rounded-full [&::-moz-range-track]:bg-[var(--border-strong)]",
|
|
32
32
|
"[&::-moz-range-progress]:h-1.5 [&::-moz-range-progress]:rounded-full [&::-moz-range-progress]:bg-[var(--brand)]",
|
|
33
33
|
"[&::-moz-range-thumb]:size-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0",
|
|
34
34
|
"[&::-moz-range-thumb]:bg-[var(--brand)] [&::-moz-range-thumb]:shadow",
|
|
35
|
-
"focus-visible:[&::-moz-range-thumb]:ring-
|
|
35
|
+
"focus-visible:[&::-moz-range-thumb]:ring-[length:var(--focus-ring-width)] focus-visible:[&::-moz-range-thumb]:ring-[var(--brand)]",
|
|
36
36
|
"focus-visible:[&::-moz-range-thumb]:ring-offset-2 focus-visible:[&::-moz-range-thumb]:ring-offset-[var(--bg-surface)]"
|
|
37
37
|
].join(" ");
|
|
38
|
+
const MARKS_LARGE = "large:-mt-[calc(24px-0.375rem)]";
|
|
38
39
|
const Slider = forwardRef(function Slider2({
|
|
39
40
|
value,
|
|
40
41
|
onChange,
|
|
@@ -133,7 +134,7 @@ const Slider = forwardRef(function Slider2({
|
|
|
133
134
|
"div",
|
|
134
135
|
{
|
|
135
136
|
"aria-hidden": true,
|
|
136
|
-
className: cn("relative mx-2 -mt-1.5", hasMarkLabels ? "h-5" : "h-1.5"),
|
|
137
|
+
className: cn("relative mx-2 -mt-1.5", MARKS_LARGE, hasMarkLabels ? "h-5" : "h-1.5"),
|
|
137
138
|
children: normalizedMarks.map((m) => /* @__PURE__ */ jsxs(
|
|
138
139
|
"span",
|
|
139
140
|
{
|
|
@@ -141,7 +142,7 @@ const Slider = forwardRef(function Slider2({
|
|
|
141
142
|
style: { insetInlineStart: `${share(position(m.value)) * 100}%` },
|
|
142
143
|
children: [
|
|
143
144
|
/* @__PURE__ */ jsx("span", { className: "h-1.5 w-px shrink-0 bg-[var(--border-strong)]" }),
|
|
144
|
-
m.label !== void 0 && /* @__PURE__ */ jsx("span", { className: "mt-0.5 select-none whitespace-nowrap text-
|
|
145
|
+
m.label !== void 0 && /* @__PURE__ */ jsx("span", { className: "mt-0.5 select-none whitespace-nowrap text-caption leading-tight text-[var(--text-muted)]", children: m.label })
|
|
145
146
|
]
|
|
146
147
|
},
|
|
147
148
|
m.value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/slider.tsx"],"sourcesContent":["import { forwardRef, useId } from \"react\";\nimport type { CSSProperties, ChangeEvent, InputHTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\n\n/**\n * A range control on a native `<input type=\"range\">`.\n *\n * Lenkbank wrote the first one (`shared/ui/slider-field.tsx`) and then the case for\n * moving it here (`docs/ui-kit-slider-proposal.md`). This is that proposal's \"stage 1\"\n * primitive — the track, the thumb, the scale and the accessibility — plus the label\n * line and tick marks its SpeedSlider needed. The four decisions it argues should be\n * made once are made here, and each carries its note below:\n *\n * 1. a logarithmic scale whose far-left stop means exactly zero ({@link SliderProps.zeroStop});\n * 2. `aria-valuetext`, so a log track does not announce its 0–1 position as the value;\n * 3. a 24px pointer target, which needs the track and thumb drawn separately;\n * 4. the number is the truth and the track a view of it: a value outside `min`–`max`\n * is kept and the thumb pins at the end — nothing here clamps what it was given.\n *\n * Controlled only, like `ToggleGroup` and `NumberInput`: there is no uncontrolled mode\n * to get wrong, and neither app wants one. The package does no number formatting and\n * holds no locale — `formatValue` is how the caller's `Intl` result gets in.\n *\n * Not here, deliberately (the proposal's list): two thumbs, vertical orientation, and\n * a number box. A `NumberInput` goes in the `readout` slot when a typed value is\n * wanted beside the track.\n */\n\n/** On a log scale with {@link SliderProps.zeroStop}, the share of the track that is\n * the \"off\" stop. The first position to its right is `min`. */\nconst ZERO_STOP = 0.02;\n\n/** Position resolution on a log track — 1000 stops, fine enough that a drag reads as\n * continuous. PageUp/PageDown still cross a tenth of the track at a time. */\nconst LOG_STEP = 0.001;\n\n/**\n * Where a value sits on a logarithmic track, 0–1.\n *\n * With `zeroStop`, zero and below is 0 and the decades between `min` and `max` are\n * mapped onto the rest; without it, `min` is the far left. A value past either end\n * pins there — that is the DISPLAY clamping, never the value's.\n */\nexport function toLogPosition(value: number, min: number, max: number, zeroStop = true): number {\n if (value <= 0) return 0;\n const share = Math.log(Math.max(value, min) / min) / Math.log(max / min);\n const clamped = Math.min(1, Math.max(0, share));\n return zeroStop ? ZERO_STOP + (1 - ZERO_STOP) * clamped : clamped;\n}\n\n/** The inverse of {@link toLogPosition}: the value at a track position. */\nexport function fromLogPosition(position: number, min: number, max: number, zeroStop = true): number {\n if (zeroStop) {\n if (position < ZERO_STOP) return 0;\n return min * Math.pow(max / min, (position - ZERO_STOP) / (1 - ZERO_STOP));\n }\n return min * Math.pow(max / min, position);\n}\n\n// The input is the pointer target, so its box is `h-6` (24px, WCAG 2.5.8) and the\n// track that LOOKS like a track is a 6px strip drawn inside it. Once the box is taller\n// than the track its background cannot be the track, and with `appearance-none`\n// nothing else draws one — measured in Chromium by Lenkbank, that is a bare thumb\n// floating on nothing, in the browser's blue. Hence the vendor pseudo-elements: the\n// two engines share no selector for either half, so each half is spelt twice.\n//\n// The fill up to the thumb: WebKit has no progress pseudo-element, so its track is a\n// two-stop gradient that breaks at `--slider-fill` (set inline from the position), and\n// the gradient runs the other way in a right-to-left document, where the native range\n// runs the other way too. Firefox draws the fill itself with `::-moz-range-progress`,\n// which follows the direction on its own.\n//\n// The thumb's `-mt-[5px]` centres a 16px thumb on a 6px track: WebKit lays the thumb\n// out from the track's top edge, Firefox centres it, so only one carries the offset.\n//\n// The focus ring goes on the THUMB, not the box: the box is the full width of the\n// row, and a ring round all of it says \"this row is focused\" rather than \"the handle\n// you are about to move is\". Offset in the surface colour, because the thumb is\n// --brand and a --brand ring touching it would be invisible.\nconst TRACK = [\n \"block h-6 w-full cursor-pointer appearance-none bg-transparent focus:outline-none disabled:cursor-not-allowed\",\n // WebKit / Blink\n \"[&::-webkit-slider-runnable-track]:h-1.5 [&::-webkit-slider-runnable-track]:rounded-full\",\n \"[&::-webkit-slider-runnable-track]:bg-[linear-gradient(to_right,var(--brand)_var(--slider-fill),var(--border-strong)_var(--slider-fill))]\",\n \"rtl:[&::-webkit-slider-runnable-track]:bg-[linear-gradient(to_left,var(--brand)_var(--slider-fill),var(--border-strong)_var(--slider-fill))]\",\n \"[&::-webkit-slider-thumb]:-mt-[5px] [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none\",\n \"[&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[var(--brand)] [&::-webkit-slider-thumb]:shadow\",\n \"focus-visible:[&::-webkit-slider-thumb]:ring-2 focus-visible:[&::-webkit-slider-thumb]:ring-[var(--brand)]\",\n \"focus-visible:[&::-webkit-slider-thumb]:ring-offset-2 focus-visible:[&::-webkit-slider-thumb]:ring-offset-[var(--bg-surface)]\",\n // Firefox\n \"[&::-moz-range-track]:h-1.5 [&::-moz-range-track]:rounded-full [&::-moz-range-track]:bg-[var(--border-strong)]\",\n \"[&::-moz-range-progress]:h-1.5 [&::-moz-range-progress]:rounded-full [&::-moz-range-progress]:bg-[var(--brand)]\",\n \"[&::-moz-range-thumb]:size-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0\",\n \"[&::-moz-range-thumb]:bg-[var(--brand)] [&::-moz-range-thumb]:shadow\",\n \"focus-visible:[&::-moz-range-thumb]:ring-2 focus-visible:[&::-moz-range-thumb]:ring-[var(--brand)]\",\n \"focus-visible:[&::-moz-range-thumb]:ring-offset-2 focus-visible:[&::-moz-range-thumb]:ring-offset-[var(--bg-surface)]\",\n].join(\" \");\n\n/** A tick under the track. A bare number is a tick with no words. */\nexport interface SliderMark {\n value: number;\n /** Shown under the tick — \"30 km/h\", \"measured\". Visual only: the value itself is\n * announced through `aria-valuetext`, so the marks row is hidden from assistive\n * technology rather than read out as a list of numbers after the slider. */\n label?: ReactNode;\n}\n\nexport interface SliderProps\n extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n \"type\" | \"value\" | \"defaultValue\" | \"onChange\" | \"min\" | \"max\" | \"step\" | \"children\"\n > {\n /** The value. On a log scale this is the real value, not the track position. */\n value: number;\n /** The new value — a number, not the DOM event, like `ToggleGroup`. Fired on every\n * movement; debounce at the call site if each one costs a request. */\n onChange: (value: number) => void;\n /** The track's ends. Not a validity range: a `value` outside it is kept and the\n * thumb pins at the end (see the module note). On a log scale `min` must be\n * above zero — zero is what {@link zeroStop} is for. */\n min: number;\n max: number;\n /** Step on a linear scale (the native default is 1). Ignored on a log scale, which\n * steps by track position — a fixed step is wrong at one end of every decade. */\n step?: number;\n /**\n * How the track maps to the value. `\"log\"` for quantities that run over decades — a\n * proportional gain of 0.5 and one of 200 are both ordinary, and on a linear track\n * everything under a tenth of the range is the first pixel. Falls back to linear if\n * `min` is not above zero or `max` not above `min`, where a logarithm has no answer.\n */\n scale?: \"linear\" | \"log\";\n /**\n * Log scale only: the far-left stop means exactly 0 (\"off\"), and the first step to\n * its right is `min`. A logarithm cannot hold zero, and zero is often the question —\n * should there be an integral term at all? Default `true`; turn it off for a scale\n * where zero is meaningless (a zoom factor, a playback rate).\n */\n zeroStop?: boolean;\n /**\n * What a screen reader says for the value — \"12.5 mm\", \"Off\". Sets\n * `aria-valuetext`. Without it a log track would announce its 0–1 POSITION (\"0.63\"\n * for a gain of 12.5), so on a log scale the raw value is announced instead; pass\n * this for anything with a unit or a locale.\n */\n formatValue?: (value: number) => string;\n /** The words above the track, as a `<label for>`. Without it, pass `aria-label`. */\n label?: ReactNode;\n /** Something that belongs to the label rather than the value — in practice a\n * `FieldHint` \"?\". Rendered beside the label, outside the `<label>` element, so it\n * never becomes part of the slider's accessible name. */\n hint?: ReactNode;\n /** The value as the reader sees it, at the end of the label line — a formatted\n * number, or a `NumberInput` for typing one. Rendered as given. */\n readout?: ReactNode;\n /** Ticks under the track, at these values. Marks outside `min`–`max` are dropped. */\n marks?: ReadonlyArray<number | SliderMark>;\n /** Classes for the `<input>`. `className` styles the outer wrapper. */\n inputClassName?: string;\n}\n\n/**\n * A native range input with the kit's track and thumb, an optional label line\n * (`label`, `hint`, `readout`), tick `marks`, and a logarithmic `scale`.\n *\n * Every other prop reaches the `<input>` — `name`, `id`, `aria-*`, `data-*`, `onBlur`,\n * `onPointerUp` for commit-on-release — and `disabled` also fades the label line.\n */\nexport const Slider = forwardRef<HTMLInputElement, SliderProps>(function Slider(\n {\n value,\n onChange,\n min,\n max,\n step,\n scale = \"linear\",\n zeroStop = true,\n formatValue,\n label,\n hint,\n readout,\n marks,\n className,\n inputClassName,\n id,\n disabled,\n style,\n ...rest\n },\n ref,\n) {\n const generated = useId();\n const inputId = id ?? generated;\n const log = scale === \"log\" && min > 0 && max > min;\n\n // Everything the native element sees is a POSITION; everything the caller sees is a\n // value. On a linear track the two are the same number.\n const trackMin = log ? 0 : min;\n const trackMax = log ? 1 : max;\n const position = (v: number) => (log ? toLogPosition(v, min, max, zeroStop) : Math.min(max, Math.max(min, v)));\n const current = position(value);\n // 0–1 share of the track, for the fill and the marks. A zero-width range (min ===\n // max) has no share to speak of; call it empty rather than divide by zero.\n const share = (p: number) => (trackMax > trackMin ? (p - trackMin) / (trackMax - trackMin) : 0);\n const outOfRange = value < min || value > max;\n\n // `aria-valuetext` replaces the announced NUMBER and leaves the announced name\n // alone. The caller's words first (`formatValue`, then a hand-written\n // `aria-valuetext`); failing those, the real value wherever the\n // native one would lie — every log position, and a linear value the thumb is only\n // pinned at. `toPrecision(4)` keeps a log value from being read out to sixteen\n // digits; it is not formatting, and `formatValue` is how to get a locale.\n const valueText = formatValue\n ? formatValue(value)\n : (rest[\"aria-valuetext\"] ??\n (log || outOfRange ? String(Number(value.toPrecision(4))) : undefined));\n\n const handleChange = (e: ChangeEvent<HTMLInputElement>) => {\n const raw = Number(e.target.value);\n if (!log) return onChange(raw);\n // The gap between the zero stop and `min` has to be crossable by keyboard. An\n // arrow key moves one LOG_STEP, which from zero lands inside the gap — and a gap\n // that rounded to the nearer end would send it straight back to zero, trapping\n // a keyboard user at \"off\". So inside the gap, moving up from zero means `min`\n // and anything else means zero.\n if (zeroStop && raw > 0 && raw < ZERO_STOP) return onChange(value <= 0 ? min : 0);\n onChange(fromLogPosition(raw, min, max, zeroStop));\n };\n\n const normalizedMarks = (marks ?? [])\n .map((m) => (typeof m === \"number\" ? { value: m } : m))\n .filter((m) => m.value >= min && m.value <= max);\n const hasMarkLabels = normalizedMarks.some((m) => m.label !== undefined);\n\n const hasHeader = label !== undefined || hint !== undefined || readout !== undefined;\n const plainReadout = typeof readout === \"string\" || typeof readout === \"number\";\n\n return (\n <div className={cn(\"w-full\", disabled && \"opacity-60\", className)}>\n {hasHeader && (\n // `select-none` on the words is not a nicety (Lenkbank feedback #93): a\n // mousedown on text beside a range input starts Chrome's native text drag, the\n // cursor turns to no-drop and the thumb stops following the pointer for the\n // rest of the gesture. The readout is only made unselectable when it is plain\n // text — a NumberInput in that slot has to stay selectable to be editable.\n // `flex-wrap`: a readout wider than the room beside the label (a value plus a\n // link button, \"0 / 60 / 120 km/h · Alle Geschwindigkeiten\") used to print on\n // top of it at 390px (lenkbank L1). Each keeps its own width, so the readout\n // drops to a line of its own, still at the end, only when the two don't fit.\n <div className=\"flex flex-wrap items-center gap-x-2 gap-y-0.5\">\n {label !== undefined && (\n <label\n htmlFor={inputId}\n className=\"min-w-0 select-none text-xs font-medium text-[var(--text-secondary)]\"\n >\n {label}\n </label>\n )}\n {hint !== undefined && <span className=\"flex shrink-0 items-center\">{hint}</span>}\n {readout !== undefined && (\n <span\n className={cn(\n \"ms-auto max-w-full text-xs tabular-nums text-[var(--text-primary)]\",\n plainReadout && \"select-none\",\n )}\n >\n {readout}\n </span>\n )}\n </div>\n )}\n <input\n ref={ref}\n id={label !== undefined ? inputId : id}\n disabled={disabled}\n {...rest}\n type=\"range\"\n min={trackMin}\n max={trackMax}\n step={log ? LOG_STEP : step}\n value={current}\n aria-valuetext={valueText}\n onChange={handleChange}\n // The fill's break point, merged under the caller's own style.\n style={{ ...style, \"--slider-fill\": `${share(current) * 100}%` } as CSSProperties}\n className={cn(TRACK, inputClassName)}\n />\n {normalizedMarks.length > 0 && (\n // `mx-2` insets the row by half a thumb on each side, which is exactly the\n // range the thumb's CENTRE travels — so a tick at 0% sits under the thumb at\n // `min`, not under the track's rounded end. Each tick is a zero-width column\n // centred on its point, which centres its label on it in either direction\n // without a `translate` that would need flipping for right-to-left.\n <div\n aria-hidden\n className={cn(\"relative mx-2 -mt-1.5\", hasMarkLabels ? \"h-5\" : \"h-1.5\")}\n >\n {normalizedMarks.map((m) => (\n <span\n key={m.value}\n className=\"absolute top-0 flex w-0 flex-col items-center\"\n style={{ insetInlineStart: `${share(position(m.value)) * 100}%` }}\n >\n <span className=\"h-1.5 w-px shrink-0 bg-[var(--border-strong)]\" />\n {m.label !== undefined && (\n <span className=\"mt-0.5 select-none whitespace-nowrap text-[11px] leading-tight text-[var(--text-muted)]\">\n {m.label}\n </span>\n )}\n </span>\n ))}\n </div>\n )}\n </div>\n );\n});\nSlider.displayName = \"Slider\";\n"],"mappings":";AAyPQ,SAEI,KAFJ;AAzPR,SAAS,YAAY,aAAa;AAElC,SAAS,UAAU;AA4BnB,MAAM,YAAY;AAIlB,MAAM,WAAW;AASV,SAAS,cAAc,OAAe,KAAa,KAAa,WAAW,MAAc;AAC9F,MAAI,SAAS,EAAG,QAAO;AACvB,QAAM,QAAQ,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,IAAI,GAAG,IAAI,KAAK,IAAI,MAAM,GAAG;AACvE,QAAM,UAAU,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC;AAC9C,SAAO,WAAW,aAAa,IAAI,aAAa,UAAU;AAC5D;AAGO,SAAS,gBAAgB,UAAkB,KAAa,KAAa,WAAW,MAAc;AACnG,MAAI,UAAU;AACZ,QAAI,WAAW,UAAW,QAAO;AACjC,WAAO,MAAM,KAAK,IAAI,MAAM,MAAM,WAAW,cAAc,IAAI,UAAU;AAAA,EAC3E;AACA,SAAO,MAAM,KAAK,IAAI,MAAM,KAAK,QAAQ;AAC3C;AAsBA,MAAM,QAAQ;AAAA,EACZ;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;A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AC;AAAA;AAAA,YAEC,WAAU;AAAA,YACV,OAAO,EAAE,kBAAkB,GAAG,MAAM,SAAS,EAAE,KAAK,CAAC,IAAI,GAAG,IAAI;AAAA,YAEhE;AAAA,kCAAC,UAAK,WAAU,iDAAgD;AAAA,cAC/D,EAAE,UAAU,UACX,oBAAC,UAAK,WAAU,2FACb,YAAE,OACL;AAAA;AAAA;AAAA,UARG,EAAE;AAAA,QAUT,CACD;AAAA;AAAA,IACH;AAAA,KAEJ;AAEJ,CAAC;AACD,OAAO,cAAc;","names":["Slider"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/slider.tsx"],"sourcesContent":["import { forwardRef, useId } from \"react\";\nimport type { CSSProperties, ChangeEvent, InputHTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\n\n/**\n * A range control on a native `<input type=\"range\">`.\n *\n * Lenkbank wrote the first one (`shared/ui/slider-field.tsx`) and then the case for\n * moving it here (`docs/ui-kit-slider-proposal.md`). This is that proposal's \"stage 1\"\n * primitive — the track, the thumb, the scale and the accessibility — plus the label\n * line and tick marks its SpeedSlider needed. The four decisions it argues should be\n * made once are made here, and each carries its note below:\n *\n * 1. a logarithmic scale whose far-left stop means exactly zero ({@link SliderProps.zeroStop});\n * 2. `aria-valuetext`, so a log track does not announce its 0–1 position as the value;\n * 3. a 24px pointer target, which needs the track and thumb drawn separately;\n * 4. the number is the truth and the track a view of it: a value outside `min`–`max`\n * is kept and the thumb pins at the end — nothing here clamps what it was given.\n *\n * Controlled only, like `ToggleGroup` and `NumberInput`: there is no uncontrolled mode\n * to get wrong, and neither app wants one. The package does no number formatting and\n * holds no locale — `formatValue` is how the caller's `Intl` result gets in.\n *\n * Not here, deliberately (the proposal's list): two thumbs, vertical orientation, and\n * a number box. A `NumberInput` goes in the `readout` slot when a typed value is\n * wanted beside the track.\n */\n\n/** On a log scale with {@link SliderProps.zeroStop}, the share of the track that is\n * the \"off\" stop. The first position to its right is `min`. */\nconst ZERO_STOP = 0.02;\n\n/** Position resolution on a log track — 1000 stops, fine enough that a drag reads as\n * continuous. PageUp/PageDown still cross a tenth of the track at a time. */\nconst LOG_STEP = 0.001;\n\n/**\n * Where a value sits on a logarithmic track, 0–1.\n *\n * With `zeroStop`, zero and below is 0 and the decades between `min` and `max` are\n * mapped onto the rest; without it, `min` is the far left. A value past either end\n * pins there — that is the DISPLAY clamping, never the value's.\n */\nexport function toLogPosition(value: number, min: number, max: number, zeroStop = true): number {\n if (value <= 0) return 0;\n const share = Math.log(Math.max(value, min) / min) / Math.log(max / min);\n const clamped = Math.min(1, Math.max(0, share));\n return zeroStop ? ZERO_STOP + (1 - ZERO_STOP) * clamped : clamped;\n}\n\n/** The inverse of {@link toLogPosition}: the value at a track position. */\nexport function fromLogPosition(position: number, min: number, max: number, zeroStop = true): number {\n if (zeroStop) {\n if (position < ZERO_STOP) return 0;\n return min * Math.pow(max / min, (position - ZERO_STOP) / (1 - ZERO_STOP));\n }\n return min * Math.pow(max / min, position);\n}\n\n// The input is the pointer target, so its box is `h-6` (24px, WCAG 2.5.8) and the\n// track that LOOKS like a track is a 6px strip drawn inside it. Once the box is taller\n// than the track its background cannot be the track, and with `appearance-none`\n// nothing else draws one — measured in Chromium by Lenkbank, that is a bare thumb\n// floating on nothing, in the browser's blue. Hence the vendor pseudo-elements: the\n// two engines share no selector for either half, so each half is spelt twice.\n//\n// The fill up to the thumb: WebKit has no progress pseudo-element, so its track is a\n// two-stop gradient that breaks at `--slider-fill` (set inline from the position), and\n// the gradient runs the other way in a right-to-left document, where the native range\n// runs the other way too. Firefox draws the fill itself with `::-moz-range-progress`,\n// which follows the direction on its own.\n//\n// The thumb's `-mt-[0.3125rem]` centres a 1rem thumb on a 0.375rem track — half the\n// difference — in rem since 0.32 (§3.2): the thumb and track grow with the text, and the\n// 5px it was left the thumb low of the track at 125 % and further at 150 %. WebKit lays\n// the thumb out from the track's top edge, Firefox centres it, so only one carries the\n// offset.\n//\n// The focus ring goes on the THUMB, not the box: the box is the full width of the\n// row, and a ring round all of it says \"this row is focused\" rather than \"the handle\n// you are about to move is\". Offset in the surface colour, because the thumb is\n// --brand and a --brand ring touching it would be invisible. Its width is the kit's\n// focus frame (`--focus-ring-width`, §5) — spelt out per engine, since `FOCUS_RING`'s\n// classes cannot carry the pseudo-element.\n//\n// At Large the box is the 48 px touch target (§4) — the track stays centred in it, and\n// the marks row below is pulled up by as much (see `MARKS_LARGE`).\nconst TRACK = [\n \"block h-6 large:h-[48px] w-full cursor-pointer appearance-none bg-transparent focus:outline-none disabled:cursor-not-allowed\",\n // WebKit / Blink\n \"[&::-webkit-slider-runnable-track]:h-1.5 [&::-webkit-slider-runnable-track]:rounded-full\",\n \"[&::-webkit-slider-runnable-track]:bg-[linear-gradient(to_right,var(--brand)_var(--slider-fill),var(--border-strong)_var(--slider-fill))]\",\n \"rtl:[&::-webkit-slider-runnable-track]:bg-[linear-gradient(to_left,var(--brand)_var(--slider-fill),var(--border-strong)_var(--slider-fill))]\",\n \"[&::-webkit-slider-thumb]:-mt-[0.3125rem] [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none\",\n \"[&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[var(--brand)] [&::-webkit-slider-thumb]:shadow\",\n \"focus-visible:[&::-webkit-slider-thumb]:ring-[length:var(--focus-ring-width)] focus-visible:[&::-webkit-slider-thumb]:ring-[var(--brand)]\",\n \"focus-visible:[&::-webkit-slider-thumb]:ring-offset-2 focus-visible:[&::-webkit-slider-thumb]:ring-offset-[var(--bg-surface)]\",\n // Firefox\n \"[&::-moz-range-track]:h-1.5 [&::-moz-range-track]:rounded-full [&::-moz-range-track]:bg-[var(--border-strong)]\",\n \"[&::-moz-range-progress]:h-1.5 [&::-moz-range-progress]:rounded-full [&::-moz-range-progress]:bg-[var(--brand)]\",\n \"[&::-moz-range-thumb]:size-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0\",\n \"[&::-moz-range-thumb]:bg-[var(--brand)] [&::-moz-range-thumb]:shadow\",\n \"focus-visible:[&::-moz-range-thumb]:ring-[length:var(--focus-ring-width)] focus-visible:[&::-moz-range-thumb]:ring-[var(--brand)]\",\n \"focus-visible:[&::-moz-range-thumb]:ring-offset-2 focus-visible:[&::-moz-range-thumb]:ring-offset-[var(--bg-surface)]\",\n].join(\" \");\n\n// The marks row sits `-mt-1.5` under a 1.5rem box, tucked against the track. In the 48 px\n// box at Large the track's lower edge is `(48px + 0.375rem) / 2` down, so the row comes\n// up by `(48px − 0.375rem) / 2` less the same 0.1875rem gap: `24px − 0.375rem`.\nconst MARKS_LARGE = \"large:-mt-[calc(24px-0.375rem)]\";\n\n/** A tick under the track. A bare number is a tick with no words. */\nexport interface SliderMark {\n value: number;\n /** Shown under the tick — \"30 km/h\", \"measured\". Visual only: the value itself is\n * announced through `aria-valuetext`, so the marks row is hidden from assistive\n * technology rather than read out as a list of numbers after the slider. */\n label?: ReactNode;\n}\n\nexport interface SliderProps\n extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n \"type\" | \"value\" | \"defaultValue\" | \"onChange\" | \"min\" | \"max\" | \"step\" | \"children\"\n > {\n /** The value. On a log scale this is the real value, not the track position. */\n value: number;\n /** The new value — a number, not the DOM event, like `ToggleGroup`. Fired on every\n * movement; debounce at the call site if each one costs a request. */\n onChange: (value: number) => void;\n /** The track's ends. Not a validity range: a `value` outside it is kept and the\n * thumb pins at the end (see the module note). On a log scale `min` must be\n * above zero — zero is what {@link zeroStop} is for. */\n min: number;\n max: number;\n /** Step on a linear scale (the native default is 1). Ignored on a log scale, which\n * steps by track position — a fixed step is wrong at one end of every decade. */\n step?: number;\n /**\n * How the track maps to the value. `\"log\"` for quantities that run over decades — a\n * proportional gain of 0.5 and one of 200 are both ordinary, and on a linear track\n * everything under a tenth of the range is the first pixel. Falls back to linear if\n * `min` is not above zero or `max` not above `min`, where a logarithm has no answer.\n */\n scale?: \"linear\" | \"log\";\n /**\n * Log scale only: the far-left stop means exactly 0 (\"off\"), and the first step to\n * its right is `min`. A logarithm cannot hold zero, and zero is often the question —\n * should there be an integral term at all? Default `true`; turn it off for a scale\n * where zero is meaningless (a zoom factor, a playback rate).\n */\n zeroStop?: boolean;\n /**\n * What a screen reader says for the value — \"12.5 mm\", \"Off\". Sets\n * `aria-valuetext`. Without it a log track would announce its 0–1 POSITION (\"0.63\"\n * for a gain of 12.5), so on a log scale the raw value is announced instead; pass\n * this for anything with a unit or a locale.\n */\n formatValue?: (value: number) => string;\n /** The words above the track, as a `<label for>`. Without it, pass `aria-label`. */\n label?: ReactNode;\n /** Something that belongs to the label rather than the value — in practice a\n * `FieldHint` \"?\". Rendered beside the label, outside the `<label>` element, so it\n * never becomes part of the slider's accessible name. */\n hint?: ReactNode;\n /** The value as the reader sees it, at the end of the label line — a formatted\n * number, or a `NumberInput` for typing one. Rendered as given. */\n readout?: ReactNode;\n /** Ticks under the track, at these values. Marks outside `min`–`max` are dropped. */\n marks?: ReadonlyArray<number | SliderMark>;\n /** Classes for the `<input>`. `className` styles the outer wrapper. */\n inputClassName?: string;\n}\n\n/**\n * A native range input with the kit's track and thumb, an optional label line\n * (`label`, `hint`, `readout`), tick `marks`, and a logarithmic `scale`.\n *\n * Every other prop reaches the `<input>` — `name`, `id`, `aria-*`, `data-*`, `onBlur`,\n * `onPointerUp` for commit-on-release — and `disabled` also fades the label line.\n */\nexport const Slider = forwardRef<HTMLInputElement, SliderProps>(function Slider(\n {\n value,\n onChange,\n min,\n max,\n step,\n scale = \"linear\",\n zeroStop = true,\n formatValue,\n label,\n hint,\n readout,\n marks,\n className,\n inputClassName,\n id,\n disabled,\n style,\n ...rest\n },\n ref,\n) {\n const generated = useId();\n const inputId = id ?? generated;\n const log = scale === \"log\" && min > 0 && max > min;\n\n // Everything the native element sees is a POSITION; everything the caller sees is a\n // value. On a linear track the two are the same number.\n const trackMin = log ? 0 : min;\n const trackMax = log ? 1 : max;\n const position = (v: number) => (log ? toLogPosition(v, min, max, zeroStop) : Math.min(max, Math.max(min, v)));\n const current = position(value);\n // 0–1 share of the track, for the fill and the marks. A zero-width range (min ===\n // max) has no share to speak of; call it empty rather than divide by zero.\n const share = (p: number) => (trackMax > trackMin ? (p - trackMin) / (trackMax - trackMin) : 0);\n const outOfRange = value < min || value > max;\n\n // `aria-valuetext` replaces the announced NUMBER and leaves the announced name\n // alone. The caller's words first (`formatValue`, then a hand-written\n // `aria-valuetext`); failing those, the real value wherever the\n // native one would lie — every log position, and a linear value the thumb is only\n // pinned at. `toPrecision(4)` keeps a log value from being read out to sixteen\n // digits; it is not formatting, and `formatValue` is how to get a locale.\n const valueText = formatValue\n ? formatValue(value)\n : (rest[\"aria-valuetext\"] ??\n (log || outOfRange ? String(Number(value.toPrecision(4))) : undefined));\n\n const handleChange = (e: ChangeEvent<HTMLInputElement>) => {\n const raw = Number(e.target.value);\n if (!log) return onChange(raw);\n // The gap between the zero stop and `min` has to be crossable by keyboard. An\n // arrow key moves one LOG_STEP, which from zero lands inside the gap — and a gap\n // that rounded to the nearer end would send it straight back to zero, trapping\n // a keyboard user at \"off\". So inside the gap, moving up from zero means `min`\n // and anything else means zero.\n if (zeroStop && raw > 0 && raw < ZERO_STOP) return onChange(value <= 0 ? min : 0);\n onChange(fromLogPosition(raw, min, max, zeroStop));\n };\n\n const normalizedMarks = (marks ?? [])\n .map((m) => (typeof m === \"number\" ? { value: m } : m))\n .filter((m) => m.value >= min && m.value <= max);\n const hasMarkLabels = normalizedMarks.some((m) => m.label !== undefined);\n\n const hasHeader = label !== undefined || hint !== undefined || readout !== undefined;\n const plainReadout = typeof readout === \"string\" || typeof readout === \"number\";\n\n return (\n <div className={cn(\"w-full\", disabled && \"opacity-60\", className)}>\n {hasHeader && (\n // `select-none` on the words is not a nicety (Lenkbank feedback #93): a\n // mousedown on text beside a range input starts Chrome's native text drag, the\n // cursor turns to no-drop and the thumb stops following the pointer for the\n // rest of the gesture. The readout is only made unselectable when it is plain\n // text — a NumberInput in that slot has to stay selectable to be editable.\n // `flex-wrap`: a readout wider than the room beside the label (a value plus a\n // link button, \"0 / 60 / 120 km/h · Alle Geschwindigkeiten\") used to print on\n // top of it at 390px (lenkbank L1). Each keeps its own width, so the readout\n // drops to a line of its own, still at the end, only when the two don't fit.\n <div className=\"flex flex-wrap items-center gap-x-2 gap-y-0.5\">\n {label !== undefined && (\n <label\n htmlFor={inputId}\n className=\"min-w-0 select-none text-xs font-medium text-[var(--text-secondary)]\"\n >\n {label}\n </label>\n )}\n {hint !== undefined && <span className=\"flex shrink-0 items-center\">{hint}</span>}\n {readout !== undefined && (\n <span\n className={cn(\n \"ms-auto max-w-full text-xs tabular-nums text-[var(--text-primary)]\",\n plainReadout && \"select-none\",\n )}\n >\n {readout}\n </span>\n )}\n </div>\n )}\n <input\n ref={ref}\n id={label !== undefined ? inputId : id}\n disabled={disabled}\n {...rest}\n type=\"range\"\n min={trackMin}\n max={trackMax}\n step={log ? LOG_STEP : step}\n value={current}\n aria-valuetext={valueText}\n onChange={handleChange}\n // The fill's break point, merged under the caller's own style.\n style={{ ...style, \"--slider-fill\": `${share(current) * 100}%` } as CSSProperties}\n className={cn(TRACK, inputClassName)}\n />\n {normalizedMarks.length > 0 && (\n // `mx-2` insets the row by half a thumb on each side, which is exactly the\n // range the thumb's CENTRE travels — so a tick at 0% sits under the thumb at\n // `min`, not under the track's rounded end. Each tick is a zero-width column\n // centred on its point, which centres its label on it in either direction\n // without a `translate` that would need flipping for right-to-left.\n <div\n aria-hidden\n className={cn(\"relative mx-2 -mt-1.5\", MARKS_LARGE, hasMarkLabels ? \"h-5\" : \"h-1.5\")}\n >\n {normalizedMarks.map((m) => (\n <span\n key={m.value}\n className=\"absolute top-0 flex w-0 flex-col items-center\"\n style={{ insetInlineStart: `${share(position(m.value)) * 100}%` }}\n >\n <span className=\"h-1.5 w-px shrink-0 bg-[var(--border-strong)]\" />\n {m.label !== undefined && (\n <span className=\"mt-0.5 select-none whitespace-nowrap text-caption leading-tight text-[var(--text-muted)]\">\n {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;AACD,OAAO,cAAc;","names":["Slider"]}
|
|
@@ -38,8 +38,12 @@ interface SparklineProps extends Omit<ComponentPropsWithoutRef<"svg">, "children
|
|
|
38
38
|
/** The series, oldest first. `null`/`undefined`/`NaN` is a GAP — the line breaks
|
|
39
39
|
* there rather than drawing a zero or bridging across the missing point. */
|
|
40
40
|
data: ReadonlyArray<number | null | undefined>;
|
|
41
|
-
/** Width in px. Ignored under `fluid`.
|
|
41
|
+
/** Width in px at Normal. Ignored under `fluid`. The drawn box is this × the text
|
|
42
|
+
* size's scale (0.32, docs/text-size-harmonization.md §3.2): a sparkline stands beside
|
|
43
|
+
* a figure, and a 72 × 24 trend under a 150 % number reads as a speck. The strokes
|
|
44
|
+
* stay px (`non-scaling-stroke`), as every chart's do. */
|
|
42
45
|
width?: number;
|
|
46
|
+
/** Height in px at Normal, × the scale likewise. */
|
|
43
47
|
height?: number;
|
|
44
48
|
/** Fill the container's width instead of a fixed one (the height stays fixed). */
|
|
45
49
|
fluid?: boolean;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { cn } from "../lib/cn.js";
|
|
4
4
|
import { useKitLabels, useKitLocale } from "../i18n/kit-labels.js";
|
|
5
|
+
import { useTextSize } from "../theme/text-size.js";
|
|
5
6
|
const DEFAULT_SPARKLINE_LABELS = {
|
|
6
7
|
rising: (first, last) => `Rising from ${first} to ${last}`,
|
|
7
8
|
falling: (first, last) => `Falling from ${first} to ${last}`,
|
|
@@ -67,6 +68,7 @@ function Sparkline({
|
|
|
67
68
|
...rest
|
|
68
69
|
}) {
|
|
69
70
|
const text = useKitLabels("sparkline", DEFAULT_SPARKLINE_LABELS, labels);
|
|
71
|
+
const { scale } = useTextSize();
|
|
70
72
|
const kitLocale = useKitLocale(locale);
|
|
71
73
|
const format = formatValue ?? defaultFormat(kitLocale);
|
|
72
74
|
const summary = sparklineSummary(data, text, format);
|
|
@@ -122,8 +124,8 @@ function Sparkline({
|
|
|
122
124
|
role: "img",
|
|
123
125
|
"aria-label": name,
|
|
124
126
|
...rest,
|
|
125
|
-
width: fluid ? "100%" : W,
|
|
126
|
-
height: H,
|
|
127
|
+
width: fluid ? "100%" : W * scale,
|
|
128
|
+
height: H * scale,
|
|
127
129
|
viewBox: `0 0 ${W} ${H}`,
|
|
128
130
|
preserveAspectRatio: "none",
|
|
129
131
|
className: cn(fluid ? "block w-full" : "inline-block shrink-0 align-middle", "overflow-visible", className),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/sparkline.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels, useKitLocale } from \"../i18n/kit-labels\";\n\n/**\n * The words a sparkline speaks. It has no axes, no tooltip and no legend, so its\n * accessible name is the ONLY way a screen reader learns what the shape says —\n * \"Sparkline, image\" is not a summary. Each message takes the values already\n * formatted, so the digits follow the locale and the sentence stays translatable.\n */\nexport interface SparklineLabels {\n /** Last value above the first: \"Rising from 12 to 40\". */\n rising: (first: string, last: string) => string;\n /** Last value below the first. */\n falling: (first: string, last: string) => string;\n /** First and last are equal — the shape may still have moved in between. */\n flat: (value: string) => string;\n /** One value is a dot, not a trend. */\n single: (value: string) => string;\n /** No value at all (empty, or every point a gap). */\n noData: string;\n /** How the series' own name is joined to the summary when `label` is given. */\n named: (name: string, summary: string) => string;\n}\n\nexport const DEFAULT_SPARKLINE_LABELS: SparklineLabels = {\n rising: (first, last) => `Rising from ${first} to ${last}`,\n falling: (first, last) => `Falling from ${first} to ${last}`,\n flat: (value) => `Unchanged at ${value}`,\n single: (value) => `One value: ${value}`,\n noData: \"No data\",\n named: (name, summary) => `${name}: ${summary}`,\n};\n\n/**\n * What colours the marks. Token names, not colours: every one resolves to a variable\n * in tokens.css, so the sparkline re-skins with the palette like everything else.\n *\n * - `chart` — the first series colour (`--chart-1`), the default.\n * - `income` / `expense` / `net` — the money trio.\n * - `signed` — a money series read by sign: bars each take income or expense by their\n * own value, a line or area takes the colour of its LAST value (where it ended up).\n */\nexport type SparklineTone =\n | \"chart\"\n | \"brand\"\n | \"muted\"\n | \"income\"\n | \"expense\"\n | \"net\"\n | \"signed\"\n | \"success\"\n | \"warning\"\n | \"danger\"\n | \"info\";\n\n// `color`, not `stroke`/`fill`: every mark paints with `currentColor`, so one class\n// per element is enough and a signed bar chart needs no second lookup table.\nconst TONE_CLASS: Record<Exclude<SparklineTone, \"signed\">, string> = {\n chart: \"text-[var(--chart-1)]\",\n brand: \"text-[var(--brand)]\",\n muted: \"text-[var(--text-muted)]\",\n income: \"text-[var(--money-income)]\",\n expense: \"text-[var(--money-expense)]\",\n net: \"text-[var(--money-net)]\",\n success: \"text-[var(--success)]\",\n warning: \"text-[var(--warning)]\",\n danger: \"text-[var(--danger)]\",\n info: \"text-[var(--info)]\",\n};\n\nconst signedClass = (v: number) => (v < 0 ? TONE_CLASS.expense : TONE_CLASS.income);\n\n/** `children` is the marks and `width`/`height` are numbers here (or `fluid`), so\n * those three are the sparkline's own; everything else lands on the `<svg>`. */\nexport interface SparklineProps\n extends Omit<ComponentPropsWithoutRef<\"svg\">, \"children\" | \"width\" | \"height\"> {\n /** The series, oldest first. `null`/`undefined`/`NaN` is a GAP — the line breaks\n * there rather than drawing a zero or bridging across the missing point. */\n data: ReadonlyArray<number | null | undefined>;\n /** Width in px. Ignored under `fluid`. */\n width?: number;\n height?: number;\n /** Fill the container's width instead of a fixed one (the height stays fixed). */\n fluid?: boolean;\n variant?: \"line\" | \"area\" | \"bar\";\n tone?: SparklineTone;\n /** Lower / upper end of the scale. Unset, the scale is the data's own tight range\n * (bars always include zero, since a bar's length IS its value). */\n min?: number;\n max?: number;\n /** A dashed hairline at this value, e.g. `0` for a series that crosses zero, or a\n * target. It is pulled into the scale unless `min`/`max` exclude it. */\n referenceValue?: number;\n /** Dot on the last point (line/area) or dim every bar but the last. Default true —\n * the last value is the one the number beside a sparkline almost always is. */\n highlightLast?: boolean;\n strokeWidth?: number;\n /** What the series is (\"Price\"), prefixed to the spoken summary. */\n label?: string;\n /** How a value is spoken in the summary. Defaults to `Intl.NumberFormat` in the\n * kit's locale, at most two decimals. */\n formatValue?: (value: number) => string;\n locale?: string;\n labels?: Partial<SparklineLabels>;\n}\n\nconst DEFAULT_WIDTH = 72;\nconst DEFAULT_HEIGHT = 24;\n\n// One formatter per locale, not per render: a sparkline is a table-cell component and\n// a hundred rows would otherwise build a hundred identical `Intl.NumberFormat`s.\nconst formatters = new Map<string, Intl.NumberFormat>();\nfunction defaultFormat(locale: string | undefined): (v: number) => string {\n const key = locale ?? \"\";\n let f = formatters.get(key);\n if (!f) {\n f = new Intl.NumberFormat(locale, { maximumFractionDigits: 2 });\n formatters.set(key, f);\n }\n return (v) => f.format(v);\n}\n\nconst isValue = (v: number | null | undefined): v is number => typeof v === \"number\" && Number.isFinite(v);\n\n/** The spoken summary, without the series name. Exported for callers that want the\n * same sentence elsewhere (a table's row description, a tooltip). */\nexport function sparklineSummary(\n data: ReadonlyArray<number | null | undefined>,\n labels: SparklineLabels,\n format: (value: number) => string,\n): string {\n const values = data.filter(isValue);\n if (values.length === 0) return labels.noData;\n const first = values[0];\n const last = values[values.length - 1];\n if (values.length === 1) return labels.single(format(last));\n if (last > first) return labels.rising(format(first), format(last));\n if (last < first) return labels.falling(format(first), format(last));\n return labels.flat(format(last));\n}\n\n/**\n * A tiny trend line: shape only — no axes, no tooltip, no legend, no chart library.\n *\n * It is plain SVG on purpose. The two copies it replaces were recharts `LineChart`s,\n * which is a ResizeObserver, a React tree of a dozen components and a 433 KB import\n * per table cell; a sparkline is one `<path>`, cheap enough for every row of a table\n * and small enough to live on the main barrel rather than behind `/chart`.\n *\n * The scale is TIGHT by default (the data's own min to max). A price that moved from\n * 9.75 to 12.40 drawn against an implicit zero baseline is a nearly flat line at the\n * top of the box — the one thing a shape-only chart must not do (keksdose dev#449).\n * Bars are the exception: a bar's length is its value, so their scale includes zero.\n *\n * `role=\"img\"` with a generated summary (\"Rising from 12 to 40\") as its name — the\n * numbers beside it are the values, the sparkline says which way they have moved.\n *\n * Under `fluid` the SVG is stretched non-uniformly to the container's width, so every\n * stroke is `non-scaling-stroke` and the last-point dot is a zero-length ROUND-CAPPED\n * stroke rather than a `<circle>`: a stroke keeps its width under that transform,\n * where a circle would be squashed into an ellipse.\n */\nexport function Sparkline({\n data,\n width = DEFAULT_WIDTH,\n height = DEFAULT_HEIGHT,\n fluid = false,\n variant = \"line\",\n tone = \"chart\",\n min,\n max,\n referenceValue,\n highlightLast = true,\n strokeWidth = 1.5,\n label,\n formatValue,\n locale,\n labels,\n className,\n style,\n ...rest\n}: SparklineProps) {\n const text = useKitLabels(\"sparkline\", DEFAULT_SPARKLINE_LABELS, labels);\n const kitLocale = useKitLocale(locale);\n const format = formatValue ?? defaultFormat(kitLocale);\n\n const summary = sparklineSummary(data, text, format);\n const name = label ? text.named(label, summary) : summary;\n\n const W = width;\n const H = height;\n const points = data.map((v) => (isValue(v) ? v : null));\n const values = points.filter(isValue);\n const n = points.length;\n\n // ── Scale ──\n const bounds = [...values];\n if (referenceValue !== undefined && isValue(referenceValue)) bounds.push(referenceValue);\n if (variant === \"bar\") bounds.push(0);\n let lo = min ?? (bounds.length ? Math.min(...bounds) : 0);\n let hi = max ?? (bounds.length ? Math.max(...bounds) : 1);\n if (hi === lo) {\n // A constant series: centre it rather than divide by zero.\n lo -= 1;\n hi += 1;\n }\n const dot = strokeWidth + 1.5;\n const pad = highlightLast && variant !== \"bar\" ? dot : strokeWidth / 2;\n const clamp = (v: number) => Math.min(hi, Math.max(lo, v));\n const y = (v: number) => pad + ((hi - clamp(v)) / (hi - lo)) * (H - 2 * pad);\n const x = (i: number) => (n <= 1 ? W / 2 : pad + (i * (W - 2 * pad)) / (n - 1));\n const r = (v: number) => Math.round(v * 100) / 100;\n\n // Last DEFINED point — the series may well end in a gap. (No `findLastIndex`: the\n // package targets ES2022.)\n let lastIndex = -1;\n for (let i = n - 1; i >= 0 && lastIndex < 0; i -= 1) if (points[i] !== null) lastIndex = i;\n const lastValue = lastIndex >= 0 ? (points[lastIndex] ?? 0) : 0;\n const lineClass = tone === \"signed\" ? signedClass(lastValue) : TONE_CLASS[tone];\n\n // Contiguous runs between gaps. A run of one point is drawn as a dot, so a value\n // isolated between two gaps is still visible.\n const runs: Array<Array<[number, number]>> = [];\n let run: Array<[number, number]> = [];\n points.forEach((v, i) => {\n if (v === null) {\n if (run.length) runs.push(run);\n run = [];\n } else {\n run.push([i, v]);\n }\n });\n if (run.length) runs.push(run);\n\n const linePath = (seg: Array<[number, number]>) =>\n seg.map(([i, v], k) => `${k === 0 ? \"M\" : \"L\"}${r(x(i))} ${r(y(v))}`).join(\" \");\n const dotPath = (i: number, v: number) => `M${r(x(i))} ${r(y(v))} h0`;\n // The area closes to zero when zero is on the scale, else to the bottom edge.\n const areaBase = y(lo <= 0 && hi >= 0 ? 0 : lo);\n\n const STROKE = {\n fill: \"none\",\n stroke: \"currentColor\",\n strokeLinecap: \"round\",\n strokeLinejoin: \"round\",\n vectorEffect: \"non-scaling-stroke\",\n } as const;\n\n return (\n <svg\n role=\"img\"\n aria-label={name}\n {...rest}\n width={fluid ? \"100%\" : W}\n height={H}\n viewBox={`0 0 ${W} ${H}`}\n preserveAspectRatio=\"none\"\n className={cn(fluid ? \"block w-full\" : \"inline-block shrink-0 align-middle\", \"overflow-visible\", className)}\n style={style}\n >\n {referenceValue !== undefined && isValue(referenceValue) && referenceValue >= lo && referenceValue <= hi && (\n <path\n d={`M0 ${r(y(referenceValue))} H${W}`}\n {...STROKE}\n strokeWidth={1}\n strokeDasharray=\"2 2\"\n className=\"text-[var(--border-strong)]\"\n />\n )}\n\n {variant === \"bar\"\n ? (() => {\n const slot = W / Math.max(n, 1);\n const bw = Math.max(1, slot * 0.7);\n const base = y(0);\n return points.map((v, i) => {\n if (v === null) return null;\n const top = Math.min(y(v), base);\n return (\n <rect\n key={i}\n x={r(i * slot + (slot - bw) / 2)}\n y={r(top)}\n width={r(bw)}\n height={r(Math.abs(y(v) - base))}\n fill=\"currentColor\"\n opacity={highlightLast && i !== lastIndex ? 0.55 : 1}\n className={tone === \"signed\" ? signedClass(v) : TONE_CLASS[tone]}\n />\n );\n });\n })()\n : runs.map((seg, k) =>\n seg.length === 1 ? (\n <path\n key={k}\n d={dotPath(seg[0][0], seg[0][1])}\n {...STROKE}\n strokeWidth={strokeWidth * 2}\n className={lineClass}\n />\n ) : (\n <g key={k} className={lineClass}>\n {variant === \"area\" && (\n <path\n d={`${linePath(seg)} L${r(x(seg[seg.length - 1][0]))} ${r(areaBase)} L${r(x(seg[0][0]))} ${r(areaBase)} Z`}\n fill=\"currentColor\"\n fillOpacity={0.15}\n stroke=\"none\"\n />\n )}\n <path d={linePath(seg)} {...STROKE} strokeWidth={strokeWidth} />\n </g>\n ),\n )}\n\n {highlightLast && variant !== \"bar\" && lastIndex >= 0 && (\n <path\n d={dotPath(lastIndex, lastValue)}\n {...STROKE}\n strokeWidth={dot * 2 - 1}\n className={lineClass}\n data-sparkline-last=\"\"\n />\n )}\n </svg>\n );\n}\n"],"mappings":";AAsQQ,cAyCM,YAzCN;AArQR,SAAS,UAAU;AACnB,SAAS,cAAc,oBAAoB;AAuBpC,MAAM,2BAA4C;AAAA,EACvD,QAAQ,CAAC,OAAO,SAAS,eAAe,KAAK,OAAO,IAAI;AAAA,EACxD,SAAS,CAAC,OAAO,SAAS,gBAAgB,KAAK,OAAO,IAAI;AAAA,EAC1D,MAAM,CAAC,UAAU,gBAAgB,KAAK;AAAA,EACtC,QAAQ,CAAC,UAAU,cAAc,KAAK;AAAA,EACtC,QAAQ;AAAA,EACR,OAAO,CAAC,MAAM,YAAY,GAAG,IAAI,KAAK,OAAO;AAC/C;AA0BA,MAAM,aAA+D;AAAA,EACnE,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,KAAK;AAAA,EACL,SAAS;AAAA,E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AAAA,cAAC;AAAA;AAAA,gBACC,GAAG,GAAG,SAAS,GAAG,CAAC,KAAK,EAAE,EAAE,IAAI,IAAI,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC;AAAA,gBACtG,MAAK;AAAA,gBACL,aAAa;AAAA,gBACb,QAAO;AAAA;AAAA,YACT;AAAA,YAEF,oBAAC,UAAK,GAAG,SAAS,GAAG,GAAI,GAAG,QAAQ,aAA0B;AAAA,eATxD,CAUR;AAAA,QAEJ;AAAA,QAEH,iBAAiB,YAAY,SAAS,aAAa,KAClD;AAAA,UAAC;AAAA;AAAA,YACC,GAAG,QAAQ,WAAW,SAAS;AAAA,YAC9B,GAAG;AAAA,YACJ,aAAa,MAAM,IAAI;AAAA,YACvB,WAAW;AAAA,YACX,uBAAoB;AAAA;AAAA,QACtB;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/sparkline.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels, useKitLocale } from \"../i18n/kit-labels\";\nimport { useTextSize } from \"../theme/text-size\";\n\n/**\n * The words a sparkline speaks. It has no axes, no tooltip and no legend, so its\n * accessible name is the ONLY way a screen reader learns what the shape says —\n * \"Sparkline, image\" is not a summary. Each message takes the values already\n * formatted, so the digits follow the locale and the sentence stays translatable.\n */\nexport interface SparklineLabels {\n /** Last value above the first: \"Rising from 12 to 40\". */\n rising: (first: string, last: string) => string;\n /** Last value below the first. */\n falling: (first: string, last: string) => string;\n /** First and last are equal — the shape may still have moved in between. */\n flat: (value: string) => string;\n /** One value is a dot, not a trend. */\n single: (value: string) => string;\n /** No value at all (empty, or every point a gap). */\n noData: string;\n /** How the series' own name is joined to the summary when `label` is given. */\n named: (name: string, summary: string) => string;\n}\n\nexport const DEFAULT_SPARKLINE_LABELS: SparklineLabels = {\n rising: (first, last) => `Rising from ${first} to ${last}`,\n falling: (first, last) => `Falling from ${first} to ${last}`,\n flat: (value) => `Unchanged at ${value}`,\n single: (value) => `One value: ${value}`,\n noData: \"No data\",\n named: (name, summary) => `${name}: ${summary}`,\n};\n\n/**\n * What colours the marks. Token names, not colours: every one resolves to a variable\n * in tokens.css, so the sparkline re-skins with the palette like everything else.\n *\n * - `chart` — the first series colour (`--chart-1`), the default.\n * - `income` / `expense` / `net` — the money trio.\n * - `signed` — a money series read by sign: bars each take income or expense by their\n * own value, a line or area takes the colour of its LAST value (where it ended up).\n */\nexport type SparklineTone =\n | \"chart\"\n | \"brand\"\n | \"muted\"\n | \"income\"\n | \"expense\"\n | \"net\"\n | \"signed\"\n | \"success\"\n | \"warning\"\n | \"danger\"\n | \"info\";\n\n// `color`, not `stroke`/`fill`: every mark paints with `currentColor`, so one class\n// per element is enough and a signed bar chart needs no second lookup table.\nconst TONE_CLASS: Record<Exclude<SparklineTone, \"signed\">, string> = {\n chart: \"text-[var(--chart-1)]\",\n brand: \"text-[var(--brand)]\",\n muted: \"text-[var(--text-muted)]\",\n income: \"text-[var(--money-income)]\",\n expense: \"text-[var(--money-expense)]\",\n net: \"text-[var(--money-net)]\",\n success: \"text-[var(--success)]\",\n warning: \"text-[var(--warning)]\",\n danger: \"text-[var(--danger)]\",\n info: \"text-[var(--info)]\",\n};\n\nconst signedClass = (v: number) => (v < 0 ? TONE_CLASS.expense : TONE_CLASS.income);\n\n/** `children` is the marks and `width`/`height` are numbers here (or `fluid`), so\n * those three are the sparkline's own; everything else lands on the `<svg>`. */\nexport interface SparklineProps\n extends Omit<ComponentPropsWithoutRef<\"svg\">, \"children\" | \"width\" | \"height\"> {\n /** The series, oldest first. `null`/`undefined`/`NaN` is a GAP — the line breaks\n * there rather than drawing a zero or bridging across the missing point. */\n data: ReadonlyArray<number | null | undefined>;\n /** Width in px at Normal. Ignored under `fluid`. The drawn box is this × the text\n * size's scale (0.32, docs/text-size-harmonization.md §3.2): a sparkline stands beside\n * a figure, and a 72 × 24 trend under a 150 % number reads as a speck. The strokes\n * stay px (`non-scaling-stroke`), as every chart's do. */\n width?: number;\n /** Height in px at Normal, × the scale likewise. */\n height?: number;\n /** Fill the container's width instead of a fixed one (the height stays fixed). */\n fluid?: boolean;\n variant?: \"line\" | \"area\" | \"bar\";\n tone?: SparklineTone;\n /** Lower / upper end of the scale. Unset, the scale is the data's own tight range\n * (bars always include zero, since a bar's length IS its value). */\n min?: number;\n max?: number;\n /** A dashed hairline at this value, e.g. `0` for a series that crosses zero, or a\n * target. It is pulled into the scale unless `min`/`max` exclude it. */\n referenceValue?: number;\n /** Dot on the last point (line/area) or dim every bar but the last. Default true —\n * the last value is the one the number beside a sparkline almost always is. */\n highlightLast?: boolean;\n strokeWidth?: number;\n /** What the series is (\"Price\"), prefixed to the spoken summary. */\n label?: string;\n /** How a value is spoken in the summary. Defaults to `Intl.NumberFormat` in the\n * kit's locale, at most two decimals. */\n formatValue?: (value: number) => string;\n locale?: string;\n labels?: Partial<SparklineLabels>;\n}\n\nconst DEFAULT_WIDTH = 72;\nconst DEFAULT_HEIGHT = 24;\n\n// One formatter per locale, not per render: a sparkline is a table-cell component and\n// a hundred rows would otherwise build a hundred identical `Intl.NumberFormat`s.\nconst formatters = new Map<string, Intl.NumberFormat>();\nfunction defaultFormat(locale: string | undefined): (v: number) => string {\n const key = locale ?? \"\";\n let f = formatters.get(key);\n if (!f) {\n f = new Intl.NumberFormat(locale, { maximumFractionDigits: 2 });\n formatters.set(key, f);\n }\n return (v) => f.format(v);\n}\n\nconst isValue = (v: number | null | undefined): v is number => typeof v === \"number\" && Number.isFinite(v);\n\n/** The spoken summary, without the series name. Exported for callers that want the\n * same sentence elsewhere (a table's row description, a tooltip). */\nexport function sparklineSummary(\n data: ReadonlyArray<number | null | undefined>,\n labels: SparklineLabels,\n format: (value: number) => string,\n): string {\n const values = data.filter(isValue);\n if (values.length === 0) return labels.noData;\n const first = values[0];\n const last = values[values.length - 1];\n if (values.length === 1) return labels.single(format(last));\n if (last > first) return labels.rising(format(first), format(last));\n if (last < first) return labels.falling(format(first), format(last));\n return labels.flat(format(last));\n}\n\n/**\n * A tiny trend line: shape only — no axes, no tooltip, no legend, no chart library.\n *\n * It is plain SVG on purpose. The two copies it replaces were recharts `LineChart`s,\n * which is a ResizeObserver, a React tree of a dozen components and a 433 KB import\n * per table cell; a sparkline is one `<path>`, cheap enough for every row of a table\n * and small enough to live on the main barrel rather than behind `/chart`.\n *\n * The scale is TIGHT by default (the data's own min to max). A price that moved from\n * 9.75 to 12.40 drawn against an implicit zero baseline is a nearly flat line at the\n * top of the box — the one thing a shape-only chart must not do (keksdose dev#449).\n * Bars are the exception: a bar's length is its value, so their scale includes zero.\n *\n * `role=\"img\"` with a generated summary (\"Rising from 12 to 40\") as its name — the\n * numbers beside it are the values, the sparkline says which way they have moved.\n *\n * Under `fluid` the SVG is stretched non-uniformly to the container's width, so every\n * stroke is `non-scaling-stroke` and the last-point dot is a zero-length ROUND-CAPPED\n * stroke rather than a `<circle>`: a stroke keeps its width under that transform,\n * where a circle would be squashed into an ellipse.\n */\nexport function Sparkline({\n data,\n width = DEFAULT_WIDTH,\n height = DEFAULT_HEIGHT,\n fluid = false,\n variant = \"line\",\n tone = \"chart\",\n min,\n max,\n referenceValue,\n highlightLast = true,\n strokeWidth = 1.5,\n label,\n formatValue,\n locale,\n labels,\n className,\n style,\n ...rest\n}: SparklineProps) {\n const text = useKitLabels(\"sparkline\", DEFAULT_SPARKLINE_LABELS, labels);\n const { scale } = useTextSize();\n const kitLocale = useKitLocale(locale);\n const format = formatValue ?? defaultFormat(kitLocale);\n\n const summary = sparklineSummary(data, text, format);\n const name = label ? text.named(label, summary) : summary;\n\n const W = width;\n const H = height;\n const points = data.map((v) => (isValue(v) ? v : null));\n const values = points.filter(isValue);\n const n = points.length;\n\n // ── Scale ──\n const bounds = [...values];\n if (referenceValue !== undefined && isValue(referenceValue)) bounds.push(referenceValue);\n if (variant === \"bar\") bounds.push(0);\n let lo = min ?? (bounds.length ? Math.min(...bounds) : 0);\n let hi = max ?? (bounds.length ? Math.max(...bounds) : 1);\n if (hi === lo) {\n // A constant series: centre it rather than divide by zero.\n lo -= 1;\n hi += 1;\n }\n const dot = strokeWidth + 1.5;\n const pad = highlightLast && variant !== \"bar\" ? dot : strokeWidth / 2;\n const clamp = (v: number) => Math.min(hi, Math.max(lo, v));\n const y = (v: number) => pad + ((hi - clamp(v)) / (hi - lo)) * (H - 2 * pad);\n const x = (i: number) => (n <= 1 ? W / 2 : pad + (i * (W - 2 * pad)) / (n - 1));\n const r = (v: number) => Math.round(v * 100) / 100;\n\n // Last DEFINED point — the series may well end in a gap. (No `findLastIndex`: the\n // package targets ES2022.)\n let lastIndex = -1;\n for (let i = n - 1; i >= 0 && lastIndex < 0; i -= 1) if (points[i] !== null) lastIndex = i;\n const lastValue = lastIndex >= 0 ? (points[lastIndex] ?? 0) : 0;\n const lineClass = tone === \"signed\" ? signedClass(lastValue) : TONE_CLASS[tone];\n\n // Contiguous runs between gaps. A run of one point is drawn as a dot, so a value\n // isolated between two gaps is still visible.\n const runs: Array<Array<[number, number]>> = [];\n let run: Array<[number, number]> = [];\n points.forEach((v, i) => {\n if (v === null) {\n if (run.length) runs.push(run);\n run = [];\n } else {\n run.push([i, v]);\n }\n });\n if (run.length) runs.push(run);\n\n const linePath = (seg: Array<[number, number]>) =>\n seg.map(([i, v], k) => `${k === 0 ? \"M\" : \"L\"}${r(x(i))} ${r(y(v))}`).join(\" \");\n const dotPath = (i: number, v: number) => `M${r(x(i))} ${r(y(v))} h0`;\n // The area closes to zero when zero is on the scale, else to the bottom edge.\n const areaBase = y(lo <= 0 && hi >= 0 ? 0 : lo);\n\n const STROKE = {\n fill: \"none\",\n stroke: \"currentColor\",\n strokeLinecap: \"round\",\n strokeLinejoin: \"round\",\n vectorEffect: \"non-scaling-stroke\",\n } as const;\n\n return (\n <svg\n role=\"img\"\n aria-label={name}\n {...rest}\n // The drawing stays in its own units (the viewBox); only the box it is shown in\n // grows, uniformly, so nothing is distorted and the strokes keep their px width.\n width={fluid ? \"100%\" : W * scale}\n height={H * scale}\n viewBox={`0 0 ${W} ${H}`}\n preserveAspectRatio=\"none\"\n className={cn(fluid ? \"block w-full\" : \"inline-block shrink-0 align-middle\", \"overflow-visible\", className)}\n style={style}\n >\n {referenceValue !== undefined && isValue(referenceValue) && referenceValue >= lo && referenceValue <= hi && (\n <path\n d={`M0 ${r(y(referenceValue))} H${W}`}\n {...STROKE}\n strokeWidth={1}\n strokeDasharray=\"2 2\"\n className=\"text-[var(--border-strong)]\"\n />\n )}\n\n {variant === \"bar\"\n ? (() => {\n const slot = W / Math.max(n, 1);\n const bw = Math.max(1, slot * 0.7);\n const base = y(0);\n return points.map((v, i) => {\n if (v === null) return null;\n const top = Math.min(y(v), base);\n return (\n <rect\n key={i}\n x={r(i * slot + (slot - bw) / 2)}\n y={r(top)}\n width={r(bw)}\n height={r(Math.abs(y(v) - base))}\n fill=\"currentColor\"\n opacity={highlightLast && i !== lastIndex ? 0.55 : 1}\n className={tone === \"signed\" ? signedClass(v) : TONE_CLASS[tone]}\n />\n );\n });\n })()\n : runs.map((seg, k) =>\n seg.length === 1 ? (\n <path\n key={k}\n d={dotPath(seg[0][0], seg[0][1])}\n {...STROKE}\n strokeWidth={strokeWidth * 2}\n className={lineClass}\n />\n ) : (\n <g key={k} className={lineClass}>\n {variant === \"area\" && (\n <path\n d={`${linePath(seg)} L${r(x(seg[seg.length - 1][0]))} ${r(areaBase)} L${r(x(seg[0][0]))} ${r(areaBase)} Z`}\n fill=\"currentColor\"\n fillOpacity={0.15}\n stroke=\"none\"\n />\n )}\n <path d={linePath(seg)} {...STROKE} strokeWidth={strokeWidth} />\n </g>\n ),\n )}\n\n {highlightLast && variant !== \"bar\" && lastIndex >= 0 && (\n <path\n d={dotPath(lastIndex, lastValue)}\n {...STROKE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G;AAAA,YACJ,aAAa,MAAM,IAAI;AAAA,YACvB,WAAW;AAAA,YACX,uBAAoB;AAAA;AAAA,QACtB;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
|
|
@@ -97,7 +97,11 @@ interface StatTileProps extends Omit<ComponentPropsWithoutRef<"div">, "children"
|
|
|
97
97
|
/** The explanation behind a "?" beside the label (a {@link FieldHint}) — hidden
|
|
98
98
|
* until asked for, so it is for what a reader MIGHT want to know ("excludes
|
|
99
99
|
* transfers between your own accounts"). For a line everyone should read, use
|
|
100
|
-
* {@link StatTileProps.description} instead.
|
|
100
|
+
* {@link StatTileProps.description} instead.
|
|
101
|
+
*
|
|
102
|
+
* 0.32 (docs/text-size-harmonization.md §4 "No fact only in a tooltip"): at Large
|
|
103
|
+
* and Extra large, and on a touch screen, the words are shown under the label
|
|
104
|
+
* instead of behind the "?". */
|
|
101
105
|
hint?: string;
|
|
102
106
|
/**
|
|
103
107
|
* Keep the label to ONE line, cut with an ellipsis, and show the whole of it in a
|
|
@@ -115,6 +119,9 @@ interface StatTileProps extends Omit<ComponentPropsWithoutRef<"div">, "children"
|
|
|
115
119
|
* your own `<Tooltip>` for the full text (keksdose's admin metrics-panel.tsx:134
|
|
116
120
|
* does, from before this prop). A wrapped label shows a bubble even when nothing is
|
|
117
121
|
* cut, and nests its trigger inside this one's.
|
|
122
|
+
*
|
|
123
|
+
* Ignored at Large and Extra large (0.32, §4): nothing truncates there, and the full
|
|
124
|
+
* label would otherwise be a fact only in a tooltip.
|
|
118
125
|
*/
|
|
119
126
|
truncateLabel?: boolean;
|
|
120
127
|
/**
|
|
@@ -145,6 +152,15 @@ interface StatTileProps extends Omit<ComponentPropsWithoutRef<"div">, "children"
|
|
|
145
152
|
* Withheld while `loading`, like the sub-values.
|
|
146
153
|
*/
|
|
147
154
|
projection?: StatTileSubValue;
|
|
155
|
+
/**
|
|
156
|
+
* Smaller figures under the headline, label left and figure right.
|
|
157
|
+
*
|
|
158
|
+
* At Large and Extra large (0.32, §4 "StatTile shows its one big number; the sparkline
|
|
159
|
+
* and sub-values move below"): the tile leads with the headline and its delta, and the
|
|
160
|
+
* projection, these rows and the sparkline follow beneath the description, each row's
|
|
161
|
+
* label over its figure — a 2-up tile at 150 % is 120 px of text wide, and a label
|
|
162
|
+
* beside a figure there squeezed both.
|
|
163
|
+
*/
|
|
148
164
|
subValues?: StatTileSubValue[];
|
|
149
165
|
/** Shorthand for a fluid {@link Sparkline} named after the tile and speaking in
|
|
150
166
|
* the tile's number format. The name is the label's text; see
|