@windwalker-io/unicorn-next 0.1.18 → 0.1.21
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/_arrayPush.js +325 -108
- package/dist/chunks/_arrayPush.js.map +1 -1
- package/dist/chunks/_baseRest.js +155 -60
- package/dist/chunks/_baseRest.js.map +1 -1
- package/dist/chunks/_baseUnary.js +463 -0
- package/dist/chunks/_baseUnary.js.map +1 -0
- package/dist/chunks/_getPrototype.js +292 -100
- package/dist/chunks/_getPrototype.js.map +1 -1
- package/dist/chunks/alert-adapter.js +29 -0
- package/dist/chunks/alert-adapter.js.map +1 -0
- package/dist/chunks/alert.js +21 -0
- package/dist/chunks/alert.js.map +1 -0
- package/dist/chunks/arr.js +24 -0
- package/dist/chunks/arr.js.map +1 -0
- package/dist/chunks/button-radio.js +127 -145
- package/dist/chunks/button-radio.js.map +1 -1
- package/dist/chunks/checkboxes-multi-select.js +44 -43
- package/dist/chunks/checkboxes-multi-select.js.map +1 -1
- package/dist/chunks/chunk.js +24 -0
- package/dist/chunks/cloneDeep.js +679 -212
- package/dist/chunks/cloneDeep.js.map +1 -1
- package/dist/chunks/cropper.min.js +6 -5
- package/dist/chunks/cropper.min.js.map +1 -1
- package/dist/chunks/crypto.js +26 -0
- package/dist/chunks/crypto.js.map +1 -0
- package/dist/chunks/data.js +49 -0
- package/dist/chunks/data.js.map +1 -0
- package/dist/chunks/dom.js +128 -0
- package/dist/chunks/dom.js.map +1 -0
- package/dist/chunks/events.js +270 -0
- package/dist/chunks/events.js.map +1 -0
- package/dist/chunks/field-cascade-select.js +207 -250
- package/dist/chunks/field-cascade-select.js.map +1 -1
- package/dist/chunks/field-file-drag.js +175 -209
- package/dist/chunks/field-file-drag.js.map +1 -1
- package/dist/chunks/field-flatpickr.js +94 -898
- package/dist/chunks/field-flatpickr.js.map +1 -1
- package/dist/chunks/field-modal-select.js +728 -467
- package/dist/chunks/field-modal-select.js.map +1 -1
- package/dist/chunks/field-modal-tree.js +771 -766
- package/dist/chunks/field-modal-tree.js.map +1 -1
- package/dist/chunks/field-multi-uploader.js +249 -256
- package/dist/chunks/field-multi-uploader.js.map +1 -1
- package/dist/chunks/field-repeatable.js +111 -127
- package/dist/chunks/field-repeatable.js.map +1 -1
- package/dist/chunks/field-single-image-drag.js +286 -338
- package/dist/chunks/field-single-image-drag.js.map +1 -1
- package/dist/chunks/form.js +146 -159
- package/dist/chunks/form.js.map +1 -1
- package/dist/chunks/grid.js +349 -418
- package/dist/chunks/grid.js.map +1 -1
- package/dist/chunks/helper.js +39 -0
- package/dist/chunks/helper.js.map +1 -0
- package/dist/chunks/http-client.js +221 -211
- package/dist/chunks/http-client.js.map +1 -1
- package/dist/chunks/iframe-modal.js +95 -115
- package/dist/chunks/iframe-modal.js.map +1 -1
- package/dist/chunks/keep-tab.js +92 -101
- package/dist/chunks/keep-tab.js.map +1 -1
- package/dist/chunks/lang.js +250 -0
- package/dist/chunks/lang.js.map +1 -0
- package/dist/chunks/legacy.js +197 -201
- package/dist/chunks/legacy.js.map +1 -1
- package/dist/chunks/list-dependent.js +195 -228
- package/dist/chunks/list-dependent.js.map +1 -1
- package/dist/chunks/loader.js +106 -0
- package/dist/chunks/loader.js.map +1 -0
- package/dist/chunks/monthSelect.js +251 -0
- package/dist/chunks/monthSelect.js.map +1 -0
- package/dist/chunks/router.js +111 -0
- package/dist/chunks/router.js.map +1 -0
- package/dist/chunks/s3-multipart-uploader.js +183 -210
- package/dist/chunks/s3-multipart-uploader.js.map +1 -1
- package/dist/chunks/s3-uploader.js +106 -128
- package/dist/chunks/s3-uploader.js.map +1 -1
- package/dist/chunks/show-on.js +358 -205
- package/dist/chunks/show-on.js.map +1 -1
- package/dist/chunks/timing.js +10 -0
- package/dist/chunks/timing.js.map +1 -0
- package/dist/chunks/tinymce.js +153 -203
- package/dist/chunks/tinymce.js.map +1 -1
- package/dist/chunks/ui-bootstrap5.js +58 -72
- package/dist/chunks/ui-bootstrap5.js.map +1 -1
- package/dist/chunks/ui.js +320 -0
- package/dist/chunks/ui.js.map +1 -0
- package/dist/chunks/unicorn.js.map +1 -1
- package/dist/chunks/useQueue.js +111 -0
- package/dist/chunks/useQueue.js.map +1 -0
- package/dist/chunks/useStack.js +76 -0
- package/dist/chunks/useStack.js.map +1 -0
- package/dist/chunks/validation.js +761 -853
- package/dist/chunks/validation.js.map +1 -1
- package/dist/editor.css +1 -1
- package/dist/index.d.ts +27 -15
- package/dist/multi-level-menu.css +1 -1
- package/dist/switcher.css +1 -1
- package/dist/unicorn.js +805 -130
- package/dist/unicorn.js.map +1 -1
- package/package.json +3 -3
- package/src/composable/useBsModalAlert.ts +92 -12
- package/src/composable/useHttp.ts +13 -1
- package/src/module/s3-uploader.ts +1 -1
- package/src/service/ui.ts +31 -15
- package/vite.config.ts +5 -1
- package/dist/chunks/_commonjsHelpers.js +0 -7
- package/dist/chunks/index.js +0 -314
- package/dist/chunks/isArguments.js +0 -146
- package/dist/chunks/unicorn.js +0 -2580
package/dist/unicorn.js
CHANGED
|
@@ -1,131 +1,806 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
a7 as trans,
|
|
70
|
-
K as uid,
|
|
71
|
-
aI as useAlertAdapter,
|
|
72
|
-
q as useAssetUri,
|
|
73
|
-
a0 as useBs5ButtonRadio,
|
|
74
|
-
$ as useBs5KeepTab,
|
|
75
|
-
a1 as useBs5Tooltip,
|
|
76
|
-
aJ as useBsModalAlert,
|
|
77
|
-
Y as useCheckboxesMultiSelect,
|
|
78
|
-
V as useColorPicker,
|
|
79
|
-
ad as useCssImport,
|
|
80
|
-
aK as useCssIncludes,
|
|
81
|
-
X as useDisableIfStackNotEmpty,
|
|
82
|
-
W as useDisableOnSubmit,
|
|
83
|
-
aL as useFieldCascadeSelect,
|
|
84
|
-
aM as useFieldFileDrag,
|
|
85
|
-
aN as useFieldFlatpickr,
|
|
86
|
-
aO as useFieldModalSelect,
|
|
87
|
-
aP as useFieldModalTree,
|
|
88
|
-
aQ as useFieldRepeatable,
|
|
89
|
-
aR as useFieldSingleImageDrag,
|
|
90
|
-
j as useFieldValidationInstance,
|
|
91
|
-
a4 as useForm,
|
|
92
|
-
a2 as useFormAsync,
|
|
93
|
-
aS as useFormComponent,
|
|
94
|
-
aT as useFormSubmit,
|
|
95
|
-
g as useFormValidation,
|
|
96
|
-
k as useFormValidationInstance,
|
|
97
|
-
a5 as useGrid,
|
|
98
|
-
a3 as useGridAsync,
|
|
99
|
-
aU as useGridComponent,
|
|
100
|
-
u as useHttpClient,
|
|
101
|
-
aV as useIframeModal,
|
|
102
|
-
ac as useImport,
|
|
103
|
-
aW as useInject,
|
|
104
|
-
Z as useKeepAlive,
|
|
105
|
-
aX as useLang,
|
|
106
|
-
aY as useLegacy,
|
|
107
|
-
aZ as useListDependent,
|
|
108
|
-
a_ as useMacro,
|
|
109
|
-
n as useQueue,
|
|
110
|
-
a$ as useS3MultipartUploader,
|
|
111
|
-
b0 as useS3Uploader,
|
|
112
|
-
ak as useScriptImport,
|
|
113
|
-
b1 as useSeriesImport,
|
|
114
|
-
b2 as useShowOn,
|
|
115
|
-
m as useStack,
|
|
116
|
-
o as useSystemUri,
|
|
117
|
-
b3 as useTinymce,
|
|
118
|
-
b4 as useTinymceHook,
|
|
119
|
-
O as useTomSelect,
|
|
120
|
-
b5 as useUI,
|
|
121
|
-
b6 as useUIBootstrap5,
|
|
122
|
-
a8 as useUITheme,
|
|
123
|
-
a as useUniDirective,
|
|
124
|
-
b7 as useUnicorn,
|
|
125
|
-
b8 as useUnicornPhpAdapter,
|
|
126
|
-
b9 as useVueComponentField,
|
|
127
|
-
ba as useWebDirective,
|
|
128
|
-
bb as wait,
|
|
129
|
-
aa as watchAttributes
|
|
1
|
+
import { n as Mixin, t as EventMixin } from "./chunks/events.js";
|
|
2
|
+
import { t as mergeDeep } from "./chunks/arr.js";
|
|
3
|
+
import { n as removeData, t as data } from "./chunks/data.js";
|
|
4
|
+
import { a as h, c as module, d as selectOne, i as getBoundedInstanceList, l as removeBoundedInstance, n as domready, o as html, r as getBoundedInstance, s as injectCssToDocument, t as delegate, u as selectAll } from "./chunks/dom.js";
|
|
5
|
+
import { C as promiseWithResolvers, S as useVueComponentField, _ as useDisableIfStackNotEmpty, a as highlight, b as useUI, c as mark, d as renderMessage, f as slideDown, g as useColorPicker, h as useAlertAdapter, i as fadeOut, l as prepareAlpine, m as slideUp, n as clearMessages, o as initAlpineComponent, p as slideToggle, r as fadeIn, s as loadAlpine, t as UnicornUI, u as prepareAlpineDefer, v as useDisableOnSubmit, w as animateTo, x as useUITheme, y as useKeepAlive } from "./chunks/ui.js";
|
|
6
|
+
import { a as simpleNotify, i as simpleConfirm, n as deleteConfirm, r as simpleAlert, t as clearNotifies } from "./chunks/alert.js";
|
|
7
|
+
import { i as uid, n as randomBytesString, r as tid, t as randomBytes } from "./chunks/crypto.js";
|
|
8
|
+
import { n as useQueue, t as createQueue } from "./chunks/useQueue.js";
|
|
9
|
+
import { n as useStack, t as createStack } from "./chunks/useStack.js";
|
|
10
|
+
import { t as sleep } from "./chunks/timing.js";
|
|
11
|
+
import { a as nextTick, i as isError, n as forceArray, o as throttle, r as isDebug, s as wait, t as debounce } from "./chunks/helper.js";
|
|
12
|
+
import { n as trans, r as useLang, t as __ } from "./chunks/lang.js";
|
|
13
|
+
import { a as useScriptImport, i as useImport, n as useCssImport, o as useSeriesImport, r as useCssIncludes, t as doImport } from "./chunks/loader.js";
|
|
14
|
+
import { a as parseQuery, i as hasRoute, n as addRoute, o as route, r as buildQuery, t as addQuery } from "./chunks/router.js";
|
|
15
|
+
import { Modal } from "bootstrap";
|
|
16
|
+
//#region src/service/crypto.ts
|
|
17
|
+
function base64UrlEncode(string) {
|
|
18
|
+
return btoa(String(string)).replace(/\+/, "-").replace(/* @__PURE__ */ new RegExp("\\/"), "_").replace(/=+$/, "");
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Base64 URL decode
|
|
22
|
+
*/
|
|
23
|
+
function base64UrlDecode(string) {
|
|
24
|
+
return atob(String(string).replace(/-/, "+").replace(/_/, "/"));
|
|
25
|
+
}
|
|
26
|
+
var globalSerial = 1;
|
|
27
|
+
function serial() {
|
|
28
|
+
return globalSerial++;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/service/dom-watcher.ts
|
|
32
|
+
function watchAttributes(el, callback) {
|
|
33
|
+
return new AttributeMutationObserver(el, callback);
|
|
34
|
+
}
|
|
35
|
+
var AttributeMutationObserver = class {
|
|
36
|
+
observer;
|
|
37
|
+
watches = {};
|
|
38
|
+
constructor(element, callback) {
|
|
39
|
+
this.element = element;
|
|
40
|
+
this.callback = callback;
|
|
41
|
+
this.element = element;
|
|
42
|
+
this.observer = new MutationObserver((mutations) => {
|
|
43
|
+
for (const mutation of mutations) if (mutation.type === "attributes") {
|
|
44
|
+
const attrName = mutation.attributeName;
|
|
45
|
+
const target = mutation.target;
|
|
46
|
+
const value = target.getAttribute(attrName);
|
|
47
|
+
this.callback?.(target, attrName, value, mutation.oldValue);
|
|
48
|
+
if (this.watches[attrName]) for (const watch of this.watches[attrName]) watch(target, value, mutation.oldValue);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
this.observe();
|
|
52
|
+
}
|
|
53
|
+
watch(name, callback) {
|
|
54
|
+
this.watches[name] ??= [];
|
|
55
|
+
this.watches[name].push(callback);
|
|
56
|
+
return () => {
|
|
57
|
+
this.watches[name] = this.watches[name].filter((fn) => fn !== callback);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
observe() {
|
|
61
|
+
this.observer.observe(this.element, {
|
|
62
|
+
attributes: true,
|
|
63
|
+
attributeOldValue: true
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
disconnect() {
|
|
67
|
+
this.observer.disconnect();
|
|
68
|
+
}
|
|
130
69
|
};
|
|
131
|
-
//#
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/composable/useUIBootstrap5.ts
|
|
72
|
+
async function useUIBootstrap5(install = false, pushToGlobal = false) {
|
|
73
|
+
const { UIBootstrap5 } = await import("./chunks/ui-bootstrap5.js");
|
|
74
|
+
const theme = UIBootstrap5.get();
|
|
75
|
+
if (install) {
|
|
76
|
+
useUITheme(theme);
|
|
77
|
+
if (pushToGlobal) theme.pushBootstrapToGlobal();
|
|
78
|
+
}
|
|
79
|
+
return theme;
|
|
80
|
+
}
|
|
81
|
+
async function useBs5Tooltip(selector = "[data-bs-toggle=\"tooltip\"]", config = {}) {
|
|
82
|
+
return (await useUIBootstrap5()).tooltip(selector, config);
|
|
83
|
+
}
|
|
84
|
+
var useBs5KeepTab = async (selector, options = {}) => {
|
|
85
|
+
return (await useUIBootstrap5()).keepTab(selector, options);
|
|
86
|
+
};
|
|
87
|
+
var useBs5ButtonRadio = async (selector, options = {}) => {
|
|
88
|
+
return (await useUIBootstrap5()).buttonRadio(selector, options);
|
|
89
|
+
};
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/composable/useBsModalAlert.ts
|
|
92
|
+
var currentOpenedModals = {};
|
|
93
|
+
var defaultOptions = { buttons: ["OK"] };
|
|
94
|
+
async function useBsModalAlert(id, options) {
|
|
95
|
+
await useUIBootstrap5();
|
|
96
|
+
let modalElement = void 0;
|
|
97
|
+
if (typeof id !== "string" && !(id instanceof HTMLElement)) {
|
|
98
|
+
options = id;
|
|
99
|
+
id = "uni-modal-alert";
|
|
100
|
+
modalElement = document.getElementById(id);
|
|
101
|
+
} else modalElement = typeof id === "string" ? document.getElementById(id) : id;
|
|
102
|
+
if (!modalElement) {
|
|
103
|
+
modalElement = html(`<div id="${id}" class="uni-modal-alert modal fade" tabindex="-1" role="dialog">
|
|
104
|
+
<div class="modal-dialog modal-dialog-centered" role="document">
|
|
105
|
+
<div class="modal-content">
|
|
106
|
+
<div class="modal-body text-center p-4"></div>
|
|
107
|
+
<div class="modal-footer"></div>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
</div>`);
|
|
111
|
+
document.body.appendChild(modalElement);
|
|
112
|
+
}
|
|
113
|
+
const bsModal = Modal.getOrCreateInstance(modalElement, options);
|
|
114
|
+
modalElement.addEventListener("show.bs.modal", () => {
|
|
115
|
+
currentOpenedModals[modalElement.id] = instance;
|
|
116
|
+
});
|
|
117
|
+
modalElement.addEventListener("hidden.bs.modal", () => {
|
|
118
|
+
delete currentOpenedModals[modalElement.id];
|
|
119
|
+
});
|
|
120
|
+
const instance = {
|
|
121
|
+
show: async (title, text, icon, options) => {
|
|
122
|
+
if (typeof title === "string") {
|
|
123
|
+
options = options || {};
|
|
124
|
+
options.title = title;
|
|
125
|
+
options.text = text;
|
|
126
|
+
options.icon = icon;
|
|
127
|
+
} else options = title;
|
|
128
|
+
await closeCurrentOpened(modalElement);
|
|
129
|
+
return new Promise((resolve) => {
|
|
130
|
+
prepareModalElement(modalElement, resolve, options);
|
|
131
|
+
bsModal.show(options?.relatedTarget);
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
hide: () => {
|
|
135
|
+
bsModal.hide();
|
|
136
|
+
},
|
|
137
|
+
dispose: () => {
|
|
138
|
+
bsModal.dispose();
|
|
139
|
+
},
|
|
140
|
+
toggle: (relatedTarget) => {
|
|
141
|
+
bsModal.toggle(relatedTarget);
|
|
142
|
+
},
|
|
143
|
+
destroy: () => {
|
|
144
|
+
bsModal.dispose();
|
|
145
|
+
modalElement.remove();
|
|
146
|
+
},
|
|
147
|
+
instance: bsModal,
|
|
148
|
+
el: modalElement,
|
|
149
|
+
on: (event, handler) => {
|
|
150
|
+
modalElement.addEventListener(event, handler);
|
|
151
|
+
return () => {
|
|
152
|
+
modalElement.removeEventListener(event, handler);
|
|
153
|
+
};
|
|
154
|
+
},
|
|
155
|
+
off: (event, handler) => {
|
|
156
|
+
modalElement.removeEventListener(event, handler);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
return instance;
|
|
160
|
+
}
|
|
161
|
+
async function closeCurrentOpened(modalElement) {
|
|
162
|
+
return new Promise((resolve) => {
|
|
163
|
+
let currentOpenedModal = currentOpenedModals[modalElement.id];
|
|
164
|
+
if (!currentOpenedModal) {
|
|
165
|
+
resolve();
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
currentOpenedModal.el.addEventListener("hidden.bs.modal", () => {
|
|
169
|
+
resolve();
|
|
170
|
+
}, { once: true });
|
|
171
|
+
currentOpenedModal.hide();
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
async function prepareModalElement(modalElement, handler, options) {
|
|
175
|
+
options = Object.assign({}, defaultOptions, options || {});
|
|
176
|
+
let header = options.header;
|
|
177
|
+
const content = options.content;
|
|
178
|
+
modalElement.querySelector(".modal-header")?.remove();
|
|
179
|
+
modalElement.querySelector(".modal-body").innerHTML = "";
|
|
180
|
+
modalElement.querySelector(".modal-footer").innerHTML = "";
|
|
181
|
+
modalElement.querySelector(".modal-dialog")?.classList.remove("modal-sm", "modal-lg", "modal-xl", "modal-xxl");
|
|
182
|
+
if (header) {
|
|
183
|
+
if (typeof header === "string") header = `<div class="modal-header">
|
|
184
|
+
<h5 class="modal-title">${header}</h5>
|
|
185
|
+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
186
|
+
</div>`;
|
|
187
|
+
header = await anyToElement(header);
|
|
188
|
+
modalElement.querySelector(".modal-header")?.remove();
|
|
189
|
+
modalElement.querySelector(".modal-content").insertAdjacentElement("afterbegin", header);
|
|
190
|
+
}
|
|
191
|
+
if (content) {
|
|
192
|
+
let contentElement = await anyToElement(content);
|
|
193
|
+
modalElement.querySelector(".modal-body").appendChild(contentElement);
|
|
194
|
+
} else {
|
|
195
|
+
const title = options.title;
|
|
196
|
+
const text = options.text;
|
|
197
|
+
let icon = options.icon;
|
|
198
|
+
if (icon) {
|
|
199
|
+
if (typeof icon === "string") icon = `<div class="uni-modal-alert__icon text-center mb-3"><span class="${icon}" style="font-size: 64px;"></span></div>`;
|
|
200
|
+
icon = await anyToElement(icon);
|
|
201
|
+
modalElement.querySelector(".modal-body").appendChild(icon);
|
|
202
|
+
}
|
|
203
|
+
if (title) {
|
|
204
|
+
const titleEl = html(`<h4 class="uni-modal-alert__title">${title}</h4>`);
|
|
205
|
+
modalElement.querySelector(".modal-body").appendChild(titleEl);
|
|
206
|
+
}
|
|
207
|
+
if (text) {
|
|
208
|
+
const textEl = html(`<div class="uni-modal-alert__text">${text}</div>`);
|
|
209
|
+
modalElement.querySelector(".modal-body").appendChild(textEl);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
const buttons = options.buttons;
|
|
213
|
+
const { resolve: resolveClosed, promise: valueSelected } = promiseWithResolvers();
|
|
214
|
+
for (const i in buttons) {
|
|
215
|
+
const button = buttons[i];
|
|
216
|
+
const buttonElement = createButton(button, handler, buttons.length === 1 || buttons.length === 2 && Number(i) === 1);
|
|
217
|
+
modalElement.querySelector(".modal-footer").appendChild(await buttonElement);
|
|
218
|
+
}
|
|
219
|
+
if (options.size) modalElement.querySelector(".modal-dialog").classList.add(`modal-${options.size}`);
|
|
220
|
+
if (options.configure) modalElement = options.configure(modalElement) ?? modalElement;
|
|
221
|
+
let isUserDismiss = false;
|
|
222
|
+
let clickListener;
|
|
223
|
+
let keydownListener;
|
|
224
|
+
modalElement.addEventListener("click", clickListener = (e) => {
|
|
225
|
+
const target = e.target;
|
|
226
|
+
if (target.matches(".modal") && target.dataset.bsBackdrop !== "static") isUserDismiss = true;
|
|
227
|
+
}, { capture: true });
|
|
228
|
+
modalElement.addEventListener("keydown", keydownListener = (e) => {
|
|
229
|
+
if (e.key === "Escape") isUserDismiss = true;
|
|
230
|
+
}, { capture: true });
|
|
231
|
+
modalElement.addEventListener("hide.bs.modal", (e) => {
|
|
232
|
+
if (isUserDismiss) handler(void 0);
|
|
233
|
+
modalElement.removeEventListener("click", clickListener);
|
|
234
|
+
modalElement.removeEventListener("keydown", keydownListener);
|
|
235
|
+
}, { once: true });
|
|
236
|
+
return modalElement;
|
|
237
|
+
}
|
|
238
|
+
async function anyToElement(content) {
|
|
239
|
+
if (typeof content === "function") return content();
|
|
240
|
+
return typeof content === "string" ? html(content) : content;
|
|
241
|
+
}
|
|
242
|
+
async function createButton(buttonOption, handler, isConfirm) {
|
|
243
|
+
if (typeof buttonOption === "function") return await buttonOption();
|
|
244
|
+
if (typeof buttonOption === "string") buttonOption = {
|
|
245
|
+
text: buttonOption,
|
|
246
|
+
value: isConfirm ?? false,
|
|
247
|
+
class: isConfirm ? "btn btn-primary is-confirm" : "btn btn-outline-secondary",
|
|
248
|
+
styles: isConfirm ? { width: "150px" } : {},
|
|
249
|
+
dismiss: true
|
|
250
|
+
};
|
|
251
|
+
let button;
|
|
252
|
+
if (buttonOption instanceof HTMLElement) button = buttonOption;
|
|
253
|
+
else {
|
|
254
|
+
const { text, class: className = "btn btn-secondary", attrs = {}, styles = {}, dismiss = true, value, href, target, onClick } = buttonOption;
|
|
255
|
+
const tag = href ? "a" : "button";
|
|
256
|
+
const el = document.createElement(tag);
|
|
257
|
+
if (el instanceof HTMLAnchorElement) {
|
|
258
|
+
el.href = href;
|
|
259
|
+
el.target = target || "_self";
|
|
260
|
+
}
|
|
261
|
+
if (el instanceof HTMLButtonElement) el.type = "button";
|
|
262
|
+
el.setAttribute("class", className);
|
|
263
|
+
for (let attr in attrs) el.setAttribute(attr, attrs[attr]);
|
|
264
|
+
for (let style in styles) el.style[style] = styles[style];
|
|
265
|
+
if (dismiss) el.setAttribute("data-bs-dismiss", "modal");
|
|
266
|
+
if (typeof text === "string") el.textContent = text;
|
|
267
|
+
else if (typeof text === "function") text(el);
|
|
268
|
+
el.addEventListener("click", (e) => {
|
|
269
|
+
onClick?.(value, e);
|
|
270
|
+
handler(value);
|
|
271
|
+
});
|
|
272
|
+
button = el;
|
|
273
|
+
}
|
|
274
|
+
return button;
|
|
275
|
+
}
|
|
276
|
+
//#endregion
|
|
277
|
+
//#region src/composable/useCheckboxesMultiSelect.ts
|
|
278
|
+
async function useCheckboxesMultiSelect(selector, options = {}) {
|
|
279
|
+
const m = await import("./chunks/checkboxes-multi-select.js");
|
|
280
|
+
if (selector) m.CheckboxesMultiSelect.handle(selector, options);
|
|
281
|
+
return m;
|
|
282
|
+
}
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region src/composable/useFieldCascadeSelect.ts
|
|
285
|
+
async function useFieldCascadeSelect() {
|
|
286
|
+
const module = await import("./chunks/field-cascade-select.js");
|
|
287
|
+
await module.ready;
|
|
288
|
+
return module;
|
|
289
|
+
}
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/composable/useFieldFileDrag.ts
|
|
292
|
+
async function useFieldFileDrag() {
|
|
293
|
+
const module = await import("./chunks/field-file-drag.js");
|
|
294
|
+
await module.ready;
|
|
295
|
+
return module;
|
|
296
|
+
}
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region src/composable/useFieldFlatpickr.ts
|
|
299
|
+
function useFieldFlatpickr() {
|
|
300
|
+
return import("./chunks/field-flatpickr.js");
|
|
301
|
+
}
|
|
302
|
+
//#endregion
|
|
303
|
+
//#region src/composable/useFieldModalSelect.ts
|
|
304
|
+
function useFieldModalSelect() {
|
|
305
|
+
return import("./chunks/field-modal-select.js");
|
|
306
|
+
}
|
|
307
|
+
//#endregion
|
|
308
|
+
//#region src/composable/useFieldModalTree.ts
|
|
309
|
+
function useFieldModalTree() {
|
|
310
|
+
return import("./chunks/field-modal-tree.js");
|
|
311
|
+
}
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region src/composable/useFieldRepeatable.ts
|
|
314
|
+
async function useFieldRepeatable() {
|
|
315
|
+
const module = await import("./chunks/field-repeatable.js");
|
|
316
|
+
await module.ready;
|
|
317
|
+
return module;
|
|
318
|
+
}
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region src/composable/useFieldSingleImageDrag.ts
|
|
321
|
+
async function useFieldSingleImageDrag() {
|
|
322
|
+
const module = await import("./chunks/field-single-image-drag.js");
|
|
323
|
+
await module.ready;
|
|
324
|
+
return module;
|
|
325
|
+
}
|
|
326
|
+
//#endregion
|
|
327
|
+
//#region src/composable/useForm.ts
|
|
328
|
+
var formElement;
|
|
329
|
+
function useFormAsync(ele, options = {}) {
|
|
330
|
+
const promise = import("./chunks/form.js").then(({ UnicornFormElement }) => {
|
|
331
|
+
formElement ??= UnicornFormElement;
|
|
332
|
+
return useForm(ele, options);
|
|
333
|
+
});
|
|
334
|
+
return new Proxy({}, { get(target, prop) {
|
|
335
|
+
return (...args) => {
|
|
336
|
+
if (prop === "then" || prop === "catch") return promise[prop].apply(promise, args);
|
|
337
|
+
return promise.then((form) => {
|
|
338
|
+
const p = form[prop];
|
|
339
|
+
if (typeof p === "function") return p.apply(form, args);
|
|
340
|
+
return p;
|
|
341
|
+
});
|
|
342
|
+
};
|
|
343
|
+
} });
|
|
344
|
+
}
|
|
345
|
+
function useForm(ele, options = {}) {
|
|
346
|
+
if (!formElement) throw new Error("Form module is not loaded. Please use useFormAsync() to load the module before using useForm().");
|
|
347
|
+
if (ele == null) return new formElement(void 0, void 0, options);
|
|
348
|
+
let selector = void 0;
|
|
349
|
+
let el = void 0;
|
|
350
|
+
if (typeof ele === "string") {
|
|
351
|
+
selector = ele;
|
|
352
|
+
el = selectOne(ele) ?? void 0;
|
|
353
|
+
} else el = ele;
|
|
354
|
+
if (!el) return new formElement(selector, el, options);
|
|
355
|
+
return module(el, "unicorn.form", () => new formElement(selector, el, options));
|
|
356
|
+
}
|
|
357
|
+
async function useFormComponent(ele, options = {}) {
|
|
358
|
+
const form = await useFormAsync(ele, options);
|
|
359
|
+
await form?.initComponent();
|
|
360
|
+
return form;
|
|
361
|
+
}
|
|
362
|
+
async function useFormSubmit(options = {}) {
|
|
363
|
+
return (await useFormAsync(options.form))[options.method?.toLowerCase() || "post"](options.url, options.data);
|
|
364
|
+
}
|
|
365
|
+
//#endregion
|
|
366
|
+
//#region src/composable/useGrid.ts
|
|
367
|
+
var gridElement;
|
|
368
|
+
async function useGridAsync(ele, options = {}) {
|
|
369
|
+
await useFormAsync();
|
|
370
|
+
const { UnicornGridElement } = await import("./chunks/grid.js");
|
|
371
|
+
gridElement ??= UnicornGridElement;
|
|
372
|
+
if (!ele) return null;
|
|
373
|
+
return useGrid(ele, options);
|
|
374
|
+
}
|
|
375
|
+
function useGrid(ele, options = {}) {
|
|
376
|
+
const selector = typeof ele === "string" ? ele : "";
|
|
377
|
+
const element = selectOne(ele);
|
|
378
|
+
if (!element) throw new Error("Element is empty");
|
|
379
|
+
const form = useForm(selector || element);
|
|
380
|
+
if (!form) throw new Error("UnicornGrid is depends on UnicornForm");
|
|
381
|
+
return module(element, "grid.plugin", () => new gridElement(selector, element, form, options));
|
|
382
|
+
}
|
|
383
|
+
async function useGridComponent(ele, options = {}) {
|
|
384
|
+
const grid = await useGridAsync(ele, options);
|
|
385
|
+
await grid?.initComponent();
|
|
386
|
+
return grid;
|
|
387
|
+
}
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/composable/useHttp.ts
|
|
390
|
+
function useHttpClient(config) {
|
|
391
|
+
const promise = import("./chunks/http-client.js").then(({ createHttpClient }) => {
|
|
392
|
+
return createHttpClient(config);
|
|
393
|
+
});
|
|
394
|
+
const data = {
|
|
395
|
+
request: (options) => {
|
|
396
|
+
return promise.then((client) => client.request(options));
|
|
397
|
+
},
|
|
398
|
+
get: (url, options) => {
|
|
399
|
+
return promise.then((client) => client.get(url, options));
|
|
400
|
+
},
|
|
401
|
+
post: (url, data, options) => {
|
|
402
|
+
return promise.then((client) => client.post(url, data, options));
|
|
403
|
+
},
|
|
404
|
+
put: (url, data, options) => {
|
|
405
|
+
return promise.then((client) => client.put(url, data, options));
|
|
406
|
+
},
|
|
407
|
+
patch: (url, data, options) => {
|
|
408
|
+
return promise.then((client) => client.patch(url, data, options));
|
|
409
|
+
},
|
|
410
|
+
delete: (url, data, options) => {
|
|
411
|
+
return promise.then((client) => client.delete(url, data, options));
|
|
412
|
+
},
|
|
413
|
+
head: (url, options) => {
|
|
414
|
+
return promise.then((client) => client.head(url, options));
|
|
415
|
+
},
|
|
416
|
+
options: (url, options) => {
|
|
417
|
+
return promise.then((client) => client.options(url, options));
|
|
418
|
+
},
|
|
419
|
+
isAxiosError(payload) {
|
|
420
|
+
if (payload == null) return false;
|
|
421
|
+
return typeof payload === "object" && payload.isAxiosError === true;
|
|
422
|
+
},
|
|
423
|
+
isCancel(value) {
|
|
424
|
+
return !!(value && value.__CANCEL__);
|
|
425
|
+
},
|
|
426
|
+
http: promise
|
|
427
|
+
};
|
|
428
|
+
Object.assign(data, {
|
|
429
|
+
then: promise.then.bind(promise),
|
|
430
|
+
catch: promise.catch.bind(promise)
|
|
431
|
+
});
|
|
432
|
+
return data;
|
|
433
|
+
}
|
|
434
|
+
//#endregion
|
|
435
|
+
//#region src/composable/useIframeModal.ts
|
|
436
|
+
async function useIframeModal() {
|
|
437
|
+
const module = await import("./chunks/iframe-modal.js");
|
|
438
|
+
await module.ready;
|
|
439
|
+
return module;
|
|
440
|
+
}
|
|
441
|
+
//#endregion
|
|
442
|
+
//#region src/composable/useListDependent.ts
|
|
443
|
+
async function useListDependent(element, dependent, options = {}) {
|
|
444
|
+
const module = await import("./chunks/list-dependent.js");
|
|
445
|
+
await module.ready;
|
|
446
|
+
if (element) {
|
|
447
|
+
const { ListDependent } = module;
|
|
448
|
+
return ListDependent.handle(element, dependent ?? void 0, options);
|
|
449
|
+
}
|
|
450
|
+
return module;
|
|
451
|
+
}
|
|
452
|
+
//#endregion
|
|
453
|
+
//#region src/composable/useS3Uploader.ts
|
|
454
|
+
async function useS3Uploader(name, options = {}) {
|
|
455
|
+
const module = await import("./chunks/s3-uploader.js");
|
|
456
|
+
if (!name) return module;
|
|
457
|
+
const { get } = module;
|
|
458
|
+
return get(name, options);
|
|
459
|
+
}
|
|
460
|
+
async function useS3MultipartUploader(options) {
|
|
461
|
+
const module = await import("./chunks/s3-multipart-uploader.js");
|
|
462
|
+
if (options != null) return new module.S3MultipartUploader(options);
|
|
463
|
+
return module;
|
|
464
|
+
}
|
|
465
|
+
//#endregion
|
|
466
|
+
//#region src/composable/useShowOn.ts
|
|
467
|
+
async function useShowOn() {
|
|
468
|
+
const module = await import("./chunks/show-on.js");
|
|
469
|
+
await module.ready;
|
|
470
|
+
return module;
|
|
471
|
+
}
|
|
472
|
+
//#endregion
|
|
473
|
+
//#region src/composable/useTomSelect.ts
|
|
474
|
+
/**
|
|
475
|
+
* @see https://tom-select.js.org/
|
|
476
|
+
*/
|
|
477
|
+
async function useTomSelect(selector, options = {}, theme = "bootstrap5") {
|
|
478
|
+
const [m] = await wait(useImport("@vendor/tom-select/dist/js/tom-select.complete.min.js"), useCssImport(`@vendor/tom-select/dist/css/tom-select.${theme}.min.css`));
|
|
479
|
+
if (selector) module(selector, "tom.select", (ele) => {
|
|
480
|
+
options = mergeDeep({
|
|
481
|
+
allowEmptyOption: true,
|
|
482
|
+
maxOptions: null,
|
|
483
|
+
plugins: {
|
|
484
|
+
caret_position: {},
|
|
485
|
+
clear_button: {}
|
|
486
|
+
}
|
|
487
|
+
}, options);
|
|
488
|
+
if (ele.multiple) options.plugins.remove_button = {};
|
|
489
|
+
else options.plugins.dropdown_input = {};
|
|
490
|
+
class UnicornTomSelect extends TomSelect {
|
|
491
|
+
syncOptionsWithoutKeepSelected() {
|
|
492
|
+
const oldValue = ele.value;
|
|
493
|
+
this.clear();
|
|
494
|
+
this.clearOptions();
|
|
495
|
+
this.sync();
|
|
496
|
+
if (ele.value !== oldValue) this.setValue(ele.querySelector(`option[value="${oldValue}"]`)?.value ?? ele.querySelector("option")?.value ?? "", true);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
const t = new UnicornTomSelect(ele, options);
|
|
500
|
+
ele.addEventListener("list:updated", () => {
|
|
501
|
+
t.syncOptionsWithoutKeepSelected();
|
|
502
|
+
});
|
|
503
|
+
return t;
|
|
504
|
+
});
|
|
505
|
+
return m;
|
|
506
|
+
}
|
|
507
|
+
//#endregion
|
|
508
|
+
//#region src/composable/useTinymce.ts
|
|
509
|
+
async function useTinymce(selector, options = {}) {
|
|
510
|
+
const module = await import("./chunks/tinymce.js");
|
|
511
|
+
if (selector) return module.get(selector, options);
|
|
512
|
+
return module;
|
|
513
|
+
}
|
|
514
|
+
async function useTinymceHook(handler) {
|
|
515
|
+
const { addHook } = await import("./chunks/tinymce.js");
|
|
516
|
+
return addHook(handler);
|
|
517
|
+
}
|
|
518
|
+
//#endregion
|
|
519
|
+
//#region src/composable/useUniDirective.ts
|
|
520
|
+
var instances = {};
|
|
521
|
+
async function useWebDirective(name = "unicorn", options = {}) {
|
|
522
|
+
if (options === false) {
|
|
523
|
+
delete instances[name];
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
return instances[name] ??= await createWebDirective(Object.assign({}, options, { prefix: "uni-" }));
|
|
527
|
+
}
|
|
528
|
+
async function useUniDirective(name, handler, wdInstance = "unicorn") {
|
|
529
|
+
(typeof wdInstance === "string" ? await useWebDirective(wdInstance) : wdInstance).register(name, handler);
|
|
530
|
+
}
|
|
531
|
+
async function createWebDirective(options = {}) {
|
|
532
|
+
const WebDirective = (await import("web-directive")).default;
|
|
533
|
+
const wd = new WebDirective(options);
|
|
534
|
+
wd.listen();
|
|
535
|
+
return wd;
|
|
536
|
+
}
|
|
537
|
+
//#endregion
|
|
538
|
+
//#region src/composable/useValidation.ts
|
|
539
|
+
async function useFormValidation(selector) {
|
|
540
|
+
const module = await import("./chunks/validation.js");
|
|
541
|
+
await module.ready;
|
|
542
|
+
if (!selector) return module;
|
|
543
|
+
return useFormValidationInstance(selector);
|
|
544
|
+
}
|
|
545
|
+
function useFormValidationInstance(selector) {
|
|
546
|
+
return getBoundedInstance(selector, "form.validation");
|
|
547
|
+
}
|
|
548
|
+
function useFieldValidationInstance(selector) {
|
|
549
|
+
return getBoundedInstance(selector, "field.validation");
|
|
550
|
+
}
|
|
551
|
+
async function addGlobalValidator(name, validator, options = {}) {
|
|
552
|
+
const { UnicornFormValidation } = await useFormValidation();
|
|
553
|
+
UnicornFormValidation.addGlobalValidator(name, validator, options);
|
|
554
|
+
}
|
|
555
|
+
//#endregion
|
|
556
|
+
//#region src/service/uri.ts
|
|
557
|
+
function useSystemUri(type, path) {
|
|
558
|
+
const uri = UnicornSystemUri.get();
|
|
559
|
+
if (type) return uri[type](path);
|
|
560
|
+
return uri;
|
|
561
|
+
}
|
|
562
|
+
function useAssetUri(type, path) {
|
|
563
|
+
const asset = UnicornAssetUri.get();
|
|
564
|
+
if (type) return asset[type](path);
|
|
565
|
+
return asset;
|
|
566
|
+
}
|
|
567
|
+
function uri(type) {
|
|
568
|
+
return data("unicorn.uri")[type];
|
|
569
|
+
}
|
|
570
|
+
function asset(type) {
|
|
571
|
+
return uri("asset")[type];
|
|
572
|
+
}
|
|
573
|
+
function addUriBase(uri, type = "path") {
|
|
574
|
+
if (uri.substring(0, 2) === "//" || uri.substring(0, 4) === "http") return uri;
|
|
575
|
+
return asset(type) + "/" + uri;
|
|
576
|
+
}
|
|
577
|
+
var UnicornSystemUri = class extends URL {
|
|
578
|
+
static instance;
|
|
579
|
+
static get() {
|
|
580
|
+
return this.instance ??= new this(uri("full"));
|
|
581
|
+
}
|
|
582
|
+
path(path = "") {
|
|
583
|
+
return uri("path") + path;
|
|
584
|
+
}
|
|
585
|
+
root(path = "") {
|
|
586
|
+
return uri("root") + path;
|
|
587
|
+
}
|
|
588
|
+
current() {
|
|
589
|
+
return uri("current") || "";
|
|
590
|
+
}
|
|
591
|
+
full() {
|
|
592
|
+
return uri("full") || "";
|
|
593
|
+
}
|
|
594
|
+
route() {
|
|
595
|
+
return uri("route") || "";
|
|
596
|
+
}
|
|
597
|
+
script() {
|
|
598
|
+
return uri("script") || "";
|
|
599
|
+
}
|
|
600
|
+
routeWithQuery() {
|
|
601
|
+
const route = this.route();
|
|
602
|
+
const query = this.searchParams.toString();
|
|
603
|
+
return query ? `${route}?${query}` : route;
|
|
604
|
+
}
|
|
605
|
+
routeAndQuery() {
|
|
606
|
+
return [this.route(), this.searchParams.toString()];
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
var UnicornAssetUri = class {
|
|
610
|
+
static instance;
|
|
611
|
+
static get() {
|
|
612
|
+
return this.instance ??= new this();
|
|
613
|
+
}
|
|
614
|
+
path(path = "") {
|
|
615
|
+
return asset("path") + path;
|
|
616
|
+
}
|
|
617
|
+
root(path = "") {
|
|
618
|
+
return asset("root") + path;
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
//#endregion
|
|
622
|
+
//#region src/utilities/base.ts
|
|
623
|
+
function removeCloak() {
|
|
624
|
+
if (globalThis.document == null) return;
|
|
625
|
+
selectAll("[uni-cloak]", (el) => el.removeAttribute("uni-cloak"));
|
|
626
|
+
}
|
|
627
|
+
//#endregion
|
|
628
|
+
//#region src/app.ts
|
|
629
|
+
var UnicornApp = class extends Mixin(EventMixin) {
|
|
630
|
+
registry = /* @__PURE__ */ new Map();
|
|
631
|
+
plugins = /* @__PURE__ */ new Map();
|
|
632
|
+
waits = [];
|
|
633
|
+
options;
|
|
634
|
+
defaultOptions = {};
|
|
635
|
+
domready = domready;
|
|
636
|
+
data = data;
|
|
637
|
+
constructor(options = {}) {
|
|
638
|
+
super();
|
|
639
|
+
this.options = Object.assign({}, this.defaultOptions, options);
|
|
640
|
+
if (typeof document !== "undefined") {
|
|
641
|
+
this.wait((resolve) => {
|
|
642
|
+
document.addEventListener("DOMContentLoaded", () => resolve());
|
|
643
|
+
});
|
|
644
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
645
|
+
this.completed().then(() => this.trigger("loaded"));
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
use(plugin, options = {}) {
|
|
650
|
+
if (Array.isArray(plugin)) {
|
|
651
|
+
plugin.forEach((p) => this.use(p));
|
|
652
|
+
return this;
|
|
653
|
+
}
|
|
654
|
+
plugin?.install?.(this, options);
|
|
655
|
+
this.trigger("plugin.installed", plugin);
|
|
656
|
+
this.plugins.set(plugin, plugin);
|
|
657
|
+
return this;
|
|
658
|
+
}
|
|
659
|
+
detach(plugin) {
|
|
660
|
+
if (plugin.uninstall) plugin.uninstall(this);
|
|
661
|
+
this.trigger("plugin.uninstalled", plugin);
|
|
662
|
+
return this;
|
|
663
|
+
}
|
|
664
|
+
inject(id, def) {
|
|
665
|
+
if (!this.registry.has(id)) {
|
|
666
|
+
if (def !== void 0) return def;
|
|
667
|
+
throw new Error(`Injectable: "${id.name ?? id}" not found.`);
|
|
668
|
+
}
|
|
669
|
+
return this.registry.get(id);
|
|
670
|
+
}
|
|
671
|
+
provide(id, value) {
|
|
672
|
+
this.registry.set(id, value);
|
|
673
|
+
return this;
|
|
674
|
+
}
|
|
675
|
+
wait(callback) {
|
|
676
|
+
const p = new Promise((resolve, reject) => {
|
|
677
|
+
const promise = callback(resolve, reject);
|
|
678
|
+
if (promise && "then" in promise) promise.then(resolve).catch(reject);
|
|
679
|
+
});
|
|
680
|
+
this.waits.push(p);
|
|
681
|
+
return p;
|
|
682
|
+
}
|
|
683
|
+
completed() {
|
|
684
|
+
const promise = Promise.all(this.waits);
|
|
685
|
+
this.waits = [];
|
|
686
|
+
return promise;
|
|
687
|
+
}
|
|
688
|
+
macro(name, prop) {
|
|
689
|
+
if (this[name]) throw new Error(`Macro: ${name} already exists.`);
|
|
690
|
+
this[name] = prop;
|
|
691
|
+
return this;
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
//#endregion
|
|
695
|
+
//#region src/polyfill/form-request-submit.ts
|
|
696
|
+
function formRequestSubmit(prototype) {
|
|
697
|
+
if (typeof prototype.requestSubmit == "function") return;
|
|
698
|
+
prototype.requestSubmit = function(submitter) {
|
|
699
|
+
if (submitter) {
|
|
700
|
+
validateSubmitter(submitter, this);
|
|
701
|
+
submitter.click();
|
|
702
|
+
} else {
|
|
703
|
+
submitter = document.createElement("input");
|
|
704
|
+
submitter.type = "submit";
|
|
705
|
+
submitter.hidden = true;
|
|
706
|
+
this.appendChild(submitter);
|
|
707
|
+
submitter.click();
|
|
708
|
+
this.removeChild(submitter);
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
function validateSubmitter(submitter, form) {
|
|
712
|
+
submitter instanceof HTMLElement || raise(TypeError, "parameter 1 is not of type 'HTMLElement'");
|
|
713
|
+
submitter.type == "submit" || raise(TypeError, "The specified element is not a submit button");
|
|
714
|
+
submitter.form == form || raise(DOMException, "The specified element is not owned by this form element", "NotFoundError");
|
|
715
|
+
}
|
|
716
|
+
function raise(errorConstructor, message, name) {
|
|
717
|
+
throw new errorConstructor("Failed to execute 'requestSubmit' on 'HTMLFormElement': " + message + ".", name);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
//#endregion
|
|
721
|
+
//#region src/polyfill/index.ts
|
|
722
|
+
function polyfill() {
|
|
723
|
+
if (typeof window !== "undefined") formRequestSubmit(HTMLFormElement.prototype);
|
|
724
|
+
}
|
|
725
|
+
//#endregion
|
|
726
|
+
//#region src/composable/useFieldMultiUploader.ts
|
|
727
|
+
async function useFieldMultiUploader() {
|
|
728
|
+
const module = await import("./chunks/field-multi-uploader.js");
|
|
729
|
+
await module.ready;
|
|
730
|
+
return module;
|
|
731
|
+
}
|
|
732
|
+
//#endregion
|
|
733
|
+
//#region src/plugin/php-adapter.ts
|
|
734
|
+
function useUnicornPhpAdapter(app) {
|
|
735
|
+
app ??= useUnicorn();
|
|
736
|
+
app.use(UnicornPhpAdapter);
|
|
737
|
+
return app.$ui;
|
|
738
|
+
}
|
|
739
|
+
var methods = {
|
|
740
|
+
repeatable: useFieldRepeatable,
|
|
741
|
+
flatpickr: useFieldFlatpickr,
|
|
742
|
+
fileDrag: useFieldFileDrag,
|
|
743
|
+
modalField: useFieldModalSelect,
|
|
744
|
+
cascadeSelect: useFieldCascadeSelect,
|
|
745
|
+
sid: useFieldSingleImageDrag,
|
|
746
|
+
tinymce: { init: useTinymce },
|
|
747
|
+
s3Uploader: useS3Uploader,
|
|
748
|
+
iframeModal: useIframeModal,
|
|
749
|
+
initShowOn: useShowOn,
|
|
750
|
+
modalTree: useFieldModalTree,
|
|
751
|
+
multiUploader: useFieldMultiUploader,
|
|
752
|
+
tomSelect: useTomSelect,
|
|
753
|
+
listDependent: useListDependent,
|
|
754
|
+
bootstrap: {
|
|
755
|
+
tooltip: useBs5Tooltip,
|
|
756
|
+
buttonRadio: useBs5ButtonRadio,
|
|
757
|
+
keepTab: useBs5KeepTab
|
|
758
|
+
}
|
|
759
|
+
};
|
|
760
|
+
var UnicornPhpAdapter = class {
|
|
761
|
+
static install(app) {
|
|
762
|
+
if (app.$ui) app.$ui = {
|
|
763
|
+
...app.$ui,
|
|
764
|
+
...methods
|
|
765
|
+
};
|
|
766
|
+
else app.$ui = methods;
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
//#endregion
|
|
770
|
+
//#region src/unicorn.ts
|
|
771
|
+
var app;
|
|
772
|
+
function createUnicorn() {
|
|
773
|
+
polyfill();
|
|
774
|
+
removeCloak();
|
|
775
|
+
return app = new UnicornApp();
|
|
776
|
+
}
|
|
777
|
+
function createUnicornWithPlugins() {
|
|
778
|
+
return createUnicorn();
|
|
779
|
+
}
|
|
780
|
+
function useUnicorn(instance) {
|
|
781
|
+
if (instance) app = instance;
|
|
782
|
+
return app ??= createUnicorn();
|
|
783
|
+
}
|
|
784
|
+
var useInject = (id, def) => {
|
|
785
|
+
return useUnicorn().inject(id, def);
|
|
786
|
+
};
|
|
787
|
+
function pushUnicornToGlobal(app) {
|
|
788
|
+
window.u = app ?? useUnicorn();
|
|
789
|
+
}
|
|
790
|
+
function useMacro(name, prop) {
|
|
791
|
+
const app = useUnicorn();
|
|
792
|
+
if (typeof name === "string") app.macro(name, prop);
|
|
793
|
+
else for (const k in name) app.macro(k, name[k]);
|
|
794
|
+
return app;
|
|
795
|
+
}
|
|
796
|
+
async function useLegacy(app) {
|
|
797
|
+
app ??= useUnicorn();
|
|
798
|
+
pushUnicornToGlobal(app);
|
|
799
|
+
const { useLegacyMethods } = await import("./chunks/legacy.js");
|
|
800
|
+
await useLegacyMethods(app);
|
|
801
|
+
return app;
|
|
802
|
+
}
|
|
803
|
+
//#endregion
|
|
804
|
+
export { AttributeMutationObserver, EventMixin, UnicornAssetUri, UnicornPhpAdapter, UnicornSystemUri, UnicornUI, __, addGlobalValidator, addQuery, addRoute, addUriBase, animateTo, base64UrlDecode, base64UrlEncode, buildQuery, clearMessages, clearNotifies, createQueue, createStack, createUnicorn, createUnicornWithPlugins, data, debounce, delegate, deleteConfirm, doImport, domready, fadeIn, fadeOut, forceArray, getBoundedInstance, getBoundedInstanceList, h, hasRoute, highlight, html, initAlpineComponent, injectCssToDocument, isDebug, isError, loadAlpine, mark, module, nextTick, parseQuery, prepareAlpine, prepareAlpineDefer, pushUnicornToGlobal, randomBytes, randomBytesString, removeBoundedInstance, removeData, renderMessage, route, selectAll, selectOne, serial, simpleAlert, simpleConfirm, simpleNotify, sleep, slideDown, slideToggle, slideUp, throttle, tid, trans, uid, useAlertAdapter, useAssetUri, useBs5ButtonRadio, useBs5KeepTab, useBs5Tooltip, useBsModalAlert, useCheckboxesMultiSelect, useColorPicker, useCssImport, useCssIncludes, useDisableIfStackNotEmpty, useDisableOnSubmit, useFieldCascadeSelect, useFieldFileDrag, useFieldFlatpickr, useFieldModalSelect, useFieldModalTree, useFieldRepeatable, useFieldSingleImageDrag, useFieldValidationInstance, useForm, useFormAsync, useFormComponent, useFormSubmit, useFormValidation, useFormValidationInstance, useGrid, useGridAsync, useGridComponent, useHttpClient, useIframeModal, useImport, useInject, useKeepAlive, useLang, useLegacy, useListDependent, useMacro, useQueue, useS3MultipartUploader, useS3Uploader, useScriptImport, useSeriesImport, useShowOn, useStack, useSystemUri, useTinymce, useTinymceHook, useTomSelect, useUI, useUIBootstrap5, useUITheme, useUniDirective, useUnicorn, useUnicornPhpAdapter, useVueComponentField, useWebDirective, wait, watchAttributes };
|
|
805
|
+
|
|
806
|
+
//# sourceMappingURL=unicorn.js.map
|