@onlynative/components 0.1.0 → 0.1.1-alpha.1
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/dist/appbar/index.js +133 -62
- package/dist/button/index.js +125 -33
- package/dist/card/index.js +88 -20
- package/dist/checkbox/index.js +88 -17
- package/dist/chip/index.js +122 -30
- package/dist/icon-button/index.js +107 -36
- package/dist/index.js +335 -251
- package/dist/list/index.js +71 -24
- package/dist/radio/index.js +43 -14
- package/dist/switch/index.js +90 -19
- package/dist/text-field/index.js +82 -26
- package/package.json +4 -23
- package/src/appbar/AppBar.tsx +0 -302
- package/src/appbar/index.ts +0 -2
- package/src/appbar/styles.ts +0 -92
- package/src/appbar/types.ts +0 -67
- package/src/button/Button.tsx +0 -133
- package/src/button/index.ts +0 -2
- package/src/button/styles.ts +0 -287
- package/src/button/types.ts +0 -42
- package/src/card/Card.tsx +0 -69
- package/src/card/index.ts +0 -2
- package/src/card/styles.ts +0 -150
- package/src/card/types.ts +0 -27
- package/src/checkbox/Checkbox.tsx +0 -113
- package/src/checkbox/index.ts +0 -2
- package/src/checkbox/styles.ts +0 -155
- package/src/checkbox/types.ts +0 -20
- package/src/chip/Chip.tsx +0 -188
- package/src/chip/index.ts +0 -2
- package/src/chip/styles.ts +0 -239
- package/src/chip/types.ts +0 -58
- package/src/icon-button/IconButton.tsx +0 -362
- package/src/icon-button/index.ts +0 -6
- package/src/icon-button/styles.ts +0 -259
- package/src/icon-button/types.ts +0 -55
- package/src/index.ts +0 -54
- package/src/keyboard-avoiding-wrapper/KeyboardAvoidingWrapper.tsx +0 -69
- package/src/keyboard-avoiding-wrapper/index.ts +0 -2
- package/src/keyboard-avoiding-wrapper/styles.ts +0 -10
- package/src/keyboard-avoiding-wrapper/types.ts +0 -37
- package/src/layout/Box.tsx +0 -99
- package/src/layout/Column.tsx +0 -16
- package/src/layout/Grid.tsx +0 -49
- package/src/layout/Layout.tsx +0 -81
- package/src/layout/Row.tsx +0 -22
- package/src/layout/index.ts +0 -13
- package/src/layout/resolveSpacing.ts +0 -11
- package/src/layout/types.ts +0 -82
- package/src/list/List.tsx +0 -17
- package/src/list/ListDivider.tsx +0 -20
- package/src/list/ListItem.tsx +0 -128
- package/src/list/index.ts +0 -9
- package/src/list/styles.ts +0 -132
- package/src/list/types.ts +0 -54
- package/src/radio/Radio.tsx +0 -103
- package/src/radio/index.ts +0 -2
- package/src/radio/styles.ts +0 -139
- package/src/radio/types.ts +0 -20
- package/src/switch/Switch.tsx +0 -121
- package/src/switch/index.ts +0 -2
- package/src/switch/styles.ts +0 -172
- package/src/switch/types.ts +0 -32
- package/src/text-field/TextField.tsx +0 -301
- package/src/text-field/index.ts +0 -2
- package/src/text-field/styles.ts +0 -239
- package/src/text-field/types.ts +0 -49
- package/src/typography/Typography.tsx +0 -79
- package/src/typography/index.ts +0 -3
- package/src/typography/types.ts +0 -17
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native'
|
|
2
|
-
import type { MaterialTheme } from '@onlynative/core'
|
|
3
|
-
import { alphaColor, blendColor } from '@onlynative/utils'
|
|
4
|
-
|
|
5
|
-
export function createStyles(theme: MaterialTheme) {
|
|
6
|
-
const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12)
|
|
7
|
-
const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12)
|
|
8
|
-
const toggleUnselectedContainerColor = theme.colors.surfaceContainerHighest
|
|
9
|
-
|
|
10
|
-
return StyleSheet.create({
|
|
11
|
-
container: {
|
|
12
|
-
borderRadius: theme.shape.cornerFull,
|
|
13
|
-
alignItems: 'center',
|
|
14
|
-
justifyContent: 'center',
|
|
15
|
-
cursor: 'pointer',
|
|
16
|
-
},
|
|
17
|
-
sizeSmall: {
|
|
18
|
-
width: 32,
|
|
19
|
-
height: 32,
|
|
20
|
-
},
|
|
21
|
-
sizeMedium: {
|
|
22
|
-
width: 40,
|
|
23
|
-
height: 40,
|
|
24
|
-
},
|
|
25
|
-
sizeLarge: {
|
|
26
|
-
width: 48,
|
|
27
|
-
height: 48,
|
|
28
|
-
},
|
|
29
|
-
colorFilled: {
|
|
30
|
-
backgroundColor: theme.colors.primary,
|
|
31
|
-
borderColor: theme.colors.primary,
|
|
32
|
-
borderWidth: 0,
|
|
33
|
-
},
|
|
34
|
-
colorFilledToggleUnselected: {
|
|
35
|
-
backgroundColor: toggleUnselectedContainerColor,
|
|
36
|
-
borderColor: toggleUnselectedContainerColor,
|
|
37
|
-
borderWidth: 0,
|
|
38
|
-
},
|
|
39
|
-
colorFilledToggleSelected: {
|
|
40
|
-
backgroundColor: theme.colors.primary,
|
|
41
|
-
borderColor: theme.colors.primary,
|
|
42
|
-
borderWidth: 0,
|
|
43
|
-
},
|
|
44
|
-
colorTonal: {
|
|
45
|
-
backgroundColor: theme.colors.secondaryContainer,
|
|
46
|
-
borderColor: theme.colors.secondaryContainer,
|
|
47
|
-
borderWidth: 0,
|
|
48
|
-
},
|
|
49
|
-
colorTonalToggleUnselected: {
|
|
50
|
-
backgroundColor: toggleUnselectedContainerColor,
|
|
51
|
-
borderColor: toggleUnselectedContainerColor,
|
|
52
|
-
borderWidth: 0,
|
|
53
|
-
},
|
|
54
|
-
colorTonalToggleSelected: {
|
|
55
|
-
backgroundColor: theme.colors.secondaryContainer,
|
|
56
|
-
borderColor: theme.colors.secondaryContainer,
|
|
57
|
-
borderWidth: 0,
|
|
58
|
-
},
|
|
59
|
-
colorOutlined: {
|
|
60
|
-
borderColor: theme.colors.outline,
|
|
61
|
-
borderWidth: 1,
|
|
62
|
-
},
|
|
63
|
-
colorOutlinedToggleSelected: {
|
|
64
|
-
backgroundColor: theme.colors.inverseSurface,
|
|
65
|
-
borderColor: theme.colors.inverseSurface,
|
|
66
|
-
borderWidth: 0,
|
|
67
|
-
},
|
|
68
|
-
colorStandard: {
|
|
69
|
-
borderWidth: 0,
|
|
70
|
-
},
|
|
71
|
-
colorStandardToggleSelected: {
|
|
72
|
-
borderWidth: 0,
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
// Hover states (M3: 8% state layer)
|
|
76
|
-
hoveredFilled: {
|
|
77
|
-
backgroundColor: blendColor(
|
|
78
|
-
theme.colors.primary,
|
|
79
|
-
theme.colors.onPrimary,
|
|
80
|
-
theme.stateLayer.hoveredOpacity,
|
|
81
|
-
),
|
|
82
|
-
},
|
|
83
|
-
hoveredFilledToggleUnselected: {
|
|
84
|
-
backgroundColor: blendColor(
|
|
85
|
-
toggleUnselectedContainerColor,
|
|
86
|
-
theme.colors.primary,
|
|
87
|
-
theme.stateLayer.hoveredOpacity,
|
|
88
|
-
),
|
|
89
|
-
},
|
|
90
|
-
hoveredFilledToggleSelected: {
|
|
91
|
-
backgroundColor: blendColor(
|
|
92
|
-
theme.colors.primary,
|
|
93
|
-
theme.colors.onPrimary,
|
|
94
|
-
theme.stateLayer.hoveredOpacity,
|
|
95
|
-
),
|
|
96
|
-
},
|
|
97
|
-
hoveredTonal: {
|
|
98
|
-
backgroundColor: blendColor(
|
|
99
|
-
theme.colors.secondaryContainer,
|
|
100
|
-
theme.colors.onSecondaryContainer,
|
|
101
|
-
theme.stateLayer.hoveredOpacity,
|
|
102
|
-
),
|
|
103
|
-
},
|
|
104
|
-
hoveredTonalToggleUnselected: {
|
|
105
|
-
backgroundColor: blendColor(
|
|
106
|
-
toggleUnselectedContainerColor,
|
|
107
|
-
theme.colors.onSurfaceVariant,
|
|
108
|
-
theme.stateLayer.hoveredOpacity,
|
|
109
|
-
),
|
|
110
|
-
},
|
|
111
|
-
hoveredTonalToggleSelected: {
|
|
112
|
-
backgroundColor: blendColor(
|
|
113
|
-
theme.colors.secondaryContainer,
|
|
114
|
-
theme.colors.onSecondaryContainer,
|
|
115
|
-
theme.stateLayer.hoveredOpacity,
|
|
116
|
-
),
|
|
117
|
-
},
|
|
118
|
-
hoveredOutlined: {
|
|
119
|
-
backgroundColor: alphaColor(
|
|
120
|
-
theme.colors.onSurfaceVariant,
|
|
121
|
-
theme.stateLayer.hoveredOpacity,
|
|
122
|
-
),
|
|
123
|
-
},
|
|
124
|
-
hoveredOutlinedToggleUnselected: {
|
|
125
|
-
backgroundColor: alphaColor(
|
|
126
|
-
theme.colors.onSurfaceVariant,
|
|
127
|
-
theme.stateLayer.hoveredOpacity,
|
|
128
|
-
),
|
|
129
|
-
},
|
|
130
|
-
hoveredOutlinedToggleSelected: {
|
|
131
|
-
backgroundColor: blendColor(
|
|
132
|
-
theme.colors.inverseSurface,
|
|
133
|
-
theme.colors.inverseOnSurface,
|
|
134
|
-
theme.stateLayer.hoveredOpacity,
|
|
135
|
-
),
|
|
136
|
-
},
|
|
137
|
-
hoveredStandard: {
|
|
138
|
-
backgroundColor: alphaColor(
|
|
139
|
-
theme.colors.onSurfaceVariant,
|
|
140
|
-
theme.stateLayer.hoveredOpacity,
|
|
141
|
-
),
|
|
142
|
-
},
|
|
143
|
-
hoveredStandardToggleUnselected: {
|
|
144
|
-
backgroundColor: alphaColor(
|
|
145
|
-
theme.colors.onSurfaceVariant,
|
|
146
|
-
theme.stateLayer.hoveredOpacity,
|
|
147
|
-
),
|
|
148
|
-
},
|
|
149
|
-
hoveredStandardToggleSelected: {
|
|
150
|
-
backgroundColor: alphaColor(
|
|
151
|
-
theme.colors.primary,
|
|
152
|
-
theme.stateLayer.hoveredOpacity,
|
|
153
|
-
),
|
|
154
|
-
},
|
|
155
|
-
|
|
156
|
-
// Pressed states (M3: 12% state layer)
|
|
157
|
-
pressedFilled: {
|
|
158
|
-
backgroundColor: blendColor(
|
|
159
|
-
theme.colors.primary,
|
|
160
|
-
theme.colors.onPrimary,
|
|
161
|
-
theme.stateLayer.pressedOpacity,
|
|
162
|
-
),
|
|
163
|
-
},
|
|
164
|
-
pressedFilledToggleUnselected: {
|
|
165
|
-
backgroundColor: blendColor(
|
|
166
|
-
toggleUnselectedContainerColor,
|
|
167
|
-
theme.colors.primary,
|
|
168
|
-
theme.stateLayer.pressedOpacity,
|
|
169
|
-
),
|
|
170
|
-
},
|
|
171
|
-
pressedFilledToggleSelected: {
|
|
172
|
-
backgroundColor: blendColor(
|
|
173
|
-
theme.colors.primary,
|
|
174
|
-
theme.colors.onPrimary,
|
|
175
|
-
theme.stateLayer.pressedOpacity,
|
|
176
|
-
),
|
|
177
|
-
},
|
|
178
|
-
pressedTonal: {
|
|
179
|
-
backgroundColor: blendColor(
|
|
180
|
-
theme.colors.secondaryContainer,
|
|
181
|
-
theme.colors.onSecondaryContainer,
|
|
182
|
-
theme.stateLayer.pressedOpacity,
|
|
183
|
-
),
|
|
184
|
-
},
|
|
185
|
-
pressedTonalToggleUnselected: {
|
|
186
|
-
backgroundColor: blendColor(
|
|
187
|
-
toggleUnselectedContainerColor,
|
|
188
|
-
theme.colors.onSurfaceVariant,
|
|
189
|
-
theme.stateLayer.pressedOpacity,
|
|
190
|
-
),
|
|
191
|
-
},
|
|
192
|
-
pressedTonalToggleSelected: {
|
|
193
|
-
backgroundColor: blendColor(
|
|
194
|
-
theme.colors.secondaryContainer,
|
|
195
|
-
theme.colors.onSecondaryContainer,
|
|
196
|
-
theme.stateLayer.pressedOpacity,
|
|
197
|
-
),
|
|
198
|
-
},
|
|
199
|
-
pressedOutlined: {
|
|
200
|
-
backgroundColor: alphaColor(
|
|
201
|
-
theme.colors.onSurfaceVariant,
|
|
202
|
-
theme.stateLayer.pressedOpacity,
|
|
203
|
-
),
|
|
204
|
-
},
|
|
205
|
-
pressedOutlinedToggleUnselected: {
|
|
206
|
-
backgroundColor: alphaColor(
|
|
207
|
-
theme.colors.onSurfaceVariant,
|
|
208
|
-
theme.stateLayer.pressedOpacity,
|
|
209
|
-
),
|
|
210
|
-
},
|
|
211
|
-
pressedOutlinedToggleSelected: {
|
|
212
|
-
backgroundColor: blendColor(
|
|
213
|
-
theme.colors.inverseSurface,
|
|
214
|
-
theme.colors.inverseOnSurface,
|
|
215
|
-
theme.stateLayer.pressedOpacity,
|
|
216
|
-
),
|
|
217
|
-
},
|
|
218
|
-
pressedStandard: {
|
|
219
|
-
backgroundColor: alphaColor(
|
|
220
|
-
theme.colors.onSurfaceVariant,
|
|
221
|
-
theme.stateLayer.pressedOpacity,
|
|
222
|
-
),
|
|
223
|
-
},
|
|
224
|
-
pressedStandardToggleUnselected: {
|
|
225
|
-
backgroundColor: alphaColor(
|
|
226
|
-
theme.colors.onSurfaceVariant,
|
|
227
|
-
theme.stateLayer.pressedOpacity,
|
|
228
|
-
),
|
|
229
|
-
},
|
|
230
|
-
pressedStandardToggleSelected: {
|
|
231
|
-
backgroundColor: alphaColor(
|
|
232
|
-
theme.colors.primary,
|
|
233
|
-
theme.stateLayer.pressedOpacity,
|
|
234
|
-
),
|
|
235
|
-
},
|
|
236
|
-
|
|
237
|
-
// Disabled states
|
|
238
|
-
disabledFilled: {
|
|
239
|
-
backgroundColor: disabledContainerColor,
|
|
240
|
-
borderColor: disabledContainerColor,
|
|
241
|
-
cursor: 'auto',
|
|
242
|
-
},
|
|
243
|
-
disabledTonal: {
|
|
244
|
-
backgroundColor: disabledContainerColor,
|
|
245
|
-
borderColor: disabledContainerColor,
|
|
246
|
-
cursor: 'auto',
|
|
247
|
-
},
|
|
248
|
-
disabledOutlined: {
|
|
249
|
-
backgroundColor: 'transparent',
|
|
250
|
-
borderColor: disabledOutlineColor,
|
|
251
|
-
cursor: 'auto',
|
|
252
|
-
},
|
|
253
|
-
disabledStandard: {
|
|
254
|
-
backgroundColor: 'transparent',
|
|
255
|
-
borderColor: 'transparent',
|
|
256
|
-
cursor: 'auto',
|
|
257
|
-
},
|
|
258
|
-
})
|
|
259
|
-
}
|
package/src/icon-button/types.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type MaterialCommunityIcons from '@expo/vector-icons/MaterialCommunityIcons'
|
|
2
|
-
import type { ComponentProps } from 'react'
|
|
3
|
-
import type { PressableProps } from 'react-native'
|
|
4
|
-
|
|
5
|
-
/** Visual fill style of the icon button. */
|
|
6
|
-
export type IconButtonVariant = 'filled' | 'tonal' | 'outlined' | 'standard'
|
|
7
|
-
|
|
8
|
-
/** Touch target size of the icon button. */
|
|
9
|
-
export type IconButtonSize = 'small' | 'medium' | 'large'
|
|
10
|
-
|
|
11
|
-
export interface IconButtonProps
|
|
12
|
-
extends Omit<
|
|
13
|
-
PressableProps,
|
|
14
|
-
'children' | 'onPress' | 'style' | 'accessibilityLabel'
|
|
15
|
-
> {
|
|
16
|
-
/** MaterialCommunityIcons icon name to display. */
|
|
17
|
-
icon: ComponentProps<typeof MaterialCommunityIcons>['name']
|
|
18
|
-
/** Icon to display when `selected` is `true` (toggle mode). */
|
|
19
|
-
selectedIcon?: ComponentProps<typeof MaterialCommunityIcons>['name']
|
|
20
|
-
/** Overrides the automatic icon color derived from the variant and state. */
|
|
21
|
-
iconColor?: string
|
|
22
|
-
/**
|
|
23
|
-
* Override the content (icon) color.
|
|
24
|
-
* Takes precedence over `iconColor` when both are provided.
|
|
25
|
-
*/
|
|
26
|
-
contentColor?: string
|
|
27
|
-
/**
|
|
28
|
-
* Override the container (background) color.
|
|
29
|
-
* State-layer colors (hover, press) are derived automatically.
|
|
30
|
-
*/
|
|
31
|
-
containerColor?: string
|
|
32
|
-
/** Custom style applied to the root container. */
|
|
33
|
-
style?: PressableProps['style']
|
|
34
|
-
/** Called when the button is pressed. */
|
|
35
|
-
onPress?: () => void
|
|
36
|
-
/**
|
|
37
|
-
* Disables the button.
|
|
38
|
-
* @default false
|
|
39
|
-
*/
|
|
40
|
-
disabled?: boolean
|
|
41
|
-
/**
|
|
42
|
-
* Visual style variant.
|
|
43
|
-
* @default 'filled'
|
|
44
|
-
*/
|
|
45
|
-
variant?: IconButtonVariant
|
|
46
|
-
/** Enables toggle mode. The button changes appearance based on selected/unselected state. */
|
|
47
|
-
selected?: boolean
|
|
48
|
-
/**
|
|
49
|
-
* Physical size of the touch target and icon container.
|
|
50
|
-
* @default 'medium'
|
|
51
|
-
*/
|
|
52
|
-
size?: IconButtonSize
|
|
53
|
-
/** Required — icon-only buttons must have a label for screen readers. */
|
|
54
|
-
accessibilityLabel: string
|
|
55
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
export { Typography } from './typography'
|
|
2
|
-
export type { TypographyProps, TypographyVariant } from './typography'
|
|
3
|
-
|
|
4
|
-
export { Layout, Box, Column, Grid, Row } from './layout'
|
|
5
|
-
export type {
|
|
6
|
-
LayoutProps,
|
|
7
|
-
BoxProps,
|
|
8
|
-
ColumnProps,
|
|
9
|
-
GridProps,
|
|
10
|
-
RowProps,
|
|
11
|
-
SpacingValue,
|
|
12
|
-
} from './layout'
|
|
13
|
-
|
|
14
|
-
export { Button } from './button'
|
|
15
|
-
export type { ButtonProps, ButtonVariant } from './button'
|
|
16
|
-
|
|
17
|
-
export { IconButton } from './icon-button'
|
|
18
|
-
export type {
|
|
19
|
-
IconButtonProps,
|
|
20
|
-
IconButtonSize,
|
|
21
|
-
IconButtonVariant,
|
|
22
|
-
} from './icon-button'
|
|
23
|
-
|
|
24
|
-
export { AppBar } from './appbar'
|
|
25
|
-
export type { AppBarAction, AppBarProps, AppBarVariant } from './appbar'
|
|
26
|
-
|
|
27
|
-
export { Card } from './card'
|
|
28
|
-
export type { CardProps, CardVariant } from './card'
|
|
29
|
-
|
|
30
|
-
export { Chip } from './chip'
|
|
31
|
-
export type { ChipProps, ChipVariant } from './chip'
|
|
32
|
-
|
|
33
|
-
export { Checkbox } from './checkbox'
|
|
34
|
-
export type { CheckboxProps } from './checkbox'
|
|
35
|
-
|
|
36
|
-
export { Radio } from './radio'
|
|
37
|
-
export type { RadioProps } from './radio'
|
|
38
|
-
|
|
39
|
-
export { Switch } from './switch'
|
|
40
|
-
export type { SwitchProps } from './switch'
|
|
41
|
-
|
|
42
|
-
export { TextField } from './text-field'
|
|
43
|
-
export type { TextFieldProps, TextFieldVariant } from './text-field'
|
|
44
|
-
|
|
45
|
-
export { List, ListItem, ListDivider } from './list'
|
|
46
|
-
export type {
|
|
47
|
-
ListProps,
|
|
48
|
-
ListItemLines,
|
|
49
|
-
ListItemProps,
|
|
50
|
-
ListDividerProps,
|
|
51
|
-
} from './list'
|
|
52
|
-
|
|
53
|
-
export { KeyboardAvoidingWrapper } from './keyboard-avoiding-wrapper'
|
|
54
|
-
export type { KeyboardAvoidingWrapperProps } from './keyboard-avoiding-wrapper'
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
Keyboard,
|
|
4
|
-
KeyboardAvoidingView,
|
|
5
|
-
Platform,
|
|
6
|
-
ScrollView,
|
|
7
|
-
} from 'react-native'
|
|
8
|
-
|
|
9
|
-
import type { KeyboardAvoidingWrapperProps } from './types'
|
|
10
|
-
import { styles } from './styles'
|
|
11
|
-
|
|
12
|
-
const isIOS = Platform.OS === 'ios'
|
|
13
|
-
|
|
14
|
-
export function KeyboardAvoidingWrapper({
|
|
15
|
-
children,
|
|
16
|
-
behavior = 'padding',
|
|
17
|
-
keyboardVerticalOffset = 0,
|
|
18
|
-
enabled = true,
|
|
19
|
-
scrollViewProps,
|
|
20
|
-
onKeyboardShow,
|
|
21
|
-
onKeyboardHide,
|
|
22
|
-
style,
|
|
23
|
-
contentContainerStyle,
|
|
24
|
-
}: KeyboardAvoidingWrapperProps) {
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
const subscriptions: ReturnType<typeof Keyboard.addListener>[] = []
|
|
27
|
-
|
|
28
|
-
if (onKeyboardShow) {
|
|
29
|
-
const showEvent = isIOS
|
|
30
|
-
? 'keyboardWillShow'
|
|
31
|
-
: 'keyboardDidShow'
|
|
32
|
-
subscriptions.push(
|
|
33
|
-
Keyboard.addListener(showEvent, onKeyboardShow),
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (onKeyboardHide) {
|
|
38
|
-
const hideEvent = isIOS
|
|
39
|
-
? 'keyboardWillHide'
|
|
40
|
-
: 'keyboardDidHide'
|
|
41
|
-
subscriptions.push(
|
|
42
|
-
Keyboard.addListener(hideEvent, onKeyboardHide),
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return () => {
|
|
47
|
-
subscriptions.forEach((sub) => sub.remove())
|
|
48
|
-
}
|
|
49
|
-
}, [onKeyboardShow, onKeyboardHide])
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<KeyboardAvoidingView
|
|
53
|
-
style={[styles.root, style]}
|
|
54
|
-
behavior={behavior}
|
|
55
|
-
keyboardVerticalOffset={keyboardVerticalOffset}
|
|
56
|
-
enabled={!isIOS && enabled}
|
|
57
|
-
>
|
|
58
|
-
<ScrollView
|
|
59
|
-
automaticallyAdjustKeyboardInsets={isIOS && enabled}
|
|
60
|
-
keyboardShouldPersistTaps="handled"
|
|
61
|
-
showsVerticalScrollIndicator={false}
|
|
62
|
-
{...scrollViewProps}
|
|
63
|
-
contentContainerStyle={[styles.container, contentContainerStyle]}
|
|
64
|
-
>
|
|
65
|
-
{children}
|
|
66
|
-
</ScrollView>
|
|
67
|
-
</KeyboardAvoidingView>
|
|
68
|
-
)
|
|
69
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { PropsWithChildren } from 'react'
|
|
2
|
-
import type {
|
|
3
|
-
KeyboardAvoidingViewProps,
|
|
4
|
-
KeyboardEvent,
|
|
5
|
-
ScrollViewProps,
|
|
6
|
-
StyleProp,
|
|
7
|
-
ViewStyle,
|
|
8
|
-
} from 'react-native'
|
|
9
|
-
|
|
10
|
-
export interface KeyboardAvoidingWrapperProps extends PropsWithChildren {
|
|
11
|
-
/**
|
|
12
|
-
* Keyboard avoidance strategy.
|
|
13
|
-
* @default 'padding'
|
|
14
|
-
*/
|
|
15
|
-
behavior?: KeyboardAvoidingViewProps['behavior']
|
|
16
|
-
/**
|
|
17
|
-
* Extra offset added to the keyboard height calculation.
|
|
18
|
-
* Useful for accounting for headers or tab bars.
|
|
19
|
-
* @default 0
|
|
20
|
-
*/
|
|
21
|
-
keyboardVerticalOffset?: number
|
|
22
|
-
/**
|
|
23
|
-
* Enable or disable the keyboard avoiding behavior.
|
|
24
|
-
* @default true
|
|
25
|
-
*/
|
|
26
|
-
enabled?: boolean
|
|
27
|
-
/** Props forwarded to the inner `ScrollView`. */
|
|
28
|
-
scrollViewProps?: ScrollViewProps
|
|
29
|
-
/** Called when the keyboard is about to show (iOS) or has shown (Android). */
|
|
30
|
-
onKeyboardShow?: (event: KeyboardEvent) => void
|
|
31
|
-
/** Called when the keyboard is about to hide (iOS) or has hidden (Android). */
|
|
32
|
-
onKeyboardHide?: (event: KeyboardEvent) => void
|
|
33
|
-
/** Style applied to the outer `KeyboardAvoidingView`. */
|
|
34
|
-
style?: StyleProp<ViewStyle>
|
|
35
|
-
/** Style applied to the inner `ScrollView` contentContainerStyle. */
|
|
36
|
-
contentContainerStyle?: StyleProp<ViewStyle>
|
|
37
|
-
}
|
package/src/layout/Box.tsx
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react'
|
|
2
|
-
import type { ViewStyle } from 'react-native'
|
|
3
|
-
import { View } from 'react-native'
|
|
4
|
-
import { useTheme } from '@onlynative/core'
|
|
5
|
-
|
|
6
|
-
import type { BoxProps, SpacingValue } from './types'
|
|
7
|
-
import { resolveSpacing } from './resolveSpacing'
|
|
8
|
-
|
|
9
|
-
export function Box({
|
|
10
|
-
p,
|
|
11
|
-
px,
|
|
12
|
-
py,
|
|
13
|
-
pt,
|
|
14
|
-
pb,
|
|
15
|
-
ps,
|
|
16
|
-
pe,
|
|
17
|
-
m,
|
|
18
|
-
mx,
|
|
19
|
-
my,
|
|
20
|
-
mt,
|
|
21
|
-
mb,
|
|
22
|
-
ms,
|
|
23
|
-
me,
|
|
24
|
-
gap,
|
|
25
|
-
rowGap,
|
|
26
|
-
columnGap,
|
|
27
|
-
flex,
|
|
28
|
-
align,
|
|
29
|
-
justify,
|
|
30
|
-
bg,
|
|
31
|
-
style,
|
|
32
|
-
...viewProps
|
|
33
|
-
}: BoxProps) {
|
|
34
|
-
const { spacing } = useTheme()
|
|
35
|
-
|
|
36
|
-
const layoutStyle = useMemo<ViewStyle>(() => {
|
|
37
|
-
const s = (v: SpacingValue | undefined) => resolveSpacing(spacing, v)
|
|
38
|
-
return {
|
|
39
|
-
...(p !== undefined && { padding: s(p) }),
|
|
40
|
-
...(px !== undefined && {
|
|
41
|
-
paddingStart: s(px),
|
|
42
|
-
paddingEnd: s(px),
|
|
43
|
-
}),
|
|
44
|
-
...(py !== undefined && {
|
|
45
|
-
paddingTop: s(py),
|
|
46
|
-
paddingBottom: s(py),
|
|
47
|
-
}),
|
|
48
|
-
...(pt !== undefined && { paddingTop: s(pt) }),
|
|
49
|
-
...(pb !== undefined && { paddingBottom: s(pb) }),
|
|
50
|
-
...(ps !== undefined && { paddingStart: s(ps) }),
|
|
51
|
-
...(pe !== undefined && { paddingEnd: s(pe) }),
|
|
52
|
-
...(m !== undefined && { margin: s(m) }),
|
|
53
|
-
...(mx !== undefined && {
|
|
54
|
-
marginStart: s(mx),
|
|
55
|
-
marginEnd: s(mx),
|
|
56
|
-
}),
|
|
57
|
-
...(my !== undefined && {
|
|
58
|
-
marginTop: s(my),
|
|
59
|
-
marginBottom: s(my),
|
|
60
|
-
}),
|
|
61
|
-
...(mt !== undefined && { marginTop: s(mt) }),
|
|
62
|
-
...(mb !== undefined && { marginBottom: s(mb) }),
|
|
63
|
-
...(ms !== undefined && { marginStart: s(ms) }),
|
|
64
|
-
...(me !== undefined && { marginEnd: s(me) }),
|
|
65
|
-
...(gap !== undefined && { gap: s(gap) }),
|
|
66
|
-
...(rowGap !== undefined && { rowGap: s(rowGap) }),
|
|
67
|
-
...(columnGap !== undefined && { columnGap: s(columnGap) }),
|
|
68
|
-
...(flex !== undefined && { flex }),
|
|
69
|
-
...(align !== undefined && { alignItems: align }),
|
|
70
|
-
...(justify !== undefined && { justifyContent: justify }),
|
|
71
|
-
...(bg !== undefined && { backgroundColor: bg }),
|
|
72
|
-
}
|
|
73
|
-
}, [
|
|
74
|
-
spacing,
|
|
75
|
-
p,
|
|
76
|
-
px,
|
|
77
|
-
py,
|
|
78
|
-
pt,
|
|
79
|
-
pb,
|
|
80
|
-
ps,
|
|
81
|
-
pe,
|
|
82
|
-
m,
|
|
83
|
-
mx,
|
|
84
|
-
my,
|
|
85
|
-
mt,
|
|
86
|
-
mb,
|
|
87
|
-
ms,
|
|
88
|
-
me,
|
|
89
|
-
gap,
|
|
90
|
-
rowGap,
|
|
91
|
-
columnGap,
|
|
92
|
-
flex,
|
|
93
|
-
align,
|
|
94
|
-
justify,
|
|
95
|
-
bg,
|
|
96
|
-
])
|
|
97
|
-
|
|
98
|
-
return <View {...viewProps} style={[layoutStyle, style]} />
|
|
99
|
-
}
|
package/src/layout/Column.tsx
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react'
|
|
2
|
-
import type { ViewStyle } from 'react-native'
|
|
3
|
-
|
|
4
|
-
import { Box } from './Box'
|
|
5
|
-
import type { ColumnProps } from './types'
|
|
6
|
-
|
|
7
|
-
export function Column({ inverted = false, style, ...boxProps }: ColumnProps) {
|
|
8
|
-
const directionStyle = useMemo<ViewStyle>(
|
|
9
|
-
() => ({
|
|
10
|
-
flexDirection: inverted ? 'column-reverse' : 'column',
|
|
11
|
-
}),
|
|
12
|
-
[inverted],
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
return <Box {...boxProps} style={[directionStyle, style]} />
|
|
16
|
-
}
|
package/src/layout/Grid.tsx
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react'
|
|
2
|
-
import type { ViewStyle } from 'react-native'
|
|
3
|
-
import { View } from 'react-native'
|
|
4
|
-
import { useTheme } from '@onlynative/core'
|
|
5
|
-
|
|
6
|
-
import { Row } from './Row'
|
|
7
|
-
import { resolveSpacing } from './resolveSpacing'
|
|
8
|
-
import type { GridProps } from './types'
|
|
9
|
-
|
|
10
|
-
export function Grid({
|
|
11
|
-
columns,
|
|
12
|
-
gap,
|
|
13
|
-
columnGap,
|
|
14
|
-
rowGap,
|
|
15
|
-
children,
|
|
16
|
-
style,
|
|
17
|
-
...rowProps
|
|
18
|
-
}: GridProps) {
|
|
19
|
-
const { spacing } = useTheme()
|
|
20
|
-
const resolvedColumnGap = resolveSpacing(spacing, columnGap ?? gap)
|
|
21
|
-
const resolvedRowGap = resolveSpacing(spacing, rowGap ?? gap)
|
|
22
|
-
const halfGap = resolvedColumnGap ? resolvedColumnGap / 2 : 0
|
|
23
|
-
|
|
24
|
-
const cellStyle = useMemo<ViewStyle>(
|
|
25
|
-
() => ({
|
|
26
|
-
flexBasis: `${100 / columns}%` as unknown as number,
|
|
27
|
-
flexShrink: 1,
|
|
28
|
-
paddingLeft: halfGap,
|
|
29
|
-
paddingRight: halfGap,
|
|
30
|
-
}),
|
|
31
|
-
[columns, halfGap],
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
const rowStyle = useMemo<ViewStyle>(
|
|
35
|
-
() => ({
|
|
36
|
-
marginLeft: -halfGap,
|
|
37
|
-
marginRight: -halfGap,
|
|
38
|
-
}),
|
|
39
|
-
[halfGap],
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<Row wrap rowGap={resolvedRowGap} {...rowProps} style={[rowStyle, style]}>
|
|
44
|
-
{React.Children.map(children, (child) =>
|
|
45
|
-
child != null ? <View style={cellStyle}>{child}</View> : null,
|
|
46
|
-
)}
|
|
47
|
-
</Row>
|
|
48
|
-
)
|
|
49
|
-
}
|