@codeleap/mobile 5.0.14 → 5.1.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/dist/components/Calendar/index.d.ts +3 -10
- package/dist/components/Calendar/index.js +15 -26
- package/dist/components/Calendar/index.js.map +1 -1
- package/dist/components/Calendar/styles.d.ts +3 -0
- package/dist/components/Calendar/styles.js +2 -0
- package/dist/components/Calendar/styles.js.map +1 -0
- package/dist/components/Calendar/types.d.ts +7 -93
- package/dist/components/CalendarInput/index.d.ts +13 -0
- package/dist/components/CalendarInput/index.js +88 -0
- package/dist/components/CalendarInput/index.js.map +1 -0
- package/dist/components/CalendarInput/styles.d.ts +3 -0
- package/dist/components/CalendarInput/styles.js +2 -0
- package/dist/components/CalendarInput/styles.js.map +1 -0
- package/dist/components/CalendarInput/types.d.ts +24 -0
- package/dist/components/CalendarInput/types.js +2 -0
- package/dist/components/CalendarInput/types.js.map +1 -0
- package/dist/components/InputBase/index.d.ts +1 -0
- package/dist/components/InputBase/index.js +1 -0
- package/dist/components/InputBase/index.js.map +1 -1
- package/dist/components/InputBase/types.d.ts +2 -1
- package/dist/components/Tabs/Context.d.ts +11 -0
- package/dist/components/Tabs/Context.js +26 -0
- package/dist/components/Tabs/Context.js.map +1 -0
- package/dist/components/Tabs/Panel.d.ts +11 -0
- package/dist/components/Tabs/Panel.js +17 -0
- package/dist/components/Tabs/Panel.js.map +1 -0
- package/dist/components/Tabs/Tab.d.ts +10 -0
- package/dist/components/Tabs/Tab.js +31 -0
- package/dist/components/Tabs/Tab.js.map +1 -0
- package/dist/components/Tabs/TabList.d.ts +5 -0
- package/dist/components/Tabs/TabList.js +7 -0
- package/dist/components/Tabs/TabList.js.map +1 -0
- package/dist/components/Tabs/index.d.ts +35 -0
- package/dist/components/Tabs/index.js +36 -0
- package/dist/components/Tabs/index.js.map +1 -0
- package/dist/components/Tabs/styles.d.ts +4 -0
- package/dist/components/Tabs/styles.js +2 -0
- package/dist/components/Tabs/styles.js.map +1 -0
- package/dist/components/Tabs/types.d.ts +20 -0
- package/dist/components/Tabs/types.js +2 -0
- package/dist/components/Tabs/types.js.map +1 -0
- package/dist/components/TextInput/index.js +5 -5
- package/dist/components/TextInput/index.js.map +1 -1
- package/dist/components/components.d.ts +2 -0
- package/dist/components/components.js +2 -0
- package/dist/components/components.js.map +1 -1
- package/package.json +18 -18
- package/package.json.bak +2 -2
- package/src/components/Calendar/index.tsx +24 -39
- package/src/components/Calendar/styles.ts +5 -0
- package/src/components/Calendar/types.ts +11 -101
- package/src/components/CalendarInput/index.tsx +150 -0
- package/src/components/CalendarInput/styles.ts +7 -0
- package/src/components/CalendarInput/types.ts +29 -0
- package/src/components/InputBase/index.tsx +2 -0
- package/src/components/InputBase/types.ts +2 -1
- package/src/components/Tabs/Context.tsx +40 -0
- package/src/components/Tabs/Panel.tsx +31 -0
- package/src/components/Tabs/Tab.tsx +69 -0
- package/src/components/Tabs/TabList.tsx +19 -0
- package/src/components/Tabs/index.tsx +66 -0
- package/src/components/Tabs/styles.ts +11 -0
- package/src/components/Tabs/types.ts +27 -0
- package/src/components/TextInput/index.tsx +5 -3
- package/src/components/components.ts +3 -1
|
@@ -10,6 +10,8 @@ import RNAnimated, { FadeIn, FadeOut } from 'react-native-reanimated'
|
|
|
10
10
|
import { View as RNView } from 'react-native'
|
|
11
11
|
import { StyledComponentProps, StyledComponentWithProps } from '@codeleap/styles'
|
|
12
12
|
|
|
13
|
+
export { useInputBase } from './useInputBase'
|
|
14
|
+
|
|
13
15
|
export * from './styles'
|
|
14
16
|
export * from './utils'
|
|
15
17
|
export * from './types'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PropsOf, StylesOf } from '@codeleap/types'
|
|
2
2
|
import { InputBaseComposition } from './styles'
|
|
3
3
|
import { ActionIcon } from '../ActionIcon'
|
|
4
|
-
import { View } from 'react-native'
|
|
4
|
+
import { View, ViewProps } from 'react-native'
|
|
5
5
|
|
|
6
6
|
type ActionIconProps = PropsOf<typeof ActionIcon>
|
|
7
7
|
|
|
@@ -27,4 +27,5 @@ export type InputBaseProps = React.PropsWithChildren<{
|
|
|
27
27
|
hideErrorMessage?: boolean
|
|
28
28
|
hasValue?: boolean
|
|
29
29
|
ref?: React.Ref<View>
|
|
30
|
+
onLayout?: ViewProps['onLayout']
|
|
30
31
|
}>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createContext, useContext, useState } from 'react'
|
|
2
|
+
import { TabsContextProps, TabsStyles } from './types'
|
|
3
|
+
|
|
4
|
+
function useTabHandle(props: TabsContextProps & { styles: TabsStyles }) {
|
|
5
|
+
const {
|
|
6
|
+
defaultValue,
|
|
7
|
+
value,
|
|
8
|
+
onValueChange,
|
|
9
|
+
keepMounted,
|
|
10
|
+
styles
|
|
11
|
+
} = props
|
|
12
|
+
|
|
13
|
+
const [tabValue, setTabValue] = !onValueChange && !value
|
|
14
|
+
? useState<string>(defaultValue)
|
|
15
|
+
: [value ?? defaultValue, onValueChange]
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
value: tabValue,
|
|
19
|
+
setValue: setTabValue,
|
|
20
|
+
styles,
|
|
21
|
+
keepMounted,
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const Context = createContext({} as ReturnType<typeof useTabHandle>)
|
|
26
|
+
|
|
27
|
+
export function TabsProvider({ children, ...handleProps }: TabsContextProps & { styles: TabsStyles }) {
|
|
28
|
+
const handle = useTabHandle(handleProps)
|
|
29
|
+
return <Context.Provider value={handle}>{children}</Context.Provider>
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function useTabContext() {
|
|
33
|
+
const ctx = useContext(Context)
|
|
34
|
+
|
|
35
|
+
if (ctx === null) {
|
|
36
|
+
throw new Error('Tabs component was not found in the tree')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return ctx
|
|
40
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ReactNode } from 'react'
|
|
2
|
+
import { useTabContext } from './Context'
|
|
3
|
+
import { memoBy } from '@codeleap/utils'
|
|
4
|
+
import { TabPropsWithCtx } from './types'
|
|
5
|
+
import { View, ViewProps } from '../View'
|
|
6
|
+
import { ICSS } from '@codeleap/styles'
|
|
7
|
+
|
|
8
|
+
type PanelProps = Omit<ViewProps, 'style'> & {
|
|
9
|
+
value: string
|
|
10
|
+
children: ReactNode
|
|
11
|
+
style?: ICSS
|
|
12
|
+
keepMounted?: boolean
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const PanelMemoized = memoBy((props: TabPropsWithCtx<PanelProps>) => {
|
|
16
|
+
const { children } = props
|
|
17
|
+
|
|
18
|
+
return <>{children}</>
|
|
19
|
+
}, ['children', 'styles'])
|
|
20
|
+
|
|
21
|
+
export const Panel = ({ keepMounted: panelKeepMounted = true, ...props }: PanelProps) => {
|
|
22
|
+
const { value, styles, keepMounted } = useTabContext()
|
|
23
|
+
|
|
24
|
+
const active = value === props.value
|
|
25
|
+
|
|
26
|
+
if (!keepMounted && !active || !panelKeepMounted && !active) return null
|
|
27
|
+
|
|
28
|
+
return <View style={[styles?.panel, props?.style, { display: active ? 'flex' : 'none' }]}>
|
|
29
|
+
<PanelMemoized {...props} styles={styles} />
|
|
30
|
+
</View>
|
|
31
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { AppIcon } from '@codeleap/styles'
|
|
2
|
+
import { useTabContext } from './Context'
|
|
3
|
+
import { memoBy } from '@codeleap/utils'
|
|
4
|
+
import { TabPropsWithCtx } from './types'
|
|
5
|
+
import { Touchable } from '../Touchable'
|
|
6
|
+
import { Icon } from '../Icon'
|
|
7
|
+
import { Text } from '../Text'
|
|
8
|
+
|
|
9
|
+
type TabProps = {
|
|
10
|
+
value: string
|
|
11
|
+
text?: string
|
|
12
|
+
icon?: AppIcon
|
|
13
|
+
disabled?: boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const TabMemoized = memoBy((props: TabPropsWithCtx<TabProps>) => {
|
|
17
|
+
const {
|
|
18
|
+
value,
|
|
19
|
+
text,
|
|
20
|
+
icon,
|
|
21
|
+
active,
|
|
22
|
+
setValue,
|
|
23
|
+
styles,
|
|
24
|
+
disabled
|
|
25
|
+
} = props
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<Touchable
|
|
29
|
+
style={[
|
|
30
|
+
styles?.tabWrapper,
|
|
31
|
+
active && styles?.['tabWrapper:active'],
|
|
32
|
+
disabled && styles?.['tabWrapper:disabled']
|
|
33
|
+
]}
|
|
34
|
+
onPress={() => setValue(value)}
|
|
35
|
+
debugName={`tabs:${value}`}
|
|
36
|
+
>
|
|
37
|
+
<Icon
|
|
38
|
+
style={[
|
|
39
|
+
styles?.tabIcon,
|
|
40
|
+
active && styles?.['tabIcon:active'],
|
|
41
|
+
disabled && styles?.['tabIcon:disabled']
|
|
42
|
+
]}
|
|
43
|
+
name={icon}
|
|
44
|
+
/>
|
|
45
|
+
|
|
46
|
+
<Text
|
|
47
|
+
style={[
|
|
48
|
+
styles?.tabText,
|
|
49
|
+
active && styles?.['tabText:active'],
|
|
50
|
+
disabled && styles?.['tabText:disabled']
|
|
51
|
+
]}
|
|
52
|
+
text={text}
|
|
53
|
+
/>
|
|
54
|
+
</Touchable>
|
|
55
|
+
)
|
|
56
|
+
}, ['icon', 'text', 'active', 'styles', 'disabled'])
|
|
57
|
+
|
|
58
|
+
export const Tab = (props: TabProps) => {
|
|
59
|
+
const { value, setValue, styles } = useTabContext()
|
|
60
|
+
|
|
61
|
+
const active = value === props.value
|
|
62
|
+
|
|
63
|
+
return <TabMemoized
|
|
64
|
+
{...props}
|
|
65
|
+
active={active}
|
|
66
|
+
setValue={setValue}
|
|
67
|
+
styles={styles}
|
|
68
|
+
/>
|
|
69
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ScrollView, ScrollViewProps } from 'react-native'
|
|
2
|
+
import { useTabContext } from './Context'
|
|
3
|
+
|
|
4
|
+
type TabListProps = ScrollViewProps
|
|
5
|
+
|
|
6
|
+
export const TabList = (props: TabListProps) => {
|
|
7
|
+
const { styles } = useTabContext()
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<ScrollView
|
|
11
|
+
horizontal
|
|
12
|
+
showsHorizontalScrollIndicator={false}
|
|
13
|
+
showsVerticalScrollIndicator={false}
|
|
14
|
+
{...props}
|
|
15
|
+
style={styles?.tabList}
|
|
16
|
+
contentContainerStyle={styles?.tabListContainer}
|
|
17
|
+
/>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { AnyRecord } from '@codeleap/types'
|
|
2
|
+
import { View } from '../View'
|
|
3
|
+
import { TabsProvider } from './Context'
|
|
4
|
+
import { Panel } from './Panel'
|
|
5
|
+
import { Tab } from './Tab'
|
|
6
|
+
import { TabList } from './TabList'
|
|
7
|
+
import { TabsProps } from './types'
|
|
8
|
+
import { IJSX, StyledComponentProps } from '@codeleap/styles'
|
|
9
|
+
import { MobileStyleRegistry } from '../../Registry'
|
|
10
|
+
import { useStylesFor } from '../../hooks'
|
|
11
|
+
|
|
12
|
+
export { useTabContext } from './Context'
|
|
13
|
+
|
|
14
|
+
export * from './types'
|
|
15
|
+
export * from './styles'
|
|
16
|
+
|
|
17
|
+
export const Tabs = (props: TabsProps) => {
|
|
18
|
+
const {
|
|
19
|
+
style,
|
|
20
|
+
value,
|
|
21
|
+
onValueChange,
|
|
22
|
+
defaultValue,
|
|
23
|
+
keepMounted,
|
|
24
|
+
children,
|
|
25
|
+
...rest
|
|
26
|
+
} = {
|
|
27
|
+
...Tabs.defaultProps,
|
|
28
|
+
...props,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const styles = useStylesFor(Tabs.styleRegistryName, style)
|
|
32
|
+
|
|
33
|
+
return <View {...rest} style={styles?.wrapper}>
|
|
34
|
+
<TabsProvider
|
|
35
|
+
value={value}
|
|
36
|
+
onValueChange={onValueChange}
|
|
37
|
+
defaultValue={defaultValue}
|
|
38
|
+
styles={styles}
|
|
39
|
+
keepMounted={keepMounted}
|
|
40
|
+
>
|
|
41
|
+
{children}
|
|
42
|
+
</TabsProvider>
|
|
43
|
+
</View>
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
Tabs.Tab = Tab
|
|
47
|
+
Tabs.TabList = TabList
|
|
48
|
+
Tabs.Panel = Panel
|
|
49
|
+
|
|
50
|
+
Tabs.styleRegistryName = 'Tabs'
|
|
51
|
+
Tabs.elements = ['wrapper', 'tab', 'panel']
|
|
52
|
+
Tabs.rootElement = 'wrapper'
|
|
53
|
+
|
|
54
|
+
Tabs.withVariantTypes = <S extends AnyRecord>(styles: S) => {
|
|
55
|
+
return Tabs as ((props: StyledComponentProps<TabsProps, typeof styles>) => IJSX) & {
|
|
56
|
+
Tab: typeof Tab,
|
|
57
|
+
TabList: typeof TabList,
|
|
58
|
+
Panel: typeof Panel,
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
Tabs.defaultProps = {
|
|
63
|
+
keepMounted: true,
|
|
64
|
+
} as Partial<TabsProps>
|
|
65
|
+
|
|
66
|
+
MobileStyleRegistry.registerComponent(Tabs)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type TabStates = 'active' | 'disabled'
|
|
2
|
+
|
|
3
|
+
type TabComposition = 'wrapper' | 'icon' | 'text'
|
|
4
|
+
|
|
5
|
+
export type TabsComposition =
|
|
6
|
+
'wrapper' |
|
|
7
|
+
'panel' |
|
|
8
|
+
'tabList' |
|
|
9
|
+
'tabListContainer' |
|
|
10
|
+
`tab${Capitalize<TabComposition>}` |
|
|
11
|
+
`tab${Capitalize<TabComposition>}:${TabStates}`
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ICSS, StyledProp } from '@codeleap/styles'
|
|
2
|
+
import { ReactNode } from 'react'
|
|
3
|
+
import { TabsComposition } from './styles'
|
|
4
|
+
import { ViewProps } from '../View'
|
|
5
|
+
|
|
6
|
+
export type TabsContextProps = {
|
|
7
|
+
defaultValue: string
|
|
8
|
+
value?: string
|
|
9
|
+
onValueChange?: (newValue: string) => void
|
|
10
|
+
children?: ReactNode
|
|
11
|
+
keepMounted?: boolean
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type TabsProps =
|
|
15
|
+
TabsContextProps &
|
|
16
|
+
Omit<ViewProps, 'style'> &
|
|
17
|
+
{
|
|
18
|
+
style?: StyledProp<TabsComposition>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type TabsStyles = Record<TabsComposition, ICSS>
|
|
22
|
+
|
|
23
|
+
export type TabPropsWithCtx<P> = P & {
|
|
24
|
+
active?: boolean
|
|
25
|
+
setValue?: (value: string) => void
|
|
26
|
+
styles: TabsStyles
|
|
27
|
+
}
|
|
@@ -41,6 +41,7 @@ export const TextInput = forwardRef<NativeTextInput, TextInputProps>((props, inp
|
|
|
41
41
|
selectionStart,
|
|
42
42
|
forceError,
|
|
43
43
|
multiline,
|
|
44
|
+
onLayout,
|
|
44
45
|
...textInputProps
|
|
45
46
|
} = others
|
|
46
47
|
|
|
@@ -73,7 +74,7 @@ export const TextInput = forwardRef<NativeTextInput, TextInputProps>((props, inp
|
|
|
73
74
|
const partialStyles = useInputBasePartialStyles(styles, ['placeholder', 'selection'], {
|
|
74
75
|
disabled: isDisabled,
|
|
75
76
|
error: !!hasError,
|
|
76
|
-
focus: isFocused,
|
|
77
|
+
focus: isFocused || textInputProps?.focused,
|
|
77
78
|
})
|
|
78
79
|
|
|
79
80
|
const visibilityToggleProps = visibilityToggle ? {
|
|
@@ -102,6 +103,7 @@ export const TextInput = forwardRef<NativeTextInput, TextInputProps>((props, inp
|
|
|
102
103
|
|
|
103
104
|
return <InputBase
|
|
104
105
|
{...inputBaseProps}
|
|
106
|
+
onLayout={onLayout}
|
|
105
107
|
ref={wrapperRef}
|
|
106
108
|
innerWrapper={isPressable ? Touchable : undefined}
|
|
107
109
|
debugName={debugName}
|
|
@@ -121,7 +123,7 @@ export const TextInput = forwardRef<NativeTextInput, TextInputProps>((props, inp
|
|
|
121
123
|
dismissKeyboard: false,
|
|
122
124
|
}}
|
|
123
125
|
rightIcon={rightIcon}
|
|
124
|
-
focused={isFocused}
|
|
126
|
+
focused={isFocused || textInputProps?.focused}
|
|
125
127
|
hasValue={hasValue}
|
|
126
128
|
>
|
|
127
129
|
<InputElement
|
|
@@ -142,7 +144,7 @@ export const TextInput = forwardRef<NativeTextInput, TextInputProps>((props, inp
|
|
|
142
144
|
style={[
|
|
143
145
|
styles?.input,
|
|
144
146
|
multiline && styles['input:multiline'],
|
|
145
|
-
isFocused && styles['input:focused'],
|
|
147
|
+
(isFocused || textInputProps?.focused) && styles['input:focused'],
|
|
146
148
|
hasError && styles['input:error'],
|
|
147
149
|
isDisabled && styles['input:disabled'],
|
|
148
150
|
hasMultipleLines && styles['input:hasMultipleLines'],
|
|
@@ -38,4 +38,6 @@ export * from './SearchInput'
|
|
|
38
38
|
export * from './PaginationIndicator'
|
|
39
39
|
export * from './PlacesAutocomplete'
|
|
40
40
|
export * from './SortablePhotos'
|
|
41
|
-
export * from './SectionFilters'
|
|
41
|
+
export * from './SectionFilters'
|
|
42
|
+
export * from './Tabs'
|
|
43
|
+
export * from './CalendarInput'
|