@mhome/ui 0.1.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 (53) hide show
  1. package/README.md +188 -0
  2. package/dist/index.cjs.js +9 -0
  3. package/dist/index.cjs.js.map +1 -0
  4. package/dist/index.css +2 -0
  5. package/dist/index.esm.js +9 -0
  6. package/dist/index.esm.js.map +1 -0
  7. package/package.json +54 -0
  8. package/src/common/adaptive-theme-provider.js +19 -0
  9. package/src/components/accordion.jsx +306 -0
  10. package/src/components/alert.jsx +137 -0
  11. package/src/components/app-bar.jsx +105 -0
  12. package/src/components/autocomplete.jsx +347 -0
  13. package/src/components/avatar.jsx +160 -0
  14. package/src/components/box.jsx +165 -0
  15. package/src/components/button.jsx +104 -0
  16. package/src/components/card.jsx +156 -0
  17. package/src/components/checkbox.jsx +63 -0
  18. package/src/components/chip.jsx +137 -0
  19. package/src/components/collapse.jsx +188 -0
  20. package/src/components/container.jsx +67 -0
  21. package/src/components/date-picker.jsx +528 -0
  22. package/src/components/dialog-content-text.jsx +27 -0
  23. package/src/components/dialog.jsx +584 -0
  24. package/src/components/divider.jsx +192 -0
  25. package/src/components/drawer.jsx +255 -0
  26. package/src/components/form-control-label.jsx +89 -0
  27. package/src/components/form-group.jsx +32 -0
  28. package/src/components/form-label.jsx +54 -0
  29. package/src/components/grid.jsx +135 -0
  30. package/src/components/icon-button.jsx +101 -0
  31. package/src/components/index.js +78 -0
  32. package/src/components/input-adornment.jsx +43 -0
  33. package/src/components/input-label.jsx +55 -0
  34. package/src/components/list.jsx +239 -0
  35. package/src/components/menu.jsx +370 -0
  36. package/src/components/paper.jsx +173 -0
  37. package/src/components/radio-group.jsx +76 -0
  38. package/src/components/radio.jsx +108 -0
  39. package/src/components/select.jsx +308 -0
  40. package/src/components/slider.jsx +382 -0
  41. package/src/components/stack.jsx +110 -0
  42. package/src/components/table.jsx +243 -0
  43. package/src/components/tabs.jsx +363 -0
  44. package/src/components/text-field.jsx +289 -0
  45. package/src/components/toggle-button.jsx +209 -0
  46. package/src/components/toolbar.jsx +48 -0
  47. package/src/components/tooltip.jsx +127 -0
  48. package/src/components/typography.jsx +77 -0
  49. package/src/global-state.js +29 -0
  50. package/src/index.css +110 -0
  51. package/src/index.js +6 -0
  52. package/src/lib/useMediaQuery.js +37 -0
  53. package/src/lib/utils.js +113 -0
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@mhome/ui",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "mHome UI Component Library",
6
+ "main": "dist/index.cjs.js",
7
+ "module": "dist/index.esm.js",
8
+ "types": "dist/index.d.ts",
9
+ "style": "dist/index.css",
10
+ "files": [
11
+ "dist",
12
+ "src"
13
+ ],
14
+ "scripts": {
15
+ "build": "rollup -c",
16
+ "prepublishOnly": "npm run build"
17
+ },
18
+ "keywords": [
19
+ "react",
20
+ "ui",
21
+ "components",
22
+ "shadcn"
23
+ ],
24
+ "author": "mhome.ai",
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": ""
29
+ },
30
+ "peerDependencies": {
31
+ "react": "^18.2.0",
32
+ "react-dom": "^18.2.0"
33
+ },
34
+ "dependencies": {
35
+ "class-variance-authority": "^0.7.1",
36
+ "clsx": "^2.1.1",
37
+ "tailwind-merge": "^3.4.0"
38
+ },
39
+ "devDependencies": {
40
+ "@babel/core": "^7.23.0",
41
+ "@babel/preset-env": "^7.23.0",
42
+ "@babel/preset-react": "^7.22.0",
43
+ "@rollup/plugin-babel": "^6.0.4",
44
+ "@rollup/plugin-commonjs": "^25.0.7",
45
+ "@rollup/plugin-node-resolve": "^15.2.3",
46
+ "autoprefixer": "^10.4.0",
47
+ "rollup": "^4.0.0",
48
+ "rollup-plugin-peer-deps-external": "^2.2.4",
49
+ "rollup-plugin-postcss": "^4.0.2",
50
+ "@rollup/plugin-terser": "^0.4.4",
51
+ "tailwindcss": "^3.4.0"
52
+ }
53
+ }
54
+
@@ -0,0 +1,19 @@
1
+ // Simplified version for examples project
2
+ import React from "react";
3
+
4
+ export const getBackground = (backgroundType, isDark) => {
5
+ // Return null for solid backgrounds, or gradient strings for gradient backgrounds
6
+ // This is a simplified version - in the real project this would handle theme logic
7
+ return null;
8
+ };
9
+
10
+ // Hook for getting component background color
11
+ export const useComponentBackgroundColor = () => {
12
+ // Simplified version - return a function that accepts a default color
13
+ // In the real project, this would use theme context or state management
14
+ return (defaultColor) => {
15
+ // Return the default color passed in, or fallback to background
16
+ return defaultColor || "hsl(var(--background))";
17
+ };
18
+ };
19
+
@@ -0,0 +1,306 @@
1
+ import * as React from "react";
2
+ import { cn } from "../lib/utils";
3
+ import { ChevronDown } from "lucide-react";
4
+
5
+ const Accordion = React.forwardRef(
6
+ (
7
+ {
8
+ className,
9
+ style,
10
+ expanded,
11
+ onChange,
12
+ children,
13
+ defaultExpanded,
14
+ ...props
15
+ },
16
+ ref
17
+ ) => {
18
+ const [isExpanded, setIsExpanded] = React.useState(
19
+ defaultExpanded || false
20
+ );
21
+ const accordionId = React.useId();
22
+
23
+ // Use ref to store latest onChange and expanded to avoid stale closures
24
+ const onChangeRef = React.useRef(onChange);
25
+ const expandedRef = React.useRef(expanded);
26
+ React.useEffect(() => {
27
+ onChangeRef.current = onChange;
28
+ expandedRef.current = expanded;
29
+ }, [onChange, expanded]);
30
+
31
+ const handleChange = React.useCallback(
32
+ (event) => {
33
+ if (event) {
34
+ event.preventDefault?.();
35
+ event.stopPropagation?.();
36
+ }
37
+
38
+ // Use ref to get the latest expanded value to avoid stale closures
39
+ const currentExpandedValue = expandedRef.current;
40
+ const currentState =
41
+ currentExpandedValue !== undefined
42
+ ? currentExpandedValue
43
+ : isExpanded;
44
+ const newExpanded = !currentState;
45
+
46
+ // Always update internal state for uncontrolled mode
47
+ setIsExpanded(newExpanded);
48
+
49
+ // Always call onChange with the new state
50
+ // The parent component will update the expanded prop if it's controlled
51
+ if (onChangeRef.current) {
52
+ // MUI Accordion onChange signature: onChange(event, expanded)
53
+ onChangeRef.current(event, newExpanded);
54
+ }
55
+ },
56
+ [isExpanded]
57
+ );
58
+
59
+ const currentExpanded = expanded !== undefined ? expanded : isExpanded;
60
+
61
+ const finalBackgroundColor = style?.backgroundColor || "hsl(var(--card))";
62
+
63
+ const {
64
+ marginBottom,
65
+ border,
66
+ borderRadius,
67
+ boxShadow,
68
+ backgroundColor,
69
+ ...restStyle
70
+ } = style || {};
71
+
72
+ return (
73
+ <div
74
+ ref={ref}
75
+ role="region"
76
+ className={cn(
77
+ "overflow-hidden rounded-2xl",
78
+ marginBottom === undefined && "mb-2",
79
+ className
80
+ )}
81
+ style={{
82
+ border:
83
+ border !== undefined ? border : "1px solid hsl(var(--border))",
84
+ borderRadius: borderRadius !== undefined ? borderRadius : 16,
85
+ boxShadow: boxShadow !== undefined ? boxShadow : "none",
86
+ backgroundColor:
87
+ backgroundColor !== undefined
88
+ ? backgroundColor
89
+ : "hsl(var(--card))",
90
+ marginBottom: marginBottom,
91
+ ...restStyle,
92
+ }}
93
+ {...props}
94
+ >
95
+ {React.Children.map(children, (child) => {
96
+ if (React.isValidElement(child)) {
97
+ if (child.type === AccordionSummary) {
98
+ return React.cloneElement(child, {
99
+ expanded: currentExpanded,
100
+ onChange: handleChange,
101
+ id: `${accordionId}-summary`,
102
+ });
103
+ }
104
+ if (child.type === AccordionDetails) {
105
+ return React.cloneElement(child, {
106
+ expanded: currentExpanded,
107
+ id: `${accordionId}-content`,
108
+ });
109
+ }
110
+ }
111
+ return child;
112
+ })}
113
+ </div>
114
+ );
115
+ }
116
+ );
117
+ Accordion.displayName = "Accordion";
118
+
119
+ const AccordionSummary = React.forwardRef(
120
+ (
121
+ {
122
+ className,
123
+ style,
124
+ expandIcon,
125
+ children,
126
+ expanded,
127
+ onChange,
128
+ id,
129
+ ...props
130
+ },
131
+ ref
132
+ ) => {
133
+ // AccordionSummary receives onChange from Accordion which is handleChange
134
+ // handleChange expects (event) and will handle the expanded state internally
135
+ // Extract padding and backgroundColor from style to allow override
136
+ const {
137
+ padding,
138
+ paddingTop,
139
+ paddingBottom,
140
+ paddingLeft,
141
+ paddingRight,
142
+ backgroundColor,
143
+ ...restStyle
144
+ } = style || {};
145
+
146
+ // Check if padding is explicitly set in style
147
+ const hasPaddingInStyle =
148
+ padding !== undefined ||
149
+ paddingTop !== undefined ||
150
+ paddingBottom !== undefined ||
151
+ paddingLeft !== undefined ||
152
+ paddingRight !== undefined;
153
+
154
+ const defaultPaddingClass = hasPaddingInStyle ? "" : "py-2 px-4";
155
+ const minHeight = style?.minHeight !== undefined ? style.minHeight : "auto";
156
+
157
+ const contentId = id ? `${id}-content` : undefined;
158
+
159
+ return (
160
+ <button
161
+ ref={ref}
162
+ type="button"
163
+ id={id}
164
+ aria-expanded={expanded}
165
+ aria-controls={contentId}
166
+ onClick={(e) => {
167
+ e.preventDefault();
168
+ e.stopPropagation();
169
+ if (onChange) {
170
+ // AccordionSummary receives onChange from Accordion, which expects (event, expanded)
171
+ // But we need to call it with just the event, and Accordion will handle the expanded state
172
+ onChange(e);
173
+ }
174
+ }}
175
+ className={cn(
176
+ "w-full flex items-center justify-between transition-colors focus:outline-none",
177
+ defaultPaddingClass,
178
+ className
179
+ )}
180
+ style={{
181
+ border: "none",
182
+ borderTop: "none",
183
+ borderBottom: "none",
184
+ cursor: "pointer",
185
+ textAlign: "left",
186
+ backgroundColor:
187
+ backgroundColor !== undefined ? backgroundColor : "transparent",
188
+ minHeight: minHeight,
189
+ padding: padding,
190
+ paddingTop: paddingTop,
191
+ paddingBottom: paddingBottom,
192
+ paddingLeft: paddingLeft,
193
+ paddingRight: paddingRight,
194
+ ...restStyle,
195
+ }}
196
+ onKeyDown={(e) => {
197
+ if (e.key === "Enter" || e.key === " ") {
198
+ e.preventDefault();
199
+ if (onChange) {
200
+ onChange(e);
201
+ }
202
+ }
203
+ }}
204
+ {...props}
205
+ >
206
+ <div style={{ flex: 1 }}>{children}</div>
207
+ {expandIcon !== false &&
208
+ (expandIcon || (
209
+ <ChevronDown
210
+ size={20}
211
+ className="text-foreground"
212
+ style={{
213
+ transform: expanded ? "rotate(180deg)" : "rotate(0deg)",
214
+ transition: "transform 0.2s",
215
+ marginLeft: "0.5rem",
216
+ }}
217
+ />
218
+ ))}
219
+ </button>
220
+ );
221
+ }
222
+ );
223
+ AccordionSummary.displayName = "AccordionSummary";
224
+
225
+ const AccordionDetails = React.forwardRef(
226
+ ({ className, style, expanded, children, id, ...props }, ref) => {
227
+ if (!expanded) return null;
228
+
229
+ const {
230
+ backgroundColor: styleBackgroundColor,
231
+ padding,
232
+ paddingTop,
233
+ paddingBottom,
234
+ paddingLeft,
235
+ paddingRight,
236
+ ...restStyle
237
+ } = style || {};
238
+
239
+ // Remove padding-related properties from restStyle to avoid conflicts
240
+ const {
241
+ padding: _,
242
+ paddingTop: __,
243
+ paddingBottom: ___,
244
+ paddingLeft: ____,
245
+ paddingRight: _____,
246
+ ...cleanRestStyle
247
+ } = restStyle;
248
+
249
+ // Check if padding (all sides) is explicitly set
250
+ const hasPadding = padding !== undefined;
251
+
252
+ // Check if individual padding sides are set
253
+ const hasIndividualPadding =
254
+ paddingTop !== undefined ||
255
+ paddingBottom !== undefined ||
256
+ paddingLeft !== undefined ||
257
+ paddingRight !== undefined;
258
+
259
+ // Default padding: use "1rem" (16px) for all sides if no padding is set
260
+ // If padding is explicitly set, use it
261
+ // If individual paddings are set, don't set padding (let individual ones work)
262
+ // Otherwise use default "1rem"
263
+ const finalPadding = hasPadding
264
+ ? padding
265
+ : hasIndividualPadding
266
+ ? undefined
267
+ : "1rem";
268
+
269
+ // Build style object, only include padding properties if they are defined
270
+ const styleObj = {
271
+ backgroundColor: styleBackgroundColor || "transparent",
272
+ ...cleanRestStyle,
273
+ };
274
+
275
+ // Only set padding if finalPadding is defined
276
+ if (finalPadding !== undefined) {
277
+ styleObj.padding = finalPadding;
278
+ }
279
+
280
+ // Only set individual padding properties if they are defined
281
+ if (paddingTop !== undefined) styleObj.paddingTop = paddingTop;
282
+ if (paddingBottom !== undefined) styleObj.paddingBottom = paddingBottom;
283
+ if (paddingLeft !== undefined) styleObj.paddingLeft = paddingLeft;
284
+ if (paddingRight !== undefined) styleObj.paddingRight = paddingRight;
285
+
286
+ return (
287
+ <div
288
+ ref={ref}
289
+ id={id}
290
+ role="region"
291
+ aria-labelledby={id ? id.replace("-content", "-summary") : undefined}
292
+ className={cn("text-foreground", className)}
293
+ style={{
294
+ ...styleObj,
295
+ borderTop: "none",
296
+ }}
297
+ {...props}
298
+ >
299
+ {children}
300
+ </div>
301
+ );
302
+ }
303
+ );
304
+ AccordionDetails.displayName = "AccordionDetails";
305
+
306
+ export { Accordion, AccordionSummary, AccordionDetails };
@@ -0,0 +1,137 @@
1
+ import * as React from "react";
2
+ import { cn } from "../lib/utils";
3
+ import { AlertCircle, CheckCircle, Info, AlertTriangle, X } from "lucide-react";
4
+
5
+ const Alert = React.forwardRef(
6
+ (
7
+ {
8
+ className,
9
+ severity = "info",
10
+ variant = "standard",
11
+ onClose,
12
+ action,
13
+ icon,
14
+ iconMapping,
15
+ children,
16
+ style,
17
+ ...props
18
+ },
19
+ ref
20
+ ) => {
21
+ // Default icon mapping
22
+ const defaultIconMapping = {
23
+ error: AlertCircle,
24
+ warning: AlertTriangle,
25
+ info: Info,
26
+ success: CheckCircle,
27
+ };
28
+
29
+ // Check if icon is a React element (already rendered) or a component
30
+ const isReactElement = icon && typeof icon === "object" && icon.$$typeof;
31
+ const IconComponent =
32
+ !isReactElement &&
33
+ (icon || iconMapping?.[severity] || defaultIconMapping[severity] || Info);
34
+
35
+ // Get severity classes
36
+ const getSeverityClasses = () => {
37
+ const classes = {
38
+ error: {
39
+ standard: "bg-destructive/10 text-destructive",
40
+ filled: "bg-destructive text-destructive-foreground",
41
+ outlined: "border-destructive text-destructive bg-transparent",
42
+ },
43
+ warning: {
44
+ standard: "bg-warning/10 text-warning",
45
+ filled: "bg-warning text-warning-foreground",
46
+ outlined: "border-warning text-warning bg-transparent",
47
+ },
48
+ info: {
49
+ standard: "bg-info/10 text-info",
50
+ filled: "bg-info text-info-foreground",
51
+ outlined: "border-info text-info bg-transparent",
52
+ },
53
+ success: {
54
+ standard: "bg-success/10 text-success",
55
+ filled: "bg-success text-success-foreground",
56
+ outlined: "border-success text-success bg-transparent",
57
+ },
58
+ };
59
+ return classes[severity]?.[variant] || classes.info.standard;
60
+ };
61
+
62
+ const severityClasses = getSeverityClasses();
63
+
64
+ // Extract padding from style to allow override
65
+ const {
66
+ padding,
67
+ paddingTop,
68
+ paddingBottom,
69
+ paddingLeft,
70
+ paddingRight,
71
+ ...restStyle
72
+ } = style || {};
73
+
74
+ const hasPaddingInStyle =
75
+ padding !== undefined ||
76
+ paddingTop !== undefined ||
77
+ paddingBottom !== undefined ||
78
+ paddingLeft !== undefined ||
79
+ paddingRight !== undefined;
80
+
81
+ // Default padding class, but allow override
82
+ const defaultPaddingClass = hasPaddingInStyle ? "" : "p-4";
83
+
84
+ return (
85
+ <div
86
+ ref={ref}
87
+ role="alert"
88
+ className={cn(
89
+ "relative flex items-center gap-3 rounded-2xl text-sm",
90
+ defaultPaddingClass,
91
+ variant === "outlined" && "border",
92
+ severityClasses,
93
+ className
94
+ )}
95
+ style={{
96
+ padding: padding,
97
+ paddingTop: paddingTop,
98
+ paddingBottom: paddingBottom,
99
+ paddingLeft: paddingLeft,
100
+ paddingRight: paddingRight,
101
+ ...restStyle,
102
+ }}
103
+ {...props}
104
+ >
105
+ {icon !== false &&
106
+ (isReactElement ? (
107
+ <div className="flex-shrink-0 flex items-center text-current">
108
+ {icon}
109
+ </div>
110
+ ) : (
111
+ <IconComponent
112
+ size={20}
113
+ className="flex-shrink-0 text-current"
114
+ />
115
+ ))}
116
+ <div className="flex-1 flex items-center">{children}</div>
117
+ {(onClose || action) && (
118
+ <div className="flex items-center gap-1">
119
+ {action}
120
+ {onClose && (
121
+ <button
122
+ onClick={onClose}
123
+ className="flex items-center justify-center rounded-sm opacity-70 hover:opacity-100 transition-opacity p-2 text-current"
124
+ aria-label="Close"
125
+ >
126
+ <X size={16} />
127
+ </button>
128
+ )}
129
+ </div>
130
+ )}
131
+ </div>
132
+ );
133
+ }
134
+ );
135
+ Alert.displayName = "Alert";
136
+
137
+ export { Alert };
@@ -0,0 +1,105 @@
1
+ import * as React from "react";
2
+ import { cn } from "../lib/utils";
3
+
4
+ const AppBar = React.forwardRef(
5
+ (
6
+ {
7
+ className,
8
+ position = "fixed",
9
+ color = "default",
10
+ elevation = 4,
11
+ sx,
12
+ style,
13
+ children,
14
+ ...props
15
+ },
16
+ ref
17
+ ) => {
18
+ // Convert sx prop to style if provided
19
+ const sxStyles = React.useMemo(() => {
20
+ if (!sx) return {};
21
+ const sxObj = typeof sx === "function" ? sx({}) : sx;
22
+ return sxObj;
23
+ }, [sx]);
24
+
25
+ // Get elevation shadow (Material Design elevation system)
26
+ const getElevationShadow = () => {
27
+ const shadows = {
28
+ 0: "none",
29
+ 1: "0px 2px 1px -1px rgba(0,0,0,0.2), 0px 1px 1px 0px rgba(0,0,0,0.14), 0px 1px 3px 0px rgba(0,0,0,0.12)",
30
+ 2: "0px 3px 1px -2px rgba(0,0,0,0.2), 0px 2px 2px 0px rgba(0,0,0,0.14), 0px 1px 5px 0px rgba(0,0,0,0.12)",
31
+ 3: "0px 3px 3px -2px rgba(0,0,0,0.2), 0px 3px 4px 0px rgba(0,0,0,0.14), 0px 1px 8px 0px rgba(0,0,0,0.12)",
32
+ 4: "0px 2px 4px -1px rgba(0,0,0,0.2), 0px 4px 5px 0px rgba(0,0,0,0.14), 0px 1px 10px 0px rgba(0,0,0,0.12)",
33
+ 5: "0px 3px 5px -1px rgba(0,0,0,0.2), 0px 5px 8px 0px rgba(0,0,0,0.14), 0px 1px 14px 0px rgba(0,0,0,0.12)",
34
+ 6: "0px 3px 5px -1px rgba(0,0,0,0.2), 0px 6px 10px 0px rgba(0,0,0,0.14), 0px 1px 18px 0px rgba(0,0,0,0.12)",
35
+ 7: "0px 4px 5px -2px rgba(0,0,0,0.2), 0px 7px 10px 1px rgba(0,0,0,0.14), 0px 2px 16px 1px rgba(0,0,0,0.12)",
36
+ 8: "0px 5px 5px -3px rgba(0,0,0,0.2), 0px 8px 10px 1px rgba(0,0,0,0.14), 0px 3px 14px 2px rgba(0,0,0,0.12)",
37
+ 9: "0px 5px 6px -3px rgba(0,0,0,0.2), 0px 9px 12px 1px rgba(0,0,0,0.14), 0px 3px 16px 2px rgba(0,0,0,0.12)",
38
+ 10: "0px 6px 6px -3px rgba(0,0,0,0.2), 0px 10px 14px 1px rgba(0,0,0,0.14), 0px 4px 18px 3px rgba(0,0,0,0.12)",
39
+ 11: "0px 6px 7px -4px rgba(0,0,0,0.2), 0px 11px 15px 1px rgba(0,0,0,0.14), 0px 4px 20px 3px rgba(0,0,0,0.12)",
40
+ 12: "0px 7px 8px -4px rgba(0,0,0,0.2), 0px 12px 17px 2px rgba(0,0,0,0.14), 0px 5px 22px 4px rgba(0,0,0,0.12)",
41
+ 13: "0px 7px 8px -4px rgba(0,0,0,0.2), 0px 13px 19px 2px rgba(0,0,0,0.14), 0px 5px 24px 4px rgba(0,0,0,0.12)",
42
+ 14: "0px 7px 9px -4px rgba(0,0,0,0.2), 0px 14px 21px 2px rgba(0,0,0,0.14), 0px 5px 26px 4px rgba(0,0,0,0.12)",
43
+ 15: "0px 8px 9px -5px rgba(0,0,0,0.2), 0px 15px 22px 2px rgba(0,0,0,0.14), 0px 6px 28px 5px rgba(0,0,0,0.12)",
44
+ 16: "0px 8px 10px -5px rgba(0,0,0,0.2), 0px 16px 24px 2px rgba(0,0,0,0.14), 0px 6px 30px 5px rgba(0,0,0,0.12)",
45
+ 17: "0px 8px 11px -5px rgba(0,0,0,0.2), 0px 17px 26px 2px rgba(0,0,0,0.14), 0px 6px 32px 5px rgba(0,0,0,0.12)",
46
+ 18: "0px 9px 11px -5px rgba(0,0,0,0.2), 0px 18px 28px 2px rgba(0,0,0,0.14), 0px 7px 34px 6px rgba(0,0,0,0.12)",
47
+ 19: "0px 9px 12px -6px rgba(0,0,0,0.2), 0px 19px 29px 2px rgba(0,0,0,0.14), 0px 7px 36px 6px rgba(0,0,0,0.12)",
48
+ 20: "0px 10px 13px -6px rgba(0,0,0,0.2), 0px 20px 31px 3px rgba(0,0,0,0.14), 0px 8px 38px 7px rgba(0,0,0,0.12)",
49
+ 21: "0px 10px 13px -6px rgba(0,0,0,0.2), 0px 21px 33px 3px rgba(0,0,0,0.14), 0px 8px 40px 7px rgba(0,0,0,0.12)",
50
+ 22: "0px 10px 14px -6px rgba(0,0,0,0.2), 0px 22px 35px 3px rgba(0,0,0,0.14), 0px 8px 42px 7px rgba(0,0,0,0.12)",
51
+ 23: "0px 11px 14px -7px rgba(0,0,0,0.2), 0px 23px 36px 3px rgba(0,0,0,0.14), 0px 9px 44px 8px rgba(0,0,0,0.12)",
52
+ 24: "0px 11px 15px -7px rgba(0,0,0,0.2), 0px 24px 38px 3px rgba(0,0,0,0.14), 0px 9px 46px 8px rgba(0,0,0,0.12)",
53
+ };
54
+ // Clamp elevation to valid range and get shadow
55
+ const clampedElevation = Math.max(0, Math.min(24, Math.round(elevation)));
56
+ return { boxShadow: shadows[clampedElevation] || shadows[4] };
57
+ };
58
+
59
+ // Get color classes
60
+ const getColorClasses = () => {
61
+ if (color === "primary") return "bg-primary text-primary-foreground";
62
+ if (color === "secondary")
63
+ return "bg-secondary text-secondary-foreground";
64
+ if (color === "transparent") return "bg-transparent text-foreground";
65
+ return "bg-card text-foreground"; // default
66
+ };
67
+
68
+ // Set position styles for fixed/absolute/sticky positions
69
+ const positionStyles =
70
+ position === "fixed" || position === "absolute" || position === "sticky"
71
+ ? {
72
+ top: 0,
73
+ left: 0,
74
+ right: 0,
75
+ width: "100%",
76
+ }
77
+ : {};
78
+
79
+ return (
80
+ <div
81
+ ref={ref}
82
+ className={cn(
83
+ getColorClasses(),
84
+ "z-app-bar",
85
+ position === "static" || position === "relative" ? "w-full" : "",
86
+ className
87
+ )}
88
+ style={{
89
+ position: position,
90
+ ...positionStyles,
91
+ ...getElevationShadow(),
92
+ ...sxStyles,
93
+ ...style,
94
+ }}
95
+ {...props}
96
+ >
97
+ {children}
98
+ </div>
99
+ );
100
+ }
101
+ );
102
+
103
+ AppBar.displayName = "AppBar";
104
+
105
+ export { AppBar };