@danielcruzcode/ui-core 0.1.4 → 0.1.6

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.
@@ -1,35 +1,24 @@
1
- function y(n) {
2
- return Object.prototype.toString.call(n) === "[object Object]";
3
- }
4
- function a(n) {
5
- return y(n) || Array.isArray(n);
6
- }
7
- function p() {
8
- return !!(typeof window != "undefined" && window.document && window.document.createElement);
9
- }
10
- function l(n, t) {
11
- const e = Object.keys(n), c = Object.keys(t);
12
- if (e.length !== c.length) return !1;
13
- const s = JSON.stringify(Object.keys(n.breakpoints || {})), u = JSON.stringify(Object.keys(t.breakpoints || {}));
14
- return s !== u ? !1 : e.every((o) => {
15
- const r = n[o], i = t[o];
16
- return typeof r == "function" ? `${r}` == `${i}` : !a(r) || !a(i) ? r === i : l(r, i);
17
- });
18
- }
19
- function f(n) {
20
- return n.concat().sort((t, e) => t.name > e.name ? 1 : -1).map((t) => t.options);
21
- }
22
- function O(n, t) {
23
- if (n.length !== t.length) return !1;
24
- const e = f(n), c = f(t);
25
- return e.every((s, u) => {
26
- const o = c[u];
27
- return l(s, o);
28
- });
1
+ import { useRef as l, useState as f, useCallback as p, useEffect as c } from "react";
2
+ import { areOptionsEqual as E, arePluginsEqual as O, canUseDOM as w } from "./index.esm16.js";
3
+ import m from "./index.esm17.js";
4
+ function b(e = {}, r = []) {
5
+ const t = l(e), n = l(r), [u, s] = f(), [a, d] = f(), o = p(() => {
6
+ u && u.reInit(t.current, n.current);
7
+ }, [u]);
8
+ return c(() => {
9
+ E(t.current, e) || (t.current = e, o());
10
+ }, [e, o]), c(() => {
11
+ O(n.current, r) || (n.current = r, o());
12
+ }, [r, o]), c(() => {
13
+ if (w() && a) {
14
+ m.globalOptions = b.globalOptions;
15
+ const i = m(a, t.current, n.current);
16
+ return s(i), () => i.destroy();
17
+ } else
18
+ s(void 0);
19
+ }, [a, s]), [d, u];
29
20
  }
21
+ b.globalOptions = void 0;
30
22
  export {
31
- l as areOptionsEqual,
32
- O as arePluginsEqual,
33
- p as canUseDOM,
34
- f as sortAndMapPluginToOptions
23
+ b as default
35
24
  };