@seed-design/lynx-react 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_virtual/_rolldown/runtime.js +13 -0
- package/lib/components/ActionButton/ActionButton.d.ts +44 -0
- package/lib/components/ActionButton/ActionButton.d.ts.map +1 -0
- package/lib/components/ActionButton/ActionButton.jsx +158 -0
- package/lib/components/ActionButton/index.d.ts +2 -0
- package/lib/components/ActionButton/index.d.ts.map +1 -0
- package/lib/components/BottomSheet/BottomSheet.d.ts +87 -0
- package/lib/components/BottomSheet/BottomSheet.d.ts.map +1 -0
- package/lib/components/BottomSheet/BottomSheet.jsx +150 -0
- package/lib/components/BottomSheet/BottomSheet.namespace.d.ts +2 -0
- package/lib/components/BottomSheet/BottomSheet.namespace.d.ts.map +1 -0
- package/lib/components/BottomSheet/BottomSheet.namespace.js +18 -0
- package/lib/components/BottomSheet/index.d.ts +3 -0
- package/lib/components/BottomSheet/index.d.ts.map +1 -0
- 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 +35 -0
- package/lib/components/Checkbox/Checkbox.d.ts.map +1 -0
- package/lib/components/Checkbox/Checkbox.jsx +130 -0
- package/lib/components/Checkbox/Checkbox.namespace.d.ts +2 -0
- package/lib/components/Checkbox/Checkbox.namespace.d.ts.map +1 -0
- package/lib/components/Checkbox/Checkbox.namespace.js +12 -0
- package/lib/components/Checkbox/index.d.ts +3 -0
- package/lib/components/Checkbox/index.d.ts.map +1 -0
- 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 +25 -0
- package/lib/components/ProgressCircle/ProgressCircle.d.ts.map +1 -0
- package/lib/components/ProgressCircle/ProgressCircle.jsx +281 -0
- package/lib/components/ProgressCircle/ProgressCircle.namespace.d.ts +2 -0
- package/lib/components/ProgressCircle/ProgressCircle.namespace.d.ts.map +1 -0
- package/lib/components/ProgressCircle/ProgressCircle.namespace.js +9 -0
- package/lib/components/ProgressCircle/index.d.ts +3 -0
- package/lib/components/ProgressCircle/index.d.ts.map +1 -0
- package/lib/components/RadioGroup/RadioGroup.d.ts +34 -0
- package/lib/components/RadioGroup/RadioGroup.d.ts.map +1 -0
- package/lib/components/RadioGroup/RadioGroup.jsx +160 -0
- package/lib/components/RadioGroup/RadioGroup.namespace.d.ts +2 -0
- package/lib/components/RadioGroup/RadioGroup.namespace.d.ts.map +1 -0
- package/lib/components/RadioGroup/RadioGroup.namespace.js +12 -0
- package/lib/components/RadioGroup/index.d.ts +3 -0
- package/lib/components/RadioGroup/index.d.ts.map +1 -0
- 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 +21 -0
- package/lib/components/Switch/Switch.d.ts.map +1 -0
- package/lib/components/Switch/Switch.jsx +101 -0
- package/lib/components/Switch/Switch.namespace.d.ts +2 -0
- package/lib/components/Switch/Switch.namespace.d.ts.map +1 -0
- package/lib/components/Switch/Switch.namespace.js +11 -0
- package/lib/components/Switch/index.d.ts +3 -0
- package/lib/components/Switch/index.d.ts.map +1 -0
- package/lib/components/TagGroup/TagGroup.d.ts +34 -0
- package/lib/components/TagGroup/TagGroup.d.ts.map +1 -0
- package/lib/components/TagGroup/TagGroup.jsx +57 -0
- package/lib/components/TagGroup/TagGroup.namespace.d.ts +2 -0
- package/lib/components/TagGroup/TagGroup.namespace.d.ts.map +1 -0
- package/lib/components/TagGroup/TagGroup.namespace.js +10 -0
- package/lib/components/TagGroup/index.d.ts +3 -0
- package/lib/components/TagGroup/index.d.ts.map +1 -0
- 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 +12 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/hooks/index.d.ts +5 -0
- package/lib/hooks/index.d.ts.map +1 -0
- package/lib/hooks/useControllableState.d.ts +15 -0
- package/lib/hooks/useControllableState.d.ts.map +1 -0
- package/lib/hooks/useControllableState.js +27 -0
- package/lib/hooks/useIconColor.d.ts +19 -0
- package/lib/hooks/useIconColor.d.ts.map +1 -0
- package/lib/hooks/useIconColor.js +38 -0
- package/lib/hooks/usePressTap.d.ts +27 -0
- package/lib/hooks/usePressTap.d.ts.map +1 -0
- package/lib/hooks/usePressTap.js +35 -0
- 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/index.d.ts +5 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +26 -0
- package/lib/types.d.ts +33 -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 +27 -0
- package/lib/utils/create-slot-recipe-context.d.ts.map +1 -0
- package/lib/utils/create-slot-recipe-context.jsx +94 -0
- package/lib/utils/get-seed-class-name.d.ts +22 -0
- package/lib/utils/get-seed-class-name.d.ts.map +1 -0
- package/lib/utils/get-seed-class-name.js +28 -0
- package/lib/utils/index.d.ts +5 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/resolve-recipe-token.d.ts +38 -0
- package/lib/utils/resolve-recipe-token.d.ts.map +1 -0
- package/lib/utils/resolve-recipe-token.js +49 -0
- package/lib/utils/split-multiple-variants-props.d.ts +29 -0
- package/lib/utils/split-multiple-variants-props.d.ts.map +1 -0
- package/lib/utils/split-multiple-variants-props.js +34 -0
- 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 +54 -0
- package/src/components/ActionButton/ActionButton.test.tsx +137 -0
- package/src/components/ActionButton/ActionButton.tsx +340 -0
- package/src/components/ActionButton/index.ts +1 -0
- package/src/components/BottomSheet/BottomSheet.namespace.ts +24 -0
- package/src/components/BottomSheet/BottomSheet.test.tsx +153 -0
- package/src/components/BottomSheet/BottomSheet.tsx +397 -0
- package/src/components/BottomSheet/index.ts +27 -0
- 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.namespace.ts +12 -0
- package/src/components/Checkbox/Checkbox.tsx +282 -0
- package/src/components/Checkbox/index.ts +14 -0
- package/src/components/Icon/Icon.tsx +265 -0
- package/src/components/Icon/index.ts +8 -0
- package/src/components/ProgressCircle/ProgressCircle.namespace.ts +5 -0
- package/src/components/ProgressCircle/ProgressCircle.tsx +424 -0
- package/src/components/ProgressCircle/index.ts +9 -0
- package/src/components/RadioGroup/RadioGroup.namespace.ts +12 -0
- package/src/components/RadioGroup/RadioGroup.tsx +320 -0
- package/src/components/RadioGroup/index.ts +14 -0
- package/src/components/Stack/Stack.tsx +97 -0
- package/src/components/Stack/index.ts +1 -0
- package/src/components/Switch/Switch.namespace.ts +10 -0
- package/src/components/Switch/Switch.tsx +200 -0
- package/src/components/Switch/index.ts +12 -0
- package/src/components/TagGroup/TagGroup.namespace.ts +8 -0
- package/src/components/TagGroup/TagGroup.tsx +127 -0
- package/src/components/TagGroup/index.ts +10 -0
- package/src/components/Text/Text.tsx +64 -0
- package/src/components/Text/index.ts +1 -0
- package/src/components/index.ts +11 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useControllableState.test.ts +120 -0
- package/src/hooks/useControllableState.ts +38 -0
- package/src/hooks/useIconColor.test.ts +13 -0
- package/src/hooks/useIconColor.ts +67 -0
- package/src/hooks/usePressTap.test.ts +129 -0
- package/src/hooks/usePressTap.ts +58 -0
- package/src/hooks/useSafeArea.test.ts +83 -0
- package/src/hooks/useSafeArea.ts +56 -0
- package/src/index.ts +4 -0
- package/src/types.ts +45 -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 +187 -0
- package/src/utils/get-seed-class-name.ts +47 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/resolve-recipe-token.ts +47 -0
- package/src/utils/split-multiple-variants-props.test.ts +61 -0
- package/src/utils/split-multiple-variants-props.ts +59 -0
- package/src/utils/styled.ts +442 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
type RecipeLike = {
|
|
2
|
+
splitVariantProps: (props: Record<string, unknown>) => [Record<string, unknown>, unknown];
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
type ExtractVariantProps<T> = T extends {
|
|
6
|
+
splitVariantProps: (...args: never[]) => [infer V, unknown];
|
|
7
|
+
}
|
|
8
|
+
? V
|
|
9
|
+
: never;
|
|
10
|
+
|
|
11
|
+
type ExtractAllVariantKeys<R> = {
|
|
12
|
+
[K in keyof R]: ExtractVariantProps<R[K]> extends infer V
|
|
13
|
+
? V extends Record<string, unknown>
|
|
14
|
+
? keyof V
|
|
15
|
+
: never
|
|
16
|
+
: never;
|
|
17
|
+
}[keyof R];
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Split `props` across multiple recipes' variant extractors in one pass.
|
|
21
|
+
*
|
|
22
|
+
* Given `recipesMap` of `{ [recipeKey]: recipe }`, returns:
|
|
23
|
+
* - A bucket per recipe key with that recipe's variant-only props.
|
|
24
|
+
* - `remainingProps` with every recipe variant key stripped out.
|
|
25
|
+
*
|
|
26
|
+
* Keys that appear in more than one recipe (e.g. shared `size`) are copied
|
|
27
|
+
* into each corresponding bucket. `remainingProps` never includes any key
|
|
28
|
+
* that any recipe claimed as a variant.
|
|
29
|
+
*
|
|
30
|
+
* Mirror of `packages/react/src/utils/splitMultipleVariantsProps` adapted
|
|
31
|
+
* to TypeScript for Lynx. Use when a single compound component composes two
|
|
32
|
+
* or more recipes (e.g. Switch's `switch` + `switchmark`).
|
|
33
|
+
*/
|
|
34
|
+
export function splitMultipleVariantsProps<R extends Record<string, RecipeLike>, P>(
|
|
35
|
+
props: P,
|
|
36
|
+
recipesMap: R,
|
|
37
|
+
): [{ [K in keyof R]: ExtractVariantProps<R[K]> }, Omit<P, ExtractAllVariantKeys<R>>] {
|
|
38
|
+
const multipleVariantsProps = {} as { [K in keyof R]: ExtractVariantProps<R[K]> };
|
|
39
|
+
const extractedKeys = new Set<string>();
|
|
40
|
+
const propsRecord = props as Record<string, unknown>;
|
|
41
|
+
|
|
42
|
+
for (const recipeKey in recipesMap) {
|
|
43
|
+
const [variantProps] = recipesMap[recipeKey].splitVariantProps(propsRecord);
|
|
44
|
+
multipleVariantsProps[recipeKey] = variantProps as ExtractVariantProps<R[keyof R]>;
|
|
45
|
+
|
|
46
|
+
for (const variantPropKey in variantProps) {
|
|
47
|
+
extractedKeys.add(variantPropKey);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const remainingProps = {} as Record<string, unknown>;
|
|
52
|
+
|
|
53
|
+
for (const propKey in propsRecord) {
|
|
54
|
+
if (extractedKeys.has(propKey)) continue;
|
|
55
|
+
remainingProps[propKey] = propsRecord[propKey];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return [multipleVariantsProps, remainingProps as Omit<P, ExtractAllVariantKeys<R>>];
|
|
59
|
+
}
|
|
@@ -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
|
+
}
|