@cn-ui/reactive
Advanced tools
Comparing version 2.2.3 to 2.2.4
@@ -1,35 +0,35 @@ | ||
var j = Object.defineProperty, B = Object.defineProperties; | ||
var R = Object.defineProperty, B = Object.defineProperties; | ||
var F = Object.getOwnPropertyDescriptors; | ||
var P = Object.getOwnPropertySymbols; | ||
var I = Object.getOwnPropertySymbols; | ||
var J = Object.prototype.hasOwnProperty, N = Object.prototype.propertyIsEnumerable; | ||
var T = (e, r, t) => r in e ? j(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, b = (e, r) => { | ||
var T = (e, r, t) => r in e ? R(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, y = (e, r) => { | ||
for (var t in r || (r = {})) | ||
J.call(r, t) && T(e, t, r[t]); | ||
if (P) | ||
for (var t of P(r)) | ||
if (I) | ||
for (var t of I(r)) | ||
N.call(r, t) && T(e, t, r[t]); | ||
return e; | ||
}, p = (e, r) => B(e, F(r)); | ||
var y = (e, r, t) => new Promise((s, o) => { | ||
var c = (n) => { | ||
}, A = (e, r) => B(e, F(r)); | ||
var S = (e, r, t) => new Promise((n, o) => { | ||
var c = (s) => { | ||
try { | ||
a(t.next(n)); | ||
u(t.next(s)); | ||
} catch (l) { | ||
o(l); | ||
} | ||
}, u = (n) => { | ||
}, a = (s) => { | ||
try { | ||
a(t.throw(n)); | ||
u(t.throw(s)); | ||
} catch (l) { | ||
o(l); | ||
} | ||
}, a = (n) => n.done ? s(n.value) : Promise.resolve(n.value).then(c, u); | ||
a((t = t.apply(e, r)).next()); | ||
}, u = (s) => s.done ? n(s.value) : Promise.resolve(s.value).then(c, a); | ||
u((t = t.apply(e, r)).next()); | ||
}); | ||
import { createEffect as x, on as q, createSignal as H, untrack as $, createMemo as M, batch as E, onCleanup as _ } from "solid-js"; | ||
import { createEffect as x, on as q, createSignal as H, untrack as _, createMemo as M, batch as O, onCleanup as $ } from "solid-js"; | ||
import { debounce as D, throttle as z } from "lodash-es"; | ||
const g = (e, r, t = null) => { | ||
let s = !0; | ||
let n = !0; | ||
return C( | ||
(o) => s ? (s = !1, null) : e(o), | ||
(o) => n ? (n = !1, null) : e(o), | ||
r, | ||
@@ -39,30 +39,30 @@ t | ||
}, ee = g, C = (e, r, t = null) => { | ||
let s = t; | ||
let n = t; | ||
return x( | ||
q(r, () => (s = e(s), s)) | ||
q(r, () => (n = e(n), n)) | ||
); | ||
}, d = Symbol("AtomTypeSymbol"), te = (e) => e[d], f = (e, r) => { | ||
const [t, s] = H(e, r); | ||
const [t, n] = H(e, r); | ||
return Object.assign( | ||
(...o) => o.length === 0 ? t() : s(...o), | ||
(...o) => o.length === 0 ? t() : n(...o), | ||
{ reflux: K, [d]: "atom" } | ||
); | ||
}, K = function(e, r, t) { | ||
const s = this, o = f(e, t); | ||
const n = this, o = f(e, t); | ||
return g(() => { | ||
s(() => r(o())); | ||
n(() => r(o())); | ||
}, [o]), o[d] = "reflux", o; | ||
}, O = (e, { | ||
}, k = (e, { | ||
immediately: r = !0, | ||
initValue: t = null | ||
} = {}) => { | ||
const s = f(r ? $(() => e(t)) : t); | ||
const n = f(r ? _(() => e(t)) : t); | ||
return x((o) => { | ||
s(() => e(o)); | ||
}, t), s[d] = "reflect", s; | ||
n(() => e(o)); | ||
}, t), n[d] = "reflect", n; | ||
}, U = (e, { | ||
immediately: r = !0, | ||
initValue: t = null | ||
} = {}) => M((s) => { | ||
const o = e(s); | ||
} = {}) => M((n) => { | ||
const o = e(n); | ||
return r ? o : (r = !0, t); | ||
@@ -72,29 +72,29 @@ }, t), W = (e, { | ||
immediately: t = !0, | ||
deps: s, | ||
deps: n, | ||
refetch: o = {}, | ||
tap: c = (a) => { | ||
tap: c = (u) => { | ||
}, | ||
ignoreError: u = !1 | ||
ignoreError: a = !1 | ||
} = {}) => { | ||
const a = f(r), n = f(!1), l = f(!1), i = M(() => !n() && !l()); | ||
const u = f(r), s = f(!1), l = f(!1), i = M(() => !s() && !l()); | ||
let h = Promise.resolve(!1); | ||
const w = (...we) => y(void 0, [...we], function* ({ warn: S = !0, cancelCallback: I } = o) { | ||
i() || (I ? I(h) : S && console.warn( | ||
const v = (...Se) => S(void 0, [...Se], function* ({ warn: b = !0, cancelCallback: p } = o) { | ||
i() || (p ? p(h) : b && console.warn( | ||
"Resource Atom: some fetch has been covered; Recommend to add a cancelCallback to some Hook" | ||
)), n(!0); | ||
const v = e().then((m) => (E(() => { | ||
a(() => m), n(!1), l(!1); | ||
}), v === h && c(m), !0)).catch((m) => (E(() => { | ||
l(m), n(!1); | ||
}), u || console.error(m), m)); | ||
return h = v, v; | ||
)), s(!0); | ||
const E = e().then((m) => (O(() => { | ||
u(() => m), s(!1), l(!1); | ||
}), E === h && c(m), !0)).catch((m) => (O(() => { | ||
l(m), s(!1); | ||
}), a || console.error(m), m)); | ||
return h = E, E; | ||
}); | ||
return t && w(), s && s.length && g(() => w(o), s), Object.assign(a, { | ||
return t && v(), n && n.length && g(() => v(o), n), Object.assign(u, { | ||
error: l, | ||
loading: n, | ||
mutate(S) { | ||
a(() => S); | ||
loading: s, | ||
mutate(b) { | ||
u(() => b); | ||
}, | ||
isReady: i, | ||
refetch: w, | ||
refetch: v, | ||
promise: () => h, | ||
@@ -110,21 +110,21 @@ [d]: "resource" | ||
let t = !1; | ||
return function(...s) { | ||
return t ? (r && r(), t) : (t = Promise.resolve(e.apply(this, s)).then((o) => (t = !1, o)), t); | ||
return function(...n) { | ||
return t ? (r && r(), t) : (t = Promise.resolve(e.apply(this, n)).then((o) => (t = !1, o)), t); | ||
}; | ||
}, ne = G; | ||
function k(e) { | ||
return typeof e == "function" ? A(e) ? e : O(e()) : f(e); | ||
function P(e) { | ||
return typeof e == "function" ? w(e) ? e : k(e()) : f(e); | ||
} | ||
function A(e) { | ||
function w(e) { | ||
return typeof e[d] == "string"; | ||
} | ||
const se = (e) => e().map((r, t) => O(() => e()[t])), Q = (e, r) => new Promise((t) => setTimeout(() => t(r), e)), oe = (e) => ({ | ||
const se = (e) => e().map((r, t) => k(() => e()[t])), Q = (e, r) => new Promise((t) => setTimeout(() => t(r), e)), oe = (e) => ({ | ||
value: e(), | ||
"on:input": (r) => e(() => r.target.value) | ||
}), ce = (e, r, t) => { | ||
var c, u, a; | ||
const s = (c = t == null ? void 0 : t.parse) != null ? c : (n) => JSON.parse(n), o = (u = t == null ? void 0 : t.stringify) != null ? u : (n) => JSON.stringify(n); | ||
if ((a = t == null ? void 0 : t.immediately) == null || a) { | ||
const n = localStorage.getItem(r); | ||
n && e(s(n)); | ||
var c, a, u; | ||
const n = (c = t == null ? void 0 : t.parse) != null ? c : (s) => JSON.parse(s), o = (a = t == null ? void 0 : t.stringify) != null ? a : (s) => JSON.stringify(s); | ||
if ((u = t == null ? void 0 : t.immediately) == null || u) { | ||
const s = localStorage.getItem(r); | ||
s && e(n(s)); | ||
} | ||
@@ -135,47 +135,47 @@ return g(() => { | ||
}, ae = (e) => [...Array(e).keys()]; | ||
function R(e, r) { | ||
const t = A(e) ? e : f(e, r), s = (c, u, a) => { | ||
const n = c.findIndex((l) => l === u); | ||
if (n >= 0) { | ||
function j(e, r) { | ||
const t = w(e) ? e : f(e, r), n = (c, a, u) => { | ||
const s = c.findIndex((l) => l === a); | ||
if (s >= 0) { | ||
const l = [...c]; | ||
return a(l, n), l; | ||
return u(l, s), l; | ||
} else | ||
return console.warn("Can't find array atom Item: ", u), c; | ||
return console.warn("Can't find array atom Item: ", a), c; | ||
}; | ||
return Object.assign(t, p(b({}, { | ||
replace(c, u) { | ||
return t((a) => s(a, c, (n, l) => { | ||
n[l] = u; | ||
return Object.assign(t, A(y({}, { | ||
replace(c, a) { | ||
return t((u) => n(u, c, (s, l) => { | ||
s[l] = a; | ||
})), this; | ||
}, | ||
replaceAll(c, u) { | ||
return t((a) => { | ||
const n = []; | ||
a.forEach((i, h) => i === c && n.push(h)); | ||
const l = [...a]; | ||
return n.forEach((i) => l[i] = u), l; | ||
replaceAll(c, a) { | ||
return t((u) => { | ||
const s = []; | ||
u.forEach((i, h) => i === c && s.push(h)); | ||
const l = [...u]; | ||
return s.forEach((i) => l[i] = a), l; | ||
}), this; | ||
}, | ||
remove(c) { | ||
return t((u) => s(u, c, (a, n) => { | ||
a.splice(n, 1); | ||
return t((a) => n(a, c, (u, s) => { | ||
u.splice(s, 1); | ||
})), this; | ||
}, | ||
removeAll(c) { | ||
return t((u) => u.filter((a) => a !== c)), this; | ||
return t((a) => a.filter((u) => u !== c)), this; | ||
}, | ||
insert(c, u, a = "before") { | ||
return t((n) => s(n, u, (l, i) => { | ||
l.splice(a === "before" ? i : i + 1, 0, c); | ||
insert(c, a, u = "before") { | ||
return t((s) => n(s, a, (l, i) => { | ||
l.splice(u === "before" ? i : i + 1, 0, c); | ||
})), this; | ||
}, | ||
move(c, u, a) { | ||
return this.remove(c), this.insert(c, u, a), this; | ||
move(c, a, u) { | ||
return this.remove(c), this.insert(c, a, u), this; | ||
}, | ||
switch(c, u) { | ||
return t((a) => { | ||
const n = [...a], l = t().findIndex((h) => h === c), i = t().findIndex((h) => h === u); | ||
switch(c, a) { | ||
return t((u) => { | ||
const s = [...u], l = t().findIndex((h) => h === c), i = t().findIndex((h) => h === a); | ||
if (l === -1 || i === -1) | ||
throw new Error("ArrayAtom: Please check the Items you want to switch "); | ||
return n[l] = u, n[i] = c, n; | ||
return s[l] = a, s[i] = c, s; | ||
}), this; | ||
@@ -186,35 +186,27 @@ } | ||
function ue(e, r) { | ||
const t = A(e) ? e : f(e, { equals: !1 }), s = A(e) ? e() : e; | ||
t[d] = "object"; | ||
const o = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set([d, ...Object.keys(s)]); | ||
return new Proxy(t, { | ||
get(u, a, n) { | ||
if (!c.has(a)) | ||
throw new Error(`key: ${a} can't be found in formObject!`); | ||
if (o.has(a)) | ||
return o.get(a); | ||
{ | ||
const l = t.reflux(u()[a], (i) => (u()[a] = i, u())); | ||
return o.set(a, l), l; | ||
} | ||
}, | ||
apply(u, a, n) { | ||
return Reflect.apply(u, a, n); | ||
} | ||
}); | ||
const t = w(e) ? e : f(e, { equals: !1 }), n = w(e) ? e() : e; | ||
return t[d] = "object", Object.assign( | ||
t, | ||
Object.fromEntries( | ||
Object.keys(n).reduce((o, c) => { | ||
const a = t.reflux(t()[c], (u) => A(y({}, t()), { [c]: u })); | ||
return o.push([c, a]), o; | ||
}, []) | ||
) | ||
); | ||
} | ||
function le(e, r = 150) { | ||
let t = e(); | ||
const s = f(t); | ||
const n = f(t); | ||
return g( | ||
D(() => { | ||
const o = e(); | ||
o !== void 0 && s(() => o); | ||
o !== void 0 && n(() => o); | ||
}, r), | ||
[e] | ||
), s; | ||
), n; | ||
} | ||
function ie(e, r = 150, t) { | ||
let s = e(); | ||
const o = f(s); | ||
let n = e(); | ||
const o = f(n); | ||
return g( | ||
@@ -258,6 +250,6 @@ z( | ||
}, V = (e, r = {}) => { | ||
var a, n; | ||
r.debounceTime = (a = r.debounceTime) != null ? a : 100; | ||
const t = f((n = r.initIndex) != null ? n : 0), s = f(10), o = W(() => e(t(), s), r), c = D(() => o.refetch(), r.debounceTime), u = (i) => { | ||
if (i < 0 || i >= s()) | ||
var u, s; | ||
r.debounceTime = (u = r.debounceTime) != null ? u : 100; | ||
const t = f((s = r.initIndex) != null ? s : 0), n = f(10), o = W(() => e(t(), n), r), c = D(() => o.refetch(), r.debounceTime), a = (i) => { | ||
if (i < 0 || i >= n()) | ||
return !1; | ||
@@ -273,11 +265,11 @@ { | ||
currentPage: U(() => t() + 1), | ||
maxPage: s, | ||
maxPage: n, | ||
prev() { | ||
return u(t() - 1); | ||
return a(t() - 1); | ||
}, | ||
next() { | ||
return u(t() + 1); | ||
return a(t() + 1); | ||
}, | ||
waitForDone() { | ||
return y(this, null, function* () { | ||
return S(this, null, function* () { | ||
return Q(r.debounceTime + 10).then(o.promise); | ||
@@ -287,14 +279,14 @@ }); | ||
refetch: c, | ||
goto: u, | ||
goto: a, | ||
currentData: o | ||
}; | ||
}, he = (e, r) => { | ||
const t = f([], { equals: !1 }), s = V((...o) => y(void 0, null, function* () { | ||
const t = f([], { equals: !1 }), n = V((...o) => S(void 0, null, function* () { | ||
const c = yield e(...o); | ||
return t((u) => (u[o[0]] = c, u)), c; | ||
return t((a) => (a[o[0]] = c, a)), c; | ||
}), r); | ||
return p(b({}, s), { | ||
return A(y({}, n), { | ||
resetStack(o = !0) { | ||
E(() => { | ||
t([]), s.currentIndex(0), o && s.currentData.refetch(); | ||
O(() => { | ||
t([]), n.currentIndex(0), o && n.currentData.refetch(); | ||
}); | ||
@@ -305,34 +297,34 @@ }, | ||
}, de = function(e = {}) { | ||
var u, a; | ||
const r = R(k((u = e.activeIds) != null ? u : [])), t = k((a = e.multi) != null ? a : !0), s = f(new Set(r())); | ||
var a, u; | ||
const r = j(P((a = e.activeIds) != null ? a : [])), t = P((u = e.multi) != null ? u : !0), n = f(new Set(r())); | ||
x(() => { | ||
!t() && r((n) => n.slice(0, 1)), s(() => new Set(r())); | ||
!t() && r((s) => s.slice(0, 1)), n(() => new Set(r())); | ||
}); | ||
const o = f(/* @__PURE__ */ new Set(), { equals: !1 }), c = (n, l) => { | ||
l === void 0 && (l = !s().has(n)), l === !0 && !s().has(n) ? r((i) => t() ? [...i, n] : [n]) : l === !1 && r.removeAll(n); | ||
const o = f(/* @__PURE__ */ new Set(), { equals: !1 }), c = (s, l) => { | ||
l === void 0 && (l = !n().has(s)), l === !0 && !n().has(s) ? r((i) => t() ? [...i, s] : [s]) : l === !1 && r.removeAll(s); | ||
}; | ||
return { | ||
changeSelected: c, | ||
register(n, l = !1) { | ||
o((i) => (i.add(n), i)), c(n, l); | ||
register(s, l = !1) { | ||
o((i) => (i.add(s), i)), c(s, l); | ||
}, | ||
deregister(n) { | ||
r.removeAll(n), o((l) => (l.delete(n), l)); | ||
deregister(s) { | ||
r.removeAll(s), o((l) => (l.delete(s), l)); | ||
}, | ||
allRegistered: o, | ||
activeIds: s, | ||
isSelected: (n) => s().has(n) | ||
activeIds: n, | ||
isSelected: (s) => n().has(s) | ||
}; | ||
}, me = (e, r, t, { | ||
on: s = (c) => c.addEventListener, | ||
on: n = (c) => c.addEventListener, | ||
off: o = (c) => c.removeEventListener | ||
} = {}) => { | ||
s(e).call(e, r, t), _(() => { | ||
n(e).call(e, r, t), $(() => { | ||
o(e).call(e, r, t); | ||
}); | ||
}, ge = (e) => { | ||
const r = (t, s, o) => { | ||
const c = o != null ? o : new s(); | ||
return Object.entries(t()).forEach(([u, a]) => { | ||
c.set(u, a.toString()); | ||
const r = (t, n, o) => { | ||
const c = o != null ? o : new n(); | ||
return Object.entries(t()).forEach(([a, u]) => { | ||
c.set(a, u.toString()); | ||
}), c; | ||
@@ -342,3 +334,3 @@ }; | ||
toKeysAtom() { | ||
return O(() => R(Object.keys(e))); | ||
return k(() => j(Object.keys(e))); | ||
}, | ||
@@ -366,3 +358,3 @@ toEntries() { | ||
export { | ||
R as ArrayAtom, | ||
j as ArrayAtom, | ||
se as AtomToArray, | ||
@@ -378,3 +370,3 @@ d as AtomTypeSymbol, | ||
f as atom, | ||
k as atomization, | ||
P as atomization, | ||
fe as createBlackBoard, | ||
@@ -384,5 +376,5 @@ ee as createIgnoreFirst, | ||
te as getAtomType, | ||
A as isAtom, | ||
w as isAtom, | ||
ce as localSync, | ||
O as reflect, | ||
k as reflect, | ||
U as reflectMemo, | ||
@@ -389,0 +381,0 @@ W as resource, |
@@ -1,35 +0,35 @@ | ||
var j = Object.defineProperty, B = Object.defineProperties; | ||
var R = Object.defineProperty, B = Object.defineProperties; | ||
var F = Object.getOwnPropertyDescriptors; | ||
var P = Object.getOwnPropertySymbols; | ||
var I = Object.getOwnPropertySymbols; | ||
var J = Object.prototype.hasOwnProperty, N = Object.prototype.propertyIsEnumerable; | ||
var T = (e, r, t) => r in e ? j(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, b = (e, r) => { | ||
var T = (e, r, t) => r in e ? R(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, y = (e, r) => { | ||
for (var t in r || (r = {})) | ||
J.call(r, t) && T(e, t, r[t]); | ||
if (P) | ||
for (var t of P(r)) | ||
if (I) | ||
for (var t of I(r)) | ||
N.call(r, t) && T(e, t, r[t]); | ||
return e; | ||
}, p = (e, r) => B(e, F(r)); | ||
var y = (e, r, t) => new Promise((s, o) => { | ||
var c = (n) => { | ||
}, A = (e, r) => B(e, F(r)); | ||
var S = (e, r, t) => new Promise((n, o) => { | ||
var c = (s) => { | ||
try { | ||
a(t.next(n)); | ||
u(t.next(s)); | ||
} catch (l) { | ||
o(l); | ||
} | ||
}, u = (n) => { | ||
}, a = (s) => { | ||
try { | ||
a(t.throw(n)); | ||
u(t.throw(s)); | ||
} catch (l) { | ||
o(l); | ||
} | ||
}, a = (n) => n.done ? s(n.value) : Promise.resolve(n.value).then(c, u); | ||
a((t = t.apply(e, r)).next()); | ||
}, u = (s) => s.done ? n(s.value) : Promise.resolve(s.value).then(c, a); | ||
u((t = t.apply(e, r)).next()); | ||
}); | ||
import { createEffect as x, on as q, createSignal as H, untrack as $, createMemo as M, batch as E, onCleanup as _ } from "solid-js"; | ||
import { createEffect as x, on as q, createSignal as H, untrack as _, createMemo as M, batch as O, onCleanup as $ } from "solid-js"; | ||
import { debounce as D, throttle as z } from "lodash-es"; | ||
const g = (e, r, t = null) => { | ||
let s = !0; | ||
let n = !0; | ||
return C( | ||
(o) => s ? (s = !1, null) : e(o), | ||
(o) => n ? (n = !1, null) : e(o), | ||
r, | ||
@@ -39,30 +39,30 @@ t | ||
}, ee = g, C = (e, r, t = null) => { | ||
let s = t; | ||
let n = t; | ||
return x( | ||
q(r, () => (s = e(s), s)) | ||
q(r, () => (n = e(n), n)) | ||
); | ||
}, d = Symbol("AtomTypeSymbol"), te = (e) => e[d], f = (e, r) => { | ||
const [t, s] = H(e, r); | ||
const [t, n] = H(e, r); | ||
return Object.assign( | ||
(...o) => o.length === 0 ? t() : s(...o), | ||
(...o) => o.length === 0 ? t() : n(...o), | ||
{ reflux: K, [d]: "atom" } | ||
); | ||
}, K = function(e, r, t) { | ||
const s = this, o = f(e, t); | ||
const n = this, o = f(e, t); | ||
return g(() => { | ||
s(() => r(o())); | ||
n(() => r(o())); | ||
}, [o]), o[d] = "reflux", o; | ||
}, O = (e, { | ||
}, k = (e, { | ||
immediately: r = !0, | ||
initValue: t = null | ||
} = {}) => { | ||
const s = f(r ? $(() => e(t)) : t); | ||
const n = f(r ? _(() => e(t)) : t); | ||
return x((o) => { | ||
s(() => e(o)); | ||
}, t), s[d] = "reflect", s; | ||
n(() => e(o)); | ||
}, t), n[d] = "reflect", n; | ||
}, U = (e, { | ||
immediately: r = !0, | ||
initValue: t = null | ||
} = {}) => M((s) => { | ||
const o = e(s); | ||
} = {}) => M((n) => { | ||
const o = e(n); | ||
return r ? o : (r = !0, t); | ||
@@ -72,29 +72,29 @@ }, t), W = (e, { | ||
immediately: t = !0, | ||
deps: s, | ||
deps: n, | ||
refetch: o = {}, | ||
tap: c = (a) => { | ||
tap: c = (u) => { | ||
}, | ||
ignoreError: u = !1 | ||
ignoreError: a = !1 | ||
} = {}) => { | ||
const a = f(r), n = f(!1), l = f(!1), i = M(() => !n() && !l()); | ||
const u = f(r), s = f(!1), l = f(!1), i = M(() => !s() && !l()); | ||
let h = Promise.resolve(!1); | ||
const w = (...we) => y(void 0, [...we], function* ({ warn: S = !0, cancelCallback: I } = o) { | ||
i() || (I ? I(h) : S && console.warn( | ||
const v = (...Se) => S(void 0, [...Se], function* ({ warn: b = !0, cancelCallback: p } = o) { | ||
i() || (p ? p(h) : b && console.warn( | ||
"Resource Atom: some fetch has been covered; Recommend to add a cancelCallback to some Hook" | ||
)), n(!0); | ||
const v = e().then((m) => (E(() => { | ||
a(() => m), n(!1), l(!1); | ||
}), v === h && c(m), !0)).catch((m) => (E(() => { | ||
l(m), n(!1); | ||
}), u || console.error(m), m)); | ||
return h = v, v; | ||
)), s(!0); | ||
const E = e().then((m) => (O(() => { | ||
u(() => m), s(!1), l(!1); | ||
}), E === h && c(m), !0)).catch((m) => (O(() => { | ||
l(m), s(!1); | ||
}), a || console.error(m), m)); | ||
return h = E, E; | ||
}); | ||
return t && w(), s && s.length && g(() => w(o), s), Object.assign(a, { | ||
return t && v(), n && n.length && g(() => v(o), n), Object.assign(u, { | ||
error: l, | ||
loading: n, | ||
mutate(S) { | ||
a(() => S); | ||
loading: s, | ||
mutate(b) { | ||
u(() => b); | ||
}, | ||
isReady: i, | ||
refetch: w, | ||
refetch: v, | ||
promise: () => h, | ||
@@ -110,21 +110,21 @@ [d]: "resource" | ||
let t = !1; | ||
return function(...s) { | ||
return t ? (r && r(), t) : (t = Promise.resolve(e.apply(this, s)).then((o) => (t = !1, o)), t); | ||
return function(...n) { | ||
return t ? (r && r(), t) : (t = Promise.resolve(e.apply(this, n)).then((o) => (t = !1, o)), t); | ||
}; | ||
}, ne = G; | ||
function k(e) { | ||
return typeof e == "function" ? A(e) ? e : O(e()) : f(e); | ||
function P(e) { | ||
return typeof e == "function" ? w(e) ? e : k(e()) : f(e); | ||
} | ||
function A(e) { | ||
function w(e) { | ||
return typeof e[d] == "string"; | ||
} | ||
const se = (e) => e().map((r, t) => O(() => e()[t])), Q = (e, r) => new Promise((t) => setTimeout(() => t(r), e)), oe = (e) => ({ | ||
const se = (e) => e().map((r, t) => k(() => e()[t])), Q = (e, r) => new Promise((t) => setTimeout(() => t(r), e)), oe = (e) => ({ | ||
value: e(), | ||
"on:input": (r) => e(() => r.target.value) | ||
}), ce = (e, r, t) => { | ||
var c, u, a; | ||
const s = (c = t == null ? void 0 : t.parse) != null ? c : (n) => JSON.parse(n), o = (u = t == null ? void 0 : t.stringify) != null ? u : (n) => JSON.stringify(n); | ||
if ((a = t == null ? void 0 : t.immediately) == null || a) { | ||
const n = localStorage.getItem(r); | ||
n && e(s(n)); | ||
var c, a, u; | ||
const n = (c = t == null ? void 0 : t.parse) != null ? c : (s) => JSON.parse(s), o = (a = t == null ? void 0 : t.stringify) != null ? a : (s) => JSON.stringify(s); | ||
if ((u = t == null ? void 0 : t.immediately) == null || u) { | ||
const s = localStorage.getItem(r); | ||
s && e(n(s)); | ||
} | ||
@@ -135,47 +135,47 @@ return g(() => { | ||
}, ae = (e) => [...Array(e).keys()]; | ||
function R(e, r) { | ||
const t = A(e) ? e : f(e, r), s = (c, u, a) => { | ||
const n = c.findIndex((l) => l === u); | ||
if (n >= 0) { | ||
function j(e, r) { | ||
const t = w(e) ? e : f(e, r), n = (c, a, u) => { | ||
const s = c.findIndex((l) => l === a); | ||
if (s >= 0) { | ||
const l = [...c]; | ||
return a(l, n), l; | ||
return u(l, s), l; | ||
} else | ||
return console.warn("Can't find array atom Item: ", u), c; | ||
return console.warn("Can't find array atom Item: ", a), c; | ||
}; | ||
return Object.assign(t, p(b({}, { | ||
replace(c, u) { | ||
return t((a) => s(a, c, (n, l) => { | ||
n[l] = u; | ||
return Object.assign(t, A(y({}, { | ||
replace(c, a) { | ||
return t((u) => n(u, c, (s, l) => { | ||
s[l] = a; | ||
})), this; | ||
}, | ||
replaceAll(c, u) { | ||
return t((a) => { | ||
const n = []; | ||
a.forEach((i, h) => i === c && n.push(h)); | ||
const l = [...a]; | ||
return n.forEach((i) => l[i] = u), l; | ||
replaceAll(c, a) { | ||
return t((u) => { | ||
const s = []; | ||
u.forEach((i, h) => i === c && s.push(h)); | ||
const l = [...u]; | ||
return s.forEach((i) => l[i] = a), l; | ||
}), this; | ||
}, | ||
remove(c) { | ||
return t((u) => s(u, c, (a, n) => { | ||
a.splice(n, 1); | ||
return t((a) => n(a, c, (u, s) => { | ||
u.splice(s, 1); | ||
})), this; | ||
}, | ||
removeAll(c) { | ||
return t((u) => u.filter((a) => a !== c)), this; | ||
return t((a) => a.filter((u) => u !== c)), this; | ||
}, | ||
insert(c, u, a = "before") { | ||
return t((n) => s(n, u, (l, i) => { | ||
l.splice(a === "before" ? i : i + 1, 0, c); | ||
insert(c, a, u = "before") { | ||
return t((s) => n(s, a, (l, i) => { | ||
l.splice(u === "before" ? i : i + 1, 0, c); | ||
})), this; | ||
}, | ||
move(c, u, a) { | ||
return this.remove(c), this.insert(c, u, a), this; | ||
move(c, a, u) { | ||
return this.remove(c), this.insert(c, a, u), this; | ||
}, | ||
switch(c, u) { | ||
return t((a) => { | ||
const n = [...a], l = t().findIndex((h) => h === c), i = t().findIndex((h) => h === u); | ||
switch(c, a) { | ||
return t((u) => { | ||
const s = [...u], l = t().findIndex((h) => h === c), i = t().findIndex((h) => h === a); | ||
if (l === -1 || i === -1) | ||
throw new Error("ArrayAtom: Please check the Items you want to switch "); | ||
return n[l] = u, n[i] = c, n; | ||
return s[l] = a, s[i] = c, s; | ||
}), this; | ||
@@ -186,35 +186,27 @@ } | ||
function ue(e, r) { | ||
const t = A(e) ? e : f(e, { equals: !1 }), s = A(e) ? e() : e; | ||
t[d] = "object"; | ||
const o = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set([d, ...Object.keys(s)]); | ||
return new Proxy(t, { | ||
get(u, a, n) { | ||
if (!c.has(a)) | ||
throw new Error(`key: ${a} can't be found in formObject!`); | ||
if (o.has(a)) | ||
return o.get(a); | ||
{ | ||
const l = t.reflux(u()[a], (i) => (u()[a] = i, u())); | ||
return o.set(a, l), l; | ||
} | ||
}, | ||
apply(u, a, n) { | ||
return Reflect.apply(u, a, n); | ||
} | ||
}); | ||
const t = w(e) ? e : f(e, { equals: !1 }), n = w(e) ? e() : e; | ||
return t[d] = "object", Object.assign( | ||
t, | ||
Object.fromEntries( | ||
Object.keys(n).reduce((o, c) => { | ||
const a = t.reflux(t()[c], (u) => A(y({}, t()), { [c]: u })); | ||
return o.push([c, a]), o; | ||
}, []) | ||
) | ||
); | ||
} | ||
function le(e, r = 150) { | ||
let t = e(); | ||
const s = f(t); | ||
const n = f(t); | ||
return g( | ||
D(() => { | ||
const o = e(); | ||
o !== void 0 && s(() => o); | ||
o !== void 0 && n(() => o); | ||
}, r), | ||
[e] | ||
), s; | ||
), n; | ||
} | ||
function ie(e, r = 150, t) { | ||
let s = e(); | ||
const o = f(s); | ||
let n = e(); | ||
const o = f(n); | ||
return g( | ||
@@ -258,6 +250,6 @@ z( | ||
}, V = (e, r = {}) => { | ||
var a, n; | ||
r.debounceTime = (a = r.debounceTime) != null ? a : 100; | ||
const t = f((n = r.initIndex) != null ? n : 0), s = f(10), o = W(() => e(t(), s), r), c = D(() => o.refetch(), r.debounceTime), u = (i) => { | ||
if (i < 0 || i >= s()) | ||
var u, s; | ||
r.debounceTime = (u = r.debounceTime) != null ? u : 100; | ||
const t = f((s = r.initIndex) != null ? s : 0), n = f(10), o = W(() => e(t(), n), r), c = D(() => o.refetch(), r.debounceTime), a = (i) => { | ||
if (i < 0 || i >= n()) | ||
return !1; | ||
@@ -273,11 +265,11 @@ { | ||
currentPage: U(() => t() + 1), | ||
maxPage: s, | ||
maxPage: n, | ||
prev() { | ||
return u(t() - 1); | ||
return a(t() - 1); | ||
}, | ||
next() { | ||
return u(t() + 1); | ||
return a(t() + 1); | ||
}, | ||
waitForDone() { | ||
return y(this, null, function* () { | ||
return S(this, null, function* () { | ||
return Q(r.debounceTime + 10).then(o.promise); | ||
@@ -287,14 +279,14 @@ }); | ||
refetch: c, | ||
goto: u, | ||
goto: a, | ||
currentData: o | ||
}; | ||
}, he = (e, r) => { | ||
const t = f([], { equals: !1 }), s = V((...o) => y(void 0, null, function* () { | ||
const t = f([], { equals: !1 }), n = V((...o) => S(void 0, null, function* () { | ||
const c = yield e(...o); | ||
return t((u) => (u[o[0]] = c, u)), c; | ||
return t((a) => (a[o[0]] = c, a)), c; | ||
}), r); | ||
return p(b({}, s), { | ||
return A(y({}, n), { | ||
resetStack(o = !0) { | ||
E(() => { | ||
t([]), s.currentIndex(0), o && s.currentData.refetch(); | ||
O(() => { | ||
t([]), n.currentIndex(0), o && n.currentData.refetch(); | ||
}); | ||
@@ -305,34 +297,34 @@ }, | ||
}, de = function(e = {}) { | ||
var u, a; | ||
const r = R(k((u = e.activeIds) != null ? u : [])), t = k((a = e.multi) != null ? a : !0), s = f(new Set(r())); | ||
var a, u; | ||
const r = j(P((a = e.activeIds) != null ? a : [])), t = P((u = e.multi) != null ? u : !0), n = f(new Set(r())); | ||
x(() => { | ||
!t() && r((n) => n.slice(0, 1)), s(() => new Set(r())); | ||
!t() && r((s) => s.slice(0, 1)), n(() => new Set(r())); | ||
}); | ||
const o = f(/* @__PURE__ */ new Set(), { equals: !1 }), c = (n, l) => { | ||
l === void 0 && (l = !s().has(n)), l === !0 && !s().has(n) ? r((i) => t() ? [...i, n] : [n]) : l === !1 && r.removeAll(n); | ||
const o = f(/* @__PURE__ */ new Set(), { equals: !1 }), c = (s, l) => { | ||
l === void 0 && (l = !n().has(s)), l === !0 && !n().has(s) ? r((i) => t() ? [...i, s] : [s]) : l === !1 && r.removeAll(s); | ||
}; | ||
return { | ||
changeSelected: c, | ||
register(n, l = !1) { | ||
o((i) => (i.add(n), i)), c(n, l); | ||
register(s, l = !1) { | ||
o((i) => (i.add(s), i)), c(s, l); | ||
}, | ||
deregister(n) { | ||
r.removeAll(n), o((l) => (l.delete(n), l)); | ||
deregister(s) { | ||
r.removeAll(s), o((l) => (l.delete(s), l)); | ||
}, | ||
allRegistered: o, | ||
activeIds: s, | ||
isSelected: (n) => s().has(n) | ||
activeIds: n, | ||
isSelected: (s) => n().has(s) | ||
}; | ||
}, me = (e, r, t, { | ||
on: s = (c) => c.addEventListener, | ||
on: n = (c) => c.addEventListener, | ||
off: o = (c) => c.removeEventListener | ||
} = {}) => { | ||
s(e).call(e, r, t), _(() => { | ||
n(e).call(e, r, t), $(() => { | ||
o(e).call(e, r, t); | ||
}); | ||
}, ge = (e) => { | ||
const r = (t, s, o) => { | ||
const c = o != null ? o : new s(); | ||
return Object.entries(t()).forEach(([u, a]) => { | ||
c.set(u, a.toString()); | ||
const r = (t, n, o) => { | ||
const c = o != null ? o : new n(); | ||
return Object.entries(t()).forEach(([a, u]) => { | ||
c.set(a, u.toString()); | ||
}), c; | ||
@@ -342,3 +334,3 @@ }; | ||
toKeysAtom() { | ||
return O(() => R(Object.keys(e))); | ||
return k(() => j(Object.keys(e))); | ||
}, | ||
@@ -366,3 +358,3 @@ toEntries() { | ||
export { | ||
R as ArrayAtom, | ||
j as ArrayAtom, | ||
se as AtomToArray, | ||
@@ -378,3 +370,3 @@ d as AtomTypeSymbol, | ||
f as atom, | ||
k as atomization, | ||
P as atomization, | ||
fe as createBlackBoard, | ||
@@ -384,5 +376,5 @@ ee as createIgnoreFirst, | ||
te as getAtomType, | ||
A as isAtom, | ||
w as isAtom, | ||
ce as localSync, | ||
O as reflect, | ||
k as reflect, | ||
U as reflectMemo, | ||
@@ -389,0 +381,0 @@ W as resource, |
{ | ||
"name": "@cn-ui/reactive", | ||
"version": "2.2.3", | ||
"version": "2.2.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77948
1134