ember-attacher 3.3.0 → 4.0.0-beta.2

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.
Files changed (41) hide show
  1. package/addon-main.js +2 -0
  2. package/dist/_app_/components/attach-popover.js +1 -0
  3. package/dist/_app_/components/attach-tooltip.js +1 -0
  4. package/dist/_app_/components/basic-attacher.js +1 -0
  5. package/dist/components/attach-popover.js +11 -0
  6. package/dist/components/attach-popover.js.map +1 -0
  7. package/dist/components/attach-tooltip.js +37 -0
  8. package/dist/components/attach-tooltip.js.map +1 -0
  9. package/{addon/components/attach-popover.js → dist/components/basic-attacher.js} +35 -18
  10. package/dist/components/basic-attacher.js.map +1 -0
  11. package/{addon → dist}/defaults.js +5 -1
  12. package/dist/defaults.js.map +1 -0
  13. package/{addon-test-support/is-visible.js → dist/test-support/index.js} +5 -1
  14. package/dist/test-support/index.js.map +1 -0
  15. package/package.json +39 -76
  16. package/.idea/codeStyles/Project.xml +0 -32
  17. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  18. package/.idea/ember-attacher.iml +0 -31
  19. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  20. package/.idea/material_theme_project_new.xml +0 -13
  21. package/.idea/modules.xml +0 -8
  22. package/.idea/vcs.xml +0 -6
  23. package/CHANGELOG.md +0 -729
  24. package/README.md +0 -321
  25. package/RELEASE.md +0 -65
  26. package/addon/-debug/helpers.js +0 -23
  27. package/addon/components/attach-tooltip.js +0 -38
  28. package/addon/styles/_mixins.scss +0 -107
  29. package/addon/styles/addon.sass +0 -5
  30. package/addon/styles/addon.scss +0 -5
  31. package/addon/styles/ember-attacher.scss +0 -137
  32. package/addon/styles/themes.scss +0 -16
  33. package/addon/styles/variables.scss +0 -3
  34. package/addon/templates/components/attach-popover.hbs +0 -29
  35. package/addon-test-support/index.js +0 -1
  36. package/app/components/attach-popover.js +0 -1
  37. package/app/components/attach-tooltip.js +0 -1
  38. package/app/templates/components/attach-popover.js +0 -1
  39. package/config/flexi.js +0 -37
  40. package/docs/upgrade-guide-2.0.md +0 -43
  41. package/index.js +0 -81
package/README.md DELETED
@@ -1,321 +0,0 @@
1
- # ember-attacher
2
-
3
- [![npm version](https://badge.fury.io/js/ember-attacher.svg)](http://badge.fury.io/js/ember-attacher)
4
- [![Download count all time](https://img.shields.io/npm/dt/ember-attacher.svg)](https://www.npmjs.com/package/ember-attacher)
5
- [![npm](https://img.shields.io/npm/dm/ember-attacher.svg)](https://www.npmjs.com/package/ember-attacher)
6
- [![Ember Observer Score](http://emberobserver.com/badges/ember-attacher.svg)](http://emberobserver.com/addons/ember-attacher)
7
- [![GitHub CI](https://github.com/tylerturdenpants/ember-attacher/actions/workflows/ci.yml/badge.svg)](https://github.com/tylerturdenpants/ember-attacher/actions/workflows/ci.yml)
8
-
9
- ## Compatibility
10
-
11
- ------------------------------------------------------------------------------
12
-
13
- ***NOTE***
14
-
15
- The addon's dummy application needs a serious upgrade. I [@tylerturdenpants](https://github.com/tylerturdenpants) have removed as much orf the support on flexi and flexi styles that I can, but the dummy app will still produces warnings regarding SASS division.
16
-
17
- As the only supporter of this addon, a father, and a full time employee at a software company, I really need the help to fully pull flexi out and to revamp the dummy app. Once these blockers are removed I can do the work to bring this addon into the future.
18
-
19
- ----
20
-
21
- * Ember.js v3.20 through v5.12
22
- * Ember CLI v3.13 or above
23
- * Node.js v12 or above
24
-
25
- Tooltips and popovers made easy.
26
- Just drop an `<AttachTooltip/>` or `<AttachPopover/>` in a parent and your floating element is ready to go!
27
-
28
- ```hbs
29
- <button>
30
- Click me
31
-
32
- <AttachTooltip>
33
- I'm a tooltip!
34
- </AttachTooltip>
35
- </button>
36
-
37
- <button class="other-button">
38
- No click me!
39
-
40
- <AttachPopover
41
- @class='ember-attacher'
42
- @hideOn='click'
43
- @isShown={{true}}
44
- @showOn='click'
45
- >
46
- I'm a popover!
47
- </AttachPopover>
48
- </button>
49
- ```
50
-
51
- See [the example site](https://tylerturdenpants.github.io/ember-attacher/) for a demonstration of all
52
- available options.
53
-
54
- ## Installation
55
-
56
- ```bash
57
- ember install ember-attacher
58
- ```
59
-
60
- If you're upgrading from 1.x to 2.x [see the upgrade guide](./docs/upgrade-guide-2.0.md).
61
-
62
-
63
- ## Components
64
-
65
- ### `<AttachPopover/>`
66
-
67
- A popover attacher.
68
-
69
- * Has no default class or roles.
70
- * Does not modify the target in any way.
71
- * Adds `aria-hidden` attribute to the floating element
72
-
73
- ### `<AttachTooltip/>`
74
-
75
- A tooltip attacher. Subclass of `<AttachPopover/>`
76
-
77
- * Has the default class `'ember-attacher-floating ember-attacher-tooltip'`
78
- * The default tooltip classes can be modified by altering the `tooltipClass`
79
- default. See [here](#user-defined-defaults) for details on editing default values.
80
-
81
- * Default `role` attribute of `tooltip`.
82
- * Causes the target to gain an `aria-describedby` attribute set to the tooltip's ID.
83
-
84
- ## Options
85
-
86
- Below is a list of all available options, along with their defaults.
87
-
88
- ```javascript
89
- {
90
- // The animation used to present the animation.
91
- // Options: ['fade', 'fill', 'none', 'perspective', 'scale', 'shift']
92
- animation: 'fill',
93
-
94
- // Whether or not an arrow will be displayed next to the attachment.
95
- arrow: false,
96
-
97
- // Add listeners that will automatically call an update function
98
- // Pass `true` to use the Floating UI default options or Options object to override them
99
- // Example: { ancestorScroll: false }
100
- // For more details see https://floating-ui.com/docs/autoUpdate
101
- autoUpdate: false,
102
-
103
- // A class that will be applied to the attachment.
104
- class: null,
105
-
106
- // The flip priority of the attacment.
107
- // Space-delimited string, any combination of ['left', 'right', 'top', 'bottom']
108
- //
109
- // Example: 'left top bottom'
110
- flip: null,
111
-
112
- // The delay, in milliseconds, before the attachment will be hidden.
113
- hideDelay: 0,
114
-
115
- // The duration, in milliseconds, of the hide animation.
116
- hideDuration: 300,
117
-
118
- // Events that will cause the attachment to hide, typically in reference to the target.
119
- //
120
- // Space-delimited string, any combination of:
121
- // ['click', 'clickout', 'mouseleave blur escapekey']
122
- hideOn: 'mouseleave blur escapekey',
123
-
124
- // Interactive tooltips will not close when clicked or hovered over.
125
- interactive: false,
126
-
127
- // Set this to true if you have an interactive attachment that hides on mouseout and the
128
- // attachment is offset from its target. This should only be the case if you are using custom
129
- // CSS that offsets that attachment.
130
- isOffset: false,
131
-
132
- // Whether or not the attachment is initially shown.
133
- isShown: false,
134
-
135
- // If true, the attachment will only be inserted into the DOM on the first "show" trigger.
136
- // Useful for performance reasons, but will hide your attachment from search engines.
137
- lazyRender: false,
138
-
139
- // A middleware array that will be merged into computePosition options
140
- middleware: null,
141
-
142
- // A function to be fired when the attachment's visibility changes. The new visibility is passed
143
- // to the function as an arg.
144
- onChange: null,
145
-
146
- // The initial position of the attachment.
147
- // Options: ['left', 'right', 'top', 'bottom']
148
- placement: 'top',
149
-
150
- // The container where the attachment's DOM will be inserted.
151
- floatingElementContainer: '.ember-application',
152
-
153
- // An options object that will be passed to Floating UI "computePosition" function.
154
- floatingUiOptions: null,
155
-
156
- // NOT RECOMMENDED: We currently allow you to pass an explicit target, but this may be removed
157
- // in a future release.
158
- // Please provide your thoughts here: https://github.com/kybishop/ember-attacher/issues/109
159
- explicitTarget: null,
160
-
161
- // Whether or not to render the attachment in place in the DOM, as opposed to
162
- // on the floatingElementContainer. NOTE: Rendering in place can cause z-index issues.
163
- renderInPlace: false,
164
-
165
- // The delay, in milliseconds, before the attachment will be shown.
166
- showDelay: 0,
167
-
168
- // The duration, in milliseconds, of the show animation.
169
- showDuration: 300,
170
-
171
- // Events on the target that will cause the attachment to show. For performance reasons, we
172
- // recommend using some combination of 'mouseenter', 'focus', and 'click'
173
- showOn: 'mouseenter focus',
174
-
175
- // Whether to add event listeners for attachment show and hide in the capturing phase rather
176
- // than the bubbling phase. This should be set to true when there are elements on the page that
177
- // are stopping event propagation in the bubbling phase, and as a result preventing correct
178
- // showing and hiding of popovers and tooltips.
179
- useCapture: false,
180
-
181
- // The default padding if collision happens. Set "false" if no collision prevention needed
182
- overflowPadding: 5
183
- }
184
- ```
185
-
186
- ## User-defined defaults
187
-
188
- User-defined defaults can be set in the consuming app or addon's config/environment.js. These defaults will be applied to every `<AttachPopover/>` and `<AttachTooltip/>`
189
-
190
- ```javascript
191
- // config/environment.js
192
-
193
- module.exports = function(environment) {
194
- var ENV = {
195
- emberAttacher: {
196
- animation: 'shift',
197
- arrow: true
198
- }
199
- };
200
- }
201
- ```
202
-
203
- You can also set the user-defined defaults separately like so:
204
-
205
- ```javascript
206
- // config/environment.js
207
-
208
- module.exports = function(environment) {
209
- var ENV = {
210
- emberAttacher: {
211
- tooltip: {
212
- animation: 'fade',
213
- arrow: true
214
- },
215
- popover: {
216
- animation: 'shift',
217
- arrow: false
218
- }
219
- }
220
- };
221
- }
222
- ```
223
-
224
- And finally you can do shared defaults along with user-defined separated defaults:
225
-
226
- ```javascript
227
- // config/environment.js
228
-
229
- module.exports = function(environment) {
230
- var ENV = {
231
- emberAttacher: {
232
- showDuration: 300,
233
- hideDuration: 300,
234
- tooltip: {
235
- animation: 'fade',
236
- arrow: true
237
- },
238
- popover: {
239
- animation: 'shift',
240
- arrow: false
241
- }
242
- }
243
- };
244
- }
245
- ```
246
-
247
- The full list of editable defaults can be seen [here](https://github.com/kybishop/ember-attacher/blob/master/addon/defaults.js).
248
-
249
- ## Styles
250
-
251
- `ember-attacher` provides [styles](https://github.com/kybishop/ember-attacher/blob/master/addon/styles/addon.scss#L85) for the default tooltip class, `ember-attacher-tooltip`, but no styles are included for `{{attach-popover}}`.
252
-
253
- Example styling for a popover [can be found in the dummy app](https://github.com/kybishop/ember-attacher/blob/master/tests/dummy/app/styles/app.scss#L132). Note how the arrow must also be styled to match the popover (background color, size, etc.)
254
-
255
- ## Testing
256
-
257
- Use the `isVisible()` test helper to check if an attachment is visible.
258
-
259
- ```javascript
260
- import { click, find } from 'ember-native-dom-helpers';
261
- import { isVisible } from 'ember-attacher';
262
-
263
- test('example', async function(assert) {
264
- this.render(hbs`
265
- <button id="toggle">
266
- Click me, captain!
267
-
268
- <AttachPopover
269
- @id='attachment'
270
- @hideOn='click'
271
- @showOn='click'
272
- >
273
- Click-toggled popover
274
- <AttachPopover/>
275
- </button>
276
- `);
277
-
278
- const attachment = find('#attachment');
279
-
280
- assert.equal(isVisible(attachment), false, 'Initially hidden');
281
-
282
- await click('#toggle');
283
-
284
- // You can also pass in a selector
285
- assert.equal(isVisible('#attachment'), true, 'Now shown');
286
- });
287
- ```
288
-
289
- ## Development setup
290
-
291
- See the [Contributing](CONTRIBUTING.md) guide for details.
292
-
293
- ## FAQ
294
-
295
- ### How animations are implemented
296
-
297
- Attachments are composed of two containers:
298
-
299
- * [An outer container](https://github.com/kybishop/ember-attacher/blob/master/addon/templates/components/attach-popover.hbs#L2) for positioning (via [floating-ui](https://github.com/floating-ui/floating-ui)).
300
- * [An inner container](https://github.com/kybishop/ember-attacher/blob/master/addon/templates/components/attach-popover.hbs#L12) for the content. This is the container that is animated.
301
-
302
- The outer container is positioned right next to the target via the CSS `transform` property. The inner container is required because animations also use `transform`, which would otherwise conflict with the container's position.
303
-
304
- `transform` and `tansition-duration` are the CSS magic that allows animations to smoothly shift up/down, left/right, etc.
305
-
306
- Note that animations require an implementation for each position (left, right, top, and bottom):
307
-
308
- * <https://github.com/kybishop/ember-attacher/blob/master/addon/styles/addon.scss#L67>
309
-
310
- * <https://github.com/kybishop/ember-attacher/blob/master/addon/styles/_mixins.scss#L75>
311
-
312
- ## Credits
313
-
314
- * [tippy.js](https://github.com/atomiks/tippyjs), the library that inspired
315
- ember-attacher.
316
-
317
- * [floating-ui](https://github.com/floating-ui/floating-ui), the library that powers
318
- positioning
319
-
320
- * [ember-tooltips](https://github.com/sir-dunxalot/ember-tooltips), the addon that
321
- influenced much of ember-attacher's API.
package/RELEASE.md DELETED
@@ -1,65 +0,0 @@
1
- # Release
2
-
3
- Releases are mostly automated using
4
- [release-it](https://github.com/release-it/release-it/) and
5
- [lerna-changelog](https://github.com/lerna/lerna-changelog/).
6
-
7
-
8
- ## Preparation
9
-
10
- Since the majority of the actual release process is automated, the primary
11
- remaining task prior to releasing is confirming that all pull requests that
12
- have been merged since the last release have been labeled with the appropriate
13
- `lerna-changelog` labels and the titles have been updated to ensure they
14
- represent something that would make sense to our users. Some great information
15
- on why this is important can be found at
16
- [keepachangelog.com](https://keepachangelog.com/en/1.0.0/), but the overall
17
- guiding principles here is that changelogs are for humans, not machines.
18
-
19
- When reviewing merged PR's the labels to be used are:
20
-
21
- * breaking - Used when the PR is considered a breaking change.
22
- * enhancement - Used when the PR adds a new feature or enhancement.
23
- * bug - Used when the PR fixes a bug included in a previous release.
24
- * documentation - Used when the PR adds or updates documentation.
25
- * internal - Used for internal changes that still require a mention in the
26
- changelog/release notes.
27
-
28
-
29
- ## Release
30
-
31
- Once the prep work is completed, the actual release is straight forward:
32
-
33
- * First ensure that you have `release-it` installed globally, generally done by
34
- using one of the following commands:
35
-
36
- ```
37
- # using https://volta.sh
38
- volta install release-it
39
-
40
- # using Yarn
41
- yarn global add release-it
42
-
43
- # using npm
44
- npm install --global release-it
45
- ```
46
-
47
- * Second, ensure that you have installed your projects dependencies:
48
-
49
- ```
50
- # using yarn
51
- yarn install
52
-
53
- # using npm
54
- npm install
55
- ```
56
-
57
- * And last (but not least 😁) do your release:
58
-
59
- ```
60
- release-it
61
- ```
62
-
63
- [release-it](https://github.com/release-it/release-it/) manages the actual
64
- release process. It will prompt you through the process of choosing the version
65
- number, tagging, pushing the tag and commits, etc.
@@ -1,23 +0,0 @@
1
- import Ember from 'ember';
2
- const { Logger } = Ember;
3
-
4
- export function assert(msg, conditional) {
5
- if (!conditional) {
6
- throw new Error(msg);
7
- }
8
- }
9
-
10
- export function debug() {
11
- Logger.debug(...arguments);
12
- }
13
-
14
- export function debugOnError(msg, conditional) {
15
- if (!conditional) {
16
- console.error(msg); // eslint-disable-line no-console
17
- debugger; // eslint-disable-line no-debugger
18
- }
19
- }
20
-
21
- export function stripInProduction(cb) {
22
- cb();
23
- }
@@ -1,38 +0,0 @@
1
- import AttachPopover from './attach-popover';
2
- import DEFAULTS from '../defaults';
3
- import layout from '../templates/components/attach-popover';
4
- import { setComponentTemplate } from '@ember/component';
5
-
6
- class AttachTooltip extends AttachPopover {
7
- configKey = 'tooltip';
8
-
9
- get ariaRole() {
10
- return this.args.ariaRole || 'tooltip';
11
- }
12
-
13
- get _class() {
14
- return `${super._class} ${this._config.tooltipClass || DEFAULTS.tooltipClass}`
15
- }
16
-
17
- _initializeAttacher() {
18
- super._initializeAttacher();
19
-
20
- if (this._currentTarget?.getAttribute('aria-describedby') != this.id) {
21
- const oldTarget = document.querySelector(`[aria-describedby="${this.id}"]`);
22
-
23
- oldTarget?.removeAttribute('aria-describedby')
24
- this._currentTarget?.setAttribute('aria-describedby', this.id);
25
- }
26
- }
27
-
28
- willDestroy() {
29
- super.willDestroy(...arguments);
30
-
31
- const target = this._currentTarget;
32
- if (target) {
33
- target.removeAttribute('aria-describedby');
34
- }
35
- }
36
- }
37
-
38
- export default setComponentTemplate(layout, AttachTooltip);
@@ -1,107 +0,0 @@
1
- @mixin arrow($position, $width) {
2
- @if ($position == 'top') {
3
- transform: rotate(-45deg);
4
- bottom: -$width * .5;
5
- } @else if ($position == 'bottom') {
6
- transform: rotate(135deg);
7
- top: -$width * .5;
8
- } @else if ($position == 'left') {
9
- transform: rotate(225deg);
10
- right: -$width * .5;
11
- top: 50%;
12
- } @else if ($position == 'right') {
13
- transform: rotate(45deg);
14
- left: -$width * .5;
15
- top: 50%;
16
- }
17
- }
18
-
19
- @mixin circle-transform-hide($position) {
20
- @if ($position == 'top') {
21
- transform: scale(0) translate(-50%, -50%);
22
- } @else if ($position == 'bottom') {
23
- transform: scale(0) translate(-50%, -50%);
24
- } @else if ($position == 'left') {
25
- transform: scale(0) translate(-50%, -33%);
26
- } @else if ($position == 'right') {
27
- transform: scale(0) translate(-50%, -33%);
28
- }
29
- }
30
-
31
- @mixin ember-attacher-hide-transform($position, $animation) {
32
- @if ($animation == 'perspective') {
33
- @if ($position == 'top') {
34
- transform: translateY(0) rotateX(90deg);
35
- } @else if ($position == 'bottom') {
36
- transform: translateY(0) rotateX(-90deg);
37
- } @else if ($position == 'left') {
38
- transform: translateX(0) rotateY(-90deg);
39
- } @else if ($position == 'right') {
40
- transform: translateX(0) rotateY(90deg);
41
- }
42
- } @else if ($animation == 'shift') {
43
- @if ($position == 'top') {
44
- transform: translateY(0);
45
- } @else if ($position == 'bottom') {
46
- transform: translateY(0);
47
- } @else if ($position == 'left') {
48
- transform: translateX(0);
49
- } @else if ($position == 'right') {
50
- transform: translateX(0);
51
- }
52
- } @else if ($animation == 'scale') {
53
- @if ($position == 'top') {
54
- transform: translateY(0) scale(0);
55
- } @else if ($position == 'bottom') {
56
- transform: translateY(0) scale(0);
57
- } @else if ($position == 'left') {
58
- transform: translateX(0) scale(0);
59
- } @else if ($position == 'right') {
60
- transform: translateX(0) scale(0);
61
- }
62
- } @else if ($animation == 'none') {
63
- @if ($position == 'top') {
64
- transform: translateY(-10px);
65
- } @else if ($position == 'bottom') {
66
- transform: translateY(10px);
67
- } @else if ($position == 'left') {
68
- transform: translateX(-10px);
69
- } @else if ($position == 'right') {
70
- transform: translateX(10px);
71
- }
72
- }
73
- }
74
-
75
- @mixin ember-attacher-show-transform($position, $animation) {
76
- @if ($animation == 'perspective') {
77
- @if ($position == 'top') {
78
- transform: translateY(-10px) rotateX(0);
79
- } @else if ($position == 'bottom') {
80
- transform: translateY(10px) rotateX(0);
81
- } @else if ($position == 'left') {
82
- transform: translateX(-10px) rotateY(0);
83
- } @else if ($position == 'right') {
84
- transform: translateX(10px) rotateY(0);
85
- }
86
- } @else if ($animation == 'fade') {
87
- @if ($position == 'top') {
88
- transform: translateY(-10px);
89
- } @else if ($position == 'bottom') {
90
- transform: translateY(10px);
91
- } @else if ($position == 'left') {
92
- transform: translateX(-10px);
93
- } @else if ($position == 'right') {
94
- transform: translateX(10px);
95
- }
96
- } @else if ($animation == 'scale') {
97
- @if ($position == 'top') {
98
- transform: translateY(-10px) scale(1);
99
- } @else if ($position == 'bottom') {
100
- transform: translateY(10px) scale(1);
101
- } @else if ($position == 'left') {
102
- transform: translateX(-10px) scale(1);
103
- } @else if ($position == 'right') {
104
- transform: translateX(10px) scale(1);
105
- }
106
- }
107
- }
@@ -1,5 +0,0 @@
1
- @import 'variables'
2
- @import 'mixins'
3
- @import 'themes'
4
-
5
- @import 'ember-attacher'
@@ -1,5 +0,0 @@
1
- @import 'variables';
2
- @import 'mixins';
3
- @import 'themes';
4
-
5
- @import 'ember-attacher';