@codeleap/web 3.1.1 → 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,8 +1,12 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react'
|
|
3
|
+
|
|
1
4
|
import {
|
|
2
5
|
AnyFunction,
|
|
3
6
|
ComponentVariants,
|
|
4
7
|
IconPlaceholder,
|
|
5
8
|
onUpdate,
|
|
9
|
+
TypeGuards,
|
|
6
10
|
useDefaultComponentStyle,
|
|
7
11
|
} from '@codeleap/common'
|
|
8
12
|
import { CSSObject } from '@emotion/react'
|
|
@@ -13,6 +17,7 @@ import { Text } from '../Text'
|
|
|
13
17
|
import { Button } from '../Button'
|
|
14
18
|
import { StylesOf } from '../../types/utility'
|
|
15
19
|
import { DrawerComposition, DrawerPresets } from './styles'
|
|
20
|
+
import { ActionIcon } from '../ActionIcon'
|
|
16
21
|
|
|
17
22
|
const axisMap = {
|
|
18
23
|
top: [-1, 'Y'],
|
|
@@ -54,7 +59,7 @@ const resolveHiddenDrawerPosition = (
|
|
|
54
59
|
return [css, translateAxis, positioning]
|
|
55
60
|
}
|
|
56
61
|
|
|
57
|
-
export const Drawer
|
|
62
|
+
export const Drawer = ({ ...rawProps }:DrawerProps) => {
|
|
58
63
|
const {
|
|
59
64
|
open,
|
|
60
65
|
toggle,
|
|
@@ -119,21 +124,24 @@ export const Drawer: React.FC<DrawerProps> = ({ ...rawProps }) => {
|
|
|
119
124
|
...variantStyles.box,
|
|
120
125
|
}}
|
|
121
126
|
>
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
127
|
+
{
|
|
128
|
+
!TypeGuards.isNil(title) || showCloseButton && (
|
|
129
|
+
<View
|
|
130
|
+
component='header'
|
|
131
|
+
variants={['justifySpaceBetween']}
|
|
132
|
+
css={variantStyles.header}
|
|
133
|
+
>
|
|
134
|
+
{typeof title === 'string' ? <Text text={title} /> : title}
|
|
135
|
+
{showCloseButton && (
|
|
136
|
+
<ActionIcon
|
|
137
|
+
onPress={toggle}
|
|
138
|
+
icon={'close' as IconPlaceholder}
|
|
139
|
+
css={variantStyles.headerCloseButton}
|
|
140
|
+
/>
|
|
141
|
+
)}
|
|
142
|
+
</View>
|
|
143
|
+
)
|
|
144
|
+
}
|
|
137
145
|
<View css={variantStyles.body}>{children}</View>
|
|
138
146
|
{footer && (
|
|
139
147
|
<View component='footer' css={variantStyles.footer}>
|
|
@@ -145,4 +153,4 @@ export const Drawer: React.FC<DrawerProps> = ({ ...rawProps }) => {
|
|
|
145
153
|
)
|
|
146
154
|
}
|
|
147
155
|
|
|
148
|
-
export * from './styles'
|
|
156
|
+
export * from './styles'
|
|
@@ -1,51 +1,79 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx, CSSObject } from '@emotion/react'
|
|
1
3
|
import React, {
|
|
2
|
-
ComponentPropsWithoutRef,
|
|
3
4
|
useImperativeHandle,
|
|
4
5
|
useRef,
|
|
5
6
|
} from 'react'
|
|
6
7
|
import { WebInputFile } from '@codeleap/common'
|
|
8
|
+
import { HTMLProps } from '../types'
|
|
7
9
|
|
|
8
10
|
export type FileInputRef = {
|
|
9
|
-
openFilePicker: () =>
|
|
11
|
+
openFilePicker: () => Promise<WebInputFile[]>
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
export type FileInputProps = Omit<
|
|
13
|
-
onFileSelect(files: WebInputFile[])
|
|
14
|
+
export type FileInputProps = Omit<HTMLProps<'input'>, 'type'|'ref'> & {
|
|
15
|
+
onFileSelect?: (files: WebInputFile[]) => void
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
export const
|
|
17
|
-
|
|
18
|
-
const inputRef = useRef<HTMLInputElement>(null)
|
|
18
|
+
export const _FileInput = (inputProps: FileInputProps, ref:React.Ref<FileInputRef>) => {
|
|
19
|
+
const inputRef = useRef<HTMLInputElement>(null)
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
const { onFileSelect, ...props } = inputProps
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const resolveWithFile = useRef<(file:WebInputFile[]) => any>()
|
|
24
|
+
|
|
25
|
+
useImperativeHandle(ref, () => ({
|
|
26
|
+
openFilePicker: () => {
|
|
27
|
+
inputRef.current.click()
|
|
28
|
+
|
|
29
|
+
return new Promise<WebInputFile[]>((resolve) => {
|
|
30
|
+
resolveWithFile.current = resolve
|
|
31
|
+
})
|
|
32
|
+
},
|
|
33
|
+
}))
|
|
27
34
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
function handleChange(e: React.ChangeEvent<HTMLInputElement>) {
|
|
36
|
+
if (!e.target.files.length) return
|
|
37
|
+
inputProps.onChange && inputProps.onChange(e)
|
|
38
|
+
const fileArray = Array.from(e.target?.files || []) as File[]
|
|
32
39
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
const files: WebInputFile[] = fileArray.map((obj) => ({
|
|
41
|
+
file: obj,
|
|
42
|
+
preview: URL.createObjectURL(obj),
|
|
43
|
+
}))
|
|
44
|
+
|
|
45
|
+
onFileSelect && onFileSelect(files)
|
|
37
46
|
|
|
38
|
-
|
|
47
|
+
if (resolveWithFile.current) {
|
|
48
|
+
resolveWithFile.current(files)
|
|
49
|
+
resolveWithFile.current = undefined
|
|
39
50
|
}
|
|
51
|
+
}
|
|
40
52
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
return (
|
|
54
|
+
<input
|
|
55
|
+
type={'file'}
|
|
56
|
+
css={{ visibility: 'hidden', width: 0, height: 0, opacity: 0, display: 'none' }}
|
|
57
|
+
{...props}
|
|
58
|
+
ref={inputRef}
|
|
59
|
+
onChange={handleChange}
|
|
60
|
+
/>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const FileInput = React.forwardRef<FileInputRef, FileInputProps>(_FileInput) as unknown as (
|
|
65
|
+
(props: FileInputProps & { ref?: React.MutableRefObject<FileInputRef> | React.Ref<FileInputRef> }) => JSX.Element
|
|
51
66
|
)
|
|
67
|
+
|
|
68
|
+
export const useFileInput = () => {
|
|
69
|
+
const inputRef = useRef<FileInputRef|null>(null)
|
|
70
|
+
|
|
71
|
+
const openFilePicker = () => {
|
|
72
|
+
return inputRef.current?.openFilePicker()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
openFilePicker,
|
|
77
|
+
ref: inputRef,
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
1
|
/** @jsx jsx */
|
|
3
2
|
import { CSSObject, jsx } from '@emotion/react'
|
|
3
|
+
import { CSSInterpolation } from '@emotion/css'
|
|
4
4
|
import {
|
|
5
5
|
ComponentVariants,
|
|
6
6
|
IconPlaceholder,
|
|
@@ -8,8 +8,7 @@ import {
|
|
|
8
8
|
useDefaultComponentStyle,
|
|
9
9
|
useCodeleapContext,
|
|
10
10
|
} from '@codeleap/common'
|
|
11
|
-
import { View
|
|
12
|
-
import { CSSInterpolation } from '@emotion/css'
|
|
11
|
+
import { View } from '../View'
|
|
13
12
|
|
|
14
13
|
export * from './styles'
|
|
15
14
|
|
|
@@ -17,11 +16,11 @@ export type IconProps = {
|
|
|
17
16
|
name: IconPlaceholder
|
|
18
17
|
style?: any
|
|
19
18
|
renderEmptySpace?: boolean
|
|
20
|
-
css?: Array<React.CSSProperties>
|
|
21
19
|
forceStyle?: CSSObject | CSSInterpolation | React.CSSProperties
|
|
20
|
+
css?: any
|
|
22
21
|
} & ComponentVariants<typeof IconStyles>
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
const IconCP = ({ name, style, variants, renderEmptySpace, ...otherProps }:IconProps) => {
|
|
25
24
|
const { Theme, logger } = useCodeleapContext()
|
|
26
25
|
const Component = Theme?.icons?.[name]
|
|
27
26
|
|
|
@@ -51,3 +50,5 @@ export const Icon: React.FC<IconProps> = ({ name, style, variants, renderEmptySp
|
|
|
51
50
|
}
|
|
52
51
|
return <Component css={variantStyles.icon} {...otherProps}/>
|
|
53
52
|
}
|
|
53
|
+
|
|
54
|
+
export const Icon = IconCP as ((props: IconProps) => jsx.JSX.Element)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react'
|
|
1
3
|
import React from 'react'
|
|
2
4
|
import { TypeGuards, getRenderedComponent } from '@codeleap/common'
|
|
3
5
|
import { ActionIcon, ActionIconProps } from '../ActionIcon'
|
|
@@ -17,7 +19,7 @@ export const InputBaseDefaultOrder:InputBaseProps['order'] = [
|
|
|
17
19
|
'error',
|
|
18
20
|
]
|
|
19
21
|
const KeyPassthrough = (props: React.PropsWithChildren<any>) => {
|
|
20
|
-
return
|
|
22
|
+
return <React.Fragment>{props.children}</React.Fragment>
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
export const InputBase = React.forwardRef<unknown, InputBaseProps>((props, ref) => {
|
|
@@ -38,6 +40,7 @@ export const InputBase = React.forwardRef<unknown, InputBaseProps>((props, ref)
|
|
|
38
40
|
disabled = false,
|
|
39
41
|
order = InputBaseDefaultOrder,
|
|
40
42
|
style,
|
|
43
|
+
noError = false,
|
|
41
44
|
labelAsRow = false,
|
|
42
45
|
innerWrapperRef,
|
|
43
46
|
...otherProps
|
|
@@ -81,9 +84,11 @@ export const InputBase = React.forwardRef<unknown, InputBaseProps>((props, ref)
|
|
|
81
84
|
{children}
|
|
82
85
|
{_rightIcon}
|
|
83
86
|
</InnerWrapperComponent>,
|
|
84
|
-
error:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
error: noError ? null : (
|
|
88
|
+
_error || <Text children={<React.Fragment>
|
|
89
|
+
|
|
90
|
+
</React.Fragment>} css={_styles.errorStyle}/>
|
|
91
|
+
),
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
return (
|
|
@@ -1,34 +1,47 @@
|
|
|
1
|
-
import { ComponentVariants, useDefaultComponentStyle } from
|
|
2
|
-
import React from
|
|
3
|
-
import { StylesOf } from
|
|
4
|
-
import { LoadingOverlayComposition, LoadingOverlayPresets } from
|
|
5
|
-
import {View} from '../View'
|
|
6
|
-
import { ActivityIndicator } from
|
|
1
|
+
import { ComponentVariants, getNestedStylesByKey, useDefaultComponentStyle } from '@codeleap/common'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { StylesOf } from '../..'
|
|
4
|
+
import { LoadingOverlayComposition, LoadingOverlayPresets } from './styles'
|
|
5
|
+
import { View, ViewProps } from '../View'
|
|
6
|
+
import { ActivityIndicator, ActivityIndicatorProps } from '../ActivityIndicator'
|
|
7
7
|
|
|
8
|
-
export type LoadingOverlayProps =
|
|
8
|
+
export type LoadingOverlayProps = Partial<ViewProps<'div'>> & {
|
|
9
9
|
visible?: boolean
|
|
10
10
|
styles?: StylesOf<LoadingOverlayComposition>
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
style?: React.CSSProperties
|
|
12
|
+
indicatorProps?: ActivityIndicatorProps
|
|
13
|
+
children?: React.ReactNode
|
|
14
|
+
} & ComponentVariants<typeof LoadingOverlayPresets>
|
|
13
15
|
|
|
14
16
|
export const LoadingOverlay = (props: LoadingOverlayProps) => {
|
|
15
|
-
const {
|
|
17
|
+
const {
|
|
18
|
+
visible,
|
|
19
|
+
children,
|
|
20
|
+
styles = {},
|
|
21
|
+
variants = [],
|
|
22
|
+
responsiveVariants = {},
|
|
23
|
+
style = {},
|
|
24
|
+
indicatorProps,
|
|
25
|
+
...rest
|
|
26
|
+
} = props
|
|
16
27
|
|
|
17
28
|
const variantStyles = useDefaultComponentStyle<'u:LoadingOverlay', typeof LoadingOverlayPresets>('u:LoadingOverlay', {
|
|
18
|
-
variants,
|
|
29
|
+
variants,
|
|
30
|
+
styles,
|
|
31
|
+
responsiveVariants,
|
|
32
|
+
rootElement: 'wrapper',
|
|
19
33
|
})
|
|
20
34
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
</View>
|
|
35
|
+
const indicatorStyles = React.useMemo(() => {
|
|
36
|
+
return getNestedStylesByKey('indicator', variantStyles)
|
|
37
|
+
}, [variantStyles])
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<View css={[variantStyles.wrapper, visible && variantStyles['wrapper:visible'], style]} {...rest}>
|
|
41
|
+
<ActivityIndicator {...indicatorProps} styles={indicatorStyles} />
|
|
42
|
+
{children}
|
|
43
|
+
</View>
|
|
44
|
+
)
|
|
32
45
|
}
|
|
33
46
|
|
|
34
|
-
export * from './styles'
|
|
47
|
+
export * from './styles'
|