@salt-ds/core 1.8.0-rc.1 → 1.8.0-rc.3
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-cjs/button/Button.css.js +1 -1
- package/dist-cjs/checkbox/Checkbox.css.js +1 -1
- package/dist-cjs/checkbox/Checkbox.js +55 -20
- package/dist-cjs/checkbox/Checkbox.js.map +1 -1
- package/dist-cjs/checkbox/CheckboxGroup.css.js +1 -1
- package/dist-cjs/checkbox/CheckboxGroup.js +25 -3
- package/dist-cjs/checkbox/CheckboxGroup.js.map +1 -1
- package/dist-cjs/checkbox/CheckboxIcon.css.js +1 -1
- package/dist-cjs/checkbox/CheckboxIcon.js +46 -26
- package/dist-cjs/checkbox/CheckboxIcon.js.map +1 -1
- package/dist-cjs/checkbox/internal/CheckboxGroupContext.js.map +1 -1
- package/dist-cjs/form-field/FormField.css.js +1 -1
- package/dist-cjs/form-field/FormField.js +4 -2
- package/dist-cjs/form-field/FormField.js.map +1 -1
- package/dist-cjs/form-field/FormFieldHelperText.css.js +1 -1
- package/dist-cjs/form-field/FormFieldLabel.css.js +1 -1
- package/dist-cjs/form-field/FormFieldLabel.js +19 -6
- package/dist-cjs/form-field/FormFieldLabel.js.map +1 -1
- package/dist-cjs/form-field-context/FormFieldContext.js.map +1 -1
- package/dist-cjs/index.js +2 -4
- package/dist-cjs/index.js.map +1 -1
- package/dist-cjs/input/Input.css.js +1 -1
- package/dist-cjs/input/Input.js +11 -7
- package/dist-cjs/input/Input.js.map +1 -1
- package/dist-cjs/radio-button/RadioButton.css.js +1 -1
- package/dist-cjs/radio-button/RadioButton.js +49 -10
- package/dist-cjs/radio-button/RadioButton.js.map +1 -1
- package/dist-cjs/radio-button/RadioButtonGroup.css.js +1 -1
- package/dist-cjs/radio-button/RadioButtonGroup.js +23 -1
- package/dist-cjs/radio-button/RadioButtonGroup.js.map +1 -1
- package/dist-cjs/radio-button/RadioButtonIcon.css.js +1 -1
- package/dist-cjs/radio-button/RadioButtonIcon.js +29 -24
- package/dist-cjs/radio-button/RadioButtonIcon.js.map +1 -1
- package/dist-cjs/radio-button/internal/RadioGroupContext.js.map +1 -1
- package/dist-cjs/status-adornment/StatusAdornment.css.js +1 -1
- package/dist-cjs/status-adornment/StatusAdornment.js.map +1 -1
- package/dist-cjs/utils/useResponsiveProp.js +7 -5
- package/dist-cjs/utils/useResponsiveProp.js.map +1 -1
- package/dist-es/button/Button.css.js +1 -1
- package/dist-es/checkbox/Checkbox.css.js +1 -1
- package/dist-es/checkbox/Checkbox.js +55 -20
- package/dist-es/checkbox/Checkbox.js.map +1 -1
- package/dist-es/checkbox/CheckboxGroup.css.js +1 -1
- package/dist-es/checkbox/CheckboxGroup.js +25 -3
- package/dist-es/checkbox/CheckboxGroup.js.map +1 -1
- package/dist-es/checkbox/CheckboxIcon.css.js +1 -1
- package/dist-es/checkbox/CheckboxIcon.js +47 -27
- package/dist-es/checkbox/CheckboxIcon.js.map +1 -1
- package/dist-es/checkbox/internal/CheckboxGroupContext.js.map +1 -1
- package/dist-es/form-field/FormField.css.js +1 -1
- package/dist-es/form-field/FormField.js +4 -2
- package/dist-es/form-field/FormField.js.map +1 -1
- package/dist-es/form-field/FormFieldHelperText.css.js +1 -1
- package/dist-es/form-field/FormFieldLabel.css.js +1 -1
- package/dist-es/form-field/FormFieldLabel.js +20 -7
- package/dist-es/form-field/FormFieldLabel.js.map +1 -1
- package/dist-es/form-field-context/FormFieldContext.js.map +1 -1
- package/dist-es/index.js +1 -2
- package/dist-es/index.js.map +1 -1
- package/dist-es/input/Input.css.js +1 -1
- package/dist-es/input/Input.js +11 -7
- package/dist-es/input/Input.js.map +1 -1
- package/dist-es/radio-button/RadioButton.css.js +1 -1
- package/dist-es/radio-button/RadioButton.js +49 -10
- package/dist-es/radio-button/RadioButton.js.map +1 -1
- package/dist-es/radio-button/RadioButtonGroup.css.js +1 -1
- package/dist-es/radio-button/RadioButtonGroup.js +23 -1
- package/dist-es/radio-button/RadioButtonGroup.js.map +1 -1
- package/dist-es/radio-button/RadioButtonIcon.css.js +1 -1
- package/dist-es/radio-button/RadioButtonIcon.js +30 -25
- package/dist-es/radio-button/RadioButtonIcon.js.map +1 -1
- package/dist-es/radio-button/internal/RadioGroupContext.js.map +1 -1
- package/dist-es/status-adornment/StatusAdornment.css.js +1 -1
- package/dist-es/status-adornment/StatusAdornment.js.map +1 -1
- package/dist-es/utils/useResponsiveProp.js +7 -5
- package/dist-es/utils/useResponsiveProp.js.map +1 -1
- package/dist-types/checkbox/Checkbox.d.ts +9 -0
- package/dist-types/checkbox/CheckboxGroup.d.ts +13 -0
- package/dist-types/checkbox/CheckboxIcon.d.ts +7 -1
- package/dist-types/checkbox/internal/CheckboxGroupContext.d.ts +6 -0
- package/dist-types/form-field/FormField.d.ts +5 -1
- package/dist-types/form-field/FormFieldLabel.d.ts +3 -1
- package/dist-types/form-field/index.d.ts +0 -1
- package/dist-types/form-field-context/FormFieldContext.d.ts +3 -0
- package/dist-types/index.d.ts +1 -0
- package/dist-types/input/index.d.ts +0 -1
- package/dist-types/radio-button/RadioButton.d.ts +15 -2
- package/dist-types/radio-button/RadioButtonGroup.d.ts +12 -0
- package/dist-types/radio-button/RadioButtonIcon.d.ts +10 -4
- package/dist-types/radio-button/internal/RadioGroupContext.d.ts +6 -0
- package/dist-types/status-adornment/StatusAdornment.d.ts +1 -2
- package/package.json +4 -3
- package/dist-cjs/checkbox/assets/CheckboxCheckedIcon.js +0 -33
- package/dist-cjs/checkbox/assets/CheckboxCheckedIcon.js.map +0 -1
- package/dist-cjs/checkbox/assets/CheckboxCheckedIconHD.js +0 -32
- package/dist-cjs/checkbox/assets/CheckboxCheckedIconHD.js.map +0 -1
- package/dist-cjs/checkbox/assets/CheckboxIndeterminateIcon.js +0 -37
- package/dist-cjs/checkbox/assets/CheckboxIndeterminateIcon.js.map +0 -1
- package/dist-cjs/checkbox/assets/CheckboxUncheckedIcon.js +0 -26
- package/dist-cjs/checkbox/assets/CheckboxUncheckedIcon.js.map +0 -1
- package/dist-cjs/form-field/FormFieldControlWrapper.css.js +0 -6
- package/dist-cjs/form-field/FormFieldControlWrapper.css.js.map +0 -1
- package/dist-cjs/form-field/FormFieldControlWrapper.js +0 -32
- package/dist-cjs/form-field/FormFieldControlWrapper.js.map +0 -1
- package/dist-cjs/input/adornment-button/AdornmentButton.css.js +0 -6
- package/dist-cjs/input/adornment-button/AdornmentButton.css.js.map +0 -1
- package/dist-cjs/input/adornment-button/AdornmentButton.js +0 -41
- package/dist-cjs/input/adornment-button/AdornmentButton.js.map +0 -1
- package/dist-es/checkbox/assets/CheckboxCheckedIcon.js +0 -29
- package/dist-es/checkbox/assets/CheckboxCheckedIcon.js.map +0 -1
- package/dist-es/checkbox/assets/CheckboxCheckedIconHD.js +0 -28
- package/dist-es/checkbox/assets/CheckboxCheckedIconHD.js.map +0 -1
- package/dist-es/checkbox/assets/CheckboxIndeterminateIcon.js +0 -33
- package/dist-es/checkbox/assets/CheckboxIndeterminateIcon.js.map +0 -1
- package/dist-es/checkbox/assets/CheckboxUncheckedIcon.js +0 -22
- package/dist-es/checkbox/assets/CheckboxUncheckedIcon.js.map +0 -1
- package/dist-es/form-field/FormFieldControlWrapper.css.js +0 -4
- package/dist-es/form-field/FormFieldControlWrapper.css.js.map +0 -1
- package/dist-es/form-field/FormFieldControlWrapper.js +0 -28
- package/dist-es/form-field/FormFieldControlWrapper.js.map +0 -1
- package/dist-es/input/adornment-button/AdornmentButton.css.js +0 -4
- package/dist-es/input/adornment-button/AdornmentButton.css.js.map +0 -1
- package/dist-es/input/adornment-button/AdornmentButton.js +0 -37
- package/dist-es/input/adornment-button/AdornmentButton.js.map +0 -1
- package/dist-types/checkbox/assets/CheckboxCheckedIcon.d.ts +0 -4
- package/dist-types/checkbox/assets/CheckboxCheckedIconHD.d.ts +0 -4
- package/dist-types/checkbox/assets/CheckboxIndeterminateIcon.d.ts +0 -4
- package/dist-types/checkbox/assets/CheckboxUncheckedIcon.d.ts +0 -4
- package/dist-types/checkbox/assets/index.d.ts +0 -4
- package/dist-types/form-field/FormFieldControlWrapper.d.ts +0 -2
- package/dist-types/input/adornment-button/AdornmentButton.d.ts +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioButton.js","sources":["../src/radio-button/RadioButton.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport {\n ChangeEventHandler,\n
|
|
1
|
+
{"version":3,"file":"RadioButton.js","sources":["../src/radio-button/RadioButton.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport {\n ChangeEventHandler,\n ComponentPropsWithoutRef,\n FocusEventHandler,\n forwardRef,\n InputHTMLAttributes,\n ReactNode,\n} from \"react\";\nimport { makePrefixer, useControlled } from \"../utils\";\nimport { useRadioGroup } from \"./internal/useRadioGroup\";\nimport { RadioButtonIcon } from \"./RadioButtonIcon\";\n\nimport radioButtonCss from \"./RadioButton.css\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useFormFieldProps } from \"../form-field-context\";\nimport { AdornmentValidationStatus } from \"../status-adornment\";\n\nconst withBaseName = makePrefixer(\"saltRadioButton\");\n\nexport interface RadioButtonProps\n extends Omit<\n ComponentPropsWithoutRef<\"label\">,\n \"onChange\" | \"onBlur\" | \"onFocus\"\n > {\n /**\n * Set the default selected radio button in the group\n */\n checked?: boolean;\n /**\n * Set the disabled state\n */\n disabled?: boolean;\n /**\n * **Deprecated**: Use validationStatus instead\n * Set the error state\n */\n error?: boolean;\n /**\n * Props to be passed to the radio input\n */\n inputProps?: Partial<InputHTMLAttributes<HTMLInputElement>>;\n /**\n * The label to be shown next to the radio icon\n */\n label?: ReactNode;\n /**\n * Name of the radio group\n */\n name?: string;\n /**\n * Callback for blur event\n */\n onBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Callback for change event\n */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Callback for focus event\n */\n onFocus?: FocusEventHandler<HTMLInputElement>;\n /**\n * Set the read only state.\n */\n readOnly?: boolean;\n /**\n * Value of radio button\n */\n value?: string;\n /**\n * Validation status, one of \"warning\" | \"error\" | \"success\"\n *\n * RadioButton has styling variants for \"error\" and \"warning\".\n * No visual styling will be applied on \"success\" variant.\n */\n validationStatus?: AdornmentValidationStatus;\n}\n\nexport const RadioButton = forwardRef<HTMLLabelElement, RadioButtonProps>(\n function RadioButton(props, ref) {\n const {\n checked: checkedProp,\n className,\n disabled: disabledProp,\n error,\n inputProps = {},\n label,\n name: nameProp,\n onFocus,\n onBlur,\n onChange,\n readOnly: readOnlyProp,\n value,\n validationStatus: validationStatusProp,\n ...rest\n } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-radio-button\",\n css: radioButtonCss,\n window: targetWindow,\n });\n\n const {\n a11yProps: formFieldA11yProps,\n disabled: formFieldDisabled,\n readOnly: formFieldReadOnly,\n validationStatus: formFieldValidationStatus,\n } = useFormFieldProps();\n\n const radioGroup = useRadioGroup();\n\n const {\n \"aria-describedby\": inputDescribedBy,\n \"aria-labelledby\": inputLabelledBy,\n className: inputClassName,\n onChange: inputOnChange,\n ...restInputProps\n } = inputProps;\n\n const disabled = radioGroup.disabled ?? formFieldDisabled ?? disabledProp;\n const readOnly = radioGroup.readOnly ?? formFieldReadOnly ?? readOnlyProp;\n const validationStatus = !disabled\n ? radioGroup.validationStatus ??\n formFieldValidationStatus ??\n validationStatusProp\n : undefined;\n\n const radioGroupChecked =\n radioGroup.value != null && value != null\n ? radioGroup.value === value\n : checkedProp;\n const name = nameProp ?? radioGroup.name;\n\n const [checked, setCheckedState] = useControlled({\n controlled: radioGroupChecked,\n default: Boolean(checkedProp),\n name: \"RadioBase\",\n state: \"checked\",\n });\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (event) => {\n if (readOnly) return;\n\n const newChecked = event.target.checked;\n setCheckedState(newChecked);\n\n onChange?.(event);\n inputOnChange?.(event);\n radioGroup.onChange?.(event);\n };\n\n return (\n <label\n className={clsx(\n withBaseName(),\n {\n [withBaseName(\"disabled\")]: disabled,\n [withBaseName(\"readOnly\")]: readOnly,\n [withBaseName(\"error\")]: error /* **Deprecated** */,\n [withBaseName(validationStatus || \"\")]: validationStatus,\n },\n className\n )}\n ref={ref}\n {...rest}\n >\n <input\n aria-describedby={clsx(\n radioGroup.a11yProps?.[\"aria-describedby\"] ??\n formFieldA11yProps?.[\"aria-describedby\"],\n inputDescribedBy\n )}\n aria-labelledby={clsx(\n radioGroup.a11yProps?.[\"aria-labelledby\"] ??\n formFieldA11yProps?.[\"aria-labelledby\"],\n inputLabelledBy\n )}\n className={clsx(withBaseName(\"input\"), inputClassName)}\n // From ADA: read-only field doesn't need to be focusable since it's not a field but text\n tabIndex={readOnly ? -1 : undefined}\n checked={checked}\n disabled={disabled}\n readOnly={readOnly}\n name={name}\n value={value}\n onBlur={onBlur}\n onChange={handleChange}\n onFocus={onFocus}\n type=\"radio\"\n {...restInputProps}\n />\n <RadioButtonIcon\n checked={checked}\n disabled={disabled}\n readOnly={readOnly}\n validationStatus={validationStatus}\n error={error}\n />\n {label}\n </label>\n );\n }\n);\n"],"names":["RadioButton","radioButtonCss","_a"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,MAAM,YAAA,GAAe,aAAa,iBAAiB,CAAA,CAAA;AA6D5C,MAAM,WAAc,GAAA,UAAA;AAAA,EACzB,SAASA,YAAY,CAAA,KAAA,EAAO,GAAK,EAAA;AAjFnC,IAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAkFI,IAAM,MAAA;AAAA,MACJ,OAAS,EAAA,WAAA;AAAA,MACT,SAAA;AAAA,MACA,QAAU,EAAA,YAAA;AAAA,MACV,KAAA;AAAA,MACA,aAAa,EAAC;AAAA,MACd,KAAA;AAAA,MACA,IAAM,EAAA,QAAA;AA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A,UACA,QAAA;AAAA,UACA,gBAAA;AAAA,UACA,KAAA;AAAA,SACF,CAAA;AAAA,QACC,KAAA;AAAA,OAAA;AAAA,KACH,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var css_248z = "/* Styles applied to root element */\n.saltRadioButtonGroup {\n border: none;\n margin: 0;\n padding: 0;\n}\n\n/* Styles applied when direction is vertical */\n.saltRadioButtonGroup-vertical {\n display: flex;\n gap: var(--salt-
|
|
1
|
+
var css_248z = "/* Styles applied to root element */\n.saltRadioButtonGroup {\n border: none;\n margin: 0;\n padding: 0;\n}\n\n/* Styles applied when direction is vertical */\n.saltRadioButtonGroup-vertical {\n display: flex;\n gap: var(--salt-spacing-100);\n flex-direction: column;\n}\n\n/* Styles applied when direction is horizontal */\n.saltRadioButtonGroup-horizontal {\n display: flex;\n gap: var(--salt-spacing-200);\n flex-direction: row;\n flex-wrap: wrap;\n}\n\n.saltRadioButtonGroup-noWrap {\n flex-wrap: nowrap;\n}\n.saltRadioButtonGroup-noWrap .saltRadioButton {\n white-space: break-spaces;\n}\n\n/* Styles applied to radio group's legend */\n.saltRadioButtonGroup-legend {\n display: inline-block;\n font-size: var(--formFieldLegacy-label-fontSize); /* TODO: V2 Form Field work */\n color: var(--salt-text-primary-foreground);\n margin-bottom: var(--salt-spacing-200);\n}\n";
|
|
2
2
|
|
|
3
3
|
export { css_248z as default };
|
|
4
4
|
//# sourceMappingURL=RadioButtonGroup.css.js.map
|
|
@@ -11,6 +11,8 @@ import { RadioGroupContext } from './internal/RadioGroupContext.js';
|
|
|
11
11
|
import css_248z from './RadioButtonGroup.css.js';
|
|
12
12
|
import { useWindow } from '@salt-ds/window';
|
|
13
13
|
import { useComponentCssInjection } from '@salt-ds/styles';
|
|
14
|
+
import '../form-field-context/FormFieldContext.js';
|
|
15
|
+
import { useFormFieldProps } from '../form-field-context/useFormFieldProps.js';
|
|
14
16
|
|
|
15
17
|
const withBaseName = makePrefixer("saltRadioButtonGroup");
|
|
16
18
|
const RadioButtonGroup = forwardRef(function RadioButtonGroup2(props, ref) {
|
|
@@ -19,10 +21,13 @@ const RadioButtonGroup = forwardRef(function RadioButtonGroup2(props, ref) {
|
|
|
19
21
|
className,
|
|
20
22
|
defaultValue,
|
|
21
23
|
direction = "vertical",
|
|
24
|
+
disabled: disabledProp,
|
|
22
25
|
wrap = true,
|
|
23
26
|
name: nameProp,
|
|
24
27
|
onChange,
|
|
28
|
+
readOnly: readOnlyProp,
|
|
25
29
|
value: valueProp,
|
|
30
|
+
validationStatus: validationStatusProp,
|
|
26
31
|
...rest
|
|
27
32
|
} = props;
|
|
28
33
|
const targetWindow = useWindow();
|
|
@@ -31,6 +36,15 @@ const RadioButtonGroup = forwardRef(function RadioButtonGroup2(props, ref) {
|
|
|
31
36
|
css: css_248z,
|
|
32
37
|
window: targetWindow
|
|
33
38
|
});
|
|
39
|
+
const {
|
|
40
|
+
a11yProps,
|
|
41
|
+
disabled: formFieldDisabled,
|
|
42
|
+
readOnly: formFieldReadOnly,
|
|
43
|
+
validationStatus: formFieldValidationStatus
|
|
44
|
+
} = useFormFieldProps();
|
|
45
|
+
const disabled = formFieldDisabled != null ? formFieldDisabled : disabledProp;
|
|
46
|
+
const readOnly = formFieldReadOnly != null ? formFieldReadOnly : readOnlyProp;
|
|
47
|
+
const validationStatus = formFieldValidationStatus != null ? formFieldValidationStatus : validationStatusProp;
|
|
34
48
|
const [value, setStateValue] = useControlled({
|
|
35
49
|
controlled: valueProp,
|
|
36
50
|
default: defaultValue,
|
|
@@ -55,7 +69,15 @@ const RadioButtonGroup = forwardRef(function RadioButtonGroup2(props, ref) {
|
|
|
55
69
|
ref,
|
|
56
70
|
...rest,
|
|
57
71
|
children: /* @__PURE__ */ jsx(RadioGroupContext.Provider, {
|
|
58
|
-
value: {
|
|
72
|
+
value: {
|
|
73
|
+
a11yProps,
|
|
74
|
+
disabled,
|
|
75
|
+
name,
|
|
76
|
+
onChange: handleChange,
|
|
77
|
+
readOnly,
|
|
78
|
+
validationStatus,
|
|
79
|
+
value
|
|
80
|
+
},
|
|
59
81
|
children
|
|
60
82
|
})
|
|
61
83
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioButtonGroup.js","sources":["../src/radio-button/RadioButtonGroup.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport {\n ChangeEventHandler,\n ComponentPropsWithoutRef,\n forwardRef,\n} from \"react\";\nimport { makePrefixer, useControlled, useId } from \"../utils\";\nimport { RadioGroupContext } from \"./internal/RadioGroupContext\";\n\nimport radioButtonGroupCss from \"./RadioButtonGroup.css\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\n\nconst withBaseName = makePrefixer(\"saltRadioButtonGroup\");\n\nexport interface RadioButtonGroupProps\n extends Omit<ComponentPropsWithoutRef<\"fieldset\">, \"onChange\"> {\n /**\n * Set the selected value when initialized.\n */\n defaultValue?: string;\n /**\n * Set the group direction.\n */\n direction?: \"horizontal\" | \"vertical\";\n /**\n * Only for horizontal direction. When `true` the text in radio button label will wrap to fit within the container. Otherwise the radio buttons will wrap onto the next line.\n */\n wrap?: boolean;\n /**\n * The name to be set on each radio button within the group. If not set, then one will be generated for you.\n */\n name?: string;\n /**\n * Callback for change event.\n */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * The value of the radio group, required for a controlled component.\n */\n value?: string;\n}\n\nexport const RadioButtonGroup = forwardRef<\n HTMLFieldSetElement,\n RadioButtonGroupProps\n>(function RadioButtonGroup(props, ref) {\n const {\n children,\n className,\n defaultValue,\n direction = \"vertical\",\n wrap = true,\n name: nameProp,\n onChange,\n value: valueProp,\n ...rest\n } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-radio-button-group\",\n css: radioButtonGroupCss,\n window: targetWindow,\n });\n\n const [value, setStateValue] = useControlled({\n controlled: valueProp,\n default: defaultValue,\n state: \"value\",\n name: \"RadioButtonGroup\",\n });\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (event) => {\n setStateValue(event.target.value);\n onChange?.(event);\n };\n\n const name = useId(nameProp);\n\n return (\n <fieldset\n className={clsx(\n withBaseName(),\n withBaseName(direction),\n {\n [withBaseName(\"noWrap\")]: !wrap,\n },\n className\n )}\n data-testid=\"radio-button-group\"\n ref={ref}\n {...rest}\n >\n <RadioGroupContext.Provider\n value={{
|
|
1
|
+
{"version":3,"file":"RadioButtonGroup.js","sources":["../src/radio-button/RadioButtonGroup.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport {\n ChangeEventHandler,\n ComponentPropsWithoutRef,\n forwardRef,\n} from \"react\";\nimport { makePrefixer, useControlled, useId } from \"../utils\";\nimport { RadioGroupContext } from \"./internal/RadioGroupContext\";\n\nimport radioButtonGroupCss from \"./RadioButtonGroup.css\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useFormFieldProps } from \"../form-field-context\";\n\nconst withBaseName = makePrefixer(\"saltRadioButtonGroup\");\n\nexport interface RadioButtonGroupProps\n extends Omit<ComponentPropsWithoutRef<\"fieldset\">, \"onChange\"> {\n /**\n * Set the selected value when initialized.\n */\n defaultValue?: string;\n /**\n * Set the group direction.\n */\n direction?: \"horizontal\" | \"vertical\";\n /**\n * Disable the RadioButton group\n */\n disabled?: boolean;\n /**\n * Only for horizontal direction. When `true` the text in radio button label will wrap to fit within the container. Otherwise the radio buttons will wrap onto the next line.\n */\n wrap?: boolean;\n /**\n * The name to be set on each radio button within the group. If not set, then one will be generated for you.\n */\n name?: string;\n /**\n * Callback for change event.\n */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Set the RadioButton group to read only.\n */\n readOnly?: boolean;\n /**\n * The value of the radio group, required for a controlled component.\n */\n value?: string;\n /**\n * Validation status.\n */\n validationStatus?: \"error\" | \"warning\";\n}\n\nexport const RadioButtonGroup = forwardRef<\n HTMLFieldSetElement,\n RadioButtonGroupProps\n>(function RadioButtonGroup(props, ref) {\n const {\n children,\n className,\n defaultValue,\n direction = \"vertical\",\n disabled: disabledProp,\n wrap = true,\n name: nameProp,\n onChange,\n readOnly: readOnlyProp,\n value: valueProp,\n validationStatus: validationStatusProp,\n ...rest\n } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-radio-button-group\",\n css: radioButtonGroupCss,\n window: targetWindow,\n });\n\n const {\n a11yProps,\n disabled: formFieldDisabled,\n readOnly: formFieldReadOnly,\n validationStatus: formFieldValidationStatus,\n } = useFormFieldProps();\n\n const disabled = formFieldDisabled ?? disabledProp;\n const readOnly = formFieldReadOnly ?? readOnlyProp;\n const validationStatus = formFieldValidationStatus ?? validationStatusProp;\n\n const [value, setStateValue] = useControlled({\n controlled: valueProp,\n default: defaultValue,\n state: \"value\",\n name: \"RadioButtonGroup\",\n });\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (event) => {\n setStateValue(event.target.value);\n onChange?.(event);\n };\n\n const name = useId(nameProp);\n\n return (\n <fieldset\n className={clsx(\n withBaseName(),\n withBaseName(direction),\n {\n [withBaseName(\"noWrap\")]: !wrap,\n },\n className\n )}\n data-testid=\"radio-button-group\"\n ref={ref}\n {...rest}\n >\n <RadioGroupContext.Provider\n value={{\n a11yProps,\n disabled,\n name,\n onChange: handleChange,\n readOnly,\n validationStatus,\n value,\n }}\n >\n {children}\n </RadioGroupContext.Provider>\n </fieldset>\n );\n});\n"],"names":["RadioButtonGroup","radioButtonGroupCss"],"mappings":";;;;;;;;;;;;;;;;AAcA,MAAM,YAAA,GAAe,aAAa,sBAAsB,CAAA,CAAA;AA0CjD,MAAM,gBAAmB,GAAA,UAAA,CAG9B,SAASA,iBAAAA,CAAiB,OAAO,GAAK,EAAA;AACtC,EAAM,MAAA;AAAA,IACJ,QAAA;AAAA,IACA,SAAA;AAAA,IACA,YAAA;AAAA,IACA,SAAY,GAAA,UAAA;AAAA,IACZ,QA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AEA,EAAM,MAAA,IAAA,GAAO,MAAM,QAAQ,CAAA,CAAA;AAE3B,EAAA,uBACG,GAAA,CAAA,UAAA,EAAA;AAAA,IACC,SAAW,EAAA,IAAA;AAAA,MACT,YAAa,EAAA;AAAA,MACb,aAAa,SAAS,CAAA;AAAA,MACtB;AAAA,QACE,CAAC,YAAA,CAAa,QAAQ,CAAA,GAAI,CAAC,IAAA;AAAA,OAC7B;AAAA,MACA,SAAA;AAAA,KACF;AAAA,IACA,aAAY,EAAA,oBAAA;AAAA,IACZ,GAAA;AAAA,IACC,GAAG,IAAA;AAAA,IAEJ,QAAA,kBAAA,GAAA,CAAC,kBAAkB,QAAlB,EAAA;AAAA,MACC,KAAO,EAAA;AAAA,QACL,SAAA;AAAA,QACA,QAAA;AAAA,QACA,IAAA;AAAA,QACA,QAAU,EAAA,YAAA;AAAA,QACV,QAAA;AAAA,QACA,gBAAA;AAAA,QACA,KAAA;AAAA,OACF;AAAA,MAEC,QAAA;AAAA,KACH,CAAA;AAAA,GACF,CAAA,CAAA;AAEJ,CAAC;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var css_248z = "/* Styles applied to radio button icon */\n.saltRadioButtonIcon {\n
|
|
1
|
+
var css_248z = "/* Styles applied to radio button icon */\n.saltRadioButtonIcon {\n --radioButton-size: var(--salt-size-selectable);\n width: var(--radioButton-size);\n height: var(--radioButton-size);\n min-width: var(--radioButton-size);\n min-height: var(--radioButton-size);\n border-radius: 50%;\n\n border: var(--salt-size-border) var(--salt-container-borderStyle) var(--salt-selectable-borderColor);\n color: var(--salt-selectable-foreground);\n background: var(--salt-container-primary-background);\n --saltIcon-color: currentColor;\n --saltIcon-size: 100%;\n display: flex;\n}\n\n.saltRadioButton:hover .saltRadioButtonIcon {\n border-color: var(--salt-selectable-borderColor-hover);\n color: var(--salt-selectable-foreground-hover);\n}\n\n.saltRadioButtonIcon-checked {\n border-color: var(--salt-selectable-borderColor-selected);\n color: var(--salt-selectable-foreground-selected);\n}\n\n.saltRadioButtonIcon-disabled,\n.saltRadioButton:hover .saltRadioButtonIcon-disabled {\n border-color: var(--salt-selectable-borderColor-disabled);\n background: var(--salt-container-primary-background-disabled);\n color: var(--salt-selectable-foreground-disabled);\n}\n\n.saltRadioButtonIcon-checked.saltRadioButtonIcon-disabled,\n.saltRadioButton:hover .saltRadioButtonIcon-checked.saltRadioButtonIcon-disabled {\n border-color: var(--salt-selectable-borderColor-selectedDisabled);\n color: var(--salt-selectable-foreground-selectedDisabled);\n}\n\n.saltRadioButtonIcon-error,\n.saltRadioButton:hover .saltRadioButtonIcon-error {\n color: var(--salt-status-error-foreground);\n border-color: var(--salt-status-error-borderColor);\n outline-color: var(--salt-status-error-foreground);\n}\n\n.saltRadioButtonIcon-warning,\n.saltRadioButton:hover .saltRadioButtonIcon-warning {\n color: var(--salt-status-warning-foreground);\n border-color: var(--salt-status-warning-borderColor);\n outline-color: var(--salt-status-warning-foreground);\n}\n\n.saltRadioButtonIcon-readOnly,\n.saltRadioButton:hover .saltRadioButtonIcon-readOnly {\n border-color: var(--salt-selectable-borderColor-readonly);\n color: var(--salt-text-primary-foreground);\n}\n";
|
|
2
2
|
|
|
3
3
|
export { css_248z as default };
|
|
4
4
|
//# sourceMappingURL=RadioButtonIcon.css.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import 'react';
|
|
3
3
|
import { makePrefixer } from '../utils/makePrefixer.js';
|
|
4
4
|
import '../utils/useFloatingUI.js';
|
|
@@ -6,15 +6,19 @@ import '../utils/useId.js';
|
|
|
6
6
|
import '../salt-provider/SaltProvider.js';
|
|
7
7
|
import '../viewport/ViewportProvider.js';
|
|
8
8
|
import { clsx } from 'clsx';
|
|
9
|
-
import css_248z from './RadioButtonIcon.css.js';
|
|
10
9
|
import { useComponentCssInjection } from '@salt-ds/styles';
|
|
11
10
|
import { useWindow } from '@salt-ds/window';
|
|
11
|
+
import css_248z from './RadioButtonIcon.css.js';
|
|
12
12
|
|
|
13
13
|
const withBaseName = makePrefixer("saltRadioButtonIcon");
|
|
14
14
|
const RadioButtonIcon = ({
|
|
15
15
|
checked,
|
|
16
|
+
className,
|
|
16
17
|
error,
|
|
17
|
-
disabled
|
|
18
|
+
disabled,
|
|
19
|
+
validationStatus,
|
|
20
|
+
readOnly,
|
|
21
|
+
...rest
|
|
18
22
|
}) => {
|
|
19
23
|
const targetWindow = useWindow();
|
|
20
24
|
useComponentCssInjection({
|
|
@@ -22,29 +26,30 @@ const RadioButtonIcon = ({
|
|
|
22
26
|
css: css_248z,
|
|
23
27
|
window: targetWindow
|
|
24
28
|
});
|
|
25
|
-
return /* @__PURE__ */
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
29
|
+
return /* @__PURE__ */ jsx("div", {
|
|
30
|
+
"aria-hidden": "true",
|
|
31
|
+
className: clsx(
|
|
32
|
+
withBaseName(),
|
|
33
|
+
{
|
|
34
|
+
[withBaseName("checked")]: checked,
|
|
35
|
+
[withBaseName("error")]: error,
|
|
36
|
+
[withBaseName("disabled")]: disabled,
|
|
37
|
+
[withBaseName(validationStatus || "")]: validationStatus,
|
|
38
|
+
[withBaseName("readOnly")]: readOnly
|
|
39
|
+
},
|
|
40
|
+
className
|
|
41
|
+
),
|
|
42
|
+
...rest,
|
|
43
|
+
children: checked && /* @__PURE__ */ jsx("svg", {
|
|
44
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
45
|
+
viewBox: "0 0 12 12",
|
|
46
|
+
fill: "currentColor",
|
|
47
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
48
|
+
fillRule: "evenodd",
|
|
49
|
+
d: "M0 6a6 6 0 1 1 12 0A6 6 0 0 1 0 6Zm6 3a3 3 0 1 1 0-6 3 3 0 0 1 0 6Z",
|
|
50
|
+
clipRule: "evenodd"
|
|
46
51
|
})
|
|
47
|
-
|
|
52
|
+
})
|
|
48
53
|
});
|
|
49
54
|
};
|
|
50
55
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioButtonIcon.js","sources":["../src/radio-button/RadioButtonIcon.tsx"],"sourcesContent":["import { makePrefixer } from \"../utils\";\nimport { clsx } from \"clsx\";\nimport
|
|
1
|
+
{"version":3,"file":"RadioButtonIcon.js","sources":["../src/radio-button/RadioButtonIcon.tsx"],"sourcesContent":["import { makePrefixer } from \"../utils\";\nimport { clsx } from \"clsx\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { AdornmentValidationStatus } from \"../status-adornment\";\nimport radioButtonIconCss from \"./RadioButtonIcon.css\";\nimport { ComponentPropsWithoutRef } from \"react\";\n\nconst withBaseName = makePrefixer(\"saltRadioButtonIcon\");\n\nexport interface RadioButtonIconProps extends ComponentPropsWithoutRef<\"div\"> {\n checked?: boolean;\n disabled?: boolean;\n /**\n * @deprecated Use validationStatus instead\n */\n error?: boolean;\n readOnly?: boolean;\n validationStatus?: AdornmentValidationStatus;\n}\n\n/**\n * Default radio icon\n */\nexport const RadioButtonIcon = ({\n checked,\n className,\n error,\n disabled,\n validationStatus,\n readOnly,\n ...rest\n}: RadioButtonIconProps) => {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-radio-button-icon\",\n css: radioButtonIconCss,\n window: targetWindow,\n });\n return (\n <div\n aria-hidden=\"true\"\n className={clsx(\n withBaseName(),\n {\n [withBaseName(\"checked\")]: checked,\n [withBaseName(\"error\")]: error,\n [withBaseName(\"disabled\")]: disabled,\n [withBaseName(validationStatus || \"\")]: validationStatus,\n [withBaseName(\"readOnly\")]: readOnly,\n },\n className\n )}\n {...rest}\n >\n {checked && (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 12 12\"\n fill=\"currentColor\"\n >\n <path\n fillRule=\"evenodd\"\n d=\"M0 6a6 6 0 1 1 12 0A6 6 0 0 1 0 6Zm6 3a3 3 0 1 1 0-6 3 3 0 0 1 0 6Z\"\n clipRule=\"evenodd\"\n />\n </svg>\n )}\n </div>\n );\n};\n"],"names":["radioButtonIconCss"],"mappings":";;;;;;;;;;;;AAQA,MAAM,YAAA,GAAe,aAAa,qBAAqB,CAAA,CAAA;AAgBhD,MAAM,kBAAkB,CAAC;AAAA,EAC9B,OAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,gBAAA;AAAA,EACA,QAAA;AAAA,EACG,GAAA,IAAA;AACL,CAA4B,KAAA;AAC1B,EAAA,MAAM,eAAe,SAAU,EAAA,CAAA;AAC/B,EAAyB,wBAAA,CAAA;AAAA,IACvB,MAAQ,EAAA,wBAAA;AAAA,IACR,GAAK,EAAAA,QAAA;AAAA,IACL,MAAQ,EAAA,YAAA;AAAA,GACT,CAAA,CAAA;AACD,EAAA,uBACG,GAAA,CAAA,KAAA,EAAA;AAAA,IACC,aAAY,EAAA,MAAA;AAAA,IACZ,SAAW,EAAA,IAAA;AAAA,MACT,YAAa,EAAA;AAAA,MACb;AAAA,QACE,CAAC,YAAa,CAAA,SAAS,CAAI,GAAA,OAAA;AAAA,QAC3B,CAAC,YAAa,CAAA,OAAO,CAAI,GAAA,KAAA;AAAA,QACzB,CAAC,YAAa,CAAA,UAAU,CAAI,GAAA,QAAA;AAAA,QAC5B,CAAC,YAAA,CAAa,gBAAoB,IAAA,EAAE,CAAI,GAAA,gBAAA;AAAA,QACxC,CAAC,YAAa,CAAA,UAAU,CAAI,GAAA,QAAA;AAAA,OAC9B;AAAA,MACA,SAAA;AAAA,KACF;AAAA,IACC,GAAG,IAAA;AAAA,IAEH,qCACE,GAAA,CAAA,KAAA,EAAA;AAAA,MACC,KAAM,EAAA,4BAAA;AAAA,MACN,OAAQ,EAAA,WAAA;AAAA,MACR,IAAK,EAAA,cAAA;AAAA,MAEL,QAAC,kBAAA,GAAA,CAAA,MAAA,EAAA;AAAA,QACC,QAAS,EAAA,SAAA;AAAA,QACT,CAAE,EAAA,qEAAA;AAAA,QACF,QAAS,EAAA,SAAA;AAAA,OACX,CAAA;AAAA,KACF,CAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroupContext.js","sources":["../src/radio-button/internal/RadioGroupContext.tsx"],"sourcesContent":["import { ChangeEventHandler } from \"react\";\nimport { createContext } from \"../../utils\";\n\nexport interface RadioGroupContextValue {\n name?: string;\n value?: string;\n onChange?: ChangeEventHandler<HTMLElement>;\n}\n\nexport const RadioGroupContext = createContext<RadioGroupContextValue>(\n \"RadioGroupContext\",\n {}\n);\n"],"names":[],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"RadioGroupContext.js","sources":["../src/radio-button/internal/RadioGroupContext.tsx"],"sourcesContent":["import { ChangeEventHandler } from \"react\";\nimport { a11yValueAriaProps } from \"../../form-field-context\";\nimport { AdornmentValidationStatus } from \"../../status-adornment\";\nimport { createContext } from \"../../utils\";\n\nexport interface RadioGroupContextValue {\n a11yProps?: a11yValueAriaProps;\n disabled?: boolean;\n name?: string;\n value?: string;\n onChange?: ChangeEventHandler<HTMLElement>;\n readOnly?: boolean;\n validationStatus?: AdornmentValidationStatus;\n}\n\nexport const RadioGroupContext = createContext<RadioGroupContextValue>(\n \"RadioGroupContext\",\n {}\n);\n"],"names":[],"mappings":";;;;;;;;AAeO,MAAM,iBAAoB,GAAA,aAAA;AAAA,EAC/B,mBAAA;AAAA,EACA,EAAC;AACH;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var css_248z = ".saltStatusAdornment {\n fill: var(--saltStatusAdornment-color, var(--statusAdornment-color));\n
|
|
1
|
+
var css_248z = ".saltStatusAdornment {\n align-self: center;\n display: inline-block;\n fill: var(--saltStatusAdornment-color, var(--statusAdornment-color));\n height: var(--salt-icon-size-status-adornment);\n min-height: var(--salt-icon-size-status-adornment);\n padding-left: var(--salt-spacing-100);\n position: relative;\n}\n\n.saltStatusAdornment-error {\n --statusAdornment-color: var(--salt-status-error-foreground);\n}\n\n.saltStatusAdornment-warning {\n --statusAdornment-color: var(--salt-status-warning-foreground);\n}\n\n.saltStatusAdornment-success {\n --statusAdornment-color: var(--salt-status-success-foreground);\n}\n";
|
|
2
2
|
|
|
3
3
|
export { css_248z as default };
|
|
4
4
|
//# sourceMappingURL=StatusAdornment.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusAdornment.js","sources":["../src/status-adornment/StatusAdornment.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport { forwardRef } from \"react\";\nimport { IconProps } from \"@salt-ds/icons\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { ValidationStatus } from \"../status-indicator\";\nimport { makePrefixer } from \"../utils\";\nimport { ErrorAdornmentIcon } from \"./ErrorAdornment\";\nimport { SuccessAdornmentIcon } from \"./SuccessAdornment\";\nimport { WarningAdornmentIcon } from \"./WarningAdornment\";\n\nimport statusAdornmentCss from \"./StatusAdornment.css\";\n\nconst icons = {\n error: ErrorAdornmentIcon,\n warning: WarningAdornmentIcon,\n success: SuccessAdornmentIcon,\n};\n\
|
|
1
|
+
{"version":3,"file":"StatusAdornment.js","sources":["../src/status-adornment/StatusAdornment.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport { forwardRef } from \"react\";\nimport { IconProps } from \"@salt-ds/icons\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { ValidationStatus } from \"../status-indicator\";\nimport { makePrefixer } from \"../utils\";\nimport { ErrorAdornmentIcon } from \"./ErrorAdornment\";\nimport { SuccessAdornmentIcon } from \"./SuccessAdornment\";\nimport { WarningAdornmentIcon } from \"./WarningAdornment\";\n\nimport statusAdornmentCss from \"./StatusAdornment.css\";\n\nconst icons = {\n error: ErrorAdornmentIcon,\n warning: WarningAdornmentIcon,\n success: SuccessAdornmentIcon,\n};\n\nexport type AdornmentValidationStatus = Exclude<ValidationStatus, \"info\">;\n\nexport interface StatusAdornmentProps extends IconProps {\n /**\n * Status adornment to be displayed.\n */\n status: AdornmentValidationStatus;\n}\n\nconst statusToAriaLabelMap: Record<AdornmentValidationStatus, string> = {\n error: \"error\",\n warning: \"warning\",\n success: \"success\",\n};\n\nconst withBaseName = makePrefixer(\"saltStatusAdornment\");\n\nexport const StatusAdornment = forwardRef<SVGSVGElement, StatusAdornmentProps>(\n function StatusAdornment({ className, status, ...restProps }, ref) {\n const AdornmentComponent = icons[status];\n const ariaLabel = statusToAriaLabelMap[status];\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-status-adornment\",\n css: statusAdornmentCss,\n window: targetWindow,\n });\n\n return (\n <AdornmentComponent\n className={clsx(withBaseName(), withBaseName(status), className)}\n aria-label={ariaLabel}\n {...restProps}\n ref={ref}\n />\n );\n }\n);\n"],"names":["StatusAdornment","statusAdornmentCss"],"mappings":";;;;;;;;;;;;;;;AAaA,MAAM,KAAQ,GAAA;AAAA,EACZ,KAAO,EAAA,kBAAA;AAAA,EACP,OAAS,EAAA,oBAAA;AAAA,EACT,OAAS,EAAA,oBAAA;AACX,CAAA,CAAA;AAWA,MAAM,oBAAkE,GAAA;AAAA,EACtE,KAAO,EAAA,OAAA;AAAA,EACP,OAAS,EAAA,SAAA;AAAA,EACT,OAAS,EAAA,SAAA;AACX,CAAA,CAAA;AAEA,MAAM,YAAA,GAAe,aAAa,qBAAqB,CAAA,CAAA;AAEhD,MAAM,eAAkB,GAAA,UAAA;AAAA,EAC7B,SAASA,gBAAgB,CAAA,EAAE,WAAW,MAAW,EAAA,GAAA,SAAA,IAAa,GAAK,EAAA;AACjE,IAAA,MAAM,qBAAqB,KAAM,CAAA,MAAA,CAAA,CAAA;AACjC,IAAA,MAAM,YAAY,oBAAqB,CAAA,MAAA,CAAA,CAAA;AAEvC,IAAA,MAAM,eAAe,SAAU,EAAA,CAAA;AAC/B,IAAyB,wBAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,uBAAA;AAAA,MACR,GAAK,EAAAC,QAAA;AAAA,MACL,MAAQ,EAAA,YAAA;AAAA,KACT,CAAA,CAAA;AAED,IAAA,uBACG,GAAA,CAAA,kBAAA,EAAA;AAAA,MACC,WAAW,IAAK,CAAA,YAAA,IAAgB,YAAa,CAAA,MAAM,GAAG,SAAS,CAAA;AAAA,MAC/D,YAAY,EAAA,SAAA;AAAA,MACX,GAAG,SAAA;AAAA,MACJ,GAAA;AAAA,KACF,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
|
@@ -2,7 +2,9 @@ import { useBreakpoints } from '../salt-provider/SaltProvider.js';
|
|
|
2
2
|
import { useViewport } from '../viewport/ViewportProvider.js';
|
|
3
3
|
|
|
4
4
|
const getCurrentBreakpoint = (breakpoints, width) => {
|
|
5
|
-
const breakpointList = Object.entries(breakpoints)
|
|
5
|
+
const breakpointList = Object.entries(breakpoints).sort(
|
|
6
|
+
([, a], [, b]) => a - b
|
|
7
|
+
);
|
|
6
8
|
const [currentBreakpoint] = breakpointList.reduce((acc, val) => {
|
|
7
9
|
const [, accWidth] = acc;
|
|
8
10
|
const [breakpoint, breakpointWidth] = val;
|
|
@@ -20,8 +22,7 @@ const useCurrentBreakpoint = () => {
|
|
|
20
22
|
};
|
|
21
23
|
const useOrderedBreakpoints = () => {
|
|
22
24
|
const breakpoints = useBreakpoints();
|
|
23
|
-
|
|
24
|
-
return orderedBreakpoints;
|
|
25
|
+
return Object.entries(breakpoints).sort(([, a], [, b]) => a - b).map(([key]) => key);
|
|
25
26
|
};
|
|
26
27
|
const isObject = (value) => {
|
|
27
28
|
const type = typeof value;
|
|
@@ -31,7 +32,7 @@ const hasBreakpointValues = (value, breakpoints) => {
|
|
|
31
32
|
return isObject(value) && Object.keys(value).every((key) => key in breakpoints);
|
|
32
33
|
};
|
|
33
34
|
const getResponsiveValue = (breakpointValues, breakpoints, viewport, defaultValue) => {
|
|
34
|
-
|
|
35
|
+
return Object.entries(breakpointValues).reduce(
|
|
35
36
|
(acc, val) => {
|
|
36
37
|
const [accWidth] = acc;
|
|
37
38
|
const [breakpoint, breakpointValue] = val;
|
|
@@ -43,11 +44,12 @@ const getResponsiveValue = (breakpointValues, breakpoints, viewport, defaultValu
|
|
|
43
44
|
},
|
|
44
45
|
[0, defaultValue]
|
|
45
46
|
)[1];
|
|
46
|
-
return value;
|
|
47
47
|
};
|
|
48
48
|
const useResponsiveProp = (value, defaultValue) => {
|
|
49
49
|
const breakpoints = useBreakpoints();
|
|
50
50
|
const viewport = useViewport();
|
|
51
|
+
if (value === defaultValue)
|
|
52
|
+
return defaultValue;
|
|
51
53
|
const currentViewport = getCurrentBreakpoint(breakpoints, viewport);
|
|
52
54
|
if (hasBreakpointValues(value, breakpoints)) {
|
|
53
55
|
return getResponsiveValue(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResponsiveProp.js","sources":["../src/utils/useResponsiveProp.ts"],"sourcesContent":["import { Breakpoints } from \"../breakpoints\";\nimport { useBreakpoints } from \"../salt-provider\";\nimport { useViewport } from \"../viewport\";\n\ntype BreakpointProp<T> = {\n [K in keyof Breakpoints]?: T;\n};\n\nexport type ResponsiveProp<T> = T | BreakpointProp<T>;\n\nexport const getCurrentBreakpoint = (\n breakpoints: Breakpoints,\n width: number\n) => {\n const breakpointList = Object.entries(breakpoints)
|
|
1
|
+
{"version":3,"file":"useResponsiveProp.js","sources":["../src/utils/useResponsiveProp.ts"],"sourcesContent":["import { Breakpoints } from \"../breakpoints\";\nimport { useBreakpoints } from \"../salt-provider\";\nimport { useViewport } from \"../viewport\";\n\ntype BreakpointProp<T> = {\n [K in keyof Breakpoints]?: T;\n};\n\nexport type ResponsiveProp<T> = T | BreakpointProp<T>;\n\nexport const getCurrentBreakpoint = (\n breakpoints: Breakpoints,\n width: number\n) => {\n const breakpointList = Object.entries(breakpoints).sort(\n ([, a], [, b]) => a - b\n );\n const [currentBreakpoint] = (\n breakpointList as [keyof Breakpoints, number][]\n ).reduce((acc, val) => {\n const [, accWidth] = acc;\n const [breakpoint, breakpointWidth] = val;\n if (breakpointWidth < width && breakpointWidth > accWidth) {\n return [breakpoint, breakpointWidth];\n }\n return [...acc];\n }, breakpointList[0] as [keyof Breakpoints, number]);\n\n return currentBreakpoint;\n};\n\nexport const useCurrentBreakpoint = () => {\n const viewport = useViewport();\n\n const breakpoints = useBreakpoints();\n\n return getCurrentBreakpoint(breakpoints, viewport);\n};\n\nexport const useOrderedBreakpoints = () => {\n const breakpoints = useBreakpoints();\n\n return Object.entries(breakpoints)\n .sort(([, a], [, b]) => a - b)\n .map(([key]) => key);\n};\n\nconst isObject = <T>(\n value: T\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): value is Record<string | number | symbol, any> => {\n const type = typeof value;\n return value !== null && (type === \"object\" || type === \"function\");\n};\n\nconst hasBreakpointValues = <T>(\n value: ResponsiveProp<T>,\n breakpoints: Breakpoints\n): value is BreakpointProp<T> => {\n return (\n isObject(value) && Object.keys(value).every((key) => key in breakpoints)\n );\n};\n\nconst getResponsiveValue = <T>(\n breakpointValues: BreakpointProp<T>,\n breakpoints: Breakpoints,\n viewport: keyof Breakpoints,\n defaultValue: T\n) => {\n return Object.entries(breakpointValues).reduce<[number, T]>(\n (acc, val) => {\n const [accWidth] = acc;\n const [breakpoint, breakpointValue] = val;\n\n const breakpointWidth =\n breakpoints[breakpoint as keyof typeof breakpoints];\n\n if (\n breakpointWidth >= accWidth &&\n breakpointWidth <= breakpoints[viewport]\n ) {\n return [breakpointWidth, breakpointValue];\n }\n\n return acc;\n },\n [0, defaultValue]\n )[1];\n};\n\nexport const useResponsiveProp = <T>(\n value: ResponsiveProp<T>,\n defaultValue: T\n) => {\n const breakpoints = useBreakpoints();\n const viewport = useViewport();\n // return early if the values are the same\n if (value === defaultValue) return defaultValue;\n\n const currentViewport = getCurrentBreakpoint(breakpoints, viewport);\n if (hasBreakpointValues(value, breakpoints)) {\n return getResponsiveValue(\n value,\n breakpoints,\n currentViewport,\n defaultValue\n );\n }\n return value;\n};\n"],"names":[],"mappings":";;;AAUa,MAAA,oBAAA,GAAuB,CAClC,WAAA,EACA,KACG,KAAA;AACH,EAAA,MAAM,cAAiB,GAAA,MAAA,CAAO,OAAQ,CAAA,WAAW,CAAE,CAAA,IAAA;AAAA,IACjD,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAA,KAAM,CAAI,GAAA,CAAA;AAAA,GACxB,CAAA;AACA,EAAA,MAAM,CAAC,iBAAiB,CAAA,GACtB,eACA,MAAO,CAAA,CAAC,KAAK,GAAQ,KAAA;AACrB,IAAM,MAAA,GAAG,QAAQ,CAAI,GAAA,GAAA,CAAA;AACrB,IAAM,MAAA,CAAC,UAAY,EAAA,eAAe,CAAI,GAAA,GAAA,CAAA;AACtC,IAAI,IAAA,eAAA,GAAkB,KAAS,IAAA,eAAA,GAAkB,QAAU,EAAA;AACzD,MAAO,OAAA,CAAC,YAAY,eAAe,CAAA,CAAA;AAAA,KACrC;AACA,IAAO,OAAA,CAAC,GAAG,GAAG,CAAA,CAAA;AAAA,GAChB,EAAG,eAAe,CAAiC,CAAA,CAAA,CAAA;AAEnD,EAAO,OAAA,iBAAA,CAAA;AACT,EAAA;AAEO,MAAM,uBAAuB,MAAM;AACxC,EAAA,MAAM,WAAW,WAAY,EAAA,CAAA;AAE7B,EAAA,MAAM,cAAc,cAAe,EAAA,CAAA;AAEnC,EAAO,OAAA,oBAAA,CAAqB,aAAa,QAAQ,CAAA,CAAA;AACnD,EAAA;AAEO,MAAM,wBAAwB,MAAM;AACzC,EAAA,MAAM,cAAc,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AA;AAAA,GAChB,CAAA,CAAA,CAAA,CAAA;AACJ,CAAA,CAAA;AAEa,MAAA,iBAAA,GAAoB,CAC/B,KAAA,EACA,YACG,KAAA;AACH,EAAA,MAAM,cAAc,cAAe,EAAA,CAAA;AACnC,EAAA,MAAM,WAAW,WAAY,EAAA,CAAA;AAE7B,EAAA,IAAI,KAAU,KAAA,YAAA;AAAc,IAAO,OAAA,YAAA,CAAA;AAEnC,EAAM,MAAA,eAAA,GAAkB,oBAAqB,CAAA,WAAA,EAAa,QAAQ,CAAA,CAAA;AAClE,EAAI,IAAA,mBAAA,CAAoB,KAAO,EAAA,WAAW,CAAG,EAAA;AAC3C,IAAO,OAAA,kBAAA;AAAA,MACL,KAAA;AAAA,MACA,WAAA;AAAA,MACA,eAAA;AAAA,MACA,YAAA;AAAA,KACF,CAAA;AAAA,GACF;AACA,EAAO,OAAA,KAAA,CAAA;AACT;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ChangeEventHandler, FocusEventHandler, InputHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import { AdornmentValidationStatus } from "../status-adornment";
|
|
2
3
|
export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLLabelElement>, "onChange" | "onBlur" | "onFocus"> {
|
|
3
4
|
/**
|
|
4
5
|
* If `true`, the checkbox will be checked.
|
|
@@ -14,6 +15,7 @@ export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLLabelElement
|
|
|
14
15
|
*/
|
|
15
16
|
disabled?: boolean;
|
|
16
17
|
/**
|
|
18
|
+
* **Deprecated**: Use validationStatus instead
|
|
17
19
|
* If `true`, the checkbox will be in the error state.
|
|
18
20
|
*/
|
|
19
21
|
error?: boolean;
|
|
@@ -51,5 +53,12 @@ export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLLabelElement
|
|
|
51
53
|
* The value of the checkbox.
|
|
52
54
|
*/
|
|
53
55
|
value?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Validation status, one of "warning" | "error" | "success"
|
|
58
|
+
*
|
|
59
|
+
* Checkbox has styling variants for "error" and "warning".
|
|
60
|
+
* No visual styling will be applied on "success" variant.
|
|
61
|
+
*/
|
|
62
|
+
validationStatus?: AdornmentValidationStatus;
|
|
54
63
|
}
|
|
55
64
|
export declare const Checkbox: import("react").ForwardRefExoticComponent<CheckboxProps & import("react").RefAttributes<HTMLLabelElement>>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ChangeEventHandler, ComponentPropsWithoutRef } from "react";
|
|
2
|
+
import { AdornmentValidationStatus } from "../status-adornment";
|
|
2
3
|
export interface CheckboxGroupProps extends Omit<ComponentPropsWithoutRef<"fieldset">, "onChange"> {
|
|
3
4
|
/**
|
|
4
5
|
* The current checked options.
|
|
@@ -12,6 +13,10 @@ export interface CheckboxGroupProps extends Omit<ComponentPropsWithoutRef<"field
|
|
|
12
13
|
* Display group of elements in a compact row.
|
|
13
14
|
*/
|
|
14
15
|
direction?: "horizontal" | "vertical";
|
|
16
|
+
/**
|
|
17
|
+
* Disable the Checkbox group
|
|
18
|
+
*/
|
|
19
|
+
disabled?: boolean;
|
|
15
20
|
/**
|
|
16
21
|
* The name used to reference the value of the control.
|
|
17
22
|
*/
|
|
@@ -21,9 +26,17 @@ export interface CheckboxGroupProps extends Omit<ComponentPropsWithoutRef<"field
|
|
|
21
26
|
* `event.target.value` returns the value of the checkbox that was clicked.
|
|
22
27
|
*/
|
|
23
28
|
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
29
|
+
/**
|
|
30
|
+
* If `true`, the component is read only.
|
|
31
|
+
*/
|
|
32
|
+
readOnly?: boolean;
|
|
24
33
|
/**
|
|
25
34
|
* Only for horizontal direction. When `true` the text in radio button label will wrap to fit within the container. Otherwise, the checkboxes will wrap onto the next line.
|
|
26
35
|
*/
|
|
27
36
|
wrap?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Validation status.
|
|
39
|
+
*/
|
|
40
|
+
validationStatus?: AdornmentValidationStatus;
|
|
28
41
|
}
|
|
29
42
|
export declare const CheckboxGroup: import("react").ForwardRefExoticComponent<CheckboxGroupProps & import("react").RefAttributes<HTMLFieldSetElement>>;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { AdornmentValidationStatus } from "../status-adornment";
|
|
2
3
|
export interface CheckboxIconProps {
|
|
3
4
|
checked?: boolean;
|
|
4
5
|
className?: string;
|
|
5
6
|
disabled?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use validationStatus instead
|
|
9
|
+
*/
|
|
6
10
|
error?: boolean;
|
|
7
11
|
indeterminate?: boolean;
|
|
12
|
+
readOnly?: boolean;
|
|
13
|
+
validationStatus?: AdornmentValidationStatus;
|
|
8
14
|
}
|
|
9
|
-
export declare const CheckboxIcon: ({ checked, className
|
|
15
|
+
export declare const CheckboxIcon: ({ checked, className, disabled, error, indeterminate, validationStatus, readOnly, }: CheckboxIconProps) => JSX.Element;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { a11yValueAriaProps } from "../../form-field-context";
|
|
3
|
+
import { AdornmentValidationStatus } from "../../status-adornment";
|
|
2
4
|
import { CheckboxGroupProps } from "../CheckboxGroup";
|
|
3
5
|
export interface CheckboxGroupState {
|
|
6
|
+
a11yProps?: a11yValueAriaProps;
|
|
7
|
+
disabled?: boolean;
|
|
4
8
|
name?: CheckboxGroupProps["name"];
|
|
5
9
|
onChange?: CheckboxGroupProps["onChange"];
|
|
6
10
|
checkedValues?: CheckboxGroupProps["checkedValues"];
|
|
11
|
+
readOnly?: boolean;
|
|
12
|
+
validationStatus?: AdornmentValidationStatus;
|
|
7
13
|
}
|
|
8
14
|
declare const CheckboxGroupContext: import("react").Context<CheckboxGroupState>;
|
|
9
15
|
export { CheckboxGroupContext };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HTMLAttributes } from "react";
|
|
2
2
|
import { A11yValueProps } from "../form-field-context";
|
|
3
|
-
export declare type FormFieldLabelPlacement = "top" | "left";
|
|
3
|
+
export declare type FormFieldLabelPlacement = "top" | "left" | "right";
|
|
4
4
|
export interface FormFieldProps extends HTMLAttributes<HTMLDivElement>, A11yValueProps {
|
|
5
5
|
/**
|
|
6
6
|
* Disabled prop
|
|
@@ -21,6 +21,10 @@ export interface FormFieldProps extends HTMLAttributes<HTMLDivElement>, A11yValu
|
|
|
21
21
|
* Used as suffix of FormFieldHelperText id: `helperText-{id}`
|
|
22
22
|
*/
|
|
23
23
|
id?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Displays necessity on label
|
|
26
|
+
*/
|
|
27
|
+
necessity?: "required" | "optional" | "asterisk";
|
|
24
28
|
/**
|
|
25
29
|
* Validation status
|
|
26
30
|
*/
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TextProps } from "../text";
|
|
3
|
-
export declare const FormFieldLabel: ({ className, children, ...restProps }: Omit<TextProps<"label">, "variant" | "styleAs">
|
|
3
|
+
export declare const FormFieldLabel: ({ className, children, pronounced, ...restProps }: Omit<TextProps<"label">, "variant" | "styleAs"> & {
|
|
4
|
+
pronounced?: boolean | undefined;
|
|
5
|
+
}) => JSX.Element;
|
|
@@ -9,6 +9,7 @@ export interface A11yValueProps {
|
|
|
9
9
|
*/
|
|
10
10
|
labelId?: string;
|
|
11
11
|
}
|
|
12
|
+
declare type NecessityType = "required" | "optional" | "asterisk";
|
|
12
13
|
export interface a11yValueAriaProps {
|
|
13
14
|
"aria-labelledby": A11yValueProps["labelId"];
|
|
14
15
|
"aria-describedby": A11yValueProps["helperTextId"] | undefined;
|
|
@@ -16,7 +17,9 @@ export interface a11yValueAriaProps {
|
|
|
16
17
|
export interface FormFieldContextValue {
|
|
17
18
|
a11yProps: a11yValueAriaProps;
|
|
18
19
|
disabled: boolean;
|
|
20
|
+
necessity: NecessityType | undefined;
|
|
19
21
|
readOnly: boolean;
|
|
20
22
|
validationStatus: "error" | "warning" | "success" | undefined;
|
|
21
23
|
}
|
|
22
24
|
export declare const FormFieldContext: import("react").Context<FormFieldContextValue>;
|
|
25
|
+
export {};
|
package/dist-types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ChangeEventHandler,
|
|
2
|
-
|
|
1
|
+
import { ChangeEventHandler, ComponentPropsWithoutRef, FocusEventHandler, InputHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import { AdornmentValidationStatus } from "../status-adornment";
|
|
3
|
+
export interface RadioButtonProps extends Omit<ComponentPropsWithoutRef<"label">, "onChange" | "onBlur" | "onFocus"> {
|
|
3
4
|
/**
|
|
4
5
|
* Set the default selected radio button in the group
|
|
5
6
|
*/
|
|
@@ -9,6 +10,7 @@ export interface RadioButtonProps extends Omit<HTMLAttributes<HTMLLabelElement>,
|
|
|
9
10
|
*/
|
|
10
11
|
disabled?: boolean;
|
|
11
12
|
/**
|
|
13
|
+
* **Deprecated**: Use validationStatus instead
|
|
12
14
|
* Set the error state
|
|
13
15
|
*/
|
|
14
16
|
error?: boolean;
|
|
@@ -36,9 +38,20 @@ export interface RadioButtonProps extends Omit<HTMLAttributes<HTMLLabelElement>,
|
|
|
36
38
|
* Callback for focus event
|
|
37
39
|
*/
|
|
38
40
|
onFocus?: FocusEventHandler<HTMLInputElement>;
|
|
41
|
+
/**
|
|
42
|
+
* Set the read only state.
|
|
43
|
+
*/
|
|
44
|
+
readOnly?: boolean;
|
|
39
45
|
/**
|
|
40
46
|
* Value of radio button
|
|
41
47
|
*/
|
|
42
48
|
value?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Validation status, one of "warning" | "error" | "success"
|
|
51
|
+
*
|
|
52
|
+
* RadioButton has styling variants for "error" and "warning".
|
|
53
|
+
* No visual styling will be applied on "success" variant.
|
|
54
|
+
*/
|
|
55
|
+
validationStatus?: AdornmentValidationStatus;
|
|
43
56
|
}
|
|
44
57
|
export declare const RadioButton: import("react").ForwardRefExoticComponent<RadioButtonProps & import("react").RefAttributes<HTMLLabelElement>>;
|
|
@@ -8,6 +8,10 @@ export interface RadioButtonGroupProps extends Omit<ComponentPropsWithoutRef<"fi
|
|
|
8
8
|
* Set the group direction.
|
|
9
9
|
*/
|
|
10
10
|
direction?: "horizontal" | "vertical";
|
|
11
|
+
/**
|
|
12
|
+
* Disable the RadioButton group
|
|
13
|
+
*/
|
|
14
|
+
disabled?: boolean;
|
|
11
15
|
/**
|
|
12
16
|
* Only for horizontal direction. When `true` the text in radio button label will wrap to fit within the container. Otherwise the radio buttons will wrap onto the next line.
|
|
13
17
|
*/
|
|
@@ -20,9 +24,17 @@ export interface RadioButtonGroupProps extends Omit<ComponentPropsWithoutRef<"fi
|
|
|
20
24
|
* Callback for change event.
|
|
21
25
|
*/
|
|
22
26
|
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
27
|
+
/**
|
|
28
|
+
* Set the RadioButton group to read only.
|
|
29
|
+
*/
|
|
30
|
+
readOnly?: boolean;
|
|
23
31
|
/**
|
|
24
32
|
* The value of the radio group, required for a controlled component.
|
|
25
33
|
*/
|
|
26
34
|
value?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Validation status.
|
|
37
|
+
*/
|
|
38
|
+
validationStatus?: "error" | "warning";
|
|
27
39
|
}
|
|
28
40
|
export declare const RadioButtonGroup: import("react").ForwardRefExoticComponent<RadioButtonGroupProps & import("react").RefAttributes<HTMLFieldSetElement>>;
|