@eifi1/ui-kit 0.51.4 → 0.51.6
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 +5 -5
- package/dist/account/account-settings-labels.js.map +1 -1
- package/dist/account/account-settings.js +11 -9
- package/dist/account/account-settings.js.map +1 -1
- package/dist/account/delete-account-setting.js +56 -65
- package/dist/account/delete-account-setting.js.map +1 -1
- package/dist/account/email-change-setting-labels.js.map +1 -1
- package/dist/account/email-change-setting.js.map +1 -1
- package/dist/account/passkeys-setting.js.map +1 -1
- package/dist/account/sessions-setting.js.map +1 -1
- package/dist/admin/admin-action-confirm.js +1 -3
- package/dist/admin/admin-action-confirm.js.map +1 -1
- package/dist/admin/admin-action-log.js.map +1 -1
- package/dist/admin/admin-area-labels.js +4 -1
- package/dist/admin/admin-area-labels.js.map +1 -1
- package/dist/admin/admin-overview.js +19 -11
- package/dist/admin/admin-overview.js.map +1 -1
- package/dist/admin/admin-sections.js.map +1 -1
- package/dist/admin/admin-tool-links.d.ts +1 -1
- package/dist/admin/admin-tool-links.js +7 -1
- package/dist/admin/admin-tool-links.js.map +1 -1
- package/dist/admin/invitations-panel.js +2 -13
- package/dist/admin/invitations-panel.js.map +1 -1
- package/dist/admin/mail-test-card.js.map +1 -1
- package/dist/admin/reviewer-scope-editor.js +4 -11
- package/dist/admin/reviewer-scope-editor.js.map +1 -1
- package/dist/admin/role-select.js.map +1 -1
- package/dist/admin/user-roster.js +1 -9
- package/dist/admin/user-roster.js.map +1 -1
- package/dist/auth/accept-invitation.js.map +1 -1
- package/dist/auth/auth-errors.js.map +1 -1
- package/dist/auth/forgot-password-form.js +23 -31
- package/dist/auth/forgot-password-form.js.map +1 -1
- package/dist/auth/register-form.js.map +1 -1
- package/dist/auth/reset-password-form.js.map +1 -1
- package/dist/auth/sign-in-form.js +13 -5
- package/dist/auth/sign-in-form.js.map +1 -1
- package/dist/auth/verify-email.js +1 -8
- package/dist/auth/verify-email.js.map +1 -1
- package/dist/billing/billing-banner.js.map +1 -1
- package/dist/billing/billing-labels.js.map +1 -1
- package/dist/billing/checkout-processing.js.map +1 -1
- package/dist/billing/plan-card.js +91 -85
- package/dist/billing/plan-card.js.map +1 -1
- package/dist/billing/plan-limit-toast.js.map +1 -1
- package/dist/billing/plan-limit.js.map +1 -1
- package/dist/billing/plan-price.js.map +1 -1
- package/dist/billing/plan-switch.js.map +1 -1
- package/dist/billing/subscription-actions.js.map +1 -1
- package/dist/bin/eifi1-pay-page.mjs +6 -1
- package/dist/components/account-chips.js.map +1 -1
- package/dist/components/alert-banner.js +1 -5
- package/dist/components/alert-banner.js.map +1 -1
- package/dist/components/amount-input.js +29 -12
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/authed-image.js.map +1 -1
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/bulk-action-bar.js +1 -4
- package/dist/components/bulk-action-bar.js.map +1 -1
- package/dist/components/button-group.js.map +1 -1
- package/dist/components/button-look.js.map +1 -1
- package/dist/components/button.js +1 -7
- package/dist/components/button.js.map +1 -1
- package/dist/components/calculator.js +5 -5
- package/dist/components/calculator.js.map +1 -1
- package/dist/components/calendar-heatmap.js +4 -10
- package/dist/components/calendar-heatmap.js.map +1 -1
- package/dist/components/card.js +1 -8
- package/dist/components/card.js.map +1 -1
- package/dist/components/chart-zoom-core.js +3 -17
- package/dist/components/chart-zoom-core.js.map +1 -1
- package/dist/components/chart.d.ts +1 -1
- package/dist/components/chart.js +4 -22
- package/dist/components/chart.js.map +1 -1
- package/dist/components/checkbox-group.js +1 -4
- package/dist/components/checkbox-group.js.map +1 -1
- package/dist/components/chip-input.js +4 -1
- package/dist/components/chip-input.js.map +1 -1
- package/dist/components/chip.js +10 -5
- package/dist/components/chip.js.map +1 -1
- package/dist/components/choice-card.js +58 -74
- package/dist/components/choice-card.js.map +1 -1
- package/dist/components/column-mapper-labels.js.map +1 -1
- package/dist/components/column-mapper.js +167 -227
- package/dist/components/column-mapper.js.map +1 -1
- package/dist/components/combobox-core.js +1 -4
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox.js +1 -4
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/confirm-dialog.js.map +1 -1
- package/dist/components/copy-button.js.map +1 -1
- package/dist/components/country-select.d.ts +5 -4
- package/dist/components/country-select.js +3 -19
- package/dist/components/country-select.js.map +1 -1
- package/dist/components/currency-option-list.js +10 -8
- package/dist/components/currency-option-list.js.map +1 -1
- package/dist/components/currency-select.js +1 -6
- package/dist/components/currency-select.js.map +1 -1
- package/dist/components/danger-confirm.js.map +1 -1
- package/dist/components/data-table-cells.js.map +1 -1
- package/dist/components/data-table-column-settings.js.map +1 -1
- package/dist/components/data-table-filter-popover.js +2 -18
- package/dist/components/data-table-filter-popover.js.map +1 -1
- package/dist/components/data-table-filters.js.map +1 -1
- package/dist/components/data-table-fit.js.map +1 -1
- package/dist/components/data-table-groups.js +3 -1
- package/dist/components/data-table-groups.js.map +1 -1
- package/dist/components/data-table-head.js +44 -56
- package/dist/components/data-table-head.js.map +1 -1
- package/dist/components/data-table-mobile.js +31 -44
- package/dist/components/data-table-mobile.js.map +1 -1
- package/dist/components/data-table-pagination.js.map +1 -1
- package/dist/components/data-table-row-actions.js +19 -16
- package/dist/components/data-table-row-actions.js.map +1 -1
- package/dist/components/data-table-row.js.map +1 -1
- package/dist/components/data-table-shared.js.map +1 -1
- package/dist/components/data-table-sort.js.map +1 -1
- package/dist/components/data-table-virtual.js +4 -1
- package/dist/components/data-table-virtual.js.map +1 -1
- package/dist/components/data-table.js +30 -39
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.js +1 -6
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/date-range-picker.js.map +1 -1
- package/dist/components/description-list.js +10 -10
- package/dist/components/description-list.js.map +1 -1
- package/dist/components/dialog-frame.js +9 -2
- package/dist/components/dialog-frame.js.map +1 -1
- package/dist/components/disclosure.js +17 -27
- package/dist/components/disclosure.js.map +1 -1
- package/dist/components/dropdown.js +25 -35
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/empty-state.js.map +1 -1
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/error-boundary.js.map +1 -1
- package/dist/components/field-base.js +5 -5
- package/dist/components/field-base.js.map +1 -1
- package/dist/components/field-parts.d.ts +1 -1
- package/dist/components/field-parts.js +10 -14
- package/dist/components/field-parts.js.map +1 -1
- package/dist/components/field-sync.js +8 -10
- package/dist/components/field-sync.js.map +1 -1
- package/dist/components/file-button.js.map +1 -1
- package/dist/components/file-dropzone.js.map +1 -1
- package/dist/components/floating-panel.js +4 -1
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/focus-ring.js.map +1 -1
- package/dist/components/form-actions.js.map +1 -1
- package/dist/components/grouped-picker.js +6 -8
- package/dist/components/grouped-picker.js.map +1 -1
- package/dist/components/hover-menu.js +1 -4
- package/dist/components/hover-menu.js.map +1 -1
- package/dist/components/iban-input-labels.js.map +1 -1
- package/dist/components/icon-button.js +4 -1
- package/dist/components/icon-button.js.map +1 -1
- package/dist/components/icon-picker.js +2 -7
- package/dist/components/icon-picker.js.map +1 -1
- package/dist/components/image-grid.js +41 -50
- package/dist/components/image-grid.js.map +1 -1
- package/dist/components/inline-edit-field.js.map +1 -1
- package/dist/components/inline-entity-combobox.js +2 -8
- package/dist/components/inline-entity-combobox.js.map +1 -1
- package/dist/components/input.js +14 -2
- package/dist/components/input.js.map +1 -1
- package/dist/components/jump-calendar.js +1 -7
- package/dist/components/jump-calendar.js.map +1 -1
- package/dist/components/legal-labels.js.map +1 -1
- package/dist/components/legal-page.js +14 -2
- package/dist/components/legal-page.js.map +1 -1
- package/dist/components/legal.js +12 -2
- package/dist/components/legal.js.map +1 -1
- package/dist/components/lightbox.js.map +1 -1
- package/dist/components/line-items.js +26 -36
- package/dist/components/line-items.js.map +1 -1
- package/dist/components/list.js +22 -10
- package/dist/components/list.js.map +1 -1
- package/dist/components/measured-grid.js +29 -53
- package/dist/components/measured-grid.js.map +1 -1
- package/dist/components/menu-item.js.map +1 -1
- package/dist/components/mini-calendar.js +13 -31
- package/dist/components/mini-calendar.js.map +1 -1
- package/dist/components/money-field.js.map +1 -1
- package/dist/components/month-picker.js +10 -21
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-entity-combobox.js +3 -16
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/nav-pills.js +10 -1
- package/dist/components/nav-pills.js.map +1 -1
- package/dist/components/number-field.js.map +1 -1
- package/dist/components/number-input.js +1 -7
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/numpad-sheet.js +1 -4
- package/dist/components/numpad-sheet.js.map +1 -1
- package/dist/components/one-time-code-input.js +1 -7
- package/dist/components/one-time-code-input.js.map +1 -1
- package/dist/components/page-contents.js +13 -22
- package/dist/components/page-contents.js.map +1 -1
- package/dist/components/page-header.js +1 -11
- package/dist/components/page-header.js.map +1 -1
- package/dist/components/password-strength-labels.js.map +1 -1
- package/dist/components/password-strength.js +2 -8
- package/dist/components/password-strength.js.map +1 -1
- package/dist/components/phone-input.js +42 -57
- package/dist/components/phone-input.js.map +1 -1
- package/dist/components/picker-sheet.js.map +1 -1
- package/dist/components/pie-chart.js +1 -8
- package/dist/components/pie-chart.js.map +1 -1
- package/dist/components/popover.js.map +1 -1
- package/dist/components/progress-bar.js +16 -9
- package/dist/components/progress-bar.js.map +1 -1
- package/dist/components/qr-code.js +1 -8
- package/dist/components/qr-code.js.map +1 -1
- package/dist/components/row-actions.js +5 -1
- package/dist/components/row-actions.js.map +1 -1
- package/dist/components/search-field.js.map +1 -1
- package/dist/components/select.js +28 -38
- package/dist/components/select.js.map +1 -1
- package/dist/components/separator.js +1 -5
- package/dist/components/separator.js.map +1 -1
- package/dist/components/series-chart-axes.js +4 -1
- package/dist/components/series-chart-axes.js.map +1 -1
- package/dist/components/series-chart-budget.js.map +1 -1
- package/dist/components/series-chart-ticks.js.map +1 -1
- package/dist/components/series-chart.js +29 -45
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/settings-fields.js +21 -17
- package/dist/components/settings-fields.js.map +1 -1
- package/dist/components/share-card.js +4 -9
- package/dist/components/share-card.js.map +1 -1
- package/dist/components/sign-chip.js.map +1 -1
- package/dist/components/signature-pad.js +4 -13
- package/dist/components/signature-pad.js.map +1 -1
- package/dist/components/signed-amount.js +12 -5
- package/dist/components/signed-amount.js.map +1 -1
- package/dist/components/skeleton.js +2 -17
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/slider.js +13 -36
- package/dist/components/slider.js.map +1 -1
- package/dist/components/sparkline.js.map +1 -1
- package/dist/components/stat-tile.js +14 -10
- package/dist/components/stat-tile.js.map +1 -1
- package/dist/components/swatch-picker.js +14 -4
- package/dist/components/swatch-picker.js.map +1 -1
- package/dist/components/swipeable-row.d.ts +1 -1
- package/dist/components/swipeable-row.js +1 -8
- package/dist/components/swipeable-row.js.map +1 -1
- package/dist/components/table-skeleton.js +4 -1
- package/dist/components/table-skeleton.js.map +1 -1
- package/dist/components/table.js +12 -9
- package/dist/components/table.js.map +1 -1
- package/dist/components/tabs.js +5 -24
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/text-link.js.map +1 -1
- package/dist/components/text.js.map +1 -1
- package/dist/components/tile-radio.js +1 -7
- package/dist/components/tile-radio.js.map +1 -1
- package/dist/components/time-input.js.map +1 -1
- package/dist/components/toast.js.map +1 -1
- package/dist/components/toggle-group.js +6 -1
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/toggle-legend.js +2 -11
- package/dist/components/toggle-legend.js.map +1 -1
- package/dist/components/tooltip.js +2 -22
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/translation-review-editor.js +1 -4
- package/dist/components/translation-review-editor.js.map +1 -1
- package/dist/components/translation-review-parts.d.ts +1 -1
- package/dist/components/translation-review-parts.js +7 -1
- package/dist/components/translation-review-parts.js.map +1 -1
- package/dist/components/translation-review.js +18 -7
- package/dist/components/translation-review.js.map +1 -1
- package/dist/components/tree-view.js +14 -10
- package/dist/components/tree-view.js.map +1 -1
- package/dist/components/treemap.d.ts +24 -2
- package/dist/components/treemap.js +28 -4
- package/dist/components/treemap.js.map +1 -1
- package/dist/components/trigger-aria.js.map +1 -1
- package/dist/components/use-table-state.js +14 -11
- package/dist/components/use-table-state.js.map +1 -1
- package/dist/components/user-avatar.js +3 -26
- package/dist/components/user-avatar.js.map +1 -1
- package/dist/demo/demo-start.js +8 -4
- package/dist/demo/demo-start.js.map +1 -1
- package/dist/eslint/index.js +1 -1
- package/dist/feedback/feedback-attachment-labels.js.map +1 -1
- package/dist/feedback/feedback-attachment.js +1 -8
- package/dist/feedback/feedback-attachment.js.map +1 -1
- package/dist/feedback/feedback-capture.d.ts +1 -1
- package/dist/feedback/feedback-capture.js +3 -1
- package/dist/feedback/feedback-capture.js.map +1 -1
- package/dist/feedback/feedback-comment-thread.js +27 -13
- package/dist/feedback/feedback-comment-thread.js.map +1 -1
- package/dist/feedback/feedback-context.js +1 -4
- package/dist/feedback/feedback-context.js.map +1 -1
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-inbox.js.map +1 -1
- package/dist/feedback/feedback-public-list.js +7 -1
- package/dist/feedback/feedback-public-list.js.map +1 -1
- package/dist/feedback/feedback-record.js +1 -5
- package/dist/feedback/feedback-record.js.map +1 -1
- package/dist/feedback/feedback-replies.js +25 -10
- package/dist/feedback/feedback-replies.js.map +1 -1
- package/dist/feedback/feedback-row-detail.js.map +1 -1
- package/dist/feedback/feedback-status-undo.js.map +1 -1
- package/dist/feedback/feedback-submit-dialog.js.map +1 -1
- package/dist/feedback/feedback-table.js +4 -1
- package/dist/feedback/feedback-table.js.map +1 -1
- package/dist/feedback/feedback-thread.js +2 -13
- package/dist/feedback/feedback-thread.js.map +1 -1
- package/dist/feedback/feedback-vocabulary.js.map +1 -1
- package/dist/feedback/feedback-vote-button.js.map +1 -1
- package/dist/hooks/use-anchored-rect.js.map +1 -1
- package/dist/hooks/use-document-title.js.map +1 -1
- package/dist/hooks/use-file-drop.js.map +1 -1
- package/dist/hooks/use-file-picker-labels.js.map +1 -1
- package/dist/hooks/use-file-picker.js.map +1 -1
- package/dist/hooks/use-focus-trap.js.map +1 -1
- package/dist/hooks/use-overlay-history.js +10 -5
- package/dist/hooks/use-overlay-history.js.map +1 -1
- package/dist/hooks/use-row-swipe.d.ts +1 -1
- package/dist/hooks/use-row-swipe.js +1 -6
- package/dist/hooks/use-row-swipe.js.map +1 -1
- package/dist/i18n/defaults.js +1 -4
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.js +4 -1
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.js +2 -8
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/languages.js.map +1 -1
- package/dist/i18n/locales/en.js +4 -1
- package/dist/i18n/locales/en.js.map +2 -2
- package/dist/i18n/locales/es.js +4 -1
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.js +4 -1
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.js +4 -1
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.js +4 -1
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/plurals.js.map +1 -1
- package/dist/i18n/review.js +13 -7
- package/dist/i18n/review.js.map +1 -1
- package/dist/i18n/shared-labels.js.map +1 -1
- package/dist/index.d.ts +16 -16
- package/dist/index.js +40 -23
- package/dist/index.js.map +1 -1
- package/dist/landing/access.js +1 -4
- package/dist/landing/access.js.map +1 -1
- package/dist/landing/landing-sections.js +35 -38
- package/dist/landing/landing-sections.js.map +1 -1
- package/dist/landing/page-seo.js.map +1 -1
- package/dist/lib/calc.js.map +1 -1
- package/dist/lib/clipboard-minus.js.map +1 -1
- package/dist/lib/dates.js.map +1 -1
- package/dist/lib/decimal-marks.js.map +1 -1
- package/dist/lib/device-settings.js +2 -1
- package/dist/lib/device-settings.js.map +1 -1
- package/dist/lib/direction.js.map +1 -1
- package/dist/lib/iban.js.map +1 -1
- package/dist/lib/logger.js +1 -5
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/person-name.js.map +1 -1
- package/dist/lib/phone.js.map +1 -1
- package/dist/lib/qr-encode.js +344 -8
- package/dist/lib/qr-encode.js.map +1 -1
- package/dist/lib/session-refresh.js.map +1 -1
- package/dist/lib/table-text.js +15 -3
- package/dist/lib/table-text.js.map +1 -1
- package/dist/lib/text-match.d.ts +4 -0
- package/dist/lib/text-match.js.map +1 -1
- package/dist/lib/translation-review.js.map +1 -1
- package/dist/notifications/notification-inbox.js +63 -44
- package/dist/notifications/notification-inbox.js.map +1 -1
- package/dist/notifications/notification-parts.js.map +1 -1
- package/dist/notifications/notification-types-setting.js.map +1 -1
- package/dist/notifications/notifications-labels.js.map +1 -1
- package/dist/notifications/push-device-setting.js +6 -1
- package/dist/notifications/push-device-setting.js.map +1 -1
- package/dist/notifications/push-devices-setting.js.map +1 -1
- package/dist/notifications/push-worker.js.map +1 -1
- package/dist/notifications/quiet-hours-setting.js.map +1 -1
- package/dist/notifications/use-push-device.js +4 -1
- package/dist/notifications/use-push-device.js.map +1 -1
- package/dist/offline/pwa-update-prompt.d.ts +1 -1
- package/dist/offline/pwa-update-prompt.js +7 -1
- package/dist/offline/pwa-update-prompt.js.map +1 -1
- package/dist/offline/query-persistence.js.map +1 -1
- package/dist/offline.d.ts +1 -1
- package/dist/offline.js +6 -1
- package/dist/offline.js.map +1 -1
- package/dist/pay/pay.css +8 -1
- package/dist/rhf/fields.d.ts +1 -2
- package/dist/rhf/fields.js +1 -10
- package/dist/rhf/fields.js.map +1 -1
- package/dist/rhf/form-core.js +1 -4
- package/dist/rhf/form-core.js.map +1 -1
- package/dist/rhf/line-items.js.map +1 -1
- package/dist/rhf/use-rhf-wizard-step.js.map +1 -1
- package/dist/search/command-palette.js +71 -62
- package/dist/search/command-palette.js.map +1 -1
- package/dist/search/global-search.js +34 -5
- package/dist/search/global-search.js.map +1 -1
- package/dist/search/search-index.js.map +1 -1
- package/dist/settings/device-reset-setting.js +1 -6
- package/dist/settings/device-reset-setting.js.map +1 -1
- package/dist/settings/settings-heading.js.map +1 -1
- package/dist/settings/settings-layout.js +9 -20
- package/dist/settings/settings-layout.js.map +1 -1
- package/dist/settings/use-settings-route.js.map +1 -1
- package/dist/shell/app-shell.js +62 -31
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/auth-layout.js +1 -10
- package/dist/shell/auth-layout.js.map +1 -1
- package/dist/shell/dev-menu.js +12 -6
- package/dist/shell/dev-menu.js.map +1 -1
- package/dist/shell/option-switcher-menu.js.map +1 -1
- package/dist/shell/sync-status-indicator.js +7 -6
- package/dist/shell/sync-status-indicator.js.map +1 -1
- package/dist/shell/top-bar-parts-labels.js.map +1 -1
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell/topbar-controls.js +1 -10
- package/dist/shell/topbar-controls.js.map +1 -1
- package/dist/shell/tour-menu.js +9 -1
- package/dist/shell/tour-menu.js.map +1 -1
- package/dist/sync/db.js.map +1 -1
- package/dist/sync/engine.js +24 -6
- package/dist/sync/engine.js.map +1 -1
- package/dist/sync.d.ts +2 -2
- package/dist/sync.js +7 -1
- package/dist/sync.js.map +1 -1
- package/dist/testing/css-variables.js.map +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +1 -3
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/react.js.map +1 -1
- package/dist/testing/viewport.js +7 -4
- package/dist/testing/viewport.js.map +1 -1
- package/dist/theme/contrast-tokens.js +13 -2
- package/dist/theme/contrast-tokens.js.map +1 -1
- package/dist/theme/contrast.d.ts +2 -2
- package/dist/theme/palette-derive.d.ts +1 -1
- package/dist/theme/palette-derive.js +18 -29
- package/dist/theme/palette-derive.js.map +1 -1
- package/dist/theme/palette-presets.js.map +1 -1
- package/dist/theme/palette-store.js.map +1 -1
- package/dist/theme/text-size.js.map +1 -1
- package/dist/theme/theme-store.js +1 -3
- package/dist/theme/theme-store.js.map +1 -1
- package/dist/tour/tour-catalogue.js.map +1 -1
- package/dist/tour/tour-dock.js +5 -1
- package/dist/tour/tour-dock.js.map +1 -1
- package/dist/tour/tour-engine.js +1 -4
- package/dist/tour/tour-engine.js.map +1 -1
- package/dist/tour/tour.js +21 -12
- package/dist/tour/tour.js.map +1 -1
- package/dist/tour/use-tour-progress.js.map +1 -1
- package/dist/tour/use-tour-url-sync.js.map +1 -1
- package/dist/wizard/stepper-nav.js +3 -24
- package/dist/wizard/stepper-nav.js.map +1 -1
- package/dist/wizard/types.js.map +1 -1
- package/dist/wizard/use-wizard.js +24 -28
- package/dist/wizard/use-wizard.js.map +1 -1
- package/dist/wizard/validation.js.map +1 -1
- package/dist/wizard/wizard-context.js.map +1 -1
- package/dist/wizard/wizard-step.d.ts +1 -1
- package/dist/wizard/wizard-step.js +1 -8
- package/dist/wizard/wizard-step.js.map +1 -1
- package/dist/wizard/wizard-summary.js.map +1 -1
- package/package.json +5 -2
- package/src/account/account-settings-labels.ts +1 -2
- package/src/account/account-settings.tsx +11 -17
- package/src/account/delete-account-setting.tsx +1 -6
- package/src/account/email-change-setting-labels.ts +1 -2
- package/src/account/email-change-setting.tsx +3 -1
- package/src/account/passkeys-setting.tsx +1 -3
- package/src/account/sessions-setting.tsx +4 -2
- package/src/admin/admin-action-confirm.tsx +4 -7
- package/src/admin/admin-action-log.tsx +29 -29
- package/src/admin/admin-area-labels.ts +4 -1
- package/src/admin/admin-overview.tsx +8 -2
- package/src/admin/admin-sections.tsx +3 -1
- package/src/admin/admin-tool-links.tsx +7 -1
- package/src/admin/invitations-panel.tsx +5 -11
- package/src/admin/mail-test-card.tsx +1 -2
- package/src/admin/reviewer-scope-editor.tsx +4 -9
- package/src/admin/role-select.tsx +4 -2
- package/src/admin/user-roster.tsx +2 -11
- package/src/auth/accept-invitation.tsx +1 -7
- package/src/auth/auth-errors.ts +1 -6
- package/src/auth/forgot-password-form.tsx +2 -7
- package/src/auth/register-form.tsx +7 -8
- package/src/auth/reset-password-form.tsx +2 -5
- package/src/auth/sign-in-form.tsx +15 -14
- package/src/auth/verify-email.tsx +2 -7
- package/src/billing/billing-banner.tsx +3 -7
- package/src/billing/billing-labels.ts +6 -4
- package/src/billing/checkout-processing.ts +0 -1
- package/src/billing/plan-card.tsx +9 -8
- package/src/billing/plan-limit-toast.tsx +1 -2
- package/src/billing/plan-limit.ts +1 -2
- package/src/billing/plan-price.ts +1 -4
- package/src/billing/plan-switch.tsx +1 -2
- package/src/billing/subscription-actions.tsx +5 -2
- package/src/components/account-chips.tsx +1 -7
- package/src/components/alert-banner.tsx +2 -8
- package/src/components/amount-input.tsx +206 -178
- package/src/components/authed-image.tsx +7 -4
- package/src/components/autocomplete.tsx +7 -9
- package/src/components/bulk-action-bar.tsx +2 -7
- package/src/components/button-group.tsx +1 -2
- package/src/components/button-look.ts +6 -17
- package/src/components/button.tsx +1 -4
- package/src/components/calculator.tsx +6 -9
- package/src/components/calendar-heatmap.tsx +5 -10
- package/src/components/card.tsx +9 -13
- package/src/components/chart-zoom-core.tsx +6 -33
- package/src/components/chart.tsx +8 -31
- package/src/components/checkbox-group.tsx +1 -4
- package/src/components/chip-input.tsx +6 -6
- package/src/components/chip.tsx +14 -26
- package/src/components/choice-card.tsx +4 -18
- package/src/components/column-mapper-labels.ts +3 -10
- package/src/components/column-mapper.tsx +33 -122
- package/src/components/combobox-core.tsx +12 -42
- package/src/components/combobox.tsx +2 -6
- package/src/components/confirm-dialog.tsx +1 -3
- package/src/components/copy-button.tsx +2 -4
- package/src/components/country-select.tsx +9 -21
- package/src/components/currency-option-list.tsx +13 -14
- package/src/components/currency-select.tsx +2 -7
- package/src/components/danger-confirm.tsx +8 -9
- package/src/components/data-table-cells.tsx +1 -2
- package/src/components/data-table-column-settings.tsx +1 -3
- package/src/components/data-table-filter-popover.tsx +5 -19
- package/src/components/data-table-filters.ts +1 -6
- package/src/components/data-table-fit.ts +1 -3
- package/src/components/data-table-groups.tsx +3 -1
- package/src/components/data-table-head.tsx +27 -45
- package/src/components/data-table-mobile.tsx +99 -108
- package/src/components/data-table-pagination.tsx +2 -6
- package/src/components/data-table-row-actions.tsx +25 -24
- package/src/components/data-table-row.tsx +16 -17
- package/src/components/data-table-shared.tsx +10 -16
- package/src/components/data-table-sort.ts +1 -2
- package/src/components/data-table-virtual.ts +9 -4
- package/src/components/data-table.tsx +489 -501
- package/src/components/date-picker.tsx +1 -7
- package/src/components/date-range-picker.tsx +3 -13
- package/src/components/description-list.tsx +7 -13
- package/src/components/dialog-frame.tsx +12 -3
- package/src/components/disclosure.tsx +8 -12
- package/src/components/dropdown.tsx +3 -11
- package/src/components/empty-state.tsx +1 -3
- package/src/components/entity-combobox.tsx +2 -6
- package/src/components/error-boundary.tsx +7 -7
- package/src/components/field-base.tsx +8 -14
- package/src/components/field-parts.tsx +12 -23
- package/src/components/field-sync.tsx +7 -11
- package/src/components/file-button.tsx +7 -3
- package/src/components/file-dropzone.tsx +7 -12
- package/src/components/floating-panel.tsx +44 -51
- package/src/components/focus-ring.ts +1 -2
- package/src/components/form-actions.tsx +1 -4
- package/src/components/grouped-picker.tsx +6 -8
- package/src/components/hover-menu.tsx +1 -4
- package/src/components/iban-input-labels.ts +1 -2
- package/src/components/icon-button.tsx +46 -48
- package/src/components/icon-picker.tsx +4 -17
- package/src/components/image-grid.tsx +1 -6
- package/src/components/inline-edit-field.tsx +1 -5
- package/src/components/inline-entity-combobox.tsx +6 -21
- package/src/components/input.tsx +14 -2
- package/src/components/jump-calendar.tsx +2 -6
- package/src/components/legal-labels.ts +1 -2
- package/src/components/legal-page.tsx +18 -7
- package/src/components/legal.tsx +14 -5
- package/src/components/lightbox.tsx +1 -3
- package/src/components/line-items.tsx +7 -15
- package/src/components/list.tsx +29 -25
- package/src/components/measured-grid.tsx +8 -30
- package/src/components/menu-item.tsx +1 -3
- package/src/components/mini-calendar.tsx +129 -159
- package/src/components/money-field.tsx +4 -2
- package/src/components/month-picker.tsx +14 -21
- package/src/components/multi-entity-combobox.tsx +6 -26
- package/src/components/multi-select.tsx +5 -9
- package/src/components/nav-pills.tsx +10 -2
- package/src/components/number-field.tsx +18 -15
- package/src/components/number-input.tsx +3 -19
- package/src/components/numpad-sheet.tsx +9 -13
- package/src/components/one-time-code-input.tsx +6 -11
- package/src/components/page-contents.tsx +2 -9
- package/src/components/page-header.tsx +5 -10
- package/src/components/password-strength-labels.ts +1 -2
- package/src/components/password-strength.tsx +6 -9
- package/src/components/phone-input.tsx +2 -13
- package/src/components/picker-sheet.tsx +2 -5
- package/src/components/pie-chart.tsx +6 -12
- package/src/components/popover.tsx +2 -1
- package/src/components/progress-bar.tsx +16 -25
- package/src/components/qr-code.tsx +2 -9
- package/src/components/row-actions.tsx +9 -1
- package/src/components/search-field.tsx +4 -5
- package/src/components/select.tsx +2 -10
- package/src/components/separator.tsx +1 -5
- package/src/components/series-chart-axes.ts +5 -5
- package/src/components/series-chart-budget.ts +1 -4
- package/src/components/series-chart-ticks.ts +1 -4
- package/src/components/series-chart.tsx +43 -83
- package/src/components/settings-fields.tsx +20 -15
- package/src/components/share-card.tsx +6 -14
- package/src/components/sign-chip.tsx +16 -16
- package/src/components/signature-pad.tsx +21 -13
- package/src/components/signed-amount.tsx +6 -14
- package/src/components/skeleton.tsx +2 -13
- package/src/components/slider.tsx +9 -20
- package/src/components/sparkline.tsx +2 -13
- package/src/components/stat-tile.tsx +13 -24
- package/src/components/swatch-picker.tsx +8 -3
- package/src/components/swipeable-row.tsx +2 -11
- package/src/components/table-skeleton.tsx +4 -1
- package/src/components/table.tsx +12 -8
- package/src/components/tabs.tsx +24 -39
- package/src/components/text-link.tsx +6 -6
- package/src/components/text.tsx +1 -2
- package/src/components/tile-radio.tsx +6 -19
- package/src/components/time-input.tsx +4 -5
- package/src/components/toast.tsx +3 -12
- package/src/components/toggle-group.tsx +9 -9
- package/src/components/toggle-legend.tsx +4 -16
- package/src/components/tooltip.tsx +9 -48
- package/src/components/translation-review-editor.tsx +4 -4
- package/src/components/translation-review-parts.tsx +7 -1
- package/src/components/translation-review.tsx +15 -16
- package/src/components/tree-view.tsx +17 -20
- package/src/components/treemap.tsx +59 -9
- package/src/components/trigger-aria.ts +1 -4
- package/src/components/use-table-state.ts +16 -17
- package/src/components/user-avatar.tsx +4 -21
- package/src/demo/demo-start.tsx +8 -4
- package/src/feedback/feedback-attachment-labels.ts +2 -1
- package/src/feedback/feedback-attachment.tsx +16 -29
- package/src/feedback/feedback-capture.ts +3 -1
- package/src/feedback/feedback-comment-thread.tsx +9 -6
- package/src/feedback/feedback-context.tsx +1 -4
- package/src/feedback/feedback-dialog.tsx +3 -4
- package/src/feedback/feedback-inbox.tsx +3 -9
- package/src/feedback/feedback-public-list.tsx +7 -1
- package/src/feedback/feedback-record.ts +6 -14
- package/src/feedback/feedback-replies.tsx +10 -5
- package/src/feedback/feedback-row-detail.tsx +2 -5
- package/src/feedback/feedback-status-undo.ts +1 -4
- package/src/feedback/feedback-submit-dialog.tsx +4 -4
- package/src/feedback/feedback-table.tsx +12 -8
- package/src/feedback/feedback-thread.tsx +4 -16
- package/src/feedback/feedback-vocabulary.ts +72 -82
- package/src/feedback/feedback-vote-button.tsx +9 -8
- package/src/hooks/use-anchored-rect.ts +1 -4
- package/src/hooks/use-document-title.ts +3 -1
- package/src/hooks/use-file-drop.ts +1 -3
- package/src/hooks/use-file-picker-labels.ts +1 -2
- package/src/hooks/use-file-picker.tsx +1 -5
- package/src/hooks/use-focus-trap.ts +1 -2
- package/src/hooks/use-overlay-history.ts +10 -5
- package/src/hooks/use-row-swipe.ts +1 -6
- package/src/i18n/defaults.ts +1 -4
- package/src/i18n/german.ts +33 -49
- package/src/i18n/kit-labels.tsx +5 -20
- package/src/i18n/languages.ts +2 -8
- package/src/i18n/locales/en.ts +11 -31
- package/src/i18n/locales/es.ts +35 -49
- package/src/i18n/locales/fr.ts +34 -51
- package/src/i18n/locales/hu.ts +26 -37
- package/src/i18n/locales/it.ts +35 -52
- package/src/i18n/locales/zh.ts +14 -32
- package/src/i18n/plurals.ts +4 -1
- package/src/i18n/review.ts +18 -7
- package/src/i18n/shared-labels.ts +1 -2
- package/src/index.ts +106 -32
- package/src/landing/access.ts +2 -7
- package/src/landing/landing-sections.tsx +14 -15
- package/src/landing/page-seo.ts +1 -3
- package/src/lib/calc.ts +4 -1
- package/src/lib/clipboard-minus.ts +4 -1
- package/src/lib/dates.ts +2 -10
- package/src/lib/decimal-marks.ts +1 -3
- package/src/lib/device-settings.ts +2 -1
- package/src/lib/direction.ts +1 -3
- package/src/lib/iban.ts +89 -9
- package/src/lib/logger.ts +1 -5
- package/src/lib/person-name.ts +1 -3
- package/src/lib/phone.ts +5 -8
- package/src/lib/qr-encode.ts +32 -8
- package/src/lib/session-refresh.ts +5 -6
- package/src/lib/table-text.ts +24 -6
- package/src/lib/text-match.ts +15 -3
- package/src/lib/translation-review.ts +1 -3
- package/src/notifications/notification-inbox.tsx +17 -4
- package/src/notifications/notification-parts.tsx +1 -2
- package/src/notifications/notification-types-setting.tsx +19 -18
- package/src/notifications/notifications-labels.ts +1 -2
- package/src/notifications/push-device-setting.tsx +7 -1
- package/src/notifications/push-devices-setting.tsx +7 -3
- package/src/notifications/push-worker.ts +10 -2
- package/src/notifications/quiet-hours-setting.tsx +4 -1
- package/src/notifications/use-push-device.ts +4 -1
- package/src/offline/pwa-update-prompt.tsx +7 -1
- package/src/offline/query-persistence.ts +9 -6
- package/src/offline.ts +6 -1
- package/src/rhf/fields.tsx +50 -19
- package/src/rhf/form-core.tsx +2 -6
- package/src/rhf/line-items.tsx +5 -7
- package/src/rhf/use-rhf-wizard-step.ts +3 -12
- package/src/search/command-palette.tsx +15 -23
- package/src/search/global-search.tsx +38 -8
- package/src/search/search-index.ts +5 -1
- package/src/settings/device-reset-setting.tsx +5 -8
- package/src/settings/settings-heading.tsx +3 -1
- package/src/settings/settings-layout.tsx +6 -13
- package/src/settings/use-settings-route.ts +4 -3
- package/src/shell/app-shell.tsx +48 -24
- package/src/shell/auth-layout.tsx +1 -6
- package/src/shell/dev-menu.tsx +12 -6
- package/src/shell/option-switcher-menu.tsx +1 -3
- package/src/shell/sync-status-indicator.tsx +14 -12
- package/src/shell/top-bar-parts-labels.ts +1 -3
- package/src/shell/topbar-action-menu.tsx +9 -8
- package/src/shell/topbar-controls.tsx +5 -19
- package/src/shell/tour-menu.tsx +9 -1
- package/src/sync/db.ts +5 -1
- package/src/sync/engine.ts +44 -12
- package/src/sync.ts +16 -2
- package/src/testing/css-variables.ts +1 -2
- package/src/testing/index.ts +1 -6
- package/src/testing/react.ts +1 -2
- package/src/testing/viewport.ts +9 -9
- package/src/theme/contrast-tokens.ts +13 -2
- package/src/theme/palette-derive.ts +24 -50
- package/src/theme/palette-presets.ts +0 -1
- package/src/theme/palette-store.ts +1 -4
- package/src/theme/text-size.ts +1 -1
- package/src/theme/theme-store.ts +2 -6
- package/src/tour/tour-catalogue.tsx +4 -2
- package/src/tour/tour-dock.ts +5 -1
- package/src/tour/tour-engine.ts +2 -6
- package/src/tour/tour.tsx +28 -12
- package/src/tour/use-tour-progress.ts +8 -2
- package/src/tour/use-tour-url-sync.ts +3 -1
- package/src/vite-env.d.ts +1 -4
- package/src/wizard/stepper-nav.tsx +10 -35
- package/src/wizard/types.ts +1 -4
- package/src/wizard/use-wizard.ts +28 -43
- package/src/wizard/validation.ts +1 -5
- package/src/wizard/wizard-context.tsx +2 -6
- package/src/wizard/wizard-step.tsx +1 -8
- package/src/wizard/wizard-summary.tsx +2 -6
- package/tokens.css +393 -152
|
@@ -140,11 +140,18 @@ function Delta({
|
|
|
140
140
|
"data-direction": dir,
|
|
141
141
|
className: cn("relative inline-flex flex-wrap items-center gap-x-1.5 tabular-nums", className),
|
|
142
142
|
children: [
|
|
143
|
-
/* @__PURE__ */ jsxs(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
/* @__PURE__ */ jsxs(
|
|
144
|
+
"span",
|
|
145
|
+
{
|
|
146
|
+
"data-private": sensitive ? "" : void 0,
|
|
147
|
+
className: cn("inline-flex items-center gap-0.5 font-medium", tone),
|
|
148
|
+
children: [
|
|
149
|
+
arrow && /* @__PURE__ */ jsx(Icon, { className: "size-[1em] shrink-0", "aria-hidden": true }),
|
|
150
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, children: amount }),
|
|
151
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: spoken })
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
),
|
|
148
155
|
label != null && /* @__PURE__ */ jsx("span", { className: "text-muted", children: label })
|
|
149
156
|
]
|
|
150
157
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/signed-amount.tsx"],"sourcesContent":["import type { ComponentPropsWithRef, ReactNode } from \"react\";\nimport { ArrowDown, ArrowUp, Minus } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { formatMoney, formatNumber, formatPercent } from \"../lib/format\";\nimport { useKitLabels, useKitLocale, type LabelOverride } from \"../i18n/kit-labels\";\nimport { DEFAULT_STAT_TILE_LABELS } from \"./stat-tile\";\nimport type { StatTileLabels } from \"./stat-tile\";\nimport { DEFAULT_SIGNED_AMOUNT_LABELS } from \"./signed-amount-labels\";\n\n/**\n * The text colours a figure can carry, token-backed — `StatTile`'s tones, as a class\n * any span can take.\n *\n * - `default` — the primary text colour. `muted` — the secondary, quiet one.\n * - `income` / `expense` / `net` — the money trio (CVD-safe teal / amber / violet).\n * - `success` / `warning` / `danger` / `info` — a verdict: a rent rise is the tenant's\n * bad news (kastlan lease-columns), a vote \"for\" is green (meeting-agenda-tab).\n * - `brand` — the app's accent.\n *\n * Colour is never the only carrier: pair a verdict with an arrow, a word, or a sign.\n */\nexport type TextTone =\n | \"default\"\n | \"muted\"\n | \"brand\"\n | \"income\"\n | \"expense\"\n | \"net\"\n | \"success\"\n | \"warning\"\n | \"danger\"\n | \"info\";\n\nconst TEXT_TONE: Record<TextTone, string> = {\n default: \"text-primary\",\n muted: \"text-muted\",\n brand: \"text-brand\",\n income: \"text-money-income\",\n expense: \"text-money-expense\",\n net: \"text-money-net\",\n success: \"text-success\",\n warning: \"text-warning\",\n danger: \"text-danger\",\n info: \"text-info\",\n};\n\n/**\n * The class that colours text in `tone` — for the spans kastlan colours by hand with\n * `text-[var(--danger)]` / `text-emerald-600` (settlement-table, changelog-page,\n * meeting-agenda-tab), so the palette they draw from is the kit's tokens.\n */\nexport function toneTextClass(tone: TextTone): string {\n return TEXT_TONE[tone];\n}\n\nexport interface ToneProps extends ComponentPropsWithRef<\"span\"> {\n tone: TextTone;\n}\n\n/** A `<span>` in a {@link TextTone} — `<Tone tone=\"success\">{votesFor}</Tone>`. */\nexport function Tone({ tone, className, ...rest }: ToneProps) {\n return <span {...rest} className={cn(TEXT_TONE[tone], className)} />;\n}\n\n/* ── Signed amounts ──────────────────────────────────────────────────────── */\n\n/** Which way is +1: `up` for a figure where more is good news (income, savings),\n * `down` where less is (a rent the tenant pays, a cost). */\nexport type GoodDirection = \"up\" | \"down\";\n\n/**\n * How a signed figure is coloured:\n * - `signed` (default) — money read by its own sign: above zero `income`, below zero\n * `expense`, zero muted. A balance, a net.\n * - `income` / `expense` / `neutral` — one colour whatever the sign (`neutral` is the\n * text's own colour).\n * - `verdict` — the change judged by {@link SignedAmountProps.goodDirection}: good\n * news `success`, bad news `danger`, zero muted. Setting `goodDirection` implies it.\n */\nexport type SignedAmountTone = \"signed\" | \"income\" | \"expense\" | \"neutral\" | \"verdict\";\n\n/**\n * The colours a VERDICT is painted in (`goodDirection` set, or `tone=\"verdict\"`):\n * - `status` (default) — `success` / `danger`: good news, bad news.\n * - `money` — `income` / `expense` (the `.text-money-pos` / `.text-money-neg` pair):\n * the app's ONE money palette (keksdose dev#434). A grocery price going UP is money\n * going out, so with `goodDirection=\"down\"` it wears the expense colour every other\n * outflow in the app wears — not a red that says \"error\". keksdose coloured its\n * three price-change sites by hand for want of this.\n */\nexport type VerdictPalette = \"status\" | \"money\";\n\n/** What a signed figure says to a screen reader, whose readers disagree about a\n * leading \"+\" (most skip it) and a \"−\" (some read \"dash\", some nothing). */\nexport interface SignedAmountLabels {\n /** A figure above zero. `amount` is formatted and unsigned. */\n positive: (amount: string) => string;\n /** A figure below zero. `amount` is formatted and unsigned. */\n negative: (amount: string) => string;\n}\n\n// Defined in ./signed-amount-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_SIGNED_AMOUNT_LABELS };\n\ninterface SignedFormatProps {\n /** ISO 4217 code: format as money. */\n currency?: string;\n /** `\"percent\"` reads `value` as a RATIO (`0.12` → 12 %), as `StatTile`'s delta does\n * — or as percent POINTS with `ratio={false}`. */\n unit?: \"value\" | \"percent\";\n /** With `unit=\"percent\"`: `true` (default) — `value` is a ratio, `0.12` is 12 %.\n * `false` — `value` is already in percent POINTS, `12` is 12 %, as `formatPercent`'s\n * `ratio` option reads it. Backends send points (keksdose's price changes, kastlan's\n * `change_pct`), and without this every site divided by 100 — and wrote its\n * `flatWithin` as a ratio (`0.005`) beside a value it had to convert. With\n * `ratio={false}` the value AND `flatWithin` are in points (`flatWithin={0.5}` is\n * half a point). Ignored for any other unit. */\n ratio?: boolean;\n /** Compact notation: 12 400 → \"12K\". */\n compact?: boolean;\n /** Fraction digits, as `formatNumber`'s `digits`. */\n digits?: number | { min?: number; max?: number };\n /** Formats the UNSIGNED magnitude, replacing the `Intl` default outright. The sign\n * is the component's. */\n format?: (magnitude: number) => string;\n locale?: string;\n}\n\nfunction useMagnitudeFormatter({ currency, unit, ratio, compact, digits, format, locale }: SignedFormatProps) {\n const kitLocale = useKitLocale(locale);\n return (magnitude: number): string => {\n if (format) return format(magnitude);\n if (unit === \"percent\") return formatPercent(magnitude, { locale: kitLocale, compact, digits, ratio });\n if (currency) return formatMoney(magnitude, currency, { locale: kitLocale, compact, digits });\n return formatNumber(magnitude, { locale: kitLocale, compact, digits });\n };\n}\n\n/** `flatWithin` widens \"no change\" from exactly zero to a band round it: a price that\n * moved by a fraction of a cent, a ratio that rounds to \"0.0 %\", is not a rise, and an\n * arrow and a colour for it claim one. Inclusive — `|value| ≤ flatWithin` is flat. */\nfunction directionOf(value: number, flatWithin = 0): \"up\" | \"down\" | \"flat\" {\n if (Math.abs(value) <= Math.max(0, flatWithin)) return \"flat\";\n return value > 0 ? \"up\" : \"down\";\n}\n\nfunction verdictClass(good: boolean, palette: VerdictPalette): string {\n if (palette === \"money\") return good ? TEXT_TONE.income : TEXT_TONE.expense;\n return good ? TEXT_TONE.success : TEXT_TONE.danger;\n}\n\nfunction signedToneClass(\n tone: SignedAmountTone,\n dir: \"up\" | \"down\" | \"flat\",\n goodDirection: GoodDirection | undefined,\n palette: VerdictPalette,\n): string {\n if (tone === \"verdict\" || (goodDirection && tone === \"signed\")) {\n if (dir === \"flat\" || !goodDirection) return TEXT_TONE.muted;\n return verdictClass(dir === goodDirection, palette);\n }\n if (tone === \"signed\") return dir === \"flat\" ? TEXT_TONE.muted : dir === \"up\" ? TEXT_TONE.income : TEXT_TONE.expense;\n if (tone === \"neutral\") return \"\";\n return TEXT_TONE[tone];\n}\n\nconst ARROW = { up: ArrowUp, down: ArrowDown, flat: Minus } as const;\n\nexport interface SignedAmountProps\n extends SignedFormatProps,\n Omit<ComponentPropsWithRef<\"span\">, \"children\"> {\n value: number;\n /** See {@link SignedAmountTone}. Default `signed`, or `verdict` with `goodDirection`. */\n tone?: SignedAmountTone;\n /** Which way is good news — colours by verdict (`success` / `danger`, or the money\n * pair with `palette=\"money\"`). */\n goodDirection?: GoodDirection;\n /** See {@link VerdictPalette}. Default `status`. Only a verdict reads it. */\n palette?: VerdictPalette;\n /** A magnitude up to which the figure counts as NO change: no sign, no arrow but the\n * flat dash, muted, spoken without \"plus\"/\"minus\" (inclusive; default 0). The digits\n * still print `|value|` — use a band below the display precision, where they round\n * to zero anyway (`flatWithin={0.005}` at two digits). */\n flatWithin?: number;\n /** Print \"+\" before a positive figure (default `true`). A negative always shows its\n * minus; zero shows neither. */\n showPlus?: boolean;\n /** An arrow before the figure (up / down / a dash at zero) — so the direction does not\n * ride on colour alone. Decorative; the words say the same. */\n arrow?: boolean;\n /** Tag the figure `data-private`, for the host's demo-mode blur. */\n sensitive?: boolean;\n labels?: LabelOverride<SignedAmountLabels>;\n}\n\n/**\n * A figure with a sign that matters: a balance, a rent change, a net.\n *\n * kastlan writes it by hand in five places — `{change > 0 ? \"+\" : \"\"}{formatCurrency(\n * change)}` in a span coloured by a ternary (lease-columns:190, settlement-table:58,\n * the tenancy `formatPct`) — and each picks its own colours for the same verdict.\n *\n * The visible figure (sign, digits, arrow) is hidden from assistive tech and spoken as\n * words instead (\"plus CHF 50.00\" / \"minus CHF 50.00\", `signedAmount.*`): a \"+\" is\n * skipped by most screen readers, and `Intl`'s \"−\" is read as \"dash\" or not at all.\n */\nexport function SignedAmount({\n value,\n currency,\n unit,\n ratio,\n compact,\n digits,\n format,\n locale,\n tone = \"signed\",\n goodDirection,\n palette = \"status\",\n flatWithin,\n showPlus = true,\n arrow = false,\n sensitive = false,\n labels,\n className,\n ...rest\n}: SignedAmountProps) {\n const text = useKitLabels(\"signedAmount\", DEFAULT_SIGNED_AMOUNT_LABELS, labels);\n const fmt = useMagnitudeFormatter({ currency, unit, ratio, compact, digits, format, locale });\n const finite = Number.isFinite(value);\n const dir = finite ? directionOf(value, flatWithin) : \"flat\";\n const amount = finite ? fmt(Math.abs(value)) : \"—\";\n // U+2212, the typographic minus: the same width as \"+\", so a column of signed figures\n // lines up under `tabular-nums`.\n const sign = dir === \"up\" ? (showPlus ? \"+\" : \"\") : dir === \"down\" ? \"−\" : \"\";\n const spoken = dir === \"up\" ? text.positive(amount) : dir === \"down\" ? text.negative(amount) : amount;\n const Icon = ARROW[dir];\n return (\n <span\n {...rest}\n data-private={sensitive ? \"\" : undefined}\n data-direction={dir}\n className={cn(\n \"relative inline-flex items-center gap-0.5 whitespace-nowrap tabular-nums\",\n signedToneClass(tone, dir, goodDirection, palette),\n className,\n )}\n >\n {arrow && <Icon aria-hidden className=\"size-[1em] shrink-0\" />}\n <span aria-hidden>\n {sign}\n {amount}\n </span>\n <span className=\"sr-only\">{spoken}</span>\n </span>\n );\n}\n\nexport interface DeltaProps extends SignedFormatProps, Omit<ComponentPropsWithRef<\"span\">, \"children\"> {\n /** The change. Above zero is \"up\". */\n value: number;\n /** Which way is good news. Unset, the change is stated and not judged (muted); set,\n * it is coloured `success` / `danger` and its sentence says \"(better)\" / \"(worse)\". */\n goodDirection?: GoodDirection;\n /** See {@link VerdictPalette}: `money` paints good news `income` and bad news\n * `expense` instead of `success` / `danger`. Default `status`. */\n palette?: VerdictPalette;\n /** See {@link SignedAmountProps.flatWithin}: up to this magnitude the change is\n * \"unchanged\" — flat dash, muted, no verdict. Default 0. */\n flatWithin?: number;\n /** What it is measured against, after it: \"vs last month\". */\n label?: ReactNode;\n /** Hide the arrow (shown by default, as on a StatTile). At zero the arrow is a flat\n * dash BESIDE the figure (\"– 0.00 %\"), never in place of it. */\n arrow?: boolean;\n sensitive?: boolean;\n /** The `statTile` namespace's direction words — a delta says the same as a tile's. */\n labels?: LabelOverride<Pick<StatTileLabels, \"increase\" | \"decrease\" | \"unchanged\" | \"better\" | \"worse\">>;\n}\n\n/**\n * `StatTile`'s delta on its own: an arrow, the unsigned magnitude, and a sentence for\n * screen readers (\"Up 12% (worse)\"), coloured only when `goodDirection` judges it —\n * users up and cost up are the same arrow until someone says which is good.\n *\n * For a change shown outside a tile: kastlan's rent-change column\n * (lease-columns:219, a \"+1.25%\" chip), the breakdown rows of the rent calculator\n * (breakdown-row:5, a trend icon coloured by hand).\n */\nexport function Delta({\n value,\n currency,\n unit,\n ratio,\n compact,\n digits,\n format,\n locale,\n goodDirection,\n palette = \"status\",\n flatWithin,\n label,\n arrow = true,\n sensitive = false,\n labels,\n className,\n ...rest\n}: DeltaProps) {\n const text = useKitLabels(\"statTile\", DEFAULT_STAT_TILE_LABELS, labels);\n const fmt = useMagnitudeFormatter({ currency, unit, ratio, compact, digits, format, locale });\n if (!Number.isFinite(value)) return null;\n const amount = fmt(Math.abs(value));\n const dir = directionOf(value, flatWithin);\n const Icon = ARROW[dir];\n let spoken = dir === \"up\" ? text.increase(amount) : dir === \"down\" ? text.decrease(amount) : text.unchanged;\n let tone = TEXT_TONE.muted;\n if (goodDirection && dir !== \"flat\") {\n const good = dir === goodDirection;\n spoken = good ? text.better(spoken) : text.worse(spoken);\n tone = verdictClass(good, palette);\n }\n return (\n <span\n {...rest}\n data-direction={dir}\n className={cn(\"relative inline-flex flex-wrap items-center gap-x-1.5 tabular-nums\", className)}\n >\n <span data-private={sensitive ? \"\" : undefined} className={cn(\"inline-flex items-center gap-0.5 font-medium\", tone)}>\n {arrow && <Icon className=\"size-[1em] shrink-0\" aria-hidden />}\n {/* The figure at zero too, beside the flat dash (kastlan feedback #48). Before\n this a flat delta with an arrow drew the dash ALONE, as a StatTile does — so\n a rent-change column that printed \"0.00 %\" for an unchanged lease showed a\n bare \"–\" in its place, and a bare dash is what a table prints for a MISSING\n value: \"unchanged\" and \"not known\" looked the same. The Minus icon is the\n neutral indicator, the muted tone the neutral colour, and the figure says\n how much (none) in the column's own digits. A value that is missing never\n reaches here — a non-finite one renders nothing, above. Visible change for\n every `<Delta value={0}>` with the default arrow: \"–\" became \"– 0 %\". */}\n <span aria-hidden>{amount}</span>\n <span className=\"sr-only\">{spoken}</span>\n </span>\n {label != null && <span className=\"text-muted\">{label}</span>}\n </span>\n );\n}\n"],"mappings":";AA6DS,cA2LH,YA3LG;AA5DT,SAAS,WAAW,SAAS,aAAa;AAC1C,SAAS,UAAU;AACnB,SAAS,aAAa,cAAc,qBAAqB;AACzD,SAAS,cAAc,oBAAwC;AAC/D,SAAS,gCAAgC;AAEzC,SAAS,oCAAoC;AA0B7C,MAAM,YAAsC;AAAA,EAC1C,SAAS;AAAA,EACT,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;A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C;AAAA,QACC,SAAS,QAAQ,oBAAC,UAAK,WAAU,cAAc,iBAAM;AAAA;AAAA;AAAA,EACxD;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/signed-amount.tsx"],"sourcesContent":["import type { ComponentPropsWithRef, ReactNode } from \"react\";\nimport { ArrowDown, ArrowUp, Minus } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { formatMoney, formatNumber, formatPercent } from \"../lib/format\";\nimport { useKitLabels, useKitLocale, type LabelOverride } from \"../i18n/kit-labels\";\nimport { DEFAULT_STAT_TILE_LABELS } from \"./stat-tile\";\nimport type { StatTileLabels } from \"./stat-tile\";\nimport { DEFAULT_SIGNED_AMOUNT_LABELS } from \"./signed-amount-labels\";\n\n/**\n * The text colours a figure can carry, token-backed — `StatTile`'s tones, as a class\n * any span can take.\n *\n * - `default` — the primary text colour. `muted` — the secondary, quiet one.\n * - `income` / `expense` / `net` — the money trio (CVD-safe teal / amber / violet).\n * - `success` / `warning` / `danger` / `info` — a verdict: a rent rise is the tenant's\n * bad news (kastlan lease-columns), a vote \"for\" is green (meeting-agenda-tab).\n * - `brand` — the app's accent.\n *\n * Colour is never the only carrier: pair a verdict with an arrow, a word, or a sign.\n */\nexport type TextTone =\n \"default\" | \"muted\" | \"brand\" | \"income\" | \"expense\" | \"net\" | \"success\" | \"warning\" | \"danger\" | \"info\";\n\nconst TEXT_TONE: Record<TextTone, string> = {\n default: \"text-primary\",\n muted: \"text-muted\",\n brand: \"text-brand\",\n income: \"text-money-income\",\n expense: \"text-money-expense\",\n net: \"text-money-net\",\n success: \"text-success\",\n warning: \"text-warning\",\n danger: \"text-danger\",\n info: \"text-info\",\n};\n\n/**\n * The class that colours text in `tone` — for the spans kastlan colours by hand with\n * `text-[var(--danger)]` / `text-emerald-600` (settlement-table, changelog-page,\n * meeting-agenda-tab), so the palette they draw from is the kit's tokens.\n */\nexport function toneTextClass(tone: TextTone): string {\n return TEXT_TONE[tone];\n}\n\nexport interface ToneProps extends ComponentPropsWithRef<\"span\"> {\n tone: TextTone;\n}\n\n/** A `<span>` in a {@link TextTone} — `<Tone tone=\"success\">{votesFor}</Tone>`. */\nexport function Tone({ tone, className, ...rest }: ToneProps) {\n return <span {...rest} className={cn(TEXT_TONE[tone], className)} />;\n}\n\n/* ── Signed amounts ──────────────────────────────────────────────────────── */\n\n/** Which way is +1: `up` for a figure where more is good news (income, savings),\n * `down` where less is (a rent the tenant pays, a cost). */\nexport type GoodDirection = \"up\" | \"down\";\n\n/**\n * How a signed figure is coloured:\n * - `signed` (default) — money read by its own sign: above zero `income`, below zero\n * `expense`, zero muted. A balance, a net.\n * - `income` / `expense` / `neutral` — one colour whatever the sign (`neutral` is the\n * text's own colour).\n * - `verdict` — the change judged by {@link SignedAmountProps.goodDirection}: good\n * news `success`, bad news `danger`, zero muted. Setting `goodDirection` implies it.\n */\nexport type SignedAmountTone = \"signed\" | \"income\" | \"expense\" | \"neutral\" | \"verdict\";\n\n/**\n * The colours a VERDICT is painted in (`goodDirection` set, or `tone=\"verdict\"`):\n * - `status` (default) — `success` / `danger`: good news, bad news.\n * - `money` — `income` / `expense` (the `.text-money-pos` / `.text-money-neg` pair):\n * the app's ONE money palette (keksdose dev#434). A grocery price going UP is money\n * going out, so with `goodDirection=\"down\"` it wears the expense colour every other\n * outflow in the app wears — not a red that says \"error\". keksdose coloured its\n * three price-change sites by hand for want of this.\n */\nexport type VerdictPalette = \"status\" | \"money\";\n\n/** What a signed figure says to a screen reader, whose readers disagree about a\n * leading \"+\" (most skip it) and a \"−\" (some read \"dash\", some nothing). */\nexport interface SignedAmountLabels {\n /** A figure above zero. `amount` is formatted and unsigned. */\n positive: (amount: string) => string;\n /** A figure below zero. `amount` is formatted and unsigned. */\n negative: (amount: string) => string;\n}\n\n// Defined in ./signed-amount-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_SIGNED_AMOUNT_LABELS };\n\ninterface SignedFormatProps {\n /** ISO 4217 code: format as money. */\n currency?: string;\n /** `\"percent\"` reads `value` as a RATIO (`0.12` → 12 %), as `StatTile`'s delta does\n * — or as percent POINTS with `ratio={false}`. */\n unit?: \"value\" | \"percent\";\n /** With `unit=\"percent\"`: `true` (default) — `value` is a ratio, `0.12` is 12 %.\n * `false` — `value` is already in percent POINTS, `12` is 12 %, as `formatPercent`'s\n * `ratio` option reads it. Backends send points (keksdose's price changes, kastlan's\n * `change_pct`), and without this every site divided by 100 — and wrote its\n * `flatWithin` as a ratio (`0.005`) beside a value it had to convert. With\n * `ratio={false}` the value AND `flatWithin` are in points (`flatWithin={0.5}` is\n * half a point). Ignored for any other unit. */\n ratio?: boolean;\n /** Compact notation: 12 400 → \"12K\". */\n compact?: boolean;\n /** Fraction digits, as `formatNumber`'s `digits`. */\n digits?: number | { min?: number; max?: number };\n /** Formats the UNSIGNED magnitude, replacing the `Intl` default outright. The sign\n * is the component's. */\n format?: (magnitude: number) => string;\n locale?: string;\n}\n\nfunction useMagnitudeFormatter({ currency, unit, ratio, compact, digits, format, locale }: SignedFormatProps) {\n const kitLocale = useKitLocale(locale);\n return (magnitude: number): string => {\n if (format) return format(magnitude);\n if (unit === \"percent\") return formatPercent(magnitude, { locale: kitLocale, compact, digits, ratio });\n if (currency) return formatMoney(magnitude, currency, { locale: kitLocale, compact, digits });\n return formatNumber(magnitude, { locale: kitLocale, compact, digits });\n };\n}\n\n/** `flatWithin` widens \"no change\" from exactly zero to a band round it: a price that\n * moved by a fraction of a cent, a ratio that rounds to \"0.0 %\", is not a rise, and an\n * arrow and a colour for it claim one. Inclusive — `|value| ≤ flatWithin` is flat. */\nfunction directionOf(value: number, flatWithin = 0): \"up\" | \"down\" | \"flat\" {\n if (Math.abs(value) <= Math.max(0, flatWithin)) return \"flat\";\n return value > 0 ? \"up\" : \"down\";\n}\n\nfunction verdictClass(good: boolean, palette: VerdictPalette): string {\n if (palette === \"money\") return good ? TEXT_TONE.income : TEXT_TONE.expense;\n return good ? TEXT_TONE.success : TEXT_TONE.danger;\n}\n\nfunction signedToneClass(\n tone: SignedAmountTone,\n dir: \"up\" | \"down\" | \"flat\",\n goodDirection: GoodDirection | undefined,\n palette: VerdictPalette,\n): string {\n if (tone === \"verdict\" || (goodDirection && tone === \"signed\")) {\n if (dir === \"flat\" || !goodDirection) return TEXT_TONE.muted;\n return verdictClass(dir === goodDirection, palette);\n }\n if (tone === \"signed\") return dir === \"flat\" ? TEXT_TONE.muted : dir === \"up\" ? TEXT_TONE.income : TEXT_TONE.expense;\n if (tone === \"neutral\") return \"\";\n return TEXT_TONE[tone];\n}\n\nconst ARROW = { up: ArrowUp, down: ArrowDown, flat: Minus } as const;\n\nexport interface SignedAmountProps extends SignedFormatProps, Omit<ComponentPropsWithRef<\"span\">, \"children\"> {\n value: number;\n /** See {@link SignedAmountTone}. Default `signed`, or `verdict` with `goodDirection`. */\n tone?: SignedAmountTone;\n /** Which way is good news — colours by verdict (`success` / `danger`, or the money\n * pair with `palette=\"money\"`). */\n goodDirection?: GoodDirection;\n /** See {@link VerdictPalette}. Default `status`. Only a verdict reads it. */\n palette?: VerdictPalette;\n /** A magnitude up to which the figure counts as NO change: no sign, no arrow but the\n * flat dash, muted, spoken without \"plus\"/\"minus\" (inclusive; default 0). The digits\n * still print `|value|` — use a band below the display precision, where they round\n * to zero anyway (`flatWithin={0.005}` at two digits). */\n flatWithin?: number;\n /** Print \"+\" before a positive figure (default `true`). A negative always shows its\n * minus; zero shows neither. */\n showPlus?: boolean;\n /** An arrow before the figure (up / down / a dash at zero) — so the direction does not\n * ride on colour alone. Decorative; the words say the same. */\n arrow?: boolean;\n /** Tag the figure `data-private`, for the host's demo-mode blur. */\n sensitive?: boolean;\n labels?: LabelOverride<SignedAmountLabels>;\n}\n\n/**\n * A figure with a sign that matters: a balance, a rent change, a net.\n *\n * kastlan writes it by hand in five places — `{change > 0 ? \"+\" : \"\"}{formatCurrency(\n * change)}` in a span coloured by a ternary (lease-columns:190, settlement-table:58,\n * the tenancy `formatPct`) — and each picks its own colours for the same verdict.\n *\n * The visible figure (sign, digits, arrow) is hidden from assistive tech and spoken as\n * words instead (\"plus CHF 50.00\" / \"minus CHF 50.00\", `signedAmount.*`): a \"+\" is\n * skipped by most screen readers, and `Intl`'s \"−\" is read as \"dash\" or not at all.\n */\nexport function SignedAmount({\n value,\n currency,\n unit,\n ratio,\n compact,\n digits,\n format,\n locale,\n tone = \"signed\",\n goodDirection,\n palette = \"status\",\n flatWithin,\n showPlus = true,\n arrow = false,\n sensitive = false,\n labels,\n className,\n ...rest\n}: SignedAmountProps) {\n const text = useKitLabels(\"signedAmount\", DEFAULT_SIGNED_AMOUNT_LABELS, labels);\n const fmt = useMagnitudeFormatter({ currency, unit, ratio, compact, digits, format, locale });\n const finite = Number.isFinite(value);\n const dir = finite ? directionOf(value, flatWithin) : \"flat\";\n const amount = finite ? fmt(Math.abs(value)) : \"—\";\n // U+2212, the typographic minus: the same width as \"+\", so a column of signed figures\n // lines up under `tabular-nums`.\n const sign = dir === \"up\" ? (showPlus ? \"+\" : \"\") : dir === \"down\" ? \"−\" : \"\";\n const spoken = dir === \"up\" ? text.positive(amount) : dir === \"down\" ? text.negative(amount) : amount;\n const Icon = ARROW[dir];\n return (\n <span\n {...rest}\n data-private={sensitive ? \"\" : undefined}\n data-direction={dir}\n className={cn(\n \"relative inline-flex items-center gap-0.5 whitespace-nowrap tabular-nums\",\n signedToneClass(tone, dir, goodDirection, palette),\n className,\n )}\n >\n {arrow && <Icon aria-hidden className=\"size-[1em] shrink-0\" />}\n <span aria-hidden>\n {sign}\n {amount}\n </span>\n <span className=\"sr-only\">{spoken}</span>\n </span>\n );\n}\n\nexport interface DeltaProps extends SignedFormatProps, Omit<ComponentPropsWithRef<\"span\">, \"children\"> {\n /** The change. Above zero is \"up\". */\n value: number;\n /** Which way is good news. Unset, the change is stated and not judged (muted); set,\n * it is coloured `success` / `danger` and its sentence says \"(better)\" / \"(worse)\". */\n goodDirection?: GoodDirection;\n /** See {@link VerdictPalette}: `money` paints good news `income` and bad news\n * `expense` instead of `success` / `danger`. Default `status`. */\n palette?: VerdictPalette;\n /** See {@link SignedAmountProps.flatWithin}: up to this magnitude the change is\n * \"unchanged\" — flat dash, muted, no verdict. Default 0. */\n flatWithin?: number;\n /** What it is measured against, after it: \"vs last month\". */\n label?: ReactNode;\n /** Hide the arrow (shown by default, as on a StatTile). At zero the arrow is a flat\n * dash BESIDE the figure (\"– 0.00 %\"), never in place of it. */\n arrow?: boolean;\n sensitive?: boolean;\n /** The `statTile` namespace's direction words — a delta says the same as a tile's. */\n labels?: LabelOverride<Pick<StatTileLabels, \"increase\" | \"decrease\" | \"unchanged\" | \"better\" | \"worse\">>;\n}\n\n/**\n * `StatTile`'s delta on its own: an arrow, the unsigned magnitude, and a sentence for\n * screen readers (\"Up 12% (worse)\"), coloured only when `goodDirection` judges it —\n * users up and cost up are the same arrow until someone says which is good.\n *\n * For a change shown outside a tile: kastlan's rent-change column\n * (lease-columns:219, a \"+1.25%\" chip), the breakdown rows of the rent calculator\n * (breakdown-row:5, a trend icon coloured by hand).\n */\nexport function Delta({\n value,\n currency,\n unit,\n ratio,\n compact,\n digits,\n format,\n locale,\n goodDirection,\n palette = \"status\",\n flatWithin,\n label,\n arrow = true,\n sensitive = false,\n labels,\n className,\n ...rest\n}: DeltaProps) {\n const text = useKitLabels(\"statTile\", DEFAULT_STAT_TILE_LABELS, labels);\n const fmt = useMagnitudeFormatter({ currency, unit, ratio, compact, digits, format, locale });\n if (!Number.isFinite(value)) return null;\n const amount = fmt(Math.abs(value));\n const dir = directionOf(value, flatWithin);\n const Icon = ARROW[dir];\n let spoken = dir === \"up\" ? text.increase(amount) : dir === \"down\" ? text.decrease(amount) : text.unchanged;\n let tone = TEXT_TONE.muted;\n if (goodDirection && dir !== \"flat\") {\n const good = dir === goodDirection;\n spoken = good ? text.better(spoken) : text.worse(spoken);\n tone = verdictClass(good, palette);\n }\n return (\n <span\n {...rest}\n data-direction={dir}\n className={cn(\"relative inline-flex flex-wrap items-center gap-x-1.5 tabular-nums\", className)}\n >\n <span\n data-private={sensitive ? \"\" : undefined}\n className={cn(\"inline-flex items-center gap-0.5 font-medium\", tone)}\n >\n {arrow && <Icon className=\"size-[1em] shrink-0\" aria-hidden />}\n {/* The figure at zero too, beside the flat dash (kastlan feedback #48). Before\n this a flat delta with an arrow drew the dash ALONE, as a StatTile does — so\n a rent-change column that printed \"0.00 %\" for an unchanged lease showed a\n bare \"–\" in its place, and a bare dash is what a table prints for a MISSING\n value: \"unchanged\" and \"not known\" looked the same. The Minus icon is the\n neutral indicator, the muted tone the neutral colour, and the figure says\n how much (none) in the column's own digits. A value that is missing never\n reaches here — a non-finite one renders nothing, above. Visible change for\n every `<Delta value={0}>` with the default arrow: \"–\" became \"– 0 %\". */}\n <span aria-hidden>{amount}</span>\n <span className=\"sr-only\">{spoken}</span>\n </span>\n {label != null && <span className=\"text-muted\">{label}</span>}\n </span>\n );\n}\n"],"mappings":";AAoDS,cAyLH,YAzLG;AAnDT,SAAS,WAAW,SAAS,aAAa;AAC1C,SAAS,UAAU;AACnB,SAAS,aAAa,cAAc,qBAAqB;AACzD,SAAS,cAAc,oBAAwC;AAC/D,SAAS,gCAAgC;AAEzC,SAAS,oCAAoC;AAiB7C,MAAM,YAAsC;AAAA,EAC1C,SAAS;AAAA,EACT,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,KAAK;AAAA,EACL,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AACR;AAOO,SAAS,cAAc,MAAwB;AACpD,SAAO,UAAU,IAAI;AACvB;AAOO,SAAS,KAAK,EAAE,MAAM,WAAW,GAAG,KAAK,GAAc;AAC5D,SAAO,oBAAC,UAAM,GAAG,MAAM,WAAW,GAAG,UAAU,IAAI,GAAG,SAAS,GAAG;AACpE;AAkEA,SAAS,sBAAsB,EAAE,UAAU,MAAM,OAAO,SAAS,QAAQ,QAAQ,OAAO,GAAsB;AAC5G,QAAM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M,OAAO,SAAS,QAAQ,QAAQ,OAAO,CAAC;AAC5F,MAAI,CAAC,OAAO,SAAS,KAAK,EAAG,QAAO;AACpC,QAAM,SAAS,IAAI,KAAK,IAAI,KAAK,CAAC;AAClC,QAAM,MAAM,YAAY,OAAO,UAAU;AACzC,QAAM,OAAO,MAAM,GAAG;AACtB,MAAI,SAAS,QAAQ,OAAO,KAAK,SAAS,MAAM,IAAI,QAAQ,SAAS,KAAK,SAAS,MAAM,IAAI,KAAK;AAClG,MAAI,OAAO,UAAU;AACrB,MAAI,iBAAiB,QAAQ,QAAQ;AACnC,UAAM,OAAO,QAAQ;AACrB,aAAS,OAAO,KAAK,OAAO,MAAM,IAAI,KAAK,MAAM,MAAM;AACvD,WAAO,aAAa,MAAM,OAAO;AAAA,EACnC;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,kBAAgB;AAAA,MAChB,WAAW,GAAG,sEAAsE,SAAS;AAAA,MAE7F;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,gBAAc,YAAY,KAAK;AAAA,YAC/B,WAAW,GAAG,gDAAgD,IAAI;AAAA,YAEjE;AAAA,uBAAS,oBAAC,QAAK,WAAU,uBAAsB,eAAW,MAAC;AAAA,cAU5D,oBAAC,UAAK,eAAW,MAAE,kBAAO;AAAA,cAC1B,oBAAC,UAAK,WAAU,WAAW,kBAAO;AAAA;AAAA;AAAA,QACpC;AAAA,QACC,SAAS,QAAQ,oBAAC,UAAK,WAAU,cAAc,iBAAM;AAAA;AAAA;AAAA,EACxD;AAEJ;","names":[]}
|
|
@@ -19,24 +19,9 @@ function Skeleton({ label, ...props }) {
|
|
|
19
19
|
}
|
|
20
20
|
function SkeletonFill({ shape = "line", lines, className, ...rest }) {
|
|
21
21
|
if (shape === "line" && lines !== void 0 && lines > 1) {
|
|
22
|
-
return /* @__PURE__ */ jsx("div", { ...rest, "aria-hidden": true, className: cn("flex flex-col gap-2", className), "data-skeleton": "lines", children: Array.from({ length: lines }, (_, i) => /* @__PURE__ */ jsx(
|
|
23
|
-
"div",
|
|
24
|
-
{
|
|
25
|
-
className: cn(SKELETON_CLASS, SHAPE.line, i === lines - 1 && "w-2/3"),
|
|
26
|
-
"data-skeleton": "line"
|
|
27
|
-
},
|
|
28
|
-
i
|
|
29
|
-
)) });
|
|
22
|
+
return /* @__PURE__ */ jsx("div", { ...rest, "aria-hidden": true, className: cn("flex flex-col gap-2", className), "data-skeleton": "lines", children: Array.from({ length: lines }, (_, i) => /* @__PURE__ */ jsx("div", { className: cn(SKELETON_CLASS, SHAPE.line, i === lines - 1 && "w-2/3"), "data-skeleton": "line" }, i)) });
|
|
30
23
|
}
|
|
31
|
-
return /* @__PURE__ */ jsx(
|
|
32
|
-
"div",
|
|
33
|
-
{
|
|
34
|
-
...rest,
|
|
35
|
-
"aria-hidden": true,
|
|
36
|
-
"data-skeleton": shape,
|
|
37
|
-
className: cn(SKELETON_CLASS, SHAPE[shape], className)
|
|
38
|
-
}
|
|
39
|
-
);
|
|
24
|
+
return /* @__PURE__ */ jsx("div", { ...rest, "aria-hidden": true, "data-skeleton": shape, className: cn(SKELETON_CLASS, SHAPE[shape], className) });
|
|
40
25
|
}
|
|
41
26
|
export {
|
|
42
27
|
SKELETON_CLASS,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/skeleton.tsx"],"sourcesContent":["import type { ComponentPropsWithRef } from \"react\";\nimport { cn } from \"../lib/cn\";\n\n/**\n * The look of a placeholder, as one class string — the same fill and pulse\n * `StatTile`'s `loading` headline draws (it imports this), so a tile and the list\n * beside it shimmer as one surface.\n *\n * `motion-reduce:animate-none`: a pulse is motion with no information in it, which\n * is exactly what `prefers-reduced-motion` asks to be dropped. The fill stays, so the\n * shape of what is coming is still there.\n */\nexport const SKELETON_CLASS = \"animate-pulse rounded bg-active motion-reduce:animate-none\";\n\nexport type SkeletonShape = \"line\" | \"block\" | \"circle\";\n\n/**\n * A `div`'s props, `ref` included (0.33.1, keksdose): they were spread onto the\n * placeholder all along, but `ComponentPropsWithoutRef` kept `ref` out of the type, so an\n * app could not hold the element (to measure it, or scroll it into view) without a\n * wrapper. The ref is the placeholder's — with `lines`, the box round the lines; with\n * `label`, still the placeholder, not the `role=\"status\"` region round it — where\n * `className` goes too.\n */\nexport interface SkeletonProps extends Omit<ComponentPropsWithRef<\"div\">, \"children\"> {\n /** `line` (default): a bar the height of a line of small text. `block`: an area\n * (an image, a chart, a card body). `circle`: an avatar. Size any of them with\n * `className` (`w-32`, `h-40`, `size-8`). */\n shape?: SkeletonShape;\n /** For `line`: this many lines, the last one shorter — a paragraph's outline. */\n lines?: number;\n /**\n * Say what is loading, once: wraps the placeholder in a `role=\"status\"` region with\n * this as its (visually hidden) text — kastlan's activity feed (activity-feed:52)\n * built exactly that by hand around `<Skeleton lines={5} />`. The placeholder itself\n * stays hidden. Left out, nothing is announced, as before.\n */\n label?: string;\n}\n\nconst SHAPE: Record<SkeletonShape, string> = {\n line: \"h-3 w-full\",\n block: \"h-24 w-full rounded-md\",\n circle: \"size-10 rounded-full\",\n};\n\n/**\n * A grey stand-in for content that is on its way.\n *\n * keksdose and kastlan both drew these by hand — `animate-pulse bg-slate-200` in one\n * place, a token in the next, a pulse that ran under reduced motion everywhere.\n *\n * ALWAYS `aria-hidden`. A placeholder is not content, and a reader that met twelve\n * unnamed grey boxes would have learned nothing. Say \"loading\" once, where it\n * belongs: `aria-busy` on the region being filled, a `Spinner` / sr-only line\n * beside the skeletons, or this component's own `label`.\n */\nexport function Skeleton({ label, ...props }: SkeletonProps) {\n if (!label) return <SkeletonFill {...props} />;\n return (\n // `relative`: the containing block for the sr-only text (sr-only-containment.test).\n <div role=\"status\" className=\"relative\" data-skeleton-status=\"\">\n <span className=\"sr-only\">{label}</span>\n <SkeletonFill {...props} />\n </div>\n );\n}\n\nfunction SkeletonFill({ shape = \"line\", lines, className, ...rest }: Omit<SkeletonProps, \"label\">) {\n if (shape === \"line\" && lines !== undefined && lines > 1) {\n return (\n <div {...rest} aria-hidden className={cn(\"flex flex-col gap-2\", className)} data-skeleton=\"lines\">\n {Array.from({ length: lines }, (_, i) => (\n <div
|
|
1
|
+
{"version":3,"sources":["../../src/components/skeleton.tsx"],"sourcesContent":["import type { ComponentPropsWithRef } from \"react\";\nimport { cn } from \"../lib/cn\";\n\n/**\n * The look of a placeholder, as one class string — the same fill and pulse\n * `StatTile`'s `loading` headline draws (it imports this), so a tile and the list\n * beside it shimmer as one surface.\n *\n * `motion-reduce:animate-none`: a pulse is motion with no information in it, which\n * is exactly what `prefers-reduced-motion` asks to be dropped. The fill stays, so the\n * shape of what is coming is still there.\n */\nexport const SKELETON_CLASS = \"animate-pulse rounded bg-active motion-reduce:animate-none\";\n\nexport type SkeletonShape = \"line\" | \"block\" | \"circle\";\n\n/**\n * A `div`'s props, `ref` included (0.33.1, keksdose): they were spread onto the\n * placeholder all along, but `ComponentPropsWithoutRef` kept `ref` out of the type, so an\n * app could not hold the element (to measure it, or scroll it into view) without a\n * wrapper. The ref is the placeholder's — with `lines`, the box round the lines; with\n * `label`, still the placeholder, not the `role=\"status\"` region round it — where\n * `className` goes too.\n */\nexport interface SkeletonProps extends Omit<ComponentPropsWithRef<\"div\">, \"children\"> {\n /** `line` (default): a bar the height of a line of small text. `block`: an area\n * (an image, a chart, a card body). `circle`: an avatar. Size any of them with\n * `className` (`w-32`, `h-40`, `size-8`). */\n shape?: SkeletonShape;\n /** For `line`: this many lines, the last one shorter — a paragraph's outline. */\n lines?: number;\n /**\n * Say what is loading, once: wraps the placeholder in a `role=\"status\"` region with\n * this as its (visually hidden) text — kastlan's activity feed (activity-feed:52)\n * built exactly that by hand around `<Skeleton lines={5} />`. The placeholder itself\n * stays hidden. Left out, nothing is announced, as before.\n */\n label?: string;\n}\n\nconst SHAPE: Record<SkeletonShape, string> = {\n line: \"h-3 w-full\",\n block: \"h-24 w-full rounded-md\",\n circle: \"size-10 rounded-full\",\n};\n\n/**\n * A grey stand-in for content that is on its way.\n *\n * keksdose and kastlan both drew these by hand — `animate-pulse bg-slate-200` in one\n * place, a token in the next, a pulse that ran under reduced motion everywhere.\n *\n * ALWAYS `aria-hidden`. A placeholder is not content, and a reader that met twelve\n * unnamed grey boxes would have learned nothing. Say \"loading\" once, where it\n * belongs: `aria-busy` on the region being filled, a `Spinner` / sr-only line\n * beside the skeletons, or this component's own `label`.\n */\nexport function Skeleton({ label, ...props }: SkeletonProps) {\n if (!label) return <SkeletonFill {...props} />;\n return (\n // `relative`: the containing block for the sr-only text (sr-only-containment.test).\n <div role=\"status\" className=\"relative\" data-skeleton-status=\"\">\n <span className=\"sr-only\">{label}</span>\n <SkeletonFill {...props} />\n </div>\n );\n}\n\nfunction SkeletonFill({ shape = \"line\", lines, className, ...rest }: Omit<SkeletonProps, \"label\">) {\n if (shape === \"line\" && lines !== undefined && lines > 1) {\n return (\n <div {...rest} aria-hidden className={cn(\"flex flex-col gap-2\", className)} data-skeleton=\"lines\">\n {Array.from({ length: lines }, (_, i) => (\n <div key={i} className={cn(SKELETON_CLASS, SHAPE.line, i === lines - 1 && \"w-2/3\")} data-skeleton=\"line\" />\n ))}\n </div>\n );\n }\n return <div {...rest} aria-hidden data-skeleton={shape} className={cn(SKELETON_CLASS, SHAPE[shape], className)} />;\n}\n"],"mappings":";AA0DqB,cAGjB,YAHiB;AAzDrB,SAAS,UAAU;AAWZ,MAAM,iBAAiB;AA4B9B,MAAM,QAAuC;AAAA,EAC3C,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AACV;AAaO,SAAS,SAAS,EAAE,OAAO,GAAG,MAAM,GAAkB;AAC3D,MAAI,CAAC,MAAO,QAAO,oBAAC,gBAAc,GAAG,OAAO;AAC5C;AAAA;AAAA,IAEE,qBAAC,SAAI,MAAK,UAAS,WAAU,YAAW,wBAAqB,IAC3D;AAAA,0BAAC,UAAK,WAAU,WAAW,iBAAM;AAAA,MACjC,oBAAC,gBAAc,GAAG,OAAO;AAAA,OAC3B;AAAA;AAEJ;AAEA,SAAS,aAAa,EAAE,QAAQ,QAAQ,OAAO,WAAW,GAAG,KAAK,GAAiC;AACjG,MAAI,UAAU,UAAU,UAAU,UAAa,QAAQ,GAAG;AACxD,WACE,oBAAC,SAAK,GAAG,MAAM,eAAW,MAAC,WAAW,GAAG,uBAAuB,SAAS,GAAG,iBAAc,SACvF,gBAAM,KAAK,EAAE,QAAQ,MAAM,GAAG,CAAC,GAAG,MACjC,oBAAC,SAAY,WAAW,GAAG,gBAAgB,MAAM,MAAM,MAAM,QAAQ,KAAK,OAAO,GAAG,iBAAc,UAAxF,CAA+F,CAC1G,GACH;AAAA,EAEJ;AACA,SAAO,oBAAC,SAAK,GAAG,MAAM,eAAW,MAAC,iBAAe,OAAO,WAAW,GAAG,gBAAgB,MAAM,KAAK,GAAG,SAAS,GAAG;AAClH;","names":[]}
|
|
@@ -97,25 +97,9 @@ function Slider({
|
|
|
97
97
|
// top of it at 390px (lenkbank L1). Each keeps its own width, so the readout
|
|
98
98
|
// drops to a line of its own, still at the end, only when the two don't fit.
|
|
99
99
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-0.5", children: [
|
|
100
|
-
label !== void 0 && /* @__PURE__ */ jsx(
|
|
101
|
-
"label",
|
|
102
|
-
{
|
|
103
|
-
htmlFor: inputId,
|
|
104
|
-
className: "min-w-0 select-none text-xs font-medium text-secondary",
|
|
105
|
-
children: label
|
|
106
|
-
}
|
|
107
|
-
),
|
|
100
|
+
label !== void 0 && /* @__PURE__ */ jsx("label", { htmlFor: inputId, className: "min-w-0 select-none text-xs font-medium text-secondary", children: label }),
|
|
108
101
|
labelHint !== void 0 && /* @__PURE__ */ jsx("span", { className: "flex shrink-0 items-center", children: labelHint }),
|
|
109
|
-
readout !== void 0 && /* @__PURE__ */ jsx(
|
|
110
|
-
"span",
|
|
111
|
-
{
|
|
112
|
-
className: cn(
|
|
113
|
-
"ms-auto max-w-full text-xs tabular-nums text-primary",
|
|
114
|
-
plainReadout && "select-none"
|
|
115
|
-
),
|
|
116
|
-
children: readout
|
|
117
|
-
}
|
|
118
|
-
)
|
|
102
|
+
readout !== void 0 && /* @__PURE__ */ jsx("span", { className: cn("ms-auto max-w-full text-xs tabular-nums text-primary", plainReadout && "select-none"), children: readout })
|
|
119
103
|
] }),
|
|
120
104
|
/* @__PURE__ */ jsx(
|
|
121
105
|
"input",
|
|
@@ -141,25 +125,18 @@ function Slider({
|
|
|
141
125
|
// `min`, not under the track's rounded end. Each tick is a zero-width column
|
|
142
126
|
// centred on its point, which centres its label on it in either direction
|
|
143
127
|
// without a `translate` that would need flipping for right-to-left.
|
|
144
|
-
/* @__PURE__ */ jsx(
|
|
145
|
-
"
|
|
128
|
+
/* @__PURE__ */ jsx("div", { "aria-hidden": true, className: cn("relative mx-2 -mt-1.5", MARKS_LARGE, hasMarkLabels ? "h-5" : "h-1.5"), children: normalizedMarks.map((m) => /* @__PURE__ */ jsxs(
|
|
129
|
+
"span",
|
|
146
130
|
{
|
|
147
|
-
"
|
|
148
|
-
|
|
149
|
-
children:
|
|
150
|
-
"span",
|
|
151
|
-
{
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
m.label !== void 0 && /* @__PURE__ */ jsx("span", { className: "mt-0.5 select-none whitespace-nowrap text-caption leading-tight text-muted", children: m.label })
|
|
157
|
-
]
|
|
158
|
-
},
|
|
159
|
-
m.value
|
|
160
|
-
))
|
|
161
|
-
}
|
|
162
|
-
),
|
|
131
|
+
className: "absolute top-0 flex w-0 flex-col items-center",
|
|
132
|
+
style: { insetInlineStart: `${share(position(m.value)) * 100}%` },
|
|
133
|
+
children: [
|
|
134
|
+
/* @__PURE__ */ jsx("span", { className: "h-1.5 w-px shrink-0 bg-[var(--border-strong)]" }),
|
|
135
|
+
m.label !== void 0 && /* @__PURE__ */ jsx("span", { className: "mt-0.5 select-none whitespace-nowrap text-caption leading-tight text-muted", children: m.label })
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
m.value
|
|
139
|
+
)) }),
|
|
163
140
|
messages.below
|
|
164
141
|
] });
|
|
165
142
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/slider.tsx"],"sourcesContent":["import { useId } from \"react\";\nimport type { CSSProperties, ChangeEvent, InputHTMLAttributes, ReactNode, Ref } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { useFieldMessages, type FieldHelpProps } from \"./field-parts\";\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-brand [&::-webkit-slider-thumb]:shadow\",\n \"focus-visible:[&::-webkit-slider-thumb]:ring-focus focus-visible:[&::-webkit-slider-thumb]:ring-brand\",\n \"focus-visible:[&::-webkit-slider-thumb]:ring-offset-2 focus-visible:[&::-webkit-slider-thumb]:ring-offset-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-brand\",\n \"[&::-moz-range-thumb]:size-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0\",\n \"[&::-moz-range-thumb]:bg-brand [&::-moz-range-thumb]:shadow\",\n \"focus-visible:[&::-moz-range-thumb]:ring-focus focus-visible:[&::-moz-range-thumb]:ring-brand\",\n \"focus-visible:[&::-moz-range-thumb]:ring-offset-2 focus-visible:[&::-moz-range-thumb]:ring-offset-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 FieldHelpProps {\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 *\n * {@link Select}'s rule since 0.34 (DUP-2, refactor audit 2026-10): plain TEXT is a\n * caption under the track, on the slider's `aria-describedby`, and so is a FieldHint\n * at Large and on a touch screen, where a \"?\" cannot be hovered open (§4) — the\n * Kurvenschmiede controller panel's Kp/Ki/Kd facts were a lone \"?\" on a phone. A\n * `HelpPopover` stays beside the label at every size. */\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 /** The `<input type=\"range\">`. A React 19 ref prop since 0.34 (MOD-4, refactor audit\n * 2026-10); it was `forwardRef`. */\n ref?: Ref<HTMLInputElement>;\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 function Slider({\n ref,\n value,\n onChange,\n min,\n max,\n step,\n scale = \"linear\",\n zeroStop = true,\n formatValue,\n label,\n hint,\n help,\n readout,\n marks,\n className,\n inputClassName,\n id,\n disabled,\n style,\n ...rest\n}: SliderProps) {\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 // The label line's \"?\", or the caption under the track (DUP-2).\n const messages = useFieldMessages({\n hint,\n help,\n name: label ?? rest[\"aria-label\"],\n describedBy: rest[\"aria-describedby\"],\n });\n const labelHint = messages.labelHint;\n const hasHeader = label !== undefined || labelHint !== 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-secondary\"\n >\n {label}\n </label>\n )}\n {labelHint !== undefined && <span className=\"flex shrink-0 items-center\">{labelHint}</span>}\n {readout !== undefined && (\n <span\n className={cn(\n \"ms-auto max-w-full text-xs tabular-nums 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 aria-describedby={messages.describedBy}\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-muted\">\n {m.label}\n </span>\n )}\n </span>\n ))}\n </div>\n )}\n {messages.below}\n </div>\n );\n}\n"],"mappings":";AAwRQ,SAEI,KAFJ;AAxRR,SAAS,aAAa;AAEtB,SAAS,UAAU;AACnB,SAAS,wBAA6C;AA4BtD,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;AA8BA,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;AAAA,EACA;AACF,EAAE,KAAK,GAAG;AAKV,MAAM,cAAc;AAkFb,SAAS,OAAO;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,WAAW;AAAA,EACX;AAAA,EACA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AAC,MACpB;AAAA,UAAC;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,8EACb,YAAE,OACL;AAAA;AAAA;AAAA,UARG,EAAE;AAAA,QAUT,CACD;AAAA;AAAA,IACH;AAAA,IAED,SAAS;AAAA,KACZ;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/slider.tsx"],"sourcesContent":["import { useId } from \"react\";\nimport type { CSSProperties, ChangeEvent, InputHTMLAttributes, ReactNode, Ref } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { useFieldMessages, type FieldHelpProps } from \"./field-parts\";\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-brand [&::-webkit-slider-thumb]:shadow\",\n \"focus-visible:[&::-webkit-slider-thumb]:ring-focus focus-visible:[&::-webkit-slider-thumb]:ring-brand\",\n \"focus-visible:[&::-webkit-slider-thumb]:ring-offset-2 focus-visible:[&::-webkit-slider-thumb]:ring-offset-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-brand\",\n \"[&::-moz-range-thumb]:size-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0\",\n \"[&::-moz-range-thumb]:bg-brand [&::-moz-range-thumb]:shadow\",\n \"focus-visible:[&::-moz-range-thumb]:ring-focus focus-visible:[&::-moz-range-thumb]:ring-brand\",\n \"focus-visible:[&::-moz-range-thumb]:ring-offset-2 focus-visible:[&::-moz-range-thumb]:ring-offset-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\n Omit<\n InputHTMLAttributes<HTMLInputElement>,\n \"type\" | \"value\" | \"defaultValue\" | \"onChange\" | \"min\" | \"max\" | \"step\" | \"children\"\n >,\n FieldHelpProps {\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 *\n * {@link Select}'s rule since 0.34 (DUP-2, refactor audit 2026-10): plain TEXT is a\n * caption under the track, on the slider's `aria-describedby`, and so is a FieldHint\n * at Large and on a touch screen, where a \"?\" cannot be hovered open (§4) — the\n * Kurvenschmiede controller panel's Kp/Ki/Kd facts were a lone \"?\" on a phone. A\n * `HelpPopover` stays beside the label at every size. */\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 /** The `<input type=\"range\">`. A React 19 ref prop since 0.34 (MOD-4, refactor audit\n * 2026-10); it was `forwardRef`. */\n ref?: Ref<HTMLInputElement>;\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 function Slider({\n ref,\n value,\n onChange,\n min,\n max,\n step,\n scale = \"linear\",\n zeroStop = true,\n formatValue,\n label,\n hint,\n help,\n readout,\n marks,\n className,\n inputClassName,\n id,\n disabled,\n style,\n ...rest\n}: SliderProps) {\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\"] ?? (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 // The label line's \"?\", or the caption under the track (DUP-2).\n const messages = useFieldMessages({\n hint,\n help,\n name: label ?? rest[\"aria-label\"],\n describedBy: rest[\"aria-describedby\"],\n });\n const labelHint = messages.labelHint;\n const hasHeader = label !== undefined || labelHint !== 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 htmlFor={inputId} className=\"min-w-0 select-none text-xs font-medium text-secondary\">\n {label}\n </label>\n )}\n {labelHint !== undefined && <span className=\"flex shrink-0 items-center\">{labelHint}</span>}\n {readout !== undefined && (\n <span className={cn(\"ms-auto max-w-full text-xs tabular-nums text-primary\", plainReadout && \"select-none\")}>\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 aria-describedby={messages.describedBy}\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 aria-hidden className={cn(\"relative mx-2 -mt-1.5\", MARKS_LARGE, hasMarkLabels ? \"h-5\" : \"h-1.5\")}>\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-muted\">\n {m.label}\n </span>\n )}\n </span>\n ))}\n </div>\n )}\n {messages.below}\n </div>\n );\n}\n"],"mappings":";AAwRQ,SAEI,KAFJ;AAxRR,SAAS,aAAa;AAEtB,SAAS,UAAU;AACnB,SAAS,wBAA6C;AA4BtD,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;AA8BA,MAAM,QAAQ;AAAA,EACZ;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAA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AAAA;AAAA,IAMxB,oBAAC,SAAI,eAAW,MAAC,WAAW,GAAG,yBAAyB,aAAa,gBAAgB,QAAQ,OAAO,GACjG,0BAAgB,IAAI,CAAC,MACpB;AAAA,MAAC;AAAA;AAAA,QAEC,WAAU;AAAA,QACV,OAAO,EAAE,kBAAkB,GAAG,MAAM,SAAS,EAAE,KAAK,CAAC,IAAI,GAAG,IAAI;AAAA,QAEhE;AAAA,8BAAC,UAAK,WAAU,iDAAgD;AAAA,UAC/D,EAAE,UAAU,UACX,oBAAC,UAAK,WAAU,8EACb,YAAE,OACL;AAAA;AAAA;AAAA,MARG,EAAE;AAAA,IAUT,CACD,GACH;AAAA,IAED,SAAS;AAAA,KACZ;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/sparkline.tsx"],"sourcesContent":["import type { ComponentPropsWithRef } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels, useKitLocale, type LabelOverride } from \"../i18n/kit-labels\";\nimport { useTextSize } from \"../theme/text-size\";\nimport { DEFAULT_SPARKLINE_LABELS } from \"./sparkline-labels\";\nimport { formatWithMinus } from \"../lib/minus\";\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\n// Defined in ./sparkline-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_SPARKLINE_LABELS };\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-brand\",\n muted: \"text-muted\",\n income: \"text-money-income\",\n expense: \"text-money-expense\",\n net: \"text-money-net\",\n success: \"text-success\",\n warning: \"text-warning\",\n danger: \"text-danger\",\n info: \"text-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<ComponentPropsWithRef<\"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?: LabelOverride<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) => formatWithMinus(f, 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}\n strokeWidth={dot * 2 - 1}\n className={lineClass}\n data-sparkline-last=\"\"\n />\n )}\n </svg>\n );\n}\n"],"mappings":";AA0QQ,cAyCM,YAzCN;AAzQR,SAAS,UAAU;AACnB,SAAS,cAAc,oBAAwC;AAC/D,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AACzC,SAAS,uBAAuB;AAkDhC,MAAM,aAA+D;AAAA,EACnE,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OA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C9B,GAAG;AAAA,cACJ,aAAa,cAAc;AAAA,cAC3B,WAAW;AAAA;AAAA,YAJN;AAAA,UAKP,IAEA,qBAAC,OAAU,WAAW,WACnB;AAAA,wBAAY,UACX;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 { ComponentPropsWithRef } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels, useKitLocale, type LabelOverride } from \"../i18n/kit-labels\";\nimport { useTextSize } from \"../theme/text-size\";\nimport { DEFAULT_SPARKLINE_LABELS } from \"./sparkline-labels\";\nimport { formatWithMinus } from \"../lib/minus\";\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\n// Defined in ./sparkline-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_SPARKLINE_LABELS };\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\" | \"brand\" | \"muted\" | \"income\" | \"expense\" | \"net\" | \"signed\" | \"success\" | \"warning\" | \"danger\" | \"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-brand\",\n muted: \"text-muted\",\n income: \"text-money-income\",\n expense: \"text-money-expense\",\n net: \"text-money-net\",\n success: \"text-success\",\n warning: \"text-warning\",\n danger: \"text-danger\",\n info: \"text-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 extends Omit<ComponentPropsWithRef<\"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?: LabelOverride<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) => formatWithMinus(f, 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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ACnD,WAAW,SAAS,WAAW,YAAY,CAAC,IAAI,WAAW,IAAI;AAAA;AAAA,cAP1D;AAAA,YAQP;AAAA,UAEJ,CAAC;AAAA,QACH,GAAG,IACH,KAAK;AAAA,UAAI,CAAC,KAAK,MACb,IAAI,WAAW,IACb;AAAA,YAAC;AAAA;AAAA,cAEC,GAAG,QAAQ,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;AAAA,cAC9B,GAAG;AAAA,cACJ,aAAa,cAAc;AAAA,cAC3B,WAAW;AAAA;AAAA,YAJN;AAAA,UAKP,IAEA,qBAAC,OAAU,WAAW,WACnB;AAAA,wBAAY,UACX;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":[]}
|
|
@@ -147,19 +147,23 @@ function StatTile({
|
|
|
147
147
|
deltaNode = // `relative`: the containing block for the sr-only sentence (see the
|
|
148
148
|
// sr-only-containment test for what an escaped one does to the page).
|
|
149
149
|
/* @__PURE__ */ jsxs("div", { className: "relative mt-1 flex flex-wrap items-center gap-x-1.5 text-xs tabular-nums", children: [
|
|
150
|
-
/* @__PURE__ */ jsxs(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
150
|
+
/* @__PURE__ */ jsxs(
|
|
151
|
+
"span",
|
|
152
|
+
{
|
|
153
|
+
id: deltaId,
|
|
154
|
+
"data-private": priv,
|
|
155
|
+
className: cn("inline-flex items-center gap-0.5 font-medium", deltaTone),
|
|
156
|
+
children: [
|
|
157
|
+
/* @__PURE__ */ jsx(Icon, { className: "size-3 shrink-0", "aria-hidden": true }),
|
|
158
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, children: amount }),
|
|
159
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: spoken })
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
),
|
|
155
163
|
d.label != null && /* @__PURE__ */ jsx("span", { className: "text-muted", children: d.label })
|
|
156
164
|
] });
|
|
157
165
|
}
|
|
158
|
-
const valueClass = cn(
|
|
159
|
-
"whitespace-nowrap font-semibold tabular-nums",
|
|
160
|
-
VALUE_TEXT[size],
|
|
161
|
-
toneClass(tone, value)
|
|
162
|
-
);
|
|
166
|
+
const valueClass = cn("whitespace-nowrap font-semibold tabular-nums", VALUE_TEXT[size], toneClass(tone, value));
|
|
163
167
|
const headline = loading ? /* @__PURE__ */ jsxs("span", { id: valueId, className: "relative block py-0.5", children: [
|
|
164
168
|
/* @__PURE__ */ jsx("span", { "aria-hidden": true, className: cn(SKELETON_CLASS, "block h-6 w-24 max-w-full") }),
|
|
165
169
|
!gridLoading && /* @__PURE__ */ jsx("span", { className: "sr-only", children: text.loading })
|