@eifi1/ui-kit 0.21.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -25
- package/dist/chart.d.ts +19 -14
- package/dist/components/account-chips.d.ts +10 -3
- package/dist/components/account-chips.js +5 -2
- package/dist/components/account-chips.js.map +1 -1
- package/dist/components/account-settings.d.ts +33 -2
- package/dist/components/account-settings.js +43 -21
- package/dist/components/account-settings.js.map +1 -1
- package/dist/components/amount-input.d.ts +53 -14
- package/dist/components/amount-input.js +17 -28
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/autocomplete.d.ts +29 -0
- package/dist/components/autocomplete.js +134 -104
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/button-group.d.ts +19 -14
- package/dist/components/calculator.d.ts +19 -14
- package/dist/components/checkbox-group.d.ts +104 -0
- package/dist/components/checkbox-group.js +111 -0
- package/dist/components/checkbox-group.js.map +1 -0
- package/dist/components/checkbox.d.ts +19 -0
- package/dist/components/checkbox.js +30 -7
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/chip.d.ts +18 -0
- package/dist/components/chip.js +47 -10
- package/dist/components/chip.js.map +1 -1
- package/dist/components/column-mapper.d.ts +182 -0
- package/dist/components/column-mapper.js +375 -0
- package/dist/components/column-mapper.js.map +1 -0
- package/dist/components/combobox-core.d.ts +39 -2
- package/dist/components/combobox-core.js +29 -6
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox.d.ts +91 -2
- package/dist/components/combobox.js +454 -308
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/confirm-dialog.d.ts +69 -161
- package/dist/components/confirm-dialog.js +7 -8
- package/dist/components/confirm-dialog.js.map +1 -1
- package/dist/components/copy-button.d.ts +16 -11
- package/dist/components/country-select.d.ts +167 -0
- package/dist/components/country-select.js +293 -0
- package/dist/components/country-select.js.map +1 -0
- package/dist/components/currency-select.d.ts +17 -1
- package/dist/components/currency-select.js +56 -23
- package/dist/components/currency-select.js.map +1 -1
- package/dist/components/danger-confirm.d.ts +69 -166
- package/dist/components/danger-confirm.js +144 -50
- package/dist/components/danger-confirm.js.map +1 -1
- package/dist/components/data-table-cells.d.ts +1 -2
- package/dist/components/data-table-filter-popover.d.ts +1 -2
- package/dist/components/data-table-filters.d.ts +1 -2
- package/dist/components/data-table-labels.d.ts +4 -97
- package/dist/components/data-table-labels.js +9 -1
- 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.d.ts +1 -2
- package/dist/components/data-table.js +98 -3
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.d.ts +66 -5
- package/dist/components/date-picker.js +378 -66
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/entity-combobox.d.ts +42 -1
- package/dist/components/entity-combobox.js +154 -113
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/facing-pair.d.ts +19 -14
- package/dist/components/field-parts.d.ts +224 -0
- package/dist/components/field-parts.js +156 -0
- package/dist/components/field-parts.js.map +1 -0
- package/dist/components/field-strip.d.ts +105 -0
- package/dist/components/field-strip.js +46 -0
- package/dist/components/field-strip.js.map +1 -0
- package/dist/components/file-button.d.ts +19 -14
- package/dist/components/file-button.js +13 -3
- package/dist/components/file-button.js.map +1 -1
- package/dist/components/file-dropzone.d.ts +41 -15
- package/dist/components/file-dropzone.js +57 -34
- package/dist/components/file-dropzone.js.map +1 -1
- package/dist/components/form-actions.d.ts +18 -13
- package/dist/components/form-actions.js +69 -5
- package/dist/components/form-actions.js.map +1 -1
- package/dist/components/iban-input.d.ts +69 -0
- package/dist/components/iban-input.js +125 -0
- package/dist/components/iban-input.js.map +1 -0
- package/dist/components/icon-picker.d.ts +21 -2
- package/dist/components/icon-picker.js +19 -4
- package/dist/components/icon-picker.js.map +1 -1
- package/dist/components/inline-edit-field.d.ts +167 -0
- package/dist/components/inline-edit-field.js +293 -0
- package/dist/components/inline-edit-field.js.map +1 -0
- package/dist/components/language-select.d.ts +130 -0
- package/dist/components/language-select.js +18 -0
- package/dist/components/language-select.js.map +1 -0
- package/dist/components/line-items.d.ts +25 -3
- package/dist/components/line-items.js +55 -46
- package/dist/components/line-items.js.map +1 -1
- package/dist/components/list.d.ts +25 -0
- package/dist/components/list.js +16 -5
- package/dist/components/list.js.map +1 -1
- package/dist/components/money-field.d.ts +32 -14
- package/dist/components/money-field.js.map +1 -1
- package/dist/components/month-picker.d.ts +52 -4
- package/dist/components/month-picker.js +291 -86
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-entity-combobox.d.ts +26 -1
- package/dist/components/multi-entity-combobox.js +143 -102
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/multi-select.d.ts +8 -1
- package/dist/components/multi-select.js +9 -4
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/number-field.d.ts +34 -19
- package/dist/components/number-field.js +6 -20
- package/dist/components/number-field.js.map +1 -1
- package/dist/components/number-input.d.ts +79 -19
- package/dist/components/number-input.js +90 -38
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/numpad-sheet.d.ts +19 -14
- package/dist/components/one-time-code-input.d.ts +100 -0
- package/dist/components/one-time-code-input.js +137 -0
- package/dist/components/one-time-code-input.js.map +1 -0
- package/dist/components/phone-input.d.ts +69 -0
- package/dist/components/phone-input.js +171 -0
- package/dist/components/phone-input.js.map +1 -0
- package/dist/components/reauth-dialog.d.ts +2 -2
- package/dist/components/reauth-dialog.js +6 -8
- package/dist/components/reauth-dialog.js.map +1 -1
- package/dist/components/series-chart.d.ts +19 -14
- package/dist/components/settings-fields.d.ts +19 -14
- package/dist/components/share-card.d.ts +16 -11
- package/dist/components/sign-chip.d.ts +66 -0
- package/dist/components/sign-chip.js +39 -0
- package/dist/components/sign-chip.js.map +1 -0
- package/dist/components/swatch-picker.d.ts +43 -2
- package/dist/components/swatch-picker.js +80 -32
- package/dist/components/swatch-picker.js.map +1 -1
- package/dist/components/switch.d.ts +19 -0
- package/dist/components/switch.js +24 -6
- package/dist/components/switch.js.map +1 -1
- package/dist/components/text-link.d.ts +18 -13
- package/dist/components/tile-radio.d.ts +88 -13
- package/dist/components/tile-radio.js +28 -11
- package/dist/components/tile-radio.js.map +1 -1
- package/dist/components/time-input.d.ts +24 -15
- package/dist/components/time-input.js.map +1 -1
- package/dist/components/toggle-group.d.ts +47 -1
- package/dist/components/toggle-group.js +110 -69
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/trigger-aria.d.ts +3 -0
- package/dist/components/trigger-aria.js +3 -1
- package/dist/components/trigger-aria.js.map +1 -1
- package/dist/components/ui.d.ts +16 -11
- package/dist/components/ui.js +284 -88
- package/dist/components/ui.js.map +1 -1
- package/dist/components/use-table-state.d.ts +1 -2
- package/dist/{data-table-3mi2R3so.d.ts → data-table-labels-B7OdnM0S.d.ts} +140 -3
- package/dist/data-table.d.ts +1 -2
- package/dist/data-table.js +2 -1
- package/dist/data-table.js.map +1 -1
- package/dist/feedback/feedback-attachment.d.ts +1 -1
- package/dist/feedback/feedback-attachment.js +348 -41
- package/dist/feedback/feedback-attachment.js.map +1 -1
- package/dist/feedback/feedback-dialog.d.ts +1 -1
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-inbox.d.ts +3 -2
- package/dist/feedback/feedback-inbox.js.map +1 -1
- package/dist/feedback/feedback-thread.d.ts +68 -253
- package/dist/feedback/feedback-thread.js +46 -10
- package/dist/feedback/feedback-thread.js.map +1 -1
- package/dist/{kit-labels-D1J2_jyD.d.ts → feedback-BxeQVzwq.d.ts} +1206 -20
- package/dist/{feedback-attachment-WFiXJ8We.d.ts → feedback-attachment-fGAzZPf0.d.ts} +178 -11
- package/dist/feedback.d.ts +66 -2
- package/dist/hooks/use-file-drop.d.ts +19 -14
- package/dist/i18n/defaults.d.ts +19 -14
- package/dist/i18n/defaults.js +19 -2
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.d.ts +19 -14
- package/dist/i18n/german.js +84 -5
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +15 -10
- package/dist/i18n/kit-labels.js +8 -2
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/languages.d.ts +19 -14
- package/dist/i18n/locales/de-CH.d.ts +19 -14
- package/dist/i18n/locales/en.d.ts +19 -14
- package/dist/i18n/locales/en.js +16 -0
- package/dist/i18n/locales/en.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +19 -14
- package/dist/i18n/locales/es.js +83 -5
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +19 -14
- package/dist/i18n/locales/fr.js +82 -5
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +19 -14
- package/dist/i18n/locales/hu.js +85 -5
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +19 -14
- package/dist/i18n/locales/it.js +84 -5
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +19 -14
- package/dist/i18n/locales/zh.js +80 -5
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.d.ts +19 -14
- package/dist/i18n/review.js +27 -1
- package/dist/i18n/review.js.map +1 -1
- package/dist/index.d.ts +21 -10
- package/dist/index.js +73 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/column-mapping.d.ts +81 -0
- package/dist/lib/column-mapping.js +108 -0
- package/dist/lib/column-mapping.js.map +1 -0
- package/dist/lib/countries.d.ts +43 -0
- package/dist/lib/countries.js +39 -0
- package/dist/lib/countries.js.map +1 -0
- package/dist/lib/decimal-marks.d.ts +46 -0
- package/dist/lib/decimal-marks.js +40 -0
- package/dist/lib/decimal-marks.js.map +1 -0
- package/dist/lib/iban.d.ts +98 -0
- package/dist/lib/iban.js +154 -0
- package/dist/lib/iban.js.map +1 -0
- package/dist/lib/isin.d.ts +30 -0
- package/dist/lib/isin.js +36 -0
- package/dist/lib/isin.js.map +1 -0
- package/dist/lib/phone.d.ts +69 -0
- package/dist/lib/phone.js +121 -0
- package/dist/lib/phone.js.map +1 -0
- package/dist/lib/table-text.d.ts +109 -1
- package/dist/lib/table-text.js +122 -1
- package/dist/lib/table-text.js.map +1 -1
- package/dist/rhf/fields.d.ts +233 -18
- package/dist/rhf/fields.js +456 -3
- package/dist/rhf/fields.js.map +1 -1
- package/dist/rhf/form.d.ts +19 -14
- package/dist/rhf.d.ts +22 -15
- package/dist/rhf.js.map +1 -1
- package/dist/shell/app-shell.d.ts +18 -13
- package/dist/shell/top-bar-brand.d.ts +19 -14
- package/dist/shell/topbar-action-menu.d.ts +36 -3
- package/dist/shell/topbar-action-menu.js +74 -33
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell.d.ts +18 -13
- package/dist/table-text.d.ts +1 -1
- package/dist/tour/tour.js +20 -24
- package/dist/tour/tour.js.map +1 -1
- package/dist/wizard/stepper-nav.d.ts +49 -16
- package/dist/wizard/stepper-nav.js +4 -0
- package/dist/wizard/stepper-nav.js.map +1 -1
- package/dist/wizard.d.ts +19 -14
- package/package.json +1 -1
- package/src/components/account-chips.tsx +17 -3
- package/src/components/account-settings.tsx +92 -26
- package/src/components/amount-input.tsx +68 -56
- package/src/components/autocomplete.tsx +198 -114
- package/src/components/checkbox-group.tsx +229 -0
- package/src/components/checkbox.tsx +72 -8
- package/src/components/chip.tsx +80 -10
- package/src/components/column-mapper.tsx +666 -0
- package/src/components/combobox-core.tsx +82 -9
- package/src/components/combobox.tsx +661 -340
- package/src/components/confirm-dialog.tsx +12 -8
- package/src/components/country-select.tsx +556 -0
- package/src/components/currency-select.tsx +109 -33
- package/src/components/danger-confirm.tsx +429 -82
- package/src/components/data-table-labels.ts +16 -1
- package/src/components/data-table.tsx +175 -6
- package/src/components/date-picker.tsx +595 -71
- package/src/components/entity-combobox.tsx +235 -124
- package/src/components/field-parts.tsx +403 -0
- package/src/components/field-strip.tsx +149 -0
- package/src/components/file-button.tsx +36 -3
- package/src/components/file-dropzone.tsx +106 -38
- package/src/components/form-actions.tsx +147 -6
- package/src/components/iban-input.tsx +231 -0
- package/src/components/icon-picker.tsx +47 -6
- package/src/components/inline-edit-field.tsx +533 -0
- package/src/components/language-select.tsx +78 -0
- package/src/components/line-items.tsx +35 -2
- package/src/components/list.tsx +55 -6
- package/src/components/money-field.tsx +13 -0
- package/src/components/month-picker.tsx +400 -63
- package/src/components/multi-entity-combobox.tsx +207 -120
- package/src/components/multi-select.tsx +80 -58
- package/src/components/number-field.tsx +28 -46
- package/src/components/number-input.tsx +210 -43
- package/src/components/one-time-code-input.tsx +288 -0
- package/src/components/phone-input.tsx +299 -0
- package/src/components/reauth-dialog.tsx +17 -18
- package/src/components/sign-chip.tsx +103 -0
- package/src/components/swatch-picker.tsx +143 -31
- package/src/components/switch.tsx +58 -7
- package/src/components/tile-radio.tsx +145 -29
- package/src/components/time-input.tsx +8 -1
- package/src/components/toggle-group.tsx +206 -73
- package/src/components/trigger-aria.ts +5 -0
- package/src/components/ui.tsx +479 -138
- package/src/data-table.ts +2 -1
- package/src/feedback/feedback-attachment.tsx +597 -46
- package/src/feedback/feedback-dialog.tsx +9 -3
- package/src/feedback/feedback-inbox.tsx +3 -2
- package/src/feedback/feedback-thread.tsx +113 -9
- package/src/i18n/defaults.ts +18 -1
- package/src/i18n/german.ts +89 -0
- package/src/i18n/kit-labels.tsx +82 -2
- package/src/i18n/locales/en.ts +36 -4
- package/src/i18n/locales/es.ts +87 -0
- package/src/i18n/locales/fr.ts +87 -0
- package/src/i18n/locales/hu.ts +83 -0
- package/src/i18n/locales/it.ts +88 -0
- package/src/i18n/locales/zh.ts +76 -0
- package/src/i18n/review.ts +26 -0
- package/src/index.ts +71 -3
- package/src/lib/column-mapping.ts +234 -0
- package/src/lib/countries.ts +91 -0
- package/src/lib/decimal-marks.ts +99 -0
- package/src/lib/iban.ts +171 -0
- package/src/lib/isin.ts +62 -0
- package/src/lib/phone.ts +211 -0
- package/src/lib/table-text.ts +271 -0
- package/src/rhf/fields.tsx +860 -9
- package/src/rhf.ts +3 -1
- package/src/shell/topbar-action-menu.tsx +134 -38
- package/src/tour/tour.tsx +66 -28
- package/src/wizard/stepper-nav.tsx +35 -1
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import '
|
|
2
|
+
import { bf as InputProps } from '../feedback-BxeQVzwq.js';
|
|
3
|
+
import '../feedback-attachment-fGAzZPf0.js';
|
|
4
|
+
import '../feedback/feedback-inbox.js';
|
|
5
|
+
import 'lucide-react';
|
|
6
|
+
import './tooltip.js';
|
|
7
|
+
import '../hooks/use-anchored-rect.js';
|
|
8
|
+
import '../lib/clipping.js';
|
|
9
|
+
import '../data-table-labels-B7OdnM0S.js';
|
|
10
|
+
import './data-table-sort.js';
|
|
11
|
+
import './swipeable-row.js';
|
|
4
12
|
import './mini-calendar.js';
|
|
5
13
|
import './calendar-heatmap.js';
|
|
6
14
|
import './popover.js';
|
|
7
15
|
import './chip.js';
|
|
8
|
-
import 'lucide-react';
|
|
9
16
|
import './field-sync.js';
|
|
10
|
-
import './tooltip.js';
|
|
11
|
-
import '../hooks/use-anchored-rect.js';
|
|
12
|
-
import '../lib/clipping.js';
|
|
13
17
|
import '../wizard/types.js';
|
|
14
18
|
import '../tour/tour.js';
|
|
15
19
|
import '../search/command-palette.js';
|
|
@@ -23,7 +27,6 @@ import './sparkline.js';
|
|
|
23
27
|
import './stat-tile.js';
|
|
24
28
|
import './signature-pad.js';
|
|
25
29
|
import './password-strength.js';
|
|
26
|
-
import './danger-confirm.js';
|
|
27
30
|
import './swatch-picker.js';
|
|
28
31
|
import './tile-radio.js';
|
|
29
32
|
import './icon-picker.js';
|
|
@@ -31,11 +34,7 @@ import './dialog-frame.js';
|
|
|
31
34
|
import './modal.js';
|
|
32
35
|
import '../hooks/use-search-param-state.js';
|
|
33
36
|
import './measured-grid.js';
|
|
34
|
-
import '../feedback-attachment-WFiXJ8We.js';
|
|
35
|
-
import '../feedback/feedback-thread.js';
|
|
36
|
-
import '../feedback/feedback-inbox.js';
|
|
37
37
|
import './account-settings-labels.js';
|
|
38
|
-
import './confirm-dialog.js';
|
|
39
38
|
import './floating-panel.js';
|
|
40
39
|
import './bulk-action-bar.js';
|
|
41
40
|
import './list.js';
|
|
@@ -54,14 +53,20 @@ import './write-lock.js';
|
|
|
54
53
|
import './legal.js';
|
|
55
54
|
import './account-chips.js';
|
|
56
55
|
import '../lib/format.js';
|
|
57
|
-
import '../data-table-3mi2R3so.js';
|
|
58
|
-
import './data-table-sort.js';
|
|
59
|
-
import './swipeable-row.js';
|
|
60
56
|
import './reauth-dialog.js';
|
|
61
57
|
import './server-wake.js';
|
|
62
58
|
import '../lib/server-wake.js';
|
|
63
59
|
import './translation-review-labels.js';
|
|
64
60
|
import '../lib/translation-review.js';
|
|
61
|
+
import './country-select.js';
|
|
62
|
+
import './inline-edit-field.js';
|
|
63
|
+
import '../lib/iban.js';
|
|
64
|
+
import '../lib/phone.js';
|
|
65
|
+
import './sign-chip.js';
|
|
66
|
+
import './column-mapper.js';
|
|
67
|
+
import '../lib/column-mapping.js';
|
|
68
|
+
import '../lib/table-text.js';
|
|
69
|
+
import './field-parts.js';
|
|
65
70
|
|
|
66
71
|
/**
|
|
67
72
|
* A time of day, as a `"HH:mm"` string (`"HH:mm:ss"` once `step` asks for seconds).
|
|
@@ -91,8 +96,12 @@ import '../lib/translation-review.js';
|
|
|
91
96
|
* {@link FIELD_INVALID} and `aria-invalid`. A reversed window (`min="22:00"
|
|
92
97
|
* max="06:00"`, a night shift, quiet hours) is read the way the HTML spec reads it:
|
|
93
98
|
* as wrapping past midnight.
|
|
99
|
+
*
|
|
100
|
+
* `hint` is Input's too (keksdose K4): text is a caption under the field ("Local time
|
|
101
|
+
* at the site"), a {@link FieldHint} rides the label line. `showCount` is typed out — a
|
|
102
|
+
* time has no length worth counting.
|
|
94
103
|
*/
|
|
95
|
-
interface TimeInputProps extends Omit<InputProps, "type" | "value" | "defaultValue" | "min" | "max" | "step" | "variant"> {
|
|
104
|
+
interface TimeInputProps extends Omit<InputProps, "type" | "value" | "defaultValue" | "min" | "max" | "step" | "variant" | "showCount" | "countLabels"> {
|
|
96
105
|
/** `"HH:mm"` (or `"HH:mm:ss"` with a sub-minute `step`); `""` is "no time". */
|
|
97
106
|
value: string;
|
|
98
107
|
/** The normalised value on every change the browser reports — which for a time
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/time-input.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type { ChangeEvent } from \"react\";\nimport { Input, type InputProps } from \"./ui\";\nimport { cn } from \"../lib/cn\";\n\n/**\n * A time of day, as a `\"HH:mm\"` string (`\"HH:mm:ss\"` once `step` asks for seconds).\n *\n * NATIVE `<input type=\"time\">`, deliberately, rather than a pair of custom spinners.\n * What the browser's control gives for free is the part a hand-rolled one gets wrong:\n * 12- versus 24-hour display follows the user's OWN locale settings (not the page's —\n * which is the right authority for \"how do I read a clock\"), a phone opens its\n * platform wheel or dial, each segment is a spin button a screen reader already knows,\n * and typing \"1430\" fills both segments. The price is that the display cannot be\n * forced to 24h from here and the look of the segments is the browser's; neither is a\n * reason for three apps to ship an unaudited widget. So this is {@link Input} with\n * `type=\"time\"` and a string contract, and everything else — the floating label, the\n * `invalid`/`error` wiring, the click-anywhere `showPicker()` (feedback #224) — is\n * Input's own, inherited rather than copied.\n *\n * Two things it adds over `<Input type=\"time\">`:\n *\n * - **A normalised value.** A time input's value is any valid time string, so a\n * browser may leave off a zero seconds segment with `step={1}` or report\n * milliseconds, and a stored value may carry seconds the field does not show.\n * `onValueChange` always hands back exactly the shape `step` implies, so the value\n * a form stores compares and sorts as a plain string.\n * - **Out-of-range painted, not just flagged.** A native time input outside\n * `min`/`max` matches `:invalid` and nothing styles that selector (see Input's\n * `invalid`), so an out-of-window time looked fine. Here it wears\n * {@link FIELD_INVALID} and `aria-invalid`. A reversed window (`min=\"22:00\"\n * max=\"06:00\"`, a night shift, quiet hours) is read the way the HTML spec reads it:\n * as wrapping past midnight.\n */\nexport interface TimeInputProps\n extends Omit
|
|
1
|
+
{"version":3,"sources":["../../src/components/time-input.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type { ChangeEvent } from \"react\";\nimport { Input, type InputProps } from \"./ui\";\nimport { cn } from \"../lib/cn\";\n\n/**\n * A time of day, as a `\"HH:mm\"` string (`\"HH:mm:ss\"` once `step` asks for seconds).\n *\n * NATIVE `<input type=\"time\">`, deliberately, rather than a pair of custom spinners.\n * What the browser's control gives for free is the part a hand-rolled one gets wrong:\n * 12- versus 24-hour display follows the user's OWN locale settings (not the page's —\n * which is the right authority for \"how do I read a clock\"), a phone opens its\n * platform wheel or dial, each segment is a spin button a screen reader already knows,\n * and typing \"1430\" fills both segments. The price is that the display cannot be\n * forced to 24h from here and the look of the segments is the browser's; neither is a\n * reason for three apps to ship an unaudited widget. So this is {@link Input} with\n * `type=\"time\"` and a string contract, and everything else — the floating label, the\n * `invalid`/`error` wiring, the click-anywhere `showPicker()` (feedback #224) — is\n * Input's own, inherited rather than copied.\n *\n * Two things it adds over `<Input type=\"time\">`:\n *\n * - **A normalised value.** A time input's value is any valid time string, so a\n * browser may leave off a zero seconds segment with `step={1}` or report\n * milliseconds, and a stored value may carry seconds the field does not show.\n * `onValueChange` always hands back exactly the shape `step` implies, so the value\n * a form stores compares and sorts as a plain string.\n * - **Out-of-range painted, not just flagged.** A native time input outside\n * `min`/`max` matches `:invalid` and nothing styles that selector (see Input's\n * `invalid`), so an out-of-window time looked fine. Here it wears\n * {@link FIELD_INVALID} and `aria-invalid`. A reversed window (`min=\"22:00\"\n * max=\"06:00\"`, a night shift, quiet hours) is read the way the HTML spec reads it:\n * as wrapping past midnight.\n *\n * `hint` is Input's too (keksdose K4): text is a caption under the field (\"Local time\n * at the site\"), a {@link FieldHint} rides the label line. `showCount` is typed out — a\n * time has no length worth counting.\n */\nexport interface TimeInputProps\n extends Omit<\n InputProps,\n \"type\" | \"value\" | \"defaultValue\" | \"min\" | \"max\" | \"step\" | \"variant\" | \"showCount\" | \"countLabels\"\n > {\n /** `\"HH:mm\"` (or `\"HH:mm:ss\"` with a sub-minute `step`); `\"\"` is \"no time\". */\n value: string;\n /** The normalised value on every change the browser reports — which for a time\n * input is only once every segment holds a digit, or when the field is cleared\n * (`\"\"`). Plain `onChange` still fires alongside it with the raw event. */\n onValueChange?: (value: string) => void;\n /** Earliest time, `\"HH:mm\"`. May be later than `max` for a window that wraps\n * midnight. */\n min?: string;\n /** Latest time, `\"HH:mm\"`. */\n max?: string;\n /** Granularity in SECONDS, as on the native input: 60 (the default) is minutes,\n * 900 is quarter hours, anything not a whole minute (e.g. 1) shows seconds. */\n step?: number;\n}\n\n/** Seconds shown when `step` is not a whole number of minutes — the browser's own rule\n * for whether the seconds segment appears. */\nfunction withSeconds(step: number | undefined): boolean {\n return step !== undefined && step % 60 !== 0;\n}\n\n/** Any `HH:mm[:ss[.sss]]` the browser reports → exactly the shape `step` implies.\n * Anything else (including `\"\"`) comes back as it went in. */\nexport function normalizeTime(raw: string, seconds: boolean): string {\n const m = /^(\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(raw);\n if (!m) return raw;\n return seconds ? `${m[1]}:${m[2]}:${m[3] ?? \"00\"}` : `${m[1]}:${m[2]}`;\n}\n\n/** Whether `value` lies inside `[min, max]`, wrapping midnight when `min > max`.\n * Zero-padded times compare as strings; both sides are padded to seconds first so\n * \"14:30\" and \"14:30:00\" are the same instant. */\nexport function isTimeInRange(value: string, min?: string, max?: string): boolean {\n if (value === \"\") return true;\n const v = normalizeTime(value, true);\n const lo = min ? normalizeTime(min, true) : undefined;\n const hi = max ? normalizeTime(max, true) : undefined;\n if (lo !== undefined && hi !== undefined && lo > hi) return v >= lo || v <= hi;\n return (lo === undefined || v >= lo) && (hi === undefined || v <= hi);\n}\n\nexport const TimeInput = forwardRef<HTMLInputElement, TimeInputProps>(function TimeInput(\n { value, onValueChange, onChange, min, max, step, invalid, inputClassName, ...rest },\n ref,\n) {\n const seconds = withSeconds(step);\n const outOfRange = !isTimeInRange(value, min, max);\n return (\n <Input\n ref={ref}\n {...rest}\n type=\"time\"\n // Normalised on the way IN as well: a stored \"14:30:00\" handed to a minutes-only\n // field would otherwise make the browser show a seconds segment nobody asked for.\n value={normalizeTime(value, seconds)}\n min={min}\n max={max}\n step={step}\n invalid={invalid || outOfRange}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n onChange?.(e);\n onValueChange?.(normalizeTime(e.target.value, seconds));\n }}\n // The segments are digits that change under the caret as you spin them;\n // proportional figures make the whole field jitter sideways on every step.\n inputClassName={cn(\"tabular-nums\", inputClassName)}\n />\n );\n});\nTimeInput.displayName = \"TimeInput\";\n"],"mappings":";AA4FI;AA5FJ,SAAS,kBAAkB;AAE3B,SAAS,aAA8B;AACvC,SAAS,UAAU;AA0DnB,SAAS,YAAY,MAAmC;AACtD,SAAO,SAAS,UAAa,OAAO,OAAO;AAC7C;AAIO,SAAS,cAAc,KAAa,SAA0B;AACnE,QAAM,IAAI,gCAAgC,KAAK,GAAG;AAClD,MAAI,CAAC,EAAG,QAAO;AACf,SAAO,UAAU,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,KAAK,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AACtE;AAKO,SAAS,cAAc,OAAe,KAAc,KAAuB;AAChF,MAAI,UAAU,GAAI,QAAO;AACzB,QAAM,IAAI,cAAc,OAAO,IAAI;AACnC,QAAM,KAAK,MAAM,cAAc,KAAK,IAAI,IAAI;AAC5C,QAAM,KAAK,MAAM,cAAc,KAAK,IAAI,IAAI;AAC5C,MAAI,OAAO,UAAa,OAAO,UAAa,KAAK,GAAI,QAAO,KAAK,MAAM,KAAK;AAC5E,UAAQ,OAAO,UAAa,KAAK,QAAQ,OAAO,UAAa,KAAK;AACpE;AAEO,MAAM,YAAY,WAA6C,SAASA,WAC7E,EAAE,OAAO,eAAe,UAAU,KAAK,KAAK,MAAM,SAAS,gBAAgB,GAAG,KAAK,GACnF,KACA;AACA,QAAM,UAAU,YAAY,IAAI;AAChC,QAAM,aAAa,CAAC,cAAc,OAAO,KAAK,GAAG;AACjD,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACC,GAAG;AAAA,MACJ,MAAK;AAAA,MAGL,OAAO,cAAc,OAAO,OAAO;AAAA,MACnC;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS,WAAW;AAAA,MACpB,UAAU,CAAC,MAAqC;AAC9C,mBAAW,CAAC;AACZ,wBAAgB,cAAc,EAAE,OAAO,OAAO,OAAO,CAAC;AAAA,MACxD;AAAA,MAGA,gBAAgB,GAAG,gBAAgB,cAAc;AAAA;AAAA,EACnD;AAEJ,CAAC;AACD,UAAU,cAAc;","names":["TimeInput"]}
|
|
@@ -53,6 +53,9 @@ interface ToggleGroupBaseProps<T extends string> extends Omit<ComponentPropsWith
|
|
|
53
53
|
* `sm`: 12px options with `px-2 py-1` — the compact group keksdose's rule editor
|
|
54
54
|
* (rule-editor:204) writes as `optionClassName="px-2 py-1 text-xs"` beside a small
|
|
55
55
|
* caption. `md` (default) is the size every other group has.
|
|
56
|
+
*
|
|
57
|
+
* Honoured inside the field chrome and the strip too (keksdose K1): the 12px type
|
|
58
|
+
* stays, and the field is still 42px — see `CHROME_PAD`.
|
|
56
59
|
*/
|
|
57
60
|
size?: "sm" | "md";
|
|
58
61
|
/**
|
|
@@ -78,11 +81,32 @@ interface ToggleGroupBaseProps<T extends string> extends Omit<ComponentPropsWith
|
|
|
78
81
|
* cap pair sits in a `Field` column between two labelled-above inputs, where the
|
|
79
82
|
* chrome's inner label would be the only one of its kind).
|
|
80
83
|
*
|
|
84
|
+
* `"strip"`: the 11px static label (and `hint`) in a strip OVER the bare group, for a
|
|
85
|
+
* group that stands in a row of fields but is not one (keksdose K2 — the transaction
|
|
86
|
+
* row's cleared-status picker, live #288 / #431 / dev#468). No field border: the group
|
|
87
|
+
* keeps its own box, and its segments drop their vertical padding so a 16px strip
|
|
88
|
+
* plus the 26px group is exactly a labelled {@link Input}'s 42px, the label on the
|
|
89
|
+
* same line as theirs. `error` and `caption` go under the group, as in the other two.
|
|
90
|
+
*
|
|
81
91
|
* Inside a `Field`, pass no `label` at all and spread the render-prop instead —
|
|
82
92
|
* `{(ids, { labelId }) => <ToggleGroup {...ids} aria-labelledby={labelId} … />}` —
|
|
83
93
|
* so the Field's label names the group and its hint and error describe it.
|
|
84
94
|
*/
|
|
85
|
-
labelPlacement?: "field" | "above";
|
|
95
|
+
labelPlacement?: "field" | "above" | "strip";
|
|
96
|
+
/**
|
|
97
|
+
* Classes for the field chrome's own box — the bordered, padded box round the
|
|
98
|
+
* segments — merged last, so they win. `className` styles the wrapper the chrome sits
|
|
99
|
+
* in; this reaches the box itself. Only with `label` in the `"field"` placement.
|
|
100
|
+
*
|
|
101
|
+
* For a field JOINED flush to a neighbour (keksdose K1): reports-filters.tsx joins its
|
|
102
|
+
* "group by" field to the range select on its start edge from `md` up, and squares the
|
|
103
|
+
* shared corners by hand chrome today — here that is
|
|
104
|
+
* `chromeClassName="md:rounded-s-none"` with `className="md:-ms-px"` (the wrapper
|
|
105
|
+
* overlaps the neighbour by the one border they share). A class rather than a
|
|
106
|
+
* `joined="start"` because every such join keksdose has is responsive: on a phone the
|
|
107
|
+
* two stack and both keep their corners.
|
|
108
|
+
*/
|
|
109
|
+
chromeClassName?: string;
|
|
86
110
|
/** A {@link FieldHint} on the label line, as on a labelled {@link Select}. Only with
|
|
87
111
|
* `label`. */
|
|
88
112
|
hint?: ReactNode;
|
|
@@ -90,6 +114,28 @@ interface ToggleGroupBaseProps<T extends string> extends Omit<ComponentPropsWith
|
|
|
90
114
|
* `--danger`, marks the group `aria-invalid` and describes it with the message, as
|
|
91
115
|
* {@link Select}'s `error` does. Only with `label`. */
|
|
92
116
|
error?: ReactNode;
|
|
117
|
+
/**
|
|
118
|
+
* Why the group cannot be changed right now — {@link Button}'s `disabledReason`, for
|
|
119
|
+
* a group that saves itself on change (keksdose K3: the last `SaveGuard` sites are
|
|
120
|
+
* self-committing controls like this one, and SaveGuard's native `disabled` took
|
|
121
|
+
* them out of the tab order so the reason never reached a keyboard).
|
|
122
|
+
*
|
|
123
|
+
* The group stays reachable — its segments are `aria-disabled`, not `disabled`, and
|
|
124
|
+
* a radio group's arrow keys still walk them — but nothing reaches `onChange`, and
|
|
125
|
+
* the reason shows in the kit {@link Tooltip} over the segments on hover or focus and
|
|
126
|
+
* describes each segment. The chosen option keeps its fill, as under `disabled`.
|
|
127
|
+
* Wins over `disabled`, as on Button: passing both keeps the group reachable.
|
|
128
|
+
*/
|
|
129
|
+
disabledReason?: ReactNode;
|
|
130
|
+
/**
|
|
131
|
+
* This group COMMITS — choosing an option saves it. Under a locked
|
|
132
|
+
* {@link WriteLockProvider} it takes the `disabledReason` path with the lock's
|
|
133
|
+
* reason (which wins over a `disabledReason` of its own): *"everything renders; only
|
|
134
|
+
* the commit is locked"* (keksdose dev#496/#497), and a control that is its own commit
|
|
135
|
+
* must render refused, never live-and-discarding. No provider, or an unlocked one:
|
|
136
|
+
* no effect.
|
|
137
|
+
*/
|
|
138
|
+
commit?: boolean;
|
|
93
139
|
}
|
|
94
140
|
/**
|
|
95
141
|
* A line under the group saying what the CHOSEN option means — lenkbank's ToggleField
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useId } from "react";
|
|
4
4
|
import { cn } from "../lib/cn.js";
|
|
5
5
|
import { horizontalStep } from "../lib/direction.js";
|
|
6
6
|
import { FIELD_INVALID, FloatingField, Label } from "./ui.js";
|
|
7
|
+
import { Tooltip } from "./tooltip.js";
|
|
8
|
+
import { useCommitReason } from "./write-lock.js";
|
|
9
|
+
import { hasContent, LabelStrip } from "./field-parts.js";
|
|
10
|
+
const CHROME_PAD = { md: "pt-5 pb-0.5", sm: "pt-5 pb-1" };
|
|
11
|
+
const CHROME_SEGMENT = { md: "py-0 leading-[18px]", sm: "py-0 leading-4" };
|
|
12
|
+
const STRIP_SEGMENT = { md: "py-0", sm: "py-0.5" };
|
|
7
13
|
function ToggleGroup(props) {
|
|
8
14
|
const {
|
|
9
15
|
value,
|
|
@@ -16,24 +22,33 @@ function ToggleGroup(props) {
|
|
|
16
22
|
size = "md",
|
|
17
23
|
label,
|
|
18
24
|
labelPlacement = "field",
|
|
25
|
+
chromeClassName,
|
|
19
26
|
hint,
|
|
20
27
|
error,
|
|
28
|
+
disabledReason: ownDisabledReason,
|
|
29
|
+
commit,
|
|
21
30
|
"aria-label": ariaLabelAttr,
|
|
22
31
|
...restWithMode
|
|
23
32
|
} = props;
|
|
24
33
|
const labelId = useId();
|
|
25
34
|
const errorId = useId();
|
|
26
|
-
const
|
|
35
|
+
const reasonId = useId();
|
|
36
|
+
const disabledReason = useCommitReason(commit, ownDisabledReason);
|
|
37
|
+
const locked = hasContent(disabledReason);
|
|
38
|
+
const dimmed = disabled || locked;
|
|
39
|
+
const labelled = hasContent(label);
|
|
27
40
|
const field = labelled && labelPlacement === "field";
|
|
28
41
|
const above = labelled && labelPlacement === "above";
|
|
29
|
-
const
|
|
42
|
+
const strip = labelled && labelPlacement === "strip";
|
|
43
|
+
const hasError = labelled && hasContent(error);
|
|
30
44
|
const { allowEmpty: _allowEmpty, onChange: _onChange, caption, semantics: _semantics, ...rest } = restWithMode;
|
|
31
45
|
const outsideInvalid = rest["aria-invalid"] === true || rest["aria-invalid"] === "true";
|
|
32
46
|
const captionId = useId();
|
|
33
47
|
const captionIsLive = typeof caption === "function";
|
|
34
48
|
const captionNode = captionIsLive ? caption(value) : caption;
|
|
35
|
-
const hasCaption = captionNode
|
|
49
|
+
const hasCaption = hasContent(captionNode);
|
|
36
50
|
const choose = (next) => {
|
|
51
|
+
if (locked) return;
|
|
37
52
|
if (props.allowEmpty) props.onChange(next === value ? null : next);
|
|
38
53
|
else props.onChange(next);
|
|
39
54
|
};
|
|
@@ -55,6 +70,68 @@ function ToggleGroup(props) {
|
|
|
55
70
|
buttons?.[next]?.focus();
|
|
56
71
|
choose(options[next].value);
|
|
57
72
|
};
|
|
73
|
+
const segments = options.map((opt, index) => {
|
|
74
|
+
const active = opt.value === value;
|
|
75
|
+
return /* @__PURE__ */ jsx(
|
|
76
|
+
"button",
|
|
77
|
+
{
|
|
78
|
+
type: "button",
|
|
79
|
+
role: pressed ? void 0 : "radio",
|
|
80
|
+
"aria-checked": pressed ? void 0 : active,
|
|
81
|
+
"aria-pressed": pressed ? active : void 0,
|
|
82
|
+
disabled: disabled && !locked,
|
|
83
|
+
"aria-disabled": locked || void 0,
|
|
84
|
+
"aria-describedby": locked ? reasonId : void 0,
|
|
85
|
+
tabIndex: pressed ? void 0 : opt.value === tabStop ? 0 : -1,
|
|
86
|
+
onKeyDown: pressed ? void 0 : (e) => onRadioKey(e, index),
|
|
87
|
+
onClick: () => choose(opt.value),
|
|
88
|
+
className: cn(
|
|
89
|
+
// `truncate` (which carries whitespace-nowrap) rather than letting a
|
|
90
|
+
// label wrap: a segmented control sizes its whole row to the tallest
|
|
91
|
+
// option, so one two-word option — Keksdose feedback #147's "Where I
|
|
92
|
+
// am" — silently doubles the height of every segment beside it.
|
|
93
|
+
//
|
|
94
|
+
// `basis-auto` is what keeps that ellipsis a LAST resort rather than
|
|
95
|
+
// the normal state (Keksdose dev#475). With flex-1's `basis-0`, a
|
|
96
|
+
// shrink-to-fit group (`w-auto`) still resolves to the sum of the
|
|
97
|
+
// labels' widths — and then splits it EQUALLY, so the short option
|
|
98
|
+
// got 66px it did not need and "Where I am" got 66 of the 81 it did:
|
|
99
|
+
// truncated at 1778px of free screen. Basing each segment on its own
|
|
100
|
+
// content and sharing only the LEFTOVER space keeps a full-width
|
|
101
|
+
// group's segments near-equal and an auto-width group's exact.
|
|
102
|
+
//
|
|
103
|
+
// `focus-visible` + `ring-inset`, not `focus` + an outset ring. A ring
|
|
104
|
+
// is a box-shadow that spreads OUTWARD, so on a flush group it painted
|
|
105
|
+
// 2px of ring over both neighbours and over the container's own border
|
|
106
|
+
// — and on a phone it appeared on every TAP, because a tap focuses the
|
|
107
|
+
// button. That is the other half of what live #268's rework saw
|
|
108
|
+
// overlaying the selected segment's boundary. Inset keeps the ring
|
|
109
|
+
// inside the segment it belongs to; focus-visible keeps it for the
|
|
110
|
+
// keyboard, which is the only input that needs it.
|
|
111
|
+
overflow === "wrap" ? "whitespace-nowrap" : "min-w-0 truncate",
|
|
112
|
+
"flex-1 basis-auto rounded px-3 py-1.5 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--border-strong)]",
|
|
113
|
+
size === "sm" && "px-2 py-1 text-xs",
|
|
114
|
+
// In the field chrome: no vertical padding, and the line that makes the
|
|
115
|
+
// field 42px under a strip that clears the label — see CHROME_PAD. `sm`
|
|
116
|
+
// keeps its 12px type here (it used to be overridden to the md line).
|
|
117
|
+
field && CHROME_SEGMENT[size],
|
|
118
|
+
// In the strip placement: a 26px group under a 16px strip — STRIP_SEGMENT.
|
|
119
|
+
strip && STRIP_SEGMENT[size],
|
|
120
|
+
active ? "bg-[var(--bg-inverse)] text-[var(--text-inverse)]" : "text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]",
|
|
121
|
+
// No hover fill on a group that cannot be changed — a segment that
|
|
122
|
+
// lights up under the pointer is an offer, and there is none here. Not on
|
|
123
|
+
// the chosen segment: its fill IS its state, and its inverse text would
|
|
124
|
+
// vanish on a transparent hover.
|
|
125
|
+
dimmed && "cursor-not-allowed",
|
|
126
|
+
dimmed && !active && "hover:bg-transparent dark:hover:bg-transparent",
|
|
127
|
+
optionClassName,
|
|
128
|
+
opt.className
|
|
129
|
+
),
|
|
130
|
+
children: opt.label
|
|
131
|
+
},
|
|
132
|
+
opt.value
|
|
133
|
+
);
|
|
134
|
+
});
|
|
58
135
|
const group = /* @__PURE__ */ jsx(
|
|
59
136
|
"div",
|
|
60
137
|
{
|
|
@@ -64,7 +141,7 @@ function ToggleGroup(props) {
|
|
|
64
141
|
"aria-labelledby": labelled && ariaLabelAttr === void 0 && ariaLabel === void 0 ? labelId : rest["aria-labelledby"],
|
|
65
142
|
"aria-invalid": hasError || rest["aria-invalid"] || void 0,
|
|
66
143
|
"aria-describedby": [rest["aria-describedby"], hasCaption && captionId, hasError && errorId].filter(Boolean).join(" ") || void 0,
|
|
67
|
-
"aria-disabled":
|
|
144
|
+
"aria-disabled": dimmed || void 0,
|
|
68
145
|
className: cn(
|
|
69
146
|
// `gap-0.5` — the same 2px as the container's own padding, so EVERY segment
|
|
70
147
|
// sits in a uniform 2px moat and no two fills ever touch. Flush segments were
|
|
@@ -83,72 +160,27 @@ function ToggleGroup(props) {
|
|
|
83
160
|
// The whole group fades, the way every other disabled control in this
|
|
84
161
|
// package does; `cursor-not-allowed` is on the buttons, which is what a
|
|
85
162
|
// pointer is actually over.
|
|
86
|
-
|
|
163
|
+
dimmed && "opacity-60",
|
|
87
164
|
// The bare group (no chrome to paint) wears the invalid border itself.
|
|
88
|
-
!field && (outsideInvalid || above && hasError) && FIELD_INVALID,
|
|
165
|
+
!field && (outsideInvalid || (above || strip) && hasError) && FIELD_INVALID,
|
|
89
166
|
// Inside the field's chrome the group is only a row of segments: no border, no
|
|
90
167
|
// surface, no padding of its own, and the field (not the group) is what dims.
|
|
91
168
|
field && "border-0 bg-transparent p-0 shadow-none opacity-100",
|
|
92
169
|
!labelled && className
|
|
93
170
|
),
|
|
94
|
-
children:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
className: cn(
|
|
108
|
-
// `truncate` (which carries whitespace-nowrap) rather than letting a
|
|
109
|
-
// label wrap: a segmented control sizes its whole row to the tallest
|
|
110
|
-
// option, so one two-word option — Keksdose feedback #147's "Where I
|
|
111
|
-
// am" — silently doubles the height of every segment beside it.
|
|
112
|
-
//
|
|
113
|
-
// `basis-auto` is what keeps that ellipsis a LAST resort rather than
|
|
114
|
-
// the normal state (Keksdose dev#475). With flex-1's `basis-0`, a
|
|
115
|
-
// shrink-to-fit group (`w-auto`) still resolves to the sum of the
|
|
116
|
-
// labels' widths — and then splits it EQUALLY, so the short option
|
|
117
|
-
// got 66px it did not need and "Where I am" got 66 of the 81 it did:
|
|
118
|
-
// truncated at 1778px of free screen. Basing each segment on its own
|
|
119
|
-
// content and sharing only the LEFTOVER space keeps a full-width
|
|
120
|
-
// group's segments near-equal and an auto-width group's exact.
|
|
121
|
-
//
|
|
122
|
-
// `focus-visible` + `ring-inset`, not `focus` + an outset ring. A ring
|
|
123
|
-
// is a box-shadow that spreads OUTWARD, so on a flush group it painted
|
|
124
|
-
// 2px of ring over both neighbours and over the container's own border
|
|
125
|
-
// — and on a phone it appeared on every TAP, because a tap focuses the
|
|
126
|
-
// button. That is the other half of what live #268's rework saw
|
|
127
|
-
// overlaying the selected segment's boundary. Inset keeps the ring
|
|
128
|
-
// inside the segment it belongs to; focus-visible keeps it for the
|
|
129
|
-
// keyboard, which is the only input that needs it.
|
|
130
|
-
overflow === "wrap" ? "whitespace-nowrap" : "min-w-0 truncate",
|
|
131
|
-
"flex-1 basis-auto rounded px-3 py-1.5 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--border-strong)]",
|
|
132
|
-
size === "sm" && "px-2 py-1 text-xs",
|
|
133
|
-
// In a field: no vertical padding and a 20px line — a `text-sm` line, the
|
|
134
|
-
// same line a labelled Select holds under its label strip — so the field's
|
|
135
|
-
// own `pt-4 pb-1` decides the height, as it does for the select.
|
|
136
|
-
field && "py-0 leading-5",
|
|
137
|
-
active ? "bg-[var(--bg-inverse)] text-[var(--text-inverse)]" : "text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]",
|
|
138
|
-
// No hover fill on a group that cannot be changed — a segment that
|
|
139
|
-
// lights up under the pointer is an offer, and there is none here. Not on
|
|
140
|
-
// the chosen segment: its fill IS its state, and its inverse text would
|
|
141
|
-
// vanish on a transparent hover.
|
|
142
|
-
disabled && "cursor-not-allowed",
|
|
143
|
-
disabled && !active && "hover:bg-transparent dark:hover:bg-transparent",
|
|
144
|
-
optionClassName,
|
|
145
|
-
opt.className
|
|
146
|
-
),
|
|
147
|
-
children: opt.label
|
|
148
|
-
},
|
|
149
|
-
opt.value
|
|
150
|
-
);
|
|
151
|
-
})
|
|
171
|
+
children: locked ? (
|
|
172
|
+
// The reason's bubble wraps the SEGMENTS, inside the group, not the group: a
|
|
173
|
+
// wrapper outside it would become the flex or grid item in the caller's row in
|
|
174
|
+
// the group's place, and a `w-full` / `md:w-auto` on the group would size the
|
|
175
|
+
// wrong box. This row inherits the group's gap and wrap, so the segments lay out
|
|
176
|
+
// exactly as they do unlocked, and `:scope > button` above still finds them. A
|
|
177
|
+
// fragment child, so the Tooltip describes nothing itself — each segment points
|
|
178
|
+
// at the hidden copy, the way a locked Button does.
|
|
179
|
+
/* @__PURE__ */ jsx(Tooltip, { label: disabledReason, className: "flex min-w-0 flex-1 gap-[inherit] [flex-wrap:inherit]", children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
180
|
+
segments,
|
|
181
|
+
/* @__PURE__ */ jsx("span", { id: reasonId, hidden: true, children: disabledReason })
|
|
182
|
+
] }) })
|
|
183
|
+
) : segments
|
|
152
184
|
}
|
|
153
185
|
);
|
|
154
186
|
const captionEl = hasCaption || captionIsLive ? /* @__PURE__ */ jsx(
|
|
@@ -168,7 +200,7 @@ function ToggleGroup(props) {
|
|
|
168
200
|
Label,
|
|
169
201
|
{
|
|
170
202
|
id: labelId,
|
|
171
|
-
disabled,
|
|
203
|
+
disabled: dimmed,
|
|
172
204
|
"data-error": hasError || void 0,
|
|
173
205
|
className: "data-[error=true]:text-[var(--danger)]",
|
|
174
206
|
children: label
|
|
@@ -183,6 +215,13 @@ function ToggleGroup(props) {
|
|
|
183
215
|
] })
|
|
184
216
|
] });
|
|
185
217
|
}
|
|
218
|
+
if (strip) {
|
|
219
|
+
return /* @__PURE__ */ jsxs(LabelStrip, { labelId, label, hint, disabled: dimmed, pad: "field", className, children: [
|
|
220
|
+
group,
|
|
221
|
+
captionEl,
|
|
222
|
+
errorEl
|
|
223
|
+
] });
|
|
224
|
+
}
|
|
186
225
|
if (!field) {
|
|
187
226
|
if (!captionEl) return group;
|
|
188
227
|
return /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
@@ -205,9 +244,11 @@ function ToggleGroup(props) {
|
|
|
205
244
|
"div",
|
|
206
245
|
{
|
|
207
246
|
className: cn(
|
|
208
|
-
"flex flex-1 flex-col justify-center rounded-md border border-[var(--border)] bg-[var(--bg-surface)] px-1
|
|
209
|
-
|
|
210
|
-
|
|
247
|
+
"flex flex-1 flex-col justify-center rounded-md border border-[var(--border)] bg-[var(--bg-surface)] px-1 shadow-sm",
|
|
248
|
+
CHROME_PAD[size],
|
|
249
|
+
dimmed && "bg-[var(--bg-surface-2)] opacity-60",
|
|
250
|
+
hasError && FIELD_INVALID,
|
|
251
|
+
chromeClassName
|
|
211
252
|
),
|
|
212
253
|
children: group
|
|
213
254
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/toggle-group.tsx"],"sourcesContent":["import { useId } from \"react\";\nimport type { ComponentPropsWithoutRef, KeyboardEvent, ReactElement, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { horizontalStep } from \"../lib/direction\";\nimport { FIELD_INVALID, FloatingField, Label } from \"./ui\";\n\nexport interface ToggleOption<T extends string> {\n value: T;\n label: string;\n className?: string;\n}\n\n/**\n * `onChange` is the group's own — the chosen VALUE, not a DOM event — so the div's\n * `onChange` is omitted rather than shadowed: leaving both in scope would give the\n * prop two incompatible meanings depending on which overload TypeScript picked.\n *\n * `children` is omitted too: this renders its `options` and nothing else, so a `children` the type\n * accepted and the component ignored would be a prop that silently does nothing —\n * worse than one that does not compile.\n */\nexport interface ToggleGroupBaseProps<T extends string>\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"onChange\" | \"children\"> {\n options: ToggleOption<T>[];\n className?: string;\n /** Applied to every option button (e.g. to tune height/rounding to match\n * adjacent fields). Per-option `className` still wins over this. */\n optionClassName?: string;\n /**\n * What happens when the options do not fit the group's width. `\"truncate\"`\n * (default): one row, and the labels that do not fit end in an ellipsis — the height\n * never changes. `\"wrap\"`: the segments flow onto a second row and every label stays\n * whole (\"Bewegung\", not \"Beweg…\"), at the price of a taller group on a narrow\n * screen (lenkbank L4: five signal types on a 390px control page). From the width\n * where they fit, both look the same.\n */\n overflow?: \"truncate\" | \"wrap\";\n /**\n * @deprecated Pass `aria-label` instead — the DOM spelling, which every other\n * control in this kit now answers to. Kept working because three applications ship\n * this one today; it names the group only when `aria-label` is absent.\n */\n ariaLabel?: string;\n /**\n * Show, refuse the change (Keksdose live #288: a payment dated in the future has no\n * state to set).\n *\n * Whatever `value` says stays pressed and keeps its own fill rather than going grey\n * with the rest — a reader who cannot see WHICH option is chosen has been told less\n * than before it was disabled. A caller with nothing to show passes no value, and\n * the group renders dimmed with nothing pressed, which is the shape Keksdose's\n * status picker uses for a row whose status does not exist yet.\n *\n * On the whole GROUP, not per option: a segmented control where some segments are\n * live and others are not is a menu with holes in it, and no caller here wants one.\n */\n disabled?: boolean;\n /**\n * `sm`: 12px options with `px-2 py-1` — the compact group keksdose's rule editor\n * (rule-editor:204) writes as `optionClassName=\"px-2 py-1 text-xs\"` beside a small\n * caption. `md` (default) is the size every other group has.\n */\n size?: \"sm\" | \"md\";\n /**\n * Stand in a form row as a FIELD: with a label the group wears the field's chrome —\n * border, surface, the top strip with a small static label in it, a labelled\n * {@link Select}'s height — so beside an Input or a Select it reads as one of them\n * rather than as a control with a caption over it. lenkbank builds exactly this by\n * hand as `ToggleField` (features/gear/common.tsx:97, feedback #69), and its notes\n * are why the chrome STRETCHES to its row as well as matching the select's padding:\n * a native select's height is the browser's, so a toggle a few pixels short of it\n * is levelled up by the row rather than by arithmetic.\n *\n * The label names the group (`aria-labelledby`), so `aria-label` is not needed. With\n * a label, `className` styles the field's wrapper — as on {@link Select} — and the\n * group's own box is dropped: two nested borders read as a control in a control.\n */\n label?: ReactNode;\n /**\n * Where `label` goes. `\"field\"` (default): the field chrome described under `label`.\n * `\"above\"`: the kit's {@link Label} over the bare group — the shape of a {@link Field}\n * — with `hint` beside the label and `error` under the group, for a form that sets\n * its labels above its fields (kastlan's international-rent-calculator.tsx, whose DE\n * cap pair sits in a `Field` column between two labelled-above inputs, where the\n * chrome's inner label would be the only one of its kind).\n *\n * Inside a `Field`, pass no `label` at all and spread the render-prop instead —\n * `{(ids, { labelId }) => <ToggleGroup {...ids} aria-labelledby={labelId} … />}` —\n * so the Field's label names the group and its hint and error describe it.\n */\n labelPlacement?: \"field\" | \"above\";\n /** A {@link FieldHint} on the label line, as on a labelled {@link Select}. Only with\n * `label`. */\n hint?: ReactNode;\n /** The message under the field when it is wrong: paints the field's border with\n * `--danger`, marks the group `aria-invalid` and describes it with the message, as\n * {@link Select}'s `error` does. Only with `label`. */\n error?: ReactNode;\n}\n\n/**\n * A line under the group saying what the CHOSEN option means — lenkbank's ToggleField\n * `hint` (features/gear/common.tsx:97): not help behind a \"?\" but a caption, and one\n * that changes as the choice does. Pass a function of the value for that; it is\n * attached with `aria-describedby`, and a function caption is also a polite live\n * region, because a description is read when the group is entered and not again when\n * an arrow key changes the choice underneath it.\n *\n * In muted 11px text under the field (or the bare group), above an `error`.\n */\ntype ToggleGroupCaption<V> = ReactNode | ((value: V) => ReactNode);\n\n/** The group as it has always been: one option is always the answer. */\nexport interface ToggleGroupRequiredProps<T extends string> extends ToggleGroupBaseProps<T> {\n allowEmpty?: false;\n /**\n * What the options ARE to a screen reader, separately from whether the group can be\n * emptied (kastlan feedback #47).\n *\n * - `\"radio\"` (default) — a `radiogroup` of radios: one Tab stop, arrow keys MOVE the\n * choice. Right for a choice between answers (\"Monthly / Yearly\").\n * - `\"pressed\"` — a `group` of toggle buttons (`aria-pressed`), each its own Tab stop,\n * Space/Enter to press; still one option always pressed. Right for a row that reads\n * as a set of switches — a view mode, a toolbar-like filter — where arrows moving the\n * selection on focus would be a surprise.\n *\n * Before this the only way to `aria-pressed` was `allowEmpty`, which also let a second\n * press clear the choice — so kastlan took the clearable shape and threw the `null`\n * away in `onChange` (`(v) => v && setMode(v)`), a group announcing that a press would\n * unpress what it would not. Here a press on the pressed option re-sends its value, as\n * the radio shape does, and nothing is ever unpressed. A clearable group\n * (`allowEmpty`) is always `\"pressed\"`: a radio cannot be unchecked by activating it.\n */\n semantics?: \"radio\" | \"pressed\";\n value: T;\n onChange: (value: T) => void;\n /** See {@link ToggleGroupCaption}. */\n caption?: ToggleGroupCaption<T>;\n}\n\n/**\n * A group that can be emptied: clicking the active option clears it, and `onChange`\n * receives `null` (Keksdose's support-panel filters, where \"no filter\" is reached by\n * clicking the filter that is on).\n *\n * The options become TOGGLE BUTTONS (`aria-pressed`, in a `role=\"group\"`) rather than\n * radios. A radio cannot be unchecked by activating it — no screen reader user expects\n * a second press on \"Open, radio, checked\" to leave nothing checked, and nothing would\n * tell them it had. \"Open, toggle button, pressed\" says exactly what a press will do.\n */\nexport interface ToggleGroupClearableProps<T extends string> extends ToggleGroupBaseProps<T> {\n allowEmpty: true;\n /** Always toggle buttons — see {@link ToggleGroupRequiredProps.semantics}. Accepted so\n * a wrapper can forward one `semantics` to either shape. */\n semantics?: \"pressed\";\n value: T | null;\n onChange: (value: T | null) => void;\n /** See {@link ToggleGroupCaption}. `null` while nothing is chosen. */\n caption?: ToggleGroupCaption<T | null>;\n}\n\n/** `allowEmpty` picks the shape, so `onChange` is typed `(T) => void` unless the group\n * can actually emit `null` — no existing caller has a `null` to handle. */\nexport type ToggleGroupProps<T extends string> =\n | ToggleGroupRequiredProps<T>\n | ToggleGroupClearableProps<T>;\n\n/**\n * Overloaded rather than typed by the union alone (keksdose, \"Gaps found adopting\n * 0.6.0\" #7). Inferring `T` through a union of prop shapes let TypeScript settle on\n * `string`, so `<ToggleGroup allowEmpty value={filter} onChange={setFilter} />` over a\n * `useState<Status | null>` did not compile unless the caller spelled\n * `<ToggleGroup<Status>>`. One signature per mode lets each infer `T` from its own\n * `value`/`onChange`/`options`; the third keeps a caller that forwards a\n * {@link ToggleGroupProps} union (a wrapper component) compiling.\n */\nexport function ToggleGroup<T extends string>(props: ToggleGroupClearableProps<T>): ReactElement;\nexport function ToggleGroup<T extends string>(props: ToggleGroupRequiredProps<T>): ReactElement;\nexport function ToggleGroup<T extends string>(props: ToggleGroupProps<T>): ReactElement;\nexport function ToggleGroup<T extends string>(props: ToggleGroupProps<T>): ReactElement {\n const {\n value,\n options,\n className,\n optionClassName,\n overflow = \"truncate\",\n ariaLabel,\n disabled = false,\n size = \"md\",\n label,\n labelPlacement = \"field\",\n hint,\n error,\n \"aria-label\": ariaLabelAttr,\n ...restWithMode\n } = props;\n const labelId = useId();\n const errorId = useId();\n const labelled = label !== undefined && label !== null && label !== false && label !== \"\";\n // `field` is the chrome; a label placed above keeps the bare group's own box.\n const field = labelled && labelPlacement === \"field\";\n const above = labelled && labelPlacement === \"above\";\n const hasError = labelled && error !== undefined && error !== null && error !== false && error !== \"\";\n // Taken off the rest so neither reaches the DOM; `props` keeps them paired, which is\n // what lets the `onChange` below be called with `null` only in the mode that allows it.\n const { allowEmpty: _allowEmpty, onChange: _onChange, caption, semantics: _semantics, ...rest } = restWithMode;\n // Invalid from outside too: a `Field` hands the bare group `aria-invalid`, and the\n // border has to say what the attribute says.\n const outsideInvalid = rest[\"aria-invalid\"] === true || rest[\"aria-invalid\"] === \"true\";\n const captionId = useId();\n const captionIsLive = typeof caption === \"function\";\n const captionNode = captionIsLive ? (caption as (v: T | null) => ReactNode)(value) : caption;\n const hasCaption = captionNode !== undefined && captionNode !== null && captionNode !== false && captionNode !== \"\";\n const choose = (next: T) => {\n if (props.allowEmpty) props.onChange(next === value ? null : next);\n else props.onChange(next);\n };\n // `pressed`: toggle buttons. Every clearable group is; a required one is when it asks\n // (kastlan #47) — the role, and not whether a second press clears, is what this flag\n // decides from here on, so `choose` above still keys off `allowEmpty` alone.\n const pressed = props.allowEmpty === true || props.semantics === \"pressed\";\n // A radio group is ONE tab stop (the checked radio, else the first) and arrows move\n // the choice — the pattern `role=\"radiogroup\"` promises a screen-reader user. Before\n // 0.7.0 each segment was its own tab stop with no arrow keys. The toggle-button shape\n // is a row of buttons, where separate tab stops are the pattern.\n const tabStop = options.some((o) => o.value === value) ? value : options[0]?.value;\n const onRadioKey = (e: KeyboardEvent<HTMLButtonElement>, index: number) => {\n const last = options.length - 1;\n let next: number | null = null;\n const step = horizontalStep(e.key, e.currentTarget);\n if (step !== 0) next = index + step;\n else if (e.key === \"ArrowDown\") next = index + 1;\n else if (e.key === \"ArrowUp\") next = index - 1;\n else if (e.key === \"Home\") next = 0;\n else if (e.key === \"End\") next = last;\n if (next === null) return;\n e.preventDefault();\n next = next < 0 ? last : next > last ? 0 : next;\n const buttons = e.currentTarget.parentElement?.querySelectorAll<HTMLButtonElement>(\":scope > button\");\n buttons?.[next]?.focus();\n choose(options[next].value);\n };\n const group = (\n <div\n // The audit's named example of a closed prop list (§\"Public API design\"): the\n // tour locates a step by CSS SELECTOR, so a component that drops every attribute\n // it was not expecting cannot be spotlighted at all — and Keksdose's rule editor\n // carries a comment explaining that it wraps this group in a bare <div> for\n // exactly that reason.\n //\n // `...rest` first, then the attributes the group cannot do without: a caller\n // hanging an anchor or a test id on the group must not be able to overwrite the\n // radiogroup role or the disabled state by accident. `className` is destructured\n // out entirely and merged through `cn`, so it is never in here.\n {...rest}\n role={pressed ? \"group\" : \"radiogroup\"}\n // The DOM spelling wins; `ariaLabel` is the fallback for the call sites that\n // have not moved yet.\n aria-label={ariaLabelAttr ?? ariaLabel}\n aria-labelledby={labelled && ariaLabelAttr === undefined && ariaLabel === undefined ? labelId : rest[\"aria-labelledby\"]}\n aria-invalid={hasError || rest[\"aria-invalid\"] || undefined}\n aria-describedby={\n [rest[\"aria-describedby\"], hasCaption && captionId, hasError && errorId].filter(Boolean).join(\" \") || undefined\n }\n // `aria-disabled` on the group as well as `disabled` on each button: a radio\n // group is what the user is being refused, and a screen reader announcing\n // three separately-disabled radios does not say that.\n aria-disabled={disabled || undefined}\n className={cn(\n // `gap-0.5` — the same 2px as the container's own padding, so EVERY segment\n // sits in a uniform 2px moat and no two fills ever touch. Flush segments were\n // Keksdose live #268's rework: the pressed segment wears a saturated fill and\n // an unpressed neighbour wears a pale hover fill, and with a shared edge the\n // two rectangles read as one smeared shape — *\"the boundary of the selected\n // option and hovering next to it overlays the boundary of the selected\n // button\"*. A gap is what makes each segment its own chip; it cannot be\n // undone by a caller's per-option colour, which a hover-only fix could.\n //\n // (The hover fill is the DESKTOP half of that report: Tailwind v4 wraps every\n // `hover:` in `@media (hover: hover)`, so a phone never paints it. The half a\n // phone does see is the focus ring — see the segment's own note below.)\n \"inline-flex w-full gap-0.5 rounded-md border border-[var(--border-strong)] bg-[var(--bg-surface)] p-0.5 shadow-sm\",\n overflow === \"wrap\" && \"flex-wrap\",\n // The whole group fades, the way every other disabled control in this\n // package does; `cursor-not-allowed` is on the buttons, which is what a\n // pointer is actually over.\n disabled && \"opacity-60\",\n // The bare group (no chrome to paint) wears the invalid border itself.\n !field && (outsideInvalid || (above && hasError)) && FIELD_INVALID,\n // Inside the field's chrome the group is only a row of segments: no border, no\n // surface, no padding of its own, and the field (not the group) is what dims.\n field && \"border-0 bg-transparent p-0 shadow-none opacity-100\",\n !labelled && className,\n )}\n >\n {options.map((opt, index) => {\n const active = opt.value === value;\n return (\n <button\n key={opt.value}\n type=\"button\"\n role={pressed ? undefined : \"radio\"}\n aria-checked={pressed ? undefined : active}\n aria-pressed={pressed ? active : undefined}\n disabled={disabled}\n tabIndex={pressed ? undefined : opt.value === tabStop ? 0 : -1}\n onKeyDown={pressed ? undefined : (e) => onRadioKey(e, index)}\n onClick={() => choose(opt.value)}\n className={cn(\n // `truncate` (which carries whitespace-nowrap) rather than letting a\n // label wrap: a segmented control sizes its whole row to the tallest\n // option, so one two-word option — Keksdose feedback #147's \"Where I\n // am\" — silently doubles the height of every segment beside it.\n //\n // `basis-auto` is what keeps that ellipsis a LAST resort rather than\n // the normal state (Keksdose dev#475). With flex-1's `basis-0`, a\n // shrink-to-fit group (`w-auto`) still resolves to the sum of the\n // labels' widths — and then splits it EQUALLY, so the short option\n // got 66px it did not need and \"Where I am\" got 66 of the 81 it did:\n // truncated at 1778px of free screen. Basing each segment on its own\n // content and sharing only the LEFTOVER space keeps a full-width\n // group's segments near-equal and an auto-width group's exact.\n //\n // `focus-visible` + `ring-inset`, not `focus` + an outset ring. A ring\n // is a box-shadow that spreads OUTWARD, so on a flush group it painted\n // 2px of ring over both neighbours and over the container's own border\n // — and on a phone it appeared on every TAP, because a tap focuses the\n // button. That is the other half of what live #268's rework saw\n // overlaying the selected segment's boundary. Inset keeps the ring\n // inside the segment it belongs to; focus-visible keeps it for the\n // keyboard, which is the only input that needs it.\n overflow === \"wrap\" ? \"whitespace-nowrap\" : \"min-w-0 truncate\",\n \"flex-1 basis-auto rounded px-3 py-1.5 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--border-strong)]\",\n size === \"sm\" && \"px-2 py-1 text-xs\",\n // In a field: no vertical padding and a 20px line — a `text-sm` line, the\n // same line a labelled Select holds under its label strip — so the field's\n // own `pt-4 pb-1` decides the height, as it does for the select.\n field && \"py-0 leading-5\",\n active\n ? \"bg-[var(--bg-inverse)] text-[var(--text-inverse)]\"\n : \"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]\",\n // No hover fill on a group that cannot be changed — a segment that\n // lights up under the pointer is an offer, and there is none here. Not on\n // the chosen segment: its fill IS its state, and its inverse text would\n // vanish on a transparent hover.\n disabled && \"cursor-not-allowed\",\n disabled && !active && \"hover:bg-transparent dark:hover:bg-transparent\",\n optionClassName,\n opt.className,\n )}\n >\n {opt.label}\n </button>\n );\n })}\n </div>\n );\n // Rendered whenever the caption is — `aria-live` must be on the element BEFORE its\n // text changes, or the change is not announced — but empty (no height, no margin)\n // when there is nothing to say, so a function caption that returns null for some\n // options leaves no gap. Empty rather than `hidden`: some readers do not announce\n // text that appears inside an element coming back from `display: none`.\n const captionEl =\n hasCaption || captionIsLive ? (\n <p\n id={captionId}\n aria-live={captionIsLive ? \"polite\" : undefined}\n className={cn(\"text-[11px] leading-snug text-[var(--text-muted)]\", hasCaption && \"mt-1\")}\n >\n {hasCaption ? captionNode : null}\n </p>\n ) : null;\n const errorEl = hasError ? (\n <p id={errorId} className=\"mt-1 text-[11px] leading-tight text-[var(--danger)]\">\n {error}\n </p>\n ) : null;\n if (above) {\n // `relative` so a caller's `sr-only` label cannot escape (sr-only-containment).\n return (\n <div className={cn(\"relative grid min-w-0 gap-1.5\", className)}>\n <div className=\"flex items-center gap-1\">\n {/* A `<label>` with no `htmlFor`: a group is not labelable, so it is named\n by `aria-labelledby` on the group; the element keeps the Field look. */}\n <Label\n id={labelId}\n disabled={disabled}\n data-error={hasError || undefined}\n className=\"data-[error=true]:text-[var(--danger)]\"\n >\n {label}\n </Label>\n {hint}\n </div>\n <div className=\"min-w-0\">\n {group}\n {captionEl}\n {errorEl}\n </div>\n </div>\n );\n }\n if (!field) {\n if (!captionEl) return group;\n // The group keeps its `className`, as without a caption; the wrapper only stacks.\n return (\n <div className=\"min-w-0\">\n {group}\n {captionEl}\n </div>\n );\n }\n return (\n // `h-full` + `flex-1`: the chrome fills a grid or stretched flex row, which is what\n // levels it with a select beside it whatever the browser makes of the select.\n <div className={cn(\"flex h-full flex-col\", className)}>\n <FloatingField\n className=\"flex flex-1 flex-col\"\n label={<span id={labelId}>{label}</span>}\n staticLabel\n hint={hint}\n >\n <div\n className={cn(\n \"flex flex-1 flex-col justify-center rounded-md border border-[var(--border)] bg-[var(--bg-surface)] px-1 pt-4 pb-1 shadow-sm\",\n disabled && \"bg-[var(--bg-surface-2)] opacity-60\",\n hasError && FIELD_INVALID,\n )}\n >\n {group}\n </div>\n </FloatingField>\n {captionEl}\n {errorEl}\n </div>\n );\n}\n"],"mappings":";AA0SU,cAmFF,YAnFE;AA1SV,SAAS,aAAa;AAEtB,SAAS,UAAU;AACnB,SAAS,sBAAsB;AAC/B,SAAS,eAAe,eAAe,aAAa;AA+K7C,SAAS,YAA8B,OAA0C;AACtF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA,WAAW;AAAA,IACX,OAAO;AAAA,IACP;AAAA,IACA,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,GAAG;AAAA,EACL,IAAI;AACJ,QAAM,UAAU,MAAM;AACtB,QAAM,UAAU,MAAM;AACtB,QAAM,WAAW,UAAU,UAAa,UAAU,QAAQ,UAAU,SAAS,UAAU;AAEvF,QAAM,QAAQ,YAAY,mBAAmB;AAC7C,QAAM,QAAQ,YAAY,mBAAmB;AAC7C,QAAM,WAAW,YAAY,UAAU,UAAa,UAAU,QAAQ,UAAU,SAAS,UAAU;AAGnG,QAAM,EAAE,YAAY,aAAa,UAAU,WAAW,SAAS,WAAW,YAAY,GAAG,KAAK,IAAI;AAGlG,QAAM,iBAAiB,KAAK,cAAc,MAAM,QAAQ,KAAK,cAAc,MAAM;AACjF,QAAM,YAAY,MAAM;AACxB,QAAM,gBAAgB,OAAO,YAAY;AACzC,QAAM,cAAc,gBAAiB,QAAuC,KAAK,IAAI;AACrF,QAAM,aAAa,gBAAgB,UAAa,gBAAgB,QAAQ,gBAAgB,SAAS,gBAAgB;AACjH,QAAM,SAAS,CAAC,SAAY;AAC1B,QAAI,MAAM,WAAY,OAAM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uBAAa,cAAc;AAAA;AAAA,EAC9B,IACE;AACN,QAAM,UAAU,WACd,oBAAC,OAAE,IAAI,SAAS,WAAU,uDACvB,iBACH,IACE;AACJ,MAAI,OAAO;AAET,WACE,qBAAC,SAAI,WAAW,GAAG,iCAAiC,SAAS,GAC3D;AAAA,2BAAC,SAAI,WAAU,2BAGb;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,IAAI;AAAA,YACJ;AAAA,YACA,cAAY,YAAY;AAAA,YACxB,WAAU;AAAA,YAET;AAAA;AAAA,QACH;AAAA,QACC;AAAA,SACH;AAAA,MACA,qBAAC,SAAI,WAAU,WACZ;AAAA;AAAA,QACA;AAAA,QACA;AAAA,SACH;AAAA,OACF;AAAA,EAEJ;AACA,MAAI,CAAC,OAAO;AACV,QAAI,CAAC,UAAW,QAAO;AAEvB,WACE,qBAAC,SAAI,WAAU,WACZ;AAAA;AAAA,MACA;AAAA,OACH;AAAA,EAEJ;AACA;AAAA;AAAA;AAAA,IAGE,qBAAC,SAAI,WAAW,GAAG,wBAAwB,SAAS,GAClD;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,OAAO,oBAAC,UAAK,IAAI,SAAU,iBAAM;AAAA,UACjC,aAAW;AAAA,UACX;AAAA,UAEA;AAAA,YAAC;AAAA;AAAA,cACC,WAAW;AAAA,gBACT;AAAA,gBACA,YAAY;AAAA,gBACZ,YAAY;AAAA,cACd;AAAA,cAEC;AAAA;AAAA,UACH;AAAA;AAAA,MACF;AAAA,MACC;AAAA,MACA;AAAA,OACH;AAAA;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/toggle-group.tsx"],"sourcesContent":["import { useId } from \"react\";\nimport type { ComponentPropsWithoutRef, KeyboardEvent, ReactElement, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { horizontalStep } from \"../lib/direction\";\nimport { FIELD_INVALID, FloatingField, Label } from \"./ui\";\nimport { Tooltip } from \"./tooltip\";\nimport { useCommitReason } from \"./write-lock\";\nimport { hasContent, LabelStrip } from \"./field-parts\";\n\nexport interface ToggleOption<T extends string> {\n value: T;\n label: string;\n className?: string;\n}\n\n/**\n * `onChange` is the group's own — the chosen VALUE, not a DOM event — so the div's\n * `onChange` is omitted rather than shadowed: leaving both in scope would give the\n * prop two incompatible meanings depending on which overload TypeScript picked.\n *\n * `children` is omitted too: this renders its `options` and nothing else, so a `children` the type\n * accepted and the component ignored would be a prop that silently does nothing —\n * worse than one that does not compile.\n */\nexport interface ToggleGroupBaseProps<T extends string>\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"onChange\" | \"children\"> {\n options: ToggleOption<T>[];\n className?: string;\n /** Applied to every option button (e.g. to tune height/rounding to match\n * adjacent fields). Per-option `className` still wins over this. */\n optionClassName?: string;\n /**\n * What happens when the options do not fit the group's width. `\"truncate\"`\n * (default): one row, and the labels that do not fit end in an ellipsis — the height\n * never changes. `\"wrap\"`: the segments flow onto a second row and every label stays\n * whole (\"Bewegung\", not \"Beweg…\"), at the price of a taller group on a narrow\n * screen (lenkbank L4: five signal types on a 390px control page). From the width\n * where they fit, both look the same.\n */\n overflow?: \"truncate\" | \"wrap\";\n /**\n * @deprecated Pass `aria-label` instead — the DOM spelling, which every other\n * control in this kit now answers to. Kept working because three applications ship\n * this one today; it names the group only when `aria-label` is absent.\n */\n ariaLabel?: string;\n /**\n * Show, refuse the change (Keksdose live #288: a payment dated in the future has no\n * state to set).\n *\n * Whatever `value` says stays pressed and keeps its own fill rather than going grey\n * with the rest — a reader who cannot see WHICH option is chosen has been told less\n * than before it was disabled. A caller with nothing to show passes no value, and\n * the group renders dimmed with nothing pressed, which is the shape Keksdose's\n * status picker uses for a row whose status does not exist yet.\n *\n * On the whole GROUP, not per option: a segmented control where some segments are\n * live and others are not is a menu with holes in it, and no caller here wants one.\n */\n disabled?: boolean;\n /**\n * `sm`: 12px options with `px-2 py-1` — the compact group keksdose's rule editor\n * (rule-editor:204) writes as `optionClassName=\"px-2 py-1 text-xs\"` beside a small\n * caption. `md` (default) is the size every other group has.\n *\n * Honoured inside the field chrome and the strip too (keksdose K1): the 12px type\n * stays, and the field is still 42px — see `CHROME_PAD`.\n */\n size?: \"sm\" | \"md\";\n /**\n * Stand in a form row as a FIELD: with a label the group wears the field's chrome —\n * border, surface, the top strip with a small static label in it, a labelled\n * {@link Select}'s height — so beside an Input or a Select it reads as one of them\n * rather than as a control with a caption over it. lenkbank builds exactly this by\n * hand as `ToggleField` (features/gear/common.tsx:97, feedback #69), and its notes\n * are why the chrome STRETCHES to its row as well as matching the select's padding:\n * a native select's height is the browser's, so a toggle a few pixels short of it\n * is levelled up by the row rather than by arithmetic.\n *\n * The label names the group (`aria-labelledby`), so `aria-label` is not needed. With\n * a label, `className` styles the field's wrapper — as on {@link Select} — and the\n * group's own box is dropped: two nested borders read as a control in a control.\n */\n label?: ReactNode;\n /**\n * Where `label` goes. `\"field\"` (default): the field chrome described under `label`.\n * `\"above\"`: the kit's {@link Label} over the bare group — the shape of a {@link Field}\n * — with `hint` beside the label and `error` under the group, for a form that sets\n * its labels above its fields (kastlan's international-rent-calculator.tsx, whose DE\n * cap pair sits in a `Field` column between two labelled-above inputs, where the\n * chrome's inner label would be the only one of its kind).\n *\n * `\"strip\"`: the 11px static label (and `hint`) in a strip OVER the bare group, for a\n * group that stands in a row of fields but is not one (keksdose K2 — the transaction\n * row's cleared-status picker, live #288 / #431 / dev#468). No field border: the group\n * keeps its own box, and its segments drop their vertical padding so a 16px strip\n * plus the 26px group is exactly a labelled {@link Input}'s 42px, the label on the\n * same line as theirs. `error` and `caption` go under the group, as in the other two.\n *\n * Inside a `Field`, pass no `label` at all and spread the render-prop instead —\n * `{(ids, { labelId }) => <ToggleGroup {...ids} aria-labelledby={labelId} … />}` —\n * so the Field's label names the group and its hint and error describe it.\n */\n labelPlacement?: \"field\" | \"above\" | \"strip\";\n /**\n * Classes for the field chrome's own box — the bordered, padded box round the\n * segments — merged last, so they win. `className` styles the wrapper the chrome sits\n * in; this reaches the box itself. Only with `label` in the `\"field\"` placement.\n *\n * For a field JOINED flush to a neighbour (keksdose K1): reports-filters.tsx joins its\n * \"group by\" field to the range select on its start edge from `md` up, and squares the\n * shared corners by hand chrome today — here that is\n * `chromeClassName=\"md:rounded-s-none\"` with `className=\"md:-ms-px\"` (the wrapper\n * overlaps the neighbour by the one border they share). A class rather than a\n * `joined=\"start\"` because every such join keksdose has is responsive: on a phone the\n * two stack and both keep their corners.\n */\n chromeClassName?: string;\n /** A {@link FieldHint} on the label line, as on a labelled {@link Select}. Only with\n * `label`. */\n hint?: ReactNode;\n /** The message under the field when it is wrong: paints the field's border with\n * `--danger`, marks the group `aria-invalid` and describes it with the message, as\n * {@link Select}'s `error` does. Only with `label`. */\n error?: ReactNode;\n /**\n * Why the group cannot be changed right now — {@link Button}'s `disabledReason`, for\n * a group that saves itself on change (keksdose K3: the last `SaveGuard` sites are\n * self-committing controls like this one, and SaveGuard's native `disabled` took\n * them out of the tab order so the reason never reached a keyboard).\n *\n * The group stays reachable — its segments are `aria-disabled`, not `disabled`, and\n * a radio group's arrow keys still walk them — but nothing reaches `onChange`, and\n * the reason shows in the kit {@link Tooltip} over the segments on hover or focus and\n * describes each segment. The chosen option keeps its fill, as under `disabled`.\n * Wins over `disabled`, as on Button: passing both keeps the group reachable.\n */\n disabledReason?: ReactNode;\n /**\n * This group COMMITS — choosing an option saves it. Under a locked\n * {@link WriteLockProvider} it takes the `disabledReason` path with the lock's\n * reason (which wins over a `disabledReason` of its own): *\"everything renders; only\n * the commit is locked\"* (keksdose dev#496/#497), and a control that is its own commit\n * must render refused, never live-and-discarding. No provider, or an unlocked one:\n * no effect.\n */\n commit?: boolean;\n}\n\n/**\n * The field chrome's vertical geometry — keksdose K1, the kit reintroducing feedback\n * #117 that keksdose's hand-built chrome had fixed.\n *\n * The label is the field's static label: `top-1` and 11px in a `leading-tight` line, so\n * its line box runs from 4px to 17.75px. Until 0.22 the chrome was `pt-4` over a 20px\n * (`leading-5`) segment, so the ACTIVE segment's fill — painted from the top of the\n * segment — started at 17px (1px border + 16px), 0.75px INSIDE the label's line box:\n * the highlight touched the word above it, exactly what #117's rework had measured and\n * cured with `pt-5`.\n *\n * Now the strip is `pt-5` and the fill starts at 21px, 3.25px clear, and the segment\n * gives the 4px back so the field stays a labelled Select's 42px: `md` sets its 14px\n * text in an 18px line with a 2px moat under it (the bare group's own `p-0.5` moat),\n * `sm` sets 12px text in a 16px line over `pb-1` — keksdose's measured chrome\n * (price-level-picker, reports-filters: `pt-5 pb-1`, `text-xs md:py-0`), byte for byte.\n * Before, `size=\"sm\"` inside the chrome was overridden to the md 20px line.\n *\n * md: 1 + 20 + 18 + 2 + 1 = 42 sm: 1 + 20 + 16 + 4 + 1 = 42\n */\nconst CHROME_PAD: Record<\"sm\" | \"md\", string> = { md: \"pt-5 pb-0.5\", sm: \"pt-5 pb-1\" };\nconst CHROME_SEGMENT: Record<\"sm\" | \"md\", string> = { md: \"py-0 leading-[18px]\", sm: \"py-0 leading-4\" };\n\n/**\n * The strip placement's segments: a 26px group (1 + 2 + 20 + 2 + 1) under the 16px\n * strip — `md`'s 20px text-sm line with no padding, `sm`'s 16px line with 2px either\n * side. See `LABEL_STRIP_PAD` for why 16.\n */\nconst STRIP_SEGMENT: Record<\"sm\" | \"md\", string> = { md: \"py-0\", sm: \"py-0.5\" };\n\n/**\n * A line under the group saying what the CHOSEN option means — lenkbank's ToggleField\n * `hint` (features/gear/common.tsx:97): not help behind a \"?\" but a caption, and one\n * that changes as the choice does. Pass a function of the value for that; it is\n * attached with `aria-describedby`, and a function caption is also a polite live\n * region, because a description is read when the group is entered and not again when\n * an arrow key changes the choice underneath it.\n *\n * In muted 11px text under the field (or the bare group), above an `error`.\n */\ntype ToggleGroupCaption<V> = ReactNode | ((value: V) => ReactNode);\n\n/** The group as it has always been: one option is always the answer. */\nexport interface ToggleGroupRequiredProps<T extends string> extends ToggleGroupBaseProps<T> {\n allowEmpty?: false;\n /**\n * What the options ARE to a screen reader, separately from whether the group can be\n * emptied (kastlan feedback #47).\n *\n * - `\"radio\"` (default) — a `radiogroup` of radios: one Tab stop, arrow keys MOVE the\n * choice. Right for a choice between answers (\"Monthly / Yearly\").\n * - `\"pressed\"` — a `group` of toggle buttons (`aria-pressed`), each its own Tab stop,\n * Space/Enter to press; still one option always pressed. Right for a row that reads\n * as a set of switches — a view mode, a toolbar-like filter — where arrows moving the\n * selection on focus would be a surprise.\n *\n * Before this the only way to `aria-pressed` was `allowEmpty`, which also let a second\n * press clear the choice — so kastlan took the clearable shape and threw the `null`\n * away in `onChange` (`(v) => v && setMode(v)`), a group announcing that a press would\n * unpress what it would not. Here a press on the pressed option re-sends its value, as\n * the radio shape does, and nothing is ever unpressed. A clearable group\n * (`allowEmpty`) is always `\"pressed\"`: a radio cannot be unchecked by activating it.\n */\n semantics?: \"radio\" | \"pressed\";\n value: T;\n onChange: (value: T) => void;\n /** See {@link ToggleGroupCaption}. */\n caption?: ToggleGroupCaption<T>;\n}\n\n/**\n * A group that can be emptied: clicking the active option clears it, and `onChange`\n * receives `null` (Keksdose's support-panel filters, where \"no filter\" is reached by\n * clicking the filter that is on).\n *\n * The options become TOGGLE BUTTONS (`aria-pressed`, in a `role=\"group\"`) rather than\n * radios. A radio cannot be unchecked by activating it — no screen reader user expects\n * a second press on \"Open, radio, checked\" to leave nothing checked, and nothing would\n * tell them it had. \"Open, toggle button, pressed\" says exactly what a press will do.\n */\nexport interface ToggleGroupClearableProps<T extends string> extends ToggleGroupBaseProps<T> {\n allowEmpty: true;\n /** Always toggle buttons — see {@link ToggleGroupRequiredProps.semantics}. Accepted so\n * a wrapper can forward one `semantics` to either shape. */\n semantics?: \"pressed\";\n value: T | null;\n onChange: (value: T | null) => void;\n /** See {@link ToggleGroupCaption}. `null` while nothing is chosen. */\n caption?: ToggleGroupCaption<T | null>;\n}\n\n/** `allowEmpty` picks the shape, so `onChange` is typed `(T) => void` unless the group\n * can actually emit `null` — no existing caller has a `null` to handle. */\nexport type ToggleGroupProps<T extends string> =\n | ToggleGroupRequiredProps<T>\n | ToggleGroupClearableProps<T>;\n\n/**\n * Overloaded rather than typed by the union alone (keksdose, \"Gaps found adopting\n * 0.6.0\" #7). Inferring `T` through a union of prop shapes let TypeScript settle on\n * `string`, so `<ToggleGroup allowEmpty value={filter} onChange={setFilter} />` over a\n * `useState<Status | null>` did not compile unless the caller spelled\n * `<ToggleGroup<Status>>`. One signature per mode lets each infer `T` from its own\n * `value`/`onChange`/`options`; the third keeps a caller that forwards a\n * {@link ToggleGroupProps} union (a wrapper component) compiling.\n */\nexport function ToggleGroup<T extends string>(props: ToggleGroupClearableProps<T>): ReactElement;\nexport function ToggleGroup<T extends string>(props: ToggleGroupRequiredProps<T>): ReactElement;\nexport function ToggleGroup<T extends string>(props: ToggleGroupProps<T>): ReactElement;\nexport function ToggleGroup<T extends string>(props: ToggleGroupProps<T>): ReactElement {\n const {\n value,\n options,\n className,\n optionClassName,\n overflow = \"truncate\",\n ariaLabel,\n disabled = false,\n size = \"md\",\n label,\n labelPlacement = \"field\",\n chromeClassName,\n hint,\n error,\n disabledReason: ownDisabledReason,\n commit,\n \"aria-label\": ariaLabelAttr,\n ...restWithMode\n } = props;\n const labelId = useId();\n const errorId = useId();\n const reasonId = useId();\n // The lock's reason under a locked provider (with `commit`), else the group's own.\n const disabledReason = useCommitReason(commit, ownDisabledReason);\n const locked = hasContent(disabledReason);\n // Locked looks disabled — the dimmed group, the not-allowed cursor, no hover offer —\n // but stays focusable; `disabled` alone also takes the segments out of the tab order.\n const dimmed = disabled || locked;\n const labelled = hasContent(label);\n // `field` is the chrome; a label placed above or in a strip keeps the bare group's\n // own box.\n const field = labelled && labelPlacement === \"field\";\n const above = labelled && labelPlacement === \"above\";\n const strip = labelled && labelPlacement === \"strip\";\n const hasError = labelled && hasContent(error);\n // Taken off the rest so neither reaches the DOM; `props` keeps them paired, which is\n // what lets the `onChange` below be called with `null` only in the mode that allows it.\n const { allowEmpty: _allowEmpty, onChange: _onChange, caption, semantics: _semantics, ...rest } = restWithMode;\n // Invalid from outside too: a `Field` hands the bare group `aria-invalid`, and the\n // border has to say what the attribute says.\n const outsideInvalid = rest[\"aria-invalid\"] === true || rest[\"aria-invalid\"] === \"true\";\n const captionId = useId();\n const captionIsLive = typeof caption === \"function\";\n const captionNode = captionIsLive ? (caption as (v: T | null) => ReactNode)(value) : caption;\n const hasCaption = hasContent(captionNode);\n const choose = (next: T) => {\n // A locked group swallows the change: it saves on change, and a lock that let the\n // value move and then discarded it would show a state that was never stored.\n if (locked) return;\n if (props.allowEmpty) props.onChange(next === value ? null : next);\n else props.onChange(next);\n };\n // `pressed`: toggle buttons. Every clearable group is; a required one is when it asks\n // (kastlan #47) — the role, and not whether a second press clears, is what this flag\n // decides from here on, so `choose` above still keys off `allowEmpty` alone.\n const pressed = props.allowEmpty === true || props.semantics === \"pressed\";\n // A radio group is ONE tab stop (the checked radio, else the first) and arrows move\n // the choice — the pattern `role=\"radiogroup\"` promises a screen-reader user. Before\n // 0.7.0 each segment was its own tab stop with no arrow keys. The toggle-button shape\n // is a row of buttons, where separate tab stops are the pattern.\n const tabStop = options.some((o) => o.value === value) ? value : options[0]?.value;\n const onRadioKey = (e: KeyboardEvent<HTMLButtonElement>, index: number) => {\n const last = options.length - 1;\n let next: number | null = null;\n const step = horizontalStep(e.key, e.currentTarget);\n if (step !== 0) next = index + step;\n else if (e.key === \"ArrowDown\") next = index + 1;\n else if (e.key === \"ArrowUp\") next = index - 1;\n else if (e.key === \"Home\") next = 0;\n else if (e.key === \"End\") next = last;\n if (next === null) return;\n e.preventDefault();\n next = next < 0 ? last : next > last ? 0 : next;\n // The segments' own parent: the group, or under a lock the tooltip's row inside it.\n const buttons = e.currentTarget.parentElement?.querySelectorAll<HTMLButtonElement>(\":scope > button\");\n buttons?.[next]?.focus();\n // Locked: the focus walks (each segment says why on arrival), the choice does not.\n choose(options[next].value);\n };\n const segments = options.map((opt, index) => {\n const active = opt.value === value;\n return (\n <button\n key={opt.value}\n type=\"button\"\n role={pressed ? undefined : \"radio\"}\n aria-checked={pressed ? undefined : active}\n aria-pressed={pressed ? active : undefined}\n // A reason wins over `disabled` (as on Button): reachable, and refusing.\n disabled={disabled && !locked}\n aria-disabled={locked || undefined}\n // On each segment rather than the group: the segment is what takes focus, and\n // a group's description is not read reliably when focus lands inside it.\n aria-describedby={locked ? reasonId : undefined}\n tabIndex={pressed ? undefined : opt.value === tabStop ? 0 : -1}\n onKeyDown={pressed ? undefined : (e) => onRadioKey(e, index)}\n onClick={() => choose(opt.value)}\n className={cn(\n // `truncate` (which carries whitespace-nowrap) rather than letting a\n // label wrap: a segmented control sizes its whole row to the tallest\n // option, so one two-word option — Keksdose feedback #147's \"Where I\n // am\" — silently doubles the height of every segment beside it.\n //\n // `basis-auto` is what keeps that ellipsis a LAST resort rather than\n // the normal state (Keksdose dev#475). With flex-1's `basis-0`, a\n // shrink-to-fit group (`w-auto`) still resolves to the sum of the\n // labels' widths — and then splits it EQUALLY, so the short option\n // got 66px it did not need and \"Where I am\" got 66 of the 81 it did:\n // truncated at 1778px of free screen. Basing each segment on its own\n // content and sharing only the LEFTOVER space keeps a full-width\n // group's segments near-equal and an auto-width group's exact.\n //\n // `focus-visible` + `ring-inset`, not `focus` + an outset ring. A ring\n // is a box-shadow that spreads OUTWARD, so on a flush group it painted\n // 2px of ring over both neighbours and over the container's own border\n // — and on a phone it appeared on every TAP, because a tap focuses the\n // button. That is the other half of what live #268's rework saw\n // overlaying the selected segment's boundary. Inset keeps the ring\n // inside the segment it belongs to; focus-visible keeps it for the\n // keyboard, which is the only input that needs it.\n overflow === \"wrap\" ? \"whitespace-nowrap\" : \"min-w-0 truncate\",\n \"flex-1 basis-auto rounded px-3 py-1.5 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--border-strong)]\",\n size === \"sm\" && \"px-2 py-1 text-xs\",\n // In the field chrome: no vertical padding, and the line that makes the\n // field 42px under a strip that clears the label — see CHROME_PAD. `sm`\n // keeps its 12px type here (it used to be overridden to the md line).\n field && CHROME_SEGMENT[size],\n // In the strip placement: a 26px group under a 16px strip — STRIP_SEGMENT.\n strip && STRIP_SEGMENT[size],\n active\n ? \"bg-[var(--bg-inverse)] text-[var(--text-inverse)]\"\n : \"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]\",\n // No hover fill on a group that cannot be changed — a segment that\n // lights up under the pointer is an offer, and there is none here. Not on\n // the chosen segment: its fill IS its state, and its inverse text would\n // vanish on a transparent hover.\n dimmed && \"cursor-not-allowed\",\n dimmed && !active && \"hover:bg-transparent dark:hover:bg-transparent\",\n optionClassName,\n opt.className,\n )}\n >\n {opt.label}\n </button>\n );\n });\n const group = (\n <div\n // The audit's named example of a closed prop list (§\"Public API design\"): the\n // tour locates a step by CSS SELECTOR, so a component that drops every attribute\n // it was not expecting cannot be spotlighted at all — and Keksdose's rule editor\n // carries a comment explaining that it wraps this group in a bare <div> for\n // exactly that reason.\n //\n // `...rest` first, then the attributes the group cannot do without: a caller\n // hanging an anchor or a test id on the group must not be able to overwrite the\n // radiogroup role or the disabled state by accident. `className` is destructured\n // out entirely and merged through `cn`, so it is never in here.\n {...rest}\n role={pressed ? \"group\" : \"radiogroup\"}\n // The DOM spelling wins; `ariaLabel` is the fallback for the call sites that\n // have not moved yet.\n aria-label={ariaLabelAttr ?? ariaLabel}\n aria-labelledby={labelled && ariaLabelAttr === undefined && ariaLabel === undefined ? labelId : rest[\"aria-labelledby\"]}\n aria-invalid={hasError || rest[\"aria-invalid\"] || undefined}\n aria-describedby={\n [rest[\"aria-describedby\"], hasCaption && captionId, hasError && errorId].filter(Boolean).join(\" \") || undefined\n }\n // `aria-disabled` on the group as well as on (or `disabled` on) each button: a\n // radio group is what the user is being refused, and a screen reader announcing\n // three separately-disabled radios does not say that.\n aria-disabled={dimmed || undefined}\n className={cn(\n // `gap-0.5` — the same 2px as the container's own padding, so EVERY segment\n // sits in a uniform 2px moat and no two fills ever touch. Flush segments were\n // Keksdose live #268's rework: the pressed segment wears a saturated fill and\n // an unpressed neighbour wears a pale hover fill, and with a shared edge the\n // two rectangles read as one smeared shape — *\"the boundary of the selected\n // option and hovering next to it overlays the boundary of the selected\n // button\"*. A gap is what makes each segment its own chip; it cannot be\n // undone by a caller's per-option colour, which a hover-only fix could.\n //\n // (The hover fill is the DESKTOP half of that report: Tailwind v4 wraps every\n // `hover:` in `@media (hover: hover)`, so a phone never paints it. The half a\n // phone does see is the focus ring — see the segment's own note below.)\n \"inline-flex w-full gap-0.5 rounded-md border border-[var(--border-strong)] bg-[var(--bg-surface)] p-0.5 shadow-sm\",\n overflow === \"wrap\" && \"flex-wrap\",\n // The whole group fades, the way every other disabled control in this\n // package does; `cursor-not-allowed` is on the buttons, which is what a\n // pointer is actually over.\n dimmed && \"opacity-60\",\n // The bare group (no chrome to paint) wears the invalid border itself.\n !field && (outsideInvalid || ((above || strip) && hasError)) && FIELD_INVALID,\n // Inside the field's chrome the group is only a row of segments: no border, no\n // surface, no padding of its own, and the field (not the group) is what dims.\n field && \"border-0 bg-transparent p-0 shadow-none opacity-100\",\n !labelled && className,\n )}\n >\n {locked ? (\n // The reason's bubble wraps the SEGMENTS, inside the group, not the group: a\n // wrapper outside it would become the flex or grid item in the caller's row in\n // the group's place, and a `w-full` / `md:w-auto` on the group would size the\n // wrong box. This row inherits the group's gap and wrap, so the segments lay out\n // exactly as they do unlocked, and `:scope > button` above still finds them. A\n // fragment child, so the Tooltip describes nothing itself — each segment points\n // at the hidden copy, the way a locked Button does.\n <Tooltip label={disabledReason} className=\"flex min-w-0 flex-1 gap-[inherit] [flex-wrap:inherit]\">\n <>\n {segments}\n <span id={reasonId} hidden>\n {disabledReason}\n </span>\n </>\n </Tooltip>\n ) : (\n segments\n )}\n </div>\n );\n // Rendered whenever the caption is — `aria-live` must be on the element BEFORE its\n // text changes, or the change is not announced — but empty (no height, no margin)\n // when there is nothing to say, so a function caption that returns null for some\n // options leaves no gap. Empty rather than `hidden`: some readers do not announce\n // text that appears inside an element coming back from `display: none`.\n const captionEl =\n hasCaption || captionIsLive ? (\n <p\n id={captionId}\n aria-live={captionIsLive ? \"polite\" : undefined}\n className={cn(\"text-[11px] leading-snug text-[var(--text-muted)]\", hasCaption && \"mt-1\")}\n >\n {hasCaption ? captionNode : null}\n </p>\n ) : null;\n const errorEl = hasError ? (\n <p id={errorId} className=\"mt-1 text-[11px] leading-tight text-[var(--danger)]\">\n {error}\n </p>\n ) : null;\n if (above) {\n // `relative` so a caller's `sr-only` label cannot escape (sr-only-containment).\n return (\n <div className={cn(\"relative grid min-w-0 gap-1.5\", className)}>\n <div className=\"flex items-center gap-1\">\n {/* A `<label>` with no `htmlFor`: a group is not labelable, so it is named\n by `aria-labelledby` on the group; the element keeps the Field look. */}\n <Label\n id={labelId}\n disabled={dimmed}\n data-error={hasError || undefined}\n className=\"data-[error=true]:text-[var(--danger)]\"\n >\n {label}\n </Label>\n {hint}\n </div>\n <div className=\"min-w-0\">\n {group}\n {captionEl}\n {errorEl}\n </div>\n </div>\n );\n }\n if (strip) {\n return (\n <LabelStrip labelId={labelId} label={label} hint={hint} disabled={dimmed} pad=\"field\" className={className}>\n {group}\n {captionEl}\n {errorEl}\n </LabelStrip>\n );\n }\n if (!field) {\n if (!captionEl) return group;\n // The group keeps its `className`, as without a caption; the wrapper only stacks.\n return (\n <div className=\"min-w-0\">\n {group}\n {captionEl}\n </div>\n );\n }\n return (\n // `h-full` + `flex-1`: the chrome fills a grid or stretched flex row, which is what\n // levels it with a select beside it whatever the browser makes of the select.\n <div className={cn(\"flex h-full flex-col\", className)}>\n <FloatingField\n className=\"flex flex-1 flex-col\"\n label={<span id={labelId}>{label}</span>}\n staticLabel\n hint={hint}\n >\n <div\n className={cn(\n \"flex flex-1 flex-col justify-center rounded-md border border-[var(--border)] bg-[var(--bg-surface)] px-1 shadow-sm\",\n CHROME_PAD[size],\n dimmed && \"bg-[var(--bg-surface-2)] opacity-60\",\n hasError && FIELD_INVALID,\n chrom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ACZ;AAAA;AAAA,MACA;AAAA,OACH;AAAA,EAEJ;AACA;AAAA;AAAA;AAAA,IAGE,qBAAC,SAAI,WAAW,GAAG,wBAAwB,SAAS,GAClD;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,OAAO,oBAAC,UAAK,IAAI,SAAU,iBAAM;AAAA,UACjC,aAAW;AAAA,UACX;AAAA,UAEA;AAAA,YAAC;AAAA;AAAA,cACC,WAAW;AAAA,gBACT;AAAA,gBACA,WAAW,IAAI;AAAA,gBACf,UAAU;AAAA,gBACV,YAAY;AAAA,gBACZ;AAAA,cACF;AAAA,cAEC;AAAA;AAAA,UACH;AAAA;AAAA,MACF;AAAA,MACC;AAAA,MACA;AAAA,OACH;AAAA;AAEJ;","names":[]}
|
|
@@ -11,6 +11,9 @@ interface TriggerAria {
|
|
|
11
11
|
"aria-labelledby"?: string;
|
|
12
12
|
"aria-describedby"?: string;
|
|
13
13
|
"aria-invalid"?: boolean | "true" | "false" | "grammar" | "spelling";
|
|
14
|
+
/** 0.23.0: a form library's `required` (RhfMonthPicker) is announced on the trigger,
|
|
15
|
+
* not lost on the wrapper. */
|
|
16
|
+
"aria-required"?: boolean | "true" | "false";
|
|
14
17
|
}
|
|
15
18
|
/** Split a field's props into what its trigger takes and what its wrapper takes. */
|
|
16
19
|
declare function splitTriggerAria<T extends TriggerAria>(props: T): [TriggerAria, Omit<T, keyof TriggerAria>];
|