ember-attacher 1.3.0 → 2.0.1
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/.github/dependabot.yml +0 -3
- package/.github/workflows/ci.yml +2 -2
- package/CHANGELOG.md +20 -0
- package/README.md +44 -31
- package/addon/components/attach-popover.js +299 -232
- package/addon/components/attach-tooltip.js +17 -33
- package/addon/defaults.js +5 -4
- package/addon/styles/_mixins.scss +4 -6
- package/addon/styles/ember-attacher.scss +5 -0
- package/addon/templates/components/attach-popover.hbs +26 -22
- package/addon-test-support/is-visible.js +1 -1
- package/docs/upgrade-guide-2.0.md +43 -0
- package/index.js +0 -2
- package/package.json +42 -34
- package/app/styles/app.scss +0 -1
- package/yarn-error.log +0 -14650
|
@@ -1,50 +1,32 @@
|
|
|
1
|
-
import classic from 'ember-classic-decorator';
|
|
2
|
-
import { observes } from '@ember-decorators/object';
|
|
3
|
-
import { computed } from '@ember/object';
|
|
4
1
|
import AttachPopover from './attach-popover';
|
|
5
2
|
import DEFAULTS from '../defaults';
|
|
3
|
+
import layout from '../templates/components/attach-popover';
|
|
4
|
+
import { setComponentTemplate } from '@ember/component';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
export default class AttachTooltip extends AttachPopover {
|
|
6
|
+
class AttachTooltip extends AttachPopover {
|
|
9
7
|
configKey = 'tooltip';
|
|
10
|
-
ariaRole = 'tooltip';
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return this._config.tooltipClass || DEFAULTS.tooltipClass;
|
|
9
|
+
get ariaRole() {
|
|
10
|
+
return this.args.ariaRole || 'tooltip';
|
|
15
11
|
}
|
|
16
12
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// eslint-disable-next-line no-setter-return
|
|
21
|
-
return `${tooltipClass} ${value}`;
|
|
13
|
+
get _class() {
|
|
14
|
+
return `${super._class} ${this._config.tooltipClass || DEFAULTS.tooltipClass}`
|
|
22
15
|
}
|
|
23
16
|
|
|
24
|
-
|
|
25
|
-
super.
|
|
26
|
-
|
|
27
|
-
if (!this._currentTarget) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
17
|
+
_initializeAttacher() {
|
|
18
|
+
super._initializeAttacher();
|
|
30
19
|
|
|
31
|
-
this._currentTarget
|
|
32
|
-
|
|
20
|
+
if (this._currentTarget?.getAttribute('aria-describedby') != this.id) {
|
|
21
|
+
const oldTarget = document.querySelector(`[aria-describedby="${this.id}"]`);
|
|
33
22
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const oldTarget = this._currentTarget;
|
|
37
|
-
if (oldTarget) {
|
|
38
|
-
oldTarget.removeAttribute('aria-describedby');
|
|
23
|
+
oldTarget?.removeAttribute('aria-describedby')
|
|
24
|
+
this._currentTarget?.setAttribute('aria-describedby', this.id);
|
|
39
25
|
}
|
|
40
|
-
|
|
41
|
-
super.popperTargetChanged;
|
|
42
|
-
|
|
43
|
-
this.popperTarget.setAttribute('aria-describedby', this.id);
|
|
44
26
|
}
|
|
45
27
|
|
|
46
|
-
|
|
47
|
-
super.
|
|
28
|
+
willDestroy() {
|
|
29
|
+
super.willDestroy(...arguments);
|
|
48
30
|
|
|
49
31
|
const target = this._currentTarget;
|
|
50
32
|
if (target) {
|
|
@@ -52,3 +34,5 @@ export default class AttachTooltip extends AttachPopover {
|
|
|
52
34
|
}
|
|
53
35
|
}
|
|
54
36
|
}
|
|
37
|
+
|
|
38
|
+
export default setComponentTemplate(layout, AttachTooltip);
|
package/addon/defaults.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
animation: 'fill',
|
|
3
3
|
arrow: false,
|
|
4
|
+
autoUpdate: false,
|
|
4
5
|
flip: null,
|
|
5
6
|
hideDelay: 0,
|
|
6
7
|
hideDuration: 300,
|
|
@@ -9,15 +10,15 @@ export default {
|
|
|
9
10
|
isOffset: false,
|
|
10
11
|
isShown: false,
|
|
11
12
|
lazyRender: false,
|
|
12
|
-
|
|
13
|
+
middleware: null,
|
|
13
14
|
placement: 'top',
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
floatingElementContainer: '.ember-application',
|
|
16
|
+
floatingUiOptions: null,
|
|
16
17
|
renderInPlace: false,
|
|
17
18
|
showDelay: 0,
|
|
18
19
|
showDuration: 300,
|
|
19
20
|
showOn: 'mouseenter focus',
|
|
20
21
|
style: null,
|
|
21
|
-
tooltipClass: 'ember-attacher-
|
|
22
|
+
tooltipClass: 'ember-attacher-floating ember-attacher-tooltip',
|
|
22
23
|
useCapture: false
|
|
23
24
|
};
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
@use "sass:math";
|
|
2
|
-
|
|
3
1
|
@mixin arrow($position, $width) {
|
|
4
2
|
@if ($position == 'top') {
|
|
5
3
|
transform: rotate(-45deg);
|
|
6
|
-
bottom:
|
|
4
|
+
bottom: -$width * .5;
|
|
7
5
|
} @else if ($position == 'bottom') {
|
|
8
6
|
transform: rotate(135deg);
|
|
9
|
-
top:
|
|
7
|
+
top: -$width * .5;
|
|
10
8
|
} @else if ($position == 'left') {
|
|
11
9
|
transform: rotate(225deg);
|
|
12
|
-
right:
|
|
10
|
+
right: -$width * .5;
|
|
13
11
|
top: 50%;
|
|
14
12
|
} @else if ($position == 'right') {
|
|
15
13
|
transform: rotate(45deg);
|
|
16
|
-
left:
|
|
14
|
+
left: -$width * .5;
|
|
17
15
|
top: 50%;
|
|
18
16
|
}
|
|
19
17
|
}
|
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
{{
|
|
1
|
+
{{~#unless this.renderFloatingElement}}
|
|
2
|
+
<meta hidden {{did-insert this.onParentFinderInsert}} {{did-update this.onIsShownChange this.isShown}}/>
|
|
3
|
+
{{~/unless~}}
|
|
2
4
|
|
|
3
|
-
{{~#if
|
|
4
|
-
{{~#
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
5
|
+
{{~#if this.renderFloatingElement}}
|
|
6
|
+
{{~#maybe-in-element destinationElement=this._floatingElementContainer renderInPlace=@renderInPlace}}
|
|
7
|
+
<div
|
|
8
|
+
class="ember-attacher"
|
|
9
|
+
id={{this.id}}
|
|
10
|
+
role={{this.ariaRole}}
|
|
11
|
+
{{did-insert this.didInsertFloatingElement}}
|
|
12
|
+
{{did-update this.onIsShownChange this.isShown}}
|
|
13
|
+
{{did-update this.onTargetOrTriggerChange this.hideOn this.showOn @explicitTarget}}
|
|
14
|
+
{{did-update this.onOptionsChange this.autoUpdate this.animation this.arrow this.useCapture this.placement this._renderInPlace this._currentTarget this._middleware}}
|
|
15
|
+
{{will-destroy this.willDestroyFloatingElement}}
|
|
16
|
+
...attributes
|
|
17
|
+
>
|
|
18
|
+
<div class={{this._class}} style={{this._style}}>
|
|
19
|
+
{{yield (hash hide=(action 'hide'))}}
|
|
20
|
+
{{#if this.arrow}}
|
|
21
|
+
<div x-arrow {{did-insert this.didInsertArrow}}></div>
|
|
22
|
+
{{/if}}
|
|
23
|
+
{{#if this.isFillAnimation}}
|
|
24
|
+
<div x-circle style="{{this._circleTransitionDuration}}"></div>
|
|
25
|
+
{{/if}}
|
|
26
|
+
</div>
|
|
23
27
|
</div>
|
|
24
|
-
{{~/
|
|
28
|
+
{{~/maybe-in-element}}
|
|
25
29
|
{{~/if~}}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export function isVisible(selector, contextEl) {
|
|
2
2
|
const attachment = typeof(selector) === 'string' ? getAttachment(selector, contextEl) : selector;
|
|
3
3
|
|
|
4
|
-
return attachment.
|
|
4
|
+
return getComputedStyle(attachment).display !== 'none';
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
function getAttachment(selectorOrElement = '', contextEl) {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# ember-attacher 2.0
|
|
2
|
+
|
|
3
|
+
## Quick Summary
|
|
4
|
+
|
|
5
|
+
- ember-popper was replaced by the [Floating UI](https://github.com/floating-ui/floating-ui)
|
|
6
|
+
- ember edition was changed to "octane"
|
|
7
|
+
- ember-test-waiters are used now to wait until positioning inside `requestAnimationFrame` happen in tests
|
|
8
|
+
- we dropped support for node < 12 and ember-source < 3.16
|
|
9
|
+
|
|
10
|
+
## Details
|
|
11
|
+
|
|
12
|
+
### API Changes
|
|
13
|
+
|
|
14
|
+
- instead of popper [modifiers](https://popper.js.org/docs/v2/modifiers/) you should use Floating UI [middleware](https://floating-ui.com/docs/middleware).
|
|
15
|
+
You can import the default ones (like [offset](https://floating-ui.com/docs/offset) or [flip](https://floating-ui.com/docs/flip)) directly from `@floating-ui/dom`
|
|
16
|
+
|
|
17
|
+
For example
|
|
18
|
+
```js
|
|
19
|
+
const modifiers = { offset: { offset: 10 } };
|
|
20
|
+
```
|
|
21
|
+
will become
|
|
22
|
+
```js
|
|
23
|
+
import { offset } from '@floating-ui/dom';
|
|
24
|
+
...
|
|
25
|
+
const middleware = [offset(10)]
|
|
26
|
+
```
|
|
27
|
+
- `popperContainer` is `floatingElementContainer` now
|
|
28
|
+
- `popperOptions` is `floatingUiOptions` now. The object is passed to Floating UI [computePosition](https://floating-ui.com/docs/computePosition) function.
|
|
29
|
+
- `popperTarget` is `explicitTarget` now.
|
|
30
|
+
- Instead of `registerAPI` used to update your tooltip or popover manually, you should use `autoUpdate` [option](https://github.com/tylerturdenpants/ember-attacher#options).
|
|
31
|
+
It adds listeners that will automatically call an update function when necessary (if the user scrolls or resizes the screen, etc.).
|
|
32
|
+
- For more details see Floating UI [migration guide](https://floating-ui.com/docs/migration). Pay attention that `ember-attacher` v1 used Popper v1.
|
|
33
|
+
|
|
34
|
+
### IDs and CSS classes changes
|
|
35
|
+
|
|
36
|
+
- The prefix for the default floating element's `id` is now "-floating" instead of "-popper".
|
|
37
|
+
- The default `ember-attacher-popper` class is now `ember-attacher-floating`
|
|
38
|
+
|
|
39
|
+
### Compatibility
|
|
40
|
+
|
|
41
|
+
For Ember.js below the v3.20 you may need to install [@ember/render-modifiers](https://github.com/emberjs/ember-render-modifiers) (`ember install @ember/render-modifiers`).
|
|
42
|
+
|
|
43
|
+
The addon may work with the ember-source < 3.16, yet the support is not guaranteed.
|
package/index.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
const FilterImports = require('babel-plugin-filter-imports');
|
|
5
5
|
const Funnel = require('broccoli-funnel');
|
|
6
|
-
const StripClassCallCheck = require('babel6-plugin-strip-class-callcheck');
|
|
7
6
|
|
|
8
7
|
module.exports = {
|
|
9
8
|
name: require('./package').name,
|
|
@@ -42,7 +41,6 @@ module.exports = {
|
|
|
42
41
|
}
|
|
43
42
|
};
|
|
44
43
|
babelOptions.plugins.push([FilterImports, strippedImports]);
|
|
45
|
-
babelOptions.postTransformPlugins.push(StripClassCallCheck);
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
this._hasSetupBabelOptions = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-attacher",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Tooltips and popovers for Ember.js apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -29,69 +29,77 @@
|
|
|
29
29
|
"test:all": "ember try:each"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
+
"@floating-ui/dom": "~1.2.8",
|
|
32
33
|
"babel-plugin-filter-imports": "^4.0.0",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"ember-
|
|
36
|
-
"ember-cli-
|
|
37
|
-
"ember-cli-
|
|
38
|
-
"ember-
|
|
39
|
-
"
|
|
40
|
-
"ember-popper": "^0.11.3",
|
|
41
|
-
"ember-truth-helpers": "^3.0.0",
|
|
42
|
-
"sass": "^1.35.2"
|
|
34
|
+
"broccoli-funnel": "~3.0.8",
|
|
35
|
+
"ember-auto-import": "~2.6.3",
|
|
36
|
+
"ember-cli-babel": "^7.26.10",
|
|
37
|
+
"ember-cli-htmlbars": "~6.2.0",
|
|
38
|
+
"ember-cli-sass": "~11.0.1",
|
|
39
|
+
"ember-in-element-polyfill": "~1.0.1",
|
|
40
|
+
"sass": "^1.62.1"
|
|
43
41
|
},
|
|
44
42
|
"devDependencies": {
|
|
43
|
+
"@babel/core": "^7.21.4",
|
|
44
|
+
"@babel/eslint-parser": "^7.21.8",
|
|
45
45
|
"@ember/optional-features": "^2.0.0",
|
|
46
|
-
"@ember/
|
|
46
|
+
"@ember/render-modifiers": "^2.0.5",
|
|
47
|
+
"@ember/string": "^3.0.1",
|
|
48
|
+
"@ember/test-helpers": "~2.9.3",
|
|
49
|
+
"@ember/test-waiters": "^3.0.2",
|
|
50
|
+
"@glimmer/component": "^1.0.0",
|
|
51
|
+
"@glimmer/tracking": "^1.0.0",
|
|
47
52
|
"@html-next/flexi-default-styles": "^2.2.0",
|
|
48
|
-
"
|
|
53
|
+
"@release-it-plugins/lerna-changelog": "^5.0.0",
|
|
49
54
|
"broccoli-asset-rev": "^3.0.0",
|
|
50
|
-
"ember-cli
|
|
55
|
+
"ember-cli": "~3.28.5",
|
|
56
|
+
"ember-cli-dependency-checker": "~3.3.1",
|
|
51
57
|
"ember-cli-github-pages": "^0.2.2",
|
|
52
58
|
"ember-cli-inject-live-reload": "^2.0.2",
|
|
53
59
|
"ember-cli-sri": "^2.1.1",
|
|
54
|
-
"ember-cli-
|
|
55
|
-
"ember-cli": "~3.26.1",
|
|
60
|
+
"ember-cli-terser": "^4.0.2",
|
|
56
61
|
"ember-disable-prototype-extensions": "^1.1.3",
|
|
57
62
|
"ember-export-application-global": "^2.0.1",
|
|
58
63
|
"ember-load-initializers": "^2.1.2",
|
|
59
|
-
"ember-maybe-import-regenerator": "^0.
|
|
60
|
-
"ember-
|
|
61
|
-
"ember-qunit": "
|
|
62
|
-
"ember-
|
|
63
|
-
"ember-
|
|
64
|
+
"ember-maybe-import-regenerator": "^1.0.0",
|
|
65
|
+
"ember-maybe-in-element": "^2.1.0",
|
|
66
|
+
"ember-qunit": "^6.2.0",
|
|
67
|
+
"ember-resolver": "~10.0.0",
|
|
68
|
+
"ember-source": "~3.28.11",
|
|
64
69
|
"ember-source-channel-url": "^3.0.0",
|
|
65
|
-
"ember-
|
|
66
|
-
"ember-
|
|
67
|
-
"ember-try": "
|
|
68
|
-
"eslint
|
|
70
|
+
"ember-svg-jar": "~2.4.2",
|
|
71
|
+
"ember-truth-helpers": "^3.1.1",
|
|
72
|
+
"ember-try": "~3.0.0-beta.1",
|
|
73
|
+
"eslint": "~8.40.0",
|
|
74
|
+
"eslint-plugin-decorator-position": "^5.0.2",
|
|
75
|
+
"eslint-plugin-ember": "~11.5.2",
|
|
69
76
|
"eslint-plugin-node": "^11.1.0",
|
|
70
|
-
"eslint": "^7.26.0",
|
|
71
77
|
"flexi": "^2.1.0",
|
|
72
78
|
"loader.js": "^4.7.0",
|
|
73
|
-
"qunit": "~2.
|
|
74
|
-
"qunit-dom": "
|
|
75
|
-
"release-it
|
|
76
|
-
"
|
|
79
|
+
"qunit": "~2.19.4",
|
|
80
|
+
"qunit-dom": "~2.0.0",
|
|
81
|
+
"release-it": "~15.10.1",
|
|
82
|
+
"webpack": "~5.82.1"
|
|
77
83
|
},
|
|
78
84
|
"resolutions": {
|
|
79
|
-
"@embroider/util": "^0.40.0",
|
|
80
85
|
"ember-in-element-polyfill": "^1.0.1"
|
|
81
86
|
},
|
|
82
87
|
"engines": {
|
|
83
|
-
"node": "
|
|
88
|
+
"node": ">= 12.*"
|
|
89
|
+
},
|
|
90
|
+
"ember": {
|
|
91
|
+
"edition": "octane"
|
|
84
92
|
},
|
|
85
93
|
"ember-addon": {
|
|
86
94
|
"configPath": "tests/dummy/config",
|
|
87
|
-
"demoURL": "https://
|
|
95
|
+
"demoURL": "https://tylerturdenpants.github.io/ember-attacher/"
|
|
88
96
|
},
|
|
89
97
|
"publishConfig": {
|
|
90
98
|
"registry": "https://registry.npmjs.org"
|
|
91
99
|
},
|
|
92
100
|
"release-it": {
|
|
93
101
|
"plugins": {
|
|
94
|
-
"release-it-lerna-changelog": {
|
|
102
|
+
"@release-it-plugins/lerna-changelog": {
|
|
95
103
|
"infile": "CHANGELOG.md"
|
|
96
104
|
}
|
|
97
105
|
},
|
package/app/styles/app.scss
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import "ember-power-select";
|