@zuzjs/ui 0.5.4 → 0.5.6
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 +34 -2
- package/dist/comps/accordion.d.ts +12 -0
- package/dist/comps/accordion.js +10 -0
- package/dist/comps/animate.d.ts +1 -1
- package/dist/comps/base.d.ts +4 -13
- package/dist/comps/base.js +3 -2
- package/dist/comps/box.d.ts +5 -2
- package/dist/comps/box.js +7 -3
- package/dist/comps/button.d.ts +4 -5
- package/dist/comps/button.js +14 -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/editor.js +8 -1
- package/dist/comps/form.d.ts +39 -5
- package/dist/comps/form.js +120 -31
- package/dist/comps/grid/index.d.ts +10 -0
- package/dist/comps/grid/index.js +16 -0
- package/dist/comps/heading.d.ts +4 -3
- package/dist/comps/heading.js +12 -6
- package/dist/comps/icon.d.ts +5 -5
- package/dist/comps/icon.js +18 -3
- package/dist/comps/image.d.ts +1 -1
- package/dist/comps/input.d.ts +5 -8
- package/dist/comps/input.js +15 -5
- package/dist/comps/otp/index.d.ts +6 -0
- package/dist/comps/otp/index.js +50 -0
- package/dist/comps/password.d.ts +3 -0
- package/dist/comps/password.js +30 -0
- package/dist/comps/search/index.d.ts +7 -0
- package/dist/comps/search/index.js +46 -0
- package/dist/comps/segmented/index.d.ts +46 -0
- package/dist/comps/segmented/index.js +59 -0
- package/dist/comps/segmented/item.d.ts +8 -0
- package/dist/comps/segmented/item.js +26 -0
- package/dist/comps/select/index.d.ts +15 -0
- package/dist/comps/select/index.js +79 -0
- package/dist/comps/select/select.d.ts +0 -0
- package/dist/comps/select/select.js +1 -0
- package/dist/comps/sheet.d.ts +1 -0
- package/dist/comps/sheet.js +30 -0
- package/dist/comps/span.d.ts +6 -0
- package/dist/comps/span.js +12 -0
- package/dist/comps/spinner.d.ts +1 -1
- package/dist/comps/spinner.js +1 -0
- package/dist/comps/svgicons.d.ts +3 -0
- package/dist/comps/svgicons.js +8 -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 +80 -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 +172 -21
- package/dist/funs/events.d.ts +4 -2
- package/dist/funs/events.js +9 -6
- package/dist/funs/index.d.ts +9 -0
- package/dist/funs/index.js +62 -2
- package/dist/funs/stylesheet.js +15 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useDB.d.ts +25 -0
- package/dist/hooks/useDB.js +101 -0
- package/dist/hooks/useIntersectionObserver.d.ts +1 -1
- package/dist/hooks/useIntersectionObserver.js +28 -11
- package/dist/hooks/useKeyBind.js +1 -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 +9 -1
- package/dist/index.js +10 -1
- package/dist/styles.css +1 -1
- package/dist/types/enums.d.ts +15 -10
- package/dist/types/enums.js +25 -0
- package/dist/types/interfaces.d.ts +37 -3
- package/package.json +1 -1
- package/dist/comps/select.d.ts +0 -18
- package/dist/comps/select.js +0 -31
package/dist/bin.js
CHANGED
|
@@ -10,9 +10,16 @@ program
|
|
|
10
10
|
.option(`-d, --debug`)
|
|
11
11
|
.option(`-v, --version`)
|
|
12
12
|
.option(`-root, --root <char>`)
|
|
13
|
-
.option(`-f, --file <char>`)
|
|
13
|
+
.option(`-f, --file <char>`)
|
|
14
|
+
.option(`-lx, --lexer`)
|
|
15
|
+
.option(`-cx, --classes`)
|
|
16
|
+
.option(`-ch, --cache`)
|
|
17
|
+
.option(`-cl, --cleaned`)
|
|
18
|
+
.option(`-sh, --sheet`)
|
|
19
|
+
.option(`-mq, --media`);
|
|
14
20
|
program.parse();
|
|
15
21
|
const options = program.opts();
|
|
22
|
+
// extendGlobals()
|
|
16
23
|
const getAllFiles = (dir, extn, files, result, regex) => {
|
|
17
24
|
files = files || readdirSync(dir);
|
|
18
25
|
result = result || [];
|
|
@@ -54,6 +61,7 @@ const rebuild = (f) => {
|
|
|
54
61
|
}
|
|
55
62
|
return arr;
|
|
56
63
|
}, []).join(` `);
|
|
64
|
+
//
|
|
57
65
|
}
|
|
58
66
|
if (v2.startsWith(`[`) && v2.endsWith(`]`))
|
|
59
67
|
v2 = v2.slice(1, -1);
|
|
@@ -62,39 +70,56 @@ const rebuild = (f) => {
|
|
|
62
70
|
if (matches && matches.length > 0) {
|
|
63
71
|
matches.map((m) => {
|
|
64
72
|
let v2;
|
|
73
|
+
// m = m.replace(/\s+|\n/gm, ` `)
|
|
65
74
|
if (type == `as`) {
|
|
66
75
|
const [x, v1] = m.split(/as\s*=/);
|
|
67
76
|
v2 = makeV2(v1);
|
|
68
77
|
}
|
|
69
78
|
else if (type == `css`) {
|
|
70
79
|
const v1 = m.split(/css\s*\(/)[1].slice(0, -1);
|
|
80
|
+
// console.log(v1)
|
|
71
81
|
v2 = makeV2(v1.trim());
|
|
72
82
|
}
|
|
83
|
+
// console.log(`v2 ->`, `"${v2}"`)
|
|
73
84
|
list.push(v2);
|
|
74
85
|
});
|
|
75
86
|
}
|
|
76
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* match as={?}
|
|
90
|
+
*/
|
|
91
|
+
// processMatch(raw.match(/as\s*=\s*\{([^{}]|{([^{}]|{[^{}]*})*})*\}/g), `as`)
|
|
77
92
|
processMatch(raw.match(/as\s*=\s*(?:\{([^{}]|{([^{}]|{[^{}]*})*})*\}|'([^']*)'|"([^"]*)")/g), `as`);
|
|
93
|
+
/**
|
|
94
|
+
* match css()
|
|
95
|
+
*/
|
|
78
96
|
processMatch(raw.match(/css\(\s*(?:\[\s*([\s\S]*?)\s*\]|\s*`([\s\S]*?)`)\s*\)/g), `css`);
|
|
79
97
|
return list;
|
|
80
98
|
};
|
|
81
99
|
const rebuildAll = () => {
|
|
82
100
|
console.log(pc.gray(`○ Building Zuz CSS`));
|
|
83
|
-
const cssBuilder = new CSS();
|
|
101
|
+
const cssBuilder = new CSS({}, options);
|
|
84
102
|
const files = getAllFiles(process.cwd(), `.jsx`);
|
|
85
103
|
if (files.length > 0) {
|
|
86
104
|
const as = [];
|
|
87
105
|
if (options.file) {
|
|
88
106
|
const r = rebuild(files.filter(f => f.endsWith(options.file.replace(path.resolve(`./`), ``)))[0]);
|
|
89
107
|
if (r && r.length > 0) {
|
|
108
|
+
// console.log(r)
|
|
90
109
|
as.push(cssBuilder.Build([r], true, options.file).sheet);
|
|
110
|
+
// as.push(r)
|
|
91
111
|
}
|
|
92
112
|
}
|
|
93
113
|
else {
|
|
94
114
|
const mediaQueries = {};
|
|
95
115
|
files.map(f => {
|
|
116
|
+
// if ( f.endsWith(`header.jsx`) ){
|
|
96
117
|
const r = rebuild(f);
|
|
97
118
|
if (r && r.length > 0) {
|
|
119
|
+
// as.push(cssBuilder.Build([r], true).sheet)
|
|
120
|
+
// as.push( f.endsWith(`header.jsx`) ?
|
|
121
|
+
// `.header{${cssBuilder.Build([r], true).sheet}}`
|
|
122
|
+
// : cssBuilder.Build([r], true).sheet)
|
|
98
123
|
const _built = cssBuilder.Build([r], true, f.replace(path.resolve(`./`), ``));
|
|
99
124
|
as.push(_built.sheet);
|
|
100
125
|
Object.keys(_built.mediaQuery).map(mq => {
|
|
@@ -105,14 +130,21 @@ const rebuildAll = () => {
|
|
|
105
130
|
..._built.mediaQuery[mq]
|
|
106
131
|
];
|
|
107
132
|
});
|
|
133
|
+
// as.push(new CSS().Build([[r]], true).sheet)
|
|
108
134
|
}
|
|
135
|
+
// }
|
|
136
|
+
// as.push(r)
|
|
109
137
|
});
|
|
110
138
|
as.push(cssBuilder.buildMediaQueries(mediaQueries));
|
|
111
139
|
}
|
|
140
|
+
// console.log(as)
|
|
141
|
+
// const { sheet } = new CSS().Build(as, true)
|
|
142
|
+
// console.log(cache)
|
|
112
143
|
const sheet = as.join(`\n`);
|
|
113
144
|
if (!fs.existsSync(path.join(process.cwd(), `src`, `app`, `css`))) {
|
|
114
145
|
fs.mkdirSync(path.join(process.cwd(), `src`, `app`, `css`));
|
|
115
146
|
}
|
|
147
|
+
// console.log(sheet)
|
|
116
148
|
fs.writeFileSync(path.join(process.cwd(), `src`, `app`, `css`, `zuz.scss`), sheet, {
|
|
117
149
|
encoding: `utf8`,
|
|
118
150
|
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,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState } from "react";
|
|
3
|
+
import With from "./base";
|
|
4
|
+
import SVGIcons from "./svgicons";
|
|
5
|
+
const Accordion = forwardRef((props, ref) => {
|
|
6
|
+
const { title, message, ...rest } = props;
|
|
7
|
+
const [visible, setVisible] = useState(false);
|
|
8
|
+
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 ? SVGIcons.ArrowUp : SVGIcons.ArrowDown })] }), visible && _jsx(With, { className: `--detail`, children: message })] });
|
|
9
|
+
});
|
|
10
|
+
export default Accordion;
|
package/dist/comps/animate.d.ts
CHANGED
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,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Props } from "./useBase/base.types";
|
|
2
|
+
export interface BoxProps extends Props<'div'> {
|
|
3
|
+
name?: string;
|
|
4
|
+
}
|
|
5
|
+
declare const Box: import("react").ForwardRefExoticComponent<BoxProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
3
6
|
export default Box;
|
package/dist/comps/box.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
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
|
-
|
|
5
|
+
const { style, ...pops } = props;
|
|
6
|
+
const { className, style: _style, rest } = useBase(pops);
|
|
7
|
+
return _jsx("div", { ref: ref, className: className, style: {
|
|
8
|
+
..._style,
|
|
9
|
+
...(style || {})
|
|
10
|
+
}, ...rest });
|
|
7
11
|
});
|
|
8
12
|
export default Box;
|
package/dist/comps/button.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
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;
|
|
4
|
+
withLabel?: boolean;
|
|
6
5
|
}
|
|
7
|
-
declare const Button: import("react").ForwardRefExoticComponent<ButtonProps &
|
|
6
|
+
declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
8
7
|
export default Button;
|
package/dist/comps/button.js
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
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, withLabel, ...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}` } }), undefined == withLabel || withLabel == true ?
|
|
9
|
+
_jsx("span", { ...{ className: `b-label` }, children: children })
|
|
10
|
+
: children] });
|
|
7
11
|
});
|
|
12
|
+
// const Button = forwardRef<HTMLButtonElement, ButtonProps>((props, ref ) => {
|
|
13
|
+
// const { as, icon, ...rest } = props;
|
|
14
|
+
// return <With tag={`button`} as={as} className={`flex aic ${icon ? `ico-btn` : ``}`.trim()} {...rest} ref={ref}>
|
|
15
|
+
// {icon && <With className={`icon-${icon}`} />}
|
|
16
|
+
// <With tag={`span`} className={`b-label`}>{props.children}</With>
|
|
17
|
+
// </With>
|
|
18
|
+
// });
|
|
8
19
|
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/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,58 @@
|
|
|
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 before form submission with validated form data */
|
|
22
|
+
beforeSubmit?: (data: FormData | dynamicObject) => void;
|
|
23
|
+
/** Handler function called on form submission with validated form data */
|
|
11
24
|
onSubmit?: (data: FormData | dynamicObject) => void;
|
|
25
|
+
/** Callback triggered upon successful form submission */
|
|
12
26
|
onSuccess?: (data: dynamicObject) => void;
|
|
27
|
+
/** Callback triggered when form submission encounters an error */
|
|
13
28
|
onError?: (error: any) => void;
|
|
29
|
+
/** Cover properties to display loading or processing message */
|
|
14
30
|
cover?: {
|
|
31
|
+
/** Background color of the loading cover */
|
|
15
32
|
color?: string;
|
|
33
|
+
/** Message displayed during loading */
|
|
16
34
|
message?: string;
|
|
17
35
|
};
|
|
18
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Exposes control methods for the Form component, such as setting loading states or hiding errors.
|
|
39
|
+
*/
|
|
19
40
|
export interface FormHandler {
|
|
41
|
+
/** Sets the loading state of the form */
|
|
20
42
|
setLoading: (mode: boolean) => void;
|
|
43
|
+
/** Hides any currently displayed error message */
|
|
21
44
|
hideError: () => void;
|
|
45
|
+
/** Resets the form to its initial state */
|
|
46
|
+
init: () => void;
|
|
22
47
|
}
|
|
23
|
-
|
|
48
|
+
/**
|
|
49
|
+
* {@link Form} is a controlled component designed to handle form data submission, validation, and display of loading or error states.
|
|
50
|
+
* It allows for optional server-side submission through an action endpoint and customizable success/error handling callbacks.
|
|
51
|
+
*
|
|
52
|
+
* The component also provides an interface for controlling loading and error states from a parent component using {@link FormHandler}.
|
|
53
|
+
*
|
|
54
|
+
* @param props - Properties to configure form behavior, validation messages, submission handling, and visual feedback.
|
|
55
|
+
* @param ref - Reference to the {@link FormHandler} interface, exposing methods to control loading and error states from the parent.
|
|
56
|
+
*/
|
|
57
|
+
declare const Form: import("react").ForwardRefExoticComponent<FormProps & import("react").RefAttributes<FormHandler>>;
|
|
24
58
|
export default Form;
|