@canonical/react-ds-global-form 0.30.0 → 0.31.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.
Files changed (63) hide show
  1. package/dist/esm/density.css +234 -0
  2. package/dist/esm/docs/examples/density-examples.css +20 -0
  3. package/dist/esm/index.css +66 -6
  4. package/dist/esm/lib/_work_in_progress/DensityTestbed/Testbed.js +77 -0
  5. package/dist/esm/lib/_work_in_progress/DensityTestbed/Testbed.js.map +1 -0
  6. package/dist/esm/lib/_work_in_progress/DensityTestbed/baseline-system.css +81 -0
  7. package/dist/esm/lib/_work_in_progress/DensityTestbed/density.testbed.css +153 -0
  8. package/dist/esm/lib/_work_in_progress/DensityTestbed/mocks.js +23 -0
  9. package/dist/esm/lib/_work_in_progress/DensityTestbed/mocks.js.map +1 -0
  10. package/dist/esm/lib/common/Wrapper/styles.css +3 -1
  11. package/dist/esm/lib/common/bindField/bindField.js +15 -8
  12. package/dist/esm/lib/common/bindField/bindField.js.map +1 -1
  13. package/dist/esm/lib/component/ChoicesField/common/Option/Option.js +1 -1
  14. package/dist/esm/lib/component/ChoicesField/common/Option/Option.js.map +1 -1
  15. package/dist/esm/lib/component/ChoicesField/styles.css +55 -15
  16. package/dist/esm/lib/component/DateField/DateField.js +19 -1
  17. package/dist/esm/lib/component/DateField/DateField.js.map +1 -1
  18. package/dist/esm/lib/component/FileUploadField/FileUploadField.js +40 -3
  19. package/dist/esm/lib/component/FileUploadField/FileUploadField.js.map +1 -1
  20. package/dist/esm/lib/component/NumberField/NumberField.js +1 -1
  21. package/dist/esm/lib/component/NumberField/NumberField.js.map +1 -1
  22. package/dist/esm/lib/component/RangeField/RangeField.js +1 -1
  23. package/dist/esm/lib/component/RangeField/RangeField.js.map +1 -1
  24. package/dist/esm/lib/subcomponent/CheckboxInput/styles.css +45 -16
  25. package/dist/esm/lib/subcomponent/DateInput/styles.css +12 -0
  26. package/dist/esm/lib/subcomponent/DateTimeInput/styles.css +13 -0
  27. package/dist/esm/lib/subcomponent/Field/Label/Label.js +1 -3
  28. package/dist/esm/lib/subcomponent/Field/Label/Label.js.map +1 -1
  29. package/dist/esm/lib/subcomponent/Field/Label/styles.css +2 -3
  30. package/dist/esm/lib/subcomponent/FileUploadInput/FileUploadInput.js +11 -21
  31. package/dist/esm/lib/subcomponent/FileUploadInput/FileUploadInput.js.map +1 -1
  32. package/dist/esm/lib/subcomponent/FileUploadInput/styles.css +3 -3
  33. package/dist/esm/lib/subcomponent/PasswordInput/styles.css +5 -6
  34. package/dist/esm/lib/subcomponent/RadioInput/styles.css +36 -7
  35. package/dist/esm/lib/subcomponent/RangeInput/styles.css +10 -9
  36. package/dist/esm/lib/subcomponent/SwitchInput/styles.css +27 -10
  37. package/dist/esm/lib/subcomponent/TextInput/TextInput.js +1 -1
  38. package/dist/esm/lib/subcomponent/TextInput/TextInput.js.map +1 -1
  39. package/dist/esm/lib/subcomponent/TextareaInput/TextareaInput.js +1 -3
  40. package/dist/esm/lib/subcomponent/TextareaInput/TextareaInput.js.map +1 -1
  41. package/dist/esm/lib/subcomponent/TextareaInput/styles.css +4 -9
  42. package/dist/esm/lib/subcomponent/TimeInput/styles.css +8 -0
  43. package/dist/esm/lib/utils/countries/countries.js +1 -1
  44. package/dist/esm/lib/utils/countries/countries.js.map +1 -1
  45. package/dist/esm/lib/utils/hooks/useFieldError.js +21 -24
  46. package/dist/esm/lib/utils/hooks/useFieldError.js.map +1 -1
  47. package/dist/types/lib/_work_in_progress/DensityTestbed/Testbed.d.ts +42 -0
  48. package/dist/types/lib/_work_in_progress/DensityTestbed/Testbed.d.ts.map +1 -0
  49. package/dist/types/lib/_work_in_progress/DensityTestbed/mocks.d.ts +26 -0
  50. package/dist/types/lib/_work_in_progress/DensityTestbed/mocks.d.ts.map +1 -0
  51. package/dist/types/lib/common/bindField/bindField.d.ts.map +1 -1
  52. package/dist/types/lib/common/bindField/types.d.ts +14 -5
  53. package/dist/types/lib/common/bindField/types.d.ts.map +1 -1
  54. package/dist/types/lib/component/DateField/DateField.d.ts +3 -2
  55. package/dist/types/lib/component/DateField/DateField.d.ts.map +1 -1
  56. package/dist/types/lib/component/FileUploadField/FileUploadField.d.ts +8 -5
  57. package/dist/types/lib/component/FileUploadField/FileUploadField.d.ts.map +1 -1
  58. package/dist/types/lib/subcomponent/Field/Label/Label.d.ts.map +1 -1
  59. package/dist/types/lib/subcomponent/FileUploadInput/FileUploadInput.d.ts.map +1 -1
  60. package/dist/types/lib/subcomponent/TextareaInput/TextareaInput.d.ts.map +1 -1
  61. package/dist/types/lib/utils/hooks/useFieldError.d.ts +14 -0
  62. package/dist/types/lib/utils/hooks/useFieldError.d.ts.map +1 -1
  63. package/package.json +13 -13
@@ -1 +1 @@
1
- {"version":3,"file":"useFieldError.js","sourceRoot":"","sources":["../../../../../src/lib/utils/hooks/useFieldError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAKL,YAAY,GACb,MAAM,iBAAiB,CAAC;AAEzB,SAAS,aAAa,CACpB,IAAY;IAIZ,MAAM,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC,EAAE,IAAI,EAAE,CAAkC,CAAC;IAE3E,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAElC,yEAAyE;IACzE,MAAM,UAAU,GAAG,OAAO,CACxB,GAA2B,EAAE;IAC3B,wBAAwB;IACxB,SAAS,CAAC,MAAM,CAAY,CAAC,GAA8B,EAAE,GAAG,EAAE,EAAE;QAClE,IAAI,GAAG,EAAE,CAAC;YACR,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,EAAE,MAAM,CAAC,EACZ;QACE,IAAI,EAAE,kBAAkB;QACxB,8FAA8F;QAC9F,sEAAsE;QACtE,wBAAwB;QACxB,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACpB,wBAAwB;QACxB,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACpC,wBAAwB;QACxB,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;KACrD,CACF,CAAC;IACF,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"useFieldError.js","sourceRoot":"","sources":["../../../../../src/lib/utils/hooks/useFieldError.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,GAAG,EAEH,YAAY,GACb,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;;;;GAaG;AACH,SAAS,aAAa,CACpB,IAAY;IAEZ,6EAA6E;IAC7E,0EAA0E;IAC1E,MAAM,EAAE,MAAM,EAAE,GAAG,YAAY,CAAe;QAC5C,IAAI,EAAE,IAA0B;KACjC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC,MAAM,EAAE,IAAI,CAA2B,CAAC;AACrD,CAAC;AAED,eAAe,aAAa,CAAC"}
@@ -0,0 +1,42 @@
1
+ import "./density.testbed.css";
2
+ import "./baseline-system.css";
3
+ /** Controls bucket — real Button + a standalone Label and TextInput (used
4
+ * separately, so there's no stacked Field grid to flatten). */
5
+ export declare const ControlsLine: () => import("react/jsx-runtime").JSX.Element;
6
+ /** Navigation bucket — tab / side-nav item stand-ins on one line. */
7
+ export declare const NavigationLine: () => import("react/jsx-runtime").JSX.Element;
8
+ /** Lists bucket — list/table rows (shared border) on one line. */
9
+ export declare const ListsLine: () => import("react/jsx-runtime").JSX.Element;
10
+ /**
11
+ * Typography bucket — pure engine output, using the package's own tags (h1..h6,
12
+ * p). First an inline row of each tier side by side (to compare their baselines),
13
+ * then full stacked paragraphs of each tier (to witness how a real prose block
14
+ * of each tier sits on the 4px grid).
15
+ */
16
+ export declare const TypographyLine: () => import("react/jsx-runtime").JSX.Element;
17
+ /**
18
+ * Editorial bucket — a real `.editorial` prose document (mixed headings + body)
19
+ * rendered INSIDE the density scope the story toolbar applies. This witnesses the
20
+ * DS.04 composition: density seats controls, but leaves prose to the engine, so
21
+ * `.editorial` here keeps its natural multi-line leading, seats every line on the
22
+ * grid, AND gets its whole-baseline inter-block margins (--space-after) — with no
23
+ * density override fighting it. Flip context/density in the toolbar: the prose
24
+ * rhythm must NOT change (it is engine-owned), proving density and editorial
25
+ * compose rather than collide.
26
+ */
27
+ export declare const EditorialLine: () => import("react/jsx-runtime").JSX.Element;
28
+ /**
29
+ * DS.01 proof — the size-agnostic `.baseline` class. A row of arbitrary,
30
+ * off-scale font sizes, each snapped to the 4px grid by `.baseline` alone (no
31
+ * tier, no engine size class). The tags h1..h6/p are untouched and still nudge
32
+ * by default — this is additive.
33
+ */
34
+ export declare const BaselineProofLine: () => import("react/jsx-runtime").JSX.Element;
35
+ /**
36
+ * DS.02 proof — `.spike-baseline-boxed` (PROTOTYPE, not core API). Two density
37
+ * line-heights: dense (24px) and comfortable (32px). Each box snaps to the grid
38
+ * via the existing start/end nudge; top-referenced, so the boxes share the top
39
+ * rhythm (a fixed baseline-from-bottom is NOT what the existing calc produces).
40
+ */
41
+ export declare const BoxedProofLine: () => import("react/jsx-runtime").JSX.Element;
42
+ //# sourceMappingURL=Testbed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Testbed.d.ts","sourceRoot":"","sources":["../../../../../src/lib/_work_in_progress/DensityTestbed/Testbed.tsx"],"names":[],"mappings":"AAKA,OAAO,uBAAuB,CAAC;AAC/B,OAAO,uBAAuB,CAAC;AA+B/B;gEACgE;AAChE,eAAO,MAAM,YAAY,+CAOxB,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,cAAc,+CAO1B,CAAC;AAEF,kEAAkE;AAClE,eAAO,MAAM,SAAS,+CAIrB,CAAC;AAWF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,+CAc1B,CAAC;AAOF;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,+CAazB,CAAC;AAOF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,+CAU7B,CAAC;AAMF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,+CAgB1B,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type React from "react";
2
+ /**
3
+ * Baseline-alignment spike — boxed-control primitive + mocks (WORK IN PROGRESS)
4
+ *
5
+ * `SpikeBox` is the unit under test: a bordered box whose interior is a single
6
+ * line of `.p`-tier text (a stand-in for a button label, input value, nav-item
7
+ * text or table-cell text). Its seat uses the shipped engine model (the
8
+ * asymmetric start/end nudges from `density.testbed.css`); the alternative
9
+ * external-margin model was dropped, so there is no model toggle. Using one
10
+ * primitive keeps buckets comparing like-for-like; the real Button/inputs are
11
+ * shown alongside in the story for reference.
12
+ */
13
+ /** A boxed control: border + a `.p` text seat, seated on the grid by the engine's
14
+ * start/end nudges (see density.testbed.css). */
15
+ export declare const SpikeBox: ({ children, as, role, }: {
16
+ children: React.ReactNode;
17
+ as?: "div" | "button";
18
+ role?: string;
19
+ }) => React.ReactElement;
20
+ /** A run of boxed cells sharing one border — the list/table-row case, laid out
21
+ * inline on the bucket line (the CSS collapses the between-borders). Exercises
22
+ * how per-cell external margin interacts with a shared border. */
23
+ export declare const SpikeRows: ({ rows }: {
24
+ rows: string[];
25
+ }) => React.ReactElement;
26
+ //# sourceMappingURL=mocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../../../../src/lib/_work_in_progress/DensityTestbed/mocks.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;;;;;;;;;GAUG;AAEH;kDACkD;AAClD,eAAO,MAAM,QAAQ,GAAI,yBAItB;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,EAAE,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,KAAG,KAAK,CAAC,YAWT,CAAC;AAEF;;mEAEmE;AACnE,eAAO,MAAM,SAAS,GAAI,UAAU;IAAE,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,KAAG,KAAK,CAAC,YAM9D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"bindField.d.ts","sourceRoot":"","sources":["../../../../../src/lib/common/bindField/bindField.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAiB,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAOnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEhF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,CAAC,SAAS,iBAAiB,EAE3D,cAAc,EAAE,aAAa,CAAC,GAAG,CAAC,EAClC,IAAI,EAAE,QAAQ,EACd,OAAO,GAAE,gBAAqB,GAC7B,EAAE,CAAC,CAAC,CAAC,CAyDP"}
1
+ {"version":3,"file":"bindField.d.ts","sourceRoot":"","sources":["../../../../../src/lib/common/bindField/bindField.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAiB,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAOnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEhF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,CAAC,SAAS,iBAAiB,EAE3D,cAAc,EAAE,aAAa,CAAC,GAAG,CAAC,EAClC,IAAI,EAAE,QAAQ,EACd,OAAO,GAAE,gBAAqB,GAC7B,EAAE,CAAC,CAAC,CAAC,CAiEP"}
@@ -13,12 +13,21 @@ export interface BindFieldOptions {
13
13
  */
14
14
  defaultValue?: unknown;
15
15
  /**
16
- * Base `register()` options merged UNDER the consumer's `registerProps` (the
17
- * consumer wins on conflict). Lets a field set input-type defaults — e.g.
18
- * Number passing `{ valueAsNumber: true }` so RHF stores a number, not the
19
- * string the native `<input type="number">` reports.
16
+ * Extra `register()` options merged UNDER the consumer's `registerProps` (the
17
+ * consumer always wins on conflict). Accepts either:
18
+ *
19
+ * - a **static** `RegisterOptions` object — for input-type defaults that don't
20
+ * depend on props, e.g. Number's `{ valueAsNumber: true }`; or
21
+ * - a **function of the component's own props** `(props) => RegisterOptions` —
22
+ * for prop-driven rules, e.g. a Date field turning its `min`/`max` props into
23
+ * RHF min/max rules, or a FileUpload field turning `maxFiles`/`maxSize` into a
24
+ * `validate` rule. Runs at render with the live props.
25
+ *
26
+ * The props are still forwarded to the input, so native constraints (picker,
27
+ * spinner, `accept`) are unaffected — this only adds the RHF-visible rules that
28
+ * surface an inline field error.
20
29
  */
21
- registerDefaults?: RegisterOptions;
30
+ additionalRegisterProps?: RegisterOptions | ((props: Record<string, unknown>) => RegisterOptions);
22
31
  }
23
32
  export type FieldBindingProps = {
24
33
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/common/bindField/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,YAAY,CAAC;AAE/C,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,eAAe,CAAC;CACpC;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,eAAe,CAAC;CACjC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/common/bindField/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,YAAY,CAAC;AAE/C,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;;;;;;;;;;OAcG;IACH,uBAAuB,CAAC,EACpB,eAAe,GACf,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,eAAe,CAAC,CAAC;CAC3D;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,eAAe,CAAC;CACjC,CAAC"}
@@ -1,3 +1,4 @@
1
+ import type { RegisterOptions } from "react-hook-form";
1
2
  import type { DateFieldProps } from "./types.js";
2
3
  /**
3
4
  * Date input bound to react-hook-form, wrapped with field chrome
@@ -318,10 +319,10 @@ declare const _default: (props: {
318
319
  onTransitionRunCapture?: import("react").TransitionEventHandler<HTMLInputElement> | undefined;
319
320
  onTransitionStart?: import("react").TransitionEventHandler<HTMLInputElement> | undefined;
320
321
  onTransitionStartCapture?: import("react").TransitionEventHandler<HTMLInputElement> | undefined;
321
- registerProps?: import("react-hook-form").RegisterOptions | undefined;
322
+ registerProps?: RegisterOptions | undefined;
322
323
  isOptional?: boolean | undefined;
323
324
  requiredIndicator?: import("../../subcomponent/index.js").RequiredIndicator | undefined;
324
- nestedRegisterProps?: import("react-hook-form").RegisterOptions | undefined;
325
+ nestedRegisterProps?: RegisterOptions | undefined;
325
326
  unregisterOnUnmount?: boolean | undefined;
326
327
  controlLabel?: string | undefined;
327
328
  mockLabel?: boolean | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"DateField.d.ts","sourceRoot":"","sources":["../../../../../src/lib/component/DateField/DateField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACH,wBAEE"}
1
+ {"version":3,"file":"DateField.d.ts","sourceRoot":"","sources":["../../../../../src/lib/component/DateField/DateField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAIvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAsBjD;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACH,wBAIE"}
@@ -1,8 +1,11 @@
1
+ import type { RegisterOptions } from "react-hook-form";
1
2
  import type { FileUploadFieldProps } from "./types.js";
2
3
  /**
3
- * FileUploadInput bound to react-hook-form (controlled), wrapped with field chrome.
4
- * The `defaultValue` preserves the registration default the original leaf set
5
- * in `useController` (`[]`).
4
+ * FileUploadInput bound to react-hook-form (controlled), wrapped with field
5
+ * chrome. The `defaultValue` preserves the registration default the original
6
+ * leaf set in `useController` (`[]`). `maxFiles`/`maxSize` are enforced as RHF
7
+ * validation rules so violations surface as a standard field error rather than
8
+ * being silently dropped in the input.
6
9
  *
7
10
  * `import { FileUploadField } from "@canonical/react-ds-global-form";`
8
11
  */
@@ -22,10 +25,10 @@ declare const _default: (props: {
22
25
  "aria-invalid"?: boolean | undefined;
23
26
  "aria-labelledby"?: string | undefined;
24
27
  onChange?: ((files: File[]) => void) | undefined;
25
- registerProps?: import("react-hook-form").RegisterOptions | undefined;
28
+ registerProps?: RegisterOptions | undefined;
26
29
  isOptional?: boolean | undefined;
27
30
  requiredIndicator?: import("../../subcomponent/index.js").RequiredIndicator | undefined;
28
- nestedRegisterProps?: import("react-hook-form").RegisterOptions | undefined;
31
+ nestedRegisterProps?: RegisterOptions | undefined;
29
32
  unregisterOnUnmount?: boolean | undefined;
30
33
  controlLabel?: string | undefined;
31
34
  mockLabel?: boolean | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"FileUploadField.d.ts","sourceRoot":"","sources":["../../../../../src/lib/component/FileUploadField/FileUploadField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACH,wBAIE"}
1
+ {"version":3,"file":"FileUploadField.d.ts","sourceRoot":"","sources":["../../../../../src/lib/component/FileUploadField/FileUploadField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAIvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAyCvD;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACH,wBAKE"}
@@ -1 +1 @@
1
- {"version":3,"file":"Label.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/subcomponent/Field/Label/Label.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,cAAc,CAAC;AAStB;;;;;GAKG;AACH,QAAA,MAAM,KAAK,GAAI,2GAWZ,UAAU,KAAG,KAAK,CAAC,YA2BrB,CAAC;AAEF,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"Label.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/subcomponent/Field/Label/Label.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,cAAc,CAAC;AAStB;;;;;GAKG;AACH,QAAA,MAAM,KAAK,GAAI,2GAWZ,UAAU,KAAG,KAAK,CAAC,YAyBrB,CAAC;AAEF,eAAe,KAAK,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"FileUploadInput.d.ts","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/FileUploadInput/FileUploadInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,cAAc,CAAC;AAItB;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAAI,yGAY7B,oBAAoB,KAAG,KAAK,CAAC,YAsK/B,CAAC;AASF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"FileUploadInput.d.ts","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/FileUploadInput/FileUploadInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,cAAc,CAAC;AAItB;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAAI,yGAe7B,oBAAoB,KAAG,KAAK,CAAC,YA+I/B,CAAC;AASF,eAAe,eAAe,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"TextareaInput.d.ts","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/TextareaInput/TextareaInput.tsx"],"names":[],"mappings":"AAEA,OAAO,cAAc,CAAC;AAItB;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,6JAkBxB,CAAC;AAEH,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"TextareaInput.d.ts","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/TextareaInput/TextareaInput.tsx"],"names":[],"mappings":"AAEA,OAAO,cAAc,CAAC;AAItB;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,6JAgBxB,CAAC;AAEH,eAAe,aAAa,CAAC"}
@@ -1,4 +1,18 @@
1
1
  import { type FieldError, type FieldValues } from "react-hook-form";
2
+ /**
3
+ * Field-scoped subscription to a single field's error.
4
+ *
5
+ * Subscribes via `useFormState({ name })` so only this field's slice of form
6
+ * state triggers a re-render, then resolves the error at `name` from the
7
+ * (possibly nested) `errors` tree on every render with RHF's own `get`.
8
+ *
9
+ * Resolving on render — rather than memoising against a fixed, hand-unrolled
10
+ * list of parent references — is what lets a *message-only* change surface: on
11
+ * cross-field revalidation a field can stay errored while its message text
12
+ * changes (e.g. a min-age constraint tightens), and `get` reflects the new
13
+ * message at any nesting depth. `useFormState`'s field-scoped subscription
14
+ * still gates the re-render, so efficiency is preserved.
15
+ */
2
16
  declare function useFieldError<TFieldValues extends FieldValues = FieldValues>(name: string): FieldError | undefined;
3
17
  export default useFieldError;
4
18
  //# sourceMappingURL=useFieldError.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFieldError.d.ts","sourceRoot":"","sources":["../../../../../src/lib/utils/hooks/useFieldError.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,UAAU,EAGf,KAAK,WAAW,EAEjB,MAAM,iBAAiB,CAAC;AAEzB,iBAAS,aAAa,CAAC,YAAY,SAAS,WAAW,GAAG,WAAW,EACnE,IAAI,EAAE,MAAM,0BA+Bb;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"useFieldError.d.ts","sourceRoot":"","sources":["../../../../../src/lib/utils/hooks/useFieldError.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,WAAW,EAIjB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;;;;GAaG;AACH,iBAAS,aAAa,CAAC,YAAY,SAAS,WAAW,GAAG,WAAW,EACnE,IAAI,EAAE,MAAM,GACX,UAAU,GAAG,SAAS,CAQxB;AAED,eAAe,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonical/react-ds-global-form",
3
- "version": "0.30.0",
3
+ "version": "0.31.0",
4
4
  "type": "module",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -43,10 +43,10 @@
43
43
  "test:vitest:watch": "vitest"
44
44
  },
45
45
  "dependencies": {
46
- "@canonical/react-ds-global": "^0.30.0",
47
- "@canonical/storybook-config": "^0.30.0",
48
- "@canonical/styles": "^0.30.0",
49
- "@canonical/utils": "^0.30.0",
46
+ "@canonical/react-ds-global": "^0.31.0",
47
+ "@canonical/storybook-config": "^0.31.0",
48
+ "@canonical/styles": "^0.31.0",
49
+ "@canonical/utils": "^0.31.0",
50
50
  "downshift": "^9.3.2",
51
51
  "react": "^19.2.4",
52
52
  "react-dom": "^19.2.4",
@@ -54,14 +54,14 @@
54
54
  },
55
55
  "devDependencies": {
56
56
  "@biomejs/biome": "2.4.9",
57
- "@canonical/biome-config": "^0.30.0",
57
+ "@canonical/biome-config": "^0.31.0",
58
58
  "@canonical/design-tokens": "0.6.2-contrasted.0",
59
- "@canonical/storybook-addon-form-state": "^0.30.0",
60
- "@canonical/storybook-addon-msw": "^0.30.0",
61
- "@canonical/storybook-helpers": "^0.30.0",
62
- "@canonical/typescript-config-react": "^0.30.0",
63
- "@canonical/vitest-config-react": "^0.30.0",
64
- "@canonical/webarchitect": "^0.30.0",
59
+ "@canonical/storybook-addon-form-state": "^0.31.0",
60
+ "@canonical/storybook-addon-msw": "^0.31.0",
61
+ "@canonical/storybook-helpers": "^0.31.0",
62
+ "@canonical/typescript-config-react": "^0.31.0",
63
+ "@canonical/vitest-config-react": "^0.31.0",
64
+ "@canonical/webarchitect": "^0.31.0",
65
65
  "@chromatic-com/storybook": "^5.0.1",
66
66
  "@storybook/addon-docs": "^10.3.1",
67
67
  "@storybook/react-vite": "^10.3.1",
@@ -81,5 +81,5 @@
81
81
  "vite": "^8.0.1",
82
82
  "vitest": "^4.0.18"
83
83
  },
84
- "gitHead": "40fe86ac955473536ac14f074812a9821f5b65c0"
84
+ "gitHead": "d4a67ebe42e62b8cf3de77f42f537309ca88d672"
85
85
  }