stimulus-library 0.6.3 → 0.6.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.
- package/CHANGELOG.md +19 -0
- package/dist/controllers/ajax/lazy_block_controller.d.ts.map +1 -1
- package/dist/controllers/anchor_spy_controller.d.ts +6 -12
- package/dist/controllers/anchor_spy_controller.d.ts.map +1 -1
- package/dist/controllers/confirm_navigation_controller.d.ts +0 -1
- package/dist/controllers/confirm_navigation_controller.d.ts.map +1 -1
- package/dist/controllers/disable_with_controller.d.ts +0 -1
- package/dist/controllers/disable_with_controller.d.ts.map +1 -1
- package/dist/controllers/element_save_controller.d.ts.map +1 -1
- package/dist/controllers/empty_dom_controller.d.ts +4 -12
- package/dist/controllers/empty_dom_controller.d.ts.map +1 -1
- package/dist/controllers/forms/autosize_controller.d.ts +1 -2
- package/dist/controllers/forms/autosize_controller.d.ts.map +1 -1
- package/dist/controllers/forms/char_count_controller.d.ts +2 -6
- package/dist/controllers/forms/char_count_controller.d.ts.map +1 -1
- package/dist/controllers/forms/detect_dirty_controller.d.ts.map +1 -1
- package/dist/controllers/forms/detect_dirty_form_controller.d.ts.map +1 -1
- package/dist/controllers/forms/navigate_form_errors_controller.d.ts +3 -6
- package/dist/controllers/forms/navigate_form_errors_controller.d.ts.map +1 -1
- package/dist/controllers/forms/password_confirm_controller.d.ts +2 -6
- package/dist/controllers/forms/password_confirm_controller.d.ts.map +1 -1
- package/dist/controllers/forms/sync_inputs_controller.d.ts +0 -2
- package/dist/controllers/forms/sync_inputs_controller.d.ts.map +1 -1
- package/dist/controllers/forms/value_warn_controller.d.ts +5 -12
- package/dist/controllers/forms/value_warn_controller.d.ts.map +1 -1
- package/dist/controllers/forms/word_count_controller.d.ts +2 -6
- package/dist/controllers/forms/word_count_controller.d.ts.map +1 -1
- package/dist/controllers/media/fallback_image_controller.d.ts +4 -12
- package/dist/controllers/media/fallback_image_controller.d.ts.map +1 -1
- package/dist/controllers/media/media_player_controller.d.ts +0 -3
- package/dist/controllers/media/media_player_controller.d.ts.map +1 -1
- package/dist/controllers/print_button_controller.d.ts +2 -6
- package/dist/controllers/print_button_controller.d.ts.map +1 -1
- package/dist/controllers/responsive_iframe_controller.d.ts +0 -5
- package/dist/controllers/responsive_iframe_controller.d.ts.map +1 -1
- package/dist/controllers/signal/events.d.ts +4 -0
- package/dist/controllers/signal/events.d.ts.map +1 -0
- package/dist/controllers/signal/expressions.d.ts +2 -0
- package/dist/controllers/signal/expressions.d.ts.map +1 -0
- package/dist/controllers/signal/index.d.ts +1 -0
- package/dist/controllers/signal/index.d.ts.map +1 -1
- package/dist/controllers/signal/signal_action_controller.d.ts +15 -0
- package/dist/controllers/signal/signal_action_controller.d.ts.map +1 -0
- package/dist/controllers/signal/signal_input_controller.d.ts +4 -1
- package/dist/controllers/signal/signal_input_controller.d.ts.map +1 -1
- package/dist/controllers/signal/signal_visibility_controller.d.ts +3 -9
- package/dist/controllers/signal/signal_visibility_controller.d.ts.map +1 -1
- package/dist/controllers/sticky_controller.d.ts +3 -6
- package/dist/controllers/sticky_controller.d.ts.map +1 -1
- package/dist/controllers/tables/table_sort_controller.d.ts.map +1 -1
- package/dist/controllers/tables/table_truncate_controller.d.ts +0 -1
- package/dist/controllers/tables/table_truncate_controller.d.ts.map +1 -1
- package/dist/controllers/temporary_state_controller.d.ts +0 -1
- package/dist/controllers/temporary_state_controller.d.ts.map +1 -1
- package/dist/controllers/toggle_class_controller.d.ts.map +1 -1
- package/dist/controllers/trix_modifier_controller.d.ts +5 -5
- package/dist/controllers/trix_modifier_controller.d.ts.map +1 -1
- package/dist/controllers/utility/intersection_controller.d.ts.map +1 -1
- package/dist/controllers/visual/countdown_controller.d.ts +4 -12
- package/dist/controllers/visual/countdown_controller.d.ts.map +1 -1
- package/dist/controllers/visual/tabs_controller.d.ts +6 -12
- package/dist/controllers/visual/tabs_controller.d.ts.map +1 -1
- package/dist/controllers/visual/time_distance_controller.d.ts +0 -1
- package/dist/controllers/visual/time_distance_controller.d.ts.map +1 -1
- package/dist/controllers/visual/tree_view_controller.d.ts +8 -12
- package/dist/controllers/visual/tree_view_controller.d.ts.map +1 -1
- package/dist/mixins/create_mixin.d.ts +3 -0
- package/dist/mixins/create_mixin.d.ts.map +1 -0
- package/dist/mixins/index.d.ts +4 -2
- package/dist/mixins/index.d.ts.map +1 -1
- package/dist/mixins/install_class_methods.d.ts +6 -0
- package/dist/mixins/install_class_methods.d.ts.map +1 -0
- package/dist/mixins/use_click_outside.d.ts +5 -0
- package/dist/mixins/use_click_outside.d.ts.map +1 -0
- package/dist/mixins/use_event_bus.d.ts +8 -0
- package/dist/mixins/use_event_bus.d.ts.map +1 -0
- package/dist/mixins/use_event_listener.d.ts +4 -4
- package/dist/mixins/use_event_listener.d.ts.map +1 -1
- package/dist/mixins/use_fullscreen.d.ts +1 -0
- package/dist/mixins/use_fullscreen.d.ts.map +1 -1
- package/dist/mixins/use_geolocation.d.ts +19 -0
- package/dist/mixins/use_geolocation.d.ts.map +1 -0
- package/dist/mixins/use_hover.d.ts +5 -0
- package/dist/mixins/use_hover.d.ts.map +1 -0
- package/dist/mixins/use_injected_html.d.ts +2 -2
- package/dist/mixins/use_injected_html.d.ts.map +1 -1
- package/dist/mixins/use_intersection.d.ts +14 -0
- package/dist/mixins/use_intersection.d.ts.map +1 -0
- package/dist/mixins/use_interval.d.ts.map +1 -1
- package/dist/mixins/use_localstorage.d.ts +15 -0
- package/dist/mixins/use_localstorage.d.ts.map +1 -0
- package/dist/mixins/use_mutation_observer.d.ts +3 -0
- package/dist/mixins/use_mutation_observer.d.ts.map +1 -0
- package/dist/mixins/use_timeout.d.ts.map +1 -1
- package/dist/mixins/{installsTrixBehaviour.d.ts → use_trix_modifiers.d.ts} +2 -2
- package/dist/mixins/use_trix_modifiers.d.ts.map +1 -0
- package/dist/stimulus-library.cjs.js +1 -5
- package/dist/stimulus-library.cjs.js.map +1 -1
- package/dist/stimulus-library.es.js +650 -3389
- package/dist/stimulus-library.es.js.map +1 -1
- package/dist/stimulus-library.umd.js +1 -5
- package/dist/stimulus-library.umd.js.map +1 -1
- package/dist/utilities/arrays.d.ts +2 -0
- package/dist/utilities/arrays.d.ts.map +1 -0
- package/dist/utilities/elements.d.ts +3 -0
- package/dist/utilities/elements.d.ts.map +1 -1
- package/dist/utilities/reactive.d.ts +2 -0
- package/dist/utilities/reactive.d.ts.map +1 -0
- package/dist/utilities/stimulus.d.ts.map +1 -1
- package/dist/utilities/strings.d.ts +2 -0
- package/dist/utilities/strings.d.ts.map +1 -0
- package/package.json +5 -6
- package/dist/mixins/installsTrixBehaviour.d.ts.map +0 -1
|
@@ -14,2263 +14,13 @@ var __spreadValues = (a, b) => {
|
|
|
14
14
|
}
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
21
|
-
target[prop] = source[prop];
|
|
22
|
-
if (source != null && __getOwnPropSymbols)
|
|
23
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
24
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
25
|
-
target[prop] = source[prop];
|
|
26
|
-
}
|
|
27
|
-
return target;
|
|
28
|
-
};
|
|
29
|
-
var __publicField = (obj, key, value) => {
|
|
30
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
31
|
-
return value;
|
|
32
|
-
};
|
|
33
|
-
import { debounce as debounce$1, clamp, get, set, camelCase as camelCase$2 } from "lodash-es";
|
|
34
|
-
import { isPast, intervalToDuration, formatDuration, toDate, formatDistanceToNow } from "date-fns";
|
|
35
|
-
var EventListener = function() {
|
|
36
|
-
function EventListener2(eventTarget, eventName, eventOptions) {
|
|
37
|
-
this.eventTarget = eventTarget;
|
|
38
|
-
this.eventName = eventName;
|
|
39
|
-
this.eventOptions = eventOptions;
|
|
40
|
-
this.unorderedBindings = new Set();
|
|
41
|
-
}
|
|
42
|
-
EventListener2.prototype.connect = function() {
|
|
43
|
-
this.eventTarget.addEventListener(this.eventName, this, this.eventOptions);
|
|
44
|
-
};
|
|
45
|
-
EventListener2.prototype.disconnect = function() {
|
|
46
|
-
this.eventTarget.removeEventListener(this.eventName, this, this.eventOptions);
|
|
47
|
-
};
|
|
48
|
-
EventListener2.prototype.bindingConnected = function(binding) {
|
|
49
|
-
this.unorderedBindings.add(binding);
|
|
50
|
-
};
|
|
51
|
-
EventListener2.prototype.bindingDisconnected = function(binding) {
|
|
52
|
-
this.unorderedBindings.delete(binding);
|
|
53
|
-
};
|
|
54
|
-
EventListener2.prototype.handleEvent = function(event) {
|
|
55
|
-
var extendedEvent2 = extendEvent(event);
|
|
56
|
-
for (var _i = 0, _a = this.bindings; _i < _a.length; _i++) {
|
|
57
|
-
var binding = _a[_i];
|
|
58
|
-
if (extendedEvent2.immediatePropagationStopped) {
|
|
59
|
-
break;
|
|
60
|
-
} else {
|
|
61
|
-
binding.handleEvent(extendedEvent2);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
Object.defineProperty(EventListener2.prototype, "bindings", {
|
|
66
|
-
get: function() {
|
|
67
|
-
return Array.from(this.unorderedBindings).sort(function(left, right) {
|
|
68
|
-
var leftIndex = left.index, rightIndex = right.index;
|
|
69
|
-
return leftIndex < rightIndex ? -1 : leftIndex > rightIndex ? 1 : 0;
|
|
70
|
-
});
|
|
71
|
-
},
|
|
72
|
-
enumerable: false,
|
|
73
|
-
configurable: true
|
|
74
|
-
});
|
|
75
|
-
return EventListener2;
|
|
76
|
-
}();
|
|
77
|
-
function extendEvent(event) {
|
|
78
|
-
if ("immediatePropagationStopped" in event) {
|
|
79
|
-
return event;
|
|
80
|
-
} else {
|
|
81
|
-
var stopImmediatePropagation_1 = event.stopImmediatePropagation;
|
|
82
|
-
return Object.assign(event, {
|
|
83
|
-
immediatePropagationStopped: false,
|
|
84
|
-
stopImmediatePropagation: function() {
|
|
85
|
-
this.immediatePropagationStopped = true;
|
|
86
|
-
stopImmediatePropagation_1.call(this);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
var Dispatcher = function() {
|
|
92
|
-
function Dispatcher2(application) {
|
|
93
|
-
this.application = application;
|
|
94
|
-
this.eventListenerMaps = new Map();
|
|
95
|
-
this.started = false;
|
|
96
|
-
}
|
|
97
|
-
Dispatcher2.prototype.start = function() {
|
|
98
|
-
if (!this.started) {
|
|
99
|
-
this.started = true;
|
|
100
|
-
this.eventListeners.forEach(function(eventListener) {
|
|
101
|
-
return eventListener.connect();
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
Dispatcher2.prototype.stop = function() {
|
|
106
|
-
if (this.started) {
|
|
107
|
-
this.started = false;
|
|
108
|
-
this.eventListeners.forEach(function(eventListener) {
|
|
109
|
-
return eventListener.disconnect();
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
Object.defineProperty(Dispatcher2.prototype, "eventListeners", {
|
|
114
|
-
get: function() {
|
|
115
|
-
return Array.from(this.eventListenerMaps.values()).reduce(function(listeners, map) {
|
|
116
|
-
return listeners.concat(Array.from(map.values()));
|
|
117
|
-
}, []);
|
|
118
|
-
},
|
|
119
|
-
enumerable: false,
|
|
120
|
-
configurable: true
|
|
121
|
-
});
|
|
122
|
-
Dispatcher2.prototype.bindingConnected = function(binding) {
|
|
123
|
-
this.fetchEventListenerForBinding(binding).bindingConnected(binding);
|
|
124
|
-
};
|
|
125
|
-
Dispatcher2.prototype.bindingDisconnected = function(binding) {
|
|
126
|
-
this.fetchEventListenerForBinding(binding).bindingDisconnected(binding);
|
|
127
|
-
};
|
|
128
|
-
Dispatcher2.prototype.handleError = function(error2, message, detail) {
|
|
129
|
-
if (detail === void 0) {
|
|
130
|
-
detail = {};
|
|
131
|
-
}
|
|
132
|
-
this.application.handleError(error2, "Error " + message, detail);
|
|
133
|
-
};
|
|
134
|
-
Dispatcher2.prototype.fetchEventListenerForBinding = function(binding) {
|
|
135
|
-
var eventTarget = binding.eventTarget, eventName = binding.eventName, eventOptions = binding.eventOptions;
|
|
136
|
-
return this.fetchEventListener(eventTarget, eventName, eventOptions);
|
|
137
|
-
};
|
|
138
|
-
Dispatcher2.prototype.fetchEventListener = function(eventTarget, eventName, eventOptions) {
|
|
139
|
-
var eventListenerMap = this.fetchEventListenerMapForEventTarget(eventTarget);
|
|
140
|
-
var cacheKey = this.cacheKey(eventName, eventOptions);
|
|
141
|
-
var eventListener = eventListenerMap.get(cacheKey);
|
|
142
|
-
if (!eventListener) {
|
|
143
|
-
eventListener = this.createEventListener(eventTarget, eventName, eventOptions);
|
|
144
|
-
eventListenerMap.set(cacheKey, eventListener);
|
|
145
|
-
}
|
|
146
|
-
return eventListener;
|
|
147
|
-
};
|
|
148
|
-
Dispatcher2.prototype.createEventListener = function(eventTarget, eventName, eventOptions) {
|
|
149
|
-
var eventListener = new EventListener(eventTarget, eventName, eventOptions);
|
|
150
|
-
if (this.started) {
|
|
151
|
-
eventListener.connect();
|
|
152
|
-
}
|
|
153
|
-
return eventListener;
|
|
154
|
-
};
|
|
155
|
-
Dispatcher2.prototype.fetchEventListenerMapForEventTarget = function(eventTarget) {
|
|
156
|
-
var eventListenerMap = this.eventListenerMaps.get(eventTarget);
|
|
157
|
-
if (!eventListenerMap) {
|
|
158
|
-
eventListenerMap = new Map();
|
|
159
|
-
this.eventListenerMaps.set(eventTarget, eventListenerMap);
|
|
160
|
-
}
|
|
161
|
-
return eventListenerMap;
|
|
162
|
-
};
|
|
163
|
-
Dispatcher2.prototype.cacheKey = function(eventName, eventOptions) {
|
|
164
|
-
var parts = [eventName];
|
|
165
|
-
Object.keys(eventOptions).sort().forEach(function(key) {
|
|
166
|
-
parts.push("" + (eventOptions[key] ? "" : "!") + key);
|
|
167
|
-
});
|
|
168
|
-
return parts.join(":");
|
|
169
|
-
};
|
|
170
|
-
return Dispatcher2;
|
|
171
|
-
}();
|
|
172
|
-
var descriptorPattern = /^((.+?)(@(window|document))?->)?(.+?)(#([^:]+?))(:(.+))?$/;
|
|
173
|
-
function parseActionDescriptorString(descriptorString) {
|
|
174
|
-
var source = descriptorString.trim();
|
|
175
|
-
var matches = source.match(descriptorPattern) || [];
|
|
176
|
-
return {
|
|
177
|
-
eventTarget: parseEventTarget(matches[4]),
|
|
178
|
-
eventName: matches[2],
|
|
179
|
-
eventOptions: matches[9] ? parseEventOptions(matches[9]) : {},
|
|
180
|
-
identifier: matches[5],
|
|
181
|
-
methodName: matches[7]
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
function parseEventTarget(eventTargetName) {
|
|
185
|
-
if (eventTargetName == "window") {
|
|
186
|
-
return window;
|
|
187
|
-
} else if (eventTargetName == "document") {
|
|
188
|
-
return document;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
function parseEventOptions(eventOptions) {
|
|
192
|
-
return eventOptions.split(":").reduce(function(options, token) {
|
|
193
|
-
var _a;
|
|
194
|
-
return Object.assign(options, (_a = {}, _a[token.replace(/^!/, "")] = !/^!/.test(token), _a));
|
|
195
|
-
}, {});
|
|
196
|
-
}
|
|
197
|
-
function stringifyEventTarget(eventTarget) {
|
|
198
|
-
if (eventTarget == window) {
|
|
199
|
-
return "window";
|
|
200
|
-
} else if (eventTarget == document) {
|
|
201
|
-
return "document";
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
var Action = function() {
|
|
205
|
-
function Action2(element, index, descriptor) {
|
|
206
|
-
this.element = element;
|
|
207
|
-
this.index = index;
|
|
208
|
-
this.eventTarget = descriptor.eventTarget || element;
|
|
209
|
-
this.eventName = descriptor.eventName || getDefaultEventNameForElement(element) || error("missing event name");
|
|
210
|
-
this.eventOptions = descriptor.eventOptions || {};
|
|
211
|
-
this.identifier = descriptor.identifier || error("missing identifier");
|
|
212
|
-
this.methodName = descriptor.methodName || error("missing method name");
|
|
213
|
-
}
|
|
214
|
-
Action2.forToken = function(token) {
|
|
215
|
-
return new this(token.element, token.index, parseActionDescriptorString(token.content));
|
|
216
|
-
};
|
|
217
|
-
Action2.prototype.toString = function() {
|
|
218
|
-
var eventNameSuffix = this.eventTargetName ? "@" + this.eventTargetName : "";
|
|
219
|
-
return "" + this.eventName + eventNameSuffix + "->" + this.identifier + "#" + this.methodName;
|
|
220
|
-
};
|
|
221
|
-
Object.defineProperty(Action2.prototype, "eventTargetName", {
|
|
222
|
-
get: function() {
|
|
223
|
-
return stringifyEventTarget(this.eventTarget);
|
|
224
|
-
},
|
|
225
|
-
enumerable: false,
|
|
226
|
-
configurable: true
|
|
227
|
-
});
|
|
228
|
-
return Action2;
|
|
229
|
-
}();
|
|
230
|
-
var defaultEventNames = {
|
|
231
|
-
"a": function(e) {
|
|
232
|
-
return "click";
|
|
233
|
-
},
|
|
234
|
-
"button": function(e) {
|
|
235
|
-
return "click";
|
|
236
|
-
},
|
|
237
|
-
"form": function(e) {
|
|
238
|
-
return "submit";
|
|
239
|
-
},
|
|
240
|
-
"input": function(e) {
|
|
241
|
-
return e.getAttribute("type") == "submit" ? "click" : "input";
|
|
242
|
-
},
|
|
243
|
-
"select": function(e) {
|
|
244
|
-
return "change";
|
|
245
|
-
},
|
|
246
|
-
"textarea": function(e) {
|
|
247
|
-
return "input";
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
function getDefaultEventNameForElement(element) {
|
|
251
|
-
var tagName = element.tagName.toLowerCase();
|
|
252
|
-
if (tagName in defaultEventNames) {
|
|
253
|
-
return defaultEventNames[tagName](element);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
function error(message) {
|
|
257
|
-
throw new Error(message);
|
|
258
|
-
}
|
|
259
|
-
var Binding = function() {
|
|
260
|
-
function Binding2(context, action) {
|
|
261
|
-
this.context = context;
|
|
262
|
-
this.action = action;
|
|
263
|
-
}
|
|
264
|
-
Object.defineProperty(Binding2.prototype, "index", {
|
|
265
|
-
get: function() {
|
|
266
|
-
return this.action.index;
|
|
267
|
-
},
|
|
268
|
-
enumerable: false,
|
|
269
|
-
configurable: true
|
|
270
|
-
});
|
|
271
|
-
Object.defineProperty(Binding2.prototype, "eventTarget", {
|
|
272
|
-
get: function() {
|
|
273
|
-
return this.action.eventTarget;
|
|
274
|
-
},
|
|
275
|
-
enumerable: false,
|
|
276
|
-
configurable: true
|
|
277
|
-
});
|
|
278
|
-
Object.defineProperty(Binding2.prototype, "eventOptions", {
|
|
279
|
-
get: function() {
|
|
280
|
-
return this.action.eventOptions;
|
|
281
|
-
},
|
|
282
|
-
enumerable: false,
|
|
283
|
-
configurable: true
|
|
284
|
-
});
|
|
285
|
-
Object.defineProperty(Binding2.prototype, "identifier", {
|
|
286
|
-
get: function() {
|
|
287
|
-
return this.context.identifier;
|
|
288
|
-
},
|
|
289
|
-
enumerable: false,
|
|
290
|
-
configurable: true
|
|
291
|
-
});
|
|
292
|
-
Binding2.prototype.handleEvent = function(event) {
|
|
293
|
-
if (this.willBeInvokedByEvent(event)) {
|
|
294
|
-
this.invokeWithEvent(event);
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
Object.defineProperty(Binding2.prototype, "eventName", {
|
|
298
|
-
get: function() {
|
|
299
|
-
return this.action.eventName;
|
|
300
|
-
},
|
|
301
|
-
enumerable: false,
|
|
302
|
-
configurable: true
|
|
303
|
-
});
|
|
304
|
-
Object.defineProperty(Binding2.prototype, "method", {
|
|
305
|
-
get: function() {
|
|
306
|
-
var method2 = this.controller[this.methodName];
|
|
307
|
-
if (typeof method2 == "function") {
|
|
308
|
-
return method2;
|
|
309
|
-
}
|
|
310
|
-
throw new Error('Action "' + this.action + '" references undefined method "' + this.methodName + '"');
|
|
311
|
-
},
|
|
312
|
-
enumerable: false,
|
|
313
|
-
configurable: true
|
|
314
|
-
});
|
|
315
|
-
Binding2.prototype.invokeWithEvent = function(event) {
|
|
316
|
-
try {
|
|
317
|
-
this.method.call(this.controller, event);
|
|
318
|
-
} catch (error2) {
|
|
319
|
-
var _a = this, identifier = _a.identifier, controller = _a.controller, element = _a.element, index = _a.index;
|
|
320
|
-
var detail = { identifier, controller, element, index, event };
|
|
321
|
-
this.context.handleError(error2, 'invoking action "' + this.action + '"', detail);
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
Binding2.prototype.willBeInvokedByEvent = function(event) {
|
|
325
|
-
var eventTarget = event.target;
|
|
326
|
-
if (this.element === eventTarget) {
|
|
327
|
-
return true;
|
|
328
|
-
} else if (eventTarget instanceof Element && this.element.contains(eventTarget)) {
|
|
329
|
-
return this.scope.containsElement(eventTarget);
|
|
330
|
-
} else {
|
|
331
|
-
return this.scope.containsElement(this.action.element);
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
Object.defineProperty(Binding2.prototype, "controller", {
|
|
335
|
-
get: function() {
|
|
336
|
-
return this.context.controller;
|
|
337
|
-
},
|
|
338
|
-
enumerable: false,
|
|
339
|
-
configurable: true
|
|
340
|
-
});
|
|
341
|
-
Object.defineProperty(Binding2.prototype, "methodName", {
|
|
342
|
-
get: function() {
|
|
343
|
-
return this.action.methodName;
|
|
344
|
-
},
|
|
345
|
-
enumerable: false,
|
|
346
|
-
configurable: true
|
|
347
|
-
});
|
|
348
|
-
Object.defineProperty(Binding2.prototype, "element", {
|
|
349
|
-
get: function() {
|
|
350
|
-
return this.scope.element;
|
|
351
|
-
},
|
|
352
|
-
enumerable: false,
|
|
353
|
-
configurable: true
|
|
354
|
-
});
|
|
355
|
-
Object.defineProperty(Binding2.prototype, "scope", {
|
|
356
|
-
get: function() {
|
|
357
|
-
return this.context.scope;
|
|
358
|
-
},
|
|
359
|
-
enumerable: false,
|
|
360
|
-
configurable: true
|
|
361
|
-
});
|
|
362
|
-
return Binding2;
|
|
363
|
-
}();
|
|
364
|
-
var ElementObserver = function() {
|
|
365
|
-
function ElementObserver2(element, delegate) {
|
|
366
|
-
var _this = this;
|
|
367
|
-
this.element = element;
|
|
368
|
-
this.started = false;
|
|
369
|
-
this.delegate = delegate;
|
|
370
|
-
this.elements = new Set();
|
|
371
|
-
this.mutationObserver = new MutationObserver(function(mutations) {
|
|
372
|
-
return _this.processMutations(mutations);
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
ElementObserver2.prototype.start = function() {
|
|
376
|
-
if (!this.started) {
|
|
377
|
-
this.started = true;
|
|
378
|
-
this.mutationObserver.observe(this.element, { attributes: true, childList: true, subtree: true });
|
|
379
|
-
this.refresh();
|
|
380
|
-
}
|
|
381
|
-
};
|
|
382
|
-
ElementObserver2.prototype.stop = function() {
|
|
383
|
-
if (this.started) {
|
|
384
|
-
this.mutationObserver.takeRecords();
|
|
385
|
-
this.mutationObserver.disconnect();
|
|
386
|
-
this.started = false;
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
ElementObserver2.prototype.refresh = function() {
|
|
390
|
-
if (this.started) {
|
|
391
|
-
var matches = new Set(this.matchElementsInTree());
|
|
392
|
-
for (var _i = 0, _a = Array.from(this.elements); _i < _a.length; _i++) {
|
|
393
|
-
var element = _a[_i];
|
|
394
|
-
if (!matches.has(element)) {
|
|
395
|
-
this.removeElement(element);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
for (var _b = 0, _c = Array.from(matches); _b < _c.length; _b++) {
|
|
399
|
-
var element = _c[_b];
|
|
400
|
-
this.addElement(element);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
ElementObserver2.prototype.processMutations = function(mutations) {
|
|
405
|
-
if (this.started) {
|
|
406
|
-
for (var _i = 0, mutations_1 = mutations; _i < mutations_1.length; _i++) {
|
|
407
|
-
var mutation = mutations_1[_i];
|
|
408
|
-
this.processMutation(mutation);
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
};
|
|
412
|
-
ElementObserver2.prototype.processMutation = function(mutation) {
|
|
413
|
-
if (mutation.type == "attributes") {
|
|
414
|
-
this.processAttributeChange(mutation.target, mutation.attributeName);
|
|
415
|
-
} else if (mutation.type == "childList") {
|
|
416
|
-
this.processRemovedNodes(mutation.removedNodes);
|
|
417
|
-
this.processAddedNodes(mutation.addedNodes);
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
ElementObserver2.prototype.processAttributeChange = function(node, attributeName) {
|
|
421
|
-
var element = node;
|
|
422
|
-
if (this.elements.has(element)) {
|
|
423
|
-
if (this.delegate.elementAttributeChanged && this.matchElement(element)) {
|
|
424
|
-
this.delegate.elementAttributeChanged(element, attributeName);
|
|
425
|
-
} else {
|
|
426
|
-
this.removeElement(element);
|
|
427
|
-
}
|
|
428
|
-
} else if (this.matchElement(element)) {
|
|
429
|
-
this.addElement(element);
|
|
430
|
-
}
|
|
431
|
-
};
|
|
432
|
-
ElementObserver2.prototype.processRemovedNodes = function(nodes) {
|
|
433
|
-
for (var _i = 0, _a = Array.from(nodes); _i < _a.length; _i++) {
|
|
434
|
-
var node = _a[_i];
|
|
435
|
-
var element = this.elementFromNode(node);
|
|
436
|
-
if (element) {
|
|
437
|
-
this.processTree(element, this.removeElement);
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
|
-
ElementObserver2.prototype.processAddedNodes = function(nodes) {
|
|
442
|
-
for (var _i = 0, _a = Array.from(nodes); _i < _a.length; _i++) {
|
|
443
|
-
var node = _a[_i];
|
|
444
|
-
var element = this.elementFromNode(node);
|
|
445
|
-
if (element && this.elementIsActive(element)) {
|
|
446
|
-
this.processTree(element, this.addElement);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
};
|
|
450
|
-
ElementObserver2.prototype.matchElement = function(element) {
|
|
451
|
-
return this.delegate.matchElement(element);
|
|
452
|
-
};
|
|
453
|
-
ElementObserver2.prototype.matchElementsInTree = function(tree) {
|
|
454
|
-
if (tree === void 0) {
|
|
455
|
-
tree = this.element;
|
|
456
|
-
}
|
|
457
|
-
return this.delegate.matchElementsInTree(tree);
|
|
458
|
-
};
|
|
459
|
-
ElementObserver2.prototype.processTree = function(tree, processor) {
|
|
460
|
-
for (var _i = 0, _a = this.matchElementsInTree(tree); _i < _a.length; _i++) {
|
|
461
|
-
var element = _a[_i];
|
|
462
|
-
processor.call(this, element);
|
|
463
|
-
}
|
|
464
|
-
};
|
|
465
|
-
ElementObserver2.prototype.elementFromNode = function(node) {
|
|
466
|
-
if (node.nodeType == Node.ELEMENT_NODE) {
|
|
467
|
-
return node;
|
|
468
|
-
}
|
|
469
|
-
};
|
|
470
|
-
ElementObserver2.prototype.elementIsActive = function(element) {
|
|
471
|
-
if (element.isConnected != this.element.isConnected) {
|
|
472
|
-
return false;
|
|
473
|
-
} else {
|
|
474
|
-
return this.element.contains(element);
|
|
475
|
-
}
|
|
476
|
-
};
|
|
477
|
-
ElementObserver2.prototype.addElement = function(element) {
|
|
478
|
-
if (!this.elements.has(element)) {
|
|
479
|
-
if (this.elementIsActive(element)) {
|
|
480
|
-
this.elements.add(element);
|
|
481
|
-
if (this.delegate.elementMatched) {
|
|
482
|
-
this.delegate.elementMatched(element);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
};
|
|
487
|
-
ElementObserver2.prototype.removeElement = function(element) {
|
|
488
|
-
if (this.elements.has(element)) {
|
|
489
|
-
this.elements.delete(element);
|
|
490
|
-
if (this.delegate.elementUnmatched) {
|
|
491
|
-
this.delegate.elementUnmatched(element);
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
};
|
|
495
|
-
return ElementObserver2;
|
|
496
|
-
}();
|
|
497
|
-
var AttributeObserver = function() {
|
|
498
|
-
function AttributeObserver2(element, attributeName, delegate) {
|
|
499
|
-
this.attributeName = attributeName;
|
|
500
|
-
this.delegate = delegate;
|
|
501
|
-
this.elementObserver = new ElementObserver(element, this);
|
|
502
|
-
}
|
|
503
|
-
Object.defineProperty(AttributeObserver2.prototype, "element", {
|
|
504
|
-
get: function() {
|
|
505
|
-
return this.elementObserver.element;
|
|
506
|
-
},
|
|
507
|
-
enumerable: false,
|
|
508
|
-
configurable: true
|
|
509
|
-
});
|
|
510
|
-
Object.defineProperty(AttributeObserver2.prototype, "selector", {
|
|
511
|
-
get: function() {
|
|
512
|
-
return "[" + this.attributeName + "]";
|
|
513
|
-
},
|
|
514
|
-
enumerable: false,
|
|
515
|
-
configurable: true
|
|
516
|
-
});
|
|
517
|
-
AttributeObserver2.prototype.start = function() {
|
|
518
|
-
this.elementObserver.start();
|
|
519
|
-
};
|
|
520
|
-
AttributeObserver2.prototype.stop = function() {
|
|
521
|
-
this.elementObserver.stop();
|
|
522
|
-
};
|
|
523
|
-
AttributeObserver2.prototype.refresh = function() {
|
|
524
|
-
this.elementObserver.refresh();
|
|
525
|
-
};
|
|
526
|
-
Object.defineProperty(AttributeObserver2.prototype, "started", {
|
|
527
|
-
get: function() {
|
|
528
|
-
return this.elementObserver.started;
|
|
529
|
-
},
|
|
530
|
-
enumerable: false,
|
|
531
|
-
configurable: true
|
|
532
|
-
});
|
|
533
|
-
AttributeObserver2.prototype.matchElement = function(element) {
|
|
534
|
-
return element.hasAttribute(this.attributeName);
|
|
535
|
-
};
|
|
536
|
-
AttributeObserver2.prototype.matchElementsInTree = function(tree) {
|
|
537
|
-
var match = this.matchElement(tree) ? [tree] : [];
|
|
538
|
-
var matches = Array.from(tree.querySelectorAll(this.selector));
|
|
539
|
-
return match.concat(matches);
|
|
540
|
-
};
|
|
541
|
-
AttributeObserver2.prototype.elementMatched = function(element) {
|
|
542
|
-
if (this.delegate.elementMatchedAttribute) {
|
|
543
|
-
this.delegate.elementMatchedAttribute(element, this.attributeName);
|
|
544
|
-
}
|
|
545
|
-
};
|
|
546
|
-
AttributeObserver2.prototype.elementUnmatched = function(element) {
|
|
547
|
-
if (this.delegate.elementUnmatchedAttribute) {
|
|
548
|
-
this.delegate.elementUnmatchedAttribute(element, this.attributeName);
|
|
549
|
-
}
|
|
550
|
-
};
|
|
551
|
-
AttributeObserver2.prototype.elementAttributeChanged = function(element, attributeName) {
|
|
552
|
-
if (this.delegate.elementAttributeValueChanged && this.attributeName == attributeName) {
|
|
553
|
-
this.delegate.elementAttributeValueChanged(element, attributeName);
|
|
554
|
-
}
|
|
555
|
-
};
|
|
556
|
-
return AttributeObserver2;
|
|
557
|
-
}();
|
|
558
|
-
var StringMapObserver = function() {
|
|
559
|
-
function StringMapObserver2(element, delegate) {
|
|
560
|
-
var _this = this;
|
|
561
|
-
this.element = element;
|
|
562
|
-
this.delegate = delegate;
|
|
563
|
-
this.started = false;
|
|
564
|
-
this.stringMap = new Map();
|
|
565
|
-
this.mutationObserver = new MutationObserver(function(mutations) {
|
|
566
|
-
return _this.processMutations(mutations);
|
|
567
|
-
});
|
|
568
|
-
}
|
|
569
|
-
StringMapObserver2.prototype.start = function() {
|
|
570
|
-
if (!this.started) {
|
|
571
|
-
this.started = true;
|
|
572
|
-
this.mutationObserver.observe(this.element, { attributes: true });
|
|
573
|
-
this.refresh();
|
|
574
|
-
}
|
|
575
|
-
};
|
|
576
|
-
StringMapObserver2.prototype.stop = function() {
|
|
577
|
-
if (this.started) {
|
|
578
|
-
this.mutationObserver.takeRecords();
|
|
579
|
-
this.mutationObserver.disconnect();
|
|
580
|
-
this.started = false;
|
|
581
|
-
}
|
|
582
|
-
};
|
|
583
|
-
StringMapObserver2.prototype.refresh = function() {
|
|
584
|
-
if (this.started) {
|
|
585
|
-
for (var _i = 0, _a = this.knownAttributeNames; _i < _a.length; _i++) {
|
|
586
|
-
var attributeName = _a[_i];
|
|
587
|
-
this.refreshAttribute(attributeName);
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
};
|
|
591
|
-
StringMapObserver2.prototype.processMutations = function(mutations) {
|
|
592
|
-
if (this.started) {
|
|
593
|
-
for (var _i = 0, mutations_1 = mutations; _i < mutations_1.length; _i++) {
|
|
594
|
-
var mutation = mutations_1[_i];
|
|
595
|
-
this.processMutation(mutation);
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
};
|
|
599
|
-
StringMapObserver2.prototype.processMutation = function(mutation) {
|
|
600
|
-
var attributeName = mutation.attributeName;
|
|
601
|
-
if (attributeName) {
|
|
602
|
-
this.refreshAttribute(attributeName);
|
|
603
|
-
}
|
|
604
|
-
};
|
|
605
|
-
StringMapObserver2.prototype.refreshAttribute = function(attributeName) {
|
|
606
|
-
var key = this.delegate.getStringMapKeyForAttribute(attributeName);
|
|
607
|
-
if (key != null) {
|
|
608
|
-
if (!this.stringMap.has(attributeName)) {
|
|
609
|
-
this.stringMapKeyAdded(key, attributeName);
|
|
610
|
-
}
|
|
611
|
-
var value = this.element.getAttribute(attributeName);
|
|
612
|
-
if (this.stringMap.get(attributeName) != value) {
|
|
613
|
-
this.stringMapValueChanged(value, key);
|
|
614
|
-
}
|
|
615
|
-
if (value == null) {
|
|
616
|
-
this.stringMap.delete(attributeName);
|
|
617
|
-
this.stringMapKeyRemoved(key, attributeName);
|
|
618
|
-
} else {
|
|
619
|
-
this.stringMap.set(attributeName, value);
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
};
|
|
623
|
-
StringMapObserver2.prototype.stringMapKeyAdded = function(key, attributeName) {
|
|
624
|
-
if (this.delegate.stringMapKeyAdded) {
|
|
625
|
-
this.delegate.stringMapKeyAdded(key, attributeName);
|
|
626
|
-
}
|
|
627
|
-
};
|
|
628
|
-
StringMapObserver2.prototype.stringMapValueChanged = function(value, key) {
|
|
629
|
-
if (this.delegate.stringMapValueChanged) {
|
|
630
|
-
this.delegate.stringMapValueChanged(value, key);
|
|
631
|
-
}
|
|
632
|
-
};
|
|
633
|
-
StringMapObserver2.prototype.stringMapKeyRemoved = function(key, attributeName) {
|
|
634
|
-
if (this.delegate.stringMapKeyRemoved) {
|
|
635
|
-
this.delegate.stringMapKeyRemoved(key, attributeName);
|
|
636
|
-
}
|
|
637
|
-
};
|
|
638
|
-
Object.defineProperty(StringMapObserver2.prototype, "knownAttributeNames", {
|
|
639
|
-
get: function() {
|
|
640
|
-
return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)));
|
|
641
|
-
},
|
|
642
|
-
enumerable: false,
|
|
643
|
-
configurable: true
|
|
644
|
-
});
|
|
645
|
-
Object.defineProperty(StringMapObserver2.prototype, "currentAttributeNames", {
|
|
646
|
-
get: function() {
|
|
647
|
-
return Array.from(this.element.attributes).map(function(attribute) {
|
|
648
|
-
return attribute.name;
|
|
649
|
-
});
|
|
650
|
-
},
|
|
651
|
-
enumerable: false,
|
|
652
|
-
configurable: true
|
|
653
|
-
});
|
|
654
|
-
Object.defineProperty(StringMapObserver2.prototype, "recordedAttributeNames", {
|
|
655
|
-
get: function() {
|
|
656
|
-
return Array.from(this.stringMap.keys());
|
|
657
|
-
},
|
|
658
|
-
enumerable: false,
|
|
659
|
-
configurable: true
|
|
660
|
-
});
|
|
661
|
-
return StringMapObserver2;
|
|
662
|
-
}();
|
|
663
|
-
function add(map, key, value) {
|
|
664
|
-
fetch$1(map, key).add(value);
|
|
665
|
-
}
|
|
666
|
-
function del(map, key, value) {
|
|
667
|
-
fetch$1(map, key).delete(value);
|
|
668
|
-
prune(map, key);
|
|
669
|
-
}
|
|
670
|
-
function fetch$1(map, key) {
|
|
671
|
-
var values = map.get(key);
|
|
672
|
-
if (!values) {
|
|
673
|
-
values = new Set();
|
|
674
|
-
map.set(key, values);
|
|
675
|
-
}
|
|
676
|
-
return values;
|
|
677
|
-
}
|
|
678
|
-
function prune(map, key) {
|
|
679
|
-
var values = map.get(key);
|
|
680
|
-
if (values != null && values.size == 0) {
|
|
681
|
-
map.delete(key);
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
var Multimap = function() {
|
|
685
|
-
function Multimap2() {
|
|
686
|
-
this.valuesByKey = new Map();
|
|
687
|
-
}
|
|
688
|
-
Object.defineProperty(Multimap2.prototype, "values", {
|
|
689
|
-
get: function() {
|
|
690
|
-
var sets = Array.from(this.valuesByKey.values());
|
|
691
|
-
return sets.reduce(function(values, set2) {
|
|
692
|
-
return values.concat(Array.from(set2));
|
|
693
|
-
}, []);
|
|
694
|
-
},
|
|
695
|
-
enumerable: false,
|
|
696
|
-
configurable: true
|
|
697
|
-
});
|
|
698
|
-
Object.defineProperty(Multimap2.prototype, "size", {
|
|
699
|
-
get: function() {
|
|
700
|
-
var sets = Array.from(this.valuesByKey.values());
|
|
701
|
-
return sets.reduce(function(size, set2) {
|
|
702
|
-
return size + set2.size;
|
|
703
|
-
}, 0);
|
|
704
|
-
},
|
|
705
|
-
enumerable: false,
|
|
706
|
-
configurable: true
|
|
707
|
-
});
|
|
708
|
-
Multimap2.prototype.add = function(key, value) {
|
|
709
|
-
add(this.valuesByKey, key, value);
|
|
710
|
-
};
|
|
711
|
-
Multimap2.prototype.delete = function(key, value) {
|
|
712
|
-
del(this.valuesByKey, key, value);
|
|
713
|
-
};
|
|
714
|
-
Multimap2.prototype.has = function(key, value) {
|
|
715
|
-
var values = this.valuesByKey.get(key);
|
|
716
|
-
return values != null && values.has(value);
|
|
717
|
-
};
|
|
718
|
-
Multimap2.prototype.hasKey = function(key) {
|
|
719
|
-
return this.valuesByKey.has(key);
|
|
720
|
-
};
|
|
721
|
-
Multimap2.prototype.hasValue = function(value) {
|
|
722
|
-
var sets = Array.from(this.valuesByKey.values());
|
|
723
|
-
return sets.some(function(set2) {
|
|
724
|
-
return set2.has(value);
|
|
725
|
-
});
|
|
726
|
-
};
|
|
727
|
-
Multimap2.prototype.getValuesForKey = function(key) {
|
|
728
|
-
var values = this.valuesByKey.get(key);
|
|
729
|
-
return values ? Array.from(values) : [];
|
|
730
|
-
};
|
|
731
|
-
Multimap2.prototype.getKeysForValue = function(value) {
|
|
732
|
-
return Array.from(this.valuesByKey).filter(function(_a) {
|
|
733
|
-
_a[0];
|
|
734
|
-
var values = _a[1];
|
|
735
|
-
return values.has(value);
|
|
736
|
-
}).map(function(_a) {
|
|
737
|
-
var key = _a[0];
|
|
738
|
-
_a[1];
|
|
739
|
-
return key;
|
|
740
|
-
});
|
|
741
|
-
};
|
|
742
|
-
return Multimap2;
|
|
743
|
-
}();
|
|
744
|
-
var __extends$1 = globalThis && globalThis.__extends || function() {
|
|
745
|
-
var extendStatics = function(d, b) {
|
|
746
|
-
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
747
|
-
d2.__proto__ = b2;
|
|
748
|
-
} || function(d2, b2) {
|
|
749
|
-
for (var p in b2)
|
|
750
|
-
if (b2.hasOwnProperty(p))
|
|
751
|
-
d2[p] = b2[p];
|
|
752
|
-
};
|
|
753
|
-
return extendStatics(d, b);
|
|
754
|
-
};
|
|
755
|
-
return function(d, b) {
|
|
756
|
-
extendStatics(d, b);
|
|
757
|
-
function __() {
|
|
758
|
-
this.constructor = d;
|
|
759
|
-
}
|
|
760
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
761
|
-
};
|
|
762
|
-
}();
|
|
763
|
-
(function(_super) {
|
|
764
|
-
__extends$1(IndexedMultimap, _super);
|
|
765
|
-
function IndexedMultimap() {
|
|
766
|
-
var _this = _super.call(this) || this;
|
|
767
|
-
_this.keysByValue = new Map();
|
|
768
|
-
return _this;
|
|
769
|
-
}
|
|
770
|
-
Object.defineProperty(IndexedMultimap.prototype, "values", {
|
|
771
|
-
get: function() {
|
|
772
|
-
return Array.from(this.keysByValue.keys());
|
|
773
|
-
},
|
|
774
|
-
enumerable: false,
|
|
775
|
-
configurable: true
|
|
776
|
-
});
|
|
777
|
-
IndexedMultimap.prototype.add = function(key, value) {
|
|
778
|
-
_super.prototype.add.call(this, key, value);
|
|
779
|
-
add(this.keysByValue, value, key);
|
|
780
|
-
};
|
|
781
|
-
IndexedMultimap.prototype.delete = function(key, value) {
|
|
782
|
-
_super.prototype.delete.call(this, key, value);
|
|
783
|
-
del(this.keysByValue, value, key);
|
|
784
|
-
};
|
|
785
|
-
IndexedMultimap.prototype.hasValue = function(value) {
|
|
786
|
-
return this.keysByValue.has(value);
|
|
787
|
-
};
|
|
788
|
-
IndexedMultimap.prototype.getKeysForValue = function(value) {
|
|
789
|
-
var set2 = this.keysByValue.get(value);
|
|
790
|
-
return set2 ? Array.from(set2) : [];
|
|
791
|
-
};
|
|
792
|
-
return IndexedMultimap;
|
|
793
|
-
})(Multimap);
|
|
794
|
-
var TokenListObserver = function() {
|
|
795
|
-
function TokenListObserver2(element, attributeName, delegate) {
|
|
796
|
-
this.attributeObserver = new AttributeObserver(element, attributeName, this);
|
|
797
|
-
this.delegate = delegate;
|
|
798
|
-
this.tokensByElement = new Multimap();
|
|
799
|
-
}
|
|
800
|
-
Object.defineProperty(TokenListObserver2.prototype, "started", {
|
|
801
|
-
get: function() {
|
|
802
|
-
return this.attributeObserver.started;
|
|
803
|
-
},
|
|
804
|
-
enumerable: false,
|
|
805
|
-
configurable: true
|
|
806
|
-
});
|
|
807
|
-
TokenListObserver2.prototype.start = function() {
|
|
808
|
-
this.attributeObserver.start();
|
|
809
|
-
};
|
|
810
|
-
TokenListObserver2.prototype.stop = function() {
|
|
811
|
-
this.attributeObserver.stop();
|
|
812
|
-
};
|
|
813
|
-
TokenListObserver2.prototype.refresh = function() {
|
|
814
|
-
this.attributeObserver.refresh();
|
|
815
|
-
};
|
|
816
|
-
Object.defineProperty(TokenListObserver2.prototype, "element", {
|
|
817
|
-
get: function() {
|
|
818
|
-
return this.attributeObserver.element;
|
|
819
|
-
},
|
|
820
|
-
enumerable: false,
|
|
821
|
-
configurable: true
|
|
822
|
-
});
|
|
823
|
-
Object.defineProperty(TokenListObserver2.prototype, "attributeName", {
|
|
824
|
-
get: function() {
|
|
825
|
-
return this.attributeObserver.attributeName;
|
|
826
|
-
},
|
|
827
|
-
enumerable: false,
|
|
828
|
-
configurable: true
|
|
829
|
-
});
|
|
830
|
-
TokenListObserver2.prototype.elementMatchedAttribute = function(element) {
|
|
831
|
-
this.tokensMatched(this.readTokensForElement(element));
|
|
832
|
-
};
|
|
833
|
-
TokenListObserver2.prototype.elementAttributeValueChanged = function(element) {
|
|
834
|
-
var _a = this.refreshTokensForElement(element), unmatchedTokens = _a[0], matchedTokens = _a[1];
|
|
835
|
-
this.tokensUnmatched(unmatchedTokens);
|
|
836
|
-
this.tokensMatched(matchedTokens);
|
|
837
|
-
};
|
|
838
|
-
TokenListObserver2.prototype.elementUnmatchedAttribute = function(element) {
|
|
839
|
-
this.tokensUnmatched(this.tokensByElement.getValuesForKey(element));
|
|
840
|
-
};
|
|
841
|
-
TokenListObserver2.prototype.tokensMatched = function(tokens) {
|
|
842
|
-
var _this = this;
|
|
843
|
-
tokens.forEach(function(token) {
|
|
844
|
-
return _this.tokenMatched(token);
|
|
845
|
-
});
|
|
846
|
-
};
|
|
847
|
-
TokenListObserver2.prototype.tokensUnmatched = function(tokens) {
|
|
848
|
-
var _this = this;
|
|
849
|
-
tokens.forEach(function(token) {
|
|
850
|
-
return _this.tokenUnmatched(token);
|
|
851
|
-
});
|
|
852
|
-
};
|
|
853
|
-
TokenListObserver2.prototype.tokenMatched = function(token) {
|
|
854
|
-
this.delegate.tokenMatched(token);
|
|
855
|
-
this.tokensByElement.add(token.element, token);
|
|
856
|
-
};
|
|
857
|
-
TokenListObserver2.prototype.tokenUnmatched = function(token) {
|
|
858
|
-
this.delegate.tokenUnmatched(token);
|
|
859
|
-
this.tokensByElement.delete(token.element, token);
|
|
860
|
-
};
|
|
861
|
-
TokenListObserver2.prototype.refreshTokensForElement = function(element) {
|
|
862
|
-
var previousTokens = this.tokensByElement.getValuesForKey(element);
|
|
863
|
-
var currentTokens = this.readTokensForElement(element);
|
|
864
|
-
var firstDifferingIndex = zip(previousTokens, currentTokens).findIndex(function(_a) {
|
|
865
|
-
var previousToken = _a[0], currentToken = _a[1];
|
|
866
|
-
return !tokensAreEqual(previousToken, currentToken);
|
|
867
|
-
});
|
|
868
|
-
if (firstDifferingIndex == -1) {
|
|
869
|
-
return [[], []];
|
|
870
|
-
} else {
|
|
871
|
-
return [previousTokens.slice(firstDifferingIndex), currentTokens.slice(firstDifferingIndex)];
|
|
872
|
-
}
|
|
873
|
-
};
|
|
874
|
-
TokenListObserver2.prototype.readTokensForElement = function(element) {
|
|
875
|
-
var attributeName = this.attributeName;
|
|
876
|
-
var tokenString = element.getAttribute(attributeName) || "";
|
|
877
|
-
return parseTokenString(tokenString, element, attributeName);
|
|
878
|
-
};
|
|
879
|
-
return TokenListObserver2;
|
|
880
|
-
}();
|
|
881
|
-
function parseTokenString(tokenString, element, attributeName) {
|
|
882
|
-
return tokenString.trim().split(/\s+/).filter(function(content) {
|
|
883
|
-
return content.length;
|
|
884
|
-
}).map(function(content, index) {
|
|
885
|
-
return { element, attributeName, content, index };
|
|
886
|
-
});
|
|
887
|
-
}
|
|
888
|
-
function zip(left, right) {
|
|
889
|
-
var length = Math.max(left.length, right.length);
|
|
890
|
-
return Array.from({ length }, function(_, index) {
|
|
891
|
-
return [left[index], right[index]];
|
|
892
|
-
});
|
|
893
|
-
}
|
|
894
|
-
function tokensAreEqual(left, right) {
|
|
895
|
-
return left && right && left.index == right.index && left.content == right.content;
|
|
896
|
-
}
|
|
897
|
-
var ValueListObserver = function() {
|
|
898
|
-
function ValueListObserver2(element, attributeName, delegate) {
|
|
899
|
-
this.tokenListObserver = new TokenListObserver(element, attributeName, this);
|
|
900
|
-
this.delegate = delegate;
|
|
901
|
-
this.parseResultsByToken = new WeakMap();
|
|
902
|
-
this.valuesByTokenByElement = new WeakMap();
|
|
903
|
-
}
|
|
904
|
-
Object.defineProperty(ValueListObserver2.prototype, "started", {
|
|
905
|
-
get: function() {
|
|
906
|
-
return this.tokenListObserver.started;
|
|
907
|
-
},
|
|
908
|
-
enumerable: false,
|
|
909
|
-
configurable: true
|
|
910
|
-
});
|
|
911
|
-
ValueListObserver2.prototype.start = function() {
|
|
912
|
-
this.tokenListObserver.start();
|
|
913
|
-
};
|
|
914
|
-
ValueListObserver2.prototype.stop = function() {
|
|
915
|
-
this.tokenListObserver.stop();
|
|
916
|
-
};
|
|
917
|
-
ValueListObserver2.prototype.refresh = function() {
|
|
918
|
-
this.tokenListObserver.refresh();
|
|
919
|
-
};
|
|
920
|
-
Object.defineProperty(ValueListObserver2.prototype, "element", {
|
|
921
|
-
get: function() {
|
|
922
|
-
return this.tokenListObserver.element;
|
|
923
|
-
},
|
|
924
|
-
enumerable: false,
|
|
925
|
-
configurable: true
|
|
926
|
-
});
|
|
927
|
-
Object.defineProperty(ValueListObserver2.prototype, "attributeName", {
|
|
928
|
-
get: function() {
|
|
929
|
-
return this.tokenListObserver.attributeName;
|
|
930
|
-
},
|
|
931
|
-
enumerable: false,
|
|
932
|
-
configurable: true
|
|
933
|
-
});
|
|
934
|
-
ValueListObserver2.prototype.tokenMatched = function(token) {
|
|
935
|
-
var element = token.element;
|
|
936
|
-
var value = this.fetchParseResultForToken(token).value;
|
|
937
|
-
if (value) {
|
|
938
|
-
this.fetchValuesByTokenForElement(element).set(token, value);
|
|
939
|
-
this.delegate.elementMatchedValue(element, value);
|
|
940
|
-
}
|
|
941
|
-
};
|
|
942
|
-
ValueListObserver2.prototype.tokenUnmatched = function(token) {
|
|
943
|
-
var element = token.element;
|
|
944
|
-
var value = this.fetchParseResultForToken(token).value;
|
|
945
|
-
if (value) {
|
|
946
|
-
this.fetchValuesByTokenForElement(element).delete(token);
|
|
947
|
-
this.delegate.elementUnmatchedValue(element, value);
|
|
948
|
-
}
|
|
949
|
-
};
|
|
950
|
-
ValueListObserver2.prototype.fetchParseResultForToken = function(token) {
|
|
951
|
-
var parseResult = this.parseResultsByToken.get(token);
|
|
952
|
-
if (!parseResult) {
|
|
953
|
-
parseResult = this.parseToken(token);
|
|
954
|
-
this.parseResultsByToken.set(token, parseResult);
|
|
955
|
-
}
|
|
956
|
-
return parseResult;
|
|
957
|
-
};
|
|
958
|
-
ValueListObserver2.prototype.fetchValuesByTokenForElement = function(element) {
|
|
959
|
-
var valuesByToken = this.valuesByTokenByElement.get(element);
|
|
960
|
-
if (!valuesByToken) {
|
|
961
|
-
valuesByToken = new Map();
|
|
962
|
-
this.valuesByTokenByElement.set(element, valuesByToken);
|
|
963
|
-
}
|
|
964
|
-
return valuesByToken;
|
|
965
|
-
};
|
|
966
|
-
ValueListObserver2.prototype.parseToken = function(token) {
|
|
967
|
-
try {
|
|
968
|
-
var value = this.delegate.parseValueForToken(token);
|
|
969
|
-
return { value };
|
|
970
|
-
} catch (error2) {
|
|
971
|
-
return { error: error2 };
|
|
972
|
-
}
|
|
973
|
-
};
|
|
974
|
-
return ValueListObserver2;
|
|
975
|
-
}();
|
|
976
|
-
var BindingObserver = function() {
|
|
977
|
-
function BindingObserver2(context, delegate) {
|
|
978
|
-
this.context = context;
|
|
979
|
-
this.delegate = delegate;
|
|
980
|
-
this.bindingsByAction = new Map();
|
|
981
|
-
}
|
|
982
|
-
BindingObserver2.prototype.start = function() {
|
|
983
|
-
if (!this.valueListObserver) {
|
|
984
|
-
this.valueListObserver = new ValueListObserver(this.element, this.actionAttribute, this);
|
|
985
|
-
this.valueListObserver.start();
|
|
986
|
-
}
|
|
987
|
-
};
|
|
988
|
-
BindingObserver2.prototype.stop = function() {
|
|
989
|
-
if (this.valueListObserver) {
|
|
990
|
-
this.valueListObserver.stop();
|
|
991
|
-
delete this.valueListObserver;
|
|
992
|
-
this.disconnectAllActions();
|
|
993
|
-
}
|
|
994
|
-
};
|
|
995
|
-
Object.defineProperty(BindingObserver2.prototype, "element", {
|
|
996
|
-
get: function() {
|
|
997
|
-
return this.context.element;
|
|
998
|
-
},
|
|
999
|
-
enumerable: false,
|
|
1000
|
-
configurable: true
|
|
1001
|
-
});
|
|
1002
|
-
Object.defineProperty(BindingObserver2.prototype, "identifier", {
|
|
1003
|
-
get: function() {
|
|
1004
|
-
return this.context.identifier;
|
|
1005
|
-
},
|
|
1006
|
-
enumerable: false,
|
|
1007
|
-
configurable: true
|
|
1008
|
-
});
|
|
1009
|
-
Object.defineProperty(BindingObserver2.prototype, "actionAttribute", {
|
|
1010
|
-
get: function() {
|
|
1011
|
-
return this.schema.actionAttribute;
|
|
1012
|
-
},
|
|
1013
|
-
enumerable: false,
|
|
1014
|
-
configurable: true
|
|
1015
|
-
});
|
|
1016
|
-
Object.defineProperty(BindingObserver2.prototype, "schema", {
|
|
1017
|
-
get: function() {
|
|
1018
|
-
return this.context.schema;
|
|
1019
|
-
},
|
|
1020
|
-
enumerable: false,
|
|
1021
|
-
configurable: true
|
|
1022
|
-
});
|
|
1023
|
-
Object.defineProperty(BindingObserver2.prototype, "bindings", {
|
|
1024
|
-
get: function() {
|
|
1025
|
-
return Array.from(this.bindingsByAction.values());
|
|
1026
|
-
},
|
|
1027
|
-
enumerable: false,
|
|
1028
|
-
configurable: true
|
|
1029
|
-
});
|
|
1030
|
-
BindingObserver2.prototype.connectAction = function(action) {
|
|
1031
|
-
var binding = new Binding(this.context, action);
|
|
1032
|
-
this.bindingsByAction.set(action, binding);
|
|
1033
|
-
this.delegate.bindingConnected(binding);
|
|
1034
|
-
};
|
|
1035
|
-
BindingObserver2.prototype.disconnectAction = function(action) {
|
|
1036
|
-
var binding = this.bindingsByAction.get(action);
|
|
1037
|
-
if (binding) {
|
|
1038
|
-
this.bindingsByAction.delete(action);
|
|
1039
|
-
this.delegate.bindingDisconnected(binding);
|
|
1040
|
-
}
|
|
1041
|
-
};
|
|
1042
|
-
BindingObserver2.prototype.disconnectAllActions = function() {
|
|
1043
|
-
var _this = this;
|
|
1044
|
-
this.bindings.forEach(function(binding) {
|
|
1045
|
-
return _this.delegate.bindingDisconnected(binding);
|
|
1046
|
-
});
|
|
1047
|
-
this.bindingsByAction.clear();
|
|
1048
|
-
};
|
|
1049
|
-
BindingObserver2.prototype.parseValueForToken = function(token) {
|
|
1050
|
-
var action = Action.forToken(token);
|
|
1051
|
-
if (action.identifier == this.identifier) {
|
|
1052
|
-
return action;
|
|
1053
|
-
}
|
|
1054
|
-
};
|
|
1055
|
-
BindingObserver2.prototype.elementMatchedValue = function(element, action) {
|
|
1056
|
-
this.connectAction(action);
|
|
1057
|
-
};
|
|
1058
|
-
BindingObserver2.prototype.elementUnmatchedValue = function(element, action) {
|
|
1059
|
-
this.disconnectAction(action);
|
|
1060
|
-
};
|
|
1061
|
-
return BindingObserver2;
|
|
1062
|
-
}();
|
|
1063
|
-
var ValueObserver = function() {
|
|
1064
|
-
function ValueObserver2(context, receiver) {
|
|
1065
|
-
this.context = context;
|
|
1066
|
-
this.receiver = receiver;
|
|
1067
|
-
this.stringMapObserver = new StringMapObserver(this.element, this);
|
|
1068
|
-
this.valueDescriptorMap = this.controller.valueDescriptorMap;
|
|
1069
|
-
this.invokeChangedCallbacksForDefaultValues();
|
|
1070
|
-
}
|
|
1071
|
-
ValueObserver2.prototype.start = function() {
|
|
1072
|
-
this.stringMapObserver.start();
|
|
1073
|
-
};
|
|
1074
|
-
ValueObserver2.prototype.stop = function() {
|
|
1075
|
-
this.stringMapObserver.stop();
|
|
1076
|
-
};
|
|
1077
|
-
Object.defineProperty(ValueObserver2.prototype, "element", {
|
|
1078
|
-
get: function() {
|
|
1079
|
-
return this.context.element;
|
|
1080
|
-
},
|
|
1081
|
-
enumerable: false,
|
|
1082
|
-
configurable: true
|
|
1083
|
-
});
|
|
1084
|
-
Object.defineProperty(ValueObserver2.prototype, "controller", {
|
|
1085
|
-
get: function() {
|
|
1086
|
-
return this.context.controller;
|
|
1087
|
-
},
|
|
1088
|
-
enumerable: false,
|
|
1089
|
-
configurable: true
|
|
1090
|
-
});
|
|
1091
|
-
ValueObserver2.prototype.getStringMapKeyForAttribute = function(attributeName) {
|
|
1092
|
-
if (attributeName in this.valueDescriptorMap) {
|
|
1093
|
-
return this.valueDescriptorMap[attributeName].name;
|
|
1094
|
-
}
|
|
1095
|
-
};
|
|
1096
|
-
ValueObserver2.prototype.stringMapValueChanged = function(attributeValue, name) {
|
|
1097
|
-
this.invokeChangedCallbackForValue(name);
|
|
1098
|
-
};
|
|
1099
|
-
ValueObserver2.prototype.invokeChangedCallbacksForDefaultValues = function() {
|
|
1100
|
-
for (var _i = 0, _a = this.valueDescriptors; _i < _a.length; _i++) {
|
|
1101
|
-
var _b = _a[_i], key = _b.key, name_1 = _b.name, defaultValue = _b.defaultValue;
|
|
1102
|
-
if (defaultValue != void 0 && !this.controller.data.has(key)) {
|
|
1103
|
-
this.invokeChangedCallbackForValue(name_1);
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
};
|
|
1107
|
-
ValueObserver2.prototype.invokeChangedCallbackForValue = function(name) {
|
|
1108
|
-
var methodName = name + "Changed";
|
|
1109
|
-
var method2 = this.receiver[methodName];
|
|
1110
|
-
if (typeof method2 == "function") {
|
|
1111
|
-
var value = this.receiver[name];
|
|
1112
|
-
method2.call(this.receiver, value);
|
|
1113
|
-
}
|
|
1114
|
-
};
|
|
1115
|
-
Object.defineProperty(ValueObserver2.prototype, "valueDescriptors", {
|
|
1116
|
-
get: function() {
|
|
1117
|
-
var valueDescriptorMap = this.valueDescriptorMap;
|
|
1118
|
-
return Object.keys(valueDescriptorMap).map(function(key) {
|
|
1119
|
-
return valueDescriptorMap[key];
|
|
1120
|
-
});
|
|
1121
|
-
},
|
|
1122
|
-
enumerable: false,
|
|
1123
|
-
configurable: true
|
|
1124
|
-
});
|
|
1125
|
-
return ValueObserver2;
|
|
1126
|
-
}();
|
|
1127
|
-
var Context = function() {
|
|
1128
|
-
function Context2(module, scope) {
|
|
1129
|
-
this.module = module;
|
|
1130
|
-
this.scope = scope;
|
|
1131
|
-
this.controller = new module.controllerConstructor(this);
|
|
1132
|
-
this.bindingObserver = new BindingObserver(this, this.dispatcher);
|
|
1133
|
-
this.valueObserver = new ValueObserver(this, this.controller);
|
|
1134
|
-
try {
|
|
1135
|
-
this.controller.initialize();
|
|
1136
|
-
} catch (error2) {
|
|
1137
|
-
this.handleError(error2, "initializing controller");
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
Context2.prototype.connect = function() {
|
|
1141
|
-
this.bindingObserver.start();
|
|
1142
|
-
this.valueObserver.start();
|
|
1143
|
-
try {
|
|
1144
|
-
this.controller.connect();
|
|
1145
|
-
} catch (error2) {
|
|
1146
|
-
this.handleError(error2, "connecting controller");
|
|
1147
|
-
}
|
|
1148
|
-
};
|
|
1149
|
-
Context2.prototype.disconnect = function() {
|
|
1150
|
-
try {
|
|
1151
|
-
this.controller.disconnect();
|
|
1152
|
-
} catch (error2) {
|
|
1153
|
-
this.handleError(error2, "disconnecting controller");
|
|
1154
|
-
}
|
|
1155
|
-
this.valueObserver.stop();
|
|
1156
|
-
this.bindingObserver.stop();
|
|
1157
|
-
};
|
|
1158
|
-
Object.defineProperty(Context2.prototype, "application", {
|
|
1159
|
-
get: function() {
|
|
1160
|
-
return this.module.application;
|
|
1161
|
-
},
|
|
1162
|
-
enumerable: false,
|
|
1163
|
-
configurable: true
|
|
1164
|
-
});
|
|
1165
|
-
Object.defineProperty(Context2.prototype, "identifier", {
|
|
1166
|
-
get: function() {
|
|
1167
|
-
return this.module.identifier;
|
|
1168
|
-
},
|
|
1169
|
-
enumerable: false,
|
|
1170
|
-
configurable: true
|
|
1171
|
-
});
|
|
1172
|
-
Object.defineProperty(Context2.prototype, "schema", {
|
|
1173
|
-
get: function() {
|
|
1174
|
-
return this.application.schema;
|
|
1175
|
-
},
|
|
1176
|
-
enumerable: false,
|
|
1177
|
-
configurable: true
|
|
1178
|
-
});
|
|
1179
|
-
Object.defineProperty(Context2.prototype, "dispatcher", {
|
|
1180
|
-
get: function() {
|
|
1181
|
-
return this.application.dispatcher;
|
|
1182
|
-
},
|
|
1183
|
-
enumerable: false,
|
|
1184
|
-
configurable: true
|
|
1185
|
-
});
|
|
1186
|
-
Object.defineProperty(Context2.prototype, "element", {
|
|
1187
|
-
get: function() {
|
|
1188
|
-
return this.scope.element;
|
|
1189
|
-
},
|
|
1190
|
-
enumerable: false,
|
|
1191
|
-
configurable: true
|
|
1192
|
-
});
|
|
1193
|
-
Object.defineProperty(Context2.prototype, "parentElement", {
|
|
1194
|
-
get: function() {
|
|
1195
|
-
return this.element.parentElement;
|
|
1196
|
-
},
|
|
1197
|
-
enumerable: false,
|
|
1198
|
-
configurable: true
|
|
1199
|
-
});
|
|
1200
|
-
Context2.prototype.handleError = function(error2, message, detail) {
|
|
1201
|
-
if (detail === void 0) {
|
|
1202
|
-
detail = {};
|
|
1203
|
-
}
|
|
1204
|
-
var _a = this, identifier = _a.identifier, controller = _a.controller, element = _a.element;
|
|
1205
|
-
detail = Object.assign({ identifier, controller, element }, detail);
|
|
1206
|
-
this.application.handleError(error2, "Error " + message, detail);
|
|
1207
|
-
};
|
|
1208
|
-
return Context2;
|
|
1209
|
-
}();
|
|
1210
|
-
function readInheritableStaticArrayValues(constructor, propertyName) {
|
|
1211
|
-
var ancestors = getAncestorsForConstructor(constructor);
|
|
1212
|
-
return Array.from(ancestors.reduce(function(values, constructor2) {
|
|
1213
|
-
getOwnStaticArrayValues(constructor2, propertyName).forEach(function(name) {
|
|
1214
|
-
return values.add(name);
|
|
1215
|
-
});
|
|
1216
|
-
return values;
|
|
1217
|
-
}, new Set()));
|
|
1218
|
-
}
|
|
1219
|
-
function readInheritableStaticObjectPairs(constructor, propertyName) {
|
|
1220
|
-
var ancestors = getAncestorsForConstructor(constructor);
|
|
1221
|
-
return ancestors.reduce(function(pairs, constructor2) {
|
|
1222
|
-
pairs.push.apply(pairs, getOwnStaticObjectPairs(constructor2, propertyName));
|
|
1223
|
-
return pairs;
|
|
1224
|
-
}, []);
|
|
1225
|
-
}
|
|
1226
|
-
function getAncestorsForConstructor(constructor) {
|
|
1227
|
-
var ancestors = [];
|
|
1228
|
-
while (constructor) {
|
|
1229
|
-
ancestors.push(constructor);
|
|
1230
|
-
constructor = Object.getPrototypeOf(constructor);
|
|
1231
|
-
}
|
|
1232
|
-
return ancestors.reverse();
|
|
1233
|
-
}
|
|
1234
|
-
function getOwnStaticArrayValues(constructor, propertyName) {
|
|
1235
|
-
var definition = constructor[propertyName];
|
|
1236
|
-
return Array.isArray(definition) ? definition : [];
|
|
1237
|
-
}
|
|
1238
|
-
function getOwnStaticObjectPairs(constructor, propertyName) {
|
|
1239
|
-
var definition = constructor[propertyName];
|
|
1240
|
-
return definition ? Object.keys(definition).map(function(key) {
|
|
1241
|
-
return [key, definition[key]];
|
|
1242
|
-
}) : [];
|
|
1243
|
-
}
|
|
1244
|
-
var __extends = globalThis && globalThis.__extends || function() {
|
|
1245
|
-
var extendStatics = function(d, b) {
|
|
1246
|
-
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
1247
|
-
d2.__proto__ = b2;
|
|
1248
|
-
} || function(d2, b2) {
|
|
1249
|
-
for (var p in b2)
|
|
1250
|
-
if (b2.hasOwnProperty(p))
|
|
1251
|
-
d2[p] = b2[p];
|
|
1252
|
-
};
|
|
1253
|
-
return extendStatics(d, b);
|
|
1254
|
-
};
|
|
1255
|
-
return function(d, b) {
|
|
1256
|
-
extendStatics(d, b);
|
|
1257
|
-
function __() {
|
|
1258
|
-
this.constructor = d;
|
|
1259
|
-
}
|
|
1260
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1261
|
-
};
|
|
1262
|
-
}();
|
|
1263
|
-
var __spreadArrays$3 = globalThis && globalThis.__spreadArrays || function() {
|
|
1264
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
1265
|
-
s += arguments[i].length;
|
|
1266
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
1267
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
1268
|
-
r[k] = a[j];
|
|
1269
|
-
return r;
|
|
1270
|
-
};
|
|
1271
|
-
function bless(constructor) {
|
|
1272
|
-
return shadow(constructor, getBlessedProperties(constructor));
|
|
1273
|
-
}
|
|
1274
|
-
function shadow(constructor, properties) {
|
|
1275
|
-
var shadowConstructor = extend(constructor);
|
|
1276
|
-
var shadowProperties = getShadowProperties(constructor.prototype, properties);
|
|
1277
|
-
Object.defineProperties(shadowConstructor.prototype, shadowProperties);
|
|
1278
|
-
return shadowConstructor;
|
|
1279
|
-
}
|
|
1280
|
-
function getBlessedProperties(constructor) {
|
|
1281
|
-
var blessings = readInheritableStaticArrayValues(constructor, "blessings");
|
|
1282
|
-
return blessings.reduce(function(blessedProperties, blessing) {
|
|
1283
|
-
var properties = blessing(constructor);
|
|
1284
|
-
for (var key in properties) {
|
|
1285
|
-
var descriptor = blessedProperties[key] || {};
|
|
1286
|
-
blessedProperties[key] = Object.assign(descriptor, properties[key]);
|
|
1287
|
-
}
|
|
1288
|
-
return blessedProperties;
|
|
1289
|
-
}, {});
|
|
1290
|
-
}
|
|
1291
|
-
function getShadowProperties(prototype, properties) {
|
|
1292
|
-
return getOwnKeys(properties).reduce(function(shadowProperties, key) {
|
|
1293
|
-
var _a;
|
|
1294
|
-
var descriptor = getShadowedDescriptor(prototype, properties, key);
|
|
1295
|
-
if (descriptor) {
|
|
1296
|
-
Object.assign(shadowProperties, (_a = {}, _a[key] = descriptor, _a));
|
|
1297
|
-
}
|
|
1298
|
-
return shadowProperties;
|
|
1299
|
-
}, {});
|
|
1300
|
-
}
|
|
1301
|
-
function getShadowedDescriptor(prototype, properties, key) {
|
|
1302
|
-
var shadowingDescriptor = Object.getOwnPropertyDescriptor(prototype, key);
|
|
1303
|
-
var shadowedByValue = shadowingDescriptor && "value" in shadowingDescriptor;
|
|
1304
|
-
if (!shadowedByValue) {
|
|
1305
|
-
var descriptor = Object.getOwnPropertyDescriptor(properties, key).value;
|
|
1306
|
-
if (shadowingDescriptor) {
|
|
1307
|
-
descriptor.get = shadowingDescriptor.get || descriptor.get;
|
|
1308
|
-
descriptor.set = shadowingDescriptor.set || descriptor.set;
|
|
1309
|
-
}
|
|
1310
|
-
return descriptor;
|
|
1311
|
-
}
|
|
1312
|
-
}
|
|
1313
|
-
var getOwnKeys = function() {
|
|
1314
|
-
if (typeof Object.getOwnPropertySymbols == "function") {
|
|
1315
|
-
return function(object) {
|
|
1316
|
-
return __spreadArrays$3(Object.getOwnPropertyNames(object), Object.getOwnPropertySymbols(object));
|
|
1317
|
-
};
|
|
1318
|
-
} else {
|
|
1319
|
-
return Object.getOwnPropertyNames;
|
|
1320
|
-
}
|
|
1321
|
-
}();
|
|
1322
|
-
var extend = function() {
|
|
1323
|
-
function extendWithReflect(constructor) {
|
|
1324
|
-
function extended() {
|
|
1325
|
-
var _newTarget = this && this instanceof extended ? this.constructor : void 0;
|
|
1326
|
-
return Reflect.construct(constructor, arguments, _newTarget);
|
|
1327
|
-
}
|
|
1328
|
-
extended.prototype = Object.create(constructor.prototype, {
|
|
1329
|
-
constructor: { value: extended }
|
|
1330
|
-
});
|
|
1331
|
-
Reflect.setPrototypeOf(extended, constructor);
|
|
1332
|
-
return extended;
|
|
1333
|
-
}
|
|
1334
|
-
function testReflectExtension() {
|
|
1335
|
-
var a = function() {
|
|
1336
|
-
this.a.call(this);
|
|
1337
|
-
};
|
|
1338
|
-
var b = extendWithReflect(a);
|
|
1339
|
-
b.prototype.a = function() {
|
|
1340
|
-
};
|
|
1341
|
-
return new b();
|
|
1342
|
-
}
|
|
1343
|
-
try {
|
|
1344
|
-
testReflectExtension();
|
|
1345
|
-
return extendWithReflect;
|
|
1346
|
-
} catch (error2) {
|
|
1347
|
-
return function(constructor) {
|
|
1348
|
-
return function(_super) {
|
|
1349
|
-
__extends(extended, _super);
|
|
1350
|
-
function extended() {
|
|
1351
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
1352
|
-
}
|
|
1353
|
-
return extended;
|
|
1354
|
-
}(constructor);
|
|
1355
|
-
};
|
|
1356
|
-
}
|
|
1357
|
-
}();
|
|
1358
|
-
function blessDefinition(definition) {
|
|
1359
|
-
return {
|
|
1360
|
-
identifier: definition.identifier,
|
|
1361
|
-
controllerConstructor: bless(definition.controllerConstructor)
|
|
1362
|
-
};
|
|
1363
|
-
}
|
|
1364
|
-
var Module = function() {
|
|
1365
|
-
function Module2(application, definition) {
|
|
1366
|
-
this.application = application;
|
|
1367
|
-
this.definition = blessDefinition(definition);
|
|
1368
|
-
this.contextsByScope = new WeakMap();
|
|
1369
|
-
this.connectedContexts = new Set();
|
|
1370
|
-
}
|
|
1371
|
-
Object.defineProperty(Module2.prototype, "identifier", {
|
|
1372
|
-
get: function() {
|
|
1373
|
-
return this.definition.identifier;
|
|
1374
|
-
},
|
|
1375
|
-
enumerable: false,
|
|
1376
|
-
configurable: true
|
|
1377
|
-
});
|
|
1378
|
-
Object.defineProperty(Module2.prototype, "controllerConstructor", {
|
|
1379
|
-
get: function() {
|
|
1380
|
-
return this.definition.controllerConstructor;
|
|
1381
|
-
},
|
|
1382
|
-
enumerable: false,
|
|
1383
|
-
configurable: true
|
|
1384
|
-
});
|
|
1385
|
-
Object.defineProperty(Module2.prototype, "contexts", {
|
|
1386
|
-
get: function() {
|
|
1387
|
-
return Array.from(this.connectedContexts);
|
|
1388
|
-
},
|
|
1389
|
-
enumerable: false,
|
|
1390
|
-
configurable: true
|
|
1391
|
-
});
|
|
1392
|
-
Module2.prototype.connectContextForScope = function(scope) {
|
|
1393
|
-
var context = this.fetchContextForScope(scope);
|
|
1394
|
-
this.connectedContexts.add(context);
|
|
1395
|
-
context.connect();
|
|
1396
|
-
};
|
|
1397
|
-
Module2.prototype.disconnectContextForScope = function(scope) {
|
|
1398
|
-
var context = this.contextsByScope.get(scope);
|
|
1399
|
-
if (context) {
|
|
1400
|
-
this.connectedContexts.delete(context);
|
|
1401
|
-
context.disconnect();
|
|
1402
|
-
}
|
|
1403
|
-
};
|
|
1404
|
-
Module2.prototype.fetchContextForScope = function(scope) {
|
|
1405
|
-
var context = this.contextsByScope.get(scope);
|
|
1406
|
-
if (!context) {
|
|
1407
|
-
context = new Context(this, scope);
|
|
1408
|
-
this.contextsByScope.set(scope, context);
|
|
1409
|
-
}
|
|
1410
|
-
return context;
|
|
1411
|
-
};
|
|
1412
|
-
return Module2;
|
|
1413
|
-
}();
|
|
1414
|
-
var ClassMap = function() {
|
|
1415
|
-
function ClassMap2(scope) {
|
|
1416
|
-
this.scope = scope;
|
|
1417
|
-
}
|
|
1418
|
-
ClassMap2.prototype.has = function(name) {
|
|
1419
|
-
return this.data.has(this.getDataKey(name));
|
|
1420
|
-
};
|
|
1421
|
-
ClassMap2.prototype.get = function(name) {
|
|
1422
|
-
return this.data.get(this.getDataKey(name));
|
|
1423
|
-
};
|
|
1424
|
-
ClassMap2.prototype.getAttributeName = function(name) {
|
|
1425
|
-
return this.data.getAttributeNameForKey(this.getDataKey(name));
|
|
1426
|
-
};
|
|
1427
|
-
ClassMap2.prototype.getDataKey = function(name) {
|
|
1428
|
-
return name + "-class";
|
|
1429
|
-
};
|
|
1430
|
-
Object.defineProperty(ClassMap2.prototype, "data", {
|
|
1431
|
-
get: function() {
|
|
1432
|
-
return this.scope.data;
|
|
1433
|
-
},
|
|
1434
|
-
enumerable: false,
|
|
1435
|
-
configurable: true
|
|
1436
|
-
});
|
|
1437
|
-
return ClassMap2;
|
|
1438
|
-
}();
|
|
1439
|
-
function camelize(value) {
|
|
1440
|
-
return value.replace(/(?:[_-])([a-z0-9])/g, function(_, char) {
|
|
1441
|
-
return char.toUpperCase();
|
|
1442
|
-
});
|
|
1443
|
-
}
|
|
1444
|
-
function capitalize(value) {
|
|
1445
|
-
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
1446
|
-
}
|
|
1447
|
-
function dasherize(value) {
|
|
1448
|
-
return value.replace(/([A-Z])/g, function(_, char) {
|
|
1449
|
-
return "-" + char.toLowerCase();
|
|
1450
|
-
});
|
|
1451
|
-
}
|
|
1452
|
-
var DataMap = function() {
|
|
1453
|
-
function DataMap2(scope) {
|
|
1454
|
-
this.scope = scope;
|
|
1455
|
-
}
|
|
1456
|
-
Object.defineProperty(DataMap2.prototype, "element", {
|
|
1457
|
-
get: function() {
|
|
1458
|
-
return this.scope.element;
|
|
1459
|
-
},
|
|
1460
|
-
enumerable: false,
|
|
1461
|
-
configurable: true
|
|
1462
|
-
});
|
|
1463
|
-
Object.defineProperty(DataMap2.prototype, "identifier", {
|
|
1464
|
-
get: function() {
|
|
1465
|
-
return this.scope.identifier;
|
|
1466
|
-
},
|
|
1467
|
-
enumerable: false,
|
|
1468
|
-
configurable: true
|
|
1469
|
-
});
|
|
1470
|
-
DataMap2.prototype.get = function(key) {
|
|
1471
|
-
var name = this.getAttributeNameForKey(key);
|
|
1472
|
-
return this.element.getAttribute(name);
|
|
1473
|
-
};
|
|
1474
|
-
DataMap2.prototype.set = function(key, value) {
|
|
1475
|
-
var name = this.getAttributeNameForKey(key);
|
|
1476
|
-
this.element.setAttribute(name, value);
|
|
1477
|
-
return this.get(key);
|
|
1478
|
-
};
|
|
1479
|
-
DataMap2.prototype.has = function(key) {
|
|
1480
|
-
var name = this.getAttributeNameForKey(key);
|
|
1481
|
-
return this.element.hasAttribute(name);
|
|
1482
|
-
};
|
|
1483
|
-
DataMap2.prototype.delete = function(key) {
|
|
1484
|
-
if (this.has(key)) {
|
|
1485
|
-
var name_1 = this.getAttributeNameForKey(key);
|
|
1486
|
-
this.element.removeAttribute(name_1);
|
|
1487
|
-
return true;
|
|
1488
|
-
} else {
|
|
1489
|
-
return false;
|
|
1490
|
-
}
|
|
1491
|
-
};
|
|
1492
|
-
DataMap2.prototype.getAttributeNameForKey = function(key) {
|
|
1493
|
-
return "data-" + this.identifier + "-" + dasherize(key);
|
|
1494
|
-
};
|
|
1495
|
-
return DataMap2;
|
|
1496
|
-
}();
|
|
1497
|
-
var Guide = function() {
|
|
1498
|
-
function Guide2(logger) {
|
|
1499
|
-
this.warnedKeysByObject = new WeakMap();
|
|
1500
|
-
this.logger = logger;
|
|
1501
|
-
}
|
|
1502
|
-
Guide2.prototype.warn = function(object, key, message) {
|
|
1503
|
-
var warnedKeys = this.warnedKeysByObject.get(object);
|
|
1504
|
-
if (!warnedKeys) {
|
|
1505
|
-
warnedKeys = new Set();
|
|
1506
|
-
this.warnedKeysByObject.set(object, warnedKeys);
|
|
1507
|
-
}
|
|
1508
|
-
if (!warnedKeys.has(key)) {
|
|
1509
|
-
warnedKeys.add(key);
|
|
1510
|
-
this.logger.warn(message, object);
|
|
1511
|
-
}
|
|
1512
|
-
};
|
|
1513
|
-
return Guide2;
|
|
1514
|
-
}();
|
|
1515
|
-
function attributeValueContainsToken(attributeName, token) {
|
|
1516
|
-
return "[" + attributeName + '~="' + token + '"]';
|
|
1517
|
-
}
|
|
1518
|
-
var __spreadArrays$2 = globalThis && globalThis.__spreadArrays || function() {
|
|
1519
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
1520
|
-
s += arguments[i].length;
|
|
1521
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
1522
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
1523
|
-
r[k] = a[j];
|
|
1524
|
-
return r;
|
|
1525
|
-
};
|
|
1526
|
-
var TargetSet = function() {
|
|
1527
|
-
function TargetSet2(scope) {
|
|
1528
|
-
this.scope = scope;
|
|
1529
|
-
}
|
|
1530
|
-
Object.defineProperty(TargetSet2.prototype, "element", {
|
|
1531
|
-
get: function() {
|
|
1532
|
-
return this.scope.element;
|
|
1533
|
-
},
|
|
1534
|
-
enumerable: false,
|
|
1535
|
-
configurable: true
|
|
1536
|
-
});
|
|
1537
|
-
Object.defineProperty(TargetSet2.prototype, "identifier", {
|
|
1538
|
-
get: function() {
|
|
1539
|
-
return this.scope.identifier;
|
|
1540
|
-
},
|
|
1541
|
-
enumerable: false,
|
|
1542
|
-
configurable: true
|
|
1543
|
-
});
|
|
1544
|
-
Object.defineProperty(TargetSet2.prototype, "schema", {
|
|
1545
|
-
get: function() {
|
|
1546
|
-
return this.scope.schema;
|
|
1547
|
-
},
|
|
1548
|
-
enumerable: false,
|
|
1549
|
-
configurable: true
|
|
1550
|
-
});
|
|
1551
|
-
TargetSet2.prototype.has = function(targetName) {
|
|
1552
|
-
return this.find(targetName) != null;
|
|
1553
|
-
};
|
|
1554
|
-
TargetSet2.prototype.find = function() {
|
|
1555
|
-
var _this = this;
|
|
1556
|
-
var targetNames = [];
|
|
1557
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1558
|
-
targetNames[_i] = arguments[_i];
|
|
1559
|
-
}
|
|
1560
|
-
return targetNames.reduce(function(target, targetName) {
|
|
1561
|
-
return target || _this.findTarget(targetName) || _this.findLegacyTarget(targetName);
|
|
1562
|
-
}, void 0);
|
|
1563
|
-
};
|
|
1564
|
-
TargetSet2.prototype.findAll = function() {
|
|
1565
|
-
var _this = this;
|
|
1566
|
-
var targetNames = [];
|
|
1567
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1568
|
-
targetNames[_i] = arguments[_i];
|
|
1569
|
-
}
|
|
1570
|
-
return targetNames.reduce(function(targets, targetName) {
|
|
1571
|
-
return __spreadArrays$2(targets, _this.findAllTargets(targetName), _this.findAllLegacyTargets(targetName));
|
|
1572
|
-
}, []);
|
|
1573
|
-
};
|
|
1574
|
-
TargetSet2.prototype.findTarget = function(targetName) {
|
|
1575
|
-
var selector = this.getSelectorForTargetName(targetName);
|
|
1576
|
-
return this.scope.findElement(selector);
|
|
1577
|
-
};
|
|
1578
|
-
TargetSet2.prototype.findAllTargets = function(targetName) {
|
|
1579
|
-
var selector = this.getSelectorForTargetName(targetName);
|
|
1580
|
-
return this.scope.findAllElements(selector);
|
|
1581
|
-
};
|
|
1582
|
-
TargetSet2.prototype.getSelectorForTargetName = function(targetName) {
|
|
1583
|
-
var attributeName = "data-" + this.identifier + "-target";
|
|
1584
|
-
return attributeValueContainsToken(attributeName, targetName);
|
|
1585
|
-
};
|
|
1586
|
-
TargetSet2.prototype.findLegacyTarget = function(targetName) {
|
|
1587
|
-
var selector = this.getLegacySelectorForTargetName(targetName);
|
|
1588
|
-
return this.deprecate(this.scope.findElement(selector), targetName);
|
|
1589
|
-
};
|
|
1590
|
-
TargetSet2.prototype.findAllLegacyTargets = function(targetName) {
|
|
1591
|
-
var _this = this;
|
|
1592
|
-
var selector = this.getLegacySelectorForTargetName(targetName);
|
|
1593
|
-
return this.scope.findAllElements(selector).map(function(element) {
|
|
1594
|
-
return _this.deprecate(element, targetName);
|
|
1595
|
-
});
|
|
1596
|
-
};
|
|
1597
|
-
TargetSet2.prototype.getLegacySelectorForTargetName = function(targetName) {
|
|
1598
|
-
var targetDescriptor = this.identifier + "." + targetName;
|
|
1599
|
-
return attributeValueContainsToken(this.schema.targetAttribute, targetDescriptor);
|
|
1600
|
-
};
|
|
1601
|
-
TargetSet2.prototype.deprecate = function(element, targetName) {
|
|
1602
|
-
if (element) {
|
|
1603
|
-
var identifier = this.identifier;
|
|
1604
|
-
var attributeName = this.schema.targetAttribute;
|
|
1605
|
-
this.guide.warn(element, "target:" + targetName, "Please replace " + attributeName + '="' + identifier + "." + targetName + '" with data-' + identifier + '-target="' + targetName + '". ' + ("The " + attributeName + " attribute is deprecated and will be removed in a future version of Stimulus."));
|
|
1606
|
-
}
|
|
1607
|
-
return element;
|
|
1608
|
-
};
|
|
1609
|
-
Object.defineProperty(TargetSet2.prototype, "guide", {
|
|
1610
|
-
get: function() {
|
|
1611
|
-
return this.scope.guide;
|
|
1612
|
-
},
|
|
1613
|
-
enumerable: false,
|
|
1614
|
-
configurable: true
|
|
1615
|
-
});
|
|
1616
|
-
return TargetSet2;
|
|
1617
|
-
}();
|
|
1618
|
-
var __spreadArrays$1 = globalThis && globalThis.__spreadArrays || function() {
|
|
1619
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
1620
|
-
s += arguments[i].length;
|
|
1621
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
1622
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
1623
|
-
r[k] = a[j];
|
|
1624
|
-
return r;
|
|
1625
|
-
};
|
|
1626
|
-
var Scope = function() {
|
|
1627
|
-
function Scope2(schema, element, identifier, logger) {
|
|
1628
|
-
var _this = this;
|
|
1629
|
-
this.targets = new TargetSet(this);
|
|
1630
|
-
this.classes = new ClassMap(this);
|
|
1631
|
-
this.data = new DataMap(this);
|
|
1632
|
-
this.containsElement = function(element2) {
|
|
1633
|
-
return element2.closest(_this.controllerSelector) === _this.element;
|
|
1634
|
-
};
|
|
1635
|
-
this.schema = schema;
|
|
1636
|
-
this.element = element;
|
|
1637
|
-
this.identifier = identifier;
|
|
1638
|
-
this.guide = new Guide(logger);
|
|
1639
|
-
}
|
|
1640
|
-
Scope2.prototype.findElement = function(selector) {
|
|
1641
|
-
return this.element.matches(selector) ? this.element : this.queryElements(selector).find(this.containsElement);
|
|
1642
|
-
};
|
|
1643
|
-
Scope2.prototype.findAllElements = function(selector) {
|
|
1644
|
-
return __spreadArrays$1(this.element.matches(selector) ? [this.element] : [], this.queryElements(selector).filter(this.containsElement));
|
|
1645
|
-
};
|
|
1646
|
-
Scope2.prototype.queryElements = function(selector) {
|
|
1647
|
-
return Array.from(this.element.querySelectorAll(selector));
|
|
1648
|
-
};
|
|
1649
|
-
Object.defineProperty(Scope2.prototype, "controllerSelector", {
|
|
1650
|
-
get: function() {
|
|
1651
|
-
return attributeValueContainsToken(this.schema.controllerAttribute, this.identifier);
|
|
1652
|
-
},
|
|
1653
|
-
enumerable: false,
|
|
1654
|
-
configurable: true
|
|
1655
|
-
});
|
|
1656
|
-
return Scope2;
|
|
1657
|
-
}();
|
|
1658
|
-
var ScopeObserver = function() {
|
|
1659
|
-
function ScopeObserver2(element, schema, delegate) {
|
|
1660
|
-
this.element = element;
|
|
1661
|
-
this.schema = schema;
|
|
1662
|
-
this.delegate = delegate;
|
|
1663
|
-
this.valueListObserver = new ValueListObserver(this.element, this.controllerAttribute, this);
|
|
1664
|
-
this.scopesByIdentifierByElement = new WeakMap();
|
|
1665
|
-
this.scopeReferenceCounts = new WeakMap();
|
|
1666
|
-
}
|
|
1667
|
-
ScopeObserver2.prototype.start = function() {
|
|
1668
|
-
this.valueListObserver.start();
|
|
1669
|
-
};
|
|
1670
|
-
ScopeObserver2.prototype.stop = function() {
|
|
1671
|
-
this.valueListObserver.stop();
|
|
1672
|
-
};
|
|
1673
|
-
Object.defineProperty(ScopeObserver2.prototype, "controllerAttribute", {
|
|
1674
|
-
get: function() {
|
|
1675
|
-
return this.schema.controllerAttribute;
|
|
1676
|
-
},
|
|
1677
|
-
enumerable: false,
|
|
1678
|
-
configurable: true
|
|
1679
|
-
});
|
|
1680
|
-
ScopeObserver2.prototype.parseValueForToken = function(token) {
|
|
1681
|
-
var element = token.element, identifier = token.content;
|
|
1682
|
-
var scopesByIdentifier = this.fetchScopesByIdentifierForElement(element);
|
|
1683
|
-
var scope = scopesByIdentifier.get(identifier);
|
|
1684
|
-
if (!scope) {
|
|
1685
|
-
scope = this.delegate.createScopeForElementAndIdentifier(element, identifier);
|
|
1686
|
-
scopesByIdentifier.set(identifier, scope);
|
|
1687
|
-
}
|
|
1688
|
-
return scope;
|
|
1689
|
-
};
|
|
1690
|
-
ScopeObserver2.prototype.elementMatchedValue = function(element, value) {
|
|
1691
|
-
var referenceCount = (this.scopeReferenceCounts.get(value) || 0) + 1;
|
|
1692
|
-
this.scopeReferenceCounts.set(value, referenceCount);
|
|
1693
|
-
if (referenceCount == 1) {
|
|
1694
|
-
this.delegate.scopeConnected(value);
|
|
1695
|
-
}
|
|
1696
|
-
};
|
|
1697
|
-
ScopeObserver2.prototype.elementUnmatchedValue = function(element, value) {
|
|
1698
|
-
var referenceCount = this.scopeReferenceCounts.get(value);
|
|
1699
|
-
if (referenceCount) {
|
|
1700
|
-
this.scopeReferenceCounts.set(value, referenceCount - 1);
|
|
1701
|
-
if (referenceCount == 1) {
|
|
1702
|
-
this.delegate.scopeDisconnected(value);
|
|
1703
|
-
}
|
|
1704
|
-
}
|
|
1705
|
-
};
|
|
1706
|
-
ScopeObserver2.prototype.fetchScopesByIdentifierForElement = function(element) {
|
|
1707
|
-
var scopesByIdentifier = this.scopesByIdentifierByElement.get(element);
|
|
1708
|
-
if (!scopesByIdentifier) {
|
|
1709
|
-
scopesByIdentifier = new Map();
|
|
1710
|
-
this.scopesByIdentifierByElement.set(element, scopesByIdentifier);
|
|
1711
|
-
}
|
|
1712
|
-
return scopesByIdentifier;
|
|
1713
|
-
};
|
|
1714
|
-
return ScopeObserver2;
|
|
1715
|
-
}();
|
|
1716
|
-
var Router = function() {
|
|
1717
|
-
function Router2(application) {
|
|
1718
|
-
this.application = application;
|
|
1719
|
-
this.scopeObserver = new ScopeObserver(this.element, this.schema, this);
|
|
1720
|
-
this.scopesByIdentifier = new Multimap();
|
|
1721
|
-
this.modulesByIdentifier = new Map();
|
|
1722
|
-
}
|
|
1723
|
-
Object.defineProperty(Router2.prototype, "element", {
|
|
1724
|
-
get: function() {
|
|
1725
|
-
return this.application.element;
|
|
1726
|
-
},
|
|
1727
|
-
enumerable: false,
|
|
1728
|
-
configurable: true
|
|
1729
|
-
});
|
|
1730
|
-
Object.defineProperty(Router2.prototype, "schema", {
|
|
1731
|
-
get: function() {
|
|
1732
|
-
return this.application.schema;
|
|
1733
|
-
},
|
|
1734
|
-
enumerable: false,
|
|
1735
|
-
configurable: true
|
|
1736
|
-
});
|
|
1737
|
-
Object.defineProperty(Router2.prototype, "logger", {
|
|
1738
|
-
get: function() {
|
|
1739
|
-
return this.application.logger;
|
|
1740
|
-
},
|
|
1741
|
-
enumerable: false,
|
|
1742
|
-
configurable: true
|
|
1743
|
-
});
|
|
1744
|
-
Object.defineProperty(Router2.prototype, "controllerAttribute", {
|
|
1745
|
-
get: function() {
|
|
1746
|
-
return this.schema.controllerAttribute;
|
|
1747
|
-
},
|
|
1748
|
-
enumerable: false,
|
|
1749
|
-
configurable: true
|
|
1750
|
-
});
|
|
1751
|
-
Object.defineProperty(Router2.prototype, "modules", {
|
|
1752
|
-
get: function() {
|
|
1753
|
-
return Array.from(this.modulesByIdentifier.values());
|
|
1754
|
-
},
|
|
1755
|
-
enumerable: false,
|
|
1756
|
-
configurable: true
|
|
1757
|
-
});
|
|
1758
|
-
Object.defineProperty(Router2.prototype, "contexts", {
|
|
1759
|
-
get: function() {
|
|
1760
|
-
return this.modules.reduce(function(contexts, module) {
|
|
1761
|
-
return contexts.concat(module.contexts);
|
|
1762
|
-
}, []);
|
|
1763
|
-
},
|
|
1764
|
-
enumerable: false,
|
|
1765
|
-
configurable: true
|
|
1766
|
-
});
|
|
1767
|
-
Router2.prototype.start = function() {
|
|
1768
|
-
this.scopeObserver.start();
|
|
1769
|
-
};
|
|
1770
|
-
Router2.prototype.stop = function() {
|
|
1771
|
-
this.scopeObserver.stop();
|
|
1772
|
-
};
|
|
1773
|
-
Router2.prototype.loadDefinition = function(definition) {
|
|
1774
|
-
this.unloadIdentifier(definition.identifier);
|
|
1775
|
-
var module = new Module(this.application, definition);
|
|
1776
|
-
this.connectModule(module);
|
|
1777
|
-
};
|
|
1778
|
-
Router2.prototype.unloadIdentifier = function(identifier) {
|
|
1779
|
-
var module = this.modulesByIdentifier.get(identifier);
|
|
1780
|
-
if (module) {
|
|
1781
|
-
this.disconnectModule(module);
|
|
1782
|
-
}
|
|
1783
|
-
};
|
|
1784
|
-
Router2.prototype.getContextForElementAndIdentifier = function(element, identifier) {
|
|
1785
|
-
var module = this.modulesByIdentifier.get(identifier);
|
|
1786
|
-
if (module) {
|
|
1787
|
-
return module.contexts.find(function(context) {
|
|
1788
|
-
return context.element == element;
|
|
1789
|
-
});
|
|
1790
|
-
}
|
|
1791
|
-
};
|
|
1792
|
-
Router2.prototype.handleError = function(error2, message, detail) {
|
|
1793
|
-
this.application.handleError(error2, message, detail);
|
|
1794
|
-
};
|
|
1795
|
-
Router2.prototype.createScopeForElementAndIdentifier = function(element, identifier) {
|
|
1796
|
-
return new Scope(this.schema, element, identifier, this.logger);
|
|
1797
|
-
};
|
|
1798
|
-
Router2.prototype.scopeConnected = function(scope) {
|
|
1799
|
-
this.scopesByIdentifier.add(scope.identifier, scope);
|
|
1800
|
-
var module = this.modulesByIdentifier.get(scope.identifier);
|
|
1801
|
-
if (module) {
|
|
1802
|
-
module.connectContextForScope(scope);
|
|
1803
|
-
}
|
|
1804
|
-
};
|
|
1805
|
-
Router2.prototype.scopeDisconnected = function(scope) {
|
|
1806
|
-
this.scopesByIdentifier.delete(scope.identifier, scope);
|
|
1807
|
-
var module = this.modulesByIdentifier.get(scope.identifier);
|
|
1808
|
-
if (module) {
|
|
1809
|
-
module.disconnectContextForScope(scope);
|
|
1810
|
-
}
|
|
1811
|
-
};
|
|
1812
|
-
Router2.prototype.connectModule = function(module) {
|
|
1813
|
-
this.modulesByIdentifier.set(module.identifier, module);
|
|
1814
|
-
var scopes = this.scopesByIdentifier.getValuesForKey(module.identifier);
|
|
1815
|
-
scopes.forEach(function(scope) {
|
|
1816
|
-
return module.connectContextForScope(scope);
|
|
1817
|
-
});
|
|
1818
|
-
};
|
|
1819
|
-
Router2.prototype.disconnectModule = function(module) {
|
|
1820
|
-
this.modulesByIdentifier.delete(module.identifier);
|
|
1821
|
-
var scopes = this.scopesByIdentifier.getValuesForKey(module.identifier);
|
|
1822
|
-
scopes.forEach(function(scope) {
|
|
1823
|
-
return module.disconnectContextForScope(scope);
|
|
1824
|
-
});
|
|
1825
|
-
};
|
|
1826
|
-
return Router2;
|
|
1827
|
-
}();
|
|
1828
|
-
var defaultSchema = {
|
|
1829
|
-
controllerAttribute: "data-controller",
|
|
1830
|
-
actionAttribute: "data-action",
|
|
1831
|
-
targetAttribute: "data-target"
|
|
1832
|
-
};
|
|
1833
|
-
var __awaiter = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
1834
|
-
function adopt(value) {
|
|
1835
|
-
return value instanceof P ? value : new P(function(resolve) {
|
|
1836
|
-
resolve(value);
|
|
1837
|
-
});
|
|
1838
|
-
}
|
|
1839
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
|
1840
|
-
function fulfilled(value) {
|
|
1841
|
-
try {
|
|
1842
|
-
step(generator.next(value));
|
|
1843
|
-
} catch (e) {
|
|
1844
|
-
reject(e);
|
|
1845
|
-
}
|
|
1846
|
-
}
|
|
1847
|
-
function rejected(value) {
|
|
1848
|
-
try {
|
|
1849
|
-
step(generator["throw"](value));
|
|
1850
|
-
} catch (e) {
|
|
1851
|
-
reject(e);
|
|
1852
|
-
}
|
|
1853
|
-
}
|
|
1854
|
-
function step(result) {
|
|
1855
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1856
|
-
}
|
|
1857
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1858
|
-
});
|
|
1859
|
-
};
|
|
1860
|
-
var __generator = globalThis && globalThis.__generator || function(thisArg, body) {
|
|
1861
|
-
var _ = { label: 0, sent: function() {
|
|
1862
|
-
if (t[0] & 1)
|
|
1863
|
-
throw t[1];
|
|
1864
|
-
return t[1];
|
|
1865
|
-
}, trys: [], ops: [] }, f, y, t, g;
|
|
1866
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
1867
|
-
return this;
|
|
1868
|
-
}), g;
|
|
1869
|
-
function verb(n) {
|
|
1870
|
-
return function(v) {
|
|
1871
|
-
return step([n, v]);
|
|
1872
|
-
};
|
|
1873
|
-
}
|
|
1874
|
-
function step(op) {
|
|
1875
|
-
if (f)
|
|
1876
|
-
throw new TypeError("Generator is already executing.");
|
|
1877
|
-
while (_)
|
|
1878
|
-
try {
|
|
1879
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
1880
|
-
return t;
|
|
1881
|
-
if (y = 0, t)
|
|
1882
|
-
op = [op[0] & 2, t.value];
|
|
1883
|
-
switch (op[0]) {
|
|
1884
|
-
case 0:
|
|
1885
|
-
case 1:
|
|
1886
|
-
t = op;
|
|
1887
|
-
break;
|
|
1888
|
-
case 4:
|
|
1889
|
-
_.label++;
|
|
1890
|
-
return { value: op[1], done: false };
|
|
1891
|
-
case 5:
|
|
1892
|
-
_.label++;
|
|
1893
|
-
y = op[1];
|
|
1894
|
-
op = [0];
|
|
1895
|
-
continue;
|
|
1896
|
-
case 7:
|
|
1897
|
-
op = _.ops.pop();
|
|
1898
|
-
_.trys.pop();
|
|
1899
|
-
continue;
|
|
1900
|
-
default:
|
|
1901
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1902
|
-
_ = 0;
|
|
1903
|
-
continue;
|
|
1904
|
-
}
|
|
1905
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1906
|
-
_.label = op[1];
|
|
1907
|
-
break;
|
|
1908
|
-
}
|
|
1909
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
1910
|
-
_.label = t[1];
|
|
1911
|
-
t = op;
|
|
1912
|
-
break;
|
|
1913
|
-
}
|
|
1914
|
-
if (t && _.label < t[2]) {
|
|
1915
|
-
_.label = t[2];
|
|
1916
|
-
_.ops.push(op);
|
|
1917
|
-
break;
|
|
1918
|
-
}
|
|
1919
|
-
if (t[2])
|
|
1920
|
-
_.ops.pop();
|
|
1921
|
-
_.trys.pop();
|
|
1922
|
-
continue;
|
|
1923
|
-
}
|
|
1924
|
-
op = body.call(thisArg, _);
|
|
1925
|
-
} catch (e) {
|
|
1926
|
-
op = [6, e];
|
|
1927
|
-
y = 0;
|
|
1928
|
-
} finally {
|
|
1929
|
-
f = t = 0;
|
|
1930
|
-
}
|
|
1931
|
-
if (op[0] & 5)
|
|
1932
|
-
throw op[1];
|
|
1933
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
1934
|
-
}
|
|
1935
|
-
};
|
|
1936
|
-
var __spreadArrays = globalThis && globalThis.__spreadArrays || function() {
|
|
1937
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
1938
|
-
s += arguments[i].length;
|
|
1939
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
1940
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
1941
|
-
r[k] = a[j];
|
|
1942
|
-
return r;
|
|
1943
|
-
};
|
|
1944
|
-
(function() {
|
|
1945
|
-
function Application(element, schema) {
|
|
1946
|
-
if (element === void 0) {
|
|
1947
|
-
element = document.documentElement;
|
|
1948
|
-
}
|
|
1949
|
-
if (schema === void 0) {
|
|
1950
|
-
schema = defaultSchema;
|
|
1951
|
-
}
|
|
1952
|
-
this.logger = console;
|
|
1953
|
-
this.element = element;
|
|
1954
|
-
this.schema = schema;
|
|
1955
|
-
this.dispatcher = new Dispatcher(this);
|
|
1956
|
-
this.router = new Router(this);
|
|
1957
|
-
}
|
|
1958
|
-
Application.start = function(element, schema) {
|
|
1959
|
-
var application = new Application(element, schema);
|
|
1960
|
-
application.start();
|
|
1961
|
-
return application;
|
|
1962
|
-
};
|
|
1963
|
-
Application.prototype.start = function() {
|
|
1964
|
-
return __awaiter(this, void 0, void 0, function() {
|
|
1965
|
-
return __generator(this, function(_a) {
|
|
1966
|
-
switch (_a.label) {
|
|
1967
|
-
case 0:
|
|
1968
|
-
return [4, domReady()];
|
|
1969
|
-
case 1:
|
|
1970
|
-
_a.sent();
|
|
1971
|
-
this.dispatcher.start();
|
|
1972
|
-
this.router.start();
|
|
1973
|
-
return [2];
|
|
1974
|
-
}
|
|
1975
|
-
});
|
|
1976
|
-
});
|
|
1977
|
-
};
|
|
1978
|
-
Application.prototype.stop = function() {
|
|
1979
|
-
this.dispatcher.stop();
|
|
1980
|
-
this.router.stop();
|
|
1981
|
-
};
|
|
1982
|
-
Application.prototype.register = function(identifier, controllerConstructor) {
|
|
1983
|
-
this.load({ identifier, controllerConstructor });
|
|
1984
|
-
};
|
|
1985
|
-
Application.prototype.load = function(head) {
|
|
1986
|
-
var _this = this;
|
|
1987
|
-
var rest = [];
|
|
1988
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1989
|
-
rest[_i - 1] = arguments[_i];
|
|
1990
|
-
}
|
|
1991
|
-
var definitions = Array.isArray(head) ? head : __spreadArrays([head], rest);
|
|
1992
|
-
definitions.forEach(function(definition) {
|
|
1993
|
-
return _this.router.loadDefinition(definition);
|
|
1994
|
-
});
|
|
1995
|
-
};
|
|
1996
|
-
Application.prototype.unload = function(head) {
|
|
1997
|
-
var _this = this;
|
|
1998
|
-
var rest = [];
|
|
1999
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2000
|
-
rest[_i - 1] = arguments[_i];
|
|
2001
|
-
}
|
|
2002
|
-
var identifiers = Array.isArray(head) ? head : __spreadArrays([head], rest);
|
|
2003
|
-
identifiers.forEach(function(identifier) {
|
|
2004
|
-
return _this.router.unloadIdentifier(identifier);
|
|
2005
|
-
});
|
|
2006
|
-
};
|
|
2007
|
-
Object.defineProperty(Application.prototype, "controllers", {
|
|
2008
|
-
get: function() {
|
|
2009
|
-
return this.router.contexts.map(function(context) {
|
|
2010
|
-
return context.controller;
|
|
2011
|
-
});
|
|
2012
|
-
},
|
|
2013
|
-
enumerable: false,
|
|
2014
|
-
configurable: true
|
|
2015
|
-
});
|
|
2016
|
-
Application.prototype.getControllerForElementAndIdentifier = function(element, identifier) {
|
|
2017
|
-
var context = this.router.getContextForElementAndIdentifier(element, identifier);
|
|
2018
|
-
return context ? context.controller : null;
|
|
2019
|
-
};
|
|
2020
|
-
Application.prototype.handleError = function(error2, message, detail) {
|
|
2021
|
-
this.logger.error("%s\n\n%o\n\n%o", message, error2, detail);
|
|
2022
|
-
};
|
|
2023
|
-
return Application;
|
|
2024
|
-
})();
|
|
2025
|
-
function domReady() {
|
|
2026
|
-
return new Promise(function(resolve) {
|
|
2027
|
-
if (document.readyState == "loading") {
|
|
2028
|
-
document.addEventListener("DOMContentLoaded", resolve);
|
|
2029
|
-
} else {
|
|
2030
|
-
resolve();
|
|
2031
|
-
}
|
|
2032
|
-
});
|
|
2033
|
-
}
|
|
2034
|
-
function ClassPropertiesBlessing(constructor) {
|
|
2035
|
-
var classes = readInheritableStaticArrayValues(constructor, "classes");
|
|
2036
|
-
return classes.reduce(function(properties, classDefinition) {
|
|
2037
|
-
return Object.assign(properties, propertiesForClassDefinition(classDefinition));
|
|
2038
|
-
}, {});
|
|
2039
|
-
}
|
|
2040
|
-
function propertiesForClassDefinition(key) {
|
|
2041
|
-
var _a;
|
|
2042
|
-
var name = key + "Class";
|
|
2043
|
-
return _a = {}, _a[name] = {
|
|
2044
|
-
get: function() {
|
|
2045
|
-
var classes = this.classes;
|
|
2046
|
-
if (classes.has(key)) {
|
|
2047
|
-
return classes.get(key);
|
|
2048
|
-
} else {
|
|
2049
|
-
var attribute = classes.getAttributeName(key);
|
|
2050
|
-
throw new Error('Missing attribute "' + attribute + '"');
|
|
2051
|
-
}
|
|
2052
|
-
}
|
|
2053
|
-
}, _a["has" + capitalize(name)] = {
|
|
2054
|
-
get: function() {
|
|
2055
|
-
return this.classes.has(key);
|
|
2056
|
-
}
|
|
2057
|
-
}, _a;
|
|
2058
|
-
}
|
|
2059
|
-
function TargetPropertiesBlessing(constructor) {
|
|
2060
|
-
var targets = readInheritableStaticArrayValues(constructor, "targets");
|
|
2061
|
-
return targets.reduce(function(properties, targetDefinition) {
|
|
2062
|
-
return Object.assign(properties, propertiesForTargetDefinition(targetDefinition));
|
|
2063
|
-
}, {});
|
|
2064
|
-
}
|
|
2065
|
-
function propertiesForTargetDefinition(name) {
|
|
2066
|
-
var _a;
|
|
2067
|
-
return _a = {}, _a[name + "Target"] = {
|
|
2068
|
-
get: function() {
|
|
2069
|
-
var target = this.targets.find(name);
|
|
2070
|
-
if (target) {
|
|
2071
|
-
return target;
|
|
2072
|
-
} else {
|
|
2073
|
-
throw new Error('Missing target element "' + this.identifier + "." + name + '"');
|
|
2074
|
-
}
|
|
2075
|
-
}
|
|
2076
|
-
}, _a[name + "Targets"] = {
|
|
2077
|
-
get: function() {
|
|
2078
|
-
return this.targets.findAll(name);
|
|
2079
|
-
}
|
|
2080
|
-
}, _a["has" + capitalize(name) + "Target"] = {
|
|
2081
|
-
get: function() {
|
|
2082
|
-
return this.targets.has(name);
|
|
2083
|
-
}
|
|
2084
|
-
}, _a;
|
|
2085
|
-
}
|
|
2086
|
-
function ValuePropertiesBlessing(constructor) {
|
|
2087
|
-
var valueDefinitionPairs = readInheritableStaticObjectPairs(constructor, "values");
|
|
2088
|
-
var propertyDescriptorMap = {
|
|
2089
|
-
valueDescriptorMap: {
|
|
2090
|
-
get: function() {
|
|
2091
|
-
var _this = this;
|
|
2092
|
-
return valueDefinitionPairs.reduce(function(result, valueDefinitionPair) {
|
|
2093
|
-
var _a;
|
|
2094
|
-
var valueDescriptor = parseValueDefinitionPair(valueDefinitionPair);
|
|
2095
|
-
var attributeName = _this.data.getAttributeNameForKey(valueDescriptor.key);
|
|
2096
|
-
return Object.assign(result, (_a = {}, _a[attributeName] = valueDescriptor, _a));
|
|
2097
|
-
}, {});
|
|
2098
|
-
}
|
|
2099
|
-
}
|
|
2100
|
-
};
|
|
2101
|
-
return valueDefinitionPairs.reduce(function(properties, valueDefinitionPair) {
|
|
2102
|
-
return Object.assign(properties, propertiesForValueDefinitionPair(valueDefinitionPair));
|
|
2103
|
-
}, propertyDescriptorMap);
|
|
2104
|
-
}
|
|
2105
|
-
function propertiesForValueDefinitionPair(valueDefinitionPair) {
|
|
2106
|
-
var _a;
|
|
2107
|
-
var definition = parseValueDefinitionPair(valueDefinitionPair);
|
|
2108
|
-
var type = definition.type, key = definition.key, name = definition.name;
|
|
2109
|
-
var read = readers[type], write = writers[type] || writers.default;
|
|
2110
|
-
return _a = {}, _a[name] = {
|
|
2111
|
-
get: function() {
|
|
2112
|
-
var value = this.data.get(key);
|
|
2113
|
-
if (value !== null) {
|
|
2114
|
-
return read(value);
|
|
2115
|
-
} else {
|
|
2116
|
-
return definition.defaultValue;
|
|
2117
|
-
}
|
|
2118
|
-
},
|
|
2119
|
-
set: function(value) {
|
|
2120
|
-
if (value === void 0) {
|
|
2121
|
-
this.data.delete(key);
|
|
2122
|
-
} else {
|
|
2123
|
-
this.data.set(key, write(value));
|
|
2124
|
-
}
|
|
2125
|
-
}
|
|
2126
|
-
}, _a["has" + capitalize(name)] = {
|
|
2127
|
-
get: function() {
|
|
2128
|
-
return this.data.has(key);
|
|
2129
|
-
}
|
|
2130
|
-
}, _a;
|
|
2131
|
-
}
|
|
2132
|
-
function parseValueDefinitionPair(_a) {
|
|
2133
|
-
var token = _a[0], typeConstant = _a[1];
|
|
2134
|
-
var type = parseValueTypeConstant(typeConstant);
|
|
2135
|
-
return valueDescriptorForTokenAndType(token, type);
|
|
2136
|
-
}
|
|
2137
|
-
function parseValueTypeConstant(typeConstant) {
|
|
2138
|
-
switch (typeConstant) {
|
|
2139
|
-
case Array:
|
|
2140
|
-
return "array";
|
|
2141
|
-
case Boolean:
|
|
2142
|
-
return "boolean";
|
|
2143
|
-
case Number:
|
|
2144
|
-
return "number";
|
|
2145
|
-
case Object:
|
|
2146
|
-
return "object";
|
|
2147
|
-
case String:
|
|
2148
|
-
return "string";
|
|
2149
|
-
}
|
|
2150
|
-
throw new Error('Unknown value type constant "' + typeConstant + '"');
|
|
2151
|
-
}
|
|
2152
|
-
function valueDescriptorForTokenAndType(token, type) {
|
|
2153
|
-
var key = dasherize(token) + "-value";
|
|
2154
|
-
return {
|
|
2155
|
-
type,
|
|
2156
|
-
key,
|
|
2157
|
-
name: camelize(key),
|
|
2158
|
-
get defaultValue() {
|
|
2159
|
-
return defaultValuesByType[type];
|
|
2160
|
-
}
|
|
2161
|
-
};
|
|
2162
|
-
}
|
|
2163
|
-
var defaultValuesByType = {
|
|
2164
|
-
get array() {
|
|
2165
|
-
return [];
|
|
2166
|
-
},
|
|
2167
|
-
boolean: false,
|
|
2168
|
-
number: 0,
|
|
2169
|
-
get object() {
|
|
2170
|
-
return {};
|
|
2171
|
-
},
|
|
2172
|
-
string: ""
|
|
2173
|
-
};
|
|
2174
|
-
var readers = {
|
|
2175
|
-
array: function(value) {
|
|
2176
|
-
var array = JSON.parse(value);
|
|
2177
|
-
if (!Array.isArray(array)) {
|
|
2178
|
-
throw new TypeError("Expected array");
|
|
2179
|
-
}
|
|
2180
|
-
return array;
|
|
2181
|
-
},
|
|
2182
|
-
boolean: function(value) {
|
|
2183
|
-
return !(value == "0" || value == "false");
|
|
2184
|
-
},
|
|
2185
|
-
number: function(value) {
|
|
2186
|
-
return parseFloat(value);
|
|
2187
|
-
},
|
|
2188
|
-
object: function(value) {
|
|
2189
|
-
var object = JSON.parse(value);
|
|
2190
|
-
if (object === null || typeof object != "object" || Array.isArray(object)) {
|
|
2191
|
-
throw new TypeError("Expected object");
|
|
2192
|
-
}
|
|
2193
|
-
return object;
|
|
2194
|
-
},
|
|
2195
|
-
string: function(value) {
|
|
2196
|
-
return value;
|
|
2197
|
-
}
|
|
2198
|
-
};
|
|
2199
|
-
var writers = {
|
|
2200
|
-
default: writeString,
|
|
2201
|
-
array: writeJSON,
|
|
2202
|
-
object: writeJSON
|
|
17
|
+
var __publicField = (obj, key, value) => {
|
|
18
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
19
|
+
return value;
|
|
2203
20
|
};
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
}
|
|
2207
|
-
function writeString(value) {
|
|
2208
|
-
return "" + value;
|
|
2209
|
-
}
|
|
2210
|
-
var Controller = function() {
|
|
2211
|
-
function Controller2(context) {
|
|
2212
|
-
this.context = context;
|
|
2213
|
-
}
|
|
2214
|
-
Object.defineProperty(Controller2.prototype, "application", {
|
|
2215
|
-
get: function() {
|
|
2216
|
-
return this.context.application;
|
|
2217
|
-
},
|
|
2218
|
-
enumerable: false,
|
|
2219
|
-
configurable: true
|
|
2220
|
-
});
|
|
2221
|
-
Object.defineProperty(Controller2.prototype, "scope", {
|
|
2222
|
-
get: function() {
|
|
2223
|
-
return this.context.scope;
|
|
2224
|
-
},
|
|
2225
|
-
enumerable: false,
|
|
2226
|
-
configurable: true
|
|
2227
|
-
});
|
|
2228
|
-
Object.defineProperty(Controller2.prototype, "element", {
|
|
2229
|
-
get: function() {
|
|
2230
|
-
return this.scope.element;
|
|
2231
|
-
},
|
|
2232
|
-
enumerable: false,
|
|
2233
|
-
configurable: true
|
|
2234
|
-
});
|
|
2235
|
-
Object.defineProperty(Controller2.prototype, "identifier", {
|
|
2236
|
-
get: function() {
|
|
2237
|
-
return this.scope.identifier;
|
|
2238
|
-
},
|
|
2239
|
-
enumerable: false,
|
|
2240
|
-
configurable: true
|
|
2241
|
-
});
|
|
2242
|
-
Object.defineProperty(Controller2.prototype, "targets", {
|
|
2243
|
-
get: function() {
|
|
2244
|
-
return this.scope.targets;
|
|
2245
|
-
},
|
|
2246
|
-
enumerable: false,
|
|
2247
|
-
configurable: true
|
|
2248
|
-
});
|
|
2249
|
-
Object.defineProperty(Controller2.prototype, "classes", {
|
|
2250
|
-
get: function() {
|
|
2251
|
-
return this.scope.classes;
|
|
2252
|
-
},
|
|
2253
|
-
enumerable: false,
|
|
2254
|
-
configurable: true
|
|
2255
|
-
});
|
|
2256
|
-
Object.defineProperty(Controller2.prototype, "data", {
|
|
2257
|
-
get: function() {
|
|
2258
|
-
return this.scope.data;
|
|
2259
|
-
},
|
|
2260
|
-
enumerable: false,
|
|
2261
|
-
configurable: true
|
|
2262
|
-
});
|
|
2263
|
-
Controller2.prototype.initialize = function() {
|
|
2264
|
-
};
|
|
2265
|
-
Controller2.prototype.connect = function() {
|
|
2266
|
-
};
|
|
2267
|
-
Controller2.prototype.disconnect = function() {
|
|
2268
|
-
};
|
|
2269
|
-
Controller2.blessings = [ClassPropertiesBlessing, TargetPropertiesBlessing, ValuePropertiesBlessing];
|
|
2270
|
-
Controller2.targets = [];
|
|
2271
|
-
Controller2.values = {};
|
|
2272
|
-
return Controller2;
|
|
2273
|
-
}();
|
|
21
|
+
import { Controller } from "stimulus";
|
|
22
|
+
import { camelCase, debounce, upperFirst, clamp, get, set } from "lodash-es";
|
|
23
|
+
import { isPast, intervalToDuration, formatDuration, toDate, formatDistanceToNow } from "date-fns";
|
|
2274
24
|
class BaseController extends Controller {
|
|
2275
25
|
constructor(context) {
|
|
2276
26
|
super(context);
|
|
@@ -2316,7 +66,7 @@ class BaseController extends Controller {
|
|
|
2316
66
|
return (element == null ? void 0 : element.getAttribute("content")) || null;
|
|
2317
67
|
}
|
|
2318
68
|
dispatch(element, eventName, options = {}) {
|
|
2319
|
-
let mergedOptions = Object.assign({}, { bubbles: true, cancelable: true, detail: { target: element } }, options);
|
|
69
|
+
let mergedOptions = Object.assign({}, { bubbles: true, cancelable: true, detail: { target: element, element } }, options);
|
|
2320
70
|
if (!!mergedOptions.detail.target) {
|
|
2321
71
|
mergedOptions.detail.target = element;
|
|
2322
72
|
}
|
|
@@ -2392,105 +142,39 @@ function logProperty(prop) {
|
|
|
2392
142
|
if (/^.*?Classes$/.test(prop)) {
|
|
2393
143
|
return false;
|
|
2394
144
|
}
|
|
145
|
+
if (/^.*?ClassesPresent$/.test(prop)) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
2395
148
|
return true;
|
|
2396
149
|
}
|
|
2397
|
-
var camelcase = { exports: {} };
|
|
2398
|
-
const preserveCamelCase = (string, locale) => {
|
|
2399
|
-
let isLastCharLower = false;
|
|
2400
|
-
let isLastCharUpper = false;
|
|
2401
|
-
let isLastLastCharUpper = false;
|
|
2402
|
-
for (let i = 0; i < string.length; i++) {
|
|
2403
|
-
const character = string[i];
|
|
2404
|
-
if (isLastCharLower && /[\p{Lu}]/u.test(character)) {
|
|
2405
|
-
string = string.slice(0, i) + "-" + string.slice(i);
|
|
2406
|
-
isLastCharLower = false;
|
|
2407
|
-
isLastLastCharUpper = isLastCharUpper;
|
|
2408
|
-
isLastCharUpper = true;
|
|
2409
|
-
i++;
|
|
2410
|
-
} else if (isLastCharUpper && isLastLastCharUpper && /[\p{Ll}]/u.test(character)) {
|
|
2411
|
-
string = string.slice(0, i - 1) + "-" + string.slice(i - 1);
|
|
2412
|
-
isLastLastCharUpper = isLastCharUpper;
|
|
2413
|
-
isLastCharUpper = false;
|
|
2414
|
-
isLastCharLower = true;
|
|
2415
|
-
} else {
|
|
2416
|
-
isLastCharLower = character.toLocaleLowerCase(locale) === character && character.toLocaleUpperCase(locale) !== character;
|
|
2417
|
-
isLastLastCharUpper = isLastCharUpper;
|
|
2418
|
-
isLastCharUpper = character.toLocaleUpperCase(locale) === character && character.toLocaleLowerCase(locale) !== character;
|
|
2419
|
-
}
|
|
2420
|
-
}
|
|
2421
|
-
return string;
|
|
2422
|
-
};
|
|
2423
|
-
const preserveConsecutiveUppercase = (input) => {
|
|
2424
|
-
return input.replace(/^[\p{Lu}](?![\p{Lu}])/gu, (m1) => m1.toLowerCase());
|
|
2425
|
-
};
|
|
2426
|
-
const postProcess = (input, options) => {
|
|
2427
|
-
return input.replace(/[_.\- ]+([\p{Alpha}\p{N}_]|$)/gu, (_, p1) => p1.toLocaleUpperCase(options.locale)).replace(/\d+([\p{Alpha}\p{N}_]|$)/gu, (m) => m.toLocaleUpperCase(options.locale));
|
|
2428
|
-
};
|
|
2429
|
-
const camelCase = (input, options) => {
|
|
2430
|
-
if (!(typeof input === "string" || Array.isArray(input))) {
|
|
2431
|
-
throw new TypeError("Expected the input to be `string | string[]`");
|
|
2432
|
-
}
|
|
2433
|
-
options = __spreadValues({
|
|
2434
|
-
pascalCase: false,
|
|
2435
|
-
preserveConsecutiveUppercase: false
|
|
2436
|
-
}, options);
|
|
2437
|
-
if (Array.isArray(input)) {
|
|
2438
|
-
input = input.map((x) => x.trim()).filter((x) => x.length).join("-");
|
|
2439
|
-
} else {
|
|
2440
|
-
input = input.trim();
|
|
2441
|
-
}
|
|
2442
|
-
if (input.length === 0) {
|
|
2443
|
-
return "";
|
|
2444
|
-
}
|
|
2445
|
-
if (input.length === 1) {
|
|
2446
|
-
return options.pascalCase ? input.toLocaleUpperCase(options.locale) : input.toLocaleLowerCase(options.locale);
|
|
2447
|
-
}
|
|
2448
|
-
const hasUpperCase = input !== input.toLocaleLowerCase(options.locale);
|
|
2449
|
-
if (hasUpperCase) {
|
|
2450
|
-
input = preserveCamelCase(input, options.locale);
|
|
2451
|
-
}
|
|
2452
|
-
input = input.replace(/^[_.\- ]+/, "");
|
|
2453
|
-
if (options.preserveConsecutiveUppercase) {
|
|
2454
|
-
input = preserveConsecutiveUppercase(input);
|
|
2455
|
-
} else {
|
|
2456
|
-
input = input.toLocaleLowerCase();
|
|
2457
|
-
}
|
|
2458
|
-
if (options.pascalCase) {
|
|
2459
|
-
input = input.charAt(0).toLocaleUpperCase(options.locale) + input.slice(1);
|
|
2460
|
-
}
|
|
2461
|
-
return postProcess(input, options);
|
|
2462
|
-
};
|
|
2463
|
-
camelcase.exports = camelCase;
|
|
2464
|
-
camelcase.exports.default = camelCase;
|
|
2465
|
-
var camelCase$1 = camelcase.exports;
|
|
2466
150
|
class EphemeralController extends BaseController {
|
|
2467
151
|
_cleanupSelf() {
|
|
2468
152
|
this.cleanup(this.el);
|
|
2469
153
|
}
|
|
2470
154
|
cleanup(element) {
|
|
2471
155
|
var _a, _b, _c;
|
|
2472
|
-
element.dataset.controller = ((_a = element.dataset.controller) == null ? void 0 : _a.replaceAll(new RegExp(`(s|^)${this.identifier}(s|$)`, "g"), "")) || "";
|
|
156
|
+
element.dataset.controller = ((_a = element.dataset.controller) == null ? void 0 : _a.replaceAll(new RegExp(`(\\s|^)${this.identifier}(\\s|$)`, "g"), "")) || "";
|
|
2473
157
|
if (element.dataset.controller == "") {
|
|
2474
158
|
delete element.dataset.controller;
|
|
2475
159
|
}
|
|
2476
|
-
let substringIdentifierValueRegex = new RegExp(`(s|^)${this.identifier}\\..+?(s|$)`, "g");
|
|
160
|
+
let substringIdentifierValueRegex = new RegExp(`(\\s|^)${this.identifier}\\..+?(\\s|$)`, "g");
|
|
2477
161
|
element.dataset.target = ((_b = element.dataset.target) == null ? void 0 : _b.replaceAll(substringIdentifierValueRegex, "")) || "";
|
|
2478
|
-
delete element.dataset[camelCase
|
|
162
|
+
delete element.dataset[camelCase(`${this.identifier}-target`)];
|
|
2479
163
|
if (element.dataset.target == "") {
|
|
2480
164
|
delete element.dataset.target;
|
|
2481
165
|
}
|
|
2482
166
|
element.dataset.action = ((_c = element.dataset.target) == null ? void 0 : _c.replaceAll(substringIdentifierValueRegex, "")) || "";
|
|
2483
|
-
delete element.dataset[camelCase
|
|
167
|
+
delete element.dataset[camelCase(`${this.identifier}-action`)];
|
|
2484
168
|
if (element.dataset.action == "") {
|
|
2485
169
|
delete element.dataset.action;
|
|
2486
170
|
}
|
|
2487
171
|
let values = this.constructor.values;
|
|
2488
172
|
if (values) {
|
|
2489
|
-
Object.keys(values).forEach((val) => delete element.dataset[camelCase
|
|
173
|
+
Object.keys(values).forEach((val) => delete element.dataset[camelCase(`${this.identifier}-${val}-value`)]);
|
|
2490
174
|
}
|
|
2491
175
|
let classes = this.constructor.classes;
|
|
2492
176
|
if (classes) {
|
|
2493
|
-
Object.keys(classes).forEach((val) => delete element.dataset[camelCase
|
|
177
|
+
Object.keys(classes).forEach((val) => delete element.dataset[camelCase(`${this.identifier}-${val}-class`)]);
|
|
2494
178
|
}
|
|
2495
179
|
}
|
|
2496
180
|
}
|
|
@@ -2660,6 +344,21 @@ function insertHiddenInput(name, value, targetElement, insertPosition) {
|
|
|
2660
344
|
function insertHiddenButton(type, targetElement, insertPosition) {
|
|
2661
345
|
return insertElement(targetElement, insertPosition, createHiddenButton(type));
|
|
2662
346
|
}
|
|
347
|
+
function getAllRadiosInGroup(radio) {
|
|
348
|
+
let parent = radio.form || document;
|
|
349
|
+
return Array.from(parent.querySelectorAll(`input[type="radio"][name="${radio.name}"]`));
|
|
350
|
+
}
|
|
351
|
+
function getOtherRadiosInGroup(radio) {
|
|
352
|
+
return getAllRadiosInGroup(radio).filter((r) => r !== radio);
|
|
353
|
+
}
|
|
354
|
+
function isElementInViewport(el) {
|
|
355
|
+
const rect = el.getBoundingClientRect();
|
|
356
|
+
const windowHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
357
|
+
const windowWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
358
|
+
const vertInView = rect.top <= windowHeight && rect.top + rect.height >= 0;
|
|
359
|
+
const horInView = rect.left <= windowWidth && rect.left + rect.width >= 0;
|
|
360
|
+
return vertInView && horInView;
|
|
361
|
+
}
|
|
2663
362
|
function requestSubmit(form) {
|
|
2664
363
|
if (form.requestSubmit) {
|
|
2665
364
|
form.requestSubmit();
|
|
@@ -2678,17 +377,11 @@ function requestReset(form) {
|
|
|
2678
377
|
}
|
|
2679
378
|
button.click();
|
|
2680
379
|
}
|
|
2681
|
-
function
|
|
380
|
+
function wrapArray(x) {
|
|
381
|
+
return Array.isArray(x) ? x : [x];
|
|
382
|
+
}
|
|
383
|
+
function useMixin(controller, setup, teardown) {
|
|
2682
384
|
const controllerDisconnect = controller.disconnect.bind(controller);
|
|
2683
|
-
let options = opts;
|
|
2684
|
-
if (options == null ? void 0 : options.debounce) {
|
|
2685
|
-
handler = debounce$1(handler.bind(controller), options.debounce);
|
|
2686
|
-
delete options.debounce;
|
|
2687
|
-
} else {
|
|
2688
|
-
handler = handler.bind(controller);
|
|
2689
|
-
}
|
|
2690
|
-
let setup = () => eventNames.forEach((eventName) => element.addEventListener(eventName, handler, options));
|
|
2691
|
-
let teardown = () => eventNames.forEach((eventName) => element.removeEventListener(eventName, handler));
|
|
2692
385
|
setup();
|
|
2693
386
|
Object.assign(controller, {
|
|
2694
387
|
disconnect() {
|
|
@@ -2696,15 +389,28 @@ function useEventListeners(controller, element, eventNames, handler, opts) {
|
|
|
2696
389
|
controllerDisconnect();
|
|
2697
390
|
}
|
|
2698
391
|
});
|
|
392
|
+
return controllerDisconnect;
|
|
393
|
+
}
|
|
394
|
+
function useEventListener(controller, element, eventNameOrNames, handler, opts) {
|
|
395
|
+
if (opts == null ? void 0 : opts.debounce) {
|
|
396
|
+
handler = debounce(handler.bind(controller), opts.debounce);
|
|
397
|
+
delete opts.debounce;
|
|
398
|
+
} else {
|
|
399
|
+
handler = handler.bind(controller);
|
|
400
|
+
}
|
|
401
|
+
let eventNames = wrapArray(eventNameOrNames);
|
|
402
|
+
let setup = () => eventNames.forEach((eventName) => element.addEventListener(eventName, handler, opts));
|
|
403
|
+
let teardown = () => eventNames.forEach((eventName) => element.removeEventListener(eventName, handler));
|
|
404
|
+
useMixin(controller, setup, teardown);
|
|
2699
405
|
return { setup, teardown };
|
|
2700
406
|
}
|
|
2701
|
-
function
|
|
2702
|
-
return
|
|
407
|
+
function useEventListeners(controller, element, eventNameOrNames, handler, opts) {
|
|
408
|
+
return useEventListener(controller, element, eventNameOrNames, handler, opts);
|
|
2703
409
|
}
|
|
2704
|
-
function
|
|
410
|
+
function useCollectionEventListener(controller, elements, eventNameOrNames, handler, opts) {
|
|
2705
411
|
let handlers = [];
|
|
2706
412
|
elements.forEach((el) => {
|
|
2707
|
-
let { setup, teardown } =
|
|
413
|
+
let { setup, teardown } = useEventListener(controller, el, eventNameOrNames, handler, opts);
|
|
2708
414
|
handlers.push({ setup, teardown });
|
|
2709
415
|
});
|
|
2710
416
|
return [
|
|
@@ -2712,95 +418,119 @@ function useCollectionEventListeners(controller, elements, eventNames, handler,
|
|
|
2712
418
|
() => handlers.forEach((h) => h.teardown())
|
|
2713
419
|
];
|
|
2714
420
|
}
|
|
2715
|
-
function
|
|
2716
|
-
return
|
|
2717
|
-
}
|
|
2718
|
-
function useInterval(controller, handler, interval) {
|
|
2719
|
-
const controllerDisconnect = controller.disconnect.bind(controller);
|
|
2720
|
-
handler = handler.bind(controller);
|
|
2721
|
-
let intervalHandle = null;
|
|
2722
|
-
let setup = () => intervalHandle = setInterval(handler, interval);
|
|
2723
|
-
let teardown = () => {
|
|
2724
|
-
if (intervalHandle !== null) {
|
|
2725
|
-
clearInterval(intervalHandle);
|
|
2726
|
-
}
|
|
2727
|
-
};
|
|
2728
|
-
setup();
|
|
2729
|
-
Object.assign(controller, {
|
|
2730
|
-
disconnect() {
|
|
2731
|
-
teardown();
|
|
2732
|
-
controllerDisconnect();
|
|
2733
|
-
}
|
|
2734
|
-
});
|
|
2735
|
-
return teardown;
|
|
421
|
+
function useCollectionEventListeners(controller, elements, eventNameOrNames, handler, opts) {
|
|
422
|
+
return useCollectionEventListener(controller, elements, eventNameOrNames, handler, opts);
|
|
2736
423
|
}
|
|
2737
424
|
function useFullscreen(controller, el) {
|
|
2738
|
-
const controllerDisconnect = controller.disconnect.bind(controller);
|
|
2739
425
|
let element = el || document.documentElement;
|
|
2740
426
|
let fullscreenOpen = document.fullscreenElement !== null;
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
async function exit() {
|
|
427
|
+
const updateFullscreenState = () => fullscreenOpen = document.fullscreenElement !== null;
|
|
428
|
+
const isFullscreen = () => fullscreenOpen;
|
|
429
|
+
const toggle = async () => fullscreenOpen ? await exit() : await enter();
|
|
430
|
+
let setup = () => document.addEventListener("fullscreenchange", updateFullscreenState);
|
|
431
|
+
let teardown = () => document.removeEventListener("fullscreenchange", updateFullscreenState);
|
|
432
|
+
const exit = async () => {
|
|
2748
433
|
if (document.exitFullscreen) {
|
|
2749
434
|
fullscreenOpen = false;
|
|
2750
435
|
await document.exitFullscreen();
|
|
2751
436
|
}
|
|
2752
|
-
}
|
|
2753
|
-
async
|
|
2754
|
-
if (fullscreenOpen) {
|
|
2755
|
-
await exit();
|
|
2756
|
-
}
|
|
2757
|
-
if (element.requestFullscreen) {
|
|
2758
|
-
await element.requestFullscreen();
|
|
2759
|
-
fullscreenOpen = true;
|
|
2760
|
-
}
|
|
2761
|
-
}
|
|
2762
|
-
async function toggle() {
|
|
437
|
+
};
|
|
438
|
+
const enter = async () => {
|
|
2763
439
|
if (fullscreenOpen) {
|
|
2764
|
-
await exit();
|
|
2765
|
-
} else {
|
|
2766
|
-
await enter();
|
|
2767
|
-
}
|
|
2768
|
-
}
|
|
2769
|
-
document.addEventListener("fullscreenchange", updateFullscreenState);
|
|
2770
|
-
Object.assign(controller, {
|
|
2771
|
-
disconnect() {
|
|
2772
|
-
document.removeEventListener("fullscreenchange", updateFullscreenState);
|
|
2773
|
-
controllerDisconnect();
|
|
440
|
+
await exit();
|
|
2774
441
|
}
|
|
2775
|
-
|
|
442
|
+
if (element.requestFullscreen) {
|
|
443
|
+
await element.requestFullscreen();
|
|
444
|
+
fullscreenOpen = true;
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
useMixin(controller, setup, teardown);
|
|
2776
448
|
return {
|
|
2777
449
|
isFullscreen,
|
|
2778
450
|
enter,
|
|
2779
451
|
exit,
|
|
2780
|
-
toggle
|
|
452
|
+
toggle,
|
|
453
|
+
teardown
|
|
2781
454
|
};
|
|
2782
455
|
}
|
|
2783
|
-
function
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
clearTimeout(timeoutHandle);
|
|
456
|
+
function reactive(object) {
|
|
457
|
+
if (object === null || typeof object !== "object") {
|
|
458
|
+
return object;
|
|
459
|
+
}
|
|
460
|
+
for (const property in object) {
|
|
461
|
+
if (Object.getOwnPropertyDescriptor(object, property) == void 0) {
|
|
462
|
+
continue;
|
|
2791
463
|
}
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
464
|
+
object[property] = reactive(object[property]);
|
|
465
|
+
}
|
|
466
|
+
return new Proxy(object, {
|
|
467
|
+
get(target, property) {
|
|
468
|
+
return target[property];
|
|
469
|
+
},
|
|
470
|
+
set(target, property, value) {
|
|
471
|
+
target[property] = reactive(value);
|
|
472
|
+
return true;
|
|
2798
473
|
}
|
|
2799
474
|
});
|
|
2800
|
-
|
|
475
|
+
}
|
|
476
|
+
function useGeolocation(controller, options = {}, update, error) {
|
|
477
|
+
if (update) {
|
|
478
|
+
update = update.bind(controller);
|
|
479
|
+
}
|
|
480
|
+
if (error) {
|
|
481
|
+
error = error.bind(controller);
|
|
482
|
+
}
|
|
483
|
+
const {
|
|
484
|
+
enableHighAccuracy = true,
|
|
485
|
+
maximumAge = 3e4,
|
|
486
|
+
timeout = 27e3
|
|
487
|
+
} = options;
|
|
488
|
+
const isSupported = navigator && "geolocation" in navigator;
|
|
489
|
+
const values = reactive({
|
|
490
|
+
locatedAt: null,
|
|
491
|
+
error: null,
|
|
492
|
+
coords: {
|
|
493
|
+
accuracy: 0,
|
|
494
|
+
latitude: Infinity,
|
|
495
|
+
longitude: Infinity,
|
|
496
|
+
altitude: null,
|
|
497
|
+
altitudeAccuracy: null,
|
|
498
|
+
heading: null,
|
|
499
|
+
speed: null
|
|
500
|
+
},
|
|
501
|
+
teardown: () => {
|
|
502
|
+
if (watcher) {
|
|
503
|
+
navigator.geolocation.clearWatch(watcher);
|
|
504
|
+
watcher = null;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
let setup = () => {
|
|
509
|
+
if (isSupported) {
|
|
510
|
+
watcher = navigator.geolocation.watchPosition((position) => {
|
|
511
|
+
values.locatedAt = position.timestamp;
|
|
512
|
+
values.coords = position.coords;
|
|
513
|
+
values.error = null;
|
|
514
|
+
if (update) {
|
|
515
|
+
update(position);
|
|
516
|
+
}
|
|
517
|
+
}, (err) => {
|
|
518
|
+
values.error = err;
|
|
519
|
+
if (error) {
|
|
520
|
+
error(err);
|
|
521
|
+
}
|
|
522
|
+
}, {
|
|
523
|
+
enableHighAccuracy,
|
|
524
|
+
maximumAge,
|
|
525
|
+
timeout
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
let watcher = null;
|
|
530
|
+
useMixin(controller, setup, values.teardown);
|
|
531
|
+
return values;
|
|
2801
532
|
}
|
|
2802
533
|
function useInjectedFragment(controller, targetElement, insertPosition, fragment, options = {}) {
|
|
2803
|
-
const controllerDisconnect = controller.disconnect.bind(controller);
|
|
2804
534
|
let nodes = Array.from(fragment.childNodes);
|
|
2805
535
|
let setup = () => {
|
|
2806
536
|
let parent = targetElement.parentElement;
|
|
@@ -2822,19 +552,8 @@ function useInjectedFragment(controller, targetElement, insertPosition, fragment
|
|
|
2822
552
|
break;
|
|
2823
553
|
}
|
|
2824
554
|
};
|
|
2825
|
-
let teardown;
|
|
2826
|
-
|
|
2827
|
-
teardown = () => nodes.forEach((node) => node.remove());
|
|
2828
|
-
} else {
|
|
2829
|
-
teardown = () => void 0;
|
|
2830
|
-
}
|
|
2831
|
-
setup();
|
|
2832
|
-
Object.assign(controller, {
|
|
2833
|
-
disconnect() {
|
|
2834
|
-
teardown();
|
|
2835
|
-
controllerDisconnect();
|
|
2836
|
-
}
|
|
2837
|
-
});
|
|
555
|
+
let teardown = options.cleanup ? () => nodes.forEach((node) => node.remove()) : () => void 0;
|
|
556
|
+
useMixin(controller, setup, teardown);
|
|
2838
557
|
return [nodes, teardown];
|
|
2839
558
|
}
|
|
2840
559
|
function useInjectedHTML(controller, targetElement, insertPosition, html, options = {}) {
|
|
@@ -2847,6 +566,128 @@ function useInjectedElement(controller, targetElement, insertPosition, element,
|
|
|
2847
566
|
let [nodes, teardown] = useInjectedFragment(controller, targetElement, insertPosition, fragment, options);
|
|
2848
567
|
return [nodes[0], teardown];
|
|
2849
568
|
}
|
|
569
|
+
const StorageSerializers = {
|
|
570
|
+
boolean: {
|
|
571
|
+
read: (v) => v === "true",
|
|
572
|
+
write: (v) => String(v)
|
|
573
|
+
},
|
|
574
|
+
object: {
|
|
575
|
+
read: (v) => JSON.parse(v),
|
|
576
|
+
write: (v) => JSON.stringify(v)
|
|
577
|
+
},
|
|
578
|
+
number: {
|
|
579
|
+
read: (v) => Number.parseFloat(v),
|
|
580
|
+
write: (v) => String(v)
|
|
581
|
+
},
|
|
582
|
+
any: {
|
|
583
|
+
read: (v) => v,
|
|
584
|
+
write: (v) => String(v)
|
|
585
|
+
},
|
|
586
|
+
string: {
|
|
587
|
+
read: (v) => v,
|
|
588
|
+
write: (v) => String(v)
|
|
589
|
+
},
|
|
590
|
+
map: {
|
|
591
|
+
read: (v) => new Map(JSON.parse(v)),
|
|
592
|
+
write: (v) => JSON.stringify(Array.from(v.entries()))
|
|
593
|
+
},
|
|
594
|
+
set: {
|
|
595
|
+
read: (v) => new Set(JSON.parse(v)),
|
|
596
|
+
write: (v) => JSON.stringify(Array.from(v.entries()))
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
function useLocalStorage(controller, key, defaultValue, opts) {
|
|
600
|
+
let type = "any";
|
|
601
|
+
let { writeDefaults } = opts;
|
|
602
|
+
if (defaultValue == null) {
|
|
603
|
+
type = "any";
|
|
604
|
+
}
|
|
605
|
+
if (defaultValue instanceof Set) {
|
|
606
|
+
type = "set";
|
|
607
|
+
}
|
|
608
|
+
if (defaultValue instanceof Map) {
|
|
609
|
+
type = "map";
|
|
610
|
+
}
|
|
611
|
+
if (typeof defaultValue === "boolean") {
|
|
612
|
+
type = "boolean";
|
|
613
|
+
}
|
|
614
|
+
if (typeof defaultValue === "string") {
|
|
615
|
+
type = "string";
|
|
616
|
+
}
|
|
617
|
+
if (typeof defaultValue === "object") {
|
|
618
|
+
type = "object";
|
|
619
|
+
}
|
|
620
|
+
if (Array.isArray(defaultValue)) {
|
|
621
|
+
type = "object";
|
|
622
|
+
}
|
|
623
|
+
if (!Number.isNaN(defaultValue)) {
|
|
624
|
+
type = "number";
|
|
625
|
+
}
|
|
626
|
+
let data = reactive({
|
|
627
|
+
value: defaultValue
|
|
628
|
+
});
|
|
629
|
+
let storage = localStorage;
|
|
630
|
+
const serializer = StorageSerializers[type];
|
|
631
|
+
const read = (event) => {
|
|
632
|
+
if (event && event.key !== key) {
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
try {
|
|
636
|
+
const rawValue = event ? event.newValue : storage.getItem(key);
|
|
637
|
+
if (rawValue == null) {
|
|
638
|
+
data.value = defaultValue;
|
|
639
|
+
if (writeDefaults && defaultValue !== null) {
|
|
640
|
+
storage.setItem(key, serializer.write(defaultValue));
|
|
641
|
+
}
|
|
642
|
+
} else {
|
|
643
|
+
data.value = serializer.read(rawValue);
|
|
644
|
+
}
|
|
645
|
+
} catch (e) {
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
read();
|
|
649
|
+
return {
|
|
650
|
+
get value() {
|
|
651
|
+
return data.value;
|
|
652
|
+
},
|
|
653
|
+
set value(value) {
|
|
654
|
+
data.value = value;
|
|
655
|
+
storage.setItem(key, serializer.write(value));
|
|
656
|
+
},
|
|
657
|
+
read
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
function useInterval(controller, handler, interval) {
|
|
661
|
+
handler = handler.bind(controller);
|
|
662
|
+
let intervalHandle = null;
|
|
663
|
+
let setup = () => intervalHandle = setInterval(handler, interval);
|
|
664
|
+
let teardown = () => {
|
|
665
|
+
if (intervalHandle !== null) {
|
|
666
|
+
clearInterval(intervalHandle);
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
useMixin(controller, setup, teardown);
|
|
670
|
+
return teardown;
|
|
671
|
+
}
|
|
672
|
+
function useTimeout(controller, handler, timeout) {
|
|
673
|
+
let controllerDisconnect;
|
|
674
|
+
let timeoutHandle = null;
|
|
675
|
+
handler = handler.bind(controller);
|
|
676
|
+
let newHandler = () => {
|
|
677
|
+
handler();
|
|
678
|
+
timeoutHandle = null;
|
|
679
|
+
Object.assign(controller, { disconnect: controllerDisconnect });
|
|
680
|
+
};
|
|
681
|
+
let setup = () => timeoutHandle = setTimeout(newHandler, timeout);
|
|
682
|
+
let teardown = () => {
|
|
683
|
+
if (timeoutHandle !== null) {
|
|
684
|
+
clearTimeout(timeoutHandle);
|
|
685
|
+
timeoutHandle = null;
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
controllerDisconnect = useMixin(controller, setup, teardown);
|
|
689
|
+
return teardown;
|
|
690
|
+
}
|
|
2850
691
|
async function fetchRetry(n, input, init) {
|
|
2851
692
|
try {
|
|
2852
693
|
return await fetch(input, init);
|
|
@@ -2918,343 +759,56 @@ __publicField(AsyncBlockController, "values", {
|
|
|
2918
759
|
selector: String,
|
|
2919
760
|
maxRetries: Number
|
|
2920
761
|
});
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
};
|
|
2928
|
-
}
|
|
2929
|
-
};
|
|
2930
|
-
const composeEventName = (name, controller, eventPrefix) => {
|
|
2931
|
-
let composedName = name;
|
|
2932
|
-
if (eventPrefix === true) {
|
|
2933
|
-
composedName = `${controller.identifier}:${name}`;
|
|
2934
|
-
} else if (typeof eventPrefix === "string") {
|
|
2935
|
-
composedName = `${eventPrefix}:${name}`;
|
|
2936
|
-
}
|
|
2937
|
-
return composedName;
|
|
2938
|
-
};
|
|
2939
|
-
const extendedEvent = (type, event, detail) => {
|
|
2940
|
-
const { bubbles, cancelable, composed } = event || { bubbles: true, cancelable: true, composed: true };
|
|
2941
|
-
if (event) {
|
|
2942
|
-
Object.assign(detail, { originalEvent: event });
|
|
2943
|
-
}
|
|
2944
|
-
const customEvent = new CustomEvent(type, {
|
|
2945
|
-
bubbles,
|
|
2946
|
-
cancelable,
|
|
2947
|
-
composed,
|
|
2948
|
-
detail
|
|
2949
|
-
});
|
|
2950
|
-
return customEvent;
|
|
2951
|
-
};
|
|
2952
|
-
function isElementInViewport(el) {
|
|
2953
|
-
const rect = el.getBoundingClientRect();
|
|
2954
|
-
const windowHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
2955
|
-
const windowWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
2956
|
-
const vertInView = rect.top <= windowHeight && rect.top + rect.height >= 0;
|
|
2957
|
-
const horInView = rect.left <= windowWidth && rect.left + rect.width >= 0;
|
|
2958
|
-
return vertInView && horInView;
|
|
2959
|
-
}
|
|
2960
|
-
const defaultOptions$2 = {
|
|
2961
|
-
dispatchEvent: true,
|
|
2962
|
-
eventPrefix: true
|
|
2963
|
-
};
|
|
2964
|
-
const useIntersection = (controller, options = {}) => {
|
|
2965
|
-
const { dispatchEvent, eventPrefix } = Object.assign({}, defaultOptions$2, options);
|
|
2966
|
-
const targetElement = (options === null || options === void 0 ? void 0 : options.element) || controller.element;
|
|
2967
|
-
const callback = (entries) => {
|
|
2968
|
-
const [entry] = entries;
|
|
2969
|
-
if (entry.isIntersecting) {
|
|
2970
|
-
dispatchAppear(entry);
|
|
2971
|
-
} else if (controller.isVisible) {
|
|
2972
|
-
dispatchDisappear(entry);
|
|
2973
|
-
}
|
|
2974
|
-
};
|
|
2975
|
-
const dispatchAppear = (entry) => {
|
|
2976
|
-
controller.isVisible = true;
|
|
2977
|
-
method(controller, "appear").call(controller, entry);
|
|
2978
|
-
if (dispatchEvent) {
|
|
2979
|
-
const eventName = composeEventName("appear", controller, eventPrefix);
|
|
2980
|
-
const appearEvent = extendedEvent(eventName, null, { controller, entry });
|
|
2981
|
-
targetElement.dispatchEvent(appearEvent);
|
|
2982
|
-
}
|
|
2983
|
-
};
|
|
2984
|
-
const dispatchDisappear = (entry) => {
|
|
2985
|
-
controller.isVisible = false;
|
|
2986
|
-
method(controller, "disappear").call(controller, entry);
|
|
2987
|
-
if (dispatchEvent) {
|
|
2988
|
-
const eventName = composeEventName("disappear", controller, eventPrefix);
|
|
2989
|
-
const disappearEvent = extendedEvent(eventName, null, { controller, entry });
|
|
2990
|
-
targetElement.dispatchEvent(disappearEvent);
|
|
2991
|
-
}
|
|
2992
|
-
};
|
|
2993
|
-
const controllerDisconnect = controller.disconnect.bind(controller);
|
|
2994
|
-
const observer = new IntersectionObserver(callback, options);
|
|
2995
|
-
const observe = () => {
|
|
2996
|
-
observer.observe(targetElement);
|
|
2997
|
-
};
|
|
2998
|
-
const unobserve = () => {
|
|
2999
|
-
observer.unobserve(targetElement);
|
|
3000
|
-
};
|
|
3001
|
-
Object.assign(controller, {
|
|
3002
|
-
isVisible: false,
|
|
3003
|
-
disconnect() {
|
|
3004
|
-
unobserve();
|
|
3005
|
-
controllerDisconnect();
|
|
3006
|
-
}
|
|
3007
|
-
});
|
|
3008
|
-
observe();
|
|
3009
|
-
return [observe, unobserve];
|
|
3010
|
-
};
|
|
3011
|
-
const defaultOptions$1 = {
|
|
3012
|
-
events: ["click", "touchend"],
|
|
3013
|
-
onlyVisible: true,
|
|
3014
|
-
dispatchEvent: true,
|
|
3015
|
-
eventPrefix: true
|
|
3016
|
-
};
|
|
3017
|
-
const useClickOutside = (controller, options = {}) => {
|
|
3018
|
-
const { onlyVisible, dispatchEvent, events, eventPrefix } = Object.assign({}, defaultOptions$1, options);
|
|
3019
|
-
const onEvent = (event) => {
|
|
3020
|
-
const targetElement = (options === null || options === void 0 ? void 0 : options.element) || controller.element;
|
|
3021
|
-
if (targetElement.contains(event.target) || !isElementInViewport(targetElement) && onlyVisible) {
|
|
3022
|
-
return;
|
|
3023
|
-
}
|
|
3024
|
-
if (controller.clickOutside) {
|
|
3025
|
-
controller.clickOutside(event);
|
|
3026
|
-
}
|
|
3027
|
-
if (dispatchEvent) {
|
|
3028
|
-
const eventName = composeEventName("click:outside", controller, eventPrefix);
|
|
3029
|
-
const clickOutsideEvent = extendedEvent(eventName, event, { controller });
|
|
3030
|
-
targetElement.dispatchEvent(clickOutsideEvent);
|
|
3031
|
-
}
|
|
3032
|
-
};
|
|
3033
|
-
const observe = () => {
|
|
3034
|
-
events === null || events === void 0 ? void 0 : events.forEach((event) => {
|
|
3035
|
-
window.addEventListener(event, onEvent, false);
|
|
3036
|
-
});
|
|
762
|
+
function useIntersectionObserver(controller, handler, options) {
|
|
763
|
+
handler = handler.bind(controller);
|
|
764
|
+
let observer = new IntersectionObserver(handler, options);
|
|
765
|
+
let teardown = () => {
|
|
766
|
+
observer == null ? void 0 : observer.disconnect();
|
|
767
|
+
observer = null;
|
|
3037
768
|
};
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
769
|
+
let observe = (element) => observer == null ? void 0 : observer.observe(element);
|
|
770
|
+
let unobserve = (element) => observer == null ? void 0 : observer.unobserve(element);
|
|
771
|
+
return {
|
|
772
|
+
observer,
|
|
773
|
+
teardown,
|
|
774
|
+
observe,
|
|
775
|
+
unobserve
|
|
3042
776
|
};
|
|
3043
|
-
const controllerDisconnect = controller.disconnect.bind(controller);
|
|
3044
|
-
Object.assign(controller, {
|
|
3045
|
-
disconnect() {
|
|
3046
|
-
unobserve();
|
|
3047
|
-
controllerDisconnect();
|
|
3048
|
-
}
|
|
3049
|
-
});
|
|
3050
|
-
observe();
|
|
3051
|
-
return [observe, unobserve];
|
|
3052
|
-
};
|
|
3053
|
-
const defaultOptions = {
|
|
3054
|
-
debug: false,
|
|
3055
|
-
logger: console,
|
|
3056
|
-
dispatchEvent: true,
|
|
3057
|
-
eventPrefix: true
|
|
3058
|
-
};
|
|
3059
|
-
class StimulusUse {
|
|
3060
|
-
constructor(controller, options = {}) {
|
|
3061
|
-
var _a, _b, _c;
|
|
3062
|
-
this.log = (functionName, args) => {
|
|
3063
|
-
if (!this.debug)
|
|
3064
|
-
return;
|
|
3065
|
-
this.logger.groupCollapsed(`%c${this.controller.identifier} %c#${functionName}`, "color: #3B82F6", "color: unset");
|
|
3066
|
-
this.logger.log(__spreadValues({
|
|
3067
|
-
controllerId: this.controllerId
|
|
3068
|
-
}, args));
|
|
3069
|
-
this.logger.groupEnd();
|
|
3070
|
-
};
|
|
3071
|
-
this.dispatch = (eventName, details = {}) => {
|
|
3072
|
-
if (this.dispatchEvent) {
|
|
3073
|
-
const _a2 = details, { event } = _a2, eventDetails = __objRest(_a2, ["event"]);
|
|
3074
|
-
const customEvent = this.extendedEvent(eventName, event || null, eventDetails);
|
|
3075
|
-
this.targetElement.dispatchEvent(customEvent);
|
|
3076
|
-
this.log("dispatchEvent", __spreadValues({ eventName: customEvent.type }, eventDetails));
|
|
3077
|
-
}
|
|
3078
|
-
};
|
|
3079
|
-
this.call = (methodName, args = {}) => {
|
|
3080
|
-
const method2 = this.controller[methodName];
|
|
3081
|
-
if (typeof method2 == "function") {
|
|
3082
|
-
return method2.call(this.controller, args);
|
|
3083
|
-
}
|
|
3084
|
-
};
|
|
3085
|
-
this.extendedEvent = (name, event, detail) => {
|
|
3086
|
-
const { bubbles, cancelable, composed } = event || { bubbles: true, cancelable: true, composed: true };
|
|
3087
|
-
if (event) {
|
|
3088
|
-
Object.assign(detail, { originalEvent: event });
|
|
3089
|
-
}
|
|
3090
|
-
const customEvent = new CustomEvent(this.composeEventName(name), {
|
|
3091
|
-
bubbles,
|
|
3092
|
-
cancelable,
|
|
3093
|
-
composed,
|
|
3094
|
-
detail
|
|
3095
|
-
});
|
|
3096
|
-
return customEvent;
|
|
3097
|
-
};
|
|
3098
|
-
this.composeEventName = (name) => {
|
|
3099
|
-
let composedName = name;
|
|
3100
|
-
if (this.eventPrefix === true) {
|
|
3101
|
-
composedName = `${this.controller.identifier}:${name}`;
|
|
3102
|
-
} else if (typeof this.eventPrefix === "string") {
|
|
3103
|
-
composedName = `${this.eventPrefix}:${name}`;
|
|
3104
|
-
}
|
|
3105
|
-
return composedName;
|
|
3106
|
-
};
|
|
3107
|
-
this.debug = (_b = (_a = options === null || options === void 0 ? void 0 : options.debug) !== null && _a !== void 0 ? _a : controller.application.stimulusUseDebug) !== null && _b !== void 0 ? _b : defaultOptions.debug;
|
|
3108
|
-
this.logger = (_c = options === null || options === void 0 ? void 0 : options.logger) !== null && _c !== void 0 ? _c : defaultOptions.logger;
|
|
3109
|
-
this.controller = controller;
|
|
3110
|
-
this.controllerId = controller.element.id || controller.element.dataset.id;
|
|
3111
|
-
this.targetElement = (options === null || options === void 0 ? void 0 : options.element) || controller.element;
|
|
3112
|
-
const { dispatchEvent, eventPrefix } = Object.assign({}, defaultOptions, options);
|
|
3113
|
-
Object.assign(this, { dispatchEvent, eventPrefix });
|
|
3114
|
-
this.controllerInitialize = controller.initialize.bind(controller);
|
|
3115
|
-
this.controllerConnect = controller.connect.bind(controller);
|
|
3116
|
-
this.controllerDisconnect = controller.disconnect.bind(controller);
|
|
3117
|
-
}
|
|
3118
|
-
}
|
|
3119
|
-
class UseHover extends StimulusUse {
|
|
3120
|
-
constructor(controller, options = {}) {
|
|
3121
|
-
super(controller, options);
|
|
3122
|
-
this.observe = () => {
|
|
3123
|
-
this.targetElement.addEventListener("mouseenter", this.onEnter);
|
|
3124
|
-
this.targetElement.addEventListener("mouseleave", this.onLeave);
|
|
3125
|
-
};
|
|
3126
|
-
this.unobserve = () => {
|
|
3127
|
-
this.targetElement.removeEventListener("mouseenter", this.onEnter);
|
|
3128
|
-
this.targetElement.removeEventListener("mouseleave", this.onLeave);
|
|
3129
|
-
};
|
|
3130
|
-
this.onEnter = (event) => {
|
|
3131
|
-
this.call("mouseEnter", event);
|
|
3132
|
-
this.log("mouseEnter", { hover: true });
|
|
3133
|
-
this.dispatch("mouseEnter", { hover: false });
|
|
3134
|
-
};
|
|
3135
|
-
this.onLeave = (event) => {
|
|
3136
|
-
this.call("mouseLeave", event);
|
|
3137
|
-
this.log("mouseLeave", { hover: false });
|
|
3138
|
-
this.dispatch("mouseLeave", { hover: false });
|
|
3139
|
-
};
|
|
3140
|
-
this.controller = controller;
|
|
3141
|
-
this.enhanceController();
|
|
3142
|
-
this.observe();
|
|
3143
|
-
}
|
|
3144
|
-
enhanceController() {
|
|
3145
|
-
const controllerDisconnect = this.controller.disconnect.bind(this.controller);
|
|
3146
|
-
const disconnect = () => {
|
|
3147
|
-
this.unobserve();
|
|
3148
|
-
controllerDisconnect();
|
|
3149
|
-
};
|
|
3150
|
-
Object.assign(this.controller, { disconnect });
|
|
3151
|
-
}
|
|
3152
777
|
}
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
};
|
|
3157
|
-
class UseMutation extends StimulusUse {
|
|
3158
|
-
constructor(controller, options = {}) {
|
|
3159
|
-
super(controller, options);
|
|
3160
|
-
this.observe = () => {
|
|
3161
|
-
try {
|
|
3162
|
-
this.observer.observe(this.targetElement, this.options);
|
|
3163
|
-
} catch (error2) {
|
|
3164
|
-
this.controller.application.handleError(error2, "At a minimum, one of childList, attributes, and/or characterData must be true", {});
|
|
3165
|
-
}
|
|
3166
|
-
};
|
|
3167
|
-
this.unobserve = () => {
|
|
3168
|
-
this.observer.disconnect();
|
|
3169
|
-
};
|
|
3170
|
-
this.mutation = (entries) => {
|
|
3171
|
-
this.call("mutate", entries);
|
|
3172
|
-
this.log("mutate", { entries });
|
|
3173
|
-
this.dispatch("mutate", { entries });
|
|
3174
|
-
};
|
|
3175
|
-
this.targetElement = (options === null || options === void 0 ? void 0 : options.element) || controller.element;
|
|
3176
|
-
this.controller = controller;
|
|
3177
|
-
this.options = options;
|
|
3178
|
-
this.observer = new MutationObserver(this.mutation);
|
|
3179
|
-
this.enhanceController();
|
|
3180
|
-
this.observe();
|
|
3181
|
-
}
|
|
3182
|
-
enhanceController() {
|
|
3183
|
-
const controllerDisconnect = this.controller.disconnect.bind(this.controller);
|
|
3184
|
-
const disconnect = () => {
|
|
3185
|
-
this.unobserve();
|
|
3186
|
-
controllerDisconnect();
|
|
3187
|
-
};
|
|
3188
|
-
Object.assign(this.controller, { disconnect });
|
|
778
|
+
function useIntersection(controller, element, appear, disappear, options) {
|
|
779
|
+
if (appear) {
|
|
780
|
+
appear = appear.bind(controller);
|
|
3189
781
|
}
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
};
|
|
3203
|
-
method(controller, "windowResize").call(controller, payload);
|
|
3204
|
-
};
|
|
3205
|
-
const controllerDisconnect = controller.disconnect.bind(controller);
|
|
3206
|
-
const observe = () => {
|
|
3207
|
-
window.addEventListener("resize", callback);
|
|
3208
|
-
callback();
|
|
3209
|
-
};
|
|
3210
|
-
const unobserve = () => {
|
|
3211
|
-
window.removeEventListener("resize", callback);
|
|
782
|
+
if (disappear) {
|
|
783
|
+
disappear = disappear.bind(controller);
|
|
784
|
+
}
|
|
785
|
+
let opts = options != null ? options : {};
|
|
786
|
+
let processEntries = (entries) => {
|
|
787
|
+
entries.forEach((entry) => {
|
|
788
|
+
if (entry.isIntersecting) {
|
|
789
|
+
appear && appear(entry);
|
|
790
|
+
} else {
|
|
791
|
+
disappear && disappear(entry);
|
|
792
|
+
}
|
|
793
|
+
});
|
|
3212
794
|
};
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
};
|
|
3222
|
-
class DebounceController extends Controller {
|
|
3223
|
-
}
|
|
3224
|
-
DebounceController.debounces = [];
|
|
3225
|
-
const defaultWait = 200;
|
|
3226
|
-
const debounce = (fn, wait = defaultWait) => {
|
|
3227
|
-
let timeoutId = null;
|
|
3228
|
-
return function() {
|
|
3229
|
-
const args = arguments;
|
|
3230
|
-
const context = this;
|
|
3231
|
-
const callback = () => fn.apply(context, args);
|
|
3232
|
-
if (timeoutId) {
|
|
3233
|
-
clearTimeout(timeoutId);
|
|
3234
|
-
}
|
|
3235
|
-
timeoutId = setTimeout(callback, wait);
|
|
795
|
+
let { observer, observe, unobserve, teardown } = useIntersectionObserver(controller, processEntries, opts);
|
|
796
|
+
let setup = () => observe(element);
|
|
797
|
+
useMixin(controller, setup, teardown);
|
|
798
|
+
return {
|
|
799
|
+
observer,
|
|
800
|
+
observe: () => observe(element),
|
|
801
|
+
unobserve: () => unobserve(element),
|
|
802
|
+
teardown
|
|
3236
803
|
};
|
|
3237
|
-
}
|
|
3238
|
-
const useDebounce = (controller, options) => {
|
|
3239
|
-
var _a;
|
|
3240
|
-
const constructor = controller.constructor;
|
|
3241
|
-
(_a = constructor.debounces) === null || _a === void 0 ? void 0 : _a.forEach((func) => {
|
|
3242
|
-
if (typeof func === "string") {
|
|
3243
|
-
controller[func] = debounce(controller[func], options === null || options === void 0 ? void 0 : options.wait);
|
|
3244
|
-
}
|
|
3245
|
-
if (typeof func === "object") {
|
|
3246
|
-
const { name, wait } = func;
|
|
3247
|
-
if (!name)
|
|
3248
|
-
return;
|
|
3249
|
-
controller[name] = debounce(controller[name], wait || (options === null || options === void 0 ? void 0 : options.wait));
|
|
3250
|
-
}
|
|
3251
|
-
});
|
|
3252
|
-
};
|
|
804
|
+
}
|
|
3253
805
|
class LazyBlockController extends LoadBlockController {
|
|
3254
806
|
async connect() {
|
|
3255
807
|
let element = this.el;
|
|
3256
808
|
if ("IntersectionObserver" in window) {
|
|
3257
|
-
|
|
809
|
+
let { observe, unobserve } = useIntersection(this, element, this.appear, null, { threshold: 0.3 });
|
|
810
|
+
this.observe = observe;
|
|
811
|
+
this.unobserve = unobserve;
|
|
3258
812
|
} else {
|
|
3259
813
|
await this.loadContent();
|
|
3260
814
|
}
|
|
@@ -3339,9 +893,8 @@ class AutoSubmitFormController extends BaseController {
|
|
|
3339
893
|
__publicField(AutoSubmitFormController, "values", { submitMode: String, eventMode: String, debounceInterval: Number });
|
|
3340
894
|
class AutosizeController extends BaseController {
|
|
3341
895
|
connect() {
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
this.unobserveIntersection = unobserveIntersection;
|
|
896
|
+
let { teardown } = useIntersection(this, this.el, this.appear);
|
|
897
|
+
this._unobserveIntersection = teardown;
|
|
3345
898
|
if (!isHTMLTextAreaElement(this.el)) {
|
|
3346
899
|
throw new Error(`Expected controller to be attached to a textarea, but was a '${this.el.tagName}'`);
|
|
3347
900
|
}
|
|
@@ -3349,13 +902,13 @@ class AutosizeController extends BaseController {
|
|
|
3349
902
|
this.el.style.resize = "none";
|
|
3350
903
|
this.el.style.boxSizing = "border-box";
|
|
3351
904
|
this._handler();
|
|
3352
|
-
|
|
3353
|
-
|
|
905
|
+
useEventListener(this, window, ["resize"], this._handler);
|
|
906
|
+
useEventListener(this, this.el, ["input", "change", "focus"], this._handler, { debounce: 100 });
|
|
3354
907
|
});
|
|
3355
908
|
}
|
|
3356
909
|
appear(_entry) {
|
|
3357
910
|
this.autosize(this.el);
|
|
3358
|
-
this.
|
|
911
|
+
this._unobserveIntersection();
|
|
3359
912
|
}
|
|
3360
913
|
_handler() {
|
|
3361
914
|
this.autosize(this.el);
|
|
@@ -3366,42 +919,58 @@ class AutosizeController extends BaseController {
|
|
|
3366
919
|
element.style.height = element.scrollHeight + offset + "px";
|
|
3367
920
|
}
|
|
3368
921
|
}
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
922
|
+
function controllerMethod(controller, methodName) {
|
|
923
|
+
const method = controller[methodName];
|
|
924
|
+
if (typeof method == "function") {
|
|
925
|
+
return method;
|
|
926
|
+
} else if (method != void 0) {
|
|
927
|
+
return () => method;
|
|
928
|
+
} else {
|
|
929
|
+
return () => void 0;
|
|
3372
930
|
}
|
|
3373
|
-
|
|
3374
|
-
|
|
931
|
+
}
|
|
932
|
+
function pascalCase(str) {
|
|
933
|
+
return upperFirst(camelCase(str));
|
|
934
|
+
}
|
|
935
|
+
function addMethodsForClassDefinition(controller, name) {
|
|
936
|
+
let defaultElement = controller.element;
|
|
937
|
+
let hasClass = () => controller[`has${pascalCase(name)}Class`] == true;
|
|
938
|
+
let classes = () => controller[`${name}Classes`];
|
|
939
|
+
let defaultClasses = () => controllerMethod(controller, `default${pascalCase(name)}Classes`).call(controller) || [];
|
|
940
|
+
let classOrDefault = () => hasClass() ? classes() : defaultClasses();
|
|
941
|
+
if (controller[`${name}Classes`] == void 0) {
|
|
942
|
+
Object.defineProperty(controller, `${name}Classes`, {
|
|
943
|
+
get: () => hasClass() ? controller[`${name}Class`].split(" ") : defaultClasses()
|
|
944
|
+
});
|
|
3375
945
|
}
|
|
946
|
+
let methods = {
|
|
947
|
+
[`add${pascalCase(name)}Classes`]: (element = defaultElement) => element.classList.add(...classOrDefault()),
|
|
948
|
+
[`remove${pascalCase(name)}Classes`]: (element = defaultElement) => element.classList.remove(...classOrDefault()),
|
|
949
|
+
[`${name}ClassesPresent`]: (element = defaultElement) => classOrDefault().every((klass) => element.classList.contains(klass))
|
|
950
|
+
};
|
|
951
|
+
console.log(methods);
|
|
952
|
+
Object.assign(controller, methods);
|
|
953
|
+
}
|
|
954
|
+
function installClassMethods(controller) {
|
|
955
|
+
let classes = controller.constructor.classes || [];
|
|
956
|
+
console.log(classes);
|
|
957
|
+
classes.forEach((classDefinition) => addMethodsForClassDefinition(controller, classDefinition));
|
|
958
|
+
}
|
|
959
|
+
class CharCountController extends BaseController {
|
|
3376
960
|
connect() {
|
|
961
|
+
installClassMethods(this);
|
|
3377
962
|
requestAnimationFrame(() => {
|
|
3378
963
|
useEventListener(this, this.inputTarget, "input", this._updateCharCount);
|
|
3379
964
|
this._updateCharCount();
|
|
3380
965
|
});
|
|
3381
966
|
}
|
|
3382
|
-
_addErrorClasses(el = this.el) {
|
|
3383
|
-
if (this.hasErrorClass) {
|
|
3384
|
-
el.classList.add(...this._errorClasses);
|
|
3385
|
-
} else {
|
|
3386
|
-
el.classList.add(...this._defaultErrorClasses);
|
|
3387
|
-
}
|
|
3388
|
-
}
|
|
3389
|
-
_removeErrorClasses(el = this.el) {
|
|
3390
|
-
if (this.hasErrorClass) {
|
|
3391
|
-
el.classList.remove(...this._errorClasses);
|
|
3392
|
-
} else {
|
|
3393
|
-
el.classList.remove(...this._defaultErrorClasses);
|
|
3394
|
-
}
|
|
3395
|
-
}
|
|
3396
967
|
_updateCharCount() {
|
|
3397
968
|
let charCount = this.inputTarget.value.length;
|
|
3398
969
|
this.outputTarget.innerText = charCount.toString();
|
|
3399
|
-
if (this.
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
this._addErrorClasses(this.outputTarget);
|
|
3404
|
-
}
|
|
970
|
+
if (this._isValidCount(charCount)) {
|
|
971
|
+
this.removeErrorClasses(this.outputTarget);
|
|
972
|
+
} else {
|
|
973
|
+
this.addErrorClasses(this.outputTarget);
|
|
3405
974
|
}
|
|
3406
975
|
}
|
|
3407
976
|
_isValidCount(count) {
|
|
@@ -3542,7 +1111,7 @@ class DetectDirtyController extends BaseController {
|
|
|
3542
1111
|
let element = this.el;
|
|
3543
1112
|
this._cacheLoadValues();
|
|
3544
1113
|
this._checkDirty();
|
|
3545
|
-
|
|
1114
|
+
useEventListener(this, element, ["input", "change"], this._checkDirty, { debounce: 10 });
|
|
3546
1115
|
}
|
|
3547
1116
|
restore(event) {
|
|
3548
1117
|
event == null ? void 0 : event.preventDefault();
|
|
@@ -3557,10 +1126,7 @@ class DetectDirtyController extends BaseController {
|
|
|
3557
1126
|
let value = element.getAttribute(this._cacheAttrName);
|
|
3558
1127
|
if (isElementCheckable(element)) {
|
|
3559
1128
|
return value == null ? element.defaultChecked : value == "true";
|
|
3560
|
-
} else if (
|
|
3561
|
-
return value;
|
|
3562
|
-
}
|
|
3563
|
-
if (isHTMLSelectElement(element)) {
|
|
1129
|
+
} else if (isHTMLSelectElement(element)) {
|
|
3564
1130
|
let options = Array.from(element.options);
|
|
3565
1131
|
options.forEach((option) => {
|
|
3566
1132
|
if (option.defaultSelected) {
|
|
@@ -3568,6 +1134,8 @@ class DetectDirtyController extends BaseController {
|
|
|
3568
1134
|
return option.value;
|
|
3569
1135
|
}
|
|
3570
1136
|
});
|
|
1137
|
+
} else if (value !== null) {
|
|
1138
|
+
return value;
|
|
3571
1139
|
}
|
|
3572
1140
|
return value;
|
|
3573
1141
|
}
|
|
@@ -3577,6 +1145,9 @@ class DetectDirtyController extends BaseController {
|
|
|
3577
1145
|
}
|
|
3578
1146
|
_checkDirty() {
|
|
3579
1147
|
let element = this.el;
|
|
1148
|
+
if (isHTMLInputElement(element) && element.type == "radio") {
|
|
1149
|
+
getOtherRadiosInGroup(element).forEach((radio) => radio.removeAttribute("data-dirty"));
|
|
1150
|
+
}
|
|
3580
1151
|
if (this._isElementDirty()) {
|
|
3581
1152
|
element.setAttribute("data-dirty", "true");
|
|
3582
1153
|
} else {
|
|
@@ -3631,7 +1202,7 @@ class DetectDirtyFormController extends BaseController {
|
|
|
3631
1202
|
let element = this.el;
|
|
3632
1203
|
this._cacheLoadValues();
|
|
3633
1204
|
this._checkDirty();
|
|
3634
|
-
|
|
1205
|
+
useEventListener(this, element, ["input", "change"], this._checkDirty, { debounce: 10 });
|
|
3635
1206
|
}
|
|
3636
1207
|
restore(event) {
|
|
3637
1208
|
event == null ? void 0 : event.preventDefault();
|
|
@@ -3644,10 +1215,7 @@ class DetectDirtyFormController extends BaseController {
|
|
|
3644
1215
|
let value = element.getAttribute(this._cacheAttrName);
|
|
3645
1216
|
if (isElementCheckable(element)) {
|
|
3646
1217
|
return value == null ? element.defaultChecked : value == "true";
|
|
3647
|
-
} else if (
|
|
3648
|
-
return value;
|
|
3649
|
-
}
|
|
3650
|
-
if (isHTMLSelectElement(element)) {
|
|
1218
|
+
} else if (isHTMLSelectElement(element)) {
|
|
3651
1219
|
let options = Array.from(element.options);
|
|
3652
1220
|
options.forEach((option) => {
|
|
3653
1221
|
if (option.defaultSelected) {
|
|
@@ -3655,6 +1223,8 @@ class DetectDirtyFormController extends BaseController {
|
|
|
3655
1223
|
return option.value;
|
|
3656
1224
|
}
|
|
3657
1225
|
});
|
|
1226
|
+
} else if (value !== null) {
|
|
1227
|
+
return value;
|
|
3658
1228
|
}
|
|
3659
1229
|
return value;
|
|
3660
1230
|
}
|
|
@@ -3662,6 +1232,9 @@ class DetectDirtyFormController extends BaseController {
|
|
|
3662
1232
|
return element.hasAttribute(this._cacheAttrName);
|
|
3663
1233
|
}
|
|
3664
1234
|
_checkElementDirty(element) {
|
|
1235
|
+
if (isHTMLInputElement(element) && element.type == "radio") {
|
|
1236
|
+
getOtherRadiosInGroup(element).forEach((radio) => radio.removeAttribute("data-dirty"));
|
|
1237
|
+
}
|
|
3665
1238
|
if (this._isElementDirty(element)) {
|
|
3666
1239
|
element.setAttribute("data-dirty", "true");
|
|
3667
1240
|
} else {
|
|
@@ -3932,10 +1505,7 @@ class NavigateFormErrorsController extends BaseController {
|
|
|
3932
1505
|
__publicField(this, "_errors", []);
|
|
3933
1506
|
__publicField(this, "_firstClick", false);
|
|
3934
1507
|
}
|
|
3935
|
-
get
|
|
3936
|
-
return this.currentClass.split(" ");
|
|
3937
|
-
}
|
|
3938
|
-
get _defaultCurrentClasses() {
|
|
1508
|
+
get defaultCurrentClasses() {
|
|
3939
1509
|
return ["currentError"];
|
|
3940
1510
|
}
|
|
3941
1511
|
get _errorCount() {
|
|
@@ -3969,9 +1539,10 @@ class NavigateFormErrorsController extends BaseController {
|
|
|
3969
1539
|
return this._errors[this._index];
|
|
3970
1540
|
}
|
|
3971
1541
|
get _otherErrors() {
|
|
3972
|
-
return this._errors.filter((
|
|
1542
|
+
return this._errors.filter((error, index) => index !== this._index);
|
|
3973
1543
|
}
|
|
3974
1544
|
connect() {
|
|
1545
|
+
installClassMethods(this);
|
|
3975
1546
|
requestAnimationFrame(() => {
|
|
3976
1547
|
this._firstClick = true;
|
|
3977
1548
|
this._toggleButtons();
|
|
@@ -4019,22 +1590,8 @@ class NavigateFormErrorsController extends BaseController {
|
|
|
4019
1590
|
this._toggleVisibility();
|
|
4020
1591
|
}
|
|
4021
1592
|
_updateClasses() {
|
|
4022
|
-
this.
|
|
4023
|
-
this._otherErrors.forEach((
|
|
4024
|
-
}
|
|
4025
|
-
_addCurrentClasses(el = this.el) {
|
|
4026
|
-
if (this.hasCurrentClass) {
|
|
4027
|
-
el.classList.add(...this._currentClasses);
|
|
4028
|
-
} else {
|
|
4029
|
-
el.classList.add(...this._defaultCurrentClasses);
|
|
4030
|
-
}
|
|
4031
|
-
}
|
|
4032
|
-
_removeCurrentClasses(el = this.el) {
|
|
4033
|
-
if (this.hasCurrentClass) {
|
|
4034
|
-
el.classList.remove(...this._currentClasses);
|
|
4035
|
-
} else {
|
|
4036
|
-
el.classList.remove(...this._defaultCurrentClasses);
|
|
4037
|
-
}
|
|
1593
|
+
this.addCurrentClasses(this._currentError);
|
|
1594
|
+
this._otherErrors.forEach((error) => this.removeCurrentClasses(error));
|
|
4038
1595
|
}
|
|
4039
1596
|
_toggleVisibility() {
|
|
4040
1597
|
if (this._errorCount === 0) {
|
|
@@ -4115,30 +1672,11 @@ __publicField(NestedFormController, "targets", ["target", "template"]);
|
|
|
4115
1672
|
__publicField(NestedFormController, "values", {
|
|
4116
1673
|
insertMode: String,
|
|
4117
1674
|
wrapperClass: String
|
|
4118
|
-
});
|
|
4119
|
-
class PasswordConfirmController extends BaseController {
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
get _defaultErrorClasses() {
|
|
4124
|
-
return [];
|
|
4125
|
-
}
|
|
4126
|
-
connect() {
|
|
4127
|
-
useCollectionEventListener(this, this.passwordTargets, "change", this._checkPasswordsMatch);
|
|
4128
|
-
}
|
|
4129
|
-
_addErrorClasses(el = this.el) {
|
|
4130
|
-
if (this.hasErrorClass) {
|
|
4131
|
-
el.classList.add(...this._errorClasses);
|
|
4132
|
-
} else {
|
|
4133
|
-
el.classList.add(...this._defaultErrorClasses);
|
|
4134
|
-
}
|
|
4135
|
-
}
|
|
4136
|
-
_removeErrorClasses(el = this.el) {
|
|
4137
|
-
if (this.hasErrorClass) {
|
|
4138
|
-
el.classList.remove(...this._errorClasses);
|
|
4139
|
-
} else {
|
|
4140
|
-
el.classList.remove(...this._defaultErrorClasses);
|
|
4141
|
-
}
|
|
1675
|
+
});
|
|
1676
|
+
class PasswordConfirmController extends BaseController {
|
|
1677
|
+
connect() {
|
|
1678
|
+
installClassMethods(this);
|
|
1679
|
+
useCollectionEventListener(this, this.passwordTargets, "change", this._checkPasswordsMatch);
|
|
4142
1680
|
}
|
|
4143
1681
|
_allPasswordsMatch() {
|
|
4144
1682
|
let values = new Set(this.passwordTargets.map((el) => el.value));
|
|
@@ -4148,14 +1686,10 @@ class PasswordConfirmController extends BaseController {
|
|
|
4148
1686
|
let element = this.el;
|
|
4149
1687
|
if (this._allPasswordsMatch()) {
|
|
4150
1688
|
this.dispatch(element, "password-confirm:match");
|
|
4151
|
-
|
|
4152
|
-
this.passwordTargets.forEach((el) => this._removeErrorClasses(el));
|
|
4153
|
-
}
|
|
1689
|
+
this.passwordTargets.forEach((el) => this.removeErrorClasses(el));
|
|
4154
1690
|
} else {
|
|
4155
1691
|
this.dispatch(element, "password-confirm:no-match");
|
|
4156
|
-
|
|
4157
|
-
this.passwordTargets.forEach((el) => this._addErrorClasses(el));
|
|
4158
|
-
}
|
|
1692
|
+
this.passwordTargets.forEach((el) => this.addErrorClasses(el));
|
|
4159
1693
|
}
|
|
4160
1694
|
}
|
|
4161
1695
|
}
|
|
@@ -4204,6 +1738,20 @@ class RemoteFormController extends BaseController {
|
|
|
4204
1738
|
}
|
|
4205
1739
|
__publicField(RemoteFormController, "targets", []);
|
|
4206
1740
|
__publicField(RemoteFormController, "values", { selector: String });
|
|
1741
|
+
function useEventBus(controller, eventNameOrNames, handler, opts) {
|
|
1742
|
+
let options = opts;
|
|
1743
|
+
if (options == null ? void 0 : options.debounce) {
|
|
1744
|
+
handler = debounce(handler.bind(controller), options.debounce);
|
|
1745
|
+
delete options.debounce;
|
|
1746
|
+
} else {
|
|
1747
|
+
handler = handler.bind(controller);
|
|
1748
|
+
}
|
|
1749
|
+
let eventNames = wrapArray(eventNameOrNames);
|
|
1750
|
+
let setup = () => eventNames.forEach((eventName) => EventBus.on(eventName, handler));
|
|
1751
|
+
let teardown = () => eventNames.forEach((eventName) => EventBus.off(eventName, handler));
|
|
1752
|
+
useMixin(controller, setup, teardown);
|
|
1753
|
+
return { setup, teardown };
|
|
1754
|
+
}
|
|
4207
1755
|
class SyncInputsController extends BaseController {
|
|
4208
1756
|
get _eventName() {
|
|
4209
1757
|
return `sync:${this._key}`;
|
|
@@ -4236,12 +1784,8 @@ class SyncInputsController extends BaseController {
|
|
|
4236
1784
|
el.innerHTML = val.toString();
|
|
4237
1785
|
}
|
|
4238
1786
|
}
|
|
4239
|
-
initialize() {
|
|
4240
|
-
this._read = this._read.bind(this);
|
|
4241
|
-
this._emit = this._emit.bind(this);
|
|
4242
|
-
}
|
|
4243
1787
|
connect() {
|
|
4244
|
-
|
|
1788
|
+
useEventBus(this, this._eventName, this._read);
|
|
4245
1789
|
requestAnimationFrame(() => {
|
|
4246
1790
|
if (isTypeOfFormInputElement(this.el)) {
|
|
4247
1791
|
this._emit();
|
|
@@ -4249,9 +1793,6 @@ class SyncInputsController extends BaseController {
|
|
|
4249
1793
|
}
|
|
4250
1794
|
});
|
|
4251
1795
|
}
|
|
4252
|
-
disconnect() {
|
|
4253
|
-
EventBus.off(this._eventName, this._read);
|
|
4254
|
-
}
|
|
4255
1796
|
_emit() {
|
|
4256
1797
|
EventBus.emit(this._eventName, { value: this._value, dispatcher: this.el });
|
|
4257
1798
|
}
|
|
@@ -4275,78 +1816,42 @@ class ValueWarnController extends BaseController {
|
|
|
4275
1816
|
get _minMessage() {
|
|
4276
1817
|
return this.hasMinMessageValue ? this.minMessageValue : `Value must be greater than ${this.minValue}`;
|
|
4277
1818
|
}
|
|
4278
|
-
get
|
|
4279
|
-
return this.warningHideClass.split(" ");
|
|
4280
|
-
}
|
|
4281
|
-
get _defaultWarningHideClasses() {
|
|
1819
|
+
get defaultWarningHideClasses() {
|
|
4282
1820
|
return ["hide"];
|
|
4283
1821
|
}
|
|
4284
|
-
get _inputWarningClasses() {
|
|
4285
|
-
return this.inputWarningClass.split(" ");
|
|
4286
|
-
}
|
|
4287
|
-
get _defaultInputWarningClasses() {
|
|
4288
|
-
return [""];
|
|
4289
|
-
}
|
|
4290
1822
|
connect() {
|
|
4291
|
-
|
|
1823
|
+
installClassMethods(this);
|
|
1824
|
+
this.addWarningHideClasses(this.warningTarget);
|
|
4292
1825
|
useEventListener(this, this.inputTarget, "input", this._check);
|
|
4293
1826
|
this._check();
|
|
4294
1827
|
}
|
|
4295
1828
|
_check() {
|
|
4296
1829
|
if (this.hasMinValue && Number.parseFloat(this.inputTarget.value) < this.minValue) {
|
|
4297
|
-
this.
|
|
4298
|
-
this.
|
|
1830
|
+
this.removeWarningHideClasses(this.warningTarget);
|
|
1831
|
+
this.addInputWarningClasses(this.inputTarget);
|
|
4299
1832
|
this.warningTarget.innerText = this._minMessage;
|
|
4300
1833
|
} else if (this.hasMaxValue && Number.parseFloat(this.inputTarget.value) > this.maxValue) {
|
|
4301
|
-
this.
|
|
4302
|
-
this.
|
|
1834
|
+
this.removeWarningHideClasses(this.warningTarget);
|
|
1835
|
+
this.addInputWarningClasses(this.inputTarget);
|
|
4303
1836
|
this.warningTarget.innerText = this._maxMessage;
|
|
4304
1837
|
} else {
|
|
4305
|
-
this.
|
|
4306
|
-
this.
|
|
1838
|
+
this.addWarningHideClasses(this.warningTarget);
|
|
1839
|
+
this.removeInputWarningClasses(this.inputTarget);
|
|
4307
1840
|
this.warningTarget.innerText = "";
|
|
4308
1841
|
}
|
|
4309
1842
|
}
|
|
4310
|
-
_addWarningHideClasses(el = this.el) {
|
|
4311
|
-
if (this.hasWarningHideClass) {
|
|
4312
|
-
el.classList.add(...this._warningHideClasses);
|
|
4313
|
-
} else {
|
|
4314
|
-
el.classList.add(...this._defaultWarningHideClasses);
|
|
4315
|
-
}
|
|
4316
|
-
}
|
|
4317
|
-
_removeWarningHideClasses(el = this.el) {
|
|
4318
|
-
if (this.hasWarningHideClass) {
|
|
4319
|
-
el.classList.remove(...this._warningHideClasses);
|
|
4320
|
-
} else {
|
|
4321
|
-
el.classList.remove(...this._defaultWarningHideClasses);
|
|
4322
|
-
}
|
|
4323
|
-
}
|
|
4324
|
-
_addInputWarningClasses(el = this.el) {
|
|
4325
|
-
if (this.hasInputWarningClass) {
|
|
4326
|
-
el.classList.add(...this._inputWarningClasses);
|
|
4327
|
-
} else {
|
|
4328
|
-
el.classList.add(...this._defaultInputWarningClasses);
|
|
4329
|
-
}
|
|
4330
|
-
}
|
|
4331
|
-
_removeInputWarningClasses(el = this.el) {
|
|
4332
|
-
if (this.hasInputWarningClass) {
|
|
4333
|
-
el.classList.remove(...this._inputWarningClasses);
|
|
4334
|
-
} else {
|
|
4335
|
-
el.classList.remove(...this._defaultInputWarningClasses);
|
|
4336
|
-
}
|
|
4337
|
-
}
|
|
4338
1843
|
}
|
|
4339
1844
|
__publicField(ValueWarnController, "classes", ["inputWarning", "warningHide"]);
|
|
4340
1845
|
__publicField(ValueWarnController, "targets", ["input", "warning"]);
|
|
4341
|
-
__publicField(ValueWarnController, "values", {
|
|
1846
|
+
__publicField(ValueWarnController, "values", {
|
|
1847
|
+
max: Number,
|
|
1848
|
+
min: Number,
|
|
1849
|
+
minMessage: String,
|
|
1850
|
+
maxMessage: String
|
|
1851
|
+
});
|
|
4342
1852
|
class WordCountController extends BaseController {
|
|
4343
|
-
get _errorClasses() {
|
|
4344
|
-
return this.errorClass.split(" ");
|
|
4345
|
-
}
|
|
4346
|
-
get _defaultErrorClasses() {
|
|
4347
|
-
return [];
|
|
4348
|
-
}
|
|
4349
1853
|
connect() {
|
|
1854
|
+
installClassMethods(this);
|
|
4350
1855
|
this._updateWordCount();
|
|
4351
1856
|
useEventListener(this, this.inputTarget, "input", this._updateWordCount);
|
|
4352
1857
|
}
|
|
@@ -4356,26 +1861,10 @@ class WordCountController extends BaseController {
|
|
|
4356
1861
|
let matches = textAreaValue.match(/\S+/g);
|
|
4357
1862
|
wordCount = matches && matches.length || 0;
|
|
4358
1863
|
this.outputTarget.innerText = wordCount.toString();
|
|
4359
|
-
if (this.
|
|
4360
|
-
|
|
4361
|
-
this._removeErrorClasses(this.outputTarget);
|
|
4362
|
-
} else {
|
|
4363
|
-
this._addErrorClasses(this.outputTarget);
|
|
4364
|
-
}
|
|
4365
|
-
}
|
|
4366
|
-
}
|
|
4367
|
-
_addErrorClasses(el = this.el) {
|
|
4368
|
-
if (this.hasErrorClass) {
|
|
4369
|
-
el.classList.add(...this._errorClasses);
|
|
1864
|
+
if (this._isValidCount(wordCount)) {
|
|
1865
|
+
this.removeErrorClasses(this.outputTarget);
|
|
4370
1866
|
} else {
|
|
4371
|
-
|
|
4372
|
-
}
|
|
4373
|
-
}
|
|
4374
|
-
_removeErrorClasses(el = this.el) {
|
|
4375
|
-
if (this.hasErrorClass) {
|
|
4376
|
-
el.classList.remove(...this._errorClasses);
|
|
4377
|
-
} else {
|
|
4378
|
-
el.classList.remove(...this._defaultErrorClasses);
|
|
1867
|
+
this.addErrorClasses(this.outputTarget);
|
|
4379
1868
|
}
|
|
4380
1869
|
}
|
|
4381
1870
|
_isValidCount(count) {
|
|
@@ -4394,18 +1883,6 @@ __publicField(WordCountController, "targets", ["input", "output"]);
|
|
|
4394
1883
|
__publicField(WordCountController, "values", { min: Number, max: Number });
|
|
4395
1884
|
__publicField(WordCountController, "classes", ["error"]);
|
|
4396
1885
|
class FallbackImageController extends BaseController {
|
|
4397
|
-
get _successClasses() {
|
|
4398
|
-
return this.successClass.split(" ");
|
|
4399
|
-
}
|
|
4400
|
-
get _defaultSuccessClasses() {
|
|
4401
|
-
return [];
|
|
4402
|
-
}
|
|
4403
|
-
get _failClasses() {
|
|
4404
|
-
return this.failClass.split(" ");
|
|
4405
|
-
}
|
|
4406
|
-
get _defaultFailClasses() {
|
|
4407
|
-
return [];
|
|
4408
|
-
}
|
|
4409
1886
|
initialize() {
|
|
4410
1887
|
this._hasLoadedSuccessfully = this._hasLoadedSuccessfully.bind(this);
|
|
4411
1888
|
this._success = this._success.bind(this);
|
|
@@ -4421,15 +1898,15 @@ class FallbackImageController extends BaseController {
|
|
|
4421
1898
|
}
|
|
4422
1899
|
}
|
|
4423
1900
|
disconnect() {
|
|
4424
|
-
this.
|
|
4425
|
-
this.
|
|
1901
|
+
this.removeSuccessClasses();
|
|
1902
|
+
this.removeFailClasses();
|
|
4426
1903
|
}
|
|
4427
1904
|
_success() {
|
|
4428
|
-
this.
|
|
1905
|
+
this.addSuccessClasses();
|
|
4429
1906
|
}
|
|
4430
1907
|
_fail() {
|
|
4431
1908
|
let element = this.el;
|
|
4432
|
-
this.
|
|
1909
|
+
this.addFailClasses();
|
|
4433
1910
|
if (this.hasPlaceholderValue && element.src !== this.placeholderValue) {
|
|
4434
1911
|
this.dispatch(element, "fallback-image:placeholder");
|
|
4435
1912
|
element.src = this.placeholderValue;
|
|
@@ -4443,34 +1920,6 @@ class FallbackImageController extends BaseController {
|
|
|
4443
1920
|
let element = this.el;
|
|
4444
1921
|
return element.naturalHeight > 0 && element.naturalWidth > 0;
|
|
4445
1922
|
}
|
|
4446
|
-
_addFailClasses(el = this.el) {
|
|
4447
|
-
if (this.hasFailClass) {
|
|
4448
|
-
el.classList.add(...this._failClasses);
|
|
4449
|
-
} else {
|
|
4450
|
-
el.classList.add(...this._defaultFailClasses);
|
|
4451
|
-
}
|
|
4452
|
-
}
|
|
4453
|
-
_removeFailClasses(el = this.el) {
|
|
4454
|
-
if (this.hasFailClass) {
|
|
4455
|
-
el.classList.remove(...this._failClasses);
|
|
4456
|
-
} else {
|
|
4457
|
-
el.classList.remove(...this._defaultFailClasses);
|
|
4458
|
-
}
|
|
4459
|
-
}
|
|
4460
|
-
_addSuccessClasses(el = this.el) {
|
|
4461
|
-
if (this.hasSuccessClass) {
|
|
4462
|
-
el.classList.add(...this._successClasses);
|
|
4463
|
-
} else {
|
|
4464
|
-
el.classList.add(...this._defaultSuccessClasses);
|
|
4465
|
-
}
|
|
4466
|
-
}
|
|
4467
|
-
_removeSuccessClasses(el = this.el) {
|
|
4468
|
-
if (this.hasSuccessClass) {
|
|
4469
|
-
el.classList.remove(...this._successClasses);
|
|
4470
|
-
} else {
|
|
4471
|
-
el.classList.remove(...this._defaultSuccessClasses);
|
|
4472
|
-
}
|
|
4473
|
-
}
|
|
4474
1923
|
}
|
|
4475
1924
|
__publicField(FallbackImageController, "values", { placeholder: String });
|
|
4476
1925
|
__publicField(FallbackImageController, "classes", ["success", "fail"]);
|
|
@@ -5109,12 +2558,6 @@ __publicField(LightboxImageController, "values", {
|
|
|
5109
2558
|
});
|
|
5110
2559
|
__publicField(LightboxImageController, "classes", ["modal", "image"]);
|
|
5111
2560
|
class MediaPlayerController extends BaseController {
|
|
5112
|
-
initialize() {
|
|
5113
|
-
}
|
|
5114
|
-
connect() {
|
|
5115
|
-
}
|
|
5116
|
-
disconnect() {
|
|
5117
|
-
}
|
|
5118
2561
|
async play(event) {
|
|
5119
2562
|
event == null ? void 0 : event.preventDefault();
|
|
5120
2563
|
await this.mediaTarget.play();
|
|
@@ -5268,123 +2711,145 @@ class ScrollToTopController extends BaseController {
|
|
|
5268
2711
|
__publicField(ScrollToTopController, "values", {
|
|
5269
2712
|
mode: String
|
|
5270
2713
|
});
|
|
2714
|
+
function extractPredicates(expressionString) {
|
|
2715
|
+
expressionString = expressionString.trim();
|
|
2716
|
+
let andExpression = expressionString.includes("&&");
|
|
2717
|
+
let orExpression = expressionString.includes("||");
|
|
2718
|
+
let groupings = expressionString.includes("(") || expressionString.includes(")");
|
|
2719
|
+
if (andExpression && orExpression) {
|
|
2720
|
+
throw new Error("Cannot have both && and || in the same expression.");
|
|
2721
|
+
}
|
|
2722
|
+
if (groupings) {
|
|
2723
|
+
throw new Error("Cannot have logical groupings `(>3 && <= 9) || (>1 && <2)` in the expression. Only supports simple expressions like `>1 && <3`");
|
|
2724
|
+
}
|
|
2725
|
+
let expressions = expressionString.split(andExpression ? "&&" : "||");
|
|
2726
|
+
if (andExpression) {
|
|
2727
|
+
return expressions.map((ex) => _predicateForExpression(ex));
|
|
2728
|
+
} else if (orExpression) {
|
|
2729
|
+
return expressions.map((ex) => _predicateForExpression(ex));
|
|
2730
|
+
} else {
|
|
2731
|
+
return [_predicateForExpression(expressionString)];
|
|
2732
|
+
}
|
|
2733
|
+
}
|
|
2734
|
+
function _predicateForExpression(expression) {
|
|
2735
|
+
let operators = [">=", "<=", "==", "!=", ">", "<"];
|
|
2736
|
+
let operator = operators.find((part) => expression.includes(part));
|
|
2737
|
+
if (!operator) {
|
|
2738
|
+
throw new Error(`Could not find operator in expression: ${expression}`);
|
|
2739
|
+
}
|
|
2740
|
+
let expressionValue = expression.split(operator)[1].trim();
|
|
2741
|
+
let isNumber = /^-?[0-9]\d*(\.\d+)?$/.test(expressionValue);
|
|
2742
|
+
expressionValue = isNumber ? parseFloat(expressionValue) : expressionValue;
|
|
2743
|
+
if (expressionValue == "") {
|
|
2744
|
+
throw new Error(`Could not find a value in expression: ${expression}`);
|
|
2745
|
+
}
|
|
2746
|
+
let notEmpty = (signalValue) => signalValue !== "";
|
|
2747
|
+
switch (operator) {
|
|
2748
|
+
case ">":
|
|
2749
|
+
return (signalValue) => isNumber && notEmpty(signalValue) && signalValue > expressionValue;
|
|
2750
|
+
case "<":
|
|
2751
|
+
return (signalValue) => isNumber && notEmpty(signalValue) && signalValue < expressionValue;
|
|
2752
|
+
case ">=":
|
|
2753
|
+
return (signalValue) => isNumber && notEmpty(signalValue) && signalValue >= expressionValue;
|
|
2754
|
+
case "<=":
|
|
2755
|
+
return (signalValue) => isNumber && notEmpty(signalValue) && signalValue <= expressionValue;
|
|
2756
|
+
case "==":
|
|
2757
|
+
return (signalValue) => notEmpty(signalValue) && signalValue == expressionValue;
|
|
2758
|
+
case "!=":
|
|
2759
|
+
return (signalValue) => notEmpty(signalValue) && signalValue != expressionValue;
|
|
2760
|
+
default:
|
|
2761
|
+
throw new Error(`Unknown operator ${operator}`);
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
function signalEventName(name, type) {
|
|
2765
|
+
return `signal:${type}:${name}`;
|
|
2766
|
+
}
|
|
2767
|
+
function signalConnectEvent(name) {
|
|
2768
|
+
return signalEventName(name, "connect");
|
|
2769
|
+
}
|
|
2770
|
+
function signalValueEvent(name) {
|
|
2771
|
+
return signalEventName(name, "value");
|
|
2772
|
+
}
|
|
2773
|
+
class SignalActionController extends BaseController {
|
|
2774
|
+
get _predicates() {
|
|
2775
|
+
return extractPredicates(this.whenValue);
|
|
2776
|
+
}
|
|
2777
|
+
connect() {
|
|
2778
|
+
EventBus.emit(signalConnectEvent(this.nameValue));
|
|
2779
|
+
useEventBus(this, signalValueEvent(this.nameValue), this._onSignal);
|
|
2780
|
+
}
|
|
2781
|
+
_onSignal(payload) {
|
|
2782
|
+
let value = payload.value;
|
|
2783
|
+
if (!this.hasWhenValue) {
|
|
2784
|
+
this.dispatch(this.el, signalEventName(this.nameValue, "match"));
|
|
2785
|
+
return;
|
|
2786
|
+
}
|
|
2787
|
+
if (this._predicates.every((predicate) => predicate(value))) {
|
|
2788
|
+
this.dispatch(this.el, signalEventName(this.nameValue, "match"), { detail: { element: this.el, value } });
|
|
2789
|
+
} else {
|
|
2790
|
+
this.dispatch(this.el, signalEventName(this.nameValue, "no-match"), { detail: { element: this.el, value } });
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
__publicField(SignalActionController, "values", {
|
|
2795
|
+
name: String,
|
|
2796
|
+
when: String
|
|
2797
|
+
});
|
|
5271
2798
|
class SignalInputController extends BaseController {
|
|
2799
|
+
get _debounceTimeout() {
|
|
2800
|
+
return this.hasDebounceIntervalValue ? this.debounceIntervalValue : null;
|
|
2801
|
+
}
|
|
5272
2802
|
get _name() {
|
|
5273
2803
|
return this.hasNameValue ? this.nameValue : this.element.name;
|
|
5274
2804
|
}
|
|
5275
|
-
get _eventName() {
|
|
5276
|
-
return `signal:value:${this._name}`;
|
|
5277
|
-
}
|
|
5278
2805
|
connect() {
|
|
5279
|
-
|
|
5280
|
-
|
|
2806
|
+
useEventBus(this, signalConnectEvent(this._name), () => this.emitValue());
|
|
2807
|
+
useEventListener(this, this.el, "input", this.emitValue, { debounce: this._debounceTimeout || void 0 });
|
|
2808
|
+
useEventListener(this, this.el, "change", this.emitValue);
|
|
5281
2809
|
requestAnimationFrame(() => this.emitValue());
|
|
5282
2810
|
}
|
|
5283
2811
|
emitValue() {
|
|
2812
|
+
var _a;
|
|
5284
2813
|
let value = this.el.value;
|
|
5285
2814
|
if (isHTMLInputElement(this.el) && this.el.type === "checkbox") {
|
|
5286
2815
|
value = this.el.checked ? "true" : "false";
|
|
2816
|
+
} else if (isHTMLInputElement(this.el) && this.el.type === "radio") {
|
|
2817
|
+
let selectedValue = (_a = getAllRadiosInGroup(this.el).find((el) => el.checked)) == null ? void 0 : _a.value;
|
|
2818
|
+
value = selectedValue ? selectedValue : "";
|
|
5287
2819
|
}
|
|
5288
|
-
EventBus.emit(this.
|
|
5289
|
-
element: this.el,
|
|
5290
|
-
value
|
|
5291
|
-
});
|
|
2820
|
+
EventBus.emit(signalValueEvent(this._name), { element: this.el, value });
|
|
5292
2821
|
}
|
|
5293
2822
|
}
|
|
5294
2823
|
__publicField(SignalInputController, "values", {
|
|
5295
|
-
name: String
|
|
2824
|
+
name: String,
|
|
2825
|
+
debounceInterval: Number
|
|
5296
2826
|
});
|
|
5297
2827
|
class SignalVisibilityController extends BaseController {
|
|
5298
2828
|
get _predicates() {
|
|
5299
|
-
|
|
5300
|
-
let andExpression = expressionString.includes("&&");
|
|
5301
|
-
let orExpression = expressionString.includes("||");
|
|
5302
|
-
let groupings = expressionString.includes("(") || expressionString.includes(")");
|
|
5303
|
-
if (andExpression && orExpression) {
|
|
5304
|
-
throw new Error("Cannot have both && and || in the same expression.");
|
|
5305
|
-
}
|
|
5306
|
-
if (groupings) {
|
|
5307
|
-
throw new Error("Cannot have logical groupings `(>3 && <= 9) || (>1 && <2)` in the expression. Only supports simple expressions like `>1 && <3`");
|
|
5308
|
-
}
|
|
5309
|
-
let expressions = expressionString.split(andExpression ? "&&" : "||");
|
|
5310
|
-
if (andExpression) {
|
|
5311
|
-
return expressions.map((ex) => this._predicateForExpression(ex));
|
|
5312
|
-
} else if (orExpression) {
|
|
5313
|
-
return expressions.map((ex) => this._predicateForExpression(ex));
|
|
5314
|
-
} else {
|
|
5315
|
-
return [this._predicateForExpression(expressionString)];
|
|
5316
|
-
}
|
|
2829
|
+
return extractPredicates(this.showValue);
|
|
5317
2830
|
}
|
|
5318
|
-
get
|
|
5319
|
-
return this.hideClass.split(" ");
|
|
5320
|
-
}
|
|
5321
|
-
get _defaultHideClasses() {
|
|
2831
|
+
get defaultHideClasses() {
|
|
5322
2832
|
return ["hide"];
|
|
5323
2833
|
}
|
|
5324
|
-
get _eventName() {
|
|
5325
|
-
return `signal:value:${this.nameValue}`;
|
|
5326
|
-
}
|
|
5327
|
-
_predicateForExpression(expression) {
|
|
5328
|
-
let operators = [">=", "<=", "==", "!=", ">", "<"];
|
|
5329
|
-
let operator = operators.find((part) => expression.includes(part));
|
|
5330
|
-
if (!operator) {
|
|
5331
|
-
throw new Error(`Could not find operator in expression: ${expression}`);
|
|
5332
|
-
}
|
|
5333
|
-
let expressionValue = expression.split(operator)[1];
|
|
5334
|
-
let isNumber = /^-?[0-9]\d*(\.\d+)?$/.test(expressionValue);
|
|
5335
|
-
expressionValue = isNumber ? parseFloat(expressionValue) : expressionValue;
|
|
5336
|
-
let notEmpty = (signalValue) => signalValue !== "";
|
|
5337
|
-
switch (operator) {
|
|
5338
|
-
case ">":
|
|
5339
|
-
return (signalValue) => isNumber && notEmpty(signalValue) && signalValue > expressionValue;
|
|
5340
|
-
case "<":
|
|
5341
|
-
return (signalValue) => isNumber && notEmpty(signalValue) && signalValue < expressionValue;
|
|
5342
|
-
case ">=":
|
|
5343
|
-
return (signalValue) => isNumber && notEmpty(signalValue) && signalValue >= expressionValue;
|
|
5344
|
-
case "<=":
|
|
5345
|
-
return (signalValue) => isNumber && notEmpty(signalValue) && signalValue <= expressionValue;
|
|
5346
|
-
case "==":
|
|
5347
|
-
return (signalValue) => notEmpty(signalValue) && signalValue == expressionValue;
|
|
5348
|
-
case "!=":
|
|
5349
|
-
return (signalValue) => notEmpty(signalValue) && signalValue != expressionValue;
|
|
5350
|
-
default:
|
|
5351
|
-
throw new Error(`Unknown operator ${operator}`);
|
|
5352
|
-
}
|
|
5353
|
-
}
|
|
5354
|
-
initialize() {
|
|
5355
|
-
this._onSignal = this._onSignal.bind(this);
|
|
5356
|
-
}
|
|
5357
2834
|
connect() {
|
|
5358
|
-
|
|
2835
|
+
installClassMethods(this);
|
|
2836
|
+
EventBus.emit(signalConnectEvent(this.nameValue));
|
|
2837
|
+
useEventBus(this, signalValueEvent(this.nameValue), this._onSignal);
|
|
5359
2838
|
}
|
|
5360
2839
|
_onSignal(payload) {
|
|
5361
2840
|
let value = payload.value;
|
|
5362
2841
|
if (this.showValue == "default") {
|
|
5363
2842
|
if (value == "") {
|
|
5364
|
-
this.
|
|
2843
|
+
this.removeHideClasses(this.el);
|
|
5365
2844
|
} else {
|
|
5366
|
-
this.
|
|
2845
|
+
this.addHideClasses(this.el);
|
|
5367
2846
|
}
|
|
5368
2847
|
return;
|
|
5369
2848
|
}
|
|
5370
2849
|
if (this._predicates.every((predicate) => predicate(value))) {
|
|
5371
|
-
this.
|
|
5372
|
-
} else {
|
|
5373
|
-
this._addHideClasses(this.el);
|
|
5374
|
-
}
|
|
5375
|
-
}
|
|
5376
|
-
_addHideClasses(el = this.el) {
|
|
5377
|
-
if (this.hasHideClass) {
|
|
5378
|
-
el.classList.add(...this._hideClasses);
|
|
2850
|
+
this.removeHideClasses(this.el);
|
|
5379
2851
|
} else {
|
|
5380
|
-
|
|
5381
|
-
}
|
|
5382
|
-
}
|
|
5383
|
-
_removeHideClasses(el = this.el) {
|
|
5384
|
-
if (this.hasHideClass) {
|
|
5385
|
-
el.classList.remove(...this._hideClasses);
|
|
5386
|
-
} else {
|
|
5387
|
-
el.classList.remove(...this._defaultHideClasses);
|
|
2852
|
+
this.addHideClasses(this.el);
|
|
5388
2853
|
}
|
|
5389
2854
|
}
|
|
5390
2855
|
}
|
|
@@ -5431,6 +2896,9 @@ class TableSortController extends BaseController {
|
|
|
5431
2896
|
event.preventDefault();
|
|
5432
2897
|
let headerCell = event.target;
|
|
5433
2898
|
let headerCellIndex = this._indexOfHeaderCell(headerCell);
|
|
2899
|
+
if (headerCell.dataset.sort == "false") {
|
|
2900
|
+
return;
|
|
2901
|
+
}
|
|
5434
2902
|
if (headerCell.dataset.sort == "asc") {
|
|
5435
2903
|
this._reverse = true;
|
|
5436
2904
|
this._otherHeaderCells(headerCell).forEach((cell) => delete cell.dataset.sort);
|
|
@@ -5483,6 +2951,14 @@ class TableSortController extends BaseController {
|
|
|
5483
2951
|
}
|
|
5484
2952
|
}
|
|
5485
2953
|
__publicField(TableSortController, "values", { startSort: Number });
|
|
2954
|
+
function useMutationObserver(controller, element, handler, options) {
|
|
2955
|
+
handler = handler.bind(controller);
|
|
2956
|
+
let observer = new MutationObserver(handler);
|
|
2957
|
+
let setup = () => observer.observe(element, options);
|
|
2958
|
+
let teardown = () => observer.disconnect();
|
|
2959
|
+
useMixin(controller, setup, teardown);
|
|
2960
|
+
return teardown;
|
|
2961
|
+
}
|
|
5486
2962
|
class TableTruncateController extends BaseController {
|
|
5487
2963
|
get _truncated() {
|
|
5488
2964
|
return this.hasTruncatedValue ? this.truncatedValue : false;
|
|
@@ -5499,12 +2975,8 @@ class TableTruncateController extends BaseController {
|
|
|
5499
2975
|
get _limit() {
|
|
5500
2976
|
return this.hasLimitValue ? this.limitValue : 20;
|
|
5501
2977
|
}
|
|
5502
|
-
initialize() {
|
|
5503
|
-
this.truncate = this.truncate.bind(this);
|
|
5504
|
-
this.expand = this.expand.bind(this);
|
|
5505
|
-
}
|
|
5506
2978
|
connect() {
|
|
5507
|
-
|
|
2979
|
+
useMutationObserver(this, this._tableBody, this.mutate, { childList: true });
|
|
5508
2980
|
requestAnimationFrame(() => {
|
|
5509
2981
|
this.truncate();
|
|
5510
2982
|
useEventListener(this, this.showMoreTarget, "click", this.expand);
|
|
@@ -5587,24 +3059,13 @@ class IntersectionController extends BaseController {
|
|
|
5587
3059
|
}
|
|
5588
3060
|
}
|
|
5589
3061
|
connect() {
|
|
5590
|
-
useIntersection(this, {
|
|
5591
|
-
threshold: this._threshold,
|
|
5592
|
-
element: this.el
|
|
5593
|
-
});
|
|
3062
|
+
useIntersection(this, this.el, this.appear, this.disappear, { threshold: this._threshold });
|
|
5594
3063
|
}
|
|
5595
3064
|
appear(entry) {
|
|
5596
|
-
this.dispatch(this.el, "intersection:appear"
|
|
5597
|
-
detail: {
|
|
5598
|
-
element: this.el
|
|
5599
|
-
}
|
|
5600
|
-
});
|
|
3065
|
+
this.dispatch(this.el, "intersection:appear");
|
|
5601
3066
|
}
|
|
5602
3067
|
disappear(entry) {
|
|
5603
|
-
this.dispatch(this.el, "intersection:disappear"
|
|
5604
|
-
detail: {
|
|
5605
|
-
element: this.el
|
|
5606
|
-
}
|
|
5607
|
-
});
|
|
3068
|
+
this.dispatch(this.el, "intersection:disappear");
|
|
5608
3069
|
}
|
|
5609
3070
|
}
|
|
5610
3071
|
__publicField(IntersectionController, "values", { threshold: String });
|
|
@@ -5659,7 +3120,7 @@ class TimeoutController extends BaseController {
|
|
|
5659
3120
|
__publicField(TimeoutController, "values", { seconds: Number });
|
|
5660
3121
|
class UserFocusController extends BaseController {
|
|
5661
3122
|
connect() {
|
|
5662
|
-
|
|
3123
|
+
useEventListener(this, window, ["focus", "blur"], this._handleVisibility);
|
|
5663
3124
|
useEventListener(this, document, "visibilitychange", this._handleVisibility);
|
|
5664
3125
|
requestAnimationFrame(() => {
|
|
5665
3126
|
this._handleVisibility();
|
|
@@ -5720,29 +3181,17 @@ class CountdownController extends BaseController {
|
|
|
5720
3181
|
get _removeUnused() {
|
|
5721
3182
|
return this.hasRemoveUnusedValue ? this.removeUnusedValue : false;
|
|
5722
3183
|
}
|
|
5723
|
-
get _endedClasses() {
|
|
5724
|
-
return this.endedClass.split(" ");
|
|
5725
|
-
}
|
|
5726
|
-
get _defaultEndedClasses() {
|
|
5727
|
-
return [];
|
|
5728
|
-
}
|
|
5729
|
-
get _countingDownClasses() {
|
|
5730
|
-
return this.countingDownClass.split(" ");
|
|
5731
|
-
}
|
|
5732
|
-
get _defaultCountingDownClasses() {
|
|
5733
|
-
return [];
|
|
5734
|
-
}
|
|
5735
3184
|
get _deadlineDate() {
|
|
5736
3185
|
return new Date(this.deadlineValue);
|
|
5737
3186
|
}
|
|
5738
3187
|
connect() {
|
|
5739
3188
|
this._interval = setInterval(this._tick.bind(this), 1e3);
|
|
5740
|
-
this.
|
|
3189
|
+
this.addCountingDownClasses();
|
|
5741
3190
|
}
|
|
5742
3191
|
disconnect() {
|
|
5743
3192
|
this._clearTick();
|
|
5744
|
-
this.
|
|
5745
|
-
this.
|
|
3193
|
+
this.removeCountingDownClasses();
|
|
3194
|
+
this.removeEndedClasses();
|
|
5746
3195
|
}
|
|
5747
3196
|
deadlineValueChanged() {
|
|
5748
3197
|
if (this._interval == null) {
|
|
@@ -5756,8 +3205,8 @@ class CountdownController extends BaseController {
|
|
|
5756
3205
|
if (isPast(this._deadlineDate)) {
|
|
5757
3206
|
distance = { years: 0, months: 0, days: 0, hours: 0, minutes: 0, seconds: 0 };
|
|
5758
3207
|
this._clearTick();
|
|
5759
|
-
this.
|
|
5760
|
-
this.
|
|
3208
|
+
this.removeCountingDownClasses();
|
|
3209
|
+
this.addEndedClasses();
|
|
5761
3210
|
this.dispatch(this.el, "countdown:ended");
|
|
5762
3211
|
} else {
|
|
5763
3212
|
distance = intervalToDuration({ start: this._deadlineDate, end: now });
|
|
@@ -5826,34 +3275,6 @@ class CountdownController extends BaseController {
|
|
|
5826
3275
|
_seconds(duration) {
|
|
5827
3276
|
return duration.seconds || 0;
|
|
5828
3277
|
}
|
|
5829
|
-
_addEndedClasses(el = this.el) {
|
|
5830
|
-
if (this.hasEndedClass) {
|
|
5831
|
-
el.classList.add(...this._endedClasses);
|
|
5832
|
-
} else {
|
|
5833
|
-
el.classList.add(...this._defaultEndedClasses);
|
|
5834
|
-
}
|
|
5835
|
-
}
|
|
5836
|
-
_removeEndedClasses(el = this.el) {
|
|
5837
|
-
if (this.hasEndedClass) {
|
|
5838
|
-
el.classList.remove(...this._endedClasses);
|
|
5839
|
-
} else {
|
|
5840
|
-
el.classList.remove(...this._defaultEndedClasses);
|
|
5841
|
-
}
|
|
5842
|
-
}
|
|
5843
|
-
_addCountingDownClasses(el = this.el) {
|
|
5844
|
-
if (this.hasCountingDownClass) {
|
|
5845
|
-
el.classList.add(...this._countingDownClasses);
|
|
5846
|
-
} else {
|
|
5847
|
-
el.classList.add(...this._defaultCountingDownClasses);
|
|
5848
|
-
}
|
|
5849
|
-
}
|
|
5850
|
-
_removeCountingDownClasses(el = this.el) {
|
|
5851
|
-
if (this.hasCountingDownClass) {
|
|
5852
|
-
el.classList.remove(...this._countingDownClasses);
|
|
5853
|
-
} else {
|
|
5854
|
-
el.classList.remove(...this._defaultCountingDownClasses);
|
|
5855
|
-
}
|
|
5856
|
-
}
|
|
5857
3278
|
}
|
|
5858
3279
|
__publicField(CountdownController, "values", { deadline: String, removeUnused: Boolean });
|
|
5859
3280
|
__publicField(CountdownController, "targets", ["years", "months", "days", "hours", "minutes", "seconds"]);
|
|
@@ -5929,16 +3350,10 @@ __publicField(DurationController, "values", {
|
|
|
5929
3350
|
seconds: Boolean
|
|
5930
3351
|
});
|
|
5931
3352
|
class TabsController extends BaseController {
|
|
5932
|
-
get
|
|
5933
|
-
return this.hideClass.split(" ");
|
|
5934
|
-
}
|
|
5935
|
-
get _defaultHideClasses() {
|
|
3353
|
+
get defaultHideClasses() {
|
|
5936
3354
|
return ["hide"];
|
|
5937
3355
|
}
|
|
5938
|
-
get
|
|
5939
|
-
return this.activeClass.split(" ");
|
|
5940
|
-
}
|
|
5941
|
-
get _defaultActiveClasses() {
|
|
3356
|
+
get defaultActiveClasses() {
|
|
5942
3357
|
return ["is-active"];
|
|
5943
3358
|
}
|
|
5944
3359
|
get _currentTab() {
|
|
@@ -5971,17 +3386,17 @@ class TabsController extends BaseController {
|
|
|
5971
3386
|
let activeLink = links[index];
|
|
5972
3387
|
let otherPanels = [...panels.slice(0, index), ...panels.slice(index + 1)];
|
|
5973
3388
|
let otherLinks = [...links.slice(0, index), ...links.slice(index + 1)];
|
|
5974
|
-
this.
|
|
3389
|
+
this.addActiveClasses(activeLink);
|
|
5975
3390
|
activeLink.setAttribute("aria-selected", "true");
|
|
5976
|
-
this.
|
|
5977
|
-
this.
|
|
3391
|
+
this.addActiveClasses(activePanel);
|
|
3392
|
+
this.removeHideClasses(activePanel);
|
|
5978
3393
|
otherLinks.forEach((link) => {
|
|
5979
3394
|
link.removeAttribute("aria-selected");
|
|
5980
|
-
this.
|
|
3395
|
+
this.removeActiveClasses(link);
|
|
5981
3396
|
});
|
|
5982
3397
|
otherPanels.forEach((panel) => {
|
|
5983
|
-
this.
|
|
5984
|
-
this.
|
|
3398
|
+
this.removeActiveClasses(panel);
|
|
3399
|
+
this.addHideClasses(panel);
|
|
5985
3400
|
});
|
|
5986
3401
|
}
|
|
5987
3402
|
_clampIndex(index) {
|
|
@@ -5992,48 +3407,18 @@ class TabsController extends BaseController {
|
|
|
5992
3407
|
this.contentTargets.forEach((content) => {
|
|
5993
3408
|
let hidden = content.hasAttribute("tab-hidden");
|
|
5994
3409
|
if (hidden) {
|
|
5995
|
-
this.
|
|
3410
|
+
this.removeHideClasses(content);
|
|
5996
3411
|
}
|
|
5997
3412
|
let height = content.offsetHeight;
|
|
5998
3413
|
if (height > minHeight) {
|
|
5999
3414
|
minHeight = height;
|
|
6000
3415
|
}
|
|
6001
3416
|
if (hidden) {
|
|
6002
|
-
this.
|
|
3417
|
+
this.addHideClasses(content);
|
|
6003
3418
|
}
|
|
6004
3419
|
});
|
|
6005
3420
|
this.contentTargets.forEach((content) => content.style.minHeight = minHeight + "px");
|
|
6006
3421
|
}
|
|
6007
|
-
_addHideClasses(el = this.el) {
|
|
6008
|
-
el.setAttribute("tab-hidden", "true");
|
|
6009
|
-
if (this.hasHideClass) {
|
|
6010
|
-
el.classList.add(...this._hideClasses);
|
|
6011
|
-
} else {
|
|
6012
|
-
el.classList.add(...this._defaultHideClasses);
|
|
6013
|
-
}
|
|
6014
|
-
}
|
|
6015
|
-
_removeHideClasses(el = this.el) {
|
|
6016
|
-
el.removeAttribute("tab-hidden");
|
|
6017
|
-
if (this.hasHideClass) {
|
|
6018
|
-
el.classList.remove(...this._hideClasses);
|
|
6019
|
-
} else {
|
|
6020
|
-
el.classList.remove(...this._defaultHideClasses);
|
|
6021
|
-
}
|
|
6022
|
-
}
|
|
6023
|
-
_addActiveClasses(el = this.el) {
|
|
6024
|
-
if (this.hasActiveClass) {
|
|
6025
|
-
el.classList.add(...this._activeClasses);
|
|
6026
|
-
} else {
|
|
6027
|
-
el.classList.add(...this._defaultActiveClasses);
|
|
6028
|
-
}
|
|
6029
|
-
}
|
|
6030
|
-
_removeActiveClasses(el = this.el) {
|
|
6031
|
-
if (this.hasActiveClass) {
|
|
6032
|
-
el.classList.remove(...this._activeClasses);
|
|
6033
|
-
} else {
|
|
6034
|
-
el.classList.remove(...this._defaultActiveClasses);
|
|
6035
|
-
}
|
|
6036
|
-
}
|
|
6037
3422
|
}
|
|
6038
3423
|
__publicField(TabsController, "values", { currentTab: Number, equalize: Boolean });
|
|
6039
3424
|
__publicField(TabsController, "targets", ["link", "content"]);
|
|
@@ -6059,9 +3444,6 @@ class TimeDistanceController extends BaseController {
|
|
|
6059
3444
|
timestampValueChanged() {
|
|
6060
3445
|
this._timestamp = toDate(this.timestampValue * 1e3);
|
|
6061
3446
|
}
|
|
6062
|
-
initialize() {
|
|
6063
|
-
this._update = this._update.bind(this);
|
|
6064
|
-
}
|
|
6065
3447
|
connect() {
|
|
6066
3448
|
if (!this.hasTimestampValue) {
|
|
6067
3449
|
throw new Error("Expected `timestampValue` to be present");
|
|
@@ -6082,24 +3464,19 @@ __publicField(TimeDistanceController, "values", {
|
|
|
6082
3464
|
timestamp: Number
|
|
6083
3465
|
});
|
|
6084
3466
|
class TreeViewController extends BaseController {
|
|
6085
|
-
get
|
|
6086
|
-
return
|
|
3467
|
+
get defaultActiveClasses() {
|
|
3468
|
+
return ["active"];
|
|
6087
3469
|
}
|
|
6088
|
-
get
|
|
3470
|
+
get defaultCollapsedClasses() {
|
|
6089
3471
|
return ["collapsed"];
|
|
6090
3472
|
}
|
|
6091
|
-
get _activeClasses() {
|
|
6092
|
-
return this.hasActiveClass ? this.activeClass.split(" ") : this._defaultActiveClasses;
|
|
6093
|
-
}
|
|
6094
|
-
get _defaultActiveClasses() {
|
|
6095
|
-
return ["active"];
|
|
6096
|
-
}
|
|
6097
3473
|
initialize() {
|
|
6098
3474
|
this._nodeClicked = this._nodeClicked.bind(this);
|
|
6099
3475
|
}
|
|
6100
3476
|
connect() {
|
|
3477
|
+
installClassMethods(this);
|
|
3478
|
+
useMutationObserver(this, this.el, this.mutate, { subtree: true, childList: true });
|
|
6101
3479
|
this._setup();
|
|
6102
|
-
useMutation(this, { subtree: true, childList: true });
|
|
6103
3480
|
}
|
|
6104
3481
|
disconnect() {
|
|
6105
3482
|
this._teardown();
|
|
@@ -6129,8 +3506,8 @@ class TreeViewController extends BaseController {
|
|
|
6129
3506
|
_teardownNode(el) {
|
|
6130
3507
|
[el, ...Array.from(el.querySelectorAll("ul, ol, li"))].forEach((x) => {
|
|
6131
3508
|
x.removeEventListener("click", this._nodeClicked);
|
|
6132
|
-
this.
|
|
6133
|
-
this.
|
|
3509
|
+
this.removeActiveClasses(x);
|
|
3510
|
+
this.removeCollapsedClasses(x);
|
|
6134
3511
|
});
|
|
6135
3512
|
}
|
|
6136
3513
|
_nodeClicked(event) {
|
|
@@ -6148,20 +3525,21 @@ class TreeViewController extends BaseController {
|
|
|
6148
3525
|
}
|
|
6149
3526
|
}
|
|
6150
3527
|
_nodeActive(el) {
|
|
6151
|
-
return this.
|
|
3528
|
+
return this.activeClassesPresent(el);
|
|
6152
3529
|
}
|
|
6153
3530
|
_showNode(el) {
|
|
6154
|
-
this.
|
|
6155
|
-
this.
|
|
3531
|
+
this.removeCollapsedClasses(el);
|
|
3532
|
+
this.addActiveClasses(el);
|
|
6156
3533
|
}
|
|
6157
3534
|
_hideNode(el) {
|
|
6158
|
-
this.
|
|
6159
|
-
this.
|
|
3535
|
+
this.removeActiveClasses(el);
|
|
3536
|
+
this.addCollapsedClasses(el);
|
|
6160
3537
|
}
|
|
6161
3538
|
_hasNested(el) {
|
|
6162
3539
|
return el.querySelectorAll("ul, ol").length > 0;
|
|
6163
3540
|
}
|
|
6164
3541
|
mutate(entries) {
|
|
3542
|
+
console.log("mutate", entries);
|
|
6165
3543
|
for (const mutation of entries) {
|
|
6166
3544
|
if (mutation.type === "childList") {
|
|
6167
3545
|
Array.from(mutation.addedNodes || []).forEach((el) => this._setupNode(el));
|
|
@@ -6169,50 +3547,16 @@ class TreeViewController extends BaseController {
|
|
|
6169
3547
|
}
|
|
6170
3548
|
}
|
|
6171
3549
|
}
|
|
6172
|
-
_addCollapsedClasses(el = this.el) {
|
|
6173
|
-
if (this.hasCollapsedClass) {
|
|
6174
|
-
el.classList.add(...this._collapsedClasses);
|
|
6175
|
-
} else {
|
|
6176
|
-
el.classList.add(...this._defaultCollapsedClasses);
|
|
6177
|
-
}
|
|
6178
|
-
}
|
|
6179
|
-
_removeCollapsedClasses(el = this.el) {
|
|
6180
|
-
if (this.hasCollapsedClass) {
|
|
6181
|
-
el.classList.remove(...this._collapsedClasses);
|
|
6182
|
-
} else {
|
|
6183
|
-
el.classList.remove(...this._defaultCollapsedClasses);
|
|
6184
|
-
}
|
|
6185
|
-
}
|
|
6186
|
-
_addActiveClasses(el = this.el) {
|
|
6187
|
-
if (this.hasActiveClass) {
|
|
6188
|
-
el.classList.add(...this._activeClasses);
|
|
6189
|
-
} else {
|
|
6190
|
-
el.classList.add(...this._defaultActiveClasses);
|
|
6191
|
-
}
|
|
6192
|
-
}
|
|
6193
|
-
_removeActiveClasses(el = this.el) {
|
|
6194
|
-
if (this.hasActiveClass) {
|
|
6195
|
-
el.classList.remove(...this._activeClasses);
|
|
6196
|
-
} else {
|
|
6197
|
-
el.classList.remove(...this._defaultActiveClasses);
|
|
6198
|
-
}
|
|
6199
|
-
}
|
|
6200
3550
|
}
|
|
6201
3551
|
__publicField(TreeViewController, "classes", [
|
|
6202
3552
|
"active",
|
|
6203
3553
|
"collapsed"
|
|
6204
3554
|
]);
|
|
6205
3555
|
class AnchorSpyController extends BaseController {
|
|
6206
|
-
get
|
|
6207
|
-
return this.activeClass.split(" ");
|
|
6208
|
-
}
|
|
6209
|
-
get _defaultActiveClasses() {
|
|
3556
|
+
get defaultActiveClasses() {
|
|
6210
3557
|
return ["active"];
|
|
6211
3558
|
}
|
|
6212
|
-
get
|
|
6213
|
-
return this.inactiveClass.split(" ");
|
|
6214
|
-
}
|
|
6215
|
-
get _defaultInactiveClasses() {
|
|
3559
|
+
get defaultInactiveClasses() {
|
|
6216
3560
|
return ["inactive"];
|
|
6217
3561
|
}
|
|
6218
3562
|
get _key() {
|
|
@@ -6225,6 +3569,7 @@ class AnchorSpyController extends BaseController {
|
|
|
6225
3569
|
window.location.hash = value;
|
|
6226
3570
|
}
|
|
6227
3571
|
connect() {
|
|
3572
|
+
installClassMethods(this);
|
|
6228
3573
|
requestAnimationFrame(() => {
|
|
6229
3574
|
this._checkAnchor();
|
|
6230
3575
|
useEventListener(this, window, "hashchange", this._checkAnchor);
|
|
@@ -6234,43 +3579,15 @@ class AnchorSpyController extends BaseController {
|
|
|
6234
3579
|
event == null ? void 0 : event.preventDefault();
|
|
6235
3580
|
this._anchor = this._key;
|
|
6236
3581
|
}
|
|
6237
|
-
_addActiveClasses(el = this.el) {
|
|
6238
|
-
if (this.hasActiveClass) {
|
|
6239
|
-
el.classList.add(...this._activeClasses);
|
|
6240
|
-
} else {
|
|
6241
|
-
el.classList.add(...this._defaultActiveClasses);
|
|
6242
|
-
}
|
|
6243
|
-
}
|
|
6244
|
-
_removeActiveClasses(el = this.el) {
|
|
6245
|
-
if (this.hasActiveClass) {
|
|
6246
|
-
el.classList.remove(...this._activeClasses);
|
|
6247
|
-
} else {
|
|
6248
|
-
el.classList.remove(...this._defaultActiveClasses);
|
|
6249
|
-
}
|
|
6250
|
-
}
|
|
6251
|
-
_addInactiveClasses(el = this.el) {
|
|
6252
|
-
if (this.hasInactiveClass) {
|
|
6253
|
-
el.classList.add(...this._inactiveClasses);
|
|
6254
|
-
} else {
|
|
6255
|
-
el.classList.add(...this._defaultInactiveClasses);
|
|
6256
|
-
}
|
|
6257
|
-
}
|
|
6258
|
-
_removeInactiveClasses(el = this.el) {
|
|
6259
|
-
if (this.hasInactiveClass) {
|
|
6260
|
-
el.classList.remove(...this._inactiveClasses);
|
|
6261
|
-
} else {
|
|
6262
|
-
el.classList.remove(...this._defaultInactiveClasses);
|
|
6263
|
-
}
|
|
6264
|
-
}
|
|
6265
3582
|
_checkAnchor() {
|
|
6266
3583
|
if (this._key === this._anchor) {
|
|
6267
3584
|
this.dispatch(this.el, "anchor-spy:active");
|
|
6268
|
-
this.
|
|
6269
|
-
this.
|
|
3585
|
+
this.addActiveClasses(this.el);
|
|
3586
|
+
this.removeInactiveClasses(this.el);
|
|
6270
3587
|
} else {
|
|
6271
3588
|
this.dispatch(this.el, "anchor-spy:inactive");
|
|
6272
|
-
this.
|
|
6273
|
-
this.
|
|
3589
|
+
this.addInactiveClasses(this.el);
|
|
3590
|
+
this.removeActiveClasses(this.el);
|
|
6274
3591
|
}
|
|
6275
3592
|
}
|
|
6276
3593
|
}
|
|
@@ -6363,16 +3680,11 @@ class ConfirmNavigationController extends BaseController {
|
|
|
6363
3680
|
get _message() {
|
|
6364
3681
|
return this.hasMessageValue ? this.messageValue : "Do you want to leave this page? Changes you made may not be saved";
|
|
6365
3682
|
}
|
|
6366
|
-
initialize() {
|
|
6367
|
-
this.allowSubmit = this.allowSubmit.bind(this);
|
|
6368
|
-
this.confirmNavigation = this.confirmNavigation.bind(this);
|
|
6369
|
-
this.confirmTurboNavigation = this.confirmTurboNavigation.bind(this);
|
|
6370
|
-
}
|
|
6371
3683
|
connect() {
|
|
6372
3684
|
window.onbeforeunload = () => this._message;
|
|
6373
3685
|
useEventListener(this, window, "popstate", this.confirmNavigation);
|
|
6374
3686
|
useEventListener(this, window, "submit", this.allowSubmit);
|
|
6375
|
-
|
|
3687
|
+
useEventListener(this, window, ["turbolinks:before-visit", "turbo:before-visit"], this.confirmTurboNavigation);
|
|
6376
3688
|
}
|
|
6377
3689
|
disconnect() {
|
|
6378
3690
|
window.onbeforeunload = null;
|
|
@@ -6408,12 +3720,10 @@ class DisableWithController extends BaseController {
|
|
|
6408
3720
|
get _timeout() {
|
|
6409
3721
|
return this.hasTimeoutValue ? this.timeoutValue : 1e3;
|
|
6410
3722
|
}
|
|
6411
|
-
initialize() {
|
|
6412
|
-
}
|
|
6413
3723
|
connect() {
|
|
6414
3724
|
requestAnimationFrame(() => {
|
|
6415
|
-
|
|
6416
|
-
|
|
3725
|
+
useEventListener(this, this.el, ["click"], this.disable);
|
|
3726
|
+
useEventListener(this, window, ["turbo:load", "turbolinks:load"], this._enable);
|
|
6417
3727
|
});
|
|
6418
3728
|
}
|
|
6419
3729
|
disable(event) {
|
|
@@ -6560,18 +3870,6 @@ class EmptyDomController extends BaseController {
|
|
|
6560
3870
|
get _container() {
|
|
6561
3871
|
return this.hasContainerTarget ? this.containerTarget : this.el;
|
|
6562
3872
|
}
|
|
6563
|
-
get _notEmptyClasses() {
|
|
6564
|
-
return this.notEmptyClass.split(" ");
|
|
6565
|
-
}
|
|
6566
|
-
get _defaultNotEmptyClasses() {
|
|
6567
|
-
return [];
|
|
6568
|
-
}
|
|
6569
|
-
get _emptyClasses() {
|
|
6570
|
-
return this.emptyClass.split(" ");
|
|
6571
|
-
}
|
|
6572
|
-
get _defaultEmptyClasses() {
|
|
6573
|
-
return [];
|
|
6574
|
-
}
|
|
6575
3873
|
get _children() {
|
|
6576
3874
|
let element = this._container;
|
|
6577
3875
|
if (this.hasScopeSelectorValue) {
|
|
@@ -6581,7 +3879,8 @@ class EmptyDomController extends BaseController {
|
|
|
6581
3879
|
}
|
|
6582
3880
|
}
|
|
6583
3881
|
connect() {
|
|
6584
|
-
|
|
3882
|
+
installClassMethods(this);
|
|
3883
|
+
useMutationObserver(this, this._container, this.mutate, { childList: true });
|
|
6585
3884
|
this.checkEmpty();
|
|
6586
3885
|
}
|
|
6587
3886
|
mutate(entries) {
|
|
@@ -6591,43 +3890,15 @@ class EmptyDomController extends BaseController {
|
|
|
6591
3890
|
let element = this._container;
|
|
6592
3891
|
let children = this._children;
|
|
6593
3892
|
if (children.length === 0) {
|
|
6594
|
-
this.
|
|
6595
|
-
this.
|
|
3893
|
+
this.removeNotEmptyClasses();
|
|
3894
|
+
this.addEmptyClasses();
|
|
6596
3895
|
this.dispatch(element, "dom:empty");
|
|
6597
3896
|
} else {
|
|
6598
|
-
this.
|
|
6599
|
-
this.
|
|
3897
|
+
this.addNotEmptyClasses();
|
|
3898
|
+
this.removeEmptyClasses();
|
|
6600
3899
|
this.dispatch(element, "dom:not-empty", { detail: { count: children.length } });
|
|
6601
3900
|
}
|
|
6602
3901
|
}
|
|
6603
|
-
_addNotEmptyClasses(el = this.el) {
|
|
6604
|
-
if (this.hasNotEmptyClass) {
|
|
6605
|
-
el.classList.add(...this._notEmptyClasses);
|
|
6606
|
-
} else {
|
|
6607
|
-
el.classList.add(...this._defaultNotEmptyClasses);
|
|
6608
|
-
}
|
|
6609
|
-
}
|
|
6610
|
-
_removeNotEmptyClasses(el = this.el) {
|
|
6611
|
-
if (this.hasNotEmptyClass) {
|
|
6612
|
-
el.classList.remove(...this._notEmptyClasses);
|
|
6613
|
-
} else {
|
|
6614
|
-
el.classList.remove(...this._defaultNotEmptyClasses);
|
|
6615
|
-
}
|
|
6616
|
-
}
|
|
6617
|
-
_addEmptyClasses(el = this.el) {
|
|
6618
|
-
if (this.hasEmptyClass) {
|
|
6619
|
-
el.classList.add(...this._emptyClasses);
|
|
6620
|
-
} else {
|
|
6621
|
-
el.classList.add(...this._defaultEmptyClasses);
|
|
6622
|
-
}
|
|
6623
|
-
}
|
|
6624
|
-
_removeEmptyClasses(el = this.el) {
|
|
6625
|
-
if (this.hasEmptyClass) {
|
|
6626
|
-
el.classList.remove(...this._emptyClasses);
|
|
6627
|
-
} else {
|
|
6628
|
-
el.classList.remove(...this._defaultEmptyClasses);
|
|
6629
|
-
}
|
|
6630
|
-
}
|
|
6631
3902
|
}
|
|
6632
3903
|
__publicField(EmptyDomController, "targets", ["container"]);
|
|
6633
3904
|
__publicField(EmptyDomController, "classes", ["empty", "notEmpty"]);
|
|
@@ -6699,32 +3970,16 @@ class PrefetchController extends BaseController {
|
|
|
6699
3970
|
}
|
|
6700
3971
|
__publicField(PrefetchController, "values", { mode: String });
|
|
6701
3972
|
class PrintButtonController extends PrintController {
|
|
6702
|
-
get
|
|
6703
|
-
return this.unsupportedClass.split(" ");
|
|
6704
|
-
}
|
|
6705
|
-
get _defaultUnsupportedClasses() {
|
|
3973
|
+
get defaultUnsupportedClasses() {
|
|
6706
3974
|
return ["unsupported"];
|
|
6707
3975
|
}
|
|
6708
3976
|
connect() {
|
|
3977
|
+
installClassMethods(this);
|
|
6709
3978
|
if (!("print" in window)) {
|
|
6710
|
-
this.
|
|
3979
|
+
this.addUnsupportedClasses();
|
|
6711
3980
|
}
|
|
6712
3981
|
useEventListener(this, this.el, "click", this.print);
|
|
6713
3982
|
}
|
|
6714
|
-
_addUnsupportedClasses(el = this.el) {
|
|
6715
|
-
if (this.hasUnsupportedClass) {
|
|
6716
|
-
el.classList.add(...this._unsupportedClasses);
|
|
6717
|
-
} else {
|
|
6718
|
-
el.classList.add(...this._defaultUnsupportedClasses);
|
|
6719
|
-
}
|
|
6720
|
-
}
|
|
6721
|
-
_removeUnsupportedClasses(el = this.el) {
|
|
6722
|
-
if (this.hasUnsupportedClass) {
|
|
6723
|
-
el.classList.remove(...this._unsupportedClasses);
|
|
6724
|
-
} else {
|
|
6725
|
-
el.classList.remove(...this._defaultUnsupportedClasses);
|
|
6726
|
-
}
|
|
6727
|
-
}
|
|
6728
3983
|
}
|
|
6729
3984
|
__publicField(PrintButtonController, "classes", [
|
|
6730
3985
|
"unsupported"
|
|
@@ -6746,14 +4001,10 @@ class ResponsiveIframeWrapperController extends BaseController {
|
|
|
6746
4001
|
class ResponsiveIframeBodyController extends BaseController {
|
|
6747
4002
|
connect() {
|
|
6748
4003
|
if (window.self !== window.top) {
|
|
6749
|
-
|
|
6750
|
-
useDebounce(this, {});
|
|
4004
|
+
useEventListener(this, window, "resize", this.postUpdate, { debounce: 200 });
|
|
6751
4005
|
this.postUpdate();
|
|
6752
4006
|
}
|
|
6753
4007
|
}
|
|
6754
|
-
windowResize(payload) {
|
|
6755
|
-
this.postUpdate();
|
|
6756
|
-
}
|
|
6757
4008
|
postUpdate() {
|
|
6758
4009
|
let payload = { name: "iframe-body", height: this.getHeight() };
|
|
6759
4010
|
window.parent.postMessage(payload, "*");
|
|
@@ -6764,7 +4015,6 @@ class ResponsiveIframeBodyController extends BaseController {
|
|
|
6764
4015
|
return Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
|
|
6765
4016
|
}
|
|
6766
4017
|
}
|
|
6767
|
-
__publicField(ResponsiveIframeBodyController, "debounces", ["postUpdate"]);
|
|
6768
4018
|
class SelfDestructController extends BaseController {
|
|
6769
4019
|
connect() {
|
|
6770
4020
|
requestAnimationFrame(() => {
|
|
@@ -6778,10 +4028,7 @@ class StickyController extends BaseController {
|
|
|
6778
4028
|
super(...arguments);
|
|
6779
4029
|
__publicField(this, "_magicElement", null);
|
|
6780
4030
|
}
|
|
6781
|
-
get
|
|
6782
|
-
return this.stuckClass.split(" ");
|
|
6783
|
-
}
|
|
6784
|
-
get _defaultStuckClasses() {
|
|
4031
|
+
get defaultStuckClasses() {
|
|
6785
4032
|
return ["stuck"];
|
|
6786
4033
|
}
|
|
6787
4034
|
get _mode() {
|
|
@@ -6804,9 +4051,9 @@ class StickyController extends BaseController {
|
|
|
6804
4051
|
return;
|
|
6805
4052
|
}
|
|
6806
4053
|
if (entry.intersectionRatio === 0) {
|
|
6807
|
-
this.
|
|
4054
|
+
this.addStuckClasses();
|
|
6808
4055
|
} else if (entry.intersectionRatio === 1) {
|
|
6809
|
-
this.
|
|
4056
|
+
this.removeStuckClasses();
|
|
6810
4057
|
}
|
|
6811
4058
|
});
|
|
6812
4059
|
}, {
|
|
@@ -6814,20 +4061,6 @@ class StickyController extends BaseController {
|
|
|
6814
4061
|
});
|
|
6815
4062
|
observer.observe(this._magicElement);
|
|
6816
4063
|
}
|
|
6817
|
-
_addStuckClasses(el = this.el) {
|
|
6818
|
-
if (this.hasStuckClass) {
|
|
6819
|
-
el.classList.add(...this._stuckClasses);
|
|
6820
|
-
} else {
|
|
6821
|
-
el.classList.add(...this._defaultStuckClasses);
|
|
6822
|
-
}
|
|
6823
|
-
}
|
|
6824
|
-
_removeStuckClasses(el = this.el) {
|
|
6825
|
-
if (this.hasStuckClass) {
|
|
6826
|
-
el.classList.remove(...this._stuckClasses);
|
|
6827
|
-
} else {
|
|
6828
|
-
el.classList.remove(...this._defaultStuckClasses);
|
|
6829
|
-
}
|
|
6830
|
-
}
|
|
6831
4064
|
}
|
|
6832
4065
|
__publicField(StickyController, "classes", ["stuck"]);
|
|
6833
4066
|
__publicField(StickyController, "values", { mode: String });
|
|
@@ -6901,10 +4134,6 @@ class TemporaryStateController extends EphemeralController {
|
|
|
6901
4134
|
}
|
|
6902
4135
|
throw new Error("Expected `secondsValue` to be present");
|
|
6903
4136
|
}
|
|
6904
|
-
initialize() {
|
|
6905
|
-
this.setState = this.setState.bind(this);
|
|
6906
|
-
this.removeState = this.removeState.bind(this);
|
|
6907
|
-
}
|
|
6908
4137
|
connect() {
|
|
6909
4138
|
this.setState();
|
|
6910
4139
|
useTimeout(this, this.removeState, this._seconds);
|
|
@@ -6930,22 +4159,63 @@ function applyTemporaryState(element, propertyString, value, seconds, controller
|
|
|
6930
4159
|
if (!element.dataset.controller || !((_a = element.dataset.controller) == null ? void 0 : _a.includes(controllerIdentifier))) {
|
|
6931
4160
|
element.dataset.controller = (element.dataset.controller || ` ${controllerIdentifier} `).trim().replaceAll(" ", " ");
|
|
6932
4161
|
}
|
|
6933
|
-
element[camelCase
|
|
6934
|
-
element[camelCase
|
|
4162
|
+
element[camelCase(`${controllerIdentifier}-attribute-value`)] = propertyString;
|
|
4163
|
+
element[camelCase(`${controllerIdentifier}-seconds-value`)] = seconds.toString();
|
|
6935
4164
|
}
|
|
6936
4165
|
function applyTemporaryClass(element, value, seconds) {
|
|
6937
4166
|
applyTemporaryState(element, "className", value, seconds);
|
|
6938
4167
|
}
|
|
4168
|
+
function useClickOutside(controller, element, callback) {
|
|
4169
|
+
callback = callback.bind(controller);
|
|
4170
|
+
const handler = (event) => {
|
|
4171
|
+
if (element.contains(event.target) || !isElementInViewport(element)) {
|
|
4172
|
+
return;
|
|
4173
|
+
}
|
|
4174
|
+
callback(event);
|
|
4175
|
+
};
|
|
4176
|
+
let { teardown } = useEventListener(controller, window, ["click", "touchend"], handler);
|
|
4177
|
+
useMixin(controller, () => void 0, teardown);
|
|
4178
|
+
return {
|
|
4179
|
+
teardown
|
|
4180
|
+
};
|
|
4181
|
+
}
|
|
4182
|
+
function useHover(controller, element, enter, leave) {
|
|
4183
|
+
let teardownEnter = null;
|
|
4184
|
+
let teardownLeave = null;
|
|
4185
|
+
if (enter) {
|
|
4186
|
+
enter = enter.bind(controller);
|
|
4187
|
+
let { teardown: _teardownEnter } = useEventListener(controller, element, "mouseenter", enter);
|
|
4188
|
+
teardownEnter = _teardownEnter;
|
|
4189
|
+
}
|
|
4190
|
+
if (leave) {
|
|
4191
|
+
leave = leave.bind(controller);
|
|
4192
|
+
let { teardown: _teardownLeave } = useEventListener(controller, element, "mouseleave", leave);
|
|
4193
|
+
teardownLeave = _teardownLeave;
|
|
4194
|
+
}
|
|
4195
|
+
let setup = () => void 0;
|
|
4196
|
+
let teardown = () => {
|
|
4197
|
+
if (teardownEnter) {
|
|
4198
|
+
teardownEnter();
|
|
4199
|
+
}
|
|
4200
|
+
if (teardownLeave) {
|
|
4201
|
+
teardownLeave();
|
|
4202
|
+
}
|
|
4203
|
+
};
|
|
4204
|
+
useMixin(controller, setup, teardown);
|
|
4205
|
+
return {
|
|
4206
|
+
teardown
|
|
4207
|
+
};
|
|
4208
|
+
}
|
|
6939
4209
|
class ToggleClassController extends BaseController {
|
|
6940
4210
|
connect() {
|
|
6941
4211
|
if (!this.hasClassValue) {
|
|
6942
4212
|
throw new Error("data-toggle-class-class-value must not be empty");
|
|
6943
4213
|
}
|
|
6944
4214
|
if (this.hasMouseEnterValue || this.hasMouseLeaveValue) {
|
|
6945
|
-
useHover(this);
|
|
4215
|
+
useHover(this, this.el, this.mouseEnter, this.mouseLeave);
|
|
6946
4216
|
}
|
|
6947
4217
|
if (this.hasClickAwayValue && this.clickAwayValue) {
|
|
6948
|
-
useClickOutside(this);
|
|
4218
|
+
useClickOutside(this, this.el, this.clickOutside);
|
|
6949
4219
|
}
|
|
6950
4220
|
requestAnimationFrame(() => {
|
|
6951
4221
|
if (this.hasInitialValue) {
|
|
@@ -7046,16 +4316,7 @@ __publicField(ToggleClassController, "values", {
|
|
|
7046
4316
|
clickAway: Boolean,
|
|
7047
4317
|
initial: String
|
|
7048
4318
|
});
|
|
7049
|
-
function
|
|
7050
|
-
const method2 = controller[methodName];
|
|
7051
|
-
if (typeof method2 == "function") {
|
|
7052
|
-
return method2;
|
|
7053
|
-
} else {
|
|
7054
|
-
return () => {
|
|
7055
|
-
};
|
|
7056
|
-
}
|
|
7057
|
-
}
|
|
7058
|
-
function installsTrixBehaviour(controller) {
|
|
4319
|
+
function useTrixModifiers(controller) {
|
|
7059
4320
|
const controllerDisconnect = controller.disconnect.bind(controller);
|
|
7060
4321
|
let observing = false;
|
|
7061
4322
|
let observerCallback = (entries, observer2) => {
|
|
@@ -7117,9 +4378,6 @@ function installsTrixBehaviour(controller) {
|
|
|
7117
4378
|
});
|
|
7118
4379
|
}
|
|
7119
4380
|
class TrixModifierController extends BaseController {
|
|
7120
|
-
connect() {
|
|
7121
|
-
installsTrixBehaviour(this);
|
|
7122
|
-
}
|
|
7123
4381
|
get enabledBehaviours() {
|
|
7124
4382
|
let enabled = (datasetProp) => datasetProp !== void 0 && datasetProp !== "false";
|
|
7125
4383
|
let behaviourIfEnabled = (datasetProp, trixInstallable) => enabled(datasetProp) ? [trixInstallable] : [];
|
|
@@ -7137,15 +4395,6 @@ class TrixModifierController extends BaseController {
|
|
|
7137
4395
|
...behaviourIfEnabled(this.el.dataset.noFileUploads, this.fileUploads)
|
|
7138
4396
|
];
|
|
7139
4397
|
}
|
|
7140
|
-
install(elements) {
|
|
7141
|
-
this.enabledBehaviours.forEach((behaviour) => behaviour.install(elements));
|
|
7142
|
-
}
|
|
7143
|
-
pasteEvent(event) {
|
|
7144
|
-
this.enabledBehaviours.forEach((behaviour) => behaviour.pasteEvent && behaviour.pasteEvent(event));
|
|
7145
|
-
}
|
|
7146
|
-
uninstall(elements) {
|
|
7147
|
-
this.enabledBehaviours.forEach((behaviour) => behaviour.uninstall(elements));
|
|
7148
|
-
}
|
|
7149
4398
|
get bold() {
|
|
7150
4399
|
return this.formattingHandlers(".trix-button--icon-bold", "bold");
|
|
7151
4400
|
}
|
|
@@ -7203,6 +4452,18 @@ class TrixModifierController extends BaseController {
|
|
|
7203
4452
|
}
|
|
7204
4453
|
};
|
|
7205
4454
|
}
|
|
4455
|
+
connect() {
|
|
4456
|
+
useTrixModifiers(this);
|
|
4457
|
+
}
|
|
4458
|
+
install(elements) {
|
|
4459
|
+
this.enabledBehaviours.forEach((behaviour) => behaviour.install(elements));
|
|
4460
|
+
}
|
|
4461
|
+
pasteEvent(event) {
|
|
4462
|
+
this.enabledBehaviours.forEach((behaviour) => behaviour.pasteEvent && behaviour.pasteEvent(event));
|
|
4463
|
+
}
|
|
4464
|
+
uninstall(elements) {
|
|
4465
|
+
this.enabledBehaviours.forEach((behaviour) => behaviour.uninstall(elements));
|
|
4466
|
+
}
|
|
7206
4467
|
simpleHideShowHandlers(selector) {
|
|
7207
4468
|
return {
|
|
7208
4469
|
install: ({ toolbar: toolbar2 }) => this.hideToolbarSelector(toolbar2, selector),
|
|
@@ -7320,5 +4581,5 @@ __publicField(TurboFrameRefreshController, "values", {
|
|
|
7320
4581
|
interval: Number,
|
|
7321
4582
|
poll: Boolean
|
|
7322
4583
|
});
|
|
7323
|
-
export { AlertController, AnchorSpyController, AsyncBlockController, AutoSubmitFormController, AutosizeController, BackLinkController, BaseController, CharCountController, CheckboxDisableInputsController, CheckboxEnableInputsController, CheckboxSelectAllController, CheckboxXORController, ClipboardController, ClockController, ConfirmController, ConfirmNavigationController, CountdownController, DebugController, DetectDirtyController, DetectDirtyFormController, DisableWithController, DismissableController, DurationController, ElementSaveController, EmptyDomController, EnableInputsController, EphemeralController, EventBus, FallbackImageController, FocusStealController, FormRcController, FormSaveController, FullscreenController, IntersectionController, IntervalController, LazyBlockController, LightboxImageController, LimitedSelectionCheckboxesController, LoadBlockController, MediaPlayerController, NavigateFormErrorsController, NestedFormController, PasswordConfirmController, PasswordPeekController, PollBlockController, PrefetchController, PresenceController, PrintButtonController, PrintController, RemoteFormController, RemoveController, ResponsiveIframeBodyController, ResponsiveIframeWrapperController, ScrollContainerController, ScrollIntoFocusController, ScrollToBottomController, ScrollToController, ScrollToTopController, SelfDestructController, SignalInputController, SignalVisibilityController, StickyController, SyncInputsController, TableSortController, TableTruncateController, TabsController, TeleportController, TemporaryStateController, TimeDistanceController, TimeoutController, ToggleClassController, TreeViewController, TrixModifierController, TurboFrameRCController, TurboFrameRefreshController, UserFocusController, ValueWarnController, WordCountController, applyTemporaryClass, applyTemporaryState, createHiddenButton, createHiddenInput, getScrollParent, insertElement, insertHiddenButton, insertHiddenInput, isDirty, isElementCheckable, isFormDirty, isHTMLAnchorElement, isHTMLButtonElement, isHTMLFormElement, isHTMLImageElement, isHTMLInputElement, isHTMLLinkElement, isHTMLSelectElement, isHTMLTextAreaElement, isTurboFrame, isTypeOfFormInputElement, requestReset, requestSubmit, scrollAbsoluteBottom, scrollAbsoluteLeft, scrollAbsoluteRight, scrollAbsoluteTop, scrollDown, scrollLeft, scrollRight, scrollToElement, scrollUp, useCollectionEventListener, useCollectionEventListeners, useEventListener, useEventListeners, useFullscreen, useInjectedElement, useInjectedFragment, useInjectedHTML, useInterval, useTimeout };
|
|
4584
|
+
export { AlertController, AnchorSpyController, AsyncBlockController, AutoSubmitFormController, AutosizeController, BackLinkController, BaseController, CharCountController, CheckboxDisableInputsController, CheckboxEnableInputsController, CheckboxSelectAllController, CheckboxXORController, ClipboardController, ClockController, ConfirmController, ConfirmNavigationController, CountdownController, DebugController, DetectDirtyController, DetectDirtyFormController, DisableWithController, DismissableController, DurationController, ElementSaveController, EmptyDomController, EnableInputsController, EphemeralController, EventBus, FallbackImageController, FocusStealController, FormRcController, FormSaveController, FullscreenController, IntersectionController, IntervalController, LazyBlockController, LightboxImageController, LimitedSelectionCheckboxesController, LoadBlockController, MediaPlayerController, NavigateFormErrorsController, NestedFormController, PasswordConfirmController, PasswordPeekController, PollBlockController, PrefetchController, PresenceController, PrintButtonController, PrintController, RemoteFormController, RemoveController, ResponsiveIframeBodyController, ResponsiveIframeWrapperController, ScrollContainerController, ScrollIntoFocusController, ScrollToBottomController, ScrollToController, ScrollToTopController, SelfDestructController, SignalActionController, SignalInputController, SignalVisibilityController, StickyController, StorageSerializers, SyncInputsController, TableSortController, TableTruncateController, TabsController, TeleportController, TemporaryStateController, TimeDistanceController, TimeoutController, ToggleClassController, TreeViewController, TrixModifierController, TurboFrameRCController, TurboFrameRefreshController, UserFocusController, ValueWarnController, WordCountController, applyTemporaryClass, applyTemporaryState, createHiddenButton, createHiddenInput, getAllRadiosInGroup, getOtherRadiosInGroup, getScrollParent, insertElement, insertHiddenButton, insertHiddenInput, isDirty, isElementCheckable, isElementInViewport, isFormDirty, isHTMLAnchorElement, isHTMLButtonElement, isHTMLFormElement, isHTMLImageElement, isHTMLInputElement, isHTMLLinkElement, isHTMLSelectElement, isHTMLTextAreaElement, isTurboFrame, isTypeOfFormInputElement, requestReset, requestSubmit, scrollAbsoluteBottom, scrollAbsoluteLeft, scrollAbsoluteRight, scrollAbsoluteTop, scrollDown, scrollLeft, scrollRight, scrollToElement, scrollUp, useCollectionEventListener, useCollectionEventListeners, useEventListener, useEventListeners, useFullscreen, useGeolocation, useInjectedElement, useInjectedFragment, useInjectedHTML, useInterval, useLocalStorage, useTimeout };
|
|
7324
4585
|
//# sourceMappingURL=stimulus-library.es.js.map
|