@codeleap/web 3.1.2 → 3.2.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/package.json +13 -10
- package/src/components/ActionIcon/index.tsx +24 -15
- package/src/components/ActivityIndicator/index.tsx +39 -46
- package/src/components/ActivityIndicator/styles.ts +7 -11
- package/src/components/Button/index.tsx +17 -21
- package/src/components/Checkbox/index.tsx +103 -96
- package/src/components/Collapse/index.tsx +4 -3
- package/src/components/Drawer/index.tsx +25 -17
- package/src/components/FileInput.tsx +60 -32
- package/src/components/Icon/index.tsx +6 -5
- package/src/components/InputBase/index.tsx +9 -4
- package/src/components/InputBase/types.ts +1 -0
- package/src/components/List/index.tsx +3 -0
- package/src/components/LoadingOverlay/index.tsx +36 -23
- package/src/components/Modal/index.tsx +260 -88
- package/src/components/Modal/styles.ts +3 -4
- package/src/components/NumberIncrement/index.tsx +2 -0
- package/src/components/Overlay/index.tsx +11 -10
- package/src/components/Pager/index.tsx +166 -0
- package/src/components/Pager/styles.ts +14 -0
- package/src/components/RadioInput/index.tsx +21 -19
- package/src/components/Scroll/index.tsx +6 -3
- package/src/components/SegmentedControl/SegmentedControlOption.tsx +78 -0
- package/src/components/SegmentedControl/index.tsx +161 -0
- package/src/components/SegmentedControl/styles.ts +26 -0
- package/src/components/Select/index.tsx +13 -11
- package/src/components/Select/types.ts +23 -23
- package/src/components/Slider/index.tsx +77 -72
- package/src/components/Switch/index.tsx +96 -93
- package/src/components/Text/index.tsx +18 -33
- package/src/components/TextInput/index.tsx +14 -8
- package/src/components/Tooltip/index.tsx +1 -1
- package/src/components/Touchable/index.tsx +16 -18
- package/src/components/View/index.tsx +49 -25
- package/src/components/View/styles.ts +0 -1
- package/src/components/components.ts +2 -2
- package/src/components/defaultStyles.ts +16 -3
- package/src/lib/OSAlert.tsx +1 -1
- package/src/types/utility.ts +31 -2
- package/src/components/Link/index.tsx +0 -69
- package/src/components/Link/styles.ts +0 -11
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
2
5
|
import { ComponentVariants, onMount, PropsOf, TypeGuards, useDefaultComponentStyle, useRef } from '@codeleap/common'
|
|
3
6
|
import { SliderComposition } from './styles'
|
|
4
7
|
import { StylesOf } from '../../types'
|
|
@@ -7,12 +10,12 @@ import { concatStyles, InputBaseProps, InputBase, selectInputBaseProps } from '.
|
|
|
7
10
|
import { SliderPresets } from './styles'
|
|
8
11
|
import { Text } from '../Text'
|
|
9
12
|
|
|
10
|
-
import {
|
|
11
|
-
Root as SliderContainer,
|
|
12
|
-
Track as SliderTrack,
|
|
13
|
-
Thumb as SliderThumb,
|
|
13
|
+
import {
|
|
14
|
+
Root as SliderContainer,
|
|
15
|
+
Track as SliderTrack,
|
|
16
|
+
Thumb as SliderThumb,
|
|
14
17
|
Range as SliderRange,
|
|
15
|
-
SliderProps as PrimitiveSliderProps
|
|
18
|
+
SliderProps as PrimitiveSliderProps,
|
|
16
19
|
} from '@radix-ui/react-slider'
|
|
17
20
|
|
|
18
21
|
export * from './styles'
|
|
@@ -42,13 +45,13 @@ export type TrackMarkProps = {
|
|
|
42
45
|
const DefaultSliderTrackMark = (props: TrackMarkProps) => {
|
|
43
46
|
const { index, content, style } = props
|
|
44
47
|
|
|
45
|
-
if(!TypeGuards.isString(props.content)){
|
|
46
|
-
return
|
|
48
|
+
if (!TypeGuards.isString(props.content)) {
|
|
49
|
+
return <React.Fragment>
|
|
47
50
|
{props.content}
|
|
48
|
-
|
|
51
|
+
</React.Fragment>
|
|
49
52
|
}
|
|
50
53
|
|
|
51
|
-
return <Text
|
|
54
|
+
return <Text
|
|
52
55
|
text={props.content}
|
|
53
56
|
css={style}
|
|
54
57
|
/>
|
|
@@ -57,7 +60,7 @@ const DefaultSliderTrackMark = (props: TrackMarkProps) => {
|
|
|
57
60
|
export const Slider = (props: SliderProps) => {
|
|
58
61
|
const {
|
|
59
62
|
inputBaseProps,
|
|
60
|
-
others
|
|
63
|
+
others,
|
|
61
64
|
} = selectInputBaseProps(props)
|
|
62
65
|
|
|
63
66
|
const {
|
|
@@ -109,7 +112,7 @@ export const Slider = (props: SliderProps) => {
|
|
|
109
112
|
const hasLeftThumb = i !== 0
|
|
110
113
|
const hasRightThumb = i + 1 < newValue.length
|
|
111
114
|
|
|
112
|
-
const previousThumbValue = hasLeftThumb ? (copyValue[i -1] + minStepsBetweenThumbs) : null
|
|
115
|
+
const previousThumbValue = hasLeftThumb ? (copyValue[i - 1] + minStepsBetweenThumbs) : null
|
|
113
116
|
const nextThumbValue = hasRightThumb ? (copyValue[i + 1] - minStepsBetweenThumbs) : null
|
|
114
117
|
|
|
115
118
|
if (previousThumbValue && _newValue <= previousThumbValue) {
|
|
@@ -133,7 +136,7 @@ export const Slider = (props: SliderProps) => {
|
|
|
133
136
|
variantStyles.thumb,
|
|
134
137
|
disabled && variantStyles['thumb:disabled'],
|
|
135
138
|
])
|
|
136
|
-
}, [])
|
|
139
|
+
}, [])
|
|
137
140
|
|
|
138
141
|
const trackStyle = React.useMemo(() => {
|
|
139
142
|
return concatStyles([
|
|
@@ -141,16 +144,16 @@ export const Slider = (props: SliderProps) => {
|
|
|
141
144
|
disabled && variantStyles['track:disabled'],
|
|
142
145
|
variantStyles.unselectedTrack,
|
|
143
146
|
disabled && variantStyles['unselectedTrack:disabled'],
|
|
144
|
-
])
|
|
145
|
-
}, [disabled])
|
|
147
|
+
])
|
|
148
|
+
}, [disabled])
|
|
146
149
|
|
|
147
150
|
const selectedTrackStyle = React.useMemo(() => {
|
|
148
151
|
return concatStyles([
|
|
149
152
|
variantStyles.selectedTrack,
|
|
150
153
|
disabled && variantStyles['selectedTrack:disabled'],
|
|
151
|
-
])
|
|
154
|
+
])
|
|
152
155
|
}, [disabled])
|
|
153
|
-
|
|
156
|
+
|
|
154
157
|
const containerStyle = React.useMemo(() => {
|
|
155
158
|
return concatStyles([
|
|
156
159
|
variantStyles.sliderContainer,
|
|
@@ -161,11 +164,11 @@ export const Slider = (props: SliderProps) => {
|
|
|
161
164
|
const trackMarksHaveContent = !(TypeGuards.isArray(trackMarks) || TypeGuards.isNil(trackMarks))
|
|
162
165
|
|
|
163
166
|
const trackMarksProp = React.useMemo(() => {
|
|
164
|
-
if(!trackMarksHaveContent){
|
|
167
|
+
if (!trackMarksHaveContent) {
|
|
165
168
|
return trackMarks
|
|
166
169
|
}
|
|
167
170
|
return Object.keys(trackMarks).map((key) => Number(key))
|
|
168
|
-
},[trackMarksHaveContent])
|
|
171
|
+
}, [trackMarksHaveContent])
|
|
169
172
|
|
|
170
173
|
const trackMarkStyle = React.useMemo(() => {
|
|
171
174
|
return concatStyles([
|
|
@@ -194,12 +197,12 @@ export const Slider = (props: SliderProps) => {
|
|
|
194
197
|
|
|
195
198
|
indicatorLabel?.order?.forEach((idx, i) => {
|
|
196
199
|
const valueLabel = value[idx]
|
|
197
|
-
|
|
200
|
+
|
|
198
201
|
if (TypeGuards.isNil(valueLabel)) return
|
|
199
|
-
|
|
202
|
+
|
|
200
203
|
str = i === 0 ? String(valueLabel) : `${str}${indicatorLabel?.separator ?? ' - '}${valueLabel}`
|
|
201
204
|
})
|
|
202
|
-
|
|
205
|
+
|
|
203
206
|
return str
|
|
204
207
|
} else {
|
|
205
208
|
return description
|
|
@@ -237,8 +240,10 @@ export const Slider = (props: SliderProps) => {
|
|
|
237
240
|
</SliderTrack>
|
|
238
241
|
|
|
239
242
|
{defaultValue.map((_thumbValue, i) => (
|
|
240
|
-
<SliderThumb
|
|
241
|
-
key={i}
|
|
243
|
+
<SliderThumb
|
|
244
|
+
key={i}
|
|
245
|
+
// @ts-ignore
|
|
246
|
+
index={i}
|
|
242
247
|
style={thumbStyle}
|
|
243
248
|
onClick={() => currentThumbRef.current = i}
|
|
244
249
|
onMouseEnter={() => currentThumbRef.current = i}
|
|
@@ -247,56 +252,56 @@ export const Slider = (props: SliderProps) => {
|
|
|
247
252
|
</SliderContainer>
|
|
248
253
|
|
|
249
254
|
{trackMarksProp ?
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
const style = [
|
|
273
|
-
trackMarkStyle,
|
|
274
|
-
idxStyle,
|
|
275
|
-
]
|
|
276
|
-
|
|
277
|
-
if (!trackMarksHaveContent){
|
|
278
|
-
return <SliderTrackMark
|
|
279
|
-
index={idx}
|
|
280
|
-
style={style}
|
|
281
|
-
key={idx}
|
|
282
|
-
/>
|
|
255
|
+
<View css={trackMarkWrapperStyle}>
|
|
256
|
+
{
|
|
257
|
+
trackMarksProp.map((_, idx) => {
|
|
258
|
+
let idxStyle = {}
|
|
259
|
+
|
|
260
|
+
const relativeValue = Number(trackMarksProp[idx])
|
|
261
|
+
|
|
262
|
+
if (idx === 0) {
|
|
263
|
+
idxStyle = variantStyles.firstTrackMark
|
|
264
|
+
} else if (idx === trackMarksProp.length - 1) {
|
|
265
|
+
idxStyle = variantStyles.lastTrackMark
|
|
266
|
+
} else {
|
|
267
|
+
const markerPosition = (relativeValue / max) * 100
|
|
268
|
+
|
|
269
|
+
idxStyle = {
|
|
270
|
+
position: 'absolute',
|
|
271
|
+
left: `${markerPosition}%`,
|
|
272
|
+
top: '50%',
|
|
273
|
+
transform: `translate(-50%, -50%)`,
|
|
283
274
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const style = [
|
|
278
|
+
trackMarkStyle,
|
|
279
|
+
idxStyle,
|
|
280
|
+
]
|
|
281
|
+
|
|
282
|
+
if (!trackMarksHaveContent) {
|
|
283
|
+
return <SliderTrackMark
|
|
284
|
+
index={idx}
|
|
285
|
+
style={style}
|
|
286
|
+
key={idx}
|
|
287
|
+
/>
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const content = trackMarks[relativeValue]
|
|
291
|
+
|
|
292
|
+
return (
|
|
293
|
+
<SliderTrackMark
|
|
294
|
+
index={idx}
|
|
295
|
+
content={content}
|
|
296
|
+
style={style}
|
|
297
|
+
key={idx}
|
|
298
|
+
/>
|
|
299
|
+
)
|
|
300
|
+
})
|
|
301
|
+
}
|
|
302
|
+
</View>
|
|
298
303
|
: null}
|
|
299
|
-
</InputBase>
|
|
304
|
+
</InputBase>
|
|
300
305
|
)
|
|
301
306
|
}
|
|
302
307
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx, CSSObject } from '@emotion/react'
|
|
1
3
|
import * as React from 'react'
|
|
2
4
|
import { ComponentVariants, useDefaultComponentStyle, StylesOf, PropsOf } from '@codeleap/common'
|
|
3
5
|
import { View } from '../View'
|
|
@@ -7,16 +9,16 @@ import { useAnimatedVariantStyles } from '../..'
|
|
|
7
9
|
import { motion } from 'framer-motion'
|
|
8
10
|
|
|
9
11
|
export * from './styles'
|
|
10
|
-
|
|
12
|
+
|
|
11
13
|
export type SwitchProps = Pick<
|
|
12
14
|
InputBaseProps,
|
|
13
15
|
'debugName' | 'disabled' | 'label'
|
|
14
|
-
> &
|
|
16
|
+
> & {
|
|
15
17
|
variants?: ComponentVariants<typeof SwitchPresets>['variants']
|
|
16
18
|
styles?: StylesOf<SwitchComposition>
|
|
17
19
|
value: boolean
|
|
18
20
|
onValueChange: (value: boolean) => void
|
|
19
|
-
onChange?:
|
|
21
|
+
onChange?: (value: boolean) => void
|
|
20
22
|
style?: PropsOf<typeof View>['style']
|
|
21
23
|
switchOnLeft?: boolean
|
|
22
24
|
}
|
|
@@ -24,105 +26,106 @@ export type SwitchProps = Pick<
|
|
|
24
26
|
const reversedOrder = [...InputBaseDefaultOrder].reverse()
|
|
25
27
|
|
|
26
28
|
export const Switch = (props: SwitchProps) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
const {
|
|
30
|
+
inputBaseProps,
|
|
31
|
+
others,
|
|
32
|
+
} = selectInputBaseProps(props)
|
|
33
|
+
const {
|
|
34
|
+
variants = [],
|
|
35
|
+
style = {},
|
|
36
|
+
styles = {},
|
|
37
|
+
value,
|
|
38
|
+
disabled,
|
|
39
|
+
debugName,
|
|
40
|
+
onValueChange,
|
|
41
|
+
onChange,
|
|
42
|
+
switchOnLeft,
|
|
43
|
+
} = others
|
|
44
|
+
|
|
45
|
+
const variantStyles = useDefaultComponentStyle<'u:Switch', typeof SwitchPresets>('u:Switch', {
|
|
46
|
+
variants,
|
|
47
|
+
styles,
|
|
48
|
+
rootElement: 'wrapper',
|
|
49
|
+
})
|
|
42
50
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
'worklet'
|
|
54
|
-
let disabledStyle = {}
|
|
55
|
-
if(disabled){
|
|
56
|
-
disabledStyle = value ? variantStyles['track:disabled-on'] : variantStyles['track:disabled-off']
|
|
57
|
-
}
|
|
58
|
-
const style = value ? variantStyles['track:on'] : variantStyles['track:off']
|
|
51
|
+
const trackAnimation = useAnimatedVariantStyles({
|
|
52
|
+
variantStyles,
|
|
53
|
+
animatedProperties: ['track:off', 'track:disabled', 'track:on', 'track:disabled-on', 'track:disabled-off'],
|
|
54
|
+
updater: () => {
|
|
55
|
+
'worklet'
|
|
56
|
+
let disabledStyle = {}
|
|
57
|
+
if (disabled) {
|
|
58
|
+
disabledStyle = value ? variantStyles['track:disabled-on'] : variantStyles['track:disabled-off']
|
|
59
|
+
}
|
|
60
|
+
const style = value ? variantStyles['track:on'] : variantStyles['track:off']
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
return {
|
|
63
|
+
...style,
|
|
64
|
+
...disabledStyle,
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
dependencies: [value, disabled],
|
|
68
|
+
})
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
70
|
+
const thumbAnimation = useAnimatedVariantStyles({
|
|
71
|
+
variantStyles,
|
|
72
|
+
animatedProperties: ['thumb:off', 'thumb:disabled', 'thumb:on', 'thumb:disabled-off', 'thumb:disabled-on'],
|
|
73
|
+
updater: () => {
|
|
74
|
+
'worklet'
|
|
75
|
+
let disabledStyle = {}
|
|
76
|
+
if (disabled) {
|
|
77
|
+
disabledStyle = value ? variantStyles['thumb:disabled-on'] : variantStyles['thumb:disabled-off']
|
|
78
|
+
}
|
|
79
|
+
const style = value ? variantStyles['thumb:on'] : variantStyles['thumb:off']
|
|
80
|
+
return {
|
|
81
|
+
...style,
|
|
82
|
+
...disabledStyle,
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
dependencies: [value, disabled],
|
|
86
|
+
})
|
|
85
87
|
|
|
86
|
-
|
|
88
|
+
const _switchOnLeft = switchOnLeft ?? variantStyles.__props?.switchOnLeft
|
|
87
89
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
const handleChange = () => {
|
|
91
|
+
if (disabled) return
|
|
92
|
+
if (onValueChange) onValueChange?.(!value)
|
|
93
|
+
if (onChange) onChange?.(!value)
|
|
94
|
+
}
|
|
93
95
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
96
|
+
return <InputBase
|
|
97
|
+
{...inputBaseProps}
|
|
98
|
+
debugName={debugName}
|
|
99
|
+
styles={{
|
|
100
|
+
...variantStyles,
|
|
101
|
+
innerWrapper: [
|
|
102
|
+
variantStyles.innerWrapper,
|
|
103
|
+
],
|
|
104
|
+
}}
|
|
105
|
+
order={_switchOnLeft ? reversedOrder : InputBaseDefaultOrder}
|
|
106
|
+
style={style}
|
|
107
|
+
disabled={disabled}
|
|
108
|
+
noError
|
|
109
|
+
>
|
|
110
|
+
<motion.div
|
|
111
|
+
css={[
|
|
112
|
+
variantStyles.track,
|
|
113
|
+
disabled && variantStyles['track:disabled'],
|
|
114
|
+
]}
|
|
115
|
+
initial={false}
|
|
116
|
+
animate={trackAnimation}
|
|
117
|
+
transition={variantStyles['track:transition']}
|
|
118
|
+
onClick={handleChange}
|
|
106
119
|
>
|
|
107
120
|
<motion.div
|
|
108
121
|
css={[
|
|
109
|
-
variantStyles.
|
|
110
|
-
disabled && variantStyles['
|
|
122
|
+
variantStyles.thumb,
|
|
123
|
+
disabled && variantStyles['thumb:disabled'],
|
|
111
124
|
]}
|
|
112
125
|
initial={false}
|
|
113
|
-
animate={
|
|
114
|
-
transition={variantStyles['
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
css={[
|
|
119
|
-
variantStyles.thumb,
|
|
120
|
-
disabled && variantStyles['thumb:disabled'],
|
|
121
|
-
]}
|
|
122
|
-
initial={false}
|
|
123
|
-
animate={thumbAnimation}
|
|
124
|
-
transition={variantStyles['thumb:transition']}
|
|
125
|
-
/>
|
|
126
|
-
</motion.div>
|
|
127
|
-
</InputBase>
|
|
126
|
+
animate={thumbAnimation}
|
|
127
|
+
transition={variantStyles['thumb:transition']}
|
|
128
|
+
/>
|
|
129
|
+
</motion.div>
|
|
130
|
+
</InputBase>
|
|
128
131
|
}
|
|
@@ -2,61 +2,46 @@
|
|
|
2
2
|
import { jsx } from '@emotion/react'
|
|
3
3
|
import {
|
|
4
4
|
ComponentVariants,
|
|
5
|
-
useCodeleapContext,
|
|
6
5
|
useDefaultComponentStyle,
|
|
7
6
|
} from '@codeleap/common'
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
7
|
+
import { NativeHTMLElement } from '../../types/utility'
|
|
8
|
+
import { TextPresets } from './styles'
|
|
9
|
+
import { View, ViewProps } from '../View'
|
|
11
10
|
|
|
12
11
|
export * from './styles'
|
|
13
12
|
|
|
14
|
-
export type TextProps<T extends
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
debugName?: string
|
|
21
|
-
} & ComponentPropsWithoutRef<T> &
|
|
22
|
-
ComponentVariants<typeof TextPresets>
|
|
13
|
+
export type TextProps<T extends NativeHTMLElement> =
|
|
14
|
+
Omit<ViewProps<T>, 'variants'|'responsiveVariants'> &
|
|
15
|
+
ComponentVariants<typeof TextPresets> &
|
|
16
|
+
{
|
|
17
|
+
text?: string
|
|
18
|
+
}
|
|
23
19
|
|
|
24
|
-
export const Text = <T extends
|
|
20
|
+
export const Text = <T extends NativeHTMLElement>(textProps: TextProps<T>) => {
|
|
25
21
|
const {
|
|
26
22
|
variants = [],
|
|
27
23
|
responsiveVariants = {},
|
|
28
24
|
text = null,
|
|
29
25
|
children,
|
|
30
|
-
|
|
31
|
-
styles,
|
|
32
|
-
message = null,
|
|
33
|
-
debug = false,
|
|
34
|
-
debugName,
|
|
26
|
+
// style,
|
|
35
27
|
...props
|
|
36
28
|
} = textProps
|
|
37
29
|
|
|
38
|
-
const variantStyles = useDefaultComponentStyle('Text', {
|
|
30
|
+
const variantStyles = useDefaultComponentStyle<'u:Text', typeof TextPresets>('u:Text', {
|
|
39
31
|
rootElement: 'text',
|
|
40
32
|
responsiveVariants,
|
|
41
33
|
variants,
|
|
42
|
-
styles,
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
const { logger } = useCodeleapContext()
|
|
46
34
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (debug) {
|
|
50
|
-
logger.log(`Text ${debugName}`, { variantStyles, text })
|
|
51
|
-
}
|
|
35
|
+
})
|
|
52
36
|
|
|
53
37
|
return (
|
|
54
|
-
|
|
55
|
-
<
|
|
56
|
-
css={
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
<View
|
|
40
|
+
css={variantStyles.text}
|
|
41
|
+
component={'p'}
|
|
57
42
|
{...props}
|
|
58
43
|
>
|
|
59
44
|
{text || children}
|
|
60
|
-
</
|
|
45
|
+
</View>
|
|
61
46
|
)
|
|
62
47
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react'
|
|
3
|
+
|
|
1
4
|
import {
|
|
2
5
|
ComponentVariants,
|
|
3
6
|
FormTypes,
|
|
@@ -10,7 +13,6 @@ import {
|
|
|
10
13
|
yup,
|
|
11
14
|
} from '@codeleap/common'
|
|
12
15
|
import React, {
|
|
13
|
-
ComponentPropsWithoutRef,
|
|
14
16
|
forwardRef,
|
|
15
17
|
useImperativeHandle,
|
|
16
18
|
useRef,
|
|
@@ -19,7 +21,7 @@ import React, {
|
|
|
19
21
|
import TextareaAutosize from 'react-autosize-textarea'
|
|
20
22
|
import InputMask from 'react-input-mask'
|
|
21
23
|
import { Touchable, TouchableProps } from '../Touchable'
|
|
22
|
-
import { StylesOf } from '../../types/utility'
|
|
24
|
+
import { StylesOf, HTMLProps } from '../../types/utility'
|
|
23
25
|
import { InputBase, InputBaseProps, selectInputBaseProps } from '../InputBase'
|
|
24
26
|
import { TextInputPresets } from './styles'
|
|
25
27
|
import { getMaskInputProps, TextInputMaskingProps } from './mask'
|
|
@@ -27,7 +29,7 @@ import { getMaskInputProps, TextInputMaskingProps } from './mask'
|
|
|
27
29
|
export * from './styles'
|
|
28
30
|
export * from './mask'
|
|
29
31
|
|
|
30
|
-
type NativeTextInputProps =
|
|
32
|
+
type NativeTextInputProps = HTMLProps<'input'>
|
|
31
33
|
|
|
32
34
|
export type TextInputProps =
|
|
33
35
|
Omit<InputBaseProps, 'styles' | 'variants'> &
|
|
@@ -41,7 +43,7 @@ export type TextInputProps =
|
|
|
41
43
|
value?: NativeTextInputProps['value']
|
|
42
44
|
multiline?: boolean
|
|
43
45
|
onPress?: TouchableProps['onPress']
|
|
44
|
-
onChangeText?: (
|
|
46
|
+
onChangeText?: (textValue:string) => void
|
|
45
47
|
caretColor?: string
|
|
46
48
|
focused?: boolean
|
|
47
49
|
_error?: boolean
|
|
@@ -49,8 +51,10 @@ export type TextInputProps =
|
|
|
49
51
|
masking?: TextInputMaskingProps
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
type InputRef = HTMLInputElement & { isTextInput?: boolean }
|
|
55
|
+
|
|
56
|
+
export const TextInput = forwardRef<InputRef, TextInputProps>((props, inputRef) => {
|
|
57
|
+
const innerInputRef = useRef<InputRef>(null)
|
|
54
58
|
|
|
55
59
|
const {
|
|
56
60
|
inputBaseProps,
|
|
@@ -201,8 +205,7 @@ export const TextInput = forwardRef<HTMLInputElement, TextInputProps>((props, in
|
|
|
201
205
|
innerWrapperProps={{
|
|
202
206
|
...(inputBaseProps.innerWrapperProps || {}),
|
|
203
207
|
[inputBaseAction]: () => {
|
|
204
|
-
//
|
|
205
|
-
if (isMasked) innerInputRef.current?.onFocus?.()
|
|
208
|
+
// if (isMasked) innerInputRef.current?.onFocus?.()
|
|
206
209
|
innerInputRef.current?.focus?.()
|
|
207
210
|
if (isPressable) onPress?.()
|
|
208
211
|
},
|
|
@@ -215,6 +218,7 @@ export const TextInput = forwardRef<HTMLInputElement, TextInputProps>((props, in
|
|
|
215
218
|
..._wrapperOnInputFocus,
|
|
216
219
|
}}
|
|
217
220
|
>
|
|
221
|
+
|
|
218
222
|
<InputElement
|
|
219
223
|
editable={`${!isPressable && !isDisabled}`}
|
|
220
224
|
{...buttonModeProps}
|
|
@@ -222,7 +226,9 @@ export const TextInput = forwardRef<HTMLInputElement, TextInputProps>((props, in
|
|
|
222
226
|
{...textInputProps}
|
|
223
227
|
value={value}
|
|
224
228
|
onChange={(e) => handleChange(e)}
|
|
229
|
+
// @ts-ignore
|
|
225
230
|
onBlur={handleBlur}
|
|
231
|
+
// @ts-ignore
|
|
226
232
|
onFocus={handleFocus}
|
|
227
233
|
css={[
|
|
228
234
|
variantStyles.input,
|