@udixio/ui-react 1.6.4 → 2.1.0

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +51 -3
  2. package/dist/index.cjs +3 -3
  3. package/dist/index.js +1699 -1466
  4. package/dist/lib/config/config.interface.d.ts +4 -0
  5. package/dist/lib/config/config.interface.d.ts.map +1 -0
  6. package/dist/lib/config/define-config.d.ts +4 -0
  7. package/dist/lib/config/define-config.d.ts.map +1 -0
  8. package/dist/lib/config/index.d.ts +3 -0
  9. package/dist/lib/config/index.d.ts.map +1 -0
  10. package/dist/lib/effects/AnimateOnScroll.d.ts +7 -0
  11. package/dist/lib/effects/AnimateOnScroll.d.ts.map +1 -0
  12. package/dist/lib/effects/ThemeProvider.d.ts +3 -2
  13. package/dist/lib/effects/ThemeProvider.d.ts.map +1 -1
  14. package/dist/lib/effects/block-scroll.effect.d.ts +22 -0
  15. package/dist/lib/effects/block-scroll.effect.d.ts.map +1 -0
  16. package/dist/lib/effects/custom-scroll/custom-scroll.effect.d.ts.map +1 -1
  17. package/dist/lib/effects/index.d.ts +1 -0
  18. package/dist/lib/effects/index.d.ts.map +1 -1
  19. package/dist/lib/effects/scrollDriven.d.ts +5 -0
  20. package/dist/lib/effects/scrollDriven.d.ts.map +1 -0
  21. package/dist/lib/effects/smooth-scroll.effect.d.ts +5 -5
  22. package/dist/lib/effects/smooth-scroll.effect.d.ts.map +1 -1
  23. package/dist/lib/index.d.ts +1 -0
  24. package/dist/lib/index.d.ts.map +1 -1
  25. package/dist/lib/styles/fab.style.d.ts.map +1 -1
  26. package/dist/scrollDriven-AP2yWhzi.js +121 -0
  27. package/dist/scrollDriven-DWAu7CR0.cjs +1 -0
  28. package/package.json +5 -3
  29. package/src/lib/config/config.interface.ts +9 -0
  30. package/src/lib/config/define-config.ts +16 -0
  31. package/src/lib/config/index.ts +2 -0
  32. package/src/lib/effects/AnimateOnScroll.ts +267 -0
  33. package/src/lib/effects/ThemeProvider.tsx +78 -52
  34. package/src/lib/effects/block-scroll.effect.tsx +174 -0
  35. package/src/lib/effects/custom-scroll/custom-scroll.effect.tsx +16 -5
  36. package/src/lib/effects/index.ts +1 -0
  37. package/src/lib/effects/scrollDriven.ts +239 -0
  38. package/src/lib/effects/smooth-scroll.effect.tsx +105 -72
  39. package/src/lib/index.ts +1 -0
  40. package/src/lib/styles/card.style.ts +1 -1
  41. package/src/lib/styles/fab.style.ts +9 -17
  42. package/src/lib/styles/slider.style.ts +2 -2
  43. package/src/lib/styles/tab.style.ts +1 -1
  44. package/src/lib/styles/tabs.style.ts +3 -3
@@ -0,0 +1,4 @@
1
+ import { ConfigInterface as ConfigTheme, FontPluginOptions } from '@udixio/theme';
2
+ import { TailwindPluginOptions } from '@udixio/tailwind';
3
+ export type ConfigInterface = Omit<ConfigTheme, 'plugins' | 'isDark'> & TailwindPluginOptions & FontPluginOptions;
4
+ //# sourceMappingURL=config.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.interface.d.ts","sourceRoot":"","sources":["../../../src/lib/config/config.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,IAAI,WAAW,EAC9B,iBAAiB,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,QAAQ,CAAC,GACnE,qBAAqB,GACrB,iBAAiB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ConfigInterface } from './config.interface';
2
+ import { ConfigInterface as ConfigTheme } from '@udixio/theme';
3
+ export declare function defineConfig(configObject: ConfigInterface): ConfigTheme;
4
+ //# sourceMappingURL=define-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-config.d.ts","sourceRoot":"","sources":["../../../src/lib/config/define-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EACL,eAAe,IAAI,WAAW,EAI/B,MAAM,eAAe,CAAC;AAGvB,wBAAgB,YAAY,CAAC,YAAY,EAAE,eAAe,GAAG,WAAW,CAMvE"}
@@ -0,0 +1,3 @@
1
+ export * from './config.interface';
2
+ export * from './define-config';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export type AnimateOnScrollOptions = {
2
+ prefix?: string;
3
+ once?: boolean;
4
+ };
5
+ export declare function initAnimateOnScroll(options?: AnimateOnScrollOptions): () => void;
6
+ export declare const AnimateOnScrollInit: typeof initAnimateOnScroll;
7
+ //# sourceMappingURL=AnimateOnScroll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimateOnScroll.d.ts","sourceRoot":"","sources":["../../../src/lib/effects/AnimateOnScroll.ts"],"names":[],"mappings":"AAyHA,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,sBAA2B,GAAG,MAAM,IAAI,CAyIpF;AAGD,eAAO,MAAM,mBAAmB,4BAAsB,CAAC"}
@@ -1,7 +1,8 @@
1
1
  import { API, ConfigInterface } from '@udixio/theme';
2
- export declare const ThemeProvider: ({ config, throttleDelay, onLoad, }: {
3
- config: ConfigInterface;
2
+ export declare const ThemeProvider: ({ config, throttleDelay, onLoad, loadTheme, }: {
3
+ config: Readonly<ConfigInterface>;
4
4
  onLoad?: (api: API) => void;
5
5
  throttleDelay?: number;
6
+ loadTheme?: boolean;
6
7
  }) => import("react/jsx-runtime").JSX.Element | null;
7
8
  //# sourceMappingURL=ThemeProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../../src/lib/effects/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,eAAe,EAAU,MAAM,eAAe,CAAC;AASvE,eAAO,MAAM,aAAa,GAAI,oCAI3B;IACD,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,mDAoFA,CAAC"}
1
+ {"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../../src/lib/effects/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,eAAe,EAGrB,MAAM,eAAe,CAAC;AASvB,eAAO,MAAM,aAAa,GAAI,+CAK3B;IACD,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC;IAClC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,mDAuGA,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { default as React } from 'react';
2
+ type ScrollIntent = {
3
+ type: 'intent';
4
+ source: 'wheel' | 'touch' | 'keyboard';
5
+ deltaX: number;
6
+ deltaY: number;
7
+ originalEvent: Event;
8
+ } | {
9
+ type: 'scrollbar';
10
+ scrollTop: number;
11
+ scrollLeft: number;
12
+ maxScrollTop: number;
13
+ maxScrollLeft: number;
14
+ };
15
+ type BlockScrollProps = {
16
+ onScroll?: (evt: ScrollIntent) => void;
17
+ touch?: boolean;
18
+ el: HTMLElement;
19
+ };
20
+ export declare const BlockScroll: React.FC<BlockScrollProps>;
21
+ export {};
22
+ //# sourceMappingURL=block-scroll.effect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-scroll.effect.d.ts","sourceRoot":"","sources":["../../../src/lib/effects/block-scroll.effect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,KAAK,YAAY,GACb;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,UAAU,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,KAAK,CAAC;CACtB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEN,KAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,IAAI,CAAC;IACvC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,EAAE,EAAE,WAAW,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAqJlD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"custom-scroll.effect.d.ts","sourceRoot":"","sources":["../../../../src/lib/effects/custom-scroll/custom-scroll.effect.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,eAAO,MAAM,YAAY,GAAI,0FAQ1B,UAAU,CAAC,qBAAqB,CAAC,4CA+QnC,CAAC"}
1
+ {"version":3,"file":"custom-scroll.effect.d.ts","sourceRoot":"","sources":["../../../../src/lib/effects/custom-scroll/custom-scroll.effect.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,eAAO,MAAM,YAAY,GAAI,0FAQ1B,UAAU,CAAC,qBAAqB,CAAC,4CA0RnC,CAAC"}
@@ -3,4 +3,5 @@ export * from './custom-scroll';
3
3
  export * from './smooth-scroll.effect';
4
4
  export * from './SyncedFixedWrapper';
5
5
  export * from './ThemeProvider';
6
+ export * from './AnimateOnScroll';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/effects/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/effects/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export type InitAnimationOptions = {
2
+ once?: boolean;
3
+ };
4
+ export declare function initScrollViewFallback(options?: InitAnimationOptions): () => void;
5
+ //# sourceMappingURL=scrollDriven.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scrollDriven.d.ts","sourceRoot":"","sources":["../../../src/lib/effects/scrollDriven.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAqKF,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,oBAAyB,SAlKpD,IAAI,CAuOxB"}
@@ -1,8 +1,8 @@
1
- import { ReactNode } from 'react';
2
1
  import { CustomScrollInterface } from './custom-scroll';
3
2
  import { ReactProps } from '../utils';
4
- export declare const SmoothScroll: ({ children, transition, orientation, throttleDuration, ...restProps }: {
5
- children: ReactNode;
6
- transition?: string;
7
- } & ReactProps<CustomScrollInterface>) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const SmoothScroll: ({ transition, orientation, throttleDuration, }: {
4
+ transition?: {
5
+ duration?: number;
6
+ };
7
+ } & ReactProps<CustomScrollInterface>) => import("react/jsx-runtime").JSX.Element | null;
8
8
  //# sourceMappingURL=smooth-scroll.effect.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"smooth-scroll.effect.d.ts","sourceRoot":"","sources":["../../../src/lib/effects/smooth-scroll.effect.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoB,MAAM,OAAO,CAAC;AAOpD,OAAO,EAAgB,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAc,UAAU,EAAE,MAAM,UAAU,CAAC;AAElD,eAAO,MAAM,YAAY,GAAI,uEAM1B;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,UAAU,CAAC,qBAAqB,CAAC,4CAuEpC,CAAC"}
1
+ {"version":3,"file":"smooth-scroll.effect.d.ts","sourceRoot":"","sources":["../../../src/lib/effects/smooth-scroll.effect.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAItC,eAAO,MAAM,YAAY,GAAI,gDAI1B;IACD,UAAU,CAAC,EAAE;QACX,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH,GAAG,UAAU,CAAC,qBAAqB,CAAC,mDA6GpC,CAAC"}
@@ -4,4 +4,5 @@ export * from './icon';
4
4
  export * from './interfaces';
5
5
  export * from './styles';
6
6
  export * from './utils';
7
+ export * from './config';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"fab.style.d.ts","sourceRoot":"","sources":["../../../src/lib/styles/fab.style.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8DAmDpB,CAAC"}
1
+ {"version":3,"file":"fab.style.d.ts","sourceRoot":"","sources":["../../../src/lib/styles/fab.style.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8DA2CpB,CAAC"}
@@ -0,0 +1,121 @@
1
+ let y = !1, h = null;
2
+ function C() {
3
+ if (typeof window > "u") return !1;
4
+ try {
5
+ if (window.CSS && typeof window.CSS.supports == "function")
6
+ return CSS.supports("animation-timeline: view()") || CSS.supports("animation-timeline: scroll()") || CSS.supports("view-timeline-name: --a");
7
+ } catch {
8
+ }
9
+ return !1;
10
+ }
11
+ function F() {
12
+ return typeof window > "u" || !("matchMedia" in window) ? !1 : window.matchMedia("(prefers-reduced-motion: reduce)").matches;
13
+ }
14
+ function V(n, t) {
15
+ return getComputedStyle(n).getPropertyValue(t).trim() || null;
16
+ }
17
+ function b(n) {
18
+ if (!n) return null;
19
+ const t = n.split(/\s+/), e = t[t.length - 1];
20
+ if (!e) return null;
21
+ if (e.endsWith("%")) {
22
+ const r = parseFloat(e);
23
+ if (!isNaN(r)) return Math.max(0, Math.min(100, r)) / 100;
24
+ }
25
+ return null;
26
+ }
27
+ function L(n) {
28
+ const t = V(n, "--udx-range-start"), e = V(n, "--udx-range-end"), r = b(t) ?? 0.2, a = b(e) ?? 0.5, o = Math.max(0, Math.min(1, r)), l = Math.max(o + 1e-3, Math.min(1, a));
29
+ return { start: o, end: l };
30
+ }
31
+ function i(n, t) {
32
+ if (!n) return null;
33
+ const e = n.trim(), r = parseFloat(e);
34
+ return isNaN(r) ? null : r;
35
+ }
36
+ function p(n, t, e) {
37
+ return n + (t - n) * e;
38
+ }
39
+ function N(n, t, e, r) {
40
+ const a = t.opacity != null ? Number(t.opacity) : 1, o = e.opacity != null ? Number(e.opacity) : 1, l = p(a, o, r);
41
+ n.style.opacity = String(l);
42
+ const v = i(t["--tw-enter-translate-x"]) ?? i(t["--tw-exit-translate-x"]) ?? 0, g = i(t["--tw-enter-translate-y"]) ?? i(t["--tw-exit-translate-y"]) ?? 0, c = i(e["--tw-enter-translate-x"]) ?? i(e["--tw-exit-translate-x"]) ?? 0, u = i(e["--tw-enter-translate-y"]) ?? i(e["--tw-exit-translate-y"]) ?? 0, S = i(t["--tw-enter-scale"]) ?? i(t["--tw-exit-scale"]) ?? 1, M = i(e["--tw-enter-scale"]) ?? i(e["--tw-exit-scale"]) ?? 1, P = i(t["--tw-enter-rotate"]) ?? i(t["--tw-exit-rotate"]) ?? 0, f = i(e["--tw-enter-rotate"]) ?? i(e["--tw-exit-rotate"]) ?? 0, x = p(v, c, r), s = p(g, u, r), d = p(S, M, r), m = p(P, f, r), w = [];
43
+ (x !== 0 || s !== 0) && w.push(`translate3d(${x}px, ${s}px, 0)`), d !== 1 && w.push(`scale(${d})`), m !== 0 && w.push(`rotate(${m}deg)`), n.style.transform = w.length ? w.join(" ") : "none";
44
+ }
45
+ function T(n) {
46
+ const t = n.classList, e = t.contains("animate-in"), r = t.contains("animate-out");
47
+ if (!e && !r) return null;
48
+ const a = getComputedStyle(n), o = {
49
+ opacity: i(a.getPropertyValue("--tw-enter-opacity")) ?? void 0,
50
+ "--tw-enter-translate-x": a.getPropertyValue("--tw-enter-translate-x") || void 0,
51
+ "--tw-enter-translate-y": a.getPropertyValue("--tw-enter-translate-y") || void 0,
52
+ "--tw-enter-scale": a.getPropertyValue("--tw-enter-scale") || void 0,
53
+ "--tw-enter-rotate": a.getPropertyValue("--tw-enter-rotate") || void 0
54
+ }, l = {
55
+ opacity: i(a.getPropertyValue("--tw-exit-opacity")) ?? void 0,
56
+ "--tw-exit-translate-x": a.getPropertyValue("--tw-exit-translate-x") || void 0,
57
+ "--tw-exit-translate-y": a.getPropertyValue("--tw-exit-translate-y") || void 0,
58
+ "--tw-exit-scale": a.getPropertyValue("--tw-exit-scale") || void 0,
59
+ "--tw-exit-rotate": a.getPropertyValue("--tw-exit-rotate") || void 0
60
+ };
61
+ return e ? {
62
+ from: o,
63
+ to: { opacity: 1, "--tw-enter-translate-x": "0", "--tw-enter-translate-y": "0", "--tw-enter-scale": "1", "--tw-enter-rotate": "0" }
64
+ } : r ? {
65
+ from: { opacity: 1, "--tw-exit-translate-x": "0", "--tw-exit-translate-y": "0", "--tw-exit-scale": "1", "--tw-exit-rotate": "0" },
66
+ to: l
67
+ } : null;
68
+ }
69
+ function $() {
70
+ const n = [
71
+ ".udx-view",
72
+ ".udx-view-x",
73
+ ".udx-view-y",
74
+ ".udx-view-inline",
75
+ ".udx-view-block",
76
+ "[data-udx-view]"
77
+ ].map((t) => `${t}.animate-in, ${t}.animate-out`).join(", ");
78
+ return Array.from(document.querySelectorAll(n));
79
+ }
80
+ function k(n = {}) {
81
+ if (y) return h || (() => {
82
+ });
83
+ if (typeof window > "u") return () => {
84
+ };
85
+ if (C() || F())
86
+ return y = !0, () => {
87
+ };
88
+ y = !0;
89
+ const t = n.once ?? !0, e = /* @__PURE__ */ new WeakSet();
90
+ let r = null;
91
+ const a = () => {
92
+ const v = $(), g = window.innerHeight || 0;
93
+ for (const c of v) {
94
+ const u = c.getBoundingClientRect(), S = Math.min(u.bottom, g) - Math.max(u.top, 0), M = Math.max(0, Math.min(S, u.height)), P = u.height > 0 ? M / u.height : 0, { start: f, end: x } = L(c);
95
+ let s = (P - f) / (x - f);
96
+ s = Math.max(0, Math.min(1, s)), t && e.has(c) && s < 1 && (s = 1);
97
+ const d = T(c);
98
+ if (!d) continue;
99
+ const { from: m, to: w } = d;
100
+ N(c, m, w, s), s >= 1 && t && e.add(c);
101
+ }
102
+ }, o = () => {
103
+ r == null && (r = window.requestAnimationFrame(() => {
104
+ r = null, a();
105
+ }));
106
+ };
107
+ a(), window.addEventListener("scroll", o, { passive: !0 }), window.addEventListener("resize", o);
108
+ const l = new MutationObserver(() => {
109
+ o();
110
+ });
111
+ return l.observe(document.documentElement, {
112
+ childList: !0,
113
+ subtree: !0,
114
+ attributes: !0
115
+ }), h = () => {
116
+ window.removeEventListener("scroll", o), window.removeEventListener("resize", o), r != null && cancelAnimationFrame(r), l.disconnect(), y = !1, h = null;
117
+ }, h;
118
+ }
119
+ export {
120
+ k as initScrollViewFallback
121
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let m=!1,g=null;function C(){if(typeof window>"u")return!1;try{if(window.CSS&&typeof window.CSS.supports=="function")return CSS.supports("animation-timeline: view()")||CSS.supports("animation-timeline: scroll()")||CSS.supports("view-timeline-name: --a")}catch{}return!1}function F(){return typeof window>"u"||!("matchMedia"in window)?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function P(n,t){return getComputedStyle(n).getPropertyValue(t).trim()||null}function V(n){if(!n)return null;const t=n.split(/\s+/),e=t[t.length-1];if(!e)return null;if(e.endsWith("%")){const r=parseFloat(e);if(!isNaN(r))return Math.max(0,Math.min(100,r))/100}return null}function T(n){const t=P(n,"--udx-range-start"),e=P(n,"--udx-range-end"),r=V(t)??.2,a=V(e)??.5,o=Math.max(0,Math.min(1,r)),l=Math.max(o+.001,Math.min(1,a));return{start:o,end:l}}function i(n,t){if(!n)return null;const e=n.trim(),r=parseFloat(e);return isNaN(r)?null:r}function p(n,t,e){return n+(t-n)*e}function k(n,t,e,r){const a=t.opacity!=null?Number(t.opacity):1,o=e.opacity!=null?Number(e.opacity):1,l=p(a,o,r);n.style.opacity=String(l);const v=i(t["--tw-enter-translate-x"])??i(t["--tw-exit-translate-x"])??0,h=i(t["--tw-enter-translate-y"])??i(t["--tw-exit-translate-y"])??0,c=i(e["--tw-enter-translate-x"])??i(e["--tw-exit-translate-x"])??0,u=i(e["--tw-enter-translate-y"])??i(e["--tw-exit-translate-y"])??0,S=i(t["--tw-enter-scale"])??i(t["--tw-exit-scale"])??1,M=i(e["--tw-enter-scale"])??i(e["--tw-exit-scale"])??1,b=i(t["--tw-enter-rotate"])??i(t["--tw-exit-rotate"])??0,f=i(e["--tw-enter-rotate"])??i(e["--tw-exit-rotate"])??0,x=p(v,c,r),s=p(h,u,r),d=p(S,M,r),y=p(b,f,r),w=[];(x!==0||s!==0)&&w.push(`translate3d(${x}px, ${s}px, 0)`),d!==1&&w.push(`scale(${d})`),y!==0&&w.push(`rotate(${y}deg)`),n.style.transform=w.length?w.join(" "):"none"}function L(n){const t=n.classList,e=t.contains("animate-in"),r=t.contains("animate-out");if(!e&&!r)return null;const a=getComputedStyle(n),o={opacity:i(a.getPropertyValue("--tw-enter-opacity"))??void 0,"--tw-enter-translate-x":a.getPropertyValue("--tw-enter-translate-x")||void 0,"--tw-enter-translate-y":a.getPropertyValue("--tw-enter-translate-y")||void 0,"--tw-enter-scale":a.getPropertyValue("--tw-enter-scale")||void 0,"--tw-enter-rotate":a.getPropertyValue("--tw-enter-rotate")||void 0},l={opacity:i(a.getPropertyValue("--tw-exit-opacity"))??void 0,"--tw-exit-translate-x":a.getPropertyValue("--tw-exit-translate-x")||void 0,"--tw-exit-translate-y":a.getPropertyValue("--tw-exit-translate-y")||void 0,"--tw-exit-scale":a.getPropertyValue("--tw-exit-scale")||void 0,"--tw-exit-rotate":a.getPropertyValue("--tw-exit-rotate")||void 0};return e?{from:o,to:{opacity:1,"--tw-enter-translate-x":"0","--tw-enter-translate-y":"0","--tw-enter-scale":"1","--tw-enter-rotate":"0"}}:r?{from:{opacity:1,"--tw-exit-translate-x":"0","--tw-exit-translate-y":"0","--tw-exit-scale":"1","--tw-exit-rotate":"0"},to:l}:null}function N(){const n=[".udx-view",".udx-view-x",".udx-view-y",".udx-view-inline",".udx-view-block","[data-udx-view]"].map(t=>`${t}.animate-in, ${t}.animate-out`).join(", ");return Array.from(document.querySelectorAll(n))}function $(n={}){if(m)return g||(()=>{});if(typeof window>"u")return()=>{};if(C()||F())return m=!0,()=>{};m=!0;const t=n.once??!0,e=new WeakSet;let r=null;const a=()=>{const v=N(),h=window.innerHeight||0;for(const c of v){const u=c.getBoundingClientRect(),S=Math.min(u.bottom,h)-Math.max(u.top,0),M=Math.max(0,Math.min(S,u.height)),b=u.height>0?M/u.height:0,{start:f,end:x}=T(c);let s=(b-f)/(x-f);s=Math.max(0,Math.min(1,s)),t&&e.has(c)&&s<1&&(s=1);const d=L(c);if(!d)continue;const{from:y,to:w}=d;k(c,y,w,s),s>=1&&t&&e.add(c)}},o=()=>{r==null&&(r=window.requestAnimationFrame(()=>{r=null,a()}))};a(),window.addEventListener("scroll",o,{passive:!0}),window.addEventListener("resize",o);const l=new MutationObserver(()=>{o()});return l.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0}),g=()=>{window.removeEventListener("scroll",o),window.removeEventListener("resize",o),r!=null&&cancelAnimationFrame(r),l.disconnect(),m=!1,g=null},g}exports.initScrollViewFallback=$;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@udixio/ui-react",
3
- "version": "1.6.4",
3
+ "version": "2.1.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -20,6 +20,8 @@
20
20
  "react-dom": ">19.0.0"
21
21
  },
22
22
  "dependencies": {
23
+ "pathe": "^2.0.3",
24
+ "jiti": "^2.5.1",
23
25
  "throttle-debounce": "^5.0.2",
24
26
  "clsx": "^1.1.1",
25
27
  "react-textarea-autosize": "^8.5.9",
@@ -34,8 +36,8 @@
34
36
  "devDependencies": {
35
37
  "react": "^19.1.1",
36
38
  "react-dom": "^19.1.1",
37
- "@udixio/tailwind": "1.7.3",
38
- "@udixio/theme": "1.3.1"
39
+ "@udixio/theme": "2.0.0",
40
+ "@udixio/tailwind": "2.1.0"
39
41
  },
40
42
  "repository": {
41
43
  "type": "git",
@@ -0,0 +1,9 @@
1
+ import {
2
+ ConfigInterface as ConfigTheme,
3
+ FontPluginOptions,
4
+ } from '@udixio/theme';
5
+ import { TailwindPluginOptions } from '@udixio/tailwind';
6
+
7
+ export type ConfigInterface = Omit<ConfigTheme, 'plugins' | 'isDark'> &
8
+ TailwindPluginOptions &
9
+ FontPluginOptions;
@@ -0,0 +1,16 @@
1
+ import { ConfigInterface } from './config.interface';
2
+ import {
3
+ ConfigInterface as ConfigTheme,
4
+ defineConfig as defineConfigTheme,
5
+ FontPlugin,
6
+ Variants,
7
+ } from '@udixio/theme';
8
+ import { TailwindPlugin } from '@udixio/tailwind';
9
+
10
+ export function defineConfig(configObject: ConfigInterface): ConfigTheme {
11
+ return defineConfigTheme({
12
+ variant: Variants.Fidelity,
13
+ ...configObject,
14
+ plugins: [new FontPlugin(configObject), new TailwindPlugin(configObject)],
15
+ });
16
+ }
@@ -0,0 +1,2 @@
1
+ export * from './config.interface';
2
+ export * from './define-config';
@@ -0,0 +1,267 @@
1
+ // Simple script initializer (no React component)
2
+
3
+ /**
4
+ * AnimateOnScroll
5
+ *
6
+ * Manages triggers for animations:
7
+ * - ScrollDriven animations: use native CSS if supported; otherwise import JS fallback per element set.
8
+ * - Other entry/exit animations: handled via IntersectionObserver in JS.
9
+ */
10
+
11
+
12
+ function supportsScrollTimeline(): boolean {
13
+ if (typeof window === `undefined`) return false;
14
+ try {
15
+ // @ts-ignore - CSS may not exist in TS lib
16
+ if (window.CSS && typeof window.CSS.supports === `function`) {
17
+ // @ts-ignore
18
+ return (
19
+ CSS.supports(`animation-timeline: view()`) ||
20
+ CSS.supports(`animation-timeline: scroll()`) ||
21
+ // some older implementations used view-timeline-name
22
+ CSS.supports(`view-timeline-name: --a`)
23
+ );
24
+ }
25
+ } catch {}
26
+ return false;
27
+ }
28
+
29
+ function prefersReducedMotion(): boolean {
30
+ if (typeof window === `undefined` || !(`matchMedia` in window)) return false;
31
+ return window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;
32
+ }
33
+
34
+ function isScrollDrivenCandidate(el: Element): boolean {
35
+ if (!(el instanceof HTMLElement)) return false;
36
+ const cls = el.classList;
37
+
38
+ return Array.from(cls).some(
39
+ (className) =>
40
+ className.startsWith('anim-') && className.includes('scroll'),
41
+ );
42
+ }
43
+ function isJsObserverCandidate(el: Element): boolean {
44
+ if (!(el instanceof HTMLElement)) return false;
45
+ const cls = el.classList;
46
+ const hasAnimation = Array.from(cls).some((className) =>
47
+ className.startsWith('anim-'),
48
+ );
49
+ if (!hasAnimation) return false;
50
+ // Not scroll-driven
51
+ return !isScrollDrivenCandidate(el);
52
+ }
53
+
54
+ function hydrateElement(el: HTMLElement, prefix: string): void {
55
+ if (!isScrollDrivenCandidate(el)) return;
56
+
57
+ // Map data-anim-scroll to correct axis class if provided
58
+ if (el.hasAttribute(`data-${prefix}-scroll`)) {
59
+ const raw = (el.getAttribute(`data-${prefix}-scroll`) || ``)
60
+ .trim()
61
+ .toLowerCase();
62
+ const axis =
63
+ raw === `x` || raw === `inline`
64
+ ? `inline`
65
+ : raw === `y` || raw === `block`
66
+ ? `block`
67
+ : `auto`;
68
+ const hasAny =
69
+ el.classList.contains(`${prefix}-timeline`) ||
70
+ el.classList.contains(`${prefix}-timeline-inline`) ||
71
+ el.classList.contains(`${prefix}-timeline-block`) ||
72
+ el.classList.contains(`${prefix}-timeline-x`) ||
73
+ el.classList.contains(`${prefix}-timeline-y`);
74
+ if (!hasAny) {
75
+ if (axis === `inline`) el.classList.add(`${prefix}-timeline-inline`);
76
+ else if (axis === `block`) el.classList.add(`${prefix}-timeline-block`);
77
+ else el.classList.add(`${prefix}-scroll`);
78
+ }
79
+ }
80
+
81
+ // Offsets via data-anim-start / data-anim-end (accepts tokens like "entry 20%", "cover 50%", etc.)
82
+ const start = el.getAttribute(`data-${prefix}-start`);
83
+ if (start) el.style.setProperty(`--${prefix}-range-start`, start);
84
+ const end = el.getAttribute(`data-${prefix}-end`);
85
+ if (end) el.style.setProperty(`--${prefix}-range-end`, end);
86
+
87
+ // Ensure play state is running unless explicitly paused
88
+ const explicitlyPaused =
89
+ el.hasAttribute(`data-${prefix}-paused`) ||
90
+ el.classList.contains(`${prefix}-paused`);
91
+ const alreadyRunning =
92
+ el.hasAttribute(`data-${prefix}-run`) ||
93
+ el.classList.contains(`${prefix}-run`);
94
+ if (!explicitlyPaused && !alreadyRunning) {
95
+ el.setAttribute(`data-${prefix}-run`, ``);
96
+ }
97
+ }
98
+
99
+ function queryScrollDrivenCandidates(
100
+ root: ParentNode = document,
101
+ prefix: string,
102
+ ): HTMLElement[] {
103
+ // Select any elements that have an animation class and are marked as scroll-driven
104
+ const animated = Array.from(
105
+ root.querySelectorAll<HTMLElement>(`[class*="${prefix}-"]`),
106
+ );
107
+ return animated.filter((el) => isScrollDrivenCandidate(el));
108
+ }
109
+
110
+ function queryJsObserverCandidates(
111
+ root: ParentNode = document,
112
+ prefix: string,
113
+ ): HTMLElement[] {
114
+ // All anim-in/out that are NOT scroll-driven
115
+ const animated = Array.from(
116
+ root.querySelectorAll<HTMLElement>(`[class*="anim-"]`),
117
+ );
118
+
119
+ return animated.filter((el) => !isScrollDrivenCandidate(el));
120
+ }
121
+
122
+ export type AnimateOnScrollOptions = {
123
+ prefix?: string;
124
+ once?: boolean;
125
+ };
126
+
127
+ export function initAnimateOnScroll(options: AnimateOnScrollOptions = {}): () => void {
128
+ const { prefix = 'anim', once = true } = options;
129
+
130
+ if (prefersReducedMotion()) {
131
+ return () => {};
132
+ }
133
+
134
+ const cssSupported = supportsScrollTimeline();
135
+
136
+ // Setup JS observers for non-scroll-driven animations
137
+ const observed = new WeakSet<Element>();
138
+
139
+ const io = new IntersectionObserver(
140
+ (entries) => {
141
+ for (const entry of entries) {
142
+ const el = entry.target as HTMLElement;
143
+
144
+ if (!isJsObserverCandidate(el)) continue;
145
+
146
+ const cls = el.classList;
147
+ const isOut = cls.contains(`${prefix}-out`);
148
+ const isIn = !isOut;
149
+
150
+ if (isIn && entry.isIntersecting) {
151
+ el.setAttribute(`data-${prefix}-in-run`, ``);
152
+ if (once) io.unobserve(el);
153
+ } else if (isOut && !entry.isIntersecting) {
154
+ el.setAttribute(`data-${prefix}-out-run`, ``);
155
+ if (once) io.unobserve(el);
156
+ } else {
157
+ if (!once) {
158
+ const currentAnimationName = el.style.animationName;
159
+ el.style.animationName = 'none';
160
+ el.removeAttribute(`data-${prefix}-in-run`);
161
+ el.removeAttribute(`data-${prefix}-out-run`);
162
+ void el.offsetWidth; // reflow
163
+ el.style.animationName = currentAnimationName;
164
+ }
165
+ }
166
+ }
167
+ },
168
+ { threshold: [0, 0.2] },
169
+ );
170
+
171
+ const observeJsCandidates = (root?: ParentNode) => {
172
+ const candidates = queryJsObserverCandidates(root || document, prefix);
173
+ for (const el of candidates) {
174
+ if (observed.has(el)) continue;
175
+ observed.add(el);
176
+ io.observe(el);
177
+ }
178
+ };
179
+
180
+ // Initial observe
181
+ observeJsCandidates();
182
+
183
+ // Scroll-driven branch per support state
184
+ let cleanupScrollDriven: void | (() => void);
185
+ let mo: MutationObserver | null = null;
186
+ let rafId: number | null = null;
187
+
188
+ if (cssSupported) {
189
+ const schedule = () => {
190
+ if (rafId != null) return;
191
+ rafId = requestAnimationFrame(() => {
192
+ rafId = null;
193
+ const els = queryScrollDrivenCandidates(undefined, prefix);
194
+ for (const el of els) hydrateElement(el, prefix);
195
+ });
196
+ };
197
+
198
+ // Initial hydration
199
+ schedule();
200
+
201
+ mo = new MutationObserver((muts) => {
202
+ for (const m of muts) {
203
+ if (m.type === `attributes`) {
204
+ const t = m.target;
205
+ if (t instanceof HTMLElement) {
206
+ hydrateElement(t as HTMLElement, prefix);
207
+ if (isJsObserverCandidate(t)) {
208
+ if (!observed.has(t)) {
209
+ observed.add(t);
210
+ io.observe(t);
211
+ }
212
+ }
213
+ }
214
+ } else if (m.type === `childList`) {
215
+ if (m.addedNodes && m.addedNodes.length) {
216
+ for (const node of Array.from(m.addedNodes)) {
217
+ if (node instanceof HTMLElement) {
218
+ const sds = queryScrollDrivenCandidates(node, prefix);
219
+ for (const el of sds) hydrateElement(el, prefix);
220
+ observeJsCandidates(node);
221
+ }
222
+ }
223
+ }
224
+ }
225
+ }
226
+ });
227
+
228
+ mo.observe(document.documentElement, {
229
+ subtree: true,
230
+ childList: true,
231
+ attributes: true,
232
+ attributeFilter: [
233
+ `class`,
234
+ `data-${prefix}-scroll`,
235
+ `data-${prefix}-start`,
236
+ `data-${prefix}-end`,
237
+ `data-${prefix}-paused`,
238
+ `data-${prefix}-run`,
239
+ ],
240
+ });
241
+
242
+ cleanupScrollDriven = () => {
243
+ if (rafId != null) cancelAnimationFrame(rafId);
244
+ if (mo) mo.disconnect();
245
+ };
246
+ } else {
247
+ let stop: void | (() => void);
248
+ const existing = queryScrollDrivenCandidates(undefined, prefix);
249
+ if (existing.length > 0) {
250
+ import(`./scrollDriven`).then((m) => {
251
+ stop = m.initScrollViewFallback({ once });
252
+ });
253
+ }
254
+ cleanupScrollDriven = () => {
255
+ if (typeof stop === `function`) (stop as () => void)();
256
+ };
257
+ }
258
+
259
+ // Public cleanup
260
+ return () => {
261
+ if (cleanupScrollDriven) cleanupScrollDriven();
262
+ io.disconnect();
263
+ };
264
+ }
265
+
266
+ // Backward-compatible alias name (non-React):
267
+ export const AnimateOnScrollInit = initAnimateOnScroll;