@uva-glass/component-library
Version:
React components UvA
636 lines (635 loc) • 20.2 kB
JavaScript
import { i as X, r as Y, j as ne, w as re, v as se } from "./LexicalUtils.prod-Dny9Fu94.js";
import { f as Z, n as G, X as ie, d as S, T as P, w as oe, c as x, q as H, o as w, J as le, Y as ce, a as N, b as ae, E as b, U as v, G as Q, Z as J, l as M, z as D } from "./Lexical.prod-CWyHQUEM.js";
import { I as W } from "./LexicalSelection.prod-DkvWlcln.js";
function p(r, ...e) {
const t = new URL("https://lexical.dev/docs/error"), n = new URLSearchParams();
n.append("code", r);
for (const s of e) n.append("v", s);
throw t.search = n.toString(), Error(`Minified Lexical error #${r}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
}
function L(r) {
let e = 1, t = r.getParent();
for (; t != null; ) {
if (g(t)) {
const n = t.getParent();
if (c(n)) {
e++, t = n.getParent();
continue;
}
p(40);
}
return e;
}
return e;
}
function O(r) {
let e = r.getParent();
c(e) || p(40);
let t = e;
for (; t !== null; ) t = t.getParent(), c(t) && (e = t);
return e;
}
function ee(r) {
let e = [];
const t = r.getChildren().filter(g);
for (let n = 0; n < t.length; n++) {
const s = t[n], i = s.getFirstChild();
c(i) ? e = e.concat(ee(i)) : e.push(s);
}
return e;
}
function m(r) {
return g(r) && c(r.getFirstChild());
}
function B(r) {
return f().append(r);
}
function te(r, e) {
return g(r) && (e.length === 0 || e.length === 1 && r.is(e[0]) && r.getChildrenSize() === 0);
}
function $(r) {
const e = N();
if (e !== null) {
let t = e.getNodes();
if (x(e)) {
const s = e.getStartEndPoints();
s === null && p(143);
const [i] = s, o = i.getNode(), a = o.getParent();
if (v(o)) {
const l = o.getFirstChild();
if (l) t = l.selectStart().getNodes();
else {
const u = P();
o.append(u), t = u.select().getNodes();
}
} else if (te(o, t)) {
const l = h(r);
if (v(a)) {
o.replace(l);
const u = f();
S(o) && (u.setFormat(o.getFormatType()), u.setIndent(o.getIndent())), l.append(u);
} else if (g(o)) {
const u = o.getParentOrThrow();
y(l, u.getChildren()), u.replace(l);
}
return;
}
}
const n = /* @__PURE__ */ new Set();
for (let s = 0; s < t.length; s++) {
const i = t[s];
if (S(i) && i.isEmpty() && !g(i) && !n.has(i.getKey())) {
z(i, r);
continue;
}
let o = Q(i) ? i.getParent() : g(i) && i.isEmpty() ? i : null;
for (; o != null; ) {
const a = o.getKey();
if (c(o)) {
if (!n.has(a)) {
const l = h(r);
y(l, o.getChildren()), o.replace(l), n.add(a);
}
break;
}
{
const l = o.getParent();
if (v(l) && !n.has(a)) {
n.add(a), z(o, r);
break;
}
o = l;
}
}
}
}
}
function y(r, e) {
r.splice(r.getChildrenSize(), 0, e);
}
function z(r, e) {
if (c(r)) return r;
const t = r.getPreviousSibling(), n = r.getNextSibling(), s = f();
let i;
if (y(s, r.getChildren()), c(t) && e === t.getListType()) t.append(s), c(n) && e === n.getListType() && (y(t, n.getChildren()), n.remove()), i = t;
else if (c(n) && e === n.getListType()) n.getFirstChildOrThrow().insertBefore(s), i = n;
else {
const o = h(e);
o.append(s), r.replace(o), i = o;
}
return s.setFormat(r.getFormatType()), s.setIndent(r.getIndent()), r.remove(), i;
}
function I(r, e) {
const t = r.getLastChild(), n = e.getFirstChild();
t && n && m(t) && m(n) && (I(t.getFirstChild(), n.getFirstChild()), n.remove());
const s = e.getChildren();
s.length > 0 && r.append(...s), e.remove();
}
function ue() {
const r = N();
if (x(r)) {
const e = /* @__PURE__ */ new Set(), t = r.getNodes(), n = r.anchor.getNode();
if (te(n, t)) e.add(O(n));
else for (let s = 0; s < t.length; s++) {
const i = t[s];
if (Q(i)) {
const o = se(i, C);
o != null && e.add(O(o));
}
}
for (const s of e) {
let i = s;
const o = ee(s);
for (const a of o) {
const l = P().setTextStyle(r.style).setTextFormat(r.format);
y(l, a.getChildren()), i.insertAfter(l), i = l, a.__key === r.anchor.key && J(r.anchor, M(D(l, "next"))), a.__key === r.focus.key && J(r.focus, M(D(l, "next"))), a.remove();
}
s.remove();
}
}
}
function ge(r) {
const e = /* @__PURE__ */ new Set();
if (m(r) || e.has(r.getKey())) return;
const t = r.getParent(), n = r.getNextSibling(), s = r.getPreviousSibling();
if (m(n) && m(s)) {
const i = s.getFirstChild();
if (c(i)) {
i.append(r);
const o = n.getFirstChild();
c(o) && (y(i, o.getChildren()), n.remove(), e.add(n.getKey()));
}
} else if (m(n)) {
const i = n.getFirstChild();
if (c(i)) {
const o = i.getFirstChild();
o !== null && o.insertBefore(r);
}
} else if (m(s)) {
const i = s.getFirstChild();
c(i) && i.append(r);
} else if (c(t)) {
const i = f().setTextFormat(t.getTextFormat()).setTextStyle(t.getTextStyle()), o = h(t.getListType()).setTextFormat(t.getTextFormat()).setTextStyle(t.getTextStyle());
i.append(o), o.append(r), s ? s.insertAfter(i) : n ? n.insertBefore(i) : t.append(i);
}
}
function he(r) {
if (m(r)) return;
const e = r.getParent(), t = e ? e.getParent() : void 0;
if (c(t ? t.getParent() : void 0) && g(t) && c(e)) {
const n = e ? e.getFirstChild() : void 0, s = e ? e.getLastChild() : void 0;
if (r.is(n)) t.insertBefore(r), e.isEmpty() && t.remove();
else if (r.is(s)) t.insertAfter(r), e.isEmpty() && t.remove();
else {
const i = e.getListType(), o = f(), a = h(i);
o.append(a), r.getPreviousSiblings().forEach((d) => a.append(d));
const l = f(), u = h(i);
l.append(u), y(u, r.getNextSiblings()), t.insertBefore(o), t.insertAfter(l), t.replace(r);
}
}
}
function fe() {
const r = N();
if (!x(r) || !r.isCollapsed()) return !1;
const e = r.anchor.getNode();
if (!g(e) || e.getChildrenSize() !== 0) return !1;
const t = O(e), n = e.getParent();
c(n) || p(40);
const s = n.getParent();
let i;
if (v(s)) i = P(), t.insertAfter(i);
else {
if (!g(s)) return !1;
i = f(), s.insertAfter(i);
}
i.setTextStyle(r.style).setTextFormat(r.format).select();
const o = e.getNextSiblings();
if (o.length > 0) {
const a = h(n.getListType());
if (g(i)) {
const l = f();
l.append(a), i.insertAfter(l);
} else i.insertAfter(a);
a.append(...o);
}
return function(a) {
let l = a;
for (; l.getNextSibling() == null && l.getPreviousSibling() == null; ) {
const u = l.getParent();
if (u == null || !g(u) && !c(u)) break;
l = u;
}
l.remove();
}(e), !0;
}
function F(...r) {
const e = [];
for (const t of r) if (t && typeof t == "string") for (const [n] of t.matchAll(/\S+/g)) e.push(n);
return e;
}
function K(r, e, t) {
const n = W(e.__textStyle);
for (const s in n) r.style.setProperty(`--listitem-marker-${s}`, n[s]);
if (t) for (const s in W(t.__textStyle)) s in n || r.style.removeProperty(`--listitem-marker-${s}`);
}
class C extends Z {
static getType() {
return "listitem";
}
static clone(e) {
return new C(e.__value, e.__checked, e.__key);
}
constructor(e, t, n) {
super(n), this.__value = e === void 0 ? 1 : e, this.__checked = t;
}
createDOM(e) {
const t = document.createElement("li"), n = this.getParent();
c(n) && n.getListType() === "check" && V(t, this, null), t.value = this.__value, U(t, e.theme, this);
const s = this.__style;
return s && (t.style.cssText = s), K(t, this, null), t;
}
updateDOM(e, t, n) {
const s = this.getParent();
c(s) && s.getListType() === "check" && V(t, this, e), t.value = this.__value, U(t, n.theme, this);
const i = e.__style, o = this.__style;
return i !== o && (o === "" ? t.removeAttribute("style") : t.style.cssText = o), K(t, this, e), !1;
}
static transform() {
return (e) => {
if (g(e) || p(144), e.__checked == null) return;
const t = e.getParent();
c(t) && t.getListType() !== "check" && e.getChecked() != null && e.setChecked(void 0);
};
}
static importDOM() {
return { li: () => ({ conversion: de, priority: 0 }) };
}
static importJSON(e) {
return f().updateFromJSON(e);
}
updateFromJSON(e) {
return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked);
}
exportDOM(e) {
const t = this.createDOM(e._config);
t.style.textAlign = this.getFormatType();
const n = this.getDirection();
return n && (t.dir = n), { element: t };
}
exportJSON() {
return { ...super.exportJSON(), checked: this.getChecked(), value: this.getValue() };
}
append(...e) {
for (let t = 0; t < e.length; t++) {
const n = e[t];
if (S(n) && this.canMergeWith(n)) {
const s = n.getChildren();
this.append(...s), n.remove();
} else super.append(n);
}
return this;
}
replace(e, t) {
if (g(e)) return super.replace(e);
this.setIndent(0);
const n = this.getParentOrThrow();
if (!c(n)) return e;
if (n.__first === this.getKey()) n.insertBefore(e);
else if (n.__last === this.getKey()) n.insertAfter(e);
else {
const s = h(n.getListType());
let i = this.getNextSibling();
for (; i; ) {
const o = i;
i = i.getNextSibling(), s.append(o);
}
n.insertAfter(e), e.insertAfter(s);
}
return t && (S(e) || p(139), this.getChildren().forEach((s) => {
e.append(s);
})), this.remove(), n.getChildrenSize() === 0 && n.remove(), e;
}
insertAfter(e, t = !0) {
const n = this.getParentOrThrow();
if (c(n) || p(39), g(e)) return super.insertAfter(e, t);
const s = this.getNextSiblings();
if (n.insertAfter(e, t), s.length !== 0) {
const i = h(n.getListType());
s.forEach((o) => i.append(o)), e.insertAfter(i, t);
}
return e;
}
remove(e) {
const t = this.getPreviousSibling(), n = this.getNextSibling();
super.remove(e), t && n && m(t) && m(n) && (I(t.getFirstChild(), n.getFirstChild()), n.remove());
}
insertNewAfter(e, t = !0) {
const n = f().updateFromJSON(this.exportJSON()).setChecked(!this.getChecked() && void 0);
return this.insertAfter(n, t), n;
}
collapseAtStart(e) {
const t = P();
this.getChildren().forEach((o) => t.append(o));
const n = this.getParentOrThrow(), s = n.getParentOrThrow(), i = g(s);
if (n.getChildrenSize() === 1) if (i) n.remove(), s.select();
else {
n.insertBefore(t), n.remove();
const o = e.anchor, a = e.focus, l = t.getKey();
o.type === "element" && o.getNode().is(this) && o.set(l, o.offset, "element"), a.type === "element" && a.getNode().is(this) && a.set(l, a.offset, "element");
}
else n.insertBefore(t), this.remove();
return !0;
}
getValue() {
return this.getLatest().__value;
}
setValue(e) {
const t = this.getWritable();
return t.__value = e, t;
}
getChecked() {
const e = this.getLatest();
let t;
const n = this.getParent();
return c(n) && (t = n.getListType()), t === "check" ? !!e.__checked : void 0;
}
setChecked(e) {
const t = this.getWritable();
return t.__checked = e, t;
}
toggleChecked() {
const e = this.getWritable();
return e.setChecked(!e.__checked);
}
getIndent() {
const e = this.getParent();
if (e === null || !this.isAttached()) return this.getLatest().__indent;
let t = e.getParentOrThrow(), n = 0;
for (; g(t); ) t = t.getParentOrThrow().getParentOrThrow(), n++;
return n;
}
setIndent(e) {
typeof e != "number" && p(117), (e = Math.floor(e)) >= 0 || p(199);
let t = this.getIndent();
for (; t !== e; ) t < e ? (ge(this), t++) : (he(this), t--);
return this;
}
canInsertAfter(e) {
return g(e);
}
canReplaceWith(e) {
return g(e);
}
canMergeWith(e) {
return g(e) || oe(e);
}
extractWithChild(e, t) {
if (!x(t)) return !1;
const n = t.anchor.getNode(), s = t.focus.getNode();
return this.isParentOf(n) && this.isParentOf(s) && this.getTextContent().length === t.getTextContent().length;
}
isParentRequired() {
return !0;
}
createParentElementNode() {
return h("bullet");
}
canMergeWhenEmpty() {
return !0;
}
}
function U(r, e, t) {
const n = [], s = [], i = e.list, o = i ? i.listitem : void 0;
let a;
if (i && i.nested && (a = i.nested.listitem), o !== void 0 && n.push(...F(o)), i) {
const l = t.getParent(), u = c(l) && l.getListType() === "check", d = t.getChecked();
u && !d || s.push(i.listitemUnchecked), u && d || s.push(i.listitemChecked), u && n.push(d ? i.listitemChecked : i.listitemUnchecked);
}
if (a !== void 0) {
const l = F(a);
t.getChildren().some((u) => c(u)) ? n.push(...l) : s.push(...l);
}
s.length > 0 && X(r, ...s), n.length > 0 && Y(r, ...n);
}
function V(r, e, t, n) {
c(e.getFirstChild()) ? (r.removeAttribute("role"), r.removeAttribute("tabIndex"), r.removeAttribute("aria-checked")) : (r.setAttribute("role", "checkbox"), r.setAttribute("tabIndex", "-1"), t && e.__checked === t.__checked || r.setAttribute("aria-checked", e.getChecked() ? "true" : "false"));
}
function de(r) {
if (r.classList.contains("task-list-item")) {
for (const t of r.children) if (t.tagName === "INPUT") return pe(t);
}
const e = r.getAttribute("aria-checked");
return { node: f(e === "true" || e !== "false" && void 0) };
}
function pe(r) {
return r.getAttribute("type") !== "checkbox" ? { node: null } : { node: f(r.hasAttribute("checked")) };
}
function f(r) {
return H(new C(void 0, r));
}
function g(r) {
return r instanceof C;
}
class k extends Z {
static getType() {
return "list";
}
static clone(e) {
const t = e.__listType || j[e.__tag];
return new k(t, e.__start, e.__key);
}
constructor(e = "number", t = 1, n) {
super(n);
const s = j[e] || e;
this.__listType = s, this.__tag = s === "number" ? "ol" : "ul", this.__start = t;
}
getTag() {
return this.__tag;
}
setListType(e) {
const t = this.getWritable();
return t.__listType = e, t.__tag = e === "number" ? "ol" : "ul", t;
}
getListType() {
return this.__listType;
}
getStart() {
return this.__start;
}
setStart(e) {
const t = this.getWritable();
return t.__start = e, t;
}
createDOM(e, t) {
const n = this.__tag, s = document.createElement(n);
return this.__start !== 1 && s.setAttribute("start", String(this.__start)), s.__lexicalListType = this.__listType, R(s, e.theme, this), s;
}
updateDOM(e, t, n) {
return e.__tag !== this.__tag || (R(t, n.theme, this), !1);
}
static transform() {
return (e) => {
c(e) || p(163), function(t) {
const n = t.getNextSibling();
c(n) && t.getListType() === n.getListType() && I(t, n);
}(e), function(t) {
const n = t.getListType() !== "check";
let s = t.getStart();
for (const i of t.getChildren()) g(i) && (i.getValue() !== s && i.setValue(s), n && i.getLatest().__checked != null && i.setChecked(void 0), c(i.getFirstChild()) || s++);
}(e);
};
}
static importDOM() {
return { ol: () => ({ conversion: q, priority: 0 }), ul: () => ({ conversion: q, priority: 0 }) };
}
static importJSON(e) {
return h().updateFromJSON(e);
}
updateFromJSON(e) {
return super.updateFromJSON(e).setListType(e.listType).setStart(e.start);
}
exportDOM(e) {
const t = this.createDOM(e._config, e);
return G(t) && (this.__start !== 1 && t.setAttribute("start", String(this.__start)), this.__listType === "check" && t.setAttribute("__lexicalListType", "check")), { element: t };
}
exportJSON() {
return { ...super.exportJSON(), listType: this.getListType(), start: this.getStart(), tag: this.getTag() };
}
canBeEmpty() {
return !1;
}
canIndent() {
return !1;
}
splice(e, t, n) {
let s = n;
for (let i = 0; i < n.length; i++) {
const o = n[i];
g(o) || (s === n && (s = [...n]), s[i] = f().append(!S(o) || c(o) || o.isInline() ? o : ie(o.getTextContent())));
}
return super.splice(e, t, s);
}
extractWithChild(e) {
return g(e);
}
}
function R(r, e, t) {
const n = [], s = [], i = e.list;
if (i !== void 0) {
const o = i[`${t.__tag}Depth`] || [], a = L(t) - 1, l = a % o.length, u = o[l], d = i[t.__tag];
let T;
const A = i.nested, E = i.checklist;
if (A !== void 0 && A.list && (T = A.list), d !== void 0 && n.push(d), E !== void 0 && t.__listType === "check" && n.push(E), u !== void 0) {
n.push(...F(u));
for (let _ = 0; _ < o.length; _++) _ !== l && s.push(t.__tag + _);
}
if (T !== void 0) {
const _ = F(T);
a > 1 ? n.push(..._) : s.push(..._);
}
}
s.length > 0 && X(r, ...s), n.length > 0 && Y(r, ...n);
}
function me(r) {
const e = [];
for (let t = 0; t < r.length; t++) {
const n = r[t];
if (g(n)) {
e.push(n);
const s = n.getChildren();
s.length > 1 && s.forEach((i) => {
c(i) && e.push(B(i));
});
} else e.push(B(n));
}
return e;
}
function q(r) {
const e = r.nodeName.toLowerCase();
let t = null;
return e === "ol" ? t = h("number", r.start) : e === "ul" && (t = function(n) {
if (n.getAttribute("__lexicallisttype") === "check" || n.classList.contains("contains-task-list")) return !0;
for (const s of n.childNodes) if (G(s) && s.hasAttribute("aria-checked")) return !0;
return !1;
}(r) ? h("check") : h("bullet")), { after: me, node: t };
}
const j = { ol: "number", ul: "bullet" };
function h(r = "number", e = 1) {
return H(new k(r, e));
}
function c(r) {
return r instanceof k;
}
const _e = w(), ye = w(), Te = w();
function ke(r) {
return ne(r.registerCommand(ye, () => ($("number"), !0), b), r.registerCommand(_e, () => ($("bullet"), !0), b), r.registerCommand(Te, () => (ue(), !0), b), r.registerCommand(ae, () => fe(), b), r.registerNodeTransform(C, (e) => {
const t = e.getFirstChild();
if (t) {
if (ce(t)) {
const n = t.getStyle(), s = t.getFormat();
e.getTextStyle() !== n && e.setTextStyle(n), e.getTextFormat() !== s && e.setTextFormat(s);
}
} else {
const n = N();
x(n) && (n.style !== e.getTextStyle() || n.format !== e.getTextFormat()) && n.isCollapsed() && e.is(n.anchor.getNode()) && e.setTextStyle(n.style).setTextFormat(n.format);
}
}), r.registerNodeTransform(le, (e) => {
const t = e.getParent();
if (g(t) && e.is(t.getFirstChild())) {
const n = e.getStyle(), s = e.getFormat();
n === t.getTextStyle() && s === t.getTextFormat() || t.setTextStyle(n).setTextFormat(s);
}
}));
}
function be(r) {
const e = (t) => {
const n = t.getParent();
if (c(t.getFirstChild()) || !c(n)) return;
const s = re(t, (i) => g(i) && c(i.getParent()) && g(i.getPreviousSibling()));
if (s === null && t.getIndent() > 0) t.setIndent(0);
else if (g(s)) {
const i = s.getPreviousSibling();
if (g(i)) {
const o = function(l) {
let u = l, d = u.getFirstChild();
for (; c(d); ) {
const T = d.getLastChild();
if (!g(T)) break;
u = T, d = u.getFirstChild();
}
return u;
}(i), a = o.getParent();
if (c(a)) {
const l = L(a);
l + 1 < L(n) && t.setIndent(l);
}
}
}
};
return r.registerNodeTransform(k, (t) => {
const n = [t];
for (; n.length > 0; ) {
const s = n.shift();
if (c(s)) {
for (const i of s.getChildren()) if (g(i)) {
e(i);
const o = i.getFirstChild();
c(o) && n.push(o);
}
}
}
});
}
export {
Te as C,
C as G,
ke as T,
_e as _,
c as a,
h as c,
g as n,
k as r,
be as v,
ye as y
};
//# sourceMappingURL=LexicalList.prod-pZmYrwOC.js.map