@zuzjs/ui 0.3.9 → 0.4.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/dist/bin.js +44 -31
- package/dist/comps/base.d.ts +11 -1
- package/dist/comps/base.js +23 -2
- package/dist/comps/box.d.ts +2 -0
- package/dist/comps/box.js +0 -7
- package/dist/comps/button.d.ts +2 -0
- package/dist/comps/button.js +0 -11
- package/dist/comps/checkbox.d.ts +2 -0
- package/dist/comps/checkbox.js +0 -18
- package/dist/comps/contextmenu.d.ts +15 -0
- package/dist/comps/contextmenu.js +9 -0
- package/dist/comps/cover.d.ts +2 -0
- package/dist/comps/cover.js +0 -24
- package/dist/comps/form.d.ts +2 -0
- package/dist/comps/form.js +0 -147
- package/dist/comps/heading.d.ts +2 -0
- package/dist/comps/heading.js +0 -13
- package/dist/comps/icon.d.ts +2 -0
- package/dist/comps/icon.js +0 -10
- package/dist/comps/image.d.ts +13 -0
- package/dist/comps/image.js +8 -0
- package/dist/comps/input.d.ts +2 -0
- package/dist/comps/input.js +0 -15
- package/dist/comps/sheet.d.ts +2 -0
- package/dist/comps/sheet.js +0 -57
- package/dist/comps/spinner.d.ts +2 -0
- package/dist/comps/spinner.js +0 -1
- package/dist/funs/colors.d.ts +0 -6
- package/dist/funs/colors.js +0 -6
- package/dist/funs/css.d.ts +25 -258
- package/dist/funs/css.js +368 -256
- package/dist/funs/index.d.ts +9 -2
- package/dist/funs/index.js +32 -12
- package/dist/funs/stylesheet.d.ts +7 -242
- package/dist/funs/stylesheet.js +96 -7
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/styles.css +1 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -5,10 +5,12 @@ import chokidar from 'chokidar';
|
|
|
5
5
|
import path from "path";
|
|
6
6
|
import CSS from "./funs/css.js";
|
|
7
7
|
import pc from "picocolors";
|
|
8
|
+
import { FIELNAME_KEY } from "./funs/index.js";
|
|
8
9
|
program
|
|
9
10
|
.option(`-d, --debug`)
|
|
10
11
|
.option(`-v, --version`)
|
|
11
|
-
.option(`-root, --root <char>`)
|
|
12
|
+
.option(`-root, --root <char>`)
|
|
13
|
+
.option(`-f, --file <char>`);
|
|
12
14
|
program.parse();
|
|
13
15
|
const options = program.opts();
|
|
14
16
|
const getAllFiles = (dir, extn, files, result, regex) => {
|
|
@@ -35,62 +37,71 @@ const getAllFiles = (dir, extn, files, result, regex) => {
|
|
|
35
37
|
};
|
|
36
38
|
const rebuild = (f) => {
|
|
37
39
|
const raw = fs.readFileSync(f, `utf8`);
|
|
38
|
-
|
|
40
|
+
let _filePath = path.relative(process.cwd(), f);
|
|
41
|
+
if (!_filePath.startsWith(`/`))
|
|
42
|
+
_filePath = `/${_filePath}`;
|
|
43
|
+
const list = [`${FIELNAME_KEY}:${_filePath}`];
|
|
39
44
|
const processMatch = (matches, type) => {
|
|
45
|
+
const makeV2 = (v1) => {
|
|
46
|
+
let v2 = v1
|
|
47
|
+
.trim()
|
|
48
|
+
.slice(1, -1);
|
|
49
|
+
if (v2.includes(`\n`)) {
|
|
50
|
+
v2 = v2.split(`\n`).reduce((arr, v) => {
|
|
51
|
+
if (v.trim() != ``) {
|
|
52
|
+
v = v.trim().endsWith(`,`) ? v.slice(0, -1) : v;
|
|
53
|
+
arr.push(v.trim());
|
|
54
|
+
}
|
|
55
|
+
return arr;
|
|
56
|
+
}, []).join(` `);
|
|
57
|
+
}
|
|
58
|
+
if (v2.startsWith(`[`) && v2.endsWith(`]`))
|
|
59
|
+
v2 = v2.slice(1, -1);
|
|
60
|
+
return v2.trim();
|
|
61
|
+
};
|
|
40
62
|
if (matches && matches.length > 0) {
|
|
41
63
|
matches.map((m) => {
|
|
42
64
|
let v2;
|
|
43
65
|
if (type == `as`) {
|
|
44
66
|
const [x, v1] = m.split(/as\s*=/);
|
|
45
|
-
v2 = v1
|
|
67
|
+
v2 = makeV2(v1);
|
|
46
68
|
}
|
|
47
69
|
else if (type == `css`) {
|
|
48
70
|
const v1 = m.split(/css\s*\(/)[1].slice(0, -1);
|
|
49
|
-
v2 = v1.trim()
|
|
71
|
+
v2 = makeV2(v1.trim());
|
|
50
72
|
}
|
|
51
73
|
list.push(v2);
|
|
52
|
-
// console.log(type, v2)
|
|
53
|
-
// const _ = v2!.match(/\w+:\$?\w+|\$?\w+/g)
|
|
54
|
-
// if(_){
|
|
55
|
-
// _.map((n:string) => !list.includes(n) && list.push(n))
|
|
56
|
-
// }
|
|
57
74
|
});
|
|
58
75
|
}
|
|
59
76
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*/
|
|
63
|
-
processMatch(raw.match(/as\s*=\s*\{([^{}]|{([^{}]|{[^{}]*})*})*\}/g), `as`);
|
|
64
|
-
/**
|
|
65
|
-
* match css()
|
|
66
|
-
*/
|
|
67
|
-
processMatch(raw.match(/css\(\s*`([^`]*?([$&]{[^}]*})?[^`]*)*`\s*\)/g), `css`);
|
|
77
|
+
processMatch(raw.match(/as\s*=\s*(?:\{([^{}]|{([^{}]|{[^{}]*})*})*\}|'([^']*)'|"([^"]*)")/g), `as`);
|
|
78
|
+
processMatch(raw.match(/css\(\s*(?:\[\s*([\s\S]*?)\s*\]|\s*`([\s\S]*?)`)\s*\)/g), `css`);
|
|
68
79
|
return list;
|
|
69
80
|
};
|
|
70
81
|
const rebuildAll = () => {
|
|
71
82
|
console.log(pc.gray(`○ Building Zuz CSS`));
|
|
83
|
+
const cssBuilder = new CSS();
|
|
72
84
|
const files = getAllFiles(process.cwd(), `.jsx`);
|
|
73
85
|
if (files.length > 0) {
|
|
74
86
|
const as = [];
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
if (r && r.length > 0)
|
|
80
|
-
as.push(r);
|
|
87
|
+
if (options.file) {
|
|
88
|
+
const r = rebuild(files.filter(f => f.endsWith(options.file))[0]);
|
|
89
|
+
if (r && r.length > 0) {
|
|
90
|
+
as.push(cssBuilder.Build([r], true).sheet);
|
|
81
91
|
}
|
|
82
|
-
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
files.map(f => {
|
|
83
95
|
const r = rebuild(f);
|
|
84
|
-
if (r && r.length > 0)
|
|
85
|
-
as.push(r);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
96
|
+
if (r && r.length > 0) {
|
|
97
|
+
as.push(cssBuilder.Build([r], true).sheet);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
const sheet = as.join(`\n`);
|
|
90
102
|
if (!fs.existsSync(path.join(process.cwd(), `src`, `app`, `css`))) {
|
|
91
103
|
fs.mkdirSync(path.join(process.cwd(), `src`, `app`, `css`));
|
|
92
104
|
}
|
|
93
|
-
// console.log(sheet)
|
|
94
105
|
fs.writeFileSync(path.join(process.cwd(), `src`, `app`, `css`, `zuz.scss`), sheet, {
|
|
95
106
|
encoding: `utf8`,
|
|
96
107
|
flag: `w+`
|
|
@@ -104,4 +115,6 @@ const watcher = chokidar.watch([
|
|
|
104
115
|
ignored: (p) => p.includes(`/dist`) || p.includes('node_modules'),
|
|
105
116
|
persistent: true
|
|
106
117
|
});
|
|
118
|
+
if (options.file)
|
|
119
|
+
console.log(pc.gray(`○ Watching ${options.file}`));
|
|
107
120
|
watcher.on(`change`, rebuildAll);
|
package/dist/comps/base.d.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef, ElementType } from "react";
|
|
2
|
+
import { dynamicObject } from "../types";
|
|
3
|
+
export interface animationProps {
|
|
4
|
+
from?: dynamicObject;
|
|
5
|
+
to?: dynamicObject;
|
|
6
|
+
when?: boolean;
|
|
7
|
+
duration?: number;
|
|
8
|
+
delay?: number;
|
|
9
|
+
curve?: string;
|
|
10
|
+
}
|
|
2
11
|
interface BaseProps<T extends ElementType> {
|
|
3
12
|
tag?: T;
|
|
4
|
-
as?: string;
|
|
13
|
+
as?: string | string[];
|
|
5
14
|
className?: string;
|
|
6
15
|
propsToRemove?: string[];
|
|
16
|
+
animate?: animationProps;
|
|
7
17
|
}
|
|
8
18
|
export type Props<T extends ElementType> = BaseProps<T> & ComponentPropsWithoutRef<T>;
|
|
9
19
|
declare const With: import("react").ForwardRefExoticComponent<Omit<Props<ElementType>, "ref"> & import("react").RefAttributes<Element>>;
|
package/dist/comps/base.js
CHANGED
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
import { createElement, forwardRef } from "react";
|
|
2
2
|
import { css, cleanProps } from "../funs";
|
|
3
|
-
|
|
3
|
+
import { buildWithStyles } from "../funs/css";
|
|
4
|
+
const With = forwardRef(({ tag, as, animate, className, propsToRemove, style, ...rest }, ref) => {
|
|
4
5
|
const Comp = tag || 'div';
|
|
5
|
-
|
|
6
|
+
let cx = [];
|
|
7
|
+
if (as) {
|
|
8
|
+
cx = css().Build(`string` == typeof as ? as : as.join(` `)).cx;
|
|
9
|
+
}
|
|
10
|
+
const { from, to, when, duration, delay, curve } = animate || {};
|
|
11
|
+
let _style = {};
|
|
12
|
+
const _transition = from && to ? { transition: `all ${duration || `0.2`}s ${curve || `linear`} ${delay || 0}s` } : {};
|
|
13
|
+
if (undefined === when) {
|
|
14
|
+
_style = { ...from, ...to };
|
|
15
|
+
}
|
|
16
|
+
else if (true === when) {
|
|
17
|
+
_style = { ...(to || {}) };
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
_style = from || {};
|
|
21
|
+
}
|
|
6
22
|
return createElement(Comp, {
|
|
23
|
+
style: {
|
|
24
|
+
...buildWithStyles(_style),
|
|
25
|
+
..._transition,
|
|
26
|
+
...style
|
|
27
|
+
},
|
|
7
28
|
className: [className, ...cx].join(' ').trim(),
|
|
8
29
|
...cleanProps(rest, propsToRemove || []),
|
|
9
30
|
ref
|
package/dist/comps/box.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { animationProps } from "./base";
|
|
1
2
|
declare const Box: import("react").ForwardRefExoticComponent<{
|
|
2
3
|
as?: string;
|
|
4
|
+
animate?: animationProps;
|
|
3
5
|
} & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
4
6
|
export default Box;
|
package/dist/comps/box.js
CHANGED
|
@@ -5,11 +5,4 @@ const Box = forwardRef((props, ref) => {
|
|
|
5
5
|
const { as, ...rest } = props;
|
|
6
6
|
return _jsx(With, { as: as, ...rest, ref: ref });
|
|
7
7
|
});
|
|
8
|
-
// const Box = ( props : UIProps<HTMLDivElement> ) => {
|
|
9
|
-
// const { cx } = css.Build(props.as)
|
|
10
|
-
// return <div
|
|
11
|
-
// ref={props.ref}
|
|
12
|
-
// className={cx.join(` `)}
|
|
13
|
-
// {...(cleanProps(props) as UIProps<HTMLDivElement>)}>{props.children}</div>
|
|
14
|
-
// }
|
|
15
8
|
export default Box;
|
package/dist/comps/button.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { animationProps } from "./base";
|
|
1
2
|
declare const Button: import("react").ForwardRefExoticComponent<{
|
|
2
3
|
as?: string;
|
|
4
|
+
animate?: animationProps;
|
|
3
5
|
} & Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
4
6
|
export default Button;
|
package/dist/comps/button.js
CHANGED
|
@@ -5,15 +5,4 @@ const Button = forwardRef((props, ref) => {
|
|
|
5
5
|
const { as, ...rest } = props;
|
|
6
6
|
return _jsx(With, { tag: `button`, as: as, ...rest, ref: ref });
|
|
7
7
|
});
|
|
8
|
-
// import { Ref } from "react";
|
|
9
|
-
// import { css, cleanProps } from "../funs";
|
|
10
|
-
// import { UIProps } from "../types/interfaces";
|
|
11
|
-
// const Button = ( props: UIProps<HTMLButtonElement> ) => {
|
|
12
|
-
// const { as, ref, children } = props
|
|
13
|
-
// const { cx } = css.Build(as)
|
|
14
|
-
// return <button
|
|
15
|
-
// ref={ref}
|
|
16
|
-
// className={cx.join(` `)}
|
|
17
|
-
// {...(cleanProps(props) as UIProps<HTMLButtonElement>)}>{children}</button>
|
|
18
|
-
// }
|
|
19
8
|
export default Button;
|
package/dist/comps/checkbox.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { animationProps } from "./base";
|
|
1
2
|
declare const CheckBox: import("react").ForwardRefExoticComponent<{
|
|
2
3
|
as?: string;
|
|
4
|
+
animate?: animationProps;
|
|
3
5
|
} & Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
4
6
|
export default CheckBox;
|
package/dist/comps/checkbox.js
CHANGED
|
@@ -7,22 +7,4 @@ const CheckBox = forwardRef((props, ref) => {
|
|
|
7
7
|
const [checked, setChecked] = useState(props.checked || false);
|
|
8
8
|
return _jsx(With, { tag: `label`, className: `zuz-checkbox${checked ? ` is-checked` : ``} rel`, as: as, ...rest, children: _jsx(With, { tag: `input`, ref: ref, type: `checkbox`, className: `abs`, name: name, required: required || false, onChange: (e) => setChecked(e.target.checked) }) });
|
|
9
9
|
});
|
|
10
|
-
// import { DetailedHTMLProps, HTMLAttributes, ReactNode, Ref, useState } from "react";
|
|
11
|
-
// import { cleanProps, css } from "../funs";
|
|
12
|
-
// import { UIProps } from "../types/interfaces";
|
|
13
|
-
// const CheckBox = ( props : UIProps<HTMLInputElement> ) => {
|
|
14
|
-
// const { cx } = css.Build(props.as)
|
|
15
|
-
// const [ checked, setChecked ] = useState(props.checked || false)
|
|
16
|
-
// return <label { ...({
|
|
17
|
-
// className: `zuz-checkbox${checked ? ` is-checked` : ``} rel${cx.length > 0 ? ` ` + cx.join(` `) : ``}`
|
|
18
|
-
// }) as UIProps<HTMLLabelElement>}>
|
|
19
|
-
// <input type='checkbox'
|
|
20
|
-
// ref={props.ref}
|
|
21
|
-
// onChange={e => {
|
|
22
|
-
// setChecked(e.target.checked)
|
|
23
|
-
// }}
|
|
24
|
-
// className={`abs`}
|
|
25
|
-
// {...(cleanProps(props) as UIProps<HTMLInputElement>)} />
|
|
26
|
-
// </label>
|
|
27
|
-
// }
|
|
28
10
|
export default CheckBox;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { animationProps } from "./base";
|
|
2
|
+
export interface ContextMenuItem {
|
|
3
|
+
label: string;
|
|
4
|
+
labelColor?: string;
|
|
5
|
+
icon?: string;
|
|
6
|
+
iconColor?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
onSelect: () => void;
|
|
9
|
+
}
|
|
10
|
+
declare const ContextMenu: import("react").ForwardRefExoticComponent<{
|
|
11
|
+
as?: string;
|
|
12
|
+
items: ContextMenuItem[];
|
|
13
|
+
animate?: animationProps;
|
|
14
|
+
} & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
15
|
+
export default ContextMenu;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import With from "./base";
|
|
4
|
+
const ContextMenu = forwardRef((props, ref) => {
|
|
5
|
+
const { as, items, ...rest } = props;
|
|
6
|
+
return _jsx(With, { as: as, className: `zuz-context-menu abs flex cols`, ...rest, ref: ref, children: items.map((item, index) => item.label == `-` ? _jsx(With, { as: `context-line` }, `${index}-line`) :
|
|
7
|
+
_jsxs(With, { onClick: item.onSelect, as: `button`, className: `context-menu-item flex aic ${item.className || ``}`.trim(), children: [_jsx(With, { as: `div`, className: `ico icon-${item.icon}`.trim(), style: item.iconColor ? { color: item.iconColor } : {} }), _jsx(With, { as: `h1`, className: `flex aic`, style: item.labelColor ? { color: item.labelColor } : {}, children: item.label })] }, `item-${item.label.replace(/\s/g, `-`)}-${index}`)) });
|
|
8
|
+
});
|
|
9
|
+
export default ContextMenu;
|
package/dist/comps/cover.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
import { animationProps } from "./base";
|
|
2
3
|
import { SpinnerProps } from "./spinner";
|
|
3
4
|
export interface CoverProps extends ComponentPropsWithoutRef<`div`> {
|
|
4
5
|
tag?: string;
|
|
@@ -6,6 +7,7 @@ export interface CoverProps extends ComponentPropsWithoutRef<`div`> {
|
|
|
6
7
|
spinner?: SpinnerProps;
|
|
7
8
|
color?: string;
|
|
8
9
|
as?: string;
|
|
10
|
+
animate?: animationProps;
|
|
9
11
|
}
|
|
10
12
|
declare const Cover: import("react").ForwardRefExoticComponent<CoverProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
11
13
|
export default Cover;
|
package/dist/comps/cover.js
CHANGED
|
@@ -9,28 +9,4 @@ const Cover = forwardRef((props, ref) => {
|
|
|
9
9
|
backgroundColor: hexToRgba(color || `#ffffff`, .9)
|
|
10
10
|
}, as: as, ...rest, children: [_jsx(Spinner, { ...spinner }), _jsx(With, { tag: `h1`, className: `label`, children: message || `loading` })] }));
|
|
11
11
|
});
|
|
12
|
-
// import { ReactNode } from "react";
|
|
13
|
-
// import { css, cleanProps, hexToRgba } from "../funs";
|
|
14
|
-
// import { UIProps } from "../types/interfaces";
|
|
15
|
-
// import Spinner, { SpinnerProps } from "./spinner";
|
|
16
|
-
// import Heading from "./heading";
|
|
17
|
-
// export interface CoverProps extends UIProps<HTMLDivElement> {
|
|
18
|
-
// spinner?: SpinnerProps
|
|
19
|
-
// }
|
|
20
|
-
// const Cover = ( props : CoverProps ) => {
|
|
21
|
-
// const { cx } = css.Build(props.as)
|
|
22
|
-
// return <div
|
|
23
|
-
// ref={props.ref}
|
|
24
|
-
// style={{
|
|
25
|
-
// backgroundColor: hexToRgba(props.color || `#ffffff`, .9)
|
|
26
|
-
// }}
|
|
27
|
-
// className={`zuz-cover flex aic jcc abs fill ${cx.join(` `)}`.trim()}
|
|
28
|
-
// {...(cleanProps(props) as UIProps<HTMLDivElement>)}>
|
|
29
|
-
// {<Spinner {...( props.spinner || {} as SpinnerProps) } />}
|
|
30
|
-
// {/* <span></span> */}
|
|
31
|
-
// {/* {<Heading>{props.message}</Heading>} */}
|
|
32
|
-
// {/* {props.message ? <Heading>{props.message}</Heading> : null} */}
|
|
33
|
-
// {/* { ...({} as HTMLHeadingElement) } */}
|
|
34
|
-
// </div>
|
|
35
|
-
// }
|
|
36
12
|
export default Cover;
|
package/dist/comps/form.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { animationProps } from "./base";
|
|
1
2
|
import { SpinnerProps } from "./spinner";
|
|
2
3
|
import { dynamicObject } from "../types";
|
|
3
4
|
export interface FormProps {
|
|
4
5
|
as?: string;
|
|
6
|
+
animate?: animationProps;
|
|
5
7
|
action?: string;
|
|
6
8
|
errors?: string[];
|
|
7
9
|
spinner?: SpinnerProps;
|
package/dist/comps/form.js
CHANGED
|
@@ -16,7 +16,6 @@ const Form = forwardRef((props, ref) => {
|
|
|
16
16
|
const _nodes = (query) => _ref.current.querySelectorAll(query);
|
|
17
17
|
const _validate = (el) => {
|
|
18
18
|
if (el.required) {
|
|
19
|
-
// console.log(el.type, el.checked)
|
|
20
19
|
if (el.type == `checkbox` && el.checked == false) {
|
|
21
20
|
return false;
|
|
22
21
|
}
|
|
@@ -98,10 +97,6 @@ const Form = forwardRef((props, ref) => {
|
|
|
98
97
|
sheet.current.show(errorMsg, 4, SHEET.Error);
|
|
99
98
|
}
|
|
100
99
|
else if (action) {
|
|
101
|
-
/**
|
|
102
|
-
* We have action so
|
|
103
|
-
* submit to rest api manually
|
|
104
|
-
*/
|
|
105
100
|
startTransition(async () => {
|
|
106
101
|
setLoading(true);
|
|
107
102
|
sheet.current.hide();
|
|
@@ -142,146 +137,4 @@ const Form = forwardRef((props, ref) => {
|
|
|
142
137
|
useEffect(_init, []);
|
|
143
138
|
return _jsxs(With, { as: as, className: `rel`, ref: _ref, propsToRemove: [`withData`, `action`, `onSubmit`, `onSuccess`, `onError`], ...rest, children: [_jsx(Sheet, { ref: sheet }), loading && _jsx(Cover, { message: cover.message || `working`, ...{ spinner, color: cover.color || `#ffffff` } }), children] });
|
|
144
139
|
});
|
|
145
|
-
// import { RefObject, useEffect, useRef, useState } from "react";
|
|
146
|
-
// import { css, cleanProps, isEmail } from "../funs";
|
|
147
|
-
// import { dynamicObject, FormInputs } from "../types";
|
|
148
|
-
// import { UIProps } from "../types/interfaces";
|
|
149
|
-
// import Cover, { CoverProps } from "./cover";
|
|
150
|
-
// import { SpinnerProps } from "./spinner";
|
|
151
|
-
// import { FORMVALIDATION, SHEET } from "../types/enums";
|
|
152
|
-
// import Sheet, { SheetHandler, SheetProps } from "./sheet";
|
|
153
|
-
// const Form = ( props : UIProps<HTMLDivElement> ) => {
|
|
154
|
-
// const { as, ref, errors, at, cover, spinner, onSubmit, onSuccess, onError, children } = props
|
|
155
|
-
// const { cx } = css.Build(as)
|
|
156
|
-
// const [ loading, setLoading ] = useState(false)
|
|
157
|
-
// const [ sheetType, setSheetType ] = useState(SHEET.Default)
|
|
158
|
-
// const sheet = useRef<SheetHandler>(null)
|
|
159
|
-
// const _ref = useRef(ref || null)
|
|
160
|
-
// const _nodes = ( query: string ) => (_ref as unknown as RefObject<HTMLDivElement>).current.querySelectorAll(query)
|
|
161
|
-
// const _init = () => {
|
|
162
|
-
// const _submit = _nodes(`[type=submit]`)
|
|
163
|
-
// if ( !_submit || _submit.length == 0 ) {
|
|
164
|
-
// console.error(`You should add at least 1 button with type=\`SUBMIT\``)
|
|
165
|
-
// }
|
|
166
|
-
// else {
|
|
167
|
-
// _submit.forEach(el => {
|
|
168
|
-
// (el as HTMLButtonElement).addEventListener(`click`, _onSubmit)
|
|
169
|
-
// })
|
|
170
|
-
// }
|
|
171
|
-
// }
|
|
172
|
-
// const _validate = ( el: any ) : boolean => {
|
|
173
|
-
// if ( el.required ){
|
|
174
|
-
// if ( el.type == `checkbox` && el.checked == false ){
|
|
175
|
-
// return false
|
|
176
|
-
// }
|
|
177
|
-
// else if ( el.value == `` )
|
|
178
|
-
// return false
|
|
179
|
-
// }
|
|
180
|
-
// if ( el.getAttribute(`with`) ){
|
|
181
|
-
// let _with = el.getAttribute(`with`)
|
|
182
|
-
// if ( _with.includes(`@`) ){
|
|
183
|
-
// _with = _with.split(`@`)[0]
|
|
184
|
-
// if ( _with == `match` ){
|
|
185
|
-
// _with = FORMVALIDATION.MatchField
|
|
186
|
-
// }
|
|
187
|
-
// }
|
|
188
|
-
// switch ( _with.toUpperCase() ){
|
|
189
|
-
// case FORMVALIDATION.Email:
|
|
190
|
-
// return isEmail(el.value)
|
|
191
|
-
// break;
|
|
192
|
-
// case FORMVALIDATION.Uri:
|
|
193
|
-
// console.log(`Add FORMVALIDATION.Uri`)
|
|
194
|
-
// return false
|
|
195
|
-
// break;
|
|
196
|
-
// case FORMVALIDATION.Password:
|
|
197
|
-
// console.log(`Add FORMVALIDATION.Password`)
|
|
198
|
-
// return false
|
|
199
|
-
// break;
|
|
200
|
-
// case FORMVALIDATION.MatchField:
|
|
201
|
-
// const [ __, field ] = el.getAttribute(`with`).split(`@`)
|
|
202
|
-
// const _el = document.querySelector<FormInputs>(`[name=${field.trim()}]`)
|
|
203
|
-
// if ( !_el ) return false
|
|
204
|
-
// console.log(`matching`, _el.name, _el.value, el.name, el.value)
|
|
205
|
-
// if ( _el && _el.value != el.value ){
|
|
206
|
-
// return false
|
|
207
|
-
// }
|
|
208
|
-
// break;
|
|
209
|
-
// default:
|
|
210
|
-
// return true
|
|
211
|
-
// }
|
|
212
|
-
// }
|
|
213
|
-
// return true;
|
|
214
|
-
// }
|
|
215
|
-
// const _buildFormData = ( ) : {
|
|
216
|
-
// error: boolean,
|
|
217
|
-
// errorMsg: string,
|
|
218
|
-
// data: FormData | dynamicObject
|
|
219
|
-
// } => {
|
|
220
|
-
// const data : dynamicObject = {}
|
|
221
|
-
// let _error: HTMLElement | null = null
|
|
222
|
-
// let _errorMsg: HTMLElement | string | null = null
|
|
223
|
-
// Array.from(_nodes(`[name]`))
|
|
224
|
-
// .forEach((el : any) => {
|
|
225
|
-
// let valid = true
|
|
226
|
-
// if ( el.required || el.with )
|
|
227
|
-
// valid = _validate(el)
|
|
228
|
-
// data[el.name] = {
|
|
229
|
-
// valid: valid,
|
|
230
|
-
// value: el.value
|
|
231
|
-
// }
|
|
232
|
-
// if ( !valid ){
|
|
233
|
-
// if ( _error == null ){
|
|
234
|
-
// _error = el
|
|
235
|
-
// _errorMsg = errors[el.name]
|
|
236
|
-
// }
|
|
237
|
-
// el.classList.add(`input-with-error`)
|
|
238
|
-
// }else
|
|
239
|
-
// el.classList.remove(`input-with-error`)
|
|
240
|
-
// })
|
|
241
|
-
// if ( _error )
|
|
242
|
-
// (_error as HTMLElement).focus()
|
|
243
|
-
// return {
|
|
244
|
-
// error: _error != null,
|
|
245
|
-
// errorMsg: _errorMsg || `Fix errors to continue...`,
|
|
246
|
-
// data
|
|
247
|
-
// }
|
|
248
|
-
// }
|
|
249
|
-
// const _onSubmit = ( ) => {
|
|
250
|
-
// const data = _buildFormData()
|
|
251
|
-
// if ( data.error ){
|
|
252
|
-
// sheet.current!.show(data.errorMsg, 4, SHEET.Error)
|
|
253
|
-
// }
|
|
254
|
-
// else{
|
|
255
|
-
// setLoading(true)
|
|
256
|
-
// }
|
|
257
|
-
// // if ( props.onSubmit ) {
|
|
258
|
-
// // // if ( data ){
|
|
259
|
-
// // // if ( props.onPost )
|
|
260
|
-
// // // props.onPost( data )
|
|
261
|
-
// // // else
|
|
262
|
-
// // // props.onGet! ( data )
|
|
263
|
-
// // // }
|
|
264
|
-
// // }
|
|
265
|
-
// // else {
|
|
266
|
-
// // console.warn(`onSubmit missing for this form.`)
|
|
267
|
-
// // }
|
|
268
|
-
// }
|
|
269
|
-
// useEffect(() => {
|
|
270
|
-
// _init()
|
|
271
|
-
// }, [])
|
|
272
|
-
// return <div
|
|
273
|
-
// ref={_ref as unknown as RefObject<HTMLDivElement>}
|
|
274
|
-
// className={`rel ${cx.join(` `)}`.trim()}
|
|
275
|
-
// {...(cleanProps(props, [`withData`, `at`, `onSubmit`, `onSuccess`, `onError`]) as UIProps<HTMLDivElement>)}>
|
|
276
|
-
// {/**
|
|
277
|
-
// * Sheet
|
|
278
|
-
// */}
|
|
279
|
-
// <Sheet ref={sheet} />
|
|
280
|
-
// {/**
|
|
281
|
-
// * Cover Loader
|
|
282
|
-
// */}
|
|
283
|
-
// { loading && <Cover {...{ spinner, color: cover || `#ffffff` } as CoverProps} /> }
|
|
284
|
-
// {children}
|
|
285
|
-
// </div>
|
|
286
|
-
// }
|
|
287
140
|
export default Form;
|
package/dist/comps/heading.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
+
import { animationProps } from "./base";
|
|
2
3
|
declare const Heading: import("react").ForwardRefExoticComponent<{
|
|
3
4
|
as?: string;
|
|
4
5
|
h?: number | string;
|
|
5
6
|
html?: ReactNode | string;
|
|
7
|
+
animate?: animationProps;
|
|
6
8
|
} & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
7
9
|
export default Heading;
|
package/dist/comps/heading.js
CHANGED
|
@@ -5,17 +5,4 @@ const Heading = forwardRef((props, ref) => {
|
|
|
5
5
|
const { as, h, html, children, ...rest } = props;
|
|
6
6
|
return _jsx(With, { tag: `h${h || 1}`, as: as, ref: ref, ...rest, children: props.html ? _jsx("span", { ...({ dangerouslySetInnerHTML: { __html: html } }) }) : children });
|
|
7
7
|
});
|
|
8
|
-
// import { Ref } from "react"
|
|
9
|
-
// import { css, cleanProps } from "../funs";
|
|
10
|
-
// import { UIProps } from "../types/interfaces";
|
|
11
|
-
// const Heading = ( props: UIProps<HTMLHeadingElement> ) => {
|
|
12
|
-
// const { children, ref, h, html } = props
|
|
13
|
-
// let Tag : string = `h${h || 1}`;
|
|
14
|
-
// const HeadingTag = Tag as `h1` | `h2` | `h3` | `h4` | `h5` | `h6`
|
|
15
|
-
// const { cx } = css.Build(props.as)
|
|
16
|
-
// return <HeadingTag
|
|
17
|
-
// ref={ref}
|
|
18
|
-
// className={cx.join(` `)}
|
|
19
|
-
// {...(cleanProps(props) as UIProps<HTMLHeadingElement>)}>{props.html ? <span { ...({dangerouslySetInnerHTML:{ __html: html }}) as UIProps<HTMLSpanElement>} /> : children}</HeadingTag>
|
|
20
|
-
// }
|
|
21
8
|
export default Heading;
|
package/dist/comps/icon.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { animationProps } from "./base";
|
|
1
2
|
declare const Icon: import("react").ForwardRefExoticComponent<{
|
|
2
3
|
name: string;
|
|
3
4
|
as?: string;
|
|
5
|
+
animate?: animationProps;
|
|
4
6
|
} & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
5
7
|
export default Icon;
|
package/dist/comps/icon.js
CHANGED
|
@@ -5,14 +5,4 @@ const Icon = forwardRef((props, ref) => {
|
|
|
5
5
|
const { as, name, ...rest } = props;
|
|
6
6
|
return _jsx(With, { className: `icon-${name}`, as: as, ...rest, ref: ref });
|
|
7
7
|
});
|
|
8
|
-
// import { DetailedHTMLProps, HTMLAttributes, ReactNode, Ref } from "react";
|
|
9
|
-
// import { css, cleanProps } from "../funs";
|
|
10
|
-
// import { UIProps } from "../types/interfaces";
|
|
11
|
-
// const Icon = ( props : UIProps<HTMLDivElement> ) => {
|
|
12
|
-
// const { cx } = css.Build(props.as)
|
|
13
|
-
// return <div
|
|
14
|
-
// ref={props.ref}
|
|
15
|
-
// className={`icon-${props.name}${cx.length > 0 ? ` ` + cx.join(` `) : ``}`}
|
|
16
|
-
// {...(cleanProps(props) as UIProps<HTMLDivElement>)}>{props.children}</div>
|
|
17
|
-
// }
|
|
18
8
|
export default Icon;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { animationProps } from "./base";
|
|
2
|
+
import React from "react";
|
|
3
|
+
interface ImageProps {
|
|
4
|
+
width: string | number;
|
|
5
|
+
height: string | number;
|
|
6
|
+
as?: string;
|
|
7
|
+
animate?: animationProps;
|
|
8
|
+
src: string;
|
|
9
|
+
alt: string;
|
|
10
|
+
crossover?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const Image: React.ForwardRefExoticComponent<ImageProps & Omit<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
13
|
+
export default Image;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import With from "./base";
|
|
4
|
+
const Image = forwardRef((props, ref) => {
|
|
5
|
+
const { as, width, height, ...rest } = props;
|
|
6
|
+
return _jsx(With, { tag: `img`, as: as, ...rest, ref: ref });
|
|
7
|
+
});
|
|
8
|
+
export default Image;
|
package/dist/comps/input.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { animationProps } from "./base";
|
|
1
2
|
import { FORMVALIDATION } from "../types/enums";
|
|
2
3
|
declare const Input: import("react").ForwardRefExoticComponent<{
|
|
3
4
|
required?: FORMVALIDATION;
|
|
4
5
|
as?: string;
|
|
6
|
+
animate?: animationProps;
|
|
5
7
|
} & Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
6
8
|
export default Input;
|
package/dist/comps/input.js
CHANGED
|
@@ -5,19 +5,4 @@ const Input = forwardRef((props, ref) => {
|
|
|
5
5
|
const { as, ...rest } = props;
|
|
6
6
|
return _jsx(With, { tag: `input`, as: as, ...rest, ref: ref });
|
|
7
7
|
});
|
|
8
|
-
// import { DetailedHTMLProps, HTMLAttributes, InputHTMLAttributes, ReactNode, Ref } from "react";
|
|
9
|
-
// import { css, cleanProps } from "../funs";
|
|
10
|
-
// import { UIProps } from "../types/interfaces";
|
|
11
|
-
// import { FORMVALIDATION } from "../types/enums";
|
|
12
|
-
// export interface InputProps extends UIProps<HTMLInputElement> {
|
|
13
|
-
// required?: FORMVALIDATION
|
|
14
|
-
// }
|
|
15
|
-
// const Input = ( props : InputProps ) => {
|
|
16
|
-
// const { cx } = css.Build(props.as)
|
|
17
|
-
// // console.log(`inputing...`)
|
|
18
|
-
// return <input
|
|
19
|
-
// ref={props.ref}
|
|
20
|
-
// className={cx.join(` `)}
|
|
21
|
-
// {...(cleanProps(props) as UIProps<HTMLInputElement>)} />
|
|
22
|
-
// }
|
|
23
8
|
export default Input;
|
package/dist/comps/sheet.d.ts
CHANGED