@homebound/form-state 2.26.8 → 2.26.9

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.
@@ -46,11 +46,11 @@ function newFragmentField(parentInstance, key) {
46
46
  value = v;
47
47
  _tick.value++;
48
48
  },
49
- set() {
50
- throw new Error("FragmentField is read-only");
49
+ set(value) {
50
+ this.value = value;
51
51
  },
52
- adapt() {
53
- throw new Error("FragmentField is read-only");
52
+ adapt(value) {
53
+ throw new Error("FragmentField does not support adapt");
54
54
  },
55
55
  };
56
56
  return (0, mobx_1.makeAutoObservable)(obj, { value: false });
@@ -130,7 +130,6 @@ function newObjectState(config, parentState, parentInstance, parentListState, in
130
130
  },
131
131
  get valid() {
132
132
  return getFields(this).every((f) => {
133
- console.log(`Looking at ${f.key} valid=${f.valid}`);
134
133
  return f.valid;
135
134
  });
136
135
  },
@@ -1671,6 +1671,16 @@ describe("formState", () => {
1671
1671
  }
1672
1672
  `);
1673
1673
  });
1674
+ it("accepts new values in set", () => {
1675
+ const a = (0, objectField_1.createObjectState)({ title: { type: "value" }, data: { type: "fragment" } }, { title: "b1", data: (0, objectField_1.fragment)({ foo: "1" }) });
1676
+ let numCalcs = 0;
1677
+ (0, mobx_1.autorun)(() => {
1678
+ numCalcs++;
1679
+ noop(a.value);
1680
+ });
1681
+ a.set({ data: (0, objectField_1.fragment)({ foo: "2" }) });
1682
+ expect(numCalcs).toBe(2);
1683
+ });
1674
1684
  it("are always considered valid", () => {
1675
1685
  const a = (0, objectField_1.createObjectState)({ data: { type: "fragment" } }, { data: (0, objectField_1.fragment)({ foo: "1" }) });
1676
1686
  expect(a.valid).toBe(true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/form-state",
3
- "version": "2.26.8",
3
+ "version": "2.26.9",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",