@conform-to/dom 0.7.0-pre.0 → 0.7.0-pre.1
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/_virtual/_rollupPluginBabelHelpers.js +8 -1
- package/_virtual/{_rollupPluginBabelHelpers.cjs → _rollupPluginBabelHelpers.mjs} +1 -8
- package/dom.js +15 -1
- package/{dom.cjs → dom.mjs} +1 -15
- package/formdata.js +11 -1
- package/{formdata.cjs → formdata.mjs} +1 -11
- package/index.d.ts +5 -5
- package/index.js +36 -4
- package/index.mjs +4 -0
- package/intent.js +16 -4
- package/{intent.cjs → intent.mjs} +4 -16
- package/package.json +7 -8
- package/parse.js +14 -10
- package/parse.mjs +33 -0
- package/index.cjs +0 -36
- package/parse.cjs +0 -37
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
1
5
|
function ownKeys(object, enumerableOnly) {
|
|
2
6
|
var keys = Object.keys(object);
|
|
3
7
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -48,4 +52,7 @@ function _toPropertyKey(arg) {
|
|
|
48
52
|
return typeof key === "symbol" ? key : String(key);
|
|
49
53
|
}
|
|
50
54
|
|
|
51
|
-
|
|
55
|
+
exports.defineProperty = _defineProperty;
|
|
56
|
+
exports.objectSpread2 = _objectSpread2;
|
|
57
|
+
exports.toPrimitive = _toPrimitive;
|
|
58
|
+
exports.toPropertyKey = _toPropertyKey;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
1
|
function ownKeys(object, enumerableOnly) {
|
|
6
2
|
var keys = Object.keys(object);
|
|
7
3
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -52,7 +48,4 @@ function _toPropertyKey(arg) {
|
|
|
52
48
|
return typeof key === "symbol" ? key : String(key);
|
|
53
49
|
}
|
|
54
50
|
|
|
55
|
-
|
|
56
|
-
exports.objectSpread2 = _objectSpread2;
|
|
57
|
-
exports.toPrimitive = _toPrimitive;
|
|
58
|
-
exports.toPropertyKey = _toPropertyKey;
|
|
51
|
+
export { _defineProperty as defineProperty, _objectSpread2 as objectSpread2, _toPrimitive as toPrimitive, _toPropertyKey as toPropertyKey };
|
package/dom.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* A type guard to check if the provided reference is a form control element, including
|
|
3
7
|
* `input`, `select`, `textarea` or `button`
|
|
@@ -152,4 +156,14 @@ function focusFormControl(form, name) {
|
|
|
152
156
|
}
|
|
153
157
|
}
|
|
154
158
|
|
|
155
|
-
|
|
159
|
+
exports.createSubmitter = createSubmitter;
|
|
160
|
+
exports.focusFirstInvalidControl = focusFirstInvalidControl;
|
|
161
|
+
exports.focusFormControl = focusFormControl;
|
|
162
|
+
exports.getFormAction = getFormAction;
|
|
163
|
+
exports.getFormControls = getFormControls;
|
|
164
|
+
exports.getFormElement = getFormElement;
|
|
165
|
+
exports.getFormEncType = getFormEncType;
|
|
166
|
+
exports.getFormMethod = getFormMethod;
|
|
167
|
+
exports.isFocusableFormControl = isFocusableFormControl;
|
|
168
|
+
exports.isFormControl = isFormControl;
|
|
169
|
+
exports.requestSubmit = requestSubmit;
|
package/{dom.cjs → dom.mjs}
RENAMED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
1
|
/**
|
|
6
2
|
* A type guard to check if the provided reference is a form control element, including
|
|
7
3
|
* `input`, `select`, `textarea` or `button`
|
|
@@ -156,14 +152,4 @@ function focusFormControl(form, name) {
|
|
|
156
152
|
}
|
|
157
153
|
}
|
|
158
154
|
|
|
159
|
-
|
|
160
|
-
exports.focusFirstInvalidControl = focusFirstInvalidControl;
|
|
161
|
-
exports.focusFormControl = focusFormControl;
|
|
162
|
-
exports.getFormAction = getFormAction;
|
|
163
|
-
exports.getFormControls = getFormControls;
|
|
164
|
-
exports.getFormElement = getFormElement;
|
|
165
|
-
exports.getFormEncType = getFormEncType;
|
|
166
|
-
exports.getFormMethod = getFormMethod;
|
|
167
|
-
exports.isFocusableFormControl = isFocusableFormControl;
|
|
168
|
-
exports.isFormControl = isFormControl;
|
|
169
|
-
exports.requestSubmit = requestSubmit;
|
|
155
|
+
export { createSubmitter, focusFirstInvalidControl, focusFormControl, getFormAction, getFormControls, getFormElement, getFormEncType, getFormMethod, isFocusableFormControl, isFormControl, requestSubmit };
|
package/formdata.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* A ponyfill-like helper to get the form data with the submitter value.
|
|
3
7
|
* It does not respect the tree order nor handles the image input.
|
|
@@ -114,4 +118,10 @@ function getErrors(validationMessage) {
|
|
|
114
118
|
return validationMessage.split(String.fromCharCode(31));
|
|
115
119
|
}
|
|
116
120
|
|
|
117
|
-
|
|
121
|
+
exports.formatPaths = formatPaths;
|
|
122
|
+
exports.getErrors = getErrors;
|
|
123
|
+
exports.getFormData = getFormData;
|
|
124
|
+
exports.getPaths = getPaths;
|
|
125
|
+
exports.getValidationMessage = getValidationMessage;
|
|
126
|
+
exports.resolve = resolve;
|
|
127
|
+
exports.setValue = setValue;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
1
|
/**
|
|
6
2
|
* A ponyfill-like helper to get the form data with the submitter value.
|
|
7
3
|
* It does not respect the tree order nor handles the image input.
|
|
@@ -118,10 +114,4 @@ function getErrors(validationMessage) {
|
|
|
118
114
|
return validationMessage.split(String.fromCharCode(31));
|
|
119
115
|
}
|
|
120
116
|
|
|
121
|
-
|
|
122
|
-
exports.getErrors = getErrors;
|
|
123
|
-
exports.getFormData = getFormData;
|
|
124
|
-
exports.getPaths = getPaths;
|
|
125
|
-
exports.getValidationMessage = getValidationMessage;
|
|
126
|
-
exports.resolve = resolve;
|
|
127
|
-
exports.setValue = setValue;
|
|
117
|
+
export { formatPaths, getErrors, getFormData, getPaths, getValidationMessage, resolve, setValue };
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { type FormControl as FieldElement, isFormControl as isFieldElement, isFocusableFormControl, getFormAction, getFormControls, getFormElement, getFormEncType, getFormMethod, focusFirstInvalidControl, focusFormControl, createSubmitter, requestSubmit, } from './dom';
|
|
2
|
-
export { formatPaths as getName, getPaths, getFormData, getValidationMessage, getErrors, } from './formdata';
|
|
3
|
-
export { type ListCommand, INTENT, getScope, isSubmitting, validate, list, parseListCommand, updateList, requestIntent, } from './intent';
|
|
4
|
-
export { type Submission, parse } from './parse';
|
|
5
|
-
export { type FieldConstraint, type FieldsetConstraint, type ResolveType, type KeysOf, } from './types';
|
|
1
|
+
export { type FormControl as FieldElement, isFormControl as isFieldElement, isFocusableFormControl, getFormAction, getFormControls, getFormElement, getFormEncType, getFormMethod, focusFirstInvalidControl, focusFormControl, createSubmitter, requestSubmit, } from './dom.js';
|
|
2
|
+
export { formatPaths as getName, getPaths, getFormData, getValidationMessage, getErrors, } from './formdata.js';
|
|
3
|
+
export { type ListCommand, INTENT, getScope, isSubmitting, validate, list, parseListCommand, updateList, requestIntent, } from './intent.js';
|
|
4
|
+
export { type Submission, parse } from './parse.js';
|
|
5
|
+
export { type FieldConstraint, type FieldsetConstraint, type ResolveType, type KeysOf, } from './types.js';
|
package/index.js
CHANGED
|
@@ -1,4 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var dom = require('./dom.js');
|
|
6
|
+
var formdata = require('./formdata.js');
|
|
7
|
+
var intent = require('./intent.js');
|
|
8
|
+
var parse = require('./parse.js');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.createSubmitter = dom.createSubmitter;
|
|
13
|
+
exports.focusFirstInvalidControl = dom.focusFirstInvalidControl;
|
|
14
|
+
exports.focusFormControl = dom.focusFormControl;
|
|
15
|
+
exports.getFormAction = dom.getFormAction;
|
|
16
|
+
exports.getFormControls = dom.getFormControls;
|
|
17
|
+
exports.getFormElement = dom.getFormElement;
|
|
18
|
+
exports.getFormEncType = dom.getFormEncType;
|
|
19
|
+
exports.getFormMethod = dom.getFormMethod;
|
|
20
|
+
exports.isFieldElement = dom.isFormControl;
|
|
21
|
+
exports.isFocusableFormControl = dom.isFocusableFormControl;
|
|
22
|
+
exports.requestSubmit = dom.requestSubmit;
|
|
23
|
+
exports.getErrors = formdata.getErrors;
|
|
24
|
+
exports.getFormData = formdata.getFormData;
|
|
25
|
+
exports.getName = formdata.formatPaths;
|
|
26
|
+
exports.getPaths = formdata.getPaths;
|
|
27
|
+
exports.getValidationMessage = formdata.getValidationMessage;
|
|
28
|
+
exports.INTENT = intent.INTENT;
|
|
29
|
+
exports.getScope = intent.getScope;
|
|
30
|
+
exports.isSubmitting = intent.isSubmitting;
|
|
31
|
+
exports.list = intent.list;
|
|
32
|
+
exports.parseListCommand = intent.parseListCommand;
|
|
33
|
+
exports.requestIntent = intent.requestIntent;
|
|
34
|
+
exports.updateList = intent.updateList;
|
|
35
|
+
exports.validate = intent.validate;
|
|
36
|
+
exports.parse = parse.parse;
|
package/index.mjs
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createSubmitter, focusFirstInvalidControl, focusFormControl, getFormAction, getFormControls, getFormElement, getFormEncType, getFormMethod, isFormControl as isFieldElement, isFocusableFormControl, requestSubmit } from './dom.mjs';
|
|
2
|
+
export { getErrors, getFormData, formatPaths as getName, getPaths, getValidationMessage } from './formdata.mjs';
|
|
3
|
+
export { INTENT, getScope, isSubmitting, list, parseListCommand, requestIntent, updateList, validate } from './intent.mjs';
|
|
4
|
+
export { parse } from './parse.mjs';
|
package/intent.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var dom = require('./dom.js');
|
|
2
6
|
|
|
3
7
|
var INTENT = '__intent__';
|
|
4
8
|
|
|
@@ -36,13 +40,13 @@ function requestIntent(form, buttonProps) {
|
|
|
36
40
|
console.warn('No form element is provided');
|
|
37
41
|
return;
|
|
38
42
|
}
|
|
39
|
-
var submitter = createSubmitter({
|
|
43
|
+
var submitter = dom.createSubmitter({
|
|
40
44
|
name: INTENT,
|
|
41
45
|
value: buttonProps.value,
|
|
42
46
|
hidden: true,
|
|
43
47
|
formNoValidate: buttonProps.formNoValidate
|
|
44
48
|
});
|
|
45
|
-
requestSubmit(form, submitter);
|
|
49
|
+
dom.requestSubmit(form, submitter);
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
/**
|
|
@@ -118,4 +122,12 @@ function updateList(list, command) {
|
|
|
118
122
|
return list;
|
|
119
123
|
}
|
|
120
124
|
|
|
121
|
-
|
|
125
|
+
exports.INTENT = INTENT;
|
|
126
|
+
exports.getIntent = getIntent;
|
|
127
|
+
exports.getScope = getScope;
|
|
128
|
+
exports.isSubmitting = isSubmitting;
|
|
129
|
+
exports.list = list;
|
|
130
|
+
exports.parseListCommand = parseListCommand;
|
|
131
|
+
exports.requestIntent = requestIntent;
|
|
132
|
+
exports.updateList = updateList;
|
|
133
|
+
exports.validate = validate;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var dom = require('./dom.cjs');
|
|
1
|
+
import { createSubmitter, requestSubmit } from './dom.mjs';
|
|
6
2
|
|
|
7
3
|
var INTENT = '__intent__';
|
|
8
4
|
|
|
@@ -40,13 +36,13 @@ function requestIntent(form, buttonProps) {
|
|
|
40
36
|
console.warn('No form element is provided');
|
|
41
37
|
return;
|
|
42
38
|
}
|
|
43
|
-
var submitter =
|
|
39
|
+
var submitter = createSubmitter({
|
|
44
40
|
name: INTENT,
|
|
45
41
|
value: buttonProps.value,
|
|
46
42
|
hidden: true,
|
|
47
43
|
formNoValidate: buttonProps.formNoValidate
|
|
48
44
|
});
|
|
49
|
-
|
|
45
|
+
requestSubmit(form, submitter);
|
|
50
46
|
}
|
|
51
47
|
|
|
52
48
|
/**
|
|
@@ -122,12 +118,4 @@ function updateList(list, command) {
|
|
|
122
118
|
return list;
|
|
123
119
|
}
|
|
124
120
|
|
|
125
|
-
|
|
126
|
-
exports.getIntent = getIntent;
|
|
127
|
-
exports.getScope = getScope;
|
|
128
|
-
exports.isSubmitting = isSubmitting;
|
|
129
|
-
exports.list = list;
|
|
130
|
-
exports.parseListCommand = parseListCommand;
|
|
131
|
-
exports.requestIntent = requestIntent;
|
|
132
|
-
exports.updateList = updateList;
|
|
133
|
-
exports.validate = validate;
|
|
121
|
+
export { INTENT, getIntent, getScope, isSubmitting, list, parseListCommand, requestIntent, updateList, validate };
|
package/package.json
CHANGED
|
@@ -3,18 +3,17 @@
|
|
|
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": "0.7.0-pre.
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"module": "index.js",
|
|
6
|
+
"version": "0.7.0-pre.1",
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"module": "index.mjs",
|
|
10
9
|
"types": "index.d.ts",
|
|
11
10
|
"exports": {
|
|
12
11
|
".": {
|
|
13
12
|
"types": "./index.d.ts",
|
|
14
|
-
"module": "./index.
|
|
15
|
-
"import": "./index.
|
|
16
|
-
"require": "./index.
|
|
17
|
-
"default": "./index.
|
|
13
|
+
"module": "./index.mjs",
|
|
14
|
+
"import": "./index.mjs",
|
|
15
|
+
"require": "./index.js",
|
|
16
|
+
"default": "./index.mjs"
|
|
18
17
|
}
|
|
19
18
|
},
|
|
20
19
|
"repository": {
|
package/parse.js
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
+
var formdata = require('./formdata.js');
|
|
7
|
+
var intent = require('./intent.js');
|
|
4
8
|
|
|
5
9
|
function parse(payload, options) {
|
|
6
10
|
var submission = {
|
|
7
|
-
intent: getIntent(payload),
|
|
8
|
-
payload: resolve(payload),
|
|
11
|
+
intent: intent.getIntent(payload),
|
|
12
|
+
payload: formdata.resolve(payload),
|
|
9
13
|
error: {}
|
|
10
14
|
};
|
|
11
|
-
var command = parseListCommand(submission.intent);
|
|
15
|
+
var command = intent.parseListCommand(submission.intent);
|
|
12
16
|
if (command) {
|
|
13
|
-
setValue(submission.payload, command.scope, list => {
|
|
17
|
+
formdata.setValue(submission.payload, command.scope, list => {
|
|
14
18
|
if (typeof list !== 'undefined' && !Array.isArray(list)) {
|
|
15
19
|
throw new Error('The list command can only be applied to a list');
|
|
16
20
|
}
|
|
17
|
-
return updateList(list !== null && list !== void 0 ? list : [], command);
|
|
21
|
+
return intent.updateList(list !== null && list !== void 0 ? list : [], command);
|
|
18
22
|
});
|
|
19
23
|
}
|
|
20
24
|
if (typeof (options === null || options === void 0 ? void 0 : options.resolve) === 'undefined') {
|
|
@@ -22,7 +26,7 @@ function parse(payload, options) {
|
|
|
22
26
|
}
|
|
23
27
|
var result = options.resolve(submission.payload, submission.intent);
|
|
24
28
|
var mergeResolveResult = resolved => {
|
|
25
|
-
return
|
|
29
|
+
return _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, submission), resolved);
|
|
26
30
|
};
|
|
27
31
|
if (result instanceof Promise) {
|
|
28
32
|
return result.then(mergeResolveResult);
|
|
@@ -30,4 +34,4 @@ function parse(payload, options) {
|
|
|
30
34
|
return mergeResolveResult(result);
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
exports.parse = parse;
|
package/parse.mjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { objectSpread2 as _objectSpread2 } from './_virtual/_rollupPluginBabelHelpers.mjs';
|
|
2
|
+
import { resolve, setValue } from './formdata.mjs';
|
|
3
|
+
import { getIntent, parseListCommand, updateList } from './intent.mjs';
|
|
4
|
+
|
|
5
|
+
function parse(payload, options) {
|
|
6
|
+
var submission = {
|
|
7
|
+
intent: getIntent(payload),
|
|
8
|
+
payload: resolve(payload),
|
|
9
|
+
error: {}
|
|
10
|
+
};
|
|
11
|
+
var command = parseListCommand(submission.intent);
|
|
12
|
+
if (command) {
|
|
13
|
+
setValue(submission.payload, command.scope, list => {
|
|
14
|
+
if (typeof list !== 'undefined' && !Array.isArray(list)) {
|
|
15
|
+
throw new Error('The list command can only be applied to a list');
|
|
16
|
+
}
|
|
17
|
+
return updateList(list !== null && list !== void 0 ? list : [], command);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.resolve) === 'undefined') {
|
|
21
|
+
return submission;
|
|
22
|
+
}
|
|
23
|
+
var result = options.resolve(submission.payload, submission.intent);
|
|
24
|
+
var mergeResolveResult = resolved => {
|
|
25
|
+
return _objectSpread2(_objectSpread2({}, submission), resolved);
|
|
26
|
+
};
|
|
27
|
+
if (result instanceof Promise) {
|
|
28
|
+
return result.then(mergeResolveResult);
|
|
29
|
+
}
|
|
30
|
+
return mergeResolveResult(result);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { parse };
|
package/index.cjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var dom = require('./dom.cjs');
|
|
6
|
-
var formdata = require('./formdata.cjs');
|
|
7
|
-
var intent = require('./intent.cjs');
|
|
8
|
-
var parse = require('./parse.cjs');
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.createSubmitter = dom.createSubmitter;
|
|
13
|
-
exports.focusFirstInvalidControl = dom.focusFirstInvalidControl;
|
|
14
|
-
exports.focusFormControl = dom.focusFormControl;
|
|
15
|
-
exports.getFormAction = dom.getFormAction;
|
|
16
|
-
exports.getFormControls = dom.getFormControls;
|
|
17
|
-
exports.getFormElement = dom.getFormElement;
|
|
18
|
-
exports.getFormEncType = dom.getFormEncType;
|
|
19
|
-
exports.getFormMethod = dom.getFormMethod;
|
|
20
|
-
exports.isFieldElement = dom.isFormControl;
|
|
21
|
-
exports.isFocusableFormControl = dom.isFocusableFormControl;
|
|
22
|
-
exports.requestSubmit = dom.requestSubmit;
|
|
23
|
-
exports.getErrors = formdata.getErrors;
|
|
24
|
-
exports.getFormData = formdata.getFormData;
|
|
25
|
-
exports.getName = formdata.formatPaths;
|
|
26
|
-
exports.getPaths = formdata.getPaths;
|
|
27
|
-
exports.getValidationMessage = formdata.getValidationMessage;
|
|
28
|
-
exports.INTENT = intent.INTENT;
|
|
29
|
-
exports.getScope = intent.getScope;
|
|
30
|
-
exports.isSubmitting = intent.isSubmitting;
|
|
31
|
-
exports.list = intent.list;
|
|
32
|
-
exports.parseListCommand = intent.parseListCommand;
|
|
33
|
-
exports.requestIntent = intent.requestIntent;
|
|
34
|
-
exports.updateList = intent.updateList;
|
|
35
|
-
exports.validate = intent.validate;
|
|
36
|
-
exports.parse = parse.parse;
|
package/parse.cjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.cjs');
|
|
6
|
-
var formdata = require('./formdata.cjs');
|
|
7
|
-
var intent = require('./intent.cjs');
|
|
8
|
-
|
|
9
|
-
function parse(payload, options) {
|
|
10
|
-
var submission = {
|
|
11
|
-
intent: intent.getIntent(payload),
|
|
12
|
-
payload: formdata.resolve(payload),
|
|
13
|
-
error: {}
|
|
14
|
-
};
|
|
15
|
-
var command = intent.parseListCommand(submission.intent);
|
|
16
|
-
if (command) {
|
|
17
|
-
formdata.setValue(submission.payload, command.scope, list => {
|
|
18
|
-
if (typeof list !== 'undefined' && !Array.isArray(list)) {
|
|
19
|
-
throw new Error('The list command can only be applied to a list');
|
|
20
|
-
}
|
|
21
|
-
return intent.updateList(list !== null && list !== void 0 ? list : [], command);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.resolve) === 'undefined') {
|
|
25
|
-
return submission;
|
|
26
|
-
}
|
|
27
|
-
var result = options.resolve(submission.payload, submission.intent);
|
|
28
|
-
var mergeResolveResult = resolved => {
|
|
29
|
-
return _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, submission), resolved);
|
|
30
|
-
};
|
|
31
|
-
if (result instanceof Promise) {
|
|
32
|
-
return result.then(mergeResolveResult);
|
|
33
|
-
}
|
|
34
|
-
return mergeResolveResult(result);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
exports.parse = parse;
|