@zuzjs/ui 0.9.5 → 0.9.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/Chart/index.d.ts +8 -0
- package/dist/cjs/comps/Chart/index.js +66 -0
- package/dist/cjs/comps/Chart/types.d.ts +10 -0
- package/dist/cjs/comps/Chart/types.js +4 -0
- package/dist/cjs/comps/Cover/index.d.ts +3 -1
- package/dist/cjs/comps/Cover/index.js +3 -3
- package/dist/cjs/comps/Form/index.js +7 -3
- package/dist/cjs/comps/Search/index.d.ts +4 -0
- package/dist/cjs/comps/Search/index.js +7 -3
- package/dist/cjs/comps/Search/types.d.ts +5 -0
- package/dist/cjs/comps/Select/index.d.ts +3 -0
- package/dist/cjs/comps/Select/index.js +13 -5
- package/dist/cjs/comps/Select/types.d.ts +7 -1
- package/dist/cjs/comps/Spinner/index.d.ts +3 -1
- package/dist/cjs/comps/Spinner/index.js +11 -4
- package/dist/cjs/comps/TextWheel/index.d.ts +2 -0
- package/dist/cjs/comps/TextWheel/index.js +24 -12
- package/dist/cjs/comps/TextWheel/types.d.ts +2 -0
- package/dist/cjs/comps/index.d.ts +2 -0
- package/dist/cjs/comps/index.js +2 -0
- package/dist/cjs/funs/stylesheet.js +3 -1
- package/dist/cjs/hooks/index.d.ts +2 -0
- package/dist/cjs/hooks/index.js +2 -0
- package/dist/cjs/hooks/useLineChart.d.ts +25 -0
- package/dist/cjs/hooks/useLineChart.js +86 -0
- package/dist/cjs/hooks/usePosition.d.ts +12 -0
- package/dist/cjs/hooks/usePosition.js +191 -0
- package/dist/cjs/hooks/useResizeObserver.d.ts +1 -1
- package/dist/cjs/hooks/useResizeObserver.js +5 -4
- package/dist/cjs/hooks/useScrollbar.js +115 -70
- package/dist/cjs/types/enums.d.ts +2 -0
- package/dist/cjs/types/enums.js +2 -0
- package/dist/cjs/types/index.d.ts +2 -1
- package/dist/css/styles.css +1 -1
- package/dist/esm/comps/Chart/index.d.ts +8 -0
- package/dist/esm/comps/Chart/index.js +66 -0
- package/dist/esm/comps/Chart/types.d.ts +10 -0
- package/dist/esm/comps/Chart/types.js +4 -0
- package/dist/esm/comps/Cover/index.d.ts +3 -1
- package/dist/esm/comps/Cover/index.js +3 -3
- package/dist/esm/comps/Form/index.js +7 -3
- package/dist/esm/comps/Search/index.d.ts +4 -0
- package/dist/esm/comps/Search/index.js +7 -3
- package/dist/esm/comps/Search/types.d.ts +5 -0
- package/dist/esm/comps/Select/index.d.ts +3 -0
- package/dist/esm/comps/Select/index.js +13 -5
- package/dist/esm/comps/Select/types.d.ts +7 -1
- package/dist/esm/comps/Spinner/index.d.ts +3 -1
- package/dist/esm/comps/Spinner/index.js +11 -4
- package/dist/esm/comps/TextWheel/index.d.ts +2 -0
- package/dist/esm/comps/TextWheel/index.js +24 -12
- package/dist/esm/comps/TextWheel/types.d.ts +2 -0
- package/dist/esm/comps/index.d.ts +2 -0
- package/dist/esm/comps/index.js +2 -0
- package/dist/esm/funs/stylesheet.js +3 -1
- package/dist/esm/hooks/index.d.ts +2 -0
- package/dist/esm/hooks/index.js +2 -0
- package/dist/esm/hooks/useLineChart.d.ts +25 -0
- package/dist/esm/hooks/useLineChart.js +86 -0
- package/dist/esm/hooks/usePosition.d.ts +12 -0
- package/dist/esm/hooks/usePosition.js +191 -0
- package/dist/esm/hooks/useResizeObserver.d.ts +1 -1
- package/dist/esm/hooks/useResizeObserver.js +5 -4
- package/dist/esm/hooks/useScrollbar.js +115 -70
- package/dist/esm/types/enums.d.ts +2 -0
- package/dist/esm/types/enums.js +2 -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 +2 -2
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BoxProps } from "../Box";
|
|
2
|
+
import { CHART } from "./types";
|
|
3
|
+
declare const Chart: import("react").ForwardRefExoticComponent<BoxProps & import("../..").LineChartProps & {
|
|
4
|
+
type?: CHART;
|
|
5
|
+
animDuration?: number;
|
|
6
|
+
animDelay?: number;
|
|
7
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
8
|
+
export default Chart;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useEffect, useId, useRef, useState } from "react";
|
|
4
|
+
import { useResizeObserver } from "../..";
|
|
5
|
+
import useBase from "../../hooks/useBase";
|
|
6
|
+
import useLineChart from "../../hooks/useLineChart";
|
|
7
|
+
import Box from "../Box";
|
|
8
|
+
import { CHART } from "./types";
|
|
9
|
+
const Chart = forwardRef((props, ref) => {
|
|
10
|
+
const { data, width, height, lineColor, strokeWidth = 2, gradientStartColor, gradientEndColor, animated, animDuration = 2, animDelay = 0, padding = 0, type, ...pops } = props;
|
|
11
|
+
const { className, style, rest } = useBase(pops);
|
|
12
|
+
const innerRef = useRef(null);
|
|
13
|
+
// State to store the actual dimensions of the container
|
|
14
|
+
const observedDimensions = useResizeObserver(innerRef.current?.parentElement || innerRef);
|
|
15
|
+
const chartWidth = typeof width === 'number' ? width : observedDimensions.width;
|
|
16
|
+
const chartHeight = typeof height === 'number' ? height : observedDimensions.height;
|
|
17
|
+
const dimensionsForChartHook = {
|
|
18
|
+
width: chartWidth,
|
|
19
|
+
height: chartHeight
|
|
20
|
+
};
|
|
21
|
+
// Generate a unique ID for the gradient to avoid conflicts if multiple charts are on the page
|
|
22
|
+
const gradientId = useId(); //`chartGradient-${Math.random().toString(36).substring(2, 9)}`;
|
|
23
|
+
// Use the custom hook to get the SVG path data and area path data
|
|
24
|
+
const { pathD, areaPathD } = useLineChart(data, dimensionsForChartHook, (padding + (strokeWidth || 2)));
|
|
25
|
+
// Refs for the path elements to get their total length for animation
|
|
26
|
+
const linePathRef = useRef(null);
|
|
27
|
+
const areaPathRef = useRef(null);
|
|
28
|
+
// State to store the calculated lengths of the paths
|
|
29
|
+
const [linePathLength, setLinePathLength] = useState(0);
|
|
30
|
+
const [areaPathLength, setAreaPathLength] = useState(0);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (animated) {
|
|
33
|
+
if (linePathRef.current) {
|
|
34
|
+
// Get the total length of the line path for stroke-dasharray animation
|
|
35
|
+
setLinePathLength(linePathRef.current.getTotalLength());
|
|
36
|
+
}
|
|
37
|
+
if (areaPathRef.current) {
|
|
38
|
+
// Get the total length of the area path for stroke-dasharray animation
|
|
39
|
+
setAreaPathLength(areaPathRef.current.getTotalLength());
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}, [animated, pathD, areaPathD, chartWidth, chartHeight]);
|
|
43
|
+
return _jsx(Box, { ref: innerRef, as: `--chart --${type || CHART.Line}-chart ${className}`.trim(), style: {
|
|
44
|
+
...style,
|
|
45
|
+
width,
|
|
46
|
+
height
|
|
47
|
+
}, ...rest, children: chartWidth > 0 && chartHeight > 0 && _jsxs("svg", { viewBox: `0 0 ${chartWidth} ${chartHeight}`, preserveAspectRatio: "xMidYMid meet" // Ensures the SVG scales nicely
|
|
48
|
+
, children: [_jsx("defs", { children: _jsxs("linearGradient", { id: gradientId, x1: "0%", y1: "0%", x2: "0%", y2: "100%", children: [_jsx("stop", { offset: "0%", stopColor: gradientStartColor }), _jsx("stop", { offset: "100%", stopColor: gradientEndColor })] }) }), _jsx("path", { ref: areaPathRef, d: areaPathD, fill: `url(#${gradientId})`, stroke: "none" // No stroke for the area
|
|
49
|
+
,
|
|
50
|
+
// Apply animation properties if 'animated' is true
|
|
51
|
+
style: animated ? {
|
|
52
|
+
strokeDasharray: areaPathLength,
|
|
53
|
+
strokeDashoffset: areaPathLength,
|
|
54
|
+
} : {}, children: animated && (_jsx("animate", { attributeName: "stroke-dashoffset", from: areaPathLength, to: "0", dur: `${animDuration || 2}s`, begin: `${animDelay || 0}s`, fill: "freeze" })) }), _jsx("path", { ref: linePathRef, d: pathD, fill: "none" // No fill for the line
|
|
55
|
+
, stroke: lineColor, strokeWidth: strokeWidth, strokeLinecap: "round" // Rounded line caps
|
|
56
|
+
, strokeLinejoin: "round" // Rounded line joins
|
|
57
|
+
,
|
|
58
|
+
// Apply animation properties if 'animated' is true
|
|
59
|
+
style: animated ? {
|
|
60
|
+
strokeDasharray: linePathLength,
|
|
61
|
+
strokeDashoffset: linePathLength,
|
|
62
|
+
} : {}, children: animated && (_jsx("animate", { attributeName: "stroke-dashoffset", from: linePathLength, to: "0", dur: `${animDuration || 2}s`, begin: `${animDelay || 0}s`, fill: "freeze" // Keep the final state
|
|
63
|
+
})) })] }) });
|
|
64
|
+
});
|
|
65
|
+
Chart.displayName = `Zuz.Chart`;
|
|
66
|
+
export default Chart;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LineChartProps } from "../../hooks/useLineChart";
|
|
2
|
+
import { BoxProps } from "../Box";
|
|
3
|
+
export declare enum CHART {
|
|
4
|
+
Line = "line"
|
|
5
|
+
}
|
|
6
|
+
export type ChartProps = BoxProps & LineChartProps & {
|
|
7
|
+
type?: CHART;
|
|
8
|
+
animDuration?: number;
|
|
9
|
+
animDelay?: number;
|
|
10
|
+
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { SPINNER } from "../../types/enums";
|
|
1
|
+
import { SPINNER, Variant } from "../../types/enums";
|
|
2
2
|
import { BoxProps } from "../Box";
|
|
3
3
|
export type CoverProps = BoxProps & {
|
|
4
4
|
message?: string;
|
|
5
5
|
spinner?: SPINNER;
|
|
6
|
+
spinnerSize?: Variant;
|
|
6
7
|
color?: string;
|
|
7
8
|
when?: boolean;
|
|
8
9
|
hideMessage?: boolean;
|
|
@@ -10,6 +11,7 @@ export type CoverProps = BoxProps & {
|
|
|
10
11
|
declare const Cover: import("react").ForwardRefExoticComponent<BoxProps & {
|
|
11
12
|
message?: string;
|
|
12
13
|
spinner?: SPINNER;
|
|
14
|
+
spinnerSize?: Variant;
|
|
13
15
|
color?: string;
|
|
14
16
|
when?: boolean;
|
|
15
17
|
hideMessage?: boolean;
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { useBase } from "../../hooks";
|
|
5
|
-
import { SPINNER } from "../../types/enums";
|
|
5
|
+
import { SPINNER, Variant } from "../../types/enums";
|
|
6
6
|
import Box from "../Box";
|
|
7
7
|
import Spinner from "../Spinner";
|
|
8
8
|
import Text from "../Text";
|
|
9
9
|
const Cover = forwardRef((props, ref) => {
|
|
10
|
-
const { message, spinner, color, when, hideMessage, ...pops } = props;
|
|
10
|
+
const { message, spinner, spinnerSize, color, when, hideMessage, ...pops } = props;
|
|
11
11
|
const { className, style, rest } = useBase(pops);
|
|
12
12
|
if (`when` in props && props.when == false) {
|
|
13
13
|
return null;
|
|
@@ -15,7 +15,7 @@ const Cover = forwardRef((props, ref) => {
|
|
|
15
15
|
return _jsxs(Box, { className: `--cover flex aic jcc cols abs fillx nope nous ${className}`.trim(), style: {
|
|
16
16
|
...style,
|
|
17
17
|
backgroundColor: `var(--cover-bg)`
|
|
18
|
-
}, ...rest, children: [_jsx(Spinner, { type: spinner || SPINNER.Simple }), !hideMessage && _jsx(Text, { className: `--label`, style: { color: `var(--cover-label)` }, children: message || `loading` })] });
|
|
18
|
+
}, ...rest, children: [_jsx(Spinner, { variant: spinnerSize || Variant.Small, type: spinner || SPINNER.Simple }), !hideMessage && _jsx(Text, { className: `--label`, style: { color: `var(--cover-label)` }, children: message || `loading` })] });
|
|
19
19
|
});
|
|
20
20
|
Cover.displayName = `Zuz.Cover`;
|
|
21
21
|
export default Cover;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { withPost } from "@zuzjs/core";
|
|
3
|
+
import { _, withPost } from "@zuzjs/core";
|
|
4
4
|
import { forwardRef, startTransition, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
5
|
-
import { addPropsToChildren,
|
|
5
|
+
import { addPropsToChildren, isEmpty } from "../../funs";
|
|
6
6
|
import { useBase, useToast } from "../../hooks";
|
|
7
7
|
import { FORMVALIDATION } from "../../types/enums";
|
|
8
8
|
import Box from "../Box";
|
|
@@ -89,8 +89,12 @@ const Form = forwardRef((props, ref) => {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
switch (_with.toUpperCase()) {
|
|
92
|
+
case FORMVALIDATION.IPV4:
|
|
93
|
+
return _(el.value).isIPv4();
|
|
94
|
+
case FORMVALIDATION.IPV6:
|
|
95
|
+
return _(el.value).isIPv6();
|
|
92
96
|
case FORMVALIDATION.Email:
|
|
93
|
-
return
|
|
97
|
+
return _(el.value).isEmail();
|
|
94
98
|
case FORMVALIDATION.Uri:
|
|
95
99
|
try {
|
|
96
100
|
new URL(el.value);
|
|
@@ -13,5 +13,9 @@ declare const Search: import("react").ForwardRefExoticComponent<import("../..").
|
|
|
13
13
|
withStyle?: string;
|
|
14
14
|
shortcut?: import("..").KeyCombination;
|
|
15
15
|
reverse?: boolean;
|
|
16
|
+
searchIcon?: string | import("react").ReactNode;
|
|
17
|
+
hideSearchIcon?: boolean;
|
|
18
|
+
clearIcon?: string | import("react").ReactNode;
|
|
19
|
+
hideClearIcon?: boolean;
|
|
16
20
|
} & import("react").RefAttributes<SearchHandler>>;
|
|
17
21
|
export default Search;
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
3
|
+
import { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { useBase } from '../../hooks';
|
|
5
5
|
import { Variant } from '../../types/enums';
|
|
6
6
|
import Box from '../Box';
|
|
7
7
|
import Button from '../Button';
|
|
8
|
+
import Icon from '../Icon';
|
|
8
9
|
import Input from '../Input';
|
|
9
10
|
import KeyBoardKeys from '../KeyboardKeys';
|
|
10
11
|
import SVGIcons from '../svgicons';
|
|
11
12
|
const Search = forwardRef((props, ref) => {
|
|
12
|
-
const { fx, animate, withStyle, as, reverse, onChange, onClear, ...pops } = props;
|
|
13
|
+
const { fx, animate, withStyle, as, reverse = false, searchIcon = SVGIcons.search, hideSearchIcon = false, clearIcon = SVGIcons.close, hideClearIcon = false, onChange, onClear, ...pops } = props;
|
|
13
14
|
const { style, className } = useBase({ as: props.as });
|
|
14
15
|
// const { className : searchStyle } = useBase({ as: withStyle || `` } as Props<`div`>)
|
|
15
16
|
const [query, setQuery] = useState(``);
|
|
16
17
|
const innerRef = useRef(null);
|
|
18
|
+
const actionBtn = useMemo(() => _jsx(Button, { tabIndex: -1, onClick: e => handleSubmit(), className: `--send flex aic jcc`, variant: props.variant || Variant.Small, children: query !== `` ?
|
|
19
|
+
!hideClearIcon && (`string` === typeof clearIcon ? _jsx(Icon, { name: clearIcon, as: `--search-action` }) : clearIcon) :
|
|
20
|
+
!hideSearchIcon && (`string` === typeof searchIcon ? _jsx(Icon, { name: searchIcon, as: `--search-action` }) : searchIcon) }), [reverse, searchIcon, hideClearIcon, clearIcon, hideSearchIcon]);
|
|
17
21
|
if (`type` in props) {
|
|
18
22
|
delete props[`type`];
|
|
19
23
|
}
|
|
@@ -38,7 +42,7 @@ const Search = forwardRef((props, ref) => {
|
|
|
38
42
|
value: () => innerRef.current?.value
|
|
39
43
|
}));
|
|
40
44
|
useEffect(() => { }, []);
|
|
41
|
-
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 &&
|
|
45
|
+
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 && actionBtn, _jsx(Input, { ref: innerRef, onChange: handleChange, className: `--${props.variant || Variant.Small}`, ...pops }), props.shortcut && _jsx(KeyBoardKeys, { keys: props.shortcut, as: `abs` }), !reverse && actionBtn] });
|
|
42
46
|
});
|
|
43
47
|
Search.displayName = `Zuz.Search`;
|
|
44
48
|
export default Search;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
1
2
|
import { KeyCombination } from "../..";
|
|
2
3
|
import { InputProps } from "../Input";
|
|
3
4
|
export type SearchProps = InputProps & {
|
|
@@ -7,6 +8,10 @@ export type SearchProps = InputProps & {
|
|
|
7
8
|
withStyle?: string;
|
|
8
9
|
shortcut?: KeyCombination;
|
|
9
10
|
reverse?: boolean;
|
|
11
|
+
searchIcon?: string | ReactNode;
|
|
12
|
+
hideSearchIcon?: boolean;
|
|
13
|
+
clearIcon?: string | ReactNode;
|
|
14
|
+
hideClearIcon?: boolean;
|
|
10
15
|
};
|
|
11
16
|
export interface SearchHandler {
|
|
12
17
|
focus: () => void;
|
|
@@ -8,5 +8,8 @@ declare const Select: import("react").ForwardRefExoticComponent<Omit<import(".."
|
|
|
8
8
|
search?: boolean;
|
|
9
9
|
onChange?: (v: Option) => void;
|
|
10
10
|
searchPlaceholder?: string;
|
|
11
|
+
maxHeight?: number;
|
|
12
|
+
arrowDownIcon?: string | import("react").ReactNode;
|
|
13
|
+
arrowUpIcon?: string | import("react").ReactNode;
|
|
11
14
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
12
15
|
export default Select;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
4
|
-
import { useBase } from "../../hooks";
|
|
4
|
+
import { useBase, usePosition } from "../../hooks";
|
|
5
|
+
import { Position } from "../../types/enums";
|
|
5
6
|
import Box from "../Box";
|
|
6
7
|
import Button from "../Button";
|
|
8
|
+
import Icon from "../Icon";
|
|
7
9
|
import Input from "../Input";
|
|
8
10
|
import SVGIcons from "../svgicons";
|
|
9
11
|
import Text from "../Text";
|
|
10
12
|
import OptionItem from "./optionItem";
|
|
11
13
|
const Select = forwardRef((props, ref) => {
|
|
12
|
-
const { selected, options, label, name, variant, search: withSearch, searchPlaceholder, onChange, ...pops } = props;
|
|
14
|
+
const { selected, options, label, name, variant, search: withSearch, searchPlaceholder, maxHeight, arrowDownIcon = SVGIcons.arrowDown, arrowUpIcon = SVGIcons.arrowUp, onChange, ...pops } = props;
|
|
13
15
|
const [value, setValue] = useState(selected ?
|
|
14
16
|
typeof selected === `string` ? options.find(fo => fo.value === selected) : selected
|
|
15
17
|
: options[0]);
|
|
@@ -17,8 +19,10 @@ const Select = forwardRef((props, ref) => {
|
|
|
17
19
|
const [query, setQuery] = useState(null);
|
|
18
20
|
const _ref = useRef(null);
|
|
19
21
|
const _search = useRef(null);
|
|
22
|
+
const _pop = useRef(null);
|
|
20
23
|
const _did = useId();
|
|
21
24
|
const _id = useMemo(() => name || _did, []);
|
|
25
|
+
const { reposition } = usePosition(_pop, { direction: Position.Bottom, offset: 2 });
|
|
22
26
|
const { className, style, rest } = useBase(pops);
|
|
23
27
|
const updateValue = (o) => {
|
|
24
28
|
setValue(o);
|
|
@@ -28,6 +32,7 @@ const Select = forwardRef((props, ref) => {
|
|
|
28
32
|
document.body.addEventListener(`click`, (e) => {
|
|
29
33
|
setChoosing(false);
|
|
30
34
|
});
|
|
35
|
+
window.dispatchEvent(new Event('resize'));
|
|
31
36
|
}, []);
|
|
32
37
|
useEffect(() => {
|
|
33
38
|
if (choosing) {
|
|
@@ -39,10 +44,13 @@ const Select = forwardRef((props, ref) => {
|
|
|
39
44
|
}
|
|
40
45
|
setQuery(null);
|
|
41
46
|
}
|
|
47
|
+
reposition();
|
|
42
48
|
}, [choosing]);
|
|
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 ?
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
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 ?
|
|
50
|
+
`string` === typeof arrowUpIcon ? _jsx(Icon, { name: arrowUpIcon, as: `--search-action` }) : arrowUpIcon :
|
|
51
|
+
`string` === typeof arrowDownIcon ? _jsx(Icon, { name: arrowDownIcon, as: `--search-action` }) : arrowDownIcon })] }), _jsxs(Box, { id: _id, className: `--options-list flex cols abs`, "aria-hidden": !choosing, style: {
|
|
52
|
+
maxHeight: maxHeight || `auto`
|
|
53
|
+
}, ref: _pop, fx: {
|
|
46
54
|
from: { y: 5, opacity: 0 },
|
|
47
55
|
to: { y: 0, opacity: 1 },
|
|
48
56
|
when: choosing,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormEventHandler } from "react";
|
|
1
|
+
import { FormEventHandler, ReactNode } from "react";
|
|
2
2
|
import { FORMVALIDATION, Variant } from "../../types/enums";
|
|
3
3
|
import { BoxProps } from "../Box";
|
|
4
4
|
/**
|
|
@@ -55,4 +55,10 @@ export type SelectProps = Omit<BoxProps, "onChange"> & {
|
|
|
55
55
|
* Placeholder text for the search input field.
|
|
56
56
|
*/
|
|
57
57
|
searchPlaceholder?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Max Height
|
|
60
|
+
*/
|
|
61
|
+
maxHeight?: number;
|
|
62
|
+
arrowDownIcon?: string | ReactNode;
|
|
63
|
+
arrowUpIcon?: string | ReactNode;
|
|
58
64
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Size, SPINNER } from "../../types/enums";
|
|
1
|
+
import { Size, SPINNER, Variant } from "../../types/enums";
|
|
2
2
|
import { BoxProps } from "../Box";
|
|
3
3
|
export type SpinnerProps = BoxProps & {
|
|
4
4
|
type?: SPINNER;
|
|
5
5
|
size?: Size | number;
|
|
6
|
+
variant?: Variant | number;
|
|
6
7
|
width?: number;
|
|
7
8
|
color?: string;
|
|
8
9
|
background?: string;
|
|
@@ -12,6 +13,7 @@ export type SpinnerProps = BoxProps & {
|
|
|
12
13
|
declare const Spinner: import("react").ForwardRefExoticComponent<BoxProps & {
|
|
13
14
|
type?: SPINNER;
|
|
14
15
|
size?: Size | number;
|
|
16
|
+
variant?: Variant | number;
|
|
15
17
|
width?: number;
|
|
16
18
|
color?: string;
|
|
17
19
|
background?: string;
|
|
@@ -2,10 +2,10 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { hexToRgba } from "../../funs";
|
|
4
4
|
import { useBase } from "../../hooks";
|
|
5
|
-
import { Size, SPINNER } from "../../types/enums";
|
|
5
|
+
import { Size, SPINNER, Variant } from "../../types/enums";
|
|
6
6
|
import Box from "../Box";
|
|
7
7
|
const Spinner = forwardRef((props, ref) => {
|
|
8
|
-
const { type, size, width, speed, color, background, foreground, ...pops } = props;
|
|
8
|
+
const { type, size, variant, width, speed, color, background, foreground, ...pops } = props;
|
|
9
9
|
const defaultColor = `#000000`;
|
|
10
10
|
const { className, style, rest } = useBase(pops);
|
|
11
11
|
const build = () => {
|
|
@@ -18,13 +18,20 @@ const Spinner = forwardRef((props, ref) => {
|
|
|
18
18
|
default: 20
|
|
19
19
|
};
|
|
20
20
|
const _size = size ? Object.values(Size).includes(size) ? sizes[size] : size : sizes.default;
|
|
21
|
+
const variants = {
|
|
22
|
+
[Variant.Small]: 20,
|
|
23
|
+
[Variant.Medium]: 30,
|
|
24
|
+
[Variant.Large]: 50,
|
|
25
|
+
default: 20
|
|
26
|
+
};
|
|
27
|
+
const _variant = variant ? Object.values(Variant).includes(variant) ? variants[variant] : variant : variants.default;
|
|
21
28
|
const _animationSetting = {
|
|
22
29
|
animationDuration: `${speed || .6}s`,
|
|
23
30
|
animationTimingFunction: `linear`
|
|
24
31
|
};
|
|
25
32
|
const _props = (type || SPINNER.Simple) == SPINNER.Simple ? {
|
|
26
|
-
width: _size,
|
|
27
|
-
height: _size,
|
|
33
|
+
width: _variant || _size,
|
|
34
|
+
height: _variant || _size,
|
|
28
35
|
border: `${width || 3}px solid ${bg}`,
|
|
29
36
|
borderRadius: `50%`,
|
|
30
37
|
borderTopColor: c,
|
|
@@ -4,5 +4,7 @@ declare const TextWheel: React.ForwardRefExoticComponent<Omit<import("..").BoxPr
|
|
|
4
4
|
value?: number | string;
|
|
5
5
|
color?: string;
|
|
6
6
|
direction?: `up` | `down`;
|
|
7
|
+
charDelay?: number | ((index: number) => number);
|
|
8
|
+
charDuration?: number | ((index: number) => number);
|
|
7
9
|
} & React.RefAttributes<TextWheelHandler>>;
|
|
8
10
|
export default TextWheel;
|
|
@@ -1,54 +1,66 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
4
|
-
import Box from '../Box';
|
|
5
|
-
import Span from '../Span';
|
|
4
|
+
import Box from '../Box'; // Assuming these are your custom components
|
|
5
|
+
import Span from '../Span'; // Assuming these are your custom components
|
|
6
6
|
const TextWheel = forwardRef((props, ref) => {
|
|
7
7
|
const { as, value, color, direction, ...rest } = props;
|
|
8
8
|
const divRef = useRef(null);
|
|
9
|
+
// Internal state to manage the displayed value
|
|
9
10
|
const [_value, _setValue] = useState(value || 0);
|
|
11
|
+
// Expose methods to parent components via ref
|
|
10
12
|
useImperativeHandle(ref, () => ({
|
|
13
|
+
// Updates the value without immediately triggering a full re-render of characters
|
|
14
|
+
// Useful for when the number of digits changes.
|
|
11
15
|
updateValue(v) {
|
|
12
|
-
if (_value.toString().length
|
|
16
|
+
if (_value.toString().length !== v.toString().length) {
|
|
13
17
|
_setValue(v);
|
|
14
18
|
}
|
|
15
19
|
},
|
|
20
|
+
// Sets the value and triggers the animation for each character
|
|
16
21
|
setValue(v) {
|
|
17
|
-
this.updateValue(v);
|
|
22
|
+
this.updateValue(v); // First, update the internal value to handle length changes
|
|
18
23
|
if (divRef.current) {
|
|
19
24
|
const chars = v.toString().split('');
|
|
20
25
|
divRef.current.querySelectorAll('.--wheel-char').forEach((charElement, index) => {
|
|
21
26
|
const char = chars[index];
|
|
22
27
|
if (charElement instanceof HTMLElement) {
|
|
28
|
+
// Set the data-value attribute, which CSS can then use
|
|
23
29
|
charElement.setAttribute('data-value', char);
|
|
24
30
|
const track = charElement.querySelector('.--wheel-char-track');
|
|
25
31
|
if (track instanceof HTMLElement) {
|
|
32
|
+
// Directly update the CSS custom property for immediate animation
|
|
26
33
|
track.style.setProperty('--v', char);
|
|
34
|
+
// Force a reflow to ensure the transition plays even if the value is the same
|
|
35
|
+
// This is a common trick for re-triggering CSS animations/transitions
|
|
36
|
+
void track.offsetWidth;
|
|
27
37
|
}
|
|
28
38
|
}
|
|
29
39
|
});
|
|
30
40
|
}
|
|
31
41
|
}
|
|
32
42
|
}));
|
|
43
|
+
// Effect to update internal value when the prop `value` changes
|
|
33
44
|
useEffect(() => {
|
|
34
|
-
// console.log(value)
|
|
35
45
|
_setValue(value || 0);
|
|
36
46
|
}, [value]);
|
|
37
|
-
return _jsxs(Box, { className: `--text-wheel flex aic rel`, "aria-hidden": true, as: as, ref: divRef, ...rest, children: [(_value || 0).toString().split('').map((char, index) => {
|
|
47
|
+
return (_jsxs(Box, { className: `--text-wheel flex aic rel`, "aria-hidden": true, as: as, ref: divRef, ...rest, children: [(_value || 0).toString().split('').map((char, index) => {
|
|
48
|
+
// Render non-numeric characters directly (e.g., decimal points)
|
|
38
49
|
if (isNaN(parseInt(char, 10))) {
|
|
39
|
-
return _jsx(Span, { className: "--wheel-char wheel-char-symbol grid", children: char }, `wheel-char-${index}`);
|
|
50
|
+
return _jsx(Span, { className: "--wheel-char wheel-char-symbol grid", children: char }, `wheel-char-symbol-${index}`);
|
|
40
51
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
52
|
+
// Render numeric characters with the wheel effect
|
|
53
|
+
return (_jsx(Span, { "data-value": char, className: `--wheel-char grid ${index > (_value || 0).toString().length - 3 ? '--wheel-fraction' : ''}`.trim(), children: _jsxs(Span, { className: `--wheel-char-track --wheel-track-${direction || `down`} grid`, style: {
|
|
54
|
+
'--v': char // Set the custom property for the current character value
|
|
55
|
+
}, children: [_jsx(Span, { children: !direction || direction === `down` ? 0 : 9 }), (!direction || direction === `down` ?
|
|
44
56
|
[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
|
|
45
57
|
: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]).map((val, indx) => {
|
|
46
58
|
return _jsx(Span, { children: val }, `${index}--${indx}`);
|
|
47
|
-
}), _jsx(Span, { children: !direction || direction
|
|
59
|
+
}), _jsx(Span, { children: !direction || direction === `down` ? 9 : 0 })] }) }, `wheel-char-${index}`));
|
|
48
60
|
}), color && _jsx(Box, { className: `abs fillx`, style: {
|
|
49
61
|
zIndex: 1,
|
|
50
62
|
background: `linear-gradient(0deg, ${color}, transparent, transparent, transparent, ${color})`,
|
|
51
|
-
} })] });
|
|
63
|
+
} })] }));
|
|
52
64
|
});
|
|
53
65
|
TextWheel.displayName = `Zuz.TextWheel`;
|
|
54
66
|
export default TextWheel;
|
|
@@ -3,6 +3,8 @@ export type TextWheelProps = Omit<BoxProps, "name"> & {
|
|
|
3
3
|
value?: number | string;
|
|
4
4
|
color?: string;
|
|
5
5
|
direction?: `up` | `down`;
|
|
6
|
+
charDelay?: number | ((index: number) => number);
|
|
7
|
+
charDuration?: number | ((index: number) => number);
|
|
6
8
|
};
|
|
7
9
|
export interface TextWheelHandler {
|
|
8
10
|
setValue: (v: number | string) => void;
|
|
@@ -12,6 +12,8 @@ export * from './Avatar/types';
|
|
|
12
12
|
export { default as Box, type BoxProps } from './Box';
|
|
13
13
|
export { default as Button } from './Button';
|
|
14
14
|
export * from './Button/types';
|
|
15
|
+
export { default as Chart } from './Chart';
|
|
16
|
+
export * from './Chart/types';
|
|
15
17
|
export { default as CheckBox } from './CheckBox';
|
|
16
18
|
export * from './CheckBox/types';
|
|
17
19
|
export { default as ColorScheme } from './ColorScheme';
|
package/dist/cjs/comps/index.js
CHANGED
|
@@ -12,6 +12,8 @@ export * from './Avatar/types';
|
|
|
12
12
|
export { default as Box } from './Box';
|
|
13
13
|
export { default as Button } from './Button';
|
|
14
14
|
export * from './Button/types';
|
|
15
|
+
export { default as Chart } from './Chart';
|
|
16
|
+
export * from './Chart/types';
|
|
15
17
|
export { default as CheckBox } from './CheckBox';
|
|
16
18
|
export * from './CheckBox/types';
|
|
17
19
|
export { default as ColorScheme } from './ColorScheme';
|
|
@@ -308,11 +308,13 @@ export const cssDirect = {
|
|
|
308
308
|
"translate": "transform: translate(__VALUE__);",
|
|
309
309
|
"translateX": "transform: translateX(__VALUE__);",
|
|
310
310
|
"translateY": "transform: translateY(__VALUE__);",
|
|
311
|
+
"translateZ": "transform: translateZ(__VALUE__);",
|
|
311
312
|
"x": "transform: translateX(__VALUE__);",
|
|
312
313
|
"y": "transform: translateY(__VALUE__);",
|
|
314
|
+
"z": "transform: translateZ(__VALUE__);",
|
|
313
315
|
"rotate": "transform: rotate(__VALUE__);",
|
|
314
316
|
"rotateX": "transform: rotateX(__VALUE__);",
|
|
315
|
-
"rotateY": "transform:
|
|
317
|
+
"rotateY": "transform: rotateY(__VALUE__);",
|
|
316
318
|
"rotateZ": "transform: rotateZ(__VALUE__);",
|
|
317
319
|
"rotate3d": "transform: rotate3d(__X__, __Y__, __Z__, __A__);",
|
|
318
320
|
"scale": "transform: scale(__VALUE__);",
|
|
@@ -11,6 +11,7 @@ export { default as useDebounce } from './useDebounce';
|
|
|
11
11
|
export { default as useDelayed, default as useMounted } from './useDelayed';
|
|
12
12
|
export { default as useDevice } from './useDevice';
|
|
13
13
|
export { default as useDimensions } from './useDimensions';
|
|
14
|
+
export { default as useLineChart, type DataPoint, type LineChartProps, type UseLineChartDimensions, type UseLineChartReturn } from './useLineChart';
|
|
14
15
|
export { default as useMediaPlayer, type MediaPlayerProps, type MediaType } from './useMediaPlayer';
|
|
15
16
|
export { default as useMergedRefs } from './useMergedRefs';
|
|
16
17
|
export { default as useMutationObserver, type MutationCallback } from './useMutationObserver';
|
|
@@ -26,6 +27,7 @@ export { default as useScrollPhysics } from './useScrollPhysics';
|
|
|
26
27
|
export { default as useSheet } from './useSheet';
|
|
27
28
|
export { default as useShortcuts } from './useShortcuts';
|
|
28
29
|
export { default as useNetworkStatus } from './useNetworkStatus';
|
|
30
|
+
export { default as usePosition } from './usePosition';
|
|
29
31
|
export { default as useResizeObserver } from './useResizeObserver';
|
|
30
32
|
export { default as useSlider } from './useSlider';
|
|
31
33
|
export { default as useToast } from './useToast';
|
package/dist/cjs/hooks/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export { default as useDebounce } from './useDebounce';
|
|
|
11
11
|
export { default as useDelayed, default as useMounted } from './useDelayed';
|
|
12
12
|
export { default as useDevice } from './useDevice';
|
|
13
13
|
export { default as useDimensions } from './useDimensions';
|
|
14
|
+
export { default as useLineChart } from './useLineChart';
|
|
14
15
|
export { default as useMediaPlayer } from './useMediaPlayer';
|
|
15
16
|
export { default as useMergedRefs } from './useMergedRefs';
|
|
16
17
|
export { default as useMutationObserver } from './useMutationObserver';
|
|
@@ -27,6 +28,7 @@ export { default as useScrollPhysics } from './useScrollPhysics';
|
|
|
27
28
|
export { default as useSheet } from './useSheet';
|
|
28
29
|
export { default as useShortcuts } from './useShortcuts';
|
|
29
30
|
export { default as useNetworkStatus } from './useNetworkStatus';
|
|
31
|
+
export { default as usePosition } from './usePosition';
|
|
30
32
|
export { default as useResizeObserver } from './useResizeObserver';
|
|
31
33
|
export { default as useSlider } from './useSlider';
|
|
32
34
|
export { default as useToast } from './useToast';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface DataPoint {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
export interface UseLineChartDimensions {
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
9
|
+
export interface UseLineChartReturn {
|
|
10
|
+
pathD: string;
|
|
11
|
+
areaPathD: string;
|
|
12
|
+
}
|
|
13
|
+
export interface LineChartProps {
|
|
14
|
+
data: DataPoint[];
|
|
15
|
+
width?: string | number;
|
|
16
|
+
height?: string | number;
|
|
17
|
+
lineColor?: string;
|
|
18
|
+
strokeWidth?: number;
|
|
19
|
+
gradientStartColor?: string;
|
|
20
|
+
gradientEndColor?: string;
|
|
21
|
+
padding?: number;
|
|
22
|
+
animated?: boolean;
|
|
23
|
+
}
|
|
24
|
+
declare const useLineChart: (data: DataPoint[], dimensions?: UseLineChartDimensions, padding?: number) => UseLineChartReturn;
|
|
25
|
+
export default useLineChart;
|