final-form-persist
Advanced tools
Comparing version 1.0.3 to 1.0.4
import { Decorator } from "final-form"; | ||
export interface FinalFormPersistOptions { | ||
export interface FinalFormPersistOptions<FormValues = object> { | ||
name: string; | ||
debounceTime?: number; | ||
whitelist?: string[]; | ||
whitelist?: Array<keyof FormValues>; | ||
blacklist?: Array<keyof FormValues>; | ||
storage?: Storage; | ||
@@ -13,2 +14,2 @@ } | ||
} | ||
export declare const createPersistDecorator: <FormValues = object>(options: FinalFormPersistOptions) => FinalFormPersistDecorator<FormValues>; | ||
export declare const createPersistDecorator: <FormValues = object>(options: FinalFormPersistOptions<FormValues>) => FinalFormPersistDecorator<FormValues>; |
@@ -408,3 +408,3 @@ /*! ***************************************************************************** | ||
var persistDecorator = function (options) { return function (form) { | ||
var name = options.name, _a = options.debounceTime, debounceTime = _a === void 0 ? 0 : _a, _b = options.whitelist, whitelist = _b === void 0 ? [] : _b, _c = options.storage, storage = _c === void 0 ? localStorage : _c; | ||
var name = options.name, _a = options.debounceTime, debounceTime = _a === void 0 ? 0 : _a, _b = options.whitelist, whitelist = _b === void 0 ? [] : _b, _c = options.storage, storage = _c === void 0 ? localStorage : _c, _d = options.blacklist, blacklist = _d === void 0 ? [] : _d; | ||
var persistedValues = storage.getItem(name) || "{}"; | ||
@@ -416,7 +416,8 @@ var initialValues = form.getState().initialValues; | ||
var valuesKeys = Object.keys(values); | ||
if (whitelist.length > 0) { | ||
valuesKeys = Object.keys(values).filter(function (value) { | ||
return whitelist.includes(value); | ||
}); | ||
if (whitelist.length > 0 && !blacklist.length) { | ||
valuesKeys = Object.keys(values).filter(function (value) { return whitelist.includes(value); }); | ||
} | ||
if (blacklist.length > 0) { | ||
valuesKeys = Object.keys(values).filter(function (value) { return !blacklist.includes(value); }); | ||
} | ||
var valuesObject = valuesKeys.reduce(function (acc, key) { | ||
@@ -423,0 +424,0 @@ var _a; |
@@ -412,3 +412,3 @@ 'use strict'; | ||
var persistDecorator = function (options) { return function (form) { | ||
var name = options.name, _a = options.debounceTime, debounceTime = _a === void 0 ? 0 : _a, _b = options.whitelist, whitelist = _b === void 0 ? [] : _b, _c = options.storage, storage = _c === void 0 ? localStorage : _c; | ||
var name = options.name, _a = options.debounceTime, debounceTime = _a === void 0 ? 0 : _a, _b = options.whitelist, whitelist = _b === void 0 ? [] : _b, _c = options.storage, storage = _c === void 0 ? localStorage : _c, _d = options.blacklist, blacklist = _d === void 0 ? [] : _d; | ||
var persistedValues = storage.getItem(name) || "{}"; | ||
@@ -420,7 +420,8 @@ var initialValues = form.getState().initialValues; | ||
var valuesKeys = Object.keys(values); | ||
if (whitelist.length > 0) { | ||
valuesKeys = Object.keys(values).filter(function (value) { | ||
return whitelist.includes(value); | ||
}); | ||
if (whitelist.length > 0 && !blacklist.length) { | ||
valuesKeys = Object.keys(values).filter(function (value) { return whitelist.includes(value); }); | ||
} | ||
if (blacklist.length > 0) { | ||
valuesKeys = Object.keys(values).filter(function (value) { return !blacklist.includes(value); }); | ||
} | ||
var valuesObject = valuesKeys.reduce(function (acc, key) { | ||
@@ -427,0 +428,0 @@ var _a; |
{ | ||
"name": "final-form-persist", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Persist your form values into a storage", | ||
@@ -5,0 +5,0 @@ "author": "premieroctet", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
92643
824