@zuzjs/ui 0.5.3 → 0.5.5
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 +29 -3
- package/dist/comps/accordion.d.ts +12 -0
- package/dist/comps/accordion.js +13 -0
- package/dist/comps/alert.d.ts +15 -0
- package/dist/comps/alert.js +15 -0
- package/dist/comps/animate.d.ts +1 -1
- package/dist/comps/avatar.d.ts +13 -0
- package/dist/comps/avatar.js +11 -0
- package/dist/comps/base.d.ts +4 -13
- package/dist/comps/base.js +3 -2
- package/dist/comps/box.d.ts +2 -2
- package/dist/comps/box.js +10 -3
- package/dist/comps/button.d.ts +3 -5
- package/dist/comps/button.js +12 -3
- package/dist/comps/checkbox.d.ts +1 -1
- package/dist/comps/checkbox.js +19 -0
- package/dist/comps/contextmenu.d.ts +1 -1
- package/dist/comps/cover.d.ts +1 -1
- package/dist/comps/cover.js +15 -0
- package/dist/comps/drawer.js +5 -1
- package/dist/comps/editor.js +8 -1
- package/dist/comps/form.d.ts +35 -5
- package/dist/comps/form.js +67 -21
- package/dist/comps/heading.js +13 -0
- package/dist/comps/icon.d.ts +4 -5
- package/dist/comps/icon.js +15 -3
- package/dist/comps/image.d.ts +1 -1
- package/dist/comps/input.d.ts +2 -8
- package/dist/comps/input.js +5 -5
- package/dist/comps/password.d.ts +3 -0
- package/dist/comps/password.js +30 -0
- package/dist/comps/select.d.ts +2 -1
- package/dist/comps/select.js +28 -3
- package/dist/comps/sheet.js +3 -0
- package/dist/comps/spinner.d.ts +1 -1
- package/dist/comps/spinner.js +1 -0
- package/dist/comps/tabview.js +8 -1
- package/dist/comps/textwheel.d.ts +1 -1
- package/dist/comps/textwheel.js +2 -0
- package/dist/comps/useBase/base.types.d.ts +64 -0
- package/dist/comps/useBase/base.types.js +1 -0
- package/dist/comps/useBase/index.d.ts +10 -0
- package/dist/comps/useBase/index.js +62 -0
- package/dist/funs/colors.d.ts +6 -0
- package/dist/funs/colors.js +6 -0
- package/dist/funs/css.d.ts +3 -1
- package/dist/funs/css.js +183 -15
- package/dist/funs/events.js +3 -0
- package/dist/funs/index.d.ts +6 -0
- package/dist/funs/index.js +36 -2
- package/dist/funs/stylesheet.d.ts +1 -0
- package/dist/funs/stylesheet.js +66 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useImage.d.ts +2 -0
- package/dist/hooks/useImage.js +22 -0
- package/dist/hooks/useKeyBind.d.ts +3 -0
- package/dist/hooks/useKeyBind.js +4 -0
- package/dist/hooks/useMounted.d.ts +15 -0
- package/dist/hooks/useMounted.js +16 -1
- package/dist/hooks/useToast.d.ts +1 -1
- package/dist/hooks/useToast.js +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/styles.css +1 -1
- package/dist/types/enums.d.ts +115 -1
- package/dist/types/enums.js +137 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/interfaces.d.ts +11 -2
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -13,6 +13,7 @@ program
|
|
|
13
13
|
.option(`-f, --file <char>`);
|
|
14
14
|
program.parse();
|
|
15
15
|
const options = program.opts();
|
|
16
|
+
// extendGlobals()
|
|
16
17
|
const getAllFiles = (dir, extn, files, result, regex) => {
|
|
17
18
|
files = files || readdirSync(dir);
|
|
18
19
|
result = result || [];
|
|
@@ -54,6 +55,7 @@ const rebuild = (f) => {
|
|
|
54
55
|
}
|
|
55
56
|
return arr;
|
|
56
57
|
}, []).join(` `);
|
|
58
|
+
//
|
|
57
59
|
}
|
|
58
60
|
if (v2.startsWith(`[`) && v2.endsWith(`]`))
|
|
59
61
|
v2 = v2.slice(1, -1);
|
|
@@ -62,19 +64,29 @@ const rebuild = (f) => {
|
|
|
62
64
|
if (matches && matches.length > 0) {
|
|
63
65
|
matches.map((m) => {
|
|
64
66
|
let v2;
|
|
67
|
+
// m = m.replace(/\s+|\n/gm, ` `)
|
|
65
68
|
if (type == `as`) {
|
|
66
69
|
const [x, v1] = m.split(/as\s*=/);
|
|
67
70
|
v2 = makeV2(v1);
|
|
68
71
|
}
|
|
69
72
|
else if (type == `css`) {
|
|
70
73
|
const v1 = m.split(/css\s*\(/)[1].slice(0, -1);
|
|
74
|
+
// console.log(v1)
|
|
71
75
|
v2 = makeV2(v1.trim());
|
|
72
76
|
}
|
|
77
|
+
// console.log(`v2 ->`, `"${v2}"`)
|
|
73
78
|
list.push(v2);
|
|
74
79
|
});
|
|
75
80
|
}
|
|
76
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* match as={?}
|
|
84
|
+
*/
|
|
85
|
+
// processMatch(raw.match(/as\s*=\s*\{([^{}]|{([^{}]|{[^{}]*})*})*\}/g), `as`)
|
|
77
86
|
processMatch(raw.match(/as\s*=\s*(?:\{([^{}]|{([^{}]|{[^{}]*})*})*\}|'([^']*)'|"([^"]*)")/g), `as`);
|
|
87
|
+
/**
|
|
88
|
+
* match css()
|
|
89
|
+
*/
|
|
78
90
|
processMatch(raw.match(/css\(\s*(?:\[\s*([\s\S]*?)\s*\]|\s*`([\s\S]*?)`)\s*\)/g), `css`);
|
|
79
91
|
return list;
|
|
80
92
|
};
|
|
@@ -85,17 +97,24 @@ const rebuildAll = () => {
|
|
|
85
97
|
if (files.length > 0) {
|
|
86
98
|
const as = [];
|
|
87
99
|
if (options.file) {
|
|
88
|
-
const r = rebuild(files.filter(f => f.endsWith(options.file))[0]);
|
|
100
|
+
const r = rebuild(files.filter(f => f.endsWith(options.file.replace(path.resolve(`./`), ``)))[0]);
|
|
89
101
|
if (r && r.length > 0) {
|
|
90
|
-
|
|
102
|
+
// console.log(r)
|
|
103
|
+
as.push(cssBuilder.Build([r], true, options.file).sheet);
|
|
104
|
+
// as.push(r)
|
|
91
105
|
}
|
|
92
106
|
}
|
|
93
107
|
else {
|
|
94
108
|
const mediaQueries = {};
|
|
95
109
|
files.map(f => {
|
|
110
|
+
// if ( f.endsWith(`header.jsx`) ){
|
|
96
111
|
const r = rebuild(f);
|
|
97
112
|
if (r && r.length > 0) {
|
|
98
|
-
|
|
113
|
+
// as.push(cssBuilder.Build([r], true).sheet)
|
|
114
|
+
// as.push( f.endsWith(`header.jsx`) ?
|
|
115
|
+
// `.header{${cssBuilder.Build([r], true).sheet}}`
|
|
116
|
+
// : cssBuilder.Build([r], true).sheet)
|
|
117
|
+
const _built = cssBuilder.Build([r], true, f.replace(path.resolve(`./`), ``));
|
|
99
118
|
as.push(_built.sheet);
|
|
100
119
|
Object.keys(_built.mediaQuery).map(mq => {
|
|
101
120
|
if (!mediaQueries[mq])
|
|
@@ -105,14 +124,21 @@ const rebuildAll = () => {
|
|
|
105
124
|
..._built.mediaQuery[mq]
|
|
106
125
|
];
|
|
107
126
|
});
|
|
127
|
+
// as.push(new CSS().Build([[r]], true).sheet)
|
|
108
128
|
}
|
|
129
|
+
// }
|
|
130
|
+
// as.push(r)
|
|
109
131
|
});
|
|
110
132
|
as.push(cssBuilder.buildMediaQueries(mediaQueries));
|
|
111
133
|
}
|
|
134
|
+
// console.log(as)
|
|
135
|
+
// const { sheet } = new CSS().Build(as, true)
|
|
136
|
+
// console.log(cache)
|
|
112
137
|
const sheet = as.join(`\n`);
|
|
113
138
|
if (!fs.existsSync(path.join(process.cwd(), `src`, `app`, `css`))) {
|
|
114
139
|
fs.mkdirSync(path.join(process.cwd(), `src`, `app`, `css`));
|
|
115
140
|
}
|
|
141
|
+
// console.log(sheet)
|
|
116
142
|
fs.writeFileSync(path.join(process.cwd(), `src`, `app`, `css`, `zuz.scss`), sheet, {
|
|
117
143
|
encoding: `utf8`,
|
|
118
144
|
flag: `w+`
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { BaseProps } from "../types/interfaces";
|
|
3
|
+
export interface AccordionProps {
|
|
4
|
+
message?: string;
|
|
5
|
+
title: string | ReactNode | ReactNode[];
|
|
6
|
+
}
|
|
7
|
+
export interface AccordionHandler {
|
|
8
|
+
open: () => void;
|
|
9
|
+
close: () => void;
|
|
10
|
+
}
|
|
11
|
+
declare const Accordion: import("react").ForwardRefExoticComponent<AccordionProps & BaseProps & import("react").RefAttributes<AccordionHandler>>;
|
|
12
|
+
export default Accordion;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState } from "react";
|
|
3
|
+
import With from "./base";
|
|
4
|
+
const Icons = {
|
|
5
|
+
ArrowDown: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: _jsx("path", { fill: "#292D32", d: "M17.919 8.18H6.079c-.96 0-1.44 1.16-.76 1.84l5.18 5.18c.83.83 2.18.83 3.01 0l1.97-1.97 3.21-3.21c.67-.68.19-1.84-.77-1.84z" }) }),
|
|
6
|
+
ArrowUp: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: _jsx("path", { fill: "#292D32", d: "M18.68 13.978l-3.21-3.21-1.96-1.97a2.13 2.13 0 00-3.01 0l-5.18 5.18c-.68.68-.19 1.84.76 1.84h11.84c.96 0 1.44-1.16.76-1.84z" }) })
|
|
7
|
+
};
|
|
8
|
+
const Accordion = forwardRef((props, ref) => {
|
|
9
|
+
const { title, message, ...rest } = props;
|
|
10
|
+
const [visible, setVisible] = useState(false);
|
|
11
|
+
return _jsxs(With, { className: `--accordion flex cols`, ...rest, children: [_jsxs(With, { onClick: (e) => setVisible(!visible), tag: `button`, className: `--toggle flex aic ${visible ? `--open` : ``}`.trim(), children: [_jsx(With, { tag: `h1`, className: `--label flex`, children: title }), _jsx(With, { className: `--arrow flex`, children: visible ? Icons.ArrowUp : Icons.ArrowDown })] }), visible && _jsx(With, { className: `--detail`, children: message })] });
|
|
12
|
+
});
|
|
13
|
+
export default Accordion;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseProps } from "../types/interfaces";
|
|
2
|
+
import { ALERT } from "../types/enums";
|
|
3
|
+
export interface AlertProps {
|
|
4
|
+
type?: ALERT;
|
|
5
|
+
icon?: string;
|
|
6
|
+
iconSize?: number;
|
|
7
|
+
message?: string;
|
|
8
|
+
title: string;
|
|
9
|
+
}
|
|
10
|
+
export interface AlertHandler {
|
|
11
|
+
open: () => void;
|
|
12
|
+
close: () => void;
|
|
13
|
+
}
|
|
14
|
+
declare const Alert: import("react").ForwardRefExoticComponent<AlertProps & BaseProps & import("react").RefAttributes<AlertHandler>>;
|
|
15
|
+
export default Alert;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { ALERT } from "../types/enums";
|
|
4
|
+
import With from "./base";
|
|
5
|
+
const Icons = {
|
|
6
|
+
[ALERT.Info]: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", children: _jsx("path", { fill: "#292D32", d: "M21.56 10.738l-1.35-1.58c-.25-.3-.46-.86-.46-1.26v-1.7c0-1.06-.87-1.93-1.93-1.93h-1.7c-.4 0-.97-.21-1.27-.46l-1.58-1.35c-.69-.59-1.82-.59-2.51 0l-1.6 1.35c-.3.25-.86.46-1.26.46H6.17c-1.06 0-1.93.87-1.93 1.93v1.7c0 .39-.2.95-.45 1.25l-1.35 1.59c-.58.7-.58 1.82 0 2.5l1.35 1.59c.25.29.45.86.45 1.25v1.71c0 1.06.87 1.93 1.93 1.93h1.74c.39 0 .96.21 1.26.46l1.58 1.35c.69.59 1.82.59 2.51 0l1.58-1.35c.3-.25.86-.46 1.26-.46h1.7c1.06 0 1.93-.87 1.93-1.93v-1.7c0-.4.21-.96.46-1.26l1.35-1.58c.61-.68.61-1.81.02-2.51zm-10.31-2.61c0-.41.34-.75.75-.75s.75.34.75.75v4.83c0 .41-.34.75-.75.75s-.75-.34-.75-.75v-4.83zm.75 8.74c-.55 0-1-.45-1-1s.44-1 1-1c.55 0 1 .45 1 1s-.44 1-1 1z" }) }),
|
|
7
|
+
[ALERT.Warning]: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", children: _jsx("path", { fill: "#292D32", d: "M19.51 5.85l-5.94-3.43c-.97-.56-2.17-.56-3.15 0L4.49 5.85a3.15 3.15 0 00-1.57 2.73v6.84c0 1.12.6 2.16 1.57 2.73l5.94 3.43c.97.56 2.17.56 3.15 0l5.94-3.43a3.15 3.15 0 001.57-2.73V8.58a3.192 3.192 0 00-1.58-2.73zm-8.26 1.9c0-.41.34-.75.75-.75s.75.34.75.75V13c0 .41-.34.75-.75.75s-.75-.34-.75-.75V7.75zm1.67 8.88c-.05.12-.12.23-.21.33a.99.99 0 01-1.09.21c-.13-.05-.23-.12-.33-.21-.09-.1-.16-.21-.22-.33a.986.986 0 01-.07-.38c0-.26.1-.52.29-.71.1-.09.2-.16.33-.21.37-.16.81-.07 1.09.21.09.1.16.2.21.33.05.12.08.25.08.38s-.03.26-.08.38z" }) }),
|
|
8
|
+
[ALERT.Error]: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", children: _jsx("path", { d: "M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z" }) }),
|
|
9
|
+
[ALERT.Success]: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", children: _jsx("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" }) })
|
|
10
|
+
};
|
|
11
|
+
const Alert = forwardRef((props, ref) => {
|
|
12
|
+
const { type, icon, title, message, iconSize, ...rest } = props;
|
|
13
|
+
return _jsxs(With, { className: `--alert --${(type || ALERT.Info).toLowerCase()} flex aic`, ...rest, children: [_jsx(With, { className: `--icon icon-${icon || `auto-matic`}`, style: iconSize ? { width: iconSize, height: iconSize } : {}, children: !icon && Icons[type || ALERT.Info] }), _jsxs(With, { className: `--meta flex cols`, tag: `h1`, children: [_jsx(With, { className: `--title ${message ? `--tm` : ``}`, tag: `h1`, children: title || `Lorem ipsum dolor sit amet, consectetur adipiscing elit.` }), message && _jsx(With, { className: `--message`, tag: `h2`, children: message })] })] });
|
|
14
|
+
});
|
|
15
|
+
export default Alert;
|
package/dist/comps/animate.d.ts
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseProps } from "../types/interfaces";
|
|
2
|
+
import { AVATAR } from "../types/enums";
|
|
3
|
+
export interface AvatarProps {
|
|
4
|
+
type?: AVATAR;
|
|
5
|
+
size?: number;
|
|
6
|
+
src: string;
|
|
7
|
+
crossOrigin?: 'anonymous' | 'use-credentials';
|
|
8
|
+
referrerPolicy?: 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
|
|
9
|
+
}
|
|
10
|
+
export interface AvatarHandler {
|
|
11
|
+
}
|
|
12
|
+
declare const Avatar: import("react").ForwardRefExoticComponent<AvatarProps & BaseProps & import("react").RefAttributes<AvatarHandler>>;
|
|
13
|
+
export default Avatar;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { AVATAR } from "../types/enums";
|
|
4
|
+
import With from "./base";
|
|
5
|
+
import { useImage } from "../hooks";
|
|
6
|
+
const Avatar = forwardRef((props, ref) => {
|
|
7
|
+
const { src, size, type, crossOrigin, referrerPolicy, ...rest } = props;
|
|
8
|
+
const [img, imgStatus, imgError] = useImage(src, crossOrigin, referrerPolicy);
|
|
9
|
+
return _jsx(With, { tag: `img`, src: img, style: size ? { width: size, height: size } : {}, crossOrigin: crossOrigin, referrerPolicy: referrerPolicy, className: `--avatar --${(type || AVATAR.Circle).toLowerCase()}`, ...rest });
|
|
10
|
+
});
|
|
11
|
+
export default Avatar;
|
package/dist/comps/base.d.ts
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef, ElementType } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Skeleton } from "../types/interfaces";
|
|
5
|
-
export interface animationProps {
|
|
6
|
-
transition?: TRANSITIONS;
|
|
7
|
-
from?: dynamicObject;
|
|
8
|
-
to?: dynamicObject;
|
|
9
|
-
when?: boolean;
|
|
10
|
-
duration?: number;
|
|
11
|
-
delay?: number;
|
|
12
|
-
curve?: string | TRANSITION_CURVES;
|
|
13
|
-
}
|
|
2
|
+
import { SHIMMER } from "../types/enums";
|
|
3
|
+
import { animationProps, Skeleton } from "../types/interfaces";
|
|
14
4
|
interface BaseProps<T extends ElementType> {
|
|
15
5
|
tag?: T;
|
|
16
6
|
as?: string | string[];
|
|
@@ -18,7 +8,8 @@ interface BaseProps<T extends ElementType> {
|
|
|
18
8
|
className?: string;
|
|
19
9
|
propsToRemove?: string[];
|
|
20
10
|
skeleton?: Skeleton;
|
|
11
|
+
shimmer?: SHIMMER;
|
|
21
12
|
}
|
|
22
|
-
export type Props<T extends ElementType> = BaseProps<T> & ComponentPropsWithoutRef<T
|
|
13
|
+
export type Props<T extends ElementType> = BaseProps<T> & Omit<ComponentPropsWithoutRef<T>, keyof BaseProps<T>>;
|
|
23
14
|
declare const With: import("react").ForwardRefExoticComponent<Omit<Props<ElementType>, "ref"> & import("react").RefAttributes<Element>>;
|
|
24
15
|
export default With;
|
package/dist/comps/base.js
CHANGED
|
@@ -45,7 +45,7 @@ const With = forwardRef(({ tag, as, animate, className, propsToRemove, style, sk
|
|
|
45
45
|
else {
|
|
46
46
|
_style = transition ? getAnimationTransition(transition, false, true) : from || {};
|
|
47
47
|
}
|
|
48
|
-
const { children, ...restProps } = cleanProps(rest, propsToRemove ? [...propsToRemove, `skeleton`] : [`skeleton`]);
|
|
48
|
+
const { children, shimmer, ...restProps } = cleanProps(rest, propsToRemove ? [...propsToRemove, `skeleton`] : [`skeleton`]);
|
|
49
49
|
return createElement(Comp, {
|
|
50
50
|
style: {
|
|
51
51
|
...buildWithStyles(_style),
|
|
@@ -56,7 +56,8 @@ const With = forwardRef(({ tag, as, animate, className, propsToRemove, style, sk
|
|
|
56
56
|
className: [
|
|
57
57
|
className,
|
|
58
58
|
...cx,
|
|
59
|
-
skeleton?.enabled ? `--skeleton` :
|
|
59
|
+
skeleton?.enabled ? `--skeleton` : ``,
|
|
60
|
+
shimmer ? `--shimmer --${shimmer.toLowerCase()}` : ``,
|
|
60
61
|
].join(' ').trim(),
|
|
61
62
|
children: skeleton?.enabled ? ` `.repeat(6)
|
|
62
63
|
: children,
|
package/dist/comps/box.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const Box: import("react").ForwardRefExoticComponent<
|
|
1
|
+
import { Props } from "./useBase/base.types";
|
|
2
|
+
declare const Box: import("react").ForwardRefExoticComponent<Props<"div"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
3
3
|
export default Box;
|
package/dist/comps/box.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
|
-
import
|
|
3
|
+
import useBase from "./useBase";
|
|
4
4
|
const Box = forwardRef((props, ref) => {
|
|
5
|
-
const {
|
|
6
|
-
return _jsx(
|
|
5
|
+
const { className, style, rest } = useBase(props);
|
|
6
|
+
return _jsx("div", { ref: ref, className: className, style: style, ...rest });
|
|
7
7
|
});
|
|
8
|
+
// export interface BoxProps extends Props<'div'> {}
|
|
9
|
+
// const Box = forwardRef<HTMLDivElement, BoxProps>((props, ref ) => {
|
|
10
|
+
// const { as, children, className, ...rest } = props
|
|
11
|
+
// return <With className={className} as={as} {...rest} ref={ref}>
|
|
12
|
+
// {children}
|
|
13
|
+
// </With>
|
|
14
|
+
// });
|
|
8
15
|
export default Box;
|
package/dist/comps/button.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface ButtonProps {
|
|
3
|
-
as?: string;
|
|
4
|
-
animate?: animationProps;
|
|
1
|
+
import { Props } from "./useBase/base.types";
|
|
2
|
+
export interface ButtonProps extends Props<`button`> {
|
|
5
3
|
icon?: string;
|
|
6
4
|
}
|
|
7
|
-
declare const Button: import("react").ForwardRefExoticComponent<ButtonProps &
|
|
5
|
+
declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
8
6
|
export default Button;
|
package/dist/comps/button.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
|
-
import With from "./base";
|
|
3
|
+
// import With, { Props } from "./base";
|
|
4
|
+
import useBase from "./useBase";
|
|
4
5
|
const Button = forwardRef((props, ref) => {
|
|
5
|
-
const {
|
|
6
|
-
|
|
6
|
+
const { icon, children, ...pops } = props;
|
|
7
|
+
const { className, style, rest } = useBase(pops);
|
|
8
|
+
return _jsxs("button", { className: `${className} flex aic ${icon ? `ico-btn` : ``}`, style: style, ref: ref, ...rest, children: [icon && _jsx("div", { ...{ className: `icon-${icon}` } }), _jsx("span", { ...{ className: `b-label` }, children: children })] });
|
|
7
9
|
});
|
|
10
|
+
// const Button = forwardRef<HTMLButtonElement, ButtonProps>((props, ref ) => {
|
|
11
|
+
// const { as, icon, ...rest } = props;
|
|
12
|
+
// return <With tag={`button`} as={as} className={`flex aic ${icon ? `ico-btn` : ``}`.trim()} {...rest} ref={ref}>
|
|
13
|
+
// {icon && <With className={`icon-${icon}`} />}
|
|
14
|
+
// <With tag={`span`} className={`b-label`}>{props.children}</With>
|
|
15
|
+
// </With>
|
|
16
|
+
// });
|
|
8
17
|
export default Button;
|
package/dist/comps/checkbox.d.ts
CHANGED
package/dist/comps/checkbox.js
CHANGED
|
@@ -3,6 +3,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { forwardRef, useImperativeHandle, useRef, useState } from "react";
|
|
4
4
|
import With from "./base";
|
|
5
5
|
import { CHECKBOX } from "../types/enums";
|
|
6
|
+
// const CheckBox = forwardRef<HTMLButtonElement, { as?: string, type?: CHECKBOX, animate?: animationProps } & ComponentPropsWithoutRef<`input`>>((props, ref) => {
|
|
6
7
|
const CheckBox = forwardRef((props, ref) => {
|
|
7
8
|
const { as, name, required, type, value, checked: defaultCheck, onChange, ...rest } = props;
|
|
8
9
|
const [checked, _setChecked] = useState(defaultCheck || false);
|
|
@@ -29,4 +30,22 @@ const CheckBox = forwardRef((props, ref) => {
|
|
|
29
30
|
_setChecked(e.target.checked);
|
|
30
31
|
} }) });
|
|
31
32
|
});
|
|
33
|
+
// import { DetailedHTMLProps, HTMLAttributes, ReactNode, Ref, useState } from "react";
|
|
34
|
+
// import { cleanProps, css } from "../funs";
|
|
35
|
+
// import { UIProps } from "../types/interfaces";
|
|
36
|
+
// const CheckBox = ( props : UIProps<HTMLInputElement> ) => {
|
|
37
|
+
// const { cx } = css.Build(props.as)
|
|
38
|
+
// const [ checked, setChecked ] = useState(props.checked || false)
|
|
39
|
+
// return <label { ...({
|
|
40
|
+
// className: `zuz-checkbox${checked ? ` is-checked` : ``} rel${cx.length > 0 ? ` ` + cx.join(` `) : ``}`
|
|
41
|
+
// }) as UIProps<HTMLLabelElement>}>
|
|
42
|
+
// <input type='checkbox'
|
|
43
|
+
// ref={props.ref}
|
|
44
|
+
// onChange={e => {
|
|
45
|
+
// setChecked(e.target.checked)
|
|
46
|
+
// }}
|
|
47
|
+
// className={`abs`}
|
|
48
|
+
// {...(cleanProps(props) as UIProps<HTMLInputElement>)} />
|
|
49
|
+
// </label>
|
|
50
|
+
// }
|
|
32
51
|
export default CheckBox;
|
package/dist/comps/cover.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef } from "react";
|
|
2
|
-
import { animationProps } from "./base";
|
|
3
2
|
import { SpinnerProps } from "./spinner";
|
|
3
|
+
import { animationProps } from "../types/interfaces";
|
|
4
4
|
export interface CoverProps extends ComponentPropsWithoutRef<`div`> {
|
|
5
5
|
tag?: string;
|
|
6
6
|
message?: string;
|
package/dist/comps/cover.js
CHANGED
|
@@ -12,5 +12,20 @@ const Cover = forwardRef((props, ref) => {
|
|
|
12
12
|
}, as: as, ...rest, children: [_jsx(Spinner, { ...{
|
|
13
13
|
...spinner
|
|
14
14
|
} }), !hideMessage && _jsx(With, { tag: `h1`, className: `label`, style: { color: `var(--cover-label)` }, children: message || `loading` })] }));
|
|
15
|
+
// return (
|
|
16
|
+
// <With
|
|
17
|
+
// className={`zuz-cover flex aic jcc cols abs fill nope nous`}
|
|
18
|
+
// ref={ref}
|
|
19
|
+
// style={{
|
|
20
|
+
// backgroundColor: color ? !color.startsWith(`#`) ? hexToRgba(color, .9) : color : hexToRgba(color || `var(--cover)`, .9)
|
|
21
|
+
// }}
|
|
22
|
+
// as={as}
|
|
23
|
+
// {...rest}
|
|
24
|
+
// >
|
|
25
|
+
// {<Spinner {...spinner} />}
|
|
26
|
+
// {<With tag={`h1`} className={`label`}>{message || `loading`}</With>}
|
|
27
|
+
// {/* {message && <With tag={`h1`} className={`label`}>{message}</With>} */}
|
|
28
|
+
// </With>
|
|
29
|
+
// );
|
|
15
30
|
});
|
|
16
31
|
export default Cover;
|
package/dist/comps/drawer.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
3
3
|
import With from "./base";
|
|
4
|
-
import { DRAWER_SIDE, TRANSITION_CURVES, TRANSITIONS } from "../types/enums";
|
|
4
|
+
import { DRAWER_SIDE, KeyCode, TRANSITION_CURVES, TRANSITIONS } from "../types/enums";
|
|
5
|
+
import { bindKey } from "../funs";
|
|
5
6
|
const Drawer = forwardRef((props, ref) => {
|
|
6
7
|
const { as, from, speed, children, prerender, ...rest } = props;
|
|
7
8
|
const [render, setRender] = useState(undefined == prerender ? true : prerender);
|
|
@@ -11,6 +12,9 @@ const Drawer = forwardRef((props, ref) => {
|
|
|
11
12
|
useEffect(() => {
|
|
12
13
|
setContent(children);
|
|
13
14
|
}, [children]);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
bindKey(KeyCode.Escape, () => visible && setVisible(false));
|
|
17
|
+
}, []);
|
|
14
18
|
const style = useMemo(() => {
|
|
15
19
|
switch (from) {
|
|
16
20
|
case DRAWER_SIDE.Left:
|
package/dist/comps/editor.js
CHANGED
|
@@ -12,6 +12,9 @@ const ComponentEditor = forwardRef((props, ref) => {
|
|
|
12
12
|
const { title, attrs, element } = props;
|
|
13
13
|
const mounted = useMounted(500);
|
|
14
14
|
const getVariable = (v) => {
|
|
15
|
+
// console.log(element!.current)
|
|
16
|
+
// const elm = document.querySelector(element!);
|
|
17
|
+
// return getComputedStyle(document.querySelector(element)!).getPropertyValue(`--${v}`).trim()
|
|
15
18
|
const a = getComputedStyle(document.querySelector(element)).getPropertyValue(`--${v}`).trim();
|
|
16
19
|
const b = getComputedStyle(document.body).getPropertyValue(`--${v}`).trim();
|
|
17
20
|
const d = getComputedStyle(document.documentElement).getPropertyValue(`--${v}`).trim();
|
|
@@ -25,19 +28,23 @@ const ComponentEditor = forwardRef((props, ref) => {
|
|
|
25
28
|
};
|
|
26
29
|
const rangeSlider = (k, value, min, max, step, unit) => {
|
|
27
30
|
return _jsxs(_Fragment, { children: [_jsx(With, { tag: `input`, type: `range`, defaultValue: value, min: min, max: max, step: step, name: `editor-prop-range-${k}`, onChange: (e) => {
|
|
31
|
+
// document.body.style.setProperty(`--${k}`,`${e.currentTarget.value}${unit || ``}`);
|
|
28
32
|
document.querySelector(element).style.setProperty(`--${k}`, `${e.currentTarget.value}${unit || ``}`);
|
|
29
33
|
document.querySelector(`input[name="editor-prop-num-${k}"]`).value = e.currentTarget.value;
|
|
30
34
|
} }), _jsx(With, { tag: `input`, type: `number`, name: `editor-prop-num-${k}`, defaultValue: value, min: min, max: max, onChange: (e) => {
|
|
31
35
|
document.querySelector(element).style.setProperty(`--${k}`, `${e.currentTarget.value}${unit || ``}`);
|
|
36
|
+
// document.body.style.setProperty(`--${k}`,`${e.currentTarget.value}${unit || ``}`);
|
|
32
37
|
document.querySelector(`input[name="editor-prop-range-${k}"]`).value = e.currentTarget.value;
|
|
33
38
|
} })] });
|
|
34
39
|
};
|
|
35
40
|
const colorPicker = (k, value) => {
|
|
36
41
|
return _jsxs(_Fragment, { children: [_jsx(With, { tag: `input`, type: `color`, defaultValue: expandHex(value.toString()), name: `editor-prop-color-${k}`, onChange: (e) => {
|
|
42
|
+
// document.body.style.setProperty(`--${k}`, e.currentTarget.value);
|
|
37
43
|
document.querySelector(element).style.setProperty(`--${k}`, e.currentTarget.value);
|
|
38
44
|
document.querySelector(`input[name="editor-prop-num-${k}"]`).value = e.currentTarget.value;
|
|
39
45
|
} }), _jsx(With, { tag: `input`, name: `editor-prop-num-${k}`, defaultValue: expandHex(value.toString()), onChange: (e) => {
|
|
40
46
|
document.querySelector(element).style.setProperty(`--${k}`, `${e.currentTarget.value}`);
|
|
47
|
+
// document.body.style.setProperty(`--${k}`,`${e.currentTarget.value}px`);
|
|
41
48
|
document.querySelector(`input[name="editor-prop-color-${k}"]`).value = e.currentTarget.value;
|
|
42
49
|
} })] });
|
|
43
50
|
};
|
|
@@ -67,7 +74,7 @@ const ComponentEditor = forwardRef((props, ref) => {
|
|
|
67
74
|
c.push(`--${k}: ${value == `auto` ? type == `range` ? parseFloat(getVariable(k)) : getVariable(k) : value}${unit || ``};`);
|
|
68
75
|
}
|
|
69
76
|
});
|
|
70
|
-
return c;
|
|
77
|
+
return c; //.join(`\n`)
|
|
71
78
|
};
|
|
72
79
|
if (!mounted)
|
|
73
80
|
return null;
|
package/dist/comps/form.d.ts
CHANGED
|
@@ -1,24 +1,54 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Props } from "./useBase/base.types";
|
|
2
2
|
import { SpinnerProps } from "./spinner";
|
|
3
3
|
import { dynamicObject } from "../types";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
/**
|
|
5
|
+
* `FormProps` defines properties for the `Form` component, including action handlers,
|
|
6
|
+
* spinner, and error handling configuration.
|
|
7
|
+
*/
|
|
8
|
+
export interface FormProps extends Props<`div`> {
|
|
9
|
+
/** Name of form, will be appended to --form-{name} in className
|
|
10
|
+
* whitespace will be replaced with dash (-)
|
|
11
|
+
*/
|
|
12
|
+
name?: string;
|
|
13
|
+
/** The URL to which the form data is submitted */
|
|
7
14
|
action?: string;
|
|
15
|
+
/** List of error messages for form validation */
|
|
8
16
|
errors?: string[];
|
|
17
|
+
/** Spinner properties for loading indicator */
|
|
9
18
|
spinner?: SpinnerProps;
|
|
19
|
+
/** Additional data to include with form submission */
|
|
10
20
|
withData?: dynamicObject;
|
|
21
|
+
/** Handler function called on form submission with validated form data */
|
|
11
22
|
onSubmit?: (data: FormData | dynamicObject) => void;
|
|
23
|
+
/** Callback triggered upon successful form submission */
|
|
12
24
|
onSuccess?: (data: dynamicObject) => void;
|
|
25
|
+
/** Callback triggered when form submission encounters an error */
|
|
13
26
|
onError?: (error: any) => void;
|
|
27
|
+
/** Cover properties to display loading or processing message */
|
|
14
28
|
cover?: {
|
|
29
|
+
/** Background color of the loading cover */
|
|
15
30
|
color?: string;
|
|
31
|
+
/** Message displayed during loading */
|
|
16
32
|
message?: string;
|
|
17
33
|
};
|
|
18
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Exposes control methods for the Form component, such as setting loading states or hiding errors.
|
|
37
|
+
*/
|
|
19
38
|
export interface FormHandler {
|
|
39
|
+
/** Sets the loading state of the form */
|
|
20
40
|
setLoading: (mode: boolean) => void;
|
|
41
|
+
/** Hides any currently displayed error message */
|
|
21
42
|
hideError: () => void;
|
|
22
43
|
}
|
|
23
|
-
|
|
44
|
+
/**
|
|
45
|
+
* {@link Form} is a controlled component designed to handle form data submission, validation, and display of loading or error states.
|
|
46
|
+
* It allows for optional server-side submission through an action endpoint and customizable success/error handling callbacks.
|
|
47
|
+
*
|
|
48
|
+
* The component also provides an interface for controlling loading and error states from a parent component using {@link FormHandler}.
|
|
49
|
+
*
|
|
50
|
+
* @param props - Properties to configure form behavior, validation messages, submission handling, and visual feedback.
|
|
51
|
+
* @param ref - Reference to the {@link FormHandler} interface, exposing methods to control loading and error states from the parent.
|
|
52
|
+
*/
|
|
53
|
+
declare const Form: import("react").ForwardRefExoticComponent<FormProps & import("react").RefAttributes<FormHandler>>;
|
|
24
54
|
export default Form;
|