@zuzjs/ui 0.5.6 → 0.5.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/comps/Accordion/index.d.ts +6 -0
- package/dist/comps/Accordion/index.js +12 -0
- package/dist/comps/Accordion/types.d.ts +10 -0
- package/dist/comps/Actionbar/index.d.ts +21 -0
- package/dist/comps/Actionbar/index.js +58 -0
- package/dist/comps/Actionbar/item.d.ts +6 -0
- package/dist/comps/Actionbar/item.js +7 -0
- package/dist/comps/Actionbar/types.d.ts +29 -0
- package/dist/comps/Actionbar/types.js +1 -0
- package/dist/comps/Avatar/index.d.ts +19 -0
- package/dist/comps/Avatar/index.js +35 -0
- package/dist/comps/Box/index.d.ts +7 -0
- package/dist/comps/{box.js → Box/index.js} +3 -2
- package/dist/comps/Button/index.d.ts +10 -0
- package/dist/comps/Button/index.js +12 -0
- package/dist/comps/CheckBox/index.d.ts +7 -0
- package/dist/comps/{checkbox.js → CheckBox/index.js} +10 -9
- package/dist/comps/CheckBox/types.d.ts +10 -0
- package/dist/comps/CheckBox/types.js +1 -0
- package/dist/comps/ContextMenu/index.d.ts +6 -0
- package/dist/comps/ContextMenu/index.js +37 -0
- package/dist/comps/ContextMenu/item.d.ts +3 -0
- package/dist/comps/ContextMenu/item.js +11 -0
- package/dist/comps/ContextMenu/types.d.ts +20 -0
- package/dist/comps/ContextMenu/types.js +1 -0
- package/dist/comps/Cover/index.d.ts +17 -0
- package/dist/comps/Cover/index.js +19 -0
- package/dist/comps/Drawer/index.d.ts +12 -0
- package/dist/comps/{drawer.js → Drawer/index.js} +8 -10
- package/dist/comps/{drawer.d.ts → Drawer/types.d.ts} +4 -5
- package/dist/comps/Drawer/types.js +1 -0
- package/dist/comps/{form.d.ts → Form/index.d.ts} +34 -10
- package/dist/comps/{form.js → Form/index.js} +11 -15
- package/dist/comps/Icon/index.d.ts +11 -0
- package/dist/comps/Icon/index.js +11 -0
- package/dist/comps/Image/index.d.ts +4 -0
- package/dist/comps/Image/index.js +9 -0
- package/dist/comps/Input/index.d.ts +8 -0
- package/dist/comps/Input/index.js +15 -0
- package/dist/comps/Label/index.d.ts +4 -0
- package/dist/comps/Label/index.js +9 -0
- package/dist/comps/Otp/index.d.ts +4 -0
- package/dist/comps/Otp/index.js +30 -0
- package/dist/comps/Overlay/index.d.ts +8 -0
- package/dist/comps/Overlay/index.js +12 -0
- package/dist/comps/Password/index.d.ts +4 -0
- package/dist/comps/Password/index.js +18 -0
- package/dist/comps/PinInput/index.d.ts +12 -0
- package/dist/comps/{otp → PinInput}/index.js +10 -18
- package/dist/comps/ProgressBar/index.d.ts +7 -0
- package/dist/comps/ProgressBar/index.js +21 -0
- package/dist/comps/ProgressBar/types.d.ts +9 -0
- package/dist/comps/ProgressBar/types.js +1 -0
- package/dist/comps/Search/index.d.ts +14 -0
- package/dist/comps/{search → Search}/index.js +9 -19
- package/dist/comps/Segmented/index.d.ts +26 -0
- package/dist/comps/{segmented → Segmented}/index.js +3 -9
- package/dist/comps/Segmented/item.d.ts +3 -0
- package/dist/comps/{segmented → Segmented}/item.js +3 -9
- package/dist/comps/Segmented/types.d.ts +31 -0
- package/dist/comps/Segmented/types.js +1 -0
- package/dist/comps/Select/index.d.ts +13 -0
- package/dist/comps/Select/index.js +56 -0
- package/dist/comps/Select/option.d.ts +2 -0
- package/dist/comps/Select/option.js +8 -0
- package/dist/comps/Select/optionItem.d.ts +3 -0
- package/dist/comps/Select/optionItem.js +6 -0
- package/dist/comps/Select/types.d.ts +52 -0
- package/dist/comps/Select/types.js +1 -0
- package/dist/comps/{sheet.d.ts → Sheet/index.d.ts} +16 -5
- package/dist/comps/Sheet/index.js +175 -0
- package/dist/comps/Span/index.d.ts +4 -0
- package/dist/comps/Span/index.js +10 -0
- package/dist/comps/Spinner/index.d.ts +21 -0
- package/dist/comps/Spinner/index.js +31 -0
- package/dist/comps/Switch/index.d.ts +7 -0
- package/dist/comps/Switch/index.js +8 -0
- package/dist/comps/TabView/index.d.ts +9 -0
- package/dist/comps/TabView/index.js +41 -0
- package/dist/comps/TabView/tab.d.ts +3 -0
- package/dist/comps/TabView/tab.js +9 -0
- package/dist/comps/{tabview.d.ts → TabView/types.d.ts} +10 -5
- package/dist/comps/TabView/types.js +1 -0
- package/dist/comps/Text/index.d.ts +11 -0
- package/dist/comps/Text/index.js +17 -0
- package/dist/comps/TextWheel/index.d.ts +8 -0
- package/dist/comps/{textwheel.js → TextWheel/index.js} +9 -9
- package/dist/comps/TextWheel/types.d.ts +10 -0
- package/dist/comps/TextWheel/types.js +1 -0
- package/dist/comps/Treeview/index.d.ts +11 -0
- package/dist/comps/{treeview → Treeview}/index.js +3 -3
- package/dist/comps/Treeview/item.d.ts +11 -0
- package/dist/comps/Treeview/item.js +26 -0
- package/dist/comps/{treeview/index.d.ts → Treeview/types.d.ts} +14 -5
- package/dist/comps/Treeview/types.js +1 -0
- package/dist/comps/index.d.ts +41 -0
- package/dist/comps/index.js +41 -0
- package/dist/comps/svgicons.d.ts +9 -2
- package/dist/comps/svgicons.js +8 -5
- package/dist/funs/index.d.ts +17 -17
- package/dist/funs/index.js +69 -69
- package/dist/hooks/index.d.ts +4 -3
- package/dist/hooks/index.js +6 -3
- package/dist/hooks/useBase.d.ts +8 -0
- package/dist/{comps/useBase/index.js → hooks/useBase.js} +23 -6
- package/dist/hooks/useContextMenu.d.ts +7 -0
- package/dist/hooks/useContextMenu.js +21 -0
- package/dist/hooks/useDrag.d.ts +10 -0
- package/dist/hooks/useDrag.js +45 -0
- package/dist/index.d.ts +5 -31
- package/dist/index.js +5 -32
- package/dist/styles.css +1 -1
- package/dist/types/index.d.ts +36 -20
- package/dist/types/interfaces.d.ts +45 -51
- package/package.json +3 -4
- package/dist/comps/accordion.d.ts +0 -12
- package/dist/comps/accordion.js +0 -10
- package/dist/comps/alert.d.ts +0 -15
- package/dist/comps/alert.js +0 -15
- package/dist/comps/animate.d.ts +0 -6
- package/dist/comps/animate.js +0 -8
- package/dist/comps/avatar.d.ts +0 -13
- package/dist/comps/avatar.js +0 -11
- package/dist/comps/base.d.ts +0 -15
- package/dist/comps/base.js +0 -68
- package/dist/comps/box.d.ts +0 -6
- package/dist/comps/button.d.ts +0 -7
- package/dist/comps/button.js +0 -19
- package/dist/comps/checkbox.d.ts +0 -18
- package/dist/comps/contextmenu.d.ts +0 -15
- package/dist/comps/contextmenu.js +0 -9
- package/dist/comps/cover.d.ts +0 -15
- package/dist/comps/cover.js +0 -31
- package/dist/comps/editor.d.ts +0 -12
- package/dist/comps/editor.js +0 -92
- package/dist/comps/grid/index.d.ts +0 -10
- package/dist/comps/grid/index.js +0 -16
- package/dist/comps/heading.d.ts +0 -8
- package/dist/comps/heading.js +0 -16
- package/dist/comps/icon.d.ts +0 -7
- package/dist/comps/icon.js +0 -23
- package/dist/comps/image.d.ts +0 -13
- package/dist/comps/image.js +0 -8
- package/dist/comps/input.d.ts +0 -6
- package/dist/comps/input.js +0 -19
- package/dist/comps/otp/index.d.ts +0 -6
- package/dist/comps/password.d.ts +0 -3
- package/dist/comps/password.js +0 -30
- package/dist/comps/progressbar.d.ts +0 -11
- package/dist/comps/progressbar.js +0 -14
- package/dist/comps/search/index.d.ts +0 -7
- package/dist/comps/segmented/index.d.ts +0 -46
- package/dist/comps/segmented/item.d.ts +0 -8
- package/dist/comps/select/index.d.ts +0 -15
- package/dist/comps/select/index.js +0 -79
- package/dist/comps/sheet.js +0 -229
- package/dist/comps/span.d.ts +0 -6
- package/dist/comps/span.js +0 -12
- package/dist/comps/spinner.d.ts +0 -16
- package/dist/comps/spinner.js +0 -42
- package/dist/comps/tabview.js +0 -64
- package/dist/comps/textwheel.d.ts +0 -15
- package/dist/comps/treeview/item.d.ts +0 -15
- package/dist/comps/treeview/item.js +0 -23
- package/dist/comps/useBase/base.types.d.ts +0 -80
- package/dist/comps/useBase/index.d.ts +0 -10
- package/dist/funs/lexer.d.ts +0 -3
- package/dist/funs/lexer.js +0 -37
- package/dist/hooks/useCompEditor.d.ts +0 -2
- package/dist/hooks/useCompEditor.js +0 -5
- package/dist/hooks/useInteractionObserver.d.ts +0 -8
- package/dist/hooks/useInteractionObserver.js +0 -21
- package/dist/hooks/usePubSub.d.ts +0 -3
- package/dist/hooks/usePubSub.js +0 -19
- package/dist/hooks/useSub.d.ts +0 -3
- package/dist/hooks/useSub.js +0 -17
- package/dist/hooks/useToast.d.ts +0 -2
- package/dist/hooks/useToast.js +0 -10
- package/dist/hooks/useWindowFocus.d.ts +0 -2
- package/dist/hooks/useWindowFocus.js +0 -11
- package/dist/media/edit-ui.d.ts +0 -2
- package/dist/media/edit-ui.js +0 -2
- package/dist/mixins.css +0 -1
- /package/dist/comps/{dialog.d.ts → Accordion/item.d.ts} +0 -0
- /package/dist/comps/{dialog.js → Accordion/item.js} +0 -0
- /package/dist/comps/{useBase/base.types.js → Accordion/types.js} +0 -0
- /package/dist/comps/{select/select.d.ts → TabView/head.d.ts} +0 -0
- /package/dist/comps/{select/select.js → TabView/head.js} +0 -0
- /package/dist/{hooks/usePub.d.ts → comps/TabView/item.d.ts} +0 -0
- /package/dist/{hooks/usePub.js → comps/TabView/item.js} +0 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AccordionHandler } from "./types";
|
|
2
|
+
declare const Accordion: import("react").ForwardRefExoticComponent<import("../Box").BoxProps & {
|
|
3
|
+
message?: string;
|
|
4
|
+
title: string | import("react").ReactNode | import("react").ReactNode[];
|
|
5
|
+
} & import("react").RefAttributes<AccordionHandler>>;
|
|
6
|
+
export default Accordion;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState } from "react";
|
|
3
|
+
import Box from "../Box";
|
|
4
|
+
import Text from "../Text";
|
|
5
|
+
import SVGIcons from "../svgicons";
|
|
6
|
+
import Button from "../Button";
|
|
7
|
+
const Accordion = forwardRef((props, ref) => {
|
|
8
|
+
const { title, message, ...rest } = props;
|
|
9
|
+
const [visible, setVisible] = useState(false);
|
|
10
|
+
return _jsxs(Box, { className: `--accordion flex cols`, ...rest, children: [_jsxs(Button, { onClick: (e) => setVisible(!visible), className: `--toggle flex aic ${visible ? `--open` : ``}`.trim(), children: [_jsx(Text, { className: `--label flex`, children: title }), _jsx(Box, { className: `--arrow flex`, children: visible ? SVGIcons.arrowUp : SVGIcons.arrowDown })] }), visible && _jsx(Box, { className: `--detail`, children: message })] });
|
|
11
|
+
});
|
|
12
|
+
export default Accordion;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { BoxProps } from "../Box";
|
|
3
|
+
export type AccordionProps = BoxProps & {
|
|
4
|
+
message?: string;
|
|
5
|
+
title: string | ReactNode | ReactNode[];
|
|
6
|
+
};
|
|
7
|
+
export interface AccordionHandler {
|
|
8
|
+
open: () => void;
|
|
9
|
+
close: () => void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BoxProps } from "../Box";
|
|
2
|
+
import { ActionBarHandler } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* ActionBar renders a list of buttons with tooltips.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* const items = [
|
|
9
|
+
* { label: 'Edit', icon: <EditIcon />, onClick: () => console.log('Edit clicked') },
|
|
10
|
+
* { label: 'Delete', icon: <DeleteIcon />, onClick: () => console.log('Delete clicked') }
|
|
11
|
+
* ];
|
|
12
|
+
*
|
|
13
|
+
* <ActionBar items={items} />
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
declare const ActionBar: import("react").ForwardRefExoticComponent<BoxProps & {
|
|
17
|
+
selected?: number | string;
|
|
18
|
+
onSwitch?: (tag: string) => void;
|
|
19
|
+
items: import("./types").ActionBarItem[];
|
|
20
|
+
} & import("react").RefAttributes<ActionBarHandler>>;
|
|
21
|
+
export default ActionBar;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
+
import Box from "../Box";
|
|
5
|
+
import { useBase } from "../../hooks";
|
|
6
|
+
import ActionItem from "./item";
|
|
7
|
+
/**
|
|
8
|
+
* ActionBar renders a list of buttons with tooltips.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const items = [
|
|
13
|
+
* { label: 'Edit', icon: <EditIcon />, onClick: () => console.log('Edit clicked') },
|
|
14
|
+
* { label: 'Delete', icon: <DeleteIcon />, onClick: () => console.log('Delete clicked') }
|
|
15
|
+
* ];
|
|
16
|
+
*
|
|
17
|
+
* <ActionBar items={items} />
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
const ActionBar = forwardRef((props, ref) => {
|
|
21
|
+
const { items, name, selected, ...pops } = props;
|
|
22
|
+
const self = useRef(null);
|
|
23
|
+
const [_selected, setSelected] = useState(selected || items[0].tag || 0);
|
|
24
|
+
const track = useCallback(({ x, y }) => {
|
|
25
|
+
if (self.current) {
|
|
26
|
+
const bounds = self.current.getBoundingClientRect();
|
|
27
|
+
document.documentElement.style.setProperty(`--tip-x`, `${x - bounds.left}`);
|
|
28
|
+
document.documentElement.style.setProperty(`--tip-y`, `${y - bounds.top}`);
|
|
29
|
+
document.documentElement.style.setProperty(`--tip-s`, `1`);
|
|
30
|
+
}
|
|
31
|
+
}, []);
|
|
32
|
+
const tear = useCallback(() => {
|
|
33
|
+
if (self.current) {
|
|
34
|
+
self.current.removeEventListener(`pointerleave`, tear);
|
|
35
|
+
self.current.removeEventListener(`pointermove`, track);
|
|
36
|
+
document.documentElement.style.setProperty(`--tip-s`, `0`);
|
|
37
|
+
}
|
|
38
|
+
}, []);
|
|
39
|
+
const initTrack = useCallback(() => {
|
|
40
|
+
if (self.current) {
|
|
41
|
+
self.current.addEventListener(`pointerleave`, tear);
|
|
42
|
+
self.current.addEventListener(`pointermove`, track);
|
|
43
|
+
}
|
|
44
|
+
}, []);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (self.current) {
|
|
47
|
+
document.documentElement.style.setProperty(`--tip-w`, items.reduce((longest, item) => {
|
|
48
|
+
return item.label.length > longest.length ? item.label : longest;
|
|
49
|
+
}, '').length.toString());
|
|
50
|
+
document.documentElement.style.setProperty(`--tip-s`, `0`);
|
|
51
|
+
document.documentElement.style.setProperty(`--tip-l`, `${items.length}`);
|
|
52
|
+
self.current?.addEventListener(`pointerenter`, initTrack);
|
|
53
|
+
}
|
|
54
|
+
}, []);
|
|
55
|
+
const { className, style, rest } = useBase(pops);
|
|
56
|
+
return _jsxs(Box, { ref: self, style: style, className: `--actionbar rel flex aic ${className}`.trim(), ...rest, children: [items.map((item, index) => _jsx(ActionItem, { selected: _selected === item.tag || selected == index, ...item, idx: index }, `actionbar-action-${item.label.toLowerCase().replace(/\s+/g, `-`)}`)), _jsx(Box, { className: `--tip abs`, children: _jsx(Box, { className: `--track flex aic`, children: items.map(({ label }) => _jsx(Box, { className: `--lb`, children: label }, `tool-tip-${label.toLowerCase().replace(/\s+/g, `-`)}`)) }) })] });
|
|
57
|
+
});
|
|
58
|
+
export default ActionBar;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Button from '../Button';
|
|
3
|
+
import Icon from '../Icon';
|
|
4
|
+
const ActionItem = ({ label, icon, onClick, idx, selected }) => {
|
|
5
|
+
return _jsx(Button, { onClick: onClick, onMouseMove: e => document.documentElement.style.setProperty(`--tip-m`, `${idx}`), className: `--action ${selected ? `--selected` : ``} aic jcc rel`.trim(), children: typeof icon == `string` ? _jsx(Icon, { name: icon }) : icon });
|
|
6
|
+
};
|
|
7
|
+
export default ActionItem;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { BoxProps } from "../Box";
|
|
3
|
+
export interface ActionBarHandler {
|
|
4
|
+
show: () => void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Represents an item in the ActionBar.
|
|
8
|
+
*/
|
|
9
|
+
export interface ActionBarItem {
|
|
10
|
+
/** Specific tag for action item */
|
|
11
|
+
tag?: string;
|
|
12
|
+
/** The label of the action item */
|
|
13
|
+
label: string;
|
|
14
|
+
/** The icon to display for the action item */
|
|
15
|
+
icon: ReactNode;
|
|
16
|
+
/** The callback function to execute when the action item is clicked */
|
|
17
|
+
onClick: () => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Props for the ActionBar component.
|
|
21
|
+
*/
|
|
22
|
+
export type ActionBarProps = BoxProps & {
|
|
23
|
+
/** The index of the initially selected action item */
|
|
24
|
+
selected?: number | string;
|
|
25
|
+
/** Callback function to execute when an action item is clicked */
|
|
26
|
+
onSwitch?: (tag: string) => void;
|
|
27
|
+
/** Array of action items to display in the ActionBar */
|
|
28
|
+
items: ActionBarItem[];
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AVATAR } from "../../types/enums";
|
|
2
|
+
import { Props } from "../../types";
|
|
3
|
+
export type AvatarProps = Props<"img"> & {
|
|
4
|
+
type?: AVATAR;
|
|
5
|
+
size?: number;
|
|
6
|
+
src: string;
|
|
7
|
+
crossOrigin?: 'anonymous' | 'use-credentials';
|
|
8
|
+
referrerPolicy?: 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
|
|
9
|
+
};
|
|
10
|
+
export interface AvatarHandler {
|
|
11
|
+
}
|
|
12
|
+
declare const Avatar: import("react").ForwardRefExoticComponent<import("../../types").ZuzProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "ref">, keyof import("../../types").ZuzProps> & {
|
|
13
|
+
type?: AVATAR;
|
|
14
|
+
size?: number;
|
|
15
|
+
src: string;
|
|
16
|
+
crossOrigin?: "anonymous" | "use-credentials";
|
|
17
|
+
referrerPolicy?: "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
|
|
18
|
+
} & import("react").RefAttributes<AvatarHandler>>;
|
|
19
|
+
export default Avatar;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect } from "react";
|
|
3
|
+
import { AVATAR } from "../../types/enums";
|
|
4
|
+
import { useBase, useImage } from "../../hooks";
|
|
5
|
+
import Image from "../Image";
|
|
6
|
+
import Box from "../Box";
|
|
7
|
+
const Avatar = forwardRef((props, ref) => {
|
|
8
|
+
const { src, size, type, crossOrigin, referrerPolicy, animate, as, ...pops } = props;
|
|
9
|
+
const [img, imgStatus, imgError] = useImage(src, crossOrigin, referrerPolicy);
|
|
10
|
+
const { className, style, rest } = useBase({ animate, as });
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (type == AVATAR.Square && !document.getElementById('squareRadiusClipPath')) {
|
|
13
|
+
const svgNS = "http://www.w3.org/2000/svg";
|
|
14
|
+
const svg = document.createElementNS(svgNS, "svg");
|
|
15
|
+
svg.setAttribute("width", "0");
|
|
16
|
+
svg.setAttribute("height", "0");
|
|
17
|
+
const defs = document.createElementNS(svgNS, "defs");
|
|
18
|
+
const clipPath = document.createElementNS(svgNS, "clipPath");
|
|
19
|
+
clipPath.setAttribute("id", "squareRadiusClipPath");
|
|
20
|
+
clipPath.setAttribute("clipPathUnits", "objectBoundingBox");
|
|
21
|
+
const path = document.createElementNS(svgNS, "path");
|
|
22
|
+
path.setAttribute("d", "M0.986 0.347C0.951 0.11 0.777 -0.002 0.5 0C0.223 -0.002 0.049 0.11 0.014 0.347C0.005 0.404 0 0.452 0 0.5C0 0.548 0.005 0.596 0.014 0.653C0.049 0.89 0.223 1.002 0.5 1C0.777 1.002 0.951 0.89 0.986 0.653C0.995 0.596 1 0.548 1 0.5C1 0.452 0.995 0.404 0.986 0.347Z");
|
|
23
|
+
clipPath.appendChild(path);
|
|
24
|
+
defs.appendChild(clipPath);
|
|
25
|
+
svg.appendChild(defs);
|
|
26
|
+
document.body.appendChild(svg);
|
|
27
|
+
}
|
|
28
|
+
}, []);
|
|
29
|
+
return _jsx(Box, { className: `--avatar --${(type || AVATAR.Circle).toLowerCase()} rel ${className}`.trim(), style: {
|
|
30
|
+
width: size || `auto`,
|
|
31
|
+
height: `auto`,
|
|
32
|
+
...style,
|
|
33
|
+
}, ...rest, children: _jsx(Image, { src: img, crossOrigin: crossOrigin, referrerPolicy: referrerPolicy, ...pops }) });
|
|
34
|
+
});
|
|
35
|
+
export default Avatar;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Props } from "../../types";
|
|
3
|
+
export interface BoxProps extends Partial<Props<`div`>> {
|
|
4
|
+
name?: string;
|
|
5
|
+
}
|
|
6
|
+
declare const Box: React.ForwardRefExoticComponent<BoxProps & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
export default Box;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
3
|
import { forwardRef } from "react";
|
|
3
|
-
import useBase from "
|
|
4
|
+
import { useBase } from "../../hooks";
|
|
4
5
|
const Box = forwardRef((props, ref) => {
|
|
5
6
|
const { style, ...pops } = props;
|
|
6
|
-
const {
|
|
7
|
+
const { style: _style, className, rest } = useBase(pops);
|
|
7
8
|
return _jsx("div", { ref: ref, className: className, style: {
|
|
8
9
|
..._style,
|
|
9
10
|
...(style || {})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Props } from '../../types';
|
|
2
|
+
export type ButtonProps = Props<`button`> & {
|
|
3
|
+
icon?: string;
|
|
4
|
+
withLabel?: boolean;
|
|
5
|
+
};
|
|
6
|
+
declare const Button: import("react").ForwardRefExoticComponent<import("../../types").ZuzProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, keyof import("../../types").ZuzProps> & {
|
|
7
|
+
icon?: string;
|
|
8
|
+
withLabel?: boolean;
|
|
9
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
10
|
+
export default Button;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { useBase } from '../../hooks';
|
|
5
|
+
import Icon from '../Icon';
|
|
6
|
+
import Span from '../Span';
|
|
7
|
+
const Button = forwardRef((props, ref) => {
|
|
8
|
+
const { icon, children, withLabel, ...pops } = props;
|
|
9
|
+
const { style, className, rest } = useBase(pops);
|
|
10
|
+
return _jsxs("button", { className: `${className} flex aic ${icon ? `ico-btn` : ``}`, style: style, ref: ref, ...rest, children: [icon && _jsx(Icon, { name: `icon-${icon}` }), withLabel === true ? _jsx(Span, { children: children }) : children] });
|
|
11
|
+
});
|
|
12
|
+
export default Button;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CHECKBOX } from "../../types/enums";
|
|
2
|
+
import { CheckboxHandler } from "./types";
|
|
3
|
+
declare const CheckBox: import("react").ForwardRefExoticComponent<import("../..").ZuzProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, keyof import("../..").ZuzProps> & {
|
|
4
|
+
type?: CHECKBOX;
|
|
5
|
+
onChange?: (checked: boolean, value: string | number | readonly string[]) => void;
|
|
6
|
+
} & import("react").RefAttributes<CheckboxHandler>>;
|
|
7
|
+
export default CheckBox;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef, useImperativeHandle, useRef, useState } from "react";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
4
|
+
import { CHECKBOX } from "../../types/enums";
|
|
5
|
+
import Label from "../Label";
|
|
6
|
+
import Input from "../Input";
|
|
7
|
+
import SVGIcons from "../svgicons";
|
|
7
8
|
const CheckBox = forwardRef((props, ref) => {
|
|
8
|
-
const {
|
|
9
|
+
const { name, required, type, value, checked: defaultCheck, onChange, ...pops } = props;
|
|
9
10
|
const [checked, _setChecked] = useState(defaultCheck || false);
|
|
10
11
|
const bRef = useRef(null);
|
|
11
12
|
useImperativeHandle(ref, () => ({
|
|
@@ -25,10 +26,10 @@ const CheckBox = forwardRef((props, ref) => {
|
|
|
25
26
|
_setChecked(!checked);
|
|
26
27
|
}
|
|
27
28
|
}));
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
return _jsxs(Label, { className: `--${(type || CHECKBOX.Default).toLowerCase()} ${!type || type == CHECKBOX.Default ? `--checkbox` : `--switch`} flex aic jcc ${checked ? `is-checked` : ``} rel`.trim(), ...pops, children: [(!type || type == CHECKBOX.Default) && SVGIcons.check, _jsx(Input, { ...{}, ref: bRef, defaultChecked: checked, value: value || `cb`, type: `checkbox`, className: `abs`, name: name, required: required || false, onChange: (e) => {
|
|
30
|
+
onChange && onChange(e.target.checked, value || `cb`);
|
|
31
|
+
_setChecked(e.target.checked);
|
|
32
|
+
} })] });
|
|
32
33
|
});
|
|
33
34
|
// import { DetailedHTMLProps, HTMLAttributes, ReactNode, Ref, useState } from "react";
|
|
34
35
|
// import { cleanProps, css } from "../funs";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Props } from "../../types";
|
|
2
|
+
import { CHECKBOX } from "../../types/enums";
|
|
3
|
+
export type CheckBoxProps = Props<"input"> & {
|
|
4
|
+
type?: CHECKBOX;
|
|
5
|
+
onChange?: (checked: boolean, value: string | number | readonly string[]) => void;
|
|
6
|
+
};
|
|
7
|
+
export interface CheckboxHandler {
|
|
8
|
+
setChecked: (mode: boolean, triggerChange?: boolean) => void;
|
|
9
|
+
toggle: (triggerChange?: boolean) => void;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BoxProps } from "../Box";
|
|
2
|
+
import { ContextMenuHandler } from "./types";
|
|
3
|
+
declare const ContextMenu: import("react").ForwardRefExoticComponent<BoxProps & {
|
|
4
|
+
items: import("./types").ContextItem[];
|
|
5
|
+
} & import("react").RefAttributes<ContextMenuHandler>>;
|
|
6
|
+
export default ContextMenu;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
|
3
|
+
import Box from "../Box";
|
|
4
|
+
import { useBase } from "../../hooks";
|
|
5
|
+
import MenuItem from "./item";
|
|
6
|
+
const ContextMenu = forwardRef((props, ref) => {
|
|
7
|
+
const { as, items, ...pops } = props;
|
|
8
|
+
const { className, style, rest } = useBase(pops);
|
|
9
|
+
const [visible, setVisible] = useState(false);
|
|
10
|
+
const [position, setPosition] = useState({ x: 0, y: 0 });
|
|
11
|
+
useImperativeHandle(ref, () => ({
|
|
12
|
+
show: (e) => {
|
|
13
|
+
// console.log(e)
|
|
14
|
+
if (e instanceof MouseEvent) {
|
|
15
|
+
setPosition({ x: e.clientX, y: e.clientY });
|
|
16
|
+
}
|
|
17
|
+
else if (e instanceof TouchEvent && e.touches.length > 0) {
|
|
18
|
+
setPosition({ x: e.touches[0].clientX, y: e.touches[0].clientY });
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const { clientX: x, clientY: y } = e;
|
|
22
|
+
setPosition({ x, y });
|
|
23
|
+
}
|
|
24
|
+
setVisible(true);
|
|
25
|
+
},
|
|
26
|
+
hide: (e) => setVisible(false),
|
|
27
|
+
}));
|
|
28
|
+
useEffect(() => { }, [visible, position]);
|
|
29
|
+
if (!visible)
|
|
30
|
+
return null;
|
|
31
|
+
return _jsx(Box, { className: `--contextmenu abs flex cols ${className}`.trim(), style: {
|
|
32
|
+
...style,
|
|
33
|
+
top: position.y,
|
|
34
|
+
left: position.x
|
|
35
|
+
}, ...rest, children: items.map((item, index) => _jsx(MenuItem, { ...{ ...item, index } }, `context-${item.label.toLowerCase()}-${index}`)) });
|
|
36
|
+
});
|
|
37
|
+
export default ContextMenu;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Box from "../Box";
|
|
3
|
+
import Button from "../Button";
|
|
4
|
+
import Icon from "../Icon";
|
|
5
|
+
import Text from "../Text";
|
|
6
|
+
const MenuItem = (props) => {
|
|
7
|
+
const { label, labelColor, icon, iconColor, index, className, onSelect } = props;
|
|
8
|
+
return label == `-` ? _jsx(Box, { className: `--line` })
|
|
9
|
+
: _jsxs(Button, { onClick: e => onSelect(), className: `--item flex aic ${className}`.trim(), children: [_jsx(Icon, { name: icon, className: `--ico`, style: iconColor ? { color: iconColor } : {} }), _jsx(Text, { className: `--lbl flex aic`, style: labelColor ? { color: labelColor } : {}, children: label })] });
|
|
10
|
+
};
|
|
11
|
+
export default MenuItem;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BoxProps } from "../Box";
|
|
2
|
+
export interface ContextItem {
|
|
3
|
+
label: string;
|
|
4
|
+
labelColor?: string;
|
|
5
|
+
icon?: string;
|
|
6
|
+
iconColor?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
onSelect: () => void;
|
|
9
|
+
}
|
|
10
|
+
export type ContextMenuProps = BoxProps & {
|
|
11
|
+
items: ContextItem[];
|
|
12
|
+
};
|
|
13
|
+
export type MenuItemProps = ContextItem & {
|
|
14
|
+
index: number;
|
|
15
|
+
className: string;
|
|
16
|
+
};
|
|
17
|
+
export interface ContextMenuHandler {
|
|
18
|
+
show: (e: MouseEvent | TouchEvent) => void;
|
|
19
|
+
hide: (e: MouseEvent | TouchEvent) => void;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BoxProps } from "../Box";
|
|
2
|
+
import { SpinnerProps } from "../Spinner";
|
|
3
|
+
export type CoverProps = BoxProps & {
|
|
4
|
+
message?: string;
|
|
5
|
+
spinner?: SpinnerProps;
|
|
6
|
+
color?: string;
|
|
7
|
+
when?: boolean;
|
|
8
|
+
hideMessage?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare const Cover: import("react").ForwardRefExoticComponent<BoxProps & {
|
|
11
|
+
message?: string;
|
|
12
|
+
spinner?: SpinnerProps;
|
|
13
|
+
color?: string;
|
|
14
|
+
when?: boolean;
|
|
15
|
+
hideMessage?: boolean;
|
|
16
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
17
|
+
export default Cover;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import Box from "../Box";
|
|
5
|
+
import { useBase } from "../../hooks";
|
|
6
|
+
import Spinner from "../Spinner";
|
|
7
|
+
import Text from "../Text";
|
|
8
|
+
const Cover = forwardRef((props, ref) => {
|
|
9
|
+
const { message, spinner, color, when, hideMessage, ...pops } = props;
|
|
10
|
+
const { className, style, rest } = useBase(pops);
|
|
11
|
+
if (`when` in props && props.when == false) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return _jsxs(Box, { className: `--cover flex aic jcc cols abs fillx nope nous`, style: {
|
|
15
|
+
...style,
|
|
16
|
+
backgroundColor: `var(--cover-bg)`
|
|
17
|
+
}, ...rest, children: [_jsx(Spinner, { ...spinner }), !hideMessage && _jsx(Text, { className: `--label`, style: { color: `var(--cover-label)` }, children: message || `loading` })] });
|
|
18
|
+
});
|
|
19
|
+
export default Cover;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { BoxProps } from "../Box";
|
|
3
|
+
import { DrawerHandler } from "./types";
|
|
4
|
+
import { DRAWER_SIDE } from "../../types/enums";
|
|
5
|
+
declare const Drawer: import("react").ForwardRefExoticComponent<BoxProps & {
|
|
6
|
+
as?: string;
|
|
7
|
+
speed?: number;
|
|
8
|
+
from?: DRAWER_SIDE;
|
|
9
|
+
children: string | ReactNode | ReactNode[];
|
|
10
|
+
prerender?: boolean;
|
|
11
|
+
} & import("react").RefAttributes<DrawerHandler>>;
|
|
12
|
+
export default Drawer;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { bindKey } from "
|
|
3
|
+
import Overlay from "../Overlay";
|
|
4
|
+
import Box from "../Box";
|
|
5
|
+
import { bindKey } from "../../funs";
|
|
6
|
+
import { DRAWER_SIDE, KeyCode, TRANSITION_CURVES } from "../../types/enums";
|
|
6
7
|
const Drawer = forwardRef((props, ref) => {
|
|
7
|
-
const { as, from, speed, children, prerender, ...
|
|
8
|
+
const { as, from, speed, children, prerender, ...pops } = props;
|
|
8
9
|
const [render, setRender] = useState(undefined == prerender ? true : prerender);
|
|
9
10
|
const [visible, setVisible] = useState(false);
|
|
10
11
|
const divRef = useRef(null);
|
|
@@ -39,19 +40,16 @@ const Drawer = forwardRef((props, ref) => {
|
|
|
39
40
|
setVisible(false);
|
|
40
41
|
}
|
|
41
42
|
}));
|
|
42
|
-
return _jsxs(_Fragment, { children: [_jsx(
|
|
43
|
+
return _jsxs(_Fragment, { children: [_jsx(Overlay, { onClick: (e) => {
|
|
43
44
|
if (visible) {
|
|
44
45
|
setVisible(false);
|
|
45
46
|
}
|
|
46
|
-
},
|
|
47
|
-
transition: TRANSITIONS.FadeIn,
|
|
48
|
-
when: visible,
|
|
49
|
-
} }), _jsxs(With, { ref: divRef, as: as, className: `zuz-drawer flex cols drawer-${from ? from.toLowerCase() : `left`} fixed`, animate: {
|
|
47
|
+
}, when: visible }), _jsxs(Box, { ref: divRef, className: `--drawer flex cols --${from ? from.toLowerCase() : `left`} fixed`, animate: {
|
|
50
48
|
from: { ...style.from, opacity: 0 },
|
|
51
49
|
to: { ...style.to, opacity: 1 },
|
|
52
50
|
when: visible,
|
|
53
51
|
curve: TRANSITION_CURVES.EaseInOut,
|
|
54
52
|
duration: speed || .5,
|
|
55
|
-
}, ...
|
|
53
|
+
}, ...pops, children: [from == DRAWER_SIDE.Top || from == DRAWER_SIDE.Bottom ? _jsx(Box, { className: `--handle` }) : null, render ? content : visible ? content : null] })] });
|
|
56
54
|
});
|
|
57
55
|
export default Drawer;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
import { DRAWER_SIDE } from "
|
|
3
|
-
|
|
2
|
+
import { DRAWER_SIDE } from "../../types/enums";
|
|
3
|
+
import { BoxProps } from "../Box";
|
|
4
|
+
export type DrawerProps = BoxProps & {
|
|
4
5
|
as?: string;
|
|
5
6
|
speed?: number;
|
|
6
7
|
from?: DRAWER_SIDE;
|
|
7
8
|
children: string | ReactNode | ReactNode[];
|
|
8
9
|
prerender?: boolean;
|
|
9
|
-
}
|
|
10
|
+
};
|
|
10
11
|
export interface DrawerHandler {
|
|
11
12
|
open: (child?: string | ReactNode | ReactNode[]) => void;
|
|
12
13
|
close: () => void;
|
|
13
14
|
}
|
|
14
|
-
declare const Drawer: import("react").ForwardRefExoticComponent<DrawerProps & import("react").RefAttributes<DrawerHandler>>;
|
|
15
|
-
export default Drawer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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`> {
|
|
1
|
+
import { BoxProps } from "../Box";
|
|
2
|
+
import { dynamicObject } from "../../types";
|
|
3
|
+
import { SpinnerProps } from "../Spinner";
|
|
4
|
+
export type FormProps = BoxProps & {
|
|
9
5
|
/** Name of form, will be appended to --form-{name} in className
|
|
10
6
|
* whitespace will be replaced with dash (-)
|
|
11
7
|
*/
|
|
@@ -33,7 +29,7 @@ export interface FormProps extends Props<`div`> {
|
|
|
33
29
|
/** Message displayed during loading */
|
|
34
30
|
message?: string;
|
|
35
31
|
};
|
|
36
|
-
}
|
|
32
|
+
};
|
|
37
33
|
/**
|
|
38
34
|
* Exposes control methods for the Form component, such as setting loading states or hiding errors.
|
|
39
35
|
*/
|
|
@@ -54,5 +50,33 @@ export interface FormHandler {
|
|
|
54
50
|
* @param props - Properties to configure form behavior, validation messages, submission handling, and visual feedback.
|
|
55
51
|
* @param ref - Reference to the {@link FormHandler} interface, exposing methods to control loading and error states from the parent.
|
|
56
52
|
*/
|
|
57
|
-
declare const Form: import("react").ForwardRefExoticComponent<
|
|
53
|
+
declare const Form: import("react").ForwardRefExoticComponent<BoxProps & {
|
|
54
|
+
/** Name of form, will be appended to --form-{name} in className
|
|
55
|
+
* whitespace will be replaced with dash (-)
|
|
56
|
+
*/
|
|
57
|
+
name?: string;
|
|
58
|
+
/** The URL to which the form data is submitted */
|
|
59
|
+
action?: string;
|
|
60
|
+
/** List of error messages for form validation */
|
|
61
|
+
errors?: string[];
|
|
62
|
+
/** Spinner properties for loading indicator */
|
|
63
|
+
spinner?: SpinnerProps;
|
|
64
|
+
/** Additional data to include with form submission */
|
|
65
|
+
withData?: dynamicObject;
|
|
66
|
+
/** Handler function called before form submission with validated form data */
|
|
67
|
+
beforeSubmit?: (data: FormData | dynamicObject) => void;
|
|
68
|
+
/** Handler function called on form submission with validated form data */
|
|
69
|
+
onSubmit?: (data: FormData | dynamicObject) => void;
|
|
70
|
+
/** Callback triggered upon successful form submission */
|
|
71
|
+
onSuccess?: (data: dynamicObject) => void;
|
|
72
|
+
/** Callback triggered when form submission encounters an error */
|
|
73
|
+
onError?: (error: any) => void;
|
|
74
|
+
/** Cover properties to display loading or processing message */
|
|
75
|
+
cover?: {
|
|
76
|
+
/** Background color of the loading cover */
|
|
77
|
+
color?: string;
|
|
78
|
+
/** Message displayed during loading */
|
|
79
|
+
message?: string;
|
|
80
|
+
};
|
|
81
|
+
} & import("react").RefAttributes<FormHandler>>;
|
|
58
82
|
export default Form;
|