@recursica/mui-adapter 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/mui-adapter.cjs +74 -1
- package/dist/mui-adapter.cjs.map +1 -1
- package/dist/mui-adapter.css +1 -1
- package/dist/mui-adapter.js +6652 -204
- package/dist/mui-adapter.js.map +1 -1
- package/dist/src/components/Accordion/Accordion.d.ts +63 -2
- package/dist/src/components/AssistiveElement/AssistiveElement.d.ts +9 -2
- package/dist/src/components/Autocomplete/Autocomplete.d.ts +16 -2
- package/dist/src/components/Avatar/Avatar.d.ts +14 -2
- package/dist/src/components/Badge/Badge.d.ts +13 -3
- package/dist/src/components/Breadcrumb/Breadcrumb.d.ts +10 -3
- package/dist/src/components/Button/Button.d.ts +1 -1
- package/dist/src/components/Card/Card.d.ts +40 -3
- package/dist/src/components/Checkbox/Checkbox.d.ts +15 -2
- package/dist/src/components/Checkbox/CheckboxGroup.d.ts +16 -0
- package/dist/src/components/Checkbox/index.d.ts +5 -1
- package/dist/src/components/Chip/Chip.d.ts +18 -2
- package/dist/src/components/Dropdown/Dropdown.d.ts +23 -3
- package/dist/src/components/FormControlLayout/FormControlLayout.d.ts +10 -2
- package/dist/src/components/FormControlWrapper/FormControlWrapper.d.ts +24 -2
- package/dist/src/components/HoverCard/HoverCard.d.ts +55 -3
- package/dist/src/components/Label/Label.d.ts +13 -2
- package/dist/src/components/Link/Link.d.ts +1 -1
- package/dist/src/components/Menu/Menu.d.ts +99 -3
- package/dist/src/components/Modal/Modal.d.ts +36 -2
- package/dist/src/components/NumberInput/NumberInput.d.ts +14 -2
- package/dist/src/components/Pagination/Pagination.d.ts +44 -2
- package/dist/src/components/Pagination/Pagination.icons.d.ts +8 -0
- package/dist/src/components/Panel/Panel.d.ts +65 -3
- package/dist/src/components/Radio/Radio.d.ts +13 -3
- package/dist/src/components/Radio/RadioGroup.d.ts +13 -0
- package/dist/src/components/ReadOnlyField/ReadOnlyBooleanField.d.ts +5 -0
- package/dist/src/components/ReadOnlyField/ReadOnlyField.d.ts +7 -2
- package/dist/src/components/ReadOnlyField/ReadOnlySwitchField.d.ts +5 -0
- package/dist/src/components/ReadOnlyField/ReadOnlyTextField.d.ts +8 -0
- package/dist/src/components/ReadOnlyField/WithReadOnlyWrapper.d.ts +28 -0
- package/dist/src/components/ReadOnlyField/index.d.ts +1 -0
- package/dist/src/components/SegmentedControl/SegmentedControl.d.ts +31 -3
- package/dist/src/components/Slider/Slider.d.ts +28 -2
- package/dist/src/components/Stepper/Stepper.d.ts +21 -2
- package/dist/src/components/Switch/Switch.d.ts +10 -3
- package/dist/src/components/Switch/SwitchGroup.d.ts +13 -0
- package/dist/src/components/Tabs/Tabs.d.ts +35 -3
- package/dist/src/components/Text/Text.d.ts +1 -1
- package/dist/src/components/TextArea/TextArea.d.ts +18 -2
- package/dist/src/components/TextField/TextField.d.ts +16 -2
- package/dist/src/components/Timeline/Timeline.d.ts +14 -2
- package/dist/src/components/Timeline/TimelineItem.d.ts +29 -0
- package/dist/src/components/Title/Title.d.ts +1 -1
- package/dist/src/components/Toast/Toast.d.ts +25 -2
- package/dist/src/components/Tooltip/Tooltip.d.ts +42 -3
- package/dist/src/components/Typography/Typography.d.ts +1 -1
- package/package.json +9 -2
- package/src/components/Accordion/Accordion.module.css +295 -56
- package/src/components/Accordion/Accordion.stories.tsx +149 -21
- package/src/components/Accordion/Accordion.tsx +264 -5
- package/src/components/AssistiveElement/AssistiveElement.module.css +111 -20
- package/src/components/AssistiveElement/AssistiveElement.stories.tsx +76 -19
- package/src/components/AssistiveElement/AssistiveElement.tsx +85 -5
- package/src/components/Autocomplete/Autocomplete.module.css +320 -42
- package/src/components/Autocomplete/Autocomplete.stories.tsx +180 -19
- package/src/components/Autocomplete/Autocomplete.tsx +199 -6
- package/src/components/Avatar/Avatar.module.css +343 -73
- package/src/components/Avatar/Avatar.stories.tsx +94 -22
- package/src/components/Avatar/Avatar.tsx +110 -6
- package/src/components/Badge/Badge.module.css +127 -29
- package/src/components/Badge/Badge.stories.tsx +65 -22
- package/src/components/Badge/Badge.tsx +70 -6
- package/src/components/Breadcrumb/Breadcrumb.module.css +25 -5
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +57 -22
- package/src/components/Breadcrumb/Breadcrumb.tsx +62 -6
- package/src/components/Button/Button.module.css +3 -3
- package/src/components/Card/Card.module.css +118 -38
- package/src/components/Card/Card.stories.tsx +117 -19
- package/src/components/Card/Card.tsx +179 -5
- package/src/components/Checkbox/Checkbox.module.css +232 -39
- package/src/components/Checkbox/Checkbox.stories.tsx +81 -19
- package/src/components/Checkbox/Checkbox.tsx +146 -5
- package/src/components/Checkbox/CheckboxGroup.tsx +117 -0
- package/src/components/Checkbox/index.ts +6 -1
- package/src/components/Chip/Chip.module.css +228 -43
- package/src/components/Chip/Chip.stories.tsx +101 -21
- package/src/components/Chip/Chip.tsx +138 -6
- package/src/components/Dropdown/Dropdown.module.css +291 -41
- package/src/components/Dropdown/Dropdown.stories.tsx +80 -21
- package/src/components/Dropdown/Dropdown.tsx +182 -6
- package/src/components/FormControlLayout/FormControlLayout.module.css +92 -0
- package/src/components/FormControlLayout/FormControlLayout.stories.tsx +74 -19
- package/src/components/FormControlLayout/FormControlLayout.tsx +58 -4
- package/src/components/FormControlWrapper/FormControlWrapper.module.css +96 -0
- package/src/components/FormControlWrapper/FormControlWrapper.stories.tsx +122 -19
- package/src/components/FormControlWrapper/FormControlWrapper.tsx +145 -6
- package/src/components/HoverCard/HoverCard.module.css +90 -22
- package/src/components/HoverCard/HoverCard.stories.tsx +158 -21
- package/src/components/HoverCard/HoverCard.tsx +150 -5
- package/src/components/Label/Label.module.css +136 -35
- package/src/components/Label/Label.stories.tsx +98 -17
- package/src/components/Label/Label.tsx +88 -5
- package/src/components/Menu/Menu.module.css +285 -51
- package/src/components/Menu/Menu.stories.tsx +307 -21
- package/src/components/Menu/Menu.tsx +318 -5
- package/src/components/Modal/Modal.module.css +171 -35
- package/src/components/Modal/Modal.stories.tsx +66 -22
- package/src/components/Modal/Modal.tsx +216 -4
- package/src/components/NumberInput/NumberInput.module.css +276 -42
- package/src/components/NumberInput/NumberInput.stories.tsx +83 -20
- package/src/components/NumberInput/NumberInput.tsx +148 -6
- package/src/components/Pagination/Pagination.icons.tsx +66 -0
- package/src/components/Pagination/Pagination.module.css +246 -20
- package/src/components/Pagination/Pagination.stories.tsx +42 -21
- package/src/components/Pagination/Pagination.tsx +193 -5
- package/src/components/Panel/Panel.module.css +206 -38
- package/src/components/Panel/Panel.stories.tsx +214 -22
- package/src/components/Panel/Panel.tsx +153 -5
- package/src/components/Radio/Radio.module.css +220 -37
- package/src/components/Radio/Radio.stories.tsx +77 -19
- package/src/components/Radio/Radio.tsx +178 -5
- package/src/components/Radio/RadioGroup.tsx +111 -0
- package/src/components/ReadOnlyField/ReadOnlyBooleanField.tsx +21 -0
- package/src/components/ReadOnlyField/ReadOnlyField.module.css +53 -15
- package/src/components/ReadOnlyField/ReadOnlyField.stories.tsx +175 -16
- package/src/components/ReadOnlyField/ReadOnlyField.tsx +109 -5
- package/src/components/ReadOnlyField/ReadOnlySwitchField.tsx +21 -0
- package/src/components/ReadOnlyField/ReadOnlyTextField.tsx +48 -0
- package/src/components/ReadOnlyField/WithReadOnlyWrapper.tsx +93 -0
- package/src/components/ReadOnlyField/index.ts +1 -0
- package/src/components/SegmentedControl/SegmentedControl.module.css +203 -47
- package/src/components/SegmentedControl/SegmentedControl.stories.tsx +102 -20
- package/src/components/SegmentedControl/SegmentedControl.tsx +110 -6
- package/src/components/Slider/Slider.module.css +542 -86
- package/src/components/Slider/Slider.stories.tsx +157 -19
- package/src/components/Slider/Slider.tsx +282 -5
- package/src/components/Stepper/Stepper.module.css +410 -71
- package/src/components/Stepper/Stepper.stories.tsx +132 -19
- package/src/components/Stepper/Stepper.tsx +145 -6
- package/src/components/Switch/Switch.module.css +238 -39
- package/src/components/Switch/Switch.stories.tsx +98 -19
- package/src/components/Switch/Switch.tsx +153 -6
- package/src/components/Switch/SwitchGroup.tsx +111 -0
- package/src/components/Tabs/Tabs.module.css +422 -79
- package/src/components/Tabs/Tabs.stories.tsx +138 -19
- package/src/components/Tabs/Tabs.tsx +103 -6
- package/src/components/TextArea/TextArea.module.css +155 -32
- package/src/components/TextArea/TextArea.stories.tsx +80 -21
- package/src/components/TextArea/TextArea.tsx +156 -6
- package/src/components/TextField/TextField.module.css +261 -42
- package/src/components/TextField/TextField.stories.tsx +168 -15
- package/src/components/TextField/TextField.tsx +171 -6
- package/src/components/Timeline/Timeline.module.css +365 -76
- package/src/components/Timeline/Timeline.stories.tsx +114 -21
- package/src/components/Timeline/Timeline.tsx +80 -5
- package/src/components/Timeline/TimelineItem.tsx +101 -0
- package/src/components/Toast/Toast.module.css +166 -28
- package/src/components/Toast/Toast.stories.tsx +54 -22
- package/src/components/Toast/Toast.tsx +90 -5
- package/src/components/Tooltip/Tooltip.module.css +89 -24
- package/src/components/Tooltip/Tooltip.stories.tsx +152 -22
- package/src/components/Tooltip/Tooltip.tsx +114 -5
|
@@ -1,35 +1,93 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
2
|
import { Radio } from "./Radio";
|
|
3
|
-
import { ComingSoon } from "@recursica/storybook-template";
|
|
4
3
|
|
|
5
4
|
const meta: Meta<typeof Radio> = {
|
|
6
|
-
title: "UI-Kit
|
|
5
|
+
title: "UI-Kit/Radio",
|
|
7
6
|
component: Radio,
|
|
8
7
|
tags: ["autodocs"],
|
|
9
8
|
parameters: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
docs: {
|
|
10
|
+
description: {
|
|
11
|
+
component: `
|
|
12
|
+
The \`Radio\` component represents a fundamental standalone boolean selection node mapping to the native HTML \`<input type="radio">\`.
|
|
13
|
+
|
|
14
|
+
> [!WARNING]
|
|
15
|
+
> This component represents the isolated primitive structure. If you need macro form configurations, standard vertical alignments, side-by-side array wrappers, or integrated assistive text and error borders natively, you MUST use the \`<Radio.Group>\` orchestrator instead!
|
|
16
|
+
`,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
argTypes: {
|
|
21
|
+
disabled: {
|
|
22
|
+
control: "boolean",
|
|
23
|
+
},
|
|
24
|
+
checked: {
|
|
25
|
+
control: "boolean",
|
|
26
|
+
},
|
|
27
|
+
readOnly: {
|
|
28
|
+
control: "boolean",
|
|
29
|
+
},
|
|
30
|
+
error: {
|
|
31
|
+
control: "boolean",
|
|
26
32
|
},
|
|
33
|
+
defaultChecked: {
|
|
34
|
+
control: "boolean",
|
|
35
|
+
},
|
|
36
|
+
controlMaxWidth: { table: { disable: true } },
|
|
37
|
+
controlMinWidth: { table: { disable: true } },
|
|
27
38
|
},
|
|
28
39
|
};
|
|
29
40
|
|
|
30
41
|
export default meta;
|
|
42
|
+
|
|
31
43
|
type Story = StoryObj<typeof Radio>;
|
|
32
44
|
|
|
33
45
|
export const Default: Story = {
|
|
34
|
-
|
|
46
|
+
args: {
|
|
47
|
+
label: "Standard Radio Primitive",
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const SideBySideLayout: Story = {
|
|
52
|
+
args: {
|
|
53
|
+
label: "Opt-in form alignment",
|
|
54
|
+
formLayout: "side-by-side",
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const CheckedState: Story = {
|
|
59
|
+
args: {
|
|
60
|
+
...Default.args,
|
|
61
|
+
defaultChecked: true,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const DisabledUnchecked: Story = {
|
|
66
|
+
args: {
|
|
67
|
+
...Default.args,
|
|
68
|
+
disabled: true,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const DisabledChecked: Story = {
|
|
73
|
+
args: {
|
|
74
|
+
...Default.args,
|
|
75
|
+
disabled: true,
|
|
76
|
+
defaultChecked: true,
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const ReadOnly: Story = {
|
|
81
|
+
args: {},
|
|
82
|
+
render: () => (
|
|
83
|
+
<div
|
|
84
|
+
style={{
|
|
85
|
+
display: "flex",
|
|
86
|
+
flexDirection: "column",
|
|
87
|
+
gap: "24px",
|
|
88
|
+
}}
|
|
89
|
+
>
|
|
90
|
+
<Radio label="Account Type" defaultChecked readOnly />
|
|
91
|
+
</div>
|
|
92
|
+
),
|
|
35
93
|
};
|
|
@@ -1,8 +1,181 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Radio as MuiRadio,
|
|
4
|
+
type RadioProps as MuiRadioProps,
|
|
5
|
+
FormControlLabel,
|
|
6
|
+
} from "@mui/material";
|
|
7
|
+
import { type ReadOnlyControlProps } from "@recursica/adapter-common";
|
|
8
|
+
import { RadioGroup } from "./RadioGroup";
|
|
9
|
+
import {
|
|
10
|
+
filterStylingProps,
|
|
11
|
+
type RecursicaOverStyled,
|
|
12
|
+
} from "../../utils/filterStylingProps";
|
|
13
|
+
import { type RequireAccessibleLabel } from "../../utils/RequireAccessibleLabel";
|
|
14
|
+
import {
|
|
15
|
+
FormControlLayout,
|
|
16
|
+
type FormControlLayoutProps,
|
|
17
|
+
} from "../FormControlLayout/FormControlLayout";
|
|
3
18
|
|
|
4
|
-
|
|
19
|
+
import styles from "./Radio.module.css";
|
|
5
20
|
|
|
6
|
-
|
|
7
|
-
|
|
21
|
+
const RadioIcon: React.FC<{
|
|
22
|
+
className?: string;
|
|
23
|
+
style?: React.CSSProperties;
|
|
24
|
+
}> = ({ className, style }) => (
|
|
25
|
+
<svg
|
|
26
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
27
|
+
viewBox="0 0 16 16"
|
|
28
|
+
fill="currentColor"
|
|
29
|
+
className={className}
|
|
30
|
+
style={style}
|
|
31
|
+
>
|
|
32
|
+
<circle cx="8" cy="8" r="5" />
|
|
33
|
+
</svg>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
export type RecursicaRadioProps = RequireAccessibleLabel<
|
|
37
|
+
Omit<MuiRadioProps, "size" | "color"> &
|
|
38
|
+
ReadOnlyControlProps &
|
|
39
|
+
Pick<
|
|
40
|
+
FormControlLayoutProps,
|
|
41
|
+
"formLayout" | "labelSize" | "controlMaxWidth" | "controlMinWidth"
|
|
42
|
+
>
|
|
43
|
+
>;
|
|
44
|
+
|
|
45
|
+
export type RadioProps = RecursicaOverStyled<RecursicaRadioProps>;
|
|
46
|
+
|
|
47
|
+
type RadioComponent = React.ForwardRefExoticComponent<
|
|
48
|
+
RadioProps & React.RefAttributes<HTMLInputElement>
|
|
49
|
+
> & {
|
|
50
|
+
Group: typeof RadioGroup;
|
|
8
51
|
};
|
|
52
|
+
|
|
53
|
+
export const Radio = forwardRef<HTMLInputElement, RadioProps>(
|
|
54
|
+
function Radio(props, ref) {
|
|
55
|
+
const {
|
|
56
|
+
overStyled = false,
|
|
57
|
+
readOnly,
|
|
58
|
+
readOnlyComponent,
|
|
59
|
+
disabled,
|
|
60
|
+
formLayout,
|
|
61
|
+
labelSize,
|
|
62
|
+
controlMaxWidth,
|
|
63
|
+
controlMinWidth,
|
|
64
|
+
...rest
|
|
65
|
+
} = props;
|
|
66
|
+
const sanitizedProps = filterStylingProps(rest, overStyled);
|
|
67
|
+
const restRecord = sanitizedProps as Record<string, unknown>;
|
|
68
|
+
|
|
69
|
+
// Actively delete dimension bindings that bypass the abstraction
|
|
70
|
+
delete restRecord["size"];
|
|
71
|
+
delete restRecord["color"];
|
|
72
|
+
|
|
73
|
+
const mergedClassNames: Partial<Record<string, string>> = {
|
|
74
|
+
root: styles.root,
|
|
75
|
+
body: styles.body,
|
|
76
|
+
inner: styles.inner,
|
|
77
|
+
radio: styles.radio,
|
|
78
|
+
icon: styles.icon,
|
|
79
|
+
labelWrapper: styles.labelWrapper,
|
|
80
|
+
label: styles.label,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const classNamesProp = restRecord.classNames;
|
|
84
|
+
if (
|
|
85
|
+
classNamesProp &&
|
|
86
|
+
typeof classNamesProp === "object" &&
|
|
87
|
+
!Array.isArray(classNamesProp)
|
|
88
|
+
) {
|
|
89
|
+
const o = classNamesProp as Partial<Record<string, string>>;
|
|
90
|
+
mergedClassNames.root = o.root ? `${styles.root} ${o.root}` : styles.root;
|
|
91
|
+
mergedClassNames.body = o.body ? `${styles.body} ${o.body}` : styles.body;
|
|
92
|
+
mergedClassNames.inner = o.inner
|
|
93
|
+
? `${styles.inner} ${o.inner}`
|
|
94
|
+
: styles.inner;
|
|
95
|
+
mergedClassNames.radio = o.radio
|
|
96
|
+
? `${styles.radio} ${o.radio}`
|
|
97
|
+
: styles.radio;
|
|
98
|
+
mergedClassNames.icon = o.icon ? `${styles.icon} ${o.icon}` : styles.icon;
|
|
99
|
+
mergedClassNames.labelWrapper = o.labelWrapper
|
|
100
|
+
? `${styles.labelWrapper} ${o.labelWrapper}`
|
|
101
|
+
: styles.labelWrapper;
|
|
102
|
+
mergedClassNames.label = o.label
|
|
103
|
+
? `${styles.label} ${o.label}`
|
|
104
|
+
: styles.label;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const classNameProp = restRecord.className as string | undefined;
|
|
108
|
+
const finalClass = classNameProp
|
|
109
|
+
? `${styles.root} ${classNameProp}`
|
|
110
|
+
: styles.root;
|
|
111
|
+
|
|
112
|
+
if (readOnly && !!readOnlyComponent) {
|
|
113
|
+
const isChecked = !!(restRecord.checked ?? restRecord.defaultChecked);
|
|
114
|
+
const ReadOnlyComp = readOnlyComponent;
|
|
115
|
+
const roNode = (
|
|
116
|
+
<ReadOnlyComp
|
|
117
|
+
{...props}
|
|
118
|
+
checked={isChecked}
|
|
119
|
+
label={restRecord.label as React.ReactNode}
|
|
120
|
+
/>
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
if (formLayout) {
|
|
124
|
+
return (
|
|
125
|
+
<FormControlLayout
|
|
126
|
+
formLayout={formLayout}
|
|
127
|
+
labelSize={labelSize}
|
|
128
|
+
controlMaxWidth={controlMaxWidth}
|
|
129
|
+
controlMinWidth={controlMinWidth}
|
|
130
|
+
>
|
|
131
|
+
{roNode}
|
|
132
|
+
</FormControlLayout>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return <>{roNode}</>;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// We omit Mui's sizing/coloring so we rely strictly on variables from Radio.module.css
|
|
140
|
+
const radioNode = (
|
|
141
|
+
<MuiRadio
|
|
142
|
+
ref={ref}
|
|
143
|
+
icon={<RadioIcon />}
|
|
144
|
+
checkedIcon={<RadioIcon className={styles.checked} />}
|
|
145
|
+
className={finalClass}
|
|
146
|
+
classes={mergedClassNames}
|
|
147
|
+
disabled={readOnly || disabled}
|
|
148
|
+
{...(sanitizedProps as unknown as MuiRadioProps)}
|
|
149
|
+
/>
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
const finalNode = restRecord.label ? (
|
|
153
|
+
<FormControlLabel
|
|
154
|
+
control={radioNode}
|
|
155
|
+
label={restRecord.label as React.ReactNode}
|
|
156
|
+
className={styles.labelWrapper}
|
|
157
|
+
classes={{ label: styles.label }}
|
|
158
|
+
/>
|
|
159
|
+
) : (
|
|
160
|
+
radioNode
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
if (formLayout) {
|
|
164
|
+
return (
|
|
165
|
+
<FormControlLayout
|
|
166
|
+
formLayout={formLayout}
|
|
167
|
+
labelSize={labelSize}
|
|
168
|
+
controlMaxWidth={controlMaxWidth}
|
|
169
|
+
controlMinWidth={controlMinWidth}
|
|
170
|
+
>
|
|
171
|
+
{finalNode}
|
|
172
|
+
</FormControlLayout>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return finalNode;
|
|
177
|
+
},
|
|
178
|
+
) as RadioComponent;
|
|
179
|
+
|
|
180
|
+
Radio.displayName = "Radio";
|
|
181
|
+
Radio.Group = RadioGroup;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import {
|
|
4
|
+
Radio as MuiRadio,
|
|
5
|
+
RadioGroup as MuiRadioGroup,
|
|
6
|
+
type RadioGroupProps as MuiRadioGroupProps,
|
|
7
|
+
} from "@mui/material";
|
|
8
|
+
import { type ReadOnlyControlProps } from "@recursica/adapter-common";
|
|
9
|
+
import {
|
|
10
|
+
filterStylingProps,
|
|
11
|
+
type RecursicaOverStyled,
|
|
12
|
+
} from "../../utils/filterStylingProps";
|
|
13
|
+
import { type RecursicaFormControlWrapperProps } from "../FormControlWrapper/FormControlWrapper";
|
|
14
|
+
import { WithReadOnlyWrapper } from "../ReadOnlyField/WithReadOnlyWrapper";
|
|
15
|
+
import styles from "./Radio.module.css";
|
|
16
|
+
|
|
17
|
+
export interface RecursicaRadioGroupProps
|
|
18
|
+
extends Omit<MuiRadioGroupProps, "size" | "labelProps">,
|
|
19
|
+
Omit<
|
|
20
|
+
RecursicaFormControlWrapperProps,
|
|
21
|
+
"controlMaxWidth" | "controlMinWidth"
|
|
22
|
+
>,
|
|
23
|
+
ReadOnlyControlProps {}
|
|
24
|
+
|
|
25
|
+
export type RadioGroupProps = RecursicaOverStyled<RecursicaRadioGroupProps>;
|
|
26
|
+
|
|
27
|
+
export const RadioGroup = forwardRef<HTMLDivElement, RadioGroupProps>(
|
|
28
|
+
function RadioGroup(props, ref) {
|
|
29
|
+
const {
|
|
30
|
+
overStyled = false,
|
|
31
|
+
formLayout = "stacked",
|
|
32
|
+
|
|
33
|
+
// Label Wrappers
|
|
34
|
+
labelSize,
|
|
35
|
+
labelAlignment,
|
|
36
|
+
labelOptionalText,
|
|
37
|
+
labelWithEditIcon,
|
|
38
|
+
onLabelEditClick,
|
|
39
|
+
|
|
40
|
+
// Base Mui Extracted Attributes
|
|
41
|
+
label,
|
|
42
|
+
description,
|
|
43
|
+
assistiveText,
|
|
44
|
+
assistiveWithIcon,
|
|
45
|
+
error,
|
|
46
|
+
required,
|
|
47
|
+
withAsterisk,
|
|
48
|
+
id,
|
|
49
|
+
className,
|
|
50
|
+
style,
|
|
51
|
+
children,
|
|
52
|
+
readOnly,
|
|
53
|
+
readOnlyComponent,
|
|
54
|
+
emptyValueComponent,
|
|
55
|
+
value,
|
|
56
|
+
defaultValue,
|
|
57
|
+
...rest
|
|
58
|
+
} = props;
|
|
59
|
+
const sanitizedProps = filterStylingProps(rest, overStyled);
|
|
60
|
+
const restRecord = sanitizedProps as Record<string, unknown>;
|
|
61
|
+
|
|
62
|
+
// Delete prohibited sizing hooks from bypassing the variables
|
|
63
|
+
delete restRecord["size"];
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<WithReadOnlyWrapper
|
|
67
|
+
className={className}
|
|
68
|
+
style={style as React.CSSProperties}
|
|
69
|
+
controlMaxWidth="var(--recursica_ui-kit_components_radio-button-item_properties_max-width)"
|
|
70
|
+
controlMinWidth={undefined}
|
|
71
|
+
overStyled={overStyled as true}
|
|
72
|
+
labelElement="div" // Strictly override. ARIA grouping prohibits interactive radios nested natively inside <label>.
|
|
73
|
+
formLayout={formLayout}
|
|
74
|
+
labelSize={labelSize}
|
|
75
|
+
labelAlignment={labelAlignment}
|
|
76
|
+
labelOptionalText={labelOptionalText}
|
|
77
|
+
labelWithEditIcon={labelWithEditIcon}
|
|
78
|
+
onLabelEditClick={onLabelEditClick}
|
|
79
|
+
label={label}
|
|
80
|
+
description={description}
|
|
81
|
+
assistiveText={assistiveText}
|
|
82
|
+
assistiveWithIcon={assistiveWithIcon}
|
|
83
|
+
error={error}
|
|
84
|
+
required={required}
|
|
85
|
+
withAsterisk={withAsterisk}
|
|
86
|
+
id={id}
|
|
87
|
+
readOnly={readOnly && !!readOnlyComponent}
|
|
88
|
+
readOnlyComponent={readOnlyComponent}
|
|
89
|
+
emptyValueComponent={emptyValueComponent}
|
|
90
|
+
readOnlyType="text"
|
|
91
|
+
readOnlyValue={value !== undefined ? value : defaultValue}
|
|
92
|
+
readOnlyNativeProps={props}
|
|
93
|
+
activeComponent={
|
|
94
|
+
<MuiRadioGroup
|
|
95
|
+
ref={ref}
|
|
96
|
+
/* Natively bind local disabled lock dynamically */
|
|
97
|
+
{...(sanitizedProps as unknown as MuiRadioGroupProps)}
|
|
98
|
+
value={value}
|
|
99
|
+
defaultValue={defaultValue}
|
|
100
|
+
>
|
|
101
|
+
<div className={styles.groupRoot} data-layout={formLayout}>
|
|
102
|
+
{children}
|
|
103
|
+
</div>
|
|
104
|
+
</MuiRadioGroup>
|
|
105
|
+
}
|
|
106
|
+
/>
|
|
107
|
+
);
|
|
108
|
+
},
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
RadioGroup.displayName = "RadioGroup";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Box } from "@mui/material";
|
|
3
|
+
import styles from "./ReadOnlyField.module.css";
|
|
4
|
+
|
|
5
|
+
export const ReadOnlyBooleanField: React.FC<{
|
|
6
|
+
checked: boolean;
|
|
7
|
+
label?: React.ReactNode;
|
|
8
|
+
}> = ({ checked, label }) => {
|
|
9
|
+
return (
|
|
10
|
+
<Box
|
|
11
|
+
component="span"
|
|
12
|
+
className={styles.textField}
|
|
13
|
+
style={{ display: "inline-flex", gap: "8px", alignItems: "baseline" }}
|
|
14
|
+
>
|
|
15
|
+
{label && <span style={{ fontWeight: 500 }}>{label}:</span>}
|
|
16
|
+
<span>{checked ? "True" : "False"}</span>
|
|
17
|
+
</Box>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
ReadOnlyBooleanField.displayName = "ReadOnlyBooleanField";
|
|
@@ -1,16 +1,54 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/* LAYOUT SPACING OVERRIDES:
|
|
2
|
+
- Sets the --form-control-margin-bottom spacing hook to map component-specific layout tokens. */
|
|
3
|
+
.root {
|
|
4
|
+
width: 100%;
|
|
5
|
+
--form-control-margin-bottom: var(
|
|
6
|
+
--recursica_ui-kit_components_read-only-field_variants_layouts_stacked_properties_top-bottom-margin,
|
|
7
|
+
0px
|
|
8
|
+
);
|
|
9
|
+
}
|
|
4
10
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
.root[data-form-layout="side-by-side"] {
|
|
12
|
+
--form-control-margin-bottom: var(
|
|
13
|
+
--recursica_ui-kit_components_read-only-field_variants_layouts_side-by-side_properties_top-bottom-margin,
|
|
14
|
+
0px
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.text {
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
|
|
22
|
+
font-family: var(
|
|
23
|
+
--recursica_ui-kit_components_read-only-field_properties_text_font-family
|
|
24
|
+
);
|
|
25
|
+
font-size: var(
|
|
26
|
+
--recursica_ui-kit_components_read-only-field_properties_text_font-size
|
|
27
|
+
);
|
|
28
|
+
font-style: var(
|
|
29
|
+
--recursica_ui-kit_components_read-only-field_properties_text_font-style
|
|
30
|
+
);
|
|
31
|
+
font-weight: var(
|
|
32
|
+
--recursica_ui-kit_components_read-only-field_properties_text_font-weight
|
|
33
|
+
);
|
|
34
|
+
letter-spacing: var(
|
|
35
|
+
--recursica_ui-kit_components_read-only-field_properties_text_letter-spacing
|
|
36
|
+
);
|
|
37
|
+
line-height: var(
|
|
38
|
+
--recursica_ui-kit_components_read-only-field_properties_text_line-height
|
|
39
|
+
);
|
|
40
|
+
text-decoration: var(
|
|
41
|
+
--recursica_ui-kit_components_read-only-field_properties_text_text-decoration
|
|
42
|
+
);
|
|
43
|
+
text-transform: var(
|
|
44
|
+
--recursica_ui-kit_components_read-only-field_properties_text_text-transform
|
|
45
|
+
);
|
|
46
|
+
color: var(
|
|
47
|
+
--recursica_ui-kit_components_read-only-field_properties_colors_text
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
min-height: var(
|
|
51
|
+
--recursica_ui-kit_components_read-only-field_properties_min-height,
|
|
52
|
+
40px
|
|
53
|
+
);
|
|
54
|
+
}
|