@musecat/uikit 0.1.1

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 (180) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +51 -0
  3. package/index.ts +78 -0
  4. package/package.json +103 -0
  5. package/packages/Components/Box/Box.tsx +173 -0
  6. package/packages/Components/Box/Box.types.ts +48 -0
  7. package/packages/Components/Button/Button.tsx +275 -0
  8. package/packages/Components/Button/Button.types.ts +44 -0
  9. package/packages/Components/Card/Card.default.tsx +180 -0
  10. package/packages/Components/Card/Card.foldable.tsx +383 -0
  11. package/packages/Components/Card/Card.module.scss +23 -0
  12. package/packages/Components/Card/Card.tsx +8 -0
  13. package/packages/Components/Card/Card.types.ts +91 -0
  14. package/packages/Components/Card/Card.utils.ts +66 -0
  15. package/packages/Components/Checkbox/Checkbox.module.scss +11 -0
  16. package/packages/Components/Checkbox/Checkbox.tsx +104 -0
  17. package/packages/Components/Checkbox/Checkbox.types.ts +24 -0
  18. package/packages/Components/CodeBox/CodeBox.copy.tsx +43 -0
  19. package/packages/Components/CodeBox/CodeBox.module.scss +72 -0
  20. package/packages/Components/CodeBox/CodeBox.tsx +91 -0
  21. package/packages/Components/CodeBox/CodeBox.types.ts +17 -0
  22. package/packages/Components/ContextMenu/ContextMenu.module.scss +8 -0
  23. package/packages/Components/ContextMenu/ContextMenu.options.tsx +126 -0
  24. package/packages/Components/ContextMenu/ContextMenu.tsx +381 -0
  25. package/packages/Components/ContextMenu/ContextMenu.types.ts +46 -0
  26. package/packages/Components/ContributionGraph/ContributionGraph.module.scss +42 -0
  27. package/packages/Components/ContributionGraph/ContributionGraph.tsx +454 -0
  28. package/packages/Components/ContributionGraph/ContributionGraph.types.ts +27 -0
  29. package/packages/Components/DatePicker/DatePicker.calendar.tsx +161 -0
  30. package/packages/Components/DatePicker/DatePicker.core.tsx +582 -0
  31. package/packages/Components/DatePicker/DatePicker.module.scss +26 -0
  32. package/packages/Components/DatePicker/DatePicker.tsx +786 -0
  33. package/packages/Components/DatePicker/DatePicker.types.ts +36 -0
  34. package/packages/Components/DatePicker/DatePicker.utils.ts +80 -0
  35. package/packages/Components/DatePicker/hooks/useCalendar.ts +61 -0
  36. package/packages/Components/DatePicker/hooks/useSelection.ts +208 -0
  37. package/packages/Components/Divider/Divider.tsx +46 -0
  38. package/packages/Components/Divider/Divider.types.ts +12 -0
  39. package/packages/Components/Header/Header.module.scss +74 -0
  40. package/packages/Components/Header/Header.tsx +47 -0
  41. package/packages/Components/Header/Header.types.ts +8 -0
  42. package/packages/Components/Icon/Icon.group.tsx +122 -0
  43. package/packages/Components/Icon/Icon.group.types.ts +20 -0
  44. package/packages/Components/Icon/Icon.tsx +341 -0
  45. package/packages/Components/Icon/Icon.types.ts +59 -0
  46. package/packages/Components/Icon/SVG/data.tsx +232 -0
  47. package/packages/Components/Input/Input.module.scss +5 -0
  48. package/packages/Components/Input/Input.tsx +87 -0
  49. package/packages/Components/Input/Input.types.ts +14 -0
  50. package/packages/Components/Label/Label.module.scss +19 -0
  51. package/packages/Components/Label/Label.tsx +115 -0
  52. package/packages/Components/Label/Label.types.ts +28 -0
  53. package/packages/Components/Layout/Layout.docs.module.scss +42 -0
  54. package/packages/Components/Layout/Layout.docs.tsx +150 -0
  55. package/packages/Components/Layout/Layout.docs.types.ts +18 -0
  56. package/packages/Components/Layout/Layout.module.scss +91 -0
  57. package/packages/Components/Layout/Layout.tsx +306 -0
  58. package/packages/Components/Layout/Layout.types.ts +71 -0
  59. package/packages/Components/Maps/OSM/MapOSM.module.scss +11 -0
  60. package/packages/Components/Maps/OSM/MapOSM.shared.ts +121 -0
  61. package/packages/Components/Maps/OSM/MapOSM.tsx +279 -0
  62. package/packages/Components/Maps/OSM/MapOSM.types.ts +18 -0
  63. package/packages/Components/Nav/Nav.module.scss +137 -0
  64. package/packages/Components/Nav/Nav.tsx +304 -0
  65. package/packages/Components/Nav/Nav.types.ts +32 -0
  66. package/packages/Components/Nav/hooks/useNavDrag.ts +374 -0
  67. package/packages/Components/Nav/hooks/useNavIndicator.ts +137 -0
  68. package/packages/Components/Pagination/Pagination.tsx +254 -0
  69. package/packages/Components/Pagination/Pagination.types.ts +18 -0
  70. package/packages/Components/Pill/Pill.tsx +127 -0
  71. package/packages/Components/Pill/Pill.types.ts +33 -0
  72. package/packages/Components/Profile/Profile.shared.ts +74 -0
  73. package/packages/Components/Profile/Profile.tsx +382 -0
  74. package/packages/Components/Profile/Profile.types.ts +55 -0
  75. package/packages/Components/Progress/Progress.module.scss +15 -0
  76. package/packages/Components/Progress/Progress.tsx +88 -0
  77. package/packages/Components/Progress/Progress.types.ts +22 -0
  78. package/packages/Components/Radio/Radio.module.scss +11 -0
  79. package/packages/Components/Radio/Radio.tsx +121 -0
  80. package/packages/Components/Radio/Radio.types.ts +20 -0
  81. package/packages/Components/Select/Select.keyboard.tsx +76 -0
  82. package/packages/Components/Select/Select.trigger.tsx +88 -0
  83. package/packages/Components/Select/Select.tsx +11 -0
  84. package/packages/Components/Select/Select.types.ts +38 -0
  85. package/packages/Components/Select/Select.utils.ts +84 -0
  86. package/packages/Components/Select/hooks/useSelectNavigation.ts +461 -0
  87. package/packages/Components/Select/hooks/useSelectSelection.ts +142 -0
  88. package/packages/Components/Select/hooks/useSelectState.ts +314 -0
  89. package/packages/Components/Select/select.control.tsx +228 -0
  90. package/packages/Components/Select/select.inner.tsx +312 -0
  91. package/packages/Components/Skeleton/Skeleton.tsx +30 -0
  92. package/packages/Components/Skeleton/Skeleton.types.ts +12 -0
  93. package/packages/Components/Spinner/Spinner.module.scss +78 -0
  94. package/packages/Components/Spinner/Spinner.tsx +125 -0
  95. package/packages/Components/Spinner/Spinner.types.ts +19 -0
  96. package/packages/Components/Text/Text.module.scss +7 -0
  97. package/packages/Components/Text/Text.tsx +49 -0
  98. package/packages/Components/Text/Text.types.ts +33 -0
  99. package/packages/Components/TimePicker/TimePicker.core.tsx +448 -0
  100. package/packages/Components/TimePicker/TimePicker.module.scss +30 -0
  101. package/packages/Components/TimePicker/TimePicker.tsx +511 -0
  102. package/packages/Components/TimePicker/TimePicker.types.ts +22 -0
  103. package/packages/Components/Timeline/Timeline.tsx +111 -0
  104. package/packages/Components/Timeline/Timeline.types.ts +23 -0
  105. package/packages/Components/Title/Title.tsx +305 -0
  106. package/packages/Components/Title/Title.types.ts +64 -0
  107. package/packages/Components/Toggle/Toggle.module.scss +32 -0
  108. package/packages/Components/Toggle/Toggle.tsx +272 -0
  109. package/packages/Components/Toggle/Toggle.types.ts +17 -0
  110. package/packages/Components/Tooltip/Tooltip.module.scss +44 -0
  111. package/packages/Components/Tooltip/Tooltip.tsx +340 -0
  112. package/packages/Components/Tooltip/Tooltip.types.ts +38 -0
  113. package/packages/Frameworks/Dialog/Dialog.background.tsx +88 -0
  114. package/packages/Frameworks/Dialog/Dialog.boot.tsx +32 -0
  115. package/packages/Frameworks/Dialog/Dialog.store.ts +199 -0
  116. package/packages/Frameworks/Dialog/Dialog.tsx +185 -0
  117. package/packages/Frameworks/Dialog/Dialog.types.ts +264 -0
  118. package/packages/Frameworks/Dialog/Dialog.utils.ts +22 -0
  119. package/packages/Frameworks/Dialog/contents/Dialog.footer.tsx +79 -0
  120. package/packages/Frameworks/Dialog/contents/Dialog.funnel.tsx +260 -0
  121. package/packages/Frameworks/Dialog/contents/Dialog.header.tsx +137 -0
  122. package/packages/Frameworks/Dialog/hooks/useDialogPosition.ts +298 -0
  123. package/packages/Frameworks/Dialog/hooks/useSheetDrag.ts +325 -0
  124. package/packages/Frameworks/Dialog/hooks/useSheetGeometry.ts +201 -0
  125. package/packages/Frameworks/Dialog/hooks/useSheetProgressive.ts +98 -0
  126. package/packages/Frameworks/Dialog/renderers/renderModal.tsx +228 -0
  127. package/packages/Frameworks/Dialog/renderers/renderPopover.tsx +220 -0
  128. package/packages/Frameworks/Dialog/renderers/renderSheet.tsx +571 -0
  129. package/packages/Frameworks/EdgeEffect/EdgeEffect.tsx +52 -0
  130. package/packages/Frameworks/EdgeEffect/EdgeEffect.types.ts +5 -0
  131. package/packages/Frameworks/Motion/Motion.presets.ts +49 -0
  132. package/packages/Frameworks/Pressable/Pressable.module.scss +19 -0
  133. package/packages/Frameworks/Pressable/Pressable.tsx +651 -0
  134. package/packages/Frameworks/Pressable/Pressable.types.ts +73 -0
  135. package/packages/Frameworks/Squircle/Squircle.tsx +263 -0
  136. package/packages/Frameworks/Squircle/Squircle.types.ts +15 -0
  137. package/packages/Frameworks/Theme/Radius.types.ts +55 -0
  138. package/packages/Frameworks/Theme/Theme.types.ts +325 -0
  139. package/packages/Frameworks/Toaster/Toaster.boot.tsx +47 -0
  140. package/packages/Frameworks/Toaster/Toaster.module.scss +168 -0
  141. package/packages/Frameworks/Toaster/Toaster.types.ts +13 -0
  142. package/packages/Frameworks/View/DNDView/DNDView.module.scss +8 -0
  143. package/packages/Frameworks/View/DNDView/DNDView.tsx +470 -0
  144. package/packages/Frameworks/View/DNDView/DNDView.types.ts +61 -0
  145. package/packages/Frameworks/View/HScrollView/HScrollView.module.scss +59 -0
  146. package/packages/Frameworks/View/HScrollView/HScrollView.tsx +386 -0
  147. package/packages/Frameworks/View/HScrollView/HScrollView.types.ts +46 -0
  148. package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.counter.tsx +27 -0
  149. package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.footer.tsx +76 -0
  150. package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.header.tsx +49 -0
  151. package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.list.tsx +74 -0
  152. package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.slide.tsx +71 -0
  153. package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.tsx +175 -0
  154. package/packages/Frameworks/View/ImageView/Image.controls.tsx +39 -0
  155. package/packages/Frameworks/View/ImageView/Image.hooks.ts +82 -0
  156. package/packages/Frameworks/View/ImageView/Image.module.scss +7 -0
  157. package/packages/Frameworks/View/ImageView/Image.tsx +375 -0
  158. package/packages/Frameworks/View/ImageView/Image.types.ts +71 -0
  159. package/packages/Frameworks/View/ImageView/Image.utils.ts +79 -0
  160. package/packages/Frameworks/View/View.module.scss +34 -0
  161. package/packages/Frameworks/View/View.tsx +200 -0
  162. package/packages/Frameworks/View/View.types.ts +36 -0
  163. package/packages/Frameworks/_shared/Padding.types.ts +52 -0
  164. package/packages/Frameworks/_shared/StopParentInteraction.tsx +45 -0
  165. package/packages/Frameworks/_shared/Wind.types.ts +17 -0
  166. package/packages/Frameworks/_shared/bodyScrollLock.ts +127 -0
  167. package/packages/Frameworks/_shared/layer.constants.ts +8 -0
  168. package/packages/Frameworks/_shared/normalize.ts +39 -0
  169. package/packages/Frameworks/_shared/sizing.ts +55 -0
  170. package/packages/Frameworks/_shared/useControllableState.ts +29 -0
  171. package/packages/Styles/_animation.scss +42 -0
  172. package/packages/Styles/_color.scss +131 -0
  173. package/packages/Styles/_font.scss +30 -0
  174. package/packages/Styles/_icon.scss +782 -0
  175. package/packages/Styles/_importer.scss +9 -0
  176. package/packages/Styles/_system.scss +69 -0
  177. package/packages/Styles/_textstyle.scss +111 -0
  178. package/packages/Styles/_theme.scss +452 -0
  179. package/packages/Styles/_viewport-global.scss +99 -0
  180. package/packages/Styles/_viewport.scss +108 -0
@@ -0,0 +1,73 @@
1
+ import type { MotionProps } from "motion/react";
2
+ import type { LinkProps } from "next/link";
3
+ import type { PaddingProps } from "@/packages/Frameworks/_shared/Padding.types";
4
+ import type { WindProps } from "@/packages/Frameworks/_shared/Wind.types";
5
+ import type { PopoverConfig } from "@/packages/Frameworks/Dialog/Dialog.types";
6
+ import type { RadiusProps } from "@/packages/Frameworks/Theme/Radius.types";
7
+ import type {
8
+ BorderProps,
9
+ ThemeSystemProps,
10
+ } from "@/packages/Frameworks/Theme/Theme.types";
11
+ export interface PressableProps
12
+ extends Omit<
13
+ React.HTMLAttributes<HTMLElement>,
14
+ "title" | "onClick" | "onChange" | "value" | "checked" | "type" | "disabled" | "tabIndex" | "popover" | "color"
15
+ >,
16
+ ThemeSystemProps,
17
+ BorderProps,
18
+ RadiusProps,
19
+ PaddingProps,
20
+ WindProps {
21
+ "data-color-mode"?: string;
22
+ motion?: MotionProps;
23
+ children?: React.ReactNode;
24
+ className?: string;
25
+ style?: React.CSSProperties;
26
+ form?: true | Omit<React.ComponentProps<"form">, "children">;
27
+ href?: LinkProps["href"];
28
+ target?: HTMLAnchorElement["target"];
29
+ rel?: HTMLAnchorElement["rel"];
30
+ download?: React.AnchorHTMLAttributes<HTMLAnchorElement>["download"];
31
+ checked?: HTMLInputElement["checked"];
32
+ onClick?: (e: React.MouseEvent) => void;
33
+ onChange?: (e: React.ChangeEvent) => void;
34
+ title?: string;
35
+ "aria-label"?: string;
36
+ "aria-labelledby"?: string;
37
+ "aria-describedby"?: string;
38
+ "aria-controls"?: string;
39
+ "aria-expanded"?: boolean;
40
+ "aria-haspopup"?: React.AriaAttributes["aria-haspopup"];
41
+ type?: HTMLButtonElement["type"] | "checkbox" | "radio";
42
+ disabled?: boolean;
43
+ readOnly?: boolean;
44
+ value?: string | number;
45
+ name?: string;
46
+ ref?: React.Ref<HTMLElement>;
47
+ onMouseEnter?: (e: React.MouseEvent) => void;
48
+ onMouseLeave?: (e: React.MouseEvent) => void;
49
+ onMouseDown?: (e: React.MouseEvent) => void;
50
+ onMouseUp?: (e: React.MouseEvent) => void;
51
+ onPointerDown?: (e: React.PointerEvent) => void;
52
+ onPointerUp?: (e: React.PointerEvent) => void;
53
+ onPointerCancel?: (e: React.PointerEvent) => void;
54
+ onPointerLeave?: (e: React.PointerEvent) => void;
55
+ onTouchStart?: (e: React.TouchEvent) => void;
56
+ onTouchEnd?: (e: React.TouchEvent) => void;
57
+ onTouchCancel?: (e: React.TouchEvent) => void;
58
+ onContextMenu?: (e: React.MouseEvent) => void;
59
+ onKeyDown?: (e: React.KeyboardEvent) => void;
60
+ onKeyUp?: (e: React.KeyboardEvent) => void;
61
+ onLongPress?: (e: React.MouseEvent | React.TouchEvent) => void;
62
+ onLongPressEnd?: (e: React.MouseEvent | React.TouchEvent) => void;
63
+ longPressDelay?: number;
64
+ tabIndex?: number;
65
+ popover?: Omit<PopoverConfig, "anchorRef"> & {
66
+ content: React.ReactNode;
67
+ open?: boolean;
68
+ defaultOpen?: boolean;
69
+ onOpenChange?: (open: boolean) => void;
70
+ closeOnOutsideClick?: boolean;
71
+ recalcKey?: string | number;
72
+ };
73
+ }
@@ -0,0 +1,263 @@
1
+ "use client";
2
+
3
+ import { getSvgPath } from "figma-squircle";
4
+ import { motion } from "motion/react";
5
+ import {
6
+ forwardRef,
7
+ type Ref,
8
+ useCallback,
9
+ useLayoutEffect,
10
+ useMemo,
11
+ useRef,
12
+ useState,
13
+ } from "react";
14
+ import {
15
+ getComputedPixelValue,
16
+ SizePX,
17
+ } from "@/packages/Frameworks/_shared/sizing";
18
+ import type { SquircleProps } from "@/packages/Frameworks/Squircle/Squircle.types";
19
+ import { Radius as resolveRadius } from "@/packages/Frameworks/Theme/Radius.types";
20
+
21
+ function resolveCornerRadius(
22
+ radius: SquircleProps["radius"],
23
+ fallback: number,
24
+ ) {
25
+ if (Array.isArray(radius)) return undefined;
26
+ if (typeof radius === "number") return SizePX(radius, fallback);
27
+ if (typeof radius === "string") return SizePX(radius, fallback);
28
+ return fallback;
29
+ }
30
+
31
+ function resolveCornerRadiusValue(
32
+ radius: SquircleProps["radius"],
33
+ fallback: number,
34
+ ) {
35
+ return resolveCornerRadius(radius, fallback) ?? fallback;
36
+ }
37
+
38
+ function resolveCornerRadii(radius: SquircleProps["radius"], fallback: number) {
39
+ if (!Array.isArray(radius)) {
40
+ const value = resolveCornerRadiusValue(radius, fallback);
41
+
42
+ return {
43
+ topLeft: value,
44
+ topRight: value,
45
+ bottomRight: value,
46
+ bottomLeft: value,
47
+ };
48
+ }
49
+
50
+ const topLeft = resolveCornerRadiusValue(radius[0], fallback);
51
+ const topRight = resolveCornerRadiusValue(radius[1] ?? radius[0], fallback);
52
+ const bottomRight = resolveCornerRadiusValue(
53
+ radius[2] ?? radius[0],
54
+ fallback,
55
+ );
56
+ const bottomLeft = resolveCornerRadiusValue(
57
+ radius[3] ?? radius[1] ?? radius[0],
58
+ fallback,
59
+ );
60
+
61
+ return {
62
+ topLeft,
63
+ topRight,
64
+ bottomRight,
65
+ bottomLeft,
66
+ };
67
+ }
68
+
69
+ function resolvePathCornerRadius(
70
+ cornerRadius: number | undefined,
71
+ computedCornerRadius: number | undefined,
72
+ fallbackCornerRadius: number,
73
+ ) {
74
+ return cornerRadius ?? computedCornerRadius ?? fallbackCornerRadius;
75
+ }
76
+
77
+ function setRef(ref: Ref<HTMLElement> | undefined, value: HTMLElement | null) {
78
+ if (!ref) return;
79
+ if (typeof ref === "function") {
80
+ ref(value);
81
+ return;
82
+ }
83
+ (ref as any).current = value;
84
+ }
85
+
86
+ function getElementSize(
87
+ element: HTMLElement,
88
+ defaultWidth?: number,
89
+ defaultHeight?: number,
90
+ ) {
91
+ const rect = element.getBoundingClientRect();
92
+
93
+ return {
94
+ width:
95
+ element.offsetWidth ||
96
+ element.clientWidth ||
97
+ element.scrollWidth ||
98
+ rect.width ||
99
+ defaultWidth ||
100
+ 0,
101
+ height:
102
+ element.offsetHeight ||
103
+ element.clientHeight ||
104
+ element.scrollHeight ||
105
+ rect.height ||
106
+ defaultHeight ||
107
+ 0,
108
+ };
109
+ }
110
+
111
+ const Squircle = forwardRef<HTMLElement, SquircleProps>(function Squircle(
112
+ {
113
+ as: Component = "div",
114
+ radius,
115
+ cornerRadius,
116
+ cornerSmoothing,
117
+ defaultWidth,
118
+ defaultHeight,
119
+ preserveSmoothing,
120
+ motion: motionProps,
121
+ children,
122
+ style,
123
+ ...props
124
+ },
125
+ ref,
126
+ ) {
127
+ const elementRef = useRef<HTMLElement | null>(null);
128
+ const [size, setSize] = useState({
129
+ width: defaultWidth ?? 0,
130
+ height: defaultHeight ?? 0,
131
+ });
132
+ const [computedCornerRadius, setComputedCornerRadius] = useState<{
133
+ topLeft?: number;
134
+ topRight?: number;
135
+ bottomRight?: number;
136
+ bottomLeft?: number;
137
+ }>({});
138
+
139
+ const resolvedRadius = resolveRadius(radius);
140
+ const _fallbackCornerRadius = resolveCornerRadius(radius, 8) ?? 8;
141
+ const fallbackCornerRadii = resolveCornerRadii(radius, 8);
142
+ const resolvedCornerRadii = {
143
+ topLeft: resolvePathCornerRadius(
144
+ cornerRadius,
145
+ computedCornerRadius.topLeft,
146
+ fallbackCornerRadii.topLeft,
147
+ ),
148
+ topRight: resolvePathCornerRadius(
149
+ cornerRadius,
150
+ computedCornerRadius.topRight,
151
+ fallbackCornerRadii.topRight,
152
+ ),
153
+ bottomRight: resolvePathCornerRadius(
154
+ cornerRadius,
155
+ computedCornerRadius.bottomRight,
156
+ fallbackCornerRadii.bottomRight,
157
+ ),
158
+ bottomLeft: resolvePathCornerRadius(
159
+ cornerRadius,
160
+ computedCornerRadius.bottomLeft,
161
+ fallbackCornerRadii.bottomLeft,
162
+ ),
163
+ };
164
+ const setElementRef = useCallback(
165
+ (element: HTMLElement | null) => {
166
+ elementRef.current = element;
167
+ setRef(ref, element);
168
+ },
169
+ [ref],
170
+ );
171
+
172
+ useLayoutEffect(() => {
173
+ const element = elementRef.current;
174
+ if (!element) return;
175
+
176
+ const updateSize = () => {
177
+ setSize(getElementSize(element, defaultWidth, defaultHeight));
178
+ setComputedCornerRadius({
179
+ topLeft: getComputedPixelValue(element, "borderTopLeftRadius") ?? 0,
180
+ topRight: getComputedPixelValue(element, "borderTopRightRadius") ?? 0,
181
+ bottomRight:
182
+ getComputedPixelValue(element, "borderBottomRightRadius") ?? 0,
183
+ bottomLeft:
184
+ getComputedPixelValue(element, "borderBottomLeftRadius") ?? 0,
185
+ });
186
+ };
187
+ updateSize();
188
+
189
+ const observer = new ResizeObserver(updateSize);
190
+ observer.observe(element);
191
+ return () => observer.disconnect();
192
+ }, [defaultHeight, defaultWidth]);
193
+
194
+ const clipPath =
195
+ size.width && size.height
196
+ ? `path('${getSvgPath({
197
+ width: size.width,
198
+ height: size.height,
199
+ topLeftCornerRadius: resolvedCornerRadii.topLeft,
200
+ topRightCornerRadius: resolvedCornerRadii.topRight,
201
+ bottomRightCornerRadius: resolvedCornerRadii.bottomRight,
202
+ bottomLeftCornerRadius: resolvedCornerRadii.bottomLeft,
203
+ cornerSmoothing: 0.6,
204
+ preserveSmoothing,
205
+ })}')`
206
+ : undefined;
207
+
208
+ const motionEnabled = Boolean(motionProps);
209
+ const MotionElement = useMemo(() => {
210
+ if (!motionEnabled) return null;
211
+ if (typeof Component === "string") return (motion as any)[Component];
212
+ return motion.create(Component);
213
+ }, [Component, motionEnabled]);
214
+
215
+ const {
216
+ background,
217
+ backgroundColor,
218
+ backdropFilter,
219
+ WebkitBackdropFilter,
220
+ ...restStyle
221
+ } = style || {};
222
+
223
+ const sharedStyle = {
224
+ borderRadius: resolvedRadius ?? resolvedCornerRadii.topLeft,
225
+ "--squircle-clip": clipPath,
226
+ ...(background !== undefined ? { "--theme-bg": background } : {}),
227
+ ...(backgroundColor !== undefined ? { "--theme-bg": backgroundColor } : {}),
228
+ ...(backdropFilter !== undefined
229
+ ? { "--theme-backdrop-filter": backdropFilter }
230
+ : {}),
231
+ ...(WebkitBackdropFilter !== undefined
232
+ ? { "--theme-backdrop-filter": WebkitBackdropFilter }
233
+ : {}),
234
+ ...restStyle,
235
+ } as any;
236
+
237
+ if (MotionElement) {
238
+ return (
239
+ <MotionElement
240
+ {...(motionProps as any)}
241
+ {...(props as any)}
242
+ ref={setElementRef as any}
243
+ data-squircle={resolvedCornerRadii.topLeft}
244
+ style={sharedStyle}
245
+ >
246
+ {children}
247
+ </MotionElement>
248
+ );
249
+ }
250
+
251
+ return (
252
+ <Component
253
+ {...props}
254
+ ref={setElementRef as any}
255
+ data-squircle={resolvedCornerRadii.topLeft}
256
+ style={sharedStyle}
257
+ >
258
+ {children}
259
+ </Component>
260
+ );
261
+ });
262
+
263
+ export default Squircle;
@@ -0,0 +1,15 @@
1
+ import type { MotionProps } from "motion/react";
2
+ import type { ElementType, HTMLAttributes } from "react";
3
+ import type { RadiusValue } from "@/packages/Frameworks/Theme/Radius.types";
4
+
5
+ export interface SquircleProps
6
+ extends Omit<HTMLAttributes<HTMLElement>, "color"> {
7
+ as?: ElementType;
8
+ radius?: RadiusValue;
9
+ cornerRadius?: number;
10
+ cornerSmoothing?: number;
11
+ defaultWidth?: number;
12
+ defaultHeight?: number;
13
+ preserveSmoothing?: boolean;
14
+ motion?: MotionProps;
15
+ }
@@ -0,0 +1,55 @@
1
+ import {
2
+ Size,
3
+ type UIKitSizeValue,
4
+ } from "@/packages/Frameworks/_shared/sizing";
5
+
6
+ type RadiusScale =
7
+ | "None"
8
+ | "ExtraLight"
9
+ | "Light"
10
+ | "Regular"
11
+ | "Bold"
12
+ | "ExtraBold"
13
+ | "Heavy"
14
+ | "Circle";
15
+ export type RadiusUnitValue = RadiusScale | UIKitSizeValue;
16
+ type RadiusArrayValue = RadiusUnitValue;
17
+
18
+ export type RadiusValue =
19
+ | RadiusUnitValue
20
+ | readonly [RadiusUnitValue]
21
+ | readonly [RadiusArrayValue, RadiusArrayValue]
22
+ | readonly [RadiusArrayValue, RadiusArrayValue, RadiusArrayValue]
23
+ | readonly [
24
+ RadiusArrayValue,
25
+ RadiusArrayValue,
26
+ RadiusArrayValue,
27
+ RadiusArrayValue,
28
+ ];
29
+ export interface RadiusProps {
30
+ radius?: RadiusValue;
31
+ }
32
+
33
+ const RADIUS_TOKEN: Partial<Record<RadiusScale, string | number>> = {
34
+ None: 0,
35
+ ExtraLight: "var(--radius-system-extra-light)",
36
+ Light: "var(--radius-system-light)",
37
+ Regular: "var(--radius-system)",
38
+ Bold: "var(--radius-system-bold)",
39
+ ExtraBold: "var(--radius-system-extra-bold)",
40
+ Heavy: "var(--radius-system-heavy)",
41
+ Circle: "var(--radius-circle)",
42
+ };
43
+
44
+ export function Radius(radius?: RadiusValue): string | number | undefined {
45
+ if (Array.isArray(radius)) {
46
+ return radius.map((value) => Radius(value)).join(" ");
47
+ }
48
+
49
+ if (typeof radius === "string") {
50
+ return RADIUS_TOKEN[radius as RadiusScale] ?? Size(radius);
51
+ }
52
+ if (typeof radius === "number") {
53
+ return Size(radius);
54
+ }
55
+ }