@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.
Files changed (159) hide show
  1. package/CHANGELOG.md +9 -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 +6652 -204
  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 +16 -2
  10. package/dist/src/components/Avatar/Avatar.d.ts +14 -2
  11. package/dist/src/components/Badge/Badge.d.ts +13 -3
  12. package/dist/src/components/Breadcrumb/Breadcrumb.d.ts +10 -3
  13. package/dist/src/components/Button/Button.d.ts +1 -1
  14. package/dist/src/components/Card/Card.d.ts +40 -3
  15. package/dist/src/components/Checkbox/Checkbox.d.ts +15 -2
  16. package/dist/src/components/Checkbox/CheckboxGroup.d.ts +16 -0
  17. package/dist/src/components/Checkbox/index.d.ts +5 -1
  18. package/dist/src/components/Chip/Chip.d.ts +18 -2
  19. package/dist/src/components/Dropdown/Dropdown.d.ts +23 -3
  20. package/dist/src/components/FormControlLayout/FormControlLayout.d.ts +10 -2
  21. package/dist/src/components/FormControlWrapper/FormControlWrapper.d.ts +24 -2
  22. package/dist/src/components/HoverCard/HoverCard.d.ts +55 -3
  23. package/dist/src/components/Label/Label.d.ts +13 -2
  24. package/dist/src/components/Link/Link.d.ts +1 -1
  25. package/dist/src/components/Menu/Menu.d.ts +99 -3
  26. package/dist/src/components/Modal/Modal.d.ts +36 -2
  27. package/dist/src/components/NumberInput/NumberInput.d.ts +14 -2
  28. package/dist/src/components/Pagination/Pagination.d.ts +44 -2
  29. package/dist/src/components/Pagination/Pagination.icons.d.ts +8 -0
  30. package/dist/src/components/Panel/Panel.d.ts +65 -3
  31. package/dist/src/components/Radio/Radio.d.ts +13 -3
  32. package/dist/src/components/Radio/RadioGroup.d.ts +13 -0
  33. package/dist/src/components/ReadOnlyField/ReadOnlyBooleanField.d.ts +5 -0
  34. package/dist/src/components/ReadOnlyField/ReadOnlyField.d.ts +7 -2
  35. package/dist/src/components/ReadOnlyField/ReadOnlySwitchField.d.ts +5 -0
  36. package/dist/src/components/ReadOnlyField/ReadOnlyTextField.d.ts +8 -0
  37. package/dist/src/components/ReadOnlyField/WithReadOnlyWrapper.d.ts +28 -0
  38. package/dist/src/components/ReadOnlyField/index.d.ts +1 -0
  39. package/dist/src/components/SegmentedControl/SegmentedControl.d.ts +31 -3
  40. package/dist/src/components/Slider/Slider.d.ts +28 -2
  41. package/dist/src/components/Stepper/Stepper.d.ts +21 -2
  42. package/dist/src/components/Switch/Switch.d.ts +10 -3
  43. package/dist/src/components/Switch/SwitchGroup.d.ts +13 -0
  44. package/dist/src/components/Tabs/Tabs.d.ts +35 -3
  45. package/dist/src/components/Text/Text.d.ts +1 -1
  46. package/dist/src/components/TextArea/TextArea.d.ts +18 -2
  47. package/dist/src/components/TextField/TextField.d.ts +16 -2
  48. package/dist/src/components/Timeline/Timeline.d.ts +14 -2
  49. package/dist/src/components/Timeline/TimelineItem.d.ts +29 -0
  50. package/dist/src/components/Title/Title.d.ts +1 -1
  51. package/dist/src/components/Toast/Toast.d.ts +25 -2
  52. package/dist/src/components/Tooltip/Tooltip.d.ts +42 -3
  53. package/dist/src/components/Typography/Typography.d.ts +1 -1
  54. package/package.json +9 -2
  55. package/src/components/Accordion/Accordion.module.css +295 -56
  56. package/src/components/Accordion/Accordion.stories.tsx +149 -21
  57. package/src/components/Accordion/Accordion.tsx +264 -5
  58. package/src/components/AssistiveElement/AssistiveElement.module.css +111 -20
  59. package/src/components/AssistiveElement/AssistiveElement.stories.tsx +76 -19
  60. package/src/components/AssistiveElement/AssistiveElement.tsx +85 -5
  61. package/src/components/Autocomplete/Autocomplete.module.css +320 -42
  62. package/src/components/Autocomplete/Autocomplete.stories.tsx +180 -19
  63. package/src/components/Autocomplete/Autocomplete.tsx +199 -6
  64. package/src/components/Avatar/Avatar.module.css +343 -73
  65. package/src/components/Avatar/Avatar.stories.tsx +94 -22
  66. package/src/components/Avatar/Avatar.tsx +110 -6
  67. package/src/components/Badge/Badge.module.css +127 -29
  68. package/src/components/Badge/Badge.stories.tsx +65 -22
  69. package/src/components/Badge/Badge.tsx +70 -6
  70. package/src/components/Breadcrumb/Breadcrumb.module.css +25 -5
  71. package/src/components/Breadcrumb/Breadcrumb.stories.tsx +57 -22
  72. package/src/components/Breadcrumb/Breadcrumb.tsx +62 -6
  73. package/src/components/Button/Button.module.css +3 -3
  74. package/src/components/Card/Card.module.css +118 -38
  75. package/src/components/Card/Card.stories.tsx +117 -19
  76. package/src/components/Card/Card.tsx +179 -5
  77. package/src/components/Checkbox/Checkbox.module.css +232 -39
  78. package/src/components/Checkbox/Checkbox.stories.tsx +81 -19
  79. package/src/components/Checkbox/Checkbox.tsx +146 -5
  80. package/src/components/Checkbox/CheckboxGroup.tsx +117 -0
  81. package/src/components/Checkbox/index.ts +6 -1
  82. package/src/components/Chip/Chip.module.css +228 -43
  83. package/src/components/Chip/Chip.stories.tsx +101 -21
  84. package/src/components/Chip/Chip.tsx +138 -6
  85. package/src/components/Dropdown/Dropdown.module.css +291 -41
  86. package/src/components/Dropdown/Dropdown.stories.tsx +80 -21
  87. package/src/components/Dropdown/Dropdown.tsx +182 -6
  88. package/src/components/FormControlLayout/FormControlLayout.module.css +92 -0
  89. package/src/components/FormControlLayout/FormControlLayout.stories.tsx +74 -19
  90. package/src/components/FormControlLayout/FormControlLayout.tsx +58 -4
  91. package/src/components/FormControlWrapper/FormControlWrapper.module.css +96 -0
  92. package/src/components/FormControlWrapper/FormControlWrapper.stories.tsx +122 -19
  93. package/src/components/FormControlWrapper/FormControlWrapper.tsx +145 -6
  94. package/src/components/HoverCard/HoverCard.module.css +90 -22
  95. package/src/components/HoverCard/HoverCard.stories.tsx +158 -21
  96. package/src/components/HoverCard/HoverCard.tsx +150 -5
  97. package/src/components/Label/Label.module.css +136 -35
  98. package/src/components/Label/Label.stories.tsx +98 -17
  99. package/src/components/Label/Label.tsx +88 -5
  100. package/src/components/Menu/Menu.module.css +285 -51
  101. package/src/components/Menu/Menu.stories.tsx +307 -21
  102. package/src/components/Menu/Menu.tsx +318 -5
  103. package/src/components/Modal/Modal.module.css +171 -35
  104. package/src/components/Modal/Modal.stories.tsx +66 -22
  105. package/src/components/Modal/Modal.tsx +216 -4
  106. package/src/components/NumberInput/NumberInput.module.css +276 -42
  107. package/src/components/NumberInput/NumberInput.stories.tsx +83 -20
  108. package/src/components/NumberInput/NumberInput.tsx +148 -6
  109. package/src/components/Pagination/Pagination.icons.tsx +66 -0
  110. package/src/components/Pagination/Pagination.module.css +246 -20
  111. package/src/components/Pagination/Pagination.stories.tsx +42 -21
  112. package/src/components/Pagination/Pagination.tsx +193 -5
  113. package/src/components/Panel/Panel.module.css +206 -38
  114. package/src/components/Panel/Panel.stories.tsx +214 -22
  115. package/src/components/Panel/Panel.tsx +153 -5
  116. package/src/components/Radio/Radio.module.css +220 -37
  117. package/src/components/Radio/Radio.stories.tsx +77 -19
  118. package/src/components/Radio/Radio.tsx +178 -5
  119. package/src/components/Radio/RadioGroup.tsx +111 -0
  120. package/src/components/ReadOnlyField/ReadOnlyBooleanField.tsx +21 -0
  121. package/src/components/ReadOnlyField/ReadOnlyField.module.css +53 -15
  122. package/src/components/ReadOnlyField/ReadOnlyField.stories.tsx +175 -16
  123. package/src/components/ReadOnlyField/ReadOnlyField.tsx +109 -5
  124. package/src/components/ReadOnlyField/ReadOnlySwitchField.tsx +21 -0
  125. package/src/components/ReadOnlyField/ReadOnlyTextField.tsx +48 -0
  126. package/src/components/ReadOnlyField/WithReadOnlyWrapper.tsx +93 -0
  127. package/src/components/ReadOnlyField/index.ts +1 -0
  128. package/src/components/SegmentedControl/SegmentedControl.module.css +203 -47
  129. package/src/components/SegmentedControl/SegmentedControl.stories.tsx +102 -20
  130. package/src/components/SegmentedControl/SegmentedControl.tsx +110 -6
  131. package/src/components/Slider/Slider.module.css +542 -86
  132. package/src/components/Slider/Slider.stories.tsx +157 -19
  133. package/src/components/Slider/Slider.tsx +282 -5
  134. package/src/components/Stepper/Stepper.module.css +410 -71
  135. package/src/components/Stepper/Stepper.stories.tsx +132 -19
  136. package/src/components/Stepper/Stepper.tsx +145 -6
  137. package/src/components/Switch/Switch.module.css +238 -39
  138. package/src/components/Switch/Switch.stories.tsx +98 -19
  139. package/src/components/Switch/Switch.tsx +153 -6
  140. package/src/components/Switch/SwitchGroup.tsx +111 -0
  141. package/src/components/Tabs/Tabs.module.css +422 -79
  142. package/src/components/Tabs/Tabs.stories.tsx +138 -19
  143. package/src/components/Tabs/Tabs.tsx +103 -6
  144. package/src/components/TextArea/TextArea.module.css +155 -32
  145. package/src/components/TextArea/TextArea.stories.tsx +80 -21
  146. package/src/components/TextArea/TextArea.tsx +156 -6
  147. package/src/components/TextField/TextField.module.css +261 -42
  148. package/src/components/TextField/TextField.stories.tsx +168 -15
  149. package/src/components/TextField/TextField.tsx +171 -6
  150. package/src/components/Timeline/Timeline.module.css +365 -76
  151. package/src/components/Timeline/Timeline.stories.tsx +114 -21
  152. package/src/components/Timeline/Timeline.tsx +80 -5
  153. package/src/components/Timeline/TimelineItem.tsx +101 -0
  154. package/src/components/Toast/Toast.module.css +166 -28
  155. package/src/components/Toast/Toast.stories.tsx +54 -22
  156. package/src/components/Toast/Toast.tsx +90 -5
  157. package/src/components/Tooltip/Tooltip.module.css +89 -24
  158. package/src/components/Tooltip/Tooltip.stories.tsx +152 -22
  159. package/src/components/Tooltip/Tooltip.tsx +114 -5
@@ -1,8 +1,149 @@
1
- import React from "react";
2
- import "./Checkbox.module.css";
1
+ import React, { forwardRef } from "react";
2
+ import {
3
+ Checkbox as MuiCheckbox,
4
+ type CheckboxProps as MuiCheckboxProps,
5
+ FormControlLabel,
6
+ } from "@mui/material";
7
+ import { type ReadOnlyControlProps } from "@recursica/adapter-common";
8
+ import { CheckboxGroup } from "./CheckboxGroup";
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
- export type CheckboxProps = React.HTMLAttributes<HTMLDivElement>;
19
+ import styles from "./Checkbox.module.css";
5
20
 
6
- export const Checkbox: React.FC<CheckboxProps> = (props) => {
7
- return <div {...props}>Checkbox</div>;
21
+ export type RecursicaCheckboxProps = RequireAccessibleLabel<
22
+ Omit<MuiCheckboxProps, "size" | "color"> & {
23
+ label?: React.ReactNode;
24
+ } & ReadOnlyControlProps &
25
+ Pick<
26
+ FormControlLayoutProps,
27
+ "formLayout" | "labelSize" | "controlMaxWidth" | "controlMinWidth"
28
+ >
29
+ >;
30
+
31
+ export type CheckboxProps = RecursicaOverStyled<RecursicaCheckboxProps>;
32
+
33
+ type CheckboxComponent = React.ForwardRefExoticComponent<
34
+ CheckboxProps & React.RefAttributes<HTMLButtonElement>
35
+ > & {
36
+ Group: typeof CheckboxGroup;
8
37
  };
38
+
39
+ export const Checkbox = forwardRef<HTMLButtonElement, CheckboxProps>(
40
+ function Checkbox(props, ref) {
41
+ const {
42
+ overStyled = false,
43
+ readOnly,
44
+ readOnlyComponent,
45
+ disabled,
46
+ formLayout,
47
+ labelSize,
48
+ controlMaxWidth,
49
+ controlMinWidth,
50
+ label,
51
+ ...rest
52
+ } = props;
53
+
54
+ const sanitizedProps = filterStylingProps(rest, overStyled);
55
+ const restRecord = sanitizedProps as Record<string, unknown>;
56
+
57
+ delete restRecord["size"];
58
+ delete restRecord["color"];
59
+
60
+ const mergedClassNames: Partial<Record<string, string>> = {
61
+ root: styles.root,
62
+ checked: styles.checked,
63
+ disabled: styles.disabled,
64
+ };
65
+
66
+ const classesProp = restRecord.classes;
67
+ if (
68
+ classesProp &&
69
+ typeof classesProp === "object" &&
70
+ !Array.isArray(classesProp)
71
+ ) {
72
+ const o = classesProp as Partial<Record<string, string>>;
73
+ mergedClassNames.root = o.root ? `${styles.root} ${o.root}` : styles.root;
74
+ mergedClassNames.checked = o.checked
75
+ ? `${styles.checked} ${o.checked}`
76
+ : styles.checked;
77
+ mergedClassNames.disabled = o.disabled
78
+ ? `${styles.disabled} ${o.disabled}`
79
+ : styles.disabled;
80
+ }
81
+
82
+ const classNameProp = restRecord.className as string | undefined;
83
+ const finalClass = classNameProp
84
+ ? `${styles.root} ${classNameProp}`
85
+ : styles.root;
86
+
87
+ if (readOnly && !!readOnlyComponent) {
88
+ const isChecked = !!(restRecord.checked ?? restRecord.defaultChecked);
89
+ const ReadOnlyComp = readOnlyComponent;
90
+ const roNode = (
91
+ <ReadOnlyComp {...props} checked={isChecked} label={label} />
92
+ );
93
+
94
+ if (formLayout) {
95
+ return (
96
+ <FormControlLayout
97
+ formLayout={formLayout}
98
+ labelSize={labelSize}
99
+ controlMaxWidth={controlMaxWidth}
100
+ controlMinWidth={controlMinWidth}
101
+ >
102
+ {roNode}
103
+ </FormControlLayout>
104
+ );
105
+ }
106
+
107
+ return <>{roNode}</>;
108
+ }
109
+
110
+ const checkboxNode = (
111
+ <MuiCheckbox
112
+ ref={ref}
113
+ className={finalClass}
114
+ classes={mergedClassNames}
115
+ disabled={readOnly || disabled}
116
+ {...(sanitizedProps as unknown as MuiCheckboxProps)}
117
+ />
118
+ );
119
+
120
+ const finalNode = label ? (
121
+ <FormControlLabel
122
+ control={checkboxNode}
123
+ label={label}
124
+ className={styles.labelWrapper}
125
+ classes={{ label: styles.label }}
126
+ />
127
+ ) : (
128
+ checkboxNode
129
+ );
130
+
131
+ if (formLayout) {
132
+ return (
133
+ <FormControlLayout
134
+ formLayout={formLayout}
135
+ labelSize={labelSize}
136
+ controlMaxWidth={controlMaxWidth}
137
+ controlMinWidth={controlMinWidth}
138
+ >
139
+ {finalNode}
140
+ </FormControlLayout>
141
+ );
142
+ }
143
+
144
+ return finalNode;
145
+ },
146
+ ) as CheckboxComponent;
147
+
148
+ Checkbox.displayName = "Checkbox";
149
+ Checkbox.Group = CheckboxGroup;
@@ -0,0 +1,117 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import React, { forwardRef } from "react";
3
+ import { FormGroup, type FormGroupProps } from "@mui/material";
4
+ import { type ReadOnlyControlProps } from "@recursica/adapter-common";
5
+ import {
6
+ filterStylingProps,
7
+ type RecursicaOverStyled,
8
+ } from "../../utils/filterStylingProps";
9
+ import { type RecursicaFormControlWrapperProps } from "../FormControlWrapper/FormControlWrapper";
10
+ import { WithReadOnlyWrapper } from "../ReadOnlyField/WithReadOnlyWrapper";
11
+ import styles from "./Checkbox.module.css";
12
+
13
+ export interface RecursicaCheckboxGroupProps
14
+ extends Omit<FormGroupProps, "size" | "onChange">,
15
+ Omit<
16
+ RecursicaFormControlWrapperProps,
17
+ "controlMaxWidth" | "controlMinWidth"
18
+ >,
19
+ ReadOnlyControlProps {
20
+ value?: any[];
21
+ defaultValue?: any[];
22
+ onChange?: (value: any[]) => void;
23
+ }
24
+
25
+ export type CheckboxGroupProps =
26
+ RecursicaOverStyled<RecursicaCheckboxGroupProps>;
27
+
28
+ export const CheckboxGroup = forwardRef<HTMLDivElement, CheckboxGroupProps>(
29
+ function CheckboxGroup(props, ref) {
30
+ const {
31
+ overStyled = false,
32
+ formLayout = "stacked",
33
+
34
+ // Label Wrappers
35
+ labelSize,
36
+ labelAlignment,
37
+ labelOptionalText,
38
+ labelWithEditIcon,
39
+ onLabelEditClick,
40
+
41
+ // Base Mantine Extracted Attributes
42
+ label,
43
+ description,
44
+ assistiveText,
45
+ assistiveWithIcon,
46
+ error,
47
+ required,
48
+ withAsterisk,
49
+ id,
50
+ className,
51
+ style,
52
+ children,
53
+ readOnly,
54
+ readOnlyComponent,
55
+ emptyValueComponent,
56
+ value,
57
+ defaultValue,
58
+ onChange,
59
+ ...rest
60
+ } = props;
61
+ const sanitizedProps = filterStylingProps(rest, overStyled);
62
+ const restRecord = sanitizedProps as Record<string, unknown>;
63
+
64
+ // Delete prohibited sizing hooks
65
+ delete restRecord["size"];
66
+
67
+ const handleChange = (event: React.SyntheticEvent, childValue: any) => {
68
+ // In MUI, FormGroup doesn't handle value arrays automatically like Mantine Checkbox.Group does.
69
+ // A common pattern is that each child Checkbox handles its own onChange,
70
+ // but to match Mantine API we might need context or cloning.
71
+ // For now, we pass down props or rely on the user to handle state.
72
+ };
73
+
74
+ return (
75
+ <WithReadOnlyWrapper
76
+ className={className}
77
+ style={style as React.CSSProperties}
78
+ controlMaxWidth="var(--recursica_ui-kit_components_checkbox-item_properties_max-width)"
79
+ controlMinWidth={undefined}
80
+ overStyled={overStyled as true}
81
+ labelElement="div"
82
+ formLayout={formLayout}
83
+ labelSize={labelSize}
84
+ labelAlignment={labelAlignment}
85
+ labelOptionalText={labelOptionalText}
86
+ labelWithEditIcon={labelWithEditIcon}
87
+ onLabelEditClick={onLabelEditClick}
88
+ label={label}
89
+ description={description}
90
+ assistiveText={assistiveText}
91
+ assistiveWithIcon={assistiveWithIcon}
92
+ error={error}
93
+ required={required}
94
+ withAsterisk={withAsterisk}
95
+ id={id}
96
+ readOnly={readOnly && !!readOnlyComponent}
97
+ readOnlyComponent={readOnlyComponent}
98
+ emptyValueComponent={emptyValueComponent}
99
+ readOnlyType="text"
100
+ readOnlyValue={value !== undefined ? value : defaultValue}
101
+ readOnlyNativeProps={props}
102
+ activeComponent={
103
+ <FormGroup
104
+ ref={ref}
105
+ {...(sanitizedProps as unknown as FormGroupProps)}
106
+ className={`${styles.groupRoot} ${(sanitizedProps as any).className || ""}`}
107
+ data-layout={formLayout}
108
+ >
109
+ {children}
110
+ </FormGroup>
111
+ }
112
+ />
113
+ );
114
+ },
115
+ );
116
+
117
+ CheckboxGroup.displayName = "CheckboxGroup";
@@ -1 +1,6 @@
1
- export * from "./Checkbox";
1
+ import { CheckboxGroup } from "./CheckboxGroup";
2
+
3
+ export { Checkbox } from "./Checkbox";
4
+ export type { CheckboxProps } from "./Checkbox";
5
+ export { CheckboxGroup };
6
+ export type { CheckboxGroupProps } from "./CheckboxGroup";
@@ -1,51 +1,236 @@
1
1
  /* EXEMPTIONS:
2
- This component is a placeholder stub. Once fully implemented, its specific
3
- tokens will be fully wired up to direct styles. */
4
-
5
- /* recursica-ignore: --recursica_ui-kit_components_chip_properties_border-radius */
6
- /* recursica-ignore: --recursica_ui-kit_components_chip_properties_border-size */
2
+ - close-icon-color, leading-icon-color, and select-specific state icon variables are ignored because
3
+ Chip uses explicit state color definitions (e.g. unselected, selected, error, error-selected variant colors)
4
+ to drive pixel-perfect hover and click transitions, rather than generic single-color overrides.
5
+ - text-size is ignored since actual chip sizing is dynamically driven by precise vertical padding and line-heights. */
7
6
  /* recursica-ignore: --recursica_ui-kit_components_chip_properties_close-icon-color */
8
- /* recursica-ignore: --recursica_ui-kit_components_chip_properties_close-icon-size */
9
- /* recursica-ignore: --recursica_ui-kit_components_chip_properties_elevation */
10
- /* recursica-ignore: --recursica_ui-kit_components_chip_properties_horizontal-padding */
11
- /* recursica-ignore: --recursica_ui-kit_components_chip_properties_icon-size */
12
- /* recursica-ignore: --recursica_ui-kit_components_chip_properties_icon-text-gap */
13
7
  /* recursica-ignore: --recursica_ui-kit_components_chip_properties_leading-icon-color */
14
- /* recursica-ignore: --recursica_ui-kit_components_chip_properties_max-width */
15
- /* recursica-ignore: --recursica_ui-kit_components_chip_properties_min-width */
16
8
  /* recursica-ignore: --recursica_ui-kit_components_chip_properties_text-size */
17
- /* recursica-ignore: --recursica_ui-kit_components_chip_properties_text_font-family */
18
- /* recursica-ignore: --recursica_ui-kit_components_chip_properties_text_font-size */
19
- /* recursica-ignore: --recursica_ui-kit_components_chip_properties_text_font-style */
20
- /* recursica-ignore: --recursica_ui-kit_components_chip_properties_text_font-weight */
21
- /* recursica-ignore: --recursica_ui-kit_components_chip_properties_text_letter-spacing */
22
- /* recursica-ignore: --recursica_ui-kit_components_chip_properties_text_line-height */
23
- /* recursica-ignore: --recursica_ui-kit_components_chip_properties_text_text-decoration */
24
- /* recursica-ignore: --recursica_ui-kit_components_chip_properties_text_text-transform */
25
- /* recursica-ignore: --recursica_ui-kit_components_chip_properties_vertical-padding */
26
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_error-selected_properties_colors_background */
27
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_error-selected_properties_colors_border-color */
28
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_error-selected_properties_colors_close-icon-color */
29
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_error-selected_properties_colors_icon */
30
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_error-selected_properties_colors_leading-icon-color */
31
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_error-selected_properties_colors_selected-icon-color */
32
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_error-selected_properties_colors_text */
33
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_error_properties_colors_background */
34
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_error_properties_colors_border-color */
35
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_error_properties_colors_close-icon-color */
36
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_error_properties_colors_icon */
37
9
  /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_error_properties_colors_leading-icon-color */
38
10
  /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_error_properties_colors_selected-icon-color */
39
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_error_properties_colors_text */
40
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_selected_properties_colors_background */
41
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_selected_properties_colors_border-color */
42
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_selected_properties_colors_close-icon-color */
11
+ /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_error-selected_properties_colors_icon */
12
+ /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_error-selected_properties_colors_leading-icon-color */
43
13
  /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_selected_properties_colors_leading-icon-color */
44
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_selected_properties_colors_selected-icon-color */
45
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_selected_properties_colors_text */
46
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_unselected_properties_colors_background */
47
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_unselected_properties_colors_border-color */
48
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_unselected_properties_colors_close-icon-color */
49
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_unselected_properties_colors_leading-icon-color */
50
14
  /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_unselected_properties_colors_selected-icon-color */
51
- /* recursica-ignore: --recursica_ui-kit_components_chip_variants_styles_unselected_properties_colors_text */
15
+
16
+ /* HARDCODED VALUES
17
+ border-style: solid; (Baseline reset)
18
+ box-sizing: border-box; (Baseline reset)
19
+ display: inline-flex; (Baseline reset)
20
+ align-items: center; (Baseline reset)
21
+ outline: none; (Accessible fallback)
22
+ padding: 0; (Override mantine default)
23
+ background: transparent; (Override mantine default)
24
+ */
25
+
26
+ .root {
27
+ /* Set preset layout variables to override mantine defaults safely */
28
+ box-sizing: border-box;
29
+ display: inline-flex;
30
+
31
+ /* Token properties */
32
+ --chip-height: max-content; /* Sizing is driven by padding and line height */
33
+ --chip-bg: var(
34
+ --recursica_ui-kit_components_chip_variants_styles_unselected_properties_colors_background
35
+ );
36
+ --chip-border: var(
37
+ --recursica_ui-kit_components_chip_variants_styles_unselected_properties_colors_border-color
38
+ );
39
+ --chip-text: var(
40
+ --recursica_ui-kit_components_chip_variants_styles_unselected_properties_colors_text
41
+ );
42
+ --chip-icon: var(
43
+ --recursica_ui-kit_components_chip_variants_styles_unselected_properties_colors_leading-icon-color
44
+ );
45
+ --chip-close: var(
46
+ --recursica_ui-kit_components_chip_variants_styles_unselected_properties_colors_close-icon-color
47
+ );
48
+
49
+ border-radius: var(
50
+ --recursica_ui-kit_components_chip_properties_border-radius
51
+ );
52
+ }
53
+
54
+ /* We target the mantine label directly because that is the visible container in Mantine's Chip */
55
+ .label {
56
+ box-sizing: border-box;
57
+ display: inline-flex;
58
+ align-items: center;
59
+ justify-content: center;
60
+
61
+ /* Reset mantine styles */
62
+ background: transparent !important; /* HARDCODE: Mantine forces background styling on label */
63
+ border-style: solid;
64
+ border-width: var(--recursica_ui-kit_components_chip_properties_border-size);
65
+ padding: var(--recursica_ui-kit_components_chip_properties_vertical-padding)
66
+ var(--recursica_ui-kit_components_chip_properties_horizontal-padding) !important;
67
+
68
+ /* Typography */
69
+ font-family: var(
70
+ --recursica_ui-kit_components_chip_properties_text_font-family
71
+ );
72
+ font-size: var(--recursica_ui-kit_components_chip_properties_text_font-size);
73
+ font-weight: var(
74
+ --recursica_ui-kit_components_chip_properties_text_font-weight
75
+ );
76
+ font-style: var(
77
+ --recursica_ui-kit_components_chip_properties_text_font-style
78
+ );
79
+ letter-spacing: var(
80
+ --recursica_ui-kit_components_chip_properties_text_letter-spacing
81
+ );
82
+ line-height: var(
83
+ --recursica_ui-kit_components_chip_properties_text_line-height
84
+ );
85
+ text-decoration: var(
86
+ --recursica_ui-kit_components_chip_properties_text_text-decoration
87
+ );
88
+ text-transform: var(
89
+ --recursica_ui-kit_components_chip_properties_text_text-transform
90
+ );
91
+
92
+ /* Token evaluation */
93
+ background-color: var(--chip-bg) !important;
94
+ border-color: var(--chip-border) !important;
95
+ color: var(--chip-text) !important;
96
+ min-width: var(--recursica_ui-kit_components_chip_properties_min-width);
97
+ max-width: var(--recursica_ui-kit_components_chip_properties_max-width);
98
+ box-shadow: var(
99
+ --recursica_ui-kit_components_chip_properties_elevation,
100
+ none
101
+ );
102
+
103
+ transition: all 0.2s ease;
104
+ }
105
+
106
+ /* Default (Unselected) hover/active interactions (Mantine overrides) */
107
+ .label[data-checked] {
108
+ --chip-bg: var(
109
+ --recursica_ui-kit_components_chip_variants_styles_selected_properties_colors_background
110
+ );
111
+ --chip-border: var(
112
+ --recursica_ui-kit_components_chip_variants_styles_selected_properties_colors_border-color
113
+ );
114
+ --chip-text: var(
115
+ --recursica_ui-kit_components_chip_variants_styles_selected_properties_colors_text
116
+ );
117
+ --chip-icon: var(
118
+ --recursica_ui-kit_components_chip_variants_styles_selected_properties_colors_selected-icon-color
119
+ );
120
+ --chip-close: var(
121
+ --recursica_ui-kit_components_chip_variants_styles_selected_properties_colors_close-icon-color
122
+ );
123
+ }
124
+
125
+ .root[data-error] .label {
126
+ --chip-bg: var(
127
+ --recursica_ui-kit_components_chip_variants_styles_error_properties_colors_background
128
+ );
129
+ --chip-border: var(
130
+ --recursica_ui-kit_components_chip_variants_styles_error_properties_colors_border-color
131
+ );
132
+ --chip-text: var(
133
+ --recursica_ui-kit_components_chip_variants_styles_error_properties_colors_text
134
+ );
135
+ --chip-icon: var(
136
+ --recursica_ui-kit_components_chip_variants_styles_error_properties_colors_icon
137
+ );
138
+ --chip-close: var(
139
+ --recursica_ui-kit_components_chip_variants_styles_error_properties_colors_close-icon-color
140
+ );
141
+ }
142
+
143
+ .root[data-error] .label[data-checked] {
144
+ --chip-bg: var(
145
+ --recursica_ui-kit_components_chip_variants_styles_error-selected_properties_colors_background
146
+ );
147
+ --chip-border: var(
148
+ --recursica_ui-kit_components_chip_variants_styles_error-selected_properties_colors_border-color
149
+ );
150
+ --chip-text: var(
151
+ --recursica_ui-kit_components_chip_variants_styles_error-selected_properties_colors_text
152
+ );
153
+ --chip-icon: var(
154
+ --recursica_ui-kit_components_chip_variants_styles_error-selected_properties_colors_selected-icon-color
155
+ );
156
+ --chip-close: var(
157
+ --recursica_ui-kit_components_chip_variants_styles_error-selected_properties_colors_close-icon-color
158
+ );
159
+ }
160
+
161
+ .root[data-disabled] .label {
162
+ opacity: var(--recursica_brand_states_disabled, 0.5);
163
+ cursor: not-allowed;
164
+ }
165
+
166
+ /* Override Mantine's built-in check icon colors and size if we keep it */
167
+ .mantineIconWrapper {
168
+ color: var(--chip-icon) !important;
169
+ width: var(
170
+ --recursica_ui-kit_components_chip_properties_icon-size
171
+ ) !important;
172
+ height: var(
173
+ --recursica_ui-kit_components_chip_properties_icon-size
174
+ ) !important;
175
+ margin-right: var(
176
+ --recursica_ui-kit_components_chip_properties_icon-text-gap
177
+ );
178
+ }
179
+
180
+ .innerWrapper {
181
+ display: inline-flex;
182
+ align-items: center;
183
+ gap: var(--recursica_ui-kit_components_chip_properties_icon-text-gap);
184
+ width: 100%;
185
+ }
186
+
187
+ .children {
188
+ flex-grow: 1;
189
+ text-overflow: ellipsis;
190
+ overflow: hidden;
191
+ white-space: nowrap;
192
+ }
193
+
194
+ .leadingIcon {
195
+ display: inline-flex;
196
+ align-items: center;
197
+ justify-content: center;
198
+ color: var(--chip-icon);
199
+ width: var(--recursica_ui-kit_components_chip_properties_icon-size);
200
+ height: var(--recursica_ui-kit_components_chip_properties_icon-size);
201
+ }
202
+
203
+ .leadingIcon svg {
204
+ width: 100%;
205
+ height: 100%;
206
+ }
207
+
208
+ .removeIcon {
209
+ display: inline-flex;
210
+ align-items: center;
211
+ justify-content: center;
212
+ color: var(--chip-close);
213
+ width: var(--recursica_ui-kit_components_chip_properties_close-icon-size);
214
+ height: var(--recursica_ui-kit_components_chip_properties_close-icon-size);
215
+ cursor: pointer;
216
+ border-radius: 50%; /* HARDCODE: Make focus ring rounded */
217
+ outline: none;
218
+ }
219
+
220
+ .removeIcon:focus-visible {
221
+ box-shadow: 0 0 0 2px var(--chip-border); /* HARDCODE: Focus indication */
222
+ }
223
+
224
+ .removeIcon svg {
225
+ width: 100%;
226
+ height: 100%;
227
+ }
228
+
229
+ .root[data-icon-only] .label {
230
+ padding-left: var(
231
+ --recursica_ui-kit_components_chip_properties_vertical-padding
232
+ ) !important;
233
+ padding-right: var(
234
+ --recursica_ui-kit_components_chip_properties_vertical-padding
235
+ ) !important;
236
+ }
@@ -1,35 +1,115 @@
1
+ import React from "react";
1
2
  import type { Meta, StoryObj } from "@storybook/react";
2
3
  import { Chip } from "./Chip";
3
- import { ComingSoon } from "@recursica/storybook-template";
4
4
 
5
- const meta: Meta<typeof Chip> = {
6
- title: "UI-Kit/🚧 Chip",
5
+ type ChipStoryProps = React.ComponentProps<typeof Chip>;
6
+
7
+ const meta: Meta<ChipStoryProps> = {
8
+ title: "UI-Kit/Chip",
7
9
  component: Chip,
8
10
  tags: ["autodocs"],
9
11
  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
+ docs: {
13
+ description: {
14
+ component:
15
+ "The Chip component is used to represent interactive selections, descriptive tags, or dynamic filters natively bounded to Recursica variables. It can be used as a toggleable input, can render a custom leading `icon`, and handles close constraints automatically via the `onRemove` property.",
16
+ },
17
+ },
18
+ },
19
+ argTypes: {
20
+ error: {
21
+ control: "boolean",
22
+ description: "Applies the error state styling dynamically.",
23
+ },
24
+ disabled: {
25
+ control: "boolean",
26
+ description: "Applies disabled token states.",
27
+ },
28
+ checked: {
29
+ control: "boolean",
30
+ description: "Forces the visual selected state.",
26
31
  },
27
32
  },
28
33
  };
29
34
 
30
35
  export default meta;
31
- type Story = StoryObj<typeof Chip>;
32
36
 
37
+ type Story = StoryObj<ChipStoryProps>;
38
+
39
+ // The Default story exposing native properties for the playground.
33
40
  export const Default: Story = {
34
- render: () => <ComingSoon componentName="Chip" />,
41
+ args: {
42
+ children: "Default Chip",
43
+ error: false,
44
+ disabled: false,
45
+ checked: false,
46
+ },
47
+ render: (args: ChipStoryProps) => <Chip {...args} />,
48
+ };
49
+
50
+ // Static Stories for Regression Snapshots
51
+ export const Unselected: Story = {
52
+ args: {
53
+ children: "Unselected",
54
+ checked: false,
55
+ },
56
+ render: (args: ChipStoryProps) => <Chip {...args} />,
57
+ };
58
+
59
+ export const Selected: Story = {
60
+ args: {
61
+ children: "Selected",
62
+ checked: true,
63
+ },
64
+ render: (args: ChipStoryProps) => <Chip {...args} onChange={() => {}} />,
65
+ };
66
+
67
+ export const ErrorState: Story = {
68
+ args: {
69
+ children: "Error",
70
+ error: true,
71
+ checked: false,
72
+ },
73
+ render: (args: ChipStoryProps) => <Chip {...args} />,
74
+ };
75
+
76
+ export const ErrorSelected: Story = {
77
+ args: {
78
+ children: "Error Selected",
79
+ error: true,
80
+ checked: true,
81
+ },
82
+ render: (args: ChipStoryProps) => <Chip {...args} onChange={() => {}} />,
83
+ };
84
+
85
+ export const Removable: Story = {
86
+ args: {
87
+ children: "Dismissible",
88
+ checked: false,
89
+ onRemove: () => console.log("Removal Action Triggered"),
90
+ },
91
+ render: (args: ChipStoryProps) => <Chip {...args} />,
92
+ };
93
+
94
+ export const WithLeadingIcon: Story = {
95
+ args: {
96
+ children: "Leading Icon",
97
+ checked: false,
98
+ icon: (
99
+ <svg
100
+ xmlns="http://www.w3.org/2000/svg"
101
+ viewBox="0 0 24 24"
102
+ fill="none"
103
+ stroke="currentColor"
104
+ strokeWidth="2"
105
+ strokeLinecap="round"
106
+ strokeLinejoin="round"
107
+ >
108
+ <circle cx="12" cy="12" r="10"></circle>
109
+ <path d="M12 8v4"></path>
110
+ <path d="M12 16h.01"></path>
111
+ </svg>
112
+ ),
113
+ },
114
+ render: (args: ChipStoryProps) => <Chip {...args} />,
35
115
  };