@destyler/splitter 0.0.7-beta.7 → 0.1.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.js ADDED
@@ -0,0 +1,666 @@
1
+ import { createAnatomy } from "@destyler/anatomy";
2
+ import { createScope, dataAttr, getEventKey, getEventStep, getRelativePoint, queryAll, raf, trackPointerMove } from "@destyler/dom";
3
+ import { compact, createSplitProps } from "@destyler/utils";
4
+ import { createMachine } from "@destyler/xstate";
5
+ import { createProps } from "@destyler/types";
6
+
7
+ //#region src/anatomy.ts
8
+ const anatomy = createAnatomy("splitter").parts("root", "panel", "resizeTrigger");
9
+ const parts = anatomy.build();
10
+
11
+ //#endregion
12
+ //#region src/dom.ts
13
+ const dom = createScope({
14
+ getRootId: (ctx) => ctx.ids?.root ?? `splitter:${ctx.id}`,
15
+ getResizeTriggerId: (ctx, id) => ctx.ids?.resizeTrigger?.(id) ?? `splitter:${ctx.id}:splitter:${id}`,
16
+ getLabelId: (ctx) => ctx.ids?.label ?? `splitter:${ctx.id}:label`,
17
+ getPanelId: (ctx, id) => ctx.ids?.panel?.(id) ?? `splitter:${ctx.id}:panel:${id}`,
18
+ getGlobalCursorId: (ctx) => `splitter:${ctx.id}:global-cursor`,
19
+ getRootEl: (ctx) => dom.getById(ctx, dom.getRootId(ctx)),
20
+ getResizeTriggerEl: (ctx, id) => dom.getById(ctx, dom.getResizeTriggerId(ctx, id)),
21
+ getPanelEl: (ctx, id) => dom.getById(ctx, dom.getPanelId(ctx, id)),
22
+ getCursor(ctx) {
23
+ const x = ctx.isHorizontal;
24
+ let cursor = x ? "col-resize" : "row-resize";
25
+ if (ctx.activeResizeState.isAtMin) cursor = x ? "e-resize" : "s-resize";
26
+ if (ctx.activeResizeState.isAtMax) cursor = x ? "w-resize" : "n-resize";
27
+ return cursor;
28
+ },
29
+ getPanelStyle(ctx, id) {
30
+ const flexGrow = ctx.panels.find((panel) => panel.id === id)?.size ?? "0";
31
+ return {
32
+ flexBasis: 0,
33
+ flexGrow,
34
+ flexShrink: 1,
35
+ overflow: "hidden"
36
+ };
37
+ },
38
+ getActiveHandleEl(ctx) {
39
+ const activeId = ctx.activeResizeId;
40
+ if (activeId == null) return;
41
+ return dom.getById(ctx, dom.getResizeTriggerId(ctx, activeId));
42
+ },
43
+ getResizeTriggerEls(ctx) {
44
+ const ownerId = CSS.escape(dom.getRootId(ctx));
45
+ return queryAll(dom.getRootEl(ctx), `[role=separator][data-ownedby='${ownerId}']`);
46
+ },
47
+ setupGlobalCursor(ctx) {
48
+ const styleEl = dom.getById(ctx, dom.getGlobalCursorId(ctx));
49
+ const textContent = `* { cursor: ${dom.getCursor(ctx)} !important; }`;
50
+ if (styleEl) styleEl.textContent = textContent;
51
+ else {
52
+ const style = dom.getDoc(ctx).createElement("style");
53
+ style.id = dom.getGlobalCursorId(ctx);
54
+ style.textContent = textContent;
55
+ dom.getDoc(ctx).head.appendChild(style);
56
+ }
57
+ },
58
+ removeGlobalCursor(ctx) {
59
+ dom.getById(ctx, dom.getGlobalCursorId(ctx))?.remove();
60
+ }
61
+ });
62
+
63
+ //#endregion
64
+ //#region src/utils.ts
65
+ function validateSize(key, size) {
66
+ if (Math.floor(size) > 100) throw new Error(`Total ${key} of panels cannot be greater than 100`);
67
+ }
68
+ function getNormalizedPanels(ctx) {
69
+ let numOfPanelsWithoutSize = 0;
70
+ let totalSize = 0;
71
+ let totalMinSize = 0;
72
+ const panels = ctx.size.map((panel) => {
73
+ const minSize = panel.minSize ?? 0;
74
+ const maxSize = panel.maxSize ?? 100;
75
+ totalMinSize += minSize;
76
+ if (panel.size == null) numOfPanelsWithoutSize++;
77
+ else totalSize += panel.size;
78
+ return {
79
+ ...panel,
80
+ minSize,
81
+ maxSize
82
+ };
83
+ });
84
+ validateSize("minSize", totalMinSize);
85
+ validateSize("size", totalSize);
86
+ let end = 0;
87
+ let remainingSize = 0;
88
+ const result = panels.map((panel) => {
89
+ const start = end;
90
+ if (panel.size != null) {
91
+ end += panel.size;
92
+ remainingSize = panel.size - panel.minSize;
93
+ return {
94
+ ...panel,
95
+ start,
96
+ end,
97
+ remainingSize
98
+ };
99
+ }
100
+ const size = (100 - totalSize) / numOfPanelsWithoutSize;
101
+ end += size;
102
+ remainingSize = size - panel.minSize;
103
+ return {
104
+ ...panel,
105
+ size,
106
+ start,
107
+ end,
108
+ remainingSize
109
+ };
110
+ });
111
+ return result;
112
+ }
113
+ function getHandlePanels(ctx, id = ctx.activeResizeId) {
114
+ const [beforeId, afterId] = id?.split(":") ?? [];
115
+ if (!beforeId || !afterId) return;
116
+ const beforeIndex = ctx.previousPanels.findIndex((panel) => panel.id === beforeId);
117
+ const afterIndex = ctx.previousPanels.findIndex((panel) => panel.id === afterId);
118
+ if (beforeIndex === -1 || afterIndex === -1) return;
119
+ const before = ctx.previousPanels[beforeIndex];
120
+ const after = ctx.previousPanels[afterIndex];
121
+ return {
122
+ before: {
123
+ ...before,
124
+ index: beforeIndex
125
+ },
126
+ after: {
127
+ ...after,
128
+ index: afterIndex
129
+ }
130
+ };
131
+ }
132
+ function getHandleBounds(ctx, id = ctx.activeResizeId) {
133
+ const panels = getHandlePanels(ctx, id);
134
+ if (!panels) return;
135
+ const { before, after } = panels;
136
+ return {
137
+ min: Math.max(before.start + before.minSize, after.end - after.maxSize),
138
+ max: Math.min(after.end - after.minSize, before.maxSize + before.start)
139
+ };
140
+ }
141
+ function getPanelBounds(ctx, id) {
142
+ const bounds = getHandleBounds(ctx, id);
143
+ const panels = getHandlePanels(ctx, id);
144
+ if (!bounds || !panels) return;
145
+ const { before, after } = panels;
146
+ const beforeMin = Math.abs(before.start - bounds.min);
147
+ const afterMin = after.size + (before.size - beforeMin);
148
+ const beforeMax = Math.abs(before.start - bounds.max);
149
+ const afterMax = after.size - (beforeMax - before.size);
150
+ return {
151
+ before: {
152
+ index: before.index,
153
+ min: beforeMin,
154
+ max: beforeMax,
155
+ isAtMin: beforeMin === before.size,
156
+ isAtMax: beforeMax === before.size,
157
+ up(step) {
158
+ return Math.min(before.size + step, beforeMax);
159
+ },
160
+ down(step) {
161
+ return Math.max(before.size - step, beforeMin);
162
+ }
163
+ },
164
+ after: {
165
+ index: after.index,
166
+ min: afterMin,
167
+ max: afterMax,
168
+ isAtMin: afterMin === after.size,
169
+ isAtMax: afterMax === after.size,
170
+ up(step) {
171
+ return Math.min(after.size + step, afterMin);
172
+ },
173
+ down(step) {
174
+ return Math.max(after.size - step, afterMax);
175
+ }
176
+ }
177
+ };
178
+ }
179
+ function clamp(value, min, max) {
180
+ return Math.min(Math.max(value, min), max);
181
+ }
182
+
183
+ //#endregion
184
+ //#region src/connect.ts
185
+ function connect(state, send, normalize) {
186
+ const horizontal = state.context.isHorizontal;
187
+ const focused = state.hasTag("focus");
188
+ const dragging = state.matches("dragging");
189
+ const panels = state.context.panels;
190
+ function getResizeTriggerState(props$1) {
191
+ const { id, disabled } = props$1;
192
+ const ids = id.split(":");
193
+ const panelIds = ids.map((id$1) => dom.getPanelId(state.context, id$1));
194
+ const panels$1 = getHandleBounds(state.context, id);
195
+ return {
196
+ disabled: !!disabled,
197
+ focused: state.context.activeResizeId === id && focused,
198
+ panelIds,
199
+ min: panels$1?.min,
200
+ max: panels$1?.max,
201
+ value: 0
202
+ };
203
+ }
204
+ return {
205
+ focused,
206
+ dragging,
207
+ getResizeTriggerState,
208
+ bounds: getHandleBounds(state.context),
209
+ setToMinSize(id) {
210
+ const panel = panels.find((panel$1) => panel$1.id === id);
211
+ send({
212
+ type: "SET_PANEL_SIZE",
213
+ id,
214
+ size: panel?.minSize,
215
+ src: "setToMinSize"
216
+ });
217
+ },
218
+ setToMaxSize(id) {
219
+ const panel = panels.find((panel$1) => panel$1.id === id);
220
+ send({
221
+ type: "SET_PANEL_SIZE",
222
+ id,
223
+ size: panel?.maxSize,
224
+ src: "setToMaxSize"
225
+ });
226
+ },
227
+ setSize(id, size) {
228
+ send({
229
+ type: "SET_PANEL_SIZE",
230
+ id,
231
+ size
232
+ });
233
+ },
234
+ getRootProps() {
235
+ return normalize.element({
236
+ ...parts.root.attrs,
237
+ "data-orientation": state.context.orientation,
238
+ "id": dom.getRootId(state.context),
239
+ "dir": state.context.dir,
240
+ "style": {
241
+ display: "flex",
242
+ flexDirection: horizontal ? "row" : "column",
243
+ height: "100%",
244
+ width: "100%",
245
+ overflow: "hidden"
246
+ }
247
+ });
248
+ },
249
+ getPanelProps(props$1) {
250
+ const { id } = props$1;
251
+ return normalize.element({
252
+ ...parts.panel.attrs,
253
+ "data-orientation": state.context.orientation,
254
+ "dir": state.context.dir,
255
+ "id": dom.getPanelId(state.context, id),
256
+ "data-ownedby": dom.getRootId(state.context),
257
+ "style": dom.getPanelStyle(state.context, id)
258
+ });
259
+ },
260
+ getResizeTriggerProps(props$1) {
261
+ const { id, disabled, step = 1 } = props$1;
262
+ const triggerState = getResizeTriggerState(props$1);
263
+ return normalize.element({
264
+ ...parts.resizeTrigger.attrs,
265
+ "dir": state.context.dir,
266
+ "id": dom.getResizeTriggerId(state.context, id),
267
+ "role": "separator",
268
+ "data-ownedby": dom.getRootId(state.context),
269
+ "tabIndex": disabled ? void 0 : 0,
270
+ "aria-valuenow": triggerState.value,
271
+ "aria-valuemin": triggerState.min,
272
+ "aria-valuemax": triggerState.max,
273
+ "data-orientation": state.context.orientation,
274
+ "aria-orientation": state.context.orientation,
275
+ "aria-controls": triggerState.panelIds.join(" "),
276
+ "data-focus": dataAttr(triggerState.focused),
277
+ "data-disabled": dataAttr(disabled),
278
+ "style": {
279
+ touchAction: "none",
280
+ userSelect: "none",
281
+ WebkitUserSelect: "none",
282
+ flex: "0 0 auto",
283
+ pointerEvents: dragging && !triggerState.focused ? "none" : void 0,
284
+ cursor: horizontal ? "col-resize" : "row-resize",
285
+ [horizontal ? "minHeight" : "minWidth"]: "0"
286
+ },
287
+ onPointerDown(event) {
288
+ if (disabled) {
289
+ event.preventDefault();
290
+ return;
291
+ }
292
+ send({
293
+ type: "POINTER_DOWN",
294
+ id
295
+ });
296
+ event.currentTarget.setPointerCapture(event.pointerId);
297
+ event.preventDefault();
298
+ event.stopPropagation();
299
+ },
300
+ onPointerUp(event) {
301
+ if (disabled) return;
302
+ if (event.currentTarget.hasPointerCapture(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId);
303
+ },
304
+ onPointerOver() {
305
+ if (disabled) return;
306
+ send({
307
+ type: "POINTER_OVER",
308
+ id
309
+ });
310
+ },
311
+ onPointerLeave() {
312
+ if (disabled) return;
313
+ send({
314
+ type: "POINTER_LEAVE",
315
+ id
316
+ });
317
+ },
318
+ onBlur() {
319
+ send("BLUR");
320
+ },
321
+ onFocus() {
322
+ send({
323
+ type: "FOCUS",
324
+ id
325
+ });
326
+ },
327
+ onDoubleClick() {
328
+ if (disabled) return;
329
+ send({
330
+ type: "DOUBLE_CLICK",
331
+ id
332
+ });
333
+ },
334
+ onKeyDown(event) {
335
+ if (event.defaultPrevented) return;
336
+ if (disabled) return;
337
+ const moveStep = getEventStep(event) * step;
338
+ const keyMap = {
339
+ Enter() {
340
+ send("ENTER");
341
+ },
342
+ ArrowUp() {
343
+ send({
344
+ type: "ARROW_UP",
345
+ step: moveStep
346
+ });
347
+ },
348
+ ArrowDown() {
349
+ send({
350
+ type: "ARROW_DOWN",
351
+ step: moveStep
352
+ });
353
+ },
354
+ ArrowLeft() {
355
+ send({
356
+ type: "ARROW_LEFT",
357
+ step: moveStep
358
+ });
359
+ },
360
+ ArrowRight() {
361
+ send({
362
+ type: "ARROW_RIGHT",
363
+ step: moveStep
364
+ });
365
+ },
366
+ Home() {
367
+ send("HOME");
368
+ },
369
+ End() {
370
+ send("END");
371
+ }
372
+ };
373
+ const key = getEventKey(event, state.context);
374
+ const exec = keyMap[key];
375
+ if (exec) {
376
+ exec(event);
377
+ event.preventDefault();
378
+ }
379
+ }
380
+ });
381
+ }
382
+ };
383
+ }
384
+
385
+ //#endregion
386
+ //#region src/machine.ts
387
+ function machine(userContext) {
388
+ const ctx = compact(userContext);
389
+ return createMachine({
390
+ id: "splitter",
391
+ initial: "idle",
392
+ context: {
393
+ orientation: "horizontal",
394
+ activeResizeId: null,
395
+ previousPanels: [],
396
+ size: [],
397
+ initialSize: [],
398
+ activeResizeState: {
399
+ isAtMin: false,
400
+ isAtMax: false
401
+ },
402
+ ...ctx
403
+ },
404
+ created: ["setPreviousPanels", "setInitialSize"],
405
+ watch: { size: ["setActiveResizeState"] },
406
+ computed: {
407
+ isHorizontal: (ctx$1) => ctx$1.orientation === "horizontal",
408
+ panels: (ctx$1) => getNormalizedPanels(ctx$1)
409
+ },
410
+ on: { SET_PANEL_SIZE: { actions: "setPanelSize" } },
411
+ states: {
412
+ "idle": {
413
+ entry: ["clearActiveHandleId"],
414
+ on: {
415
+ POINTER_OVER: {
416
+ target: "hover:temp",
417
+ actions: ["setActiveHandleId"]
418
+ },
419
+ FOCUS: {
420
+ target: "focused",
421
+ actions: ["setActiveHandleId"]
422
+ },
423
+ DOUBLE_CLICK: { actions: ["resetStartPanel", "setPreviousPanels"] }
424
+ }
425
+ },
426
+ "hover:temp": {
427
+ after: { HOVER_DELAY: "hover" },
428
+ on: {
429
+ POINTER_DOWN: {
430
+ target: "dragging",
431
+ actions: ["setActiveHandleId"]
432
+ },
433
+ POINTER_LEAVE: "idle"
434
+ }
435
+ },
436
+ "hover": {
437
+ tags: ["focus"],
438
+ on: {
439
+ POINTER_DOWN: "dragging",
440
+ POINTER_LEAVE: "idle"
441
+ }
442
+ },
443
+ "focused": {
444
+ tags: ["focus"],
445
+ on: {
446
+ BLUR: "idle",
447
+ POINTER_DOWN: {
448
+ target: "dragging",
449
+ actions: ["setActiveHandleId"]
450
+ },
451
+ ARROW_LEFT: {
452
+ guard: "isHorizontal",
453
+ actions: ["shrinkStartPanel", "setPreviousPanels"]
454
+ },
455
+ ARROW_RIGHT: {
456
+ guard: "isHorizontal",
457
+ actions: ["expandStartPanel", "setPreviousPanels"]
458
+ },
459
+ ARROW_UP: {
460
+ guard: "isVertical",
461
+ actions: ["shrinkStartPanel", "setPreviousPanels"]
462
+ },
463
+ ARROW_DOWN: {
464
+ guard: "isVertical",
465
+ actions: ["expandStartPanel", "setPreviousPanels"]
466
+ },
467
+ ENTER: [{
468
+ guard: "isStartPanelAtMax",
469
+ actions: ["setStartPanelToMin", "setPreviousPanels"]
470
+ }, { actions: ["setStartPanelToMax", "setPreviousPanels"] }],
471
+ HOME: { actions: ["setStartPanelToMin", "setPreviousPanels"] },
472
+ END: { actions: ["setStartPanelToMax", "setPreviousPanels"] }
473
+ }
474
+ },
475
+ "dragging": {
476
+ tags: ["focus"],
477
+ entry: "focusResizeHandle",
478
+ activities: ["trackPointerMove"],
479
+ on: {
480
+ POINTER_MOVE: { actions: [
481
+ "setPointerValue",
482
+ "setGlobalCursor",
483
+ "invokeOnResize"
484
+ ] },
485
+ POINTER_UP: {
486
+ target: "focused",
487
+ actions: [
488
+ "setPreviousPanels",
489
+ "clearGlobalCursor",
490
+ "blurResizeHandle",
491
+ "invokeOnResizeEnd"
492
+ ]
493
+ }
494
+ }
495
+ }
496
+ }
497
+ }, {
498
+ activities: { trackPointerMove: (ctx$1, _evt, { send }) => {
499
+ const doc = dom.getDoc(ctx$1);
500
+ return trackPointerMove(doc, {
501
+ onPointerMove(info) {
502
+ send({
503
+ type: "POINTER_MOVE",
504
+ point: info.point
505
+ });
506
+ },
507
+ onPointerUp() {
508
+ send("POINTER_UP");
509
+ }
510
+ });
511
+ } },
512
+ guards: {
513
+ isStartPanelAtMin: (ctx$1) => ctx$1.activeResizeState.isAtMin,
514
+ isStartPanelAtMax: (ctx$1) => ctx$1.activeResizeState.isAtMax,
515
+ isHorizontal: (ctx$1) => ctx$1.isHorizontal,
516
+ isVertical: (ctx$1) => !ctx$1.isHorizontal
517
+ },
518
+ delays: { HOVER_DELAY: 250 },
519
+ actions: {
520
+ setGlobalCursor(ctx$1) {
521
+ dom.setupGlobalCursor(ctx$1);
522
+ },
523
+ clearGlobalCursor(ctx$1) {
524
+ dom.removeGlobalCursor(ctx$1);
525
+ },
526
+ invokeOnResize(ctx$1) {
527
+ ctx$1.onSizeChange?.({
528
+ size: Array.from(ctx$1.size),
529
+ activeHandleId: ctx$1.activeResizeId
530
+ });
531
+ },
532
+ invokeOnResizeEnd(ctx$1) {
533
+ ctx$1.onSizeChangeEnd?.({
534
+ size: Array.from(ctx$1.size),
535
+ activeHandleId: ctx$1.activeResizeId
536
+ });
537
+ },
538
+ setActiveHandleId(ctx$1, evt) {
539
+ ctx$1.activeResizeId = evt.id;
540
+ },
541
+ clearActiveHandleId(ctx$1) {
542
+ ctx$1.activeResizeId = null;
543
+ },
544
+ setInitialSize(ctx$1) {
545
+ ctx$1.initialSize = ctx$1.panels.slice().map((panel) => ({
546
+ id: panel.id,
547
+ size: panel.size
548
+ }));
549
+ },
550
+ setPanelSize(ctx$1, evt) {
551
+ const { id, size } = evt;
552
+ ctx$1.size = ctx$1.size.map((panel) => {
553
+ const panelSize = clamp(size, panel.minSize ?? 0, panel.maxSize ?? 100);
554
+ return panel.id === id ? {
555
+ ...panel,
556
+ size: panelSize
557
+ } : panel;
558
+ });
559
+ },
560
+ setStartPanelToMin(ctx$1) {
561
+ const bounds = getPanelBounds(ctx$1);
562
+ if (!bounds) return;
563
+ const { before, after } = bounds;
564
+ ctx$1.size[before.index].size = before.min;
565
+ ctx$1.size[after.index].size = after.min;
566
+ },
567
+ setStartPanelToMax(ctx$1) {
568
+ const bounds = getPanelBounds(ctx$1);
569
+ if (!bounds) return;
570
+ const { before, after } = bounds;
571
+ ctx$1.size[before.index].size = before.max;
572
+ ctx$1.size[after.index].size = after.max;
573
+ },
574
+ expandStartPanel(ctx$1, evt) {
575
+ const bounds = getPanelBounds(ctx$1);
576
+ if (!bounds) return;
577
+ const { before, after } = bounds;
578
+ ctx$1.size[before.index].size = before.up(evt.step);
579
+ ctx$1.size[after.index].size = after.down(evt.step);
580
+ },
581
+ shrinkStartPanel(ctx$1, evt) {
582
+ const bounds = getPanelBounds(ctx$1);
583
+ if (!bounds) return;
584
+ const { before, after } = bounds;
585
+ ctx$1.size[before.index].size = before.down(evt.step);
586
+ ctx$1.size[after.index].size = after.up(evt.step);
587
+ },
588
+ resetStartPanel(ctx$1, evt) {
589
+ const bounds = getPanelBounds(ctx$1, evt.id);
590
+ if (!bounds) return;
591
+ const { before, after } = bounds;
592
+ ctx$1.size[before.index].size = ctx$1.initialSize[before.index].size;
593
+ ctx$1.size[after.index].size = ctx$1.initialSize[after.index].size;
594
+ },
595
+ focusResizeHandle(ctx$1) {
596
+ raf(() => {
597
+ dom.getActiveHandleEl(ctx$1)?.focus({ preventScroll: true });
598
+ });
599
+ },
600
+ blurResizeHandle(ctx$1) {
601
+ raf(() => {
602
+ dom.getActiveHandleEl(ctx$1)?.blur();
603
+ });
604
+ },
605
+ setPreviousPanels(ctx$1) {
606
+ ctx$1.previousPanels = ctx$1.panels.slice();
607
+ },
608
+ setActiveResizeState(ctx$1) {
609
+ const panels = getPanelBounds(ctx$1);
610
+ if (!panels) return;
611
+ const { before } = panels;
612
+ ctx$1.activeResizeState = {
613
+ isAtMin: before.isAtMin,
614
+ isAtMax: before.isAtMax
615
+ };
616
+ },
617
+ setPointerValue(ctx$1, evt) {
618
+ const panels = getHandlePanels(ctx$1);
619
+ const bounds = getHandleBounds(ctx$1);
620
+ if (!panels || !bounds) return;
621
+ const rootEl = dom.getRootEl(ctx$1);
622
+ if (!rootEl) return;
623
+ const relativePoint = getRelativePoint(evt.point, rootEl);
624
+ const percentValue = relativePoint.getPercentValue({
625
+ dir: ctx$1.dir,
626
+ orientation: ctx$1.orientation
627
+ });
628
+ let pointValue = percentValue * 100;
629
+ ctx$1.activeResizeState = {
630
+ isAtMin: pointValue < bounds.min,
631
+ isAtMax: pointValue > bounds.max
632
+ };
633
+ pointValue = clamp(pointValue, bounds.min, bounds.max);
634
+ const { before, after } = panels;
635
+ const offset = pointValue - before.end;
636
+ ctx$1.size[before.index].size = before.size + offset;
637
+ ctx$1.size[after.index].size = after.size - offset;
638
+ }
639
+ }
640
+ });
641
+ }
642
+
643
+ //#endregion
644
+ //#region src/props.ts
645
+ const props = createProps()([
646
+ "dir",
647
+ "getRootNode",
648
+ "id",
649
+ "ids",
650
+ "onSizeChange",
651
+ "onSizeChangeEnd",
652
+ "orientation",
653
+ "size"
654
+ ]);
655
+ const splitProps = createSplitProps(props);
656
+ const panelProps = createProps()(["id", "snapSize"]);
657
+ const splitPanelProps = createSplitProps(panelProps);
658
+ const resizeTriggerProps = createProps()([
659
+ "disabled",
660
+ "id",
661
+ "step"
662
+ ]);
663
+ const splitResizeTriggerProps = createSplitProps(resizeTriggerProps);
664
+
665
+ //#endregion
666
+ export { anatomy, connect, machine, panelProps, props, resizeTriggerProps, splitPanelProps, splitProps, splitResizeTriggerProps };
package/package.json CHANGED
@@ -1,37 +1,31 @@
1
1
  {
2
2
  "name": "@destyler/splitter",
3
3
  "type": "module",
4
- "version": "0.0.7-beta.7",
4
+ "version": "0.1.0",
5
5
  "description": "A component that divides your layout into resizable sections.",
6
6
  "author": "Elone Hoo <elonehoo@gmail.com>",
7
7
  "license": "MIT",
8
8
  "exports": {
9
- ".": {
10
- "types": "./dist/index.d.mts",
11
- "default": "./dist/index.mjs"
12
- },
13
- "./*": "./*"
9
+ ".": "./dist/index.js"
14
10
  },
15
- "main": "dist/index.cjs",
16
- "module": "dist/index.mjs",
11
+ "main": "dist/index.js",
12
+ "module": "dist/index.js",
17
13
  "types": "dist/index.d.ts",
18
14
  "files": [
19
15
  "*.d.ts",
20
16
  "dist"
21
17
  ],
22
18
  "dependencies": {
23
- "@zag-js/anatomy": "^0.82.1",
24
- "@zag-js/core": "^0.82.1",
25
- "@zag-js/dom-event": "^0.80.0",
26
- "@zag-js/dom-query": "^0.82.1",
27
- "@zag-js/number-utils": "^0.80.0",
28
- "@zag-js/types": "^0.82.1",
29
- "@zag-js/utils": "^0.82.1"
19
+ "@destyler/anatomy": "0.1.0",
20
+ "@destyler/types": "0.1.0",
21
+ "@destyler/xstate": "0.1.0",
22
+ "@destyler/dom": "0.1.0",
23
+ "@destyler/utils": "0.1.0"
30
24
  },
31
25
  "scripts": {
32
26
  "clear": "rimraf ./dist",
33
27
  "clear:node_modules": "rimraf ./node_modules",
34
- "build": "pnpm run clear && unbuild",
35
- "stub": "unbuild --stub"
28
+ "build": "pnpm run clear && tsdown",
29
+ "watch": "tsdown --watch"
36
30
  }
37
31
  }