@gsc-basic/components 1.0.1 → 1.0.2
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.
- package/README.md +59 -0
- package/dist/es/index.js +34 -30
- package/dist/es/node_modules/@codemirror/commands/dist/index.js +26 -20
- package/dist/es/node_modules/@codemirror/language/dist/index.js +77 -77
- package/dist/es/node_modules/@codemirror/search/dist/index.js +432 -465
- package/dist/es/node_modules/@codemirror/state/dist/index.js +272 -268
- package/dist/es/node_modules/@codemirror/view/dist/index.js +1732 -1647
- package/dist/es/node_modules/@lezer/common/dist/index.js +191 -190
- package/dist/es/node_modules/@lezer/lr/dist/index.js +3 -3
- package/dist/es/node_modules/@tanstack/devtools-event-client/dist/esm/plugin.js +178 -0
- package/dist/es/node_modules/@tanstack/form-core/dist/esm/EventClient.js +13 -0
- package/dist/es/node_modules/@tanstack/form-core/dist/esm/FieldApi.js +406 -0
- package/dist/es/node_modules/@tanstack/form-core/dist/esm/FormApi.js +768 -0
- package/dist/es/node_modules/@tanstack/form-core/dist/esm/ValidationLogic.js +55 -0
- package/dist/es/node_modules/@tanstack/form-core/dist/esm/metaHelper.js +109 -0
- package/dist/es/node_modules/@tanstack/form-core/dist/esm/standardSchemaValidator.js +45 -0
- package/dist/es/node_modules/@tanstack/form-core/dist/esm/utils.js +213 -0
- package/dist/es/node_modules/@tanstack/pacer-lite/dist/lite-throttler.js +29 -0
- package/dist/es/node_modules/@tanstack/store/dist/esm/derived.js +74 -0
- package/dist/es/node_modules/@tanstack/store/dist/esm/scheduler.js +79 -0
- package/dist/es/node_modules/@tanstack/store/dist/esm/store.js +21 -0
- package/dist/es/node_modules/@tanstack/store/dist/esm/types.js +6 -0
- package/dist/es/node_modules/@tanstack/table-core/build/lib/index.js +1885 -0
- package/dist/es/node_modules/@tanstack/vue-form/dist/esm/useField.js +38 -0
- package/dist/es/node_modules/@tanstack/vue-form/dist/esm/useForm.js +33 -0
- package/dist/es/node_modules/@tanstack/vue-store/dist/esm/index.js +48 -0
- package/dist/es/node_modules/@tanstack/vue-table/build/lib/index.js +159 -0
- package/dist/es/src/Grid/index.js +6 -0
- package/dist/es/src/Grid/src/Grid.css +1 -0
- package/dist/es/src/Grid/src/Grid.vue.js +186 -0
- package/dist/es/src/Grid/src/components/ActionBar.css +1 -0
- package/dist/es/src/Grid/src/components/ActionBar.vue.js +58 -0
- package/dist/es/src/Grid/src/components/CellEditor.css +1 -0
- package/dist/es/src/Grid/src/components/CellEditor.vue.js +121 -0
- package/dist/es/src/Grid/src/components/CellEditor2.css +1 -0
- package/dist/es/src/Grid/src/components/ColumnFilter.css +1 -0
- package/dist/es/src/Grid/src/components/ColumnFilter.vue.js +61 -0
- package/dist/es/src/Grid/src/components/ColumnSettings.css +1 -0
- package/dist/es/src/Grid/src/components/ColumnSettings.vue.js +86 -0
- package/dist/es/src/Grid/src/components/DataTable.css +1 -0
- package/dist/es/src/Grid/src/components/DataTable.vue.js +533 -0
- package/dist/es/src/Grid/src/components/Pager.css +1 -0
- package/dist/es/src/Grid/src/components/Pager.vue.js +55 -0
- package/dist/es/src/Grid/src/components/QueryBar.css +1 -0
- package/dist/es/src/Grid/src/components/QueryBar.vue.js +184 -0
- package/dist/es/src/Grid/src/composables/useCellEditor.js +20 -0
- package/dist/es/src/Grid/src/composables/useGridTable.js +212 -0
- package/dist/es/src/Grid/src/styles/antd.css +1 -0
- package/dist/es/src/Grid/src/utils/exportCsv.js +15 -0
- package/dist/es/src/index.js +23 -21
- package/dist/es/src/locale/lang/en-US.js +40 -0
- package/dist/es/src/locale/lang/ja-JP.js +42 -2
- package/dist/es/src/locale/lang/zh-CN.js +42 -2
- package/dist/es/src/styles/tokens.css +1 -1
- package/dist/lib/index.js +1 -1
- package/dist/lib/node_modules/@codemirror/commands/dist/index.js +1 -1
- package/dist/lib/node_modules/@codemirror/language/dist/index.js +1 -1
- package/dist/lib/node_modules/@codemirror/search/dist/index.js +2 -2
- package/dist/lib/node_modules/@codemirror/state/dist/index.js +4 -4
- package/dist/lib/node_modules/@codemirror/view/dist/index.js +5 -5
- package/dist/lib/node_modules/@lezer/common/dist/index.js +1 -1
- package/dist/lib/node_modules/@lezer/lr/dist/index.js +1 -1
- package/dist/lib/node_modules/@tanstack/devtools-event-client/dist/esm/plugin.js +1 -0
- package/dist/lib/node_modules/@tanstack/form-core/dist/esm/EventClient.js +1 -0
- package/dist/lib/node_modules/@tanstack/form-core/dist/esm/FieldApi.js +1 -0
- package/dist/lib/node_modules/@tanstack/form-core/dist/esm/FormApi.js +1 -0
- package/dist/lib/node_modules/@tanstack/form-core/dist/esm/ValidationLogic.js +1 -0
- package/dist/lib/node_modules/@tanstack/form-core/dist/esm/metaHelper.js +1 -0
- package/dist/lib/node_modules/@tanstack/form-core/dist/esm/standardSchemaValidator.js +1 -0
- package/dist/lib/node_modules/@tanstack/form-core/dist/esm/utils.js +1 -0
- package/dist/lib/node_modules/@tanstack/pacer-lite/dist/lite-throttler.js +1 -0
- package/dist/lib/node_modules/@tanstack/store/dist/esm/derived.js +1 -0
- package/dist/lib/node_modules/@tanstack/store/dist/esm/scheduler.js +1 -0
- package/dist/lib/node_modules/@tanstack/store/dist/esm/store.js +1 -0
- package/dist/lib/node_modules/@tanstack/store/dist/esm/types.js +1 -0
- package/dist/lib/node_modules/@tanstack/table-core/build/lib/index.js +4 -0
- package/dist/lib/node_modules/@tanstack/vue-form/dist/esm/useField.js +1 -0
- package/dist/lib/node_modules/@tanstack/vue-form/dist/esm/useForm.js +1 -0
- package/dist/lib/node_modules/@tanstack/vue-store/dist/esm/index.js +1 -0
- package/dist/lib/node_modules/@tanstack/vue-table/build/lib/index.js +1 -0
- package/dist/lib/src/Grid/index.js +1 -0
- package/dist/lib/src/Grid/src/Grid.css +1 -0
- package/dist/lib/src/Grid/src/Grid.vue.js +1 -0
- package/dist/lib/src/Grid/src/components/ActionBar.css +1 -0
- package/dist/lib/src/Grid/src/components/ActionBar.vue.js +1 -0
- package/dist/lib/src/Grid/src/components/CellEditor.css +1 -0
- package/dist/lib/src/Grid/src/components/CellEditor.vue.js +1 -0
- package/dist/lib/src/Grid/src/components/CellEditor2.css +1 -0
- package/dist/lib/src/Grid/src/components/ColumnFilter.css +1 -0
- package/dist/lib/src/Grid/src/components/ColumnFilter.vue.js +1 -0
- package/dist/lib/src/Grid/src/components/ColumnSettings.css +1 -0
- package/dist/lib/src/Grid/src/components/ColumnSettings.vue.js +1 -0
- package/dist/lib/src/Grid/src/components/DataTable.css +1 -0
- package/dist/lib/src/Grid/src/components/DataTable.vue.js +1 -0
- package/dist/lib/src/Grid/src/components/Pager.css +1 -0
- package/dist/lib/src/Grid/src/components/Pager.vue.js +1 -0
- package/dist/lib/src/Grid/src/components/QueryBar.css +1 -0
- package/dist/lib/src/Grid/src/components/QueryBar.vue.js +1 -0
- package/dist/lib/src/Grid/src/composables/useCellEditor.js +1 -0
- package/dist/lib/src/Grid/src/composables/useGridTable.js +1 -0
- package/dist/lib/src/Grid/src/styles/antd.css +1 -0
- package/dist/lib/src/Grid/src/utils/exportCsv.js +3 -0
- package/dist/lib/src/index.js +1 -1
- package/dist/lib/src/locale/lang/en-US.js +1 -1
- package/dist/lib/src/locale/lang/ja-JP.js +1 -1
- package/dist/lib/src/locale/lang/zh-CN.js +1 -1
- package/dist/lib/src/styles/tokens.css +1 -1
- package/package.json +6 -3
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const l = (a) => {
|
|
2
|
+
if (!a.validators)
|
|
3
|
+
return a.runValidation({
|
|
4
|
+
validators: [],
|
|
5
|
+
form: a.form
|
|
6
|
+
});
|
|
7
|
+
const n = a.event.async, r = n ? void 0 : { fn: a.validators.onMount, cause: "mount" }, o = {
|
|
8
|
+
fn: n ? a.validators.onChangeAsync : a.validators.onChange,
|
|
9
|
+
cause: "change"
|
|
10
|
+
}, i = {
|
|
11
|
+
fn: n ? a.validators.onBlurAsync : a.validators.onBlur,
|
|
12
|
+
cause: "blur"
|
|
13
|
+
}, e = {
|
|
14
|
+
fn: n ? a.validators.onSubmitAsync : a.validators.onSubmit,
|
|
15
|
+
cause: "submit"
|
|
16
|
+
}, t = n ? void 0 : { fn: () => {
|
|
17
|
+
}, cause: "server" };
|
|
18
|
+
switch (a.event.type) {
|
|
19
|
+
case "mount":
|
|
20
|
+
return a.runValidation({
|
|
21
|
+
validators: [r],
|
|
22
|
+
form: a.form
|
|
23
|
+
});
|
|
24
|
+
case "submit":
|
|
25
|
+
return a.runValidation({
|
|
26
|
+
validators: [
|
|
27
|
+
o,
|
|
28
|
+
i,
|
|
29
|
+
e,
|
|
30
|
+
t
|
|
31
|
+
],
|
|
32
|
+
form: a.form
|
|
33
|
+
});
|
|
34
|
+
case "server":
|
|
35
|
+
return a.runValidation({
|
|
36
|
+
validators: [],
|
|
37
|
+
form: a.form
|
|
38
|
+
});
|
|
39
|
+
case "blur":
|
|
40
|
+
return a.runValidation({
|
|
41
|
+
validators: [i, t],
|
|
42
|
+
form: a.form
|
|
43
|
+
});
|
|
44
|
+
case "change":
|
|
45
|
+
return a.runValidation({
|
|
46
|
+
validators: [o, t],
|
|
47
|
+
form: a.form
|
|
48
|
+
});
|
|
49
|
+
default:
|
|
50
|
+
throw new Error(`Unknown validation event type: ${a.event.type}`);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
l as defaultValidationLogic
|
|
55
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
const k = {
|
|
2
|
+
isValidating: !1,
|
|
3
|
+
isTouched: !1,
|
|
4
|
+
isBlurred: !1,
|
|
5
|
+
isDirty: !1,
|
|
6
|
+
isPristine: !0,
|
|
7
|
+
isValid: !0,
|
|
8
|
+
isDefaultValue: !0,
|
|
9
|
+
errors: [],
|
|
10
|
+
errorMap: {},
|
|
11
|
+
errorSourceMap: {}
|
|
12
|
+
};
|
|
13
|
+
function v(u) {
|
|
14
|
+
function f(t, e, s) {
|
|
15
|
+
const r = h(t, e, "move", s), n = Math.min(e, s), c = Math.max(e, s);
|
|
16
|
+
for (let a = n; a <= c; a++)
|
|
17
|
+
r.push(o(t, a));
|
|
18
|
+
const i = Object.keys(u.fieldInfo).reduce(
|
|
19
|
+
(a, l) => (l.startsWith(o(t, e)) && a.set(
|
|
20
|
+
l,
|
|
21
|
+
u.getFieldMeta(l)
|
|
22
|
+
), a),
|
|
23
|
+
/* @__PURE__ */ new Map()
|
|
24
|
+
);
|
|
25
|
+
F(r, e < s ? "up" : "down"), Object.keys(u.fieldInfo).filter((a) => a.startsWith(o(t, s))).forEach((a) => {
|
|
26
|
+
const l = a.replace(
|
|
27
|
+
o(t, s),
|
|
28
|
+
o(t, e)
|
|
29
|
+
), d = i.get(l);
|
|
30
|
+
d && u.setFieldMeta(a, d);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function g(t, e) {
|
|
34
|
+
const s = h(t, e, "remove");
|
|
35
|
+
F(s, "up");
|
|
36
|
+
}
|
|
37
|
+
function p(t, e, s) {
|
|
38
|
+
h(t, e, "swap", s).forEach((n) => {
|
|
39
|
+
if (!n.toString().startsWith(o(t, e)))
|
|
40
|
+
return;
|
|
41
|
+
const c = n.toString().replace(
|
|
42
|
+
o(t, e),
|
|
43
|
+
o(t, s)
|
|
44
|
+
), [i, a] = [
|
|
45
|
+
u.getFieldMeta(n),
|
|
46
|
+
u.getFieldMeta(c)
|
|
47
|
+
];
|
|
48
|
+
i && u.setFieldMeta(c, i), a && u.setFieldMeta(n, a);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function w(t, e) {
|
|
52
|
+
const s = h(t, e, "insert");
|
|
53
|
+
F(s, "down"), s.forEach((r) => {
|
|
54
|
+
r.toString().startsWith(o(t, e)) && u.setFieldMeta(r, M());
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function o(t, e) {
|
|
58
|
+
return `${t}[${e}]`;
|
|
59
|
+
}
|
|
60
|
+
function h(t, e, s, r) {
|
|
61
|
+
const n = [o(t, e)];
|
|
62
|
+
switch (s) {
|
|
63
|
+
case "swap":
|
|
64
|
+
n.push(o(t, r));
|
|
65
|
+
break;
|
|
66
|
+
case "move": {
|
|
67
|
+
const [c, i] = [
|
|
68
|
+
Math.min(e, r),
|
|
69
|
+
Math.max(e, r)
|
|
70
|
+
];
|
|
71
|
+
for (let a = c; a <= i; a++)
|
|
72
|
+
n.push(o(t, a));
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
default: {
|
|
76
|
+
const c = u.getFieldValue(t), i = Array.isArray(c) ? c.length : 0;
|
|
77
|
+
for (let a = e + 1; a < i; a++)
|
|
78
|
+
n.push(o(t, a));
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return Object.keys(u.fieldInfo).filter(
|
|
83
|
+
(c) => n.some((i) => c.startsWith(i))
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
function b(t, e) {
|
|
87
|
+
return t.replace(/\[(\d+)\]/, (s, r) => {
|
|
88
|
+
const n = parseInt(r, 10);
|
|
89
|
+
return `[${e === "up" ? n + 1 : Math.max(0, n - 1)}]`;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function F(t, e) {
|
|
93
|
+
(e === "up" ? t : [...t].reverse()).forEach((r) => {
|
|
94
|
+
const n = b(r.toString(), e), c = u.getFieldMeta(n);
|
|
95
|
+
c ? u.setFieldMeta(r, c) : u.setFieldMeta(r, M());
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
const M = () => k;
|
|
99
|
+
return {
|
|
100
|
+
handleArrayMove: f,
|
|
101
|
+
handleArrayRemove: g,
|
|
102
|
+
handleArraySwap: p,
|
|
103
|
+
handleArrayInsert: w
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
k as defaultFieldMeta,
|
|
108
|
+
v as metaHelper
|
|
109
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
function l(s, r) {
|
|
2
|
+
const t = /* @__PURE__ */ new Map();
|
|
3
|
+
for (const e of s) {
|
|
4
|
+
const u = e.path ?? [];
|
|
5
|
+
let n = r, a = "";
|
|
6
|
+
for (let i = 0; i < u.length; i++) {
|
|
7
|
+
const o = u[i];
|
|
8
|
+
if (o === void 0) continue;
|
|
9
|
+
const c = typeof o == "object" ? o.key : o, f = Number(c);
|
|
10
|
+
Array.isArray(n) && !Number.isNaN(f) ? a += `[${f}]` : a += (i > 0 ? "." : "") + String(c), typeof n == "object" && n !== null ? n = n[c] : n = void 0;
|
|
11
|
+
}
|
|
12
|
+
t.set(a, (t.get(a) ?? []).concat(e));
|
|
13
|
+
}
|
|
14
|
+
return Object.fromEntries(t);
|
|
15
|
+
}
|
|
16
|
+
const d = (s, r) => {
|
|
17
|
+
const t = l(s, r);
|
|
18
|
+
return {
|
|
19
|
+
form: t,
|
|
20
|
+
fields: t
|
|
21
|
+
};
|
|
22
|
+
}, m = {
|
|
23
|
+
validate({
|
|
24
|
+
value: s,
|
|
25
|
+
validationSource: r
|
|
26
|
+
}, t) {
|
|
27
|
+
const e = t["~standard"].validate(s);
|
|
28
|
+
if (e instanceof Promise)
|
|
29
|
+
throw new Error("async function passed to sync validator");
|
|
30
|
+
if (e.issues)
|
|
31
|
+
return r === "field" ? e.issues : d(e.issues, s);
|
|
32
|
+
},
|
|
33
|
+
async validateAsync({
|
|
34
|
+
value: s,
|
|
35
|
+
validationSource: r
|
|
36
|
+
}, t) {
|
|
37
|
+
const e = await t["~standard"].validate(s);
|
|
38
|
+
if (e.issues)
|
|
39
|
+
return r === "field" ? e.issues : d(e.issues, s);
|
|
40
|
+
}
|
|
41
|
+
}, h = (s) => !!s && "~standard" in s;
|
|
42
|
+
export {
|
|
43
|
+
h as isStandardSchemaValidator,
|
|
44
|
+
m as standardSchemaValidators
|
|
45
|
+
};
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { liteThrottle as v } from "../../../pacer-lite/dist/lite-throttler.js";
|
|
2
|
+
import { formEventClient as D } from "./EventClient.js";
|
|
3
|
+
function S(e, t) {
|
|
4
|
+
return typeof e == "function" ? e(t) : e;
|
|
5
|
+
}
|
|
6
|
+
function $(e, t) {
|
|
7
|
+
return w(t).reduce((o, r) => {
|
|
8
|
+
if (o === null) return null;
|
|
9
|
+
if (typeof o < "u")
|
|
10
|
+
return o[r];
|
|
11
|
+
}, e);
|
|
12
|
+
}
|
|
13
|
+
function F(e, t, n) {
|
|
14
|
+
const o = w(t);
|
|
15
|
+
function r(i) {
|
|
16
|
+
if (!o.length)
|
|
17
|
+
return S(n, i);
|
|
18
|
+
const u = o.shift();
|
|
19
|
+
if (typeof u == "string" || typeof u == "number" && !Array.isArray(i))
|
|
20
|
+
return typeof i == "object" ? (i === null && (i = {}), {
|
|
21
|
+
...i,
|
|
22
|
+
[u]: r(i[u])
|
|
23
|
+
}) : {
|
|
24
|
+
[u]: r()
|
|
25
|
+
};
|
|
26
|
+
if (Array.isArray(i) && typeof u == "number") {
|
|
27
|
+
const c = i.slice(0, u);
|
|
28
|
+
return [
|
|
29
|
+
...c.length ? c : new Array(u),
|
|
30
|
+
r(i[u]),
|
|
31
|
+
...i.slice(u + 1)
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
return [...new Array(u), r()];
|
|
35
|
+
}
|
|
36
|
+
return r(e);
|
|
37
|
+
}
|
|
38
|
+
function T(e, t) {
|
|
39
|
+
const n = w(t);
|
|
40
|
+
function o(r) {
|
|
41
|
+
if (!r) return;
|
|
42
|
+
if (n.length === 1) {
|
|
43
|
+
const u = n[0];
|
|
44
|
+
if (Array.isArray(r) && typeof u == "number")
|
|
45
|
+
return r.filter((g, a) => a !== u);
|
|
46
|
+
const { [u]: c, ...m } = r;
|
|
47
|
+
return m;
|
|
48
|
+
}
|
|
49
|
+
const i = n.shift();
|
|
50
|
+
if ((typeof i == "string" || typeof i == "number" && !Array.isArray(r)) && typeof r == "object")
|
|
51
|
+
return {
|
|
52
|
+
...r,
|
|
53
|
+
[i]: o(r[i])
|
|
54
|
+
};
|
|
55
|
+
if (typeof i == "number" && Array.isArray(r)) {
|
|
56
|
+
if (i >= r.length)
|
|
57
|
+
return r;
|
|
58
|
+
const u = r.slice(0, i);
|
|
59
|
+
return [
|
|
60
|
+
...u.length ? u : new Array(i),
|
|
61
|
+
o(r[i]),
|
|
62
|
+
...r.slice(i + 1)
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
throw new Error("It seems we have created an infinite loop in deleteBy. ");
|
|
66
|
+
}
|
|
67
|
+
return o(e);
|
|
68
|
+
}
|
|
69
|
+
const A = /^(\d+)$/gm, k = /\.(\d+)(?=\.)/gm, E = /^(\d+)\./gm, p = /\.(\d+$)/gm, V = /\.{2,}/gm, h = "__int__", l = `${h}$1`;
|
|
70
|
+
function w(e) {
|
|
71
|
+
if (Array.isArray(e))
|
|
72
|
+
return [...e];
|
|
73
|
+
if (typeof e != "string")
|
|
74
|
+
throw new Error("Path must be a string.");
|
|
75
|
+
return e.replace(/(^\[)|]/gm, "").replace(/\[/g, ".").replace(A, l).replace(k, `.${l}.`).replace(E, `${l}.`).replace(p, `.${l}`).replace(V, ".").split(".").map((t) => {
|
|
76
|
+
if (t.startsWith(h)) {
|
|
77
|
+
const n = t.substring(h.length), o = parseInt(n, 10);
|
|
78
|
+
return String(o) === n ? o : n;
|
|
79
|
+
}
|
|
80
|
+
return t;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function _(e) {
|
|
84
|
+
return !(Array.isArray(e) && e.length === 0);
|
|
85
|
+
}
|
|
86
|
+
function x(e, t) {
|
|
87
|
+
const n = (o) => o.validators.filter(Boolean).map((r) => ({
|
|
88
|
+
cause: r.cause,
|
|
89
|
+
validate: r.fn
|
|
90
|
+
}));
|
|
91
|
+
return t.validationLogic({
|
|
92
|
+
form: t.form,
|
|
93
|
+
validators: t.validators,
|
|
94
|
+
event: { type: e, async: !1 },
|
|
95
|
+
runValidation: n
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function z(e, t) {
|
|
99
|
+
const { asyncDebounceMs: n } = t, {
|
|
100
|
+
onBlurAsyncDebounceMs: o,
|
|
101
|
+
onChangeAsyncDebounceMs: r,
|
|
102
|
+
onDynamicAsyncDebounceMs: i
|
|
103
|
+
} = t.validators || {}, u = n ?? 0, c = (m) => m.validators.filter(Boolean).map((g) => {
|
|
104
|
+
const a = g?.cause || e;
|
|
105
|
+
let f = u;
|
|
106
|
+
switch (a) {
|
|
107
|
+
case "change":
|
|
108
|
+
f = r ?? u;
|
|
109
|
+
break;
|
|
110
|
+
case "blur":
|
|
111
|
+
f = o ?? u;
|
|
112
|
+
break;
|
|
113
|
+
case "dynamic":
|
|
114
|
+
f = i ?? u;
|
|
115
|
+
break;
|
|
116
|
+
case "submit":
|
|
117
|
+
f = 0;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
return e === "submit" && (f = 0), {
|
|
121
|
+
cause: a,
|
|
122
|
+
validate: g.fn,
|
|
123
|
+
debounceMs: f
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
return t.validationLogic({
|
|
127
|
+
form: t.form,
|
|
128
|
+
validators: t.validators,
|
|
129
|
+
event: { type: e, async: !0 },
|
|
130
|
+
runValidation: c
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
const I = (e) => !!e && typeof e == "object" && "fields" in e;
|
|
134
|
+
function M(e, t) {
|
|
135
|
+
if (Object.is(e, t))
|
|
136
|
+
return !0;
|
|
137
|
+
if (typeof e != "object" || e === null || typeof t != "object" || t === null)
|
|
138
|
+
return !1;
|
|
139
|
+
if (e instanceof Date && t instanceof Date)
|
|
140
|
+
return e.getTime() === t.getTime();
|
|
141
|
+
if (e instanceof Map && t instanceof Map) {
|
|
142
|
+
if (e.size !== t.size) return !1;
|
|
143
|
+
for (const [r, i] of e)
|
|
144
|
+
if (!t.has(r) || !Object.is(i, t.get(r))) return !1;
|
|
145
|
+
return !0;
|
|
146
|
+
}
|
|
147
|
+
if (e instanceof Set && t instanceof Set) {
|
|
148
|
+
if (e.size !== t.size) return !1;
|
|
149
|
+
for (const r of e)
|
|
150
|
+
if (!t.has(r)) return !1;
|
|
151
|
+
return !0;
|
|
152
|
+
}
|
|
153
|
+
const n = Object.keys(e), o = Object.keys(t);
|
|
154
|
+
if (n.length !== o.length)
|
|
155
|
+
return !1;
|
|
156
|
+
for (const r of n)
|
|
157
|
+
if (!o.includes(r) || !M(e[r], t[r]))
|
|
158
|
+
return !1;
|
|
159
|
+
return !0;
|
|
160
|
+
}
|
|
161
|
+
const P = ({
|
|
162
|
+
newFormValidatorError: e,
|
|
163
|
+
isPreviousErrorFromFormValidator: t,
|
|
164
|
+
previousErrorValue: n
|
|
165
|
+
}) => e ? { newErrorValue: e, newSource: "form" } : t ? { newErrorValue: void 0, newSource: void 0 } : n ? { newErrorValue: n, newSource: "field" } : { newErrorValue: void 0, newSource: void 0 }, C = ({
|
|
166
|
+
formLevelError: e,
|
|
167
|
+
fieldLevelError: t
|
|
168
|
+
}) => t ? { newErrorValue: t, newSource: "field" } : e ? { newErrorValue: e, newSource: "form" } : { newErrorValue: void 0, newSource: void 0 };
|
|
169
|
+
function L(e, t) {
|
|
170
|
+
return e == null ? t : { ...e, ...t };
|
|
171
|
+
}
|
|
172
|
+
let s = 256;
|
|
173
|
+
const d = [];
|
|
174
|
+
let y;
|
|
175
|
+
for (; s--; )
|
|
176
|
+
d[s] = (s + 256).toString(16).substring(1);
|
|
177
|
+
function W() {
|
|
178
|
+
let e = 0, t, n = "";
|
|
179
|
+
if (!y || s + 16 > 256) {
|
|
180
|
+
for (y = new Array(256), e = 256; e--; )
|
|
181
|
+
y[e] = 256 * Math.random() | 0;
|
|
182
|
+
e = 0, s = 0;
|
|
183
|
+
}
|
|
184
|
+
for (; e < 16; e++)
|
|
185
|
+
t = y[s + e], e === 6 ? n += d[t & 15 | 64] : e === 8 ? n += d[t & 63 | 128] : n += d[t], e & 1 && e > 1 && e < 11 && (n += "-");
|
|
186
|
+
return s++, n;
|
|
187
|
+
}
|
|
188
|
+
const R = v(
|
|
189
|
+
(e) => D.emit("form-state", {
|
|
190
|
+
id: e.formId,
|
|
191
|
+
state: e.store.state
|
|
192
|
+
}),
|
|
193
|
+
{
|
|
194
|
+
wait: 300
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
export {
|
|
198
|
+
T as deleteBy,
|
|
199
|
+
C as determineFieldLevelErrorSourceAndValue,
|
|
200
|
+
P as determineFormLevelErrorSourceAndValue,
|
|
201
|
+
M as evaluate,
|
|
202
|
+
S as functionalUpdate,
|
|
203
|
+
z as getAsyncValidatorArray,
|
|
204
|
+
$ as getBy,
|
|
205
|
+
x as getSyncValidatorArray,
|
|
206
|
+
I as isGlobalFormValidationError,
|
|
207
|
+
_ as isNonEmptyArray,
|
|
208
|
+
w as makePathArray,
|
|
209
|
+
L as mergeOpts,
|
|
210
|
+
F as setBy,
|
|
211
|
+
R as throttleFormState,
|
|
212
|
+
W as uuid
|
|
213
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var h = class {
|
|
2
|
+
constructor(i, s) {
|
|
3
|
+
this.fn = i, this.options = s, this.lastExecutionTime = 0, this.isPending = !1, this.maybeExecute = (...t) => {
|
|
4
|
+
const e = Date.now() - this.lastExecutionTime;
|
|
5
|
+
if (this.options.leading && e >= this.options.wait) this.execute(...t);
|
|
6
|
+
else if (this.lastArgs = t, !this.timeoutId && this.options.trailing) {
|
|
7
|
+
const o = this.options.wait - e;
|
|
8
|
+
this.isPending = !0, this.timeoutId = setTimeout(() => {
|
|
9
|
+
this.lastArgs !== void 0 && this.execute(...this.lastArgs);
|
|
10
|
+
}, o);
|
|
11
|
+
}
|
|
12
|
+
}, this.execute = (...t) => {
|
|
13
|
+
this.fn(...t), this.options.onExecute?.(t, this), this.lastExecutionTime = Date.now(), this.clearTimeout(), this.lastArgs = void 0, this.isPending = !1;
|
|
14
|
+
}, this.flush = () => {
|
|
15
|
+
this.isPending && this.lastArgs && this.execute(...this.lastArgs);
|
|
16
|
+
}, this.cancel = () => {
|
|
17
|
+
this.clearTimeout(), this.lastArgs = void 0, this.isPending = !1;
|
|
18
|
+
}, this.clearTimeout = () => {
|
|
19
|
+
this.timeoutId && (clearTimeout(this.timeoutId), this.timeoutId = void 0);
|
|
20
|
+
}, this.options.leading === void 0 && this.options.trailing === void 0 && (this.options.leading = !0, this.options.trailing = !0);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
function n(i, s) {
|
|
24
|
+
return new h(i, s).maybeExecute;
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
h as LiteThrottler,
|
|
28
|
+
n as liteThrottle
|
|
29
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Store as p } from "./store.js";
|
|
2
|
+
import { __storeToDerived as n, __derivedToStore as a } from "./scheduler.js";
|
|
3
|
+
class r {
|
|
4
|
+
constructor(o) {
|
|
5
|
+
this.listeners = /* @__PURE__ */ new Set(), this._subscriptions = [], this.lastSeenDepValues = [], this.getDepVals = () => {
|
|
6
|
+
const e = this.options.deps.length, s = new Array(e), t = new Array(e);
|
|
7
|
+
for (let i = 0; i < e; i++) {
|
|
8
|
+
const l = this.options.deps[i];
|
|
9
|
+
s[i] = l.prevState, t[i] = l.state;
|
|
10
|
+
}
|
|
11
|
+
return this.lastSeenDepValues = t, {
|
|
12
|
+
prevDepVals: s,
|
|
13
|
+
currDepVals: t,
|
|
14
|
+
prevVal: this.prevState ?? void 0
|
|
15
|
+
};
|
|
16
|
+
}, this.recompute = () => {
|
|
17
|
+
var e, s;
|
|
18
|
+
this.prevState = this.state;
|
|
19
|
+
const t = this.getDepVals();
|
|
20
|
+
this.state = this.options.fn(t), (s = (e = this.options).onUpdate) == null || s.call(e);
|
|
21
|
+
}, this.checkIfRecalculationNeededDeeply = () => {
|
|
22
|
+
for (const i of this.options.deps)
|
|
23
|
+
i instanceof r && i.checkIfRecalculationNeededDeeply();
|
|
24
|
+
let e = !1;
|
|
25
|
+
const s = this.lastSeenDepValues, { currDepVals: t } = this.getDepVals();
|
|
26
|
+
for (let i = 0; i < t.length; i++)
|
|
27
|
+
if (t[i] !== s[i]) {
|
|
28
|
+
e = !0;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
e && this.recompute();
|
|
32
|
+
}, this.mount = () => (this.registerOnGraph(), this.checkIfRecalculationNeededDeeply(), () => {
|
|
33
|
+
this.unregisterFromGraph();
|
|
34
|
+
for (const e of this._subscriptions)
|
|
35
|
+
e();
|
|
36
|
+
}), this.subscribe = (e) => {
|
|
37
|
+
var s, t;
|
|
38
|
+
this.listeners.add(e);
|
|
39
|
+
const i = (t = (s = this.options).onSubscribe) == null ? void 0 : t.call(s, e, this);
|
|
40
|
+
return () => {
|
|
41
|
+
this.listeners.delete(e), i?.();
|
|
42
|
+
};
|
|
43
|
+
}, this.options = o, this.state = o.fn({
|
|
44
|
+
prevDepVals: void 0,
|
|
45
|
+
prevVal: void 0,
|
|
46
|
+
currDepVals: this.getDepVals().currDepVals
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
registerOnGraph(o = this.options.deps) {
|
|
50
|
+
for (const e of o)
|
|
51
|
+
if (e instanceof r)
|
|
52
|
+
e.registerOnGraph(), this.registerOnGraph(e.options.deps);
|
|
53
|
+
else if (e instanceof p) {
|
|
54
|
+
let s = n.get(e);
|
|
55
|
+
s || (s = /* @__PURE__ */ new Set(), n.set(e, s)), s.add(this);
|
|
56
|
+
let t = a.get(this);
|
|
57
|
+
t || (t = /* @__PURE__ */ new Set(), a.set(this, t)), t.add(e);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
unregisterFromGraph(o = this.options.deps) {
|
|
61
|
+
for (const e of o)
|
|
62
|
+
if (e instanceof r)
|
|
63
|
+
this.unregisterFromGraph(e.options.deps);
|
|
64
|
+
else if (e instanceof p) {
|
|
65
|
+
const s = n.get(e);
|
|
66
|
+
s && s.delete(this);
|
|
67
|
+
const t = a.get(this);
|
|
68
|
+
t && t.delete(e);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
r as Derived
|
|
74
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Derived as p } from "./derived.js";
|
|
2
|
+
const l = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new WeakMap(), c = {
|
|
3
|
+
current: []
|
|
4
|
+
};
|
|
5
|
+
let a = !1, o = 0;
|
|
6
|
+
const s = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map();
|
|
7
|
+
function d(t) {
|
|
8
|
+
const r = Array.from(t).sort((e, n) => e instanceof p && e.options.deps.includes(n) ? 1 : n instanceof p && n.options.deps.includes(e) ? -1 : 0);
|
|
9
|
+
for (const e of r) {
|
|
10
|
+
if (c.current.includes(e))
|
|
11
|
+
continue;
|
|
12
|
+
c.current.push(e), e.recompute();
|
|
13
|
+
const n = _.get(e);
|
|
14
|
+
if (n)
|
|
15
|
+
for (const f of n) {
|
|
16
|
+
const u = l.get(f);
|
|
17
|
+
u && d(u);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function v(t) {
|
|
22
|
+
const r = {
|
|
23
|
+
prevVal: t.prevState,
|
|
24
|
+
currentVal: t.state
|
|
25
|
+
};
|
|
26
|
+
for (const e of t.listeners)
|
|
27
|
+
e(r);
|
|
28
|
+
}
|
|
29
|
+
function h(t) {
|
|
30
|
+
const r = {
|
|
31
|
+
prevVal: t.prevState,
|
|
32
|
+
currentVal: t.state
|
|
33
|
+
};
|
|
34
|
+
for (const e of t.listeners)
|
|
35
|
+
e(r);
|
|
36
|
+
}
|
|
37
|
+
function g(t) {
|
|
38
|
+
if (o > 0 && !i.has(t) && i.set(t, t.prevState), s.add(t), !(o > 0) && !a)
|
|
39
|
+
try {
|
|
40
|
+
for (a = !0; s.size > 0; ) {
|
|
41
|
+
const r = Array.from(s);
|
|
42
|
+
s.clear();
|
|
43
|
+
for (const e of r) {
|
|
44
|
+
const n = i.get(e) ?? e.prevState;
|
|
45
|
+
e.prevState = n, v(e);
|
|
46
|
+
}
|
|
47
|
+
for (const e of r) {
|
|
48
|
+
const n = l.get(e);
|
|
49
|
+
n && (c.current.push(e), d(n));
|
|
50
|
+
}
|
|
51
|
+
for (const e of r) {
|
|
52
|
+
const n = l.get(e);
|
|
53
|
+
if (n)
|
|
54
|
+
for (const f of n)
|
|
55
|
+
h(f);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} finally {
|
|
59
|
+
a = !1, c.current = [], i.clear();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function S(t) {
|
|
63
|
+
o++;
|
|
64
|
+
try {
|
|
65
|
+
t();
|
|
66
|
+
} finally {
|
|
67
|
+
if (o--, o === 0) {
|
|
68
|
+
const r = s.values().next().value;
|
|
69
|
+
r && g(r);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
c as __depsThatHaveWrittenThisTick,
|
|
75
|
+
_ as __derivedToStore,
|
|
76
|
+
g as __flush,
|
|
77
|
+
l as __storeToDerived,
|
|
78
|
+
S as batch
|
|
79
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { __flush as h } from "./scheduler.js";
|
|
2
|
+
import { isUpdaterFunction as l } from "./types.js";
|
|
3
|
+
class u {
|
|
4
|
+
constructor(t, e) {
|
|
5
|
+
this.listeners = /* @__PURE__ */ new Set(), this.subscribe = (s) => {
|
|
6
|
+
var i, o;
|
|
7
|
+
this.listeners.add(s);
|
|
8
|
+
const n = (o = (i = this.options) == null ? void 0 : i.onSubscribe) == null ? void 0 : o.call(i, s, this);
|
|
9
|
+
return () => {
|
|
10
|
+
this.listeners.delete(s), n?.();
|
|
11
|
+
};
|
|
12
|
+
}, this.prevState = t, this.state = t, this.options = e;
|
|
13
|
+
}
|
|
14
|
+
setState(t) {
|
|
15
|
+
var e, s, i;
|
|
16
|
+
this.prevState = this.state, (e = this.options) != null && e.updateFn ? this.state = this.options.updateFn(this.prevState)(t) : l(t) ? this.state = t(this.prevState) : this.state = t, (i = (s = this.options) == null ? void 0 : s.onUpdate) == null || i.call(s), h(this);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
u as Store
|
|
21
|
+
};
|