react-native-ui-lib 8.3.4 → 8.4.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/android/build.gradle +3 -3
- package/package.json +1 -1
- package/screenFooter.d.ts +2 -0
- package/screenFooter.js +1 -0
- package/scripts/release/prReleaseNotesCommon.js +2 -1
- package/src/assets/internal/images/bottomGradient.png +0 -0
- package/src/assets/internal/images/bottomGradient@1.5x.png +0 -0
- package/src/assets/internal/images/bottomGradient@2x.png +0 -0
- package/src/assets/internal/images/bottomGradient@3x.png +0 -0
- package/src/assets/internal/images/bottomGradient@4x.png +0 -0
- package/src/assets/internal/images/index.js +3 -0
- package/src/components/floatingButton/floatingButton.api.json +10 -15
- package/src/components/floatingButton/index.d.ts +13 -39
- package/src/components/floatingButton/index.js +57 -167
- package/src/components/screenFooter/index.d.ts +8 -0
- package/src/components/screenFooter/index.js +214 -0
- package/src/components/screenFooter/screenFooter.api.json +250 -0
- package/src/components/screenFooter/types.d.ts +105 -0
- package/src/components/screenFooter/types.js +39 -0
- package/src/components/textField/TextField.driver.new.js +12 -7
- package/src/components/textField/index.js +31 -9
- package/src/hooks/index.d.ts +1 -0
- package/src/hooks/index.js +1 -0
- package/src/hooks/useScrollToHide/index.d.ts +24 -0
- package/src/hooks/useScrollToHide/index.js +48 -0
- package/src/incubator/expandableOverlay/index.js +7 -3
- package/src/index.d.ts +1 -0
- package/src/index.js +70 -0
- package/src/style/colors.d.ts +12 -13
- package/src/style/colors.js +40 -39
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ScreenFooter",
|
|
3
|
+
"category": "layout",
|
|
4
|
+
"description": "A flexible footer component that stays at the bottom of the screen with support for various layouts, backgrounds, and keyboard behaviors",
|
|
5
|
+
"example": "https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/ScreenFooterScreen.tsx",
|
|
6
|
+
"images": [],
|
|
7
|
+
"props": [
|
|
8
|
+
{
|
|
9
|
+
"name": "backgroundType",
|
|
10
|
+
"type": "ScreenFooterBackgrounds",
|
|
11
|
+
"description": "The background style of the footer [fading, solid, transparent]",
|
|
12
|
+
"default": "'solid'"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "layout",
|
|
16
|
+
"type": "ScreenFooterLayouts",
|
|
17
|
+
"description": "The layout direction of footer items [horizontal, vertical]",
|
|
18
|
+
"default": "'vertical'"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "alignment",
|
|
22
|
+
"type": "FooterAlignment",
|
|
23
|
+
"description": "Cross-axis alignment [start, center, end]. In vertical layout: controls horizontal position. In horizontal layout: controls vertical position",
|
|
24
|
+
"default": "'center'"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "horizontalAlignment",
|
|
28
|
+
"type": "FooterAlignment",
|
|
29
|
+
"description": "Main-axis alignment for horizontal layout only when distribution is STACK [start, center, end]",
|
|
30
|
+
"default": "'center'"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "horizontalItemsDistribution",
|
|
34
|
+
"type": "HorizontalItemsDistribution",
|
|
35
|
+
"description": "Distribution of items in horizontal layout [stack, spread]",
|
|
36
|
+
"default": "'spread'"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "itemsFit",
|
|
40
|
+
"type": "ItemsFit",
|
|
41
|
+
"description": "How items should fit in vertical layout [fit, fixed, stretch]",
|
|
42
|
+
"default": "'fit'"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "keyboardBehavior",
|
|
46
|
+
"type": "KeyboardBehavior",
|
|
47
|
+
"description": "The footer's keyboard behavior [sticky, hoisted]. Sticky: stays at bottom when keyboard opens. Hoisted: pushed up when keyboard opens",
|
|
48
|
+
"default": "'sticky'"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "itemWidth",
|
|
52
|
+
"type": "DimensionValue",
|
|
53
|
+
"description": "Fixed width for all items (used with ItemsFit.FIXED)"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "visible",
|
|
57
|
+
"type": "boolean",
|
|
58
|
+
"description": "If true, the footer is visible. If false, it slides down",
|
|
59
|
+
"default": "true"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"name": "animationDuration",
|
|
63
|
+
"type": "number",
|
|
64
|
+
"description": "Duration of the show/hide animation in ms",
|
|
65
|
+
"default": "200"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"name": "useSafeArea",
|
|
69
|
+
"type": "boolean",
|
|
70
|
+
"description": "If true, the footer will respect the safe area (add bottom padding)",
|
|
71
|
+
"default": "true"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"name": "shadow",
|
|
75
|
+
"type": "ScreenFooterShadow",
|
|
76
|
+
"description": "Shadow preset for solid background [sh10, sh20, sh30]. Only applies when backgroundType is 'solid'",
|
|
77
|
+
"default": "'sh20'"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "hideDivider",
|
|
81
|
+
"type": "boolean",
|
|
82
|
+
"description": "If true, hides the top divider for solid background. Only applies when backgroundType is 'solid'",
|
|
83
|
+
"default": "false"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "contentContainerStyle",
|
|
87
|
+
"type": "StyleProp<ViewStyle>",
|
|
88
|
+
"description": "Custom style for the content container that wraps the footer's children. Can be used to override default padding, gap, or other layout properties."
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
"snippet": [
|
|
92
|
+
"<View flex bg-$backgroundDefault>",
|
|
93
|
+
" <ScrollView>",
|
|
94
|
+
" {/* Screen content */}",
|
|
95
|
+
" </ScrollView>",
|
|
96
|
+
" <ScreenFooter>",
|
|
97
|
+
" <Button label=\"Primary Action\" />",
|
|
98
|
+
" <Button label=\"Secondary Action\" link />",
|
|
99
|
+
" </ScreenFooter>",
|
|
100
|
+
"</View>"
|
|
101
|
+
],
|
|
102
|
+
"docs": {
|
|
103
|
+
"hero": {
|
|
104
|
+
"title": "ScreenFooter",
|
|
105
|
+
"description": "The ScreenFooter component provides a flexible footer that stays at the bottom of the screen with support for various layouts, backgrounds, and keyboard behaviors. It's ideal for forms, checkout flows, and any screen requiring persistent bottom actions.",
|
|
106
|
+
"type": "hero",
|
|
107
|
+
"layout": "horizontal",
|
|
108
|
+
"content": [
|
|
109
|
+
{
|
|
110
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ScreenFooter/screenFooter_overview_preview.png"
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
"tabs": [
|
|
115
|
+
{
|
|
116
|
+
"title": "Overview",
|
|
117
|
+
"sections": [
|
|
118
|
+
{
|
|
119
|
+
"type": "section",
|
|
120
|
+
"title": "Use Examples",
|
|
121
|
+
"description": "The ScreenFooter can be used in various scenarios depending on the content and action hierarchy. Each layout type serves different use cases and provides different visual emphasis.",
|
|
122
|
+
"content": []
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"type": "table",
|
|
126
|
+
"columns": ["Layout Type", "Use Case", "Example"],
|
|
127
|
+
"items": [
|
|
128
|
+
{
|
|
129
|
+
"title": "Horizontal - Spread",
|
|
130
|
+
"content": [
|
|
131
|
+
{
|
|
132
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ScreenFooter/screenFooter_horizontal_spread.png"
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
"description": "Best for two equally important actions positioned at opposite ends. Common in navigation flows or when presenting contrasting choices."
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"title": "Horizontal - Stacked Center",
|
|
139
|
+
"content": [
|
|
140
|
+
{
|
|
141
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ScreenFooter/screenFooter_horizontal_stacked.png"
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
"description": "Ideal for primary and secondary actions of similar importance that should be grouped together in the center."
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"title": "Horizontal - With Content",
|
|
148
|
+
"content": [
|
|
149
|
+
{
|
|
150
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ScreenFooter/screenFooter_horizontal_content.png"
|
|
151
|
+
}
|
|
152
|
+
],
|
|
153
|
+
"description": "Perfect for checkout or summary screens where you need to display information alongside actions. The footer can accommodate text, prices, or other content elements."
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
"title": "Horizontal Layouts",
|
|
157
|
+
"description": "markdown: Horizontal layouts are best when screen content is abundant and vertical space is limited. They keep actions compact while maintaining good reachability. Use the `layout` prop set to `ScreenFooterLayouts.HORIZONTAL`."
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"type": "table",
|
|
161
|
+
"columns": ["Layout Type", "Use Case", "Example"],
|
|
162
|
+
"items": [
|
|
163
|
+
{
|
|
164
|
+
"title": "Vertical - Fit",
|
|
165
|
+
"content": [
|
|
166
|
+
{
|
|
167
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ScreenFooter/screenFooter_vertical_fit.png"
|
|
168
|
+
}
|
|
169
|
+
],
|
|
170
|
+
"description": "Buttons are sized based on their content. Best for clear action hierarchy with a prominent primary button and a subtle secondary link button."
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"title": "Vertical - Stretched",
|
|
174
|
+
"content": [
|
|
175
|
+
{
|
|
176
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ScreenFooter/screenFooter_vertical_stretched.png"
|
|
177
|
+
}
|
|
178
|
+
],
|
|
179
|
+
"description": "Full-width buttons provide maximum tap area and visual prominence. Recommended for forms and high-priority actions where accessibility is crucial."
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
"title": "Vertical Layouts",
|
|
183
|
+
"description": "markdown: Vertical layouts provide better action prominence and are recommended when a single primary action needs emphasis, or when content can be obscured. Use `itemsFit` prop with `ItemsFit.STRETCH` for full-width buttons or `ItemsFit.FIT` for content-sized buttons."
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"type": "table",
|
|
187
|
+
"columns": ["Background Type", "Visual", "When to Use"],
|
|
188
|
+
"items": [
|
|
189
|
+
{
|
|
190
|
+
"title": "Solid",
|
|
191
|
+
"content": [
|
|
192
|
+
{
|
|
193
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ScreenFooter/screenFooter_background_solid.png"
|
|
194
|
+
}
|
|
195
|
+
],
|
|
196
|
+
"description": "Provides clear separation with a solid background and optional shadow. Best for content-heavy screens where the footer needs to stand out."
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"title": "Fading",
|
|
200
|
+
"content": [
|
|
201
|
+
{
|
|
202
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ScreenFooter/screenFooter_background_fading.png"
|
|
203
|
+
}
|
|
204
|
+
],
|
|
205
|
+
"description": "Creates a subtle gradient overlay that doesn't obscure content completely. Ideal for minimal designs or when content should remain partially visible."
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"title": "Transparent",
|
|
209
|
+
"content": [
|
|
210
|
+
{
|
|
211
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ScreenFooter/screenFooter_background_transparent.png"
|
|
212
|
+
}
|
|
213
|
+
],
|
|
214
|
+
"description": "No background overlay. Use when the screen has minimal content or a solid background color, and separation isn't needed."
|
|
215
|
+
}
|
|
216
|
+
],
|
|
217
|
+
"title": "Background Types",
|
|
218
|
+
"description": "markdown: Choose the background type based on your content density and visual hierarchy needs. Set using the `backgroundType` prop."
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"type": "table",
|
|
222
|
+
"columns": ["Behavior", "Description", "Example"],
|
|
223
|
+
"items": [
|
|
224
|
+
{
|
|
225
|
+
"title": "Sticky",
|
|
226
|
+
"content": [
|
|
227
|
+
{
|
|
228
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ScreenFooter/screenFooter_behavior_sticky.png"
|
|
229
|
+
}
|
|
230
|
+
],
|
|
231
|
+
"description": "The footer remains at the bottom of the screen even when the keyboard is open. Best for short forms or when the footer actions don't relate to keyboard input."
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"title": "Hoisted",
|
|
235
|
+
"content": [
|
|
236
|
+
{
|
|
237
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ScreenFooter/screenFooter_behavior_hoisted.png"
|
|
238
|
+
}
|
|
239
|
+
],
|
|
240
|
+
"description": "The footer moves up with the keyboard, staying above it. Recommended for forms where users need immediate access to submit actions while typing."
|
|
241
|
+
}
|
|
242
|
+
],
|
|
243
|
+
"title": "Keyboard Behavior",
|
|
244
|
+
"description": "markdown: Control how the footer responds to the keyboard using the `keyboardBehavior` prop. Choose `KeyboardBehavior.STICKY` to keep it at the bottom, or `KeyboardBehavior.HOISTED` to move it above the keyboard."
|
|
245
|
+
}
|
|
246
|
+
]
|
|
247
|
+
}
|
|
248
|
+
]
|
|
249
|
+
}
|
|
250
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { DimensionValue, StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
export declare enum ScreenFooterLayouts {
|
|
4
|
+
HORIZONTAL = "horizontal",
|
|
5
|
+
VERTICAL = "vertical"
|
|
6
|
+
}
|
|
7
|
+
export declare enum ScreenFooterBackgrounds {
|
|
8
|
+
FADING = "fading",
|
|
9
|
+
SOLID = "solid",
|
|
10
|
+
TRANSPARENT = "transparent"
|
|
11
|
+
}
|
|
12
|
+
export declare enum FooterAlignment {
|
|
13
|
+
START = "start",
|
|
14
|
+
CENTER = "center",
|
|
15
|
+
END = "end"
|
|
16
|
+
}
|
|
17
|
+
export declare enum HorizontalItemsDistribution {
|
|
18
|
+
STACK = "stack",
|
|
19
|
+
SPREAD = "spread"
|
|
20
|
+
}
|
|
21
|
+
export declare enum ItemsFit {
|
|
22
|
+
FIT = "fit",
|
|
23
|
+
STRETCH = "stretch",
|
|
24
|
+
FIXED = "fixed"
|
|
25
|
+
}
|
|
26
|
+
export declare enum KeyboardBehavior {
|
|
27
|
+
STICKY = "sticky",
|
|
28
|
+
HOISTED = "hoisted"
|
|
29
|
+
}
|
|
30
|
+
export declare enum ScreenFooterShadow {
|
|
31
|
+
SH10 = "sh10",
|
|
32
|
+
SH20 = "sh20",
|
|
33
|
+
SH30 = "sh30"
|
|
34
|
+
}
|
|
35
|
+
export interface ScreenFooterProps extends PropsWithChildren<{}> {
|
|
36
|
+
/**
|
|
37
|
+
* Used as testing identifier
|
|
38
|
+
*/
|
|
39
|
+
testID?: string;
|
|
40
|
+
/**
|
|
41
|
+
* The background style of the footer
|
|
42
|
+
*/
|
|
43
|
+
backgroundType?: ScreenFooterBackgrounds | `${ScreenFooterBackgrounds}`;
|
|
44
|
+
/**
|
|
45
|
+
* The layout direction of footer items
|
|
46
|
+
*/
|
|
47
|
+
layout?: ScreenFooterLayouts | `${ScreenFooterLayouts}`;
|
|
48
|
+
/**
|
|
49
|
+
* Cross-axis alignment:
|
|
50
|
+
* - Vertical layout: controls horizontal position (left/center/right)
|
|
51
|
+
* - Horizontal layout: controls vertical position (top/center/bottom)
|
|
52
|
+
*/
|
|
53
|
+
alignment?: FooterAlignment | `${FooterAlignment}`;
|
|
54
|
+
/**
|
|
55
|
+
* Main-axis alignment for horizontal layout only (when distribution is STACK):
|
|
56
|
+
* Controls horizontal position (left/center/right) of the stacked items
|
|
57
|
+
*/
|
|
58
|
+
horizontalAlignment?: FooterAlignment | `${FooterAlignment}`;
|
|
59
|
+
/**
|
|
60
|
+
* Distribution of items in horizontal layout (stack/spread)
|
|
61
|
+
*/
|
|
62
|
+
horizontalItemsDistribution?: HorizontalItemsDistribution | `${HorizontalItemsDistribution}`;
|
|
63
|
+
/**
|
|
64
|
+
* How items should fit in vertical layout (fit/fixed/stretch)
|
|
65
|
+
*/
|
|
66
|
+
itemsFit?: ItemsFit | `${ItemsFit}`;
|
|
67
|
+
/**
|
|
68
|
+
* The footer's keyboard behavior.
|
|
69
|
+
* When STICKY, the footer will stay at the bottom of the screen when keyboard is opened.
|
|
70
|
+
* When HOISTED, the footer will be pushed up when keyboard is opened.
|
|
71
|
+
*/
|
|
72
|
+
keyboardBehavior?: KeyboardBehavior | `${KeyboardBehavior}`;
|
|
73
|
+
/**
|
|
74
|
+
* Fixed width for all items (used with ItemsFit.FIXED)
|
|
75
|
+
*/
|
|
76
|
+
itemWidth?: DimensionValue;
|
|
77
|
+
/**
|
|
78
|
+
* If true, the footer is visible. If false, it slides down.
|
|
79
|
+
*/
|
|
80
|
+
visible?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Duration of the show/hide animation in ms.
|
|
83
|
+
* @default 200
|
|
84
|
+
*/
|
|
85
|
+
animationDuration?: number;
|
|
86
|
+
/**
|
|
87
|
+
* If true, the footer will respect the safe area (add bottom padding)
|
|
88
|
+
*/
|
|
89
|
+
useSafeArea?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Shadow preset for solid background (default: SH20)
|
|
92
|
+
* Only applies when backgroundType is 'solid'
|
|
93
|
+
*/
|
|
94
|
+
shadow?: ScreenFooterShadow | `${ScreenFooterShadow}`;
|
|
95
|
+
/**
|
|
96
|
+
* If true, hides the top divider for solid background (default: false)
|
|
97
|
+
* Only applies when backgroundType is 'solid'
|
|
98
|
+
*/
|
|
99
|
+
hideDivider?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Custom style for the content container that wraps the footer's children.
|
|
102
|
+
* Can be used to override default padding, gap, or other layout properties.
|
|
103
|
+
*/
|
|
104
|
+
contentContainerStyle?: StyleProp<ViewStyle>;
|
|
105
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export let ScreenFooterLayouts = /*#__PURE__*/function (ScreenFooterLayouts) {
|
|
2
|
+
ScreenFooterLayouts["HORIZONTAL"] = "horizontal";
|
|
3
|
+
ScreenFooterLayouts["VERTICAL"] = "vertical";
|
|
4
|
+
return ScreenFooterLayouts;
|
|
5
|
+
}({});
|
|
6
|
+
export let ScreenFooterBackgrounds = /*#__PURE__*/function (ScreenFooterBackgrounds) {
|
|
7
|
+
ScreenFooterBackgrounds["FADING"] = "fading";
|
|
8
|
+
ScreenFooterBackgrounds["SOLID"] = "solid";
|
|
9
|
+
ScreenFooterBackgrounds["TRANSPARENT"] = "transparent";
|
|
10
|
+
return ScreenFooterBackgrounds;
|
|
11
|
+
}({});
|
|
12
|
+
export let FooterAlignment = /*#__PURE__*/function (FooterAlignment) {
|
|
13
|
+
FooterAlignment["START"] = "start";
|
|
14
|
+
FooterAlignment["CENTER"] = "center";
|
|
15
|
+
FooterAlignment["END"] = "end";
|
|
16
|
+
return FooterAlignment;
|
|
17
|
+
}({});
|
|
18
|
+
export let HorizontalItemsDistribution = /*#__PURE__*/function (HorizontalItemsDistribution) {
|
|
19
|
+
HorizontalItemsDistribution["STACK"] = "stack";
|
|
20
|
+
HorizontalItemsDistribution["SPREAD"] = "spread";
|
|
21
|
+
return HorizontalItemsDistribution;
|
|
22
|
+
}({});
|
|
23
|
+
export let ItemsFit = /*#__PURE__*/function (ItemsFit) {
|
|
24
|
+
ItemsFit["FIT"] = "fit";
|
|
25
|
+
ItemsFit["STRETCH"] = "stretch";
|
|
26
|
+
ItemsFit["FIXED"] = "fixed";
|
|
27
|
+
return ItemsFit;
|
|
28
|
+
}({});
|
|
29
|
+
export let KeyboardBehavior = /*#__PURE__*/function (KeyboardBehavior) {
|
|
30
|
+
KeyboardBehavior["STICKY"] = "sticky";
|
|
31
|
+
KeyboardBehavior["HOISTED"] = "hoisted";
|
|
32
|
+
return KeyboardBehavior;
|
|
33
|
+
}({});
|
|
34
|
+
export let ScreenFooterShadow = /*#__PURE__*/function (ScreenFooterShadow) {
|
|
35
|
+
ScreenFooterShadow["SH10"] = "sh10";
|
|
36
|
+
ScreenFooterShadow["SH20"] = "sh20";
|
|
37
|
+
ScreenFooterShadow["SH30"] = "sh30";
|
|
38
|
+
return ScreenFooterShadow;
|
|
39
|
+
}({});
|
|
@@ -9,6 +9,10 @@ import { ButtonDriver } from "../button/Button.driver.new";
|
|
|
9
9
|
import { ViewDriver } from "../view/View.driver.new";
|
|
10
10
|
export const TextFieldDriver = (props, options) => {
|
|
11
11
|
const driver = usePressableDriver(useComponentDriver(props, options));
|
|
12
|
+
const inputDriver = useComponentDriver({
|
|
13
|
+
renderTree: props.renderTree,
|
|
14
|
+
testID: `${props.testID}.input`
|
|
15
|
+
}, options);
|
|
12
16
|
const floatingPlaceholderDriver = TextDriver({
|
|
13
17
|
renderTree: props.renderTree,
|
|
14
18
|
testID: `${props.testID}.floatingPlaceholder`
|
|
@@ -41,30 +45,31 @@ export const TextFieldDriver = (props, options) => {
|
|
|
41
45
|
renderTree: props.renderTree,
|
|
42
46
|
testID: `${props.testID}.clearButton.container`
|
|
43
47
|
});
|
|
48
|
+
const getInputElement = () => inputDriver.queryElement() ?? driver.getElement();
|
|
44
49
|
const getValue = () => {
|
|
45
|
-
return
|
|
50
|
+
return getInputElement().props.value ?? getInputElement().props.defaultValue;
|
|
46
51
|
};
|
|
47
52
|
const changeText = text => {
|
|
48
|
-
fireEvent.changeText(
|
|
53
|
+
fireEvent.changeText(getInputElement(), text);
|
|
49
54
|
};
|
|
50
55
|
const focus = () => {
|
|
51
|
-
fireEvent(
|
|
56
|
+
fireEvent(getInputElement(), 'focus');
|
|
52
57
|
};
|
|
53
58
|
const blur = () => {
|
|
54
|
-
fireEvent(
|
|
59
|
+
fireEvent(getInputElement(), 'blur');
|
|
55
60
|
};
|
|
56
61
|
const isEnabled = () => {
|
|
57
|
-
return !
|
|
62
|
+
return !getInputElement().props.accessibilityState?.disabled;
|
|
58
63
|
};
|
|
59
64
|
const getPlaceholder = () => {
|
|
60
65
|
const exists = () => {
|
|
61
|
-
const hasPlaceholder = !!
|
|
66
|
+
const hasPlaceholder = !!getInputElement().props.placeholder;
|
|
62
67
|
const hasText = !!getValue();
|
|
63
68
|
return hasPlaceholder && (!hasText || hasText && floatingPlaceholderDriver.exists());
|
|
64
69
|
};
|
|
65
70
|
const getText = () => {
|
|
66
71
|
if (exists()) {
|
|
67
|
-
return
|
|
72
|
+
return getInputElement().props.placeholder;
|
|
68
73
|
}
|
|
69
74
|
};
|
|
70
75
|
return {
|
|
@@ -78,6 +78,8 @@ const TextField = props => {
|
|
|
78
78
|
readonly = false,
|
|
79
79
|
showMandatoryIndication,
|
|
80
80
|
clearButtonStyle,
|
|
81
|
+
testID,
|
|
82
|
+
accessibilityLabel: accessibilityLabelProp,
|
|
81
83
|
...others
|
|
82
84
|
} = usePreset(props);
|
|
83
85
|
const {
|
|
@@ -135,11 +137,31 @@ const TextField = props => {
|
|
|
135
137
|
const hasValue = fieldState.value !== undefined; // NOTE: not pressable if centered without a value (so can't center placeholder)
|
|
136
138
|
const inputStyle = useMemo(() => [typographyStyle, colorStyle, others.style, hasValue && centeredTextStyle], [typographyStyle, colorStyle, others.style, centeredTextStyle, hasValue]);
|
|
137
139
|
const dummyPlaceholderStyle = useMemo(() => [inputStyle, styles.dummyPlaceholder], [inputStyle]);
|
|
140
|
+
const defaultAccessibilityLabel = useMemo(() => {
|
|
141
|
+
const parts = [];
|
|
142
|
+
if (label) {
|
|
143
|
+
parts.push(label);
|
|
144
|
+
}
|
|
145
|
+
if (context.isMandatory) {
|
|
146
|
+
parts.push('required');
|
|
147
|
+
}
|
|
148
|
+
parts.push('textField');
|
|
149
|
+
if (helperText) {
|
|
150
|
+
parts.push(helperText);
|
|
151
|
+
} else if (placeholder) {
|
|
152
|
+
parts.push(placeholder);
|
|
153
|
+
}
|
|
154
|
+
if (showCharCounter && others.maxLength) {
|
|
155
|
+
parts.push(`you can enter up to ${others.maxLength} characters`);
|
|
156
|
+
}
|
|
157
|
+
return parts.join(', ');
|
|
158
|
+
}, [label, context.isMandatory, helperText, placeholder, showCharCounter, others.maxLength]);
|
|
159
|
+
const accessibilityLabel = accessibilityLabelProp ?? defaultAccessibilityLabel;
|
|
138
160
|
return <FieldContext.Provider value={context}>
|
|
139
|
-
<View {...containerProps} style={[margins, positionStyle, containerStyle, centeredContainerStyle]}>
|
|
161
|
+
<View {...containerProps} testID={testID} accessible accessibilityLabel={accessibilityLabel} style={[margins, positionStyle, containerStyle, centeredContainerStyle]}>
|
|
140
162
|
<View row spread style={centeredContainerStyle}>
|
|
141
|
-
<Label label={label} labelColor={labelColor} labelStyle={_labelStyle} labelProps={labelProps} floatingPlaceholder={floatingPlaceholder} validationMessagePosition={validationMessagePosition} testID={`${
|
|
142
|
-
{validationMessagePosition === ValidationMessagePosition.TOP && <ValidationMessage enableErrors={enableErrors} validate={others.validate} validationMessage={others.validationMessage} validationMessageStyle={_validationMessageStyle} retainValidationSpace={retainValidationSpace && retainTopMessageSpace} testID={`${
|
|
163
|
+
<Label label={label} labelColor={labelColor} labelStyle={_labelStyle} labelProps={labelProps} floatingPlaceholder={floatingPlaceholder} validationMessagePosition={validationMessagePosition} testID={`${testID}.label`} showMandatoryIndication={showMandatoryIndication} enableErrors={enableErrors} />
|
|
164
|
+
{validationMessagePosition === ValidationMessagePosition.TOP && <ValidationMessage enableErrors={enableErrors} validate={others.validate} validationMessage={others.validationMessage} validationMessageStyle={_validationMessageStyle} retainValidationSpace={retainValidationSpace && retainTopMessageSpace} testID={`${testID}.validationMessage`} />}
|
|
143
165
|
{topTrailingAccessory && <View>{topTrailingAccessory}</View>}
|
|
144
166
|
</View>
|
|
145
167
|
<View style={[paddings, fieldStyle]} row centerV centerH={centered}>
|
|
@@ -158,26 +180,26 @@ const TextField = props => {
|
|
|
158
180
|
{Constants.isAndroid && centered && <Text marginR-s1 style={dummyPlaceholderStyle}>
|
|
159
181
|
{placeholder}
|
|
160
182
|
</Text>}
|
|
161
|
-
{floatingPlaceholder && <FloatingPlaceholder defaultValue={others.defaultValue} placeholder={placeholder} floatingPlaceholderStyle={_floatingPlaceholderStyle} floatingPlaceholderColor={floatingPlaceholderColor} floatOnFocus={floatOnFocus} validationMessagePosition={validationMessagePosition} extraOffset={leadingAccessoryMeasurements?.width} testID={`${
|
|
183
|
+
{floatingPlaceholder && <FloatingPlaceholder defaultValue={others.defaultValue} placeholder={placeholder} floatingPlaceholderStyle={_floatingPlaceholderStyle} floatingPlaceholderColor={floatingPlaceholderColor} floatOnFocus={floatOnFocus} validationMessagePosition={validationMessagePosition} extraOffset={leadingAccessoryMeasurements?.width} testID={`${testID}.floatingPlaceholder`} showMandatoryIndication={showMandatoryIndication} />}
|
|
162
184
|
<Input hitSlop={{
|
|
163
185
|
top: 20,
|
|
164
186
|
bottom: 20
|
|
165
|
-
}} placeholderTextColor={hidePlaceholder ? 'transparent' : placeholderTextColor} value={fieldState.value} {...others} readonly={readonly} style={inputStyle} onFocus={onFocus} onBlur={onBlur} onChangeText={onChangeText} placeholder={placeholder} hint={hint} showMandatoryIndication={showMandatoryIndication && !label} />
|
|
187
|
+
}} placeholderTextColor={hidePlaceholder ? 'transparent' : placeholderTextColor} value={fieldState.value} {...others} testID={`${testID}.input`} readonly={readonly} style={inputStyle} onFocus={onFocus} onBlur={onBlur} onChangeText={onChangeText} placeholder={placeholder} hint={hint} showMandatoryIndication={showMandatoryIndication && !label} />
|
|
166
188
|
</View>}
|
|
167
|
-
{showClearButton && <ClearButton onClear={onClear} testID={`${
|
|
189
|
+
{showClearButton && <ClearButton onClear={onClear} testID={`${testID}.clearButton`} onChangeText={onChangeText} clearButtonStyle={clearButtonStyle} />}
|
|
168
190
|
{trailingAccessory}
|
|
169
191
|
{/* </View> */}
|
|
170
192
|
</View>
|
|
171
193
|
<View row spread center={centered}>
|
|
172
194
|
<View flex={!centered} flexG={centered} marginR-s4={showCharCounter}>
|
|
173
|
-
{validationMessagePosition === ValidationMessagePosition.BOTTOM && <ValidationMessage enableErrors={enableErrors} validate={others.validate} validationMessage={others.validationMessage} validationIcon={validationIcon} validationMessageStyle={_validationMessageStyle} retainValidationSpace={retainValidationSpace} testID={`${
|
|
174
|
-
{helperText && <Text $textNeutralHeavy subtext marginT-s1 testID={`${
|
|
195
|
+
{validationMessagePosition === ValidationMessagePosition.BOTTOM && <ValidationMessage enableErrors={enableErrors} validate={others.validate} validationMessage={others.validationMessage} validationIcon={validationIcon} validationMessageStyle={_validationMessageStyle} retainValidationSpace={retainValidationSpace} testID={`${testID}.validationMessage`} />}
|
|
196
|
+
{helperText && <Text $textNeutralHeavy subtext marginT-s1 testID={`${testID}.helperText`}>
|
|
175
197
|
{helperText}
|
|
176
198
|
</Text>}
|
|
177
199
|
{bottomAccessory}
|
|
178
200
|
</View>
|
|
179
201
|
<View>
|
|
180
|
-
{showCharCounter && <CharCounter maxLength={others.maxLength} charCounterStyle={charCounterStyle} testID={`${
|
|
202
|
+
{showCharCounter && <CharCounter maxLength={others.maxLength} charCounterStyle={charCounterStyle} testID={`${testID}.charCounter`} />}
|
|
181
203
|
</View>
|
|
182
204
|
</View>
|
|
183
205
|
</View>
|
package/src/hooks/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { default as useModifiers } from './useModifiers';
|
|
|
6
6
|
export { default as useOrientation } from './useOrientation';
|
|
7
7
|
export { default as useScrollEnabler } from './useScrollEnabler';
|
|
8
8
|
export { default as useScrollReached } from './useScrollReached';
|
|
9
|
+
export { default as useScrollToHide } from './useScrollToHide';
|
|
9
10
|
export { default as useScrollToItem } from './useScrollToItem';
|
|
10
11
|
export { default as useScrollTo } from './useScrollTo';
|
|
11
12
|
export { default as useThemeProps } from './useThemeProps';
|
package/src/hooks/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { default as useModifiers } from "./useModifiers";
|
|
|
6
6
|
export { default as useOrientation } from "./useOrientation";
|
|
7
7
|
export { default as useScrollEnabler } from "./useScrollEnabler";
|
|
8
8
|
export { default as useScrollReached } from "./useScrollReached";
|
|
9
|
+
export { default as useScrollToHide } from "./useScrollToHide";
|
|
9
10
|
export { default as useScrollToItem } from "./useScrollToItem";
|
|
10
11
|
export { default as useScrollTo } from "./useScrollTo";
|
|
11
12
|
export { default as useThemeProps } from "./useThemeProps";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { NativeSyntheticEvent, NativeScrollEvent } from 'react-native';
|
|
2
|
+
export type ScrollToHideProps = {
|
|
3
|
+
/**
|
|
4
|
+
* The threshold (in pixels) to ignore small scroll movements before updating visibility.
|
|
5
|
+
* Defaults to 0 (immediate reaction).
|
|
6
|
+
*/
|
|
7
|
+
scrollingThreshold?: number;
|
|
8
|
+
};
|
|
9
|
+
export type ScrollToHideResult = {
|
|
10
|
+
/**
|
|
11
|
+
* onScroll callback (should be passed to your ScrollView/FlatList onScroll prop).
|
|
12
|
+
*/
|
|
13
|
+
onScroll: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the footer should be visible based on scroll direction.
|
|
16
|
+
*/
|
|
17
|
+
visible: boolean;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* @description: A hook that tracks scroll direction to toggle visibility (e.g., for hiding a footer on scroll).
|
|
21
|
+
* @example: const {onScroll, visible} = useScrollToHide();
|
|
22
|
+
*/
|
|
23
|
+
declare const useScrollToHide: (props?: ScrollToHideProps) => ScrollToHideResult;
|
|
24
|
+
export default useScrollToHide;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useState, useCallback, useRef } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* @description: A hook that tracks scroll direction to toggle visibility (e.g., for hiding a footer on scroll).
|
|
4
|
+
* @example: const {onScroll, visible} = useScrollToHide();
|
|
5
|
+
*/
|
|
6
|
+
const useScrollToHide = (props = {}) => {
|
|
7
|
+
const {
|
|
8
|
+
scrollingThreshold = 0
|
|
9
|
+
} = props;
|
|
10
|
+
const [visible, setVisible] = useState(true);
|
|
11
|
+
const prevContentOffset = useRef(0);
|
|
12
|
+
const onScroll = useCallback(event => {
|
|
13
|
+
const {
|
|
14
|
+
nativeEvent: {
|
|
15
|
+
contentOffset: {
|
|
16
|
+
y: currentOffset
|
|
17
|
+
},
|
|
18
|
+
contentSize: {
|
|
19
|
+
height: contentHeight
|
|
20
|
+
},
|
|
21
|
+
layoutMeasurement: {
|
|
22
|
+
height: layoutHeight
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
} = event;
|
|
26
|
+
|
|
27
|
+
// Ignore bounces (iOS)
|
|
28
|
+
if (currentOffset < 0 || currentOffset > contentHeight - layoutHeight) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const diff = currentOffset - prevContentOffset.current;
|
|
32
|
+
if (Math.abs(diff) > scrollingThreshold) {
|
|
33
|
+
if (diff > 0 && visible) {
|
|
34
|
+
// Scrolling Down -> Hide
|
|
35
|
+
setVisible(false);
|
|
36
|
+
} else if (diff < 0 && !visible) {
|
|
37
|
+
// Scrolling Up -> Show
|
|
38
|
+
setVisible(true);
|
|
39
|
+
}
|
|
40
|
+
prevContentOffset.current = currentOffset;
|
|
41
|
+
}
|
|
42
|
+
}, [visible, scrollingThreshold]);
|
|
43
|
+
return {
|
|
44
|
+
onScroll,
|
|
45
|
+
visible
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export default useScrollToHide;
|
|
@@ -33,11 +33,15 @@ const ExpandableOverlay = (props, ref) => {
|
|
|
33
33
|
setExpandableVisible(true);
|
|
34
34
|
onPress?.(props);
|
|
35
35
|
}, [onPress, customValue]);
|
|
36
|
-
const
|
|
36
|
+
const dismissOverlay = useCallback(() => {
|
|
37
37
|
setExpandableVisible(false);
|
|
38
38
|
focusAccessibility();
|
|
39
|
+
}, [focusAccessibility]);
|
|
40
|
+
const closeExpandable = useCallback(() => {
|
|
41
|
+
dismissOverlay();
|
|
39
42
|
useDialog ? dialogProps?.onDismiss?.() : modalProps?.onDismiss?.();
|
|
40
|
-
|
|
43
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
44
|
+
}, [dismissOverlay, dialogProps?.onDismiss, modalProps?.onDismiss]);
|
|
41
45
|
const toggleExpandable = useCallback(() => visible ? closeExpandable() : openExpandable(), [visible, openExpandable, closeExpandable]);
|
|
42
46
|
useImperativeHandle(ref, () => ({
|
|
43
47
|
openExpandable,
|
|
@@ -45,7 +49,7 @@ const ExpandableOverlay = (props, ref) => {
|
|
|
45
49
|
toggleExpandable
|
|
46
50
|
}));
|
|
47
51
|
const renderModal = () => {
|
|
48
|
-
return <Modal testID={`${testID}.overlay`} overlayBackgroundColor={Colors.$backgroundDefault} {...modalProps} visible={visible} onDismiss={
|
|
52
|
+
return <Modal testID={`${testID}.overlay`} overlayBackgroundColor={Colors.$backgroundDefault} {...modalProps} visible={visible} onDismiss={dismissOverlay} onRequestClose={closeExpandable} onBackgroundPress={closeExpandable}>
|
|
49
53
|
{showTopBar && <Modal.TopBar onDone={closeExpandable} {...topBarProps} />}
|
|
50
54
|
{expandableContent}
|
|
51
55
|
</Modal>;
|
package/src/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export { default as ExpandableSection, ExpandableSectionProps } from './componen
|
|
|
38
38
|
export { default as Fader, FaderProps, FaderPosition } from './components/fader';
|
|
39
39
|
export { default as FeatureHighlight, FeatureHighlightProps } from './components/featureHighlight';
|
|
40
40
|
export { default as FloatingButton, FloatingButtonProps, FloatingButtonLayouts } from './components/floatingButton';
|
|
41
|
+
export { default as ScreenFooter, ScreenFooterProps, ScreenFooterLayouts, ScreenFooterBackgrounds, FooterAlignment, HorizontalItemsDistribution, ItemsFit, KeyboardBehavior, ScreenFooterShadow } from './components/screenFooter';
|
|
41
42
|
export { default as Gradient, GradientProps, GradientTypes } from './components/gradient';
|
|
42
43
|
export { default as Slider } from './components/slider';
|
|
43
44
|
export { default as GradientSlider } from './components/slider/GradientSlider';
|