@zuzjs/ui 0.5.0 → 0.5.2
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/comps/drawer.js +6 -2
- package/dist/comps/tabview.d.ts +1 -1
- package/dist/funs/css.js +2 -2
- package/dist/funs/index.d.ts +1 -1
- package/dist/funs/index.js +23 -1
- package/dist/funs/stylesheet.js +1 -0
- package/package.json +1 -1
package/dist/comps/drawer.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
3
3
|
import With from "./base";
|
|
4
4
|
import { DRAWER_SIDE, TRANSITION_CURVES, TRANSITIONS } from "../types/enums";
|
|
5
5
|
const Drawer = forwardRef((props, ref) => {
|
|
6
6
|
const { as, from, speed, children, prerender, ...rest } = props;
|
|
7
|
+
const [render, setRender] = useState(undefined == prerender ? true : prerender);
|
|
7
8
|
const [visible, setVisible] = useState(false);
|
|
8
9
|
const divRef = useRef(null);
|
|
9
10
|
const [content, setContent] = useState(children);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
setContent(children);
|
|
13
|
+
}, [children]);
|
|
10
14
|
const style = useMemo(() => {
|
|
11
15
|
switch (from) {
|
|
12
16
|
case DRAWER_SIDE.Left:
|
|
@@ -44,6 +48,6 @@ const Drawer = forwardRef((props, ref) => {
|
|
|
44
48
|
when: visible,
|
|
45
49
|
curve: TRANSITION_CURVES.EaseInOut,
|
|
46
50
|
duration: speed || .5,
|
|
47
|
-
}, ...rest, children: [from == DRAWER_SIDE.Top || from == DRAWER_SIDE.Bottom ? _jsx(With, { className: "drawer-handle" }) : null, visible
|
|
51
|
+
}, ...rest, children: [from == DRAWER_SIDE.Top || from == DRAWER_SIDE.Bottom ? _jsx(With, { className: "drawer-handle" }) : null, render ? content : visible ? content : null] })] });
|
|
48
52
|
});
|
|
49
53
|
export default Drawer;
|
package/dist/comps/tabview.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ReactNode } from "react";
|
|
|
2
2
|
import { BaseProps } from "../types/interfaces";
|
|
3
3
|
export interface Tab {
|
|
4
4
|
onSelect: (index: number) => void;
|
|
5
|
-
label: string;
|
|
5
|
+
label: string | ReactNode | ReactNode[];
|
|
6
6
|
body: string | ReactNode | ReactNode[];
|
|
7
7
|
render?: boolean;
|
|
8
8
|
}
|
package/dist/funs/css.js
CHANGED
|
@@ -55,7 +55,7 @@ class CSS {
|
|
|
55
55
|
"@before", "@after", "@active", "@checked", "@default", "@disabled", "@empty", "@enabled", "@first", "@firstChild", "@firstOfType", "@focus", "@hover", "@indeterminate", "@inRange", "@invalid", "@lastChild", "@lastOfType", "@link", "@not", "@nthChild", "@nthLastChild", "@nthLastOfType", "@nthOfType", "@onlyChild", "@onlyOfType", "@optional", "@outOfRange", "@readOnly", "@readWrite", "@required", "@root", "@scope", "@target", "@valid", "@visited"
|
|
56
56
|
];
|
|
57
57
|
this.IGNORE = [
|
|
58
|
-
`flex`, `opacity`, `z-index`, `zIndex`, `color`, `line-height`, `anim`, `scale`
|
|
58
|
+
`flex`, `opacity`, `z-index`, `zIndex`, `color`, `line-height`, `anim`, `scale`, `saturate`
|
|
59
59
|
];
|
|
60
60
|
this.keysWithoutCommaToSpace = [
|
|
61
61
|
`transform`, `translate`, `color`, `background`, `background-color`, `backgroundColor`,
|
|
@@ -546,7 +546,7 @@ class CSS {
|
|
|
546
546
|
_out = _out.replace(`;`, `${important};`);
|
|
547
547
|
}
|
|
548
548
|
else {
|
|
549
|
-
const __value = `${val}${key
|
|
549
|
+
const __value = `${val}${self.IGNORE.includes(key) ? `` : self.makeUnit(key, val)}`;
|
|
550
550
|
_out = self.DIRECT[key].includes(`__VALUE__`) ?
|
|
551
551
|
self.DIRECT[key].replace(/__VALUE__/g, __value).replace(`;`, `${important};`) : self.DIRECT[key];
|
|
552
552
|
}
|
package/dist/funs/index.d.ts
CHANGED
|
@@ -35,4 +35,4 @@ export declare const withTime: (fun: (...args: any[]) => any) => {
|
|
|
35
35
|
export declare const time: (stamp?: number, format?: string) => string;
|
|
36
36
|
export declare const arrayRand: (arr: any[]) => any;
|
|
37
37
|
export declare const formatNumber: ({ number, locale, style, decimal, currency }: FormatNumberParams) => string;
|
|
38
|
-
export declare const copyToClipboard: (text: string) => Promise<
|
|
38
|
+
export declare const copyToClipboard: (text: string) => Promise<unknown>;
|
package/dist/funs/index.js
CHANGED
|
@@ -190,4 +190,26 @@ export const formatNumber = ({ number, locale = 'en-US', style = `decimal`, deci
|
|
|
190
190
|
maximumFractionDigits: +number % 1 > 0 ? 2 : 0
|
|
191
191
|
}).format(+number);
|
|
192
192
|
};
|
|
193
|
-
export const copyToClipboard = (text) =>
|
|
193
|
+
export const copyToClipboard = (text) => {
|
|
194
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
195
|
+
return navigator.clipboard.writeText(text);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
return new Promise((resolve, reject) => {
|
|
199
|
+
const textarea = document.createElement("textarea");
|
|
200
|
+
textarea.value = text;
|
|
201
|
+
textarea.style.position = "fixed";
|
|
202
|
+
document.body.appendChild(textarea);
|
|
203
|
+
textarea.focus();
|
|
204
|
+
textarea.select();
|
|
205
|
+
try {
|
|
206
|
+
document.execCommand("copy");
|
|
207
|
+
resolve(`Copied to clipboard`);
|
|
208
|
+
}
|
|
209
|
+
catch (err) {
|
|
210
|
+
reject(err);
|
|
211
|
+
}
|
|
212
|
+
document.body.removeChild(textarea);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
};
|
package/dist/funs/stylesheet.js
CHANGED
|
@@ -292,6 +292,7 @@ export const cssDirect = {
|
|
|
292
292
|
"block": "display: block;",
|
|
293
293
|
"inlineblock": "display: inline-block;",
|
|
294
294
|
"blur": "filter: blur(__VALUE__);",
|
|
295
|
+
"saturate": "filter: saturate(__VALUE__);",
|
|
295
296
|
"ratio": "aspect-ratio: __VALUE__;",
|
|
296
297
|
"center-h": "left: 50%;transform: translateX(-50%);",
|
|
297
298
|
"center-v": "top: 50%;transform: translateY(-50%);",
|