@eifi1/ui-kit 0.22.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -25
- package/dist/chart.d.ts +8 -7
- package/dist/components/amount-input.d.ts +34 -7
- package/dist/components/amount-input.js +14 -10
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/autocomplete.d.ts +26 -0
- package/dist/components/autocomplete.js +164 -137
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/button-group.d.ts +8 -7
- package/dist/components/calculator.d.ts +8 -7
- package/dist/components/column-mapper.d.ts +235 -0
- package/dist/components/column-mapper.js +411 -0
- package/dist/components/column-mapper.js.map +1 -0
- package/dist/components/combobox-core.d.ts +39 -2
- package/dist/components/combobox-core.js +29 -6
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox.d.ts +113 -3
- package/dist/components/combobox.js +456 -313
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/confirm-dialog.d.ts +8 -7
- package/dist/components/confirm-dialog.js +7 -8
- package/dist/components/confirm-dialog.js.map +1 -1
- package/dist/components/copy-button.d.ts +5 -4
- package/dist/components/country-select.d.ts +50 -7
- package/dist/components/country-select.js +65 -9
- package/dist/components/country-select.js.map +1 -1
- package/dist/components/danger-confirm.d.ts +8 -7
- package/dist/components/danger-confirm.js +64 -7
- package/dist/components/danger-confirm.js.map +1 -1
- package/dist/components/date-picker.d.ts +41 -0
- package/dist/components/date-picker.js +269 -8
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/entity-combobox.d.ts +48 -2
- package/dist/components/entity-combobox.js +159 -114
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/facing-pair.d.ts +8 -7
- package/dist/components/field-parts.d.ts +116 -6
- package/dist/components/field-parts.js +84 -0
- package/dist/components/field-parts.js.map +1 -1
- package/dist/components/field-strip.d.ts +105 -0
- package/dist/components/field-strip.js +46 -0
- package/dist/components/field-strip.js.map +1 -0
- package/dist/components/file-button.d.ts +8 -7
- package/dist/components/file-dropzone.d.ts +8 -7
- package/dist/components/form-actions.d.ts +8 -7
- package/dist/components/form-actions.js +23 -3
- package/dist/components/form-actions.js.map +1 -1
- package/dist/components/iban-input.d.ts +8 -7
- package/dist/components/icon-picker.d.ts +10 -1
- package/dist/components/icon-picker.js +12 -4
- package/dist/components/icon-picker.js.map +1 -1
- package/dist/components/language-select.d.ts +8 -7
- package/dist/components/money-field.d.ts +11 -7
- package/dist/components/money-field.js.map +1 -1
- package/dist/components/month-picker.js +2 -1
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-entity-combobox.d.ts +31 -2
- package/dist/components/multi-entity-combobox.js +152 -103
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/number-field.d.ts +8 -7
- package/dist/components/number-input.d.ts +8 -7
- package/dist/components/numpad-sheet.d.ts +8 -7
- package/dist/components/phone-input.d.ts +8 -7
- package/dist/components/reauth-dialog.d.ts +2 -2
- package/dist/components/reauth-dialog.js +6 -8
- package/dist/components/reauth-dialog.js.map +1 -1
- package/dist/components/series-chart.d.ts +8 -7
- package/dist/components/settings-fields.d.ts +8 -7
- package/dist/components/share-card.d.ts +8 -7
- package/dist/components/swatch-picker.d.ts +17 -1
- package/dist/components/swatch-picker.js +10 -4
- package/dist/components/swatch-picker.js.map +1 -1
- package/dist/components/text-link.d.ts +8 -7
- package/dist/components/tile-radio.d.ts +20 -0
- package/dist/components/tile-radio.js +25 -8
- package/dist/components/tile-radio.js.map +1 -1
- package/dist/components/time-input.d.ts +8 -7
- package/dist/components/toggle-group.js +2 -2
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/trigger-aria.d.ts +3 -0
- package/dist/components/trigger-aria.js +3 -1
- package/dist/components/trigger-aria.js.map +1 -1
- package/dist/components/ui.d.ts +5 -4
- package/dist/components/ui.js +60 -28
- package/dist/components/ui.js.map +1 -1
- package/dist/feedback/feedback-attachment.d.ts +66 -1
- package/dist/feedback/feedback-attachment.js +185 -65
- package/dist/feedback/feedback-attachment.js.map +1 -1
- package/dist/feedback/feedback-dialog.d.ts +66 -1
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-inbox.d.ts +67 -252
- package/dist/feedback/feedback-inbox.js.map +1 -1
- package/dist/feedback/feedback-thread.d.ts +66 -287
- package/dist/feedback/feedback-thread.js +16 -3
- package/dist/feedback/feedback-thread.js.map +1 -1
- package/dist/{kit-labels-R8mIAc9N.d.ts → feedback-DOwPu-Il.d.ts} +1273 -30
- package/dist/feedback.d.ts +65 -3
- package/dist/hooks/use-file-drop.d.ts +8 -7
- package/dist/i18n/defaults.d.ts +8 -7
- package/dist/i18n/defaults.js +3 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.d.ts +8 -7
- package/dist/i18n/german.js +36 -2
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +5 -4
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/languages.d.ts +8 -7
- package/dist/i18n/locales/de-CH.d.ts +8 -7
- package/dist/i18n/locales/en.d.ts +8 -7
- package/dist/i18n/locales/en.js +7 -0
- package/dist/i18n/locales/en.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +8 -7
- package/dist/i18n/locales/es.js +37 -2
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +8 -7
- package/dist/i18n/locales/fr.js +36 -2
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +8 -7
- package/dist/i18n/locales/hu.js +38 -2
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +8 -7
- package/dist/i18n/locales/it.js +37 -2
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +8 -7
- package/dist/i18n/locales/zh.js +34 -2
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.d.ts +8 -7
- package/dist/i18n/review.js +20 -1
- package/dist/i18n/review.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/column-mapping.d.ts +81 -0
- package/dist/lib/column-mapping.js +108 -0
- package/dist/lib/column-mapping.js.map +1 -0
- package/dist/lib/strip-fade.d.ts +2 -2
- package/dist/lib/strip-fade.js.map +1 -1
- package/dist/lib/table-text.d.ts +109 -1
- package/dist/lib/table-text.js +122 -1
- package/dist/lib/table-text.js.map +1 -1
- package/dist/rhf/fields.d.ts +142 -13
- package/dist/rhf/fields.js +185 -3
- package/dist/rhf/fields.js.map +1 -1
- package/dist/rhf/form.d.ts +8 -7
- package/dist/rhf.d.ts +9 -8
- package/dist/rhf.js.map +1 -1
- package/dist/shell/app-shell.d.ts +8 -7
- package/dist/shell/top-bar-brand.d.ts +8 -7
- package/dist/shell/topbar-action-menu.d.ts +36 -3
- package/dist/shell/topbar-action-menu.js +74 -33
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell.d.ts +8 -7
- package/dist/table-text.d.ts +1 -1
- package/dist/wizard/stepper-nav.d.ts +38 -9
- package/dist/wizard/stepper-nav.js +4 -0
- package/dist/wizard/stepper-nav.js.map +1 -1
- package/dist/wizard.d.ts +8 -7
- package/package.json +1 -1
- package/src/components/amount-input.tsx +50 -14
- package/src/components/autocomplete.tsx +188 -116
- package/src/components/column-mapper.tsx +768 -0
- package/src/components/combobox-core.tsx +82 -9
- package/src/components/combobox.tsx +655 -335
- package/src/components/confirm-dialog.tsx +12 -8
- package/src/components/country-select.tsx +135 -22
- package/src/components/danger-confirm.tsx +274 -24
- package/src/components/date-picker.tsx +423 -10
- package/src/components/entity-combobox.tsx +243 -129
- package/src/components/field-parts.tsx +224 -5
- package/src/components/field-strip.tsx +149 -0
- package/src/components/form-actions.tsx +52 -5
- package/src/components/icon-picker.tsx +23 -4
- package/src/components/money-field.tsx +3 -0
- package/src/components/month-picker.tsx +2 -1
- package/src/components/multi-entity-combobox.tsx +221 -121
- package/src/components/reauth-dialog.tsx +17 -18
- package/src/components/swatch-picker.tsx +29 -5
- package/src/components/tile-radio.tsx +74 -13
- package/src/components/toggle-group.tsx +2 -2
- package/src/components/trigger-aria.ts +5 -0
- package/src/components/ui.tsx +114 -33
- package/src/feedback/feedback-attachment.tsx +372 -72
- package/src/feedback/feedback-dialog.tsx +7 -3
- package/src/feedback/feedback-inbox.tsx +3 -2
- package/src/feedback/feedback-thread.tsx +112 -9
- package/src/i18n/defaults.ts +2 -0
- package/src/i18n/german.ts +42 -0
- package/src/i18n/kit-labels.tsx +4 -0
- package/src/i18n/locales/en.ts +27 -5
- package/src/i18n/locales/es.ts +41 -0
- package/src/i18n/locales/fr.ts +42 -0
- package/src/i18n/locales/hu.ts +37 -0
- package/src/i18n/locales/it.ts +41 -0
- package/src/i18n/locales/zh.ts +32 -0
- package/src/i18n/review.ts +19 -0
- package/src/index.ts +18 -0
- package/src/lib/column-mapping.ts +234 -0
- package/src/lib/strip-fade.ts +2 -2
- package/src/lib/table-text.ts +271 -0
- package/src/rhf/fields.tsx +421 -6
- package/src/rhf.ts +2 -1
- package/src/shell/topbar-action-menu.tsx +134 -38
- package/src/wizard/stepper-nav.tsx +35 -1
- package/dist/components/field-anatomy.d.ts +0 -95
- package/dist/components/field-anatomy.js +0 -84
- package/dist/components/field-anatomy.js.map +0 -1
- package/dist/feedback-attachment-NhUm7Zga.d.ts +0 -367
- package/src/components/field-anatomy.tsx +0 -190
package/dist/rhf/fields.d.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, ReactElement } from 'react';
|
|
3
3
|
import { FieldValues, FieldPath, ControllerProps, ControllerRenderProps, ControllerFieldState } from 'react-hook-form';
|
|
4
|
-
import {
|
|
4
|
+
import { bK as IbanInputProps, c5 as PhoneInputProps, c9 as SelectProps, bU as InputProps, cu as TextareaProps } from '../feedback-DOwPu-Il.js';
|
|
5
5
|
import { NumberFieldProps } from '../components/number-field.js';
|
|
6
6
|
import { DatePickerProps, DateRangePickerProps } from '../components/date-picker.js';
|
|
7
7
|
import { TimeInputProps } from '../components/time-input.js';
|
|
8
|
+
import { CountrySelectProps } from '../components/country-select.js';
|
|
9
|
+
import { MonthPickerProps } from '../components/month-picker.js';
|
|
8
10
|
import { ToggleGroupBaseProps, ToggleGroupRequiredProps, ToggleGroupClearableProps } from '../components/toggle-group.js';
|
|
9
11
|
import { CheckboxProps } from '../components/checkbox.js';
|
|
10
12
|
import { EntityComboboxProps } from '../components/entity-combobox.js';
|
|
11
|
-
import { ComboboxProps } from '../components/combobox.js';
|
|
13
|
+
import { InlineEntityComboboxProps, ComboboxProps } from '../components/combobox.js';
|
|
12
14
|
import { ComboClearValue } from '../components/combobox-core.js';
|
|
15
|
+
import '../components/tooltip.js';
|
|
16
|
+
import '../hooks/use-anchored-rect.js';
|
|
17
|
+
import '../lib/clipping.js';
|
|
13
18
|
import '../data-table-labels-B7OdnM0S.js';
|
|
14
19
|
import '../components/data-table-sort.js';
|
|
15
20
|
import '../components/swipeable-row.js';
|
|
@@ -19,15 +24,11 @@ import '../components/popover.js';
|
|
|
19
24
|
import '../components/chip.js';
|
|
20
25
|
import 'lucide-react';
|
|
21
26
|
import '../components/field-sync.js';
|
|
22
|
-
import '../components/tooltip.js';
|
|
23
|
-
import '../hooks/use-anchored-rect.js';
|
|
24
|
-
import '../lib/clipping.js';
|
|
25
27
|
import '../wizard/types.js';
|
|
26
28
|
import '../tour/tour.js';
|
|
27
29
|
import '../search/command-palette.js';
|
|
28
30
|
import '../search/global-search.js';
|
|
29
31
|
import '../search/search-index.js';
|
|
30
|
-
import '../components/month-picker.js';
|
|
31
32
|
import '../components/page-contents.js';
|
|
32
33
|
import '../components/series-chart-labels.js';
|
|
33
34
|
import '../components/pie-chart-labels.js';
|
|
@@ -42,9 +43,6 @@ import '../components/dialog-frame.js';
|
|
|
42
43
|
import '../components/modal.js';
|
|
43
44
|
import '../hooks/use-search-param-state.js';
|
|
44
45
|
import '../components/measured-grid.js';
|
|
45
|
-
import '../feedback-attachment-NhUm7Zga.js';
|
|
46
|
-
import '../feedback/feedback-thread.js';
|
|
47
|
-
import '../feedback/feedback-inbox.js';
|
|
48
46
|
import '../components/account-settings-labels.js';
|
|
49
47
|
import '../components/floating-panel.js';
|
|
50
48
|
import '../components/bulk-action-bar.js';
|
|
@@ -69,11 +67,14 @@ import '../components/server-wake.js';
|
|
|
69
67
|
import '../lib/server-wake.js';
|
|
70
68
|
import '../components/translation-review-labels.js';
|
|
71
69
|
import '../lib/translation-review.js';
|
|
72
|
-
import '../components/country-select.js';
|
|
73
70
|
import '../components/inline-edit-field.js';
|
|
74
71
|
import '../lib/iban.js';
|
|
75
72
|
import '../lib/phone.js';
|
|
76
73
|
import '../components/sign-chip.js';
|
|
74
|
+
import '../components/column-mapper.js';
|
|
75
|
+
import '../lib/column-mapping.js';
|
|
76
|
+
import '../lib/table-text.js';
|
|
77
|
+
import '../components/field-parts.js';
|
|
77
78
|
import '../components/number-input.js';
|
|
78
79
|
import '../components/calculator.js';
|
|
79
80
|
import '../components/numpad-sheet.js';
|
|
@@ -232,6 +233,10 @@ type RhfMoneyFieldProps<TFieldValues extends FieldValues = FieldValues, TName ex
|
|
|
232
233
|
* with `rules` as well if a clamp needs explaining. */
|
|
233
234
|
min?: number;
|
|
234
235
|
max?: number;
|
|
236
|
+
/** Classes for the `<input>` — `className` is the item's box. {@link RhfTextField},
|
|
237
|
+
* {@link RhfTextarea} and {@link RhfNumberField} take it; since 0.23 AmountInput
|
|
238
|
+
* does too (keksdose G7: `text-end` for a money column). */
|
|
239
|
+
inputClassName?: string;
|
|
235
240
|
};
|
|
236
241
|
/**
|
|
237
242
|
* The kit's {@link AmountInput}: a money figure with its currency chip and the
|
|
@@ -339,6 +344,77 @@ type RhfPhoneInputProps<TFieldValues extends FieldValues = FieldValues, TName ex
|
|
|
339
344
|
* schema's or `rules`'.
|
|
340
345
|
*/
|
|
341
346
|
declare function RhfPhoneInput<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TTransformed = TFieldValues>({ name, control, rules, label, hint, required, disabled, excludeWhenDisabled, className, ...phoneProps }: RhfPhoneInputProps<TFieldValues, TName, TTransformed>): react.JSX.Element;
|
|
347
|
+
type OwnCountrySelectProps = Omit<CountrySelectProps<boolean>, "value" | "onChange" | "onBlur" | "label" | "hint" | "error" | "invalid" | "disabled" | "className" | "id" | "ref" | "clearable">;
|
|
348
|
+
type RhfCountrySelectProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TTransformed = TFieldValues> = RhfFieldBaseProps<TFieldValues, TName, TTransformed> & OwnCountrySelectProps & {
|
|
349
|
+
/** Offer the picker's clear "×" (and Delete on the trigger) while a country is
|
|
350
|
+
* chosen. A clear stores `clearValue`. */
|
|
351
|
+
clearable?: boolean;
|
|
352
|
+
/** What a clear stores. Default `null`; `""` for a schema that spells "no
|
|
353
|
+
* country" as an empty string (a zod `z.string().max(2)`, kastlan's). The picker
|
|
354
|
+
* reads either back as empty. */
|
|
355
|
+
clearValue?: ComboClearValue;
|
|
356
|
+
/** Classes for the picker — `className` is the item's box. */
|
|
357
|
+
selectClassName?: string;
|
|
358
|
+
};
|
|
359
|
+
/**
|
|
360
|
+
* {@link CountrySelect} bound to one field, which stores the ISO 3166-1 alpha-2 code
|
|
361
|
+
* ("CH", always upper-case), or `clearValue` once cleared (`clearable`). kastlan asked
|
|
362
|
+
* for it (0.22 adoption): its address form wired a `CountrySelect` through
|
|
363
|
+
* {@link RhfField}'s render, and with no ref on the picker react-hook-form's
|
|
364
|
+
* focus-on-error had nothing to focus — the one field on the form a failed submit
|
|
365
|
+
* could not take you to.
|
|
366
|
+
*
|
|
367
|
+
* Bound the way {@link RhfIbanInput} and {@link RhfPhoneInput} are: `field.ref` reaches
|
|
368
|
+
* the trigger (the picker's `ref`, 0.23), the form's error paints the trigger and is
|
|
369
|
+
* the shell's message under it, the hint is the shell's description — so neither is
|
|
370
|
+
* ever handed to the picker, and its box never changes when one comes or goes. The
|
|
371
|
+
* form's label names the trigger together with the chosen country, and is the phone
|
|
372
|
+
* sheet's title. `commit` and `disabledReason` are the picker's own: a country that
|
|
373
|
+
* saves itself stays focusable under a lock and says why.
|
|
374
|
+
*
|
|
375
|
+
* ```tsx
|
|
376
|
+
* <RhfCountrySelect name="country" label="Country" required
|
|
377
|
+
* preferred={["CH", "LI", "DE", "AT", "FR", "IT"]} rules={{ required: "Choose a country" }} />
|
|
378
|
+
* ```
|
|
379
|
+
*/
|
|
380
|
+
declare function RhfCountrySelect<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TTransformed = TFieldValues>({ name, control, rules, label, hint, required, disabled, excludeWhenDisabled, className, clearable, clearValue, selectClassName, labels, ...countryProps }: RhfCountrySelectProps<TFieldValues, TName, TTransformed>): react.JSX.Element;
|
|
381
|
+
type OwnMonthPickerProps = Omit<MonthPickerProps, "value" | "onChange" | "onBlur" | "label" | "hint" | "error" | "invalid" | "disabled" | "className" | "id" | "mode">;
|
|
382
|
+
/** `mode` picks what the form stores, and `valueAsNumber` is only offered for a year. */
|
|
383
|
+
type RhfMonthPickerMode = {
|
|
384
|
+
/** A month, stored as `"YYYY-MM"` (the default). */
|
|
385
|
+
mode?: "month";
|
|
386
|
+
valueAsNumber?: undefined;
|
|
387
|
+
} | {
|
|
388
|
+
/** A year, stored as `"YYYY"` — or as a number with `valueAsNumber`. */
|
|
389
|
+
mode: "year";
|
|
390
|
+
/** Store the year as a number (`2026`) rather than `"2026"` — kastlan's budget
|
|
391
|
+
* `fiscal_year` is an integer column. A number in the form reads back as its
|
|
392
|
+
* year. */
|
|
393
|
+
valueAsNumber?: boolean;
|
|
394
|
+
};
|
|
395
|
+
type RhfMonthPickerProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TTransformed = TFieldValues> = RhfFieldBaseProps<TFieldValues, TName, TTransformed> & OwnMonthPickerProps & {
|
|
396
|
+
/** Classes for the picker — `className` is the item's box. As {@link RhfDateField}'s. */
|
|
397
|
+
inputClassName?: string;
|
|
398
|
+
} & RhfMonthPickerMode;
|
|
399
|
+
/**
|
|
400
|
+
* {@link MonthPicker} bound to one field: a month as `"YYYY-MM"`, or with `mode="year"` a
|
|
401
|
+
* year as `"YYYY"` (`valueAsNumber` stores `2026`). kastlan asked for it with
|
|
402
|
+
* {@link RhfCountrySelect}: its budget wizard's fiscal year was a `MonthPicker
|
|
403
|
+
* mode="year"` inside {@link RhfField}'s render — the `String()` in, the `Number()`
|
|
404
|
+
* out, `invalid` by hand — and a failed submit could not focus it, because the picker
|
|
405
|
+
* forwards no ref.
|
|
406
|
+
*
|
|
407
|
+
* Bound as {@link RhfDateField} is: a focus handle finds the trigger by its id, so
|
|
408
|
+
* focus-on-error lands there; the form's error paints the trigger and is the shell's
|
|
409
|
+
* message; the hint is the shell's description; neither is handed to the picker, so
|
|
410
|
+
* its box never changes. Picking marks the field touched.
|
|
411
|
+
*
|
|
412
|
+
* ```tsx
|
|
413
|
+
* <RhfMonthPicker name="fiscalYear" label="Fiscal year" mode="year" valueAsNumber
|
|
414
|
+
* min="2020" max="2029" rules={{ required: "Choose a year" }} />
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
417
|
+
declare function RhfMonthPicker<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TTransformed = TFieldValues>({ name, control, rules, label, hint, required, disabled, excludeWhenDisabled, className, inputClassName, mode, valueAsNumber, ...pickerProps }: RhfMonthPickerProps<TFieldValues, TName, TTransformed>): react.JSX.Element;
|
|
342
418
|
interface RhfSelectOption {
|
|
343
419
|
value: string | number;
|
|
344
420
|
label: ReactNode;
|
|
@@ -407,7 +483,7 @@ type RhfToggleGroupProps<TFieldValues extends FieldValues = FieldValues, TName e
|
|
|
407
483
|
* field still needs answering is the schema's or `rules`' to say.
|
|
408
484
|
*/
|
|
409
485
|
declare function RhfToggleGroup<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, T extends string = string, TTransformed = TFieldValues>({ name, control, rules, label, hint, required, disabled, excludeWhenDisabled, className, ...groupProps }: RhfToggleGroupProps<TFieldValues, TName, T, TTransformed>): react.JSX.Element;
|
|
410
|
-
type RhfComboboxProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, V extends string | number = string | number, TTransformed = TFieldValues> = RhfFieldBaseProps<TFieldValues, TName, TTransformed> & Pick<EntityComboboxProps<V>, "options" | "loadOptions" | "loading" | "placeholder" | "searchPlaceholder" | "emptyLabel" | "clearable" | "clearLabel" | "onCreate" | "createLabel" | "filter" | "minChars" | "debounceMs"> & {
|
|
486
|
+
type RhfComboboxProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, V extends string | number = string | number, TTransformed = TFieldValues> = RhfFieldBaseProps<TFieldValues, TName, TTransformed> & Pick<EntityComboboxProps<V>, "options" | "loadOptions" | "loading" | "placeholder" | "searchPlaceholder" | "emptyLabel" | "clearable" | "clearLabel" | "closeLabel" | "onCreate" | "createLabel" | "createEmptyLabel" | "createCommit" | "commit" | "disabledReason" | "filter" | "minChars" | "debounceMs" | "aria-label"> & {
|
|
411
487
|
/** What a clear stores — the picker's `clearValue`. Default `null`; `""` for a
|
|
412
488
|
* schema that spells "no choice" as an empty string. */
|
|
413
489
|
clearValue?: ComboClearValue;
|
|
@@ -418,9 +494,62 @@ type RhfComboboxProps<TFieldValues extends FieldValues = FieldValues, TName exte
|
|
|
418
494
|
* The kit's {@link EntityCombobox}: an id-keyed pick from `options` or `loadOptions`.
|
|
419
495
|
* Stores the option's `value`, or `clearValue` on a clear (only offered with
|
|
420
496
|
* `clearable`).
|
|
497
|
+
*
|
|
498
|
+
* 0.24: `field.ref` goes through the picker's own `ref` to its trigger (it used to be
|
|
499
|
+
* a focus handle that found the trigger by id — the same element, now by the route
|
|
500
|
+
* every other binding takes); the write lock (`commit`, `disabledReason`), the create
|
|
501
|
+
* row's `createEmptyLabel` / `createCommit`, `closeLabel` and `aria-label` pass
|
|
502
|
+
* through; and the form's label titles the phone sheet, which fell back to the
|
|
503
|
+
* placeholder. For the INLINE picker — a text input, the account field typed into —
|
|
504
|
+
* see {@link RhfInlineEntityCombobox}.
|
|
421
505
|
*/
|
|
422
506
|
declare function RhfCombobox<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, V extends string | number = string | number, TTransformed = TFieldValues>({ name, control, rules, label, hint, required, disabled, excludeWhenDisabled, className, clearValue, comboClassName, ...comboProps }: RhfComboboxProps<TFieldValues, TName, V, TTransformed>): react.JSX.Element;
|
|
423
|
-
type
|
|
507
|
+
type OwnInlineEntityComboboxProps<V extends string | number> = Omit<InlineEntityComboboxProps<V, ComboClearValue>, "value" | "defaultValue" | "onChange" | "onBlur" | "label" | "hint" | "error" | "invalid" | "disabled" | "className" | "id" | "ref" | "clearValue">;
|
|
508
|
+
type RhfInlineEntityComboboxProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, V extends string | number = string | number, TTransformed = TFieldValues> = RhfFieldBaseProps<TFieldValues, TName, TTransformed> & OwnInlineEntityComboboxProps<V> & {
|
|
509
|
+
/** What a clear stores — emptying the text, or the "×" with `clearable`. Default
|
|
510
|
+
* `null`; `""` for a schema that spells "no choice" as an empty string. The
|
|
511
|
+
* picker reads either back as empty. */
|
|
512
|
+
clearValue?: ComboClearValue;
|
|
513
|
+
/** Classes for the picker — `className` is the item's box. As {@link RhfCombobox}'s. */
|
|
514
|
+
comboClassName?: string;
|
|
515
|
+
};
|
|
516
|
+
/**
|
|
517
|
+
* {@link InlineEntityCombobox} bound to one field, which stores the chosen option's
|
|
518
|
+
* `value` (an id), or `clearValue` once the text is emptied or the "×" pressed.
|
|
519
|
+
*
|
|
520
|
+
* kastlan asked for it (0.24): its account picker IS an `InlineEntityCombobox` — the
|
|
521
|
+
* account number is typed straight into the field — and the budget line-item form
|
|
522
|
+
* wired it through {@link RhfField}'s render. The picker took no `ref`, so react-hook-
|
|
523
|
+
* form's focus-on-error had nothing to focus: a line item saved without an account
|
|
524
|
+
* failed its submit and left the caret where it was, the one field on the form a
|
|
525
|
+
* failed submit could not take you to. (The same gap {@link RhfCountrySelect} closed
|
|
526
|
+
* for the address form's country in 0.23.)
|
|
527
|
+
*
|
|
528
|
+
* Bound the way {@link RhfCountrySelect} is: `field.ref` reaches the `<input>` (the
|
|
529
|
+
* picker's `ref`, 0.24), the form's error paints the input and is the shell's message
|
|
530
|
+
* under it, and the hint is the shell's description — so neither is ever handed to the
|
|
531
|
+
* picker, and its box never changes when one comes or goes. The form's label names
|
|
532
|
+
* the input through `<label for>` and titles the phone sheet (`sheetTitle`); the picker
|
|
533
|
+
* draws no floating label of its own. Focus leaving the picker marks the field
|
|
534
|
+
* touched.
|
|
535
|
+
*
|
|
536
|
+
* Everything else is the picker's and passes through: `commit` and `disabledReason`
|
|
537
|
+
* (a picker whose choice saves stays focusable under a lock and says why), `clearable`,
|
|
538
|
+
* `autoFocus`, `aria-label` for an unlabelled cell, and the create row — `onCreate`,
|
|
539
|
+
* `createLabel`, `createEmptyLabel`, `createCommit`. Making the record is the
|
|
540
|
+
* caller's, and so is storing its id once it exists:
|
|
541
|
+
*
|
|
542
|
+
* ```tsx
|
|
543
|
+
* <RhfInlineEntityCombobox<LineItem, "account_id", number>
|
|
544
|
+
* name="account_id" label="Account" required options={accounts}
|
|
545
|
+
* rules={{ required: "Choose an account" }}
|
|
546
|
+
* onCreate={async (name) => form.setValue("account_id", (await createAccount(name)).id)} />
|
|
547
|
+
* ```
|
|
548
|
+
*
|
|
549
|
+
* For the button-shaped picker with an async `loadOptions`, see {@link RhfCombobox}.
|
|
550
|
+
*/
|
|
551
|
+
declare function RhfInlineEntityCombobox<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, V extends string | number = string | number, TTransformed = TFieldValues>({ name, control, rules, label, hint, required, disabled, excludeWhenDisabled, className, clearValue, comboClassName, ...comboProps }: RhfInlineEntityComboboxProps<TFieldValues, TName, V, TTransformed>): react.JSX.Element;
|
|
552
|
+
type RhfTextComboboxProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TTransformed = TFieldValues> = RhfFieldBaseProps<TFieldValues, TName, TTransformed> & Pick<ComboboxProps, "options" | "placeholder" | "groupBy" | "maxSuggestions" | "searchPlaceholder" | "createLabel" | "optionAdornment" | "autoFocus" | "aria-label" | "closeLabel" | "commit" | "disabledReason"> & {
|
|
424
553
|
/** Classes for the combobox. */
|
|
425
554
|
comboClassName?: string;
|
|
426
555
|
};
|
|
@@ -430,4 +559,4 @@ type RhfTextComboboxProps<TFieldValues extends FieldValues = FieldValues, TName
|
|
|
430
559
|
*/
|
|
431
560
|
declare function RhfTextCombobox<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TTransformed = TFieldValues>({ name, control, rules, label, hint, required, disabled, excludeWhenDisabled, className, comboClassName, ...comboProps }: RhfTextComboboxProps<TFieldValues, TName, TTransformed>): react.JSX.Element;
|
|
432
561
|
|
|
433
|
-
export { RhfCheckbox, type RhfCheckboxProps, RhfCombobox, type RhfComboboxProps, RhfDateField, type RhfDateFieldProps, RhfDateRangePicker, type RhfDateRangePickerProps, RhfField, type RhfFieldBaseProps, type RhfFieldProps, type RhfFieldRenderContext, RhfIbanInput, type RhfIbanInputProps, RhfIntegerField, type RhfIntegerFieldProps, RhfMoneyField, type RhfMoneyFieldProps, RhfNumberField, type RhfNumberFieldProps, RhfPhoneInput, type RhfPhoneInputProps, RhfSelect, type RhfSelectOption, type RhfSelectProps, RhfTextCombobox, type RhfTextComboboxProps, RhfTextField, type RhfTextFieldProps, RhfTextarea, type RhfTextareaProps, RhfTimeInput, type RhfTimeInputProps, RhfToggleGroup, type RhfToggleGroupProps };
|
|
562
|
+
export { RhfCheckbox, type RhfCheckboxProps, RhfCombobox, type RhfComboboxProps, RhfCountrySelect, type RhfCountrySelectProps, RhfDateField, type RhfDateFieldProps, RhfDateRangePicker, type RhfDateRangePickerProps, RhfField, type RhfFieldBaseProps, type RhfFieldProps, type RhfFieldRenderContext, RhfIbanInput, type RhfIbanInputProps, RhfInlineEntityCombobox, type RhfInlineEntityComboboxProps, RhfIntegerField, type RhfIntegerFieldProps, RhfMoneyField, type RhfMoneyFieldProps, RhfMonthPicker, type RhfMonthPickerProps, RhfNumberField, type RhfNumberFieldProps, RhfPhoneInput, type RhfPhoneInputProps, RhfSelect, type RhfSelectOption, type RhfSelectProps, RhfTextCombobox, type RhfTextComboboxProps, RhfTextField, type RhfTextFieldProps, RhfTextarea, type RhfTextareaProps, RhfTimeInput, type RhfTimeInputProps, RhfToggleGroup, type RhfToggleGroupProps };
|
package/dist/rhf/fields.js
CHANGED
|
@@ -15,12 +15,17 @@ import {
|
|
|
15
15
|
import { TimeInput } from "../components/time-input.js";
|
|
16
16
|
import { IbanInput } from "../components/iban-input.js";
|
|
17
17
|
import { PhoneInput } from "../components/phone-input.js";
|
|
18
|
+
import { CountrySelect } from "../components/country-select.js";
|
|
19
|
+
import { MonthPicker } from "../components/month-picker.js";
|
|
18
20
|
import {
|
|
19
21
|
ToggleGroup
|
|
20
22
|
} from "../components/toggle-group.js";
|
|
21
23
|
import { Checkbox } from "../components/checkbox.js";
|
|
22
24
|
import { EntityCombobox } from "../components/entity-combobox.js";
|
|
23
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
Combobox,
|
|
27
|
+
InlineEntityCombobox
|
|
28
|
+
} from "../components/combobox.js";
|
|
24
29
|
import { cn } from "../lib/cn.js";
|
|
25
30
|
function hasContent(node) {
|
|
26
31
|
return node !== void 0 && node !== null && node !== false && node !== "";
|
|
@@ -631,6 +636,126 @@ function RhfPhoneInput({
|
|
|
631
636
|
}
|
|
632
637
|
);
|
|
633
638
|
}
|
|
639
|
+
function RhfCountrySelect({
|
|
640
|
+
name,
|
|
641
|
+
control,
|
|
642
|
+
rules,
|
|
643
|
+
label,
|
|
644
|
+
hint,
|
|
645
|
+
required,
|
|
646
|
+
disabled,
|
|
647
|
+
excludeWhenDisabled,
|
|
648
|
+
className,
|
|
649
|
+
clearable,
|
|
650
|
+
clearValue = null,
|
|
651
|
+
selectClassName,
|
|
652
|
+
labels,
|
|
653
|
+
...countryProps
|
|
654
|
+
}) {
|
|
655
|
+
const labelled = hasContent(label);
|
|
656
|
+
const ownLabels = typeof label === "string" ? { country: label, ...labels } : labels;
|
|
657
|
+
return /* @__PURE__ */ jsx(
|
|
658
|
+
RhfField,
|
|
659
|
+
{
|
|
660
|
+
...{ name, control, rules, label, hint, required, disabled, excludeWhenDisabled, className },
|
|
661
|
+
render: ({ field, invalid, labelId }) => {
|
|
662
|
+
const value = field.value;
|
|
663
|
+
return (
|
|
664
|
+
// FormControl clones this element with `id` / `aria-describedby` /
|
|
665
|
+
// `aria-invalid`, which the picker routes to its trigger.
|
|
666
|
+
/* @__PURE__ */ jsx(
|
|
667
|
+
CountrySelect,
|
|
668
|
+
{
|
|
669
|
+
"aria-required": required || void 0,
|
|
670
|
+
"aria-labelledby": labelled ? labelId : void 0,
|
|
671
|
+
...countryProps,
|
|
672
|
+
labels: ownLabels,
|
|
673
|
+
className: selectClassName,
|
|
674
|
+
ref: field.ref,
|
|
675
|
+
value: typeof value === "string" ? value : null,
|
|
676
|
+
clearable,
|
|
677
|
+
onChange: (code) => field.onChange(code ?? clearValue),
|
|
678
|
+
onBlur: field.onBlur,
|
|
679
|
+
disabled: field.disabled,
|
|
680
|
+
invalid
|
|
681
|
+
}
|
|
682
|
+
)
|
|
683
|
+
);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
function MonthControl({
|
|
689
|
+
field,
|
|
690
|
+
invalid,
|
|
691
|
+
id,
|
|
692
|
+
valueAsNumber,
|
|
693
|
+
mode,
|
|
694
|
+
inputClassName,
|
|
695
|
+
pickerProps,
|
|
696
|
+
required,
|
|
697
|
+
...aria
|
|
698
|
+
}) {
|
|
699
|
+
useFocusHandle(field.ref, () => document.getElementById(id));
|
|
700
|
+
const value = field.value;
|
|
701
|
+
return /* @__PURE__ */ jsx(
|
|
702
|
+
MonthPicker,
|
|
703
|
+
{
|
|
704
|
+
...pickerProps,
|
|
705
|
+
...aria,
|
|
706
|
+
"aria-required": required || void 0,
|
|
707
|
+
id,
|
|
708
|
+
mode,
|
|
709
|
+
value: value === null || value === void 0 ? "" : String(value),
|
|
710
|
+
onChange: (key) => {
|
|
711
|
+
field.onChange(mode === "year" && valueAsNumber ? Number(key) : key);
|
|
712
|
+
field.onBlur();
|
|
713
|
+
},
|
|
714
|
+
disabled: field.disabled,
|
|
715
|
+
invalid,
|
|
716
|
+
className: inputClassName
|
|
717
|
+
}
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
function RhfMonthPicker({
|
|
721
|
+
name,
|
|
722
|
+
control,
|
|
723
|
+
rules,
|
|
724
|
+
label,
|
|
725
|
+
hint,
|
|
726
|
+
required,
|
|
727
|
+
disabled,
|
|
728
|
+
excludeWhenDisabled,
|
|
729
|
+
className,
|
|
730
|
+
inputClassName,
|
|
731
|
+
mode,
|
|
732
|
+
valueAsNumber,
|
|
733
|
+
...pickerProps
|
|
734
|
+
}) {
|
|
735
|
+
return /* @__PURE__ */ jsx(
|
|
736
|
+
RhfField,
|
|
737
|
+
{
|
|
738
|
+
...{ name, control, rules, label, hint, required, disabled, excludeWhenDisabled, className },
|
|
739
|
+
render: ({ field, invalid, id }) => (
|
|
740
|
+
// FormControl clones this element with `aria-describedby` / `aria-invalid`,
|
|
741
|
+
// which MonthControl hands on to the picker's trigger.
|
|
742
|
+
/* @__PURE__ */ jsx(
|
|
743
|
+
MonthControl,
|
|
744
|
+
{
|
|
745
|
+
field,
|
|
746
|
+
invalid,
|
|
747
|
+
id,
|
|
748
|
+
mode,
|
|
749
|
+
valueAsNumber,
|
|
750
|
+
inputClassName,
|
|
751
|
+
pickerProps,
|
|
752
|
+
required
|
|
753
|
+
}
|
|
754
|
+
)
|
|
755
|
+
)
|
|
756
|
+
}
|
|
757
|
+
);
|
|
758
|
+
}
|
|
634
759
|
function RhfSelect({
|
|
635
760
|
name,
|
|
636
761
|
control,
|
|
@@ -809,10 +934,11 @@ function EntityControl({
|
|
|
809
934
|
describedBy,
|
|
810
935
|
clearValue,
|
|
811
936
|
comboClassName,
|
|
937
|
+
sheetTitle,
|
|
938
|
+
focusRef,
|
|
812
939
|
comboProps
|
|
813
940
|
}) {
|
|
814
941
|
const box = useRef(null);
|
|
815
|
-
useFocusHandle(field.ref, () => document.getElementById(id));
|
|
816
942
|
const onBlur = field.onBlur;
|
|
817
943
|
useLayoutEffect(() => {
|
|
818
944
|
const el = box.current;
|
|
@@ -824,7 +950,9 @@ function EntityControl({
|
|
|
824
950
|
return /* @__PURE__ */ jsx("div", { ref: box, children: /* @__PURE__ */ jsx(
|
|
825
951
|
EntityCombobox,
|
|
826
952
|
{
|
|
953
|
+
sheetTitle,
|
|
827
954
|
...comboProps,
|
|
955
|
+
ref: focusRef,
|
|
828
956
|
className: comboClassName,
|
|
829
957
|
id,
|
|
830
958
|
"aria-describedby": describedBy,
|
|
@@ -869,12 +997,58 @@ function RhfCombobox({
|
|
|
869
997
|
describedBy,
|
|
870
998
|
clearValue,
|
|
871
999
|
comboClassName,
|
|
1000
|
+
sheetTitle: hasContent(label) ? label : void 0,
|
|
1001
|
+
focusRef: field.ref,
|
|
872
1002
|
comboProps
|
|
873
1003
|
}
|
|
874
1004
|
)
|
|
875
1005
|
}
|
|
876
1006
|
);
|
|
877
1007
|
}
|
|
1008
|
+
function RhfInlineEntityCombobox({
|
|
1009
|
+
name,
|
|
1010
|
+
control,
|
|
1011
|
+
rules,
|
|
1012
|
+
label,
|
|
1013
|
+
hint,
|
|
1014
|
+
required,
|
|
1015
|
+
disabled,
|
|
1016
|
+
excludeWhenDisabled,
|
|
1017
|
+
className,
|
|
1018
|
+
clearValue = null,
|
|
1019
|
+
comboClassName,
|
|
1020
|
+
...comboProps
|
|
1021
|
+
}) {
|
|
1022
|
+
return /* @__PURE__ */ jsx(
|
|
1023
|
+
RhfField,
|
|
1024
|
+
{
|
|
1025
|
+
...{ name, control, rules, label, hint, required, disabled, excludeWhenDisabled, className },
|
|
1026
|
+
render: ({ field, invalid }) => {
|
|
1027
|
+
const value = field.value;
|
|
1028
|
+
return (
|
|
1029
|
+
// FormControl clones this element with `id` / `aria-describedby` /
|
|
1030
|
+
// `aria-invalid`, which the picker routes to its <input>.
|
|
1031
|
+
/* @__PURE__ */ jsx(
|
|
1032
|
+
InlineEntityCombobox,
|
|
1033
|
+
{
|
|
1034
|
+
"aria-required": required || void 0,
|
|
1035
|
+
sheetTitle: hasContent(label) ? label : void 0,
|
|
1036
|
+
...comboProps,
|
|
1037
|
+
className: comboClassName,
|
|
1038
|
+
ref: field.ref,
|
|
1039
|
+
value: value ?? null,
|
|
1040
|
+
clearValue,
|
|
1041
|
+
onChange: (v) => field.onChange(v),
|
|
1042
|
+
onBlur: field.onBlur,
|
|
1043
|
+
disabled: field.disabled,
|
|
1044
|
+
invalid
|
|
1045
|
+
}
|
|
1046
|
+
)
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
);
|
|
1051
|
+
}
|
|
878
1052
|
function RhfTextCombobox({
|
|
879
1053
|
name,
|
|
880
1054
|
control,
|
|
@@ -904,6 +1078,8 @@ function RhfTextCombobox({
|
|
|
904
1078
|
id,
|
|
905
1079
|
describedBy,
|
|
906
1080
|
className: comboClassName,
|
|
1081
|
+
sheetTitle: hasContent(label) ? label : void 0,
|
|
1082
|
+
focusRef: field.ref,
|
|
907
1083
|
comboProps
|
|
908
1084
|
}
|
|
909
1085
|
)
|
|
@@ -918,14 +1094,17 @@ function TextComboControl({
|
|
|
918
1094
|
id,
|
|
919
1095
|
describedBy,
|
|
920
1096
|
className,
|
|
1097
|
+
sheetTitle,
|
|
1098
|
+
focusRef,
|
|
921
1099
|
comboProps
|
|
922
1100
|
}) {
|
|
923
|
-
useFocusHandle(field.ref, () => document.getElementById(id));
|
|
924
1101
|
const value = field.value;
|
|
925
1102
|
return /* @__PURE__ */ jsx(
|
|
926
1103
|
Combobox,
|
|
927
1104
|
{
|
|
1105
|
+
sheetTitle,
|
|
928
1106
|
...comboProps,
|
|
1107
|
+
ref: focusRef,
|
|
929
1108
|
id,
|
|
930
1109
|
"aria-describedby": describedBy,
|
|
931
1110
|
"aria-required": required || void 0,
|
|
@@ -942,12 +1121,15 @@ function TextComboControl({
|
|
|
942
1121
|
export {
|
|
943
1122
|
RhfCheckbox,
|
|
944
1123
|
RhfCombobox,
|
|
1124
|
+
RhfCountrySelect,
|
|
945
1125
|
RhfDateField,
|
|
946
1126
|
RhfDateRangePicker,
|
|
947
1127
|
RhfField,
|
|
948
1128
|
RhfIbanInput,
|
|
1129
|
+
RhfInlineEntityCombobox,
|
|
949
1130
|
RhfIntegerField,
|
|
950
1131
|
RhfMoneyField,
|
|
1132
|
+
RhfMonthPicker,
|
|
951
1133
|
RhfNumberField,
|
|
952
1134
|
RhfPhoneInput,
|
|
953
1135
|
RhfSelect,
|