sbs-editable-bs5 1.0.0
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/LICENSE +21 -0
- package/README.md +325 -0
- package/dist/editable.css +1 -0
- package/dist/editable.iife.js +3 -0
- package/dist/editable.iife.js.map +1 -0
- package/dist/editable.js +906 -0
- package/dist/editable.js.map +1 -0
- package/dist/editable.umd.cjs +3 -0
- package/dist/editable.umd.cjs.map +1 -0
- package/dist/src/Interfaces/BaseTypeButtons.d.ts +4 -0
- package/dist/src/Interfaces/Options.d.ts +36 -0
- package/dist/src/Modes/BaseMode.d.ts +14 -0
- package/dist/src/Modes/InlineMode.d.ts +11 -0
- package/dist/src/Modes/PopupMode.d.ts +12 -0
- package/dist/src/Types/BaseType.d.ts +35 -0
- package/dist/src/Types/DateTimeType.d.ts +5 -0
- package/dist/src/Types/DateType.d.ts +7 -0
- package/dist/src/Types/InputType.d.ts +4 -0
- package/dist/src/Types/SelectType.d.ts +7 -0
- package/dist/src/Types/TextAreaType.d.ts +4 -0
- package/dist/src/editable.d.ts +51 -0
- package/dist/tests/accessibility.test.d.ts +1 -0
- package/dist/tests/disabled.test.d.ts +1 -0
- package/dist/tests/errors.test.d.ts +1 -0
- package/dist/tests/events.test.d.ts +1 -0
- package/dist/tests/lifecycle.test.d.ts +1 -0
- package/dist/tests/public-api.test.d.ts +1 -0
- package/dist/tests/render.test.d.ts +1 -0
- package/dist/tests/request.test.d.ts +1 -0
- package/dist/tests/save-flow.test.d.ts +1 -0
- package/dist/tests/theme.test.d.ts +1 -0
- package/dist/tests/types/attributes.test.d.ts +1 -0
- package/dist/tests/types/date.test.d.ts +1 -0
- package/dist/tests/types/select.test.d.ts +1 -0
- package/package.json +57 -0
- package/src/Interfaces/BaseTypeButtons.ts +4 -0
- package/src/Interfaces/Options.ts +30 -0
- package/src/Modes/BaseMode.ts +57 -0
- package/src/Modes/InlineMode.ts +47 -0
- package/src/Modes/PopupMode.ts +107 -0
- package/src/Types/BaseType.ts +301 -0
- package/src/Types/DateTimeType.ts +18 -0
- package/src/Types/DateType.ts +43 -0
- package/src/Types/InputType.ts +12 -0
- package/src/Types/SelectType.ts +70 -0
- package/src/Types/TextAreaType.ts +9 -0
- package/src/editable.css +136 -0
- package/src/editable.ts +244 -0
package/dist/editable.js
ADDED
|
@@ -0,0 +1,906 @@
|
|
|
1
|
+
import { Popover as e } from "bootstrap";
|
|
2
|
+
import './editable.css';//#region \0rolldown/runtime.js
|
|
3
|
+
var t = Object.create, n = Object.defineProperty, r = Object.getOwnPropertyDescriptor, i = Object.getOwnPropertyNames, a = Object.getPrototypeOf, o = Object.prototype.hasOwnProperty, s = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), c = (e, t, a, s) => {
|
|
4
|
+
if (t && typeof t == "object" || typeof t == "function") for (var c = i(t), l = 0, u = c.length, d; l < u; l++) d = c[l], !o.call(e, d) && d !== a && n(e, d, {
|
|
5
|
+
get: ((e) => t[e]).bind(null, d),
|
|
6
|
+
enumerable: !(s = r(t, d)) || s.enumerable
|
|
7
|
+
});
|
|
8
|
+
return e;
|
|
9
|
+
}, l = (e, r, i) => (i = e == null ? {} : t(a(e)), c(r || !e || !e.__esModule || !o.call(e, "default") ? n(i, "default", {
|
|
10
|
+
value: e,
|
|
11
|
+
enumerable: !0
|
|
12
|
+
}) : i, e)), u = class e {
|
|
13
|
+
context;
|
|
14
|
+
constructor(t) {
|
|
15
|
+
if (this.constructor === e) throw Error("BaseMode is abstract and cannot be instantiated directly — create a subclass that implements init()/enable()/disable()/hide()/destroy() (see PopupMode, InlineMode).");
|
|
16
|
+
this.context = t;
|
|
17
|
+
}
|
|
18
|
+
event_show() {
|
|
19
|
+
if (this.context.typeElement.hideError(), !this.context.typeElement.element) throw Error(`${this.context.typeElement.constructor.name}.create() did not call createContainer() — the input element was never set.`);
|
|
20
|
+
this.context.typeElement.element.value = this.context.getValue(), this.context.element.dispatchEvent(new CustomEvent("show", { detail: { Editable: this.context } }));
|
|
21
|
+
}
|
|
22
|
+
event_shown() {
|
|
23
|
+
this.context.element.dispatchEvent(new CustomEvent("shown", { detail: { Editable: this.context } }));
|
|
24
|
+
}
|
|
25
|
+
event_hide() {
|
|
26
|
+
this.context.element.dispatchEvent(new CustomEvent("hide", { detail: { Editable: this.context } }));
|
|
27
|
+
}
|
|
28
|
+
event_hidden() {
|
|
29
|
+
this.context.element.dispatchEvent(new CustomEvent("hidden", { detail: { Editable: this.context } }));
|
|
30
|
+
}
|
|
31
|
+
init() {
|
|
32
|
+
throw Error(`${this.constructor.name} must implement init().`);
|
|
33
|
+
}
|
|
34
|
+
enable() {
|
|
35
|
+
throw Error(`${this.constructor.name} must implement enable().`);
|
|
36
|
+
}
|
|
37
|
+
disable() {
|
|
38
|
+
throw Error(`${this.constructor.name} must implement disable().`);
|
|
39
|
+
}
|
|
40
|
+
hide() {
|
|
41
|
+
throw Error(`${this.constructor.name} must implement hide().`);
|
|
42
|
+
}
|
|
43
|
+
destroy() {
|
|
44
|
+
throw Error(`${this.constructor.name} must implement destroy().`);
|
|
45
|
+
}
|
|
46
|
+
}, d = class extends u {
|
|
47
|
+
openHandler = null;
|
|
48
|
+
disabled = !1;
|
|
49
|
+
init() {
|
|
50
|
+
this.openHandler = () => {
|
|
51
|
+
if (!this.disabled) {
|
|
52
|
+
let e = this.context.typeElement.create();
|
|
53
|
+
this.event_show(), this.removeOpenHandler(), this.context.element.replaceChildren(e), this.event_shown();
|
|
54
|
+
}
|
|
55
|
+
}, this.context.element.addEventListener("click", this.openHandler);
|
|
56
|
+
}
|
|
57
|
+
removeOpenHandler() {
|
|
58
|
+
this.openHandler &&= (this.context.element.removeEventListener("click", this.openHandler), null);
|
|
59
|
+
}
|
|
60
|
+
enable() {
|
|
61
|
+
this.disabled = !1;
|
|
62
|
+
}
|
|
63
|
+
disable() {
|
|
64
|
+
this.disabled = !0;
|
|
65
|
+
}
|
|
66
|
+
hide() {
|
|
67
|
+
this.event_hide(), this.context.element.textContent = this.context.getValue(), setTimeout(() => {
|
|
68
|
+
this.init(), this.event_hidden();
|
|
69
|
+
}, 100);
|
|
70
|
+
}
|
|
71
|
+
destroy() {
|
|
72
|
+
this.removeOpenHandler();
|
|
73
|
+
}
|
|
74
|
+
}, f = class extends u {
|
|
75
|
+
popover = null;
|
|
76
|
+
abortController = new AbortController();
|
|
77
|
+
init() {
|
|
78
|
+
let t = {
|
|
79
|
+
container: "body",
|
|
80
|
+
content: this.context.typeElement.create(),
|
|
81
|
+
html: !0,
|
|
82
|
+
customClass: "editable",
|
|
83
|
+
title: this.context.options.title
|
|
84
|
+
};
|
|
85
|
+
this.popover = new e(this.context.element, Object.assign(t, this.context.options.popoverOptions));
|
|
86
|
+
let { signal: n } = this.abortController;
|
|
87
|
+
this.context.element.addEventListener("show.bs.popover", () => {
|
|
88
|
+
this.event_show();
|
|
89
|
+
}, { signal: n }), this.context.element.addEventListener("inserted.bs.popover", () => {
|
|
90
|
+
this.syncTheme();
|
|
91
|
+
}, { signal: n }), this.context.element.addEventListener("shown.bs.popover", () => {
|
|
92
|
+
this.event_shown();
|
|
93
|
+
}, { signal: n }), this.context.element.addEventListener("hide.bs.popover", () => {
|
|
94
|
+
this.event_hide();
|
|
95
|
+
}, { signal: n }), this.context.element.addEventListener("hidden.bs.popover", () => {
|
|
96
|
+
this.event_hidden();
|
|
97
|
+
}, { signal: n }), document.addEventListener("click", (e) => {
|
|
98
|
+
let t = e.target, n = this.popover?.tip;
|
|
99
|
+
if (this.popover && t === n || t === this.context.element) return;
|
|
100
|
+
let r = t.parentNode;
|
|
101
|
+
for (; r;) {
|
|
102
|
+
if (r === n) return;
|
|
103
|
+
r = r.parentNode;
|
|
104
|
+
}
|
|
105
|
+
this.hide();
|
|
106
|
+
}, { signal: n });
|
|
107
|
+
}
|
|
108
|
+
syncTheme() {
|
|
109
|
+
let e = this.context.element.closest("[data-bs-theme]"), t = this.popover?.tip;
|
|
110
|
+
t && e && t.setAttribute("data-bs-theme", e.getAttribute("data-bs-theme") ?? "");
|
|
111
|
+
}
|
|
112
|
+
enable() {
|
|
113
|
+
this.popover && this.popover.enable();
|
|
114
|
+
}
|
|
115
|
+
disable() {
|
|
116
|
+
this.popover && this.popover.disable();
|
|
117
|
+
}
|
|
118
|
+
hide() {
|
|
119
|
+
this.popover && this.popover.hide();
|
|
120
|
+
}
|
|
121
|
+
destroy() {
|
|
122
|
+
this.abortController.abort(), this.popover?.dispose(), this.popover = null;
|
|
123
|
+
}
|
|
124
|
+
}, p = class e {
|
|
125
|
+
context;
|
|
126
|
+
element = null;
|
|
127
|
+
error = null;
|
|
128
|
+
form = null;
|
|
129
|
+
load = null;
|
|
130
|
+
buttons = {
|
|
131
|
+
success: null,
|
|
132
|
+
cancel: null
|
|
133
|
+
};
|
|
134
|
+
constructor(t) {
|
|
135
|
+
if (this.constructor === e) throw Error("BaseType is abstract and cannot be instantiated directly — create a subclass that implements create() (see InputType, SelectType, etc.).");
|
|
136
|
+
this.context = t;
|
|
137
|
+
}
|
|
138
|
+
create() {
|
|
139
|
+
throw Error(`${this.constructor.name} must implement create().`);
|
|
140
|
+
}
|
|
141
|
+
checkUnsupportedOptions() {
|
|
142
|
+
this.context.options.format !== void 0 && console.error(`${this.constructor.name} does not support the "format" option — it only applies to type: 'date'/'datetime'. It will be ignored.`), this.context.options.displayFormat !== void 0 && console.error(`${this.constructor.name} does not support the "displayFormat" option — it only applies to type: 'date'/'datetime'. It will be ignored.`), this.context.options.source !== void 0 && console.error(`${this.constructor.name} does not support the "source" option — it only applies to type: 'select'. It will be ignored.`);
|
|
143
|
+
}
|
|
144
|
+
createContainer(e) {
|
|
145
|
+
let t = document.createElement("div");
|
|
146
|
+
return this.element = e, this.error = this.createContainerError(), this.form = this.createContainerForm(), this.load = this.createContainerLoad(), this.form.append(e, this.load), this.buttons.success = null, this.buttons.cancel = null, this.context.options.showButtons && (this.buttons.success = this.createButtonSuccess(), this.buttons.cancel = this.createButtonCancel(), this.form.append(this.buttons.success, this.buttons.cancel)), t.append(this.error, this.form), t;
|
|
147
|
+
}
|
|
148
|
+
createContainerError() {
|
|
149
|
+
let e = document.createElement("div");
|
|
150
|
+
return e.classList.add("editable-error", "text-danger", "fst-italic", "mb-2", "fw-bold"), e.setAttribute("role", "alert"), e.hidden = !0, e;
|
|
151
|
+
}
|
|
152
|
+
closeAndFocus() {
|
|
153
|
+
this.context.modeElement.hide(), this.context.element.focus();
|
|
154
|
+
}
|
|
155
|
+
createContainerForm() {
|
|
156
|
+
let e = document.createElement("form");
|
|
157
|
+
return e.classList.add("editable-form", "d-flex", "align-items-start"), e.addEventListener("keydown", (e) => {
|
|
158
|
+
e.key === "Escape" && (e.preventDefault(), this.closeAndFocus());
|
|
159
|
+
}), e.addEventListener("submit", async (e) => {
|
|
160
|
+
e.preventDefault();
|
|
161
|
+
let t = this.getValue();
|
|
162
|
+
if (this.context.options.send && this.context.options.url && this.context.getValue() !== t) {
|
|
163
|
+
this.showLoad();
|
|
164
|
+
let e;
|
|
165
|
+
try {
|
|
166
|
+
let n = await this.ajax(t);
|
|
167
|
+
e = n.ok ? await this.context.success(n, t) : await this.context.error(n, t) || `${n.status} ${n.statusText}`;
|
|
168
|
+
} catch (t) {
|
|
169
|
+
if (console.error(t), !(t instanceof TypeError)) throw t;
|
|
170
|
+
e = t.message;
|
|
171
|
+
}
|
|
172
|
+
e ? (this.showError(), this.setError(e)) : (this.setError(""), this.hideError(), this.context.setValue(this.getValue()), this.closeAndFocus(), this.initText()), this.hideLoad();
|
|
173
|
+
} else this.context.setValue(this.getValue()), this.closeAndFocus(), this.initText();
|
|
174
|
+
this.context.element.dispatchEvent(new CustomEvent("save", { detail: { Editable: this.context } }));
|
|
175
|
+
}), e;
|
|
176
|
+
}
|
|
177
|
+
createContainerLoad() {
|
|
178
|
+
let e = document.createElement("div");
|
|
179
|
+
e.classList.add("editable-load-overlay"), e.hidden = !0;
|
|
180
|
+
let t = document.createElement("div");
|
|
181
|
+
return t.classList.add("editable-loader"), e.append(t), e;
|
|
182
|
+
}
|
|
183
|
+
createButton() {
|
|
184
|
+
let e = document.createElement("button");
|
|
185
|
+
return e.type = "button", e.classList.add("btn", "btn-sm"), e;
|
|
186
|
+
}
|
|
187
|
+
createButtonSuccess() {
|
|
188
|
+
let e = this.createButton();
|
|
189
|
+
return e.type = "submit", e.classList.add("btn-success"), e.setAttribute("aria-label", "Save"), e.innerHTML = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"currentColor\" aria-hidden=\"true\"><path d=\"M13.485 1.929a1 1 0 0 1 .057 1.414l-7.5 8a1 1 0 0 1-1.45.036l-3.5-3.5a1 1 0 1 1 1.414-1.415L5.5 9.379l6.571-7.007a1 1 0 0 1 1.414-.043z\"/></svg>", e;
|
|
190
|
+
}
|
|
191
|
+
createButtonCancel() {
|
|
192
|
+
let e = this.createButton();
|
|
193
|
+
return e.classList.add("btn-danger"), e.setAttribute("aria-label", "Cancel"), e.innerHTML = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"currentColor\" aria-hidden=\"true\"><path d=\"M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854z\"/></svg>", e.addEventListener("click", () => {
|
|
194
|
+
this.closeAndFocus();
|
|
195
|
+
}), e;
|
|
196
|
+
}
|
|
197
|
+
hideLoad() {
|
|
198
|
+
this.load && (this.load.hidden = !0);
|
|
199
|
+
}
|
|
200
|
+
showLoad() {
|
|
201
|
+
this.load && (this.load.hidden = !1);
|
|
202
|
+
}
|
|
203
|
+
async ajax(e) {
|
|
204
|
+
let t = this.context.options.url;
|
|
205
|
+
if (!t) {
|
|
206
|
+
let e = /* @__PURE__ */ Error("ajax() was called without a `url` option configured. Set `url` (string or function) before calling save.");
|
|
207
|
+
throw console.error(e), e;
|
|
208
|
+
}
|
|
209
|
+
let n = typeof t == "function" ? t(this.context, e) : t;
|
|
210
|
+
if (this.context.options.requestBuilder) {
|
|
211
|
+
let t = await this.context.options.requestBuilder(this.context, e, n);
|
|
212
|
+
return fetch(t.url, t.init);
|
|
213
|
+
}
|
|
214
|
+
let r = new FormData();
|
|
215
|
+
r.append(this.context.options.name ?? "value", e);
|
|
216
|
+
let i = { ...this.context.options.ajaxOptions };
|
|
217
|
+
return i.body = r, fetch(n, i);
|
|
218
|
+
}
|
|
219
|
+
async successResponse(e, t) {}
|
|
220
|
+
async errorResponse(e, t) {}
|
|
221
|
+
setError(e) {
|
|
222
|
+
this.error && (this.error.textContent = e);
|
|
223
|
+
}
|
|
224
|
+
showError() {
|
|
225
|
+
this.error && (this.error.hidden = !1);
|
|
226
|
+
}
|
|
227
|
+
hideError() {
|
|
228
|
+
this.error && (this.error.hidden = !0);
|
|
229
|
+
}
|
|
230
|
+
createElement(e) {
|
|
231
|
+
let t = document.createElement(e);
|
|
232
|
+
return t.classList.add("form-control"), this.context.options.required && (t.required = this.context.options.required), this.applyAttributes(t), this.context.options.showButtons || t.addEventListener("change", () => {
|
|
233
|
+
this.form && this.form.dispatchEvent(new Event("submit"));
|
|
234
|
+
}), this.add_focus(t), t;
|
|
235
|
+
}
|
|
236
|
+
applyAttributes(e) {
|
|
237
|
+
let t = this.context.options.attributes || {}, n = [
|
|
238
|
+
"step",
|
|
239
|
+
"min",
|
|
240
|
+
"max",
|
|
241
|
+
"minlength",
|
|
242
|
+
"maxlength",
|
|
243
|
+
"pattern",
|
|
244
|
+
"placeholder",
|
|
245
|
+
"required",
|
|
246
|
+
"readonly",
|
|
247
|
+
"disabled",
|
|
248
|
+
"autocomplete",
|
|
249
|
+
"autofocus"
|
|
250
|
+
];
|
|
251
|
+
for (let [r, i] of Object.entries(t)) n.includes(r) && i !== void 0 && e.setAttribute(r, String(i));
|
|
252
|
+
}
|
|
253
|
+
add_focus(e) {
|
|
254
|
+
this.context.element.addEventListener("shown", () => {
|
|
255
|
+
e.focus();
|
|
256
|
+
}, { once: !0 });
|
|
257
|
+
}
|
|
258
|
+
initText() {
|
|
259
|
+
if (this.context.getValue() === "") return this.context.element.textContent = this.context.options.emptyText || "", !0;
|
|
260
|
+
{
|
|
261
|
+
let e = this.context.getValue();
|
|
262
|
+
return this.context.element.textContent = this.context.options.render ? this.context.options.render(e, this.context) : e, !1;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
initOptions() {}
|
|
266
|
+
getValue() {
|
|
267
|
+
return this.element ? this.element.value : "";
|
|
268
|
+
}
|
|
269
|
+
}, m = /* @__PURE__ */ s(((e, t) => {
|
|
270
|
+
(function(n, r) {
|
|
271
|
+
typeof e == "object" && t !== void 0 ? t.exports = r() : typeof define == "function" && define.amd ? define(r) : (n = typeof globalThis < "u" ? globalThis : n || self).dayjs = r();
|
|
272
|
+
})(e, (function() {
|
|
273
|
+
var e = 1e3, t = 6e4, n = 36e5, r = "millisecond", i = "second", a = "minute", o = "hour", s = "day", c = "week", l = "month", u = "quarter", d = "year", f = "date", p = "Invalid Date", m = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, h = /\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, g = {
|
|
274
|
+
name: "en",
|
|
275
|
+
weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
|
|
276
|
+
months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
|
|
277
|
+
ordinal: function(e) {
|
|
278
|
+
var t = [
|
|
279
|
+
"th",
|
|
280
|
+
"st",
|
|
281
|
+
"nd",
|
|
282
|
+
"rd"
|
|
283
|
+
], n = e % 100;
|
|
284
|
+
return "[" + e + (t[(n - 20) % 10] || t[n] || t[0]) + "]";
|
|
285
|
+
}
|
|
286
|
+
}, _ = function(e, t, n) {
|
|
287
|
+
var r = String(e);
|
|
288
|
+
return !r || r.length >= t ? e : "" + Array(t + 1 - r.length).join(n) + e;
|
|
289
|
+
}, v = {
|
|
290
|
+
s: _,
|
|
291
|
+
z: function(e) {
|
|
292
|
+
var t = -e.utcOffset(), n = Math.abs(t), r = Math.floor(n / 60), i = n % 60;
|
|
293
|
+
return (t <= 0 ? "+" : "-") + _(r, 2, "0") + ":" + _(i, 2, "0");
|
|
294
|
+
},
|
|
295
|
+
m: function e(t, n) {
|
|
296
|
+
if (t.date() < n.date()) return -e(n, t);
|
|
297
|
+
var r = 12 * (n.year() - t.year()) + (n.month() - t.month()), i = t.clone().add(r, l), a = n - i < 0, o = t.clone().add(r + (a ? -1 : 1), l);
|
|
298
|
+
return +(-(r + (n - i) / (a ? i - o : o - i)) || 0);
|
|
299
|
+
},
|
|
300
|
+
a: function(e) {
|
|
301
|
+
return e < 0 ? Math.ceil(e) || 0 : Math.floor(e);
|
|
302
|
+
},
|
|
303
|
+
p: function(e) {
|
|
304
|
+
return {
|
|
305
|
+
M: l,
|
|
306
|
+
y: d,
|
|
307
|
+
w: c,
|
|
308
|
+
d: s,
|
|
309
|
+
D: f,
|
|
310
|
+
h: o,
|
|
311
|
+
m: a,
|
|
312
|
+
s: i,
|
|
313
|
+
ms: r,
|
|
314
|
+
Q: u
|
|
315
|
+
}[e] || String(e || "").toLowerCase().replace(/s$/, "");
|
|
316
|
+
},
|
|
317
|
+
u: function(e) {
|
|
318
|
+
return e === void 0;
|
|
319
|
+
}
|
|
320
|
+
}, y = "en", b = {};
|
|
321
|
+
b[y] = g;
|
|
322
|
+
var x = "$isDayjsObject", S = function(e) {
|
|
323
|
+
return e instanceof E || !(!e || !e[x]);
|
|
324
|
+
}, C = function e(t, n, r) {
|
|
325
|
+
var i;
|
|
326
|
+
if (!t) return y;
|
|
327
|
+
if (typeof t == "string") {
|
|
328
|
+
var a = t.toLowerCase();
|
|
329
|
+
b[a] && (i = a), n && (b[a] = n, i = a);
|
|
330
|
+
var o = t.split("-");
|
|
331
|
+
if (!i && o.length > 1) return e(o[0]);
|
|
332
|
+
} else {
|
|
333
|
+
var s = t.name;
|
|
334
|
+
b[s] = t, i = s;
|
|
335
|
+
}
|
|
336
|
+
return !r && i && (y = i), i || !r && y;
|
|
337
|
+
}, w = function(e, t) {
|
|
338
|
+
if (S(e)) return e.clone();
|
|
339
|
+
var n = typeof t == "object" ? t : {};
|
|
340
|
+
return n.date = e, n.args = arguments, new E(n);
|
|
341
|
+
}, T = v;
|
|
342
|
+
T.l = C, T.i = S, T.w = function(e, t) {
|
|
343
|
+
return w(e, {
|
|
344
|
+
locale: t.$L,
|
|
345
|
+
utc: t.$u,
|
|
346
|
+
x: t.$x,
|
|
347
|
+
$offset: t.$offset
|
|
348
|
+
});
|
|
349
|
+
};
|
|
350
|
+
var E = function() {
|
|
351
|
+
function g(e) {
|
|
352
|
+
this.$L = C(e.locale, null, !0), this.parse(e), this.$x = this.$x || e.x || {}, this[x] = !0;
|
|
353
|
+
}
|
|
354
|
+
var _ = g.prototype;
|
|
355
|
+
return _.parse = function(e) {
|
|
356
|
+
this.$d = function(e) {
|
|
357
|
+
var t = e.date, n = e.utc;
|
|
358
|
+
if (t === null) return /* @__PURE__ */ new Date(NaN);
|
|
359
|
+
if (T.u(t)) return /* @__PURE__ */ new Date();
|
|
360
|
+
if (t instanceof Date) return new Date(t);
|
|
361
|
+
if (typeof t == "string" && !/Z$/i.test(t)) {
|
|
362
|
+
var r = t.match(m);
|
|
363
|
+
if (r) {
|
|
364
|
+
var i = r[2] - 1 || 0, a = (r[7] || "0").substring(0, 3);
|
|
365
|
+
return n ? new Date(Date.UTC(r[1], i, r[3] || 1, r[4] || 0, r[5] || 0, r[6] || 0, a)) : new Date(r[1], i, r[3] || 1, r[4] || 0, r[5] || 0, r[6] || 0, a);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return new Date(t);
|
|
369
|
+
}(e), this.init();
|
|
370
|
+
}, _.init = function() {
|
|
371
|
+
var e = this.$d;
|
|
372
|
+
this.$y = e.getFullYear(), this.$M = e.getMonth(), this.$D = e.getDate(), this.$W = e.getDay(), this.$H = e.getHours(), this.$m = e.getMinutes(), this.$s = e.getSeconds(), this.$ms = e.getMilliseconds();
|
|
373
|
+
}, _.$utils = function() {
|
|
374
|
+
return T;
|
|
375
|
+
}, _.isValid = function() {
|
|
376
|
+
return this.$d.toString() !== p;
|
|
377
|
+
}, _.isSame = function(e, t) {
|
|
378
|
+
var n = w(e);
|
|
379
|
+
return this.startOf(t) <= n && n <= this.endOf(t);
|
|
380
|
+
}, _.isAfter = function(e, t) {
|
|
381
|
+
return w(e) < this.startOf(t);
|
|
382
|
+
}, _.isBefore = function(e, t) {
|
|
383
|
+
return this.endOf(t) < w(e);
|
|
384
|
+
}, _.$g = function(e, t, n) {
|
|
385
|
+
return T.u(e) ? this[t] : this.set(n, e);
|
|
386
|
+
}, _.unix = function() {
|
|
387
|
+
return Math.floor(this.valueOf() / 1e3);
|
|
388
|
+
}, _.valueOf = function() {
|
|
389
|
+
return this.$d.getTime();
|
|
390
|
+
}, _.startOf = function(e, t) {
|
|
391
|
+
var n = this, r = !!T.u(t) || t, u = T.p(e), p = function(e, t) {
|
|
392
|
+
var i = T.w(n.$u ? Date.UTC(n.$y, t, e) : new Date(n.$y, t, e), n);
|
|
393
|
+
return r ? i : i.endOf(s);
|
|
394
|
+
}, m = function(e, t) {
|
|
395
|
+
return T.w(n.toDate()[e].apply(n.toDate("s"), (r ? [
|
|
396
|
+
0,
|
|
397
|
+
0,
|
|
398
|
+
0,
|
|
399
|
+
0
|
|
400
|
+
] : [
|
|
401
|
+
23,
|
|
402
|
+
59,
|
|
403
|
+
59,
|
|
404
|
+
999
|
|
405
|
+
]).slice(t)), n);
|
|
406
|
+
}, h = this.$W, g = this.$M, _ = this.$D, v = "set" + (this.$u ? "UTC" : "");
|
|
407
|
+
switch (u) {
|
|
408
|
+
case d: return r ? p(1, 0) : p(31, 11);
|
|
409
|
+
case l: return r ? p(1, g) : p(0, g + 1);
|
|
410
|
+
case c:
|
|
411
|
+
var y = this.$locale().weekStart || 0, b = (h < y ? h + 7 : h) - y;
|
|
412
|
+
return p(r ? _ - b : _ + (6 - b), g);
|
|
413
|
+
case s:
|
|
414
|
+
case f: return m(v + "Hours", 0);
|
|
415
|
+
case o: return m(v + "Minutes", 1);
|
|
416
|
+
case a: return m(v + "Seconds", 2);
|
|
417
|
+
case i: return m(v + "Milliseconds", 3);
|
|
418
|
+
default: return this.clone();
|
|
419
|
+
}
|
|
420
|
+
}, _.endOf = function(e) {
|
|
421
|
+
return this.startOf(e, !1);
|
|
422
|
+
}, _.$set = function(e, t) {
|
|
423
|
+
var n, c = T.p(e), u = "set" + (this.$u ? "UTC" : ""), p = (n = {}, n[s] = u + "Date", n[f] = u + "Date", n[l] = u + "Month", n[d] = u + "FullYear", n[o] = u + "Hours", n[a] = u + "Minutes", n[i] = u + "Seconds", n[r] = u + "Milliseconds", n)[c], m = c === s ? this.$D + (t - this.$W) : t;
|
|
424
|
+
if (c === l || c === d) {
|
|
425
|
+
var h = this.clone().set(f, 1);
|
|
426
|
+
h.$d[p](m), h.init(), this.$d = h.set(f, Math.min(this.$D, h.daysInMonth())).$d;
|
|
427
|
+
} else p && this.$d[p](m);
|
|
428
|
+
return this.init(), this;
|
|
429
|
+
}, _.set = function(e, t) {
|
|
430
|
+
return this.clone().$set(e, t);
|
|
431
|
+
}, _.get = function(e) {
|
|
432
|
+
return this[T.p(e)]();
|
|
433
|
+
}, _.add = function(r, u) {
|
|
434
|
+
var f, p = this;
|
|
435
|
+
r = Number(r);
|
|
436
|
+
var m = T.p(u), h = function(e) {
|
|
437
|
+
var t = w(p);
|
|
438
|
+
return T.w(t.date(t.date() + Math.round(e * r)), p);
|
|
439
|
+
};
|
|
440
|
+
if (m === l) return this.set(l, this.$M + r);
|
|
441
|
+
if (m === d) return this.set(d, this.$y + r);
|
|
442
|
+
if (m === s) return h(1);
|
|
443
|
+
if (m === c) return h(7);
|
|
444
|
+
var g = (f = {}, f[a] = t, f[o] = n, f[i] = e, f)[m] || 1, _ = this.$d.getTime() + r * g;
|
|
445
|
+
return T.w(_, this);
|
|
446
|
+
}, _.subtract = function(e, t) {
|
|
447
|
+
return this.add(-1 * e, t);
|
|
448
|
+
}, _.format = function(e) {
|
|
449
|
+
var t = this, n = this.$locale();
|
|
450
|
+
if (!this.isValid()) return n.invalidDate || p;
|
|
451
|
+
var r = e || "YYYY-MM-DDTHH:mm:ssZ", i = T.z(this), a = this.$H, o = this.$m, s = this.$M, c = n.weekdays, l = n.months, u = n.meridiem, d = function(e, n, i, a) {
|
|
452
|
+
return e && (e[n] || e(t, r)) || i[n].slice(0, a);
|
|
453
|
+
}, f = function(e) {
|
|
454
|
+
return T.s(a % 12 || 12, e, "0");
|
|
455
|
+
}, m = u || function(e, t, n) {
|
|
456
|
+
var r = e < 12 ? "AM" : "PM";
|
|
457
|
+
return n ? r.toLowerCase() : r;
|
|
458
|
+
};
|
|
459
|
+
return r.replace(h, (function(e, r) {
|
|
460
|
+
return r || function(e) {
|
|
461
|
+
switch (e) {
|
|
462
|
+
case "YY": return String(t.$y).slice(-2);
|
|
463
|
+
case "YYYY": return T.s(t.$y, 4, "0");
|
|
464
|
+
case "M": return s + 1;
|
|
465
|
+
case "MM": return T.s(s + 1, 2, "0");
|
|
466
|
+
case "MMM": return d(n.monthsShort, s, l, 3);
|
|
467
|
+
case "MMMM": return d(l, s);
|
|
468
|
+
case "D": return t.$D;
|
|
469
|
+
case "DD": return T.s(t.$D, 2, "0");
|
|
470
|
+
case "d": return String(t.$W);
|
|
471
|
+
case "dd": return d(n.weekdaysMin, t.$W, c, 2);
|
|
472
|
+
case "ddd": return d(n.weekdaysShort, t.$W, c, 3);
|
|
473
|
+
case "dddd": return c[t.$W];
|
|
474
|
+
case "H": return String(a);
|
|
475
|
+
case "HH": return T.s(a, 2, "0");
|
|
476
|
+
case "h": return f(1);
|
|
477
|
+
case "hh": return f(2);
|
|
478
|
+
case "a": return m(a, o, !0);
|
|
479
|
+
case "A": return m(a, o, !1);
|
|
480
|
+
case "m": return String(o);
|
|
481
|
+
case "mm": return T.s(o, 2, "0");
|
|
482
|
+
case "s": return String(t.$s);
|
|
483
|
+
case "ss": return T.s(t.$s, 2, "0");
|
|
484
|
+
case "SSS": return T.s(t.$ms, 3, "0");
|
|
485
|
+
case "Z": return i;
|
|
486
|
+
}
|
|
487
|
+
return null;
|
|
488
|
+
}(e) || i.replace(":", "");
|
|
489
|
+
}));
|
|
490
|
+
}, _.utcOffset = function() {
|
|
491
|
+
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
|
|
492
|
+
}, _.diff = function(r, f, p) {
|
|
493
|
+
var m, h = this, g = T.p(f), _ = w(r), v = (_.utcOffset() - this.utcOffset()) * t, y = this - _, b = function() {
|
|
494
|
+
return T.m(h, _);
|
|
495
|
+
};
|
|
496
|
+
switch (g) {
|
|
497
|
+
case d:
|
|
498
|
+
m = b() / 12;
|
|
499
|
+
break;
|
|
500
|
+
case l:
|
|
501
|
+
m = b();
|
|
502
|
+
break;
|
|
503
|
+
case u:
|
|
504
|
+
m = b() / 3;
|
|
505
|
+
break;
|
|
506
|
+
case c:
|
|
507
|
+
m = (y - v) / 6048e5;
|
|
508
|
+
break;
|
|
509
|
+
case s:
|
|
510
|
+
m = (y - v) / 864e5;
|
|
511
|
+
break;
|
|
512
|
+
case o:
|
|
513
|
+
m = y / n;
|
|
514
|
+
break;
|
|
515
|
+
case a:
|
|
516
|
+
m = y / t;
|
|
517
|
+
break;
|
|
518
|
+
case i:
|
|
519
|
+
m = y / e;
|
|
520
|
+
break;
|
|
521
|
+
default: m = y;
|
|
522
|
+
}
|
|
523
|
+
return p ? m : T.a(m);
|
|
524
|
+
}, _.daysInMonth = function() {
|
|
525
|
+
return this.endOf(l).$D;
|
|
526
|
+
}, _.$locale = function() {
|
|
527
|
+
return b[this.$L];
|
|
528
|
+
}, _.locale = function(e, t) {
|
|
529
|
+
if (!e) return this.$L;
|
|
530
|
+
var n = this.clone(), r = C(e, t, !0);
|
|
531
|
+
return r && (n.$L = r), n;
|
|
532
|
+
}, _.clone = function() {
|
|
533
|
+
return T.w(this.$d, this);
|
|
534
|
+
}, _.toDate = function() {
|
|
535
|
+
return new Date(this.valueOf());
|
|
536
|
+
}, _.toJSON = function() {
|
|
537
|
+
return this.isValid() ? this.toISOString() : null;
|
|
538
|
+
}, _.toISOString = function() {
|
|
539
|
+
return this.$d.toISOString();
|
|
540
|
+
}, _.toString = function() {
|
|
541
|
+
return this.$d.toUTCString();
|
|
542
|
+
}, g;
|
|
543
|
+
}(), D = E.prototype;
|
|
544
|
+
return w.prototype = D, [
|
|
545
|
+
["$ms", r],
|
|
546
|
+
["$s", i],
|
|
547
|
+
["$m", a],
|
|
548
|
+
["$H", o],
|
|
549
|
+
["$W", s],
|
|
550
|
+
["$M", l],
|
|
551
|
+
["$y", d],
|
|
552
|
+
["$D", f]
|
|
553
|
+
].forEach((function(e) {
|
|
554
|
+
D[e[1]] = function(t) {
|
|
555
|
+
return this.$g(t, e[0], e[1]);
|
|
556
|
+
};
|
|
557
|
+
})), w.extend = function(e, t) {
|
|
558
|
+
return e.$i ||= (e(t, E, w), !0), w;
|
|
559
|
+
}, w.locale = C, w.isDayjs = S, w.unix = function(e) {
|
|
560
|
+
return w(1e3 * e);
|
|
561
|
+
}, w.en = b[y], w.Ls = b, w.p = {}, w;
|
|
562
|
+
}));
|
|
563
|
+
})), h = /* @__PURE__ */ s(((e, t) => {
|
|
564
|
+
(function(n, r) {
|
|
565
|
+
typeof e == "object" && t !== void 0 ? t.exports = r() : typeof define == "function" && define.amd ? define(r) : (n = typeof globalThis < "u" ? globalThis : n || self).dayjs_plugin_customParseFormat = r();
|
|
566
|
+
})(e, (function() {
|
|
567
|
+
var e = {
|
|
568
|
+
LTS: "h:mm:ss A",
|
|
569
|
+
LT: "h:mm A",
|
|
570
|
+
L: "MM/DD/YYYY",
|
|
571
|
+
LL: "MMMM D, YYYY",
|
|
572
|
+
LLL: "MMMM D, YYYY h:mm A",
|
|
573
|
+
LLLL: "dddd, MMMM D, YYYY h:mm A"
|
|
574
|
+
}, t = /(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g, n = /\d/, r = /\d\d/, i = /\d\d?/, a = /\d*[^-_:/,()\s\d]+/, o = {}, s = function(e) {
|
|
575
|
+
return (e = +e) + (e > 68 ? 1900 : 2e3);
|
|
576
|
+
}, c = function(e) {
|
|
577
|
+
return function(t) {
|
|
578
|
+
this[e] = +t;
|
|
579
|
+
};
|
|
580
|
+
}, l = [/[+-]\d\d:?(\d\d)?|Z/, function(e) {
|
|
581
|
+
(this.zone ||= {}).offset = function(e) {
|
|
582
|
+
if (!e || e === "Z") return 0;
|
|
583
|
+
var t = e.match(/([+-]|\d\d)/g), n = 60 * t[1] + (+t[2] || 0);
|
|
584
|
+
return n === 0 ? 0 : t[0] === "+" ? -n : n;
|
|
585
|
+
}(e);
|
|
586
|
+
}], u = function(e) {
|
|
587
|
+
var t = o[e];
|
|
588
|
+
return t && (t.indexOf ? t : t.s.concat(t.f));
|
|
589
|
+
}, d = function(e, t) {
|
|
590
|
+
var n, r = o.meridiem;
|
|
591
|
+
if (r) {
|
|
592
|
+
for (var i = 1; i <= 24; i += 1) if (e.indexOf(r(i, 0, t)) > -1) {
|
|
593
|
+
n = i > 12;
|
|
594
|
+
break;
|
|
595
|
+
}
|
|
596
|
+
} else n = e === (t ? "pm" : "PM");
|
|
597
|
+
return n;
|
|
598
|
+
}, f = {
|
|
599
|
+
A: [a, function(e) {
|
|
600
|
+
this.afternoon = d(e, !1);
|
|
601
|
+
}],
|
|
602
|
+
a: [a, function(e) {
|
|
603
|
+
this.afternoon = d(e, !0);
|
|
604
|
+
}],
|
|
605
|
+
Q: [n, function(e) {
|
|
606
|
+
this.month = 3 * (e - 1) + 1;
|
|
607
|
+
}],
|
|
608
|
+
S: [n, function(e) {
|
|
609
|
+
this.milliseconds = 100 * e;
|
|
610
|
+
}],
|
|
611
|
+
SS: [r, function(e) {
|
|
612
|
+
this.milliseconds = 10 * e;
|
|
613
|
+
}],
|
|
614
|
+
SSS: [/\d{3}/, function(e) {
|
|
615
|
+
this.milliseconds = +e;
|
|
616
|
+
}],
|
|
617
|
+
s: [i, c("seconds")],
|
|
618
|
+
ss: [i, c("seconds")],
|
|
619
|
+
m: [i, c("minutes")],
|
|
620
|
+
mm: [i, c("minutes")],
|
|
621
|
+
H: [i, c("hours")],
|
|
622
|
+
h: [i, c("hours")],
|
|
623
|
+
HH: [i, c("hours")],
|
|
624
|
+
hh: [i, c("hours")],
|
|
625
|
+
D: [i, c("day")],
|
|
626
|
+
DD: [r, c("day")],
|
|
627
|
+
Do: [a, function(e) {
|
|
628
|
+
var t = o.ordinal, n = e.match(/\d+/);
|
|
629
|
+
if (this.day = n[0], t) for (var r = 1; r <= 31; r += 1) t(r).replace(/\[|\]/g, "") === e && (this.day = r);
|
|
630
|
+
}],
|
|
631
|
+
w: [i, c("week")],
|
|
632
|
+
ww: [r, c("week")],
|
|
633
|
+
M: [i, c("month")],
|
|
634
|
+
MM: [r, c("month")],
|
|
635
|
+
MMM: [a, function(e) {
|
|
636
|
+
var t = u("months"), n = (u("monthsShort") || t.map((function(e) {
|
|
637
|
+
return e.slice(0, 3);
|
|
638
|
+
}))).indexOf(e) + 1;
|
|
639
|
+
if (n < 1) throw Error();
|
|
640
|
+
this.month = n % 12 || n;
|
|
641
|
+
}],
|
|
642
|
+
MMMM: [a, function(e) {
|
|
643
|
+
var t = u("months").indexOf(e) + 1;
|
|
644
|
+
if (t < 1) throw Error();
|
|
645
|
+
this.month = t % 12 || t;
|
|
646
|
+
}],
|
|
647
|
+
Y: [/[+-]?\d+/, c("year")],
|
|
648
|
+
YY: [r, function(e) {
|
|
649
|
+
this.year = s(e);
|
|
650
|
+
}],
|
|
651
|
+
YYYY: [/\d{4}/, c("year")],
|
|
652
|
+
Z: l,
|
|
653
|
+
ZZ: l
|
|
654
|
+
};
|
|
655
|
+
function p(n) {
|
|
656
|
+
for (var r = n, i = o && o.formats, a = (n = r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, (function(t, n, r) {
|
|
657
|
+
var a = r && r.toUpperCase();
|
|
658
|
+
return n || i[r] || e[r] || i[a].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, (function(e, t, n) {
|
|
659
|
+
return t || n.slice(1);
|
|
660
|
+
}));
|
|
661
|
+
}))).match(t), s = a.length, c = 0; c < s; c += 1) {
|
|
662
|
+
var l = a[c], u = f[l], d = u && u[0], p = u && u[1];
|
|
663
|
+
a[c] = p ? {
|
|
664
|
+
regex: d,
|
|
665
|
+
parser: p
|
|
666
|
+
} : l.replace(/^\[|\]$/g, "");
|
|
667
|
+
}
|
|
668
|
+
return function(e) {
|
|
669
|
+
for (var t = {}, n = 0, r = 0; n < s; n += 1) {
|
|
670
|
+
var i = a[n];
|
|
671
|
+
if (typeof i == "string") r += i.length;
|
|
672
|
+
else {
|
|
673
|
+
var o = i.regex, c = i.parser, l = e.slice(r), u = o.exec(l)[0];
|
|
674
|
+
c.call(t, u), e = e.replace(u, "");
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
return function(e) {
|
|
678
|
+
var t = e.afternoon;
|
|
679
|
+
if (t !== void 0) {
|
|
680
|
+
var n = e.hours;
|
|
681
|
+
t ? n < 12 && (e.hours += 12) : n === 12 && (e.hours = 0), delete e.afternoon;
|
|
682
|
+
}
|
|
683
|
+
}(t), t;
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
return function(e, t, n) {
|
|
687
|
+
n.p.customParseFormat = !0, e && e.parseTwoDigitYear && (s = e.parseTwoDigitYear);
|
|
688
|
+
var r = t.prototype, i = r.parse;
|
|
689
|
+
r.parse = function(e) {
|
|
690
|
+
var t = e.date, r = e.utc, a = e.args;
|
|
691
|
+
this.$u = r;
|
|
692
|
+
var s = a[1];
|
|
693
|
+
if (typeof s == "string") {
|
|
694
|
+
var c = !0 === a[2], l = !0 === a[3], u = c || l, d = a[2];
|
|
695
|
+
l && (d = a[2]), o = this.$locale(), !c && d && (o = n.Ls[d]), this.$d = function(e, t, n, r) {
|
|
696
|
+
try {
|
|
697
|
+
if (["x", "X"].indexOf(t) > -1) return /* @__PURE__ */ new Date((t === "X" ? 1e3 : 1) * e);
|
|
698
|
+
var i = p(t)(e), a = i.year, o = i.month, s = i.day, c = i.hours, l = i.minutes, u = i.seconds, d = i.milliseconds, f = i.zone, m = i.week, h = /* @__PURE__ */ new Date(), g = s || (a || o ? 1 : h.getDate()), _ = a || h.getFullYear(), v = 0;
|
|
699
|
+
a && !o || (v = o > 0 ? o - 1 : h.getMonth());
|
|
700
|
+
var y, b = c || 0, x = l || 0, S = u || 0, C = d || 0;
|
|
701
|
+
return f ? new Date(Date.UTC(_, v, g, b, x, S, C + 60 * f.offset * 1e3)) : n ? new Date(Date.UTC(_, v, g, b, x, S, C)) : (y = new Date(_, v, g, b, x, S, C), m && (y = r(y).week(m).toDate()), y);
|
|
702
|
+
} catch {
|
|
703
|
+
return /* @__PURE__ */ new Date("");
|
|
704
|
+
}
|
|
705
|
+
}(t, s, r, n), this.init(), d && !0 !== d && (this.$L = this.locale(d).$L), u && t != this.format(s) && (this.$d = /* @__PURE__ */ new Date("")), o = {};
|
|
706
|
+
} else if (s instanceof Array) for (var f = s.length, m = 1; m <= f; m += 1) {
|
|
707
|
+
a[1] = s[m - 1];
|
|
708
|
+
var h = n.apply(this, a);
|
|
709
|
+
if (h.isValid()) {
|
|
710
|
+
this.$d = h.$d, this.$L = h.$L, this.init();
|
|
711
|
+
break;
|
|
712
|
+
}
|
|
713
|
+
m === f && (this.$d = /* @__PURE__ */ new Date(""));
|
|
714
|
+
}
|
|
715
|
+
else i.call(this, e);
|
|
716
|
+
};
|
|
717
|
+
};
|
|
718
|
+
}));
|
|
719
|
+
})), g = /* @__PURE__ */ l(m(), 1), _ = /* @__PURE__ */ l(h(), 1);
|
|
720
|
+
g.default.extend(_.default);
|
|
721
|
+
var v = class extends p {
|
|
722
|
+
checkUnsupportedOptions() {
|
|
723
|
+
this.context.options.source !== void 0 && console.error(`${this.constructor.name} does not support the "source" option — it only applies to type: 'select'. It will be ignored.`);
|
|
724
|
+
}
|
|
725
|
+
create() {
|
|
726
|
+
let e = this.createElement("input");
|
|
727
|
+
return e.type = "date", this.createContainer(e);
|
|
728
|
+
}
|
|
729
|
+
initText() {
|
|
730
|
+
let e = this.context.getValue();
|
|
731
|
+
if (e === "") return this.context.element.textContent = this.context.options.emptyText || "", !0;
|
|
732
|
+
{
|
|
733
|
+
let t = (0, g.default)(e, this.context.options.format).format(this.context.options.displayFormat);
|
|
734
|
+
return this.context.element.textContent = this.context.options.render ? this.context.options.render(t, this.context) : t, !1;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
initOptions() {
|
|
738
|
+
let e = "YYYY-MM-DD", t = this.context.get_opt("format", e), n = this.context.get_opt("displayFormat", e);
|
|
739
|
+
this.context.setValue((0, g.default)(this.context.getValue(), n).format(t));
|
|
740
|
+
}
|
|
741
|
+
}, y = class extends v {
|
|
742
|
+
create() {
|
|
743
|
+
let e = this.createElement("input");
|
|
744
|
+
return e.type = "datetime-local", this.createContainer(e);
|
|
745
|
+
}
|
|
746
|
+
initOptions() {
|
|
747
|
+
let e = "YYYY-MM-DDTHH:mm", t = this.context.get_opt("format", e), n = this.context.get_opt("displayFormat", e);
|
|
748
|
+
this.context.setValue((0, g.default)(this.context.getValue(), n).format(t));
|
|
749
|
+
}
|
|
750
|
+
}, b = class extends p {
|
|
751
|
+
create() {
|
|
752
|
+
let e = this.createElement("input"), { options: t = {} } = this.context;
|
|
753
|
+
return e.type = typeof t.type == "string" ? t.type : "text", this.createContainer(e);
|
|
754
|
+
}
|
|
755
|
+
}, x = class extends p {
|
|
756
|
+
checkUnsupportedOptions() {
|
|
757
|
+
this.context.options.format !== void 0 && console.error(`${this.constructor.name} does not support the "format" option — it only applies to type: 'date'/'datetime'. It will be ignored.`), this.context.options.displayFormat !== void 0 && console.error(`${this.constructor.name} does not support the "displayFormat" option — it only applies to type: 'date'/'datetime'. It will be ignored.`);
|
|
758
|
+
}
|
|
759
|
+
create() {
|
|
760
|
+
let e = this.createElement("select");
|
|
761
|
+
return this.context.options.source && Array.isArray(this.context.options.source) && this.context.options.source.forEach((t) => {
|
|
762
|
+
let n = document.createElement("option");
|
|
763
|
+
n.value = String(t.value), n.textContent = t.text, e.append(n);
|
|
764
|
+
}), this.createContainer(e);
|
|
765
|
+
}
|
|
766
|
+
initText() {
|
|
767
|
+
if (this.context.element.textContent = this.context.options.emptyText || "", this.context.getValue() !== "" && this.context.options.source && Array.isArray(this.context.options.source) && this.context.options.source.length > 0) for (let e = 0; e < this.context.options.source.length; e++) {
|
|
768
|
+
let t = this.context.options.source[e];
|
|
769
|
+
if (String(t.value) === this.context.getValue()) return this.context.element.textContent = this.context.options.render ? this.context.options.render(t.text, this.context) : t.text, !1;
|
|
770
|
+
}
|
|
771
|
+
return !0;
|
|
772
|
+
}
|
|
773
|
+
initOptions() {
|
|
774
|
+
if (this.context.get_opt("source", []), this.context.options && typeof this.context.options.source == "string" && this.context.options.source !== "") try {
|
|
775
|
+
this.context.options.source = JSON.parse(this.context.options.source);
|
|
776
|
+
} catch (e) {
|
|
777
|
+
let t = this.context.element, n = t.id ? `#${t.id}` : `<${t.tagName.toLowerCase()}>`;
|
|
778
|
+
throw Error(`Invalid JSON in "source" option/data-source attribute on ${n}: ${e.message}`);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}, S = class extends p {
|
|
782
|
+
create() {
|
|
783
|
+
let e = this.createElement("textarea");
|
|
784
|
+
return this.createContainer(e);
|
|
785
|
+
}
|
|
786
|
+
}, C = class e {
|
|
787
|
+
static BaseType = p;
|
|
788
|
+
static BaseMode = u;
|
|
789
|
+
static InputType = b;
|
|
790
|
+
static TextAreaType = S;
|
|
791
|
+
static SelectType = x;
|
|
792
|
+
static DateType = v;
|
|
793
|
+
static DateTimeType = y;
|
|
794
|
+
static PopupMode = f;
|
|
795
|
+
static InlineMode = d;
|
|
796
|
+
static types = /* @__PURE__ */ new Map([
|
|
797
|
+
["text", b],
|
|
798
|
+
["password", b],
|
|
799
|
+
["email", b],
|
|
800
|
+
["url", b],
|
|
801
|
+
["tel", b],
|
|
802
|
+
["number", b],
|
|
803
|
+
["range", b],
|
|
804
|
+
["time", b],
|
|
805
|
+
["textarea", S],
|
|
806
|
+
["select", x],
|
|
807
|
+
["date", v],
|
|
808
|
+
["datetime", y]
|
|
809
|
+
]);
|
|
810
|
+
static modes = /* @__PURE__ */ new Map([["popup", f], ["inline", d]]);
|
|
811
|
+
static registerType(t, n) {
|
|
812
|
+
e.types.set(t, n);
|
|
813
|
+
}
|
|
814
|
+
static registerMode(t, n) {
|
|
815
|
+
e.modes.set(t, n);
|
|
816
|
+
}
|
|
817
|
+
element;
|
|
818
|
+
options;
|
|
819
|
+
typeElement;
|
|
820
|
+
modeElement;
|
|
821
|
+
accessibilityAbortController = new AbortController();
|
|
822
|
+
constructor(e, t = {}) {
|
|
823
|
+
this.element = e, this.options = { ...t }, this.init_options(), this.typeElement = this.route_type(), this.typeElement.checkUnsupportedOptions(), this.typeElement.initOptions(), this.modeElement = this.route_mode(), this.modeElement.init(), this.init_text(), this.init_style(), this.init_accessibility(), this.element.dispatchEvent(new CustomEvent("init", { detail: { Editable: this } }));
|
|
824
|
+
}
|
|
825
|
+
readOption(e) {
|
|
826
|
+
return this.options[e];
|
|
827
|
+
}
|
|
828
|
+
writeOption(e, t) {
|
|
829
|
+
this.options[e] = t;
|
|
830
|
+
}
|
|
831
|
+
get_opt(e, t) {
|
|
832
|
+
let n = this.element.dataset?.[e] ?? this.readOption(e) ?? t;
|
|
833
|
+
return this.writeOption(e, n), n;
|
|
834
|
+
}
|
|
835
|
+
get_opt_object(e, t) {
|
|
836
|
+
this.writeOption(e, this.readOption(e) ?? t);
|
|
837
|
+
}
|
|
838
|
+
get_opt_bool(e, t) {
|
|
839
|
+
if (this.get_opt(e, t), typeof this.readOption(e) != "boolean") {
|
|
840
|
+
if (this.readOption(e) === "true") {
|
|
841
|
+
this.writeOption(e, !0);
|
|
842
|
+
return;
|
|
843
|
+
}
|
|
844
|
+
if (this.readOption(e) === "false") {
|
|
845
|
+
this.writeOption(e, !1);
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
this.writeOption(e, t);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
init_options() {
|
|
852
|
+
this.get_opt("value", this.element.textContent ?? ""), this.get_opt("name", this.element.id || "value"), this.get_opt("title", ""), this.get_opt("type", "text"), this.get_opt("emptyText", "Empty"), this.get_opt("mode", "popup"), this.get_opt("url", null), this.get_opt_object("ajaxOptions", {}), this.options.ajaxOptions = Object.assign({ method: "POST" }, this.options.ajaxOptions), this.get_opt_bool("send", !0), this.get_opt_bool("required", !1), this.get_opt_bool("showButtons", !0), this.options?.success && typeof this.options?.success == "function" && (this.success = this.options.success), this.options?.error && typeof this.options?.error == "function" && (this.error = this.options.error), this.get_opt_object("attributes", {}), this.get_opt_object("popoverOptions", {});
|
|
853
|
+
}
|
|
854
|
+
init_text() {
|
|
855
|
+
let e = "editable-element-empty";
|
|
856
|
+
this.element.classList.remove(e), this.typeElement.initText() && this.element.classList.add(e);
|
|
857
|
+
}
|
|
858
|
+
init_style() {
|
|
859
|
+
this.element.classList.add("editable-element");
|
|
860
|
+
}
|
|
861
|
+
init_accessibility() {
|
|
862
|
+
let e = this.element;
|
|
863
|
+
e.tagName === "BUTTON" || e.tagName === "INPUT" || e.tagName === "SELECT" || e.tagName === "TEXTAREA" || e.tagName === "A" && e.hasAttribute("href") || (e.hasAttribute("tabindex") || (e.tabIndex = 0), e.hasAttribute("role") || e.setAttribute("role", "button"), e.addEventListener("keydown", (t) => {
|
|
864
|
+
t.target === e && (t.key === "Enter" || t.key === " ") && (t.preventDefault(), e.click());
|
|
865
|
+
}, { signal: this.accessibilityAbortController.signal }));
|
|
866
|
+
}
|
|
867
|
+
route_mode() {
|
|
868
|
+
let t = e.modes.get(this.options.mode);
|
|
869
|
+
if (!t) throw Error(`Mode "${this.options.mode}" is not registered. Available modes: ${[...e.modes.keys()].join(", ")}. Register custom modes via Editable.registerMode(name, ModeClass).`);
|
|
870
|
+
return new t(this);
|
|
871
|
+
}
|
|
872
|
+
route_type() {
|
|
873
|
+
if (this.options.type && typeof this.options.type != "string") return new this.options.type(this);
|
|
874
|
+
let t = e.types.get(this.options.type);
|
|
875
|
+
if (!t) throw Error(`Type "${this.options.type}" is not registered. Available types: ${[...e.types.keys()].join(", ")}. Register custom types via Editable.registerType(name, TypeClass).`);
|
|
876
|
+
return new t(this);
|
|
877
|
+
}
|
|
878
|
+
async success(e, t) {
|
|
879
|
+
return await this.typeElement.successResponse(e, t);
|
|
880
|
+
}
|
|
881
|
+
async error(e, t) {
|
|
882
|
+
return await this.typeElement.errorResponse(e, t);
|
|
883
|
+
}
|
|
884
|
+
enable() {
|
|
885
|
+
this.element.classList.remove("editable-element-disabled"), this.modeElement.enable();
|
|
886
|
+
}
|
|
887
|
+
disable() {
|
|
888
|
+
this.element.classList.add("editable-element-disabled"), this.modeElement.disable();
|
|
889
|
+
}
|
|
890
|
+
setValue(e) {
|
|
891
|
+
this.options.value = e, this.init_text();
|
|
892
|
+
}
|
|
893
|
+
getValue() {
|
|
894
|
+
return this.options.value ?? "";
|
|
895
|
+
}
|
|
896
|
+
getOption(e) {
|
|
897
|
+
return this.readOption(e) ?? null;
|
|
898
|
+
}
|
|
899
|
+
destroy() {
|
|
900
|
+
this.accessibilityAbortController.abort(), this.modeElement.destroy(), this.element.classList.remove("editable-element", "editable-element-disabled", "editable-element-empty");
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
//#endregion
|
|
904
|
+
export { C as default };
|
|
905
|
+
|
|
906
|
+
//# sourceMappingURL=editable.js.map
|