Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@conform-to/dom

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@conform-to/dom - npm Package Compare versions

Comparing version 0.4.0-pre.3 to 0.4.0

6

_virtual/_rollupPluginBabelHelpers.js

@@ -7,3 +7,2 @@ 'use strict';

var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {

@@ -15,6 +14,4 @@ var symbols = Object.getOwnPropertySymbols(object);

}
return keys;
}
function _objectSpread2(target) {

@@ -29,6 +26,4 @@ for (var i = 1; i < arguments.length; i++) {

}
return target;
}
function _defineProperty(obj, key, value) {

@@ -45,3 +40,2 @@ if (key in obj) {

}
return obj;

@@ -48,0 +42,0 @@ }

@@ -15,18 +15,13 @@ 'use strict';

var pattern = /(\w*)\[(\d+)\]/;
if (!name) {
return [];
}
return name.split('.').flatMap(key => {
var matches = pattern.exec(key);
if (!matches) {
return key;
}
if (matches[1] === '') {
return Number(matches[2]);
}
return [matches[1], Number(matches[2])];

@@ -37,7 +32,5 @@ });

var payload = new FormData(form);
if (submitter !== null && submitter !== void 0 && submitter.name) {
payload.append(submitter.name, submitter.value);
}
return payload;

@@ -50,7 +43,5 @@ }

}
if (name === '' || path === '') {
return [name, path].join('');
}
return [name, path].join('.');

@@ -70,7 +61,5 @@ }, '');

var firstErrorByName = Object.fromEntries([...submission.error].reverse());
for (var element of form.elements) {
if (isFieldElement(element)) {
var error = firstErrorByName[element.name];
if (typeof error !== 'undefined' || shouldValidate(submission, element.name)) {

@@ -87,6 +76,4 @@ element.setCustomValidity(error !== null && error !== void 0 ? error : '');

var pointer = target;
while (pointer != null && ++index < length) {
var _pointer$key;
var key = paths[index];

@@ -119,7 +106,5 @@ var next = paths[index + 1];

var form = element instanceof HTMLFormElement ? element : element === null || element === void 0 ? void 0 : element.form;
if (!form) {
return null;
}
return form;

@@ -129,7 +114,5 @@ }

var currentFocus = document.activeElement;
if (!isFieldElement(currentFocus) || currentFocus.tagName !== 'BUTTON' || currentFocus.form !== form) {
return;
}
for (var field of form.elements) {

@@ -147,7 +130,5 @@ if (isFieldElement(field)) {

var prefix = 'conform/';
if (!name.startsWith(prefix) || name.length <= prefix.length) {
return null;
}
return name.slice(prefix.length);

@@ -162,7 +143,5 @@ }

};
try {
var _loop = function _loop(name, value) {
var submissionType = getSubmissionType(name);
if (submissionType) {

@@ -172,7 +151,5 @@ if (typeof value !== 'string') {

}
if (hasCommand) {
throw new Error('The conform command could only be set on a button');
}
submission = _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, submission), {}, {

@@ -189,3 +166,2 @@ type: submissionType,

}
return value;

@@ -195,7 +171,5 @@ });

};
for (var [name, value] of payload.entries()) {
_loop(name, value);
}
switch (submission.type) {

@@ -209,3 +183,2 @@ case 'list':

}
return submission;

@@ -216,7 +189,5 @@ }

var command = JSON.parse(data);
if (typeof command.type !== 'string' || !['prepend', 'append', 'replace', 'remove', 'reorder'].includes(command.type)) {
throw new Error('Unsupported list command type');
}
return command;

@@ -234,3 +205,2 @@ } catch (error) {

}
case 'append':

@@ -241,3 +211,2 @@ {

}
case 'replace':

@@ -248,15 +217,11 @@ {

}
case 'remove':
list.splice(command.payload.index, 1);
break;
case 'reorder':
list.splice(command.payload.to, 0, ...list.splice(command.payload.from, 1));
break;
default:
throw new Error('Unknown list command received');
}
return list;

@@ -266,7 +231,5 @@ }

var _submission$intent;
if (submission.type !== 'list') {
return submission;
}
var command = parseListCommand((_submission$intent = submission.intent) !== null && _submission$intent !== void 0 ? _submission$intent : '');

@@ -278,3 +241,2 @@ var paths = getPaths(command.scope);

}
return updateList(list, command);

@@ -281,0 +243,0 @@ });

function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {

@@ -10,6 +9,4 @@ var symbols = Object.getOwnPropertySymbols(object);

}
return keys;
}
function _objectSpread2(target) {

@@ -24,6 +21,4 @@ for (var i = 1; i < arguments.length; i++) {

}
return target;
}
function _defineProperty(obj, key, value) {

@@ -40,3 +35,2 @@ if (key in obj) {

}
return obj;

@@ -43,0 +37,0 @@ }

@@ -11,18 +11,13 @@ import { objectSpread2 as _objectSpread2 } from './_virtual/_rollupPluginBabelHelpers.js';

var pattern = /(\w*)\[(\d+)\]/;
if (!name) {
return [];
}
return name.split('.').flatMap(key => {
var matches = pattern.exec(key);
if (!matches) {
return key;
}
if (matches[1] === '') {
return Number(matches[2]);
}
return [matches[1], Number(matches[2])];

@@ -33,7 +28,5 @@ });

var payload = new FormData(form);
if (submitter !== null && submitter !== void 0 && submitter.name) {
payload.append(submitter.name, submitter.value);
}
return payload;

@@ -46,7 +39,5 @@ }

}
if (name === '' || path === '') {
return [name, path].join('');
}
return [name, path].join('.');

@@ -66,7 +57,5 @@ }, '');

var firstErrorByName = Object.fromEntries([...submission.error].reverse());
for (var element of form.elements) {
if (isFieldElement(element)) {
var error = firstErrorByName[element.name];
if (typeof error !== 'undefined' || shouldValidate(submission, element.name)) {

@@ -83,6 +72,4 @@ element.setCustomValidity(error !== null && error !== void 0 ? error : '');

var pointer = target;
while (pointer != null && ++index < length) {
var _pointer$key;
var key = paths[index];

@@ -115,7 +102,5 @@ var next = paths[index + 1];

var form = element instanceof HTMLFormElement ? element : element === null || element === void 0 ? void 0 : element.form;
if (!form) {
return null;
}
return form;

@@ -125,7 +110,5 @@ }

var currentFocus = document.activeElement;
if (!isFieldElement(currentFocus) || currentFocus.tagName !== 'BUTTON' || currentFocus.form !== form) {
return;
}
for (var field of form.elements) {

@@ -143,7 +126,5 @@ if (isFieldElement(field)) {

var prefix = 'conform/';
if (!name.startsWith(prefix) || name.length <= prefix.length) {
return null;
}
return name.slice(prefix.length);

@@ -158,7 +139,5 @@ }

};
try {
var _loop = function _loop(name, value) {
var submissionType = getSubmissionType(name);
if (submissionType) {

@@ -168,7 +147,5 @@ if (typeof value !== 'string') {

}
if (hasCommand) {
throw new Error('The conform command could only be set on a button');
}
submission = _objectSpread2(_objectSpread2({}, submission), {}, {

@@ -185,3 +162,2 @@ type: submissionType,

}
return value;

@@ -191,7 +167,5 @@ });

};
for (var [name, value] of payload.entries()) {
_loop(name, value);
}
switch (submission.type) {

@@ -205,3 +179,2 @@ case 'list':

}
return submission;

@@ -212,7 +185,5 @@ }

var command = JSON.parse(data);
if (typeof command.type !== 'string' || !['prepend', 'append', 'replace', 'remove', 'reorder'].includes(command.type)) {
throw new Error('Unsupported list command type');
}
return command;

@@ -230,3 +201,2 @@ } catch (error) {

}
case 'append':

@@ -237,3 +207,2 @@ {

}
case 'replace':

@@ -244,15 +213,11 @@ {

}
case 'remove':
list.splice(command.payload.index, 1);
break;
case 'reorder':
list.splice(command.payload.to, 0, ...list.splice(command.payload.from, 1));
break;
default:
throw new Error('Unknown list command received');
}
return list;

@@ -262,7 +227,5 @@ }

var _submission$intent;
if (submission.type !== 'list') {
return submission;
}
var command = parseListCommand((_submission$intent = submission.intent) !== null && _submission$intent !== void 0 ? _submission$intent : '');

@@ -274,3 +237,2 @@ var paths = getPaths(command.scope);

}
return updateList(list, command);

@@ -277,0 +239,0 @@ });

2

package.json

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "0.4.0-pre.3",
"version": "0.4.0",
"main": "index.js",

@@ -8,0 +8,0 @@ "module": "module/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc