@seed-design/lynx-react 0.2.0-alpha.3 → 0.3.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.
- package/lib/_virtual/_rolldown/runtime.js +13 -0
- package/lib/components/ActionButton/ActionButton.d.ts +26 -33
- package/lib/components/ActionButton/ActionButton.d.ts.map +1 -1
- package/lib/components/ActionButton/ActionButton.jsx +139 -120
- package/lib/components/ActionButton/index.d.ts +1 -1
- package/lib/components/AppBar/AppBar.d.ts +35 -0
- package/lib/components/AppBar/AppBar.d.ts.map +1 -0
- package/lib/components/AppBar/AppBar.jsx +132 -0
- package/lib/components/AppBar/AppBar.namespace.d.ts +2 -0
- package/lib/components/AppBar/AppBar.namespace.d.ts.map +1 -0
- package/lib/components/AppBar/AppBar.namespace.js +15 -0
- package/lib/components/AppBar/context.d.ts +13 -0
- package/lib/components/AppBar/context.d.ts.map +1 -0
- package/lib/components/AppBar/context.js +12 -0
- package/lib/components/AppBar/index.d.ts +3 -0
- package/lib/components/AppBar/index.d.ts.map +1 -0
- package/lib/components/AppBar/useAppBar.d.ts +15 -0
- package/lib/components/AppBar/useAppBar.d.ts.map +1 -0
- package/lib/components/AppBar/useAppBar.js +72 -0
- package/lib/components/Badge/Badge.d.ts +14 -0
- package/lib/components/Badge/Badge.d.ts.map +1 -0
- package/lib/components/Badge/Badge.jsx +15 -0
- package/lib/components/Badge/index.d.ts +2 -0
- package/lib/components/Badge/index.d.ts.map +1 -0
- package/lib/components/BottomSheet/BottomSheet.d.ts +22 -27
- package/lib/components/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/lib/components/BottomSheet/BottomSheet.jsx +127 -142
- package/lib/components/BottomSheet/BottomSheet.namespace.d.ts +1 -1
- package/lib/components/BottomSheet/BottomSheet.namespace.js +18 -1
- package/lib/components/BottomSheet/index.d.ts +2 -2
- package/lib/components/Box/Box.d.ts +20 -0
- package/lib/components/Box/Box.d.ts.map +1 -0
- package/lib/components/Box/Box.jsx +14 -0
- package/lib/components/Box/index.d.ts +2 -0
- package/lib/components/Box/index.d.ts.map +1 -0
- package/lib/components/Checkbox/Checkbox.d.ts +14 -31
- package/lib/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/lib/components/Checkbox/Checkbox.jsx +107 -98
- package/lib/components/Checkbox/Checkbox.namespace.d.ts +1 -1
- package/lib/components/Checkbox/Checkbox.namespace.js +12 -1
- package/lib/components/Checkbox/index.d.ts +2 -2
- package/lib/components/Icon/Icon.d.ts +37 -0
- package/lib/components/Icon/Icon.d.ts.map +1 -0
- package/lib/components/Icon/Icon.jsx +143 -0
- package/lib/components/Icon/index.d.ts +2 -0
- package/lib/components/Icon/index.d.ts.map +1 -0
- package/lib/components/ProgressCircle/ProgressCircle.d.ts +4 -8
- package/lib/components/ProgressCircle/ProgressCircle.d.ts.map +1 -1
- package/lib/components/ProgressCircle/ProgressCircle.jsx +255 -260
- package/lib/components/ProgressCircle/ProgressCircle.namespace.d.ts +1 -1
- package/lib/components/ProgressCircle/ProgressCircle.namespace.js +9 -1
- package/lib/components/ProgressCircle/index.d.ts +2 -2
- package/lib/components/RadioGroup/RadioGroup.d.ts +12 -29
- package/lib/components/RadioGroup/RadioGroup.d.ts.map +1 -1
- package/lib/components/RadioGroup/RadioGroup.jsx +134 -118
- package/lib/components/RadioGroup/RadioGroup.namespace.d.ts +1 -1
- package/lib/components/RadioGroup/RadioGroup.namespace.js +12 -1
- package/lib/components/RadioGroup/index.d.ts +2 -2
- package/lib/components/Stack/Stack.d.ts +33 -0
- package/lib/components/Stack/Stack.d.ts.map +1 -0
- package/lib/components/Stack/Stack.jsx +39 -0
- package/lib/components/Stack/index.d.ts +2 -0
- package/lib/components/Stack/index.d.ts.map +1 -0
- package/lib/components/Switch/Switch.d.ts +8 -14
- package/lib/components/Switch/Switch.d.ts.map +1 -1
- package/lib/components/Switch/Switch.jsx +82 -56
- package/lib/components/Switch/Switch.namespace.d.ts +1 -1
- package/lib/components/Switch/Switch.namespace.js +11 -1
- package/lib/components/Switch/index.d.ts +2 -2
- package/lib/components/TagGroup/TagGroup.d.ts +8 -14
- package/lib/components/TagGroup/TagGroup.d.ts.map +1 -1
- package/lib/components/TagGroup/TagGroup.jsx +42 -39
- package/lib/components/TagGroup/TagGroup.namespace.d.ts +1 -1
- package/lib/components/TagGroup/TagGroup.namespace.js +10 -1
- package/lib/components/TagGroup/index.d.ts +2 -2
- package/lib/components/Text/Text.d.ts +7 -0
- package/lib/components/Text/Text.d.ts.map +1 -0
- package/lib/components/Text/Text.jsx +28 -0
- package/lib/components/Text/index.d.ts +2 -0
- package/lib/components/Text/index.d.ts.map +1 -0
- package/lib/components/index.d.ts +13 -7
- package/lib/components/index.d.ts.map +1 -1
- package/lib/hooks/index.d.ts +5 -3
- package/lib/hooks/index.d.ts.map +1 -1
- package/lib/hooks/useControllableState.js +23 -23
- package/lib/hooks/useIconColor.d.ts +6 -3
- package/lib/hooks/useIconColor.d.ts.map +1 -1
- package/lib/hooks/useIconColor.js +34 -37
- package/lib/hooks/usePressTap.d.ts +11 -8
- package/lib/hooks/usePressTap.d.ts.map +1 -1
- package/lib/hooks/usePressTap.js +31 -31
- package/lib/hooks/useSafeArea.d.ts +19 -0
- package/lib/hooks/useSafeArea.d.ts.map +1 -0
- package/lib/hooks/useSafeArea.js +33 -0
- package/lib/hooks/useSeedClassName.d.ts +27 -0
- package/lib/hooks/useSeedClassName.d.ts.map +1 -0
- package/lib/hooks/useSeedClassName.js +32 -0
- package/lib/index.d.ts +4 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +30 -3
- package/lib/types.d.ts +51 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/utils/children.d.ts +3 -0
- package/lib/utils/children.d.ts.map +1 -0
- package/lib/utils/children.js +8 -0
- package/lib/utils/create-slot-recipe-context.d.ts +13 -12
- package/lib/utils/create-slot-recipe-context.d.ts.map +1 -1
- package/lib/utils/create-slot-recipe-context.jsx +88 -70
- package/lib/utils/get-seed-class-name.d.ts +9 -7
- package/lib/utils/get-seed-class-name.d.ts.map +1 -1
- package/lib/utils/get-seed-class-name.js +29 -37
- package/lib/utils/index.d.ts +4 -4
- package/lib/utils/resolve-recipe-token.js +45 -43
- package/lib/utils/split-multiple-variants-props.js +32 -32
- package/lib/utils/styled.d.ts +83 -0
- package/lib/utils/styled.d.ts.map +1 -0
- package/lib/utils/styled.js +144 -0
- package/package.json +10 -9
- package/src/components/ActionButton/ActionButton.test.tsx +167 -0
- package/src/components/ActionButton/ActionButton.tsx +210 -169
- package/src/components/AppBar/AppBar.namespace.ts +18 -0
- package/src/components/AppBar/AppBar.test.tsx +270 -0
- package/src/components/AppBar/AppBar.tsx +288 -0
- package/src/components/AppBar/context.ts +27 -0
- package/src/components/AppBar/index.ts +21 -0
- package/src/components/AppBar/useAppBar.ts +100 -0
- package/src/components/Badge/Badge.test.tsx +54 -0
- package/src/components/Badge/Badge.tsx +32 -0
- package/src/components/Badge/index.ts +1 -0
- package/src/components/BottomSheet/BottomSheet.test.tsx +219 -0
- package/src/components/BottomSheet/BottomSheet.tsx +120 -83
- package/src/components/Box/Box.test.tsx +85 -0
- package/src/components/Box/Box.tsx +39 -0
- package/src/components/Box/index.ts +1 -0
- package/src/components/Checkbox/Checkbox.tsx +106 -116
- package/src/components/Icon/Icon.tsx +265 -0
- package/src/components/Icon/index.ts +8 -0
- package/src/components/ProgressCircle/ProgressCircle.tsx +39 -25
- package/src/components/RadioGroup/RadioGroup.tsx +98 -117
- package/src/components/Stack/Stack.tsx +97 -0
- package/src/components/Stack/index.ts +1 -0
- package/src/components/Switch/Switch.tsx +59 -50
- package/src/components/TagGroup/TagGroup.tsx +27 -25
- package/src/components/Text/Text.tsx +64 -0
- package/src/components/Text/index.ts +1 -0
- package/src/components/index.ts +6 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/{__tests__/useControllableState.test.ts → useControllableState.test.ts} +1 -1
- package/src/hooks/{__tests__/useIconColor.test.ts → useIconColor.test.ts} +1 -1
- package/src/hooks/useIconColor.ts +22 -12
- package/src/hooks/{__tests__/usePressTap.test.ts → usePressTap.test.ts} +1 -1
- package/src/hooks/usePressTap.ts +14 -10
- package/src/hooks/useSafeArea.test.ts +83 -0
- package/src/hooks/useSafeArea.ts +56 -0
- package/src/hooks/useSeedClassName.ts +35 -0
- package/src/index.ts +1 -0
- package/src/types.ts +76 -0
- package/src/utils/children.ts +13 -0
- package/src/utils/create-slot-recipe-context.test.tsx +96 -0
- package/src/utils/create-slot-recipe-context.tsx +55 -15
- package/src/utils/get-seed-class-name.ts +10 -12
- package/src/utils/{__tests__/split-multiple-variants-props.test.ts → split-multiple-variants-props.test.ts} +1 -1
- package/src/utils/styled.ts +442 -0
- package/lib/components/ActionButton/index.js +0 -1
- package/lib/components/BottomSheet/index.js +0 -2
- package/lib/components/Checkbox/index.js +0 -2
- package/lib/components/ProgressCircle/index.js +0 -2
- package/lib/components/RadioGroup/index.js +0 -2
- package/lib/components/Switch/index.js +0 -2
- package/lib/components/TagGroup/index.js +0 -2
- package/lib/components/index.js +0 -7
- package/lib/hooks/index.js +0 -3
- package/lib/utils/index.js +0 -4
- package/src/components/ActionButton/__tests__/ActionButton.test.tsx +0 -35
- package/src/components/BottomSheet/__tests__/BottomSheet.test.tsx +0 -119
- package/src/components/__tests__/ProgressCircle.test.ts +0 -33
- package/src/components/__tests__/exports.test.ts +0 -38
- package/src/components/__tests__/switch.test.ts +0 -34
- package/src/utils/__tests__/create-slot-recipe-context.test.tsx +0 -228
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
import type { CSSProperties } from "@lynx-js/types";
|
|
2
|
+
import type {
|
|
3
|
+
Dimension,
|
|
4
|
+
FontSize,
|
|
5
|
+
FontWeight,
|
|
6
|
+
LineHeight,
|
|
7
|
+
Radius,
|
|
8
|
+
ScopedColorBanner,
|
|
9
|
+
ScopedColorBg,
|
|
10
|
+
ScopedColorFg,
|
|
11
|
+
ScopedColorPalette,
|
|
12
|
+
ScopedColorStroke,
|
|
13
|
+
SpacingX,
|
|
14
|
+
SpacingY,
|
|
15
|
+
} from "@seed-design/lynx-css/vars";
|
|
16
|
+
import { vars } from "@seed-design/lynx-css/vars";
|
|
17
|
+
|
|
18
|
+
import { useSafeArea } from "../hooks/useSafeArea";
|
|
19
|
+
|
|
20
|
+
export function handleColor(color: string | undefined) {
|
|
21
|
+
if (!color) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
const [type, value] = color.split(".");
|
|
25
|
+
// @ts-expect-error token category is derived from the public string contract.
|
|
26
|
+
return vars.$color[type]?.[value] ?? color;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function handleDimension(dimension: number | string | undefined): string | undefined {
|
|
30
|
+
if (dimension == null) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (typeof dimension === "number") {
|
|
35
|
+
return `${dimension}px`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (dimension === "full") {
|
|
39
|
+
return "100%";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const [type, value] = dimension.split(".");
|
|
43
|
+
|
|
44
|
+
// @ts-expect-error token category is derived from the public string contract.
|
|
45
|
+
return vars.$dimension[dimension] ?? vars.$dimension[type]?.[value] ?? dimension;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function resolveFlexValue(
|
|
49
|
+
value: number | string | boolean | undefined,
|
|
50
|
+
): number | string | undefined {
|
|
51
|
+
if (value === true) return 1;
|
|
52
|
+
if (value === false) return 0;
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function handleBorderWidth(width: 0 | 1 | (string & {}) | undefined) {
|
|
57
|
+
if (width == null) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (typeof width === "number") {
|
|
62
|
+
return `${width}px`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return width;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function handlePaddingWithSafeArea(
|
|
69
|
+
padding: string | 0 | undefined,
|
|
70
|
+
safeAreaInset: string,
|
|
71
|
+
): string | undefined {
|
|
72
|
+
if (padding === "safeArea") {
|
|
73
|
+
return safeAreaInset;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return handleDimension(padding);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function handleRadius(radius: string | 0 | undefined) {
|
|
80
|
+
if (radius == null) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
// @ts-expect-error token category is derived from the public string contract.
|
|
84
|
+
return vars.$radius[radius] ?? radius;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function handleDisplay(display: string | undefined) {
|
|
88
|
+
if (!display) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
{
|
|
94
|
+
flex: "flex",
|
|
95
|
+
none: "none",
|
|
96
|
+
}[display] ?? display
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function handleFlexDirection(flexDirection: string | undefined) {
|
|
101
|
+
if (!flexDirection) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
{
|
|
107
|
+
row: "row",
|
|
108
|
+
column: "column",
|
|
109
|
+
rowReverse: "row-reverse",
|
|
110
|
+
columnReverse: "column-reverse",
|
|
111
|
+
}[flexDirection] ?? flexDirection
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function handleJustifyContent(justifyContent: string | undefined) {
|
|
116
|
+
if (!justifyContent) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
{
|
|
122
|
+
flexStart: "flex-start",
|
|
123
|
+
flexEnd: "flex-end",
|
|
124
|
+
center: "center",
|
|
125
|
+
spaceBetween: "space-between",
|
|
126
|
+
spaceAround: "space-around",
|
|
127
|
+
}[justifyContent] ?? justifyContent
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function handleAlignItems(alignItems: string | undefined) {
|
|
132
|
+
if (!alignItems) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
{
|
|
138
|
+
flexStart: "flex-start",
|
|
139
|
+
flexEnd: "flex-end",
|
|
140
|
+
center: "center",
|
|
141
|
+
stretch: "stretch",
|
|
142
|
+
}[alignItems] ?? alignItems
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function handleFontWeight(fontWeight: string | undefined) {
|
|
147
|
+
if (!fontWeight) {
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
// @ts-expect-error token category is derived from the public string contract.
|
|
151
|
+
return vars.$fontWeight[fontWeight] ?? fontWeight;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function handleFontSize(size: string | undefined) {
|
|
155
|
+
if (!size) {
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
// @ts-expect-error token category is derived from the public string contract.
|
|
159
|
+
return vars.$fontSize[size] ?? size;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function handleLineHeight(lineHeight: string | undefined) {
|
|
163
|
+
if (!lineHeight) {
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
// @ts-expect-error token category is derived from the public string contract.
|
|
167
|
+
return vars.$lineHeight[lineHeight] ?? lineHeight;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export interface StyleProps {
|
|
171
|
+
bg?: ScopedColorBg | ScopedColorPalette | ScopedColorBanner | (string & {});
|
|
172
|
+
background?: ScopedColorBg | ScopedColorPalette | ScopedColorBanner | (string & {});
|
|
173
|
+
color?: ScopedColorFg | ScopedColorPalette | (string & {});
|
|
174
|
+
borderColor?: ScopedColorStroke | ScopedColorPalette | (string & {});
|
|
175
|
+
borderWidth?: 0 | 1 | (string & {});
|
|
176
|
+
borderTopWidth?: 0 | 1 | (string & {});
|
|
177
|
+
borderRightWidth?: 0 | 1 | (string & {});
|
|
178
|
+
borderBottomWidth?: 0 | 1 | (string & {});
|
|
179
|
+
borderLeftWidth?: 0 | 1 | (string & {});
|
|
180
|
+
borderRadius?: Radius | 0 | (string & {});
|
|
181
|
+
borderTopLeftRadius?: Radius | 0 | (string & {});
|
|
182
|
+
borderTopRightRadius?: Radius | 0 | (string & {});
|
|
183
|
+
borderBottomRightRadius?: Radius | 0 | (string & {});
|
|
184
|
+
borderBottomLeftRadius?: Radius | 0 | (string & {});
|
|
185
|
+
width?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
|
|
186
|
+
minWidth?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
|
|
187
|
+
maxWidth?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
|
|
188
|
+
height?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
|
|
189
|
+
minHeight?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
|
|
190
|
+
maxHeight?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
|
|
191
|
+
top?: 0 | (string & {});
|
|
192
|
+
left?: 0 | (string & {});
|
|
193
|
+
right?: 0 | (string & {});
|
|
194
|
+
bottom?: 0 | (string & {});
|
|
195
|
+
padding?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
196
|
+
p?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
197
|
+
paddingX?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
198
|
+
px?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
199
|
+
paddingY?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
200
|
+
py?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
201
|
+
paddingTop?:
|
|
202
|
+
| Dimension
|
|
203
|
+
| `spacingX.${SpacingX}`
|
|
204
|
+
| `spacingY.${SpacingY}`
|
|
205
|
+
| 0
|
|
206
|
+
| "safeArea"
|
|
207
|
+
| (string & {});
|
|
208
|
+
pt?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | "safeArea" | (string & {});
|
|
209
|
+
paddingRight?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
210
|
+
pr?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
211
|
+
paddingBottom?:
|
|
212
|
+
| Dimension
|
|
213
|
+
| `spacingX.${SpacingX}`
|
|
214
|
+
| `spacingY.${SpacingY}`
|
|
215
|
+
| 0
|
|
216
|
+
| "safeArea"
|
|
217
|
+
| (string & {});
|
|
218
|
+
pb?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | "safeArea" | (string & {});
|
|
219
|
+
paddingLeft?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
220
|
+
pl?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
221
|
+
display?: "flex" | "none" | (string & {});
|
|
222
|
+
position?: "relative" | "absolute" | "fixed" | (string & {});
|
|
223
|
+
overflowX?: "visible" | "hidden" | (string & {});
|
|
224
|
+
overflowY?: "visible" | "hidden" | (string & {});
|
|
225
|
+
zIndex?: CSSProperties["zIndex"];
|
|
226
|
+
flexGrow?: CSSProperties["flexGrow"] | boolean;
|
|
227
|
+
flexShrink?: CSSProperties["flexShrink"] | boolean;
|
|
228
|
+
flexDirection?: "row" | "column" | "rowReverse" | "columnReverse" | (string & {});
|
|
229
|
+
flexWrap?: "nowrap" | "wrap" | boolean;
|
|
230
|
+
justifyContent?:
|
|
231
|
+
| "flexStart"
|
|
232
|
+
| "flexEnd"
|
|
233
|
+
| "center"
|
|
234
|
+
| "spaceBetween"
|
|
235
|
+
| "spaceAround"
|
|
236
|
+
| (string & {});
|
|
237
|
+
justifySelf?: CSSProperties["justifySelf"];
|
|
238
|
+
alignItems?: "flexStart" | "flexEnd" | "center" | "stretch" | (string & {});
|
|
239
|
+
alignContent?: "flexStart" | "flexEnd" | "center" | "stretch" | (string & {});
|
|
240
|
+
alignSelf?: "flexStart" | "flexEnd" | "center" | "stretch" | (string & {});
|
|
241
|
+
gap?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
interface UseStyleProps extends StyleProps {
|
|
245
|
+
style?: CSSProperties;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export function useStyleProps<T extends UseStyleProps>(
|
|
249
|
+
props: T,
|
|
250
|
+
): {
|
|
251
|
+
style: CSSProperties;
|
|
252
|
+
restProps: Omit<T, keyof UseStyleProps>;
|
|
253
|
+
} {
|
|
254
|
+
const {
|
|
255
|
+
background,
|
|
256
|
+
bg,
|
|
257
|
+
color,
|
|
258
|
+
borderColor,
|
|
259
|
+
borderWidth,
|
|
260
|
+
borderTopWidth,
|
|
261
|
+
borderRightWidth,
|
|
262
|
+
borderBottomWidth,
|
|
263
|
+
borderLeftWidth,
|
|
264
|
+
borderRadius,
|
|
265
|
+
borderTopLeftRadius,
|
|
266
|
+
borderTopRightRadius,
|
|
267
|
+
borderBottomRightRadius,
|
|
268
|
+
borderBottomLeftRadius,
|
|
269
|
+
width,
|
|
270
|
+
minWidth,
|
|
271
|
+
maxWidth,
|
|
272
|
+
height,
|
|
273
|
+
minHeight,
|
|
274
|
+
maxHeight,
|
|
275
|
+
padding,
|
|
276
|
+
paddingX,
|
|
277
|
+
paddingY,
|
|
278
|
+
paddingTop,
|
|
279
|
+
paddingRight,
|
|
280
|
+
paddingBottom,
|
|
281
|
+
paddingLeft,
|
|
282
|
+
p,
|
|
283
|
+
px,
|
|
284
|
+
py,
|
|
285
|
+
pt,
|
|
286
|
+
pr,
|
|
287
|
+
pb,
|
|
288
|
+
pl,
|
|
289
|
+
bottom,
|
|
290
|
+
left,
|
|
291
|
+
right,
|
|
292
|
+
top,
|
|
293
|
+
display,
|
|
294
|
+
position,
|
|
295
|
+
overflowX,
|
|
296
|
+
overflowY,
|
|
297
|
+
zIndex,
|
|
298
|
+
flexGrow,
|
|
299
|
+
flexShrink,
|
|
300
|
+
flexDirection,
|
|
301
|
+
flexWrap,
|
|
302
|
+
justifyContent,
|
|
303
|
+
justifySelf,
|
|
304
|
+
alignItems,
|
|
305
|
+
alignContent,
|
|
306
|
+
alignSelf,
|
|
307
|
+
gap,
|
|
308
|
+
style,
|
|
309
|
+
...restProps
|
|
310
|
+
} = props;
|
|
311
|
+
const { safeAreaInsetTop, safeAreaInsetBottom } = useSafeArea();
|
|
312
|
+
|
|
313
|
+
const backgroundValue = handleColor(background ?? bg);
|
|
314
|
+
const paddingValue = handleDimension(padding ?? p);
|
|
315
|
+
const paddingXValue = handleDimension(paddingX ?? px) ?? paddingValue;
|
|
316
|
+
const paddingYValue = handleDimension(paddingY ?? py) ?? paddingValue;
|
|
317
|
+
const paddingTopValue =
|
|
318
|
+
handlePaddingWithSafeArea(paddingTop ?? pt, safeAreaInsetTop) ?? paddingYValue;
|
|
319
|
+
const paddingRightValue = handleDimension(paddingRight ?? pr) ?? paddingXValue;
|
|
320
|
+
const paddingBottomValue =
|
|
321
|
+
handlePaddingWithSafeArea(paddingBottom ?? pb, safeAreaInsetBottom) ?? paddingYValue;
|
|
322
|
+
const paddingLeftValue = handleDimension(paddingLeft ?? pl) ?? paddingXValue;
|
|
323
|
+
const hasBorderStyle =
|
|
324
|
+
borderColor != null ||
|
|
325
|
+
borderWidth != null ||
|
|
326
|
+
borderTopWidth != null ||
|
|
327
|
+
borderRightWidth != null ||
|
|
328
|
+
borderBottomWidth != null ||
|
|
329
|
+
borderLeftWidth != null;
|
|
330
|
+
|
|
331
|
+
return {
|
|
332
|
+
style: {
|
|
333
|
+
background: backgroundValue,
|
|
334
|
+
color: handleColor(color),
|
|
335
|
+
borderStyle: hasBorderStyle ? "solid" : undefined,
|
|
336
|
+
borderColor: handleColor(borderColor),
|
|
337
|
+
borderWidth: handleBorderWidth(borderWidth),
|
|
338
|
+
borderTopWidth: handleBorderWidth(borderTopWidth),
|
|
339
|
+
borderRightWidth: handleBorderWidth(borderRightWidth),
|
|
340
|
+
borderBottomWidth: handleBorderWidth(borderBottomWidth),
|
|
341
|
+
borderLeftWidth: handleBorderWidth(borderLeftWidth),
|
|
342
|
+
borderRadius: handleRadius(borderRadius),
|
|
343
|
+
borderTopLeftRadius: handleRadius(borderTopLeftRadius),
|
|
344
|
+
borderTopRightRadius: handleRadius(borderTopRightRadius),
|
|
345
|
+
borderBottomRightRadius: handleRadius(borderBottomRightRadius),
|
|
346
|
+
borderBottomLeftRadius: handleRadius(borderBottomLeftRadius),
|
|
347
|
+
width: handleDimension(width),
|
|
348
|
+
minWidth: handleDimension(minWidth),
|
|
349
|
+
maxWidth: handleDimension(maxWidth),
|
|
350
|
+
height: handleDimension(height),
|
|
351
|
+
minHeight: handleDimension(minHeight),
|
|
352
|
+
maxHeight: handleDimension(maxHeight),
|
|
353
|
+
paddingTop: paddingTopValue,
|
|
354
|
+
paddingRight: paddingRightValue,
|
|
355
|
+
paddingBottom: paddingBottomValue,
|
|
356
|
+
paddingLeft: paddingLeftValue,
|
|
357
|
+
top: handleDimension(top),
|
|
358
|
+
left: handleDimension(left),
|
|
359
|
+
right: handleDimension(right),
|
|
360
|
+
bottom: handleDimension(bottom),
|
|
361
|
+
gap: handleDimension(gap),
|
|
362
|
+
display: handleDisplay(display),
|
|
363
|
+
position,
|
|
364
|
+
overflowX,
|
|
365
|
+
overflowY,
|
|
366
|
+
zIndex,
|
|
367
|
+
flexGrow: resolveFlexValue(flexGrow),
|
|
368
|
+
flexShrink: resolveFlexValue(flexShrink),
|
|
369
|
+
flexDirection: handleFlexDirection(flexDirection),
|
|
370
|
+
flexWrap: flexWrap === true ? "wrap" : flexWrap === false ? "nowrap" : flexWrap,
|
|
371
|
+
justifyContent: handleJustifyContent(justifyContent),
|
|
372
|
+
justifySelf,
|
|
373
|
+
alignItems: handleAlignItems(alignItems),
|
|
374
|
+
alignContent: handleAlignItems(alignContent),
|
|
375
|
+
alignSelf: handleAlignItems(alignSelf),
|
|
376
|
+
...style,
|
|
377
|
+
} as CSSProperties,
|
|
378
|
+
restProps,
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export type TextStyle =
|
|
383
|
+
| "screenTitle"
|
|
384
|
+
| "articleBody"
|
|
385
|
+
| "articleNote"
|
|
386
|
+
| "t1Regular"
|
|
387
|
+
| "t1Medium"
|
|
388
|
+
| "t1Bold"
|
|
389
|
+
| "t2Regular"
|
|
390
|
+
| "t2Medium"
|
|
391
|
+
| "t2Bold"
|
|
392
|
+
| "t3Regular"
|
|
393
|
+
| "t3Medium"
|
|
394
|
+
| "t3Bold"
|
|
395
|
+
| "t4Regular"
|
|
396
|
+
| "t4Medium"
|
|
397
|
+
| "t4Bold"
|
|
398
|
+
| "t5Regular"
|
|
399
|
+
| "t5Medium"
|
|
400
|
+
| "t5Bold"
|
|
401
|
+
| "t6Regular"
|
|
402
|
+
| "t6Medium"
|
|
403
|
+
| "t6Bold"
|
|
404
|
+
| "t7Regular"
|
|
405
|
+
| "t7Medium"
|
|
406
|
+
| "t7Bold"
|
|
407
|
+
| "t8Bold"
|
|
408
|
+
| "t9Bold"
|
|
409
|
+
| "t10Bold"
|
|
410
|
+
| "t1StaticRegular"
|
|
411
|
+
| "t1StaticMedium"
|
|
412
|
+
| "t1StaticBold"
|
|
413
|
+
| "t2StaticRegular"
|
|
414
|
+
| "t2StaticMedium"
|
|
415
|
+
| "t2StaticBold"
|
|
416
|
+
| "t3StaticRegular"
|
|
417
|
+
| "t3StaticMedium"
|
|
418
|
+
| "t3StaticBold"
|
|
419
|
+
| "t4StaticRegular"
|
|
420
|
+
| "t4StaticMedium"
|
|
421
|
+
| "t4StaticBold"
|
|
422
|
+
| "t5StaticRegular"
|
|
423
|
+
| "t5StaticMedium"
|
|
424
|
+
| "t5StaticBold"
|
|
425
|
+
| "t6StaticRegular"
|
|
426
|
+
| "t6StaticMedium"
|
|
427
|
+
| "t6StaticBold"
|
|
428
|
+
| "t7StaticRegular"
|
|
429
|
+
| "t7StaticMedium"
|
|
430
|
+
| "t7StaticBold"
|
|
431
|
+
| "t8StaticBold"
|
|
432
|
+
| "t9StaticBold"
|
|
433
|
+
| "t10StaticBold";
|
|
434
|
+
|
|
435
|
+
export interface TextStyleProps {
|
|
436
|
+
color?: ScopedColorFg | ScopedColorPalette | (string & {});
|
|
437
|
+
fontSize?: FontSize | (string & {});
|
|
438
|
+
lineHeight?: LineHeight | (string & {});
|
|
439
|
+
fontWeight?: FontWeight;
|
|
440
|
+
textStyle?: TextStyle;
|
|
441
|
+
align?: "left" | "center" | "right";
|
|
442
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ActionButton } from "./ActionButton";
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export { BottomSheetBackdrop, BottomSheetBody, BottomSheetContent, BottomSheetDescription, BottomSheetFooter, BottomSheetHandle, BottomSheetHeader, BottomSheetPositioner, BottomSheetRoot, BottomSheetTitle, BottomSheetTrigger, } from "./BottomSheet";
|
|
2
|
-
export * as BottomSheet from "./BottomSheet.namespace";
|
package/lib/components/index.js
DELETED
package/lib/hooks/index.js
DELETED
package/lib/utils/index.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import "@testing-library/jest-dom";
|
|
2
|
-
import { getQueriesForElement, render } from "@lynx-js/react/testing-library";
|
|
3
|
-
import { describe, expect, it } from "vitest";
|
|
4
|
-
|
|
5
|
-
import { ActionButton } from "../ActionButton";
|
|
6
|
-
|
|
7
|
-
function getRenderedQueries() {
|
|
8
|
-
return getQueriesForElement(getRenderedRoot());
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function getRenderedRoot() {
|
|
12
|
-
const root = elementTree.root;
|
|
13
|
-
|
|
14
|
-
if (!root) {
|
|
15
|
-
throw new Error("Expected Lynx render root to exist.");
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return root;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
describe("ActionButton", () => {
|
|
22
|
-
it("keeps the original label in the text slot while loading", () => {
|
|
23
|
-
render(<ActionButton loading>Submit</ActionButton>);
|
|
24
|
-
|
|
25
|
-
const { getByText } = getRenderedQueries();
|
|
26
|
-
const label = getByText("Submit");
|
|
27
|
-
const root = getRenderedRoot();
|
|
28
|
-
|
|
29
|
-
expect(label).toHaveClass("seed-action-button__text");
|
|
30
|
-
expect(label).toHaveClass("seed-action-button__text--size_medium-layout_withText");
|
|
31
|
-
expect(root.querySelector(".seed-action-button__content")).toBeInTheDocument();
|
|
32
|
-
expect(root.querySelector(".seed-action-button__loadingIndicator")).toBeInTheDocument();
|
|
33
|
-
expect(root.querySelector(".seed-progress-circle__root")).toBeInTheDocument();
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { fireEvent, render } from "@lynx-js/react/testing-library";
|
|
2
|
-
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
-
|
|
4
|
-
const sheetMocks = vi.hoisted(() => ({
|
|
5
|
-
contentProps: [] as Array<Record<string, unknown>>,
|
|
6
|
-
rootRef: {
|
|
7
|
-
open: vi.fn(),
|
|
8
|
-
},
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
vi.mock("@lynx-js/lynx-ui-sheet", async () => {
|
|
12
|
-
const React = await vi.importActual<typeof import("@lynx-js/react")>("@lynx-js/react");
|
|
13
|
-
|
|
14
|
-
const SheetRoot = React.forwardRef<unknown, { children?: React.ReactNode }>((props, ref) => {
|
|
15
|
-
React.useImperativeHandle(ref, () => sheetMocks.rootRef);
|
|
16
|
-
return <>{props.children}</>;
|
|
17
|
-
});
|
|
18
|
-
SheetRoot.displayName = "MockSheetRoot";
|
|
19
|
-
|
|
20
|
-
const SheetView = React.forwardRef<unknown, { children?: React.ReactNode }>((props) => {
|
|
21
|
-
return <>{props.children}</>;
|
|
22
|
-
});
|
|
23
|
-
SheetView.displayName = "MockSheetView";
|
|
24
|
-
|
|
25
|
-
const SheetContent = React.forwardRef<unknown, Record<string, unknown>>((props) => {
|
|
26
|
-
sheetMocks.contentProps.push(props);
|
|
27
|
-
return <>{props.children as React.ReactNode}</>;
|
|
28
|
-
});
|
|
29
|
-
SheetContent.displayName = "MockSheetContent";
|
|
30
|
-
|
|
31
|
-
const passthrough = (displayName: string) => {
|
|
32
|
-
const Component = React.forwardRef<unknown, { children?: React.ReactNode }>((props) => {
|
|
33
|
-
return <>{props.children}</>;
|
|
34
|
-
});
|
|
35
|
-
Component.displayName = displayName;
|
|
36
|
-
return Component;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
SheetBackdrop: passthrough("MockSheetBackdrop"),
|
|
41
|
-
SheetContent,
|
|
42
|
-
SheetHandle: passthrough("MockSheetHandle"),
|
|
43
|
-
SheetRoot,
|
|
44
|
-
SheetView,
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
import * as BottomSheet from "../BottomSheet.namespace";
|
|
49
|
-
|
|
50
|
-
describe("BottomSheet", () => {
|
|
51
|
-
beforeEach(() => {
|
|
52
|
-
sheetMocks.contentProps = [];
|
|
53
|
-
sheetMocks.rootRef.open.mockClear();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("skips motion-engine animations when Root has skipAnimation", () => {
|
|
57
|
-
render(
|
|
58
|
-
<BottomSheet.Root skipAnimation>
|
|
59
|
-
<BottomSheet.Content />
|
|
60
|
-
</BottomSheet.Root>,
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
expect(sheetMocks.contentProps.at(-1)).toMatchObject({
|
|
64
|
-
snapAnimation: { type: "tween", duration: 0 },
|
|
65
|
-
enterAnimation: { type: "tween", duration: 0 },
|
|
66
|
-
exitAnimation: { type: "tween", duration: 0 },
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("preserves user-provided animations when Root has skipAnimation", () => {
|
|
71
|
-
const snapAnimation = { type: "tween", duration: 120 };
|
|
72
|
-
const enterAnimation = { type: "tween", duration: 140 };
|
|
73
|
-
const exitAnimation = { type: "tween", duration: 90 };
|
|
74
|
-
|
|
75
|
-
render(
|
|
76
|
-
<BottomSheet.Root skipAnimation>
|
|
77
|
-
<BottomSheet.Content
|
|
78
|
-
snapAnimation={snapAnimation}
|
|
79
|
-
enterAnimation={enterAnimation}
|
|
80
|
-
exitAnimation={exitAnimation}
|
|
81
|
-
/>
|
|
82
|
-
</BottomSheet.Root>,
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
expect(sheetMocks.contentProps.at(-1)).toMatchObject({
|
|
86
|
-
snapAnimation,
|
|
87
|
-
enterAnimation,
|
|
88
|
-
exitAnimation,
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it("opens with default animation when Root does not skip animation", () => {
|
|
93
|
-
const { getByText } = render(
|
|
94
|
-
<BottomSheet.Root>
|
|
95
|
-
<BottomSheet.Trigger>
|
|
96
|
-
<text>Open sheet</text>
|
|
97
|
-
</BottomSheet.Trigger>
|
|
98
|
-
</BottomSheet.Root>,
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
fireEvent.tap(getByText("Open sheet").parentElement!);
|
|
102
|
-
|
|
103
|
-
expect(sheetMocks.rootRef.open).toHaveBeenCalledWith();
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it("opens without animation when Trigger is tapped inside a skipping Root", () => {
|
|
107
|
-
const { getByText } = render(
|
|
108
|
-
<BottomSheet.Root skipAnimation>
|
|
109
|
-
<BottomSheet.Trigger>
|
|
110
|
-
<text>Open sheet</text>
|
|
111
|
-
</BottomSheet.Trigger>
|
|
112
|
-
</BottomSheet.Root>,
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
fireEvent.tap(getByText("Open sheet").parentElement!);
|
|
116
|
-
|
|
117
|
-
expect(sheetMocks.rootRef.open).toHaveBeenCalledWith({ animate: false });
|
|
118
|
-
});
|
|
119
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import { dirname, join } from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
|
|
6
|
-
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
const progressCircleSource = readFileSync(
|
|
8
|
-
join(currentDir, "..", "ProgressCircle", "ProgressCircle.tsx"),
|
|
9
|
-
"utf8",
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
function readEffectDependencies(marker: string): string {
|
|
13
|
-
const markerIndex = progressCircleSource.indexOf(marker);
|
|
14
|
-
expect(markerIndex).toBeGreaterThanOrEqual(0);
|
|
15
|
-
|
|
16
|
-
const dependencyStart = progressCircleSource.indexOf("}, [", markerIndex);
|
|
17
|
-
expect(dependencyStart).toBeGreaterThanOrEqual(0);
|
|
18
|
-
|
|
19
|
-
const dependencyEnd = progressCircleSource.indexOf("]);", dependencyStart);
|
|
20
|
-
expect(dependencyEnd).toBeGreaterThanOrEqual(0);
|
|
21
|
-
|
|
22
|
-
return progressCircleSource.slice(dependencyStart, dependencyEnd);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
describe("ProgressCircle", () => {
|
|
26
|
-
it("restarts indeterminate animation when size changes", () => {
|
|
27
|
-
expect(readEffectDependencies("runOnMainThread(startLoop)")).toContain("numSize");
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("restarts determinate transition when size changes", () => {
|
|
31
|
-
expect(readEffectDependencies("runOnMainThread(startAnimation)")).toContain("numSize");
|
|
32
|
-
});
|
|
33
|
-
});
|