@homebound/form-state 2.2.11 → 2.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/formState.js CHANGED
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createObjectState = exports.required = void 0;
7
7
  const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
8
- const is_plain_object_1 = __importDefault(require("is-plain-object"));
8
+ const is_plain_object_1 = require("is-plain-object");
9
9
  const mobx_1 = require("mobx");
10
10
  const utils_1 = require("./utils");
11
11
  /** A rule that validates `value` is not `undefined`, `null`, or empty string. */
@@ -188,7 +188,7 @@ function newObjectState(config, parentState, instance, key, onBlur) {
188
188
  function newValueFieldState(parentInstance, parentState, key, rules, isIdKey, isDeleteKey, isReadOnlyKey, computed, readOnly, onBlur) {
189
189
  // keep a copy here for reference equality
190
190
  const value = parentInstance[key];
191
- let _originalValue = value === null ? undefined : is_plain_object_1.default(value) ? mobx_1.toJS(value) : value;
191
+ let _originalValue = value === null ? undefined : is_plain_object_1.isPlainObject(value) ? mobx_1.toJS(value) : value;
192
192
  // Because we read/write the value directly back into parentInstance[key],
193
193
  // which itself is not a proxy, we use this as our "value changed" trigger.
194
194
  const _tick = mobx_1.observable({ value: 1 });
@@ -309,7 +309,7 @@ function newValueFieldState(parentInstance, parentState, key, rules, isIdKey, is
309
309
  this.touched = false;
310
310
  },
311
311
  save() {
312
- if (is_plain_object_1.default(this.originalValue)) {
312
+ if (is_plain_object_1.isPlainObject(this.originalValue)) {
313
313
  this.originalValue = mobx_1.toJS(this.value);
314
314
  }
315
315
  else {
@@ -538,7 +538,7 @@ function isEmpty(value) {
538
538
  *
539
539
  */
540
540
  function areEqual(a, b) {
541
- if (is_plain_object_1.default(a)) {
541
+ if (is_plain_object_1.isPlainObject(a)) {
542
542
  return fast_deep_equal_1.default(mobx_1.toJS(a), mobx_1.toJS(b));
543
543
  }
544
544
  if (hasToJSON(a) || hasToJSON(b)) {
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.pickFields = exports.useFormState = void 0;
7
- const is_plain_object_1 = __importDefault(require("is-plain-object"));
4
+ const is_plain_object_1 = require("is-plain-object");
8
5
  const mobx_1 = require("mobx");
9
6
  const react_1 = require("react");
10
7
  const formState_1 = require("./formState");
@@ -21,7 +18,7 @@ function useFormState(opts) {
21
18
  const firstRunRef = react_1.useRef(true);
22
19
  // This is a little weird, but we need to know ahead of time, before the form useMemo, if we're working with classes/mobx proxies
23
20
  const [firstInitValue] = react_1.useState(() => initValue(config, init));
24
- const isWrappingMobxProxy = !is_plain_object_1.default(firstInitValue);
21
+ const isWrappingMobxProxy = !is_plain_object_1.isPlainObject(firstInitValue);
25
22
  // If they're using init.input, useMemo on it (and it might be an array), otherwise allow the identity of init be unstable
26
23
  const dep = init && "input" in init && "map" in init ? (Array.isArray(init.input) ? init.input : [init.input]) : [];
27
24
  const form = react_1.useMemo(() => {
@@ -88,7 +85,7 @@ function initValue(config, init) {
88
85
  */
89
86
  function pickFields(formConfig, instance) {
90
87
  // If the caller is using classes, i.e. with their own custom observable behavior, then just use as-is
91
- if (!is_plain_object_1.default(instance)) {
88
+ if (!is_plain_object_1.isPlainObject(instance)) {
92
89
  return instance;
93
90
  }
94
91
  return Object.fromEntries(Object.entries(formConfig).map(([key, _keyConfig]) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/form-state",
3
- "version": "2.2.11",
3
+ "version": "2.2.12",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -21,7 +21,9 @@
21
21
  "format": "prettier --loglevel warn --write \"**/*.{ts,tsx,css,md}\"",
22
22
  "semantic-release": "semantic-release"
23
23
  },
24
- "peerDependencies": {
24
+ "dependencies": {
25
+ "fast-deep-equal": "^3.1.3",
26
+ "is-plain-object": "^5.0.0",
25
27
  "mobx": "^6.3.2",
26
28
  "mobx-react": "^7.2.0",
27
29
  "react": ">=16"