@codeleap/web 5.8.20 → 6.0.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/dist/components/ActionIcon/index.d.ts +1 -1
- package/dist/components/ActionIcon/index.js +1 -1
- package/dist/components/ActionIcon/index.js.map +1 -1
- package/dist/components/ActivityIndicator/index.d.ts +9 -2
- package/dist/components/ActivityIndicator/index.js +8 -16
- package/dist/components/ActivityIndicator/index.js.map +1 -1
- package/dist/components/Badge/index.d.ts +1 -1
- package/dist/components/Badge/index.js +1 -1
- package/dist/components/Badge/index.js.map +1 -1
- package/dist/components/Badge/types.d.ts +1 -2
- package/dist/components/Button/index.d.ts +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Carousel/index.d.ts +5 -0
- package/dist/components/Carousel/index.js +168 -0
- package/dist/components/Carousel/index.js.map +1 -0
- package/dist/components/Carousel/styles.d.ts +3 -0
- package/dist/components/Carousel/styles.js.map +1 -0
- package/dist/components/Carousel/types.d.ts +34 -0
- package/dist/components/{Grid → Carousel}/types.js.map +1 -1
- package/dist/components/Checkbox/index.d.ts +1 -1
- package/dist/components/Checkbox/index.js +2 -2
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Collapse/index.d.ts +1 -1
- package/dist/components/Collapse/index.js +3 -3
- package/dist/components/Collapse/index.js.map +1 -1
- package/dist/components/Collapse/types.d.ts +1 -2
- package/dist/components/ColorPicker/index.d.ts +1 -1
- package/dist/components/ColorPicker/index.js +4 -4
- package/dist/components/ColorPicker/index.js.map +1 -1
- package/dist/components/ColorPicker/types.d.ts +3 -3
- package/dist/components/CropPicker/index.d.ts +9 -2
- package/dist/components/CropPicker/index.js +6 -6
- package/dist/components/CropPicker/index.js.map +1 -1
- package/dist/components/CropPicker/types.d.ts +3 -1
- package/dist/components/DatePicker/components/DayContent.js +1 -1
- package/dist/components/DatePicker/components/DayContent.js.map +1 -1
- package/dist/components/DatePicker/components/Header.js +1 -1
- package/dist/components/DatePicker/components/Header.js.map +1 -1
- package/dist/components/DatePicker/components/OuterInput.js +2 -12
- package/dist/components/DatePicker/components/OuterInput.js.map +1 -1
- package/dist/components/DatePicker/components/YearContent.js +1 -1
- package/dist/components/DatePicker/components/YearContent.js.map +1 -1
- package/dist/components/DatePicker/index.d.ts +1 -1
- package/dist/components/DatePicker/index.js +12 -13
- package/dist/components/DatePicker/index.js.map +1 -1
- package/dist/components/DatePicker/types.d.ts +8 -6
- package/dist/components/Drawer/index.d.ts +1 -1
- package/dist/components/Drawer/index.js +2 -2
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Dropzone/index.d.ts +9 -2
- package/dist/components/Dropzone/index.js +7 -6
- package/dist/components/Dropzone/index.js.map +1 -1
- package/dist/components/Dropzone/types.d.ts +3 -2
- package/dist/components/EmptyPlaceholder/index.d.ts +1 -1
- package/dist/components/EmptyPlaceholder/index.js +3 -3
- package/dist/components/EmptyPlaceholder/index.js.map +1 -1
- package/dist/components/EmptyPlaceholder/types.d.ts +2 -2
- package/dist/components/FileInput/index.d.ts +5 -9
- package/dist/components/FileInput/index.js +6 -5
- package/dist/components/FileInput/index.js.map +1 -1
- package/dist/components/FileInput/types.d.ts +2 -0
- package/dist/components/Icon/index.d.ts +1 -1
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/InputBase/index.js +2 -2
- package/dist/components/InputBase/index.js.map +1 -1
- package/dist/components/InputBase/types.d.ts +0 -1
- package/dist/components/InputBase/useInputBase.d.ts +2 -3
- package/dist/components/InputBase/useInputBase.js +2 -3
- package/dist/components/InputBase/useInputBase.js.map +1 -1
- package/dist/components/InputBase/useInputBasePartialStyles.js +1 -2
- package/dist/components/InputBase/useInputBasePartialStyles.js.map +1 -1
- package/dist/components/InputBase/utils.d.ts +1 -1
- package/dist/components/InputBase/utils.js +3 -3
- package/dist/components/InputBase/utils.js.map +1 -1
- package/dist/components/List/index.d.ts +2 -3
- package/dist/components/List/index.js +87 -40
- package/dist/components/List/index.js.map +1 -1
- package/dist/components/List/styles.d.ts +2 -4
- package/dist/components/List/types.d.ts +10 -52
- package/dist/components/LoadingOverlay/index.d.ts +1 -1
- package/dist/components/LoadingOverlay/index.js +1 -1
- package/dist/components/LoadingOverlay/index.js.map +1 -1
- package/dist/components/MaskedTextInput/index.d.ts +7 -0
- package/dist/components/MaskedTextInput/index.js +69 -0
- package/dist/components/MaskedTextInput/index.js.map +1 -0
- package/dist/components/MaskedTextInput/mask.d.ts +8 -0
- package/dist/components/MaskedTextInput/mask.js +37 -0
- package/dist/components/MaskedTextInput/mask.js.map +1 -0
- package/dist/components/MaskedTextInput/types.d.ts +10 -0
- package/dist/components/MaskedTextInput/types.js.map +1 -0
- package/dist/components/Modal/index.d.ts +1 -1
- package/dist/components/Modal/index.js +6 -6
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/NumberIncrement/index.d.ts +1 -1
- package/dist/components/NumberIncrement/index.js +1 -3
- package/dist/components/NumberIncrement/index.js.map +1 -1
- package/dist/components/NumberIncrement/useNumberIncrement.d.ts +4 -4
- package/dist/components/NumberIncrement/useNumberIncrement.js +1 -2
- package/dist/components/NumberIncrement/useNumberIncrement.js.map +1 -1
- package/dist/components/Overlay/index.d.ts +1 -1
- package/dist/components/PaginationButtons/index.d.ts +1 -1
- package/dist/components/PaginationButtons/index.js +2 -2
- package/dist/components/PaginationButtons/index.js.map +1 -1
- package/dist/components/PaginationButtons/types.d.ts +1 -2
- package/dist/components/PaginationIndicator/index.d.ts +2 -3
- package/dist/components/PaginationIndicator/index.js +2 -2
- package/dist/components/PaginationIndicator/index.js.map +1 -1
- package/dist/components/PaginationIndicator/types.d.ts +3 -3
- package/dist/components/Progress/Bar/index.d.ts +1 -1
- package/dist/components/Progress/Bar/index.js +1 -1
- package/dist/components/Progress/Bar/index.js.map +1 -1
- package/dist/components/Progress/Bar/types.d.ts +2 -3
- package/dist/components/Progress/Circle/index.d.ts +1 -1
- package/dist/components/Progress/Circle/index.js +2 -2
- package/dist/components/Progress/Circle/index.js.map +1 -1
- package/dist/components/Progress/Circle/types.d.ts +1 -2
- package/dist/components/Progress/index.d.ts +0 -1
- package/dist/components/Progress/utils.js +1 -2
- package/dist/components/Progress/utils.js.map +1 -1
- package/dist/components/RadioInput/index.d.ts +1 -1
- package/dist/components/RadioInput/index.js +2 -2
- package/dist/components/RadioInput/index.js.map +1 -1
- package/dist/components/SearchInput/index.js.map +1 -1
- package/dist/components/SectionFilters/index.d.ts +1 -1
- package/dist/components/SectionFilters/index.js +4 -4
- package/dist/components/SectionFilters/index.js.map +1 -1
- package/dist/components/SectionFilters/types.d.ts +1 -2
- package/dist/components/SegmentedControl/index.d.ts +1 -1
- package/dist/components/SegmentedControl/index.js +12 -21
- package/dist/components/SegmentedControl/index.js.map +1 -1
- package/dist/components/SegmentedControl/types.d.ts +2 -2
- package/dist/components/Select/index.js +5 -5
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Select/styles.js +1 -2
- package/dist/components/Select/styles.js.map +1 -1
- package/dist/components/Select/types.d.ts +6 -6
- package/dist/components/Slider/index.d.ts +1 -1
- package/dist/components/Slider/index.js +3 -3
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/Switch/index.d.ts +1 -1
- package/dist/components/Switch/index.js +2 -2
- package/dist/components/Switch/index.js.map +1 -1
- package/dist/components/Tag/index.d.ts +1 -1
- package/dist/components/Tag/index.js +1 -1
- package/dist/components/Tag/index.js.map +1 -1
- package/dist/components/Text/index.d.ts +10 -2
- package/dist/components/Text/index.js +12 -20
- package/dist/components/Text/index.js.map +1 -1
- package/dist/components/Text/types.d.ts +3 -2
- package/dist/components/TextEditor/index.d.ts +1 -1
- package/dist/components/TextEditor/index.js +21 -9
- package/dist/components/TextEditor/index.js.map +1 -1
- package/dist/components/TextEditor/types.d.ts +4 -5
- package/dist/components/TextInput/index.d.ts +9 -3
- package/dist/components/TextInput/index.js +14 -30
- package/dist/components/TextInput/index.js.map +1 -1
- package/dist/components/TextInput/types.d.ts +4 -40
- package/dist/components/TextInput/useTextInput.d.ts +2 -6
- package/dist/components/TextInput/useTextInput.js +7 -16
- package/dist/components/TextInput/useTextInput.js.map +1 -1
- package/dist/components/Tooltip/index.d.ts +1 -1
- package/dist/components/Tooltip/index.js +1 -1
- package/dist/components/Tooltip/index.js.map +1 -1
- package/dist/components/Tooltip/types.d.ts +1 -1
- package/dist/components/Touchable/index.d.ts +10 -2
- package/dist/components/Touchable/index.js +9 -19
- package/dist/components/Touchable/index.js.map +1 -1
- package/dist/components/Touchable/types.d.ts +2 -1
- package/dist/components/View/index.d.ts +10 -2
- package/dist/components/View/index.js +7 -7
- package/dist/components/View/index.js.map +1 -1
- package/dist/components/View/types.d.ts +2 -2
- package/dist/components/VirtualList/context.d.ts +3 -0
- package/dist/components/VirtualList/context.js +93 -0
- package/dist/components/VirtualList/context.js.map +1 -0
- package/dist/components/VirtualList/index.d.ts +5 -0
- package/dist/components/VirtualList/index.js +14 -0
- package/dist/components/VirtualList/index.js.map +1 -0
- package/dist/components/VirtualList/list.d.ts +3 -0
- package/dist/components/VirtualList/list.js +102 -0
- package/dist/components/VirtualList/list.js.map +1 -0
- package/dist/components/VirtualList/types.d.ts +33 -0
- package/dist/components/{Pager/styles.js → VirtualList/types.js} +1 -1
- package/dist/components/VirtualList/types.js.map +1 -0
- package/dist/components/components.d.ts +4 -2
- package/dist/components/components.js +4 -2
- package/dist/components/components.js.map +1 -1
- package/dist/lib/ListMasonry.js +3 -3
- package/dist/lib/ListMasonry.js.map +1 -1
- package/dist/lib/WebStyleRegistry.js.map +1 -1
- package/dist/lib/hooks/index.d.ts +0 -1
- package/dist/lib/hooks/index.js +0 -1
- package/dist/lib/hooks/index.js.map +1 -1
- package/dist/lib/hooks/useAnimatedStyle.d.ts +8 -4
- package/dist/lib/hooks/useAnimatedStyle.js.map +1 -1
- package/dist/lib/hooks/useAnimatedVariantStyles.d.ts +3 -3
- package/dist/lib/hooks/useAnimatedVariantStyles.js +1 -2
- package/dist/lib/hooks/useAnimatedVariantStyles.js.map +1 -1
- package/dist/lib/hooks/useBreakpointMatch.js +1 -2
- package/dist/lib/hooks/useBreakpointMatch.js.map +1 -1
- package/dist/lib/hooks/useClick.js +1 -2
- package/dist/lib/hooks/useClick.js.map +1 -1
- package/dist/lib/hooks/useClickOutside.d.ts +1 -2
- package/dist/lib/hooks/useClickOutside.js +2 -3
- package/dist/lib/hooks/useClickOutside.js.map +1 -1
- package/dist/lib/hooks/useCropPicker.d.ts +1 -2
- package/dist/lib/hooks/useCropPicker.js +19 -7
- package/dist/lib/hooks/useCropPicker.js.map +1 -1
- package/dist/lib/hooks/useFileInput.d.ts +1 -2
- package/dist/lib/hooks/useKeydown.js +2 -2
- package/dist/lib/hooks/useKeydown.js.map +1 -1
- package/dist/lib/hooks/useMediaQuery.js +2 -3
- package/dist/lib/hooks/useMediaQuery.js.map +1 -1
- package/dist/lib/hooks/usePageExitBlocker.js.map +1 -1
- package/dist/lib/hooks/usePagination.js +1 -2
- package/dist/lib/hooks/usePagination.js.map +1 -1
- package/dist/lib/hooks/usePopState.js.map +1 -1
- package/dist/lib/hooks/useRefresh.d.ts +1 -1
- package/dist/lib/hooks/useRefresh.js.map +1 -1
- package/dist/lib/hooks/useScrollEffect.js +1 -2
- package/dist/lib/hooks/useScrollEffect.js.map +1 -1
- package/dist/lib/hooks/useSearchParams.d.ts +0 -1
- package/dist/lib/hooks/useSearchParams.js +1 -2
- package/dist/lib/hooks/useSearchParams.js.map +1 -1
- package/dist/lib/hooks/useStaticAnimationStyles.js +1 -2
- package/dist/lib/hooks/useStaticAnimationStyles.js.map +1 -1
- package/dist/lib/hooks/useWindowSize.js +1 -2
- package/dist/lib/hooks/useWindowSize.js.map +1 -1
- package/dist/lib/tools/localStorage.js.map +1 -1
- package/dist/lib/tools/mediaQuery.js +3 -4
- package/dist/lib/tools/mediaQuery.js.map +1 -1
- package/dist/lib/tools/modal.js +3 -3
- package/dist/lib/tools/modal.js.map +1 -1
- package/dist/lib/utils/pollyfils/scroll.js.map +1 -1
- package/dist/lib/utils/stopPropagation.js +1 -2
- package/dist/lib/utils/stopPropagation.js.map +1 -1
- package/dist/lib/utils/test.js.map +1 -1
- package/dist/types/utility.d.ts +2 -2
- package/package.json +39 -39
- package/package.json.bak +24 -24
- package/src/components/ActionIcon/index.tsx +1 -1
- package/src/components/ActivityIndicator/index.tsx +3 -4
- package/src/components/Badge/types.ts +1 -1
- package/src/components/Carousel/index.tsx +230 -0
- package/src/components/{Pager → Carousel}/styles.ts +2 -2
- package/src/components/Carousel/types.ts +41 -0
- package/src/components/Checkbox/index.tsx +1 -1
- package/src/components/Collapse/index.tsx +1 -1
- package/src/components/Collapse/types.ts +1 -1
- package/src/components/ColorPicker/types.ts +3 -3
- package/src/components/CropPicker/index.tsx +4 -3
- package/src/components/CropPicker/types.ts +3 -1
- package/src/components/DatePicker/components/OuterInput.tsx +3 -12
- package/src/components/DatePicker/index.tsx +18 -10
- package/src/components/DatePicker/types.ts +8 -5
- package/src/components/Dropzone/index.tsx +3 -2
- package/src/components/Dropzone/types.ts +3 -1
- package/src/components/EmptyPlaceholder/types.ts +2 -2
- package/src/components/FileInput/index.tsx +4 -3
- package/src/components/FileInput/types.ts +2 -0
- package/src/components/InputBase/useInputBase.ts +1 -1
- package/src/components/InputBase/utils.ts +1 -1
- package/src/components/List/index.tsx +56 -78
- package/src/components/List/styles.ts +2 -10
- package/src/components/List/types.ts +10 -52
- package/src/components/MaskedTextInput/index.tsx +58 -0
- package/src/components/MaskedTextInput/mask.ts +41 -0
- package/src/components/MaskedTextInput/types.ts +18 -0
- package/src/components/NumberIncrement/index.tsx +1 -3
- package/src/components/PaginationButtons/types.ts +1 -1
- package/src/components/PaginationIndicator/types.ts +2 -2
- package/src/components/Progress/Bar/types.ts +2 -2
- package/src/components/Progress/Circle/types.ts +1 -1
- package/src/components/SectionFilters/types.ts +1 -1
- package/src/components/SegmentedControl/index.tsx +6 -5
- package/src/components/SegmentedControl/types.ts +2 -2
- package/src/components/Select/index.tsx +3 -3
- package/src/components/Select/types.ts +6 -6
- package/src/components/Switch/index.tsx +1 -1
- package/src/components/Text/index.tsx +4 -3
- package/src/components/Text/types.ts +3 -2
- package/src/components/TextEditor/index.tsx +20 -18
- package/src/components/TextEditor/types.ts +5 -5
- package/src/components/TextInput/index.tsx +14 -34
- package/src/components/TextInput/types.ts +5 -57
- package/src/components/TextInput/useTextInput.ts +10 -19
- package/src/components/Tooltip/types.ts +1 -1
- package/src/components/Touchable/index.tsx +4 -4
- package/src/components/Touchable/types.ts +2 -1
- package/src/components/View/index.tsx +6 -5
- package/src/components/View/types.ts +3 -3
- package/src/components/VirtualList/context.tsx +93 -0
- package/src/components/VirtualList/index.tsx +11 -0
- package/src/components/VirtualList/list.tsx +85 -0
- package/src/components/VirtualList/types.ts +38 -0
- package/src/components/components.ts +4 -2
- package/src/lib/hooks/index.ts +0 -1
- package/src/lib/hooks/useAnimatedStyle.ts +11 -7
- package/src/lib/hooks/useAnimatedVariantStyles.ts +2 -2
- package/src/lib/hooks/useClickOutside.ts +1 -1
- package/src/lib/hooks/useMediaQuery.ts +1 -1
- package/src/types/utility.ts +2 -2
- package/dist/components/Grid/index.d.ts +0 -13
- package/dist/components/Grid/index.js +0 -94
- package/dist/components/Grid/index.js.map +0 -1
- package/dist/components/Grid/styles.d.ts +0 -2
- package/dist/components/Grid/styles.js.map +0 -1
- package/dist/components/Grid/types.d.ts +0 -9
- package/dist/components/List/ListLayout.d.ts +0 -2
- package/dist/components/List/ListLayout.js +0 -39
- package/dist/components/List/ListLayout.js.map +0 -1
- package/dist/components/Pager/index.d.ts +0 -7
- package/dist/components/Pager/index.js +0 -118
- package/dist/components/Pager/index.js.map +0 -1
- package/dist/components/Pager/styles.d.ts +0 -3
- package/dist/components/Pager/styles.js.map +0 -1
- package/dist/components/Pager/types.d.ts +0 -27
- package/dist/components/Pager/types.js.map +0 -1
- package/dist/components/TextInput/mask.d.ts +0 -5
- package/dist/components/TextInput/mask.js +0 -110
- package/dist/components/TextInput/mask.js.map +0 -1
- package/dist/lib/deprecated/OSAlert.d.ts +0 -38
- package/dist/lib/deprecated/OSAlert.js +0 -139
- package/dist/lib/deprecated/OSAlert.js.map +0 -1
- package/dist/lib/deprecated/index.d.ts +0 -1
- package/dist/lib/deprecated/index.js +0 -22
- package/dist/lib/deprecated/index.js.map +0 -1
- package/dist/lib/hooks/useInfiniteScroll.d.ts +0 -22
- package/dist/lib/hooks/useInfiniteScroll.js +0 -98
- package/dist/lib/hooks/useInfiniteScroll.js.map +0 -1
- package/src/components/Grid/index.tsx +0 -126
- package/src/components/Grid/styles.ts +0 -3
- package/src/components/Grid/types.ts +0 -13
- package/src/components/List/ListLayout.tsx +0 -87
- package/src/components/Pager/index.tsx +0 -156
- package/src/components/Pager/types.ts +0 -35
- package/src/components/TextInput/mask.tsx +0 -117
- package/src/lib/deprecated/OSAlert.tsx +0 -200
- package/src/lib/deprecated/index.ts +0 -6
- package/src/lib/hooks/useInfiniteScroll.ts +0 -77
- /package/dist/components/{Grid → Carousel}/styles.js +0 -0
- /package/dist/components/{Grid → Carousel}/types.js +0 -0
- /package/dist/components/{Pager → MaskedTextInput}/types.js +0 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { onUpdate } from '@codeleap/hooks'
|
|
2
|
+
import React, { forwardRef, useCallback, useImperativeHandle, useEffect, useState, useMemo } from 'react'
|
|
3
|
+
import useEmblaCarousel from 'embla-carousel-react'
|
|
4
|
+
import Autoplay from 'embla-carousel-autoplay'
|
|
5
|
+
import type { EmblaCarouselType } from 'embla-carousel'
|
|
6
|
+
import { View } from '../View'
|
|
7
|
+
import { Touchable } from '../Touchable'
|
|
8
|
+
import { DotsProps, CarouselProps, CarouselRef } from './types'
|
|
9
|
+
import { AnyRecord, IJSX, StyledComponentProps, StyledComponentWithProps } from '@codeleap/styles'
|
|
10
|
+
import { WebStyleRegistry } from '../../lib/WebStyleRegistry'
|
|
11
|
+
import { useStylesFor } from '../../lib/hooks/useStylesFor'
|
|
12
|
+
|
|
13
|
+
export * from './styles'
|
|
14
|
+
export * from './types'
|
|
15
|
+
|
|
16
|
+
const Dots = (params: DotsProps) => {
|
|
17
|
+
const { page, childArray, onPress, styles, dotsDisabled } = params
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<View style={styles.dots}>
|
|
21
|
+
{childArray.map((_, index) => {
|
|
22
|
+
const isSelected = index === page
|
|
23
|
+
|
|
24
|
+
const style = [
|
|
25
|
+
styles.dot,
|
|
26
|
+
isSelected && styles['dot:selected'],
|
|
27
|
+
dotsDisabled && styles['dot:disabled'],
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Touchable
|
|
32
|
+
key={index}
|
|
33
|
+
onPress={() => onPress?.(index)}
|
|
34
|
+
style={style}
|
|
35
|
+
disabled={dotsDisabled}
|
|
36
|
+
debugName='dots'
|
|
37
|
+
/>
|
|
38
|
+
)
|
|
39
|
+
})}
|
|
40
|
+
</View>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const Carousel = forwardRef<CarouselRef, CarouselProps>((props, ref) => {
|
|
45
|
+
const {
|
|
46
|
+
style,
|
|
47
|
+
children,
|
|
48
|
+
renderSlideWrapper: SlideWrapper,
|
|
49
|
+
page,
|
|
50
|
+
dots,
|
|
51
|
+
dotsDisabled,
|
|
52
|
+
infinite,
|
|
53
|
+
disableSwipe,
|
|
54
|
+
onChange,
|
|
55
|
+
footer,
|
|
56
|
+
dotsProps,
|
|
57
|
+
slideWrapperProps,
|
|
58
|
+
autoplay,
|
|
59
|
+
autoplayDelay,
|
|
60
|
+
spaceBetween,
|
|
61
|
+
slidesPerView,
|
|
62
|
+
...rest
|
|
63
|
+
} = {
|
|
64
|
+
...Carousel.defaultProps,
|
|
65
|
+
...props,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const styles = useStylesFor(Carousel.styleRegistryName, style)
|
|
69
|
+
const childArray = React.Children.toArray(children)
|
|
70
|
+
|
|
71
|
+
const [currentIndex, setCurrentIndex] = useState(0)
|
|
72
|
+
|
|
73
|
+
const plugins = useMemo(() => {
|
|
74
|
+
const pluginList = []
|
|
75
|
+
if (autoplay) {
|
|
76
|
+
pluginList.push(Autoplay({ delay: autoplayDelay, stopOnInteraction: false }))
|
|
77
|
+
}
|
|
78
|
+
return pluginList
|
|
79
|
+
}, [autoplay, autoplayDelay])
|
|
80
|
+
|
|
81
|
+
const [emblaRef, emblaApi] = useEmblaCarousel(
|
|
82
|
+
{
|
|
83
|
+
loop: infinite,
|
|
84
|
+
dragFree: false,
|
|
85
|
+
containScroll: 'trimSnaps',
|
|
86
|
+
align: 'start',
|
|
87
|
+
slidesToScroll: 1,
|
|
88
|
+
...(disableSwipe && { watchDrag: false }),
|
|
89
|
+
},
|
|
90
|
+
plugins,
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
const goTo = useCallback(
|
|
94
|
+
(index: number) => {
|
|
95
|
+
if (emblaApi) {
|
|
96
|
+
emblaApi.scrollTo(index)
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
[emblaApi],
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
const next = useCallback(() => {
|
|
103
|
+
if (emblaApi) {
|
|
104
|
+
emblaApi.scrollNext()
|
|
105
|
+
}
|
|
106
|
+
}, [emblaApi])
|
|
107
|
+
|
|
108
|
+
const prev = useCallback(() => {
|
|
109
|
+
if (emblaApi) {
|
|
110
|
+
emblaApi.scrollPrev()
|
|
111
|
+
}
|
|
112
|
+
}, [emblaApi])
|
|
113
|
+
|
|
114
|
+
useImperativeHandle(
|
|
115
|
+
ref,
|
|
116
|
+
() => ({
|
|
117
|
+
goTo,
|
|
118
|
+
next,
|
|
119
|
+
prev,
|
|
120
|
+
emblaApi,
|
|
121
|
+
}),
|
|
122
|
+
[goTo, next, prev, emblaApi],
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (!emblaApi) return
|
|
127
|
+
|
|
128
|
+
const onSelect = () => {
|
|
129
|
+
const index = emblaApi.selectedScrollSnap()
|
|
130
|
+
setCurrentIndex(index)
|
|
131
|
+
onChange?.(index)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
emblaApi.on('select', onSelect)
|
|
135
|
+
onSelect()
|
|
136
|
+
|
|
137
|
+
return () => {
|
|
138
|
+
emblaApi.off('select', onSelect)
|
|
139
|
+
}
|
|
140
|
+
}, [emblaApi, onChange])
|
|
141
|
+
|
|
142
|
+
onUpdate(() => {
|
|
143
|
+
if (page !== undefined && page !== currentIndex && emblaApi) {
|
|
144
|
+
goTo(page)
|
|
145
|
+
}
|
|
146
|
+
}, [page])
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<View style={styles.wrapper}>
|
|
150
|
+
<View
|
|
151
|
+
ref={emblaRef}
|
|
152
|
+
style={{
|
|
153
|
+
overflow: 'hidden',
|
|
154
|
+
}}
|
|
155
|
+
>
|
|
156
|
+
<View
|
|
157
|
+
style={{
|
|
158
|
+
display: 'flex',
|
|
159
|
+
flexDirection: 'row',
|
|
160
|
+
gap: spaceBetween,
|
|
161
|
+
}}
|
|
162
|
+
>
|
|
163
|
+
{childArray.map((child, index) => {
|
|
164
|
+
return (
|
|
165
|
+
<View
|
|
166
|
+
key={index}
|
|
167
|
+
style={{
|
|
168
|
+
flex: slidesPerView === 1 ? '0 0 100%' : slidesPerView === 'auto' ? '0 0 auto' : `0 0 ${100 / slidesPerView}%`,
|
|
169
|
+
minWidth: 0,
|
|
170
|
+
}}
|
|
171
|
+
>
|
|
172
|
+
<SlideWrapper
|
|
173
|
+
style={styles.slideWrapper}
|
|
174
|
+
{...slideWrapperProps}
|
|
175
|
+
>
|
|
176
|
+
{child}
|
|
177
|
+
</SlideWrapper>
|
|
178
|
+
</View>
|
|
179
|
+
)
|
|
180
|
+
})}
|
|
181
|
+
</View>
|
|
182
|
+
</View>
|
|
183
|
+
|
|
184
|
+
<View style={styles.footerWrapper}>
|
|
185
|
+
{footer}
|
|
186
|
+
|
|
187
|
+
{dots ? (
|
|
188
|
+
<Dots
|
|
189
|
+
page={currentIndex}
|
|
190
|
+
onPress={goTo}
|
|
191
|
+
childArray={childArray}
|
|
192
|
+
styles={styles}
|
|
193
|
+
dotsDisabled={dotsDisabled}
|
|
194
|
+
{...dotsProps}
|
|
195
|
+
/>
|
|
196
|
+
) : null}
|
|
197
|
+
</View>
|
|
198
|
+
</View>
|
|
199
|
+
)
|
|
200
|
+
}) as StyledComponentWithProps<CarouselProps>
|
|
201
|
+
|
|
202
|
+
Carousel.styleRegistryName = 'Carousel'
|
|
203
|
+
|
|
204
|
+
Carousel.elements = [
|
|
205
|
+
'wrapper',
|
|
206
|
+
'dot',
|
|
207
|
+
'dots',
|
|
208
|
+
'slideWrapper',
|
|
209
|
+
'footerWrapper',
|
|
210
|
+
]
|
|
211
|
+
|
|
212
|
+
Carousel.rootElement = 'wrapper'
|
|
213
|
+
|
|
214
|
+
Carousel.withVariantTypes = <S extends AnyRecord>(styles: S) => {
|
|
215
|
+
return Carousel as (props: StyledComponentProps<CarouselProps, typeof styles>) => IJSX
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
Carousel.defaultProps = {
|
|
219
|
+
dots: false,
|
|
220
|
+
dotsDisabled: false,
|
|
221
|
+
infinite: false,
|
|
222
|
+
disableSwipe: false,
|
|
223
|
+
renderSlideWrapper: View,
|
|
224
|
+
autoplay: false,
|
|
225
|
+
autoplayDelay: 3000,
|
|
226
|
+
spaceBetween: 0,
|
|
227
|
+
slidesPerView: 1,
|
|
228
|
+
} as Partial<CarouselProps>
|
|
229
|
+
|
|
230
|
+
WebStyleRegistry.registerComponent(Carousel)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { StylesOf } from '@codeleap/types'
|
|
2
|
+
import { CarouselComposition } from './styles'
|
|
3
|
+
import React, { ReactNode, ReactElement } from 'react'
|
|
4
|
+
import { ViewProps } from '../View'
|
|
5
|
+
import { ComponentCommonProps } from '../../types'
|
|
6
|
+
import { StyledProp } from '@codeleap/styles'
|
|
7
|
+
|
|
8
|
+
export type CarouselRef = {
|
|
9
|
+
goTo: (index: number) => void
|
|
10
|
+
next: () => void
|
|
11
|
+
prev: () => void
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type CarouselProps =
|
|
15
|
+
ComponentCommonProps &
|
|
16
|
+
{
|
|
17
|
+
style?: StyledProp<CarouselComposition>
|
|
18
|
+
page?: number
|
|
19
|
+
children: ReactNode
|
|
20
|
+
onChange?: (index: number) => void
|
|
21
|
+
renderSlideWrapper?: any
|
|
22
|
+
footer?: ReactElement
|
|
23
|
+
dotsProps?: DotsProps
|
|
24
|
+
slideWrapperProps?: ViewProps
|
|
25
|
+
dotsDisabled?: boolean
|
|
26
|
+
disableSwipe?: boolean
|
|
27
|
+
dots?: boolean
|
|
28
|
+
infinite?: boolean
|
|
29
|
+
autoplay?: boolean
|
|
30
|
+
autoplayDelay?: number
|
|
31
|
+
spaceBetween?: number
|
|
32
|
+
slidesPerView?: number | 'auto'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type DotsProps =
|
|
36
|
+
Pick<CarouselProps, 'page' | 'dotsDisabled'> &
|
|
37
|
+
{
|
|
38
|
+
childArray: ReactNode[]
|
|
39
|
+
onPress?: (index: number) => void
|
|
40
|
+
styles: StylesOf<CarouselComposition>
|
|
41
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InputBase, InputBaseDefaultOrder, selectInputBaseProps } from '../InputBase'
|
|
2
2
|
import { useAnimatedVariantStyles } from '../..'
|
|
3
3
|
import { Icon } from '../Icon'
|
|
4
|
-
import { motion } from '
|
|
4
|
+
import { motion } from 'motion/react'
|
|
5
5
|
import { CheckboxProps } from './types'
|
|
6
6
|
import { useStylesFor } from '../../lib/hooks/useStylesFor'
|
|
7
7
|
import { AnyRecord, AppIcon, IJSX, mergeStyles, StyledComponentProps } from '@codeleap/styles'
|
|
@@ -2,7 +2,7 @@ import { CollapseProps } from './types'
|
|
|
2
2
|
import { useStylesFor } from '../../lib/hooks/useStylesFor'
|
|
3
3
|
import { AnyRecord, IJSX, StyledComponentProps } from '@codeleap/styles'
|
|
4
4
|
import { WebStyleRegistry } from '../../lib/WebStyleRegistry'
|
|
5
|
-
import { motion } from '
|
|
5
|
+
import { motion } from 'motion/react'
|
|
6
6
|
|
|
7
7
|
export * from './styles'
|
|
8
8
|
export * from './types'
|
|
@@ -30,9 +30,9 @@ export type ColorPickerProps = {
|
|
|
30
30
|
openPickerProps?: ActionIconProps
|
|
31
31
|
onConfirm?: (color: ColorTypes) => void
|
|
32
32
|
onClear?: () => void
|
|
33
|
-
openPickerComponent?: (props: ColorPickerPickerProps) =>
|
|
34
|
-
pickerComponent?: (props: any) =>
|
|
35
|
-
footerComponent?: (props: ColorPickerFooterProps) =>
|
|
33
|
+
openPickerComponent?: (props: ColorPickerPickerProps) => React.ReactElement
|
|
34
|
+
pickerComponent?: (props: any) => React.ReactElement
|
|
35
|
+
footerComponent?: (props: ColorPickerFooterProps) => React.ReactElement
|
|
36
36
|
visible?: boolean
|
|
37
37
|
toggle?: React.Dispatch<React.SetStateAction<boolean>>
|
|
38
38
|
children?: React.ReactNode
|
|
@@ -17,7 +17,7 @@ import 'react-image-crop/dist/ReactCrop.css'
|
|
|
17
17
|
export * from './styles'
|
|
18
18
|
export * from './types'
|
|
19
19
|
|
|
20
|
-
export const CropPicker =
|
|
20
|
+
export const CropPicker = (props: CropPickerProps) => {
|
|
21
21
|
const {
|
|
22
22
|
onFileSelect,
|
|
23
23
|
targetCrop,
|
|
@@ -29,6 +29,7 @@ export const CropPicker = forwardRef<FileInputRef, CropPickerProps>((props, ref)
|
|
|
29
29
|
withLoading,
|
|
30
30
|
style,
|
|
31
31
|
confirmButtonProps,
|
|
32
|
+
ref,
|
|
32
33
|
...fileInputProps
|
|
33
34
|
} = {
|
|
34
35
|
...CropPicker.defaultProps,
|
|
@@ -87,7 +88,7 @@ export const CropPicker = forwardRef<FileInputRef, CropPickerProps>((props, ref)
|
|
|
87
88
|
>
|
|
88
89
|
<img
|
|
89
90
|
src={image?.src}
|
|
90
|
-
// @ts-
|
|
91
|
+
// @ts-ignore
|
|
91
92
|
css={[styles.cropPreview, styles.previewSize]}
|
|
92
93
|
/>
|
|
93
94
|
</ReactCrop>
|
|
@@ -96,7 +97,7 @@ export const CropPicker = forwardRef<FileInputRef, CropPickerProps>((props, ref)
|
|
|
96
97
|
</Modal>
|
|
97
98
|
</>
|
|
98
99
|
)
|
|
99
|
-
}
|
|
100
|
+
}
|
|
100
101
|
|
|
101
102
|
CropPicker.styleRegistryName = 'CropPicker'
|
|
102
103
|
CropPicker.elements = ['previewSize', 'cropPreview', 'confirmButton', 'modal']
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { StyledProp } from '@codeleap/styles'
|
|
2
|
-
import { FileInputProps } from '../FileInput'
|
|
2
|
+
import { FileInputProps, FileInputRef } from '../FileInput'
|
|
3
3
|
import { CropPickerComposition } from './styles'
|
|
4
4
|
import { ReactCropProps } from 'react-image-crop'
|
|
5
5
|
import { ModalProps } from '../Modal'
|
|
6
6
|
import { useCropPicker } from '../../lib'
|
|
7
7
|
import { ButtonProps } from '../Button'
|
|
8
|
+
import { RefObject } from 'react'
|
|
8
9
|
|
|
9
10
|
export type BaseCropProps = Partial<ReactCropProps>
|
|
10
11
|
|
|
@@ -20,6 +21,7 @@ export type CropPickerProps =
|
|
|
20
21
|
handle?: ReturnType<typeof useCropPicker>
|
|
21
22
|
withLoading?: boolean
|
|
22
23
|
confirmButtonProps?: Partial<ButtonProps>
|
|
24
|
+
ref?: RefObject<FileInputRef | null>
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
export type ImageReading = HTMLImageElement
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TextInput } from '../../components'
|
|
2
2
|
import { DatePickerProps } from '../types'
|
|
3
3
|
|
|
4
|
-
export const OuterInput: DatePickerProps['outerInputComponent'] = ({ hideInput, ...props }) => {
|
|
4
|
+
export const OuterInput: DatePickerProps['outerInputComponent'] = ({ hideInput, onChange, value, ...props }) => {
|
|
5
5
|
if (hideInput) {
|
|
6
6
|
return null
|
|
7
7
|
}
|
|
@@ -9,18 +9,9 @@ export const OuterInput: DatePickerProps['outerInputComponent'] = ({ hideInput,
|
|
|
9
9
|
return (
|
|
10
10
|
<TextInput
|
|
11
11
|
debugName='DatePicker - OuterInputComponent'
|
|
12
|
-
masking={{
|
|
13
|
-
type: 'custom',
|
|
14
|
-
options: {
|
|
15
|
-
mask: 'xx/xx/xxxx',
|
|
16
|
-
placeholder: props.placeholder,
|
|
17
|
-
formatChars: {
|
|
18
|
-
x: '[0123456789]',
|
|
19
|
-
},
|
|
20
|
-
maskChar: '',
|
|
21
|
-
},
|
|
22
|
-
}}
|
|
23
12
|
{...props}
|
|
13
|
+
value={value}
|
|
14
|
+
onChangeText={onChange}
|
|
24
15
|
/>
|
|
25
16
|
)
|
|
26
17
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { useCallback, useConditionalState } from '@codeleap/hooks'
|
|
2
2
|
import { View } from '../components'
|
|
3
3
|
import { DatePickerProps } from './types'
|
|
4
|
-
import ReactDatePicker from 'react-datepicker'
|
|
4
|
+
import { DatePicker as ReactDatePicker } from 'react-datepicker'
|
|
5
5
|
import { DayContent, Header, OuterInput, YearContent } from './components'
|
|
6
6
|
import { useStylesFor } from '../../lib/hooks/useStylesFor'
|
|
7
7
|
import { WebStyleRegistry } from '../../lib/WebStyleRegistry'
|
|
8
8
|
import { AnyRecord, IJSX, StyledComponentProps, useCompositionStyles } from '@codeleap/styles'
|
|
9
|
+
import { useInputBase } from '../InputBase/useInputBase'
|
|
10
|
+
import { fields } from '@codeleap/form'
|
|
9
11
|
|
|
10
12
|
export * from './styles'
|
|
11
13
|
export * from './types'
|
|
@@ -16,6 +18,7 @@ export function DatePicker(props: DatePickerProps) {
|
|
|
16
18
|
hideInput,
|
|
17
19
|
value,
|
|
18
20
|
onValueChange,
|
|
21
|
+
field,
|
|
19
22
|
style,
|
|
20
23
|
defaultValue,
|
|
21
24
|
outerInputComponent: OuterInputComponent,
|
|
@@ -47,44 +50,49 @@ export function DatePicker(props: DatePickerProps) {
|
|
|
47
50
|
const [visible, toggle] = useConditionalState(providedVisible, providedToggle, { initialValue: false })
|
|
48
51
|
const [yearShow, setYearShow] = useConditionalState(providedYearShow, providedSetYearShow, { initialValue: false })
|
|
49
52
|
|
|
53
|
+
const {
|
|
54
|
+
inputValue,
|
|
55
|
+
onInputValueChange,
|
|
56
|
+
} = useInputBase(field, fields.date, { value, onValueChange })
|
|
57
|
+
|
|
50
58
|
const DayContentComponent = useCallback(({ day, date }) => {
|
|
51
59
|
return (
|
|
52
60
|
<DayContent
|
|
53
61
|
day={day}
|
|
54
62
|
date={date}
|
|
55
63
|
{...providedDayProps}
|
|
56
|
-
value={
|
|
64
|
+
value={inputValue}
|
|
57
65
|
minDate={minDate}
|
|
58
66
|
maxDate={maxDate}
|
|
59
67
|
component={dayComponent}
|
|
60
68
|
styles={styles}
|
|
61
69
|
/>
|
|
62
70
|
)
|
|
63
|
-
}, [
|
|
71
|
+
}, [inputValue])
|
|
64
72
|
|
|
65
73
|
const YearContentComponent = useCallback(({ year }) => {
|
|
66
74
|
return (
|
|
67
75
|
<YearContent
|
|
68
76
|
year={year}
|
|
69
77
|
{...providedYearProps}
|
|
70
|
-
value={
|
|
78
|
+
value={inputValue}
|
|
71
79
|
component={yearComponent}
|
|
72
80
|
styles={styles}
|
|
73
81
|
/>
|
|
74
82
|
)
|
|
75
|
-
}, [
|
|
83
|
+
}, [inputValue])
|
|
76
84
|
|
|
77
85
|
return (
|
|
78
86
|
<View style={styles.wrapper}>
|
|
79
87
|
<ReactDatePicker
|
|
80
|
-
onChange={
|
|
88
|
+
onChange={(date) => onInputValueChange(date as any)}
|
|
89
|
+
selected={inputValue}
|
|
81
90
|
open={visible}
|
|
82
|
-
selected={value}
|
|
83
91
|
todayButton={null}
|
|
84
92
|
shouldCloseOnSelect={false}
|
|
85
|
-
openToDate={defaultValue ??
|
|
93
|
+
openToDate={defaultValue ?? inputValue}
|
|
86
94
|
dateFormat='dd/MM/yyyy'
|
|
87
|
-
formatWeekDay={(
|
|
95
|
+
formatWeekDay={(day) => day.charAt(0)}
|
|
88
96
|
calendarStartDay={1}
|
|
89
97
|
placeholderText={otherProps?.placeholder}
|
|
90
98
|
disabled={disabled}
|
|
@@ -130,7 +138,7 @@ export function DatePicker(props: DatePickerProps) {
|
|
|
130
138
|
if (date.getFullYear() < startDate.getFullYear() || date.getFullYear() > maxDate.getFullYear()) return false
|
|
131
139
|
return true
|
|
132
140
|
}}
|
|
133
|
-
{...datePickerProps}
|
|
141
|
+
{...datePickerProps as any}
|
|
134
142
|
/>
|
|
135
143
|
</View>
|
|
136
144
|
)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { StylesOf } from '@codeleap/types'
|
|
2
|
-
import { ReactDatePickerCustomHeaderProps, ReactDatePickerProps } from 'react-datepicker'
|
|
1
|
+
import { AnyFunction, StylesOf } from '@codeleap/types'
|
|
2
|
+
import { ReactDatePickerCustomHeaderProps, DatePickerProps as ReactDatePickerProps } from 'react-datepicker'
|
|
3
3
|
import { ActionIconProps, TextInputProps } from '../components'
|
|
4
4
|
import { DatePickerComposition, DatePickerHeaderComposition } from './styles'
|
|
5
5
|
import { StyledProp } from '@codeleap/styles'
|
|
6
|
+
import { DateField } from '@codeleap/form'
|
|
6
7
|
|
|
7
8
|
export type DatePickerOuterInputProps = TextInputProps & {
|
|
8
9
|
valueLabel: React.ReactNode
|
|
@@ -12,6 +13,7 @@ export type DatePickerOuterInputProps = TextInputProps & {
|
|
|
12
13
|
export type DatePickerHeaderComponent = Omit<ReactDatePickerCustomHeaderProps, 'styles'> & {
|
|
13
14
|
styles?: StylesOf<DatePickerHeaderComposition>
|
|
14
15
|
formatHeaderTitle?: (date: Date) => string
|
|
16
|
+
setYearShow?: AnyFunction
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
export type DatePickerArrowProps = Partial<ActionIconProps> & {
|
|
@@ -38,7 +40,7 @@ type RootDatePickerProps = 'startDate' | 'minDate' | 'maxDate'
|
|
|
38
40
|
|
|
39
41
|
export type DatePickerProps =
|
|
40
42
|
Omit<Partial<Pick<Partial<ReactDatePickerProps>, RootDatePickerProps>>, 'style'> &
|
|
41
|
-
Omit<TextInputProps, 'defaultValue' | 'style'> &
|
|
43
|
+
Omit<TextInputProps, 'defaultValue' | 'style' | 'value' | 'onValueChange'> &
|
|
42
44
|
{
|
|
43
45
|
style?: StyledProp<DatePickerComposition>
|
|
44
46
|
hideInput?: boolean
|
|
@@ -56,6 +58,7 @@ export type DatePickerProps =
|
|
|
56
58
|
toggle?: () => void
|
|
57
59
|
yearShow?: boolean
|
|
58
60
|
setYearShow?: () => void
|
|
59
|
-
value
|
|
60
|
-
onValueChange
|
|
61
|
+
value?: Date
|
|
62
|
+
onValueChange?: (value: Date) => void
|
|
63
|
+
field?: DateField<any>
|
|
61
64
|
}
|
|
@@ -109,7 +109,7 @@ const FilePreview = (props: DropzoneFilePreviewProps) => {
|
|
|
109
109
|
)
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
export const Dropzone =
|
|
112
|
+
export const Dropzone = (props: DropzoneProps) => {
|
|
113
113
|
const {
|
|
114
114
|
icon,
|
|
115
115
|
placeholder,
|
|
@@ -126,6 +126,7 @@ export const Dropzone = forwardRef<DropzoneRef, DropzoneProps>((props, ref) => {
|
|
|
126
126
|
children,
|
|
127
127
|
FilePreviewComponent,
|
|
128
128
|
style,
|
|
129
|
+
ref,
|
|
129
130
|
...rest
|
|
130
131
|
} = {
|
|
131
132
|
...Dropzone.defaultProps,
|
|
@@ -221,7 +222,7 @@ export const Dropzone = forwardRef<DropzoneRef, DropzoneProps>((props, ref) => {
|
|
|
221
222
|
<input {...getInputProps() as HTMLProps<HTMLInputElement>} />
|
|
222
223
|
</View>
|
|
223
224
|
</View>)
|
|
224
|
-
}
|
|
225
|
+
}
|
|
225
226
|
|
|
226
227
|
Dropzone.styleRegistryName = 'Dropzone'
|
|
227
228
|
|
|
@@ -3,6 +3,7 @@ import { DropzoneComposition } from './styles'
|
|
|
3
3
|
import { DropzoneOptions, FileRejection, DropzoneRef as ReactDropzoneRef } from 'react-dropzone'
|
|
4
4
|
import { ActionIconComposition } from '../ActionIcon'
|
|
5
5
|
import { AppIcon, StyledProp } from '@codeleap/styles'
|
|
6
|
+
import { RefObject } from 'react'
|
|
6
7
|
|
|
7
8
|
export type DropzoneFile = File
|
|
8
9
|
|
|
@@ -23,7 +24,8 @@ export type DropzoneProps =
|
|
|
23
24
|
fileRightIcon?: AppIcon
|
|
24
25
|
fileLeftIcon?: AppIcon
|
|
25
26
|
withImagePreview?: boolean
|
|
26
|
-
FilePreviewComponent?: (props: DropzoneInnerFilePreviewProps) =>
|
|
27
|
+
FilePreviewComponent?: (props: DropzoneInnerFilePreviewProps) => React.ReactElement
|
|
28
|
+
ref?: RefObject<DropzoneRef | null>
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
export type DropzoneFilePreviewProps =
|
|
@@ -20,12 +20,12 @@ export type EmptyPlaceholderProps =
|
|
|
20
20
|
itemName?: string
|
|
21
21
|
title?: React.ReactElement | string
|
|
22
22
|
description?: React.ReactElement | string
|
|
23
|
-
icon?: AppIcon | ((props: EmptyPlaceholderProps) =>
|
|
23
|
+
icon?: AppIcon | ((props: EmptyPlaceholderProps) => React.ReactElement)
|
|
24
24
|
image?: string
|
|
25
25
|
imageProps?: ImgHTMLAttributes<HTMLImageElement>
|
|
26
26
|
loading?: boolean
|
|
27
27
|
style?: StyledProp<EmptyPlaceholderComposition>
|
|
28
|
-
renderEmpty?: (props: RenderEmptyProps) =>
|
|
28
|
+
renderEmpty?: (props: RenderEmptyProps) => React.ReactElement
|
|
29
29
|
wrapperProps?: ViewProps
|
|
30
30
|
imageWrapperProps?: ViewProps
|
|
31
31
|
indicatorProps?: Partial<ActivityIndicatorProps>
|
|
@@ -5,20 +5,21 @@ import { FileInputProps, FileInputRef } from './types'
|
|
|
5
5
|
|
|
6
6
|
export * from './types'
|
|
7
7
|
|
|
8
|
-
export const FileInput =
|
|
8
|
+
export const FileInput = (props: FileInputProps) => {
|
|
9
9
|
const inputRef = useRef<HTMLInputElement>(null)
|
|
10
10
|
|
|
11
11
|
const {
|
|
12
12
|
onFileSelect,
|
|
13
13
|
autoClear,
|
|
14
14
|
onChange,
|
|
15
|
+
ref,
|
|
15
16
|
...inputProps
|
|
16
17
|
} = {
|
|
17
18
|
...FileInput.defaultProps,
|
|
18
19
|
...props,
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
const resolveWithFile = useRef<(file: WebInputFile[]) => any>()
|
|
22
|
+
const resolveWithFile = useRef<(file: WebInputFile[]) => any>(undefined)
|
|
22
23
|
|
|
23
24
|
const clearInput = useCallback(() => {
|
|
24
25
|
if (!inputRef.current) return
|
|
@@ -66,7 +67,7 @@ export const FileInput = forwardRef<FileInputRef, FileInputProps>((props, ref) =
|
|
|
66
67
|
onChange={handleChange}
|
|
67
68
|
/>
|
|
68
69
|
)
|
|
69
|
-
}
|
|
70
|
+
}
|
|
70
71
|
|
|
71
72
|
FileInput.defaultProps = {
|
|
72
73
|
autoClear: true,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { WebInputFile } from '@codeleap/types'
|
|
2
2
|
import { HTMLProps } from '../../types'
|
|
3
|
+
import { RefObject } from 'react'
|
|
3
4
|
|
|
4
5
|
export type FileInputRef = {
|
|
5
6
|
openFilePicker: () => Promise<WebInputFile[]>
|
|
@@ -11,4 +12,5 @@ export type FileInputProps =
|
|
|
11
12
|
{
|
|
12
13
|
onFileSelect?: (files: WebInputFile[]) => void
|
|
13
14
|
autoClear?: boolean
|
|
15
|
+
ref?: RefObject<FileInputRef | null>
|
|
14
16
|
}
|
|
@@ -14,7 +14,7 @@ export function useInputBase<V, T extends Field<V, any, any, unknown> = Field<V
|
|
|
14
14
|
|
|
15
15
|
const hasInternalState = useMemo(() => TypeGuards.isFunction(onValueChange) && !TypeGuards.isNil(value), [])
|
|
16
16
|
|
|
17
|
-
const wrapperRef = useRef<HTMLDivElement>()
|
|
17
|
+
const wrapperRef = useRef<HTMLDivElement>(undefined)
|
|
18
18
|
|
|
19
19
|
const innerInputRef = useRef<HTMLInputElement>(null)
|
|
20
20
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IconState, IconStyles, InputBaseKey, InputBaseProps, OmitDiff } from './types'
|
|
2
2
|
|
|
3
|
-
export function selectInputBaseProps<T extends Omit<InputBaseProps, 'style'>>(props: T): {
|
|
3
|
+
export function selectInputBaseProps<T extends Omit<InputBaseProps, 'style' | 'ref'>>(props: T): {
|
|
4
4
|
inputBaseProps: InputBaseProps
|
|
5
5
|
others: OmitDiff<T, T>
|
|
6
6
|
} {
|