@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,7 +1,112 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Avatar as MuiAvatar,
|
|
4
|
+
type AvatarProps as MuiAvatarProps,
|
|
5
|
+
} from "@mui/material";
|
|
6
|
+
import {
|
|
7
|
+
filterStylingProps,
|
|
8
|
+
type RecursicaOverStyled,
|
|
9
|
+
} from "../../utils/filterStylingProps";
|
|
10
|
+
import styles from "./Avatar.module.css";
|
|
2
11
|
|
|
3
|
-
export
|
|
12
|
+
export interface RecursicaAvatarProps {
|
|
13
|
+
size?: "small" | "default" | "large";
|
|
14
|
+
variant?: "solid" | "outline" | "ghost";
|
|
15
|
+
icon?: React.ReactNode;
|
|
16
|
+
}
|
|
4
17
|
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
18
|
+
export type AvatarProps = RecursicaOverStyled<
|
|
19
|
+
Omit<MuiAvatarProps, "variant" | "size" | "color" | "radius"> &
|
|
20
|
+
RecursicaAvatarProps
|
|
21
|
+
>;
|
|
22
|
+
|
|
23
|
+
const _Avatar = forwardRef<HTMLDivElement, AvatarProps>(function Avatar(
|
|
24
|
+
{
|
|
25
|
+
size = "default",
|
|
26
|
+
variant = "solid",
|
|
27
|
+
icon,
|
|
28
|
+
children,
|
|
29
|
+
src,
|
|
30
|
+
overStyled = false,
|
|
31
|
+
...rest
|
|
32
|
+
},
|
|
33
|
+
ref,
|
|
34
|
+
) {
|
|
35
|
+
const mapVariant = {
|
|
36
|
+
solid: "filled",
|
|
37
|
+
outline: "outline",
|
|
38
|
+
ghost: "transparent",
|
|
39
|
+
} as const;
|
|
40
|
+
|
|
41
|
+
const mapSize = {
|
|
42
|
+
default: "md",
|
|
43
|
+
small: "sm",
|
|
44
|
+
large: "lg",
|
|
45
|
+
} as const;
|
|
46
|
+
|
|
47
|
+
const sanitizedProps = filterStylingProps(rest, overStyled);
|
|
48
|
+
const restRecord = sanitizedProps as Record<string, unknown>;
|
|
49
|
+
|
|
50
|
+
// Determine semantic style based on provided props
|
|
51
|
+
let computedStyle = "text";
|
|
52
|
+
if (src) {
|
|
53
|
+
computedStyle = "image";
|
|
54
|
+
} else if (icon) {
|
|
55
|
+
computedStyle = "icon";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const mergedClassNames: Partial<Record<string, string>> = {
|
|
59
|
+
root: styles.root,
|
|
60
|
+
image: styles.image,
|
|
61
|
+
placeholder: styles.placeholder,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const classNamesProp = restRecord.classNames;
|
|
65
|
+
if (
|
|
66
|
+
classNamesProp &&
|
|
67
|
+
typeof classNamesProp === "object" &&
|
|
68
|
+
!Array.isArray(classNamesProp)
|
|
69
|
+
) {
|
|
70
|
+
const o = classNamesProp as Partial<Record<string, string>>;
|
|
71
|
+
mergedClassNames.root = o.root ? `${styles.root} ${o.root}` : styles.root;
|
|
72
|
+
mergedClassNames.image = o.image
|
|
73
|
+
? `${styles.image} ${o.image}`
|
|
74
|
+
: styles.image;
|
|
75
|
+
mergedClassNames.placeholder = o.placeholder
|
|
76
|
+
? `${styles.placeholder} ${o.placeholder}`
|
|
77
|
+
: styles.placeholder;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const classNameProp = restRecord.className as string | undefined;
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<MuiAvatar
|
|
84
|
+
ref={ref}
|
|
85
|
+
className={classNameProp}
|
|
86
|
+
classes={mergedClassNames}
|
|
87
|
+
variant={mapVariant[variant]}
|
|
88
|
+
size={mapSize[size]}
|
|
89
|
+
src={src}
|
|
90
|
+
data-variant={variant}
|
|
91
|
+
data-size={size}
|
|
92
|
+
data-style={computedStyle}
|
|
93
|
+
{...sanitizedProps}
|
|
94
|
+
>
|
|
95
|
+
{icon != null ? (
|
|
96
|
+
<span className={styles.iconWrapper} aria-hidden>
|
|
97
|
+
{icon}
|
|
98
|
+
</span>
|
|
99
|
+
) : children != null ? (
|
|
100
|
+
<span className={styles.textWrapper}>{children}</span>
|
|
101
|
+
) : undefined}
|
|
102
|
+
</MuiAvatar>
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
_Avatar.displayName = "Avatar";
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Recursica Avatar component wrapping Mui's Avatar.
|
|
109
|
+
*
|
|
110
|
+
* Supports polymorphism via the `component` prop or `renderRoot` for custom element rendering.
|
|
111
|
+
*/
|
|
112
|
+
export const Avatar = _Avatar as any;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/* HARDCODED VALUES:
|
|
2
|
+
- border-style: solid (needs a token if we support other border styles)
|
|
3
|
+
- box-sizing: border-box
|
|
4
|
+
- display: inline-flex
|
|
5
|
+
- align-items: center
|
|
6
|
+
- justify-content: center
|
|
7
|
+
- text-transform: uppercase (Mantine does this, but our tokens also specify it so we map it)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
.root {
|
|
11
|
+
/* HARDCODE: Basic structural assumptions */
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
border-style: solid;
|
|
17
|
+
|
|
18
|
+
/* Base style resets to fully clear Mantine's defaults before applying ours */
|
|
19
|
+
background-color: transparent;
|
|
20
|
+
color: inherit;
|
|
21
|
+
border-color: transparent;
|
|
22
|
+
|
|
23
|
+
/* Apply global badge properties */
|
|
24
|
+
border-radius: var(
|
|
25
|
+
--recursica_ui-kit_components_badge_properties_border-radius
|
|
26
|
+
);
|
|
27
|
+
border-width: var(--recursica_ui-kit_components_badge_properties_border-size);
|
|
28
|
+
box-shadow: var(--recursica_ui-kit_components_badge_properties_elevation);
|
|
29
|
+
|
|
30
|
+
padding-left: var(
|
|
31
|
+
--recursica_ui-kit_components_badge_properties_padding-horizontal
|
|
32
|
+
);
|
|
33
|
+
padding-right: var(
|
|
34
|
+
--recursica_ui-kit_components_badge_properties_padding-horizontal
|
|
35
|
+
);
|
|
36
|
+
padding-top: var(
|
|
37
|
+
--recursica_ui-kit_components_badge_properties_padding-vertical
|
|
38
|
+
);
|
|
39
|
+
padding-bottom: var(
|
|
40
|
+
--recursica_ui-kit_components_badge_properties_padding-vertical
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
font-family: var(
|
|
44
|
+
--recursica_ui-kit_components_badge_properties_text_font-family
|
|
45
|
+
);
|
|
46
|
+
font-size: var(--recursica_ui-kit_components_badge_properties_text_font-size);
|
|
47
|
+
font-weight: var(
|
|
48
|
+
--recursica_ui-kit_components_badge_properties_text_font-weight
|
|
49
|
+
);
|
|
50
|
+
font-style: var(
|
|
51
|
+
--recursica_ui-kit_components_badge_properties_text_font-style
|
|
52
|
+
);
|
|
53
|
+
letter-spacing: var(
|
|
54
|
+
--recursica_ui-kit_components_badge_properties_text_letter-spacing
|
|
55
|
+
);
|
|
56
|
+
line-height: var(
|
|
57
|
+
--recursica_ui-kit_components_badge_properties_text_line-height
|
|
58
|
+
);
|
|
59
|
+
text-decoration: var(
|
|
60
|
+
--recursica_ui-kit_components_badge_properties_text_text-decoration
|
|
61
|
+
);
|
|
62
|
+
text-transform: var(
|
|
63
|
+
--recursica_ui-kit_components_badge_properties_text_text-transform
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* Variant Definitions */
|
|
68
|
+
|
|
69
|
+
.root[data-variant="alert"] {
|
|
70
|
+
background-color: var(
|
|
71
|
+
--recursica_ui-kit_components_badge_variants_styles_alert_properties_colors_background
|
|
72
|
+
);
|
|
73
|
+
border-color: var(
|
|
74
|
+
--recursica_ui-kit_components_badge_variants_styles_alert_properties_colors_border-color
|
|
75
|
+
);
|
|
76
|
+
color: var(
|
|
77
|
+
--recursica_ui-kit_components_badge_variants_styles_alert_properties_colors_text
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.root[data-variant="primary-color"] {
|
|
82
|
+
background-color: var(
|
|
83
|
+
--recursica_ui-kit_components_badge_variants_styles_primary-color_properties_colors_background
|
|
84
|
+
);
|
|
85
|
+
border-color: var(
|
|
86
|
+
--recursica_ui-kit_components_badge_variants_styles_primary-color_properties_colors_border-color
|
|
87
|
+
);
|
|
88
|
+
color: var(
|
|
89
|
+
--recursica_ui-kit_components_badge_variants_styles_primary-color_properties_colors_text
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.root[data-variant="success"] {
|
|
94
|
+
background-color: var(
|
|
95
|
+
--recursica_ui-kit_components_badge_variants_styles_success_properties_colors_background
|
|
96
|
+
);
|
|
97
|
+
border-color: var(
|
|
98
|
+
--recursica_ui-kit_components_badge_variants_styles_success_properties_colors_border-color
|
|
99
|
+
);
|
|
100
|
+
color: var(
|
|
101
|
+
--recursica_ui-kit_components_badge_variants_styles_success_properties_colors_text
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.root[data-variant="warning"] {
|
|
106
|
+
background-color: var(
|
|
107
|
+
--recursica_ui-kit_components_badge_variants_styles_warning_properties_colors_background
|
|
108
|
+
);
|
|
109
|
+
border-color: var(
|
|
110
|
+
--recursica_ui-kit_components_badge_variants_styles_warning_properties_colors_border-color
|
|
111
|
+
);
|
|
112
|
+
color: var(
|
|
113
|
+
--recursica_ui-kit_components_badge_variants_styles_warning_properties_colors_text
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* Target Mantine internal children if needed for typography constraints */
|
|
118
|
+
.root :global(.mantine-Badge-label),
|
|
119
|
+
.root :global(.mantine-Badge-section) {
|
|
120
|
+
/* HARDCODE: Prevent Mantine from overriding our typography setup inside inner wrappers */
|
|
121
|
+
font-size: inherit;
|
|
122
|
+
font-weight: inherit;
|
|
123
|
+
line-height: inherit;
|
|
124
|
+
font-family: inherit;
|
|
125
|
+
letter-spacing: inherit;
|
|
126
|
+
text-transform: inherit;
|
|
127
|
+
}
|
|
@@ -1,35 +1,78 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
3
|
import { Badge } from "./Badge";
|
|
3
|
-
import {
|
|
4
|
+
import { Layer } from "@recursica/adapter-common";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
type BadgeStoryProps = React.ComponentProps<typeof Badge>;
|
|
7
|
+
|
|
8
|
+
const meta: Meta<BadgeStoryProps> = {
|
|
9
|
+
title: "UI-Kit/Badge",
|
|
7
10
|
component: Badge,
|
|
8
11
|
tags: ["autodocs"],
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"children",
|
|
15
|
-
"component",
|
|
16
|
-
"variant",
|
|
17
|
-
"size",
|
|
18
|
-
"icon",
|
|
19
|
-
"disabled",
|
|
20
|
-
"href",
|
|
21
|
-
"onClick",
|
|
22
|
-
"onChange",
|
|
23
|
-
"value",
|
|
24
|
-
"checked",
|
|
25
|
-
],
|
|
12
|
+
argTypes: {
|
|
13
|
+
variant: {
|
|
14
|
+
control: "select",
|
|
15
|
+
options: ["alert", "primary-color", "success", "warning"],
|
|
16
|
+
description: "The style / intent mapping for the badge",
|
|
26
17
|
},
|
|
27
18
|
},
|
|
28
19
|
};
|
|
29
20
|
|
|
30
21
|
export default meta;
|
|
31
|
-
|
|
22
|
+
|
|
23
|
+
type Story = StoryObj<BadgeStoryProps>;
|
|
32
24
|
|
|
33
25
|
export const Default: Story = {
|
|
34
|
-
|
|
26
|
+
args: {
|
|
27
|
+
children: "Badge Label",
|
|
28
|
+
variant: "primary-color",
|
|
29
|
+
},
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
31
|
+
render: ({ withLayer, layer, ...args }: any) => {
|
|
32
|
+
return <Badge {...args} />;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const StaticAlert: Story = {
|
|
37
|
+
args: {
|
|
38
|
+
children: "Alert Badge",
|
|
39
|
+
variant: "alert",
|
|
40
|
+
},
|
|
41
|
+
render: (args: BadgeStoryProps) => <Badge {...args} />,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const StaticPrimary: Story = {
|
|
45
|
+
args: {
|
|
46
|
+
children: "Primary Badge",
|
|
47
|
+
variant: "primary-color",
|
|
48
|
+
},
|
|
49
|
+
render: (args: BadgeStoryProps) => <Badge {...args} />,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const StaticSuccess: Story = {
|
|
53
|
+
args: {
|
|
54
|
+
children: "Success Badge",
|
|
55
|
+
variant: "success",
|
|
56
|
+
},
|
|
57
|
+
render: (args: BadgeStoryProps) => <Badge {...args} />,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const StaticWarning: Story = {
|
|
61
|
+
args: {
|
|
62
|
+
children: "Warning Badge",
|
|
63
|
+
variant: "warning",
|
|
64
|
+
},
|
|
65
|
+
render: (args: BadgeStoryProps) => <Badge {...args} />,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const LayerOneAlert: Story = {
|
|
69
|
+
args: {
|
|
70
|
+
children: "Layer 1 Alert",
|
|
71
|
+
variant: "alert",
|
|
72
|
+
},
|
|
73
|
+
render: (args: BadgeStoryProps) => (
|
|
74
|
+
<Layer layer={1} style={{ padding: "24px" }}>
|
|
75
|
+
<Badge {...args} />
|
|
76
|
+
</Layer>
|
|
77
|
+
),
|
|
35
78
|
};
|
|
@@ -1,7 +1,72 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Badge as MuiBadge,
|
|
4
|
+
type BadgeProps as MuiBadgeProps,
|
|
5
|
+
} from "@mui/material";
|
|
6
|
+
import {
|
|
7
|
+
filterStylingProps,
|
|
8
|
+
type RecursicaOverStyled,
|
|
9
|
+
} from "../../utils/filterStylingProps";
|
|
10
|
+
import styles from "./Badge.module.css";
|
|
2
11
|
|
|
3
|
-
export
|
|
12
|
+
export interface RecursicaBadgeProps {
|
|
13
|
+
/** Map to the component styles defined in variables */
|
|
14
|
+
variant?: "alert" | "primary-color" | "success" | "warning";
|
|
15
|
+
}
|
|
4
16
|
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
17
|
+
export type BadgeProps = RecursicaOverStyled<
|
|
18
|
+
Omit<MuiBadgeProps, "variant" | "size" | "color" | "radius"> &
|
|
19
|
+
RecursicaBadgeProps
|
|
20
|
+
>;
|
|
21
|
+
|
|
22
|
+
const _Badge = forwardRef<HTMLDivElement, BadgeProps>(function Badge(
|
|
23
|
+
{ variant = "primary-color", overStyled = false, ...rest },
|
|
24
|
+
ref,
|
|
25
|
+
) {
|
|
26
|
+
// Strip all visual override injections unless developer has specifically opted into overStyling.
|
|
27
|
+
// External layout props like margins are safely preserved.
|
|
28
|
+
const sanitizedProps = filterStylingProps(rest, overStyled);
|
|
29
|
+
|
|
30
|
+
const mergedClassNames: Partial<Record<string, string>> = {
|
|
31
|
+
root: styles.root,
|
|
32
|
+
section: styles.section,
|
|
33
|
+
label: styles.label,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const classNamesProp = (sanitizedProps as Record<string, unknown>).classNames;
|
|
37
|
+
if (
|
|
38
|
+
classNamesProp &&
|
|
39
|
+
typeof classNamesProp === "object" &&
|
|
40
|
+
!Array.isArray(classNamesProp)
|
|
41
|
+
) {
|
|
42
|
+
const o = classNamesProp as Partial<Record<string, string>>;
|
|
43
|
+
mergedClassNames.root = o.root ? `${styles.root} ${o.root}` : styles.root;
|
|
44
|
+
mergedClassNames.section = o.section ?? styles.section;
|
|
45
|
+
mergedClassNames.label = o.label ?? styles.label;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const classNameProp = (sanitizedProps as Record<string, unknown>)
|
|
49
|
+
.className as string | undefined;
|
|
50
|
+
const finalClass = classNameProp
|
|
51
|
+
? `${styles.root} ${classNameProp}`
|
|
52
|
+
: styles.root;
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<MuiBadge
|
|
56
|
+
ref={ref}
|
|
57
|
+
variant="filled" // We manage visual style purely through our CSS variables mapping
|
|
58
|
+
data-variant={variant}
|
|
59
|
+
{...sanitizedProps}
|
|
60
|
+
className={finalClass}
|
|
61
|
+
classes={mergedClassNames}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
_Badge.displayName = "Badge";
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Recursica Badge component wrapping Mui's Badge.
|
|
69
|
+
*
|
|
70
|
+
* Supports polymorphism via the `component` prop or `renderRoot` for custom element rendering.
|
|
71
|
+
*/
|
|
72
|
+
export const Badge = _Badge as any;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* HARDCODED VALUES:
|
|
2
|
+
- align-items: center
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
.root {
|
|
6
|
+
/* HARDCODE: Basic structural flex layout for breadcrumbs */
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
|
|
10
|
+
/* Base style resets */
|
|
11
|
+
background-color: transparent;
|
|
12
|
+
color: inherit;
|
|
13
|
+
|
|
14
|
+
/* Apply global breadcrumb properties */
|
|
15
|
+
padding: var(--recursica_ui-kit_components_breadcrumb_properties_padding);
|
|
16
|
+
|
|
17
|
+
/* Mantine's breadcrumbs uses gap on the root or pseudo classes, but standard gap is safest since flex is used */
|
|
18
|
+
gap: var(--recursica_ui-kit_components_breadcrumb_properties_item-gap);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.separator {
|
|
22
|
+
/* Separator base resets if needed */
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
justify-content: center;
|
|
26
|
+
}
|
|
@@ -1,35 +1,70 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
3
|
import { Breadcrumb } from "./Breadcrumb";
|
|
3
|
-
import {
|
|
4
|
+
import { Link } from "../Link";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
type BreadcrumbStoryProps = React.ComponentProps<typeof Breadcrumb> & {
|
|
7
|
+
items?: string[];
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const meta: Meta<BreadcrumbStoryProps> = {
|
|
11
|
+
title: "UI-Kit/Breadcrumb",
|
|
7
12
|
component: Breadcrumb,
|
|
8
13
|
tags: ["autodocs"],
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
argTypes: {
|
|
15
|
+
children: {
|
|
16
|
+
table: {
|
|
17
|
+
disable: true,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
items: {
|
|
21
|
+
control: "object",
|
|
22
|
+
description:
|
|
23
|
+
"Array of string labels used to dynamically generate the interactive Breadcrumb nodes.",
|
|
24
|
+
table: {
|
|
25
|
+
category: "Story Controls",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
separator: {
|
|
29
|
+
control: "text",
|
|
30
|
+
description: "Custom separator between items",
|
|
26
31
|
},
|
|
27
32
|
},
|
|
33
|
+
args: {
|
|
34
|
+
items: ["Home", "Components", "Breadcrumbs"],
|
|
35
|
+
},
|
|
36
|
+
render: ({ items, children, ...args }) => {
|
|
37
|
+
const mappedChildren = items
|
|
38
|
+
? items.map((label, index) => (
|
|
39
|
+
<Link href="#" key={index}>
|
|
40
|
+
{label}
|
|
41
|
+
</Link>
|
|
42
|
+
))
|
|
43
|
+
: children;
|
|
44
|
+
|
|
45
|
+
return <Breadcrumb children={mappedChildren} {...args} />;
|
|
46
|
+
},
|
|
28
47
|
};
|
|
29
48
|
|
|
30
49
|
export default meta;
|
|
31
|
-
|
|
50
|
+
|
|
51
|
+
type Story = StoryObj<BreadcrumbStoryProps>;
|
|
32
52
|
|
|
33
53
|
export const Default: Story = {
|
|
34
|
-
|
|
54
|
+
args: {
|
|
55
|
+
items: ["Dashboard", "Settings", "Security"],
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const StaticExample: Story = {
|
|
60
|
+
args: {
|
|
61
|
+
items: ["Store", "Electronics", "Computers", "Laptops"],
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const CustomSeparator: Story = {
|
|
66
|
+
args: {
|
|
67
|
+
items: ["Root", "Branch", "Leaf"],
|
|
68
|
+
separator: "→",
|
|
69
|
+
},
|
|
35
70
|
};
|
|
@@ -1,7 +1,64 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Breadcrumbs as MuiBreadcrumbs,
|
|
4
|
+
type BreadcrumbsProps as MuiBreadcrumbsProps,
|
|
5
|
+
} from "@mui/material";
|
|
6
|
+
import {
|
|
7
|
+
filterStylingProps,
|
|
8
|
+
type RecursicaOverStyled,
|
|
9
|
+
} from "../../utils/filterStylingProps";
|
|
10
|
+
import styles from "./Breadcrumb.module.css";
|
|
2
11
|
|
|
3
|
-
|
|
12
|
+
// Currently there are no Recursica prop additions specific to Breadcrumbs (like size or variant)
|
|
13
|
+
// according to recursica_ui-kit.json
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
15
|
+
export interface RecursicaBreadcrumbProps {}
|
|
4
16
|
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
17
|
+
export type BreadcrumbProps = RecursicaOverStyled<
|
|
18
|
+
Omit<MuiBreadcrumbsProps, "variant" | "size"> & RecursicaBreadcrumbProps
|
|
19
|
+
>;
|
|
20
|
+
|
|
21
|
+
export const Breadcrumb = forwardRef<HTMLDivElement, BreadcrumbProps>(
|
|
22
|
+
function Breadcrumb({ overStyled = false, separator = ">", ...rest }, ref) {
|
|
23
|
+
const sanitizedProps = filterStylingProps(
|
|
24
|
+
{ separator, ...rest },
|
|
25
|
+
overStyled,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const mergedClassNames: Partial<Record<string, string>> = {
|
|
29
|
+
root: styles.root,
|
|
30
|
+
separator: styles.separator,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const classNamesProp = (sanitizedProps as Record<string, unknown>)
|
|
34
|
+
.classNames;
|
|
35
|
+
if (
|
|
36
|
+
classNamesProp &&
|
|
37
|
+
typeof classNamesProp === "object" &&
|
|
38
|
+
!Array.isArray(classNamesProp)
|
|
39
|
+
) {
|
|
40
|
+
const o = classNamesProp as Partial<Record<string, string>>;
|
|
41
|
+
mergedClassNames.root = o.root ? `${styles.root} ${o.root}` : styles.root;
|
|
42
|
+
mergedClassNames.separator = o.separator
|
|
43
|
+
? `${styles.separator} ${o.separator}`
|
|
44
|
+
: styles.separator;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const classNameProp = (sanitizedProps as Record<string, unknown>)
|
|
48
|
+
.className as string | undefined;
|
|
49
|
+
const finalClass = classNameProp
|
|
50
|
+
? `${styles.root} ${classNameProp}`
|
|
51
|
+
: styles.root;
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<MuiBreadcrumbs
|
|
55
|
+
ref={ref}
|
|
56
|
+
{...(sanitizedProps as unknown as MuiBreadcrumbsProps)}
|
|
57
|
+
className={finalClass}
|
|
58
|
+
classes={mergedClassNames}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
Breadcrumb.displayName = "Breadcrumb";
|