New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

@shopify/react-form

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/react-form - npm Package Compare versions

Comparing version

to
2.1.0

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

exports.fieldsToArray = utilities.fieldsToArray;
exports.getDirtyValues = utilities.getDirtyValues;
exports.getValues = utilities.getValues;

@@ -21,0 +22,0 @@ exports.makeCleanDynamicLists = utilities.makeCleanDynamicLists;

@@ -102,2 +102,11 @@ 'use strict';

}
function getDirtyValues(fieldBag) {
return Object.entries(fieldBag).reduce((acc, [fieldName, field]) => {
return { ...acc,
...(field.dirty ? {
[fieldName]: field.value
} : {})
};
}, {});
}
function shallowArrayComparison(arrA, arrB) {

@@ -142,2 +151,3 @@ if (arrA === arrB) {

exports.fieldsToArray = fieldsToArray;
exports.getDirtyValues = getDirtyValues;
exports.getValues = getValues;

@@ -144,0 +154,0 @@ exports.isChangeEvent = isChangeEvent;

@@ -5,3 +5,3 @@ export * from './types';

export type { ChoiceField, FieldConfig } from './hooks';
export { fieldsToArray, getValues, propagateErrors, validateAll, reduceFields, makeCleanFields, makeCleanDynamicLists, } from './utilities';
export { fieldsToArray, getValues, getDirtyValues, propagateErrors, validateAll, reduceFields, makeCleanFields, makeCleanDynamicLists, } from './utilities';
//# sourceMappingURL=index.d.ts.map

@@ -14,2 +14,3 @@ import { ChangeEvent } from 'react';

export declare function getValues<T extends FieldBag>(fieldBag: T): FormMapping<T, "value">;
export declare function getDirtyValues<T extends FieldBag>(fieldBag: T): {};
export declare function noop(): void;

@@ -16,0 +17,0 @@ export declare function shallowArrayComparison(arrA: unknown[], arrB: any): boolean;

{
"name": "@shopify/react-form",
"version": "2.0.1-react-18-react-testing-beta.0",
"version": "2.1.0",
"license": "MIT",

@@ -27,3 +27,3 @@ "description": "Manage React forms tersely and safely-typed with no magic using React hooks",

"peerDependencies": {
"react": ">=16.8.0"
"react": ">=16.8.0 <18.0.0"
},

@@ -40,3 +40,3 @@ "files": [

"@shopify/predicates": "^3.0.0",
"@shopify/react-hooks": "^3.0.1-react-18-react-testing-beta.0",
"@shopify/react-hooks": "^3.0.0",
"fast-deep-equal": "^3.1.3",

@@ -54,3 +54,3 @@ "get-value": "^3.0.1"

},
"gitHead": "98d5dbd85ade201ee2a47504fba7e47a91312e29"
"gitHead": "8cc6ba3e75696a7ae0b79ec2a18dc36d733d070f"
}

@@ -34,2 +34,3 @@ # `@shopify/react-form`

1. [getValues](#utilities)
1. [getDirtyValues](#utilities)
1. [fieldsToArray](#utilities)

@@ -1126,2 +1127,22 @@ 1. [makeCleanFields](#utilities)

#### getDirtyValues
Takes `FieldBag` and returns object with only dirty field values, similar to the `FormMapping` argument passed to `onSubmit`.
##### Signature
```tsx
function getDirtyValues<T extends FieldBag>(fieldBag: T) {
return Object.entries(fieldBag).reduce(
(acc, [fieldName, field]: [string, Field<any>]) => {
return {
...acc,
...(field.dirty ? {[fieldName]: field.value} : {}),
};
},
{},
);
}
```
#### reduceFields

@@ -1128,0 +1149,0 @@

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet