ember-attacher 5.0.0-beta.4 → 5.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -81,13 +81,13 @@ If you're upgrading from **1.x to 2.x**, see the [2.0 upgrade guide](https://git
81
81
 
82
82
  ### `{{tooltip}}` modifier
83
83
 
84
- `{{tooltip "Text" class="hint"}}` attaches a tooltip to a void or simple element such as `<button>` or `<input>`. Every `{{tooltip}}` in the document shares one singleton `.ember-attacher` DOM node with a `300ms` warm delay-group handoff across adjacent tooltips.
84
+ `{{tooltip "Text" class="hint"}}` attaches a tooltip to a void or simple element such as `<button>` or `<input>`. Uncontrolled `{{tooltip}}` modifiers in the document share one singleton `.ember-attacher` DOM node with a `300ms` warm delay-group handoff across adjacent tooltips, while controlled `{{tooltip "..." isShown=...}}` modifiers allocate a dedicated host instance so concurrent or hover tooltips never steal or hide them.
85
85
 
86
86
  ### `<AttachTooltip/>`
87
87
 
88
88
  A target-attached tooltip component (default `ariaRole="tooltip"`).
89
89
 
90
- * Must be bound to a Target (`@target`, `<:target>`, `{{a.target}}`, `a.setTarget()`, `[popovertarget]`, or `[interestfor]`). Asserts in debug if no target binding is provided (nullable reactive `@target={{this.target}}` is supported).
90
+ * Must be bound to a Target (`@target`, `<:target>`, `{{a.target}}`, `a.setTarget()`, `[popovertarget]`, or `[interestfor]`). Asserts in debug if no target binding is provided (nullable reactive `@target={{this.target}}` is supported). Relative `@target` tokens (`:previous`, `:previous(selector)`, `:closest(selector)`, `:parent`) resolve from the in-place Host without wrapper elements or `<meta hidden>`.
91
91
  * Has the default class `'ember-attacher-floating ember-attacher-tooltip'` (configurable via `tooltipClass`).
92
92
  * Hoverable by default (`@interactive={{true}}`) per WCAG 1.4.13 with an automatic `safePolygon` diagonal pointer corridor (pass `@interactive={{false}}` to opt out).
93
93
  * Smart Tooltip ARIA: binds `aria-labelledby` upfront on nameless triggers (such as icon buttons), suppresses duplicate `aria-describedby` when tooltip text matches the trigger's accessible name, and otherwise binds open-only token-safe `aria-describedby`.
@@ -96,8 +96,8 @@ A target-attached tooltip component (default `ariaRole="tooltip"`).
96
96
 
97
97
  An interactive popover component (default `ariaRole="dialog"`, `showOn="click"`, `hideOn="click clickout escapekey"`, `interactive=true`, `lazyRender=true`).
98
98
 
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.
99
+ * Must be bound to a Target (`@target`, `<:target>`, `{{a.target}}`, `a.setTarget()`, `[popovertarget]`, or relative tokens such as `@target=":previous"`).
100
+ * Has **no default visual look** by default (tooltip styles are not applied automatically); pass `@class="ember-attacher-popover"` or configure `ENV.emberAttacher.popoverClass` (or `popover.popoverClass`) to opt into default styling. Arrows and `--ember-attacher-*` tokens work with any custom `@class`.
101
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).
102
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.
103
103
  * Restores focus to the Target when dismissed via `Escape` while focus is inside the popover.
@@ -154,6 +154,10 @@ Below are the 5.0 defaults (shared defaults from `addon/src/defaults.ts`; `<Atta
154
154
  // { arrow, autoPlacement, flip, hide, inline, limitShift, offset, shift, size }
155
155
  middleware: null,
156
156
 
157
+ // Shorthand Floating UI offset() option (number or OffsetOptions), prepended unless @middleware already has `offset`.
158
+ // When active, `.ember-attacher[data-offset]` uses Floating UI for the resting gap instead of `--ember-attacher-distance`.
159
+ offset: null,
160
+
157
161
  // Invoked with the new visibility boolean when the attachment shows or hides.
158
162
  onChange: null,
159
163
 
@@ -162,6 +166,9 @@ Below are the 5.0 defaults (shared defaults from `addon/src/defaults.ts`; `<Atta
162
166
  // | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end'
163
167
  placement: 'top',
164
168
 
169
+ // Default inner class applied to <AttachPopover> (configured via ENV.emberAttacher; '' keeps popovers unstyled).
170
+ popoverClass: '',
171
+
165
172
  // Renders in place without promoting to the browser Top Layer ([popover="manual"]).
166
173
  renderInPlace: false,
167
174
 
@@ -179,7 +186,7 @@ Below are the 5.0 defaults (shared defaults from `addon/src/defaults.ts`; `<Atta
179
186
  // CSS positioning strategy used by Floating UI ('absolute' | 'fixed').
180
187
  strategy: 'absolute',
181
188
 
182
- // Attach Target (`Element | CSS selector | VirtualElement`).
189
+ // Attach Target (`Element | CSS selector | relative token (':previous' | ':previous(...)' | ':closest(...)' | ':parent') | VirtualElement`).
183
190
  target: null,
184
191
 
185
192
  // Registers target/document event listeners in the capture phase.
@@ -189,6 +196,21 @@ Below are the 5.0 defaults (shared defaults from `addon/src/defaults.ts`; `<Atta
189
196
 
190
197
  ## Recipes
191
198
 
199
+ ### Encapsulated sibling / relative targets (`:previous`, `:closest(...)`, `:parent`)
200
+
201
+ Because 5.0 renders `.ember-attacher` directly in place, encapsulated popover or tooltip components can target an adjacent trigger without `<meta hidden>` or `ember-ref-bucket`:
202
+
203
+ ```hbs
204
+ {{!-- Preferred: sibling placement keeps valid HTML and stacks cleanly (skipping .ember-attacher siblings) --}}
205
+ <button type="button">Options</button>
206
+ <AttachTooltip @target=":previous">Quick hint</AttachTooltip>
207
+ <AttachPopover @target=":previous(button)" @offset={{8}}>
208
+ Menu items
209
+ </AttachPopover>
210
+ ```
211
+
212
+ Use `:closest(<selector>)` to resolve an ancestor wrapper (starting from `parentElement`), or `:parent` for non-interactive parent containers (avoid nesting interactive popovers inside `<button>` or `<a>`).
213
+
192
214
  ### Pinning and flipping within a custom boundary
193
215
 
194
216
  Pass Floating UI `flip` and `shift` options with a custom `boundary` element via `@middleware` to keep an attachment constrained inside a scroll area or layout panel:
@@ -321,7 +343,7 @@ See [defaults.ts](https://github.com/tylerturdenpants/ember-attacher/blob/master
321
343
 
322
344
  ## Styles
323
345
 
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).
346
+ `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"` or configure `ENV.emberAttacher.popoverClass` (arrow and fill-backdrop geometry work with any `@class` without needing `.ember-attacher-popover`).
325
347
 
326
348
  Default token values use `:where()` so an app class can override them even if addon `implicit-styles` load last.
327
349
 
@@ -349,7 +371,8 @@ Default token values use `:where()` so an app class can override them even if ad
349
371
  `.ember-attacher-light-theme` reassigns those same tokens (fill `#f3f6f9`, text `#203d5d`, border `#ced2e2`, `border-width: 1px`, and box shadow).
350
372
 
351
373
  Outer wrapper tokens on `.ember-attacher`:
352
- * `--ember-attacher-distance` (default `10px`): inner animation gap.
374
+ * `--ember-attacher-distance` (default `10px`): inner animation gap when Floating UI `offset()` is not active.
375
+ * `--ember-attacher-slide-distance` (defaults to `var(--ember-attacher-distance, 10px)`): entry/exit animation travel distance when `@offset` or `offset()` middleware sets `[data-offset]`.
353
376
  * `--ember-attacher-z-index` (default `9999`): stacking context (used for non-Top-Layer / `@renderInPlace` hosts).
354
377
  * `--ember-attacher-transition-duration` (default `0ms`): driven via CSSOM from `@showDuration` / `@hideDuration` (strict CSP `style-src` compatible without `'unsafe-inline'`). Spatial transforms opt in under `@media (prefers-reduced-motion: no-preference)`, and `@media (prefers-reduced-motion: reduce)` caps opacity transitions to `min(var(--ember-attacher-transition-duration, 0ms), 100ms)`.
355
378