@eifi1/ui-kit 0.5.0 → 0.6.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 +50 -1
- package/dist/components/amount-input.d.ts +7 -0
- package/dist/components/autocomplete.d.ts +101 -0
- package/dist/components/autocomplete.js +260 -0
- package/dist/components/autocomplete.js.map +1 -0
- package/dist/components/calculator.d.ts +7 -0
- package/dist/components/chip.d.ts +22 -7
- package/dist/components/chip.js +14 -1
- package/dist/components/chip.js.map +1 -1
- package/dist/components/choice-card.d.ts +100 -0
- package/dist/components/choice-card.js +170 -0
- package/dist/components/choice-card.js.map +1 -0
- package/dist/components/combobox-core.d.ts +76 -6
- package/dist/components/combobox-core.js +119 -49
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox.d.ts +12 -2
- package/dist/components/combobox.js +42 -17
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/currency-select.js +10 -2
- package/dist/components/currency-select.js.map +1 -1
- package/dist/components/danger-confirm.d.ts +91 -0
- package/dist/components/danger-confirm.js +181 -0
- package/dist/components/danger-confirm.js.map +1 -0
- package/dist/components/date-picker.js +19 -7
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/dialog-frame.d.ts +84 -0
- package/dist/components/dialog-frame.js +86 -0
- package/dist/components/dialog-frame.js.map +1 -0
- package/dist/components/disclosure.d.ts +108 -0
- package/dist/components/disclosure.js +127 -0
- package/dist/components/disclosure.js.map +1 -0
- package/dist/components/entity-combobox.d.ts +17 -3
- package/dist/components/entity-combobox.js +25 -5
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/file-button.d.ts +161 -0
- package/dist/components/file-button.js +225 -0
- package/dist/components/file-button.js.map +1 -0
- package/dist/components/file-dropzone.d.ts +72 -23
- package/dist/components/file-dropzone.js +219 -94
- package/dist/components/file-dropzone.js.map +1 -1
- package/dist/components/icon-picker.d.ts +72 -0
- package/dist/components/icon-picker.js +104 -0
- package/dist/components/icon-picker.js.map +1 -0
- package/dist/components/mini-calendar.d.ts +3 -0
- package/dist/components/mini-calendar.js +4 -3
- package/dist/components/mini-calendar.js.map +1 -1
- package/dist/components/modal.d.ts +8 -1
- package/dist/components/modal.js +4 -2
- package/dist/components/modal.js.map +1 -1
- package/dist/components/month-picker.js +16 -5
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-entity-combobox.d.ts +16 -3
- package/dist/components/multi-entity-combobox.js +25 -5
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/number-field.d.ts +41 -1
- package/dist/components/number-field.js +42 -10
- package/dist/components/number-field.js.map +1 -1
- package/dist/components/number-input.d.ts +35 -2
- package/dist/components/number-input.js +35 -4
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/numpad-sheet.d.ts +7 -0
- package/dist/components/popover.js +4 -1
- package/dist/components/popover.js.map +1 -1
- package/dist/components/search-field.d.ts +16 -0
- package/dist/components/search-field.js +29 -7
- package/dist/components/search-field.js.map +1 -1
- package/dist/components/signature-pad.d.ts +43 -1
- package/dist/components/signature-pad.js +74 -2
- package/dist/components/signature-pad.js.map +1 -1
- package/dist/components/swatch-picker.d.ts +69 -0
- package/dist/components/swatch-picker.js +75 -0
- package/dist/components/swatch-picker.js.map +1 -0
- package/dist/components/tile-radio.d.ts +50 -0
- package/dist/components/tile-radio.js +140 -0
- package/dist/components/tile-radio.js.map +1 -0
- package/dist/components/toggle-group.d.ts +27 -5
- package/dist/components/toggle-group.js +22 -15
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/trigger-aria.d.ts +18 -0
- package/dist/components/trigger-aria.js +25 -0
- package/dist/components/trigger-aria.js.map +1 -0
- package/dist/components/ui.d.ts +164 -18
- package/dist/components/ui.js +207 -34
- package/dist/components/ui.js.map +1 -1
- package/dist/i18n/defaults.d.ts +7 -0
- package/dist/i18n/defaults.js +13 -2
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +38 -5
- package/dist/i18n/kit-labels.js +12 -4
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/index.d.ts +16 -7
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/table-text.d.ts +127 -0
- package/dist/lib/table-text.js +82 -0
- package/dist/lib/table-text.js.map +1 -0
- package/dist/rhf/form.d.ts +79 -0
- package/dist/rhf/form.js +143 -0
- package/dist/rhf/form.js.map +1 -0
- package/dist/rhf.d.ts +4 -0
- package/dist/rhf.js +3 -0
- package/dist/rhf.js.map +1 -0
- package/dist/shell/app-shell.js +3 -1
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/table-text.d.ts +1 -0
- package/dist/table-text.js +3 -0
- package/dist/table-text.js.map +1 -0
- package/package.json +14 -1
- package/src/components/autocomplete.tsx +425 -0
- package/src/components/chip.tsx +43 -7
- package/src/components/choice-card.tsx +305 -0
- package/src/components/combobox-core.tsx +228 -58
- package/src/components/combobox.tsx +58 -21
- package/src/components/currency-select.tsx +16 -2
- package/src/components/danger-confirm.tsx +286 -0
- package/src/components/date-picker.tsx +31 -6
- package/src/components/dialog-frame.tsx +179 -0
- package/src/components/disclosure.tsx +259 -0
- package/src/components/entity-combobox.tsx +41 -6
- package/src/components/file-button.tsx +431 -0
- package/src/components/file-dropzone.tsx +323 -117
- package/src/components/icon-picker.tsx +181 -0
- package/src/components/mini-calendar.tsx +7 -3
- package/src/components/modal.tsx +10 -2
- package/src/components/month-picker.tsx +22 -4
- package/src/components/multi-entity-combobox.tsx +40 -6
- package/src/components/number-field.tsx +86 -10
- package/src/components/number-input.tsx +79 -2
- package/src/components/popover.tsx +4 -1
- package/src/components/search-field.tsx +49 -6
- package/src/components/signature-pad.tsx +112 -0
- package/src/components/swatch-picker.tsx +141 -0
- package/src/components/tile-radio.tsx +228 -0
- package/src/components/toggle-group.tsx +54 -18
- package/src/components/trigger-aria.ts +42 -0
- package/src/components/ui.tsx +427 -40
- package/src/i18n/defaults.ts +12 -1
- package/src/i18n/kit-labels.tsx +45 -5
- package/src/index.ts +19 -0
- package/src/lib/table-text.ts +265 -0
- package/src/rhf/form.tsx +300 -0
- package/src/rhf.ts +9 -0
- package/src/shell/app-shell.tsx +3 -1
- package/src/table-text.ts +8 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { DataTableLabels } from '../components/data-table-labels.js';
|
|
4
|
-
import { MiniCalendarLabels } from '../components/mini-calendar.js';
|
|
4
|
+
import { MiniCalendarLabels, WeekDay } from '../components/mini-calendar.js';
|
|
5
5
|
import { PopoverLabels } from '../components/popover.js';
|
|
6
6
|
import { ChipInputLabels } from '../components/chip.js';
|
|
7
7
|
import { FieldSyncLabels } from '../components/field-sync.js';
|
|
8
|
-
import { PasswordRevealLabels } from '../components/ui.js';
|
|
8
|
+
import { PasswordRevealLabels, TabsLabels } from '../components/ui.js';
|
|
9
9
|
import { WizardLabels } from '../wizard/types.js';
|
|
10
10
|
import { TourLabels } from '../tour/tour.js';
|
|
11
11
|
import { CommandPaletteLabels } from '../search/command-palette.js';
|
|
@@ -16,7 +16,14 @@ import { SparklineLabels } from '../components/sparkline.js';
|
|
|
16
16
|
import { StatTileLabels } from '../components/stat-tile.js';
|
|
17
17
|
import { SignaturePadLabels } from '../components/signature-pad.js';
|
|
18
18
|
import { PasswordStrengthLabels } from '../components/password-strength.js';
|
|
19
|
+
import { DangerConfirmLabels } from '../components/danger-confirm.js';
|
|
20
|
+
import { SwatchPickerLabels } from '../components/swatch-picker.js';
|
|
21
|
+
import { IconPickerLabels } from '../components/icon-picker.js';
|
|
22
|
+
import { DialogFrameLabels } from '../components/dialog-frame.js';
|
|
23
|
+
import { FilePickerLabels } from '../components/file-button.js';
|
|
19
24
|
import 'lucide-react';
|
|
25
|
+
import '../components/tile-radio.js';
|
|
26
|
+
import '../components/modal.js';
|
|
20
27
|
|
|
21
28
|
/**
|
|
22
29
|
* EVERY string the kit renders, as one typed tree — and an optional provider that
|
|
@@ -77,7 +84,7 @@ interface DatePickerLabels {
|
|
|
77
84
|
today: string;
|
|
78
85
|
}
|
|
79
86
|
/** The whole combobox family: `Combobox`, `EntityCombobox`,
|
|
80
|
-
* `MultiEntityCombobox`, `InlineEntityCombobox`. */
|
|
87
|
+
* `MultiEntityCombobox`, `InlineEntityCombobox`, `Autocomplete`. */
|
|
81
88
|
interface ComboboxLabels {
|
|
82
89
|
search: string;
|
|
83
90
|
noResults: string;
|
|
@@ -87,6 +94,12 @@ interface ComboboxLabels {
|
|
|
87
94
|
create: (query: string) => string;
|
|
88
95
|
/** Trigger summary once more than one value is picked. */
|
|
89
96
|
selectedCount: (count: number) => string;
|
|
97
|
+
/** An async lookup (`loadOptions`) failed. */
|
|
98
|
+
loadError: string;
|
|
99
|
+
/** Announced (live region) when the list settles on `count` > 0 rows. */
|
|
100
|
+
resultCount: (count: number) => string;
|
|
101
|
+
/** The query is shorter than the `minChars` a lookup needs. */
|
|
102
|
+
minChars: (count: number) => string;
|
|
90
103
|
}
|
|
91
104
|
interface MultiSelectLabels {
|
|
92
105
|
search: string;
|
|
@@ -164,6 +177,7 @@ interface UiKitLabels {
|
|
|
164
177
|
chipInput: ChipInputLabels;
|
|
165
178
|
fieldSync: FieldSyncLabels;
|
|
166
179
|
passwordReveal: PasswordRevealLabels;
|
|
180
|
+
tabs: TabsLabels;
|
|
167
181
|
appShell: AppShellLabels;
|
|
168
182
|
pageContents: PageContentsLabels;
|
|
169
183
|
topBar: TopBarLabels;
|
|
@@ -178,6 +192,11 @@ interface UiKitLabels {
|
|
|
178
192
|
statTile: StatTileLabels;
|
|
179
193
|
signaturePad: SignaturePadLabels;
|
|
180
194
|
passwordStrength: PasswordStrengthLabels;
|
|
195
|
+
dangerConfirm: DangerConfirmLabels;
|
|
196
|
+
swatchPicker: SwatchPickerLabels;
|
|
197
|
+
iconPicker: IconPickerLabels;
|
|
198
|
+
dialogFrame: DialogFrameLabels;
|
|
199
|
+
filePicker: FilePickerLabels;
|
|
181
200
|
}
|
|
182
201
|
/** Any subset of the tree, one level deep — each namespace may be partial, and a
|
|
183
202
|
* namespace that holds a record (`dataTable.presets`) is merged key by key. */
|
|
@@ -209,6 +228,16 @@ interface UiKitProviderProps {
|
|
|
209
228
|
* its own. Without a provider, and without a prop, those use the runtime default.
|
|
210
229
|
*/
|
|
211
230
|
locale?: string;
|
|
231
|
+
/**
|
|
232
|
+
* The first day of the week (0 = Sunday, 1 = Monday …) for every calendar below —
|
|
233
|
+
* `MiniCalendar` and the pickers built on it — that is not handed a `weekStartsOn`
|
|
234
|
+
* of its own. Without it the week start follows `locale`'s week info.
|
|
235
|
+
*
|
|
236
|
+
* Separate from `locale` because the two are separate decisions: a German-built
|
|
237
|
+
* app running in English (`locale="en"`) would otherwise start its weeks on Sunday,
|
|
238
|
+
* and switching it to `en-GB` to get Monday changes every date and number format.
|
|
239
|
+
*/
|
|
240
|
+
weekStartsOn?: WeekDay;
|
|
212
241
|
children: ReactNode;
|
|
213
242
|
}
|
|
214
243
|
/**
|
|
@@ -219,7 +248,7 @@ interface UiKitProviderProps {
|
|
|
219
248
|
* it names, so a page can re-label one table's `dataTable.table` without restating
|
|
220
249
|
* the language.
|
|
221
250
|
*/
|
|
222
|
-
declare function UiKitProvider({ labels, locale, children }: UiKitProviderProps): react.JSX.Element;
|
|
251
|
+
declare function UiKitProvider({ labels, locale, weekStartsOn, children }: UiKitProviderProps): react.JSX.Element;
|
|
223
252
|
/** What the nearest provider says about one namespace — `undefined` outside one.
|
|
224
253
|
* For a component whose own resolver does more than a merge (the data table
|
|
225
254
|
* derives `columnsCount` from `columns`): feed `{ ...overrides, ...props }` to it. */
|
|
@@ -232,6 +261,10 @@ declare function useKitLabels<K extends keyof UiKitLabels>(ns: K, defaults: UiKi
|
|
|
232
261
|
/** The component's own `locale` prop, else the provider's, else `undefined` (which
|
|
233
262
|
* every `Intl` API reads as "the runtime's default"). */
|
|
234
263
|
declare function useKitLocale(prop?: string): string | undefined;
|
|
264
|
+
/** The week start the nearest `<UiKitProvider weekStartsOn>` pins, else `undefined`
|
|
265
|
+
* (the caller then asks the locale). A component's own prop goes first:
|
|
266
|
+
* `prop ?? useKitWeekStart()`. */
|
|
267
|
+
declare function useKitWeekStart(): WeekDay | undefined;
|
|
235
268
|
/** {@link DEFAULT_FILE_LABELS}, but formatting in the provider's locale. */
|
|
236
269
|
declare function useKitFileLabels(prop?: Partial<FileLabels>): FileLabels;
|
|
237
270
|
/**
|
|
@@ -247,4 +280,4 @@ declare function useKitFileLabels(prop?: Partial<FileLabels>): FileLabels;
|
|
|
247
280
|
*/
|
|
248
281
|
declare function missingKitLabels(labels: UiKitLabelOverrides | undefined, reference: UiKitLabels): string[];
|
|
249
282
|
|
|
250
|
-
export { type AppShellLabels, type CalculatorLabels, type ComboboxLabels, type CommonLabels, type CurrencyLabels, DEFAULT_APP_SHELL_LABELS, DEFAULT_CALCULATOR_LABELS, DEFAULT_COMBOBOX_LABELS, DEFAULT_COMMON_LABELS, DEFAULT_CURRENCY_LABELS, DEFAULT_DATE_PICKER_LABELS, DEFAULT_FILE_LABELS, DEFAULT_MULTI_SELECT_LABELS, DEFAULT_PICKER_SHEET_LABELS, DEFAULT_SWIPEABLE_ROW_LABELS, DEFAULT_TOP_BAR_LABELS, type DatePickerLabels, type FileLabels, type MultiSelectLabels, type PickerSheetLabels, type SwipeableRowLabels, type TopBarLabels, type UiKitLabelOverrides, type UiKitLabels, UiKitProvider, type UiKitProviderProps, formatFileSize, missingKitLabels, useKitFileLabels, useKitLabelOverrides, useKitLabels, useKitLocale };
|
|
283
|
+
export { type AppShellLabels, type CalculatorLabels, type ComboboxLabels, type CommonLabels, type CurrencyLabels, DEFAULT_APP_SHELL_LABELS, DEFAULT_CALCULATOR_LABELS, DEFAULT_COMBOBOX_LABELS, DEFAULT_COMMON_LABELS, DEFAULT_CURRENCY_LABELS, DEFAULT_DATE_PICKER_LABELS, DEFAULT_FILE_LABELS, DEFAULT_MULTI_SELECT_LABELS, DEFAULT_PICKER_SHEET_LABELS, DEFAULT_SWIPEABLE_ROW_LABELS, DEFAULT_TOP_BAR_LABELS, type DatePickerLabels, type FileLabels, type MultiSelectLabels, type PickerSheetLabels, type SwipeableRowLabels, type TopBarLabels, type UiKitLabelOverrides, type UiKitLabels, UiKitProvider, type UiKitProviderProps, formatFileSize, missingKitLabels, useKitFileLabels, useKitLabelOverrides, useKitLabels, useKitLocale, useKitWeekStart };
|
package/dist/i18n/kit-labels.js
CHANGED
|
@@ -29,7 +29,10 @@ const DEFAULT_COMBOBOX_LABELS = {
|
|
|
29
29
|
clear: "Clear",
|
|
30
30
|
loading: "Loading\u2026",
|
|
31
31
|
create: (query) => `Create \u201C${query}\u201D`,
|
|
32
|
-
selectedCount: (count) => `${count} selected
|
|
32
|
+
selectedCount: (count) => `${count} selected`,
|
|
33
|
+
loadError: "Couldn\u2019t load results",
|
|
34
|
+
resultCount: (count) => count === 1 ? "1 result" : `${count} results`,
|
|
35
|
+
minChars: (count) => count === 1 ? "Type at least 1 character" : `Type at least ${count} characters`
|
|
33
36
|
};
|
|
34
37
|
const DEFAULT_MULTI_SELECT_LABELS = {
|
|
35
38
|
search: "Search",
|
|
@@ -89,14 +92,15 @@ function formatFileSize(bytes, locale) {
|
|
|
89
92
|
}).format(value);
|
|
90
93
|
}
|
|
91
94
|
const KitI18nContext = createContext({});
|
|
92
|
-
function UiKitProvider({ labels, locale, children }) {
|
|
95
|
+
function UiKitProvider({ labels, locale, weekStartsOn, children }) {
|
|
93
96
|
const outer = useContext(KitI18nContext);
|
|
94
97
|
const value = useMemo(
|
|
95
98
|
() => ({
|
|
96
99
|
locale: locale ?? outer.locale,
|
|
100
|
+
weekStartsOn: weekStartsOn ?? outer.weekStartsOn,
|
|
97
101
|
labels: mergeOverrides(outer.labels, labels)
|
|
98
102
|
}),
|
|
99
|
-
[outer, labels, locale]
|
|
103
|
+
[outer, labels, locale, weekStartsOn]
|
|
100
104
|
);
|
|
101
105
|
return /* @__PURE__ */ jsx(KitI18nContext.Provider, { value, children });
|
|
102
106
|
}
|
|
@@ -136,6 +140,9 @@ function useKitLocale(prop) {
|
|
|
136
140
|
const fromProvider = useContext(KitI18nContext).locale;
|
|
137
141
|
return prop ?? fromProvider;
|
|
138
142
|
}
|
|
143
|
+
function useKitWeekStart() {
|
|
144
|
+
return useContext(KitI18nContext).weekStartsOn;
|
|
145
|
+
}
|
|
139
146
|
function useKitFileLabels(prop) {
|
|
140
147
|
const locale = useKitLocale();
|
|
141
148
|
const defaults = useMemo(
|
|
@@ -179,6 +186,7 @@ export {
|
|
|
179
186
|
useKitFileLabels,
|
|
180
187
|
useKitLabelOverrides,
|
|
181
188
|
useKitLabels,
|
|
182
|
-
useKitLocale
|
|
189
|
+
useKitLocale,
|
|
190
|
+
useKitWeekStart
|
|
183
191
|
};
|
|
184
192
|
//# sourceMappingURL=kit-labels.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/i18n/kit-labels.tsx"],"sourcesContent":["import { createContext, useContext, useMemo } from \"react\";\nimport type { ReactNode } from \"react\";\nimport type { DataTableLabels } from \"../components/data-table-labels\";\nimport type { MiniCalendarLabels } from \"../components/mini-calendar\";\nimport type { PopoverLabels } from \"../components/popover\";\nimport type { ChipInputLabels } from \"../components/chip\";\nimport type { FieldSyncLabels } from \"../components/field-sync\";\nimport type { PasswordRevealLabels } from \"../components/ui\";\nimport type { WizardLabels } from \"../wizard/types\";\nimport type { TourLabels } from \"../tour/tour\";\nimport type { CommandPaletteLabels } from \"../search/command-palette\";\nimport type { MonthPickerLabels } from \"../components/month-picker\";\nimport type { PageContentsLabels } from \"../components/page-contents\";\nimport type { SeriesChartLabels } from \"../components/series-chart-labels\";\nimport type { SparklineLabels } from \"../components/sparkline\";\nimport type { StatTileLabels } from \"../components/stat-tile\";\nimport type { SignaturePadLabels } from \"../components/signature-pad\";\nimport type { PasswordStrengthLabels } from \"../components/password-strength\";\n\n/**\n * EVERY string the kit renders, as one typed tree — and an optional provider that\n * hands it to every component at once.\n *\n * WHY THIS EXISTS. The kit ships no catalogue and resolves no strings, and that stays\n * true: the app supplies every word. What was wrong was HOW it had to supply them —\n * one `labels` prop per component instance, under a different prop name per\n * component (`labels`, `calendarLabels`, `passwordLabels`, `clearLabel`,\n * `searchPlaceholder`, `ariaLabel` …). A translated app therefore rendered English\n * wherever one call site forgot one prop, and nothing told it so: a German showcase\n * still said \"Rows per page\", \"Collapse sidebar\" and \"Popover\" in seven languages.\n *\n * Now there is one key per string, addressed by a dot path (`dataTable.pageSize`,\n * `datePicker.today`), and three sources in a fixed order of precedence:\n *\n * the component's own prop > <UiKitProvider labels> > English default\n *\n * A consumer writes its translation ONCE, as a `UiKitLabels` (or a partial of it),\n * mounts `<UiKitProvider labels={…} locale={…}>` at the root, and every kit component\n * below speaks that language — including the ones nested inside other kit components\n * (the calendar inside the data table's date filter, the popover inside the date\n * picker), which no prop at the outer call site could reach before.\n *\n * Messages that carry a value are FUNCTIONS of that value, never a template to fill:\n * a number glued into an English sentence is untranslatable, because the grammar\n * around it moves with it in most languages.\n */\n\n/* ── Namespaces that had no labels type of their own ─────────────────────── */\n\n/** The words several components share. A component's own namespace wins over these\n * where both exist; these are what a new component reaches for first. */\nexport interface CommonLabels {\n close: string;\n clear: string;\n search: string;\n done: string;\n cancel: string;\n save: string;\n back: string;\n next: string;\n remove: string;\n loading: string;\n noResults: string;\n /** \"Name: value\" — how a field's accessible name is composed with its value.\n * A colon-and-space is not universal punctuation (French puts a space before\n * the colon, Chinese uses a full-width one). */\n fieldValue: (field: string, value: string) => string;\n}\n\n/** `DatePicker` / `DateRangePicker` chrome. The calendar inside has its own\n * namespace, `miniCalendar`. */\nexport interface DatePickerLabels {\n /** Accessible name of the popover panel the calendar opens in. */\n panel: string;\n /** The same, for `DateRangePicker`'s panel. */\n rangePanel: string;\n clear: string;\n previousDay: string;\n nextDay: string;\n today: string;\n}\n\n/** The whole combobox family: `Combobox`, `EntityCombobox`,\n * `MultiEntityCombobox`, `InlineEntityCombobox`. */\nexport interface ComboboxLabels {\n search: string;\n noResults: string;\n clear: string;\n loading: string;\n /** The \"add this\" row when free entry is allowed. */\n create: (query: string) => string;\n /** Trigger summary once more than one value is picked. */\n selectedCount: (count: number) => string;\n}\n\nexport interface MultiSelectLabels {\n search: string;\n selectAll: string;\n clear: string;\n /** Trigger text when nothing is picked, which a multi-select reads as \"all\". */\n all: string;\n /** Trigger summary once some (but not all) values are picked. The English\n * default is the bare count, which is what the trigger has always shown. */\n selectedCount: (count: number) => string;\n}\n\n/** `CalculatorButton` (desktop popover keypad) and `NumberPadSheet` (phone sheet). */\nexport interface CalculatorLabels {\n /** The button that opens the calculator. */\n open: string;\n /** The popover / sheet itself. */\n panel: string;\n calculation: string;\n backspace: string;\n clear: string;\n equals: string;\n /** The primary key of the phone pad — visible text, not an aria-label. */\n done: string;\n /** Names of the operator keys and the decimal key. Their glyphs are not names a\n * screen reader agrees on — \"÷\" is read as \"division sign\", \"divided by\" or\n * nothing at all depending on the reader — so each says what it does. */\n plus: string;\n minus: string;\n times: string;\n divide: string;\n decimal: string;\n}\n\n/** `CurrencySelect` and the currency half of `AmountInput`. */\nexport interface CurrencyLabels {\n currency: string;\n search: string;\n}\n\nexport interface AppShellLabels {\n collapse: string;\n expand: string;\n /** Accessible name of an inline group's disclosure button (`subNav=\"inline\"`). */\n toggleGroup: (groupLabel: string) => string;\n}\n\nexport interface TopBarLabels {\n theme: string;\n palette: string;\n language: string;\n switchRole: string;\n /** The role switcher's tooltip, given the active role's name. */\n role: (value: string) => string;\n}\n\nexport interface PickerSheetLabels {\n close: string;\n}\n\nexport interface SwipeableRowLabels {\n actions: string;\n}\n\nexport interface FileLabels {\n /** A file size for display, given its size in BYTES. The default uses\n * `Intl.NumberFormat`'s unit formatting in the provider's locale. */\n size: (bytes: number) => string;\n}\n\n/** The complete tree. `UiKitProvider` takes any partial of it. */\nexport interface UiKitLabels {\n common: CommonLabels;\n dataTable: DataTableLabels;\n miniCalendar: MiniCalendarLabels;\n datePicker: DatePickerLabels;\n monthPicker: MonthPickerLabels;\n popover: PopoverLabels;\n combobox: ComboboxLabels;\n multiSelect: MultiSelectLabels;\n calculator: CalculatorLabels;\n currency: CurrencyLabels;\n chipInput: ChipInputLabels;\n fieldSync: FieldSyncLabels;\n passwordReveal: PasswordRevealLabels;\n appShell: AppShellLabels;\n pageContents: PageContentsLabels;\n topBar: TopBarLabels;\n pickerSheet: PickerSheetLabels;\n swipeableRow: SwipeableRowLabels;\n file: FileLabels;\n wizard: WizardLabels;\n tour: TourLabels;\n commandPalette: CommandPaletteLabels;\n seriesChart: SeriesChartLabels;\n sparkline: SparklineLabels;\n statTile: StatTileLabels;\n signaturePad: SignaturePadLabels;\n passwordStrength: PasswordStrengthLabels;\n}\n\n/** Any subset of the tree, one level deep — each namespace may be partial, and a\n * namespace that holds a record (`dataTable.presets`) is merged key by key. */\nexport type UiKitLabelOverrides = { [K in keyof UiKitLabels]?: Partial<UiKitLabels[K]> };\n\n/* ── English defaults for the namespaces defined here ────────────────────── */\n\nexport const DEFAULT_COMMON_LABELS: CommonLabels = {\n close: \"Close\",\n clear: \"Clear\",\n search: \"Search\",\n done: \"Done\",\n cancel: \"Cancel\",\n save: \"Save\",\n back: \"Back\",\n next: \"Next\",\n remove: \"Remove\",\n loading: \"Loading…\",\n noResults: \"No results\",\n fieldValue: (field, value) => `${field}: ${value}`,\n};\n\nexport const DEFAULT_DATE_PICKER_LABELS: DatePickerLabels = {\n panel: \"Choose a date\",\n rangePanel: \"Choose a date range\",\n clear: \"Clear\",\n previousDay: \"Previous day\",\n nextDay: \"Next day\",\n today: \"Today\",\n};\n\nexport const DEFAULT_COMBOBOX_LABELS: ComboboxLabels = {\n search: \"Search\",\n noResults: \"No results\",\n clear: \"Clear\",\n loading: \"Loading…\",\n create: (query) => `Create “${query}”`,\n selectedCount: (count) => `${count} selected`,\n};\n\nexport const DEFAULT_MULTI_SELECT_LABELS: MultiSelectLabels = {\n search: \"Search\",\n selectAll: \"Select all\",\n clear: \"Clear\",\n all: \"All\",\n selectedCount: (count) => String(count),\n};\n\nexport const DEFAULT_CALCULATOR_LABELS: CalculatorLabels = {\n open: \"Open calculator\",\n panel: \"Calculator\",\n calculation: \"Calculation\",\n backspace: \"Backspace\",\n clear: \"Clear\",\n equals: \"Equals\",\n done: \"Done\",\n plus: \"Plus\",\n minus: \"Minus\",\n times: \"Times\",\n divide: \"Divide\",\n decimal: \"Decimal point\",\n};\n\nexport const DEFAULT_CURRENCY_LABELS: CurrencyLabels = {\n currency: \"Currency\",\n search: \"Search currency\",\n};\n\nexport const DEFAULT_APP_SHELL_LABELS: AppShellLabels = {\n collapse: \"Collapse sidebar\",\n expand: \"Expand sidebar\",\n toggleGroup: (groupLabel) => `${groupLabel}: pages`,\n};\n\nexport const DEFAULT_TOP_BAR_LABELS: TopBarLabels = {\n theme: \"Toggle theme\",\n palette: \"Appearance preset\",\n language: \"Language\",\n switchRole: \"Switch role\",\n role: (value) => `Role: ${value}`,\n};\n\nexport const DEFAULT_PICKER_SHEET_LABELS: PickerSheetLabels = { close: \"Close\" };\n\nexport const DEFAULT_SWIPEABLE_ROW_LABELS: SwipeableRowLabels = { actions: \"Row actions\" };\n\n/** Formats with the locale the provider was given (see {@link useKitFileLabels}).\n * This static default has no locale to hand and falls back to the runtime's. */\nexport const DEFAULT_FILE_LABELS: FileLabels = {\n size: (bytes) => formatFileSize(bytes),\n};\n\n/** \"12 kB\", \"3.4 MB\" — `Intl`'s unit formatting, so the digits, the decimal mark and\n * the unit's spelling all follow `locale`. */\nexport function formatFileSize(bytes: number, locale?: string): string {\n const units = [\"byte\", \"kilobyte\", \"megabyte\", \"gigabyte\"] as const;\n let value = bytes;\n let i = 0;\n while (value >= 1000 && i < units.length - 1) {\n value /= 1000;\n i += 1;\n }\n return new Intl.NumberFormat(locale, {\n style: \"unit\",\n unit: units[i],\n unitDisplay: i === 0 ? \"long\" : \"short\",\n maximumFractionDigits: value < 10 && i > 0 ? 1 : 0,\n }).format(value);\n}\n\n/* ── The provider ────────────────────────────────────────────────────────── */\n\ninterface KitI18n {\n labels?: UiKitLabelOverrides;\n locale?: string;\n}\n\nconst KitI18nContext = createContext<KitI18n>({});\n\nexport interface UiKitProviderProps {\n /** Any part of {@link UiKitLabels}. Missing keys fall back to English. */\n labels?: UiKitLabelOverrides;\n /**\n * BCP 47 tag used by every kit component that formats something — dates, numbers,\n * month and weekday names, file sizes — when it is not handed a `locale` prop of\n * its own. Without a provider, and without a prop, those use the runtime default.\n */\n locale?: string;\n children: ReactNode;\n}\n\n/**\n * Hand every kit component below this point its strings and its locale.\n *\n * Optional: a component outside any provider behaves exactly as it did before the\n * provider existed. Nesting works as a merge — an inner provider overrides only what\n * it names, so a page can re-label one table's `dataTable.table` without restating\n * the language.\n */\nexport function UiKitProvider({ labels, locale, children }: UiKitProviderProps) {\n const outer = useContext(KitI18nContext);\n const value = useMemo<KitI18n>(\n () => ({\n locale: locale ?? outer.locale,\n labels: mergeOverrides(outer.labels, labels),\n }),\n [outer, labels, locale],\n );\n return <KitI18nContext.Provider value={value}>{children}</KitI18nContext.Provider>;\n}\n\nfunction isRecord(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\n/** Two levels: namespaces, and inside a namespace a record-valued key (presets). */\nfunction mergeNamespace<T extends object>(base: T, over: Partial<T> | undefined): T {\n if (!over) return base;\n const out = { ...base } as Record<string, unknown>;\n for (const [k, v] of Object.entries(over)) {\n if (v === undefined) continue;\n const prev = out[k];\n out[k] = isRecord(prev) && isRecord(v) ? { ...prev, ...v } : v;\n }\n return out as T;\n}\n\nfunction mergeOverrides(\n a: UiKitLabelOverrides | undefined,\n b: UiKitLabelOverrides | undefined,\n): UiKitLabelOverrides | undefined {\n if (!a) return b;\n if (!b) return a;\n const out: Record<string, unknown> = { ...a };\n for (const [ns, v] of Object.entries(b)) {\n out[ns] = mergeNamespace((out[ns] as object | undefined) ?? {}, v as object);\n }\n return out as UiKitLabelOverrides;\n}\n\n/** What the nearest provider says about one namespace — `undefined` outside one.\n * For a component whose own resolver does more than a merge (the data table\n * derives `columnsCount` from `columns`): feed `{ ...overrides, ...props }` to it. */\nexport function useKitLabelOverrides<K extends keyof UiKitLabels>(\n ns: K,\n): Partial<UiKitLabels[K]> | undefined {\n return useContext(KitI18nContext).labels?.[ns] as Partial<UiKitLabels[K]> | undefined;\n}\n\n/**\n * One namespace, resolved: `defaults`, then the provider, then the component's own\n * `prop`. Record-valued keys are merged key by key at each step.\n */\nexport function useKitLabels<K extends keyof UiKitLabels>(\n ns: K,\n defaults: UiKitLabels[K],\n prop?: Partial<UiKitLabels[K]>,\n): UiKitLabels[K] {\n const fromProvider = useKitLabelOverrides(ns);\n return useMemo(\n () => mergeNamespace(mergeNamespace(defaults, fromProvider), prop),\n [defaults, fromProvider, prop],\n );\n}\n\n/** The component's own `locale` prop, else the provider's, else `undefined` (which\n * every `Intl` API reads as \"the runtime's default\"). */\nexport function useKitLocale(prop?: string): string | undefined {\n const fromProvider = useContext(KitI18nContext).locale;\n return prop ?? fromProvider;\n}\n\n/** {@link DEFAULT_FILE_LABELS}, but formatting in the provider's locale. */\nexport function useKitFileLabels(prop?: Partial<FileLabels>): FileLabels {\n const locale = useKitLocale();\n const defaults = useMemo<FileLabels>(\n () => ({ size: (bytes) => formatFileSize(bytes, locale) }),\n [locale],\n );\n return useKitLabels(\"file\", defaults, prop);\n}\n\n/**\n * The dot paths of every key `labels` does NOT supply — the ones a translated app is\n * still showing in English. Assert on it in the app's own test:\n *\n * expect(missingKitLabels(de)).toEqual([]);\n *\n * `reference` is the complete tree to check against — pass\n * {@link DEFAULT_UI_KIT_LABELS} (src/i18n/defaults.ts). It is a parameter rather than an import\n * because the defaults live beside their components, and this module is imported BY\n * those components.\n */\nexport function missingKitLabels(\n labels: UiKitLabelOverrides | undefined,\n reference: UiKitLabels,\n): string[] {\n const missing: string[] = [];\n for (const [ns, keys] of Object.entries(reference)) {\n const given = (labels as Record<string, Record<string, unknown> | undefined> | undefined)?.[ns];\n for (const [key, value] of Object.entries(keys as Record<string, unknown>)) {\n const got = given?.[key];\n if (got === undefined) {\n missing.push(`${ns}.${key}`);\n } else if (isRecord(value) && isRecord(got)) {\n for (const sub of Object.keys(value)) {\n if (got[sub] === undefined) missing.push(`${ns}.${key}.${sub}`);\n }\n }\n }\n }\n return missing;\n}\n"],"mappings":"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","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/i18n/kit-labels.tsx"],"sourcesContent":["import { createContext, useContext, useMemo } from \"react\";\nimport type { ReactNode } from \"react\";\nimport type { DataTableLabels } from \"../components/data-table-labels\";\nimport type { MiniCalendarLabels, WeekDay } from \"../components/mini-calendar\";\nimport type { PopoverLabels } from \"../components/popover\";\nimport type { ChipInputLabels } from \"../components/chip\";\nimport type { FieldSyncLabels } from \"../components/field-sync\";\nimport type { PasswordRevealLabels, TabsLabels } from \"../components/ui\";\nimport type { WizardLabels } from \"../wizard/types\";\nimport type { TourLabels } from \"../tour/tour\";\nimport type { CommandPaletteLabels } from \"../search/command-palette\";\nimport type { MonthPickerLabels } from \"../components/month-picker\";\nimport type { PageContentsLabels } from \"../components/page-contents\";\nimport type { SeriesChartLabels } from \"../components/series-chart-labels\";\nimport type { SparklineLabels } from \"../components/sparkline\";\nimport type { StatTileLabels } from \"../components/stat-tile\";\nimport type { SignaturePadLabels } from \"../components/signature-pad\";\nimport type { PasswordStrengthLabels } from \"../components/password-strength\";\nimport type { DangerConfirmLabels } from \"../components/danger-confirm\";\nimport type { SwatchPickerLabels } from \"../components/swatch-picker\";\nimport type { IconPickerLabels } from \"../components/icon-picker\";\nimport type { DialogFrameLabels } from \"../components/dialog-frame\";\nimport type { FilePickerLabels } from \"../components/file-button\";\n\n/**\n * EVERY string the kit renders, as one typed tree — and an optional provider that\n * hands it to every component at once.\n *\n * WHY THIS EXISTS. The kit ships no catalogue and resolves no strings, and that stays\n * true: the app supplies every word. What was wrong was HOW it had to supply them —\n * one `labels` prop per component instance, under a different prop name per\n * component (`labels`, `calendarLabels`, `passwordLabels`, `clearLabel`,\n * `searchPlaceholder`, `ariaLabel` …). A translated app therefore rendered English\n * wherever one call site forgot one prop, and nothing told it so: a German showcase\n * still said \"Rows per page\", \"Collapse sidebar\" and \"Popover\" in seven languages.\n *\n * Now there is one key per string, addressed by a dot path (`dataTable.pageSize`,\n * `datePicker.today`), and three sources in a fixed order of precedence:\n *\n * the component's own prop > <UiKitProvider labels> > English default\n *\n * A consumer writes its translation ONCE, as a `UiKitLabels` (or a partial of it),\n * mounts `<UiKitProvider labels={…} locale={…}>` at the root, and every kit component\n * below speaks that language — including the ones nested inside other kit components\n * (the calendar inside the data table's date filter, the popover inside the date\n * picker), which no prop at the outer call site could reach before.\n *\n * Messages that carry a value are FUNCTIONS of that value, never a template to fill:\n * a number glued into an English sentence is untranslatable, because the grammar\n * around it moves with it in most languages.\n */\n\n/* ── Namespaces that had no labels type of their own ─────────────────────── */\n\n/** The words several components share. A component's own namespace wins over these\n * where both exist; these are what a new component reaches for first. */\nexport interface CommonLabels {\n close: string;\n clear: string;\n search: string;\n done: string;\n cancel: string;\n save: string;\n back: string;\n next: string;\n remove: string;\n loading: string;\n noResults: string;\n /** \"Name: value\" — how a field's accessible name is composed with its value.\n * A colon-and-space is not universal punctuation (French puts a space before\n * the colon, Chinese uses a full-width one). */\n fieldValue: (field: string, value: string) => string;\n}\n\n/** `DatePicker` / `DateRangePicker` chrome. The calendar inside has its own\n * namespace, `miniCalendar`. */\nexport interface DatePickerLabels {\n /** Accessible name of the popover panel the calendar opens in. */\n panel: string;\n /** The same, for `DateRangePicker`'s panel. */\n rangePanel: string;\n clear: string;\n previousDay: string;\n nextDay: string;\n today: string;\n}\n\n/** The whole combobox family: `Combobox`, `EntityCombobox`,\n * `MultiEntityCombobox`, `InlineEntityCombobox`, `Autocomplete`. */\nexport interface ComboboxLabels {\n search: string;\n noResults: string;\n clear: string;\n loading: string;\n /** The \"add this\" row when free entry is allowed. */\n create: (query: string) => string;\n /** Trigger summary once more than one value is picked. */\n selectedCount: (count: number) => string;\n /** An async lookup (`loadOptions`) failed. */\n loadError: string;\n /** Announced (live region) when the list settles on `count` > 0 rows. */\n resultCount: (count: number) => string;\n /** The query is shorter than the `minChars` a lookup needs. */\n minChars: (count: number) => string;\n}\n\nexport interface MultiSelectLabels {\n search: string;\n selectAll: string;\n clear: string;\n /** Trigger text when nothing is picked, which a multi-select reads as \"all\". */\n all: string;\n /** Trigger summary once some (but not all) values are picked. The English\n * default is the bare count, which is what the trigger has always shown. */\n selectedCount: (count: number) => string;\n}\n\n/** `CalculatorButton` (desktop popover keypad) and `NumberPadSheet` (phone sheet). */\nexport interface CalculatorLabels {\n /** The button that opens the calculator. */\n open: string;\n /** The popover / sheet itself. */\n panel: string;\n calculation: string;\n backspace: string;\n clear: string;\n equals: string;\n /** The primary key of the phone pad — visible text, not an aria-label. */\n done: string;\n /** Names of the operator keys and the decimal key. Their glyphs are not names a\n * screen reader agrees on — \"÷\" is read as \"division sign\", \"divided by\" or\n * nothing at all depending on the reader — so each says what it does. */\n plus: string;\n minus: string;\n times: string;\n divide: string;\n decimal: string;\n}\n\n/** `CurrencySelect` and the currency half of `AmountInput`. */\nexport interface CurrencyLabels {\n currency: string;\n search: string;\n}\n\nexport interface AppShellLabels {\n collapse: string;\n expand: string;\n /** Accessible name of an inline group's disclosure button (`subNav=\"inline\"`). */\n toggleGroup: (groupLabel: string) => string;\n}\n\nexport interface TopBarLabels {\n theme: string;\n palette: string;\n language: string;\n switchRole: string;\n /** The role switcher's tooltip, given the active role's name. */\n role: (value: string) => string;\n}\n\nexport interface PickerSheetLabels {\n close: string;\n}\n\nexport interface SwipeableRowLabels {\n actions: string;\n}\n\nexport interface FileLabels {\n /** A file size for display, given its size in BYTES. The default uses\n * `Intl.NumberFormat`'s unit formatting in the provider's locale. */\n size: (bytes: number) => string;\n}\n\n/** The complete tree. `UiKitProvider` takes any partial of it. */\nexport interface UiKitLabels {\n common: CommonLabels;\n dataTable: DataTableLabels;\n miniCalendar: MiniCalendarLabels;\n datePicker: DatePickerLabels;\n monthPicker: MonthPickerLabels;\n popover: PopoverLabels;\n combobox: ComboboxLabels;\n multiSelect: MultiSelectLabels;\n calculator: CalculatorLabels;\n currency: CurrencyLabels;\n chipInput: ChipInputLabels;\n fieldSync: FieldSyncLabels;\n passwordReveal: PasswordRevealLabels;\n tabs: TabsLabels;\n appShell: AppShellLabels;\n pageContents: PageContentsLabels;\n topBar: TopBarLabels;\n pickerSheet: PickerSheetLabels;\n swipeableRow: SwipeableRowLabels;\n file: FileLabels;\n wizard: WizardLabels;\n tour: TourLabels;\n commandPalette: CommandPaletteLabels;\n seriesChart: SeriesChartLabels;\n sparkline: SparklineLabels;\n statTile: StatTileLabels;\n signaturePad: SignaturePadLabels;\n passwordStrength: PasswordStrengthLabels;\n dangerConfirm: DangerConfirmLabels;\n swatchPicker: SwatchPickerLabels;\n iconPicker: IconPickerLabels;\n dialogFrame: DialogFrameLabels;\n filePicker: FilePickerLabels;\n}\n\n/** Any subset of the tree, one level deep — each namespace may be partial, and a\n * namespace that holds a record (`dataTable.presets`) is merged key by key. */\nexport type UiKitLabelOverrides = { [K in keyof UiKitLabels]?: Partial<UiKitLabels[K]> };\n\n/* ── English defaults for the namespaces defined here ────────────────────── */\n\nexport const DEFAULT_COMMON_LABELS: CommonLabels = {\n close: \"Close\",\n clear: \"Clear\",\n search: \"Search\",\n done: \"Done\",\n cancel: \"Cancel\",\n save: \"Save\",\n back: \"Back\",\n next: \"Next\",\n remove: \"Remove\",\n loading: \"Loading…\",\n noResults: \"No results\",\n fieldValue: (field, value) => `${field}: ${value}`,\n};\n\nexport const DEFAULT_DATE_PICKER_LABELS: DatePickerLabels = {\n panel: \"Choose a date\",\n rangePanel: \"Choose a date range\",\n clear: \"Clear\",\n previousDay: \"Previous day\",\n nextDay: \"Next day\",\n today: \"Today\",\n};\n\nexport const DEFAULT_COMBOBOX_LABELS: ComboboxLabels = {\n search: \"Search\",\n noResults: \"No results\",\n clear: \"Clear\",\n loading: \"Loading…\",\n create: (query) => `Create “${query}”`,\n selectedCount: (count) => `${count} selected`,\n loadError: \"Couldn’t load results\",\n resultCount: (count) => (count === 1 ? \"1 result\" : `${count} results`),\n minChars: (count) =>\n count === 1 ? \"Type at least 1 character\" : `Type at least ${count} characters`,\n};\n\nexport const DEFAULT_MULTI_SELECT_LABELS: MultiSelectLabels = {\n search: \"Search\",\n selectAll: \"Select all\",\n clear: \"Clear\",\n all: \"All\",\n selectedCount: (count) => String(count),\n};\n\nexport const DEFAULT_CALCULATOR_LABELS: CalculatorLabels = {\n open: \"Open calculator\",\n panel: \"Calculator\",\n calculation: \"Calculation\",\n backspace: \"Backspace\",\n clear: \"Clear\",\n equals: \"Equals\",\n done: \"Done\",\n plus: \"Plus\",\n minus: \"Minus\",\n times: \"Times\",\n divide: \"Divide\",\n decimal: \"Decimal point\",\n};\n\nexport const DEFAULT_CURRENCY_LABELS: CurrencyLabels = {\n currency: \"Currency\",\n search: \"Search currency\",\n};\n\nexport const DEFAULT_APP_SHELL_LABELS: AppShellLabels = {\n collapse: \"Collapse sidebar\",\n expand: \"Expand sidebar\",\n toggleGroup: (groupLabel) => `${groupLabel}: pages`,\n};\n\nexport const DEFAULT_TOP_BAR_LABELS: TopBarLabels = {\n theme: \"Toggle theme\",\n palette: \"Appearance preset\",\n language: \"Language\",\n switchRole: \"Switch role\",\n role: (value) => `Role: ${value}`,\n};\n\nexport const DEFAULT_PICKER_SHEET_LABELS: PickerSheetLabels = { close: \"Close\" };\n\nexport const DEFAULT_SWIPEABLE_ROW_LABELS: SwipeableRowLabels = { actions: \"Row actions\" };\n\n/** Formats with the locale the provider was given (see {@link useKitFileLabels}).\n * This static default has no locale to hand and falls back to the runtime's. */\nexport const DEFAULT_FILE_LABELS: FileLabels = {\n size: (bytes) => formatFileSize(bytes),\n};\n\n/** \"12 kB\", \"3.4 MB\" — `Intl`'s unit formatting, so the digits, the decimal mark and\n * the unit's spelling all follow `locale`. */\nexport function formatFileSize(bytes: number, locale?: string): string {\n const units = [\"byte\", \"kilobyte\", \"megabyte\", \"gigabyte\"] as const;\n let value = bytes;\n let i = 0;\n while (value >= 1000 && i < units.length - 1) {\n value /= 1000;\n i += 1;\n }\n return new Intl.NumberFormat(locale, {\n style: \"unit\",\n unit: units[i],\n unitDisplay: i === 0 ? \"long\" : \"short\",\n maximumFractionDigits: value < 10 && i > 0 ? 1 : 0,\n }).format(value);\n}\n\n/* ── The provider ────────────────────────────────────────────────────────── */\n\ninterface KitI18n {\n labels?: UiKitLabelOverrides;\n locale?: string;\n weekStartsOn?: WeekDay;\n}\n\nconst KitI18nContext = createContext<KitI18n>({});\n\nexport interface UiKitProviderProps {\n /** Any part of {@link UiKitLabels}. Missing keys fall back to English. */\n labels?: UiKitLabelOverrides;\n /**\n * BCP 47 tag used by every kit component that formats something — dates, numbers,\n * month and weekday names, file sizes — when it is not handed a `locale` prop of\n * its own. Without a provider, and without a prop, those use the runtime default.\n */\n locale?: string;\n /**\n * The first day of the week (0 = Sunday, 1 = Monday …) for every calendar below —\n * `MiniCalendar` and the pickers built on it — that is not handed a `weekStartsOn`\n * of its own. Without it the week start follows `locale`'s week info.\n *\n * Separate from `locale` because the two are separate decisions: a German-built\n * app running in English (`locale=\"en\"`) would otherwise start its weeks on Sunday,\n * and switching it to `en-GB` to get Monday changes every date and number format.\n */\n weekStartsOn?: WeekDay;\n children: ReactNode;\n}\n\n/**\n * Hand every kit component below this point its strings and its locale.\n *\n * Optional: a component outside any provider behaves exactly as it did before the\n * provider existed. Nesting works as a merge — an inner provider overrides only what\n * it names, so a page can re-label one table's `dataTable.table` without restating\n * the language.\n */\nexport function UiKitProvider({ labels, locale, weekStartsOn, children }: UiKitProviderProps) {\n const outer = useContext(KitI18nContext);\n const value = useMemo<KitI18n>(\n () => ({\n locale: locale ?? outer.locale,\n weekStartsOn: weekStartsOn ?? outer.weekStartsOn,\n labels: mergeOverrides(outer.labels, labels),\n }),\n [outer, labels, locale, weekStartsOn],\n );\n return <KitI18nContext.Provider value={value}>{children}</KitI18nContext.Provider>;\n}\n\nfunction isRecord(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\n/** Two levels: namespaces, and inside a namespace a record-valued key (presets). */\nfunction mergeNamespace<T extends object>(base: T, over: Partial<T> | undefined): T {\n if (!over) return base;\n const out = { ...base } as Record<string, unknown>;\n for (const [k, v] of Object.entries(over)) {\n if (v === undefined) continue;\n const prev = out[k];\n out[k] = isRecord(prev) && isRecord(v) ? { ...prev, ...v } : v;\n }\n return out as T;\n}\n\nfunction mergeOverrides(\n a: UiKitLabelOverrides | undefined,\n b: UiKitLabelOverrides | undefined,\n): UiKitLabelOverrides | undefined {\n if (!a) return b;\n if (!b) return a;\n const out: Record<string, unknown> = { ...a };\n for (const [ns, v] of Object.entries(b)) {\n out[ns] = mergeNamespace((out[ns] as object | undefined) ?? {}, v as object);\n }\n return out as UiKitLabelOverrides;\n}\n\n/** What the nearest provider says about one namespace — `undefined` outside one.\n * For a component whose own resolver does more than a merge (the data table\n * derives `columnsCount` from `columns`): feed `{ ...overrides, ...props }` to it. */\nexport function useKitLabelOverrides<K extends keyof UiKitLabels>(\n ns: K,\n): Partial<UiKitLabels[K]> | undefined {\n return useContext(KitI18nContext).labels?.[ns] as Partial<UiKitLabels[K]> | undefined;\n}\n\n/**\n * One namespace, resolved: `defaults`, then the provider, then the component's own\n * `prop`. Record-valued keys are merged key by key at each step.\n */\nexport function useKitLabels<K extends keyof UiKitLabels>(\n ns: K,\n defaults: UiKitLabels[K],\n prop?: Partial<UiKitLabels[K]>,\n): UiKitLabels[K] {\n const fromProvider = useKitLabelOverrides(ns);\n return useMemo(\n () => mergeNamespace(mergeNamespace(defaults, fromProvider), prop),\n [defaults, fromProvider, prop],\n );\n}\n\n/** The component's own `locale` prop, else the provider's, else `undefined` (which\n * every `Intl` API reads as \"the runtime's default\"). */\nexport function useKitLocale(prop?: string): string | undefined {\n const fromProvider = useContext(KitI18nContext).locale;\n return prop ?? fromProvider;\n}\n\n/** The week start the nearest `<UiKitProvider weekStartsOn>` pins, else `undefined`\n * (the caller then asks the locale). A component's own prop goes first:\n * `prop ?? useKitWeekStart()`. */\nexport function useKitWeekStart(): WeekDay | undefined {\n return useContext(KitI18nContext).weekStartsOn;\n}\n\n/** {@link DEFAULT_FILE_LABELS}, but formatting in the provider's locale. */\nexport function useKitFileLabels(prop?: Partial<FileLabels>): FileLabels {\n const locale = useKitLocale();\n const defaults = useMemo<FileLabels>(\n () => ({ size: (bytes) => formatFileSize(bytes, locale) }),\n [locale],\n );\n return useKitLabels(\"file\", defaults, prop);\n}\n\n/**\n * The dot paths of every key `labels` does NOT supply — the ones a translated app is\n * still showing in English. Assert on it in the app's own test:\n *\n * expect(missingKitLabels(de)).toEqual([]);\n *\n * `reference` is the complete tree to check against — pass\n * {@link DEFAULT_UI_KIT_LABELS} (src/i18n/defaults.ts). It is a parameter rather than an import\n * because the defaults live beside their components, and this module is imported BY\n * those components.\n */\nexport function missingKitLabels(\n labels: UiKitLabelOverrides | undefined,\n reference: UiKitLabels,\n): string[] {\n const missing: string[] = [];\n for (const [ns, keys] of Object.entries(reference)) {\n const given = (labels as Record<string, Record<string, unknown> | undefined> | undefined)?.[ns];\n for (const [key, value] of Object.entries(keys as Record<string, unknown>)) {\n const got = given?.[key];\n if (got === undefined) {\n missing.push(`${ns}.${key}`);\n } else if (isRecord(value) && isRecord(got)) {\n for (const sub of Object.keys(value)) {\n if (got[sub] === undefined) missing.push(`${ns}.${key}.${sub}`);\n }\n }\n }\n }\n return missing;\n}\n"],"mappings":";AAuXS;AAvXT,SAAS,eAAe,YAAY,eAAe;AA0N5C,MAAM,wBAAsC;AAAA,EACjD,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,WAAW;AAAA,EACX,YAAY,CAAC,OAAO,UAAU,GAAG,KAAK,KAAK,KAAK;AAClD;AAEO,MAAM,6BAA+C;AAAA,EAC1D,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,aAAa;AAAA,EACb,SAAS;AAAA,EACT,OAAO;AACT;AAEO,MAAM,0BAA0C;AAAA,EACrD,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ,CAAC,UAAU,gBAAW,KAAK;AAAA,EACnC,eAAe,CAAC,UAAU,GAAG,KAAK;AAAA,EAClC,WAAW;AAAA,EACX,aAAa,CAAC,UAAW,UAAU,IAAI,aAAa,GAAG,KAAK;AAAA,EAC5D,UAAU,CAAC,UACT,UAAU,IAAI,8BAA8B,iBAAiB,KAAK;AACtE;AAEO,MAAM,8BAAiD;AAAA,EAC5D,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,OAAO;AAAA,EACP,KAAK;AAAA,EACL,eAAe,CAAC,UAAU,OAAO,KAAK;AACxC;AAEO,MAAM,4BAA8C;AAAA,EACzD,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aAAa;AAAA,EACb,WAAW;AAAA,EACX,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AACX;AAEO,MAAM,0BAA0C;AAAA,EACrD,UAAU;AAAA,EACV,QAAQ;AACV;AAEO,MAAM,2BAA2C;AAAA,EACtD,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,aAAa,CAAC,eAAe,GAAG,UAAU;AAC5C;AAEO,MAAM,yBAAuC;AAAA,EAClD,OAAO;AAAA,EACP,SAAS;AAAA,EACT,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,MAAM,CAAC,UAAU,SAAS,KAAK;AACjC;AAEO,MAAM,8BAAiD,EAAE,OAAO,QAAQ;AAExE,MAAM,+BAAmD,EAAE,SAAS,cAAc;AAIlF,MAAM,sBAAkC;AAAA,EAC7C,MAAM,CAAC,UAAU,eAAe,KAAK;AACvC;AAIO,SAAS,eAAe,OAAe,QAAyB;AACrE,QAAM,QAAQ,CAAC,QAAQ,YAAY,YAAY,UAAU;AACzD,MAAI,QAAQ;AACZ,MAAI,IAAI;AACR,SAAO,SAAS,OAAQ,IAAI,MAAM,SAAS,GAAG;AAC5C,aAAS;AACT,SAAK;AAAA,EACP;AACA,SAAO,IAAI,KAAK,aAAa,QAAQ;AAAA,IACnC,OAAO;AAAA,IACP,MAAM,MAAM,CAAC;AAAA,IACb,aAAa,MAAM,IAAI,SAAS;AAAA,IAChC,uBAAuB,QAAQ,MAAM,IAAI,IAAI,IAAI;AAAA,EACnD,CAAC,EAAE,OAAO,KAAK;AACjB;AAUA,MAAM,iBAAiB,cAAuB,CAAC,CAAC;AAgCzC,SAAS,cAAc,EAAE,QAAQ,QAAQ,cAAc,SAAS,GAAuB;AAC5F,QAAM,QAAQ,WAAW,cAAc;AACvC,QAAM,QAAQ;AAAA,IACZ,OAAO;AAAA,MACL,QAAQ,UAAU,MAAM;AAAA,MACxB,cAAc,gBAAgB,MAAM;AAAA,MACpC,QAAQ,eAAe,MAAM,QAAQ,MAAM;AAAA,IAC7C;AAAA,IACA,CAAC,OAAO,QAAQ,QAAQ,YAAY;AAAA,EACtC;AACA,SAAO,oBAAC,eAAe,UAAf,EAAwB,OAAe,UAAS;AAC1D;AAEA,SAAS,SAAS,GAA0C;AAC1D,SAAO,OAAO,MAAM,YAAY,MAAM,QAAQ,CAAC,MAAM,QAAQ,CAAC;AAChE;AAGA,SAAS,eAAiC,MAAS,MAAiC;AAClF,MAAI,CAAC,KAAM,QAAO;AAClB,QAAM,MAAM,EAAE,GAAG,KAAK;AACtB,aAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,IAAI,GAAG;AACzC,QAAI,MAAM,OAAW;AACrB,UAAM,OAAO,IAAI,CAAC;AAClB,QAAI,CAAC,IAAI,SAAS,IAAI,KAAK,SAAS,CAAC,IAAI,EAAE,GAAG,MAAM,GAAG,EAAE,IAAI;AAAA,EAC/D;AACA,SAAO;AACT;AAEA,SAAS,eACP,GACA,GACiC;AACjC,MAAI,CAAC,EAAG,QAAO;AACf,MAAI,CAAC,EAAG,QAAO;AACf,QAAM,MAA+B,EAAE,GAAG,EAAE;AAC5C,aAAW,CAAC,IAAI,CAAC,KAAK,OAAO,QAAQ,CAAC,GAAG;AACvC,QAAI,EAAE,IAAI,eAAgB,IAAI,EAAE,KAA4B,CAAC,GAAG,CAAW;AAAA,EAC7E;AACA,SAAO;AACT;AAKO,SAAS,qBACd,IACqC;AACrC,SAAO,WAAW,cAAc,EAAE,SAAS,EAAE;AAC/C;AAMO,SAAS,aACd,IACA,UACA,MACgB;AAChB,QAAM,eAAe,qBAAqB,EAAE;AAC5C,SAAO;AAAA,IACL,MAAM,eAAe,eAAe,UAAU,YAAY,GAAG,IAAI;AAAA,IACjE,CAAC,UAAU,cAAc,IAAI;AAAA,EAC/B;AACF;AAIO,SAAS,aAAa,MAAmC;AAC9D,QAAM,eAAe,WAAW,cAAc,EAAE;AAChD,SAAO,QAAQ;AACjB;AAKO,SAAS,kBAAuC;AACrD,SAAO,WAAW,cAAc,EAAE;AACpC;AAGO,SAAS,iBAAiB,MAAwC;AACvE,QAAM,SAAS,aAAa;AAC5B,QAAM,WAAW;AAAA,IACf,OAAO,EAAE,MAAM,CAAC,UAAU,eAAe,OAAO,MAAM,EAAE;AAAA,IACxD,CAAC,MAAM;AAAA,EACT;AACA,SAAO,aAAa,QAAQ,UAAU,IAAI;AAC5C;AAaO,SAAS,iBACd,QACA,WACU;AACV,QAAM,UAAoB,CAAC;AAC3B,aAAW,CAAC,IAAI,IAAI,KAAK,OAAO,QAAQ,SAAS,GAAG;AAClD,UAAM,QAAS,SAA6E,EAAE;AAC9F,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,IAA+B,GAAG;AAC1E,YAAM,MAAM,QAAQ,GAAG;AACvB,UAAI,QAAQ,QAAW;AACrB,gBAAQ,KAAK,GAAG,EAAE,IAAI,GAAG,EAAE;AAAA,MAC7B,WAAW,SAAS,KAAK,KAAK,SAAS,GAAG,GAAG;AAC3C,mBAAW,OAAO,OAAO,KAAK,KAAK,GAAG;AACpC,cAAI,IAAI,GAAG,MAAM,OAAW,SAAQ,KAAK,GAAG,EAAE,IAAI,GAAG,IAAI,GAAG,EAAE;AAAA,QAChE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -17,14 +17,14 @@ export { AnchorRole, ChartRampReport, ContrastCheck, ContrastReport, DeriveOptio
|
|
|
17
17
|
export { ALTERNATIVE_PRESETS, DEFAULT_PRESET, DERIVED_PRESETS, IMPRINT_PRESET, PALETTES, PalettePreset, TokenSet, applyTokenSet, presetById } from './theme/palette-presets.js';
|
|
18
18
|
export { ThemeMode, ThemePreference, ThemeState, ThemeStore, applyPersistedTheme, createThemeStore } from './theme/theme-store.js';
|
|
19
19
|
export { PaletteStore, applyPersistedPalette, createPaletteStore } from './theme/palette-store.js';
|
|
20
|
-
export { Button, ButtonProps, ButtonVariant, Card, CardAction, CardActionProps, CardContent, CardContentProps, CardDescription, CardDescriptionProps, CardFooter, CardFooterProps, CardHeader, CardHeaderProps, CardProps, CardTitle, CardTitleProps, DEFAULT_PASSWORD_REVEAL_LABELS, EmptyState, EmptyStateProps, FIELD_BASE, FIELD_DISPLAY, FIELD_FLOATING_PAD, FIELD_INVALID, FIELD_TRIGGER, FIELD_WRITABLE_LOOK, FLOATING_INPUT_CLASS, FLOATING_LABEL_CLASS, FLOATING_LABEL_STATIC, FieldChevron, FieldChevronProps, FieldHint, FieldHintProps, FieldLabel, FieldLabelProps, FloatingField, FloatingFieldProps, IconButton, IconButtonProps, Input, InputProps, PHONE_QUERY, PasswordRevealLabels, Select, SelectProps, Spinner, SpinnerProps, Tabs, TabsProps, Textarea, TextareaProps, buttonClasses, resolvePasswordRevealLabels } from './components/ui.js';
|
|
20
|
+
export { Button, ButtonProps, ButtonVariant, Card, CardAction, CardActionProps, CardContent, CardContentProps, CardDescription, CardDescriptionProps, CardFooter, CardFooterProps, CardHeader, CardHeaderProps, CardProps, CardTitle, CardTitleProps, DEFAULT_PASSWORD_REVEAL_LABELS, DEFAULT_TABS_LABELS, EmptyState, EmptyStateProps, FIELD_BASE, FIELD_DISPLAY, FIELD_FLOATING_PAD, FIELD_INVALID, FIELD_TRIGGER, FIELD_WRITABLE_LOOK, FLOATING_INPUT_CLASS, FLOATING_LABEL_CLASS, FLOATING_LABEL_STATIC, FieldChevron, FieldChevronProps, FieldHint, FieldHintProps, FieldLabel, FieldLabelProps, FloatingField, FloatingFieldProps, IconButton, IconButtonProps, IconButtonSize, Input, InputProps, Label, LabelProps, PHONE_QUERY, PasswordRevealLabels, Select, SelectProps, Spinner, SpinnerProps, TabItem, Tabs, TabsLabels, TabsProps, Textarea, TextareaProps, buttonClasses, resolvePasswordRevealLabels } from './components/ui.js';
|
|
21
21
|
export { SearchField, SearchFieldProps } from './components/search-field.js';
|
|
22
22
|
export { DropdownPanel, DropdownPanelProps, DropdownSearchHeader, DropdownSearchHeaderProps, useDropdown, useDropdownSearch } from './components/dropdown.js';
|
|
23
23
|
export { DEFAULT_POPOVER_LABELS, Popover, PopoverLabels, PopoverProps } from './components/popover.js';
|
|
24
24
|
export { SwipeAction, SwipeableRow, SwipeableRowProps } from './components/swipeable-row.js';
|
|
25
25
|
export { CalculatorButton, CalculatorButtonLabels } from './components/calculator.js';
|
|
26
26
|
export { NumberPadSheet, NumberPadSheetLabels } from './components/numpad-sheet.js';
|
|
27
|
-
export { NumberInput } from './components/number-input.js';
|
|
27
|
+
export { NumberInput, stepNumber } from './components/number-input.js';
|
|
28
28
|
export { CURRENCIES, CurrencyFlag, CurrencyFlagProps, CurrencyOption, CurrencySelect, CurrencySelectProps, currencyName, getCurrency } from './components/currency-select.js';
|
|
29
29
|
export { AmountInput } from './components/amount-input.js';
|
|
30
30
|
export { Combobox, ComboboxProps, InlineEntityCombobox, InlineEntityComboboxProps } from './components/combobox.js';
|
|
@@ -44,9 +44,17 @@ export { TimeInput, TimeInputProps, isTimeInRange, normalizeTime } from './compo
|
|
|
44
44
|
export { NumberField, NumberFieldProps } from './components/number-field.js';
|
|
45
45
|
export { DEFAULT_SPARKLINE_LABELS, Sparkline, SparklineLabels, SparklineProps, SparklineTone, sparklineSummary } from './components/sparkline.js';
|
|
46
46
|
export { DEFAULT_STAT_TILE_LABELS, StatTile, StatTileDelta, StatTileGrid, StatTileGridProps, StatTileLabels, StatTileLinkProps, StatTileProps, StatTileSubValue, StatTileTone } from './components/stat-tile.js';
|
|
47
|
-
export { DEFAULT_SIGNATURE_PAD_LABELS, SignatureDetail, SignaturePad, SignaturePadHandle, SignaturePadLabels, SignaturePadProps } from './components/signature-pad.js';
|
|
47
|
+
export { DEFAULT_SIGNATURE_PAD_LABELS, SignatureDetail, SignaturePad, SignaturePadHandle, SignaturePadLabels, SignaturePadProps, SignatureView, SignatureViewProps } from './components/signature-pad.js';
|
|
48
48
|
export { DEFAULT_PASSWORD_STRENGTH_LABELS, PasswordRule, PasswordRuleId, PasswordScoreOptions, PasswordStrengthLabels, PasswordStrengthMeter, PasswordStrengthMeterProps, PasswordStrengthScore, passwordByteLength, passwordRules, scorePassword } from './components/password-strength.js';
|
|
49
49
|
export { DEFAULT_PAGE_CONTENTS_LABELS, PageContents, PageContentsItem, PageContentsLabels, PageContentsLayout, PageContentsLayoutProps, PageContentsProps, UseScrollSpyOptions, useScrollSpy } from './components/page-contents.js';
|
|
50
|
+
export { Collapse, CollapseProps, Disclosure, DisclosureProps } from './components/disclosure.js';
|
|
51
|
+
export { DEFAULT_DIALOG_FRAME_LABELS, DialogFrame, DialogFrameLabels, DialogFrameProps } from './components/dialog-frame.js';
|
|
52
|
+
export { DEFAULT_DANGER_CONFIRM_LABELS, DangerConfirm, DangerConfirmLabels, DangerConfirmProps } from './components/danger-confirm.js';
|
|
53
|
+
export { DEFAULT_SWATCH_PICKER_LABELS, SwatchOption, SwatchPicker, SwatchPickerLabels, SwatchPickerProps } from './components/swatch-picker.js';
|
|
54
|
+
export { DEFAULT_ICON_PICKER_LABELS, IconOption, IconPicker, IconPickerLabels, IconPickerProps } from './components/icon-picker.js';
|
|
55
|
+
export { ChoiceCard, ChoiceCardGroup, ChoiceCardGroupProps, ChoiceCardMultipleProps, ChoiceCardOption, ChoiceCardProps, ChoiceCardSingleProps, ChoiceCardType } from './components/choice-card.js';
|
|
56
|
+
export { Autocomplete, AutocompleteProps } from './components/autocomplete.js';
|
|
57
|
+
export { DEFAULT_FILE_PICKER_LABELS, FileButton, FileButtonProps, FilePickerLabels, FileRejection, FileRejectionReason, FileScreenOptions, UseFilePickerOptions, UseFilePickerReturn, matchesAccept, useFilePicker } from './components/file-button.js';
|
|
50
58
|
export { Treemap, TreemapCell, TreemapCellProps, TreemapNode, TreemapProps, fitLabel } from './components/treemap.js';
|
|
51
59
|
export { AXIS_TICK_WIDTH, AXIS_TITLE_STRIP, SeriesChart, SeriesChartAxis, SeriesChartProps, SeriesChartSeries, SeriesChartSpan, SeriesChartX, SeriesSource, StaticSeriesChart, axisBandWidth, mergeSeries, oneAxis, padBand, paddedDomain, seriesKey, soleSeriesColor } from './components/series-chart.js';
|
|
52
60
|
export { DEFAULT_Y_AXIS, NO_ZOOM, SharedXZoom, ZOOM_MIN_DRAG, ZOOM_SQUARE_ENOUGH, ZoomAxes, ZoomBinding, ZoomDrag, ZoomFitSource, ZoomSelection, ZoomState, ZoomTarget, fitXToY, fitYToX, selectionFromDrag, withChartZoom, zoomAfter, zoomAxesFor, zoomDomains } from './components/chart-zoom.js';
|
|
@@ -55,14 +63,14 @@ export { FACING_SIDES, FacingSide, facingAxes, facingBand, facingHeadingPad } fr
|
|
|
55
63
|
export { DEFAULT_SERIES_CHART_LABELS, SeriesChartLabels } from './components/series-chart-labels.js';
|
|
56
64
|
export { PasswordSetting, PasswordSettingLabels, ProfileSetting, ProfileSettingLabels, TwoFactorSetting, TwoFactorSettingLabels } from './components/account-settings.js';
|
|
57
65
|
export { AlertBanner, AlertBannerProps, AlertTone, alertFrameClass, toneFrameClass } from './components/alert-banner.js';
|
|
58
|
-
export { ToggleGroup, ToggleGroupProps, ToggleOption } from './components/toggle-group.js';
|
|
66
|
+
export { ToggleGroup, ToggleGroupBaseProps, ToggleGroupClearableProps, ToggleGroupProps, ToggleGroupRequiredProps, ToggleOption } from './components/toggle-group.js';
|
|
59
67
|
export { Chip, ChipInput, ChipInputLabels, ChipInputProps, ChipProps, ChipSize, ChipTone, DEFAULT_CHIP_INPUT_LABELS, resolveChipInputLabels } from './components/chip.js';
|
|
60
68
|
export { WizardStepper } from './components/wizard-stepper.js';
|
|
61
69
|
export { HoverMenu, HoverMenuProps } from './components/hover-menu.js';
|
|
62
|
-
export { Modal, ModalProps, useBackdropClose } from './components/modal.js';
|
|
70
|
+
export { Modal, ModalCloseContext, ModalProps, useBackdropClose } from './components/modal.js';
|
|
63
71
|
export { FullBleedDialog, FullBleedDialogProps } from './components/full-bleed-dialog.js';
|
|
64
72
|
export { GroupedPicker, GroupedPickerProps, PickerGroup } from './components/grouped-picker.js';
|
|
65
|
-
export { FileDropzone, FileDropzoneProps } from './components/file-dropzone.js';
|
|
73
|
+
export { FileDropzone, FileDropzoneProps, FileDropzoneRejectionFeedback } from './components/file-dropzone.js';
|
|
66
74
|
export { DEFAULT_MINI_CALENDAR_LABELS, MiniCalendar, MiniCalendarLabels, MiniCalendarProps, WeekDay } from './components/mini-calendar.js';
|
|
67
75
|
export { DatePicker, DatePickerProps, DateRangePicker, DateRangePickerPreset, DateRangePickerProps } from './components/date-picker.js';
|
|
68
76
|
export { ChartConfig, ChartContainer, ChartLegend, ChartLegendContent, ChartSeriesConfig, ChartTooltip, ChartTooltipContent, useChart } from './components/chart.js';
|
|
@@ -89,12 +97,13 @@ export { WizardSummary } from './wizard/wizard-summary.js';
|
|
|
89
97
|
export { StepperNav } from './wizard/stepper-nav.js';
|
|
90
98
|
export { DEFAULT_TOUR_LABELS, TourLabels, TourPlacement, TourProvider, TourStep, useTour, useTourOptional } from './tour/tour.js';
|
|
91
99
|
export { CommandItem, CommandPalette, CommandPaletteLabels, DEFAULT_COMMAND_PALETTE_LABELS, useCommandKey } from './search/command-palette.js';
|
|
92
|
-
export { AppShellLabels, CalculatorLabels, ComboboxLabels, CommonLabels, CurrencyLabels, DEFAULT_APP_SHELL_LABELS, DEFAULT_CALCULATOR_LABELS, DEFAULT_COMBOBOX_LABELS, DEFAULT_COMMON_LABELS, DEFAULT_CURRENCY_LABELS, DEFAULT_DATE_PICKER_LABELS, DEFAULT_FILE_LABELS, DEFAULT_MULTI_SELECT_LABELS, DEFAULT_PICKER_SHEET_LABELS, DEFAULT_SWIPEABLE_ROW_LABELS, DEFAULT_TOP_BAR_LABELS, DatePickerLabels, FileLabels, MultiSelectLabels, PickerSheetLabels, SwipeableRowLabels, TopBarLabels, UiKitLabelOverrides, UiKitLabels, UiKitProvider, UiKitProviderProps, formatFileSize, missingKitLabels, useKitFileLabels, useKitLabelOverrides, useKitLabels, useKitLocale } from './i18n/kit-labels.js';
|
|
100
|
+
export { AppShellLabels, CalculatorLabels, ComboboxLabels, CommonLabels, CurrencyLabels, DEFAULT_APP_SHELL_LABELS, DEFAULT_CALCULATOR_LABELS, DEFAULT_COMBOBOX_LABELS, DEFAULT_COMMON_LABELS, DEFAULT_CURRENCY_LABELS, DEFAULT_DATE_PICKER_LABELS, DEFAULT_FILE_LABELS, DEFAULT_MULTI_SELECT_LABELS, DEFAULT_PICKER_SHEET_LABELS, DEFAULT_SWIPEABLE_ROW_LABELS, DEFAULT_TOP_BAR_LABELS, DatePickerLabels, FileLabels, MultiSelectLabels, PickerSheetLabels, SwipeableRowLabels, TopBarLabels, UiKitLabelOverrides, UiKitLabels, UiKitProvider, UiKitProviderProps, formatFileSize, missingKitLabels, useKitFileLabels, useKitLabelOverrides, useKitLabels, useKitLocale, useKitWeekStart } from './i18n/kit-labels.js';
|
|
93
101
|
export { DEFAULT_UI_KIT_LABELS } from './i18n/defaults.js';
|
|
94
102
|
export { ComboOption } from './components/combobox-core.js';
|
|
95
103
|
import 'clsx';
|
|
96
104
|
import 'zustand';
|
|
97
105
|
import 'react';
|
|
98
106
|
import 'zustand/middleware';
|
|
107
|
+
import './components/tile-radio.js';
|
|
99
108
|
import 'recharts';
|
|
100
109
|
import 'lucide-react';
|
package/dist/index.js
CHANGED
|
@@ -48,6 +48,14 @@ export * from "./components/stat-tile.js";
|
|
|
48
48
|
export * from "./components/signature-pad.js";
|
|
49
49
|
export * from "./components/password-strength.js";
|
|
50
50
|
export * from "./components/page-contents.js";
|
|
51
|
+
export * from "./components/disclosure.js";
|
|
52
|
+
export * from "./components/dialog-frame.js";
|
|
53
|
+
export * from "./components/danger-confirm.js";
|
|
54
|
+
export * from "./components/swatch-picker.js";
|
|
55
|
+
export * from "./components/icon-picker.js";
|
|
56
|
+
export * from "./components/choice-card.js";
|
|
57
|
+
export * from "./components/autocomplete.js";
|
|
58
|
+
import { FileButton, useFilePicker, matchesAccept, DEFAULT_FILE_PICKER_LABELS } from "./components/file-button.js";
|
|
51
59
|
export * from "./components/treemap.js";
|
|
52
60
|
export * from "./components/series-chart.js";
|
|
53
61
|
export * from "./components/chart-zoom.js";
|
|
@@ -94,13 +102,16 @@ export * from "./search/command-palette.js";
|
|
|
94
102
|
export * from "./i18n/kit-labels.js";
|
|
95
103
|
export * from "./i18n/defaults.js";
|
|
96
104
|
export {
|
|
105
|
+
DEFAULT_FILE_PICKER_LABELS,
|
|
97
106
|
DataTable,
|
|
107
|
+
FileButton,
|
|
98
108
|
FilterPopover,
|
|
99
109
|
OVERLAY_EXIT_MS,
|
|
100
110
|
SwipeableRow,
|
|
101
111
|
anchoredPanelPlacement,
|
|
102
112
|
cn,
|
|
103
113
|
logger,
|
|
114
|
+
matchesAccept,
|
|
104
115
|
setStoreLog,
|
|
105
116
|
useAnchoredPanel,
|
|
106
117
|
useAnchoredRect,
|
|
@@ -108,6 +119,7 @@ export {
|
|
|
108
119
|
useBodyScrollLock,
|
|
109
120
|
useCloseTransition,
|
|
110
121
|
useEscapeKey,
|
|
122
|
+
useFilePicker,
|
|
111
123
|
useFocusTrap,
|
|
112
124
|
useMediaQuery,
|
|
113
125
|
useOutsideClick,
|
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// 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\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\";\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/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/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/account-settings\";\nexport * from \"./components/alert-banner\";\nexport * from \"./components/toggle-group\";\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/date-picker\";\nexport * from \"./components/chart\";\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 { DataTableColumn, DataTableProps, ServerPagination, FilterState } from \"./components/data-table\";\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\";\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\";\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\";\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"],"mappings":";AAMA,cAAc;AACd,SAAS,UAAU;AACnB,SAAS,QAAQ,mBAAmB;AAIpC,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAClC,SAAS,uBAAuB;AAEhC,SAAS,kBAAkB,wBAAwB,yBAAyB;AAM5E,SAAS,cAAc,uBAAuB;AAI9C,SAAS,oBAAoB;AAE7B,SAAS,mBAAmB;AAE5B,SAAS,yBAAyB;AAClC,SAAS,oBAAoB,uBAAuB;AACpD,SAAS,mBAAmB;AAI5B,cAAc;AAKd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,oBAAoB;AAE7B,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAId,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAId,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,qBAAqB;AAG9B,SAAS,iBAAiB;AAI1B,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AASd,cAAc;AACd,cAAc;AACd,cAAc;AAgBd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAGd,cAAc;AAMd,cAAc;AACd,cAAc;","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// 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\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\";\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/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\";\nexport * from \"./components/danger-confirm\";\nexport * from \"./components/swatch-picker\";\nexport * from \"./components/icon-picker\";\nexport * from \"./components/choice-card\";\nexport * from \"./components/autocomplete\";\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/account-settings\";\nexport * from \"./components/alert-banner\";\nexport * from \"./components/toggle-group\";\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/date-picker\";\nexport * from \"./components/chart\";\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 { DataTableColumn, DataTableProps, ServerPagination, FilterState } from \"./components/data-table\";\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\";\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\";\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\";\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"],"mappings":";AAMA,cAAc;AACd,SAAS,UAAU;AACnB,SAAS,QAAQ,mBAAmB;AAIpC,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAClC,SAAS,uBAAuB;AAEhC,SAAS,kBAAkB,wBAAwB,yBAAyB;AAM5E,SAAS,cAAc,uBAAuB;AAI9C,SAAS,oBAAoB;AAE7B,SAAS,mBAAmB;AAE5B,SAAS,yBAAyB;AAClC,SAAS,oBAAoB,uBAAuB;AACpD,SAAS,mBAAmB;AAI5B,cAAc;AAKd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,oBAAoB;AAE7B,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAId,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,SAAS,YAAY,eAAe,eAAe,kCAAkC;AAUrF,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAId,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,qBAAqB;AAG9B,SAAS,iBAAiB;AAI1B,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AASd,cAAc;AACd,cAAc;AACd,cAAc;AAgBd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAGd,cAAc;AAMd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One lexer for "paste the table out of a spreadsheet", and the three rules for the
|
|
3
|
+
* comma. `@eifi1/ui-kit/table-text` — pure functions over strings, no React.
|
|
4
|
+
*
|
|
5
|
+
* Moved here from Lenkbank (`shared/lib/parse-table.ts`), where three screens took a
|
|
6
|
+
* table off somebody's clipboard — a measured-table grid, the text view beside it, and
|
|
7
|
+
* a page that reads a recorder's setpoint/actual files — and each had grown its own
|
|
8
|
+
* reader. They disagreed, and not in the harmless way: a whitespace-separated German
|
|
9
|
+
* export was read as six columns of nonsense by two of them and as nothing at all by
|
|
10
|
+
* the third, with no message either way. The lexing is one problem (lines, a
|
|
11
|
+
* separator, fields, a header, numbers) and it is solved once here, so the next app
|
|
12
|
+
* that imports a CSV does not write the comma rules wrong a second time.
|
|
13
|
+
*
|
|
14
|
+
* **What is genuinely different between callers is where the decision about the
|
|
15
|
+
* comma is taken**, and that is a parameter rather than a constant. A comma is the
|
|
16
|
+
* decimal mark in every German export and the column separator in every English CSV,
|
|
17
|
+
* and no single rule serves both without regressing one of them. So the rules are
|
|
18
|
+
* named instead of one being picked:
|
|
19
|
+
*
|
|
20
|
+
* * **`"whole-text"`** — the *file* door. A recorder writes one file in one
|
|
21
|
+
* convention, so the separator and the decimal mark are decided once, from the
|
|
22
|
+
* whole text, and stated back to the reader (`decimalComma`) where they can see
|
|
23
|
+
* what was assumed. Deciding once is what lets one damaged line be *counted*
|
|
24
|
+
* rather than re-guessed into a different convention than the lines around it.
|
|
25
|
+
* * **`"per-line"`** — the *paste* door. What arrives on a clipboard is a few rows
|
|
26
|
+
* out of a spreadsheet, sometimes one row, sometimes a line somebody typed. There
|
|
27
|
+
* is no file to be consistent with, and a line must not change meaning because of
|
|
28
|
+
* another line somewhere else in the box — so each line is read on its own
|
|
29
|
+
* evidence.
|
|
30
|
+
* * **unconditional** — one cell (`cellNumber` / `isCellNumber`). A single cell has
|
|
31
|
+
* no columns in it, so a comma in one cannot be separating anything and is always
|
|
32
|
+
* a decimal mark. That is not a table rule at all, which is why it is a pair of
|
|
33
|
+
* one-liners beside the others rather than an option on them.
|
|
34
|
+
*
|
|
35
|
+
* What this deliberately does not do:
|
|
36
|
+
*
|
|
37
|
+
* * **Thousands separators.** `1.234,5` and `1,234.5` are both a number with two
|
|
38
|
+
* marks in it, and telling the grouping mark from the decimal mark needs a rule
|
|
39
|
+
* about digit runs that would then have to be right for a three-digit integer
|
|
40
|
+
* too. A field carrying one is reported as a line that could not be read, with
|
|
41
|
+
* its line number, which is something a reader can act on. Guessing is not.
|
|
42
|
+
* * **Empty cells.** An empty field is dropped rather than held open as a hole, so a
|
|
43
|
+
* row with a dropped channel in the middle of it shifts left. Keeping the hole
|
|
44
|
+
* would mean reading `1;2;3;` — a trailing separator, which every spreadsheet
|
|
45
|
+
* writes — as a four-column row. It is a known gap, not an oversight.
|
|
46
|
+
* * **Quoted fields.** No `"a;b"` escaping. These are numbers; the only text in them
|
|
47
|
+
* is the header line, and a header field with a separator in it costs a column
|
|
48
|
+
* name, not a measurement.
|
|
49
|
+
*/
|
|
50
|
+
/** Where the decision about the comma is taken. See the module docstring: the
|
|
51
|
+
* file door decides once for the whole text, the paste door decides per line. */
|
|
52
|
+
type DecimalRule = "per-line" | "whole-text";
|
|
53
|
+
interface ParseTableOptions {
|
|
54
|
+
decimal: DecimalRule;
|
|
55
|
+
/**
|
|
56
|
+
* How many columns the caller already knows the table has. A grid with fixed
|
|
57
|
+
* columns knows its width before a number arrives: anything past it is sliced
|
|
58
|
+
* off — an export with a trailing timestamp column is not an error worth
|
|
59
|
+
* refusing — and a line with fewer is reported. Omitted where the width is the
|
|
60
|
+
* file's own answer.
|
|
61
|
+
*/
|
|
62
|
+
columns?: number;
|
|
63
|
+
/**
|
|
64
|
+
* How many leading lines that are not rows of numbers may be a header.
|
|
65
|
+
* Default 1, the name row. {@link parseRows} passes 2, because a bench export
|
|
66
|
+
* writes the units on a second line under the names.
|
|
67
|
+
*/
|
|
68
|
+
headerLines?: number;
|
|
69
|
+
}
|
|
70
|
+
interface ParsedTable {
|
|
71
|
+
rows: number[][];
|
|
72
|
+
/** The first header line's fields — the column *names*. A units line under it
|
|
73
|
+
* is absorbed and not returned: what a column is measured in is the caller's to
|
|
74
|
+
* say (its column definitions), and a second list of strings here would be a
|
|
75
|
+
* second answer to that. */
|
|
76
|
+
header: string[] | null;
|
|
77
|
+
/** Whether a comma was read as a decimal mark. Under `"per-line"` this is true
|
|
78
|
+
* if any line was read that way, and it exists for the reader: a guess
|
|
79
|
+
* nobody can see is a guess nobody can correct. */
|
|
80
|
+
decimalComma: boolean;
|
|
81
|
+
/** Line numbers — 1-based, counted in the text as it was handed over, blank
|
|
82
|
+
* lines included — that held something which is not a row of numbers. A list
|
|
83
|
+
* rather than a count, because one door names the first one and the other
|
|
84
|
+
* counts them. */
|
|
85
|
+
skipped: number[];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The columns of one line, as text, with the decimal mark normalised to a point.
|
|
89
|
+
*
|
|
90
|
+
* Text rather than numbers because a grid holds cells as strings: a pasted
|
|
91
|
+
* field that is not a number belongs in the cell it landed in, marked, where the
|
|
92
|
+
* person who pasted it can see which column went wrong. Dropping it here would
|
|
93
|
+
* shift every column after it and lose the evidence.
|
|
94
|
+
*/
|
|
95
|
+
declare function splitRow(line: string): string[];
|
|
96
|
+
/**
|
|
97
|
+
* A pasted table, or the lines of it that are not one.
|
|
98
|
+
*
|
|
99
|
+
* The lexer both doors are built on. It reads lines, drops blanks and `#`
|
|
100
|
+
* banners, decides what separates the columns, takes the header off the top and
|
|
101
|
+
* converts what is left.
|
|
102
|
+
*/
|
|
103
|
+
declare function parseTable(text: string, options: ParseTableOptions): ParsedTable;
|
|
104
|
+
/**
|
|
105
|
+
* The paste door: a fixed number of columns, and the line that stopped it.
|
|
106
|
+
*
|
|
107
|
+
* Read per line, with up to two header lines (names, then units). It answers with a
|
|
108
|
+
* line number rather than with what it managed to read, because half a pasted
|
|
109
|
+
* sweep saved as a measurement is worse than a refused paste — and because a
|
|
110
|
+
* table that comes back **empty** is the one answer a reader cannot act on: it
|
|
111
|
+
* looks exactly like a paste that did not happen. So text that has content and
|
|
112
|
+
* produced no row at all is an error naming its first unreadable line, never
|
|
113
|
+
* `{ rows: [] }`.
|
|
114
|
+
*/
|
|
115
|
+
declare function parseRows(text: string, columns: number): {
|
|
116
|
+
rows: number[][];
|
|
117
|
+
} | {
|
|
118
|
+
error: number;
|
|
119
|
+
};
|
|
120
|
+
/** One cell as a number. Unconditional: a cell has no columns in it, so a comma
|
|
121
|
+
* in one is a decimal mark and nothing else. */
|
|
122
|
+
declare const cellNumber: (cell: string) => number;
|
|
123
|
+
/** Whether one cell holds a number yet. An empty cell is not one — it is a hole
|
|
124
|
+
* in the measurement, which is a different thing from a zero. */
|
|
125
|
+
declare const isCellNumber: (cell: string) => boolean;
|
|
126
|
+
|
|
127
|
+
export { type DecimalRule, type ParseTableOptions, type ParsedTable, cellNumber, isCellNumber, parseRows, parseTable, splitRow };
|