@zag-js/splitter 1.27.1 → 1.29.0
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 +24 -2
- package/dist/index.d.ts +24 -2
- package/dist/index.js +54 -21
- package/dist/index.mjs +54 -21
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { RequiredBy, DirectionProperty, CommonProperties, PropTypes, NormalizePr
|
|
|
3
3
|
import * as _zag_js_core from '@zag-js/core';
|
|
4
4
|
import { Service, EventObject, Machine } from '@zag-js/core';
|
|
5
5
|
|
|
6
|
-
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "panel" | "resizeTrigger">;
|
|
6
|
+
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "panel" | "resizeTrigger" | "resizeTriggerIndicator">;
|
|
7
7
|
|
|
8
8
|
type ResizeEvent = PointerEvent | KeyboardEvent;
|
|
9
9
|
type PanelId = string;
|
|
@@ -153,6 +153,11 @@ interface ResizeTriggerProps {
|
|
|
153
153
|
id: ResizeTriggerId;
|
|
154
154
|
disabled?: boolean | undefined;
|
|
155
155
|
}
|
|
156
|
+
interface ResizeTriggerState {
|
|
157
|
+
dragging: boolean;
|
|
158
|
+
focused: boolean;
|
|
159
|
+
disabled: boolean;
|
|
160
|
+
}
|
|
156
161
|
interface PanelItem {
|
|
157
162
|
type: "panel";
|
|
158
163
|
id: PanelId;
|
|
@@ -167,6 +172,10 @@ interface SplitterApi<T extends PropTypes = PropTypes> {
|
|
|
167
172
|
* Whether the splitter is currently being resized.
|
|
168
173
|
*/
|
|
169
174
|
dragging: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* The orientation of the splitter.
|
|
177
|
+
*/
|
|
178
|
+
orientation: "horizontal" | "vertical";
|
|
170
179
|
/**
|
|
171
180
|
* Returns the current sizes of the panels.
|
|
172
181
|
*/
|
|
@@ -179,6 +188,14 @@ interface SplitterApi<T extends PropTypes = PropTypes> {
|
|
|
179
188
|
* Returns the items of the splitter.
|
|
180
189
|
*/
|
|
181
190
|
getItems: () => SplitterItem[];
|
|
191
|
+
/**
|
|
192
|
+
* Returns the panels of the splitter.
|
|
193
|
+
*/
|
|
194
|
+
getPanels: () => PanelData[];
|
|
195
|
+
/**
|
|
196
|
+
* Returns the panel with the specified id.
|
|
197
|
+
*/
|
|
198
|
+
getPanelById: (id: PanelId) => PanelData;
|
|
182
199
|
/**
|
|
183
200
|
* Returns the size of the specified panel.
|
|
184
201
|
*/
|
|
@@ -211,9 +228,14 @@ interface SplitterApi<T extends PropTypes = PropTypes> {
|
|
|
211
228
|
* Resets the splitter to its initial state.
|
|
212
229
|
*/
|
|
213
230
|
resetSizes: VoidFunction;
|
|
231
|
+
/**
|
|
232
|
+
* Returns the state of the resize trigger.
|
|
233
|
+
*/
|
|
234
|
+
getResizeTriggerState: (props: ResizeTriggerProps) => ResizeTriggerState;
|
|
214
235
|
getRootProps: () => T["element"];
|
|
215
236
|
getPanelProps: (props: PanelProps) => T["element"];
|
|
216
237
|
getResizeTriggerProps: (props: ResizeTriggerProps) => T["element"];
|
|
238
|
+
getResizeTriggerIndicator: (props: ResizeTriggerProps) => T["element"];
|
|
217
239
|
}
|
|
218
240
|
|
|
219
241
|
declare function connect<T extends PropTypes>(service: SplitterService, normalize: NormalizeProps<T>): SplitterApi<T>;
|
|
@@ -229,4 +251,4 @@ declare const splitResizeTriggerProps: <Props extends ResizeTriggerProps>(props:
|
|
|
229
251
|
|
|
230
252
|
declare function getPanelLayout(panels: PanelData[]): string;
|
|
231
253
|
|
|
232
|
-
export { type SplitterApi as Api, type CursorState, type DragState, type ElementIds, type ExpandCollapseDetails, type SplitterItem as Item, type KeyboardState, type SplitterMachine as Machine, type PanelData, type PanelId, type PanelItem, type PanelProps, type SplitterProps as Props, type ResizeDetails, type ResizeEndDetails, type ResizeEvent, type ResizeTriggerId, type ResizeTriggerItem, type ResizeTriggerProps, type SplitterService as Service, anatomy, connect, getPanelLayout as layout, machine, panelProps, props, resizeTriggerProps, splitPanelProps, splitProps, splitResizeTriggerProps };
|
|
254
|
+
export { type SplitterApi as Api, type CursorState, type DragState, type ElementIds, type ExpandCollapseDetails, type SplitterItem as Item, type KeyboardState, type SplitterMachine as Machine, type PanelData, type PanelId, type PanelItem, type PanelProps, type SplitterProps as Props, type ResizeDetails, type ResizeEndDetails, type ResizeEvent, type ResizeTriggerId, type ResizeTriggerItem, type ResizeTriggerProps, type ResizeTriggerState, type SplitterService as Service, anatomy, connect, getPanelLayout as layout, machine, panelProps, props, resizeTriggerProps, splitPanelProps, splitProps, splitResizeTriggerProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { RequiredBy, DirectionProperty, CommonProperties, PropTypes, NormalizePr
|
|
|
3
3
|
import * as _zag_js_core from '@zag-js/core';
|
|
4
4
|
import { Service, EventObject, Machine } from '@zag-js/core';
|
|
5
5
|
|
|
6
|
-
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "panel" | "resizeTrigger">;
|
|
6
|
+
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "panel" | "resizeTrigger" | "resizeTriggerIndicator">;
|
|
7
7
|
|
|
8
8
|
type ResizeEvent = PointerEvent | KeyboardEvent;
|
|
9
9
|
type PanelId = string;
|
|
@@ -153,6 +153,11 @@ interface ResizeTriggerProps {
|
|
|
153
153
|
id: ResizeTriggerId;
|
|
154
154
|
disabled?: boolean | undefined;
|
|
155
155
|
}
|
|
156
|
+
interface ResizeTriggerState {
|
|
157
|
+
dragging: boolean;
|
|
158
|
+
focused: boolean;
|
|
159
|
+
disabled: boolean;
|
|
160
|
+
}
|
|
156
161
|
interface PanelItem {
|
|
157
162
|
type: "panel";
|
|
158
163
|
id: PanelId;
|
|
@@ -167,6 +172,10 @@ interface SplitterApi<T extends PropTypes = PropTypes> {
|
|
|
167
172
|
* Whether the splitter is currently being resized.
|
|
168
173
|
*/
|
|
169
174
|
dragging: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* The orientation of the splitter.
|
|
177
|
+
*/
|
|
178
|
+
orientation: "horizontal" | "vertical";
|
|
170
179
|
/**
|
|
171
180
|
* Returns the current sizes of the panels.
|
|
172
181
|
*/
|
|
@@ -179,6 +188,14 @@ interface SplitterApi<T extends PropTypes = PropTypes> {
|
|
|
179
188
|
* Returns the items of the splitter.
|
|
180
189
|
*/
|
|
181
190
|
getItems: () => SplitterItem[];
|
|
191
|
+
/**
|
|
192
|
+
* Returns the panels of the splitter.
|
|
193
|
+
*/
|
|
194
|
+
getPanels: () => PanelData[];
|
|
195
|
+
/**
|
|
196
|
+
* Returns the panel with the specified id.
|
|
197
|
+
*/
|
|
198
|
+
getPanelById: (id: PanelId) => PanelData;
|
|
182
199
|
/**
|
|
183
200
|
* Returns the size of the specified panel.
|
|
184
201
|
*/
|
|
@@ -211,9 +228,14 @@ interface SplitterApi<T extends PropTypes = PropTypes> {
|
|
|
211
228
|
* Resets the splitter to its initial state.
|
|
212
229
|
*/
|
|
213
230
|
resetSizes: VoidFunction;
|
|
231
|
+
/**
|
|
232
|
+
* Returns the state of the resize trigger.
|
|
233
|
+
*/
|
|
234
|
+
getResizeTriggerState: (props: ResizeTriggerProps) => ResizeTriggerState;
|
|
214
235
|
getRootProps: () => T["element"];
|
|
215
236
|
getPanelProps: (props: PanelProps) => T["element"];
|
|
216
237
|
getResizeTriggerProps: (props: ResizeTriggerProps) => T["element"];
|
|
238
|
+
getResizeTriggerIndicator: (props: ResizeTriggerProps) => T["element"];
|
|
217
239
|
}
|
|
218
240
|
|
|
219
241
|
declare function connect<T extends PropTypes>(service: SplitterService, normalize: NormalizeProps<T>): SplitterApi<T>;
|
|
@@ -229,4 +251,4 @@ declare const splitResizeTriggerProps: <Props extends ResizeTriggerProps>(props:
|
|
|
229
251
|
|
|
230
252
|
declare function getPanelLayout(panels: PanelData[]): string;
|
|
231
253
|
|
|
232
|
-
export { type SplitterApi as Api, type CursorState, type DragState, type ElementIds, type ExpandCollapseDetails, type SplitterItem as Item, type KeyboardState, type SplitterMachine as Machine, type PanelData, type PanelId, type PanelItem, type PanelProps, type SplitterProps as Props, type ResizeDetails, type ResizeEndDetails, type ResizeEvent, type ResizeTriggerId, type ResizeTriggerItem, type ResizeTriggerProps, type SplitterService as Service, anatomy, connect, getPanelLayout as layout, machine, panelProps, props, resizeTriggerProps, splitPanelProps, splitProps, splitResizeTriggerProps };
|
|
254
|
+
export { type SplitterApi as Api, type CursorState, type DragState, type ElementIds, type ExpandCollapseDetails, type SplitterItem as Item, type KeyboardState, type SplitterMachine as Machine, type PanelData, type PanelId, type PanelItem, type PanelProps, type SplitterProps as Props, type ResizeDetails, type ResizeEndDetails, type ResizeEvent, type ResizeTriggerId, type ResizeTriggerItem, type ResizeTriggerProps, type ResizeTriggerState, type SplitterService as Service, anatomy, connect, getPanelLayout as layout, machine, panelProps, props, resizeTriggerProps, splitPanelProps, splitProps, splitResizeTriggerProps };
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var core = require('@zag-js/core');
|
|
|
7
7
|
var types = require('@zag-js/types');
|
|
8
8
|
|
|
9
9
|
// src/splitter.anatomy.ts
|
|
10
|
-
var anatomy = anatomy$1.createAnatomy("splitter").parts("root", "panel", "resizeTrigger");
|
|
10
|
+
var anatomy = anatomy$1.createAnatomy("splitter").parts("root", "panel", "resizeTrigger", "resizeTriggerIndicator");
|
|
11
11
|
var parts = anatomy.build();
|
|
12
12
|
var getRootId = (ctx) => ctx.ids?.root ?? `splitter:${ctx.id}`;
|
|
13
13
|
var getResizeTriggerId = (ctx, id) => ctx.ids?.resizeTrigger?.(id) ?? `splitter:${ctx.id}:splitter:${id}`;
|
|
@@ -222,6 +222,7 @@ function connect(service, normalize) {
|
|
|
222
222
|
const { state, send, prop, computed, context, scope } = service;
|
|
223
223
|
const horizontal = computed("horizontal");
|
|
224
224
|
const dragging = state.matches("dragging");
|
|
225
|
+
const orientation = prop("orientation");
|
|
225
226
|
const getPanelStyle = (id) => {
|
|
226
227
|
const panels = prop("panels");
|
|
227
228
|
const panelIndex = panels.findIndex((panel) => panel.id === id);
|
|
@@ -235,8 +236,25 @@ function connect(service, normalize) {
|
|
|
235
236
|
panelIndex
|
|
236
237
|
});
|
|
237
238
|
};
|
|
239
|
+
const getResizeTriggerState = (props2) => {
|
|
240
|
+
const { id, disabled } = props2;
|
|
241
|
+
const dragging2 = context.get("dragState")?.resizeTriggerId === id;
|
|
242
|
+
const focused = dragging2 || context.get("keyboardState")?.resizeTriggerId === id;
|
|
243
|
+
return {
|
|
244
|
+
dragging: dragging2,
|
|
245
|
+
focused,
|
|
246
|
+
disabled: !!disabled
|
|
247
|
+
};
|
|
248
|
+
};
|
|
238
249
|
return {
|
|
239
250
|
dragging,
|
|
251
|
+
orientation,
|
|
252
|
+
getPanels() {
|
|
253
|
+
return prop("panels");
|
|
254
|
+
},
|
|
255
|
+
getPanelById(id) {
|
|
256
|
+
return getPanelById(prop("panels"), id);
|
|
257
|
+
},
|
|
240
258
|
getItems() {
|
|
241
259
|
return prop("panels").flatMap((panel, index, arr) => {
|
|
242
260
|
const nextPanel = arr[index + 1];
|
|
@@ -297,7 +315,8 @@ function connect(service, normalize) {
|
|
|
297
315
|
getRootProps() {
|
|
298
316
|
return normalize.element({
|
|
299
317
|
...parts.root.attrs,
|
|
300
|
-
"data-orientation":
|
|
318
|
+
"data-orientation": orientation,
|
|
319
|
+
"data-dragging": domQuery.dataAttr(dragging),
|
|
301
320
|
id: getRootId(scope),
|
|
302
321
|
dir: prop("dir"),
|
|
303
322
|
style: {
|
|
@@ -313,7 +332,8 @@ function connect(service, normalize) {
|
|
|
313
332
|
const { id } = props2;
|
|
314
333
|
return normalize.element({
|
|
315
334
|
...parts.panel.attrs,
|
|
316
|
-
"data-orientation":
|
|
335
|
+
"data-orientation": orientation,
|
|
336
|
+
"data-dragging": domQuery.dataAttr(dragging),
|
|
317
337
|
dir: prop("dir"),
|
|
318
338
|
"data-id": id,
|
|
319
339
|
"data-index": findPanelIndex(prop("panels"), id),
|
|
@@ -322,11 +342,22 @@ function connect(service, normalize) {
|
|
|
322
342
|
style: getPanelStyle(id)
|
|
323
343
|
});
|
|
324
344
|
},
|
|
345
|
+
getResizeTriggerState,
|
|
346
|
+
getResizeTriggerIndicator(props2) {
|
|
347
|
+
const triggerState = getResizeTriggerState(props2);
|
|
348
|
+
return normalize.element({
|
|
349
|
+
...parts.resizeTriggerIndicator.attrs,
|
|
350
|
+
"data-orientation": orientation,
|
|
351
|
+
"data-focus": domQuery.dataAttr(triggerState.focused),
|
|
352
|
+
"data-dragging": domQuery.dataAttr(triggerState.dragging),
|
|
353
|
+
"data-disabled": domQuery.dataAttr(triggerState.disabled),
|
|
354
|
+
"data-ownedby": getRootId(scope)
|
|
355
|
+
});
|
|
356
|
+
},
|
|
325
357
|
getResizeTriggerProps(props2) {
|
|
326
|
-
const { id
|
|
358
|
+
const { id } = props2;
|
|
359
|
+
const triggerState = getResizeTriggerState(props2);
|
|
327
360
|
const aria = getAriaValue(context.get("size"), prop("panels"), id);
|
|
328
|
-
const dragging2 = context.get("dragState")?.resizeTriggerId === id;
|
|
329
|
-
const focused = dragging2 || context.get("keyboardState")?.resizeTriggerId === id;
|
|
330
361
|
return normalize.element({
|
|
331
362
|
...parts.resizeTrigger.attrs,
|
|
332
363
|
dir: prop("dir"),
|
|
@@ -334,27 +365,28 @@ function connect(service, normalize) {
|
|
|
334
365
|
role: "separator",
|
|
335
366
|
"data-id": id,
|
|
336
367
|
"data-ownedby": getRootId(scope),
|
|
337
|
-
tabIndex: disabled ? void 0 : 0,
|
|
368
|
+
tabIndex: triggerState.disabled ? void 0 : 0,
|
|
338
369
|
"aria-valuenow": aria.valueNow,
|
|
339
370
|
"aria-valuemin": aria.valueMin,
|
|
340
371
|
"aria-valuemax": aria.valueMax,
|
|
341
|
-
"data-orientation":
|
|
342
|
-
"aria-orientation":
|
|
372
|
+
"data-orientation": orientation,
|
|
373
|
+
"aria-orientation": orientation,
|
|
343
374
|
"aria-controls": `${getPanelId(scope, aria.beforeId)} ${getPanelId(scope, aria.afterId)}`,
|
|
344
|
-
"data-focus": domQuery.dataAttr(focused),
|
|
345
|
-
"data-
|
|
375
|
+
"data-focus": domQuery.dataAttr(triggerState.focused),
|
|
376
|
+
"data-dragging": domQuery.dataAttr(triggerState.dragging),
|
|
377
|
+
"data-disabled": domQuery.dataAttr(triggerState.disabled),
|
|
346
378
|
style: {
|
|
347
379
|
touchAction: "none",
|
|
348
380
|
userSelect: "none",
|
|
349
381
|
WebkitUserSelect: "none",
|
|
350
382
|
flex: "0 0 auto",
|
|
351
|
-
pointerEvents:
|
|
352
|
-
cursor: horizontal ? "col-resize" : "row-resize",
|
|
383
|
+
pointerEvents: triggerState.disabled ? "none" : triggerState.dragging && !triggerState.focused ? "none" : void 0,
|
|
384
|
+
cursor: triggerState.disabled ? void 0 : horizontal ? "col-resize" : "row-resize",
|
|
353
385
|
[horizontal ? "minHeight" : "minWidth"]: "0"
|
|
354
386
|
},
|
|
355
387
|
onPointerDown(event) {
|
|
356
388
|
if (!domQuery.isLeftClick(event)) return;
|
|
357
|
-
if (disabled) {
|
|
389
|
+
if (triggerState.disabled) {
|
|
358
390
|
event.preventDefault();
|
|
359
391
|
return;
|
|
360
392
|
}
|
|
@@ -365,30 +397,30 @@ function connect(service, normalize) {
|
|
|
365
397
|
event.stopPropagation();
|
|
366
398
|
},
|
|
367
399
|
onPointerUp(event) {
|
|
368
|
-
if (disabled) return;
|
|
400
|
+
if (triggerState.disabled) return;
|
|
369
401
|
if (event.currentTarget.hasPointerCapture(event.pointerId)) {
|
|
370
402
|
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
371
403
|
}
|
|
372
404
|
},
|
|
373
405
|
onPointerOver() {
|
|
374
|
-
if (disabled) return;
|
|
406
|
+
if (triggerState.disabled) return;
|
|
375
407
|
send({ type: "POINTER_OVER", id });
|
|
376
408
|
},
|
|
377
409
|
onPointerLeave() {
|
|
378
|
-
if (disabled) return;
|
|
410
|
+
if (triggerState.disabled) return;
|
|
379
411
|
send({ type: "POINTER_LEAVE", id });
|
|
380
412
|
},
|
|
381
413
|
onBlur() {
|
|
382
|
-
if (disabled) return;
|
|
414
|
+
if (triggerState.disabled) return;
|
|
383
415
|
send({ type: "BLUR" });
|
|
384
416
|
},
|
|
385
417
|
onFocus() {
|
|
386
|
-
if (disabled) return;
|
|
418
|
+
if (triggerState.disabled) return;
|
|
387
419
|
send({ type: "FOCUS", id });
|
|
388
420
|
},
|
|
389
421
|
onKeyDown(event) {
|
|
390
422
|
if (event.defaultPrevented) return;
|
|
391
|
-
if (disabled) return;
|
|
423
|
+
if (triggerState.disabled) return;
|
|
392
424
|
const keyboardResizeBy = prop("keyboardResizeBy");
|
|
393
425
|
let delta = 0;
|
|
394
426
|
if (event.shiftKey) {
|
|
@@ -426,7 +458,7 @@ function connect(service, normalize) {
|
|
|
426
458
|
};
|
|
427
459
|
const key = domQuery.getEventKey(event, {
|
|
428
460
|
dir: prop("dir"),
|
|
429
|
-
orientation
|
|
461
|
+
orientation
|
|
430
462
|
});
|
|
431
463
|
const exec = keyMap[key];
|
|
432
464
|
if (exec) {
|
|
@@ -712,6 +744,7 @@ var machine = core.createMachine({
|
|
|
712
744
|
}
|
|
713
745
|
},
|
|
714
746
|
entry: ["syncSize"],
|
|
747
|
+
exit: ["clearGlobalCursor"],
|
|
715
748
|
states: {
|
|
716
749
|
idle: {
|
|
717
750
|
entry: ["clearDraggingState", "clearKeyboardState"],
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { createMachine } from '@zag-js/core';
|
|
|
5
5
|
import { createProps } from '@zag-js/types';
|
|
6
6
|
|
|
7
7
|
// src/splitter.anatomy.ts
|
|
8
|
-
var anatomy = createAnatomy("splitter").parts("root", "panel", "resizeTrigger");
|
|
8
|
+
var anatomy = createAnatomy("splitter").parts("root", "panel", "resizeTrigger", "resizeTriggerIndicator");
|
|
9
9
|
var parts = anatomy.build();
|
|
10
10
|
var getRootId = (ctx) => ctx.ids?.root ?? `splitter:${ctx.id}`;
|
|
11
11
|
var getResizeTriggerId = (ctx, id) => ctx.ids?.resizeTrigger?.(id) ?? `splitter:${ctx.id}:splitter:${id}`;
|
|
@@ -220,6 +220,7 @@ function connect(service, normalize) {
|
|
|
220
220
|
const { state, send, prop, computed, context, scope } = service;
|
|
221
221
|
const horizontal = computed("horizontal");
|
|
222
222
|
const dragging = state.matches("dragging");
|
|
223
|
+
const orientation = prop("orientation");
|
|
223
224
|
const getPanelStyle = (id) => {
|
|
224
225
|
const panels = prop("panels");
|
|
225
226
|
const panelIndex = panels.findIndex((panel) => panel.id === id);
|
|
@@ -233,8 +234,25 @@ function connect(service, normalize) {
|
|
|
233
234
|
panelIndex
|
|
234
235
|
});
|
|
235
236
|
};
|
|
237
|
+
const getResizeTriggerState = (props2) => {
|
|
238
|
+
const { id, disabled } = props2;
|
|
239
|
+
const dragging2 = context.get("dragState")?.resizeTriggerId === id;
|
|
240
|
+
const focused = dragging2 || context.get("keyboardState")?.resizeTriggerId === id;
|
|
241
|
+
return {
|
|
242
|
+
dragging: dragging2,
|
|
243
|
+
focused,
|
|
244
|
+
disabled: !!disabled
|
|
245
|
+
};
|
|
246
|
+
};
|
|
236
247
|
return {
|
|
237
248
|
dragging,
|
|
249
|
+
orientation,
|
|
250
|
+
getPanels() {
|
|
251
|
+
return prop("panels");
|
|
252
|
+
},
|
|
253
|
+
getPanelById(id) {
|
|
254
|
+
return getPanelById(prop("panels"), id);
|
|
255
|
+
},
|
|
238
256
|
getItems() {
|
|
239
257
|
return prop("panels").flatMap((panel, index, arr) => {
|
|
240
258
|
const nextPanel = arr[index + 1];
|
|
@@ -295,7 +313,8 @@ function connect(service, normalize) {
|
|
|
295
313
|
getRootProps() {
|
|
296
314
|
return normalize.element({
|
|
297
315
|
...parts.root.attrs,
|
|
298
|
-
"data-orientation":
|
|
316
|
+
"data-orientation": orientation,
|
|
317
|
+
"data-dragging": dataAttr(dragging),
|
|
299
318
|
id: getRootId(scope),
|
|
300
319
|
dir: prop("dir"),
|
|
301
320
|
style: {
|
|
@@ -311,7 +330,8 @@ function connect(service, normalize) {
|
|
|
311
330
|
const { id } = props2;
|
|
312
331
|
return normalize.element({
|
|
313
332
|
...parts.panel.attrs,
|
|
314
|
-
"data-orientation":
|
|
333
|
+
"data-orientation": orientation,
|
|
334
|
+
"data-dragging": dataAttr(dragging),
|
|
315
335
|
dir: prop("dir"),
|
|
316
336
|
"data-id": id,
|
|
317
337
|
"data-index": findPanelIndex(prop("panels"), id),
|
|
@@ -320,11 +340,22 @@ function connect(service, normalize) {
|
|
|
320
340
|
style: getPanelStyle(id)
|
|
321
341
|
});
|
|
322
342
|
},
|
|
343
|
+
getResizeTriggerState,
|
|
344
|
+
getResizeTriggerIndicator(props2) {
|
|
345
|
+
const triggerState = getResizeTriggerState(props2);
|
|
346
|
+
return normalize.element({
|
|
347
|
+
...parts.resizeTriggerIndicator.attrs,
|
|
348
|
+
"data-orientation": orientation,
|
|
349
|
+
"data-focus": dataAttr(triggerState.focused),
|
|
350
|
+
"data-dragging": dataAttr(triggerState.dragging),
|
|
351
|
+
"data-disabled": dataAttr(triggerState.disabled),
|
|
352
|
+
"data-ownedby": getRootId(scope)
|
|
353
|
+
});
|
|
354
|
+
},
|
|
323
355
|
getResizeTriggerProps(props2) {
|
|
324
|
-
const { id
|
|
356
|
+
const { id } = props2;
|
|
357
|
+
const triggerState = getResizeTriggerState(props2);
|
|
325
358
|
const aria = getAriaValue(context.get("size"), prop("panels"), id);
|
|
326
|
-
const dragging2 = context.get("dragState")?.resizeTriggerId === id;
|
|
327
|
-
const focused = dragging2 || context.get("keyboardState")?.resizeTriggerId === id;
|
|
328
359
|
return normalize.element({
|
|
329
360
|
...parts.resizeTrigger.attrs,
|
|
330
361
|
dir: prop("dir"),
|
|
@@ -332,27 +363,28 @@ function connect(service, normalize) {
|
|
|
332
363
|
role: "separator",
|
|
333
364
|
"data-id": id,
|
|
334
365
|
"data-ownedby": getRootId(scope),
|
|
335
|
-
tabIndex: disabled ? void 0 : 0,
|
|
366
|
+
tabIndex: triggerState.disabled ? void 0 : 0,
|
|
336
367
|
"aria-valuenow": aria.valueNow,
|
|
337
368
|
"aria-valuemin": aria.valueMin,
|
|
338
369
|
"aria-valuemax": aria.valueMax,
|
|
339
|
-
"data-orientation":
|
|
340
|
-
"aria-orientation":
|
|
370
|
+
"data-orientation": orientation,
|
|
371
|
+
"aria-orientation": orientation,
|
|
341
372
|
"aria-controls": `${getPanelId(scope, aria.beforeId)} ${getPanelId(scope, aria.afterId)}`,
|
|
342
|
-
"data-focus": dataAttr(focused),
|
|
343
|
-
"data-
|
|
373
|
+
"data-focus": dataAttr(triggerState.focused),
|
|
374
|
+
"data-dragging": dataAttr(triggerState.dragging),
|
|
375
|
+
"data-disabled": dataAttr(triggerState.disabled),
|
|
344
376
|
style: {
|
|
345
377
|
touchAction: "none",
|
|
346
378
|
userSelect: "none",
|
|
347
379
|
WebkitUserSelect: "none",
|
|
348
380
|
flex: "0 0 auto",
|
|
349
|
-
pointerEvents:
|
|
350
|
-
cursor: horizontal ? "col-resize" : "row-resize",
|
|
381
|
+
pointerEvents: triggerState.disabled ? "none" : triggerState.dragging && !triggerState.focused ? "none" : void 0,
|
|
382
|
+
cursor: triggerState.disabled ? void 0 : horizontal ? "col-resize" : "row-resize",
|
|
351
383
|
[horizontal ? "minHeight" : "minWidth"]: "0"
|
|
352
384
|
},
|
|
353
385
|
onPointerDown(event) {
|
|
354
386
|
if (!isLeftClick(event)) return;
|
|
355
|
-
if (disabled) {
|
|
387
|
+
if (triggerState.disabled) {
|
|
356
388
|
event.preventDefault();
|
|
357
389
|
return;
|
|
358
390
|
}
|
|
@@ -363,30 +395,30 @@ function connect(service, normalize) {
|
|
|
363
395
|
event.stopPropagation();
|
|
364
396
|
},
|
|
365
397
|
onPointerUp(event) {
|
|
366
|
-
if (disabled) return;
|
|
398
|
+
if (triggerState.disabled) return;
|
|
367
399
|
if (event.currentTarget.hasPointerCapture(event.pointerId)) {
|
|
368
400
|
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
369
401
|
}
|
|
370
402
|
},
|
|
371
403
|
onPointerOver() {
|
|
372
|
-
if (disabled) return;
|
|
404
|
+
if (triggerState.disabled) return;
|
|
373
405
|
send({ type: "POINTER_OVER", id });
|
|
374
406
|
},
|
|
375
407
|
onPointerLeave() {
|
|
376
|
-
if (disabled) return;
|
|
408
|
+
if (triggerState.disabled) return;
|
|
377
409
|
send({ type: "POINTER_LEAVE", id });
|
|
378
410
|
},
|
|
379
411
|
onBlur() {
|
|
380
|
-
if (disabled) return;
|
|
412
|
+
if (triggerState.disabled) return;
|
|
381
413
|
send({ type: "BLUR" });
|
|
382
414
|
},
|
|
383
415
|
onFocus() {
|
|
384
|
-
if (disabled) return;
|
|
416
|
+
if (triggerState.disabled) return;
|
|
385
417
|
send({ type: "FOCUS", id });
|
|
386
418
|
},
|
|
387
419
|
onKeyDown(event) {
|
|
388
420
|
if (event.defaultPrevented) return;
|
|
389
|
-
if (disabled) return;
|
|
421
|
+
if (triggerState.disabled) return;
|
|
390
422
|
const keyboardResizeBy = prop("keyboardResizeBy");
|
|
391
423
|
let delta = 0;
|
|
392
424
|
if (event.shiftKey) {
|
|
@@ -424,7 +456,7 @@ function connect(service, normalize) {
|
|
|
424
456
|
};
|
|
425
457
|
const key = getEventKey(event, {
|
|
426
458
|
dir: prop("dir"),
|
|
427
|
-
orientation
|
|
459
|
+
orientation
|
|
428
460
|
});
|
|
429
461
|
const exec = keyMap[key];
|
|
430
462
|
if (exec) {
|
|
@@ -710,6 +742,7 @@ var machine = createMachine({
|
|
|
710
742
|
}
|
|
711
743
|
},
|
|
712
744
|
entry: ["syncSize"],
|
|
745
|
+
exit: ["clearGlobalCursor"],
|
|
713
746
|
states: {
|
|
714
747
|
idle: {
|
|
715
748
|
entry: ["clearDraggingState", "clearKeyboardState"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/splitter",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.29.0",
|
|
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.
|
|
31
|
-
"@zag-js/core": "1.
|
|
32
|
-
"@zag-js/types": "1.
|
|
33
|
-
"@zag-js/dom-query": "1.
|
|
34
|
-
"@zag-js/utils": "1.
|
|
30
|
+
"@zag-js/anatomy": "1.29.0",
|
|
31
|
+
"@zag-js/core": "1.29.0",
|
|
32
|
+
"@zag-js/types": "1.29.0",
|
|
33
|
+
"@zag-js/dom-query": "1.29.0",
|
|
34
|
+
"@zag-js/utils": "1.29.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"clean-package": "2.2.0"
|