@codeleap/web 1.1.0 → 1.1.4

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.
Files changed (47) hide show
  1. package/dist/components/PageRouter/Router.js +1 -1
  2. package/dist/components/PageRouter/Router.js.map +1 -1
  3. package/dist/components/PageRouter/index.js +1 -1
  4. package/dist/components/PageRouter/index.js.map +1 -1
  5. package/package.json +3 -2
  6. package/.eslintignore +0 -2
  7. package/.eslintrc.js +0 -3
  8. package/.turbo/turbo-build.log +0 -2
  9. package/src/components/ActivityIndicator/index.tsx +0 -55
  10. package/src/components/ActivityIndicator/styles.ts +0 -18
  11. package/src/components/Button.tsx +0 -67
  12. package/src/components/CenterWrapper.tsx +0 -24
  13. package/src/components/Checkbox/index.tsx +0 -47
  14. package/src/components/Checkbox/styles.ts +0 -57
  15. package/src/components/ContentView.tsx +0 -48
  16. package/src/components/Drawer.tsx +0 -114
  17. package/src/components/FileInput.tsx +0 -48
  18. package/src/components/FlatList.tsx +0 -77
  19. package/src/components/HorizontalScroll.tsx +0 -24
  20. package/src/components/Icon.tsx +0 -29
  21. package/src/components/Link.tsx +0 -51
  22. package/src/components/Modal/index.tsx +0 -150
  23. package/src/components/Modal/styles.ts +0 -49
  24. package/src/components/Overlay.tsx +0 -25
  25. package/src/components/PageRouter/Menu.tsx +0 -49
  26. package/src/components/PageRouter/MenuItem.tsx +0 -57
  27. package/src/components/PageRouter/Router.tsx +0 -23
  28. package/src/components/PageRouter/index.tsx +0 -81
  29. package/src/components/RadioInput/index.tsx +0 -72
  30. package/src/components/RadioInput/styles.ts +0 -57
  31. package/src/components/Select.tsx +0 -60
  32. package/src/components/Slider.tsx +0 -14
  33. package/src/components/Text.tsx +0 -27
  34. package/src/components/TextInput.tsx +0 -223
  35. package/src/components/Tooltip.tsx +0 -138
  36. package/src/components/Touchable.tsx +0 -47
  37. package/src/components/View.tsx +0 -54
  38. package/src/components/index.ts +0 -23
  39. package/src/index.ts +0 -4
  40. package/src/lib/hooks.ts +0 -59
  41. package/src/lib/logger.ts +0 -15
  42. package/src/lib/utils/cookies.ts +0 -19
  43. package/src/lib/utils/index.ts +0 -4
  44. package/src/lib/utils/pollyfils/scroll.ts +0 -59
  45. package/src/lib/utils/stopPropagation.ts +0 -17
  46. package/src/types/utility.ts +0 -4
  47. package/tsconfig.json +0 -42
@@ -21,7 +21,7 @@ var router_1 = require("@reach/router");
21
21
  var Router = function (props) {
22
22
  var children = props.children, style = props.style, basePath = props.basePath, defaultPath = props.defaultPath;
23
23
  var base = "/:language".concat(basePath);
24
- return ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: (0, jsx_runtime_1.jsx)(router_1.Router, __assign({ basepath: base }, { children: children }), void 0) }, void 0));
24
+ return ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: (0, jsx_runtime_1.jsx)(router_1.Router, __assign({ basepath: base, style: style }, { children: children }), void 0) }, void 0));
25
25
  };
26
26
  exports.Router = Router;
27
27
  //# sourceMappingURL=Router.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Router.js","sourceRoot":"","sources":["../../../src/components/PageRouter/Router.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,wCAAsD;AAQ/C,IAAM,MAAM,GAA0B,UAAC,KAAK;IACzC,IAAA,QAAQ,GAAmC,KAAK,SAAxC,EAAE,KAAK,GAA4B,KAAK,MAAjC,EAAE,QAAQ,GAAkB,KAAK,SAAvB,EAAE,WAAW,GAAK,KAAK,YAAV,CAAW;IACzD,IAAM,IAAI,GAAG,oBAAa,QAAQ,CAAE,CAAC;IAGrC,OAAO,CACL,uBAAC,eAAK,CAAC,QAAQ,cAEb,uBAAC,eAAW,aAAC,QAAQ,EAAE,IAAI,gBACxB,QAAQ,YACG,WACC,CAClB,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,MAAM,UAajB"}
1
+ {"version":3,"file":"Router.js","sourceRoot":"","sources":["../../../src/components/PageRouter/Router.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,wCAAsD;AAQ/C,IAAM,MAAM,GAA0B,UAAC,KAAK;IACzC,IAAA,QAAQ,GAAmC,KAAK,SAAxC,EAAE,KAAK,GAA4B,KAAK,MAAjC,EAAE,QAAQ,GAAkB,KAAK,SAAvB,EAAE,WAAW,GAAK,KAAK,YAAV,CAAW;IACzD,IAAM,IAAI,GAAG,oBAAa,QAAQ,CAAE,CAAC;IAErC,OAAO,CACL,uBAAC,eAAK,CAAC,QAAQ,cACb,uBAAC,eAAW,aAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,gBACtC,QAAQ,YACG,WACC,CAClB,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,MAAM,UAWjB"}
@@ -70,7 +70,7 @@ var RouterPage = function (props) {
70
70
  var path = _a.path;
71
71
  return pathName.includes(path);
72
72
  });
73
- return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_helmet_1.Helmet, { children: (0, jsx_runtime_1.jsx)("title", { children: (pageGroupTitle ? "".concat(pageGroupTitle, " | ") : '') + (currentPage ? currentPage === null || currentPage === void 0 ? void 0 : currentPage.title : '') }, void 0) }, void 0), (0, jsx_runtime_1.jsx)(Menu_1.Menu, { items: menuItems, styles: variantStyles }, void 0), (0, jsx_runtime_1.jsx)(View_1.View, __assign({ css: variantStyles.content }, { children: (0, jsx_runtime_1.jsx)(Router_1.Router, __assign({ defaultPath: defaultPath, basePath: basePath }, { children: children }), void 0) }), void 0)] }, void 0);
73
+ return (0, jsx_runtime_1.jsxs)(View_1.View, __assign({ css: variantStyles.wrapper }, { children: [(0, jsx_runtime_1.jsx)(react_helmet_1.Helmet, { children: (0, jsx_runtime_1.jsx)("title", { children: (pageGroupTitle ? "".concat(pageGroupTitle, " | ") : '') + (currentPage ? currentPage === null || currentPage === void 0 ? void 0 : currentPage.title : '') }, void 0) }, void 0), (0, jsx_runtime_1.jsx)(Menu_1.Menu, { items: menuItems, styles: variantStyles }, void 0), (0, jsx_runtime_1.jsx)(View_1.View, __assign({ css: variantStyles.content }, { children: (0, jsx_runtime_1.jsx)(Router_1.Router, __assign({ defaultPath: defaultPath, basePath: basePath, style: variantStyles.router }, { children: children }), void 0) }), void 0)] }), void 0);
74
74
  };
75
75
  exports.RouterPage = RouterPage;
76
76
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/PageRouter/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gCAA8B;AAC9B,6CAAsC;AAEtC,+BAA6B;AAC7B,mCAAiC;AACjC,2CAAiI;AAEjI,6CAAqC;AACrC,yCAAqC;AASrC,2CAAwB;AAQjB,IAAM,UAAU,GAA6B,UAAC,KAAK;IACjD,IAAA,QAAQ,GAA6E,KAAK,SAAlF,EAAG,QAAQ,GAAkE,KAAK,SAAvE,EAAG,QAAQ,GAAuD,KAAK,SAA5D,EAAS,cAAc,GAAgC,KAAK,MAArC,EAAE,kBAAkB,GAAY,KAAK,mBAAjB,EAAE,MAAM,GAAI,KAAK,OAAT,CAAS;IACjG,IAAM,QAAQ,GAAG,IAAA,WAAG,GAAE,CAAC,QAAQ,CAAA;IAEzB,IAAA,KAA2B,IAAA,eAAO,EAAC;QACvC,IAAM,KAAK,GAAG,EAAE,CAAA;QAEhB,IAAI,WAAW,GAAG,EAAE,CAAA;QAEpB,eAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAC,CAAC;YACjC,IAAI,eAAK,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAC;gBAC/B,IAAA,KAA0B,CAAC,CAAC,KAAK,EAAhC,KAAK,WAAA,EAAE,IAAI,UAAA,EAAE,QAAQ,cAAW,CAAA;gBACvC,IAAI,CAAC,KAAK,EA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Y,QAAA,UAAU,cAwDtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/web",
3
- "version": "1.1.0",
3
+ "version": "1.1.4",
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
@@ -1,2 +0,0 @@
1
- node_modules
2
- dist
package/.eslintrc.js DELETED
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- ...require('@codeleap/config/.eslintrc'),
3
- }
@@ -1,2 +0,0 @@
1
- @codeleap/web:build: cache hit, replaying output 25fd6d1ac903fccd
2
- @codeleap/web:build: $ tsc --build
@@ -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
-