@formisch/solid 0.11.0 → 0.12.0

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 CHANGED
@@ -56,7 +56,7 @@ export default function LoginPage() {
56
56
  }
57
57
  ```
58
58
 
59
- In addition, Formisch offers several functions (we call them "methods") that can be used to read and manipulate the form state. These include `focus`, `getErrors`, `getAllErrors`, `getInput`, `insert`, `move`, `remove`, `replace`, `reset`, `setErrors`, `setInput`, `submit`, `swap` and `validate`. These methods allow you to control the form programmatically.
59
+ In addition, Formisch offers several functions (we call them "methods") that can be used to read and manipulate the form state. These include `focus`, `getDeepErrorEntries`, `getDeepErrors`, `getDirtyInput`, `getDirtyPaths`, `getErrors`, `getInput`, `handleSubmit`, `insert`, `isDirty`, `isEdited`, `isTouched`, `isValid`, `move`, `pickDirty`, `remove`, `replace`, `reset`, `setErrors`, `setInput`, `submit`, `swap` and `validate`. These methods allow you to control the form programmatically.
60
60
 
61
61
  ## Comparison
62
62
 
package/dist/dev.js CHANGED
@@ -25,11 +25,13 @@ function initializeFieldStore(internalFieldStore, schema, initialInput, path, nu
25
25
  else {
26
26
  internalFieldStore.schema = schema;
27
27
  internalFieldStore.name = JSON.stringify(path);
28
+ internalFieldStore.path = path;
28
29
  const initialElements = [];
29
30
  internalFieldStore.initialElements = initialElements;
30
31
  internalFieldStore.elements = initialElements;
31
32
  internalFieldStore.errors = /* @__PURE__ */ createSignal(null);
32
33
  internalFieldStore.isTouched = /* @__PURE__ */ createSignal(false);
34
+ internalFieldStore.isEdited = /* @__PURE__ */ createSignal(false);
33
35
  internalFieldStore.isDirty = /* @__PURE__ */ createSignal(false);
34
36
  if (schema.type === "array" || schema.type === "loose_tuple" || schema.type === "strict_tuple" || schema.type === "tuple") {
35
37
  if (internalFieldStore.kind && internalFieldStore.kind !== "array") throw new Error(`Store initialized as "${internalFieldStore.kind}" cannot be reinitialized as "array"`);
@@ -39,16 +41,13 @@ function initializeFieldStore(internalFieldStore, schema, initialInput, path, nu
39
41
  if (schema.type === "array") {
40
42
  if (initialInput) for (let index = 0; index < initialInput.length; index++) {
41
43
  internalFieldStore.children[index] = {};
42
- path.push(index);
43
- initializeFieldStore(internalFieldStore.children[index], schema.item, initialInput[index], path);
44
- path.pop();
44
+ initializeFieldStore(internalFieldStore.children[index], schema.item, initialInput[index], [...path, index]);
45
45
  }
46
46
  } else for (let index = 0; index < schema.items.length; index++) {
47
47
  internalFieldStore.children[index] = {};
48
- path.push(index);
49
- initializeFieldStore(internalFieldStore.children[index], schema.items[index], initialInput?.[index], path);
50
- path.pop();
48
+ initializeFieldStore(internalFieldStore.children[index], schema.items[index], initialInput?.[index], [...path, index]);
51
49
  }
50
+ internalFieldStore.isNullish = nullish;
52
51
  const arrayInput = nullish && initialInput == null ? initialInput : true;
53
52
  internalFieldStore.initialInput = /* @__PURE__ */ createSignal(arrayInput);
54
53
  internalFieldStore.startInput = /* @__PURE__ */ createSignal(arrayInput);
@@ -65,10 +64,9 @@ function initializeFieldStore(internalFieldStore, schema, initialInput, path, nu
65
64
  internalFieldStore.children ??= {};
66
65
  for (const key in schema.entries) {
67
66
  internalFieldStore.children[key] ??= {};
68
- path.push(key);
69
- initializeFieldStore(internalFieldStore.children[key], schema.entries[key], initialInput?.[key], path);
70
- path.pop();
67
+ initializeFieldStore(internalFieldStore.children[key], schema.entries[key], initialInput?.[key], [...path, key]);
71
68
  }
69
+ internalFieldStore.isNullish = nullish;
72
70
  const objectInput = nullish && initialInput == null ? initialInput : true;
73
71
  internalFieldStore.initialInput = /* @__PURE__ */ createSignal(objectInput);
74
72
  internalFieldStore.startInput = /* @__PURE__ */ createSignal(objectInput);
@@ -93,19 +91,16 @@ function copyItemState(fromInternalFieldStore, toInternalFieldStore) {
93
91
  toInternalFieldStore.startInput.value = fromInternalFieldStore.startInput.value;
94
92
  toInternalFieldStore.input.value = fromInternalFieldStore.input.value;
95
93
  toInternalFieldStore.isTouched.value = fromInternalFieldStore.isTouched.value;
94
+ toInternalFieldStore.isEdited.value = fromInternalFieldStore.isEdited.value;
96
95
  toInternalFieldStore.isDirty.value = fromInternalFieldStore.isDirty.value;
97
96
  if (fromInternalFieldStore.kind === "array" && toInternalFieldStore.kind === "array") {
98
97
  const fromItems = fromInternalFieldStore.items.value;
99
98
  toInternalFieldStore.startItems.value = fromInternalFieldStore.startItems.value;
100
99
  toInternalFieldStore.items.value = fromItems;
101
- let path;
102
100
  for (let index = 0; index < fromItems.length; index++) {
103
101
  if (!toInternalFieldStore.children[index]) {
104
- path ??= JSON.parse(toInternalFieldStore.name);
105
102
  toInternalFieldStore.children[index] = {};
106
- path.push(index);
107
- initializeFieldStore(toInternalFieldStore.children[index], toInternalFieldStore.schema.item, void 0, path);
108
- path.pop();
103
+ initializeFieldStore(toInternalFieldStore.children[index], toInternalFieldStore.schema.item, void 0, [...toInternalFieldStore.path, index]);
109
104
  }
110
105
  copyItemState(fromInternalFieldStore.children[index], toInternalFieldStore.children[index]);
111
106
  }
@@ -120,30 +115,32 @@ function resetItemState(internalFieldStore, input, keepStart = false) {
120
115
  internalFieldStore.elements = elements;
121
116
  internalFieldStore.errors.value = null;
122
117
  internalFieldStore.isTouched.value = false;
118
+ internalFieldStore.isEdited.value = false;
123
119
  internalFieldStore.isDirty.value = false;
124
120
  if (internalFieldStore.kind === "array" || internalFieldStore.kind === "object") {
125
- const objectInput = input == null ? input : true;
121
+ const objectInput = internalFieldStore.isNullish && input == null ? input : true;
126
122
  if (!keepStart) internalFieldStore.startInput.value = objectInput;
127
123
  internalFieldStore.input.value = objectInput;
128
- if (internalFieldStore.kind === "array") if (input) {
129
- const length = internalFieldStore.schema.type === "array" ? input.length : internalFieldStore.children.length;
130
- const newItems = Array.from({ length }, createUniqueId);
131
- if (!keepStart) internalFieldStore.startItems.value = newItems;
132
- internalFieldStore.items.value = newItems;
133
- let path;
134
- for (let index = 0; index < length; index++) if (internalFieldStore.children[index]) resetItemState(internalFieldStore.children[index], input[index], keepStart);
135
- else {
136
- path ??= JSON.parse(internalFieldStore.name);
137
- internalFieldStore.children[index] = {};
138
- path.push(index);
139
- initializeFieldStore(internalFieldStore.children[index], internalFieldStore.schema.item, input[index], path);
140
- path.pop();
124
+ if (internalFieldStore.kind === "array") {
125
+ const isTuple = internalFieldStore.schema.type !== "array";
126
+ if (input || isTuple) {
127
+ const length = isTuple ? internalFieldStore.children.length : input.length;
128
+ const newItems = Array.from({ length }, createUniqueId);
129
+ if (!keepStart) internalFieldStore.startItems.value = newItems;
130
+ internalFieldStore.items.value = newItems;
131
+ for (let index = 0; index < length; index++) {
132
+ const itemInput = input?.[index];
133
+ if (internalFieldStore.children[index]) resetItemState(internalFieldStore.children[index], itemInput, keepStart);
134
+ else {
135
+ internalFieldStore.children[index] = {};
136
+ initializeFieldStore(internalFieldStore.children[index], internalFieldStore.schema.item, itemInput, [...internalFieldStore.path, index]);
137
+ }
138
+ }
139
+ } else {
140
+ if (!keepStart) internalFieldStore.startItems.value = [];
141
+ internalFieldStore.items.value = [];
141
142
  }
142
- } else {
143
- if (!keepStart) internalFieldStore.startItems.value = [];
144
- internalFieldStore.items.value = [];
145
- }
146
- else for (const key in internalFieldStore.children) resetItemState(internalFieldStore.children[key], input?.[key], keepStart);
143
+ } else for (const key in internalFieldStore.children) resetItemState(internalFieldStore.children[key], input?.[key], keepStart);
147
144
  } else {
148
145
  if (!keepStart) internalFieldStore.startInput.value = input;
149
146
  internalFieldStore.input.value = input;
@@ -168,6 +165,9 @@ function swapItemState(firstInternalFieldStore, secondInternalFieldStore) {
168
165
  const tempIsTouched = firstInternalFieldStore.isTouched.value;
169
166
  firstInternalFieldStore.isTouched.value = secondInternalFieldStore.isTouched.value;
170
167
  secondInternalFieldStore.isTouched.value = tempIsTouched;
168
+ const tempIsEdited = firstInternalFieldStore.isEdited.value;
169
+ firstInternalFieldStore.isEdited.value = secondInternalFieldStore.isEdited.value;
170
+ secondInternalFieldStore.isEdited.value = tempIsEdited;
171
171
  const tempIsDirty = firstInternalFieldStore.isDirty.value;
172
172
  firstInternalFieldStore.isDirty.value = secondInternalFieldStore.isDirty.value;
173
173
  secondInternalFieldStore.isDirty.value = tempIsDirty;
@@ -180,22 +180,14 @@ function swapItemState(firstInternalFieldStore, secondInternalFieldStore) {
180
180
  firstInternalFieldStore.items.value = secondItems;
181
181
  secondInternalFieldStore.items.value = firstItems;
182
182
  const maxLength = Math.max(firstItems.length, secondItems.length);
183
- let firstPath;
184
- let secondPath;
185
183
  for (let index = 0; index < maxLength; index++) {
186
184
  if (!firstInternalFieldStore.children[index]) {
187
- firstPath ??= JSON.parse(firstInternalFieldStore.name);
188
185
  firstInternalFieldStore.children[index] = {};
189
- firstPath.push(index);
190
- initializeFieldStore(firstInternalFieldStore.children[index], firstInternalFieldStore.schema.item, void 0, firstPath);
191
- firstPath.pop();
186
+ initializeFieldStore(firstInternalFieldStore.children[index], firstInternalFieldStore.schema.item, void 0, [...firstInternalFieldStore.path, index]);
192
187
  }
193
188
  if (!secondInternalFieldStore.children[index]) {
194
- secondPath ??= JSON.parse(secondInternalFieldStore.name);
195
189
  secondInternalFieldStore.children[index] = {};
196
- secondPath.push(index);
197
- initializeFieldStore(secondInternalFieldStore.children[index], secondInternalFieldStore.schema.item, void 0, secondPath);
198
- secondPath.pop();
190
+ initializeFieldStore(secondInternalFieldStore.children[index], secondInternalFieldStore.schema.item, void 0, [...secondInternalFieldStore.path, index]);
199
191
  }
200
192
  swapItemState(firstInternalFieldStore.children[index], secondInternalFieldStore.children[index]);
201
193
  }
@@ -210,20 +202,20 @@ function focusFieldElement(internalFieldStore) {
210
202
  }
211
203
  return false;
212
204
  }
213
- // @__NO_SIDE_EFFECTS__
214
- function getFieldBool(internalFieldStore, type) {
215
- if (internalFieldStore[type].value) return true;
205
+ function walkFieldStore(internalFieldStore, callback) {
206
+ if (callback(internalFieldStore)) return true;
216
207
  if (internalFieldStore.kind === "array") {
217
- for (let index = 0; index < internalFieldStore.items.value.length; index++) if (/* @__PURE__ */ getFieldBool(internalFieldStore.children[index], type)) return true;
218
- return false;
219
- }
220
- if (internalFieldStore.kind == "object") {
221
- for (const key in internalFieldStore.children) if (/* @__PURE__ */ getFieldBool(internalFieldStore.children[key], type)) return true;
222
- return false;
208
+ for (let index = 0; index < internalFieldStore.items.value.length; index++) if (walkFieldStore(internalFieldStore.children[index], callback)) return true;
209
+ } else if (internalFieldStore.kind === "object") {
210
+ for (const key in internalFieldStore.children) if (walkFieldStore(internalFieldStore.children[key], callback)) return true;
223
211
  }
224
212
  return false;
225
213
  }
226
214
  // @__NO_SIDE_EFFECTS__
215
+ function getFieldBool(internalFieldStore, type) {
216
+ return walkFieldStore(internalFieldStore, (internalFieldStore$1) => Boolean(internalFieldStore$1[type].value));
217
+ }
218
+ // @__NO_SIDE_EFFECTS__
227
219
  function getDirtyFieldInput(internalFieldStore, dirtyOnly = true) {
228
220
  if (dirtyOnly && !/* @__PURE__ */ getFieldBool(internalFieldStore, "isDirty")) return;
229
221
  if (internalFieldStore.kind === "array") {
@@ -293,26 +285,26 @@ function getFieldStore(internalFormStore, path) {
293
285
  }
294
286
  function setFieldBool(internalFieldStore, type, bool) {
295
287
  batch(() => {
296
- internalFieldStore[type].value = bool;
297
- if (internalFieldStore.kind === "array") for (let index = 0; index < untrack(() => internalFieldStore.items.value).length; index++) setFieldBool(internalFieldStore.children[index], type, bool);
298
- else if (internalFieldStore.kind === "object") for (const key in internalFieldStore.children) setFieldBool(internalFieldStore.children[key], type, bool);
288
+ untrack(() => {
289
+ walkFieldStore(internalFieldStore, (internalFieldStore$1) => {
290
+ internalFieldStore$1[type].value = bool;
291
+ });
292
+ });
299
293
  });
300
294
  }
301
295
  function setNestedInput(internalFieldStore, input) {
302
296
  internalFieldStore.isTouched.value = true;
297
+ internalFieldStore.isEdited.value = true;
303
298
  if (internalFieldStore.kind === "array") {
304
299
  const arrayInput = input ?? [];
305
300
  const items = internalFieldStore.items.value;
306
301
  const length = internalFieldStore.schema.type === "array" ? arrayInput.length : internalFieldStore.children.length;
307
302
  if (length < items.length) internalFieldStore.items.value = items.slice(0, length);
308
303
  else if (length > items.length) {
309
- const path = JSON.parse(internalFieldStore.name);
310
304
  for (let index = items.length; index < length; index++) if (internalFieldStore.children[index]) resetItemState(internalFieldStore.children[index], arrayInput[index], true);
311
305
  else {
312
306
  internalFieldStore.children[index] = {};
313
- path.push(index);
314
- initializeFieldStore(internalFieldStore.children[index], internalFieldStore.schema.item, arrayInput[index], path);
315
- path.pop();
307
+ initializeFieldStore(internalFieldStore.children[index], internalFieldStore.schema.item, arrayInput[index], [...internalFieldStore.path, index]);
316
308
  }
317
309
  internalFieldStore.items.value = [...items, ...Array.from({ length: length - items.length }, createUniqueId)];
318
310
  }
@@ -347,14 +339,9 @@ function setInitialFieldInput(internalFieldStore, initialInput) {
347
339
  internalFieldStore.initialInput.value = initialInput == null ? initialInput : true;
348
340
  const initialArrayInput = initialInput ?? [];
349
341
  const length = internalFieldStore.schema.type === "array" ? initialArrayInput.length : internalFieldStore.children.length;
350
- if (length > internalFieldStore.children.length) {
351
- const path = JSON.parse(internalFieldStore.name);
352
- for (let index = internalFieldStore.children.length; index < length; index++) {
353
- internalFieldStore.children[index] = {};
354
- path.push(index);
355
- initializeFieldStore(internalFieldStore.children[index], internalFieldStore.schema.item, initialArrayInput[index], path);
356
- path.pop();
357
- }
342
+ if (length > internalFieldStore.children.length) for (let index = internalFieldStore.children.length; index < length; index++) {
343
+ internalFieldStore.children[index] = {};
344
+ initializeFieldStore(internalFieldStore.children[index], internalFieldStore.schema.item, initialArrayInput[index], [...internalFieldStore.path, index]);
358
345
  }
359
346
  internalFieldStore.initialItems.value = Array.from({ length }, createUniqueId);
360
347
  for (let index = 0; index < internalFieldStore.children.length; index++) setInitialFieldInput(internalFieldStore.children[index], initialArrayInput[index]);
@@ -364,11 +351,6 @@ function setInitialFieldInput(internalFieldStore, initialInput) {
364
351
  } else internalFieldStore.initialInput.value = initialInput;
365
352
  });
366
353
  }
367
- function walkFieldStore(internalFieldStore, callback) {
368
- callback(internalFieldStore);
369
- if (internalFieldStore.kind === "array") for (let index = 0; index < untrack(() => internalFieldStore.items.value).length; index++) walkFieldStore(internalFieldStore.children[index], callback);
370
- else if (internalFieldStore.kind === "object") for (const key in internalFieldStore.children) walkFieldStore(internalFieldStore.children[key], callback);
371
- }
372
354
  function createFormStore(config, parse) {
373
355
  const store = {};
374
356
  initializeFieldStore(store, config.schema, config.initialInput, []);
@@ -408,13 +390,15 @@ async function validateFormInput(internalFormStore, config) {
408
390
  }
409
391
  let shouldFocus = config?.shouldFocus ?? false;
410
392
  batch(() => {
411
- walkFieldStore(internalFormStore, (internalFieldStore) => {
412
- if (internalFieldStore.name === "[]") internalFieldStore.errors.value = rootErrors ?? null;
413
- else {
414
- const fieldErrors = nestedErrors?.[internalFieldStore.name] ?? null;
415
- internalFieldStore.errors.value = fieldErrors;
416
- if (shouldFocus && fieldErrors && focusFieldElement(internalFieldStore)) shouldFocus = false;
417
- }
393
+ untrack(() => {
394
+ walkFieldStore(internalFormStore, (internalFieldStore) => {
395
+ if (internalFieldStore.path.length === 0) internalFieldStore.errors.value = rootErrors ?? null;
396
+ else {
397
+ const fieldErrors = nestedErrors?.[internalFieldStore.name] ?? null;
398
+ internalFieldStore.errors.value = fieldErrors;
399
+ if (shouldFocus && fieldErrors && focusFieldElement(internalFieldStore)) shouldFocus = false;
400
+ }
401
+ });
418
402
  });
419
403
  internalFormStore.validators--;
420
404
  internalFormStore.isValidating.value = internalFormStore.validators > 0;
@@ -438,15 +422,26 @@ function focus(form, config) {
438
422
  focusFieldElement(getFieldStore(form[INTERNAL], config.path));
439
423
  }
440
424
  // @__NO_SIDE_EFFECTS__
441
- function getAllErrors(form) {
442
- let allErrors = null;
443
- walkFieldStore(form[INTERNAL], (internalFieldStore) => {
444
- if (internalFieldStore.kind === "array") internalFieldStore.items.value;
425
+ function getDeepErrorEntries(form, config) {
426
+ const entries = [];
427
+ walkFieldStore(config?.path ? getFieldStore(form[INTERNAL], config.path) : form[INTERNAL], (internalFieldStore) => {
428
+ const errors = internalFieldStore.errors.value;
429
+ if (errors) entries.push({
430
+ path: internalFieldStore.path,
431
+ errors
432
+ });
433
+ });
434
+ return entries;
435
+ }
436
+ // @__NO_SIDE_EFFECTS__
437
+ function getDeepErrors(form, config) {
438
+ let deepErrors = null;
439
+ walkFieldStore(config?.path ? getFieldStore(form[INTERNAL], config.path) : form[INTERNAL], (internalFieldStore) => {
445
440
  const errors = internalFieldStore.errors.value;
446
- if (errors) if (allErrors) allErrors.push(...errors);
447
- else allErrors = [...errors];
441
+ if (errors) if (deepErrors) deepErrors.push(...errors);
442
+ else deepErrors = [...errors];
448
443
  });
449
- return allErrors;
444
+ return deepErrors;
450
445
  }
451
446
  // @__NO_SIDE_EFFECTS__
452
447
  function getDirtyInput(form, config) {
@@ -454,9 +449,8 @@ function getDirtyInput(form, config) {
454
449
  }
455
450
  // @__NO_SIDE_EFFECTS__
456
451
  function getDirtyPaths(form, config) {
457
- config?.path ? getFieldStore(form[INTERNAL], config.path) : form[INTERNAL];
458
452
  const paths = [];
459
- config?.path && [...config.path];
453
+ config?.path ? getFieldStore(form[INTERNAL], config.path) : form[INTERNAL];
460
454
  return paths;
461
455
  }
462
456
  // @__NO_SIDE_EFFECTS__
@@ -500,25 +494,38 @@ function insert(form, config) {
500
494
  internalArrayStore.items.value = newItems;
501
495
  for (let index = items.length; index > insertIndex; index--) {
502
496
  if (!internalArrayStore.children[index]) {
503
- const path = JSON.parse(internalArrayStore.name);
504
497
  internalArrayStore.children[index] = {};
505
- path.push(index);
506
- initializeFieldStore(internalArrayStore.children[index], internalArrayStore.schema.item, void 0, path);
498
+ initializeFieldStore(internalArrayStore.children[index], internalArrayStore.schema.item, void 0, [...internalArrayStore.path, index]);
507
499
  }
508
500
  copyItemState(internalArrayStore.children[index - 1], internalArrayStore.children[index]);
509
501
  }
510
502
  if (!internalArrayStore.children[insertIndex]) {
511
- const path = JSON.parse(internalArrayStore.name);
512
503
  internalArrayStore.children[insertIndex] = {};
513
- path.push(insertIndex);
514
- initializeFieldStore(internalArrayStore.children[insertIndex], internalArrayStore.schema.item, config.initialInput, path);
504
+ initializeFieldStore(internalArrayStore.children[insertIndex], internalArrayStore.schema.item, config.initialInput, [...internalArrayStore.path, insertIndex]);
515
505
  } else resetItemState(internalArrayStore.children[insertIndex], config.initialInput);
516
506
  internalArrayStore.input.value = true;
517
507
  internalArrayStore.isTouched.value = true;
508
+ internalArrayStore.isEdited.value = true;
518
509
  internalArrayStore.isDirty.value = true;
519
510
  validateIfRequired(internalFormStore, internalArrayStore, "input");
520
511
  });
521
512
  }
513
+ // @__NO_SIDE_EFFECTS__
514
+ function isDirty(form, config) {
515
+ return getFieldBool(config?.path ? getFieldStore(form[INTERNAL], config.path) : form[INTERNAL], "isDirty");
516
+ }
517
+ // @__NO_SIDE_EFFECTS__
518
+ function isEdited(form, config) {
519
+ return getFieldBool(config?.path ? getFieldStore(form[INTERNAL], config.path) : form[INTERNAL], "isEdited");
520
+ }
521
+ // @__NO_SIDE_EFFECTS__
522
+ function isTouched(form, config) {
523
+ return getFieldBool(config?.path ? getFieldStore(form[INTERNAL], config.path) : form[INTERNAL], "isTouched");
524
+ }
525
+ // @__NO_SIDE_EFFECTS__
526
+ function isValid(form, config) {
527
+ return !getFieldBool(config?.path ? getFieldStore(form[INTERNAL], config.path) : form[INTERNAL], "errors");
528
+ }
522
529
  function move(form, config) {
523
530
  const internalFormStore = form[INTERNAL];
524
531
  const internalArrayStore = getFieldStore(internalFormStore, config.path);
@@ -534,6 +541,7 @@ function move(form, config) {
534
541
  else for (let index = config.from; index > config.to; index--) copyItemState(internalArrayStore.children[index - 1], internalArrayStore.children[index]);
535
542
  copyItemState(tempInternalFieldStore, internalArrayStore.children[config.to]);
536
543
  internalArrayStore.isTouched.value = true;
544
+ internalArrayStore.isEdited.value = true;
537
545
  internalArrayStore.isDirty.value = internalArrayStore.startItems.value.join() !== newItems.join();
538
546
  validateIfRequired(internalFormStore, internalArrayStore, "input");
539
547
  });
@@ -566,6 +574,7 @@ function remove(form, config) {
566
574
  internalArrayStore.items.value = newItems;
567
575
  for (let index = config.at; index < items.length - 1; index++) copyItemState(internalArrayStore.children[index + 1], internalArrayStore.children[index]);
568
576
  internalArrayStore.isTouched.value = true;
577
+ internalArrayStore.isEdited.value = true;
569
578
  internalArrayStore.isDirty.value = internalArrayStore.startItems.value.join() !== newItems.join();
570
579
  validateIfRequired(internalFormStore, internalArrayStore, "input");
571
580
  });
@@ -580,6 +589,7 @@ function replace(form, config) {
580
589
  internalArrayStore.items.value = newItems;
581
590
  resetItemState(internalArrayStore.children[config.at], config.initialInput);
582
591
  internalArrayStore.isTouched.value = true;
592
+ internalArrayStore.isEdited.value = true;
583
593
  internalArrayStore.isDirty.value = true;
584
594
  validateIfRequired(internalFormStore, internalArrayStore, "input");
585
595
  });
@@ -594,6 +604,7 @@ function reset(form, config) {
594
604
  internalFieldStore$1.elements = internalFieldStore$1.initialElements;
595
605
  if (!config?.keepErrors) internalFieldStore$1.errors.value = null;
596
606
  if (!config?.keepTouched) internalFieldStore$1.isTouched.value = false;
607
+ if (!config?.keepEdited) internalFieldStore$1.isEdited.value = false;
597
608
  internalFieldStore$1.startInput.value = internalFieldStore$1.initialInput.value;
598
609
  if (!config?.keepInput) internalFieldStore$1.input.value = internalFieldStore$1.initialInput.value;
599
610
  if (internalFieldStore$1.kind === "array") {
@@ -640,6 +651,7 @@ function swap(form, config) {
640
651
  internalArrayStore.items.value = newItems;
641
652
  swapItemState(internalArrayStore.children[config.at], internalArrayStore.children[config.and]);
642
653
  internalArrayStore.isTouched.value = true;
654
+ internalArrayStore.isEdited.value = true;
643
655
  internalArrayStore.isDirty.value = internalArrayStore.startItems.value.join() !== newItems.join();
644
656
  validateIfRequired(internalFormStore, internalArrayStore, "input");
645
657
  });
@@ -656,6 +668,9 @@ function createForm(config) {
656
668
  const getIsTouched = createMemo(
657
669
  () => getFieldBool(internalFormStore, "isTouched")
658
670
  );
671
+ const getIsEdited = createMemo(
672
+ () => getFieldBool(internalFormStore, "isEdited")
673
+ );
659
674
  const getIsDirty = createMemo(
660
675
  () => getFieldBool(internalFormStore, "isDirty")
661
676
  );
@@ -676,6 +691,9 @@ function createForm(config) {
676
691
  get isTouched() {
677
692
  return getIsTouched();
678
693
  },
694
+ get isEdited() {
695
+ return getIsEdited();
696
+ },
679
697
  get isDirty() {
680
698
  return getIsDirty();
681
699
  },
@@ -712,6 +730,9 @@ function useField(form, config) {
712
730
  const getIsTouched = createMemo(
713
731
  () => getFieldBool(getInternalFieldStore(), "isTouched")
714
732
  );
733
+ const getIsEdited = createMemo(
734
+ () => getFieldBool(getInternalFieldStore(), "isEdited")
735
+ );
715
736
  const getIsDirty = createMemo(
716
737
  () => getFieldBool(getInternalFieldStore(), "isDirty")
717
738
  );
@@ -731,6 +752,9 @@ function useField(form, config) {
731
752
  get isTouched() {
732
753
  return getIsTouched();
733
754
  },
755
+ get isEdited() {
756
+ return getIsEdited();
757
+ },
734
758
  get isDirty() {
735
759
  return getIsDirty();
736
760
  },
@@ -809,6 +833,9 @@ function useFieldArray(form, config) {
809
833
  const getIsTouched = createMemo(
810
834
  () => getFieldBool(getInternalFieldStore(), "isTouched")
811
835
  );
836
+ const getIsEdited = createMemo(
837
+ () => getFieldBool(getInternalFieldStore(), "isEdited")
838
+ );
812
839
  const getIsDirty = createMemo(
813
840
  () => getFieldBool(getInternalFieldStore(), "isDirty")
814
841
  );
@@ -828,6 +855,9 @@ function useFieldArray(form, config) {
828
855
  get isTouched() {
829
856
  return getIsTouched();
830
857
  },
858
+ get isEdited() {
859
+ return getIsEdited();
860
+ },
831
861
  get isDirty() {
832
862
  return getIsDirty();
833
863
  },
@@ -869,4 +899,4 @@ function Form(props) {
869
899
  })();
870
900
  }
871
901
 
872
- export { Field, FieldArray, Form, createForm, focus, getAllErrors, getDirtyInput, getDirtyPaths, getErrors, getInput, handleSubmit, insert, move, pickDirty, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, validate };
902
+ export { Field, FieldArray, Form, createForm, focus, getDeepErrorEntries, getDeepErrors, getDirtyInput, getDirtyPaths, getErrors, getInput, handleSubmit, insert, isDirty, isEdited, isTouched, isValid, move, pickDirty, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, validate };