@eifi1/ui-kit 0.21.0 → 0.22.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/dist/chart.d.ts +10 -8
- 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 +27 -8
- package/dist/components/amount-input.js +15 -28
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/autocomplete.d.ts +8 -0
- package/dist/components/autocomplete.js +9 -4
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/button-group.d.ts +10 -8
- package/dist/components/calculator.d.ts +10 -8
- 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/combobox.d.ts +13 -2
- package/dist/components/combobox.js +17 -8
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/confirm-dialog.d.ts +66 -161
- package/dist/components/copy-button.d.ts +10 -8
- package/dist/components/country-select.d.ts +124 -0
- package/dist/components/country-select.js +237 -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 +66 -166
- package/dist/components/danger-confirm.js +133 -49
- 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 +25 -5
- package/dist/components/date-picker.js +110 -59
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/entity-combobox.d.ts +8 -1
- package/dist/components/entity-combobox.js +9 -4
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/facing-pair.d.ts +10 -8
- package/dist/components/field-anatomy.d.ts +95 -0
- package/dist/components/field-anatomy.js +84 -0
- package/dist/components/field-anatomy.js.map +1 -0
- package/dist/components/field-parts.d.ts +114 -0
- package/dist/components/field-parts.js +72 -0
- package/dist/components/field-parts.js.map +1 -0
- package/dist/components/file-button.d.ts +10 -8
- package/dist/components/file-button.js +13 -3
- package/dist/components/file-button.js.map +1 -1
- package/dist/components/file-dropzone.d.ts +32 -9
- package/dist/components/file-dropzone.js +57 -34
- package/dist/components/file-dropzone.js.map +1 -1
- package/dist/components/form-actions.d.ts +10 -8
- package/dist/components/form-actions.js +61 -3
- package/dist/components/form-actions.js.map +1 -1
- package/dist/components/iban-input.d.ts +66 -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 +12 -2
- package/dist/components/icon-picker.js +9 -2
- 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 +127 -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 +20 -8
- package/dist/components/money-field.js.map +1 -1
- package/dist/components/month-picker.d.ts +52 -4
- package/dist/components/month-picker.js +290 -86
- package/dist/components/month-picker.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 +25 -13
- package/dist/components/number-field.js +6 -20
- package/dist/components/number-field.js.map +1 -1
- package/dist/components/number-input.d.ts +70 -13
- package/dist/components/number-input.js +90 -38
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/numpad-sheet.d.ts +10 -8
- 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 +66 -0
- package/dist/components/phone-input.js +171 -0
- package/dist/components/phone-input.js.map +1 -0
- package/dist/components/series-chart.d.ts +10 -8
- package/dist/components/settings-fields.d.ts +10 -8
- package/dist/components/share-card.d.ts +8 -6
- 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 +27 -2
- package/dist/components/swatch-picker.js +73 -31
- 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 +10 -8
- package/dist/components/tile-radio.d.ts +68 -13
- package/dist/components/tile-radio.js +3 -3
- package/dist/components/tile-radio.js.map +1 -1
- package/dist/components/time-input.d.ts +15 -9
- 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/ui.d.ts +10 -8
- package/dist/components/ui.js +280 -78
- 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 +210 -3
- 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 +1 -1
- package/dist/feedback/feedback-thread.d.ts +37 -3
- package/dist/feedback/feedback-thread.js +38 -9
- package/dist/feedback/feedback-thread.js.map +1 -1
- package/dist/{feedback-attachment-WFiXJ8We.d.ts → feedback-attachment-NhUm7Zga.d.ts} +70 -5
- package/dist/feedback.d.ts +2 -2
- package/dist/hooks/use-file-drop.d.ts +10 -8
- package/dist/i18n/defaults.d.ts +10 -8
- package/dist/i18n/defaults.js +17 -2
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.d.ts +10 -8
- package/dist/i18n/german.js +50 -5
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +10 -8
- package/dist/i18n/kit-labels.js +8 -2
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/languages.d.ts +10 -8
- package/dist/i18n/locales/de-CH.d.ts +10 -8
- package/dist/i18n/locales/en.d.ts +10 -8
- package/dist/i18n/locales/en.js +9 -0
- package/dist/i18n/locales/en.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +10 -8
- package/dist/i18n/locales/es.js +48 -5
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +10 -8
- package/dist/i18n/locales/fr.js +48 -5
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +10 -8
- package/dist/i18n/locales/hu.js +49 -5
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +10 -8
- package/dist/i18n/locales/it.js +49 -5
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +10 -8
- package/dist/i18n/locales/zh.js +48 -5
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.d.ts +10 -8
- package/dist/i18n/review.js +8 -1
- package/dist/i18n/review.js.map +1 -1
- package/dist/index.d.ts +17 -10
- package/dist/index.js +57 -2
- package/dist/index.js.map +1 -1
- package/dist/{kit-labels-D1J2_jyD.d.ts → kit-labels-R8mIAc9N.d.ts} +811 -8
- 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/rhf/fields.d.ts +148 -11
- package/dist/rhf/fields.js +332 -3
- package/dist/rhf/fields.js.map +1 -1
- package/dist/rhf/form.d.ts +10 -8
- package/dist/rhf.d.ts +13 -9
- package/dist/rhf.js.map +1 -1
- package/dist/shell/app-shell.d.ts +10 -8
- package/dist/shell/top-bar-brand.d.ts +10 -8
- package/dist/shell.d.ts +10 -8
- package/dist/tour/tour.js +20 -24
- package/dist/tour/tour.js.map +1 -1
- package/dist/wizard/stepper-nav.d.ts +10 -8
- package/dist/wizard.d.ts +10 -8
- 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 +49 -56
- package/src/components/autocomplete.tsx +133 -110
- 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/combobox.tsx +292 -253
- package/src/components/country-select.tsx +443 -0
- package/src/components/currency-select.tsx +109 -33
- package/src/components/danger-confirm.tsx +345 -77
- package/src/components/data-table-labels.ts +16 -1
- package/src/components/data-table.tsx +175 -6
- package/src/components/date-picker.tsx +173 -62
- package/src/components/entity-combobox.tsx +107 -87
- package/src/components/field-anatomy.tsx +190 -0
- package/src/components/field-parts.tsx +184 -0
- package/src/components/file-button.tsx +36 -3
- package/src/components/file-dropzone.tsx +106 -38
- package/src/components/form-actions.tsx +115 -2
- package/src/components/iban-input.tsx +231 -0
- package/src/components/icon-picker.tsx +26 -4
- 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 +10 -0
- package/src/components/month-picker.tsx +399 -63
- 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/sign-chip.tsx +103 -0
- package/src/components/swatch-picker.tsx +118 -30
- package/src/components/switch.tsx +58 -7
- package/src/components/tile-radio.tsx +71 -16
- package/src/components/time-input.tsx +8 -1
- package/src/components/toggle-group.tsx +206 -73
- package/src/components/ui.tsx +472 -105
- package/src/data-table.ts +2 -1
- package/src/feedback/feedback-attachment.tsx +313 -9
- package/src/feedback/feedback-dialog.tsx +2 -0
- package/src/feedback/feedback-thread.tsx +66 -5
- package/src/i18n/defaults.ts +16 -1
- package/src/i18n/german.ts +47 -0
- package/src/i18n/kit-labels.tsx +78 -2
- package/src/i18n/locales/en.ts +10 -0
- package/src/i18n/locales/es.ts +46 -0
- package/src/i18n/locales/fr.ts +45 -0
- package/src/i18n/locales/hu.ts +46 -0
- package/src/i18n/locales/it.ts +47 -0
- package/src/i18n/locales/zh.ts +44 -0
- package/src/i18n/review.ts +7 -0
- package/src/index.ts +53 -3
- 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/rhf/fields.tsx +606 -9
- package/src/rhf.ts +2 -1
- package/src/tour/tour.tsx +66 -28
|
@@ -1,161 +1,66 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
* ignored, the rule both apps applied to an address. `"trim"` keeps case, `"exact"`
|
|
68
|
-
* keeps spaces too — for a phrase like "DELETE" whose contract is "exactly this".
|
|
69
|
-
*/
|
|
70
|
-
typedMatch?: TypedMatch;
|
|
71
|
-
}
|
|
72
|
-
type ConfirmFn = (options: ConfirmOptions) => Promise<boolean>;
|
|
73
|
-
/**
|
|
74
|
-
* `const confirm = useConfirm()` → `if (!(await confirm({ title }))) return`.
|
|
75
|
-
*
|
|
76
|
-
* The returned function is STABLE for the life of the provider, so it can sit in an
|
|
77
|
-
* effect's or a `useCallback`'s dependency list without re-running it.
|
|
78
|
-
*
|
|
79
|
-
* Throws outside a {@link ConfirmProvider}, rather than falling back to
|
|
80
|
-
* `window.confirm`: a silent fallback is exactly the native dialog the three apps are
|
|
81
|
-
* migrating away from, and it would look like the migration had worked.
|
|
82
|
-
*/
|
|
83
|
-
declare function useConfirm(): ConfirmFn;
|
|
84
|
-
interface ConfirmProviderProps {
|
|
85
|
-
children: ReactNode;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* The host for {@link useConfirm}: ONE confirm dialog for the whole app, rendered on
|
|
89
|
-
* {@link DialogFrame}, answering a promise.
|
|
90
|
-
*
|
|
91
|
-
* Asked for by all three apps at once — keksdose has 20+ `window.confirm` calls,
|
|
92
|
-
* kastlan 7, lenkbank 1. The native dialog cannot be translated past its OK/Cancel
|
|
93
|
-
* (those are the BROWSER's language, not the app's), cannot say which button is the
|
|
94
|
-
* destructive one, and on an installed PWA it prints the origin over the question.
|
|
95
|
-
* A promise is what lets each of those call sites change by one `await`:
|
|
96
|
-
*
|
|
97
|
-
* if (!window.confirm(t("budget.delete_confirm"))) return;
|
|
98
|
-
* // becomes
|
|
99
|
-
* if (!(await confirm({ title: t("budget.delete_confirm"), tone: "danger" }))) return;
|
|
100
|
-
*
|
|
101
|
-
* ## Its own provider, not part of `UiKitProvider`
|
|
102
|
-
*
|
|
103
|
-
* `UiKitProvider` renders nothing: it is strings and a locale, it is optional, and it
|
|
104
|
-
* NESTS (an inner one re-labels one table). A dialog host inside it would mount a host
|
|
105
|
-
* per nested provider, and a component under the inner one would open a second dialog
|
|
106
|
-
* layer of its own. So the host is its own component, mounted once — inside the
|
|
107
|
-
* `UiKitProvider` whose strings it should speak, which is also the order the labels
|
|
108
|
-
* need.
|
|
109
|
-
*
|
|
110
|
-
* ## Focus
|
|
111
|
-
*
|
|
112
|
-
* On CANCEL for `tone: "danger"`, on CONFIRM otherwise. A confirm is often answered by
|
|
113
|
-
* a reflexive Enter — the key that pressed the Delete button in the first place may
|
|
114
|
-
* still be down — and for an action that cannot be undone that reflex must land on the
|
|
115
|
-
* harmless answer; `DangerConfirm` makes the same call ("never to the destructive
|
|
116
|
-
* button itself"). For everything else the confirm is the expected answer and Enter
|
|
117
|
-
* accepting it is what `window.confirm` taught users, which the migrating call sites'
|
|
118
|
-
* users already rely on. Focus returns to whatever opened it, through `Modal`'s trap.
|
|
119
|
-
*
|
|
120
|
-
* ## Escape, the backdrop, Back and Cancel all answer `false`
|
|
121
|
-
*
|
|
122
|
-
* Only the confirm button answers `true`. Anything that merely dismisses is a no.
|
|
123
|
-
*
|
|
124
|
-
* ## A second `confirm` while one is open QUEUES
|
|
125
|
-
*
|
|
126
|
-
* It is shown when the first is answered, and each call gets its own answer. The
|
|
127
|
-
* alternative — answering the open one `false` to make room — would answer a question
|
|
128
|
-
* the user never answered: a background prompt ("your session is about to expire")
|
|
129
|
-
* would cancel the delete they were reading. `false` has to mean "the user said no".
|
|
130
|
-
* A double-click cannot queue two of the same: the first click opens the modal
|
|
131
|
-
* synchronously (a discrete event's update is flushed before the next one), so the
|
|
132
|
-
* second lands on the open dialog rather than on the button — at worst on its
|
|
133
|
-
* backdrop, which answers `false`, the safe way to be wrong.
|
|
134
|
-
*
|
|
135
|
-
* Unmounting the provider answers everything still pending `false`, so no caller's
|
|
136
|
-
* `await` hangs forever.
|
|
137
|
-
*
|
|
138
|
-
* ## keksdose's synchronous call (transaction-swipe-plan.ts)
|
|
139
|
-
*
|
|
140
|
-
* `buildTxSwipeActions` is synchronous, but its `window.confirm` sits inside the
|
|
141
|
-
* action THUNK (`confirmed(key, run)` returns `() => { if (confirm(…)) run() }`), and a
|
|
142
|
-
* thunk may be async without its caller knowing. So the plan builder stays
|
|
143
|
-
* synchronous; it takes the confirm as an argument and the thunk awaits it:
|
|
144
|
-
*
|
|
145
|
-
* // mobile-transaction-list.tsx
|
|
146
|
-
* const confirm = useConfirm();
|
|
147
|
-
* buildTxSwipeActions({ tx, …, confirm });
|
|
148
|
-
*
|
|
149
|
-
* // transaction-swipe-plan.ts
|
|
150
|
-
* const confirmed = (messageKey: string, run: () => void) => () => {
|
|
151
|
-
* void confirm({ title: t(messageKey), tone: "danger" }).then((ok) => ok && run());
|
|
152
|
-
* };
|
|
153
|
-
*
|
|
154
|
-
* Its test then passes `confirm: vi.fn(async () => false)` instead of stubbing the
|
|
155
|
-
* global, and asserts after an `await` (the mutation now runs a microtask later). The
|
|
156
|
-
* row snaps back when the swipe commits, before the answer — which is right: the
|
|
157
|
-
* dialog, not the half-swiped row, is where the question now is.
|
|
158
|
-
*/
|
|
159
|
-
declare function ConfirmProvider({ children }: ConfirmProviderProps): react.JSX.Element;
|
|
160
|
-
|
|
161
|
-
export { type ConfirmDialogLabels, type ConfirmFn, type ConfirmOptions, ConfirmProvider, type ConfirmProviderProps, type ConfirmTone, DEFAULT_CONFIRM_DIALOG_LABELS, useConfirm };
|
|
1
|
+
import 'react';
|
|
2
|
+
export { E as ConfirmDialogLabels, F as ConfirmFn, G as ConfirmOptions, H as ConfirmProvider, I as ConfirmProviderProps, J as ConfirmTone, W as DEFAULT_CONFIRM_DIALOG_LABELS, bT as useConfirm } from '../kit-labels-R8mIAc9N.js';
|
|
3
|
+
import '../data-table-labels-B7OdnM0S.js';
|
|
4
|
+
import './data-table-sort.js';
|
|
5
|
+
import './swipeable-row.js';
|
|
6
|
+
import './mini-calendar.js';
|
|
7
|
+
import './calendar-heatmap.js';
|
|
8
|
+
import './popover.js';
|
|
9
|
+
import './chip.js';
|
|
10
|
+
import 'lucide-react';
|
|
11
|
+
import './field-sync.js';
|
|
12
|
+
import './tooltip.js';
|
|
13
|
+
import '../hooks/use-anchored-rect.js';
|
|
14
|
+
import '../lib/clipping.js';
|
|
15
|
+
import '../wizard/types.js';
|
|
16
|
+
import '../tour/tour.js';
|
|
17
|
+
import '../search/command-palette.js';
|
|
18
|
+
import '../search/global-search.js';
|
|
19
|
+
import '../search/search-index.js';
|
|
20
|
+
import './month-picker.js';
|
|
21
|
+
import './page-contents.js';
|
|
22
|
+
import './series-chart-labels.js';
|
|
23
|
+
import './pie-chart-labels.js';
|
|
24
|
+
import './sparkline.js';
|
|
25
|
+
import './stat-tile.js';
|
|
26
|
+
import './signature-pad.js';
|
|
27
|
+
import './password-strength.js';
|
|
28
|
+
import './swatch-picker.js';
|
|
29
|
+
import './tile-radio.js';
|
|
30
|
+
import './icon-picker.js';
|
|
31
|
+
import './dialog-frame.js';
|
|
32
|
+
import './modal.js';
|
|
33
|
+
import '../hooks/use-search-param-state.js';
|
|
34
|
+
import './measured-grid.js';
|
|
35
|
+
import '../feedback-attachment-NhUm7Zga.js';
|
|
36
|
+
import '../feedback/feedback-thread.js';
|
|
37
|
+
import '../feedback/feedback-inbox.js';
|
|
38
|
+
import './account-settings-labels.js';
|
|
39
|
+
import './floating-panel.js';
|
|
40
|
+
import './bulk-action-bar.js';
|
|
41
|
+
import './list.js';
|
|
42
|
+
import './signed-amount.js';
|
|
43
|
+
import './breadcrumbs.js';
|
|
44
|
+
import './toast.js';
|
|
45
|
+
import './description-list.js';
|
|
46
|
+
import './line-items.js';
|
|
47
|
+
import './progress-bar.js';
|
|
48
|
+
import './error-boundary.js';
|
|
49
|
+
import './authed-image.js';
|
|
50
|
+
import '../hooks/use-authed-src.js';
|
|
51
|
+
import './image-grid.js';
|
|
52
|
+
import './lightbox.js';
|
|
53
|
+
import './write-lock.js';
|
|
54
|
+
import './legal.js';
|
|
55
|
+
import './account-chips.js';
|
|
56
|
+
import '../lib/format.js';
|
|
57
|
+
import './reauth-dialog.js';
|
|
58
|
+
import './server-wake.js';
|
|
59
|
+
import '../lib/server-wake.js';
|
|
60
|
+
import './translation-review-labels.js';
|
|
61
|
+
import '../lib/translation-review.js';
|
|
62
|
+
import './country-select.js';
|
|
63
|
+
import './inline-edit-field.js';
|
|
64
|
+
import '../lib/iban.js';
|
|
65
|
+
import '../lib/phone.js';
|
|
66
|
+
import './sign-chip.js';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import 'react';
|
|
2
|
-
export {
|
|
2
|
+
export { K as CopyButton, L as CopyButtonLabels, M as CopyButtonProps, X as DEFAULT_COPY_BUTTON_LABELS } from '../kit-labels-R8mIAc9N.js';
|
|
3
3
|
import './tooltip.js';
|
|
4
|
-
import '
|
|
4
|
+
import '../data-table-labels-B7OdnM0S.js';
|
|
5
|
+
import './data-table-sort.js';
|
|
6
|
+
import './swipeable-row.js';
|
|
5
7
|
import './mini-calendar.js';
|
|
6
8
|
import './calendar-heatmap.js';
|
|
7
9
|
import './popover.js';
|
|
@@ -21,7 +23,6 @@ import './sparkline.js';
|
|
|
21
23
|
import './stat-tile.js';
|
|
22
24
|
import './signature-pad.js';
|
|
23
25
|
import './password-strength.js';
|
|
24
|
-
import './danger-confirm.js';
|
|
25
26
|
import './swatch-picker.js';
|
|
26
27
|
import './tile-radio.js';
|
|
27
28
|
import './icon-picker.js';
|
|
@@ -29,11 +30,10 @@ import './dialog-frame.js';
|
|
|
29
30
|
import './modal.js';
|
|
30
31
|
import '../hooks/use-search-param-state.js';
|
|
31
32
|
import './measured-grid.js';
|
|
32
|
-
import '../feedback-attachment-
|
|
33
|
+
import '../feedback-attachment-NhUm7Zga.js';
|
|
33
34
|
import '../feedback/feedback-thread.js';
|
|
34
35
|
import '../feedback/feedback-inbox.js';
|
|
35
36
|
import './account-settings-labels.js';
|
|
36
|
-
import './confirm-dialog.js';
|
|
37
37
|
import './floating-panel.js';
|
|
38
38
|
import '../hooks/use-anchored-rect.js';
|
|
39
39
|
import '../lib/clipping.js';
|
|
@@ -54,11 +54,13 @@ import './write-lock.js';
|
|
|
54
54
|
import './legal.js';
|
|
55
55
|
import './account-chips.js';
|
|
56
56
|
import '../lib/format.js';
|
|
57
|
-
import '../data-table-3mi2R3so.js';
|
|
58
|
-
import './data-table-sort.js';
|
|
59
|
-
import './swipeable-row.js';
|
|
60
57
|
import './reauth-dialog.js';
|
|
61
58
|
import './server-wake.js';
|
|
62
59
|
import '../lib/server-wake.js';
|
|
63
60
|
import './translation-review-labels.js';
|
|
64
61
|
import '../lib/translation-review.js';
|
|
62
|
+
import './country-select.js';
|
|
63
|
+
import './inline-edit-field.js';
|
|
64
|
+
import '../lib/iban.js';
|
|
65
|
+
import '../lib/phone.js';
|
|
66
|
+
import './sign-chip.js';
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/** The words {@link CountrySelect} renders on its own behalf. The list's "no results",
|
|
5
|
+
* "loading" and result-count announcements are the shared `combobox` namespace's,
|
|
6
|
+
* as on every other searchable picker. */
|
|
7
|
+
interface CountrySelectLabels {
|
|
8
|
+
/** What the field is, when the caller gives no `label`: the first half of the
|
|
9
|
+
* trigger's accessible name, the phone sheet's title, and the empty trigger's
|
|
10
|
+
* text. */
|
|
11
|
+
country: string;
|
|
12
|
+
/** The search box in the open list. */
|
|
13
|
+
search: string;
|
|
14
|
+
/** The heading between the `preferred` countries and all the others. Shown only
|
|
15
|
+
* when `preferred` puts something above it. */
|
|
16
|
+
others: string;
|
|
17
|
+
}
|
|
18
|
+
declare const DEFAULT_COUNTRY_SELECT_LABELS: CountrySelectLabels;
|
|
19
|
+
/**
|
|
20
|
+
* `onChange` is the kit's — "a country was picked", carrying its code — rather than
|
|
21
|
+
* the div's form event. `id` and the `aria-*` wiring below go to the TRIGGER, which is
|
|
22
|
+
* the control a reader meets; everything else in `rest` dresses the wrapper.
|
|
23
|
+
*/
|
|
24
|
+
interface CountrySelectProps extends Omit<ComponentPropsWithoutRef<"div">, "onChange" | "defaultValue"> {
|
|
25
|
+
/** The chosen country as an ISO 3166-1 alpha-2 code ("CH"), in either case;
|
|
26
|
+
* `null`, `undefined` or `""` when none is. A code outside the list still shows
|
|
27
|
+
* its name — the list restricts what can be PICKED, not what can be shown. */
|
|
28
|
+
value: string | null | undefined;
|
|
29
|
+
/** A country was picked: its alpha-2 code, always upper-case. */
|
|
30
|
+
onChange: (code: string) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Offer only these codes (any case; duplicates and malformed entries dropped).
|
|
33
|
+
* Default: every ISO 3166-1 country, {@link COUNTRY_CODES}. Sorted by name either
|
|
34
|
+
* way — the order given is not kept, because the reader looks a country up by its
|
|
35
|
+
* name in their own language, and any other order is one they cannot predict.
|
|
36
|
+
*
|
|
37
|
+
* keksdose's bank picker offers the fifteen countries its banks are in
|
|
38
|
+
* (DE AT CH FR IT ES NL BE PT PL SE DK FI GB IE). A code that is not in ISO's list
|
|
39
|
+
* is allowed here on purpose: `XK` (Kosovo) is the app's decision, not the kit's.
|
|
40
|
+
*/
|
|
41
|
+
countries?: readonly string[];
|
|
42
|
+
/**
|
|
43
|
+
* A short group shown FIRST, in the order given, above the alphabetical rest —
|
|
44
|
+
* kastlan's CH, LI, DE, AT, FR, IT, the six countries most of its customers live
|
|
45
|
+
* in, out of a list of 249. Each code appears once: a preferred country is not
|
|
46
|
+
* repeated in the rest. The rest gets a heading (`labels.others`) so the boundary
|
|
47
|
+
* is visible. Search keeps the split: matching preferred countries stay on top.
|
|
48
|
+
* Codes not in `countries` are ignored — `countries` decides what can be picked.
|
|
49
|
+
*/
|
|
50
|
+
preferred?: readonly string[];
|
|
51
|
+
/**
|
|
52
|
+
* Draw each country's flag as a flag-icons span (`fi fi-ch`), in the rows and on
|
|
53
|
+
* the trigger. Default `false`, because the kit ships no flag stylesheet — the same
|
|
54
|
+
* convention as `LanguageMenu`'s `country` and `CurrencySelect`: the host imports
|
|
55
|
+
* `flag-icons/css/flag-icons.min.css`, and without it a flag is an empty box.
|
|
56
|
+
*/
|
|
57
|
+
flags?: boolean;
|
|
58
|
+
/** The floating label, as on every field. A string also names the trigger
|
|
59
|
+
* ("Country: Switzerland"). */
|
|
60
|
+
label?: ReactNode;
|
|
61
|
+
/** As {@link Select}'s `hint`: plain TEXT is a caption under the field, attached
|
|
62
|
+
* through `aria-describedby`; a {@link FieldHint} rides the label line (or the
|
|
63
|
+
* field's end, when there is no label). */
|
|
64
|
+
hint?: ReactNode;
|
|
65
|
+
/** As {@link Input}'s `error`: rendered under the field, on the trigger's
|
|
66
|
+
* `aria-describedby`, and implies `invalid`. */
|
|
67
|
+
error?: ReactNode;
|
|
68
|
+
/** Required and unanswered — {@link FIELD_INVALID}, as on every field. */
|
|
69
|
+
invalid?: boolean;
|
|
70
|
+
/** The empty trigger's text. Default: nothing when the field has a `label` (the
|
|
71
|
+
* label already says what goes here), else `labels.country`. */
|
|
72
|
+
placeholder?: string;
|
|
73
|
+
/** As on the other pickers: no focus, no list, the settled look. */
|
|
74
|
+
disabled?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Why the country cannot be changed — {@link Button}'s `disabledReason`, for a field
|
|
77
|
+
* that saves itself. The trigger stays focusable and `aria-disabled`, the list does
|
|
78
|
+
* not open and `onChange` never fires; the reason is in the kit {@link Tooltip} and
|
|
79
|
+
* on the trigger's `aria-describedby`. Wins over `disabled`.
|
|
80
|
+
*/
|
|
81
|
+
disabledReason?: ReactNode;
|
|
82
|
+
/**
|
|
83
|
+
* This select SAVES on change (a settings row with no Save button). Under a locked
|
|
84
|
+
* {@link WriteLockProvider} it is locked the `disabledReason` way, with the lock's
|
|
85
|
+
* reason. A country field inside a form that has its own Save stays editable under
|
|
86
|
+
* the lock — leave this off there, and put `commit` on the Save.
|
|
87
|
+
*/
|
|
88
|
+
commit?: boolean;
|
|
89
|
+
/** The language the names are in. Default: the `<UiKitProvider locale>`, else
|
|
90
|
+
* English (see {@link countryName}). */
|
|
91
|
+
locale?: string;
|
|
92
|
+
/** Per-instance overrides of {@link CountrySelectLabels}, over the provider's
|
|
93
|
+
* `countrySelect` namespace, over English. */
|
|
94
|
+
labels?: Partial<CountrySelectLabels>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* A country picker: the value is the ISO 3166-1 alpha-2 code ("CH"), the names are the
|
|
98
|
+
* runtime's own (`Intl.DisplayNames`) in the provider's locale, sorted by that
|
|
99
|
+
* locale's collation. Requested by kastlan (customer and handover addresses, with its
|
|
100
|
+
* six neighbours on top) and keksdose (the bank picker's fifteen countries) — both
|
|
101
|
+
* apps carried a hand-written list of names in two languages.
|
|
102
|
+
*
|
|
103
|
+
* ## Built on the kit's searchable combobox
|
|
104
|
+
*
|
|
105
|
+
* 249 countries is not a menu, it is a lookup, and the list has to work on a phone. So
|
|
106
|
+
* this is the entity pickers' machinery — `useComboboxCore` and `ComboboxPanel`, which
|
|
107
|
+
* {@link EntityCombobox} is also made of — not a native `<select>`: the anchored panel
|
|
108
|
+
* with a search box on a pointer device, the full-screen sheet with its own search box
|
|
109
|
+
* on a phone (live #200), the same keyboard (APG listbox), the same announcements, the
|
|
110
|
+
* same group headings. Only the trigger is this component's own, because the trigger
|
|
111
|
+
* is where the write lock lives: `EntityCombobox`'s is a native `disabled` button,
|
|
112
|
+
* and a locked field has to stay focusable to say why.
|
|
113
|
+
*
|
|
114
|
+
* The search is this component's own too: it folds accents and case ("osterreich"
|
|
115
|
+
* finds Österreich), matches the code ("ch" ranks Switzerland first), and ranks
|
|
116
|
+
* name-starts above name-contains. The panel is handed those rows in place of the
|
|
117
|
+
* core's plain substring filter.
|
|
118
|
+
*
|
|
119
|
+
* Field anatomy as on every field: floating `label`, `hint`, `error`, `invalid`; the
|
|
120
|
+
* trigger is named "label: value" as the other trigger pickers are.
|
|
121
|
+
*/
|
|
122
|
+
declare function CountrySelect({ value, onChange, countries, preferred, flags, label, hint, error, invalid, placeholder, disabled, disabledReason: ownReason, commit, locale: localeProp, labels: labelsProp, className, id, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-required": ariaRequired, ...rest }: CountrySelectProps): react.JSX.Element;
|
|
123
|
+
|
|
124
|
+
export { CountrySelect, type CountrySelectLabels, type CountrySelectProps, DEFAULT_COUNTRY_SELECT_LABELS };
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId, useMemo } from "react";
|
|
4
|
+
import { cn } from "../lib/cn.js";
|
|
5
|
+
import { COUNTRY_CODES, countryName, normalizeCountryCode } from "../lib/countries.js";
|
|
6
|
+
import { FieldChevron, FIELD_FLOATING_PAD, FIELD_INVALID, FIELD_TRIGGER, FloatingField } from "./ui.js";
|
|
7
|
+
import { Tooltip } from "./tooltip.js";
|
|
8
|
+
import { CurrencyFlag } from "./currency-select.js";
|
|
9
|
+
import {
|
|
10
|
+
ComboboxPanel,
|
|
11
|
+
useComboboxCore,
|
|
12
|
+
useComboboxFieldError
|
|
13
|
+
} from "./combobox-core.js";
|
|
14
|
+
import { hasMessage, mergeDescribedBy } from "./choice-parts.js";
|
|
15
|
+
import { useCommitReason } from "./write-lock.js";
|
|
16
|
+
import { DEFAULT_COMMON_LABELS, useKitLabels, useKitLocale } from "../i18n/kit-labels.js";
|
|
17
|
+
const DEFAULT_COUNTRY_SELECT_LABELS = {
|
|
18
|
+
country: "Country",
|
|
19
|
+
search: "Search country",
|
|
20
|
+
others: "Other countries"
|
|
21
|
+
};
|
|
22
|
+
function fold(s) {
|
|
23
|
+
return s.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase();
|
|
24
|
+
}
|
|
25
|
+
function rank(e, q) {
|
|
26
|
+
if (e.code.toLowerCase() === q) return 0;
|
|
27
|
+
if (e.folded.startsWith(q)) return 1;
|
|
28
|
+
return e.folded.includes(q) ? 2 : -1;
|
|
29
|
+
}
|
|
30
|
+
function search(entries, q) {
|
|
31
|
+
return entries.map((e) => ({ e, r: rank(e, q) })).filter((x) => x.r >= 0).sort((a, b) => a.r - b.r).map((x) => x.e);
|
|
32
|
+
}
|
|
33
|
+
function toOption(e, flags, group) {
|
|
34
|
+
return {
|
|
35
|
+
value: e.code,
|
|
36
|
+
label: e.name,
|
|
37
|
+
icon: flags ? /* @__PURE__ */ jsx(CurrencyFlag, { country: e.code.toLowerCase() }) : void 0,
|
|
38
|
+
group
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function collator(locale) {
|
|
42
|
+
try {
|
|
43
|
+
return new Intl.Collator(locale);
|
|
44
|
+
} catch {
|
|
45
|
+
return new Intl.Collator();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function CountrySelect({
|
|
49
|
+
value,
|
|
50
|
+
onChange,
|
|
51
|
+
countries,
|
|
52
|
+
preferred,
|
|
53
|
+
flags = false,
|
|
54
|
+
label,
|
|
55
|
+
hint,
|
|
56
|
+
error,
|
|
57
|
+
invalid,
|
|
58
|
+
placeholder,
|
|
59
|
+
disabled,
|
|
60
|
+
disabledReason: ownReason,
|
|
61
|
+
commit,
|
|
62
|
+
locale: localeProp,
|
|
63
|
+
labels: labelsProp,
|
|
64
|
+
className,
|
|
65
|
+
id,
|
|
66
|
+
"aria-label": ariaLabel,
|
|
67
|
+
"aria-describedby": ariaDescribedBy,
|
|
68
|
+
"aria-invalid": ariaInvalid,
|
|
69
|
+
"aria-required": ariaRequired,
|
|
70
|
+
...rest
|
|
71
|
+
}) {
|
|
72
|
+
const text = useKitLabels("countrySelect", DEFAULT_COUNTRY_SELECT_LABELS, labelsProp);
|
|
73
|
+
const common = useKitLabels("common", DEFAULT_COMMON_LABELS);
|
|
74
|
+
const locale = useKitLocale(localeProp) ?? "en";
|
|
75
|
+
const countriesKey = countries?.join(",");
|
|
76
|
+
const preferredKey = preferred?.join(",");
|
|
77
|
+
const { top, rest: others } = useMemo(() => {
|
|
78
|
+
const seen = /* @__PURE__ */ new Set();
|
|
79
|
+
const pool = [];
|
|
80
|
+
for (const raw of countriesKey !== void 0 ? countriesKey.split(",") : COUNTRY_CODES) {
|
|
81
|
+
const code2 = normalizeCountryCode(raw);
|
|
82
|
+
if (code2 && !seen.has(code2)) {
|
|
83
|
+
seen.add(code2);
|
|
84
|
+
pool.push(code2);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const entry = (code2) => {
|
|
88
|
+
const name2 = countryName(code2, locale);
|
|
89
|
+
return { code: code2, name: name2, folded: fold(name2) };
|
|
90
|
+
};
|
|
91
|
+
const firsts = [];
|
|
92
|
+
const picked = /* @__PURE__ */ new Set();
|
|
93
|
+
for (const raw of preferredKey ? preferredKey.split(",") : []) {
|
|
94
|
+
const code2 = normalizeCountryCode(raw);
|
|
95
|
+
if (code2 && seen.has(code2) && !picked.has(code2)) {
|
|
96
|
+
picked.add(code2);
|
|
97
|
+
firsts.push(entry(code2));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const compare = collator(locale).compare;
|
|
101
|
+
const sorted = pool.filter((c) => !picked.has(c)).map(entry).sort((a, b) => compare(a.name, b.name));
|
|
102
|
+
return { top: firsts, rest: sorted };
|
|
103
|
+
}, [countriesKey, preferredKey, locale]);
|
|
104
|
+
const allOptions = useMemo(
|
|
105
|
+
() => [...top, ...others].map((e) => toOption(e, flags)),
|
|
106
|
+
[top, others, flags]
|
|
107
|
+
);
|
|
108
|
+
const core = useComboboxCore({ options: allOptions, filter: false });
|
|
109
|
+
const { open, setOpen, query, triggerRef, closeToTrigger } = core;
|
|
110
|
+
const q = fold(query.trim());
|
|
111
|
+
const results = useMemo(() => {
|
|
112
|
+
const firsts = q ? search(top, q) : top;
|
|
113
|
+
const below = q ? search(others, q) : others;
|
|
114
|
+
const heading = firsts.length > 0 ? text.others : void 0;
|
|
115
|
+
return [...firsts.map((e) => toOption(e, flags)), ...below.map((e) => toOption(e, flags, heading))];
|
|
116
|
+
}, [top, others, q, text.others, flags]);
|
|
117
|
+
const reason = useCommitReason(commit, ownReason);
|
|
118
|
+
const locked = hasMessage(reason);
|
|
119
|
+
const inert = locked || Boolean(disabled);
|
|
120
|
+
if (inert && open) setOpen(false);
|
|
121
|
+
const generated = useId();
|
|
122
|
+
const triggerId = id ?? generated;
|
|
123
|
+
const listboxId = `${generated}-listbox`;
|
|
124
|
+
const hintId = useId();
|
|
125
|
+
const reasonId = useId();
|
|
126
|
+
const textHint = typeof hint === "string" && hint !== "" || typeof hint === "number";
|
|
127
|
+
const field = useComboboxFieldError(
|
|
128
|
+
error,
|
|
129
|
+
invalid || ariaInvalid === true || ariaInvalid === "true",
|
|
130
|
+
// The caller's, then the standing advice, then (inside) the error — the order every
|
|
131
|
+
// field keeps — and the lock's reason last, while there is one.
|
|
132
|
+
mergeDescribedBy(ariaDescribedBy, textHint && hintId)
|
|
133
|
+
);
|
|
134
|
+
const code = normalizeCountryCode(value);
|
|
135
|
+
const selectedName = code ? countryName(code, locale) : void 0;
|
|
136
|
+
const emptyText = placeholder ?? (label === void 0 ? text.country : "");
|
|
137
|
+
const fieldName = typeof label === "string" ? label : text.country;
|
|
138
|
+
const name = ariaLabel ?? (selectedName !== void 0 ? common.fieldValue(fieldName, selectedName) : placeholder ? common.fieldValue(fieldName, placeholder) : fieldName);
|
|
139
|
+
const choose = (o) => {
|
|
140
|
+
if (inert) return;
|
|
141
|
+
onChange(o.value);
|
|
142
|
+
closeToTrigger();
|
|
143
|
+
};
|
|
144
|
+
const trigger = /* @__PURE__ */ jsxs(
|
|
145
|
+
"button",
|
|
146
|
+
{
|
|
147
|
+
ref: triggerRef,
|
|
148
|
+
id: triggerId,
|
|
149
|
+
type: "button",
|
|
150
|
+
role: "combobox",
|
|
151
|
+
"aria-haspopup": "listbox",
|
|
152
|
+
"aria-controls": listboxId,
|
|
153
|
+
"aria-expanded": open,
|
|
154
|
+
"aria-label": name,
|
|
155
|
+
"aria-invalid": field.isInvalid || void 0,
|
|
156
|
+
"aria-required": ariaRequired,
|
|
157
|
+
"aria-describedby": mergeDescribedBy(field.describedBy, locked && reasonId),
|
|
158
|
+
disabled: locked ? void 0 : disabled,
|
|
159
|
+
"aria-disabled": locked || void 0,
|
|
160
|
+
onClick: (e) => {
|
|
161
|
+
if (inert) {
|
|
162
|
+
e.preventDefault();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
setOpen((o) => !o);
|
|
166
|
+
},
|
|
167
|
+
onKeyDown: (e) => {
|
|
168
|
+
if (inert) return;
|
|
169
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
170
|
+
e.preventDefault();
|
|
171
|
+
setOpen(true);
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
className: cn(
|
|
175
|
+
FIELD_TRIGGER,
|
|
176
|
+
// `peer` dims the floating label with a natively disabled trigger, as Select's.
|
|
177
|
+
"peer pe-9",
|
|
178
|
+
label !== void 0 && FIELD_FLOATING_PAD,
|
|
179
|
+
inert && "cursor-not-allowed opacity-50",
|
|
180
|
+
field.isInvalid && FIELD_INVALID
|
|
181
|
+
),
|
|
182
|
+
children: [
|
|
183
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-center gap-2", children: [
|
|
184
|
+
flags && code && /* @__PURE__ */ jsx(CurrencyFlag, { country: code.toLowerCase() }),
|
|
185
|
+
/* @__PURE__ */ jsx("span", { className: cn("truncate", selectedName === void 0 && "text-[var(--text-placeholder)]"), children: selectedName ?? emptyText })
|
|
186
|
+
] }),
|
|
187
|
+
/* @__PURE__ */ jsx(FieldChevron, {})
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
const control = locked ? (
|
|
192
|
+
// In a FRAGMENT, as Button does, so the Tooltip does not clone its bubble into the
|
|
193
|
+
// description as well — the hidden copy is what `aria-describedby` points at.
|
|
194
|
+
/* @__PURE__ */ jsx(Tooltip, { label: reason, className: "flex w-full", children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
195
|
+
trigger,
|
|
196
|
+
/* @__PURE__ */ jsx("span", { id: reasonId, hidden: true, children: reason })
|
|
197
|
+
] }) })
|
|
198
|
+
) : trigger;
|
|
199
|
+
const labelHint = textHint ? void 0 : hasMessage(hint) ? hint : void 0;
|
|
200
|
+
const box = label !== void 0 ? /* @__PURE__ */ jsx(FloatingField, { htmlFor: triggerId, label, staticLabel: true, hint: labelHint, children: control }) : labelHint !== void 0 ? (
|
|
201
|
+
// No label line to ride: the "?" goes at the field's end, outside the box, as on
|
|
202
|
+
// an unlabelled Select.
|
|
203
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
204
|
+
/* @__PURE__ */ jsx("div", { className: "relative min-w-0 flex-1", children: control }),
|
|
205
|
+
/* @__PURE__ */ jsx("span", { className: "flex shrink-0 items-center", children: labelHint })
|
|
206
|
+
] })
|
|
207
|
+
) : /* @__PURE__ */ jsx("div", { className: "relative", children: control });
|
|
208
|
+
return (
|
|
209
|
+
// `rest` dresses the wrapper — a `data-tour` anchor, a test id. The name, the
|
|
210
|
+
// description and the invalid state are on the trigger above.
|
|
211
|
+
/* @__PURE__ */ jsxs("div", { ...rest, className, children: [
|
|
212
|
+
box,
|
|
213
|
+
textHint && /* @__PURE__ */ jsx("p", { id: hintId, className: "mt-1 text-[11px] leading-tight text-[var(--text-muted)]", children: hint }),
|
|
214
|
+
field.errorEl,
|
|
215
|
+
/* @__PURE__ */ jsx(
|
|
216
|
+
ComboboxPanel,
|
|
217
|
+
{
|
|
218
|
+
core: { ...core, results },
|
|
219
|
+
listboxId,
|
|
220
|
+
sheetTitle: label ?? text.country,
|
|
221
|
+
searchPlaceholder: text.search,
|
|
222
|
+
isSelected: (v) => v === code,
|
|
223
|
+
onChoose: choose,
|
|
224
|
+
showCreate: false,
|
|
225
|
+
onCreate: () => {
|
|
226
|
+
},
|
|
227
|
+
createContent: null
|
|
228
|
+
}
|
|
229
|
+
)
|
|
230
|
+
] })
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
export {
|
|
234
|
+
CountrySelect,
|
|
235
|
+
DEFAULT_COUNTRY_SELECT_LABELS
|
|
236
|
+
};
|
|
237
|
+
//# sourceMappingURL=country-select.js.map
|