@eifi1/ui-kit 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +32 -0
- package/README.md +498 -57
- package/dist/chart.d.ts +10 -0
- package/dist/chart.js +10 -0
- package/dist/chart.js.map +1 -0
- package/dist/components/account-settings.d.ts +11 -0
- package/dist/components/account-settings.js +19 -12
- package/dist/components/account-settings.js.map +1 -1
- package/dist/components/alert-banner.d.ts +10 -6
- package/dist/components/alert-banner.js +20 -16
- package/dist/components/alert-banner.js.map +1 -1
- package/dist/components/amount-input.d.ts +30 -4
- package/dist/components/amount-input.js +36 -14
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/calculator.d.ts +24 -7
- package/dist/components/calculator.js +37 -20
- package/dist/components/calculator.js.map +1 -1
- package/dist/components/chart-zoom.d.ts +156 -0
- package/dist/components/chart-zoom.js +262 -0
- package/dist/components/chart-zoom.js.map +1 -0
- package/dist/components/chart.d.ts +28 -3
- package/dist/components/chart.js +71 -32
- package/dist/components/chart.js.map +1 -1
- package/dist/components/checkbox.d.ts +51 -0
- package/dist/components/checkbox.js +123 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/chip.d.ts +128 -0
- package/dist/components/chip.js +357 -0
- package/dist/components/chip.js.map +1 -0
- package/dist/components/choice-parts.d.ts +24 -0
- package/dist/components/choice-parts.js +18 -0
- package/dist/components/choice-parts.js.map +1 -0
- package/dist/components/combobox-core.d.ts +52 -9
- package/dist/components/combobox-core.js +91 -20
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox.d.ts +43 -33
- package/dist/components/combobox.js +409 -340
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/currency-select.d.ts +48 -8
- package/dist/components/currency-select.js +107 -65
- package/dist/components/currency-select.js.map +1 -1
- package/dist/components/data-table-filter-popover.d.ts +15 -3
- package/dist/components/data-table-filter-popover.js +23 -17
- package/dist/components/data-table-filter-popover.js.map +1 -1
- package/dist/components/data-table-filters.d.ts +1 -1
- package/dist/components/data-table-filters.js +3 -2
- package/dist/components/data-table-filters.js.map +1 -1
- package/dist/components/data-table-labels.d.ts +53 -2
- package/dist/components/data-table-labels.js +31 -2
- package/dist/components/data-table-labels.js.map +1 -1
- package/dist/components/data-table-pagination.d.ts +3 -1
- package/dist/components/data-table-pagination.js +16 -10
- package/dist/components/data-table-pagination.js.map +1 -1
- package/dist/components/data-table-sort.js +1 -0
- package/dist/components/data-table-sort.js.map +1 -1
- package/dist/components/data-table.d.ts +1 -1
- package/dist/components/data-table.js +201 -85
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.d.ts +25 -9
- package/dist/components/date-picker.js +232 -94
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/dropdown.d.ts +96 -20
- package/dist/components/dropdown.js +77 -33
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/entity-combobox.d.ts +5 -4
- package/dist/components/entity-combobox.js +107 -76
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/facing-pair.d.ts +36 -0
- package/dist/components/facing-pair.js +40 -0
- package/dist/components/facing-pair.js.map +1 -0
- package/dist/components/field-sync.d.ts +164 -0
- package/dist/components/field-sync.js +264 -0
- package/dist/components/field-sync.js.map +1 -0
- package/dist/components/file-dropzone.d.ts +38 -6
- package/dist/components/file-dropzone.js +34 -9
- package/dist/components/file-dropzone.js.map +1 -1
- package/dist/components/full-bleed-dialog.d.ts +37 -26
- package/dist/components/full-bleed-dialog.js +20 -5
- package/dist/components/full-bleed-dialog.js.map +1 -1
- package/dist/components/grouped-picker.d.ts +21 -10
- package/dist/components/grouped-picker.js +66 -52
- package/dist/components/grouped-picker.js.map +1 -1
- package/dist/components/hover-menu.d.ts +20 -4
- package/dist/components/hover-menu.js +15 -4
- package/dist/components/hover-menu.js.map +1 -1
- package/dist/components/mini-calendar.d.ts +102 -14
- package/dist/components/mini-calendar.js +256 -70
- package/dist/components/mini-calendar.js.map +1 -1
- package/dist/components/modal.d.ts +9 -3
- package/dist/components/modal.js +34 -45
- package/dist/components/modal.js.map +1 -1
- package/dist/components/month-picker.d.ts +79 -0
- package/dist/components/month-picker.js +342 -0
- package/dist/components/month-picker.js.map +1 -0
- package/dist/components/multi-entity-combobox.d.ts +7 -6
- package/dist/components/multi-entity-combobox.js +112 -72
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/multi-select.d.ts +13 -11
- package/dist/components/multi-select.js +161 -84
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/number-field.d.ts +92 -0
- package/dist/components/number-field.js +111 -0
- package/dist/components/number-field.js.map +1 -0
- package/dist/components/number-input.d.ts +28 -2
- package/dist/components/number-input.js +12 -2
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/numpad-sheet.d.ts +32 -4
- package/dist/components/numpad-sheet.js +30 -13
- package/dist/components/numpad-sheet.js.map +1 -1
- package/dist/components/page-contents.d.ts +90 -0
- package/dist/components/page-contents.js +170 -0
- package/dist/components/page-contents.js.map +1 -0
- package/dist/components/password-strength.d.ts +106 -0
- package/dist/components/password-strength.js +132 -0
- package/dist/components/password-strength.js.map +1 -0
- package/dist/components/picker-sheet.d.ts +23 -15
- package/dist/components/picker-sheet.js +34 -14
- package/dist/components/picker-sheet.js.map +1 -1
- package/dist/components/popover.d.ts +62 -4
- package/dist/components/popover.js +52 -2
- package/dist/components/popover.js.map +1 -1
- package/dist/components/search-field.d.ts +25 -7
- package/dist/components/search-field.js +7 -5
- package/dist/components/search-field.js.map +1 -1
- package/dist/components/series-chart-labels.d.ts +14 -0
- package/dist/components/series-chart-labels.js +11 -0
- package/dist/components/series-chart-labels.js.map +1 -0
- package/dist/components/series-chart.d.ts +207 -0
- package/dist/components/series-chart.js +223 -0
- package/dist/components/series-chart.js.map +1 -0
- package/dist/components/settings-fields.d.ts +14 -4
- package/dist/components/settings-fields.js +19 -8
- package/dist/components/settings-fields.js.map +1 -1
- package/dist/components/signature-pad.d.ts +119 -0
- package/dist/components/signature-pad.js +405 -0
- package/dist/components/signature-pad.js.map +1 -0
- package/dist/components/slider.d.ts +80 -0
- package/dist/components/slider.js +155 -0
- package/dist/components/slider.js.map +1 -0
- package/dist/components/sparkline.d.ts +93 -0
- package/dist/components/sparkline.js +205 -0
- package/dist/components/sparkline.js.map +1 -0
- package/dist/components/stat-tile.d.ts +151 -0
- package/dist/components/stat-tile.js +236 -0
- package/dist/components/stat-tile.js.map +1 -0
- package/dist/components/swipeable-row.d.ts +25 -2
- package/dist/components/swipeable-row.js +31 -0
- package/dist/components/swipeable-row.js.map +1 -1
- package/dist/components/switch.d.ts +60 -0
- package/dist/components/switch.js +81 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/time-input.d.ts +58 -0
- package/dist/components/time-input.js +50 -0
- package/dist/components/time-input.js.map +1 -0
- package/dist/components/toggle-group.d.ts +18 -3
- package/dist/components/toggle-group.js +10 -6
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/toggle-legend.d.ts +115 -0
- package/dist/components/toggle-legend.js +114 -0
- package/dist/components/toggle-legend.js.map +1 -0
- package/dist/components/tooltip.d.ts +40 -11
- package/dist/components/tooltip.js +77 -20
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/treemap.d.ts +132 -0
- package/dist/components/treemap.js +179 -0
- package/dist/components/treemap.js.map +1 -0
- package/dist/components/ui.d.ts +159 -46
- package/dist/components/ui.js +220 -115
- package/dist/components/ui.js.map +1 -1
- package/dist/components/use-mobile-reveal.js +1 -0
- package/dist/components/use-mobile-reveal.js.map +1 -1
- package/dist/components/use-table-state.d.ts +1 -1
- package/dist/components/use-table-state.js +38 -17
- package/dist/components/use-table-state.js.map +1 -1
- package/dist/components/user-avatar.d.ts +15 -4
- package/dist/components/user-avatar.js +5 -4
- package/dist/components/user-avatar.js.map +1 -1
- package/dist/components/wizard-stepper.js +3 -2
- package/dist/components/wizard-stepper.js.map +1 -1
- package/dist/{data-table-filters-aXyf0Xub.d.ts → data-table-filters-DM1auUfH.d.ts} +27 -5
- package/dist/data-table.d.ts +7 -0
- package/dist/data-table.js +12 -0
- package/dist/data-table.js.map +1 -0
- package/dist/feedback/feedback-attachment.js +12 -11
- package/dist/feedback/feedback-attachment.js.map +1 -1
- package/dist/feedback/feedback-dialog.js +2 -1
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-inbox.d.ts +33 -7
- package/dist/feedback/feedback-inbox.js +49 -37
- package/dist/feedback/feedback-inbox.js.map +1 -1
- package/dist/feedback.d.ts +5 -0
- package/dist/feedback.js +5 -0
- package/dist/feedback.js.map +1 -0
- package/dist/hooks/use-anchored-panel.js +1 -0
- package/dist/hooks/use-anchored-panel.js.map +1 -1
- package/dist/hooks/use-anchored-rect.js +1 -0
- package/dist/hooks/use-anchored-rect.js.map +1 -1
- package/dist/hooks/use-announce.d.ts +46 -0
- package/dist/hooks/use-announce.js +37 -0
- package/dist/hooks/use-announce.js.map +1 -0
- package/dist/hooks/use-body-scroll-lock.js +1 -0
- package/dist/hooks/use-body-scroll-lock.js.map +1 -1
- package/dist/hooks/use-close-transition.js +1 -0
- package/dist/hooks/use-close-transition.js.map +1 -1
- package/dist/hooks/use-dismiss.js +1 -0
- package/dist/hooks/use-dismiss.js.map +1 -1
- package/dist/hooks/use-focus-trap.d.ts +16 -0
- package/dist/hooks/use-focus-trap.js +67 -0
- package/dist/hooks/use-focus-trap.js.map +1 -0
- package/dist/hooks/use-media-query.js +1 -0
- package/dist/hooks/use-media-query.js.map +1 -1
- package/dist/hooks/use-overlay-history.js +27 -1
- package/dist/hooks/use-overlay-history.js.map +1 -1
- package/dist/hooks/use-row-swipe.js +1 -0
- package/dist/hooks/use-row-swipe.js.map +1 -1
- package/dist/i18n/defaults.d.ts +31 -0
- package/dist/i18n/defaults.js +63 -0
- package/dist/i18n/defaults.js.map +1 -0
- package/dist/i18n/kit-labels.d.ts +250 -0
- package/dist/i18n/kit-labels.js +184 -0
- package/dist/i18n/kit-labels.js.map +1 -0
- package/dist/index.d.ts +47 -22
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/calc.js +1 -0
- package/dist/lib/calc.js.map +1 -1
- package/dist/lib/cn.js +1 -0
- package/dist/lib/cn.js.map +1 -1
- package/dist/lib/dates.js +1 -0
- package/dist/lib/dates.js.map +1 -1
- package/dist/lib/logger.js +1 -0
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/safe-storage.js +1 -0
- package/dist/lib/safe-storage.js.map +1 -1
- package/dist/search/command-palette.d.ts +11 -1
- package/dist/search/command-palette.js +21 -15
- package/dist/search/command-palette.js.map +1 -1
- package/dist/search.d.ts +2 -0
- package/dist/search.js +3 -0
- package/dist/search.js.map +1 -0
- package/dist/shell/app-shell.d.ts +33 -4
- package/dist/shell/app-shell.js +275 -78
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/option-switcher-menu.js +3 -2
- package/dist/shell/option-switcher-menu.js.map +1 -1
- package/dist/shell/role-switcher.d.ts +6 -0
- package/dist/shell/role-switcher.js +7 -4
- package/dist/shell/role-switcher.js.map +1 -1
- package/dist/shell/top-bar.d.ts +15 -7
- package/dist/shell/top-bar.js +3 -5
- package/dist/shell/top-bar.js.map +1 -1
- package/dist/shell/topbar-action-menu.js +3 -2
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell/topbar-controls.d.ts +5 -2
- package/dist/shell/topbar-controls.js +20 -15
- package/dist/shell/topbar-controls.js.map +1 -1
- package/dist/shell.d.ts +13 -0
- package/dist/shell.js +8 -0
- package/dist/shell.js.map +1 -0
- package/dist/theme/chart-palette.d.ts +19 -12
- package/dist/theme/chart-palette.js +24 -30
- package/dist/theme/chart-palette.js.map +1 -1
- package/dist/theme/color.d.ts +78 -0
- package/dist/theme/color.js +148 -0
- package/dist/theme/color.js.map +1 -0
- package/dist/theme/palette-derive.d.ts +140 -0
- package/dist/theme/palette-derive.js +376 -0
- package/dist/theme/palette-derive.js.map +1 -0
- package/dist/theme/palette-presets.d.ts +27 -5
- package/dist/theme/palette-presets.js +231 -33
- package/dist/theme/palette-presets.js.map +1 -1
- package/dist/theme/palette-store.js +1 -0
- package/dist/theme/palette-store.js.map +1 -1
- package/dist/theme/theme-store.js +1 -0
- package/dist/theme/theme-store.js.map +1 -1
- package/dist/tour/tour.d.ts +2 -1
- package/dist/tour/tour.js +15 -9
- package/dist/tour/tour.js.map +1 -1
- package/dist/tour.d.ts +2 -0
- package/dist/tour.js +3 -0
- package/dist/tour.js.map +1 -0
- package/dist/wizard/stepper-nav.js +10 -8
- package/dist/wizard/stepper-nav.js.map +1 -1
- package/dist/wizard/types.d.ts +18 -2
- package/dist/wizard/types.js +4 -1
- package/dist/wizard/types.js.map +1 -1
- package/dist/wizard/use-wizard.js +12 -4
- package/dist/wizard/use-wizard.js.map +1 -1
- package/dist/wizard/validation.js +1 -0
- package/dist/wizard/validation.js.map +1 -1
- package/dist/wizard/wizard-context.js +1 -0
- package/dist/wizard/wizard-context.js.map +1 -1
- package/dist/wizard/wizard-step.js +1 -0
- package/dist/wizard/wizard-step.js.map +1 -1
- package/dist/wizard/wizard-summary.js +5 -3
- package/dist/wizard/wizard-summary.js.map +1 -1
- package/dist/wizard.d.ts +8 -0
- package/dist/wizard.js +9 -0
- package/dist/wizard.js.map +1 -0
- package/package.json +67 -14
- package/src/chart.ts +22 -0
- package/src/components/account-settings.tsx +275 -0
- package/src/components/alert-banner.tsx +75 -0
- package/src/components/amount-input.tsx +471 -0
- package/src/components/calculator.tsx +252 -0
- package/src/components/chart-zoom.tsx +499 -0
- package/src/components/chart.tsx +363 -0
- package/src/components/checkbox.tsx +222 -0
- package/src/components/chip.tsx +570 -0
- package/src/components/choice-parts.ts +33 -0
- package/src/components/combobox-core.tsx +540 -0
- package/src/components/combobox.tsx +1026 -0
- package/src/components/currency-select.tsx +269 -0
- package/src/components/data-table-filter-popover.tsx +252 -0
- package/src/components/data-table-filters.ts +176 -0
- package/src/components/data-table-labels.ts +190 -0
- package/src/components/data-table-pagination.tsx +126 -0
- package/src/components/data-table-sort.ts +70 -0
- package/src/components/data-table.tsx +1740 -0
- package/src/components/date-picker.tsx +631 -0
- package/src/components/dropdown.tsx +341 -0
- package/src/components/entity-combobox.tsx +215 -0
- package/src/components/facing-pair.ts +86 -0
- package/src/components/field-sync.tsx +472 -0
- package/src/components/file-dropzone.tsx +181 -0
- package/src/components/full-bleed-dialog.tsx +179 -0
- package/src/components/grouped-picker.tsx +157 -0
- package/src/components/hover-menu.tsx +183 -0
- package/src/components/mini-calendar.tsx +554 -0
- package/src/components/modal.tsx +287 -0
- package/src/components/month-picker.tsx +549 -0
- package/src/components/multi-entity-combobox.tsx +226 -0
- package/src/components/multi-select.tsx +303 -0
- package/src/components/number-field.tsx +225 -0
- package/src/components/number-input.tsx +211 -0
- package/src/components/numpad-sheet.tsx +264 -0
- package/src/components/page-contents.tsx +289 -0
- package/src/components/password-strength.tsx +258 -0
- package/src/components/picker-sheet.tsx +251 -0
- package/src/components/popover.tsx +195 -0
- package/src/components/search-field.tsx +146 -0
- package/src/components/series-chart-labels.ts +26 -0
- package/src/components/series-chart.tsx +481 -0
- package/src/components/settings-fields.tsx +68 -0
- package/src/components/signature-pad.tsx +630 -0
- package/src/components/slider.tsx +313 -0
- package/src/components/sparkline.tsx +329 -0
- package/src/components/stat-tile.tsx +448 -0
- package/src/components/swipeable-row.tsx +271 -0
- package/src/components/switch.tsx +170 -0
- package/src/components/time-input.tsx +107 -0
- package/src/components/toggle-group.tsx +153 -0
- package/src/components/toggle-legend.tsx +229 -0
- package/src/components/tooltip.tsx +477 -0
- package/src/components/treemap.tsx +390 -0
- package/src/components/ui.tsx +1284 -0
- package/src/components/use-mobile-reveal.ts +54 -0
- package/src/components/use-table-state.ts +295 -0
- package/src/components/user-avatar.tsx +61 -0
- package/src/components/wizard-stepper.tsx +37 -0
- package/src/data-table.ts +19 -0
- package/src/feedback/feedback-attachment.tsx +246 -0
- package/src/feedback/feedback-dialog.tsx +209 -0
- package/src/feedback/feedback-inbox.tsx +615 -0
- package/src/feedback.ts +8 -0
- package/src/hooks/use-anchored-panel.ts +169 -0
- package/src/hooks/use-anchored-rect.ts +78 -0
- package/src/hooks/use-announce.ts +85 -0
- package/src/hooks/use-body-scroll-lock.ts +94 -0
- package/src/hooks/use-close-transition.ts +99 -0
- package/src/hooks/use-dismiss.ts +77 -0
- package/src/hooks/use-focus-trap.ts +160 -0
- package/src/hooks/use-media-query.ts +23 -0
- package/src/hooks/use-overlay-history.ts +345 -0
- package/src/hooks/use-row-swipe.ts +212 -0
- package/src/i18n/defaults.ts +68 -0
- package/src/i18n/kit-labels.tsx +447 -0
- package/src/index.ts +169 -0
- package/src/lib/calc.ts +309 -0
- package/src/lib/cn.ts +5 -0
- package/src/lib/dates.ts +187 -0
- package/src/lib/logger.ts +73 -0
- package/src/lib/safe-storage.ts +37 -0
- package/src/search/command-palette.tsx +342 -0
- package/src/search.ts +3 -0
- package/src/shell/app-shell.tsx +772 -0
- package/src/shell/option-switcher-menu.tsx +72 -0
- package/src/shell/role-switcher.tsx +46 -0
- package/src/shell/top-bar.tsx +39 -0
- package/src/shell/topbar-action-menu.tsx +91 -0
- package/src/shell/topbar-controls.tsx +229 -0
- package/src/shell.ts +10 -0
- package/src/theme/chart-palette.ts +145 -0
- package/src/theme/color.ts +266 -0
- package/src/theme/palette-derive.ts +681 -0
- package/src/theme/palette-presets.ts +760 -0
- package/src/theme/palette-store.ts +94 -0
- package/src/theme/theme-store.ts +145 -0
- package/src/tour/tour.tsx +586 -0
- package/src/tour.ts +3 -0
- package/src/vite-env.d.ts +26 -0
- package/src/wizard/stepper-nav.tsx +221 -0
- package/src/wizard/types.ts +178 -0
- package/src/wizard/use-wizard.ts +345 -0
- package/src/wizard/validation.ts +37 -0
- package/src/wizard/wizard-context.tsx +29 -0
- package/src/wizard/wizard-step.tsx +14 -0
- package/src/wizard/wizard-summary.tsx +69 -0
- package/src/wizard.ts +14 -0
- package/tokens.css +222 -20
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { useId, useRef, useState } from "react";
|
|
3
4
|
import { CalculatorButton } from "./calculator.js";
|
|
@@ -98,12 +99,21 @@ function NumberInput({
|
|
|
98
99
|
"span",
|
|
99
100
|
{
|
|
100
101
|
"aria-hidden": true,
|
|
101
|
-
className: "pointer-events-none pr-3 text-xs font-medium text-
|
|
102
|
+
className: "pointer-events-none pr-3 text-xs font-medium text-[var(--text-muted)]",
|
|
102
103
|
children: suffix
|
|
103
104
|
}
|
|
104
105
|
)
|
|
105
106
|
] }),
|
|
106
|
-
showNumpad && /* @__PURE__ */ jsx(
|
|
107
|
+
showNumpad && /* @__PURE__ */ jsx(
|
|
108
|
+
NumberPadSheet,
|
|
109
|
+
{
|
|
110
|
+
value,
|
|
111
|
+
onChange,
|
|
112
|
+
onDone: () => inputRef.current?.blur(),
|
|
113
|
+
label,
|
|
114
|
+
labels: labels?.pad
|
|
115
|
+
}
|
|
116
|
+
)
|
|
107
117
|
]
|
|
108
118
|
}
|
|
109
119
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/number-input.tsx"],"sourcesContent":["import { useId, useRef, useState } from \"react\";\nimport type { KeyboardEvent, ReactNode } from \"react\";\nimport { CalculatorButton, type CalculatorButtonLabels } from \"./calculator\";\nimport { NumberPadSheet } from \"./numpad-sheet\";\nimport { FIELD_BASE, FIELD_DISPLAY, FIELD_INVALID, FLOATING_INPUT_CLASS, FloatingField, PHONE_QUERY } from \"./ui\";\nimport { cn } from \"../lib/cn\";\nimport { commitExpression, sanitizeLive } from \"../lib/calc\";\nimport { useMediaQuery } from \"../hooks/use-media-query\";\n\ninterface NumberInputProps {\n value: string;\n /** Fired on every keystroke with the raw text (comma → dot, operators kept so\n * a typed expression survives). */\n onChange: (value: string) => void;\n /** Fired on blur/Enter with the *evaluated* value — use this for save-on-blur\n * fields so the save always sees the resolved number, never \"10+5\". */\n onCommit?: (value: string) => void;\n label?: ReactNode;\n ariaLabel?: string;\n /** Names for the calculator this field renders — its trigger, and the controls\n * inside the popover. English defaults, so a host that does not translate is\n * unaffected. */\n labels?: { calculatorTrigger?: string; calculator?: CalculatorButtonLabels };\n placeholder?: string;\n disabled?: boolean;\n autoFocus?: boolean;\n /** Wrapper class. */\n className?: string;\n /** Overrides the input's own styling (merged after the field base). */\n inputClassName?: string;\n id?: string;\n /** Show the calculator-popover trigger (default true). Set false for fields in\n * an ephemeral close-on-blur editor, where clicking the icon would blur away\n * and tear the editor down before the popover could open — inline typing\n * (e.g. \"200+50\" → Enter) still evaluates there. */\n calculator?: boolean;\n /** {@link FIELD_DISPLAY} — on a phone, the figure at display size with the field\n * chrome dropped. The currency-free half of the same treatment `AmountInput`\n * carries, for a dialog whose whole point is the one number (a budget goal's\n * target); not for a field among many, and never for the compact inline\n * editors this control also serves. */\n variant?: \"field\" | \"display\";\n /** A {@link FieldHint} \"?\" on the label's own line, beside the label rather\n * than at the far end of the strip — the far end is where the calculator\n * lives, and a hint placed there landed on top of it (steering-design\n * feedback #48). */\n hint?: ReactNode;\n /** Required and unanswered — {@link FIELD_INVALID}. See {@link Input}'s `invalid`. */\n invalid?: boolean;\n /**\n * A static unit shown at the field's right edge — \"%\", \"kg\", \"km/h\".\n *\n * The read-out half of {@link AmountInput}'s currency chip, and it exists for the\n * same reason that one does: a unit belongs to the FIELD, not to the text, so\n * typing it is a way to get it into the value. Keksdose had a percentage spelled\n * three different ways across three screens — `<Input type=\"number\" step=\"0.01\">`\n * for a loan rate, `step=\"0.1\"` for a tax rate, `inputMode=\"decimal\"` for a VAT\n * rate — and none of the three showed a \"%\" anywhere near the box, so what the\n * digits meant was a question the label alone had to answer.\n *\n * `aria-hidden`, like the currency read-out: it is a property of the field that\n * the label already names (\"Interest rate (%)\"), and announcing it again after\n * every value reads as part of the number.\n */\n suffix?: ReactNode;\n}\n\n/**\n * A numeric text field with a built-in calculator: type a calculation straight\n * in (e.g. \"12+5\", evaluated on blur/Enter) or click the trailing calculator\n * icon for a keypad. String `value`/`onChange` contract, mirroring\n * {@link AmountInput} — the currency-free counterpart for budgets, goals,\n * invoice totals and split lines.\n */\nexport function NumberInput({\n value,\n onChange,\n onCommit,\n label,\n ariaLabel,\n labels,\n placeholder,\n disabled,\n autoFocus,\n className,\n inputClassName,\n id,\n calculator = true,\n variant = \"field\",\n hint,\n invalid,\n suffix,\n}: NumberInputProps) {\n const generatedId = useId();\n const fieldId = id ?? generatedId;\n const labelled = label !== undefined;\n // On phones we suppress the OS keyboard (inputMode=\"none\" below) for our own\n // calculator numpad, so the desktop popover trigger is hidden (feedback #334).\n const isMobile = useMediaQuery(PHONE_QUERY, false);\n const asDisplay = isMobile && variant === \"display\";\n const showCalc = calculator && !disabled && !isMobile;\n const [focused, setFocused] = useState(false);\n // On mobile, focusing opens the numpad bottom sheet instead of the native\n // keyboard (#334); the ref lets its \"Done\" blur → commit + close.\n const showNumpad = isMobile && !disabled && focused;\n const inputRef = useRef<HTMLInputElement>(null);\n\n const commit = () => {\n const next = commitExpression(value);\n if (next !== value) onChange(next);\n onCommit?.(next);\n };\n\n const onKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"Enter\") commit();\n };\n\n return (\n <FloatingField\n className={cn(\"w-full\", className)}\n htmlFor={fieldId}\n label={label}\n srOnlyLabel={asDisplay}\n hint={hint}\n >\n <input\n ref={inputRef}\n id={fieldId}\n aria-label={ariaLabel}\n type=\"text\"\n // Mobile: suppress the OS keyboard so the numpad sheet owns entry (field\n // keeps focus/caret); desktop keeps the native decimal keypad.\n inputMode={isMobile ? \"none\" : \"decimal\"}\n autoComplete=\"off\"\n autoFocus={autoFocus}\n disabled={disabled}\n // Display mode has no floating label to feed the blank-placeholder trick,\n // and an empty borderless figure shows nothing — so it keeps whatever\n // placeholder the caller gave, falling back to a zero to aim at.\n placeholder={asDisplay ? (placeholder ?? \"0\") : labelled ? \" \" : placeholder}\n value={value}\n onChange={(e) => onChange(sanitizeLive(e.target.value))}\n onFocus={() => setFocused(true)}\n onBlur={() => {\n commit();\n setFocused(false);\n }}\n onKeyDown={onKeyDown}\n aria-invalid={invalid || undefined}\n // The right-padding sits last so it always wins over an inputClassName that\n // sets its own px. Both trailing controls can be on at once, so the room\n // they need is reserved together rather than by whichever happens to render:\n // the calculator is ~36px and a short unit ~24px, and a field that reserved\n // only one of them would let the digits run under the other.\n className={cn(\n asDisplay\n ? cn(FIELD_DISPLAY, \"text-4xl font-semibold leading-tight tracking-tight tabular-nums\")\n : labelled\n ? FLOATING_INPUT_CLASS\n : FIELD_BASE,\n inputClassName,\n showCalc && suffix !== undefined ? \"pr-16\" : showCalc ? \"pr-9\" : suffix !== undefined ? \"pr-8\" : undefined,\n invalid && FIELD_INVALID,\n )}\n />\n {(showCalc || suffix !== undefined) && (\n // One flex track for both, so the unit and the calculator sit side by side\n // instead of stacking on the same corner — AmountInput's arrangement, which\n // has carried a chip and a calculator together since #430.\n <div className=\"absolute inset-y-0 right-0 flex items-center\">\n {showCalc && (\n <CalculatorButton\n value={value}\n onChange={onChange}\n className=\"self-stretch px-2.5\"\n ariaLabel={labels?.calculatorTrigger}\n labels={labels?.calculator}\n />\n )}\n {suffix !== undefined && (\n <span\n aria-hidden\n className=\"pointer-events-none pr-3 text-xs font-medium text-slate-500 dark:text-slate-400\"\n >\n {suffix}\n </span>\n )}\n </div>\n )}\n {showNumpad && (\n <NumberPadSheet value={value} onChange={onChange} onDone={() => inputRef.current?.blur()} label={label} />\n )}\n </FloatingField>\n );\n}\n"],"mappings":"AA6HM,cA4CE,YA5CF;AA7HN,SAAS,OAAO,QAAQ,gBAAgB;AAExC,SAAS,wBAAqD;AAC9D,SAAS,sBAAsB;AAC/B,SAAS,YAAY,eAAe,eAAe,sBAAsB,eAAe,mBAAmB;AAC3G,SAAS,UAAU;AACnB,SAAS,kBAAkB,oBAAoB;AAC/C,SAAS,qBAAqB;AAmEvB,SAAS,YAAY;AAAA,EA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YAClB;AAAA,YACA;AAAA,YACA,gBAAc,WAAW;AAAA,YAMzB,WAAW;AAAA,cACT,YACI,GAAG,eAAe,kEAAkE,IACpF,WACE,uBACA;AAAA,cACN;AAAA,cACA,YAAY,WAAW,SAAY,UAAU,WAAW,SAAS,WAAW,SAAY,SAAS;AAAA,cACjG,WAAW;AAAA,YACb;AAAA;AAAA,QACF;AAAA,SACE,YAAY,WAAW;AAAA;AAAA;AAAA,QAIvB,qBAAC,SAAI,WAAU,gDACZ;AAAA,sBACC;AAAA,YAAC;AAAA;AAAA,cACC;AAAA,cACA;AAAA,cACA,WAAU;AAAA,cACV,WAAW,QAAQ;AAAA,cACnB,QAAQ,QAAQ;AAAA;AAAA,UAClB;AAAA,UAED,WAAW,UACV;AAAA,YAAC;AAAA;AAAA,cACC,eAAW;AAAA,cACX,WAAU;AAAA,cAET;AAAA;AAAA,UACH;AAAA,WAEJ;AAAA,QAED,cACC,oBAAC,kBAAe,OAAc,UAAoB,QAAQ,MAAM,SAAS,SAAS,KAAK,GAAG,OAAc;AAAA;AAAA;AAAA,EAE5G;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/number-input.tsx"],"sourcesContent":["import { useId, useRef, useState } from \"react\";\nimport type { KeyboardEvent, ReactNode } from \"react\";\nimport { CalculatorButton, type CalculatorButtonLabels } from \"./calculator\";\nimport { NumberPadSheet, type NumberPadSheetLabels } from \"./numpad-sheet\";\nimport { FIELD_BASE, FIELD_DISPLAY, FIELD_INVALID, FLOATING_INPUT_CLASS, FloatingField, PHONE_QUERY } from \"./ui\";\nimport { cn } from \"../lib/cn\";\nimport { commitExpression, sanitizeLive } from \"../lib/calc\";\nimport { useMediaQuery } from \"../hooks/use-media-query\";\n\ninterface NumberInputProps {\n value: string;\n /** Fired on every keystroke with the raw text (comma → dot, operators kept so\n * a typed expression survives). */\n onChange: (value: string) => void;\n /** Fired on blur/Enter with the *evaluated* value — use this for save-on-blur\n * fields so the save always sees the resolved number, never \"10+5\". */\n onCommit?: (value: string) => void;\n label?: ReactNode;\n ariaLabel?: string;\n /** Names for the calculator this field renders — its trigger, and the controls\n * inside the popover — and for the numpad sheet it opens on a phone. Overrides\n * for THIS field only: both resolve the `calculator` namespace of\n * `<UiKitProvider labels>` themselves, then fall back to English.\n *\n * `pad` is not optional plumbing: this field renders a {@link NumberPadSheet}\n * exactly as {@link AmountInput} does, but had no way to pass it anything, so\n * the SAME keypad announced itself in German when a money field opened it and in\n * English when a goal target did. */\n labels?: {\n calculatorTrigger?: string;\n calculator?: CalculatorButtonLabels;\n pad?: NumberPadSheetLabels;\n };\n placeholder?: string;\n disabled?: boolean;\n autoFocus?: boolean;\n /** Wrapper class. */\n className?: string;\n /** Overrides the input's own styling (merged after the field base). */\n inputClassName?: string;\n id?: string;\n /** Show the calculator-popover trigger (default true). Set false for fields in\n * an ephemeral close-on-blur editor, where clicking the icon would blur away\n * and tear the editor down before the popover could open — inline typing\n * (e.g. \"200+50\" → Enter) still evaluates there. */\n calculator?: boolean;\n /** {@link FIELD_DISPLAY} — on a phone, the figure at display size with the field\n * chrome dropped. The currency-free half of the same treatment `AmountInput`\n * carries, for a dialog whose whole point is the one number (a budget goal's\n * target); not for a field among many, and never for the compact inline\n * editors this control also serves. */\n variant?: \"field\" | \"display\";\n /** A {@link FieldHint} \"?\" on the label's own line, beside the label rather\n * than at the far end of the strip — the far end is where the calculator\n * lives, and a hint placed there landed on top of it (steering-design\n * feedback #48). */\n hint?: ReactNode;\n /** Required and unanswered — {@link FIELD_INVALID}. See {@link Input}'s `invalid`. */\n invalid?: boolean;\n /**\n * A static unit shown at the field's right edge — \"%\", \"kg\", \"km/h\".\n *\n * The read-out half of {@link AmountInput}'s currency chip, and it exists for the\n * same reason that one does: a unit belongs to the FIELD, not to the text, so\n * typing it is a way to get it into the value. Keksdose had a percentage spelled\n * three different ways across three screens — `<Input type=\"number\" step=\"0.01\">`\n * for a loan rate, `step=\"0.1\"` for a tax rate, `inputMode=\"decimal\"` for a VAT\n * rate — and none of the three showed a \"%\" anywhere near the box, so what the\n * digits meant was a question the label alone had to answer.\n *\n * `aria-hidden`, like the currency read-out: it is a property of the field that\n * the label already names (\"Interest rate (%)\"), and announcing it again after\n * every value reads as part of the number.\n */\n suffix?: ReactNode;\n}\n\n/**\n * A numeric text field with a built-in calculator: type a calculation straight\n * in (e.g. \"12+5\", evaluated on blur/Enter) or click the trailing calculator\n * icon for a keypad. String `value`/`onChange` contract, mirroring\n * {@link AmountInput} — the currency-free counterpart for budgets, goals,\n * invoice totals and split lines.\n */\nexport function NumberInput({\n value,\n onChange,\n onCommit,\n label,\n ariaLabel,\n labels,\n placeholder,\n disabled,\n autoFocus,\n className,\n inputClassName,\n id,\n calculator = true,\n variant = \"field\",\n hint,\n invalid,\n suffix,\n}: NumberInputProps) {\n const generatedId = useId();\n const fieldId = id ?? generatedId;\n const labelled = label !== undefined;\n // On phones we suppress the OS keyboard (inputMode=\"none\" below) for our own\n // calculator numpad, so the desktop popover trigger is hidden (feedback #334).\n const isMobile = useMediaQuery(PHONE_QUERY, false);\n const asDisplay = isMobile && variant === \"display\";\n const showCalc = calculator && !disabled && !isMobile;\n const [focused, setFocused] = useState(false);\n // On mobile, focusing opens the numpad bottom sheet instead of the native\n // keyboard (#334); the ref lets its \"Done\" blur → commit + close.\n const showNumpad = isMobile && !disabled && focused;\n const inputRef = useRef<HTMLInputElement>(null);\n\n const commit = () => {\n const next = commitExpression(value);\n if (next !== value) onChange(next);\n onCommit?.(next);\n };\n\n const onKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"Enter\") commit();\n };\n\n return (\n <FloatingField\n className={cn(\"w-full\", className)}\n htmlFor={fieldId}\n label={label}\n srOnlyLabel={asDisplay}\n hint={hint}\n >\n <input\n ref={inputRef}\n id={fieldId}\n aria-label={ariaLabel}\n type=\"text\"\n // Mobile: suppress the OS keyboard so the numpad sheet owns entry (field\n // keeps focus/caret); desktop keeps the native decimal keypad.\n inputMode={isMobile ? \"none\" : \"decimal\"}\n autoComplete=\"off\"\n autoFocus={autoFocus}\n disabled={disabled}\n // Display mode has no floating label to feed the blank-placeholder trick,\n // and an empty borderless figure shows nothing — so it keeps whatever\n // placeholder the caller gave, falling back to a zero to aim at.\n placeholder={asDisplay ? (placeholder ?? \"0\") : labelled ? \" \" : placeholder}\n value={value}\n onChange={(e) => onChange(sanitizeLive(e.target.value))}\n onFocus={() => setFocused(true)}\n onBlur={() => {\n commit();\n setFocused(false);\n }}\n onKeyDown={onKeyDown}\n aria-invalid={invalid || undefined}\n // The right-padding sits last so it always wins over an inputClassName that\n // sets its own px. Both trailing controls can be on at once, so the room\n // they need is reserved together rather than by whichever happens to render:\n // the calculator is ~36px and a short unit ~24px, and a field that reserved\n // only one of them would let the digits run under the other.\n className={cn(\n asDisplay\n ? cn(FIELD_DISPLAY, \"text-4xl font-semibold leading-tight tracking-tight tabular-nums\")\n : labelled\n ? FLOATING_INPUT_CLASS\n : FIELD_BASE,\n inputClassName,\n showCalc && suffix !== undefined ? \"pr-16\" : showCalc ? \"pr-9\" : suffix !== undefined ? \"pr-8\" : undefined,\n invalid && FIELD_INVALID,\n )}\n />\n {(showCalc || suffix !== undefined) && (\n // One flex track for both, so the unit and the calculator sit side by side\n // instead of stacking on the same corner — AmountInput's arrangement, which\n // has carried a chip and a calculator together since #430.\n <div className=\"absolute inset-y-0 right-0 flex items-center\">\n {showCalc && (\n <CalculatorButton\n value={value}\n onChange={onChange}\n className=\"self-stretch px-2.5\"\n ariaLabel={labels?.calculatorTrigger}\n labels={labels?.calculator}\n />\n )}\n {suffix !== undefined && (\n <span\n aria-hidden\n className=\"pointer-events-none pr-3 text-xs font-medium text-[var(--text-muted)]\"\n >\n {suffix}\n </span>\n )}\n </div>\n )}\n {showNumpad && (\n <NumberPadSheet\n value={value}\n onChange={onChange}\n onDone={() => inputRef.current?.blur()}\n label={label}\n labels={labels?.pad}\n />\n )}\n </FloatingField>\n );\n}\n"],"mappings":";AAuIM,cA4CE,YA5C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A,YACA;AAAA,YAIA,aAAa,YAAa,eAAe,MAAO,WAAW,MAAM;AAAA,YACjE;AAAA,YACA,UAAU,CAAC,MAAM,SAAS,aAAa,EAAE,OAAO,KAAK,CAAC;AAAA,YACtD,SAAS,MAAM,WAAW,IAAI;AAAA,YAC9B,QAAQ,MAAM;AACZ,qBAAO;AACP,yBAAW,KAAK;AAAA,YAClB;AAAA,YACA;AAAA,YACA,gBAAc,WAAW;AAAA,YAMzB,WAAW;AAAA,cACT,YACI,GAAG,eAAe,kEAAkE,IACpF,WACE,uBACA;AAAA,cACN;AAAA,cACA,YAAY,WAAW,SAAY,UAAU,WAAW,SAAS,WAAW,SAAY,SAAS;AAAA,cACjG,WAAW;AAAA,YACb;AAAA;AAAA,QACF;AAAA,SACE,YAAY,WAAW;AAAA;AAAA;AAAA,QAIvB,qBAAC,SAAI,WAAU,gDACZ;AAAA,sBACC;AAAA,YAAC;AAAA;AAAA,cACC;AAAA,cACA;AAAA,cACA,WAAU;AAAA,cACV,WAAW,QAAQ;AAAA,cACnB,QAAQ,QAAQ;AAAA;AAAA,UAClB;AAAA,UAED,WAAW,UACV;AAAA,YAAC;AAAA;AAAA,cACC,eAAW;AAAA,cACX,WAAU;AAAA,cAET;AAAA;AAAA,UACH;AAAA,WAEJ;AAAA,QAED,cACC;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA,QAAQ,MAAM,SAAS,SAAS,KAAK;AAAA,YACrC;AAAA,YACA,QAAQ,QAAQ;AAAA;AAAA,QAClB;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
|
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
+
import { CalculatorLabels } from '../i18n/kit-labels.js';
|
|
4
|
+
import './data-table-labels.js';
|
|
5
|
+
import './mini-calendar.js';
|
|
6
|
+
import './popover.js';
|
|
7
|
+
import './chip.js';
|
|
8
|
+
import 'lucide-react';
|
|
9
|
+
import './field-sync.js';
|
|
10
|
+
import './ui.js';
|
|
11
|
+
import '../wizard/types.js';
|
|
12
|
+
import '../tour/tour.js';
|
|
13
|
+
import '../search/command-palette.js';
|
|
14
|
+
import './month-picker.js';
|
|
15
|
+
import './page-contents.js';
|
|
16
|
+
import './series-chart-labels.js';
|
|
17
|
+
import './sparkline.js';
|
|
18
|
+
import './stat-tile.js';
|
|
19
|
+
import './signature-pad.js';
|
|
20
|
+
import './password-strength.js';
|
|
3
21
|
|
|
4
22
|
/**
|
|
5
23
|
* A full calculator keypad rendered as a bottom sheet — the mobile counterpart to
|
|
@@ -19,12 +37,19 @@ import { ReactNode } from 'react';
|
|
|
19
37
|
* the root keeps the host input focused (caret stays, keyboard stays hidden) as
|
|
20
38
|
* the user taps keys; the buttons' `onClick` still fires.
|
|
21
39
|
*/
|
|
22
|
-
/**
|
|
23
|
-
|
|
40
|
+
/** Names for the pad itself and its four non-digit keys. The first four are
|
|
41
|
+
* screen-reader names; `done` is the one string here that is READ OFF THE SCREEN —
|
|
42
|
+
* the brand-filled primary button — and it was a hardcoded English literal while
|
|
43
|
+
* its three neighbours each took an override, so a German phone showed "Done"
|
|
44
|
+
* among German labels with no prop able to change it. */
|
|
45
|
+
interface NumberPadSheetLabels extends Partial<CalculatorLabels> {
|
|
46
|
+
/** The pad's own name — the `calculator.panel` key under its older name here. */
|
|
24
47
|
pad?: string;
|
|
25
48
|
backspace?: string;
|
|
26
49
|
clear?: string;
|
|
27
50
|
equals?: string;
|
|
51
|
+
/** Visible text on the primary key, not an `aria-label`. */
|
|
52
|
+
done?: string;
|
|
28
53
|
}
|
|
29
54
|
declare function NumberPadSheet({ value, onChange, onDone, label, labels, }: {
|
|
30
55
|
value: string;
|
|
@@ -37,8 +62,11 @@ declare function NumberPadSheet({ value, onChange, onDone, label, labels, }: {
|
|
|
37
62
|
/** Optional field label, echoed in the sheet header so the user still knows
|
|
38
63
|
* which field they're editing when the sheet covers it. */
|
|
39
64
|
label?: ReactNode;
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
65
|
+
/** Names for the pad itself and its non-digit keys — screen-reader names, except
|
|
66
|
+
* `done`, which is the visible text on the primary key. Merged over `calculator`
|
|
67
|
+
* from `<UiKitProvider labels>`: this is the same keypad as `CalculatorButton`'s,
|
|
68
|
+
* on a phone, and one translation covers both. Digits need no name — their glyph
|
|
69
|
+
* IS the name; the operators do (see {@link CalculatorLabels.plus}). */
|
|
42
70
|
labels?: NumberPadSheetLabels;
|
|
43
71
|
}): react.ReactPortal;
|
|
44
72
|
|
|
@@ -1,27 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { createPortal } from "react-dom";
|
|
3
4
|
import { Delete } from "lucide-react";
|
|
5
|
+
import { useMemo } from "react";
|
|
4
6
|
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { useEscapeKey } from "../hooks/use-dismiss.js";
|
|
5
8
|
import { evaluateExpression, formatResult, sanitizeLive } from "../lib/calc.js";
|
|
9
|
+
import {
|
|
10
|
+
DEFAULT_CALCULATOR_LABELS,
|
|
11
|
+
useKitLabels
|
|
12
|
+
} from "../i18n/kit-labels.js";
|
|
6
13
|
const PAD_KEYS = [
|
|
7
14
|
{ kind: "ins", label: "7", ins: "7" },
|
|
8
15
|
{ kind: "ins", label: "8", ins: "8" },
|
|
9
16
|
{ kind: "ins", label: "9", ins: "9" },
|
|
10
|
-
{ kind: "ins", label: "\xF7", ins: "\xF7", accent: true },
|
|
17
|
+
{ kind: "ins", label: "\xF7", ins: "\xF7", accent: true, name: "divide" },
|
|
11
18
|
{ kind: "ins", label: "4", ins: "4" },
|
|
12
19
|
{ kind: "ins", label: "5", ins: "5" },
|
|
13
20
|
{ kind: "ins", label: "6", ins: "6" },
|
|
14
|
-
{ kind: "ins", label: "\xD7", ins: "\xD7", accent: true },
|
|
21
|
+
{ kind: "ins", label: "\xD7", ins: "\xD7", accent: true, name: "times" },
|
|
15
22
|
{ kind: "ins", label: "1", ins: "1" },
|
|
16
23
|
{ kind: "ins", label: "2", ins: "2" },
|
|
17
24
|
{ kind: "ins", label: "3", ins: "3" },
|
|
18
|
-
{ kind: "ins", label: "\u2212", ins: "-", accent: true },
|
|
19
|
-
{ kind: "ins", label: ".", ins: "." },
|
|
25
|
+
{ kind: "ins", label: "\u2212", ins: "-", accent: true, name: "minus" },
|
|
26
|
+
{ kind: "ins", label: ".", ins: ".", name: "decimal" },
|
|
20
27
|
{ kind: "ins", label: "0", ins: "0" },
|
|
21
28
|
{ kind: "back" },
|
|
22
|
-
{ kind: "ins", label: "+", ins: "+", accent: true }
|
|
29
|
+
{ kind: "ins", label: "+", ins: "+", accent: true, name: "plus" }
|
|
23
30
|
];
|
|
24
|
-
const PAD_BTN = "flex h-14 items-center justify-center rounded-lg text-lg font-medium transition-transform select-none focus:outline-none active:scale-[0.97]";
|
|
31
|
+
const PAD_BTN = "flex h-14 items-center justify-center rounded-lg text-lg font-medium transition-transform select-none focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--brand)] active:scale-[0.97]";
|
|
25
32
|
const PAD_DIGIT = "bg-[var(--bg-surface-2)] text-[var(--text-primary)] active:bg-[var(--border)]";
|
|
26
33
|
const PAD_ACCENT = "bg-[var(--border)] text-[var(--text-primary)] active:bg-[var(--bg-surface-2)]";
|
|
27
34
|
function NumberPadSheet({
|
|
@@ -31,6 +38,13 @@ function NumberPadSheet({
|
|
|
31
38
|
label,
|
|
32
39
|
labels
|
|
33
40
|
}) {
|
|
41
|
+
const fromProps = useMemo(() => {
|
|
42
|
+
if (!labels) return void 0;
|
|
43
|
+
const { pad, ...rest } = labels;
|
|
44
|
+
return pad === void 0 ? rest : { ...rest, panel: pad };
|
|
45
|
+
}, [labels]);
|
|
46
|
+
const text = useKitLabels("calculator", DEFAULT_CALCULATOR_LABELS, fromProps);
|
|
47
|
+
useEscapeKey(onDone);
|
|
34
48
|
const result = evaluateExpression(value);
|
|
35
49
|
const preview = result !== null && formatResult(result) !== value.trim() ? `= ${formatResult(result)}` : "";
|
|
36
50
|
const insert = (ch) => onChange(sanitizeLive(value + ch));
|
|
@@ -43,7 +57,7 @@ function NumberPadSheet({
|
|
|
43
57
|
"div",
|
|
44
58
|
{
|
|
45
59
|
role: "group",
|
|
46
|
-
"aria-label":
|
|
60
|
+
"aria-label": text.panel,
|
|
47
61
|
onPointerDown: (e) => e.preventDefault(),
|
|
48
62
|
className: "fixed inset-x-0 bottom-0 z-50 border-t border-[var(--border)] bg-[var(--bg-surface)] px-2 pt-2 shadow-[0_-4px_24px_rgba(0,0,0,0.12)]",
|
|
49
63
|
style: { paddingBottom: "max(0.5rem, env(safe-area-inset-bottom))" },
|
|
@@ -60,7 +74,7 @@ function NumberPadSheet({
|
|
|
60
74
|
"button",
|
|
61
75
|
{
|
|
62
76
|
type: "button",
|
|
63
|
-
"aria-label":
|
|
77
|
+
"aria-label": text.backspace,
|
|
64
78
|
onClick: backspace,
|
|
65
79
|
className: cn(PAD_BTN, PAD_ACCENT),
|
|
66
80
|
children: /* @__PURE__ */ jsx(Delete, { className: "size-5" })
|
|
@@ -70,7 +84,7 @@ function NumberPadSheet({
|
|
|
70
84
|
"button",
|
|
71
85
|
{
|
|
72
86
|
type: "button",
|
|
73
|
-
"aria-label": key.label,
|
|
87
|
+
"aria-label": key.name ? text[key.name] : key.label,
|
|
74
88
|
onClick: () => insert(key.ins),
|
|
75
89
|
className: cn(PAD_BTN, key.accent ? PAD_ACCENT : PAD_DIGIT),
|
|
76
90
|
children: key.label
|
|
@@ -79,15 +93,18 @@ function NumberPadSheet({
|
|
|
79
93
|
)
|
|
80
94
|
) }),
|
|
81
95
|
/* @__PURE__ */ jsxs("div", { className: "mt-1.5 grid grid-cols-4 gap-1.5", children: [
|
|
82
|
-
/* @__PURE__ */ jsx("button", { type: "button", "aria-label":
|
|
83
|
-
/* @__PURE__ */ jsx("button", { type: "button", "aria-label":
|
|
96
|
+
/* @__PURE__ */ jsx("button", { type: "button", "aria-label": text.clear, onClick: clearAll, className: cn(PAD_BTN, PAD_ACCENT), children: "C" }),
|
|
97
|
+
/* @__PURE__ */ jsx("button", { type: "button", "aria-label": text.equals, onClick: equals, className: cn(PAD_BTN, PAD_ACCENT), children: "=" }),
|
|
84
98
|
/* @__PURE__ */ jsx(
|
|
85
99
|
"button",
|
|
86
100
|
{
|
|
87
101
|
type: "button",
|
|
88
102
|
onClick: onDone,
|
|
89
|
-
className: cn(
|
|
90
|
-
|
|
103
|
+
className: cn(
|
|
104
|
+
PAD_BTN,
|
|
105
|
+
"col-span-2 bg-[var(--brand)] text-[var(--brand-contrast)] focus-visible:ring-[var(--brand-contrast)] active:bg-[var(--brand-hover)]"
|
|
106
|
+
),
|
|
107
|
+
children: text.done
|
|
91
108
|
}
|
|
92
109
|
)
|
|
93
110
|
] })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/numpad-sheet.tsx"],"sourcesContent":["import { createPortal } from \"react-dom\";\nimport { Delete } from \"lucide-react\";\nimport type { ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { evaluateExpression, formatResult, sanitizeLive } from \"../lib/calc\";\n\n/**\n * A full calculator keypad rendered as a bottom sheet — the mobile counterpart to\n * the desktop {@link CalculatorButton} popover, and the replacement for the old\n * under-the-field operator bar (`MathKeys`, feedback #334).\n *\n * A native app (YNAB) can swap the system keyboard for its own keypad; a PWA\n * cannot — but it CAN suppress the OS keyboard with `inputMode=\"none\"` on the\n * host field and paint its own keypad in the freed space. So the host input keeps\n * real focus/caret/selection + the existing value/commit contract, while this\n * sheet drives it: digits + operators + a live `= …` preview, evaluated through\n * the shared {@link evaluateExpression} engine. Desktop is untouched (it keeps the\n * native keyboard and the calculator popover); the host gates this to mobile.\n *\n * Buttons commit through the host's `onChange`/blur, so the sheet is stateless —\n * the field text is the single source of truth. `onPointerDown` preventDefault on\n * the root keeps the host input focused (caret stays, keyboard stays hidden) as\n * the user taps keys; the buttons' `onClick` still fires.\n */\n/** Screen-reader names for the pad itself and its three non-digit keys. */\nexport interface NumberPadSheetLabels {\n pad?: string;\n backspace?: string;\n clear?: string;\n equals?: string;\n}\n\ntype PadKey =\n | { kind: \"ins\"; label: string; ins: string; accent?: boolean }\n | { kind: \"back\" };\n\n// Insert chars that survive `sanitizeLive` (it keeps `× ÷` and ASCII `+ - * /`\n// but strips the unicode minus `−`, so minus inserts an ASCII \"-\" while showing\n// the nicer glyph). The evaluator normalises `× ÷` back to `* /`.\nconst PAD_KEYS: PadKey[] = [\n { kind: \"ins\", label: \"7\", ins: \"7\" },\n { kind: \"ins\", label: \"8\", ins: \"8\" },\n { kind: \"ins\", label: \"9\", ins: \"9\" },\n { kind: \"ins\", label: \"÷\", ins: \"÷\", accent: true },\n { kind: \"ins\", label: \"4\", ins: \"4\" },\n { kind: \"ins\", label: \"5\", ins: \"5\" },\n { kind: \"ins\", label: \"6\", ins: \"6\" },\n { kind: \"ins\", label: \"×\", ins: \"×\", accent: true },\n { kind: \"ins\", label: \"1\", ins: \"1\" },\n { kind: \"ins\", label: \"2\", ins: \"2\" },\n { kind: \"ins\", label: \"3\", ins: \"3\" },\n { kind: \"ins\", label: \"−\", ins: \"-\", accent: true },\n { kind: \"ins\", label: \".\", ins: \".\" },\n { kind: \"ins\", label: \"0\", ins: \"0\" },\n { kind: \"back\" },\n { kind: \"ins\", label: \"+\", ins: \"+\", accent: true },\n];\n\nconst PAD_BTN =\n \"flex h-14 items-center justify-center rounded-lg text-lg font-medium transition-transform select-none focus:outline-none active:scale-[0.97]\";\nconst PAD_DIGIT = \"bg-[var(--bg-surface-2)] text-[var(--text-primary)] active:bg-[var(--border)]\";\nconst PAD_ACCENT = \"bg-[var(--border)] text-[var(--text-primary)] active:bg-[var(--bg-surface-2)]\";\n\nexport function NumberPadSheet({\n value,\n onChange,\n onDone,\n label,\n labels,\n}: {\n value: string;\n /** Fired with the raw (sanitised) field text on every key — same contract as\n * the host field's own `onChange`. */\n onChange: (value: string) => void;\n /** Fired on \"Done\": the host blurs the input, which commits (evaluates) and\n * unmounts the sheet via its existing blur handler. */\n onDone: () => void;\n /** Optional field label, echoed in the sheet header so the user still knows\n * which field they're editing when the sheet covers it. */\n label?: ReactNode;\n /** Screen-reader names for the pad itself and its three non-digit keys. The\n * digits and operators need none — their visible glyph IS the name. */\n labels?: NumberPadSheetLabels;\n}) {\n // NO `useBodyScrollLock`, and that is the point of the control (Keksdose live\n // #317: *\"Background not scrollable when the amount input calculator field is\n // open\"*).\n //\n // This sheet is a KEYBOARD, not a dialog. It is opened by focusing a field and\n // exists only because a PWA cannot swap the system keyboard for its own — so it\n // suppresses the OS keyboard with `inputMode=\"none\"` and paints itself in the\n // freed space. An OS keyboard does not freeze the page behind it; it takes the\n // bottom of the screen and leaves you free to scroll what is left, which is how\n // you reach the field you are typing into when the keys cover it.\n //\n // Locking here made the page unreachable at exactly the moment it matters most:\n // correcting a receipt total against the running line sum, where the figure you\n // are comparing against sits below the keypad. The other four holders of that\n // hook are all modal — `Modal`, `PickerSheet`, `FullBleedDialog`, the DataTable\n // row dialog — and they stay locked, because for them the page behind is not\n // part of the task.\n //\n // The pad still does not scroll ITSELF away under a stray drag: the root's\n // `onPointerDown` preventDefault (below) keeps the host input focused and eats\n // the gesture on the sheet, so a touch that starts on a key is not a page scroll.\n\n const result = evaluateExpression(value);\n const preview = result !== null && formatResult(result) !== value.trim() ? `= ${formatResult(result)}` : \"\";\n\n const insert = (ch: string) => onChange(sanitizeLive(value + ch));\n const backspace = () => onChange(value.slice(0, -1));\n const clearAll = () => onChange(\"\");\n const equals = () => {\n if (result !== null) onChange(formatResult(result));\n };\n\n const sheet = (\n <div\n role=\"group\"\n aria-label={labels?.pad ?? \"Number pad\"}\n // Keep the host input focused when tapping the pad: preventDefault on\n // pointerdown blocks the focus/blur, while the buttons' click still fires.\n onPointerDown={(e) => e.preventDefault()}\n className=\"fixed inset-x-0 bottom-0 z-50 border-t border-[var(--border)] bg-[var(--bg-surface)] px-2 pt-2 shadow-[0_-4px_24px_rgba(0,0,0,0.12)]\"\n style={{ paddingBottom: \"max(0.5rem, env(safe-area-inset-bottom))\" }}\n >\n {/* Header display: which field + the running expression and live result, so\n the value stays visible even when the sheet covers the field. */}\n <div className=\"flex items-end justify-between gap-3 px-2 pb-2\">\n {label != null && (\n <span className=\"truncate pb-1 text-xs font-medium text-[var(--money-neutral)]\">{label}</span>\n )}\n <div className=\"ml-auto min-w-0 text-right\">\n <div className=\"truncate font-mono text-lg leading-tight text-[var(--text-primary)]\">{value || \"0\"}</div>\n <div className=\"h-4 font-mono text-xs text-[var(--money-neutral)]\">{preview}</div>\n </div>\n </div>\n\n <div className=\"grid grid-cols-4 gap-1.5\">\n {PAD_KEYS.map((key, i) =>\n key.kind === \"back\" ? (\n <button\n key=\"back\"\n type=\"button\"\n aria-label={labels?.backspace ?? \"Backspace\"}\n onClick={backspace}\n className={cn(PAD_BTN, PAD_ACCENT)}\n >\n <Delete className=\"size-5\" />\n </button>\n ) : (\n <button\n key={`${key.ins}-${i}`}\n type=\"button\"\n aria-label={key.label}\n onClick={() => insert(key.ins)}\n className={cn(PAD_BTN, key.accent ? PAD_ACCENT : PAD_DIGIT)}\n >\n {key.label}\n </button>\n ),\n )}\n </div>\n\n <div className=\"mt-1.5 grid grid-cols-4 gap-1.5\">\n <button type=\"button\" aria-label={labels?.clear ?? \"Clear\"} onClick={clearAll} className={cn(PAD_BTN, PAD_ACCENT)}>\n C\n </button>\n <button type=\"button\" aria-label={labels?.equals ?? \"Equals\"} onClick={equals} className={cn(PAD_BTN, PAD_ACCENT)}>\n =\n </button>\n <button\n type=\"button\"\n onClick={onDone}\n className={cn(PAD_BTN, \"col-span-2 bg-[var(--brand)] text-[var(--brand-contrast)] active:bg-[var(--brand-hover)]\")}\n >\n Done\n </button>\n </div>\n </div>\n );\n\n return createPortal(sheet, document.body);\n}\n"],"mappings":"AAkIU,cAEF,YAFE;AAlIV,SAAS,oBAAoB;AAC7B,S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QAEJ,GACF;AAAA,QAEA,qBAAC,SAAI,WAAU,mCACb;AAAA,8BAAC,YAAO,MAAK,UAAS,cAAY,QAAQ,SAAS,SAAS,SAAS,UAAU,WAAW,GAAG,SAAS,UAAU,GAAG,eAEnH;AAAA,UACA,oBAAC,YAAO,MAAK,UAAS,cAAY,QAAQ,UAAU,UAAU,SAAS,QAAQ,WAAW,GAAG,SAAS,UAAU,GAAG,eAEnH;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,SAAS;AAAA,cACT,WAAW,GAAG,SAAS,0FAA0F;AAAA,cAClH;AAAA;AAAA,UAED;AAAA,WACF;AAAA;AAAA;AAAA,EACF;AAGF,SAAO,aAAa,OAAO,SAAS,IAAI;AAC1C;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/numpad-sheet.tsx"],"sourcesContent":["import { createPortal } from \"react-dom\";\nimport { Delete } from \"lucide-react\";\nimport { useMemo } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { useEscapeKey } from \"../hooks/use-dismiss\";\nimport { evaluateExpression, formatResult, sanitizeLive } from \"../lib/calc\";\nimport {\n DEFAULT_CALCULATOR_LABELS,\n useKitLabels,\n type CalculatorLabels,\n} from \"../i18n/kit-labels\";\n\n/**\n * A full calculator keypad rendered as a bottom sheet — the mobile counterpart to\n * the desktop {@link CalculatorButton} popover, and the replacement for the old\n * under-the-field operator bar (`MathKeys`, feedback #334).\n *\n * A native app (YNAB) can swap the system keyboard for its own keypad; a PWA\n * cannot — but it CAN suppress the OS keyboard with `inputMode=\"none\"` on the\n * host field and paint its own keypad in the freed space. So the host input keeps\n * real focus/caret/selection + the existing value/commit contract, while this\n * sheet drives it: digits + operators + a live `= …` preview, evaluated through\n * the shared {@link evaluateExpression} engine. Desktop is untouched (it keeps the\n * native keyboard and the calculator popover); the host gates this to mobile.\n *\n * Buttons commit through the host's `onChange`/blur, so the sheet is stateless —\n * the field text is the single source of truth. `onPointerDown` preventDefault on\n * the root keeps the host input focused (caret stays, keyboard stays hidden) as\n * the user taps keys; the buttons' `onClick` still fires.\n */\n/** Names for the pad itself and its four non-digit keys. The first four are\n * screen-reader names; `done` is the one string here that is READ OFF THE SCREEN —\n * the brand-filled primary button — and it was a hardcoded English literal while\n * its three neighbours each took an override, so a German phone showed \"Done\"\n * among German labels with no prop able to change it. */\nexport interface NumberPadSheetLabels extends Partial<CalculatorLabels> {\n /** The pad's own name — the `calculator.panel` key under its older name here. */\n pad?: string;\n backspace?: string;\n clear?: string;\n equals?: string;\n /** Visible text on the primary key, not an `aria-label`. */\n done?: string;\n}\n\ntype PadKey =\n | { kind: \"ins\"; label: string; ins: string; accent?: boolean; name?: PadKeyName }\n | { kind: \"back\" };\n\n/** The {@link CalculatorLabels} key naming a non-digit key; digits are their glyph. */\ntype PadKeyName = \"plus\" | \"minus\" | \"times\" | \"divide\" | \"decimal\";\n\n// Insert chars that survive `sanitizeLive` (it keeps `× ÷` and ASCII `+ - * /`\n// but strips the unicode minus `−`, so minus inserts an ASCII \"-\" while showing\n// the nicer glyph). The evaluator normalises `× ÷` back to `* /`.\nconst PAD_KEYS: PadKey[] = [\n { kind: \"ins\", label: \"7\", ins: \"7\" },\n { kind: \"ins\", label: \"8\", ins: \"8\" },\n { kind: \"ins\", label: \"9\", ins: \"9\" },\n { kind: \"ins\", label: \"÷\", ins: \"÷\", accent: true, name: \"divide\" },\n { kind: \"ins\", label: \"4\", ins: \"4\" },\n { kind: \"ins\", label: \"5\", ins: \"5\" },\n { kind: \"ins\", label: \"6\", ins: \"6\" },\n { kind: \"ins\", label: \"×\", ins: \"×\", accent: true, name: \"times\" },\n { kind: \"ins\", label: \"1\", ins: \"1\" },\n { kind: \"ins\", label: \"2\", ins: \"2\" },\n { kind: \"ins\", label: \"3\", ins: \"3\" },\n { kind: \"ins\", label: \"−\", ins: \"-\", accent: true, name: \"minus\" },\n { kind: \"ins\", label: \".\", ins: \".\", name: \"decimal\" },\n { kind: \"ins\", label: \"0\", ins: \"0\" },\n { kind: \"back\" },\n { kind: \"ins\", label: \"+\", ins: \"+\", accent: true, name: \"plus\" },\n];\n\n/** Every key's shape — including the thing this pad used to delete without replacing.\n *\n * `focus:outline-none` alone is not a style choice, it is the removal of the only\n * signal a keyboard user has; on a 4×4 grid of identical tiles it leaves no way at all\n * to tell which key Enter is about to press (the audit's §a11y, and the same defect as\n * the dropdown search box).\n *\n * `focus-visible` and `ring-inset`, for the two reasons {@link ToggleGroup} already\n * writes down. This is a touch control first, and a plain `focus:` ring paints itself\n * on every TAP, because a tap focuses the button. And the keys sit 6px apart, which is\n * thinner than an outward ring plus the neighbour it would spill onto — inset keeps the\n * ring inside the key it describes.\n *\n * --brand rather than --border-strong: the operator keys are filled with --border, and\n * a ring in the colour of the thing it surrounds is not an indicator. */\nconst PAD_BTN =\n \"flex h-14 items-center justify-center rounded-lg text-lg font-medium transition-transform select-none focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--brand)] active:scale-[0.97]\";\nconst PAD_DIGIT = \"bg-[var(--bg-surface-2)] text-[var(--text-primary)] active:bg-[var(--border)]\";\nconst PAD_ACCENT = \"bg-[var(--border)] text-[var(--text-primary)] active:bg-[var(--bg-surface-2)]\";\n\nexport function NumberPadSheet({\n value,\n onChange,\n onDone,\n label,\n labels,\n}: {\n value: string;\n /** Fired with the raw (sanitised) field text on every key — same contract as\n * the host field's own `onChange`. */\n onChange: (value: string) => void;\n /** Fired on \"Done\": the host blurs the input, which commits (evaluates) and\n * unmounts the sheet via its existing blur handler. */\n onDone: () => void;\n /** Optional field label, echoed in the sheet header so the user still knows\n * which field they're editing when the sheet covers it. */\n label?: ReactNode;\n /** Names for the pad itself and its non-digit keys — screen-reader names, except\n * `done`, which is the visible text on the primary key. Merged over `calculator`\n * from `<UiKitProvider labels>`: this is the same keypad as `CalculatorButton`'s,\n * on a phone, and one translation covers both. Digits need no name — their glyph\n * IS the name; the operators do (see {@link CalculatorLabels.plus}). */\n labels?: NumberPadSheetLabels;\n}) {\n // `pad` is this sheet's older spelling of `panel`, so it is folded in as that.\n const fromProps = useMemo(() => {\n if (!labels) return undefined;\n const { pad, ...rest } = labels;\n return pad === undefined ? rest : { ...rest, panel: pad };\n }, [labels]);\n const text = useKitLabels(\"calculator\", DEFAULT_CALCULATOR_LABELS, fromProps);\n\n // NO `useBodyScrollLock`, and that is the point of the control (Keksdose live\n // #317: *\"Background not scrollable when the amount input calculator field is\n // open\"*).\n //\n // This sheet is a KEYBOARD, not a dialog. It is opened by focusing a field and\n // exists only because a PWA cannot swap the system keyboard for its own — so it\n // suppresses the OS keyboard with `inputMode=\"none\"` and paints itself in the\n // freed space. An OS keyboard does not freeze the page behind it; it takes the\n // bottom of the screen and leaves you free to scroll what is left, which is how\n // you reach the field you are typing into when the keys cover it.\n //\n // Locking here made the page unreachable at exactly the moment it matters most:\n // correcting a receipt total against the running line sum, where the figure you\n // are comparing against sits below the keypad. The other four holders of that\n // hook are all modal — `Modal`, `PickerSheet`, `FullBleedDialog`, the DataTable\n // row dialog — and they stay locked, because for them the page behind is not\n // part of the task.\n //\n // The pad still does not scroll ITSELF away under a stray drag: the root's\n // `onPointerDown` preventDefault (below) keeps the host input focused and eats\n // the gesture on the sheet, so a touch that starts on a key is not a page scroll.\n\n // ── NO focus trap either, and for a harder reason than the scroll lock ────────\n //\n // Wave 3 put `useFocusTrap` on every overlay in this package. This one is the\n // exception, and it is not an oversight to be tidied up later: a trap here would\n // DELETE THE COMPONENT IT WAS PROTECTING. Both hosts render the pad with\n // `showNumpad = isMobile && !disabled && focused`, where `focused` is the host\n // input's own focus state. Moving focus into the pad blurs that input, the host\n // sets `focused` false, and the pad unmounts — on mount, before a single key can be\n // pressed. The blur also COMMITS, so the trap would evaluate a half-typed\n // expression on the way out.\n //\n // That is the contract, not an accident of it. This sheet exists because a PWA\n // cannot swap the system keyboard for its own: the host keeps real focus, caret and\n // selection while `inputMode=\"none\"` suppresses the OS keys, and the root's\n // `onPointerDown` preventDefault below is there for the same reason. The pad is\n // `role=\"group\"`, not a dialog. A keyboard does not trap focus; it is what you type\n // WITH.\n //\n // What was genuinely missing is a way OUT that is not a tap. `useEscapeKey` and not\n // a handler on the sheet, because the sheet never has the focus a keydown would\n // bubble from — the host does, and the host is not this component. Escape does what\n // the Done key does rather than cancelling, because committing on blur is the\n // host's contract and a cancel would have to be the host's to offer.\n //\n // The limit, since it is better written down than discovered: inside a `Modal` the\n // dialog's own Escape handler sits on the focus path and stops the event before a\n // document listener sees it, so there the press closes the dialog — which it did\n // before this line existed too, and which takes the pad with it either way.\n useEscapeKey(onDone);\n\n const result = evaluateExpression(value);\n const preview = result !== null && formatResult(result) !== value.trim() ? `= ${formatResult(result)}` : \"\";\n\n const insert = (ch: string) => onChange(sanitizeLive(value + ch));\n const backspace = () => onChange(value.slice(0, -1));\n const clearAll = () => onChange(\"\");\n const equals = () => {\n if (result !== null) onChange(formatResult(result));\n };\n\n const sheet = (\n <div\n role=\"group\"\n aria-label={text.panel}\n // Keep the host input focused when tapping the pad: preventDefault on\n // pointerdown blocks the focus/blur, while the buttons' click still fires.\n onPointerDown={(e) => e.preventDefault()}\n className=\"fixed inset-x-0 bottom-0 z-50 border-t border-[var(--border)] bg-[var(--bg-surface)] px-2 pt-2 shadow-[0_-4px_24px_rgba(0,0,0,0.12)]\"\n style={{ paddingBottom: \"max(0.5rem, env(safe-area-inset-bottom))\" }}\n >\n {/* Header display: which field + the running expression and live result, so\n the value stays visible even when the sheet covers the field. */}\n <div className=\"flex items-end justify-between gap-3 px-2 pb-2\">\n {label != null && (\n <span className=\"truncate pb-1 text-xs font-medium text-[var(--money-neutral)]\">{label}</span>\n )}\n <div className=\"ml-auto min-w-0 text-right\">\n <div className=\"truncate font-mono text-lg leading-tight text-[var(--text-primary)]\">{value || \"0\"}</div>\n <div className=\"h-4 font-mono text-xs text-[var(--money-neutral)]\">{preview}</div>\n </div>\n </div>\n\n <div className=\"grid grid-cols-4 gap-1.5\">\n {PAD_KEYS.map((key, i) =>\n key.kind === \"back\" ? (\n <button\n key=\"back\"\n type=\"button\"\n aria-label={text.backspace}\n onClick={backspace}\n className={cn(PAD_BTN, PAD_ACCENT)}\n >\n <Delete className=\"size-5\" />\n </button>\n ) : (\n <button\n key={`${key.ins}-${i}`}\n type=\"button\"\n aria-label={key.name ? text[key.name] : key.label}\n onClick={() => insert(key.ins)}\n className={cn(PAD_BTN, key.accent ? PAD_ACCENT : PAD_DIGIT)}\n >\n {key.label}\n </button>\n ),\n )}\n </div>\n\n <div className=\"mt-1.5 grid grid-cols-4 gap-1.5\">\n <button type=\"button\" aria-label={text.clear} onClick={clearAll} className={cn(PAD_BTN, PAD_ACCENT)}>\n C\n </button>\n <button type=\"button\" aria-label={text.equals} onClick={equals} className={cn(PAD_BTN, PAD_ACCENT)}>\n =\n </button>\n <button\n type=\"button\"\n onClick={onDone}\n // The one key whose own fill is --brand, so it rings in the colour that fill\n // was chosen to be legible against instead (tailwind-merge keeps the later\n // ring colour). A --brand ring here would be present in the DOM and invisible\n // on screen, which is the defect this change exists to fix.\n className={cn(\n PAD_BTN,\n \"col-span-2 bg-[var(--brand)] text-[var(--brand-contrast)] focus-visible:ring-[var(--brand-contrast)] active:bg-[var(--brand-hover)]\",\n )}\n >\n {text.done}\n </button>\n </div>\n </div>\n );\n\n return createPortal(sheet, document.body);\n}\n"],"mappings":";AA2MU,cAEF,YAFE;AA3MV,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,eAAe;AAExB,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB,cAAc,oBAAoB;AAC/D;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AA6CP,MAAM,WAAqB;AAAA,EACzB,EAAE,MAAM,OAAO,OAAO,KAAK,KAAK,IAAI;AAAA,EACpC,EAAE,MAAM,OAAO,OAAO,KAAK,KAAK,IAAI;AAAA,EACpC,EAAE,MAAM,OAAO,OAAO,KAAK,KAAK,IAAI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AI,SAAS,aAAa,SAAS;AAAA,cAEzD,cAAI;AAAA;AAAA,YANA,GAAG,IAAI,GAAG,IAAI,CAAC;AAAA,UAOtB;AAAA,QAEJ,GACF;AAAA,QAEA,qBAAC,SAAI,WAAU,mCACb;AAAA,8BAAC,YAAO,MAAK,UAAS,cAAY,KAAK,OAAO,SAAS,UAAU,WAAW,GAAG,SAAS,UAAU,GAAG,eAErG;AAAA,UACA,oBAAC,YAAO,MAAK,UAAS,cAAY,KAAK,QAAQ,SAAS,QAAQ,WAAW,GAAG,SAAS,UAAU,GAAG,eAEpG;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,SAAS;AAAA,cAKT,WAAW;AAAA,gBACT;AAAA,gBACA;AAAA,cACF;AAAA,cAEC,eAAK;AAAA;AAAA,UACR;AAAA,WACF;AAAA;AAAA;AAAA,EACF;AAGF,SAAO,aAAa,OAAO,SAAS,IAAI;AAC1C;","names":[]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* "On this page": a page's own table of contents, with the section being read marked.
|
|
6
|
+
*
|
|
7
|
+
* Three parts, because an app needs them separately:
|
|
8
|
+
*
|
|
9
|
+
* - {@link useScrollSpy} — which section is current, from the headings' positions in
|
|
10
|
+
* a scroll container. No markup; usable for anything that follows the reader.
|
|
11
|
+
* - {@link PageContents} — the list. `variant="rail"` for beside the page,
|
|
12
|
+
* `variant="disclosure"` for a collapsed block under the title on narrow screens.
|
|
13
|
+
* - {@link PageContentsLayout} — the page with the rail sticky on one side of it.
|
|
14
|
+
*
|
|
15
|
+
* Domain-free: the app supplies the entries and how an entry links (`hrefFor`), so it
|
|
16
|
+
* works with any router, including a hash router where `#id` alone would be read as a
|
|
17
|
+
* route.
|
|
18
|
+
*/
|
|
19
|
+
interface PageContentsItem {
|
|
20
|
+
/** The id of the heading the entry jumps to. */
|
|
21
|
+
id: string;
|
|
22
|
+
label: ReactNode;
|
|
23
|
+
/** 2 indents the entry under the one before it. */
|
|
24
|
+
level?: 1 | 2;
|
|
25
|
+
}
|
|
26
|
+
interface PageContentsLabels {
|
|
27
|
+
/** The heading above the list, and the landmark's accessible name. */
|
|
28
|
+
title: string;
|
|
29
|
+
}
|
|
30
|
+
declare const DEFAULT_PAGE_CONTENTS_LABELS: PageContentsLabels;
|
|
31
|
+
interface UseScrollSpyOptions {
|
|
32
|
+
/** The element that scrolls. Defaults to the viewport. In `AppShell`, pass its
|
|
33
|
+
* `<main>` — it is the page's scroll container from `md` up. */
|
|
34
|
+
root?: Element | null;
|
|
35
|
+
/**
|
|
36
|
+
* How far down the scroller the "reading line" sits, as a fraction of its height.
|
|
37
|
+
* A section becomes current once its heading passes above it, and stays current
|
|
38
|
+
* until the next heading does — so a long section keeps its entry marked while it
|
|
39
|
+
* is being read, not only while its heading is on screen. Default 0.15: close to
|
|
40
|
+
* the top, so a short section followed by another does not hand its mark to the
|
|
41
|
+
* next one the moment it is scrolled to.
|
|
42
|
+
*/
|
|
43
|
+
line?: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The id of the section being read: the last of `ids` whose element has scrolled
|
|
47
|
+
* above the reading line — or the first, before any has.
|
|
48
|
+
*/
|
|
49
|
+
declare function useScrollSpy(ids: readonly string[], options?: UseScrollSpyOptions): string | null;
|
|
50
|
+
interface PageContentsProps extends Omit<ComponentPropsWithoutRef<"nav">, "children"> {
|
|
51
|
+
items: PageContentsItem[];
|
|
52
|
+
/** The current entry — typically `useScrollSpy(items.map(i => i.id), …)`. */
|
|
53
|
+
activeId?: string | null;
|
|
54
|
+
/** The link for an entry. Default `#id`; under a hash router build it with the
|
|
55
|
+
* router (react-router's `useHref({ hash: id })` gives `#/page#id`). */
|
|
56
|
+
hrefFor?: (id: string) => string;
|
|
57
|
+
/** `rail` — a list beside the page. `disclosure` — collapsed under a summary line,
|
|
58
|
+
* for narrow screens where a rail has no room. */
|
|
59
|
+
variant?: "rail" | "disclosure";
|
|
60
|
+
labels?: Partial<PageContentsLabels>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The list itself. The current entry gets a brand bar on the list's rule, the brand
|
|
64
|
+
* colour, and `aria-current="location"` — the marker documentation sites use, and the
|
|
65
|
+
* one a screen reader announces.
|
|
66
|
+
*/
|
|
67
|
+
declare function PageContents({ items, activeId, hrefFor, variant, labels, className, ...rest }: PageContentsProps): react.JSX.Element | null;
|
|
68
|
+
interface PageContentsLayoutProps extends ComponentPropsWithoutRef<"div"> {
|
|
69
|
+
/** What goes in the rail — typically a `<PageContents variant="rail">`. */
|
|
70
|
+
contents: ReactNode;
|
|
71
|
+
/**
|
|
72
|
+
* Which side of the page the rail sits on: `start` is the left in a left-to-right
|
|
73
|
+
* language (next to the app's own sidebar, so both navigations are in one place),
|
|
74
|
+
* `end` the right (the documentation-site convention, clear of the sidebar). Logical,
|
|
75
|
+
* so both flip in a right-to-left UI.
|
|
76
|
+
*/
|
|
77
|
+
position?: "start" | "end";
|
|
78
|
+
children: ReactNode;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The page with a sticky contents rail beside it, from `xl` (1280px) up. Below that
|
|
82
|
+
* the rail would squeeze the content, so it is not rendered there — pair it with a
|
|
83
|
+
* `<PageContents variant="disclosure" className="xl:hidden">` in the page.
|
|
84
|
+
*
|
|
85
|
+
* The rail is `sticky top-6`, which sticks inside the nearest scroll container — the
|
|
86
|
+
* viewport, or `AppShell`'s `<main>`.
|
|
87
|
+
*/
|
|
88
|
+
declare function PageContentsLayout({ contents, position, children, className, ...rest }: PageContentsLayoutProps): react.JSX.Element;
|
|
89
|
+
|
|
90
|
+
export { DEFAULT_PAGE_CONTENTS_LABELS, PageContents, type PageContentsItem, type PageContentsLabels, PageContentsLayout, type PageContentsLayoutProps, type PageContentsProps, type UseScrollSpyOptions, useScrollSpy };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { ChevronDown } from "lucide-react";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { useKitLabels } from "../i18n/kit-labels.js";
|
|
7
|
+
const DEFAULT_PAGE_CONTENTS_LABELS = {
|
|
8
|
+
title: "On this page"
|
|
9
|
+
};
|
|
10
|
+
function useScrollSpy(ids, options = {}) {
|
|
11
|
+
const { root = null, line = 0.15 } = options;
|
|
12
|
+
const [current, setCurrent] = useState(null);
|
|
13
|
+
const key = ids.join("\0");
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (ids.length === 0) return;
|
|
16
|
+
const scroller = root ?? window;
|
|
17
|
+
const measure = () => {
|
|
18
|
+
const top = root ? root.getBoundingClientRect().top : 0;
|
|
19
|
+
const height = root ? root.clientHeight : window.innerHeight;
|
|
20
|
+
const reading = top + height * line;
|
|
21
|
+
let next = ids[0];
|
|
22
|
+
for (const id of ids) {
|
|
23
|
+
const el = document.getElementById(id);
|
|
24
|
+
if (el && el.getBoundingClientRect().top <= reading) next = id;
|
|
25
|
+
}
|
|
26
|
+
const atEnd = root ? root.scrollTop + root.clientHeight >= root.scrollHeight - 2 : window.scrollY + window.innerHeight >= document.documentElement.scrollHeight - 2;
|
|
27
|
+
const scrolled = root ? root.scrollTop : window.scrollY;
|
|
28
|
+
if (atEnd && scrolled > 0) next = ids[ids.length - 1];
|
|
29
|
+
setCurrent(next);
|
|
30
|
+
};
|
|
31
|
+
let frame = 0;
|
|
32
|
+
const onScroll = () => {
|
|
33
|
+
cancelAnimationFrame(frame);
|
|
34
|
+
frame = requestAnimationFrame(measure);
|
|
35
|
+
};
|
|
36
|
+
measure();
|
|
37
|
+
scroller.addEventListener("scroll", onScroll, { passive: true });
|
|
38
|
+
window.addEventListener("resize", onScroll);
|
|
39
|
+
return () => {
|
|
40
|
+
cancelAnimationFrame(frame);
|
|
41
|
+
scroller.removeEventListener("scroll", onScroll);
|
|
42
|
+
window.removeEventListener("resize", onScroll);
|
|
43
|
+
};
|
|
44
|
+
}, [key, root, line]);
|
|
45
|
+
return current;
|
|
46
|
+
}
|
|
47
|
+
function PageContents({
|
|
48
|
+
items,
|
|
49
|
+
activeId,
|
|
50
|
+
hrefFor = (id) => `#${id}`,
|
|
51
|
+
variant = "rail",
|
|
52
|
+
labels,
|
|
53
|
+
className,
|
|
54
|
+
...rest
|
|
55
|
+
}) {
|
|
56
|
+
const l = useKitLabels("pageContents", DEFAULT_PAGE_CONTENTS_LABELS, labels);
|
|
57
|
+
const listRef = useRef(null);
|
|
58
|
+
const [clicked, setClicked] = useState(null);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (!clicked) return;
|
|
61
|
+
const release = () => setClicked(null);
|
|
62
|
+
window.addEventListener("wheel", release, { passive: true, once: true });
|
|
63
|
+
window.addEventListener("touchmove", release, { passive: true, once: true });
|
|
64
|
+
window.addEventListener("keydown", release, { once: true });
|
|
65
|
+
return () => {
|
|
66
|
+
window.removeEventListener("wheel", release);
|
|
67
|
+
window.removeEventListener("touchmove", release);
|
|
68
|
+
window.removeEventListener("keydown", release);
|
|
69
|
+
};
|
|
70
|
+
}, [clicked]);
|
|
71
|
+
const shown = clicked ?? activeId;
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!shown || variant !== "rail") return;
|
|
74
|
+
listRef.current?.querySelector(`[data-entry="${CSS.escape(shown)}"]`)?.scrollIntoView?.({ block: "nearest" });
|
|
75
|
+
}, [shown, variant]);
|
|
76
|
+
if (items.length === 0) return null;
|
|
77
|
+
const list = /* @__PURE__ */ jsx(
|
|
78
|
+
"ul",
|
|
79
|
+
{
|
|
80
|
+
ref: listRef,
|
|
81
|
+
className: cn(
|
|
82
|
+
"space-y-0.5 border-s border-[var(--border)]",
|
|
83
|
+
variant === "rail" && "max-h-[calc(100dvh-10rem)] overflow-y-auto [scrollbar-width:thin]"
|
|
84
|
+
),
|
|
85
|
+
children: items.map((item) => {
|
|
86
|
+
const current = item.id === shown;
|
|
87
|
+
return /* @__PURE__ */ jsx("li", { "data-entry": item.id, children: /* @__PURE__ */ jsx(
|
|
88
|
+
"a",
|
|
89
|
+
{
|
|
90
|
+
href: hrefFor(item.id),
|
|
91
|
+
title: variant === "rail" && typeof item.label === "string" ? item.label : void 0,
|
|
92
|
+
"aria-current": current ? "location" : void 0,
|
|
93
|
+
onClick: () => setClicked(item.id),
|
|
94
|
+
className: cn(
|
|
95
|
+
"-ms-px block border-s-2 py-1 pe-1 text-[13px] leading-snug transition-colors duration-150",
|
|
96
|
+
variant === "rail" && "truncate",
|
|
97
|
+
item.level === 2 ? "ps-6" : "ps-3",
|
|
98
|
+
current ? "border-[var(--brand)] font-medium text-[var(--brand)]" : "border-transparent text-[var(--text-muted)] hover:border-[var(--border-strong)] hover:text-[var(--text-primary)]"
|
|
99
|
+
),
|
|
100
|
+
children: item.label
|
|
101
|
+
}
|
|
102
|
+
) }, item.id);
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
if (variant === "disclosure") {
|
|
107
|
+
return /* @__PURE__ */ jsxs(
|
|
108
|
+
"details",
|
|
109
|
+
{
|
|
110
|
+
className: cn(
|
|
111
|
+
"group rounded-md border border-[var(--border)] bg-[var(--bg-surface)]",
|
|
112
|
+
className
|
|
113
|
+
),
|
|
114
|
+
children: [
|
|
115
|
+
/* @__PURE__ */ jsxs("summary", { className: "flex cursor-pointer list-none items-center justify-between px-3 py-2 text-sm font-medium text-[var(--text-secondary)] [&::-webkit-details-marker]:hidden", children: [
|
|
116
|
+
l.title,
|
|
117
|
+
/* @__PURE__ */ jsx(
|
|
118
|
+
ChevronDown,
|
|
119
|
+
{
|
|
120
|
+
"aria-hidden": true,
|
|
121
|
+
className: "size-4 transition-transform duration-200 group-open:rotate-180 motion-reduce:transition-none"
|
|
122
|
+
}
|
|
123
|
+
)
|
|
124
|
+
] }),
|
|
125
|
+
/* @__PURE__ */ jsx("nav", { ...rest, "aria-label": l.title, className: "border-t border-[var(--border)] px-2 py-2", children: list })
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
return /* @__PURE__ */ jsxs("nav", { ...rest, "aria-label": l.title, className, children: [
|
|
131
|
+
/* @__PURE__ */ jsx("p", { className: "mb-2 text-[11px] font-semibold uppercase tracking-wide text-[var(--text-muted)]", children: l.title }),
|
|
132
|
+
list
|
|
133
|
+
] });
|
|
134
|
+
}
|
|
135
|
+
function PageContentsLayout({
|
|
136
|
+
contents,
|
|
137
|
+
position = "start",
|
|
138
|
+
children,
|
|
139
|
+
className,
|
|
140
|
+
...rest
|
|
141
|
+
}) {
|
|
142
|
+
const rail = /* @__PURE__ */ jsx("aside", { className: "hidden xl:block", children: /* @__PURE__ */ jsx("div", { className: "sticky top-6", children: contents }) });
|
|
143
|
+
return /* @__PURE__ */ jsxs(
|
|
144
|
+
"div",
|
|
145
|
+
{
|
|
146
|
+
...rest,
|
|
147
|
+
className: cn(
|
|
148
|
+
"xl:grid xl:gap-10",
|
|
149
|
+
// `fit-content(22rem)`: the rail is as wide as its longest entry, up to 22rem.
|
|
150
|
+
// A fixed 13rem broke "Select — unlabelled, labelled, invalid, disabled" over
|
|
151
|
+
// three lines beside a page with room to spare; an index you scan should read
|
|
152
|
+
// one entry per line.
|
|
153
|
+
position === "start" ? "xl:grid-cols-[fit-content(22rem)_minmax(0,1fr)]" : "xl:grid-cols-[minmax(0,1fr)_fit-content(22rem)]",
|
|
154
|
+
className
|
|
155
|
+
),
|
|
156
|
+
children: [
|
|
157
|
+
position === "start" && rail,
|
|
158
|
+
/* @__PURE__ */ jsx("div", { className: "min-w-0", children }),
|
|
159
|
+
position === "end" && rail
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
export {
|
|
165
|
+
DEFAULT_PAGE_CONTENTS_LABELS,
|
|
166
|
+
PageContents,
|
|
167
|
+
PageContentsLayout,
|
|
168
|
+
useScrollSpy
|
|
169
|
+
};
|
|
170
|
+
//# sourceMappingURL=page-contents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/page-contents.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { ChevronDown } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\n\n/**\n * \"On this page\": a page's own table of contents, with the section being read marked.\n *\n * Three parts, because an app needs them separately:\n *\n * - {@link useScrollSpy} — which section is current, from the headings' positions in\n * a scroll container. No markup; usable for anything that follows the reader.\n * - {@link PageContents} — the list. `variant=\"rail\"` for beside the page,\n * `variant=\"disclosure\"` for a collapsed block under the title on narrow screens.\n * - {@link PageContentsLayout} — the page with the rail sticky on one side of it.\n *\n * Domain-free: the app supplies the entries and how an entry links (`hrefFor`), so it\n * works with any router, including a hash router where `#id` alone would be read as a\n * route.\n */\n\nexport interface PageContentsItem {\n /** The id of the heading the entry jumps to. */\n id: string;\n label: ReactNode;\n /** 2 indents the entry under the one before it. */\n level?: 1 | 2;\n}\n\nexport interface PageContentsLabels {\n /** The heading above the list, and the landmark's accessible name. */\n title: string;\n}\n\nexport const DEFAULT_PAGE_CONTENTS_LABELS: PageContentsLabels = {\n title: \"On this page\",\n};\n\nexport interface UseScrollSpyOptions {\n /** The element that scrolls. Defaults to the viewport. In `AppShell`, pass its\n * `<main>` — it is the page's scroll container from `md` up. */\n root?: Element | null;\n /**\n * How far down the scroller the \"reading line\" sits, as a fraction of its height.\n * A section becomes current once its heading passes above it, and stays current\n * until the next heading does — so a long section keeps its entry marked while it\n * is being read, not only while its heading is on screen. Default 0.15: close to\n * the top, so a short section followed by another does not hand its mark to the\n * next one the moment it is scrolled to.\n */\n line?: number;\n}\n\n/**\n * The id of the section being read: the last of `ids` whose element has scrolled\n * above the reading line — or the first, before any has.\n */\nexport function useScrollSpy(ids: readonly string[], options: UseScrollSpyOptions = {}): string | null {\n const { root = null, line = 0.15 } = options;\n const [current, setCurrent] = useState<string | null>(null);\n const key = ids.join(\"\\u0000\");\n\n useEffect(() => {\n if (ids.length === 0) return;\n const scroller: Element | Window = root ?? window;\n const measure = () => {\n const top = root ? root.getBoundingClientRect().top : 0;\n const height = root ? root.clientHeight : window.innerHeight;\n const reading = top + height * line;\n let next = ids[0];\n for (const id of ids) {\n const el = document.getElementById(id);\n if (el && el.getBoundingClientRect().top <= reading) next = id;\n }\n // At the very bottom the last sections may never reach the line; the reader\n // who scrolled to the end is reading the end.\n const atEnd = root\n ? root.scrollTop + root.clientHeight >= root.scrollHeight - 2\n : window.scrollY + window.innerHeight >= document.documentElement.scrollHeight - 2;\n const scrolled = root ? root.scrollTop : window.scrollY;\n if (atEnd && scrolled > 0) next = ids[ids.length - 1];\n setCurrent(next);\n };\n let frame = 0;\n const onScroll = () => {\n cancelAnimationFrame(frame);\n frame = requestAnimationFrame(measure);\n };\n measure();\n scroller.addEventListener(\"scroll\", onScroll, { passive: true });\n window.addEventListener(\"resize\", onScroll);\n return () => {\n cancelAnimationFrame(frame);\n scroller.removeEventListener(\"scroll\", onScroll);\n window.removeEventListener(\"resize\", onScroll);\n };\n // `key` stands for `ids`: a new array with the same entries is the same list.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [key, root, line]);\n\n return current;\n}\n\nexport interface PageContentsProps extends Omit<ComponentPropsWithoutRef<\"nav\">, \"children\"> {\n items: PageContentsItem[];\n /** The current entry — typically `useScrollSpy(items.map(i => i.id), …)`. */\n activeId?: string | null;\n /** The link for an entry. Default `#id`; under a hash router build it with the\n * router (react-router's `useHref({ hash: id })` gives `#/page#id`). */\n hrefFor?: (id: string) => string;\n /** `rail` — a list beside the page. `disclosure` — collapsed under a summary line,\n * for narrow screens where a rail has no room. */\n variant?: \"rail\" | \"disclosure\";\n labels?: Partial<PageContentsLabels>;\n}\n\n/**\n * The list itself. The current entry gets a brand bar on the list's rule, the brand\n * colour, and `aria-current=\"location\"` — the marker documentation sites use, and the\n * one a screen reader announces.\n */\nexport function PageContents({\n items,\n activeId,\n hrefFor = (id) => `#${id}`,\n variant = \"rail\",\n labels,\n className,\n ...rest\n}: PageContentsProps) {\n const l = useKitLabels(\"pageContents\", DEFAULT_PAGE_CONTENTS_LABELS, labels);\n const listRef = useRef<HTMLUListElement>(null);\n // The entry just clicked is the current one until the reader scrolls on their own.\n // Without this, jumping to a short section near the end of a page marks whichever\n // later section the jump also carried past the reading line — you click one entry\n // and another lights up.\n const [clicked, setClicked] = useState<string | null>(null);\n useEffect(() => {\n if (!clicked) return;\n const release = () => setClicked(null);\n // A user scroll — wheel, touch, keys — releases it; the programmatic scroll the\n // jump itself causes does not fire these.\n window.addEventListener(\"wheel\", release, { passive: true, once: true });\n window.addEventListener(\"touchmove\", release, { passive: true, once: true });\n window.addEventListener(\"keydown\", release, { once: true });\n return () => {\n window.removeEventListener(\"wheel\", release);\n window.removeEventListener(\"touchmove\", release);\n window.removeEventListener(\"keydown\", release);\n };\n }, [clicked]);\n const shown = clicked ?? activeId;\n\n // Keep the current entry in view when the list is taller than the window.\n useEffect(() => {\n if (!shown || variant !== \"rail\") return;\n listRef.current\n ?.querySelector<HTMLElement>(`[data-entry=\"${CSS.escape(shown)}\"]`)\n ?.scrollIntoView?.({ block: \"nearest\" });\n }, [shown, variant]);\n\n if (items.length === 0) return null;\n\n const list = (\n <ul\n ref={listRef}\n className={cn(\n \"space-y-0.5 border-s border-[var(--border)]\",\n variant === \"rail\" && \"max-h-[calc(100dvh-10rem)] overflow-y-auto [scrollbar-width:thin]\",\n )}\n >\n {items.map((item) => {\n const current = item.id === shown;\n return (\n <li key={item.id} data-entry={item.id}>\n <a\n href={hrefFor(item.id)}\n // One line per entry in the rail; past 22rem the ellipsis takes over and\n // the full text is on hover. The disclosure has the page's width and wraps.\n title={variant === \"rail\" && typeof item.label === \"string\" ? item.label : undefined}\n aria-current={current ? \"location\" : undefined}\n onClick={() => setClicked(item.id)}\n className={cn(\n \"-ms-px block border-s-2 py-1 pe-1 text-[13px] leading-snug transition-colors duration-150\",\n variant === \"rail\" && \"truncate\",\n item.level === 2 ? \"ps-6\" : \"ps-3\",\n current\n ? \"border-[var(--brand)] font-medium text-[var(--brand)]\"\n : \"border-transparent text-[var(--text-muted)] hover:border-[var(--border-strong)] hover:text-[var(--text-primary)]\",\n )}\n >\n {item.label}\n </a>\n </li>\n );\n })}\n </ul>\n );\n\n if (variant === \"disclosure\") {\n return (\n <details\n className={cn(\n \"group rounded-md border border-[var(--border)] bg-[var(--bg-surface)]\",\n className,\n )}\n >\n <summary className=\"flex cursor-pointer list-none items-center justify-between px-3 py-2 text-sm font-medium text-[var(--text-secondary)] [&::-webkit-details-marker]:hidden\">\n {l.title}\n <ChevronDown\n aria-hidden\n className=\"size-4 transition-transform duration-200 group-open:rotate-180 motion-reduce:transition-none\"\n />\n </summary>\n <nav {...rest} aria-label={l.title} className=\"border-t border-[var(--border)] px-2 py-2\">\n {list}\n </nav>\n </details>\n );\n }\n\n return (\n <nav {...rest} aria-label={l.title} className={className}>\n <p className=\"mb-2 text-[11px] font-semibold uppercase tracking-wide text-[var(--text-muted)]\">\n {l.title}\n </p>\n {list}\n </nav>\n );\n}\n\nexport interface PageContentsLayoutProps extends ComponentPropsWithoutRef<\"div\"> {\n /** What goes in the rail — typically a `<PageContents variant=\"rail\">`. */\n contents: ReactNode;\n /**\n * Which side of the page the rail sits on: `start` is the left in a left-to-right\n * language (next to the app's own sidebar, so both navigations are in one place),\n * `end` the right (the documentation-site convention, clear of the sidebar). Logical,\n * so both flip in a right-to-left UI.\n */\n position?: \"start\" | \"end\";\n children: ReactNode;\n}\n\n/**\n * The page with a sticky contents rail beside it, from `xl` (1280px) up. Below that\n * the rail would squeeze the content, so it is not rendered there — pair it with a\n * `<PageContents variant=\"disclosure\" className=\"xl:hidden\">` in the page.\n *\n * The rail is `sticky top-6`, which sticks inside the nearest scroll container — the\n * viewport, or `AppShell`'s `<main>`.\n */\nexport function PageContentsLayout({\n contents,\n position = \"start\",\n children,\n className,\n ...rest\n}: PageContentsLayoutProps) {\n // In DOM order on its side, not moved there with `order`: Tab and a screen reader\n // follow the source, and a rail painted on the left but read after the page would\n // put the page's index at its end.\n const rail = (\n <aside className=\"hidden xl:block\">\n <div className=\"sticky top-6\">{contents}</div>\n </aside>\n );\n return (\n <div\n {...rest}\n className={cn(\n \"xl:grid xl:gap-10\",\n // `fit-content(22rem)`: the rail is as wide as its longest entry, up to 22rem.\n // A fixed 13rem broke \"Select — unlabelled, labelled, invalid, disabled\" over\n // three lines beside a page with room to spare; an index you scan should read\n // one entry per line.\n position === \"start\"\n ? \"xl:grid-cols-[fit-content(22rem)_minmax(0,1fr)]\"\n : \"xl:grid-cols-[minmax(0,1fr)_fit-content(22rem)]\",\n className,\n )}\n >\n {position === \"start\" && rail}\n <div className=\"min-w-0\">{children}</div>\n {position === \"end\" && rail}\n </div>\n );\n}\n"],"mappings":";AAgLY,cAgCJ,YAhCI;AAhLZ,SAAS,WAAW,QAAQ,gBAAgB;AAE5C,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AACnB,SAAS,oBAAoB;AA+BtB,MAAM,+BAAmD;AAAA,EAC9D,OAAO;AACT;AAqBO,SAAS,aAAa,KAAwB,UAA+B,CAAC,GAAkB;AACrG,QAAM,EAAE,OAAO,MAAM,OAAO,KAAK,IAAI;AACrC,QAAM,CAAC,SAAS,UAAU,IAAI,SAAwB,IAAI;AAC1D,QAAM,MAAM,IAAI,KAAK,IAAQ;AAE7B,YAAU,MAAM;AACd,QAAI,IAAI,WAAW,EAAG;AACtB,UAAM,WAA6B,QAAQ;AAC3C,UAAM,UAAU,MAAM;AACpB,YAAM,MAAM,OAAO,KAAK,sBAAsB,EAAE,MAAM;AACtD,YAAM,SAAS,OAAO,KAAK,eAAe,OAAO;AACjD,YAAM,UAAU,M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