@zag-js/splitter 1.0.0 → 1.0.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/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _zag_js_anatomy from '@zag-js/anatomy';
2
2
  import { DirectionProperty, CommonProperties, PropTypes, RequiredBy, Required, NormalizeProps } from '@zag-js/types';
3
3
  import * as _zag_js_core from '@zag-js/core';
4
- import { Service, EventObject } from '@zag-js/core';
4
+ import { Service, Machine, EventObject } from '@zag-js/core';
5
5
 
6
6
  declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "panel" | "resizeTrigger">;
7
7
 
@@ -95,6 +95,7 @@ interface SplitterSchema {
95
95
  guard: string;
96
96
  }
97
97
  type SplitterService = Service<SplitterSchema>;
98
+ type SplitterMachine = Machine<SplitterSchema>;
98
99
  interface PanelProps {
99
100
  id: PanelId;
100
101
  snapSize?: number | undefined;
@@ -152,7 +153,7 @@ interface SplitterApi<T extends PropTypes = PropTypes> {
152
153
 
153
154
  declare function connect<T extends PropTypes>(service: SplitterService, normalize: NormalizeProps<T>): SplitterApi<T>;
154
155
 
155
- declare const machine: _zag_js_core.MachineConfig<SplitterSchema>;
156
+ declare const machine: _zag_js_core.Machine<SplitterSchema>;
156
157
 
157
158
  declare const props: (keyof SplitterProps)[];
158
159
  declare const splitProps: <Props extends Partial<SplitterProps>>(props: Props) => [Partial<SplitterProps>, Omit<Props, keyof SplitterProps>];
@@ -161,4 +162,4 @@ declare const splitPanelProps: <Props extends PanelProps>(props: Props) => [Pane
161
162
  declare const resizeTriggerProps: (keyof ResizeTriggerProps)[];
162
163
  declare const splitResizeTriggerProps: <Props extends ResizeTriggerProps>(props: Props) => [ResizeTriggerProps, Omit<Props, keyof ResizeTriggerProps>];
163
164
 
164
- export { type SplitterApi as Api, type PanelProps, type PanelSizeData, type SplitterProps as Props, type ResizeTriggerProps, type SplitterService as Service, type SizeChangeDetails, anatomy, connect, machine, panelProps, props, resizeTriggerProps, splitPanelProps, splitProps, splitResizeTriggerProps };
165
+ export { type SplitterApi as Api, type SplitterMachine as Machine, type PanelProps, type PanelSizeData, type SplitterProps as Props, type ResizeTriggerProps, type SplitterService as Service, type SizeChangeDetails, anatomy, connect, machine, panelProps, props, resizeTriggerProps, splitPanelProps, splitProps, splitResizeTriggerProps };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _zag_js_anatomy from '@zag-js/anatomy';
2
2
  import { DirectionProperty, CommonProperties, PropTypes, RequiredBy, Required, NormalizeProps } from '@zag-js/types';
3
3
  import * as _zag_js_core from '@zag-js/core';
4
- import { Service, EventObject } from '@zag-js/core';
4
+ import { Service, Machine, EventObject } from '@zag-js/core';
5
5
 
6
6
  declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "panel" | "resizeTrigger">;
7
7
 
@@ -95,6 +95,7 @@ interface SplitterSchema {
95
95
  guard: string;
96
96
  }
97
97
  type SplitterService = Service<SplitterSchema>;
98
+ type SplitterMachine = Machine<SplitterSchema>;
98
99
  interface PanelProps {
99
100
  id: PanelId;
100
101
  snapSize?: number | undefined;
@@ -152,7 +153,7 @@ interface SplitterApi<T extends PropTypes = PropTypes> {
152
153
 
153
154
  declare function connect<T extends PropTypes>(service: SplitterService, normalize: NormalizeProps<T>): SplitterApi<T>;
154
155
 
155
- declare const machine: _zag_js_core.MachineConfig<SplitterSchema>;
156
+ declare const machine: _zag_js_core.Machine<SplitterSchema>;
156
157
 
157
158
  declare const props: (keyof SplitterProps)[];
158
159
  declare const splitProps: <Props extends Partial<SplitterProps>>(props: Props) => [Partial<SplitterProps>, Omit<Props, keyof SplitterProps>];
@@ -161,4 +162,4 @@ declare const splitPanelProps: <Props extends PanelProps>(props: Props) => [Pane
161
162
  declare const resizeTriggerProps: (keyof ResizeTriggerProps)[];
162
163
  declare const splitResizeTriggerProps: <Props extends ResizeTriggerProps>(props: Props) => [ResizeTriggerProps, Omit<Props, keyof ResizeTriggerProps>];
163
164
 
164
- export { type SplitterApi as Api, type PanelProps, type PanelSizeData, type SplitterProps as Props, type ResizeTriggerProps, type SplitterService as Service, type SizeChangeDetails, anatomy, connect, machine, panelProps, props, resizeTriggerProps, splitPanelProps, splitProps, splitResizeTriggerProps };
165
+ export { type SplitterApi as Api, type SplitterMachine as Machine, type PanelProps, type PanelSizeData, type SplitterProps as Props, type ResizeTriggerProps, type SplitterService as Service, type SizeChangeDetails, anatomy, connect, machine, panelProps, props, resizeTriggerProps, splitPanelProps, splitProps, splitResizeTriggerProps };
package/dist/index.js CHANGED
@@ -331,7 +331,7 @@ var machine = core.createMachine({
331
331
  return {
332
332
  orientation: "horizontal",
333
333
  defaultSize: [],
334
- ...utils.compact(props2)
334
+ ...props2
335
335
  };
336
336
  },
337
337
  initialState() {
@@ -392,6 +392,10 @@ var machine = core.createMachine({
392
392
  target: "focused",
393
393
  actions: ["setActiveHandleId"]
394
394
  },
395
+ POINTER_DOWN: {
396
+ target: "dragging",
397
+ actions: ["setActiveHandleId"]
398
+ },
395
399
  DOUBLE_CLICK: {
396
400
  actions: ["resetStartPanel", "setPreviousPanels"]
397
401
  }
@@ -482,10 +486,9 @@ var machine = core.createMachine({
482
486
  implementations: {
483
487
  effects: {
484
488
  waitForHoverDelay: ({ send }) => {
485
- const id = setTimeout(() => {
489
+ return utils.setRafTimeout(() => {
486
490
  send({ type: "HOVER_DELAY" });
487
491
  }, 250);
488
- return () => clearTimeout(id);
489
492
  },
490
493
  trackPointerMove: ({ scope, send }) => {
491
494
  const doc = scope.getDoc();
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createAnatomy } from '@zag-js/anatomy';
2
2
  import { trackPointerMove, raf, getRelativePoint, dataAttr, getEventStep, getEventKey } from '@zag-js/dom-query';
3
3
  import { createMachine } from '@zag-js/core';
4
- import { compact, createSplitProps } from '@zag-js/utils';
4
+ import { setRafTimeout, createSplitProps } from '@zag-js/utils';
5
5
  import { createProps } from '@zag-js/types';
6
6
 
7
7
  // src/splitter.anatomy.ts
@@ -329,7 +329,7 @@ var machine = createMachine({
329
329
  return {
330
330
  orientation: "horizontal",
331
331
  defaultSize: [],
332
- ...compact(props2)
332
+ ...props2
333
333
  };
334
334
  },
335
335
  initialState() {
@@ -390,6 +390,10 @@ var machine = createMachine({
390
390
  target: "focused",
391
391
  actions: ["setActiveHandleId"]
392
392
  },
393
+ POINTER_DOWN: {
394
+ target: "dragging",
395
+ actions: ["setActiveHandleId"]
396
+ },
393
397
  DOUBLE_CLICK: {
394
398
  actions: ["resetStartPanel", "setPreviousPanels"]
395
399
  }
@@ -480,10 +484,9 @@ var machine = createMachine({
480
484
  implementations: {
481
485
  effects: {
482
486
  waitForHoverDelay: ({ send }) => {
483
- const id = setTimeout(() => {
487
+ return setRafTimeout(() => {
484
488
  send({ type: "HOVER_DELAY" });
485
489
  }, 250);
486
- return () => clearTimeout(id);
487
490
  },
488
491
  trackPointerMove: ({ scope, send }) => {
489
492
  const doc = scope.getDoc();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/splitter",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
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.0.0",
31
- "@zag-js/core": "1.0.0",
32
- "@zag-js/types": "1.0.0",
33
- "@zag-js/dom-query": "1.0.0",
34
- "@zag-js/utils": "1.0.0"
30
+ "@zag-js/anatomy": "1.0.2",
31
+ "@zag-js/core": "1.0.2",
32
+ "@zag-js/types": "1.0.2",
33
+ "@zag-js/dom-query": "1.0.2",
34
+ "@zag-js/utils": "1.0.2"
35
35
  },
36
36
  "devDependencies": {
37
37
  "clean-package": "2.2.0"