@conform-to/dom 1.0.0-pre.6 → 1.0.0-rc.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/submission.js CHANGED
@@ -9,20 +9,20 @@ var util = require('./util.js');
9
9
  /**
10
10
  * The name to be used when submitting a form control
11
11
  */
12
- var CONTROL = '__control__';
12
+ var INTENT = '__intent__';
13
13
 
14
14
  /**
15
15
  * The name to be used when submitting a state
16
16
  */
17
17
  var STATE = '__state__';
18
18
  function getSubmissionContext(body) {
19
- var control = body.get(CONTROL);
19
+ var intent = body.get(INTENT);
20
20
  var state = body.get(STATE);
21
21
  var payload = {};
22
22
  var fields = [];
23
- util.invariant((typeof control === 'string' || control === null) && (typeof state === 'string' || state === null), "The input name \"".concat(CONTROL, "\" and \"").concat(STATE, "\" are reserved by Conform. Please use another name for your input."));
23
+ util.invariant((typeof intent === 'string' || intent === null) && (typeof state === 'string' || state === null), "The input name \"".concat(INTENT, "\" and \"").concat(STATE, "\" are reserved by Conform. Please use another name for your input."));
24
24
  var _loop = function _loop(next) {
25
- if (name === CONTROL || name === STATE) {
25
+ if (name === INTENT || name === STATE) {
26
26
  return 1; // continue
27
27
  }
28
28
  fields.push(name);
@@ -41,7 +41,7 @@ function getSubmissionContext(body) {
41
41
  }
42
42
  return {
43
43
  payload,
44
- control: getControl(control),
44
+ intent: getIntent(intent),
45
45
  state: state ? JSON.parse(state) : {
46
46
  validated: {}
47
47
  },
@@ -50,68 +50,64 @@ function getSubmissionContext(body) {
50
50
  }
51
51
  function parse(payload, options) {
52
52
  var context = getSubmissionContext(payload);
53
- var control = context.control;
54
- if (control) {
55
- switch (control.type) {
53
+ var intent = context.intent;
54
+ if (intent) {
55
+ switch (intent.type) {
56
56
  case 'validate':
57
- if (control.payload.name) {
58
- context.state.validated[control.payload.name] = true;
57
+ if (intent.payload.name) {
58
+ context.state.validated[intent.payload.name] = true;
59
59
  }
60
60
  break;
61
- case 'replace':
61
+ case 'update':
62
62
  {
63
63
  var {
64
64
  name,
65
65
  value: _value,
66
66
  validated
67
- } = control.payload;
68
- if (name) {
69
- formdata.setValue(context.payload, name, () => _value);
70
- } else {
71
- // @ts-expect-error FIXME - it must be an object if there is no name
72
- context.payload = _value;
67
+ } = intent.payload;
68
+ if (typeof _value !== 'undefined') {
69
+ if (name) {
70
+ formdata.setValue(context.payload, name, () => _value);
71
+ } else {
72
+ // @ts-expect-error FIXME - it must be an object if there is no name
73
+ context.payload = _value;
74
+ }
73
75
  }
74
- if (validated) {
75
- if (formdata.isPlainObject(_value) || Array.isArray(_value)) {
76
- // Clean up previous validated state
76
+ if (typeof validated !== 'undefined') {
77
+ // Clean up previous validated state
78
+ if (name) {
77
79
  setState(context.state.validated, name, () => undefined);
78
- Object.assign(context.state.validated, formdata.flatten(_value, {
79
- resolve() {
80
- return true;
81
- },
82
- prefix: name
83
- }));
80
+ } else {
81
+ context.state.validated = {};
84
82
  }
85
- context.state.validated[name] = true;
86
- } else {
87
- if (formdata.isPlainObject(_value) || Array.isArray(_value)) {
88
- setState(context.state.validated, name, () => undefined);
83
+ if (validated) {
84
+ if (formdata.isPlainObject(_value) || Array.isArray(_value)) {
85
+ Object.assign(context.state.validated, formdata.flatten(_value, {
86
+ resolve() {
87
+ return true;
88
+ },
89
+ prefix: name
90
+ }));
91
+ }
92
+ context.state.validated[name !== null && name !== void 0 ? name : ''] = true;
93
+ } else if (name) {
94
+ delete context.state.validated[name];
89
95
  }
90
- delete context.state.validated[name];
91
96
  }
92
97
  break;
93
98
  }
94
99
  case 'reset':
95
100
  {
96
101
  var {
97
- name: _name,
98
- value: _value2,
99
- validated: _validated
100
- } = control.payload;
101
- if (typeof _value2 === 'undefined' || _value2) {
102
- if (_name) {
103
- formdata.setValue(context.payload, _name, () => undefined);
104
- } else {
105
- context.payload = {};
106
- }
107
- }
108
- if (typeof _validated === 'undefined' || _validated) {
109
- if (_name) {
110
- setState(context.state.validated, _name, () => undefined);
111
- delete context.state.validated[_name];
112
- } else {
113
- context.state.validated = {};
114
- }
102
+ name: _name
103
+ } = intent.payload;
104
+ if (_name) {
105
+ formdata.setValue(context.payload, _name, () => undefined);
106
+ setState(context.state.validated, _name, () => undefined);
107
+ delete context.state.validated[_name];
108
+ } else {
109
+ context.payload = {};
110
+ context.state.validated = {};
115
111
  }
116
112
  break;
117
113
  }
@@ -119,17 +115,17 @@ function parse(payload, options) {
119
115
  case 'remove':
120
116
  case 'reorder':
121
117
  {
122
- setListValue(context.payload, control);
123
- setListState(context.state.validated, control);
124
- context.state.validated[control.payload.name] = true;
118
+ setListValue(context.payload, intent);
119
+ setListState(context.state.validated, intent);
120
+ context.state.validated[intent.payload.name] = true;
125
121
  break;
126
122
  }
127
123
  }
128
124
  }
129
- var result = options.resolve(context.payload, control);
125
+ var result = options.resolve(context.payload, intent);
130
126
  var mergeResolveResult = resolved => {
131
127
  var error = typeof resolved.error !== 'undefined' ? resolved.error : {};
132
- if (!control || control.type === 'validate' && !control.payload.name) {
128
+ if (!intent || intent.type === 'validate' && !intent.payload.name) {
133
129
  for (var _name2 of [...context.fields, ...Object.keys(error !== null && error !== void 0 ? error : {})]) {
134
130
  context.state.validated[_name2] = true;
135
131
  }
@@ -145,9 +141,9 @@ function parse(payload, options) {
145
141
  return mergeResolveResult(result);
146
142
  }
147
143
  function createSubmission(context) {
148
- if (context.control || !context.value || context.error) {
144
+ if (context.intent || !context.value || context.error) {
149
145
  return {
150
- status: !context.control ? 'error' : undefined,
146
+ status: !context.intent ? 'error' : undefined,
151
147
  payload: context.payload,
152
148
  error: typeof context.error !== 'undefined' ? context.error : {},
153
149
  reply(options) {
@@ -165,13 +161,13 @@ function createSubmission(context) {
165
161
  };
166
162
  }
167
163
  function replySubmission(context) {
168
- var _context$control, _context$error, _simplify;
164
+ var _context$intent, _context$error, _simplify;
169
165
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
170
- switch ((_context$control = context.control) === null || _context$control === void 0 ? void 0 : _context$control.type) {
166
+ switch ((_context$intent = context.intent) === null || _context$intent === void 0 ? void 0 : _context$intent.type) {
171
167
  case 'reset':
172
168
  {
173
- var _context$control$payl;
174
- var name = (_context$control$payl = context.control.payload.name) !== null && _context$control$payl !== void 0 ? _context$control$payl : '';
169
+ var _context$intent$paylo;
170
+ var name = (_context$intent$paylo = context.intent.payload.name) !== null && _context$intent$paylo !== void 0 ? _context$intent$paylo : '';
175
171
  if (name === '') {
176
172
  return {
177
173
  initialValue: null
@@ -186,8 +182,8 @@ function replySubmission(context) {
186
182
  }
187
183
  if ('hideFields' in options && options.hideFields) {
188
184
  for (var _name3 of options.hideFields) {
189
- var _value3 = formdata.getValue(context.payload, _name3);
190
- if (typeof _value3 !== 'undefined') {
185
+ var _value2 = formdata.getValue(context.payload, _name3);
186
+ if (typeof _value2 !== 'undefined') {
191
187
  formdata.setValue(context.payload, _name3, () => undefined);
192
188
  }
193
189
  }
@@ -204,47 +200,47 @@ function replySubmission(context) {
204
200
  }, options.fieldErrors)) : null;
205
201
  var error = formdata.simplify(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, submissionError), extraError));
206
202
  return {
207
- status: context.control ? undefined : error ? 'error' : 'success',
208
- control: context.control ? context.control : undefined,
203
+ status: context.intent ? undefined : error ? 'error' : 'success',
204
+ intent: context.intent ? context.intent : undefined,
209
205
  initialValue: (_simplify = formdata.simplify(context.payload)) !== null && _simplify !== void 0 ? _simplify : {},
210
206
  error,
211
207
  state: context.state
212
208
  };
213
209
  }
214
- function getControl(serializedControl) {
215
- if (!serializedControl) {
210
+ function getIntent(serializedIntent) {
211
+ if (!serializedIntent) {
216
212
  return null;
217
213
  }
218
- var control = JSON.parse(serializedControl);
214
+ var control = JSON.parse(serializedIntent);
219
215
  if (typeof control.type !== 'string' || typeof control.payload === 'undefined') {
220
- throw new Error('Unknown control');
216
+ throw new Error('Unknown form control intent');
221
217
  }
222
218
  return control;
223
219
  }
224
- function serializeControl(control) {
225
- return JSON.stringify(control);
220
+ function serializeIntent(intent) {
221
+ return JSON.stringify(intent);
226
222
  }
227
- function updateList(list, control) {
228
- var _control$payload$inde;
223
+ function updateList(list, intent) {
224
+ var _intent$payload$index;
229
225
  util.invariant(Array.isArray(list), "Failed to update list. The value is not an array.");
230
- switch (control.type) {
226
+ switch (intent.type) {
231
227
  case 'insert':
232
- list.splice((_control$payload$inde = control.payload.index) !== null && _control$payload$inde !== void 0 ? _control$payload$inde : list.length, 0, serialize(control.payload.defaultValue));
228
+ list.splice((_intent$payload$index = intent.payload.index) !== null && _intent$payload$index !== void 0 ? _intent$payload$index : list.length, 0, serialize(intent.payload.defaultValue));
233
229
  break;
234
230
  case 'remove':
235
- list.splice(control.payload.index, 1);
231
+ list.splice(intent.payload.index, 1);
236
232
  break;
237
233
  case 'reorder':
238
- list.splice(control.payload.to, 0, ...list.splice(control.payload.from, 1));
234
+ list.splice(intent.payload.to, 0, ...list.splice(intent.payload.from, 1));
239
235
  break;
240
236
  default:
241
- throw new Error('Unknown list control received');
237
+ throw new Error('Unknown list intent received');
242
238
  }
243
239
  }
244
- function setListValue(data, control) {
245
- formdata.setValue(data, control.payload.name, value => {
240
+ function setListValue(data, intent) {
241
+ formdata.setValue(data, intent.payload.name, value => {
246
242
  var list = value !== null && value !== void 0 ? value : [];
247
- updateList(list, control);
243
+ updateList(list, intent);
248
244
  return list;
249
245
  });
250
246
  }
@@ -292,20 +288,20 @@ function setState(state, name, valueFn) {
292
288
  prefix: name
293
289
  }));
294
290
  }
295
- function setListState(state, control, getDefaultValue) {
296
- setState(state, control.payload.name, value => {
291
+ function setListState(state, intent, getDefaultValue) {
292
+ setState(state, intent.payload.name, value => {
297
293
  var list = value !== null && value !== void 0 ? value : [];
298
- switch (control.type) {
294
+ switch (intent.type) {
299
295
  case 'insert':
300
296
  updateList(list, {
301
- type: control.type,
302
- payload: _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, control.payload), {}, {
297
+ type: intent.type,
298
+ payload: _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, intent.payload), {}, {
303
299
  defaultValue: getDefaultValue === null || getDefaultValue === void 0 ? void 0 : getDefaultValue()
304
300
  })
305
301
  });
306
302
  break;
307
303
  default:
308
- updateList(list, control);
304
+ updateList(list, intent);
309
305
  break;
310
306
  }
311
307
  return list;
@@ -339,28 +335,16 @@ function serialize(defaultValue) {
339
335
  return defaultValue !== null && defaultValue !== void 0 ? defaultValue : undefined;
340
336
  }
341
337
  }
342
- var control = new Proxy({}, {
343
- get(_, type) {
344
- return function () {
345
- var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
346
- return {
347
- type,
348
- payload
349
- };
350
- };
351
- }
352
- });
353
338
 
354
- exports.CONTROL = CONTROL;
339
+ exports.INTENT = INTENT;
355
340
  exports.STATE = STATE;
356
- exports.control = control;
357
341
  exports.createSubmission = createSubmission;
358
- exports.getControl = getControl;
342
+ exports.getIntent = getIntent;
359
343
  exports.getSubmissionContext = getSubmissionContext;
360
344
  exports.parse = parse;
361
345
  exports.replySubmission = replySubmission;
362
346
  exports.serialize = serialize;
363
- exports.serializeControl = serializeControl;
347
+ exports.serializeIntent = serializeIntent;
364
348
  exports.setListState = setListState;
365
349
  exports.setListValue = setListValue;
366
350
  exports.setState = setState;
package/submission.mjs CHANGED
@@ -5,20 +5,20 @@ import { invariant } from './util.mjs';
5
5
  /**
6
6
  * The name to be used when submitting a form control
7
7
  */
8
- var CONTROL = '__control__';
8
+ var INTENT = '__intent__';
9
9
 
10
10
  /**
11
11
  * The name to be used when submitting a state
12
12
  */
13
13
  var STATE = '__state__';
14
14
  function getSubmissionContext(body) {
15
- var control = body.get(CONTROL);
15
+ var intent = body.get(INTENT);
16
16
  var state = body.get(STATE);
17
17
  var payload = {};
18
18
  var fields = [];
19
- invariant((typeof control === 'string' || control === null) && (typeof state === 'string' || state === null), "The input name \"".concat(CONTROL, "\" and \"").concat(STATE, "\" are reserved by Conform. Please use another name for your input."));
19
+ invariant((typeof intent === 'string' || intent === null) && (typeof state === 'string' || state === null), "The input name \"".concat(INTENT, "\" and \"").concat(STATE, "\" are reserved by Conform. Please use another name for your input."));
20
20
  var _loop = function _loop(next) {
21
- if (name === CONTROL || name === STATE) {
21
+ if (name === INTENT || name === STATE) {
22
22
  return 1; // continue
23
23
  }
24
24
  fields.push(name);
@@ -37,7 +37,7 @@ function getSubmissionContext(body) {
37
37
  }
38
38
  return {
39
39
  payload,
40
- control: getControl(control),
40
+ intent: getIntent(intent),
41
41
  state: state ? JSON.parse(state) : {
42
42
  validated: {}
43
43
  },
@@ -46,68 +46,64 @@ function getSubmissionContext(body) {
46
46
  }
47
47
  function parse(payload, options) {
48
48
  var context = getSubmissionContext(payload);
49
- var control = context.control;
50
- if (control) {
51
- switch (control.type) {
49
+ var intent = context.intent;
50
+ if (intent) {
51
+ switch (intent.type) {
52
52
  case 'validate':
53
- if (control.payload.name) {
54
- context.state.validated[control.payload.name] = true;
53
+ if (intent.payload.name) {
54
+ context.state.validated[intent.payload.name] = true;
55
55
  }
56
56
  break;
57
- case 'replace':
57
+ case 'update':
58
58
  {
59
59
  var {
60
60
  name,
61
61
  value: _value,
62
62
  validated
63
- } = control.payload;
64
- if (name) {
65
- setValue(context.payload, name, () => _value);
66
- } else {
67
- // @ts-expect-error FIXME - it must be an object if there is no name
68
- context.payload = _value;
63
+ } = intent.payload;
64
+ if (typeof _value !== 'undefined') {
65
+ if (name) {
66
+ setValue(context.payload, name, () => _value);
67
+ } else {
68
+ // @ts-expect-error FIXME - it must be an object if there is no name
69
+ context.payload = _value;
70
+ }
69
71
  }
70
- if (validated) {
71
- if (isPlainObject(_value) || Array.isArray(_value)) {
72
- // Clean up previous validated state
72
+ if (typeof validated !== 'undefined') {
73
+ // Clean up previous validated state
74
+ if (name) {
73
75
  setState(context.state.validated, name, () => undefined);
74
- Object.assign(context.state.validated, flatten(_value, {
75
- resolve() {
76
- return true;
77
- },
78
- prefix: name
79
- }));
76
+ } else {
77
+ context.state.validated = {};
80
78
  }
81
- context.state.validated[name] = true;
82
- } else {
83
- if (isPlainObject(_value) || Array.isArray(_value)) {
84
- setState(context.state.validated, name, () => undefined);
79
+ if (validated) {
80
+ if (isPlainObject(_value) || Array.isArray(_value)) {
81
+ Object.assign(context.state.validated, flatten(_value, {
82
+ resolve() {
83
+ return true;
84
+ },
85
+ prefix: name
86
+ }));
87
+ }
88
+ context.state.validated[name !== null && name !== void 0 ? name : ''] = true;
89
+ } else if (name) {
90
+ delete context.state.validated[name];
85
91
  }
86
- delete context.state.validated[name];
87
92
  }
88
93
  break;
89
94
  }
90
95
  case 'reset':
91
96
  {
92
97
  var {
93
- name: _name,
94
- value: _value2,
95
- validated: _validated
96
- } = control.payload;
97
- if (typeof _value2 === 'undefined' || _value2) {
98
- if (_name) {
99
- setValue(context.payload, _name, () => undefined);
100
- } else {
101
- context.payload = {};
102
- }
103
- }
104
- if (typeof _validated === 'undefined' || _validated) {
105
- if (_name) {
106
- setState(context.state.validated, _name, () => undefined);
107
- delete context.state.validated[_name];
108
- } else {
109
- context.state.validated = {};
110
- }
98
+ name: _name
99
+ } = intent.payload;
100
+ if (_name) {
101
+ setValue(context.payload, _name, () => undefined);
102
+ setState(context.state.validated, _name, () => undefined);
103
+ delete context.state.validated[_name];
104
+ } else {
105
+ context.payload = {};
106
+ context.state.validated = {};
111
107
  }
112
108
  break;
113
109
  }
@@ -115,17 +111,17 @@ function parse(payload, options) {
115
111
  case 'remove':
116
112
  case 'reorder':
117
113
  {
118
- setListValue(context.payload, control);
119
- setListState(context.state.validated, control);
120
- context.state.validated[control.payload.name] = true;
114
+ setListValue(context.payload, intent);
115
+ setListState(context.state.validated, intent);
116
+ context.state.validated[intent.payload.name] = true;
121
117
  break;
122
118
  }
123
119
  }
124
120
  }
125
- var result = options.resolve(context.payload, control);
121
+ var result = options.resolve(context.payload, intent);
126
122
  var mergeResolveResult = resolved => {
127
123
  var error = typeof resolved.error !== 'undefined' ? resolved.error : {};
128
- if (!control || control.type === 'validate' && !control.payload.name) {
124
+ if (!intent || intent.type === 'validate' && !intent.payload.name) {
129
125
  for (var _name2 of [...context.fields, ...Object.keys(error !== null && error !== void 0 ? error : {})]) {
130
126
  context.state.validated[_name2] = true;
131
127
  }
@@ -141,9 +137,9 @@ function parse(payload, options) {
141
137
  return mergeResolveResult(result);
142
138
  }
143
139
  function createSubmission(context) {
144
- if (context.control || !context.value || context.error) {
140
+ if (context.intent || !context.value || context.error) {
145
141
  return {
146
- status: !context.control ? 'error' : undefined,
142
+ status: !context.intent ? 'error' : undefined,
147
143
  payload: context.payload,
148
144
  error: typeof context.error !== 'undefined' ? context.error : {},
149
145
  reply(options) {
@@ -161,13 +157,13 @@ function createSubmission(context) {
161
157
  };
162
158
  }
163
159
  function replySubmission(context) {
164
- var _context$control, _context$error, _simplify;
160
+ var _context$intent, _context$error, _simplify;
165
161
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
166
- switch ((_context$control = context.control) === null || _context$control === void 0 ? void 0 : _context$control.type) {
162
+ switch ((_context$intent = context.intent) === null || _context$intent === void 0 ? void 0 : _context$intent.type) {
167
163
  case 'reset':
168
164
  {
169
- var _context$control$payl;
170
- var name = (_context$control$payl = context.control.payload.name) !== null && _context$control$payl !== void 0 ? _context$control$payl : '';
165
+ var _context$intent$paylo;
166
+ var name = (_context$intent$paylo = context.intent.payload.name) !== null && _context$intent$paylo !== void 0 ? _context$intent$paylo : '';
171
167
  if (name === '') {
172
168
  return {
173
169
  initialValue: null
@@ -182,8 +178,8 @@ function replySubmission(context) {
182
178
  }
183
179
  if ('hideFields' in options && options.hideFields) {
184
180
  for (var _name3 of options.hideFields) {
185
- var _value3 = getValue(context.payload, _name3);
186
- if (typeof _value3 !== 'undefined') {
181
+ var _value2 = getValue(context.payload, _name3);
182
+ if (typeof _value2 !== 'undefined') {
187
183
  setValue(context.payload, _name3, () => undefined);
188
184
  }
189
185
  }
@@ -200,47 +196,47 @@ function replySubmission(context) {
200
196
  }, options.fieldErrors)) : null;
201
197
  var error = simplify(_objectSpread2(_objectSpread2({}, submissionError), extraError));
202
198
  return {
203
- status: context.control ? undefined : error ? 'error' : 'success',
204
- control: context.control ? context.control : undefined,
199
+ status: context.intent ? undefined : error ? 'error' : 'success',
200
+ intent: context.intent ? context.intent : undefined,
205
201
  initialValue: (_simplify = simplify(context.payload)) !== null && _simplify !== void 0 ? _simplify : {},
206
202
  error,
207
203
  state: context.state
208
204
  };
209
205
  }
210
- function getControl(serializedControl) {
211
- if (!serializedControl) {
206
+ function getIntent(serializedIntent) {
207
+ if (!serializedIntent) {
212
208
  return null;
213
209
  }
214
- var control = JSON.parse(serializedControl);
210
+ var control = JSON.parse(serializedIntent);
215
211
  if (typeof control.type !== 'string' || typeof control.payload === 'undefined') {
216
- throw new Error('Unknown control');
212
+ throw new Error('Unknown form control intent');
217
213
  }
218
214
  return control;
219
215
  }
220
- function serializeControl(control) {
221
- return JSON.stringify(control);
216
+ function serializeIntent(intent) {
217
+ return JSON.stringify(intent);
222
218
  }
223
- function updateList(list, control) {
224
- var _control$payload$inde;
219
+ function updateList(list, intent) {
220
+ var _intent$payload$index;
225
221
  invariant(Array.isArray(list), "Failed to update list. The value is not an array.");
226
- switch (control.type) {
222
+ switch (intent.type) {
227
223
  case 'insert':
228
- list.splice((_control$payload$inde = control.payload.index) !== null && _control$payload$inde !== void 0 ? _control$payload$inde : list.length, 0, serialize(control.payload.defaultValue));
224
+ list.splice((_intent$payload$index = intent.payload.index) !== null && _intent$payload$index !== void 0 ? _intent$payload$index : list.length, 0, serialize(intent.payload.defaultValue));
229
225
  break;
230
226
  case 'remove':
231
- list.splice(control.payload.index, 1);
227
+ list.splice(intent.payload.index, 1);
232
228
  break;
233
229
  case 'reorder':
234
- list.splice(control.payload.to, 0, ...list.splice(control.payload.from, 1));
230
+ list.splice(intent.payload.to, 0, ...list.splice(intent.payload.from, 1));
235
231
  break;
236
232
  default:
237
- throw new Error('Unknown list control received');
233
+ throw new Error('Unknown list intent received');
238
234
  }
239
235
  }
240
- function setListValue(data, control) {
241
- setValue(data, control.payload.name, value => {
236
+ function setListValue(data, intent) {
237
+ setValue(data, intent.payload.name, value => {
242
238
  var list = value !== null && value !== void 0 ? value : [];
243
- updateList(list, control);
239
+ updateList(list, intent);
244
240
  return list;
245
241
  });
246
242
  }
@@ -288,20 +284,20 @@ function setState(state, name, valueFn) {
288
284
  prefix: name
289
285
  }));
290
286
  }
291
- function setListState(state, control, getDefaultValue) {
292
- setState(state, control.payload.name, value => {
287
+ function setListState(state, intent, getDefaultValue) {
288
+ setState(state, intent.payload.name, value => {
293
289
  var list = value !== null && value !== void 0 ? value : [];
294
- switch (control.type) {
290
+ switch (intent.type) {
295
291
  case 'insert':
296
292
  updateList(list, {
297
- type: control.type,
298
- payload: _objectSpread2(_objectSpread2({}, control.payload), {}, {
293
+ type: intent.type,
294
+ payload: _objectSpread2(_objectSpread2({}, intent.payload), {}, {
299
295
  defaultValue: getDefaultValue === null || getDefaultValue === void 0 ? void 0 : getDefaultValue()
300
296
  })
301
297
  });
302
298
  break;
303
299
  default:
304
- updateList(list, control);
300
+ updateList(list, intent);
305
301
  break;
306
302
  }
307
303
  return list;
@@ -335,16 +331,5 @@ function serialize(defaultValue) {
335
331
  return defaultValue !== null && defaultValue !== void 0 ? defaultValue : undefined;
336
332
  }
337
333
  }
338
- var control = new Proxy({}, {
339
- get(_, type) {
340
- return function () {
341
- var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
342
- return {
343
- type,
344
- payload
345
- };
346
- };
347
- }
348
- });
349
334
 
350
- export { CONTROL, STATE, control, createSubmission, getControl, getSubmissionContext, parse, replySubmission, serialize, serializeControl, setListState, setListValue, setState, updateList };
335
+ export { INTENT, STATE, createSubmission, getIntent, getSubmissionContext, parse, replySubmission, serialize, serializeIntent, setListState, setListValue, setState, updateList };
package/README.md DELETED
@@ -1,17 +0,0 @@
1
- # @conform-to/dom
2
-
3
- > This package is a transitive dependency for the rest of the conform packages with no intention to be used directly at the moment. Use at your own risk.
4
-
5
- Conform is a progressive enhancement first form validation library for [Remix](https://remix.run)
6
-
7
- ### Highlights
8
-
9
- - Focused on progressive enhancment by default
10
- - Simplifed intergration through event delegation
11
- - Server first validation with Zod / Yup schema support
12
- - Field name inference with type checking
13
- - Focus management
14
- - Accessibility support
15
- - About 5kb compressed
16
-
17
- Checkout the [repository](https://github.com/edmundhung/conform) if you want to know more!