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 1.0.0 to 1.0.1

4

form.d.ts

@@ -7,6 +7,6 @@ import { getFormAction, getFormEncType, getFormMethod } from './dom';

} ? T[K] : undefined;
export type DefaultValue<Schema> = Schema extends string | number | boolean | Date | null | undefined ? Schema | string | null | undefined : Schema extends File ? null | undefined : Schema extends Array<infer Item> ? Array<DefaultValue<Item>> | null | undefined : Schema extends Record<string, any> ? {
export type DefaultValue<Schema> = Schema extends string | number | boolean | Date | bigint | null | undefined ? Schema | string | null | undefined : Schema extends File ? null | undefined : Schema extends Array<infer Item> ? Array<DefaultValue<Item>> | null | undefined : Schema extends Record<string, any> ? {
[Key in UnionKeyof<Schema>]?: DefaultValue<UnionKeyType<Schema, Key>>;
} | null | undefined : string | null | undefined;
export type FormValue<Schema> = Schema extends string | number | boolean | Date | null | undefined ? string | undefined : Schema extends File ? File | undefined : Schema extends Array<infer Item> ? Array<FormValue<Item>> | undefined : Schema extends Record<string, any> ? {
export type FormValue<Schema> = Schema extends string | number | boolean | Date | bigint | null | undefined ? string | undefined : Schema extends File ? File | undefined : Schema extends Array<infer Item> ? string | Array<FormValue<Item>> | undefined : Schema extends Record<string, any> ? {
[Key in UnionKeyof<Schema>]?: FormValue<UnionKeyType<Schema, Key>>;

@@ -13,0 +13,0 @@ } | undefined : unknown;

@@ -55,3 +55,3 @@ 'use strict';

var _name = (_intent$payload$name = intent.payload.name) !== null && _intent$payload$name !== void 0 ? _intent$payload$name : '';
var value = intent.payload.value;
var value = submission.serialize(intent.payload.value);
updateValue(meta, _name, value);

@@ -105,3 +105,3 @@ }

function createValueProxy(value) {
var val = formdata.simplify(value);
var val = formdata.normalize(value);
return createStateProxy((name, proxy) => {

@@ -215,5 +215,3 @@ if (name === '') {

function getFormElement() {
var element = document.forms.namedItem(latestOptions.formId);
util.invariant(element !== null, "Form#".concat(latestOptions.formId, " does not exist"));
return element;
return document.forms.namedItem(latestOptions.formId);
}

@@ -322,3 +320,3 @@ function createFormState(next) {

var element = event.target;
if (!dom.isFieldElement(element) || element.form !== form || element.name === '') {
if (!form || !dom.isFieldElement(element) || element.form !== form || element.name === '') {
return null;

@@ -379,3 +377,3 @@ }

if (!result.initialValue) {
formElement.reset();
formElement === null || formElement === void 0 || formElement.reset();
return;

@@ -401,3 +399,3 @@ }

updateFormMeta(update);
if (result.status === 'error') {
if (formElement && result.status === 'error') {
for (var element of formElement.elements) {

@@ -418,3 +416,4 @@ if (dom.isFieldElement(element) && error[element.name]) {

if (latestOptions.formId !== currentFormId) {
getFormElement().reset();
var _getFormElement;
(_getFormElement = getFormElement()) === null || _getFormElement === void 0 || _getFormElement.reset();
} else if (options.lastResult && options.lastResult !== currentResult) {

@@ -421,0 +420,0 @@ report(options.lastResult);

@@ -46,7 +46,7 @@ /**

/**
* Simplify value by removing empty object or array and null values
* Normalize value by removing empty object or array, empty string and null values
*/
export declare function simplify<Type extends Record<string, unknown>>(value: Type | null): Type | undefined;
export declare function simplify<Type extends Array<unknown>>(value: Type | null): Type | undefined;
export declare function simplify(value: unknown): unknown | undefined;
export declare function normalize<Type extends Record<string, unknown>>(value: Type | null): Type | null | undefined;
export declare function normalize<Type extends Array<unknown>>(value: Type | null): Type | null | undefined;
export declare function normalize(value: unknown): unknown | undefined;
/**

@@ -53,0 +53,0 @@ * Flatten a tree into a dictionary

@@ -135,9 +135,9 @@ 'use strict';

/**
* Simplify value by removing empty object or array and null values
* Normalize value by removing empty object or array, empty string and null values
*/
function simplify(value) {
function normalize(value) {
if (isPlainObject(value)) {
var obj = Object.keys(value).sort().reduce((result, key) => {
var data = simplify(value[key]);
var data = normalize(value[key]);
if (typeof data !== 'undefined') {

@@ -157,3 +157,3 @@ result[key] = data;

}
return value.map(simplify);
return value.map(normalize);
}

@@ -174,3 +174,3 @@ if (typeof value === 'string' && value === '' || value === null || isFile(value)) {

function setResult(data, name) {
var value = simplify(resolve(data));
var value = normalize(resolve(data));
if (typeof value !== 'undefined') {

@@ -227,3 +227,3 @@ result[name] = value;

exports.isPrefix = isPrefix;
exports.normalize = normalize;
exports.setValue = setValue;
exports.simplify = simplify;

@@ -6,3 +6,3 @@ {

"license": "MIT",
"version": "1.0.0",
"version": "1.0.1",
"main": "index.js",

@@ -9,0 +9,0 @@ "module": "index.mjs",

@@ -65,5 +65,5 @@ 'use strict';

name,
value: _value,
validated
} = intent.payload;
var _value = serialize(intent.payload.value);
if (typeof _value !== 'undefined') {

@@ -165,3 +165,3 @@ if (name) {

function replySubmission(context) {
var _context$intent, _context$error, _simplify;
var _context$intent, _options$formErrors, _normalize;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -193,3 +193,3 @@ switch ((_context$intent = context.intent) === null || _context$intent === void 0 ? void 0 : _context$intent.type) {

}
var submissionError = Object.entries((_context$error = context.error) !== null && _context$error !== void 0 ? _context$error : {}).reduce((result, _ref) => {
var submissionError = context.error ? Object.entries(context.error).reduce((result, _ref) => {
var [name, error] = _ref;

@@ -200,11 +200,11 @@ if (context.state.validated[name]) {

return result;
}, {});
var extraError = 'formErrors' in options || 'fieldErrors' in options ? formdata.simplify(_rollupPluginBabelHelpers.objectSpread2({
'': options.formErrors
}, {}) : undefined;
var extraError = 'formErrors' in options || 'fieldErrors' in options ? formdata.normalize(_rollupPluginBabelHelpers.objectSpread2({
'': (_options$formErrors = options.formErrors) !== null && _options$formErrors !== void 0 ? _options$formErrors : null
}, options.fieldErrors)) : null;
var error = formdata.simplify(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, submissionError), extraError));
var error = submissionError || extraError ? _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, submissionError), extraError) : undefined;
return {
status: context.intent ? undefined : error ? 'error' : 'success',
intent: context.intent ? context.intent : undefined,
initialValue: (_simplify = formdata.simplify(context.payload)) !== null && _simplify !== void 0 ? _simplify : {},
initialValue: (_normalize = formdata.normalize(context.payload)) !== null && _normalize !== void 0 ? _normalize : {},
error,

@@ -211,0 +211,0 @@ state: context.state

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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