@window-splitter/state 1.1.1--canary.9d2f98a.0 → 1.1.1

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@window-splitter/state",
4
4
  "sideEffects": false,
5
- "version": "1.1.1--canary.9d2f98a.0",
5
+ "version": "1.1.1",
6
6
  "description": "A state machine for a WAI-ARIA compliant window splitter",
7
7
  "homepage": "https://react-window-splitter-six.vercel.app",
8
8
  "repository": {
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "license": "MIT",
31
31
  "devDependencies": {
32
- "@internal/eslint-config": "1.1.1--canary.9d2f98a.0",
32
+ "@internal/eslint-config": "1.1.1",
33
33
  "@testing-library/react": "^16.0.0",
34
34
  "@types/big.js": "^6.2.2",
35
35
  "@vitest/browser": "catalog:",
@@ -77,5 +77,5 @@
77
77
  "window"
78
78
  ],
79
79
  "types": "./dist/commonjs/index.d.ts",
80
- "gitHead": "9d2f98a3d6226018c598018cea829d6412b60cd0"
80
+ "gitHead": "a7f123555c7e5ef966007731aba4dfae73cd19a2"
81
81
  }
package/src/index.ts CHANGED
@@ -405,6 +405,10 @@ export function prepareSnapshot(snapshot: GroupMachineContextValue) {
405
405
  item.collapsedSize.value = new Big(item.collapsedSize.value);
406
406
  item.min.value = new Big(item.min.value);
407
407
 
408
+ if (item.default) {
409
+ item.default.value = new Big(item.default.value);
410
+ }
411
+
408
412
  if (item.max && item.max !== "1fr") {
409
413
  item.max.value = new Big(item.max.value);
410
414
  }
package/src/utils.test.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { expect, test, describe } from "vitest";
1
+ import { expect, test, describe, assert } from "vitest";
2
2
 
3
3
  import {
4
4
  getUnitPercentageValue,
@@ -6,6 +6,8 @@ import {
6
6
  initializePanel,
7
7
  getCursor,
8
8
  initializePanelHandleData,
9
+ prepareSnapshot,
10
+ type Item,
9
11
  } from "./index.js";
10
12
  import Big from "big.js";
11
13
  import { createActor } from "./test-utils.js";
@@ -190,3 +192,28 @@ describe("initializePanelHandleData", () => {
190
192
  `);
191
193
  });
192
194
  });
195
+
196
+ describe('prepareSnapshot', () => {
197
+ test('converts sizes to Big', () => {
198
+ const item: Item = initializePanel({ id: 'panel-1', min: '100px', max: '300px', default: '200px' });
199
+
200
+ prepareSnapshot({
201
+ size: { width: 500, height: 300 },
202
+ items: [item, initializePanel({ id: 'panel-2', min: '100px' })],
203
+ groupId: 'group-1',
204
+ orientation: 'horizontal',
205
+ dragOvershoot: new Big(0),
206
+ });
207
+
208
+ expect(item.currentValue.value).toBeInstanceOf(Big);
209
+ expect(item.collapsedSize.value).toBeInstanceOf(Big);
210
+
211
+ expect(item.min.value).toBeInstanceOf(Big);
212
+
213
+ assert(typeof item.max === 'object');
214
+ expect(item.max.value).toBeInstanceOf(Big);
215
+
216
+ assert(typeof item.default === 'object');
217
+ expect(item.default.value).toBeInstanceOf(Big);
218
+ });
219
+ });