@windwalker-io/unicorn-next 0.1.12 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/field-modal-select.js +87 -23
- package/dist/chunks/field-modal-select.js.map +1 -1
- package/dist/chunks/form.js +8 -2
- package/dist/chunks/form.js.map +1 -1
- package/dist/chunks/keep-tab.js +3 -0
- package/dist/chunks/keep-tab.js.map +1 -1
- package/dist/chunks/s3-multipart-uploader.js +29 -10
- package/dist/chunks/s3-multipart-uploader.js.map +1 -1
- package/dist/chunks/s3-uploader.js +1 -0
- package/dist/chunks/s3-uploader.js.map +1 -1
- package/dist/chunks/tinymce.js +13 -3
- package/dist/chunks/tinymce.js.map +1 -1
- package/dist/chunks/unicorn.js +83 -38
- package/dist/chunks/unicorn.js.map +1 -1
- package/dist/chunks/validation.js +32 -15
- package/dist/chunks/validation.js.map +1 -1
- package/dist/index.d.ts +51 -24
- package/dist/unicorn.js +15 -14
- package/package.json +2 -2
- package/src/bootstrap/keep-tab.ts +4 -0
- package/src/composable/useForm.ts +36 -6
- package/src/module/field-modal-select.ts +121 -30
- package/src/module/form.ts +9 -2
- package/src/module/s3-multipart-uploader.ts +46 -14
- package/src/module/s3-uploader.ts +2 -0
- package/src/module/tinymce.ts +20 -5
- package/src/module/validation.ts +42 -17
- package/src/service/dom.ts +32 -14
- package/src/service/loader.ts +37 -17
- package/src/service/ui.ts +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { v as selectOne, U as highlight, _ as __, ac as data, B as html, P as slideUp } from "./unicorn.js";
|
|
1
|
+
import { v as selectOne, U as highlight, G as simpleAlert, _ as __, ac as data, B as html, P as slideUp } from "./unicorn.js";
|
|
2
2
|
import { b as baseAssignValue, a as assignValue, i as isIndex, c as isPrototype, d as arrayLikeKeys, g as getPrototype, k as keys } from "./_getPrototype.js";
|
|
3
3
|
import { b as baseRest, a as apply } from "./_baseRest.js";
|
|
4
4
|
import { i as isObjectLike, b as baseGetTag, a as isArray, S as Symbol$1, c as isObject, d as isArrayLike, e as eq } from "./isArguments.js";
|
|
@@ -282,18 +282,35 @@ function template(string, options, guard) {
|
|
|
282
282
|
}
|
|
283
283
|
function createCallback(type, selector, modalSelector) {
|
|
284
284
|
switch (type) {
|
|
285
|
-
// case 'tag':
|
|
286
|
-
// return () => {
|
|
287
|
-
//
|
|
288
|
-
// };
|
|
289
285
|
case "list":
|
|
290
286
|
return (item) => {
|
|
291
287
|
const modalList = document.querySelector(selector);
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
288
|
+
const checked = item.checked;
|
|
289
|
+
if (checked === void 0) {
|
|
290
|
+
if (!modalList.querySelector(`[data-value="${item.value}"]`)) {
|
|
291
|
+
modalList.appendItem(item, true);
|
|
292
|
+
selectOne(modalSelector)?.close();
|
|
293
|
+
} else {
|
|
294
|
+
simpleAlert(__("unicorn.field.modal.already.selected"));
|
|
295
|
+
}
|
|
296
|
+
} else if (checked) {
|
|
297
|
+
try {
|
|
298
|
+
modalList.appendIfNotExists(item, true);
|
|
299
|
+
} catch (e) {
|
|
300
|
+
window.postMessage({
|
|
301
|
+
task: "remove-row",
|
|
302
|
+
value: item,
|
|
303
|
+
id: item.instanceId
|
|
304
|
+
});
|
|
305
|
+
simpleAlert(e.message);
|
|
306
|
+
} finally {
|
|
307
|
+
modalList.updateSelected();
|
|
308
|
+
}
|
|
309
|
+
} else if (!checked) {
|
|
310
|
+
modalList.removeItem(item).then(() => {
|
|
311
|
+
console.log(modalList.items);
|
|
312
|
+
modalList.updateSelected();
|
|
313
|
+
});
|
|
297
314
|
}
|
|
298
315
|
};
|
|
299
316
|
case "single":
|
|
@@ -318,15 +335,22 @@ class ModalListSelectElement extends HTMLElement {
|
|
|
318
335
|
static is = "uni-modal-list";
|
|
319
336
|
itemTemplate;
|
|
320
337
|
options;
|
|
338
|
+
isMultiCheck = false;
|
|
321
339
|
get listContainer() {
|
|
322
340
|
return this.querySelector("[data-role=list-container]");
|
|
323
341
|
}
|
|
342
|
+
get selectButton() {
|
|
343
|
+
return this.querySelector("[data-role=select]");
|
|
344
|
+
}
|
|
324
345
|
get modal() {
|
|
325
346
|
return document.querySelector(this.options.modalSelector);
|
|
326
347
|
}
|
|
327
348
|
get items() {
|
|
328
349
|
return Array.from(this.listContainer.querySelectorAll("[data-value]"));
|
|
329
350
|
}
|
|
351
|
+
get count() {
|
|
352
|
+
return this.items.length;
|
|
353
|
+
}
|
|
330
354
|
connectedCallback() {
|
|
331
355
|
this.options = JSON.parse(this.getAttribute("options") || "{}");
|
|
332
356
|
this.itemTemplate = template(document.querySelector(this.options.itemTemplate).innerHTML);
|
|
@@ -339,15 +363,19 @@ class ModalListSelectElement extends HTMLElement {
|
|
|
339
363
|
new Sortable(this.listContainer, { handle: ".h-drag-handle", animation: 150 });
|
|
340
364
|
});
|
|
341
365
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
366
|
+
this.selectButton.addEventListener("click", (e) => {
|
|
367
|
+
try {
|
|
368
|
+
this.open(e);
|
|
369
|
+
} catch (e2) {
|
|
370
|
+
simpleAlert(e2.message);
|
|
371
|
+
}
|
|
345
372
|
});
|
|
346
373
|
this.querySelector("[data-role=clear]")?.addEventListener("click", () => {
|
|
347
374
|
this.removeAll();
|
|
348
375
|
});
|
|
349
|
-
selectButton.style.pointerEvents = "";
|
|
376
|
+
this.selectButton.style.pointerEvents = "";
|
|
350
377
|
this.render();
|
|
378
|
+
this.enableMultiCheck(this.options.multiCheck || false);
|
|
351
379
|
}
|
|
352
380
|
render() {
|
|
353
381
|
const items = data("unicorn.modal-field")[this.options.dataKey] || [];
|
|
@@ -356,6 +384,10 @@ class ModalListSelectElement extends HTMLElement {
|
|
|
356
384
|
});
|
|
357
385
|
}
|
|
358
386
|
appendItem(item, highlights = false) {
|
|
387
|
+
const max = this.options.max;
|
|
388
|
+
if (max && this.count >= max) {
|
|
389
|
+
throw new Error(__("unicorn.field.modal.max.selected", max));
|
|
390
|
+
}
|
|
359
391
|
const itemHtml = html(this.itemTemplate({ item }));
|
|
360
392
|
itemHtml.dataset.value = String(item.value);
|
|
361
393
|
itemHtml.querySelector("[data-role=remove]")?.addEventListener("click", () => {
|
|
@@ -366,6 +398,9 @@ class ModalListSelectElement extends HTMLElement {
|
|
|
366
398
|
if (highlights) {
|
|
367
399
|
highlight(itemHtml);
|
|
368
400
|
}
|
|
401
|
+
if (this.isMultiCheck) {
|
|
402
|
+
this.updateSelected();
|
|
403
|
+
}
|
|
369
404
|
}
|
|
370
405
|
appendIfNotExists(item, highlights = false) {
|
|
371
406
|
if (!this.isExists(item)) {
|
|
@@ -387,15 +422,18 @@ class ModalListSelectElement extends HTMLElement {
|
|
|
387
422
|
getValues() {
|
|
388
423
|
return this.items.map((item) => item.dataset.value);
|
|
389
424
|
}
|
|
390
|
-
removeItem(item) {
|
|
425
|
+
async removeItem(item) {
|
|
391
426
|
if (typeof item === "object") {
|
|
392
427
|
item = item.value;
|
|
393
428
|
}
|
|
394
429
|
const element = this.listContainer.querySelector(`[data-value="${item}"]`);
|
|
395
430
|
if (element) {
|
|
396
|
-
slideUp(element).then(() => {
|
|
431
|
+
return slideUp(element).then(() => {
|
|
397
432
|
element.remove();
|
|
398
433
|
this.toggleRequired();
|
|
434
|
+
if (this.isMultiCheck) {
|
|
435
|
+
this.updateSelected();
|
|
436
|
+
}
|
|
399
437
|
});
|
|
400
438
|
}
|
|
401
439
|
}
|
|
@@ -406,6 +444,9 @@ class ModalListSelectElement extends HTMLElement {
|
|
|
406
444
|
}
|
|
407
445
|
await Promise.all(promises);
|
|
408
446
|
this.toggleRequired();
|
|
447
|
+
if (this.isMultiCheck) {
|
|
448
|
+
this.updateSelected();
|
|
449
|
+
}
|
|
409
450
|
}
|
|
410
451
|
toggleRequired() {
|
|
411
452
|
const placeholder = this.querySelector("[data-role=validation-placeholder]");
|
|
@@ -422,14 +463,29 @@ class ModalListSelectElement extends HTMLElement {
|
|
|
422
463
|
this.modal?.open(target.href, { size: "modal-xl" });
|
|
423
464
|
return;
|
|
424
465
|
}
|
|
425
|
-
if (this.
|
|
426
|
-
|
|
427
|
-
__("unicorn.field.modal.max.selected", max)
|
|
428
|
-
);
|
|
429
|
-
return;
|
|
466
|
+
if (this.count >= max) {
|
|
467
|
+
throw new Error(__("unicorn.field.modal.max.selected", max));
|
|
430
468
|
}
|
|
431
469
|
this.modal?.open(target.href, { size: "modal-xl" });
|
|
432
470
|
}
|
|
471
|
+
enableMultiCheck(enable = true) {
|
|
472
|
+
this.isMultiCheck = enable;
|
|
473
|
+
if (enable) {
|
|
474
|
+
this.updateSelected();
|
|
475
|
+
} else {
|
|
476
|
+
this.clearSelected();
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
updateSelected() {
|
|
480
|
+
const url = new URL(this.selectButton.href);
|
|
481
|
+
url.searchParams.set("selected", this.items.map((i) => i.dataset.value).join(","));
|
|
482
|
+
this.selectButton.href = url.toString();
|
|
483
|
+
}
|
|
484
|
+
clearSelected() {
|
|
485
|
+
const url = new URL(this.selectButton.href);
|
|
486
|
+
url.searchParams.delete("selected");
|
|
487
|
+
this.selectButton.href = url.toString();
|
|
488
|
+
}
|
|
433
489
|
}
|
|
434
490
|
async function init() {
|
|
435
491
|
customElements.define(ModalListSelectElement.is, ModalListSelectElement);
|
|
@@ -437,8 +493,16 @@ async function init() {
|
|
|
437
493
|
function listenMessages(options) {
|
|
438
494
|
const callback = createCallback(options.type, options.selector, options.modalSelector);
|
|
439
495
|
window.addEventListener("message", (e) => {
|
|
440
|
-
if (e.origin === options.origin
|
|
441
|
-
|
|
496
|
+
if (e.origin === options.origin) {
|
|
497
|
+
if (Array.isArray(e.data) && e.data[0] === options.instanceId) {
|
|
498
|
+
callback(e.data[1]);
|
|
499
|
+
}
|
|
500
|
+
if (typeof e.data === "object" && e.data !== null && e.data.id === options.instanceId && e.data.task === "select-row") {
|
|
501
|
+
const item = e.data.value;
|
|
502
|
+
item.checked = e.data.checked;
|
|
503
|
+
item.instanceId = e.data.id;
|
|
504
|
+
callback(e.data.value);
|
|
505
|
+
}
|
|
442
506
|
}
|
|
443
507
|
});
|
|
444
508
|
window[options.instanceId] = callback;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-modal-select.js","sources":["../../../../../../node_modules/lodash-es/isSymbol.js","../../../../../../node_modules/lodash-es/_arrayMap.js","../../../../../../node_modules/lodash-es/_baseToString.js","../../../../../../node_modules/lodash-es/_copyObject.js","../../../../../../node_modules/lodash-es/_isIterateeCall.js","../../../../../../node_modules/lodash-es/_createAssigner.js","../../../../../../node_modules/lodash-es/_nativeKeysIn.js","../../../../../../node_modules/lodash-es/_baseKeysIn.js","../../../../../../node_modules/lodash-es/keysIn.js","../../../../../../node_modules/lodash-es/assignInWith.js","../../../../../../node_modules/lodash-es/toString.js","../../../../../../node_modules/lodash-es/isPlainObject.js","../../../../../../node_modules/lodash-es/isError.js","../../../../../../node_modules/lodash-es/attempt.js","../../../../../../node_modules/lodash-es/_basePropertyOf.js","../../../../../../node_modules/lodash-es/_escapeHtmlChar.js","../../../../../../node_modules/lodash-es/escape.js","../../../../../../node_modules/lodash-es/_baseValues.js","../../../../../../node_modules/lodash-es/_customDefaultsAssignIn.js","../../../../../../node_modules/lodash-es/_escapeStringChar.js","../../../../../../node_modules/lodash-es/_reInterpolate.js","../../../../../../node_modules/lodash-es/_reEscape.js","../../../../../../node_modules/lodash-es/_reEvaluate.js","../../../../../../node_modules/lodash-es/templateSettings.js","../../../../../../node_modules/lodash-es/template.js","../../src/module/field-modal-select.ts"],"sourcesContent":["import baseGetTag from './_baseGetTag.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar symbolTag = '[object Symbol]';\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && baseGetTag(value) == symbolTag);\n}\n\nexport default isSymbol;\n","/**\n * A specialized version of `_.map` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the new mapped array.\n */\nfunction arrayMap(array, iteratee) {\n var index = -1,\n length = array == null ? 0 : array.length,\n result = Array(length);\n\n while (++index < length) {\n result[index] = iteratee(array[index], index, array);\n }\n return result;\n}\n\nexport default arrayMap;\n","import Symbol from './_Symbol.js';\nimport arrayMap from './_arrayMap.js';\nimport isArray from './isArray.js';\nimport isSymbol from './isSymbol.js';\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0;\n\n/** Used to convert symbols to primitives and strings. */\nvar symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolToString = symbolProto ? symbolProto.toString : undefined;\n\n/**\n * The base implementation of `_.toString` which doesn't convert nullish\n * values to empty strings.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {string} Returns the string.\n */\nfunction baseToString(value) {\n // Exit early for strings to avoid a performance hit in some environments.\n if (typeof value == 'string') {\n return value;\n }\n if (isArray(value)) {\n // Recursively convert values (susceptible to call stack limits).\n return arrayMap(value, baseToString) + '';\n }\n if (isSymbol(value)) {\n return symbolToString ? symbolToString.call(value) : '';\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n}\n\nexport default baseToString;\n","import assignValue from './_assignValue.js';\nimport baseAssignValue from './_baseAssignValue.js';\n\n/**\n * Copies properties of `source` to `object`.\n *\n * @private\n * @param {Object} source The object to copy properties from.\n * @param {Array} props The property identifiers to copy.\n * @param {Object} [object={}] The object to copy properties to.\n * @param {Function} [customizer] The function to customize copied values.\n * @returns {Object} Returns `object`.\n */\nfunction copyObject(source, props, object, customizer) {\n var isNew = !object;\n object || (object = {});\n\n var index = -1,\n length = props.length;\n\n while (++index < length) {\n var key = props[index];\n\n var newValue = customizer\n ? customizer(object[key], source[key], key, object, source)\n : undefined;\n\n if (newValue === undefined) {\n newValue = source[key];\n }\n if (isNew) {\n baseAssignValue(object, key, newValue);\n } else {\n assignValue(object, key, newValue);\n }\n }\n return object;\n}\n\nexport default copyObject;\n","import eq from './eq.js';\nimport isArrayLike from './isArrayLike.js';\nimport isIndex from './_isIndex.js';\nimport isObject from './isObject.js';\n\n/**\n * Checks if the given arguments are from an iteratee call.\n *\n * @private\n * @param {*} value The potential iteratee value argument.\n * @param {*} index The potential iteratee index or key argument.\n * @param {*} object The potential iteratee object argument.\n * @returns {boolean} Returns `true` if the arguments are from an iteratee call,\n * else `false`.\n */\nfunction isIterateeCall(value, index, object) {\n if (!isObject(object)) {\n return false;\n }\n var type = typeof index;\n if (type == 'number'\n ? (isArrayLike(object) && isIndex(index, object.length))\n : (type == 'string' && index in object)\n ) {\n return eq(object[index], value);\n }\n return false;\n}\n\nexport default isIterateeCall;\n","import baseRest from './_baseRest.js';\nimport isIterateeCall from './_isIterateeCall.js';\n\n/**\n * Creates a function like `_.assign`.\n *\n * @private\n * @param {Function} assigner The function to assign values.\n * @returns {Function} Returns the new assigner function.\n */\nfunction createAssigner(assigner) {\n return baseRest(function(object, sources) {\n var index = -1,\n length = sources.length,\n customizer = length > 1 ? sources[length - 1] : undefined,\n guard = length > 2 ? sources[2] : undefined;\n\n customizer = (assigner.length > 3 && typeof customizer == 'function')\n ? (length--, customizer)\n : undefined;\n\n if (guard && isIterateeCall(sources[0], sources[1], guard)) {\n customizer = length < 3 ? undefined : customizer;\n length = 1;\n }\n object = Object(object);\n while (++index < length) {\n var source = sources[index];\n if (source) {\n assigner(object, source, index, customizer);\n }\n }\n return object;\n });\n}\n\nexport default createAssigner;\n","/**\n * This function is like\n * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n * except that it includes inherited enumerable properties.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction nativeKeysIn(object) {\n var result = [];\n if (object != null) {\n for (var key in Object(object)) {\n result.push(key);\n }\n }\n return result;\n}\n\nexport default nativeKeysIn;\n","import isObject from './isObject.js';\nimport isPrototype from './_isPrototype.js';\nimport nativeKeysIn from './_nativeKeysIn.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction baseKeysIn(object) {\n if (!isObject(object)) {\n return nativeKeysIn(object);\n }\n var isProto = isPrototype(object),\n result = [];\n\n for (var key in object) {\n if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {\n result.push(key);\n }\n }\n return result;\n}\n\nexport default baseKeysIn;\n","import arrayLikeKeys from './_arrayLikeKeys.js';\nimport baseKeysIn from './_baseKeysIn.js';\nimport isArrayLike from './isArrayLike.js';\n\n/**\n * Creates an array of the own and inherited enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keysIn(new Foo);\n * // => ['a', 'b', 'c'] (iteration order is not guaranteed)\n */\nfunction keysIn(object) {\n return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);\n}\n\nexport default keysIn;\n","import copyObject from './_copyObject.js';\nimport createAssigner from './_createAssigner.js';\nimport keysIn from './keysIn.js';\n\n/**\n * This method is like `_.assignIn` except that it accepts `customizer`\n * which is invoked to produce the assigned values. If `customizer` returns\n * `undefined`, assignment is handled by the method instead. The `customizer`\n * is invoked with five arguments: (objValue, srcValue, key, object, source).\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @alias extendWith\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} sources The source objects.\n * @param {Function} [customizer] The function to customize assigned values.\n * @returns {Object} Returns `object`.\n * @see _.assignWith\n * @example\n *\n * function customizer(objValue, srcValue) {\n * return _.isUndefined(objValue) ? srcValue : objValue;\n * }\n *\n * var defaults = _.partialRight(_.assignInWith, customizer);\n *\n * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });\n * // => { 'a': 1, 'b': 2 }\n */\nvar assignInWith = createAssigner(function(object, source, srcIndex, customizer) {\n copyObject(source, keysIn(source), object, customizer);\n});\n\nexport default assignInWith;\n","import baseToString from './_baseToString.js';\n\n/**\n * Converts `value` to a string. An empty string is returned for `null`\n * and `undefined` values. The sign of `-0` is preserved.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n * @example\n *\n * _.toString(null);\n * // => ''\n *\n * _.toString(-0);\n * // => '-0'\n *\n * _.toString([1, 2, 3]);\n * // => '1,2,3'\n */\nfunction toString(value) {\n return value == null ? '' : baseToString(value);\n}\n\nexport default toString;\n","import baseGetTag from './_baseGetTag.js';\nimport getPrototype from './_getPrototype.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar objectTag = '[object Object]';\n\n/** Used for built-in method references. */\nvar funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Used to infer the `Object` constructor. */\nvar objectCtorString = funcToString.call(Object);\n\n/**\n * Checks if `value` is a plain object, that is, an object created by the\n * `Object` constructor or one with a `[[Prototype]]` of `null`.\n *\n * @static\n * @memberOf _\n * @since 0.8.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * }\n *\n * _.isPlainObject(new Foo);\n * // => false\n *\n * _.isPlainObject([1, 2, 3]);\n * // => false\n *\n * _.isPlainObject({ 'x': 0, 'y': 0 });\n * // => true\n *\n * _.isPlainObject(Object.create(null));\n * // => true\n */\nfunction isPlainObject(value) {\n if (!isObjectLike(value) || baseGetTag(value) != objectTag) {\n return false;\n }\n var proto = getPrototype(value);\n if (proto === null) {\n return true;\n }\n var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;\n return typeof Ctor == 'function' && Ctor instanceof Ctor &&\n funcToString.call(Ctor) == objectCtorString;\n}\n\nexport default isPlainObject;\n","import baseGetTag from './_baseGetTag.js';\nimport isObjectLike from './isObjectLike.js';\nimport isPlainObject from './isPlainObject.js';\n\n/** `Object#toString` result references. */\nvar domExcTag = '[object DOMException]',\n errorTag = '[object Error]';\n\n/**\n * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,\n * `SyntaxError`, `TypeError`, or `URIError` object.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an error object, else `false`.\n * @example\n *\n * _.isError(new Error);\n * // => true\n *\n * _.isError(Error);\n * // => false\n */\nfunction isError(value) {\n if (!isObjectLike(value)) {\n return false;\n }\n var tag = baseGetTag(value);\n return tag == errorTag || tag == domExcTag ||\n (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));\n}\n\nexport default isError;\n","import apply from './_apply.js';\nimport baseRest from './_baseRest.js';\nimport isError from './isError.js';\n\n/**\n * Attempts to invoke `func`, returning either the result or the caught error\n * object. Any additional arguments are provided to `func` when it's invoked.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Util\n * @param {Function} func The function to attempt.\n * @param {...*} [args] The arguments to invoke `func` with.\n * @returns {*} Returns the `func` result or error object.\n * @example\n *\n * // Avoid throwing errors for invalid selectors.\n * var elements = _.attempt(function(selector) {\n * return document.querySelectorAll(selector);\n * }, '>_>');\n *\n * if (_.isError(elements)) {\n * elements = [];\n * }\n */\nvar attempt = baseRest(function(func, args) {\n try {\n return apply(func, undefined, args);\n } catch (e) {\n return isError(e) ? e : new Error(e);\n }\n});\n\nexport default attempt;\n","/**\n * The base implementation of `_.propertyOf` without support for deep paths.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Function} Returns the new accessor function.\n */\nfunction basePropertyOf(object) {\n return function(key) {\n return object == null ? undefined : object[key];\n };\n}\n\nexport default basePropertyOf;\n","import basePropertyOf from './_basePropertyOf.js';\n\n/** Used to map characters to HTML entities. */\nvar htmlEscapes = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": '''\n};\n\n/**\n * Used by `_.escape` to convert characters to HTML entities.\n *\n * @private\n * @param {string} chr The matched character to escape.\n * @returns {string} Returns the escaped character.\n */\nvar escapeHtmlChar = basePropertyOf(htmlEscapes);\n\nexport default escapeHtmlChar;\n","import escapeHtmlChar from './_escapeHtmlChar.js';\nimport toString from './toString.js';\n\n/** Used to match HTML entities and HTML characters. */\nvar reUnescapedHtml = /[&<>\"']/g,\n reHasUnescapedHtml = RegExp(reUnescapedHtml.source);\n\n/**\n * Converts the characters \"&\", \"<\", \">\", '\"', and \"'\" in `string` to their\n * corresponding HTML entities.\n *\n * **Note:** No other characters are escaped. To escape additional\n * characters use a third-party library like [_he_](https://mths.be/he).\n *\n * Though the \">\" character is escaped for symmetry, characters like\n * \">\" and \"/\" don't need escaping in HTML and have no special meaning\n * unless they're part of a tag or unquoted attribute value. See\n * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)\n * (under \"semi-related fun fact\") for more details.\n *\n * When working with HTML you should always\n * [quote attribute values](http://wonko.com/post/html-escaping) to reduce\n * XSS vectors.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to escape.\n * @returns {string} Returns the escaped string.\n * @example\n *\n * _.escape('fred, barney, & pebbles');\n * // => 'fred, barney, & pebbles'\n */\nfunction escape(string) {\n string = toString(string);\n return (string && reHasUnescapedHtml.test(string))\n ? string.replace(reUnescapedHtml, escapeHtmlChar)\n : string;\n}\n\nexport default escape;\n","import arrayMap from './_arrayMap.js';\n\n/**\n * The base implementation of `_.values` and `_.valuesIn` which creates an\n * array of `object` property values corresponding to the property names\n * of `props`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array} props The property names to get values for.\n * @returns {Object} Returns the array of property values.\n */\nfunction baseValues(object, props) {\n return arrayMap(props, function(key) {\n return object[key];\n });\n}\n\nexport default baseValues;\n","import eq from './eq.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used by `_.defaults` to customize its `_.assignIn` use to assign properties\n * of source objects to the destination object for all destination properties\n * that resolve to `undefined`.\n *\n * @private\n * @param {*} objValue The destination value.\n * @param {*} srcValue The source value.\n * @param {string} key The key of the property to assign.\n * @param {Object} object The parent object of `objValue`.\n * @returns {*} Returns the value to assign.\n */\nfunction customDefaultsAssignIn(objValue, srcValue, key, object) {\n if (objValue === undefined ||\n (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {\n return srcValue;\n }\n return objValue;\n}\n\nexport default customDefaultsAssignIn;\n","/** Used to escape characters for inclusion in compiled string literals. */\nvar stringEscapes = {\n '\\\\': '\\\\',\n \"'\": \"'\",\n '\\n': 'n',\n '\\r': 'r',\n '\\u2028': 'u2028',\n '\\u2029': 'u2029'\n};\n\n/**\n * Used by `_.template` to escape characters for inclusion in compiled string literals.\n *\n * @private\n * @param {string} chr The matched character to escape.\n * @returns {string} Returns the escaped character.\n */\nfunction escapeStringChar(chr) {\n return '\\\\' + stringEscapes[chr];\n}\n\nexport default escapeStringChar;\n","/** Used to match template delimiters. */\nvar reInterpolate = /<%=([\\s\\S]+?)%>/g;\n\nexport default reInterpolate;\n","/** Used to match template delimiters. */\nvar reEscape = /<%-([\\s\\S]+?)%>/g;\n\nexport default reEscape;\n","/** Used to match template delimiters. */\nvar reEvaluate = /<%([\\s\\S]+?)%>/g;\n\nexport default reEvaluate;\n","import escape from './escape.js';\nimport reEscape from './_reEscape.js';\nimport reEvaluate from './_reEvaluate.js';\nimport reInterpolate from './_reInterpolate.js';\n\n/**\n * By default, the template delimiters used by lodash are like those in\n * embedded Ruby (ERB) as well as ES2015 template strings. Change the\n * following template settings to use alternative delimiters.\n *\n * @static\n * @memberOf _\n * @type {Object}\n */\nvar templateSettings = {\n\n /**\n * Used to detect `data` property values to be HTML-escaped.\n *\n * @memberOf _.templateSettings\n * @type {RegExp}\n */\n 'escape': reEscape,\n\n /**\n * Used to detect code to be evaluated.\n *\n * @memberOf _.templateSettings\n * @type {RegExp}\n */\n 'evaluate': reEvaluate,\n\n /**\n * Used to detect `data` property values to inject.\n *\n * @memberOf _.templateSettings\n * @type {RegExp}\n */\n 'interpolate': reInterpolate,\n\n /**\n * Used to reference the data object in the template text.\n *\n * @memberOf _.templateSettings\n * @type {string}\n */\n 'variable': '',\n\n /**\n * Used to import variables into the compiled template.\n *\n * @memberOf _.templateSettings\n * @type {Object}\n */\n 'imports': {\n\n /**\n * A reference to the `lodash` function.\n *\n * @memberOf _.templateSettings.imports\n * @type {Function}\n */\n '_': { 'escape': escape }\n }\n};\n\nexport default templateSettings;\n","import assignInWith from './assignInWith.js';\nimport attempt from './attempt.js';\nimport baseValues from './_baseValues.js';\nimport customDefaultsAssignIn from './_customDefaultsAssignIn.js';\nimport escapeStringChar from './_escapeStringChar.js';\nimport isError from './isError.js';\nimport isIterateeCall from './_isIterateeCall.js';\nimport keys from './keys.js';\nimport reInterpolate from './_reInterpolate.js';\nimport templateSettings from './templateSettings.js';\nimport toString from './toString.js';\n\n/** Error message constants. */\nvar INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';\n\n/** Used to match empty string literals in compiled template source. */\nvar reEmptyStringLeading = /\\b__p \\+= '';/g,\n reEmptyStringMiddle = /\\b(__p \\+=) '' \\+/g,\n reEmptyStringTrailing = /(__e\\(.*?\\)|\\b__t\\)) \\+\\n'';/g;\n\n/**\n * Used to validate the `validate` option in `_.template` variable.\n *\n * Forbids characters which could potentially change the meaning of the function argument definition:\n * - \"(),\" (modification of function parameters)\n * - \"=\" (default value)\n * - \"[]{}\" (destructuring of function parameters)\n * - \"/\" (beginning of a comment)\n * - whitespace\n */\nvar reForbiddenIdentifierChars = /[()=,{}\\[\\]\\/\\s]/;\n\n/**\n * Used to match\n * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).\n */\nvar reEsTemplate = /\\$\\{([^\\\\}]*(?:\\\\.[^\\\\}]*)*)\\}/g;\n\n/** Used to ensure capturing order of template delimiters. */\nvar reNoMatch = /($^)/;\n\n/** Used to match unescaped characters in compiled string literals. */\nvar reUnescapedString = /['\\n\\r\\u2028\\u2029\\\\]/g;\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Creates a compiled template function that can interpolate data properties\n * in \"interpolate\" delimiters, HTML-escape interpolated data properties in\n * \"escape\" delimiters, and execute JavaScript in \"evaluate\" delimiters. Data\n * properties may be accessed as free variables in the template. If a setting\n * object is given, it takes precedence over `_.templateSettings` values.\n *\n * **Note:** In the development build `_.template` utilizes\n * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)\n * for easier debugging.\n *\n * For more information on precompiling templates see\n * [lodash's custom builds documentation](https://lodash.com/custom-builds).\n *\n * For more information on Chrome extension sandboxes see\n * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category String\n * @param {string} [string=''] The template string.\n * @param {Object} [options={}] The options object.\n * @param {RegExp} [options.escape=_.templateSettings.escape]\n * The HTML \"escape\" delimiter.\n * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]\n * The \"evaluate\" delimiter.\n * @param {Object} [options.imports=_.templateSettings.imports]\n * An object to import into the template as free variables.\n * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]\n * The \"interpolate\" delimiter.\n * @param {string} [options.sourceURL='templateSources[n]']\n * The sourceURL of the compiled template.\n * @param {string} [options.variable='obj']\n * The data object variable name.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Function} Returns the compiled template function.\n * @example\n *\n * // Use the \"interpolate\" delimiter to create a compiled template.\n * var compiled = _.template('hello <%= user %>!');\n * compiled({ 'user': 'fred' });\n * // => 'hello fred!'\n *\n * // Use the HTML \"escape\" delimiter to escape data property values.\n * var compiled = _.template('<b><%- value %></b>');\n * compiled({ 'value': '<script>' });\n * // => '<b><script></b>'\n *\n * // Use the \"evaluate\" delimiter to execute JavaScript and generate HTML.\n * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');\n * compiled({ 'users': ['fred', 'barney'] });\n * // => '<li>fred</li><li>barney</li>'\n *\n * // Use the internal `print` function in \"evaluate\" delimiters.\n * var compiled = _.template('<% print(\"hello \" + user); %>!');\n * compiled({ 'user': 'barney' });\n * // => 'hello barney!'\n *\n * // Use the ES template literal delimiter as an \"interpolate\" delimiter.\n * // Disable support by replacing the \"interpolate\" delimiter.\n * var compiled = _.template('hello ${ user }!');\n * compiled({ 'user': 'pebbles' });\n * // => 'hello pebbles!'\n *\n * // Use backslashes to treat delimiters as plain text.\n * var compiled = _.template('<%= \"\\\\<%- value %\\\\>\" %>');\n * compiled({ 'value': 'ignored' });\n * // => '<%- value %>'\n *\n * // Use the `imports` option to import `jQuery` as `jq`.\n * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';\n * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });\n * compiled({ 'users': ['fred', 'barney'] });\n * // => '<li>fred</li><li>barney</li>'\n *\n * // Use the `sourceURL` option to specify a custom sourceURL for the template.\n * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });\n * compiled(data);\n * // => Find the source of \"greeting.jst\" under the Sources tab or Resources panel of the web inspector.\n *\n * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.\n * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });\n * compiled.source;\n * // => function(data) {\n * // var __t, __p = '';\n * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';\n * // return __p;\n * // }\n *\n * // Use custom template delimiters.\n * _.templateSettings.interpolate = /{{([\\s\\S]+?)}}/g;\n * var compiled = _.template('hello {{ user }}!');\n * compiled({ 'user': 'mustache' });\n * // => 'hello mustache!'\n *\n * // Use the `source` property to inline compiled templates for meaningful\n * // line numbers in error messages and stack traces.\n * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\\\n * var JST = {\\\n * \"main\": ' + _.template(mainText).source + '\\\n * };\\\n * ');\n */\nfunction template(string, options, guard) {\n // Based on John Resig's `tmpl` implementation\n // (http://ejohn.org/blog/javascript-micro-templating/)\n // and Laura Doktorova's doT.js (https://github.com/olado/doT).\n var settings = templateSettings.imports._.templateSettings || templateSettings;\n\n if (guard && isIterateeCall(string, options, guard)) {\n options = undefined;\n }\n string = toString(string);\n options = assignInWith({}, options, settings, customDefaultsAssignIn);\n\n var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),\n importsKeys = keys(imports),\n importsValues = baseValues(imports, importsKeys);\n\n var isEscaping,\n isEvaluating,\n index = 0,\n interpolate = options.interpolate || reNoMatch,\n source = \"__p += '\";\n\n // Compile the regexp to match each delimiter.\n var reDelimiters = RegExp(\n (options.escape || reNoMatch).source + '|' +\n interpolate.source + '|' +\n (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +\n (options.evaluate || reNoMatch).source + '|$'\n , 'g');\n\n // Use a sourceURL for easier debugging.\n // The sourceURL gets injected into the source that's eval-ed, so be careful\n // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in\n // and escape the comment, thus injecting code that gets evaled.\n var sourceURL = hasOwnProperty.call(options, 'sourceURL')\n ? ('//# sourceURL=' +\n (options.sourceURL + '').replace(/\\s/g, ' ') +\n '\\n')\n : '';\n\n string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {\n interpolateValue || (interpolateValue = esTemplateValue);\n\n // Escape characters that can't be included in string literals.\n source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);\n\n // Replace delimiters with snippets.\n if (escapeValue) {\n isEscaping = true;\n source += \"' +\\n__e(\" + escapeValue + \") +\\n'\";\n }\n if (evaluateValue) {\n isEvaluating = true;\n source += \"';\\n\" + evaluateValue + \";\\n__p += '\";\n }\n if (interpolateValue) {\n source += \"' +\\n((__t = (\" + interpolateValue + \")) == null ? '' : __t) +\\n'\";\n }\n index = offset + match.length;\n\n // The JS engine embedded in Adobe products needs `match` returned in\n // order to produce the correct `offset` value.\n return match;\n });\n\n source += \"';\\n\";\n\n // If `variable` is not specified wrap a with-statement around the generated\n // code to add the data object to the top of the scope chain.\n var variable = hasOwnProperty.call(options, 'variable') && options.variable;\n if (!variable) {\n source = 'with (obj) {\\n' + source + '\\n}\\n';\n }\n // Throw an error if a forbidden character was found in `variable`, to prevent\n // potential command injection attacks.\n else if (reForbiddenIdentifierChars.test(variable)) {\n throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);\n }\n\n // Cleanup code by stripping empty strings.\n source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)\n .replace(reEmptyStringMiddle, '$1')\n .replace(reEmptyStringTrailing, '$1;');\n\n // Frame code as the function body.\n source = 'function(' + (variable || 'obj') + ') {\\n' +\n (variable\n ? ''\n : 'obj || (obj = {});\\n'\n ) +\n \"var __t, __p = ''\" +\n (isEscaping\n ? ', __e = _.escape'\n : ''\n ) +\n (isEvaluating\n ? ', __j = Array.prototype.join;\\n' +\n \"function print() { __p += __j.call(arguments, '') }\\n\"\n : ';\\n'\n ) +\n source +\n 'return __p\\n}';\n\n var result = attempt(function() {\n return Function(importsKeys, sourceURL + 'return ' + source)\n .apply(undefined, importsValues);\n });\n\n // Provide the compiled function's source by its `toString` method or\n // the `source` property as a convenience for inlining compiled templates.\n result.source = source;\n if (isError(result)) {\n throw result;\n }\n return result;\n}\n\nexport default template;\n","import type { IFrameModalElement } from './iframe-modal';\nimport { data } from '../data';\nimport { __, highlight, html, selectOne, slideUp } from '../service';\nimport { template } from 'lodash-es';\n\nexport type ModalSelectCallback = (item: any) => void;\n\nexport function createCallback(type: 'list' | 'single', selector: string, modalSelector: string): ModalSelectCallback {\n switch (type) {\n // case 'tag':\n // return () => {\n //\n // };\n case 'list':\n return (item: any) => {\n const modalList = document.querySelector(selector) as any as ModalListSelectElement;\n\n if (!modalList.querySelector(`[data-value=\"${item.value}\"]`)) {\n modalList.appendItem(item, true);\n\n selectOne<IFrameModalElement>(modalSelector)?.close();\n } else {\n alert(__('unicorn.field.modal.already.selected'));\n }\n };\n\n case 'single':\n default:\n return (item) => {\n const element = document.querySelector<HTMLDivElement>(selector)!;\n\n const image = element.querySelector<HTMLDivElement>('[data-role=image]')!;\n const title = element.querySelector<HTMLInputElement>('[data-role=title]')!;\n const store = element.querySelector<HTMLInputElement>('[data-role=value]')!;\n\n if (image && item.image) {\n image.style.backgroundImage = `url(${item.image});`;\n }\n\n title.value = item.title || '';\n store.value = item.value || '';\n\n store.dispatchEvent(new CustomEvent('change'));\n\n selectOne<IFrameModalElement>(modalSelector)?.close();\n\n highlight(title);\n };\n }\n}\n\ninterface ModalListOptions {\n modalSelector: string;\n itemTemplate: string;\n sortable: boolean;\n dataKey: string;\n max: number;\n}\n\nexport interface ReceivedItem {\n value: string | number;\n title?: string;\n image?: string;\n [key: string]: any;\n}\n\nclass ModalListSelectElement extends HTMLElement {\n static is = 'uni-modal-list';\n\n itemTemplate!: ReturnType<typeof template>;\n options!: ModalListOptions;\n\n get listContainer() {\n return this.querySelector<HTMLDivElement>('[data-role=list-container]')!;\n }\n\n get modal() {\n return document.querySelector<IFrameModalElement>(this.options.modalSelector);\n }\n\n get items(): HTMLElement[] {\n return Array.from(this.listContainer.querySelectorAll<HTMLElement>('[data-value]'));\n }\n\n connectedCallback() {\n this.options = JSON.parse(this.getAttribute('options') || '{}');\n this.itemTemplate = template(document.querySelector(this.options.itemTemplate)!.innerHTML);\n\n const emptyInput = this.querySelector<HTMLInputElement>('[data-role=empty]');\n\n if (emptyInput) {\n emptyInput.name = emptyInput.dataset.name || '';\n }\n\n if (this.options.sortable) {\n import('sortablejs').then(({ default: Sortable }) => {\n new Sortable(this.listContainer, { handle: '.h-drag-handle', animation: 150 });\n });\n }\n\n const selectButton = this.querySelector<HTMLButtonElement>('[data-role=select]')!;\n selectButton.addEventListener('click', (e) => {\n this.open(e);\n });\n\n this.querySelector('[data-role=clear]')?.addEventListener('click', () => {\n this.removeAll();\n });\n\n selectButton.style.pointerEvents = '';\n\n this.render();\n }\n\n render() {\n const items: ReceivedItem[] = data('unicorn.modal-field')[this.options.dataKey] || [];\n\n items.forEach((item) => {\n this.appendItem(item);\n });\n }\n\n appendItem(item: ReceivedItem, highlights = false) {\n const itemHtml = html(this.itemTemplate({ item }));\n\n itemHtml.dataset.value = String(item.value);\n itemHtml.querySelector<HTMLButtonElement>('[data-role=remove]')?.addEventListener('click', () => {\n this.removeItem(item);\n });\n\n this.listContainer.appendChild(itemHtml);\n this.toggleRequired();\n\n if (highlights) {\n highlight(itemHtml);\n }\n }\n\n appendIfNotExists(item: ReceivedItem, highlights = false) {\n if (!this.isExists(item)) {\n this.appendItem(item, highlights);\n }\n }\n\n isExists(item: ReceivedItem | string | number): boolean {\n if (typeof item === 'object') {\n item = item.value;\n }\n\n return this.listContainer.querySelector(`[data-value=\"${item}\"]`) !== null;\n }\n\n getItemElement(item: ReceivedItem | string | number): HTMLElement | null {\n if (typeof item === 'object') {\n item = item.value;\n }\n\n return this.listContainer.querySelector<HTMLElement>(`[data-value=\"${item}\"]`);\n }\n\n getValues() {\n return this.items.map((item) => item.dataset.value);\n }\n\n removeItem(item: ReceivedItem | string | number) {\n if (typeof item === 'object') {\n item = item.value;\n }\n\n const element = this.listContainer.querySelector<HTMLElement>(`[data-value=\"${item}\"]`);\n\n if (element) {\n slideUp(element).then(() => {\n element.remove();\n this.toggleRequired();\n });\n }\n }\n\n async removeAll() {\n const promises: Promise<any>[] = [];\n\n for (const item of this.items) {\n promises.push(slideUp(item).then(() => item.remove()));\n }\n\n await Promise.all(promises);\n\n this.toggleRequired();\n }\n\n toggleRequired() {\n const placeholder = this.querySelector<HTMLInputElement>('[data-role=validation-placeholder]');\n\n if (placeholder) {\n placeholder.disabled = this.listContainer.children.length !== 0;\n }\n }\n\n open(event: Event) {\n event.preventDefault();\n event.stopPropagation();\n\n const max = this.options.max;\n\n const target = event.target as HTMLAnchorElement;\n\n if (!max) {\n this.modal?.open(target.href, { size: 'modal-xl' });\n return;\n }\n\n if (this.listContainer.children.length >= max) {\n alert(\n __('unicorn.field.modal.max.selected', max)\n );\n\n return;\n }\n\n this.modal?.open(target.href, { size: 'modal-xl' });\n }\n}\n\nasync function init() {\n customElements.define(ModalListSelectElement.is, ModalListSelectElement);\n}\n\nexport interface ModalListenMessagesOptions {\n origin: string;\n instanceId: string;\n type: 'list' | 'single';\n selector: string;\n modalSelector: string;\n}\n\nexport function listenMessages(options: ModalListenMessagesOptions) {\n const callback = createCallback(options.type, options.selector, options.modalSelector);\n\n window.addEventListener('message', (e) => {\n if (e.origin === options.origin && Array.isArray(e.data) && e.data[0] === options.instanceId) {\n callback(e.data[1]);\n }\n });\n\n // Todo: Should remove this after 4.3 or 5.0\n // @ts-ignore\n window[options.instanceId] = callback;\n}\n\nexport const ready = init();\n\nexport interface ModalSelectModule {\n createCallback: typeof create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,UAAM,gBAAA;AAEN,UAAM,MAAM,KAAK,QAAQ;AAEzB,UAAM,SAAS,MAAM;AAErB,QAAI,CAAC,KAAK;AACR,WAAK,OAAO,KAAK,OAAO,MAAM,EAAE,MAAM,YAAY;AAClD;AAAA,IACF;AAEA,QAAI,KAAK,cAAc,SAAS,UAAU,KAAK;AAC7C;AAAA,QACE,GAAG,oCAAoC,GAAG;AAAA,MAAA;AAG5C;AAAA,IACF;AAEA,SAAK,OAAO,KAAK,OAAO,MAAM,EAAE,MAAM,YAAY;AAAA,EACpD;AACF;AAEA,eAAe,OAAO;AACpB,iBAAe,OAAO,uBAAuB,IAAI,sBAAsB;AACzE;AAUO,SAAS,eAAe,SAAqC;AAClE,QAAM,WAAW,eAAe,QAAQ,MAAM,QAAQ,UAAU,QAAQ,aAAa;AAErF,SAAO,iBAAiB,WAAW,CAAC,MAAM;AACxC,QAAI,EAAE,WAAW,QAAQ,UAAU,MAAM,QAAQ,EAAE,IAAI,KAAK,EAAE,KAAK,CAAC,MAAM,QAAQ,YAAY;AAC5F,eAAS,EAAE,KAAK,CAAC,CAAC;AAAA,IACpB;AAAA,EACF,CAAC;AAID,SAAO,QAAQ,UAAU,IAAI;AAC/B;AAEO,MAAM,QAAQ,qBAAA;","x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]}
|
|
1
|
+
{"version":3,"file":"field-modal-select.js","sources":["../../../../../../node_modules/lodash-es/isSymbol.js","../../../../../../node_modules/lodash-es/_arrayMap.js","../../../../../../node_modules/lodash-es/_baseToString.js","../../../../../../node_modules/lodash-es/_copyObject.js","../../../../../../node_modules/lodash-es/_isIterateeCall.js","../../../../../../node_modules/lodash-es/_createAssigner.js","../../../../../../node_modules/lodash-es/_nativeKeysIn.js","../../../../../../node_modules/lodash-es/_baseKeysIn.js","../../../../../../node_modules/lodash-es/keysIn.js","../../../../../../node_modules/lodash-es/assignInWith.js","../../../../../../node_modules/lodash-es/toString.js","../../../../../../node_modules/lodash-es/isPlainObject.js","../../../../../../node_modules/lodash-es/isError.js","../../../../../../node_modules/lodash-es/attempt.js","../../../../../../node_modules/lodash-es/_basePropertyOf.js","../../../../../../node_modules/lodash-es/_escapeHtmlChar.js","../../../../../../node_modules/lodash-es/escape.js","../../../../../../node_modules/lodash-es/_baseValues.js","../../../../../../node_modules/lodash-es/_customDefaultsAssignIn.js","../../../../../../node_modules/lodash-es/_escapeStringChar.js","../../../../../../node_modules/lodash-es/_reInterpolate.js","../../../../../../node_modules/lodash-es/_reEscape.js","../../../../../../node_modules/lodash-es/_reEvaluate.js","../../../../../../node_modules/lodash-es/templateSettings.js","../../../../../../node_modules/lodash-es/template.js","../../src/module/field-modal-select.ts"],"sourcesContent":["import baseGetTag from './_baseGetTag.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar symbolTag = '[object Symbol]';\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && baseGetTag(value) == symbolTag);\n}\n\nexport default isSymbol;\n","/**\n * A specialized version of `_.map` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the new mapped array.\n */\nfunction arrayMap(array, iteratee) {\n var index = -1,\n length = array == null ? 0 : array.length,\n result = Array(length);\n\n while (++index < length) {\n result[index] = iteratee(array[index], index, array);\n }\n return result;\n}\n\nexport default arrayMap;\n","import Symbol from './_Symbol.js';\nimport arrayMap from './_arrayMap.js';\nimport isArray from './isArray.js';\nimport isSymbol from './isSymbol.js';\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0;\n\n/** Used to convert symbols to primitives and strings. */\nvar symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolToString = symbolProto ? symbolProto.toString : undefined;\n\n/**\n * The base implementation of `_.toString` which doesn't convert nullish\n * values to empty strings.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {string} Returns the string.\n */\nfunction baseToString(value) {\n // Exit early for strings to avoid a performance hit in some environments.\n if (typeof value == 'string') {\n return value;\n }\n if (isArray(value)) {\n // Recursively convert values (susceptible to call stack limits).\n return arrayMap(value, baseToString) + '';\n }\n if (isSymbol(value)) {\n return symbolToString ? symbolToString.call(value) : '';\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n}\n\nexport default baseToString;\n","import assignValue from './_assignValue.js';\nimport baseAssignValue from './_baseAssignValue.js';\n\n/**\n * Copies properties of `source` to `object`.\n *\n * @private\n * @param {Object} source The object to copy properties from.\n * @param {Array} props The property identifiers to copy.\n * @param {Object} [object={}] The object to copy properties to.\n * @param {Function} [customizer] The function to customize copied values.\n * @returns {Object} Returns `object`.\n */\nfunction copyObject(source, props, object, customizer) {\n var isNew = !object;\n object || (object = {});\n\n var index = -1,\n length = props.length;\n\n while (++index < length) {\n var key = props[index];\n\n var newValue = customizer\n ? customizer(object[key], source[key], key, object, source)\n : undefined;\n\n if (newValue === undefined) {\n newValue = source[key];\n }\n if (isNew) {\n baseAssignValue(object, key, newValue);\n } else {\n assignValue(object, key, newValue);\n }\n }\n return object;\n}\n\nexport default copyObject;\n","import eq from './eq.js';\nimport isArrayLike from './isArrayLike.js';\nimport isIndex from './_isIndex.js';\nimport isObject from './isObject.js';\n\n/**\n * Checks if the given arguments are from an iteratee call.\n *\n * @private\n * @param {*} value The potential iteratee value argument.\n * @param {*} index The potential iteratee index or key argument.\n * @param {*} object The potential iteratee object argument.\n * @returns {boolean} Returns `true` if the arguments are from an iteratee call,\n * else `false`.\n */\nfunction isIterateeCall(value, index, object) {\n if (!isObject(object)) {\n return false;\n }\n var type = typeof index;\n if (type == 'number'\n ? (isArrayLike(object) && isIndex(index, object.length))\n : (type == 'string' && index in object)\n ) {\n return eq(object[index], value);\n }\n return false;\n}\n\nexport default isIterateeCall;\n","import baseRest from './_baseRest.js';\nimport isIterateeCall from './_isIterateeCall.js';\n\n/**\n * Creates a function like `_.assign`.\n *\n * @private\n * @param {Function} assigner The function to assign values.\n * @returns {Function} Returns the new assigner function.\n */\nfunction createAssigner(assigner) {\n return baseRest(function(object, sources) {\n var index = -1,\n length = sources.length,\n customizer = length > 1 ? sources[length - 1] : undefined,\n guard = length > 2 ? sources[2] : undefined;\n\n customizer = (assigner.length > 3 && typeof customizer == 'function')\n ? (length--, customizer)\n : undefined;\n\n if (guard && isIterateeCall(sources[0], sources[1], guard)) {\n customizer = length < 3 ? undefined : customizer;\n length = 1;\n }\n object = Object(object);\n while (++index < length) {\n var source = sources[index];\n if (source) {\n assigner(object, source, index, customizer);\n }\n }\n return object;\n });\n}\n\nexport default createAssigner;\n","/**\n * This function is like\n * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n * except that it includes inherited enumerable properties.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction nativeKeysIn(object) {\n var result = [];\n if (object != null) {\n for (var key in Object(object)) {\n result.push(key);\n }\n }\n return result;\n}\n\nexport default nativeKeysIn;\n","import isObject from './isObject.js';\nimport isPrototype from './_isPrototype.js';\nimport nativeKeysIn from './_nativeKeysIn.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction baseKeysIn(object) {\n if (!isObject(object)) {\n return nativeKeysIn(object);\n }\n var isProto = isPrototype(object),\n result = [];\n\n for (var key in object) {\n if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {\n result.push(key);\n }\n }\n return result;\n}\n\nexport default baseKeysIn;\n","import arrayLikeKeys from './_arrayLikeKeys.js';\nimport baseKeysIn from './_baseKeysIn.js';\nimport isArrayLike from './isArrayLike.js';\n\n/**\n * Creates an array of the own and inherited enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keysIn(new Foo);\n * // => ['a', 'b', 'c'] (iteration order is not guaranteed)\n */\nfunction keysIn(object) {\n return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);\n}\n\nexport default keysIn;\n","import copyObject from './_copyObject.js';\nimport createAssigner from './_createAssigner.js';\nimport keysIn from './keysIn.js';\n\n/**\n * This method is like `_.assignIn` except that it accepts `customizer`\n * which is invoked to produce the assigned values. If `customizer` returns\n * `undefined`, assignment is handled by the method instead. The `customizer`\n * is invoked with five arguments: (objValue, srcValue, key, object, source).\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @alias extendWith\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} sources The source objects.\n * @param {Function} [customizer] The function to customize assigned values.\n * @returns {Object} Returns `object`.\n * @see _.assignWith\n * @example\n *\n * function customizer(objValue, srcValue) {\n * return _.isUndefined(objValue) ? srcValue : objValue;\n * }\n *\n * var defaults = _.partialRight(_.assignInWith, customizer);\n *\n * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });\n * // => { 'a': 1, 'b': 2 }\n */\nvar assignInWith = createAssigner(function(object, source, srcIndex, customizer) {\n copyObject(source, keysIn(source), object, customizer);\n});\n\nexport default assignInWith;\n","import baseToString from './_baseToString.js';\n\n/**\n * Converts `value` to a string. An empty string is returned for `null`\n * and `undefined` values. The sign of `-0` is preserved.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n * @example\n *\n * _.toString(null);\n * // => ''\n *\n * _.toString(-0);\n * // => '-0'\n *\n * _.toString([1, 2, 3]);\n * // => '1,2,3'\n */\nfunction toString(value) {\n return value == null ? '' : baseToString(value);\n}\n\nexport default toString;\n","import baseGetTag from './_baseGetTag.js';\nimport getPrototype from './_getPrototype.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar objectTag = '[object Object]';\n\n/** Used for built-in method references. */\nvar funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Used to infer the `Object` constructor. */\nvar objectCtorString = funcToString.call(Object);\n\n/**\n * Checks if `value` is a plain object, that is, an object created by the\n * `Object` constructor or one with a `[[Prototype]]` of `null`.\n *\n * @static\n * @memberOf _\n * @since 0.8.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * }\n *\n * _.isPlainObject(new Foo);\n * // => false\n *\n * _.isPlainObject([1, 2, 3]);\n * // => false\n *\n * _.isPlainObject({ 'x': 0, 'y': 0 });\n * // => true\n *\n * _.isPlainObject(Object.create(null));\n * // => true\n */\nfunction isPlainObject(value) {\n if (!isObjectLike(value) || baseGetTag(value) != objectTag) {\n return false;\n }\n var proto = getPrototype(value);\n if (proto === null) {\n return true;\n }\n var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;\n return typeof Ctor == 'function' && Ctor instanceof Ctor &&\n funcToString.call(Ctor) == objectCtorString;\n}\n\nexport default isPlainObject;\n","import baseGetTag from './_baseGetTag.js';\nimport isObjectLike from './isObjectLike.js';\nimport isPlainObject from './isPlainObject.js';\n\n/** `Object#toString` result references. */\nvar domExcTag = '[object DOMException]',\n errorTag = '[object Error]';\n\n/**\n * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,\n * `SyntaxError`, `TypeError`, or `URIError` object.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an error object, else `false`.\n * @example\n *\n * _.isError(new Error);\n * // => true\n *\n * _.isError(Error);\n * // => false\n */\nfunction isError(value) {\n if (!isObjectLike(value)) {\n return false;\n }\n var tag = baseGetTag(value);\n return tag == errorTag || tag == domExcTag ||\n (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));\n}\n\nexport default isError;\n","import apply from './_apply.js';\nimport baseRest from './_baseRest.js';\nimport isError from './isError.js';\n\n/**\n * Attempts to invoke `func`, returning either the result or the caught error\n * object. Any additional arguments are provided to `func` when it's invoked.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Util\n * @param {Function} func The function to attempt.\n * @param {...*} [args] The arguments to invoke `func` with.\n * @returns {*} Returns the `func` result or error object.\n * @example\n *\n * // Avoid throwing errors for invalid selectors.\n * var elements = _.attempt(function(selector) {\n * return document.querySelectorAll(selector);\n * }, '>_>');\n *\n * if (_.isError(elements)) {\n * elements = [];\n * }\n */\nvar attempt = baseRest(function(func, args) {\n try {\n return apply(func, undefined, args);\n } catch (e) {\n return isError(e) ? e : new Error(e);\n }\n});\n\nexport default attempt;\n","/**\n * The base implementation of `_.propertyOf` without support for deep paths.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Function} Returns the new accessor function.\n */\nfunction basePropertyOf(object) {\n return function(key) {\n return object == null ? undefined : object[key];\n };\n}\n\nexport default basePropertyOf;\n","import basePropertyOf from './_basePropertyOf.js';\n\n/** Used to map characters to HTML entities. */\nvar htmlEscapes = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": '''\n};\n\n/**\n * Used by `_.escape` to convert characters to HTML entities.\n *\n * @private\n * @param {string} chr The matched character to escape.\n * @returns {string} Returns the escaped character.\n */\nvar escapeHtmlChar = basePropertyOf(htmlEscapes);\n\nexport default escapeHtmlChar;\n","import escapeHtmlChar from './_escapeHtmlChar.js';\nimport toString from './toString.js';\n\n/** Used to match HTML entities and HTML characters. */\nvar reUnescapedHtml = /[&<>\"']/g,\n reHasUnescapedHtml = RegExp(reUnescapedHtml.source);\n\n/**\n * Converts the characters \"&\", \"<\", \">\", '\"', and \"'\" in `string` to their\n * corresponding HTML entities.\n *\n * **Note:** No other characters are escaped. To escape additional\n * characters use a third-party library like [_he_](https://mths.be/he).\n *\n * Though the \">\" character is escaped for symmetry, characters like\n * \">\" and \"/\" don't need escaping in HTML and have no special meaning\n * unless they're part of a tag or unquoted attribute value. See\n * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)\n * (under \"semi-related fun fact\") for more details.\n *\n * When working with HTML you should always\n * [quote attribute values](http://wonko.com/post/html-escaping) to reduce\n * XSS vectors.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to escape.\n * @returns {string} Returns the escaped string.\n * @example\n *\n * _.escape('fred, barney, & pebbles');\n * // => 'fred, barney, & pebbles'\n */\nfunction escape(string) {\n string = toString(string);\n return (string && reHasUnescapedHtml.test(string))\n ? string.replace(reUnescapedHtml, escapeHtmlChar)\n : string;\n}\n\nexport default escape;\n","import arrayMap from './_arrayMap.js';\n\n/**\n * The base implementation of `_.values` and `_.valuesIn` which creates an\n * array of `object` property values corresponding to the property names\n * of `props`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array} props The property names to get values for.\n * @returns {Object} Returns the array of property values.\n */\nfunction baseValues(object, props) {\n return arrayMap(props, function(key) {\n return object[key];\n });\n}\n\nexport default baseValues;\n","import eq from './eq.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used by `_.defaults` to customize its `_.assignIn` use to assign properties\n * of source objects to the destination object for all destination properties\n * that resolve to `undefined`.\n *\n * @private\n * @param {*} objValue The destination value.\n * @param {*} srcValue The source value.\n * @param {string} key The key of the property to assign.\n * @param {Object} object The parent object of `objValue`.\n * @returns {*} Returns the value to assign.\n */\nfunction customDefaultsAssignIn(objValue, srcValue, key, object) {\n if (objValue === undefined ||\n (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {\n return srcValue;\n }\n return objValue;\n}\n\nexport default customDefaultsAssignIn;\n","/** Used to escape characters for inclusion in compiled string literals. */\nvar stringEscapes = {\n '\\\\': '\\\\',\n \"'\": \"'\",\n '\\n': 'n',\n '\\r': 'r',\n '\\u2028': 'u2028',\n '\\u2029': 'u2029'\n};\n\n/**\n * Used by `_.template` to escape characters for inclusion in compiled string literals.\n *\n * @private\n * @param {string} chr The matched character to escape.\n * @returns {string} Returns the escaped character.\n */\nfunction escapeStringChar(chr) {\n return '\\\\' + stringEscapes[chr];\n}\n\nexport default escapeStringChar;\n","/** Used to match template delimiters. */\nvar reInterpolate = /<%=([\\s\\S]+?)%>/g;\n\nexport default reInterpolate;\n","/** Used to match template delimiters. */\nvar reEscape = /<%-([\\s\\S]+?)%>/g;\n\nexport default reEscape;\n","/** Used to match template delimiters. */\nvar reEvaluate = /<%([\\s\\S]+?)%>/g;\n\nexport default reEvaluate;\n","import escape from './escape.js';\nimport reEscape from './_reEscape.js';\nimport reEvaluate from './_reEvaluate.js';\nimport reInterpolate from './_reInterpolate.js';\n\n/**\n * By default, the template delimiters used by lodash are like those in\n * embedded Ruby (ERB) as well as ES2015 template strings. Change the\n * following template settings to use alternative delimiters.\n *\n * @static\n * @memberOf _\n * @type {Object}\n */\nvar templateSettings = {\n\n /**\n * Used to detect `data` property values to be HTML-escaped.\n *\n * @memberOf _.templateSettings\n * @type {RegExp}\n */\n 'escape': reEscape,\n\n /**\n * Used to detect code to be evaluated.\n *\n * @memberOf _.templateSettings\n * @type {RegExp}\n */\n 'evaluate': reEvaluate,\n\n /**\n * Used to detect `data` property values to inject.\n *\n * @memberOf _.templateSettings\n * @type {RegExp}\n */\n 'interpolate': reInterpolate,\n\n /**\n * Used to reference the data object in the template text.\n *\n * @memberOf _.templateSettings\n * @type {string}\n */\n 'variable': '',\n\n /**\n * Used to import variables into the compiled template.\n *\n * @memberOf _.templateSettings\n * @type {Object}\n */\n 'imports': {\n\n /**\n * A reference to the `lodash` function.\n *\n * @memberOf _.templateSettings.imports\n * @type {Function}\n */\n '_': { 'escape': escape }\n }\n};\n\nexport default templateSettings;\n","import assignInWith from './assignInWith.js';\nimport attempt from './attempt.js';\nimport baseValues from './_baseValues.js';\nimport customDefaultsAssignIn from './_customDefaultsAssignIn.js';\nimport escapeStringChar from './_escapeStringChar.js';\nimport isError from './isError.js';\nimport isIterateeCall from './_isIterateeCall.js';\nimport keys from './keys.js';\nimport reInterpolate from './_reInterpolate.js';\nimport templateSettings from './templateSettings.js';\nimport toString from './toString.js';\n\n/** Error message constants. */\nvar INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';\n\n/** Used to match empty string literals in compiled template source. */\nvar reEmptyStringLeading = /\\b__p \\+= '';/g,\n reEmptyStringMiddle = /\\b(__p \\+=) '' \\+/g,\n reEmptyStringTrailing = /(__e\\(.*?\\)|\\b__t\\)) \\+\\n'';/g;\n\n/**\n * Used to validate the `validate` option in `_.template` variable.\n *\n * Forbids characters which could potentially change the meaning of the function argument definition:\n * - \"(),\" (modification of function parameters)\n * - \"=\" (default value)\n * - \"[]{}\" (destructuring of function parameters)\n * - \"/\" (beginning of a comment)\n * - whitespace\n */\nvar reForbiddenIdentifierChars = /[()=,{}\\[\\]\\/\\s]/;\n\n/**\n * Used to match\n * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).\n */\nvar reEsTemplate = /\\$\\{([^\\\\}]*(?:\\\\.[^\\\\}]*)*)\\}/g;\n\n/** Used to ensure capturing order of template delimiters. */\nvar reNoMatch = /($^)/;\n\n/** Used to match unescaped characters in compiled string literals. */\nvar reUnescapedString = /['\\n\\r\\u2028\\u2029\\\\]/g;\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Creates a compiled template function that can interpolate data properties\n * in \"interpolate\" delimiters, HTML-escape interpolated data properties in\n * \"escape\" delimiters, and execute JavaScript in \"evaluate\" delimiters. Data\n * properties may be accessed as free variables in the template. If a setting\n * object is given, it takes precedence over `_.templateSettings` values.\n *\n * **Note:** In the development build `_.template` utilizes\n * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)\n * for easier debugging.\n *\n * For more information on precompiling templates see\n * [lodash's custom builds documentation](https://lodash.com/custom-builds).\n *\n * For more information on Chrome extension sandboxes see\n * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category String\n * @param {string} [string=''] The template string.\n * @param {Object} [options={}] The options object.\n * @param {RegExp} [options.escape=_.templateSettings.escape]\n * The HTML \"escape\" delimiter.\n * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]\n * The \"evaluate\" delimiter.\n * @param {Object} [options.imports=_.templateSettings.imports]\n * An object to import into the template as free variables.\n * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]\n * The \"interpolate\" delimiter.\n * @param {string} [options.sourceURL='templateSources[n]']\n * The sourceURL of the compiled template.\n * @param {string} [options.variable='obj']\n * The data object variable name.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Function} Returns the compiled template function.\n * @example\n *\n * // Use the \"interpolate\" delimiter to create a compiled template.\n * var compiled = _.template('hello <%= user %>!');\n * compiled({ 'user': 'fred' });\n * // => 'hello fred!'\n *\n * // Use the HTML \"escape\" delimiter to escape data property values.\n * var compiled = _.template('<b><%- value %></b>');\n * compiled({ 'value': '<script>' });\n * // => '<b><script></b>'\n *\n * // Use the \"evaluate\" delimiter to execute JavaScript and generate HTML.\n * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');\n * compiled({ 'users': ['fred', 'barney'] });\n * // => '<li>fred</li><li>barney</li>'\n *\n * // Use the internal `print` function in \"evaluate\" delimiters.\n * var compiled = _.template('<% print(\"hello \" + user); %>!');\n * compiled({ 'user': 'barney' });\n * // => 'hello barney!'\n *\n * // Use the ES template literal delimiter as an \"interpolate\" delimiter.\n * // Disable support by replacing the \"interpolate\" delimiter.\n * var compiled = _.template('hello ${ user }!');\n * compiled({ 'user': 'pebbles' });\n * // => 'hello pebbles!'\n *\n * // Use backslashes to treat delimiters as plain text.\n * var compiled = _.template('<%= \"\\\\<%- value %\\\\>\" %>');\n * compiled({ 'value': 'ignored' });\n * // => '<%- value %>'\n *\n * // Use the `imports` option to import `jQuery` as `jq`.\n * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';\n * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });\n * compiled({ 'users': ['fred', 'barney'] });\n * // => '<li>fred</li><li>barney</li>'\n *\n * // Use the `sourceURL` option to specify a custom sourceURL for the template.\n * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });\n * compiled(data);\n * // => Find the source of \"greeting.jst\" under the Sources tab or Resources panel of the web inspector.\n *\n * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.\n * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });\n * compiled.source;\n * // => function(data) {\n * // var __t, __p = '';\n * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';\n * // return __p;\n * // }\n *\n * // Use custom template delimiters.\n * _.templateSettings.interpolate = /{{([\\s\\S]+?)}}/g;\n * var compiled = _.template('hello {{ user }}!');\n * compiled({ 'user': 'mustache' });\n * // => 'hello mustache!'\n *\n * // Use the `source` property to inline compiled templates for meaningful\n * // line numbers in error messages and stack traces.\n * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\\\n * var JST = {\\\n * \"main\": ' + _.template(mainText).source + '\\\n * };\\\n * ');\n */\nfunction template(string, options, guard) {\n // Based on John Resig's `tmpl` implementation\n // (http://ejohn.org/blog/javascript-micro-templating/)\n // and Laura Doktorova's doT.js (https://github.com/olado/doT).\n var settings = templateSettings.imports._.templateSettings || templateSettings;\n\n if (guard && isIterateeCall(string, options, guard)) {\n options = undefined;\n }\n string = toString(string);\n options = assignInWith({}, options, settings, customDefaultsAssignIn);\n\n var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),\n importsKeys = keys(imports),\n importsValues = baseValues(imports, importsKeys);\n\n var isEscaping,\n isEvaluating,\n index = 0,\n interpolate = options.interpolate || reNoMatch,\n source = \"__p += '\";\n\n // Compile the regexp to match each delimiter.\n var reDelimiters = RegExp(\n (options.escape || reNoMatch).source + '|' +\n interpolate.source + '|' +\n (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +\n (options.evaluate || reNoMatch).source + '|$'\n , 'g');\n\n // Use a sourceURL for easier debugging.\n // The sourceURL gets injected into the source that's eval-ed, so be careful\n // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in\n // and escape the comment, thus injecting code that gets evaled.\n var sourceURL = hasOwnProperty.call(options, 'sourceURL')\n ? ('//# sourceURL=' +\n (options.sourceURL + '').replace(/\\s/g, ' ') +\n '\\n')\n : '';\n\n string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {\n interpolateValue || (interpolateValue = esTemplateValue);\n\n // Escape characters that can't be included in string literals.\n source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);\n\n // Replace delimiters with snippets.\n if (escapeValue) {\n isEscaping = true;\n source += \"' +\\n__e(\" + escapeValue + \") +\\n'\";\n }\n if (evaluateValue) {\n isEvaluating = true;\n source += \"';\\n\" + evaluateValue + \";\\n__p += '\";\n }\n if (interpolateValue) {\n source += \"' +\\n((__t = (\" + interpolateValue + \")) == null ? '' : __t) +\\n'\";\n }\n index = offset + match.length;\n\n // The JS engine embedded in Adobe products needs `match` returned in\n // order to produce the correct `offset` value.\n return match;\n });\n\n source += \"';\\n\";\n\n // If `variable` is not specified wrap a with-statement around the generated\n // code to add the data object to the top of the scope chain.\n var variable = hasOwnProperty.call(options, 'variable') && options.variable;\n if (!variable) {\n source = 'with (obj) {\\n' + source + '\\n}\\n';\n }\n // Throw an error if a forbidden character was found in `variable`, to prevent\n // potential command injection attacks.\n else if (reForbiddenIdentifierChars.test(variable)) {\n throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);\n }\n\n // Cleanup code by stripping empty strings.\n source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)\n .replace(reEmptyStringMiddle, '$1')\n .replace(reEmptyStringTrailing, '$1;');\n\n // Frame code as the function body.\n source = 'function(' + (variable || 'obj') + ') {\\n' +\n (variable\n ? ''\n : 'obj || (obj = {});\\n'\n ) +\n \"var __t, __p = ''\" +\n (isEscaping\n ? ', __e = _.escape'\n : ''\n ) +\n (isEvaluating\n ? ', __j = Array.prototype.join;\\n' +\n \"function print() { __p += __j.call(arguments, '') }\\n\"\n : ';\\n'\n ) +\n source +\n 'return __p\\n}';\n\n var result = attempt(function() {\n return Function(importsKeys, sourceURL + 'return ' + source)\n .apply(undefined, importsValues);\n });\n\n // Provide the compiled function's source by its `toString` method or\n // the `source` property as a convenience for inlining compiled templates.\n result.source = source;\n if (isError(result)) {\n throw result;\n }\n return result;\n}\n\nexport default template;\n","import { template } from 'lodash-es';\nimport { data } from '../data';\nimport { __, highlight, html, selectOne, simpleAlert, slideUp } from '../service';\nimport type { IFrameModalElement } from './iframe-modal';\n\nexport type ModalSelectCallback = (item: any, ...args: any[]) => void;\n\nexport function createCallback(\n type: 'list' | 'single',\n selector: string,\n modalSelector: string\n): ModalSelectCallback {\n switch (type) {\n case 'list':\n return (item: any) => {\n const modalList = document.querySelector(selector) as any as ModalListSelectElement;\n const checked = item.checked;\n\n if (checked === undefined) {\n // Single selection mode\n if (!modalList.querySelector(`[data-value=\"${item.value}\"]`)) {\n modalList.appendItem(item, true);\n\n selectOne<IFrameModalElement>(modalSelector)?.close();\n } else {\n simpleAlert(__('unicorn.field.modal.already.selected'));\n }\n } else if (checked) {\n // Multiple selection mode - add item\n try {\n modalList.appendIfNotExists(item, true);\n } catch (e) {\n window.postMessage({\n task: 'remove-row',\n value: item,\n id: item.instanceId\n });\n simpleAlert((e as Error).message);\n } finally {\n modalList.updateSelected();\n }\n } else if (!checked) {\n // Multiple selection mode - remove item\n modalList.removeItem(item).then(() => {\n console.log(modalList.items);\n modalList.updateSelected();\n });\n }\n };\n\n case 'single':\n default:\n return (item) => {\n const element = document.querySelector<HTMLDivElement>(selector)!;\n\n const image = element.querySelector<HTMLDivElement>('[data-role=image]')!;\n const title = element.querySelector<HTMLInputElement>('[data-role=title]')!;\n const store = element.querySelector<HTMLInputElement>('[data-role=value]')!;\n\n if (image && item.image) {\n image.style.backgroundImage = `url(${item.image});`;\n }\n\n title.value = item.title || '';\n store.value = item.value || '';\n\n store.dispatchEvent(new CustomEvent('change'));\n\n selectOne<IFrameModalElement>(modalSelector)?.close();\n\n highlight(title);\n };\n }\n}\n\ninterface ModalListOptions {\n modalSelector: string;\n itemTemplate: string;\n sortable: boolean;\n dataKey: string;\n max: number;\n multiCheck?: boolean;\n}\n\nexport interface ReceivedItem {\n value: string | number;\n title?: string;\n image?: string;\n\n [key: string]: any;\n}\n\nclass ModalListSelectElement extends HTMLElement {\n static is = 'uni-modal-list';\n\n itemTemplate!: ReturnType<typeof template>;\n options!: ModalListOptions;\n isMultiCheck = false;\n\n get listContainer() {\n return this.querySelector<HTMLDivElement>('[data-role=list-container]')!;\n }\n\n get selectButton() {\n return this.querySelector<HTMLAnchorElement>('[data-role=select]')!;\n }\n\n get modal() {\n return document.querySelector<IFrameModalElement>(this.options.modalSelector);\n }\n\n get items(): HTMLElement[] {\n return Array.from(this.listContainer.querySelectorAll<HTMLElement>('[data-value]'));\n }\n\n get count(): number {\n return this.items.length;\n }\n\n connectedCallback() {\n this.options = JSON.parse(this.getAttribute('options') || '{}');\n this.itemTemplate = template(document.querySelector(this.options.itemTemplate)!.innerHTML);\n\n const emptyInput = this.querySelector<HTMLInputElement>('[data-role=empty]');\n\n if (emptyInput) {\n emptyInput.name = emptyInput.dataset.name || '';\n }\n\n if (this.options.sortable) {\n import('sortablejs').then(({ default: Sortable }) => {\n new Sortable(this.listContainer, { handle: '.h-drag-handle', animation: 150 });\n });\n }\n\n this.selectButton.addEventListener('click', (e) => {\n try {\n this.open(e);\n } catch (e) {\n simpleAlert((e as Error).message);\n }\n });\n\n this.querySelector('[data-role=clear]')?.addEventListener('click', () => {\n this.removeAll();\n });\n\n this.selectButton.style.pointerEvents = '';\n\n this.render();\n\n this.enableMultiCheck(this.options.multiCheck || false);\n }\n\n render() {\n const items: ReceivedItem[] = data('unicorn.modal-field')[this.options.dataKey] || [];\n\n items.forEach((item) => {\n this.appendItem(item);\n });\n }\n\n appendItem(item: ReceivedItem, highlights = false) {\n const max = this.options.max;\n\n if (max && this.count >= max) {\n throw new Error(__('unicorn.field.modal.max.selected', max));\n }\n\n const itemHtml = html(this.itemTemplate({ item }));\n\n itemHtml.dataset.value = String(item.value);\n itemHtml.querySelector<HTMLButtonElement>('[data-role=remove]')?.addEventListener('click', () => {\n this.removeItem(item);\n });\n\n this.listContainer.appendChild(itemHtml);\n this.toggleRequired();\n\n if (highlights) {\n highlight(itemHtml);\n }\n\n if (this.isMultiCheck) {\n this.updateSelected();\n }\n }\n\n appendIfNotExists(item: ReceivedItem, highlights = false) {\n if (!this.isExists(item)) {\n this.appendItem(item, highlights);\n }\n }\n\n isExists(item: ReceivedItem | string | number): boolean {\n if (typeof item === 'object') {\n item = item.value;\n }\n\n return this.listContainer.querySelector(`[data-value=\"${item}\"]`) !== null;\n }\n\n getItemElement(item: ReceivedItem | string | number): HTMLElement | null {\n if (typeof item === 'object') {\n item = item.value;\n }\n\n return this.listContainer.querySelector<HTMLElement>(`[data-value=\"${item}\"]`);\n }\n\n getValues() {\n return this.items.map((item) => item.dataset.value);\n }\n\n async removeItem(item: ReceivedItem | string | number) {\n if (typeof item === 'object') {\n item = item.value;\n }\n\n const element = this.listContainer.querySelector<HTMLElement>(`[data-value=\"${item}\"]`);\n\n if (element) {\n return slideUp(element).then(() => {\n element.remove();\n this.toggleRequired();\n\n if (this.isMultiCheck) {\n this.updateSelected();\n }\n });\n }\n }\n\n async removeAll() {\n const promises: Promise<any>[] = [];\n\n for (const item of this.items) {\n promises.push(slideUp(item).then(() => item.remove()));\n }\n\n await Promise.all(promises);\n\n this.toggleRequired();\n\n if (this.isMultiCheck) {\n this.updateSelected();\n }\n }\n\n toggleRequired() {\n const placeholder = this.querySelector<HTMLInputElement>('[data-role=validation-placeholder]');\n\n if (placeholder) {\n placeholder.disabled = this.listContainer.children.length !== 0;\n }\n }\n\n open(event: Event) {\n event.preventDefault();\n event.stopPropagation();\n\n const max = this.options.max;\n\n const target = event.target as HTMLAnchorElement;\n\n if (!max) {\n this.modal?.open(target.href, { size: 'modal-xl' });\n return;\n }\n\n if (this.count >= max) {\n throw new Error(__('unicorn.field.modal.max.selected', max));\n }\n\n this.modal?.open(target.href, { size: 'modal-xl' });\n }\n\n enableMultiCheck(enable = true) {\n this.isMultiCheck = enable;\n\n if (enable) {\n this.updateSelected();\n } else {\n this.clearSelected();\n }\n }\n\n updateSelected() {\n const url = new URL(this.selectButton.href);\n url.searchParams.set('selected', this.items.map((i) => i.dataset.value).join(','));\n this.selectButton.href = url.toString();\n }\n\n clearSelected() {\n const url = new URL(this.selectButton.href);\n url.searchParams.delete('selected');\n this.selectButton.href = url.toString();\n }\n}\n\nasync function init() {\n customElements.define(ModalListSelectElement.is, ModalListSelectElement);\n}\n\nexport interface ModalListenMessagesOptions {\n origin: string;\n instanceId: string;\n type: 'list' | 'single';\n selector: string;\n modalSelector: string;\n}\n\nexport function listenMessages(options: ModalListenMessagesOptions) {\n const callback = createCallback(options.type, options.selector, options.modalSelector);\n\n window.addEventListener('message', (e) => {\n if (e.origin === options.origin) {\n if (Array.isArray(e.data) && e.data[0] === options.instanceId) {\n callback(e.data[1]);\n }\n\n if (\n typeof e.data === 'object'\n && e.data !== null\n && e.data.id === options.instanceId\n && e.data.task === 'select-row'\n ) {\n const item = e.data.value;\n item.checked = e.data.checked;\n item.instanceId = e.data.id;\n\n callback(e.data.value);\n }\n }\n });\n\n // Todo: Should remove this after 4.3 or 5.0\n // @ts-ignore\n window[options.instanceId] = callback;\n}\n\nexport const ready = init();\n\nexport interface ModalSelectModule {\n createCallback: typeof createCallback;\n listenMessages: typeof listenMessages;\n ready: typeof ready;\n}\n"],"names":["Symbol","objectProto","hasOwnProperty","e"],"mappings":";;;;AAIA,IAAI,YAAY;AAmBhB,SAAS,SAAS,OAAO;AACvB,SAAO,OAAO,SAAS,YACpB,aAAa,KAAK,KAAK,WAAW,KAAK,KAAK;AACjD;ACjBA,SAAS,SAAS,OAAO,UAAU;AACjC,MAAI,QAAQ,IACR,SAAS,SAAS,OAAO,IAAI,MAAM,QACnC,SAAS,MAAM,MAAM;AAEzB,SAAO,EAAE,QAAQ,QAAQ;AACvB,WAAO,KAAK,IAAI,SAAS,MAAM,KAAK,GAAG,OAAO,KAAK;AAAA,EACrD;AACA,SAAO;AACT;ACTA,IAAI,cAAcA,WAAM,uBAAGA,SAAO,WAAA,IAAY,QAC1C,iBAAiB,cAAW,uBAAG,YAAY,UAAA,IAAW;AAU1D,SAAS,aAAa,OAAO;AAE3B,MAAI,OAAO,SAAS,UAAU;AAC5B,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,KAAK,GAAG;AAElB,WAAO,SAAS,OAAO,YAAY,IAAI;AAAA,EACzC;AACA,MAAI,SAAS,KAAK,GAAG;AACnB,WAAO,iBAAiB,eAAe,KAAK,KA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AAC,MAAM;AACxC,QAAI,EAAE,WAAW,QAAQ,QAAQ;AAC/B,UAAI,MAAM,QAAQ,EAAE,IAAI,KAAK,EAAE,KAAK,CAAC,MAAM,QAAQ,YAAY;AAC7D,iBAAS,EAAE,KAAK,CAAC,CAAC;AAAA,MACpB;AAEA,UACE,OAAO,EAAE,SAAS,YACf,EAAE,SAAS,QACX,EAAE,KAAK,OAAO,QAAQ,cACtB,EAAE,KAAK,SAAS,cACnB;AACA,cAAM,OAAO,EAAE,KAAK;AACpB,aAAK,UAAU,EAAE,KAAK;AACtB,aAAK,aAAa,EAAE,KAAK;AAEzB,iBAAS,EAAE,KAAK,KAAK;AAAA,MACvB;AAAA,IACF;AAAA,EACF,CAAC;AAID,SAAO,QAAQ,UAAU,IAAI;AAC/B;AAEO,MAAM,QAAQ,qBAAA;","x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]}
|
package/dist/chunks/form.js
CHANGED
|
@@ -16,8 +16,8 @@ class UnicornFormElement {
|
|
|
16
16
|
element.setAttribute("style", "display: none;");
|
|
17
17
|
const csrf = document.createElement("input");
|
|
18
18
|
csrf.setAttribute("type", "hidden");
|
|
19
|
-
csrf.setAttribute("name",
|
|
20
|
-
csrf.setAttribute("value", "
|
|
19
|
+
csrf.setAttribute("name", "anticsrf");
|
|
20
|
+
csrf.setAttribute("value", data("csrf-token"));
|
|
21
21
|
element.appendChild(csrf);
|
|
22
22
|
document.body.appendChild(element);
|
|
23
23
|
}
|
|
@@ -116,6 +116,12 @@ class UnicornFormElement {
|
|
|
116
116
|
delete(url, data2) {
|
|
117
117
|
return this.post(url, data2, "DELETE");
|
|
118
118
|
}
|
|
119
|
+
destroy() {
|
|
120
|
+
if (this.element) {
|
|
121
|
+
this.element.remove();
|
|
122
|
+
this.element = void 0;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
119
125
|
/**
|
|
120
126
|
* @see https://stackoverflow.com/a/53739792
|
|
121
127
|
*
|
package/dist/chunks/form.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.js","sources":["../../src/module/form.ts"],"sourcesContent":["import { data } from '../data';\nimport { loadAlpine, useSystemUri } from '../service';\nimport type { Nullable } from '../types';\n\nexport class UnicornFormElement {\n element: HTMLFormElement | undefined;\n options: Record<string, any>;\n\n constructor(\n selector?: string | Element,\n element?: HTMLFormElement,\n options: Record<string, any> = {},\n ) {\n // If form not found, create one\n if (!element) {\n element = document.createElement('form');\n\n if (typeof selector === 'string' && selector.startsWith('#')) {\n element.setAttribute('id', selector.substring(1));\n element.setAttribute('name', selector.substring(1));\n }\n\n element.setAttribute('method', 'post');\n element.setAttribute('enctype', 'multipart/form-data');\n element.setAttribute('novalidate', 'true');\n element.setAttribute('action', useSystemUri('full'));\n element.setAttribute('style', 'display: none;');\n\n const csrf = document.createElement('input');\n csrf.setAttribute('type', 'hidden');\n csrf.setAttribute('name',
|
|
1
|
+
{"version":3,"file":"form.js","sources":["../../src/module/form.ts"],"sourcesContent":["import { data } from '../data';\nimport { loadAlpine, useSystemUri } from '../service';\nimport type { Nullable } from '../types';\n\nexport class UnicornFormElement {\n element: HTMLFormElement | undefined;\n options: Record<string, any>;\n\n constructor(\n selector?: string | Element,\n element?: HTMLFormElement,\n options: Record<string, any> = {},\n ) {\n // If form not found, create one\n if (!element) {\n element = document.createElement('form');\n\n if (typeof selector === 'string' && selector.startsWith('#')) {\n element.setAttribute('id', selector.substring(1));\n element.setAttribute('name', selector.substring(1));\n }\n\n element.setAttribute('method', 'post');\n element.setAttribute('enctype', 'multipart/form-data');\n element.setAttribute('novalidate', 'true');\n element.setAttribute('action', useSystemUri('full'));\n element.setAttribute('style', 'display: none;');\n\n const csrf = document.createElement('input');\n csrf.setAttribute('type', 'hidden');\n csrf.setAttribute('name', 'anticsrf');\n csrf.setAttribute('value', data('csrf-token'));\n\n element.appendChild(csrf);\n document.body.appendChild(element);\n }\n\n this.element = element;\n this.options = { ...options };\n }\n\n initComponent(store = 'form', custom = {}) {\n return loadAlpine((Alpine) => {\n Alpine.store(store, this.useState(custom));\n });\n }\n\n useState(custom = {}) {\n const state: Record<string, any> = {};\n Object.getOwnPropertyNames(Object.getPrototypeOf(this))\n .map(item => {\n // @ts-ignore\n return state[item] = this[item].bind(this);\n });\n\n return Object.assign(\n state,\n custom\n );\n }\n\n getElement() {\n return this.element;\n }\n\n submit(\n url?: Nullable<string>,\n data?: Nullable<Record<string, any>>,\n method?: Nullable<string>,\n customMethod?: Nullable<string>,\n ): boolean {\n const form = this.element!;\n\n if (customMethod) {\n let methodInput = form.querySelector<HTMLInputElement>('input[name=\"_method\"]');\n\n if (!methodInput) {\n methodInput = document.createElement('input');\n methodInput.setAttribute('name', '_method');\n methodInput.setAttribute('type', 'hidden');\n methodInput.value = customMethod;\n\n form.appendChild(methodInput);\n } else {\n methodInput.value = customMethod;\n }\n }\n\n // Set data into form.\n if (data) {\n const flatted = UnicornFormElement.flattenObject(data);\n\n for (const key in flatted) {\n const value = flatted[key];\n\n const fieldName = UnicornFormElement.buildFieldName(key);\n this.injectInput(fieldName, value);\n }\n }\n\n if (url) {\n form.setAttribute('action', url);\n }\n\n if (method) {\n form.setAttribute('method', method);\n }\n\n // Use requestSubmit() to fire submit event.\n form.requestSubmit();\n\n return true;\n }\n\n injectInput(name: string, value: any) {\n let input = this.element!.querySelector<HTMLInputElement>(`input[name=\"${name}\"]`);\n\n if (!input) {\n input = document.createElement('input');\n input.setAttribute('name', name);\n input.setAttribute('type', 'hidden');\n input.setAttribute('data-role', 'temp-input');\n\n this.element!.appendChild(input);\n }\n\n input.value = value;\n return input;\n }\n\n /**\n * Make a GET request.\n */\n get(\n url?: Nullable<string>,\n data?: Nullable<Record<string, any>>,\n customMethod?: Nullable<string>,\n ): boolean {\n return this.submit(url, data, 'GET', customMethod);\n }\n\n /**\n * Post form.\n */\n post(\n url?: Nullable<string>,\n data?: Nullable<Record<string, any>>,\n customMethod?: Nullable<string>,\n ) {\n customMethod = customMethod || 'POST';\n\n return this.submit(url, data, 'POST', customMethod);\n }\n\n /**\n * Make a PUT request.\n */\n put(\n url?: Nullable<string>,\n data?: Nullable<Record<string, any>>,\n ) {\n return this.post(url, data, 'PUT');\n }\n\n /**\n * Make a PATCH request.\n */\n patch(\n url?: Nullable<string>,\n data?: Nullable<Record<string, any>>,\n ) {\n return this.post(url, data, 'PATCH');\n }\n\n /**\n * Make a DELETE request.\n */\n delete(\n url?: Nullable<string>,\n data?: Nullable<Record<string, any>>,\n ) {\n return this.post(url, data, 'DELETE');\n }\n\n destroy() {\n if (this.element) {\n this.element.remove();\n this.element = undefined;\n }\n }\n\n /**\n * @see https://stackoverflow.com/a/53739792\n *\n * @param {Object} ob\n * @returns {Object}\n */\n static flattenObject(ob: Record<string, any>): Record<string, any> {\n const toReturn: Record<string, any> = {};\n\n for (let i in ob) {\n if (!ob.hasOwnProperty(i)) {\n continue;\n }\n\n if ((typeof ob[i]) === 'object' && ob[i] != null) {\n const flatObject = this.flattenObject(ob[i]);\n\n for (let x in flatObject) {\n if (!flatObject.hasOwnProperty(x)) {\n continue;\n }\n\n toReturn[i + '/' + x] = flatObject[x];\n }\n } else {\n toReturn[i] = ob[i];\n }\n }\n return toReturn;\n }\n\n static buildFieldName(field: string) {\n const names = field.split('/');\n\n const first = names.shift();\n\n return first + names.map(name => `[${name}]`).join('');\n }\n}\n"],"names":["data"],"mappings":";AAIO,MAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EAEA,YACE,UACA,SACA,UAA+B,CAAA,GAC/B;AAEA,QAAI,CAAC,SAAS;AACZ,gBAAU,SAAS,cAAc,MAAM;AAEvC,UAAI,OAAO,aAAa,YAAY,SAAS,WAAW,GAAG,GAAG;AAC5D,gBAAQ,aAAa,MAAM,SAAS,UAAU,CAAC,CAAC;AAChD,gBAAQ,aAAa,QAAQ,SAAS,UAAU,CAAC,CAAC;AAAA,MACpD;AAEA,cAAQ,aAAa,UAAU,MAAM;AAC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Q;AAAA,EACtC;AAAA,EAEA,UAAU;AACR,QAAI,KAAK,SAAS;AAChB,WAAK,QAAQ,OAAA;AACb,WAAK,UAAU;AAAA,IACjB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,cAAc,IAA8C;AACjE,UAAM,WAAgC,CAAA;AAEtC,aAAS,KAAK,IAAI;AAChB,UAAI,CAAC,GAAG,eAAe,CAAC,GAAG;AACzB;AAAA,MACF;AAEA,UAAK,OAAO,GAAG,CAAC,MAAO,YAAY,GAAG,CAAC,KAAK,MAAM;AAChD,cAAM,aAAa,KAAK,cAAc,GAAG,CAAC,CAAC;AAE3C,iBAAS,KAAK,YAAY;AACxB,cAAI,CAAC,WAAW,eAAe,CAAC,GAAG;AACjC;AAAA,UACF;AAEA,mBAAS,IAAI,MAAM,CAAC,IAAI,WAAW,CAAC;AAAA,QACtC;AAAA,MACF,OAAO;AACL,iBAAS,CAAC,IAAI,GAAG,CAAC;AAAA,MACpB;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,eAAe,OAAe;AACnC,UAAM,QAAQ,MAAM,MAAM,GAAG;AAE7B,UAAM,QAAQ,MAAM,MAAA;AAEpB,WAAO,QAAQ,MAAM,IAAI,CAAA,SAAQ,IAAI,IAAI,GAAG,EAAE,KAAK,EAAE;AAAA,EACvD;AACF;"}
|
package/dist/chunks/keep-tab.js
CHANGED
|
@@ -57,6 +57,9 @@ class KeepTab {
|
|
|
57
57
|
activateTab(href) {
|
|
58
58
|
const tabTrigger = this.findTabButtonByHref(href);
|
|
59
59
|
if (tabTrigger) {
|
|
60
|
+
if (tabTrigger?.getAttribute("disabled") != null || tabTrigger.classList.contains("disabled")) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
60
63
|
Tab.getOrCreateInstance(tabTrigger).show();
|
|
61
64
|
}
|
|
62
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keep-tab.js","sources":["../../src/bootstrap/keep-tab.ts"],"sourcesContent":["import { useUniDirective } from '../composable';\nimport { module, selectAll, selectOne, sleep } from '../service';\nimport { Tab } from 'bootstrap';\nimport { mergeDeep } from '../utilities';\n\nexport interface KeepTabOptions {\n uid?: string;\n delay?: number;\n tabItemSelector?: string;\n}\n\nconst defaultOptions = {\n tabItemSelector: '[data-toggle=tab],[data-bs-toggle=tab],[data-toggle=pill],[data-bs-toggle=pill]',\n delay: 0,\n};\n\nexport class KeepTab {\n $element: HTMLElement;\n tabButtons!: NodeListOf<HTMLElement>;\n storageKey: string = '';\n options: any;\n\n constructor(selector: HTMLElement | string, options: KeepTabOptions = {}) {\n options = mergeDeep({}, defaultOptions, options);\n let uid: string;\n\n if (typeof selector === 'object') {\n uid = options.uid || selector.id;\n } else {\n uid = selector;\n }\n\n const $element = this.$element = selectOne<HTMLElement>(selector)!;\n\n if (!$element) {\n console.warn(`[KeepTab] Element ${selector} not found.`);\n return;\n }\n\n this.options = options;\n\n this.$element = $element;\n this.tabButtons = $element.querySelectorAll(this.options.tabItemSelector);\n\n this.init(uid);\n }\n\n protected async init(uid: string) {\n this.storageKey = 'tab-href-' + await this.hashCode(location.href + ':' + uid);\n\n this.bindEvents();\n\n await sleep(this.options.delay || 0);\n\n this.switchTab();\n }\n\n bindEvents() {\n [].forEach.call(this.tabButtons, (button: HTMLAnchorElement) => {\n button.addEventListener('click', () => {\n // Store the selected tab href in localstorage\n window.localStorage.setItem(this.storageKey, this.getButtonHref(button));\n });\n });\n }\n\n getButtonHref(button: HTMLAnchorElement) {\n return button.dataset.bsTarget || button.dataset.target || button.href;\n }\n\n findTabButtonByHref(href: string) {\n return selectAll<HTMLAnchorElement>(this.options.tabItemSelector)\n .filter((button: HTMLAnchorElement) => {\n if (button.href === href) {\n return true;\n }\n\n if (button.dataset.bsTarget === href) {\n return true;\n }\n\n return button.dataset.target === href;\n })\n .shift();\n }\n\n activateTab(href: string) {\n const tabTrigger = this.findTabButtonByHref(href);\n\n if (tabTrigger) {\n Tab.getOrCreateInstance(tabTrigger).show();\n }\n }\n\n hasTab(href: string) {\n return this.findTabButtonByHref(href) != null;\n }\n\n /**\n * Switch tab.\n *\n * @returns {boolean}\n */\n switchTab() {\n if (localStorage.getItem(this.storageKey)) {\n // When moving from tab area to a different view\n if (!this.hasTab(localStorage.getItem(this.storageKey) || '')) {\n localStorage.removeItem(this.storageKey);\n return true;\n }\n\n // Clean default tabs\n // selectOne(this.$element, '[data-toggle=\"tab\"], [data-bs-toggle=tab]')\n // this.$element.querySelector('a[data-toggle=\"tab\"]').parent().removeClass('active');\n\n const tabhref = localStorage.getItem(this.storageKey) || '';\n\n // Add active attribute for selected tab indicated by url\n this.activateTab(tabhref);\n\n // Check whether internal tab is selected (in format <tabname>-<id>)\n // const seperatorIndex = tabhref.indexOf('-');\n //\n // if (seperatorIndex !== -1) {\n // const singular = tabhref.substring(0, seperatorIndex);\n // const plural = singular + 's';\n //\n // this.activateTab(plural);\n // }\n }\n }\n\n /**\n * Hash code.\n */\n async hashCode(text: string): Promise<string> {\n const msgBuffer = new TextEncoder().encode(text);\n const hashBuffer = await globalThis.crypto.subtle.digest(\"SHA-256\", msgBuffer);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n return hashArray.map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n }\n}\n\nexport const ready = useUniDirective('keeptab', {\n mounted(el, { value }) {\n const options: KeepTabOptions = JSON.parse(value || '{}');\n\n module(el, 'uni.keeptab', () => new KeepTab(el, options));\n }\n});\n\nexport interface KeepTabModule {\n KeepTab: typeof KeepTab;\n ready: typeof ready;\n}\n"],"names":["module"],"mappings":";;AAWA,MAAM,iBAAiB;AAAA,EACrB,iBAAiB;AAAA,EACjB,OAAO;AACT;AAEO,MAAM,QAAQ;AAAA,EACnB;AAAA,EACA;AAAA,EACA,aAAqB;AAAA,EACrB;AAAA,EAEA,YAAY,UAAgC,UAA0B,IAAI;AACxE,cAAU,UAAU,IAAI,gBAAgB,OAAO;AA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AoB,UAAU,EAAE,KAAA;AAAA,IACtC;AAAA,EACF;AAAA,EAEA,OAAO,MAAc;AACnB,WAAO,KAAK,oBAAoB,IAAI,KAAK;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAY;AACV,QAAI,aAAa,QAAQ,KAAK,UAAU,GAAG;AAEzC,UAAI,CAAC,KAAK,OAAO,aAAa,QAAQ,KAAK,UAAU,KAAK,EAAE,GAAG;AAC7D,qBAAa,WAAW,KAAK,UAAU;AACvC,eAAO;AAAA,MACT;AAMA,YAAM,UAAU,aAAa,QAAQ,KAAK,UAAU,KAAK;AAGzD,WAAK,YAAY,OAAO;AAAA,IAW1B;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,SAAS,MAA+B;AAC5C,UAAM,YAAY,IAAI,cAAc,OAAO,IAAI;AAC/C,UAAM,aAAa,MAAM,WAAW,OAAO,OAAO,OAAO,WAAW,SAAS;AAC7E,UAAM,YAAY,MAAM,KAAK,IAAI,WAAW,UAAU,CAAC;AACvD,WAAO,UAAU,IAAI,CAAA,MAAK,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AAAA,EACpE;AACF;AAEO,MAAM,QAAQ,gCAAgB,WAAW;AAAA,EAC9C,QAAQ,IAAI,EAAE,SAAS;AACrB,UAAM,UAA0B,KAAK,MAAM,SAAS,IAAI;AAExDA,aAAO,IAAI,eAAe,MAAM,IAAI,QAAQ,IAAI,OAAO,CAAC;AAAA,EAC1D;AACF,CAAC;"}
|
|
1
|
+
{"version":3,"file":"keep-tab.js","sources":["../../src/bootstrap/keep-tab.ts"],"sourcesContent":["import { useUniDirective } from '../composable';\nimport { module, selectAll, selectOne, sleep } from '../service';\nimport { Tab } from 'bootstrap';\nimport { mergeDeep } from '../utilities';\n\nexport interface KeepTabOptions {\n uid?: string;\n delay?: number;\n tabItemSelector?: string;\n}\n\nconst defaultOptions = {\n tabItemSelector: '[data-toggle=tab],[data-bs-toggle=tab],[data-toggle=pill],[data-bs-toggle=pill]',\n delay: 0,\n};\n\nexport class KeepTab {\n $element: HTMLElement;\n tabButtons!: NodeListOf<HTMLElement>;\n storageKey: string = '';\n options: any;\n\n constructor(selector: HTMLElement | string, options: KeepTabOptions = {}) {\n options = mergeDeep({}, defaultOptions, options);\n let uid: string;\n\n if (typeof selector === 'object') {\n uid = options.uid || selector.id;\n } else {\n uid = selector;\n }\n\n const $element = this.$element = selectOne<HTMLElement>(selector)!;\n\n if (!$element) {\n console.warn(`[KeepTab] Element ${selector} not found.`);\n return;\n }\n\n this.options = options;\n\n this.$element = $element;\n this.tabButtons = $element.querySelectorAll(this.options.tabItemSelector);\n\n this.init(uid);\n }\n\n protected async init(uid: string) {\n this.storageKey = 'tab-href-' + await this.hashCode(location.href + ':' + uid);\n\n this.bindEvents();\n\n await sleep(this.options.delay || 0);\n\n this.switchTab();\n }\n\n bindEvents() {\n [].forEach.call(this.tabButtons, (button: HTMLAnchorElement) => {\n button.addEventListener('click', () => {\n // Store the selected tab href in localstorage\n window.localStorage.setItem(this.storageKey, this.getButtonHref(button));\n });\n });\n }\n\n getButtonHref(button: HTMLAnchorElement) {\n return button.dataset.bsTarget || button.dataset.target || button.href;\n }\n\n findTabButtonByHref(href: string) {\n return selectAll<HTMLAnchorElement>(this.options.tabItemSelector)\n .filter((button: HTMLAnchorElement) => {\n if (button.href === href) {\n return true;\n }\n\n if (button.dataset.bsTarget === href) {\n return true;\n }\n\n return button.dataset.target === href;\n })\n .shift();\n }\n\n activateTab(href: string) {\n const tabTrigger = this.findTabButtonByHref(href);\n\n if (tabTrigger) {\n if (tabTrigger?.getAttribute('disabled') != null || tabTrigger.classList.contains('disabled')) {\n return;\n }\n\n Tab.getOrCreateInstance(tabTrigger).show();\n }\n }\n\n hasTab(href: string) {\n return this.findTabButtonByHref(href) != null;\n }\n\n /**\n * Switch tab.\n *\n * @returns {boolean}\n */\n switchTab() {\n if (localStorage.getItem(this.storageKey)) {\n // When moving from tab area to a different view\n if (!this.hasTab(localStorage.getItem(this.storageKey) || '')) {\n localStorage.removeItem(this.storageKey);\n return true;\n }\n\n // Clean default tabs\n // selectOne(this.$element, '[data-toggle=\"tab\"], [data-bs-toggle=tab]')\n // this.$element.querySelector('a[data-toggle=\"tab\"]').parent().removeClass('active');\n\n const tabhref = localStorage.getItem(this.storageKey) || '';\n\n // Add active attribute for selected tab indicated by url\n this.activateTab(tabhref);\n\n // Check whether internal tab is selected (in format <tabname>-<id>)\n // const seperatorIndex = tabhref.indexOf('-');\n //\n // if (seperatorIndex !== -1) {\n // const singular = tabhref.substring(0, seperatorIndex);\n // const plural = singular + 's';\n //\n // this.activateTab(plural);\n // }\n }\n }\n\n /**\n * Hash code.\n */\n async hashCode(text: string): Promise<string> {\n const msgBuffer = new TextEncoder().encode(text);\n const hashBuffer = await globalThis.crypto.subtle.digest(\"SHA-256\", msgBuffer);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n return hashArray.map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n }\n}\n\nexport const ready = useUniDirective('keeptab', {\n mounted(el, { value }) {\n const options: KeepTabOptions = JSON.parse(value || '{}');\n\n module(el, 'uni.keeptab', () => new KeepTab(el, options));\n }\n});\n\nexport interface KeepTabModule {\n KeepTab: typeof KeepTab;\n ready: typeof ready;\n}\n"],"names":["module"],"mappings":";;AAWA,MAAM,iBAAiB;AAAA,EACrB,iBAAiB;AAAA,EACjB,OAAO;AACT;AAEO,MAAM,QAAQ;AAAA,EACnB;AAAA,EACA;AAAA,EACA,aAAqB;AAAA,EACrB;AAAA,EAEA,YAAY,UAAgC,UAA0B,IAAI;AACxE,cAAU,UAAU,IAAI,gBAAgB,OAAO;AAC/C,QAAI;AAEJ,QAAI,OAAO,aAAa,UAAU;AAChC,YAAM,QAAQ,OAAO,SAAS;AAAA,IAChC,OAAO;AACL,YAAM;AAAA,IACR;AAEA,UAAM,WAAW,KAAK,WAAW,UAAuB,QAAQ;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