@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
package/dist/index.js
CHANGED
|
@@ -60,7 +60,13 @@ export * from "./components/password-strength.js";
|
|
|
60
60
|
export * from "./components/page-contents.js";
|
|
61
61
|
export * from "./components/disclosure.js";
|
|
62
62
|
export * from "./components/dialog-frame.js";
|
|
63
|
-
import {
|
|
63
|
+
import {
|
|
64
|
+
DangerConfirm,
|
|
65
|
+
DEFAULT_DANGER_CONFIRM_LABELS,
|
|
66
|
+
typedMatches,
|
|
67
|
+
TypedConfirmField,
|
|
68
|
+
CurrentPasswordInput
|
|
69
|
+
} from "./components/danger-confirm.js";
|
|
64
70
|
import { ReauthDialog, DEFAULT_REAUTH_DIALOG_LABELS } from "./components/reauth-dialog.js";
|
|
65
71
|
export * from "./components/confirm-dialog.js";
|
|
66
72
|
export * from "./components/floating-panel.js";
|
|
@@ -133,7 +139,7 @@ export * from "./components/data-table-sort.js";
|
|
|
133
139
|
export * from "./components/data-table-filters.js";
|
|
134
140
|
export * from "./components/data-table-pagination.js";
|
|
135
141
|
import { FilterPopover } from "./components/data-table-filter-popover.js";
|
|
136
|
-
import { DataTable } from "./components/data-table.js";
|
|
142
|
+
import { DataTable, DEFAULT_DATA_TABLE_SORT_LABELS } from "./components/data-table.js";
|
|
137
143
|
export * from "./components/data-table-cells.js";
|
|
138
144
|
import { useTableUrlState, readTableUrlState } from "./components/use-table-state.js";
|
|
139
145
|
export * from "./shell/topbar-controls.js";
|
|
@@ -195,13 +201,54 @@ import {
|
|
|
195
201
|
DEFAULT_TRANSLATION_REVIEW_LABELS
|
|
196
202
|
} from "./components/translation-review.js";
|
|
197
203
|
import { LegalLayout, LegalSection, LegalLinks, DEFAULT_LEGAL_LABELS } from "./components/legal.js";
|
|
204
|
+
export * from "./components/checkbox-group.js";
|
|
205
|
+
export * from "./components/one-time-code-input.js";
|
|
206
|
+
export * from "./components/language-select.js";
|
|
207
|
+
export * from "./components/tile-radio.js";
|
|
208
|
+
export * from "./components/inline-edit-field.js";
|
|
209
|
+
export * from "./components/sign-chip.js";
|
|
210
|
+
export * from "./components/country-select.js";
|
|
211
|
+
import { COUNTRY_CODES, countryName } from "./lib/countries.js";
|
|
212
|
+
export * from "./components/iban-input.js";
|
|
213
|
+
import {
|
|
214
|
+
IBAN_LENGTHS,
|
|
215
|
+
compactIban,
|
|
216
|
+
formatIban,
|
|
217
|
+
ibanCheckDigits,
|
|
218
|
+
ibanProblem,
|
|
219
|
+
isValidIban,
|
|
220
|
+
isQrIban
|
|
221
|
+
} from "./lib/iban.js";
|
|
222
|
+
import { formatIsin, isinCheckDigit, isValidIsin } from "./lib/isin.js";
|
|
223
|
+
export * from "./components/phone-input.js";
|
|
224
|
+
import {
|
|
225
|
+
PHONE_DIAL_CODES,
|
|
226
|
+
PHONE_COUNTRIES,
|
|
227
|
+
parsePhone,
|
|
228
|
+
formatNationalPhone,
|
|
229
|
+
formatPhone,
|
|
230
|
+
isE164
|
|
231
|
+
} from "./lib/phone.js";
|
|
232
|
+
export * from "./components/field-strip.js";
|
|
233
|
+
export * from "./components/column-mapper.js";
|
|
234
|
+
import {
|
|
235
|
+
assignColumnRole,
|
|
236
|
+
guessMapping,
|
|
237
|
+
missingRoles,
|
|
238
|
+
readMappedTable,
|
|
239
|
+
readTextFile,
|
|
240
|
+
roleOfColumn
|
|
241
|
+
} from "./lib/column-mapping.js";
|
|
198
242
|
export {
|
|
199
243
|
ACCOUNT_STATE_TONES,
|
|
200
244
|
AccountStateChip,
|
|
201
245
|
AuthedImage,
|
|
246
|
+
COUNTRY_CODES,
|
|
247
|
+
CurrentPasswordInput,
|
|
202
248
|
DEFAULT_ACCOUNT_STATE_LABELS,
|
|
203
249
|
DEFAULT_AUTHED_IMAGE_LABELS,
|
|
204
250
|
DEFAULT_DANGER_CONFIRM_LABELS,
|
|
251
|
+
DEFAULT_DATA_TABLE_SORT_LABELS,
|
|
205
252
|
DEFAULT_FILE_PICKER_LABELS,
|
|
206
253
|
DEFAULT_LEGAL_LABELS,
|
|
207
254
|
DEFAULT_REAUTH_DIALOG_LABELS,
|
|
@@ -216,10 +263,13 @@ export {
|
|
|
216
263
|
DateMark,
|
|
217
264
|
FileButton,
|
|
218
265
|
FilterPopover,
|
|
266
|
+
IBAN_LENGTHS,
|
|
219
267
|
LegalLayout,
|
|
220
268
|
LegalLinks,
|
|
221
269
|
LegalSection,
|
|
222
270
|
OVERLAY_EXIT_MS,
|
|
271
|
+
PHONE_COUNTRIES,
|
|
272
|
+
PHONE_DIAL_CODES,
|
|
223
273
|
REVIEW_STATUSES,
|
|
224
274
|
REVIEW_STATUS_TONES,
|
|
225
275
|
ReauthDialog,
|
|
@@ -240,11 +290,15 @@ export {
|
|
|
240
290
|
TranslationProgress,
|
|
241
291
|
TranslationReviewEditor,
|
|
242
292
|
TranslationReviewPanel,
|
|
293
|
+
TypedConfirmField,
|
|
243
294
|
WriteLockProvider,
|
|
244
295
|
anchoredPanelPlacement,
|
|
296
|
+
assignColumnRole,
|
|
245
297
|
attachServerWake,
|
|
246
298
|
cn,
|
|
299
|
+
compactIban,
|
|
247
300
|
copyToClipboard,
|
|
301
|
+
countryName,
|
|
248
302
|
createServerWake,
|
|
249
303
|
dateColumn,
|
|
250
304
|
dragHasFiles,
|
|
@@ -252,7 +306,19 @@ export {
|
|
|
252
306
|
encodeQr,
|
|
253
307
|
filterTranslationRows,
|
|
254
308
|
flattenStrings,
|
|
309
|
+
formatIban,
|
|
310
|
+
formatIsin,
|
|
311
|
+
formatNationalPhone,
|
|
312
|
+
formatPhone,
|
|
255
313
|
fromApiReview,
|
|
314
|
+
guessMapping,
|
|
315
|
+
ibanCheckDigits,
|
|
316
|
+
ibanProblem,
|
|
317
|
+
isE164,
|
|
318
|
+
isQrIban,
|
|
319
|
+
isValidIban,
|
|
320
|
+
isValidIsin,
|
|
321
|
+
isinCheckDigit,
|
|
256
322
|
keyInArea,
|
|
257
323
|
keyInAreas,
|
|
258
324
|
keyNamespace,
|
|
@@ -261,13 +327,18 @@ export {
|
|
|
261
327
|
matchesAccept,
|
|
262
328
|
matchesHotkey,
|
|
263
329
|
mergeReviews,
|
|
330
|
+
missingRoles,
|
|
264
331
|
parseHotkey,
|
|
332
|
+
parsePhone,
|
|
265
333
|
placeholderMismatch,
|
|
266
334
|
placeholderTokens,
|
|
335
|
+
readMappedTable,
|
|
267
336
|
readStored,
|
|
268
337
|
readTableUrlState,
|
|
338
|
+
readTextFile,
|
|
269
339
|
reviewStatus,
|
|
270
340
|
reviewWrite,
|
|
341
|
+
roleOfColumn,
|
|
271
342
|
serverWake,
|
|
272
343
|
setStoreLog,
|
|
273
344
|
summariseRows,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// @eifi1/ui-kit — shared design-system barrel.\n//\n// Domain-free UI + theme surface shared across apps (lead app: Keksdose). Consumers import\n// components/theme from \"@eifi1/ui-kit\" and the token stylesheet from \"@eifi1/ui-kit/tokens.css\".\n\n// ── lib ────────────────────────────────────────────────────────────────────\nexport * from \"./lib/calc\";\nexport { cn } from \"./lib/cn\";\nexport { logger, setStoreLog } from \"./lib/logger\";\n// Intl number / money / percent / date / relative-time formatting, and `useKitFormat()`\n// for the same bound to the provider's locale (kastlan's formatters.ts, English \"5m ago\").\nexport * from \"./lib/format\";\n// localStorage that never throws (Safari private mode, blocked site data).\nexport { readStored, writeStored } from \"./lib/safe-storage\";\n// Date helpers are also available via the \"@eifi1/ui-kit/dates\" subpath.\n\n// ── hooks ────────────────────────────────────────────────────────────────────\nexport { useMediaQuery } from \"./hooks/use-media-query\";\nexport { useBodyScrollLock } from \"./hooks/use-body-scroll-lock\";\nexport { useAnchoredRect } from \"./hooks/use-anchored-rect\";\nexport type { AnchorRect } from \"./hooks/use-anchored-rect\";\nexport { useAnchoredPanel, anchoredPanelPlacement, useVisualViewport } from \"./hooks/use-anchored-panel\";\nexport type {\n AnchoredPanel,\n AnchoredPanelOptions,\n ViewportBox,\n} from \"./hooks/use-anchored-panel\";\nexport { useEscapeKey, useOutsideClick } from \"./hooks/use-dismiss\";\n// Focus containment for an overlay, and a live region for a change that moves no focus.\n// Both were extracted from the two components that already did them correctly (Modal and\n// CommandPalette) so the rest of the kit stops being the exception.\nexport { useFocusTrap } from \"./hooks/use-focus-trap\";\nexport type { FocusTrapOptions } from \"./hooks/use-focus-trap\";\nexport { useAnnounce } from \"./hooks/use-announce\";\nexport type { UseAnnounceReturn, UseAnnounceOptions, AnnounceRegionProps } from \"./hooks/use-announce\";\nexport { useOverlayHistory } from \"./hooks/use-overlay-history\";\nexport { useCloseTransition, OVERLAY_EXIT_MS } from \"./hooks/use-close-transition\";\nexport { useRowSwipe } from \"./hooks/use-row-swipe\";\nexport type { SwipeStage, RowSwipeOptions, RowSwipeReturn } from \"./hooks/use-row-swipe\";\n// Any element as a file drop target, screened like FileButton (kastlan).\nexport { useFileDrop, dragHasFiles } from \"./hooks/use-file-drop\";\nexport type { UseFileDropOptions, UseFileDropReturn, FileDropProps } from \"./hooks/use-file-drop\";\n// kastlan's search boxes each carried a hand-rolled copy, two without the cleanup.\nexport { useDebounce, useDebouncedCallback } from \"./hooks/use-debounce\";\nexport type { DebouncedCallbackOptions, DebouncedFunction } from \"./hooks/use-debounce\";\n// One search param as state, the active tab in `?tab=`, and a dialog's open state in the\n// URL (Modal's `urlParam`) — kastlan's and keksdose's use-search-param-state, in the kit.\nexport { useSearchParamState, useTabParam, useDialogParam } from \"./hooks/use-search-param-state\";\nexport type { SearchParamStateOptions, DialogParam } from \"./hooks/use-search-param-state\";\n// Copy that reports whether it worked — keksdose's copy buttons said \"Copied\" when it had not.\nexport { useCopyToClipboard, copyToClipboard } from \"./hooks/use-copy-to-clipboard\";\nexport type { CopyState, UseCopyToClipboardOptions, UseCopyToClipboardReturn } from \"./hooks/use-copy-to-clipboard\";\n// Keyboard shortcuts (\"Mod+K\", \"Ctrl+Shift+F\") that leave typing in fields alone.\nexport { useHotkey, parseHotkey, matchesHotkey } from \"./hooks/use-hotkey\";\nexport type { Hotkey, ParsedHotkey, UseHotkeyOptions } from \"./hooks/use-hotkey\";\n// A protected file as an object URL, fetched with the app's own auth (kastlan's AuthedImage).\nexport { useAuthedSrc } from \"./hooks/use-authed-src\";\nexport type { AuthedFetcher, AuthedSrcStatus, UseAuthedSrcOptions, UseAuthedSrcResult } from \"./hooks/use-authed-src\";\n\n// ── theme / palettes ─────────────────────────────────────────────────────────\nexport * from \"./theme/chart-palette\";\n// Colour maths (sRGB ↔ OKLCH, WCAG contrast, CVD simulation) and the palette deriver\n// that builds a whole, contrast-solved palette from one brand colour plus any colours\n// pinned by hand. `auditPalette` / `auditChartRamp` measure a palette rather than\n// trusting a comment about it.\nexport * from \"./theme/color\";\nexport * from \"./theme/palette-derive\";\nexport * from \"./theme/palette-presets\";\nexport * from \"./theme/theme-store\";\nexport * from \"./theme/palette-store\";\n\n// ── components ───────────────────────────────────────────────────────────────\nexport * from \"./components/ui\";\n// The label-ABOVE field group (label, hint, error, required), inside wizards or out.\nexport * from \"./components/field\";\nexport * from \"./components/search-field\";\nexport * from \"./components/dropdown\";\nexport * from \"./components/popover\";\nexport { SwipeableRow } from \"./components/swipeable-row\";\nexport type { SwipeAction, SwipeableRowProps } from \"./components/swipeable-row\";\nexport * from \"./components/calculator\";\nexport * from \"./components/numpad-sheet\";\nexport * from \"./components/number-input\";\nexport * from \"./components/currency-select\";\nexport * from \"./components/amount-input\";\nexport * from \"./components/money-field\";\nexport * from \"./components/combobox\";\nexport * from \"./components/picker-sheet\";\nexport * from \"./components/entity-combobox\";\nexport * from \"./components/multi-entity-combobox\";\nexport * from \"./components/multi-select\";\nexport * from \"./components/tooltip\";\nexport * from \"./components/user-avatar\";\nexport * from \"./components/settings-fields\";\n// Sync state for a database-backed field: the engine (`useFieldSync`) and the\n// affordance (`FieldSyncIndicator`), kept separate because the state is useful\n// without the dot — a form can gate its submit on any field being `pending`.\nexport * from \"./components/field-sync\";\nexport * from \"./components/month-picker\";\nexport * from \"./components/checkbox\";\nexport * from \"./components/switch\";\nexport * from \"./components/slider\";\nexport * from \"./components/time-input\";\nexport * from \"./components/number-field\";\nexport * from \"./components/sparkline\";\nexport * from \"./components/stat-tile\";\nexport * from \"./components/signature-pad\";\nexport * from \"./components/password-strength\";\nexport * from \"./components/page-contents\";\nexport * from \"./components/disclosure\";\nexport * from \"./components/dialog-frame\";\n// Named, not `*`: danger-confirm also holds the password field and pending hook that\n// ReauthDialog shares with it, which are kit-internal.\nexport { DangerConfirm, DEFAULT_DANGER_CONFIRM_LABELS, typedMatches } from \"./components/danger-confirm\";\nexport type { DangerConfirmLabels, DangerConfirmProps, TypedMatch } from \"./components/danger-confirm\";\n// 0.18: re-authentication before a sensitive action (Kurvenschmiede 4).\nexport { ReauthDialog, DEFAULT_REAUTH_DIALOG_LABELS } from \"./components/reauth-dialog\";\nexport type { ReauthDialogProps, ReauthDialogLabels } from \"./components/reauth-dialog\";\n// `useConfirm()` — the promise-based replacement for `window.confirm`, one host per app.\nexport * from \"./components/confirm-dialog\";\n// A non-modal corner panel and its round trigger (keksdose's assistant launcher).\nexport * from \"./components/floating-panel\";\n// The count / clear / actions bar a selection brings up (keksdose's three copies).\nexport * from \"./components/bulk-action-bar\";\nexport * from \"./components/swatch-picker\";\nexport * from \"./components/icon-picker\";\nexport * from \"./components/choice-card\";\nexport * from \"./components/autocomplete\";\nexport * from \"./components/measured-grid\";\nexport { useWindowedRows } from \"./hooks/use-windowed-rows\";\nexport type { WindowedRows } from \"./hooks/use-windowed-rows\";\n// Named, not `export *`: file-button.tsx also holds the screening helpers the\n// dropzone shares, which are internal.\nexport { FileButton, useFilePicker, matchesAccept, DEFAULT_FILE_PICKER_LABELS } from \"./components/file-button\";\nexport type {\n FileButtonProps,\n UseFilePickerOptions,\n UseFilePickerReturn,\n FilePickerLabels,\n FileRejection,\n FileRejectionReason,\n FileScreenOptions,\n} from \"./components/file-button\";\nexport * from \"./components/treemap\";\nexport * from \"./components/series-chart\";\nexport * from \"./components/chart-zoom\";\nexport * from \"./components/toggle-legend\";\nexport * from \"./components/facing-pair\";\nexport * from \"./components/series-chart-labels\";\nexport * from \"./components/pie-chart\";\nexport * from \"./components/pie-chart-labels\";\nexport * from \"./components/account-settings\";\n// 0.12.0: the fourth account section, and the QR code TwoFactorSetting draws its\n// otpauth URI with (encoder in lib/qr-encode.ts — no dependency, see there).\nexport * from \"./components/passkeys-setting\";\nexport * from \"./components/qr-code\";\nexport { encodeQr } from \"./lib/qr-encode\";\nexport type { QrEncodeOptions, QrErrorCorrection, QrMatrix } from \"./lib/qr-encode\";\nexport * from \"./components/alert-banner\";\nexport * from \"./components/toggle-group\";\n// A wrapping set of links/buttons marked `aria-current` — Tabs-like looks, not tabs.\nexport * from \"./components/nav-pills\";\n// A pill carrying one VALUE — inert, a link, or a toggle, depending on which prop it is\n// given — and the list field built from it. Distinct from Button on purpose: a row of\n// buttons reads as \"choose an action\", a row of chips as \"here are the things\".\nexport * from \"./components/chip\";\nexport * from \"./components/wizard-stepper\";\nexport * from \"./components/hover-menu\";\nexport * from \"./components/modal\";\nexport * from \"./components/full-bleed-dialog\";\nexport * from \"./components/grouped-picker\";\nexport * from \"./components/file-dropzone\";\nexport * from \"./components/mini-calendar\";\nexport * from \"./components/calendar-heatmap\";\nexport * from \"./components/date-picker\";\nexport * from \"./components/tree-view\";\nexport * from \"./components/chart\";\n// 0.8.0 layout and feedback primitives the apps hand-rolled or took from shadcn/Radix.\nexport * from \"./components/description-list\";\n// The Save / Cancel row forms and dialogs end in, and the editable line-item repeater\n// (journal lines, lease components, invoice positions). 0.12.0.\nexport * from \"./components/form-actions\";\n// 0.18: lock every opted-in commit under one provider, the reason in its tooltip\n// (Kurvenschmiede 2). `useCommitReason` stays internal.\nexport { WriteLockProvider, useWriteLock, DEFAULT_WRITE_LOCK_LABELS } from \"./components/write-lock\";\nexport type { WriteLock, WriteLockLabels, WriteLockProviderProps } from \"./components/write-lock\";\n// 0.18: the parts both apps' admin rosters repeat (Kurvenschmiede 6).\nexport { RoleChip, AccountStateChip, DateMark, dateColumn, DEFAULT_ACCOUNT_STATE_LABELS, ACCOUNT_STATE_TONES } from \"./components/account-chips\";\nexport type { RoleChipProps, RoleDefinition, RoleVocabulary, AccountState, AccountStateLabels, AccountStateChipProps, DateMarkProps, DateColumnOptions } from \"./components/account-chips\";\n// 0.18: the cold-start notice keksdose built (#199), for every app: a framework-free\n// watchdog over the app's requests and the corner notice that explains the wait.\nexport { createServerWake, serverWake, watchReadsAnd, attachServerWake, wrapFetch } from \"./lib/server-wake\";\nexport type { ServerWakeStage, ServerWakeFilter, ServerWakeOptions, ServerWakeRequest, ServerWakeWatcher, ServerWakeAxiosConfig, AxiosLikeInstance } from \"./lib/server-wake\";\nexport { ServerWakeNotice, useServerWakeStage, DEFAULT_SERVER_WAKE_LABELS } from \"./components/server-wake\";\nexport type { ServerWakeLabels, ServerWakeNoticeProps } from \"./components/server-wake\";\n// 0.18: sharing — grantees, roles, pending grants, candidates (Kurvenschmiede 1).\nexport { ShareCard, ShareDialog, SharePanel, DEFAULT_SHARE_CARD_LABELS } from \"./components/share-card\";\nexport type { ShareCardProps, ShareDialogProps, SharePanelProps, ShareCardLabels, ShareRole, ShareGrantee, SharePendingGrant, ShareCandidate, ShareAddRequest } from \"./components/share-card\";\nexport * from \"./components/line-items\";\nexport * from \"./components/progress-bar\";\n// Named: skeleton.tsx also holds SKELETON_CLASS, the look StatTile shares — internal.\nexport { Skeleton } from \"./components/skeleton\";\nexport type { SkeletonProps, SkeletonShape } from \"./components/skeleton\";\n// 0.12.0: a centred spinner with words, signed figures and deltas, a render-error fallback.\nexport * from \"./components/loading-state\";\nexport * from \"./components/signed-amount\";\nexport * from \"./components/error-boundary\";\nexport * from \"./components/copy-button\";\nexport { AuthedImage, DEFAULT_AUTHED_IMAGE_LABELS } from \"./components/authed-image\";\nexport type { AuthedImageProps, AuthedImageLabels } from \"./components/authed-image\";\nexport * from \"./components/image-grid\";\nexport * from \"./components/lightbox\";\nexport * from \"./components/button-group\";\nexport * from \"./components/table\";\nexport * from \"./components/separator\";\n// Named: scroll-area.tsx also holds the overflow hook and scrollbar class Table shares.\nexport { ScrollArea } from \"./components/scroll-area\";\nexport type { ScrollAreaProps } from \"./components/scroll-area\";\n// 0.10.0 rows, menu rows, text primitives and page chrome the apps drew by hand.\nexport * from \"./components/list\";\nexport * from \"./components/menu-item\";\nexport * from \"./components/text\";\nexport * from \"./components/status-dot\";\nexport * from \"./components/page-header\";\nexport * from \"./components/breadcrumbs\";\n// The one inline link (kastlan's EntityLink / CellLink / legal and source links), through\n// `<UiKitProvider linkComponent>`. Named: the file also holds the kit's internal link picker.\nexport { TextLink } from \"./components/text-link\";\nexport type {\n TextLinkProps,\n TextLinkRenderProps,\n TextLinkTone,\n TextLinkUnderline,\n TextLinkCurrent,\n} from \"./components/text-link\";\n// The toast layer over sonner (an OPTIONAL peer, loaded lazily): `toast` mirrors sonner's\n// API so apps migrate by swapping the import; `<Toaster>` carries the placement, theme,\n// tones and z-index both apps had wired by hand.\nexport { toast, Toaster, DEFAULT_TOAST_LABELS, TOAST_ACTION_DURATION } from \"./components/toast\";\nexport type {\n ToastId,\n ToastAction,\n ToastOptions,\n ToastPromiseOptions,\n ToastUndoOptions,\n ToastRedoOptions,\n ToastLabels,\n ToastPosition,\n ToastSwipeDirection,\n ToasterOffset,\n ToasterProps,\n} from \"./components/toast\";\n\n// ── data-table suite ─────────────────────────────────────────────────────────\nexport * from \"./components/data-table-labels\";\nexport * from \"./components/data-table-sort\";\nexport * from \"./components/data-table-filters\";\nexport * from \"./components/data-table-pagination\";\nexport { FilterPopover } from \"./components/data-table-filter-popover\";\n// data-table re-exports SortState internally; export the rest explicitly to\n// avoid a duplicate SortState star-export (it comes from data-table-sort).\nexport { DataTable } from \"./components/data-table\";\nexport type {\n DataTableColumn,\n DataTableCellProps,\n DataTableHeadProps,\n DataTableProps,\n ServerPagination,\n FilterState,\n MobileSwipeActions,\n DataTableDensity,\n DataTableChrome,\n DataTableRowAction,\n} from \"./components/data-table\";\n// 0.12.0: the yes/no cell, and a server table's state held by its owner, URL-synced.\nexport * from \"./components/data-table-cells\";\nexport { useTableUrlState, readTableUrlState } from \"./components/use-table-state\";\nexport type {\n TableUrlState,\n TableUrlSync,\n TableUrlStateProps,\n UseTableUrlStateOptions,\n UseTableUrlStateReturn,\n} from \"./components/use-table-state\";\n\n// ── shell (composable app chrome) ────────────────────────────────────────────\nexport * from \"./shell/topbar-controls\";\nexport * from \"./shell/top-bar\";\nexport * from \"./shell/app-shell\";\nexport * from \"./shell/option-switcher-menu\";\nexport * from \"./shell/role-switcher\";\nexport * from \"./shell/topbar-action-menu\";\nexport * from \"./shell/top-bar-brand\";\nexport * from \"./shell/auth-layout\";\n\n// ── feedback ─────────────────────────────────────────────────────────────────\n// The form somebody files a report with, and the parts an inbox is built from:\n// the status vocabulary both apps share value for value, the policy about what a\n// row may move to from where it stands, and the look of a status control, a\n// category badge and an opened report. The app still wires its own API, columns\n// and strings — see the note at the top of `feedback-inbox.tsx` for what is\n// deliberately left to it.\nexport * from \"./feedback/feedback-attachment\";\nexport * from \"./feedback/feedback-dialog\";\nexport * from \"./feedback/feedback-inbox\";\nexport * from \"./feedback/feedback-thread\";\n\n// ── multi-step wizard ────────────────────────────────────────────────────────\n// The engine (step machine, validators, collected data), the chrome around it\n// (indicator + nav bar + cancel confirm) and the review step it ends on.\n// `components/wizard-stepper` next door is a different, much smaller thing: a bare\n// step indicator for a two-step import flow, with no engine.\n//\n// Two modules were removed here rather than kept as stock. `wizard-field` held a\n// `WizardField`/`WizardSelectField` pair that had never been rendered in any app —\n// a field group nothing was built from, which this comment used to advertise. And\n// `use-rhf-wizard-step` was the only thing in the package that touched\n// react-hook-form, for a hook neither consumer called: keeping it meant an optional\n// peer, a dev dependency and a type import in every consumer's typecheck, bought\n// for nobody. A design system may carry stock; untested stock nothing has ever\n// rendered is not stock, it is a liability with an export.\nexport * from \"./wizard/types\";\nexport * from \"./wizard/use-wizard\";\nexport * from \"./wizard/wizard-context\";\nexport * from \"./wizard/validation\";\nexport * from \"./wizard/wizard-step\";\nexport * from \"./wizard/wizard-summary\";\nexport * from \"./wizard/stepper-nav\";\n\n// ── guided tours ─────────────────────────────────────────────────────────────\nexport * from \"./tour/tour\";\n\n// ── command palette / global search ──────────────────────────────────────────\nexport * from \"./search/command-palette\";\nexport * from \"./search/search-index\";\nexport * from \"./search/global-search\";\n\n// ── i18n: one label tree, one optional provider ──────────────────────────────\n// `UiKitLabels` names every string the kit renders; `<UiKitProvider labels locale>`\n// hands a translation to every component below it. Precedence: a component's own\n// prop > the provider > the English default. See src/i18n/kit-labels.tsx.\nexport * from \"./i18n/kit-labels\";\nexport * from \"./i18n/defaults\";\n// The kit's words as `key → text` rows for an app's translation review (keksdose).\nexport { kitLabelStrings } from \"./i18n/review\";\n// The seven languages, how an app resolves one, and the kit catalogue loader for it.\nexport * from \"./i18n/languages\";\n// CLDR plural categories for an app's i18next catalogue, filled from `_other`.\nexport { withAllPlurals } from \"./i18n/plurals\";\n// Translation review (0.19): one contract for kastlan's and keksdose's review pages —\n// the pure rows/status/placeholder logic and the presentational page parts.\nexport {\n REVIEW_STATUSES,\n fromApiReview,\n toApiWrite,\n flattenStrings,\n keyNamespace,\n placeholderTokens,\n placeholderMismatch,\n reviewStatus,\n keyInArea,\n keyInAreas,\n translationRows,\n summariseRows,\n DEFAULT_TRANSLATION_REVIEW_FILTER,\n filterTranslationRows,\n reviewWrite,\n mergeReviews,\n dropReviews,\n translationCorrections,\n} from \"./lib/translation-review\";\nexport type {\n TranslationVerdict,\n TranslationReview,\n TranslationReviewWrite,\n TranslationReviewKey,\n ReviewStatus,\n TranslationRow,\n ApiTranslationReview,\n ApiTranslationReviewWrite,\n TranslationRowsInput,\n TranslationSummary,\n TranslationReviewFilter,\n TranslationCorrection,\n} from \"./lib/translation-review\";\nexport {\n TranslationReviewPanel,\n TranslationReviewEditor,\n ReviewStatusChip,\n TranslationProgress,\n TranslationLocaleTabs,\n TranslationExportButton,\n REVIEW_STATUS_TONES,\n DEFAULT_TRANSLATION_REVIEW_LABELS,\n} from \"./components/translation-review\";\nexport type {\n TranslationReviewPanelProps,\n TranslationReviewEditorProps,\n ReviewStatusChipProps,\n TranslationProgressProps,\n TranslationLocaleTab,\n TranslationLocaleTabsProps,\n TranslationExportButtonProps,\n TranslationReviewLabels,\n} from \"./components/translation-review\";\n// The legal pages' shell (0.19, H10): Imprint, Privacy Policy, Terms in every app.\nexport { LegalLayout, LegalSection, LegalLinks, DEFAULT_LEGAL_LABELS } from \"./components/legal\";\nexport type { LegalLabels, LegalLink, LegalLinksProps, LegalSectionProps, LegalLayoutProps } from \"./components/legal\";\n"],"mappings":"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","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// @eifi1/ui-kit — shared design-system barrel.\n//\n// Domain-free UI + theme surface shared across apps (lead app: Keksdose). Consumers import\n// components/theme from \"@eifi1/ui-kit\" and the token stylesheet from \"@eifi1/ui-kit/tokens.css\".\n\n// ── lib ────────────────────────────────────────────────────────────────────\nexport * from \"./lib/calc\";\nexport { cn } from \"./lib/cn\";\nexport { logger, setStoreLog } from \"./lib/logger\";\n// Intl number / money / percent / date / relative-time formatting, and `useKitFormat()`\n// for the same bound to the provider's locale (kastlan's formatters.ts, English \"5m ago\").\nexport * from \"./lib/format\";\n// localStorage that never throws (Safari private mode, blocked site data).\nexport { readStored, writeStored } from \"./lib/safe-storage\";\n// Date helpers are also available via the \"@eifi1/ui-kit/dates\" subpath.\n\n// ── hooks ────────────────────────────────────────────────────────────────────\nexport { useMediaQuery } from \"./hooks/use-media-query\";\nexport { useBodyScrollLock } from \"./hooks/use-body-scroll-lock\";\nexport { useAnchoredRect } from \"./hooks/use-anchored-rect\";\nexport type { AnchorRect } from \"./hooks/use-anchored-rect\";\nexport { useAnchoredPanel, anchoredPanelPlacement, useVisualViewport } from \"./hooks/use-anchored-panel\";\nexport type {\n AnchoredPanel,\n AnchoredPanelOptions,\n ViewportBox,\n} from \"./hooks/use-anchored-panel\";\nexport { useEscapeKey, useOutsideClick } from \"./hooks/use-dismiss\";\n// Focus containment for an overlay, and a live region for a change that moves no focus.\n// Both were extracted from the two components that already did them correctly (Modal and\n// CommandPalette) so the rest of the kit stops being the exception.\nexport { useFocusTrap } from \"./hooks/use-focus-trap\";\nexport type { FocusTrapOptions } from \"./hooks/use-focus-trap\";\nexport { useAnnounce } from \"./hooks/use-announce\";\nexport type { UseAnnounceReturn, UseAnnounceOptions, AnnounceRegionProps } from \"./hooks/use-announce\";\nexport { useOverlayHistory } from \"./hooks/use-overlay-history\";\nexport { useCloseTransition, OVERLAY_EXIT_MS } from \"./hooks/use-close-transition\";\nexport { useRowSwipe } from \"./hooks/use-row-swipe\";\nexport type { SwipeStage, RowSwipeOptions, RowSwipeReturn } from \"./hooks/use-row-swipe\";\n// Any element as a file drop target, screened like FileButton (kastlan).\nexport { useFileDrop, dragHasFiles } from \"./hooks/use-file-drop\";\nexport type { UseFileDropOptions, UseFileDropReturn, FileDropProps } from \"./hooks/use-file-drop\";\n// kastlan's search boxes each carried a hand-rolled copy, two without the cleanup.\nexport { useDebounce, useDebouncedCallback } from \"./hooks/use-debounce\";\nexport type { DebouncedCallbackOptions, DebouncedFunction } from \"./hooks/use-debounce\";\n// One search param as state, the active tab in `?tab=`, and a dialog's open state in the\n// URL (Modal's `urlParam`) — kastlan's and keksdose's use-search-param-state, in the kit.\nexport { useSearchParamState, useTabParam, useDialogParam } from \"./hooks/use-search-param-state\";\nexport type { SearchParamStateOptions, DialogParam } from \"./hooks/use-search-param-state\";\n// Copy that reports whether it worked — keksdose's copy buttons said \"Copied\" when it had not.\nexport { useCopyToClipboard, copyToClipboard } from \"./hooks/use-copy-to-clipboard\";\nexport type { CopyState, UseCopyToClipboardOptions, UseCopyToClipboardReturn } from \"./hooks/use-copy-to-clipboard\";\n// Keyboard shortcuts (\"Mod+K\", \"Ctrl+Shift+F\") that leave typing in fields alone.\nexport { useHotkey, parseHotkey, matchesHotkey } from \"./hooks/use-hotkey\";\nexport type { Hotkey, ParsedHotkey, UseHotkeyOptions } from \"./hooks/use-hotkey\";\n// A protected file as an object URL, fetched with the app's own auth (kastlan's AuthedImage).\nexport { useAuthedSrc } from \"./hooks/use-authed-src\";\nexport type { AuthedFetcher, AuthedSrcStatus, UseAuthedSrcOptions, UseAuthedSrcResult } from \"./hooks/use-authed-src\";\n\n// ── theme / palettes ─────────────────────────────────────────────────────────\nexport * from \"./theme/chart-palette\";\n// Colour maths (sRGB ↔ OKLCH, WCAG contrast, CVD simulation) and the palette deriver\n// that builds a whole, contrast-solved palette from one brand colour plus any colours\n// pinned by hand. `auditPalette` / `auditChartRamp` measure a palette rather than\n// trusting a comment about it.\nexport * from \"./theme/color\";\nexport * from \"./theme/palette-derive\";\nexport * from \"./theme/palette-presets\";\nexport * from \"./theme/theme-store\";\nexport * from \"./theme/palette-store\";\n\n// ── components ───────────────────────────────────────────────────────────────\nexport * from \"./components/ui\";\n// The label-ABOVE field group (label, hint, error, required), inside wizards or out.\nexport * from \"./components/field\";\nexport * from \"./components/search-field\";\nexport * from \"./components/dropdown\";\nexport * from \"./components/popover\";\nexport { SwipeableRow } from \"./components/swipeable-row\";\nexport type { SwipeAction, SwipeableRowProps } from \"./components/swipeable-row\";\nexport * from \"./components/calculator\";\nexport * from \"./components/numpad-sheet\";\nexport * from \"./components/number-input\";\nexport * from \"./components/currency-select\";\nexport * from \"./components/amount-input\";\nexport * from \"./components/money-field\";\nexport * from \"./components/combobox\";\nexport * from \"./components/picker-sheet\";\nexport * from \"./components/entity-combobox\";\nexport * from \"./components/multi-entity-combobox\";\nexport * from \"./components/multi-select\";\nexport * from \"./components/tooltip\";\nexport * from \"./components/user-avatar\";\nexport * from \"./components/settings-fields\";\n// Sync state for a database-backed field: the engine (`useFieldSync`) and the\n// affordance (`FieldSyncIndicator`), kept separate because the state is useful\n// without the dot — a form can gate its submit on any field being `pending`.\nexport * from \"./components/field-sync\";\nexport * from \"./components/month-picker\";\nexport * from \"./components/checkbox\";\nexport * from \"./components/switch\";\nexport * from \"./components/slider\";\nexport * from \"./components/time-input\";\nexport * from \"./components/number-field\";\nexport * from \"./components/sparkline\";\nexport * from \"./components/stat-tile\";\nexport * from \"./components/signature-pad\";\nexport * from \"./components/password-strength\";\nexport * from \"./components/page-contents\";\nexport * from \"./components/disclosure\";\nexport * from \"./components/dialog-frame\";\n// Named, not `*`: danger-confirm also holds the password field and pending hook that\n// ReauthDialog shares with it, which are kit-internal.\nexport {\n DangerConfirm,\n DEFAULT_DANGER_CONFIRM_LABELS,\n typedMatches,\n // 0.22.0: the typed-confirmation field on its own (keksdose K7) and the current-password\n // field kastlan wants for sign-in and re-authentication (kastlan 1).\n TypedConfirmField,\n CurrentPasswordInput,\n} from \"./components/danger-confirm\";\nexport type {\n DangerConfirmLabels,\n DangerConfirmProps,\n TypedMatch,\n DangerConsequence,\n TypedConfirmFieldProps,\n TypedConfirmFieldLabels,\n CurrentPasswordInputProps,\n CurrentPasswordInputLabels,\n // 0.23.0: onConfirm's second argument — the guards' values (keksdose G4b).\n DangerConfirmValues,\n} from \"./components/danger-confirm\";\n// 0.18: re-authentication before a sensitive action (Kurvenschmiede 4).\nexport { ReauthDialog, DEFAULT_REAUTH_DIALOG_LABELS } from \"./components/reauth-dialog\";\nexport type { ReauthDialogProps, ReauthDialogLabels } from \"./components/reauth-dialog\";\n// `useConfirm()` — the promise-based replacement for `window.confirm`, one host per app.\nexport * from \"./components/confirm-dialog\";\n// A non-modal corner panel and its round trigger (keksdose's assistant launcher).\nexport * from \"./components/floating-panel\";\n// The count / clear / actions bar a selection brings up (keksdose's three copies).\nexport * from \"./components/bulk-action-bar\";\nexport * from \"./components/swatch-picker\";\nexport * from \"./components/icon-picker\";\nexport * from \"./components/choice-card\";\nexport * from \"./components/autocomplete\";\nexport * from \"./components/measured-grid\";\nexport { useWindowedRows } from \"./hooks/use-windowed-rows\";\nexport type { WindowedRows } from \"./hooks/use-windowed-rows\";\n// Named, not `export *`: file-button.tsx also holds the screening helpers the\n// dropzone shares, which are internal.\nexport { FileButton, useFilePicker, matchesAccept, DEFAULT_FILE_PICKER_LABELS } from \"./components/file-button\";\nexport type {\n FileButtonProps,\n UseFilePickerOptions,\n UseFilePickerReturn,\n FilePickerLabels,\n FileRejection,\n FileRejectionReason,\n FileScreenOptions,\n} from \"./components/file-button\";\nexport * from \"./components/treemap\";\nexport * from \"./components/series-chart\";\nexport * from \"./components/chart-zoom\";\nexport * from \"./components/toggle-legend\";\nexport * from \"./components/facing-pair\";\nexport * from \"./components/series-chart-labels\";\nexport * from \"./components/pie-chart\";\nexport * from \"./components/pie-chart-labels\";\nexport * from \"./components/account-settings\";\n// 0.12.0: the fourth account section, and the QR code TwoFactorSetting draws its\n// otpauth URI with (encoder in lib/qr-encode.ts — no dependency, see there).\nexport * from \"./components/passkeys-setting\";\nexport * from \"./components/qr-code\";\nexport { encodeQr } from \"./lib/qr-encode\";\nexport type { QrEncodeOptions, QrErrorCorrection, QrMatrix } from \"./lib/qr-encode\";\nexport * from \"./components/alert-banner\";\nexport * from \"./components/toggle-group\";\n// A wrapping set of links/buttons marked `aria-current` — Tabs-like looks, not tabs.\nexport * from \"./components/nav-pills\";\n// A pill carrying one VALUE — inert, a link, or a toggle, depending on which prop it is\n// given — and the list field built from it. Distinct from Button on purpose: a row of\n// buttons reads as \"choose an action\", a row of chips as \"here are the things\".\nexport * from \"./components/chip\";\nexport * from \"./components/wizard-stepper\";\nexport * from \"./components/hover-menu\";\nexport * from \"./components/modal\";\nexport * from \"./components/full-bleed-dialog\";\nexport * from \"./components/grouped-picker\";\nexport * from \"./components/file-dropzone\";\nexport * from \"./components/mini-calendar\";\nexport * from \"./components/calendar-heatmap\";\nexport * from \"./components/date-picker\";\nexport * from \"./components/tree-view\";\nexport * from \"./components/chart\";\n// 0.8.0 layout and feedback primitives the apps hand-rolled or took from shadcn/Radix.\nexport * from \"./components/description-list\";\n// The Save / Cancel row forms and dialogs end in, and the editable line-item repeater\n// (journal lines, lease components, invoice positions). 0.12.0.\nexport * from \"./components/form-actions\";\n// 0.18: lock every opted-in commit under one provider, the reason in its tooltip\n// (Kurvenschmiede 2). `useCommitReason` stays internal.\nexport { WriteLockProvider, useWriteLock, DEFAULT_WRITE_LOCK_LABELS } from \"./components/write-lock\";\nexport type { WriteLock, WriteLockLabels, WriteLockProviderProps } from \"./components/write-lock\";\n// 0.18: the parts both apps' admin rosters repeat (Kurvenschmiede 6).\nexport { RoleChip, AccountStateChip, DateMark, dateColumn, DEFAULT_ACCOUNT_STATE_LABELS, ACCOUNT_STATE_TONES } from \"./components/account-chips\";\nexport type { RoleChipProps, RoleDefinition, RoleVocabulary, AccountState, AccountStateLabels, AccountStateChipProps, DateMarkProps, DateColumnOptions } from \"./components/account-chips\";\n// 0.18: the cold-start notice keksdose built (#199), for every app: a framework-free\n// watchdog over the app's requests and the corner notice that explains the wait.\nexport { createServerWake, serverWake, watchReadsAnd, attachServerWake, wrapFetch } from \"./lib/server-wake\";\nexport type { ServerWakeStage, ServerWakeFilter, ServerWakeOptions, ServerWakeRequest, ServerWakeWatcher, ServerWakeAxiosConfig, AxiosLikeInstance } from \"./lib/server-wake\";\nexport { ServerWakeNotice, useServerWakeStage, DEFAULT_SERVER_WAKE_LABELS } from \"./components/server-wake\";\nexport type { ServerWakeLabels, ServerWakeNoticeProps } from \"./components/server-wake\";\n// 0.18: sharing — grantees, roles, pending grants, candidates (Kurvenschmiede 1).\nexport { ShareCard, ShareDialog, SharePanel, DEFAULT_SHARE_CARD_LABELS } from \"./components/share-card\";\nexport type { ShareCardProps, ShareDialogProps, SharePanelProps, ShareCardLabels, ShareRole, ShareGrantee, SharePendingGrant, ShareCandidate, ShareAddRequest } from \"./components/share-card\";\nexport * from \"./components/line-items\";\nexport * from \"./components/progress-bar\";\n// Named: skeleton.tsx also holds SKELETON_CLASS, the look StatTile shares — internal.\nexport { Skeleton } from \"./components/skeleton\";\nexport type { SkeletonProps, SkeletonShape } from \"./components/skeleton\";\n// 0.12.0: a centred spinner with words, signed figures and deltas, a render-error fallback.\nexport * from \"./components/loading-state\";\nexport * from \"./components/signed-amount\";\nexport * from \"./components/error-boundary\";\nexport * from \"./components/copy-button\";\nexport { AuthedImage, DEFAULT_AUTHED_IMAGE_LABELS } from \"./components/authed-image\";\nexport type { AuthedImageProps, AuthedImageLabels } from \"./components/authed-image\";\nexport * from \"./components/image-grid\";\nexport * from \"./components/lightbox\";\nexport * from \"./components/button-group\";\nexport * from \"./components/table\";\nexport * from \"./components/separator\";\n// Named: scroll-area.tsx also holds the overflow hook and scrollbar class Table shares.\nexport { ScrollArea } from \"./components/scroll-area\";\nexport type { ScrollAreaProps } from \"./components/scroll-area\";\n// 0.10.0 rows, menu rows, text primitives and page chrome the apps drew by hand.\nexport * from \"./components/list\";\nexport * from \"./components/menu-item\";\nexport * from \"./components/text\";\nexport * from \"./components/status-dot\";\nexport * from \"./components/page-header\";\nexport * from \"./components/breadcrumbs\";\n// The one inline link (kastlan's EntityLink / CellLink / legal and source links), through\n// `<UiKitProvider linkComponent>`. Named: the file also holds the kit's internal link picker.\nexport { TextLink } from \"./components/text-link\";\nexport type {\n TextLinkProps,\n TextLinkRenderProps,\n TextLinkTone,\n TextLinkUnderline,\n TextLinkCurrent,\n} from \"./components/text-link\";\n// The toast layer over sonner (an OPTIONAL peer, loaded lazily): `toast` mirrors sonner's\n// API so apps migrate by swapping the import; `<Toaster>` carries the placement, theme,\n// tones and z-index both apps had wired by hand.\nexport { toast, Toaster, DEFAULT_TOAST_LABELS, TOAST_ACTION_DURATION } from \"./components/toast\";\nexport type {\n ToastId,\n ToastAction,\n ToastOptions,\n ToastPromiseOptions,\n ToastUndoOptions,\n ToastRedoOptions,\n ToastLabels,\n ToastPosition,\n ToastSwipeDirection,\n ToasterOffset,\n ToasterProps,\n} from \"./components/toast\";\n\n// ── data-table suite ─────────────────────────────────────────────────────────\nexport * from \"./components/data-table-labels\";\nexport * from \"./components/data-table-sort\";\nexport * from \"./components/data-table-filters\";\nexport * from \"./components/data-table-pagination\";\nexport { FilterPopover } from \"./components/data-table-filter-popover\";\n// data-table re-exports SortState internally; export the rest explicitly to\n// avoid a duplicate SortState star-export (it comes from data-table-sort).\nexport { DataTable, DEFAULT_DATA_TABLE_SORT_LABELS } from \"./components/data-table\";\nexport type {\n DataTableSortLabels,\n DataTableColumn,\n DataTableCellProps,\n DataTableHeadProps,\n DataTableProps,\n ServerPagination,\n FilterState,\n MobileSwipeActions,\n DataTableDensity,\n DataTableChrome,\n DataTableRowAction,\n} from \"./components/data-table\";\n// 0.12.0: the yes/no cell, and a server table's state held by its owner, URL-synced.\nexport * from \"./components/data-table-cells\";\nexport { useTableUrlState, readTableUrlState } from \"./components/use-table-state\";\nexport type {\n TableUrlState,\n TableUrlSync,\n TableUrlStateProps,\n UseTableUrlStateOptions,\n UseTableUrlStateReturn,\n} from \"./components/use-table-state\";\n\n// ── shell (composable app chrome) ────────────────────────────────────────────\nexport * from \"./shell/topbar-controls\";\nexport * from \"./shell/top-bar\";\nexport * from \"./shell/app-shell\";\nexport * from \"./shell/option-switcher-menu\";\nexport * from \"./shell/role-switcher\";\nexport * from \"./shell/topbar-action-menu\";\nexport * from \"./shell/top-bar-brand\";\nexport * from \"./shell/auth-layout\";\n\n// ── feedback ─────────────────────────────────────────────────────────────────\n// The form somebody files a report with, and the parts an inbox is built from:\n// the status vocabulary both apps share value for value, the policy about what a\n// row may move to from where it stands, and the look of a status control, a\n// category badge and an opened report. The app still wires its own API, columns\n// and strings — see the note at the top of `feedback-inbox.tsx` for what is\n// deliberately left to it.\nexport * from \"./feedback/feedback-attachment\";\nexport * from \"./feedback/feedback-dialog\";\nexport * from \"./feedback/feedback-inbox\";\nexport * from \"./feedback/feedback-thread\";\n\n// ── multi-step wizard ────────────────────────────────────────────────────────\n// The engine (step machine, validators, collected data), the chrome around it\n// (indicator + nav bar + cancel confirm) and the review step it ends on.\n// `components/wizard-stepper` next door is a different, much smaller thing: a bare\n// step indicator for a two-step import flow, with no engine.\n//\n// Two modules were removed here rather than kept as stock. `wizard-field` held a\n// `WizardField`/`WizardSelectField` pair that had never been rendered in any app —\n// a field group nothing was built from, which this comment used to advertise. And\n// `use-rhf-wizard-step` was the only thing in the package that touched\n// react-hook-form, for a hook neither consumer called: keeping it meant an optional\n// peer, a dev dependency and a type import in every consumer's typecheck, bought\n// for nobody. A design system may carry stock; untested stock nothing has ever\n// rendered is not stock, it is a liability with an export.\nexport * from \"./wizard/types\";\nexport * from \"./wizard/use-wizard\";\nexport * from \"./wizard/wizard-context\";\nexport * from \"./wizard/validation\";\nexport * from \"./wizard/wizard-step\";\nexport * from \"./wizard/wizard-summary\";\nexport * from \"./wizard/stepper-nav\";\n\n// ── guided tours ─────────────────────────────────────────────────────────────\nexport * from \"./tour/tour\";\n\n// ── command palette / global search ──────────────────────────────────────────\nexport * from \"./search/command-palette\";\nexport * from \"./search/search-index\";\nexport * from \"./search/global-search\";\n\n// ── i18n: one label tree, one optional provider ──────────────────────────────\n// `UiKitLabels` names every string the kit renders; `<UiKitProvider labels locale>`\n// hands a translation to every component below it. Precedence: a component's own\n// prop > the provider > the English default. See src/i18n/kit-labels.tsx.\nexport * from \"./i18n/kit-labels\";\nexport * from \"./i18n/defaults\";\n// The kit's words as `key → text` rows for an app's translation review (keksdose).\nexport { kitLabelStrings } from \"./i18n/review\";\n// The seven languages, how an app resolves one, and the kit catalogue loader for it.\nexport * from \"./i18n/languages\";\n// CLDR plural categories for an app's i18next catalogue, filled from `_other`.\nexport { withAllPlurals } from \"./i18n/plurals\";\n// Translation review (0.19): one contract for kastlan's and keksdose's review pages —\n// the pure rows/status/placeholder logic and the presentational page parts.\nexport {\n REVIEW_STATUSES,\n fromApiReview,\n toApiWrite,\n flattenStrings,\n keyNamespace,\n placeholderTokens,\n placeholderMismatch,\n reviewStatus,\n keyInArea,\n keyInAreas,\n translationRows,\n summariseRows,\n DEFAULT_TRANSLATION_REVIEW_FILTER,\n filterTranslationRows,\n reviewWrite,\n mergeReviews,\n dropReviews,\n translationCorrections,\n} from \"./lib/translation-review\";\nexport type {\n TranslationVerdict,\n TranslationReview,\n TranslationReviewWrite,\n TranslationReviewKey,\n ReviewStatus,\n TranslationRow,\n ApiTranslationReview,\n ApiTranslationReviewWrite,\n TranslationRowsInput,\n TranslationSummary,\n TranslationReviewFilter,\n TranslationCorrection,\n} from \"./lib/translation-review\";\nexport {\n TranslationReviewPanel,\n TranslationReviewEditor,\n ReviewStatusChip,\n TranslationProgress,\n TranslationLocaleTabs,\n TranslationExportButton,\n REVIEW_STATUS_TONES,\n DEFAULT_TRANSLATION_REVIEW_LABELS,\n} from \"./components/translation-review\";\nexport type {\n TranslationReviewPanelProps,\n TranslationReviewEditorProps,\n ReviewStatusChipProps,\n TranslationProgressProps,\n TranslationLocaleTab,\n TranslationLocaleTabsProps,\n TranslationExportButtonProps,\n TranslationReviewLabels,\n} from \"./components/translation-review\";\n// The legal pages' shell (0.19, H10): Imprint, Privacy Policy, Terms in every app.\nexport { LegalLayout, LegalSection, LegalLinks, DEFAULT_LEGAL_LABELS } from \"./components/legal\";\nexport type { LegalLabels, LegalLink, LegalLinksProps, LegalSectionProps, LegalLayoutProps } from \"./components/legal\";\n\n// ── 0.22.0: the inputs round (kastlan's, keksdose's and Kurvenschmiede's audits) ──\nexport * from \"./components/checkbox-group\";\nexport * from \"./components/one-time-code-input\";\nexport * from \"./components/language-select\";\nexport * from \"./components/tile-radio\";\nexport * from \"./components/inline-edit-field\";\nexport * from \"./components/sign-chip\";\nexport * from \"./components/country-select\";\nexport { COUNTRY_CODES, countryName } from \"./lib/countries\";\nexport * from \"./components/iban-input\";\nexport {\n IBAN_LENGTHS,\n compactIban,\n formatIban,\n ibanCheckDigits,\n ibanProblem,\n isValidIban,\n isQrIban,\n} from \"./lib/iban\";\nexport type { IbanKind, IbanProblem } from \"./lib/iban\";\nexport { formatIsin, isinCheckDigit, isValidIsin } from \"./lib/isin\";\nexport * from \"./components/phone-input\";\nexport {\n PHONE_DIAL_CODES,\n PHONE_COUNTRIES,\n parsePhone,\n formatNationalPhone,\n formatPhone,\n isE164,\n} from \"./lib/phone\";\nexport type { PhoneCountryCode, PhoneCountry, ParsedPhone } from \"./lib/phone\";\n\n// ── 0.23.0: the apps' 0.22 adoption round (kastlan, keksdose, Kurvenschmiede) ──\n// The label strip over custom content (keksdose G8).\nexport * from \"./components/field-strip\";\n// Paste or drop a table, give each column a role (Kurvenschmiede's columns input,\n// keksdose's import map step). The lexer itself stays in `@eifi1/ui-kit/table-text`.\nexport * from \"./components/column-mapper\";\nexport {\n assignColumnRole,\n guessMapping,\n missingRoles,\n readMappedTable,\n readTextFile,\n roleOfColumn,\n} from \"./lib/column-mapping\";\nexport type { ColumnMapperResult, ColumnMapping, ColumnRole } from \"./lib/column-mapping\";\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { TextTable } from './table-text.js';
|
|
2
|
+
|
|
3
|
+
/** One part a column can play, defined by the caller. */
|
|
4
|
+
interface ColumnRole<R extends string = string> {
|
|
5
|
+
/** The key the mapping is stored under. */
|
|
6
|
+
value: R;
|
|
7
|
+
/** What the role select shows — translated by the caller. */
|
|
8
|
+
label: string;
|
|
9
|
+
/**
|
|
10
|
+
* `true`: the table cannot be used until a column plays this role. A string names a
|
|
11
|
+
* GROUP: the table needs any one of the roles that share it — keksdose's amount,
|
|
12
|
+
* debit and credit, any of which carries the money.
|
|
13
|
+
*/
|
|
14
|
+
required?: boolean | string;
|
|
15
|
+
/**
|
|
16
|
+
* Every cell this role reads must be a number in the table's decimal convention
|
|
17
|
+
* ({@link tableNumber}). A row where one is not — a footer, a units line, a total
|
|
18
|
+
* with a grouping mark — is moved to `unread` with its line number instead of being
|
|
19
|
+
* handed over. Kurvenschmiede's time, setpoint and actual. The cells stay strings:
|
|
20
|
+
* converting is the caller's, with `tableNumber(cell, result.decimalComma)`.
|
|
21
|
+
*/
|
|
22
|
+
numeric?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** Role → column index. A role that is absent or `null` sits on no column — so a
|
|
25
|
+
* mapping with nullable fields (keksdose's `CsvMapping`) is one as it stands. */
|
|
26
|
+
type ColumnMapping<R extends string = string> = Partial<Record<R, number | null>>;
|
|
27
|
+
/** What the table is, read through a mapping. */
|
|
28
|
+
interface ColumnMapperResult<R extends string = string> extends TextTable {
|
|
29
|
+
mapping: ColumnMapping<R>;
|
|
30
|
+
/** What the table still needs before it can be used: one entry per gap, each the
|
|
31
|
+
* roles any of which would fill it (one role, or a required group). */
|
|
32
|
+
missing: R[][];
|
|
33
|
+
/** Every required role placed, and at least one row read. */
|
|
34
|
+
complete: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** The role on this column, or `null` for an ignored one. */
|
|
37
|
+
declare function roleOfColumn<R extends string>(roles: readonly ColumnRole<R>[], mapping: ColumnMapping<R>, column: number): R | null;
|
|
38
|
+
/**
|
|
39
|
+
* Put `role` on `column` — or, with `null`, take the column's role off it.
|
|
40
|
+
*
|
|
41
|
+
* Whatever this column played before stops, and the role moves here from any other
|
|
42
|
+
* column, in one new mapping (keksdose's `assignColumn`: "both halves are patches to
|
|
43
|
+
* the same object"). Other fields of the mapping are kept as they are.
|
|
44
|
+
*/
|
|
45
|
+
declare function assignColumnRole<R extends string, M extends ColumnMapping<R>>(roles: readonly ColumnRole<R>[], mapping: M, column: number, role: R | null): M;
|
|
46
|
+
/**
|
|
47
|
+
* The gaps: each required role with no column, and each required group none of whose
|
|
48
|
+
* roles has one. In the order of `roles`. A column index past `width` is no column.
|
|
49
|
+
*/
|
|
50
|
+
declare function missingRoles<R extends string>(roles: readonly ColumnRole<R>[], mapping: ColumnMapping<R>, width?: number): R[][];
|
|
51
|
+
/**
|
|
52
|
+
* A first mapping for a table nobody has mapped yet.
|
|
53
|
+
*
|
|
54
|
+
* A column whose header IS a role's label or key gets that role. The required roles
|
|
55
|
+
* left over then take the free columns in order — Kurvenschmiede's "time, setpoint,
|
|
56
|
+
* actual are the first three columns", which is how a recorder writes them. Optional
|
|
57
|
+
* roles are not guessed by position: in a bank
|
|
58
|
+
* export of twelve columns, "the fourth role is the fourth column" is a wrong answer
|
|
59
|
+
* presented as a suggestion, and an "ignore" is the honest one.
|
|
60
|
+
*/
|
|
61
|
+
declare function guessMapping<R extends string>(roles: readonly ColumnRole<R>[], header: readonly string[] | null, width: number): ColumnMapping<R>;
|
|
62
|
+
/**
|
|
63
|
+
* The table read through the mapping: the rows every `numeric` role can read, the
|
|
64
|
+
* others moved to `unread` (in line order, with the parse's own), what is missing,
|
|
65
|
+
* and whether the table can be used. Column indexes past the table's width count as
|
|
66
|
+
* unplaced.
|
|
67
|
+
*/
|
|
68
|
+
declare function readMappedTable<R extends string>(table: TextTable, roles: readonly ColumnRole<R>[], mapping: ColumnMapping<R>): ColumnMapperResult<R>;
|
|
69
|
+
/**
|
|
70
|
+
* A dropped or chosen file's text — UTF-8 when it is UTF-8, else Windows-1252.
|
|
71
|
+
*
|
|
72
|
+
* A German bank or bench export is very often written in Windows-1252, and reading it
|
|
73
|
+
* as UTF-8 turns every "ä" in a column name into "�" — no error, just a header nobody
|
|
74
|
+
* recognises. So the bytes are tried as strict UTF-8 first and read as Windows-1252
|
|
75
|
+
* when that fails (keksdose's server sniffs the encoding for the same reason; a file
|
|
76
|
+
* read in the browser had nothing doing it). Falls back to `FileReader` where a `File`
|
|
77
|
+
* has no `arrayBuffer` (Kurvenschmiede's `readText`).
|
|
78
|
+
*/
|
|
79
|
+
declare function readTextFile(file: Blob): Promise<string>;
|
|
80
|
+
|
|
81
|
+
export { type ColumnMapperResult, type ColumnMapping, type ColumnRole, assignColumnRole, guessMapping, missingRoles, readMappedTable, readTextFile, roleOfColumn };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { tableNumber } from "./table-text.js";
|
|
3
|
+
const placedAt = (mapping, role, width) => {
|
|
4
|
+
const column = mapping[role];
|
|
5
|
+
if (typeof column !== "number") return null;
|
|
6
|
+
return width === void 0 || column < width ? column : null;
|
|
7
|
+
};
|
|
8
|
+
function roleOfColumn(roles, mapping, column) {
|
|
9
|
+
return roles.find((role) => mapping[role.value] === column)?.value ?? null;
|
|
10
|
+
}
|
|
11
|
+
function assignColumnRole(roles, mapping, column, role) {
|
|
12
|
+
const next = { ...mapping };
|
|
13
|
+
for (const { value } of roles) {
|
|
14
|
+
if (mapping[value] === column) next[value] = null;
|
|
15
|
+
}
|
|
16
|
+
if (role !== null) next[role] = column;
|
|
17
|
+
return next;
|
|
18
|
+
}
|
|
19
|
+
function missingRoles(roles, mapping, width) {
|
|
20
|
+
const gaps = [];
|
|
21
|
+
const groups = /* @__PURE__ */ new Set();
|
|
22
|
+
for (const role of roles) {
|
|
23
|
+
if (role.required === true) {
|
|
24
|
+
if (placedAt(mapping, role.value, width) === null) gaps.push([role.value]);
|
|
25
|
+
} else if (typeof role.required === "string" && !groups.has(role.required)) {
|
|
26
|
+
groups.add(role.required);
|
|
27
|
+
const members = roles.filter((other) => other.required === role.required);
|
|
28
|
+
if (members.every((member) => placedAt(mapping, member.value, width) === null)) {
|
|
29
|
+
gaps.push(members.map((member) => member.value));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return gaps;
|
|
34
|
+
}
|
|
35
|
+
const normalised = (text) => text.trim().toLowerCase();
|
|
36
|
+
function guessMapping(roles, header, width) {
|
|
37
|
+
const mapping = {};
|
|
38
|
+
const taken = /* @__PURE__ */ new Set();
|
|
39
|
+
if (header) {
|
|
40
|
+
for (const role of roles) {
|
|
41
|
+
const names = [normalised(role.label), normalised(role.value)];
|
|
42
|
+
const column = header.findIndex((name, index) => !taken.has(index) && names.includes(normalised(name)));
|
|
43
|
+
if (column >= 0) {
|
|
44
|
+
mapping[role.value] = column;
|
|
45
|
+
taken.add(column);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const free = Array.from({ length: width }, (_, index) => index).filter((index) => !taken.has(index));
|
|
50
|
+
for (const role of roles) {
|
|
51
|
+
if (role.required !== true || typeof mapping[role.value] === "number") continue;
|
|
52
|
+
const column = free.shift();
|
|
53
|
+
if (column === void 0) break;
|
|
54
|
+
mapping[role.value] = column;
|
|
55
|
+
}
|
|
56
|
+
return mapping;
|
|
57
|
+
}
|
|
58
|
+
function readMappedTable(table, roles, mapping) {
|
|
59
|
+
const numeric = roles.filter((role) => role.numeric).map((role) => placedAt(mapping, role.value, table.width)).filter((column) => column !== null);
|
|
60
|
+
const rows = [];
|
|
61
|
+
const lines = [];
|
|
62
|
+
const refused = [];
|
|
63
|
+
table.rows.forEach((row, index) => {
|
|
64
|
+
if (numeric.every((column) => Number.isFinite(tableNumber(row[column] ?? "", table.decimalComma)))) {
|
|
65
|
+
rows.push(row);
|
|
66
|
+
lines.push(table.lines[index]);
|
|
67
|
+
} else {
|
|
68
|
+
refused.push(table.lines[index]);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
const unread = refused.length ? [...table.unread, ...refused].sort((a, b) => a.line - b.line) : table.unread;
|
|
72
|
+
const missing = missingRoles(roles, mapping, table.width);
|
|
73
|
+
return {
|
|
74
|
+
...table,
|
|
75
|
+
rows,
|
|
76
|
+
lines,
|
|
77
|
+
unread,
|
|
78
|
+
mapping,
|
|
79
|
+
missing,
|
|
80
|
+
complete: missing.length === 0 && rows.length > 0
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
async function readTextFile(file) {
|
|
84
|
+
const bytes = await bytesOf(file);
|
|
85
|
+
try {
|
|
86
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
87
|
+
} catch {
|
|
88
|
+
return new TextDecoder("windows-1252").decode(bytes);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function bytesOf(file) {
|
|
92
|
+
if (typeof file.arrayBuffer === "function") return file.arrayBuffer();
|
|
93
|
+
return new Promise((resolve, reject) => {
|
|
94
|
+
const reader = new FileReader();
|
|
95
|
+
reader.onload = () => resolve(reader.result);
|
|
96
|
+
reader.onerror = () => reject(reader.error ?? new Error("read failed"));
|
|
97
|
+
reader.readAsArrayBuffer(file);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
export {
|
|
101
|
+
assignColumnRole,
|
|
102
|
+
guessMapping,
|
|
103
|
+
missingRoles,
|
|
104
|
+
readMappedTable,
|
|
105
|
+
readTextFile,
|
|
106
|
+
roleOfColumn
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=column-mapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/column-mapping.ts"],"sourcesContent":["/**\n * Which column of a table plays which part — the headless half of {@link ColumnMapper}.\n *\n * Two apps built this by hand, the same way. Kurvenschmiede's columns input\n * (`features/control/columns-input.tsx`) reads a recorder's export and asks which\n * column is the time, the setpoint and the actual; keksdose's bank-file import\n * (`import-map-step.tsx`, `use-file-import.ts`) shows a bank's CSV and asks which\n * column is the booking date, the amount, the payee. Both then have the same four\n * rules, and keksdose wrote them down after getting each one wrong once:\n *\n * * **A role sits on one column at most, and a column carries one role.** Picking a\n * role for a column MOVES it there from wherever it was ({@link assignColumnRole});\n * the column it left falls back to \"ignore\" in the same step. There is no error\n * state, because there is nothing wrong to report.\n * * **What is still missing is named**, not left to a disabled button\n * ({@link missingRoles}). A required role can be one of a group: a bank export that\n * splits debit and credit has no amount column and needs none, so `required` may\n * name a group, satisfied by any one of its members (keksdose's \"money\").\n * * **A mapping is indexes into ONE table.** When the column count changes, the\n * indexes mean nothing any more and are guessed afresh; when it does not (the\n * header line toggled), they still point where they did — keksdose's `keepRoles`.\n * * **The rows a role cannot read are reported by line**, not dropped in silence\n * ({@link readMappedTable}): a footer under a recording, a total under a statement.\n *\n * Pure functions over plain data, so a two-step wizard can hold the mapping in its own\n * state between steps, and a table the server sniffed (keksdose's) can be mapped with\n * the same rules as one parsed here.\n */\nimport { tableNumber } from \"./table-text\";\nimport type { TableLine, TextTable } from \"./table-text\";\n\n/** One part a column can play, defined by the caller. */\nexport interface ColumnRole<R extends string = string> {\n /** The key the mapping is stored under. */\n value: R;\n /** What the role select shows — translated by the caller. */\n label: string;\n /**\n * `true`: the table cannot be used until a column plays this role. A string names a\n * GROUP: the table needs any one of the roles that share it — keksdose's amount,\n * debit and credit, any of which carries the money.\n */\n required?: boolean | string;\n /**\n * Every cell this role reads must be a number in the table's decimal convention\n * ({@link tableNumber}). A row where one is not — a footer, a units line, a total\n * with a grouping mark — is moved to `unread` with its line number instead of being\n * handed over. Kurvenschmiede's time, setpoint and actual. The cells stay strings:\n * converting is the caller's, with `tableNumber(cell, result.decimalComma)`.\n */\n numeric?: boolean;\n}\n\n/** Role → column index. A role that is absent or `null` sits on no column — so a\n * mapping with nullable fields (keksdose's `CsvMapping`) is one as it stands. */\nexport type ColumnMapping<R extends string = string> = Partial<Record<R, number | null>>;\n\n/** What the table is, read through a mapping. */\nexport interface ColumnMapperResult<R extends string = string> extends TextTable {\n mapping: ColumnMapping<R>;\n /** What the table still needs before it can be used: one entry per gap, each the\n * roles any of which would fill it (one role, or a required group). */\n missing: R[][];\n /** Every required role placed, and at least one row read. */\n complete: boolean;\n}\n\nconst placedAt = <R extends string>(mapping: ColumnMapping<R>, role: R, width?: number): number | null => {\n const column = mapping[role];\n if (typeof column !== \"number\") return null;\n return width === undefined || column < width ? column : null;\n};\n\n/** The role on this column, or `null` for an ignored one. */\nexport function roleOfColumn<R extends string>(\n roles: readonly ColumnRole<R>[],\n mapping: ColumnMapping<R>,\n column: number,\n): R | null {\n return roles.find((role) => mapping[role.value] === column)?.value ?? null;\n}\n\n/**\n * Put `role` on `column` — or, with `null`, take the column's role off it.\n *\n * Whatever this column played before stops, and the role moves here from any other\n * column, in one new mapping (keksdose's `assignColumn`: \"both halves are patches to\n * the same object\"). Other fields of the mapping are kept as they are.\n */\nexport function assignColumnRole<R extends string, M extends ColumnMapping<R>>(\n roles: readonly ColumnRole<R>[],\n mapping: M,\n column: number,\n role: R | null,\n): M {\n const next = { ...mapping } as Record<string, unknown>;\n for (const { value } of roles) {\n if (mapping[value] === column) next[value] = null;\n }\n if (role !== null) next[role] = column;\n return next as M;\n}\n\n/**\n * The gaps: each required role with no column, and each required group none of whose\n * roles has one. In the order of `roles`. A column index past `width` is no column.\n */\nexport function missingRoles<R extends string>(\n roles: readonly ColumnRole<R>[],\n mapping: ColumnMapping<R>,\n width?: number,\n): R[][] {\n const gaps: R[][] = [];\n const groups = new Set<string>();\n for (const role of roles) {\n if (role.required === true) {\n if (placedAt(mapping, role.value, width) === null) gaps.push([role.value]);\n } else if (typeof role.required === \"string\" && !groups.has(role.required)) {\n groups.add(role.required);\n const members = roles.filter((other) => other.required === role.required);\n if (members.every((member) => placedAt(mapping, member.value, width) === null)) {\n gaps.push(members.map((member) => member.value));\n }\n }\n }\n return gaps;\n}\n\nconst normalised = (text: string) => text.trim().toLowerCase();\n\n/**\n * A first mapping for a table nobody has mapped yet.\n *\n * A column whose header IS a role's label or key gets that role. The required roles\n * left over then take the free columns in order — Kurvenschmiede's \"time, setpoint,\n * actual are the first three columns\", which is how a recorder writes them. Optional\n * roles are not guessed by position: in a bank\n * export of twelve columns, \"the fourth role is the fourth column\" is a wrong answer\n * presented as a suggestion, and an \"ignore\" is the honest one.\n */\nexport function guessMapping<R extends string>(\n roles: readonly ColumnRole<R>[],\n header: readonly string[] | null,\n width: number,\n): ColumnMapping<R> {\n const mapping: ColumnMapping<R> = {};\n const taken = new Set<number>();\n if (header) {\n for (const role of roles) {\n const names = [normalised(role.label), normalised(role.value)];\n const column = header.findIndex((name, index) => !taken.has(index) && names.includes(normalised(name)));\n if (column >= 0) {\n mapping[role.value] = column;\n taken.add(column);\n }\n }\n }\n const free = Array.from({ length: width }, (_, index) => index).filter((index) => !taken.has(index));\n for (const role of roles) {\n if (role.required !== true || typeof mapping[role.value] === \"number\") continue;\n const column = free.shift();\n if (column === undefined) break;\n mapping[role.value] = column;\n }\n return mapping;\n}\n\n/**\n * The table read through the mapping: the rows every `numeric` role can read, the\n * others moved to `unread` (in line order, with the parse's own), what is missing,\n * and whether the table can be used. Column indexes past the table's width count as\n * unplaced.\n */\nexport function readMappedTable<R extends string>(\n table: TextTable,\n roles: readonly ColumnRole<R>[],\n mapping: ColumnMapping<R>,\n): ColumnMapperResult<R> {\n const numeric = roles\n .filter((role) => role.numeric)\n .map((role) => placedAt(mapping, role.value, table.width))\n .filter((column): column is number => column !== null);\n const rows: string[][] = [];\n const lines: TableLine[] = [];\n const refused: TableLine[] = [];\n table.rows.forEach((row, index) => {\n if (numeric.every((column) => Number.isFinite(tableNumber(row[column] ?? \"\", table.decimalComma)))) {\n rows.push(row);\n lines.push(table.lines[index]);\n } else {\n refused.push(table.lines[index]);\n }\n });\n const unread = refused.length ? [...table.unread, ...refused].sort((a, b) => a.line - b.line) : table.unread;\n const missing = missingRoles(roles, mapping, table.width);\n return {\n ...table,\n rows,\n lines,\n unread,\n mapping,\n missing,\n complete: missing.length === 0 && rows.length > 0,\n };\n}\n\n/**\n * A dropped or chosen file's text — UTF-8 when it is UTF-8, else Windows-1252.\n *\n * A German bank or bench export is very often written in Windows-1252, and reading it\n * as UTF-8 turns every \"ä\" in a column name into \"�\" — no error, just a header nobody\n * recognises. So the bytes are tried as strict UTF-8 first and read as Windows-1252\n * when that fails (keksdose's server sniffs the encoding for the same reason; a file\n * read in the browser had nothing doing it). Falls back to `FileReader` where a `File`\n * has no `arrayBuffer` (Kurvenschmiede's `readText`).\n */\nexport async function readTextFile(file: Blob): Promise<string> {\n const bytes = await bytesOf(file);\n try {\n return new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes);\n } catch {\n return new TextDecoder(\"windows-1252\").decode(bytes);\n }\n}\n\nfunction bytesOf(file: Blob): Promise<ArrayBuffer> {\n if (typeof file.arrayBuffer === \"function\") return file.arrayBuffer();\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () => resolve(reader.result as ArrayBuffer);\n reader.onerror = () => reject(reader.error ?? new Error(\"read failed\"));\n reader.readAsArrayBuffer(file);\n });\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Countries as ISO 3166-1 alpha-2 codes, named by the runtime — for {@link CountrySelect}
|
|
3
|
+
* and for an app that shows the code it stored ("CH") as a name somewhere else (a
|
|
4
|
+
* table cell, an address line).
|
|
5
|
+
*
|
|
6
|
+
* The kit ships CODES, not names. Every runtime the kit supports has
|
|
7
|
+
* `Intl.DisplayNames({ type: "region" })`, which names all of these in every locale
|
|
8
|
+
* the browser knows — so a table of 249 names per language would be a large file
|
|
9
|
+
* that is out of date the day a country is renamed (Türkiye, Czechia, Eswatini) and
|
|
10
|
+
* still covers fewer languages than the browser does. What is left to ship is the
|
|
11
|
+
* list of which codes ARE countries, and that is one string.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Every officially assigned ISO 3166-1 alpha-2 code — the 249 countries, territories
|
|
15
|
+
* and areas of the standard, upper-case, in code order.
|
|
16
|
+
*
|
|
17
|
+
* User-assigned codes are deliberately not in it: `XK` (Kosovo) is a widespread
|
|
18
|
+
* convention, not ISO, and whether to offer it is the app's decision. An app that
|
|
19
|
+
* wants it passes its own list to `CountrySelect`'s `countries` — the runtime names
|
|
20
|
+
* `XK` as well.
|
|
21
|
+
*/
|
|
22
|
+
declare const COUNTRY_CODES: readonly string[];
|
|
23
|
+
/** `code` upper-cased when it has the shape of an alpha-2 code, else `undefined`. Does
|
|
24
|
+
* not check that ISO assigned it — see {@link COUNTRY_CODES} for why `XK` must pass. */
|
|
25
|
+
declare function normalizeCountryCode(code: string | null | undefined): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* The name of the country `code` stands for, in `locale` — `countryName("CH", "de-CH")`
|
|
28
|
+
* is "Schweiz". Falls back to the upper-cased code itself when the runtime has no name
|
|
29
|
+
* for it, rejects the locale, or has no `Intl.DisplayNames`: a code is still the right
|
|
30
|
+
* answer, where an empty cell would not be.
|
|
31
|
+
*
|
|
32
|
+
* `locale` defaults to English rather than to the runtime's language, the rule the
|
|
33
|
+
* kit's currency names follow (`currencyName`): an app that never set a locale reads
|
|
34
|
+
* the kit's English everywhere else, and a country list in the browser's language
|
|
35
|
+
* beside English labels — or in the test runner's — is two languages on one form.
|
|
36
|
+
*
|
|
37
|
+
* The code is upper-cased first. `DisplayNames` is case-sensitive about it in some
|
|
38
|
+
* runtimes (Node answers "ch" with "ch"), and the codes reach this from forms,
|
|
39
|
+
* URLs and databases in either case.
|
|
40
|
+
*/
|
|
41
|
+
declare function countryName(code: string, locale?: string): string;
|
|
42
|
+
|
|
43
|
+
export { COUNTRY_CODES, countryName, normalizeCountryCode };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const COUNTRY_CODES = Object.freeze(
|
|
3
|
+
"AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YE YT ZA ZM ZW".split(" ")
|
|
4
|
+
);
|
|
5
|
+
const ALPHA_2 = /^[A-Za-z]{2}$/;
|
|
6
|
+
function normalizeCountryCode(code) {
|
|
7
|
+
return code && ALPHA_2.test(code) ? code.toUpperCase() : void 0;
|
|
8
|
+
}
|
|
9
|
+
const namers = /* @__PURE__ */ new Map();
|
|
10
|
+
function namer(locale) {
|
|
11
|
+
let n = namers.get(locale);
|
|
12
|
+
if (n === void 0) {
|
|
13
|
+
try {
|
|
14
|
+
n = new Intl.DisplayNames([locale], { type: "region", fallback: "code" });
|
|
15
|
+
} catch {
|
|
16
|
+
n = null;
|
|
17
|
+
}
|
|
18
|
+
namers.set(locale, n);
|
|
19
|
+
}
|
|
20
|
+
return n;
|
|
21
|
+
}
|
|
22
|
+
function countryName(code, locale = "en") {
|
|
23
|
+
const upper = code.toUpperCase();
|
|
24
|
+
const n = namer(locale);
|
|
25
|
+
if (n) {
|
|
26
|
+
try {
|
|
27
|
+
const name = n.of(upper);
|
|
28
|
+
if (name) return name;
|
|
29
|
+
} catch {
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return upper;
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
COUNTRY_CODES,
|
|
36
|
+
countryName,
|
|
37
|
+
normalizeCountryCode
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=countries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/countries.ts"],"sourcesContent":["/**\n * Countries as ISO 3166-1 alpha-2 codes, named by the runtime — for {@link CountrySelect}\n * and for an app that shows the code it stored (\"CH\") as a name somewhere else (a\n * table cell, an address line).\n *\n * The kit ships CODES, not names. Every runtime the kit supports has\n * `Intl.DisplayNames({ type: \"region\" })`, which names all of these in every locale\n * the browser knows — so a table of 249 names per language would be a large file\n * that is out of date the day a country is renamed (Türkiye, Czechia, Eswatini) and\n * still covers fewer languages than the browser does. What is left to ship is the\n * list of which codes ARE countries, and that is one string.\n */\n\n/**\n * Every officially assigned ISO 3166-1 alpha-2 code — the 249 countries, territories\n * and areas of the standard, upper-case, in code order.\n *\n * User-assigned codes are deliberately not in it: `XK` (Kosovo) is a widespread\n * convention, not ISO, and whether to offer it is the app's decision. An app that\n * wants it passes its own list to `CountrySelect`'s `countries` — the runtime names\n * `XK` as well.\n */\nexport const COUNTRY_CODES: readonly string[] = Object.freeze(\n (\n \"AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ \" +\n \"BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM \" +\n \"DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS \" +\n \"GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN \" +\n \"KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ \" +\n \"MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM \" +\n \"PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV \" +\n \"SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI \" +\n \"VN VU WF WS YE YT ZA ZM ZW\"\n ).split(\" \"),\n);\n\n/** Two ASCII letters — the shape of an alpha-2 code, whatever the case. */\nconst ALPHA_2 = /^[A-Za-z]{2}$/;\n\n/** `code` upper-cased when it has the shape of an alpha-2 code, else `undefined`. Does\n * not check that ISO assigned it — see {@link COUNTRY_CODES} for why `XK` must pass. */\nexport function normalizeCountryCode(code: string | null | undefined): string | undefined {\n return code && ALPHA_2.test(code) ? code.toUpperCase() : undefined;\n}\n\n// One `DisplayNames` per locale, built on first use. `null` records a locale the\n// runtime refused (a malformed tag) or a runtime without the API, so neither is\n// retried for every row of a 249-row list.\nconst namers = new Map<string, Intl.DisplayNames | null>();\n\nfunction namer(locale: string): Intl.DisplayNames | null {\n let n = namers.get(locale);\n if (n === undefined) {\n try {\n n = new Intl.DisplayNames([locale], { type: \"region\", fallback: \"code\" });\n } catch {\n n = null;\n }\n namers.set(locale, n);\n }\n return n;\n}\n\n/**\n * The name of the country `code` stands for, in `locale` — `countryName(\"CH\", \"de-CH\")`\n * is \"Schweiz\". Falls back to the upper-cased code itself when the runtime has no name\n * for it, rejects the locale, or has no `Intl.DisplayNames`: a code is still the right\n * answer, where an empty cell would not be.\n *\n * `locale` defaults to English rather than to the runtime's language, the rule the\n * kit's currency names follow (`currencyName`): an app that never set a locale reads\n * the kit's English everywhere else, and a country list in the browser's language\n * beside English labels — or in the test runner's — is two languages on one form.\n *\n * The code is upper-cased first. `DisplayNames` is case-sensitive about it in some\n * runtimes (Node answers \"ch\" with \"ch\"), and the codes reach this from forms,\n * URLs and databases in either case.\n */\nexport function countryName(code: string, locale: string = \"en\"): string {\n const upper = code.toUpperCase();\n const n = namer(locale);\n if (n) {\n try {\n const name = n.of(upper);\n if (name) return name;\n } catch {\n // Not a well-formed region subtag (\"C1\", \"\") — the code is all there is.\n }\n }\n return upper;\n}\n"],"mappings":";AAsBO,MAAM,gBAAmC,OAAO;AAAA,EAEnD,6uBASA,MAAM,GAAG;AACb;AAGA,MAAM,UAAU;AAIT,SAAS,qBAAqB,MAAqD;AACxF,SAAO,QAAQ,QAAQ,KAAK,IAAI,IAAI,KAAK,YAAY,IAAI;AAC3D;AAKA,MAAM,SAAS,oBAAI,IAAsC;AAEzD,SAAS,MAAM,QAA0C;AACvD,MAAI,IAAI,OAAO,IAAI,MAAM;AACzB,MAAI,MAAM,QAAW;AACnB,QAAI;AACF,UAAI,IAAI,KAAK,aAAa,CAAC,MAAM,GAAG,EAAE,MAAM,UAAU,UAAU,OAAO,CAAC;AAAA,IAC1E,QAAQ;AACN,UAAI;AAAA,IACN;AACA,WAAO,IAAI,QAAQ,CAAC;AAAA,EACtB;AACA,SAAO;AACT;AAiBO,SAAS,YAAY,MAAc,SAAiB,MAAc;AACvE,QAAM,QAAQ,KAAK,YAAY;AAC/B,QAAM,IAAI,MAAM,MAAM;AACtB,MAAI,GAAG;AACL,QAAI;AACF,YAAM,OAAO,EAAE,GAAG,KAAK;AACvB,UAAI,KAAM,QAAO;AAAA,IACnB,QAAQ;AAAA,IAER;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|