tracked-instance 1.0.9 → 1.0.11
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 +2 -0
- package/dist/index.mjs +1019 -0
- package/package.json +3 -3
- package/dist/index.js +0 -14
- package/dist/types/collection.d.ts +0 -17
- package/dist/types/index.d.ts +0 -4
- package/dist/types/tracked-instance.d.ts +0 -13
package/README.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# Tracked instance
|
|
1
2
|
<a href="https://www.npmjs.com/package/tracked-instance"><img src="https://img.shields.io/npm/v/tracked-instance.svg?sanitize=true" alt="Version"></a>
|
|
2
3
|
|
|
3
4
|
# 🚀 Features
|
|
@@ -10,6 +11,7 @@
|
|
|
10
11
|
Build large forms and send all requests in one take.
|
|
11
12
|
Combination of useTrackedInstance and useCollection can manage very large form with entities which deeply related each other.
|
|
12
13
|
You can control what data should be sent to the server so that only what has changed is sent.
|
|
14
|
+
Tracked instance is not so much about managing forms, but about building and optimizing queries.
|
|
13
15
|
|
|
14
16
|
# Install
|
|
15
17
|
> npm i tracked-instance
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,1019 @@
|
|
|
1
|
+
// node_modules/lodash-es/_freeGlobal.js
|
|
2
|
+
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
|
3
|
+
var freeGlobal_default = freeGlobal;
|
|
4
|
+
|
|
5
|
+
// node_modules/lodash-es/_root.js
|
|
6
|
+
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
7
|
+
var root = freeGlobal_default || freeSelf || Function("return this")();
|
|
8
|
+
var root_default = root;
|
|
9
|
+
|
|
10
|
+
// node_modules/lodash-es/_Symbol.js
|
|
11
|
+
var Symbol = root_default.Symbol;
|
|
12
|
+
var Symbol_default = Symbol;
|
|
13
|
+
|
|
14
|
+
// node_modules/lodash-es/_getRawTag.js
|
|
15
|
+
var objectProto = Object.prototype;
|
|
16
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
17
|
+
var nativeObjectToString = objectProto.toString;
|
|
18
|
+
var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
|
|
19
|
+
function getRawTag(value) {
|
|
20
|
+
var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
|
|
21
|
+
try {
|
|
22
|
+
value[symToStringTag] = void 0;
|
|
23
|
+
var unmasked = true;
|
|
24
|
+
} catch (e) {
|
|
25
|
+
}
|
|
26
|
+
var result = nativeObjectToString.call(value);
|
|
27
|
+
if (unmasked) {
|
|
28
|
+
if (isOwn) {
|
|
29
|
+
value[symToStringTag] = tag;
|
|
30
|
+
} else {
|
|
31
|
+
delete value[symToStringTag];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
var getRawTag_default = getRawTag;
|
|
37
|
+
|
|
38
|
+
// node_modules/lodash-es/_objectToString.js
|
|
39
|
+
var objectProto2 = Object.prototype;
|
|
40
|
+
var nativeObjectToString2 = objectProto2.toString;
|
|
41
|
+
function objectToString(value) {
|
|
42
|
+
return nativeObjectToString2.call(value);
|
|
43
|
+
}
|
|
44
|
+
var objectToString_default = objectToString;
|
|
45
|
+
|
|
46
|
+
// node_modules/lodash-es/_baseGetTag.js
|
|
47
|
+
var nullTag = "[object Null]";
|
|
48
|
+
var undefinedTag = "[object Undefined]";
|
|
49
|
+
var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
|
|
50
|
+
function baseGetTag(value) {
|
|
51
|
+
if (value == null) {
|
|
52
|
+
return value === void 0 ? undefinedTag : nullTag;
|
|
53
|
+
}
|
|
54
|
+
return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
|
|
55
|
+
}
|
|
56
|
+
var baseGetTag_default = baseGetTag;
|
|
57
|
+
|
|
58
|
+
// node_modules/lodash-es/isObjectLike.js
|
|
59
|
+
function isObjectLike(value) {
|
|
60
|
+
return value != null && typeof value == "object";
|
|
61
|
+
}
|
|
62
|
+
var isObjectLike_default = isObjectLike;
|
|
63
|
+
|
|
64
|
+
// node_modules/lodash-es/isSymbol.js
|
|
65
|
+
var symbolTag = "[object Symbol]";
|
|
66
|
+
function isSymbol(value) {
|
|
67
|
+
return typeof value == "symbol" || isObjectLike_default(value) && baseGetTag_default(value) == symbolTag;
|
|
68
|
+
}
|
|
69
|
+
var isSymbol_default = isSymbol;
|
|
70
|
+
|
|
71
|
+
// node_modules/lodash-es/_arrayMap.js
|
|
72
|
+
function arrayMap(array, iteratee) {
|
|
73
|
+
var index = -1, length = array == null ? 0 : array.length, result = Array(length);
|
|
74
|
+
while (++index < length) {
|
|
75
|
+
result[index] = iteratee(array[index], index, array);
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
var arrayMap_default = arrayMap;
|
|
80
|
+
|
|
81
|
+
// node_modules/lodash-es/isArray.js
|
|
82
|
+
var isArray = Array.isArray;
|
|
83
|
+
var isArray_default = isArray;
|
|
84
|
+
|
|
85
|
+
// node_modules/lodash-es/_baseToString.js
|
|
86
|
+
var INFINITY = 1 / 0;
|
|
87
|
+
var symbolProto = Symbol_default ? Symbol_default.prototype : void 0;
|
|
88
|
+
var symbolToString = symbolProto ? symbolProto.toString : void 0;
|
|
89
|
+
function baseToString(value) {
|
|
90
|
+
if (typeof value == "string") {
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
if (isArray_default(value)) {
|
|
94
|
+
return arrayMap_default(value, baseToString) + "";
|
|
95
|
+
}
|
|
96
|
+
if (isSymbol_default(value)) {
|
|
97
|
+
return symbolToString ? symbolToString.call(value) : "";
|
|
98
|
+
}
|
|
99
|
+
var result = value + "";
|
|
100
|
+
return result == "0" && 1 / value == -INFINITY ? "-0" : result;
|
|
101
|
+
}
|
|
102
|
+
var baseToString_default = baseToString;
|
|
103
|
+
|
|
104
|
+
// node_modules/lodash-es/isObject.js
|
|
105
|
+
function isObject(value) {
|
|
106
|
+
var type = typeof value;
|
|
107
|
+
return value != null && (type == "object" || type == "function");
|
|
108
|
+
}
|
|
109
|
+
var isObject_default = isObject;
|
|
110
|
+
|
|
111
|
+
// node_modules/lodash-es/isFunction.js
|
|
112
|
+
var asyncTag = "[object AsyncFunction]";
|
|
113
|
+
var funcTag = "[object Function]";
|
|
114
|
+
var genTag = "[object GeneratorFunction]";
|
|
115
|
+
var proxyTag = "[object Proxy]";
|
|
116
|
+
function isFunction(value) {
|
|
117
|
+
if (!isObject_default(value)) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
var tag = baseGetTag_default(value);
|
|
121
|
+
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
122
|
+
}
|
|
123
|
+
var isFunction_default = isFunction;
|
|
124
|
+
|
|
125
|
+
// node_modules/lodash-es/_coreJsData.js
|
|
126
|
+
var coreJsData = root_default["__core-js_shared__"];
|
|
127
|
+
var coreJsData_default = coreJsData;
|
|
128
|
+
|
|
129
|
+
// node_modules/lodash-es/_isMasked.js
|
|
130
|
+
var maskSrcKey = function() {
|
|
131
|
+
var uid = /[^.]+$/.exec(coreJsData_default && coreJsData_default.keys && coreJsData_default.keys.IE_PROTO || "");
|
|
132
|
+
return uid ? "Symbol(src)_1." + uid : "";
|
|
133
|
+
}();
|
|
134
|
+
function isMasked(func) {
|
|
135
|
+
return !!maskSrcKey && maskSrcKey in func;
|
|
136
|
+
}
|
|
137
|
+
var isMasked_default = isMasked;
|
|
138
|
+
|
|
139
|
+
// node_modules/lodash-es/_toSource.js
|
|
140
|
+
var funcProto = Function.prototype;
|
|
141
|
+
var funcToString = funcProto.toString;
|
|
142
|
+
function toSource(func) {
|
|
143
|
+
if (func != null) {
|
|
144
|
+
try {
|
|
145
|
+
return funcToString.call(func);
|
|
146
|
+
} catch (e) {
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
return func + "";
|
|
150
|
+
} catch (e) {
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return "";
|
|
154
|
+
}
|
|
155
|
+
var toSource_default = toSource;
|
|
156
|
+
|
|
157
|
+
// node_modules/lodash-es/_baseIsNative.js
|
|
158
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
159
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
160
|
+
var funcProto2 = Function.prototype;
|
|
161
|
+
var objectProto3 = Object.prototype;
|
|
162
|
+
var funcToString2 = funcProto2.toString;
|
|
163
|
+
var hasOwnProperty2 = objectProto3.hasOwnProperty;
|
|
164
|
+
var reIsNative = RegExp(
|
|
165
|
+
"^" + funcToString2.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
166
|
+
);
|
|
167
|
+
function baseIsNative(value) {
|
|
168
|
+
if (!isObject_default(value) || isMasked_default(value)) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
var pattern = isFunction_default(value) ? reIsNative : reIsHostCtor;
|
|
172
|
+
return pattern.test(toSource_default(value));
|
|
173
|
+
}
|
|
174
|
+
var baseIsNative_default = baseIsNative;
|
|
175
|
+
|
|
176
|
+
// node_modules/lodash-es/_getValue.js
|
|
177
|
+
function getValue(object, key) {
|
|
178
|
+
return object == null ? void 0 : object[key];
|
|
179
|
+
}
|
|
180
|
+
var getValue_default = getValue;
|
|
181
|
+
|
|
182
|
+
// node_modules/lodash-es/_getNative.js
|
|
183
|
+
function getNative(object, key) {
|
|
184
|
+
var value = getValue_default(object, key);
|
|
185
|
+
return baseIsNative_default(value) ? value : void 0;
|
|
186
|
+
}
|
|
187
|
+
var getNative_default = getNative;
|
|
188
|
+
|
|
189
|
+
// node_modules/lodash-es/_defineProperty.js
|
|
190
|
+
var defineProperty = function() {
|
|
191
|
+
try {
|
|
192
|
+
var func = getNative_default(Object, "defineProperty");
|
|
193
|
+
func({}, "", {});
|
|
194
|
+
return func;
|
|
195
|
+
} catch (e) {
|
|
196
|
+
}
|
|
197
|
+
}();
|
|
198
|
+
var defineProperty_default = defineProperty;
|
|
199
|
+
|
|
200
|
+
// node_modules/lodash-es/_isIndex.js
|
|
201
|
+
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
202
|
+
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|
203
|
+
function isIndex(value, length) {
|
|
204
|
+
var type = typeof value;
|
|
205
|
+
length = length == null ? MAX_SAFE_INTEGER : length;
|
|
206
|
+
return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
|
|
207
|
+
}
|
|
208
|
+
var isIndex_default = isIndex;
|
|
209
|
+
|
|
210
|
+
// node_modules/lodash-es/_baseAssignValue.js
|
|
211
|
+
function baseAssignValue(object, key, value) {
|
|
212
|
+
if (key == "__proto__" && defineProperty_default) {
|
|
213
|
+
defineProperty_default(object, key, {
|
|
214
|
+
"configurable": true,
|
|
215
|
+
"enumerable": true,
|
|
216
|
+
"value": value,
|
|
217
|
+
"writable": true
|
|
218
|
+
});
|
|
219
|
+
} else {
|
|
220
|
+
object[key] = value;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
var baseAssignValue_default = baseAssignValue;
|
|
224
|
+
|
|
225
|
+
// node_modules/lodash-es/eq.js
|
|
226
|
+
function eq(value, other) {
|
|
227
|
+
return value === other || value !== value && other !== other;
|
|
228
|
+
}
|
|
229
|
+
var eq_default = eq;
|
|
230
|
+
|
|
231
|
+
// node_modules/lodash-es/_assignValue.js
|
|
232
|
+
var objectProto4 = Object.prototype;
|
|
233
|
+
var hasOwnProperty3 = objectProto4.hasOwnProperty;
|
|
234
|
+
function assignValue(object, key, value) {
|
|
235
|
+
var objValue = object[key];
|
|
236
|
+
if (!(hasOwnProperty3.call(object, key) && eq_default(objValue, value)) || value === void 0 && !(key in object)) {
|
|
237
|
+
baseAssignValue_default(object, key, value);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
var assignValue_default = assignValue;
|
|
241
|
+
|
|
242
|
+
// node_modules/lodash-es/isLength.js
|
|
243
|
+
var MAX_SAFE_INTEGER2 = 9007199254740991;
|
|
244
|
+
function isLength(value) {
|
|
245
|
+
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER2;
|
|
246
|
+
}
|
|
247
|
+
var isLength_default = isLength;
|
|
248
|
+
|
|
249
|
+
// node_modules/lodash-es/_baseIsArguments.js
|
|
250
|
+
var argsTag = "[object Arguments]";
|
|
251
|
+
function baseIsArguments(value) {
|
|
252
|
+
return isObjectLike_default(value) && baseGetTag_default(value) == argsTag;
|
|
253
|
+
}
|
|
254
|
+
var baseIsArguments_default = baseIsArguments;
|
|
255
|
+
|
|
256
|
+
// node_modules/lodash-es/isArguments.js
|
|
257
|
+
var objectProto5 = Object.prototype;
|
|
258
|
+
var hasOwnProperty4 = objectProto5.hasOwnProperty;
|
|
259
|
+
var propertyIsEnumerable = objectProto5.propertyIsEnumerable;
|
|
260
|
+
var isArguments = baseIsArguments_default(/* @__PURE__ */ function() {
|
|
261
|
+
return arguments;
|
|
262
|
+
}()) ? baseIsArguments_default : function(value) {
|
|
263
|
+
return isObjectLike_default(value) && hasOwnProperty4.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
|
|
264
|
+
};
|
|
265
|
+
var isArguments_default = isArguments;
|
|
266
|
+
|
|
267
|
+
// node_modules/lodash-es/_isKey.js
|
|
268
|
+
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
|
|
269
|
+
var reIsPlainProp = /^\w*$/;
|
|
270
|
+
function isKey(value, object) {
|
|
271
|
+
if (isArray_default(value)) {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
var type = typeof value;
|
|
275
|
+
if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol_default(value)) {
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
|
|
279
|
+
}
|
|
280
|
+
var isKey_default = isKey;
|
|
281
|
+
|
|
282
|
+
// node_modules/lodash-es/_nativeCreate.js
|
|
283
|
+
var nativeCreate = getNative_default(Object, "create");
|
|
284
|
+
var nativeCreate_default = nativeCreate;
|
|
285
|
+
|
|
286
|
+
// node_modules/lodash-es/_hashClear.js
|
|
287
|
+
function hashClear() {
|
|
288
|
+
this.__data__ = nativeCreate_default ? nativeCreate_default(null) : {};
|
|
289
|
+
this.size = 0;
|
|
290
|
+
}
|
|
291
|
+
var hashClear_default = hashClear;
|
|
292
|
+
|
|
293
|
+
// node_modules/lodash-es/_hashDelete.js
|
|
294
|
+
function hashDelete(key) {
|
|
295
|
+
var result = this.has(key) && delete this.__data__[key];
|
|
296
|
+
this.size -= result ? 1 : 0;
|
|
297
|
+
return result;
|
|
298
|
+
}
|
|
299
|
+
var hashDelete_default = hashDelete;
|
|
300
|
+
|
|
301
|
+
// node_modules/lodash-es/_hashGet.js
|
|
302
|
+
var HASH_UNDEFINED = "__lodash_hash_undefined__";
|
|
303
|
+
var objectProto6 = Object.prototype;
|
|
304
|
+
var hasOwnProperty5 = objectProto6.hasOwnProperty;
|
|
305
|
+
function hashGet(key) {
|
|
306
|
+
var data = this.__data__;
|
|
307
|
+
if (nativeCreate_default) {
|
|
308
|
+
var result = data[key];
|
|
309
|
+
return result === HASH_UNDEFINED ? void 0 : result;
|
|
310
|
+
}
|
|
311
|
+
return hasOwnProperty5.call(data, key) ? data[key] : void 0;
|
|
312
|
+
}
|
|
313
|
+
var hashGet_default = hashGet;
|
|
314
|
+
|
|
315
|
+
// node_modules/lodash-es/_hashHas.js
|
|
316
|
+
var objectProto7 = Object.prototype;
|
|
317
|
+
var hasOwnProperty6 = objectProto7.hasOwnProperty;
|
|
318
|
+
function hashHas(key) {
|
|
319
|
+
var data = this.__data__;
|
|
320
|
+
return nativeCreate_default ? data[key] !== void 0 : hasOwnProperty6.call(data, key);
|
|
321
|
+
}
|
|
322
|
+
var hashHas_default = hashHas;
|
|
323
|
+
|
|
324
|
+
// node_modules/lodash-es/_hashSet.js
|
|
325
|
+
var HASH_UNDEFINED2 = "__lodash_hash_undefined__";
|
|
326
|
+
function hashSet(key, value) {
|
|
327
|
+
var data = this.__data__;
|
|
328
|
+
this.size += this.has(key) ? 0 : 1;
|
|
329
|
+
data[key] = nativeCreate_default && value === void 0 ? HASH_UNDEFINED2 : value;
|
|
330
|
+
return this;
|
|
331
|
+
}
|
|
332
|
+
var hashSet_default = hashSet;
|
|
333
|
+
|
|
334
|
+
// node_modules/lodash-es/_Hash.js
|
|
335
|
+
function Hash(entries) {
|
|
336
|
+
var index = -1, length = entries == null ? 0 : entries.length;
|
|
337
|
+
this.clear();
|
|
338
|
+
while (++index < length) {
|
|
339
|
+
var entry = entries[index];
|
|
340
|
+
this.set(entry[0], entry[1]);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
Hash.prototype.clear = hashClear_default;
|
|
344
|
+
Hash.prototype["delete"] = hashDelete_default;
|
|
345
|
+
Hash.prototype.get = hashGet_default;
|
|
346
|
+
Hash.prototype.has = hashHas_default;
|
|
347
|
+
Hash.prototype.set = hashSet_default;
|
|
348
|
+
var Hash_default = Hash;
|
|
349
|
+
|
|
350
|
+
// node_modules/lodash-es/_listCacheClear.js
|
|
351
|
+
function listCacheClear() {
|
|
352
|
+
this.__data__ = [];
|
|
353
|
+
this.size = 0;
|
|
354
|
+
}
|
|
355
|
+
var listCacheClear_default = listCacheClear;
|
|
356
|
+
|
|
357
|
+
// node_modules/lodash-es/_assocIndexOf.js
|
|
358
|
+
function assocIndexOf(array, key) {
|
|
359
|
+
var length = array.length;
|
|
360
|
+
while (length--) {
|
|
361
|
+
if (eq_default(array[length][0], key)) {
|
|
362
|
+
return length;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return -1;
|
|
366
|
+
}
|
|
367
|
+
var assocIndexOf_default = assocIndexOf;
|
|
368
|
+
|
|
369
|
+
// node_modules/lodash-es/_listCacheDelete.js
|
|
370
|
+
var arrayProto = Array.prototype;
|
|
371
|
+
var splice = arrayProto.splice;
|
|
372
|
+
function listCacheDelete(key) {
|
|
373
|
+
var data = this.__data__, index = assocIndexOf_default(data, key);
|
|
374
|
+
if (index < 0) {
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
var lastIndex = data.length - 1;
|
|
378
|
+
if (index == lastIndex) {
|
|
379
|
+
data.pop();
|
|
380
|
+
} else {
|
|
381
|
+
splice.call(data, index, 1);
|
|
382
|
+
}
|
|
383
|
+
--this.size;
|
|
384
|
+
return true;
|
|
385
|
+
}
|
|
386
|
+
var listCacheDelete_default = listCacheDelete;
|
|
387
|
+
|
|
388
|
+
// node_modules/lodash-es/_listCacheGet.js
|
|
389
|
+
function listCacheGet(key) {
|
|
390
|
+
var data = this.__data__, index = assocIndexOf_default(data, key);
|
|
391
|
+
return index < 0 ? void 0 : data[index][1];
|
|
392
|
+
}
|
|
393
|
+
var listCacheGet_default = listCacheGet;
|
|
394
|
+
|
|
395
|
+
// node_modules/lodash-es/_listCacheHas.js
|
|
396
|
+
function listCacheHas(key) {
|
|
397
|
+
return assocIndexOf_default(this.__data__, key) > -1;
|
|
398
|
+
}
|
|
399
|
+
var listCacheHas_default = listCacheHas;
|
|
400
|
+
|
|
401
|
+
// node_modules/lodash-es/_listCacheSet.js
|
|
402
|
+
function listCacheSet(key, value) {
|
|
403
|
+
var data = this.__data__, index = assocIndexOf_default(data, key);
|
|
404
|
+
if (index < 0) {
|
|
405
|
+
++this.size;
|
|
406
|
+
data.push([key, value]);
|
|
407
|
+
} else {
|
|
408
|
+
data[index][1] = value;
|
|
409
|
+
}
|
|
410
|
+
return this;
|
|
411
|
+
}
|
|
412
|
+
var listCacheSet_default = listCacheSet;
|
|
413
|
+
|
|
414
|
+
// node_modules/lodash-es/_ListCache.js
|
|
415
|
+
function ListCache(entries) {
|
|
416
|
+
var index = -1, length = entries == null ? 0 : entries.length;
|
|
417
|
+
this.clear();
|
|
418
|
+
while (++index < length) {
|
|
419
|
+
var entry = entries[index];
|
|
420
|
+
this.set(entry[0], entry[1]);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
ListCache.prototype.clear = listCacheClear_default;
|
|
424
|
+
ListCache.prototype["delete"] = listCacheDelete_default;
|
|
425
|
+
ListCache.prototype.get = listCacheGet_default;
|
|
426
|
+
ListCache.prototype.has = listCacheHas_default;
|
|
427
|
+
ListCache.prototype.set = listCacheSet_default;
|
|
428
|
+
var ListCache_default = ListCache;
|
|
429
|
+
|
|
430
|
+
// node_modules/lodash-es/_Map.js
|
|
431
|
+
var Map2 = getNative_default(root_default, "Map");
|
|
432
|
+
var Map_default = Map2;
|
|
433
|
+
|
|
434
|
+
// node_modules/lodash-es/_mapCacheClear.js
|
|
435
|
+
function mapCacheClear() {
|
|
436
|
+
this.size = 0;
|
|
437
|
+
this.__data__ = {
|
|
438
|
+
"hash": new Hash_default(),
|
|
439
|
+
"map": new (Map_default || ListCache_default)(),
|
|
440
|
+
"string": new Hash_default()
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
var mapCacheClear_default = mapCacheClear;
|
|
444
|
+
|
|
445
|
+
// node_modules/lodash-es/_isKeyable.js
|
|
446
|
+
function isKeyable(value) {
|
|
447
|
+
var type = typeof value;
|
|
448
|
+
return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
|
|
449
|
+
}
|
|
450
|
+
var isKeyable_default = isKeyable;
|
|
451
|
+
|
|
452
|
+
// node_modules/lodash-es/_getMapData.js
|
|
453
|
+
function getMapData(map, key) {
|
|
454
|
+
var data = map.__data__;
|
|
455
|
+
return isKeyable_default(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
|
|
456
|
+
}
|
|
457
|
+
var getMapData_default = getMapData;
|
|
458
|
+
|
|
459
|
+
// node_modules/lodash-es/_mapCacheDelete.js
|
|
460
|
+
function mapCacheDelete(key) {
|
|
461
|
+
var result = getMapData_default(this, key)["delete"](key);
|
|
462
|
+
this.size -= result ? 1 : 0;
|
|
463
|
+
return result;
|
|
464
|
+
}
|
|
465
|
+
var mapCacheDelete_default = mapCacheDelete;
|
|
466
|
+
|
|
467
|
+
// node_modules/lodash-es/_mapCacheGet.js
|
|
468
|
+
function mapCacheGet(key) {
|
|
469
|
+
return getMapData_default(this, key).get(key);
|
|
470
|
+
}
|
|
471
|
+
var mapCacheGet_default = mapCacheGet;
|
|
472
|
+
|
|
473
|
+
// node_modules/lodash-es/_mapCacheHas.js
|
|
474
|
+
function mapCacheHas(key) {
|
|
475
|
+
return getMapData_default(this, key).has(key);
|
|
476
|
+
}
|
|
477
|
+
var mapCacheHas_default = mapCacheHas;
|
|
478
|
+
|
|
479
|
+
// node_modules/lodash-es/_mapCacheSet.js
|
|
480
|
+
function mapCacheSet(key, value) {
|
|
481
|
+
var data = getMapData_default(this, key), size = data.size;
|
|
482
|
+
data.set(key, value);
|
|
483
|
+
this.size += data.size == size ? 0 : 1;
|
|
484
|
+
return this;
|
|
485
|
+
}
|
|
486
|
+
var mapCacheSet_default = mapCacheSet;
|
|
487
|
+
|
|
488
|
+
// node_modules/lodash-es/_MapCache.js
|
|
489
|
+
function MapCache(entries) {
|
|
490
|
+
var index = -1, length = entries == null ? 0 : entries.length;
|
|
491
|
+
this.clear();
|
|
492
|
+
while (++index < length) {
|
|
493
|
+
var entry = entries[index];
|
|
494
|
+
this.set(entry[0], entry[1]);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
MapCache.prototype.clear = mapCacheClear_default;
|
|
498
|
+
MapCache.prototype["delete"] = mapCacheDelete_default;
|
|
499
|
+
MapCache.prototype.get = mapCacheGet_default;
|
|
500
|
+
MapCache.prototype.has = mapCacheHas_default;
|
|
501
|
+
MapCache.prototype.set = mapCacheSet_default;
|
|
502
|
+
var MapCache_default = MapCache;
|
|
503
|
+
|
|
504
|
+
// node_modules/lodash-es/memoize.js
|
|
505
|
+
var FUNC_ERROR_TEXT = "Expected a function";
|
|
506
|
+
function memoize(func, resolver) {
|
|
507
|
+
if (typeof func != "function" || resolver != null && typeof resolver != "function") {
|
|
508
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
509
|
+
}
|
|
510
|
+
var memoized = function() {
|
|
511
|
+
var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
|
|
512
|
+
if (cache.has(key)) {
|
|
513
|
+
return cache.get(key);
|
|
514
|
+
}
|
|
515
|
+
var result = func.apply(this, args);
|
|
516
|
+
memoized.cache = cache.set(key, result) || cache;
|
|
517
|
+
return result;
|
|
518
|
+
};
|
|
519
|
+
memoized.cache = new (memoize.Cache || MapCache_default)();
|
|
520
|
+
return memoized;
|
|
521
|
+
}
|
|
522
|
+
memoize.Cache = MapCache_default;
|
|
523
|
+
var memoize_default = memoize;
|
|
524
|
+
|
|
525
|
+
// node_modules/lodash-es/_memoizeCapped.js
|
|
526
|
+
var MAX_MEMOIZE_SIZE = 500;
|
|
527
|
+
function memoizeCapped(func) {
|
|
528
|
+
var result = memoize_default(func, function(key) {
|
|
529
|
+
if (cache.size === MAX_MEMOIZE_SIZE) {
|
|
530
|
+
cache.clear();
|
|
531
|
+
}
|
|
532
|
+
return key;
|
|
533
|
+
});
|
|
534
|
+
var cache = result.cache;
|
|
535
|
+
return result;
|
|
536
|
+
}
|
|
537
|
+
var memoizeCapped_default = memoizeCapped;
|
|
538
|
+
|
|
539
|
+
// node_modules/lodash-es/_stringToPath.js
|
|
540
|
+
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
|
541
|
+
var reEscapeChar = /\\(\\)?/g;
|
|
542
|
+
var stringToPath = memoizeCapped_default(function(string) {
|
|
543
|
+
var result = [];
|
|
544
|
+
if (string.charCodeAt(0) === 46) {
|
|
545
|
+
result.push("");
|
|
546
|
+
}
|
|
547
|
+
string.replace(rePropName, function(match, number, quote, subString) {
|
|
548
|
+
result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match);
|
|
549
|
+
});
|
|
550
|
+
return result;
|
|
551
|
+
});
|
|
552
|
+
var stringToPath_default = stringToPath;
|
|
553
|
+
|
|
554
|
+
// node_modules/lodash-es/toString.js
|
|
555
|
+
function toString(value) {
|
|
556
|
+
return value == null ? "" : baseToString_default(value);
|
|
557
|
+
}
|
|
558
|
+
var toString_default = toString;
|
|
559
|
+
|
|
560
|
+
// node_modules/lodash-es/_castPath.js
|
|
561
|
+
function castPath(value, object) {
|
|
562
|
+
if (isArray_default(value)) {
|
|
563
|
+
return value;
|
|
564
|
+
}
|
|
565
|
+
return isKey_default(value, object) ? [value] : stringToPath_default(toString_default(value));
|
|
566
|
+
}
|
|
567
|
+
var castPath_default = castPath;
|
|
568
|
+
|
|
569
|
+
// node_modules/lodash-es/_toKey.js
|
|
570
|
+
var INFINITY2 = 1 / 0;
|
|
571
|
+
function toKey(value) {
|
|
572
|
+
if (typeof value == "string" || isSymbol_default(value)) {
|
|
573
|
+
return value;
|
|
574
|
+
}
|
|
575
|
+
var result = value + "";
|
|
576
|
+
return result == "0" && 1 / value == -INFINITY2 ? "-0" : result;
|
|
577
|
+
}
|
|
578
|
+
var toKey_default = toKey;
|
|
579
|
+
|
|
580
|
+
// node_modules/lodash-es/_baseGet.js
|
|
581
|
+
function baseGet(object, path) {
|
|
582
|
+
path = castPath_default(path, object);
|
|
583
|
+
var index = 0, length = path.length;
|
|
584
|
+
while (object != null && index < length) {
|
|
585
|
+
object = object[toKey_default(path[index++])];
|
|
586
|
+
}
|
|
587
|
+
return index && index == length ? object : void 0;
|
|
588
|
+
}
|
|
589
|
+
var baseGet_default = baseGet;
|
|
590
|
+
|
|
591
|
+
// node_modules/lodash-es/get.js
|
|
592
|
+
function get(object, path, defaultValue) {
|
|
593
|
+
var result = object == null ? void 0 : baseGet_default(object, path);
|
|
594
|
+
return result === void 0 ? defaultValue : result;
|
|
595
|
+
}
|
|
596
|
+
var get_default = get;
|
|
597
|
+
|
|
598
|
+
// node_modules/lodash-es/_baseSlice.js
|
|
599
|
+
function baseSlice(array, start, end) {
|
|
600
|
+
var index = -1, length = array.length;
|
|
601
|
+
if (start < 0) {
|
|
602
|
+
start = -start > length ? 0 : length + start;
|
|
603
|
+
}
|
|
604
|
+
end = end > length ? length : end;
|
|
605
|
+
if (end < 0) {
|
|
606
|
+
end += length;
|
|
607
|
+
}
|
|
608
|
+
length = start > end ? 0 : end - start >>> 0;
|
|
609
|
+
start >>>= 0;
|
|
610
|
+
var result = Array(length);
|
|
611
|
+
while (++index < length) {
|
|
612
|
+
result[index] = array[index + start];
|
|
613
|
+
}
|
|
614
|
+
return result;
|
|
615
|
+
}
|
|
616
|
+
var baseSlice_default = baseSlice;
|
|
617
|
+
|
|
618
|
+
// node_modules/lodash-es/_hasPath.js
|
|
619
|
+
function hasPath(object, path, hasFunc) {
|
|
620
|
+
path = castPath_default(path, object);
|
|
621
|
+
var index = -1, length = path.length, result = false;
|
|
622
|
+
while (++index < length) {
|
|
623
|
+
var key = toKey_default(path[index]);
|
|
624
|
+
if (!(result = object != null && hasFunc(object, key))) {
|
|
625
|
+
break;
|
|
626
|
+
}
|
|
627
|
+
object = object[key];
|
|
628
|
+
}
|
|
629
|
+
if (result || ++index != length) {
|
|
630
|
+
return result;
|
|
631
|
+
}
|
|
632
|
+
length = object == null ? 0 : object.length;
|
|
633
|
+
return !!length && isLength_default(length) && isIndex_default(key, length) && (isArray_default(object) || isArguments_default(object));
|
|
634
|
+
}
|
|
635
|
+
var hasPath_default = hasPath;
|
|
636
|
+
|
|
637
|
+
// node_modules/lodash-es/last.js
|
|
638
|
+
function last(array) {
|
|
639
|
+
var length = array == null ? 0 : array.length;
|
|
640
|
+
return length ? array[length - 1] : void 0;
|
|
641
|
+
}
|
|
642
|
+
var last_default = last;
|
|
643
|
+
|
|
644
|
+
// node_modules/lodash-es/_baseHas.js
|
|
645
|
+
var objectProto8 = Object.prototype;
|
|
646
|
+
var hasOwnProperty7 = objectProto8.hasOwnProperty;
|
|
647
|
+
function baseHas(object, key) {
|
|
648
|
+
return object != null && hasOwnProperty7.call(object, key);
|
|
649
|
+
}
|
|
650
|
+
var baseHas_default = baseHas;
|
|
651
|
+
|
|
652
|
+
// node_modules/lodash-es/has.js
|
|
653
|
+
function has(object, path) {
|
|
654
|
+
return object != null && hasPath_default(object, path, baseHas_default);
|
|
655
|
+
}
|
|
656
|
+
var has_default = has;
|
|
657
|
+
|
|
658
|
+
// node_modules/lodash-es/_parent.js
|
|
659
|
+
function parent(object, path) {
|
|
660
|
+
return path.length < 2 ? object : baseGet_default(object, baseSlice_default(path, 0, -1));
|
|
661
|
+
}
|
|
662
|
+
var parent_default = parent;
|
|
663
|
+
|
|
664
|
+
// node_modules/lodash-es/_baseUnset.js
|
|
665
|
+
function baseUnset(object, path) {
|
|
666
|
+
path = castPath_default(path, object);
|
|
667
|
+
object = parent_default(object, path);
|
|
668
|
+
return object == null || delete object[toKey_default(last_default(path))];
|
|
669
|
+
}
|
|
670
|
+
var baseUnset_default = baseUnset;
|
|
671
|
+
|
|
672
|
+
// node_modules/lodash-es/_baseSet.js
|
|
673
|
+
function baseSet(object, path, value, customizer) {
|
|
674
|
+
if (!isObject_default(object)) {
|
|
675
|
+
return object;
|
|
676
|
+
}
|
|
677
|
+
path = castPath_default(path, object);
|
|
678
|
+
var index = -1, length = path.length, lastIndex = length - 1, nested = object;
|
|
679
|
+
while (nested != null && ++index < length) {
|
|
680
|
+
var key = toKey_default(path[index]), newValue = value;
|
|
681
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
682
|
+
return object;
|
|
683
|
+
}
|
|
684
|
+
if (index != lastIndex) {
|
|
685
|
+
var objValue = nested[key];
|
|
686
|
+
newValue = customizer ? customizer(objValue, key, nested) : void 0;
|
|
687
|
+
if (newValue === void 0) {
|
|
688
|
+
newValue = isObject_default(objValue) ? objValue : isIndex_default(path[index + 1]) ? [] : {};
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
assignValue_default(nested, key, newValue);
|
|
692
|
+
nested = nested[key];
|
|
693
|
+
}
|
|
694
|
+
return object;
|
|
695
|
+
}
|
|
696
|
+
var baseSet_default = baseSet;
|
|
697
|
+
|
|
698
|
+
// node_modules/lodash-es/set.js
|
|
699
|
+
function set(object, path, value) {
|
|
700
|
+
return object == null ? object : baseSet_default(object, path, value);
|
|
701
|
+
}
|
|
702
|
+
var set_default = set;
|
|
703
|
+
|
|
704
|
+
// node_modules/lodash-es/unset.js
|
|
705
|
+
function unset(object, path) {
|
|
706
|
+
return object == null ? true : baseUnset_default(object, path);
|
|
707
|
+
}
|
|
708
|
+
var unset_default = unset;
|
|
709
|
+
|
|
710
|
+
// src/tracked-instance.ts
|
|
711
|
+
import { computed, customRef } from "vue";
|
|
712
|
+
var isObject2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof File) && !(value instanceof Map) && !(value instanceof Set);
|
|
713
|
+
var isEmpty = (value) => Object.keys(value).length === 0;
|
|
714
|
+
var iterateObject = function* (source, params = {}) {
|
|
715
|
+
const { goDeepCondition = (_, value) => isObject2(value), includeParent = false } = params;
|
|
716
|
+
const iterateObjectDeep = function* (path, obj) {
|
|
717
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
718
|
+
const currentPath = path.concat(key);
|
|
719
|
+
if (goDeepCondition(currentPath, value)) {
|
|
720
|
+
if (includeParent) {
|
|
721
|
+
yield [currentPath, value];
|
|
722
|
+
}
|
|
723
|
+
yield* iterateObjectDeep(currentPath, value);
|
|
724
|
+
} else {
|
|
725
|
+
yield [currentPath, value];
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
yield* iterateObjectDeep([], source);
|
|
730
|
+
};
|
|
731
|
+
var createNestedRef = (source, handler) => customRef((track, trigger) => {
|
|
732
|
+
const createProxy = (source2, path = []) => {
|
|
733
|
+
const currentProxyHandler = handler(path);
|
|
734
|
+
return new Proxy(source2, {
|
|
735
|
+
...currentProxyHandler,
|
|
736
|
+
get(target, property, receiver) {
|
|
737
|
+
track();
|
|
738
|
+
const result = currentProxyHandler.get ? currentProxyHandler.get(target, property, receiver) : Reflect.get(target, property, receiver);
|
|
739
|
+
if (isObject2(result) || Array.isArray(result)) {
|
|
740
|
+
return createProxy(result, path.concat({ target, property, receiver }));
|
|
741
|
+
}
|
|
742
|
+
return result;
|
|
743
|
+
},
|
|
744
|
+
set(target, property, value2, receiver) {
|
|
745
|
+
const result = currentProxyHandler.set ? currentProxyHandler.set(target, property, value2, receiver) : Reflect.set(target, property, value2, receiver);
|
|
746
|
+
trigger();
|
|
747
|
+
return result;
|
|
748
|
+
},
|
|
749
|
+
deleteProperty(target, property) {
|
|
750
|
+
const result = currentProxyHandler.deleteProperty ? currentProxyHandler.deleteProperty(target, property) : Reflect.deleteProperty(target, property);
|
|
751
|
+
trigger();
|
|
752
|
+
return result;
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
};
|
|
756
|
+
let value = createProxy(source);
|
|
757
|
+
return {
|
|
758
|
+
get() {
|
|
759
|
+
track();
|
|
760
|
+
return value;
|
|
761
|
+
},
|
|
762
|
+
set(newValue) {
|
|
763
|
+
value = createProxy(newValue);
|
|
764
|
+
trigger();
|
|
765
|
+
}
|
|
766
|
+
};
|
|
767
|
+
});
|
|
768
|
+
var ArrayInOriginalData = class {
|
|
769
|
+
length;
|
|
770
|
+
constructor(length) {
|
|
771
|
+
this.length = length;
|
|
772
|
+
Object.defineProperty(this, "length", {
|
|
773
|
+
enumerable: false,
|
|
774
|
+
value: length
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
var setOriginalDataValue = (originalData, path) => {
|
|
779
|
+
let originalDataTarget = originalData;
|
|
780
|
+
for (const { target: oldValueParent, property } of path.slice(0, -1)) {
|
|
781
|
+
if (property in originalDataTarget) {
|
|
782
|
+
if (isObject2(originalDataTarget[property]) || originalDataTarget[property] instanceof ArrayInOriginalData) {
|
|
783
|
+
originalDataTarget = originalDataTarget[property];
|
|
784
|
+
} else {
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
} else {
|
|
788
|
+
if (Array.isArray(oldValueParent[property])) {
|
|
789
|
+
originalDataTarget = originalDataTarget[property] = new ArrayInOriginalData(oldValueParent[property].length);
|
|
790
|
+
} else if (isObject2(oldValueParent[property])) {
|
|
791
|
+
originalDataTarget = originalDataTarget[property] = {};
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
const lastItem = path.at(-1);
|
|
796
|
+
originalDataTarget[lastItem.property] = lastItem.target[lastItem.property];
|
|
797
|
+
};
|
|
798
|
+
var snapshotValueToOriginalData = (originalData, path, value) => {
|
|
799
|
+
const pathAsString = path.map((i) => i.property);
|
|
800
|
+
const valueInOriginalData = get_default(originalData, pathAsString);
|
|
801
|
+
const markRemovedFieldsAsUndefined = (valueInOriginalData2, oldValue2) => {
|
|
802
|
+
const keysSet = /* @__PURE__ */ new Set();
|
|
803
|
+
if (valueInOriginalData2) {
|
|
804
|
+
for (const key of Object.keys(valueInOriginalData2)) {
|
|
805
|
+
keysSet.add(key);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
if (oldValue2) {
|
|
809
|
+
for (const key of Object.keys(oldValue2)) {
|
|
810
|
+
keysSet.add(key);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
const keys = Array.from(keysSet).filter((key) => !Object.keys(value).includes(key));
|
|
814
|
+
for (const key of keys) {
|
|
815
|
+
snapshotValueToOriginalData(
|
|
816
|
+
originalData,
|
|
817
|
+
path.concat({ target: oldValue2 || value, property: key }),
|
|
818
|
+
void 0
|
|
819
|
+
);
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
const lastPathItem = path.at(-1);
|
|
823
|
+
const oldValue = lastPathItem.target[lastPathItem.property];
|
|
824
|
+
if (isObject2(value) && (isObject2(valueInOriginalData) || isObject2(oldValue))) {
|
|
825
|
+
markRemovedFieldsAsUndefined(valueInOriginalData, oldValue);
|
|
826
|
+
for (const key of Object.keys(value)) {
|
|
827
|
+
snapshotValueToOriginalData(originalData, path.concat({ target: oldValue || value, property: key }), value[key]);
|
|
828
|
+
}
|
|
829
|
+
} else if (Array.isArray(value) && (valueInOriginalData instanceof ArrayInOriginalData || Array.isArray(oldValue))) {
|
|
830
|
+
markRemovedFieldsAsUndefined(valueInOriginalData, oldValue);
|
|
831
|
+
for (const key of value.keys()) {
|
|
832
|
+
snapshotValueToOriginalData(
|
|
833
|
+
originalData,
|
|
834
|
+
path.concat({ target: oldValue || value, property: key.toString() }),
|
|
835
|
+
value[key]
|
|
836
|
+
);
|
|
837
|
+
}
|
|
838
|
+
} else {
|
|
839
|
+
if (!has_default(originalData, pathAsString)) {
|
|
840
|
+
if (oldValue !== value) {
|
|
841
|
+
setOriginalDataValue(originalData, path);
|
|
842
|
+
}
|
|
843
|
+
} else if (valueInOriginalData === value) {
|
|
844
|
+
unset_default(originalData, pathAsString);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
var useTrackedInstance = (initialData) => {
|
|
849
|
+
const _originalData = createNestedRef({}, (path) => ({
|
|
850
|
+
deleteProperty(target, property) {
|
|
851
|
+
const result = Reflect.deleteProperty(target, property);
|
|
852
|
+
if (path.length) {
|
|
853
|
+
const parent2 = path.at(-1);
|
|
854
|
+
if (isEmpty(target)) {
|
|
855
|
+
delete parent2.receiver[parent2.property];
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
return result;
|
|
859
|
+
}
|
|
860
|
+
}));
|
|
861
|
+
const _data = createNestedRef({ root: initialData }, (parentThree) => ({
|
|
862
|
+
set(target, property, value, receiver) {
|
|
863
|
+
const path = parentThree.concat({ target, property, receiver });
|
|
864
|
+
const oldValue = target[property];
|
|
865
|
+
const triggerChangingArrayItems = () => {
|
|
866
|
+
const originalDataValue = get_default(
|
|
867
|
+
_originalData.value,
|
|
868
|
+
path.map((i) => i.property)
|
|
869
|
+
);
|
|
870
|
+
const { length: originalDataLength } = originalDataValue || oldValue;
|
|
871
|
+
if (value < originalDataLength) {
|
|
872
|
+
for (let i = value; i < originalDataLength; i++) {
|
|
873
|
+
delete receiver[i];
|
|
874
|
+
}
|
|
875
|
+
} else if (originalDataLength < value) {
|
|
876
|
+
for (let i = originalDataLength; i < value; i++) {
|
|
877
|
+
receiver[i] = void 0;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
};
|
|
881
|
+
if (Array.isArray(target) && property === "length") {
|
|
882
|
+
if (value !== oldValue) {
|
|
883
|
+
triggerChangingArrayItems();
|
|
884
|
+
}
|
|
885
|
+
} else {
|
|
886
|
+
snapshotValueToOriginalData(_originalData.value, path, value);
|
|
887
|
+
}
|
|
888
|
+
return Reflect.set(target, property, value, receiver);
|
|
889
|
+
},
|
|
890
|
+
deleteProperty(target, property) {
|
|
891
|
+
setOriginalDataValue(_originalData.value, parentThree.concat({ target, property }));
|
|
892
|
+
return Reflect.deleteProperty(target, property);
|
|
893
|
+
}
|
|
894
|
+
}));
|
|
895
|
+
const data = computed({
|
|
896
|
+
get: () => _data.value.root,
|
|
897
|
+
set: (value) => _data.value.root = value
|
|
898
|
+
});
|
|
899
|
+
const isDirty = computed(() => Object.keys(_originalData.value).length > 0);
|
|
900
|
+
const _changedData = computed(() => {
|
|
901
|
+
const changedData2 = {};
|
|
902
|
+
const originalDataIterator = iterateObject(_originalData.value, {
|
|
903
|
+
goDeepCondition: (path, value) => {
|
|
904
|
+
const valueInData = get_default(_data.value, path);
|
|
905
|
+
const isBothValuesAsArray = value instanceof ArrayInOriginalData && Array.isArray(valueInData);
|
|
906
|
+
const isBothValuesAsObject = isObject2(value) && isObject2(valueInData);
|
|
907
|
+
return isBothValuesAsObject || isBothValuesAsArray;
|
|
908
|
+
}
|
|
909
|
+
});
|
|
910
|
+
for (const [path] of originalDataIterator) {
|
|
911
|
+
const valueInData = get_default(_data.value, path);
|
|
912
|
+
set_default(changedData2, path, valueInData);
|
|
913
|
+
}
|
|
914
|
+
return changedData2;
|
|
915
|
+
});
|
|
916
|
+
const changedData = computed(() => _changedData.value.root);
|
|
917
|
+
const loadData = (newData) => {
|
|
918
|
+
_data.value = { root: newData };
|
|
919
|
+
_originalData.value = {};
|
|
920
|
+
};
|
|
921
|
+
const reset = () => {
|
|
922
|
+
const updatedData = JSON.parse(JSON.stringify(_data.value));
|
|
923
|
+
for (const [path, value] of iterateObject(_originalData.value, { includeParent: true })) {
|
|
924
|
+
if (value instanceof ArrayInOriginalData) {
|
|
925
|
+
set_default(updatedData, path.concat("length"), value.length);
|
|
926
|
+
} else if (!isObject2(value)) {
|
|
927
|
+
if (value === void 0) {
|
|
928
|
+
unset_default(updatedData, path);
|
|
929
|
+
} else {
|
|
930
|
+
set_default(updatedData, path, value);
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
_data.value = updatedData;
|
|
935
|
+
_originalData.value = {};
|
|
936
|
+
};
|
|
937
|
+
return {
|
|
938
|
+
data,
|
|
939
|
+
changedData,
|
|
940
|
+
isDirty,
|
|
941
|
+
loadData,
|
|
942
|
+
reset
|
|
943
|
+
};
|
|
944
|
+
};
|
|
945
|
+
|
|
946
|
+
// src/collection.ts
|
|
947
|
+
import { computed as computed2, shallowRef, triggerRef, ref } from "vue";
|
|
948
|
+
var useCollection = (createItemMeta = () => ({})) => {
|
|
949
|
+
const items = shallowRef([]);
|
|
950
|
+
const isDirty = computed2(
|
|
951
|
+
() => items.value.some(({ instance, isRemoved, isNew }) => instance.isDirty.value || isNew.value || isRemoved.value)
|
|
952
|
+
);
|
|
953
|
+
const add = (item, index = items.value.length) => {
|
|
954
|
+
const instance = useTrackedInstance(item);
|
|
955
|
+
const newItem = {
|
|
956
|
+
isRemoved: ref(false),
|
|
957
|
+
isNew: ref(true),
|
|
958
|
+
instance,
|
|
959
|
+
meta: createItemMeta(instance)
|
|
960
|
+
};
|
|
961
|
+
items.value.splice(index, 0, newItem);
|
|
962
|
+
triggerRef(items);
|
|
963
|
+
return newItem;
|
|
964
|
+
};
|
|
965
|
+
const remove = (index, isHardRemove = false) => {
|
|
966
|
+
const item = items.value[index];
|
|
967
|
+
if (item.isNew.value || isHardRemove) {
|
|
968
|
+
items.value.splice(index, 1);
|
|
969
|
+
triggerRef(items);
|
|
970
|
+
} else {
|
|
971
|
+
items.value[index].isRemoved.value = true;
|
|
972
|
+
}
|
|
973
|
+
};
|
|
974
|
+
const loadData = (loadedItems) => {
|
|
975
|
+
items.value = loadedItems.map((item) => {
|
|
976
|
+
const instance = useTrackedInstance(item);
|
|
977
|
+
return {
|
|
978
|
+
isNew: ref(false),
|
|
979
|
+
isRemoved: ref(false),
|
|
980
|
+
instance,
|
|
981
|
+
meta: createItemMeta(instance)
|
|
982
|
+
};
|
|
983
|
+
});
|
|
984
|
+
triggerRef(items);
|
|
985
|
+
};
|
|
986
|
+
const reset = () => {
|
|
987
|
+
items.value = items.value.filter(({ isNew }) => !isNew.value);
|
|
988
|
+
for (const item of items.value) {
|
|
989
|
+
item.isRemoved.value = false;
|
|
990
|
+
item.instance.reset();
|
|
991
|
+
}
|
|
992
|
+
triggerRef(items);
|
|
993
|
+
};
|
|
994
|
+
return {
|
|
995
|
+
items,
|
|
996
|
+
isDirty,
|
|
997
|
+
add,
|
|
998
|
+
remove,
|
|
999
|
+
loadData,
|
|
1000
|
+
reset
|
|
1001
|
+
};
|
|
1002
|
+
};
|
|
1003
|
+
export {
|
|
1004
|
+
useCollection,
|
|
1005
|
+
useTrackedInstance
|
|
1006
|
+
};
|
|
1007
|
+
/*! Bundled license information:
|
|
1008
|
+
|
|
1009
|
+
lodash-es/lodash.js:
|
|
1010
|
+
(**
|
|
1011
|
+
* @license
|
|
1012
|
+
* Lodash (Custom Build) <https://lodash.com/>
|
|
1013
|
+
* Build: `lodash modularize exports="es" -o ./`
|
|
1014
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
1015
|
+
* Released under MIT license <https://lodash.com/license>
|
|
1016
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
1017
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
1018
|
+
*)
|
|
1019
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tracked-instance",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "Build large forms and track all changes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "
|
|
7
|
+
"build": "esbuild ./src/index.ts --bundle --external:vue --outfile=./dist/index.mjs --format=esm",
|
|
8
8
|
"test": "vitest run"
|
|
9
9
|
},
|
|
10
|
-
"main": "./dist/index.
|
|
10
|
+
"main": "./dist/index.mjs",
|
|
11
11
|
"types": "./dist/types/index.d.ts",
|
|
12
12
|
"files": [
|
|
13
13
|
"dist"
|
package/dist/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";(()=>{var tt=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var oe=typeof global=="object"&&global&&global.Object===Object&&global,et=oe;var ae=typeof self=="object"&&self&&self.Object===Object&&self,fe=et||ae||Function("return this")(),w=fe;var se=w.Symbol,y=se;var rt=Object.prototype,le=rt.hasOwnProperty,pe=rt.toString,B=y?y.toStringTag:void 0;function ne(t){var e=le.call(t,B),r=t[B];try{t[B]=void 0;var o=!0}catch{}var a=pe.call(t);return o&&(e?t[B]=r:delete t[B]),a}var ot=ne;var ue=Object.prototype,ie=ue.toString;function me(t){return ie.call(t)}var at=me;var de="[object Null]",xe="[object Undefined]",ft=y?y.toStringTag:void 0;function ce(t){return t==null?t===void 0?xe:de:ft&&ft in Object(t)?ot(t):at(t)}var C=ce;function he(t){return t!=null&&typeof t=="object"}var T=he;var ye="[object Symbol]";function ge(t){return typeof t=="symbol"||T(t)&&C(t)==ye}var D=ge;function be(t,e){for(var r=-1,o=t==null?0:t.length,a=Array(o);++r<o;)a[r]=e(t[r],r,t);return a}var st=be;var ve=Array.isArray,b=ve;var _e=1/0,lt=y?y.prototype:void 0,pt=lt?lt.toString:void 0;function nt(t){if(typeof t=="string")return t;if(b(t))return st(t,nt)+"";if(D(t))return pt?pt.call(t):"";var e=t+"";return e=="0"&&1/t==-_e?"-0":e}var ut=nt;function Oe(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var P=Oe;var Se="[object AsyncFunction]",Pe="[object Function]",Ie="[object GeneratorFunction]",Ae="[object Proxy]";function we(t){if(!P(t))return!1;var e=C(t);return e==Pe||e==Ie||e==Se||e==Ae}var it=we;var Ce=w["__core-js_shared__"],F=Ce;var mt=function(){var t=/[^.]+$/.exec(F&&F.keys&&F.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Te(t){return!!mt&&mt in t}var dt=Te;var De=Function.prototype,Re=De.toString;function je(t){if(t!=null){try{return Re.call(t)}catch{}try{return t+""}catch{}}return""}var xt=je;var Ee=/[\\^$.*+?()[\]{}|]/g,Ne=/^\[object .+?Constructor\]$/,ze=Function.prototype,Be=Object.prototype,Me=ze.toString,We=Be.hasOwnProperty,ke=RegExp("^"+Me.call(We).replace(Ee,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Fe(t){if(!P(t)||dt(t))return!1;var e=it(t)?ke:Ne;return e.test(xt(t))}var ct=Fe;function Le(t,e){return t?.[e]}var ht=Le;function Ge(t,e){var r=ht(t,e);return ct(r)?r:void 0}var R=Ge;var He=function(){try{var t=R(Object,"defineProperty");return t({},"",{}),t}catch{}}(),$=He;var Ke=9007199254740991,qe=/^(?:0|[1-9]\d*)$/;function Ue(t,e){var r=typeof t;return e=e??Ke,!!e&&(r=="number"||r!="symbol"&&qe.test(t))&&t>-1&&t%1==0&&t<e}var L=Ue;function Ve(t,e,r){e=="__proto__"&&$?$(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var yt=Ve;function $e(t,e){return t===e||t!==t&&e!==e}var G=$e;var Je=Object.prototype,Xe=Je.hasOwnProperty;function Ye(t,e,r){var o=t[e];(!(Xe.call(t,e)&&G(o,r))||r===void 0&&!(e in t))&&yt(t,e,r)}var gt=Ye;var Ze=9007199254740991;function Qe(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ze}var bt=Qe;var tr="[object Arguments]";function er(t){return T(t)&&C(t)==tr}var J=er;var vt=Object.prototype,rr=vt.hasOwnProperty,or=vt.propertyIsEnumerable,ar=J(function(){return arguments}())?J:function(t){return T(t)&&rr.call(t,"callee")&&!or.call(t,"callee")},_t=ar;var fr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,sr=/^\w*$/;function lr(t,e){if(b(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||D(t)?!0:sr.test(t)||!fr.test(t)||e!=null&&t in Object(e)}var Ot=lr;var pr=R(Object,"create"),g=pr;function nr(){this.__data__=g?g(null):{},this.size=0}var St=nr;function ur(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Pt=ur;var ir="__lodash_hash_undefined__",mr=Object.prototype,dr=mr.hasOwnProperty;function xr(t){var e=this.__data__;if(g){var r=e[t];return r===ir?void 0:r}return dr.call(e,t)?e[t]:void 0}var It=xr;var cr=Object.prototype,hr=cr.hasOwnProperty;function yr(t){var e=this.__data__;return g?e[t]!==void 0:hr.call(e,t)}var At=yr;var gr="__lodash_hash_undefined__";function br(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=g&&e===void 0?gr:e,this}var wt=br;function j(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}j.prototype.clear=St;j.prototype.delete=Pt;j.prototype.get=It;j.prototype.has=At;j.prototype.set=wt;var X=j;function vr(){this.__data__=[],this.size=0}var Ct=vr;function _r(t,e){for(var r=t.length;r--;)if(G(t[r][0],e))return r;return-1}var v=_r;var Or=Array.prototype,Sr=Or.splice;function Pr(t){var e=this.__data__,r=v(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Sr.call(e,r,1),--this.size,!0}var Tt=Pr;function Ir(t){var e=this.__data__,r=v(e,t);return r<0?void 0:e[r][1]}var Dt=Ir;function Ar(t){return v(this.__data__,t)>-1}var Rt=Ar;function wr(t,e){var r=this.__data__,o=v(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var jt=wr;function E(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}E.prototype.clear=Ct;E.prototype.delete=Tt;E.prototype.get=Dt;E.prototype.has=Rt;E.prototype.set=jt;var Et=E;var Cr=R(w,"Map"),Nt=Cr;function Tr(){this.size=0,this.__data__={hash:new X,map:new(Nt||Et),string:new X}}var zt=Tr;function Dr(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Bt=Dr;function Rr(t,e){var r=t.__data__;return Bt(e)?r[typeof e=="string"?"string":"hash"]:r.map}var _=Rr;function jr(t){var e=_(this,t).delete(t);return this.size-=e?1:0,e}var Mt=jr;function Er(t){return _(this,t).get(t)}var Wt=Er;function Nr(t){return _(this,t).has(t)}var kt=Nr;function zr(t,e){var r=_(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ft=zr;function N(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}N.prototype.clear=zt;N.prototype.delete=Mt;N.prototype.get=Wt;N.prototype.has=kt;N.prototype.set=Ft;var Y=N;var Br="Expected a function";function Z(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Br);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],l=r.cache;if(l.has(a))return l.get(a);var m=t.apply(this,o);return r.cache=l.set(a,m)||l,m};return r.cache=new(Z.Cache||Y),r}Z.Cache=Y;var Lt=Z;var Mr=500;function Wr(t){var e=Lt(t,function(o){return r.size===Mr&&r.clear(),o}),r=e.cache;return e}var Gt=Wr;var kr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Fr=/\\(\\)?/g,Lr=Gt(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(kr,function(r,o,a,l){e.push(a?l.replace(Fr,"$1"):o||r)}),e}),Ht=Lr;function Gr(t){return t==null?"":ut(t)}var Kt=Gr;function Hr(t,e){return b(t)?t:Ot(t,e)?[t]:Ht(Kt(t))}var O=Hr;var Kr=1/0;function qr(t){if(typeof t=="string"||D(t))return t;var e=t+"";return e=="0"&&1/t==-Kr?"-0":e}var S=qr;function Ur(t,e){e=O(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[S(e[r++])];return r&&r==o?t:void 0}var H=Ur;function Vr(t,e,r){var o=t==null?void 0:H(t,e);return o===void 0?r:o}var z=Vr;function $r(t,e,r){var o=-1,a=t.length;e<0&&(e=-e>a?0:a+e),r=r>a?a:r,r<0&&(r+=a),a=e>r?0:r-e>>>0,e>>>=0;for(var l=Array(a);++o<a;)l[o]=t[o+e];return l}var qt=$r;function Jr(t,e,r){e=O(e,t);for(var o=-1,a=e.length,l=!1;++o<a;){var m=S(e[o]);if(!(l=t!=null&&r(t,m)))break;t=t[m]}return l||++o!=a?l:(a=t==null?0:t.length,!!a&&bt(a)&&L(m,a)&&(b(t)||_t(t)))}var Ut=Jr;function Xr(t){var e=t==null?0:t.length;return e?t[e-1]:void 0}var Vt=Xr;var Yr=Object.prototype,Zr=Yr.hasOwnProperty;function Qr(t,e){return t!=null&&Zr.call(t,e)}var $t=Qr;function to(t,e){return t!=null&&Ut(t,e,$t)}var Q=to;function eo(t,e){return e.length<2?t:H(t,qt(e,0,-1))}var Jt=eo;function ro(t,e){return e=O(e,t),t=Jt(t,e),t==null||delete t[S(Vt(e))]}var Xt=ro;function oo(t,e,r,o){if(!P(t))return t;e=O(e,t);for(var a=-1,l=e.length,m=l-1,n=t;n!=null&&++a<l;){var s=S(e[a]),f=r;if(s==="__proto__"||s==="constructor"||s==="prototype")return t;if(a!=m){var p=n[s];f=o?o(p,s,n):void 0,f===void 0&&(f=P(p)?p:L(e[a+1])?[]:{})}gt(n,s,f),n=n[s]}return t}var Yt=oo;function ao(t,e,r){return t==null?t:Yt(t,e,r)}var M=ao;function fo(t,e){return t==null?!0:Xt(t,e)}var K=fo;var I=tt("vue"),c=t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&!(t instanceof Date)&&!(t instanceof File)&&!(t instanceof Map)&&!(t instanceof Set),so=t=>Object.keys(t).length===0,Zt=function*(t,e={}){let{goDeepCondition:r=(l,m)=>c(m),includeParent:o=!1}=e,a=function*(l,m){for(let[n,s]of Object.entries(m)){let f=l.concat(n);r(f,s)?(o&&(yield[f,s]),yield*a(f,s)):yield[f,s]}};yield*a([],t)},Qt=(t,e)=>(0,I.customRef)((r,o)=>{let a=(m,n=[])=>{let s=e(n);return new Proxy(m,{...s,get(f,p,u){r();let i=s.get?s.get(f,p,u):Reflect.get(f,p,u);return c(i)||Array.isArray(i)?a(i,n.concat({target:f,property:p,receiver:u})):i},set(f,p,u,i){let x=s.set?s.set(f,p,u,i):Reflect.set(f,p,u,i);return o(),x},deleteProperty(f,p){let u=s.deleteProperty?s.deleteProperty(f,p):Reflect.deleteProperty(f,p);return o(),u}})},l=a(t);return{get(){return r(),l},set(m){l=a(m),o()}}}),A=class{length;constructor(e){this.length=e,Object.defineProperty(this,"length",{enumerable:!1,value:e})}},te=(t,e)=>{let r=t;for(let{target:a,property:l}of e.slice(0,-1))if(l in r)if(c(r[l])||r[l]instanceof A)r=r[l];else return;else Array.isArray(a[l])?r=r[l]=new A(a[l].length):c(a[l])&&(r=r[l]={});let o=e.at(-1);r[o.property]=o.target[o.property]},q=(t,e,r)=>{let o=e.map(s=>s.property),a=z(t,o),l=(s,f)=>{let p=new Set;if(s)for(let i of Object.keys(s))p.add(i);if(f)for(let i of Object.keys(f))p.add(i);let u=Array.from(p).filter(i=>!Object.keys(r).includes(i));for(let i of u)q(t,e.concat({target:f||r,property:i}),void 0)},m=e.at(-1),n=m.target[m.property];if(c(r)&&(c(a)||c(n))){l(a,n);for(let s of Object.keys(r))q(t,e.concat({target:n||r,property:s}),r[s])}else if(Array.isArray(r)&&(a instanceof A||Array.isArray(n))){l(a,n);for(let s of r.keys())q(t,e.concat({target:n||r,property:s.toString()}),r[s])}else Q(t,o)?a===r&&K(t,o):n!==r&&te(t,e)},U=t=>{let e=Qt({},f=>({deleteProperty(p,u){let i=Reflect.deleteProperty(p,u);if(f.length){let x=f.at(-1);so(p)&&delete x.receiver[x.property]}return i}})),r=Qt({root:t},f=>({set(p,u,i,x){let W=f.concat({target:p,property:u,receiver:x}),V=p[u],ee=()=>{let re=z(e.value,W.map(h=>h.property)),{length:k}=re||V;if(i<k)for(let h=i;h<k;h++)delete x[h];else if(k<i)for(let h=k;h<i;h++)x[h]=void 0};return Array.isArray(p)&&u==="length"?i!==V&&ee():q(e.value,W,i),Reflect.set(p,u,i,x)},deleteProperty(p,u){return te(e.value,f.concat({target:p,property:u})),Reflect.deleteProperty(p,u)}})),o=(0,I.computed)({get:()=>r.value.root,set:f=>r.value.root=f}),a=(0,I.computed)(()=>Object.keys(e.value).length>0),l=(0,I.computed)(()=>{let f={},p=Zt(e.value,{goDeepCondition:(u,i)=>{let x=z(r.value,u),W=i instanceof A&&Array.isArray(x);return c(i)&&c(x)||W}});for(let[u]of p){let i=z(r.value,u);M(f,u,i)}return f}),m=(0,I.computed)(()=>l.value.root);return{data:o,changedData:m,isDirty:a,loadData:f=>{r.value={root:f},e.value={}},reset:()=>{let f=JSON.parse(JSON.stringify(r.value));for(let[p,u]of Zt(e.value,{includeParent:!0}))u instanceof A?M(f,p.concat("length"),u.length):c(u)||(u===void 0?K(f,p):M(f,p,u));r.value=f,e.value={}}}};var d=tt("vue");var lo=(t=()=>({}))=>{let e=(0,d.shallowRef)([]),r=(0,d.computed)(()=>e.value.some(({instance:n,isRemoved:s,isNew:f})=>n.isDirty.value||f.value||s.value));return{items:e,isDirty:r,add:(n,s=e.value.length)=>{let f=U(n),p={isRemoved:(0,d.ref)(!1),isNew:(0,d.ref)(!0),instance:f,meta:t(f)};return e.value.splice(s,0,p),(0,d.triggerRef)(e),p},remove:(n,s=!1)=>{e.value[n].isNew.value||s?(e.value.splice(n,1),(0,d.triggerRef)(e)):e.value[n].isRemoved.value=!0},loadData:n=>{e.value=n.map(s=>{let f=U(s);return{isNew:(0,d.ref)(!1),isRemoved:(0,d.ref)(!1),instance:f,meta:t(f)}}),(0,d.triggerRef)(e)},reset:()=>{e.value=e.value.filter(({isNew:n})=>!n.value);for(let n of e.value)n.isRemoved.value=!1,n.instance.reset();(0,d.triggerRef)(e)}}};})();
|
|
2
|
-
/*! Bundled license information:
|
|
3
|
-
|
|
4
|
-
lodash-es/lodash.js:
|
|
5
|
-
(**
|
|
6
|
-
* @license
|
|
7
|
-
* Lodash (Custom Build) <https://lodash.com/>
|
|
8
|
-
* Build: `lodash modularize exports="es" -o ./`
|
|
9
|
-
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
10
|
-
* Released under MIT license <https://lodash.com/license>
|
|
11
|
-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
12
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
13
|
-
*)
|
|
14
|
-
*/
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ShallowRef, ComputedRef, Ref } from 'vue';
|
|
2
|
-
import { TrackedInstance } from './tracked-instance';
|
|
3
|
-
export interface CollectionItem<Item extends Record<string, any>, Meta = Record<string, any>> {
|
|
4
|
-
instance: TrackedInstance<Item>;
|
|
5
|
-
meta: Meta;
|
|
6
|
-
isRemoved: Ref<boolean>;
|
|
7
|
-
isNew: Ref<boolean>;
|
|
8
|
-
}
|
|
9
|
-
export interface Collection<Item extends Record<string, any>, Meta = Record<string, any>> {
|
|
10
|
-
items: ShallowRef<CollectionItem<Item, Meta>[]>;
|
|
11
|
-
isDirty: ComputedRef<boolean>;
|
|
12
|
-
add: (item: Partial<Item>, afterIndex?: number) => CollectionItem<Item, Meta>;
|
|
13
|
-
remove: (index: number, isHardRemove?: boolean) => void;
|
|
14
|
-
loadData: (items: Item[]) => void;
|
|
15
|
-
reset: () => void;
|
|
16
|
-
}
|
|
17
|
-
export declare const useCollection: <Item extends Record<string, any>, Meta = Record<string, any>>(createItemMeta?: (instance: TrackedInstance<Item>) => Meta) => Collection<Item, Meta>;
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Ref } from 'vue';
|
|
2
|
-
type DeepPartial<T> = T extends object ? {
|
|
3
|
-
[P in keyof T]?: DeepPartial<T[P]>;
|
|
4
|
-
} : T;
|
|
5
|
-
export interface TrackedInstance<Data extends Record<string, any>> {
|
|
6
|
-
data: Ref<Data>;
|
|
7
|
-
isDirty: Ref<boolean>;
|
|
8
|
-
changedData: Ref<DeepPartial<Data>>;
|
|
9
|
-
loadData: (newData: DeepPartial<Data>) => void;
|
|
10
|
-
reset: () => void;
|
|
11
|
-
}
|
|
12
|
-
export declare const useTrackedInstance: <Data extends Record<string, any>>(initialData: Partial<Data>) => TrackedInstance<Data>;
|
|
13
|
-
export {};
|