@zuzjs/ui 0.7.5 → 0.7.7
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/cjs/comps/AutoComplete/index.js +3 -3
- package/dist/cjs/comps/Drawer/index.d.ts +2 -1
- package/dist/cjs/comps/Drawer/index.js +12 -5
- package/dist/cjs/comps/Drawer/types.d.ts +1 -0
- package/dist/cjs/comps/Filters/index.js +1 -0
- package/dist/cjs/comps/Pagination/index.d.ts +5 -2
- package/dist/cjs/comps/Pagination/index.js +23 -13
- package/dist/cjs/comps/Pagination/types.d.ts +5 -2
- package/dist/cjs/comps/ProgressBar/index.d.ts +1 -1
- package/dist/cjs/comps/ProgressBar/index.js +2 -1
- package/dist/cjs/comps/Radio/index.d.ts +2 -2
- package/dist/cjs/comps/Radio/index.js +7 -5
- package/dist/cjs/comps/Radio/types.d.ts +1 -1
- package/dist/cjs/comps/Segmented/index.d.ts +2 -2
- package/dist/cjs/comps/Segmented/index.js +3 -3
- package/dist/cjs/comps/Segmented/item.js +2 -2
- package/dist/cjs/comps/TabView/body.js +1 -1
- package/dist/cjs/comps/TabView/index.d.ts +1 -2
- package/dist/cjs/comps/TabView/index.js +2 -1
- package/dist/cjs/comps/Table/col.d.ts +2 -1
- package/dist/cjs/comps/Table/col.js +16 -4
- package/dist/cjs/comps/Table/index.js +12 -6
- package/dist/cjs/comps/Table/row.js +6 -6
- package/dist/cjs/comps/Table/types.d.ts +11 -4
- package/dist/cjs/comps/TextWheel/index.js +5 -5
- package/dist/cjs/funs/index.d.ts +7 -6
- package/dist/cjs/funs/index.js +36 -9
- package/dist/cjs/hooks/useBase.d.ts +1 -1
- package/dist/cjs/hooks/useBase.js +3 -3
- package/dist/cjs/src/comps/TabView/body.js +1 -1
- package/dist/cjs/src/hooks/useBase.d.ts +1 -1
- package/dist/cjs/src/hooks/useBase.js +3 -3
- package/dist/cjs/tsconfig.tsbuildinfo +1 -0
- package/dist/cjs/types/index.d.ts +2 -1
- package/dist/css/styles.css +1 -1
- package/dist/esm/comps/AutoComplete/index.js +3 -3
- package/dist/esm/comps/Drawer/index.d.ts +2 -1
- package/dist/esm/comps/Drawer/index.js +12 -5
- package/dist/esm/comps/Drawer/types.d.ts +1 -0
- package/dist/esm/comps/Filters/index.js +1 -0
- package/dist/esm/comps/Pagination/index.d.ts +5 -2
- package/dist/esm/comps/Pagination/index.js +23 -13
- package/dist/esm/comps/Pagination/types.d.ts +5 -2
- package/dist/esm/comps/ProgressBar/index.d.ts +1 -1
- package/dist/esm/comps/ProgressBar/index.js +2 -1
- package/dist/esm/comps/Radio/index.d.ts +2 -2
- package/dist/esm/comps/Radio/index.js +7 -5
- package/dist/esm/comps/Radio/types.d.ts +1 -1
- package/dist/esm/comps/Segmented/index.d.ts +2 -2
- package/dist/esm/comps/Segmented/index.js +3 -3
- package/dist/esm/comps/Segmented/item.js +2 -2
- package/dist/esm/comps/TabView/body.js +1 -1
- package/dist/esm/comps/TabView/index.d.ts +1 -2
- package/dist/esm/comps/TabView/index.js +2 -1
- package/dist/esm/comps/Table/col.d.ts +2 -1
- package/dist/esm/comps/Table/col.js +16 -4
- package/dist/esm/comps/Table/index.js +12 -6
- package/dist/esm/comps/Table/row.js +6 -6
- package/dist/esm/comps/Table/types.d.ts +11 -4
- package/dist/esm/comps/TextWheel/index.js +5 -5
- package/dist/esm/funs/index.d.ts +7 -6
- package/dist/esm/funs/index.js +36 -9
- package/dist/esm/hooks/useBase.d.ts +1 -1
- package/dist/esm/hooks/useBase.js +3 -3
- package/dist/esm/src/comps/TabView/body.js +1 -1
- package/dist/esm/src/hooks/useBase.d.ts +1 -1
- package/dist/esm/src/hooks/useBase.js +3 -3
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/esm/types/index.d.ts +2 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/cjs/hooks/useToast.d.ts +0 -1
- package/dist/cjs/hooks/useToast.js +0 -3
- package/dist/esm/hooks/useToast.d.ts +0 -1
- package/dist/esm/hooks/useToast.js +0 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { Box } from '@zuzjs/ui';
|
|
4
3
|
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import Box from '../Box';
|
|
5
5
|
const TabBody = ({ size, index, active, render, content }) => {
|
|
6
6
|
const _ref = useRef(null);
|
|
7
7
|
const [style, setStyle] = useState({});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Tab, TabViewHandler } from "./types";
|
|
2
|
-
|
|
3
|
-
declare const TabView: import("react").ForwardRefExoticComponent<BoxProps & {
|
|
2
|
+
declare const TabView: import("react").ForwardRefExoticComponent<import("..").BoxProps & {
|
|
4
3
|
onChange?: (tab: Tab, index: number) => void;
|
|
5
4
|
speed?: number;
|
|
6
5
|
variant?: "fixed" | "default";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { forwardRef, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { SelectTabs } from "../..";
|
|
3
5
|
import { uuid } from "../../funs";
|
|
4
6
|
import { useBase, useResizeObserver } from "../../hooks";
|
|
5
7
|
import Box from "../Box";
|
|
6
|
-
import { SelectTabs } from "../..";
|
|
7
8
|
import TabBody from "./body";
|
|
8
9
|
const TabView = forwardRef((props, ref) => {
|
|
9
10
|
const { tabs: _tabs, speed, prerender, variant, onChange, ...rest } = props;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { CSSProperties } from "react";
|
|
2
|
-
import type { Column } from "./types";
|
|
3
2
|
import { PubSub } from "../..";
|
|
3
|
+
import type { Column } from "./types";
|
|
4
4
|
declare const TColumn: <T>(props: Column<T> & {
|
|
5
5
|
idx: number;
|
|
6
6
|
style?: CSSProperties;
|
|
7
7
|
pubsub: PubSub;
|
|
8
|
+
sortBy?: string | null;
|
|
8
9
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
export default TColumn;
|
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { SVGIcons } from "../..";
|
|
2
4
|
import Box from "../Box";
|
|
3
5
|
const TColumn = (props) => {
|
|
4
|
-
const { idx, id, as, weight, style, value, render, resize,
|
|
5
|
-
|
|
6
|
+
const { idx, id, as, weight, style, value, render, resize, sortBy, sortable, onSort } = props;
|
|
7
|
+
const [_sort, setSort] = useState(0);
|
|
8
|
+
const _onSort = () => {
|
|
9
|
+
if (sortable) {
|
|
10
|
+
onSort?.(String(id), _sort == 1 ? -1 : 1);
|
|
11
|
+
setSort(prev => prev == 1 ? -1 : 1);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
return _jsxs(Box, { style: {
|
|
6
15
|
flex: weight || 1,
|
|
7
16
|
...style
|
|
8
|
-
}, as: `--col flex aic ${as || ``}`, children: value })
|
|
17
|
+
}, as: `--col flex aic ${as || ``} ${sortable ? `--sortable` : ``}`, onClick: _onSort, children: [_jsx(Box, { children: value }), idx == -1
|
|
18
|
+
&& sortable
|
|
19
|
+
&& sortBy == id
|
|
20
|
+
&& _jsx(Box, { as: `--arrow flex aib`, children: _sort == 1 ? SVGIcons.arrowUp : SVGIcons.arrowDown })] });
|
|
9
21
|
};
|
|
10
22
|
export default TColumn;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useMemo, useRef } from "react";
|
|
3
|
-
import
|
|
3
|
+
import { forwardRef, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { PubSub, uuid } from "../..";
|
|
4
5
|
import { useBase } from "../../hooks";
|
|
5
|
-
import
|
|
6
|
+
import Box from "../Box";
|
|
6
7
|
import Pagination from "../Pagination";
|
|
7
8
|
import { PaginationStyle } from "../Pagination/types";
|
|
8
|
-
import
|
|
9
|
+
import TRow from "./row";
|
|
9
10
|
// const Table = forwardRef<HTMLDivElement, TableProps>((props, ref) => {
|
|
10
11
|
const Table = (props, ref) => {
|
|
11
|
-
const { schema, rows, rowCount, rowsPerPage, currentPage, pagination, animateRows, header,
|
|
12
|
+
const { schema, rows, rowCount, rowsPerPage, currentPage, pagination, paginationHash, showPaginationOnZeroPageCount, animateRows, header, rowClassName, selectableRows, hoverable, sortBy, onSort, onRowSelectToggle, onPageChange, onRowContextMenu, ...pops } = props;
|
|
12
13
|
const _schemaParsed = useMemo(() => schema.reduce((prev, c) => {
|
|
13
14
|
prev[c.id] = {
|
|
14
15
|
flex: c.weight || 1,
|
|
@@ -28,7 +29,12 @@ const Table = (props, ref) => {
|
|
|
28
29
|
const _tableRef = useRef(null);
|
|
29
30
|
const pubsub = useMemo(() => new PubSub(), []);
|
|
30
31
|
const rowKeys = useMemo(() => rows.map(() => uuid()), [rows]);
|
|
31
|
-
|
|
32
|
+
const [_sortBy, setSortBy] = useState(sortBy || null);
|
|
33
|
+
const handleSort = (col, dir) => {
|
|
34
|
+
setSortBy(col);
|
|
35
|
+
onSort?.(col, dir);
|
|
36
|
+
};
|
|
37
|
+
return _jsxs(Box, { as: `--table ${(hoverable ?? true) ? `--hoverable` : ``} flex cols ${className}`, ref: _tableRef, children: [_header == true && _jsx(TRow, { sortBy: _sortBy, onSort: handleSort, tableRef: _tableRef, pubsub: pubsub, selectable: selectableRows, index: -1, schema: schema, styles: _schemaParsed }), rows && rows.map((row, index) => _jsx(TRow, { tableRef: _tableRef, pubsub: pubsub, index: index, schema: schema, ids: _cols, styles: _schemaParsed, animate: animateRows, data: row, rowClassName: rowClassName, selectable: selectableRows, onSelect: onRowSelectToggle, onContextMenu: onRowContextMenu }, `--trow-${rowKeys[index]}-${schema[0].id}`)), pagination && _jsx(Box, { as: `--row flex aic --row-footer`, children: _jsx(Pagination, { hash: paginationHash, renderOnZeroPageCount: showPaginationOnZeroPageCount, onPageChange: onPageChange, paginationStyle: PaginationStyle.Table, startPage: currentPage, itemCount: rowCount || (rows ? rows.length : 0), itemsPerPage: rowsPerPage || 10 }) })] });
|
|
32
38
|
};
|
|
33
39
|
const ForwardedTable = forwardRef(Table);
|
|
34
40
|
export default ForwardedTable;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment, useEffect, useMemo, useRef } from "react";
|
|
3
|
-
import Box from "../Box";
|
|
4
|
-
import TColumn from "./col";
|
|
5
|
-
import { CHECKBOX, TRANSITION_CURVES, TRANSITIONS } from "../../types/enums";
|
|
6
3
|
import { useDelayed } from "../../hooks";
|
|
4
|
+
import { CHECKBOX, TRANSITION_CURVES, TRANSITIONS } from "../../types/enums";
|
|
5
|
+
import Box from "../Box";
|
|
7
6
|
import CheckBox from "../CheckBox";
|
|
7
|
+
import TColumn from "./col";
|
|
8
8
|
const TRow = (props) => {
|
|
9
|
-
const { index, pubsub, schema, data, ids, styles, animate, selectable, tableRef, rowClassName, onSelect, onContextMenu } = props;
|
|
9
|
+
const { index, pubsub, schema, data, ids, styles, animate, sortBy, selectable, tableRef, rowClassName, onSort, onSelect, onContextMenu } = props;
|
|
10
10
|
const mounted = useDelayed();
|
|
11
11
|
const _animation = useMemo(() => ({
|
|
12
12
|
transition: TRANSITIONS.SlideInBottom,
|
|
@@ -75,11 +75,11 @@ const TRow = (props) => {
|
|
|
75
75
|
}, []);
|
|
76
76
|
return _jsxs(Box, { onContextMenu: e => onContextMenu ? onContextMenu(e, data) : null, "data-index": index, ...(animate ? { animate: { ..._animation, when: mounted } } : {}), as: `--row flex aic ${index == -1 ? `--row-head` : ``} ${rowClassName || ``}`, children: [index == -1 && schema.map((c, i) => {
|
|
77
77
|
const { renderWhenHeader, render, value, ...cc } = c;
|
|
78
|
-
return _jsxs(Fragment, { children: [selectable && i == 0 && Selector(-1, `--selector-${c.id}`, `all`), _jsx(TColumn, { idx: -1,
|
|
78
|
+
return _jsxs(Fragment, { children: [selectable && i == 0 && Selector(-1, `--selector-${c.id}`, `all`), _jsx(TColumn, { idx: -1, onSort: onSort, sortBy: sortBy,
|
|
79
79
|
// value={renderWhenHeader && render ? render!(index == -1 ? c as dynamicObject : data as T, index) : value as string}
|
|
80
80
|
value: value, ...cc, pubsub: pubsub, style: styles[c.id] })] }, `--col-${c.id}`);
|
|
81
81
|
}), index > -1 && ids && data && schema.map((c, i) => {
|
|
82
|
-
return _jsxs(Fragment, { children: [selectable && i == 0 && Selector(i, `--selector-${c.id}`, c.id.toString()), ids.includes(String(c.id)) ? _jsx(TColumn, { pubsub: pubsub, idx: i, id: String(c.id), style: styles[String(c.id)], value: c.render ? c.render(data, index) : data[c.id] }) : null] }, `--${String(c.id)}-val-${i}`);
|
|
82
|
+
return _jsxs(Fragment, { children: [selectable && i == 0 && Selector(i, `--selector-${c.id}`, c.id.toString()), ids.includes(String(c.id)) ? _jsx(TColumn, { pubsub: pubsub, idx: i, id: String(c.id), style: styles[String(c.id)], value: c.render ? c.render(data, index) : data[String(c.id).includes(`.`) ? String(c.id).split(`.`).reverse()[0] : c.id] }) : null] }, `--${String(c.id)}-val-${i}`);
|
|
83
83
|
})] });
|
|
84
84
|
};
|
|
85
85
|
export default TRow;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ReactNode, RefObject } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { PubSub } from "../..";
|
|
3
3
|
import { dynamicObject } from "../../types";
|
|
4
|
+
import { BoxProps } from "../Box";
|
|
4
5
|
import { PaginationCallback } from "../Pagination/types";
|
|
5
|
-
import { PubSub } from "../..";
|
|
6
6
|
export type RowSelectCallback<T> = (row: T, selected: boolean) => void;
|
|
7
|
+
export type TableSortCallback = (col: string, dir: number) => void;
|
|
7
8
|
export type Row<T> = {
|
|
8
9
|
index: number;
|
|
9
10
|
schema: Column<T>[];
|
|
@@ -13,14 +14,16 @@ export type Row<T> = {
|
|
|
13
14
|
data?: T;
|
|
14
15
|
rowClassName?: string;
|
|
15
16
|
selectable?: boolean;
|
|
17
|
+
sortBy?: string | null;
|
|
16
18
|
onSelect?: RowSelectCallback<T>;
|
|
19
|
+
onSort?: TableSortCallback;
|
|
17
20
|
pubsub: PubSub;
|
|
18
21
|
tableRef?: RefObject<HTMLDivElement | null>;
|
|
19
22
|
onContextMenu?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>, row: T) => void;
|
|
20
23
|
};
|
|
21
24
|
export type Column<T> = {
|
|
22
25
|
id: string | number;
|
|
23
|
-
value
|
|
26
|
+
value?: string | ReactNode | dynamicObject;
|
|
24
27
|
weight?: number;
|
|
25
28
|
w?: number | string;
|
|
26
29
|
maxW?: number | string;
|
|
@@ -29,7 +32,8 @@ export type Column<T> = {
|
|
|
29
32
|
maxH?: number | string;
|
|
30
33
|
minH?: number | string;
|
|
31
34
|
resize?: boolean;
|
|
32
|
-
|
|
35
|
+
sortable?: boolean;
|
|
36
|
+
onSort?: TableSortCallback;
|
|
33
37
|
as?: string;
|
|
34
38
|
renderWhenHeader?: boolean;
|
|
35
39
|
render?: (row: T, index: number) => ReactNode;
|
|
@@ -42,12 +46,15 @@ export type TableProps<T> = BoxProps & {
|
|
|
42
46
|
rowClassName?: string;
|
|
43
47
|
currentPage?: number;
|
|
44
48
|
pagination?: boolean;
|
|
49
|
+
paginationHash?: number | null;
|
|
45
50
|
showPaginationOnZeroPageCount?: boolean;
|
|
46
51
|
animateRows?: boolean;
|
|
47
52
|
header?: boolean;
|
|
53
|
+
sortBy?: string;
|
|
48
54
|
selectableRows?: boolean;
|
|
49
55
|
hoverable?: boolean;
|
|
50
56
|
onRowSelectToggle?: RowSelectCallback<T>;
|
|
51
57
|
onRowContextMenu?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>, row: T) => void;
|
|
52
58
|
onPageChange?: PaginationCallback;
|
|
59
|
+
onSort?: TableSortCallback;
|
|
53
60
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
3
|
-
import { forwardRef } from 'react';
|
|
3
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
4
4
|
import Box from '../Box';
|
|
5
5
|
import Span from '../Span';
|
|
6
6
|
const TextWheel = forwardRef((props, ref) => {
|
|
@@ -34,11 +34,11 @@ const TextWheel = forwardRef((props, ref) => {
|
|
|
34
34
|
// console.log(value)
|
|
35
35
|
_setValue(value || 0);
|
|
36
36
|
}, [value]);
|
|
37
|
-
return _jsxs(Box, { className:
|
|
37
|
+
return _jsxs(Box, { className: `--text-wheel flex aic jcc rel`, "aria-hidden": true, as: as, ref: divRef, ...rest, children: [(_value || 0).toString().split('').map((char, index) => {
|
|
38
38
|
if (isNaN(parseInt(char, 10))) {
|
|
39
|
-
return _jsx(Span, { className: "wheel-char wheel-char-symbol grid", children: char }, `wheel-char-${index}`);
|
|
39
|
+
return _jsx(Span, { className: "--wheel-char wheel-char-symbol grid", children: char }, `wheel-char-${index}`);
|
|
40
40
|
}
|
|
41
|
-
return _jsx(Span, { "data-value": char, className:
|
|
41
|
+
return _jsx(Span, { "data-value": char, className: `--wheel-char grid ${index > char.toString().split('').length - 3 ? '--wheel-fraction' : ''}`.trim(), children: _jsxs(Span, { className: `--wheel-char-track --wheel-track-${direction || `down`} grid`, style: {
|
|
42
42
|
'--v': char
|
|
43
43
|
}, children: [_jsx(Span, { children: !direction || direction == `down` ? 0 : 9 }), (!direction || direction == `down` ?
|
|
44
44
|
[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
|
package/dist/esm/funs/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import CSS from "./css.js";
|
|
2
|
-
import { dynamicObject, FormatNumberParams, sortOptions } from "../types/index.js";
|
|
3
1
|
import { AxiosProgressEvent } from "axios";
|
|
4
|
-
import { KeyCode } from "../types/enums.js";
|
|
5
2
|
import { ReactElement, ReactNode, Ref } from "react";
|
|
3
|
+
import { KeyCode } from "../types/enums.js";
|
|
4
|
+
import { dynamicObject, FormatNumberParams, sortOptions } from "../types/index.js";
|
|
5
|
+
import CSS from "./css.js";
|
|
6
6
|
export declare const __SALT: string;
|
|
7
7
|
export declare const FIELNAME_KEY = "__FILENAME__";
|
|
8
8
|
export declare const LINE_KEY = "__LINE__";
|
|
@@ -29,8 +29,8 @@ export declare const isEmail: (e: string) => boolean;
|
|
|
29
29
|
export declare const isUrl: (o: string) => boolean;
|
|
30
30
|
export declare const toLowerCase: (o: string) => string;
|
|
31
31
|
export declare const ucfirst: (o: any) => string;
|
|
32
|
-
export declare const toHash: (n: number, len?: number) => string;
|
|
33
|
-
export declare const fromHash: (n: string) => number;
|
|
32
|
+
export declare const toHash: (n: number, len?: number, SALT?: string | null) => string;
|
|
33
|
+
export declare const fromHash: (n: string, SALT?: string | null) => number;
|
|
34
34
|
export declare const css: () => CSS;
|
|
35
35
|
export declare const withCSS: (cx: string | string[]) => string;
|
|
36
36
|
export declare const uuid: (len?: number) => string;
|
|
@@ -49,7 +49,8 @@ export declare const cleanProps: <T extends dynamicObject>(props: T, withProps?:
|
|
|
49
49
|
export declare const withZuz: (cx: string | string[]) => string;
|
|
50
50
|
export declare const setDeep: (object: dynamicObject, path: string, value: any, seperator?: string) => dynamicObject;
|
|
51
51
|
export declare const removeDuplicatesFromArray: <T>(array: T[]) => T[];
|
|
52
|
-
export declare const withPost: (uri: string, data: dynamicObject | FormData, timeout?: number, onProgress?: (ev: AxiosProgressEvent) => void) => Promise<
|
|
52
|
+
export declare const withPost: <T>(uri: string, data: dynamicObject | FormData, timeout?: number, onProgress?: (ev: AxiosProgressEvent) => void) => Promise<T>;
|
|
53
|
+
export declare const withGet: <T>(uri: string, timeout?: number) => Promise<T>;
|
|
53
54
|
export declare const withTime: (fun: (...args: any[]) => any) => {
|
|
54
55
|
result: any;
|
|
55
56
|
executionTime: number;
|
package/dist/esm/funs/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import Hashids from "hashids";
|
|
2
|
-
import CSS from "./css.js";
|
|
3
|
-
import { nanoid } from "nanoid";
|
|
4
|
-
import md5 from "md5";
|
|
5
|
-
import { colorNames } from "./colors.js";
|
|
6
|
-
import { cssProps } from "./stylesheet.js";
|
|
7
1
|
import axios from "axios";
|
|
2
|
+
import Hashids from "hashids";
|
|
8
3
|
import Cookies from "js-cookie";
|
|
4
|
+
import md5 from "md5";
|
|
9
5
|
import moment from "moment";
|
|
10
|
-
import {
|
|
6
|
+
import { nanoid } from "nanoid";
|
|
11
7
|
import { Children, cloneElement, isValidElement } from "react";
|
|
8
|
+
import { SORT } from "../types/enums.js";
|
|
9
|
+
import { colorNames } from "./colors.js";
|
|
10
|
+
import CSS from "./css.js";
|
|
11
|
+
import { cssProps } from "./stylesheet.js";
|
|
12
12
|
let __css;
|
|
13
13
|
export const __SALT = `zuzjs-ui`;
|
|
14
14
|
export const FIELNAME_KEY = `__FILENAME__`;
|
|
@@ -129,8 +129,8 @@ export const isEmail = (e) => /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.te
|
|
|
129
129
|
export const isUrl = (o) => /^(https?:\/\/)?(www\.)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(\/[^\s]*)?$/.test(o);
|
|
130
130
|
export const toLowerCase = (o) => (String.prototype.toLocaleLowerCase || String.prototype.toLowerCase)(o);
|
|
131
131
|
export const ucfirst = (o) => `${o.charAt(0).toUpperCase()}${o.substring(1, o.length)}`;
|
|
132
|
-
export const toHash = (n, len = 6) => new Hashids(__SALT, len).encode(n);
|
|
133
|
-
export const fromHash = (n) => Number(new Hashids(__SALT).decode(n));
|
|
132
|
+
export const toHash = (n, len = 6, SALT = null) => new Hashids(SALT || __SALT, len).encode(n);
|
|
133
|
+
export const fromHash = (n, SALT = null) => Number(new Hashids(SALT || __SALT).decode(n));
|
|
134
134
|
export const css = () => __css ? __css : __css = new CSS();
|
|
135
135
|
export const withCSS = (cx) => css().Build([[`string` == typeof cx ? cx : cx.join(` `)]]).cx.join(` `);
|
|
136
136
|
export const uuid = (len) => nanoid(len);
|
|
@@ -260,6 +260,33 @@ export const withPost = async (uri, data, timeout = 60, onProgress) => {
|
|
|
260
260
|
});
|
|
261
261
|
});
|
|
262
262
|
};
|
|
263
|
+
export const withGet = async (uri, timeout = 60) => {
|
|
264
|
+
return new Promise((resolve, reject) => {
|
|
265
|
+
axios
|
|
266
|
+
.get(uri, { timeout: timeout * 1000 })
|
|
267
|
+
.then((resp) => {
|
|
268
|
+
if (resp.data && "kind" in resp.data) {
|
|
269
|
+
resolve(resp.data);
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
reject(resp.data);
|
|
273
|
+
}
|
|
274
|
+
})
|
|
275
|
+
.catch((err) => {
|
|
276
|
+
if (err?.response?.data)
|
|
277
|
+
reject(err.response.data);
|
|
278
|
+
else
|
|
279
|
+
reject(err.code === `ERR_NETWORK`
|
|
280
|
+
? {
|
|
281
|
+
error: err.code,
|
|
282
|
+
message: navigator.onLine
|
|
283
|
+
? `Unable to connect to the server. It may be temporarily down.`
|
|
284
|
+
: `Network error: Unable to connect. Please check your internet connection and try again.`,
|
|
285
|
+
}
|
|
286
|
+
: err);
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
};
|
|
263
290
|
export const withTime = (fun) => {
|
|
264
291
|
const start = new Date().getTime();
|
|
265
292
|
const result = fun();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Props } from "../types";
|
|
2
1
|
import { ComponentPropsWithRef, CSSProperties, JSX } from "react";
|
|
2
|
+
import { Props } from "../types";
|
|
3
3
|
declare const useBase: <T extends keyof JSX.IntrinsicElements>(props: Props<T>) => {
|
|
4
4
|
style: CSSProperties;
|
|
5
5
|
className: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cleanProps, css } from "../funs";
|
|
2
2
|
import { buildWithStyles, getAnimationCurve, getAnimationTransition } from "../funs/css";
|
|
3
|
-
import useDrag from "./useDrag";
|
|
4
3
|
import { cssFilterKeys, cssTransformKeys, cssWithKeys } from "../funs/stylesheet";
|
|
4
|
+
import useDrag from "./useDrag";
|
|
5
5
|
const buildSkeletonStyle = (s) => {
|
|
6
6
|
const makeValue = (v, unit = `px`) => {
|
|
7
7
|
return v ?
|
|
@@ -29,12 +29,12 @@ const buildSkeletonStyle = (s) => {
|
|
|
29
29
|
return style;
|
|
30
30
|
};
|
|
31
31
|
const useBase = (props) => {
|
|
32
|
-
const { as, animate, skeleton, className, shimmer, propsToRemove, draggable, dragOptions, ...rest } = props || {};
|
|
32
|
+
const { as, fx, animate, skeleton, className, shimmer, propsToRemove, draggable, dragOptions, ...rest } = props || {};
|
|
33
33
|
let cx = [];
|
|
34
34
|
if (as) {
|
|
35
35
|
cx = css().Build(`string` == typeof as ? as : as.join(` `)).cx;
|
|
36
36
|
}
|
|
37
|
-
const { transition, from, to, when, duration, delay, curve } = animate || {};
|
|
37
|
+
const { transition, from, to, when, duration, delay, curve } = fx || animate || {};
|
|
38
38
|
let _style = {};
|
|
39
39
|
if (undefined === when) {
|
|
40
40
|
_style = transition ? getAnimationTransition(transition, true) : { ...from, ...to };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { Box } from '@zuzjs/ui';
|
|
4
3
|
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import Box from '../Box';
|
|
5
5
|
const TabBody = ({ size, index, active, render, content }) => {
|
|
6
6
|
const _ref = useRef(null);
|
|
7
7
|
const [style, setStyle] = useState({});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Props } from "../types";
|
|
2
1
|
import { ComponentPropsWithRef, CSSProperties, JSX } from "react";
|
|
2
|
+
import { Props } from "../types";
|
|
3
3
|
declare const useBase: <T extends keyof JSX.IntrinsicElements>(props: Props<T>) => {
|
|
4
4
|
style: CSSProperties;
|
|
5
5
|
className: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cleanProps, css } from "../funs";
|
|
2
2
|
import { buildWithStyles, getAnimationCurve, getAnimationTransition } from "../funs/css";
|
|
3
|
-
import useDrag from "./useDrag";
|
|
4
3
|
import { cssFilterKeys, cssTransformKeys, cssWithKeys } from "../funs/stylesheet";
|
|
4
|
+
import useDrag from "./useDrag";
|
|
5
5
|
const buildSkeletonStyle = (s) => {
|
|
6
6
|
const makeValue = (v, unit = `px`) => {
|
|
7
7
|
return v ?
|
|
@@ -29,12 +29,12 @@ const buildSkeletonStyle = (s) => {
|
|
|
29
29
|
return style;
|
|
30
30
|
};
|
|
31
31
|
const useBase = (props) => {
|
|
32
|
-
const { as, animate, skeleton, className, shimmer, propsToRemove, draggable, dragOptions, ...rest } = props || {};
|
|
32
|
+
const { as, fx, animate, skeleton, className, shimmer, propsToRemove, draggable, dragOptions, ...rest } = props || {};
|
|
33
33
|
let cx = [];
|
|
34
34
|
if (as) {
|
|
35
35
|
cx = css().Build(`string` == typeof as ? as : as.join(` `)).cx;
|
|
36
36
|
}
|
|
37
|
-
const { transition, from, to, when, duration, delay, curve } = animate || {};
|
|
37
|
+
const { transition, from, to, when, duration, delay, curve } = fx || animate || {};
|
|
38
38
|
let _style = {};
|
|
39
39
|
if (undefined === when) {
|
|
40
40
|
_style = transition ? getAnimationTransition(transition, true) : { ...from, ...to };
|