@conform-to/react
Advanced tools
Comparing version 1.0.0-pre.5 to 1.0.0-pre.6
@@ -40,2 +40,29 @@ 'use strict'; | ||
} | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {}; | ||
var target = {}; | ||
var sourceKeys = Object.keys(source); | ||
var key, i; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
target[key] = source[key]; | ||
} | ||
return target; | ||
} | ||
function _objectWithoutProperties(source, excluded) { | ||
if (source == null) return {}; | ||
var target = _objectWithoutPropertiesLoose(source, excluded); | ||
var key, i; | ||
if (Object.getOwnPropertySymbols) { | ||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source); | ||
for (i = 0; i < sourceSymbolKeys.length; i++) { | ||
key = sourceSymbolKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; | ||
target[key] = source[key]; | ||
} | ||
} | ||
return target; | ||
} | ||
function _toPrimitive(input, hint) { | ||
@@ -58,3 +85,5 @@ if (typeof input !== "object" || input === null) return input; | ||
exports.objectSpread2 = _objectSpread2; | ||
exports.objectWithoutProperties = _objectWithoutProperties; | ||
exports.objectWithoutPropertiesLoose = _objectWithoutPropertiesLoose; | ||
exports.toPrimitive = _toPrimitive; | ||
exports.toPropertyKey = _toPropertyKey; |
23
hooks.js
@@ -10,2 +10,4 @@ 'use strict'; | ||
var _excluded = ["id"]; | ||
/** | ||
@@ -34,7 +36,10 @@ * useLayoutEffect is client-only. | ||
function useForm(options) { | ||
var formId = useFormId(options.id); | ||
var [context$1] = react.useState(() => dom.createFormContext(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, options), {}, { | ||
var { | ||
id | ||
} = options, | ||
formConfig = _rollupPluginBabelHelpers.objectWithoutProperties(options, _excluded); | ||
var formId = useFormId(id); | ||
var [context$1] = react.useState(() => dom.createFormContext(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, formConfig), {}, { | ||
formId | ||
}))); | ||
var optionsRef = react.useRef(options); | ||
useSafeLayoutEffect(() => { | ||
@@ -51,13 +56,3 @@ document.addEventListener('input', context$1.input); | ||
useSafeLayoutEffect(() => { | ||
if (options.lastResult === optionsRef.current.lastResult) { | ||
// If there is no change, do nothing | ||
return; | ||
} | ||
if (options.lastResult) { | ||
context$1.report(options.lastResult); | ||
} | ||
}, [context$1, options.lastResult]); | ||
useSafeLayoutEffect(() => { | ||
optionsRef.current = options; | ||
context$1.update(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, options), {}, { | ||
context$1.update(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, formConfig), {}, { | ||
formId | ||
@@ -64,0 +59,0 @@ })); |
@@ -1,2 +0,2 @@ | ||
export { type Submission, type SubmissionResult, type FormControl, type FormId, type FieldName, requestSubmit, isFieldElement, control, } from '@conform-to/dom'; | ||
export { type Submission, type SubmissionResult, type DefaultValue, type FormControl, type FormId, type FieldName, requestSubmit, isFieldElement, control, } from '@conform-to/dom'; | ||
export { type FieldMetadata, type FormMetadata, FormProvider, FormStateInput, } from './context'; | ||
@@ -3,0 +3,0 @@ export { useForm, useFormMetadata, useField } from './hooks'; |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "1.0.0-pre.5", | ||
"version": "1.0.0-pre.6", | ||
"main": "index.js", | ||
@@ -34,3 +34,3 @@ "module": "index.mjs", | ||
"dependencies": { | ||
"@conform-to/dom": "1.0.0-pre.5" | ||
"@conform-to/dom": "1.0.0-pre.6" | ||
}, | ||
@@ -37,0 +37,0 @@ "devDependencies": { |
@@ -433,3 +433,3 @@ # @conform-to/react | ||
onValidate(context) { | ||
// This enables validating each field based on the validity state and custom cosntraint if defined | ||
// This enables validating each field based on the validity state and custom constraint if defined | ||
return validateConstraint( | ||
@@ -436,0 +436,0 @@ ...context, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
95713
1841
+ Added@conform-to/dom@1.0.0-pre.6(transitive)
- Removed@conform-to/dom@1.0.0-pre.5(transitive)
Updated@conform-to/dom@1.0.0-pre.6