ember-attacher 5.0.0-beta.2 → 5.0.0-beta.3

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/README.md CHANGED
@@ -97,6 +97,7 @@ A target-attached tooltip component (default `ariaRole="tooltip"`).
97
97
  An interactive popover component (default `ariaRole="dialog"`, `showOn="click"`, `hideOn="click clickout escapekey"`, `interactive=true`, `lazyRender=true`).
98
98
 
99
99
  * Must be bound to a Target (`@target`, `<:target>`, `{{a.target}}`, `a.setTarget()`, or `[popovertarget]`).
100
+ * Has **no default visual look** (tooltip styles are not applied automatically); pass `@class="ember-attacher-popover"` to opt into the packaged styling or supply your own class.
100
101
  * Renders `<div class="ember-attacher" popover="manual">` in place in 1 pass and promotes to the browser Top Layer on open (`@renderInPlace={{true}}` opts out of Top Layer).
101
102
  * While mounted, sets `aria-haspopup` (matching `@ariaRole` or `'dialog'`), `aria-controls`, and `aria-expanded` on the Target when not already provided by the caller.
102
103
  * Restores focus to the Target when dismissed via `Escape` while focus is inside the popover.
@@ -148,6 +149,7 @@ Below are the 5.0 defaults (shared defaults from `addon/src/defaults.ts`; `<Atta
148
149
 
149
150
  // Floating UI middleware array merged and deduplicated by `m.name`.
150
151
  // Default `flip()` and `shift({ limiter: limitShift(), padding: 5 })` apply unless overridden.
152
+ // Pass `hide()` when you want attachments to hide once their target scrolls out of a clipping container.
151
153
  // Re-exported builders from 'ember-attacher':
152
154
  // { arrow, autoPlacement, flip, hide, inline, limitShift, offset, shift, size }
153
155
  middleware: null,
@@ -319,7 +321,7 @@ See [defaults.ts](https://github.com/tylerturdenpants/ember-attacher/blob/master
319
321
 
320
322
  ## Styles
321
323
 
322
- `ember-attacher` provides CSS for the default tooltip class, `ember-attacher-tooltip` (`ember-attacher/styles`; also injected via `implicit-styles`). `<AttachPopover>` has no packaged look unless you opt in with `@class="ember-attacher-popover"` (same tokens as the tooltip; not applied automatically).
324
+ `ember-attacher` provides CSS for the default tooltip class, `ember-attacher-tooltip` (`ember-attacher/styles`, also auto-injected via `ember-addon.implicit-styles` when the host app depends on `ember-attacher` directly). If an intermediate addon only lists `ember-attacher` as a `peerDependency`, the host app must also depend on `ember-attacher` directly or `import 'ember-attacher/styles';`. `<AttachPopover>` has no packaged look unless you opt in with `@class="ember-attacher-popover"` (same tokens as the tooltip; not applied automatically).
323
325
 
324
326
  Default token values use `:where()` so an app class can override them even if addon `implicit-styles` load last.
325
327
 
@@ -332,10 +334,13 @@ Default token values use `:where()` so an app class can override them even if ad
332
334
  --ember-attacher-border: var(--ember-attacher-fill);
333
335
  --ember-attacher-border-width: 0px; /* set to 1px+ when you need a visible border */
334
336
  --ember-attacher-arrow-size: 10px;
337
+ --ember-attacher-arrow-width: var(--ember-attacher-arrow-size);
338
+ --ember-attacher-arrow-height: var(--ember-attacher-arrow-size);
335
339
  --ember-attacher-padding: 0.5rem 1rem;
336
340
  --ember-attacher-shadow: none;
337
341
  --ember-attacher-max-width: 400px;
338
342
  --ember-attacher-font-size: inherit;
343
+ --ember-attacher-line-height: inherit;
339
344
  --ember-attacher-text-align: center;
340
345
  }
341
346
  ```
@@ -356,69 +356,6 @@ function elementContainsEvent(element, event) {
356
356
  }
357
357
  return Boolean(typeof Node !== 'undefined' && event?.target instanceof Node && element.contains(event.target));
358
358
  }
359
- function getEventClientPoint(event) {
360
- if (!event) {
361
- return null;
362
- }
363
- const touch = event.changedTouches?.[0];
364
- if (touch) {
365
- return {
366
- x: touch.clientX,
367
- y: touch.clientY
368
- };
369
- }
370
- if ('clientX' in event && 'clientY' in event) {
371
- const mouseEvent = event;
372
- const x = mouseEvent.clientX;
373
- const y = mouseEvent.clientY;
374
- // Keyboard/synthetic clicks without pointer coordinates default to (0, 0) with detail === 0.
375
- if (x === 0 && y === 0 && !mouseEvent.detail) {
376
- return null;
377
- }
378
- return {
379
- x,
380
- y
381
- };
382
- }
383
- return null;
384
- }
385
- function isPointWithinElementBoxes(element, x, y) {
386
- const rect = element.getBoundingClientRect();
387
- if (rect.width === 0 && rect.height === 0) {
388
- return true;
389
- }
390
- if (isPointInRect(x, y, rect)) {
391
- return true;
392
- }
393
- for (const child of element.children) {
394
- const childRect = child.getBoundingClientRect();
395
- if ((childRect.width > 0 || childRect.height > 0) && isPointInRect(x, y, childRect)) {
396
- return true;
397
- }
398
- }
399
- return false;
400
- }
401
-
402
- /**
403
- * Determine whether a click/touch event landed inside a floating host element.
404
- *
405
- * Unlike `elementContainsEvent`, direct hits targeting a Top-Layer `[popover]`'s
406
- * `::backdrop` (`event.target === element` with pointer coordinates outside the
407
- * popover's rendered boxes) return `false` so clickout dismisses the popover.
408
- */
409
- function floatingElementContainsEvent(element, event) {
410
- if (!elementContainsEvent(element, event)) {
411
- return false;
412
- }
413
- if (!element || event?.target !== element) {
414
- return true;
415
- }
416
- const point = getEventClientPoint(event);
417
- if (!point) {
418
- return true;
419
- }
420
- return isPointWithinElementBoxes(element, point.x, point.y);
421
- }
422
359
  const CORRIDOR_BUFFER = 2;
423
360
  function isPointInRect(x, y, rect) {
424
361
  return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;
@@ -601,7 +538,7 @@ function descendantAttachmentContainsEvent(parent, event) {
601
538
  continue;
602
539
  }
603
540
  if (isDescendantOf(candidate, parent)) {
604
- if (floatingElementContainsEvent(candidate._floatingElement, event) || elementContainsEvent(candidate._listenerTarget, event)) {
541
+ if (elementContainsEvent(candidate._floatingElement, event) || elementContainsEvent(candidate._listenerTarget, event)) {
605
542
  return true;
606
543
  }
607
544
  }
@@ -610,9 +547,6 @@ function descendantAttachmentContainsEvent(parent, event) {
610
547
  const path = typeof event?.composedPath === 'function' ? event.composedPath() : null;
611
548
  if (path) {
612
549
  for (const node of path) {
613
- if (node instanceof Element && node === event?.target && !floatingElementContainsEvent(node, event)) {
614
- continue;
615
- }
616
550
  let currentParent = floatingElementParentMap.get(node);
617
551
  const visited = new Set();
618
552
  while (currentParent && !visited.has(currentParent)) {
@@ -2492,7 +2426,7 @@ let AttacherCore = (_class = class AttacherCore {
2492
2426
  if (elementContainsEvent(target, event) || descendantAttachmentContainsEvent(this, event)) {
2493
2427
  return;
2494
2428
  }
2495
- if (!this._opt('interactive') || !floatingElementContainsEvent(this._floatingElement, event)) {
2429
+ if (!this._opt('interactive') || !elementContainsEvent(this._floatingElement, event)) {
2496
2430
  this._hideAfterDelay();
2497
2431
  }
2498
2432
  }
@@ -2673,4 +2607,4 @@ let AttacherCore = (_class = class AttacherCore {
2673
2607
  }), _class);
2674
2608
 
2675
2609
  export { AttacherCore as A, cancelScheduled as c, resolveTooltipClass as r, scheduleMicrotask as s };
2676
- //# sourceMappingURL=attacher-core-DIAMEQR6.js.map
2610
+ //# sourceMappingURL=attacher-core-CtbFbuD_.js.map