@miso.ai/client-sdk-ui 1.10.0-beta.0 → 1.10.0-beta.10

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 (90) hide show
  1. package/dist/cjs/actor/autocomplete.js +157 -0
  2. package/dist/cjs/actor/data.js +4 -12
  3. package/dist/cjs/actor/fields.js +8 -0
  4. package/dist/cjs/actor/index.js +7 -0
  5. package/dist/cjs/actor/tracker.js +46 -70
  6. package/dist/cjs/actor/trackers.js +5 -1
  7. package/dist/cjs/actor/utils.js +16 -2
  8. package/dist/cjs/actor/view.js +14 -3
  9. package/dist/cjs/actor/views.js +9 -1
  10. package/dist/cjs/affiliation/index.js +126 -0
  11. package/dist/cjs/combo/ask/options.js +1 -1
  12. package/dist/cjs/combo/base.js +1 -1
  13. package/dist/cjs/constants.js +6 -3
  14. package/dist/cjs/defaults/ask/controls.js +1 -1
  15. package/dist/cjs/defaults/ask/phrases.js +1 -1
  16. package/dist/cjs/defaults/ask/templates.js +35 -4
  17. package/dist/cjs/element/role/index.js +7 -0
  18. package/dist/cjs/element/role/miso-affiliation.js +20 -0
  19. package/dist/cjs/layout/affiliation/affiliation.js +330 -0
  20. package/dist/cjs/layout/banner/banner.js +1 -1
  21. package/dist/cjs/layout/container/container.js +1 -1
  22. package/dist/cjs/layout/error/error.js +1 -1
  23. package/dist/cjs/layout/index.js +7 -0
  24. package/dist/cjs/layout/input/option-list.js +35 -50
  25. package/dist/cjs/layout/input/search-box.js +227 -129
  26. package/dist/cjs/layout/list/cards.js +1 -1
  27. package/dist/cjs/layout/list/carousel.js +5 -3
  28. package/dist/cjs/layout/list/collection.js +44 -49
  29. package/dist/cjs/layout/list/list.js +1 -1
  30. package/dist/cjs/layout/radio/feedback.js +1 -1
  31. package/dist/cjs/layout/radio/radio.js +1 -1
  32. package/dist/cjs/layout/raf.js +1 -1
  33. package/dist/cjs/layout/template.js +1 -1
  34. package/dist/cjs/layout/templates.js +172 -66
  35. package/dist/cjs/layout/text/text.js +1 -1
  36. package/dist/cjs/layout/text/typewriter/index.js +3 -3
  37. package/dist/cjs/layout/trackable.js +124 -0
  38. package/dist/cjs/plugin.js +1 -1
  39. package/dist/cjs/source/index.js +20 -8
  40. package/dist/cjs/util/bindings.js +58 -110
  41. package/dist/cjs/util/states.js +31 -24
  42. package/dist/cjs/util/trackers.js +75 -0
  43. package/dist/cjs/util/viewables.js +55 -0
  44. package/dist/cjs/version.js +1 -1
  45. package/dist/cjs/workflow/ask.js +60 -19
  46. package/dist/cjs/workflow/asks.js +1 -1
  47. package/dist/cjs/workflow/base.js +6 -7
  48. package/dist/cjs/workflow/explore.js +5 -2
  49. package/dist/cjs/workflow/options.js +60 -14
  50. package/dist/cjs/workflow/recommendation.js +2 -0
  51. package/dist/cjs/workflow/search.js +35 -7
  52. package/package.json +2 -2
  53. package/src/actor/autocomplete.js +131 -0
  54. package/src/actor/data.js +3 -10
  55. package/src/actor/fields.js +8 -0
  56. package/src/actor/index.js +1 -0
  57. package/src/actor/tracker.js +39 -62
  58. package/src/actor/trackers.js +3 -1
  59. package/src/actor/utils.js +14 -2
  60. package/src/actor/view.js +12 -1
  61. package/src/actor/views.js +11 -0
  62. package/src/affiliation/index.js +108 -0
  63. package/src/constants.js +10 -1
  64. package/src/defaults/ask/phrases.js +1 -1
  65. package/src/defaults/ask/templates.js +34 -2
  66. package/src/element/role/index.js +1 -0
  67. package/src/element/role/miso-affiliation.js +16 -0
  68. package/src/layout/affiliation/affiliation.js +295 -0
  69. package/src/layout/index.js +1 -0
  70. package/src/layout/input/option-list.js +35 -43
  71. package/src/layout/input/search-box.js +192 -95
  72. package/src/layout/list/carousel.js +4 -2
  73. package/src/layout/list/collection.js +42 -43
  74. package/src/layout/templates.js +127 -46
  75. package/src/layout/text/typewriter/index.js +2 -2
  76. package/src/layout/trackable.js +106 -0
  77. package/src/source/index.js +14 -1
  78. package/src/util/bindings.js +47 -103
  79. package/src/util/states.js +26 -20
  80. package/src/util/trackers.js +69 -0
  81. package/src/util/viewables.js +47 -0
  82. package/src/version.js +1 -1
  83. package/src/workflow/ask.js +37 -3
  84. package/src/workflow/base.js +2 -3
  85. package/src/workflow/explore.js +1 -1
  86. package/src/workflow/options.js +54 -13
  87. package/src/workflow/recommendation.js +1 -0
  88. package/src/workflow/search.js +33 -1
  89. package/dist/cjs/util/tracker.js +0 -348
  90. package/src/util/tracker.js +0 -318
@@ -1,348 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _commons = require("@miso.ai/commons");
8
- var _constants = require("../constants.js");
9
- var _bindings = require("./bindings.js");
10
- var _states = _interopRequireDefault(require("./states.js"));
11
- var _proxy = _interopRequireDefault(require("./proxy.js"));
12
- const _excluded = ["impression", "viewable", "click"],
13
- _excluded2 = ["proxyElement", "element", "sessionId", "active", "bindings"];
14
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
16
- const {
17
- IMPRESSION,
18
- VIEWABLE,
19
- CLICK
20
- } = _constants.EVENT_TYPE;
21
- const {
22
- UNTRACKED,
23
- TRACKING,
24
- TRIGGERED
25
- } = _constants.TRACKING_STATUS;
26
- const DEFAULT_TRACKING_OPTIONS = Object.freeze({
27
- impression: Object.freeze({}),
28
- viewable: Object.freeze({
29
- area: 0.5,
30
- duration: 1000
31
- }),
32
- click: Object.freeze({
33
- lenient: false
34
- }),
35
- watch: false
36
- });
37
- function mergeOptions(def, opt) {
38
- // if opt is falsy then return false, merge otherwise
39
- return !!opt && Object.assign({}, def, opt);
40
- }
41
- function normalizeOptions(options) {
42
- if (options === false) {
43
- return false; // turn off all tracking
44
- }
45
- if (options === true) {
46
- options = {};
47
- }
48
- if (typeof options !== 'object') {
49
- throw new Error(`Invalid options: ${options}`);
50
- }
51
- const {
52
- impression = {},
53
- viewable = {},
54
- click = {}
55
- } = options,
56
- rest = _objectWithoutPropertiesLoose(options, _excluded);
57
- return (0, _commons.trimObj)(Object.assign({}, DEFAULT_TRACKING_OPTIONS, rest, {
58
- impression: mergeOptions(DEFAULT_TRACKING_OPTIONS.impression, impression),
59
- viewable: mergeOptions(DEFAULT_TRACKING_OPTIONS.viewable, viewable),
60
- click: mergeOptions(DEFAULT_TRACKING_OPTIONS.click, click)
61
- }));
62
- }
63
- class Tracker {
64
- constructor() {
65
- let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
66
- let {
67
- proxyElement,
68
- element,
69
- sessionId = 'default',
70
- active = true,
71
- bindings
72
- } = _ref,
73
- options = _objectWithoutPropertiesLoose(_ref, _excluded2);
74
- this._events = new _commons.EventEmitter({
75
- target: this
76
- });
77
- this._proxyElement = proxyElement || new _proxy.default(element);
78
- this._getSessionId = typeof sessionId === 'function' ? sessionId : () => sessionId;
79
- this._isActive = typeof active === 'function' ? active : () => active;
80
- this._bindings = new _bindings.Bindings(bindings);
81
- this._viewables = new WeakMap();
82
- this._options = normalizeOptions(options);
83
- this._unsubscribes = [this._proxyElement.on('click', event => this._handleClick(event)), this._proxyElement.on('element', () => this.refresh())];
84
- this.refresh();
85
- }
86
- get active() {
87
- return this._isActive();
88
- }
89
- config(options) {
90
- this._options = normalizeOptions(options);
91
- }
92
- refresh() {
93
- // refresh against root element
94
- this._syncElement();
95
- // refresh against view state
96
- this._syncStates();
97
- // refresh bindings
98
- this._refreshBindings();
99
- }
100
- _syncStates() {
101
- const sessionId = this._getSessionId();
102
- if (!sessionId) {
103
- return;
104
- }
105
- if (this._states && sessionId !== this._states.sessionId) {
106
- this._retireStates();
107
- }
108
- if (!this._states && sessionId) {
109
- this._states = new _states.default(sessionId);
110
- }
111
- }
112
- impression(values, options) {
113
- this._assertActive();
114
- if (this._options && this._options.impression) {
115
- this._trigger(IMPRESSION, values, Object.assign({
116
- manual: true
117
- }, options));
118
- }
119
- }
120
- viewable(values, options) {
121
- this._assertActive();
122
- if (this._options && this._options.viewable) {
123
- this._trigger(VIEWABLE, values, Object.assign({
124
- manual: true
125
- }, options));
126
- }
127
- }
128
- click(values, options) {
129
- this._assertActive();
130
- if (this._options && this._options.click) {
131
- this._trigger(CLICK, values, Object.assign({
132
- manual: true
133
- }, options));
134
- }
135
- }
136
- _assertActive() {
137
- if (!this._isActive()) {
138
- throw new Error(`Tracker is not active.`);
139
- }
140
- }
141
- getState(value) {
142
- // TODO: do we have to be so precise?
143
- return Object.freeze(Object.assign({
144
- [CLICK]: this._proxyElement.current ? TRACKING : UNTRACKED
145
- }, this._states.getFullState(value)));
146
- }
147
- _syncElement() {
148
- this._proxyElement.sync({
149
- silent: true
150
- });
151
- const element = this._proxyElement.current;
152
- if (this._element === element) {
153
- return;
154
- }
155
- // remove observer from old element
156
- this._retireElement();
157
-
158
- // add observer on new element
159
- if (element) {
160
- if (this._options && this._options.watch) {
161
- // TODO: move to proxy element
162
- this._mutationObserver = new MutationObserver(() => this.refresh());
163
- this._mutationObserver.observe(element, {
164
- childList: true,
165
- subtree: true
166
- });
167
- }
168
- }
169
- this._element = element;
170
- }
171
- _retireElement() {
172
- if (!this._element) {
173
- return;
174
- }
175
- if (this._mutationObserver) {
176
- this._mutationObserver.disconnect();
177
- this._mutationObserver = undefined;
178
- }
179
- this._element = undefined;
180
- }
181
- _retireStates() {
182
- const {
183
- unbounds
184
- } = this._bindings.unbindAll();
185
- this._untrackViewables(unbounds);
186
- this._states = undefined;
187
- }
188
- _refreshBindings() {
189
- if (!this._states) {
190
- return;
191
- }
192
- const element = this._proxyElement.current;
193
- const {
194
- bounds,
195
- unbounds
196
- } = this._bindings.refresh(element);
197
- this._untrackViewables(unbounds);
198
- this._trackImpressions(bounds);
199
- this._trackViewables(bounds);
200
- }
201
-
202
- // impression //
203
- _trackImpressions(bindings) {
204
- const options = this._options && this._options.impression;
205
- if (!options) {
206
- return;
207
- }
208
- this._trigger(IMPRESSION, bindings.map(b => b.value), {
209
- bindings
210
- });
211
- }
212
-
213
- // viewable //
214
- _trackViewables(bindings) {
215
- const options = this._options && this._options.viewable;
216
- if (!options) {
217
- return;
218
- }
219
- for (const binding of bindings) {
220
- this._trackViewableOnElement(binding);
221
- }
222
- }
223
- async _trackViewableOnElement(binding) {
224
- const {
225
- value,
226
- element
227
- } = binding;
228
- if (!value || !(0, _commons.isElement)(element) || this._viewables.has(element)) {
229
- return;
230
- }
231
- // TODO: when element is replaced without proper unload...
232
- const state = this._states.get(value, VIEWABLE);
233
- if (state !== UNTRACKED) {
234
- return;
235
- }
236
- this._states.set(value, VIEWABLE, TRACKING);
237
- const {
238
- area,
239
- duration
240
- } = this._options && this._options.viewable;
241
- // abort signal
242
- const ac = new AbortController();
243
- const {
244
- signal
245
- } = ac;
246
- this._viewables.set(element, {
247
- ac
248
- });
249
- await (0, _commons.viewable)(element, {
250
- area,
251
- duration,
252
- signal
253
- });
254
- this._viewables.delete(element);
255
- this._trigger(VIEWABLE, [value], {
256
- bindings: [binding]
257
- });
258
- }
259
- _untrackViewableOnElement(_ref2) {
260
- let {
261
- value,
262
- element
263
- } = _ref2;
264
- const viewable = this._viewables.get(element);
265
- if (!viewable) {
266
- return;
267
- }
268
- viewable.ac.abort();
269
- this._viewables.delete(element);
270
- const type = VIEWABLE;
271
- if (this._states.get(value, type) === TRACKING) {
272
- this._states.set(value, type, UNTRACKED);
273
- }
274
- }
275
- _untrackViewables(bindings) {
276
- for (const binding of bindings) {
277
- this._untrackViewableOnElement(binding);
278
- }
279
- }
280
-
281
- // click //
282
- _handleClick(event) {
283
- const options = this._options && this._options.click;
284
- if (!options || !this._isActive()) {
285
- return;
286
- }
287
- const binding = this._bindings.get(event.target);
288
- if (!binding) {
289
- return;
290
- }
291
-
292
- // TODO: refactor
293
- if (typeof options.validate === 'function') {
294
- if (!options.validate(event, binding)) {
295
- return;
296
- }
297
- } else if (!options.lenient) {
298
- // it must be a left click
299
- if (event.button !== 0) {
300
- return;
301
- }
302
- // event default must not be prevented
303
- if (event.defaultPrevented) {
304
- return;
305
- }
306
- // must go through a real link
307
- if (!(0, _commons.findInAncestors)(event.target, element => element.tagName === 'A' && element.href || undefined)) {
308
- return;
309
- }
310
- }
311
- this._trigger(CLICK, [binding.value], {
312
- bindings: [binding]
313
- });
314
- }
315
- _trigger(event, values) {
316
- let {
317
- manual = false,
318
- bindings
319
- } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
320
- (0, _constants.validateEventType)(event);
321
- if (!this._isActive()) {
322
- return;
323
- }
324
-
325
- // ignore already triggered
326
- values = this._states.untriggered((0, _commons.asArray)(values), event);
327
- if (values.length === 0) {
328
- return;
329
- }
330
- this._states.set(values, event, TRIGGERED);
331
- this._events.emit(event, {
332
- event,
333
- values,
334
- manual,
335
- bindings
336
- });
337
- }
338
- destroy() {
339
- this._retireElement();
340
- this._retireStates();
341
- this._bindings._destroy();
342
- for (const unsubscribe of this._unsubscribes) {
343
- unsubscribe();
344
- }
345
- this._unsubscribes = [];
346
- }
347
- }
348
- exports.default = Tracker;
@@ -1,318 +0,0 @@
1
- import { EventEmitter, isElement, findInAncestors, trimObj, asArray, viewable as whenViewable } from '@miso.ai/commons';
2
- import { EVENT_TYPE, TRACKING_STATUS, validateEventType } from '../constants.js';
3
- import { Bindings } from './bindings.js';
4
- import States from './states.js';
5
- import ProxyElement from './proxy.js';
6
-
7
- const { IMPRESSION, VIEWABLE, CLICK } = EVENT_TYPE;
8
- const { UNTRACKED, TRACKING, TRIGGERED } = TRACKING_STATUS;
9
-
10
- const DEFAULT_TRACKING_OPTIONS = Object.freeze({
11
- impression: Object.freeze({
12
- }),
13
- viewable: Object.freeze({
14
- area: 0.5,
15
- duration: 1000,
16
- }),
17
- click: Object.freeze({
18
- lenient: false,
19
- }),
20
- watch: false,
21
- });
22
-
23
- function mergeOptions(def, opt) {
24
- // if opt is falsy then return false, merge otherwise
25
- return !!opt && { ...def, ...opt };
26
- }
27
-
28
- function normalizeOptions(options) {
29
- if (options === false) {
30
- return false; // turn off all tracking
31
- }
32
- if (options === true) {
33
- options = {};
34
- }
35
- if (typeof options !== 'object') {
36
- throw new Error(`Invalid options: ${options}`);
37
- }
38
- const { impression = {}, viewable = {}, click = {}, ...rest } = options;
39
- return trimObj({
40
- ...DEFAULT_TRACKING_OPTIONS,
41
- ...rest,
42
- impression: mergeOptions(DEFAULT_TRACKING_OPTIONS.impression, impression),
43
- viewable: mergeOptions(DEFAULT_TRACKING_OPTIONS.viewable, viewable),
44
- click: mergeOptions(DEFAULT_TRACKING_OPTIONS.click, click),
45
- });
46
- }
47
-
48
- export default class Tracker {
49
-
50
- constructor({
51
- proxyElement,
52
- element,
53
- sessionId = 'default',
54
- active = true,
55
- bindings,
56
- ...options
57
- } = {}) {
58
- this._events = new EventEmitter({ target: this });
59
- this._proxyElement = proxyElement || new ProxyElement(element);
60
- this._getSessionId = typeof sessionId === 'function' ? sessionId : () => sessionId;
61
- this._isActive = typeof active === 'function' ? active : () => active;
62
- this._bindings = new Bindings(bindings);
63
- this._viewables = new WeakMap();
64
- this._options = normalizeOptions(options);
65
-
66
- this._unsubscribes = [
67
- this._proxyElement.on('click', event => this._handleClick(event)),
68
- this._proxyElement.on('element', () => this.refresh()),
69
- ];
70
-
71
- this.refresh();
72
- }
73
-
74
- get active() {
75
- return this._isActive();
76
- }
77
-
78
- config(options) {
79
- this._options = normalizeOptions(options);
80
- }
81
-
82
- refresh() {
83
- // refresh against root element
84
- this._syncElement();
85
- // refresh against view state
86
- this._syncStates();
87
- // refresh bindings
88
- this._refreshBindings();
89
- }
90
-
91
- _syncStates() {
92
- const sessionId = this._getSessionId();
93
- if (!sessionId) {
94
- return;
95
- }
96
- if (this._states && sessionId !== this._states.sessionId) {
97
- this._retireStates();
98
- }
99
- if (!this._states && sessionId) {
100
- this._states = new States(sessionId);
101
- }
102
- }
103
-
104
- impression(values, options) {
105
- this._assertActive();
106
- if (this._options && this._options.impression) {
107
- this._trigger(IMPRESSION, values, { manual: true, ...options });
108
- }
109
- }
110
-
111
- viewable(values, options) {
112
- this._assertActive();
113
- if (this._options && this._options.viewable) {
114
- this._trigger(VIEWABLE, values, { manual: true, ...options });
115
- }
116
- }
117
-
118
- click(values, options) {
119
- this._assertActive();
120
- if (this._options && this._options.click) {
121
- this._trigger(CLICK, values, { manual: true, ...options });
122
- }
123
- }
124
-
125
- _assertActive() {
126
- if (!this._isActive()) {
127
- throw new Error(`Tracker is not active.`);
128
- }
129
- }
130
-
131
- getState(value) {
132
- // TODO: do we have to be so precise?
133
- return Object.freeze({
134
- [CLICK]: this._proxyElement.current ? TRACKING : UNTRACKED,
135
- ...this._states.getFullState(value),
136
- });
137
- }
138
-
139
-
140
-
141
- _syncElement() {
142
- this._proxyElement.sync({ silent: true });
143
- const element = this._proxyElement.current;
144
- if (this._element === element) {
145
- return;
146
- }
147
- // remove observer from old element
148
- this._retireElement();
149
-
150
- // add observer on new element
151
- if (element) {
152
- if (this._options && this._options.watch) {
153
- // TODO: move to proxy element
154
- this._mutationObserver = new MutationObserver(() => this.refresh());
155
- this._mutationObserver.observe(element, { childList: true, subtree: true });
156
- }
157
- }
158
- this._element = element;
159
- }
160
-
161
- _retireElement() {
162
- if (!this._element) {
163
- return;
164
- }
165
- if (this._mutationObserver) {
166
- this._mutationObserver.disconnect();
167
- this._mutationObserver = undefined;
168
- }
169
- this._element = undefined;
170
- }
171
-
172
- _retireStates() {
173
- const { unbounds } = this._bindings.unbindAll();
174
- this._untrackViewables(unbounds);
175
- this._states = undefined;
176
- }
177
-
178
- _refreshBindings() {
179
- if (!this._states) {
180
- return;
181
- }
182
- const element = this._proxyElement.current;
183
- const { bounds, unbounds } = this._bindings.refresh(element);
184
- this._untrackViewables(unbounds);
185
- this._trackImpressions(bounds);
186
- this._trackViewables(bounds);
187
- }
188
-
189
-
190
-
191
- // impression //
192
- _trackImpressions(bindings) {
193
- const options = this._options && this._options.impression;
194
- if (!options) {
195
- return;
196
- }
197
- this._trigger(IMPRESSION, bindings.map(b => b.value), { bindings });
198
- }
199
-
200
-
201
-
202
- // viewable //
203
- _trackViewables(bindings) {
204
- const options = this._options && this._options.viewable;
205
- if (!options) {
206
- return;
207
- }
208
- for (const binding of bindings) {
209
- this._trackViewableOnElement(binding);
210
- }
211
- }
212
-
213
- async _trackViewableOnElement(binding) {
214
- const { value, element } = binding;
215
- if (!value || !isElement(element) || this._viewables.has(element)) {
216
- return;
217
- }
218
- // TODO: when element is replaced without proper unload...
219
- const state = this._states.get(value, VIEWABLE);
220
- if (state !== UNTRACKED) {
221
- return;
222
- }
223
- this._states.set(value, VIEWABLE, TRACKING);
224
-
225
- const { area, duration } = this._options && this._options.viewable;
226
- // abort signal
227
- const ac = new AbortController();
228
- const { signal } = ac;
229
- this._viewables.set(element, { ac });
230
- await whenViewable(element, { area, duration, signal });
231
- this._viewables.delete(element);
232
- this._trigger(VIEWABLE, [value], { bindings: [binding] });
233
- }
234
-
235
- _untrackViewableOnElement({ value, element }) {
236
- const viewable = this._viewables.get(element);
237
- if (!viewable) {
238
- return;
239
- }
240
- viewable.ac.abort();
241
- this._viewables.delete(element);
242
- const type = VIEWABLE;
243
- if (this._states.get(value, type) === TRACKING) {
244
- this._states.set(value, type, UNTRACKED);
245
- }
246
- }
247
-
248
- _untrackViewables(bindings) {
249
- for (const binding of bindings) {
250
- this._untrackViewableOnElement(binding);
251
- }
252
- }
253
-
254
-
255
-
256
- // click //
257
- _handleClick(event) {
258
- const options = this._options && this._options.click;
259
- if (!options || !this._isActive()) {
260
- return;
261
- }
262
- const binding = this._bindings.get(event.target);
263
- if (!binding) {
264
- return;
265
- }
266
-
267
- // TODO: refactor
268
- if (typeof options.validate === 'function') {
269
- if (!options.validate(event, binding)) {
270
- return;
271
- }
272
- } else if (!options.lenient) {
273
- // it must be a left click
274
- if (event.button !== 0) {
275
- return;
276
- }
277
- // event default must not be prevented
278
- if (event.defaultPrevented) {
279
- return;
280
- }
281
- // must go through a real link
282
- if (!findInAncestors(event.target, element => (element.tagName === 'A' && element.href) || undefined)) {
283
- return;
284
- }
285
- }
286
- this._trigger(CLICK, [binding.value], { bindings: [binding] });
287
- }
288
-
289
-
290
-
291
- _trigger(event, values, { manual = false, bindings } = {}) {
292
- validateEventType(event);
293
-
294
- if (!this._isActive()) {
295
- return;
296
- }
297
-
298
- // ignore already triggered
299
- values = this._states.untriggered(asArray(values), event);
300
-
301
- if (values.length === 0) {
302
- return;
303
- }
304
- this._states.set(values, event, TRIGGERED);
305
- this._events.emit(event, { event, values, manual, bindings });
306
- }
307
-
308
- destroy() {
309
- this._retireElement();
310
- this._retireStates();
311
- this._bindings._destroy();
312
- for (const unsubscribe of this._unsubscribes) {
313
- unsubscribe();
314
- }
315
- this._unsubscribes = [];
316
- }
317
-
318
- }