@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.
Files changed (177) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/mui-adapter.cjs +74 -1
  3. package/dist/mui-adapter.cjs.map +1 -1
  4. package/dist/mui-adapter.css +1 -1
  5. package/dist/mui-adapter.js +6651 -201
  6. package/dist/mui-adapter.js.map +1 -1
  7. package/dist/src/components/Accordion/Accordion.d.ts +63 -2
  8. package/dist/src/components/AssistiveElement/AssistiveElement.d.ts +9 -2
  9. package/dist/src/components/Autocomplete/Autocomplete.d.ts +17 -0
  10. package/dist/src/components/Autocomplete/index.d.ts +1 -0
  11. package/dist/src/components/Avatar/Avatar.d.ts +14 -2
  12. package/dist/src/components/Badge/Badge.d.ts +13 -3
  13. package/dist/src/components/Breadcrumb/Breadcrumb.d.ts +10 -3
  14. package/dist/src/components/Button/Button.d.ts +1 -1
  15. package/dist/src/components/Card/Card.d.ts +40 -3
  16. package/dist/src/components/Checkbox/Checkbox.d.ts +15 -2
  17. package/dist/src/components/Checkbox/CheckboxGroup.d.ts +16 -0
  18. package/dist/src/components/Checkbox/index.d.ts +5 -1
  19. package/dist/src/components/Chip/Chip.d.ts +18 -2
  20. package/dist/src/components/Dropdown/Dropdown.d.ts +23 -3
  21. package/dist/src/components/FormControlLayout/FormControlLayout.d.ts +10 -2
  22. package/dist/src/components/FormControlWrapper/FormControlWrapper.d.ts +24 -2
  23. package/dist/src/components/HoverCard/HoverCard.d.ts +55 -3
  24. package/dist/src/components/Label/Label.d.ts +13 -2
  25. package/dist/src/components/Link/Link.d.ts +1 -1
  26. package/dist/src/components/Menu/Menu.d.ts +99 -3
  27. package/dist/src/components/Modal/Modal.d.ts +36 -2
  28. package/dist/src/components/NumberInput/NumberInput.d.ts +14 -2
  29. package/dist/src/components/Pagination/Pagination.d.ts +44 -2
  30. package/dist/src/components/Pagination/Pagination.icons.d.ts +8 -0
  31. package/dist/src/components/Panel/Panel.d.ts +65 -3
  32. package/dist/src/components/Radio/Radio.d.ts +13 -3
  33. package/dist/src/components/Radio/RadioGroup.d.ts +13 -0
  34. package/dist/src/components/ReadOnlyField/ReadOnlyBooleanField.d.ts +5 -0
  35. package/dist/src/components/ReadOnlyField/ReadOnlyField.d.ts +7 -2
  36. package/dist/src/components/ReadOnlyField/ReadOnlySwitchField.d.ts +5 -0
  37. package/dist/src/components/ReadOnlyField/ReadOnlyTextField.d.ts +8 -0
  38. package/dist/src/components/ReadOnlyField/WithReadOnlyWrapper.d.ts +28 -0
  39. package/dist/src/components/ReadOnlyField/index.d.ts +1 -0
  40. package/dist/src/components/SegmentedControl/SegmentedControl.d.ts +31 -3
  41. package/dist/src/components/Slider/Slider.d.ts +28 -2
  42. package/dist/src/components/Stepper/Stepper.d.ts +21 -2
  43. package/dist/src/components/Switch/Switch.d.ts +10 -3
  44. package/dist/src/components/Switch/SwitchGroup.d.ts +13 -0
  45. package/dist/src/components/Tabs/Tabs.d.ts +35 -3
  46. package/dist/src/components/Text/Text.d.ts +1 -1
  47. package/dist/src/components/TextArea/TextArea.d.ts +18 -2
  48. package/dist/src/components/TextField/TextField.d.ts +16 -2
  49. package/dist/src/components/Timeline/Timeline.d.ts +14 -2
  50. package/dist/src/components/Timeline/TimelineItem.d.ts +29 -0
  51. package/dist/src/components/Title/Title.d.ts +1 -1
  52. package/dist/src/components/Toast/Toast.d.ts +25 -2
  53. package/dist/src/components/Tooltip/Tooltip.d.ts +42 -3
  54. package/dist/src/components/Typography/Typography.d.ts +1 -1
  55. package/dist/src/components/index.d.ts +1 -0
  56. package/package.json +12 -2
  57. package/src/GlobalExemptions.modules.css +13 -0
  58. package/src/components/Accordion/Accordion.module.css +295 -0
  59. package/src/components/Accordion/Accordion.stories.tsx +149 -21
  60. package/src/components/Accordion/Accordion.tsx +264 -4
  61. package/src/components/AssistiveElement/AssistiveElement.module.css +111 -0
  62. package/src/components/AssistiveElement/AssistiveElement.stories.tsx +76 -19
  63. package/src/components/AssistiveElement/AssistiveElement.tsx +85 -4
  64. package/src/components/Autocomplete/Autocomplete.module.css +325 -0
  65. package/src/components/Autocomplete/Autocomplete.stories.tsx +196 -0
  66. package/src/components/Autocomplete/Autocomplete.tsx +201 -0
  67. package/src/components/Autocomplete/index.ts +1 -0
  68. package/src/components/Avatar/Avatar.module.css +344 -0
  69. package/src/components/Avatar/Avatar.stories.tsx +94 -22
  70. package/src/components/Avatar/Avatar.tsx +110 -5
  71. package/src/components/Badge/Badge.module.css +127 -0
  72. package/src/components/Badge/Badge.stories.tsx +65 -22
  73. package/src/components/Badge/Badge.tsx +70 -5
  74. package/src/components/Breadcrumb/Breadcrumb.module.css +26 -0
  75. package/src/components/Breadcrumb/Breadcrumb.stories.tsx +57 -22
  76. package/src/components/Breadcrumb/Breadcrumb.tsx +62 -5
  77. package/src/components/Button/Button.module.css +113 -20
  78. package/src/components/Button/Button.stories.tsx +3 -0
  79. package/src/components/Button/Button.tsx +10 -3
  80. package/src/components/Card/Card.module.css +118 -0
  81. package/src/components/Card/Card.stories.tsx +117 -19
  82. package/src/components/Card/Card.tsx +179 -4
  83. package/src/components/Checkbox/Checkbox.module.css +232 -0
  84. package/src/components/Checkbox/Checkbox.stories.tsx +81 -19
  85. package/src/components/Checkbox/Checkbox.tsx +146 -4
  86. package/src/components/Checkbox/CheckboxGroup.tsx +117 -0
  87. package/src/components/Checkbox/index.ts +6 -1
  88. package/src/components/Chip/Chip.module.css +236 -0
  89. package/src/components/Chip/Chip.stories.tsx +101 -21
  90. package/src/components/Chip/Chip.tsx +138 -5
  91. package/src/components/DatePicker/DatePicker.module.css +42 -0
  92. package/src/components/DatePicker/DatePicker.tsx +1 -0
  93. package/src/components/Dropdown/Dropdown.module.css +296 -0
  94. package/src/components/Dropdown/Dropdown.stories.tsx +80 -21
  95. package/src/components/Dropdown/Dropdown.tsx +182 -5
  96. package/src/components/FileInput/FileInput.module.css +47 -0
  97. package/src/components/FileInput/FileInput.tsx +1 -0
  98. package/src/components/FileUpload/FileUpload.module.css +40 -0
  99. package/src/components/FileUpload/FileUpload.tsx +1 -0
  100. package/src/components/FormControlLayout/FormControlLayout.module.css +92 -0
  101. package/src/components/FormControlLayout/FormControlLayout.stories.tsx +74 -19
  102. package/src/components/FormControlLayout/FormControlLayout.tsx +58 -4
  103. package/src/components/FormControlWrapper/FormControlWrapper.module.css +96 -0
  104. package/src/components/FormControlWrapper/FormControlWrapper.stories.tsx +122 -19
  105. package/src/components/FormControlWrapper/FormControlWrapper.tsx +145 -6
  106. package/src/components/HoverCard/HoverCard.module.css +91 -0
  107. package/src/components/HoverCard/HoverCard.stories.tsx +158 -21
  108. package/src/components/HoverCard/HoverCard.tsx +150 -4
  109. package/src/components/Label/Label.module.css +136 -0
  110. package/src/components/Label/Label.stories.tsx +98 -17
  111. package/src/components/Label/Label.tsx +88 -4
  112. package/src/components/Link/Link.module.css +8 -0
  113. package/src/components/Menu/Menu.module.css +287 -0
  114. package/src/components/Menu/Menu.stories.tsx +307 -21
  115. package/src/components/Menu/Menu.tsx +318 -4
  116. package/src/components/Modal/Modal.module.css +172 -0
  117. package/src/components/Modal/Modal.stories.tsx +66 -22
  118. package/src/components/Modal/Modal.tsx +216 -3
  119. package/src/components/NumberInput/NumberInput.module.css +281 -0
  120. package/src/components/NumberInput/NumberInput.stories.tsx +83 -20
  121. package/src/components/NumberInput/NumberInput.tsx +148 -5
  122. package/src/components/Pagination/Pagination.icons.tsx +66 -0
  123. package/src/components/Pagination/Pagination.module.css +307 -0
  124. package/src/components/Pagination/Pagination.stories.tsx +42 -21
  125. package/src/components/Pagination/Pagination.tsx +193 -4
  126. package/src/components/Panel/Panel.module.css +206 -0
  127. package/src/components/Panel/Panel.stories.tsx +214 -22
  128. package/src/components/Panel/Panel.tsx +153 -4
  129. package/src/components/Radio/Radio.module.css +220 -0
  130. package/src/components/Radio/Radio.stories.tsx +77 -19
  131. package/src/components/Radio/Radio.tsx +178 -4
  132. package/src/components/Radio/RadioGroup.tsx +111 -0
  133. package/src/components/ReadOnlyField/ReadOnlyBooleanField.tsx +21 -0
  134. package/src/components/ReadOnlyField/ReadOnlyField.module.css +54 -0
  135. package/src/components/ReadOnlyField/ReadOnlyField.stories.tsx +175 -16
  136. package/src/components/ReadOnlyField/ReadOnlyField.tsx +109 -4
  137. package/src/components/ReadOnlyField/ReadOnlySwitchField.tsx +21 -0
  138. package/src/components/ReadOnlyField/ReadOnlyTextField.tsx +48 -0
  139. package/src/components/ReadOnlyField/WithReadOnlyWrapper.tsx +93 -0
  140. package/src/components/ReadOnlyField/index.ts +1 -0
  141. package/src/components/SegmentedControl/SegmentedControl.module.css +203 -0
  142. package/src/components/SegmentedControl/SegmentedControl.stories.tsx +102 -20
  143. package/src/components/SegmentedControl/SegmentedControl.tsx +110 -5
  144. package/src/components/Slider/Slider.module.css +542 -0
  145. package/src/components/Slider/Slider.stories.tsx +157 -19
  146. package/src/components/Slider/Slider.tsx +282 -4
  147. package/src/components/Stepper/Stepper.module.css +410 -0
  148. package/src/components/Stepper/Stepper.stories.tsx +132 -19
  149. package/src/components/Stepper/Stepper.tsx +145 -5
  150. package/src/components/Switch/Switch.module.css +238 -0
  151. package/src/components/Switch/Switch.stories.tsx +98 -19
  152. package/src/components/Switch/Switch.tsx +153 -5
  153. package/src/components/Switch/SwitchGroup.tsx +111 -0
  154. package/src/components/Tabs/Tabs.module.css +422 -0
  155. package/src/components/Tabs/Tabs.stories.tsx +138 -19
  156. package/src/components/Tabs/Tabs.tsx +103 -5
  157. package/src/components/TextArea/TextArea.module.css +160 -0
  158. package/src/components/TextArea/TextArea.stories.tsx +80 -21
  159. package/src/components/TextArea/TextArea.tsx +156 -5
  160. package/src/components/TextField/TextField.module.css +266 -0
  161. package/src/components/TextField/TextField.stories.tsx +168 -15
  162. package/src/components/TextField/TextField.tsx +171 -5
  163. package/src/components/TimePicker/TimePicker.module.css +41 -0
  164. package/src/components/TimePicker/TimePicker.tsx +1 -0
  165. package/src/components/Timeline/Timeline.module.css +367 -0
  166. package/src/components/Timeline/Timeline.stories.tsx +114 -21
  167. package/src/components/Timeline/Timeline.tsx +80 -4
  168. package/src/components/Timeline/TimelineItem.tsx +101 -0
  169. package/src/components/Toast/Toast.module.css +170 -0
  170. package/src/components/Toast/Toast.stories.tsx +54 -22
  171. package/src/components/Toast/Toast.tsx +90 -4
  172. package/src/components/Tooltip/Tooltip.module.css +90 -0
  173. package/src/components/Tooltip/Tooltip.stories.tsx +152 -22
  174. package/src/components/Tooltip/Tooltip.tsx +114 -4
  175. package/src/components/TransferList/TransferList.module.css +38 -0
  176. package/src/components/TransferList/TransferList.tsx +1 -0
  177. 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 type AvatarProps = React.HTMLAttributes<HTMLDivElement>;
12
+ export interface RecursicaAvatarProps {
13
+ size?: "small" | "default" | "large";
14
+ variant?: "solid" | "outline" | "ghost";
15
+ icon?: React.ReactNode;
16
+ }
4
17
 
5
- export const Avatar: React.FC<AvatarProps> = (props) => {
6
- return <div {...props}>Avatar</div>;
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 { ComingSoon } from "@recursica/storybook-template";
4
+ import { Layer } from "@recursica/adapter-common";
4
5
 
5
- const meta: Meta<typeof Badge> = {
6
- title: "UI-Kit/🚧 Badge",
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
- parameters: {
10
- controls: {
11
- include: [
12
- "layer",
13
- "withLayer",
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
- type Story = StoryObj<typeof Badge>;
22
+
23
+ type Story = StoryObj<BadgeStoryProps>;
32
24
 
33
25
  export const Default: Story = {
34
- render: () => <ComingSoon componentName="Badge" />,
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 React from "react";
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 type BadgeProps = React.HTMLAttributes<HTMLDivElement>;
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 const Badge: React.FC<BadgeProps> = (props) => {
6
- return <div {...props}>Badge</div>;
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 { ComingSoon } from "@recursica/storybook-template";
4
+ import { Link } from "../Link";
4
5
 
5
- const meta: Meta<typeof Breadcrumb> = {
6
- title: "UI-Kit/🚧 Breadcrumb",
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
- parameters: {
10
- controls: {
11
- include: [
12
- "layer",
13
- "withLayer",
14
- "children",
15
- "component",
16
- "variant",
17
- "size",
18
- "icon",
19
- "disabled",
20
- "href",
21
- "onClick",
22
- "onChange",
23
- "value",
24
- "checked",
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
- type Story = StoryObj<typeof Breadcrumb>;
50
+
51
+ type Story = StoryObj<BreadcrumbStoryProps>;
32
52
 
33
53
  export const Default: Story = {
34
- render: () => <ComingSoon componentName="Breadcrumb" />,
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 React from "react";
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
- export type BreadcrumbProps = React.HTMLAttributes<HTMLDivElement>;
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 const Breadcrumb: React.FC<BreadcrumbProps> = (props) => {
6
- return <div {...props}>Breadcrumb</div>;
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";