Skip to content

Commit

Permalink
Drop @ember/render-modifiers (#932)
Browse files Browse the repository at this point in the history
* Drop render-modifiers

* Release 3.1.0

* CHANGELOG.md fix
  • Loading branch information
pzubar authored Mar 7, 2024
1 parent 7ff76a4 commit 24ab755
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 71 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@




## v3.1.0 (2024-03-07)
#### :rocket: Enhancement
* [#932](https://github.com/tylerturdenpants/ember-attacher/pull/932) Drop `@ember/render-modifiers` ([@pzubar](https://github.com/pzubar))
* [#887](https://github.com/tylerturdenpants/ember-attacher/pull/887) [chore]: Bump ember-cli-babel from 7.26.11 to 8.2.0 ([@dependabot[bot]](https://github.com/apps/dependabot))

#### Committers: 1
- Petro Zubar ([@pzubar](https://github.com/pzubar))

## v3.0.0 (2024-03-06)

#### :boom: Breaking Change
Expand Down
71 changes: 30 additions & 41 deletions addon/components/attach-popover.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { action } from '@ember/object';
import Component from '@glimmer/component';
import { cancel, debounce, later, next, run } from '@ember/runloop';
import { cancel, debounce, later, next, run, once } from '@ember/runloop';
import { getOwner } from '@ember/application';
import { guidFor } from '@ember/object/internals';
import { htmlSafe, isHTMLSafe } from '@ember/template';
Expand All @@ -10,6 +10,7 @@ import { isEmpty, typeOf } from '@ember/utils';
import { autoUpdate, computePosition, arrow, flip, limitShift, shift } from '@floating-ui/dom';
import { buildWaiter } from '@ember/test-waiters';
import { tracked } from '@glimmer/tracking';
import { modifier } from 'ember-modifier';
import DEFAULTS from '../defaults';

const animationTestWaiter = buildWaiter('attach-popover');
Expand Down Expand Up @@ -293,20 +294,18 @@ export default class AttachPopover extends Component {
this._hide();
}

@action
onParentFinderInsert(element) {
onParentFinderInsert = modifier((element) => {
this.parentElement = element.parentElement;
this._initializeAttacher();
}
once(this, '_initializeAttacher')
});

@action
_ensureArgumentsAreValid() {
_ensureArgumentsAreValid([arrow, useCapture]) {
stripInProduction(() => {
if (this.arrow && this.isFillAnimation) {
if (arrow && this.isFillAnimation) {
warn('Animation: \'fill\' is not compatible with arrow: true', { id: 70015 });
}

if (this.useCapture !== this._lastUseCaptureArgumentValue) {
if (useCapture !== this._lastUseCaptureArgumentValue) {
warn(
'The value of the useCapture argument was mutated',
{ id: 'ember-attacher.use-capture-mutated' }
Expand Down Expand Up @@ -403,15 +402,11 @@ export default class AttachPopover extends Component {
});
}

@action
onTargetOrTriggerChange() {
this._initializeAttacher();
}

@action
onIsShownChange() {
const isShown = this.isShown;
onTargetOrTriggerChange = modifier((_, _positional) => {
once(this, '_initializeAttacher', ..._positional);
});

onIsShownChange = modifier((_, [isShown]) => {
if (isShown === true && this._isHidden) {
this._show();

Expand All @@ -421,7 +416,18 @@ export default class AttachPopover extends Component {
} else if (isShown === false && !this._isHidden) {
this._hide();
}
}
});

initializeAttacher = modifier((floatingElement) => {
this._floatingElement = floatingElement;

if (this.renderInPlace) {
this.parentElement = floatingElement.parentElement;
once(this, '_initializeAttacher');
}

return () => this._cleanup?.();
});

/**
* ================== SHOW ATTACHMENT LOGIC ==================
Expand Down Expand Up @@ -768,31 +774,14 @@ export default class AttachPopover extends Component {
});
}

@action
didInsertFloatingElement(floatingElement) {
this._floatingElement = floatingElement;

if (this.renderInPlace) {
this.parentElement = floatingElement.parentElement;
this._initializeAttacher();
}
}

@action
didInsertArrow(element) {
didInsertArrow = modifier((element) => {
this._arrowElement = element;
}

@action
onOptionsChange() {
this._ensureArgumentsAreValid();
this._update();
}
})

@action
willDestroyFloatingElement() {
this._cleanup?.();
}
onOptionsChange = modifier((_, positional) => {
this._ensureArgumentsAreValid(positional);
once(this, '_update')
})

_update() {
this._cleanup?.();
Expand Down
15 changes: 7 additions & 8 deletions addon/templates/components/attach-popover.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{~#unless this.renderFloatingElement}}
<meta hidden {{did-insert this.onParentFinderInsert}} {{did-update this.onIsShownChange this.isShown}}/>
<meta hidden {{this.onParentFinderInsert}} {{this.onIsShownChange this.isShown}}/>
{{~/unless~}}

{{~#if this.renderFloatingElement~}}
Expand All @@ -8,17 +8,16 @@
class="ember-attacher"
id={{this.id}}
role={{this.ariaRole}}
{{did-insert this.didInsertFloatingElement}}
{{did-update this.onIsShownChange this.isShown}}
{{did-update this.onTargetOrTriggerChange this.hideOn this.showOn @explicitTarget}}
{{did-update this.onOptionsChange this.autoUpdate this.animation this.arrow this.useCapture this.placement this._renderInPlace this._currentTarget this._middleware}}
{{will-destroy this.willDestroyFloatingElement}}
{{this.onIsShownChange this.isShown}}
{{this.onTargetOrTriggerChange this.hideOn this.showOn @explicitTarget}}
{{this.onOptionsChange this.arrow this.useCapture this.autoUpdate this.animation this.placement this._renderInPlace this._currentTarget this._middleware}}
{{this.initializeAttacher}}
...attributes
>
<div class={{this._class}} style={{this._style}}>
{{yield (hash hide=(action 'hide'))}}
{{yield (hash hide=this.hide)}}
{{#if this.arrow}}
<div x-arrow {{did-insert this.didInsertArrow}}></div>
<div x-arrow {{this.didInsertArrow}}></div>
{{/if}}
{{#if this.isFillAnimation}}
<div x-circle style="{{this._circleTransitionDuration}}"></div>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-attacher",
"version": "3.0.0",
"version": "3.1.0",
"description": "Tooltips and popovers for Ember.js apps",
"keywords": [
"ember-addon",
Expand Down Expand Up @@ -37,6 +37,7 @@
"ember-cli-htmlbars": "^6.3.0",
"ember-cli-sass": "^11.0.1",
"ember-maybe-in-element": "^2.1.0",
"ember-modifier": "^4.1.0",
"sass": "^1.71.1"
},
"devDependencies": {
Expand All @@ -45,7 +46,6 @@
"@babel/helper-get-function-arity": "^7.16.7",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@ember/optional-features": "^2.0.0",
"@ember/render-modifiers": "^2.0.5",
"@ember/string": "^3.1.1",
"@ember/test-helpers": "~2.9.4",
"@ember/test-waiters": "^3.1.0",
Expand Down
46 changes: 26 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1115,15 +1115,6 @@
mkdirp "^1.0.4"
silent-error "^1.1.1"

"@ember/render-modifiers@^2.0.5":
version "2.0.5"
resolved "https://registry.yarnpkg.com/@ember/render-modifiers/-/render-modifiers-2.0.5.tgz#4b1d9496a82ca471aeaa3ecddd94ef089450f415"
integrity sha512-5cJ1niIdOJC6k6KtIn9HGbr1DATJQp4ZqMv1vbi6LKQWbVCQ3byvKONtUEi3H0wcewlrcaWCqXOgm0nACzCOQA==
dependencies:
"@embroider/macros" "^1.0.0"
ember-cli-babel "^7.26.11"
ember-modifier-manager-polyfill "^1.2.0"

"@ember/string@^3.1.1":
version "3.1.1"
resolved "https://registry.yarnpkg.com/@ember/string/-/string-3.1.1.tgz#0a5ac0d1e4925259e41d5c8d55ef616117d47ff0"
Expand Down Expand Up @@ -1155,7 +1146,7 @@
ember-cli-version-checker "^5.1.2"
semver "^7.3.5"

"@embroider/addon-shim@^1.8.6":
"@embroider/addon-shim@^1.8.4", "@embroider/addon-shim@^1.8.6":
version "1.8.7"
resolved "https://registry.yarnpkg.com/@embroider/addon-shim/-/addon-shim-1.8.7.tgz#ba2dcb0647ed2cb0c500c835326266b89ceec595"
integrity sha512-JGOQNRj3UR0NdWEg8MsM2eqPLncEwSB1IX+rwntIj22TEKj8biqx7GDgSbeH+ZedijmCh354Hf2c5rthrdzUAw==
Expand Down Expand Up @@ -1192,6 +1183,21 @@
semver "^7.3.5"
typescript-memoize "^1.0.1"

"@embroider/shared-internals@^2.5.1":
version "2.5.2"
resolved "https://registry.yarnpkg.com/@embroider/shared-internals/-/shared-internals-2.5.2.tgz#5cd49c6164147c68fe9d6994ef5cccb47e138bb4"
integrity sha512-jNDJ9YlV6Qp9Na9v17qirUewVuq6T0t32nn+bbnFlCRTvmllKluZdYPSC5RuRnEZKTloVYRSF0+f1rgkTIEvxQ==
dependencies:
babel-import-util "^2.0.0"
debug "^4.3.2"
ember-rfc176-data "^0.3.17"
fs-extra "^9.1.0"
js-string-escape "^1.0.1"
lodash "^4.17.21"
resolve-package-path "^4.0.1"
semver "^7.3.5"
typescript-memoize "^1.0.1"

"@embroider/shared-internals@^2.0.0", "@embroider/shared-internals@^2.5.1":
version "2.5.2"
resolved "https://registry.yarnpkg.com/@embroider/shared-internals/-/shared-internals-2.5.2.tgz#5cd49c6164147c68fe9d6994ef5cccb47e138bb4"
Expand Down Expand Up @@ -4569,7 +4575,7 @@ ember-cli-babel-plugin-helpers@^1.0.0, ember-cli-babel-plugin-helpers@^1.1.1:
resolved "https://registry.yarnpkg.com/ember-cli-babel-plugin-helpers/-/ember-cli-babel-plugin-helpers-1.1.1.tgz#5016b80cdef37036c4282eef2d863e1d73576879"
integrity sha512-sKvOiPNHr5F/60NLd7SFzMpYPte/nnGkq/tMIfXejfKHIhaiIkYFqX8Z9UFTKWLLn+V7NOaby6niNPZUdvKCRw==

ember-cli-babel@^7.1.2, ember-cli-babel@^7.10.0, ember-cli-babel@^7.13.0, ember-cli-babel@^7.13.2, ember-cli-babel@^7.22.1, ember-cli-babel@^7.26.11, ember-cli-babel@^7.26.6, ember-cli-babel@^7.7.3:
ember-cli-babel@^7.1.2, ember-cli-babel@^7.13.0, ember-cli-babel@^7.13.2, ember-cli-babel@^7.22.1, ember-cli-babel@^7.26.11, ember-cli-babel@^7.26.6, ember-cli-babel@^7.7.3:
version "7.26.11"
resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-7.26.11.tgz#50da0fe4dcd99aada499843940fec75076249a9f"
integrity sha512-JJYeYjiz/JTn34q7F5DSOjkkZqy8qwFOOxXfE6pe9yEJqWGu4qErKxlz8I22JoVEQ/aBUO+OcKTpmctvykM9YA==
Expand Down Expand Up @@ -4849,7 +4855,7 @@ ember-cli-typescript@^5.0.0:
stagehand "^1.0.0"
walk-sync "^2.2.0"

ember-cli-version-checker@^2.1.0, ember-cli-version-checker@^2.1.2:
ember-cli-version-checker@^2.1.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/ember-cli-version-checker/-/ember-cli-version-checker-2.2.0.tgz#47771b731fe0962705e27c8199a9e3825709f3b3"
integrity sha512-G+KtYIVlSOWGcNaTFHk76xR4GdzDLzAS4uxZUKdASuFX0KJE43C6DaqL+y3VTpUFLI2FIkAS6HZ4I1YBi+S3hg==
Expand Down Expand Up @@ -4982,7 +4988,7 @@ ember-cli@~4.12.1:
workerpool "^6.4.0"
yam "^1.0.0"

ember-compatibility-helpers@^1.1.2, ember-compatibility-helpers@^1.2.0, ember-compatibility-helpers@^1.2.1:
ember-compatibility-helpers@^1.1.2, ember-compatibility-helpers@^1.2.1:
version "1.2.6"
resolved "https://registry.yarnpkg.com/ember-compatibility-helpers/-/ember-compatibility-helpers-1.2.6.tgz#603579ab2fb14be567ef944da3fc2d355f779cd8"
integrity sha512-2UBUa5SAuPg8/kRVaiOfTwlXdeVweal1zdNPibwItrhR0IvPrXpaqwJDlEZnWKEoB+h33V0JIfiWleSG6hGkkA==
Expand Down Expand Up @@ -5028,14 +5034,14 @@ ember-maybe-in-element@^2.1.0:
ember-cli-htmlbars "^6.1.1"
ember-cli-version-checker "^5.1.2"

ember-modifier-manager-polyfill@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/ember-modifier-manager-polyfill/-/ember-modifier-manager-polyfill-1.2.0.tgz#cf4444e11a42ac84f5c8badd85e635df57565dda"
integrity sha512-bnaKF1LLKMkBNeDoetvIJ4vhwRPKIIumWr6dbVuW6W6p4QV8ZiO+GdF8J7mxDNlog9CeL9Z/7wam4YS86G8BYA==
ember-modifier@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/ember-modifier/-/ember-modifier-4.1.0.tgz#cb91efbf8ca4ff4a1a859767afa42dddba5a2bbd"
integrity sha512-YFCNpEYj6jdyy3EjslRb2ehNiDvaOrXTilR9+ngq+iUqSHYto2zKV0rleiA1XJQ27ELM1q8RihT29U6Lq5EyqQ==
dependencies:
ember-cli-babel "^7.10.0"
ember-cli-version-checker "^2.1.2"
ember-compatibility-helpers "^1.2.0"
"@embroider/addon-shim" "^1.8.4"
ember-cli-normalize-entity-name "^1.0.0"
ember-cli-string-utils "^1.1.0"

ember-qunit@^6.2.0:
version "6.2.0"
Expand Down

0 comments on commit 24ab755

Please sign in to comment.