form_components 0.1.1
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +29 -0
- data/MIT-LICENSE +20 -0
- data/README.md +194 -0
- data/app/assets/stylesheets/form_components/application.css +9 -0
- data/app/assets/tailwind/form_components/engine.css +6 -0
- data/app/components/form_components/base/component.rb +76 -0
- data/app/components/form_components/check_box/component.html.slim +13 -0
- data/app/components/form_components/check_box/component.rb +26 -0
- data/app/components/form_components/collection/component.html.slim +10 -0
- data/app/components/form_components/collection/component.rb +76 -0
- data/app/components/form_components/collection_check_boxes/component.rb +12 -0
- data/app/components/form_components/collection_radio_buttons/component.rb +12 -0
- data/app/components/form_components/color_field/component.css +69 -0
- data/app/components/form_components/color_field/component.html.slim +8 -0
- data/app/components/form_components/color_field/component.rb +26 -0
- data/app/components/form_components/color_field/component_controller.js +25 -0
- data/app/components/form_components/combobox/component.html.slim +8 -0
- data/app/components/form_components/combobox/component.rb +28 -0
- data/app/components/form_components/field/component.rb +58 -0
- data/app/components/form_components/file_field/component.html.slim +10 -0
- data/app/components/form_components/file_field/component.rb +25 -0
- data/app/components/form_components/label/component.rb +31 -0
- data/app/components/form_components/nested_form/component.html.slim +20 -0
- data/app/components/form_components/nested_form/component.rb +71 -0
- data/app/components/form_components/nested_form/component_controller.js +36 -0
- data/app/components/form_components/radio_button/component.html.slim +12 -0
- data/app/components/form_components/radio_button/component.rb +24 -0
- data/app/components/form_components/rating_field/component.rb +39 -0
- data/app/components/form_components/scale_field/component.rb +44 -0
- data/app/components/form_components/select/component.html.slim +8 -0
- data/app/components/form_components/select/component.rb +35 -0
- data/app/components/form_components/submit/component.rb +21 -0
- data/app/components/form_components/text_area/component.html.slim +14 -0
- data/app/components/form_components/text_area/component.rb +22 -0
- data/app/components/form_components/text_field/component.html.slim +16 -0
- data/app/components/form_components/text_field/component.rb +33 -0
- data/app/components/form_components/validation.rb +41 -0
- data/app/form_builders/form_components/form_builder.rb +133 -0
- data/app/form_builders/form_components/validation_context.rb +17 -0
- data/app/javascript/form_components/application.js +12 -0
- data/config/importmap.rb +6 -0
- data/lib/form_components/engine.rb +23 -0
- data/lib/form_components/version.rb +5 -0
- data/lib/form_components.rb +13 -0
- data/vendor/javascript/form_components/jscolorpicker/LICENSE +21 -0
- data/vendor/javascript/form_components/jscolorpicker/colorpicker.css +409 -0
- data/vendor/javascript/form_components/jscolorpicker/colorpicker.js +2410 -0
- metadata +145 -0
|
@@ -0,0 +1,2410 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
function getDefaultExportFromCjs(x) {
|
|
5
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
6
|
+
}
|
|
7
|
+
var events = { exports: {} };
|
|
8
|
+
var R = typeof Reflect === "object" ? Reflect : null;
|
|
9
|
+
var ReflectApply = R && typeof R.apply === "function" ? R.apply : function ReflectApply2(target, receiver, args) {
|
|
10
|
+
return Function.prototype.apply.call(target, receiver, args);
|
|
11
|
+
};
|
|
12
|
+
var ReflectOwnKeys;
|
|
13
|
+
if (R && typeof R.ownKeys === "function") {
|
|
14
|
+
ReflectOwnKeys = R.ownKeys;
|
|
15
|
+
} else if (Object.getOwnPropertySymbols) {
|
|
16
|
+
ReflectOwnKeys = function ReflectOwnKeys2(target) {
|
|
17
|
+
return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target));
|
|
18
|
+
};
|
|
19
|
+
} else {
|
|
20
|
+
ReflectOwnKeys = function ReflectOwnKeys2(target) {
|
|
21
|
+
return Object.getOwnPropertyNames(target);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function ProcessEmitWarning(warning) {
|
|
25
|
+
if (console && console.warn) console.warn(warning);
|
|
26
|
+
}
|
|
27
|
+
var NumberIsNaN = Number.isNaN || function NumberIsNaN2(value) {
|
|
28
|
+
return value !== value;
|
|
29
|
+
};
|
|
30
|
+
function EventEmitter() {
|
|
31
|
+
EventEmitter.init.call(this);
|
|
32
|
+
}
|
|
33
|
+
events.exports = EventEmitter;
|
|
34
|
+
events.exports.once = once2;
|
|
35
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
36
|
+
EventEmitter.prototype._events = void 0;
|
|
37
|
+
EventEmitter.prototype._eventsCount = 0;
|
|
38
|
+
EventEmitter.prototype._maxListeners = void 0;
|
|
39
|
+
var defaultMaxListeners = 10;
|
|
40
|
+
function checkListener(listener) {
|
|
41
|
+
if (typeof listener !== "function") {
|
|
42
|
+
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
Object.defineProperty(EventEmitter, "defaultMaxListeners", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function() {
|
|
48
|
+
return defaultMaxListeners;
|
|
49
|
+
},
|
|
50
|
+
set: function(arg) {
|
|
51
|
+
if (typeof arg !== "number" || arg < 0 || NumberIsNaN(arg)) {
|
|
52
|
+
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + ".");
|
|
53
|
+
}
|
|
54
|
+
defaultMaxListeners = arg;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
EventEmitter.init = function() {
|
|
58
|
+
if (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) {
|
|
59
|
+
this._events = /* @__PURE__ */ Object.create(null);
|
|
60
|
+
this._eventsCount = 0;
|
|
61
|
+
}
|
|
62
|
+
this._maxListeners = this._maxListeners || void 0;
|
|
63
|
+
};
|
|
64
|
+
EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
|
|
65
|
+
if (typeof n !== "number" || n < 0 || NumberIsNaN(n)) {
|
|
66
|
+
throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + ".");
|
|
67
|
+
}
|
|
68
|
+
this._maxListeners = n;
|
|
69
|
+
return this;
|
|
70
|
+
};
|
|
71
|
+
function _getMaxListeners(that) {
|
|
72
|
+
if (that._maxListeners === void 0)
|
|
73
|
+
return EventEmitter.defaultMaxListeners;
|
|
74
|
+
return that._maxListeners;
|
|
75
|
+
}
|
|
76
|
+
EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
|
|
77
|
+
return _getMaxListeners(this);
|
|
78
|
+
};
|
|
79
|
+
EventEmitter.prototype.emit = function emit(type) {
|
|
80
|
+
var args = [];
|
|
81
|
+
for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
|
|
82
|
+
var doError = type === "error";
|
|
83
|
+
var events2 = this._events;
|
|
84
|
+
if (events2 !== void 0)
|
|
85
|
+
doError = doError && events2.error === void 0;
|
|
86
|
+
else if (!doError)
|
|
87
|
+
return false;
|
|
88
|
+
if (doError) {
|
|
89
|
+
var er;
|
|
90
|
+
if (args.length > 0)
|
|
91
|
+
er = args[0];
|
|
92
|
+
if (er instanceof Error) {
|
|
93
|
+
throw er;
|
|
94
|
+
}
|
|
95
|
+
var err = new Error("Unhandled error." + (er ? " (" + er.message + ")" : ""));
|
|
96
|
+
err.context = er;
|
|
97
|
+
throw err;
|
|
98
|
+
}
|
|
99
|
+
var handler = events2[type];
|
|
100
|
+
if (handler === void 0)
|
|
101
|
+
return false;
|
|
102
|
+
if (typeof handler === "function") {
|
|
103
|
+
ReflectApply(handler, this, args);
|
|
104
|
+
} else {
|
|
105
|
+
var len = handler.length;
|
|
106
|
+
var listeners2 = arrayClone(handler, len);
|
|
107
|
+
for (var i = 0; i < len; ++i)
|
|
108
|
+
ReflectApply(listeners2[i], this, args);
|
|
109
|
+
}
|
|
110
|
+
return true;
|
|
111
|
+
};
|
|
112
|
+
function _addListener(target, type, listener, prepend) {
|
|
113
|
+
var m;
|
|
114
|
+
var events2;
|
|
115
|
+
var existing;
|
|
116
|
+
checkListener(listener);
|
|
117
|
+
events2 = target._events;
|
|
118
|
+
if (events2 === void 0) {
|
|
119
|
+
events2 = target._events = /* @__PURE__ */ Object.create(null);
|
|
120
|
+
target._eventsCount = 0;
|
|
121
|
+
} else {
|
|
122
|
+
if (events2.newListener !== void 0) {
|
|
123
|
+
target.emit(
|
|
124
|
+
"newListener",
|
|
125
|
+
type,
|
|
126
|
+
listener.listener ? listener.listener : listener
|
|
127
|
+
);
|
|
128
|
+
events2 = target._events;
|
|
129
|
+
}
|
|
130
|
+
existing = events2[type];
|
|
131
|
+
}
|
|
132
|
+
if (existing === void 0) {
|
|
133
|
+
existing = events2[type] = listener;
|
|
134
|
+
++target._eventsCount;
|
|
135
|
+
} else {
|
|
136
|
+
if (typeof existing === "function") {
|
|
137
|
+
existing = events2[type] = prepend ? [listener, existing] : [existing, listener];
|
|
138
|
+
} else if (prepend) {
|
|
139
|
+
existing.unshift(listener);
|
|
140
|
+
} else {
|
|
141
|
+
existing.push(listener);
|
|
142
|
+
}
|
|
143
|
+
m = _getMaxListeners(target);
|
|
144
|
+
if (m > 0 && existing.length > m && !existing.warned) {
|
|
145
|
+
existing.warned = true;
|
|
146
|
+
var w = new Error("Possible EventEmitter memory leak detected. " + existing.length + " " + String(type) + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
147
|
+
w.name = "MaxListenersExceededWarning";
|
|
148
|
+
w.emitter = target;
|
|
149
|
+
w.type = type;
|
|
150
|
+
w.count = existing.length;
|
|
151
|
+
ProcessEmitWarning(w);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return target;
|
|
155
|
+
}
|
|
156
|
+
EventEmitter.prototype.addListener = function addListener(type, listener) {
|
|
157
|
+
return _addListener(this, type, listener, false);
|
|
158
|
+
};
|
|
159
|
+
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
|
160
|
+
EventEmitter.prototype.prependListener = function prependListener(type, listener) {
|
|
161
|
+
return _addListener(this, type, listener, true);
|
|
162
|
+
};
|
|
163
|
+
function onceWrapper() {
|
|
164
|
+
if (!this.fired) {
|
|
165
|
+
this.target.removeListener(this.type, this.wrapFn);
|
|
166
|
+
this.fired = true;
|
|
167
|
+
if (arguments.length === 0)
|
|
168
|
+
return this.listener.call(this.target);
|
|
169
|
+
return this.listener.apply(this.target, arguments);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function _onceWrap(target, type, listener) {
|
|
173
|
+
var state = { fired: false, wrapFn: void 0, target, type, listener };
|
|
174
|
+
var wrapped = onceWrapper.bind(state);
|
|
175
|
+
wrapped.listener = listener;
|
|
176
|
+
state.wrapFn = wrapped;
|
|
177
|
+
return wrapped;
|
|
178
|
+
}
|
|
179
|
+
EventEmitter.prototype.once = function once(type, listener) {
|
|
180
|
+
checkListener(listener);
|
|
181
|
+
this.on(type, _onceWrap(this, type, listener));
|
|
182
|
+
return this;
|
|
183
|
+
};
|
|
184
|
+
EventEmitter.prototype.prependOnceListener = function prependOnceListener(type, listener) {
|
|
185
|
+
checkListener(listener);
|
|
186
|
+
this.prependListener(type, _onceWrap(this, type, listener));
|
|
187
|
+
return this;
|
|
188
|
+
};
|
|
189
|
+
EventEmitter.prototype.removeListener = function removeListener(type, listener) {
|
|
190
|
+
var list, events2, position, i, originalListener;
|
|
191
|
+
checkListener(listener);
|
|
192
|
+
events2 = this._events;
|
|
193
|
+
if (events2 === void 0)
|
|
194
|
+
return this;
|
|
195
|
+
list = events2[type];
|
|
196
|
+
if (list === void 0)
|
|
197
|
+
return this;
|
|
198
|
+
if (list === listener || list.listener === listener) {
|
|
199
|
+
if (--this._eventsCount === 0)
|
|
200
|
+
this._events = /* @__PURE__ */ Object.create(null);
|
|
201
|
+
else {
|
|
202
|
+
delete events2[type];
|
|
203
|
+
if (events2.removeListener)
|
|
204
|
+
this.emit("removeListener", type, list.listener || listener);
|
|
205
|
+
}
|
|
206
|
+
} else if (typeof list !== "function") {
|
|
207
|
+
position = -1;
|
|
208
|
+
for (i = list.length - 1; i >= 0; i--) {
|
|
209
|
+
if (list[i] === listener || list[i].listener === listener) {
|
|
210
|
+
originalListener = list[i].listener;
|
|
211
|
+
position = i;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (position < 0)
|
|
216
|
+
return this;
|
|
217
|
+
if (position === 0)
|
|
218
|
+
list.shift();
|
|
219
|
+
else {
|
|
220
|
+
spliceOne(list, position);
|
|
221
|
+
}
|
|
222
|
+
if (list.length === 1)
|
|
223
|
+
events2[type] = list[0];
|
|
224
|
+
if (events2.removeListener !== void 0)
|
|
225
|
+
this.emit("removeListener", type, originalListener || listener);
|
|
226
|
+
}
|
|
227
|
+
return this;
|
|
228
|
+
};
|
|
229
|
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
230
|
+
EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) {
|
|
231
|
+
var listeners2, events2, i;
|
|
232
|
+
events2 = this._events;
|
|
233
|
+
if (events2 === void 0)
|
|
234
|
+
return this;
|
|
235
|
+
if (events2.removeListener === void 0) {
|
|
236
|
+
if (arguments.length === 0) {
|
|
237
|
+
this._events = /* @__PURE__ */ Object.create(null);
|
|
238
|
+
this._eventsCount = 0;
|
|
239
|
+
} else if (events2[type] !== void 0) {
|
|
240
|
+
if (--this._eventsCount === 0)
|
|
241
|
+
this._events = /* @__PURE__ */ Object.create(null);
|
|
242
|
+
else
|
|
243
|
+
delete events2[type];
|
|
244
|
+
}
|
|
245
|
+
return this;
|
|
246
|
+
}
|
|
247
|
+
if (arguments.length === 0) {
|
|
248
|
+
var keys = Object.keys(events2);
|
|
249
|
+
var key;
|
|
250
|
+
for (i = 0; i < keys.length; ++i) {
|
|
251
|
+
key = keys[i];
|
|
252
|
+
if (key === "removeListener") continue;
|
|
253
|
+
this.removeAllListeners(key);
|
|
254
|
+
}
|
|
255
|
+
this.removeAllListeners("removeListener");
|
|
256
|
+
this._events = /* @__PURE__ */ Object.create(null);
|
|
257
|
+
this._eventsCount = 0;
|
|
258
|
+
return this;
|
|
259
|
+
}
|
|
260
|
+
listeners2 = events2[type];
|
|
261
|
+
if (typeof listeners2 === "function") {
|
|
262
|
+
this.removeListener(type, listeners2);
|
|
263
|
+
} else if (listeners2 !== void 0) {
|
|
264
|
+
for (i = listeners2.length - 1; i >= 0; i--) {
|
|
265
|
+
this.removeListener(type, listeners2[i]);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return this;
|
|
269
|
+
};
|
|
270
|
+
function _listeners(target, type, unwrap) {
|
|
271
|
+
var events2 = target._events;
|
|
272
|
+
if (events2 === void 0)
|
|
273
|
+
return [];
|
|
274
|
+
var evlistener = events2[type];
|
|
275
|
+
if (evlistener === void 0)
|
|
276
|
+
return [];
|
|
277
|
+
if (typeof evlistener === "function")
|
|
278
|
+
return unwrap ? [evlistener.listener || evlistener] : [evlistener];
|
|
279
|
+
return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
|
|
280
|
+
}
|
|
281
|
+
EventEmitter.prototype.listeners = function listeners(type) {
|
|
282
|
+
return _listeners(this, type, true);
|
|
283
|
+
};
|
|
284
|
+
EventEmitter.prototype.rawListeners = function rawListeners(type) {
|
|
285
|
+
return _listeners(this, type, false);
|
|
286
|
+
};
|
|
287
|
+
EventEmitter.listenerCount = function(emitter, type) {
|
|
288
|
+
if (typeof emitter.listenerCount === "function") {
|
|
289
|
+
return emitter.listenerCount(type);
|
|
290
|
+
} else {
|
|
291
|
+
return listenerCount.call(emitter, type);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
EventEmitter.prototype.listenerCount = listenerCount;
|
|
295
|
+
function listenerCount(type) {
|
|
296
|
+
var events2 = this._events;
|
|
297
|
+
if (events2 !== void 0) {
|
|
298
|
+
var evlistener = events2[type];
|
|
299
|
+
if (typeof evlistener === "function") {
|
|
300
|
+
return 1;
|
|
301
|
+
} else if (evlistener !== void 0) {
|
|
302
|
+
return evlistener.length;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return 0;
|
|
306
|
+
}
|
|
307
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
308
|
+
return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
|
|
309
|
+
};
|
|
310
|
+
function arrayClone(arr, n) {
|
|
311
|
+
var copy = new Array(n);
|
|
312
|
+
for (var i = 0; i < n; ++i)
|
|
313
|
+
copy[i] = arr[i];
|
|
314
|
+
return copy;
|
|
315
|
+
}
|
|
316
|
+
function spliceOne(list, index) {
|
|
317
|
+
for (; index + 1 < list.length; index++)
|
|
318
|
+
list[index] = list[index + 1];
|
|
319
|
+
list.pop();
|
|
320
|
+
}
|
|
321
|
+
function unwrapListeners(arr) {
|
|
322
|
+
var ret = new Array(arr.length);
|
|
323
|
+
for (var i = 0; i < ret.length; ++i) {
|
|
324
|
+
ret[i] = arr[i].listener || arr[i];
|
|
325
|
+
}
|
|
326
|
+
return ret;
|
|
327
|
+
}
|
|
328
|
+
function once2(emitter, name) {
|
|
329
|
+
return new Promise(function(resolve, reject) {
|
|
330
|
+
function errorListener(err) {
|
|
331
|
+
emitter.removeListener(name, resolver);
|
|
332
|
+
reject(err);
|
|
333
|
+
}
|
|
334
|
+
function resolver() {
|
|
335
|
+
if (typeof emitter.removeListener === "function") {
|
|
336
|
+
emitter.removeListener("error", errorListener);
|
|
337
|
+
}
|
|
338
|
+
resolve([].slice.call(arguments));
|
|
339
|
+
}
|
|
340
|
+
eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
|
|
341
|
+
if (name !== "error") {
|
|
342
|
+
addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
|
|
347
|
+
if (typeof emitter.on === "function") {
|
|
348
|
+
eventTargetAgnosticAddListener(emitter, "error", handler, flags);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
|
|
352
|
+
if (typeof emitter.on === "function") {
|
|
353
|
+
if (flags.once) {
|
|
354
|
+
emitter.once(name, listener);
|
|
355
|
+
} else {
|
|
356
|
+
emitter.on(name, listener);
|
|
357
|
+
}
|
|
358
|
+
} else if (typeof emitter.addEventListener === "function") {
|
|
359
|
+
emitter.addEventListener(name, function wrapListener(arg) {
|
|
360
|
+
if (flags.once) {
|
|
361
|
+
emitter.removeEventListener(name, wrapListener);
|
|
362
|
+
}
|
|
363
|
+
listener(arg);
|
|
364
|
+
});
|
|
365
|
+
} else {
|
|
366
|
+
throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
var eventsExports = events.exports;
|
|
370
|
+
const EventEmitter$1 = /* @__PURE__ */ getDefaultExportFromCjs(eventsExports);
|
|
371
|
+
var top = "top";
|
|
372
|
+
var bottom = "bottom";
|
|
373
|
+
var right = "right";
|
|
374
|
+
var left = "left";
|
|
375
|
+
var auto = "auto";
|
|
376
|
+
var basePlacements = [top, bottom, right, left];
|
|
377
|
+
var start = "start";
|
|
378
|
+
var end = "end";
|
|
379
|
+
var clippingParents = "clippingParents";
|
|
380
|
+
var viewport = "viewport";
|
|
381
|
+
var popper = "popper";
|
|
382
|
+
var reference = "reference";
|
|
383
|
+
var variationPlacements = /* @__PURE__ */ basePlacements.reduce(function(acc, placement) {
|
|
384
|
+
return acc.concat([placement + "-" + start, placement + "-" + end]);
|
|
385
|
+
}, []);
|
|
386
|
+
var placements = /* @__PURE__ */ [].concat(basePlacements, [auto]).reduce(function(acc, placement) {
|
|
387
|
+
return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
|
|
388
|
+
}, []);
|
|
389
|
+
var beforeRead = "beforeRead";
|
|
390
|
+
var read = "read";
|
|
391
|
+
var afterRead = "afterRead";
|
|
392
|
+
var beforeMain = "beforeMain";
|
|
393
|
+
var main = "main";
|
|
394
|
+
var afterMain = "afterMain";
|
|
395
|
+
var beforeWrite = "beforeWrite";
|
|
396
|
+
var write = "write";
|
|
397
|
+
var afterWrite = "afterWrite";
|
|
398
|
+
var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
|
|
399
|
+
function getNodeName(element) {
|
|
400
|
+
return element ? (element.nodeName || "").toLowerCase() : null;
|
|
401
|
+
}
|
|
402
|
+
function getWindow(node) {
|
|
403
|
+
if (node == null) {
|
|
404
|
+
return window;
|
|
405
|
+
}
|
|
406
|
+
if (node.toString() !== "[object Window]") {
|
|
407
|
+
var ownerDocument = node.ownerDocument;
|
|
408
|
+
return ownerDocument ? ownerDocument.defaultView || window : window;
|
|
409
|
+
}
|
|
410
|
+
return node;
|
|
411
|
+
}
|
|
412
|
+
function isElement(node) {
|
|
413
|
+
var OwnElement = getWindow(node).Element;
|
|
414
|
+
return node instanceof OwnElement || node instanceof Element;
|
|
415
|
+
}
|
|
416
|
+
function isHTMLElement(node) {
|
|
417
|
+
var OwnElement = getWindow(node).HTMLElement;
|
|
418
|
+
return node instanceof OwnElement || node instanceof HTMLElement;
|
|
419
|
+
}
|
|
420
|
+
function isShadowRoot(node) {
|
|
421
|
+
if (typeof ShadowRoot === "undefined") {
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
var OwnElement = getWindow(node).ShadowRoot;
|
|
425
|
+
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
426
|
+
}
|
|
427
|
+
function applyStyles(_ref) {
|
|
428
|
+
var state = _ref.state;
|
|
429
|
+
Object.keys(state.elements).forEach(function(name) {
|
|
430
|
+
var style = state.styles[name] || {};
|
|
431
|
+
var attributes = state.attributes[name] || {};
|
|
432
|
+
var element = state.elements[name];
|
|
433
|
+
if (!isHTMLElement(element) || !getNodeName(element)) {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
Object.assign(element.style, style);
|
|
437
|
+
Object.keys(attributes).forEach(function(name2) {
|
|
438
|
+
var value = attributes[name2];
|
|
439
|
+
if (value === false) {
|
|
440
|
+
element.removeAttribute(name2);
|
|
441
|
+
} else {
|
|
442
|
+
element.setAttribute(name2, value === true ? "" : value);
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
function effect$2(_ref2) {
|
|
448
|
+
var state = _ref2.state;
|
|
449
|
+
var initialStyles = {
|
|
450
|
+
popper: {
|
|
451
|
+
position: state.options.strategy,
|
|
452
|
+
left: "0",
|
|
453
|
+
top: "0",
|
|
454
|
+
margin: "0"
|
|
455
|
+
},
|
|
456
|
+
arrow: {
|
|
457
|
+
position: "absolute"
|
|
458
|
+
},
|
|
459
|
+
reference: {}
|
|
460
|
+
};
|
|
461
|
+
Object.assign(state.elements.popper.style, initialStyles.popper);
|
|
462
|
+
state.styles = initialStyles;
|
|
463
|
+
if (state.elements.arrow) {
|
|
464
|
+
Object.assign(state.elements.arrow.style, initialStyles.arrow);
|
|
465
|
+
}
|
|
466
|
+
return function() {
|
|
467
|
+
Object.keys(state.elements).forEach(function(name) {
|
|
468
|
+
var element = state.elements[name];
|
|
469
|
+
var attributes = state.attributes[name] || {};
|
|
470
|
+
var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]);
|
|
471
|
+
var style = styleProperties.reduce(function(style2, property) {
|
|
472
|
+
style2[property] = "";
|
|
473
|
+
return style2;
|
|
474
|
+
}, {});
|
|
475
|
+
if (!isHTMLElement(element) || !getNodeName(element)) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
Object.assign(element.style, style);
|
|
479
|
+
Object.keys(attributes).forEach(function(attribute) {
|
|
480
|
+
element.removeAttribute(attribute);
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
const applyStyles$1 = {
|
|
486
|
+
name: "applyStyles",
|
|
487
|
+
enabled: true,
|
|
488
|
+
phase: "write",
|
|
489
|
+
fn: applyStyles,
|
|
490
|
+
effect: effect$2,
|
|
491
|
+
requires: ["computeStyles"]
|
|
492
|
+
};
|
|
493
|
+
function getBasePlacement(placement) {
|
|
494
|
+
return placement.split("-")[0];
|
|
495
|
+
}
|
|
496
|
+
var max = Math.max;
|
|
497
|
+
var min = Math.min;
|
|
498
|
+
var round = Math.round;
|
|
499
|
+
function getUAString() {
|
|
500
|
+
var uaData = navigator.userAgentData;
|
|
501
|
+
if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
|
|
502
|
+
return uaData.brands.map(function(item) {
|
|
503
|
+
return item.brand + "/" + item.version;
|
|
504
|
+
}).join(" ");
|
|
505
|
+
}
|
|
506
|
+
return navigator.userAgent;
|
|
507
|
+
}
|
|
508
|
+
function isLayoutViewport() {
|
|
509
|
+
return !/^((?!chrome|android).)*safari/i.test(getUAString());
|
|
510
|
+
}
|
|
511
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
|
512
|
+
if (includeScale === void 0) {
|
|
513
|
+
includeScale = false;
|
|
514
|
+
}
|
|
515
|
+
if (isFixedStrategy === void 0) {
|
|
516
|
+
isFixedStrategy = false;
|
|
517
|
+
}
|
|
518
|
+
var clientRect = element.getBoundingClientRect();
|
|
519
|
+
var scaleX = 1;
|
|
520
|
+
var scaleY = 1;
|
|
521
|
+
if (includeScale && isHTMLElement(element)) {
|
|
522
|
+
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
|
523
|
+
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
|
524
|
+
}
|
|
525
|
+
var _ref = isElement(element) ? getWindow(element) : window, visualViewport = _ref.visualViewport;
|
|
526
|
+
var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
|
527
|
+
var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
|
|
528
|
+
var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
|
|
529
|
+
var width = clientRect.width / scaleX;
|
|
530
|
+
var height = clientRect.height / scaleY;
|
|
531
|
+
return {
|
|
532
|
+
width,
|
|
533
|
+
height,
|
|
534
|
+
top: y,
|
|
535
|
+
right: x + width,
|
|
536
|
+
bottom: y + height,
|
|
537
|
+
left: x,
|
|
538
|
+
x,
|
|
539
|
+
y
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
function getLayoutRect(element) {
|
|
543
|
+
var clientRect = getBoundingClientRect(element);
|
|
544
|
+
var width = element.offsetWidth;
|
|
545
|
+
var height = element.offsetHeight;
|
|
546
|
+
if (Math.abs(clientRect.width - width) <= 1) {
|
|
547
|
+
width = clientRect.width;
|
|
548
|
+
}
|
|
549
|
+
if (Math.abs(clientRect.height - height) <= 1) {
|
|
550
|
+
height = clientRect.height;
|
|
551
|
+
}
|
|
552
|
+
return {
|
|
553
|
+
x: element.offsetLeft,
|
|
554
|
+
y: element.offsetTop,
|
|
555
|
+
width,
|
|
556
|
+
height
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
function contains(parent, child) {
|
|
560
|
+
var rootNode = child.getRootNode && child.getRootNode();
|
|
561
|
+
if (parent.contains(child)) {
|
|
562
|
+
return true;
|
|
563
|
+
} else if (rootNode && isShadowRoot(rootNode)) {
|
|
564
|
+
var next = child;
|
|
565
|
+
do {
|
|
566
|
+
if (next && parent.isSameNode(next)) {
|
|
567
|
+
return true;
|
|
568
|
+
}
|
|
569
|
+
next = next.parentNode || next.host;
|
|
570
|
+
} while (next);
|
|
571
|
+
}
|
|
572
|
+
return false;
|
|
573
|
+
}
|
|
574
|
+
function getComputedStyle$1(element) {
|
|
575
|
+
return getWindow(element).getComputedStyle(element);
|
|
576
|
+
}
|
|
577
|
+
function isTableElement(element) {
|
|
578
|
+
return ["table", "td", "th"].indexOf(getNodeName(element)) >= 0;
|
|
579
|
+
}
|
|
580
|
+
function getDocumentElement(element) {
|
|
581
|
+
return ((isElement(element) ? element.ownerDocument : (
|
|
582
|
+
// $FlowFixMe[prop-missing]
|
|
583
|
+
element.document
|
|
584
|
+
)) || window.document).documentElement;
|
|
585
|
+
}
|
|
586
|
+
function getParentNode(element) {
|
|
587
|
+
if (getNodeName(element) === "html") {
|
|
588
|
+
return element;
|
|
589
|
+
}
|
|
590
|
+
return (
|
|
591
|
+
// this is a quicker (but less type safe) way to save quite some bytes from the bundle
|
|
592
|
+
// $FlowFixMe[incompatible-return]
|
|
593
|
+
// $FlowFixMe[prop-missing]
|
|
594
|
+
element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
|
|
595
|
+
element.parentNode || // DOM Element detected
|
|
596
|
+
(isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
|
|
597
|
+
// $FlowFixMe[incompatible-call]: HTMLElement is a Node
|
|
598
|
+
getDocumentElement(element)
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
function getTrueOffsetParent(element) {
|
|
602
|
+
if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
|
|
603
|
+
getComputedStyle$1(element).position === "fixed") {
|
|
604
|
+
return null;
|
|
605
|
+
}
|
|
606
|
+
return element.offsetParent;
|
|
607
|
+
}
|
|
608
|
+
function getContainingBlock(element) {
|
|
609
|
+
var isFirefox = /firefox/i.test(getUAString());
|
|
610
|
+
var isIE = /Trident/i.test(getUAString());
|
|
611
|
+
if (isIE && isHTMLElement(element)) {
|
|
612
|
+
var elementCss = getComputedStyle$1(element);
|
|
613
|
+
if (elementCss.position === "fixed") {
|
|
614
|
+
return null;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
var currentNode = getParentNode(element);
|
|
618
|
+
if (isShadowRoot(currentNode)) {
|
|
619
|
+
currentNode = currentNode.host;
|
|
620
|
+
}
|
|
621
|
+
while (isHTMLElement(currentNode) && ["html", "body"].indexOf(getNodeName(currentNode)) < 0) {
|
|
622
|
+
var css = getComputedStyle$1(currentNode);
|
|
623
|
+
if (css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || ["transform", "perspective"].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === "filter" || isFirefox && css.filter && css.filter !== "none") {
|
|
624
|
+
return currentNode;
|
|
625
|
+
} else {
|
|
626
|
+
currentNode = currentNode.parentNode;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
return null;
|
|
630
|
+
}
|
|
631
|
+
function getOffsetParent(element) {
|
|
632
|
+
var window2 = getWindow(element);
|
|
633
|
+
var offsetParent = getTrueOffsetParent(element);
|
|
634
|
+
while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === "static") {
|
|
635
|
+
offsetParent = getTrueOffsetParent(offsetParent);
|
|
636
|
+
}
|
|
637
|
+
if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle$1(offsetParent).position === "static")) {
|
|
638
|
+
return window2;
|
|
639
|
+
}
|
|
640
|
+
return offsetParent || getContainingBlock(element) || window2;
|
|
641
|
+
}
|
|
642
|
+
function getMainAxisFromPlacement(placement) {
|
|
643
|
+
return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y";
|
|
644
|
+
}
|
|
645
|
+
function within(min$1, value, max$1) {
|
|
646
|
+
return max(min$1, min(value, max$1));
|
|
647
|
+
}
|
|
648
|
+
function withinMaxClamp(min2, value, max2) {
|
|
649
|
+
var v = within(min2, value, max2);
|
|
650
|
+
return v > max2 ? max2 : v;
|
|
651
|
+
}
|
|
652
|
+
function getFreshSideObject() {
|
|
653
|
+
return {
|
|
654
|
+
top: 0,
|
|
655
|
+
right: 0,
|
|
656
|
+
bottom: 0,
|
|
657
|
+
left: 0
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
function mergePaddingObject(paddingObject) {
|
|
661
|
+
return Object.assign({}, getFreshSideObject(), paddingObject);
|
|
662
|
+
}
|
|
663
|
+
function expandToHashMap(value, keys) {
|
|
664
|
+
return keys.reduce(function(hashMap, key) {
|
|
665
|
+
hashMap[key] = value;
|
|
666
|
+
return hashMap;
|
|
667
|
+
}, {});
|
|
668
|
+
}
|
|
669
|
+
var toPaddingObject = function toPaddingObject2(padding, state) {
|
|
670
|
+
padding = typeof padding === "function" ? padding(Object.assign({}, state.rects, {
|
|
671
|
+
placement: state.placement
|
|
672
|
+
})) : padding;
|
|
673
|
+
return mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
|
|
674
|
+
};
|
|
675
|
+
function arrow(_ref) {
|
|
676
|
+
var _state$modifiersData$;
|
|
677
|
+
var state = _ref.state, name = _ref.name, options = _ref.options;
|
|
678
|
+
var arrowElement = state.elements.arrow;
|
|
679
|
+
var popperOffsets2 = state.modifiersData.popperOffsets;
|
|
680
|
+
var basePlacement = getBasePlacement(state.placement);
|
|
681
|
+
var axis = getMainAxisFromPlacement(basePlacement);
|
|
682
|
+
var isVertical = [left, right].indexOf(basePlacement) >= 0;
|
|
683
|
+
var len = isVertical ? "height" : "width";
|
|
684
|
+
if (!arrowElement || !popperOffsets2) {
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
var paddingObject = toPaddingObject(options.padding, state);
|
|
688
|
+
var arrowRect = getLayoutRect(arrowElement);
|
|
689
|
+
var minProp = axis === "y" ? top : left;
|
|
690
|
+
var maxProp = axis === "y" ? bottom : right;
|
|
691
|
+
var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets2[axis] - state.rects.popper[len];
|
|
692
|
+
var startDiff = popperOffsets2[axis] - state.rects.reference[axis];
|
|
693
|
+
var arrowOffsetParent = getOffsetParent(arrowElement);
|
|
694
|
+
var clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
|
|
695
|
+
var centerToReference = endDiff / 2 - startDiff / 2;
|
|
696
|
+
var min2 = paddingObject[minProp];
|
|
697
|
+
var max2 = clientSize - arrowRect[len] - paddingObject[maxProp];
|
|
698
|
+
var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
|
|
699
|
+
var offset2 = within(min2, center, max2);
|
|
700
|
+
var axisProp = axis;
|
|
701
|
+
state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset2, _state$modifiersData$.centerOffset = offset2 - center, _state$modifiersData$);
|
|
702
|
+
}
|
|
703
|
+
function effect$1(_ref2) {
|
|
704
|
+
var state = _ref2.state, options = _ref2.options;
|
|
705
|
+
var _options$element = options.element, arrowElement = _options$element === void 0 ? "[data-popper-arrow]" : _options$element;
|
|
706
|
+
if (arrowElement == null) {
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
if (typeof arrowElement === "string") {
|
|
710
|
+
arrowElement = state.elements.popper.querySelector(arrowElement);
|
|
711
|
+
if (!arrowElement) {
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
if (!contains(state.elements.popper, arrowElement)) {
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
state.elements.arrow = arrowElement;
|
|
719
|
+
}
|
|
720
|
+
const arrow$1 = {
|
|
721
|
+
name: "arrow",
|
|
722
|
+
enabled: true,
|
|
723
|
+
phase: "main",
|
|
724
|
+
fn: arrow,
|
|
725
|
+
effect: effect$1,
|
|
726
|
+
requires: ["popperOffsets"],
|
|
727
|
+
requiresIfExists: ["preventOverflow"]
|
|
728
|
+
};
|
|
729
|
+
function getVariation(placement) {
|
|
730
|
+
return placement.split("-")[1];
|
|
731
|
+
}
|
|
732
|
+
var unsetSides = {
|
|
733
|
+
top: "auto",
|
|
734
|
+
right: "auto",
|
|
735
|
+
bottom: "auto",
|
|
736
|
+
left: "auto"
|
|
737
|
+
};
|
|
738
|
+
function roundOffsetsByDPR(_ref, win) {
|
|
739
|
+
var x = _ref.x, y = _ref.y;
|
|
740
|
+
var dpr = win.devicePixelRatio || 1;
|
|
741
|
+
return {
|
|
742
|
+
x: round(x * dpr) / dpr || 0,
|
|
743
|
+
y: round(y * dpr) / dpr || 0
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
function mapToStyles(_ref2) {
|
|
747
|
+
var _Object$assign2;
|
|
748
|
+
var popper2 = _ref2.popper, popperRect = _ref2.popperRect, placement = _ref2.placement, variation = _ref2.variation, offsets = _ref2.offsets, position = _ref2.position, gpuAcceleration = _ref2.gpuAcceleration, adaptive = _ref2.adaptive, roundOffsets = _ref2.roundOffsets, isFixed = _ref2.isFixed;
|
|
749
|
+
var _offsets$x = offsets.x, x = _offsets$x === void 0 ? 0 : _offsets$x, _offsets$y = offsets.y, y = _offsets$y === void 0 ? 0 : _offsets$y;
|
|
750
|
+
var _ref3 = typeof roundOffsets === "function" ? roundOffsets({
|
|
751
|
+
x,
|
|
752
|
+
y
|
|
753
|
+
}) : {
|
|
754
|
+
x,
|
|
755
|
+
y
|
|
756
|
+
};
|
|
757
|
+
x = _ref3.x;
|
|
758
|
+
y = _ref3.y;
|
|
759
|
+
var hasX = offsets.hasOwnProperty("x");
|
|
760
|
+
var hasY = offsets.hasOwnProperty("y");
|
|
761
|
+
var sideX = left;
|
|
762
|
+
var sideY = top;
|
|
763
|
+
var win = window;
|
|
764
|
+
if (adaptive) {
|
|
765
|
+
var offsetParent = getOffsetParent(popper2);
|
|
766
|
+
var heightProp = "clientHeight";
|
|
767
|
+
var widthProp = "clientWidth";
|
|
768
|
+
if (offsetParent === getWindow(popper2)) {
|
|
769
|
+
offsetParent = getDocumentElement(popper2);
|
|
770
|
+
if (getComputedStyle$1(offsetParent).position !== "static" && position === "absolute") {
|
|
771
|
+
heightProp = "scrollHeight";
|
|
772
|
+
widthProp = "scrollWidth";
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
offsetParent = offsetParent;
|
|
776
|
+
if (placement === top || (placement === left || placement === right) && variation === end) {
|
|
777
|
+
sideY = bottom;
|
|
778
|
+
var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : (
|
|
779
|
+
// $FlowFixMe[prop-missing]
|
|
780
|
+
offsetParent[heightProp]
|
|
781
|
+
);
|
|
782
|
+
y -= offsetY - popperRect.height;
|
|
783
|
+
y *= gpuAcceleration ? 1 : -1;
|
|
784
|
+
}
|
|
785
|
+
if (placement === left || (placement === top || placement === bottom) && variation === end) {
|
|
786
|
+
sideX = right;
|
|
787
|
+
var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : (
|
|
788
|
+
// $FlowFixMe[prop-missing]
|
|
789
|
+
offsetParent[widthProp]
|
|
790
|
+
);
|
|
791
|
+
x -= offsetX - popperRect.width;
|
|
792
|
+
x *= gpuAcceleration ? 1 : -1;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
var commonStyles = Object.assign({
|
|
796
|
+
position
|
|
797
|
+
}, adaptive && unsetSides);
|
|
798
|
+
var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
|
|
799
|
+
x,
|
|
800
|
+
y
|
|
801
|
+
}, getWindow(popper2)) : {
|
|
802
|
+
x,
|
|
803
|
+
y
|
|
804
|
+
};
|
|
805
|
+
x = _ref4.x;
|
|
806
|
+
y = _ref4.y;
|
|
807
|
+
if (gpuAcceleration) {
|
|
808
|
+
var _Object$assign;
|
|
809
|
+
return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? "0" : "", _Object$assign[sideX] = hasX ? "0" : "", _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
|
|
810
|
+
}
|
|
811
|
+
return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : "", _Object$assign2[sideX] = hasX ? x + "px" : "", _Object$assign2.transform = "", _Object$assign2));
|
|
812
|
+
}
|
|
813
|
+
function computeStyles(_ref5) {
|
|
814
|
+
var state = _ref5.state, options = _ref5.options;
|
|
815
|
+
var _options$gpuAccelerat = options.gpuAcceleration, gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat, _options$adaptive = options.adaptive, adaptive = _options$adaptive === void 0 ? true : _options$adaptive, _options$roundOffsets = options.roundOffsets, roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
|
|
816
|
+
var commonStyles = {
|
|
817
|
+
placement: getBasePlacement(state.placement),
|
|
818
|
+
variation: getVariation(state.placement),
|
|
819
|
+
popper: state.elements.popper,
|
|
820
|
+
popperRect: state.rects.popper,
|
|
821
|
+
gpuAcceleration,
|
|
822
|
+
isFixed: state.options.strategy === "fixed"
|
|
823
|
+
};
|
|
824
|
+
if (state.modifiersData.popperOffsets != null) {
|
|
825
|
+
state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
|
|
826
|
+
offsets: state.modifiersData.popperOffsets,
|
|
827
|
+
position: state.options.strategy,
|
|
828
|
+
adaptive,
|
|
829
|
+
roundOffsets
|
|
830
|
+
})));
|
|
831
|
+
}
|
|
832
|
+
if (state.modifiersData.arrow != null) {
|
|
833
|
+
state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
|
|
834
|
+
offsets: state.modifiersData.arrow,
|
|
835
|
+
position: "absolute",
|
|
836
|
+
adaptive: false,
|
|
837
|
+
roundOffsets
|
|
838
|
+
})));
|
|
839
|
+
}
|
|
840
|
+
state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
|
841
|
+
"data-popper-placement": state.placement
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
const computeStyles$1 = {
|
|
845
|
+
name: "computeStyles",
|
|
846
|
+
enabled: true,
|
|
847
|
+
phase: "beforeWrite",
|
|
848
|
+
fn: computeStyles,
|
|
849
|
+
data: {}
|
|
850
|
+
};
|
|
851
|
+
var passive = {
|
|
852
|
+
passive: true
|
|
853
|
+
};
|
|
854
|
+
function effect(_ref) {
|
|
855
|
+
var state = _ref.state, instance = _ref.instance, options = _ref.options;
|
|
856
|
+
var _options$scroll = options.scroll, scroll = _options$scroll === void 0 ? true : _options$scroll, _options$resize = options.resize, resize = _options$resize === void 0 ? true : _options$resize;
|
|
857
|
+
var window2 = getWindow(state.elements.popper);
|
|
858
|
+
var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
|
|
859
|
+
if (scroll) {
|
|
860
|
+
scrollParents.forEach(function(scrollParent) {
|
|
861
|
+
scrollParent.addEventListener("scroll", instance.update, passive);
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
if (resize) {
|
|
865
|
+
window2.addEventListener("resize", instance.update, passive);
|
|
866
|
+
}
|
|
867
|
+
return function() {
|
|
868
|
+
if (scroll) {
|
|
869
|
+
scrollParents.forEach(function(scrollParent) {
|
|
870
|
+
scrollParent.removeEventListener("scroll", instance.update, passive);
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
if (resize) {
|
|
874
|
+
window2.removeEventListener("resize", instance.update, passive);
|
|
875
|
+
}
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
const eventListeners = {
|
|
879
|
+
name: "eventListeners",
|
|
880
|
+
enabled: true,
|
|
881
|
+
phase: "write",
|
|
882
|
+
fn: function fn() {
|
|
883
|
+
},
|
|
884
|
+
effect,
|
|
885
|
+
data: {}
|
|
886
|
+
};
|
|
887
|
+
var hash$1 = {
|
|
888
|
+
left: "right",
|
|
889
|
+
right: "left",
|
|
890
|
+
bottom: "top",
|
|
891
|
+
top: "bottom"
|
|
892
|
+
};
|
|
893
|
+
function getOppositePlacement(placement) {
|
|
894
|
+
return placement.replace(/left|right|bottom|top/g, function(matched) {
|
|
895
|
+
return hash$1[matched];
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
var hash = {
|
|
899
|
+
start: "end",
|
|
900
|
+
end: "start"
|
|
901
|
+
};
|
|
902
|
+
function getOppositeVariationPlacement(placement) {
|
|
903
|
+
return placement.replace(/start|end/g, function(matched) {
|
|
904
|
+
return hash[matched];
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
function getWindowScroll(node) {
|
|
908
|
+
var win = getWindow(node);
|
|
909
|
+
var scrollLeft = win.pageXOffset;
|
|
910
|
+
var scrollTop = win.pageYOffset;
|
|
911
|
+
return {
|
|
912
|
+
scrollLeft,
|
|
913
|
+
scrollTop
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
function getWindowScrollBarX(element) {
|
|
917
|
+
return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
|
|
918
|
+
}
|
|
919
|
+
function getViewportRect(element, strategy) {
|
|
920
|
+
var win = getWindow(element);
|
|
921
|
+
var html = getDocumentElement(element);
|
|
922
|
+
var visualViewport = win.visualViewport;
|
|
923
|
+
var width = html.clientWidth;
|
|
924
|
+
var height = html.clientHeight;
|
|
925
|
+
var x = 0;
|
|
926
|
+
var y = 0;
|
|
927
|
+
if (visualViewport) {
|
|
928
|
+
width = visualViewport.width;
|
|
929
|
+
height = visualViewport.height;
|
|
930
|
+
var layoutViewport = isLayoutViewport();
|
|
931
|
+
if (layoutViewport || !layoutViewport && strategy === "fixed") {
|
|
932
|
+
x = visualViewport.offsetLeft;
|
|
933
|
+
y = visualViewport.offsetTop;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
return {
|
|
937
|
+
width,
|
|
938
|
+
height,
|
|
939
|
+
x: x + getWindowScrollBarX(element),
|
|
940
|
+
y
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
function getDocumentRect(element) {
|
|
944
|
+
var _element$ownerDocumen;
|
|
945
|
+
var html = getDocumentElement(element);
|
|
946
|
+
var winScroll = getWindowScroll(element);
|
|
947
|
+
var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
|
948
|
+
var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
|
949
|
+
var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
|
950
|
+
var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
|
|
951
|
+
var y = -winScroll.scrollTop;
|
|
952
|
+
if (getComputedStyle$1(body || html).direction === "rtl") {
|
|
953
|
+
x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
|
954
|
+
}
|
|
955
|
+
return {
|
|
956
|
+
width,
|
|
957
|
+
height,
|
|
958
|
+
x,
|
|
959
|
+
y
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
function isScrollParent(element) {
|
|
963
|
+
var _getComputedStyle = getComputedStyle$1(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
|
|
964
|
+
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|
965
|
+
}
|
|
966
|
+
function getScrollParent(node) {
|
|
967
|
+
if (["html", "body", "#document"].indexOf(getNodeName(node)) >= 0) {
|
|
968
|
+
return node.ownerDocument.body;
|
|
969
|
+
}
|
|
970
|
+
if (isHTMLElement(node) && isScrollParent(node)) {
|
|
971
|
+
return node;
|
|
972
|
+
}
|
|
973
|
+
return getScrollParent(getParentNode(node));
|
|
974
|
+
}
|
|
975
|
+
function listScrollParents(element, list) {
|
|
976
|
+
var _element$ownerDocumen;
|
|
977
|
+
if (list === void 0) {
|
|
978
|
+
list = [];
|
|
979
|
+
}
|
|
980
|
+
var scrollParent = getScrollParent(element);
|
|
981
|
+
var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
|
|
982
|
+
var win = getWindow(scrollParent);
|
|
983
|
+
var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
|
984
|
+
var updatedList = list.concat(target);
|
|
985
|
+
return isBody ? updatedList : (
|
|
986
|
+
// $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
|
|
987
|
+
updatedList.concat(listScrollParents(getParentNode(target)))
|
|
988
|
+
);
|
|
989
|
+
}
|
|
990
|
+
function rectToClientRect(rect) {
|
|
991
|
+
return Object.assign({}, rect, {
|
|
992
|
+
left: rect.x,
|
|
993
|
+
top: rect.y,
|
|
994
|
+
right: rect.x + rect.width,
|
|
995
|
+
bottom: rect.y + rect.height
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
999
|
+
var rect = getBoundingClientRect(element, false, strategy === "fixed");
|
|
1000
|
+
rect.top = rect.top + element.clientTop;
|
|
1001
|
+
rect.left = rect.left + element.clientLeft;
|
|
1002
|
+
rect.bottom = rect.top + element.clientHeight;
|
|
1003
|
+
rect.right = rect.left + element.clientWidth;
|
|
1004
|
+
rect.width = element.clientWidth;
|
|
1005
|
+
rect.height = element.clientHeight;
|
|
1006
|
+
rect.x = rect.left;
|
|
1007
|
+
rect.y = rect.top;
|
|
1008
|
+
return rect;
|
|
1009
|
+
}
|
|
1010
|
+
function getClientRectFromMixedType(element, clippingParent, strategy) {
|
|
1011
|
+
return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
1012
|
+
}
|
|
1013
|
+
function getClippingParents(element) {
|
|
1014
|
+
var clippingParents2 = listScrollParents(getParentNode(element));
|
|
1015
|
+
var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle$1(element).position) >= 0;
|
|
1016
|
+
var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
|
|
1017
|
+
if (!isElement(clipperElement)) {
|
|
1018
|
+
return [];
|
|
1019
|
+
}
|
|
1020
|
+
return clippingParents2.filter(function(clippingParent) {
|
|
1021
|
+
return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
function getClippingRect(element, boundary, rootBoundary, strategy) {
|
|
1025
|
+
var mainClippingParents = boundary === "clippingParents" ? getClippingParents(element) : [].concat(boundary);
|
|
1026
|
+
var clippingParents2 = [].concat(mainClippingParents, [rootBoundary]);
|
|
1027
|
+
var firstClippingParent = clippingParents2[0];
|
|
1028
|
+
var clippingRect = clippingParents2.reduce(function(accRect, clippingParent) {
|
|
1029
|
+
var rect = getClientRectFromMixedType(element, clippingParent, strategy);
|
|
1030
|
+
accRect.top = max(rect.top, accRect.top);
|
|
1031
|
+
accRect.right = min(rect.right, accRect.right);
|
|
1032
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
1033
|
+
accRect.left = max(rect.left, accRect.left);
|
|
1034
|
+
return accRect;
|
|
1035
|
+
}, getClientRectFromMixedType(element, firstClippingParent, strategy));
|
|
1036
|
+
clippingRect.width = clippingRect.right - clippingRect.left;
|
|
1037
|
+
clippingRect.height = clippingRect.bottom - clippingRect.top;
|
|
1038
|
+
clippingRect.x = clippingRect.left;
|
|
1039
|
+
clippingRect.y = clippingRect.top;
|
|
1040
|
+
return clippingRect;
|
|
1041
|
+
}
|
|
1042
|
+
function computeOffsets(_ref) {
|
|
1043
|
+
var reference2 = _ref.reference, element = _ref.element, placement = _ref.placement;
|
|
1044
|
+
var basePlacement = placement ? getBasePlacement(placement) : null;
|
|
1045
|
+
var variation = placement ? getVariation(placement) : null;
|
|
1046
|
+
var commonX = reference2.x + reference2.width / 2 - element.width / 2;
|
|
1047
|
+
var commonY = reference2.y + reference2.height / 2 - element.height / 2;
|
|
1048
|
+
var offsets;
|
|
1049
|
+
switch (basePlacement) {
|
|
1050
|
+
case top:
|
|
1051
|
+
offsets = {
|
|
1052
|
+
x: commonX,
|
|
1053
|
+
y: reference2.y - element.height
|
|
1054
|
+
};
|
|
1055
|
+
break;
|
|
1056
|
+
case bottom:
|
|
1057
|
+
offsets = {
|
|
1058
|
+
x: commonX,
|
|
1059
|
+
y: reference2.y + reference2.height
|
|
1060
|
+
};
|
|
1061
|
+
break;
|
|
1062
|
+
case right:
|
|
1063
|
+
offsets = {
|
|
1064
|
+
x: reference2.x + reference2.width,
|
|
1065
|
+
y: commonY
|
|
1066
|
+
};
|
|
1067
|
+
break;
|
|
1068
|
+
case left:
|
|
1069
|
+
offsets = {
|
|
1070
|
+
x: reference2.x - element.width,
|
|
1071
|
+
y: commonY
|
|
1072
|
+
};
|
|
1073
|
+
break;
|
|
1074
|
+
default:
|
|
1075
|
+
offsets = {
|
|
1076
|
+
x: reference2.x,
|
|
1077
|
+
y: reference2.y
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
|
|
1081
|
+
if (mainAxis != null) {
|
|
1082
|
+
var len = mainAxis === "y" ? "height" : "width";
|
|
1083
|
+
switch (variation) {
|
|
1084
|
+
case start:
|
|
1085
|
+
offsets[mainAxis] = offsets[mainAxis] - (reference2[len] / 2 - element[len] / 2);
|
|
1086
|
+
break;
|
|
1087
|
+
case end:
|
|
1088
|
+
offsets[mainAxis] = offsets[mainAxis] + (reference2[len] / 2 - element[len] / 2);
|
|
1089
|
+
break;
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
return offsets;
|
|
1093
|
+
}
|
|
1094
|
+
function detectOverflow(state, options) {
|
|
1095
|
+
if (options === void 0) {
|
|
1096
|
+
options = {};
|
|
1097
|
+
}
|
|
1098
|
+
var _options = options, _options$placement = _options.placement, placement = _options$placement === void 0 ? state.placement : _options$placement, _options$strategy = _options.strategy, strategy = _options$strategy === void 0 ? state.strategy : _options$strategy, _options$boundary = _options.boundary, boundary = _options$boundary === void 0 ? clippingParents : _options$boundary, _options$rootBoundary = _options.rootBoundary, rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary, _options$elementConte = _options.elementContext, elementContext = _options$elementConte === void 0 ? popper : _options$elementConte, _options$altBoundary = _options.altBoundary, altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary, _options$padding = _options.padding, padding = _options$padding === void 0 ? 0 : _options$padding;
|
|
1099
|
+
var paddingObject = mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
|
|
1100
|
+
var altContext = elementContext === popper ? reference : popper;
|
|
1101
|
+
var popperRect = state.rects.popper;
|
|
1102
|
+
var element = state.elements[altBoundary ? altContext : elementContext];
|
|
1103
|
+
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
|
|
1104
|
+
var referenceClientRect = getBoundingClientRect(state.elements.reference);
|
|
1105
|
+
var popperOffsets2 = computeOffsets({
|
|
1106
|
+
reference: referenceClientRect,
|
|
1107
|
+
element: popperRect,
|
|
1108
|
+
strategy: "absolute",
|
|
1109
|
+
placement
|
|
1110
|
+
});
|
|
1111
|
+
var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets2));
|
|
1112
|
+
var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
|
|
1113
|
+
var overflowOffsets = {
|
|
1114
|
+
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
|
1115
|
+
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
|
1116
|
+
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
|
1117
|
+
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
|
1118
|
+
};
|
|
1119
|
+
var offsetData = state.modifiersData.offset;
|
|
1120
|
+
if (elementContext === popper && offsetData) {
|
|
1121
|
+
var offset2 = offsetData[placement];
|
|
1122
|
+
Object.keys(overflowOffsets).forEach(function(key) {
|
|
1123
|
+
var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
|
|
1124
|
+
var axis = [top, bottom].indexOf(key) >= 0 ? "y" : "x";
|
|
1125
|
+
overflowOffsets[key] += offset2[axis] * multiply;
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
return overflowOffsets;
|
|
1129
|
+
}
|
|
1130
|
+
function computeAutoPlacement(state, options) {
|
|
1131
|
+
if (options === void 0) {
|
|
1132
|
+
options = {};
|
|
1133
|
+
}
|
|
1134
|
+
var _options = options, placement = _options.placement, boundary = _options.boundary, rootBoundary = _options.rootBoundary, padding = _options.padding, flipVariations = _options.flipVariations, _options$allowedAutoP = _options.allowedAutoPlacements, allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
|
|
1135
|
+
var variation = getVariation(placement);
|
|
1136
|
+
var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function(placement2) {
|
|
1137
|
+
return getVariation(placement2) === variation;
|
|
1138
|
+
}) : basePlacements;
|
|
1139
|
+
var allowedPlacements = placements$1.filter(function(placement2) {
|
|
1140
|
+
return allowedAutoPlacements.indexOf(placement2) >= 0;
|
|
1141
|
+
});
|
|
1142
|
+
if (allowedPlacements.length === 0) {
|
|
1143
|
+
allowedPlacements = placements$1;
|
|
1144
|
+
}
|
|
1145
|
+
var overflows = allowedPlacements.reduce(function(acc, placement2) {
|
|
1146
|
+
acc[placement2] = detectOverflow(state, {
|
|
1147
|
+
placement: placement2,
|
|
1148
|
+
boundary,
|
|
1149
|
+
rootBoundary,
|
|
1150
|
+
padding
|
|
1151
|
+
})[getBasePlacement(placement2)];
|
|
1152
|
+
return acc;
|
|
1153
|
+
}, {});
|
|
1154
|
+
return Object.keys(overflows).sort(function(a, b) {
|
|
1155
|
+
return overflows[a] - overflows[b];
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
function getExpandedFallbackPlacements(placement) {
|
|
1159
|
+
if (getBasePlacement(placement) === auto) {
|
|
1160
|
+
return [];
|
|
1161
|
+
}
|
|
1162
|
+
var oppositePlacement = getOppositePlacement(placement);
|
|
1163
|
+
return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
|
|
1164
|
+
}
|
|
1165
|
+
function flip(_ref) {
|
|
1166
|
+
var state = _ref.state, options = _ref.options, name = _ref.name;
|
|
1167
|
+
if (state.modifiersData[name]._skip) {
|
|
1168
|
+
return;
|
|
1169
|
+
}
|
|
1170
|
+
var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis, specifiedFallbackPlacements = options.fallbackPlacements, padding = options.padding, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, _options$flipVariatio = options.flipVariations, flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio, allowedAutoPlacements = options.allowedAutoPlacements;
|
|
1171
|
+
var preferredPlacement = state.options.placement;
|
|
1172
|
+
var basePlacement = getBasePlacement(preferredPlacement);
|
|
1173
|
+
var isBasePlacement = basePlacement === preferredPlacement;
|
|
1174
|
+
var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
|
|
1175
|
+
var placements2 = [preferredPlacement].concat(fallbackPlacements).reduce(function(acc, placement2) {
|
|
1176
|
+
return acc.concat(getBasePlacement(placement2) === auto ? computeAutoPlacement(state, {
|
|
1177
|
+
placement: placement2,
|
|
1178
|
+
boundary,
|
|
1179
|
+
rootBoundary,
|
|
1180
|
+
padding,
|
|
1181
|
+
flipVariations,
|
|
1182
|
+
allowedAutoPlacements
|
|
1183
|
+
}) : placement2);
|
|
1184
|
+
}, []);
|
|
1185
|
+
var referenceRect = state.rects.reference;
|
|
1186
|
+
var popperRect = state.rects.popper;
|
|
1187
|
+
var checksMap = /* @__PURE__ */ new Map();
|
|
1188
|
+
var makeFallbackChecks = true;
|
|
1189
|
+
var firstFittingPlacement = placements2[0];
|
|
1190
|
+
for (var i = 0; i < placements2.length; i++) {
|
|
1191
|
+
var placement = placements2[i];
|
|
1192
|
+
var _basePlacement = getBasePlacement(placement);
|
|
1193
|
+
var isStartVariation = getVariation(placement) === start;
|
|
1194
|
+
var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
|
|
1195
|
+
var len = isVertical ? "width" : "height";
|
|
1196
|
+
var overflow = detectOverflow(state, {
|
|
1197
|
+
placement,
|
|
1198
|
+
boundary,
|
|
1199
|
+
rootBoundary,
|
|
1200
|
+
altBoundary,
|
|
1201
|
+
padding
|
|
1202
|
+
});
|
|
1203
|
+
var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
|
|
1204
|
+
if (referenceRect[len] > popperRect[len]) {
|
|
1205
|
+
mainVariationSide = getOppositePlacement(mainVariationSide);
|
|
1206
|
+
}
|
|
1207
|
+
var altVariationSide = getOppositePlacement(mainVariationSide);
|
|
1208
|
+
var checks = [];
|
|
1209
|
+
if (checkMainAxis) {
|
|
1210
|
+
checks.push(overflow[_basePlacement] <= 0);
|
|
1211
|
+
}
|
|
1212
|
+
if (checkAltAxis) {
|
|
1213
|
+
checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
|
|
1214
|
+
}
|
|
1215
|
+
if (checks.every(function(check) {
|
|
1216
|
+
return check;
|
|
1217
|
+
})) {
|
|
1218
|
+
firstFittingPlacement = placement;
|
|
1219
|
+
makeFallbackChecks = false;
|
|
1220
|
+
break;
|
|
1221
|
+
}
|
|
1222
|
+
checksMap.set(placement, checks);
|
|
1223
|
+
}
|
|
1224
|
+
if (makeFallbackChecks) {
|
|
1225
|
+
var numberOfChecks = flipVariations ? 3 : 1;
|
|
1226
|
+
var _loop = function _loop2(_i2) {
|
|
1227
|
+
var fittingPlacement = placements2.find(function(placement2) {
|
|
1228
|
+
var checks2 = checksMap.get(placement2);
|
|
1229
|
+
if (checks2) {
|
|
1230
|
+
return checks2.slice(0, _i2).every(function(check) {
|
|
1231
|
+
return check;
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
});
|
|
1235
|
+
if (fittingPlacement) {
|
|
1236
|
+
firstFittingPlacement = fittingPlacement;
|
|
1237
|
+
return "break";
|
|
1238
|
+
}
|
|
1239
|
+
};
|
|
1240
|
+
for (var _i = numberOfChecks; _i > 0; _i--) {
|
|
1241
|
+
var _ret = _loop(_i);
|
|
1242
|
+
if (_ret === "break") break;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
if (state.placement !== firstFittingPlacement) {
|
|
1246
|
+
state.modifiersData[name]._skip = true;
|
|
1247
|
+
state.placement = firstFittingPlacement;
|
|
1248
|
+
state.reset = true;
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
const flip$1 = {
|
|
1252
|
+
name: "flip",
|
|
1253
|
+
enabled: true,
|
|
1254
|
+
phase: "main",
|
|
1255
|
+
fn: flip,
|
|
1256
|
+
requiresIfExists: ["offset"],
|
|
1257
|
+
data: {
|
|
1258
|
+
_skip: false
|
|
1259
|
+
}
|
|
1260
|
+
};
|
|
1261
|
+
function getSideOffsets(overflow, rect, preventedOffsets) {
|
|
1262
|
+
if (preventedOffsets === void 0) {
|
|
1263
|
+
preventedOffsets = {
|
|
1264
|
+
x: 0,
|
|
1265
|
+
y: 0
|
|
1266
|
+
};
|
|
1267
|
+
}
|
|
1268
|
+
return {
|
|
1269
|
+
top: overflow.top - rect.height - preventedOffsets.y,
|
|
1270
|
+
right: overflow.right - rect.width + preventedOffsets.x,
|
|
1271
|
+
bottom: overflow.bottom - rect.height + preventedOffsets.y,
|
|
1272
|
+
left: overflow.left - rect.width - preventedOffsets.x
|
|
1273
|
+
};
|
|
1274
|
+
}
|
|
1275
|
+
function isAnySideFullyClipped(overflow) {
|
|
1276
|
+
return [top, right, bottom, left].some(function(side) {
|
|
1277
|
+
return overflow[side] >= 0;
|
|
1278
|
+
});
|
|
1279
|
+
}
|
|
1280
|
+
function hide(_ref) {
|
|
1281
|
+
var state = _ref.state, name = _ref.name;
|
|
1282
|
+
var referenceRect = state.rects.reference;
|
|
1283
|
+
var popperRect = state.rects.popper;
|
|
1284
|
+
var preventedOffsets = state.modifiersData.preventOverflow;
|
|
1285
|
+
var referenceOverflow = detectOverflow(state, {
|
|
1286
|
+
elementContext: "reference"
|
|
1287
|
+
});
|
|
1288
|
+
var popperAltOverflow = detectOverflow(state, {
|
|
1289
|
+
altBoundary: true
|
|
1290
|
+
});
|
|
1291
|
+
var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
|
|
1292
|
+
var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
|
|
1293
|
+
var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
|
|
1294
|
+
var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
|
|
1295
|
+
state.modifiersData[name] = {
|
|
1296
|
+
referenceClippingOffsets,
|
|
1297
|
+
popperEscapeOffsets,
|
|
1298
|
+
isReferenceHidden,
|
|
1299
|
+
hasPopperEscaped
|
|
1300
|
+
};
|
|
1301
|
+
state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
|
1302
|
+
"data-popper-reference-hidden": isReferenceHidden,
|
|
1303
|
+
"data-popper-escaped": hasPopperEscaped
|
|
1304
|
+
});
|
|
1305
|
+
}
|
|
1306
|
+
const hide$1 = {
|
|
1307
|
+
name: "hide",
|
|
1308
|
+
enabled: true,
|
|
1309
|
+
phase: "main",
|
|
1310
|
+
requiresIfExists: ["preventOverflow"],
|
|
1311
|
+
fn: hide
|
|
1312
|
+
};
|
|
1313
|
+
function distanceAndSkiddingToXY(placement, rects, offset2) {
|
|
1314
|
+
var basePlacement = getBasePlacement(placement);
|
|
1315
|
+
var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
|
|
1316
|
+
var _ref = typeof offset2 === "function" ? offset2(Object.assign({}, rects, {
|
|
1317
|
+
placement
|
|
1318
|
+
})) : offset2, skidding = _ref[0], distance = _ref[1];
|
|
1319
|
+
skidding = skidding || 0;
|
|
1320
|
+
distance = (distance || 0) * invertDistance;
|
|
1321
|
+
return [left, right].indexOf(basePlacement) >= 0 ? {
|
|
1322
|
+
x: distance,
|
|
1323
|
+
y: skidding
|
|
1324
|
+
} : {
|
|
1325
|
+
x: skidding,
|
|
1326
|
+
y: distance
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1329
|
+
function offset(_ref2) {
|
|
1330
|
+
var state = _ref2.state, options = _ref2.options, name = _ref2.name;
|
|
1331
|
+
var _options$offset = options.offset, offset2 = _options$offset === void 0 ? [0, 0] : _options$offset;
|
|
1332
|
+
var data = placements.reduce(function(acc, placement) {
|
|
1333
|
+
acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset2);
|
|
1334
|
+
return acc;
|
|
1335
|
+
}, {});
|
|
1336
|
+
var _data$state$placement = data[state.placement], x = _data$state$placement.x, y = _data$state$placement.y;
|
|
1337
|
+
if (state.modifiersData.popperOffsets != null) {
|
|
1338
|
+
state.modifiersData.popperOffsets.x += x;
|
|
1339
|
+
state.modifiersData.popperOffsets.y += y;
|
|
1340
|
+
}
|
|
1341
|
+
state.modifiersData[name] = data;
|
|
1342
|
+
}
|
|
1343
|
+
const offset$1 = {
|
|
1344
|
+
name: "offset",
|
|
1345
|
+
enabled: true,
|
|
1346
|
+
phase: "main",
|
|
1347
|
+
requires: ["popperOffsets"],
|
|
1348
|
+
fn: offset
|
|
1349
|
+
};
|
|
1350
|
+
function popperOffsets(_ref) {
|
|
1351
|
+
var state = _ref.state, name = _ref.name;
|
|
1352
|
+
state.modifiersData[name] = computeOffsets({
|
|
1353
|
+
reference: state.rects.reference,
|
|
1354
|
+
element: state.rects.popper,
|
|
1355
|
+
strategy: "absolute",
|
|
1356
|
+
placement: state.placement
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1359
|
+
const popperOffsets$1 = {
|
|
1360
|
+
name: "popperOffsets",
|
|
1361
|
+
enabled: true,
|
|
1362
|
+
phase: "read",
|
|
1363
|
+
fn: popperOffsets,
|
|
1364
|
+
data: {}
|
|
1365
|
+
};
|
|
1366
|
+
function getAltAxis(axis) {
|
|
1367
|
+
return axis === "x" ? "y" : "x";
|
|
1368
|
+
}
|
|
1369
|
+
function preventOverflow(_ref) {
|
|
1370
|
+
var state = _ref.state, options = _ref.options, name = _ref.name;
|
|
1371
|
+
var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, padding = options.padding, _options$tether = options.tether, tether = _options$tether === void 0 ? true : _options$tether, _options$tetherOffset = options.tetherOffset, tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
|
|
1372
|
+
var overflow = detectOverflow(state, {
|
|
1373
|
+
boundary,
|
|
1374
|
+
rootBoundary,
|
|
1375
|
+
padding,
|
|
1376
|
+
altBoundary
|
|
1377
|
+
});
|
|
1378
|
+
var basePlacement = getBasePlacement(state.placement);
|
|
1379
|
+
var variation = getVariation(state.placement);
|
|
1380
|
+
var isBasePlacement = !variation;
|
|
1381
|
+
var mainAxis = getMainAxisFromPlacement(basePlacement);
|
|
1382
|
+
var altAxis = getAltAxis(mainAxis);
|
|
1383
|
+
var popperOffsets2 = state.modifiersData.popperOffsets;
|
|
1384
|
+
var referenceRect = state.rects.reference;
|
|
1385
|
+
var popperRect = state.rects.popper;
|
|
1386
|
+
var tetherOffsetValue = typeof tetherOffset === "function" ? tetherOffset(Object.assign({}, state.rects, {
|
|
1387
|
+
placement: state.placement
|
|
1388
|
+
})) : tetherOffset;
|
|
1389
|
+
var normalizedTetherOffsetValue = typeof tetherOffsetValue === "number" ? {
|
|
1390
|
+
mainAxis: tetherOffsetValue,
|
|
1391
|
+
altAxis: tetherOffsetValue
|
|
1392
|
+
} : Object.assign({
|
|
1393
|
+
mainAxis: 0,
|
|
1394
|
+
altAxis: 0
|
|
1395
|
+
}, tetherOffsetValue);
|
|
1396
|
+
var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
|
|
1397
|
+
var data = {
|
|
1398
|
+
x: 0,
|
|
1399
|
+
y: 0
|
|
1400
|
+
};
|
|
1401
|
+
if (!popperOffsets2) {
|
|
1402
|
+
return;
|
|
1403
|
+
}
|
|
1404
|
+
if (checkMainAxis) {
|
|
1405
|
+
var _offsetModifierState$;
|
|
1406
|
+
var mainSide = mainAxis === "y" ? top : left;
|
|
1407
|
+
var altSide = mainAxis === "y" ? bottom : right;
|
|
1408
|
+
var len = mainAxis === "y" ? "height" : "width";
|
|
1409
|
+
var offset2 = popperOffsets2[mainAxis];
|
|
1410
|
+
var min$1 = offset2 + overflow[mainSide];
|
|
1411
|
+
var max$1 = offset2 - overflow[altSide];
|
|
1412
|
+
var additive = tether ? -popperRect[len] / 2 : 0;
|
|
1413
|
+
var minLen = variation === start ? referenceRect[len] : popperRect[len];
|
|
1414
|
+
var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
|
|
1415
|
+
var arrowElement = state.elements.arrow;
|
|
1416
|
+
var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
|
|
1417
|
+
width: 0,
|
|
1418
|
+
height: 0
|
|
1419
|
+
};
|
|
1420
|
+
var arrowPaddingObject = state.modifiersData["arrow#persistent"] ? state.modifiersData["arrow#persistent"].padding : getFreshSideObject();
|
|
1421
|
+
var arrowPaddingMin = arrowPaddingObject[mainSide];
|
|
1422
|
+
var arrowPaddingMax = arrowPaddingObject[altSide];
|
|
1423
|
+
var arrowLen = within(0, referenceRect[len], arrowRect[len]);
|
|
1424
|
+
var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
|
|
1425
|
+
var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
|
|
1426
|
+
var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
|
|
1427
|
+
var clientOffset = arrowOffsetParent ? mainAxis === "y" ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
|
|
1428
|
+
var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
|
|
1429
|
+
var tetherMin = offset2 + minOffset - offsetModifierValue - clientOffset;
|
|
1430
|
+
var tetherMax = offset2 + maxOffset - offsetModifierValue;
|
|
1431
|
+
var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset2, tether ? max(max$1, tetherMax) : max$1);
|
|
1432
|
+
popperOffsets2[mainAxis] = preventedOffset;
|
|
1433
|
+
data[mainAxis] = preventedOffset - offset2;
|
|
1434
|
+
}
|
|
1435
|
+
if (checkAltAxis) {
|
|
1436
|
+
var _offsetModifierState$2;
|
|
1437
|
+
var _mainSide = mainAxis === "x" ? top : left;
|
|
1438
|
+
var _altSide = mainAxis === "x" ? bottom : right;
|
|
1439
|
+
var _offset = popperOffsets2[altAxis];
|
|
1440
|
+
var _len = altAxis === "y" ? "height" : "width";
|
|
1441
|
+
var _min = _offset + overflow[_mainSide];
|
|
1442
|
+
var _max = _offset - overflow[_altSide];
|
|
1443
|
+
var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
|
|
1444
|
+
var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
|
|
1445
|
+
var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
|
|
1446
|
+
var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
|
|
1447
|
+
var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
|
|
1448
|
+
popperOffsets2[altAxis] = _preventedOffset;
|
|
1449
|
+
data[altAxis] = _preventedOffset - _offset;
|
|
1450
|
+
}
|
|
1451
|
+
state.modifiersData[name] = data;
|
|
1452
|
+
}
|
|
1453
|
+
const preventOverflow$1 = {
|
|
1454
|
+
name: "preventOverflow",
|
|
1455
|
+
enabled: true,
|
|
1456
|
+
phase: "main",
|
|
1457
|
+
fn: preventOverflow,
|
|
1458
|
+
requiresIfExists: ["offset"]
|
|
1459
|
+
};
|
|
1460
|
+
function getHTMLElementScroll(element) {
|
|
1461
|
+
return {
|
|
1462
|
+
scrollLeft: element.scrollLeft,
|
|
1463
|
+
scrollTop: element.scrollTop
|
|
1464
|
+
};
|
|
1465
|
+
}
|
|
1466
|
+
function getNodeScroll(node) {
|
|
1467
|
+
if (node === getWindow(node) || !isHTMLElement(node)) {
|
|
1468
|
+
return getWindowScroll(node);
|
|
1469
|
+
} else {
|
|
1470
|
+
return getHTMLElementScroll(node);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
function isElementScaled(element) {
|
|
1474
|
+
var rect = element.getBoundingClientRect();
|
|
1475
|
+
var scaleX = round(rect.width) / element.offsetWidth || 1;
|
|
1476
|
+
var scaleY = round(rect.height) / element.offsetHeight || 1;
|
|
1477
|
+
return scaleX !== 1 || scaleY !== 1;
|
|
1478
|
+
}
|
|
1479
|
+
function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
|
1480
|
+
if (isFixed === void 0) {
|
|
1481
|
+
isFixed = false;
|
|
1482
|
+
}
|
|
1483
|
+
var isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1484
|
+
var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
|
|
1485
|
+
var documentElement = getDocumentElement(offsetParent);
|
|
1486
|
+
var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
|
|
1487
|
+
var scroll = {
|
|
1488
|
+
scrollLeft: 0,
|
|
1489
|
+
scrollTop: 0
|
|
1490
|
+
};
|
|
1491
|
+
var offsets = {
|
|
1492
|
+
x: 0,
|
|
1493
|
+
y: 0
|
|
1494
|
+
};
|
|
1495
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1496
|
+
if (getNodeName(offsetParent) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
|
|
1497
|
+
isScrollParent(documentElement)) {
|
|
1498
|
+
scroll = getNodeScroll(offsetParent);
|
|
1499
|
+
}
|
|
1500
|
+
if (isHTMLElement(offsetParent)) {
|
|
1501
|
+
offsets = getBoundingClientRect(offsetParent, true);
|
|
1502
|
+
offsets.x += offsetParent.clientLeft;
|
|
1503
|
+
offsets.y += offsetParent.clientTop;
|
|
1504
|
+
} else if (documentElement) {
|
|
1505
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
return {
|
|
1509
|
+
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
1510
|
+
y: rect.top + scroll.scrollTop - offsets.y,
|
|
1511
|
+
width: rect.width,
|
|
1512
|
+
height: rect.height
|
|
1513
|
+
};
|
|
1514
|
+
}
|
|
1515
|
+
function order(modifiers) {
|
|
1516
|
+
var map = /* @__PURE__ */ new Map();
|
|
1517
|
+
var visited = /* @__PURE__ */ new Set();
|
|
1518
|
+
var result = [];
|
|
1519
|
+
modifiers.forEach(function(modifier) {
|
|
1520
|
+
map.set(modifier.name, modifier);
|
|
1521
|
+
});
|
|
1522
|
+
function sort(modifier) {
|
|
1523
|
+
visited.add(modifier.name);
|
|
1524
|
+
var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
|
|
1525
|
+
requires.forEach(function(dep) {
|
|
1526
|
+
if (!visited.has(dep)) {
|
|
1527
|
+
var depModifier = map.get(dep);
|
|
1528
|
+
if (depModifier) {
|
|
1529
|
+
sort(depModifier);
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
});
|
|
1533
|
+
result.push(modifier);
|
|
1534
|
+
}
|
|
1535
|
+
modifiers.forEach(function(modifier) {
|
|
1536
|
+
if (!visited.has(modifier.name)) {
|
|
1537
|
+
sort(modifier);
|
|
1538
|
+
}
|
|
1539
|
+
});
|
|
1540
|
+
return result;
|
|
1541
|
+
}
|
|
1542
|
+
function orderModifiers(modifiers) {
|
|
1543
|
+
var orderedModifiers = order(modifiers);
|
|
1544
|
+
return modifierPhases.reduce(function(acc, phase) {
|
|
1545
|
+
return acc.concat(orderedModifiers.filter(function(modifier) {
|
|
1546
|
+
return modifier.phase === phase;
|
|
1547
|
+
}));
|
|
1548
|
+
}, []);
|
|
1549
|
+
}
|
|
1550
|
+
function debounce(fn2) {
|
|
1551
|
+
var pending;
|
|
1552
|
+
return function() {
|
|
1553
|
+
if (!pending) {
|
|
1554
|
+
pending = new Promise(function(resolve) {
|
|
1555
|
+
Promise.resolve().then(function() {
|
|
1556
|
+
pending = void 0;
|
|
1557
|
+
resolve(fn2());
|
|
1558
|
+
});
|
|
1559
|
+
});
|
|
1560
|
+
}
|
|
1561
|
+
return pending;
|
|
1562
|
+
};
|
|
1563
|
+
}
|
|
1564
|
+
function mergeByName(modifiers) {
|
|
1565
|
+
var merged = modifiers.reduce(function(merged2, current) {
|
|
1566
|
+
var existing = merged2[current.name];
|
|
1567
|
+
merged2[current.name] = existing ? Object.assign({}, existing, current, {
|
|
1568
|
+
options: Object.assign({}, existing.options, current.options),
|
|
1569
|
+
data: Object.assign({}, existing.data, current.data)
|
|
1570
|
+
}) : current;
|
|
1571
|
+
return merged2;
|
|
1572
|
+
}, {});
|
|
1573
|
+
return Object.keys(merged).map(function(key) {
|
|
1574
|
+
return merged[key];
|
|
1575
|
+
});
|
|
1576
|
+
}
|
|
1577
|
+
var DEFAULT_OPTIONS = {
|
|
1578
|
+
placement: "bottom",
|
|
1579
|
+
modifiers: [],
|
|
1580
|
+
strategy: "absolute"
|
|
1581
|
+
};
|
|
1582
|
+
function areValidElements() {
|
|
1583
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1584
|
+
args[_key] = arguments[_key];
|
|
1585
|
+
}
|
|
1586
|
+
return !args.some(function(element) {
|
|
1587
|
+
return !(element && typeof element.getBoundingClientRect === "function");
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
function popperGenerator(generatorOptions) {
|
|
1591
|
+
if (generatorOptions === void 0) {
|
|
1592
|
+
generatorOptions = {};
|
|
1593
|
+
}
|
|
1594
|
+
var _generatorOptions = generatorOptions, _generatorOptions$def = _generatorOptions.defaultModifiers, defaultModifiers2 = _generatorOptions$def === void 0 ? [] : _generatorOptions$def, _generatorOptions$def2 = _generatorOptions.defaultOptions, defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
|
|
1595
|
+
return function createPopper2(reference2, popper2, options) {
|
|
1596
|
+
if (options === void 0) {
|
|
1597
|
+
options = defaultOptions;
|
|
1598
|
+
}
|
|
1599
|
+
var state = {
|
|
1600
|
+
placement: "bottom",
|
|
1601
|
+
orderedModifiers: [],
|
|
1602
|
+
options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
|
|
1603
|
+
modifiersData: {},
|
|
1604
|
+
elements: {
|
|
1605
|
+
reference: reference2,
|
|
1606
|
+
popper: popper2
|
|
1607
|
+
},
|
|
1608
|
+
attributes: {},
|
|
1609
|
+
styles: {}
|
|
1610
|
+
};
|
|
1611
|
+
var effectCleanupFns = [];
|
|
1612
|
+
var isDestroyed = false;
|
|
1613
|
+
var instance = {
|
|
1614
|
+
state,
|
|
1615
|
+
setOptions: function setOptions(setOptionsAction) {
|
|
1616
|
+
var options2 = typeof setOptionsAction === "function" ? setOptionsAction(state.options) : setOptionsAction;
|
|
1617
|
+
cleanupModifierEffects();
|
|
1618
|
+
state.options = Object.assign({}, defaultOptions, state.options, options2);
|
|
1619
|
+
state.scrollParents = {
|
|
1620
|
+
reference: isElement(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
|
|
1621
|
+
popper: listScrollParents(popper2)
|
|
1622
|
+
};
|
|
1623
|
+
var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers2, state.options.modifiers)));
|
|
1624
|
+
state.orderedModifiers = orderedModifiers.filter(function(m) {
|
|
1625
|
+
return m.enabled;
|
|
1626
|
+
});
|
|
1627
|
+
runModifierEffects();
|
|
1628
|
+
return instance.update();
|
|
1629
|
+
},
|
|
1630
|
+
// Sync update – it will always be executed, even if not necessary. This
|
|
1631
|
+
// is useful for low frequency updates where sync behavior simplifies the
|
|
1632
|
+
// logic.
|
|
1633
|
+
// For high frequency updates (e.g. `resize` and `scroll` events), always
|
|
1634
|
+
// prefer the async Popper#update method
|
|
1635
|
+
forceUpdate: function forceUpdate() {
|
|
1636
|
+
if (isDestroyed) {
|
|
1637
|
+
return;
|
|
1638
|
+
}
|
|
1639
|
+
var _state$elements = state.elements, reference3 = _state$elements.reference, popper3 = _state$elements.popper;
|
|
1640
|
+
if (!areValidElements(reference3, popper3)) {
|
|
1641
|
+
return;
|
|
1642
|
+
}
|
|
1643
|
+
state.rects = {
|
|
1644
|
+
reference: getCompositeRect(reference3, getOffsetParent(popper3), state.options.strategy === "fixed"),
|
|
1645
|
+
popper: getLayoutRect(popper3)
|
|
1646
|
+
};
|
|
1647
|
+
state.reset = false;
|
|
1648
|
+
state.placement = state.options.placement;
|
|
1649
|
+
state.orderedModifiers.forEach(function(modifier) {
|
|
1650
|
+
return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
|
|
1651
|
+
});
|
|
1652
|
+
for (var index = 0; index < state.orderedModifiers.length; index++) {
|
|
1653
|
+
if (state.reset === true) {
|
|
1654
|
+
state.reset = false;
|
|
1655
|
+
index = -1;
|
|
1656
|
+
continue;
|
|
1657
|
+
}
|
|
1658
|
+
var _state$orderedModifie = state.orderedModifiers[index], fn2 = _state$orderedModifie.fn, _state$orderedModifie2 = _state$orderedModifie.options, _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2, name = _state$orderedModifie.name;
|
|
1659
|
+
if (typeof fn2 === "function") {
|
|
1660
|
+
state = fn2({
|
|
1661
|
+
state,
|
|
1662
|
+
options: _options,
|
|
1663
|
+
name,
|
|
1664
|
+
instance
|
|
1665
|
+
}) || state;
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
},
|
|
1669
|
+
// Async and optimistically optimized update – it will not be executed if
|
|
1670
|
+
// not necessary (debounced to run at most once-per-tick)
|
|
1671
|
+
update: debounce(function() {
|
|
1672
|
+
return new Promise(function(resolve) {
|
|
1673
|
+
instance.forceUpdate();
|
|
1674
|
+
resolve(state);
|
|
1675
|
+
});
|
|
1676
|
+
}),
|
|
1677
|
+
destroy: function destroy() {
|
|
1678
|
+
cleanupModifierEffects();
|
|
1679
|
+
isDestroyed = true;
|
|
1680
|
+
}
|
|
1681
|
+
};
|
|
1682
|
+
if (!areValidElements(reference2, popper2)) {
|
|
1683
|
+
return instance;
|
|
1684
|
+
}
|
|
1685
|
+
instance.setOptions(options).then(function(state2) {
|
|
1686
|
+
if (!isDestroyed && options.onFirstUpdate) {
|
|
1687
|
+
options.onFirstUpdate(state2);
|
|
1688
|
+
}
|
|
1689
|
+
});
|
|
1690
|
+
function runModifierEffects() {
|
|
1691
|
+
state.orderedModifiers.forEach(function(_ref) {
|
|
1692
|
+
var name = _ref.name, _ref$options = _ref.options, options2 = _ref$options === void 0 ? {} : _ref$options, effect2 = _ref.effect;
|
|
1693
|
+
if (typeof effect2 === "function") {
|
|
1694
|
+
var cleanupFn = effect2({
|
|
1695
|
+
state,
|
|
1696
|
+
name,
|
|
1697
|
+
instance,
|
|
1698
|
+
options: options2
|
|
1699
|
+
});
|
|
1700
|
+
var noopFn = function noopFn2() {
|
|
1701
|
+
};
|
|
1702
|
+
effectCleanupFns.push(cleanupFn || noopFn);
|
|
1703
|
+
}
|
|
1704
|
+
});
|
|
1705
|
+
}
|
|
1706
|
+
function cleanupModifierEffects() {
|
|
1707
|
+
effectCleanupFns.forEach(function(fn2) {
|
|
1708
|
+
return fn2();
|
|
1709
|
+
});
|
|
1710
|
+
effectCleanupFns = [];
|
|
1711
|
+
}
|
|
1712
|
+
return instance;
|
|
1713
|
+
};
|
|
1714
|
+
}
|
|
1715
|
+
var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
|
|
1716
|
+
var createPopper = /* @__PURE__ */ popperGenerator({
|
|
1717
|
+
defaultModifiers
|
|
1718
|
+
});
|
|
1719
|
+
const rgb2hsv = ([r, g, b, a]) => {
|
|
1720
|
+
const v = Math.max(r, g, b);
|
|
1721
|
+
const c = v - Math.min(r, g, b);
|
|
1722
|
+
const h = c && (v == r ? (g - b) / c : v == g ? 2 + (b - r) / c : 4 + (r - g) / c);
|
|
1723
|
+
return [60 * (h < 0 ? h + 6 : h), v && c / v, v, a];
|
|
1724
|
+
};
|
|
1725
|
+
const strip = (input) => input.replace(/[^0-9%.,]/g, "").split(",").map((v) => parseFloat(v) / (v.endsWith("%") ? 100 : 1));
|
|
1726
|
+
const parseCSS = (input) => {
|
|
1727
|
+
const $el = document.createElement("span");
|
|
1728
|
+
$el.style.display = "none";
|
|
1729
|
+
$el.style.color = input;
|
|
1730
|
+
document.body.append($el);
|
|
1731
|
+
const { color } = getComputedStyle($el);
|
|
1732
|
+
$el.remove();
|
|
1733
|
+
if (!color) return null;
|
|
1734
|
+
const [r, g, b, a] = strip(color);
|
|
1735
|
+
return rgb2hsv([r / 255, g / 255, b / 255, a]);
|
|
1736
|
+
};
|
|
1737
|
+
const parseHSV = (input) => {
|
|
1738
|
+
const color = strip(input).map((v, i) => Math.min(v, i ? 1 : 255));
|
|
1739
|
+
if (color.length < 3 || color.some((v) => isNaN(v))) return null;
|
|
1740
|
+
return color;
|
|
1741
|
+
};
|
|
1742
|
+
const parseColor = (input) => {
|
|
1743
|
+
let format;
|
|
1744
|
+
if (/^hsva?\(/i.test(input)) format = "hsv";
|
|
1745
|
+
else if (/^hsla?\(/i.test(input)) format = "hsl";
|
|
1746
|
+
else if (/^rgba?\(/i.test(input)) format = "rgb";
|
|
1747
|
+
else if (/^oklch\(/i.test(input)) format = "oklch";
|
|
1748
|
+
else format = "hex";
|
|
1749
|
+
const color = format === "hsv" ? parseHSV(input) : parseCSS(input);
|
|
1750
|
+
if (!color) throw new Error("Color could not be parsed!");
|
|
1751
|
+
color[3] = color[3] ?? 1;
|
|
1752
|
+
return { color, format };
|
|
1753
|
+
};
|
|
1754
|
+
const chop = (v) => v.toFixed();
|
|
1755
|
+
const fix = (v, p) => ("" + +v.toFixed(p)).replace(/^0\./g, ".");
|
|
1756
|
+
const hsv2hsl = ([h, s, v, a]) => {
|
|
1757
|
+
const l = v - v * s / 2;
|
|
1758
|
+
const m = Math.min(l, 1 - l);
|
|
1759
|
+
return [h, m ? (v - l) / m : 0, l, a];
|
|
1760
|
+
};
|
|
1761
|
+
const hsv2rgb = ([h, s, v, a]) => {
|
|
1762
|
+
const f = (n, k = (n + h / 60) % 6) => v - v * s * Math.max(Math.min(k, 4 - k, 1), 0);
|
|
1763
|
+
return [f(5), f(3), f(1), a];
|
|
1764
|
+
};
|
|
1765
|
+
const toFn = ([c1, c2, c3, a], name, forceAlpha = false) => {
|
|
1766
|
+
const includeAlpha = forceAlpha || a < 1;
|
|
1767
|
+
if ("rgb" === name && includeAlpha) {
|
|
1768
|
+
name = "rgba";
|
|
1769
|
+
}
|
|
1770
|
+
const values = name.startsWith("hs") ? [chop(c1), chop(c2 * 100) + "%", chop(c3 * 100) + "%"] : [chop(c1 * 255), chop(c2 * 255), chop(c3 * 255)];
|
|
1771
|
+
if (includeAlpha) values.push(fix(a, 2));
|
|
1772
|
+
return `${name}(${values.join()})`;
|
|
1773
|
+
};
|
|
1774
|
+
const toHex = (color) => "#" + color.slice(0, color[3] < 1 ? 4 : 3).map(
|
|
1775
|
+
(v) => Math.round(v * 255).toString(16).padStart(2, "0")
|
|
1776
|
+
).join("");
|
|
1777
|
+
const srgbToLinear = (c) => c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
1778
|
+
const hsv2oklch = (hsv) => {
|
|
1779
|
+
const [r, g, b, a] = hsv2rgb(hsv);
|
|
1780
|
+
const lr = srgbToLinear(r);
|
|
1781
|
+
const lg = srgbToLinear(g);
|
|
1782
|
+
const lb = srgbToLinear(b);
|
|
1783
|
+
const l = 0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb;
|
|
1784
|
+
const m = 0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb;
|
|
1785
|
+
const s = 0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb;
|
|
1786
|
+
const l_ = Math.cbrt(l);
|
|
1787
|
+
const m_ = Math.cbrt(m);
|
|
1788
|
+
const s_ = Math.cbrt(s);
|
|
1789
|
+
const L = 0.2104542553 * l_ + 0.793617785 * m_ - 0.0040720468 * s_;
|
|
1790
|
+
const A = 1.9779984951 * l_ - 2.428592205 * m_ + 0.4505937099 * s_;
|
|
1791
|
+
const B = 0.0259040371 * l_ + 0.7827717662 * m_ - 0.808675766 * s_;
|
|
1792
|
+
const C = Math.sqrt(A * A + B * B);
|
|
1793
|
+
const H = (Math.atan2(B, A) * 180 / Math.PI + 360) % 360;
|
|
1794
|
+
return [L, C, H, a];
|
|
1795
|
+
};
|
|
1796
|
+
const toOklch = ([L, C, H, a]) => {
|
|
1797
|
+
const includeAlpha = a < 1;
|
|
1798
|
+
const parts = `${fix(L, 3)} ${fix(C, 3)} ${fix(H, 2)}`;
|
|
1799
|
+
return includeAlpha ? `oklch(${parts} / ${fix(a, 2)})` : `oklch(${parts})`;
|
|
1800
|
+
};
|
|
1801
|
+
const convertColor = (color, format) => {
|
|
1802
|
+
if (format === "hsv") return toFn(color, format);
|
|
1803
|
+
if (format === "hsl") return toFn(hsv2hsl(color), format);
|
|
1804
|
+
if (format === "rgb") return toFn(hsv2rgb(color), format);
|
|
1805
|
+
if (format === "rgba") return toFn(hsv2rgb(color), format, true);
|
|
1806
|
+
if (format === "oklch") return toOklch(hsv2oklch(color));
|
|
1807
|
+
return toHex(hsv2rgb(color));
|
|
1808
|
+
};
|
|
1809
|
+
class Color {
|
|
1810
|
+
constructor(from) {
|
|
1811
|
+
__publicField(this, "color");
|
|
1812
|
+
if (!from) {
|
|
1813
|
+
this.color = [0, 0, 0, 1];
|
|
1814
|
+
} else if (from instanceof Color) {
|
|
1815
|
+
this.color = [...from.color];
|
|
1816
|
+
} else if (Array.isArray(from)) {
|
|
1817
|
+
const [h = 0, s = 0, v = 0, a = 1] = from;
|
|
1818
|
+
this.color = [h, s, v, a];
|
|
1819
|
+
} else {
|
|
1820
|
+
this.color = parseColor(from).color;
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
getSet(index, value) {
|
|
1824
|
+
if (value === void 0) return this.color[index];
|
|
1825
|
+
const clone = [...this.color];
|
|
1826
|
+
clone[index] = value;
|
|
1827
|
+
return new Color(clone);
|
|
1828
|
+
}
|
|
1829
|
+
hue(value) {
|
|
1830
|
+
return this.getSet(0, value);
|
|
1831
|
+
}
|
|
1832
|
+
saturation(value) {
|
|
1833
|
+
return this.getSet(1, value);
|
|
1834
|
+
}
|
|
1835
|
+
value(value) {
|
|
1836
|
+
return this.getSet(2, value);
|
|
1837
|
+
}
|
|
1838
|
+
alpha(value) {
|
|
1839
|
+
return this.getSet(3, value);
|
|
1840
|
+
}
|
|
1841
|
+
string(format) {
|
|
1842
|
+
return convertColor(this.color, format);
|
|
1843
|
+
}
|
|
1844
|
+
toString() {
|
|
1845
|
+
return this.string("hex");
|
|
1846
|
+
}
|
|
1847
|
+
clone() {
|
|
1848
|
+
return new Color(this);
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
class Slider extends EventEmitter$1 {
|
|
1852
|
+
constructor($element) {
|
|
1853
|
+
super();
|
|
1854
|
+
__publicField(this, "x", 0);
|
|
1855
|
+
__publicField(this, "y", 0);
|
|
1856
|
+
__publicField(this, "$track");
|
|
1857
|
+
__publicField(this, "$thumb");
|
|
1858
|
+
this.$track = $element;
|
|
1859
|
+
this.$thumb = $element.querySelector(".cp_thumb");
|
|
1860
|
+
this.$track.addEventListener("pointerdown", (e) => {
|
|
1861
|
+
this.$track.setPointerCapture(e.pointerId);
|
|
1862
|
+
this.handleDrag(e);
|
|
1863
|
+
e.preventDefault();
|
|
1864
|
+
});
|
|
1865
|
+
this.$track.addEventListener("pointermove", (e) => {
|
|
1866
|
+
if (!this.$track.hasPointerCapture(e.pointerId)) return;
|
|
1867
|
+
this.handleDrag(e);
|
|
1868
|
+
e.preventDefault();
|
|
1869
|
+
});
|
|
1870
|
+
this.$track.addEventListener("pointerup", (e) => {
|
|
1871
|
+
this.$track.releasePointerCapture(e.pointerId);
|
|
1872
|
+
this.$thumb.focus();
|
|
1873
|
+
e.preventDefault();
|
|
1874
|
+
});
|
|
1875
|
+
this.$track.addEventListener("keydown", (e) => {
|
|
1876
|
+
if (e.key === "ArrowLeft") {
|
|
1877
|
+
this.handleNudge(-1, 0, e.shiftKey);
|
|
1878
|
+
e.preventDefault();
|
|
1879
|
+
} else if (e.key === "ArrowRight") {
|
|
1880
|
+
this.handleNudge(1, 0, e.shiftKey);
|
|
1881
|
+
e.preventDefault();
|
|
1882
|
+
} else if (e.key === "ArrowUp") {
|
|
1883
|
+
this.handleNudge(0, -1, e.shiftKey);
|
|
1884
|
+
e.preventDefault();
|
|
1885
|
+
} else if (e.key === "ArrowDown") {
|
|
1886
|
+
this.handleNudge(0, 1, e.shiftKey);
|
|
1887
|
+
e.preventDefault();
|
|
1888
|
+
}
|
|
1889
|
+
});
|
|
1890
|
+
}
|
|
1891
|
+
handleDrag(e) {
|
|
1892
|
+
const rect = this.$track.getBoundingClientRect();
|
|
1893
|
+
this.fireDrag((e.clientX - rect.x) / rect.width, (e.clientY - rect.y) / rect.height);
|
|
1894
|
+
}
|
|
1895
|
+
handleNudge(x, y, shift) {
|
|
1896
|
+
const mult = shift ? 0.1 : 0.01;
|
|
1897
|
+
this.fireDrag(this.x + x * mult, this.y + y * mult);
|
|
1898
|
+
}
|
|
1899
|
+
fireDrag(x, y) {
|
|
1900
|
+
if (x < 0) x = 0;
|
|
1901
|
+
else if (x > 1) x = 1;
|
|
1902
|
+
if (y < 0) y = 0;
|
|
1903
|
+
else if (y > 1) y = 1;
|
|
1904
|
+
this.emit("drag", x, y);
|
|
1905
|
+
}
|
|
1906
|
+
move(x, y) {
|
|
1907
|
+
if (x !== void 0) {
|
|
1908
|
+
this.x = x;
|
|
1909
|
+
this.$thumb.style.left = `${x * 100}%`;
|
|
1910
|
+
}
|
|
1911
|
+
if (y !== void 0) {
|
|
1912
|
+
this.y = y;
|
|
1913
|
+
this.$thumb.style.top = `${y * 100}%`;
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
const defaultConfig = {
|
|
1918
|
+
headless: false,
|
|
1919
|
+
toggleStyle: "button",
|
|
1920
|
+
container: null,
|
|
1921
|
+
color: null,
|
|
1922
|
+
swatches: null,
|
|
1923
|
+
swatchesOnly: false,
|
|
1924
|
+
enableAlpha: true,
|
|
1925
|
+
enableEyedropper: true,
|
|
1926
|
+
formats: ["hex", "rgb", "hsv", "hsl"],
|
|
1927
|
+
defaultFormat: "hex",
|
|
1928
|
+
submitMode: "confirm",
|
|
1929
|
+
showClearButton: false,
|
|
1930
|
+
dismissOnOutsideClick: true,
|
|
1931
|
+
dismissOnEscape: true,
|
|
1932
|
+
dialogPlacement: "top",
|
|
1933
|
+
dialogOffset: 8,
|
|
1934
|
+
staticPlacement: "center",
|
|
1935
|
+
staticOffset: 8
|
|
1936
|
+
};
|
|
1937
|
+
const getElement = (from) => {
|
|
1938
|
+
if (!from) return null;
|
|
1939
|
+
if (from instanceof HTMLElement) return from;
|
|
1940
|
+
return document.querySelector(from);
|
|
1941
|
+
};
|
|
1942
|
+
const alignElement = (element, placement, offset2) => {
|
|
1943
|
+
const [y, x = "center"] = placement.split(" ");
|
|
1944
|
+
const distance = `${offset2}px`;
|
|
1945
|
+
const alignY = y === "bottom" ? "bottom" : "top";
|
|
1946
|
+
const centerY = y === "center";
|
|
1947
|
+
element.style[alignY] = centerY ? "50%" : distance;
|
|
1948
|
+
const alignX = x === "right" ? "right" : "left";
|
|
1949
|
+
const centerX = x === "center";
|
|
1950
|
+
element.style[alignX] = centerX ? "50%" : distance;
|
|
1951
|
+
element.style.position = "fixed";
|
|
1952
|
+
element.style.transform = `translate(${centerX ? "-50%" : "0%"}, ${centerY ? "-50%" : "0%"})`;
|
|
1953
|
+
};
|
|
1954
|
+
const dialogContent = '<div class="cp_dialog"><div class="cp_area cp_area-hsv"><div class="cp_thumb" tabindex="0"></div></div><div class="cp_dialog-inner"><div class="cp_slider-hue cp_slider"><div class="cp_thumb" tabindex="0"></div></div><div class="cp_slider cp_slider-alpha"><div class="cp_thumb" tabindex="0"></div></div><div class="cp_swatches"></div><div class="cp_formats"></div><div class="cp_input-group"><div class="cp_sample"></div><input class="cp_value" value="#ff0000" autocomplete="false" spellcheck="false" /><button type="button" class="cp_action cp_eyedrop"><svg class="cp_icon" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 256 256"><g fill="currentColor"><path d="m207.8 87.6l-25.37 25.53l4.89 4.88a16 16 0 0 1 0 22.64l-9 9a8 8 0 0 1-11.32 0l-60.68-60.7a8 8 0 0 1 0-11.32l9-9a16 16 0 0 1 22.63 0l4.88 4.89l25-25.11c10.79-10.79 28.37-11.45 39.45-1a28 28 0 0 1 .52 40.19" opacity="0.2"/><path d="M224 67.3a35.8 35.8 0 0 0-11.26-25.66c-14-13.28-36.72-12.78-50.62 1.13L142.8 62.2a24 24 0 0 0-33.14.77l-9 9a16 16 0 0 0 0 22.64l2 2.06l-51 51a39.75 39.75 0 0 0-10.53 38l-8 18.41A13.68 13.68 0 0 0 36 219.3a15.92 15.92 0 0 0 17.71 3.35L71.23 215a39.89 39.89 0 0 0 37.06-10.75l51-51l2.06 2.06a16 16 0 0 0 22.62 0l9-9a24 24 0 0 0 .74-33.18l19.75-19.87A35.75 35.75 0 0 0 224 67.3M97 193a24 24 0 0 1-24 6a8 8 0 0 0-5.55.31l-18.1 7.91L57 189.41a8 8 0 0 0 .25-5.75A23.88 23.88 0 0 1 63 159l51-51l33.94 34ZM202.13 82l-25.37 25.52a8 8 0 0 0 0 11.3l4.89 4.89a8 8 0 0 1 0 11.32l-9 9L112 83.26l9-9a8 8 0 0 1 11.31 0l4.89 4.89a8 8 0 0 0 5.65 2.34a8 8 0 0 0 5.66-2.36l24.94-25.09c7.81-7.82 20.5-8.18 28.29-.81a20 20 0 0 1 .39 28.7Z"/></g></svg></button><button type="button" class="cp_action cp_clear"><svg class="cp_icon" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 256 256"><g fill="currentColor"><path d="M224 56v144a8 8 0 0 1-8 8H68.53a8 8 0 0 1-6.86-3.88L16 128l45.67-76.12A8 8 0 0 1 68.53 48H216a8 8 0 0 1 8 8" opacity="0.2"/><path d="M216 40H68.53a16.08 16.08 0 0 0-13.72 7.77L9.14 123.88a8 8 0 0 0 0 8.24l45.67 76.11A16.08 16.08 0 0 0 68.53 216H216a16 16 0 0 0 16-16V56a16 16 0 0 0-16-16M61.67 204.12l6.86-4.12ZM216 200H68.53l-43.2-72l43.2-72H216Zm-109.66-53.66L124.69 128l-18.35-18.34a8 8 0 0 1 11.32-11.32L136 116.69l18.34-18.35a8 8 0 0 1 11.32 11.32L147.31 128l18.35 18.34a8 8 0 0 1-11.32 11.32L136 139.31l-18.34 18.35a8 8 0 0 1-11.32-11.32"/></g></svg></button><button type="button" class="cp_action cp_submit"><svg class="cp_icon" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 256 256"><g fill="currentColor"><path d="m237.66 85.26l-128.4 128.4a8 8 0 0 1-11.32 0l-71.6-72a8 8 0 0 1 0-11.31l24-24a8 8 0 0 1 11.32 0L104 147.43l98.34-97.09a8 8 0 0 1 11.32 0l24 23.6a8 8 0 0 1 0 11.32" opacity="0.2"/><path d="m243.28 68.24l-24-23.56a16 16 0 0 0-22.59 0L104 136.23l-36.69-35.6a16 16 0 0 0-22.58.05l-24 24a16 16 0 0 0 0 22.61l71.62 72a16 16 0 0 0 22.63 0L243.33 90.91a16 16 0 0 0-.05-22.67M103.62 208L32 136l24-24a.6.6 0 0 1 .08.08l42.35 41.09a8 8 0 0 0 11.19 0L208.06 56L232 79.6Z"/></g></svg></button></div></div></div>';
|
|
1955
|
+
const caretContent = '<div class="cp_caret"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 256 256"><path fill="currentColor" d="M208.49 120.49a12 12 0 0 1-17 0L140 69v147a12 12 0 0 1-24 0V69l-51.51 51.49a12 12 0 0 1-17-17l72-72a12 12 0 0 1 17 0l72 72a12 12 0 0 1 0 17"/></svg></div>';
|
|
1956
|
+
let currentlyOpen;
|
|
1957
|
+
class ColorPicker extends eventsExports.EventEmitter {
|
|
1958
|
+
/**
|
|
1959
|
+
* Create a new ColorPicker instance.
|
|
1960
|
+
* @param $from The element or query to bind to. (leave null to create one)
|
|
1961
|
+
* @param config The picker configuration.
|
|
1962
|
+
*/
|
|
1963
|
+
constructor($from, config = {}) {
|
|
1964
|
+
super();
|
|
1965
|
+
__publicField(this, "_open", false);
|
|
1966
|
+
__publicField(this, "_unset", true);
|
|
1967
|
+
__publicField(this, "_firingChange", false);
|
|
1968
|
+
__publicField(this, "_format");
|
|
1969
|
+
__publicField(this, "_color");
|
|
1970
|
+
__publicField(this, "_newColor");
|
|
1971
|
+
__publicField(this, "_swatches");
|
|
1972
|
+
__publicField(this, "config");
|
|
1973
|
+
__publicField(this, "popper");
|
|
1974
|
+
__publicField(this, "isInput");
|
|
1975
|
+
__publicField(this, "$toggle");
|
|
1976
|
+
__publicField(this, "$dialog");
|
|
1977
|
+
__publicField(this, "$button");
|
|
1978
|
+
__publicField(this, "$input");
|
|
1979
|
+
__publicField(this, "changeHandler");
|
|
1980
|
+
__publicField(this, "clickHandler");
|
|
1981
|
+
__publicField(this, "hsvSlider");
|
|
1982
|
+
__publicField(this, "hueSlider");
|
|
1983
|
+
__publicField(this, "alphaSlider");
|
|
1984
|
+
__publicField(this, "$formats");
|
|
1985
|
+
__publicField(this, "$colorInput");
|
|
1986
|
+
this.config = { ...defaultConfig, ...config };
|
|
1987
|
+
$from = getElement($from) ?? document.createElement("button");
|
|
1988
|
+
this.$toggle = $from;
|
|
1989
|
+
const color = this.config.color || $from.value || $from.dataset.color || void 0;
|
|
1990
|
+
if (!this.config.headless) this.createToggle($from);
|
|
1991
|
+
this._setCurrentColor(new Color(color), false);
|
|
1992
|
+
if (!color) this.clear(false);
|
|
1993
|
+
this.setSwatches(this.config.swatches);
|
|
1994
|
+
if (this.config.dismissOnOutsideClick) {
|
|
1995
|
+
window.addEventListener("pointerdown", (event) => {
|
|
1996
|
+
if (!this._open) return;
|
|
1997
|
+
const $toggle = event.target;
|
|
1998
|
+
if (!$toggle.closest(".cp_dialog") && !$toggle.closest(".color-picker")) this.close();
|
|
1999
|
+
});
|
|
2000
|
+
}
|
|
2001
|
+
if (this.config.dismissOnEscape) {
|
|
2002
|
+
window.addEventListener("keydown", (event) => {
|
|
2003
|
+
if (event.key === "Escape") {
|
|
2004
|
+
const $focus = document.querySelector(":focus");
|
|
2005
|
+
if (!$focus || $focus.closest(".cp_dialog")) this.close();
|
|
2006
|
+
return;
|
|
2007
|
+
}
|
|
2008
|
+
});
|
|
2009
|
+
}
|
|
2010
|
+
this.close();
|
|
2011
|
+
}
|
|
2012
|
+
/**
|
|
2013
|
+
* Get whether the dialog is currently open.
|
|
2014
|
+
*/
|
|
2015
|
+
get isOpen() {
|
|
2016
|
+
return this._open;
|
|
2017
|
+
}
|
|
2018
|
+
/**
|
|
2019
|
+
* Get the picked color.
|
|
2020
|
+
*/
|
|
2021
|
+
get color() {
|
|
2022
|
+
return this._unset ? null : this._color;
|
|
2023
|
+
}
|
|
2024
|
+
/**
|
|
2025
|
+
* Get the array of swatches.
|
|
2026
|
+
*/
|
|
2027
|
+
get swatches() {
|
|
2028
|
+
return this._swatches;
|
|
2029
|
+
}
|
|
2030
|
+
/**
|
|
2031
|
+
* Get the color currently selected in the dialog.
|
|
2032
|
+
*/
|
|
2033
|
+
get selectedColor() {
|
|
2034
|
+
return this._newColor;
|
|
2035
|
+
}
|
|
2036
|
+
/**
|
|
2037
|
+
* Get the color output format.
|
|
2038
|
+
*/
|
|
2039
|
+
get format() {
|
|
2040
|
+
return this._format;
|
|
2041
|
+
}
|
|
2042
|
+
/**
|
|
2043
|
+
* Get the target element.
|
|
2044
|
+
*/
|
|
2045
|
+
get element() {
|
|
2046
|
+
return this.$toggle;
|
|
2047
|
+
}
|
|
2048
|
+
createToggle($from) {
|
|
2049
|
+
const isInput = $from instanceof HTMLInputElement;
|
|
2050
|
+
this.isInput = isInput;
|
|
2051
|
+
this.$toggle = isInput ? document.createElement("button") : $from;
|
|
2052
|
+
this.$input = isInput ? $from : document.createElement("input");
|
|
2053
|
+
if (this.isInput && "color" == $from.type) {
|
|
2054
|
+
$from.type = "text";
|
|
2055
|
+
}
|
|
2056
|
+
$from.replaceWith(this.$toggle);
|
|
2057
|
+
this.$input.tabIndex = -1;
|
|
2058
|
+
this.$input.readOnly = true;
|
|
2059
|
+
this.$input.classList.add("cp_input");
|
|
2060
|
+
if (this.config.toggleStyle === "input") {
|
|
2061
|
+
this.$toggle.classList.add("cp_wide");
|
|
2062
|
+
}
|
|
2063
|
+
this.$button = document.createElement("div");
|
|
2064
|
+
this.$button.classList.add("cp_button");
|
|
2065
|
+
this.$button.innerHTML = caretContent;
|
|
2066
|
+
this.$toggle.classList.add("color-picker");
|
|
2067
|
+
this.$toggle.setAttribute("type", "button");
|
|
2068
|
+
this.$toggle.append(this.$input, this.$button);
|
|
2069
|
+
this.changeHandler = () => {
|
|
2070
|
+
if (!this._firingChange) {
|
|
2071
|
+
this.setColor(this.isInput ? this.$input.value : this.$toggle.getAttribute("data-color"), false);
|
|
2072
|
+
}
|
|
2073
|
+
};
|
|
2074
|
+
this.clickHandler = () => this.toggle();
|
|
2075
|
+
this.$toggle.addEventListener("click", this.clickHandler);
|
|
2076
|
+
const $el = isInput ? this.$input : this.$toggle;
|
|
2077
|
+
$el.addEventListener("change", this.changeHandler);
|
|
2078
|
+
}
|
|
2079
|
+
/**
|
|
2080
|
+
* Append the picker to a given element.
|
|
2081
|
+
* @param target The element to attach the picker to.
|
|
2082
|
+
*/
|
|
2083
|
+
appendTo(target) {
|
|
2084
|
+
target.append(this.element);
|
|
2085
|
+
}
|
|
2086
|
+
setSwatches(swatches) {
|
|
2087
|
+
this._swatches = swatches || [];
|
|
2088
|
+
this.updateSwatches();
|
|
2089
|
+
}
|
|
2090
|
+
/**
|
|
2091
|
+
* Toggle whether the picker dialog is opened.
|
|
2092
|
+
* @param value Force open or closed?
|
|
2093
|
+
* @param emit Emit event?
|
|
2094
|
+
*/
|
|
2095
|
+
toggle(value = !this._open, emit2 = true) {
|
|
2096
|
+
if (value) {
|
|
2097
|
+
this.open(emit2);
|
|
2098
|
+
} else {
|
|
2099
|
+
this.close(emit2);
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
/**
|
|
2103
|
+
* Open the picker dialog.
|
|
2104
|
+
* @param emit Emit event?
|
|
2105
|
+
*/
|
|
2106
|
+
open(emit2 = true) {
|
|
2107
|
+
var _a;
|
|
2108
|
+
if (this._open) return;
|
|
2109
|
+
this._open = true;
|
|
2110
|
+
currentlyOpen == null ? void 0 : currentlyOpen.close();
|
|
2111
|
+
currentlyOpen = this;
|
|
2112
|
+
const container = getElement(this.config.container) ?? document.body;
|
|
2113
|
+
container.insertAdjacentHTML("beforeend", dialogContent);
|
|
2114
|
+
this.$dialog = container.lastElementChild;
|
|
2115
|
+
this.$colorInput = this.$dialog.querySelector(".cp_value");
|
|
2116
|
+
this.populateDialog();
|
|
2117
|
+
this.updateSwatches();
|
|
2118
|
+
this.bindDialog();
|
|
2119
|
+
this.setFormat(this.config.defaultFormat, false);
|
|
2120
|
+
this.updateColor();
|
|
2121
|
+
const toggleExists = document.documentElement.contains(this.$toggle);
|
|
2122
|
+
if (toggleExists) {
|
|
2123
|
+
this.popper = createPopper(this.$toggle, this.$dialog, {
|
|
2124
|
+
placement: this.config.dialogPlacement,
|
|
2125
|
+
strategy: "absolute",
|
|
2126
|
+
modifiers: [
|
|
2127
|
+
{
|
|
2128
|
+
name: "offset",
|
|
2129
|
+
options: {
|
|
2130
|
+
offset: [0, this.config.dialogOffset]
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
]
|
|
2134
|
+
});
|
|
2135
|
+
} else {
|
|
2136
|
+
this.popper = void 0;
|
|
2137
|
+
alignElement(this.$dialog, this.config.staticPlacement, this.config.staticOffset);
|
|
2138
|
+
}
|
|
2139
|
+
this.$colorInput.focus({ preventScroll: true });
|
|
2140
|
+
(_a = this.$button) == null ? void 0 : _a.classList.add("cp_open");
|
|
2141
|
+
setTimeout(() => this.$dialog.classList.add("cp_open"));
|
|
2142
|
+
if (emit2) {
|
|
2143
|
+
this.emit("open");
|
|
2144
|
+
setTimeout(() => this.emit("opened"), this.getAnimationDuration());
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
/**
|
|
2148
|
+
* Open the picker, returning a promise with the chosen color, optionally destroying it after.
|
|
2149
|
+
*/
|
|
2150
|
+
prompt(destroy = false) {
|
|
2151
|
+
return new Promise((resolve) => {
|
|
2152
|
+
this.once("close", () => resolve(this.color));
|
|
2153
|
+
if (destroy) {
|
|
2154
|
+
this.once("closed", () => this.destroy());
|
|
2155
|
+
}
|
|
2156
|
+
this.open();
|
|
2157
|
+
});
|
|
2158
|
+
}
|
|
2159
|
+
populateDialog() {
|
|
2160
|
+
if (this.config.formats) {
|
|
2161
|
+
this.$formats = this.config.formats.map((format) => {
|
|
2162
|
+
const $format = document.createElement("button");
|
|
2163
|
+
$format.className = "cp_format";
|
|
2164
|
+
$format.dataset.format = format;
|
|
2165
|
+
$format.textContent = format.toUpperCase();
|
|
2166
|
+
$format.addEventListener("click", () => this.setFormat(format));
|
|
2167
|
+
return $format;
|
|
2168
|
+
});
|
|
2169
|
+
this.$dialog.querySelector(".cp_formats").append(...this.$formats);
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
bindDialog() {
|
|
2173
|
+
const $hsvTrack = this.$dialog.querySelector(".cp_area-hsv");
|
|
2174
|
+
this.hsvSlider = new Slider($hsvTrack);
|
|
2175
|
+
this.hsvSlider.on("drag", (x, y) => {
|
|
2176
|
+
this._setNewColor(this._newColor.saturation(x).value(1 - y));
|
|
2177
|
+
});
|
|
2178
|
+
const $hueTrack = this.$dialog.querySelector(".cp_slider-hue");
|
|
2179
|
+
this.hueSlider = new Slider($hueTrack);
|
|
2180
|
+
this.hueSlider.on("drag", (x) => {
|
|
2181
|
+
this._setNewColor(this._newColor.hue(x * 360));
|
|
2182
|
+
});
|
|
2183
|
+
const $alphaTrack = this.$dialog.querySelector(".cp_slider-alpha");
|
|
2184
|
+
if (this.config.enableAlpha) {
|
|
2185
|
+
this.alphaSlider = new Slider($alphaTrack);
|
|
2186
|
+
this.alphaSlider.on("drag", (x) => {
|
|
2187
|
+
this._setNewColor(this._newColor.alpha(x), true);
|
|
2188
|
+
});
|
|
2189
|
+
} else {
|
|
2190
|
+
$alphaTrack.remove();
|
|
2191
|
+
}
|
|
2192
|
+
const $eyedrop = this.$dialog.querySelector(".cp_eyedrop");
|
|
2193
|
+
if (this.config.enableEyedropper && "EyeDropper" in window) {
|
|
2194
|
+
$eyedrop.addEventListener("click", () => {
|
|
2195
|
+
new EyeDropper().open().then((result) => {
|
|
2196
|
+
const color = new Color(result.sRGBHex);
|
|
2197
|
+
this._setNewColor(color);
|
|
2198
|
+
}).catch(() => {
|
|
2199
|
+
});
|
|
2200
|
+
});
|
|
2201
|
+
} else {
|
|
2202
|
+
$eyedrop.remove();
|
|
2203
|
+
}
|
|
2204
|
+
const $submit = this.$dialog.querySelector(".cp_submit");
|
|
2205
|
+
if ("confirm" === this.config.submitMode) {
|
|
2206
|
+
$submit.addEventListener("click", () => this.submit());
|
|
2207
|
+
} else {
|
|
2208
|
+
$submit.remove();
|
|
2209
|
+
}
|
|
2210
|
+
const $clear = this.$dialog.querySelector(".cp_clear");
|
|
2211
|
+
if (this.config.showClearButton) {
|
|
2212
|
+
$clear.addEventListener("click", () => {
|
|
2213
|
+
this.clear();
|
|
2214
|
+
this.close();
|
|
2215
|
+
});
|
|
2216
|
+
} else {
|
|
2217
|
+
$clear.remove();
|
|
2218
|
+
}
|
|
2219
|
+
this.$colorInput.addEventListener("input", () => {
|
|
2220
|
+
try {
|
|
2221
|
+
const { color, format } = parseColor(this.$colorInput.value);
|
|
2222
|
+
this.setFormat(format, false);
|
|
2223
|
+
this._setNewColor(new Color(color), false);
|
|
2224
|
+
} catch (error) {
|
|
2225
|
+
}
|
|
2226
|
+
});
|
|
2227
|
+
this.$colorInput.addEventListener("keydown", (event) => {
|
|
2228
|
+
if (event.key === "Enter") this.submit();
|
|
2229
|
+
});
|
|
2230
|
+
if (this.config.swatchesOnly) {
|
|
2231
|
+
const $iptGroup = this.$dialog.querySelector(".cp_input-group");
|
|
2232
|
+
$iptGroup && $iptGroup.remove();
|
|
2233
|
+
const $formats = this.$dialog.querySelector(".cp_formats");
|
|
2234
|
+
$formats && $formats.remove();
|
|
2235
|
+
$hueTrack && $hueTrack.remove();
|
|
2236
|
+
$hsvTrack && $hsvTrack.remove();
|
|
2237
|
+
$alphaTrack && $alphaTrack.remove();
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
getAnimationDuration() {
|
|
2241
|
+
const computed = window.getComputedStyle(this.$toggle);
|
|
2242
|
+
const raw = computed.getPropertyValue("--cp-delay");
|
|
2243
|
+
return parseFloat(raw) * (raw.endsWith("ms") ? 1 : 1e3);
|
|
2244
|
+
}
|
|
2245
|
+
/**
|
|
2246
|
+
* Close the picker dialog.
|
|
2247
|
+
* @param emit Emit event?
|
|
2248
|
+
*/
|
|
2249
|
+
close(emit2 = true) {
|
|
2250
|
+
var _a;
|
|
2251
|
+
if (!this._open) return;
|
|
2252
|
+
this._open = false;
|
|
2253
|
+
currentlyOpen = void 0;
|
|
2254
|
+
(_a = this.$button) == null ? void 0 : _a.classList.remove("cp_open");
|
|
2255
|
+
const $dialog = this.$dialog;
|
|
2256
|
+
const popper2 = this.popper;
|
|
2257
|
+
this.$dialog = void 0;
|
|
2258
|
+
this.popper = void 0;
|
|
2259
|
+
$dialog == null ? void 0 : $dialog.classList.remove("cp_open");
|
|
2260
|
+
setTimeout(() => {
|
|
2261
|
+
$dialog == null ? void 0 : $dialog.remove();
|
|
2262
|
+
popper2 == null ? void 0 : popper2.destroy();
|
|
2263
|
+
if (emit2) this.emit("closed");
|
|
2264
|
+
}, this.getAnimationDuration());
|
|
2265
|
+
if (emit2) this.emit("close");
|
|
2266
|
+
}
|
|
2267
|
+
/**
|
|
2268
|
+
* Submit the current color and close.
|
|
2269
|
+
* @param color The picked color value.
|
|
2270
|
+
* @param emit Emit event?
|
|
2271
|
+
*/
|
|
2272
|
+
submit(color = this._newColor, emit2 = true) {
|
|
2273
|
+
this._setCurrentColor(color, emit2, true);
|
|
2274
|
+
this.close(emit2);
|
|
2275
|
+
}
|
|
2276
|
+
/**
|
|
2277
|
+
* Destroy the picker and revert all HTML to what it was.
|
|
2278
|
+
*/
|
|
2279
|
+
destroy() {
|
|
2280
|
+
var _a;
|
|
2281
|
+
this.close();
|
|
2282
|
+
(_a = this.$dialog) == null ? void 0 : _a.remove();
|
|
2283
|
+
if (this.isInput) {
|
|
2284
|
+
if (!this.$input) return;
|
|
2285
|
+
this.$toggle.removeChild(this.$input);
|
|
2286
|
+
this.$toggle.replaceWith(this.$input);
|
|
2287
|
+
this.$input.classList.remove("cp_input");
|
|
2288
|
+
this.$input.removeAttribute("tabindex");
|
|
2289
|
+
this.$input.removeAttribute("readonly");
|
|
2290
|
+
if (this.changeHandler) this.$input.removeEventListener("change", this.changeHandler);
|
|
2291
|
+
} else {
|
|
2292
|
+
if (!this.$toggle) return;
|
|
2293
|
+
this.$toggle.classList.remove("color-picker", "cp_open");
|
|
2294
|
+
this.$toggle.removeAttribute("data-color");
|
|
2295
|
+
this.$toggle.removeAttribute("type");
|
|
2296
|
+
this.$toggle.textContent = "";
|
|
2297
|
+
if (this.clickHandler) this.$toggle.removeEventListener("click", this.clickHandler);
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
/**
|
|
2301
|
+
* Clear the picker color value.
|
|
2302
|
+
* @param emit Emit event?
|
|
2303
|
+
*/
|
|
2304
|
+
clear(emit2 = true) {
|
|
2305
|
+
this._unset = true;
|
|
2306
|
+
this.updateAppliedColor(emit2);
|
|
2307
|
+
}
|
|
2308
|
+
/**
|
|
2309
|
+
* Set the picker color value.
|
|
2310
|
+
* @param color The new color value.
|
|
2311
|
+
* @param emit Emit event?
|
|
2312
|
+
*/
|
|
2313
|
+
setColor(color, emit2 = true) {
|
|
2314
|
+
if (!color) return this.clear(emit2);
|
|
2315
|
+
this._setCurrentColor(new Color(color), emit2);
|
|
2316
|
+
}
|
|
2317
|
+
/**
|
|
2318
|
+
* Set the picker color format.
|
|
2319
|
+
* @param format The color format.
|
|
2320
|
+
* @param update Update colors?
|
|
2321
|
+
*/
|
|
2322
|
+
setFormat(format, update = true) {
|
|
2323
|
+
this._format = format;
|
|
2324
|
+
this.updateFormat();
|
|
2325
|
+
if (update) {
|
|
2326
|
+
this.updateColor();
|
|
2327
|
+
this.updateAppliedColor(false);
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
_setNewColor(color, updateInput = true) {
|
|
2331
|
+
this._newColor = color;
|
|
2332
|
+
if (this.config.submitMode === "instant" || this.config.swatchesOnly) {
|
|
2333
|
+
this._unset = false;
|
|
2334
|
+
this._color = color;
|
|
2335
|
+
this.updateAppliedColor(true);
|
|
2336
|
+
}
|
|
2337
|
+
this.updateColor(updateInput);
|
|
2338
|
+
}
|
|
2339
|
+
_setCurrentColor(color, emit2 = true, updateInput = true) {
|
|
2340
|
+
this._unset = false;
|
|
2341
|
+
this._newColor = this._color = color;
|
|
2342
|
+
this.updateColor(updateInput);
|
|
2343
|
+
this.updateAppliedColor(emit2);
|
|
2344
|
+
}
|
|
2345
|
+
updateColor(updateInput = true) {
|
|
2346
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2347
|
+
const currentColor = ((_a = this.color) == null ? void 0 : _a.toString()) ?? "transparent";
|
|
2348
|
+
const newColorHex = this._newColor.string("hex");
|
|
2349
|
+
(_b = this.$dialog) == null ? void 0 : _b.style.setProperty("--cp-base-color", newColorHex.substring(0, 7));
|
|
2350
|
+
(_c = this.$button) == null ? void 0 : _c.style.setProperty("--cp-current-color", currentColor);
|
|
2351
|
+
(_d = this.$dialog) == null ? void 0 : _d.style.setProperty("--cp-current-color", currentColor);
|
|
2352
|
+
(_e = this.$dialog) == null ? void 0 : _e.style.setProperty("--cp-color", newColorHex);
|
|
2353
|
+
(_f = this.$dialog) == null ? void 0 : _f.style.setProperty("--cp-hue", this._newColor.hue().toString());
|
|
2354
|
+
(_g = this.$dialog) == null ? void 0 : _g.style.setProperty("--cp-alpha", this._newColor.alpha().toString());
|
|
2355
|
+
(_h = this.hsvSlider) == null ? void 0 : _h.move(this._newColor.saturation(), 1 - this._newColor.value());
|
|
2356
|
+
(_i = this.hueSlider) == null ? void 0 : _i.move(this._newColor.hue() / 360);
|
|
2357
|
+
(_j = this.alphaSlider) == null ? void 0 : _j.move(this._newColor.alpha());
|
|
2358
|
+
if (updateInput && this.$colorInput) {
|
|
2359
|
+
this.$colorInput.value = this._newColor.string(this._format);
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
updateAppliedColor(emit2 = true) {
|
|
2363
|
+
const color = this._unset ? "" : this._color.string(this.config.defaultFormat);
|
|
2364
|
+
if (this.$input) {
|
|
2365
|
+
this.$input.value = color;
|
|
2366
|
+
this.$input.dataset.color = color;
|
|
2367
|
+
}
|
|
2368
|
+
if (this.$toggle) this.$toggle.dataset.color = color;
|
|
2369
|
+
if (this.$button) this.$button.classList.toggle("cp_unset", this._unset);
|
|
2370
|
+
if (emit2) {
|
|
2371
|
+
this.emit("pick", this.color);
|
|
2372
|
+
if (this.$input) {
|
|
2373
|
+
this._firingChange = true;
|
|
2374
|
+
this.$input.dispatchEvent(new Event("change"));
|
|
2375
|
+
this._firingChange = false;
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
updateFormat() {
|
|
2380
|
+
if (!this.$formats) return;
|
|
2381
|
+
this.$formats.forEach(($fmt) => $fmt.removeAttribute("aria-checked"));
|
|
2382
|
+
const $checked = this.$formats.find(($fmt) => $fmt.dataset.format === this._format);
|
|
2383
|
+
if ($checked) {
|
|
2384
|
+
$checked.ariaChecked = "true";
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
updateSwatches() {
|
|
2388
|
+
if (!this.$dialog) return;
|
|
2389
|
+
const $swatches = this.$dialog.querySelector(".cp_swatches");
|
|
2390
|
+
$swatches.textContent = "";
|
|
2391
|
+
this._swatches.forEach((swatch) => {
|
|
2392
|
+
const $swatch = document.createElement("button");
|
|
2393
|
+
$swatch.className = "cp_swatch";
|
|
2394
|
+
$swatch.style.setProperty("--cp-color", swatch);
|
|
2395
|
+
$swatch.dataset.color = swatch;
|
|
2396
|
+
const color = new Color($swatch.dataset.color);
|
|
2397
|
+
$swatch.addEventListener("click", () => {
|
|
2398
|
+
this._setNewColor(color);
|
|
2399
|
+
if (this.config.swatchesOnly) {
|
|
2400
|
+
this.close();
|
|
2401
|
+
}
|
|
2402
|
+
});
|
|
2403
|
+
$swatches.append($swatch);
|
|
2404
|
+
});
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
__publicField(ColorPicker, "Color", Color);
|
|
2408
|
+
export {
|
|
2409
|
+
ColorPicker as default
|
|
2410
|
+
};
|