ember-attacher 5.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -9
- package/dist/{attacher-core-CtbFbuD_.js → attacher-core-BuH7FXay.js} +341 -28
- package/dist/attacher-core-BuH7FXay.js.map +1 -0
- package/dist/{attacher-overlay-BoI7s8AI.js → attacher-overlay-D0IJ82qu.js} +3 -3
- package/dist/attacher-overlay-D0IJ82qu.js.map +1 -0
- package/dist/components/attach-popover.d.ts +2 -1
- package/dist/components/attach-popover.js +5 -1
- package/dist/components/attach-popover.js.map +1 -1
- package/dist/components/attach-tooltip.js +2 -2
- package/dist/components/attacher.js +2 -2
- package/dist/components/attacher.js.map +1 -1
- package/dist/defaults.d.ts +3 -1
- package/dist/defaults.js +2 -0
- package/dist/defaults.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/{is-visible-CeN9qZyc.js → is-visible-BRGjlnLT.js} +23 -13
- package/dist/is-visible-BRGjlnLT.js.map +1 -0
- package/dist/lib/attacher-core.d.ts +20 -2
- package/dist/lib/positioning.d.ts +12 -2
- package/dist/lib/target-resolution.d.ts +12 -4
- package/dist/modifiers/tooltip.d.ts +3 -1
- package/dist/modifiers/tooltip.js +42 -4
- package/dist/modifiers/tooltip.js.map +1 -1
- package/dist/styles/ember-attacher.css +1 -1
- package/dist/test-support/index.js +1 -1
- package/package.json +4 -4
- package/dist/attacher-core-CtbFbuD_.js.map +0 -1
- package/dist/attacher-overlay-BoI7s8AI.js.map +0 -1
- package/dist/is-visible-CeN9qZyc.js.map +0 -1
package/README.md
CHANGED
|
@@ -81,14 +81,14 @@ 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>`.
|
|
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).
|
|
91
|
-
* Has the default class `'ember-attacher-floating ember-attacher-tooltip'` (configurable via `tooltipClass`).
|
|
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
|
+
* Has the default class `'ember-attacher-floating ember-attacher-tooltip'` (configurable via `ENV.emberAttacher.tooltipClass` or `tooltip.tooltipClass`, which **replaces** this default rather than appending—include `'ember-attacher-tooltip'` alongside custom theme classes such as `'ember-attacher-tooltip my-theme'` to keep packaged styles and `--ember-attacher-*` tokens, whereas per-instance `@class` / `class=` appends to it).
|
|
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`.
|
|
94
94
|
|
|
@@ -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()`,
|
|
100
|
-
* Has **no default visual look** (tooltip styles are not applied automatically); pass `@class="ember-attacher-popover"` to opt into
|
|
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.
|
|
@@ -140,7 +140,9 @@ Below are the 5.0 defaults (shared defaults from `addon/src/defaults.ts`; `<Atta
|
|
|
140
140
|
// Keeps attachment open while pointer/focus enters it or traverses the safePolygon corridor.
|
|
141
141
|
interactive: true,
|
|
142
142
|
|
|
143
|
-
// Controlled visibility flag.
|
|
143
|
+
// Controlled visibility flag. Does NOT disable default `showOn` / `hideOn` triggers;
|
|
144
|
+
// pass `@showOn={{null}} @hideOn={{null}}` (or `""`) for fully controlled attachments
|
|
145
|
+
// so native hover/focus/blur/Escape/clickout events cannot desync DOM state.
|
|
144
146
|
isShown: false,
|
|
145
147
|
|
|
146
148
|
// Defers rendering inner content until the attachment is first triggered.
|
|
@@ -154,6 +156,10 @@ Below are the 5.0 defaults (shared defaults from `addon/src/defaults.ts`; `<Atta
|
|
|
154
156
|
// { arrow, autoPlacement, flip, hide, inline, limitShift, offset, shift, size }
|
|
155
157
|
middleware: null,
|
|
156
158
|
|
|
159
|
+
// Shorthand Floating UI offset() option (number or OffsetOptions), prepended unless @middleware already has `offset`.
|
|
160
|
+
// When active, `.ember-attacher[data-offset]` uses Floating UI for the resting gap instead of `--ember-attacher-distance`.
|
|
161
|
+
offset: null,
|
|
162
|
+
|
|
157
163
|
// Invoked with the new visibility boolean when the attachment shows or hides.
|
|
158
164
|
onChange: null,
|
|
159
165
|
|
|
@@ -162,6 +168,9 @@ Below are the 5.0 defaults (shared defaults from `addon/src/defaults.ts`; `<Atta
|
|
|
162
168
|
// | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end'
|
|
163
169
|
placement: 'top',
|
|
164
170
|
|
|
171
|
+
// Default inner class applied to <AttachPopover> (configured via ENV.emberAttacher; '' keeps popovers unstyled).
|
|
172
|
+
popoverClass: '',
|
|
173
|
+
|
|
165
174
|
// Renders in place without promoting to the browser Top Layer ([popover="manual"]).
|
|
166
175
|
renderInPlace: false,
|
|
167
176
|
|
|
@@ -179,7 +188,7 @@ Below are the 5.0 defaults (shared defaults from `addon/src/defaults.ts`; `<Atta
|
|
|
179
188
|
// CSS positioning strategy used by Floating UI ('absolute' | 'fixed').
|
|
180
189
|
strategy: 'absolute',
|
|
181
190
|
|
|
182
|
-
// Attach Target (`Element | CSS selector | VirtualElement`).
|
|
191
|
+
// Attach Target (`Element | CSS selector | relative token (':previous' | ':previous(...)' | ':closest(...)' | ':parent') | VirtualElement`).
|
|
183
192
|
target: null,
|
|
184
193
|
|
|
185
194
|
// Registers target/document event listeners in the capture phase.
|
|
@@ -189,6 +198,21 @@ Below are the 5.0 defaults (shared defaults from `addon/src/defaults.ts`; `<Atta
|
|
|
189
198
|
|
|
190
199
|
## Recipes
|
|
191
200
|
|
|
201
|
+
### Encapsulated sibling / relative targets (`:previous`, `:closest(...)`, `:parent`)
|
|
202
|
+
|
|
203
|
+
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`:
|
|
204
|
+
|
|
205
|
+
```hbs
|
|
206
|
+
{{!-- Preferred: sibling placement keeps valid HTML and stacks cleanly (skipping .ember-attacher siblings) --}}
|
|
207
|
+
<button type="button">Options</button>
|
|
208
|
+
<AttachTooltip @target=":previous">Quick hint</AttachTooltip>
|
|
209
|
+
<AttachPopover @target=":previous(button)" @offset={{8}}>
|
|
210
|
+
Menu items
|
|
211
|
+
</AttachPopover>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
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>`).
|
|
215
|
+
|
|
192
216
|
### Pinning and flipping within a custom boundary
|
|
193
217
|
|
|
194
218
|
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 +345,7 @@ See [defaults.ts](https://github.com/tylerturdenpants/ember-attacher/blob/master
|
|
|
321
345
|
|
|
322
346
|
## Styles
|
|
323
347
|
|
|
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"` (
|
|
348
|
+
`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';`. Setting `ENV.emberAttacher.tooltipClass` (or `tooltip.tooltipClass`) replaces `'ember-attacher-floating ember-attacher-tooltip'`, so custom tooltip theme classes using `--ember-attacher-*` tokens must include `'ember-attacher-tooltip'` (e.g. `'ember-attacher-tooltip my-theme'`) unless opting out of base 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
349
|
|
|
326
350
|
Default token values use `:where()` so an app class can override them even if addon `implicit-styles` load last.
|
|
327
351
|
|
|
@@ -349,7 +373,8 @@ Default token values use `:where()` so an app class can override them even if ad
|
|
|
349
373
|
`.ember-attacher-light-theme` reassigns those same tokens (fill `#f3f6f9`, text `#203d5d`, border `#ced2e2`, `border-width: 1px`, and box shadow).
|
|
350
374
|
|
|
351
375
|
Outer wrapper tokens on `.ember-attacher`:
|
|
352
|
-
* `--ember-attacher-distance` (default `10px`): inner animation gap.
|
|
376
|
+
* `--ember-attacher-distance` (default `10px`): inner animation gap when Floating UI `offset()` is not active.
|
|
377
|
+
* `--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
378
|
* `--ember-attacher-z-index` (default `9999`): stacking context (used for non-Top-Layer / `@renderInPlace` hosts).
|
|
354
379
|
* `--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
380
|
|