@pairdraw/vue 0.21.1 → 0.22.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.
Files changed (156) hide show
  1. package/dist/canvas/index.d.ts +2 -1
  2. package/dist/canvas/index.js +2 -1
  3. package/dist/canvas/pointer/drag-move.js +2 -2
  4. package/dist/canvas/pointer/drag-move.js.map +1 -1
  5. package/dist/canvas/surface/color-space.d.ts.map +1 -1
  6. package/dist/canvas/surface/color-space.js +3 -19
  7. package/dist/canvas/surface/color-space.js.map +1 -1
  8. package/dist/canvas/surface/kit-loader.d.ts +10 -0
  9. package/dist/canvas/surface/kit-loader.d.ts.map +1 -0
  10. package/dist/canvas/surface/kit-loader.js +11 -2
  11. package/dist/canvas/surface/kit-loader.js.map +1 -1
  12. package/dist/canvas/tools/registry.js +1 -0
  13. package/dist/canvas/tools/registry.js.map +1 -1
  14. package/dist/canvas/useCanvasInput.d.ts +420 -0
  15. package/dist/controls/layout/helpers.js +28 -9
  16. package/dist/controls/layout/helpers.js.map +1 -1
  17. package/dist/controls/layout/use.d.ts +2 -0
  18. package/dist/controls/layout/use.d.ts.map +1 -1
  19. package/dist/controls/layout/use.js +3 -1
  20. package/dist/controls/layout/use.js.map +1 -1
  21. package/dist/controls/node-props/helpers.d.ts.map +1 -1
  22. package/dist/controls/node-props/helpers.js +1 -1
  23. package/dist/controls/node-props/helpers.js.map +1 -1
  24. package/dist/controls/number-variable-binding/index.d.ts +2 -2
  25. package/dist/controls/number-variable-binding/index.js +2 -2
  26. package/dist/controls/number-variable-binding/use.d.ts +7 -2
  27. package/dist/controls/number-variable-binding/use.d.ts.map +1 -1
  28. package/dist/controls/number-variable-binding/use.js +9 -1
  29. package/dist/controls/number-variable-binding/use.js.map +1 -1
  30. package/dist/controls/position/use.d.ts +1 -1
  31. package/dist/controls/typography/arrivals.js +35 -0
  32. package/dist/controls/typography/arrivals.js.map +1 -0
  33. package/dist/controls/typography/axes.d.ts.map +1 -1
  34. package/dist/controls/typography/axes.js +3 -0
  35. package/dist/controls/typography/axes.js.map +1 -1
  36. package/dist/controls/typography/faces.js +4 -15
  37. package/dist/controls/typography/faces.js.map +1 -1
  38. package/dist/controls/typography/features.d.ts.map +1 -1
  39. package/dist/controls/typography/features.js +3 -17
  40. package/dist/controls/typography/features.js.map +1 -1
  41. package/dist/editor/commands/actions.d.ts +10 -0
  42. package/dist/editor/commands/actions.d.ts.map +1 -0
  43. package/dist/editor/commands/actions.js +9 -1
  44. package/dist/editor/commands/actions.js.map +1 -1
  45. package/dist/editor/commands/index.d.ts +3 -1
  46. package/dist/editor/commands/index.js +3 -1
  47. package/dist/editor/commands/refusals.d.ts +18 -0
  48. package/dist/editor/commands/refusals.d.ts.map +1 -0
  49. package/dist/editor/commands/refusals.js +16 -0
  50. package/dist/editor/commands/refusals.js.map +1 -0
  51. package/dist/editor/commands/registry.d.ts +4 -1
  52. package/dist/editor/commands/registry.d.ts.map +1 -1
  53. package/dist/editor/commands/registry.js +2 -1
  54. package/dist/editor/commands/registry.js.map +1 -1
  55. package/dist/editor/commands/selection.js +11 -0
  56. package/dist/editor/commands/selection.js.map +1 -1
  57. package/dist/editor/commands/types.d.ts +1 -1
  58. package/dist/editor/commands/types.d.ts.map +1 -1
  59. package/dist/editor/selection-capabilities/use.d.ts +2 -0
  60. package/dist/editor/selection-capabilities/use.d.ts.map +1 -1
  61. package/dist/editor/selection-capabilities/use.js +38 -11
  62. package/dist/editor/selection-capabilities/use.js.map +1 -1
  63. package/dist/editor/selection-state/use.js +1 -5
  64. package/dist/editor/selection-state/use.js.map +1 -1
  65. package/dist/editor/tool-cursor/index.d.ts.map +1 -1
  66. package/dist/editor/tool-cursor/index.js +1 -0
  67. package/dist/editor/tool-cursor/index.js.map +1 -1
  68. package/dist/i18n/locales/de/ai.json.js +4 -11
  69. package/dist/i18n/locales/de/commands.json.js +4 -2
  70. package/dist/i18n/locales/de/files.json.js +21 -1
  71. package/dist/i18n/locales/de/menu.json.js +2 -0
  72. package/dist/i18n/locales/de/panels.json.js +77 -2
  73. package/dist/i18n/locales/de/tools.json.js +1 -0
  74. package/dist/i18n/locales/es/ai.json.js +4 -11
  75. package/dist/i18n/locales/es/commands.json.js +4 -2
  76. package/dist/i18n/locales/es/files.json.js +21 -1
  77. package/dist/i18n/locales/es/menu.json.js +2 -0
  78. package/dist/i18n/locales/es/panels.json.js +77 -2
  79. package/dist/i18n/locales/es/tools.json.js +1 -0
  80. package/dist/i18n/locales/fr/ai.json.js +4 -11
  81. package/dist/i18n/locales/fr/commands.json.js +4 -2
  82. package/dist/i18n/locales/fr/files.json.js +21 -1
  83. package/dist/i18n/locales/fr/menu.json.js +2 -0
  84. package/dist/i18n/locales/fr/panels.json.js +77 -2
  85. package/dist/i18n/locales/fr/tools.json.js +1 -0
  86. package/dist/i18n/locales/id/ai.json.js +4 -11
  87. package/dist/i18n/locales/id/commands.json.js +4 -2
  88. package/dist/i18n/locales/id/files.json.js +21 -1
  89. package/dist/i18n/locales/id/menu.json.js +2 -0
  90. package/dist/i18n/locales/id/panels.json.js +77 -2
  91. package/dist/i18n/locales/id/tools.json.js +1 -0
  92. package/dist/i18n/locales/it/ai.json.js +4 -11
  93. package/dist/i18n/locales/it/commands.json.js +4 -2
  94. package/dist/i18n/locales/it/files.json.js +21 -1
  95. package/dist/i18n/locales/it/menu.json.js +2 -0
  96. package/dist/i18n/locales/it/panels.json.js +77 -2
  97. package/dist/i18n/locales/it/tools.json.js +1 -0
  98. package/dist/i18n/locales/ja/ai.json.js +4 -11
  99. package/dist/i18n/locales/ja/commands.json.js +4 -2
  100. package/dist/i18n/locales/ja/files.json.js +21 -1
  101. package/dist/i18n/locales/ja/menu.json.js +2 -0
  102. package/dist/i18n/locales/ja/panels.json.js +77 -2
  103. package/dist/i18n/locales/ja/tools.json.js +1 -0
  104. package/dist/i18n/locales/pl/ai.json.js +4 -11
  105. package/dist/i18n/locales/pl/commands.json.js +4 -2
  106. package/dist/i18n/locales/pl/files.json.js +21 -1
  107. package/dist/i18n/locales/pl/menu.json.js +2 -0
  108. package/dist/i18n/locales/pl/panels.json.js +77 -2
  109. package/dist/i18n/locales/pl/tools.json.js +1 -0
  110. package/dist/i18n/locales/ru/ai.json.js +4 -11
  111. package/dist/i18n/locales/ru/commands.json.js +4 -2
  112. package/dist/i18n/locales/ru/files.json.js +21 -1
  113. package/dist/i18n/locales/ru/menu.json.js +2 -0
  114. package/dist/i18n/locales/ru/panels.json.js +77 -2
  115. package/dist/i18n/locales/ru/tools.json.js +1 -0
  116. package/dist/i18n/locales/zh-cn/ai.json.js +4 -11
  117. package/dist/i18n/locales/zh-cn/commands.json.js +4 -2
  118. package/dist/i18n/locales/zh-cn/files.json.js +21 -1
  119. package/dist/i18n/locales/zh-cn/menu.json.js +2 -0
  120. package/dist/i18n/locales/zh-cn/panels.json.js +77 -2
  121. package/dist/i18n/locales/zh-cn/tools.json.js +1 -0
  122. package/dist/i18n/messages/ai.d.ts +10 -11
  123. package/dist/i18n/messages/ai.js +4 -11
  124. package/dist/i18n/messages/ai.js.map +1 -1
  125. package/dist/i18n/messages/commands.d.ts +3 -1
  126. package/dist/i18n/messages/commands.d.ts.map +1 -1
  127. package/dist/i18n/messages/commands.js +3 -1
  128. package/dist/i18n/messages/commands.js.map +1 -1
  129. package/dist/i18n/messages/files.d.ts +34 -0
  130. package/dist/i18n/messages/files.d.ts.map +1 -1
  131. package/dist/i18n/messages/files.js +20 -0
  132. package/dist/i18n/messages/files.js.map +1 -1
  133. package/dist/i18n/messages/menu.d.ts +2 -0
  134. package/dist/i18n/messages/menu.d.ts.map +1 -1
  135. package/dist/i18n/messages/menu.js +2 -0
  136. package/dist/i18n/messages/menu.js.map +1 -1
  137. package/dist/i18n/messages/panels.d.ts +77 -0
  138. package/dist/i18n/messages/panels.d.ts.map +1 -1
  139. package/dist/i18n/messages/panels.js +75 -0
  140. package/dist/i18n/messages/panels.js.map +1 -1
  141. package/dist/i18n/messages/tools.d.ts +1 -0
  142. package/dist/i18n/messages/tools.d.ts.map +1 -1
  143. package/dist/i18n/messages/tools.js +1 -0
  144. package/dist/i18n/messages/tools.js.map +1 -1
  145. package/dist/i18n/messages.d.ts +127 -12
  146. package/dist/i18n/useI18n.d.ts +508 -48
  147. package/dist/i18n/useI18n.d.ts.map +1 -1
  148. package/dist/primitives/LayerTree/LayerTreeRoot.vue.d.ts +1 -1
  149. package/dist/primitives/LayoutControls/LayoutControlsRoot.vue.d.ts.map +1 -1
  150. package/dist/primitives/LayoutControls/LayoutControlsRoot.vue.js +2 -0
  151. package/dist/primitives/LayoutControls/LayoutControlsRoot.vue.js.map +1 -1
  152. package/dist/shared/input/resize.js +28 -12
  153. package/dist/shared/input/resize.js.map +1 -1
  154. package/dist/shared/input/types.js +1 -0
  155. package/dist/shared/input/types.js.map +1 -1
  156. package/package.json +4 -4
@@ -2354,6 +2354,8 @@ bigNudge?: () => number): {
2354
2354
  columnSpan: number;
2355
2355
  rowSpan: number;
2356
2356
  } | null;
2357
+ gridChildHorizontalAlign: import("@pairdraw/scene-graph").GridChildAlign;
2358
+ gridChildVerticalAlign: import("@pairdraw/scene-graph").GridChildAlign;
2357
2359
  counterAxisAlignContent: "AUTO" | "SPACE_BETWEEN";
2358
2360
  itemReverseZIndex: boolean;
2359
2361
  strokesIncludedInLayout: boolean;
@@ -2416,6 +2418,22 @@ bigNudge?: () => number): {
2416
2418
  displayName?: string | undefined;
2417
2419
  displayText?: string | undefined;
2418
2420
  }[];
2421
+ annotations: {
2422
+ label: string;
2423
+ labelMarkdown: string;
2424
+ properties: import("@pairdraw/scene-graph").AnnotationPropertyName[];
2425
+ categoryId: string | null;
2426
+ }[];
2427
+ measurements: {
2428
+ id: string;
2429
+ fromNodeId: string;
2430
+ toNodeId: string;
2431
+ fromNodeSide: import("@pairdraw/scene-graph").AnnotationMeasurementSide;
2432
+ toSameSide: boolean;
2433
+ innerOffsetRelative: number;
2434
+ outerOffsetFixed: number;
2435
+ freeText: string;
2436
+ }[];
2419
2437
  variantPropSpecs: {
2420
2438
  propDefId: string;
2421
2439
  value: string;
@@ -2456,12 +2474,204 @@ bigNudge?: () => number): {
2456
2474
  type: import("@pairdraw/scene-graph").PrototypeTransitionType;
2457
2475
  duration: number;
2458
2476
  easing?: import("@pairdraw/scene-graph").PrototypeEasingType | undefined;
2477
+ easingCurve?: {
2478
+ x1: number;
2479
+ y1: number;
2480
+ x2: number;
2481
+ y2: number;
2482
+ } | undefined;
2483
+ easingSpring?: {
2484
+ mass: number;
2485
+ stiffness: number;
2486
+ damping: number;
2487
+ initialVelocity: number;
2488
+ } | undefined;
2459
2489
  };
2460
2490
  overlayPosition: import("@pairdraw/scene-graph").PrototypeOverlayPositionType;
2461
2491
  } | {
2462
2492
  type: "BACK";
2463
2493
  } | {
2464
2494
  type: "CLOSE";
2495
+ } | {
2496
+ type: "SET_VARIABLE";
2497
+ variableId: string | null;
2498
+ value: {
2499
+ kind: "boolean";
2500
+ value: boolean;
2501
+ } | {
2502
+ kind: "number";
2503
+ value: number;
2504
+ } | {
2505
+ kind: "string";
2506
+ value: string;
2507
+ } | {
2508
+ kind: "color";
2509
+ value: {
2510
+ r: number;
2511
+ g: number;
2512
+ b: number;
2513
+ a: number;
2514
+ };
2515
+ } | {
2516
+ kind: "alias";
2517
+ variableId: string;
2518
+ } | {
2519
+ kind: "expression";
2520
+ fn: string;
2521
+ args: ({
2522
+ kind: "boolean";
2523
+ value: boolean;
2524
+ } | {
2525
+ kind: "number";
2526
+ value: number;
2527
+ } | {
2528
+ kind: "string";
2529
+ value: string;
2530
+ } | {
2531
+ kind: "color";
2532
+ value: {
2533
+ r: number;
2534
+ g: number;
2535
+ b: number;
2536
+ a: number;
2537
+ };
2538
+ } | {
2539
+ kind: "alias";
2540
+ variableId: string;
2541
+ } | /*elided*/ any)[];
2542
+ };
2543
+ } | {
2544
+ type: "SET_VARIABLE_MODE";
2545
+ collectionId: string | null;
2546
+ modeId: string | null;
2547
+ } | {
2548
+ type: "CONDITIONAL";
2549
+ blocks: {
2550
+ condition?: {
2551
+ kind: "boolean";
2552
+ value: boolean;
2553
+ } | {
2554
+ kind: "number";
2555
+ value: number;
2556
+ } | {
2557
+ kind: "string";
2558
+ value: string;
2559
+ } | {
2560
+ kind: "color";
2561
+ value: {
2562
+ r: number;
2563
+ g: number;
2564
+ b: number;
2565
+ a: number;
2566
+ };
2567
+ } | {
2568
+ kind: "alias";
2569
+ variableId: string;
2570
+ } | {
2571
+ kind: "expression";
2572
+ fn: string;
2573
+ args: ({
2574
+ kind: "boolean";
2575
+ value: boolean;
2576
+ } | {
2577
+ kind: "number";
2578
+ value: number;
2579
+ } | {
2580
+ kind: "string";
2581
+ value: string;
2582
+ } | {
2583
+ kind: "color";
2584
+ value: {
2585
+ r: number;
2586
+ g: number;
2587
+ b: number;
2588
+ a: number;
2589
+ };
2590
+ } | {
2591
+ kind: "alias";
2592
+ variableId: string;
2593
+ } | /*elided*/ any)[];
2594
+ } | undefined;
2595
+ actions: ({
2596
+ type: "NODE";
2597
+ nodeId: string | null;
2598
+ navigation: import("@pairdraw/scene-graph").PrototypeNavigationType;
2599
+ transition: {
2600
+ type: import("@pairdraw/scene-graph").PrototypeTransitionType;
2601
+ duration: number;
2602
+ easing?: import("@pairdraw/scene-graph").PrototypeEasingType | undefined;
2603
+ easingCurve?: {
2604
+ x1: number;
2605
+ y1: number;
2606
+ x2: number;
2607
+ y2: number;
2608
+ } | undefined;
2609
+ easingSpring?: {
2610
+ mass: number;
2611
+ stiffness: number;
2612
+ damping: number;
2613
+ initialVelocity: number;
2614
+ } | undefined;
2615
+ };
2616
+ overlayPosition: import("@pairdraw/scene-graph").PrototypeOverlayPositionType;
2617
+ } | {
2618
+ type: "BACK";
2619
+ } | {
2620
+ type: "CLOSE";
2621
+ } | {
2622
+ type: "SET_VARIABLE";
2623
+ variableId: string | null;
2624
+ value: {
2625
+ kind: "boolean";
2626
+ value: boolean;
2627
+ } | {
2628
+ kind: "number";
2629
+ value: number;
2630
+ } | {
2631
+ kind: "string";
2632
+ value: string;
2633
+ } | {
2634
+ kind: "color";
2635
+ value: {
2636
+ r: number;
2637
+ g: number;
2638
+ b: number;
2639
+ a: number;
2640
+ };
2641
+ } | {
2642
+ kind: "alias";
2643
+ variableId: string;
2644
+ } | {
2645
+ kind: "expression";
2646
+ fn: string;
2647
+ args: ({
2648
+ kind: "boolean";
2649
+ value: boolean;
2650
+ } | {
2651
+ kind: "number";
2652
+ value: number;
2653
+ } | {
2654
+ kind: "string";
2655
+ value: string;
2656
+ } | {
2657
+ kind: "color";
2658
+ value: {
2659
+ r: number;
2660
+ g: number;
2661
+ b: number;
2662
+ a: number;
2663
+ };
2664
+ } | {
2665
+ kind: "alias";
2666
+ variableId: string;
2667
+ } | /*elided*/ any)[];
2668
+ };
2669
+ } | {
2670
+ type: "SET_VARIABLE_MODE";
2671
+ collectionId: string | null;
2672
+ modeId: string | null;
2673
+ } | /*elided*/ any)[];
2674
+ }[];
2465
2675
  })[];
2466
2676
  }[];
2467
2677
  internalOnly: boolean;
@@ -5177,6 +5387,8 @@ bigNudge?: () => number): {
5177
5387
  columnSpan: number;
5178
5388
  rowSpan: number;
5179
5389
  } | null;
5390
+ gridChildHorizontalAlign: import("@pairdraw/scene-graph").GridChildAlign;
5391
+ gridChildVerticalAlign: import("@pairdraw/scene-graph").GridChildAlign;
5180
5392
  counterAxisAlignContent: "AUTO" | "SPACE_BETWEEN";
5181
5393
  itemReverseZIndex: boolean;
5182
5394
  strokesIncludedInLayout: boolean;
@@ -5239,6 +5451,22 @@ bigNudge?: () => number): {
5239
5451
  displayName?: string | undefined;
5240
5452
  displayText?: string | undefined;
5241
5453
  }[];
5454
+ annotations: {
5455
+ label: string;
5456
+ labelMarkdown: string;
5457
+ properties: import("@pairdraw/scene-graph").AnnotationPropertyName[];
5458
+ categoryId: string | null;
5459
+ }[];
5460
+ measurements: {
5461
+ id: string;
5462
+ fromNodeId: string;
5463
+ toNodeId: string;
5464
+ fromNodeSide: import("@pairdraw/scene-graph").AnnotationMeasurementSide;
5465
+ toSameSide: boolean;
5466
+ innerOffsetRelative: number;
5467
+ outerOffsetFixed: number;
5468
+ freeText: string;
5469
+ }[];
5242
5470
  variantPropSpecs: {
5243
5471
  propDefId: string;
5244
5472
  value: string;
@@ -5279,12 +5507,204 @@ bigNudge?: () => number): {
5279
5507
  type: import("@pairdraw/scene-graph").PrototypeTransitionType;
5280
5508
  duration: number;
5281
5509
  easing?: import("@pairdraw/scene-graph").PrototypeEasingType | undefined;
5510
+ easingCurve?: {
5511
+ x1: number;
5512
+ y1: number;
5513
+ x2: number;
5514
+ y2: number;
5515
+ } | undefined;
5516
+ easingSpring?: {
5517
+ mass: number;
5518
+ stiffness: number;
5519
+ damping: number;
5520
+ initialVelocity: number;
5521
+ } | undefined;
5282
5522
  };
5283
5523
  overlayPosition: import("@pairdraw/scene-graph").PrototypeOverlayPositionType;
5284
5524
  } | {
5285
5525
  type: "BACK";
5286
5526
  } | {
5287
5527
  type: "CLOSE";
5528
+ } | {
5529
+ type: "SET_VARIABLE";
5530
+ variableId: string | null;
5531
+ value: {
5532
+ kind: "boolean";
5533
+ value: boolean;
5534
+ } | {
5535
+ kind: "number";
5536
+ value: number;
5537
+ } | {
5538
+ kind: "string";
5539
+ value: string;
5540
+ } | {
5541
+ kind: "color";
5542
+ value: {
5543
+ r: number;
5544
+ g: number;
5545
+ b: number;
5546
+ a: number;
5547
+ };
5548
+ } | {
5549
+ kind: "alias";
5550
+ variableId: string;
5551
+ } | {
5552
+ kind: "expression";
5553
+ fn: string;
5554
+ args: ({
5555
+ kind: "boolean";
5556
+ value: boolean;
5557
+ } | {
5558
+ kind: "number";
5559
+ value: number;
5560
+ } | {
5561
+ kind: "string";
5562
+ value: string;
5563
+ } | {
5564
+ kind: "color";
5565
+ value: {
5566
+ r: number;
5567
+ g: number;
5568
+ b: number;
5569
+ a: number;
5570
+ };
5571
+ } | {
5572
+ kind: "alias";
5573
+ variableId: string;
5574
+ } | /*elided*/ any)[];
5575
+ };
5576
+ } | {
5577
+ type: "SET_VARIABLE_MODE";
5578
+ collectionId: string | null;
5579
+ modeId: string | null;
5580
+ } | {
5581
+ type: "CONDITIONAL";
5582
+ blocks: {
5583
+ condition?: {
5584
+ kind: "boolean";
5585
+ value: boolean;
5586
+ } | {
5587
+ kind: "number";
5588
+ value: number;
5589
+ } | {
5590
+ kind: "string";
5591
+ value: string;
5592
+ } | {
5593
+ kind: "color";
5594
+ value: {
5595
+ r: number;
5596
+ g: number;
5597
+ b: number;
5598
+ a: number;
5599
+ };
5600
+ } | {
5601
+ kind: "alias";
5602
+ variableId: string;
5603
+ } | {
5604
+ kind: "expression";
5605
+ fn: string;
5606
+ args: ({
5607
+ kind: "boolean";
5608
+ value: boolean;
5609
+ } | {
5610
+ kind: "number";
5611
+ value: number;
5612
+ } | {
5613
+ kind: "string";
5614
+ value: string;
5615
+ } | {
5616
+ kind: "color";
5617
+ value: {
5618
+ r: number;
5619
+ g: number;
5620
+ b: number;
5621
+ a: number;
5622
+ };
5623
+ } | {
5624
+ kind: "alias";
5625
+ variableId: string;
5626
+ } | /*elided*/ any)[];
5627
+ } | undefined;
5628
+ actions: ({
5629
+ type: "NODE";
5630
+ nodeId: string | null;
5631
+ navigation: import("@pairdraw/scene-graph").PrototypeNavigationType;
5632
+ transition: {
5633
+ type: import("@pairdraw/scene-graph").PrototypeTransitionType;
5634
+ duration: number;
5635
+ easing?: import("@pairdraw/scene-graph").PrototypeEasingType | undefined;
5636
+ easingCurve?: {
5637
+ x1: number;
5638
+ y1: number;
5639
+ x2: number;
5640
+ y2: number;
5641
+ } | undefined;
5642
+ easingSpring?: {
5643
+ mass: number;
5644
+ stiffness: number;
5645
+ damping: number;
5646
+ initialVelocity: number;
5647
+ } | undefined;
5648
+ };
5649
+ overlayPosition: import("@pairdraw/scene-graph").PrototypeOverlayPositionType;
5650
+ } | {
5651
+ type: "BACK";
5652
+ } | {
5653
+ type: "CLOSE";
5654
+ } | {
5655
+ type: "SET_VARIABLE";
5656
+ variableId: string | null;
5657
+ value: {
5658
+ kind: "boolean";
5659
+ value: boolean;
5660
+ } | {
5661
+ kind: "number";
5662
+ value: number;
5663
+ } | {
5664
+ kind: "string";
5665
+ value: string;
5666
+ } | {
5667
+ kind: "color";
5668
+ value: {
5669
+ r: number;
5670
+ g: number;
5671
+ b: number;
5672
+ a: number;
5673
+ };
5674
+ } | {
5675
+ kind: "alias";
5676
+ variableId: string;
5677
+ } | {
5678
+ kind: "expression";
5679
+ fn: string;
5680
+ args: ({
5681
+ kind: "boolean";
5682
+ value: boolean;
5683
+ } | {
5684
+ kind: "number";
5685
+ value: number;
5686
+ } | {
5687
+ kind: "string";
5688
+ value: string;
5689
+ } | {
5690
+ kind: "color";
5691
+ value: {
5692
+ r: number;
5693
+ g: number;
5694
+ b: number;
5695
+ a: number;
5696
+ };
5697
+ } | {
5698
+ kind: "alias";
5699
+ variableId: string;
5700
+ } | /*elided*/ any)[];
5701
+ };
5702
+ } | {
5703
+ type: "SET_VARIABLE_MODE";
5704
+ collectionId: string | null;
5705
+ modeId: string | null;
5706
+ } | /*elided*/ any)[];
5707
+ }[];
5288
5708
  })[];
5289
5709
  }[];
5290
5710
  internalOnly: boolean;
@@ -132,7 +132,7 @@ function createGridTrackActions(editor, node) {
132
132
  }
133
133
  function removeTrack(prop, index) {
134
134
  if (!node.value) return;
135
- editor.updateNodeWithUndo(node.value.id, { [prop]: node.value[prop].filter((_, i) => i !== index) }, "Remove grid track");
135
+ editor.removeGridTrack(node.value.id, prop, index);
136
136
  }
137
137
  return {
138
138
  updateGridTrack,
@@ -203,20 +203,33 @@ function createLayoutActions({ editor, node }) {
203
203
  if (!node.value) return;
204
204
  preview.update([node.value.id], { [prop]: value }, `Change ${prop}`);
205
205
  }
206
+ /**
207
+ * The layers a size-limit action applies to: every selected layer, so a panel edit keeps the
208
+ * selection wide behaviour, each limit taken from that layer's own size.
209
+ */
210
+ function sizeLimitTargets() {
211
+ const selected = editor.getSelectedNodes();
212
+ if (selected.length > 0) return selected;
213
+ return node.value ? [node.value] : [];
214
+ }
215
+ function setSizeLimitFor(prop, label) {
216
+ const targets = sizeLimitTargets();
217
+ if (targets.length === 0) return;
218
+ const set = (target) => {
219
+ const value = prop === "minWidth" || prop === "maxWidth" ? target.width : target.height;
220
+ editor.updateNodeWithUndo(target.id, { [prop]: Math.round(value) }, label);
221
+ };
222
+ if (targets.length > 1) editor.undo.runBatch(label, () => targets.forEach(set));
223
+ else set(targets[0]);
224
+ }
206
225
  function setSizeLimitToCurrent(prop) {
207
- const n = node.value;
208
- if (!n) return;
209
- const value = prop === "minWidth" || prop === "maxWidth" ? n.width : n.height;
210
- editor.updateNodeWithUndo(n.id, { [prop]: Math.round(value) }, `Set ${prop}`);
226
+ setSizeLimitFor(prop, `Set ${prop}`);
211
227
  }
212
228
  function commitSizeLimit(_prop, _value, _previous) {
213
229
  preview.commit();
214
230
  }
215
231
  function addSizeLimit(prop) {
216
- const n = node.value;
217
- if (!n) return;
218
- const fallback = prop === "minWidth" || prop === "maxWidth" ? n.width : n.height;
219
- editor.updateNodeWithUndo(n.id, { [prop]: Math.round(fallback) }, `Add ${prop}`);
232
+ setSizeLimitFor(prop, `Add ${prop}`);
220
233
  }
221
234
  function removeSizeLimit(prop) {
222
235
  if (!node.value) return;
@@ -347,6 +360,11 @@ function createLayoutSizingState(editor, node, panels) {
347
360
  return parent ? parent.layoutMode !== "NONE" : false;
348
361
  });
349
362
  const isGrid = computed(() => node.value?.layoutMode === "GRID");
363
+ const isGridChild = computed(() => {
364
+ const n = node.value;
365
+ if (!n?.parentId) return false;
366
+ return editor.getNode(n.parentId)?.layoutMode === "GRID";
367
+ });
350
368
  const isFlex = computed(() => node.value?.layoutMode === "HORIZONTAL" || node.value?.layoutMode === "VERTICAL");
351
369
  const widthSizing = computed(() => axisSizingForNode(editor.graph, node.value, "width"));
352
370
  const heightSizing = computed(() => axisSizingForNode(editor.graph, node.value, "height"));
@@ -367,6 +385,7 @@ function createLayoutSizingState(editor, node, panels) {
367
385
  return !!n && aspectRatioLockEditable(editor.graph, n);
368
386
  }),
369
387
  isGrid,
388
+ isGridChild,
370
389
  isFlex,
371
390
  widthSizing,
372
391
  heightSizing,
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","names":[],"sources":["../../../src/controls/layout/helpers.ts"],"sourcesContent":["import { computed, ref } from 'vue'\nimport type { ComputedRef } from 'vue'\n\nimport type { Editor } from '@pairdraw/core'\nimport type {\n GridTrack,\n LayoutAlign,\n LayoutCounterAlign,\n LayoutSizing,\n NumericNodeProperty,\n SceneGraph,\n SceneNode\n} from '@pairdraw/scene-graph'\nimport {\n aspectRatioLockEditable,\n enforcedAspectRatio,\n layoutSizing,\n layoutSizingOptions,\n layoutSizingUpdates,\n lockedAspectRatioTarget,\n sizeKeepingAspectRatio,\n type LayoutSizingAxis\n} from '@pairdraw/scene-graph/layout'\nimport {\n collectResizeDescendants,\n computeConstrainedResizeChanges,\n type ResizeSnapshot\n} from '@pairdraw/scene-graph/resize'\n\nimport { useNodePreview } from '#vue/controls/node-preview/use'\nimport { useSelectedNodeState } from '#vue/editor/selection-state/nodes'\nimport type { useI18n } from '#vue/i18n'\n\ntype AlignCell = { primary: LayoutAlign; counter: LayoutCounterAlign }\n\ntype GridTrackProp = 'gridTemplateColumns' | 'gridTemplateRows'\n\ntype LayoutPanelStrings = {\n sizingFixed: string\n sizingHug: string\n sizingFill: string\n}\n\nexport type LayoutAxis = 'width' | 'height'\nexport type SizeLimitProp = 'minWidth' | 'maxWidth' | 'minHeight' | 'maxHeight'\n\ntype ValueRef<T> = { readonly value: T }\n\nconst ALIGN_HORIZONTAL: AlignCell[] = [\n { primary: 'MIN', counter: 'MIN' },\n { primary: 'CENTER', counter: 'MIN' },\n { primary: 'MAX', counter: 'MIN' },\n { primary: 'MIN', counter: 'CENTER' },\n { primary: 'CENTER', counter: 'CENTER' },\n { primary: 'MAX', counter: 'CENTER' },\n { primary: 'MIN', counter: 'MAX' },\n { primary: 'CENTER', counter: 'MAX' },\n { primary: 'MAX', counter: 'MAX' }\n]\n\nconst ALIGN_VERTICAL: AlignCell[] = [\n { primary: 'MIN', counter: 'MIN' },\n { primary: 'MIN', counter: 'CENTER' },\n { primary: 'MIN', counter: 'MAX' },\n { primary: 'CENTER', counter: 'MIN' },\n { primary: 'CENTER', counter: 'CENTER' },\n { primary: 'CENTER', counter: 'MAX' },\n { primary: 'MAX', counter: 'MIN' },\n { primary: 'MAX', counter: 'CENTER' },\n { primary: 'MAX', counter: 'MAX' }\n]\n\nexport function createLayoutSelectionState(\n editor: Editor,\n panels: ReturnType<typeof useI18n>['panels']\n) {\n const { node } = useSelectedNodeState(editor)\n const layoutDirection = computed<SceneNode['layoutDirection']>(\n () => node.value?.layoutDirection ?? 'AUTO'\n )\n const sizingState = createLayoutSizingState(editor, node, panels)\n const gapAuto = computed(() => node.value?.primaryAxisAlign === 'SPACE_BETWEEN')\n const alignGrid = computed(() =>\n node.value?.layoutMode === 'VERTICAL' ? ALIGN_VERTICAL : ALIGN_HORIZONTAL\n )\n\n return { node, layoutDirection, gapAuto, alignGrid, ...sizingState }\n}\n\nexport function createTrackSizingOptions(panels: ReturnType<typeof useI18n>['panels']['value']) {\n return [\n { value: 'FR' as const, label: panels.sizingFillFr },\n { value: 'FIXED' as const, label: panels.sizingFixedPx },\n { value: 'AUTO' as const, label: panels.auto }\n ]\n}\n\nexport function trackLabel(track: GridTrack): string {\n if (track.sizing === 'FR') return `${track.value}fr`\n if (track.sizing === 'FIXED') return `${track.value}px`\n return 'Auto'\n}\n\nexport function createGridTrackActions(editor: Editor, node: ComputedRef<SceneNode | null>) {\n function updateGridTrack(prop: GridTrackProp, index: number, updates: Partial<GridTrack>) {\n if (!node.value) return\n const tracks = [...node.value[prop]]\n tracks[index] = { ...tracks[index], ...updates }\n editor.updateNodeWithUndo(node.value.id, { [prop]: tracks }, 'Change grid track')\n }\n\n function addTrack(prop: GridTrackProp) {\n if (!node.value) return\n editor.updateNodeWithUndo(\n node.value.id,\n { [prop]: [...node.value[prop], { sizing: 'FR' as const, value: 1 }] },\n 'Add grid track'\n )\n }\n\n function removeTrack(prop: GridTrackProp, index: number) {\n if (!node.value) return\n editor.updateNodeWithUndo(\n node.value.id,\n { [prop]: node.value[prop].filter((_: GridTrack, i: number) => i !== index) },\n 'Remove grid track'\n )\n }\n\n return { updateGridTrack, addTrack, removeTrack }\n}\n\nexport function createPaddingActions(editor: Editor, node: ComputedRef<SceneNode | null>) {\n const showIndividualPadding = ref(false)\n const preview = useNodePreview(editor)\n\n const hasUniformPadding = computed(() => {\n const n = node.value\n if (!n) return true\n return (\n n.paddingTop === n.paddingRight &&\n n.paddingRight === n.paddingBottom &&\n n.paddingBottom === n.paddingLeft\n )\n })\n\n const hasSymmetricPadding = computed(() => {\n const n = node.value\n if (!n) return true\n return n.paddingLeft === n.paddingRight && n.paddingTop === n.paddingBottom\n })\n\n function setHorizontalPadding(v: number) {\n if (!node.value) return\n preview.update(\n [node.value.id],\n { paddingLeft: v, paddingRight: v },\n 'Change horizontal padding'\n )\n }\n\n function commitHorizontalPadding(_value: number, _previous: number) {\n preview.commit()\n }\n\n function setVerticalPadding(v: number) {\n if (!node.value) return\n preview.update([node.value.id], { paddingTop: v, paddingBottom: v }, 'Change vertical padding')\n }\n\n function commitVerticalPadding(_value: number, _previous: number) {\n preview.commit()\n }\n\n function toggleIndividualPadding() {\n showIndividualPadding.value = !showIndividualPadding.value\n }\n\n return {\n cancelPaddingPreview: preview.cancel,\n showIndividualPadding,\n hasUniformPadding,\n hasSymmetricPadding,\n setHorizontalPadding,\n commitHorizontalPadding,\n setVerticalPadding,\n commitVerticalPadding,\n toggleIndividualPadding\n }\n}\n\nfunction sizingAxis(axis: LayoutAxis): LayoutSizingAxis {\n return axis === 'width' ? 'HORIZONTAL' : 'VERTICAL'\n}\n\nexport function axisSizingPatchForNode(\n graph: SceneGraph,\n node: SceneNode,\n axis: LayoutAxis,\n sizing: LayoutSizing\n): Partial<SceneNode> {\n return layoutSizingUpdates(graph, node, sizingAxis(axis), sizing)\n}\n\nexport function createLayoutActions({\n editor,\n node\n}: {\n editor: Editor\n node: ComputedRef<SceneNode | null>\n}) {\n const preview = useNodePreview(editor)\n\n function updateProp(key: NumericNodeProperty, value: number) {\n if (node.value) preview.update([node.value.id], { [key]: value }, `Change ${key}`)\n }\n\n function updateSizeLimit(prop: SizeLimitProp, value: number) {\n if (!node.value) return\n preview.update([node.value.id], { [prop]: value }, `Change ${prop}`)\n }\n\n function setSizeLimitToCurrent(prop: SizeLimitProp) {\n const n = node.value\n if (!n) return\n const value = prop === 'minWidth' || prop === 'maxWidth' ? n.width : n.height\n editor.updateNodeWithUndo(n.id, { [prop]: Math.round(value) }, `Set ${prop}`)\n }\n\n function commitSizeLimit(_prop: SizeLimitProp, _value: number, _previous: number) {\n preview.commit()\n }\n\n function addSizeLimit(prop: SizeLimitProp) {\n const n = node.value\n if (!n) return\n const fallback = prop === 'minWidth' || prop === 'maxWidth' ? n.width : n.height\n editor.updateNodeWithUndo(n.id, { [prop]: Math.round(fallback) }, `Add ${prop}`)\n }\n\n function removeSizeLimit(prop: SizeLimitProp) {\n if (!node.value) return\n editor.updateNodeWithUndo(node.value.id, { [prop]: null }, `Remove ${prop}`)\n }\n\n function commitProp(_key: NumericNodeProperty, _value: number, _previous: number) {\n preview.commit()\n }\n\n function setAxisSizing(axis: LayoutAxis, sizing: LayoutSizing) {\n const n = node.value\n if (!n) return\n editor.updateNodeWithUndo(\n n.id,\n axisSizingPatchForNode(editor.graph, n, axis, sizing),\n `Set ${axis} sizing`\n )\n }\n\n function fixedAxisPatch(n: SceneNode, axis: LayoutAxis): Partial<SceneNode> {\n return axisSizingForNode(editor.graph, n, axis) === 'FIXED'\n ? {}\n : axisSizingPatchForNode(editor.graph, n, axis, 'FIXED')\n }\n\n /**\n * What the size edit running in the preview started from. A size typed in the panel places the\n * layers inside by their constraints, as a corner drag does in Figma, instead of leaving them\n * pinned to their old offsets; every keystroke and scrub step of one edit previews the same\n * frame, so a later value measures from where the edit began instead of from the size the\n * previous keystroke already gave.\n */\n let sizeEditStart:\n | {\n nodeId: string\n size: { width: number; height: number }\n originals: ReadonlyMap<string, ResizeSnapshot>\n }\n | undefined\n\n function startOfSizeEdit(n: SceneNode) {\n if (!preview.isActive() || sizeEditStart?.nodeId !== n.id) {\n sizeEditStart = {\n nodeId: n.id,\n size: { width: n.width, height: n.height },\n originals: collectResizeDescendants(editor.graph, n.id) ?? new Map()\n }\n }\n return sizeEditStart\n }\n\n function previewSize(\n n: SceneNode,\n size: { width: number; height: number },\n label: string,\n sizing: Partial<SceneNode>\n ) {\n const start = startOfSizeEdit(n)\n const placed = computeConstrainedResizeChanges(\n editor.graph,\n n.id,\n start.size,\n size,\n start.originals\n )\n preview.update([n.id], { ...sizing, ...size }, label)\n preview.updateNodes(placed, label)\n }\n\n // A locked layer keeps its ratio as either side is typed, as in Figma.\n function updateAxisSize(axis: LayoutAxis, value: number) {\n const n = node.value\n if (!n) return\n const ratio = enforcedAspectRatio(n)\n if (ratio === null) {\n previewSize(\n n,\n { width: n.width, height: n.height, [axis]: value },\n `Change ${axis}`,\n fixedAxisPatch(n, axis)\n )\n return\n }\n const size = sizeKeepingAspectRatio(ratio, axis, value)\n const sizing = { ...fixedAxisPatch(n, 'width'), ...fixedAxisPatch(n, 'height') }\n previewSize(n, size, `Change ${axis}`, sizing)\n }\n\n function toggleAspectRatioLock() {\n const n = node.value\n if (!n || !aspectRatioLockEditable(editor.graph, n)) return\n const locked = n.targetAspectRatio !== null\n editor.updateNodeWithUndo(\n n.id,\n { targetAspectRatio: locked ? null : lockedAspectRatioTarget(n.width, n.height) },\n 'Toggle aspect ratio lock'\n )\n }\n\n function commitAxisSize(_axis: LayoutAxis, _value: number, _previous: number) {\n preview.commit()\n }\n\n function setAlignment(primary: LayoutAlign, counter: LayoutCounterAlign) {\n if (!node.value) return\n editor.updateNodeWithUndo(\n node.value.id,\n { primaryAxisAlign: primary, counterAxisAlign: counter },\n 'Change alignment'\n )\n }\n\n function setGapAuto(enabled: boolean) {\n const n = node.value\n if (!n) return\n editor.updateNodeWithUndo(\n n.id,\n { primaryAxisAlign: enabled ? 'SPACE_BETWEEN' : 'MIN' },\n enabled ? 'Set gap to auto' : 'Set gap to fixed'\n )\n }\n\n function setLayoutDirection(direction: SceneNode['layoutDirection']) {\n if (!node.value) return\n editor.updateNodeWithUndo(\n node.value.id,\n { layoutDirection: direction },\n 'Change layout direction'\n )\n }\n\n return {\n cancelPreview: preview.cancel,\n updateProp,\n updateSizeLimit,\n setSizeLimitToCurrent,\n commitSizeLimit,\n addSizeLimit,\n removeSizeLimit,\n commitProp,\n setAxisSizing,\n updateAxisSize,\n commitAxisSize,\n toggleAspectRatioLock,\n setAlignment,\n setGapAuto,\n setLayoutDirection\n }\n}\n\nexport function axisSizingForNode(\n graph: SceneGraph,\n node: SceneNode | null,\n axis: LayoutAxis\n): LayoutSizing {\n return node ? layoutSizing(graph, node, sizingAxis(axis)) : 'FIXED'\n}\n\nexport function sizingOptionsForNode(\n graph: SceneGraph,\n node: SceneNode | null,\n labels: Partial<Record<LayoutSizing, string>> = {}\n): { value: LayoutSizing; label: string }[] {\n const allowed = node ? layoutSizingOptions(graph, node) : []\n // A node outside auto-layout still shows its fixed size.\n const values: LayoutSizing[] = allowed.length > 0 ? allowed : ['FIXED']\n const fallback: Record<LayoutSizing, string> = { FIXED: 'Fixed', HUG: 'Hug', FILL: 'Fill' }\n return values.map((value) => ({ value, label: labels[value] ?? fallback[value] }))\n}\n\nfunction createLayoutSizingState(\n editor: Editor,\n node: ComputedRef<SceneNode | null>,\n panels: ValueRef<LayoutPanelStrings>\n) {\n const isInAutoLayout = computed(() => {\n const n = node.value\n if (!n?.parentId) return false\n const parent = editor.getNode(n.parentId)\n return parent ? parent.layoutMode !== 'NONE' : false\n })\n\n const isGrid = computed(() => node.value?.layoutMode === 'GRID')\n const isFlex = computed(\n () => node.value?.layoutMode === 'HORIZONTAL' || node.value?.layoutMode === 'VERTICAL'\n )\n const widthSizing = computed(() => axisSizingForNode(editor.graph, node.value, 'width'))\n const heightSizing = computed(() => axisSizingForNode(editor.graph, node.value, 'height'))\n\n function sizingOptions() {\n return sizingOptionsForNode(editor.graph, node.value, {\n FIXED: panels.value.sizingFixed,\n HUG: panels.value.sizingHug,\n FILL: panels.value.sizingFill\n })\n }\n\n const widthSizingOptions = computed(sizingOptions)\n const heightSizingOptions = computed(sizingOptions)\n const aspectRatioLocked = computed(() => node.value?.targetAspectRatio != null)\n const aspectRatioLockable = computed(() => {\n const n = node.value\n return !!n && aspectRatioLockEditable(editor.graph, n)\n })\n\n return {\n isInAutoLayout,\n aspectRatioLocked,\n aspectRatioLockable,\n isGrid,\n isFlex,\n widthSizing,\n heightSizing,\n widthSizingOptions,\n heightSizingOptions\n }\n}\n"],"mappings":";;;;;;AAgDA,MAAM,mBAAgC;CACpC;EAAE,SAAS;EAAO,SAAS;CAAM;CACjC;EAAE,SAAS;EAAU,SAAS;CAAM;CACpC;EAAE,SAAS;EAAO,SAAS;CAAM;CACjC;EAAE,SAAS;EAAO,SAAS;CAAS;CACpC;EAAE,SAAS;EAAU,SAAS;CAAS;CACvC;EAAE,SAAS;EAAO,SAAS;CAAS;CACpC;EAAE,SAAS;EAAO,SAAS;CAAM;CACjC;EAAE,SAAS;EAAU,SAAS;CAAM;CACpC;EAAE,SAAS;EAAO,SAAS;CAAM;AACnC;AAEA,MAAM,iBAA8B;CAClC;EAAE,SAAS;EAAO,SAAS;CAAM;CACjC;EAAE,SAAS;EAAO,SAAS;CAAS;CACpC;EAAE,SAAS;EAAO,SAAS;CAAM;CACjC;EAAE,SAAS;EAAU,SAAS;CAAM;CACpC;EAAE,SAAS;EAAU,SAAS;CAAS;CACvC;EAAE,SAAS;EAAU,SAAS;CAAM;CACpC;EAAE,SAAS;EAAO,SAAS;CAAM;CACjC;EAAE,SAAS;EAAO,SAAS;CAAS;CACpC;EAAE,SAAS;EAAO,SAAS;CAAM;AACnC;AAEA,SAAgB,2BACd,QACA,QACA;CACA,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AE;AACnF;AAEA,SAAS,wBACP,QACA,MACA,QACA;CACA,MAAM,iBAAiB,eAAe;EACpC,MAAM,IAAI,KAAK;EACf,IAAI,CAAC,GAAG,UAAU,OAAO;EACzB,MAAM,SAAS,OAAO,QAAQ,EAAE,QAAQ;EACxC,OAAO,SAAS,OAAO,eAAe,SAAS;CACjD,CAAC;CAED,MAAM,SAAS,eAAe,KAAK,OAAO,eAAe,MAAM;CAC/D,MAAM,SAAS,eACP,KAAK,OAAO,eAAe,gBAAgB,KAAK,OAAO,eAAe,UAC9E;CACA,MAAM,cAAc,eAAe,kBAAkB,OAAO,OAAO,KAAK,OAAO,OAAO,CAAC;CACvF,MAAM,eAAe,eAAe,kBAAkB,OAAO,OAAO,KAAK,OAAO,QAAQ,CAAC;CAEzF,SAAS,gBAAgB;EACvB,OAAO,qBAAqB,OAAO,OAAO,KAAK,OAAO;GACpD,OAAO,OAAO,MAAM;GACpB,KAAK,OAAO,MAAM;GAClB,MAAM,OAAO,MAAM;EACrB,CAAC;CACH;CAEA,MAAM,qBAAqB,SAAS,aAAa;CACjD,MAAM,sBAAsB,SAAS,aAAa;CAOlD,OAAO;EACL;EACA,mBARwB,eAAe,KAAK,OAAO,qBAAqB,IAQxD;EAChB,qBAR0B,eAAe;GACzC,MAAM,IAAI,KAAK;GACf,OAAO,CAAC,CAAC,KAAK,wBAAwB,OAAO,OAAO,CAAC;EACvD,CAKoB;EAClB;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"helpers.js","names":[],"sources":["../../../src/controls/layout/helpers.ts"],"sourcesContent":["import { computed, ref } from 'vue'\nimport type { ComputedRef } from 'vue'\n\nimport type { Editor } from '@pairdraw/core'\nimport type {\n GridTrack,\n LayoutAlign,\n LayoutCounterAlign,\n LayoutSizing,\n NumericNodeProperty,\n SceneGraph,\n SceneNode\n} from '@pairdraw/scene-graph'\nimport {\n aspectRatioLockEditable,\n enforcedAspectRatio,\n layoutSizing,\n layoutSizingOptions,\n layoutSizingUpdates,\n lockedAspectRatioTarget,\n sizeKeepingAspectRatio,\n type LayoutSizingAxis\n} from '@pairdraw/scene-graph/layout'\nimport {\n collectResizeDescendants,\n computeConstrainedResizeChanges,\n type ResizeSnapshot\n} from '@pairdraw/scene-graph/resize'\n\nimport { useNodePreview } from '#vue/controls/node-preview/use'\nimport { useSelectedNodeState } from '#vue/editor/selection-state/nodes'\nimport type { useI18n } from '#vue/i18n'\n\ntype AlignCell = { primary: LayoutAlign; counter: LayoutCounterAlign }\n\ntype GridTrackProp = 'gridTemplateColumns' | 'gridTemplateRows'\n\ntype LayoutPanelStrings = {\n sizingFixed: string\n sizingHug: string\n sizingFill: string\n}\n\nexport type LayoutAxis = 'width' | 'height'\nexport type SizeLimitProp = 'minWidth' | 'maxWidth' | 'minHeight' | 'maxHeight'\n\ntype ValueRef<T> = { readonly value: T }\n\nconst ALIGN_HORIZONTAL: AlignCell[] = [\n { primary: 'MIN', counter: 'MIN' },\n { primary: 'CENTER', counter: 'MIN' },\n { primary: 'MAX', counter: 'MIN' },\n { primary: 'MIN', counter: 'CENTER' },\n { primary: 'CENTER', counter: 'CENTER' },\n { primary: 'MAX', counter: 'CENTER' },\n { primary: 'MIN', counter: 'MAX' },\n { primary: 'CENTER', counter: 'MAX' },\n { primary: 'MAX', counter: 'MAX' }\n]\n\nconst ALIGN_VERTICAL: AlignCell[] = [\n { primary: 'MIN', counter: 'MIN' },\n { primary: 'MIN', counter: 'CENTER' },\n { primary: 'MIN', counter: 'MAX' },\n { primary: 'CENTER', counter: 'MIN' },\n { primary: 'CENTER', counter: 'CENTER' },\n { primary: 'CENTER', counter: 'MAX' },\n { primary: 'MAX', counter: 'MIN' },\n { primary: 'MAX', counter: 'CENTER' },\n { primary: 'MAX', counter: 'MAX' }\n]\n\nexport function createLayoutSelectionState(\n editor: Editor,\n panels: ReturnType<typeof useI18n>['panels']\n) {\n const { node } = useSelectedNodeState(editor)\n const layoutDirection = computed<SceneNode['layoutDirection']>(\n () => node.value?.layoutDirection ?? 'AUTO'\n )\n const sizingState = createLayoutSizingState(editor, node, panels)\n const gapAuto = computed(() => node.value?.primaryAxisAlign === 'SPACE_BETWEEN')\n const alignGrid = computed(() =>\n node.value?.layoutMode === 'VERTICAL' ? ALIGN_VERTICAL : ALIGN_HORIZONTAL\n )\n\n return { node, layoutDirection, gapAuto, alignGrid, ...sizingState }\n}\n\nexport function createTrackSizingOptions(panels: ReturnType<typeof useI18n>['panels']['value']) {\n return [\n { value: 'FR' as const, label: panels.sizingFillFr },\n { value: 'FIXED' as const, label: panels.sizingFixedPx },\n { value: 'AUTO' as const, label: panels.auto }\n ]\n}\n\nexport function trackLabel(track: GridTrack): string {\n if (track.sizing === 'FR') return `${track.value}fr`\n if (track.sizing === 'FIXED') return `${track.value}px`\n return 'Auto'\n}\n\nexport function createGridTrackActions(editor: Editor, node: ComputedRef<SceneNode | null>) {\n function updateGridTrack(prop: GridTrackProp, index: number, updates: Partial<GridTrack>) {\n if (!node.value) return\n const tracks = [...node.value[prop]]\n tracks[index] = { ...tracks[index], ...updates }\n editor.updateNodeWithUndo(node.value.id, { [prop]: tracks }, 'Change grid track')\n }\n\n function addTrack(prop: GridTrackProp) {\n if (!node.value) return\n editor.updateNodeWithUndo(\n node.value.id,\n { [prop]: [...node.value[prop], { sizing: 'FR' as const, value: 1 }] },\n 'Add grid track'\n )\n }\n\n function removeTrack(prop: GridTrackProp, index: number) {\n if (!node.value) return\n editor.removeGridTrack(node.value.id, prop, index)\n }\n\n return { updateGridTrack, addTrack, removeTrack }\n}\n\nexport function createPaddingActions(editor: Editor, node: ComputedRef<SceneNode | null>) {\n const showIndividualPadding = ref(false)\n const preview = useNodePreview(editor)\n\n const hasUniformPadding = computed(() => {\n const n = node.value\n if (!n) return true\n return (\n n.paddingTop === n.paddingRight &&\n n.paddingRight === n.paddingBottom &&\n n.paddingBottom === n.paddingLeft\n )\n })\n\n const hasSymmetricPadding = computed(() => {\n const n = node.value\n if (!n) return true\n return n.paddingLeft === n.paddingRight && n.paddingTop === n.paddingBottom\n })\n\n function setHorizontalPadding(v: number) {\n if (!node.value) return\n preview.update(\n [node.value.id],\n { paddingLeft: v, paddingRight: v },\n 'Change horizontal padding'\n )\n }\n\n function commitHorizontalPadding(_value: number, _previous: number) {\n preview.commit()\n }\n\n function setVerticalPadding(v: number) {\n if (!node.value) return\n preview.update([node.value.id], { paddingTop: v, paddingBottom: v }, 'Change vertical padding')\n }\n\n function commitVerticalPadding(_value: number, _previous: number) {\n preview.commit()\n }\n\n function toggleIndividualPadding() {\n showIndividualPadding.value = !showIndividualPadding.value\n }\n\n return {\n cancelPaddingPreview: preview.cancel,\n showIndividualPadding,\n hasUniformPadding,\n hasSymmetricPadding,\n setHorizontalPadding,\n commitHorizontalPadding,\n setVerticalPadding,\n commitVerticalPadding,\n toggleIndividualPadding\n }\n}\n\nfunction sizingAxis(axis: LayoutAxis): LayoutSizingAxis {\n return axis === 'width' ? 'HORIZONTAL' : 'VERTICAL'\n}\n\nexport function axisSizingPatchForNode(\n graph: SceneGraph,\n node: SceneNode,\n axis: LayoutAxis,\n sizing: LayoutSizing\n): Partial<SceneNode> {\n return layoutSizingUpdates(graph, node, sizingAxis(axis), sizing)\n}\n\nexport function createLayoutActions({\n editor,\n node\n}: {\n editor: Editor\n node: ComputedRef<SceneNode | null>\n}) {\n const preview = useNodePreview(editor)\n\n function updateProp(key: NumericNodeProperty, value: number) {\n if (node.value) preview.update([node.value.id], { [key]: value }, `Change ${key}`)\n }\n\n function updateSizeLimit(prop: SizeLimitProp, value: number) {\n if (!node.value) return\n preview.update([node.value.id], { [prop]: value }, `Change ${prop}`)\n }\n\n /**\n * The layers a size-limit action applies to: every selected layer, so a panel edit keeps the\n * selection wide behaviour, each limit taken from that layer's own size.\n */\n function sizeLimitTargets(): SceneNode[] {\n const selected = editor.getSelectedNodes()\n if (selected.length > 0) return selected\n return node.value ? [node.value] : []\n }\n\n function setSizeLimitFor(prop: SizeLimitProp, label: string) {\n const targets = sizeLimitTargets()\n if (targets.length === 0) return\n const set = (target: SceneNode) => {\n const value = prop === 'minWidth' || prop === 'maxWidth' ? target.width : target.height\n editor.updateNodeWithUndo(target.id, { [prop]: Math.round(value) }, label)\n }\n if (targets.length > 1) editor.undo.runBatch(label, () => targets.forEach(set))\n else set(targets[0])\n }\n\n function setSizeLimitToCurrent(prop: SizeLimitProp) {\n setSizeLimitFor(prop, `Set ${prop}`)\n }\n\n function commitSizeLimit(_prop: SizeLimitProp, _value: number, _previous: number) {\n preview.commit()\n }\n\n function addSizeLimit(prop: SizeLimitProp) {\n setSizeLimitFor(prop, `Add ${prop}`)\n }\n\n function removeSizeLimit(prop: SizeLimitProp) {\n if (!node.value) return\n editor.updateNodeWithUndo(node.value.id, { [prop]: null }, `Remove ${prop}`)\n }\n\n function commitProp(_key: NumericNodeProperty, _value: number, _previous: number) {\n preview.commit()\n }\n\n function setAxisSizing(axis: LayoutAxis, sizing: LayoutSizing) {\n const n = node.value\n if (!n) return\n editor.updateNodeWithUndo(\n n.id,\n axisSizingPatchForNode(editor.graph, n, axis, sizing),\n `Set ${axis} sizing`\n )\n }\n\n function fixedAxisPatch(n: SceneNode, axis: LayoutAxis): Partial<SceneNode> {\n return axisSizingForNode(editor.graph, n, axis) === 'FIXED'\n ? {}\n : axisSizingPatchForNode(editor.graph, n, axis, 'FIXED')\n }\n\n /**\n * What the size edit running in the preview started from. A size typed in the panel places the\n * layers inside by their constraints, as a corner drag does in Figma, instead of leaving them\n * pinned to their old offsets; every keystroke and scrub step of one edit previews the same\n * frame, so a later value measures from where the edit began instead of from the size the\n * previous keystroke already gave.\n */\n let sizeEditStart:\n | {\n nodeId: string\n size: { width: number; height: number }\n originals: ReadonlyMap<string, ResizeSnapshot>\n }\n | undefined\n\n function startOfSizeEdit(n: SceneNode) {\n if (!preview.isActive() || sizeEditStart?.nodeId !== n.id) {\n sizeEditStart = {\n nodeId: n.id,\n size: { width: n.width, height: n.height },\n originals: collectResizeDescendants(editor.graph, n.id) ?? new Map()\n }\n }\n return sizeEditStart\n }\n\n function previewSize(\n n: SceneNode,\n size: { width: number; height: number },\n label: string,\n sizing: Partial<SceneNode>\n ) {\n const start = startOfSizeEdit(n)\n const placed = computeConstrainedResizeChanges(\n editor.graph,\n n.id,\n start.size,\n size,\n start.originals\n )\n preview.update([n.id], { ...sizing, ...size }, label)\n preview.updateNodes(placed, label)\n }\n\n // A locked layer keeps its ratio as either side is typed, as in Figma.\n function updateAxisSize(axis: LayoutAxis, value: number) {\n const n = node.value\n if (!n) return\n const ratio = enforcedAspectRatio(n)\n if (ratio === null) {\n previewSize(\n n,\n { width: n.width, height: n.height, [axis]: value },\n `Change ${axis}`,\n fixedAxisPatch(n, axis)\n )\n return\n }\n const size = sizeKeepingAspectRatio(ratio, axis, value)\n const sizing = { ...fixedAxisPatch(n, 'width'), ...fixedAxisPatch(n, 'height') }\n previewSize(n, size, `Change ${axis}`, sizing)\n }\n\n function toggleAspectRatioLock() {\n const n = node.value\n if (!n || !aspectRatioLockEditable(editor.graph, n)) return\n const locked = n.targetAspectRatio !== null\n editor.updateNodeWithUndo(\n n.id,\n { targetAspectRatio: locked ? null : lockedAspectRatioTarget(n.width, n.height) },\n 'Toggle aspect ratio lock'\n )\n }\n\n function commitAxisSize(_axis: LayoutAxis, _value: number, _previous: number) {\n preview.commit()\n }\n\n function setAlignment(primary: LayoutAlign, counter: LayoutCounterAlign) {\n if (!node.value) return\n editor.updateNodeWithUndo(\n node.value.id,\n { primaryAxisAlign: primary, counterAxisAlign: counter },\n 'Change alignment'\n )\n }\n\n function setGapAuto(enabled: boolean) {\n const n = node.value\n if (!n) return\n editor.updateNodeWithUndo(\n n.id,\n { primaryAxisAlign: enabled ? 'SPACE_BETWEEN' : 'MIN' },\n enabled ? 'Set gap to auto' : 'Set gap to fixed'\n )\n }\n\n function setLayoutDirection(direction: SceneNode['layoutDirection']) {\n if (!node.value) return\n editor.updateNodeWithUndo(\n node.value.id,\n { layoutDirection: direction },\n 'Change layout direction'\n )\n }\n\n return {\n cancelPreview: preview.cancel,\n updateProp,\n updateSizeLimit,\n setSizeLimitToCurrent,\n commitSizeLimit,\n addSizeLimit,\n removeSizeLimit,\n commitProp,\n setAxisSizing,\n updateAxisSize,\n commitAxisSize,\n toggleAspectRatioLock,\n setAlignment,\n setGapAuto,\n setLayoutDirection\n }\n}\n\nexport function axisSizingForNode(\n graph: SceneGraph,\n node: SceneNode | null,\n axis: LayoutAxis\n): LayoutSizing {\n return node ? layoutSizing(graph, node, sizingAxis(axis)) : 'FIXED'\n}\n\nexport function sizingOptionsForNode(\n graph: SceneGraph,\n node: SceneNode | null,\n labels: Partial<Record<LayoutSizing, string>> = {}\n): { value: LayoutSizing; label: string }[] {\n const allowed = node ? layoutSizingOptions(graph, node) : []\n // A node outside auto-layout still shows its fixed size.\n const values: LayoutSizing[] = allowed.length > 0 ? allowed : ['FIXED']\n const fallback: Record<LayoutSizing, string> = { FIXED: 'Fixed', HUG: 'Hug', FILL: 'Fill' }\n return values.map((value) => ({ value, label: labels[value] ?? fallback[value] }))\n}\n\nfunction createLayoutSizingState(\n editor: Editor,\n node: ComputedRef<SceneNode | null>,\n panels: ValueRef<LayoutPanelStrings>\n) {\n const isInAutoLayout = computed(() => {\n const n = node.value\n if (!n?.parentId) return false\n const parent = editor.getNode(n.parentId)\n return parent ? parent.layoutMode !== 'NONE' : false\n })\n\n const isGrid = computed(() => node.value?.layoutMode === 'GRID')\n const isGridChild = computed(() => {\n const n = node.value\n if (!n?.parentId) return false\n return editor.getNode(n.parentId)?.layoutMode === 'GRID'\n })\n const isFlex = computed(\n () => node.value?.layoutMode === 'HORIZONTAL' || node.value?.layoutMode === 'VERTICAL'\n )\n const widthSizing = computed(() => axisSizingForNode(editor.graph, node.value, 'width'))\n const heightSizing = computed(() => axisSizingForNode(editor.graph, node.value, 'height'))\n\n function sizingOptions() {\n return sizingOptionsForNode(editor.graph, node.value, {\n FIXED: panels.value.sizingFixed,\n HUG: panels.value.sizingHug,\n FILL: panels.value.sizingFill\n })\n }\n\n const widthSizingOptions = computed(sizingOptions)\n const heightSizingOptions = computed(sizingOptions)\n const aspectRatioLocked = computed(() => node.value?.targetAspectRatio != null)\n const aspectRatioLockable = computed(() => {\n const n = node.value\n return !!n && aspectRatioLockEditable(editor.graph, n)\n })\n\n return {\n isInAutoLayout,\n aspectRatioLocked,\n aspectRatioLockable,\n isGrid,\n isGridChild,\n isFlex,\n widthSizing,\n heightSizing,\n widthSizingOptions,\n heightSizingOptions\n }\n}\n"],"mappings":";;;;;;AAgDA,MAAM,mBAAgC;CACpC;EAAE,SAAS;EAAO,SAAS;CAAM;CACjC;EAAE,SAAS;EAAU,SAAS;CAAM;CACpC;EAAE,SAAS;EAAO,SAAS;CAAM;CACjC;EAAE,SAAS;EAAO,SAAS;CAAS;CACpC;EAAE,SAAS;EAAU,SAAS;CAAS;CACvC;EAAE,SAAS;EAAO,SAAS;CAAS;CACpC;EAAE,SAAS;EAAO,SAAS;CAAM;CACjC;EAAE,SAAS;EAAU,SAAS;CAAM;CACpC;EAAE,SAAS;EAAO,SAAS;CAAM;AACnC;AAEA,MAAM,iBAA8B;CAClC;EAAE,SAAS;EAAO,SAAS;CAAM;CACjC;EAAE,SAAS;EAAO,SAAS;CAAS;CACpC;EAAE,SAAS;EAAO,SAAS;CAAM;CACjC;EAAE,SAAS;EAAU,SAAS;CAAM;CACpC;EAAE,SAAS;EAAU,SAAS;CAAS;CACvC;EAAE,SAAS;EAAU,SAAS;CAAM;CACpC;EAAE,SAAS;EAAO,SAAS;CAAM;CACjC;EAAE,SAAS;EAAO,SAAS;CAAS;CACpC;EAAE,SAAS;EAAO,SAAS;CAAM;AACnC;AAEA,SAAgB,2BACd,QACA,QACA;CACA,MAAM,EAAE,SAAS,qBAAqB,MAAM;CAC5C,MAAM,kBAAkB,eAChB,KAAK,OAAO,mBAAmB,MACvC;CACA,MAAM,cAAc,wBAAwB,QAAQ,MAAM,MAAM;CAMhE,OAAO;EAAE;EAAM;EAAiB,SALhB,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A,MACA,QACA;CACA,MAAM,iBAAiB,eAAe;EACpC,MAAM,IAAI,KAAK;EACf,IAAI,CAAC,GAAG,UAAU,OAAO;EACzB,MAAM,SAAS,OAAO,QAAQ,EAAE,QAAQ;EACxC,OAAO,SAAS,OAAO,eAAe,SAAS;CACjD,CAAC;CAED,MAAM,SAAS,eAAe,KAAK,OAAO,eAAe,MAAM;CAC/D,MAAM,cAAc,eAAe;EACjC,MAAM,IAAI,KAAK;EACf,IAAI,CAAC,GAAG,UAAU,OAAO;EACzB,OAAO,OAAO,QAAQ,EAAE,QAAQ,CAAC,EAAE,eAAe;CACpD,CAAC;CACD,MAAM,SAAS,eACP,KAAK,OAAO,eAAe,gBAAgB,KAAK,OAAO,eAAe,UAC9E;CACA,MAAM,cAAc,eAAe,kBAAkB,OAAO,OAAO,KAAK,OAAO,OAAO,CAAC;CACvF,MAAM,eAAe,eAAe,kBAAkB,OAAO,OAAO,KAAK,OAAO,QAAQ,CAAC;CAEzF,SAAS,gBAAgB;EACvB,OAAO,qBAAqB,OAAO,OAAO,KAAK,OAAO;GACpD,OAAO,OAAO,MAAM;GACpB,KAAK,OAAO,MAAM;GAClB,MAAM,OAAO,MAAM;EACrB,CAAC;CACH;CAEA,MAAM,qBAAqB,SAAS,aAAa;CACjD,MAAM,sBAAsB,SAAS,aAAa;CAOlD,OAAO;EACL;EACA,mBARwB,eAAe,KAAK,OAAO,qBAAqB,IAQxD;EAChB,qBAR0B,eAAe;GACzC,MAAM,IAAI,KAAK;GACf,OAAO,CAAC,CAAC,KAAK,wBAAwB,OAAO,OAAO,CAAC;EACvD,CAKoB;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
@@ -9,11 +9,13 @@ import { LayoutAxis, SizeLimitProp, trackLabel } from "./helpers.js";
9
9
  declare function useLayout(): {
10
10
  editor: import("@pairdraw/core").Editor;
11
11
  node: import("vue").ComputedRef<import("@pairdraw/scene-graph").SceneNode | null>;
12
+ isMulti: import("vue").ComputedRef<boolean>;
12
13
  resizes: import("vue").ComputedRef<boolean>;
13
14
  layoutDirection: import("vue").ComputedRef<import("@pairdraw/scene-graph").LayoutDirection>;
14
15
  gapAuto: import("vue").ComputedRef<boolean>;
15
16
  isInAutoLayout: import("vue").ComputedRef<boolean>;
16
17
  isGrid: import("vue").ComputedRef<boolean>;
18
+ isGridChild: import("vue").ComputedRef<boolean>;
17
19
  isFlex: import("vue").ComputedRef<boolean>;
18
20
  widthSizing: import("vue").ComputedRef<import("@pairdraw/scene-graph").LayoutSizing>;
19
21
  heightSizing: import("vue").ComputedRef<import("@pairdraw/scene-graph").LayoutSizing>;
@@ -1 +1 @@
1
- {"version":3,"file":"use.d.ts","names":[],"sources":["../../../src/controls/layout/use.ts"],"mappings":";;;;;;;;iBAqBgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAAA"}
1
+ {"version":3,"file":"use.d.ts","names":[],"sources":["../../../src/controls/layout/use.ts"],"mappings":";;;;;;;;iBAqBgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAAA"}