@zuzjs/ui 0.4.4 → 0.4.5

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,6 @@
1
+ import { animationProps } from "./base";
2
+ declare const Animate: import("react").ForwardRefExoticComponent<{
3
+ as?: string;
4
+ animate?: animationProps;
5
+ } & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
6
+ export default Animate;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import With from "./base";
4
+ const Animate = forwardRef((props, ref) => {
5
+ const { as, ...rest } = props;
6
+ return _jsx(With, { as: as, ...rest, ref: ref });
7
+ });
8
+ export default Animate;
@@ -19,6 +19,11 @@ declare class CSS {
19
19
  mediaQueries: dynamicObject;
20
20
  _mediaQueries: dynamicObject;
21
21
  _mediaQueriesLabels: dynamicObject;
22
+ PROPS_KEYS: string[];
23
+ DIRECT_KEYS: string[];
24
+ _cli: boolean;
25
+ DIRECT_VALUES: string[];
26
+ PROPS_VALUES: string[];
22
27
  constructor(options?: dynamicObject | undefined);
23
28
  buildMediaQueries(queries: dynamicObject): string;
24
29
  styleSheet(cache: dynamicObject, pseudo?: string): string;
@@ -28,7 +33,8 @@ declare class CSS {
28
33
  makeUnit(k: string, v: any): any;
29
34
  makeValue(k: string, v: any): string;
30
35
  calcIndexes(str: string): string;
31
- mmakeID(k: string, v: string, _out: string): string;
36
+ makeID2(k: string, v: string, _out: string): string;
37
+ makeID3(k: string, v: string, _out: string): string;
32
38
  makeID(k: string, v: string, _out: string): string;
33
39
  lexer(line: string): dynamicObject;
34
40
  processLine(line: string): void;
package/dist/funs/css.js CHANGED
@@ -2,6 +2,7 @@ import { __SALT, FIELNAME_KEY, isColor, isHexColor, isNumber, LINE_KEY, setDeep
2
2
  import { cssAnimationCurves, cssDirect, cssProps, cssTransformKeys, cssWithKeys } from "./stylesheet.js";
3
3
  import Hashids from "hashids";
4
4
  import { TRANSITION_CURVES, TRANSITIONS } from "../types/enums.js";
5
+ import md5 from "md5";
5
6
  class CSS {
6
7
  cx;
7
8
  cache;
@@ -20,8 +21,14 @@ class CSS {
20
21
  mediaQueries;
21
22
  _mediaQueries;
22
23
  _mediaQueriesLabels;
24
+ PROPS_KEYS;
25
+ DIRECT_KEYS;
26
+ _cli;
27
+ DIRECT_VALUES;
28
+ PROPS_VALUES;
23
29
  constructor(options) {
24
30
  const opts = options || {};
31
+ this._cli = false;
25
32
  this._mediaQueries = {};
26
33
  this._mediaQueriesLabels = {
27
34
  ph: `Extra Small Devices (Phones)`,
@@ -42,7 +49,7 @@ class CSS {
42
49
  this.unit = opts.unit || `px`;
43
50
  this.seperator = `__@@__`;
44
51
  this.hashids = new Hashids(__SALT, 5);
45
- this.chars = "#@_-[]{}();:^/!^&*+='\"`,.~abcdefghijklmnopqrstuvwxyz0123456789";
52
+ this.chars = "#@_-[]{}();:^/!^&*+='\"`,.~%abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
46
53
  this.rgbaRegex = /\b\w+\[\d+,\d+,\d+(?:,\d+)?\]/g;
47
54
  this.pseudoList = [
48
55
  "@before", "@after", "@active", "@checked", "@default", "@disabled", "@empty", "@enabled", "@first", "@firstChild", "@firstOfType", "@focus", "@hover", "@indeterminate", "@inRange", "@invalid", "@lastChild", "@lastOfType", "@link", "@not", "@nthChild", "@nthLastChild", "@nthLastOfType", "@nthOfType", "@onlyChild", "@onlyOfType", "@optional", "@outOfRange", "@readOnly", "@readWrite", "@required", "@root", "@scope", "@target", "@valid", "@visited"
@@ -58,7 +65,18 @@ class CSS {
58
65
  this.propCounter = {};
59
66
  this.ids = [];
60
67
  this.PROPS = cssProps;
68
+ this.PROPS_KEYS = Object.keys(cssProps);
69
+ this.PROPS_VALUES = this.PROPS_KEYS.reduce((arr, k) => {
70
+ arr.push(cssProps[k]);
71
+ return arr;
72
+ }, []);
61
73
  this.DIRECT = cssDirect;
74
+ this.DIRECT_KEYS = Object.keys(cssDirect);
75
+ this.DIRECT_VALUES = this.DIRECT_KEYS.reduce((arr, k) => {
76
+ if (!cssDirect[k].includes(`__VALUE__`))
77
+ arr.push(cssDirect[k].replace(/\s+/g, ``));
78
+ return arr;
79
+ }, []);
62
80
  }
63
81
  buildMediaQueries(queries) {
64
82
  const self = this;
@@ -345,15 +363,76 @@ class CSS {
345
363
  }
346
364
  return _indices.join(``);
347
365
  }
348
- mmakeID(k, v, _out) {
349
- const cs = [];
350
- const out = this.calcIndexes(k) + this.calcIndexes(v) + this.calcIndexes(_out);
351
- console.log(this.hashids.encode(out));
352
- cs.push(out.charAt(0).match(/\d+/g) ? `z` : ``, out);
353
- return cs.join(``);
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
+ const self = this;
401
+ const md = md5(_out);
402
+ let _ = [];
403
+ const _mi = (_k, _v) => {
404
+ let i = Math.abs(self.DIRECT_KEYS.indexOf(_k)) + Math.abs(self.PROPS_VALUES.indexOf(_k));
405
+ _.push(i);
406
+ const nums = _v.match(/[0-9]/g);
407
+ if (nums) {
408
+ let ii = Math.abs(+nums.join(``));
409
+ _.push(ii);
410
+ i += ii;
411
+ }
412
+ const abc = _v.match(/[a-zA-Z,/-\[\]]/g);
413
+ if (abc) {
414
+ const ai = abc.reduce((acc, char) => acc + self.chars.indexOf(char), 0);
415
+ _.push(ai);
416
+ i += ai;
417
+ }
418
+ return i;
419
+ };
420
+ const out = _out.replace(/\s+/g, ``).trim();
421
+ const [_ok, _ov] = out.split(`:`);
422
+ const ok = _ok.trim();
423
+ const ov = _ov.trim();
424
+ let _cp = ok.charAt(0);
425
+ if (self.PROPS[ok]?.indexOf("-") > -1) {
426
+ _cp = "";
427
+ self.PROPS[ok].split("-").map((c) => _cp += c.charAt(0));
428
+ }
429
+ const io = self.DIRECT_VALUES.includes(out) ? self.DIRECT_VALUES.indexOf(out) : _mi(ok, ov);
430
+ const ai = md.split(``).reduce((acc, char) => acc + self.chars.indexOf(char), 0);
431
+ return `${_cp}${self.hashids.encode(io, ai)}`;
354
432
  }
355
433
  makeID(k, v, _out) {
356
434
  const self = this;
435
+ return self.makeID3(k, v, _out);
357
436
  const _css = _out.toString().replace(/;|:|\s/g, "");
358
437
  let _indices = 0;
359
438
  for (let i = 0; i < _css.length; i++) {
@@ -479,6 +558,7 @@ class CSS {
479
558
  }
480
559
  else if (key == `ratio`) {
481
560
  _out = self.DIRECT[key].replace(`__VALUE__`, val.replace(`,`, `/`));
561
+ _out = _out.replace(`;`, `${important};`);
482
562
  }
483
563
  else if (key == `anim`) {
484
564
  let delay = `0s`;
@@ -502,6 +582,7 @@ class CSS {
502
582
  .replace(`__VALUE__`, duration)
503
583
  .replace(`__CURVE__`, curve)
504
584
  .replace(`__DELAY__`, delay);
585
+ _out = _out.replace(`;`, `${important};`);
505
586
  }
506
587
  else {
507
588
  const __value = `${val}${key == `extend` ? `` : self.makeUnit(key, val)}`;
@@ -552,6 +633,7 @@ class CSS {
552
633
  }
553
634
  Build(css, cli = false) {
554
635
  let self = this;
636
+ self._cli = cli;
555
637
  self.cx = [];
556
638
  self.cache = {};
557
639
  self._mediaQueries = {};
@@ -277,9 +277,9 @@ export const cssDirect = {
277
277
  "pv": "padding-top:__VALUE__;padding-bottom:__VALUE__;",
278
278
  "mh": "margin-left:__VALUE__;margin-right:__VALUE__;",
279
279
  "mv": "margin-top:__VALUE__;margin-bottom:__VALUE__;",
280
- "translate": "transform:translate(__VALUE__);",
281
- "translateX": "transform:translateX(__VALUE__);",
282
- "translateY": "transform:translateY(__VALUE__);",
280
+ "translate": "transform: translate(__VALUE__);",
281
+ "translateX": "transform: translateX(__VALUE__);",
282
+ "translateY": "transform: translateY(__VALUE__);",
283
283
  "rotate": "transform: rotate(__VALUE__);",
284
284
  "scale": "transform: scale(__VALUE__);",
285
285
  "anim": "transition: all __VALUE__ __CURVE__ __DELAY__;",
@@ -0,0 +1 @@
1
+ export { default as useMounted } from './useMounted';
@@ -0,0 +1 @@
1
+ export { default as useMounted } from './useMounted';
@@ -0,0 +1,2 @@
1
+ declare const useMounted: (delay?: number) => boolean;
2
+ export default useMounted;
@@ -0,0 +1,10 @@
1
+ import { useState, useEffect } from 'react';
2
+ const useMounted = (delay = 100) => {
3
+ const [mounted, setMounted] = useState(false);
4
+ useEffect(() => {
5
+ const timer = setTimeout(() => setMounted(true), delay);
6
+ return () => clearTimeout(timer);
7
+ }, [delay]);
8
+ return mounted;
9
+ };
10
+ export default useMounted;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { withZuz as css } from './funs';
2
2
  export * from "./funs";
3
+ export * from "./hooks";
3
4
  export { default as Box } from "./comps/box";
4
5
  export { default as Button } from "./comps/button";
5
6
  export { default as CheckBox } from "./comps/checkbox";
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export { withZuz as css } from './funs';
2
2
  export * from "./funs";
3
+ export * from "./hooks";
3
4
  export { default as Box } from "./comps/box";
4
5
  export { default as Button } from "./comps/button";
5
6
  export { default as CheckBox } from "./comps/checkbox";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuzjs/ui",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "keywords": [
5
5
  "react",
6
6
  "zuz",
@@ -32,6 +32,7 @@
32
32
  "node": ">=18.17.0"
33
33
  },
34
34
  "dependencies": {
35
+ "@types/md5": "^2.3.5",
35
36
  "axios": "^1.7.6",
36
37
  "chokidar": "^3.6.0",
37
38
  "commander": "^12.1.0",