@codeleap/web 1.0.0
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/.eslintignore +2 -0
- package/.eslintrc.js +3 -0
- package/.turbo/turbo-build.log +1 -0
- package/dist/components/ActivityIndicator/index.d.ts +12 -0
- package/dist/components/ActivityIndicator/index.js +60 -0
- package/dist/components/ActivityIndicator/index.js.map +1 -0
- package/dist/components/ActivityIndicator/styles.d.ts +42 -0
- package/dist/components/ActivityIndicator/styles.js +22 -0
- package/dist/components/ActivityIndicator/styles.js.map +1 -0
- package/dist/components/Button.d.ts +15 -0
- package/dist/components/Button.js +48 -0
- package/dist/components/Button.js.map +1 -0
- package/dist/components/CenterWrapper.d.ts +7 -0
- package/dist/components/CenterWrapper.js +28 -0
- package/dist/components/CenterWrapper.js.map +1 -0
- package/dist/components/Checkbox.d.ts +11 -0
- package/dist/components/Checkbox.js +46 -0
- package/dist/components/Checkbox.js.map +1 -0
- package/dist/components/ContentView.d.ts +10 -0
- package/dist/components/ContentView.js +52 -0
- package/dist/components/ContentView.js.map +1 -0
- package/dist/components/Drawer.d.ts +23 -0
- package/dist/components/Drawer.js +66 -0
- package/dist/components/Drawer.js.map +1 -0
- package/dist/components/FileInput.d.ts +8 -0
- package/dist/components/FileInput.js +69 -0
- package/dist/components/FileInput.js.map +1 -0
- package/dist/components/FlatList.d.ts +18 -0
- package/dist/components/FlatList.js +52 -0
- package/dist/components/FlatList.js.map +1 -0
- package/dist/components/HorizontalScroll.d.ts +3 -0
- package/dist/components/HorizontalScroll.js +42 -0
- package/dist/components/HorizontalScroll.js.map +1 -0
- package/dist/components/Icon.d.ts +12 -0
- package/dist/components/Icon.js +21 -0
- package/dist/components/Icon.js.map +1 -0
- package/dist/components/Link.d.ts +6 -0
- package/dist/components/Link.js +66 -0
- package/dist/components/Link.js.map +1 -0
- package/dist/components/Modal/index.d.ts +19 -0
- package/dist/components/Modal/index.js +111 -0
- package/dist/components/Modal/index.js.map +1 -0
- package/dist/components/Modal/styles.d.ts +44 -0
- package/dist/components/Modal/styles.js +33 -0
- package/dist/components/Modal/styles.js.map +1 -0
- package/dist/components/Overlay.d.ts +10 -0
- package/dist/components/Overlay.js +41 -0
- package/dist/components/Overlay.js.map +1 -0
- package/dist/components/PageRouter/Menu.d.ts +10 -0
- package/dist/components/PageRouter/Menu.js +36 -0
- package/dist/components/PageRouter/Menu.js.map +1 -0
- package/dist/components/PageRouter/MenuItem.d.ts +11 -0
- package/dist/components/PageRouter/MenuItem.js +42 -0
- package/dist/components/PageRouter/MenuItem.js.map +1 -0
- package/dist/components/PageRouter/Router.d.ts +8 -0
- package/dist/components/PageRouter/Router.js +27 -0
- package/dist/components/PageRouter/Router.js.map +1 -0
- package/dist/components/PageRouter/index.d.ts +15 -0
- package/dist/components/PageRouter/index.js +76 -0
- package/dist/components/PageRouter/index.js.map +1 -0
- package/dist/components/RadioInput/index.d.ts +62 -0
- package/dist/components/RadioInput/index.js +53 -0
- package/dist/components/RadioInput/index.js.map +1 -0
- package/dist/components/RadioInput/styles.d.ts +43 -0
- package/dist/components/RadioInput/styles.js +44 -0
- package/dist/components/RadioInput/styles.js.map +1 -0
- package/dist/components/Select.d.ts +17 -0
- package/dist/components/Select.js +44 -0
- package/dist/components/Select.js.map +1 -0
- package/dist/components/Slider.d.ts +5 -0
- package/dist/components/Slider.js +36 -0
- package/dist/components/Slider.js.map +1 -0
- package/dist/components/Text.d.ts +9 -0
- package/dist/components/Text.js +39 -0
- package/dist/components/Text.js.map +1 -0
- package/dist/components/TextInput.d.ts +122 -0
- package/dist/components/TextInput.js +125 -0
- package/dist/components/TextInput.js.map +1 -0
- package/dist/components/Tooltip-old.d.ts +11 -0
- package/dist/components/Tooltip-old.js +151 -0
- package/dist/components/Tooltip-old.js.map +1 -0
- package/dist/components/Tooltip.d.ts +12 -0
- package/dist/components/Tooltip.js +124 -0
- package/dist/components/Tooltip.js.map +1 -0
- package/dist/components/Touchable.d.ts +12 -0
- package/dist/components/Touchable.js +48 -0
- package/dist/components/Touchable.js.map +1 -0
- package/dist/components/View.d.ts +9 -0
- package/dist/components/View.js +47 -0
- package/dist/components/View.js.map +1 -0
- package/dist/components/index.d.ts +22 -0
- package/dist/components/index.js +35 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/router/Menu.d.ts +10 -0
- package/dist/components/router/Menu.js +39 -0
- package/dist/components/router/Menu.js.map +1 -0
- package/dist/components/router/MenuItem.d.ts +11 -0
- package/dist/components/router/MenuItem.js +42 -0
- package/dist/components/router/MenuItem.js.map +1 -0
- package/dist/components/router/Router.d.ts +8 -0
- package/dist/components/router/Router.js +28 -0
- package/dist/components/router/Router.js.map +1 -0
- package/dist/components/router/index.d.ts +14 -0
- package/dist/components/router/index.js +69 -0
- package/dist/components/router/index.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/hooks.d.ts +8 -0
- package/dist/lib/hooks.js +49 -0
- package/dist/lib/hooks.js.map +1 -0
- package/dist/lib/logger.d.ts +2 -0
- package/dist/lib/logger.js +16 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/utils/cookies.d.ts +6 -0
- package/dist/lib/utils/cookies.js +15 -0
- package/dist/lib/utils/cookies.js.map +1 -0
- package/dist/lib/utils/index.d.ts +4 -0
- package/dist/lib/utils/index.js +23 -0
- package/dist/lib/utils/index.js.map +1 -0
- package/dist/lib/utils/pollyfils/scroll.d.ts +1 -0
- package/dist/lib/utils/pollyfils/scroll.js +58 -0
- package/dist/lib/utils/pollyfils/scroll.js.map +1 -0
- package/dist/lib/utils/stopPropagation.d.ts +1 -0
- package/dist/lib/utils/stopPropagation.js +21 -0
- package/dist/lib/utils/stopPropagation.js.map +1 -0
- package/dist/types/utility.d.ts +2 -0
- package/dist/types/utility.js +3 -0
- package/dist/types/utility.js.map +1 -0
- package/package.json +38 -0
- package/src/components/ActivityIndicator/index.tsx +55 -0
- package/src/components/ActivityIndicator/styles.ts +18 -0
- package/src/components/Button.tsx +67 -0
- package/src/components/CenterWrapper.tsx +24 -0
- package/src/components/Checkbox.tsx +46 -0
- package/src/components/ContentView.tsx +48 -0
- package/src/components/Drawer.tsx +114 -0
- package/src/components/FileInput.tsx +48 -0
- package/src/components/FlatList.tsx +77 -0
- package/src/components/HorizontalScroll.tsx +24 -0
- package/src/components/Icon.tsx +26 -0
- package/src/components/Link.tsx +51 -0
- package/src/components/Modal/index.tsx +150 -0
- package/src/components/Modal/styles.ts +49 -0
- package/src/components/Overlay.tsx +25 -0
- package/src/components/PageRouter/Menu.tsx +49 -0
- package/src/components/PageRouter/MenuItem.tsx +55 -0
- package/src/components/PageRouter/Router.tsx +23 -0
- package/src/components/PageRouter/index.tsx +81 -0
- package/src/components/RadioInput/index.tsx +72 -0
- package/src/components/RadioInput/styles.ts +57 -0
- package/src/components/Select.tsx +60 -0
- package/src/components/Slider.tsx +14 -0
- package/src/components/Text.tsx +27 -0
- package/src/components/TextInput.tsx +219 -0
- package/src/components/Tooltip.tsx +138 -0
- package/src/components/Touchable.tsx +47 -0
- package/src/components/View.tsx +54 -0
- package/src/components/index.ts +23 -0
- package/src/index.ts +4 -0
- package/src/lib/hooks.ts +42 -0
- package/src/lib/logger.ts +15 -0
- package/src/lib/utils/cookies.ts +19 -0
- package/src/lib/utils/index.ts +4 -0
- package/src/lib/utils/pollyfils/scroll.ts +59 -0
- package/src/lib/utils/stopPropagation.ts +17 -0
- package/src/types/utility.ts +4 -0
- package/tsconfig.json +42 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scrollToElem = void 0;
|
|
4
|
+
// native smooth scrolling for Chrome, Firefox & Opera
|
|
5
|
+
// @see: https://caniuse.com/#feat=css-scroll-behavior
|
|
6
|
+
var nativeSmoothScrollTo = function (elem) {
|
|
7
|
+
window.scroll({
|
|
8
|
+
behavior: 'smooth',
|
|
9
|
+
left: 0,
|
|
10
|
+
top: elem.getBoundingClientRect().top + window.pageYOffset,
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
// polyfilled smooth scrolling for IE, Edge & Safari
|
|
14
|
+
var smoothScrollTo = function (to, duration) {
|
|
15
|
+
var element = document.scrollingElement || document.documentElement, start = element.scrollTop, change = to - start, startDate = +new Date();
|
|
16
|
+
// t = current time
|
|
17
|
+
// b = start value
|
|
18
|
+
// c = change in value
|
|
19
|
+
// d = duration
|
|
20
|
+
var easeInOutQuad = function (t, b, c, d) {
|
|
21
|
+
t /= d / 2;
|
|
22
|
+
if (t < 1)
|
|
23
|
+
return c / 2 * t * t + b;
|
|
24
|
+
t--;
|
|
25
|
+
return -c / 2 * (t * (t - 2) - 1) + b;
|
|
26
|
+
};
|
|
27
|
+
var animateScroll = function () {
|
|
28
|
+
var currentDate = +new Date();
|
|
29
|
+
var currentTime = currentDate - startDate;
|
|
30
|
+
element.scrollTop = parseInt(easeInOutQuad(currentTime, start, change, duration));
|
|
31
|
+
if (currentTime < duration) {
|
|
32
|
+
requestAnimationFrame(animateScroll);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
element.scrollTop = to;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
animateScroll();
|
|
39
|
+
};
|
|
40
|
+
// detect support for the behavior property in ScrollOptions
|
|
41
|
+
var supportsNativeSmoothScroll = 'scrollBehavior' in document.documentElement.style;
|
|
42
|
+
// smooth scrolling stub
|
|
43
|
+
var scrollToElem = function (elemSelector) {
|
|
44
|
+
if (!elemSelector) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
var elem = document.querySelector(elemSelector);
|
|
48
|
+
if (elem) {
|
|
49
|
+
if (supportsNativeSmoothScroll) {
|
|
50
|
+
nativeSmoothScrollTo(elem);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
smoothScrollTo(elem.offsetTop, 600);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
exports.scrollToElem = scrollToElem;
|
|
58
|
+
//# sourceMappingURL=scroll.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll.js","sourceRoot":"","sources":["../../../../src/lib/utils/pollyfils/scroll.ts"],"names":[],"mappings":";;;AAAA,sDAAsD;AACtD,sDAAsD;AACtD,IAAM,oBAAoB,GAAG,UAAA,IAAI;IAC/B,MAAM,CAAC,MAAM,CAAC;QACZ,QAAQ,EAAE,QAAQ;QAClB,IAAI,EAAE,CAAC;QACP,GAAG,EAAE,IAAI,CAAC,qBAAqB,EAAE,CAAC,GAAG,GAAG,MAAM,CAAC,WAAW;KAC3D,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,oDAAoD;AACpD,IAAM,cAAc,GAAG,UAAC,EAAE,EAAE,QAAQ;IAClC,IAAM,OAAO,GAAG,QAAQ,CAAC,gBAAgB,IAAI,QAAQ,CAAC,eAAe,EACnE,KAAK,GAAG,OAAO,CAAC,SAAS,EACzB,MAAM,GAAG,EAAE,GAAG,KAAK,EACnB,SAAS,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;IAE1B,mBAAmB;IACnB,kBAAkB;IAClB,sBAAsB;IACtB,eAAe;IACf,IAAM,aAAa,GAAG,UAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QAC/B,CAAC,IAAI,CAAC,GAAC,CAAC,CAAC;QACT,IAAI,CAAC,GAAG,CAAC;YAAE,OAAO,CAAC,GAAC,CAAC,GAAC,CAAC,GAAC,CAAC,GAAG,CAAC,CAAC;QAC9B,CAAC,EAAE,CAAC;QACJ,OAAO,CAAC,CAAC,GAAC,CAAC,GAAG,CAAC,CAAC,GAAC,CAAC,CAAC,GAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC,CAAC;IAEF,IAAM,aAAa,GAAG;QACpB,IAAM,WAAW,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;QAChC,IAAM,WAAW,GAAG,WAAW,GAAG,SAAS,CAAC;QAC5C,OAAO,CAAC,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;QAClF,IAAI,WAAW,GAAG,QAAQ,EAAE;YAC1B,qBAAqB,CAAC,aAAa,CAAC,CAAC;SACtC;aAAM;YACL,OAAO,CAAC,SAAS,GAAG,EAAE,CAAC;SACxB;IACH,CAAC,CAAC;IACF,aAAa,EAAE,CAAC;AAClB,CAAC,CAAC;AAEF,4DAA4D;AAC5D,IAAM,0BAA0B,GAAG,gBAAgB,IAAI,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC;AAEtF,wBAAwB;AACjB,IAAM,YAAY,GAAG,UAAA,YAAY;IACtC,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO;KACR;IAED,IAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;IAClD,IAAI,IAAI,EAAE;QACR,IAAI,0BAA0B,EAAE;YAC9B,oBAAoB,CAAC,IAAI,CAAC,CAAC;SAC5B;aAAM;YACL,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;SACrC;KACF;AACH,CAAC,CAAC;AAbW,QAAA,YAAY,gBAavB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function stopPropagation(event: any): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stopPropagation = void 0;
|
|
4
|
+
function stopPropagation(event) {
|
|
5
|
+
var _a;
|
|
6
|
+
var tryCalls = [
|
|
7
|
+
event === null || event === void 0 ? void 0 : event.stopPropagation,
|
|
8
|
+
event === null || event === void 0 ? void 0 : event.preventDefault,
|
|
9
|
+
(_a = event.nativeEvent) === null || _a === void 0 ? void 0 : _a.stopImmediatePropagation,
|
|
10
|
+
];
|
|
11
|
+
for (var _i = 0, tryCalls_1 = tryCalls; _i < tryCalls_1.length; _i++) {
|
|
12
|
+
var call = tryCalls_1[_i];
|
|
13
|
+
try {
|
|
14
|
+
call();
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.stopPropagation = stopPropagation;
|
|
21
|
+
//# sourceMappingURL=stopPropagation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stopPropagation.js","sourceRoot":"","sources":["../../../src/lib/utils/stopPropagation.ts"],"names":[],"mappings":";;;AAEA,SAAgB,eAAe,CAAC,KAAS;;IACvC,IAAM,QAAQ,GAAG;QACf,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,eAAe;QACtB,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc;QACjB,MAAA,KAAK,CAAC,WAAW,0CAAE,wBAAuC;KAC/D,CAAA;IAED,KAAmB,UAAQ,EAAR,qBAAQ,EAAR,sBAAQ,EAAR,IAAQ,EAAC;QAAvB,IAAM,IAAI,iBAAA;QACb,IAAI;YACF,IAAI,EAAE,CAAA;SACP;QAAC,OAAO,CAAC,EAAC;SACV;KACF;AAEH,CAAC;AAdD,0CAcC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utility.js","sourceRoot":"","sources":["../../src/types/utility.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@codeleap/web",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"repository": "git@github.com:codeleap-uk/codeleap-lib.git",
|
|
7
|
+
"author": "Paulo Henrique De Souza <paulosouza300272@gmail.com>",
|
|
8
|
+
"license": "UNLICENSED",
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@codeleap/config": "*",
|
|
11
|
+
"@types/react-window": "^1.8.5",
|
|
12
|
+
"react": "^17.0.2"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc --build",
|
|
16
|
+
"lint": "./node_modules/.bin/eslint -c .eslintrc.js \"./src/**/*.{ts,tsx,js,jsx}\""
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@emotion/css": "^11.7.1",
|
|
20
|
+
"@emotion/react": "^11.7.1",
|
|
21
|
+
"rc-slider": "^9.7.5",
|
|
22
|
+
"react-autosize-textarea": "^7.1.0",
|
|
23
|
+
"react-virtualized-auto-sizer": "^1.0.6",
|
|
24
|
+
"react-window": "^1.8.6",
|
|
25
|
+
"url-parse": "^1.5.4",
|
|
26
|
+
"uuid": "^8.3.2"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@codeleap/common": "*",
|
|
30
|
+
"@reach/router": "^1.3.4",
|
|
31
|
+
"@types/react": "^17.0.38",
|
|
32
|
+
"axios": "^0.24.0",
|
|
33
|
+
"gatsby-plugin-intl": "^0.3.3",
|
|
34
|
+
"react": "^17.0.2",
|
|
35
|
+
"react-dom": "^17.0.2",
|
|
36
|
+
"react-helmet": "^6.1.0"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
// );
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
|