@window-splitter/state 0.4.3 → 0.5.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": "0.4.3",
5
+ "version": "0.5.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": {
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "license": "MIT",
30
30
  "devDependencies": {
31
- "@internal/eslint-config": "0.4.3",
31
+ "@internal/eslint-config": "0.5.1",
32
32
  "@testing-library/react": "^16.0.0",
33
33
  "@types/big.js": "^6.2.2",
34
34
  "@vitest/browser": "^2.0.5",
@@ -80,5 +80,5 @@
80
80
  "window"
81
81
  ],
82
82
  "types": "./dist/commonjs/index.d.ts",
83
- "gitHead": "f38708708e9bc6355e81e419433d4ebbf9c43193"
83
+ "gitHead": "7107d50f4b302ac05eeeccd76df00e5cde5c8b42"
84
84
  }
package/src/index.ts CHANGED
@@ -319,6 +319,8 @@ export interface GroupMachineContextValue {
319
319
  orientation: Orientation;
320
320
  /** How much the drag has overshot the handle */
321
321
  dragOvershoot: Big.Big;
322
+ /** The id of the handle that is currently being dragged */
323
+ activeDragHandleId?: string;
322
324
  groupId: string;
323
325
  /**
324
326
  * How to save the persisted state
@@ -1658,7 +1660,10 @@ export const groupMachine = createMachine(
1658
1660
  idle: {
1659
1661
  entry: ["onAutosave"],
1660
1662
  on: {
1661
- dragHandleStart: { target: "dragging" },
1663
+ dragHandleStart: {
1664
+ target: "dragging",
1665
+ actions: ["onDragHandleStart"],
1666
+ },
1662
1667
  setPanelPixelSize: {
1663
1668
  actions: [
1664
1669
  "prepare",
@@ -1703,7 +1708,7 @@ export const groupMachine = createMachine(
1703
1708
  actions: "runCollapseToggle",
1704
1709
  },
1705
1710
  },
1706
- exit: ["commit"],
1711
+ exit: ["commit", "clearDragHandle"],
1707
1712
  },
1708
1713
  togglingCollapse: {
1709
1714
  entry: ["prepare", "onClearLastKnownSize"],
@@ -1822,6 +1827,15 @@ export const groupMachine = createMachine(
1822
1827
  animation: animationActor,
1823
1828
  },
1824
1829
  actions: {
1830
+ onDragHandleStart: assign({
1831
+ activeDragHandleId: ({ event }) => {
1832
+ isEvent(event, ["dragHandleStart"]);
1833
+ return event.handleId;
1834
+ },
1835
+ }),
1836
+ clearDragHandle: assign({
1837
+ activeDragHandleId: undefined,
1838
+ }),
1825
1839
  onAutosave: ({ context, self }) => {
1826
1840
  if (!context.autosaveStrategy || typeof window === "undefined") {
1827
1841
  return;
@@ -1829,6 +1843,7 @@ export const groupMachine = createMachine(
1829
1843
 
1830
1844
  const snapshot = self.getPersistedSnapshot() as GroupMachineSnapshot;
1831
1845
  snapshot.context.items = clearLastKnownSize(context.items);
1846
+ snapshot.context.activeDragHandleId = context.activeDragHandleId;
1832
1847
  snapshot.value = "idle";
1833
1848
  const data = JSON.stringify(snapshot);
1834
1849