@canonical/react-ds-global-form 0.29.1 → 0.30.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/dist/esm/lib/common/Wrapper/ToggleWrapper.css +35 -0
- package/dist/esm/lib/common/Wrapper/ToggleWrapper.js +52 -0
- package/dist/esm/lib/common/Wrapper/ToggleWrapper.js.map +1 -0
- package/dist/esm/lib/common/Wrapper/Wrapper.js +2 -2
- package/dist/esm/lib/common/Wrapper/Wrapper.js.map +1 -1
- package/dist/esm/lib/common/Wrapper/hooks/useFieldWrapper.js +1 -1
- package/dist/esm/lib/common/Wrapper/hooks/useFieldWrapper.js.map +1 -1
- package/dist/esm/lib/common/Wrapper/index.js +2 -0
- package/dist/esm/lib/common/Wrapper/index.js.map +1 -1
- package/dist/esm/lib/common/Wrapper/withToggleWrapper.js +14 -0
- package/dist/esm/lib/common/Wrapper/withToggleWrapper.js.map +1 -0
- package/dist/esm/lib/component/CheckboxField/CheckboxField.js +8 -6
- package/dist/esm/lib/component/CheckboxField/CheckboxField.js.map +1 -1
- package/dist/esm/lib/component/ChoicesField/ChoicesField.js +2 -2
- package/dist/esm/lib/component/ChoicesField/ChoicesField.js.map +1 -1
- package/dist/esm/lib/component/ChoicesField/common/Option/Option.js +1 -1
- package/dist/esm/lib/component/ChoicesField/common/Option/Option.js.map +1 -1
- package/dist/esm/lib/component/ColorField/ColorField.js +3 -3
- package/dist/esm/lib/component/ColorField/ColorField.js.map +1 -1
- package/dist/esm/lib/component/ComboboxField/ComboboxField.js +3 -3
- package/dist/esm/lib/component/ComboboxField/ComboboxField.js.map +1 -1
- package/dist/esm/lib/component/DateField/DateField.js +3 -3
- package/dist/esm/lib/component/DateField/DateField.js.map +1 -1
- package/dist/esm/lib/component/DateTimeField/DateTimeField.js +3 -3
- package/dist/esm/lib/component/DateTimeField/DateTimeField.js.map +1 -1
- package/dist/esm/lib/component/FileUploadField/FileUploadField.js +3 -3
- package/dist/esm/lib/component/FileUploadField/FileUploadField.js.map +1 -1
- package/dist/esm/lib/component/HiddenField/HiddenField.js +3 -3
- package/dist/esm/lib/component/HiddenField/HiddenField.js.map +1 -1
- package/dist/esm/lib/component/NumberField/NumberField.js +3 -3
- package/dist/esm/lib/component/NumberField/NumberField.js.map +1 -1
- package/dist/esm/lib/component/PasswordField/PasswordField.js +3 -3
- package/dist/esm/lib/component/PasswordField/PasswordField.js.map +1 -1
- package/dist/esm/lib/component/PhoneField/PhoneField.js +3 -3
- package/dist/esm/lib/component/PhoneField/PhoneField.js.map +1 -1
- package/dist/esm/lib/component/RangeField/RangeField.js +2 -2
- package/dist/esm/lib/component/RangeField/RangeField.js.map +1 -1
- package/dist/esm/lib/component/RangeField/common/RangeControl/RangeControl.js +1 -1
- package/dist/esm/lib/component/RangeField/common/RangeControl/RangeControl.js.map +1 -1
- package/dist/esm/lib/component/RatingField/RatingField.js +12 -0
- package/dist/esm/lib/component/RatingField/RatingField.js.map +1 -0
- package/dist/esm/lib/component/RatingField/index.js +2 -0
- package/dist/esm/lib/component/RatingField/index.js.map +1 -0
- package/dist/esm/lib/component/RatingField/types.js +2 -0
- package/dist/esm/lib/component/RatingField/types.js.map +1 -0
- package/dist/esm/lib/component/RichChoicesField/RichChoicesField.js +2 -2
- package/dist/esm/lib/component/RichChoicesField/RichChoicesField.js.map +1 -1
- package/dist/esm/lib/component/RichChoicesField/common/Option/Option.js +1 -1
- package/dist/esm/lib/component/RichChoicesField/common/Option/Option.js.map +1 -1
- package/dist/esm/lib/component/RichChoicesField/styles.css +6 -0
- package/dist/esm/lib/component/SelectField/SelectField.js +3 -3
- package/dist/esm/lib/component/SelectField/SelectField.js.map +1 -1
- package/dist/esm/lib/component/SwitchField/SwitchField.js +13 -0
- package/dist/esm/lib/component/SwitchField/SwitchField.js.map +1 -0
- package/dist/esm/lib/component/SwitchField/index.js +2 -0
- package/dist/esm/lib/component/SwitchField/index.js.map +1 -0
- package/dist/esm/lib/component/SwitchField/types.js +2 -0
- package/dist/esm/lib/component/SwitchField/types.js.map +1 -0
- package/dist/esm/lib/component/TextField/TextField.js +3 -3
- package/dist/esm/lib/component/TextField/TextField.js.map +1 -1
- package/dist/esm/lib/component/TextareaField/TextareaField.js +3 -3
- package/dist/esm/lib/component/TextareaField/TextareaField.js.map +1 -1
- package/dist/esm/lib/component/TimeField/TimeField.js +3 -3
- package/dist/esm/lib/component/TimeField/TimeField.js.map +1 -1
- package/dist/esm/lib/component/index.js +2 -0
- package/dist/esm/lib/component/index.js.map +1 -1
- package/dist/esm/lib/index.js +2 -1
- package/dist/esm/lib/index.js.map +1 -1
- package/dist/esm/lib/pattern/Field/Field.js +23 -17
- package/dist/esm/lib/pattern/Field/Field.js.map +1 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/MultipleCombobox.js +14 -8
- package/dist/esm/lib/subcomponent/ComboboxInput/MultipleCombobox.js.map +1 -1
- package/dist/esm/lib/subcomponent/FileUploadInput/styles.css +3 -0
- package/dist/esm/lib/subcomponent/PhoneInput/PhoneInput.js +1 -1
- package/dist/esm/lib/subcomponent/PhoneInput/PhoneInput.js.map +1 -1
- package/dist/esm/lib/subcomponent/RatingInput/RatingInput.js +48 -0
- package/dist/esm/lib/subcomponent/RatingInput/RatingInput.js.map +1 -0
- package/dist/esm/lib/subcomponent/RatingInput/index.js +2 -0
- package/dist/esm/lib/subcomponent/RatingInput/index.js.map +1 -0
- package/dist/esm/lib/subcomponent/RatingInput/styles.css +159 -0
- package/dist/esm/lib/subcomponent/RatingInput/types.js +2 -0
- package/dist/esm/lib/subcomponent/RatingInput/types.js.map +1 -0
- package/dist/esm/lib/subcomponent/SwitchInput/SwitchInput.js +26 -0
- package/dist/esm/lib/subcomponent/SwitchInput/SwitchInput.js.map +1 -0
- package/dist/esm/lib/subcomponent/SwitchInput/index.js +2 -0
- package/dist/esm/lib/subcomponent/SwitchInput/index.js.map +1 -0
- package/dist/esm/lib/subcomponent/SwitchInput/styles.css +88 -0
- package/dist/esm/lib/subcomponent/SwitchInput/types.js +2 -0
- package/dist/esm/lib/subcomponent/SwitchInput/types.js.map +1 -0
- package/dist/esm/lib/subcomponent/index.js +2 -0
- package/dist/esm/lib/subcomponent/index.js.map +1 -1
- package/dist/types/lib/common/Wrapper/ToggleWrapper.d.ts +24 -0
- package/dist/types/lib/common/Wrapper/ToggleWrapper.d.ts.map +1 -0
- package/dist/types/lib/common/Wrapper/index.d.ts +2 -0
- package/dist/types/lib/common/Wrapper/index.d.ts.map +1 -1
- package/dist/types/lib/common/Wrapper/withToggleWrapper.d.ts +20 -0
- package/dist/types/lib/common/Wrapper/withToggleWrapper.d.ts.map +1 -0
- package/dist/types/lib/common/Wrapper/withWrapper.d.ts +1 -1
- package/dist/types/lib/common/Wrapper/withWrapper.d.ts.map +1 -1
- package/dist/types/lib/common/types.d.ts +24 -2
- package/dist/types/lib/common/types.d.ts.map +1 -1
- package/dist/types/lib/component/CheckboxField/CheckboxField.d.ts +8 -332
- package/dist/types/lib/component/CheckboxField/CheckboxField.d.ts.map +1 -1
- package/dist/types/lib/component/CheckboxField/types.d.ts +7 -4
- package/dist/types/lib/component/CheckboxField/types.d.ts.map +1 -1
- package/dist/types/lib/component/ChoicesField/ChoicesField.d.ts +1 -0
- package/dist/types/lib/component/ChoicesField/ChoicesField.d.ts.map +1 -1
- package/dist/types/lib/component/ChoicesField/common/Option/types.d.ts +1 -1
- package/dist/types/lib/component/ChoicesField/common/Option/types.d.ts.map +1 -1
- package/dist/types/lib/component/ChoicesField/types.d.ts +2 -2
- package/dist/types/lib/component/ChoicesField/types.d.ts.map +1 -1
- package/dist/types/lib/component/ColorField/ColorField.d.ts +2 -1
- package/dist/types/lib/component/ColorField/ColorField.d.ts.map +1 -1
- package/dist/types/lib/component/ColorField/types.d.ts +2 -2
- package/dist/types/lib/component/ColorField/types.d.ts.map +1 -1
- package/dist/types/lib/component/ComboboxField/ComboboxField.d.ts +1 -0
- package/dist/types/lib/component/ComboboxField/ComboboxField.d.ts.map +1 -1
- package/dist/types/lib/component/ComboboxField/types.d.ts +2 -2
- package/dist/types/lib/component/ComboboxField/types.d.ts.map +1 -1
- package/dist/types/lib/component/DateField/DateField.d.ts +1 -0
- package/dist/types/lib/component/DateField/DateField.d.ts.map +1 -1
- package/dist/types/lib/component/DateField/types.d.ts +2 -2
- package/dist/types/lib/component/DateField/types.d.ts.map +1 -1
- package/dist/types/lib/component/DateTimeField/DateTimeField.d.ts +1 -0
- package/dist/types/lib/component/DateTimeField/DateTimeField.d.ts.map +1 -1
- package/dist/types/lib/component/DateTimeField/types.d.ts +2 -2
- package/dist/types/lib/component/DateTimeField/types.d.ts.map +1 -1
- package/dist/types/lib/component/FileUploadField/FileUploadField.d.ts +1 -0
- package/dist/types/lib/component/FileUploadField/FileUploadField.d.ts.map +1 -1
- package/dist/types/lib/component/FileUploadField/types.d.ts +2 -2
- package/dist/types/lib/component/FileUploadField/types.d.ts.map +1 -1
- package/dist/types/lib/component/HiddenField/HiddenField.d.ts +1 -0
- package/dist/types/lib/component/HiddenField/HiddenField.d.ts.map +1 -1
- package/dist/types/lib/component/HiddenField/types.d.ts +2 -2
- package/dist/types/lib/component/HiddenField/types.d.ts.map +1 -1
- package/dist/types/lib/component/NumberField/NumberField.d.ts +1 -0
- package/dist/types/lib/component/NumberField/NumberField.d.ts.map +1 -1
- package/dist/types/lib/component/NumberField/types.d.ts +2 -2
- package/dist/types/lib/component/NumberField/types.d.ts.map +1 -1
- package/dist/types/lib/component/PasswordField/PasswordField.d.ts +1 -0
- package/dist/types/lib/component/PasswordField/PasswordField.d.ts.map +1 -1
- package/dist/types/lib/component/PasswordField/types.d.ts +2 -2
- package/dist/types/lib/component/PasswordField/types.d.ts.map +1 -1
- package/dist/types/lib/component/PhoneField/PhoneField.d.ts +3 -2
- package/dist/types/lib/component/PhoneField/PhoneField.d.ts.map +1 -1
- package/dist/types/lib/component/PhoneField/index.d.ts +1 -1
- package/dist/types/lib/component/PhoneField/index.d.ts.map +1 -1
- package/dist/types/lib/component/PhoneField/types.d.ts +2 -2
- package/dist/types/lib/component/PhoneField/types.d.ts.map +1 -1
- package/dist/types/lib/component/RangeField/RangeField.d.ts +1 -0
- package/dist/types/lib/component/RangeField/RangeField.d.ts.map +1 -1
- package/dist/types/lib/component/RangeField/types.d.ts +1 -1
- package/dist/types/lib/component/RangeField/types.d.ts.map +1 -1
- package/dist/types/lib/component/RatingField/RatingField.d.ts +46 -0
- package/dist/types/lib/component/RatingField/RatingField.d.ts.map +1 -0
- package/dist/types/lib/component/RatingField/index.d.ts +3 -0
- package/dist/types/lib/component/RatingField/index.d.ts.map +1 -0
- package/dist/types/lib/component/RatingField/types.d.ts +9 -0
- package/dist/types/lib/component/RatingField/types.d.ts.map +1 -0
- package/dist/types/lib/component/RichChoicesField/RichChoicesField.d.ts +1 -0
- package/dist/types/lib/component/RichChoicesField/RichChoicesField.d.ts.map +1 -1
- package/dist/types/lib/component/RichChoicesField/types.d.ts +2 -2
- package/dist/types/lib/component/RichChoicesField/types.d.ts.map +1 -1
- package/dist/types/lib/component/SelectField/SelectField.d.ts +1 -0
- package/dist/types/lib/component/SelectField/SelectField.d.ts.map +1 -1
- package/dist/types/lib/component/SelectField/types.d.ts +2 -2
- package/dist/types/lib/component/SelectField/types.d.ts.map +1 -1
- package/dist/types/lib/component/SwitchField/SwitchField.d.ts +14 -0
- package/dist/types/lib/component/SwitchField/SwitchField.d.ts.map +1 -0
- package/dist/types/lib/component/SwitchField/index.d.ts +3 -0
- package/dist/types/lib/component/SwitchField/index.d.ts.map +1 -0
- package/dist/types/lib/component/SwitchField/types.d.ts +8 -0
- package/dist/types/lib/component/SwitchField/types.d.ts.map +1 -0
- package/dist/types/lib/component/TextField/TextField.d.ts +2 -1
- package/dist/types/lib/component/TextField/TextField.d.ts.map +1 -1
- package/dist/types/lib/component/TextField/types.d.ts +2 -2
- package/dist/types/lib/component/TextField/types.d.ts.map +1 -1
- package/dist/types/lib/component/TextareaField/TextareaField.d.ts +1 -0
- package/dist/types/lib/component/TextareaField/TextareaField.d.ts.map +1 -1
- package/dist/types/lib/component/TextareaField/types.d.ts +2 -2
- package/dist/types/lib/component/TextareaField/types.d.ts.map +1 -1
- package/dist/types/lib/component/TimeField/TimeField.d.ts +1 -0
- package/dist/types/lib/component/TimeField/TimeField.d.ts.map +1 -1
- package/dist/types/lib/component/TimeField/types.d.ts +2 -2
- package/dist/types/lib/component/TimeField/types.d.ts.map +1 -1
- package/dist/types/lib/component/index.d.ts +2 -0
- package/dist/types/lib/component/index.d.ts.map +1 -1
- package/dist/types/lib/index.d.ts +2 -0
- package/dist/types/lib/index.d.ts.map +1 -1
- package/dist/types/lib/pattern/Field/Field.d.ts.map +1 -1
- package/dist/types/lib/pattern/Field/types.d.ts +27 -21
- package/dist/types/lib/pattern/Field/types.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/ComboboxInput/MultipleCombobox.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/PhoneInput/types.d.ts +2 -2
- package/dist/types/lib/subcomponent/PhoneInput/types.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/RatingInput/RatingInput.d.ts +23 -0
- package/dist/types/lib/subcomponent/RatingInput/RatingInput.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/RatingInput/index.d.ts +3 -0
- package/dist/types/lib/subcomponent/RatingInput/index.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/RatingInput/types.d.ts +52 -0
- package/dist/types/lib/subcomponent/RatingInput/types.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/SwitchInput/SwitchInput.d.ts +16 -0
- package/dist/types/lib/subcomponent/SwitchInput/SwitchInput.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/SwitchInput/index.d.ts +3 -0
- package/dist/types/lib/subcomponent/SwitchInput/index.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/SwitchInput/types.d.ts +8 -0
- package/dist/types/lib/subcomponent/SwitchInput/types.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/index.d.ts +4 -0
- package/dist/types/lib/subcomponent/index.d.ts.map +1 -1
- package/dist/types/lib/utils/middleware/addRESTOptions.d.ts +2 -2
- package/dist/types/lib/utils/middleware/addRESTOptions.d.ts.map +1 -1
- package/dist/types/lib/utils/middleware/addRESTValidation.d.ts +1 -1
- package/dist/types/lib/utils/middleware/addRESTValidation.d.ts.map +1 -1
- package/package.json +14 -20
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import bindField from "
|
|
2
|
-
import withWrapper from "
|
|
3
|
-
import { TextInput } from "
|
|
1
|
+
import bindField from "../../common/bindField/index.js";
|
|
2
|
+
import withWrapper from "../../common/Wrapper/withWrapper.js";
|
|
3
|
+
import { TextInput } from "../../subcomponent/TextInput/index.js";
|
|
4
4
|
/**
|
|
5
5
|
* TextInput bound to react-hook-form, wrapped with field chrome
|
|
6
6
|
* (label, description, error) and middleware/conditional-display support.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.js","sourceRoot":"","sources":["../../../../../src/lib/component/TextField/TextField.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"TextField.js","sourceRoot":"","sources":["../../../../../src/lib/component/TextField/TextField.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,iCAAiC,CAAC;AACxD,OAAO,WAAW,MAAM,qCAAqC,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAGlE;;;;;GAKG;AACH,eAAe,WAAW,CACxB,SAAS,CAAiB,SAAS,EAAE,QAAQ,CAAC,CAC/C,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import bindField from "
|
|
2
|
-
import withWrapper from "
|
|
3
|
-
import { TextareaInput } from "
|
|
1
|
+
import bindField from "../../common/bindField/index.js";
|
|
2
|
+
import withWrapper from "../../common/Wrapper/withWrapper.js";
|
|
3
|
+
import { TextareaInput } from "../../subcomponent/TextareaInput/index.js";
|
|
4
4
|
/**
|
|
5
5
|
* TextareaInput bound to react-hook-form, wrapped with field chrome
|
|
6
6
|
* (label, description, error) and middleware/conditional-display support.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextareaField.js","sourceRoot":"","sources":["../../../../../src/lib/component/TextareaField/TextareaField.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"TextareaField.js","sourceRoot":"","sources":["../../../../../src/lib/component/TextareaField/TextareaField.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,iCAAiC,CAAC;AACxD,OAAO,WAAW,MAAM,qCAAqC,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAG1E;;;;;GAKG;AACH,eAAe,WAAW,CACxB,SAAS,CAAqB,aAAa,EAAE,QAAQ,CAAC,CACvD,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import bindField from "
|
|
2
|
-
import withWrapper from "
|
|
3
|
-
import { TimeInput } from "
|
|
1
|
+
import bindField from "../../common/bindField/index.js";
|
|
2
|
+
import withWrapper from "../../common/Wrapper/withWrapper.js";
|
|
3
|
+
import { TimeInput } from "../../subcomponent/TimeInput/index.js";
|
|
4
4
|
/**
|
|
5
5
|
* Time input bound to react-hook-form, wrapped with field chrome
|
|
6
6
|
* (label, description, error) and middleware/conditional-display support.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeField.js","sourceRoot":"","sources":["../../../../../src/lib/component/TimeField/TimeField.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"TimeField.js","sourceRoot":"","sources":["../../../../../src/lib/component/TimeField/TimeField.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,iCAAiC,CAAC;AACxD,OAAO,WAAW,MAAM,qCAAqC,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAGlE;;;;;GAKG;AACH,eAAe,WAAW,CACxB,SAAS,CAAiB,SAAS,EAAE,QAAQ,CAAC,CAC/C,CAAC"}
|
|
@@ -12,8 +12,10 @@ export * from "./NumberField/index.js";
|
|
|
12
12
|
export * from "./PasswordField/index.js";
|
|
13
13
|
export * from "./PhoneField/index.js";
|
|
14
14
|
export * from "./RangeField/index.js";
|
|
15
|
+
export * from "./RatingField/index.js";
|
|
15
16
|
export * from "./RichChoicesField/index.js";
|
|
16
17
|
export * from "./SelectField/index.js";
|
|
18
|
+
export * from "./SwitchField/index.js";
|
|
17
19
|
export * from "./TextareaField/index.js";
|
|
18
20
|
export * from "./TextField/index.js";
|
|
19
21
|
export * from "./TimeField/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/component/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,oEAAoE;AACpE,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/component/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,oEAAoE;AACpE,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC"}
|
package/dist/esm/lib/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Public package surface (unchanged by the tier restructure): the Field pattern
|
|
2
2
|
// (Field + FieldProps + the shared/machinery types it re-exports), the Form
|
|
3
3
|
// pattern, and the form middleware. The component/ and subcomponent/ tiers are
|
|
4
|
-
// internal — composed by the Field pattern, not exported at the root.
|
|
4
|
+
// otherwise internal — composed by the Field pattern, not exported at the root.
|
|
5
5
|
export * from "./pattern/index.js";
|
|
6
|
+
export { RatingInput } from "./subcomponent/index.js";
|
|
6
7
|
export * from "./utils/middleware/index.js";
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -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,
|
|
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;AACtD,cAAc,6BAA6B,CAAC"}
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { CheckboxField } from "
|
|
3
|
-
import { ChoicesField } from "
|
|
4
|
-
import { ColorField } from "
|
|
5
|
-
import { ComboboxField } from "
|
|
6
|
-
import { DateField } from "
|
|
7
|
-
import { DateTimeField } from "
|
|
8
|
-
import { FileUploadField } from "
|
|
9
|
-
import { HiddenField } from "
|
|
10
|
-
import { NumberField } from "
|
|
11
|
-
import { PasswordField } from "
|
|
12
|
-
import { PhoneField } from "
|
|
13
|
-
import { RangeField } from "
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
2
|
+
import { CheckboxField } from "../../component/CheckboxField/index.js";
|
|
3
|
+
import { ChoicesField } from "../../component/ChoicesField/index.js";
|
|
4
|
+
import { ColorField } from "../../component/ColorField/index.js";
|
|
5
|
+
import { ComboboxField } from "../../component/ComboboxField/index.js";
|
|
6
|
+
import { DateField } from "../../component/DateField/index.js";
|
|
7
|
+
import { DateTimeField } from "../../component/DateTimeField/index.js";
|
|
8
|
+
import { FileUploadField } from "../../component/FileUploadField/index.js";
|
|
9
|
+
import { HiddenField } from "../../component/HiddenField/index.js";
|
|
10
|
+
import { NumberField } from "../../component/NumberField/index.js";
|
|
11
|
+
import { PasswordField } from "../../component/PasswordField/index.js";
|
|
12
|
+
import { PhoneField } from "../../component/PhoneField/index.js";
|
|
13
|
+
import { RangeField } from "../../component/RangeField/index.js";
|
|
14
|
+
import { RatingField } from "../../component/RatingField/index.js";
|
|
15
|
+
import { RichChoicesField } from "../../component/RichChoicesField/index.js";
|
|
16
|
+
import { SelectField } from "../../component/SelectField/index.js";
|
|
17
|
+
import { SwitchField } from "../../component/SwitchField/index.js";
|
|
18
|
+
import { TextareaField } from "../../component/TextareaField/index.js";
|
|
19
|
+
import { TextField } from "../../component/TextField/index.js";
|
|
20
|
+
import { TimeField } from "../../component/TimeField/index.js";
|
|
19
21
|
/**
|
|
20
22
|
* description of the Field component
|
|
21
23
|
* @returns {React.ReactElement} - Rendered Field
|
|
@@ -28,6 +30,10 @@ const Field = ({ inputType, CustomComponent, ...props }) => {
|
|
|
28
30
|
return _jsx(TextareaField, { ...props });
|
|
29
31
|
case "checkbox":
|
|
30
32
|
return _jsx(CheckboxField, { ...props });
|
|
33
|
+
case "switch":
|
|
34
|
+
return _jsx(SwitchField, { ...props });
|
|
35
|
+
case "rating":
|
|
36
|
+
return _jsx(RatingField, { ...props });
|
|
31
37
|
case "range":
|
|
32
38
|
return _jsx(RangeField, { ...props });
|
|
33
39
|
case "select":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.js","sourceRoot":"","sources":["../../../../../src/lib/pattern/Field/Field.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,
|
|
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,WAA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,OAAK,KAAK,GAAI,CAAC;QACtC,KAAK,MAAM;YACT,OAAO,KAAC,eAAe,OAAK,KAAK,GAAI,CAAC;QACxC,KAAK,OAAO;YACV,OAAO,KAAC,UAAU,OAAK,KAAK,GAAI,CAAC;QACnC,KAAK,OAAO;YACV,OAAO,KAAC,UAAU,OAAK,KAAK,GAAI,CAAC;QACnC,KAAK,UAAU;YACb,OAAO,KAAC,aAAa,OAAK,KAAK,GAAI,CAAC;QACtC,KAAK,QAAQ;YACX,OAAO,KAAC,WAAW,OAAK,KAAK,GAAI,CAAC;QACpC,KAAK,cAAc;YACjB,OAAO,KAAC,gBAAgB,OAAK,KAAK,GAAI,CAAC;QACzC,KAAK,QAAQ;YACX,IAAI,CAAC,eAAe,EAAE,CAAC;gBACrB,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;YACJ,CAAC;YACD,OAAO,KAAC,eAAe,OAAK,KAAK,GAAI,CAAC;QACxC;YACE,OAAO,KAAC,SAAS,IAAC,SAAS,EAAE,SAAS,KAAM,KAAK,GAAI,CAAC;IAC1D,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -26,12 +26,13 @@ const MultipleCombobox = ({ id, className, style, options, value, onChange, disa
|
|
|
26
26
|
.map((val) => convertValueToItem(val, options, valueKey))
|
|
27
27
|
.filter(Boolean);
|
|
28
28
|
}, [convertValueToItem, options, valueKey]);
|
|
29
|
-
//
|
|
29
|
+
// Keep selectedItems in sync with the controlled value — on mount and on every
|
|
30
|
+
// change. Must clear as well as populate: an empty/undefined `value` (e.g. after
|
|
31
|
+
// reset) has to drive `selectedItems` back to [], otherwise a later re-render
|
|
32
|
+
// that re-supplies the previous array would resurrect the cleared chips.
|
|
30
33
|
useEffect(() => {
|
|
31
|
-
const values = value;
|
|
32
|
-
|
|
33
|
-
setSelectedItems(convertValuesToItems(values));
|
|
34
|
-
}
|
|
34
|
+
const values = value ?? [];
|
|
35
|
+
setSelectedItems(values.length > 0 ? convertValuesToItems(values) : []);
|
|
35
36
|
}, [value, convertValuesToItems]);
|
|
36
37
|
// Downshift's useMultipleSelection hook for managing multiple selections
|
|
37
38
|
const { getSelectedItemProps, getDropdownProps, addSelectedItem, removeSelectedItem, } = useMultipleSelection({
|
|
@@ -39,8 +40,11 @@ const MultipleCombobox = ({ id, className, style, options, value, onChange, disa
|
|
|
39
40
|
onSelectedItemsChange: ({ selectedItems: newSelectedItems }) => {
|
|
40
41
|
if (newSelectedItems) {
|
|
41
42
|
setSelectedItems(newSelectedItems);
|
|
43
|
+
// Emit [] (never undefined) when the list empties: with a react-hook-form
|
|
44
|
+
// Controller that has a defaultValue, onChange(undefined) reverts the field
|
|
45
|
+
// to that default, resurrecting the removed chips. [] clears cleanly.
|
|
42
46
|
const newValue = newSelectedItems.map((item) => item[valueKey]);
|
|
43
|
-
onChange?.(newValue
|
|
47
|
+
onChange?.(newValue);
|
|
44
48
|
}
|
|
45
49
|
},
|
|
46
50
|
});
|
|
@@ -66,11 +70,13 @@ const MultipleCombobox = ({ id, className, style, options, value, onChange, disa
|
|
|
66
70
|
},
|
|
67
71
|
itemToString: convertItemToString,
|
|
68
72
|
});
|
|
69
|
-
// Reset function to clear selections and input
|
|
73
|
+
// Reset function to clear selections and input. Emits [] (not undefined) so a
|
|
74
|
+
// react-hook-form Controller with a defaultValue stores the cleared state
|
|
75
|
+
// rather than falling back to its default and repopulating the chips.
|
|
70
76
|
const resetSelection = useCallback(() => {
|
|
71
77
|
setSelectedItems([]);
|
|
72
78
|
setInputValue("");
|
|
73
|
-
onChange?.(
|
|
79
|
+
onChange?.([]);
|
|
74
80
|
}, [onChange, setInputValue]);
|
|
75
81
|
return (_jsxs("div", { id: id, style: style, className: [componentCssClassName, className].filter(Boolean).join(" "), children: [_jsx("div", { className: "selected-items", children: selectedItems.map((selectedItem, index) => (_jsxs("button", { ...getSelectedItemProps({ selectedItem, index }), onClick: () => removeSelectedItem(selectedItem), className: "chip", children: [convertItemToString(selectedItem), _jsx("span", { className: "remove-icon", children: "\u00D7" })] }, String(selectedItem[valueKey])))) }), _jsxs("div", { className: "ds input combobox-input chrome", children: [_jsx("input", { className: "p", ...getInputProps(getDropdownProps({ preventKeyAction: isOpen })), placeholder: placeholder, disabled: disabled }), _jsx(ResetButton, { onClick: resetSelection })] }), _jsx(List, { isOpen: isOpen, getMenuProps: getMenuProps, getItemProps: getItemProps, items: items, highlightedIndex: highlightedIndex, convertItemToString: convertItemToString, valueKey: valueKey, fieldValue: selectedItems.map((item) => String(item[valueKey])) })] }));
|
|
76
82
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultipleCombobox.js","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/ComboboxInput/MultipleCombobox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EACL,mBAAmB,IAAI,0BAA0B,EACjD,kBAAkB,IAAI,yBAAyB,EAC/C,WAAW,IAAI,kBAAkB,GAClC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAEjD;;;;;;;;;GASG;AACH,MAAM,gBAAgB,GAAG,CAAC,EACxB,EAAE,EACF,SAAS,EACT,KAAK,EACL,OAAO,EACP,KAAK,EACL,QAAQ,EACR,QAAQ,GAAG,KAAK,EAChB,WAAW,EACX,QAAQ,GAAG,SAAS,EACpB,mBAAmB,GAAG,0BAA0B,EAChD,kBAAkB,GAAG,yBAAyB,EAC9C,WAAW,GAAG,kBAAkB,EAChC,yBAAyB,GACN,EAAsB,EAAE;IAC3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G,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,GAC/D,IACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -117,6 +117,9 @@
|
|
|
117
117
|
color: var(--color-text);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
/* biome-ignore lint/style/noDescendingSpecificity: :disabled follows :hover by
|
|
121
|
+
interaction-state order; both target the same element and reordering would
|
|
122
|
+
change the cascade for no visual gain. */
|
|
120
123
|
&:disabled {
|
|
121
124
|
cursor: not-allowed;
|
|
122
125
|
opacity: 0.5;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useMemo, useState } from "react";
|
|
3
|
-
import { applyPhoneMask, countries as defaultCountries, } from "
|
|
3
|
+
import { applyPhoneMask, countries as defaultCountries, } from "../../utils/countries/index.js";
|
|
4
4
|
import "./styles.css";
|
|
5
5
|
const componentCssClassName = "ds input phone chrome";
|
|
6
6
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhoneInput.js","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/PhoneInput/PhoneInput.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EACL,cAAc,EAEd,SAAS,IAAI,gBAAgB,GAE9B,MAAM
|
|
1
|
+
{"version":3,"file":"PhoneInput.js","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/PhoneInput/PhoneInput.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EACL,cAAc,EAEd,SAAS,IAAI,gBAAgB,GAE9B,MAAM,gCAAgC,CAAC;AAEx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IAAI;QACxB,CAAC,CAAC,cAAc,CAAC,gBAAgB,EAAE,EAAE,kBAAkB,CAAC,MAAM,CAAC;QAC/D,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAEvB,OAAO,CACL,eACE,EAAE,EAAE,EAAE,EACN,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,aAEvE,iBACE,SAAS,EAAC,kBAAkB,EAC5B,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,mBAAmB,EAC7B,QAAQ,EAAE,QAAQ,gBACP,cAAc,YAExB,eAAe,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAChC,kBAA2B,KAAK,EAAE,OAAO,CAAC,IAAI,aAC3C,OAAO,CAAC,QAAQ,OAAG,YAAY,CAAC,OAAO,EAAE,cAAc,CAAC,KAD9C,OAAO,CAAC,IAAI,CAEhB,CACV,CAAC,GACK,EACT,gBACE,IAAI,EAAC,KAAK,EACV,SAAS,EAAC,gBAAgB,EAC1B,SAAS,EAAC,KAAK,EACf,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,kBAAkB,EAC5B,QAAQ,EAAE,QAAQ,gBACP,cAAc,GACzB,IACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import "./styles.css";
|
|
4
|
+
const componentCssClassName = "ds form-rating";
|
|
5
|
+
const defaultFormatStarLabel = (value, count) => `${value} of ${count} star${count === 1 ? "" : "s"}`;
|
|
6
|
+
/**
|
|
7
|
+
* Presentational star-rating input — pure markup, no react-hook-form. It is a
|
|
8
|
+
* radio group of `count` stars (5 or 10): exactly one value is selectable, so it
|
|
9
|
+
* inherits the native radio semantics — arrow keys move and select, Tab reaches
|
|
10
|
+
* the group once, and each choice is announced with its name and position.
|
|
11
|
+
*
|
|
12
|
+
* With `allowHalf`, every star carries two overlaid radio targets — the left
|
|
13
|
+
* half selects a half rating (n − 0.5), the right half the full star (n) — so
|
|
14
|
+
* the same five (or ten) stars stay on screen and clicking a star's left side
|
|
15
|
+
* gives a half. The fill is masked: a star is fully or half filled by clipping
|
|
16
|
+
* the solid-star glyph over the outline one.
|
|
17
|
+
*
|
|
18
|
+
* Usable standalone (controlled via `value`/`onChange`, or uncontrolled via
|
|
19
|
+
* `defaultValue`).
|
|
20
|
+
*
|
|
21
|
+
* `import { RatingInput } from "@canonical/react-ds-global-form";`
|
|
22
|
+
*/
|
|
23
|
+
export const RatingInput = ({ id, className, style, name, count = 5, allowHalf = false, value, defaultValue, onChange, disabled = false, formatStarLabel = defaultFormatStarLabel, ...labelling }) => {
|
|
24
|
+
const reactId = useId();
|
|
25
|
+
const groupId = id ?? reactId;
|
|
26
|
+
const stars = Array.from({ length: count }, (_, i) => i + 1);
|
|
27
|
+
// For a star `n`, the selectable ratings it offers: [n] normally, or
|
|
28
|
+
// [n - 0.5, n] when half ratings are allowed (left half then right half).
|
|
29
|
+
const ratingsFor = (star) => allowHalf ? [star - 0.5, star] : [star];
|
|
30
|
+
const isChecked = (rating) => value !== undefined ? value === rating : undefined;
|
|
31
|
+
return (_jsx("div", { id: groupId, style: style, className: [componentCssClassName, allowHalf && "half", className]
|
|
32
|
+
.filter(Boolean)
|
|
33
|
+
.join(" "), role: "radiogroup", "aria-label": labelling["aria-labelledby"]
|
|
34
|
+
? undefined
|
|
35
|
+
: (labelling["aria-label"] ?? "Rating"), "aria-labelledby": labelling["aria-labelledby"], children: stars.map((star) => (_jsxs("span", { className: "star", children: [_jsx("span", { className: "star-glyph", "aria-hidden": "true" }), ratingsFor(star).map((rating) => {
|
|
36
|
+
const half = rating % 1 !== 0;
|
|
37
|
+
const ratingId = `${groupId}-${rating}`;
|
|
38
|
+
const label = formatStarLabel(rating, count);
|
|
39
|
+
return (
|
|
40
|
+
// The label is the positioned click target and wraps its own
|
|
41
|
+
// (visually-hidden) radio, so it is a labelled control.
|
|
42
|
+
_jsxs("label", { className: ["star-target", half ? "left" : "right"].join(" "), title: label, children: [_jsx("input", { id: ratingId, className: "star-input", type: "radio", name: name, value: rating, disabled: disabled, "data-rating": rating, ...(value !== undefined
|
|
43
|
+
? { checked: isChecked(rating) }
|
|
44
|
+
: { defaultChecked: defaultValue === rating }), onChange: () => onChange?.(rating) }), _jsx("span", { className: "ds-visually-hidden", children: label })] }, rating));
|
|
45
|
+
})] }, star))) }));
|
|
46
|
+
};
|
|
47
|
+
export default RatingInput;
|
|
48
|
+
//# sourceMappingURL=RatingInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RatingInput.js","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/RatingInput/RatingInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,KAAK,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAE/C,MAAM,sBAAsB,GAAG,CAAC,KAAa,EAAE,KAAa,EAAE,EAAE,CAC9D,GAAG,KAAK,OAAO,KAAK,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AAEvD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAC1B,EAAE,EACF,SAAS,EACT,KAAK,EACL,IAAI,EACJ,KAAK,GAAG,CAAC,EACT,SAAS,GAAG,KAAK,EACjB,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,QAAQ,GAAG,KAAK,EAChB,eAAe,GAAG,sBAAsB,EACxC,GAAG,SAAS,EACK,EAAgB,EAAE;IACnC,MAAM,OAAO,GAAG,KAAK,EAAE,CAAC;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OAAO,IAAI,MAAM,EAAE,CAAC;oBACxC,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;oBAC7C,OAAO;oBACL,6DAA6D;oBAC7D,wDAAwD;oBACxD,iBAEE,SAAS,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAC7D,KAAK,EAAE,KAAK,aAEZ,gBACE,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAC,YAAY,EACtB,IAAI,EAAC,OAAO,EACZ,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,QAAQ,iBACL,MAAM,KAEf,CAAC,KAAK,KAAK,SAAS;oCACtB,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE;oCAChC,CAAC,CAAC,EAAE,cAAc,EAAE,YAAY,KAAK,MAAM,EAAE,CAAC,EAChD,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,GAClC,EACF,eAAM,SAAS,EAAC,oBAAoB,YAAE,KAAK,GAAQ,KAlB9C,MAAM,CAmBL,CACT,CAAC;gBACJ,CAAC,CAAC,KAlCwB,IAAI,CAmCzB,CACR,CAAC,GACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/RatingInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/* RatingInput — a radio group of stars.
|
|
2
|
+
*
|
|
3
|
+
* There are always `count` visible stars, in natural DOM order (star 1 first,
|
|
4
|
+
* left to right), so the visual, keyboard and screen-reader order all agree.
|
|
5
|
+
* With `allowHalf` each star carries two overlaid radio targets (a left half and
|
|
6
|
+
* a right half); without it, one radio per star.
|
|
7
|
+
*
|
|
8
|
+
* The fill is masked. Each star renders an outline `starred-off` glyph; a solid
|
|
9
|
+
* `starred` glyph is layered over it (`.star::after`) and its width is clipped
|
|
10
|
+
* to 0%, 50% or 100% to show empty, half or full — so half-fill is one masked
|
|
11
|
+
* shape rather than a separate half-width star.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
.ds.form-rating {
|
|
15
|
+
display: inline-flex;
|
|
16
|
+
gap: var(--dimension-025, 0.125rem);
|
|
17
|
+
|
|
18
|
+
--rating-color-empty: var(--color-text-muted, #b0b0b0);
|
|
19
|
+
--rating-color-filled: var(--color-foreground-primary-warning, #f5a623);
|
|
20
|
+
--rating-size: var(--rating-size-default, 1.5rem);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.ds.form-rating > .star {
|
|
24
|
+
position: relative;
|
|
25
|
+
display: inline-block;
|
|
26
|
+
width: var(--rating-size);
|
|
27
|
+
height: var(--rating-size);
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* Outline star (empty base). */
|
|
32
|
+
.ds.form-rating > .star > .star-glyph {
|
|
33
|
+
display: block;
|
|
34
|
+
width: 100%;
|
|
35
|
+
height: 100%;
|
|
36
|
+
background-color: var(--rating-color-empty);
|
|
37
|
+
mask: url("/icons/starred-off.svg#starred-off") no-repeat center / contain;
|
|
38
|
+
-webkit-mask:
|
|
39
|
+
url("/icons/starred-off.svg#starred-off") no-repeat center / contain;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* Solid star (fill overlay), clipped to a fill amount that defaults to 0. */
|
|
43
|
+
.ds.form-rating > .star::after {
|
|
44
|
+
content: "";
|
|
45
|
+
position: absolute;
|
|
46
|
+
inset: 0;
|
|
47
|
+
width: var(--star-fill, 0%);
|
|
48
|
+
overflow: hidden;
|
|
49
|
+
background-color: var(--rating-color-filled);
|
|
50
|
+
mask: url("/icons/starred.svg#starred") no-repeat left center / auto 100%;
|
|
51
|
+
-webkit-mask:
|
|
52
|
+
url("/icons/starred.svg#starred") no-repeat left center / auto 100%;
|
|
53
|
+
/* The mask must stay the full star width so clipping the box reveals a left
|
|
54
|
+
slice of the star, not a squashed star. */
|
|
55
|
+
mask-size: var(--rating-size) 100%;
|
|
56
|
+
-webkit-mask-size: var(--rating-size) 100%;
|
|
57
|
+
pointer-events: none;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* Radios are visually hidden but keep a11y semantics and keyboard focus. */
|
|
61
|
+
.ds.form-rating .star-input {
|
|
62
|
+
position: absolute;
|
|
63
|
+
width: 1px;
|
|
64
|
+
height: 1px;
|
|
65
|
+
margin: -1px;
|
|
66
|
+
padding: 0;
|
|
67
|
+
border: 0;
|
|
68
|
+
clip-path: inset(50%);
|
|
69
|
+
overflow: hidden;
|
|
70
|
+
white-space: nowrap;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Click targets. Full mode: one target covering the star. Half mode: a left
|
|
74
|
+
half and a right half, each an absolutely-positioned 50%-wide hit area. */
|
|
75
|
+
.ds.form-rating > .star > .star-target {
|
|
76
|
+
position: absolute;
|
|
77
|
+
inset: 0;
|
|
78
|
+
z-index: 1;
|
|
79
|
+
}
|
|
80
|
+
.ds.form-rating.half > .star > .star-target.left {
|
|
81
|
+
right: 50%;
|
|
82
|
+
}
|
|
83
|
+
.ds.form-rating.half > .star > .star-target.right {
|
|
84
|
+
left: 50%;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* --- Fill amount -------------------------------------------------------------
|
|
88
|
+
A star is FULL when its full radio is checked, or when any later star has a
|
|
89
|
+
radio checked. It is HALF when its half radio is checked (and no later star
|
|
90
|
+
is). CSS custom property `--star-fill` drives the ::after width. */
|
|
91
|
+
|
|
92
|
+
/* Full: this star's whole-number radio is checked. */
|
|
93
|
+
.ds.form-rating
|
|
94
|
+
> .star:has(
|
|
95
|
+
> .star-input[data-rating$="0"]:checked,
|
|
96
|
+
> .star-input:not([data-rating*="."]):checked
|
|
97
|
+
) {
|
|
98
|
+
--star-fill: 100%;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* Full: any later star has a checked radio → this star is fully filled. */
|
|
102
|
+
.ds.form-rating > .star:has(~ .star .star-input:checked) {
|
|
103
|
+
--star-fill: 100%;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* Half: this star's half radio (a `.5` value) is checked. Comes after the full
|
|
107
|
+
rules so, when both apply to different stars, each resolves independently. */
|
|
108
|
+
.ds.form-rating.half
|
|
109
|
+
> .star:has(> .star-input[data-rating$=".5"]:checked):not(
|
|
110
|
+
:has(~ .star .star-input:checked)
|
|
111
|
+
) {
|
|
112
|
+
--star-fill: 50%;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* Hover preview overrides the checked fill until the pointer leaves. */
|
|
116
|
+
@media (hover: hover) {
|
|
117
|
+
.ds.form-rating:hover > .star {
|
|
118
|
+
--star-fill: 0%;
|
|
119
|
+
}
|
|
120
|
+
/* Hovering a right (or full) target fills that star and every earlier one. */
|
|
121
|
+
.ds.form-rating > .star:hover,
|
|
122
|
+
.ds.form-rating > .star:has(~ .star:hover) {
|
|
123
|
+
--star-fill: 100%;
|
|
124
|
+
}
|
|
125
|
+
/* Hovering a left half-target fills earlier stars fully and this one to 50%. */
|
|
126
|
+
.ds.form-rating.half > .star:has(> .star-target.left:hover) {
|
|
127
|
+
--star-fill: 50%;
|
|
128
|
+
}
|
|
129
|
+
.ds.form-rating.half > .star:has(~ .star > .star-target.left:hover) {
|
|
130
|
+
--star-fill: 100%;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* Keyboard focus ring on the star whose radio is focused. */
|
|
135
|
+
.ds.form-rating > .star:has(> .star-input:focus-visible) {
|
|
136
|
+
outline: var(--focus-outline-width, 2px) solid
|
|
137
|
+
var(--color-focusRing, currentColor);
|
|
138
|
+
outline-offset: 2px;
|
|
139
|
+
border-radius: var(--dimension-radius-small, 2px);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/* Disabled. */
|
|
143
|
+
.ds.form-rating:has(.star-input:disabled) > .star {
|
|
144
|
+
cursor: not-allowed;
|
|
145
|
+
opacity: 0.5;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* Local visually-hidden helper for the per-target text label. */
|
|
149
|
+
.ds.form-rating .ds-visually-hidden {
|
|
150
|
+
position: absolute;
|
|
151
|
+
width: 1px;
|
|
152
|
+
height: 1px;
|
|
153
|
+
margin: -1px;
|
|
154
|
+
padding: 0;
|
|
155
|
+
border: 0;
|
|
156
|
+
clip-path: inset(50%);
|
|
157
|
+
overflow: hidden;
|
|
158
|
+
white-space: nowrap;
|
|
159
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/RatingInput/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import "./styles.css";
|
|
4
|
+
const componentCssClassName = "ds form-switch";
|
|
5
|
+
/**
|
|
6
|
+
* Presentational switch input — pure markup, no react-hook-form.
|
|
7
|
+
*
|
|
8
|
+
* A switch is a checkbox with `role="switch"`, styled as a sliding toggle.
|
|
9
|
+
* Usable standalone (controlled via `checked`/`onChange`, or uncontrolled) or
|
|
10
|
+
* via the field tier, which spreads react-hook-form's `register()` result onto
|
|
11
|
+
* it. Do not use directly in a form — use SwitchField instead.
|
|
12
|
+
* @returns {ReactElement} - Rendered Switch
|
|
13
|
+
*
|
|
14
|
+
* `import { SwitchInput } from "@canonical/react-ds-global-form";`
|
|
15
|
+
*/
|
|
16
|
+
export const SwitchInput = forwardRef(function SwitchInput({ id, className, style, ...nativeProps }, ref) {
|
|
17
|
+
return (_jsx("input", { id: id, style: style, className: [componentCssClassName, className].filter(Boolean).join(" "), ref: ref, ...nativeProps,
|
|
18
|
+
// `type`/`role` are the fixed switch semantics: spread `nativeProps`
|
|
19
|
+
// BEFORE them so they can never be overridden (belt-and-suspenders with
|
|
20
|
+
// omitting the keys from SwitchInputProps).
|
|
21
|
+
type: "checkbox",
|
|
22
|
+
// biome-ignore lint/a11y/useAriaPropsForRole: a native checkbox exposes its checked state to the a11y tree, so role="switch" needs no explicit aria-checked.
|
|
23
|
+
role: "switch" }));
|
|
24
|
+
});
|
|
25
|
+
export default SwitchInput;
|
|
26
|
+
//# sourceMappingURL=SwitchInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwitchInput.js","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/SwitchInput/SwitchInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,OAAO,CAAC;AAEtD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAE/C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CACnC,SAAS,WAAW,CAClB,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,WAAW,EAAE,EACxC,GAAG;IAEH,OAAO,CACL,gBACE,EAAE,EAAE,EAAE,EACN,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EACvE,GAAG,EAAE,GAAG,KACJ,WAAW;QACf,qEAAqE;QACrE,wEAAwE;QACxE,4CAA4C;QAC5C,IAAI,EAAC,UAAU;QACf,6JAA6J;QAC7J,IAAI,EAAC,QAAQ,GACb,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/SwitchInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|