react-native-varia 0.4.1 → 0.4.3

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.
@@ -77,7 +77,13 @@ function AccordionGroupRoot({
77
77
  })
78
78
  })
79
79
 
80
- return <View style={styles.groupContainer(flex, alignSelf)}>{items}</View>
80
+ return (
81
+ <View
82
+ testID="varia-accordion-group-root"
83
+ style={styles.groupContainer(flex, alignSelf)}>
84
+ {items}
85
+ </View>
86
+ )
81
87
  }
82
88
 
83
89
  function AccordionGroupItem({
@@ -88,23 +94,28 @@ function AccordionGroupItem({
88
94
  children,
89
95
  isOpen = false,
90
96
  onToggle,
97
+ itemKey,
91
98
  }: AccordionItemProps) {
92
99
  AccordionStyles.useVariants({variant, size, active: isOpen})
93
100
  return (
94
101
  <AnimatedView
102
+ testID={`varia-accordion-group-item-${itemKey}`}
95
103
  layout={LinearTransition.duration(150)}
96
104
  style={[
97
105
  styles.itemContainer,
98
106
  AccordionStyles.itemContainer(colorPalette),
99
107
  ]}>
100
108
  <Pressable
109
+ testID={`varia-accordion-group-header-${itemKey}`}
101
110
  onPress={onToggle}
102
111
  style={[styles.header, AccordionStyles.header(colorPalette)]}>
103
112
  <Text style={AccordionStyles.headerTitle(colorPalette)}>{title}</Text>
104
113
  </Pressable>
105
114
 
106
115
  {isOpen && (
107
- <View style={styles.contentContainer}>
116
+ <View
117
+ style={styles.contentContainer}
118
+ testID={`varia-accordion-group-content-${itemKey}`}>
108
119
  <View style={styles.innerContent}>{children}</View>
109
120
  </View>
110
121
  )}
@@ -48,16 +48,24 @@ function Checkbox({
48
48
 
49
49
  return (
50
50
  <Pressable
51
+ testID="varia-checkbox-container"
51
52
  style={[styles.container, CheckboxStyles.container(colorPalette)]}
52
53
  onPress={handlePress}>
53
54
  <View
55
+ testID="varia-check-container"
54
56
  style={[
55
57
  styles.checkContainer,
56
58
  CheckboxStyles.checkContainer(colorPalette),
57
59
  ]}>
58
- {isChecked && <Check size={checkSize} color={checkColor} />}
60
+ {isChecked && (
61
+ <Check testID="varia-check" size={checkSize} color={checkColor} />
62
+ )}
59
63
  </View>
60
- <Text style={CheckboxStyles.label(colorPalette)}>{children}</Text>
64
+ <Text
65
+ testID="varia-checkbox-label"
66
+ style={CheckboxStyles.label(colorPalette)}>
67
+ {children}
68
+ </Text>
61
69
  </Pressable>
62
70
  )
63
71
  }
@@ -81,9 +89,22 @@ const styles = StyleSheet.create({
81
89
 
82
90
  export default Checkbox
83
91
 
84
- const Check = ({size, color}: {size: string; color: string}) => {
92
+ const Check = ({
93
+ size,
94
+ color,
95
+ testID,
96
+ }: {
97
+ size: string
98
+ color: string
99
+ testID?: string
100
+ }) => {
85
101
  return (
86
- <Svg width={size} height={size} viewBox="0 0 16 13" fill="none">
102
+ <Svg
103
+ testID={testID}
104
+ width={size}
105
+ height={size}
106
+ viewBox="0 0 16 13"
107
+ fill="none">
87
108
  <Line
88
109
  x1="1.64402"
89
110
  y1="6.05591"
@@ -17,8 +17,13 @@ const Divider = ({
17
17
  colorPalette?: PalettesWithNestedKeys
18
18
  }) => {
19
19
  return (
20
- <View style={styles.container(size, axis, margin)}>
21
- <View style={[styles.divider(color, colorPalette, size, axis)]} />
20
+ <View
21
+ testID="varia-divider-container"
22
+ style={styles.container(size, axis, margin)}>
23
+ <View
24
+ testID="varia-divider"
25
+ style={[styles.divider(color, colorPalette, size, axis)]}
26
+ />
22
27
  </View>
23
28
  )
24
29
  }
@@ -1,10 +1,18 @@
1
1
  import React, {
2
2
  createContext,
3
3
  useContext,
4
+ useEffect,
4
5
  useImperativeHandle,
5
6
  useMemo,
7
+ useState,
6
8
  } from 'react'
7
- import {Platform, TouchableWithoutFeedback, View} from 'react-native'
9
+ import {
10
+ Dimensions,
11
+ Keyboard,
12
+ Platform,
13
+ TouchableWithoutFeedback,
14
+ View,
15
+ } from 'react-native'
8
16
  import {Gesture, GestureDetector} from 'react-native-gesture-handler'
9
17
  import Animated, {
10
18
  measure,
@@ -228,8 +236,27 @@ const DrawerSliderInternal = ({
228
236
 
229
237
  DrawerStyles.useVariants({variant})
230
238
 
239
+ const [keyboardHeight, setKeyboardHeight] = useState<number>(0)
240
+
241
+ useEffect(() => {
242
+ const showSub = Keyboard.addListener('keyboardDidShow', e => {
243
+ if (e.endCoordinates.height < 50) return
244
+ setKeyboardHeight(e.endCoordinates.height)
245
+ })
246
+ const hideSub = Keyboard.addListener('keyboardDidHide', () => {
247
+ setKeyboardHeight(0)
248
+ })
249
+ return () => {
250
+ showSub.remove()
251
+ hideSub.remove()
252
+ }
253
+ }, [])
254
+
231
255
  const screenHeight =
232
- UnistylesRuntime.screen.height - UnistylesRuntime.insets.top
256
+ Dimensions.get('window').height - UnistylesRuntime.insets.top
257
+
258
+ // const screenHeight =
259
+ // UnistylesRuntime.screen.height - UnistylesRuntime.insets.top
233
260
  const screenWidth = UnistylesRuntime.screen.width
234
261
 
235
262
  const animations = {withSpring, withTiming}
@@ -251,7 +278,10 @@ const DrawerSliderInternal = ({
251
278
  )
252
279
  }
253
280
 
281
+ const initialized = useSharedValue(false)
282
+
254
283
  const onLayout = () => {
284
+ if (initialized.value) return
255
285
  const _screenHeight = screenHeight
256
286
  const _screenWidth = screenWidth
257
287
  const _axis = axis
@@ -275,6 +305,7 @@ const DrawerSliderInternal = ({
275
305
  resolvedSnapPoints.value = resolved
276
306
  translate.value = resolved[0]
277
307
  context.value = {position: resolved[0], snapPoint: 0}
308
+ initialized.value = true
278
309
  }
279
310
  })
280
311
  }
@@ -446,7 +477,7 @@ const DrawerSliderInternal = ({
446
477
  return {
447
478
  transform: [
448
479
  axis === 'y'
449
- ? {translateY: translate.value}
480
+ ? {translateY: translate.value - keyboardHeight}
450
481
  : {translateX: translate.value},
451
482
  ],
452
483
  }
@@ -40,6 +40,7 @@ const FieldRoot = ({
40
40
 
41
41
  return (
42
42
  <View
43
+ testID="varia-field-root"
43
44
  style={[
44
45
  styles.root(flex),
45
46
  FieldStyles.root(colorPalette),
@@ -71,7 +72,11 @@ const FieldLabel = ({children, ...props}: FieldLabelProps) => {
71
72
 
72
73
  FieldStyles.useVariants({variant, size})
73
74
 
74
- return <Text style={FieldStyles.label(colorPalette)}>{children}</Text>
75
+ return (
76
+ <Text testID="varia-field-label" style={FieldStyles.label(colorPalette)}>
77
+ {children}
78
+ </Text>
79
+ )
75
80
  }
76
81
 
77
82
  type FieldErrorProps = {
@@ -96,7 +101,10 @@ const FieldError = ({...props}: FieldErrorProps) => {
96
101
  FieldStyles.useVariants({size, variant})
97
102
 
98
103
  return (
99
- <Text size={size} color={FieldStyles.error(colorPalette).color}>
104
+ <Text
105
+ testID="varia-field-error"
106
+ size={size}
107
+ color={FieldStyles.error(colorPalette).color}>
100
108
  {error}
101
109
  </Text>
102
110
  )
@@ -89,6 +89,7 @@ function Item({children, onPress, ...props}: ItemProps) {
89
89
 
90
90
  return (
91
91
  <AnimatedPressable
92
+ testID="varia-floating-action-item"
92
93
  style={[
93
94
  animatedStyles,
94
95
  styles.itemButton,
@@ -150,15 +151,15 @@ function Root({
150
151
  variant,
151
152
  'color',
152
153
  )
153
- console.log('🚀 ~ iconColor:', iconColor)
154
-
155
154
  return (
156
155
  <View
156
+ testID="varia-floating-action-container"
157
157
  style={[
158
158
  styles.buttonContainer(top, bottom, left, right),
159
159
  FloatingActionStyles.buttonContainer(colorPalette),
160
160
  ]}>
161
161
  <AnimatedPressable
162
+ testID="varia-floating-action-button"
162
163
  onPress={() => (isExpanded.value = !isExpanded.value)}
163
164
  style={[
164
165
  plusIconStyle,
@@ -129,9 +129,11 @@ const Input = ({
129
129
 
130
130
  return (
131
131
  <View
132
+ testID="varia-input-container"
132
133
  style={styles.container(flex, direction, alignSelf, textAlignVertical)}>
133
134
  {IconRendered}
134
135
  <TextInput
136
+ testID="varia-input"
135
137
  editable={!disabled}
136
138
  style={[
137
139
  styles.input(
@@ -65,23 +65,11 @@ export const DrawerStyles = StyleSheet.create((theme, rt) => ({
65
65
  card: {
66
66
  boxShadow: 'none',
67
67
  borderRadius: theme.radii.lg,
68
- // marginHorizontal: theme.spacing[3],
69
68
  borderWidth: 2,
70
69
  borderColor: theme.colors.border.default,
71
- // height: rt.screen.height,
72
- // height: 'auto',
73
70
  alignSelf: 'auto',
74
71
  maxWidth: '90%',
75
72
  },
76
- new: {
77
- maxWidth: '80%',
78
- },
79
- iglooroom: {
80
- padding: 0,
81
- boxShadow: 'none',
82
- borderRadius: theme.radii.none,
83
- backgroundColor: 'transparent',
84
- },
85
73
  },
86
74
  },
87
75
  }),
@@ -73,6 +73,11 @@ export const FloatingActionStyles = StyleSheet.create(theme => ({
73
73
  color: theme.colors[colorPalette].text,
74
74
  },
75
75
  },
76
+ size: {
77
+ sm: {},
78
+ md: {},
79
+ lg: {},
80
+ },
76
81
  },
77
82
  }),
78
83
  item: (colorPalette: PalettesWithNestedKeys) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-varia",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "bin": {
5
5
  "varia": "bin/cli.js"
6
6
  },