@canonical/react-ds-global-form 0.44.1 → 0.47.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 CHANGED
@@ -146,12 +146,16 @@ The `Field` component uses `inputType` to select the appropriate input component
146
146
  | `checkbox` | Checkbox | Boolean toggle |
147
147
  | `range` | Range | Slider input |
148
148
  | `select` | Select | Dropdown selection |
149
- | `simple-choices` | SimpleChoices | Radio buttons or checkboxes |
149
+ | `choices`, `rich-choices` | Choices | Radio buttons or checkboxes |
150
150
  | `combobox` | Combobox | Searchable dropdown |
151
151
  | `hidden` | Hidden | Hidden input |
152
152
  | `custom` | Your component | Pass via `CustomComponent` prop |
153
153
 
154
- All fields are wrapped with `withWrapper`, which provides form registration, labels, descriptions, error display, and middleware support.
154
+ Built-in fields provide form binding and field chrome. Custom fields are rendered directly and own their binding and chrome.
155
+
156
+ `FieldProps` is a discriminated union. When migrating from the previously unchecked type, preserve literal `inputType` values with `satisfies FieldProps[]`, provide `options` for selects (use `[]` when middleware supplies them) and a `label` or `controlLabel` for toggles. Extend it with a type intersection rather than `interface extends FieldProps`; use `FieldProps<CustomProps>` for a custom component with additional required props. Custom-field declarations require TypeScript 5.5 or newer: although `NoInfer` was introduced in 5.4, the reserved-prop conditional does not resolve correctly in 5.4.
157
+
158
+ Built-in `Field` variants determine the native input type from `inputType`; do not pass a separate native `type` prop. Custom components may define their own `type` prop.
155
159
 
156
160
  ### Custom Fields
157
161
 
@@ -169,7 +173,27 @@ import { MyColorPicker } from "./MyColorPicker";
169
173
  />
170
174
  ```
171
175
 
172
- Custom components must be wrapped with `withWrapper`. Custom components must satisfy the `InputProps` type and integrate with react-hook-form via `useFormContext`.
176
+ Custom components receive the supplied props except `inputType`, `CustomComponent` and React's `key`. They must implement any needed registration, labels, errors, conditions and middleware themselves; `withWrapper` is internal. JSX checks the custom component's props. For typed maps, use `FieldProps<MyCustomProps>[]`; a map with different custom components needs a union of those types and narrowing before rendering each custom variant. See the Creating Custom Fields guide for an example.
177
+
178
+ ### Standalone Inputs
179
+
180
+ Every input the Field pattern composes is also exported on its own: `TextInput`, `SelectInput`, `CheckboxInput`, `SwitchInput`, `RadioInput`, `NumberInput`, `PasswordInput`, `RangeInput`, `RatingInput`, `DateInput`, `TimeInput`, `DateTimeInput`, `ColorInput`, `ComboboxInput`, `PhoneInput`, `FileUploadInput`, `TextareaInput` and `HiddenInput`, each with its props type. They are presentational: no `<Form>`, no react-hook-form context and no label, so a control outside a form keeps the same input chrome. Name it with `aria-label` or a `<label>` of your own.
181
+
182
+ ```tsx
183
+ import { SelectInput } from "@canonical/react-ds-global-form";
184
+
185
+ <SelectInput
186
+ aria-label="Language"
187
+ value={locale}
188
+ onChange={(event) => setLocale(event.target.value)}
189
+ options={[
190
+ { value: "en", label: "English", lang: "en" },
191
+ { value: "fr", label: "français", lang: "fr" },
192
+ ]}
193
+ />
194
+ ```
195
+
196
+ An option's optional `lang` marks a label written in another language, so assistive technology pronounces it correctly.
173
197
 
174
198
  ## Middleware Pattern
175
199
 
@@ -180,6 +204,7 @@ Middleware are higher-order components that wrap fields to add functionality. Th
180
204
  name="country"
181
205
  inputType="select"
182
206
  label="Country"
207
+ options={[]}
183
208
  middleware={[addRESTOptions("/api/countries")]}
184
209
  />
185
210
  ```
@@ -196,6 +221,7 @@ import { addRESTOptions } from "@canonical/react-ds-global-form";
196
221
  <Field
197
222
  name="category"
198
223
  inputType="select"
224
+ options={[]}
199
225
  middleware={[
200
226
  addRESTOptions("/api/categories", {
201
227
  transformData: (data) => data.categories,
@@ -1,9 +1,9 @@
1
- // Public package surface (unchanged by the tier restructure): the Field pattern
1
+ // Public package surface: the Field pattern
2
2
  // (Field + FieldProps + the shared/machinery types it re-exports), the Form
3
- // pattern, and the form middleware. The component/ and subcomponent/ tiers are
4
- // otherwise internal — composed by the Field pattern, not exported at the root.
3
+ // pattern, the form middleware, and the input subcomponents below. The
4
+ // component/ tier is otherwise internal — composed by the Field pattern.
5
5
  export * from "./pattern/index.js";
6
- export { RatingInput } from "./subcomponent/index.js";
6
+ export { CheckboxInput, ColorInput, ComboboxInput, DateInput, DateTimeInput, FileUploadInput, HiddenInput, NumberInput, PasswordInput, PhoneInput, RadioInput, RangeInput, RatingInput, SelectInput, SwitchInput, TextareaInput, TextInput, TimeInput, } from "./subcomponent/index.js";
7
7
  export { applyPattern, createFormatterRegisterOptions, createPatternFormatter, stripToDigits, } from "./utils/formatter/index.js";
8
8
  export { useFormattedValue } from "./utils/hooks/index.js";
9
9
  export * from "./utils/middleware/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,4EAA4E;AAC5E,+EAA+E;AAC/E,gFAAgF;AAChF,cAAc,oBAAoB,CAAC;AAUnC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAOtD,OAAO,EACL,YAAY,EACZ,8BAA8B,EAC9B,sBAAsB,EACtB,aAAa,GACd,MAAM,4BAA4B,CAAC;AAKpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,4EAA4E;AAC5E,uEAAuE;AACvE,yEAAyE;AACzE,cAAc,oBAAoB,CAAC;AA+BnC,OAAO,EACL,aAAa,EACb,UAAU,EACV,aAAa,EACb,SAAS,EACT,aAAa,EACb,eAAe,EACf,WAAW,EACX,WAAW,EACX,aAAa,EACb,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,aAAa,EACb,SAAS,EACT,SAAS,GACV,MAAM,yBAAyB,CAAC;AAOjC,OAAO,EACL,YAAY,EACZ,8BAA8B,EAC9B,sBAAsB,EACtB,aAAa,GACd,MAAM,4BAA4B,CAAC;AAKpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,cAAc,6BAA6B,CAAC"}
@@ -18,61 +18,68 @@ import { SwitchField } from "../../component/SwitchField/index.js";
18
18
  import { TextareaField } from "../../component/TextareaField/index.js";
19
19
  import { TextField } from "../../component/TextField/index.js";
20
20
  import { TimeField } from "../../component/TimeField/index.js";
21
+ const withoutRoutingProps = (props) => {
22
+ const { inputType: _, CustomComponent: _component, type: _type, ...rest } = props;
23
+ return rest;
24
+ };
21
25
  /**
22
- * description of the Field component
23
- * @returns {React.ReactElement} - Rendered Field
26
+ * A form field is the unit that pairs a single input with the surrounding meaning a user needs to act on it: a label naming what is being asked, optional descriptive guidance, the input itself, and validation feedback when an entry is rejected. It is the common frame every concrete form control adopts so that labelling, help text, optionality and error reporting behave the same across a form.
27
+ *
28
+ * This router has no single native root; the selected field renders its own root.
24
29
  *
25
30
  * `import { Field } from "@canonical/react-ds-global-form";`
31
+ *
32
+ * @implements ds:global.pattern.field
26
33
  */
27
- const Field = ({ inputType, CustomComponent, ...props }) => {
28
- switch (inputType) {
34
+ const Field = (props) => {
35
+ switch (props.inputType) {
29
36
  case "textarea":
30
- return _jsx(TextareaField, { ...props });
37
+ return _jsx(TextareaField, { ...withoutRoutingProps(props) });
31
38
  case "checkbox":
32
- return _jsx(CheckboxField, { ...props });
39
+ return _jsx(CheckboxField, { ...withoutRoutingProps(props) });
33
40
  case "switch":
34
- return _jsx(SwitchField, { ...props });
41
+ return _jsx(SwitchField, { ...withoutRoutingProps(props) });
35
42
  case "rating":
36
- return _jsx(RatingField, { ...props });
43
+ return _jsx(RatingField, { ...withoutRoutingProps(props) });
37
44
  case "range":
38
- return _jsx(RangeField, { ...props });
45
+ return _jsx(RangeField, { ...withoutRoutingProps(props) });
39
46
  case "select":
40
- return _jsx(SelectField, { ...props });
47
+ return _jsx(SelectField, { ...withoutRoutingProps(props) });
41
48
  case "choices":
42
- return _jsx(ChoicesField, { ...props });
49
+ return _jsx(ChoicesField, { ...withoutRoutingProps(props) });
43
50
  case "combobox":
44
- return _jsx(ComboboxField, { ...props });
51
+ return _jsx(ComboboxField, { ...withoutRoutingProps(props) });
45
52
  case "hidden":
46
- return _jsx(HiddenField, { ...props });
53
+ return _jsx(HiddenField, { ...withoutRoutingProps(props) });
47
54
  case "date":
48
- return _jsx(DateField, { ...props });
55
+ return _jsx(DateField, { ...withoutRoutingProps(props) });
49
56
  case "time":
50
- return _jsx(TimeField, { ...props });
57
+ return _jsx(TimeField, { ...withoutRoutingProps(props) });
51
58
  case "datetime":
52
- return _jsx(DateTimeField, { ...props });
59
+ return _jsx(DateTimeField, { ...withoutRoutingProps(props) });
53
60
  case "file":
54
- return _jsx(FileUploadField, { ...props });
61
+ return _jsx(FileUploadField, { ...withoutRoutingProps(props) });
55
62
  case "color":
56
- return _jsx(ColorField, { ...props });
63
+ return _jsx(ColorField, { ...withoutRoutingProps(props) });
57
64
  case "phone":
58
- return _jsx(PhoneField, { ...props });
65
+ return _jsx(PhoneField, { ...withoutRoutingProps(props) });
59
66
  case "password":
60
- return _jsx(PasswordField, { ...props });
67
+ return _jsx(PasswordField, { ...withoutRoutingProps(props) });
61
68
  case "number":
62
- return _jsx(NumberField, { ...props });
69
+ return _jsx(NumberField, { ...withoutRoutingProps(props) });
63
70
  case "rich-choices":
64
- return _jsx(RichChoicesField, { ...props });
71
+ return _jsx(RichChoicesField, { ...withoutRoutingProps(props) });
65
72
  case "custom":
66
- if (!CustomComponent) {
73
+ if (!props.CustomComponent) {
67
74
  throw new Error('Field with inputType="custom" requires a CustomComponent prop.');
68
75
  }
69
- return _jsx(CustomComponent, { ...props });
76
+ {
77
+ const { inputType: _, CustomComponent, ...customProps } = props;
78
+ return _jsx(CustomComponent, { ...customProps });
79
+ }
70
80
  default:
71
- return _jsx(TextField, { inputType: inputType, ...props });
81
+ return (_jsx(TextField, { ...withoutRoutingProps(props), inputType: props.inputType }));
72
82
  }
73
83
  };
74
- /**
75
- * @implements ds:global.pattern.field
76
- */
77
84
  export default Field;
78
85
  //# sourceMappingURL=Field.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Field.js","sourceRoot":"","sources":["../../../../../src/lib/pattern/Field/Field.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAG/D;;;;;GAKG;AACH,MAAM,KAAK,GAAG,CAAC,EACb,SAAS,EACT,eAAe,EACf,GAAG,KAAK,EACG,EAAsB,EAAE;IACnC,QAAQ,S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@ const componentCssClassName = "ds input select chrome";
14
14
  * @implements ds:global.subcomponent.select_input
15
15
  */
16
16
  export const SelectInput = forwardRef(function SelectInput({ id, className, style, options, ...nativeProps }, ref) {
17
- return (_jsx("select", { id: id, className: [componentCssClassName, className].filter(Boolean).join(" "), style: style, ref: ref, ...nativeProps, children: options.map((option) => (_jsx("option", { value: option.value, disabled: option.disabled, children: option.label }, option.value))) }));
17
+ return (_jsx("select", { id: id, className: [componentCssClassName, className].filter(Boolean).join(" "), style: style, ref: ref, ...nativeProps, children: options.map((option) => (_jsx("option", { value: option.value, disabled: option.disabled, lang: option.lang, children: option.label }, option.value))) }));
18
18
  });
19
19
  export default SelectInput;
20
20
  //# sourceMappingURL=SelectInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectInput.js","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/SelectInput/SelectInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,OAAO,CAAC;AAEtD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CACnC,SAAS,WAAW,CAClB,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,WAAW,EAAE,EACjD,GAAG;IAEH,OAAO,CACL,iBACE,EAAE,EAAE,EAAE,EACN,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EACvE,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,GAAG,KACJ,WAAW,YAEd,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACvB,iBAEE,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,QAAQ,EAAE,MAAM,CAAC,QAAQ,YAExB,MAAM,CAAC,KAAK,IAJR,MAAM,CAAC,KAAK,CAKV,CACV,CAAC,GACK,CACV,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"SelectInput.js","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/SelectInput/SelectInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,OAAO,CAAC;AAEtD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CACnC,SAAS,WAAW,CAClB,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,WAAW,EAAE,EACjD,GAAG;IAEH,OAAO,CACL,iBACE,EAAE,EAAE,EAAE,EACN,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EACvE,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,GAAG,KACJ,WAAW,YAEd,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACvB,iBAEE,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,QAAQ,EAAE,MAAM,CAAC,QAAQ,EACzB,IAAI,EAAE,MAAM,CAAC,IAAI,YAEhB,MAAM,CAAC,KAAK,IALR,MAAM,CAAC,KAAK,CAMV,CACV,CAAC,GACK,CACV,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -41,5 +41,16 @@
41
41
  * room for the chevron. */
42
42
  padding-inline-start: var(--form-input-padding-inline);
43
43
  padding-inline-end: calc(var(--form-input-padding-inline) * 2 + 1em);
44
+
45
+ /* The padding above is logical, so in right-to-left text the room for
46
+ the chevron opens on the left; `background-position` has no logical
47
+ keywords, so the chevron moves there explicitly. Mirrored, the two
48
+ gradient squares swap halves: the 45deg square is the outer one. */
49
+ &:dir(rtl) {
50
+ background-position:
51
+ left var(--form-input-padding-inline) center,
52
+ left calc(var(--form-input-padding-inline) + var(--select-caret-half))
53
+ center;
54
+ }
44
55
  }
45
56
  }
@@ -1,11 +1,11 @@
1
1
  import type { ComponentType, FC } from "react";
2
- import type { BaseInputProps, ToggleLabelProps, WrapperProps } from "../types.js";
2
+ import type { BaseInputProps, ToggleLabelProps, WrappedComponentProps } from "../types.js";
3
3
  /**
4
4
  * Public props of a toggle field: everything the wrapper accepts, but with the
5
5
  * optional `label`/`controlLabel` replaced by the "at least one" union so a
6
6
  * label-less toggle is a compile error.
7
7
  */
8
- type ToggleWrapperProps<ComponentProps extends BaseInputProps> = Omit<WrapperProps<ComponentProps>, "Component" | "label" | "controlLabel"> & ToggleLabelProps;
8
+ type ToggleWrapperProps<ComponentProps extends BaseInputProps> = Omit<WrappedComponentProps<ComponentProps>, "Component" | "label" | "controlLabel"> & ToggleLabelProps;
9
9
  /**
10
10
  * Field HOC for toggle inputs (checkbox, switch). Like `withWrapper`, but bakes
11
11
  * in `ToggleWrapper` (control inline with its label) and types the result to
@@ -1 +1 @@
1
- {"version":3,"file":"withToggleWrapper.d.ts","sourceRoot":"","sources":["../../../../../src/lib/common/Wrapper/withToggleWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,YAAY,EACb,MAAM,aAAa,CAAC;AAIrB;;;;GAIG;AACH,KAAK,kBAAkB,CAAC,cAAc,SAAS,cAAc,IAAI,IAAI,CACnE,YAAY,CAAC,cAAc,CAAC,EAC5B,WAAW,GAAG,OAAO,GAAG,cAAc,CACvC,GACC,gBAAgB,CAAC;AAEnB;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,iBAAiB,GAAI,cAAc,SAAS,cAAc,aACnD,aAAa,CAAC,cAAc,CAAC,aAC7B,OAAO,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC,KACrD,EAAE,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAWvC,CAAC;eAEa,iBAAiB"}
1
+ {"version":3,"file":"withToggleWrapper.d.ts","sourceRoot":"","sources":["../../../../../src/lib/common/Wrapper/withToggleWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAIrB;;;;GAIG;AACH,KAAK,kBAAkB,CAAC,cAAc,SAAS,cAAc,IAAI,IAAI,CACnE,qBAAqB,CAAC,cAAc,CAAC,EACrC,WAAW,GAAG,OAAO,GAAG,cAAc,CACvC,GACC,gBAAgB,CAAC;AAEnB;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,iBAAiB,GAAI,cAAc,SAAS,cAAc,aACnD,aAAa,CAAC,cAAc,CAAC,aAC7B,OAAO,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC,KACrD,EAAE,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAWvC,CAAC;eAEa,iBAAiB"}
@@ -11,6 +11,6 @@ type CheckboxInputFieldProps = InputProps<CheckboxInputProps>;
11
11
  *
12
12
  * @implements ds:global.component.checkbox_field
13
13
  */
14
- declare const _default: import("react").FC<Omit<import("../../common/types.js").WrapperProps<CheckboxInputFieldProps>, "Component" | "controlLabel" | "label"> & import("../../common/types.js").ToggleLabelProps>;
14
+ declare const _default: import("react").FC<Omit<import("../../common/types.js").WrappedComponentProps<CheckboxInputFieldProps>, "Component" | "controlLabel" | "label"> & import("../../common/types.js").ToggleLabelProps>;
15
15
  export default _default;
16
16
  //# sourceMappingURL=CheckboxField.d.ts.map
@@ -16,6 +16,6 @@ type SwitchInputFieldProps = InputProps<SwitchInputProps>;
16
16
  *
17
17
  * @implements ds:global.component.switch_field
18
18
  */
19
- declare const _default: import("react").FC<Omit<import("../../common/types.js").WrapperProps<SwitchInputFieldProps>, "Component" | "controlLabel" | "label"> & import("../../common/types.js").ToggleLabelProps>;
19
+ declare const _default: import("react").FC<Omit<import("../../common/types.js").WrappedComponentProps<SwitchInputFieldProps>, "Component" | "controlLabel" | "label"> & import("../../common/types.js").ToggleLabelProps>;
20
20
  export default _default;
21
21
  //# sourceMappingURL=SwitchField.d.ts.map
@@ -1,6 +1,6 @@
1
1
  export * from "./pattern/index.js";
2
- export type { RatingInputProps, RatingScale, } from "./subcomponent/index.js";
3
- export { RatingInput } from "./subcomponent/index.js";
2
+ export type { CheckboxInputProps, ColorInputProps, ComboboxInputProps, DateInputProps, DateTimeInputProps, FileUploadInputProps, HexFormat, HiddenInputProps, NumberInputProps, PasswordInputProps, PhoneInputProps, PhoneValue, RadioInputProps, RangeInputProps, RatingInputProps, RatingScale, SelectInputProps, SwitchInputProps, TextareaInputProps, TextInputProps, TextInputType, TimeInputProps, } from "./subcomponent/index.js";
3
+ export { CheckboxInput, ColorInput, ComboboxInput, DateInput, DateTimeInput, FileUploadInput, HiddenInput, NumberInput, PasswordInput, PhoneInput, RadioInput, RangeInput, RatingInput, SelectInput, SwitchInput, TextareaInput, TextInput, TimeInput, } from "./subcomponent/index.js";
4
4
  export type { Formatter } from "./utils/formatter/index.js";
5
5
  export { applyPattern, createFormatterRegisterOptions, createPatternFormatter, stripToDigits, } from "./utils/formatter/index.js";
6
6
  export type { UseFormattedValueProps, UseFormattedValueResult, } from "./utils/hooks/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAIA,cAAc,oBAAoB,CAAC;AAMnC,YAAY,EACV,gBAAgB,EAChB,WAAW,GACZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAMtD,YAAY,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EACL,YAAY,EACZ,8BAA8B,EAC9B,sBAAsB,EACtB,aAAa,GACd,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAIA,cAAc,oBAAoB,CAAC;AAOnC,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,cAAc,GACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,aAAa,EACb,UAAU,EACV,aAAa,EACb,SAAS,EACT,aAAa,EACb,eAAe,EACf,WAAW,EACX,WAAW,EACX,aAAa,EACb,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,aAAa,EACb,SAAS,EACT,SAAS,GACV,MAAM,yBAAyB,CAAC;AAMjC,YAAY,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EACL,YAAY,EACZ,8BAA8B,EAC9B,sBAAsB,EACtB,aAAa,GACd,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,cAAc,6BAA6B,CAAC"}
@@ -1,14 +1,18 @@
1
1
  import type React from "react";
2
2
  import type { FieldProps } from "./types.js";
3
3
  /**
4
- * description of the Field component
5
- * @returns {React.ReactElement} - Rendered Field
4
+ * A form field is the unit that pairs a single input with the surrounding meaning a user needs to act on it: a label naming what is being asked, optional descriptive guidance, the input itself, and validation feedback when an entry is rejected. It is the common frame every concrete form control adopts so that labelling, help text, optionality and error reporting behave the same across a form.
5
+ *
6
+ * This router has no single native root; the selected field renders its own root.
6
7
  *
7
8
  * `import { Field } from "@canonical/react-ds-global-form";`
8
- */
9
- declare const Field: ({ inputType, CustomComponent, ...props }: FieldProps) => React.ReactElement;
10
- /**
9
+ *
11
10
  * @implements ds:global.pattern.field
12
11
  */
12
+ declare const Field: <P extends {
13
+ name: string;
14
+ } = {
15
+ name: string;
16
+ }>(props: FieldProps<P>) => React.ReactElement;
13
17
  export default Field;
14
18
  //# sourceMappingURL=Field.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../../../../src/lib/pattern/Field/Field.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAoB/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;GAKG;AACH,QAAA,MAAM,KAAK,6CAIR,UAAU,KAAG,KAAK,CAAC,YAgDrB,CAAC;AAEF;;GAEG;eACY,KAAK"}
1
+ {"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../../../../src/lib/pattern/Field/Field.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAoB/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAqB7C;;;;;;;;GAQG;AACH,QAAA,MAAM,KAAK,GAAI,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,SACnD,UAAU,CAAC,CAAC,CAAC,KACnB,KAAK,CAAC,YAwDR,CAAC;eAEa,KAAK"}
@@ -1,66 +1,90 @@
1
- import type { InputProps } from "../../common/types.js";
2
- import type { CheckboxFieldProps } from "../../component/CheckboxField/index.js";
3
- import type { ChoicesFieldProps } from "../../component/ChoicesField/index.js";
4
- import type { ColorFieldProps } from "../../component/ColorField/index.js";
5
- import type { ComboboxFieldProps } from "../../component/ComboboxField/index.js";
6
- import type { DateFieldProps } from "../../component/DateField/index.js";
7
- import type { DateTimeFieldProps } from "../../component/DateTimeField/index.js";
8
- import type { FileUploadFieldProps } from "../../component/FileUploadField/index.js";
9
- import type { HiddenFieldProps } from "../../component/HiddenField/index.js";
10
- import type { NumberFieldProps } from "../../component/NumberField/index.js";
11
- import type { PasswordFieldProps } from "../../component/PasswordField/index.js";
12
- import type { PhoneFieldProps } from "../../component/PhoneField/index.js";
13
- import type { RangeFieldProps } from "../../component/RangeField/index.js";
14
- import type { RatingFieldProps } from "../../component/RatingField/index.js";
15
- import type { RichChoicesFieldProps } from "../../component/RichChoicesField/index.js";
16
- import type { SelectFieldProps } from "../../component/SelectField/index.js";
17
- import type { SwitchFieldProps } from "../../component/SwitchField/index.js";
18
- import type { TextareaFieldProps } from "../../component/TextareaField/index.js";
19
- import type { TextFieldProps } from "../../component/TextField/index.js";
20
- import type { TimeFieldProps } from "../../component/TimeField/index.js";
1
+ import type { ComponentProps, ComponentType } from "react";
2
+ import type { CheckboxField } from "../../component/CheckboxField/index.js";
3
+ import type { ChoicesField } from "../../component/ChoicesField/index.js";
4
+ import type { ColorField } from "../../component/ColorField/index.js";
5
+ import type { ComboboxField } from "../../component/ComboboxField/index.js";
6
+ import type { DateField } from "../../component/DateField/index.js";
7
+ import type { DateTimeField } from "../../component/DateTimeField/index.js";
8
+ import type { FileUploadField } from "../../component/FileUploadField/index.js";
9
+ import type { HiddenField } from "../../component/HiddenField/index.js";
10
+ import type { NumberField } from "../../component/NumberField/index.js";
11
+ import type { PasswordField } from "../../component/PasswordField/index.js";
12
+ import type { PhoneField } from "../../component/PhoneField/index.js";
13
+ import type { RangeField } from "../../component/RangeField/index.js";
14
+ import type { RatingField } from "../../component/RatingField/index.js";
15
+ import type { RichChoicesField } from "../../component/RichChoicesField/index.js";
16
+ import type { SelectField } from "../../component/SelectField/index.js";
17
+ import type { SwitchField } from "../../component/SwitchField/index.js";
18
+ import type { TextareaField } from "../../component/TextareaField/index.js";
19
+ import type { TextField } from "../../component/TextField/index.js";
20
+ import type { TimeField } from "../../component/TimeField/index.js";
21
21
  import type { NativeInputType } from "../../subcomponent/types.js";
22
22
  export type { BaseInputProps, BaseWrapperProps, Condition, InputProps, Middleware, WrappedComponentProps, WrapperHOCAdditionalProps, WrapperProps, } from "../../common/types.js";
23
23
  export type { BaseProps, NativeInputType, Option, OptionsProps, } from "../../subcomponent/types.js";
24
- export type FieldProps = ({
25
- inputType: Exclude<NativeInputType, "password" | "number">;
26
- } & TextFieldProps) | ({
24
+ type ReservedCustomKeys<P> = P extends unknown ? Extract<"inputType" | "CustomComponent" | "key", keyof P> : never;
25
+ type CustomVariant<P extends {
26
+ name: string;
27
+ }, Whole extends {
28
+ name: string;
29
+ } = P> = P extends unknown ? {
30
+ inputType: "custom";
31
+ CustomComponent: ComponentType<Whole>;
32
+ } & NoInfer<P> : never;
33
+ type TextInputType = Exclude<NativeInputType, "password" | "number">;
34
+ type TextVariants = {
35
+ [T in TextInputType]: {
36
+ inputType: T;
37
+ } & Omit<ComponentProps<typeof TextField>, "inputType">;
38
+ }[TextInputType];
39
+ type BuiltinFields = TextVariants | ({
27
40
  inputType: "password";
28
- } & PasswordFieldProps) | ({
41
+ } & ComponentProps<typeof PasswordField>) | ({
29
42
  inputType: "number";
30
- } & NumberFieldProps) | ({
43
+ } & ComponentProps<typeof NumberField>) | ({
31
44
  inputType: "checkbox";
32
- } & CheckboxFieldProps) | ({
45
+ } & ComponentProps<typeof CheckboxField>) | ({
33
46
  inputType: "switch";
34
- } & SwitchFieldProps) | ({
47
+ } & ComponentProps<typeof SwitchField>) | ({
35
48
  inputType: "hidden";
36
- } & HiddenFieldProps) | ({
49
+ } & ComponentProps<typeof HiddenField>) | ({
37
50
  inputType: "range";
38
- } & RangeFieldProps) | ({
51
+ } & ComponentProps<typeof RangeField>) | ({
39
52
  inputType: "rating";
40
- } & RatingFieldProps) | ({
53
+ } & ComponentProps<typeof RatingField>) | ({
41
54
  inputType: "select";
42
- } & SelectFieldProps) | ({
55
+ } & ComponentProps<typeof SelectField>) | ({
43
56
  inputType: "combobox";
44
- } & ComboboxFieldProps) | ({
57
+ } & ComponentProps<typeof ComboboxField>) | ({
45
58
  inputType: "choices";
46
- } & ChoicesFieldProps) | ({
59
+ } & ComponentProps<typeof ChoicesField>) | ({
47
60
  inputType: "textarea";
48
- } & TextareaFieldProps) | ({
61
+ } & ComponentProps<typeof TextareaField>) | ({
49
62
  inputType: "date";
50
- } & DateFieldProps) | ({
63
+ } & ComponentProps<typeof DateField>) | ({
51
64
  inputType: "time";
52
- } & TimeFieldProps) | ({
65
+ } & ComponentProps<typeof TimeField>) | ({
53
66
  inputType: "datetime";
54
- } & DateTimeFieldProps) | ({
67
+ } & ComponentProps<typeof DateTimeField>) | ({
55
68
  inputType: "file";
56
- } & FileUploadFieldProps) | ({
69
+ } & ComponentProps<typeof FileUploadField>) | ({
57
70
  inputType: "color";
58
- } & ColorFieldProps) | ({
71
+ } & ComponentProps<typeof ColorField>) | ({
59
72
  inputType: "phone";
60
- } & PhoneFieldProps) | ({
73
+ } & ComponentProps<typeof PhoneField>) | ({
61
74
  inputType: "rich-choices";
62
- } & RichChoicesFieldProps) | ({
63
- inputType: "custom";
64
- CustomComponent: React.ComponentType<InputProps<any>>;
65
- } & InputProps<any>);
75
+ } & ComponentProps<typeof RichChoicesField>);
76
+ type WithoutNativeType<T> = T extends unknown ? Omit<T, "type"> & {
77
+ type?: never;
78
+ } : never;
79
+ /**
80
+ * Props for a built-in or custom field. Custom props are inferred from the
81
+ * component in JSX or supplied as the type argument for a field map. They must
82
+ * include a string `name` and cannot declare `inputType`, `CustomComponent`,
83
+ * or React's `key`, which are consumed before the component is rendered.
84
+ */
85
+ export type FieldProps<P extends {
86
+ name: string;
87
+ } = {
88
+ name: string;
89
+ }> = WithoutNativeType<BuiltinFields> | ([ReservedCustomKeys<P>] extends [never] ? CustomVariant<P> : never);
66
90
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/pattern/Field/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAA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MAAM,UAAU,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,IAChE,iBAAiB,CAAC,aAAa,CAAC,GAChC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectInput.d.ts","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/SelectInput/SelectInput.tsx"],"names":[],"mappings":"AAEA,OAAO,cAAc,CAAC;AAItB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,4LAyBvB,CAAC;eAEa,WAAW"}
1
+ {"version":3,"file":"SelectInput.d.ts","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/SelectInput/SelectInput.tsx"],"names":[],"mappings":"AAEA,OAAO,cAAc,CAAC;AAItB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,4LA0BvB,CAAC;eAEa,WAAW"}
@@ -9,6 +9,12 @@ export type Option = {
9
9
  value: string;
10
10
  label: string;
11
11
  disabled?: boolean;
12
+ /**
13
+ * BCP 47 language of the label, when it differs from the page's: a language
14
+ * picker labels each option in its own language, and `lang` lets assistive
15
+ * technology pronounce it correctly.
16
+ */
17
+ lang?: string;
12
18
  };
13
19
  export type OptionsProps = {
14
20
  options: Option[];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/subcomponent/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B,CAAC;AAEF,gFAAgF;AAChF,MAAM,MAAM,MAAM,GAAG;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF,iEAAiE;AACjE,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,UAAU,GACV,OAAO,GACP,QAAQ,GACR,KAAK,GACL,KAAK,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/subcomponent/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B,CAAC;AAEF,gFAAgF;AAChF,MAAM,MAAM,MAAM,GAAG;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF,iEAAiE;AACjE,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,UAAU,GACV,OAAO,GACP,QAAQ,GACR,KAAK,GACL,KAAK,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@canonical/react-ds-global-form",
3
- "version": "0.44.1",
3
+ "version": "0.47.0",
4
4
  "type": "module",
5
+ "sideEffects": [
6
+ "*.css"
7
+ ],
8
+ "main": "dist/esm/index.js",
5
9
  "module": "dist/esm/index.js",
6
10
  "types": "dist/types/index.d.ts",
7
11
  "style": "dist/esm/index.css",
@@ -43,11 +47,11 @@
43
47
  "test:vitest:watch": "vitest"
44
48
  },
45
49
  "dependencies": {
46
- "@canonical/ds-utils": "^0.44.1",
47
- "@canonical/react-ds-global": "^0.44.1",
48
- "@canonical/storybook-config": "^0.44.1",
49
- "@canonical/styles": "^0.44.1",
50
- "@canonical/utils": "0.43.0",
50
+ "@canonical/ds-utils": "^0.47.0",
51
+ "@canonical/react-ds-global": "^0.47.0",
52
+ "@canonical/storybook-config": "^0.47.0",
53
+ "@canonical/styles": "^0.47.0",
54
+ "@canonical/utils": "0.44.0",
51
55
  "downshift": "^9.3.2",
52
56
  "react": "^19.2.4",
53
57
  "react-dom": "^19.2.4",
@@ -56,13 +60,13 @@
56
60
  "devDependencies": {
57
61
  "@biomejs/biome": "2.5.15",
58
62
  "@canonical/biome-config": "0.43.0",
59
- "@canonical/design-tokens": "0.43.0",
60
- "@canonical/storybook-addon-form-state": "^0.44.1",
61
- "@canonical/storybook-addon-msw": "^0.44.1",
62
- "@canonical/storybook-helpers": "^0.44.1",
63
- "@canonical/typescript-config-react": "^0.44.1",
64
- "@canonical/vitest-config-react": "^0.44.1",
65
- "@canonical/webarchitect": "0.43.0",
63
+ "@canonical/design-tokens": "0.44.0",
64
+ "@canonical/storybook-addon-form-state": "^0.47.0",
65
+ "@canonical/storybook-addon-msw": "^0.47.0",
66
+ "@canonical/storybook-helpers": "^0.47.0",
67
+ "@canonical/typescript-config-react": "^0.47.0",
68
+ "@canonical/vitest-config-react": "^0.47.0",
69
+ "@canonical/webarchitect": "0.44.0",
66
70
  "@chromatic-com/storybook": "^5.0.1",
67
71
  "@storybook/addon-docs": "^10.6.0",
68
72
  "@storybook/react-vite": "^10.6.0",
@@ -76,11 +80,11 @@
76
80
  "copyfiles": "^2.4.1",
77
81
  "globals": "^17.4.0",
78
82
  "jsdom": "^28.1.0",
79
- "msw": "^2.12.10",
83
+ "msw": "^3.0.0",
80
84
  "storybook": "^10.6.0",
81
85
  "typescript": "^7.0.2",
82
86
  "vite": "^8.0.1",
83
87
  "vitest": "^5.0.0"
84
88
  },
85
- "gitHead": "81ed283dd7509fb5de86dfe39021c62de3e31b5e"
89
+ "gitHead": "f846e7e21001a0fcbc4cd9f28c14a55cea7f4974"
86
90
  }