@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,275 @@
1
+ "use client";
2
+
3
+ import clsx from "clsx";
4
+ import type { ButtonProps } from "@/packages/Components/Button/Button.types";
5
+ import Divider from "@/packages/Components/Divider/Divider";
6
+ import Icon from "@/packages/Components/Icon/Icon";
7
+ import Text from "@/packages/Components/Text/Text";
8
+ import Pressable from "@/packages/Frameworks/Pressable/Pressable";
9
+ import View from "@/packages/Frameworks/View/View";
10
+
11
+ function resolveButtonEndIcon(iconEnd: ButtonProps["iconEnd"]) {
12
+ if (!iconEnd?.pressable?.popover) {
13
+ return iconEnd;
14
+ }
15
+ return {
16
+ ...iconEnd,
17
+ pressable: {
18
+ ...iconEnd.pressable,
19
+ popover: {
20
+ ...iconEnd.pressable.popover,
21
+ placement: iconEnd.pressable.popover.placement ?? "bottom",
22
+ },
23
+ },
24
+ };
25
+ }
26
+
27
+ function ButtonContent({
28
+ icon,
29
+ text,
30
+ textType,
31
+ column,
32
+ reversed,
33
+ promise,
34
+ }: Pick<
35
+ ButtonProps,
36
+ "icon" | "text" | "textType" | "column" | "reversed" | "promise"
37
+ >) {
38
+ if (promise?.type) {
39
+ const isError = promise.type === "error";
40
+ const isSuccess = promise.type === "success";
41
+ const isLoading = promise.type === "loading";
42
+
43
+ return (
44
+ <View alignItems="center" column={column} gap={column ? 4 : 8}>
45
+ {(isError || isSuccess) && (
46
+ <Icon
47
+ size={18}
48
+ {...icon}
49
+ icon={isError ? "iWarningCircle" : "iCheckCircle"}
50
+ />
51
+ )}
52
+ {isLoading && <Icon spinner size={18} />}
53
+ <Text
54
+ type={textType || "Subheadline"}
55
+ style={{ order: reversed ? -1 : 0 }}
56
+ >
57
+ {promise.text ||
58
+ (isError ? "Error" : isSuccess ? "Success" : "Loading...")}
59
+ </Text>
60
+ </View>
61
+ );
62
+ }
63
+
64
+ return (
65
+ <View alignItems="center" column={column} gap={column ? 4 : 8}>
66
+ {icon && <Icon size={column ? 22 : 18} {...icon} />}
67
+ {text && (
68
+ <Text
69
+ type={textType || (column ? "Caption1" : "Subheadline")}
70
+ style={{ order: reversed ? -1 : 0 }}
71
+ >
72
+ {text}
73
+ </Text>
74
+ )}
75
+ </View>
76
+ );
77
+ }
78
+
79
+ export function Button({
80
+ themePreset,
81
+ background,
82
+ color,
83
+ themeInteractive,
84
+ selected,
85
+ border,
86
+ radius,
87
+ shadow,
88
+ icon,
89
+ pressable,
90
+ textType,
91
+ sizeFull,
92
+ promise,
93
+ text,
94
+ style,
95
+ className,
96
+ column,
97
+ padding,
98
+ paddingHorizontal,
99
+ paddingVertical,
100
+ modal,
101
+ iconEnd,
102
+ "data-color-mode": dataColorMode,
103
+ reversed,
104
+ }: ButtonProps) {
105
+ const resolvedIconEnd = resolveButtonEndIcon(iconEnd);
106
+ const isDisabledByPromise =
107
+ promise?.type === "loading" ||
108
+ promise?.type === "error" ||
109
+ promise?.type === "success";
110
+ const resolvedRadius = radius ?? (modal ? "Circle" : "Regular");
111
+ const resolvedPreset = themePreset ?? "UIPrimary";
112
+
113
+ if (resolvedIconEnd) {
114
+ return (
115
+ <View
116
+ data-color-mode={dataColorMode}
117
+ background={background}
118
+ color={color}
119
+ border={border}
120
+ radius={resolvedRadius}
121
+ shadow={shadow}
122
+ className={className}
123
+ fullWidth={modal || sizeFull}
124
+ width={modal || sizeFull ? undefined : "max-content"}
125
+ alignItems="stretch"
126
+ gap={0}
127
+ style={{
128
+ overflow: "hidden",
129
+ ...style,
130
+ }}
131
+ >
132
+ {}
133
+ <Pressable
134
+ {...pressable}
135
+ themePreset={resolvedPreset}
136
+ themeInteractive={themeInteractive ?? true}
137
+ selected={selected}
138
+ disabled={isDisabledByPromise || pressable?.disabled}
139
+ className={pressable?.className}
140
+ alignItems="center"
141
+ justifyContent="center"
142
+ padding={modal ? 16 : (padding ?? 12)}
143
+ paddingHorizontal={paddingHorizontal}
144
+ paddingVertical={paddingVertical}
145
+ style={{
146
+ position: "relative",
147
+ textAlign: "center",
148
+ flex: "1 1 auto",
149
+ height: "auto",
150
+ ...pressable?.style,
151
+ }}
152
+ title={pressable?.title}
153
+ >
154
+ <ButtonContent
155
+ icon={icon}
156
+ text={text}
157
+ textType={textType}
158
+ column={column}
159
+ reversed={reversed}
160
+ promise={promise}
161
+ />
162
+ <Divider
163
+ vertical
164
+ style={{
165
+ position: "absolute",
166
+ right: 0,
167
+ top: "18%",
168
+ bottom: "18%",
169
+ width: ".1rem",
170
+ zIndex: 1,
171
+ pointerEvents: "none",
172
+ }}
173
+ />
174
+ </Pressable>
175
+
176
+ {}
177
+ <Pressable
178
+ {...resolvedIconEnd.pressable}
179
+ themePreset={resolvedIconEnd.pressable?.themePreset ?? resolvedPreset}
180
+ themeInteractive={
181
+ resolvedIconEnd.pressable?.themeInteractive ??
182
+ themeInteractive ??
183
+ true
184
+ }
185
+ selected={resolvedIconEnd.pressable?.selected ?? selected}
186
+ onClick={(event) => {
187
+ if (
188
+ !resolvedIconEnd.pressable?.popover &&
189
+ !resolvedIconEnd.pressable?.href
190
+ ) {
191
+ event.preventDefault();
192
+ }
193
+ event.stopPropagation();
194
+ resolvedIconEnd.pressable?.onClick?.(event as never);
195
+ }}
196
+ onMouseDown={(event) => {
197
+ event.stopPropagation();
198
+ resolvedIconEnd.pressable?.onMouseDown?.(event);
199
+ }}
200
+ disabled={isDisabledByPromise || resolvedIconEnd.pressable?.disabled}
201
+ className={resolvedIconEnd.pressable?.className}
202
+ padding="0 .8rem"
203
+ alignItems="center"
204
+ justifyContent="center"
205
+ style={{
206
+ display: "inline-flex",
207
+ flex: "0 0 auto",
208
+ height: "auto",
209
+ ...resolvedIconEnd.pressable?.style,
210
+ }}
211
+ >
212
+ <Icon
213
+ size={resolvedIconEnd.size ?? 20}
214
+ border="None"
215
+ icon={resolvedIconEnd.icon}
216
+ svg={resolvedIconEnd.svg}
217
+ />
218
+ </Pressable>
219
+ </View>
220
+ );
221
+ }
222
+
223
+ const {
224
+ className: pressableClassName,
225
+ style: pressableStyle,
226
+ title: pressableTitle,
227
+ disabled: pressableDisabled,
228
+ ...restPressable
229
+ } = pressable ?? {};
230
+
231
+ return (
232
+ <Pressable
233
+ data-color-mode={dataColorMode}
234
+ {...restPressable}
235
+ themePreset={resolvedPreset}
236
+ background={background}
237
+ color={color}
238
+ themeInteractive={themeInteractive}
239
+ selected={selected}
240
+ border={border}
241
+ radius={resolvedRadius}
242
+ shadow={shadow}
243
+ className={clsx(className, pressableClassName)}
244
+ disabled={isDisabledByPromise || pressableDisabled}
245
+ padding={modal ? 16 : (padding ?? 12)}
246
+ paddingHorizontal={paddingHorizontal}
247
+ paddingVertical={paddingVertical}
248
+ fullWidth={modal || sizeFull}
249
+ width={modal || sizeFull ? undefined : "max-content"}
250
+ column={column}
251
+ alignItems="center"
252
+ justifyContent="center"
253
+ height="max-content"
254
+ gap={column ? 6 : 8}
255
+ style={{
256
+ position: "relative",
257
+ textAlign: "center",
258
+ ...style,
259
+ ...pressableStyle,
260
+ }}
261
+ title={pressableTitle}
262
+ >
263
+ <ButtonContent
264
+ icon={icon}
265
+ text={text}
266
+ textType={textType}
267
+ column={column}
268
+ reversed={reversed}
269
+ promise={promise}
270
+ />
271
+ </Pressable>
272
+ );
273
+ }
274
+
275
+ export default Button;
@@ -0,0 +1,44 @@
1
+ import type { IconProps } from "@/packages/Components/Icon/Icon.types";
2
+ import type { TextProps } from "@/packages/Components/Text/Text.types";
3
+ import type { UIKitSizeValue } from "@/packages/Frameworks/_shared/sizing";
4
+ import type { PressableProps } from "@/packages/Frameworks/Pressable/Pressable.types";
5
+ import type { RadiusProps } from "@/packages/Frameworks/Theme/Radius.types";
6
+ import type {
7
+ BorderProps,
8
+ ThemeSystemProps,
9
+ } from "@/packages/Frameworks/Theme/Theme.types";
10
+
11
+ export type ButtonIconEndProps = Pick<
12
+ IconProps,
13
+ "icon" | "pressable" | "size" | "svg"
14
+ >;
15
+
16
+ export interface ButtonProps
17
+ extends ThemeSystemProps,
18
+ RadiusProps,
19
+ BorderProps {
20
+ "data-color-mode"?: string;
21
+ className?: string;
22
+ style?: React.CSSProperties;
23
+ icon?: IconProps;
24
+ pressable?: PressableProps;
25
+ textType?: TextProps["type"];
26
+ sizeFull?: boolean;
27
+ promise?: {
28
+ type: "loading" | "success" | "error";
29
+ text?: React.ReactNode;
30
+ };
31
+ text?: React.ReactNode;
32
+ column?: boolean;
33
+ padding?: UIKitSizeValue;
34
+ paddingHorizontal?: UIKitSizeValue;
35
+ paddingVertical?: UIKitSizeValue;
36
+ modal?: boolean;
37
+ popover?: {
38
+ text?: React.ReactNode;
39
+ icon?: IconProps;
40
+ pressable?: PressableProps;
41
+ }[];
42
+ iconEnd?: ButtonIconEndProps;
43
+ reversed?: boolean;
44
+ }
@@ -0,0 +1,180 @@
1
+ import clsx from "clsx";
2
+ import { useInBoxContent } from "@/packages/Components/Box/Box";
3
+ import styles from "@/packages/Components/Card/Card.module.scss";
4
+ import type { CardDefaultProps } from "@/packages/Components/Card/Card.types";
5
+ import { buildRenderKeys } from "@/packages/Components/Card/Card.utils";
6
+ import Icon from "@/packages/Components/Icon/Icon";
7
+ import Pill from "@/packages/Components/Pill/Pill";
8
+ import Text from "@/packages/Components/Text/Text";
9
+ import { normalizeCardIcon } from "@/packages/Components/Card/Card.utils";
10
+ import StopParentInteraction from "@/packages/Frameworks/_shared/StopParentInteraction";
11
+ import Pressable from "@/packages/Frameworks/Pressable/Pressable";
12
+ import View from "@/packages/Frameworks/View/View";
13
+
14
+ export default function CardDefault({
15
+ themePreset,
16
+ background,
17
+ color,
18
+ themeInteractive,
19
+ selected,
20
+ border,
21
+ shadow,
22
+ vertical,
23
+ contained,
24
+ radius,
25
+ pressable,
26
+ style,
27
+ className,
28
+ title,
29
+ caption,
30
+ titleReversed,
31
+ icon,
32
+ arrow,
33
+ pill,
34
+ customRight,
35
+ customRightAllowDefault,
36
+ "data-color-mode": dataTheme,
37
+ }: CardDefaultProps) {
38
+ const shouldBlockHostDefault = Boolean(pressable) && !customRightAllowDefault;
39
+ const inBoxContent = useInBoxContent();
40
+
41
+ const resolvedContained = contained ?? !inBoxContent;
42
+ const resolvedIcon = normalizeCardIcon(icon);
43
+ const pillItems = Array.isArray(pill) ? pill : pill ? [pill] : [];
44
+ const pillKeys = buildRenderKeys(
45
+ pillItems,
46
+ (pillItem, index) =>
47
+ pillItem.renderKey ||
48
+ [
49
+ pillItem.pressable?.href,
50
+ pillItem.icon?.icon,
51
+ pillItem.icon?.svg,
52
+ pillItem.rightIcon?.icon,
53
+ index,
54
+ ]
55
+ .filter(Boolean)
56
+ .join("-"),
57
+ );
58
+
59
+ const { disabled: pressableDisabled, ...restPressable } = pressable ?? {};
60
+
61
+ return (
62
+ <Pressable
63
+ alignItems="center"
64
+ justifyContent="space-between"
65
+ gap={12}
66
+ data-color-mode={dataTheme}
67
+ themePreset={themePreset ?? "UIPrimary"}
68
+ background={background}
69
+ color={color}
70
+ shadow={shadow}
71
+ themeInteractive={themeInteractive}
72
+ selected={selected}
73
+ border={border}
74
+ radius={radius ?? "Regular"}
75
+ {...restPressable}
76
+ disabled={pressableDisabled}
77
+ fullWidth
78
+ className={clsx(
79
+ styles.Card,
80
+ resolvedContained && styles.Contained,
81
+ className,
82
+ )}
83
+ style={style}
84
+ >
85
+ <View
86
+ gap={12}
87
+ fullWidth
88
+ style={{ minWidth: 0 }}
89
+ column={vertical}
90
+ alignItems={vertical ? "flex-start" : undefined}
91
+ justifyContent={vertical ? "flex-start" : undefined}
92
+ >
93
+ {resolvedIcon && <Icon {...resolvedIcon} />}
94
+ {(title || caption) && (
95
+ <View
96
+ column
97
+ justifyContent="center"
98
+ gap={2}
99
+ style={
100
+ titleReversed ? { flexDirection: "column-reverse" } : undefined
101
+ }
102
+ >
103
+ {title && (
104
+ <Text type="Subheadline" weight={500}>
105
+ {title}
106
+ </Text>
107
+ )}
108
+ {caption && (
109
+ <Text type="Footnote" opacity={0.6}>
110
+ {caption}
111
+ </Text>
112
+ )}
113
+ </View>
114
+ )}
115
+ </View>
116
+
117
+ {}
118
+ <View gap={8}>
119
+ {pillItems.length > 0 && (
120
+ <StopParentInteraction
121
+ alignItems="center"
122
+ gap={6}
123
+ style={{ width: "max-content", maxWidth: "100%" }}
124
+ blockDefault={shouldBlockHostDefault}
125
+ data-stop-parent-interaction-state
126
+ >
127
+ {pillItems.map((pillItem, index) => (
128
+ <Pill
129
+ key={pillKeys[index]}
130
+ themePreset={pillItem.themePreset ? themePreset : "BaseFull"}
131
+ padding={8}
132
+ {...pillItem}
133
+ />
134
+ ))}
135
+ </StopParentInteraction>
136
+ )}
137
+ {customRight && (
138
+ <StopParentInteraction
139
+ alignItems="center"
140
+ gap={12}
141
+ blockDefault={shouldBlockHostDefault}
142
+ data-stop-parent-interaction-state
143
+ >
144
+ {customRight}
145
+ </StopParentInteraction>
146
+ )}
147
+
148
+ {arrow &&
149
+ (() => {
150
+ if (typeof arrow === "boolean") {
151
+ return <Icon icon="iArrowKeyRight" size={24} opacity={0.6} />;
152
+ }
153
+
154
+ const { filled, degree, ...iconProps } = arrow;
155
+ return (
156
+ <Icon
157
+ icon="iArrowKeyRight"
158
+ size={18}
159
+ {...iconProps}
160
+ box={iconProps.box ?? true}
161
+ boxOptions={iconProps.boxOptions ?? { padding: 6 }}
162
+ background={iconProps.background}
163
+ themePreset={
164
+ filled
165
+ ? iconProps.themePreset
166
+ ? themePreset
167
+ : "BaseFull"
168
+ : iconProps.themePreset
169
+ }
170
+ style={{
171
+ transform: degree ? `rotate(${degree}deg)` : undefined,
172
+ ...iconProps.style,
173
+ }}
174
+ />
175
+ );
176
+ })()}
177
+ </View>
178
+ </Pressable>
179
+ );
180
+ }