arethesis 0.0.0-stage → 0.1.1
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 +48 -0
- package/LICENSE +21 -0
- package/README.md +122 -2
- package/dist/arethesis-DTJOJ7F-.js +5179 -0
- package/dist/arethesis-DTJOJ7F-.js.map +1 -0
- package/dist/arethesis.js +147 -0
- package/dist/arethesis.js.map +1 -0
- package/dist/binding/data-binder.d.ts +82 -0
- package/dist/binding/data-binder.d.ts.map +1 -0
- package/dist/binding/types.d.ts +119 -0
- package/dist/binding/types.d.ts.map +1 -0
- package/dist/binding/validation-engine.d.ts +22 -0
- package/dist/binding/validation-engine.d.ts.map +1 -0
- package/dist/components/component.d.ts +93 -0
- package/dist/components/component.d.ts.map +1 -0
- package/dist/components/decorators.d.ts +9 -0
- package/dist/components/decorators.d.ts.map +1 -0
- package/dist/components/runtime.d.ts +17 -0
- package/dist/components/runtime.d.ts.map +1 -0
- package/dist/components/template-loader.d.ts +37 -0
- package/dist/components/template-loader.d.ts.map +1 -0
- package/dist/components/types.d.ts +22 -0
- package/dist/components/types.d.ts.map +1 -0
- package/dist/components.js +609 -0
- package/dist/components.js.map +1 -0
- package/dist/core/arethesis.d.ts +97 -0
- package/dist/core/arethesis.d.ts.map +1 -0
- package/dist/core/types.d.ts +40 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/data/list-view-registry.d.ts +69 -0
- package/dist/data/list-view-registry.d.ts.map +1 -0
- package/dist/data/object-store.d.ts +88 -0
- package/dist/data/object-store.d.ts.map +1 -0
- package/dist/data/optimistic-updates.d.ts +59 -0
- package/dist/data/optimistic-updates.d.ts.map +1 -0
- package/dist/data/persistence-manager.d.ts +56 -0
- package/dist/data/persistence-manager.d.ts.map +1 -0
- package/dist/data/types.d.ts +145 -0
- package/dist/data/types.d.ts.map +1 -0
- package/dist/http/auth-manager.d.ts +60 -0
- package/dist/http/auth-manager.d.ts.map +1 -0
- package/dist/http/http-client.d.ts +77 -0
- package/dist/http/http-client.d.ts.map +1 -0
- package/dist/http/http-error.d.ts +35 -0
- package/dist/http/http-error.d.ts.map +1 -0
- package/dist/http/mapping.d.ts +21 -0
- package/dist/http/mapping.d.ts.map +1 -0
- package/dist/http/types.d.ts +237 -0
- package/dist/http/types.d.ts.map +1 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/kit/data-table.d.ts +57 -0
- package/dist/kit/data-table.d.ts.map +1 -0
- package/dist/kit/flex-view.d.ts +42 -0
- package/dist/kit/flex-view.d.ts.map +1 -0
- package/dist/kit/form.d.ts +13 -0
- package/dist/kit/form.d.ts.map +1 -0
- package/dist/kit/index.d.ts +24 -0
- package/dist/kit/index.d.ts.map +1 -0
- package/dist/kit/list.d.ts +10 -0
- package/dist/kit/list.d.ts.map +1 -0
- package/dist/kit/theme-boot.generated.d.ts +3 -0
- package/dist/kit/theme-boot.generated.d.ts.map +1 -0
- package/dist/kit/theme.d.ts +34 -0
- package/dist/kit/theme.d.ts.map +1 -0
- package/dist/mixins/context-menu.d.ts +3 -0
- package/dist/mixins/context-menu.d.ts.map +1 -0
- package/dist/mixins/draggable.d.ts +3 -0
- package/dist/mixins/draggable.d.ts.map +1 -0
- package/dist/mixins/dropdown.d.ts +3 -0
- package/dist/mixins/dropdown.d.ts.map +1 -0
- package/dist/mixins/editable.d.ts +3 -0
- package/dist/mixins/editable.d.ts.map +1 -0
- package/dist/mixins/grid-navigation.d.ts +3 -0
- package/dist/mixins/grid-navigation.d.ts.map +1 -0
- package/dist/mixins/index.d.ts +19 -0
- package/dist/mixins/index.d.ts.map +1 -0
- package/dist/mixins/infinite-scroll.d.ts +3 -0
- package/dist/mixins/infinite-scroll.d.ts.map +1 -0
- package/dist/mixins/registry.d.ts +41 -0
- package/dist/mixins/registry.d.ts.map +1 -0
- package/dist/mixins/resizable.d.ts +3 -0
- package/dist/mixins/resizable.d.ts.map +1 -0
- package/dist/mixins/sortable.d.ts +3 -0
- package/dist/mixins/sortable.d.ts.map +1 -0
- package/dist/mixins/tooltip.d.ts +3 -0
- package/dist/mixins/tooltip.d.ts.map +1 -0
- package/dist/mixins/types.d.ts +165 -0
- package/dist/mixins/types.d.ts.map +1 -0
- package/dist/mixins/utils.d.ts +22 -0
- package/dist/mixins/utils.d.ts.map +1 -0
- package/dist/plugins/async-validators.d.ts +9 -0
- package/dist/plugins/async-validators.d.ts.map +1 -0
- package/dist/plugins/builtins.d.ts +9 -0
- package/dist/plugins/builtins.d.ts.map +1 -0
- package/dist/plugins/date-utils.d.ts +16 -0
- package/dist/plugins/date-utils.d.ts.map +1 -0
- package/dist/plugins/plugin-manager.d.ts +29 -0
- package/dist/plugins/plugin-manager.d.ts.map +1 -0
- package/dist/plugins/rich-text.d.ts +15 -0
- package/dist/plugins/rich-text.d.ts.map +1 -0
- package/dist/plugins/types.d.ts +50 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/realtime/azure-pubsub-manager.d.ts +49 -0
- package/dist/realtime/azure-pubsub-manager.d.ts.map +1 -0
- package/dist/realtime/collab/collab-session.d.ts +75 -0
- package/dist/realtime/collab/collab-session.d.ts.map +1 -0
- package/dist/realtime/collab/cursor-overlay.d.ts +20 -0
- package/dist/realtime/collab/cursor-overlay.d.ts.map +1 -0
- package/dist/realtime/collab/textarea-adapter.d.ts +27 -0
- package/dist/realtime/collab/textarea-adapter.d.ts.map +1 -0
- package/dist/realtime/ot/client.d.ts +27 -0
- package/dist/realtime/ot/client.d.ts.map +1 -0
- package/dist/realtime/ot/server.d.ts +36 -0
- package/dist/realtime/ot/server.d.ts.map +1 -0
- package/dist/realtime/ot/text-operation.d.ts +55 -0
- package/dist/realtime/ot/text-operation.d.ts.map +1 -0
- package/dist/realtime/reconnect.d.ts +22 -0
- package/dist/realtime/reconnect.d.ts.map +1 -0
- package/dist/realtime/sse-manager.d.ts +37 -0
- package/dist/realtime/sse-manager.d.ts.map +1 -0
- package/dist/realtime/types.d.ts +122 -0
- package/dist/realtime/types.d.ts.map +1 -0
- package/dist/realtime/websocket-manager.d.ts +34 -0
- package/dist/realtime/websocket-manager.d.ts.map +1 -0
- package/dist/theme-boot.js +17 -0
- package/dist/theme.css +680 -0
- package/dist/tokens/arethesis.resolver.json +57 -0
- package/dist/tokens/base.tokens.json +55 -0
- package/dist/tokens/dark-high-contrast.tokens.json +172 -0
- package/dist/tokens/dark.tokens.json +331 -0
- package/dist/tokens/light-high-contrast.tokens.json +115 -0
- package/dist/tokens/light.tokens.json +331 -0
- package/dist/utils/backoff.d.ts +18 -0
- package/dist/utils/backoff.d.ts.map +1 -0
- package/dist/utils/dates.d.ts +22 -0
- package/dist/utils/dates.d.ts.map +1 -0
- package/dist/utils/dom.d.ts +16 -0
- package/dist/utils/dom.d.ts.map +1 -0
- package/dist/utils/emitter.d.ts +17 -0
- package/dist/utils/emitter.d.ts.map +1 -0
- package/dist/utils/path.d.ts +33 -0
- package/dist/utils/path.d.ts.map +1 -0
- package/dist/utils/sanitize.d.ts +20 -0
- package/dist/utils/sanitize.d.ts.map +1 -0
- package/dist/utils/url.d.ts +16 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/package.json +102 -4
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
import { B as e, F as t, S as n, i as r, k as i, st as a, w as o } from "./arethesis-DTJOJ7F-.js";
|
|
2
|
+
// src/kit/data-table.ts
|
|
3
|
+
var s = "\n<template id=\"main\">\n <div class=\"ar-table\">\n <div class=\"ar-table__scroll\" tabindex=\"-1\">\n <table role=\"grid\" aria-rowcount=\"-1\">\n <caption class=\"ar-visually-hidden\"></caption>\n <thead><tr></tr></thead>\n <tbody data-items></tbody>\n </table>\n </div>\n <div class=\"ar-table__status\" role=\"status\" aria-live=\"polite\"></div>\n </div>\n</template>\n<template id=\"empty\"><tr class=\"ar-table__empty\"><td colspan=\"999\"></td></tr></template>\n<template id=\"loading\"><tr class=\"ar-table__loading\" aria-hidden=\"true\"><td colspan=\"999\"><div class=\"ar-skeleton\"></div><div class=\"ar-skeleton\"></div><div class=\"ar-skeleton\"></div></td></tr></template>\n<template id=\"error\"><tr class=\"ar-table__error\"><td colspan=\"999\"><span data-error-message></span> <button type=\"button\" class=\"ar-button\" data-retry>Retry</button></td></tr></template>\n", c = class extends n {
|
|
4
|
+
#e = null;
|
|
5
|
+
#t = null;
|
|
6
|
+
#n = [];
|
|
7
|
+
#r = null;
|
|
8
|
+
configure(e) {
|
|
9
|
+
this.#e = e;
|
|
10
|
+
let { listViews: n } = t();
|
|
11
|
+
this.#t = "ids" in e.list ? e.list : n.getOrCreate(e.list), this.ready.then(() => this.#i());
|
|
12
|
+
}
|
|
13
|
+
get view() {
|
|
14
|
+
return this.#t;
|
|
15
|
+
}
|
|
16
|
+
get selected() {
|
|
17
|
+
return this.#r;
|
|
18
|
+
}
|
|
19
|
+
setFilters(e) {
|
|
20
|
+
return this.#t ? t().listViews.update(this.#t.id, { filters: e }) : Promise.resolve();
|
|
21
|
+
}
|
|
22
|
+
setSort(e) {
|
|
23
|
+
if (!this.#t) return Promise.resolve();
|
|
24
|
+
let n = t().listViews.update(this.#t.id, { sort: e });
|
|
25
|
+
return this.#a(), n;
|
|
26
|
+
}
|
|
27
|
+
#i() {
|
|
28
|
+
let t = this.#e;
|
|
29
|
+
for (let e of this.#n.splice(0)) e.destroy();
|
|
30
|
+
let n = this.querySelector("table"), r = this.querySelector("caption");
|
|
31
|
+
r.textContent = t.caption ?? "", n.setAttribute("aria-label", t.caption ?? "Data table"), this.#a();
|
|
32
|
+
let a = {};
|
|
33
|
+
for (let n of t.columns) a[n.field] = {
|
|
34
|
+
...n.bind,
|
|
35
|
+
displayType: n.displayType ?? n.bind?.displayType,
|
|
36
|
+
selector: `[data-col="${e(n.field)}"]`
|
|
37
|
+
};
|
|
38
|
+
let o = {
|
|
39
|
+
fields: a,
|
|
40
|
+
itemTemplate: "item",
|
|
41
|
+
emptyTemplate: "empty",
|
|
42
|
+
loadingTemplate: "loading",
|
|
43
|
+
errorTemplate: "error",
|
|
44
|
+
infiniteScroll: {
|
|
45
|
+
threshold: t.threshold ?? 400,
|
|
46
|
+
root: "self"
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
this.bind(this.#t, o);
|
|
50
|
+
let s = i.apply(n, "grid-navigation", {
|
|
51
|
+
cellSelector: "td[data-col], th[data-col]",
|
|
52
|
+
rowSelector: "tr"
|
|
53
|
+
});
|
|
54
|
+
s && this.#n.push(s), this.listen(n, "grid:edit", (e) => {
|
|
55
|
+
let { cell: t, key: n } = e.detail;
|
|
56
|
+
this.#s(t, n);
|
|
57
|
+
}), this.listen(n, "click", (e) => {
|
|
58
|
+
let t = e.target.closest("tbody tr[data-id]");
|
|
59
|
+
t && this.#o(t.getAttribute("data-id"));
|
|
60
|
+
}), this.listen(n, "keydown", (e) => {
|
|
61
|
+
let t = e;
|
|
62
|
+
if (t.key === " " && t.target.closest("tbody td")) {
|
|
63
|
+
let e = t.target.closest("tr[data-id]");
|
|
64
|
+
e && (t.preventDefault(), this.#o(e.getAttribute("data-id")));
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
#a() {
|
|
69
|
+
let e = this.#e, t = this.querySelector("thead tr");
|
|
70
|
+
if (!e || !t) return;
|
|
71
|
+
let n = this.#t?.sort[0];
|
|
72
|
+
t.replaceChildren(...e.columns.map((e, t) => {
|
|
73
|
+
let r = document.createElement("th");
|
|
74
|
+
if (r.scope = "col", r.dataset.col = e.field, r.setAttribute("aria-colindex", String(t + 1)), e.width && (r.style.width = e.width), e.align && (r.dataset.align = e.align), e.sortable) {
|
|
75
|
+
let t = n?.field === e.field;
|
|
76
|
+
r.setAttribute("aria-sort", t ? n.direction === "asc" ? "ascending" : "descending" : "none");
|
|
77
|
+
let i = document.createElement("button");
|
|
78
|
+
i.type = "button", i.className = "ar-table__sort", i.textContent = e.label;
|
|
79
|
+
let a = document.createElement("span");
|
|
80
|
+
a.setAttribute("aria-hidden", "true"), a.className = "ar-table__sort-icon", a.textContent = t ? n.direction === "asc" ? "▲" : "▼" : "↕", i.appendChild(a), i.addEventListener("click", () => {
|
|
81
|
+
let r = t && n.direction === "asc" ? "desc" : "asc";
|
|
82
|
+
this.setSort([{
|
|
83
|
+
field: e.field,
|
|
84
|
+
direction: r
|
|
85
|
+
}]);
|
|
86
|
+
}), r.appendChild(i);
|
|
87
|
+
} else r.textContent = e.label;
|
|
88
|
+
let a = i.apply(r, "resizable", {
|
|
89
|
+
handles: ["e"],
|
|
90
|
+
minWidth: 60
|
|
91
|
+
});
|
|
92
|
+
return a && this.#n.push(a), r;
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
async loadTemplate(e) {
|
|
96
|
+
if (e === "item" && this.#e) {
|
|
97
|
+
let e = document.createElement("tr");
|
|
98
|
+
for (let [t, n] of this.#e.columns.entries()) {
|
|
99
|
+
let r = document.createElement("td");
|
|
100
|
+
r.dataset.col = n.field, r.setAttribute("aria-colindex", String(t + 1)), n.align && (r.dataset.align = n.align), n.editable && r.setAttribute("aria-readonly", "false"), e.appendChild(r);
|
|
101
|
+
}
|
|
102
|
+
let t = document.createDocumentFragment();
|
|
103
|
+
return t.appendChild(e), t;
|
|
104
|
+
}
|
|
105
|
+
let t = await super.loadTemplate(e);
|
|
106
|
+
if (t && e === "empty") {
|
|
107
|
+
let e = t.querySelector("td");
|
|
108
|
+
e && (e.textContent = this.#e?.emptyText ?? "No results");
|
|
109
|
+
}
|
|
110
|
+
return t;
|
|
111
|
+
}
|
|
112
|
+
onItemRender(e, t) {
|
|
113
|
+
e.setAttribute("aria-selected", String(t.id === this.#r));
|
|
114
|
+
}
|
|
115
|
+
onListChange(e) {
|
|
116
|
+
let t = this.querySelector(".ar-table__status"), n = this.querySelector("table");
|
|
117
|
+
if (n && n.setAttribute("aria-rowcount", String(e.totalCount ?? -1)), i.get(n, "grid-navigation")?.refresh?.(), !t) return;
|
|
118
|
+
let r = e.ids.length;
|
|
119
|
+
t.textContent = e.status === "loading" ? "Loading…" : e.status === "loading-more" ? `Showing ${r}${e.totalCount === void 0 ? "" : ` of ${e.totalCount}`}, loading more…` : e.status === "error" ? "Could not load data." : `Showing ${r}${e.totalCount === void 0 ? "" : ` of ${e.totalCount}`}`;
|
|
120
|
+
}
|
|
121
|
+
#o(e) {
|
|
122
|
+
this.#r = e, this.querySelectorAll("tbody tr[data-id]").forEach((t) => t.setAttribute("aria-selected", String(t.getAttribute("data-id") === e))), this.emit("row-select", { id: e });
|
|
123
|
+
}
|
|
124
|
+
#s(e, n) {
|
|
125
|
+
let r = this.#e, a = e.dataset.col, o = e.closest("tr")?.getAttribute("data-id"), s = r?.columns.find((e) => e.field === a);
|
|
126
|
+
if (!r || !a || !o || !s?.editable || e.classList.contains("is-editing")) return;
|
|
127
|
+
let c = typeof s.editable == "object" ? s.editable : {}, { store: l } = t(), u = this.#t.type, d = l.getData(u, o)?.[a];
|
|
128
|
+
e.textContent = d == null ? "" : String(d);
|
|
129
|
+
let f = i.apply(e, "editable", {
|
|
130
|
+
type: c.type ?? (s.displayType === "number" || s.displayType === "currency" ? "number" : s.displayType === "date" ? "date" : "text"),
|
|
131
|
+
choices: c.choices,
|
|
132
|
+
label: `Edit ${s.label}`,
|
|
133
|
+
validate: c.validation ? async (e) => {
|
|
134
|
+
let n = await t().binder.validationEngine.validateField(a, e, c.validation, { ...l.getData(u, o) });
|
|
135
|
+
return !n || n.message;
|
|
136
|
+
} : void 0
|
|
137
|
+
});
|
|
138
|
+
if (!f) return;
|
|
139
|
+
let p = () => {
|
|
140
|
+
i.remove(e, "editable");
|
|
141
|
+
let n = l.getData(u, o);
|
|
142
|
+
t().binder.applyValue(e, n?.[a], {
|
|
143
|
+
...s.bind,
|
|
144
|
+
displayType: s.displayType ?? s.bind?.displayType
|
|
145
|
+
}, n), e.focus();
|
|
146
|
+
};
|
|
147
|
+
e.addEventListener("editable:save", (e) => {
|
|
148
|
+
e.preventDefault();
|
|
149
|
+
let t = e.detail, n = c.type === "number" || s.displayType === "number" || s.displayType === "currency" ? Number(t.value) : t.value;
|
|
150
|
+
this.#c(u, o, { [a]: n }).finally(p);
|
|
151
|
+
}, { once: !0 }), e.addEventListener("editable:cancel", p, { once: !0 }), f.start();
|
|
152
|
+
let m = e.querySelector("input");
|
|
153
|
+
m && n && n.length === 1 && (m.value = n);
|
|
154
|
+
}
|
|
155
|
+
async #c(e, t, n) {
|
|
156
|
+
let i = this.#e?.save, a = r(), o = async () => {
|
|
157
|
+
if (!i) return;
|
|
158
|
+
if (typeof i == "function") return await i(t, n);
|
|
159
|
+
let e = a.http.getEndpoint(i.endpoint);
|
|
160
|
+
if (!e) throw Error(`Unknown endpoint "${i.endpoint}"`);
|
|
161
|
+
return a.http.request({
|
|
162
|
+
url: e.url,
|
|
163
|
+
method: i.method ?? e.method ?? "PATCH",
|
|
164
|
+
params: { id: t },
|
|
165
|
+
body: n
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
try {
|
|
169
|
+
await a.optimistic.update(e, t, n, o), this.emit("save", {
|
|
170
|
+
id: t,
|
|
171
|
+
changes: n
|
|
172
|
+
});
|
|
173
|
+
} catch (e) {
|
|
174
|
+
this.emit("save-error", {
|
|
175
|
+
id: t,
|
|
176
|
+
changes: n,
|
|
177
|
+
error: e
|
|
178
|
+
});
|
|
179
|
+
let r = this.itemElement(t);
|
|
180
|
+
r?.classList.add("is-error"), setTimeout(() => r?.classList.remove("is-error"), 1500);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
onDisconnected() {
|
|
184
|
+
for (let e of this.#n.splice(0)) e.destroy();
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
o({
|
|
188
|
+
tag: "a-data-table",
|
|
189
|
+
html: s
|
|
190
|
+
})(c);
|
|
191
|
+
// src/kit/flex-view.ts
|
|
192
|
+
var l = "ArLayout", u = 16;
|
|
193
|
+
function d(e, t, n) {
|
|
194
|
+
return e.endsWith("px") ? parseFloat(e) : e.endsWith("%") ? parseFloat(e) / 100 * t : n;
|
|
195
|
+
}
|
|
196
|
+
var f = class extends n {
|
|
197
|
+
#e = null;
|
|
198
|
+
#t = [];
|
|
199
|
+
#n = null;
|
|
200
|
+
#r = null;
|
|
201
|
+
configure(e) {
|
|
202
|
+
this.#e = e, this.ready.then(() => this.#p());
|
|
203
|
+
}
|
|
204
|
+
resetLayout() {
|
|
205
|
+
this.#e?.id && t().store.delete(l, this.#e.id), this.#p();
|
|
206
|
+
}
|
|
207
|
+
#i() {
|
|
208
|
+
return this.#e?.id ? t().store.getData(l, this.#e.id) : void 0;
|
|
209
|
+
}
|
|
210
|
+
#a() {
|
|
211
|
+
let e = this.querySelector(".ar-flex");
|
|
212
|
+
return e ? Array.from(e.querySelectorAll(":scope > .ar-flex__panel")) : [];
|
|
213
|
+
}
|
|
214
|
+
#o() {
|
|
215
|
+
if (!this.#e?.id) return;
|
|
216
|
+
let e = this.#a(), n = {};
|
|
217
|
+
for (let t of e) {
|
|
218
|
+
let e = t.dataset.grow ? parseFloat(t.dataset.grow) : void 0, r = parseFloat(t.style.height) || void 0;
|
|
219
|
+
(e !== void 0 || r !== void 0) && (n[t.dataset.key] = {
|
|
220
|
+
grow: e,
|
|
221
|
+
height: r
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
t().store.upsert(l, this.#e.id, {
|
|
225
|
+
order: e.map((e) => e.dataset.key),
|
|
226
|
+
sizes: n
|
|
227
|
+
}, {
|
|
228
|
+
merge: "replace",
|
|
229
|
+
source: "local"
|
|
230
|
+
}), this.emit("layout-change", { order: e.map((e) => e.dataset.key) });
|
|
231
|
+
}
|
|
232
|
+
#s(e, t) {
|
|
233
|
+
let n = String(Math.round(t * 1e3) / 1e3);
|
|
234
|
+
e.style.flexGrow = n, e.dataset.grow = n;
|
|
235
|
+
}
|
|
236
|
+
#c() {
|
|
237
|
+
let e = (this.#e?.direction ?? "row") === "row", t = this.#a();
|
|
238
|
+
t.forEach((n, r) => {
|
|
239
|
+
let i = n.querySelector(":scope > .ar-flex__splitter");
|
|
240
|
+
if (!i) return;
|
|
241
|
+
let a = t[r + 1], o = !1;
|
|
242
|
+
if (e && a && a.querySelector(":scope > .ar-flex__splitter")) {
|
|
243
|
+
let e = n.getBoundingClientRect(), t = a.getBoundingClientRect();
|
|
244
|
+
o = Math.abs(e.top - t.top) < 1 && t.left > e.left;
|
|
245
|
+
}
|
|
246
|
+
let s = o && (parseFloat(getComputedStyle(n).flexGrow) || 0) + (parseFloat(getComputedStyle(a).flexGrow) || 0) > 0;
|
|
247
|
+
if (i.hidden = !s, !s) return;
|
|
248
|
+
let c = (e) => e.getAttribute("aria-label") ?? e.dataset.key;
|
|
249
|
+
i.setAttribute("aria-label", `Resize ${c(n)} and ${c(a)}`), i.setAttribute("aria-controls", `${n.id} ${a.id}`), this.#l(i, n, a);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
#l(e, t, n) {
|
|
253
|
+
let r = this.#u(t, n);
|
|
254
|
+
r.total <= 0 || (e.setAttribute("aria-valuemin", String(Math.round(100 * r.minA / r.total))), e.setAttribute("aria-valuemax", String(Math.round(100 * r.maxA / r.total))), e.setAttribute("aria-valuenow", String(Math.round(100 * r.widthA / r.total))));
|
|
255
|
+
}
|
|
256
|
+
#u(e, t) {
|
|
257
|
+
let n = this.querySelector(".ar-flex").getBoundingClientRect().width, r = (e) => {
|
|
258
|
+
let t = getComputedStyle(e);
|
|
259
|
+
return {
|
|
260
|
+
width: e.getBoundingClientRect().width,
|
|
261
|
+
grow: parseFloat(t.flexGrow) || 0,
|
|
262
|
+
basis: d(t.flexBasis, n, 0),
|
|
263
|
+
min: d(t.minWidth, n, 0),
|
|
264
|
+
max: d(t.maxWidth, n, Infinity)
|
|
265
|
+
};
|
|
266
|
+
}, i = r(e), a = r(t), o = i.width + a.width, s = Math.max(i.min, i.basis), c = Math.max(a.min, a.basis), l = Math.max(s, o - Math.min(a.max, o)), u = Math.min(i.max, o - c);
|
|
267
|
+
return {
|
|
268
|
+
total: o,
|
|
269
|
+
widthA: i.width,
|
|
270
|
+
minA: l,
|
|
271
|
+
maxA: Math.max(l, u),
|
|
272
|
+
a: i,
|
|
273
|
+
b: a
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
#d(e, t, n, r) {
|
|
277
|
+
let i = Math.max(n.minA, Math.min(n.maxA, r)), a = n.a.grow + n.b.grow, o = n.total - n.a.basis - n.b.basis;
|
|
278
|
+
if (a <= 0 || o <= 0) return;
|
|
279
|
+
let s = a * (i - n.a.basis) / o;
|
|
280
|
+
this.#s(e, Math.max(0, s)), this.#s(t, Math.max(0, a - s));
|
|
281
|
+
}
|
|
282
|
+
#f(e, t) {
|
|
283
|
+
let n = document.createElement("div");
|
|
284
|
+
n.className = "ar-flex__splitter", n.tabIndex = 0, n.hidden = !0, n.setAttribute("role", "separator"), n.setAttribute("aria-orientation", "vertical"), e.appendChild(n);
|
|
285
|
+
let r = () => {
|
|
286
|
+
let t = this.#a();
|
|
287
|
+
return t[t.indexOf(e) + 1] ?? null;
|
|
288
|
+
}, i = () => {
|
|
289
|
+
this.#o();
|
|
290
|
+
let t = r();
|
|
291
|
+
t && this.#l(n, e, t), this.emit("panel-resize", {
|
|
292
|
+
key: e.dataset.key,
|
|
293
|
+
neighbour: t?.dataset.key
|
|
294
|
+
});
|
|
295
|
+
}, a = null;
|
|
296
|
+
n.addEventListener("pointerdown", (t) => {
|
|
297
|
+
let i = r();
|
|
298
|
+
t.button === 0 && i && !n.hidden && (t.preventDefault(), t.stopPropagation(), a = {
|
|
299
|
+
x: t.clientX,
|
|
300
|
+
pointerId: t.pointerId,
|
|
301
|
+
next: i,
|
|
302
|
+
pair: this.#u(e, i)
|
|
303
|
+
}, n.setPointerCapture?.(t.pointerId), n.classList.add("is-active"), this.classList.add("is-resizing"));
|
|
304
|
+
}, { signal: t }), n.addEventListener("pointermove", (t) => {
|
|
305
|
+
a && t.pointerId === a.pointerId && (this.#d(e, a.next, a.pair, a.pair.widthA + (t.clientX - a.x)), this.#l(n, e, a.next));
|
|
306
|
+
}, { signal: t });
|
|
307
|
+
let o = (e) => {
|
|
308
|
+
a && e.pointerId === a.pointerId && (a = null, n.classList.remove("is-active"), this.classList.remove("is-resizing"), i());
|
|
309
|
+
};
|
|
310
|
+
n.addEventListener("pointerup", o, { signal: t }), n.addEventListener("pointercancel", o, { signal: t }), n.addEventListener("keydown", (t) => {
|
|
311
|
+
let n = r();
|
|
312
|
+
if (!n) return;
|
|
313
|
+
let a = this.#u(e, n), o = t.shiftKey ? 64 : u, s = {
|
|
314
|
+
ArrowLeft: a.widthA - o,
|
|
315
|
+
ArrowRight: a.widthA + o,
|
|
316
|
+
Home: a.minA,
|
|
317
|
+
End: a.maxA
|
|
318
|
+
};
|
|
319
|
+
t.key in s && (t.preventDefault(), this.#d(e, n, a, s[t.key]), i());
|
|
320
|
+
}, { signal: t });
|
|
321
|
+
}
|
|
322
|
+
#p() {
|
|
323
|
+
let e = this.#e;
|
|
324
|
+
if (!e) return;
|
|
325
|
+
this.#m(), this.#n = new AbortController();
|
|
326
|
+
let { signal: t } = this.#n, n = this.querySelector(".ar-flex");
|
|
327
|
+
n || (n = document.createElement("div"), n.className = "ar-flex", this.replaceChildren(n)), n.replaceChildren(), Object.assign(n.style, {
|
|
328
|
+
display: "flex",
|
|
329
|
+
flexDirection: e.direction ?? "row",
|
|
330
|
+
flexWrap: e.wrap === !1 ? "nowrap" : "wrap",
|
|
331
|
+
gap: e.gap ?? "1rem"
|
|
332
|
+
}), n.style.setProperty("--ar-flex-gap", e.gap ?? "1rem"), n.setAttribute("aria-label", "Dashboard panels");
|
|
333
|
+
let r = this.#i(), a = [...e.children].sort((e, t) => {
|
|
334
|
+
let n = r?.order ?? [], i = n.indexOf(e.key), a = n.indexOf(t.key);
|
|
335
|
+
return (i === -1 ? Infinity : i) - (a === -1 ? Infinity : a);
|
|
336
|
+
});
|
|
337
|
+
for (let o of a) {
|
|
338
|
+
let a = document.createElement("section");
|
|
339
|
+
a.className = "ar-flex__panel", a.dataset.key = o.key, a.setAttribute("data-id", o.key), a.id = `${e.id ?? "flex"}-panel-${o.key}`.replace(/[^\w-]/g, "-"), Object.assign(a.style, {
|
|
340
|
+
flex: o.flex ?? "1",
|
|
341
|
+
minWidth: o.minWidth ?? "16rem",
|
|
342
|
+
maxWidth: o.maxWidth ?? "none"
|
|
343
|
+
});
|
|
344
|
+
let s = r?.sizes[o.key];
|
|
345
|
+
if (s?.grow !== void 0 && this.#s(a, s.grow), s?.height && (a.style.height = `${s.height}px`), o.title) {
|
|
346
|
+
let e = document.createElement("header");
|
|
347
|
+
e.className = "ar-flex__header";
|
|
348
|
+
let t = document.createElement("h2");
|
|
349
|
+
t.textContent = o.title, e.appendChild(t), a.appendChild(e), a.setAttribute("aria-label", o.title);
|
|
350
|
+
}
|
|
351
|
+
let c = document.createElement("div");
|
|
352
|
+
c.className = "ar-flex__body", o.scrollable && (c.tabIndex = 0, c.setAttribute("role", "region"), c.setAttribute("aria-label", o.title ?? o.key));
|
|
353
|
+
let l = document.createElement(o.component);
|
|
354
|
+
for (let [e, t] of Object.entries(o.attributes ?? {})) l.setAttribute(e, String(t));
|
|
355
|
+
if (c.appendChild(l), a.appendChild(c), n.appendChild(a), (o.binding || o.list) && customElements.whenDefined(o.component).then(() => {
|
|
356
|
+
let e = l;
|
|
357
|
+
typeof e.bind == "function" && (o.list ? e.bindList(o.list, o.bindConfig) : e.bind(o.binding, o.bindConfig));
|
|
358
|
+
}), o.resizable !== !1) {
|
|
359
|
+
this.#f(a, t);
|
|
360
|
+
let e = i.apply(a, "resizable", {
|
|
361
|
+
handles: ["s"],
|
|
362
|
+
minHeight: 120
|
|
363
|
+
});
|
|
364
|
+
e && this.#t.push(e), a.addEventListener("resizable:end", () => this.#o(), { signal: t });
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (e.reorderable !== !1) {
|
|
368
|
+
let e = i.apply(n, "sortable", {
|
|
369
|
+
items: ".ar-flex__panel",
|
|
370
|
+
handle: ".ar-flex__header",
|
|
371
|
+
direction: "horizontal"
|
|
372
|
+
});
|
|
373
|
+
e && this.#t.push(e), n.addEventListener("sortable:end", () => queueMicrotask(() => {
|
|
374
|
+
this.#o(), this.#c();
|
|
375
|
+
}), { signal: t });
|
|
376
|
+
}
|
|
377
|
+
this.#c(), typeof ResizeObserver < "u" && (this.#r = new ResizeObserver(() => this.#c()), this.#r.observe(n));
|
|
378
|
+
}
|
|
379
|
+
#m() {
|
|
380
|
+
for (let e of this.#t.splice(0)) e.destroy();
|
|
381
|
+
this.#n?.abort(), this.#n = null, this.#r?.disconnect(), this.#r = null;
|
|
382
|
+
}
|
|
383
|
+
onDisconnected() {
|
|
384
|
+
this.#m();
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
o({ tag: "a-flex-view" })(f);
|
|
388
|
+
// src/kit/list.ts
|
|
389
|
+
var p = class extends n {
|
|
390
|
+
#e = /* @__PURE__ */ new Map();
|
|
391
|
+
#t = null;
|
|
392
|
+
onConnected() {
|
|
393
|
+
this.#t || this.#n();
|
|
394
|
+
}
|
|
395
|
+
#n() {
|
|
396
|
+
for (let e of Array.from(this.querySelectorAll(":scope > template"))) {
|
|
397
|
+
let t = e.hasAttribute("data-empty") ? "empty" : e.hasAttribute("data-loading") ? "loading" : e.hasAttribute("data-error") ? "error" : "item";
|
|
398
|
+
this.#e.set(t, e.content.cloneNode(!0)), e.remove();
|
|
399
|
+
}
|
|
400
|
+
let e = this.getAttribute("data-tag") ?? (this.#e.get("item")?.firstElementChild?.tagName === "LI" ? "ul" : "div");
|
|
401
|
+
this.#t = document.createElement(e), this.#t.className = "ar-list", this.#t.setAttribute("data-items", ""), this.getAttribute("aria-label") && this.#t.setAttribute("aria-label", this.getAttribute("aria-label")), this.replaceChildren(this.#t);
|
|
402
|
+
}
|
|
403
|
+
async loadTemplate(e) {
|
|
404
|
+
if (e === "main") {
|
|
405
|
+
this.#t || this.#n();
|
|
406
|
+
let e = document.createDocumentFragment();
|
|
407
|
+
return e.appendChild(this.#t), e;
|
|
408
|
+
}
|
|
409
|
+
let t = this.#e.get(e);
|
|
410
|
+
return t ? t.cloneNode(!0) : null;
|
|
411
|
+
}
|
|
412
|
+
async hasTemplate(e) {
|
|
413
|
+
return e === "main" || this.#e.has(e);
|
|
414
|
+
}
|
|
415
|
+
get bindConfig() {
|
|
416
|
+
let e = {}, t = this.#e.get("item");
|
|
417
|
+
for (let [n, r] of Array.from(t?.querySelectorAll("[data-bind]") ?? []).entries()) r.setAttribute("data-ar-field", String(n)), e[`${r.getAttribute("data-bind")}#${n}`] = {
|
|
418
|
+
field: r.getAttribute("data-bind"),
|
|
419
|
+
selector: `[data-ar-field="${n}"]`,
|
|
420
|
+
displayType: r.getAttribute("data-display") ?? void 0,
|
|
421
|
+
format: r.getAttribute("data-format") ?? void 0,
|
|
422
|
+
attribute: r.getAttribute("data-attribute") ?? void 0
|
|
423
|
+
};
|
|
424
|
+
return {
|
|
425
|
+
fields: e,
|
|
426
|
+
itemTemplate: "item",
|
|
427
|
+
emptyTemplate: this.#e.has("empty") ? "empty" : void 0,
|
|
428
|
+
loadingTemplate: this.#e.has("loading") ? "loading" : void 0,
|
|
429
|
+
errorTemplate: this.#e.has("error") ? "error" : void 0,
|
|
430
|
+
infiniteScroll: this.hasAttribute("infinite") ? { threshold: Number(this.getAttribute("data-threshold")) || 300 } : !1
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
o({ tag: "a-list" })(p);
|
|
435
|
+
// src/kit/form.ts
|
|
436
|
+
var m = class extends n {
|
|
437
|
+
#e = null;
|
|
438
|
+
#t = null;
|
|
439
|
+
#n = !1;
|
|
440
|
+
onConnected() {
|
|
441
|
+
this.#t = this.querySelector("form"), this.#t ? (this.#t.noValidate = !0, this.#a(), this.listen(this.#t, "submit", (e) => {
|
|
442
|
+
e.preventDefault(), this.submit();
|
|
443
|
+
})) : console.error("<a-form> needs a <form> child");
|
|
444
|
+
}
|
|
445
|
+
values() {
|
|
446
|
+
return this.#e?.values() ?? {};
|
|
447
|
+
}
|
|
448
|
+
async validate() {
|
|
449
|
+
return (await this.#e?.validate())?.valid ?? !0;
|
|
450
|
+
}
|
|
451
|
+
#r() {
|
|
452
|
+
return Array.from(this.#t?.elements ?? []).filter((e) => (e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement) && !!e.name && e.type !== "submit" && e.type !== "button");
|
|
453
|
+
}
|
|
454
|
+
#i(e) {
|
|
455
|
+
let t = [];
|
|
456
|
+
e.required && t.push({ type: "required" }), e instanceof HTMLInputElement && (e.type === "email" && t.push({ type: "email" }), e.type === "url" && t.push({ type: "url" }), e.type === "tel" && t.push({ type: "phone" }), e.minLength > 0 && t.push({
|
|
457
|
+
type: "minLength",
|
|
458
|
+
params: { min: e.minLength }
|
|
459
|
+
}), e.maxLength > 0 && e.hasAttribute("maxlength") && t.push({
|
|
460
|
+
type: "maxLength",
|
|
461
|
+
params: { max: e.maxLength }
|
|
462
|
+
}), e.min !== "" && e.type !== "date" && t.push({
|
|
463
|
+
type: "min",
|
|
464
|
+
params: { min: Number(e.min) }
|
|
465
|
+
}), e.max !== "" && e.type !== "date" && t.push({
|
|
466
|
+
type: "max",
|
|
467
|
+
params: { max: Number(e.max) }
|
|
468
|
+
}), e.pattern && t.push({
|
|
469
|
+
type: "pattern",
|
|
470
|
+
params: { pattern: `^(?:${e.pattern})$` }
|
|
471
|
+
})), e instanceof HTMLTextAreaElement && e.minLength > 0 && t.push({
|
|
472
|
+
type: "minLength",
|
|
473
|
+
params: { min: e.minLength }
|
|
474
|
+
});
|
|
475
|
+
let n = e.getAttribute("data-rules");
|
|
476
|
+
if (n) try {
|
|
477
|
+
t.push(...JSON.parse(n));
|
|
478
|
+
} catch {
|
|
479
|
+
console.error(`<a-form>: invalid data-rules on "${e.name}"`);
|
|
480
|
+
}
|
|
481
|
+
return t;
|
|
482
|
+
}
|
|
483
|
+
#a() {
|
|
484
|
+
let e = {};
|
|
485
|
+
for (let t of this.#r()) {
|
|
486
|
+
if (t.name in e) continue;
|
|
487
|
+
let n = this.#i(t), r = t.labels?.[0]?.textContent?.trim().replace(/\s*\*$/, ""), i = n.length ? {
|
|
488
|
+
rules: n,
|
|
489
|
+
label: r
|
|
490
|
+
} : void 0;
|
|
491
|
+
e[t.name] = {
|
|
492
|
+
selector: `[name="${t.name}"]`,
|
|
493
|
+
inputType: t instanceof HTMLInputElement && t.type === "checkbox" ? "checkbox" : t.hasAttribute("data-rich-text") ? "rich-text" : void 0,
|
|
494
|
+
validation: i
|
|
495
|
+
}, t.required && t.setAttribute("aria-required", "true");
|
|
496
|
+
}
|
|
497
|
+
let n = {
|
|
498
|
+
fields: e,
|
|
499
|
+
showErrorSummary: "[data-error-summary]",
|
|
500
|
+
validateOn: ["blur", "change"]
|
|
501
|
+
}, r = this.getAttribute("data-source"), i = r?.includes(":") ? t().store.getData(r.slice(0, r.indexOf(":")), r.slice(r.indexOf(":") + 1)) ?? {} : Object.fromEntries(this.#r().map((e) => [e.name, e instanceof HTMLInputElement && e.type === "checkbox" ? e.checked : e.value]));
|
|
502
|
+
this.#e = t().binder.bind(this.#t, i, n);
|
|
503
|
+
}
|
|
504
|
+
async submit() {
|
|
505
|
+
if (this.#n || !this.#e || !this.#t) return;
|
|
506
|
+
let e = this.#t.querySelector("button:not([type=button]), [type=submit]");
|
|
507
|
+
this.#n = !0, this.#t.setAttribute("aria-busy", "true"), e?.setAttribute("aria-disabled", "true");
|
|
508
|
+
try {
|
|
509
|
+
if (!(await this.#e.validate()).valid) {
|
|
510
|
+
this.querySelector("[data-error-summary] a")?.focus();
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
let e = this.#e.values(), t = this.getAttribute("data-endpoint");
|
|
514
|
+
if (!t) {
|
|
515
|
+
this.emit("submit-valid", { data: e });
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
await this.#o(t, e);
|
|
519
|
+
} finally {
|
|
520
|
+
this.#n = !1, this.#t.removeAttribute("aria-busy"), e?.removeAttribute("aria-disabled");
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
async #o(e, t) {
|
|
524
|
+
let n = r(), i = n.http.getEndpoint(e);
|
|
525
|
+
if (!i) throw Error(`<a-form>: unknown endpoint "${e}"`);
|
|
526
|
+
let o = this.getAttribute("data-source"), s = o?.slice(o.indexOf(":") + 1);
|
|
527
|
+
try {
|
|
528
|
+
let e = await n.http.request({
|
|
529
|
+
url: i.url,
|
|
530
|
+
method: i.method ?? (s ? "PATCH" : "POST"),
|
|
531
|
+
params: s ? { id: s } : {},
|
|
532
|
+
body: t,
|
|
533
|
+
retry: i.retry
|
|
534
|
+
}), r = e === void 0 ? void 0 : n.http.ingest({
|
|
535
|
+
...i,
|
|
536
|
+
type: i.type ?? this.getAttribute("data-type") ?? void 0,
|
|
537
|
+
list: !1
|
|
538
|
+
}, e).data;
|
|
539
|
+
this.emit("submit-success", {
|
|
540
|
+
data: t,
|
|
541
|
+
result: r
|
|
542
|
+
}), this.hasAttribute("data-reset") && (this.#t.reset(), this.#a());
|
|
543
|
+
} catch (e) {
|
|
544
|
+
e instanceof a && (e.status === 422 || e.status === 400) && this.#s(e.body), this.emit("submit-error", { error: e });
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
#s(e) {
|
|
548
|
+
let n = e?.errors;
|
|
549
|
+
if (!n || typeof n != "object") return;
|
|
550
|
+
let { binder: r } = t();
|
|
551
|
+
for (let [e, t] of Object.entries(n)) {
|
|
552
|
+
let n = this.#t.querySelector(`[name="${e}"]`);
|
|
553
|
+
n && r.showFieldError(n, {
|
|
554
|
+
field: e,
|
|
555
|
+
rule: "server",
|
|
556
|
+
message: Array.isArray(t) ? t.join(" ") : t
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
this.#t.querySelector("[aria-invalid=\"true\"]")?.focus();
|
|
560
|
+
}
|
|
561
|
+
onDisconnected() {
|
|
562
|
+
this.#t && t().binder.unbind(this.#t), this.#e = null;
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
o({ tag: "a-form" })(m);
|
|
566
|
+
// src/kit/theme-boot.generated.ts
|
|
567
|
+
var h = ":root{background:#ffffff;color:#161a23;color-scheme:light}@media (prefers-color-scheme: dark){:root:not([data-theme='light']){background:#0f1117;color:#e8eaf1;color-scheme:dark}}:root[data-theme='dark']{background:#0f1117;color:#e8eaf1;color-scheme:dark}@media (prefers-contrast: more){:root:not([data-contrast='standard']){background:#ffffff;color:#000000;color-scheme:light}}:root[data-contrast='more']{background:#ffffff;color:#000000;color-scheme:light}@media (prefers-contrast: more) and (prefers-color-scheme: dark){:root:not([data-contrast='standard']):not([data-theme='light']){background:#000000;color:#ffffff;color-scheme:dark}}@media (prefers-contrast: more){:root[data-theme='dark']:not([data-contrast='standard']){background:#000000;color:#ffffff;color-scheme:dark}}@media (prefers-color-scheme: dark){:root[data-contrast='more']:not([data-theme='light']){background:#000000;color:#ffffff;color-scheme:dark}}:root[data-theme='dark'][data-contrast='more']{background:#000000;color:#ffffff;color-scheme:dark}", g = "ar-theme", _ = "ar-contrast";
|
|
568
|
+
function v(e, t) {
|
|
569
|
+
try {
|
|
570
|
+
t === null ? localStorage.removeItem(e) : localStorage.setItem(e, t);
|
|
571
|
+
} catch {}
|
|
572
|
+
}
|
|
573
|
+
var y = () => document.documentElement, b = (e) => typeof matchMedia == "function" && matchMedia(e).matches;
|
|
574
|
+
function x(e, { themeKey: t = g } = {}) {
|
|
575
|
+
e === "system" ? y().removeAttribute("data-theme") : y().setAttribute("data-theme", e), v(t, e === "system" ? null : e), y().dispatchEvent(new CustomEvent("ar-theme-change", { detail: {
|
|
576
|
+
theme: C(),
|
|
577
|
+
contrast: w()
|
|
578
|
+
} }));
|
|
579
|
+
}
|
|
580
|
+
function S(e, { contrastKey: t = _ } = {}) {
|
|
581
|
+
e === "system" ? y().removeAttribute("data-contrast") : y().setAttribute("data-contrast", e), v(t, e === "system" ? null : e), y().dispatchEvent(new CustomEvent("ar-theme-change", { detail: {
|
|
582
|
+
theme: C(),
|
|
583
|
+
contrast: w()
|
|
584
|
+
} }));
|
|
585
|
+
}
|
|
586
|
+
function C() {
|
|
587
|
+
let e = y().getAttribute("data-theme");
|
|
588
|
+
return e === "light" || e === "dark" ? e : b("(prefers-color-scheme: dark)") ? "dark" : "light";
|
|
589
|
+
}
|
|
590
|
+
function w() {
|
|
591
|
+
let e = y().getAttribute("data-contrast");
|
|
592
|
+
return e === "more" || e === "standard" ? e : b("(prefers-contrast: more)") ? "more" : "standard";
|
|
593
|
+
}
|
|
594
|
+
function T({ themeKey: e = g, contrastKey: t = _ } = {}) {
|
|
595
|
+
try {
|
|
596
|
+
let n = localStorage.getItem(e), r = localStorage.getItem(t);
|
|
597
|
+
(n === "light" || n === "dark") && y().setAttribute("data-theme", n), (r === "more" || r === "standard") && y().setAttribute("data-contrast", r);
|
|
598
|
+
} catch {}
|
|
599
|
+
}
|
|
600
|
+
function E({ themeKey: e = g, contrastKey: t = _ } = {}) {
|
|
601
|
+
return `try{var d=document.documentElement,t=localStorage.getItem(${JSON.stringify(e)}),c=localStorage.getItem(${JSON.stringify(t)});if(t==='light'||t==='dark')d.setAttribute('data-theme',t);if(c==='more'||c==='standard')d.setAttribute('data-contrast',c)}catch(e){}`;
|
|
602
|
+
}
|
|
603
|
+
function D(e = {}) {
|
|
604
|
+
let t = e.nonce ? ` nonce="${e.nonce.replace(/[^\w+/=-]/g, "")}"` : "";
|
|
605
|
+
return `<style${t}>${h}</style><script${t}>${E(e)}<\/script>`;
|
|
606
|
+
}
|
|
607
|
+
export { _ as CONTRAST_STORAGE_KEY, h as CRITICAL_CSS, c as DataTable, f as FlexView, m as Form, p as List, g as THEME_STORAGE_KEY, T as applyStoredTheme, w as getContrast, C as getTheme, S as setContrast, x as setTheme, D as themeBootHtml, E as themeBootScript };
|
|
608
|
+
|
|
609
|
+
//# sourceMappingURL=components.js.map
|