@codeleap/mobile 3.24.3 → 4.0.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/package.json +6 -4
- package/src/Registry.ts +52 -0
- package/src/components/ActionIcon/index.tsx +55 -37
- package/src/components/ActionIcon/styles.ts +2 -4
- package/src/components/ActionIcon/types.ts +15 -0
- package/src/components/ActivityIndicator/index.tsx +42 -64
- package/src/components/ActivityIndicator/styles.ts +1 -10
- package/src/components/ActivityIndicator/types.ts +9 -0
- package/src/components/Autocomplete/index.tsx +46 -54
- package/src/components/Autocomplete/styles.ts +2 -5
- package/src/components/Autocomplete/types.ts +13 -23
- package/src/components/Avatar/index.tsx +59 -71
- package/src/components/Avatar/styles.ts +1 -9
- package/src/components/Avatar/types.ts +23 -0
- package/src/components/AvatarGroup/index.tsx +30 -44
- package/src/components/AvatarGroup/styles.ts +0 -6
- package/src/components/AvatarGroup/types.ts +10 -0
- package/src/components/Backdrop/index.tsx +51 -34
- package/src/components/Backdrop/styles.ts +5 -10
- package/src/components/Backdrop/types.ts +14 -0
- package/src/components/Badge/index.tsx +36 -62
- package/src/components/Badge/styles.ts +3 -11
- package/src/components/Badge/types.ts +27 -0
- package/src/components/Button/index.tsx +55 -82
- package/src/components/Button/styles.ts +13 -14
- package/src/components/Button/types.ts +20 -0
- package/src/components/Calendar/index.tsx +35 -29
- package/src/components/Checkbox/index.tsx +43 -64
- package/src/components/Checkbox/styles.ts +1 -6
- package/src/components/Checkbox/types.ts +13 -0
- package/src/components/DatePickerModal/index.tsx +50 -65
- package/src/components/DatePickerModal/styles.ts +9 -10
- package/src/components/DatePickerModal/types.ts +36 -54
- package/src/components/EmptyPlaceholder/index.tsx +40 -63
- package/src/components/EmptyPlaceholder/styles.ts +0 -5
- package/src/components/EmptyPlaceholder/types.ts +21 -0
- package/src/components/FileInput/index.tsx +11 -49
- package/src/components/FileInput/types.ts +27 -0
- package/src/components/Grid/index.tsx +84 -116
- package/src/components/Grid/styles.ts +0 -5
- package/src/components/Grid/types.ts +20 -0
- package/src/components/Icon/index.tsx +44 -79
- package/src/components/Icon/styles.ts +0 -6
- package/src/components/Icon/types.ts +15 -0
- package/src/components/Image/index.tsx +58 -78
- package/src/components/Image/styles.ts +1 -6
- package/src/components/Image/types.ts +18 -0
- package/src/components/ImageView/Spotlight.tsx +1 -4
- package/src/components/ImageView/component.tsx +1 -2
- package/src/components/InputBase/index.tsx +33 -24
- package/src/components/InputBase/styles.ts +66 -75
- package/src/components/InputBase/types.ts +3 -4
- package/src/components/InputBase/utils.ts +6 -4
- package/src/components/List/index.tsx +99 -151
- package/src/components/List/styles.ts +0 -6
- package/src/components/List/types.ts +41 -0
- package/src/components/LoadingOverlay/index.tsx +42 -29
- package/src/components/LoadingOverlay/styles.ts +7 -7
- package/src/components/LoadingOverlay/types.ts +9 -0
- package/src/components/Modal/index.tsx +80 -127
- package/src/components/Modal/styles.ts +0 -8
- package/src/components/Modal/types.ts +41 -0
- package/src/components/Navigation/Navigation.tsx +1 -0
- package/src/components/Navigation/types.ts +2 -9
- package/src/components/NumberIncrement/index.tsx +50 -60
- package/src/components/NumberIncrement/styles.ts +0 -5
- package/src/components/NumberIncrement/types.ts +32 -39
- package/src/components/Pager/index.tsx +42 -94
- package/src/components/Pager/styles.ts +1 -13
- package/src/components/Pager/types.ts +37 -0
- package/src/components/PaginationIndicator/index.tsx +51 -0
- package/src/components/PaginationIndicator/styles.ts +3 -0
- package/src/components/PaginationIndicator/types.ts +10 -0
- package/src/components/RadioInput/index.tsx +32 -57
- package/src/components/RadioInput/styles.ts +5 -7
- package/src/components/RadioInput/types.ts +31 -0
- package/src/components/RefreshControl/index.tsx +39 -19
- package/src/components/RefreshControl/styles.ts +1 -6
- package/src/components/RefreshControl/types.ts +9 -0
- package/src/components/Scroll/index.tsx +89 -105
- package/src/components/Scroll/styles.ts +0 -5
- package/src/components/Scroll/types.ts +21 -0
- package/src/components/SearchInput/index.tsx +90 -0
- package/src/components/Sections/index.tsx +111 -161
- package/src/components/Sections/styles.ts +0 -5
- package/src/components/Sections/types.ts +39 -0
- package/src/components/SegmentedControl/Option.tsx +46 -31
- package/src/components/SegmentedControl/index.tsx +86 -121
- package/src/components/SegmentedControl/styles.ts +15 -22
- package/src/components/SegmentedControl/types.ts +31 -0
- package/src/components/Select/index.tsx +71 -82
- package/src/components/Select/styles.ts +3 -5
- package/src/components/Select/types.ts +20 -25
- package/src/components/Slider/index.tsx +58 -43
- package/src/components/Slider/styles.ts +15 -6
- package/src/components/Slider/types.ts +9 -14
- package/src/components/Switch/index.tsx +43 -56
- package/src/components/Switch/styles.ts +1 -7
- package/src/components/Switch/types.ts +12 -0
- package/src/components/Text/index.tsx +56 -52
- package/src/components/Text/styles.ts +1 -7
- package/src/components/Text/types.ts +18 -0
- package/src/components/TextInput/index.tsx +49 -162
- package/src/components/TextInput/styles.ts +2 -8
- package/src/components/TextInput/types.ts +23 -0
- package/src/components/Touchable/index.tsx +44 -87
- package/src/components/Touchable/styles.ts +0 -9
- package/src/components/Touchable/types.ts +27 -0
- package/src/components/View/index.tsx +23 -92
- package/src/components/View/styles.ts +0 -6
- package/src/components/View/types.ts +13 -0
- package/src/components/components.ts +2 -6
- package/src/hooks/index.ts +13 -0
- package/src/index.ts +2 -0
- package/src/modules/PressableRipple/type.ts +1 -0
- package/src/utils/KeyboardAware/context.tsx +0 -2
- package/src/utils/KeyboardAware/keyboardHooks.ts +1 -2
- package/src/utils/ModalManager/components.tsx +1 -30
- package/src/utils/ModalManager/context.tsx +4 -4
- package/src/utils/ModalManager/index.ts +1 -4
- package/src/utils/hooks.ts +12 -1
- package/src/components/Calendar/style.ts +0 -6
- package/src/components/ContentView/index.tsx +0 -63
- package/src/components/ContentView/styles.ts +0 -8
- package/src/components/Drawer/index.tsx +0 -28
- package/src/components/Drawer/styles.ts +0 -8
- package/src/components/FileInput/styles.ts +0 -8
- package/src/components/InputLabel/index.tsx +0 -38
- package/src/components/InputLabel/styles.ts +0 -7
- package/src/components/List/PaginationIndicator.tsx +0 -54
- package/src/components/defaultStyles.ts +0 -77
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LoadingOverlayProps } from '../LoadingOverlay'
|
|
2
|
+
import FastImage, { Source } from 'react-native-fast-image'
|
|
3
|
+
import { ImageProps as RNImageProps } from 'react-native'
|
|
4
|
+
import { ImageComposition } from './styles'
|
|
5
|
+
import { StyledProp } from '@codeleap/styles'
|
|
6
|
+
import { FormTypes } from '@codeleap/common'
|
|
7
|
+
|
|
8
|
+
export type ImageProps =
|
|
9
|
+
Omit<RNImageProps, 'source' | 'style'> &
|
|
10
|
+
{
|
|
11
|
+
fast?: boolean
|
|
12
|
+
style?: StyledProp<ImageComposition>
|
|
13
|
+
source: Source | FormTypes.AnyFile
|
|
14
|
+
resizeMode?: keyof typeof FastImage.resizeMode
|
|
15
|
+
spotlight?: string
|
|
16
|
+
maintainAspectRatio?: boolean
|
|
17
|
+
withLoadingOverlay?: boolean | ((props: LoadingOverlayProps) => JSX.Element)
|
|
18
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { useContext, useState } from 'react'
|
|
2
2
|
import { deepEqual, onUpdate, ReactState, TypeGuards, usePrevious, useUnmount } from '@codeleap/common'
|
|
3
|
-
|
|
4
3
|
import uuid from 'react-native-uuid'
|
|
5
4
|
import { ImageView, ImageViewProps } from './component'
|
|
6
5
|
import { ImageProps } from '../Image'
|
|
@@ -166,9 +165,7 @@ export type SpotlightProps = {
|
|
|
166
165
|
} & ImageViewProps
|
|
167
166
|
|
|
168
167
|
const DefaultFooterComponent: SpootlightFooterComponent = ({ imageIndex, imagesLength }) => (
|
|
169
|
-
<View
|
|
170
|
-
<Text text={imageIndex + 1 + '/' + imagesLength} />
|
|
171
|
-
</View>
|
|
168
|
+
<View><Text text={imageIndex + 1 + '/' + imagesLength} /></View>
|
|
172
169
|
)
|
|
173
170
|
|
|
174
171
|
export const Spotlight = (props: SpotlightProps) => {
|
|
@@ -16,11 +16,12 @@ export const InputBaseDefaultOrder: InputBaseProps['order'] = [
|
|
|
16
16
|
'innerWrapper',
|
|
17
17
|
'error',
|
|
18
18
|
]
|
|
19
|
+
|
|
19
20
|
const KeyPassthrough = (props: React.PropsWithChildren<any>) => {
|
|
20
21
|
return <>{props.children}</>
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
export const InputBase =
|
|
24
|
+
export const InputBase = (props: InputBaseProps) => {
|
|
24
25
|
const {
|
|
25
26
|
children,
|
|
26
27
|
error = null,
|
|
@@ -28,69 +29,67 @@ export const InputBase = React.forwardRef<any, InputBaseProps>((props, ref) => {
|
|
|
28
29
|
description = null,
|
|
29
30
|
leftIcon = null,
|
|
30
31
|
rightIcon = null,
|
|
31
|
-
|
|
32
|
-
wrapper,
|
|
32
|
+
wrapper: WrapperComponent,
|
|
33
33
|
debugName,
|
|
34
|
-
innerWrapper,
|
|
34
|
+
innerWrapper: InnerWrapperComponent,
|
|
35
35
|
focused,
|
|
36
36
|
innerWrapperProps = {},
|
|
37
37
|
wrapperProps = {},
|
|
38
|
-
disabled
|
|
38
|
+
disabled,
|
|
39
39
|
order = InputBaseDefaultOrder,
|
|
40
40
|
style,
|
|
41
|
-
labelAsRow
|
|
42
|
-
hideErrorMessage
|
|
41
|
+
labelAsRow,
|
|
42
|
+
hideErrorMessage,
|
|
43
43
|
...otherProps
|
|
44
|
-
} =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
} = {
|
|
45
|
+
...InputBase.defaultProps,
|
|
46
|
+
...props,
|
|
47
|
+
}
|
|
48
48
|
|
|
49
|
-
const
|
|
49
|
+
const styles = useInputBaseStyles(props)
|
|
50
50
|
|
|
51
51
|
const _leftIcon = getRenderedComponent<Partial<ActionIconProps>>(leftIcon, ActionIcon, {
|
|
52
52
|
// @ts-ignore
|
|
53
|
-
|
|
53
|
+
style: styles.leftIconStyles,
|
|
54
54
|
debugName: `${debugName} left icon`,
|
|
55
55
|
dismissKeyboard: false,
|
|
56
56
|
})
|
|
57
57
|
|
|
58
58
|
const _rightIcon = getRenderedComponent<Partial<ActionIconProps>>(rightIcon, ActionIcon, {
|
|
59
|
-
|
|
60
59
|
// @ts-ignore
|
|
61
|
-
|
|
60
|
+
style: styles.rightIconStyles,
|
|
62
61
|
debugName: `${debugName} right icon`,
|
|
63
62
|
dismissKeyboard: false,
|
|
64
63
|
})
|
|
65
64
|
|
|
66
|
-
const _label = TypeGuards.isString(label) ? <Text text={label} style={
|
|
65
|
+
const _label = TypeGuards.isString(label) ? <Text text={label} style={styles.labelStyle} /> : label
|
|
67
66
|
|
|
68
|
-
const _error = TypeGuards.isString(error) ? <Text text={error} style={
|
|
67
|
+
const _error = TypeGuards.isString(error) ? <Text text={error} style={styles.errorStyle} /> : error
|
|
69
68
|
|
|
70
|
-
const _description = TypeGuards.isString(description) ? <Text text={description} style={
|
|
69
|
+
const _description = TypeGuards.isString(description) ? <Text text={description} style={styles.descriptionStyle} /> : description
|
|
71
70
|
|
|
72
71
|
const parts = {
|
|
73
|
-
label: labelAsRow ? <View style={
|
|
72
|
+
label: labelAsRow ? <View style={styles.labelRowStyle}>
|
|
74
73
|
{_label}
|
|
75
74
|
{_description}
|
|
76
75
|
</View> : _label,
|
|
77
76
|
description: labelAsRow ? null : _description,
|
|
78
77
|
innerWrapper: <InnerWrapperComponent style={[
|
|
79
|
-
|
|
78
|
+
styles.innerWrapperStyle,
|
|
80
79
|
]} {...innerWrapperProps}>
|
|
81
80
|
{_leftIcon}
|
|
82
81
|
{children}
|
|
83
82
|
{_rightIcon}
|
|
84
83
|
</InnerWrapperComponent>,
|
|
85
84
|
error: hideErrorMessage ? null : (
|
|
86
|
-
_error || <Text text={''} style={
|
|
85
|
+
_error || <Text text={''} style={styles.errorStyle} />
|
|
87
86
|
),
|
|
88
87
|
}
|
|
89
88
|
|
|
90
89
|
return <WrapperComponent
|
|
91
|
-
style={[_styles.wrapperStyle, style]}
|
|
92
90
|
{...otherProps}
|
|
93
91
|
{...wrapperProps}
|
|
92
|
+
style={styles.wrapperStyle}
|
|
94
93
|
>
|
|
95
94
|
{
|
|
96
95
|
order.map((key) => <KeyPassthrough key={key}>
|
|
@@ -98,6 +97,16 @@ export const InputBase = React.forwardRef<any, InputBaseProps>((props, ref) => {
|
|
|
98
97
|
</KeyPassthrough>)
|
|
99
98
|
|
|
100
99
|
}
|
|
101
|
-
|
|
102
100
|
</WrapperComponent>
|
|
103
|
-
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
InputBase.elements = ['wrapper', 'innerWrapper', 'label', 'errorMessage', 'description', 'icon', 'leftIcon', 'rightIcon']
|
|
104
|
+
|
|
105
|
+
InputBase.defaultProps = {
|
|
106
|
+
disabled: false,
|
|
107
|
+
labelAsRow: false,
|
|
108
|
+
hideErrorMessage: false,
|
|
109
|
+
order: InputBaseDefaultOrder,
|
|
110
|
+
wrapper: View,
|
|
111
|
+
innerWrapper: View,
|
|
112
|
+
} as Partial<InputBaseProps>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { TypeGuards
|
|
2
|
-
import {
|
|
1
|
+
import { TypeGuards } from "@codeleap/common"
|
|
2
|
+
import { ActionIconParts } from "../ActionIcon"
|
|
3
3
|
import { InputBaseProps } from "./types"
|
|
4
|
-
import {
|
|
4
|
+
import { mergeStyles, useCompositionStyles } from '@codeleap/styles'
|
|
5
|
+
import { useMemo } from 'react'
|
|
5
6
|
|
|
6
7
|
type InputIcons = 'icon' | 'leftIcon' | 'rightIcon'
|
|
7
8
|
|
|
@@ -24,32 +25,33 @@ export type IconLessInputBaseParts = Exclude<InputBaseParts, InputIconCompositio
|
|
|
24
25
|
|
|
25
26
|
export type InputBaseComposition = `${InputBaseParts}:${InputBaseStates}` | InputBaseParts
|
|
26
27
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
],
|
|
40
|
-
'
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
28
|
+
const getIconStyles = (obj, state) => ({
|
|
29
|
+
icon: mergeStyles([
|
|
30
|
+
obj.icon,
|
|
31
|
+
state.focused && obj['icon:focus'],
|
|
32
|
+
state.hasError && obj['icon:error'],
|
|
33
|
+
state.disabled && obj['icon:disabled']
|
|
34
|
+
]),
|
|
35
|
+
'icon:disabled': mergeStyles([
|
|
36
|
+
state.disabled && obj['icon:disabled']
|
|
37
|
+
]),
|
|
38
|
+
touchableWrapper: mergeStyles([
|
|
39
|
+
obj.touchableWrapper,
|
|
40
|
+
state.focused && obj['touchableWrapper:focus'],
|
|
41
|
+
state.hasError && obj['touchableWrapper:error'],
|
|
42
|
+
state.disabled && obj['touchableWrapper:disabled']
|
|
43
|
+
]),
|
|
44
|
+
'touchableWrapper:disabled': mergeStyles([
|
|
45
|
+
state.disabled && obj['touchableWrapper:disabled']
|
|
46
|
+
])
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const useIconStyles = (styles, iconStyles, states) => {
|
|
50
|
+
return useMemo(() => {
|
|
51
|
+
const _iconStyles = getIconStyles(iconStyles, states)
|
|
52
|
+
|
|
53
|
+
return mergeStyles([styles, _iconStyles])
|
|
54
|
+
}, [states, styles, iconStyles])
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
export const useInputBaseStyles = (props: InputBaseProps) => {
|
|
@@ -57,76 +59,65 @@ export const useInputBaseStyles = (props: InputBaseProps) => {
|
|
|
57
59
|
focused,
|
|
58
60
|
disabled,
|
|
59
61
|
error,
|
|
60
|
-
styles
|
|
62
|
+
style: styles,
|
|
61
63
|
} = props
|
|
62
64
|
|
|
63
65
|
const hasError = !TypeGuards.isNil(error)
|
|
64
66
|
|
|
65
|
-
const
|
|
66
|
-
styles,
|
|
67
|
-
transform: StyleSheet.flatten,
|
|
68
|
-
rootElement: 'wrapper'
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
const _leftIconStyles = useNestedStylesByKey<ActionIconComposition>('leftIcon', variantStyles)
|
|
72
|
-
const _rightIconStyles = useNestedStylesByKey<ActionIconComposition>('rightIcon', variantStyles)
|
|
73
|
-
const _generalIconStyles = useNestedStylesByKey<ActionIconComposition>('icon', variantStyles)
|
|
67
|
+
const compositionStyles = useCompositionStyles(['leftIcon', 'rightIcon', 'icon'], styles)
|
|
74
68
|
|
|
75
|
-
const generalIconStyles = getIconStyles(
|
|
69
|
+
const generalIconStyles = getIconStyles(compositionStyles?.icon, { hasError, disabled })
|
|
76
70
|
|
|
77
|
-
const leftIconStyles =
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
]
|
|
71
|
+
const leftIconStyles = useIconStyles(generalIconStyles, compositionStyles?.leftIcon, {
|
|
72
|
+
// @ts-expect-error
|
|
73
|
+
hasError, disabled: (disabled || props?.leftIcon?.disabled), focused
|
|
74
|
+
})
|
|
82
75
|
|
|
83
|
-
const rightIconStyles =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
]
|
|
76
|
+
const rightIconStyles = useIconStyles(generalIconStyles, compositionStyles?.rightIcon, {
|
|
77
|
+
// @ts-expect-error
|
|
78
|
+
hasError, disabled: (disabled || props?.rightIcon?.disabled), focused
|
|
79
|
+
})
|
|
88
80
|
|
|
89
81
|
const labelStyle = [
|
|
90
|
-
|
|
91
|
-
focused &&
|
|
92
|
-
hasError &&
|
|
93
|
-
disabled &&
|
|
94
|
-
|
|
82
|
+
styles.label,
|
|
83
|
+
focused && styles['label:focus'],
|
|
84
|
+
hasError && styles['label:error'],
|
|
85
|
+
disabled && styles['label:disabled'],
|
|
95
86
|
]
|
|
96
87
|
|
|
97
88
|
const errorStyle = [
|
|
98
|
-
|
|
99
|
-
focused &&
|
|
100
|
-
hasError &&
|
|
101
|
-
disabled &&
|
|
89
|
+
styles.errorMessage,
|
|
90
|
+
focused && styles['errorMessage:focus'],
|
|
91
|
+
hasError && styles['errorMessage:error'],
|
|
92
|
+
disabled && styles['errorMessage:disabled'],
|
|
102
93
|
]
|
|
103
94
|
|
|
104
95
|
const descriptionStyle = [
|
|
105
|
-
|
|
106
|
-
focused &&
|
|
107
|
-
hasError &&
|
|
108
|
-
disabled &&
|
|
96
|
+
styles.description,
|
|
97
|
+
focused && styles['description:focus'],
|
|
98
|
+
hasError && styles['description:error'],
|
|
99
|
+
disabled && styles['description:disabled'],
|
|
109
100
|
]
|
|
110
101
|
|
|
111
102
|
const wrapperStyle = [
|
|
112
|
-
|
|
113
|
-
focused &&
|
|
114
|
-
error &&
|
|
115
|
-
disabled &&
|
|
103
|
+
styles.wrapper,
|
|
104
|
+
focused && styles['wrapper:focus'],
|
|
105
|
+
error && styles['wrapper:error'],
|
|
106
|
+
disabled && styles['wrapper:disabled'],
|
|
116
107
|
]
|
|
117
108
|
|
|
118
109
|
const innerWrapperStyle = [
|
|
119
|
-
|
|
120
|
-
focused &&
|
|
121
|
-
hasError &&
|
|
122
|
-
disabled &&
|
|
110
|
+
styles.innerWrapper,
|
|
111
|
+
focused && styles['innerWrapper:focus'],
|
|
112
|
+
hasError && styles['innerWrapper:error'],
|
|
113
|
+
disabled && styles['innerWrapper:disabled'],
|
|
123
114
|
]
|
|
124
115
|
|
|
125
116
|
const labelRowStyle = [
|
|
126
|
-
|
|
127
|
-
focused &&
|
|
128
|
-
hasError &&
|
|
129
|
-
disabled &&
|
|
117
|
+
styles.labelRow,
|
|
118
|
+
focused && styles['labelRow:focus'],
|
|
119
|
+
hasError && styles['labelRow:error'],
|
|
120
|
+
disabled && styles['labelRow:disabled'],
|
|
130
121
|
]
|
|
131
122
|
|
|
132
123
|
return {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { PropsOf } from '@codeleap/common'
|
|
2
|
-
import { StylesOf } from '../../types'
|
|
1
|
+
import { PropsOf, StylesOf } from '@codeleap/common'
|
|
3
2
|
import { InputBaseComposition } from './styles'
|
|
4
3
|
import { ActionIcon } from '../ActionIcon'
|
|
5
4
|
|
|
@@ -7,6 +6,7 @@ type ActionIconProps = PropsOf<typeof ActionIcon>
|
|
|
7
6
|
|
|
8
7
|
type OrderedParts = 'label' | 'description' | 'innerWrapper' | 'error'
|
|
9
8
|
type IconProp = Partial<ActionIconProps> | JSX.Element
|
|
9
|
+
|
|
10
10
|
export type InputBaseProps = React.PropsWithChildren<{
|
|
11
11
|
label?: React.ReactNode
|
|
12
12
|
error?: React.ReactNode
|
|
@@ -16,13 +16,12 @@ export type InputBaseProps = React.PropsWithChildren<{
|
|
|
16
16
|
wrapperProps?: any
|
|
17
17
|
innerWrapper?: React.FC<any>
|
|
18
18
|
innerWrapperProps?: any
|
|
19
|
-
styles?: StylesOf<InputBaseComposition>
|
|
20
19
|
description?: React.ReactNode
|
|
21
20
|
debugName: string
|
|
22
21
|
focused?: boolean
|
|
23
22
|
disabled?: boolean
|
|
24
23
|
order?: OrderedParts[]
|
|
25
|
-
style?:
|
|
24
|
+
style?: StylesOf<InputBaseComposition>
|
|
26
25
|
labelAsRow?: boolean
|
|
27
26
|
hideErrorMessage?: boolean
|
|
28
27
|
}>
|
|
@@ -8,8 +8,10 @@ type OmitDiff<T1, T2> = {
|
|
|
8
8
|
|
|
9
9
|
type InputBaseKey = keyof InputBaseProps
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
type BaseProps = Omit<InputBaseProps, 'style'>
|
|
12
|
+
|
|
13
|
+
export function selectInputBaseProps<T extends BaseProps>(props: T): {
|
|
14
|
+
inputBaseProps: BaseProps
|
|
13
15
|
others: OmitDiff<T, T>
|
|
14
16
|
} {
|
|
15
17
|
const varList:InputBaseKey[] = [
|
|
@@ -19,7 +21,6 @@ export function selectInputBaseProps<T extends InputBaseProps>(props: T): {
|
|
|
19
21
|
'innerWrapper',
|
|
20
22
|
'leftIcon',
|
|
21
23
|
'rightIcon',
|
|
22
|
-
// 'styles',
|
|
23
24
|
'description',
|
|
24
25
|
'wrapper',
|
|
25
26
|
'children',
|
|
@@ -27,6 +28,7 @@ export function selectInputBaseProps<T extends InputBaseProps>(props: T): {
|
|
|
27
28
|
'wrapperProps',
|
|
28
29
|
'disabled',
|
|
29
30
|
'hideErrorMessage',
|
|
31
|
+
'style',
|
|
30
32
|
]
|
|
31
33
|
|
|
32
34
|
const copy = { ...props }
|
|
@@ -36,7 +38,7 @@ export function selectInputBaseProps<T extends InputBaseProps>(props: T): {
|
|
|
36
38
|
acc[key] = copy[key]
|
|
37
39
|
|
|
38
40
|
return acc
|
|
39
|
-
}, {} as
|
|
41
|
+
}, {} as BaseProps)
|
|
40
42
|
|
|
41
43
|
return { inputBaseProps: result, others: copy as OmitDiff<T, T> }
|
|
42
44
|
}
|