fluent-styles 1.59.0 → 1.61.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/commonjs/button/index.js +5 -10
- package/lib/commonjs/button/index.js.map +1 -1
- package/lib/commonjs/form/index.js +267 -0
- package/lib/commonjs/form/index.js.map +1 -1
- package/lib/commonjs/header/index.js +79 -66
- package/lib/commonjs/header/index.js.map +1 -1
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/button/index.js +5 -10
- package/lib/module/button/index.js.map +1 -1
- package/lib/module/form/index.js +262 -0
- package/lib/module/form/index.js.map +1 -1
- package/lib/module/header/index.js +81 -68
- package/lib/module/header/index.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/button/index.d.ts.map +1 -1
- package/lib/typescript/form/index.d.ts +127 -0
- package/lib/typescript/form/index.d.ts.map +1 -1
- package/lib/typescript/header/index.d.ts +4 -9
- package/lib/typescript/header/index.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/button/index.tsx +1 -6
- package/src/form/index.tsx +331 -0
- package/src/header/index.tsx +87 -103
- package/src/index.ts +1 -0
package/src/header/index.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import {
|
|
3
|
-
useWindowDimensions,
|
|
4
3
|
View,
|
|
5
4
|
ViewProps,
|
|
6
5
|
ViewStyle,
|
|
@@ -14,8 +13,11 @@ import { StyleShape, ShapeProps } from "../shape";
|
|
|
14
13
|
import { StyledText, StyledTextProps } from "../text";
|
|
15
14
|
import { ChevronLeft } from "../icons";
|
|
16
15
|
import { theme } from "../utiles/theme";
|
|
16
|
+
import { StyledPressable } from "../pressable";
|
|
17
|
+
import { viewStyleStringVariants, viewStyleVariants } from "../utiles/viewStyleVariants";
|
|
18
|
+
|
|
19
|
+
// ─── Types ────────────────────────────────────────────────────────────────────
|
|
17
20
|
|
|
18
|
-
// Types
|
|
19
21
|
export interface BackArrowProps {
|
|
20
22
|
size?: number;
|
|
21
23
|
color?: string;
|
|
@@ -37,73 +39,46 @@ export interface HeaderProps extends ViewProps, ViewStyle {
|
|
|
37
39
|
statusBarProps?: StatusBarProps;
|
|
38
40
|
skipStatusBarOnAndroid?: boolean;
|
|
39
41
|
skipStatusBarOnIOS?: boolean;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface FullHeaderProps extends ViewProps, ViewStyle {
|
|
43
42
|
children?: React.ReactNode;
|
|
44
|
-
statusBarProps?: StatusBarProps;
|
|
45
|
-
skipStatusBarOnAndroid?: boolean;
|
|
46
|
-
skipStatusBarOnIOS?: boolean;
|
|
47
43
|
}
|
|
48
44
|
|
|
49
|
-
//
|
|
45
|
+
// ─── Container ────────────────────────────────────────────────────────────────
|
|
46
|
+
|
|
50
47
|
const StyledHeaderContainer = styled<ViewProps & ViewStyle>(View, {
|
|
51
48
|
base: {
|
|
52
49
|
position: "relative",
|
|
53
50
|
flexDirection: "row",
|
|
54
51
|
alignItems: "center",
|
|
55
|
-
|
|
56
|
-
height: Platform.select({
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
justifyContent: "space-between",
|
|
53
|
+
height: Platform.select({ ios: 44, android: 56, default: 56 }),
|
|
54
|
+
paddingHorizontal: 4,
|
|
55
|
+
},
|
|
56
|
+
variants: {
|
|
57
|
+
// ── Forward all generic style props ─────────────────────────────────────
|
|
58
|
+
...viewStyleVariants,
|
|
59
|
+
...viewStyleStringVariants,
|
|
61
60
|
},
|
|
62
61
|
});
|
|
63
62
|
|
|
64
|
-
// Full
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
FullHeaderProps
|
|
68
|
-
>(
|
|
69
|
-
(
|
|
70
|
-
{
|
|
71
|
-
children,
|
|
72
|
-
statusBarProps,
|
|
73
|
-
skipStatusBarOnAndroid = true,
|
|
74
|
-
skipStatusBarOnIOS = true,
|
|
75
|
-
...rest
|
|
76
|
-
},
|
|
77
|
-
ref,
|
|
78
|
-
) => {
|
|
79
|
-
const { width } = useWindowDimensions();
|
|
63
|
+
// ─── Full — pure children pass-through ───────────────────────────────────────
|
|
64
|
+
// No layout of its own. StyledHeader (the outer wrapper) owns all spacing,
|
|
65
|
+
// status bar, and container sizing. Full just renders whatever is inside it.
|
|
80
66
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
<StatusBar {...statusBarProps} />
|
|
84
|
-
<StyledHeaderContainer
|
|
85
|
-
ref={ref}
|
|
86
|
-
width={width}
|
|
87
|
-
marginTop={getStatusBarHeight({
|
|
88
|
-
skipAndroid: skipStatusBarOnAndroid,
|
|
89
|
-
skipIos: skipStatusBarOnIOS,
|
|
90
|
-
})}
|
|
91
|
-
{...rest}
|
|
92
|
-
>
|
|
93
|
-
{children}
|
|
94
|
-
</StyledHeaderContainer>
|
|
95
|
-
</Stack>
|
|
96
|
-
);
|
|
97
|
-
},
|
|
67
|
+
const Full: React.FC<{ children?: React.ReactNode }> = ({ children }) => (
|
|
68
|
+
<>{children}</>
|
|
98
69
|
);
|
|
99
70
|
|
|
100
|
-
|
|
71
|
+
Full.displayName = "StyledHeader.Full";
|
|
72
|
+
|
|
73
|
+
// ─── StyledHeader ─────────────────────────────────────────────────────────────
|
|
74
|
+
|
|
101
75
|
const HeaderComponent = React.forwardRef<
|
|
102
76
|
React.ComponentPropsWithRef<typeof StyledHeaderContainer>,
|
|
103
77
|
HeaderProps
|
|
104
78
|
>(
|
|
105
79
|
(
|
|
106
80
|
{
|
|
81
|
+
// built-in title/icon layout props
|
|
107
82
|
showBackArrow,
|
|
108
83
|
backArrowProps,
|
|
109
84
|
showStatusBar = true,
|
|
@@ -117,72 +92,83 @@ const HeaderComponent = React.forwardRef<
|
|
|
117
92
|
statusBarProps,
|
|
118
93
|
skipStatusBarOnAndroid = true,
|
|
119
94
|
skipStatusBarOnIOS = true,
|
|
95
|
+
// children covers StyledHeader.Full usage
|
|
96
|
+
children,
|
|
120
97
|
...rest
|
|
121
98
|
},
|
|
122
99
|
ref,
|
|
123
100
|
) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
<StyleShape cycle {...shapeProps}>
|
|
101
|
+
// ── Left slot ─────────────────────────────────────────────────────────
|
|
102
|
+
const renderLeft = () => (
|
|
103
|
+
<Stack flex={1} horizontal alignItems="center" justifyContent="flex-start">
|
|
104
|
+
{showBackArrow && (
|
|
105
|
+
<StyledPressable onPress={onBackPress ?? backArrowProps?.onPress}>
|
|
106
|
+
<StyleShape
|
|
107
|
+
cycle
|
|
108
|
+
|
|
109
|
+
{...shapeProps}
|
|
110
|
+
>
|
|
135
111
|
<ChevronLeft
|
|
136
|
-
size={
|
|
137
|
-
color={theme.colors.gray[
|
|
138
|
-
|
|
139
|
-
{...backArrowProps}
|
|
112
|
+
size={backArrowProps?.size ?? 24}
|
|
113
|
+
color={backArrowProps?.color ?? theme.colors.gray[700]}
|
|
114
|
+
strokeWidth={backArrowProps?.strokeWidth}
|
|
140
115
|
/>
|
|
141
116
|
</StyleShape>
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
117
|
+
</StyledPressable>
|
|
118
|
+
|
|
119
|
+
)}
|
|
120
|
+
{leftIcon}
|
|
121
|
+
{titleAlignment === "left" && title && (
|
|
122
|
+
<StyledText
|
|
123
|
+
marginLeft={showBackArrow || leftIcon ? 8 : 0}
|
|
124
|
+
{...titleProps}
|
|
125
|
+
>
|
|
126
|
+
{title}
|
|
127
|
+
</StyledText>
|
|
128
|
+
)}
|
|
129
|
+
</Stack>
|
|
130
|
+
);
|
|
154
131
|
|
|
155
|
-
|
|
132
|
+
// ── Center slot ───────────────────────────────────────────────────────
|
|
133
|
+
const renderCenter = () => {
|
|
156
134
|
if (titleAlignment !== "center" || !title) return null;
|
|
157
135
|
return (
|
|
158
|
-
<Stack
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
>
|
|
163
|
-
{titleAlignment === "center" && title && (
|
|
164
|
-
<StyledText {...titleProps}>{title}</StyledText>
|
|
165
|
-
)}
|
|
136
|
+
<Stack flex={2} alignItems="center" justifyContent="center">
|
|
137
|
+
<StyledText numberOfLines={1} {...titleProps}>
|
|
138
|
+
{title}
|
|
139
|
+
</StyledText>
|
|
166
140
|
</Stack>
|
|
167
141
|
);
|
|
168
142
|
};
|
|
169
143
|
|
|
170
|
-
|
|
171
|
-
|
|
144
|
+
// ── Right slot ────────────────────────────────────────────────────────
|
|
145
|
+
const renderRight = () => (
|
|
146
|
+
<Stack flex={1} horizontal alignItems="center" justifyContent="flex-end">
|
|
147
|
+
{titleAlignment === "right" && title && (
|
|
148
|
+
<StyledText marginRight={rightIcon ? 8 : 0} {...titleProps}>
|
|
149
|
+
{title}
|
|
150
|
+
</StyledText>
|
|
151
|
+
)}
|
|
152
|
+
{rightIcon}
|
|
153
|
+
</Stack>
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
// ── When children is present (e.g. StyledHeader.Full usage), render
|
|
157
|
+
// them directly inside the container — skip the built-in layout slots.
|
|
158
|
+
const renderContent = () => {
|
|
159
|
+
if (children) return <>{children}</>;
|
|
172
160
|
return (
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
{rightIcon}
|
|
179
|
-
</Stack>
|
|
161
|
+
<>
|
|
162
|
+
{renderLeft()}
|
|
163
|
+
{renderCenter()}
|
|
164
|
+
{renderRight()}
|
|
165
|
+
</>
|
|
180
166
|
);
|
|
181
167
|
};
|
|
182
168
|
|
|
183
169
|
return (
|
|
184
170
|
<Stack vertical>
|
|
185
|
-
<StatusBar {...statusBarProps} />
|
|
171
|
+
{showStatusBar && <StatusBar {...statusBarProps} />}
|
|
186
172
|
<StyledHeaderContainer
|
|
187
173
|
ref={ref}
|
|
188
174
|
marginTop={getStatusBarHeight({
|
|
@@ -191,27 +177,25 @@ const HeaderComponent = React.forwardRef<
|
|
|
191
177
|
})}
|
|
192
178
|
{...rest}
|
|
193
179
|
>
|
|
194
|
-
{
|
|
195
|
-
{renderCenterSection()}
|
|
196
|
-
{renderRightSection()}
|
|
180
|
+
{renderContent()}
|
|
197
181
|
</StyledHeaderContainer>
|
|
198
182
|
</Stack>
|
|
199
183
|
);
|
|
200
184
|
},
|
|
201
185
|
);
|
|
202
186
|
|
|
203
|
-
//
|
|
187
|
+
// ─── Composition ──────────────────────────────────────────────────────────────
|
|
188
|
+
|
|
204
189
|
interface HeaderComponent
|
|
205
190
|
extends React.ForwardRefExoticComponent<
|
|
206
191
|
HeaderProps & React.RefAttributes<View>
|
|
207
192
|
> {
|
|
208
|
-
Full: typeof
|
|
193
|
+
Full: typeof Full;
|
|
209
194
|
}
|
|
210
195
|
|
|
211
196
|
const StyledHeader = HeaderComponent as HeaderComponent;
|
|
212
197
|
|
|
213
|
-
StyledHeader.Full =
|
|
214
|
-
StyledHeader.Full.displayName = "StyledHeader.Full";
|
|
198
|
+
StyledHeader.Full = Full;
|
|
215
199
|
StyledHeader.displayName = "StyledHeader";
|
|
216
200
|
|
|
217
|
-
export { StyledHeader };
|
|
201
|
+
export { StyledHeader };
|