@codeleap/web 3.6.1 → 3.7.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/web",
3
- "version": "3.6.1",
3
+ "version": "3.7.0",
4
4
  "main": "src/index.ts",
5
5
  "repository": {
6
6
  "url": "https://github.com/codeleap-uk/internal-libs-monorepo.git",
@@ -5,6 +5,7 @@ import {
5
5
  useDefaultComponentStyle,
6
6
  StylesOf,
7
7
  PropsOf,
8
+ IconPlaceholder,
8
9
  } from '@codeleap/common'
9
10
  import { View } from '../View'
10
11
  import { CheckboxPresets, CheckboxComposition } from './styles'
@@ -25,10 +26,15 @@ export type CheckboxProps = Pick<
25
26
  onValueChange: (value: boolean) => void
26
27
  style?: PropsOf<typeof View>['style']
27
28
  checkboxOnLeft?: boolean
29
+ checkIcon?: IconPlaceholder
28
30
  } & ComponentVariants<typeof CheckboxPresets>
29
31
 
30
32
  const reversedOrder = [...InputBaseDefaultOrder].reverse()
31
33
 
34
+ const defaultProps: Partial<CheckboxProps> = {
35
+ checkIcon: 'check' as IconPlaceholder,
36
+ }
37
+
32
38
  export const Checkbox = (props: CheckboxProps) => {
33
39
  const {
34
40
  inputBaseProps,
@@ -45,6 +51,7 @@ export const Checkbox = (props: CheckboxProps) => {
45
51
  debugName,
46
52
  onValueChange,
47
53
  checkboxOnLeft,
54
+ checkIcon,
48
55
  } = others
49
56
 
50
57
  const variantStyles = useDefaultComponentStyle<'u:Checkbox', typeof CheckboxPresets>('u:Checkbox', {
@@ -118,7 +125,7 @@ export const Checkbox = (props: CheckboxProps) => {
118
125
  order={_checkboxOnLeft ? reversedOrder : InputBaseDefaultOrder}
119
126
  style={style}
120
127
  wrapperProps={{
121
- onClick: handleChange
128
+ onClick: handleChange,
122
129
  }}
123
130
  >
124
131
  <motion.div
@@ -142,10 +149,13 @@ export const Checkbox = (props: CheckboxProps) => {
142
149
  >
143
150
  <Icon
144
151
  debugName={debugName}
145
- name={'checkbox-checkmark' as any}
152
+ name={checkIcon as any}
146
153
  css={[variantStyles.checkmark, disabled && variantStyles['checkmark:disabled']]}
154
+ style={variantStyles.checkmark}
147
155
  />
148
156
  </motion.div>
149
157
  </motion.div>
150
158
  </InputBase>
151
159
  }
160
+
161
+ Checkbox.defaultProps = defaultProps
@@ -37,6 +37,7 @@ export type DrawerProps = {
37
37
  animationDuration?: string
38
38
  closeButtonProps?: Partial<ActionIconProps>
39
39
  scrollLocked?: boolean
40
+ closeIcon?: IconPlaceholder
40
41
  children?: React.ReactNode
41
42
  } & ComponentVariants<typeof DrawerPresets> & ComponentCommonProps
42
43
 
@@ -68,6 +69,7 @@ const defaultProps: Partial<DrawerProps> = {
68
69
  size: '75vw',
69
70
  title: null,
70
71
  scrollLocked: true,
72
+ closeIcon: 'x' as IconPlaceholder,
71
73
  }
72
74
 
73
75
  export const Drawer = (props: DrawerProps) => {
@@ -94,6 +96,7 @@ export const Drawer = (props: DrawerProps) => {
94
96
  animationDuration,
95
97
  debugName,
96
98
  scrollLocked,
99
+ closeIcon,
97
100
  } = allProps as DrawerProps
98
101
 
99
102
  usePopState(open, toggle, scrollLocked)
@@ -118,7 +121,7 @@ export const Drawer = (props: DrawerProps) => {
118
121
  {
119
122
  transition: 'visibility 0.01s ease',
120
123
  transitionDelay: open ? '0' : animationDuration,
121
- visibility: open ? 'visible' : 'hidden'
124
+ visibility: open ? 'visible' : 'hidden',
122
125
  },
123
126
  style,
124
127
  ]), [open, variantStyles])
@@ -158,7 +161,7 @@ export const Drawer = (props: DrawerProps) => {
158
161
  <ActionIcon
159
162
  debugName={debugName}
160
163
  onPress={toggle}
161
- icon={'close' as IconPlaceholder}
164
+ icon={closeIcon as IconPlaceholder}
162
165
  {...closeButtonProps}
163
166
  styles={closeButtonStyles}
164
167
  />
@@ -166,9 +169,9 @@ export const Drawer = (props: DrawerProps) => {
166
169
  </View>
167
170
  ) : null
168
171
  }
169
-
172
+
170
173
  <View css={variantStyles.body}>{children}</View>
171
-
174
+
172
175
  {footer && (
173
176
  <View component='footer' css={variantStyles.footer}>
174
177
  {footer}
@@ -135,7 +135,7 @@ const ModalDefaultHeader = (props: ModalHeaderProps) => {
135
135
 
136
136
  const defaultProps: Partial<ModalProps> = {
137
137
  title: '',
138
- closeIconName: 'close' as IconPlaceholder,
138
+ closeIconName: 'x' as IconPlaceholder,
139
139
  closable: true,
140
140
  withOverlay: true,
141
141
  showClose: true,
@@ -38,7 +38,7 @@ export const SearchInput: ComponentWithDefaultProps<SearchInputProps> = (props)
38
38
  const hasStateProps = !TypeGuards.isNil(value) && TypeGuards.isFunction(onValueChange)
39
39
 
40
40
  const [search, setSearch] = hasStateProps ? [value, onValueChange] : useState('')
41
- const setSearchTimeout = React.useRef<NodeJS.Timeout|null>(null)
41
+ const setSearchTimeout = React.useRef<NodeJS.Timeout | null>(null)
42
42
 
43
43
  const handleChangeSearch = (value: string) => {
44
44
  setSearch(value)
@@ -88,6 +88,6 @@ export const SearchInput: ComponentWithDefaultProps<SearchInputProps> = (props)
88
88
  SearchInput.defaultProps = {
89
89
  debounce: null,
90
90
  clearable: true,
91
- clearIcon: 'close' as IconPlaceholder,
91
+ clearIcon: 'x' as IconPlaceholder,
92
92
  searchIcon: 'search' as IconPlaceholder,
93
93
  }
@@ -162,7 +162,7 @@ const defaultProps: Partial<SelectProps> = {
162
162
  placeholder: 'Select',
163
163
  clearable: false,
164
164
  formatPlaceholderNoItems: defaultFormatPlaceholderNoItems,
165
- selectedIcon: 'checkmark',
165
+ selectedIcon: 'check',
166
166
  searchable: false,
167
167
  separatorMultiValue: ', ',
168
168
  itemProps: {} as ButtonProps,
@@ -172,273 +172,273 @@ const defaultProps: Partial<SelectProps> = {
172
172
 
173
173
  export const Select = forwardRef<HTMLInputElement, SelectProps>(
174
174
  <T extends string | number = string, Multi extends boolean = false>
175
- (props: SelectProps<T, Multi>, inputRef: React.ForwardedRef<HTMLInputElement>) => {
175
+ (props: SelectProps<T, Multi>, inputRef: React.ForwardedRef<HTMLInputElement>) => {
176
176
 
177
- type Option = FormTypes.Option<T>
177
+ type Option = FormTypes.Option<T>
178
178
 
179
- const {
180
- inputBaseProps,
181
- others: selectProps,
182
- } = selectInputBaseProps({
183
- ...Select.defaultProps,
184
- ...props,
185
- })
179
+ const {
180
+ inputBaseProps,
181
+ others: selectProps,
182
+ } = selectInputBaseProps({
183
+ ...Select.defaultProps,
184
+ ...props,
185
+ })
186
+
187
+ const {
188
+ variants,
189
+ validate,
190
+ styles,
191
+ debugName,
192
+ onValueChange,
193
+ options,
194
+ value,
195
+ loadOptions,
196
+ multiple,
197
+ limit = null,
198
+ focused,
199
+ _error,
200
+ renderItem: OptionComponent = null,
201
+ FooterComponent = null,
202
+ PlaceholderComponent,
203
+ PlaceholderNoItemsComponent,
204
+ LoadingIndicatorComponent,
205
+ noItemsText,
206
+ noItemsIcon,
207
+ placeholderText,
208
+ placeholderIcon,
209
+ showDropdownIcon,
210
+ placeholder,
211
+ clearable,
212
+ formatPlaceholderNoItems,
213
+ closeOnSelect = !multiple,
214
+ selectedIcon,
215
+ onLoadOptionsError,
216
+ loadOptionsOnMount = options?.length === 0,
217
+ searchable,
218
+ separatorMultiValue,
219
+ filterItems = null,
220
+ itemProps = {},
221
+ loadingIndicatorSize,
222
+ ...otherProps
223
+ } = selectProps
224
+
225
+ const innerInputRef = useRef<any>(null)
226
+ const innerWrapperRef = useRef(null)
227
+
228
+ const [selectedOption, setSelectedOption] = useState(value)
229
+
230
+ const [_isFocused, setIsFocused] = useState(false)
231
+
232
+ const [keyDownActive, setKeyDownActive] = useState(false)
233
+
234
+ const isFocused = _isFocused || focused
235
+
236
+ // @ts-ignore
237
+ const validation = useValidate(value, validate)
238
+
239
+ const isDisabled = !!inputBaseProps.disabled
240
+
241
+ const hasError = !validation.isValid || _error
242
+ const errorMessage = validation.message || _error
243
+
244
+ const {
245
+ reactSelectStyles,
246
+ variantStyles,
247
+ optionsStyles,
248
+ placeholderStyles,
249
+ loadingStyles,
250
+ inputMultiValueStyles,
251
+ menuWrapperStyles,
252
+ } = useSelectStyles(props, {
253
+ error: !!hasError,
254
+ focused: isFocused,
255
+ disabled: isDisabled,
256
+ })
257
+
258
+ useImperativeHandle(inputRef, () => {
259
+ return {
260
+ ...innerInputRef.current,
261
+ focus: () => {
262
+ innerInputRef.current?.focus?.()
263
+ },
264
+ }
265
+ }, [!!innerInputRef?.current?.focus])
186
266
 
187
- const {
188
- variants,
189
- validate,
190
- styles,
191
- debugName,
192
- onValueChange,
193
- options,
194
- value,
195
- loadOptions,
196
- multiple,
197
- limit = null,
198
- focused,
199
- _error,
200
- renderItem: OptionComponent = null,
201
- FooterComponent = null,
202
- PlaceholderComponent,
203
- PlaceholderNoItemsComponent,
204
- LoadingIndicatorComponent,
205
- noItemsText,
206
- noItemsIcon,
207
- placeholderText,
208
- placeholderIcon,
209
- showDropdownIcon,
210
- placeholder,
211
- clearable,
212
- formatPlaceholderNoItems,
213
- closeOnSelect = !multiple,
214
- selectedIcon,
215
- onLoadOptionsError,
216
- loadOptionsOnMount = options?.length === 0,
217
- searchable,
218
- separatorMultiValue,
219
- filterItems = null,
220
- itemProps = {},
221
- loadingIndicatorSize,
222
- ...otherProps
223
- } = selectProps
224
-
225
- const innerInputRef = useRef<any>(null)
226
- const innerWrapperRef = useRef(null)
227
-
228
- const [selectedOption, setSelectedOption] = useState(value)
229
-
230
- const [_isFocused, setIsFocused] = useState(false)
231
-
232
- const [keyDownActive, setKeyDownActive] = useState(false)
233
-
234
- const isFocused = _isFocused || focused
267
+ const onLoadOptions = async (inputValue, cb) => {
268
+ if (!!loadOptions) {
269
+ try {
270
+ const _options = await loadOptions(inputValue).then((options) => {
271
+ cb(options)
272
+ return options
273
+ })
235
274
 
236
- // @ts-ignore
237
- const validation = useValidate(value, validate)
238
-
239
- const isDisabled = !!inputBaseProps.disabled
240
-
241
- const hasError = !validation.isValid || _error
242
- const errorMessage = validation.message || _error
243
-
244
- const {
245
- reactSelectStyles,
246
- variantStyles,
247
- optionsStyles,
248
- placeholderStyles,
249
- loadingStyles,
250
- inputMultiValueStyles,
251
- menuWrapperStyles,
252
- } = useSelectStyles(props, {
253
- error: !!hasError,
254
- focused: isFocused,
255
- disabled: isDisabled,
256
- })
275
+ return _options
276
+ } catch (err) {
277
+ onLoadOptionsError?.(err)
278
+ }
257
279
 
258
- useImperativeHandle(inputRef, () => {
259
- return {
260
- ...innerInputRef.current,
261
- focus: () => {
262
- innerInputRef.current?.focus?.()
263
- },
264
- }
265
- }, [!!innerInputRef?.current?.focus])
266
-
267
- const onLoadOptions = async (inputValue, cb) => {
268
- if (!!loadOptions) {
269
- try {
270
- const _options = await loadOptions(inputValue).then((options) => {
271
- cb(options)
272
- return options
273
- })
274
-
275
- return _options
276
- } catch (err) {
277
- onLoadOptionsError?.(err)
280
+ return
278
281
  }
279
-
280
- return
281
282
  }
282
- }
283
283
 
284
- const handleChange = (opt: Multi extends true ? Option[] : Option) => {
285
- if (TypeGuards.isArray(opt)) {
286
- // @ts-ignore
287
- if (TypeGuards.isNumber(limit) && opt?.length > limit && opt?.length > selectedOption?.length) {
288
- return
284
+ const handleChange = (opt: Multi extends true ? Option[] : Option) => {
285
+ if (TypeGuards.isArray(opt)) {
286
+ // @ts-ignore
287
+ if (TypeGuards.isNumber(limit) && opt?.length > limit && opt?.length > selectedOption?.length) {
288
+ return
289
+ }
290
+ // @ts-ignore
291
+ setSelectedOption(opt)
292
+ // @ts-ignore
293
+ onValueChange?.(opt?.map((o) => o?.value))
294
+ } else {
295
+ // @ts-ignore
296
+ setSelectedOption(opt)
297
+ // @ts-ignore
298
+ onValueChange?.(opt?.value)
289
299
  }
290
- // @ts-ignore
291
- setSelectedOption(opt)
292
- // @ts-ignore
293
- onValueChange?.(opt?.map((o) => o?.value))
294
- } else {
295
- // @ts-ignore
296
- setSelectedOption(opt)
297
- // @ts-ignore
298
- onValueChange?.(opt?.value)
299
300
  }
300
- }
301
301
 
302
- const handleBlur: SelectProps['onBlur'] = React.useCallback((e) => {
303
- validation?.onInputBlurred()
304
- setIsFocused(false)
305
- props?.onBlur?.(e)
306
- }, [validation?.onInputBlurred, props?.onBlur])
307
-
308
- const handleFocus: SelectProps['onFocus'] = React.useCallback((e) => {
309
- validation?.onInputFocused()
310
- setIsFocused(true)
311
- props?.onFocus?.(e)
312
- }, [validation?.onInputFocused, props?.onFocus])
313
-
314
- const SelectComponent = !!loadOptions ? Async : _Select
315
-
316
- const componentProps = {
317
- focused: isFocused,
318
- error: !!hasError,
319
- disabled: isDisabled,
320
- variantStyles,
321
- debugName: debugName,
322
- }
302
+ const handleBlur: SelectProps['onBlur'] = React.useCallback((e) => {
303
+ validation?.onInputBlurred()
304
+ setIsFocused(false)
305
+ props?.onBlur?.(e)
306
+ }, [validation?.onInputBlurred, props?.onBlur])
307
+
308
+ const handleFocus: SelectProps['onFocus'] = React.useCallback((e) => {
309
+ validation?.onInputFocused()
310
+ setIsFocused(true)
311
+ props?.onFocus?.(e)
312
+ }, [validation?.onInputFocused, props?.onFocus])
313
+
314
+ const SelectComponent = !!loadOptions ? Async : _Select
315
+
316
+ const componentProps = {
317
+ focused: isFocused,
318
+ error: !!hasError,
319
+ disabled: isDisabled,
320
+ variantStyles,
321
+ debugName: debugName,
322
+ }
323
323
 
324
- const _Placeholder = (props: NoticeProps) => {
325
- const hasInputValue = !!props.selectProps.inputValue
326
- const styles = placeholderStyles[hasInputValue ? 'noItems' : 'empty']
327
- const icon = hasInputValue ? noItemsIcon : placeholderIcon
324
+ const _Placeholder = (props: NoticeProps) => {
325
+ const hasInputValue = !!props.selectProps.inputValue
326
+ const styles = placeholderStyles[hasInputValue ? 'noItems' : 'empty']
327
+ const icon = hasInputValue ? noItemsIcon : placeholderIcon
328
328
 
329
- const placeholderProps = {
330
- ...props,
331
- ...componentProps,
332
- icon,
333
- defaultStyles: styles,
329
+ const placeholderProps = {
330
+ ...props,
331
+ ...componentProps,
332
+ icon,
333
+ defaultStyles: styles,
334
+ }
335
+
336
+ if (!hasInputValue) {
337
+
338
+ return <PlaceholderComponent {...placeholderProps} text={placeholderText} />
339
+ } else {
340
+ const _Text = TypeGuards.isString(noItemsText) ? formatPlaceholderNoItems({ ...placeholderProps, text: noItemsText }) : noItemsText
341
+ return <PlaceholderNoItemsComponent {...placeholderProps} text={_Text} />
342
+ }
334
343
  }
335
344
 
336
- if (!hasInputValue) {
337
-
338
- return <PlaceholderComponent {...placeholderProps} text={placeholderText} />
339
- } else {
340
- const _Text = TypeGuards.isString(noItemsText) ? formatPlaceholderNoItems({ ...placeholderProps, text: noItemsText }) : noItemsText
341
- return <PlaceholderNoItemsComponent {...placeholderProps} text={_Text} />
345
+ const _props = {
346
+ ...(!filterItems ? {} : { filterOption: filterItems }),
342
347
  }
343
- }
344
348
 
345
- const _props = {
346
- ...(!filterItems ? {} : { filterOption: filterItems }),
347
- }
349
+ onUpdate(() => {
350
+ if (!_isFocused) {
351
+ setKeyDownActive(false)
352
+ }
353
+ }, [_isFocused])
348
354
 
349
- onUpdate(() => {
350
- if (!_isFocused) {
351
- setKeyDownActive(false)
355
+ const handleKeyDown = () => {
356
+ setKeyDownActive(true)
352
357
  }
353
- }, [_isFocused])
354
358
 
355
- const handleKeyDown = () => {
356
- setKeyDownActive(true)
357
- }
358
-
359
- return (
360
- <InputBase
361
- {...inputBaseProps}
362
- debugName={debugName}
363
- error={hasError ? errorMessage : null}
364
- focused={isFocused}
365
- styles={{
366
- ...variantStyles,
367
- innerWrapper: [
368
- variantStyles.innerWrapper,
369
- searchable && variantStyles['innerWrapper:searchable'],
370
- ],
371
- }}
372
- innerWrapperProps={{
373
- ...(inputBaseProps.innerWrapperProps || {}),
374
- onClick: () => {
375
- innerInputRef.current?.focus?.()
376
- },
377
- }}
378
- innerWrapperRef={innerWrapperRef}
379
- >
380
- <SelectComponent
381
- openMenuOnFocus={true}
382
- hideSelectedOptions={false}
383
- tabSelectsValue={false}
384
- tabIndex={0}
385
- {...otherProps}
386
- {..._props}
387
- onKeyDown={isFocused ? handleKeyDown : null}
388
- onBlur={handleBlur}
389
- onFocus={handleFocus}
390
- onChange={handleChange}
391
- styles={reactSelectStyles}
392
- value={selectedOption as any}
393
- isMulti={multiple}
394
- options={options}
395
- loadOptions={onLoadOptions as any}
396
- defaultOptions={loadOptionsOnMount}
397
- ref={innerInputRef}
398
- closeMenuOnSelect={closeOnSelect}
399
- menuPortalTarget={innerWrapperRef.current}
400
- placeholder={placeholder}
401
- isDisabled={isDisabled}
402
- isClearable={clearable}
403
- isSearchable={searchable}
404
- components={{
405
- LoadingIndicator: () => null,
406
- ...otherProps.components,
407
- MultiValueRemove: () => null,
408
- LoadingMessage: props => (
409
- <LoadingIndicatorComponent
410
- {...props}
411
- defaultStyles={loadingStyles}
412
- size={loadingIndicatorSize}
413
- debugName={debugName}
414
- />
415
- ),
416
- DropdownIndicator: props => showDropdownIcon ? <components.DropdownIndicator {...props} /> : null,
417
- NoOptionsMessage: props => <_Placeholder {...props} />,
418
- Menu: props => <CustomMenu {...props} Footer={FooterComponent} />,
419
- MenuList: props => <CustomMenuList {...props} defaultStyles={menuWrapperStyles} />,
420
- Option: props => (
421
- <DefaultOption
422
- {...props}
423
- {...componentProps}
424
- itemProps={itemProps as ButtonProps}
425
- selectedIcon={selectedIcon}
426
- optionsStyles={optionsStyles}
427
- component={OptionComponent}
428
- isFocused={props?.isFocused && keyDownActive}
429
- />
430
- ),
431
- MultiValue: props => (
432
- <CustomMultiValue
433
- {...props}
434
- separator={separatorMultiValue}
435
- defaultStyles={inputMultiValueStyles}
436
- />
437
- ),
359
+ return (
360
+ <InputBase
361
+ {...inputBaseProps}
362
+ debugName={debugName}
363
+ error={hasError ? errorMessage : null}
364
+ focused={isFocused}
365
+ styles={{
366
+ ...variantStyles,
367
+ innerWrapper: [
368
+ variantStyles.innerWrapper,
369
+ searchable && variantStyles['innerWrapper:searchable'],
370
+ ],
438
371
  }}
439
- />
440
- </InputBase>
441
- )
372
+ innerWrapperProps={{
373
+ ...(inputBaseProps.innerWrapperProps || {}),
374
+ onClick: () => {
375
+ innerInputRef.current?.focus?.()
376
+ },
377
+ }}
378
+ innerWrapperRef={innerWrapperRef}
379
+ >
380
+ <SelectComponent
381
+ openMenuOnFocus={true}
382
+ hideSelectedOptions={false}
383
+ tabSelectsValue={false}
384
+ tabIndex={0}
385
+ {...otherProps}
386
+ {..._props}
387
+ onKeyDown={isFocused ? handleKeyDown : null}
388
+ onBlur={handleBlur}
389
+ onFocus={handleFocus}
390
+ onChange={handleChange}
391
+ styles={reactSelectStyles}
392
+ value={selectedOption as any}
393
+ isMulti={multiple}
394
+ options={options}
395
+ loadOptions={onLoadOptions as any}
396
+ defaultOptions={loadOptionsOnMount}
397
+ ref={innerInputRef}
398
+ closeMenuOnSelect={closeOnSelect}
399
+ menuPortalTarget={innerWrapperRef.current}
400
+ placeholder={placeholder}
401
+ isDisabled={isDisabled}
402
+ isClearable={clearable}
403
+ isSearchable={searchable}
404
+ components={{
405
+ LoadingIndicator: () => null,
406
+ ...otherProps.components,
407
+ MultiValueRemove: () => null,
408
+ LoadingMessage: props => (
409
+ <LoadingIndicatorComponent
410
+ {...props}
411
+ defaultStyles={loadingStyles}
412
+ size={loadingIndicatorSize}
413
+ debugName={debugName}
414
+ />
415
+ ),
416
+ DropdownIndicator: props => showDropdownIcon ? <components.DropdownIndicator {...props} /> : null,
417
+ NoOptionsMessage: props => <_Placeholder {...props} />,
418
+ Menu: props => <CustomMenu {...props} Footer={FooterComponent} />,
419
+ MenuList: props => <CustomMenuList {...props} defaultStyles={menuWrapperStyles} />,
420
+ Option: props => (
421
+ <DefaultOption
422
+ {...props}
423
+ {...componentProps}
424
+ itemProps={itemProps as ButtonProps}
425
+ selectedIcon={selectedIcon}
426
+ optionsStyles={optionsStyles}
427
+ component={OptionComponent}
428
+ isFocused={props?.isFocused && keyDownActive}
429
+ />
430
+ ),
431
+ MultiValue: props => (
432
+ <CustomMultiValue
433
+ {...props}
434
+ separator={separatorMultiValue}
435
+ defaultStyles={inputMultiValueStyles}
436
+ />
437
+ ),
438
+ }}
439
+ />
440
+ </InputBase>
441
+ )
442
442
  })
443
443
 
444
444
  Select.defaultProps = defaultProps
@@ -21,7 +21,7 @@ import React, {
21
21
  import TextareaAutosize from 'react-autosize-textarea'
22
22
  import InputMask from 'react-input-mask'
23
23
  import { Touchable, TouchableProps } from '../Touchable'
24
- import { StylesOf, HTMLProps } from '../../types/utility'
24
+ import { StylesOf, HTMLProps, ComponentWithDefaultProps } from '../../types/utility'
25
25
  import { InputBase, InputBaseProps, selectInputBaseProps } from '../InputBase'
26
26
  import { TextInputPresets } from './styles'
27
27
  import { getMaskInputProps, TextInputMaskingProps } from './mask'
@@ -33,7 +33,7 @@ type NativeTextInputProps = HTMLProps<'input'>
33
33
 
34
34
  export type TextInputProps =
35
35
  Omit<InputBaseProps, 'styles' | 'variants'> &
36
- Omit<NativeTextInputProps, 'value'|'crossOrigin'> & {
36
+ Omit<NativeTextInputProps, 'value' | 'crossOrigin'> & {
37
37
  styles?: StylesOf<TextInputComposition>
38
38
  password?: boolean
39
39
  validate?: FormTypes.ValidatorWithoutForm<string> | yup.SchemaOf<string>
@@ -42,23 +42,33 @@ export type TextInputProps =
42
42
  value?: NativeTextInputProps['value']
43
43
  multiline?: boolean
44
44
  onPress?: TouchableProps['onPress']
45
- onChangeText?: (textValue:string) => void
45
+ onChangeText?: (textValue: string) => void
46
46
  caretColor?: string
47
47
  focused?: boolean
48
48
  _error?: boolean
49
49
  rows?: number
50
50
  masking?: TextInputMaskingProps
51
+ visibleIcon?: IconPlaceholder
52
+ hiddenIcon?: IconPlaceholder
51
53
  } & ComponentVariants<typeof TextInputPresets>
52
54
 
53
55
  type InputRef = HTMLInputElement & { isTextInput?: boolean }
54
56
 
55
- export const TextInput = forwardRef<InputRef, TextInputProps>((props, inputRef) => {
57
+ const defaultProps:Partial<TextInputProps> = {
58
+ hiddenIcon: 'input-visiblity:hidden' as IconPlaceholder,
59
+ visibleIcon: 'input-visiblity:visible' as IconPlaceholder,
60
+ }
61
+
62
+ export const TextInputComponent = forwardRef<InputRef, TextInputProps>((props, inputRef) => {
56
63
  const innerInputRef = useRef<InputRef>(null)
57
64
 
58
65
  const {
59
66
  inputBaseProps,
60
67
  others,
61
- } = selectInputBaseProps(props)
68
+ } = selectInputBaseProps({
69
+ ...TextInput.defaultProps,
70
+ ...props,
71
+ })
62
72
 
63
73
  const {
64
74
  variants = [],
@@ -75,6 +85,8 @@ export const TextInput = forwardRef<InputRef, TextInputProps>((props, inputRef)
75
85
  focused,
76
86
  _error,
77
87
  masking = null,
88
+ visibleIcon,
89
+ hiddenIcon,
78
90
  ...textInputProps
79
91
  } = others as TextInputProps
80
92
 
@@ -141,7 +153,7 @@ export const TextInput = forwardRef<InputRef, TextInputProps>((props, inputRef)
141
153
 
142
154
  const visibilityToggleProps = visibilityToggle ? {
143
155
  onPress: toggleSecureTextEntry,
144
- icon: (secureTextEntry ? 'input-visiblity:hidden' : 'input-visiblity:visible') as IconPlaceholder,
156
+ icon: (secureTextEntry ? hiddenIcon : visibleIcon) as IconPlaceholder,
145
157
  debugName: `${debugName} toggle visibility`,
146
158
  } : null
147
159
 
@@ -248,3 +260,7 @@ export const TextInput = forwardRef<InputRef, TextInputProps>((props, inputRef)
248
260
  </InputBase>
249
261
  )
250
262
  })
263
+
264
+ export const TextInput = TextInputComponent as ComponentWithDefaultProps<TextInputProps>
265
+
266
+ TextInput.defaultProps = defaultProps