@ember-eui/core 7.0.11 → 7.0.13-7.0.13-alpha.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.
@@ -49,7 +49,7 @@ export default class EuiMarkdownEditorToolbarComponent extends Component<EuiMark
49
49
  if (this.args.rootClasses) {
50
50
  let rootClasses = isArray(this.args.rootClasses)
51
51
  ? this.args.rootClasses
52
- : (this.args.rootClasses as string)?.trim()?.split(' ') || [];
52
+ : (this.args.rootClasses as string)?.split(' ') || [];
53
53
 
54
54
  baseClasses = baseClasses.concat(rootClasses);
55
55
  }
@@ -1,6 +1,7 @@
1
1
  import Modifier from 'ember-modifier';
2
2
  import { guidFor } from '@ember/object/internals';
3
3
  import { action } from '@ember/object';
4
+ import { registerDestructor } from '@ember/destroyable';
4
5
 
5
6
  interface OutsideClickDetectorModifierArgs {
6
7
  positional: [];
@@ -22,9 +23,13 @@ export default class OutsideClickDetector extends Modifier<OutsideClickDetectorM
22
23
  id!: string;
23
24
  capturedDownIds: string[] = [];
24
25
 
26
+ element!: Element;
27
+ named!: OutsideClickDetectorModifierArgs['named'];
28
+ positional!: OutsideClickDetectorModifierArgs['positional'];
29
+
25
30
  @action
26
31
  onClickOutside(e: Event): void {
27
- const { isDisabled, onOutsideClick } = this.args.named;
32
+ const { isDisabled, onOutsideClick } = this.named;
28
33
 
29
34
  if (isDisabled) {
30
35
  this.capturedDownIds = [];
@@ -45,13 +50,32 @@ export default class OutsideClickDetector extends Modifier<OutsideClickDetectorM
45
50
  return onOutsideClick(event);
46
51
  }
47
52
 
48
- didInstall(): void {
53
+ //@ts-expect-error dont know how to type this
54
+ modify(
55
+ element: Element,
56
+ positional: OutsideClickDetector['positional'],
57
+ named: OutsideClickDetector['named']
58
+ ): void {
59
+ this.element = element;
60
+ this.named = named;
61
+ this.positional = positional;
62
+ this._setup();
63
+ registerDestructor(this, () => this._teardown());
64
+ }
65
+
66
+ _setup(): void {
49
67
  this.id = guidFor({});
50
68
  document.addEventListener('mouseup', this.onClickOutside);
51
69
  document.addEventListener('touchend', this.onClickOutside);
52
70
  this.addElementEvents();
53
71
  }
54
72
 
73
+ _teardown(): void {
74
+ document.removeEventListener('mouseup', this.onClickOutside);
75
+ document.removeEventListener('touchend', this.onClickOutside);
76
+ this.removeElementEvents();
77
+ }
78
+
55
79
  addElementEvents(): void {
56
80
  this.element.addEventListener('mousedown', this.onChildMouseDown);
57
81
  this.element.addEventListener('touchstart', this.onChildMouseDown);
@@ -66,12 +90,6 @@ export default class OutsideClickDetector extends Modifier<OutsideClickDetectorM
66
90
  this.element.removeEventListener('touchend', this.onChildMouseUp);
67
91
  }
68
92
 
69
- willRemove(): void {
70
- document.removeEventListener('mouseup', this.onClickOutside);
71
- document.removeEventListener('touchend', this.onClickOutside);
72
- this.removeElementEvents();
73
- }
74
-
75
93
  @action
76
94
  onChildClick(event: MouseEvent, cb: (event: MouseEvent) => void): void {
77
95
  // to support nested click detectors, build an array
@@ -90,16 +108,16 @@ export default class OutsideClickDetector extends Modifier<OutsideClickDetectorM
90
108
  this.onChildClick(event, (e) => {
91
109
  const nativeEvent = e as unknown as EuiEvent;
92
110
  this.capturedDownIds = nativeEvent.euiGeneratedBy;
93
- if (this.args.named.onMouseDown) this.args.named.onMouseDown(e);
94
- if (this.args.named.onTouchStart) this.args.named.onTouchStart(e);
111
+ this.named?.onMouseDown?.(e);
112
+ this.named?.onTouchStart?.(e);
95
113
  });
96
114
  }
97
115
 
98
116
  @action
99
117
  onChildMouseUp(event: MouseEvent): void {
100
118
  this.onChildClick(event, (e) => {
101
- if (this.args.named.onMouseUp) this.args.named.onMouseUp(e);
102
- if (this.args.named.onTouchEnd) this.args.named.onTouchEnd(e);
119
+ this.named?.onMouseUp?.(e);
120
+ this.named?.onTouchEnd?.(e);
103
121
  });
104
122
  }
105
123
  }
@@ -1,5 +1,6 @@
1
1
  import Modifier from 'ember-modifier';
2
2
  import { action } from '@ember/object';
3
+ import { registerDestructor } from '@ember/destroyable';
3
4
 
4
5
  // IE11 and Safari don't support the `ResizeObserver` API at the time of writing
5
6
  const hasResizeObserver =
@@ -60,9 +61,13 @@ export default class ResizeObserver extends Modifier<ResizeObserverArgs> {
60
61
  width: number = 0;
61
62
  observer: Observer | null = null;
62
63
 
64
+ element!: Element;
65
+ named!: ResizeObserverArgs['named'];
66
+ positional!: ResizeObserverArgs['positional'];
67
+
63
68
  @action
64
69
  setSize({ width, height }: { width: number; height: number }) {
65
- let [dimension] = this.args.positional;
70
+ let [dimension] = this.positional;
66
71
  const doesWidthMatter = dimension !== 'height';
67
72
  const doesHeightMatter = dimension !== 'width';
68
73
  if (
@@ -71,11 +76,24 @@ export default class ResizeObserver extends Modifier<ResizeObserverArgs> {
71
76
  ) {
72
77
  this.width = width;
73
78
  this.height = height;
74
- this.args.named?.onResize({ width, height });
79
+ this.named?.onResize({ width, height });
75
80
  }
76
81
  }
77
82
 
78
- didInstall() {
83
+ //@ts-expect-error dont know how to type this
84
+ modify(
85
+ element: Element,
86
+ positional: ['width' | 'height'],
87
+ named: { onResize: (dimensions: { height: number; width: number }) => void }
88
+ ) {
89
+ this.element = element;
90
+ this.named = named;
91
+ this.positional = positional;
92
+ this._setup();
93
+ registerDestructor(this, () => this._teardown());
94
+ }
95
+
96
+ _setup() {
79
97
  let { setSize, element } = this;
80
98
  if (element != null) {
81
99
  // ResizeObserver's first call to the observation callback is scheduled in the future
@@ -101,7 +119,7 @@ export default class ResizeObserver extends Modifier<ResizeObserverArgs> {
101
119
  }
102
120
  }
103
121
 
104
- willRemove() {
122
+ _teardown() {
105
123
  this.observer?.disconnect();
106
124
  }
107
125
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ember-eui/core",
3
- "version": "7.0.11",
3
+ "version": "7.0.13-7.0.13-alpha.1.0",
4
4
  "description": "Ember Components for Elastic UI",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -66,14 +66,14 @@
66
66
  "ember-cli-string-helpers": "^6.1.0",
67
67
  "ember-cli-typescript": "4.2.1",
68
68
  "ember-composable-helpers": "^4.4.1",
69
- "ember-element-helper": "^0.6.0",
69
+ "ember-element-helper": "^0.8.5",
70
70
  "ember-event-helpers": "^0.1.1",
71
71
  "ember-in-element-polyfill": "^1.0.0",
72
72
  "ember-keyboard": "^7.0.1",
73
73
  "ember-math-helpers": "^2.15.0",
74
- "ember-modifier": "^3.1.0",
74
+ "ember-modifier": "^4.1.0",
75
75
  "ember-named-blocks-polyfill": "^0.2.3",
76
- "ember-power-select": "7.0.0",
76
+ "ember-power-select": "7.1.2",
77
77
  "ember-set-body-class": "^1.0.2",
78
78
  "ember-set-helper": "^2.0.1",
79
79
  "ember-style-modifier": "^0.7.0",
@@ -186,5 +186,5 @@
186
186
  "volta": {
187
187
  "extends": "../../package.json"
188
188
  },
189
- "gitHead": "43e92f974430c62511e62bfa0b12fe2b50900b36"
189
+ "gitHead": "e6ea2cbd75f5490039cbd98a298e7f07df2d675f"
190
190
  }
package/tsconfig.json CHANGED
@@ -14,6 +14,7 @@
14
14
  "core/*": ["addon/*"],
15
15
  "core/test-support": ["addon-test-support"],
16
16
  "core/test-support/*": ["addon-test-support/*"],
17
+ "@ember/destroyable": ["../../node_modules/ember-destroyable-polyfill"],
17
18
  "*": ["types/*"]
18
19
  }
19
20
  },