@zag-js/splitter 1.3.3 → 1.4.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/dist/index.d.mts CHANGED
@@ -142,6 +142,14 @@ interface SplitterApi<T extends PropTypes = PropTypes> {
142
142
  * Function to set the size of a panel.
143
143
  */
144
144
  setSize(id: PanelId, size: number): void;
145
+ /**
146
+ * Function to set the size of multiple panels.
147
+ */
148
+ setSizes(sizes: PanelSizeData[]): void;
149
+ /**
150
+ * Returns the size of a panel.
151
+ */
152
+ getSize(id: PanelId): number;
145
153
  /**
146
154
  * Returns the state details for a resize trigger.
147
155
  */
package/dist/index.d.ts CHANGED
@@ -142,6 +142,14 @@ interface SplitterApi<T extends PropTypes = PropTypes> {
142
142
  * Function to set the size of a panel.
143
143
  */
144
144
  setSize(id: PanelId, size: number): void;
145
+ /**
146
+ * Function to set the size of multiple panels.
147
+ */
148
+ setSizes(sizes: PanelSizeData[]): void;
149
+ /**
150
+ * Returns the size of a panel.
151
+ */
152
+ getSize(id: PanelId): number;
145
153
  /**
146
154
  * Returns the state details for a resize trigger.
147
155
  */
package/dist/index.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  var anatomy$1 = require('@zag-js/anatomy');
4
4
  var domQuery = require('@zag-js/dom-query');
5
- var core = require('@zag-js/core');
6
5
  var utils = require('@zag-js/utils');
6
+ var core = require('@zag-js/core');
7
7
  var types = require('@zag-js/types');
8
8
 
9
9
  // src/splitter.anatomy.ts
@@ -189,14 +189,22 @@ function connect(service, normalize) {
189
189
  bounds: getHandleBounds(computed("panels"), activeResizeId),
190
190
  setToMinSize(id) {
191
191
  const panel = panels.find((panel2) => panel2.id === id);
192
- send({ type: "SET_PANEL_SIZE", id, size: panel?.minSize, src: "setToMinSize" });
192
+ send({ type: "SIZE.SET", id, size: panel?.minSize, src: "setToMinSize" });
193
193
  },
194
194
  setToMaxSize(id) {
195
195
  const panel = panels.find((panel2) => panel2.id === id);
196
- send({ type: "SET_PANEL_SIZE", id, size: panel?.maxSize, src: "setToMaxSize" });
196
+ send({ type: "SIZE.SET", id, size: panel?.maxSize, src: "setToMaxSize" });
197
197
  },
198
198
  setSize(id, size) {
199
- send({ type: "SET_PANEL_SIZE", id, size });
199
+ send({ type: "SIZE.SET", id, size });
200
+ },
201
+ setSizes(sizes) {
202
+ send({ type: "SIZES.SET", sizes });
203
+ },
204
+ getSize(id) {
205
+ const panel = panels.find((panel2) => panel2.id === id);
206
+ utils.ensure(panel, `Panel with id ${id} not found`);
207
+ return panel.size;
200
208
  },
201
209
  getRootProps() {
202
210
  return normalize.element({
@@ -376,8 +384,11 @@ var machine = core.createMachine({
376
384
  panels: ({ context }) => getNormalizedPanels(context.get("size"))
377
385
  },
378
386
  on: {
379
- SET_PANEL_SIZE: {
387
+ "SIZE.SET": {
380
388
  actions: ["setPanelSize"]
389
+ },
390
+ "SIZES.SET": {
391
+ actions: ["setPanelSizes"]
381
392
  }
382
393
  },
383
394
  states: {
@@ -545,6 +556,9 @@ var machine = core.createMachine({
545
556
  })
546
557
  );
547
558
  },
559
+ setPanelSizes({ context, event }) {
560
+ context.set("size", event.sizes);
561
+ },
548
562
  setStartPanelToMin({ context, computed }) {
549
563
  const bounds = getPanelBounds(computed("panels"), context.get("activeResizeId"));
550
564
  if (!bounds) return;
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createAnatomy } from '@zag-js/anatomy';
2
2
  import { getRelativePoint, raf, trackPointerMove, dataAttr, getEventStep, getEventKey } from '@zag-js/dom-query';
3
+ import { setRafTimeout, createSplitProps, ensure } from '@zag-js/utils';
3
4
  import { createMachine } from '@zag-js/core';
4
- import { setRafTimeout, createSplitProps } from '@zag-js/utils';
5
5
  import { createProps } from '@zag-js/types';
6
6
 
7
7
  // src/splitter.anatomy.ts
@@ -187,14 +187,22 @@ function connect(service, normalize) {
187
187
  bounds: getHandleBounds(computed("panels"), activeResizeId),
188
188
  setToMinSize(id) {
189
189
  const panel = panels.find((panel2) => panel2.id === id);
190
- send({ type: "SET_PANEL_SIZE", id, size: panel?.minSize, src: "setToMinSize" });
190
+ send({ type: "SIZE.SET", id, size: panel?.minSize, src: "setToMinSize" });
191
191
  },
192
192
  setToMaxSize(id) {
193
193
  const panel = panels.find((panel2) => panel2.id === id);
194
- send({ type: "SET_PANEL_SIZE", id, size: panel?.maxSize, src: "setToMaxSize" });
194
+ send({ type: "SIZE.SET", id, size: panel?.maxSize, src: "setToMaxSize" });
195
195
  },
196
196
  setSize(id, size) {
197
- send({ type: "SET_PANEL_SIZE", id, size });
197
+ send({ type: "SIZE.SET", id, size });
198
+ },
199
+ setSizes(sizes) {
200
+ send({ type: "SIZES.SET", sizes });
201
+ },
202
+ getSize(id) {
203
+ const panel = panels.find((panel2) => panel2.id === id);
204
+ ensure(panel, `Panel with id ${id} not found`);
205
+ return panel.size;
198
206
  },
199
207
  getRootProps() {
200
208
  return normalize.element({
@@ -374,8 +382,11 @@ var machine = createMachine({
374
382
  panels: ({ context }) => getNormalizedPanels(context.get("size"))
375
383
  },
376
384
  on: {
377
- SET_PANEL_SIZE: {
385
+ "SIZE.SET": {
378
386
  actions: ["setPanelSize"]
387
+ },
388
+ "SIZES.SET": {
389
+ actions: ["setPanelSizes"]
379
390
  }
380
391
  },
381
392
  states: {
@@ -543,6 +554,9 @@ var machine = createMachine({
543
554
  })
544
555
  );
545
556
  },
557
+ setPanelSizes({ context, event }) {
558
+ context.set("size", event.sizes);
559
+ },
546
560
  setStartPanelToMin({ context, computed }) {
547
561
  const bounds = getPanelBounds(computed("panels"), context.get("activeResizeId"));
548
562
  if (!bounds) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/splitter",
3
- "version": "1.3.3",
3
+ "version": "1.4.1",
4
4
  "description": "Core logic for the splitter widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -27,11 +27,11 @@
27
27
  "url": "https://github.com/chakra-ui/zag/issues"
28
28
  },
29
29
  "dependencies": {
30
- "@zag-js/anatomy": "1.3.3",
31
- "@zag-js/types": "1.3.3",
32
- "@zag-js/core": "1.3.3",
33
- "@zag-js/dom-query": "1.3.3",
34
- "@zag-js/utils": "1.3.3"
30
+ "@zag-js/anatomy": "1.4.1",
31
+ "@zag-js/core": "1.4.1",
32
+ "@zag-js/types": "1.4.1",
33
+ "@zag-js/dom-query": "1.4.1",
34
+ "@zag-js/utils": "1.4.1"
35
35
  },
36
36
  "devDependencies": {
37
37
  "clean-package": "2.2.0"