@recursica/mui-adapter 0.4.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 +15 -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 +6651 -201
- 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 +17 -0
- package/dist/src/components/Autocomplete/index.d.ts +1 -0
- 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/dist/src/components/index.d.ts +1 -0
- package/package.json +12 -2
- package/src/GlobalExemptions.modules.css +13 -0
- package/src/components/Accordion/Accordion.module.css +295 -0
- package/src/components/Accordion/Accordion.stories.tsx +149 -21
- package/src/components/Accordion/Accordion.tsx +264 -4
- package/src/components/AssistiveElement/AssistiveElement.module.css +111 -0
- package/src/components/AssistiveElement/AssistiveElement.stories.tsx +76 -19
- package/src/components/AssistiveElement/AssistiveElement.tsx +85 -4
- package/src/components/Autocomplete/Autocomplete.module.css +325 -0
- package/src/components/Autocomplete/Autocomplete.stories.tsx +196 -0
- package/src/components/Autocomplete/Autocomplete.tsx +201 -0
- package/src/components/Autocomplete/index.ts +1 -0
- package/src/components/Avatar/Avatar.module.css +344 -0
- package/src/components/Avatar/Avatar.stories.tsx +94 -22
- package/src/components/Avatar/Avatar.tsx +110 -5
- package/src/components/Badge/Badge.module.css +127 -0
- package/src/components/Badge/Badge.stories.tsx +65 -22
- package/src/components/Badge/Badge.tsx +70 -5
- package/src/components/Breadcrumb/Breadcrumb.module.css +26 -0
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +57 -22
- package/src/components/Breadcrumb/Breadcrumb.tsx +62 -5
- package/src/components/Button/Button.module.css +113 -20
- package/src/components/Button/Button.stories.tsx +3 -0
- package/src/components/Button/Button.tsx +10 -3
- package/src/components/Card/Card.module.css +118 -0
- package/src/components/Card/Card.stories.tsx +117 -19
- package/src/components/Card/Card.tsx +179 -4
- package/src/components/Checkbox/Checkbox.module.css +232 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +81 -19
- package/src/components/Checkbox/Checkbox.tsx +146 -4
- package/src/components/Checkbox/CheckboxGroup.tsx +117 -0
- package/src/components/Checkbox/index.ts +6 -1
- package/src/components/Chip/Chip.module.css +236 -0
- package/src/components/Chip/Chip.stories.tsx +101 -21
- package/src/components/Chip/Chip.tsx +138 -5
- package/src/components/DatePicker/DatePicker.module.css +42 -0
- package/src/components/DatePicker/DatePicker.tsx +1 -0
- package/src/components/Dropdown/Dropdown.module.css +296 -0
- package/src/components/Dropdown/Dropdown.stories.tsx +80 -21
- package/src/components/Dropdown/Dropdown.tsx +182 -5
- package/src/components/FileInput/FileInput.module.css +47 -0
- package/src/components/FileInput/FileInput.tsx +1 -0
- package/src/components/FileUpload/FileUpload.module.css +40 -0
- package/src/components/FileUpload/FileUpload.tsx +1 -0
- 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 +91 -0
- package/src/components/HoverCard/HoverCard.stories.tsx +158 -21
- package/src/components/HoverCard/HoverCard.tsx +150 -4
- package/src/components/Label/Label.module.css +136 -0
- package/src/components/Label/Label.stories.tsx +98 -17
- package/src/components/Label/Label.tsx +88 -4
- package/src/components/Link/Link.module.css +8 -0
- package/src/components/Menu/Menu.module.css +287 -0
- package/src/components/Menu/Menu.stories.tsx +307 -21
- package/src/components/Menu/Menu.tsx +318 -4
- package/src/components/Modal/Modal.module.css +172 -0
- package/src/components/Modal/Modal.stories.tsx +66 -22
- package/src/components/Modal/Modal.tsx +216 -3
- package/src/components/NumberInput/NumberInput.module.css +281 -0
- package/src/components/NumberInput/NumberInput.stories.tsx +83 -20
- package/src/components/NumberInput/NumberInput.tsx +148 -5
- package/src/components/Pagination/Pagination.icons.tsx +66 -0
- package/src/components/Pagination/Pagination.module.css +307 -0
- package/src/components/Pagination/Pagination.stories.tsx +42 -21
- package/src/components/Pagination/Pagination.tsx +193 -4
- package/src/components/Panel/Panel.module.css +206 -0
- package/src/components/Panel/Panel.stories.tsx +214 -22
- package/src/components/Panel/Panel.tsx +153 -4
- package/src/components/Radio/Radio.module.css +220 -0
- package/src/components/Radio/Radio.stories.tsx +77 -19
- package/src/components/Radio/Radio.tsx +178 -4
- package/src/components/Radio/RadioGroup.tsx +111 -0
- package/src/components/ReadOnlyField/ReadOnlyBooleanField.tsx +21 -0
- package/src/components/ReadOnlyField/ReadOnlyField.module.css +54 -0
- package/src/components/ReadOnlyField/ReadOnlyField.stories.tsx +175 -16
- package/src/components/ReadOnlyField/ReadOnlyField.tsx +109 -4
- 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 -0
- package/src/components/SegmentedControl/SegmentedControl.stories.tsx +102 -20
- package/src/components/SegmentedControl/SegmentedControl.tsx +110 -5
- package/src/components/Slider/Slider.module.css +542 -0
- package/src/components/Slider/Slider.stories.tsx +157 -19
- package/src/components/Slider/Slider.tsx +282 -4
- package/src/components/Stepper/Stepper.module.css +410 -0
- package/src/components/Stepper/Stepper.stories.tsx +132 -19
- package/src/components/Stepper/Stepper.tsx +145 -5
- package/src/components/Switch/Switch.module.css +238 -0
- package/src/components/Switch/Switch.stories.tsx +98 -19
- package/src/components/Switch/Switch.tsx +153 -5
- package/src/components/Switch/SwitchGroup.tsx +111 -0
- package/src/components/Tabs/Tabs.module.css +422 -0
- package/src/components/Tabs/Tabs.stories.tsx +138 -19
- package/src/components/Tabs/Tabs.tsx +103 -5
- package/src/components/TextArea/TextArea.module.css +160 -0
- package/src/components/TextArea/TextArea.stories.tsx +80 -21
- package/src/components/TextArea/TextArea.tsx +156 -5
- package/src/components/TextField/TextField.module.css +266 -0
- package/src/components/TextField/TextField.stories.tsx +168 -15
- package/src/components/TextField/TextField.tsx +171 -5
- package/src/components/TimePicker/TimePicker.module.css +41 -0
- package/src/components/TimePicker/TimePicker.tsx +1 -0
- package/src/components/Timeline/Timeline.module.css +367 -0
- package/src/components/Timeline/Timeline.stories.tsx +114 -21
- package/src/components/Timeline/Timeline.tsx +80 -4
- package/src/components/Timeline/TimelineItem.tsx +101 -0
- package/src/components/Toast/Toast.module.css +170 -0
- package/src/components/Toast/Toast.stories.tsx +54 -22
- package/src/components/Toast/Toast.tsx +90 -4
- package/src/components/Tooltip/Tooltip.module.css +90 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +152 -22
- package/src/components/Tooltip/Tooltip.tsx +114 -4
- package/src/components/TransferList/TransferList.module.css +38 -0
- package/src/components/TransferList/TransferList.tsx +1 -0
- package/src/components/index.ts +1 -0
|
@@ -1,35 +1,117 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
2
|
import { SegmentedControl } from "./SegmentedControl";
|
|
3
|
-
import { ComingSoon } from "@recursica/storybook-template";
|
|
4
3
|
|
|
5
4
|
const meta: Meta<typeof SegmentedControl> = {
|
|
6
|
-
title: "UI-Kit
|
|
5
|
+
title: "UI-Kit/SegmentedControl",
|
|
7
6
|
component: SegmentedControl,
|
|
8
7
|
tags: ["autodocs"],
|
|
9
8
|
parameters: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"component",
|
|
16
|
-
"variant",
|
|
17
|
-
"size",
|
|
18
|
-
"icon",
|
|
19
|
-
"disabled",
|
|
20
|
-
"href",
|
|
21
|
-
"onClick",
|
|
22
|
-
"onChange",
|
|
23
|
-
"value",
|
|
24
|
-
"checked",
|
|
25
|
-
],
|
|
9
|
+
docs: {
|
|
10
|
+
description: {
|
|
11
|
+
component:
|
|
12
|
+
"SegmentedControl provides a linear set of two or more segments, each of which functions as a mutually exclusive button.",
|
|
13
|
+
},
|
|
26
14
|
},
|
|
27
15
|
},
|
|
28
|
-
|
|
16
|
+
argTypes: {
|
|
17
|
+
orientation: {
|
|
18
|
+
control: "radio",
|
|
19
|
+
options: ["horizontal", "vertical"],
|
|
20
|
+
},
|
|
21
|
+
fullWidth: {
|
|
22
|
+
control: "boolean",
|
|
23
|
+
},
|
|
24
|
+
disabled: { table: { disable: true } },
|
|
25
|
+
data: { table: { disable: true } },
|
|
26
|
+
defaultChecked: { table: { disable: true } },
|
|
27
|
+
},
|
|
28
|
+
} satisfies Meta<typeof SegmentedControl>;
|
|
29
29
|
|
|
30
30
|
export default meta;
|
|
31
31
|
type Story = StoryObj<typeof SegmentedControl>;
|
|
32
32
|
|
|
33
33
|
export const Default: Story = {
|
|
34
|
-
|
|
34
|
+
args: {
|
|
35
|
+
data: ["React", "Angular", "Vue", "Svelte"],
|
|
36
|
+
orientation: "horizontal",
|
|
37
|
+
fullWidth: false,
|
|
38
|
+
},
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
40
|
+
render: ({ withLayer, layer, ...args }: any) => {
|
|
41
|
+
return <SegmentedControl {...args} />;
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const FullWidth: Story = {
|
|
46
|
+
args: {
|
|
47
|
+
data: ["Daily", "Weekly", "Monthly"],
|
|
48
|
+
fullWidth: true,
|
|
49
|
+
},
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
51
|
+
render: ({ withLayer, layer, ...args }: any) => {
|
|
52
|
+
return <SegmentedControl {...args} />;
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const Vertical: Story = {
|
|
57
|
+
args: {
|
|
58
|
+
data: ["Option 1", "Option 2", "Option 3"],
|
|
59
|
+
orientation: "vertical",
|
|
60
|
+
},
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
62
|
+
render: ({ withLayer, layer, ...args }: any) => {
|
|
63
|
+
return <SegmentedControl {...args} />;
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const CheckIcon = () => (
|
|
68
|
+
<svg
|
|
69
|
+
viewBox="0 0 24 24"
|
|
70
|
+
fill="none"
|
|
71
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
72
|
+
stroke="currentColor"
|
|
73
|
+
strokeWidth="2"
|
|
74
|
+
strokeLinecap="round"
|
|
75
|
+
strokeLinejoin="round"
|
|
76
|
+
>
|
|
77
|
+
<polyline points="20 6 9 17 4 12" />
|
|
78
|
+
</svg>
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
export const WithIcons: Story = {
|
|
82
|
+
args: {
|
|
83
|
+
data: [
|
|
84
|
+
{
|
|
85
|
+
value: "daily",
|
|
86
|
+
label: (
|
|
87
|
+
<>
|
|
88
|
+
<CheckIcon />
|
|
89
|
+
<span>Daily</span>
|
|
90
|
+
</>
|
|
91
|
+
),
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
value: "weekly",
|
|
95
|
+
label: (
|
|
96
|
+
<>
|
|
97
|
+
<CheckIcon />
|
|
98
|
+
<span>Weekly</span>
|
|
99
|
+
</>
|
|
100
|
+
),
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
value: "monthly",
|
|
104
|
+
label: (
|
|
105
|
+
<>
|
|
106
|
+
<CheckIcon />
|
|
107
|
+
<span>Monthly</span>
|
|
108
|
+
</>
|
|
109
|
+
),
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
114
|
+
render: ({ withLayer, layer, ...args }: any) => {
|
|
115
|
+
return <SegmentedControl {...args} />;
|
|
116
|
+
},
|
|
35
117
|
};
|
|
@@ -1,7 +1,112 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
ToggleButtonGroup as MuiSegmentedControl,
|
|
4
|
+
type ToggleButtonGroupProps as MuiSegmentedControlProps,
|
|
5
|
+
} from "@mui/material";
|
|
6
|
+
import {
|
|
7
|
+
filterStylingProps,
|
|
8
|
+
type RecursicaOverStyled,
|
|
9
|
+
} from "../../utils/filterStylingProps";
|
|
10
|
+
import styles from "./SegmentedControl.module.css";
|
|
2
11
|
|
|
3
|
-
export
|
|
12
|
+
export interface RecursicaSegmentedControlProps {
|
|
13
|
+
/** The orientation of the control */
|
|
14
|
+
orientation?: "horizontal" | "vertical";
|
|
15
|
+
/** If true, the control will take up the full width of its container */
|
|
16
|
+
fullWidth?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* SegmentedControl should NOT be allowed to be disabled by design.
|
|
19
|
+
* This component explicitly disables the `disabled` prop.
|
|
20
|
+
*/
|
|
21
|
+
disabled?: never;
|
|
22
|
+
}
|
|
4
23
|
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
24
|
+
export type SegmentedControlProps = RecursicaOverStyled<
|
|
25
|
+
Omit<
|
|
26
|
+
MuiSegmentedControlProps,
|
|
27
|
+
| "variant"
|
|
28
|
+
| "size"
|
|
29
|
+
| "radius"
|
|
30
|
+
| "color"
|
|
31
|
+
| "classNames"
|
|
32
|
+
| "className"
|
|
33
|
+
| "disabled"
|
|
34
|
+
> & {
|
|
35
|
+
className?: string;
|
|
36
|
+
classNames?: Partial<Record<string, string>>;
|
|
37
|
+
} & RecursicaSegmentedControlProps
|
|
38
|
+
>;
|
|
39
|
+
|
|
40
|
+
function useSegmentedControlClassNames(restRecord: Record<string, unknown>): {
|
|
41
|
+
className: string;
|
|
42
|
+
classNames: Partial<Record<string, string>>;
|
|
43
|
+
} {
|
|
44
|
+
const mergedClassNames: Partial<Record<string, string>> = {
|
|
45
|
+
root: styles.root,
|
|
46
|
+
control: styles.control,
|
|
47
|
+
label: styles.label,
|
|
48
|
+
indicator: styles.indicator,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const classNamesProp = restRecord.classNames;
|
|
52
|
+
if (
|
|
53
|
+
classNamesProp &&
|
|
54
|
+
typeof classNamesProp === "object" &&
|
|
55
|
+
!Array.isArray(classNamesProp)
|
|
56
|
+
) {
|
|
57
|
+
const o = classNamesProp as Partial<Record<string, string>>;
|
|
58
|
+
mergedClassNames.root = o.root ? `${styles.root} ${o.root}` : styles.root;
|
|
59
|
+
mergedClassNames.control = o.control
|
|
60
|
+
? `${styles.control} ${o.control}`
|
|
61
|
+
: styles.control;
|
|
62
|
+
mergedClassNames.label = o.label
|
|
63
|
+
? `${styles.label} ${o.label}`
|
|
64
|
+
: styles.label;
|
|
65
|
+
mergedClassNames.indicator = o.indicator
|
|
66
|
+
? `${styles.indicator} ${o.indicator}`
|
|
67
|
+
: styles.indicator;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const classNameProp = restRecord.className as string | undefined;
|
|
71
|
+
const finalClass = classNameProp
|
|
72
|
+
? `${styles.root} ${classNameProp}`
|
|
73
|
+
: styles.root;
|
|
74
|
+
|
|
75
|
+
return { className: finalClass, classNames: mergedClassNames };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const _SegmentedControl = forwardRef<HTMLDivElement, SegmentedControlProps>(
|
|
79
|
+
function SegmentedControl(
|
|
80
|
+
{ overStyled = false, orientation = "horizontal", fullWidth, ...rest },
|
|
81
|
+
ref,
|
|
82
|
+
) {
|
|
83
|
+
const sanitizedProps = filterStylingProps(rest, overStyled);
|
|
84
|
+
const restRecord = sanitizedProps as Record<string, unknown>;
|
|
85
|
+
|
|
86
|
+
// Explicitly prevent consumers from bypassing the disabled restriction
|
|
87
|
+
delete restRecord["disabled"];
|
|
88
|
+
|
|
89
|
+
const stylingParams = useSegmentedControlClassNames(restRecord);
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<MuiSegmentedControl
|
|
93
|
+
ref={ref}
|
|
94
|
+
className={stylingParams.className}
|
|
95
|
+
classes={stylingParams.classNames}
|
|
96
|
+
orientation={orientation}
|
|
97
|
+
fullWidth={fullWidth}
|
|
98
|
+
data-orientation={orientation}
|
|
99
|
+
{...(sanitizedProps as Omit<
|
|
100
|
+
MuiSegmentedControlProps,
|
|
101
|
+
"variant" | "size"
|
|
102
|
+
>)}
|
|
103
|
+
/>
|
|
104
|
+
);
|
|
105
|
+
},
|
|
106
|
+
);
|
|
107
|
+
_SegmentedControl.displayName = "SegmentedControl";
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Recursica SegmentedControl component wrapping Mui's SegmentedControl.
|
|
111
|
+
*/
|
|
112
|
+
export const SegmentedControl = _SegmentedControl;
|