@ng-atomic/common 19.144.4 → 19.148.4

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.
@@ -68,6 +68,17 @@ function releaseFocusWithin(hostElement) {
68
68
  }
69
69
 
70
70
  const ACTIVE_CONTROL_DEACTIVATE_EVENT = 'active-control:request-deactivate';
71
+ const ACTIVE_CONTROL_KEEP_ATTR = 'data-active-control-keep';
72
+ const ACTIVE_CONTROL_DEACTIVATE_ATTR = 'data-active-control-deactivate';
73
+ function keepsActiveOnMousedown(target) {
74
+ return target instanceof Element && target.closest(`[${ACTIVE_CONTROL_KEEP_ATTR}]`) !== null;
75
+ }
76
+ function forcesDeactivateOnClick(target) {
77
+ return target instanceof Element && target.closest(`[${ACTIVE_CONTROL_DEACTIVATE_ATTR}]`) !== null;
78
+ }
79
+ function keepsActiveByModifier(event) {
80
+ return event.altKey;
81
+ }
71
82
  class ActiveControlEventHandlers {
72
83
  constructor(hostElement, isActive, onActiveChange, options = {}) {
73
84
  this.hostElement = hostElement;
@@ -126,6 +137,9 @@ class ActiveControlEventHandlers {
126
137
  forwardActivationFocus({ hostElement: this.hostElement, focusTargetSelector: this.options.focusTargetSelector }, e.clientX, e.clientY);
127
138
  return;
128
139
  }
140
+ if (keepsActiveByModifier(e)) {
141
+ return;
142
+ }
129
143
  if (!start) {
130
144
  return;
131
145
  }
@@ -133,7 +147,7 @@ class ActiveControlEventHandlers {
133
147
  if (moved) {
134
148
  return;
135
149
  }
136
- if (isClickConsumedByInnerWidget({ hostElement: this.hostElement, focusTargetSelector: this.options.focusTargetSelector }, e.target)) {
150
+ if (!forcesDeactivateOnClick(e.target) && isClickConsumedByInnerWidget({ hostElement: this.hostElement, focusTargetSelector: this.options.focusTargetSelector }, e.target)) {
137
151
  return;
138
152
  }
139
153
  if (this.isActive()) {
@@ -146,6 +160,8 @@ class ActiveControlEventHandlers {
146
160
  this.setActive(false);
147
161
  });
148
162
  const documentClickListener = (e) => {
163
+ if (keepsActiveOnMousedown(e.target))
164
+ return;
149
165
  if (!this.hostElement.contains(e.target) && this.isActive()) {
150
166
  this.setActive(false);
151
167
  }
@@ -202,6 +202,17 @@ function releaseFocusWithin(hostElement) {
202
202
  }
203
203
 
204
204
  const ACTIVE_CONTROL_DEACTIVATE_EVENT = 'active-control:request-deactivate';
205
+ const ACTIVE_CONTROL_KEEP_ATTR = 'data-active-control-keep';
206
+ const ACTIVE_CONTROL_DEACTIVATE_ATTR = 'data-active-control-deactivate';
207
+ function keepsActiveOnMousedown(target) {
208
+ return target instanceof Element && target.closest(`[${ACTIVE_CONTROL_KEEP_ATTR}]`) !== null;
209
+ }
210
+ function forcesDeactivateOnClick(target) {
211
+ return target instanceof Element && target.closest(`[${ACTIVE_CONTROL_DEACTIVATE_ATTR}]`) !== null;
212
+ }
213
+ function keepsActiveByModifier(event) {
214
+ return event.altKey;
215
+ }
205
216
  class ActiveControlEventHandlers {
206
217
  constructor(hostElement, isActive, onActiveChange, options = {}) {
207
218
  this.hostElement = hostElement;
@@ -260,6 +271,9 @@ class ActiveControlEventHandlers {
260
271
  forwardActivationFocus({ hostElement: this.hostElement, focusTargetSelector: this.options.focusTargetSelector }, e.clientX, e.clientY);
261
272
  return;
262
273
  }
274
+ if (keepsActiveByModifier(e)) {
275
+ return;
276
+ }
263
277
  if (!start) {
264
278
  return;
265
279
  }
@@ -267,7 +281,7 @@ class ActiveControlEventHandlers {
267
281
  if (moved) {
268
282
  return;
269
283
  }
270
- if (isClickConsumedByInnerWidget({ hostElement: this.hostElement, focusTargetSelector: this.options.focusTargetSelector }, e.target)) {
284
+ if (!forcesDeactivateOnClick(e.target) && isClickConsumedByInnerWidget({ hostElement: this.hostElement, focusTargetSelector: this.options.focusTargetSelector }, e.target)) {
271
285
  return;
272
286
  }
273
287
  if (this.isActive()) {
@@ -280,6 +294,8 @@ class ActiveControlEventHandlers {
280
294
  this.setActive(false);
281
295
  });
282
296
  const documentClickListener = (e) => {
297
+ if (keepsActiveOnMousedown(e.target))
298
+ return;
283
299
  if (!this.hostElement.contains(e.target) && this.isActive()) {
284
300
  this.setActive(false);
285
301
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@ng-atomic/common",
3
- "version": "19.144.4",
3
+ "version": "19.148.4",
4
4
  "license": "MIT",
5
5
  "peerDependencies": {
6
- "@nx-ddd/core": "19.144.4",
7
- "@nx-ddd/common": "19.144.4"
6
+ "@nx-ddd/core": "19.148.4",
7
+ "@nx-ddd/common": "19.148.4"
8
8
  },
9
9
  "dependencies": {
10
10
  "tslib": "^2.3.0"