arethesis 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/{arethesis-DTJOJ7F-.js → arethesis-D0-ZaXOM.js} +569 -415
- package/dist/arethesis-D0-ZaXOM.js.map +1 -0
- package/dist/arethesis.js +1 -1
- package/dist/components.js +2 -5
- package/dist/components.js.map +1 -1
- package/dist/core/arethesis.d.ts +1 -1
- package/dist/mixins/registry.d.ts.map +1 -1
- package/dist/mixins/sortable.d.ts.map +1 -1
- package/dist/mixins/types.d.ts +8 -0
- package/dist/mixins/types.d.ts.map +1 -1
- package/dist/theme.css +4 -2
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/arethesis-DTJOJ7F-.js.map +0 -1
|
@@ -827,11 +827,11 @@ function S(e, t, n, i) {
|
|
|
827
827
|
};
|
|
828
828
|
}
|
|
829
829
|
// src/utils/backoff.ts
|
|
830
|
-
function
|
|
830
|
+
function ee(e, t = {}, n = Math.random) {
|
|
831
831
|
let r = t.baseDelay ?? 1e3, i = t.maxDelay ?? 3e4, a = t.jitter ?? .3, o = Math.min(r * 2 ** e, i);
|
|
832
832
|
return Math.min(o + n() * a * o, i);
|
|
833
833
|
}
|
|
834
|
-
function
|
|
834
|
+
function te(e, t) {
|
|
835
835
|
return new Promise((n, r) => {
|
|
836
836
|
if (t?.aborted) {
|
|
837
837
|
r(t.reason ?? new DOMException("Aborted", "AbortError"));
|
|
@@ -846,7 +846,7 @@ function ee(e, t) {
|
|
|
846
846
|
});
|
|
847
847
|
}
|
|
848
848
|
// src/http/http-client.ts
|
|
849
|
-
var
|
|
849
|
+
var ne = {
|
|
850
850
|
maxAttempts: 3,
|
|
851
851
|
baseDelay: 500,
|
|
852
852
|
maxDelay: 1e4,
|
|
@@ -861,20 +861,20 @@ var te = {
|
|
|
861
861
|
504
|
|
862
862
|
],
|
|
863
863
|
retryNonIdempotent: !1
|
|
864
|
-
},
|
|
864
|
+
}, re = /* @__PURE__ */ new Set([
|
|
865
865
|
"GET",
|
|
866
866
|
"HEAD",
|
|
867
867
|
"PUT",
|
|
868
868
|
"DELETE",
|
|
869
869
|
"OPTIONS"
|
|
870
870
|
]);
|
|
871
|
-
function
|
|
871
|
+
function ie(e) {
|
|
872
872
|
return typeof e == "string" || typeof FormData < "u" && e instanceof FormData || typeof Blob < "u" && e instanceof Blob || typeof URLSearchParams < "u" && e instanceof URLSearchParams || e instanceof ArrayBuffer || ArrayBuffer.isView(e);
|
|
873
873
|
}
|
|
874
|
-
function
|
|
874
|
+
function ae(e) {
|
|
875
875
|
return e instanceof Error && e.name === "AbortError";
|
|
876
876
|
}
|
|
877
|
-
var
|
|
877
|
+
var C = class {
|
|
878
878
|
config = {};
|
|
879
879
|
endpoints = /* @__PURE__ */ new Map();
|
|
880
880
|
auth = null;
|
|
@@ -975,23 +975,23 @@ var ae = class {
|
|
|
975
975
|
}
|
|
976
976
|
async requestWithRetry(e, t, n) {
|
|
977
977
|
let r = n.retry === !1 || this.config.retry === !1 ? {
|
|
978
|
-
...
|
|
978
|
+
...ne,
|
|
979
979
|
maxAttempts: 1
|
|
980
980
|
} : {
|
|
981
|
-
...
|
|
981
|
+
...ne,
|
|
982
982
|
...this.config.retry,
|
|
983
983
|
...n.retry
|
|
984
|
-
}, i =
|
|
984
|
+
}, i = re.has(t) || r.retryNonIdempotent, a = 0, o = !1;
|
|
985
985
|
for (;;) try {
|
|
986
986
|
return await this.send(e, t, n, a);
|
|
987
987
|
} catch (e) {
|
|
988
|
-
if (
|
|
988
|
+
if (ae(e)) throw e;
|
|
989
989
|
let t = e;
|
|
990
990
|
if (t.status === 401 && !o && n.auth !== !1 && this.auth?.getRefreshToken() && (o = !0, await this.auth.refreshAccessToken())) continue;
|
|
991
991
|
a++;
|
|
992
992
|
let s = t.kind === "network" || t.kind === "timeout" || r.retryOn.includes(t.status);
|
|
993
993
|
if (!i || !s || t.kind === "parse" || a >= r.maxAttempts) throw t;
|
|
994
|
-
await
|
|
994
|
+
await te(t.retryAfter === void 0 ? ee(a - 1, r) : Math.min(t.retryAfter * 1e3, r.maxDelay), n.signal);
|
|
995
995
|
}
|
|
996
996
|
}
|
|
997
997
|
async send(e, t, n, r) {
|
|
@@ -1001,7 +1001,7 @@ var ae = class {
|
|
|
1001
1001
|
e && (i.Authorization = `Bearer ${e}`);
|
|
1002
1002
|
}
|
|
1003
1003
|
let a;
|
|
1004
|
-
n.body !== void 0 && (
|
|
1004
|
+
n.body !== void 0 && (ie(n.body) ? a = n.body : (a = JSON.stringify(n.body), Object.keys(i).some((e) => e.toLowerCase() === "content-type") || (i["Content-Type"] = "application/json")));
|
|
1005
1005
|
let o = new AbortController(), s = n.timeout ?? this.config.timeout ?? 3e4, c = !1, l = s > 0 ? setTimeout(() => {
|
|
1006
1006
|
c = !0, o.abort();
|
|
1007
1007
|
}, s) : void 0, u = () => o.abort(n.signal?.reason);
|
|
@@ -1174,7 +1174,7 @@ var ae = class {
|
|
|
1174
1174
|
url: t.url,
|
|
1175
1175
|
method: "POST",
|
|
1176
1176
|
body: o,
|
|
1177
|
-
retry: { retryNonIdempotent: a.every((e) =>
|
|
1177
|
+
retry: { retryNonIdempotent: a.every((e) => re.has(e.method)) }
|
|
1178
1178
|
}), c = t.parseResponse ? t.parseResponse(s) : Array.isArray(s) ? s : r(s, "results") ?? [], l = new Map(c.filter((e) => e.id !== void 0).map((e) => [e.id, e]));
|
|
1179
1179
|
a.forEach((e, t) => n.push(l.get(e.id) ?? c[t] ?? {
|
|
1180
1180
|
id: e.id,
|
|
@@ -1232,7 +1232,7 @@ function ce(e) {
|
|
|
1232
1232
|
let t = e.replace(/-/g, "+").replace(/_/g, "/"), n = t + "=".repeat((4 - t.length % 4) % 4), r = atob(n), i = Uint8Array.from(r, (e) => e.charCodeAt(0));
|
|
1233
1233
|
return new TextDecoder().decode(i);
|
|
1234
1234
|
}
|
|
1235
|
-
var
|
|
1235
|
+
var w = class extends f {
|
|
1236
1236
|
config;
|
|
1237
1237
|
storage;
|
|
1238
1238
|
refreshPromise = null;
|
|
@@ -1397,7 +1397,7 @@ var le = class extends f {
|
|
|
1397
1397
|
destroy() {
|
|
1398
1398
|
this.storageListener && window.removeEventListener("storage", this.storageListener), this.storageListener = null, this.clear();
|
|
1399
1399
|
}
|
|
1400
|
-
},
|
|
1400
|
+
}, T = class extends f {
|
|
1401
1401
|
options;
|
|
1402
1402
|
attempts = 0;
|
|
1403
1403
|
timer = null;
|
|
@@ -1420,7 +1420,7 @@ var le = class extends f {
|
|
|
1420
1420
|
schedule(e) {
|
|
1421
1421
|
if (this.options.reconnect === !1 || this.attempts >= (this.options.maxReconnectAttempts ?? Infinity)) return this.status = "closed", !1;
|
|
1422
1422
|
if (this.timer) return !0;
|
|
1423
|
-
let t =
|
|
1423
|
+
let t = ee(this.attempts, {
|
|
1424
1424
|
baseDelay: this.options.baseDelay ?? 1e3,
|
|
1425
1425
|
maxDelay: this.options.maxDelay ?? 3e4,
|
|
1426
1426
|
jitter: this.options.jitter ?? .3
|
|
@@ -1432,7 +1432,7 @@ var le = class extends f {
|
|
|
1432
1432
|
cancel() {
|
|
1433
1433
|
this.timer && clearTimeout(this.timer), this.timer = null, this.attempts = 0;
|
|
1434
1434
|
}
|
|
1435
|
-
},
|
|
1435
|
+
}, le = class {
|
|
1436
1436
|
config;
|
|
1437
1437
|
source = null;
|
|
1438
1438
|
store = null;
|
|
@@ -1444,7 +1444,7 @@ var le = class extends f {
|
|
|
1444
1444
|
handlers = new f();
|
|
1445
1445
|
customEvents = /* @__PURE__ */ new Set();
|
|
1446
1446
|
constructor(e) {
|
|
1447
|
-
this.config = e, this.policy = new
|
|
1447
|
+
this.config = e, this.policy = new T(e);
|
|
1448
1448
|
}
|
|
1449
1449
|
connectStore(e, t) {
|
|
1450
1450
|
this.store = e, this.listViews = t ?? null;
|
|
@@ -1556,7 +1556,7 @@ var le = class extends f {
|
|
|
1556
1556
|
disconnect() {
|
|
1557
1557
|
this.generation++, this.policy.cancel(), this.source?.close(), this.source = null, this.policy.status = "closed";
|
|
1558
1558
|
}
|
|
1559
|
-
},
|
|
1559
|
+
}, ue = /* @__PURE__ */ new Set(["ping", "pong"]), de = class {
|
|
1560
1560
|
config;
|
|
1561
1561
|
socket = null;
|
|
1562
1562
|
channels = /* @__PURE__ */ new Map();
|
|
@@ -1571,7 +1571,7 @@ var le = class extends f {
|
|
|
1571
1571
|
pingInterval: 3e4,
|
|
1572
1572
|
maxQueue: 1e3,
|
|
1573
1573
|
...e
|
|
1574
|
-
}, this.policy = new
|
|
1574
|
+
}, this.policy = new T(e);
|
|
1575
1575
|
}
|
|
1576
1576
|
setTokenProvider(e) {
|
|
1577
1577
|
this.getToken = e;
|
|
@@ -1626,7 +1626,7 @@ var le = class extends f {
|
|
|
1626
1626
|
console.error("WebSocket: ignoring non-JSON message");
|
|
1627
1627
|
return;
|
|
1628
1628
|
}
|
|
1629
|
-
t && typeof t.type == "string" && !
|
|
1629
|
+
t && typeof t.type == "string" && !ue.has(t.type) && this.dispatch(t);
|
|
1630
1630
|
};
|
|
1631
1631
|
}
|
|
1632
1632
|
dispatch(e) {
|
|
@@ -1692,7 +1692,7 @@ var le = class extends f {
|
|
|
1692
1692
|
}
|
|
1693
1693
|
this.policy.status = "closed";
|
|
1694
1694
|
}
|
|
1695
|
-
},
|
|
1695
|
+
}, fe = "json.webpubsub.azure.v1", pe = class {
|
|
1696
1696
|
config;
|
|
1697
1697
|
socket = null;
|
|
1698
1698
|
channels = /* @__PURE__ */ new Map();
|
|
@@ -1713,7 +1713,7 @@ var le = class extends f {
|
|
|
1713
1713
|
ackTimeout: 15e3,
|
|
1714
1714
|
autoJoinGroups: [],
|
|
1715
1715
|
...e
|
|
1716
|
-
}, this.policy = new
|
|
1716
|
+
}, this.policy = new T(e);
|
|
1717
1717
|
}
|
|
1718
1718
|
connectStore(e, t) {
|
|
1719
1719
|
this.store = e, this.listViews = t ?? null;
|
|
@@ -1749,7 +1749,7 @@ var le = class extends f {
|
|
|
1749
1749
|
return;
|
|
1750
1750
|
}
|
|
1751
1751
|
if (e !== this.generation) return;
|
|
1752
|
-
let n = this.config.socketFactory ? this.config.socketFactory(t,
|
|
1752
|
+
let n = this.config.socketFactory ? this.config.socketFactory(t, fe) : new WebSocket(t, fe);
|
|
1753
1753
|
this.socket = n, n.onmessage = (e) => {
|
|
1754
1754
|
if (this.socket !== n) return;
|
|
1755
1755
|
let t;
|
|
@@ -1901,11 +1901,11 @@ var le = class extends f {
|
|
|
1901
1901
|
}
|
|
1902
1902
|
this.policy.status = "closed";
|
|
1903
1903
|
}
|
|
1904
|
-
},
|
|
1905
|
-
function
|
|
1904
|
+
}, E = (e) => typeof e == "number" && e > 0, me = (e) => typeof e == "number" && e < 0, D = (e) => typeof e == "string";
|
|
1905
|
+
function O(e) {
|
|
1906
1906
|
return e === void 0 ? "none" : typeof e == "string" ? "insert" : e > 0 ? "retain" : "delete";
|
|
1907
1907
|
}
|
|
1908
|
-
var
|
|
1908
|
+
var k = class e {
|
|
1909
1909
|
ops = [];
|
|
1910
1910
|
baseLength = 0;
|
|
1911
1911
|
targetLength = 0;
|
|
@@ -1914,16 +1914,16 @@ var D = class e {
|
|
|
1914
1914
|
if (e === 0) return this;
|
|
1915
1915
|
this.baseLength += e, this.targetLength += e;
|
|
1916
1916
|
let t = this.ops[this.ops.length - 1];
|
|
1917
|
-
return t !== void 0 &&
|
|
1917
|
+
return t !== void 0 && E(t) ? this.ops[this.ops.length - 1] = t + e : this.ops.push(e), this;
|
|
1918
1918
|
}
|
|
1919
1919
|
insert(e) {
|
|
1920
1920
|
if (e === "") return this;
|
|
1921
1921
|
this.targetLength += e.length;
|
|
1922
1922
|
let t = this.ops, n = t[t.length - 1];
|
|
1923
|
-
if (n !== void 0 &&
|
|
1924
|
-
else if (n !== void 0 &&
|
|
1923
|
+
if (n !== void 0 && D(n)) t[t.length - 1] = n + e;
|
|
1924
|
+
else if (n !== void 0 && me(n)) {
|
|
1925
1925
|
let r = t[t.length - 2];
|
|
1926
|
-
r !== void 0 &&
|
|
1926
|
+
r !== void 0 && D(r) ? t[t.length - 2] = r + e : (t[t.length] = n, t[t.length - 2] = e);
|
|
1927
1927
|
} else t.push(e);
|
|
1928
1928
|
return this;
|
|
1929
1929
|
}
|
|
@@ -1932,27 +1932,27 @@ var D = class e {
|
|
|
1932
1932
|
if (t === 0) return this;
|
|
1933
1933
|
this.baseLength += t;
|
|
1934
1934
|
let n = this.ops[this.ops.length - 1];
|
|
1935
|
-
return n !== void 0 &&
|
|
1935
|
+
return n !== void 0 && me(n) ? this.ops[this.ops.length - 1] = n - t : this.ops.push(-t), this;
|
|
1936
1936
|
}
|
|
1937
1937
|
isNoop() {
|
|
1938
|
-
return this.ops.length === 0 || this.ops.length === 1 &&
|
|
1938
|
+
return this.ops.length === 0 || this.ops.length === 1 && E(this.ops[0]);
|
|
1939
1939
|
}
|
|
1940
1940
|
apply(e) {
|
|
1941
1941
|
if (e.length !== this.baseLength) throw Error(`Operation base length ${this.baseLength} does not match document length ${e.length}`);
|
|
1942
1942
|
let t = [], n = 0;
|
|
1943
|
-
for (let r of this.ops)
|
|
1943
|
+
for (let r of this.ops) E(r) ? (t.push(e.slice(n, n + r)), n += r) : D(r) ? t.push(r) : n -= r;
|
|
1944
1944
|
return t.join("");
|
|
1945
1945
|
}
|
|
1946
1946
|
invert(t) {
|
|
1947
1947
|
let n = new e(), r = 0;
|
|
1948
|
-
for (let e of this.ops)
|
|
1948
|
+
for (let e of this.ops) E(e) ? (n.retain(e), r += e) : D(e) ? n.delete(e.length) : (n.insert(t.slice(r, r - e)), r -= e);
|
|
1949
1949
|
return n;
|
|
1950
1950
|
}
|
|
1951
1951
|
compose(t) {
|
|
1952
1952
|
if (this.targetLength !== t.baseLength) throw Error("compose: length mismatch");
|
|
1953
1953
|
let n = new e(), r = this.ops, i = t.ops, a = 0, o = 0, s = r[a++], c = i[o++];
|
|
1954
1954
|
for (;;) {
|
|
1955
|
-
let e =
|
|
1955
|
+
let e = O(s), t = O(c);
|
|
1956
1956
|
if (e === "none" && t === "none") break;
|
|
1957
1957
|
if (e === "delete") n.delete(s), s = r[a++];
|
|
1958
1958
|
else if (t === "insert") n.insert(c), c = i[o++];
|
|
@@ -1979,7 +1979,7 @@ var D = class e {
|
|
|
1979
1979
|
if (t.baseLength !== n.baseLength) throw Error("transform: operations must share a base");
|
|
1980
1980
|
let r = new e(), i = new e(), a = t.ops, o = n.ops, s = 0, c = 0, l = a[s++], u = o[c++];
|
|
1981
1981
|
for (;;) {
|
|
1982
|
-
let e =
|
|
1982
|
+
let e = O(l), t = O(u);
|
|
1983
1983
|
if (e === "none" && t === "none") break;
|
|
1984
1984
|
if (e === "insert") {
|
|
1985
1985
|
r.insert(l), i.retain(l.length), l = a[s++];
|
|
@@ -1999,7 +1999,7 @@ var D = class e {
|
|
|
1999
1999
|
let n = e, r = 0;
|
|
2000
2000
|
for (let i of this.ops) {
|
|
2001
2001
|
if (r > e) break;
|
|
2002
|
-
|
|
2002
|
+
E(i) ? r += i : D(i) ? (r < e || r === e && !t) && (n += i.length) : (n -= Math.min(-i, Math.max(0, e - r)), r -= i);
|
|
2003
2003
|
}
|
|
2004
2004
|
return n;
|
|
2005
2005
|
}
|
|
@@ -2025,9 +2025,9 @@ var D = class e {
|
|
|
2025
2025
|
return n;
|
|
2026
2026
|
}
|
|
2027
2027
|
toString() {
|
|
2028
|
-
return this.ops.map((e) =>
|
|
2028
|
+
return this.ops.map((e) => E(e) ? `retain ${e}` : D(e) ? `insert ${JSON.stringify(e)}` : `delete ${-e}`).join(", ");
|
|
2029
2029
|
}
|
|
2030
|
-
},
|
|
2030
|
+
}, he = class {
|
|
2031
2031
|
callbacks;
|
|
2032
2032
|
revision;
|
|
2033
2033
|
outstanding = null;
|
|
@@ -2045,9 +2045,9 @@ var D = class e {
|
|
|
2045
2045
|
this.revision++;
|
|
2046
2046
|
let t = e;
|
|
2047
2047
|
if (this.outstanding) {
|
|
2048
|
-
let [e, n] =
|
|
2048
|
+
let [e, n] = k.transform(this.outstanding, t);
|
|
2049
2049
|
if (this.outstanding = e, t = n, this.buffer) {
|
|
2050
|
-
let [e, n] =
|
|
2050
|
+
let [e, n] = k.transform(this.buffer, t);
|
|
2051
2051
|
this.buffer = e, t = n;
|
|
2052
2052
|
}
|
|
2053
2053
|
}
|
|
@@ -2064,7 +2064,7 @@ var D = class e {
|
|
|
2064
2064
|
let t = e;
|
|
2065
2065
|
return this.outstanding && (t = this.outstanding.transformIndex(t)), this.buffer && (t = this.buffer.transformIndex(t)), t;
|
|
2066
2066
|
}
|
|
2067
|
-
},
|
|
2067
|
+
}, ge = class {
|
|
2068
2068
|
element;
|
|
2069
2069
|
previous;
|
|
2070
2070
|
composing = !1;
|
|
@@ -2097,7 +2097,7 @@ var D = class e {
|
|
|
2097
2097
|
if (this.composing) return;
|
|
2098
2098
|
let t = this.element.value;
|
|
2099
2099
|
if (t === this.previous) return;
|
|
2100
|
-
let n =
|
|
2100
|
+
let n = k.fromDiff(this.previous, t);
|
|
2101
2101
|
this.previous = t, e(n);
|
|
2102
2102
|
};
|
|
2103
2103
|
this.element.addEventListener("input", r, { signal: n }), this.element.addEventListener("compositionstart", () => this.composing = !0, { signal: n }), this.element.addEventListener("compositionend", () => {
|
|
@@ -2117,10 +2117,10 @@ var D = class e {
|
|
|
2117
2117
|
destroy() {
|
|
2118
2118
|
this.controller.abort();
|
|
2119
2119
|
}
|
|
2120
|
-
},
|
|
2121
|
-
function
|
|
2120
|
+
}, _e = /* @__PURE__ */ "boxSizing.width.height.overflowX.overflowY.borderTopWidth.borderRightWidth.borderBottomWidth.borderLeftWidth.paddingTop.paddingRight.paddingBottom.paddingLeft.fontStyle.fontVariant.fontWeight.fontStretch.fontSize.lineHeight.fontFamily.textAlign.textTransform.textIndent.letterSpacing.wordSpacing.tabSize.whiteSpace.wordBreak.overflowWrap".split(".");
|
|
2121
|
+
function ve(e, t) {
|
|
2122
2122
|
let n = document.createElement("div"), r = getComputedStyle(e);
|
|
2123
|
-
for (let e of
|
|
2123
|
+
for (let e of _e) n.style[e] = r[e];
|
|
2124
2124
|
Object.assign(n.style, {
|
|
2125
2125
|
position: "absolute",
|
|
2126
2126
|
visibility: "hidden",
|
|
@@ -2139,7 +2139,7 @@ function be(e, t) {
|
|
|
2139
2139
|
};
|
|
2140
2140
|
return n.remove(), o;
|
|
2141
2141
|
}
|
|
2142
|
-
var
|
|
2142
|
+
var ye = class {
|
|
2143
2143
|
textarea;
|
|
2144
2144
|
layer;
|
|
2145
2145
|
cursors = [];
|
|
@@ -2173,7 +2173,7 @@ var xe = class {
|
|
|
2173
2173
|
this.layer.replaceChildren();
|
|
2174
2174
|
for (let r of this.cursors) {
|
|
2175
2175
|
if (!r.selection) continue;
|
|
2176
|
-
let i = r.user?.color ?? "#7c3aed", a =
|
|
2176
|
+
let i = r.user?.color ?? "#7c3aed", a = ve(e, Math.min(r.selection.head, e.value.length)), o = document.createElement("div");
|
|
2177
2177
|
o.className = "collab-cursor", Object.assign(o.style, {
|
|
2178
2178
|
position: "absolute",
|
|
2179
2179
|
top: `${t + a.top}px`,
|
|
@@ -2196,7 +2196,7 @@ var xe = class {
|
|
|
2196
2196
|
destroy() {
|
|
2197
2197
|
cancelAnimationFrame(this.frame), this.controller.abort(), this.layer.remove();
|
|
2198
2198
|
}
|
|
2199
|
-
},
|
|
2199
|
+
}, be = class extends f {
|
|
2200
2200
|
ws;
|
|
2201
2201
|
options;
|
|
2202
2202
|
docId;
|
|
@@ -2214,7 +2214,7 @@ var xe = class {
|
|
|
2214
2214
|
_status = "connecting";
|
|
2215
2215
|
clientId = null;
|
|
2216
2216
|
constructor(e, t, n, r = {}) {
|
|
2217
|
-
super(), this.ws = e, this.options = r, this.docId = t, this.channel = `doc:${t}`, this.adapter = n instanceof HTMLElement ? new
|
|
2217
|
+
super(), this.ws = e, this.options = r, this.docId = t, this.channel = `doc:${t}`, this.adapter = n instanceof HTMLElement ? new ge(n) : n, n instanceof HTMLTextAreaElement && r.cursors !== !1 && (this.overlay = new ye(n)), n instanceof HTMLElement && n.setAttribute("aria-busy", "true"), this.adapter.attach((e) => this.handleLocalEdit(e), (e) => this.queuePresence(e)), this.unsubscribe = e.subscribe(this.channel, (e) => this.handleMessage(e)), this.offOpen = e.onOpen(() => this.join()), this.offStatus = e.onStatusChange((e) => {
|
|
2218
2218
|
e !== "open" && this.setStatus("offline");
|
|
2219
2219
|
}), e.isConnected ? this.join() : e.connect();
|
|
2220
2220
|
}
|
|
@@ -2251,7 +2251,7 @@ var xe = class {
|
|
|
2251
2251
|
break;
|
|
2252
2252
|
case "collab:op":
|
|
2253
2253
|
if (!this.client || t.clientId === this.clientId) return;
|
|
2254
|
-
this.client.applyServer(
|
|
2254
|
+
this.client.applyServer(k.fromJSON(t.op)), this.updateStatus();
|
|
2255
2255
|
break;
|
|
2256
2256
|
case "collab:ack":
|
|
2257
2257
|
if (!this.client || t.opId && t.opId !== this.outstandingOpId) return;
|
|
@@ -2275,7 +2275,7 @@ var xe = class {
|
|
|
2275
2275
|
}
|
|
2276
2276
|
}
|
|
2277
2277
|
handleInit(e) {
|
|
2278
|
-
if (this.clientId = e.clientId, !this.client || e.since === null || e.since === void 0 || !e.missed) this.client = new
|
|
2278
|
+
if (this.clientId = e.clientId, !this.client || e.since === null || e.since === void 0 || !e.missed) this.client = new he(e.revision, {
|
|
2279
2279
|
send: (e, t) => this.sendOp(e, t),
|
|
2280
2280
|
apply: (e) => this.applyRemote(e)
|
|
2281
2281
|
}), this.outstandingOpId = null, this.adapter.setValue(e.content), this.emit("ready", {
|
|
@@ -2286,12 +2286,12 @@ var xe = class {
|
|
|
2286
2286
|
remote: !0
|
|
2287
2287
|
});
|
|
2288
2288
|
else {
|
|
2289
|
-
for (let t of e.missed) t.opId && t.opId === this.outstandingOpId ? (this.outstandingOpId = null, this.client.serverAck()) : this.client.applyServer(
|
|
2289
|
+
for (let t of e.missed) t.opId && t.opId === this.outstandingOpId ? (this.outstandingOpId = null, this.client.serverAck()) : this.client.applyServer(k.fromJSON(t.op));
|
|
2290
2290
|
this.client.resend();
|
|
2291
2291
|
}
|
|
2292
2292
|
this.cursors.clear();
|
|
2293
2293
|
for (let t of e.peers ?? []) this.cursors.set(t.clientId, t);
|
|
2294
|
-
this.emitPresence(), this.adapter instanceof
|
|
2294
|
+
this.emitPresence(), this.adapter instanceof ge && this.adapter.element.removeAttribute("aria-busy"), this.updateStatus();
|
|
2295
2295
|
}
|
|
2296
2296
|
sendOp(e, t) {
|
|
2297
2297
|
this.outstandingOpId = `${this.clientId ?? "c"}-${++this.opCounter}`, this.ws.send({
|
|
@@ -2359,7 +2359,7 @@ var xe = class {
|
|
|
2359
2359
|
channel: this.channel
|
|
2360
2360
|
}), this.unsubscribe?.(), this.offOpen?.(), this.offStatus?.(), this.adapter.destroy(), this.overlay?.destroy(), this.clear();
|
|
2361
2361
|
}
|
|
2362
|
-
},
|
|
2362
|
+
}, xe = class {
|
|
2363
2363
|
getWs;
|
|
2364
2364
|
constructor(e) {
|
|
2365
2365
|
this.getWs = e;
|
|
@@ -2367,17 +2367,17 @@ var xe = class {
|
|
|
2367
2367
|
open(e, t, n = {}) {
|
|
2368
2368
|
let r = this.getWs();
|
|
2369
2369
|
if (!r) throw Error("Collaboration needs a WebSocket: pass `websocket` to Arethesis.init().");
|
|
2370
|
-
return new
|
|
2370
|
+
return new be(r, e, t, n);
|
|
2371
2371
|
}
|
|
2372
|
-
},
|
|
2373
|
-
function
|
|
2372
|
+
}, Se = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
2373
|
+
function A(e) {
|
|
2374
2374
|
if (e == null || e === "") return null;
|
|
2375
2375
|
if (e instanceof Date) return isNaN(e.getTime()) ? null : e;
|
|
2376
2376
|
if (typeof e == "number") {
|
|
2377
2377
|
let t = new Date(e);
|
|
2378
2378
|
return isNaN(t.getTime()) ? null : t;
|
|
2379
2379
|
}
|
|
2380
|
-
let t = String(e), n =
|
|
2380
|
+
let t = String(e), n = Se.exec(t);
|
|
2381
2381
|
if (n) {
|
|
2382
2382
|
let e = new Date(Number(n[1]), Number(n[2]) - 1, Number(n[3]));
|
|
2383
2383
|
return isNaN(e.getTime()) ? null : e;
|
|
@@ -2385,45 +2385,45 @@ function O(e) {
|
|
|
2385
2385
|
let r = new Date(t);
|
|
2386
2386
|
return isNaN(r.getTime()) ? null : r;
|
|
2387
2387
|
}
|
|
2388
|
-
var
|
|
2389
|
-
function
|
|
2390
|
-
return `${e.getFullYear()}-${
|
|
2388
|
+
var j = (e, t = 2) => String(e).padStart(t, "0");
|
|
2389
|
+
function M(e) {
|
|
2390
|
+
return `${e.getFullYear()}-${j(e.getMonth() + 1)}-${j(e.getDate())}`;
|
|
2391
2391
|
}
|
|
2392
|
-
function
|
|
2393
|
-
return `${
|
|
2392
|
+
function Ce(e) {
|
|
2393
|
+
return `${M(e)}T${j(e.getHours())}:${j(e.getMinutes())}`;
|
|
2394
2394
|
}
|
|
2395
|
-
function
|
|
2395
|
+
function N(e) {
|
|
2396
2396
|
return new Date(e.getFullYear(), e.getMonth(), e.getDate());
|
|
2397
2397
|
}
|
|
2398
|
-
var
|
|
2399
|
-
function
|
|
2398
|
+
var we = /YYYY|YY|MM|M|DD|D|HH|H|hh|h|mm|ss|A/g;
|
|
2399
|
+
function Te(e, t) {
|
|
2400
2400
|
let n = e.getHours() % 12 || 12, r = {
|
|
2401
2401
|
YYYY: String(e.getFullYear()),
|
|
2402
2402
|
YY: String(e.getFullYear()).slice(-2),
|
|
2403
|
-
MM:
|
|
2403
|
+
MM: j(e.getMonth() + 1),
|
|
2404
2404
|
M: String(e.getMonth() + 1),
|
|
2405
|
-
DD:
|
|
2405
|
+
DD: j(e.getDate()),
|
|
2406
2406
|
D: String(e.getDate()),
|
|
2407
|
-
HH:
|
|
2407
|
+
HH: j(e.getHours()),
|
|
2408
2408
|
H: String(e.getHours()),
|
|
2409
|
-
hh:
|
|
2409
|
+
hh: j(n),
|
|
2410
2410
|
h: String(n),
|
|
2411
|
-
mm:
|
|
2412
|
-
ss:
|
|
2411
|
+
mm: j(e.getMinutes()),
|
|
2412
|
+
ss: j(e.getSeconds()),
|
|
2413
2413
|
A: e.getHours() < 12 ? "AM" : "PM"
|
|
2414
2414
|
};
|
|
2415
|
-
return t.split(/(\[[^\]]*\])/).map((e) => e.startsWith("[") && e.endsWith("]") ? e.slice(1, -1) : e.replace(
|
|
2415
|
+
return t.split(/(\[[^\]]*\])/).map((e) => e.startsWith("[") && e.endsWith("]") ? e.slice(1, -1) : e.replace(we, (e) => r[e])).join("");
|
|
2416
2416
|
}
|
|
2417
2417
|
// src/binding/validation-engine.ts
|
|
2418
|
-
var
|
|
2418
|
+
var P = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0, Ee = /^[^\s@]+@[^\s@.]+(?:\.[^\s@.]+)+$/, De = /^\+?[\d\s\-().]+$/, Oe = class {
|
|
2419
2419
|
validators = /* @__PURE__ */ new Map();
|
|
2420
2420
|
constructor() {
|
|
2421
2421
|
this.registerBuiltIns();
|
|
2422
2422
|
}
|
|
2423
2423
|
registerBuiltIns() {
|
|
2424
2424
|
let e = (e) => Array.isArray(e) ? e.length : String(e).length;
|
|
2425
|
-
this.registerValidator("required", (e) => typeof e == "string" ? e.trim().length > 0 : typeof e == "boolean" ? e : !
|
|
2426
|
-
if (
|
|
2425
|
+
this.registerValidator("required", (e) => typeof e == "string" ? e.trim().length > 0 : typeof e == "boolean" ? e : !P(e), { message: "This field is required" }), this.registerValidator("email", (e) => P(e) || Ee.test(String(e)), { message: "Enter a valid email address" }), this.registerValidator("url", (e) => {
|
|
2426
|
+
if (P(e)) return !0;
|
|
2427
2427
|
try {
|
|
2428
2428
|
let t = new URL(String(e));
|
|
2429
2429
|
return t.protocol === "http:" || t.protocol === "https:";
|
|
@@ -2431,16 +2431,16 @@ var M = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0, Oe =
|
|
|
2431
2431
|
return !1;
|
|
2432
2432
|
}
|
|
2433
2433
|
}, { message: "Enter a valid URL" }), this.registerValidator("phone", (e) => {
|
|
2434
|
-
if (
|
|
2434
|
+
if (P(e)) return !0;
|
|
2435
2435
|
let t = String(e), n = t.replace(/\D/g, "").length;
|
|
2436
|
-
return
|
|
2437
|
-
}, { message: "Enter a valid phone number" }), this.registerValidator("minLength", (t, n) =>
|
|
2436
|
+
return De.test(t) && n >= 7 && n <= 15;
|
|
2437
|
+
}, { message: "Enter a valid phone number" }), this.registerValidator("minLength", (t, n) => P(t) || e(t) >= Number(n.min), { message: "Must be at least {min} characters" }), this.registerValidator("maxLength", (t, n) => P(t) || e(t) <= Number(n.max), { message: "Must be at most {max} characters" });
|
|
2438
2438
|
let t = (e) => typeof e == "number" ? e : Number(e);
|
|
2439
|
-
this.registerValidator("numeric", (e) =>
|
|
2440
|
-
if (
|
|
2439
|
+
this.registerValidator("numeric", (e) => P(e) || !isNaN(t(e)), { message: "Must be a number" }), this.registerValidator("integer", (e) => P(e) || Number.isInteger(t(e)), { message: "Must be a whole number" }), this.registerValidator("min", (e, n) => P(e) || !isNaN(t(e)) && t(e) >= Number(n.min), { message: "Must be at least {min}" }), this.registerValidator("max", (e, n) => P(e) || !isNaN(t(e)) && t(e) <= Number(n.max), { message: "Must be at most {max}" }), this.registerValidator("between", (e, n) => P(e) || !isNaN(t(e)) && t(e) >= Number(n.min) && t(e) <= Number(n.max), { message: "Must be between {min} and {max}" }), this.registerValidator("pattern", (e, t) => {
|
|
2440
|
+
if (P(e)) return !0;
|
|
2441
2441
|
let n = t.pattern instanceof RegExp ? t.pattern : new RegExp(String(t.pattern), typeof t.flags == "string" ? t.flags : void 0);
|
|
2442
2442
|
return n.lastIndex = 0, n.test(String(e));
|
|
2443
|
-
}, { message: "Invalid format" }), this.registerValidator("oneOf", (e, t) =>
|
|
2443
|
+
}, { message: "Invalid format" }), this.registerValidator("oneOf", (e, t) => P(e) || Array.isArray(t.values) && t.values.includes(e), { message: "Choose a valid option" }), this.registerValidator("equals", (e, t, n) => e === n.data[String(t.field)], { message: "Must match {field}" }), this.registerValidator("date", (e) => P(e) || A(e) !== null, { message: "Enter a valid date" }), this.registerValidator("custom", (e, t, n) => {
|
|
2444
2444
|
let r = t.fn;
|
|
2445
2445
|
return !r || r(e, n);
|
|
2446
2446
|
}, { message: "Invalid value" });
|
|
@@ -2530,27 +2530,27 @@ var M = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0, Oe =
|
|
|
2530
2530
|
};
|
|
2531
2531
|
return e.replace(/\{(\w+)\}/g, (e, t) => t in r ? String(r[t]) : e);
|
|
2532
2532
|
}
|
|
2533
|
-
},
|
|
2533
|
+
}, ke = /* @__PURE__ */ new Set([
|
|
2534
2534
|
"http:",
|
|
2535
2535
|
"https:",
|
|
2536
2536
|
"mailto:",
|
|
2537
2537
|
"tel:"
|
|
2538
|
-
]),
|
|
2538
|
+
]), Ae = /* @__PURE__ */ new Set([
|
|
2539
2539
|
"http:",
|
|
2540
2540
|
"https:",
|
|
2541
2541
|
"blob:"
|
|
2542
|
-
]),
|
|
2543
|
-
function
|
|
2542
|
+
]), je = /^data:image\/(png|gif|jpe?g|webp|avif|svg\+xml);/i;
|
|
2543
|
+
function F(e, t = "link") {
|
|
2544
2544
|
if (e == null) return "";
|
|
2545
2545
|
let n = String(e).trim();
|
|
2546
2546
|
if (n === "") return "";
|
|
2547
2547
|
let r = n.replace(/[\u0000-\u001F\u007F\s]+/g, ""), i = /^([a-z][a-z0-9+.-]*):/i.exec(r);
|
|
2548
2548
|
if (!i) return n;
|
|
2549
2549
|
let a = `${i[1].toLowerCase()}:`;
|
|
2550
|
-
return t === "image" ? a === "data:" ?
|
|
2550
|
+
return t === "image" ? a === "data:" ? je.test(r) && !/svg/i.test(r) ? n : "" : Ae.has(a) ? n : "" : ke.has(a) ? n : "";
|
|
2551
2551
|
}
|
|
2552
2552
|
// src/utils/sanitize.ts
|
|
2553
|
-
var
|
|
2553
|
+
var Me = /* @__PURE__ */ "a.abbr.b.blockquote.br.code.del.div.em.figcaption.figure.h1.h2.h3.h4.h5.h6.hr.i.img.ins.kbd.li.mark.ol.p.pre.s.small.span.strong.sub.sup.table.tbody.td.tfoot.th.thead.tr.u.ul".split("."), Ne = {
|
|
2554
2554
|
"*": [
|
|
2555
2555
|
"class",
|
|
2556
2556
|
"title",
|
|
@@ -2575,7 +2575,7 @@ var Pe = /* @__PURE__ */ "a.abbr.b.blockquote.br.code.del.div.em.figcaption.figu
|
|
|
2575
2575
|
"scope"
|
|
2576
2576
|
],
|
|
2577
2577
|
ol: ["start"]
|
|
2578
|
-
},
|
|
2578
|
+
}, Pe = /* @__PURE__ */ new Set([
|
|
2579
2579
|
"script",
|
|
2580
2580
|
"style",
|
|
2581
2581
|
"iframe",
|
|
@@ -2596,12 +2596,12 @@ var Pe = /* @__PURE__ */ "a.abbr.b.blockquote.br.code.del.div.em.figcaption.figu
|
|
|
2596
2596
|
"frame",
|
|
2597
2597
|
"frameset"
|
|
2598
2598
|
]);
|
|
2599
|
-
function
|
|
2599
|
+
function I(e, t = {}) {
|
|
2600
2600
|
if (e == null) return "";
|
|
2601
|
-
let n = new Set(t.allowedTags ??
|
|
2602
|
-
return
|
|
2601
|
+
let n = new Set(t.allowedTags ?? Me), r = t.allowedAttributes ?? Ne, i = new DOMParser().parseFromString(`<body>${String(e)}</body>`, "text/html");
|
|
2602
|
+
return Fe(i.body, n, r), i.body.innerHTML;
|
|
2603
2603
|
}
|
|
2604
|
-
function
|
|
2604
|
+
function Fe(e, t, n) {
|
|
2605
2605
|
for (let r of Array.from(e.childNodes)) {
|
|
2606
2606
|
if (r.nodeType === Node.COMMENT_NODE || r.nodeType === Node.PROCESSING_INSTRUCTION_NODE) {
|
|
2607
2607
|
r.remove();
|
|
@@ -2609,44 +2609,44 @@ function Le(e, t, n) {
|
|
|
2609
2609
|
}
|
|
2610
2610
|
if (r.nodeType !== Node.ELEMENT_NODE) continue;
|
|
2611
2611
|
let e = r, i = e.tagName.toLowerCase();
|
|
2612
|
-
|
|
2612
|
+
Pe.has(i) ? e.remove() : (Fe(e, t, n), t.has(i) ? Ie(e, i, n) : e.replaceWith(...Array.from(e.childNodes)));
|
|
2613
2613
|
}
|
|
2614
2614
|
}
|
|
2615
|
-
function
|
|
2615
|
+
function Ie(e, t, n) {
|
|
2616
2616
|
let r = /* @__PURE__ */ new Set([...n["*"] ?? [], ...n[t] ?? []]);
|
|
2617
2617
|
for (let t of Array.from(e.attributes)) {
|
|
2618
2618
|
let n = t.name.toLowerCase();
|
|
2619
2619
|
if (!r.has(n) || n.startsWith("on")) e.removeAttribute(t.name);
|
|
2620
2620
|
else if (n === "href") {
|
|
2621
|
-
let n =
|
|
2621
|
+
let n = F(t.value, "link");
|
|
2622
2622
|
n ? e.setAttribute("href", n) : e.removeAttribute("href");
|
|
2623
2623
|
} else if (n === "src") {
|
|
2624
|
-
let n =
|
|
2624
|
+
let n = F(t.value, "image");
|
|
2625
2625
|
n ? e.setAttribute("src", n) : e.removeAttribute("src");
|
|
2626
2626
|
}
|
|
2627
2627
|
}
|
|
2628
2628
|
t === "a" && e.getAttribute("target") === "_blank" && e.setAttribute("rel", "noopener noreferrer");
|
|
2629
2629
|
}
|
|
2630
|
-
function
|
|
2630
|
+
function L(e) {
|
|
2631
2631
|
return e == null ? "" : new DOMParser().parseFromString(String(e), "text/html").body.textContent ?? "";
|
|
2632
2632
|
}
|
|
2633
2633
|
// src/utils/dom.ts
|
|
2634
|
-
function
|
|
2634
|
+
function R(e) {
|
|
2635
2635
|
return typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/([^\w-])/g, "\\$1").replace(/^(\d)/, "\\3$1 ");
|
|
2636
2636
|
}
|
|
2637
|
-
function
|
|
2637
|
+
function Le(e) {
|
|
2638
2638
|
return e.replace(/-([a-z0-9])/g, (e, t) => t.toUpperCase());
|
|
2639
2639
|
}
|
|
2640
|
-
var
|
|
2641
|
-
function
|
|
2642
|
-
return
|
|
2640
|
+
var Re = 0;
|
|
2641
|
+
function z(e = "ar") {
|
|
2642
|
+
return Re += 1, `${e}-${Re.toString(36)}`;
|
|
2643
2643
|
}
|
|
2644
|
-
function
|
|
2644
|
+
function ze(e) {
|
|
2645
2645
|
let t = document.createElement("template");
|
|
2646
2646
|
return t.innerHTML = e, t.content;
|
|
2647
2647
|
}
|
|
2648
2648
|
// src/binding/data-binder.ts
|
|
2649
|
-
var
|
|
2649
|
+
var Be = /* @__PURE__ */ new Set([
|
|
2650
2650
|
"href",
|
|
2651
2651
|
"src",
|
|
2652
2652
|
"action",
|
|
@@ -2657,29 +2657,29 @@ var He = /* @__PURE__ */ new Set([
|
|
|
2657
2657
|
"background",
|
|
2658
2658
|
"ping"
|
|
2659
2659
|
]);
|
|
2660
|
-
function
|
|
2660
|
+
function B(e) {
|
|
2661
2661
|
return e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement;
|
|
2662
2662
|
}
|
|
2663
|
-
function
|
|
2663
|
+
function V(e) {
|
|
2664
2664
|
return e instanceof HTMLElement && (e.isContentEditable || e.getAttribute("contenteditable") === "true");
|
|
2665
2665
|
}
|
|
2666
|
-
function
|
|
2666
|
+
function Ve() {
|
|
2667
2667
|
return typeof document < "u" && document.documentElement.lang || "en-US";
|
|
2668
2668
|
}
|
|
2669
|
-
var
|
|
2669
|
+
var He = class {
|
|
2670
2670
|
validationEngine;
|
|
2671
2671
|
bindings = /* @__PURE__ */ new WeakMap();
|
|
2672
2672
|
timers = /* @__PURE__ */ new WeakMap();
|
|
2673
2673
|
validationRuns = /* @__PURE__ */ new WeakMap();
|
|
2674
2674
|
touched = /* @__PURE__ */ new WeakSet();
|
|
2675
2675
|
constructor(e) {
|
|
2676
|
-
this.validationEngine = e ?? new
|
|
2676
|
+
this.validationEngine = e ?? new Oe();
|
|
2677
2677
|
}
|
|
2678
2678
|
bind(e, t, n) {
|
|
2679
2679
|
this.unbind(e);
|
|
2680
2680
|
let r = new AbortController(), i = [];
|
|
2681
2681
|
for (let [t, r] of Object.entries(n.fields)) {
|
|
2682
|
-
let n = r.selector ?? `[data-bind="${
|
|
2682
|
+
let n = r.selector ?? `[data-bind="${R(t)}"]`, a = Array.from(e.querySelectorAll(n));
|
|
2683
2683
|
e.matches?.(n) && a.unshift(e), i.push({
|
|
2684
2684
|
key: t,
|
|
2685
2685
|
path: r.field ?? t,
|
|
@@ -2717,7 +2717,7 @@ var We = class {
|
|
|
2717
2717
|
let n = r(t, e.path);
|
|
2718
2718
|
if (!(e.initialized && s(n, e.lastValue))) {
|
|
2719
2719
|
e.lastValue = n, e.initialized = !0;
|
|
2720
|
-
for (let r of e.targets) r === document.activeElement && (
|
|
2720
|
+
for (let r of e.targets) r === document.activeElement && (B(r) || V(r)) && e.config.twoWay || this.applyValue(r, n, e.config, t);
|
|
2721
2721
|
}
|
|
2722
2722
|
}
|
|
2723
2723
|
}
|
|
@@ -2734,13 +2734,13 @@ var We = class {
|
|
|
2734
2734
|
}
|
|
2735
2735
|
}
|
|
2736
2736
|
applyValue(e, t, n, r) {
|
|
2737
|
-
n.visible && (e.hidden = !n.visible(t, r)), n.attribute ? this.applyAttribute(e, n.attribute, this.format(t, n, r)) :
|
|
2737
|
+
n.visible && (e.hidden = !n.visible(t, r)), n.attribute ? this.applyAttribute(e, n.attribute, this.format(t, n, r)) : B(e) ? this.applyToControl(e, t, n) : n.inputType === "rich-text" && V(e) ? e.innerHTML = I(t) : this.applyToDisplay(e, t, n, r);
|
|
2738
2738
|
}
|
|
2739
2739
|
applyAttribute(e, t, n) {
|
|
2740
2740
|
let r = t.toLowerCase();
|
|
2741
2741
|
if (!(r.startsWith("on") || r === "style" && /expression|url\s*\(/i.test(n))) {
|
|
2742
|
-
if (
|
|
2743
|
-
let i =
|
|
2742
|
+
if (Be.has(r)) {
|
|
2743
|
+
let i = F(n, r === "href" || r === "action" || r === "formaction" || r === "ping" ? "link" : "image");
|
|
2744
2744
|
i ? e.setAttribute(t, i) : e.removeAttribute(t);
|
|
2745
2745
|
} else e.setAttribute(t, n);
|
|
2746
2746
|
}
|
|
@@ -2748,21 +2748,21 @@ var We = class {
|
|
|
2748
2748
|
format(e, t, n) {
|
|
2749
2749
|
if (typeof t.format == "function") return t.format(e, n);
|
|
2750
2750
|
if (e == null || e === "") return t.emptyText ?? "";
|
|
2751
|
-
let r = t.locale ??
|
|
2751
|
+
let r = t.locale ?? Ve(), i = t.displayType ?? "text";
|
|
2752
2752
|
switch (i) {
|
|
2753
2753
|
case "date":
|
|
2754
2754
|
case "datetime":
|
|
2755
2755
|
case "time": {
|
|
2756
|
-
let n =
|
|
2757
|
-
return n ? typeof t.format == "string" ?
|
|
2756
|
+
let n = A(e);
|
|
2757
|
+
return n ? typeof t.format == "string" ? Te(n, t.format) : i === "date" ? n.toLocaleDateString(r, t.intl) : i === "time" ? n.toLocaleTimeString(r, {
|
|
2758
2758
|
hour: "numeric",
|
|
2759
2759
|
minute: "2-digit",
|
|
2760
2760
|
...t.intl
|
|
2761
2761
|
}) : n.toLocaleString(r, t.intl) : t.emptyText ?? "";
|
|
2762
2762
|
}
|
|
2763
2763
|
case "relative": {
|
|
2764
|
-
let n =
|
|
2765
|
-
return n ?
|
|
2764
|
+
let n = A(e);
|
|
2765
|
+
return n ? Ke(n, r) : t.emptyText ?? "";
|
|
2766
2766
|
}
|
|
2767
2767
|
case "currency":
|
|
2768
2768
|
case "number":
|
|
@@ -2788,10 +2788,10 @@ var We = class {
|
|
|
2788
2788
|
let i = n.displayType ?? "text", a = this.format(t, n, r);
|
|
2789
2789
|
switch (i) {
|
|
2790
2790
|
case "html":
|
|
2791
|
-
e.innerHTML = n.trusted ? String(t ?? "") :
|
|
2791
|
+
e.innerHTML = n.trusted ? String(t ?? "") : I(t);
|
|
2792
2792
|
return;
|
|
2793
2793
|
case "image": {
|
|
2794
|
-
let n =
|
|
2794
|
+
let n = F(t, "image");
|
|
2795
2795
|
if (e instanceof HTMLImageElement) {
|
|
2796
2796
|
n ? e.src = n : e.removeAttribute("src");
|
|
2797
2797
|
return;
|
|
@@ -2803,7 +2803,7 @@ var We = class {
|
|
|
2803
2803
|
return;
|
|
2804
2804
|
}
|
|
2805
2805
|
case "link": {
|
|
2806
|
-
let i =
|
|
2806
|
+
let i = F(n.href ? n.href(t, r) : t, "link"), o = n.linkText ?? a;
|
|
2807
2807
|
if (e instanceof HTMLAnchorElement) {
|
|
2808
2808
|
i ? e.href = i : e.removeAttribute("href"), n.linkText === void 0 && e.dataset.keepText || (e.textContent = o);
|
|
2809
2809
|
return;
|
|
@@ -2831,11 +2831,11 @@ var We = class {
|
|
|
2831
2831
|
}
|
|
2832
2832
|
case "relative": {
|
|
2833
2833
|
e.textContent = a;
|
|
2834
|
-
let r = typeof n.format == "function" ? null :
|
|
2834
|
+
let r = typeof n.format == "function" ? null : A(t);
|
|
2835
2835
|
if (r) {
|
|
2836
|
-
let t = n.locale ??
|
|
2837
|
-
e instanceof HTMLTimeElement && (e.dateTime = r.toISOString()), (!e.hasAttribute("title") || e.hasAttribute("data-relative-title")) && (e.setAttribute("title", r.toLocaleString(t)), e.setAttribute("data-relative-title", "")), n.live === !1 ?
|
|
2838
|
-
} else
|
|
2836
|
+
let t = n.locale ?? Ve();
|
|
2837
|
+
e instanceof HTMLTimeElement && (e.dateTime = r.toISOString()), (!e.hasAttribute("title") || e.hasAttribute("data-relative-title")) && (e.setAttribute("title", r.toLocaleString(t)), e.setAttribute("data-relative-title", "")), n.live === !1 ? H.unwatch(e) : H.watch(e, r, t);
|
|
2838
|
+
} else H.unwatch(e);
|
|
2839
2839
|
return;
|
|
2840
2840
|
}
|
|
2841
2841
|
default: e.textContent = a;
|
|
@@ -2860,13 +2860,13 @@ var We = class {
|
|
|
2860
2860
|
return;
|
|
2861
2861
|
}
|
|
2862
2862
|
case "date": {
|
|
2863
|
-
let n =
|
|
2864
|
-
e.value = n ?
|
|
2863
|
+
let n = A(t);
|
|
2864
|
+
e.value = n ? M(n) : "";
|
|
2865
2865
|
return;
|
|
2866
2866
|
}
|
|
2867
2867
|
case "datetime": {
|
|
2868
|
-
let n =
|
|
2869
|
-
e.value = n ?
|
|
2868
|
+
let n = A(t);
|
|
2869
|
+
e.value = n ? Ce(n) : "";
|
|
2870
2870
|
return;
|
|
2871
2871
|
}
|
|
2872
2872
|
case "tags":
|
|
@@ -2877,7 +2877,7 @@ var We = class {
|
|
|
2877
2877
|
}
|
|
2878
2878
|
readValue(e, t) {
|
|
2879
2879
|
let n;
|
|
2880
|
-
if (
|
|
2880
|
+
if (B(e)) switch (this.inputTypeOf(e, t)) {
|
|
2881
2881
|
case "checkbox":
|
|
2882
2882
|
case "toggle":
|
|
2883
2883
|
n = e.checked;
|
|
@@ -2894,14 +2894,14 @@ var We = class {
|
|
|
2894
2894
|
break;
|
|
2895
2895
|
default: n = e.value;
|
|
2896
2896
|
}
|
|
2897
|
-
else n =
|
|
2897
|
+
else n = V(e) && t.inputType === "rich-text" ? I(e.innerHTML) : e.textContent;
|
|
2898
2898
|
return t.parse ? t.parse(n) : n;
|
|
2899
2899
|
}
|
|
2900
2900
|
values(e) {
|
|
2901
2901
|
let t = this.bindings.get(e), n = {};
|
|
2902
2902
|
if (!t) return n;
|
|
2903
2903
|
for (let e of t.fields) {
|
|
2904
|
-
let i = e.targets.find((e) =>
|
|
2904
|
+
let i = e.targets.find((e) => B(e) || V(e));
|
|
2905
2905
|
n[e.key] = i ? this.readValue(i, e.config) : r(t.data, e.path);
|
|
2906
2906
|
}
|
|
2907
2907
|
return n;
|
|
@@ -2910,7 +2910,7 @@ var We = class {
|
|
|
2910
2910
|
return new Set(e.config.validateOn ?? ["blur", "change"]);
|
|
2911
2911
|
}
|
|
2912
2912
|
listen(e, t, n) {
|
|
2913
|
-
if (!(
|
|
2913
|
+
if (!(B(n) || V(n))) return;
|
|
2914
2914
|
let { signal: r } = e.controller, i = t.config.validation, a = this.triggers(e), o = (r) => {
|
|
2915
2915
|
let o = this.readValue(n, t.config), s = () => {
|
|
2916
2916
|
t.config.twoWay && (t.lastValue = o, e.config.onChange?.(t.path, o));
|
|
@@ -2959,7 +2959,7 @@ var We = class {
|
|
|
2959
2959
|
let n = [];
|
|
2960
2960
|
for (let e of t.fields) {
|
|
2961
2961
|
if (!e.config.validation) continue;
|
|
2962
|
-
let i = e.targets.find((e) =>
|
|
2962
|
+
let i = e.targets.find((e) => B(e) || V(e));
|
|
2963
2963
|
if (i) {
|
|
2964
2964
|
this.touched.add(i);
|
|
2965
2965
|
let r = await this.validateTarget(t, e, i);
|
|
@@ -2983,9 +2983,9 @@ var We = class {
|
|
|
2983
2983
|
o.className = "error-summary__title", o.textContent = n.length === 1 ? "Please fix 1 error:" : `Please fix ${n.length} errors:`;
|
|
2984
2984
|
let s = document.createElement("ul");
|
|
2985
2985
|
for (let e of n) {
|
|
2986
|
-
let n = document.createElement("li"), r = t.fields.find((t) => t.key === e.field), i = r?.config.validation?.label, a = i && !e.message.toLowerCase().includes(i.toLowerCase()) ? `${i}: ${e.message}` : e.message, o = r?.targets.find((e) =>
|
|
2986
|
+
let n = document.createElement("li"), r = t.fields.find((t) => t.key === e.field), i = r?.config.validation?.label, a = i && !e.message.toLowerCase().includes(i.toLowerCase()) ? `${i}: ${e.message}` : e.message, o = r?.targets.find((e) => B(e) || V(e));
|
|
2987
2987
|
if (o) {
|
|
2988
|
-
o.id ||=
|
|
2988
|
+
o.id ||= z("field");
|
|
2989
2989
|
let e = document.createElement("a");
|
|
2990
2990
|
e.href = `#${o.id}`, e.textContent = a, e.addEventListener("click", (e) => {
|
|
2991
2991
|
e.preventDefault(), o.focus();
|
|
@@ -3015,14 +3015,14 @@ var We = class {
|
|
|
3015
3015
|
let n = e.ownerDocument.getElementById(t);
|
|
3016
3016
|
if (n?.classList.contains("field-error")) return n;
|
|
3017
3017
|
}
|
|
3018
|
-
let i = (t ? e.closest("form, [data-form], body")?.querySelector(`[data-error-for="${
|
|
3018
|
+
let i = (t ? e.closest("form, [data-form], body")?.querySelector(`[data-error-for="${R(t)}"]`) : null) ?? null;
|
|
3019
3019
|
if (!i) {
|
|
3020
3020
|
if (!n) return null;
|
|
3021
3021
|
i = document.createElement("div"), i.className = "field-error", i.setAttribute("data-generated", ""), e.insertAdjacentElement("afterend", i);
|
|
3022
3022
|
}
|
|
3023
|
-
return i.classList.add("field-error"), i.id || (i.id =
|
|
3023
|
+
return i.classList.add("field-error"), i.id || (i.id = z("error")), i.setAttribute("aria-live", "polite"), e.setAttribute("aria-describedby", [...r, i.id].join(" ")), i;
|
|
3024
3024
|
}
|
|
3025
|
-
},
|
|
3025
|
+
}, Ue = [
|
|
3026
3026
|
["year", 31536e3],
|
|
3027
3027
|
["month", 2592e3],
|
|
3028
3028
|
["week", 604800],
|
|
@@ -3031,11 +3031,11 @@ var We = class {
|
|
|
3031
3031
|
["minute", 60],
|
|
3032
3032
|
["second", 1]
|
|
3033
3033
|
];
|
|
3034
|
-
function
|
|
3034
|
+
function We(e, t) {
|
|
3035
3035
|
let n = Math.abs(t - e.getTime()) / 1e3;
|
|
3036
3036
|
return n < 60 ? 5e3 : n < 3600 ? 15e3 : n < 86400 ? 3e5 : 36e5;
|
|
3037
3037
|
}
|
|
3038
|
-
var
|
|
3038
|
+
var Ge = class {
|
|
3039
3039
|
targets = /* @__PURE__ */ new Map();
|
|
3040
3040
|
timer = null;
|
|
3041
3041
|
listening = !1;
|
|
@@ -3061,7 +3061,7 @@ var qe = class {
|
|
|
3061
3061
|
this.targets.delete(t);
|
|
3062
3062
|
continue;
|
|
3063
3063
|
}
|
|
3064
|
-
let i =
|
|
3064
|
+
let i = Ke(n, r, e);
|
|
3065
3065
|
t.textContent !== i && (t.textContent = i);
|
|
3066
3066
|
}
|
|
3067
3067
|
this.targets.size ? this.schedule(e) : this.stop();
|
|
@@ -3072,26 +3072,26 @@ var qe = class {
|
|
|
3072
3072
|
schedule(e = Date.now()) {
|
|
3073
3073
|
if (this.timer || this.targets.size === 0) return;
|
|
3074
3074
|
let t = Infinity;
|
|
3075
|
-
for (let { date: n } of this.targets.values()) t = Math.min(t,
|
|
3075
|
+
for (let { date: n } of this.targets.values()) t = Math.min(t, We(n, e));
|
|
3076
3076
|
this.timer = setTimeout(() => this.tick(), t), !this.listening && typeof document < "u" && (document.addEventListener("visibilitychange", this.onVisibility), this.listening = !0);
|
|
3077
3077
|
}
|
|
3078
|
-
},
|
|
3079
|
-
function
|
|
3078
|
+
}, H = new Ge();
|
|
3079
|
+
function Ke(e, t = "en-US", n = Date.now()) {
|
|
3080
3080
|
let r = Math.round((e.getTime() - n) / 1e3), i = new Intl.RelativeTimeFormat(t, { numeric: "auto" });
|
|
3081
|
-
for (let [e, t] of
|
|
3081
|
+
for (let [e, t] of Ue) if (Math.abs(r) >= t || e === "second") return i.format(Math.round(r / t), e);
|
|
3082
3082
|
return i.format(0, "second");
|
|
3083
3083
|
}
|
|
3084
3084
|
// src/components/runtime.ts
|
|
3085
|
-
var
|
|
3085
|
+
var qe = null;
|
|
3086
3086
|
function Je(e) {
|
|
3087
|
-
|
|
3087
|
+
qe = e;
|
|
3088
3088
|
}
|
|
3089
3089
|
function U() {
|
|
3090
|
-
if (!
|
|
3091
|
-
return
|
|
3090
|
+
if (!qe) throw Error("Arethesis is not loaded. Import from \"arethesis\" and call getArethesis() first.");
|
|
3091
|
+
return qe;
|
|
3092
3092
|
}
|
|
3093
3093
|
function Ye() {
|
|
3094
|
-
return
|
|
3094
|
+
return qe !== null;
|
|
3095
3095
|
}
|
|
3096
3096
|
// src/components/template-loader.ts
|
|
3097
3097
|
var Xe = class {
|
|
@@ -3103,7 +3103,7 @@ var Xe = class {
|
|
|
3103
3103
|
this.fetchImpl = () => e;
|
|
3104
3104
|
}
|
|
3105
3105
|
register(e, t) {
|
|
3106
|
-
this.files.set(e,
|
|
3106
|
+
this.files.set(e, ze(t));
|
|
3107
3107
|
for (let t of this.extracted.keys()) t.startsWith(`${e}#`) && this.extracted.delete(t);
|
|
3108
3108
|
}
|
|
3109
3109
|
async load(e, t) {
|
|
@@ -3113,7 +3113,7 @@ var Xe = class {
|
|
|
3113
3113
|
return i || (i = this.extract(n, t, e), this.extracted.set(r, i)), i.cloneNode(!0);
|
|
3114
3114
|
}
|
|
3115
3115
|
async has(e, t) {
|
|
3116
|
-
return (await this.loadFile(e)).querySelector(`template#${
|
|
3116
|
+
return (await this.loadFile(e)).querySelector(`template#${R(t)}`) !== null;
|
|
3117
3117
|
}
|
|
3118
3118
|
loadFile(e) {
|
|
3119
3119
|
let t = this.files.get(e);
|
|
@@ -3126,10 +3126,10 @@ var Xe = class {
|
|
|
3126
3126
|
async fetchFile(e) {
|
|
3127
3127
|
let t = await this.fetchImpl()(e);
|
|
3128
3128
|
if (!t.ok) throw Error(`Failed to load template ${e} (${t.status})`);
|
|
3129
|
-
return
|
|
3129
|
+
return ze(await t.text());
|
|
3130
3130
|
}
|
|
3131
3131
|
extract(e, t, n) {
|
|
3132
|
-
let r = e.querySelector(`template#${
|
|
3132
|
+
let r = e.querySelector(`template#${R(t)}`);
|
|
3133
3133
|
if (r) return r.content.cloneNode(!0);
|
|
3134
3134
|
if (t === "main" && !e.querySelector("template")) return e.cloneNode(!0);
|
|
3135
3135
|
throw Error(`Template "#${t}" not found in ${n}`);
|
|
@@ -3167,8 +3167,10 @@ var Xe = class {
|
|
|
3167
3167
|
for (let e of r.conflicts ?? []) if (i.has(e)) return console.error(`Mixin "${t}" conflicts with "${e}"`), null;
|
|
3168
3168
|
for (let t of r.dependencies ?? []) i.has(t) || this.apply(e, t, {});
|
|
3169
3169
|
try {
|
|
3170
|
-
let a = r.fn(e, n);
|
|
3171
|
-
return
|
|
3170
|
+
let a = r.fn(e, n), o = a.destroy.bind(a), s = i;
|
|
3171
|
+
return a.destroy = () => {
|
|
3172
|
+
s.get(t) === a && (s.delete(t), s.size ? e.dataset.mixinsApplied = Array.from(s.keys()).join(" ") : delete e.dataset.mixinsApplied), o();
|
|
3173
|
+
}, i.set(t, a), e.dataset.mixinsApplied = Array.from(i.keys()).join(" "), a;
|
|
3172
3174
|
} catch (e) {
|
|
3173
3175
|
return console.error(`Failed to apply mixin "${t}":`, e), null;
|
|
3174
3176
|
}
|
|
@@ -3181,12 +3183,12 @@ var Xe = class {
|
|
|
3181
3183
|
}
|
|
3182
3184
|
remove(e, t) {
|
|
3183
3185
|
let n = this.applied.get(e), r = n?.get(t);
|
|
3184
|
-
return !n || !r ? !1 : (r.destroy(),
|
|
3186
|
+
return !n || !r ? !1 : (r.destroy(), !0);
|
|
3185
3187
|
}
|
|
3186
3188
|
removeAll(e) {
|
|
3187
3189
|
let t = this.applied.get(e);
|
|
3188
3190
|
if (t) {
|
|
3189
|
-
for (let e of t.values()) e.destroy();
|
|
3191
|
+
for (let e of [...t.values()]) e.destroy();
|
|
3190
3192
|
t.clear(), delete e.dataset.mixinsApplied;
|
|
3191
3193
|
}
|
|
3192
3194
|
}
|
|
@@ -3198,7 +3200,7 @@ var Xe = class {
|
|
|
3198
3200
|
console.error(`data-mixin-${t} is not valid JSON`);
|
|
3199
3201
|
}
|
|
3200
3202
|
let i = `data-mixin-${t}-`;
|
|
3201
|
-
for (let t of Array.from(e.attributes)) t.name.startsWith(i) && (n[
|
|
3203
|
+
for (let t of Array.from(e.attributes)) t.name.startsWith(i) && (n[Le(t.name.slice(i.length))] = Qe(t.value));
|
|
3202
3204
|
return n;
|
|
3203
3205
|
}
|
|
3204
3206
|
init(e = document) {
|
|
@@ -3590,10 +3592,10 @@ var lt = class extends HTMLElement {
|
|
|
3590
3592
|
onListChange(e) {}
|
|
3591
3593
|
onRetry() {}
|
|
3592
3594
|
}, ut = /* @__PURE__ */ new Map();
|
|
3593
|
-
function
|
|
3595
|
+
function dt(e, t) {
|
|
3594
3596
|
ut.set(e, t);
|
|
3595
3597
|
}
|
|
3596
|
-
var
|
|
3598
|
+
var ft = class {
|
|
3597
3599
|
app;
|
|
3598
3600
|
plugins = /* @__PURE__ */ new Map();
|
|
3599
3601
|
pending = [];
|
|
@@ -3659,17 +3661,17 @@ var dt = class {
|
|
|
3659
3661
|
}
|
|
3660
3662
|
};
|
|
3661
3663
|
// src/mixins/utils.ts
|
|
3662
|
-
function
|
|
3664
|
+
function K(e, t, n) {
|
|
3663
3665
|
return e.dispatchEvent(new CustomEvent(t, {
|
|
3664
3666
|
detail: n,
|
|
3665
3667
|
bubbles: !0,
|
|
3666
3668
|
cancelable: !0
|
|
3667
3669
|
}));
|
|
3668
3670
|
}
|
|
3669
|
-
var
|
|
3670
|
-
function
|
|
3671
|
+
var q = null;
|
|
3672
|
+
function J(e) {
|
|
3671
3673
|
if (typeof document > "u") return;
|
|
3672
|
-
|
|
3674
|
+
q && q.isConnected || (q = document.createElement("div"), q.setAttribute("aria-live", "assertive"), q.setAttribute("role", "status"), q.className = "ar-visually-hidden", Object.assign(q.style, {
|
|
3673
3675
|
position: "absolute",
|
|
3674
3676
|
width: "1px",
|
|
3675
3677
|
height: "1px",
|
|
@@ -3679,13 +3681,13 @@ function Y(e) {
|
|
|
3679
3681
|
margin: "-1px",
|
|
3680
3682
|
padding: "0",
|
|
3681
3683
|
border: "0"
|
|
3682
|
-
}), document.body.appendChild(
|
|
3683
|
-
let t =
|
|
3684
|
+
}), document.body.appendChild(q)), q.textContent = "";
|
|
3685
|
+
let t = q;
|
|
3684
3686
|
setTimeout(() => {
|
|
3685
3687
|
t.textContent = e;
|
|
3686
3688
|
}, 30);
|
|
3687
3689
|
}
|
|
3688
|
-
function
|
|
3690
|
+
function pt(e, t, n, r = 8) {
|
|
3689
3691
|
e.style.position = "fixed", e.style.left = "0px", e.style.top = "0px";
|
|
3690
3692
|
let i = e.getBoundingClientRect(), a = window.innerWidth, o = window.innerHeight, s = {
|
|
3691
3693
|
top: t.top - i.height - r >= 0,
|
|
@@ -3712,7 +3714,7 @@ function ft(e, t, n, r = 8) {
|
|
|
3712
3714
|
}
|
|
3713
3715
|
return e.style.left = `${Math.max(4, Math.min(u, a - i.width - 4))}px`, e.style.top = `${Math.max(4, Math.min(d, o - i.height - 4))}px`, e.dataset.placement = l, l;
|
|
3714
3716
|
}
|
|
3715
|
-
function
|
|
3717
|
+
function mt(e) {
|
|
3716
3718
|
let t = /translate\(\s*(-?[\d.]+)px\s*,\s*(-?[\d.]+)px\s*\)/.exec(e.style.transform);
|
|
3717
3719
|
return t ? {
|
|
3718
3720
|
x: Number(t[1]),
|
|
@@ -3723,8 +3725,8 @@ function pt(e) {
|
|
|
3723
3725
|
};
|
|
3724
3726
|
}
|
|
3725
3727
|
// src/mixins/draggable.ts
|
|
3726
|
-
function
|
|
3727
|
-
let { axis: n = "both", grid: r, keyboardStep: i = 10 } = t, a = new AbortController(), { signal: o } = a, s = t.handle && e.querySelector(t.handle) || e, c =
|
|
3728
|
+
function ht(e, t = {}) {
|
|
3729
|
+
let { axis: n = "both", grid: r, keyboardStep: i = 10 } = t, a = new AbortController(), { signal: o } = a, s = t.handle && e.querySelector(t.handle) || e, c = mt(e), l = null, u = s.style.touchAction;
|
|
3728
3730
|
s.style.touchAction = "none", s.style.cursor = "grab", e.hasAttribute("tabindex") || (e.tabIndex = 0), e.classList.add("is-draggable"), e.getAttribute("aria-roledescription") || e.setAttribute("aria-roledescription", "draggable");
|
|
3729
3731
|
function d() {
|
|
3730
3732
|
let n = t.containment;
|
|
@@ -3770,19 +3772,19 @@ function mt(e, t = {}) {
|
|
|
3770
3772
|
bounds: f()
|
|
3771
3773
|
}, s.setPointerCapture?.(n.pointerId), s.style.cursor = "grabbing", e.classList.add("is-dragging");
|
|
3772
3774
|
let i = h(l.base);
|
|
3773
|
-
t.onStart?.(i),
|
|
3775
|
+
t.onStart?.(i), K(e, "draggable:start", i), n.preventDefault();
|
|
3774
3776
|
}, { signal: o }), s.addEventListener("pointermove", (n) => {
|
|
3775
3777
|
if (!l || n.pointerId !== l.pointerId) return;
|
|
3776
3778
|
m(p(l.base.x + n.clientX - l.startX, l.base.y + n.clientY - l.startY, l.bounds));
|
|
3777
3779
|
let r = h(l.base);
|
|
3778
|
-
t.onDrag?.(r),
|
|
3780
|
+
t.onDrag?.(r), K(e, "draggable:move", r);
|
|
3779
3781
|
}, { signal: o });
|
|
3780
3782
|
let g = (n) => {
|
|
3781
3783
|
if (!l || n.pointerId !== l.pointerId) return;
|
|
3782
3784
|
let r = l.base;
|
|
3783
3785
|
l = null, s.releasePointerCapture?.(n.pointerId), s.style.cursor = "grab", e.classList.remove("is-dragging");
|
|
3784
3786
|
let i = h(r);
|
|
3785
|
-
t.onEnd?.(i),
|
|
3787
|
+
t.onEnd?.(i), K(e, "draggable:end", i);
|
|
3786
3788
|
};
|
|
3787
3789
|
return s.addEventListener("pointerup", g, { signal: o }), s.addEventListener("pointercancel", g, { signal: o }), e.addEventListener("keydown", (n) => {
|
|
3788
3790
|
if (n.target !== e) return;
|
|
@@ -3797,7 +3799,7 @@ function mt(e, t = {}) {
|
|
|
3797
3799
|
let o = { ...c };
|
|
3798
3800
|
m(p(c.x + a[0], c.y + a[1], f()));
|
|
3799
3801
|
let s = h(o);
|
|
3800
|
-
t.onEnd?.(s),
|
|
3802
|
+
t.onEnd?.(s), K(e, "draggable:end", s);
|
|
3801
3803
|
}, { signal: o }), {
|
|
3802
3804
|
name: "draggable",
|
|
3803
3805
|
element: e,
|
|
@@ -3812,9 +3814,9 @@ function mt(e, t = {}) {
|
|
|
3812
3814
|
}
|
|
3813
3815
|
};
|
|
3814
3816
|
}
|
|
3815
|
-
G.register("draggable",
|
|
3817
|
+
G.register("draggable", ht);
|
|
3816
3818
|
// src/mixins/editable.ts
|
|
3817
|
-
function
|
|
3819
|
+
function gt(e, t = {}) {
|
|
3818
3820
|
let { type: n = "text", placeholder: r = "", saveOnBlur: i = !0 } = t, a = new AbortController(), o = null;
|
|
3819
3821
|
e.hasAttribute("tabindex") || (e.tabIndex = 0), e.classList.add("is-editable"), e.setAttribute("aria-roledescription", "editable");
|
|
3820
3822
|
function s(i) {
|
|
@@ -3840,7 +3842,7 @@ function ht(e, t = {}) {
|
|
|
3840
3842
|
}, e.classList.add("is-editing"), e.replaceChildren(r), r.focus(), "select" in r && typeof r.select == "function" && r.select(), r.addEventListener("keydown", (e) => {
|
|
3841
3843
|
let t = e;
|
|
3842
3844
|
t.stopPropagation(), t.key === "Escape" ? (t.preventDefault(), f()) : t.key === "Enter" && (n !== "textarea" || t.ctrlKey || t.metaKey) && (t.preventDefault(), d());
|
|
3843
|
-
}, { signal: a.signal }), i && r.addEventListener("blur", () => void d(), { signal: a.signal }), n === "select" && r.addEventListener("change", () => void d(), { signal: a.signal }),
|
|
3845
|
+
}, { signal: a.signal }), i && r.addEventListener("blur", () => void d(), { signal: a.signal }), n === "select" && r.addEventListener("change", () => void d(), { signal: a.signal }), K(e, "editable:start", { value: t });
|
|
3844
3846
|
}
|
|
3845
3847
|
function l(t, n) {
|
|
3846
3848
|
o && (o.controller.abort(), o = null, e.classList.remove("is-editing", "is-invalid"), e.removeAttribute("aria-invalid"), e.textContent = t, n && e.focus());
|
|
@@ -3848,7 +3850,7 @@ function ht(e, t = {}) {
|
|
|
3848
3850
|
function u(t) {
|
|
3849
3851
|
if (!o) return;
|
|
3850
3852
|
let n = o.input, r = e.querySelector(".editable-error");
|
|
3851
|
-
r || (r = document.createElement("div"), r.className = "editable-error", r.id =
|
|
3853
|
+
r || (r = document.createElement("div"), r.className = "editable-error", r.id = z("editable-error"), r.setAttribute("role", "alert"), e.appendChild(r)), r.textContent = t, n.setAttribute("aria-invalid", "true"), n.setAttribute("aria-describedby", r.id), e.classList.add("is-invalid"), n.focus();
|
|
3852
3854
|
}
|
|
3853
3855
|
async function d() {
|
|
3854
3856
|
if (!o || o.saving) return;
|
|
@@ -3864,7 +3866,7 @@ function ht(e, t = {}) {
|
|
|
3864
3866
|
return;
|
|
3865
3867
|
}
|
|
3866
3868
|
}
|
|
3867
|
-
if (!
|
|
3869
|
+
if (!K(e, "editable:save", {
|
|
3868
3870
|
value: r,
|
|
3869
3871
|
previous: n.previous
|
|
3870
3872
|
})) l(n.previous, !0);
|
|
@@ -3873,7 +3875,7 @@ function ht(e, t = {}) {
|
|
|
3873
3875
|
try {
|
|
3874
3876
|
await t.onSave(r, e);
|
|
3875
3877
|
} catch (t) {
|
|
3876
|
-
e.textContent = n.previous,
|
|
3878
|
+
e.textContent = n.previous, K(e, "editable:error", {
|
|
3877
3879
|
error: t,
|
|
3878
3880
|
value: r
|
|
3879
3881
|
});
|
|
@@ -3884,7 +3886,7 @@ function ht(e, t = {}) {
|
|
|
3884
3886
|
}
|
|
3885
3887
|
}
|
|
3886
3888
|
function f() {
|
|
3887
|
-
o && (l(o.previous, !0), t.onCancel?.(e),
|
|
3889
|
+
o && (l(o.previous, !0), t.onCancel?.(e), K(e, "editable:cancel", {}));
|
|
3888
3890
|
}
|
|
3889
3891
|
return e.addEventListener("dblclick", c, { signal: a.signal }), e.addEventListener("keydown", (t) => {
|
|
3890
3892
|
o || t.target !== e || t.key !== "Enter" && t.key !== "F2" || (t.preventDefault(), c());
|
|
@@ -3901,9 +3903,9 @@ function ht(e, t = {}) {
|
|
|
3901
3903
|
}
|
|
3902
3904
|
};
|
|
3903
3905
|
}
|
|
3904
|
-
G.register("editable",
|
|
3906
|
+
G.register("editable", gt);
|
|
3905
3907
|
// src/mixins/grid-navigation.ts
|
|
3906
|
-
function
|
|
3908
|
+
function _t(e, t = {}) {
|
|
3907
3909
|
let { cellSelector: n = "[data-cell], td, th[scope=\"col\"], [role=\"gridcell\"]", rowSelector: r = "[data-row], tr, [role=\"row\"]", wrap: i = !1, tabBehavior: a = "exit", pageSize: o = 10 } = t, s = new AbortController(), { signal: c } = s, l = null, u = !e.hasAttribute("role") && !(e instanceof HTMLTableElement);
|
|
3908
3910
|
u && e.setAttribute("role", "grid");
|
|
3909
3911
|
let d = () => Array.from(e.querySelectorAll(r)).filter((e) => e.querySelector(n)), f = (e) => Array.from(e.querySelectorAll(n)).filter((t) => t.closest(r) === e);
|
|
@@ -3931,7 +3933,7 @@ function gt(e, t = {}) {
|
|
|
3931
3933
|
inline: "nearest"
|
|
3932
3934
|
});
|
|
3933
3935
|
let i = p(n);
|
|
3934
|
-
t.onNavigate?.(n, r),
|
|
3936
|
+
t.onNavigate?.(n, r), K(e, "grid:navigate", {
|
|
3935
3937
|
cell: n,
|
|
3936
3938
|
row: i?.row ?? -1,
|
|
3937
3939
|
col: i?.col ?? -1,
|
|
@@ -3955,7 +3957,7 @@ function gt(e, t = {}) {
|
|
|
3955
3957
|
return !u || u === l ? !1 : (h(u, n), !0);
|
|
3956
3958
|
}
|
|
3957
3959
|
function _(n) {
|
|
3958
|
-
l && (t.onEdit?.(l, n),
|
|
3960
|
+
l && (t.onEdit?.(l, n), K(e, "grid:edit", {
|
|
3959
3961
|
cell: l,
|
|
3960
3962
|
key: n
|
|
3961
3963
|
}));
|
|
@@ -4036,9 +4038,9 @@ function gt(e, t = {}) {
|
|
|
4036
4038
|
}
|
|
4037
4039
|
};
|
|
4038
4040
|
}
|
|
4039
|
-
G.register("grid-navigation",
|
|
4041
|
+
G.register("grid-navigation", _t);
|
|
4040
4042
|
// src/mixins/infinite-scroll.ts
|
|
4041
|
-
function
|
|
4043
|
+
function vt(e, t = {}) {
|
|
4042
4044
|
let n = t.threshold ?? 300, r = !1, i = !1, a = () => t.view && Ye() ? U().listViews.get(t.view) : void 0, o = () => {
|
|
4043
4045
|
if (t.hasMore) return t.hasMore();
|
|
4044
4046
|
let e = a();
|
|
@@ -4062,12 +4064,12 @@ function _t(e, t = {}) {
|
|
|
4062
4064
|
}), f.observe(u));
|
|
4063
4065
|
};
|
|
4064
4066
|
async function m() {
|
|
4065
|
-
if (!(r || i || !o()) &&
|
|
4067
|
+
if (!(r || i || !o()) && K(e, "infinite-scroll:load", {})) {
|
|
4066
4068
|
r = !0, e.classList.add("is-loading-more"), e.setAttribute("aria-busy", "true");
|
|
4067
4069
|
try {
|
|
4068
|
-
await s(),
|
|
4070
|
+
await s(), K(e, "infinite-scroll:loaded", {});
|
|
4069
4071
|
} catch (t) {
|
|
4070
|
-
|
|
4072
|
+
K(e, "infinite-scroll:error", { error: t });
|
|
4071
4073
|
} finally {
|
|
4072
4074
|
r = !1, e.classList.remove("is-loading-more"), e.removeAttribute("aria-busy"), u.parentElement === e && e.lastElementChild !== u && e.appendChild(u), !i && o() ? p() : f?.disconnect();
|
|
4073
4075
|
}
|
|
@@ -4083,178 +4085,330 @@ function _t(e, t = {}) {
|
|
|
4083
4085
|
}
|
|
4084
4086
|
};
|
|
4085
4087
|
}
|
|
4086
|
-
G.register("infinite-scroll",
|
|
4088
|
+
G.register("infinite-scroll", vt);
|
|
4087
4089
|
// src/mixins/sortable.ts
|
|
4088
|
-
var
|
|
4089
|
-
function
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4090
|
+
var Y = /* @__PURE__ */ new Map(), yt = !1, X = 48, bt = 18, xt = 6, St = 64, Ct = () => typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
4091
|
+
function wt(e, t, n) {
|
|
4092
|
+
if (n <= 0 || Ct() || typeof Element.prototype.animate != "function") {
|
|
4093
|
+
t();
|
|
4094
|
+
return;
|
|
4095
|
+
}
|
|
4096
|
+
let r = new Map(e.map((e) => [e, e.getBoundingClientRect()]));
|
|
4097
|
+
t();
|
|
4098
|
+
for (let [e, t] of r) {
|
|
4099
|
+
if (!e.isConnected) continue;
|
|
4100
|
+
let r = e.getBoundingClientRect(), i = t.left - r.left, a = t.top - r.top;
|
|
4101
|
+
Math.abs(i) < .5 && Math.abs(a) < .5 || (e.getAnimations?.().forEach((e) => e.cancel()), e.animate([{ transform: `translate(${i}px, ${a}px)` }, { transform: "translate(0, 0)" }], {
|
|
4102
|
+
duration: n,
|
|
4103
|
+
easing: "cubic-bezier(0.2, 0, 0, 1)"
|
|
4104
|
+
}));
|
|
4095
4105
|
}
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4106
|
+
}
|
|
4107
|
+
function Tt(e) {
|
|
4108
|
+
let t = [];
|
|
4109
|
+
for (let n = e; n && n !== document.body; n = n.parentElement) {
|
|
4110
|
+
let e = getComputedStyle(n), r = /(auto|scroll)/.test(e.overflowY) && n.scrollHeight > n.clientHeight;
|
|
4111
|
+
(/(auto|scroll)/.test(e.overflowX) && n.scrollWidth > n.clientWidth || r) && t.push(n);
|
|
4112
|
+
}
|
|
4113
|
+
let n = document.scrollingElement;
|
|
4114
|
+
return n && t.push(n), t;
|
|
4115
|
+
}
|
|
4116
|
+
function Et(e) {
|
|
4117
|
+
let t = e.getBoundingClientRect(), n = getComputedStyle(e).transform;
|
|
4118
|
+
if (!n || n === "none" || typeof DOMMatrixReadOnly > "u") return t;
|
|
4119
|
+
let r = new DOMMatrixReadOnly(n);
|
|
4120
|
+
return new DOMRect(t.left - r.e, t.top - r.f, t.width, t.height);
|
|
4121
|
+
}
|
|
4122
|
+
function Dt(e, t, n) {
|
|
4123
|
+
let r = Math.max(e.left - t, 0, t - e.right), i = Math.max(e.top - n, 0, n - e.bottom);
|
|
4124
|
+
return Math.hypot(r, i);
|
|
4125
|
+
}
|
|
4126
|
+
function Ot(e, t = {}) {
|
|
4127
|
+
let n = new AbortController(), { signal: r } = n, i = t.draggingClass ?? "is-sorting", a = t.placeholderClass ?? "sortable-placeholder", o = t.animation ?? 180, s = t.activationDistance ?? 5, c = t.touchDelay ?? 200, l = t.group, u = null, d = null;
|
|
4128
|
+
l && (Y.has(l) || Y.set(l, /* @__PURE__ */ new Set()), Y.get(l).add(e)), e.classList.add("is-sortable"), e.hasAttribute("role") || e.setAttribute("role", "list");
|
|
4129
|
+
let f = (e, n) => e.parentElement === n && !e.classList.contains(a) && (!t.items || e.matches(t.items)), p = (e) => Array.from(e.children).filter((t) => t instanceof HTMLElement && f(t, e)), m = () => (l ? Array.from(Y.get(l) ?? []) : [e]).filter((e) => e.isConnected);
|
|
4130
|
+
function h() {
|
|
4131
|
+
for (let t of p(e)) t.hasAttribute("tabindex") || (t.tabIndex = 0), t.hasAttribute("role") || t.setAttribute("role", "listitem"), t.setAttribute("aria-roledescription", "sortable item");
|
|
4132
|
+
}
|
|
4133
|
+
h();
|
|
4134
|
+
let g = typeof MutationObserver < "u" ? new MutationObserver(h) : null;
|
|
4135
|
+
g?.observe(e, { childList: !0 });
|
|
4136
|
+
function _(e) {
|
|
4100
4137
|
if (t.direction) return t.direction;
|
|
4101
4138
|
let n = getComputedStyle(e);
|
|
4102
4139
|
return n.display.includes("flex") && !n.flexDirection.startsWith("column") ? "horizontal" : "vertical";
|
|
4103
4140
|
}
|
|
4104
|
-
function
|
|
4141
|
+
function v(e) {
|
|
4105
4142
|
return e.getAttribute("aria-label") ?? e.textContent?.trim().slice(0, 60) ?? "item";
|
|
4106
4143
|
}
|
|
4107
|
-
function
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
let
|
|
4137
|
-
|
|
4144
|
+
function y() {
|
|
4145
|
+
return m().flatMap((e) => [...p(e), ...Array.from(e.querySelectorAll(`:scope > .${CSS.escape(a)}`))]).filter((e) => e !== d?.item);
|
|
4146
|
+
}
|
|
4147
|
+
function b(e, t) {
|
|
4148
|
+
let n = e.parentElement, r = p(n).indexOf(e);
|
|
4149
|
+
return d = {
|
|
4150
|
+
item: e,
|
|
4151
|
+
from: n,
|
|
4152
|
+
oldIndex: r,
|
|
4153
|
+
keyboard: t,
|
|
4154
|
+
nextSibling: e.nextSibling,
|
|
4155
|
+
offsetX: 0,
|
|
4156
|
+
offsetY: 0,
|
|
4157
|
+
fixX: 0,
|
|
4158
|
+
fixY: 0,
|
|
4159
|
+
x: 0,
|
|
4160
|
+
y: 0,
|
|
4161
|
+
lastX: 0,
|
|
4162
|
+
lastY: 0,
|
|
4163
|
+
style: e.getAttribute("style") ?? "",
|
|
4164
|
+
container: n,
|
|
4165
|
+
index: r
|
|
4166
|
+
}, d;
|
|
4167
|
+
}
|
|
4168
|
+
function x(t, n, r) {
|
|
4169
|
+
let o = b(t.item, !1), { item: s } = o, c = s.getBoundingClientRect();
|
|
4170
|
+
o.pointerId = t.pointerId, o.offsetX = t.startX - c.left, o.offsetY = t.startY - c.top;
|
|
4171
|
+
let l = document.createElement(s.tagName === "LI" ? "li" : "div");
|
|
4172
|
+
l.className = a, l.setAttribute("aria-hidden", "true");
|
|
4173
|
+
let u = getComputedStyle(s);
|
|
4174
|
+
Object.assign(l.style, {
|
|
4175
|
+
height: `${c.height}px`,
|
|
4176
|
+
width: _(o.from) === "horizontal" ? `${c.width}px` : "",
|
|
4177
|
+
flex: u.flex,
|
|
4178
|
+
minWidth: u.minWidth,
|
|
4179
|
+
maxWidth: u.maxWidth,
|
|
4180
|
+
margin: u.margin
|
|
4181
|
+
}), s.before(l), o.placeholder = l, s.classList.add(i), Object.assign(s.style, {
|
|
4138
4182
|
position: "fixed",
|
|
4139
|
-
left: `${
|
|
4140
|
-
top: `${
|
|
4141
|
-
width: `${
|
|
4142
|
-
height: `${
|
|
4183
|
+
left: `${c.left}px`,
|
|
4184
|
+
top: `${c.top}px`,
|
|
4185
|
+
width: `${c.width}px`,
|
|
4186
|
+
height: `${c.height}px`,
|
|
4187
|
+
margin: "0",
|
|
4143
4188
|
zIndex: "9999",
|
|
4144
4189
|
pointerEvents: "none",
|
|
4145
|
-
|
|
4146
|
-
}), document.body.appendChild(t), s.started = !0, q(e, "sortable:start", {
|
|
4147
|
-
item: t,
|
|
4148
|
-
from: s.from,
|
|
4149
|
-
oldIndex: s.oldIndex
|
|
4190
|
+
boxSizing: "border-box"
|
|
4150
4191
|
});
|
|
4192
|
+
let d = s.getBoundingClientRect();
|
|
4193
|
+
o.fixX = c.left - d.left, o.fixY = c.top - d.top, document.documentElement.classList.add("is-sorting-active"), K(e, "sortable:start", {
|
|
4194
|
+
item: s,
|
|
4195
|
+
from: o.from,
|
|
4196
|
+
oldIndex: o.oldIndex
|
|
4197
|
+
}), S(n, r);
|
|
4198
|
+
}
|
|
4199
|
+
function S(e, t) {
|
|
4200
|
+
d && !d.keyboard && (d.x = e, d.y = t, d.item.style.left = `${e - d.offsetX + d.fixX}px`, d.item.style.top = `${t - d.offsetY + d.fixY}px`, d.frame === void 0 && (d.frame = requestAnimationFrame(ee)));
|
|
4201
|
+
}
|
|
4202
|
+
function ee() {
|
|
4203
|
+
if (!d || d.keyboard) return;
|
|
4204
|
+
d.frame = void 0;
|
|
4205
|
+
let e = t.autoScroll !== !1 && te(d.x, d.y);
|
|
4206
|
+
ie(d.x, d.y), e && (d.frame = requestAnimationFrame(ee));
|
|
4207
|
+
}
|
|
4208
|
+
function te(e, t) {
|
|
4209
|
+
if (!d) return !1;
|
|
4210
|
+
let n = !1;
|
|
4211
|
+
for (let r of Tt(d.container)) {
|
|
4212
|
+
let i = r === document.scrollingElement, a = i ? new DOMRect(0, 0, innerWidth, innerHeight) : r.getBoundingClientRect();
|
|
4213
|
+
if (!i && Dt(a, e, t) > 0) continue;
|
|
4214
|
+
let o = (e) => Math.ceil(bt * Math.min(1, (X - e) / X)), s = t - a.top < X ? -o(t - a.top) : a.bottom - t < X ? o(a.bottom - t) : 0, c = e - a.left < X ? -o(e - a.left) : a.right - e < X ? o(a.right - e) : 0;
|
|
4215
|
+
if (!c && !s) continue;
|
|
4216
|
+
let l = r.scrollTop, u = r.scrollLeft;
|
|
4217
|
+
r.scrollBy?.(c, s), (r.scrollTop !== l || r.scrollLeft !== u) && (n = !0);
|
|
4218
|
+
}
|
|
4219
|
+
return n;
|
|
4151
4220
|
}
|
|
4152
|
-
function
|
|
4153
|
-
let n =
|
|
4154
|
-
for (let
|
|
4155
|
-
|
|
4221
|
+
function ne(e, t) {
|
|
4222
|
+
let n = null, r = St;
|
|
4223
|
+
for (let i of m()) {
|
|
4224
|
+
let a = Dt(i.getBoundingClientRect(), e, t);
|
|
4225
|
+
(a < r || a === 0 && r === 0) && (n = i, r = a);
|
|
4226
|
+
}
|
|
4227
|
+
return n;
|
|
4156
4228
|
}
|
|
4157
|
-
function
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4229
|
+
function re(e, t, n) {
|
|
4230
|
+
let r = p(e).filter((e) => e !== d?.item);
|
|
4231
|
+
if (!r.length) return 0;
|
|
4232
|
+
let i = _(e) === "horizontal", a = 0, o = Infinity, s = Infinity, c = r.map(Et);
|
|
4233
|
+
c.forEach((e, r) => {
|
|
4234
|
+
let i = Dt(e, t, n), c = Math.hypot(t - (e.left + e.width / 2), n - (e.top + e.height / 2));
|
|
4235
|
+
(i < o || i === o && c < s) && (a = r, o = i, s = c);
|
|
4236
|
+
});
|
|
4237
|
+
let l = c[a], u;
|
|
4238
|
+
return u = i ? n >= l.top && n <= l.bottom ? t > l.left + l.width / 2 : n > l.bottom : n > l.top + l.height / 2, a + +!!u;
|
|
4239
|
+
}
|
|
4240
|
+
function ie(t, n) {
|
|
4241
|
+
if (!d?.placeholder || Math.hypot(t - d.lastX, n - d.lastY) < xt || d.placeholder.isConnected && Dt(Et(d.placeholder), t, n) === 0) return;
|
|
4242
|
+
let r = ne(t, n);
|
|
4243
|
+
if (!r) return;
|
|
4244
|
+
let i = re(r, t, n);
|
|
4245
|
+
if (r === d.container && i === d.index) return;
|
|
4246
|
+
let a = d, s = p(r).filter((e) => e !== a.item);
|
|
4247
|
+
wt(y(), () => r.insertBefore(a.placeholder, s[i] ?? null), o), a.container = r, a.index = i, a.lastX = t, a.lastY = n, K(e, "sortable:move", {
|
|
4248
|
+
item: a.item,
|
|
4249
|
+
to: r,
|
|
4250
|
+
index: i
|
|
4251
|
+
});
|
|
4252
|
+
}
|
|
4253
|
+
function ae(e) {
|
|
4254
|
+
e.frame !== void 0 && cancelAnimationFrame(e.frame), e.item.classList.remove(i), e.item.removeAttribute("aria-grabbed"), e.style ? e.item.setAttribute("style", e.style) : e.item.removeAttribute("style"), document.documentElement.classList.remove("is-sorting-active");
|
|
4255
|
+
}
|
|
4256
|
+
function C(e) {
|
|
4257
|
+
if (!d) return;
|
|
4258
|
+
let t = d;
|
|
4259
|
+
d = null, t.keyboard && (yt = !1, t.item.removeEventListener("keydown", T));
|
|
4260
|
+
let { item: n, placeholder: r } = t, i = () => {
|
|
4261
|
+
ae(t), r && (e && r.parentElement && r.replaceWith(n), r.remove()), oe(t, e);
|
|
4262
|
+
};
|
|
4263
|
+
if (!r || !e || o <= 0 || Ct() || typeof n.animate != "function") {
|
|
4264
|
+
if (r && !e) {
|
|
4265
|
+
ae(t), wt(y(), () => r.remove(), o), oe(t, !1);
|
|
4266
|
+
return;
|
|
4165
4267
|
}
|
|
4268
|
+
i();
|
|
4269
|
+
return;
|
|
4166
4270
|
}
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
}
|
|
4187
|
-
r
|
|
4271
|
+
let a = n.getBoundingClientRect(), s = r.getBoundingClientRect();
|
|
4272
|
+
n.style.transition = "none";
|
|
4273
|
+
let c = n.animate([{ transform: "translate(0, 0)" }, { transform: `translate(${s.left - a.left}px, ${s.top - a.top}px)` }], {
|
|
4274
|
+
duration: o,
|
|
4275
|
+
easing: "cubic-bezier(0.2, 0, 0, 1)",
|
|
4276
|
+
fill: "forwards"
|
|
4277
|
+
}), l = () => {
|
|
4278
|
+
c.cancel(), i();
|
|
4279
|
+
};
|
|
4280
|
+
c.finished.then(l, l);
|
|
4281
|
+
}
|
|
4282
|
+
function oe(n, r) {
|
|
4283
|
+
let { item: i } = n, a = i.parentElement, s = p(a).indexOf(i), c = {
|
|
4284
|
+
item: i,
|
|
4285
|
+
id: i.getAttribute("data-id"),
|
|
4286
|
+
from: n.from,
|
|
4287
|
+
to: a,
|
|
4288
|
+
oldIndex: n.oldIndex,
|
|
4289
|
+
newIndex: s
|
|
4290
|
+
}, l = a !== n.from || s !== n.oldIndex;
|
|
4291
|
+
if (!r || l && !K(e, "sortable:end", c)) {
|
|
4292
|
+
if (l) {
|
|
4293
|
+
let e = p(n.from).filter((e) => e !== i);
|
|
4294
|
+
wt(y(), () => n.from.insertBefore(i, e[n.oldIndex] ?? null), o);
|
|
4295
|
+
}
|
|
4296
|
+
n.keyboard && J(`${v(i)} returned to position ${n.oldIndex + 1}.`);
|
|
4297
|
+
} else l ? (t.onEnd?.(c), n.keyboard && J(`${v(i)} dropped at position ${s + 1} of ${p(a).length}.`)) : n.keyboard && J(`${v(i)} dropped.`);
|
|
4298
|
+
n.keyboard && i.focus();
|
|
4299
|
+
}
|
|
4300
|
+
function se() {
|
|
4301
|
+
u?.timer && clearTimeout(u.timer), u = null;
|
|
4188
4302
|
}
|
|
4189
4303
|
e.addEventListener("pointerdown", (n) => {
|
|
4190
|
-
if (n.button !== 0 ||
|
|
4191
|
-
let r = n.target, i = Array.from(e.children).find((t) => t instanceof HTMLElement && t.contains(r) &&
|
|
4192
|
-
!i || t.handle && !r.closest(t.handle) || r.closest("input, textarea, select, button, a, [contenteditable=\"true\"]")
|
|
4304
|
+
if (n.button !== 0 || d || u) return;
|
|
4305
|
+
let r = n.target, i = Array.from(e.children).find((t) => t instanceof HTMLElement && t.contains(r) && f(t, e));
|
|
4306
|
+
if (!i || t.handle && !r.closest(t.handle) || r.closest("input, textarea, select, button, a, [contenteditable=\"true\"]")) return;
|
|
4307
|
+
let a = n.pointerType === "touch";
|
|
4308
|
+
if (u = {
|
|
4309
|
+
item: i,
|
|
4310
|
+
pointerId: n.pointerId,
|
|
4311
|
+
startX: n.clientX,
|
|
4312
|
+
startY: n.clientY,
|
|
4313
|
+
touch: a,
|
|
4314
|
+
ready: !a || c <= 0
|
|
4315
|
+
}, !u.ready) {
|
|
4316
|
+
let e = u;
|
|
4317
|
+
e.timer = setTimeout(() => {
|
|
4318
|
+
u === e && (u = null, x(e, e.startX, e.startY));
|
|
4319
|
+
}, c);
|
|
4320
|
+
}
|
|
4193
4321
|
}, { signal: r });
|
|
4194
|
-
let
|
|
4195
|
-
if (
|
|
4196
|
-
|
|
4197
|
-
if (
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4322
|
+
let ce = (e) => {
|
|
4323
|
+
if (u && e.pointerId === u.pointerId) {
|
|
4324
|
+
let t = Math.hypot(e.clientX - u.startX, e.clientY - u.startY);
|
|
4325
|
+
if (!u.ready) {
|
|
4326
|
+
t > 8 && se();
|
|
4327
|
+
return;
|
|
4328
|
+
}
|
|
4329
|
+
if (t < s) return;
|
|
4330
|
+
let n = u;
|
|
4331
|
+
u = null, x(n, e.clientX, e.clientY), e.preventDefault();
|
|
4332
|
+
} else d && !d.keyboard && e.pointerId === d.pointerId && (e.preventDefault(), S(e.clientX, e.clientY));
|
|
4333
|
+
}, w = (e) => {
|
|
4334
|
+
u && e.pointerId === u.pointerId ? se() : d && !d.keyboard && e.pointerId === d.pointerId && (e.type === "pointerup" && ie(e.clientX, e.clientY), C(e.type === "pointerup"));
|
|
4205
4335
|
};
|
|
4206
|
-
document.addEventListener("pointermove",
|
|
4336
|
+
document.addEventListener("pointermove", ce, {
|
|
4337
|
+
signal: r,
|
|
4338
|
+
passive: !1
|
|
4339
|
+
}), document.addEventListener("pointerup", w, { signal: r }), document.addEventListener("pointercancel", w, { signal: r }), document.addEventListener("touchmove", (e) => {
|
|
4340
|
+
d && !d.keyboard && e.cancelable && e.preventDefault();
|
|
4341
|
+
}, {
|
|
4207
4342
|
signal: r,
|
|
4208
4343
|
passive: !1
|
|
4209
|
-
}),
|
|
4344
|
+
}), e.addEventListener("dragstart", (e) => {
|
|
4345
|
+
(d || u) && e.preventDefault();
|
|
4346
|
+
}, { signal: r }), e.addEventListener("keydown", (t) => {
|
|
4210
4347
|
let n = t.target;
|
|
4211
|
-
|
|
4348
|
+
if (!(yt || d) && f(n, n.parentElement) && n.parentElement === e && (t.key === " " || t.key === "Enter")) {
|
|
4349
|
+
t.preventDefault();
|
|
4350
|
+
let a = b(n, !0);
|
|
4351
|
+
yt = !0, n.addEventListener("keydown", T, { signal: r }), n.classList.add(i), n.setAttribute("aria-grabbed", "true"), K(e, "sortable:start", {
|
|
4352
|
+
item: n,
|
|
4353
|
+
from: a.from,
|
|
4354
|
+
oldIndex: a.oldIndex
|
|
4355
|
+
}), J(`Picked up ${v(n)}. Position ${a.oldIndex + 1} of ${p(a.from).length}. Use arrow keys to move, Space to drop, Escape to cancel.`);
|
|
4356
|
+
}
|
|
4212
4357
|
}, { signal: r });
|
|
4213
|
-
function
|
|
4214
|
-
if (!
|
|
4215
|
-
|
|
4216
|
-
let
|
|
4217
|
-
switch (
|
|
4218
|
-
case o:
|
|
4219
|
-
i > 0 && n.insertBefore(t, r[i - 1]);
|
|
4220
|
-
break;
|
|
4358
|
+
function T(t) {
|
|
4359
|
+
if (!d || !d.keyboard || t.target !== d.item) return;
|
|
4360
|
+
t.stopPropagation();
|
|
4361
|
+
let n = d.item, r = n.parentElement, i = p(r), a = i.indexOf(n), s = _(r) === "horizontal", c = s ? "ArrowLeft" : "ArrowUp", l = s ? "ArrowRight" : "ArrowDown", u = m(), f = u.indexOf(r), h = null;
|
|
4362
|
+
switch (t.key) {
|
|
4221
4363
|
case c:
|
|
4222
|
-
|
|
4364
|
+
a > 0 && (h = () => r.insertBefore(n, i[a - 1]));
|
|
4365
|
+
break;
|
|
4366
|
+
case l:
|
|
4367
|
+
a < i.length - 1 && (h = () => r.insertBefore(n, i[a + 1].nextSibling));
|
|
4223
4368
|
break;
|
|
4224
4369
|
case "ArrowLeft":
|
|
4225
4370
|
case "ArrowRight": {
|
|
4226
|
-
let
|
|
4227
|
-
if (!
|
|
4228
|
-
let r =
|
|
4229
|
-
|
|
4371
|
+
let e = u[f + (t.key === "ArrowLeft" ? -1 : 1)];
|
|
4372
|
+
if (!e) break;
|
|
4373
|
+
let r = p(e);
|
|
4374
|
+
h = () => e.insertBefore(n, r[Math.min(a, r.length)] ?? null);
|
|
4230
4375
|
break;
|
|
4231
4376
|
}
|
|
4232
4377
|
case " ":
|
|
4233
4378
|
case "Enter":
|
|
4234
|
-
|
|
4379
|
+
t.preventDefault(), C(!0);
|
|
4235
4380
|
return;
|
|
4236
4381
|
case "Escape":
|
|
4237
|
-
|
|
4382
|
+
t.preventDefault(), C(!1);
|
|
4238
4383
|
return;
|
|
4239
4384
|
default: return;
|
|
4240
4385
|
}
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4386
|
+
if (t.preventDefault(), h) {
|
|
4387
|
+
wt([...y(), n], h, o);
|
|
4388
|
+
let t = n.parentElement;
|
|
4389
|
+
d.container = t, d.index = p(t).indexOf(n), K(e, "sortable:move", {
|
|
4390
|
+
item: n,
|
|
4391
|
+
to: t,
|
|
4392
|
+
index: d.index
|
|
4393
|
+
});
|
|
4394
|
+
}
|
|
4395
|
+
n.focus();
|
|
4396
|
+
let g = n.parentElement;
|
|
4397
|
+
J(`Position ${p(g).indexOf(n) + 1} of ${p(g).length}${g === r ? "" : `, in ${g.getAttribute("aria-label") ?? "next list"}`}.`);
|
|
4244
4398
|
}
|
|
4245
4399
|
return {
|
|
4246
4400
|
name: "sortable",
|
|
4247
4401
|
element: e,
|
|
4248
4402
|
options: t,
|
|
4249
|
-
toArray: () =>
|
|
4403
|
+
toArray: () => p(e).map((e) => e.getAttribute("data-id") ?? ""),
|
|
4250
4404
|
destroy: () => {
|
|
4251
|
-
|
|
4405
|
+
se(), d && C(!1), n.abort(), g?.disconnect(), l && Y.get(l)?.delete(e), e.classList.remove("is-sortable");
|
|
4252
4406
|
}
|
|
4253
4407
|
};
|
|
4254
4408
|
}
|
|
4255
|
-
G.register("sortable",
|
|
4409
|
+
G.register("sortable", Ot);
|
|
4256
4410
|
// src/mixins/resizable.ts
|
|
4257
|
-
function
|
|
4411
|
+
function kt(e, t = {}) {
|
|
4258
4412
|
let n = t.handles ?? [
|
|
4259
4413
|
"e",
|
|
4260
4414
|
"s",
|
|
@@ -4286,7 +4440,7 @@ function bt(e, t = {}) {
|
|
|
4286
4440
|
let t = e.dataset.edge;
|
|
4287
4441
|
e.setAttribute("aria-valuenow", String(t === "e" || t === "w" ? h.width : h.height));
|
|
4288
4442
|
}
|
|
4289
|
-
t.onResize?.(h),
|
|
4443
|
+
t.onResize?.(h), K(e, "resizable:resize", h);
|
|
4290
4444
|
}
|
|
4291
4445
|
for (let a of n) {
|
|
4292
4446
|
let n = document.createElement("div");
|
|
@@ -4303,7 +4457,7 @@ function bt(e, t = {}) {
|
|
|
4303
4457
|
y: t.clientY,
|
|
4304
4458
|
...r,
|
|
4305
4459
|
pointerId: t.pointerId
|
|
4306
|
-
}, n.setPointerCapture?.(t.pointerId), e.classList.add("is-resizing"),
|
|
4460
|
+
}, n.setPointerCapture?.(t.pointerId), e.classList.add("is-resizing"), K(e, "resizable:start", r);
|
|
4307
4461
|
}, { signal: c.signal }), n.addEventListener("pointermove", (e) => {
|
|
4308
4462
|
if (!u || e.pointerId !== u.pointerId) return;
|
|
4309
4463
|
let t = e.clientX - u.x, n = e.clientY - u.y;
|
|
@@ -4313,7 +4467,7 @@ function bt(e, t = {}) {
|
|
|
4313
4467
|
if (!u || n.pointerId !== u.pointerId) return;
|
|
4314
4468
|
u = null, e.classList.remove("is-resizing");
|
|
4315
4469
|
let r = d();
|
|
4316
|
-
t.onEnd?.(r),
|
|
4470
|
+
t.onEnd?.(r), K(e, "resizable:end", r);
|
|
4317
4471
|
};
|
|
4318
4472
|
n.addEventListener("pointerup", f, { signal: c.signal }), n.addEventListener("pointercancel", f, { signal: c.signal }), n.addEventListener("keydown", (n) => {
|
|
4319
4473
|
let r = n.shiftKey ? s * 5 : s, i = d(), o = {
|
|
@@ -4325,7 +4479,7 @@ function bt(e, t = {}) {
|
|
|
4325
4479
|
if (!o) return;
|
|
4326
4480
|
n.preventDefault(), p(a, i.width + o[0], i.height + o[1]);
|
|
4327
4481
|
let c = d();
|
|
4328
|
-
t.onEnd?.(c),
|
|
4482
|
+
t.onEnd?.(c), K(e, "resizable:end", c);
|
|
4329
4483
|
}, { signal: c.signal });
|
|
4330
4484
|
}
|
|
4331
4485
|
return {
|
|
@@ -4338,11 +4492,11 @@ function bt(e, t = {}) {
|
|
|
4338
4492
|
}
|
|
4339
4493
|
};
|
|
4340
4494
|
}
|
|
4341
|
-
G.register("resizable",
|
|
4495
|
+
G.register("resizable", kt);
|
|
4342
4496
|
// src/mixins/dropdown.ts
|
|
4343
|
-
function
|
|
4497
|
+
function At(e, t = {}) {
|
|
4344
4498
|
if (!(e instanceof HTMLSelectElement)) throw Error("dropdown mixin must be applied to a <select>");
|
|
4345
|
-
let n = e, { searchable: r = !0, emptyText: i = "No matches" } = t, a = new AbortController(), { signal: o } = a, s =
|
|
4499
|
+
let n = e, { searchable: r = !0, emptyText: i = "No matches" } = t, a = new AbortController(), { signal: o } = a, s = z("dropdown"), c = document.createElement("div");
|
|
4346
4500
|
c.className = "dropdown";
|
|
4347
4501
|
let l = document.createElement("input");
|
|
4348
4502
|
l.type = "text", l.className = "dropdown__input", l.setAttribute("role", "combobox"), l.setAttribute("aria-expanded", "false"), l.setAttribute("aria-controls", `${s}-list`), l.setAttribute("aria-autocomplete", r ? "list" : "none"), l.autocomplete = "off", l.readOnly = !r, l.placeholder = t.placeholder ?? n.getAttribute("placeholder") ?? "";
|
|
@@ -4397,7 +4551,7 @@ function xt(e, t = {}) {
|
|
|
4397
4551
|
let r = h[e];
|
|
4398
4552
|
if (!r || r.disabled) return;
|
|
4399
4553
|
let i = n.value !== r.value;
|
|
4400
|
-
n.value = r.value, l.value = r.textContent ?? "", x(!1), i && (n.dispatchEvent(new Event("input", { bubbles: !0 })), n.dispatchEvent(new Event("change", { bubbles: !0 })), t.onChange?.(r.value),
|
|
4554
|
+
n.value = r.value, l.value = r.textContent ?? "", x(!1), i && (n.dispatchEvent(new Event("input", { bubbles: !0 })), n.dispatchEvent(new Event("change", { bubbles: !0 })), t.onChange?.(r.value), K(n, "dropdown:change", {
|
|
4401
4555
|
value: r.value,
|
|
4402
4556
|
label: r.textContent
|
|
4403
4557
|
}));
|
|
@@ -4445,20 +4599,20 @@ function xt(e, t = {}) {
|
|
|
4445
4599
|
}
|
|
4446
4600
|
};
|
|
4447
4601
|
}
|
|
4448
|
-
G.register("dropdown",
|
|
4602
|
+
G.register("dropdown", At);
|
|
4449
4603
|
// src/mixins/tooltip.ts
|
|
4450
|
-
function
|
|
4604
|
+
function jt(e, t = {}) {
|
|
4451
4605
|
let { placement: n = "top", delay: r = 300 } = t, i = new AbortController(), { signal: a } = i, o = e.getAttribute("title"), s = () => t.content ?? e.dataset.tooltip ?? o ?? "";
|
|
4452
4606
|
o !== null && e.removeAttribute("title");
|
|
4453
4607
|
let c = document.createElement("div");
|
|
4454
|
-
c.id =
|
|
4608
|
+
c.id = z("tooltip"), c.className = "tooltip", c.setAttribute("role", "tooltip"), c.hidden = !0;
|
|
4455
4609
|
let l = e.getAttribute("aria-describedby");
|
|
4456
4610
|
e.setAttribute("aria-describedby", [l, c.id].filter(Boolean).join(" "));
|
|
4457
4611
|
let u = null;
|
|
4458
4612
|
function d() {
|
|
4459
4613
|
u && clearTimeout(u), u = null;
|
|
4460
4614
|
let t = s();
|
|
4461
|
-
t && (c.textContent = t, c.isConnected || document.body.appendChild(c), c.hidden = !1,
|
|
4615
|
+
t && (c.textContent = t, c.isConnected || document.body.appendChild(c), c.hidden = !1, pt(c, e.getBoundingClientRect(), n));
|
|
4462
4616
|
}
|
|
4463
4617
|
function f() {
|
|
4464
4618
|
u && clearTimeout(u), u = setTimeout(d, r);
|
|
@@ -4486,9 +4640,9 @@ function St(e, t = {}) {
|
|
|
4486
4640
|
}
|
|
4487
4641
|
};
|
|
4488
4642
|
}
|
|
4489
|
-
G.register("tooltip",
|
|
4643
|
+
G.register("tooltip", jt);
|
|
4490
4644
|
// src/mixins/context-menu.ts
|
|
4491
|
-
function
|
|
4645
|
+
function Mt(e, t = {}) {
|
|
4492
4646
|
let n = new AbortController(), { signal: r } = n, i = null, a = null, o = null, s = null, c = "", l = null, u = () => t.items ?? [];
|
|
4493
4647
|
function d() {
|
|
4494
4648
|
return i ? Array.from(i.querySelectorAll("[role=\"menuitem\"]:not([aria-disabled=\"true\"])")) : [];
|
|
@@ -4500,7 +4654,7 @@ function Ct(e, t = {}) {
|
|
|
4500
4654
|
function p(t, n, r) {
|
|
4501
4655
|
h(!1), o = r, s = document.activeElement, a = new AbortController();
|
|
4502
4656
|
let p = a.signal;
|
|
4503
|
-
i = document.createElement("div"), i.className = "context-menu", i.id =
|
|
4657
|
+
i = document.createElement("div"), i.className = "context-menu", i.id = z("menu"), i.setAttribute("role", "menu");
|
|
4504
4658
|
for (let e of u()) {
|
|
4505
4659
|
if (e.separator) {
|
|
4506
4660
|
let e = document.createElement("div");
|
|
@@ -4559,7 +4713,7 @@ function Ct(e, t = {}) {
|
|
|
4559
4713
|
}
|
|
4560
4714
|
function m(n) {
|
|
4561
4715
|
let r = o ?? e;
|
|
4562
|
-
h(), t.onSelect?.(n, r),
|
|
4716
|
+
h(), t.onSelect?.(n, r), K(e, "context-menu:select", {
|
|
4563
4717
|
action: n,
|
|
4564
4718
|
target: r
|
|
4565
4719
|
});
|
|
@@ -4593,103 +4747,103 @@ function Ct(e, t = {}) {
|
|
|
4593
4747
|
}
|
|
4594
4748
|
};
|
|
4595
4749
|
}
|
|
4596
|
-
G.register("context-menu",
|
|
4750
|
+
G.register("context-menu", Mt);
|
|
4597
4751
|
// src/mixins/index.ts
|
|
4598
|
-
function
|
|
4752
|
+
function Nt() {
|
|
4599
4753
|
let e = {
|
|
4600
|
-
draggable:
|
|
4601
|
-
editable:
|
|
4602
|
-
"grid-navigation":
|
|
4603
|
-
"infinite-scroll":
|
|
4604
|
-
sortable:
|
|
4605
|
-
resizable:
|
|
4606
|
-
dropdown:
|
|
4607
|
-
tooltip:
|
|
4608
|
-
"context-menu":
|
|
4754
|
+
draggable: ht,
|
|
4755
|
+
editable: gt,
|
|
4756
|
+
"grid-navigation": _t,
|
|
4757
|
+
"infinite-scroll": vt,
|
|
4758
|
+
sortable: Ot,
|
|
4759
|
+
resizable: kt,
|
|
4760
|
+
dropdown: At,
|
|
4761
|
+
tooltip: jt,
|
|
4762
|
+
"context-menu": Mt
|
|
4609
4763
|
};
|
|
4610
4764
|
for (let [t, n] of Object.entries(e)) G.has(t) || G.register(t, n);
|
|
4611
4765
|
}
|
|
4612
4766
|
// src/version.ts
|
|
4613
|
-
var Z = "0.1.
|
|
4767
|
+
var Z = "0.1.3";
|
|
4614
4768
|
// src/plugins/date-utils.ts
|
|
4615
|
-
function
|
|
4769
|
+
function Pt(e, t = {}) {
|
|
4616
4770
|
let n = e instanceof HTMLInputElement ? e : e.querySelector("input"), r = new AbortController();
|
|
4617
4771
|
if (!n) throw Error("datepicker: no <input> found");
|
|
4618
4772
|
let i = n.type;
|
|
4619
4773
|
n.type = "date";
|
|
4620
|
-
let a =
|
|
4621
|
-
return a && (n.min =
|
|
4622
|
-
let e =
|
|
4623
|
-
t.onChange?.(e),
|
|
4774
|
+
let a = A(t.min), o = A(t.max);
|
|
4775
|
+
return a && (n.min = M(a)), o && (n.max = M(o)), n.addEventListener("change", () => {
|
|
4776
|
+
let e = A(n.value);
|
|
4777
|
+
t.onChange?.(e), K(n, "datepicker:change", { date: e });
|
|
4624
4778
|
}, { signal: r.signal }), {
|
|
4625
4779
|
name: "datepicker",
|
|
4626
4780
|
element: e,
|
|
4627
4781
|
options: t,
|
|
4628
|
-
value: () =>
|
|
4782
|
+
value: () => A(n.value),
|
|
4629
4783
|
destroy: () => {
|
|
4630
4784
|
r.abort(), n.type = i;
|
|
4631
4785
|
}
|
|
4632
4786
|
};
|
|
4633
4787
|
}
|
|
4634
|
-
function
|
|
4788
|
+
function Ft(e, t = {}) {
|
|
4635
4789
|
let n = e.querySelector(t.startSelector ?? "[data-start], [name=\"start\"]"), r = e.querySelector(t.endSelector ?? "[data-end], [name=\"end\"]");
|
|
4636
4790
|
if (!n || !r) throw Error("daterange: start and end inputs are required");
|
|
4637
4791
|
let i = new AbortController();
|
|
4638
4792
|
n.type = "date", r.type = "date";
|
|
4639
4793
|
let a = () => (r.min = n.value || "", n.max = r.value || "", {
|
|
4640
|
-
start:
|
|
4641
|
-
end:
|
|
4794
|
+
start: A(n.value),
|
|
4795
|
+
end: A(r.value)
|
|
4642
4796
|
}), o = () => {
|
|
4643
4797
|
let n = a();
|
|
4644
|
-
t.onChange?.(n),
|
|
4798
|
+
t.onChange?.(n), K(e, "daterange:change", n);
|
|
4645
4799
|
};
|
|
4646
4800
|
return a(), n.addEventListener("change", o, { signal: i.signal }), r.addEventListener("change", o, { signal: i.signal }), {
|
|
4647
4801
|
name: "daterange",
|
|
4648
4802
|
element: e,
|
|
4649
4803
|
options: t,
|
|
4650
4804
|
value: () => ({
|
|
4651
|
-
start:
|
|
4652
|
-
end:
|
|
4805
|
+
start: A(n.value),
|
|
4806
|
+
end: A(r.value)
|
|
4653
4807
|
}),
|
|
4654
4808
|
destroy: () => i.abort()
|
|
4655
4809
|
};
|
|
4656
4810
|
}
|
|
4657
|
-
var Q = () =>
|
|
4658
|
-
function
|
|
4811
|
+
var Q = () => N(/* @__PURE__ */ new Date());
|
|
4812
|
+
function It() {
|
|
4659
4813
|
return {
|
|
4660
4814
|
name: "date-utils",
|
|
4661
4815
|
version: Z,
|
|
4662
4816
|
mixins: {
|
|
4663
|
-
datepicker:
|
|
4664
|
-
daterange:
|
|
4817
|
+
datepicker: Pt,
|
|
4818
|
+
daterange: Ft
|
|
4665
4819
|
},
|
|
4666
4820
|
validators: {
|
|
4667
4821
|
futureDate: {
|
|
4668
4822
|
fn: (e, t) => {
|
|
4669
|
-
let n =
|
|
4670
|
-
return n ? t.includeToday === !1 ?
|
|
4823
|
+
let n = A(e);
|
|
4824
|
+
return n ? t.includeToday === !1 ? N(n) > Q() : N(n) >= Q() : !0;
|
|
4671
4825
|
},
|
|
4672
4826
|
message: "Choose a date in the future"
|
|
4673
4827
|
},
|
|
4674
4828
|
pastDate: {
|
|
4675
4829
|
fn: (e, t) => {
|
|
4676
|
-
let n =
|
|
4677
|
-
return n ? t.includeToday === !1 ?
|
|
4830
|
+
let n = A(e);
|
|
4831
|
+
return n ? t.includeToday === !1 ? N(n) < Q() : N(n) <= Q() : !0;
|
|
4678
4832
|
},
|
|
4679
4833
|
message: "Choose a date in the past"
|
|
4680
4834
|
},
|
|
4681
4835
|
dateRange: {
|
|
4682
4836
|
fn: (e, t) => {
|
|
4683
|
-
let n =
|
|
4837
|
+
let n = A(e);
|
|
4684
4838
|
if (!n) return !0;
|
|
4685
|
-
let r =
|
|
4686
|
-
return !(r &&
|
|
4839
|
+
let r = A(t.min), i = A(t.max);
|
|
4840
|
+
return !(r && N(n) < N(r) || i && N(n) > N(i));
|
|
4687
4841
|
},
|
|
4688
4842
|
message: "Choose a date between {min} and {max}"
|
|
4689
4843
|
},
|
|
4690
4844
|
businessDay: {
|
|
4691
4845
|
fn: (e) => {
|
|
4692
|
-
let t =
|
|
4846
|
+
let t = A(e);
|
|
4693
4847
|
if (!t) return !0;
|
|
4694
4848
|
let n = t.getDay();
|
|
4695
4849
|
return n !== 0 && n !== 6;
|
|
@@ -4698,10 +4852,10 @@ function Dt() {
|
|
|
4698
4852
|
},
|
|
4699
4853
|
minAge: {
|
|
4700
4854
|
fn: (e, t) => {
|
|
4701
|
-
let n =
|
|
4855
|
+
let n = A(e);
|
|
4702
4856
|
if (!n) return !0;
|
|
4703
4857
|
let r = Number(t.years ?? 18), i = Q();
|
|
4704
|
-
return i.setFullYear(i.getFullYear() - r),
|
|
4858
|
+
return i.setFullYear(i.getFullYear() - r), N(n) <= i;
|
|
4705
4859
|
},
|
|
4706
4860
|
message: "You must be at least {years} years old"
|
|
4707
4861
|
}
|
|
@@ -4709,7 +4863,7 @@ function Dt() {
|
|
|
4709
4863
|
};
|
|
4710
4864
|
}
|
|
4711
4865
|
// src/plugins/async-validators.ts
|
|
4712
|
-
function
|
|
4866
|
+
function Lt() {
|
|
4713
4867
|
let e = null, t = {
|
|
4714
4868
|
debounce: 300,
|
|
4715
4869
|
failOpen: !0
|
|
@@ -4720,7 +4874,7 @@ function Ot() {
|
|
|
4720
4874
|
let s = new AbortController();
|
|
4721
4875
|
n.set(o, s), e.signal?.addEventListener("abort", () => s.abort(), { once: !0 });
|
|
4722
4876
|
try {
|
|
4723
|
-
return await
|
|
4877
|
+
return await te(r ?? t.debounce, s.signal), await i(s.signal);
|
|
4724
4878
|
} catch {
|
|
4725
4879
|
return s.signal.aborted || t.failOpen ? !0 : a;
|
|
4726
4880
|
} finally {
|
|
@@ -4784,7 +4938,7 @@ function Ot() {
|
|
|
4784
4938
|
};
|
|
4785
4939
|
}
|
|
4786
4940
|
// src/plugins/rich-text.ts
|
|
4787
|
-
var
|
|
4941
|
+
var Rt = [
|
|
4788
4942
|
"bold",
|
|
4789
4943
|
"italic",
|
|
4790
4944
|
"underline",
|
|
@@ -4796,7 +4950,7 @@ var kt = [
|
|
|
4796
4950
|
"blockquote",
|
|
4797
4951
|
"link",
|
|
4798
4952
|
"clear"
|
|
4799
|
-
],
|
|
4953
|
+
], zt = {
|
|
4800
4954
|
bold: {
|
|
4801
4955
|
label: "Bold",
|
|
4802
4956
|
icon: "B",
|
|
@@ -4900,14 +5054,14 @@ function $(e, t) {
|
|
|
4900
5054
|
return !1;
|
|
4901
5055
|
}
|
|
4902
5056
|
}
|
|
4903
|
-
function
|
|
4904
|
-
let n = new AbortController(), { signal: r } = n, i = e instanceof HTMLTextAreaElement ? e : null, a = i ? document.createElement("div") : e, o = (e) =>
|
|
5057
|
+
function Bt(e, t = {}) {
|
|
5058
|
+
let n = new AbortController(), { signal: r } = n, i = e instanceof HTMLTextAreaElement ? e : null, a = i ? document.createElement("div") : e, o = (e) => I(e, t.sanitize), s = document.createElement("div");
|
|
4905
5059
|
s.className = "rich-text", e.insertAdjacentElement("beforebegin", s);
|
|
4906
5060
|
let c = document.createElement("div");
|
|
4907
|
-
c.className = "rich-text__toolbar", c.setAttribute("role", "toolbar"), c.setAttribute("aria-label", "Formatting"), s.appendChild(c), i ? (a.innerHTML = o(i.value), i.hidden = !0, s.append(a, i)) : (a.innerHTML = o(a.innerHTML), s.appendChild(a)), a.contentEditable = "true", a.classList.add("rich-text__content"), a.setAttribute("role", "textbox"), a.setAttribute("aria-multiline", "true"), t.label && a.setAttribute("aria-label", t.label), t.placeholder && (a.dataset.placeholder = t.placeholder), a.id ||=
|
|
5061
|
+
c.className = "rich-text__toolbar", c.setAttribute("role", "toolbar"), c.setAttribute("aria-label", "Formatting"), s.appendChild(c), i ? (a.innerHTML = o(i.value), i.hidden = !0, s.append(a, i)) : (a.innerHTML = o(a.innerHTML), s.appendChild(a)), a.contentEditable = "true", a.classList.add("rich-text__content"), a.setAttribute("role", "textbox"), a.setAttribute("aria-multiline", "true"), t.label && a.setAttribute("aria-label", t.label), t.placeholder && (a.dataset.placeholder = t.placeholder), a.id ||= z("rich-text"), $("defaultParagraphSeparator", "p");
|
|
4908
5062
|
let l = [];
|
|
4909
|
-
for (let e of t.toolbar ??
|
|
4910
|
-
let t =
|
|
5063
|
+
for (let e of t.toolbar ?? Rt) {
|
|
5064
|
+
let t = zt[e];
|
|
4911
5065
|
if (!t) continue;
|
|
4912
5066
|
let n = document.createElement("button");
|
|
4913
5067
|
n.type = "button", n.className = `rich-text__button rich-text__button--${e}`, n.dataset.command = e, n.dataset.icon = t.icon, n.setAttribute("aria-label", t.label), n.title = t.shortcut ? `${t.label} (Ctrl+${t.shortcut.toUpperCase()})` : t.label, n.tabIndex = l.length === 0 ? 0 : -1, (t.state || t.block) && n.setAttribute("aria-pressed", "false"), c.appendChild(n), l.push(n);
|
|
@@ -4921,12 +5075,12 @@ function jt(e, t = {}) {
|
|
|
4921
5075
|
let p = null, m = a.innerHTML;
|
|
4922
5076
|
function h() {
|
|
4923
5077
|
let e = o(a.innerHTML);
|
|
4924
|
-
e !== m && (m = e, i && (i.value = e, i.dispatchEvent(new Event("input", { bubbles: !0 }))), a.classList.toggle("is-empty",
|
|
5078
|
+
e !== m && (m = e, i && (i.value = e, i.dispatchEvent(new Event("input", { bubbles: !0 }))), a.classList.toggle("is-empty", L(e).trim() === ""), K(a, "rich-text:change", {
|
|
4925
5079
|
html: e,
|
|
4926
|
-
text:
|
|
5080
|
+
text: L(e)
|
|
4927
5081
|
}));
|
|
4928
5082
|
}
|
|
4929
|
-
a.classList.toggle("is-empty",
|
|
5083
|
+
a.classList.toggle("is-empty", L(a.innerHTML).trim() === "");
|
|
4930
5084
|
function g() {
|
|
4931
5085
|
let e = document.getSelection();
|
|
4932
5086
|
if (!e || !e.anchorNode || !a.contains(e.anchorNode)) return;
|
|
@@ -4934,7 +5088,7 @@ function jt(e, t = {}) {
|
|
|
4934
5088
|
for (; t && t !== a && !/^(P|H2|H3|BLOCKQUOTE|PRE|LI)$/.test(t.tagName);) t = t.parentElement;
|
|
4935
5089
|
let n = t && t !== a ? t.tagName.toLowerCase() : "p";
|
|
4936
5090
|
for (let e of l) {
|
|
4937
|
-
let t =
|
|
5091
|
+
let t = zt[e.dataset.command], r = null;
|
|
4938
5092
|
if (t.block) r = n === t.block;
|
|
4939
5093
|
else if (t.state) try {
|
|
4940
5094
|
r = document.queryCommandState?.(t.state) ?? !1;
|
|
@@ -4951,12 +5105,12 @@ function jt(e, t = {}) {
|
|
|
4951
5105
|
d.value = t?.getAttribute("href") ?? "", u.hidden = !1, d.focus();
|
|
4952
5106
|
}
|
|
4953
5107
|
function v(e) {
|
|
4954
|
-
let t =
|
|
5108
|
+
let t = zt[e];
|
|
4955
5109
|
a.focus(), e === "link" ? _() : (t.block ? $("formatBlock", l.find((t) => t.dataset.command === e)?.getAttribute("aria-pressed") === "true" ? "p" : `<${t.arg}>`) : $(t.exec, t.arg), h(), g());
|
|
4956
5110
|
}
|
|
4957
5111
|
return u.addEventListener("submit", (e) => {
|
|
4958
5112
|
e.preventDefault();
|
|
4959
|
-
let t =
|
|
5113
|
+
let t = F(d.value.trim(), "link");
|
|
4960
5114
|
if (u.hidden = !0, a.focus(), p) {
|
|
4961
5115
|
let e = document.getSelection();
|
|
4962
5116
|
e?.removeAllRanges(), e?.addRange(p);
|
|
@@ -4987,7 +5141,7 @@ function jt(e, t = {}) {
|
|
|
4987
5141
|
u: "underline",
|
|
4988
5142
|
k: "link"
|
|
4989
5143
|
};
|
|
4990
|
-
r[n] && (t.toolbar ??
|
|
5144
|
+
r[n] && (t.toolbar ?? Rt).includes(r[n]) ? (e.preventDefault(), v(r[n])) : e.shiftKey && (n === "7" || n === "&") ? (e.preventDefault(), v("orderedList")) : e.shiftKey && (n === "8" || n === "*") && (e.preventDefault(), v("bulletList"));
|
|
4991
5145
|
}, { signal: r }), a.addEventListener("paste", (e) => {
|
|
4992
5146
|
let t = e.clipboardData;
|
|
4993
5147
|
if (!t) return;
|
|
@@ -5002,7 +5156,7 @@ function jt(e, t = {}) {
|
|
|
5002
5156
|
options: t,
|
|
5003
5157
|
editor: a,
|
|
5004
5158
|
getHTML: () => o(a.innerHTML),
|
|
5005
|
-
getText: () =>
|
|
5159
|
+
getText: () => L(a.innerHTML),
|
|
5006
5160
|
setHTML: (e) => {
|
|
5007
5161
|
a.innerHTML = o(e), h();
|
|
5008
5162
|
},
|
|
@@ -5012,21 +5166,21 @@ function jt(e, t = {}) {
|
|
|
5012
5166
|
}
|
|
5013
5167
|
};
|
|
5014
5168
|
}
|
|
5015
|
-
function
|
|
5169
|
+
function Vt() {
|
|
5016
5170
|
return {
|
|
5017
5171
|
name: "rich-text",
|
|
5018
5172
|
version: Z,
|
|
5019
|
-
mixins: { "rich-text":
|
|
5173
|
+
mixins: { "rich-text": Bt },
|
|
5020
5174
|
validators: {
|
|
5021
5175
|
richTextMinLength: {
|
|
5022
5176
|
fn: (e, t) => {
|
|
5023
|
-
let n =
|
|
5177
|
+
let n = L(e).trim();
|
|
5024
5178
|
return n === "" || n.length >= Number(t.min ?? 0);
|
|
5025
5179
|
},
|
|
5026
5180
|
message: "Write at least {min} characters"
|
|
5027
5181
|
},
|
|
5028
5182
|
richTextMaxLength: {
|
|
5029
|
-
fn: (e, t) =>
|
|
5183
|
+
fn: (e, t) => L(e).trim().length <= Number(t.max ?? Infinity),
|
|
5030
5184
|
message: "Keep it under {max} characters"
|
|
5031
5185
|
},
|
|
5032
5186
|
noEmptyParagraphs: {
|
|
@@ -5037,19 +5191,19 @@ function Mt() {
|
|
|
5037
5191
|
};
|
|
5038
5192
|
}
|
|
5039
5193
|
// src/plugins/builtins.ts
|
|
5040
|
-
function
|
|
5041
|
-
|
|
5194
|
+
function Ht() {
|
|
5195
|
+
dt("date-utils", It), dt("async-validators", Lt), dt("rich-text", Vt);
|
|
5042
5196
|
}
|
|
5043
|
-
|
|
5197
|
+
Ht();
|
|
5044
5198
|
// src/core/arethesis.ts
|
|
5045
|
-
var
|
|
5199
|
+
var Ut = class e extends f {
|
|
5046
5200
|
static instance = null;
|
|
5047
5201
|
version = Z;
|
|
5048
5202
|
store = new l();
|
|
5049
5203
|
listViews = new u();
|
|
5050
5204
|
optimistic;
|
|
5051
|
-
http = new
|
|
5052
|
-
validation = new
|
|
5205
|
+
http = new C();
|
|
5206
|
+
validation = new Oe();
|
|
5053
5207
|
binder;
|
|
5054
5208
|
plugins;
|
|
5055
5209
|
collab;
|
|
@@ -5064,7 +5218,7 @@ var Pt = class e extends f {
|
|
|
5064
5218
|
initPromise = null;
|
|
5065
5219
|
stopObserving = null;
|
|
5066
5220
|
constructor() {
|
|
5067
|
-
super(),
|
|
5221
|
+
super(), Nt(), Ht(), this.optimistic = new m(this.store, this.listViews), this.binder = new He(this.validation), this.plugins = new ft(this), this.collab = new xe(() => this.ws), this.http.connect({
|
|
5068
5222
|
store: this.store,
|
|
5069
5223
|
listViews: this.listViews
|
|
5070
5224
|
}), this.listViews.setLoader((e, t) => this.http.loadListView(e, t)), Je({
|
|
@@ -5105,7 +5259,7 @@ var Pt = class e extends f {
|
|
|
5105
5259
|
for (let e of t.types ?? []) this.defineType(e);
|
|
5106
5260
|
for (let [e, n] of Object.entries(t.endpoints ?? {})) this.defineEndpoint(e, n);
|
|
5107
5261
|
for (let [e, n] of Object.entries(t.validation?.messages ?? {})) this.validation.setMessage(e, n);
|
|
5108
|
-
t.auth && (this.auth = new
|
|
5262
|
+
t.auth && (this.auth = new w(t.auth, {
|
|
5109
5263
|
fetch: () => t.http?.fetch ?? globalThis.fetch.bind(globalThis),
|
|
5110
5264
|
resolveUrl: (e) => this.http.resolveUrl(e)
|
|
5111
5265
|
}), this.http.connect({ auth: this.auth })), t.persistence !== !1 && await this.initPersistence(typeof t.persistence == "object" ? t.persistence : {});
|
|
@@ -5113,10 +5267,10 @@ var Pt = class e extends f {
|
|
|
5113
5267
|
let t = e.replace(/^ws(s?):\/\//i, "http$1://");
|
|
5114
5268
|
return this.auth && this.http.isTrustedUrl(t) ? this.auth.ensureValidToken() : null;
|
|
5115
5269
|
};
|
|
5116
|
-
if (t.sse && (this.sse = new
|
|
5270
|
+
if (t.sse && (this.sse = new le({
|
|
5117
5271
|
...t.sse,
|
|
5118
5272
|
url: this.http.resolveUrl(t.sse.url)
|
|
5119
|
-
}), this.sse.connectStore(this.store, this.listViews), this.sse.setTokenProvider(n(this.sse.config.url))), t.websocket && (this.ws = new
|
|
5273
|
+
}), this.sse.connectStore(this.store, this.listViews), this.sse.setTokenProvider(n(this.sse.config.url))), t.websocket && (this.ws = new de(t.websocket), this.ws.setTokenProvider(n(t.websocket.url))), t.azurePubSub && (this.azurePubSub = new pe({
|
|
5120
5274
|
...t.azurePubSub,
|
|
5121
5275
|
negotiateUrl: this.http.resolveUrl(t.azurePubSub.negotiateUrl),
|
|
5122
5276
|
fetch: t.azurePubSub.fetch ?? t.http?.fetch
|
|
@@ -5165,15 +5319,15 @@ var Pt = class e extends f {
|
|
|
5165
5319
|
this.disconnect(), this.stopObserving?.(), this.stopObserving = null, this.plugins.destroy(), this.auth?.destroy(), this.persistence?.close(), this.clear(), e.instance === this && (e.instance = null);
|
|
5166
5320
|
}
|
|
5167
5321
|
};
|
|
5168
|
-
function
|
|
5169
|
-
return
|
|
5322
|
+
function Wt() {
|
|
5323
|
+
return Ut.getInstance();
|
|
5170
5324
|
}
|
|
5171
|
-
function
|
|
5172
|
-
return
|
|
5325
|
+
function Gt(e) {
|
|
5326
|
+
return Wt().defineType(e);
|
|
5173
5327
|
}
|
|
5174
|
-
function
|
|
5175
|
-
return
|
|
5328
|
+
function Kt(e, t) {
|
|
5329
|
+
return Wt().defineEndpoint(e, t);
|
|
5176
5330
|
}
|
|
5177
|
-
export {
|
|
5331
|
+
export { ge as $, rt as A, R as B, it as C, et as D, Ze as E, U as F, Te as G, I as H, He as I, Ce as J, A as K, Ge as L, tt as M, Xe as N, nt as O, W as P, ve as Q, Ke as R, lt as S, ot as T, F as U, L as V, Oe as W, be as X, xe as Y, ye as Z, _t as _, Bt as a, w as at, ft as b, It as c, _ as ct, Mt as d, u as dt, he as et, jt as f, l as ft, vt as g, i as gt, Ot as h, r as ht, Wt as i, le as it, $e as j, G as k, Z as l, m as lt, kt as m, a as mt, Kt as n, pe as nt, Vt as o, C as ot, At as p, s as pt, M as q, Gt as r, de as rt, Lt as s, v as st, Ut as t, k as tt, Nt as u, f as ut, gt as v, at as w, dt as x, ht as y, H as z };
|
|
5178
5332
|
|
|
5179
|
-
//# sourceMappingURL=arethesis-
|
|
5333
|
+
//# sourceMappingURL=arethesis-D0-ZaXOM.js.map
|