@conform-to/dom 0.7.0-pre.2 → 0.7.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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { type FormControl as FieldElement, isFormControl as isFieldElement, isFocusableFormControl, getFormAction, getFormControls, getFormElement, getFormEncType, getFormMethod, focusFirstInvalidControl, createSubmitter, requestSubmit, } from './dom.js';
2
2
  export { formatPaths as getName, getPaths, getFormData, getValidationMessage, getErrors, } from './formdata.js';
3
3
  export { INTENT, getIntent, parseIntent, validate, list, updateList, requestIntent, } from './intent.js';
4
- export { type Submission, parse } from './parse.js';
4
+ export { type Submission, parse, VALIDATION_SKIPPED, VALIDATION_UNDEFINED, } from './parse.js';
5
5
  export { type FieldConstraint, type FieldsetConstraint, type ResolveType, type KeysOf, } from './types.js';
package/index.js CHANGED
@@ -31,4 +31,6 @@ exports.parseIntent = intent.parseIntent;
31
31
  exports.requestIntent = intent.requestIntent;
32
32
  exports.updateList = intent.updateList;
33
33
  exports.validate = intent.validate;
34
+ exports.VALIDATION_SKIPPED = parse.VALIDATION_SKIPPED;
35
+ exports.VALIDATION_UNDEFINED = parse.VALIDATION_UNDEFINED;
34
36
  exports.parse = parse.parse;
package/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  export { createSubmitter, focusFirstInvalidControl, getFormAction, getFormControls, getFormElement, getFormEncType, getFormMethod, isFormControl as isFieldElement, isFocusableFormControl, requestSubmit } from './dom.mjs';
2
2
  export { getErrors, getFormData, formatPaths as getName, getPaths, getValidationMessage } from './formdata.mjs';
3
3
  export { INTENT, getIntent, list, parseIntent, requestIntent, updateList, validate } from './intent.mjs';
4
- export { parse } from './parse.mjs';
4
+ export { VALIDATION_SKIPPED, VALIDATION_UNDEFINED, parse } from './parse.mjs';
package/intent.js CHANGED
@@ -72,25 +72,29 @@ function requestIntent(form, buttonProps) {
72
72
  dom.requestSubmit(form, submitter);
73
73
  }
74
74
  function parseIntent(intent) {
75
- var [type, payload] = intent.split('/', 2);
76
- if (typeof payload !== 'undefined') {
77
- try {
78
- switch (type) {
79
- case 'validate':
80
- return {
81
- type,
82
- payload
83
- };
84
- case 'list':
85
- return {
86
- type,
87
- payload: JSON.parse(payload)
88
- };
75
+ var seperatorIndex = intent.indexOf('/');
76
+ if (seperatorIndex > -1) {
77
+ var type = intent.slice(0, seperatorIndex);
78
+ var _payload = intent.slice(seperatorIndex + 1);
79
+ if (typeof _payload !== 'undefined') {
80
+ try {
81
+ switch (type) {
82
+ case 'validate':
83
+ return {
84
+ type,
85
+ payload: _payload
86
+ };
87
+ case 'list':
88
+ return {
89
+ type,
90
+ payload: JSON.parse(_payload)
91
+ };
92
+ }
93
+ } catch (error) {
94
+ throw new Error("Failed parsing intent: ".concat(intent), {
95
+ cause: error
96
+ });
89
97
  }
90
- } catch (error) {
91
- throw new Error("Failed parsing intent: ".concat(intent), {
92
- cause: error
93
- });
94
98
  }
95
99
  }
96
100
  return null;
package/intent.mjs CHANGED
@@ -68,25 +68,29 @@ function requestIntent(form, buttonProps) {
68
68
  requestSubmit(form, submitter);
69
69
  }
70
70
  function parseIntent(intent) {
71
- var [type, payload] = intent.split('/', 2);
72
- if (typeof payload !== 'undefined') {
73
- try {
74
- switch (type) {
75
- case 'validate':
76
- return {
77
- type,
78
- payload
79
- };
80
- case 'list':
81
- return {
82
- type,
83
- payload: JSON.parse(payload)
84
- };
71
+ var seperatorIndex = intent.indexOf('/');
72
+ if (seperatorIndex > -1) {
73
+ var type = intent.slice(0, seperatorIndex);
74
+ var _payload = intent.slice(seperatorIndex + 1);
75
+ if (typeof _payload !== 'undefined') {
76
+ try {
77
+ switch (type) {
78
+ case 'validate':
79
+ return {
80
+ type,
81
+ payload: _payload
82
+ };
83
+ case 'list':
84
+ return {
85
+ type,
86
+ payload: JSON.parse(_payload)
87
+ };
88
+ }
89
+ } catch (error) {
90
+ throw new Error("Failed parsing intent: ".concat(intent), {
91
+ cause: error
92
+ });
85
93
  }
86
- } catch (error) {
87
- throw new Error("Failed parsing intent: ".concat(intent), {
88
- cause: error
89
- });
90
94
  }
91
95
  }
92
96
  return null;
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": "0.7.0-pre.2",
6
+ "version": "0.7.0",
7
7
  "main": "index.js",
8
8
  "module": "index.mjs",
9
9
  "types": "index.d.ts",
package/parse.d.ts CHANGED
@@ -4,6 +4,8 @@ export type Submission<Schema = any> = {
4
4
  error: Record<string, string | string[]>;
5
5
  value?: Schema | null;
6
6
  };
7
+ export declare const VALIDATION_UNDEFINED = "__undefined__";
8
+ export declare const VALIDATION_SKIPPED = "__skipped__";
7
9
  export declare function parse(payload: FormData | URLSearchParams): Submission;
8
10
  export declare function parse<Schema>(payload: FormData | URLSearchParams, options?: {
9
11
  resolve?: (payload: Record<string, any>, intent: string) => {
package/parse.js CHANGED
@@ -6,6 +6,8 @@ var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js
6
6
  var formdata = require('./formdata.js');
7
7
  var intent = require('./intent.js');
8
8
 
9
+ var VALIDATION_UNDEFINED = '__undefined__';
10
+ var VALIDATION_SKIPPED = '__skipped__';
9
11
  function parse(payload, options) {
10
12
  var submission = {
11
13
  intent: intent.getIntent(payload),
@@ -34,4 +36,6 @@ function parse(payload, options) {
34
36
  return mergeResolveResult(result);
35
37
  }
36
38
 
39
+ exports.VALIDATION_SKIPPED = VALIDATION_SKIPPED;
40
+ exports.VALIDATION_UNDEFINED = VALIDATION_UNDEFINED;
37
41
  exports.parse = parse;
package/parse.mjs CHANGED
@@ -2,6 +2,8 @@ import { objectSpread2 as _objectSpread2 } from './_virtual/_rollupPluginBabelHe
2
2
  import { resolve, setValue } from './formdata.mjs';
3
3
  import { getIntent, parseIntent, updateList, INTENT } from './intent.mjs';
4
4
 
5
+ var VALIDATION_UNDEFINED = '__undefined__';
6
+ var VALIDATION_SKIPPED = '__skipped__';
5
7
  function parse(payload, options) {
6
8
  var submission = {
7
9
  intent: getIntent(payload),
@@ -30,4 +32,4 @@ function parse(payload, options) {
30
32
  return mergeResolveResult(result);
31
33
  }
32
34
 
33
- export { parse };
35
+ export { VALIDATION_SKIPPED, VALIDATION_UNDEFINED, parse };