@codeleap/web 1.1.0 → 1.1.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 +3 -2
- package/.eslintignore +0 -2
- package/.eslintrc.js +0 -3
- package/.turbo/turbo-build.log +0 -2
- package/src/components/ActivityIndicator/index.tsx +0 -55
- package/src/components/ActivityIndicator/styles.ts +0 -18
- package/src/components/Button.tsx +0 -67
- package/src/components/CenterWrapper.tsx +0 -24
- package/src/components/Checkbox/index.tsx +0 -47
- package/src/components/Checkbox/styles.ts +0 -57
- package/src/components/ContentView.tsx +0 -48
- package/src/components/Drawer.tsx +0 -114
- package/src/components/FileInput.tsx +0 -48
- package/src/components/FlatList.tsx +0 -77
- package/src/components/HorizontalScroll.tsx +0 -24
- package/src/components/Icon.tsx +0 -29
- package/src/components/Link.tsx +0 -51
- package/src/components/Modal/index.tsx +0 -150
- package/src/components/Modal/styles.ts +0 -49
- package/src/components/Overlay.tsx +0 -25
- package/src/components/PageRouter/Menu.tsx +0 -49
- package/src/components/PageRouter/MenuItem.tsx +0 -57
- package/src/components/PageRouter/Router.tsx +0 -23
- package/src/components/PageRouter/index.tsx +0 -81
- package/src/components/RadioInput/index.tsx +0 -72
- package/src/components/RadioInput/styles.ts +0 -57
- package/src/components/Select.tsx +0 -60
- package/src/components/Slider.tsx +0 -14
- package/src/components/Text.tsx +0 -27
- package/src/components/TextInput.tsx +0 -223
- package/src/components/Tooltip.tsx +0 -138
- package/src/components/Touchable.tsx +0 -47
- package/src/components/View.tsx +0 -54
- package/src/components/index.ts +0 -23
- package/src/index.ts +0 -4
- package/src/lib/hooks.ts +0 -59
- package/src/lib/logger.ts +0 -15
- package/src/lib/utils/cookies.ts +0 -19
- package/src/lib/utils/index.ts +0 -4
- package/src/lib/utils/pollyfils/scroll.ts +0 -59
- package/src/lib/utils/stopPropagation.ts +0 -17
- package/src/types/utility.ts +0 -4
- package/tsconfig.json +0 -42
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeleap/web",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "git@github.com:codeleap-uk/codeleap-lib.git",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "tsc --build",
|
|
18
|
-
"lint": "./node_modules/.bin/eslint -c .eslintrc.js \"./src/**/*.{ts,tsx,js,jsx}\""
|
|
18
|
+
"lint": "./node_modules/.bin/eslint -c .eslintrc.js \"./src/**/*.{ts,tsx,js,jsx}\"",
|
|
19
|
+
"publish": "npm publish"
|
|
19
20
|
},
|
|
20
21
|
"dependencies": {
|
|
21
22
|
"@emotion/css": "^11.7.1",
|
package/.eslintignore
DELETED
package/.eslintrc.js
DELETED
package/.turbo/turbo-build.log
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { View } from '../View'
|
|
2
|
-
import { CSSObject, keyframes } from '@emotion/react'
|
|
3
|
-
import { useComponentStyle, ComponentVariants, ActivityIndicatorStyles, ActivityIndicatorComposition } from '@codeleap/common'
|
|
4
|
-
import { StylesOf } from '../../types/utility'
|
|
5
|
-
|
|
6
|
-
export * from './styles'
|
|
7
|
-
|
|
8
|
-
const spin = keyframes`
|
|
9
|
-
from {
|
|
10
|
-
transform: rotate(0deg);
|
|
11
|
-
}
|
|
12
|
-
to{
|
|
13
|
-
transform: rotate(360deg);
|
|
14
|
-
}
|
|
15
|
-
`
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export type ActivityIndicatorProps = {
|
|
20
|
-
animating?:boolean
|
|
21
|
-
hidesWhenStopped?:boolean
|
|
22
|
-
styles?:StylesOf<ActivityIndicatorComposition>
|
|
23
|
-
css?:CSSObject
|
|
24
|
-
} & ComponentVariants<typeof ActivityIndicatorStyles>
|
|
25
|
-
|
|
26
|
-
export const ActivityIndicator:React.FC<ActivityIndicatorProps> = (indicatorProps) => {
|
|
27
|
-
const {
|
|
28
|
-
animating = true,
|
|
29
|
-
hidesWhenStopped = true,
|
|
30
|
-
|
|
31
|
-
variants,
|
|
32
|
-
responsiveVariants,
|
|
33
|
-
styles,
|
|
34
|
-
...viewProps
|
|
35
|
-
} = indicatorProps
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const variantStyles = useComponentStyle('ActivityIndicator', {
|
|
39
|
-
styles,
|
|
40
|
-
responsiveVariants,
|
|
41
|
-
variants,
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
if (!animating && hidesWhenStopped){
|
|
45
|
-
return null
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return <View {...viewProps} css={variantStyles.wrapper}>
|
|
49
|
-
<View css={{...variantStyles.circle, ...variantStyles.backCircle}}/>
|
|
50
|
-
<View css={{...variantStyles.circle, ...variantStyles.frontCircle,
|
|
51
|
-
animation: `${spin} 1s infinite`,
|
|
52
|
-
animationPlayState: animating ? 'running' : 'paused',
|
|
53
|
-
}}/>
|
|
54
|
-
</View>
|
|
55
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { ActivityIndicatorComposition, ActivityIndicatorStyles, createDefaultVariantFactory } from '@codeleap/common'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const createActivityIndicatorStyle = createDefaultVariantFactory<ActivityIndicatorComposition>()
|
|
7
|
-
|
|
8
|
-
const getDefault = ActivityIndicatorStyles.default
|
|
9
|
-
|
|
10
|
-
export const WebActivityIndicatorStyles = {
|
|
11
|
-
...ActivityIndicatorStyles,
|
|
12
|
-
default: createActivityIndicatorStyle((theme) => {
|
|
13
|
-
const defaults = getDefault(theme)
|
|
14
|
-
return defaults
|
|
15
|
-
|
|
16
|
-
}),
|
|
17
|
-
}
|
|
18
|
-
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { jsx } from '@emotion/react'
|
|
3
|
-
import { useComponentStyle, ButtonStyles, ComponentVariants, ButtonComposition } from '@codeleap/common';
|
|
4
|
-
import React, { ComponentPropsWithRef } from 'react'
|
|
5
|
-
import { StylesOf } from '../types/utility';
|
|
6
|
-
import { Text } from './Text';
|
|
7
|
-
import { Touchable } from './Touchable';
|
|
8
|
-
import { Icon } from './Icon';
|
|
9
|
-
import { ActivityIndicator } from './ActivityIndicator';
|
|
10
|
-
import { IconPlaceholder } from '@codeleap/common';
|
|
11
|
-
|
|
12
|
-
type NativeButtonProps = ComponentPropsWithRef<'button'>
|
|
13
|
-
|
|
14
|
-
export type ButtonProps = NativeButtonProps & ComponentVariants<typeof ButtonStyles> & {
|
|
15
|
-
text?:string
|
|
16
|
-
rightIcon?: IconPlaceholder
|
|
17
|
-
icon?: IconPlaceholder
|
|
18
|
-
onPress?:NativeButtonProps['onClick']
|
|
19
|
-
styles?: StylesOf<ButtonComposition>
|
|
20
|
-
loading?: boolean
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const Button:React.FC<ButtonProps> = (buttonProps) => {
|
|
25
|
-
const {
|
|
26
|
-
variants = [],
|
|
27
|
-
responsiveVariants = {},
|
|
28
|
-
children,
|
|
29
|
-
icon,
|
|
30
|
-
text,
|
|
31
|
-
loading,
|
|
32
|
-
styles,
|
|
33
|
-
onPress,
|
|
34
|
-
rightIcon,
|
|
35
|
-
...props
|
|
36
|
-
} = buttonProps
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const variantStyles = useComponentStyle('Button', {
|
|
40
|
-
responsiveVariants,
|
|
41
|
-
variants,
|
|
42
|
-
styles,
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
function handlePress(e:Parameters<ButtonProps['onPress']>[0]){
|
|
47
|
-
props.onClick && props.onClick(e)
|
|
48
|
-
onPress && onPress(e)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<Touchable
|
|
54
|
-
css={variantStyles.wrapper}
|
|
55
|
-
component='button'
|
|
56
|
-
onClick={handlePress}
|
|
57
|
-
{...props}
|
|
58
|
-
>
|
|
59
|
-
{loading && <ActivityIndicator css={variantStyles.loader} />}
|
|
60
|
-
{!loading && <Icon name={icon} style={{...variantStyles.icon, ...variantStyles.leftIcon}}/>}
|
|
61
|
-
{children || <Text text={text} styles={{
|
|
62
|
-
text: variantStyles.text,
|
|
63
|
-
}}/>}
|
|
64
|
-
<Icon name={rightIcon} style={{...variantStyles.icon, ...variantStyles.rightIcon}}/>
|
|
65
|
-
</Touchable>
|
|
66
|
-
)
|
|
67
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { View } from './View';
|
|
3
|
-
import { StylesOf } from '../types/utility';
|
|
4
|
-
import { ComponentVariants, useComponentStyle, CenterWrapperComposition, CenterWrapperStyles } from '@codeleap/common';
|
|
5
|
-
|
|
6
|
-
export type CenterWrapperProps = {
|
|
7
|
-
styles?: StylesOf<CenterWrapperComposition>
|
|
8
|
-
} & ComponentVariants<typeof CenterWrapperStyles>
|
|
9
|
-
|
|
10
|
-
export const CenterWrapper:React.FC<CenterWrapperProps> = (props) => {
|
|
11
|
-
const { styles: propStyles = {}, children, variants, styles, responsiveVariants } = props;
|
|
12
|
-
|
|
13
|
-
const variantStyles = useComponentStyle('CenterWrapper', {
|
|
14
|
-
variants, styles, responsiveVariants,
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<View css={[variantStyles.wrapper, propStyles.wrapper]}>
|
|
19
|
-
<View css={[variantStyles.innerWrapper, propStyles.innerWrapper]}>{children}</View>
|
|
20
|
-
</View>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/** @jsx jsx */
|
|
3
|
-
import { jsx } from '@emotion/react'
|
|
4
|
-
import { ComponentVariants, StylesOf, useComponentStyle, useStyle } from '@codeleap/common'
|
|
5
|
-
import { ComponentPropsWithRef } from 'react'
|
|
6
|
-
import { View } from '../View'
|
|
7
|
-
import { Text } from '../Text'
|
|
8
|
-
import {WebCheckboxComposition, WebCheckboxStyles as CheckboxStyles} from './styles'
|
|
9
|
-
type NativeCheckboxProps = ComponentPropsWithRef<'input'>
|
|
10
|
-
export * from './styles'
|
|
11
|
-
export type CheckboxProps = NativeCheckboxProps & {
|
|
12
|
-
checked?:boolean
|
|
13
|
-
onValueChange?: (checked:boolean) => any
|
|
14
|
-
label?: React.ReactNode
|
|
15
|
-
styles?:StylesOf<WebCheckboxComposition>
|
|
16
|
-
} & ComponentVariants<typeof CheckboxStyles>
|
|
17
|
-
|
|
18
|
-
export const Checkbox = (checkboxProps:CheckboxProps) => {
|
|
19
|
-
const {checked, onValueChange, variants= [], responsiveVariants = {}, label, onChange, styles, ...props} = checkboxProps
|
|
20
|
-
|
|
21
|
-
function handleChange(e:React.ChangeEvent<HTMLInputElement>){
|
|
22
|
-
onChange && onChange(e)
|
|
23
|
-
onValueChange && onValueChange(e.target.checked)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const variantStyles = useComponentStyle('Checkbox', {
|
|
27
|
-
responsiveVariants,
|
|
28
|
-
variants,
|
|
29
|
-
styles,
|
|
30
|
-
}) as StylesOf<WebCheckboxComposition>
|
|
31
|
-
|
|
32
|
-
const {logger} = useStyle()
|
|
33
|
-
logger.log('Checkbox Style', variantStyles, 'Style')
|
|
34
|
-
|
|
35
|
-
return <View component='label' css={{...variantStyles.wrapper }} >
|
|
36
|
-
<input {...props} css={variantStyles.input} onChange={handleChange} type='checkbox' checked={checked}/>
|
|
37
|
-
<span className='checkbox-label' css={{
|
|
38
|
-
...variantStyles.checkmarkWrapper,
|
|
39
|
-
'&:after': {
|
|
40
|
-
...variantStyles.checkmark,
|
|
41
|
-
},
|
|
42
|
-
}}/>
|
|
43
|
-
{
|
|
44
|
-
typeof label === 'string' ? <Text text={label} styles={{text: variantStyles.label}}/> : label
|
|
45
|
-
}
|
|
46
|
-
</View>
|
|
47
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import {createDefaultVariantFactory, includePresets} from '@codeleap/common'
|
|
2
|
-
export type WebCheckboxComposition = 'wrapper' | 'label' | 'input' | 'checkmark' | 'checkmarkWrapper';
|
|
3
|
-
|
|
4
|
-
const createCheckboxStyle = createDefaultVariantFactory<WebCheckboxComposition>()
|
|
5
|
-
|
|
6
|
-
const presets = includePresets((styles) => createCheckboxStyle(() => ({ wrapper: styles })))
|
|
7
|
-
|
|
8
|
-
export const WebCheckboxStyles = {
|
|
9
|
-
...presets,
|
|
10
|
-
default: createCheckboxStyle((theme) => ({
|
|
11
|
-
wrapper: {
|
|
12
|
-
display: 'flex',
|
|
13
|
-
alignItems: 'center',
|
|
14
|
-
position: 'relative',
|
|
15
|
-
cursor: 'pointer',
|
|
16
|
-
'.checkbox-label': {
|
|
17
|
-
height: '18px',
|
|
18
|
-
width: '18px',
|
|
19
|
-
border: `1px solid ${theme.colors.gray}`,
|
|
20
|
-
borderRadius: theme.borderRadius.small,
|
|
21
|
-
position: 'absolute',
|
|
22
|
-
overflow: 'hidden',
|
|
23
|
-
transition: 'background 0.3s ease',
|
|
24
|
-
':after': {
|
|
25
|
-
content: '""',
|
|
26
|
-
border: `2px solid ${theme.colors.white}`,
|
|
27
|
-
borderLeftColor: 'transparent',
|
|
28
|
-
borderTopColor: 'transparent',
|
|
29
|
-
height: '40%',
|
|
30
|
-
width: '20%',
|
|
31
|
-
position: 'absolute',
|
|
32
|
-
left: '50%',
|
|
33
|
-
top: '40%',
|
|
34
|
-
|
|
35
|
-
transform: 'translate(-50%,-50%) rotate(45deg) scale(0)',
|
|
36
|
-
transition: 'transform 0.2s ease',
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
label: {
|
|
42
|
-
...theme.spacing.marginLeft(1),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
input: {
|
|
47
|
-
visibility: 'hidden',
|
|
48
|
-
'&:checked + .checkbox-label': {
|
|
49
|
-
'&:after': {
|
|
50
|
-
transform: 'translate(-50%,-50%) rotate(45deg) scale(1)',
|
|
51
|
-
},
|
|
52
|
-
background: theme.colors.primary,
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
})),
|
|
56
|
-
|
|
57
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { ComponentVariants, ContentViewStyles, useComponentStyle, ViewComposition } from '@codeleap/common'
|
|
2
|
-
import { ActivityIndicator } from '.'
|
|
3
|
-
import { ViewProps, View } from './View'
|
|
4
|
-
import { Text } from './Text'
|
|
5
|
-
import { StylesOf } from '../types/utility'
|
|
6
|
-
|
|
7
|
-
export type ContentViewProps = Omit<ViewProps<'div'>, 'variants' | 'responsiveVariants'> & {
|
|
8
|
-
placeholderMsg: string
|
|
9
|
-
loading?:boolean
|
|
10
|
-
styles?: StylesOf<ViewComposition>
|
|
11
|
-
} & ComponentVariants<typeof ContentViewStyles>
|
|
12
|
-
|
|
13
|
-
const WrapContent = ({children, ...props}:Partial<ContentViewProps>) => <View {...props} >{children}</View>
|
|
14
|
-
|
|
15
|
-
export const ContentView:React.FC<ContentViewProps> = (rawProps) => {
|
|
16
|
-
const {
|
|
17
|
-
children,
|
|
18
|
-
placeholderMsg,
|
|
19
|
-
loading,
|
|
20
|
-
variants,
|
|
21
|
-
responsiveVariants,
|
|
22
|
-
styles,
|
|
23
|
-
...props
|
|
24
|
-
} = rawProps
|
|
25
|
-
|
|
26
|
-
const variantStyle = useComponentStyle('ContentView', {
|
|
27
|
-
variants,
|
|
28
|
-
responsiveVariants,
|
|
29
|
-
styles,
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
if (loading){
|
|
33
|
-
return <WrapContent {...props} css={{...variantStyle.wrapper}}>
|
|
34
|
-
<ActivityIndicator css={variantStyle.loader}/>
|
|
35
|
-
</WrapContent>
|
|
36
|
-
}
|
|
37
|
-
const hasChildren = Object.keys(children||{}).length > 0
|
|
38
|
-
if (hasChildren){
|
|
39
|
-
return <WrapContent {...props}css={variantStyle.wrapper}>
|
|
40
|
-
{children}
|
|
41
|
-
</WrapContent>
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return <WrapContent {...props} css={variantStyle.wrapper}>
|
|
45
|
-
<Text text={placeholderMsg} css={variantStyle.placeholder}/>
|
|
46
|
-
</WrapContent>
|
|
47
|
-
|
|
48
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { AnyFunction, ComponentVariants, DrawerComposition, DrawerStyles, IconPlaceholder, useComponentStyle } from '@codeleap/common'
|
|
3
|
-
import { CSSObject } from '@emotion/react'
|
|
4
|
-
import React, { ReactNode } from 'react'
|
|
5
|
-
import { Overlay } from './Overlay'
|
|
6
|
-
import { View } from './View'
|
|
7
|
-
import { Text } from './Text'
|
|
8
|
-
import { Button } from './Button'
|
|
9
|
-
import { StylesOf } from '../types/utility'
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const axisMap = {
|
|
13
|
-
top: [-1, 'Y'],
|
|
14
|
-
bottom: [1, 'Y'],
|
|
15
|
-
left: [-1, 'X'],
|
|
16
|
-
right: [1, 'X'],
|
|
17
|
-
} as const
|
|
18
|
-
|
|
19
|
-
export type DrawerProps = {
|
|
20
|
-
open: boolean
|
|
21
|
-
toggle: AnyFunction
|
|
22
|
-
darkenBackground?:boolean
|
|
23
|
-
size: string|number
|
|
24
|
-
showCloseButton?:boolean
|
|
25
|
-
title?:ReactNode
|
|
26
|
-
footer?: ReactNode
|
|
27
|
-
position?: keyof typeof axisMap
|
|
28
|
-
styles?: StylesOf<DrawerComposition>
|
|
29
|
-
animationDuration?:string
|
|
30
|
-
} & ComponentVariants<typeof DrawerStyles>
|
|
31
|
-
|
|
32
|
-
const resolveHiddenDrawerPosition = (position: DrawerProps['position']):[string, string, CSSObject] => {
|
|
33
|
-
const [translateOrient, translateAxis] = axisMap[position]
|
|
34
|
-
|
|
35
|
-
const translateValues = {
|
|
36
|
-
X: 0,
|
|
37
|
-
Y: 0,
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
translateValues[translateAxis] = 100 * translateOrient
|
|
41
|
-
|
|
42
|
-
const css = `translate(${translateValues.X}%, ${translateValues.Y}%)`
|
|
43
|
-
const positioningKeys = translateAxis === 'X' ? ['top', 'bottom'] : ['left', 'right']
|
|
44
|
-
|
|
45
|
-
const positioning = Object.fromEntries(positioningKeys.map(k => [k, 0]))
|
|
46
|
-
return [css, translateAxis, positioning]
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
export const Drawer:React.FC<DrawerProps> = ({ ...rawProps}) => {
|
|
52
|
-
const {
|
|
53
|
-
open,
|
|
54
|
-
toggle,
|
|
55
|
-
children,
|
|
56
|
-
size,
|
|
57
|
-
title,
|
|
58
|
-
footer,
|
|
59
|
-
darkenBackground = true,
|
|
60
|
-
showCloseButton,
|
|
61
|
-
position = 'bottom',
|
|
62
|
-
variants = [],
|
|
63
|
-
responsiveVariants = {},
|
|
64
|
-
styles,
|
|
65
|
-
animationDuration = '0.3s',
|
|
66
|
-
} = rawProps
|
|
67
|
-
|
|
68
|
-
const [hiddenStyle, axis, positioning] = resolveHiddenDrawerPosition(position)
|
|
69
|
-
|
|
70
|
-
const sizeProperty = axis === 'X' ? 'width' : 'height'
|
|
71
|
-
const fullProperty = sizeProperty === 'height' ? 'width' : 'height'
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const variantStyles = useComponentStyle('Drawer', {
|
|
75
|
-
styles,
|
|
76
|
-
variants,
|
|
77
|
-
responsiveVariants,
|
|
78
|
-
})
|
|
79
|
-
return <View
|
|
80
|
-
css={{...variantStyles.wrapper,
|
|
81
|
-
transition: 'visibility 0.01s ease',
|
|
82
|
-
transitionDelay: open ? '0' : animationDuration,
|
|
83
|
-
visibility: open ?'visible' : 'hidden' }}>
|
|
84
|
-
{
|
|
85
|
-
darkenBackground && <Overlay visible={open} css={variantStyles.overlay} onPress={() => toggle()}/>
|
|
86
|
-
}
|
|
87
|
-
<View variants={['fixed']} css={{
|
|
88
|
-
transform: open ? `translate(0%, 0%)` : hiddenStyle,
|
|
89
|
-
transition: `transform ${animationDuration} ease`,
|
|
90
|
-
[sizeProperty]: size,
|
|
91
|
-
[fullProperty]: '100%',
|
|
92
|
-
...positioning,
|
|
93
|
-
[position]: 0,
|
|
94
|
-
...variantStyles.box,
|
|
95
|
-
|
|
96
|
-
}} >
|
|
97
|
-
<View component='header' variants={['justifySpaceBetween']} css={variantStyles.header}>
|
|
98
|
-
{typeof title === 'string' ? <Text text={title} /> : title}
|
|
99
|
-
{
|
|
100
|
-
showCloseButton && <Button onPress={toggle} icon={'close' as IconPlaceholder} variants={['icon']} css={variantStyles.headerCloseButton}/>
|
|
101
|
-
}
|
|
102
|
-
</View>
|
|
103
|
-
<View css={variantStyles.body}>
|
|
104
|
-
{children}
|
|
105
|
-
</View>
|
|
106
|
-
{
|
|
107
|
-
footer &&
|
|
108
|
-
<View component='footer' css={variantStyles.footer}>
|
|
109
|
-
{footer}
|
|
110
|
-
</View>
|
|
111
|
-
}
|
|
112
|
-
</View>
|
|
113
|
-
</View>
|
|
114
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import React, { ComponentPropsWithoutRef, useImperativeHandle, useRef } from 'react'
|
|
2
|
-
import { WebInputFile } from '@codeleap/common'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export type FileInputRef = {
|
|
6
|
-
openFilePicker: () => void
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
type FileInputProps= Omit<ComponentPropsWithoutRef<'input'>, 'type'> & {
|
|
10
|
-
onFileSelect(files:WebInputFile[]): void
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export const FileInput = React.forwardRef<FileInputRef, FileInputProps>((inputProps, ref) => {
|
|
16
|
-
const inputRef = useRef<HTMLInputElement>(null)
|
|
17
|
-
|
|
18
|
-
const { onFileSelect, ...props } = inputProps
|
|
19
|
-
|
|
20
|
-
useImperativeHandle(ref, () => ({
|
|
21
|
-
openFilePicker: () => {
|
|
22
|
-
inputRef.current.click()
|
|
23
|
-
},
|
|
24
|
-
}))
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function handleChange(e:React.ChangeEvent<HTMLInputElement>){
|
|
29
|
-
if (!e.target.files.length) return
|
|
30
|
-
inputProps.onChange && inputProps.onChange(e)
|
|
31
|
-
const fileArray = Array.from(e.target?.files||[]) as File[]
|
|
32
|
-
|
|
33
|
-
const files:WebInputFile[] = fileArray.map((obj) => ({
|
|
34
|
-
file: obj,
|
|
35
|
-
preview: URL.createObjectURL(obj),
|
|
36
|
-
}))
|
|
37
|
-
|
|
38
|
-
onFileSelect && onFileSelect(files)
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return <input type={'file'} css={{visibility: 'hidden'}} {...props} ref={inputRef} onChange={handleChange}/>
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { VariableSizeList as List } from 'react-window';
|
|
2
|
-
import { ComponentProps, CSSProperties, ReactElement } from 'react'
|
|
3
|
-
import AutoSizer from 'react-virtualized-auto-sizer'
|
|
4
|
-
import { ComponentVariants, useComponentStyle, ViewComposition, ViewStyles } from '@codeleap/common';
|
|
5
|
-
import { StylesOf } from '../types/utility';
|
|
6
|
-
import { CSSObject } from '@emotion/react';
|
|
7
|
-
|
|
8
|
-
export type FlatListRender<T> = (itemProps:{item:T, index:number, style:CSSProperties}) => ReactElement
|
|
9
|
-
|
|
10
|
-
export type FlatListProps<T> = {
|
|
11
|
-
styles?:StylesOf<ViewComposition>
|
|
12
|
-
css?:CSSObject
|
|
13
|
-
data: T[]
|
|
14
|
-
getSize: (i:T, idx:number) => number
|
|
15
|
-
renderItem: FlatListRender<T>
|
|
16
|
-
|
|
17
|
-
} & Omit<ComponentProps<typeof List>, 'itemCount' | 'itemSize' | 'itemData' | 'itemHeight' |'width'|'height'|'children'>
|
|
18
|
-
& ComponentVariants<typeof ViewStyles>
|
|
19
|
-
|
|
20
|
-
export const FlatList = <T extends unknown>(flatListProps:FlatListProps<T>) => {
|
|
21
|
-
const { variants, responsiveVariants, styles, data, getSize, renderItem: Item, ...viewProps} = flatListProps
|
|
22
|
-
|
|
23
|
-
const variantStyles = useComponentStyle('View', {
|
|
24
|
-
variants, responsiveVariants, styles,
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
return <AutoSizer>
|
|
28
|
-
{
|
|
29
|
-
({height, width}) => (
|
|
30
|
-
|
|
31
|
-
<List
|
|
32
|
-
height={height}
|
|
33
|
-
width={width}
|
|
34
|
-
itemCount={data.length}
|
|
35
|
-
itemData={data}
|
|
36
|
-
itemSize={(idx) => getSize(data[idx], idx)}
|
|
37
|
-
css={variantStyles.wrapper}
|
|
38
|
-
{...viewProps}
|
|
39
|
-
>
|
|
40
|
-
{
|
|
41
|
-
({style, index}) => <Item item={data[index]} style={style} index={index}/>
|
|
42
|
-
}
|
|
43
|
-
</List>
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
</AutoSizer>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// return <View {...viewProps}>
|
|
51
|
-
// {data.map((item, idx) => <Component item={item} idx={idx} key={idx}/>)}
|
|
52
|
-
// </View>
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
// const rowHeights = new Array(1000)
|
|
59
|
-
// .fill(true)
|
|
60
|
-
// .map(() => 25 + Math.round(Math.random() * 50));
|
|
61
|
-
|
|
62
|
-
// const getItemSize = index => rowHeights[index];
|
|
63
|
-
|
|
64
|
-
// const Row = ({ index, style }) => (
|
|
65
|
-
// <div style={style}>Row {index}</div>
|
|
66
|
-
// );
|
|
67
|
-
|
|
68
|
-
// const Example = () => (
|
|
69
|
-
// <List
|
|
70
|
-
// height={150}
|
|
71
|
-
// itemCount={1000}
|
|
72
|
-
// itemSize={getItemSize}
|
|
73
|
-
// width={300}
|
|
74
|
-
// >
|
|
75
|
-
// {Row}
|
|
76
|
-
// </List>
|
|
77
|
-
// );
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React, { ElementType } from 'react';
|
|
2
|
-
import { ViewProps } from '.';
|
|
3
|
-
import { View } from './View';
|
|
4
|
-
|
|
5
|
-
export function HorizontalScroll<T extends ElementType = 'div'>(props:ViewProps<T>) {
|
|
6
|
-
const { children, style, ...otherProps } = props;
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<View {...otherProps} css={[styles.scroll, style]}>
|
|
10
|
-
{children}
|
|
11
|
-
</View>
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const styles = {
|
|
16
|
-
scroll: {
|
|
17
|
-
overflow: 'auto',
|
|
18
|
-
'::-webkit-scrollbar': {
|
|
19
|
-
display: 'none',
|
|
20
|
-
},
|
|
21
|
-
whiteSpace: 'nowrap',
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
|
package/src/components/Icon.tsx
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ComponentVariants, IconPlaceholder, useComponentStyle, useStyle, IconStyles } from '@codeleap/common'
|
|
2
|
-
|
|
3
|
-
export type IconProps = {
|
|
4
|
-
name:IconPlaceholder
|
|
5
|
-
style?: {
|
|
6
|
-
color: string
|
|
7
|
-
size?:string|number
|
|
8
|
-
width?:string|number
|
|
9
|
-
height?:string|number
|
|
10
|
-
}
|
|
11
|
-
} & ComponentVariants<typeof IconStyles>
|
|
12
|
-
|
|
13
|
-
export const Icon:React.FC<IconProps> = ({name, style, responsiveVariants, variants}) => {
|
|
14
|
-
const {Theme, logger} = useStyle()
|
|
15
|
-
if (!name) return null
|
|
16
|
-
const Component = Theme?.icons?.[name]
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const variantStyles = useComponentStyle('Icon', {
|
|
21
|
-
variants,
|
|
22
|
-
responsiveVariants,
|
|
23
|
-
})
|
|
24
|
-
if (!Component) {
|
|
25
|
-
logger.warn('Icon', `No icon found in theme for name "${name}"`, 'Component')
|
|
26
|
-
return null
|
|
27
|
-
}
|
|
28
|
-
return <Component style={{...variantStyles.icon, ...style}}/>
|
|
29
|
-
}
|