arethesis 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/README.md +3 -3
- package/dist/arethesis.js +84 -9
- package/dist/arethesis.js.map +1 -1
- package/dist/components/component.d.ts +1 -0
- package/dist/components/component.d.ts.map +1 -1
- package/dist/components.js +2340 -136
- package/dist/components.js.map +1 -1
- package/dist/core/arethesis.d.ts +1 -1
- package/dist/{arethesis-Cu_lOx8o.js → fuzzy-Dnlbxdby.js} +732 -325
- package/dist/fuzzy-Dnlbxdby.js.map +1 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/kit/cell-editor.d.ts +47 -0
- package/dist/kit/cell-editor.d.ts.map +1 -0
- package/dist/kit/chart.d.ts +55 -0
- package/dist/kit/chart.d.ts.map +1 -0
- package/dist/kit/command-palette.d.ts +52 -0
- package/dist/kit/command-palette.d.ts.map +1 -0
- package/dist/kit/data-table.d.ts +6 -1
- package/dist/kit/data-table.d.ts.map +1 -1
- package/dist/kit/index.d.ts +18 -1
- package/dist/kit/index.d.ts.map +1 -1
- package/dist/kit/markdown/highlight.d.ts +29 -0
- package/dist/kit/markdown/highlight.d.ts.map +1 -0
- package/dist/kit/markdown/render.d.ts +31 -0
- package/dist/kit/markdown/render.d.ts.map +1 -0
- package/dist/kit/markdown-editor.d.ts +52 -0
- package/dist/kit/markdown-editor.d.ts.map +1 -0
- package/dist/kit/sheet/formula.d.ts +106 -0
- package/dist/kit/sheet/formula.d.ts.map +1 -0
- package/dist/kit/sheet/model.d.ts +28 -0
- package/dist/kit/sheet/model.d.ts.map +1 -0
- package/dist/kit/sheet/sheet.d.ts +45 -0
- package/dist/kit/sheet/sheet.d.ts.map +1 -0
- package/dist/kit/theme-boot.generated.d.ts +2 -0
- package/dist/kit/theme-boot.generated.d.ts.map +1 -1
- package/dist/kit/theme.d.ts +5 -3
- package/dist/kit/theme.d.ts.map +1 -1
- package/dist/mixins/editable.d.ts.map +1 -1
- package/dist/mixins/grid-navigation.d.ts.map +1 -1
- package/dist/mixins/index.d.ts +2 -0
- package/dist/mixins/index.d.ts.map +1 -1
- package/dist/mixins/listbox.d.ts +19 -0
- package/dist/mixins/listbox.d.ts.map +1 -0
- package/dist/realtime/collab/anchors.d.ts +10 -0
- package/dist/realtime/collab/anchors.d.ts.map +1 -0
- package/dist/realtime/collab/collab-session.d.ts +46 -1
- package/dist/realtime/collab/collab-session.d.ts.map +1 -1
- package/dist/realtime/collab/cursor-overlay.d.ts +10 -0
- package/dist/realtime/collab/cursor-overlay.d.ts.map +1 -1
- package/dist/realtime/collab/textarea-adapter.d.ts +13 -0
- package/dist/realtime/collab/textarea-adapter.d.ts.map +1 -1
- package/dist/realtime/collab/undo-manager.d.ts +44 -0
- package/dist/realtime/collab/undo-manager.d.ts.map +1 -0
- package/dist/realtime/ot/client.d.ts +1 -1
- package/dist/realtime/ot/client.d.ts.map +1 -1
- package/dist/realtime/ot/server.d.ts +13 -1
- package/dist/realtime/ot/server.d.ts.map +1 -1
- package/dist/realtime/types.d.ts +29 -1
- package/dist/realtime/types.d.ts.map +1 -1
- package/dist/theme-polychrome-boot.js +17 -0
- package/dist/theme-polychrome.css +310 -0
- package/dist/theme.css +312 -1
- package/dist/tokens/base.tokens.json +18 -0
- package/dist/tokens/dark-high-contrast.tokens.json +11 -0
- package/dist/tokens/dark.tokens.json +81 -0
- package/dist/tokens/light-high-contrast.tokens.json +11 -0
- package/dist/tokens/light.tokens.json +81 -0
- package/dist/tokens/polychrome.base.tokens.json +45 -0
- package/dist/tokens/polychrome.dark-high-contrast.tokens.json +183 -0
- package/dist/tokens/polychrome.dark.tokens.json +321 -0
- package/dist/tokens/polychrome.light-high-contrast.tokens.json +115 -0
- package/dist/tokens/polychrome.light.tokens.json +418 -0
- package/dist/tokens/polychrome.resolver.json +78 -0
- package/dist/utils/fuzzy.d.ts +21 -0
- package/dist/utils/fuzzy.d.ts.map +1 -0
- package/dist/version.d.ts +1 -1
- package/package.json +3 -1
- package/dist/arethesis-Cu_lOx8o.js.map +0 -1
|
@@ -1221,18 +1221,18 @@ var C = class {
|
|
|
1221
1221
|
this.map.delete(e);
|
|
1222
1222
|
}
|
|
1223
1223
|
};
|
|
1224
|
-
function
|
|
1224
|
+
function se(e) {
|
|
1225
1225
|
try {
|
|
1226
1226
|
return e === "memory" ? new oe() : e === "session" ? sessionStorage : e && typeof e == "object" ? e : localStorage;
|
|
1227
1227
|
} catch {
|
|
1228
1228
|
return new oe();
|
|
1229
1229
|
}
|
|
1230
1230
|
}
|
|
1231
|
-
function
|
|
1231
|
+
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 le = class extends f {
|
|
1236
1236
|
config;
|
|
1237
1237
|
storage;
|
|
1238
1238
|
refreshPromise = null;
|
|
@@ -1247,7 +1247,7 @@ var T = class extends f {
|
|
|
1247
1247
|
refreshThreshold: 60,
|
|
1248
1248
|
refreshBodyField: "refresh_token",
|
|
1249
1249
|
...e
|
|
1250
|
-
}, this.storage =
|
|
1250
|
+
}, this.storage = se(e.storage), this.fetchImpl = t.fetch ?? (() => globalThis.fetch.bind(globalThis)), this.resolveUrl = t.resolveUrl ?? ((e) => e), typeof window < "u" && (e.storage === void 0 || e.storage === "local") && (this.storageListener = (e) => {
|
|
1251
1251
|
(e.key === this.config.accessTokenKey || e.key === null) && (this.parsed = null, this.emit("change", { authenticated: this.isAuthenticated() }));
|
|
1252
1252
|
}, window.addEventListener("storage", this.storageListener));
|
|
1253
1253
|
}
|
|
@@ -1286,7 +1286,7 @@ var T = class extends f {
|
|
|
1286
1286
|
else {
|
|
1287
1287
|
let n = e.split(".");
|
|
1288
1288
|
if (n.length === 3) try {
|
|
1289
|
-
let e = JSON.parse(
|
|
1289
|
+
let e = JSON.parse(ce(n[1]));
|
|
1290
1290
|
t = e && typeof e == "object" ? e : null;
|
|
1291
1291
|
} catch {
|
|
1292
1292
|
t = null;
|
|
@@ -1397,7 +1397,7 @@ var T = class extends f {
|
|
|
1397
1397
|
destroy() {
|
|
1398
1398
|
this.storageListener && window.removeEventListener("storage", this.storageListener), this.storageListener = null, this.clear();
|
|
1399
1399
|
}
|
|
1400
|
-
},
|
|
1400
|
+
}, w = class extends f {
|
|
1401
1401
|
options;
|
|
1402
1402
|
attempts = 0;
|
|
1403
1403
|
timer = null;
|
|
@@ -1432,7 +1432,7 @@ var T = class extends f {
|
|
|
1432
1432
|
cancel() {
|
|
1433
1433
|
this.timer && clearTimeout(this.timer), this.timer = null, this.attempts = 0;
|
|
1434
1434
|
}
|
|
1435
|
-
},
|
|
1435
|
+
}, ue = class {
|
|
1436
1436
|
config;
|
|
1437
1437
|
source = null;
|
|
1438
1438
|
store = null;
|
|
@@ -1444,7 +1444,7 @@ var T = 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 w(e);
|
|
1448
1448
|
}
|
|
1449
1449
|
connectStore(e, t) {
|
|
1450
1450
|
this.store = e, this.listViews = t ?? null;
|
|
@@ -1556,7 +1556,7 @@ var T = 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
|
+
}, de = /* @__PURE__ */ new Set(["ping", "pong"]), fe = class {
|
|
1560
1560
|
config;
|
|
1561
1561
|
socket = null;
|
|
1562
1562
|
channels = /* @__PURE__ */ new Map();
|
|
@@ -1571,7 +1571,7 @@ var T = class extends f {
|
|
|
1571
1571
|
pingInterval: 3e4,
|
|
1572
1572
|
maxQueue: 1e3,
|
|
1573
1573
|
...e
|
|
1574
|
-
}, this.policy = new
|
|
1574
|
+
}, this.policy = new w(e);
|
|
1575
1575
|
}
|
|
1576
1576
|
setTokenProvider(e) {
|
|
1577
1577
|
this.getToken = e;
|
|
@@ -1626,7 +1626,7 @@ var T = 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" && !de.has(t.type) && this.dispatch(t);
|
|
1630
1630
|
};
|
|
1631
1631
|
}
|
|
1632
1632
|
dispatch(e) {
|
|
@@ -1692,7 +1692,7 @@ var T = class extends f {
|
|
|
1692
1692
|
}
|
|
1693
1693
|
this.policy.status = "closed";
|
|
1694
1694
|
}
|
|
1695
|
-
},
|
|
1695
|
+
}, pe = "json.webpubsub.azure.v1", me = class {
|
|
1696
1696
|
config;
|
|
1697
1697
|
socket = null;
|
|
1698
1698
|
channels = /* @__PURE__ */ new Map();
|
|
@@ -1713,7 +1713,7 @@ var T = class extends f {
|
|
|
1713
1713
|
ackTimeout: 15e3,
|
|
1714
1714
|
autoJoinGroups: [],
|
|
1715
1715
|
...e
|
|
1716
|
-
}, this.policy = new
|
|
1716
|
+
}, this.policy = new w(e);
|
|
1717
1717
|
}
|
|
1718
1718
|
connectStore(e, t) {
|
|
1719
1719
|
this.store = e, this.listViews = t ?? null;
|
|
@@ -1749,7 +1749,7 @@ var T = 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, pe) : new WebSocket(t, pe);
|
|
1753
1753
|
this.socket = n, n.onmessage = (e) => {
|
|
1754
1754
|
if (this.socket !== n) return;
|
|
1755
1755
|
let t;
|
|
@@ -1901,11 +1901,11 @@ var T = class extends f {
|
|
|
1901
1901
|
}
|
|
1902
1902
|
this.policy.status = "closed";
|
|
1903
1903
|
}
|
|
1904
|
-
},
|
|
1905
|
-
function
|
|
1904
|
+
}, T = (e) => typeof e == "number" && e > 0, he = (e) => typeof e == "number" && e < 0, E = (e) => typeof e == "string";
|
|
1905
|
+
function ge(e) {
|
|
1906
1906
|
return e === void 0 ? "none" : typeof e == "string" ? "insert" : e > 0 ? "retain" : "delete";
|
|
1907
1907
|
}
|
|
1908
|
-
var
|
|
1908
|
+
var D = class e {
|
|
1909
1909
|
ops = [];
|
|
1910
1910
|
baseLength = 0;
|
|
1911
1911
|
targetLength = 0;
|
|
@@ -1914,16 +1914,16 @@ var k = 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 && T(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 && E(n)) t[t.length - 1] = n + e;
|
|
1924
|
+
else if (n !== void 0 && he(n)) {
|
|
1925
1925
|
let r = t[t.length - 2];
|
|
1926
|
-
r !== void 0 &&
|
|
1926
|
+
r !== void 0 && E(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 k = 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 && he(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 && T(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) T(r) ? (t.push(e.slice(n, n + r)), n += r) : E(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) T(e) ? (n.retain(e), r += e) : E(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 = ge(s), t = ge(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 k = 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 = ge(l), t = ge(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 k = 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
|
+
T(i) ? r += i : E(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 k = class e {
|
|
|
2025
2025
|
return n;
|
|
2026
2026
|
}
|
|
2027
2027
|
toString() {
|
|
2028
|
-
return this.ops.map((e) =>
|
|
2028
|
+
return this.ops.map((e) => T(e) ? `retain ${e}` : E(e) ? `insert ${JSON.stringify(e)}` : `delete ${-e}`).join(", ");
|
|
2029
2029
|
}
|
|
2030
|
-
},
|
|
2030
|
+
}, _e = class {
|
|
2031
2031
|
callbacks;
|
|
2032
2032
|
revision;
|
|
2033
2033
|
outstanding = null;
|
|
@@ -2045,9 +2045,9 @@ var k = class e {
|
|
|
2045
2045
|
this.revision++;
|
|
2046
2046
|
let t = e;
|
|
2047
2047
|
if (this.outstanding) {
|
|
2048
|
-
let [e, n] =
|
|
2048
|
+
let [e, n] = D.transform(this.outstanding, t);
|
|
2049
2049
|
if (this.outstanding = e, t = n, this.buffer) {
|
|
2050
|
-
let [e, n] =
|
|
2050
|
+
let [e, n] = D.transform(this.buffer, t);
|
|
2051
2051
|
this.buffer = e, t = n;
|
|
2052
2052
|
}
|
|
2053
2053
|
}
|
|
@@ -2060,11 +2060,11 @@ var k = class e {
|
|
|
2060
2060
|
resend() {
|
|
2061
2061
|
this.outstanding && this.callbacks.send(this.revision, this.outstanding);
|
|
2062
2062
|
}
|
|
2063
|
-
transformIndex(e) {
|
|
2064
|
-
let
|
|
2065
|
-
return this.outstanding && (
|
|
2063
|
+
transformIndex(e, t = !1) {
|
|
2064
|
+
let n = e;
|
|
2065
|
+
return this.outstanding && (n = this.outstanding.transformIndex(n, t)), this.buffer && (n = this.buffer.transformIndex(n, t)), n;
|
|
2066
2066
|
}
|
|
2067
|
-
},
|
|
2067
|
+
}, O = class {
|
|
2068
2068
|
element;
|
|
2069
2069
|
previous;
|
|
2070
2070
|
composing = !1;
|
|
@@ -2076,11 +2076,36 @@ var k = class e {
|
|
|
2076
2076
|
return this.element.value;
|
|
2077
2077
|
}
|
|
2078
2078
|
setValue(e) {
|
|
2079
|
-
this.element.value = e, this.previous = e;
|
|
2079
|
+
this.element.value = e, this.previous = e, this.announce(null, !0);
|
|
2080
|
+
}
|
|
2081
|
+
announce(e, t) {
|
|
2082
|
+
this.element.dispatchEvent(new CustomEvent("collab:apply", { detail: {
|
|
2083
|
+
op: e,
|
|
2084
|
+
remote: t
|
|
2085
|
+
} }));
|
|
2080
2086
|
}
|
|
2081
2087
|
applyOperation(e) {
|
|
2082
2088
|
let t = this.element, n = document.activeElement === t, r = t.selectionStart ?? 0, i = t.selectionEnd ?? 0, a = t.selectionDirection, o = e.apply(this.previous), s = t.scrollTop;
|
|
2083
|
-
t.value = o, this.previous = o, n && t.setSelectionRange(e.transformIndex(r, !0), e.transformIndex(i, !0), a ?? void 0), t.scrollTop = s;
|
|
2089
|
+
t.value = o, this.previous = o, n && t.setSelectionRange(e.transformIndex(r, !0), e.transformIndex(i, !0), a ?? void 0), t.scrollTop = s, this.announce(e, !0);
|
|
2090
|
+
}
|
|
2091
|
+
applyLocal(e, t) {
|
|
2092
|
+
let n = this.element, r = e.apply(this.previous);
|
|
2093
|
+
n.value = r, this.previous = r, n.setSelectionRange(t, t), this.announce(e, !1);
|
|
2094
|
+
}
|
|
2095
|
+
attachHistory(e, t) {
|
|
2096
|
+
let { signal: n } = this.controller;
|
|
2097
|
+
this.element.addEventListener("keydown", (n) => {
|
|
2098
|
+
let r = n;
|
|
2099
|
+
if (r.defaultPrevented || !(r.ctrlKey || r.metaKey) || r.altKey) return;
|
|
2100
|
+
let i = r.key.toLowerCase();
|
|
2101
|
+
if (i === "z" && !r.shiftKey) e();
|
|
2102
|
+
else if (i === "z" && r.shiftKey || i === "y" && !r.shiftKey) t();
|
|
2103
|
+
else return;
|
|
2104
|
+
r.preventDefault();
|
|
2105
|
+
}, { signal: n }), this.element.addEventListener("beforeinput", (n) => {
|
|
2106
|
+
let r = n.inputType;
|
|
2107
|
+
(r === "historyUndo" || r === "historyRedo") && (n.preventDefault(), r === "historyUndo" ? e() : t());
|
|
2108
|
+
}, { signal: n });
|
|
2084
2109
|
}
|
|
2085
2110
|
getSelection() {
|
|
2086
2111
|
let e = this.element.selectionStart ?? 0, t = this.element.selectionEnd ?? 0;
|
|
@@ -2097,7 +2122,7 @@ var k = class e {
|
|
|
2097
2122
|
if (this.composing) return;
|
|
2098
2123
|
let t = this.element.value;
|
|
2099
2124
|
if (t === this.previous) return;
|
|
2100
|
-
let n =
|
|
2125
|
+
let n = D.fromDiff(this.previous, t);
|
|
2101
2126
|
this.previous = t, e(n);
|
|
2102
2127
|
};
|
|
2103
2128
|
this.element.addEventListener("input", r, { signal: n }), this.element.addEventListener("compositionstart", () => this.composing = !0, { signal: n }), this.element.addEventListener("compositionend", () => {
|
|
@@ -2117,11 +2142,11 @@ var k = class e {
|
|
|
2117
2142
|
destroy() {
|
|
2118
2143
|
this.controller.abort();
|
|
2119
2144
|
}
|
|
2120
|
-
},
|
|
2121
|
-
function
|
|
2122
|
-
let
|
|
2123
|
-
for (let e of
|
|
2124
|
-
Object.assign(
|
|
2145
|
+
}, ve = /* @__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(".");
|
|
2146
|
+
function ye(e) {
|
|
2147
|
+
let t = document.createElement("div"), n = getComputedStyle(e);
|
|
2148
|
+
for (let e of ve) t.style[e] = n[e];
|
|
2149
|
+
return Object.assign(t.style, {
|
|
2125
2150
|
position: "absolute",
|
|
2126
2151
|
visibility: "hidden",
|
|
2127
2152
|
top: "0",
|
|
@@ -2129,7 +2154,14 @@ function _e(e, t) {
|
|
|
2129
2154
|
whiteSpace: e instanceof HTMLInputElement ? "pre" : "pre-wrap",
|
|
2130
2155
|
wordWrap: "break-word",
|
|
2131
2156
|
overflow: "hidden"
|
|
2132
|
-
}),
|
|
2157
|
+
}), {
|
|
2158
|
+
mirror: t,
|
|
2159
|
+
style: n
|
|
2160
|
+
};
|
|
2161
|
+
}
|
|
2162
|
+
function be(e, t) {
|
|
2163
|
+
let { mirror: n, style: r } = ye(e);
|
|
2164
|
+
n.textContent = e.value.slice(0, t);
|
|
2133
2165
|
let i = document.createElement("span");
|
|
2134
2166
|
i.textContent = e.value.slice(t) || ".", n.appendChild(i), document.body.appendChild(n);
|
|
2135
2167
|
let a = parseFloat(r.lineHeight) || parseFloat(r.fontSize) * 1.2 || 16, o = {
|
|
@@ -2139,7 +2171,20 @@ function _e(e, t) {
|
|
|
2139
2171
|
};
|
|
2140
2172
|
return n.remove(), o;
|
|
2141
2173
|
}
|
|
2142
|
-
|
|
2174
|
+
function xe(e, t, n) {
|
|
2175
|
+
let r = Math.max(0, Math.min(t, n)), i = Math.min(e.value.length, Math.max(t, n));
|
|
2176
|
+
if (r === i) return [];
|
|
2177
|
+
let { mirror: a, style: o } = ye(e), s = document.createElement("span");
|
|
2178
|
+
s.textContent = e.value.slice(r, i), a.append(e.value.slice(0, r), s, e.value.slice(i) || "."), document.body.appendChild(a);
|
|
2179
|
+
let c = a.getBoundingClientRect(), l = parseFloat(o.lineHeight) || parseFloat(o.fontSize) * 1.2 || 16, u = Array.from(s.getClientRects()).filter((e) => e.width > .5).map((e) => ({
|
|
2180
|
+
top: e.top - c.top + (e.height - l) / 2,
|
|
2181
|
+
left: e.left - c.left,
|
|
2182
|
+
width: e.width,
|
|
2183
|
+
height: l
|
|
2184
|
+
}));
|
|
2185
|
+
return a.remove(), u;
|
|
2186
|
+
}
|
|
2187
|
+
var Se = class {
|
|
2143
2188
|
textarea;
|
|
2144
2189
|
layer;
|
|
2145
2190
|
cursors = [];
|
|
@@ -2173,7 +2218,20 @@ var ve = class {
|
|
|
2173
2218
|
this.layer.replaceChildren();
|
|
2174
2219
|
for (let r of this.cursors) {
|
|
2175
2220
|
if (!r.selection) continue;
|
|
2176
|
-
let i = r.user?.color ?? "#7c3aed"
|
|
2221
|
+
let i = r.user?.color ?? "#7c3aed";
|
|
2222
|
+
for (let a of xe(e, r.selection.anchor, r.selection.head)) {
|
|
2223
|
+
let e = document.createElement("div");
|
|
2224
|
+
e.className = "collab-selection", Object.assign(e.style, {
|
|
2225
|
+
position: "absolute",
|
|
2226
|
+
top: `${t + a.top}px`,
|
|
2227
|
+
left: `${n + a.left}px`,
|
|
2228
|
+
width: `${a.width}px`,
|
|
2229
|
+
height: `${a.height}px`,
|
|
2230
|
+
background: i,
|
|
2231
|
+
opacity: "0.22"
|
|
2232
|
+
}), this.layer.appendChild(e);
|
|
2233
|
+
}
|
|
2234
|
+
let a = be(e, Math.min(r.selection.head, e.value.length)), o = document.createElement("div");
|
|
2177
2235
|
o.className = "collab-cursor", Object.assign(o.style, {
|
|
2178
2236
|
position: "absolute",
|
|
2179
2237
|
top: `${t + a.top}px`,
|
|
@@ -2196,7 +2254,93 @@ var ve = class {
|
|
|
2196
2254
|
destroy() {
|
|
2197
2255
|
cancelAnimationFrame(this.frame), this.controller.abort(), this.layer.remove();
|
|
2198
2256
|
}
|
|
2199
|
-
}
|
|
2257
|
+
};
|
|
2258
|
+
// src/realtime/collab/undo-manager.ts
|
|
2259
|
+
function Ce(e) {
|
|
2260
|
+
let t = 0, n = 0;
|
|
2261
|
+
for (let r of e.ops) typeof r == "string" ? t++ : r < 0 && n++;
|
|
2262
|
+
return t === 1 && n === 0 ? "insert" : n === 1 && t === 0 ? "delete" : "other";
|
|
2263
|
+
}
|
|
2264
|
+
var we = class e {
|
|
2265
|
+
undoStack = [];
|
|
2266
|
+
redoStack = [];
|
|
2267
|
+
groupInterval;
|
|
2268
|
+
limit;
|
|
2269
|
+
sealed = !0;
|
|
2270
|
+
constructor(e = {}) {
|
|
2271
|
+
this.groupInterval = e.groupInterval ?? 800, this.limit = e.limit ?? 200;
|
|
2272
|
+
}
|
|
2273
|
+
get canUndo() {
|
|
2274
|
+
return this.undoStack.length > 0;
|
|
2275
|
+
}
|
|
2276
|
+
get canRedo() {
|
|
2277
|
+
return this.redoStack.length > 0;
|
|
2278
|
+
}
|
|
2279
|
+
record(e, t, n = Date.now()) {
|
|
2280
|
+
if (e.isNoop()) return;
|
|
2281
|
+
let r = e.invert(t), i = Ce(e), a = this.undoStack[this.undoStack.length - 1], o = e.ops.some((e) => typeof e == "string" && e.includes("\n"));
|
|
2282
|
+
a && !this.sealed && i !== "other" && i === a.kind && !o && n - a.time < this.groupInterval ? (a.op = r.compose(a.op), a.time = n) : (this.undoStack.push({
|
|
2283
|
+
op: r,
|
|
2284
|
+
time: n,
|
|
2285
|
+
kind: i
|
|
2286
|
+
}), this.undoStack.length > this.limit && this.undoStack.shift()), this.sealed = o, this.redoStack = [];
|
|
2287
|
+
}
|
|
2288
|
+
break() {
|
|
2289
|
+
this.sealed = !0;
|
|
2290
|
+
}
|
|
2291
|
+
transform(t) {
|
|
2292
|
+
this.undoStack = e.rebase(this.undoStack, t), this.redoStack = e.rebase(this.redoStack, t), this.sealed = !0;
|
|
2293
|
+
}
|
|
2294
|
+
static rebase(e, t) {
|
|
2295
|
+
let n = t, r = [];
|
|
2296
|
+
for (let t = e.length - 1; t >= 0; t--) {
|
|
2297
|
+
let [i, a] = D.transform(e[t].op, n);
|
|
2298
|
+
n = a, i.isNoop() || r.unshift({
|
|
2299
|
+
...e[t],
|
|
2300
|
+
op: i
|
|
2301
|
+
});
|
|
2302
|
+
}
|
|
2303
|
+
return r;
|
|
2304
|
+
}
|
|
2305
|
+
undo(e) {
|
|
2306
|
+
let t = this.undoStack.pop();
|
|
2307
|
+
return t ? (this.redoStack.push({
|
|
2308
|
+
op: t.op.invert(e),
|
|
2309
|
+
time: 0,
|
|
2310
|
+
kind: "other"
|
|
2311
|
+
}), this.sealed = !0, t.op) : null;
|
|
2312
|
+
}
|
|
2313
|
+
redo(e) {
|
|
2314
|
+
let t = this.redoStack.pop();
|
|
2315
|
+
return t ? (this.undoStack.push({
|
|
2316
|
+
op: t.op.invert(e),
|
|
2317
|
+
time: 0,
|
|
2318
|
+
kind: "other"
|
|
2319
|
+
}), this.sealed = !0, t.op) : null;
|
|
2320
|
+
}
|
|
2321
|
+
clear() {
|
|
2322
|
+
this.undoStack = [], this.redoStack = [], this.sealed = !0;
|
|
2323
|
+
}
|
|
2324
|
+
};
|
|
2325
|
+
function Te(e) {
|
|
2326
|
+
let t = 0, n = -1;
|
|
2327
|
+
for (let r of e.ops) typeof r == "string" ? (t += r.length, n = t) : r > 0 ? t += r : n = t;
|
|
2328
|
+
return n === -1 ? 0 : n;
|
|
2329
|
+
}
|
|
2330
|
+
// src/realtime/collab/anchors.ts
|
|
2331
|
+
function Ee(e, t) {
|
|
2332
|
+
return De(e, (e, n) => t.transformIndex(e, n));
|
|
2333
|
+
}
|
|
2334
|
+
function De(e, t) {
|
|
2335
|
+
let n = e.from === e.to, r = t(e.from, n), i = n ? r : Math.max(r, t(e.to, !0));
|
|
2336
|
+
return {
|
|
2337
|
+
...e,
|
|
2338
|
+
from: r,
|
|
2339
|
+
to: i
|
|
2340
|
+
};
|
|
2341
|
+
}
|
|
2342
|
+
// src/realtime/collab/collab-session.ts
|
|
2343
|
+
var Oe = class extends f {
|
|
2200
2344
|
ws;
|
|
2201
2345
|
options;
|
|
2202
2346
|
docId;
|
|
@@ -2213,9 +2357,13 @@ var ve = class {
|
|
|
2213
2357
|
presenceTimer = null;
|
|
2214
2358
|
_status = "connecting";
|
|
2215
2359
|
wasReadOnly = null;
|
|
2360
|
+
history = null;
|
|
2361
|
+
lastContent = "";
|
|
2362
|
+
annotationMap = /* @__PURE__ */ new Map();
|
|
2363
|
+
pendingAnnotations = [];
|
|
2216
2364
|
clientId = null;
|
|
2217
2365
|
constructor(e, t, n, r = {}) {
|
|
2218
|
-
super(), this.ws = e, this.options = r, this.docId = t, this.channel = `doc:${t}`, this.adapter = n instanceof HTMLElement ? new
|
|
2366
|
+
super(), this.ws = e, this.options = r, this.docId = t, this.channel = `doc:${t}`, this.adapter = n instanceof HTMLElement ? new O(n) : n, n instanceof HTMLTextAreaElement && r.cursors !== !1 && (this.overlay = new Se(n)), n instanceof HTMLElement && (n.setAttribute("aria-busy", "true"), (n instanceof HTMLTextAreaElement || n instanceof HTMLInputElement) && (this.wasReadOnly = n.readOnly, n.readOnly = !0)), this.adapter.attach((e) => this.handleLocalEdit(e), (e) => this.queuePresence(e)), r.undo && (this.history = new we(), this.adapter.attachHistory?.(() => this.undo(), () => this.redo())), this.unsubscribe = e.subscribe(this.channel, (e) => this.handleMessage(e)), this.offOpen = e.onOpen(() => this.join()), this.offStatus = e.onStatusChange((e) => {
|
|
2219
2367
|
e !== "open" && this.setStatus("offline");
|
|
2220
2368
|
}), e.isConnected ? this.join() : e.connect();
|
|
2221
2369
|
}
|
|
@@ -2231,6 +2379,72 @@ var ve = class {
|
|
|
2231
2379
|
get peers() {
|
|
2232
2380
|
return Array.from(this.cursors.values());
|
|
2233
2381
|
}
|
|
2382
|
+
get annotations() {
|
|
2383
|
+
return [...this.annotationMap.values()].sort((e, t) => e.from - t.from || e.to - t.to);
|
|
2384
|
+
}
|
|
2385
|
+
get canUndo() {
|
|
2386
|
+
return this.history?.canUndo ?? !1;
|
|
2387
|
+
}
|
|
2388
|
+
get canRedo() {
|
|
2389
|
+
return this.history?.canRedo ?? !1;
|
|
2390
|
+
}
|
|
2391
|
+
undo() {
|
|
2392
|
+
return this.applyHistory(this.history?.undo(this.adapter.getValue()) ?? null);
|
|
2393
|
+
}
|
|
2394
|
+
redo() {
|
|
2395
|
+
return this.applyHistory(this.history?.redo(this.adapter.getValue()) ?? null);
|
|
2396
|
+
}
|
|
2397
|
+
applyHistory(e) {
|
|
2398
|
+
return !e || !this.client || !this.adapter.applyLocal ? !1 : (this.adapter.applyLocal(e, Te(e)), this.commitLocal(e), !0);
|
|
2399
|
+
}
|
|
2400
|
+
annotate(e, t, n, r = `a-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`) {
|
|
2401
|
+
return this.sendAnnotation({
|
|
2402
|
+
action: "add",
|
|
2403
|
+
annotation: {
|
|
2404
|
+
id: r,
|
|
2405
|
+
from: Math.min(e, t),
|
|
2406
|
+
to: Math.max(e, t),
|
|
2407
|
+
body: n,
|
|
2408
|
+
user: this.options.user,
|
|
2409
|
+
createdAt: Date.now()
|
|
2410
|
+
}
|
|
2411
|
+
}), r;
|
|
2412
|
+
}
|
|
2413
|
+
updateAnnotation(e, t) {
|
|
2414
|
+
this.sendAnnotation({
|
|
2415
|
+
action: "update",
|
|
2416
|
+
annotation: {
|
|
2417
|
+
...t,
|
|
2418
|
+
id: e
|
|
2419
|
+
}
|
|
2420
|
+
});
|
|
2421
|
+
}
|
|
2422
|
+
removeAnnotation(e) {
|
|
2423
|
+
this.sendAnnotation({
|
|
2424
|
+
action: "remove",
|
|
2425
|
+
annotation: { id: e }
|
|
2426
|
+
});
|
|
2427
|
+
}
|
|
2428
|
+
sendAnnotation(e) {
|
|
2429
|
+
this.pendingAnnotations.push(e), this.flushAnnotations();
|
|
2430
|
+
}
|
|
2431
|
+
flushAnnotations() {
|
|
2432
|
+
if (this.client && this.client.state === "synchronized" && this.ws.isConnected) for (let e of this.pendingAnnotations.splice(0)) this.ws.send({
|
|
2433
|
+
type: "collab:annotate",
|
|
2434
|
+
channel: this.channel,
|
|
2435
|
+
payload: {
|
|
2436
|
+
...e,
|
|
2437
|
+
revision: this.client.revision
|
|
2438
|
+
}
|
|
2439
|
+
});
|
|
2440
|
+
}
|
|
2441
|
+
toLocalRange(e) {
|
|
2442
|
+
let t = this.client;
|
|
2443
|
+
return t ? De(e, (e, n) => t.transformIndex(e, n)) : e;
|
|
2444
|
+
}
|
|
2445
|
+
emitAnnotations() {
|
|
2446
|
+
this.emit("annotations", this.annotations);
|
|
2447
|
+
}
|
|
2234
2448
|
setStatus(e) {
|
|
2235
2449
|
e !== this._status && (this._status = e, this.emit("status", e));
|
|
2236
2450
|
}
|
|
@@ -2252,7 +2466,7 @@ var ve = class {
|
|
|
2252
2466
|
break;
|
|
2253
2467
|
case "collab:op":
|
|
2254
2468
|
if (!this.client || t.clientId === this.clientId) return;
|
|
2255
|
-
this.client.applyServer(
|
|
2469
|
+
this.client.applyServer(D.fromJSON(t.op)), this.updateStatus();
|
|
2256
2470
|
break;
|
|
2257
2471
|
case "collab:ack":
|
|
2258
2472
|
if (!this.client || t.opId && t.opId !== this.outstandingOpId) return;
|
|
@@ -2272,14 +2486,20 @@ var ve = class {
|
|
|
2272
2486
|
case "collab:leave":
|
|
2273
2487
|
this.cursors.delete(String(t.clientId)) && this.emitPresence();
|
|
2274
2488
|
break;
|
|
2489
|
+
case "collab:annotate": {
|
|
2490
|
+
let { action: e, annotation: n } = t;
|
|
2491
|
+
if (!n?.id) return;
|
|
2492
|
+
e === "remove" ? this.annotationMap.delete(n.id) : this.annotationMap.set(n.id, this.toLocalRange(n)), this.emitAnnotations();
|
|
2493
|
+
break;
|
|
2494
|
+
}
|
|
2275
2495
|
case "collab:error": this.emit("error", { message: String(t.message ?? "Collaboration error") });
|
|
2276
2496
|
}
|
|
2277
2497
|
}
|
|
2278
2498
|
handleInit(e) {
|
|
2279
|
-
if (this.clientId = e.clientId, !this.client || e.since === null || e.since === void 0 || !e.missed) this.client = new
|
|
2499
|
+
if (this.clientId = e.clientId, !this.client || e.since === null || e.since === void 0 || !e.missed) this.client = new _e(e.revision, {
|
|
2280
2500
|
send: (e, t) => this.sendOp(e, t),
|
|
2281
2501
|
apply: (e) => this.applyRemote(e)
|
|
2282
|
-
}), this.outstandingOpId = null, this.adapter.setValue(e.content), this.emit("ready", {
|
|
2502
|
+
}), this.outstandingOpId = null, this.lastContent = e.content, this.history?.clear(), this.adapter.setValue(e.content), this.emit("ready", {
|
|
2283
2503
|
content: e.content,
|
|
2284
2504
|
revision: e.revision
|
|
2285
2505
|
}), this.emit("change", {
|
|
@@ -2287,12 +2507,14 @@ var ve = class {
|
|
|
2287
2507
|
remote: !0
|
|
2288
2508
|
});
|
|
2289
2509
|
else {
|
|
2290
|
-
for (let t of e.missed) t.opId && t.opId === this.outstandingOpId ? (this.outstandingOpId = null, this.client.serverAck()) : this.client.applyServer(
|
|
2510
|
+
for (let t of e.missed) t.opId && t.opId === this.outstandingOpId ? (this.outstandingOpId = null, this.client.serverAck()) : this.client.applyServer(D.fromJSON(t.op));
|
|
2291
2511
|
this.client.resend();
|
|
2292
2512
|
}
|
|
2293
2513
|
this.cursors.clear();
|
|
2294
2514
|
for (let t of e.peers ?? []) this.cursors.set(t.clientId, t);
|
|
2295
|
-
this.emitPresence(), this.
|
|
2515
|
+
this.emitPresence(), this.annotationMap.clear();
|
|
2516
|
+
for (let t of e.annotations ?? []) this.annotationMap.set(t.id, this.toLocalRange(t));
|
|
2517
|
+
this.emitAnnotations(), this.adapter instanceof O && (this.adapter.element.removeAttribute("aria-busy"), this.wasReadOnly !== null && (this.adapter.element.readOnly = this.wasReadOnly), this.wasReadOnly = null), this.updateStatus();
|
|
2296
2518
|
}
|
|
2297
2519
|
sendOp(e, t) {
|
|
2298
2520
|
this.outstandingOpId = `${this.clientId ?? "c"}-${++this.opCounter}`, this.ws.send({
|
|
@@ -2306,7 +2528,7 @@ var ve = class {
|
|
|
2306
2528
|
});
|
|
2307
2529
|
}
|
|
2308
2530
|
applyRemote(e) {
|
|
2309
|
-
this.adapter.applyOperation(e);
|
|
2531
|
+
this.adapter.applyOperation(e), this.lastContent = this.adapter.getValue(), this.history?.transform(e), this.moveAnnotations(e);
|
|
2310
2532
|
for (let t of this.cursors.values()) t.selection &&= {
|
|
2311
2533
|
anchor: e.transformIndex(t.selection.anchor),
|
|
2312
2534
|
head: e.transformIndex(t.selection.head)
|
|
@@ -2317,18 +2539,27 @@ var ve = class {
|
|
|
2317
2539
|
});
|
|
2318
2540
|
}
|
|
2319
2541
|
handleLocalEdit(e) {
|
|
2542
|
+
this.client && (this.history?.record(e, this.lastContent), this.commitLocal(e));
|
|
2543
|
+
}
|
|
2544
|
+
commitLocal(e) {
|
|
2320
2545
|
if (this.client) {
|
|
2321
|
-
this.client.applyClient(e);
|
|
2546
|
+
this.lastContent = this.adapter.getValue(), this.client.applyClient(e);
|
|
2322
2547
|
for (let t of this.cursors.values()) t.selection &&= {
|
|
2323
2548
|
anchor: e.transformIndex(t.selection.anchor),
|
|
2324
2549
|
head: e.transformIndex(t.selection.head)
|
|
2325
2550
|
};
|
|
2326
|
-
this.emitPresence(), this.updateStatus(), this.emit("change", {
|
|
2551
|
+
this.moveAnnotations(e), this.emitPresence(), this.updateStatus(), this.emit("change", {
|
|
2327
2552
|
content: this.adapter.getValue(),
|
|
2328
2553
|
remote: !1
|
|
2329
2554
|
}), this.queuePresence(this.adapter.getSelection());
|
|
2330
2555
|
}
|
|
2331
2556
|
}
|
|
2557
|
+
moveAnnotations(e) {
|
|
2558
|
+
if (this.annotationMap.size) {
|
|
2559
|
+
for (let [t, n] of this.annotationMap) this.annotationMap.set(t, Ee(n, e));
|
|
2560
|
+
this.emitAnnotations();
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2332
2563
|
toLocal(e) {
|
|
2333
2564
|
return this.client ? {
|
|
2334
2565
|
anchor: this.client.transformIndex(e.anchor),
|
|
@@ -2352,15 +2583,15 @@ var ve = class {
|
|
|
2352
2583
|
this.overlay?.update(e), this.emit("presence", e);
|
|
2353
2584
|
}
|
|
2354
2585
|
updateStatus() {
|
|
2355
|
-
this.ws.isConnected ? this.setStatus(this.client?.state === "synchronized" ? "synced" : "syncing") : this.setStatus("offline");
|
|
2586
|
+
this.ws.isConnected ? this.setStatus(this.client?.state === "synchronized" ? "synced" : "syncing") : this.setStatus("offline"), this.flushAnnotations();
|
|
2356
2587
|
}
|
|
2357
2588
|
close() {
|
|
2358
2589
|
this.presenceTimer && clearTimeout(this.presenceTimer), this.ws.isConnected && this.ws.send({
|
|
2359
2590
|
type: "collab:leave",
|
|
2360
2591
|
channel: this.channel
|
|
2361
|
-
}), this.unsubscribe?.(), this.offOpen?.(), this.offStatus?.(), this.adapter instanceof
|
|
2592
|
+
}), this.unsubscribe?.(), this.offOpen?.(), this.offStatus?.(), this.adapter instanceof O && this.wasReadOnly !== null && (this.adapter.element.readOnly = this.wasReadOnly, this.adapter.element.removeAttribute("aria-busy")), this.adapter.destroy(), this.overlay?.destroy(), this.clear();
|
|
2362
2593
|
}
|
|
2363
|
-
},
|
|
2594
|
+
}, ke = class {
|
|
2364
2595
|
getWs;
|
|
2365
2596
|
constructor(e) {
|
|
2366
2597
|
this.getWs = e;
|
|
@@ -2368,17 +2599,17 @@ var ve = class {
|
|
|
2368
2599
|
open(e, t, n = {}) {
|
|
2369
2600
|
let r = this.getWs();
|
|
2370
2601
|
if (!r) throw Error("Collaboration needs a WebSocket: pass `websocket` to Arethesis.init().");
|
|
2371
|
-
return new
|
|
2602
|
+
return new Oe(r, e, t, n);
|
|
2372
2603
|
}
|
|
2373
|
-
},
|
|
2374
|
-
function
|
|
2604
|
+
}, Ae = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
2605
|
+
function k(e) {
|
|
2375
2606
|
if (e == null || e === "") return null;
|
|
2376
2607
|
if (e instanceof Date) return isNaN(e.getTime()) ? null : e;
|
|
2377
2608
|
if (typeof e == "number") {
|
|
2378
2609
|
let t = new Date(e);
|
|
2379
2610
|
return isNaN(t.getTime()) ? null : t;
|
|
2380
2611
|
}
|
|
2381
|
-
let t = String(e), n =
|
|
2612
|
+
let t = String(e), n = Ae.exec(t);
|
|
2382
2613
|
if (n) {
|
|
2383
2614
|
let e = new Date(Number(n[1]), Number(n[2]) - 1, Number(n[3]));
|
|
2384
2615
|
return isNaN(e.getTime()) ? null : e;
|
|
@@ -2386,45 +2617,45 @@ function j(e) {
|
|
|
2386
2617
|
let r = new Date(t);
|
|
2387
2618
|
return isNaN(r.getTime()) ? null : r;
|
|
2388
2619
|
}
|
|
2389
|
-
var
|
|
2390
|
-
function
|
|
2391
|
-
return `${e.getFullYear()}-${
|
|
2620
|
+
var A = (e, t = 2) => String(e).padStart(t, "0");
|
|
2621
|
+
function j(e) {
|
|
2622
|
+
return `${e.getFullYear()}-${A(e.getMonth() + 1)}-${A(e.getDate())}`;
|
|
2392
2623
|
}
|
|
2393
|
-
function
|
|
2394
|
-
return `${
|
|
2624
|
+
function je(e) {
|
|
2625
|
+
return `${j(e)}T${A(e.getHours())}:${A(e.getMinutes())}`;
|
|
2395
2626
|
}
|
|
2396
|
-
function
|
|
2627
|
+
function M(e) {
|
|
2397
2628
|
return new Date(e.getFullYear(), e.getMonth(), e.getDate());
|
|
2398
2629
|
}
|
|
2399
|
-
var
|
|
2400
|
-
function
|
|
2630
|
+
var Me = /YYYY|YY|MM|M|DD|D|HH|H|hh|h|mm|ss|A/g;
|
|
2631
|
+
function Ne(e, t) {
|
|
2401
2632
|
let n = e.getHours() % 12 || 12, r = {
|
|
2402
2633
|
YYYY: String(e.getFullYear()),
|
|
2403
2634
|
YY: String(e.getFullYear()).slice(-2),
|
|
2404
|
-
MM:
|
|
2635
|
+
MM: A(e.getMonth() + 1),
|
|
2405
2636
|
M: String(e.getMonth() + 1),
|
|
2406
|
-
DD:
|
|
2637
|
+
DD: A(e.getDate()),
|
|
2407
2638
|
D: String(e.getDate()),
|
|
2408
|
-
HH:
|
|
2639
|
+
HH: A(e.getHours()),
|
|
2409
2640
|
H: String(e.getHours()),
|
|
2410
|
-
hh:
|
|
2641
|
+
hh: A(n),
|
|
2411
2642
|
h: String(n),
|
|
2412
|
-
mm:
|
|
2413
|
-
ss:
|
|
2643
|
+
mm: A(e.getMinutes()),
|
|
2644
|
+
ss: A(e.getSeconds()),
|
|
2414
2645
|
A: e.getHours() < 12 ? "AM" : "PM"
|
|
2415
2646
|
};
|
|
2416
|
-
return t.split(/(\[[^\]]*\])/).map((e) => e.startsWith("[") && e.endsWith("]") ? e.slice(1, -1) : e.replace(
|
|
2647
|
+
return t.split(/(\[[^\]]*\])/).map((e) => e.startsWith("[") && e.endsWith("]") ? e.slice(1, -1) : e.replace(Me, (e) => r[e])).join("");
|
|
2417
2648
|
}
|
|
2418
2649
|
// src/binding/validation-engine.ts
|
|
2419
|
-
var
|
|
2650
|
+
var N = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0, Pe = /^[^\s@]+@[^\s@.]+(?:\.[^\s@.]+)+$/, Fe = /^\+?[\d\s\-().]+$/, Ie = class {
|
|
2420
2651
|
validators = /* @__PURE__ */ new Map();
|
|
2421
2652
|
constructor() {
|
|
2422
2653
|
this.registerBuiltIns();
|
|
2423
2654
|
}
|
|
2424
2655
|
registerBuiltIns() {
|
|
2425
2656
|
let e = (e) => Array.isArray(e) ? e.length : String(e).length;
|
|
2426
|
-
this.registerValidator("required", (e) => typeof e == "string" ? e.trim().length > 0 : typeof e == "boolean" ? e : !
|
|
2427
|
-
if (
|
|
2657
|
+
this.registerValidator("required", (e) => typeof e == "string" ? e.trim().length > 0 : typeof e == "boolean" ? e : !N(e), { message: "This field is required" }), this.registerValidator("email", (e) => N(e) || Pe.test(String(e)), { message: "Enter a valid email address" }), this.registerValidator("url", (e) => {
|
|
2658
|
+
if (N(e)) return !0;
|
|
2428
2659
|
try {
|
|
2429
2660
|
let t = new URL(String(e));
|
|
2430
2661
|
return t.protocol === "http:" || t.protocol === "https:";
|
|
@@ -2432,16 +2663,16 @@ var F = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0, Te =
|
|
|
2432
2663
|
return !1;
|
|
2433
2664
|
}
|
|
2434
2665
|
}, { message: "Enter a valid URL" }), this.registerValidator("phone", (e) => {
|
|
2435
|
-
if (
|
|
2666
|
+
if (N(e)) return !0;
|
|
2436
2667
|
let t = String(e), n = t.replace(/\D/g, "").length;
|
|
2437
|
-
return
|
|
2438
|
-
}, { message: "Enter a valid phone number" }), this.registerValidator("minLength", (t, n) =>
|
|
2668
|
+
return Fe.test(t) && n >= 7 && n <= 15;
|
|
2669
|
+
}, { message: "Enter a valid phone number" }), this.registerValidator("minLength", (t, n) => N(t) || e(t) >= Number(n.min), { message: "Must be at least {min} characters" }), this.registerValidator("maxLength", (t, n) => N(t) || e(t) <= Number(n.max), { message: "Must be at most {max} characters" });
|
|
2439
2670
|
let t = (e) => typeof e == "number" ? e : Number(e);
|
|
2440
|
-
this.registerValidator("numeric", (e) =>
|
|
2441
|
-
if (
|
|
2671
|
+
this.registerValidator("numeric", (e) => N(e) || !isNaN(t(e)), { message: "Must be a number" }), this.registerValidator("integer", (e) => N(e) || Number.isInteger(t(e)), { message: "Must be a whole number" }), this.registerValidator("min", (e, n) => N(e) || !isNaN(t(e)) && t(e) >= Number(n.min), { message: "Must be at least {min}" }), this.registerValidator("max", (e, n) => N(e) || !isNaN(t(e)) && t(e) <= Number(n.max), { message: "Must be at most {max}" }), this.registerValidator("between", (e, n) => N(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) => {
|
|
2672
|
+
if (N(e)) return !0;
|
|
2442
2673
|
let n = t.pattern instanceof RegExp ? t.pattern : new RegExp(String(t.pattern), typeof t.flags == "string" ? t.flags : void 0);
|
|
2443
2674
|
return n.lastIndex = 0, n.test(String(e));
|
|
2444
|
-
}, { message: "Invalid format" }), this.registerValidator("oneOf", (e, t) =>
|
|
2675
|
+
}, { message: "Invalid format" }), this.registerValidator("oneOf", (e, t) => N(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) => N(e) || k(e) !== null, { message: "Enter a valid date" }), this.registerValidator("custom", (e, t, n) => {
|
|
2445
2676
|
let r = t.fn;
|
|
2446
2677
|
return !r || r(e, n);
|
|
2447
2678
|
}, { message: "Invalid value" });
|
|
@@ -2531,27 +2762,27 @@ var F = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0, Te =
|
|
|
2531
2762
|
};
|
|
2532
2763
|
return e.replace(/\{(\w+)\}/g, (e, t) => t in r ? String(r[t]) : e);
|
|
2533
2764
|
}
|
|
2534
|
-
},
|
|
2765
|
+
}, Le = /* @__PURE__ */ new Set([
|
|
2535
2766
|
"http:",
|
|
2536
2767
|
"https:",
|
|
2537
2768
|
"mailto:",
|
|
2538
2769
|
"tel:"
|
|
2539
|
-
]),
|
|
2770
|
+
]), Re = /* @__PURE__ */ new Set([
|
|
2540
2771
|
"http:",
|
|
2541
2772
|
"https:",
|
|
2542
2773
|
"blob:"
|
|
2543
|
-
]),
|
|
2544
|
-
function
|
|
2774
|
+
]), ze = /^data:image\/(png|gif|jpe?g|webp|avif|svg\+xml);/i;
|
|
2775
|
+
function P(e, t = "link") {
|
|
2545
2776
|
if (e == null) return "";
|
|
2546
2777
|
let n = String(e).trim();
|
|
2547
2778
|
if (n === "") return "";
|
|
2548
2779
|
let r = n.replace(/[\u0000-\u001F\u007F\s]+/g, ""), i = /^([a-z][a-z0-9+.-]*):/i.exec(r);
|
|
2549
2780
|
if (!i) return n;
|
|
2550
2781
|
let a = `${i[1].toLowerCase()}:`;
|
|
2551
|
-
return t === "image" ? a === "data:" ?
|
|
2782
|
+
return t === "image" ? a === "data:" ? ze.test(r) && !/svg/i.test(r) ? n : "" : Re.has(a) ? n : "" : Le.has(a) ? n : "";
|
|
2552
2783
|
}
|
|
2553
2784
|
// src/utils/sanitize.ts
|
|
2554
|
-
var
|
|
2785
|
+
var Be = /* @__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("."), Ve = {
|
|
2555
2786
|
"*": [
|
|
2556
2787
|
"class",
|
|
2557
2788
|
"title",
|
|
@@ -2576,7 +2807,7 @@ var je = /* @__PURE__ */ "a.abbr.b.blockquote.br.code.del.div.em.figcaption.figu
|
|
|
2576
2807
|
"scope"
|
|
2577
2808
|
],
|
|
2578
2809
|
ol: ["start"]
|
|
2579
|
-
},
|
|
2810
|
+
}, He = /* @__PURE__ */ new Set([
|
|
2580
2811
|
"script",
|
|
2581
2812
|
"style",
|
|
2582
2813
|
"iframe",
|
|
@@ -2597,12 +2828,12 @@ var je = /* @__PURE__ */ "a.abbr.b.blockquote.br.code.del.div.em.figcaption.figu
|
|
|
2597
2828
|
"frame",
|
|
2598
2829
|
"frameset"
|
|
2599
2830
|
]);
|
|
2600
|
-
function
|
|
2831
|
+
function F(e, t = {}) {
|
|
2601
2832
|
if (e == null) return "";
|
|
2602
|
-
let n = new Set(t.allowedTags ??
|
|
2603
|
-
return
|
|
2833
|
+
let n = new Set(t.allowedTags ?? Be), r = t.allowedAttributes ?? Ve, i = new DOMParser().parseFromString(`<body>${String(e)}</body>`, "text/html");
|
|
2834
|
+
return Ue(i.body, n, r), i.body.innerHTML;
|
|
2604
2835
|
}
|
|
2605
|
-
function
|
|
2836
|
+
function Ue(e, t, n) {
|
|
2606
2837
|
for (let r of Array.from(e.childNodes)) {
|
|
2607
2838
|
if (r.nodeType === Node.COMMENT_NODE || r.nodeType === Node.PROCESSING_INSTRUCTION_NODE) {
|
|
2608
2839
|
r.remove();
|
|
@@ -2610,44 +2841,44 @@ function Pe(e, t, n) {
|
|
|
2610
2841
|
}
|
|
2611
2842
|
if (r.nodeType !== Node.ELEMENT_NODE) continue;
|
|
2612
2843
|
let e = r, i = e.tagName.toLowerCase();
|
|
2613
|
-
|
|
2844
|
+
He.has(i) ? e.remove() : (Ue(e, t, n), t.has(i) ? We(e, i, n) : e.replaceWith(...Array.from(e.childNodes)));
|
|
2614
2845
|
}
|
|
2615
2846
|
}
|
|
2616
|
-
function
|
|
2847
|
+
function We(e, t, n) {
|
|
2617
2848
|
let r = /* @__PURE__ */ new Set([...n["*"] ?? [], ...n[t] ?? []]);
|
|
2618
2849
|
for (let t of Array.from(e.attributes)) {
|
|
2619
2850
|
let n = t.name.toLowerCase();
|
|
2620
2851
|
if (!r.has(n) || n.startsWith("on")) e.removeAttribute(t.name);
|
|
2621
2852
|
else if (n === "href") {
|
|
2622
|
-
let n =
|
|
2853
|
+
let n = P(t.value, "link");
|
|
2623
2854
|
n ? e.setAttribute("href", n) : e.removeAttribute("href");
|
|
2624
2855
|
} else if (n === "src") {
|
|
2625
|
-
let n =
|
|
2856
|
+
let n = P(t.value, "image");
|
|
2626
2857
|
n ? e.setAttribute("src", n) : e.removeAttribute("src");
|
|
2627
2858
|
}
|
|
2628
2859
|
}
|
|
2629
2860
|
t === "a" && e.getAttribute("target") === "_blank" && e.setAttribute("rel", "noopener noreferrer");
|
|
2630
2861
|
}
|
|
2631
|
-
function
|
|
2862
|
+
function I(e) {
|
|
2632
2863
|
return e == null ? "" : new DOMParser().parseFromString(String(e), "text/html").body.textContent ?? "";
|
|
2633
2864
|
}
|
|
2634
2865
|
// src/utils/dom.ts
|
|
2635
|
-
function
|
|
2866
|
+
function L(e) {
|
|
2636
2867
|
return typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/([^\w-])/g, "\\$1").replace(/^(\d)/, "\\3$1 ");
|
|
2637
2868
|
}
|
|
2638
|
-
function
|
|
2869
|
+
function Ge(e) {
|
|
2639
2870
|
return e.replace(/-([a-z0-9])/g, (e, t) => t.toUpperCase());
|
|
2640
2871
|
}
|
|
2641
|
-
var
|
|
2642
|
-
function
|
|
2643
|
-
return
|
|
2872
|
+
var Ke = 0;
|
|
2873
|
+
function R(e = "ar") {
|
|
2874
|
+
return Ke += 1, `${e}-${Ke.toString(36)}`;
|
|
2644
2875
|
}
|
|
2645
|
-
function
|
|
2876
|
+
function qe(e) {
|
|
2646
2877
|
let t = document.createElement("template");
|
|
2647
2878
|
return t.innerHTML = e, t.content;
|
|
2648
2879
|
}
|
|
2649
2880
|
// src/binding/data-binder.ts
|
|
2650
|
-
var
|
|
2881
|
+
var Je = /* @__PURE__ */ new Set([
|
|
2651
2882
|
"href",
|
|
2652
2883
|
"src",
|
|
2653
2884
|
"action",
|
|
@@ -2658,29 +2889,29 @@ var ze = /* @__PURE__ */ new Set([
|
|
|
2658
2889
|
"background",
|
|
2659
2890
|
"ping"
|
|
2660
2891
|
]);
|
|
2661
|
-
function
|
|
2892
|
+
function z(e) {
|
|
2662
2893
|
return e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement;
|
|
2663
2894
|
}
|
|
2664
|
-
function
|
|
2895
|
+
function B(e) {
|
|
2665
2896
|
return e instanceof HTMLElement && (e.isContentEditable || e.getAttribute("contenteditable") === "true");
|
|
2666
2897
|
}
|
|
2667
|
-
function
|
|
2898
|
+
function Ye() {
|
|
2668
2899
|
return typeof document < "u" && document.documentElement.lang || "en-US";
|
|
2669
2900
|
}
|
|
2670
|
-
var
|
|
2901
|
+
var Xe = class {
|
|
2671
2902
|
validationEngine;
|
|
2672
2903
|
bindings = /* @__PURE__ */ new WeakMap();
|
|
2673
2904
|
timers = /* @__PURE__ */ new WeakMap();
|
|
2674
2905
|
validationRuns = /* @__PURE__ */ new WeakMap();
|
|
2675
2906
|
touched = /* @__PURE__ */ new WeakSet();
|
|
2676
2907
|
constructor(e) {
|
|
2677
|
-
this.validationEngine = e ?? new
|
|
2908
|
+
this.validationEngine = e ?? new Ie();
|
|
2678
2909
|
}
|
|
2679
2910
|
bind(e, t, n) {
|
|
2680
2911
|
this.unbind(e);
|
|
2681
2912
|
let r = new AbortController(), i = [];
|
|
2682
2913
|
for (let [t, r] of Object.entries(n.fields)) {
|
|
2683
|
-
let n = r.selector ?? `[data-bind="${
|
|
2914
|
+
let n = r.selector ?? `[data-bind="${L(t)}"]`, a = Array.from(e.querySelectorAll(n));
|
|
2684
2915
|
e.matches?.(n) && a.unshift(e), i.push({
|
|
2685
2916
|
key: t,
|
|
2686
2917
|
path: r.field ?? t,
|
|
@@ -2718,7 +2949,7 @@ var Ve = class {
|
|
|
2718
2949
|
let n = r(t, e.path);
|
|
2719
2950
|
if (!(e.initialized && s(n, e.lastValue))) {
|
|
2720
2951
|
e.lastValue = n, e.initialized = !0;
|
|
2721
|
-
for (let r of e.targets) r === document.activeElement && (
|
|
2952
|
+
for (let r of e.targets) r === document.activeElement && (z(r) || B(r)) && e.config.twoWay || this.applyValue(r, n, e.config, t);
|
|
2722
2953
|
}
|
|
2723
2954
|
}
|
|
2724
2955
|
}
|
|
@@ -2735,13 +2966,13 @@ var Ve = class {
|
|
|
2735
2966
|
}
|
|
2736
2967
|
}
|
|
2737
2968
|
applyValue(e, t, n, r) {
|
|
2738
|
-
n.visible && (e.hidden = !n.visible(t, r)), n.attribute ? this.applyAttribute(e, n.attribute, this.format(t, n, r)) :
|
|
2969
|
+
n.visible && (e.hidden = !n.visible(t, r)), n.attribute ? this.applyAttribute(e, n.attribute, this.format(t, n, r)) : z(e) ? this.applyToControl(e, t, n) : n.inputType === "rich-text" && B(e) ? e.innerHTML = F(t) : this.applyToDisplay(e, t, n, r);
|
|
2739
2970
|
}
|
|
2740
2971
|
applyAttribute(e, t, n) {
|
|
2741
2972
|
let r = t.toLowerCase();
|
|
2742
2973
|
if (!(r.startsWith("on") || r === "style" && /expression|url\s*\(/i.test(n))) {
|
|
2743
|
-
if (
|
|
2744
|
-
let i =
|
|
2974
|
+
if (Je.has(r)) {
|
|
2975
|
+
let i = P(n, r === "href" || r === "action" || r === "formaction" || r === "ping" ? "link" : "image");
|
|
2745
2976
|
i ? e.setAttribute(t, i) : e.removeAttribute(t);
|
|
2746
2977
|
} else e.setAttribute(t, n);
|
|
2747
2978
|
}
|
|
@@ -2749,21 +2980,21 @@ var Ve = class {
|
|
|
2749
2980
|
format(e, t, n) {
|
|
2750
2981
|
if (typeof t.format == "function") return t.format(e, n);
|
|
2751
2982
|
if (e == null || e === "") return t.emptyText ?? "";
|
|
2752
|
-
let r = t.locale ??
|
|
2983
|
+
let r = t.locale ?? Ye(), i = t.displayType ?? "text";
|
|
2753
2984
|
switch (i) {
|
|
2754
2985
|
case "date":
|
|
2755
2986
|
case "datetime":
|
|
2756
2987
|
case "time": {
|
|
2757
|
-
let n =
|
|
2758
|
-
return n ? typeof t.format == "string" ?
|
|
2988
|
+
let n = k(e);
|
|
2989
|
+
return n ? typeof t.format == "string" ? Ne(n, t.format) : i === "date" ? n.toLocaleDateString(r, t.intl) : i === "time" ? n.toLocaleTimeString(r, {
|
|
2759
2990
|
hour: "numeric",
|
|
2760
2991
|
minute: "2-digit",
|
|
2761
2992
|
...t.intl
|
|
2762
2993
|
}) : n.toLocaleString(r, t.intl) : t.emptyText ?? "";
|
|
2763
2994
|
}
|
|
2764
2995
|
case "relative": {
|
|
2765
|
-
let n =
|
|
2766
|
-
return n ?
|
|
2996
|
+
let n = k(e);
|
|
2997
|
+
return n ? et(n, r) : t.emptyText ?? "";
|
|
2767
2998
|
}
|
|
2768
2999
|
case "currency":
|
|
2769
3000
|
case "number":
|
|
@@ -2789,10 +3020,10 @@ var Ve = class {
|
|
|
2789
3020
|
let i = n.displayType ?? "text", a = this.format(t, n, r);
|
|
2790
3021
|
switch (i) {
|
|
2791
3022
|
case "html":
|
|
2792
|
-
e.innerHTML = n.trusted ? String(t ?? "") :
|
|
3023
|
+
e.innerHTML = n.trusted ? String(t ?? "") : F(t);
|
|
2793
3024
|
return;
|
|
2794
3025
|
case "image": {
|
|
2795
|
-
let n =
|
|
3026
|
+
let n = P(t, "image");
|
|
2796
3027
|
if (e instanceof HTMLImageElement) {
|
|
2797
3028
|
n ? e.src = n : e.removeAttribute("src");
|
|
2798
3029
|
return;
|
|
@@ -2804,7 +3035,7 @@ var Ve = class {
|
|
|
2804
3035
|
return;
|
|
2805
3036
|
}
|
|
2806
3037
|
case "link": {
|
|
2807
|
-
let i =
|
|
3038
|
+
let i = P(n.href ? n.href(t, r) : t, "link"), o = n.linkText ?? a;
|
|
2808
3039
|
if (e instanceof HTMLAnchorElement) {
|
|
2809
3040
|
i ? e.href = i : e.removeAttribute("href"), n.linkText === void 0 && e.dataset.keepText || (e.textContent = o);
|
|
2810
3041
|
return;
|
|
@@ -2832,11 +3063,11 @@ var Ve = class {
|
|
|
2832
3063
|
}
|
|
2833
3064
|
case "relative": {
|
|
2834
3065
|
e.textContent = a;
|
|
2835
|
-
let r = typeof n.format == "function" ? null :
|
|
3066
|
+
let r = typeof n.format == "function" ? null : k(t);
|
|
2836
3067
|
if (r) {
|
|
2837
|
-
let t = n.locale ??
|
|
2838
|
-
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 ?
|
|
2839
|
-
} else
|
|
3068
|
+
let t = n.locale ?? Ye();
|
|
3069
|
+
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 ? V.unwatch(e) : V.watch(e, r, t);
|
|
3070
|
+
} else V.unwatch(e);
|
|
2840
3071
|
return;
|
|
2841
3072
|
}
|
|
2842
3073
|
default: e.textContent = a;
|
|
@@ -2861,13 +3092,13 @@ var Ve = class {
|
|
|
2861
3092
|
return;
|
|
2862
3093
|
}
|
|
2863
3094
|
case "date": {
|
|
2864
|
-
let n =
|
|
2865
|
-
e.value = n ?
|
|
3095
|
+
let n = k(t);
|
|
3096
|
+
e.value = n ? j(n) : "";
|
|
2866
3097
|
return;
|
|
2867
3098
|
}
|
|
2868
3099
|
case "datetime": {
|
|
2869
|
-
let n =
|
|
2870
|
-
e.value = n ?
|
|
3100
|
+
let n = k(t);
|
|
3101
|
+
e.value = n ? je(n) : "";
|
|
2871
3102
|
return;
|
|
2872
3103
|
}
|
|
2873
3104
|
case "tags":
|
|
@@ -2878,7 +3109,7 @@ var Ve = class {
|
|
|
2878
3109
|
}
|
|
2879
3110
|
readValue(e, t) {
|
|
2880
3111
|
let n;
|
|
2881
|
-
if (
|
|
3112
|
+
if (z(e)) switch (this.inputTypeOf(e, t)) {
|
|
2882
3113
|
case "checkbox":
|
|
2883
3114
|
case "toggle":
|
|
2884
3115
|
n = e.checked;
|
|
@@ -2895,14 +3126,14 @@ var Ve = class {
|
|
|
2895
3126
|
break;
|
|
2896
3127
|
default: n = e.value;
|
|
2897
3128
|
}
|
|
2898
|
-
else n =
|
|
3129
|
+
else n = B(e) && t.inputType === "rich-text" ? F(e.innerHTML) : e.textContent;
|
|
2899
3130
|
return t.parse ? t.parse(n) : n;
|
|
2900
3131
|
}
|
|
2901
3132
|
values(e) {
|
|
2902
3133
|
let t = this.bindings.get(e), n = {};
|
|
2903
3134
|
if (!t) return n;
|
|
2904
3135
|
for (let e of t.fields) {
|
|
2905
|
-
let i = e.targets.find((e) =>
|
|
3136
|
+
let i = e.targets.find((e) => z(e) || B(e));
|
|
2906
3137
|
n[e.key] = i ? this.readValue(i, e.config) : r(t.data, e.path);
|
|
2907
3138
|
}
|
|
2908
3139
|
return n;
|
|
@@ -2911,7 +3142,7 @@ var Ve = class {
|
|
|
2911
3142
|
return new Set(e.config.validateOn ?? ["blur", "change"]);
|
|
2912
3143
|
}
|
|
2913
3144
|
listen(e, t, n) {
|
|
2914
|
-
if (!(
|
|
3145
|
+
if (!(z(n) || B(n))) return;
|
|
2915
3146
|
let { signal: r } = e.controller, i = t.config.validation, a = this.triggers(e), o = (r) => {
|
|
2916
3147
|
let o = this.readValue(n, t.config), s = () => {
|
|
2917
3148
|
t.config.twoWay && (t.lastValue = o, e.config.onChange?.(t.path, o));
|
|
@@ -2960,7 +3191,7 @@ var Ve = class {
|
|
|
2960
3191
|
let n = [];
|
|
2961
3192
|
for (let e of t.fields) {
|
|
2962
3193
|
if (!e.config.validation) continue;
|
|
2963
|
-
let i = e.targets.find((e) =>
|
|
3194
|
+
let i = e.targets.find((e) => z(e) || B(e));
|
|
2964
3195
|
if (i) {
|
|
2965
3196
|
this.touched.add(i);
|
|
2966
3197
|
let r = await this.validateTarget(t, e, i);
|
|
@@ -2984,9 +3215,9 @@ var Ve = class {
|
|
|
2984
3215
|
o.className = "error-summary__title", o.textContent = n.length === 1 ? "Please fix 1 error:" : `Please fix ${n.length} errors:`;
|
|
2985
3216
|
let s = document.createElement("ul");
|
|
2986
3217
|
for (let e of n) {
|
|
2987
|
-
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) =>
|
|
3218
|
+
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) => z(e) || B(e));
|
|
2988
3219
|
if (o) {
|
|
2989
|
-
o.id ||=
|
|
3220
|
+
o.id ||= R("field");
|
|
2990
3221
|
let e = document.createElement("a");
|
|
2991
3222
|
e.href = `#${o.id}`, e.textContent = a, e.addEventListener("click", (e) => {
|
|
2992
3223
|
e.preventDefault(), o.focus();
|
|
@@ -3016,14 +3247,14 @@ var Ve = class {
|
|
|
3016
3247
|
let n = e.ownerDocument.getElementById(t);
|
|
3017
3248
|
if (n?.classList.contains("field-error")) return n;
|
|
3018
3249
|
}
|
|
3019
|
-
let i = (t ? e.closest("form, [data-form], body")?.querySelector(`[data-error-for="${
|
|
3250
|
+
let i = (t ? e.closest("form, [data-form], body")?.querySelector(`[data-error-for="${L(t)}"]`) : null) ?? null;
|
|
3020
3251
|
if (!i) {
|
|
3021
3252
|
if (!n) return null;
|
|
3022
3253
|
i = document.createElement("div"), i.className = "field-error", i.setAttribute("data-generated", ""), e.insertAdjacentElement("afterend", i);
|
|
3023
3254
|
}
|
|
3024
|
-
return i.classList.add("field-error"), i.id || (i.id =
|
|
3255
|
+
return i.classList.add("field-error"), i.id || (i.id = R("error")), i.setAttribute("aria-live", "polite"), e.setAttribute("aria-describedby", [...r, i.id].join(" ")), i;
|
|
3025
3256
|
}
|
|
3026
|
-
},
|
|
3257
|
+
}, Ze = [
|
|
3027
3258
|
["year", 31536e3],
|
|
3028
3259
|
["month", 2592e3],
|
|
3029
3260
|
["week", 604800],
|
|
@@ -3032,11 +3263,11 @@ var Ve = class {
|
|
|
3032
3263
|
["minute", 60],
|
|
3033
3264
|
["second", 1]
|
|
3034
3265
|
];
|
|
3035
|
-
function
|
|
3266
|
+
function Qe(e, t) {
|
|
3036
3267
|
let n = Math.abs(t - e.getTime()) / 1e3;
|
|
3037
3268
|
return n < 60 ? 5e3 : n < 3600 ? 15e3 : n < 86400 ? 3e5 : 36e5;
|
|
3038
3269
|
}
|
|
3039
|
-
var
|
|
3270
|
+
var $e = class {
|
|
3040
3271
|
targets = /* @__PURE__ */ new Map();
|
|
3041
3272
|
timer = null;
|
|
3042
3273
|
listening = !1;
|
|
@@ -3062,7 +3293,7 @@ var We = class {
|
|
|
3062
3293
|
this.targets.delete(t);
|
|
3063
3294
|
continue;
|
|
3064
3295
|
}
|
|
3065
|
-
let i =
|
|
3296
|
+
let i = et(n, r, e);
|
|
3066
3297
|
t.textContent !== i && (t.textContent = i);
|
|
3067
3298
|
}
|
|
3068
3299
|
this.targets.size ? this.schedule(e) : this.stop();
|
|
@@ -3073,29 +3304,29 @@ var We = class {
|
|
|
3073
3304
|
schedule(e = Date.now()) {
|
|
3074
3305
|
if (this.timer || this.targets.size === 0) return;
|
|
3075
3306
|
let t = Infinity;
|
|
3076
|
-
for (let { date: n } of this.targets.values()) t = Math.min(t,
|
|
3307
|
+
for (let { date: n } of this.targets.values()) t = Math.min(t, Qe(n, e));
|
|
3077
3308
|
this.timer = setTimeout(() => this.tick(), t), !this.listening && typeof document < "u" && (document.addEventListener("visibilitychange", this.onVisibility), this.listening = !0);
|
|
3078
3309
|
}
|
|
3079
|
-
},
|
|
3080
|
-
function
|
|
3310
|
+
}, V = new $e();
|
|
3311
|
+
function et(e, t = "en-US", n = Date.now()) {
|
|
3081
3312
|
let r = Math.round((e.getTime() - n) / 1e3), i = new Intl.RelativeTimeFormat(t, { numeric: "auto" });
|
|
3082
|
-
for (let [e, t] of
|
|
3313
|
+
for (let [e, t] of Ze) if (Math.abs(r) >= t || e === "second") return i.format(Math.round(r / t), e);
|
|
3083
3314
|
return i.format(0, "second");
|
|
3084
3315
|
}
|
|
3085
3316
|
// src/components/runtime.ts
|
|
3086
|
-
var
|
|
3087
|
-
function
|
|
3088
|
-
|
|
3317
|
+
var H = null;
|
|
3318
|
+
function tt(e) {
|
|
3319
|
+
H = e;
|
|
3089
3320
|
}
|
|
3090
3321
|
function U() {
|
|
3091
|
-
if (!
|
|
3092
|
-
return
|
|
3322
|
+
if (!H) throw Error("Arethesis is not loaded. Import from \"arethesis\" and call getArethesis() first.");
|
|
3323
|
+
return H;
|
|
3093
3324
|
}
|
|
3094
|
-
function
|
|
3095
|
-
return
|
|
3325
|
+
function nt() {
|
|
3326
|
+
return H !== null;
|
|
3096
3327
|
}
|
|
3097
3328
|
// src/components/template-loader.ts
|
|
3098
|
-
var
|
|
3329
|
+
var rt = class {
|
|
3099
3330
|
files = /* @__PURE__ */ new Map();
|
|
3100
3331
|
pending = /* @__PURE__ */ new Map();
|
|
3101
3332
|
extracted = /* @__PURE__ */ new Map();
|
|
@@ -3104,7 +3335,7 @@ var Xe = class {
|
|
|
3104
3335
|
this.fetchImpl = () => e;
|
|
3105
3336
|
}
|
|
3106
3337
|
register(e, t) {
|
|
3107
|
-
this.files.set(e,
|
|
3338
|
+
this.files.set(e, qe(t));
|
|
3108
3339
|
for (let t of this.extracted.keys()) t.startsWith(`${e}#`) && this.extracted.delete(t);
|
|
3109
3340
|
}
|
|
3110
3341
|
async load(e, t) {
|
|
@@ -3114,7 +3345,7 @@ var Xe = class {
|
|
|
3114
3345
|
return i || (i = this.extract(n, t, e), this.extracted.set(r, i)), i.cloneNode(!0);
|
|
3115
3346
|
}
|
|
3116
3347
|
async has(e, t) {
|
|
3117
|
-
return (await this.loadFile(e)).querySelector(`template#${
|
|
3348
|
+
return (await this.loadFile(e)).querySelector(`template#${L(t)}`) !== null;
|
|
3118
3349
|
}
|
|
3119
3350
|
loadFile(e) {
|
|
3120
3351
|
let t = this.files.get(e);
|
|
@@ -3127,10 +3358,10 @@ var Xe = class {
|
|
|
3127
3358
|
async fetchFile(e) {
|
|
3128
3359
|
let t = await this.fetchImpl()(e);
|
|
3129
3360
|
if (!t.ok) throw Error(`Failed to load template ${e} (${t.status})`);
|
|
3130
|
-
return
|
|
3361
|
+
return qe(await t.text());
|
|
3131
3362
|
}
|
|
3132
3363
|
extract(e, t, n) {
|
|
3133
|
-
let r = e.querySelector(`template#${
|
|
3364
|
+
let r = e.querySelector(`template#${L(t)}`);
|
|
3134
3365
|
if (r) return r.content.cloneNode(!0);
|
|
3135
3366
|
if (t === "main" && !e.querySelector("template")) return e.cloneNode(!0);
|
|
3136
3367
|
throw Error(`Template "#${t}" not found in ${n}`);
|
|
@@ -3144,7 +3375,7 @@ var Xe = class {
|
|
|
3144
3375
|
clearCache() {
|
|
3145
3376
|
this.files.clear(), this.extracted.clear();
|
|
3146
3377
|
}
|
|
3147
|
-
}, W = new
|
|
3378
|
+
}, W = new rt(), it = class {
|
|
3148
3379
|
definitions = /* @__PURE__ */ new Map();
|
|
3149
3380
|
applied = /* @__PURE__ */ new WeakMap();
|
|
3150
3381
|
observers = /* @__PURE__ */ new Set();
|
|
@@ -3201,7 +3432,7 @@ var Xe = class {
|
|
|
3201
3432
|
console.error(`data-mixin-${t} is not valid JSON`);
|
|
3202
3433
|
}
|
|
3203
3434
|
let i = `data-mixin-${t}-`;
|
|
3204
|
-
for (let t of Array.from(e.attributes)) t.name.startsWith(i) && (n[
|
|
3435
|
+
for (let t of Array.from(e.attributes)) t.name.startsWith(i) && (n[Ge(t.name.slice(i.length))] = at(t.value));
|
|
3205
3436
|
return n;
|
|
3206
3437
|
}
|
|
3207
3438
|
init(e = document) {
|
|
@@ -3230,7 +3461,7 @@ var Xe = class {
|
|
|
3230
3461
|
this.observers.clear();
|
|
3231
3462
|
}
|
|
3232
3463
|
};
|
|
3233
|
-
function
|
|
3464
|
+
function at(e) {
|
|
3234
3465
|
if (e === "" || e === "true") return !0;
|
|
3235
3466
|
if (e === "false") return !1;
|
|
3236
3467
|
if (e === "null") return null;
|
|
@@ -3242,32 +3473,32 @@ function Qe(e) {
|
|
|
3242
3473
|
}
|
|
3243
3474
|
return e;
|
|
3244
3475
|
}
|
|
3245
|
-
var G = new
|
|
3246
|
-
function
|
|
3476
|
+
var G = new it(), ot = G.register.bind(G), st = G.apply.bind(G), ct = G.remove.bind(G), lt = G.init.bind(G), ut = G.observe.bind(G), dt = Symbol.for("arethesis.componentMetadata");
|
|
3477
|
+
function ft(e) {
|
|
3247
3478
|
if (!/^[a-z][a-z0-9._]*-[a-z0-9._-]*$/.test(e.tag)) throw Error(`Invalid custom element name "${e.tag}": use lowercase letters and a hyphen.`);
|
|
3248
3479
|
return function(t, n) {
|
|
3249
3480
|
let r = { ...e };
|
|
3250
|
-
return e.html === void 0 ? e.template && (r.templateKey = e.template) : (r.templateKey = `inline:${e.tag}`, W.register(r.templateKey, e.html)), Object.defineProperty(t,
|
|
3481
|
+
return e.html === void 0 ? e.template && (r.templateKey = e.template) : (r.templateKey = `inline:${e.tag}`, W.register(r.templateKey, e.html)), Object.defineProperty(t, dt, {
|
|
3251
3482
|
value: r,
|
|
3252
3483
|
configurable: !0
|
|
3253
3484
|
}), customElements.get(e.tag) || customElements.define(e.tag, t), t;
|
|
3254
3485
|
};
|
|
3255
3486
|
}
|
|
3256
|
-
function
|
|
3257
|
-
return e[
|
|
3487
|
+
function pt(e) {
|
|
3488
|
+
return e[dt];
|
|
3258
3489
|
}
|
|
3259
3490
|
// src/components/component.ts
|
|
3260
|
-
function
|
|
3491
|
+
function mt() {
|
|
3261
3492
|
return typeof document < "u" && document.readyState === "loading" ? new Promise((e) => document.addEventListener("DOMContentLoaded", () => e(), { once: !0 })) : Promise.resolve();
|
|
3262
3493
|
}
|
|
3263
|
-
function
|
|
3494
|
+
function ht(e) {
|
|
3264
3495
|
return "ids" in e && "status" in e && Array.isArray(e.ids);
|
|
3265
3496
|
}
|
|
3266
|
-
var
|
|
3497
|
+
var gt = class extends HTMLElement {
|
|
3267
3498
|
static bindConfig;
|
|
3268
3499
|
state = "idle";
|
|
3269
3500
|
error = null;
|
|
3270
|
-
mainTemplateId = "main";
|
|
3501
|
+
mainTemplateId = this.metadata?.templateId ?? "main";
|
|
3271
3502
|
loadingTemplateId = "loading";
|
|
3272
3503
|
errorTemplateId = "error";
|
|
3273
3504
|
#e = null;
|
|
@@ -3286,7 +3517,7 @@ var lt = class extends HTMLElement {
|
|
|
3286
3517
|
this.#s = e;
|
|
3287
3518
|
});
|
|
3288
3519
|
async connectedCallback() {
|
|
3289
|
-
this.#r = new AbortController(), this.#d || (this.#d = !0, await
|
|
3520
|
+
this.#r = new AbortController(), this.#d || (this.#d = !0, await mt(), this.hasAttribute("data-hydrate") || !this.metadata?.templateKey ? this.#o = this.mainTemplateId : this.#o === null && await this.render(this.mainTemplateId), this.#s()), this.onConnected();
|
|
3290
3521
|
let e = this.#t;
|
|
3291
3522
|
this.#t = null, e && !this.#e && this.bind(e.kind === "list" ? e.view : e.ref, e.config), this.#m();
|
|
3292
3523
|
}
|
|
@@ -3327,7 +3558,7 @@ var lt = class extends HTMLElement {
|
|
|
3327
3558
|
}));
|
|
3328
3559
|
}
|
|
3329
3560
|
get metadata() {
|
|
3330
|
-
return
|
|
3561
|
+
return pt(this.constructor);
|
|
3331
3562
|
}
|
|
3332
3563
|
async hasTemplate(e) {
|
|
3333
3564
|
let t = this.metadata?.templateKey;
|
|
@@ -3358,7 +3589,7 @@ var lt = class extends HTMLElement {
|
|
|
3358
3589
|
bind(e, t) {
|
|
3359
3590
|
this.#t = null, this.#p();
|
|
3360
3591
|
let { store: n, listViews: r } = U();
|
|
3361
|
-
if (
|
|
3592
|
+
if (ht(e)) {
|
|
3362
3593
|
this.#e = {
|
|
3363
3594
|
kind: "list",
|
|
3364
3595
|
view: e,
|
|
@@ -3603,11 +3834,11 @@ var lt = class extends HTMLElement {
|
|
|
3603
3834
|
onItemRender(e, t) {}
|
|
3604
3835
|
onListChange(e) {}
|
|
3605
3836
|
onRetry() {}
|
|
3606
|
-
},
|
|
3607
|
-
function
|
|
3608
|
-
|
|
3837
|
+
}, _t = /* @__PURE__ */ new Map();
|
|
3838
|
+
function vt(e, t) {
|
|
3839
|
+
_t.set(e, t);
|
|
3609
3840
|
}
|
|
3610
|
-
var
|
|
3841
|
+
var yt = class {
|
|
3611
3842
|
app;
|
|
3612
3843
|
plugins = /* @__PURE__ */ new Map();
|
|
3613
3844
|
pending = [];
|
|
@@ -3617,8 +3848,8 @@ var ft = class {
|
|
|
3617
3848
|
}
|
|
3618
3849
|
resolve(e, t) {
|
|
3619
3850
|
if (typeof e == "string") {
|
|
3620
|
-
let n =
|
|
3621
|
-
if (!n) throw Error(`Unknown plugin "${e}". Built-in plugins: ${[...
|
|
3851
|
+
let n = _t.get(e);
|
|
3852
|
+
if (!n) throw Error(`Unknown plugin "${e}". Built-in plugins: ${[..._t.keys()].join(", ")}`);
|
|
3622
3853
|
return {
|
|
3623
3854
|
plugin: n(),
|
|
3624
3855
|
options: t
|
|
@@ -3642,7 +3873,7 @@ var ft = class {
|
|
|
3642
3873
|
for (let [e, t] of Object.entries(r.mixins ?? {})) G.has(e) && !n.override ? console.warn(`Mixin "${e}" from plugin "${r.name}" is already registered; keeping the existing one`) : G.register(e, t);
|
|
3643
3874
|
let a = this.app.validation;
|
|
3644
3875
|
for (let [e, t] of Object.entries(r.validators ?? {})) a.hasValidator(e) && !n.override ? console.warn(`Validator "${e}" from plugin "${r.name}" is already registered; keeping the existing one`) : typeof t == "function" ? a.registerValidator(e, t) : a.registerValidator(e, t.fn, { message: t.message });
|
|
3645
|
-
r.extendComponent?.(
|
|
3876
|
+
r.extendComponent?.(gt);
|
|
3646
3877
|
let o = r.install?.(this.app, i);
|
|
3647
3878
|
o instanceof Promise && this.pending.push(o.catch((e) => console.error(`Plugin "${r.name}" install failed:`, e))), this.initialized && r.afterInit && this.pending.push(Promise.resolve(r.afterInit(this.app)).catch((e) => console.error(`Plugin "${r.name}" afterInit failed:`, e)));
|
|
3648
3879
|
}
|
|
@@ -3699,7 +3930,7 @@ function J(e) {
|
|
|
3699
3930
|
t.textContent = e;
|
|
3700
3931
|
}, 30);
|
|
3701
3932
|
}
|
|
3702
|
-
function
|
|
3933
|
+
function bt(e, t, n, r = 8) {
|
|
3703
3934
|
e.style.position = "fixed", e.style.left = "0px", e.style.top = "0px";
|
|
3704
3935
|
let i = e.getBoundingClientRect(), a = window.innerWidth, o = window.innerHeight, s = {
|
|
3705
3936
|
top: t.top - i.height - r >= 0,
|
|
@@ -3726,7 +3957,7 @@ function pt(e, t, n, r = 8) {
|
|
|
3726
3957
|
}
|
|
3727
3958
|
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;
|
|
3728
3959
|
}
|
|
3729
|
-
function
|
|
3960
|
+
function xt(e) {
|
|
3730
3961
|
let t = /translate\(\s*(-?[\d.]+)px\s*,\s*(-?[\d.]+)px\s*\)/.exec(e.style.transform);
|
|
3731
3962
|
return t ? {
|
|
3732
3963
|
x: Number(t[1]),
|
|
@@ -3737,8 +3968,8 @@ function mt(e) {
|
|
|
3737
3968
|
};
|
|
3738
3969
|
}
|
|
3739
3970
|
// src/mixins/draggable.ts
|
|
3740
|
-
function
|
|
3741
|
-
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 =
|
|
3971
|
+
function St(e, t = {}) {
|
|
3972
|
+
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 = xt(e), l = null, u = s.style.touchAction;
|
|
3742
3973
|
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");
|
|
3743
3974
|
function d() {
|
|
3744
3975
|
let n = t.containment;
|
|
@@ -3826,9 +4057,9 @@ function ht(e, t = {}) {
|
|
|
3826
4057
|
}
|
|
3827
4058
|
};
|
|
3828
4059
|
}
|
|
3829
|
-
G.register("draggable",
|
|
4060
|
+
G.register("draggable", St);
|
|
3830
4061
|
// src/mixins/editable.ts
|
|
3831
|
-
function
|
|
4062
|
+
function Ct(e, t = {}) {
|
|
3832
4063
|
let { type: n = "text", placeholder: r = "", saveOnBlur: i = !0 } = t, a = new AbortController(), o = null;
|
|
3833
4064
|
e.hasAttribute("tabindex") || (e.tabIndex = 0), e.classList.add("is-editable"), e.setAttribute("aria-roledescription", "editable");
|
|
3834
4065
|
function s(i) {
|
|
@@ -3851,10 +4082,23 @@ function gt(e, t = {}) {
|
|
|
3851
4082
|
previous: t,
|
|
3852
4083
|
controller: a,
|
|
3853
4084
|
saving: !1
|
|
3854
|
-
}, e.classList.add("is-editing"), e.replaceChildren(r), r.focus(), "select" in r && typeof r.select == "function" && r.select()
|
|
4085
|
+
}, e.classList.add("is-editing"), e.replaceChildren(r), r.focus(), "select" in r && typeof r.select == "function" && r.select();
|
|
4086
|
+
let c = !1;
|
|
4087
|
+
r.addEventListener("keydown", (e) => {
|
|
3855
4088
|
let t = e;
|
|
3856
|
-
t.stopPropagation(),
|
|
3857
|
-
|
|
4089
|
+
t.stopPropagation(), c = n === "select" && [
|
|
4090
|
+
"ArrowUp",
|
|
4091
|
+
"ArrowDown",
|
|
4092
|
+
"ArrowLeft",
|
|
4093
|
+
"ArrowRight",
|
|
4094
|
+
"Home",
|
|
4095
|
+
"End",
|
|
4096
|
+
"PageUp",
|
|
4097
|
+
"PageDown"
|
|
4098
|
+
].includes(t.key), n === "select" && t.key.length === 1 && (c = !0), t.key === "Escape" ? (t.preventDefault(), f()) : t.key === "Enter" && (n !== "textarea" || t.ctrlKey || t.metaKey) && (t.preventDefault(), d());
|
|
4099
|
+
}, { signal: a.signal }), i && r.addEventListener("blur", () => void d(), { signal: a.signal }), n === "select" && r.addEventListener("change", () => {
|
|
4100
|
+
c ? c = !1 : d();
|
|
4101
|
+
}, { signal: a.signal }), K(e, "editable:start", { value: t });
|
|
3858
4102
|
}
|
|
3859
4103
|
function l(t, n) {
|
|
3860
4104
|
o && (o.controller.abort(), o = null, e.classList.remove("is-editing", "is-invalid"), e.removeAttribute("aria-invalid"), e.textContent = t, n && e.focus());
|
|
@@ -3862,7 +4106,7 @@ function gt(e, t = {}) {
|
|
|
3862
4106
|
function u(t) {
|
|
3863
4107
|
if (!o) return;
|
|
3864
4108
|
let n = o.input, r = e.querySelector(".editable-error");
|
|
3865
|
-
r || (r = document.createElement("div"), r.className = "editable-error", r.id =
|
|
4109
|
+
r || (r = document.createElement("div"), r.className = "editable-error", r.id = R("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();
|
|
3866
4110
|
}
|
|
3867
4111
|
async function d() {
|
|
3868
4112
|
if (!o || o.saving) return;
|
|
@@ -3915,9 +4159,9 @@ function gt(e, t = {}) {
|
|
|
3915
4159
|
}
|
|
3916
4160
|
};
|
|
3917
4161
|
}
|
|
3918
|
-
G.register("editable",
|
|
4162
|
+
G.register("editable", Ct);
|
|
3919
4163
|
// src/mixins/grid-navigation.ts
|
|
3920
|
-
function
|
|
4164
|
+
function wt(e, t = {}) {
|
|
3921
4165
|
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);
|
|
3922
4166
|
u && e.setAttribute("role", "grid");
|
|
3923
4167
|
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);
|
|
@@ -3969,7 +4213,7 @@ function _t(e, t = {}) {
|
|
|
3969
4213
|
return !u || u === l ? !1 : (h(u, n), !0);
|
|
3970
4214
|
}
|
|
3971
4215
|
function _(n) {
|
|
3972
|
-
l
|
|
4216
|
+
return !l || (t.onEdit?.(l, n), K(e, "grid:edit", {
|
|
3973
4217
|
cell: l,
|
|
3974
4218
|
key: n
|
|
3975
4219
|
}));
|
|
@@ -4021,7 +4265,7 @@ function _t(e, t = {}) {
|
|
|
4021
4265
|
case "F2":
|
|
4022
4266
|
_(t.key);
|
|
4023
4267
|
break;
|
|
4024
|
-
default: t.key.length
|
|
4268
|
+
default: t.key.length === 1 && !t.ctrlKey && !t.metaKey && !t.altKey ? s = !_(t.key) : ((t.key === "Process" || t.isComposing) && _(""), s = !1);
|
|
4025
4269
|
}
|
|
4026
4270
|
s && t.preventDefault();
|
|
4027
4271
|
}, { signal: c }), e.addEventListener("focusin", (t) => {
|
|
@@ -4050,15 +4294,15 @@ function _t(e, t = {}) {
|
|
|
4050
4294
|
}
|
|
4051
4295
|
};
|
|
4052
4296
|
}
|
|
4053
|
-
G.register("grid-navigation",
|
|
4297
|
+
G.register("grid-navigation", wt);
|
|
4054
4298
|
// src/mixins/infinite-scroll.ts
|
|
4055
|
-
function
|
|
4056
|
-
let n = t.threshold ?? 300, r = !1, i = !1, a = () => t.view &&
|
|
4299
|
+
function Tt(e, t = {}) {
|
|
4300
|
+
let n = t.threshold ?? 300, r = !1, i = !1, a = () => t.view && nt() ? U().listViews.get(t.view) : void 0, o = () => {
|
|
4057
4301
|
if (t.hasMore) return t.hasMore();
|
|
4058
4302
|
let e = a();
|
|
4059
4303
|
return !e || e.hasMore;
|
|
4060
4304
|
}, s = async () => {
|
|
4061
|
-
t.loadMore ? await t.loadMore() : t.view &&
|
|
4305
|
+
t.loadMore ? await t.loadMore() : t.view && nt() && await U().listViews.loadMore(t.view);
|
|
4062
4306
|
}, c = t.sentinel ? e.querySelector(t.sentinel) : null, l = !c;
|
|
4063
4307
|
c || (c = document.createElement("div"), c.className = "ar-scroll-sentinel", c.setAttribute("aria-hidden", "true"), e.appendChild(c));
|
|
4064
4308
|
let u = c, d = () => {
|
|
@@ -4097,11 +4341,11 @@ function vt(e, t = {}) {
|
|
|
4097
4341
|
}
|
|
4098
4342
|
};
|
|
4099
4343
|
}
|
|
4100
|
-
G.register("infinite-scroll",
|
|
4344
|
+
G.register("infinite-scroll", Tt);
|
|
4101
4345
|
// src/mixins/sortable.ts
|
|
4102
|
-
var Y = /* @__PURE__ */ new Map(),
|
|
4103
|
-
function
|
|
4104
|
-
if (n <= 0 ||
|
|
4346
|
+
var Y = /* @__PURE__ */ new Map(), Et = !1, X = 48, Dt = 18, Ot = 6, kt = 64, At = () => typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
4347
|
+
function jt(e, t, n) {
|
|
4348
|
+
if (n <= 0 || At() || typeof Element.prototype.animate != "function") {
|
|
4105
4349
|
t();
|
|
4106
4350
|
return;
|
|
4107
4351
|
}
|
|
@@ -4116,7 +4360,7 @@ function wt(e, t, n) {
|
|
|
4116
4360
|
}));
|
|
4117
4361
|
}
|
|
4118
4362
|
}
|
|
4119
|
-
function
|
|
4363
|
+
function Mt(e) {
|
|
4120
4364
|
let t = [];
|
|
4121
4365
|
for (let n = e; n && n !== document.body; n = n.parentElement) {
|
|
4122
4366
|
let e = getComputedStyle(n), r = /(auto|scroll)/.test(e.overflowY) && n.scrollHeight > n.clientHeight;
|
|
@@ -4125,17 +4369,17 @@ function Tt(e) {
|
|
|
4125
4369
|
let n = document.scrollingElement;
|
|
4126
4370
|
return n && t.push(n), t;
|
|
4127
4371
|
}
|
|
4128
|
-
function
|
|
4372
|
+
function Nt(e) {
|
|
4129
4373
|
let t = e.getBoundingClientRect(), n = getComputedStyle(e).transform;
|
|
4130
4374
|
if (!n || n === "none" || typeof DOMMatrixReadOnly > "u") return t;
|
|
4131
4375
|
let r = new DOMMatrixReadOnly(n);
|
|
4132
4376
|
return new DOMRect(t.left - r.e, t.top - r.f, t.width, t.height);
|
|
4133
4377
|
}
|
|
4134
|
-
function
|
|
4378
|
+
function Pt(e, t, n) {
|
|
4135
4379
|
let r = Math.max(e.left - t, 0, t - e.right), i = Math.max(e.top - n, 0, n - e.bottom);
|
|
4136
4380
|
return Math.hypot(r, i);
|
|
4137
4381
|
}
|
|
4138
|
-
function
|
|
4382
|
+
function Ft(e, t = {}) {
|
|
4139
4383
|
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;
|
|
4140
4384
|
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");
|
|
4141
4385
|
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);
|
|
@@ -4220,10 +4464,10 @@ function Ot(e, t = {}) {
|
|
|
4220
4464
|
function te(e, t) {
|
|
4221
4465
|
if (!d) return !1;
|
|
4222
4466
|
let n = !1;
|
|
4223
|
-
for (let r of
|
|
4467
|
+
for (let r of Mt(d.container)) {
|
|
4224
4468
|
let i = r === document.scrollingElement, a = i ? new DOMRect(0, 0, innerWidth, innerHeight) : r.getBoundingClientRect();
|
|
4225
|
-
if (!i &&
|
|
4226
|
-
let o = (e) => Math.ceil(
|
|
4469
|
+
if (!i && Pt(a, e, t) > 0) continue;
|
|
4470
|
+
let o = (e) => Math.ceil(Dt * 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;
|
|
4227
4471
|
if (!c && !s) continue;
|
|
4228
4472
|
let l = r.scrollTop, u = r.scrollLeft;
|
|
4229
4473
|
r.scrollBy?.(c, s), (r.scrollTop !== l || r.scrollLeft !== u) && (n = !0);
|
|
@@ -4231,9 +4475,9 @@ function Ot(e, t = {}) {
|
|
|
4231
4475
|
return n;
|
|
4232
4476
|
}
|
|
4233
4477
|
function ne(e, t) {
|
|
4234
|
-
let n = null, r =
|
|
4478
|
+
let n = null, r = kt;
|
|
4235
4479
|
for (let i of m()) {
|
|
4236
|
-
let a =
|
|
4480
|
+
let a = Pt(i.getBoundingClientRect(), e, t);
|
|
4237
4481
|
(a < r || a === 0 && r === 0) && (n = i, r = a);
|
|
4238
4482
|
}
|
|
4239
4483
|
return n;
|
|
@@ -4241,22 +4485,22 @@ function Ot(e, t = {}) {
|
|
|
4241
4485
|
function re(e, t, n) {
|
|
4242
4486
|
let r = p(e).filter((e) => e !== d?.item);
|
|
4243
4487
|
if (!r.length) return 0;
|
|
4244
|
-
let i = _(e) === "horizontal", a = 0, o = Infinity, s = Infinity, c = r.map(
|
|
4488
|
+
let i = _(e) === "horizontal", a = 0, o = Infinity, s = Infinity, c = r.map(Nt);
|
|
4245
4489
|
c.forEach((e, r) => {
|
|
4246
|
-
let i =
|
|
4490
|
+
let i = Pt(e, t, n), c = Math.hypot(t - (e.left + e.width / 2), n - (e.top + e.height / 2));
|
|
4247
4491
|
(i < o || i === o && c < s) && (a = r, o = i, s = c);
|
|
4248
4492
|
});
|
|
4249
4493
|
let l = c[a], u;
|
|
4250
4494
|
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;
|
|
4251
4495
|
}
|
|
4252
4496
|
function ie(t, n) {
|
|
4253
|
-
if (!d?.placeholder || Math.hypot(t - d.lastX, n - d.lastY) <
|
|
4497
|
+
if (!d?.placeholder || Math.hypot(t - d.lastX, n - d.lastY) < Ot || d.placeholder.isConnected && Pt(Nt(d.placeholder), t, n) === 0) return;
|
|
4254
4498
|
let r = ne(t, n);
|
|
4255
4499
|
if (!r) return;
|
|
4256
4500
|
let i = re(r, t, n);
|
|
4257
4501
|
if (r === d.container && i === d.index) return;
|
|
4258
4502
|
let a = d, s = p(r).filter((e) => e !== a.item);
|
|
4259
|
-
|
|
4503
|
+
jt(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", {
|
|
4260
4504
|
item: a.item,
|
|
4261
4505
|
to: r,
|
|
4262
4506
|
index: i
|
|
@@ -4268,13 +4512,13 @@ function Ot(e, t = {}) {
|
|
|
4268
4512
|
function C(e) {
|
|
4269
4513
|
if (!d) return;
|
|
4270
4514
|
let t = d;
|
|
4271
|
-
d = null, t.keyboard && (
|
|
4515
|
+
d = null, t.keyboard && (Et = !1, t.item.removeEventListener("keydown", w));
|
|
4272
4516
|
let { item: n, placeholder: r } = t, i = () => {
|
|
4273
4517
|
ae(t), r && (e && r.parentElement && r.replaceWith(n), r.remove()), oe(t, e);
|
|
4274
4518
|
};
|
|
4275
|
-
if (!r || !e || o <= 0 ||
|
|
4519
|
+
if (!r || !e || o <= 0 || At() || typeof n.animate != "function") {
|
|
4276
4520
|
if (r && !e) {
|
|
4277
|
-
ae(t),
|
|
4521
|
+
ae(t), jt(y(), () => r.remove(), o), oe(t, !1);
|
|
4278
4522
|
return;
|
|
4279
4523
|
}
|
|
4280
4524
|
i();
|
|
@@ -4303,13 +4547,13 @@ function Ot(e, t = {}) {
|
|
|
4303
4547
|
if (!r || l && !K(e, "sortable:end", c)) {
|
|
4304
4548
|
if (l) {
|
|
4305
4549
|
let e = p(n.from).filter((e) => e !== i);
|
|
4306
|
-
|
|
4550
|
+
jt(y(), () => n.from.insertBefore(i, e[n.oldIndex] ?? null), o);
|
|
4307
4551
|
}
|
|
4308
4552
|
n.keyboard && J(`${v(i)} returned to position ${n.oldIndex + 1}.`);
|
|
4309
4553
|
} 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.`);
|
|
4310
4554
|
n.keyboard && i.focus();
|
|
4311
4555
|
}
|
|
4312
|
-
function
|
|
4556
|
+
function se() {
|
|
4313
4557
|
u?.timer && clearTimeout(u.timer), u = null;
|
|
4314
4558
|
}
|
|
4315
4559
|
e.addEventListener("pointerdown", (n) => {
|
|
@@ -4331,24 +4575,24 @@ function Ot(e, t = {}) {
|
|
|
4331
4575
|
}, c);
|
|
4332
4576
|
}
|
|
4333
4577
|
}, { signal: r });
|
|
4334
|
-
let
|
|
4578
|
+
let ce = (e) => {
|
|
4335
4579
|
if (u && e.pointerId === u.pointerId) {
|
|
4336
4580
|
let t = Math.hypot(e.clientX - u.startX, e.clientY - u.startY);
|
|
4337
4581
|
if (!u.ready) {
|
|
4338
|
-
t > 8 &&
|
|
4582
|
+
t > 8 && se();
|
|
4339
4583
|
return;
|
|
4340
4584
|
}
|
|
4341
4585
|
if (t < s) return;
|
|
4342
4586
|
let n = u;
|
|
4343
4587
|
u = null, x(n, e.clientX, e.clientY), e.preventDefault();
|
|
4344
4588
|
} else d && !d.keyboard && e.pointerId === d.pointerId && (e.preventDefault(), S(e.clientX, e.clientY));
|
|
4345
|
-
},
|
|
4346
|
-
u && e.pointerId === u.pointerId ?
|
|
4589
|
+
}, le = (e) => {
|
|
4590
|
+
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"));
|
|
4347
4591
|
};
|
|
4348
|
-
document.addEventListener("pointermove",
|
|
4592
|
+
document.addEventListener("pointermove", ce, {
|
|
4349
4593
|
signal: r,
|
|
4350
4594
|
passive: !1
|
|
4351
|
-
}), document.addEventListener("pointerup",
|
|
4595
|
+
}), document.addEventListener("pointerup", le, { signal: r }), document.addEventListener("pointercancel", le, { signal: r }), document.addEventListener("touchmove", (e) => {
|
|
4352
4596
|
d && !d.keyboard && e.cancelable && e.preventDefault();
|
|
4353
4597
|
}, {
|
|
4354
4598
|
signal: r,
|
|
@@ -4357,17 +4601,17 @@ function Ot(e, t = {}) {
|
|
|
4357
4601
|
(d || u) && e.preventDefault();
|
|
4358
4602
|
}, { signal: r }), e.addEventListener("keydown", (t) => {
|
|
4359
4603
|
let n = t.target;
|
|
4360
|
-
if (!(
|
|
4604
|
+
if (!(Et || d) && f(n, n.parentElement) && n.parentElement === e && (t.key === " " || t.key === "Enter")) {
|
|
4361
4605
|
t.preventDefault();
|
|
4362
4606
|
let a = b(n, !0);
|
|
4363
|
-
|
|
4607
|
+
Et = !0, n.addEventListener("keydown", w, { signal: r }), n.classList.add(i), n.setAttribute("aria-grabbed", "true"), K(e, "sortable:start", {
|
|
4364
4608
|
item: n,
|
|
4365
4609
|
from: a.from,
|
|
4366
4610
|
oldIndex: a.oldIndex
|
|
4367
4611
|
}), 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.`);
|
|
4368
4612
|
}
|
|
4369
4613
|
}, { signal: r });
|
|
4370
|
-
function
|
|
4614
|
+
function w(t) {
|
|
4371
4615
|
if (!d || !d.keyboard || t.target !== d.item) return;
|
|
4372
4616
|
t.stopPropagation();
|
|
4373
4617
|
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;
|
|
@@ -4396,7 +4640,7 @@ function Ot(e, t = {}) {
|
|
|
4396
4640
|
default: return;
|
|
4397
4641
|
}
|
|
4398
4642
|
if (t.preventDefault(), h) {
|
|
4399
|
-
|
|
4643
|
+
jt([...y(), n], h, o);
|
|
4400
4644
|
let t = n.parentElement;
|
|
4401
4645
|
d.container = t, d.index = p(t).indexOf(n), K(e, "sortable:move", {
|
|
4402
4646
|
item: n,
|
|
@@ -4414,13 +4658,13 @@ function Ot(e, t = {}) {
|
|
|
4414
4658
|
options: t,
|
|
4415
4659
|
toArray: () => p(e).map((e) => e.getAttribute("data-id") ?? ""),
|
|
4416
4660
|
destroy: () => {
|
|
4417
|
-
|
|
4661
|
+
se(), d && C(!1), n.abort(), g?.disconnect(), l && Y.get(l)?.delete(e), e.classList.remove("is-sortable");
|
|
4418
4662
|
}
|
|
4419
4663
|
};
|
|
4420
4664
|
}
|
|
4421
|
-
G.register("sortable",
|
|
4665
|
+
G.register("sortable", Ft);
|
|
4422
4666
|
// src/mixins/resizable.ts
|
|
4423
|
-
function
|
|
4667
|
+
function It(e, t = {}) {
|
|
4424
4668
|
let n = t.handles ?? [
|
|
4425
4669
|
"e",
|
|
4426
4670
|
"s",
|
|
@@ -4504,11 +4748,11 @@ function kt(e, t = {}) {
|
|
|
4504
4748
|
}
|
|
4505
4749
|
};
|
|
4506
4750
|
}
|
|
4507
|
-
G.register("resizable",
|
|
4751
|
+
G.register("resizable", It);
|
|
4508
4752
|
// src/mixins/dropdown.ts
|
|
4509
|
-
function
|
|
4753
|
+
function Lt(e, t = {}) {
|
|
4510
4754
|
if (!(e instanceof HTMLSelectElement)) throw Error("dropdown mixin must be applied to a <select>");
|
|
4511
|
-
let n = e, { searchable: r = !0, emptyText: i = "No matches" } = t, a = new AbortController(), { signal: o } = a, s =
|
|
4755
|
+
let n = e, { searchable: r = !0, emptyText: i = "No matches" } = t, a = new AbortController(), { signal: o } = a, s = R("dropdown"), c = document.createElement("div");
|
|
4512
4756
|
c.className = "dropdown";
|
|
4513
4757
|
let l = document.createElement("input");
|
|
4514
4758
|
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") ?? "";
|
|
@@ -4611,20 +4855,20 @@ function At(e, t = {}) {
|
|
|
4611
4855
|
}
|
|
4612
4856
|
};
|
|
4613
4857
|
}
|
|
4614
|
-
G.register("dropdown",
|
|
4858
|
+
G.register("dropdown", Lt);
|
|
4615
4859
|
// src/mixins/tooltip.ts
|
|
4616
|
-
function
|
|
4860
|
+
function Rt(e, t = {}) {
|
|
4617
4861
|
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 ?? "";
|
|
4618
4862
|
o !== null && e.removeAttribute("title");
|
|
4619
4863
|
let c = document.createElement("div");
|
|
4620
|
-
c.id =
|
|
4864
|
+
c.id = R("tooltip"), c.className = "tooltip", c.setAttribute("role", "tooltip"), c.hidden = !0;
|
|
4621
4865
|
let l = e.getAttribute("aria-describedby");
|
|
4622
4866
|
e.setAttribute("aria-describedby", [l, c.id].filter(Boolean).join(" "));
|
|
4623
4867
|
let u = null;
|
|
4624
4868
|
function d() {
|
|
4625
4869
|
u && clearTimeout(u), u = null;
|
|
4626
4870
|
let t = s();
|
|
4627
|
-
t && (c.textContent = t, c.isConnected || document.body.appendChild(c), c.hidden = !1,
|
|
4871
|
+
t && (c.textContent = t, c.isConnected || document.body.appendChild(c), c.hidden = !1, bt(c, e.getBoundingClientRect(), n));
|
|
4628
4872
|
}
|
|
4629
4873
|
function f() {
|
|
4630
4874
|
u && clearTimeout(u), u = setTimeout(d, r);
|
|
@@ -4652,9 +4896,9 @@ function jt(e, t = {}) {
|
|
|
4652
4896
|
}
|
|
4653
4897
|
};
|
|
4654
4898
|
}
|
|
4655
|
-
G.register("tooltip",
|
|
4899
|
+
G.register("tooltip", Rt);
|
|
4656
4900
|
// src/mixins/context-menu.ts
|
|
4657
|
-
function
|
|
4901
|
+
function zt(e, t = {}) {
|
|
4658
4902
|
let n = new AbortController(), { signal: r } = n, i = null, a = null, o = null, s = null, c = "", l = null, u = () => t.items ?? [];
|
|
4659
4903
|
function d() {
|
|
4660
4904
|
return i ? Array.from(i.querySelectorAll("[role=\"menuitem\"]:not([aria-disabled=\"true\"])")) : [];
|
|
@@ -4666,7 +4910,7 @@ function Mt(e, t = {}) {
|
|
|
4666
4910
|
function p(t, n, r) {
|
|
4667
4911
|
h(!1), o = r, s = document.activeElement, a = new AbortController();
|
|
4668
4912
|
let p = a.signal;
|
|
4669
|
-
i = document.createElement("div"), i.className = "context-menu", i.id =
|
|
4913
|
+
i = document.createElement("div"), i.className = "context-menu", i.id = R("menu"), i.setAttribute("role", "menu");
|
|
4670
4914
|
for (let e of u()) {
|
|
4671
4915
|
if (e.separator) {
|
|
4672
4916
|
let e = document.createElement("div");
|
|
@@ -4759,52 +5003,163 @@ function Mt(e, t = {}) {
|
|
|
4759
5003
|
}
|
|
4760
5004
|
};
|
|
4761
5005
|
}
|
|
4762
|
-
G.register("context-menu",
|
|
5006
|
+
G.register("context-menu", zt);
|
|
5007
|
+
// src/mixins/listbox.ts
|
|
5008
|
+
function Bt(e, t) {
|
|
5009
|
+
let n = new AbortController(), { signal: r } = n, i = t.options.map((e) => typeof e == "string" ? { value: e } : e), a = (e) => e.label ?? e.value, o = t.value ?? i[0]?.value ?? "", s = Math.max(0, i.findIndex((e) => e.value === o)), c = !1, l = "", u = 0, d = R("ar-listbox"), f = document.createElement("ul");
|
|
5010
|
+
f.id = d, f.className = "ar-listbox", f.setAttribute("role", "listbox"), f.hidden = !0, f.tabIndex = -1;
|
|
5011
|
+
let p = t.label ?? e.getAttribute("aria-label");
|
|
5012
|
+
p && f.setAttribute("aria-label", p), i.forEach((e, t) => {
|
|
5013
|
+
let n = document.createElement("li");
|
|
5014
|
+
n.id = `${d}-${t}`, n.className = "ar-listbox__option", n.setAttribute("role", "option"), n.textContent = a(e), e.disabled && n.setAttribute("aria-disabled", "true"), f.appendChild(n);
|
|
5015
|
+
}), (t.container ?? e.parentElement ?? document.body).appendChild(f), t.container || e.after(f);
|
|
5016
|
+
let m = document.createElement("span");
|
|
5017
|
+
m.className = "ar-listbox__value", e.replaceChildren(m), e.classList.add("ar-listbox__button"), e.setAttribute("role", "combobox"), e.setAttribute("aria-haspopup", "listbox"), e.setAttribute("aria-controls", d), e.setAttribute("aria-expanded", "false"), e.hasAttribute("tabindex") || (e.tabIndex = 0);
|
|
5018
|
+
let h = () => Array.from(f.children);
|
|
5019
|
+
function g() {
|
|
5020
|
+
m.textContent = a(i.find((e) => e.value === o) ?? { value: o }), h().forEach((e, t) => {
|
|
5021
|
+
e.setAttribute("aria-selected", String(i[t].value === o)), e.classList.toggle("is-active", t === s && c);
|
|
5022
|
+
}), c && h()[s] ? (e.setAttribute("aria-activedescendant", h()[s].id), h()[s].scrollIntoView?.({ block: "nearest" })) : e.removeAttribute("aria-activedescendant");
|
|
5023
|
+
}
|
|
5024
|
+
function _(e, t = 1) {
|
|
5025
|
+
let n = (e) => Math.max(0, Math.min(i.length - 1, e));
|
|
5026
|
+
for (let r of [t, -t]) for (let t = n(e); t >= 0 && t < i.length; t += r) if (!i[t].disabled) {
|
|
5027
|
+
s = t, g();
|
|
5028
|
+
return;
|
|
5029
|
+
}
|
|
5030
|
+
}
|
|
5031
|
+
function v(t = s) {
|
|
5032
|
+
c || (c = !0, f.hidden = !1, e.setAttribute("aria-expanded", "true"), _(t));
|
|
5033
|
+
}
|
|
5034
|
+
function y() {
|
|
5035
|
+
c && (c = !1, f.hidden = !0, e.setAttribute("aria-expanded", "false"), g());
|
|
5036
|
+
}
|
|
5037
|
+
function b(t, n, r = !1) {
|
|
5038
|
+
let a = i[t];
|
|
5039
|
+
if (!a || a.disabled) return;
|
|
5040
|
+
let c = a.value !== o;
|
|
5041
|
+
o = a.value, s = t, y(), c && K(e, "listbox:change", { value: o }), K(e, "listbox:commit", {
|
|
5042
|
+
value: o,
|
|
5043
|
+
key: n,
|
|
5044
|
+
shiftKey: r
|
|
5045
|
+
});
|
|
5046
|
+
}
|
|
5047
|
+
function x(e) {
|
|
5048
|
+
let t = Date.now();
|
|
5049
|
+
l = t - u > 600 ? e : l + e, u = t;
|
|
5050
|
+
let n = l.toLowerCase(), r = l.length === 1 ? s + 1 : s;
|
|
5051
|
+
for (let e = 0; e < i.length; e++) {
|
|
5052
|
+
let t = (r + e) % i.length;
|
|
5053
|
+
if (!i[t].disabled && a(i[t]).toLowerCase().startsWith(n)) {
|
|
5054
|
+
_(t);
|
|
5055
|
+
return;
|
|
5056
|
+
}
|
|
5057
|
+
}
|
|
5058
|
+
}
|
|
5059
|
+
return e.addEventListener("keydown", (t) => {
|
|
5060
|
+
let n = !0;
|
|
5061
|
+
if (!c) t.key === "ArrowDown" || t.key === "ArrowUp" || t.key === "Enter" || t.key === " " ? v() : t.key === "Home" ? v(0) : t.key === "End" ? v(i.length - 1) : t.key.length === 1 && !t.ctrlKey && !t.metaKey && !t.altKey ? (v(), x(t.key)) : n = !1;
|
|
5062
|
+
else switch (t.key) {
|
|
5063
|
+
case "ArrowDown":
|
|
5064
|
+
t.altKey ? n = !1 : _(Math.min(i.length - 1, s + 1));
|
|
5065
|
+
break;
|
|
5066
|
+
case "ArrowUp":
|
|
5067
|
+
t.altKey ? b(s, "Enter") : _(Math.max(0, s - 1), -1);
|
|
5068
|
+
break;
|
|
5069
|
+
case "PageDown":
|
|
5070
|
+
_(Math.min(i.length - 1, s + 10));
|
|
5071
|
+
break;
|
|
5072
|
+
case "PageUp":
|
|
5073
|
+
_(Math.max(0, s - 10), -1);
|
|
5074
|
+
break;
|
|
5075
|
+
case "Home":
|
|
5076
|
+
_(0);
|
|
5077
|
+
break;
|
|
5078
|
+
case "End":
|
|
5079
|
+
_(i.length - 1, -1);
|
|
5080
|
+
break;
|
|
5081
|
+
case "Enter":
|
|
5082
|
+
b(s, "Enter", t.shiftKey);
|
|
5083
|
+
break;
|
|
5084
|
+
case "Escape":
|
|
5085
|
+
y(), K(e, "listbox:cancel", {});
|
|
5086
|
+
break;
|
|
5087
|
+
case "Tab":
|
|
5088
|
+
b(s, "Tab", t.shiftKey), n = !1;
|
|
5089
|
+
break;
|
|
5090
|
+
default: t.key.length === 1 && !t.ctrlKey && !t.metaKey && !t.altKey ? x(t.key) : n = !1;
|
|
5091
|
+
}
|
|
5092
|
+
n && (t.preventDefault(), t.stopPropagation());
|
|
5093
|
+
}, { signal: r }), e.addEventListener("click", () => c ? y() : v(), { signal: r }), f.addEventListener("mousedown", (e) => e.preventDefault(), { signal: r }), f.addEventListener("click", (e) => {
|
|
5094
|
+
let t = e.target.closest("[role=option]");
|
|
5095
|
+
t && b(h().indexOf(t), "click");
|
|
5096
|
+
}, { signal: r }), f.addEventListener("mousemove", (e) => {
|
|
5097
|
+
let t = e.target.closest("[role=option]"), n = t ? h().indexOf(t) : -1;
|
|
5098
|
+
n !== -1 && n !== s && !i[n].disabled && _(n);
|
|
5099
|
+
}, { signal: r }), e.addEventListener("blur", () => y(), { signal: r }), g(), t.open && v(), {
|
|
5100
|
+
name: "listbox",
|
|
5101
|
+
element: e,
|
|
5102
|
+
options: t,
|
|
5103
|
+
open: () => v(),
|
|
5104
|
+
close: y,
|
|
5105
|
+
isOpen: () => c,
|
|
5106
|
+
getValue: () => o,
|
|
5107
|
+
getActiveValue: () => i[s]?.value,
|
|
5108
|
+
setValue: (e) => {
|
|
5109
|
+
o = e, s = Math.max(0, i.findIndex((t) => t.value === e)), g();
|
|
5110
|
+
},
|
|
5111
|
+
destroy: () => {
|
|
5112
|
+
n.abort(), f.remove(), e.removeAttribute("role"), e.removeAttribute("aria-haspopup"), e.removeAttribute("aria-controls"), e.removeAttribute("aria-expanded"), e.removeAttribute("aria-activedescendant"), e.classList.remove("ar-listbox__button");
|
|
5113
|
+
}
|
|
5114
|
+
};
|
|
5115
|
+
}
|
|
5116
|
+
G.register("listbox", Bt);
|
|
4763
5117
|
// src/mixins/index.ts
|
|
4764
|
-
function
|
|
5118
|
+
function Vt() {
|
|
4765
5119
|
let e = {
|
|
4766
|
-
draggable:
|
|
4767
|
-
editable:
|
|
4768
|
-
"grid-navigation":
|
|
4769
|
-
"infinite-scroll":
|
|
4770
|
-
sortable:
|
|
4771
|
-
resizable:
|
|
4772
|
-
dropdown:
|
|
4773
|
-
tooltip:
|
|
4774
|
-
"context-menu":
|
|
5120
|
+
draggable: St,
|
|
5121
|
+
editable: Ct,
|
|
5122
|
+
"grid-navigation": wt,
|
|
5123
|
+
"infinite-scroll": Tt,
|
|
5124
|
+
sortable: Ft,
|
|
5125
|
+
resizable: It,
|
|
5126
|
+
dropdown: Lt,
|
|
5127
|
+
tooltip: Rt,
|
|
5128
|
+
"context-menu": zt,
|
|
5129
|
+
listbox: Bt
|
|
4775
5130
|
};
|
|
4776
5131
|
for (let [t, n] of Object.entries(e)) G.has(t) || G.register(t, n);
|
|
4777
5132
|
}
|
|
4778
5133
|
// src/version.ts
|
|
4779
|
-
var Z = "0.
|
|
5134
|
+
var Z = "0.2.0";
|
|
4780
5135
|
// src/plugins/date-utils.ts
|
|
4781
|
-
function
|
|
5136
|
+
function Ht(e, t = {}) {
|
|
4782
5137
|
let n = e instanceof HTMLInputElement ? e : e.querySelector("input"), r = new AbortController();
|
|
4783
5138
|
if (!n) throw Error("datepicker: no <input> found");
|
|
4784
5139
|
let i = n.type;
|
|
4785
5140
|
n.type = "date";
|
|
4786
|
-
let a =
|
|
4787
|
-
return a && (n.min =
|
|
4788
|
-
let e =
|
|
5141
|
+
let a = k(t.min), o = k(t.max);
|
|
5142
|
+
return a && (n.min = j(a)), o && (n.max = j(o)), n.addEventListener("change", () => {
|
|
5143
|
+
let e = k(n.value);
|
|
4789
5144
|
t.onChange?.(e), K(n, "datepicker:change", { date: e });
|
|
4790
5145
|
}, { signal: r.signal }), {
|
|
4791
5146
|
name: "datepicker",
|
|
4792
5147
|
element: e,
|
|
4793
5148
|
options: t,
|
|
4794
|
-
value: () =>
|
|
5149
|
+
value: () => k(n.value),
|
|
4795
5150
|
destroy: () => {
|
|
4796
5151
|
r.abort(), n.type = i;
|
|
4797
5152
|
}
|
|
4798
5153
|
};
|
|
4799
5154
|
}
|
|
4800
|
-
function
|
|
5155
|
+
function Ut(e, t = {}) {
|
|
4801
5156
|
let n = e.querySelector(t.startSelector ?? "[data-start], [name=\"start\"]"), r = e.querySelector(t.endSelector ?? "[data-end], [name=\"end\"]");
|
|
4802
5157
|
if (!n || !r) throw Error("daterange: start and end inputs are required");
|
|
4803
5158
|
let i = new AbortController();
|
|
4804
5159
|
n.type = "date", r.type = "date";
|
|
4805
5160
|
let a = () => (r.min = n.value || "", n.max = r.value || "", {
|
|
4806
|
-
start:
|
|
4807
|
-
end:
|
|
5161
|
+
start: k(n.value),
|
|
5162
|
+
end: k(r.value)
|
|
4808
5163
|
}), o = () => {
|
|
4809
5164
|
let n = a();
|
|
4810
5165
|
t.onChange?.(n), K(e, "daterange:change", n);
|
|
@@ -4814,48 +5169,48 @@ function Ft(e, t = {}) {
|
|
|
4814
5169
|
element: e,
|
|
4815
5170
|
options: t,
|
|
4816
5171
|
value: () => ({
|
|
4817
|
-
start:
|
|
4818
|
-
end:
|
|
5172
|
+
start: k(n.value),
|
|
5173
|
+
end: k(r.value)
|
|
4819
5174
|
}),
|
|
4820
5175
|
destroy: () => i.abort()
|
|
4821
5176
|
};
|
|
4822
5177
|
}
|
|
4823
|
-
var Q = () =>
|
|
4824
|
-
function
|
|
5178
|
+
var Q = () => M(/* @__PURE__ */ new Date());
|
|
5179
|
+
function Wt() {
|
|
4825
5180
|
return {
|
|
4826
5181
|
name: "date-utils",
|
|
4827
5182
|
version: Z,
|
|
4828
5183
|
mixins: {
|
|
4829
|
-
datepicker:
|
|
4830
|
-
daterange:
|
|
5184
|
+
datepicker: Ht,
|
|
5185
|
+
daterange: Ut
|
|
4831
5186
|
},
|
|
4832
5187
|
validators: {
|
|
4833
5188
|
futureDate: {
|
|
4834
5189
|
fn: (e, t) => {
|
|
4835
|
-
let n =
|
|
4836
|
-
return n ? t.includeToday === !1 ?
|
|
5190
|
+
let n = k(e);
|
|
5191
|
+
return n ? t.includeToday === !1 ? M(n) > Q() : M(n) >= Q() : !0;
|
|
4837
5192
|
},
|
|
4838
5193
|
message: "Choose a date in the future"
|
|
4839
5194
|
},
|
|
4840
5195
|
pastDate: {
|
|
4841
5196
|
fn: (e, t) => {
|
|
4842
|
-
let n =
|
|
4843
|
-
return n ? t.includeToday === !1 ?
|
|
5197
|
+
let n = k(e);
|
|
5198
|
+
return n ? t.includeToday === !1 ? M(n) < Q() : M(n) <= Q() : !0;
|
|
4844
5199
|
},
|
|
4845
5200
|
message: "Choose a date in the past"
|
|
4846
5201
|
},
|
|
4847
5202
|
dateRange: {
|
|
4848
5203
|
fn: (e, t) => {
|
|
4849
|
-
let n =
|
|
5204
|
+
let n = k(e);
|
|
4850
5205
|
if (!n) return !0;
|
|
4851
|
-
let r =
|
|
4852
|
-
return !(r &&
|
|
5206
|
+
let r = k(t.min), i = k(t.max);
|
|
5207
|
+
return !(r && M(n) < M(r) || i && M(n) > M(i));
|
|
4853
5208
|
},
|
|
4854
5209
|
message: "Choose a date between {min} and {max}"
|
|
4855
5210
|
},
|
|
4856
5211
|
businessDay: {
|
|
4857
5212
|
fn: (e) => {
|
|
4858
|
-
let t =
|
|
5213
|
+
let t = k(e);
|
|
4859
5214
|
if (!t) return !0;
|
|
4860
5215
|
let n = t.getDay();
|
|
4861
5216
|
return n !== 0 && n !== 6;
|
|
@@ -4864,10 +5219,10 @@ function It() {
|
|
|
4864
5219
|
},
|
|
4865
5220
|
minAge: {
|
|
4866
5221
|
fn: (e, t) => {
|
|
4867
|
-
let n =
|
|
5222
|
+
let n = k(e);
|
|
4868
5223
|
if (!n) return !0;
|
|
4869
5224
|
let r = Number(t.years ?? 18), i = Q();
|
|
4870
|
-
return i.setFullYear(i.getFullYear() - r),
|
|
5225
|
+
return i.setFullYear(i.getFullYear() - r), M(n) <= i;
|
|
4871
5226
|
},
|
|
4872
5227
|
message: "You must be at least {years} years old"
|
|
4873
5228
|
}
|
|
@@ -4875,7 +5230,7 @@ function It() {
|
|
|
4875
5230
|
};
|
|
4876
5231
|
}
|
|
4877
5232
|
// src/plugins/async-validators.ts
|
|
4878
|
-
function
|
|
5233
|
+
function Gt() {
|
|
4879
5234
|
let e = null, t = {
|
|
4880
5235
|
debounce: 300,
|
|
4881
5236
|
failOpen: !0
|
|
@@ -4950,7 +5305,7 @@ function Lt() {
|
|
|
4950
5305
|
};
|
|
4951
5306
|
}
|
|
4952
5307
|
// src/plugins/rich-text.ts
|
|
4953
|
-
var
|
|
5308
|
+
var Kt = [
|
|
4954
5309
|
"bold",
|
|
4955
5310
|
"italic",
|
|
4956
5311
|
"underline",
|
|
@@ -4962,7 +5317,7 @@ var Rt = [
|
|
|
4962
5317
|
"blockquote",
|
|
4963
5318
|
"link",
|
|
4964
5319
|
"clear"
|
|
4965
|
-
],
|
|
5320
|
+
], qt = {
|
|
4966
5321
|
bold: {
|
|
4967
5322
|
label: "Bold",
|
|
4968
5323
|
icon: "B",
|
|
@@ -5066,14 +5421,14 @@ function $(e, t) {
|
|
|
5066
5421
|
return !1;
|
|
5067
5422
|
}
|
|
5068
5423
|
}
|
|
5069
|
-
function
|
|
5070
|
-
let n = new AbortController(), { signal: r } = n, i = e instanceof HTMLTextAreaElement ? e : null, a = i ? document.createElement("div") : e, o = (e) =>
|
|
5424
|
+
function Jt(e, t = {}) {
|
|
5425
|
+
let n = new AbortController(), { signal: r } = n, i = e instanceof HTMLTextAreaElement ? e : null, a = i ? document.createElement("div") : e, o = (e) => F(e, t.sanitize), s = document.createElement("div");
|
|
5071
5426
|
s.className = "rich-text", e.insertAdjacentElement("beforebegin", s);
|
|
5072
5427
|
let c = document.createElement("div");
|
|
5073
|
-
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 ||=
|
|
5428
|
+
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 ||= R("rich-text"), $("defaultParagraphSeparator", "p");
|
|
5074
5429
|
let l = [];
|
|
5075
|
-
for (let e of t.toolbar ??
|
|
5076
|
-
let t =
|
|
5430
|
+
for (let e of t.toolbar ?? Kt) {
|
|
5431
|
+
let t = qt[e];
|
|
5077
5432
|
if (!t) continue;
|
|
5078
5433
|
let n = document.createElement("button");
|
|
5079
5434
|
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);
|
|
@@ -5087,12 +5442,12 @@ function Bt(e, t = {}) {
|
|
|
5087
5442
|
let p = null, m = a.innerHTML;
|
|
5088
5443
|
function h() {
|
|
5089
5444
|
let e = o(a.innerHTML);
|
|
5090
|
-
e !== m && (m = e, i && (i.value = e, i.dispatchEvent(new Event("input", { bubbles: !0 }))), a.classList.toggle("is-empty",
|
|
5445
|
+
e !== m && (m = e, i && (i.value = e, i.dispatchEvent(new Event("input", { bubbles: !0 }))), a.classList.toggle("is-empty", I(e).trim() === ""), K(a, "rich-text:change", {
|
|
5091
5446
|
html: e,
|
|
5092
|
-
text:
|
|
5447
|
+
text: I(e)
|
|
5093
5448
|
}));
|
|
5094
5449
|
}
|
|
5095
|
-
a.classList.toggle("is-empty",
|
|
5450
|
+
a.classList.toggle("is-empty", I(a.innerHTML).trim() === "");
|
|
5096
5451
|
function g() {
|
|
5097
5452
|
let e = document.getSelection();
|
|
5098
5453
|
if (!e || !e.anchorNode || !a.contains(e.anchorNode)) return;
|
|
@@ -5100,7 +5455,7 @@ function Bt(e, t = {}) {
|
|
|
5100
5455
|
for (; t && t !== a && !/^(P|H2|H3|BLOCKQUOTE|PRE|LI)$/.test(t.tagName);) t = t.parentElement;
|
|
5101
5456
|
let n = t && t !== a ? t.tagName.toLowerCase() : "p";
|
|
5102
5457
|
for (let e of l) {
|
|
5103
|
-
let t =
|
|
5458
|
+
let t = qt[e.dataset.command], r = null;
|
|
5104
5459
|
if (t.block) r = n === t.block;
|
|
5105
5460
|
else if (t.state) try {
|
|
5106
5461
|
r = document.queryCommandState?.(t.state) ?? !1;
|
|
@@ -5117,12 +5472,12 @@ function Bt(e, t = {}) {
|
|
|
5117
5472
|
d.value = t?.getAttribute("href") ?? "", u.hidden = !1, d.focus();
|
|
5118
5473
|
}
|
|
5119
5474
|
function v(e) {
|
|
5120
|
-
let t =
|
|
5475
|
+
let t = qt[e];
|
|
5121
5476
|
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());
|
|
5122
5477
|
}
|
|
5123
5478
|
return u.addEventListener("submit", (e) => {
|
|
5124
5479
|
e.preventDefault();
|
|
5125
|
-
let t =
|
|
5480
|
+
let t = P(d.value.trim(), "link");
|
|
5126
5481
|
if (u.hidden = !0, a.focus(), p) {
|
|
5127
5482
|
let e = document.getSelection();
|
|
5128
5483
|
e?.removeAllRanges(), e?.addRange(p);
|
|
@@ -5153,7 +5508,7 @@ function Bt(e, t = {}) {
|
|
|
5153
5508
|
u: "underline",
|
|
5154
5509
|
k: "link"
|
|
5155
5510
|
};
|
|
5156
|
-
r[n] && (t.toolbar ??
|
|
5511
|
+
r[n] && (t.toolbar ?? Kt).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"));
|
|
5157
5512
|
}, { signal: r }), a.addEventListener("paste", (e) => {
|
|
5158
5513
|
let t = e.clipboardData;
|
|
5159
5514
|
if (!t) return;
|
|
@@ -5168,7 +5523,7 @@ function Bt(e, t = {}) {
|
|
|
5168
5523
|
options: t,
|
|
5169
5524
|
editor: a,
|
|
5170
5525
|
getHTML: () => o(a.innerHTML),
|
|
5171
|
-
getText: () =>
|
|
5526
|
+
getText: () => I(a.innerHTML),
|
|
5172
5527
|
setHTML: (e) => {
|
|
5173
5528
|
a.innerHTML = o(e), h();
|
|
5174
5529
|
},
|
|
@@ -5178,21 +5533,21 @@ function Bt(e, t = {}) {
|
|
|
5178
5533
|
}
|
|
5179
5534
|
};
|
|
5180
5535
|
}
|
|
5181
|
-
function
|
|
5536
|
+
function Yt() {
|
|
5182
5537
|
return {
|
|
5183
5538
|
name: "rich-text",
|
|
5184
5539
|
version: Z,
|
|
5185
|
-
mixins: { "rich-text":
|
|
5540
|
+
mixins: { "rich-text": Jt },
|
|
5186
5541
|
validators: {
|
|
5187
5542
|
richTextMinLength: {
|
|
5188
5543
|
fn: (e, t) => {
|
|
5189
|
-
let n =
|
|
5544
|
+
let n = I(e).trim();
|
|
5190
5545
|
return n === "" || n.length >= Number(t.min ?? 0);
|
|
5191
5546
|
},
|
|
5192
5547
|
message: "Write at least {min} characters"
|
|
5193
5548
|
},
|
|
5194
5549
|
richTextMaxLength: {
|
|
5195
|
-
fn: (e, t) =>
|
|
5550
|
+
fn: (e, t) => I(e).trim().length <= Number(t.max ?? Infinity),
|
|
5196
5551
|
message: "Keep it under {max} characters"
|
|
5197
5552
|
},
|
|
5198
5553
|
noEmptyParagraphs: {
|
|
@@ -5203,19 +5558,19 @@ function Vt() {
|
|
|
5203
5558
|
};
|
|
5204
5559
|
}
|
|
5205
5560
|
// src/plugins/builtins.ts
|
|
5206
|
-
function
|
|
5207
|
-
|
|
5561
|
+
function Xt() {
|
|
5562
|
+
vt("date-utils", Wt), vt("async-validators", Gt), vt("rich-text", Yt);
|
|
5208
5563
|
}
|
|
5209
|
-
|
|
5564
|
+
Xt();
|
|
5210
5565
|
// src/core/arethesis.ts
|
|
5211
|
-
var
|
|
5566
|
+
var Zt = class e extends f {
|
|
5212
5567
|
static instance = null;
|
|
5213
5568
|
version = Z;
|
|
5214
5569
|
store = new l();
|
|
5215
5570
|
listViews = new u();
|
|
5216
5571
|
optimistic;
|
|
5217
5572
|
http = new C();
|
|
5218
|
-
validation = new
|
|
5573
|
+
validation = new Ie();
|
|
5219
5574
|
binder;
|
|
5220
5575
|
plugins;
|
|
5221
5576
|
collab;
|
|
@@ -5230,10 +5585,10 @@ var Ut = class e extends f {
|
|
|
5230
5585
|
initPromise = null;
|
|
5231
5586
|
stopObserving = null;
|
|
5232
5587
|
constructor() {
|
|
5233
|
-
super(),
|
|
5588
|
+
super(), Vt(), Xt(), this.optimistic = new m(this.store, this.listViews), this.binder = new Xe(this.validation), this.plugins = new yt(this), this.collab = new ke(() => this.ws), this.http.connect({
|
|
5234
5589
|
store: this.store,
|
|
5235
5590
|
listViews: this.listViews
|
|
5236
|
-
}), this.listViews.setLoader((e, t) => this.http.loadListView(e, t)),
|
|
5591
|
+
}), this.listViews.setLoader((e, t) => this.http.loadListView(e, t)), tt({
|
|
5237
5592
|
store: this.store,
|
|
5238
5593
|
listViews: this.listViews,
|
|
5239
5594
|
binder: this.binder,
|
|
@@ -5271,7 +5626,7 @@ var Ut = class e extends f {
|
|
|
5271
5626
|
for (let e of t.types ?? []) this.defineType(e);
|
|
5272
5627
|
for (let [e, n] of Object.entries(t.endpoints ?? {})) this.defineEndpoint(e, n);
|
|
5273
5628
|
for (let [e, n] of Object.entries(t.validation?.messages ?? {})) this.validation.setMessage(e, n);
|
|
5274
|
-
t.auth && (this.auth = new
|
|
5629
|
+
t.auth && (this.auth = new le(t.auth, {
|
|
5275
5630
|
fetch: () => t.http?.fetch ?? globalThis.fetch.bind(globalThis),
|
|
5276
5631
|
resolveUrl: (e) => this.http.resolveUrl(e)
|
|
5277
5632
|
}), this.http.connect({ auth: this.auth })), t.persistence !== !1 && await this.initPersistence(typeof t.persistence == "object" ? t.persistence : {});
|
|
@@ -5279,10 +5634,10 @@ var Ut = class e extends f {
|
|
|
5279
5634
|
let t = e.replace(/^ws(s?):\/\//i, "http$1://");
|
|
5280
5635
|
return this.auth && this.http.isTrustedUrl(t) ? this.auth.ensureValidToken() : null;
|
|
5281
5636
|
};
|
|
5282
|
-
if (t.sse && (this.sse = new
|
|
5637
|
+
if (t.sse && (this.sse = new ue({
|
|
5283
5638
|
...t.sse,
|
|
5284
5639
|
url: this.http.resolveUrl(t.sse.url)
|
|
5285
|
-
}), this.sse.connectStore(this.store, this.listViews), this.sse.setTokenProvider(n(this.sse.config.url))), t.websocket && (this.ws = new
|
|
5640
|
+
}), this.sse.connectStore(this.store, this.listViews), this.sse.setTokenProvider(n(this.sse.config.url))), t.websocket && (this.ws = new fe(t.websocket), this.ws.setTokenProvider(n(t.websocket.url))), t.azurePubSub && (this.azurePubSub = new me({
|
|
5286
5641
|
...t.azurePubSub,
|
|
5287
5642
|
negotiateUrl: this.http.resolveUrl(t.azurePubSub.negotiateUrl),
|
|
5288
5643
|
fetch: t.azurePubSub.fetch ?? t.http?.fetch
|
|
@@ -5331,15 +5686,67 @@ var Ut = class e extends f {
|
|
|
5331
5686
|
this.disconnect(), this.stopObserving?.(), this.stopObserving = null, this.plugins.destroy(), this.auth?.destroy(), this.persistence?.close(), this.clear(), e.instance === this && (e.instance = null);
|
|
5332
5687
|
}
|
|
5333
5688
|
};
|
|
5334
|
-
function
|
|
5335
|
-
return
|
|
5689
|
+
function Qt() {
|
|
5690
|
+
return Zt.getInstance();
|
|
5336
5691
|
}
|
|
5337
|
-
function
|
|
5338
|
-
return
|
|
5692
|
+
function $t(e) {
|
|
5693
|
+
return Qt().defineType(e);
|
|
5339
5694
|
}
|
|
5340
|
-
function
|
|
5341
|
-
return
|
|
5695
|
+
function en(e, t) {
|
|
5696
|
+
return Qt().defineEndpoint(e, t);
|
|
5697
|
+
}
|
|
5698
|
+
// src/utils/fuzzy.ts
|
|
5699
|
+
var tn = (e) => e.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase(), nn = (e, t) => t === 0 || /[\s\-_/.:,()]/.test(e[t - 1]) || /[a-z]/.test(e[t - 1]) && /[A-Z]/.test(e[t]);
|
|
5700
|
+
function rn(e, t) {
|
|
5701
|
+
let n = tn(e.trim());
|
|
5702
|
+
if (!n) return {
|
|
5703
|
+
score: 0,
|
|
5704
|
+
indices: []
|
|
5705
|
+
};
|
|
5706
|
+
let r = tn(t), i = r.indexOf(n);
|
|
5707
|
+
if (i !== -1) {
|
|
5708
|
+
let e = Array.from({ length: n.length }, (e, t) => i + t);
|
|
5709
|
+
return {
|
|
5710
|
+
score: 100 + n.length * 10 - i + (nn(t, i) ? 30 : 0) - r.length * .1,
|
|
5711
|
+
indices: e
|
|
5712
|
+
};
|
|
5713
|
+
}
|
|
5714
|
+
let a = [], o = 0, s = 0, c = 0;
|
|
5715
|
+
for (let e of n) {
|
|
5716
|
+
if (e === " ") continue;
|
|
5717
|
+
let n = -1;
|
|
5718
|
+
for (let i = r.indexOf(e, s); i !== -1; i = r.indexOf(e, i + 1)) {
|
|
5719
|
+
if (n === -1 && (n = i), nn(t, i)) {
|
|
5720
|
+
n = i;
|
|
5721
|
+
break;
|
|
5722
|
+
}
|
|
5723
|
+
if (i === s) break;
|
|
5724
|
+
}
|
|
5725
|
+
if (n === -1) return null;
|
|
5726
|
+
c = a.length && n === a[a.length - 1] + 1 ? c + 1 : 0, o += 10 + c * 8 + (nn(t, n) ? 15 : 0) - Math.min(n - s, 10), a.push(n), s = n + 1;
|
|
5727
|
+
}
|
|
5728
|
+
return {
|
|
5729
|
+
score: o - r.length * .1,
|
|
5730
|
+
indices: a
|
|
5731
|
+
};
|
|
5732
|
+
}
|
|
5733
|
+
function an(e, t, n) {
|
|
5734
|
+
let r = [];
|
|
5735
|
+
for (let i of t) {
|
|
5736
|
+
let t = [n(i)].flat(), a = null;
|
|
5737
|
+
t.forEach((t, n) => {
|
|
5738
|
+
let r = rn(e, t);
|
|
5739
|
+
r && (!a || r.score - n * 20 > a.match.score - a.field * 20) && (a = {
|
|
5740
|
+
match: r,
|
|
5741
|
+
field: n
|
|
5742
|
+
});
|
|
5743
|
+
}), a && r.push({
|
|
5744
|
+
item: i,
|
|
5745
|
+
...a
|
|
5746
|
+
});
|
|
5747
|
+
}
|
|
5748
|
+
return r.sort((e, t) => t.match.score - t.field * 20 - (e.match.score - e.field * 20));
|
|
5342
5749
|
}
|
|
5343
|
-
export {
|
|
5750
|
+
export { je as $, it as A, Xe as B, J as C, s as Ct, dt as D, gt as E, i as Et, ot as F, R as G, et as H, ct as I, P as J, I as K, rt as L, lt as M, G as N, ft as O, ut as P, j as Q, W as R, St as S, l as St, vt as T, r as Tt, V as U, $e as V, L as W, Ne as X, Ie as Y, k as Z, It as _, v as _t, $t as a, Te as at, wt as b, f as bt, Yt as c, xe as ct, Z as d, D as dt, ke as et, Vt as f, me as ft, Lt as g, C as gt, Rt as h, le as ht, en as i, we as it, st as j, pt as k, Gt as l, O as lt, zt as m, ue as mt, rn as n, De as nt, Qt as o, Se as ot, Bt as p, fe as pt, F as q, Zt as r, Ee as rt, Jt as s, be as st, an as t, Oe as tt, Wt as u, _e as ut, Ft as v, _ as vt, yt as w, a as wt, Ct as x, u as xt, Tt as y, m as yt, U as z };
|
|
5344
5751
|
|
|
5345
|
-
//# sourceMappingURL=
|
|
5752
|
+
//# sourceMappingURL=fuzzy-Dnlbxdby.js.map
|