@dazhicheng/ui 1.5.215 → 1.5.217
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/dist/components/tt-form/src/config.js +44 -42
- package/dist/components/tt-form/src/form-render/FormField.vue2.js +67 -70
- package/dist/components/tt-form/src/form-render/FormFieldContact.d.ts +9 -0
- package/dist/components/tt-form/src/form-render/FormFieldContact.js +28 -25
- package/dist/components/tt-form/src/form-render/array-register/FormArrayRegister.d.ts +3 -0
- package/dist/components/tt-form/src/form-render/array-register/FormArrayRegister.js +20 -18
- package/dist/components/tt-form/src/form-render/array-register/props.d.ts +4 -0
- package/dist/components/tt-form/src/form-render/array-register/props.js +1 -0
- package/dist/components/tt-form/src/form-render/array-register/types.d.ts +4 -0
- package/dist/components/tt-form/src/form-render/dependencies.d.ts +5 -0
- package/dist/components/tt-form/src/form-render/dependencies.js +77 -39
- package/dist/components/tt-form/src/group-form/GroupForm.vue.d.ts +15 -7
- package/dist/components/tt-form/src/group-form/GroupForm.vue2.js +120 -104
- package/dist/components/tt-form/src/group-form/GroupSection.vue.d.ts +1 -0
- package/dist/components/tt-form/src/group-form/GroupSection.vue2.js +68 -64
- package/dist/components/tt-form/src/group-form/LazyFormField.vue.d.ts +1 -0
- package/dist/components/tt-form/src/group-form/LazyFormField.vue.js +131 -101
- package/dist/components/tt-form/src/group-form/groupFormApi.d.ts +110 -46
- package/dist/components/tt-form/src/group-form/groupFormApi.js +465 -314
- package/dist/components/tt-form/src/group-form/lazyContext.d.ts +15 -13
- package/dist/components/tt-form/src/group-form/lazyContext.js +42 -26
- package/dist/components/tt-form/src/group-form/types.d.ts +13 -3
- package/dist/components/tt-form/src/group-form/useGroupForm.js +47 -50
- package/dist/components/tt-form/src/hooks/useFieldArray.js +101 -93
- package/dist/components/tt-form/src/hooks/useSelectCollapse.js +47 -47
- package/dist/components/tt-form/src/types.d.ts +3 -5
- package/dist/components/tt-modal-form/index.vue.js +12 -11
- package/dist/components/tt-table/src/TableForm.vue.js +3 -2
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
import { InjectionKey
|
|
2
|
-
/**
|
|
3
|
-
* 共享的字段错误缓存 Map,key 为 fieldName,value 为错误信息。
|
|
4
|
-
* 由 VirtualGroupForm provide,LazyFormField inject。
|
|
5
|
-
* validate 时对未挂载字段的校验错误写入此 map,
|
|
6
|
-
* LazyFormField 挂载时从中读取并通过 setFieldError 恢复。
|
|
7
|
-
*/
|
|
8
|
-
export declare const VIRTUAL_ERROR_CACHE_KEY: InjectionKey<Map<string, string>>;
|
|
9
|
-
/**
|
|
10
|
-
* 重置信号(递增计数器),resetForm / resetValidate 清空虚拟字段错误缓存时 +1。
|
|
11
|
-
* useGroupForm 中 watch 此值以同步导航错误计数;LazyFormField 不依赖 inject 该 key。
|
|
12
|
-
*/
|
|
13
|
-
export declare const VIRTUAL_RESET_SIGNAL_KEY: InjectionKey<Ref<number>>;
|
|
1
|
+
import { InjectionKey } from 'vue';
|
|
14
2
|
/**
|
|
15
3
|
* @description 分批渲染调度器,所有 LazyFormField 共享同一个实例。
|
|
16
4
|
* 滚动停稳后,视口内的字段排队请求渲染,调度器每帧只处理有限数量,
|
|
@@ -27,6 +15,20 @@ export interface RenderScheduler {
|
|
|
27
15
|
pause: () => void;
|
|
28
16
|
/** @description 恢复调度并处理队列中积压的请求 */
|
|
29
17
|
resume: () => void;
|
|
18
|
+
/**
|
|
19
|
+
* @description 标记一个字段已提交挂载(真实 DOM 尚未就绪)。与 {@link settleMount} 成对调用,
|
|
20
|
+
* 用于精确统计"仍在挂载中的字段数",供 {@link whenAllSettled} 判断是否全部就绪。
|
|
21
|
+
*/
|
|
22
|
+
trackMount: () => void;
|
|
23
|
+
/** @description 标记一个字段的真实 DOM 已挂载完成(在 FormField 的 vue:mounted 时调用),与 {@link trackMount} 成对。 */
|
|
24
|
+
settleMount: () => void;
|
|
25
|
+
/**
|
|
26
|
+
* @description 返回一个 Promise,在「队列排空 且 所有已提交挂载的字段真实 DOM 均已就绪」时 resolve。
|
|
27
|
+
* 渐进式挂载场景下,在需要操作全量 DOM 的场景(截图、导出、爬虫等)前 await 此 Promise,
|
|
28
|
+
* 可精确确保全部字段已挂载进 DOM,而非依赖固定帧数猜测。若调用时已就绪则立即 resolve。
|
|
29
|
+
* @returns {Promise<void>}
|
|
30
|
+
*/
|
|
31
|
+
whenAllSettled: () => Promise<void>;
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
34
|
* @description 创建分批渲染调度器
|
|
@@ -1,38 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
function R(f = 4) {
|
|
2
|
+
const n = [];
|
|
3
|
+
let l = !1, u = !1, r = 0, c = [];
|
|
4
|
+
function i() {
|
|
5
|
+
return n.length === 0 && !l && r === 0;
|
|
6
|
+
}
|
|
5
7
|
function o() {
|
|
6
|
-
if (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const t = e.shift();
|
|
10
|
-
t.cancelled || (t.cb(), l++);
|
|
8
|
+
if (i() && c.length > 0) {
|
|
9
|
+
const e = c;
|
|
10
|
+
c = [], e.forEach((t) => t());
|
|
11
11
|
}
|
|
12
|
-
e.length > 0 && r();
|
|
13
12
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
13
|
+
function a() {
|
|
14
|
+
if (l = !1, u) return;
|
|
15
|
+
let e = 0;
|
|
16
|
+
for (; n.length > 0 && e < f; ) {
|
|
17
|
+
const t = n.shift();
|
|
18
|
+
t.cancelled || (t.cb(), e++);
|
|
19
|
+
}
|
|
20
|
+
n.length > 0 ? s() : o();
|
|
21
|
+
}
|
|
22
|
+
function s() {
|
|
23
|
+
l || u || (l = !0, requestAnimationFrame(a));
|
|
16
24
|
}
|
|
17
|
-
function
|
|
18
|
-
const t = { cb:
|
|
19
|
-
return
|
|
25
|
+
function d(e) {
|
|
26
|
+
const t = { cb: e, cancelled: !1 };
|
|
27
|
+
return n.push(t), s(), () => {
|
|
20
28
|
t.cancelled = !0;
|
|
21
29
|
};
|
|
22
30
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
31
|
+
function h() {
|
|
32
|
+
u = !0;
|
|
25
33
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
34
|
+
function S() {
|
|
35
|
+
u = !1, n.length > 0 && s();
|
|
36
|
+
}
|
|
37
|
+
function m() {
|
|
38
|
+
r++;
|
|
39
|
+
}
|
|
40
|
+
function E() {
|
|
41
|
+
r > 0 && r--, o();
|
|
42
|
+
}
|
|
43
|
+
function p() {
|
|
44
|
+
return i() ? Promise.resolve() : new Promise((e) => c.push(e));
|
|
28
45
|
}
|
|
29
|
-
return { request:
|
|
46
|
+
return { request: d, pause: h, resume: S, trackMount: m, settleMount: E, whenAllSettled: p };
|
|
30
47
|
}
|
|
31
|
-
const
|
|
48
|
+
const _ = Symbol("VirtualRenderScheduler"), b = Symbol("GroupVisibilityCallback"), g = Symbol("HiddenGroupKeys");
|
|
32
49
|
export {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
d as createRenderScheduler
|
|
50
|
+
b as GROUP_VISIBILITY_CALLBACK_KEY,
|
|
51
|
+
g as HIDDEN_GROUP_KEYS_KEY,
|
|
52
|
+
_ as RENDER_SCHEDULER_KEY,
|
|
53
|
+
R as createRenderScheduler
|
|
38
54
|
};
|
|
@@ -66,6 +66,12 @@ export type GroupFormNavAnchorProps = UseGroupFormNavAnchorProps;
|
|
|
66
66
|
export type UseGroupFormOptionsCommon = Omit<TtFormProps, "schema" | "showDefaultActions"> & {
|
|
67
67
|
/** 是否启用虚拟化,默认 true */
|
|
68
68
|
virtual?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* 渐进式挂载:不启用虚拟化(视口外字段也渲染 DOM),但所有字段分批(按帧)后台挂载,提升首次打开速度。
|
|
71
|
+
* 默认 false。
|
|
72
|
+
* 与 `virtual` 互斥:显式开启 progressive 时自动关闭 virtual。操作 DOM 前可 `await formApi.whenAllRendered()` 确保挂载完成。
|
|
73
|
+
*/
|
|
74
|
+
progressive?: boolean;
|
|
69
75
|
/** 滚动容器高度,默认 '100%' */
|
|
70
76
|
containerHeight?: number | string;
|
|
71
77
|
/** IntersectionObserver rootMargin,控制提前渲染的距离,默认 '200px 0px'(仅 virtual 为 true 时生效) */
|
|
@@ -98,7 +104,7 @@ export interface UseGroupFormOptionsWithLegacySchema extends UseGroupFormOptions
|
|
|
98
104
|
}
|
|
99
105
|
/** groupSchema 与 schema 二选一(至少传一个) */
|
|
100
106
|
export type UseGroupFormOptions = UseGroupFormOptionsWithGroupSchema | UseGroupFormOptionsWithLegacySchema;
|
|
101
|
-
export type GroupFormExtraState = Partial<Pick<UseGroupFormOptions, "virtual" | "navAnchorProps" | "containerHeight" | "rootMargin" | "estimateFieldHeight" | "scrollOffset">> & {
|
|
107
|
+
export type GroupFormExtraState = Partial<Pick<UseGroupFormOptions, "virtual" | "progressive" | "navAnchorProps" | "containerHeight" | "rootMargin" | "estimateFieldHeight" | "scrollOffset">> & {
|
|
102
108
|
/** 分组 schema 树形结构(store 状态,由 GroupFormApi.setState 维护) */
|
|
103
109
|
groupSchema?: GroupFormSchema[];
|
|
104
110
|
};
|
|
@@ -118,6 +124,8 @@ export interface LazyFormFieldProps {
|
|
|
118
124
|
root?: Element | null;
|
|
119
125
|
/** IntersectionObserver rootMargin,控制提前渲染的距离 */
|
|
120
126
|
rootMargin?: string;
|
|
127
|
+
/** 渐进式挂载:onMounted 即分批入队挂载,不依赖视口、挂载后常驻,供操作全量 DOM 场景使用 */
|
|
128
|
+
progressive?: boolean;
|
|
121
129
|
/** 预估占位高度(px),首次渲染前使用 */
|
|
122
130
|
estimateHeight?: number;
|
|
123
131
|
/** 未进入视口时是否显示骨架屏(弹框首屏等场景减少白屏感),默认 true */
|
|
@@ -128,7 +136,7 @@ export interface LazyFormFieldProps {
|
|
|
128
136
|
/**
|
|
129
137
|
* 分组表单根组件 props:`formApi` 为必传数据入口;
|
|
130
138
|
*/
|
|
131
|
-
export type GroupFormSectionProps = Partial<Pick<UseGroupFormOptions, "virtual" | "scrollToFirstError" | "containerHeight" | "rootMargin" | "estimateFieldHeight" | "wrapperClass" | "layout" | "compact" | "commonConfig" | "actionWrapperClass" | "showCollapseButton" | "collapsed" | "collapsedRows" | "collapseTriggerResize" | "submitOnChange" | "submitOnEnter" | "fieldMappingTime" | "arrayToStringFields">> & {
|
|
139
|
+
export type GroupFormSectionProps = Partial<Pick<UseGroupFormOptions, "virtual" | "progressive" | "scrollToFirstError" | "containerHeight" | "rootMargin" | "estimateFieldHeight" | "wrapperClass" | "layout" | "compact" | "commonConfig" | "actionWrapperClass" | "showCollapseButton" | "collapsed" | "collapsedRows" | "collapseTriggerResize" | "submitOnChange" | "submitOnEnter" | "fieldMappingTime" | "arrayToStringFields">> & {
|
|
132
140
|
/** 表单 API(必传,所有内部数据的入口) */
|
|
133
141
|
formApi: GroupFormApi;
|
|
134
142
|
/** 模板侧覆盖:导航锚点配置(与 store.navAnchorProps 合并,模板优先) */
|
|
@@ -152,6 +160,8 @@ export interface GroupSectionProps {
|
|
|
152
160
|
depth?: number;
|
|
153
161
|
/** 是否启用表单项级别的虚拟化(IntersectionObserver 懒渲染) */
|
|
154
162
|
virtual?: boolean;
|
|
163
|
+
/** 渐进式挂载:分批后台挂载全部字段,挂载后常驻DOM常驻(供操作全量 DOM 场景使用) */
|
|
164
|
+
progressive?: boolean;
|
|
155
165
|
/** 虚拟化时滚动容器引用 */
|
|
156
166
|
scrollElement?: Element | null;
|
|
157
167
|
/** IntersectionObserver rootMargin,控制提前渲染的距离 */
|
|
@@ -163,7 +173,7 @@ export interface GroupSectionProps {
|
|
|
163
173
|
* @description GroupFormApi 构造函数的分组配置选项,复用 UseGroupFormOptions 中同名字段的类型定义,
|
|
164
174
|
* 额外增加 `groupSchema`(由 useGroupForm 传入)。
|
|
165
175
|
*/
|
|
166
|
-
export type GroupFormApiOptions = Pick<UseGroupFormOptions, "virtual" | "navAnchorProps" | "scrollToFirstError" | "containerHeight" | "rootMargin" | "estimateFieldHeight" | "scrollOffset"> & {
|
|
176
|
+
export type GroupFormApiOptions = Pick<UseGroupFormOptions, "virtual" | "progressive" | "navAnchorProps" | "scrollToFirstError" | "containerHeight" | "rootMargin" | "estimateFieldHeight" | "scrollOffset"> & {
|
|
167
177
|
/** 分组 schema 树形结构(由 useGroupForm 传入) */
|
|
168
178
|
groupSchema: GroupFormSchema[];
|
|
169
179
|
};
|
|
@@ -1,77 +1,74 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useStore as
|
|
3
|
-
import { GroupFormApi as
|
|
4
|
-
import
|
|
1
|
+
import { defineComponent as x, onMounted as y, watch as c, onBeforeUnmount as C, h as P, isReactive as w } from "vue";
|
|
2
|
+
import { useStore as N } from "@tanstack/vue-store";
|
|
3
|
+
import { GroupFormApi as M } from "./groupFormApi.js";
|
|
4
|
+
import D from "./GroupForm.vue2.js";
|
|
5
5
|
/* empty css */
|
|
6
|
-
import { resolveGroupSchema as u, extractFlatSchemas as
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
groupSchema:
|
|
10
|
-
schema:
|
|
6
|
+
import { resolveGroupSchema as u, extractFlatSchemas as H } from "./utils.js";
|
|
7
|
+
function z(e) {
|
|
8
|
+
const n = u(e), {
|
|
9
|
+
groupSchema: O,
|
|
10
|
+
schema: R,
|
|
11
11
|
virtual: i = !0,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
progressive: f = !1,
|
|
13
|
+
containerHeight: h = "100%",
|
|
14
|
+
rootMargin: l = "400px 0px",
|
|
15
|
+
estimateFieldHeight: F = 52,
|
|
16
|
+
navAnchorProps: v,
|
|
17
|
+
scrollToFirstError: S,
|
|
18
|
+
scrollOffset: d = 0,
|
|
19
|
+
...g
|
|
20
|
+
} = e, A = {
|
|
20
21
|
title: "导航",
|
|
21
22
|
show: !0,
|
|
22
|
-
...
|
|
23
|
-
},
|
|
24
|
-
...
|
|
25
|
-
schema:
|
|
23
|
+
...v
|
|
24
|
+
}, G = H(n), T = {
|
|
25
|
+
...g,
|
|
26
|
+
schema: G,
|
|
26
27
|
showDefaultActions: !1,
|
|
27
28
|
scrollToFirstError: !1
|
|
28
|
-
}, r = new
|
|
29
|
-
groupSchema:
|
|
30
|
-
navAnchorProps:
|
|
29
|
+
}, r = new M(T, {
|
|
30
|
+
groupSchema: n,
|
|
31
|
+
navAnchorProps: A,
|
|
31
32
|
virtual: i,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
progressive: f,
|
|
34
|
+
scrollToFirstError: S ?? !0,
|
|
35
|
+
containerHeight: h,
|
|
36
|
+
rootMargin: l,
|
|
37
|
+
estimateFieldHeight: F,
|
|
38
|
+
scrollOffset: d
|
|
37
39
|
}), s = r;
|
|
38
|
-
s.useStore = (o) =>
|
|
39
|
-
const E =
|
|
40
|
+
s.useStore = (o) => N(r.store, o);
|
|
41
|
+
const E = x({
|
|
40
42
|
name: "TtGroupForm",
|
|
41
43
|
inheritAttrs: !1,
|
|
42
|
-
setup(o, { attrs: p, slots:
|
|
44
|
+
setup(o, { attrs: p, slots: _ }) {
|
|
43
45
|
r.setState({ ...p });
|
|
44
|
-
const
|
|
45
|
-
return
|
|
46
|
-
r.resetCollapseStatesToDefault(), r.navAnchorProps.show && (r.syncNavErrorCountsFromForm(),
|
|
47
|
-
|
|
46
|
+
const m = [];
|
|
47
|
+
return y(() => {
|
|
48
|
+
r.resetCollapseStatesToDefault(), r.navAnchorProps.show && (r.syncNavErrorCountsFromForm(), m.push(
|
|
49
|
+
c(
|
|
48
50
|
() => {
|
|
49
|
-
var t,
|
|
50
|
-
return (
|
|
51
|
+
var t, a;
|
|
52
|
+
return (a = (t = r.form) == null ? void 0 : t.errors) == null ? void 0 : a.value;
|
|
51
53
|
},
|
|
52
54
|
() => r.syncNavErrorCountsFromForm(),
|
|
53
55
|
{ deep: !0, flush: "post" }
|
|
54
56
|
)
|
|
55
|
-
), r.virtual && n.push(
|
|
56
|
-
a(
|
|
57
|
-
() => r.resetSignal.value,
|
|
58
|
-
() => r.syncNavErrorCountsFromForm()
|
|
59
|
-
)
|
|
60
57
|
));
|
|
61
|
-
}),
|
|
62
|
-
|
|
63
|
-
}), () =>
|
|
64
|
-
|
|
58
|
+
}), C(() => {
|
|
59
|
+
m.splice(0).forEach((t) => t()), r.unmount();
|
|
60
|
+
}), () => P(
|
|
61
|
+
D,
|
|
65
62
|
{
|
|
66
63
|
...p,
|
|
67
64
|
ref: r.groupFormRef,
|
|
68
65
|
formApi: s
|
|
69
66
|
},
|
|
70
|
-
|
|
67
|
+
_
|
|
71
68
|
);
|
|
72
69
|
}
|
|
73
70
|
});
|
|
74
|
-
return
|
|
71
|
+
return w(e) && c(
|
|
75
72
|
() => u(e),
|
|
76
73
|
(o) => {
|
|
77
74
|
o.length && r._applyGroupSchema(o);
|
|
@@ -79,5 +76,5 @@ function q(e) {
|
|
|
79
76
|
), [E, s];
|
|
80
77
|
}
|
|
81
78
|
export {
|
|
82
|
-
|
|
79
|
+
z as useGroupForm
|
|
83
80
|
};
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import { inject as
|
|
2
|
-
import { get as
|
|
3
|
-
import { FormContextKey as
|
|
4
|
-
function
|
|
5
|
-
return typeof File < "u" &&
|
|
1
|
+
import { inject as Y, computed as E, toValue as V, ref as q, watch as D, onBeforeUnmount as K } from "vue";
|
|
2
|
+
import { get as T, set as z, cloneDeep as m } from "lodash-es";
|
|
3
|
+
import { FormContextKey as U } from "vee-validate";
|
|
4
|
+
function $(i) {
|
|
5
|
+
return typeof File < "u" && i instanceof File;
|
|
6
6
|
}
|
|
7
|
-
function d(
|
|
8
|
-
if (
|
|
9
|
-
if (
|
|
10
|
-
if (
|
|
11
|
-
if (Array.isArray(
|
|
12
|
-
if (
|
|
13
|
-
for (let
|
|
7
|
+
function d(i, e) {
|
|
8
|
+
if (i === e) return !0;
|
|
9
|
+
if (i && e && typeof i == "object" && typeof e == "object") {
|
|
10
|
+
if (i.constructor !== e.constructor) return !1;
|
|
11
|
+
if (Array.isArray(i)) {
|
|
12
|
+
if (i.length !== e.length) return !1;
|
|
13
|
+
for (let s = i.length; s-- !== 0; ) if (!d(i[s], e[s])) return !1;
|
|
14
14
|
return !0;
|
|
15
15
|
}
|
|
16
|
-
if (
|
|
17
|
-
if (
|
|
18
|
-
for (const
|
|
19
|
-
for (const [
|
|
16
|
+
if (i instanceof Map && e instanceof Map) {
|
|
17
|
+
if (i.size !== e.size) return !1;
|
|
18
|
+
for (const s of i.keys()) if (!e.has(s)) return !1;
|
|
19
|
+
for (const [s, a] of i) if (!d(a, e.get(s))) return !1;
|
|
20
20
|
return !0;
|
|
21
21
|
}
|
|
22
|
-
if (
|
|
23
|
-
if (
|
|
24
|
-
for (const
|
|
22
|
+
if (i instanceof Set && e instanceof Set) {
|
|
23
|
+
if (i.size !== e.size) return !1;
|
|
24
|
+
for (const s of i) if (!e.has(s)) return !1;
|
|
25
25
|
return !0;
|
|
26
26
|
}
|
|
27
|
-
if (ArrayBuffer.isView(
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
for (let v =
|
|
27
|
+
if (ArrayBuffer.isView(i) && ArrayBuffer.isView(e)) {
|
|
28
|
+
const s = i, a = e;
|
|
29
|
+
if (s.length !== a.length) return !1;
|
|
30
|
+
for (let v = s.length; v-- !== 0; ) if (s[v] !== a[v]) return !1;
|
|
31
31
|
return !0;
|
|
32
32
|
}
|
|
33
|
-
if (
|
|
34
|
-
return
|
|
35
|
-
if (
|
|
36
|
-
return
|
|
37
|
-
if (
|
|
38
|
-
if (
|
|
39
|
-
const c = Object.keys(
|
|
40
|
-
if (c.length !==
|
|
41
|
-
for (const
|
|
42
|
-
if (!Object.prototype.hasOwnProperty.call(e,
|
|
33
|
+
if (i instanceof RegExp && e instanceof RegExp)
|
|
34
|
+
return i.source === e.source && i.flags === e.flags;
|
|
35
|
+
if ($(i) && $(e))
|
|
36
|
+
return i.size === e.size && i.name === e.name && i.lastModified === e.lastModified && i.type === e.type;
|
|
37
|
+
if (i.valueOf !== Object.prototype.valueOf) return i.valueOf() === e.valueOf();
|
|
38
|
+
if (i.toString !== Object.prototype.toString) return i.toString() === e.toString();
|
|
39
|
+
const c = Object.keys(i).filter((s) => i[s] !== void 0), u = Object.keys(e).filter((s) => e[s] !== void 0);
|
|
40
|
+
if (c.length !== u.length) return !1;
|
|
41
|
+
for (const s of c)
|
|
42
|
+
if (!Object.prototype.hasOwnProperty.call(e, s) || !d(i[s], e[s])) return !1;
|
|
43
43
|
return !0;
|
|
44
44
|
}
|
|
45
|
-
return
|
|
45
|
+
return i !== i && e !== e;
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
const e =
|
|
49
|
-
let
|
|
47
|
+
function H(i) {
|
|
48
|
+
const e = Y(U), c = E(() => V(i)), u = q([]);
|
|
49
|
+
let s = 0, a;
|
|
50
50
|
const v = Object.freeze([]);
|
|
51
|
-
function
|
|
51
|
+
function o() {
|
|
52
52
|
if (!e)
|
|
53
53
|
return v;
|
|
54
|
-
const t =
|
|
54
|
+
const t = T(e.values, c.value);
|
|
55
55
|
return Array.isArray(t) ? t : v;
|
|
56
56
|
}
|
|
57
57
|
function p(t) {
|
|
58
|
-
e && (
|
|
58
|
+
e && (z(e.values, c.value, t), a = o());
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
return
|
|
60
|
+
function M(t, n) {
|
|
61
|
+
return E({
|
|
62
62
|
get() {
|
|
63
|
-
const r =
|
|
63
|
+
const r = o(), f = u.value.findIndex((l) => l.key === t);
|
|
64
64
|
return f === -1 ? n : r[f];
|
|
65
65
|
},
|
|
66
66
|
set(r) {
|
|
67
|
-
const f =
|
|
68
|
-
f !== -1 &&
|
|
67
|
+
const f = u.value.findIndex((l) => l.key === t);
|
|
68
|
+
f !== -1 && j(f, r);
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
function O() {
|
|
73
|
-
const t =
|
|
73
|
+
const t = u.value.length;
|
|
74
74
|
for (let n = 0; n < t; n++) {
|
|
75
|
-
const r =
|
|
75
|
+
const r = u.value[n];
|
|
76
76
|
r.isFirst = n === 0, r.isLast = n === t - 1;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -82,100 +82,108 @@ function G(s) {
|
|
|
82
82
|
function g(t, n, r) {
|
|
83
83
|
if (r && n != null && r[n])
|
|
84
84
|
return r[n];
|
|
85
|
-
const f =
|
|
85
|
+
const f = s++;
|
|
86
86
|
return {
|
|
87
87
|
key: f,
|
|
88
|
-
value:
|
|
88
|
+
value: M(f, t),
|
|
89
89
|
isFirst: !1,
|
|
90
90
|
isLast: !1
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
+
let k = !1;
|
|
93
94
|
function h() {
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
if (!k) {
|
|
96
|
+
k = !0;
|
|
97
|
+
try {
|
|
98
|
+
const t = o(), n = u.value;
|
|
99
|
+
u.value = t.map((r, f) => g(r, f, n)), a = o(), O();
|
|
100
|
+
} finally {
|
|
101
|
+
k = !1;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
96
104
|
}
|
|
97
|
-
h(),
|
|
98
|
-
const n = t.length !==
|
|
105
|
+
h(), D([() => o(), () => o().length], ([t]) => {
|
|
106
|
+
const n = t.length !== u.value.length || t !== a;
|
|
99
107
|
a = t, n && h();
|
|
100
108
|
});
|
|
101
|
-
function
|
|
109
|
+
function S(t) {
|
|
102
110
|
if (!e)
|
|
103
111
|
return;
|
|
104
|
-
const n = [...
|
|
112
|
+
const n = [...o()];
|
|
105
113
|
if (t < 0 || t >= n.length)
|
|
106
114
|
return;
|
|
107
115
|
const r = `${c.value}[${t}]`;
|
|
108
|
-
e.destroyPath(r), e.unsetInitialValue(r), n.splice(t, 1), p(n),
|
|
116
|
+
e.destroyPath(r), e.unsetInitialValue(r), n.splice(t, 1), p(n), u.value.splice(t, 1), y();
|
|
109
117
|
}
|
|
110
|
-
function
|
|
118
|
+
function w(t) {
|
|
111
119
|
if (!e)
|
|
112
120
|
return;
|
|
113
|
-
const n = m(t), r = [...
|
|
114
|
-
e.stageInitialValue(`${c.value}[${r.length - 1}]`, n), p(r),
|
|
121
|
+
const n = m(t), r = [...o(), n];
|
|
122
|
+
e.stageInitialValue(`${c.value}[${r.length - 1}]`, n), p(r), u.value.push(g(n)), y();
|
|
115
123
|
}
|
|
116
|
-
function
|
|
124
|
+
function C(t) {
|
|
117
125
|
if (!e)
|
|
118
126
|
return;
|
|
119
|
-
const n = m(t), r = [n, ...
|
|
120
|
-
e.stageInitialValue(`${c.value}[0]`, n), p(r),
|
|
127
|
+
const n = m(t), r = [n, ...o()];
|
|
128
|
+
e.stageInitialValue(`${c.value}[0]`, n), p(r), u.value.unshift(g(n)), y();
|
|
121
129
|
}
|
|
122
|
-
function
|
|
130
|
+
function R(t, n) {
|
|
123
131
|
if (!e)
|
|
124
132
|
return;
|
|
125
|
-
const r = m(n), f = [...
|
|
126
|
-
t < 0 || t > f.length || (f.splice(t, 0, r), p(f),
|
|
133
|
+
const r = m(n), f = [...o()];
|
|
134
|
+
t < 0 || t > f.length || (f.splice(t, 0, r), p(f), u.value.splice(t, 0, g(r)), y());
|
|
127
135
|
}
|
|
128
|
-
function
|
|
136
|
+
function I(t) {
|
|
129
137
|
e && (e.stageInitialValue(c.value, t), p(m(t)), h(), y());
|
|
130
138
|
}
|
|
131
|
-
function
|
|
139
|
+
function j(t, n) {
|
|
132
140
|
if (!e)
|
|
133
141
|
return;
|
|
134
|
-
const r =
|
|
135
|
-
t < 0 || t >= r.length ||
|
|
142
|
+
const r = o();
|
|
143
|
+
t < 0 || t >= r.length || d(r[t], n) || (z(e.values, `${c.value}[${t}]`, n), e.validate({ mode: "validated-only" }));
|
|
136
144
|
}
|
|
137
|
-
function
|
|
145
|
+
function L(t, n) {
|
|
138
146
|
if (!e)
|
|
139
147
|
return;
|
|
140
|
-
const r = [...
|
|
148
|
+
const r = [...o()];
|
|
141
149
|
if (!(t in r) || !(n in r))
|
|
142
150
|
return;
|
|
143
151
|
const f = r[t];
|
|
144
152
|
r[t] = r[n], r[n] = f;
|
|
145
|
-
const
|
|
146
|
-
|
|
153
|
+
const l = [...u.value], A = l[t];
|
|
154
|
+
l[t] = l[n], l[n] = A, p(r), u.value = l, O();
|
|
147
155
|
}
|
|
148
|
-
function
|
|
156
|
+
function P(t, n) {
|
|
149
157
|
if (!e)
|
|
150
158
|
return;
|
|
151
|
-
const r = [...
|
|
159
|
+
const r = [...o()];
|
|
152
160
|
if (!(t in r) || !(n in r))
|
|
153
161
|
return;
|
|
154
162
|
const f = r.splice(t, 1)[0];
|
|
155
163
|
r.splice(n, 0, f);
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
const
|
|
160
|
-
fields:
|
|
161
|
-
remove:
|
|
162
|
-
push:
|
|
163
|
-
prepend:
|
|
164
|
-
insert:
|
|
165
|
-
replace:
|
|
166
|
-
update:
|
|
167
|
-
swap:
|
|
168
|
-
move:
|
|
164
|
+
const l = [...u.value], A = l.splice(t, 1)[0];
|
|
165
|
+
l.splice(n, 0, A), p(r), u.value = l, y();
|
|
166
|
+
}
|
|
167
|
+
const F = {
|
|
168
|
+
fields: u,
|
|
169
|
+
remove: S,
|
|
170
|
+
push: w,
|
|
171
|
+
prepend: C,
|
|
172
|
+
insert: R,
|
|
173
|
+
replace: I,
|
|
174
|
+
update: j,
|
|
175
|
+
swap: L,
|
|
176
|
+
move: P
|
|
169
177
|
};
|
|
170
178
|
if (e) {
|
|
171
|
-
const t = Object.assign({ path:
|
|
172
|
-
e.fieldArrays.push(t),
|
|
173
|
-
const n = e.fieldArrays.findIndex((r) =>
|
|
179
|
+
const t = Object.assign({ path: i, reset: h }, F);
|
|
180
|
+
e.fieldArrays.push(t), K(() => {
|
|
181
|
+
const n = e.fieldArrays.findIndex((r) => V(r.path) === V(i));
|
|
174
182
|
n >= 0 && e.fieldArrays.splice(n, 1);
|
|
175
183
|
});
|
|
176
184
|
}
|
|
177
|
-
return
|
|
185
|
+
return F;
|
|
178
186
|
}
|
|
179
187
|
export {
|
|
180
|
-
|
|
188
|
+
H as useFieldArray
|
|
181
189
|
};
|