@gnist/design-system 4.5.1 → 5.0.1
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/CHANGELOG.md +21 -0
- package/dist/components/actions/index.cjs +2 -2
- package/dist/components/actions/index.js +2 -2
- package/dist/components/actions/selectionControls/RadioButton.cjs +25 -2
- package/dist/components/actions/selectionControls/RadioButton.d.ts +2 -11
- package/dist/components/actions/selectionControls/RadioButton.d.ts.map +1 -1
- package/dist/components/actions/selectionControls/RadioButton.js +25 -2
- package/dist/components/actions/selectionControls/RadioGroup.cjs +35 -0
- package/dist/components/actions/selectionControls/RadioGroup.d.ts +45 -0
- package/dist/components/actions/selectionControls/RadioGroup.d.ts.map +1 -0
- package/dist/components/actions/selectionControls/RadioGroup.js +33 -0
- package/dist/components/actions/selectionControls/index.cjs +2 -2
- package/dist/components/actions/selectionControls/index.d.ts +1 -1
- package/dist/components/actions/selectionControls/index.d.ts.map +1 -1
- package/dist/components/actions/selectionControls/index.js +2 -2
- package/dist/components/actions/selectionControls/{radiobuttongroup.css.cjs → radiogroup.css.cjs} +25 -0
- package/dist/components/actions/selectionControls/radiogroup.css.d.ts +9 -0
- package/dist/components/actions/selectionControls/radiogroup.css.d.ts.map +1 -0
- package/dist/components/actions/selectionControls/radiogroup.css.js +46 -0
- package/dist/components/index.cjs +2 -2
- package/dist/components/index.js +2 -2
- package/dist/components/inputs/dropdowns/SelectBase.cjs +1 -1
- package/dist/components/inputs/dropdowns/SelectBase.js +1 -1
- package/dist/components/inputs/pickers/calendar.cjs +1 -1
- package/dist/components/inputs/pickers/calendar.js +1 -1
- package/dist/components/surfaces/modal/Modal.cjs +1 -1
- package/dist/components/surfaces/modal/Modal.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/utilities/forms/formInputs.cjs +3 -1
- package/dist/utilities/forms/formInputs.d.ts +3 -0
- package/dist/utilities/forms/formInputs.d.ts.map +1 -1
- package/dist/utilities/forms/formInputs.js +4 -2
- package/dist/utilities/forms/internal/components.cjs +21 -0
- package/dist/utilities/forms/internal/components.d.ts +3 -0
- package/dist/utilities/forms/internal/components.d.ts.map +1 -1
- package/dist/utilities/forms/internal/components.js +21 -0
- package/package.json +3 -3
- package/dist/components/actions/selectionControls/RadioButtonGroup.cjs +0 -12
- package/dist/components/actions/selectionControls/RadioButtonGroup.d.ts +0 -31
- package/dist/components/actions/selectionControls/RadioButtonGroup.d.ts.map +0 -1
- package/dist/components/actions/selectionControls/RadioButtonGroup.js +0 -10
- package/dist/components/actions/selectionControls/radiobuttongroup.css.d.ts +0 -3
- package/dist/components/actions/selectionControls/radiobuttongroup.css.d.ts.map +0 -1
- package/dist/components/actions/selectionControls/radiobuttongroup.css.js +0 -21
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,27 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [5.0.1](https://github.com/mollerdigital/design-system-design-system/compare/@gnist/design-system@5.0.0...@gnist/design-system@5.0.1) (2025-11-25)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* check group before setting group.value ([fcb7fb6](https://github.com/mollerdigital/design-system-design-system/commit/fcb7fb6c71faa1bed7a2673beaae172837df773d))
|
|
11
|
+
|
|
12
|
+
## [5.0.0](https://github.com/mollerdigital/design-system-design-system/compare/@gnist/design-system@4.5.1...@gnist/design-system@5.0.0) (2025-11-24)
|
|
13
|
+
|
|
14
|
+
### ⚠ BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
* RadioButtonGroup renamed to RadioGroup
|
|
17
|
+
|
|
18
|
+
- Radiobuttons can be used in form provider using RadioGroup for field
|
|
19
|
+
- RadioGroup should control state for RadioButtons (but individual control is still supported)
|
|
20
|
+
|
|
21
|
+
This commit was to trigger publish. For code, see: https://github.com/mollerdigital/design-system-design-system/pull/747
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* RadioButtonGroup renamed to RadioGroup ([ce61d98](https://github.com/mollerdigital/design-system-design-system/commit/ce61d984db8f646a3e2dc1d4b853edf7e1f144e8))
|
|
26
|
+
|
|
6
27
|
## [4.5.1](https://github.com/mollerdigital/design-system-design-system/compare/@gnist/design-system@4.5.0...@gnist/design-system@4.5.1) (2025-11-20)
|
|
7
28
|
|
|
8
29
|
**Note:** Version bump only for package @gnist/design-system
|
|
@@ -11,7 +11,7 @@ const IconButton = require("./buttons/IconButton.cjs");
|
|
|
11
11
|
const Checkbox = require("./selectionControls/Checkbox.cjs");
|
|
12
12
|
const RadioButton = require("./selectionControls/RadioButton.cjs");
|
|
13
13
|
const Switch = require("./selectionControls/Switch.cjs");
|
|
14
|
-
const
|
|
14
|
+
const RadioGroup = require("./selectionControls/RadioGroup.cjs");
|
|
15
15
|
const ActionChip = require("./chips/ActionChip.cjs");
|
|
16
16
|
const FilterChip = require("./chips/FilterChip.cjs");
|
|
17
17
|
const TagChip = require("./chips/TagChip.cjs");
|
|
@@ -25,7 +25,7 @@ exports.IconButton = IconButton.IconButton;
|
|
|
25
25
|
exports.Checkbox = Checkbox.Checkbox;
|
|
26
26
|
exports.RadioButton = RadioButton.RadioButton;
|
|
27
27
|
exports.Switch = Switch.Switch;
|
|
28
|
-
exports.
|
|
28
|
+
exports.RadioGroup = RadioGroup.RadioGroup;
|
|
29
29
|
exports.ActionChip = ActionChip.ActionChip;
|
|
30
30
|
exports.FilterChip = FilterChip.FilterChip;
|
|
31
31
|
exports.TagChip = TagChip.TagChip;
|
|
@@ -9,7 +9,7 @@ import { IconButton } from "./buttons/IconButton.js";
|
|
|
9
9
|
import { Checkbox } from "./selectionControls/Checkbox.js";
|
|
10
10
|
import { RadioButton } from "./selectionControls/RadioButton.js";
|
|
11
11
|
import { Switch } from "./selectionControls/Switch.js";
|
|
12
|
-
import {
|
|
12
|
+
import { RadioGroup } from "./selectionControls/RadioGroup.js";
|
|
13
13
|
import { ActionChip } from "./chips/ActionChip.js";
|
|
14
14
|
import { FilterChip } from "./chips/FilterChip.js";
|
|
15
15
|
import { TagChip } from "./chips/TagChip.js";
|
|
@@ -22,7 +22,7 @@ export {
|
|
|
22
22
|
IconButton,
|
|
23
23
|
PrimaryButton,
|
|
24
24
|
RadioButton,
|
|
25
|
-
|
|
25
|
+
RadioGroup,
|
|
26
26
|
SecondaryButton,
|
|
27
27
|
SuccessButton,
|
|
28
28
|
Switch,
|
|
@@ -10,6 +10,7 @@ const classNames = require("classnames");
|
|
|
10
10
|
const radiobutton_css = require("./radiobutton.css.cjs");
|
|
11
11
|
const shared_css = require("./shared.css.cjs");
|
|
12
12
|
const shared = require("./shared.cjs");
|
|
13
|
+
const RadioGroup = require("./RadioGroup.cjs");
|
|
13
14
|
const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
14
15
|
const classNames__default = /* @__PURE__ */ _interopDefaultCompat(classNames);
|
|
15
16
|
const CustomRadioButton = ({ isChecked, disabled, validity }) => {
|
|
@@ -37,19 +38,41 @@ function RadioButton({
|
|
|
37
38
|
render = defaultRender,
|
|
38
39
|
ref,
|
|
39
40
|
checked,
|
|
41
|
+
required,
|
|
42
|
+
name,
|
|
40
43
|
// Input element props
|
|
41
44
|
...rest
|
|
42
45
|
}) {
|
|
46
|
+
const group = RadioGroup.useRadio();
|
|
43
47
|
const inputId = id;
|
|
44
48
|
const labelId = `${id}-label`;
|
|
45
49
|
const helperId = `${id}-helper`;
|
|
46
50
|
const { helperTextProps, inputAriaProps } = InputHelperText.useInputHelperText({
|
|
47
51
|
id: helperId,
|
|
52
|
+
/*
|
|
53
|
+
Used radiobutton-validity here,
|
|
54
|
+
as this determines helperText.
|
|
55
|
+
If controlled by group, error text is in the group component.
|
|
56
|
+
*/
|
|
48
57
|
validity,
|
|
49
58
|
reserveSpaceForMessage: canShowErrorMessage
|
|
50
59
|
});
|
|
51
|
-
const
|
|
52
|
-
const
|
|
60
|
+
const effectiveRequired = group?.required ?? required;
|
|
61
|
+
const effectiveChecked = group ? group.value === value : !!checked;
|
|
62
|
+
const effectiveName = group?.name ?? name;
|
|
63
|
+
const effectiveValidity = group?.validity ?? validity;
|
|
64
|
+
const effectiveDisabled = group?.disabled ?? disabled;
|
|
65
|
+
const handleChange = (event) => {
|
|
66
|
+
if (group?.onChange) {
|
|
67
|
+
group.onChange(String(value));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
onChange?.(event);
|
|
71
|
+
};
|
|
72
|
+
const radioButtonElement = jsxRuntime.jsx("span", { className: classNames__default.default(shared_css.InputWrapper, className), ref, children: jsxRuntime.jsxs("label", { htmlFor: inputId, className: shared_css.LabelRecipe({ disabled: effectiveDisabled }), id: labelId, children: [jsxRuntime.jsx("input", { type: "radio", id: inputId, name: effectiveName, disabled: effectiveDisabled, required: effectiveRequired, onChange: handleChange, value, checked: effectiveChecked, className: shared_css.InputStyleRecipe({
|
|
73
|
+
disabled: effectiveDisabled
|
|
74
|
+
}), tabIndex: 0, ...inputAriaProps, ...rest }), jsxRuntime.jsx(CustomRadioButton, { isChecked: effectiveChecked, disabled: effectiveDisabled, validity: effectiveValidity }), hideLabel ? jsxRuntime.jsx(ScreenReaderOnly.ScreenReaderOnly, { children: label }) : jsxRuntime.jsx("span", { className: shared_css.LabelStyle, children: label })] }) });
|
|
75
|
+
const descriptionElement = description ? jsxRuntime.jsx(shared.SelectionDescription, { disabled: effectiveDisabled, children: description }) : void 0;
|
|
53
76
|
return jsxRuntime.jsx(shared.HelperTextWrapper, { ...helperTextProps, children: render && render(radioButtonElement, descriptionElement) });
|
|
54
77
|
}
|
|
55
78
|
exports.RadioButton = RadioButton;
|
|
@@ -2,16 +2,7 @@ import { Ref } from "react";
|
|
|
2
2
|
import { SelectionControlProps } from "./shared.js";
|
|
3
3
|
export type RadioButtonProps = SelectionControlProps<string> & {
|
|
4
4
|
ref?: Ref<HTMLSpanElement>;
|
|
5
|
-
checked
|
|
5
|
+
checked?: boolean;
|
|
6
6
|
};
|
|
7
|
-
|
|
8
|
-
* Radio buttons allow users to select one option from a list. Use radio buttons when the user needs to see all available options. If available options can be collapsed, consider using a dropdown menu because it uses less space.
|
|
9
|
-
*
|
|
10
|
-
* Radio buttons should be wrapped in a RadioButtonGroup component to ensure proper accessibility and functionality.
|
|
11
|
-
*
|
|
12
|
-
* Radio buttons should be used instead of checkboxes if only one item can be selected from a list.
|
|
13
|
-
|
|
14
|
-
Documentation: [RadioButton](https://gnist.moller.no/developers/components/latest/?path=/docs/components-actions-selectioncontrols-radiobutton--docs)
|
|
15
|
-
**/
|
|
16
|
-
export declare function RadioButton({ value, onChange, disabled, validity, label, description, id, hideLabel, canShowErrorMessage, className, render, ref, checked, ...rest }: RadioButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function RadioButton({ value, onChange, disabled, validity, label, description, id, hideLabel, canShowErrorMessage, className, render, ref, checked, required, name, ...rest }: RadioButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
17
8
|
//# sourceMappingURL=RadioButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioButton.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/selectionControls/RadioButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RadioButton.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/selectionControls/RadioButton.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAcnC,OAAO,EAEH,qBAAqB,EAExB,MAAM,aAAa,CAAC;AAGrB,MAAM,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,MAAM,CAAC,GAAG;IAC3D,GAAG,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAoDF,wBAAgB,WAAW,CAAC,EACxB,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,WAAW,EACX,EAA6B,EAC7B,SAAiB,EACjB,mBAA2B,EAC3B,SAAS,EACT,MAAsB,EACtB,GAAG,EACH,OAAO,EACP,QAAQ,EACR,IAAI,EAEJ,GAAG,IAAI,EACV,EAAE,gBAAgB,2CAmFlB"}
|
|
@@ -8,6 +8,7 @@ import classNames from "classnames";
|
|
|
8
8
|
import { RadioButtonRecipe, CheckedCircleRecipe } from "./radiobutton.css.js";
|
|
9
9
|
import { LabelRecipe, InputStyleRecipe, LabelStyle, InputWrapper, indentedDescriptionStyle } from "./shared.css.js";
|
|
10
10
|
import { SelectionDescription, HelperTextWrapper } from "./shared.js";
|
|
11
|
+
import { useRadio } from "./RadioGroup.js";
|
|
11
12
|
const CustomRadioButton = ({ isChecked, disabled, validity }) => {
|
|
12
13
|
return jsx("span", { className: RadioButtonRecipe({
|
|
13
14
|
disabled,
|
|
@@ -33,19 +34,41 @@ function RadioButton({
|
|
|
33
34
|
render = defaultRender,
|
|
34
35
|
ref,
|
|
35
36
|
checked,
|
|
37
|
+
required,
|
|
38
|
+
name,
|
|
36
39
|
// Input element props
|
|
37
40
|
...rest
|
|
38
41
|
}) {
|
|
42
|
+
const group = useRadio();
|
|
39
43
|
const inputId = id;
|
|
40
44
|
const labelId = `${id}-label`;
|
|
41
45
|
const helperId = `${id}-helper`;
|
|
42
46
|
const { helperTextProps, inputAriaProps } = useInputHelperText({
|
|
43
47
|
id: helperId,
|
|
48
|
+
/*
|
|
49
|
+
Used radiobutton-validity here,
|
|
50
|
+
as this determines helperText.
|
|
51
|
+
If controlled by group, error text is in the group component.
|
|
52
|
+
*/
|
|
44
53
|
validity,
|
|
45
54
|
reserveSpaceForMessage: canShowErrorMessage
|
|
46
55
|
});
|
|
47
|
-
const
|
|
48
|
-
const
|
|
56
|
+
const effectiveRequired = group?.required ?? required;
|
|
57
|
+
const effectiveChecked = group ? group.value === value : !!checked;
|
|
58
|
+
const effectiveName = group?.name ?? name;
|
|
59
|
+
const effectiveValidity = group?.validity ?? validity;
|
|
60
|
+
const effectiveDisabled = group?.disabled ?? disabled;
|
|
61
|
+
const handleChange = (event) => {
|
|
62
|
+
if (group?.onChange) {
|
|
63
|
+
group.onChange(String(value));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
onChange?.(event);
|
|
67
|
+
};
|
|
68
|
+
const radioButtonElement = jsx("span", { className: classNames(InputWrapper, className), ref, children: jsxs("label", { htmlFor: inputId, className: LabelRecipe({ disabled: effectiveDisabled }), id: labelId, children: [jsx("input", { type: "radio", id: inputId, name: effectiveName, disabled: effectiveDisabled, required: effectiveRequired, onChange: handleChange, value, checked: effectiveChecked, className: InputStyleRecipe({
|
|
69
|
+
disabled: effectiveDisabled
|
|
70
|
+
}), tabIndex: 0, ...inputAriaProps, ...rest }), jsx(CustomRadioButton, { isChecked: effectiveChecked, disabled: effectiveDisabled, validity: effectiveValidity }), hideLabel ? jsx(ScreenReaderOnly, { children: label }) : jsx("span", { className: LabelStyle, children: label })] }) });
|
|
71
|
+
const descriptionElement = description ? jsx(SelectionDescription, { disabled: effectiveDisabled, children: description }) : void 0;
|
|
49
72
|
return jsx(HelperTextWrapper, { ...helperTextProps, children: render && render(radioButtonElement, descriptionElement) });
|
|
50
73
|
}
|
|
51
74
|
export {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const classNames = require("classnames");
|
|
6
|
+
const radiogroup_css = require("./radiogroup.css.cjs");
|
|
7
|
+
const React = require("react");
|
|
8
|
+
const InputHelperText = require("../../../building-blocks/inputs/InputHelperText.cjs");
|
|
9
|
+
require("../../../utilities/layout/Row.cjs");
|
|
10
|
+
require("@gnist/themes/tokens.css.js");
|
|
11
|
+
require("react-content-loader");
|
|
12
|
+
const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
13
|
+
const classNames__default = /* @__PURE__ */ _interopDefaultCompat(classNames);
|
|
14
|
+
function RadioGroup({ className, label, children, ref, name, value, onChange, required, validity, helperText, direction = "vertical", ...props }) {
|
|
15
|
+
const nameId = React.useId();
|
|
16
|
+
const radioName = name ?? `groupName-${nameId}`;
|
|
17
|
+
const isControlledByGroup = name !== void 0 && value !== void 0 && onChange !== void 0;
|
|
18
|
+
const contextValue = isControlledByGroup ? {
|
|
19
|
+
name: radioName,
|
|
20
|
+
value,
|
|
21
|
+
onChange,
|
|
22
|
+
required: required ?? false,
|
|
23
|
+
validity,
|
|
24
|
+
disabled: props.disabled
|
|
25
|
+
} : null;
|
|
26
|
+
const helperId = `${nameId}-helper`;
|
|
27
|
+
return jsxRuntime.jsx("fieldset", { className: classNames__default.default(radiogroup_css.fieldSetStyle, className), ref, ...props, children: jsxRuntime.jsxs(RadioGroupContext, { value: contextValue, children: [jsxRuntime.jsx("legend", { className: radiogroup_css.legendStyle, children: label }), jsxRuntime.jsx("div", { className: radiogroup_css.radioContainerStyle({ direction }), children }), jsxRuntime.jsx(InputHelperText.InputHelperText, { helperText, id: helperId, validity })] }) });
|
|
28
|
+
}
|
|
29
|
+
const RadioGroupContext = React.createContext(null);
|
|
30
|
+
function useRadio() {
|
|
31
|
+
const context = React.use(RadioGroupContext);
|
|
32
|
+
return context;
|
|
33
|
+
}
|
|
34
|
+
exports.RadioGroup = RadioGroup;
|
|
35
|
+
exports.useRadio = useRadio;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { InputFieldValidity } from "../../../building-blocks/index.js";
|
|
2
|
+
interface BaseProps extends Omit<React.FieldsetHTMLAttributes<HTMLFieldSetElement>, "onChange" | "name" | "value"> {
|
|
3
|
+
label: string;
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
ref?: React.Ref<HTMLFieldSetElement>;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
validity?: InputFieldValidity<{
|
|
9
|
+
errorMsgRequired: false;
|
|
10
|
+
}>;
|
|
11
|
+
helperText?: string;
|
|
12
|
+
direction?: "horizontal" | "vertical";
|
|
13
|
+
}
|
|
14
|
+
type ControlledByGroup = {
|
|
15
|
+
name: string;
|
|
16
|
+
value: string;
|
|
17
|
+
onChange: (value: string) => void;
|
|
18
|
+
};
|
|
19
|
+
type ControlledByItem = {
|
|
20
|
+
name?: never;
|
|
21
|
+
value?: never;
|
|
22
|
+
onChange?: never;
|
|
23
|
+
};
|
|
24
|
+
export type RadioGroupProps = BaseProps & (ControlledByGroup | ControlledByItem);
|
|
25
|
+
/**
|
|
26
|
+
* Radio groups gives a label for a group of radio buttons.
|
|
27
|
+
*
|
|
28
|
+
* You should also use the radio group to control the items.
|
|
29
|
+
*
|
|
30
|
+
* Documentation: [RadioGroup](https://gnist.moller.no/developers/components/latest/?path=/docs/components-actions-selectioncontrols-radiogroup--docs)
|
|
31
|
+
**/
|
|
32
|
+
export declare function RadioGroup({ className, label, children, ref, name, value, onChange, required, validity, helperText, direction, ...props }: RadioGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
interface RadioGroupContextProps {
|
|
34
|
+
name: string;
|
|
35
|
+
value: string;
|
|
36
|
+
onChange: (value: string) => void;
|
|
37
|
+
required: boolean;
|
|
38
|
+
validity?: InputFieldValidity<{
|
|
39
|
+
errorMsgRequired: false;
|
|
40
|
+
}>;
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export declare function useRadio(): RadioGroupContextProps | null;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=RadioGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/selectionControls/RadioGroup.tsx"],"names":[],"mappings":"AAOA,OAAO,EACH,kBAAkB,EAErB,0CAAsD;AAEvD,UAAU,SACN,SAAQ,IAAI,CACR,KAAK,CAAC,sBAAsB,CAAC,mBAAmB,CAAC,EACjD,UAAU,GAAG,MAAM,GAAG,OAAO,CAChC;IACD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;QAAE,gBAAgB,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;CACzC;AAED,KAAK,iBAAiB,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACpB,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,SAAS,GACnC,CAAC,iBAAiB,GAAG,gBAAgB,CAAC,CAAC;AAE3C;;;;;;IAMI;AACJ,wBAAgB,UAAU,CAAC,EACvB,SAAS,EACT,KAAK,EACL,QAAQ,EACR,GAAG,EACH,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,SAAsB,EACtB,GAAG,KAAK,EACX,EAAE,eAAe,2CAuCjB;AAED,UAAU,sBAAsB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;QAAE,gBAAgB,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAID,wBAAgB,QAAQ,kCAIvB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import classNames from "classnames";
|
|
4
|
+
import { legendStyle, radioContainerStyle, fieldSetStyle } from "./radiogroup.css.js";
|
|
5
|
+
import { createContext, useId, use } from "react";
|
|
6
|
+
import { InputHelperText } from "../../../building-blocks/inputs/InputHelperText.js";
|
|
7
|
+
import "../../../utilities/layout/Row.js";
|
|
8
|
+
import "@gnist/themes/tokens.css.js";
|
|
9
|
+
import "react-content-loader";
|
|
10
|
+
function RadioGroup({ className, label, children, ref, name, value, onChange, required, validity, helperText, direction = "vertical", ...props }) {
|
|
11
|
+
const nameId = useId();
|
|
12
|
+
const radioName = name ?? `groupName-${nameId}`;
|
|
13
|
+
const isControlledByGroup = name !== void 0 && value !== void 0 && onChange !== void 0;
|
|
14
|
+
const contextValue = isControlledByGroup ? {
|
|
15
|
+
name: radioName,
|
|
16
|
+
value,
|
|
17
|
+
onChange,
|
|
18
|
+
required: required ?? false,
|
|
19
|
+
validity,
|
|
20
|
+
disabled: props.disabled
|
|
21
|
+
} : null;
|
|
22
|
+
const helperId = `${nameId}-helper`;
|
|
23
|
+
return jsx("fieldset", { className: classNames(fieldSetStyle, className), ref, ...props, children: jsxs(RadioGroupContext, { value: contextValue, children: [jsx("legend", { className: legendStyle, children: label }), jsx("div", { className: radioContainerStyle({ direction }), children }), jsx(InputHelperText, { helperText, id: helperId, validity })] }) });
|
|
24
|
+
}
|
|
25
|
+
const RadioGroupContext = createContext(null);
|
|
26
|
+
function useRadio() {
|
|
27
|
+
const context = use(RadioGroupContext);
|
|
28
|
+
return context;
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
RadioGroup,
|
|
32
|
+
useRadio
|
|
33
|
+
};
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
4
4
|
const Checkbox = require("./Checkbox.cjs");
|
|
5
5
|
const RadioButton = require("./RadioButton.cjs");
|
|
6
6
|
const Switch = require("./Switch.cjs");
|
|
7
|
-
const
|
|
7
|
+
const RadioGroup = require("./RadioGroup.cjs");
|
|
8
8
|
exports.Checkbox = Checkbox.Checkbox;
|
|
9
9
|
exports.RadioButton = RadioButton.RadioButton;
|
|
10
10
|
exports.Switch = Switch.Switch;
|
|
11
|
-
exports.
|
|
11
|
+
exports.RadioGroup = RadioGroup.RadioGroup;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Checkbox, type CheckboxProps } from "./Checkbox.js";
|
|
2
2
|
export { RadioButton, type RadioButtonProps } from "./RadioButton.js";
|
|
3
3
|
export { Switch, type SwitchProps } from "./Switch.js";
|
|
4
|
-
export {
|
|
4
|
+
export { RadioGroup } from "./RadioGroup.js";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/selectionControls/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/selectionControls/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { Checkbox } from "./Checkbox.js";
|
|
3
3
|
import { RadioButton } from "./RadioButton.js";
|
|
4
4
|
import { Switch } from "./Switch.js";
|
|
5
|
-
import {
|
|
5
|
+
import { RadioGroup } from "./RadioGroup.js";
|
|
6
6
|
export {
|
|
7
7
|
Checkbox,
|
|
8
8
|
RadioButton,
|
|
9
|
-
|
|
9
|
+
RadioGroup,
|
|
10
10
|
Switch
|
|
11
11
|
};
|
package/dist/components/actions/selectionControls/{radiobuttongroup.css.cjs → radiogroup.css.cjs}
RENAMED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
const atoms_css_js = require("@gnist/themes/atoms.css.js");
|
|
5
5
|
const css = require("@vanilla-extract/css");
|
|
6
|
+
const recipes = require("@vanilla-extract/recipes");
|
|
6
7
|
const fieldSetStyle = css.style([
|
|
7
8
|
{
|
|
8
9
|
border: "none"
|
|
@@ -17,5 +18,29 @@ const fieldSetStyle = css.style([
|
|
|
17
18
|
const legendStyle = atoms_css_js.atoms({
|
|
18
19
|
marginBottom: "base"
|
|
19
20
|
});
|
|
21
|
+
const radioContainerStyle = recipes.recipe({
|
|
22
|
+
base: [
|
|
23
|
+
atoms_css_js.atoms({
|
|
24
|
+
display: "flex",
|
|
25
|
+
gap: "xs"
|
|
26
|
+
})
|
|
27
|
+
],
|
|
28
|
+
variants: {
|
|
29
|
+
direction: {
|
|
30
|
+
vertical: [
|
|
31
|
+
atoms_css_js.atoms({
|
|
32
|
+
flexDirection: "column"
|
|
33
|
+
})
|
|
34
|
+
],
|
|
35
|
+
horizontal: [
|
|
36
|
+
atoms_css_js.atoms({
|
|
37
|
+
flexDirection: "row",
|
|
38
|
+
flexWrap: "wrap"
|
|
39
|
+
})
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
20
44
|
exports.fieldSetStyle = fieldSetStyle;
|
|
21
45
|
exports.legendStyle = legendStyle;
|
|
46
|
+
exports.radioContainerStyle = radioContainerStyle;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const fieldSetStyle: string;
|
|
2
|
+
export declare const legendStyle: string;
|
|
3
|
+
export declare const radioContainerStyle: import("@vanilla-extract/recipes").RuntimeFn<{
|
|
4
|
+
direction: {
|
|
5
|
+
vertical: string[];
|
|
6
|
+
horizontal: string[];
|
|
7
|
+
};
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=radiogroup.css.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radiogroup.css.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/selectionControls/radiogroup.css.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,QAUxB,CAAC;AAEH,eAAO,MAAM,WAAW,QAEtB,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;EAsB9B,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { atoms } from "@gnist/themes/atoms.css.js";
|
|
3
|
+
import { style } from "@vanilla-extract/css";
|
|
4
|
+
import { recipe } from "@vanilla-extract/recipes";
|
|
5
|
+
const fieldSetStyle = style([
|
|
6
|
+
{
|
|
7
|
+
border: "none"
|
|
8
|
+
},
|
|
9
|
+
atoms({
|
|
10
|
+
padding: "none",
|
|
11
|
+
display: "flex",
|
|
12
|
+
flexDirection: "column",
|
|
13
|
+
gap: "base"
|
|
14
|
+
})
|
|
15
|
+
]);
|
|
16
|
+
const legendStyle = atoms({
|
|
17
|
+
marginBottom: "base"
|
|
18
|
+
});
|
|
19
|
+
const radioContainerStyle = recipe({
|
|
20
|
+
base: [
|
|
21
|
+
atoms({
|
|
22
|
+
display: "flex",
|
|
23
|
+
gap: "xs"
|
|
24
|
+
})
|
|
25
|
+
],
|
|
26
|
+
variants: {
|
|
27
|
+
direction: {
|
|
28
|
+
vertical: [
|
|
29
|
+
atoms({
|
|
30
|
+
flexDirection: "column"
|
|
31
|
+
})
|
|
32
|
+
],
|
|
33
|
+
horizontal: [
|
|
34
|
+
atoms({
|
|
35
|
+
flexDirection: "row",
|
|
36
|
+
flexWrap: "wrap"
|
|
37
|
+
})
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
export {
|
|
43
|
+
fieldSetStyle,
|
|
44
|
+
legendStyle,
|
|
45
|
+
radioContainerStyle
|
|
46
|
+
};
|
|
@@ -11,7 +11,7 @@ const IconButton = require("./actions/buttons/IconButton.cjs");
|
|
|
11
11
|
const Checkbox = require("./actions/selectionControls/Checkbox.cjs");
|
|
12
12
|
const RadioButton = require("./actions/selectionControls/RadioButton.cjs");
|
|
13
13
|
const Switch = require("./actions/selectionControls/Switch.cjs");
|
|
14
|
-
const
|
|
14
|
+
const RadioGroup = require("./actions/selectionControls/RadioGroup.cjs");
|
|
15
15
|
const ActionChip = require("./actions/chips/ActionChip.cjs");
|
|
16
16
|
const FilterChip = require("./actions/chips/FilterChip.cjs");
|
|
17
17
|
const TagChip = require("./actions/chips/TagChip.cjs");
|
|
@@ -42,7 +42,7 @@ exports.IconButton = IconButton.IconButton;
|
|
|
42
42
|
exports.Checkbox = Checkbox.Checkbox;
|
|
43
43
|
exports.RadioButton = RadioButton.RadioButton;
|
|
44
44
|
exports.Switch = Switch.Switch;
|
|
45
|
-
exports.
|
|
45
|
+
exports.RadioGroup = RadioGroup.RadioGroup;
|
|
46
46
|
exports.ActionChip = ActionChip.ActionChip;
|
|
47
47
|
exports.FilterChip = FilterChip.FilterChip;
|
|
48
48
|
exports.TagChip = TagChip.TagChip;
|
package/dist/components/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { IconButton } from "./actions/buttons/IconButton.js";
|
|
|
9
9
|
import { Checkbox } from "./actions/selectionControls/Checkbox.js";
|
|
10
10
|
import { RadioButton } from "./actions/selectionControls/RadioButton.js";
|
|
11
11
|
import { Switch } from "./actions/selectionControls/Switch.js";
|
|
12
|
-
import {
|
|
12
|
+
import { RadioGroup } from "./actions/selectionControls/RadioGroup.js";
|
|
13
13
|
import { ActionChip } from "./actions/chips/ActionChip.js";
|
|
14
14
|
import { FilterChip } from "./actions/chips/FilterChip.js";
|
|
15
15
|
import { TagChip } from "./actions/chips/TagChip.js";
|
|
@@ -52,8 +52,8 @@ export {
|
|
|
52
52
|
ProgressBar,
|
|
53
53
|
ProgressBarComponent,
|
|
54
54
|
RadioButton,
|
|
55
|
-
RadioButtonGroup,
|
|
56
55
|
RadioCard,
|
|
56
|
+
RadioGroup,
|
|
57
57
|
SecondaryButton,
|
|
58
58
|
SingleSelect,
|
|
59
59
|
Spinner,
|
|
@@ -31,8 +31,8 @@ const Checkbox = require("../../actions/selectionControls/Checkbox.cjs");
|
|
|
31
31
|
require("../../actions/selectionControls/radiobutton.css.cjs");
|
|
32
32
|
require("../../actions/selectionControls/shared.css.cjs");
|
|
33
33
|
require("../../../utilities/layout/Column.cjs");
|
|
34
|
+
require("../../actions/selectionControls/RadioGroup.cjs");
|
|
34
35
|
require("../../actions/selectionControls/switch.css.cjs");
|
|
35
|
-
require("../../actions/selectionControls/radiobuttongroup.css.cjs");
|
|
36
36
|
require("../../../styles/animations.css.cjs");
|
|
37
37
|
require("../../actions/chips/styles.css.cjs");
|
|
38
38
|
const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
@@ -30,8 +30,8 @@ import { Checkbox } from "../../actions/selectionControls/Checkbox.js";
|
|
|
30
30
|
import "../../actions/selectionControls/radiobutton.css.js";
|
|
31
31
|
import "../../actions/selectionControls/shared.css.js";
|
|
32
32
|
import "../../../utilities/layout/Column.js";
|
|
33
|
+
import "../../actions/selectionControls/RadioGroup.js";
|
|
33
34
|
import "../../actions/selectionControls/switch.css.js";
|
|
34
|
-
import "../../actions/selectionControls/radiobuttongroup.css.js";
|
|
35
35
|
import "../../../styles/animations.css.js";
|
|
36
36
|
import "../../actions/chips/styles.css.js";
|
|
37
37
|
function SelectBase(props, isMultiple) {
|
|
@@ -32,8 +32,8 @@ require("../../actions/selectionControls/checkbox.css.cjs");
|
|
|
32
32
|
require("../../actions/selectionControls/shared.css.cjs");
|
|
33
33
|
require("../../../utilities/layout/Column.cjs");
|
|
34
34
|
require("../../actions/selectionControls/radiobutton.css.cjs");
|
|
35
|
+
require("../../actions/selectionControls/RadioGroup.cjs");
|
|
35
36
|
require("../../actions/selectionControls/switch.css.cjs");
|
|
36
|
-
require("../../actions/selectionControls/radiobuttongroup.css.cjs");
|
|
37
37
|
require("../../../styles/animations.css.cjs");
|
|
38
38
|
require("../../actions/chips/styles.css.cjs");
|
|
39
39
|
const Calendar_css = require("./Calendar.css.cjs");
|
|
@@ -30,8 +30,8 @@ import "../../actions/selectionControls/checkbox.css.js";
|
|
|
30
30
|
import "../../actions/selectionControls/shared.css.js";
|
|
31
31
|
import "../../../utilities/layout/Column.js";
|
|
32
32
|
import "../../actions/selectionControls/radiobutton.css.js";
|
|
33
|
+
import "../../actions/selectionControls/RadioGroup.js";
|
|
33
34
|
import "../../actions/selectionControls/switch.css.js";
|
|
34
|
-
import "../../actions/selectionControls/radiobuttongroup.css.js";
|
|
35
35
|
import "../../../styles/animations.css.js";
|
|
36
36
|
import "../../actions/chips/styles.css.js";
|
|
37
37
|
import { headerCell, containerStyle, selectMonthRow, buttonRow, arrowButton, gridStyle, rowStyle, cellSkeletonStyle, firstDay, cellRecipe } from "./Calendar.css.js";
|
|
@@ -26,8 +26,8 @@ require("../../actions/selectionControls/shared.css.cjs");
|
|
|
26
26
|
require("../../../utilities/layout/Column.cjs");
|
|
27
27
|
require("../../../utilities/layout/Row.cjs");
|
|
28
28
|
require("../../actions/selectionControls/radiobutton.css.cjs");
|
|
29
|
+
require("../../actions/selectionControls/RadioGroup.cjs");
|
|
29
30
|
require("../../actions/selectionControls/switch.css.cjs");
|
|
30
|
-
require("../../actions/selectionControls/radiobuttongroup.css.cjs");
|
|
31
31
|
require("../../../styles/animations.css.cjs");
|
|
32
32
|
require("../../actions/chips/styles.css.cjs");
|
|
33
33
|
const index = require("../../../translations/index.cjs");
|
|
@@ -24,8 +24,8 @@ import "../../actions/selectionControls/shared.css.js";
|
|
|
24
24
|
import "../../../utilities/layout/Column.js";
|
|
25
25
|
import "../../../utilities/layout/Row.js";
|
|
26
26
|
import "../../actions/selectionControls/radiobutton.css.js";
|
|
27
|
+
import "../../actions/selectionControls/RadioGroup.js";
|
|
27
28
|
import "../../actions/selectionControls/switch.css.js";
|
|
28
|
-
import "../../actions/selectionControls/radiobuttongroup.css.js";
|
|
29
29
|
import "../../../styles/animations.css.js";
|
|
30
30
|
import "../../actions/chips/styles.css.js";
|
|
31
31
|
import { useTranslation } from "../../../translations/index.js";
|
package/dist/index.cjs
CHANGED
|
@@ -12,7 +12,7 @@ const IconButton = require("./components/actions/buttons/IconButton.cjs");
|
|
|
12
12
|
const Checkbox = require("./components/actions/selectionControls/Checkbox.cjs");
|
|
13
13
|
const RadioButton = require("./components/actions/selectionControls/RadioButton.cjs");
|
|
14
14
|
const Switch = require("./components/actions/selectionControls/Switch.cjs");
|
|
15
|
-
const
|
|
15
|
+
const RadioGroup = require("./components/actions/selectionControls/RadioGroup.cjs");
|
|
16
16
|
const ActionChip = require("./components/actions/chips/ActionChip.cjs");
|
|
17
17
|
const FilterChip = require("./components/actions/chips/FilterChip.cjs");
|
|
18
18
|
const TagChip = require("./components/actions/chips/TagChip.cjs");
|
|
@@ -63,7 +63,7 @@ exports.IconButton = IconButton.IconButton;
|
|
|
63
63
|
exports.Checkbox = Checkbox.Checkbox;
|
|
64
64
|
exports.RadioButton = RadioButton.RadioButton;
|
|
65
65
|
exports.Switch = Switch.Switch;
|
|
66
|
-
exports.
|
|
66
|
+
exports.RadioGroup = RadioGroup.RadioGroup;
|
|
67
67
|
exports.ActionChip = ActionChip.ActionChip;
|
|
68
68
|
exports.FilterChip = FilterChip.FilterChip;
|
|
69
69
|
exports.TagChip = TagChip.TagChip;
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { IconButton } from "./components/actions/buttons/IconButton.js";
|
|
|
10
10
|
import { Checkbox } from "./components/actions/selectionControls/Checkbox.js";
|
|
11
11
|
import { RadioButton } from "./components/actions/selectionControls/RadioButton.js";
|
|
12
12
|
import { Switch } from "./components/actions/selectionControls/Switch.js";
|
|
13
|
-
import {
|
|
13
|
+
import { RadioGroup } from "./components/actions/selectionControls/RadioGroup.js";
|
|
14
14
|
import { ActionChip } from "./components/actions/chips/ActionChip.js";
|
|
15
15
|
import { FilterChip } from "./components/actions/chips/FilterChip.js";
|
|
16
16
|
import { TagChip } from "./components/actions/chips/TagChip.js";
|
|
@@ -95,8 +95,8 @@ export {
|
|
|
95
95
|
ProgressBar,
|
|
96
96
|
ProgressBarComponent,
|
|
97
97
|
RadioButton,
|
|
98
|
-
RadioButtonGroup,
|
|
99
98
|
RadioCard,
|
|
99
|
+
RadioGroup,
|
|
100
100
|
Row,
|
|
101
101
|
ScreenReaderOnly,
|
|
102
102
|
SecondaryButton,
|
|
@@ -8,12 +8,14 @@ function formInputs() {
|
|
|
8
8
|
const Checkbox = components.FormCheckbox;
|
|
9
9
|
const SingleSelect = components.FormSingleSelect;
|
|
10
10
|
const MultiSelect = components.FormMultiSelect;
|
|
11
|
+
const RadioGroup = components.FormRadioGroup;
|
|
11
12
|
return {
|
|
12
13
|
TextField,
|
|
13
14
|
TextArea,
|
|
14
15
|
Checkbox,
|
|
15
16
|
SingleSelect,
|
|
16
|
-
MultiSelect
|
|
17
|
+
MultiSelect,
|
|
18
|
+
RadioGroup
|
|
17
19
|
};
|
|
18
20
|
}
|
|
19
21
|
exports.formInputs = formInputs;
|
|
@@ -13,5 +13,8 @@ export declare function formInputs<_T>(): {
|
|
|
13
13
|
MultiSelect: (originalProps: import("react").PropsWithChildren<Omit<Omit<import("../../components/inputs/dropdowns/MultiSelect.js").MultiSelectProps, "onChange"> & {
|
|
14
14
|
onChange?: ((value: string[]) => void) | undefined;
|
|
15
15
|
}, "value" | "id"> & import("./types.js").FormContext<_T>>) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
RadioGroup: (originalProps: import("react").PropsWithChildren<Omit<Omit<import("../../components/actions/selectionControls/RadioGroup.js").RadioGroupProps, "onChange"> & {
|
|
17
|
+
onChange?: ((value: string) => void) | undefined;
|
|
18
|
+
}, "value" | "id"> & import("./types.js").FormContext<_T>>) => import("react/jsx-runtime").JSX.Element;
|
|
16
19
|
};
|
|
17
20
|
//# sourceMappingURL=formInputs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formInputs.d.ts","sourceRoot":"","sources":["../../../src/utilities/forms/formInputs.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formInputs.d.ts","sourceRoot":"","sources":["../../../src/utilities/forms/formInputs.tsx"],"names":[],"mappings":"AASA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EAAE;;;;;;;;;;;;;EAe5B"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { FormMultiSelect, FormSingleSelect, FormCheckbox, FormTextArea, FormTextField } from "./internal/components.js";
|
|
2
|
+
import { FormRadioGroup, FormMultiSelect, FormSingleSelect, FormCheckbox, FormTextArea, FormTextField } from "./internal/components.js";
|
|
3
3
|
function formInputs() {
|
|
4
4
|
const TextField = FormTextField;
|
|
5
5
|
const TextArea = FormTextArea;
|
|
6
6
|
const Checkbox = FormCheckbox;
|
|
7
7
|
const SingleSelect = FormSingleSelect;
|
|
8
8
|
const MultiSelect = FormMultiSelect;
|
|
9
|
+
const RadioGroup = FormRadioGroup;
|
|
9
10
|
return {
|
|
10
11
|
TextField,
|
|
11
12
|
TextArea,
|
|
12
13
|
Checkbox,
|
|
13
14
|
SingleSelect,
|
|
14
|
-
MultiSelect
|
|
15
|
+
MultiSelect,
|
|
16
|
+
RadioGroup
|
|
15
17
|
};
|
|
16
18
|
}
|
|
17
19
|
export {
|
|
@@ -12,6 +12,7 @@ require("../../validation/validators.cjs");
|
|
|
12
12
|
const validation = require("../../validation/validation.cjs");
|
|
13
13
|
const formContext = require("../formContext.cjs");
|
|
14
14
|
const useFormProps = require("../useFormProps.cjs");
|
|
15
|
+
const RadioGroup = require("../../../components/actions/selectionControls/RadioGroup.cjs");
|
|
15
16
|
function FormTextField(originalProps) {
|
|
16
17
|
const props = useFormProps.useFormProps(originalProps, (event) => event.target.value);
|
|
17
18
|
return jsxRuntime.jsx(TextField.TextField, { ...props });
|
|
@@ -66,8 +67,28 @@ function FormMultiSelect(originalProps) {
|
|
|
66
67
|
};
|
|
67
68
|
return jsxRuntime.jsx(MultiSelect.MultiSelect, { ...props });
|
|
68
69
|
}
|
|
70
|
+
function FormRadioGroup(originalProps) {
|
|
71
|
+
const formCtx = formContext.useForm();
|
|
72
|
+
if (!formCtx) {
|
|
73
|
+
throw new Error("FormRadioGroup must be used inside a <FormProvider />");
|
|
74
|
+
}
|
|
75
|
+
const { id: formId, form } = formCtx;
|
|
76
|
+
const formProps = form.inputProps(originalProps.field);
|
|
77
|
+
const props = {
|
|
78
|
+
...originalProps,
|
|
79
|
+
name: `${formId}_${String(originalProps.field)}`,
|
|
80
|
+
onChange: (value) => {
|
|
81
|
+
originalProps.onChange?.(value);
|
|
82
|
+
formProps.setValue(value);
|
|
83
|
+
},
|
|
84
|
+
value: formProps.value,
|
|
85
|
+
validity: formProps.validity ?? originalProps.validity
|
|
86
|
+
};
|
|
87
|
+
return jsxRuntime.jsx(RadioGroup.RadioGroup, { ...props });
|
|
88
|
+
}
|
|
69
89
|
exports.FormCheckbox = FormCheckbox;
|
|
70
90
|
exports.FormMultiSelect = FormMultiSelect;
|
|
91
|
+
exports.FormRadioGroup = FormRadioGroup;
|
|
71
92
|
exports.FormSingleSelect = FormSingleSelect;
|
|
72
93
|
exports.FormTextArea = FormTextArea;
|
|
73
94
|
exports.FormTextField = FormTextField;
|
|
@@ -4,6 +4,7 @@ import { CheckboxProps } from "../../../components/actions/selectionControls/Che
|
|
|
4
4
|
import { TextAreaProps } from "../../../components/inputs/textFields/TextArea.js";
|
|
5
5
|
import { TextFieldProps } from "../../../components/inputs/textFields/TextField.js";
|
|
6
6
|
import { FormComponentProps } from "../types.js";
|
|
7
|
+
import { RadioGroupProps } from "../../../components/actions/selectionControls/RadioGroup.js";
|
|
7
8
|
type FormTextFieldProps<T> = FormComponentProps<T, TextFieldProps>;
|
|
8
9
|
export declare function FormTextField<T>(originalProps: React.PropsWithChildren<FormTextFieldProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
type FormTextAreaProps<T> = FormComponentProps<T, TextAreaProps>;
|
|
@@ -17,5 +18,7 @@ type FormSingleSelectProps<T> = FormComponentProps<T, WithOptional<"onChange", S
|
|
|
17
18
|
export declare function FormSingleSelect<T>(originalProps: React.PropsWithChildren<FormSingleSelectProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
18
19
|
type FormMultiSelectProps<T> = FormComponentProps<T, WithOptional<"onChange", MultiSelectProps>>;
|
|
19
20
|
export declare function FormMultiSelect<T>(originalProps: React.PropsWithChildren<FormMultiSelectProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
type FormRadioGroupProps<T> = FormComponentProps<T, WithOptional<"onChange", RadioGroupProps>>;
|
|
22
|
+
export declare function FormRadioGroup<T>(originalProps: React.PropsWithChildren<FormRadioGroupProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
20
23
|
export {};
|
|
21
24
|
//# sourceMappingURL=components.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../../src/utilities/forms/internal/components.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEH,gBAAgB,EACnB,4DAAwE;AACzE,OAAO,EAEH,iBAAiB,EACpB,6DAAyE;AAC1E,OAAO,EAEH,aAAa,EAChB,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAEH,aAAa,EAChB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAEH,cAAc,EACjB,MAAM,oDAAoD,CAAC;AAI5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../../src/utilities/forms/internal/components.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEH,gBAAgB,EACnB,4DAAwE;AACzE,OAAO,EAEH,iBAAiB,EACpB,6DAAyE;AAC1E,OAAO,EAEH,aAAa,EAChB,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAEH,aAAa,EAChB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAEH,cAAc,EACjB,MAAM,oDAAoD,CAAC;AAI5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAEH,eAAe,EAClB,oEAAgF;AAEjF,KAAK,kBAAkB,CAAC,CAAC,IAAI,kBAAkB,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;AAEnE,wBAAgB,aAAa,CAAC,CAAC,EAC3B,aAAa,EAAE,KAAK,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,2CAShE;AAED,KAAK,iBAAiB,CAAC,CAAC,IAAI,kBAAkB,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;AAEjE,wBAAgB,YAAY,CAAC,CAAC,EAC1B,aAAa,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,2CAU/D;AAED,KAAK,iBAAiB,CAAC,CAAC,IAAI,kBAAkB,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;AAEjE,wBAAgB,YAAY,CAAC,CAAC,EAC1B,aAAa,EAAE,KAAK,CAAC,iBAAiB,CAClC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,qBAAqB,CAAC,CACpD,2CASJ;AAED,KAAK,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;KAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC;CAAE,CAAC;AAE/E,KAAK,qBAAqB,CAAC,CAAC,IAAI,kBAAkB,CAC9C,CAAC,EACD,YAAY,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAC9C,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,CAAC,EAC9B,aAAa,EAAE,KAAK,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,2CA8BnE;AAED,KAAK,oBAAoB,CAAC,CAAC,IAAI,kBAAkB,CAC7C,CAAC,EACD,YAAY,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAC7C,CAAC;AAEF,wBAAgB,eAAe,CAAC,CAAC,EAC7B,aAAa,EAAE,KAAK,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,2CA8BlE;AAED,KAAK,mBAAmB,CAAC,CAAC,IAAI,kBAAkB,CAC5C,CAAC,EACD,YAAY,CAAC,UAAU,EAAE,eAAe,CAAC,CAC5C,CAAC;AAEF,wBAAgB,cAAc,CAAC,CAAC,EAC5B,aAAa,EAAE,KAAK,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,2CAuBjE"}
|
|
@@ -10,6 +10,7 @@ import "../../validation/validators.js";
|
|
|
10
10
|
import { addNecessityIndicator } from "../../validation/validation.js";
|
|
11
11
|
import { useForm } from "../formContext.js";
|
|
12
12
|
import { useFormProps } from "../useFormProps.js";
|
|
13
|
+
import { RadioGroup } from "../../../components/actions/selectionControls/RadioGroup.js";
|
|
13
14
|
function FormTextField(originalProps) {
|
|
14
15
|
const props = useFormProps(originalProps, (event) => event.target.value);
|
|
15
16
|
return jsx(TextField, { ...props });
|
|
@@ -64,9 +65,29 @@ function FormMultiSelect(originalProps) {
|
|
|
64
65
|
};
|
|
65
66
|
return jsx(MultiSelect, { ...props });
|
|
66
67
|
}
|
|
68
|
+
function FormRadioGroup(originalProps) {
|
|
69
|
+
const formCtx = useForm();
|
|
70
|
+
if (!formCtx) {
|
|
71
|
+
throw new Error("FormRadioGroup must be used inside a <FormProvider />");
|
|
72
|
+
}
|
|
73
|
+
const { id: formId, form } = formCtx;
|
|
74
|
+
const formProps = form.inputProps(originalProps.field);
|
|
75
|
+
const props = {
|
|
76
|
+
...originalProps,
|
|
77
|
+
name: `${formId}_${String(originalProps.field)}`,
|
|
78
|
+
onChange: (value) => {
|
|
79
|
+
originalProps.onChange?.(value);
|
|
80
|
+
formProps.setValue(value);
|
|
81
|
+
},
|
|
82
|
+
value: formProps.value,
|
|
83
|
+
validity: formProps.validity ?? originalProps.validity
|
|
84
|
+
};
|
|
85
|
+
return jsx(RadioGroup, { ...props });
|
|
86
|
+
}
|
|
67
87
|
export {
|
|
68
88
|
FormCheckbox,
|
|
69
89
|
FormMultiSelect,
|
|
90
|
+
FormRadioGroup,
|
|
70
91
|
FormSingleSelect,
|
|
71
92
|
FormTextArea,
|
|
72
93
|
FormTextField
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gnist/design-system",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@base-ui-components/react": "1.0.0-beta.2",
|
|
51
51
|
"@formkit/auto-animate": "^0.8.2",
|
|
52
52
|
"@gnist/component-utils": "3.0.10",
|
|
53
|
-
"@gnist/themes": "^3.22.
|
|
53
|
+
"@gnist/themes": "^3.22.1",
|
|
54
54
|
"@vanilla-extract/css": "^1.17.4",
|
|
55
55
|
"@vanilla-extract/css-utils": "^0.1.6",
|
|
56
56
|
"@vanilla-extract/dynamic": "^2.1.5",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"optional": true
|
|
103
103
|
}
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "c80dadbc6fea53420af1b2e956efebefbe4062d9"
|
|
106
106
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
-
const classNames = require("classnames");
|
|
6
|
-
const radiobuttongroup_css = require("./radiobuttongroup.css.cjs");
|
|
7
|
-
const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
8
|
-
const classNames__default = /* @__PURE__ */ _interopDefaultCompat(classNames);
|
|
9
|
-
function RadioButtonGroup({ className, label, children, ref, ...props }) {
|
|
10
|
-
return jsxRuntime.jsxs("fieldset", { className: classNames__default.default(radiobuttongroup_css.fieldSetStyle, className), ref, ...props, children: [jsxRuntime.jsx("legend", { className: radiobuttongroup_css.legendStyle, children: label }), children] });
|
|
11
|
-
}
|
|
12
|
-
exports.RadioButtonGroup = RadioButtonGroup;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
interface Props extends React.HTMLAttributes<HTMLFieldSetElement> {
|
|
2
|
-
label: string;
|
|
3
|
-
children: React.ReactNode;
|
|
4
|
-
className?: string;
|
|
5
|
-
ref?: React.Ref<HTMLFieldSetElement>;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Radio group to wrap RadioButton.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```jsx
|
|
12
|
-
* <RadioGroup
|
|
13
|
-
* label="What option?"
|
|
14
|
-
* >
|
|
15
|
-
* <RadioButton label="Option 1" name="option1" />
|
|
16
|
-
* <RadioButton label="Option 2" name="option2" />
|
|
17
|
-
* </RadioGroup>
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* @param children - RadioButtons.
|
|
21
|
-
* @param label - Label of group.
|
|
22
|
-
*/
|
|
23
|
-
/**
|
|
24
|
-
* Radio button groups gives a label for a group of radio buttons.
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
Documentation: [RadioButtonGroup](https://gnist.moller.no/developers/components/latest/?path=/docs/components-actions-selectioncontrols-radiobuttongroup--docs)
|
|
28
|
-
**/
|
|
29
|
-
export declare function RadioButtonGroup({ className, label, children, ref, ...props }: Props): import("react/jsx-runtime").JSX.Element;
|
|
30
|
-
export {};
|
|
31
|
-
//# sourceMappingURL=RadioButtonGroup.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RadioButtonGroup.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/selectionControls/RadioButtonGroup.tsx"],"names":[],"mappings":"AAGA,UAAU,KAAM,SAAQ,KAAK,CAAC,cAAc,CAAC,mBAAmB,CAAC;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;CACxC;AAED;;;;;;;;;;;;;;;GAeG;AAEH;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,EAC7B,SAAS,EACT,KAAK,EACL,QAAQ,EACR,GAAG,EACH,GAAG,KAAK,EACX,EAAE,KAAK,2CAWP"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
-
import classNames from "classnames";
|
|
4
|
-
import { legendStyle, fieldSetStyle } from "./radiobuttongroup.css.js";
|
|
5
|
-
function RadioButtonGroup({ className, label, children, ref, ...props }) {
|
|
6
|
-
return jsxs("fieldset", { className: classNames(fieldSetStyle, className), ref, ...props, children: [jsx("legend", { className: legendStyle, children: label }), children] });
|
|
7
|
-
}
|
|
8
|
-
export {
|
|
9
|
-
RadioButtonGroup
|
|
10
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"radiobuttongroup.css.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/selectionControls/radiobuttongroup.css.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,QAUxB,CAAC;AAEH,eAAO,MAAM,WAAW,QAEtB,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { atoms } from "@gnist/themes/atoms.css.js";
|
|
3
|
-
import { style } from "@vanilla-extract/css";
|
|
4
|
-
const fieldSetStyle = style([
|
|
5
|
-
{
|
|
6
|
-
border: "none"
|
|
7
|
-
},
|
|
8
|
-
atoms({
|
|
9
|
-
padding: "none",
|
|
10
|
-
display: "flex",
|
|
11
|
-
flexDirection: "column",
|
|
12
|
-
gap: "base"
|
|
13
|
-
})
|
|
14
|
-
]);
|
|
15
|
-
const legendStyle = atoms({
|
|
16
|
-
marginBottom: "base"
|
|
17
|
-
});
|
|
18
|
-
export {
|
|
19
|
-
fieldSetStyle,
|
|
20
|
-
legendStyle
|
|
21
|
-
};
|