react-native-varia 0.2.2 → 0.2.4

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.
Files changed (40) hide show
  1. package/bin/cli.js +316 -139
  2. package/lib/components/Accordion.tsx +113 -0
  3. package/lib/components/Button.tsx +19 -8
  4. package/lib/components/CircleProgress.tsx +46 -28
  5. package/lib/components/Divider.tsx +18 -15
  6. package/lib/components/Drawer.tsx +496 -0
  7. package/lib/components/Field.tsx +24 -39
  8. package/lib/components/GradientBackground.tsx +25 -7
  9. package/lib/components/GradientText.tsx +38 -11
  10. package/lib/components/IconWrapper.tsx +20 -14
  11. package/lib/components/Input.tsx +106 -25
  12. package/lib/components/NumberInput.tsx +88 -19
  13. package/lib/components/OldSlider.tsx +327 -0
  14. package/lib/components/RadioGroup.tsx +55 -17
  15. package/lib/components/ReText.tsx +1 -1
  16. package/lib/components/Select.tsx +58 -22
  17. package/lib/components/Slider.tsx +176 -115
  18. package/lib/components/Slideshow.tsx +68 -69
  19. package/lib/components/SlidingDrawer.tsx +72 -29
  20. package/lib/components/Spinner.tsx +6 -2
  21. package/lib/components/Toast.tsx +89 -0
  22. package/lib/components/context/Field.tsx +27 -0
  23. package/lib/icons/Minus.tsx +24 -0
  24. package/lib/icons/Plus.tsx +23 -0
  25. package/lib/theme/Button.recipe.tsx +11 -1
  26. package/lib/theme/CircleProgress.recipe.tsx +3 -3
  27. package/lib/theme/Field.recipe.tsx +17 -2
  28. package/lib/theme/Input.recipe.tsx +12 -3
  29. package/lib/theme/NumberInput.recipe.tsx +9 -4
  30. package/lib/theme/RadioGroup.recipe.tsx +7 -1
  31. package/lib/theme/Select.recipe.tsx +7 -7
  32. package/lib/theme/Slider.recipe.tsx +366 -22
  33. package/lib/theme/Slideshow.recipe.tsx +1 -1
  34. package/lib/theme/SlidingDrawer.recipe.tsx +58 -4
  35. package/lib/theme/Toast.recipe.tsx +71 -0
  36. package/package.json +3 -2
  37. package/lib/components/NewSelect.tsx +0 -202
  38. package/lib/components/index.tsx +0 -83
  39. package/lib/components/layoutTest.tsx +0 -74
  40. package/lib/theme/Button.recipe-old.tsx +0 -67
@@ -1,202 +0,0 @@
1
- import React, {createContext, useContext, useState, ReactNode} from 'react'
2
- import {
3
- View,
4
- // Text,
5
- TouchableOpacity,
6
- ScrollView,
7
- TouchableWithoutFeedback,
8
- StyleSheet,
9
- } from 'react-native'
10
- import Text from './Text'
11
- import {StyleSheet as UniStyleSheet} from 'react-native-unistyles'
12
- import {SelectStyles, SelectDefaultVariants} from '../theme/Select.recipe'
13
- import {PalettesWithNestedKeys} from '../style/varia/types'
14
- import {UnistylesVariants} from 'react-native-unistyles'
15
- import {Portal} from '@gorhom/portal'
16
-
17
- type SelectVariants = UnistylesVariants<typeof SelectStyles>
18
-
19
- interface Option {
20
- label: string
21
- value: string
22
- }
23
-
24
- interface SelectContextType {
25
- value: string
26
- setValue: (val: string) => void
27
- isOpen: boolean
28
- setIsOpen: (open: boolean) => void
29
- options: Option[]
30
- colorPalette: PalettesWithNestedKeys
31
- variant: SelectVariants['variant']
32
- size: SelectVariants['size']
33
- }
34
-
35
- const SelectContext = createContext<SelectContextType | undefined>(undefined)
36
-
37
- const useSelect = () => {
38
- const context = useContext(SelectContext)
39
- if (!context)
40
- throw new Error('Select subcomponent must be used within Select.Root')
41
- return context
42
- }
43
-
44
- type RootProps = SelectVariants & {
45
- options: Option[]
46
- value?: string
47
- onChange?: (val: string) => void
48
- defaultValue?: string
49
- placeholder?: string
50
- colorPalette?: PalettesWithNestedKeys
51
- flex?: number
52
- children: ReactNode
53
- portalHostName?: string
54
- }
55
-
56
- export const Select = {
57
- Root: ({
58
- options,
59
- value: propValue,
60
- onChange: propOnChange,
61
- defaultValue = '',
62
- placeholder = 'Selecciona una opción',
63
- variant = SelectDefaultVariants.variant,
64
- size = SelectDefaultVariants.size,
65
- colorPalette = 'accent',
66
- flex = 1,
67
- children,
68
- portalHostName = 'select',
69
- }: RootProps) => {
70
- SelectStyles.useVariants({variant, size})
71
-
72
- const [internalValue, setInternalValue] = useState<string>(defaultValue)
73
- const [isOpen, setIsOpen] = useState(false)
74
- const isControlled = propValue !== undefined && propOnChange !== undefined
75
- const value = isControlled ? propValue! : internalValue
76
-
77
- const setValue = (val: string) => {
78
- if (isControlled) propOnChange!(val)
79
- else setInternalValue(val)
80
- setIsOpen(false)
81
- }
82
-
83
- return (
84
- <SelectContext.Provider
85
- value={{
86
- value,
87
- setValue,
88
- isOpen,
89
- setIsOpen,
90
- options,
91
- colorPalette,
92
- variant,
93
- size,
94
- }}>
95
- <View style={[styles.container(flex)]}>{children}</View>
96
-
97
- {isOpen && (
98
- <Portal hostName={portalHostName}>
99
- <View style={styles.modalOverlay}>
100
- <TouchableWithoutFeedback onPress={() => setIsOpen(false)}>
101
- <View style={styles.backdrop} />
102
- </TouchableWithoutFeedback>
103
- <View
104
- style={[
105
- styles.modalContent,
106
- SelectStyles.ModalContainer(colorPalette),
107
- ]}>
108
- <ScrollView
109
- contentContainerStyle={SelectStyles.itemsContainer(
110
- colorPalette,
111
- )}>
112
- {options.map(opt => (
113
- <TouchableOpacity
114
- key={opt.value}
115
- onPress={() => setValue(opt.value)}>
116
- <View
117
- style={[
118
- styles.item,
119
- SelectStyles.item(colorPalette, value === opt.value),
120
- ]}>
121
- <Text
122
- style={SelectStyles.itemText(
123
- colorPalette,
124
- value === opt.value,
125
- )}>
126
- {opt.label}
127
- </Text>
128
- </View>
129
- </TouchableOpacity>
130
- ))}
131
- </ScrollView>
132
- </View>
133
- </View>
134
- </Portal>
135
- )}
136
- </SelectContext.Provider>
137
- )
138
- },
139
-
140
- Trigger: ({placeholder = 'Selecciona una opción'}) => {
141
- const {
142
- variant,
143
- size,
144
- value,
145
- setIsOpen,
146
- options,
147
- colorPalette = 'accent',
148
- } = useSelect()
149
- SelectStyles.useVariants({variant, size})
150
- const selectedOption = options.find(opt => opt.value === value)
151
-
152
- return (
153
- <TouchableWithoutFeedback onPress={() => setIsOpen(true)}>
154
- <View style={[styles.input, SelectStyles.input(colorPalette)]}>
155
- <Text style={SelectStyles.valueText(colorPalette, !!selectedOption)}>
156
- {selectedOption ? selectedOption.label : placeholder}
157
- </Text>
158
- </View>
159
- </TouchableWithoutFeedback>
160
- )
161
- },
162
- }
163
-
164
- const styles = UniStyleSheet.create({
165
- container: (flex: number) => ({
166
- flexGrow: flex,
167
- flexDirection: 'row',
168
- justifyContent: 'center',
169
- }),
170
- input: {
171
- flex: 1,
172
- flexDirection: 'row',
173
- alignItems: 'center',
174
- justifyContent: 'center',
175
- },
176
- item: {
177
- paddingVertical: 2,
178
- paddingHorizontal: 8,
179
- alignItems: 'center',
180
- flexDirection: 'row',
181
- },
182
- modalOverlay: {
183
- position: 'absolute',
184
- top: 0,
185
- left: 0,
186
- right: 0,
187
- bottom: 0,
188
- justifyContent: 'center',
189
- alignItems: 'center',
190
- },
191
- backdrop: {
192
- ...StyleSheet.absoluteFillObject,
193
- backgroundColor: 'rgba(0,0,0,0.3)',
194
- },
195
- modalContent: {
196
- maxHeight: '50%',
197
- width: '80%',
198
- backgroundColor: 'white',
199
- borderRadius: 8,
200
- overflow: 'hidden',
201
- },
202
- })
@@ -1,83 +0,0 @@
1
- import { StyleSheet, UnistylesVariants } from "react-native-unistyles"
2
- import ButtonRaw from "./Button-old"
3
- import ButtonStyles from "../theme/Button.recipe-old"
4
-
5
- // const ButtonStyles = StyleSheet.create(theme => ({
6
- // container: {
7
- // variants: {
8
- // colorPalette: {
9
- // primary: {
10
- // backgroundColor: 'tomato',
11
- // },
12
- // secondary: {
13
- // backgroundColor: theme.colors.foreground2,
14
- // }
15
- // },
16
- // size: {
17
- // sm: {
18
- // height: 32,
19
- // maxHeight: 32,
20
- // padding: 6,
21
- // },
22
- // md: {
23
- // maxHeight: 48,
24
- // height: 48,
25
- // padding: 8,
26
- // },
27
- // lg: {
28
- // maxHeight: 64,
29
- // height: 64,
30
- // padding: 12,
31
- // },
32
- // xl: {
33
- // maxHeight: 80,
34
- // height: 80,
35
- // padding: 16,
36
- // }
37
- // }
38
- // },
39
- // },
40
- // text: {
41
- // variants: {
42
- // colorPalette: {
43
- // primary: {
44
- // color: 'white',
45
- // },
46
- // secondary: {
47
- // color: theme.colors.categoryAquamarine,
48
- // }
49
- // },
50
- // size: {
51
- // sm: {
52
- // fontSize: 24,
53
- // },
54
- // md: {
55
- // fontSize: 28,
56
- // },
57
- // lg: {
58
- // fontSize: 32,
59
- // },
60
- // xl: {
61
- // fontSize: 36,
62
- // }
63
- // }
64
- // }
65
- // }
66
- // }))
67
-
68
- type ButtonVariants = UnistylesVariants<typeof ButtonStyles>;
69
-
70
- type ButtonProps = ButtonVariants & {
71
- onPress: () => void;
72
- };
73
-
74
- export const Button = ({ size, colorPalette, ...props }: ButtonProps) => {
75
- return (
76
- <ButtonRaw
77
- buttonStyles={ButtonStyles}
78
- size={size}
79
- colorPalette={colorPalette}
80
- {...props}
81
- />
82
- );
83
- };
@@ -1,74 +0,0 @@
1
- import {VStack, HStack} from '../patterns'
2
- import Text from './Text'
3
-
4
- const LayoutTest = () => {
5
- return (
6
- <VStack
7
- // flex={1}
8
- style={{
9
- flexGrow: 1,
10
- // flexShrink: 1,
11
- alignSelf: 'stretch',
12
- alignItems: 'stretch',
13
- backgroundColor: 'red',
14
- gap: 10,
15
- }}>
16
- <VStack
17
- style={{
18
- // flexGrow: 1,
19
- // flexShrink: 1,
20
- // alignSelf: 'stretch',
21
- backgroundColor: 'pink',
22
- }}>
23
- <Component />
24
- <Component />
25
- </VStack>
26
- <VStack
27
- style={{
28
- borderWidth: 5,
29
- borderColor: 'yellow',
30
- // flexGrow: 1,
31
- // flexShrink: 1,
32
- // alignSelf: 'stretch',
33
- backgroundColor: 'pink',
34
- }}>
35
- <Component />
36
- <Component />
37
- </VStack>
38
- </VStack>
39
- )
40
- }
41
-
42
- const Component = () => {
43
- return (
44
- <VStack
45
- style={{
46
- borderWidth: 1,
47
- borderColor: 'black',
48
- // flexGrow: 1,
49
- alignSelf: 'stretch',
50
- backgroundColor: 'blue',
51
- // flexShrink: 0,
52
- // alignSelf: 'flex-start',
53
- }}>
54
- <Text>hola</Text>
55
- <HStack
56
- style={{
57
- flexShrink: 0,
58
- flexGrow: 1,
59
- backgroundColor: 'green',
60
- minHeight: 50,
61
- maxHeight: 50,
62
- width: '100%',
63
- // opacity: 0.5,
64
- }}
65
- />
66
- <VStack>
67
- <Text>hola</Text>
68
- <Text>hola</Text>
69
- </VStack>
70
- </VStack>
71
- )
72
- }
73
-
74
- export default LayoutTest
@@ -1,67 +0,0 @@
1
- import { StyleSheet } from "react-native-unistyles"
2
-
3
- const ButtonStyles = StyleSheet.create(theme => ({
4
- container: {
5
- variants: {
6
- colorPalette: {
7
- primary: {
8
- backgroundColor: 'tomato',
9
- },
10
- secondary: {
11
- backgroundColor: theme.colors.foreground,
12
- }
13
- },
14
- size: {
15
- sm: {
16
- height: 32,
17
- maxHeight: 32,
18
- padding: 6,
19
- },
20
- md: {
21
- maxHeight: 48,
22
- height: 48,
23
- padding: 8,
24
- },
25
- lg: {
26
- maxHeight: 64,
27
- height: 64,
28
- padding: 12,
29
- },
30
- xl: {
31
- maxHeight: 80,
32
- height: 80,
33
- padding: 16,
34
- }
35
- }
36
- },
37
- },
38
- text: {
39
- variants: {
40
- colorPalette: {
41
- primary: {
42
- color: 'white',
43
- },
44
- secondary: {
45
- color: theme.colors.categoryAquamarine,
46
- }
47
- },
48
- size: {
49
- sm: {
50
- fontSize: 24,
51
- },
52
- md: {
53
- fontSize: 28,
54
- },
55
- lg: {
56
- fontSize: 32,
57
- },
58
- xl: {
59
- fontSize: 36,
60
- }
61
- }
62
- }
63
- }
64
- }))
65
-
66
-
67
- export default ButtonStyles