@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.
- package/LICENSE +9 -0
- package/README.md +51 -0
- package/index.ts +78 -0
- package/package.json +103 -0
- package/packages/Components/Box/Box.tsx +173 -0
- package/packages/Components/Box/Box.types.ts +48 -0
- package/packages/Components/Button/Button.tsx +275 -0
- package/packages/Components/Button/Button.types.ts +44 -0
- package/packages/Components/Card/Card.default.tsx +180 -0
- package/packages/Components/Card/Card.foldable.tsx +383 -0
- package/packages/Components/Card/Card.module.scss +23 -0
- package/packages/Components/Card/Card.tsx +8 -0
- package/packages/Components/Card/Card.types.ts +91 -0
- package/packages/Components/Card/Card.utils.ts +66 -0
- package/packages/Components/Checkbox/Checkbox.module.scss +11 -0
- package/packages/Components/Checkbox/Checkbox.tsx +104 -0
- package/packages/Components/Checkbox/Checkbox.types.ts +24 -0
- package/packages/Components/CodeBox/CodeBox.copy.tsx +43 -0
- package/packages/Components/CodeBox/CodeBox.module.scss +72 -0
- package/packages/Components/CodeBox/CodeBox.tsx +91 -0
- package/packages/Components/CodeBox/CodeBox.types.ts +17 -0
- package/packages/Components/ContextMenu/ContextMenu.module.scss +8 -0
- package/packages/Components/ContextMenu/ContextMenu.options.tsx +126 -0
- package/packages/Components/ContextMenu/ContextMenu.tsx +381 -0
- package/packages/Components/ContextMenu/ContextMenu.types.ts +46 -0
- package/packages/Components/ContributionGraph/ContributionGraph.module.scss +42 -0
- package/packages/Components/ContributionGraph/ContributionGraph.tsx +454 -0
- package/packages/Components/ContributionGraph/ContributionGraph.types.ts +27 -0
- package/packages/Components/DatePicker/DatePicker.calendar.tsx +161 -0
- package/packages/Components/DatePicker/DatePicker.core.tsx +582 -0
- package/packages/Components/DatePicker/DatePicker.module.scss +26 -0
- package/packages/Components/DatePicker/DatePicker.tsx +786 -0
- package/packages/Components/DatePicker/DatePicker.types.ts +36 -0
- package/packages/Components/DatePicker/DatePicker.utils.ts +80 -0
- package/packages/Components/DatePicker/hooks/useCalendar.ts +61 -0
- package/packages/Components/DatePicker/hooks/useSelection.ts +208 -0
- package/packages/Components/Divider/Divider.tsx +46 -0
- package/packages/Components/Divider/Divider.types.ts +12 -0
- package/packages/Components/Header/Header.module.scss +74 -0
- package/packages/Components/Header/Header.tsx +47 -0
- package/packages/Components/Header/Header.types.ts +8 -0
- package/packages/Components/Icon/Icon.group.tsx +122 -0
- package/packages/Components/Icon/Icon.group.types.ts +20 -0
- package/packages/Components/Icon/Icon.tsx +341 -0
- package/packages/Components/Icon/Icon.types.ts +59 -0
- package/packages/Components/Icon/SVG/data.tsx +232 -0
- package/packages/Components/Input/Input.module.scss +5 -0
- package/packages/Components/Input/Input.tsx +87 -0
- package/packages/Components/Input/Input.types.ts +14 -0
- package/packages/Components/Label/Label.module.scss +19 -0
- package/packages/Components/Label/Label.tsx +115 -0
- package/packages/Components/Label/Label.types.ts +28 -0
- package/packages/Components/Layout/Layout.docs.module.scss +42 -0
- package/packages/Components/Layout/Layout.docs.tsx +150 -0
- package/packages/Components/Layout/Layout.docs.types.ts +18 -0
- package/packages/Components/Layout/Layout.module.scss +91 -0
- package/packages/Components/Layout/Layout.tsx +306 -0
- package/packages/Components/Layout/Layout.types.ts +71 -0
- package/packages/Components/Maps/OSM/MapOSM.module.scss +11 -0
- package/packages/Components/Maps/OSM/MapOSM.shared.ts +121 -0
- package/packages/Components/Maps/OSM/MapOSM.tsx +279 -0
- package/packages/Components/Maps/OSM/MapOSM.types.ts +18 -0
- package/packages/Components/Nav/Nav.module.scss +137 -0
- package/packages/Components/Nav/Nav.tsx +304 -0
- package/packages/Components/Nav/Nav.types.ts +32 -0
- package/packages/Components/Nav/hooks/useNavDrag.ts +374 -0
- package/packages/Components/Nav/hooks/useNavIndicator.ts +137 -0
- package/packages/Components/Pagination/Pagination.tsx +254 -0
- package/packages/Components/Pagination/Pagination.types.ts +18 -0
- package/packages/Components/Pill/Pill.tsx +127 -0
- package/packages/Components/Pill/Pill.types.ts +33 -0
- package/packages/Components/Profile/Profile.shared.ts +74 -0
- package/packages/Components/Profile/Profile.tsx +382 -0
- package/packages/Components/Profile/Profile.types.ts +55 -0
- package/packages/Components/Progress/Progress.module.scss +15 -0
- package/packages/Components/Progress/Progress.tsx +88 -0
- package/packages/Components/Progress/Progress.types.ts +22 -0
- package/packages/Components/Radio/Radio.module.scss +11 -0
- package/packages/Components/Radio/Radio.tsx +121 -0
- package/packages/Components/Radio/Radio.types.ts +20 -0
- package/packages/Components/Select/Select.keyboard.tsx +76 -0
- package/packages/Components/Select/Select.trigger.tsx +88 -0
- package/packages/Components/Select/Select.tsx +11 -0
- package/packages/Components/Select/Select.types.ts +38 -0
- package/packages/Components/Select/Select.utils.ts +84 -0
- package/packages/Components/Select/hooks/useSelectNavigation.ts +461 -0
- package/packages/Components/Select/hooks/useSelectSelection.ts +142 -0
- package/packages/Components/Select/hooks/useSelectState.ts +314 -0
- package/packages/Components/Select/select.control.tsx +228 -0
- package/packages/Components/Select/select.inner.tsx +312 -0
- package/packages/Components/Skeleton/Skeleton.tsx +30 -0
- package/packages/Components/Skeleton/Skeleton.types.ts +12 -0
- package/packages/Components/Spinner/Spinner.module.scss +78 -0
- package/packages/Components/Spinner/Spinner.tsx +125 -0
- package/packages/Components/Spinner/Spinner.types.ts +19 -0
- package/packages/Components/Text/Text.module.scss +7 -0
- package/packages/Components/Text/Text.tsx +49 -0
- package/packages/Components/Text/Text.types.ts +33 -0
- package/packages/Components/TimePicker/TimePicker.core.tsx +448 -0
- package/packages/Components/TimePicker/TimePicker.module.scss +30 -0
- package/packages/Components/TimePicker/TimePicker.tsx +511 -0
- package/packages/Components/TimePicker/TimePicker.types.ts +22 -0
- package/packages/Components/Timeline/Timeline.tsx +111 -0
- package/packages/Components/Timeline/Timeline.types.ts +23 -0
- package/packages/Components/Title/Title.tsx +305 -0
- package/packages/Components/Title/Title.types.ts +64 -0
- package/packages/Components/Toggle/Toggle.module.scss +32 -0
- package/packages/Components/Toggle/Toggle.tsx +272 -0
- package/packages/Components/Toggle/Toggle.types.ts +17 -0
- package/packages/Components/Tooltip/Tooltip.module.scss +44 -0
- package/packages/Components/Tooltip/Tooltip.tsx +340 -0
- package/packages/Components/Tooltip/Tooltip.types.ts +38 -0
- package/packages/Frameworks/Dialog/Dialog.background.tsx +88 -0
- package/packages/Frameworks/Dialog/Dialog.boot.tsx +32 -0
- package/packages/Frameworks/Dialog/Dialog.store.ts +199 -0
- package/packages/Frameworks/Dialog/Dialog.tsx +185 -0
- package/packages/Frameworks/Dialog/Dialog.types.ts +264 -0
- package/packages/Frameworks/Dialog/Dialog.utils.ts +22 -0
- package/packages/Frameworks/Dialog/contents/Dialog.footer.tsx +79 -0
- package/packages/Frameworks/Dialog/contents/Dialog.funnel.tsx +260 -0
- package/packages/Frameworks/Dialog/contents/Dialog.header.tsx +137 -0
- package/packages/Frameworks/Dialog/hooks/useDialogPosition.ts +298 -0
- package/packages/Frameworks/Dialog/hooks/useSheetDrag.ts +325 -0
- package/packages/Frameworks/Dialog/hooks/useSheetGeometry.ts +201 -0
- package/packages/Frameworks/Dialog/hooks/useSheetProgressive.ts +98 -0
- package/packages/Frameworks/Dialog/renderers/renderModal.tsx +228 -0
- package/packages/Frameworks/Dialog/renderers/renderPopover.tsx +220 -0
- package/packages/Frameworks/Dialog/renderers/renderSheet.tsx +571 -0
- package/packages/Frameworks/EdgeEffect/EdgeEffect.tsx +52 -0
- package/packages/Frameworks/EdgeEffect/EdgeEffect.types.ts +5 -0
- package/packages/Frameworks/Motion/Motion.presets.ts +49 -0
- package/packages/Frameworks/Pressable/Pressable.module.scss +19 -0
- package/packages/Frameworks/Pressable/Pressable.tsx +651 -0
- package/packages/Frameworks/Pressable/Pressable.types.ts +73 -0
- package/packages/Frameworks/Squircle/Squircle.tsx +263 -0
- package/packages/Frameworks/Squircle/Squircle.types.ts +15 -0
- package/packages/Frameworks/Theme/Radius.types.ts +55 -0
- package/packages/Frameworks/Theme/Theme.types.ts +325 -0
- package/packages/Frameworks/Toaster/Toaster.boot.tsx +47 -0
- package/packages/Frameworks/Toaster/Toaster.module.scss +168 -0
- package/packages/Frameworks/Toaster/Toaster.types.ts +13 -0
- package/packages/Frameworks/View/DNDView/DNDView.module.scss +8 -0
- package/packages/Frameworks/View/DNDView/DNDView.tsx +470 -0
- package/packages/Frameworks/View/DNDView/DNDView.types.ts +61 -0
- package/packages/Frameworks/View/HScrollView/HScrollView.module.scss +59 -0
- package/packages/Frameworks/View/HScrollView/HScrollView.tsx +386 -0
- package/packages/Frameworks/View/HScrollView/HScrollView.types.ts +46 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.counter.tsx +27 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.footer.tsx +76 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.header.tsx +49 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.list.tsx +74 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.slide.tsx +71 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.tsx +175 -0
- package/packages/Frameworks/View/ImageView/Image.controls.tsx +39 -0
- package/packages/Frameworks/View/ImageView/Image.hooks.ts +82 -0
- package/packages/Frameworks/View/ImageView/Image.module.scss +7 -0
- package/packages/Frameworks/View/ImageView/Image.tsx +375 -0
- package/packages/Frameworks/View/ImageView/Image.types.ts +71 -0
- package/packages/Frameworks/View/ImageView/Image.utils.ts +79 -0
- package/packages/Frameworks/View/View.module.scss +34 -0
- package/packages/Frameworks/View/View.tsx +200 -0
- package/packages/Frameworks/View/View.types.ts +36 -0
- package/packages/Frameworks/_shared/Padding.types.ts +52 -0
- package/packages/Frameworks/_shared/StopParentInteraction.tsx +45 -0
- package/packages/Frameworks/_shared/Wind.types.ts +17 -0
- package/packages/Frameworks/_shared/bodyScrollLock.ts +127 -0
- package/packages/Frameworks/_shared/layer.constants.ts +8 -0
- package/packages/Frameworks/_shared/normalize.ts +39 -0
- package/packages/Frameworks/_shared/sizing.ts +55 -0
- package/packages/Frameworks/_shared/useControllableState.ts +29 -0
- package/packages/Styles/_animation.scss +42 -0
- package/packages/Styles/_color.scss +131 -0
- package/packages/Styles/_font.scss +30 -0
- package/packages/Styles/_icon.scss +782 -0
- package/packages/Styles/_importer.scss +9 -0
- package/packages/Styles/_system.scss +69 -0
- package/packages/Styles/_textstyle.scss +111 -0
- package/packages/Styles/_theme.scss +452 -0
- package/packages/Styles/_viewport-global.scss +99 -0
- package/packages/Styles/_viewport.scss +108 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IconProps } from "@/packages/Components/Icon/Icon.types";
|
|
2
|
+
import type { UIKitSizeValue } from "@/packages/Frameworks/_shared/sizing";
|
|
3
|
+
import type { RadiusProps } from "@/packages/Frameworks/Theme/Radius.types";
|
|
4
|
+
import type {
|
|
5
|
+
BorderProps,
|
|
6
|
+
ThemeSystemProps,
|
|
7
|
+
} from "@/packages/Frameworks/Theme/Theme.types";
|
|
8
|
+
|
|
9
|
+
export interface IconGroupProps extends BorderProps, RadiusProps {
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
icons?: IconProps | IconProps[];
|
|
14
|
+
padding?: UIKitSizeValue;
|
|
15
|
+
iconBoxOptions?: IconProps["boxOptions"];
|
|
16
|
+
iconSize?: IconProps["size"];
|
|
17
|
+
iconWidth?: IconProps["width"];
|
|
18
|
+
iconHeight?: IconProps["height"];
|
|
19
|
+
background?: ThemeSystemProps["background"];
|
|
20
|
+
}
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import Image from "next/image";
|
|
3
|
+
import type { IconProps } from "@/packages/Components/Icon/Icon.types";
|
|
4
|
+
import SVGData from "@/packages/Components/Icon/SVG/data";
|
|
5
|
+
import Spinner from "@/packages/Components/Spinner/Spinner";
|
|
6
|
+
import Text from "@/packages/Components/Text/Text";
|
|
7
|
+
import {
|
|
8
|
+
normalizeBrandIconClass as _normalizeBrandIconClass,
|
|
9
|
+
normalizeUIKitImageSrc as _normalizeUIKitImageSrc,
|
|
10
|
+
} from "@/packages/Frameworks/_shared/normalize";
|
|
11
|
+
import { Size, SizePX } from "@/packages/Frameworks/_shared/sizing";
|
|
12
|
+
import Pressable from "@/packages/Frameworks/Pressable/Pressable";
|
|
13
|
+
import View from "@/packages/Frameworks/View/View";
|
|
14
|
+
|
|
15
|
+
const normalizeUIKitImageSrc = _normalizeUIKitImageSrc;
|
|
16
|
+
const normalizeBrandIconClass = _normalizeBrandIconClass;
|
|
17
|
+
|
|
18
|
+
function normalizeDToArray(d: string | (string | string[])[]): string[] {
|
|
19
|
+
if (Array.isArray(d)) {
|
|
20
|
+
return d.flat();
|
|
21
|
+
}
|
|
22
|
+
return [d];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const buildRenderKeys = (items: string[], prefix: string) => {
|
|
26
|
+
const counts = new Map<string, number>();
|
|
27
|
+
|
|
28
|
+
return items.map((item) => {
|
|
29
|
+
const base = item || prefix;
|
|
30
|
+
const nextCount = (counts.get(base) ?? 0) + 1;
|
|
31
|
+
counts.set(base, nextCount);
|
|
32
|
+
return `${prefix}-${base}-${nextCount}`;
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export function IconInner({
|
|
37
|
+
innerClassName,
|
|
38
|
+
size,
|
|
39
|
+
width,
|
|
40
|
+
height,
|
|
41
|
+
iconFill,
|
|
42
|
+
weight,
|
|
43
|
+
icon,
|
|
44
|
+
iconBrand,
|
|
45
|
+
svg,
|
|
46
|
+
svgBordered,
|
|
47
|
+
spinner,
|
|
48
|
+
spinnerOptions,
|
|
49
|
+
image,
|
|
50
|
+
imageLoading,
|
|
51
|
+
title,
|
|
52
|
+
opacity,
|
|
53
|
+
box,
|
|
54
|
+
titleType,
|
|
55
|
+
reversed,
|
|
56
|
+
}: IconProps) {
|
|
57
|
+
const dArray = svg ? normalizeDToArray(SVGData[svg].d) : [];
|
|
58
|
+
const pathKeys = buildRenderKeys(dArray, svg ?? "svg");
|
|
59
|
+
const resolvedSize = Size(size) ?? "2.4rem";
|
|
60
|
+
const resolvedWidth = Size(width) ?? resolvedSize;
|
|
61
|
+
const resolvedHeight = Size(height) ?? resolvedSize;
|
|
62
|
+
const svgBorderOptions =
|
|
63
|
+
typeof svgBordered === "object" ? svgBordered : undefined;
|
|
64
|
+
const svgBorderFill = svgBorderOptions?.fill ?? "None";
|
|
65
|
+
const svgBorderStroke = svgBorderOptions?.stroke ?? "currentColor";
|
|
66
|
+
const svgBorderStrokeWidth = svgBorderOptions?.strokeWidth ?? 1;
|
|
67
|
+
const imageWidth = SizePX(width ?? size, 64);
|
|
68
|
+
const imageHeight = SizePX(height ?? size, 64);
|
|
69
|
+
const resolvedImage = typeof image === "string" ? image.trim() : "";
|
|
70
|
+
const imageSrc = normalizeUIKitImageSrc(resolvedImage);
|
|
71
|
+
const accessibleTitle = typeof title === "string" ? title : undefined;
|
|
72
|
+
const brandIconClass = normalizeBrandIconClass(iconBrand);
|
|
73
|
+
|
|
74
|
+
if (spinner) {
|
|
75
|
+
return (
|
|
76
|
+
<View
|
|
77
|
+
alignItems="center"
|
|
78
|
+
justifyContent="center"
|
|
79
|
+
gap={4}
|
|
80
|
+
width={resolvedWidth}
|
|
81
|
+
height={resolvedHeight}
|
|
82
|
+
style={{ minWidth: "max-content", minHeight: "max-content" }}
|
|
83
|
+
>
|
|
84
|
+
<Spinner
|
|
85
|
+
{...spinnerOptions}
|
|
86
|
+
size={spinnerOptions?.size ?? size}
|
|
87
|
+
color={spinnerOptions?.color}
|
|
88
|
+
opacity={spinnerOptions?.opacity ?? opacity}
|
|
89
|
+
/>
|
|
90
|
+
{title && (
|
|
91
|
+
<Text
|
|
92
|
+
type={titleType || "Subheadline"}
|
|
93
|
+
opacity={opacity}
|
|
94
|
+
style={{ order: reversed ? -1 : undefined }}
|
|
95
|
+
>
|
|
96
|
+
{title}
|
|
97
|
+
</Text>
|
|
98
|
+
)}
|
|
99
|
+
</View>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (icon || iconBrand) {
|
|
104
|
+
return (
|
|
105
|
+
<View
|
|
106
|
+
alignItems="center"
|
|
107
|
+
justifyContent="center"
|
|
108
|
+
gap={4}
|
|
109
|
+
style={{
|
|
110
|
+
width: "max-content",
|
|
111
|
+
height: "max-content",
|
|
112
|
+
minWidth: "max-content",
|
|
113
|
+
minHeight: "max-content",
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
<i
|
|
117
|
+
className={clsx(
|
|
118
|
+
icon,
|
|
119
|
+
brandIconClass,
|
|
120
|
+
{ iFill: iconFill },
|
|
121
|
+
innerClassName,
|
|
122
|
+
)}
|
|
123
|
+
style={
|
|
124
|
+
{
|
|
125
|
+
fontSize: resolvedSize,
|
|
126
|
+
"--uikit-icon-font-weight": weight,
|
|
127
|
+
color: "var(--color-icon)",
|
|
128
|
+
opacity,
|
|
129
|
+
} as React.CSSProperties
|
|
130
|
+
}
|
|
131
|
+
/>
|
|
132
|
+
{title && (
|
|
133
|
+
<Text
|
|
134
|
+
type={titleType || "Subheadline"}
|
|
135
|
+
style={{ order: reversed ? -1 : undefined }}
|
|
136
|
+
>
|
|
137
|
+
{title}
|
|
138
|
+
</Text>
|
|
139
|
+
)}
|
|
140
|
+
</View>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (imageSrc) {
|
|
145
|
+
return (
|
|
146
|
+
<View
|
|
147
|
+
className={innerClassName}
|
|
148
|
+
width={resolvedWidth}
|
|
149
|
+
height={resolvedHeight}
|
|
150
|
+
opacity={opacity}
|
|
151
|
+
padding={box ? 0 : 2}
|
|
152
|
+
style={{ position: "relative" }}
|
|
153
|
+
>
|
|
154
|
+
<Image
|
|
155
|
+
style={{
|
|
156
|
+
width: "100%",
|
|
157
|
+
height: "100%",
|
|
158
|
+
objectPosition: "center",
|
|
159
|
+
objectFit: "cover",
|
|
160
|
+
}}
|
|
161
|
+
alt={accessibleTitle || ""}
|
|
162
|
+
src={imageSrc}
|
|
163
|
+
width={imageWidth}
|
|
164
|
+
height={imageHeight}
|
|
165
|
+
loading={imageLoading}
|
|
166
|
+
unoptimized
|
|
167
|
+
/>
|
|
168
|
+
</View>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (svg) {
|
|
173
|
+
return (
|
|
174
|
+
<View
|
|
175
|
+
width={resolvedWidth}
|
|
176
|
+
height={resolvedHeight}
|
|
177
|
+
style={{
|
|
178
|
+
display: "flex",
|
|
179
|
+
alignItems: "center",
|
|
180
|
+
justifyContent: "center",
|
|
181
|
+
}}
|
|
182
|
+
>
|
|
183
|
+
<svg
|
|
184
|
+
className={innerClassName}
|
|
185
|
+
aria-hidden={accessibleTitle ? undefined : true}
|
|
186
|
+
aria-label={accessibleTitle}
|
|
187
|
+
role={accessibleTitle ? "img" : undefined}
|
|
188
|
+
style={{
|
|
189
|
+
width: `calc(${resolvedWidth} * 0.75)`,
|
|
190
|
+
height: `calc(${resolvedHeight} * 0.75)`,
|
|
191
|
+
color: "var(--color-icon)",
|
|
192
|
+
opacity,
|
|
193
|
+
}}
|
|
194
|
+
viewBox={SVGData[svg].viewBox}
|
|
195
|
+
>
|
|
196
|
+
{accessibleTitle ? <title>{accessibleTitle}</title> : null}
|
|
197
|
+
{svgBordered
|
|
198
|
+
? dArray.map((d, index) => (
|
|
199
|
+
<path
|
|
200
|
+
key={`${pathKeys[index]}-border`}
|
|
201
|
+
d={d}
|
|
202
|
+
fill={svgBorderFill}
|
|
203
|
+
stroke={svgBorderStroke}
|
|
204
|
+
strokeLinecap="round"
|
|
205
|
+
strokeLinejoin="round"
|
|
206
|
+
strokeWidth={svgBorderStrokeWidth}
|
|
207
|
+
vectorEffect="non-scaling-stroke"
|
|
208
|
+
/>
|
|
209
|
+
))
|
|
210
|
+
: dArray.map((d, index) => (
|
|
211
|
+
<path key={pathKeys[index]} d={d} fill="currentColor" />
|
|
212
|
+
))}
|
|
213
|
+
</svg>
|
|
214
|
+
</View>
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export function Icon({
|
|
222
|
+
themePreset,
|
|
223
|
+
background,
|
|
224
|
+
color,
|
|
225
|
+
themeInteractive,
|
|
226
|
+
selected,
|
|
227
|
+
border,
|
|
228
|
+
radius,
|
|
229
|
+
shadow,
|
|
230
|
+
pressable,
|
|
231
|
+
box,
|
|
232
|
+
boxOptions,
|
|
233
|
+
title,
|
|
234
|
+
className,
|
|
235
|
+
style,
|
|
236
|
+
innerClassName,
|
|
237
|
+
size,
|
|
238
|
+
width,
|
|
239
|
+
height,
|
|
240
|
+
iconFill,
|
|
241
|
+
weight,
|
|
242
|
+
icon,
|
|
243
|
+
iconBrand,
|
|
244
|
+
spinner,
|
|
245
|
+
spinnerOptions,
|
|
246
|
+
svg,
|
|
247
|
+
svgBordered,
|
|
248
|
+
image,
|
|
249
|
+
imageLoading,
|
|
250
|
+
opacity,
|
|
251
|
+
backgroundBlur,
|
|
252
|
+
"data-color-mode": dataColorMode,
|
|
253
|
+
titleType,
|
|
254
|
+
reversed,
|
|
255
|
+
}: IconProps) {
|
|
256
|
+
const resolvedBackground = background ?? boxOptions?.background;
|
|
257
|
+
const resolvedBorder = border ?? (box ? undefined : undefined);
|
|
258
|
+
const resolvedRadius = radius ?? (box ? "Circle" : undefined);
|
|
259
|
+
const accessibleTitle = typeof title === "string" ? title : undefined;
|
|
260
|
+
|
|
261
|
+
const {
|
|
262
|
+
className: pressableClassName,
|
|
263
|
+
style: pressableStyle,
|
|
264
|
+
title: pressableTitle,
|
|
265
|
+
disabled: pressableDisabled,
|
|
266
|
+
...restPressable
|
|
267
|
+
} = pressable ?? {};
|
|
268
|
+
|
|
269
|
+
return (
|
|
270
|
+
<Pressable
|
|
271
|
+
data-color-mode={dataColorMode}
|
|
272
|
+
{...restPressable}
|
|
273
|
+
themePreset={themePreset}
|
|
274
|
+
background={resolvedBackground}
|
|
275
|
+
color={color}
|
|
276
|
+
themeInteractive={themeInteractive}
|
|
277
|
+
selected={selected}
|
|
278
|
+
border={resolvedBorder}
|
|
279
|
+
backgroundBlur={backgroundBlur}
|
|
280
|
+
radius={resolvedRadius}
|
|
281
|
+
shadow={shadow}
|
|
282
|
+
opacity={opacity}
|
|
283
|
+
className={clsx(className, pressableClassName)}
|
|
284
|
+
alignItems="center"
|
|
285
|
+
justifyContent="center"
|
|
286
|
+
width={Size(width) ?? "max-content"}
|
|
287
|
+
height={Size(height) ?? "max-content"}
|
|
288
|
+
padding={
|
|
289
|
+
boxOptions?.padding !== undefined
|
|
290
|
+
? Size(boxOptions.padding)
|
|
291
|
+
: box
|
|
292
|
+
? ".8rem"
|
|
293
|
+
: image
|
|
294
|
+
? 0
|
|
295
|
+
: undefined
|
|
296
|
+
}
|
|
297
|
+
gap={box ? undefined : 4}
|
|
298
|
+
style={{
|
|
299
|
+
minWidth: "max-content",
|
|
300
|
+
minHeight: "max-content",
|
|
301
|
+
paddingInline: Size(boxOptions?.paddingHorizontal),
|
|
302
|
+
paddingBlock: Size(boxOptions?.paddingVertical),
|
|
303
|
+
overflow: "hidden",
|
|
304
|
+
margin: Size(boxOptions?.margin),
|
|
305
|
+
marginInline: Size(boxOptions?.marginHorizontal),
|
|
306
|
+
marginBlock: Size(boxOptions?.marginVertical),
|
|
307
|
+
...boxOptions?.style,
|
|
308
|
+
...style,
|
|
309
|
+
...pressableStyle,
|
|
310
|
+
}}
|
|
311
|
+
title={accessibleTitle ?? pressableTitle}
|
|
312
|
+
disabled={pressableDisabled}
|
|
313
|
+
>
|
|
314
|
+
<IconInner
|
|
315
|
+
className={className}
|
|
316
|
+
innerClassName={innerClassName}
|
|
317
|
+
size={size}
|
|
318
|
+
width={width}
|
|
319
|
+
height={height}
|
|
320
|
+
iconFill={iconFill}
|
|
321
|
+
weight={weight}
|
|
322
|
+
icon={icon}
|
|
323
|
+
iconBrand={iconBrand}
|
|
324
|
+
spinner={spinner}
|
|
325
|
+
spinnerOptions={spinnerOptions}
|
|
326
|
+
svg={svg}
|
|
327
|
+
svgBordered={svgBordered}
|
|
328
|
+
image={image}
|
|
329
|
+
imageLoading={imageLoading}
|
|
330
|
+
box={box}
|
|
331
|
+
boxOptions={boxOptions}
|
|
332
|
+
title={title}
|
|
333
|
+
opacity={opacity}
|
|
334
|
+
titleType={titleType}
|
|
335
|
+
reversed={reversed}
|
|
336
|
+
/>
|
|
337
|
+
</Pressable>
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export default Icon;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { SpinnerProps } from "@/packages/Components/Spinner/Spinner.types";
|
|
2
|
+
import type { TextProps } from "@/packages/Components/Text/Text.types";
|
|
3
|
+
import type { TitleProps } from "@/packages/Components/Title/Title.types";
|
|
4
|
+
import type { UIKitSizeValue } from "@/packages/Frameworks/_shared/sizing";
|
|
5
|
+
import type { PressableProps } from "@/packages/Frameworks/Pressable/Pressable.types";
|
|
6
|
+
import type { RadiusProps } from "@/packages/Frameworks/Theme/Radius.types";
|
|
7
|
+
import type {
|
|
8
|
+
BorderProps,
|
|
9
|
+
ThemePaint,
|
|
10
|
+
ThemeSystemProps,
|
|
11
|
+
} from "@/packages/Frameworks/Theme/Theme.types";
|
|
12
|
+
|
|
13
|
+
type SVGPathPaint = React.SVGProps<SVGPathElement>["fill"];
|
|
14
|
+
type SVGPathStrokeWidth = React.SVGProps<SVGPathElement>["strokeWidth"];
|
|
15
|
+
|
|
16
|
+
interface SVGBorderedOptions {
|
|
17
|
+
fill?: SVGPathPaint;
|
|
18
|
+
stroke?: SVGPathPaint;
|
|
19
|
+
strokeWidth?: SVGPathStrokeWidth;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface IconProps extends ThemeSystemProps, RadiusProps, BorderProps {
|
|
23
|
+
"data-color-mode"?: string;
|
|
24
|
+
className?: string;
|
|
25
|
+
style?: React.CSSProperties;
|
|
26
|
+
title?: React.ReactNode;
|
|
27
|
+
box?: boolean;
|
|
28
|
+
boxOptions?: {
|
|
29
|
+
padding?: UIKitSizeValue;
|
|
30
|
+
paddingHorizontal?: UIKitSizeValue;
|
|
31
|
+
paddingVertical?: UIKitSizeValue;
|
|
32
|
+
background?: ThemePaint;
|
|
33
|
+
style?: React.CSSProperties;
|
|
34
|
+
margin?: UIKitSizeValue;
|
|
35
|
+
marginHorizontal?: UIKitSizeValue;
|
|
36
|
+
marginVertical?: UIKitSizeValue;
|
|
37
|
+
};
|
|
38
|
+
innerClassName?: string;
|
|
39
|
+
size?: UIKitSizeValue;
|
|
40
|
+
width?: UIKitSizeValue;
|
|
41
|
+
height?: UIKitSizeValue;
|
|
42
|
+
image?: string;
|
|
43
|
+
imageLoading?: "eager" | "lazy";
|
|
44
|
+
icon?: string;
|
|
45
|
+
iconBrand?: string;
|
|
46
|
+
iconFill?: boolean;
|
|
47
|
+
spinner?: boolean;
|
|
48
|
+
spinnerOptions?: Omit<SpinnerProps, "color" | "data-color-mode" | "size"> & {
|
|
49
|
+
color?: SpinnerProps["color"];
|
|
50
|
+
size?: SpinnerProps["size"];
|
|
51
|
+
};
|
|
52
|
+
weight?: TextProps["weight"];
|
|
53
|
+
svg?: string;
|
|
54
|
+
svgBordered?: boolean | SVGBorderedOptions;
|
|
55
|
+
pressable?: PressableProps;
|
|
56
|
+
opacity?: number;
|
|
57
|
+
titleType?: TitleProps["titleType"];
|
|
58
|
+
reversed?: boolean;
|
|
59
|
+
}
|