ember-attacher 1.3.0-beta.3 → 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.
@@ -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
- @classic
8
- export default class AttachTooltip extends AttachPopover {
6
+ class AttachTooltip extends AttachPopover {
9
7
  configKey = 'tooltip';
10
- ariaRole = 'tooltip';
11
8
 
12
- @computed('_config.tooltipClass')
13
- get class() {
14
- return this._config.tooltipClass || DEFAULTS.tooltipClass;
9
+ get ariaRole() {
10
+ return this.args.ariaRole || 'tooltip';
15
11
  }
16
12
 
17
- set class(value) {
18
- const tooltipClass = this._config.tooltipClass || DEFAULTS.tooltipClass;
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
- didInsertElement() {
25
- super.didInsertElement(...arguments);
26
-
27
- if (!this._currentTarget) {
28
- return;
29
- }
17
+ _initializeAttacher() {
18
+ super._initializeAttacher();
30
19
 
31
- this._currentTarget.setAttribute('aria-describedby', this.id);
32
- }
20
+ if (this._currentTarget?.getAttribute('aria-describedby') != this.id) {
21
+ const oldTarget = document.querySelector(`[aria-describedby="${this.id}"]`);
33
22
 
34
- @observes('popperTarget')
35
- popperTargetChanged() {
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
- willDestroyElement() {
47
- super.willDestroyElement(...arguments);
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
- modifiers: null,
13
+ middleware: null,
13
14
  placement: 'top',
14
- popperContainer: '.ember-application',
15
- popperOptions: null,
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-popper ember-attacher-tooltip',
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: math.div(-$width, 2);
4
+ bottom: -$width * .5;
7
5
  } @else if ($position == 'bottom') {
8
6
  transform: rotate(135deg);
9
- top: math.div(-$width, 2);
7
+ top: -$width * .5;
10
8
  } @else if ($position == 'left') {
11
9
  transform: rotate(225deg);
12
- right: math.div(-$width, 2);
10
+ right: -$width * .5;
13
11
  top: 50%;
14
12
  } @else if ($position == 'right') {
15
13
  transform: rotate(45deg);
16
- left: math.div(-$width, 2);
14
+ left: -$width * .5;
17
15
  top: 50%;
18
16
  }
19
17
  }
@@ -1,4 +1,9 @@
1
1
  .ember-attacher {
2
+ width: max-content;
3
+ position: absolute;
4
+ top: 0;
5
+ left: 0;
6
+ display: none;
2
7
  perspective: 800px;
3
8
  transition-timing-function: cubic-bezier(.165, .84, .44, 1);
4
9
  z-index: 9999;
@@ -1,25 +1,29 @@
1
- {{unbound this._parentFinder}}
1
+ {{~#unless this.renderFloatingElement}}
2
+ <meta hidden {{did-insert this.onParentFinderInsert}} {{did-update this.onIsShownChange this.isShown}}/>
3
+ {{~/unless~}}
2
4
 
3
- {{~#if (and this._currentTarget (or (not this.lazyRender) this._mustRender))}}
4
- {{~#ember-popper ariaRole=this.ariaRole
5
- class="ember-attacher"
6
- eventsEnabled=false
7
- id=this.id
8
- modifiers=this._modifiers
9
- placement=this.placement
10
- popperContainer=this.popperContainer
11
- popperTarget=this._currentTarget
12
- registerAPI=(action '_registerAPI')
13
- renderInPlace=this.renderInPlace as |emberPopper|~}}
14
- <div class="{{this._class}}" style="{{this._style}}">
15
- {{yield (hash emberPopper=emberPopper hide=(action 'hide'))}}
16
-
17
- {{#if this.arrow}}
18
- <div x-arrow></div>
19
- {{/if}}
20
- {{#if (eq this.animation 'fill')}}
21
- <div x-circle style="{{this._circleTransitionDuration}}"></div>
22
- {{/if}}
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
- {{~/ember-popper}}
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.style.display !== 'none';
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": "1.3.0-beta.3",
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
- "babel6-plugin-strip-class-callcheck": "^6.0.0",
34
- "broccoli-funnel": "^3.0.5",
35
- "ember-classic-decorator": "^2.0.0",
36
- "ember-cli-babel": "^7.26.6",
37
- "ember-cli-htmlbars": "^5.7.1",
38
- "ember-cli-sass": "^10.0.1",
39
- "ember-decorators": "^6.1.1",
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/test-helpers": "~2.2.8",
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
- "babel-eslint": "^10.1.0",
53
+ "@release-it-plugins/lerna-changelog": "^5.0.0",
49
54
  "broccoli-asset-rev": "^3.0.0",
50
- "ember-cli-dependency-checker": "^3.2.0",
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-uglify": "^3.0.0",
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.1.6",
60
- "ember-power-select": "^4.1.5",
61
- "ember-qunit": "~5.1.3",
62
- "ember-raf-test-waiter": "^0.1.0",
63
- "ember-resolver": "^8.0.2",
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-source": "~3.27.5",
66
- "ember-svg-jar": "^2.3.3",
67
- "ember-try": "^1.4.0",
68
- "eslint-plugin-ember": "^9.6.0",
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.16.0",
74
- "qunit-dom": "^1.6.0",
75
- "release-it-lerna-changelog": "^3.1.0",
76
- "release-it": "^14.10.0"
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": "10.* || >= 12.*"
88
+ "node": ">= 12.*"
89
+ },
90
+ "ember": {
91
+ "edition": "octane"
84
92
  },
85
93
  "ember-addon": {
86
94
  "configPath": "tests/dummy/config",
87
- "demoURL": "https://kybishop.github.io/ember-attacher/"
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
  },
@@ -1 +0,0 @@
1
- @import "ember-power-select";