@window-splitter/state 0.4.1 → 0.4.2

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/src/index.ts CHANGED
@@ -176,6 +176,12 @@ interface RegisterPanelEvent {
176
176
  data: Omit<PanelData, "type" | "currentValue" | "defaultCollapsed">;
177
177
  }
178
178
 
179
+ interface RebindPanelCallbacksEvent {
180
+ /** Rebind the panel callbacks */
181
+ type: "rebindPanelCallbacks";
182
+ data: Pick<PanelData, "id" | "onCollapseChange" | "onResize">;
183
+ }
184
+
179
185
  interface RegisterDynamicPanelEvent extends Omit<RegisterPanelEvent, "type"> {
180
186
  /** Register a new panel with the state machine */
181
187
  type: "registerDynamicPanel";
@@ -329,8 +335,8 @@ export type GroupMachineEvent =
329
335
  | ExpandPanelEvent
330
336
  | SetPanelPixelSizeEvent
331
337
  | ApplyDeltaEvent
332
- | SetActualItemsSizeEvent;
333
-
338
+ | SetActualItemsSizeEvent
339
+ | RebindPanelCallbacksEvent;
334
340
  type EventForType<T extends GroupMachineEvent["type"]> = Extract<
335
341
  GroupMachineEvent,
336
342
  { type: T }
@@ -1646,6 +1652,7 @@ export const groupMachine = createMachine(
1646
1652
  on: {
1647
1653
  setActualItemsSize: { actions: ["recordActualItemSize", "onResize"] },
1648
1654
  registerPanel: { actions: ["assignPanelData"] },
1655
+ rebindPanelCallbacks: { actions: ["rebindPanelCallbacks"] },
1649
1656
  registerDynamicPanel: {
1650
1657
  actions: [
1651
1658
  "prepare",
@@ -1857,6 +1864,20 @@ export const groupMachine = createMachine(
1857
1864
  });
1858
1865
  },
1859
1866
  }),
1867
+ rebindPanelCallbacks: assign({
1868
+ items: ({ context, event }) => {
1869
+ isEvent(event, ["rebindPanelCallbacks"]);
1870
+
1871
+ for (const item of context.items) {
1872
+ if (isPanelData(item) && item.id === event.data.id) {
1873
+ item.onCollapseChange = event.data.onCollapseChange;
1874
+ item.onResize = event.data.onResize;
1875
+ }
1876
+ }
1877
+
1878
+ return context.items;
1879
+ },
1880
+ }),
1860
1881
  onRegisterDynamicPanel: assign({
1861
1882
  items: ({ context, event }) => {
1862
1883
  isEvent(event, ["registerDynamicPanel"]);
@@ -1,4 +0,0 @@
1
-
2
- > @window-splitter/state@0.4.0 lint /home/runner/work/react-window-splitter/react-window-splitter/packages/state
3
- > eslint .
4
-