@zuzjs/ui 0.4.5 → 0.4.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.
@@ -0,0 +1,14 @@
1
+ import { ReactNode } from "react";
2
+ import { DRAWER_SIDE } from "../types/enums";
3
+ export interface DrawerProps {
4
+ as?: string;
5
+ speed?: number;
6
+ from?: DRAWER_SIDE;
7
+ children: string | ReactNode | ReactNode[];
8
+ }
9
+ export interface DrawerHandler {
10
+ open: () => void;
11
+ close: () => void;
12
+ }
13
+ declare const Drawer: import("react").ForwardRefExoticComponent<DrawerProps & import("react").RefAttributes<DrawerHandler>>;
14
+ export default Drawer;
@@ -0,0 +1,46 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { forwardRef, useImperativeHandle, useMemo, useRef, useState } from "react";
3
+ import With from "./base";
4
+ import { DRAWER_SIDE, TRANSITION_CURVES, TRANSITIONS } from "../types/enums";
5
+ const Drawer = forwardRef((props, ref) => {
6
+ const { as, from, speed, children, ...rest } = props;
7
+ const [visible, setVisible] = useState(false);
8
+ const divRef = useRef(null);
9
+ const style = useMemo(() => {
10
+ switch (from) {
11
+ case DRAWER_SIDE.Left:
12
+ return { from: { x: `-100vh` }, to: { x: 0 } };
13
+ case DRAWER_SIDE.Right:
14
+ return { from: { x: `100vh` }, to: { x: 0 } };
15
+ case DRAWER_SIDE.Top:
16
+ return { from: { y: `-100vh` }, to: { y: 0 } };
17
+ case DRAWER_SIDE.Bottom:
18
+ return { from: { y: `100vh` }, to: { y: 0 } };
19
+ default:
20
+ return { from: { x: `-100vh` }, to: { x: 0 } };
21
+ }
22
+ }, []);
23
+ useImperativeHandle(ref, () => ({
24
+ open() {
25
+ setVisible(true);
26
+ },
27
+ close() {
28
+ setVisible(false);
29
+ }
30
+ }));
31
+ return _jsxs(_Fragment, { children: [_jsx(With, { className: `zuz-overlay fixed fill`, onClick: (e) => {
32
+ if (visible) {
33
+ setVisible(false);
34
+ }
35
+ }, "aria-hidden": !visible, animate: {
36
+ transition: TRANSITIONS.FadeIn,
37
+ when: visible,
38
+ } }), _jsxs(With, { ref: divRef, as: as, className: `zuz-drawer flex cols drawer-${from ? from.toLowerCase() : `left`} fixed`, animate: {
39
+ from: { ...style.from, opacity: 0 },
40
+ to: { ...style.to, opacity: 1 },
41
+ when: visible,
42
+ curve: TRANSITION_CURVES.EaseInOut,
43
+ duration: speed || .5,
44
+ }, ...rest, children: [from == DRAWER_SIDE.Top || from == DRAWER_SIDE.Bottom ? _jsx(With, { className: "drawer-handle" }) : null, children] })] });
45
+ });
46
+ export default Drawer;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { animationProps } from "./base";
3
+ declare const TextWheel: React.ForwardRefExoticComponent<{
4
+ as?: string;
5
+ direction?: `up` | `down`;
6
+ value: number | string;
7
+ color?: string;
8
+ animate?: animationProps;
9
+ } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
10
+ export default TextWheel;
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef } from 'react';
3
+ import With from "./base";
4
+ const TextWheel = forwardRef((props, ref) => {
5
+ const { as, value, color, direction, ...rest } = props;
6
+ return _jsxs(With, { className: `text-wheel flex aic rel`, "aria-hidden": true, as: as, ref: ref, ...rest, children: [value.toString().split('').map((char, index) => {
7
+ if (isNaN(parseInt(char, 10))) {
8
+ return _jsx(With, { tag: `span`, className: "wheel-char wheel-char-symbol grid", children: char }, `wheel-char-${index}`);
9
+ }
10
+ return _jsx(With, { tag: `span`, "data-value": char, className: `wheel-char grid ${index > char.toString().split('').length - 3 ? 'wheel-fraction' : ''}`.trim(), children: _jsxs(With, { tag: `span`, className: `wheel-char-track wheel-track-${direction || `down`} grid`, style: {
11
+ '--v': char
12
+ }, children: [_jsx(With, { tag: `span`, children: !direction || direction == `down` ? 0 : 9 }), (!direction || direction == `down` ?
13
+ [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
14
+ : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]).map((val, indx) => {
15
+ return _jsx(With, { tag: `span`, children: val }, `${index}--${indx}`);
16
+ }), _jsx(With, { tag: `span`, children: !direction || direction == `down` ? 9 : 0 })] }) }, `wheel-char-${index}`);
17
+ }), color && _jsx(With, { className: `abs fill`, style: {
18
+ zIndex: 1,
19
+ background: `linear-gradient(0deg, ${color}, transparent, transparent, transparent, ${color})`,
20
+ } })] });
21
+ });
22
+ export default TextWheel;
@@ -34,7 +34,6 @@ declare class CSS {
34
34
  makeValue(k: string, v: any): string;
35
35
  calcIndexes(str: string): string;
36
36
  makeID2(k: string, v: string, _out: string): string;
37
- makeID3(k: string, v: string, _out: string): string;
38
37
  makeID(k: string, v: string, _out: string): string;
39
38
  lexer(line: string): dynamicObject;
40
39
  processLine(line: string): void;
package/dist/funs/css.js CHANGED
@@ -364,39 +364,6 @@ class CSS {
364
364
  return _indices.join(``);
365
365
  }
366
366
  makeID2(k, v, _out) {
367
- const self = this;
368
- let _ = [];
369
- const out = _out.replace(/\s+/g, ``).trim();
370
- const _mi = (_k, _v) => {
371
- let i = Math.abs(self.DIRECT_KEYS.indexOf(_k)) + Math.abs(self.PROPS_VALUES.indexOf(_k));
372
- _.push(i);
373
- const nums = _v.match(/[0-9]/g);
374
- if (nums) {
375
- let ii = Math.abs(+nums.join(``));
376
- _.push(ii);
377
- i += ii;
378
- }
379
- const abc = _v.match(/[a-zA-Z,/-\[\]]/g);
380
- if (abc) {
381
- const ai = abc.reduce((acc, char) => acc + self.chars.indexOf(char), 0);
382
- _.push(ai);
383
- i += ai;
384
- }
385
- return i;
386
- };
387
- const [_ok, _ov] = out.split(`:`);
388
- const ok = _ok.trim();
389
- const ov = _ov.trim();
390
- let _cp = ok.charAt(0);
391
- if (self.PROPS[ok]?.indexOf("-") > -1) {
392
- _cp = "";
393
- self.PROPS[ok].split("-").map((c) => _cp += c.charAt(0));
394
- }
395
- const io = self.DIRECT_VALUES.includes(out) ? self.DIRECT_VALUES.indexOf(out) : _mi(ok, ov);
396
- const id = `${_cp}${self.hashids.encode(io, _mi(k, v))}`;
397
- return id;
398
- }
399
- makeID3(k, v, _out) {
400
367
  const self = this;
401
368
  const md = md5(_out);
402
369
  let _ = [];
@@ -421,6 +388,9 @@ class CSS {
421
388
  const [_ok, _ov] = out.split(`:`);
422
389
  const ok = _ok.trim();
423
390
  const ov = _ov.trim();
391
+ if (ov == ``) {
392
+ throw new TypeError(`${ok} value is empty.`);
393
+ }
424
394
  let _cp = ok.charAt(0);
425
395
  if (self.PROPS[ok]?.indexOf("-") > -1) {
426
396
  _cp = "";
@@ -432,7 +402,7 @@ class CSS {
432
402
  }
433
403
  makeID(k, v, _out) {
434
404
  const self = this;
435
- return self.makeID3(k, v, _out);
405
+ return self.makeID2(k, v, _out);
436
406
  const _css = _out.toString().replace(/;|:|\s/g, "");
437
407
  let _indices = 0;
438
408
  for (let i = 0; i < _css.length; i++) {
@@ -696,6 +666,9 @@ export const getAnimationCurve = (curve) => {
696
666
  case TRANSITION_CURVES.Spring:
697
667
  return `cubic-bezier(0.2, -0.36, 0, 1.46)`;
698
668
  break;
669
+ case TRANSITION_CURVES.EaseInOut:
670
+ return `cubic-bezier(0.42, 0, 0.58, 1)`;
671
+ break;
699
672
  default:
700
673
  return `linear`;
701
674
  }
@@ -717,6 +690,10 @@ export const getAnimationTransition = (transition, to, from) => {
717
690
  _from = { scale: 0, opacity: 0 };
718
691
  _to = { scale: 1, opacity: 1 };
719
692
  break;
693
+ case TRANSITIONS.FadeIn:
694
+ _from = { opacity: 0 };
695
+ _to = { opacity: 1 };
696
+ break;
720
697
  }
721
698
  return to ? { ..._from, ..._to } : from ? _from : _to;
722
699
  };
@@ -0,0 +1,14 @@
1
+ export interface Event {
2
+ event: String | Symbol;
3
+ listeners: (() => void)[];
4
+ }
5
+ declare class Events {
6
+ _events: Event[];
7
+ constructor();
8
+ addEvent(event: String | Symbol, fun: (...args: any[]) => void): number | undefined;
9
+ removeEvent(event: String | Symbol, fun: (...args: any[]) => void): void;
10
+ on(event: String | Symbol, fun: (...args: any[]) => void): number | undefined;
11
+ off(event: String | Symbol, fun: (...args: any[]) => void): void;
12
+ emit(event: String | Symbol, ...args: any[]): void;
13
+ }
14
+ export default Events;
@@ -0,0 +1,41 @@
1
+ class Events {
2
+ _events;
3
+ constructor() {
4
+ this._events = [];
5
+ }
6
+ addEvent(event, fun) {
7
+ const evt = this._events.find(x => x.event == event);
8
+ if (!evt) {
9
+ return this._events.push({ event: event, listeners: [fun] });
10
+ }
11
+ if (!evt.listeners.find(x => x == fun)) {
12
+ evt.listeners.push(fun);
13
+ }
14
+ }
15
+ removeEvent(event, fun) {
16
+ const evt = this._events.find(x => x.event == event);
17
+ if (evt) {
18
+ evt.listeners = evt.listeners.filter(x => x != fun);
19
+ }
20
+ }
21
+ on(event, fun) {
22
+ return this.addEvent(event, fun);
23
+ }
24
+ off(event, fun) {
25
+ this.removeEvent(event, fun);
26
+ }
27
+ emit(event, ...args) {
28
+ const self = this;
29
+ const evt = this._events.find(x => x.event == event);
30
+ if (evt) {
31
+ evt.listeners.forEach((f) => {
32
+ try {
33
+ f.apply(self, args);
34
+ }
35
+ catch (e) {
36
+ }
37
+ });
38
+ }
39
+ }
40
+ }
41
+ export default Events;
@@ -1,5 +1,6 @@
1
1
  import CSS from './css.js';
2
2
  import { dynamicObject } from "../types/index.js";
3
+ import { FormatNumberParams } from "../types/interfaces.js";
3
4
  export declare const __SALT: string;
4
5
  export declare const FIELNAME_KEY = "__FILENAME__";
5
6
  export declare const LINE_KEY = "__LINE__";
@@ -27,13 +28,10 @@ export declare const setDeep: (object: dynamicObject, path: string, value: any,
27
28
  export declare const removeDuplicatesFromArray: <T>(array: T[]) => T[];
28
29
  export declare const extendGlobals: () => void;
29
30
  export declare const withPost: (uri: string, data: dynamicObject, timeout?: number, fd?: dynamicObject) => Promise<unknown>;
30
- export declare const useDevice: () => {
31
- isMobile: boolean;
32
- isTablet: boolean;
33
- isDesktop: boolean;
34
- };
35
31
  export declare const withTime: (fun: (...args: any[]) => any) => {
36
32
  result: any;
37
33
  executionTime: number;
38
34
  };
39
35
  export declare const time: (stamp?: number, format?: string) => string;
36
+ export declare const arrayRand: (arr: any[]) => any;
37
+ export declare const formatNumber: ({ number, locale, style, decimal, currency }: FormatNumberParams) => string;
@@ -154,16 +154,6 @@ export const withPost = async (uri, data, timeout = 60, fd = {}) => {
154
154
  .catch(err => reject(err));
155
155
  });
156
156
  };
157
- export const useDevice = () => {
158
- const userAgent = navigator.userAgent;
159
- const mobile = /Mobi|Android/i.test(userAgent);
160
- const tablet = /Tablet|iPad/i.test(userAgent);
161
- return {
162
- isMobile: mobile,
163
- isTablet: tablet,
164
- isDesktop: !mobile && !tablet
165
- };
166
- };
167
157
  export const withTime = (fun) => {
168
158
  const start = new Date().getTime();
169
159
  const result = fun();
@@ -178,3 +168,25 @@ export const time = (stamp, format) => {
178
168
  moment.unix(+stamp / 1000).format(format || `YYYY-MM-DD HH:mm:ss`)
179
169
  : moment().format(format || `YYYY-MM-DD HH:mm:ss`);
180
170
  };
171
+ export const arrayRand = (arr) => arr[Math.floor(Math.random() * arr.length)];
172
+ export const formatNumber = ({ number, locale = 'en-US', style = `decimal`, decimal = 2, currency }) => {
173
+ if (style === 'currency' && !currency) {
174
+ throw new TypeError('Currency code is required with currency style.');
175
+ }
176
+ if (currency) {
177
+ const { code, style: currencyStyle, symbol } = currency;
178
+ const out = new Intl.NumberFormat(locale, {
179
+ style: `currency`,
180
+ currency: code,
181
+ currencyDisplay: currencyStyle,
182
+ minimumFractionDigits: +number % 1 > 0 ? decimal : 0,
183
+ maximumFractionDigits: +number % 1 > 0 ? decimal : 0
184
+ }).format(+number);
185
+ return symbol ? out.replace(new RegExp(`\\${code}`, 'g'), symbol) : out;
186
+ }
187
+ return new Intl.NumberFormat(locale, {
188
+ style,
189
+ minimumFractionDigits: +number % 1 > 0 ? 2 : 0,
190
+ maximumFractionDigits: +number % 1 > 0 ? 2 : 0
191
+ }).format(+number);
192
+ };
@@ -288,6 +288,13 @@ export const cssDirect = {
288
288
  "inlineblock": "display: inline-block;",
289
289
  "blur": "filter: blur(__VALUE__);",
290
290
  "ratio": "aspect-ratio: __VALUE__;",
291
+ "center-h": "left: 50%;transform: translateX(-50%);",
292
+ "center-v": "top: 50%;transform: translateY(-50%);",
293
+ "no-overflow": "overflow: hidden;",
294
+ "overflow-x": "overflow-x: auto;",
295
+ "overflow-y": "overflow-x: auto;",
296
+ "space-pre": "white-space: pre;",
297
+ "text-wrap": "width: 98%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;",
291
298
  };
292
299
  export const cssAnimationCurves = {
293
300
  ease: 'ease',
@@ -1 +1,4 @@
1
+ export { default as useDevice } from './useDevice';
2
+ export { default as useDimensions } from './useDimensions';
1
3
  export { default as useMounted } from './useMounted';
4
+ export * from './usePubSub';
@@ -1 +1,4 @@
1
+ export { default as useDevice } from './useDevice';
2
+ export { default as useDimensions } from './useDimensions';
1
3
  export { default as useMounted } from './useMounted';
4
+ export * from './usePubSub';
@@ -0,0 +1,7 @@
1
+ import { Dimensions } from './useDimensions';
2
+ declare const useDevice: () => {
3
+ isMobile: boolean;
4
+ isTablet: boolean;
5
+ isDesktop: boolean;
6
+ } & Dimensions;
7
+ export default useDevice;
@@ -0,0 +1,17 @@
1
+ import { useEffect } from 'react';
2
+ import useDimensions from './useDimensions';
3
+ const useDevice = () => {
4
+ const userAgent = navigator.userAgent;
5
+ const mobile = /Mobi|Android/i.test(userAgent);
6
+ const tablet = /Tablet|iPad/i.test(userAgent);
7
+ const dims = useDimensions();
8
+ useEffect(() => {
9
+ }, []);
10
+ return {
11
+ isMobile: mobile,
12
+ isTablet: tablet,
13
+ isDesktop: !mobile && !tablet,
14
+ ...dims
15
+ };
16
+ };
17
+ export default useDevice;
@@ -0,0 +1,13 @@
1
+ import { ReactNode } from 'react';
2
+ export interface Dimensions {
3
+ width: number;
4
+ height: number;
5
+ top: number;
6
+ left: number;
7
+ bottom: number;
8
+ right: number;
9
+ x: number;
10
+ y: number;
11
+ }
12
+ declare const useDimensions: (el?: HTMLElement | ReactNode) => Dimensions;
13
+ export default useDimensions;
@@ -0,0 +1,47 @@
1
+ import { useState, useEffect } from 'react';
2
+ const useDimensions = (el) => {
3
+ const [dims, setDims] = useState({
4
+ width: 0,
5
+ height: 0,
6
+ top: 0,
7
+ left: 0,
8
+ bottom: 0,
9
+ right: 0,
10
+ x: 0,
11
+ y: 0
12
+ });
13
+ const update = () => {
14
+ if (el) {
15
+ const { width, height, top, left, bottom, right, x, y } = el.getBoundingClientRect();
16
+ setDims({
17
+ width,
18
+ height,
19
+ top,
20
+ left,
21
+ bottom,
22
+ right,
23
+ x,
24
+ y
25
+ });
26
+ }
27
+ else {
28
+ setDims({
29
+ width: window.innerWidth,
30
+ height: window.innerHeight,
31
+ top: 0,
32
+ left: 0,
33
+ bottom: 0,
34
+ right: 0,
35
+ x: 0,
36
+ y: 0
37
+ });
38
+ }
39
+ };
40
+ useEffect(() => {
41
+ update();
42
+ window.addEventListener("resize", update);
43
+ return () => window.removeEventListener("resize", update);
44
+ }, []);
45
+ return dims;
46
+ };
47
+ export default useDimensions;
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,3 @@
1
+ declare const useSub: (event: String | Symbol, fun: () => void) => () => void;
2
+ declare const usePub: () => (event: String | Symbol) => void;
3
+ export { useSub, usePub };
@@ -0,0 +1,19 @@
1
+ import { useEffect } from "react";
2
+ import Events from "../funs/events";
3
+ const events = new Events();
4
+ const useSub = (event, fun) => {
5
+ const unsubscribe = () => {
6
+ events.off(event, fun);
7
+ };
8
+ useEffect(() => {
9
+ events.on(event, fun);
10
+ return;
11
+ }, []);
12
+ return unsubscribe;
13
+ };
14
+ const usePub = () => {
15
+ return (event) => {
16
+ events.emit(event);
17
+ };
18
+ };
19
+ export { useSub, usePub };
@@ -0,0 +1,3 @@
1
+ declare const useSub: (event: String | Symbol, fun: () => void) => () => void;
2
+ declare const usePub: () => void;
3
+ export { useSub, usePub };
@@ -0,0 +1,17 @@
1
+ import { useEffect } from "react";
2
+ import Events from "../funs/events";
3
+ const events = new Events();
4
+ const useSub = (event, fun) => {
5
+ const unsubscribe = () => {
6
+ events.off(event, fun);
7
+ };
8
+ useEffect(() => {
9
+ events.on(event, fun);
10
+ return;
11
+ }, []);
12
+ return unsubscribe;
13
+ };
14
+ const usePub = () => {
15
+ return;
16
+ };
17
+ export { useSub, usePub };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  export { withZuz as css } from './funs';
2
2
  export * from "./funs";
3
3
  export * from "./hooks";
4
+ export { default as PubSub } from "./funs/events";
4
5
  export { default as Box } from "./comps/box";
5
6
  export { default as Button } from "./comps/button";
6
7
  export { default as CheckBox } from "./comps/checkbox";
7
8
  export { default as ContextMenu } from "./comps/contextmenu";
8
9
  export { default as Cover } from "./comps/cover";
10
+ export { default as Drawer } from "./comps/drawer";
9
11
  export { default as Form } from "./comps/form";
10
12
  export { default as Heading } from "./comps/heading";
11
13
  export { default as Text } from "./comps/heading";
@@ -15,4 +17,5 @@ export { default as Input } from "./comps/input";
15
17
  export { default as Select } from "./comps/select";
16
18
  export { default as Sheet } from "./comps/sheet";
17
19
  export { default as Spinner } from "./comps/spinner";
18
- export { SHEET, FORMVALIDATION, FORMVALIDATION_STYLE, SPINNER, TRANSITIONS, TRANSITION_CURVES } from "./types/enums";
20
+ export { default as TextWheel } from "./comps/textwheel";
21
+ export { DRAWER_SIDE, SHEET, FORMVALIDATION, FORMVALIDATION_STYLE, SPINNER, TRANSITIONS, TRANSITION_CURVES } from "./types/enums";
package/dist/index.js CHANGED
@@ -1,11 +1,13 @@
1
1
  export { withZuz as css } from './funs';
2
2
  export * from "./funs";
3
3
  export * from "./hooks";
4
+ export { default as PubSub } from "./funs/events";
4
5
  export { default as Box } from "./comps/box";
5
6
  export { default as Button } from "./comps/button";
6
7
  export { default as CheckBox } from "./comps/checkbox";
7
8
  export { default as ContextMenu } from "./comps/contextmenu";
8
9
  export { default as Cover } from "./comps/cover";
10
+ export { default as Drawer } from "./comps/drawer";
9
11
  export { default as Form } from "./comps/form";
10
12
  export { default as Heading } from "./comps/heading";
11
13
  export { default as Text } from "./comps/heading";
@@ -15,4 +17,5 @@ export { default as Input } from "./comps/input";
15
17
  export { default as Select } from "./comps/select";
16
18
  export { default as Sheet } from "./comps/sheet";
17
19
  export { default as Spinner } from "./comps/spinner";
18
- export { SHEET, FORMVALIDATION, FORMVALIDATION_STYLE, SPINNER, TRANSITIONS, TRANSITION_CURVES } from "./types/enums";
20
+ export { default as TextWheel } from "./comps/textwheel";
21
+ export { DRAWER_SIDE, SHEET, FORMVALIDATION, FORMVALIDATION_STYLE, SPINNER, TRANSITIONS, TRANSITION_CURVES } from "./types/enums";
package/dist/styles.css CHANGED
@@ -1 +1 @@
1
- *,*::before,*::after{box-sizing:border-box}button{user-select:none;cursor:pointer}input{user-select:none}input:-webkit-autofill{background-color:rgba(0,0,0,0) !important;-webkit-box-shadow:0 0 0px 1000px rgba(0,0,0,0) inset;box-shadow:0 0 0px 1000px rgba(0,0,0,0) inset}[popover]{margin:0;padding:0;border:0}:root{--checkbox-checked: rgb(46, 161, 42);--checkbox-unchecked: rgb(203, 203, 203);--checkbox-thumb: #fff;--checkbox-thumb-shadow: #000;--checkbox-thumb-shadow-size: 2px;--select: #fff;--select-options: #fff;--select-option-font-size: 16px;--select-hover: #eee;--select-selected: #ddd;--select-padding: 6px 8px;--select-radius: 5px;--cover-bg: rgba(255,255,255,0.8);--cover-label: #111;--dialog-bg: #fff;--dialog-radius: 10px;--dialog-padding: 10px;--dialog-title-font-size: 16px;--dialog-closer-font-size: 36px;--dialog-closer-hover: rgba(255,255,255,0.2);--sheet-error: #ff4747;--sheet-warn: #ffba00;--sheet-success: #23ac28}.flex{display:flex}.flex.cols{flex-direction:column}.flex.aic{align-items:center}.flex.jcc{justify-content:center}.abs{position:absolute}.fixed{position:fixed}.fill{top:0px;left:0px;bottom:0px;right:0px}.fillx{top:-10px;left:-10px;bottom:-10px;right:-10px}.nope{pointer-events:none}.nous{user-select:none}.rel{position:relative}.ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.input-with-error{box-shadow:inset 0px 0px 0px 1px #ff8b8b}.zuz-checkbox{height:25px;width:45px;cursor:pointer}.zuz-checkbox input[type=checkbox]{z-index:0;left:10px;top:10px;opacity:0}.zuz-checkbox:before{content:"";position:absolute;width:45px;height:25px;background:var(--checkbox-unchecked);border-radius:50px;z-index:1;transition:all .3s linear 0s}.zuz-checkbox:after{content:"";position:absolute;width:21px;height:21px;background:var(--checkbox-thumb);border-radius:50px;z-index:2;top:2px;left:2px;box-shadow:0px 0px --checkbox-thumb-shadow-size --checkbox-thumb-shadow;transition:all .2s linear 0s}.zuz-checkbox.is-checked:before{box-shadow:inset 0px 0px 0px 15px var(--checkbox-checked)}.zuz-checkbox.is-checked:after{transform:translateX(20px)}.zuz-spinner{animation:spin infinite}@keyframes spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}.zuz-cover{backdrop-filter:blur(4px);z-index:99999;gap:15px}.zuz-cover .label{font-size:14px;animation:breath 1s linear infinite}@keyframes breath{0%{opacity:.5}50%{opacity:1}100%{opacity:.5}}.zuz-toast,.zuz-sheet.toast-warn,.zuz-sheet.toast-success,.zuz-sheet.toast-error,.zuz-sheet.toast-default{border-radius:6px;padding:6px 12px;font-size:14px;white-space:pre}.zuz-sheet{top:50%;left:50%;transform:translate(-50%, -50%);z-index:214748364;transform-origin:top left;transition:all .5s cubic-bezier(0.2, -0.36, 0, 1.46) 0s}.zuz-sheet.wobble{transform-origin:inherit !important}.zuz-sheet.toast-default{background:#333;color:#fff;top:10px !important}.zuz-sheet.toast-error{background:var(--sheet-error);color:#fff;top:10px}.zuz-sheet.toast-success{background:var(--sheet-success);color:#fff;top:10px}.zuz-sheet.toast-warn{background:var(--sheet-warn);color:#111;top:10px}.zuz-sheet.toast-dialog{background:var(--dialog-bg);border-radius:var(--dialog-radius);padding:var(--dialog-padding);overflow:hidden}.zuz-sheet .zuz-sheet-head{margin-bottom:20px}.zuz-sheet .zuz-sheet-head .zuz-sheet-title{flex:1;font-size:var(--dialog-title-font-size);opacity:.5;text-align:center;padding:0px 45px}.zuz-sheet .zuz-sheet-head .zuz-sheet-dot{flex:1}.zuz-sheet .zuz-sheet-head .zuz-sheet-closer{width:32px;height:32px;cursor:pointer;font-size:var(--dialog-closer-font-size);background:rgba(0,0,0,0);border:0px;line-height:0;padding:0px;font-weight:normal;border-radius:20px;opacity:.35;top:50%;right:0px;transform:translateY(-50%)}.zuz-sheet .zuz-sheet-head .zuz-sheet-closer:hover{background:var(--dialog-closer-hover);opacity:1}.zuz-sheet-overlay{background:rgba(0,0,0,.7);z-index:111;backdrop-filter:blur(10px)}.zuz-context-menu{z-index:99;background:var(--context-background);border-radius:var(--context-radius);padding:10px;box-shadow:var(--context-shadow)}.zuz-context-menu .context-line{height:1px;background:var(--context-seperator);margin:3px 6px}.zuz-context-menu .context-menu-item{width:220px;padding:6px 10px;gap:10px;cursor:pointer;font-size:var(--context-label-size);border-radius:var(--context-radius)}.zuz-context-menu .context-menu-item .ico{font-size:var(--context-icon-size)}.zuz-context-menu .context-menu-item:hover{background:var(--context-hover)}@position-try --zuz-select-bottom{top:anchor(bottom);bottom:unset;margin-block:calc(var(--zuz-select-height) + var(--zuz-select-gap)) 0}.zuz-selectk-wrap{width:100%}.zuz-select{width:100%;gap:5px;background:var(--select);border-radius:var(--select-radius);border:0px;padding:12px 15px;anchor-name:--zuz-select-anchor}.zuz-select:hover{background:var(--select-hover)}.zuz-select .zuz-selected{flex:1;text-align:left}.zuz-select-options{--zuz-select-height: 30px;--zuz-select-gap: 0px;position-anchor:--zuz-select-anchor;position-try:most-height --zuz-select-bottom;width:100%;max-height:400px;overflow-x:hidden;gap:2px;background:var(--select-options);border-radius:var(--select-radius);padding:4px 0px}.zuz-select-options button{background:rgba(0,0,0,0);border:0px;text-align:left;padding:var(--select-padding);border-radius:var(--select-radius);font-size:var(--select-option-font-size)}.zuz-select-options button:hover{background:var(--select-hover)}.zuz-select-options button.selected{background:var(--select-selected)}
1
+ *,*::before,*::after{box-sizing:border-box;-webkit-tap-highlight-color:rgba(0,0,0,0)}button{user-select:none;cursor:pointer}input{user-select:none}input:-webkit-autofill{background-color:rgba(0,0,0,0) !important;-webkit-box-shadow:0 0 0px 1000px rgba(0,0,0,0) inset;box-shadow:0 0 0px 1000px rgba(0,0,0,0) inset}[aria-hidden=true]{user-select:none;pointer-events:none}[popover]{margin:0;padding:0;border:0}:root{--basic: ease;--back: linear( 0, -0.0077 5.2%, -0.0452 16.98%, -0.0493 22.35%, -0.0418 25.57%, -0.0258 28.57%, -0.0007 31.42%, 0.0335 34.15%, 0.1242 39.03%, 0.2505 43.65%, 0.3844 47.35%, 0.656 53.68%, 0.81 58.37%, 0.9282 63.52%, 0.9719 66.23%, 1.0055 69.04%, 1.0255 71.4%, 1.0396 73.87%, 1.0477 76.48%, 1.05 79.27%, 1.0419 84.36%, 1.0059 95.49%, 1 );--expo: linear( 0, 0.0053 17.18%, 0.0195 26.59%, 0.0326 30.31%, 0.0506 33.48%, 0.0744 36.25%, 0.1046 38.71%, 0.1798 42.62%, 0.2846 45.93%, 0.3991 48.37%, 0.6358 52.29%, 0.765 55.45%, 0.8622 59.3%, 0.8986 61.51%, 0.9279 63.97%, 0.9481 66.34%, 0.9641 69.01%, 0.9856 75.57%, 0.9957 84.37%, 1 );--sine: linear( 0, 0.007 5.35%, 0.0282 10.75%, 0.0638 16.26%, 0.1144 21.96%, 0.1833 28.16%, 0.2717 34.9%, 0.6868 62.19%, 0.775 68.54%, 0.8457 74.3%, 0.9141 81.07%, 0.9621 87.52%, 0.9905 93.8%, 1 );--power: linear( 0, 0.0012 14.95%, 0.0089 22.36%, 0.0297 28.43%, 0.0668 33.43%, 0.0979 36.08%, 0.1363 38.55%, 0.2373 43.07%, 0.3675 47.01%, 0.5984 52.15%, 0.7121 55.23%, 0.8192 59.21%, 0.898 63.62%, 0.9297 66.23%, 0.9546 69.06%, 0.9733 72.17%, 0.9864 75.67%, 0.9982 83.73%, 1 );--circ: linear( -0, 0.0033 5.75%, 0.0132 11.43%, 0.0296 16.95%, 0.0522 22.25%, 0.0808 27.25%, 0.1149 31.89%, 0.1542 36.11%, 0.1981 39.85%, 0.2779 44.79%, 0.3654 48.15%, 0.4422 49.66%, 0.5807 50.66%, 0.6769 53.24%, 0.7253 55.37%, 0.7714 58.01%, 0.8142 61.11%, 0.8536 64.65%, 0.9158 72.23%, 0.9619 80.87%, 0.9904 90.25%, 1 );--bounce: linear( 0, 0.0039, 0.0157, 0.0352, 0.0625 9.09%, 0.1407, 0.25, 0.3908, 0.5625, 0.7654, 1, 0.8907, 0.8125 45.45%, 0.7852, 0.7657, 0.7539, 0.75, 0.7539, 0.7657, 0.7852, 0.8125 63.64%, 0.8905, 1 72.73%, 0.9727, 0.9532, 0.9414, 0.9375, 0.9414, 0.9531, 0.9726, 1, 0.9883, 0.9844, 0.9883, 1 );--elastic: linear( 0, 0.0009 8.51%, -0.0047 19.22%, 0.0016 22.39%, 0.023 27.81%, 0.0237 30.08%, 0.0144 31.81%, -0.0051 33.48%, -0.1116 39.25%, -0.1181 40.59%, -0.1058 41.79%, -0.0455, 0.0701 45.34%, 0.9702 55.19%, 1.0696 56.97%, 1.0987 57.88%, 1.1146 58.82%, 1.1181 59.83%, 1.1092 60.95%, 1.0057 66.48%, 0.986 68.14%, 0.9765 69.84%, 0.9769 72.16%, 0.9984 77.61%, 1.0047 80.79%, 0.9991 91.48%, 1 );--ease: var(--back);--text-wheel-speed: 2;--text-wheel-transition: translate calc(var(--text-wheel-speed) * 1s) var(--ease);--checkbox-checked: rgb(46, 161, 42);--checkbox-unchecked: rgb(203, 203, 203);--checkbox-thumb: #fff;--checkbox-thumb-shadow: #000;--checkbox-thumb-shadow-size: 2px;--select: #fff;--select-options: #fff;--select-option-font-size: 16px;--select-hover: #eee;--select-selected: #ddd;--select-padding: 6px 8px;--select-radius: 5px;--cover-bg: rgba(255,255,255,0.8);--cover-label: #111;--dialog-bg: #fff;--dialog-radius: 10px;--dialog-padding: 10px;--dialog-title-font-size: 16px;--dialog-closer-font-size: 36px;--dialog-closer-hover: rgba(255,255,255,0.2);--sheet-error: #ff4747;--sheet-warn: #ffba00;--sheet-success: #23ac28;--zuz-overlay: rgba(0, 0, 0, 0.7);--zuz-overlay-blur: 0;--drawer-color: #fff;--drawer-handle-color: #ccc;--drawer-radius-v: 0px;--drawer-radius-h: 0px}.flex{display:flex}.flex.cols{flex-direction:column}.flex.aic{align-items:center}.flex.jcc{justify-content:center}.abs{position:absolute}.fixed{position:fixed}.fill{top:0px;left:0px;bottom:0px;right:0px}.fillx{top:-10px;left:-10px;bottom:-10px;right:-10px}.grid{display:grid}.nope{pointer-events:none}.nous{user-select:none}.rel{position:relative}.ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.input-with-error{box-shadow:inset 0px 0px 0px 1px #ff8b8b}.zuz-checkbox{height:25px;width:45px;cursor:pointer}.zuz-checkbox input[type=checkbox]{z-index:0;left:10px;top:10px;opacity:0}.zuz-checkbox:before{content:"";position:absolute;width:45px;height:25px;background:var(--checkbox-unchecked);border-radius:50px;z-index:1;transition:all .3s linear 0s}.zuz-checkbox:after{content:"";position:absolute;width:21px;height:21px;background:var(--checkbox-thumb);border-radius:50px;z-index:2;top:2px;left:2px;box-shadow:0px 0px --checkbox-thumb-shadow-size --checkbox-thumb-shadow;transition:all .2s linear 0s}.zuz-checkbox.is-checked:before{box-shadow:inset 0px 0px 0px 15px var(--checkbox-checked)}.zuz-checkbox.is-checked:after{transform:translateX(20px)}.zuz-spinner{animation:spin infinite}@keyframes spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}.zuz-cover{backdrop-filter:blur(4px);z-index:99999;gap:15px}.zuz-cover .label{font-size:14px;animation:breath 1s linear infinite}@keyframes breath{0%{opacity:.5}50%{opacity:1}100%{opacity:.5}}.zuz-toast,.zuz-sheet.toast-warn,.zuz-sheet.toast-success,.zuz-sheet.toast-error,.zuz-sheet.toast-default{border-radius:6px;padding:6px 12px;font-size:14px;white-space:pre}.zuz-sheet{top:50%;left:50%;transform:translate(-50%, -50%);z-index:214748364;transform-origin:top left;transition:all .5s cubic-bezier(0.2, -0.36, 0, 1.46) 0s}.zuz-sheet.wobble{transform-origin:inherit !important}.zuz-sheet.toast-default{background:#333;color:#fff;top:10px !important}.zuz-sheet.toast-error{background:var(--sheet-error);color:#fff;top:10px}.zuz-sheet.toast-success{background:var(--sheet-success);color:#fff;top:10px}.zuz-sheet.toast-warn{background:var(--sheet-warn);color:#111;top:10px}.zuz-sheet.toast-dialog{background:var(--dialog-bg);border-radius:var(--dialog-radius);padding:var(--dialog-padding);overflow:hidden}.zuz-sheet .zuz-sheet-head{margin-bottom:20px}.zuz-sheet .zuz-sheet-head .zuz-sheet-title{flex:1;font-size:var(--dialog-title-font-size);opacity:.5;text-align:center;padding:0px 45px}.zuz-sheet .zuz-sheet-head .zuz-sheet-dot{flex:1}.zuz-sheet .zuz-sheet-head .zuz-sheet-closer{width:32px;height:32px;cursor:pointer;font-size:var(--dialog-closer-font-size);background:rgba(0,0,0,0);border:0px;line-height:0;padding:0px;font-weight:normal;border-radius:20px;opacity:.35;top:50%;right:0px;transform:translateY(-50%)}.zuz-sheet .zuz-sheet-head .zuz-sheet-closer:hover{background:var(--dialog-closer-hover);opacity:1}.zuz-sheet-overlay{background:rgba(0,0,0,.7);z-index:111;backdrop-filter:blur(10px)}.zuz-context-menu{z-index:99;background:var(--context-background);border-radius:var(--context-radius);padding:10px;box-shadow:var(--context-shadow)}.zuz-context-menu .context-line{height:1px;background:var(--context-seperator);margin:3px 6px}.zuz-context-menu .context-menu-item{width:220px;padding:6px 10px;gap:10px;cursor:pointer;font-size:var(--context-label-size);border-radius:var(--context-radius)}.zuz-context-menu .context-menu-item .ico{font-size:var(--context-icon-size)}.zuz-context-menu .context-menu-item:hover{background:var(--context-hover)}@position-try --zuz-select-bottom{top:anchor(bottom);bottom:unset;margin-block:calc(var(--zuz-select-height) + var(--zuz-select-gap)) 0}.zuz-selectk-wrap{width:100%}.zuz-select{width:100%;gap:5px;background:var(--select);border-radius:var(--select-radius);border:0px;padding:12px 15px;anchor-name:--zuz-select-anchor}.zuz-select:hover{background:var(--select-hover)}.zuz-select .zuz-selected{flex:1;text-align:left}.zuz-select-options{--zuz-select-height: 30px;--zuz-select-gap: 0px;position-anchor:--zuz-select-anchor;position-try:most-height --zuz-select-bottom;width:100%;max-height:400px;overflow-x:hidden;gap:2px;background:var(--select-options);border-radius:var(--select-radius);padding:4px 0px}.zuz-select-options button{background:rgba(0,0,0,0);border:0px;text-align:left;padding:var(--select-padding);border-radius:var(--select-radius);font-size:var(--select-option-font-size)}.zuz-select-options button:hover{background:var(--select-hover)}.zuz-select-options button.selected{background:var(--select-selected)}.zuz-overlay{background:var(--zuz-overlay);z-index:2147483645;backdrop-filter:blur(var(--zuz-overlay-blur))}.drawer-h,.zuz-drawer.drawer-right,.zuz-drawer.drawer-left{min-width:320px;max-width:90vw;top:0px;bottom:0px;border-radius:var(--drawer-radius-h)}.drawer-v,.zuz-drawer.drawer-bottom,.zuz-drawer.drawer-top{min-height:10vh;max-height:90vh;left:0px;right:0px;border-radius:var(--drawer-radius-v)}.zuz-drawer{background:var(--drawer-color);z-index:2147483646;overflow-x:hidden;overflow-y:auto}.zuz-drawer.drawer-left{left:0px}.zuz-drawer.drawer-right{right:0px}.zuz-drawer.drawer-top{top:0px}.zuz-drawer.drawer-bottom{bottom:0px}.zuz-drawer .drawer-handle{width:100px;height:6px;border-radius:10px;background:var(--drawer-handle-color);margin:12px auto 0px auto}.text-wheel{transform-style:flat}.text-wheel .wheel-char{font-variant:tabular-nums;overflow:hidden;height:1lh}.text-wheel .wheel-char .wheel-char-track{transition:var(--text-wheel-transition)}.text-wheel .wheel-char .wheel-char-track.wheel-track-down{translate:0 calc((10 - var(--v))*-1lh)}.text-wheel .wheel-char .wheel-char-track.wheel-track-up{translate:0 calc((var(--v) + 1)*-1lh)}.text-wheel .wheel-char .wheel-char-track span{height:1lh;transition:opacity .5s}
@@ -19,12 +19,20 @@ export declare enum SHEET {
19
19
  Warn = "WARN"
20
20
  }
21
21
  export declare enum TRANSITION_CURVES {
22
- Spring = "SPRING"
22
+ Spring = "SPRING",
23
+ EaseInOut = "EASEINOUT"
23
24
  }
24
25
  export declare enum TRANSITIONS {
26
+ FadeIn = "FADE_IN",
25
27
  ScaleIn = "SCALE_IN",
26
28
  SlideInTop = "SLIDE_FROM_TOP",
27
29
  SlideInRight = "SLIDE_FROM_RIGHT",
28
30
  SlideInBottom = "SLIDE_FROM_BOTTOM",
29
31
  SlideInLeft = "SLIDE_FROM_LEFT"
30
32
  }
33
+ export declare enum DRAWER_SIDE {
34
+ Left = "LEFT",
35
+ Right = "RIGHT",
36
+ Top = "TOP",
37
+ Bottom = "BOTTOM"
38
+ }
@@ -25,12 +25,21 @@ export var SHEET;
25
25
  export var TRANSITION_CURVES;
26
26
  (function (TRANSITION_CURVES) {
27
27
  TRANSITION_CURVES["Spring"] = "SPRING";
28
+ TRANSITION_CURVES["EaseInOut"] = "EASEINOUT";
28
29
  })(TRANSITION_CURVES || (TRANSITION_CURVES = {}));
29
30
  export var TRANSITIONS;
30
31
  (function (TRANSITIONS) {
32
+ TRANSITIONS["FadeIn"] = "FADE_IN";
31
33
  TRANSITIONS["ScaleIn"] = "SCALE_IN";
32
34
  TRANSITIONS["SlideInTop"] = "SLIDE_FROM_TOP";
33
35
  TRANSITIONS["SlideInRight"] = "SLIDE_FROM_RIGHT";
34
36
  TRANSITIONS["SlideInBottom"] = "SLIDE_FROM_BOTTOM";
35
37
  TRANSITIONS["SlideInLeft"] = "SLIDE_FROM_LEFT";
36
38
  })(TRANSITIONS || (TRANSITIONS = {}));
39
+ export var DRAWER_SIDE;
40
+ (function (DRAWER_SIDE) {
41
+ DRAWER_SIDE["Left"] = "LEFT";
42
+ DRAWER_SIDE["Right"] = "RIGHT";
43
+ DRAWER_SIDE["Top"] = "TOP";
44
+ DRAWER_SIDE["Bottom"] = "BOTTOM";
45
+ })(DRAWER_SIDE || (DRAWER_SIDE = {}));
@@ -1,4 +1,15 @@
1
1
  import { DetailedHTMLProps, HTMLAttributes } from "react";
2
+ export interface FormatNumberParams {
3
+ number: number | string;
4
+ locale: string;
5
+ style?: `decimal` | `currency` | `percent`;
6
+ decimal?: number;
7
+ currency?: {
8
+ code: string;
9
+ style: `symbol` | `code` | `name`;
10
+ symbol?: string;
11
+ };
12
+ }
2
13
  export interface UIProps<T extends HTMLElement> extends DetailedHTMLProps<HTMLAttributes<T>, T> {
3
14
  [key: string]: any;
4
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuzjs/ui",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "keywords": [
5
5
  "react",
6
6
  "zuz",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "exports": {
20
20
  ".": "./dist/index.js",
21
+ "./hooks": "./dist/hooks/index.js",
21
22
  "./styles": "./dist/styles.css"
22
23
  },
23
24
  "files": [