fluent-styles 1.59.0 → 1.60.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.
@@ -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
- // Styled Components
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
- justifyContent: "space-between",
56
- height: Platform.select({
57
- ios: 44,
58
- android: 56,
59
- default: 56,
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 Header Component
65
- const FullHeader = React.forwardRef<
66
- React.ComponentPropsWithRef<typeof StyledHeaderContainer>,
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
- return (
82
- <Stack vertical>
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
- // Main Header Component
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
- const renderLeftSection = () => {
125
- if (titleAlignment !== "left") return null;
126
- return (
127
- <Stack
128
- flex={titleAlignment === "left" ? 2 : 1}
129
- alignItems={"center" }
130
- justifyContent={showBackArrow ? "flex-start" : "flex-start"}
131
- horizontal
132
- >
133
- {showBackArrow && (
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={32}
137
- color={theme.colors.gray[1]}
138
- onPress={onBackPress}
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
- {leftIcon}
145
-
146
- {titleAlignment === "left" && title && (
147
- <StyledText marginLeft={showBackArrow ? 24 : 0} {...titleProps}>
148
- {title}
149
- </StyledText>
150
- )}
151
- </Stack>
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
- const renderCenterSection = () => {
132
+ // ── Center slot ───────────────────────────────────────────────────────
133
+ const renderCenter = () => {
156
134
  if (titleAlignment !== "center" || !title) return null;
157
135
  return (
158
- <Stack
159
- flex={titleAlignment === "center" ? 8 : 1}
160
- flexWrap="nowrap"
161
- alignItems="center"
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
- const renderRightSection = () => {
171
- if (!rightIcon) return null;
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
- <Stack
174
- flex={1}
175
- backgroundColor={theme.colors.gray[1]}
176
- alignItems="flex-end"
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
- {renderLeftSection()}
195
- {renderCenterSection()}
196
- {renderRightSection()}
180
+ {renderContent()}
197
181
  </StyledHeaderContainer>
198
182
  </Stack>
199
183
  );
200
184
  },
201
185
  );
202
186
 
203
- // Component Composition
187
+ // ─── Composition ──────────────────────────────────────────────────────────────
188
+
204
189
  interface HeaderComponent
205
190
  extends React.ForwardRefExoticComponent<
206
191
  HeaderProps & React.RefAttributes<View>
207
192
  > {
208
- Full: typeof FullHeader;
193
+ Full: typeof Full;
209
194
  }
210
195
 
211
196
  const StyledHeader = HeaderComponent as HeaderComponent;
212
197
 
213
- StyledHeader.Full = FullHeader;
214
- StyledHeader.Full.displayName = "StyledHeader.Full";
198
+ StyledHeader.Full = Full;
215
199
  StyledHeader.displayName = "StyledHeader";
216
200
 
217
- export { StyledHeader };
201
+ export { StyledHeader };
package/src/index.ts CHANGED
@@ -72,5 +72,6 @@ export * from './dialog'
72
72
  export * from './utiles/validators'
73
73
  export * from './spinner'
74
74
  export * from './input'
75
+ export * from './form'
75
76
  export * from './shape/cycle'
76
77