@conform-to/dom 1.17.0 → 1.18.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/dist/formdata.mjs CHANGED
@@ -35,12 +35,12 @@ function getFormData(form, submitter) {
35
35
  *
36
36
  * @example
37
37
  * ```js
38
- * getPathSegments("object.key"); // → ['object', 'key']
39
- * getPathSegments("array[0].content"); // → ['array', 0, 'content']
40
- * getPathSegments("todos[]"); // → ['todos', '']
38
+ * parsePath("object.key"); // → ['object', 'key']
39
+ * parsePath("array[0].content"); // → ['array', 0, 'content']
40
+ * parsePath("todos[]"); // → ['todos', '']
41
41
  * ```
42
42
  */
43
- function getPathSegments(path) {
43
+ function parsePath(path) {
44
44
  if (!path) return [];
45
45
  var tokenRegex = /([^.[\]]+)|\[(\d*)\]/g;
46
46
  var segments = [];
@@ -81,13 +81,13 @@ function getPathSegments(path) {
81
81
  *
82
82
  * @example
83
83
  * ```js
84
- * formatPathSegments(['object', 'key']); // → "object.key"
85
- * formatPathSegments(['array', 0, 'content']); // → "array[0].content"
86
- * formatPathSegments(['todos', '']); // → "todos[]"
84
+ * formatPath(['object', 'key']); // → "object.key"
85
+ * formatPath(['array', 0, 'content']); // → "array[0].content"
86
+ * formatPath(['todos', '']); // → "todos[]"
87
87
  * ```
88
88
  */
89
- function formatPathSegments(segments) {
90
- return segments.reduce((path, segment) => appendPathSegment(path, segment), '');
89
+ function formatPath(segments) {
90
+ return segments.reduce((path, segment) => appendPath(path, segment), '');
91
91
  }
92
92
 
93
93
  /**
@@ -98,7 +98,7 @@ function formatPathSegments(segments) {
98
98
  * - segment = `number` ⇒ bracket notation "[n]"
99
99
  * - segment = `string` ⇒ dot-notation ".prop"
100
100
  */
101
- function appendPathSegment(path, segment) {
101
+ function appendPath(path, segment) {
102
102
  // 1) nothing to append
103
103
  if (typeof segment === 'undefined') {
104
104
  return path !== null && path !== void 0 ? path : '';
@@ -124,23 +124,23 @@ function appendPathSegment(path, segment) {
124
124
  *
125
125
  * @example
126
126
  * ```js
127
- * isPrefix("foo.bar.baz", "foo.bar") // → true
128
- * isPrefix("foo.bar[3].baz", "foo.bar[3]") // → true
129
- * isPrefix("foo.bar[3].baz", "foo.bar") // → true
130
- * isPrefix("foo.bar[3].baz", "foo.baz") // → false
131
- * isPrefix("foo", "foo.bar") // → false
127
+ * isPathPrefix("foo.bar.baz", "foo.bar") // → true
128
+ * isPathPrefix("foo.bar[3].baz", "foo.bar[3]") // → true
129
+ * isPathPrefix("foo.bar[3].baz", "foo.bar") // → true
130
+ * isPathPrefix("foo.bar[3].baz", "foo.baz") // → false
131
+ * isPathPrefix("foo", "foo.bar") // → false
132
132
  * ```
133
133
  */
134
- function isPrefix(name, prefix) {
135
- return getRelativePath(name, getPathSegments(prefix)) !== null;
134
+ function isPathPrefix(name, prefix) {
135
+ return getRelativePath(name, parsePath(prefix)) !== null;
136
136
  }
137
137
 
138
138
  /**
139
- * Return the segments of `fullPathStr` that come after the `baseSegments` prefix.
139
+ * Return the segments of `fullPath` that come after the `basePath` prefix.
140
140
  *
141
- * @param fullPathStr Full path as a dot/bracket string
142
- * @param basePath Base path, already parsed into segments
143
- * @returns The “tail” segments, or `null` if `fullPathStr` isn’t nested under `baseSegments`
141
+ * @param fullPath Full path as a dot/bracket string or array of segments
142
+ * @param basePath Base path as a dot/bracket string or array of segments
143
+ * @returns The “tail” segments, or `null` if `fullPath` isn’t nested under `basePath`
144
144
  *
145
145
  * @example
146
146
  * ```js
@@ -149,12 +149,13 @@ function isPrefix(name, prefix) {
149
149
  * getRelativePath("foo", ["foo","bar"]) // → null
150
150
  * ```
151
151
  */
152
- function getRelativePath(name, basePath) {
153
- var fullPath = getPathSegments(name);
152
+ function getRelativePath(fullPath, basePath) {
153
+ var fullPathSegments = typeof fullPath === 'string' ? parsePath(fullPath) : fullPath;
154
+ var basePathSegments = typeof basePath === 'string' ? parsePath(basePath) : basePath;
154
155
 
155
156
  // if full is at least as long *and* starts with the base…
156
- if (fullPath.length >= basePath.length && basePath.every((segment, i) => segment === fullPath[i])) {
157
- return fullPath.slice(basePath.length);
157
+ if (fullPathSegments.length >= basePathSegments.length && basePathSegments.every((segment, i) => segment === fullPathSegments[i])) {
158
+ return fullPathSegments.slice(basePathSegments.length);
158
159
  }
159
160
  return null;
160
161
  }
@@ -162,11 +163,11 @@ function getRelativePath(name, basePath) {
162
163
  /**
163
164
  * Assign a value to a target object by following the path segments.
164
165
  */
165
- function setValueAtPath(target, pathOrSegments, valueOrFn) {
166
+ function setPathValue(target, pathOrSegments, valueOrFn) {
166
167
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
167
168
  try {
168
169
  // 1) normalize + validate path
169
- var segments = typeof pathOrSegments === 'string' ? getPathSegments(pathOrSegments) : pathOrSegments;
170
+ var segments = typeof pathOrSegments === 'string' ? parsePath(pathOrSegments) : pathOrSegments;
170
171
  if (segments.length === 0) {
171
172
  throw new Error('Cannot set value at the object root');
172
173
  }
@@ -218,9 +219,9 @@ function setValueAtPath(target, pathOrSegments, valueOrFn) {
218
219
  /**
219
220
  * Retrive the value from a target object by following the path segments.
220
221
  */
221
- function getValueAtPath(target, pathOrSegments) {
222
+ function getPathValue(target, pathOrSegments) {
222
223
  var pointer = target;
223
- var segments = typeof pathOrSegments === 'string' ? getPathSegments(pathOrSegments) : pathOrSegments;
224
+ var segments = typeof pathOrSegments === 'string' ? parsePath(pathOrSegments) : pathOrSegments;
224
225
  for (var segment of segments) {
225
226
  if (segment === '') {
226
227
  throw new Error("Cannot access empty segment \"[]\" in \"".concat(pathOrSegments, "\""));
@@ -298,7 +299,7 @@ function parseSubmission(formData, options) {
298
299
  if (_name !== intentName && !(options !== null && options !== void 0 && (_options$skipEntry = options.skipEntry) !== null && _options$skipEntry !== void 0 && _options$skipEntry.call(options, _name))) {
299
300
  var _options$stripEmptyVa;
300
301
  var _value = formData.getAll(_name);
301
- var segments = getPathSegments(_name);
302
+ var segments = parsePath(_name);
302
303
 
303
304
  // If the name ends with [], remove the empty segment and keep the full array
304
305
  // Otherwise, unwrap single values
@@ -307,9 +308,7 @@ function parseSubmission(formData, options) {
307
308
  } else {
308
309
  _value = _value.length > 1 ? _value : _value[0];
309
310
  }
310
-
311
- // Check if the value is empty and should be skipped (defaults to true)
312
- var stripEmptyValues = (_options$stripEmptyVa = options === null || options === void 0 ? void 0 : options.stripEmptyValues) !== null && _options$stripEmptyVa !== void 0 ? _options$stripEmptyVa : true;
311
+ var stripEmptyValues = (_options$stripEmptyVa = options === null || options === void 0 ? void 0 : options.stripEmptyValues) !== null && _options$stripEmptyVa !== void 0 ? _options$stripEmptyVa : false;
313
312
  if (stripEmptyValues) {
314
313
  // For arrays, filter out individual empty items
315
314
  if (Array.isArray(_value)) {
@@ -319,7 +318,7 @@ function parseSubmission(formData, options) {
319
318
  _value = undefined;
320
319
  }
321
320
  }
322
- setValueAtPath(submission.payload, segments, _value, {
321
+ setPathValue(submission.payload, segments, _value, {
323
322
  silent: true // Avoid errors if the path is invalid
324
323
  });
325
324
  submission.fields.push(_name);
@@ -395,10 +394,10 @@ function report(submission) {
395
394
  var targetValue = typeof options.value === 'undefined' || submission.payload === options.value && !options.reset ? undefined : options.value && !options.keepFiles ? stripFiles(options.value) : (_options$value = options.value) !== null && _options$value !== void 0 ? _options$value : {};
396
395
  if (options.hideFields) {
397
396
  for (var _name3 of options.hideFields) {
398
- var path = getPathSegments(_name3);
399
- setValueAtPath(submission.payload, path, undefined);
397
+ var path = parsePath(_name3);
398
+ setPathValue(submission.payload, path, undefined);
400
399
  if (targetValue) {
401
- setValueAtPath(targetValue, path, undefined);
400
+ setPathValue(targetValue, path, undefined);
402
401
  }
403
402
  }
404
403
  }
@@ -448,58 +447,8 @@ formData, options) {
448
447
  skipEntry: options === null || options === void 0 ? void 0 : options.skipEntry
449
448
  }).payload : formData;
450
449
  var defaultValue = options === null || options === void 0 ? void 0 : options.defaultValue;
451
- var serializeData = value => {
452
- if (options !== null && options !== void 0 && options.serialize) {
453
- return options.serialize(value, serialize);
454
- }
455
- return serialize(value);
456
- };
457
- function normalize(data) {
458
- var value = serializeData(data);
459
- if (typeof value === 'undefined') {
460
- value = data;
461
- }
462
-
463
- // Removes empty strings, so that both empty string, empty file, null and undefined are treated as the same
464
- if (value === '' || value === null) {
465
- return undefined;
466
- }
467
- if (isGlobalInstance(value, 'File')) {
468
- // Remove empty File as well, which happens if no File was selected
469
- if (value.name === '' && value.size === 0) {
470
- return undefined;
471
- }
472
-
473
- // If the value is a File, no need to serialize it
474
- return value;
475
- }
476
- if (Array.isArray(value)) {
477
- if (value.length === 0) {
478
- return undefined;
479
- }
480
- var array = value.map(normalize);
481
- if (array.length === 1 && (typeof array[0] === 'string' || array[0] === undefined)) {
482
- return array[0];
483
- }
484
- return array;
485
- }
486
- if (isPlainObject(value)) {
487
- var entries = Object.entries(value).reduce((list, _ref) => {
488
- var [key, value] = _ref;
489
- var normalizedValue = normalize(value);
490
- if (typeof normalizedValue !== 'undefined') {
491
- list.push([key, normalizedValue]);
492
- }
493
- return list;
494
- }, []);
495
- if (entries.length === 0) {
496
- return undefined;
497
- }
498
- return Object.fromEntries(entries);
499
- }
500
- return value;
501
- }
502
- return !deepEqual(normalize(formValue), normalize(defaultValue));
450
+ var serializeValue = options !== null && options !== void 0 && options.serialize ? value => options.serialize(value, serialize) : serialize;
451
+ return !deepEqual(normalize(formValue, serializeValue), normalize(defaultValue, serializeValue));
503
452
  }
504
453
 
505
454
  /**
@@ -511,7 +460,7 @@ formData, options) {
511
460
  * - null -> '' (empty string)
512
461
  * - boolean -> 'on' | '' (checked semantics)
513
462
  * - number | bigint -> value.toString()
514
- * - Date -> value.toISOString()
463
+ * - Date -> value.toISOString() without trailing `Z`
515
464
  * - File -> File
516
465
  * - FileList -> File[]
517
466
  * - Array -> string[] or File[] if all items serialize to the same kind; otherwise undefined
@@ -529,7 +478,7 @@ function serialize(value) {
529
478
  return value.toString();
530
479
  }
531
480
  if (value instanceof Date) {
532
- return value.toISOString();
481
+ return value.toISOString().slice(0, -1);
533
482
  }
534
483
  if (isGlobalInstance(value, 'File')) {
535
484
  return value;
@@ -572,6 +521,59 @@ function serialize(value) {
572
521
  return serializePrimitive(value);
573
522
  }
574
523
 
524
+ /**
525
+ * Recursively serializes a value using the provided serialize function,
526
+ * collapsing empty leaves (`null`, `''`, empty files) to `undefined`
527
+ * and removing empty containers (objects with no remaining keys, empty arrays).
528
+ *
529
+ * When serialize returns `undefined` for a value (i.e. it can't be represented
530
+ * as form data), the raw value is kept and recursed into if it's an object or array.
531
+ *
532
+ * Single-element arrays where the element is a string or undefined are unwrapped
533
+ * to handle the case where a multi-value field (e.g. checkboxes) has only one value.
534
+ */
535
+ function normalize(value) {
536
+ var serializeValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : serialize;
537
+ var data = serializeValue(value);
538
+ if (typeof data === 'undefined') {
539
+ data = value;
540
+ }
541
+ if (data === '' || data === null) {
542
+ return undefined;
543
+ }
544
+ if (isGlobalInstance(data, 'File')) {
545
+ if (data.name === '' && data.size === 0) {
546
+ return undefined;
547
+ }
548
+ return data;
549
+ }
550
+ if (Array.isArray(data)) {
551
+ if (data.length === 0) {
552
+ return undefined;
553
+ }
554
+ var array = data.map(item => normalize(item, serializeValue));
555
+ if (array.length === 1 && (typeof array[0] === 'string' || array[0] === undefined)) {
556
+ return array[0];
557
+ }
558
+ return array;
559
+ }
560
+ if (isPlainObject(data)) {
561
+ var entries = Object.entries(data).reduce((list, _ref) => {
562
+ var [key, value] = _ref;
563
+ var normalizedValue = normalize(value, serializeValue);
564
+ if (typeof normalizedValue !== 'undefined') {
565
+ list.push([key, normalizedValue]);
566
+ }
567
+ return list;
568
+ }, []);
569
+ if (entries.length === 0) {
570
+ return undefined;
571
+ }
572
+ return Object.fromEntries(entries);
573
+ }
574
+ return data;
575
+ }
576
+
575
577
  /**
576
578
  * Retrieve a field value from FormData with optional type guards.
577
579
  *
@@ -605,11 +607,9 @@ function getFieldValue(formData, name, options) {
605
607
  // Get value based on array option
606
608
  value = array ? formData.getAll(name) : formData.get(name);
607
609
  } else {
608
- // Parse formData and use getValueAtPath
609
- var _submission = parseSubmission(formData, {
610
- stripEmptyValues: false
611
- });
612
- value = getValueAtPath(_submission.payload, name);
610
+ // Parse formData and use getPathValue
611
+ var _submission = parseSubmission(formData);
612
+ value = getPathValue(_submission.payload, name);
613
613
  }
614
614
 
615
615
  // If optional and value is undefined, skip validation and return early
@@ -643,4 +643,4 @@ function getFieldValue(formData, name, options) {
643
643
  return value;
644
644
  }
645
645
 
646
- export { DEFAULT_INTENT_NAME, appendPathSegment, formatPathSegments, getFieldValue, getFormData, getPathSegments, getRelativePath, getValueAtPath, isDirty, isPrefix, parseSubmission, report, serialize, setValueAtPath };
646
+ export { DEFAULT_INTENT_NAME, appendPath, formatPath, getFieldValue, getFormData, getPathValue, getRelativePath, isDirty, isPathPrefix, normalize, parsePath, parseSubmission, report, serialize, setPathValue };
@@ -1,6 +1,6 @@
1
1
  export type { Serialize, FieldName, FormValue, FormError, Submission, SubmissionResult, ValidationAttributes, } from '../types';
2
- export { DEFAULT_INTENT_NAME, getFormData, isDirty, parseSubmission, getPathSegments, formatPathSegments, appendPathSegment, getRelativePath, getValueAtPath, setValueAtPath, report, serialize, getFieldValue, } from '../formdata';
2
+ export { DEFAULT_INTENT_NAME, getFormData, isDirty, normalize, parseSubmission, parsePath, formatPath, appendPath, getRelativePath, getPathValue, setPathValue, report, serialize, getFieldValue, } from '../formdata';
3
3
  export { isPlainObject, deepEqual } from '../util';
4
- export { isFieldElement, isGlobalInstance, updateField, createFileList, createSubmitEvent, createGlobalFormsObserver, focus, change, blur, getFormAction, getFormEncType, getFormMethod, requestSubmit, requestIntent, } from '../dom';
4
+ export { isFieldElement, isGlobalInstance, updateField, createFileList, createGlobalFormsObserver, dispatchInternalUpdateEvent, focus, change, blur, getFormAction, getFormEncType, getFormMethod, requestSubmit, requestIntent, } from '../dom';
5
5
  export { formatIssues } from '../standard-schema';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -10,25 +10,26 @@ var standardSchema = require('../standard-schema.js');
10
10
 
11
11
 
12
12
  exports.DEFAULT_INTENT_NAME = formdata.DEFAULT_INTENT_NAME;
13
- exports.appendPathSegment = formdata.appendPathSegment;
14
- exports.formatPathSegments = formdata.formatPathSegments;
13
+ exports.appendPath = formdata.appendPath;
14
+ exports.formatPath = formdata.formatPath;
15
15
  exports.getFieldValue = formdata.getFieldValue;
16
16
  exports.getFormData = formdata.getFormData;
17
- exports.getPathSegments = formdata.getPathSegments;
17
+ exports.getPathValue = formdata.getPathValue;
18
18
  exports.getRelativePath = formdata.getRelativePath;
19
- exports.getValueAtPath = formdata.getValueAtPath;
20
19
  exports.isDirty = formdata.isDirty;
20
+ exports.normalize = formdata.normalize;
21
+ exports.parsePath = formdata.parsePath;
21
22
  exports.parseSubmission = formdata.parseSubmission;
22
23
  exports.report = formdata.report;
23
24
  exports.serialize = formdata.serialize;
24
- exports.setValueAtPath = formdata.setValueAtPath;
25
+ exports.setPathValue = formdata.setPathValue;
25
26
  exports.deepEqual = util.deepEqual;
26
27
  exports.isPlainObject = util.isPlainObject;
27
28
  exports.blur = dom.blur;
28
29
  exports.change = dom.change;
29
30
  exports.createFileList = dom.createFileList;
30
31
  exports.createGlobalFormsObserver = dom.createGlobalFormsObserver;
31
- exports.createSubmitEvent = dom.createSubmitEvent;
32
+ exports.dispatchInternalUpdateEvent = dom.dispatchInternalUpdateEvent;
32
33
  exports.focus = dom.focus;
33
34
  exports.getFormAction = dom.getFormAction;
34
35
  exports.getFormEncType = dom.getFormEncType;
@@ -1,4 +1,4 @@
1
- export { DEFAULT_INTENT_NAME, appendPathSegment, formatPathSegments, getFieldValue, getFormData, getPathSegments, getRelativePath, getValueAtPath, isDirty, parseSubmission, report, serialize, setValueAtPath } from '../formdata.mjs';
1
+ export { DEFAULT_INTENT_NAME, appendPath, formatPath, getFieldValue, getFormData, getPathValue, getRelativePath, isDirty, normalize, parsePath, parseSubmission, report, serialize, setPathValue } from '../formdata.mjs';
2
2
  export { deepEqual, isPlainObject } from '../util.mjs';
3
- export { blur, change, createFileList, createGlobalFormsObserver, createSubmitEvent, focus, getFormAction, getFormEncType, getFormMethod, isFieldElement, isGlobalInstance, requestIntent, requestSubmit, updateField } from '../dom.mjs';
3
+ export { blur, change, createFileList, createGlobalFormsObserver, dispatchInternalUpdateEvent, focus, getFormAction, getFormEncType, getFormMethod, isFieldElement, isGlobalInstance, requestIntent, requestSubmit, updateField } from '../dom.mjs';
4
4
  export { formatIssues } from '../standard-schema.mjs';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { type Combine, type Constraint, type ControlButtonProps, type FormId, type FieldName, type DefaultValue, type FormValue, type FormOptions, type FormState, type FormContext, type SubscriptionSubject, type SubscriptionScope, createFormContext as unstable_createFormContext, } from './form';
2
2
  export { type FieldElement, isFieldElement, isGlobalInstance, updateField as unstable_updateField, createFileList, } from './dom';
3
3
  export { type Submission, type SubmissionResult, type Intent, INTENT, STATE, serializeIntent, parse, } from './submission';
4
- export { getFormData, getPathSegments as getPaths, formatPathSegments as formatPaths, isPrefix, } from './formdata';
4
+ export { getFormData, parsePath as getPaths, formatPath as formatPaths, isPathPrefix as isPrefix, getRelativePath, } from './formdata';
5
5
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -18,7 +18,8 @@ exports.INTENT = submission.INTENT;
18
18
  exports.STATE = submission.STATE;
19
19
  exports.parse = submission.parse;
20
20
  exports.serializeIntent = submission.serializeIntent;
21
- exports.formatPaths = formdata.formatPathSegments;
21
+ exports.formatPaths = formdata.formatPath;
22
22
  exports.getFormData = formdata.getFormData;
23
- exports.getPaths = formdata.getPathSegments;
24
- exports.isPrefix = formdata.isPrefix;
23
+ exports.getPaths = formdata.parsePath;
24
+ exports.getRelativePath = formdata.getRelativePath;
25
+ exports.isPrefix = formdata.isPathPrefix;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  export { createFormContext as unstable_createFormContext } from './form.mjs';
2
2
  export { createFileList, isFieldElement, isGlobalInstance, updateField as unstable_updateField } from './dom.mjs';
3
3
  export { INTENT, STATE, parse, serializeIntent } from './submission.mjs';
4
- export { formatPathSegments as formatPaths, getFormData, getPathSegments as getPaths, isPrefix } from './formdata.mjs';
4
+ export { formatPath as formatPaths, getFormData, parsePath as getPaths, getRelativePath, isPathPrefix as isPrefix } from './formdata.mjs';
@@ -26,7 +26,7 @@ function formatIssues(issues) {
26
26
  }
27
27
  return path;
28
28
  })) !== null && _issue$path$map !== void 0 ? _issue$path$map : [];
29
- var name = formdata.formatPathSegments(segments !== null && segments !== void 0 ? segments : []);
29
+ var name = formdata.formatPath(segments !== null && segments !== void 0 ? segments : []);
30
30
  if (!name) {
31
31
  error.formErrors.push(issue.message);
32
32
  } else {
@@ -1,4 +1,4 @@
1
- import { formatPathSegments } from './formdata.mjs';
1
+ import { formatPath } from './formdata.mjs';
2
2
  import { isPlainObject } from './util.mjs';
3
3
 
4
4
  /**
@@ -22,7 +22,7 @@ function formatIssues(issues) {
22
22
  }
23
23
  return path;
24
24
  })) !== null && _issue$path$map !== void 0 ? _issue$path$map : [];
25
- var name = formatPathSegments(segments !== null && segments !== void 0 ? segments : []);
25
+ var name = formatPath(segments !== null && segments !== void 0 ? segments : []);
26
26
  if (!name) {
27
27
  error.formErrors.push(issue.message);
28
28
  } else {
@@ -33,7 +33,7 @@ function getSubmissionContext(body) {
33
33
  return 1; // continue
34
34
  }
35
35
  context.fields.add(name);
36
- formdata.setValueAtPath(context.payload, name, prev => {
36
+ formdata.setPathValue(context.payload, name, prev => {
37
37
  if (!prev) {
38
38
  return next;
39
39
  } else if (Array.isArray(prev)) {
@@ -57,11 +57,11 @@ function parse(payload, options) {
57
57
  switch (intent.type) {
58
58
  case 'update':
59
59
  {
60
- var name = formdata.appendPathSegment(intent.payload.name, intent.payload.index);
60
+ var name = formdata.appendPath(intent.payload.name, intent.payload.index);
61
61
  var _value = intent.payload.value;
62
62
  if (typeof intent.payload.value !== 'undefined') {
63
63
  if (name) {
64
- formdata.setValueAtPath(context.payload, name, () => _value);
64
+ formdata.setPathValue(context.payload, name, () => _value);
65
65
  } else {
66
66
  context.payload = _value;
67
67
  }
@@ -70,9 +70,9 @@ function parse(payload, options) {
70
70
  }
71
71
  case 'reset':
72
72
  {
73
- var _name = formdata.appendPathSegment(intent.payload.name, intent.payload.index);
73
+ var _name = formdata.appendPath(intent.payload.name, intent.payload.index);
74
74
  if (_name) {
75
- formdata.setValueAtPath(context.payload, _name, () => undefined);
75
+ formdata.setPathValue(context.payload, _name, () => undefined);
76
76
  } else {
77
77
  context.payload = {};
78
78
  }
@@ -127,9 +127,9 @@ function replySubmission(context) {
127
127
  }
128
128
  if ('hideFields' in options && options.hideFields) {
129
129
  for (var name of options.hideFields) {
130
- var _value2 = formdata.getValueAtPath(context.payload, name);
130
+ var _value2 = formdata.getPathValue(context.payload, name);
131
131
  if (typeof _value2 !== 'undefined') {
132
- formdata.setValueAtPath(context.payload, name, () => undefined);
132
+ formdata.setPathValue(context.payload, name, () => undefined);
133
133
  }
134
134
  }
135
135
  }
@@ -201,7 +201,7 @@ function updateList(list, intent) {
201
201
  }
202
202
  }
203
203
  function setListValue(data, intent) {
204
- formdata.setValueAtPath(data, intent.payload.name, value => {
204
+ formdata.setPathValue(data, intent.payload.name, value => {
205
205
  var list = value !== null && value !== void 0 ? value : [];
206
206
  updateList(list, intent);
207
207
  return list;
@@ -218,8 +218,8 @@ function setState(state, name, valueFn) {
218
218
  var target = {};
219
219
  var _loop2 = function _loop2() {
220
220
  var value = state[_key];
221
- if (formdata.isPrefix(_key, name) && _key !== name) {
222
- formdata.setValueAtPath(target, _key, currentValue => {
221
+ if (formdata.isPathPrefix(_key, name) && _key !== name) {
222
+ formdata.setPathValue(target, _key, currentValue => {
223
223
  if (typeof currentValue === 'undefined') {
224
224
  return value;
225
225
  }
@@ -239,7 +239,7 @@ function setState(state, name, valueFn) {
239
239
  for (var _key of keys) {
240
240
  _loop2();
241
241
  }
242
- var result = valueFn(formdata.getValueAtPath(target, name));
242
+ var result = valueFn(formdata.getPathValue(target, name));
243
243
  Object.assign(state, flatten(result, {
244
244
  resolve(data) {
245
245
  if (util.isPlainObject(data) || Array.isArray(data)) {
@@ -1,6 +1,6 @@
1
1
  import { objectSpread2 as _objectSpread2 } from './_virtual/_rollupPluginBabelHelpers.mjs';
2
2
  import { isGlobalInstance } from './dom.mjs';
3
- import { appendPathSegment, setValueAtPath, getValueAtPath, isPrefix } from './formdata.mjs';
3
+ import { appendPath, setPathValue, getPathValue, isPathPrefix } from './formdata.mjs';
4
4
  import { isPlainObject, invariant } from './util.mjs';
5
5
 
6
6
  /**
@@ -29,7 +29,7 @@ function getSubmissionContext(body) {
29
29
  return 1; // continue
30
30
  }
31
31
  context.fields.add(name);
32
- setValueAtPath(context.payload, name, prev => {
32
+ setPathValue(context.payload, name, prev => {
33
33
  if (!prev) {
34
34
  return next;
35
35
  } else if (Array.isArray(prev)) {
@@ -53,11 +53,11 @@ function parse(payload, options) {
53
53
  switch (intent.type) {
54
54
  case 'update':
55
55
  {
56
- var name = appendPathSegment(intent.payload.name, intent.payload.index);
56
+ var name = appendPath(intent.payload.name, intent.payload.index);
57
57
  var _value = intent.payload.value;
58
58
  if (typeof intent.payload.value !== 'undefined') {
59
59
  if (name) {
60
- setValueAtPath(context.payload, name, () => _value);
60
+ setPathValue(context.payload, name, () => _value);
61
61
  } else {
62
62
  context.payload = _value;
63
63
  }
@@ -66,9 +66,9 @@ function parse(payload, options) {
66
66
  }
67
67
  case 'reset':
68
68
  {
69
- var _name = appendPathSegment(intent.payload.name, intent.payload.index);
69
+ var _name = appendPath(intent.payload.name, intent.payload.index);
70
70
  if (_name) {
71
- setValueAtPath(context.payload, _name, () => undefined);
71
+ setPathValue(context.payload, _name, () => undefined);
72
72
  } else {
73
73
  context.payload = {};
74
74
  }
@@ -123,9 +123,9 @@ function replySubmission(context) {
123
123
  }
124
124
  if ('hideFields' in options && options.hideFields) {
125
125
  for (var name of options.hideFields) {
126
- var _value2 = getValueAtPath(context.payload, name);
126
+ var _value2 = getPathValue(context.payload, name);
127
127
  if (typeof _value2 !== 'undefined') {
128
- setValueAtPath(context.payload, name, () => undefined);
128
+ setPathValue(context.payload, name, () => undefined);
129
129
  }
130
130
  }
131
131
  }
@@ -197,7 +197,7 @@ function updateList(list, intent) {
197
197
  }
198
198
  }
199
199
  function setListValue(data, intent) {
200
- setValueAtPath(data, intent.payload.name, value => {
200
+ setPathValue(data, intent.payload.name, value => {
201
201
  var list = value !== null && value !== void 0 ? value : [];
202
202
  updateList(list, intent);
203
203
  return list;
@@ -214,8 +214,8 @@ function setState(state, name, valueFn) {
214
214
  var target = {};
215
215
  var _loop2 = function _loop2() {
216
216
  var value = state[_key];
217
- if (isPrefix(_key, name) && _key !== name) {
218
- setValueAtPath(target, _key, currentValue => {
217
+ if (isPathPrefix(_key, name) && _key !== name) {
218
+ setPathValue(target, _key, currentValue => {
219
219
  if (typeof currentValue === 'undefined') {
220
220
  return value;
221
221
  }
@@ -235,7 +235,7 @@ function setState(state, name, valueFn) {
235
235
  for (var _key of keys) {
236
236
  _loop2();
237
237
  }
238
- var result = valueFn(getValueAtPath(target, name));
238
+ var result = valueFn(getPathValue(target, name));
239
239
  Object.assign(state, flatten(result, {
240
240
  resolve(data) {
241
241
  if (isPlainObject(data) || Array.isArray(data)) {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A set of opinionated helpers built on top of the Constraint Validation API",
4
4
  "homepage": "https://conform.guide",
5
5
  "license": "MIT",
6
- "version": "1.17.0",
6
+ "version": "1.18.0",
7
7
  "main": "./dist/index.js",
8
8
  "module": "./dist/index.mjs",
9
9
  "types": "./dist/index.d.ts",