@zuzjs/ui 0.8.1 → 0.8.3
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/Accordion/index.js +1 -1
- package/dist/cjs/comps/Actionbar/index.js +1 -1
- package/dist/cjs/comps/Alert/index.js +1 -1
- package/dist/cjs/comps/AutoComplete/index.d.ts +1 -1
- package/dist/cjs/comps/AutoComplete/index.js +3 -2
- package/dist/cjs/comps/Avatar/index.js +5 -5
- package/dist/cjs/comps/Box/index.js +1 -1
- package/dist/cjs/comps/Button/index.js +1 -1
- package/dist/cjs/comps/CheckBox/index.d.ts +1 -0
- package/dist/cjs/comps/CheckBox/index.js +1 -1
- package/dist/cjs/comps/CheckBox/types.d.ts +1 -0
- package/dist/cjs/comps/ColorScheme/index.js +1 -1
- package/dist/cjs/comps/ContextMenu/index.d.ts +2 -0
- package/dist/cjs/comps/ContextMenu/index.js +6 -6
- package/dist/cjs/comps/ContextMenu/item.js +1 -1
- package/dist/cjs/comps/ContextMenu/types.d.ts +3 -1
- package/dist/cjs/comps/CookiesConsent/index.js +1 -1
- package/dist/cjs/comps/Cover/index.js +1 -1
- package/dist/cjs/comps/Cropper/index.d.ts +8 -0
- package/dist/cjs/comps/Cropper/index.js +20 -0
- package/dist/cjs/comps/Cropper/types.d.ts +14 -0
- package/dist/cjs/comps/Cropper/types.js +5 -0
- package/dist/cjs/comps/Crumb/index.d.ts +2 -1
- package/dist/cjs/comps/Crumb/index.js +13 -3
- package/dist/cjs/comps/Crumb/types.d.ts +1 -0
- package/dist/cjs/comps/Drawer/index.js +1 -1
- package/dist/cjs/comps/Fab/index.js +1 -1
- package/dist/cjs/comps/Filters/index.js +1 -1
- package/dist/cjs/comps/Form/index.js +22 -6
- package/dist/cjs/comps/Icon/index.js +1 -1
- package/dist/cjs/comps/Image/index.js +1 -1
- package/dist/cjs/comps/Input/index.d.ts +2 -2
- package/dist/cjs/comps/Input/index.js +1 -1
- package/dist/cjs/comps/KeyboardKeys/index.js +1 -1
- package/dist/cjs/comps/Label/index.js +1 -1
- package/dist/cjs/comps/List/index.d.ts +1 -1
- package/dist/cjs/comps/List/index.js +1 -1
- package/dist/cjs/comps/Network/index.js +1 -1
- package/dist/cjs/comps/Overlay/index.js +1 -1
- package/dist/cjs/comps/Pagination/index.js +1 -1
- package/dist/cjs/comps/Password/index.d.ts +6 -2
- package/dist/cjs/comps/Password/index.js +15 -5
- package/dist/cjs/comps/PinInput/index.d.ts +1 -1
- package/dist/cjs/comps/PinInput/index.js +8 -3
- package/dist/cjs/comps/ProgressBar/index.js +2 -2
- package/dist/cjs/comps/Radio/index.js +1 -1
- package/dist/cjs/comps/ScrollView/index.js +1 -1
- package/dist/cjs/comps/Search/index.d.ts +1 -1
- package/dist/cjs/comps/Search/index.js +1 -1
- package/dist/cjs/comps/Segmented/index.js +1 -1
- package/dist/cjs/comps/Select/index.d.ts +1 -0
- package/dist/cjs/comps/Select/index.js +3 -3
- package/dist/cjs/comps/Select/types.d.ts +6 -1
- package/dist/cjs/comps/Sheet/index.js +1 -1
- package/dist/cjs/comps/Sidebar/index.js +1 -1
- package/dist/cjs/comps/Slider/index.js +1 -1
- package/dist/cjs/comps/Span/index.js +1 -1
- package/dist/cjs/comps/Spinner/index.js +1 -1
- package/dist/cjs/comps/Switch/index.d.ts +1 -0
- package/dist/cjs/comps/Switch/index.js +1 -1
- package/dist/cjs/comps/TabView/body.js +1 -1
- package/dist/cjs/comps/TabView/index.js +1 -1
- package/dist/cjs/comps/TabView/tab.js +1 -1
- package/dist/cjs/comps/Table/col.js +1 -1
- package/dist/cjs/comps/Table/index.js +56 -2
- package/dist/cjs/comps/Table/row.js +1 -1
- package/dist/cjs/comps/Text/index.js +1 -1
- package/dist/cjs/comps/TextArea/index.js +1 -1
- package/dist/cjs/comps/TextWheel/index.js +3 -3
- package/dist/cjs/comps/Tooltip/index.js +1 -1
- package/dist/cjs/comps/Treeview/index.js +1 -1
- package/dist/cjs/comps/Treeview/item.js +1 -1
- package/dist/cjs/comps/VideoPlayer/index.js +1 -0
- package/dist/cjs/comps/index.d.ts +2 -0
- package/dist/cjs/comps/index.js +2 -0
- package/dist/cjs/funs/events.d.ts +31 -7
- package/dist/cjs/funs/events.js +57 -19
- package/dist/cjs/funs/index.d.ts +5 -3
- package/dist/cjs/funs/index.js +39 -84
- package/dist/cjs/hooks/index.d.ts +2 -0
- package/dist/cjs/hooks/index.js +2 -0
- package/dist/cjs/hooks/useDB.d.ts +5 -1
- package/dist/cjs/hooks/useDB.js +52 -4
- package/dist/cjs/hooks/useImage.js +2 -2
- package/dist/cjs/hooks/useImageCropper.d.ts +10 -0
- package/dist/cjs/hooks/useImageCropper.js +67 -0
- package/dist/cjs/hooks/useSlider.d.ts +1 -1
- package/dist/cjs/hooks/useUploader.d.ts +46 -0
- package/dist/cjs/hooks/useUploader.js +101 -0
- package/dist/cjs/hooks/useWebSocket.d.ts +2 -2
- package/dist/cjs/hooks/useWebSocket.js +13 -2
- package/dist/cjs/types/index.d.ts +3 -0
- package/dist/css/styles.css +1 -1
- package/dist/esm/comps/Accordion/index.js +1 -1
- package/dist/esm/comps/Actionbar/index.js +1 -1
- package/dist/esm/comps/Alert/index.js +1 -1
- package/dist/esm/comps/AutoComplete/index.d.ts +1 -1
- package/dist/esm/comps/AutoComplete/index.js +3 -2
- package/dist/esm/comps/Avatar/index.js +5 -5
- package/dist/esm/comps/Box/index.js +1 -1
- package/dist/esm/comps/Button/index.js +1 -1
- package/dist/esm/comps/CheckBox/index.d.ts +1 -0
- package/dist/esm/comps/CheckBox/index.js +1 -1
- package/dist/esm/comps/CheckBox/types.d.ts +1 -0
- package/dist/esm/comps/ColorScheme/index.js +1 -1
- package/dist/esm/comps/ContextMenu/index.d.ts +2 -0
- package/dist/esm/comps/ContextMenu/index.js +6 -6
- package/dist/esm/comps/ContextMenu/item.js +1 -1
- package/dist/esm/comps/ContextMenu/types.d.ts +3 -1
- package/dist/esm/comps/CookiesConsent/index.js +1 -1
- package/dist/esm/comps/Cover/index.js +1 -1
- package/dist/esm/comps/Cropper/index.d.ts +8 -0
- package/dist/esm/comps/Cropper/index.js +20 -0
- package/dist/esm/comps/Cropper/types.d.ts +14 -0
- package/dist/esm/comps/Cropper/types.js +5 -0
- package/dist/esm/comps/Crumb/index.d.ts +2 -1
- package/dist/esm/comps/Crumb/index.js +13 -3
- package/dist/esm/comps/Crumb/types.d.ts +1 -0
- package/dist/esm/comps/Drawer/index.js +1 -1
- package/dist/esm/comps/Fab/index.js +1 -1
- package/dist/esm/comps/Filters/index.js +1 -1
- package/dist/esm/comps/Form/index.js +22 -6
- package/dist/esm/comps/Icon/index.js +1 -1
- package/dist/esm/comps/Image/index.js +1 -1
- package/dist/esm/comps/Input/index.d.ts +2 -2
- package/dist/esm/comps/Input/index.js +1 -1
- package/dist/esm/comps/KeyboardKeys/index.js +1 -1
- package/dist/esm/comps/Label/index.js +1 -1
- package/dist/esm/comps/List/index.d.ts +1 -1
- package/dist/esm/comps/List/index.js +1 -1
- package/dist/esm/comps/Network/index.js +1 -1
- package/dist/esm/comps/Overlay/index.js +1 -1
- package/dist/esm/comps/Pagination/index.js +1 -1
- package/dist/esm/comps/Password/index.d.ts +6 -2
- package/dist/esm/comps/Password/index.js +15 -5
- package/dist/esm/comps/PinInput/index.d.ts +1 -1
- package/dist/esm/comps/PinInput/index.js +8 -3
- package/dist/esm/comps/ProgressBar/index.js +2 -2
- package/dist/esm/comps/Radio/index.js +1 -1
- package/dist/esm/comps/ScrollView/index.js +1 -1
- package/dist/esm/comps/Search/index.d.ts +1 -1
- package/dist/esm/comps/Search/index.js +1 -1
- package/dist/esm/comps/Segmented/index.js +1 -1
- package/dist/esm/comps/Select/index.d.ts +1 -0
- package/dist/esm/comps/Select/index.js +3 -3
- package/dist/esm/comps/Select/types.d.ts +6 -1
- package/dist/esm/comps/Sheet/index.js +1 -1
- package/dist/esm/comps/Sidebar/index.js +1 -1
- package/dist/esm/comps/Slider/index.js +1 -1
- package/dist/esm/comps/Span/index.js +1 -1
- package/dist/esm/comps/Spinner/index.js +1 -1
- package/dist/esm/comps/Switch/index.d.ts +1 -0
- package/dist/esm/comps/Switch/index.js +1 -1
- package/dist/esm/comps/TabView/body.js +1 -1
- package/dist/esm/comps/TabView/index.js +1 -1
- package/dist/esm/comps/TabView/tab.js +1 -1
- package/dist/esm/comps/Table/col.js +1 -1
- package/dist/esm/comps/Table/index.js +56 -2
- package/dist/esm/comps/Table/row.js +1 -1
- package/dist/esm/comps/Text/index.js +1 -1
- package/dist/esm/comps/TextArea/index.js +1 -1
- package/dist/esm/comps/TextWheel/index.js +3 -3
- package/dist/esm/comps/Tooltip/index.js +1 -1
- package/dist/esm/comps/Treeview/index.js +1 -1
- package/dist/esm/comps/Treeview/item.js +1 -1
- package/dist/esm/comps/VideoPlayer/index.js +1 -0
- package/dist/esm/comps/index.d.ts +2 -0
- package/dist/esm/comps/index.js +2 -0
- package/dist/esm/funs/events.d.ts +31 -7
- package/dist/esm/funs/events.js +57 -19
- package/dist/esm/funs/index.d.ts +5 -3
- package/dist/esm/funs/index.js +39 -84
- package/dist/esm/hooks/index.d.ts +2 -0
- package/dist/esm/hooks/index.js +2 -0
- package/dist/esm/hooks/useDB.d.ts +5 -1
- package/dist/esm/hooks/useDB.js +52 -4
- package/dist/esm/hooks/useImage.js +2 -2
- package/dist/esm/hooks/useImageCropper.d.ts +10 -0
- package/dist/esm/hooks/useImageCropper.js +67 -0
- package/dist/esm/hooks/useSlider.d.ts +1 -1
- package/dist/esm/hooks/useUploader.d.ts +46 -0
- package/dist/esm/hooks/useUploader.js +101 -0
- package/dist/esm/hooks/useWebSocket.d.ts +2 -2
- package/dist/esm/hooks/useWebSocket.js +13 -2
- package/dist/esm/types/index.d.ts +3 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -4,7 +4,7 @@ declare const Search: import("react").ForwardRefExoticComponent<import("../..").
|
|
|
4
4
|
numeric?: boolean;
|
|
5
5
|
size?: import("../..").Size;
|
|
6
6
|
variant?: Variant;
|
|
7
|
-
with?: import("../..").FORMVALIDATION
|
|
7
|
+
with?: import("../..").FORMVALIDATION | `${import("../..").FORMVALIDATION}${string}`;
|
|
8
8
|
} & {
|
|
9
9
|
onSubmit?: (value: string) => void;
|
|
10
10
|
onChange?: (value: string) => void;
|
|
@@ -38,5 +38,5 @@ const Search = forwardRef((props, ref) => {
|
|
|
38
38
|
useEffect(() => { }, []);
|
|
39
39
|
return _jsxs(Box, { style: style, className: `--search ${reverse ? `--search-rev` : ``} --${props.variant || Variant.Small} flex aic ${props.as?.includes(`abs`) ? `` : `rel`} ${className}`.trim(), children: [reverse && _jsx(Button, { tabIndex: -1, onClick: e => handleSubmit(), className: `--send flex aic jcc`, variant: props.variant || Variant.Small, children: query !== `` ? SVGIcons.close : SVGIcons.search }), _jsx(Input, { ref: innerRef, onChange: handleChange, className: `--${props.variant || Variant.Small}`, ...pops }), props.shortcut && _jsx(KeyBoardKeys, { keys: props.shortcut, as: `abs` }), !reverse && _jsx(Button, { tabIndex: -1, onClick: e => handleSubmit(), className: `--send flex aic jcc`, variant: props.variant || Variant.Small, children: query !== `` ? SVGIcons.close : SVGIcons.search })] });
|
|
40
40
|
});
|
|
41
|
-
Search.displayName = `Search`;
|
|
41
|
+
Search.displayName = `Zuz.Search`;
|
|
42
42
|
export default Search;
|
|
@@ -9,7 +9,7 @@ import SVGIcons from "../svgicons";
|
|
|
9
9
|
import Text from "../Text";
|
|
10
10
|
import OptionItem from "./optionItem";
|
|
11
11
|
const Select = forwardRef((props, ref) => {
|
|
12
|
-
const { selected, options, label, name, search: withSearch, searchPlaceholder, onChange, ...pops } = props;
|
|
12
|
+
const { selected, options, label, name, variant, search: withSearch, searchPlaceholder, onChange, ...pops } = props;
|
|
13
13
|
const [value, setValue] = useState(selected ?
|
|
14
14
|
typeof selected === `string` ? options.find(fo => fo.value === selected) : selected
|
|
15
15
|
: options[0]);
|
|
@@ -40,7 +40,7 @@ const Select = forwardRef((props, ref) => {
|
|
|
40
40
|
setQuery(null);
|
|
41
41
|
}
|
|
42
42
|
}, [choosing]);
|
|
43
|
-
return _jsxs(Box, { className: `--select ${name ? `--${name}` : ``} rel`.trim(), name: _id, children: [_jsxs(Button, { "data-value": value ? `string` == typeof value ? value : value.value : value || `-1`, className: `--selected flex aic rel ${className}`.trim(), withLabel: false, style: style, onClick: (e) => setChoosing(prev => !prev), ...rest, children: [_jsx(Text, { className: `--label`, children: value ? `string` == typeof value ? value : value.label : label || `Choose` }), _jsx(Box, { className: `--svg-arrow rel flex aic jcc`, children: choosing ? SVGIcons.arrowUp : SVGIcons.arrowDown })] }), _jsxs(Box, { id: _id, className: `--options-list flex cols abs`, style: {
|
|
43
|
+
return _jsxs(Box, { className: `--select ${variant ? `--${variant}` : ``} ${name ? `--${name}` : ``} rel`.trim(), name: _id, children: [_jsxs(Button, { "data-value": value ? `string` == typeof value ? value : value.value : value || `-1`, className: `--selected flex aic rel ${className}`.trim(), withLabel: false, style: style, onClick: (e) => setChoosing(prev => !prev), ...rest, children: [_jsx(Text, { className: `--label`, children: value ? `string` == typeof value ? value : value.label : label || `Choose` }), _jsx(Box, { className: `--svg-arrow rel flex aic jcc`, children: choosing ? SVGIcons.arrowUp : SVGIcons.arrowDown })] }), _jsxs(Box, { id: _id, className: `--options-list flex cols abs`, style: {
|
|
44
44
|
pointerEvents: choosing ? `auto` : `none`,
|
|
45
45
|
}, animate: {
|
|
46
46
|
from: { y: 5, opacity: 0 },
|
|
@@ -58,5 +58,5 @@ const Select = forwardRef((props, ref) => {
|
|
|
58
58
|
}))
|
|
59
59
|
.map((o) => _jsx(OptionItem, { updateValue: updateValue, value: value, o: o }, `option-${(`string` == typeof o ? o : o.label).replace(/\s+/g, `-`)}-${`string` == typeof o ? o : o.value}`))] })] });
|
|
60
60
|
});
|
|
61
|
-
Select.displayName = `Select`;
|
|
61
|
+
Select.displayName = `Zuz.Select`;
|
|
62
62
|
export default Select;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FormEventHandler } from "react";
|
|
2
|
-
import { FORMVALIDATION } from "../../types/enums";
|
|
2
|
+
import { FORMVALIDATION, Variant } from "../../types/enums";
|
|
3
3
|
import { BoxProps } from "../Box";
|
|
4
4
|
/**
|
|
5
5
|
* Represents an option which can be either a string or an OptionObject.
|
|
@@ -21,6 +21,11 @@ export interface OptionItemProps {
|
|
|
21
21
|
* Props for the Select component.
|
|
22
22
|
*/
|
|
23
23
|
export type SelectProps = Omit<BoxProps, "onChange"> & {
|
|
24
|
+
/**
|
|
25
|
+
* Size of the select field.
|
|
26
|
+
* @default "md"
|
|
27
|
+
*/
|
|
28
|
+
variant?: Variant;
|
|
24
29
|
/**
|
|
25
30
|
* Indicates if the select field is required and its validation type.
|
|
26
31
|
*/
|
|
@@ -5,5 +5,5 @@ const Sidebar = forwardRef((props, ref) => {
|
|
|
5
5
|
const { layout, logo } = props;
|
|
6
6
|
return _jsxs(Box, { ref: ref, className: `--sidebar --${layout || `2-columns`} flex cols`, children: [_jsx(Box, { as: `--logo`, children: logo }), _jsx(Box, { as: `--nav flex cols` })] });
|
|
7
7
|
});
|
|
8
|
-
Sidebar.displayName = `Sidebar`;
|
|
8
|
+
Sidebar.displayName = `Zuz.Sidebar`;
|
|
9
9
|
export default Sidebar;
|
|
@@ -78,5 +78,5 @@ const Slider = forwardRef((props, ref) => {
|
|
|
78
78
|
}, [isDragging]);
|
|
79
79
|
return _jsx(Box, { ref: slider, "data-value": value || 0, className: `--slider --${type || SLIDER.Default} flex rel ${className}`.trim(), style: { ...style }, children: SLIDER.Text === type ? _jsx(_Fragment, { children: _jsx(Text, { ref: text, onMouseDown: handleMouseDown, className: `--slider-text`, children: value || 0 }) }) : _jsxs(_Fragment, { children: [_jsx(Box, { ref: track, className: `--slider-track abs fill` }), _jsx(Box, { ref: knob, className: `--slider-knob abs` }), _jsx(Input, { ref: input, onInput: handleInput, className: `abs fill`, tabIndex: 0, type: type || SLIDER.Default, defaultValue: value || 0, step: step, max: max, min: min })] }) });
|
|
80
80
|
});
|
|
81
|
-
Slider.displayName = `Slider`;
|
|
81
|
+
Slider.displayName = `Zuz.Slider`;
|
|
82
82
|
export default Slider;
|
|
@@ -7,5 +7,5 @@ const Span = forwardRef((props, ref) => {
|
|
|
7
7
|
const { style: _style, className, rest } = useBase(pops);
|
|
8
8
|
return _jsx("span", { ref: ref, style: style, className: className, ...rest });
|
|
9
9
|
});
|
|
10
|
-
Span.displayName = `Span`;
|
|
10
|
+
Span.displayName = `Zuz.Span`;
|
|
11
11
|
export default Span;
|
|
@@ -4,6 +4,7 @@ declare const Switch: import("react").ForwardRefExoticComponent<import("../..").
|
|
|
4
4
|
type?: CHECKBOX;
|
|
5
5
|
size?: import("../..").Size;
|
|
6
6
|
variant?: import("../..").Variant;
|
|
7
|
+
checked?: boolean;
|
|
7
8
|
onSwitch?: (checked: boolean, value: string | number | readonly string[]) => void;
|
|
8
9
|
} & import("react").RefAttributes<CheckboxHandler>>;
|
|
9
10
|
export default Switch;
|
|
@@ -46,5 +46,5 @@ const TabView = forwardRef((props, ref) => {
|
|
|
46
46
|
transition: `all ${speed || 0.3}s ease-in-out 0s`, transform: `translate(-${activeTab * size.width}px, 0)`
|
|
47
47
|
}, children: tabs.map((tab, index) => _jsx(TabBody, { index: index, active: index === activeTab, size: size, render: render, content: tab.body }, `tab-body-${tab.key || index}-${tabViewID}`)) }) })] });
|
|
48
48
|
});
|
|
49
|
-
TabView.displayName = `TabView`;
|
|
49
|
+
TabView.displayName = `Zuz.TabView`;
|
|
50
50
|
export default TabView;
|
|
@@ -6,5 +6,5 @@ const TabItem = ({ tab, index, activeTab, onClick }) => {
|
|
|
6
6
|
const { icon, label } = tab;
|
|
7
7
|
return _jsxs(Button, { onClick: e => onClick(index), className: `--tab jcc ${index === activeTab ? '--active' : ''}`.trim(), children: [icon && (typeof icon === 'string' ? _jsx(Icon, { className: `--icon`, name: icon }) : icon), _jsx(Text, { className: `--label rel`, children: label })] });
|
|
8
8
|
};
|
|
9
|
-
TabItem.displayName = `TabItem`;
|
|
9
|
+
TabItem.displayName = `Zuz.TabItem`;
|
|
10
10
|
export default TabItem;
|
|
@@ -7,7 +7,61 @@ import Box from "../Box";
|
|
|
7
7
|
import Pagination from "../Pagination";
|
|
8
8
|
import { PaginationStyle } from "../Pagination/types";
|
|
9
9
|
import TRow from "./row";
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* `Table` is a highly flexible and customizable generic component for rendering data in a tabular format.
|
|
12
|
+
*
|
|
13
|
+
* This component supports features such as:
|
|
14
|
+
* - Dynamic column schema and row data.
|
|
15
|
+
* - Sortable and selectable rows.
|
|
16
|
+
* - Optional pagination with custom control.
|
|
17
|
+
* - Row-level animation and hover states.
|
|
18
|
+
* - Loading placeholders and spinners.
|
|
19
|
+
* - Context menu support for rows.
|
|
20
|
+
*
|
|
21
|
+
* @template T - The shape of the row data object.
|
|
22
|
+
*
|
|
23
|
+
* @param props - The props for configuring the table behavior and appearance.
|
|
24
|
+
* @param props.schema - Column definitions used to render the table header and body.
|
|
25
|
+
* @param props.rows - The array of row data to display.
|
|
26
|
+
* @param props.rowCount - Optional total row count for server-side pagination.
|
|
27
|
+
* @param props.rowsPerPage - Number of rows shown per page.
|
|
28
|
+
* @param props.currentPage - Current page index (for pagination control).
|
|
29
|
+
* @param props.pagination - Whether pagination is enabled.
|
|
30
|
+
* @param props.paginationHash - A value to force pagination re-render.
|
|
31
|
+
* @param props.showPaginationOnZeroPageCount - Show pagination controls even with 0 rows.
|
|
32
|
+
* @param props.animateRows - Whether to animate rows on render/update.
|
|
33
|
+
* @param props.header - Whether to show the header row.
|
|
34
|
+
* @param props.rowClassName - CSS class name to apply to each row.
|
|
35
|
+
* @param props.selectableRows - Whether rows are selectable.
|
|
36
|
+
* @param props.hoverable - Whether rows should show hover styles.
|
|
37
|
+
* @param props.sortBy - Default column key to sort rows.
|
|
38
|
+
* @param props.loading - Enables loading state with placeholder rows and spinner.
|
|
39
|
+
* @param props.loadingRowCount - Number of placeholder rows to render during loading.
|
|
40
|
+
* @param props.loadingMessage - Optional loading text to show next to spinner.
|
|
41
|
+
* @param props.spinner - Spinner type to use when loading.
|
|
42
|
+
* @param props.onSort - Callback when a column header triggers sorting.
|
|
43
|
+
* @param props.onRowSelectToggle - Callback when a row’s selected state changes.
|
|
44
|
+
* @param props.onPageChange - Callback when pagination state changes.
|
|
45
|
+
* @param props.onRowContextMenu - Callback when a row is right-clicked.
|
|
46
|
+
* @param props.className - Additional class names to apply to the root table container.
|
|
47
|
+
* @param props.style - Inline styles to apply to the root table container.
|
|
48
|
+
*
|
|
49
|
+
* @returns The rendered table component.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```tsx
|
|
53
|
+
* <Table
|
|
54
|
+
* schema={[
|
|
55
|
+
* { id: 'name', value: 'Name', sortable: true },
|
|
56
|
+
* { id: 'email', value: 'Email' },
|
|
57
|
+
* ]}
|
|
58
|
+
* rows={[{ name: 'Kamran', email: 'kamran@example.com' }]}
|
|
59
|
+
* selectableRows
|
|
60
|
+
* pagination
|
|
61
|
+
* loading={false}
|
|
62
|
+
* />
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
11
65
|
const Table = (props, ref) => {
|
|
12
66
|
const { schema, rows, rowCount, rowsPerPage, currentPage, pagination, paginationHash, showPaginationOnZeroPageCount, animateRows, header, rowClassName, selectableRows, hoverable, sortBy, loading, loadingRowCount, loadingMessage, spinner, onSort, onRowSelectToggle, onPageChange, onRowContextMenu, ...pops } = props;
|
|
13
67
|
const _pagination = useRef(null);
|
|
@@ -43,6 +97,6 @@ const Table = (props, ref) => {
|
|
|
43
97
|
const _paginated = useMemo(() => _jsx(Pagination, { hash: paginationHash, ref: _pagination, renderOnZeroPageCount: showPaginationOnZeroPageCount, onPageChange: onPageChange, paginationStyle: PaginationStyle.Table, startPage: currentPage, itemCount: rowCount || (rows ? rows.length : 0), itemsPerPage: rowsPerPage || 10 }), []);
|
|
44
98
|
return _jsxs(Box, { as: `--table ${(hoverable ?? true) ? `--hoverable` : ``} flex cols rel ${className}`, ref: _tableRef, children: [_header == true && _jsx(TRow, { sortBy: _sortBy, onSort: handleSort, tableRef: _tableRef, pubsub: pubsub, selectable: selectableRows, index: -1, schema: schema, loading: true, styles: _schemaParsed }), loading && _jsxs(Box, { as: `abs center-x flex aic --table-spinner`, children: [_jsx(Spinner, { type: spinner || SPINNER.Simple }), loadingMessage && _jsx(Text, { as: `--table-loading-message`, children: loadingMessage })] }), loading && Array(loadingRowCount || 5).fill({}).map((row, index) => _jsx(TRow, { tableRef: _tableRef, index: index, pubsub: pubsub, schema: schema, styles: _schemaParsed, loading: true, animate: animateRows }, `--trow-loading-${index}-${schema[0].id}`)), !loading && rows && rows.map((row, index) => _jsx(TRow, { tableRef: _tableRef, pubsub: pubsub, loading: false, index: index, schema: schema, ids: _cols, styles: _schemaParsed, animate: animateRows, data: row, rowClassName: rowClassName, selectable: selectableRows, onSelect: onRowSelectToggle, onContextMenu: onRowContextMenu }, `--trow-${rowKeys.current[index] || index}-${schema[0].id}`)), pagination && _pagination.current != null && _jsx(Box, { as: `--row flex aic --row-footer`, children: _paginated })] });
|
|
45
99
|
};
|
|
46
|
-
Table.displayName = `Table`;
|
|
100
|
+
Table.displayName = `Zuz.Table`;
|
|
47
101
|
const ForwardedTable = forwardRef(Table);
|
|
48
102
|
export default ForwardedTable;
|
|
@@ -83,5 +83,5 @@ const TRow = (props) => {
|
|
|
83
83
|
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}`);
|
|
84
84
|
})] });
|
|
85
85
|
};
|
|
86
|
-
TRow.displayName = `Row`;
|
|
86
|
+
TRow.displayName = `Zuz.Row`;
|
|
87
87
|
export default TRow;
|
|
@@ -10,5 +10,5 @@ const Text = forwardRef((props, ref) => {
|
|
|
10
10
|
const Tag = `h${props.h || 1}`;
|
|
11
11
|
return _jsx(Tag, { ref: ref, style: style, className: className, ...rest, children: html ? _jsx(Span, { dangerouslySetInnerHTML: { __html: html } }) : children });
|
|
12
12
|
});
|
|
13
|
-
Text.displayName = `
|
|
13
|
+
Text.displayName = `Zuz.Text`;
|
|
14
14
|
export default Text;
|
|
@@ -9,5 +9,5 @@ const TextArea = forwardRef((props, ref) => {
|
|
|
9
9
|
};
|
|
10
10
|
return _jsx("textarea", { className: `--input --textarea --${variant || Variant.Small} flex ${className}`.trim(), style: { ...style, resize: resize || `none` }, onInput: handleInput, ref: ref, ...rest });
|
|
11
11
|
});
|
|
12
|
-
TextArea.displayName = `
|
|
12
|
+
TextArea.displayName = `Zuz.TextArea`;
|
|
13
13
|
export default TextArea;
|
|
@@ -17,11 +17,11 @@ const TextWheel = forwardRef((props, ref) => {
|
|
|
17
17
|
this.updateValue(v);
|
|
18
18
|
if (divRef.current) {
|
|
19
19
|
const chars = v.toString().split('');
|
|
20
|
-
divRef.current.querySelectorAll('
|
|
20
|
+
divRef.current.querySelectorAll('.--wheel-char').forEach((charElement, index) => {
|
|
21
21
|
const char = chars[index];
|
|
22
22
|
if (charElement instanceof HTMLElement) {
|
|
23
23
|
charElement.setAttribute('data-value', char);
|
|
24
|
-
const track = charElement.querySelector('
|
|
24
|
+
const track = charElement.querySelector('.--wheel-char-track');
|
|
25
25
|
if (track instanceof HTMLElement) {
|
|
26
26
|
track.style.setProperty('--v', char);
|
|
27
27
|
}
|
|
@@ -50,5 +50,5 @@ const TextWheel = forwardRef((props, ref) => {
|
|
|
50
50
|
background: `linear-gradient(0deg, ${color}, transparent, transparent, transparent, ${color})`,
|
|
51
51
|
} })] });
|
|
52
52
|
});
|
|
53
|
-
TextWheel.displayName = `TextWheel`;
|
|
53
|
+
TextWheel.displayName = `Zuz.TextWheel`;
|
|
54
54
|
export default TextWheel;
|
|
@@ -22,5 +22,5 @@ const TreeView = forwardRef((props, ref) => {
|
|
|
22
22
|
.filter(node => roots.includes(node.tag))
|
|
23
23
|
.map(node => _jsx(TreeItem, { treeTag: treeViewTag ? `-${treeViewTag}` : ``, selected: selected, onSelect: e => handleSelect(e), icons: icons, meta: node, roots: roots, expanded: node.expanded || false, skeleton: rest.skeleton, nodes: nodes }, `--node-${node.tag}`)) });
|
|
24
24
|
});
|
|
25
|
-
TreeView.displayName = `
|
|
25
|
+
TreeView.displayName = `Zuz.TreeView`;
|
|
26
26
|
export default TreeView;
|
|
@@ -27,7 +27,7 @@ const TreeItem = forwardRef((props, ref) => {
|
|
|
27
27
|
: _nodes.length == 0 ? SVGIcons.chevronBottom : isOpen ? SVGIcons.chevronBottom : SVGIcons.chevronRight }), _jsxs(Button, { className: `--node-meta flex aic`, onClick: (e) => onSelect(tag), children: [((icons?.nodeOpen && icons?.nodeClose) || (isRoot && icons?.rootOpen && icons?.rootClose)) &&
|
|
28
28
|
_jsx(Icon, { skeleton: rest.skeleton, className: `--node-icon ${isRoot ? `--icon-root` : ``}`, name: icon || (isOpen ?
|
|
29
29
|
isRoot ? icons?.rootOpen || icons.nodeOpen : icons.nodeOpen
|
|
30
|
-
: isRoot ? icons?.rootClose || icons?.nodeClose : icons?.nodeClose) }), _jsx(Text, { ...{ className: `--node-label` }, skeleton: rest.skeleton, children: label })] })] }), isOpen && _nodes.length > 0 && _jsx(Box, { className: `--sub-node tree-sub-node-${tag} flex cols`, children: _nodes.map(node => _jsx(TreeItem, { treeTag: treeTag, selected: selected, onSelect: onSelect, icons: icons, roots: roots, expanded: node.expanded || false, meta: node, nodes: nodes }, `--node-${node.tag}`)) })] });
|
|
30
|
+
: isRoot ? icons?.rootClose || icons?.nodeClose : icons?.nodeClose) }), _jsx(Text, { ...{ className: `--node-label ${isRoot ? `--node-label-root` : ``}`.trim() }, skeleton: rest.skeleton, children: label })] })] }), isOpen && _nodes.length > 0 && _jsx(Box, { className: `--sub-node tree-sub-node-${tag} flex cols`, children: _nodes.map(node => _jsx(TreeItem, { treeTag: treeTag, selected: selected, onSelect: onSelect, icons: icons, roots: roots, expanded: node.expanded || false, meta: node, nodes: nodes }, `--node-${node.tag}`)) })] });
|
|
31
31
|
});
|
|
32
32
|
TreeItem.displayName = `TreeItem`;
|
|
33
33
|
export default TreeItem;
|
|
@@ -20,6 +20,8 @@ export * from './ContextMenu/types';
|
|
|
20
20
|
export { default as CookiesConsent } from './CookiesConsent';
|
|
21
21
|
export * from './CookiesConsent/types';
|
|
22
22
|
export { default as Cover, type CoverProps } from './Cover';
|
|
23
|
+
export { default as Cropper } from './Cropper';
|
|
24
|
+
export * from './Cropper/types';
|
|
23
25
|
export { default as Crumb } from './Crumb';
|
|
24
26
|
export * from './Crumb/types';
|
|
25
27
|
export { default as Drawer } from './Drawer';
|
package/dist/cjs/comps/index.js
CHANGED
|
@@ -20,6 +20,8 @@ export * from './ContextMenu/types';
|
|
|
20
20
|
export { default as CookiesConsent } from './CookiesConsent';
|
|
21
21
|
export * from './CookiesConsent/types';
|
|
22
22
|
export { default as Cover } from './Cover';
|
|
23
|
+
export { default as Cropper } from './Cropper';
|
|
24
|
+
export * from './Cropper/types';
|
|
23
25
|
export { default as Crumb } from './Crumb';
|
|
24
26
|
export * from './Crumb/types';
|
|
25
27
|
export { default as Drawer } from './Drawer';
|
|
@@ -1,17 +1,41 @@
|
|
|
1
|
+
export interface EventListener {
|
|
2
|
+
fun: (...args: any[]) => void;
|
|
3
|
+
context?: any;
|
|
4
|
+
id: symbol;
|
|
5
|
+
}
|
|
1
6
|
export interface Event {
|
|
2
7
|
event: String | Symbol;
|
|
3
|
-
listeners: Array<
|
|
4
|
-
fun: (...args: any[]) => void;
|
|
5
|
-
context?: any;
|
|
6
|
-
}>;
|
|
8
|
+
listeners: Array<EventListener>;
|
|
7
9
|
}
|
|
8
10
|
declare class Events {
|
|
9
11
|
_events: Event[];
|
|
10
12
|
constructor();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Registers an event listener.
|
|
15
|
+
* @param event The name of the event.
|
|
16
|
+
* @param fun The callback function.
|
|
17
|
+
* @param context Optional context (this) for the callback.
|
|
18
|
+
* @returns A function to unsubscribe this specific listener.
|
|
19
|
+
*/
|
|
20
|
+
on(event: String | Symbol, fun: (...args: any[]) => void, context?: any): () => void;
|
|
21
|
+
/**
|
|
22
|
+
* Removes event listeners matching a specific event and function.
|
|
23
|
+
* Note: This removes *all* listeners for the event that use the exact same function reference.
|
|
24
|
+
* It's often more reliable to use the unsubscribe function returned by 'on'.
|
|
25
|
+
* @param event The name of the event.
|
|
26
|
+
* @param fun The callback function to remove.
|
|
27
|
+
*/
|
|
14
28
|
off(event: String | Symbol, fun: (...args: any[]) => void): void;
|
|
29
|
+
/**
|
|
30
|
+
* Emits an event, calling all registered listeners.
|
|
31
|
+
* @param event The name of the event.
|
|
32
|
+
* @param args Arguments to pass to the listeners.
|
|
33
|
+
*/
|
|
15
34
|
emit(event: String | Symbol, ...args: any[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* Removes all listeners for a specific event.
|
|
37
|
+
* @param event The name of the event.
|
|
38
|
+
*/
|
|
39
|
+
removeAllListeners(event: String | Symbol): void;
|
|
16
40
|
}
|
|
17
41
|
export default Events;
|
package/dist/cjs/funs/events.js
CHANGED
|
@@ -3,42 +3,80 @@ class Events {
|
|
|
3
3
|
constructor() {
|
|
4
4
|
this._events = [];
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Registers an event listener.
|
|
8
|
+
* @param event The name of the event.
|
|
9
|
+
* @param fun The callback function.
|
|
10
|
+
* @param context Optional context (this) for the callback.
|
|
11
|
+
* @returns A function to unsubscribe this specific listener.
|
|
12
|
+
*/
|
|
13
|
+
on(event, fun, context) {
|
|
14
|
+
const evt = this._events.find(x => x.event === event);
|
|
15
|
+
const id = Symbol('listener_id'); // Give each listener a unique ID
|
|
16
|
+
const listener = {
|
|
17
|
+
fun: fun, // Store original function
|
|
18
|
+
context: context,
|
|
19
|
+
id: id,
|
|
20
|
+
};
|
|
9
21
|
if (!evt) {
|
|
10
|
-
|
|
22
|
+
this._events.push({ event: event, listeners: [listener] });
|
|
11
23
|
}
|
|
12
|
-
|
|
24
|
+
else {
|
|
13
25
|
evt.listeners.push(listener);
|
|
14
26
|
}
|
|
27
|
+
// Return an unsubscribe function
|
|
28
|
+
return () => {
|
|
29
|
+
const currentEvt = this._events.find(x => x.event === event);
|
|
30
|
+
if (currentEvt) {
|
|
31
|
+
currentEvt.listeners = currentEvt.listeners.filter(l => l.id !== id);
|
|
32
|
+
if (currentEvt.listeners.length === 0) {
|
|
33
|
+
this._events = this._events.filter(e => e.event !== event);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
15
37
|
}
|
|
16
|
-
|
|
17
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Removes event listeners matching a specific event and function.
|
|
40
|
+
* Note: This removes *all* listeners for the event that use the exact same function reference.
|
|
41
|
+
* It's often more reliable to use the unsubscribe function returned by 'on'.
|
|
42
|
+
* @param event The name of the event.
|
|
43
|
+
* @param fun The callback function to remove.
|
|
44
|
+
*/
|
|
45
|
+
off(event, fun) {
|
|
46
|
+
const evt = this._events.find(x => x.event === event);
|
|
18
47
|
if (evt) {
|
|
19
|
-
|
|
48
|
+
// Filter out listeners where the 'fun' property matches the provided function.
|
|
49
|
+
evt.listeners = evt.listeners.filter(listener => listener.fun !== fun);
|
|
50
|
+
// Optional: If no listeners remain for this event, remove the event entry.
|
|
51
|
+
if (evt.listeners.length === 0) {
|
|
52
|
+
this._events = this._events.filter(e => e.event !== event);
|
|
53
|
+
}
|
|
20
54
|
}
|
|
21
55
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
56
|
+
/**
|
|
57
|
+
* Emits an event, calling all registered listeners.
|
|
58
|
+
* @param event The name of the event.
|
|
59
|
+
* @param args Arguments to pass to the listeners.
|
|
60
|
+
*/
|
|
28
61
|
emit(event, ...args) {
|
|
29
|
-
const evt = this._events.find(x => x.event
|
|
62
|
+
const evt = this._events.find(x => x.event === event);
|
|
30
63
|
if (evt) {
|
|
31
|
-
|
|
32
|
-
evt.listeners.forEach(({ fun, context }) => {
|
|
64
|
+
[...evt.listeners].forEach(({ fun, context }) => {
|
|
33
65
|
try {
|
|
34
|
-
// f(args)
|
|
35
66
|
fun.apply(context, args);
|
|
36
67
|
}
|
|
37
68
|
catch (e) {
|
|
38
|
-
console.error(e);
|
|
69
|
+
console.error(`Error during event '${String(event)}' emission:`, e);
|
|
39
70
|
}
|
|
40
71
|
});
|
|
41
72
|
}
|
|
42
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Removes all listeners for a specific event.
|
|
76
|
+
* @param event The name of the event.
|
|
77
|
+
*/
|
|
78
|
+
removeAllListeners(event) {
|
|
79
|
+
this._events = this._events.filter(e => e.event !== event);
|
|
80
|
+
}
|
|
43
81
|
}
|
|
44
82
|
export default Events;
|
package/dist/cjs/funs/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AxiosProgressEvent } from "axios";
|
|
2
1
|
import { ReactElement, ReactNode, Ref } from "react";
|
|
3
2
|
import { KeyCode } from "../types/enums.js";
|
|
4
3
|
import { dynamicObject, FormatNumberParams, sortOptions } from "../types/index.js";
|
|
@@ -49,8 +48,6 @@ export declare const cleanProps: <T extends dynamicObject>(props: T, withProps?:
|
|
|
49
48
|
export declare const withZuz: (cx: string | string[]) => string;
|
|
50
49
|
export declare const setDeep: (object: dynamicObject, path: string, value: any, seperator?: string) => dynamicObject;
|
|
51
50
|
export declare const removeDuplicatesFromArray: <T>(array: T[]) => T[];
|
|
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, ignoreKind?: boolean) => Promise<T>;
|
|
54
51
|
export declare const withTime: (fun: (...args: any[]) => any) => {
|
|
55
52
|
result: any;
|
|
56
53
|
executionTime: number;
|
|
@@ -75,3 +72,8 @@ export declare const clamp: (value: number, min: number, max: number) => number;
|
|
|
75
72
|
export declare function mergeRefs<T>(...refs: (Ref<T> | undefined)[]): Ref<T>;
|
|
76
73
|
export declare const slugify: (text: string, separator?: string) => string;
|
|
77
74
|
export declare const truncate: (selector: string, lines?: number) => void;
|
|
75
|
+
export declare const checkPasswordStrength: (password: string) => {
|
|
76
|
+
score: number;
|
|
77
|
+
result: string;
|
|
78
|
+
suggestion: string[];
|
|
79
|
+
};
|