@canonical/react-ds-global-form 0.44.0 → 0.45.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 +20 -0
- package/dist/esm/lib/index.js +4 -4
- package/dist/esm/lib/index.js.map +1 -1
- package/dist/esm/lib/subcomponent/SelectInput/SelectInput.js +1 -1
- package/dist/esm/lib/subcomponent/SelectInput/SelectInput.js.map +1 -1
- package/dist/esm/lib/subcomponent/SelectInput/styles.css +11 -0
- package/dist/types/lib/index.d.ts +2 -2
- package/dist/types/lib/index.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/SelectInput/SelectInput.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/types.d.ts +6 -0
- package/dist/types/lib/subcomponent/types.d.ts.map +1 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -171,6 +171,26 @@ import { MyColorPicker } from "./MyColorPicker";
|
|
|
171
171
|
|
|
172
172
|
Custom components must be wrapped with `withWrapper`. Custom components must satisfy the `InputProps` type and integrate with react-hook-form via `useFormContext`.
|
|
173
173
|
|
|
174
|
+
### Standalone Inputs
|
|
175
|
+
|
|
176
|
+
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.
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
import { SelectInput } from "@canonical/react-ds-global-form";
|
|
180
|
+
|
|
181
|
+
<SelectInput
|
|
182
|
+
aria-label="Language"
|
|
183
|
+
value={locale}
|
|
184
|
+
onChange={(event) => setLocale(event.target.value)}
|
|
185
|
+
options={[
|
|
186
|
+
{ value: "en", label: "English", lang: "en" },
|
|
187
|
+
{ value: "fr", label: "français", lang: "fr" },
|
|
188
|
+
]}
|
|
189
|
+
/>
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
An option's optional `lang` marks a label written in another language, so assistive technology pronounces it correctly.
|
|
193
|
+
|
|
174
194
|
## Middleware Pattern
|
|
175
195
|
|
|
176
196
|
Middleware are higher-order components that wrap fields to add functionality. They compose via the `middleware` prop:
|
package/dist/esm/lib/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// Public package surface
|
|
1
|
+
// Public package surface: the Field pattern
|
|
2
2
|
// (Field + FieldProps + the shared/machinery types it re-exports), the Form
|
|
3
|
-
// pattern,
|
|
4
|
-
// otherwise internal — composed by the Field pattern
|
|
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,
|
|
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"}
|
|
@@ -14,7 +14,7 @@ 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,UA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M,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,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;
|
|
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 +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,
|
|
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;
|
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/react-ds-global-form",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.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/ds-utils": "^0.
|
|
47
|
-
"@canonical/react-ds-global": "^0.
|
|
48
|
-
"@canonical/storybook-config": "^0.
|
|
49
|
-
"@canonical/styles": "^0.
|
|
46
|
+
"@canonical/ds-utils": "^0.45.0",
|
|
47
|
+
"@canonical/react-ds-global": "^0.45.0",
|
|
48
|
+
"@canonical/storybook-config": "^0.45.0",
|
|
49
|
+
"@canonical/styles": "^0.45.0",
|
|
50
50
|
"@canonical/utils": "0.43.0",
|
|
51
51
|
"downshift": "^9.3.2",
|
|
52
52
|
"react": "^19.2.4",
|
|
@@ -54,14 +54,14 @@
|
|
|
54
54
|
"react-hook-form": "^7.71.2"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@biomejs/biome": "2.5.
|
|
57
|
+
"@biomejs/biome": "2.5.15",
|
|
58
58
|
"@canonical/biome-config": "0.43.0",
|
|
59
59
|
"@canonical/design-tokens": "0.43.0",
|
|
60
|
-
"@canonical/storybook-addon-form-state": "^0.
|
|
61
|
-
"@canonical/storybook-addon-msw": "^0.
|
|
62
|
-
"@canonical/storybook-helpers": "^0.
|
|
63
|
-
"@canonical/typescript-config-react": "^0.
|
|
64
|
-
"@canonical/vitest-config-react": "^0.
|
|
60
|
+
"@canonical/storybook-addon-form-state": "^0.45.0",
|
|
61
|
+
"@canonical/storybook-addon-msw": "^0.45.0",
|
|
62
|
+
"@canonical/storybook-helpers": "^0.45.0",
|
|
63
|
+
"@canonical/typescript-config-react": "^0.45.0",
|
|
64
|
+
"@canonical/vitest-config-react": "^0.45.0",
|
|
65
65
|
"@canonical/webarchitect": "0.43.0",
|
|
66
66
|
"@chromatic-com/storybook": "^5.0.1",
|
|
67
67
|
"@storybook/addon-docs": "^10.6.0",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"vite": "^8.0.1",
|
|
83
83
|
"vitest": "^5.0.0"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "f8c2473f9aa92d14c24f0976f2f02ebc4944f32f"
|
|
86
86
|
}
|