@codeleap/web 1.0.1 → 1.1.3
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/ActivityIndicator/index.d.ts +0 -1
- package/dist/components/ActivityIndicator/styles.d.ts +5 -1
- package/dist/components/Checkbox/index.d.ts +12 -0
- package/dist/components/Checkbox/index.js +57 -0
- package/dist/components/Checkbox/index.js.map +1 -0
- package/dist/components/Checkbox/styles.d.ts +46 -0
- package/dist/components/Checkbox/styles.js +58 -0
- package/dist/components/Checkbox/styles.js.map +1 -0
- package/dist/components/ContentView.d.ts +0 -1
- package/dist/components/ContentView.js +1 -1
- package/dist/components/ContentView.js.map +1 -1
- package/dist/components/FileInput.d.ts +1 -5
- package/dist/components/FileInput.js.map +1 -1
- package/dist/components/Icon.d.ts +2 -3
- package/dist/components/Icon.js +18 -4
- package/dist/components/Icon.js.map +1 -1
- package/dist/components/Link.d.ts +1 -1
- package/dist/components/Modal/styles.d.ts +5 -1
- package/dist/components/Overlay.d.ts +0 -1
- package/dist/components/PageRouter/Menu.d.ts +0 -1
- package/dist/components/PageRouter/MenuItem.d.ts +1 -1
- package/dist/components/PageRouter/MenuItem.js.map +1 -1
- package/dist/components/PageRouter/Router.js +1 -1
- package/dist/components/PageRouter/Router.js.map +1 -1
- package/dist/components/PageRouter/index.js +1 -1
- package/dist/components/PageRouter/index.js.map +1 -1
- package/dist/components/RadioInput/index.d.ts +1 -42
- package/dist/components/RadioInput/styles.d.ts +5 -1
- package/dist/components/Slider.d.ts +0 -1
- package/dist/components/Text.d.ts +1 -1
- package/dist/components/TextInput.d.ts +1 -89
- package/dist/components/TextInput.js +4 -4
- package/dist/components/TextInput.js.map +1 -1
- package/dist/components/Touchable.d.ts +2 -2
- package/dist/components/View.d.ts +3 -3
- package/dist/lib/hooks.d.ts +1 -1
- package/package.json +6 -3
- package/.eslintignore +0 -2
- package/.eslintrc.js +0 -3
- package/.turbo/turbo-build.log +0 -1
- package/dist/components/Tooltip-old.d.ts +0 -11
- package/dist/components/Tooltip-old.js +0 -151
- package/dist/components/Tooltip-old.js.map +0 -1
- package/dist/components/router/Menu.d.ts +0 -10
- package/dist/components/router/Menu.js +0 -39
- package/dist/components/router/Menu.js.map +0 -1
- package/dist/components/router/MenuItem.d.ts +0 -11
- package/dist/components/router/MenuItem.js +0 -42
- package/dist/components/router/MenuItem.js.map +0 -1
- package/dist/components/router/Router.d.ts +0 -8
- package/dist/components/router/Router.js +0 -28
- package/dist/components/router/Router.js.map +0 -1
- package/dist/components/router/index.d.ts +0 -14
- package/dist/components/router/index.js +0 -69
- package/dist/components/router/index.js.map +0 -1
- 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.tsx +0 -46
- 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 -26
- 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 -55
- 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 -219
- 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
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ComponentVariants, IconPlaceholder, RouterComposition, RouterStyles } from '@codeleap/common';
|
|
3
|
-
import { StylesOf } from '../../types/utility';
|
|
4
|
-
export declare type RouteProps = {
|
|
5
|
-
title?: string;
|
|
6
|
-
path?: string;
|
|
7
|
-
menuIcon?: IconPlaceholder;
|
|
8
|
-
};
|
|
9
|
-
export * from './Router';
|
|
10
|
-
declare type RouterPageProps = {
|
|
11
|
-
basePath: string;
|
|
12
|
-
styles: StylesOf<RouterComposition>;
|
|
13
|
-
} & ComponentVariants<typeof RouterStyles>;
|
|
14
|
-
export declare const RouterPage: React.FC<RouterPageProps>;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
16
|
-
}) : (function(o, m, k, k2) {
|
|
17
|
-
if (k2 === undefined) k2 = k;
|
|
18
|
-
o[k2] = m[k];
|
|
19
|
-
}));
|
|
20
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
-
}) : function(o, v) {
|
|
23
|
-
o["default"] = v;
|
|
24
|
-
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
-
if (mod && mod.__esModule) return mod;
|
|
27
|
-
var result = {};
|
|
28
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
-
__setModuleDefault(result, mod);
|
|
30
|
-
return result;
|
|
31
|
-
};
|
|
32
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
33
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
34
|
-
};
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.RouterPage = void 0;
|
|
37
|
-
var jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
38
|
-
var View_1 = require("../View");
|
|
39
|
-
var react_1 = __importStar(require("react"));
|
|
40
|
-
var Menu_1 = require("./Menu");
|
|
41
|
-
var Router_1 = require("./Router");
|
|
42
|
-
var common_1 = require("@codeleap/common");
|
|
43
|
-
__exportStar(require("./Router"), exports);
|
|
44
|
-
var RouterPage = function (props) {
|
|
45
|
-
var children = props.children, basePath = props.basePath, variants = props.variants, responsiveVariants = props.responsiveVariants, styles = props.styles;
|
|
46
|
-
var _a = (0, react_1.useMemo)(function () {
|
|
47
|
-
var items = [];
|
|
48
|
-
var defaultPath = '';
|
|
49
|
-
react_1.default.Children.forEach(children, function (c) {
|
|
50
|
-
if (react_1.default.isValidElement(c)) {
|
|
51
|
-
var _a = c.props, title = _a.title, path = _a.path, menuIcon = _a.menuIcon;
|
|
52
|
-
if ([title, path, menuIcon].some(function (i) { return !i; })) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (c.props.default)
|
|
56
|
-
defaultPath = path;
|
|
57
|
-
items.push(__assign(__assign({}, c.props), { title: title, path: "".concat(basePath).concat(path), icon: menuIcon }));
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
return {
|
|
61
|
-
menuItems: items,
|
|
62
|
-
defaultPath: defaultPath,
|
|
63
|
-
};
|
|
64
|
-
}, [children]), menuItems = _a.menuItems, defaultPath = _a.defaultPath;
|
|
65
|
-
var variantStyles = (0, common_1.useComponentStyle)('Router', { variants: variants, responsiveVariants: responsiveVariants, styles: styles });
|
|
66
|
-
return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(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);
|
|
67
|
-
};
|
|
68
|
-
exports.RouterPage = RouterPage;
|
|
69
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/router/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gCAA8B;AAC9B,6CAAsC;AAEtC,+BAA6B;AAC7B,mCAAiC;AACjC,2CAAyH;AAUzH,2CAAwB;AAOjB,IAAM,UAAU,GAA6B,UAAC,KAAK;IACjD,IAAA,QAAQ,GAAqD,KAAK,SAA1D,EAAG,QAAQ,GAA0C,KAAK,SAA/C,EAAE,QAAQ,GAAgC,KAAK,SAArC,EAAE,kBAAkB,GAAY,KAAK,mBAAjB,EAAE,MAAM,GAAI,KAAK,OAAT,CAAS;IAEnE,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,EAAC;gBACpB,IAAA,KAA0B,CAAC,CAAC,KAAK,EAAhC,KAAK,WAAA,EAAE,IAAI,UAAA,EAAE,QAAQ,cAAW,CAAA;gBACvC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,EAAF,CAAE,CAAC,EAAC;oBAC1C,OAAM;iBACP;gBACD,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO;oBAAE,WAAW,GAAG,IAAI,CAAA;gBACvC,KAAK,CAAC,IAAI,uBACL,CAAC,CAAC,KAAK,KACV,KAAK,OAAA,EACL,IAAI,EAAE,UAAG,QAAQ,SAAG,IAAI,CAAE,EAC1B,IAAI,EAAE,QAAQ,IACd,CAAA;aACH;QACH,CAAC,CAAC,CAAA;QAEF,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,WAAW,aAAA;SACZ,CAAA;IAEH,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,EA1BP,SAAS,eAAA,EAAE,WAAW,iBA0Bf,CAAA;IACd,IAAM,aAAa,GAAG,IAAA,0BAAiB,EAAC,QAAQ,EAAE,EAAC,QAAQ,UAAA,EAAE,kBAAkB,oBAAA,EAAE,MAAM,QAAA,EAAC,CAAC,CAAA;IACzF,OAAO,6DACL,uBAAC,WAAI,IACH,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,aAAa,WACrB,EACF,uBAAC,WAAI,aAAC,GAAG,EAAE,aAAa,CAAC,OAAO,gBAC9B,uBAAC,eAAM,aACL,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,gBAEjB,QAAQ,YACF,YACJ,YACN,CAAA;AAEL,CAAC,CAAA;AA9CY,QAAA,UAAU,cA8CtB"}
|
|
@@ -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,46 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { jsx } from '@emotion/react'
|
|
3
|
-
import { CheckboxComposition, CheckboxStyles, ComponentVariants, StylesOf, useComponentStyle, useStyle } from '@codeleap/common'
|
|
4
|
-
import { ComponentPropsWithRef } from 'react'
|
|
5
|
-
import { View } from './View'
|
|
6
|
-
import { Text } from './Text'
|
|
7
|
-
|
|
8
|
-
type NativeCheckboxProps = ComponentPropsWithRef<'input'>
|
|
9
|
-
|
|
10
|
-
export type CheckboxProps = NativeCheckboxProps & {
|
|
11
|
-
checked?:boolean
|
|
12
|
-
onValueChange?: (checked:boolean) => any
|
|
13
|
-
label?: React.ReactNode
|
|
14
|
-
styles?:StylesOf<CheckboxComposition>
|
|
15
|
-
} & ComponentVariants<typeof CheckboxStyles>
|
|
16
|
-
|
|
17
|
-
export const Checkbox = (checkboxProps:CheckboxProps) => {
|
|
18
|
-
const {checked, onValueChange, variants= [], responsiveVariants = {}, label, onChange, styles, ...props} = checkboxProps
|
|
19
|
-
|
|
20
|
-
function handleChange(e:React.ChangeEvent<HTMLInputElement>){
|
|
21
|
-
onChange && onChange(e)
|
|
22
|
-
onValueChange && onValueChange(e.target.checked)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const variantStyles = useComponentStyle('Checkbox', {
|
|
26
|
-
responsiveVariants,
|
|
27
|
-
variants,
|
|
28
|
-
styles,
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
const {logger} = useStyle()
|
|
32
|
-
logger.log('Checkbox Style', variantStyles, 'Style')
|
|
33
|
-
|
|
34
|
-
return <View component='label' css={{...variantStyles.wrapper }} >
|
|
35
|
-
<input {...props} css={variantStyles.input} onChange={handleChange} type='checkbox' checked={checked}/>
|
|
36
|
-
<span className='checkbox-label' css={{
|
|
37
|
-
...variantStyles.checkmarkWrapper,
|
|
38
|
-
'&:after': {
|
|
39
|
-
...variantStyles.checkmark,
|
|
40
|
-
},
|
|
41
|
-
}}/>
|
|
42
|
-
{
|
|
43
|
-
typeof label === 'string' ? <Text text={label} styles={{text: variantStyles.label}}/> : label
|
|
44
|
-
}
|
|
45
|
-
</View>
|
|
46
|
-
}
|
|
@@ -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||[])
|
|
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,26 +0,0 @@
|
|
|
1
|
-
import { IconPlaceholder, useStyle } 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
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const Icon:React.FC<IconProps> = ({name, style}) => {
|
|
15
|
-
const {Theme} = useStyle()
|
|
16
|
-
if (!name) return null
|
|
17
|
-
const Component = Theme?.icons?.[name]
|
|
18
|
-
|
|
19
|
-
const {logger} = useStyle()
|
|
20
|
-
|
|
21
|
-
if (!Component) {
|
|
22
|
-
logger.warn('Icon', `No icon found in theme for name "${name}"`, 'Component')
|
|
23
|
-
return null
|
|
24
|
-
}
|
|
25
|
-
return <Component style={style}/>
|
|
26
|
-
}
|