@threadlabs/looma 0.1.16 → 0.1.18

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 (133) hide show
  1. package/README.md +2 -1
  2. package/dist/{chunk-SVINNT3E.js → chunk-DTQVRGVL.js} +29 -29
  3. package/dist/{chunk-G53JEAQK.js → chunk-SZJQ3NPX.js} +6 -3
  4. package/dist/chunk-YHXJC5M5.js +341 -0
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/cjs/looma.cjs.js +1 -1
  7. package/dist/cjs/{manager-BOpVXb92.js → manager-C9j3HZay.js} +5 -2
  8. package/dist/cjs/positioning-i0WrCAdF.js +384 -0
  9. package/dist/cjs/ui-affordance-scope.cjs.entry.js +3 -113
  10. package/dist/cjs/ui-context-menu.cjs.entry.js +43 -5
  11. package/dist/cjs/ui-dialog.cjs.entry.js +1 -1
  12. package/dist/cjs/ui-menu.cjs.entry.js +83 -2
  13. package/dist/cjs/ui-popover.cjs.entry.js +43 -3
  14. package/dist/cjs/ui-toast-region.cjs.entry.js +17 -2
  15. package/dist/cjs/ui-tooltip.cjs.entry.js +95 -27
  16. package/dist/cjs/ui-tree-item.cjs.entry.js +1 -1
  17. package/dist/collection/components/ui-context-menu/ui-context-menu.css +21 -4
  18. package/dist/collection/components/ui-context-menu/ui-context-menu.js +43 -4
  19. package/dist/collection/components/ui-menu/ui-menu.css +39 -0
  20. package/dist/collection/components/ui-menu/ui-menu.js +128 -1
  21. package/dist/collection/components/ui-popover/ui-popover.css +31 -0
  22. package/dist/collection/components/ui-popover/ui-popover.js +87 -1
  23. package/dist/collection/components/ui-toast-region/ui-toast-region.css +6 -0
  24. package/dist/collection/components/ui-toast-region/ui-toast-region.js +16 -1
  25. package/dist/collection/components/ui-tooltip/ui-tooltip.css +20 -0
  26. package/dist/collection/components/ui-tooltip/ui-tooltip.js +160 -25
  27. package/dist/collection/components/ui-tree-item/ui-tree-item.css +10 -6
  28. package/dist/collection/input-modality.js +24 -0
  29. package/dist/collection/overlay/manager.js +5 -2
  30. package/dist/collection/overlay/positioning.js +246 -0
  31. package/dist/components/p-CEYIKqYc.js +1 -0
  32. package/dist/components/p-DOulVJT7.js +1 -0
  33. package/dist/components/p-PM9a74r7.js +1 -0
  34. package/dist/components/ui-affordance-scope.js +1 -1
  35. package/dist/components/ui-context-menu.js +1 -1
  36. package/dist/components/ui-dialog.js +1 -1
  37. package/dist/components/ui-menu.js +1 -1
  38. package/dist/components/ui-popover.js +1 -1
  39. package/dist/components/ui-toast-region.js +1 -1
  40. package/dist/components/ui-tooltip.js +1 -1
  41. package/dist/components/ui-tree-item.js +1 -1
  42. package/dist/esm/loader.js +1 -1
  43. package/dist/esm/looma.js +1 -1
  44. package/dist/esm/{manager-CR7f2MQC.js → manager-PM9a74r7.js} +5 -2
  45. package/dist/esm/positioning-Bu0dmLBE.js +379 -0
  46. package/dist/esm/ui-affordance-scope.entry.js +1 -111
  47. package/dist/esm/ui-context-menu.entry.js +43 -5
  48. package/dist/esm/ui-dialog.entry.js +1 -1
  49. package/dist/esm/ui-menu.entry.js +83 -2
  50. package/dist/esm/ui-popover.entry.js +43 -3
  51. package/dist/esm/ui-toast-region.entry.js +17 -2
  52. package/dist/esm/ui-tooltip.entry.js +95 -27
  53. package/dist/esm/ui-tree-item.entry.js +1 -1
  54. package/dist/index.cjs +779 -59
  55. package/dist/index.d.cts +44 -1
  56. package/dist/index.d.ts +44 -1
  57. package/dist/index.js +235 -4
  58. package/dist/looma/looma.esm.js +1 -1
  59. package/dist/looma/p-063f5a89.entry.js +1 -0
  60. package/dist/looma/{p-c6721aba.entry.js → p-11083743.entry.js} +1 -1
  61. package/dist/looma/p-1674cda4.entry.js +1 -0
  62. package/dist/looma/p-2e6f791e.entry.js +1 -0
  63. package/dist/looma/p-54c41576.entry.js +1 -0
  64. package/dist/looma/p-9194a99d.entry.js +1 -0
  65. package/dist/looma/p-Bu0dmLBE.js +1 -0
  66. package/dist/looma/p-PM9a74r7.js +1 -0
  67. package/dist/looma/p-caa8fc7b.entry.js +1 -0
  68. package/dist/looma/{p-ef9ca2ed.entry.js → p-d01960c2.entry.js} +2 -2
  69. package/dist/types/components/ui-context-menu/ui-context-menu.d.ts +6 -0
  70. package/dist/types/components/ui-menu/ui-menu.d.ts +13 -0
  71. package/dist/types/components/ui-popover/ui-popover.d.ts +9 -0
  72. package/dist/types/components/ui-toast-region/ui-toast-region.d.ts +2 -0
  73. package/dist/types/components/ui-tooltip/ui-tooltip.d.ts +16 -1
  74. package/dist/types/components.d.ts +71 -0
  75. package/dist/types/input-modality.d.ts +6 -0
  76. package/dist/types/overlay/manager.d.ts +3 -0
  77. package/dist/types/overlay/positioning.d.ts +33 -0
  78. package/dist/ui-affordance-scope.entry-2W7ZKAGK.js +54 -0
  79. package/dist/{ui-avatar-group.entry-DQDP325O.js → ui-avatar-group.entry-SE5JG2FT.js} +1 -1
  80. package/dist/{ui-avatar.entry-WYIDMOFE.js → ui-avatar.entry-46JDI25A.js} +1 -1
  81. package/dist/{ui-badge.entry-VGHXPEDT.js → ui-badge.entry-U7G3MEC5.js} +1 -1
  82. package/dist/{ui-button.entry-LKPLOJ22.js → ui-button.entry-DELD6KMH.js} +1 -1
  83. package/dist/{ui-checkbox.entry-J74HEA22.js → ui-checkbox.entry-ZUG2P642.js} +1 -1
  84. package/dist/{ui-context-menu.entry-MQM2FCLI.js → ui-context-menu.entry-L4HTK3PV.js} +43 -6
  85. package/dist/{ui-dialog.entry-DQMMDO4Z.js → ui-dialog.entry-TQPYD2YI.js} +2 -2
  86. package/dist/{ui-disclosure.entry-ONF7UZDC.js → ui-disclosure.entry-23TII4YU.js} +1 -1
  87. package/dist/{ui-floating-action-button.entry-FKTGVC5T.js → ui-floating-action-button.entry-FOQYAFJI.js} +1 -1
  88. package/dist/{ui-form-field.entry-M3ISWQNU.js → ui-form-field.entry-SCPG4STY.js} +1 -1
  89. package/dist/{ui-icon-button.entry-AWFIQUHM.js → ui-icon-button.entry-U45ZVAC3.js} +1 -1
  90. package/dist/{ui-input.entry-JZ6RETMT.js → ui-input.entry-3AIA3G4C.js} +1 -1
  91. package/dist/{ui-menu-item.entry-5MFR5LFL.js → ui-menu-item.entry-3QO5TG2J.js} +1 -1
  92. package/dist/ui-menu.entry-JACWGDDG.js +184 -0
  93. package/dist/{ui-popover.entry-ELCMKO6Y.js → ui-popover.entry-2XP4H3S2.js} +46 -4
  94. package/dist/{ui-radio-group.entry-RJHUPPEM.js → ui-radio-group.entry-73IKFMDK.js} +1 -1
  95. package/dist/{ui-radio.entry-3VRDPOY4.js → ui-radio.entry-INJVXUKE.js} +1 -1
  96. package/dist/{ui-search-result-row.entry-J34YPAV7.js → ui-search-result-row.entry-4J732TDC.js} +1 -1
  97. package/dist/{ui-search-shell.entry-IJ4UUP27.js → ui-search-shell.entry-3C2WRVE2.js} +1 -1
  98. package/dist/{ui-select.entry-C6YD3HQ5.js → ui-select.entry-3ZLDGAKX.js} +1 -1
  99. package/dist/{ui-switch.entry-UZDF5QTI.js → ui-switch.entry-5MJRLR2P.js} +1 -1
  100. package/dist/{ui-tabs.entry-YRAKWOMR.js → ui-tabs.entry-F5H7OPBO.js} +1 -1
  101. package/dist/{ui-textarea.entry-JLDKFT3K.js → ui-textarea.entry-BNJ375JB.js} +1 -1
  102. package/dist/{ui-toast-region.entry-GC7C7KXF.js → ui-toast-region.entry-ZUIPJ2JH.js} +20 -3
  103. package/dist/ui-tooltip.entry-DZ4RMF35.js +214 -0
  104. package/dist/{ui-top-bar.entry-5W5UA5KV.js → ui-top-bar.entry-VKRXIUU6.js} +1 -1
  105. package/dist/{ui-tree-item.entry-3LM7IXIK.js → ui-tree-item.entry-NFUQ45OL.js} +2 -2
  106. package/dist/{ui-tree.entry-X4FU42A6.js → ui-tree.entry-H4CWDYI6.js} +1 -1
  107. package/editor/{chunk-RTHHTPWK.js → chunk-3QMBK3XZ.js} +245 -41
  108. package/editor/{chunk-OHD4OS32.js → chunk-OXFYYLUC.js} +632 -236
  109. package/editor/{chunk-CX4QDKSV.js → chunk-ZOUKEZ77.js} +21 -1
  110. package/editor/extensions/index.d.ts +49 -1
  111. package/editor/extensions/index.js +15 -3
  112. package/editor/index.d.ts +3 -2
  113. package/editor/index.js +16 -4
  114. package/editor/ui.d.ts +9 -1
  115. package/editor/ui.js +2 -2
  116. package/editor.css +173 -4
  117. package/package.json +1 -1
  118. package/styles.css +1 -7
  119. package/tokens.css +14 -2
  120. package/vue/editor/index.d.ts +103 -4
  121. package/vue/editor/index.js +199 -114
  122. package/dist/components/p-CR7f2MQC.js +0 -1
  123. package/dist/components/p-QiwSQmKJ.js +0 -1
  124. package/dist/looma/p-2ae73d5b.entry.js +0 -1
  125. package/dist/looma/p-3ac2e0d4.entry.js +0 -1
  126. package/dist/looma/p-65c25c94.entry.js +0 -1
  127. package/dist/looma/p-8c09c724.entry.js +0 -1
  128. package/dist/looma/p-95cd639d.entry.js +0 -1
  129. package/dist/looma/p-96f73d07.entry.js +0 -1
  130. package/dist/looma/p-CR7f2MQC.js +0 -1
  131. package/dist/ui-affordance-scope.entry-PFP2TDKO.js +0 -145
  132. package/dist/ui-menu.entry-IOEIDATQ.js +0 -98
  133. package/dist/ui-tooltip.entry-F26XDTYX.js +0 -145
@@ -1,6 +1,7 @@
1
1
  import { Host, h } from "@stencil/core";
2
2
  import { openOverlay, closeOverlay, requestTopOverlayClose } from "../../overlay/manager";
3
3
  import { dispatchDetail } from "../../utils/events";
4
+ import { createAnchoredSurface } from "../../overlay/positioning";
4
5
  export class UIContextMenu {
5
6
  host;
6
7
  /** Controls the menu when the consumer owns open state. */
@@ -10,11 +11,14 @@ export class UIContextMenu {
10
11
  /** Optional id of the region that should also respond to a context-menu gesture. */
11
12
  for;
12
13
  internalOpen = false;
14
+ focusTrigger = 'programmatic';
13
15
  overlayId = `ui-context-menu-${Math.random().toString(36).slice(2, 11)}`;
14
16
  trigger = null;
15
17
  contextTarget = null;
16
18
  pointerX = 0;
17
19
  pointerY = 0;
20
+ pointPositioned = false;
21
+ surface = null;
18
22
  syncFromProp() {
19
23
  this.internalOpen = this.open;
20
24
  }
@@ -25,6 +29,12 @@ export class UIContextMenu {
25
29
  syncOverlay() {
26
30
  this.syncTriggerState();
27
31
  if (this.internalOpen) {
32
+ if (this.pointPositioned) {
33
+ this.surface?.showAtPoint({ x: this.pointerX, y: this.pointerY });
34
+ }
35
+ else {
36
+ this.surface?.show();
37
+ }
28
38
  openOverlay({
29
39
  id: this.overlayId,
30
40
  modal: false,
@@ -34,6 +44,7 @@ export class UIContextMenu {
34
44
  });
35
45
  }
36
46
  else {
47
+ this.surface?.hide();
37
48
  closeOverlay(this.overlayId);
38
49
  }
39
50
  }
@@ -42,18 +53,33 @@ export class UIContextMenu {
42
53
  this.internalOpen = this.internalOpen || this.defaultOpen;
43
54
  this.resolveTargets();
44
55
  this.attachTargetListeners();
56
+ this.setupSurface();
45
57
  this.syncTriggerState();
46
58
  this.syncOverlay();
47
59
  }
48
60
  componentDidUpdate() {
49
61
  this.resolveTargets();
50
62
  this.attachTargetListeners();
63
+ if (!this.pointPositioned)
64
+ this.surface?.setAnchor(this.trigger);
51
65
  this.syncTriggerState();
52
66
  }
53
67
  disconnectedCallback() {
54
68
  this.detachTargetListeners();
69
+ this.surface?.destroy();
70
+ this.surface = null;
55
71
  closeOverlay(this.overlayId);
56
72
  }
73
+ setupSurface() {
74
+ const menu = this.host.shadowRoot?.querySelector('.menu');
75
+ if (!menu)
76
+ return;
77
+ this.surface?.destroy();
78
+ this.surface = createAnchoredSurface(menu, {
79
+ anchor: this.trigger,
80
+ placement: 'bottom-start',
81
+ });
82
+ }
57
83
  resolveTargets() {
58
84
  const previousTrigger = this.trigger;
59
85
  const previousContextTarget = this.contextTarget;
@@ -93,6 +119,11 @@ export class UIContextMenu {
93
119
  openMenu(x, y, trigger) {
94
120
  this.pointerX = x;
95
121
  this.pointerY = y;
122
+ this.focusTrigger = trigger;
123
+ this.pointPositioned = true;
124
+ // Context-click can reposition an already-open trigger menu, so do not
125
+ // depend on a state transition to run the positioning controller.
126
+ this.surface?.showAtPoint({ x, y });
96
127
  this.internalOpen = true;
97
128
  dispatchDetail(this.host, 'open', {
98
129
  open: true,
@@ -104,8 +135,14 @@ export class UIContextMenu {
104
135
  openFromTrigger(trigger) {
105
136
  if (!this.trigger)
106
137
  return;
107
- const rect = this.trigger.getBoundingClientRect();
108
- this.openMenu(rect.left, rect.bottom, trigger);
138
+ this.pointPositioned = false;
139
+ this.internalOpen = true;
140
+ dispatchDetail(this.host, 'open', {
141
+ open: true,
142
+ reason: 'action',
143
+ trigger,
144
+ });
145
+ this.focusFirstItem();
109
146
  }
110
147
  closeMenu(reason, trigger, returnFocus = true) {
111
148
  if (!this.internalOpen)
@@ -150,6 +187,7 @@ export class UIContextMenu {
150
187
  onKeydown = (event) => {
151
188
  if (!this.internalOpen)
152
189
  return;
190
+ this.focusTrigger = 'keyboard';
153
191
  if (event.key === 'Escape') {
154
192
  event.preventDefault();
155
193
  requestTopOverlayClose('escape', 'keyboard');
@@ -174,7 +212,7 @@ export class UIContextMenu {
174
212
  this.closeMenu('action', 'pointer');
175
213
  };
176
214
  render() {
177
- return (h(Host, { key: '79fbca2c89f1d1fd1f4796ad88d2a599e811a3f9', "data-open": this.internalOpen ? '' : undefined, onKeyDown: this.onKeydown, onClick: this.onItemClick }, h("slot", { key: '9308cadfa155930e3e46dfb4a69a847ae388958b', name: "trigger" }), h("div", { key: '16cfba2b32444ac9e3cac1f040f81f17fd5db23c', class: "menu", "data-open": this.internalOpen ? '' : undefined, style: { left: `${this.pointerX}px`, top: `${this.pointerY}px` } }, h("ui-menu", { key: '59f18e0df3bb1fe85efa8eeca00b336bbde47c70', open: this.internalOpen }, h("slot", { key: '5bdbb7773c9c1ae43ec2e05fca9558482815e28a' })))));
215
+ return (h(Host, { key: '4db0d5b55ead41925aa682b1e383b5735b49bf56', "data-open": this.internalOpen ? '' : undefined, "data-focus-trigger": this.internalOpen ? this.focusTrigger : undefined, onKeyDown: this.onKeydown, onClick: this.onItemClick }, h("slot", { key: '462925d53db169c13e485789ae91e28b0abd3e40', name: "trigger" }), h("div", { key: 'cac8f3b11c4872d38e976f210ce9a43fd854b335', class: "menu", "data-open": this.internalOpen ? '' : undefined }, h("ui-menu", { key: 'ba50f74e11466da2240f7568479d5d10a614b394', open: this.internalOpen }, h("slot", { key: '1fcb45bf124e2377ac6c7fc236d2babf0d9e3bae' })))));
178
216
  }
179
217
  static get is() { return "ui-context-menu"; }
180
218
  static get encapsulation() { return "shadow"; }
@@ -253,7 +291,8 @@ export class UIContextMenu {
253
291
  }
254
292
  static get states() {
255
293
  return {
256
- "internalOpen": {}
294
+ "internalOpen": {},
295
+ "focusTrigger": {}
257
296
  };
258
297
  }
259
298
  static get elementRef() { return "host"; }
@@ -12,6 +12,45 @@
12
12
  box-shadow: var(--ui-shadow-lg);
13
13
  }
14
14
 
15
+ :host(:not([data-open])) {
16
+ display: none;
17
+ }
18
+
19
+ :host([popover]) {
20
+ position: fixed;
21
+ inset: auto;
22
+ margin: 0;
23
+ overflow: auto;
24
+ max-block-size: calc(100dvh - (var(--ui-menu-viewport-gap) * 2));
25
+ opacity: 0;
26
+ transform: translateY(-4px) scale(0.99);
27
+ transition:
28
+ opacity var(--ui-motion-fast) var(--ui-motion-ease),
29
+ transform var(--ui-motion-fast) var(--ui-motion-ease),
30
+ display var(--ui-motion-fast) allow-discrete,
31
+ overlay var(--ui-motion-fast) allow-discrete;
32
+ }
33
+
34
+ :host([popover]:popover-open) {
35
+ opacity: 1;
36
+ transform: translateY(0) scale(1);
37
+ }
38
+
39
+ @starting-style {
40
+ :host([popover]:popover-open) {
41
+ opacity: 0;
42
+ transform: translateY(-4px) scale(0.99);
43
+ }
44
+ }
45
+
46
+ :host([hidden]) {
47
+ display: none !important;
48
+ }
49
+
50
+ @media (prefers-reduced-motion: reduce) {
51
+ :host([popover]) { transition: none; }
52
+ }
53
+
15
54
  ::slotted(ui-menu-item) {
16
55
  display: block;
17
56
  width: 100%;
@@ -1,23 +1,90 @@
1
1
  import { Host, h } from "@stencil/core";
2
2
  import { eventToTrigger } from "../../utils/events";
3
3
  import { dispatchDetail } from "../../utils/events";
4
+ import { closeOverlay, openOverlay, requestTopOverlayClose } from "../../overlay/manager";
5
+ import { createAnchoredSurface, } from "../../overlay/positioning";
4
6
  export class UIMenu {
5
7
  host;
6
8
  open = false;
7
9
  defaultOpen = false;
10
+ /** Id of the control that anchors this menu in the top layer. */
11
+ for;
12
+ /** Preferred placement; Looma flips and shifts when space is constrained. */
13
+ placement = 'bottom-start';
8
14
  internalOpen = false;
15
+ overlayId = `ui-menu-${Math.random().toString(36).slice(2, 11)}`;
16
+ anchor = null;
17
+ surface = null;
9
18
  syncFromProp() {
10
19
  this.internalOpen = this.open;
11
20
  }
21
+ resetSurface() {
22
+ this.setupSurface();
23
+ this.syncSurface();
24
+ }
25
+ syncSurface() {
26
+ this.syncAnchorState();
27
+ if (!this.surface)
28
+ return;
29
+ if (this.internalOpen) {
30
+ this.surface.show();
31
+ openOverlay({
32
+ id: this.overlayId,
33
+ modal: false,
34
+ element: this.host,
35
+ relatedElements: this.anchor ? [this.anchor] : undefined,
36
+ dismissible: true,
37
+ requestClose: (reason, trigger) => this.closeMenu(reason, trigger),
38
+ });
39
+ }
40
+ else {
41
+ this.surface.hide();
42
+ closeOverlay(this.overlayId);
43
+ }
44
+ }
12
45
  componentDidLoad() {
13
46
  this.syncFromProp();
14
47
  this.internalOpen = this.internalOpen || this.defaultOpen;
15
48
  this.host.addEventListener('click', this.onItemClick);
16
49
  this.host.addEventListener('keydown', this.onKeydown);
50
+ this.setupSurface();
51
+ this.syncSurface();
17
52
  }
18
53
  disconnectedCallback() {
19
54
  this.host.removeEventListener('click', this.onItemClick);
20
55
  this.host.removeEventListener('keydown', this.onKeydown);
56
+ this.surface?.destroy();
57
+ this.surface = null;
58
+ closeOverlay(this.overlayId);
59
+ }
60
+ setupSurface() {
61
+ this.surface?.destroy();
62
+ this.surface = null;
63
+ this.anchor = this.for ? this.host.ownerDocument.getElementById(this.for) : null;
64
+ if (!this.anchor)
65
+ return;
66
+ this.surface = createAnchoredSurface(this.host, {
67
+ anchor: this.anchor,
68
+ placement: this.placement,
69
+ });
70
+ }
71
+ syncAnchorState() {
72
+ if (!this.anchor)
73
+ return;
74
+ this.anchor.setAttribute('aria-haspopup', 'menu');
75
+ this.anchor.setAttribute('aria-expanded', this.internalOpen ? 'true' : 'false');
76
+ }
77
+ closeMenu(reason, trigger) {
78
+ if (!this.internalOpen)
79
+ return;
80
+ this.internalOpen = false;
81
+ dispatchDetail(this.host, 'close', {
82
+ open: false,
83
+ reason: reason,
84
+ trigger: trigger,
85
+ });
86
+ if (reason === 'escape')
87
+ this.anchor?.focus();
21
88
  }
22
89
  getItems() {
23
90
  return Array.from(this.host.querySelectorAll('ui-menu-item'));
@@ -44,6 +111,11 @@ export class UIMenu {
44
111
  this.internalOpen = false;
45
112
  };
46
113
  onKeydown = (e) => {
114
+ if (e.key === 'Escape') {
115
+ e.preventDefault();
116
+ requestTopOverlayClose('escape', 'keyboard');
117
+ return;
118
+ }
47
119
  const items = this.getItems().filter((i) => !this.isItemDisabled(i));
48
120
  if (items.length === 0)
49
121
  return;
@@ -76,7 +148,7 @@ export class UIMenu {
76
148
  }
77
149
  };
78
150
  render() {
79
- return (h(Host, { key: '5e463cbbce272c6b6132a839b818deef3e39a532', role: "menu", "aria-orientation": "vertical", "data-open": this.internalOpen ? '' : undefined }, h("slot", { key: 'feea6a21d41a7b27a6270814bcf0b3f3ded394a1' })));
151
+ return (h(Host, { key: '06ad0750df843cb874bd4f257d8567157c855493', role: "menu", "aria-orientation": "vertical", "data-open": this.internalOpen ? '' : undefined }, h("slot", { key: '50118ac749a2747ca06f4d483499c4cd20125a89' })));
80
152
  }
81
153
  static get is() { return "ui-menu"; }
82
154
  static get encapsulation() { return "shadow"; }
@@ -131,6 +203,52 @@ export class UIMenu {
131
203
  "reflect": false,
132
204
  "attribute": "default-open",
133
205
  "defaultValue": "false"
206
+ },
207
+ "for": {
208
+ "type": "string",
209
+ "mutable": false,
210
+ "complexType": {
211
+ "original": "string",
212
+ "resolved": "string",
213
+ "references": {}
214
+ },
215
+ "required": false,
216
+ "optional": true,
217
+ "docs": {
218
+ "tags": [],
219
+ "text": "Id of the control that anchors this menu in the top layer."
220
+ },
221
+ "getter": false,
222
+ "setter": false,
223
+ "reflect": false,
224
+ "attribute": "for"
225
+ },
226
+ "placement": {
227
+ "type": "string",
228
+ "mutable": false,
229
+ "complexType": {
230
+ "original": "AnchoredPlacement",
231
+ "resolved": "\"bottom-end\" | \"bottom-start\" | \"top-end\" | \"top-start\"",
232
+ "references": {
233
+ "AnchoredPlacement": {
234
+ "location": "import",
235
+ "path": "../../overlay/positioning",
236
+ "id": "src/overlay/positioning.ts::AnchoredPlacement",
237
+ "referenceLocation": "AnchoredPlacement"
238
+ }
239
+ }
240
+ },
241
+ "required": false,
242
+ "optional": false,
243
+ "docs": {
244
+ "tags": [],
245
+ "text": "Preferred placement; Looma flips and shifts when space is constrained."
246
+ },
247
+ "getter": false,
248
+ "setter": false,
249
+ "reflect": false,
250
+ "attribute": "placement",
251
+ "defaultValue": "'bottom-start'"
134
252
  }
135
253
  };
136
254
  }
@@ -144,6 +262,15 @@ export class UIMenu {
144
262
  return [{
145
263
  "propName": "open",
146
264
  "methodName": "syncFromProp"
265
+ }, {
266
+ "propName": "for",
267
+ "methodName": "resetSurface"
268
+ }, {
269
+ "propName": "placement",
270
+ "methodName": "resetSurface"
271
+ }, {
272
+ "propName": "internalOpen",
273
+ "methodName": "syncSurface"
147
274
  }];
148
275
  }
149
276
  }
@@ -12,3 +12,34 @@
12
12
  max-block-size: calc(100dvh - (var(--ui-popover-viewport-gap) * 2));
13
13
  overflow: auto;
14
14
  }
15
+
16
+ :host(:not([data-open])) {
17
+ display: none;
18
+ }
19
+
20
+ :host([popover]) {
21
+ position: fixed;
22
+ inset: auto;
23
+ margin: 0;
24
+ opacity: 0;
25
+ transform: translateY(-4px) scale(0.99);
26
+ transition:
27
+ opacity var(--ui-motion-fast) var(--ui-motion-ease),
28
+ transform var(--ui-motion-fast) var(--ui-motion-ease),
29
+ display var(--ui-motion-fast) allow-discrete,
30
+ overlay var(--ui-motion-fast) allow-discrete;
31
+ }
32
+
33
+ :host([popover]:popover-open) { opacity: 1; transform: translateY(0) scale(1); }
34
+
35
+ @starting-style {
36
+ :host([popover]:popover-open) { opacity: 0; transform: translateY(-4px) scale(0.99); }
37
+ }
38
+
39
+ :host([hidden]) {
40
+ display: none !important;
41
+ }
42
+
43
+ @media (prefers-reduced-motion: reduce) {
44
+ :host([popover]) { transition: none; }
45
+ }
@@ -1,12 +1,18 @@
1
1
  import { Host, h } from "@stencil/core";
2
2
  import { openOverlay, closeOverlay, requestTopOverlayClose } from "../../overlay/manager";
3
3
  import { dispatchDetail } from "../../utils/events";
4
+ import { createAnchoredSurface, } from "../../overlay/positioning";
4
5
  export class UIPopover {
5
6
  host;
6
7
  open = false;
7
8
  defaultOpen = false;
9
+ /** Optional id of the element this popover follows in the top layer. */
10
+ for;
11
+ placement = 'bottom-start';
8
12
  internalOpen = false;
9
13
  overlayId = `ui-popover-${Math.random().toString(36).slice(2, 11)}`;
14
+ anchor = null;
15
+ surface = null;
10
16
  syncFromProp() {
11
17
  this.internalOpen = this.open;
12
18
  }
@@ -27,12 +33,37 @@ export class UIPopover {
27
33
  });
28
34
  }
29
35
  }
36
+ resetSurface() {
37
+ this.setupSurface();
38
+ this.syncSurface();
39
+ }
40
+ setupSurface() {
41
+ this.surface?.destroy();
42
+ this.surface = null;
43
+ this.anchor = this.for ? this.host.ownerDocument.getElementById(this.for) : null;
44
+ if (!this.anchor)
45
+ return;
46
+ this.surface = createAnchoredSurface(this.host, {
47
+ anchor: this.anchor,
48
+ placement: this.placement,
49
+ });
50
+ }
51
+ syncSurface() {
52
+ if (!this.surface)
53
+ return;
54
+ if (this.internalOpen)
55
+ this.surface.show();
56
+ else
57
+ this.surface.hide();
58
+ }
30
59
  syncOverlay() {
60
+ this.syncSurface();
31
61
  if (this.internalOpen) {
32
62
  openOverlay({
33
63
  id: this.overlayId,
34
64
  modal: false,
35
65
  element: this.host,
66
+ relatedElements: this.anchor ? [this.anchor] : undefined,
36
67
  dismissible: true,
37
68
  requestClose: (reason, trigger) => this.handleRequestClose(reason, trigger),
38
69
  });
@@ -45,10 +76,13 @@ export class UIPopover {
45
76
  this.syncFromProp();
46
77
  this.internalOpen = this.internalOpen || this.defaultOpen;
47
78
  this.host.addEventListener('keydown', this.onKeydown);
79
+ this.setupSurface();
48
80
  this.syncOverlay();
49
81
  }
50
82
  disconnectedCallback() {
51
83
  this.host.removeEventListener('keydown', this.onKeydown);
84
+ this.surface?.destroy();
85
+ this.surface = null;
52
86
  closeOverlay(this.overlayId);
53
87
  }
54
88
  componentDidUpdate() {
@@ -68,7 +102,7 @@ export class UIPopover {
68
102
  }
69
103
  };
70
104
  render() {
71
- return (h(Host, { key: '67e7f52220db9d997fb11b686d6abcbdf9557a8d', "data-open": this.internalOpen ? '' : undefined, onKeyDown: this.onKeydown }, h("slot", { key: 'd7c1fa2ab75994fe0a7dd63f8289754c7754c30f' })));
105
+ return (h(Host, { key: '8e45be54147ff8f76a0d5e7fd875c3f4cf5ac40a', "data-open": this.internalOpen ? '' : undefined, onKeyDown: this.onKeydown }, h("slot", { key: '3141729cd32c8dcdaec1fbd763eb034242563c8f' })));
72
106
  }
73
107
  static get is() { return "ui-popover"; }
74
108
  static get encapsulation() { return "shadow"; }
@@ -123,6 +157,52 @@ export class UIPopover {
123
157
  "reflect": false,
124
158
  "attribute": "default-open",
125
159
  "defaultValue": "false"
160
+ },
161
+ "for": {
162
+ "type": "string",
163
+ "mutable": false,
164
+ "complexType": {
165
+ "original": "string",
166
+ "resolved": "string",
167
+ "references": {}
168
+ },
169
+ "required": false,
170
+ "optional": true,
171
+ "docs": {
172
+ "tags": [],
173
+ "text": "Optional id of the element this popover follows in the top layer."
174
+ },
175
+ "getter": false,
176
+ "setter": false,
177
+ "reflect": false,
178
+ "attribute": "for"
179
+ },
180
+ "placement": {
181
+ "type": "string",
182
+ "mutable": false,
183
+ "complexType": {
184
+ "original": "AnchoredPlacement",
185
+ "resolved": "\"bottom-end\" | \"bottom-start\" | \"top-end\" | \"top-start\"",
186
+ "references": {
187
+ "AnchoredPlacement": {
188
+ "location": "import",
189
+ "path": "../../overlay/positioning",
190
+ "id": "src/overlay/positioning.ts::AnchoredPlacement",
191
+ "referenceLocation": "AnchoredPlacement"
192
+ }
193
+ }
194
+ },
195
+ "required": false,
196
+ "optional": false,
197
+ "docs": {
198
+ "tags": [],
199
+ "text": ""
200
+ },
201
+ "getter": false,
202
+ "setter": false,
203
+ "reflect": false,
204
+ "attribute": "placement",
205
+ "defaultValue": "'bottom-start'"
126
206
  }
127
207
  };
128
208
  }
@@ -139,6 +219,12 @@ export class UIPopover {
139
219
  }, {
140
220
  "propName": "internalOpen",
141
221
  "methodName": "onOpenChange"
222
+ }, {
223
+ "propName": "for",
224
+ "methodName": "resetSurface"
225
+ }, {
226
+ "propName": "placement",
227
+ "methodName": "resetSurface"
142
228
  }];
143
229
  }
144
230
  }
@@ -11,6 +11,12 @@
11
11
  pointer-events: none;
12
12
  }
13
13
 
14
+ :host([popover]) {
15
+ right: auto;
16
+ bottom: auto;
17
+ margin: 0;
18
+ }
19
+
14
20
  :host > * {
15
21
  pointer-events: auto;
16
22
  }
@@ -1,19 +1,31 @@
1
1
  import { Host, h } from "@stencil/core";
2
2
  import { eventToTrigger } from "../../utils/events";
3
3
  import { dispatchDetail } from "../../utils/events";
4
+ import { createViewportSurface } from "../../overlay/positioning";
4
5
  export class UIToastRegion {
5
6
  host;
6
7
  open = true;
7
8
  internalOpen = true;
9
+ surface = null;
8
10
  syncFromProp() {
9
11
  this.internalOpen = this.open;
10
12
  }
13
+ syncSurface() {
14
+ if (this.internalOpen)
15
+ this.surface?.show();
16
+ else
17
+ this.surface?.hide();
18
+ }
11
19
  componentDidLoad() {
20
+ this.surface = createViewportSurface(this.host);
12
21
  this.syncFromProp();
22
+ this.syncSurface();
13
23
  this.host.addEventListener('click', this.onClick);
14
24
  }
15
25
  disconnectedCallback() {
16
26
  this.host.removeEventListener('click', this.onClick);
27
+ this.surface?.destroy();
28
+ this.surface = null;
17
29
  }
18
30
  getToasts() {
19
31
  return Array.from(this.host.querySelectorAll('[data-ui-toast]'));
@@ -47,7 +59,7 @@ export class UIToastRegion {
47
59
  }
48
60
  };
49
61
  render() {
50
- return (h(Host, { key: '0edcce54864ba991b092d004d3b45cf697b9c3ac', role: "region", "aria-label": "Notifications", "data-open": this.internalOpen ? '' : undefined }, h("slot", { key: '2e30794a05b018fb55c4313c8e17f7262ecee7da' })));
62
+ return (h(Host, { key: '693e24016ec0881a4d619a489f1b655feee41784', role: "region", "aria-label": "Notifications", "data-open": this.internalOpen ? '' : undefined }, h("slot", { key: 'e666b2a73a5d7eb8dd607df3d1c5135b78cf3775' })));
51
63
  }
52
64
  static get is() { return "ui-toast-region"; }
53
65
  static get encapsulation() { return "shadow"; }
@@ -95,6 +107,9 @@ export class UIToastRegion {
95
107
  return [{
96
108
  "propName": "open",
97
109
  "methodName": "syncFromProp"
110
+ }, {
111
+ "propName": "internalOpen",
112
+ "methodName": "syncSurface"
98
113
  }];
99
114
  }
100
115
  }
@@ -1,4 +1,7 @@
1
1
  :host {
2
+ position: fixed;
3
+ inset: auto;
4
+ margin: 0;
2
5
  display: inline-block;
3
6
  border: 1px solid var(--ui-border-default);
4
7
  border-radius: var(--ui-radius-2);
@@ -7,8 +10,25 @@
7
10
  padding: var(--ui-space-2) var(--ui-space-3);
8
11
  font-size: var(--ui-font-size-sm);
9
12
  box-shadow: var(--ui-shadow-md);
13
+ opacity: 0;
14
+ transform: translateY(4px);
15
+ transition:
16
+ opacity var(--ui-motion-fast) var(--ui-motion-ease),
17
+ transform var(--ui-motion-fast) var(--ui-motion-ease),
18
+ display var(--ui-motion-fast) allow-discrete,
19
+ overlay var(--ui-motion-fast) allow-discrete;
20
+ }
21
+
22
+ :host(:popover-open) { opacity: 1; transform: translateY(0); }
23
+
24
+ @starting-style {
25
+ :host(:popover-open) { opacity: 0; transform: translateY(4px); }
10
26
  }
11
27
 
12
28
  :host([hidden]) {
13
29
  display: none !important;
14
30
  }
31
+
32
+ @media (prefers-reduced-motion: reduce) {
33
+ :host { transition: none; }
34
+ }