@uva-glass/component-library
Version:
React components UvA
596 lines (595 loc) • 19.2 kB
JavaScript
import { i as Q, r as X, j as te, v as ne } from "./LexicalUtils.prod-DVr8VsHc.js";
import { d as Y, r as j, X as re, h as C, w as v, N as se, c as S, H as q, o as L, J as ie, Y as oe, a as N, b as le, P as x, U as k, Q as G, t as J, e as E, B as M } from "./Lexical.prod-CniF7zEE.js";
import { I as B } from "./LexicalSelection.prod-BfAlhGGm.js";
function d(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 ce(r) {
let e = 1, t = r.getParent();
for (; t != null; ) {
if (h(t)) {
const n = t.getParent();
if (c(n)) {
e++, t = n.getParent();
continue;
}
d(40);
}
return e;
}
return e;
}
function O(r) {
let e = r.getParent();
c(e) || d(40);
let t = e;
for (; t !== null; ) t = t.getParent(), c(t) && (e = t);
return e;
}
function Z(r) {
let e = [];
const t = r.getChildren().filter(h);
for (let n = 0; n < t.length; n++) {
const s = t[n], i = s.getFirstChild();
c(i) ? e = e.concat(Z(i)) : e.push(s);
}
return e;
}
function p(r) {
return h(r) && c(r.getFirstChild());
}
function D(r) {
return f().append(r);
}
function ee(r, e) {
return h(r) && (e.length === 0 || e.length === 1 && r.is(e[0]) && r.getChildrenSize() === 0);
}
function W(r) {
const e = N();
if (e !== null) {
let t = e.getNodes();
if (S(e)) {
const s = e.getStartEndPoints();
s === null && d(143);
const [i] = s, o = i.getNode(), a = o.getParent();
if (k(o)) {
const l = o.getFirstChild();
if (l) t = l.selectStart().getNodes();
else {
const u = v();
o.append(u), t = u.select().getNodes();
}
} else if (ee(o, t)) {
const l = g(r);
if (k(a)) {
o.replace(l);
const u = f();
C(o) && (u.setFormat(o.getFormatType()), u.setIndent(o.getIndent())), l.append(u);
} else if (h(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 (!C(i) || !i.isEmpty() || h(i) || n.has(i.getKey())) {
if (G(i)) {
let o = i.getParent();
for (; o != null; ) {
const a = o.getKey();
if (c(o)) {
if (!n.has(a)) {
const l = g(r);
y(l, o.getChildren()), o.replace(l), n.add(a);
}
break;
}
{
const l = o.getParent();
if (k(l) && !n.has(a)) {
n.add(a), $(o, r);
break;
}
o = l;
}
}
}
} else $(i, r);
}
}
}
function y(r, e) {
r.splice(r.getChildrenSize(), 0, e);
}
function $(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 = g(e);
o.append(s), r.replace(o), i = o;
}
return s.setFormat(r.getFormatType()), s.setIndent(r.getIndent()), r.remove(), i;
}
function w(r, e) {
const t = r.getLastChild(), n = e.getFirstChild();
t && n && p(t) && p(n) && (w(t.getFirstChild(), n.getFirstChild()), n.remove());
const s = e.getChildren();
s.length > 0 && r.append(...s), e.remove();
}
function ae() {
const r = N();
if (S(r)) {
const e = /* @__PURE__ */ new Set(), t = r.getNodes(), n = r.anchor.getNode();
if (ee(n, t)) e.add(O(n));
else for (let s = 0; s < t.length; s++) {
const i = t[s];
if (G(i)) {
const o = ne(i, T);
o != null && e.add(O(o));
}
}
for (const s of e) {
let i = s;
const o = Z(s);
for (const a of o) {
const l = v().setTextStyle(r.style).setTextFormat(r.format);
y(l, a.getChildren()), i.insertAfter(l), i = l, a.__key === r.anchor.key && J(r.anchor, E(M(l, "next"))), a.__key === r.focus.key && J(r.focus, E(M(l, "next"))), a.remove();
}
s.remove();
}
}
}
function ue(r) {
const e = /* @__PURE__ */ new Set();
if (p(r) || e.has(r.getKey())) return;
const t = r.getParent(), n = r.getNextSibling(), s = r.getPreviousSibling();
if (p(n) && p(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 (p(n)) {
const i = n.getFirstChild();
if (c(i)) {
const o = i.getFirstChild();
o !== null && o.insertBefore(r);
}
} else if (p(s)) {
const i = s.getFirstChild();
c(i) && i.append(r);
} else if (c(t)) {
const i = f().setTextFormat(t.getTextFormat()).setTextStyle(t.getTextStyle()), o = g(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 (p(r)) return;
const e = r.getParent(), t = e ? e.getParent() : void 0;
if (c(t ? t.getParent() : void 0) && h(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 = g(i);
o.append(a), r.getPreviousSiblings().forEach((m) => a.append(m));
const l = f(), u = g(i);
l.append(u), y(u, r.getNextSiblings()), t.insertBefore(o), t.insertAfter(l), t.replace(r);
}
}
}
function ge() {
const r = N();
if (!S(r) || !r.isCollapsed()) return !1;
const e = r.anchor.getNode();
if (!h(e) || e.getChildrenSize() !== 0) return !1;
const t = O(e), n = e.getParent();
c(n) || d(40);
const s = n.getParent();
let i;
if (k(s)) i = v(), t.insertAfter(i);
else {
if (!h(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 = g(n.getListType());
if (h(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 || !h(u) && !c(u)) break;
l = u;
}
l.remove();
}(e), !0;
}
function b(...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 U(r, e, t) {
const n = B(e.__textStyle);
for (const s in n) r.style.setProperty(`--listitem-marker-${s}`, n[s]);
if (t) for (const s in B(t.__textStyle)) s in n || r.style.removeProperty(`--listitem-marker-${s}`);
}
class T extends Y {
static getType() {
return "listitem";
}
static clone(e) {
return new T(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, K(t, e.theme, this);
const s = this.__style;
return s && (t.style.cssText = s), U(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, K(t, n.theme, this);
const i = e.__style, o = this.__style;
return i !== o && (o === "" ? t.removeAttribute("style") : t.style.cssText = o), U(t, this, e), !1;
}
static transform() {
return (e) => {
if (h(e) || d(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: fe, 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 (C(n) && this.canMergeWith(n)) {
const s = n.getChildren();
this.append(...s), n.remove();
} else super.append(n);
}
return this;
}
replace(e, t) {
if (h(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 = g(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 && (C(e) || d(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) || d(39), h(e)) return super.insertAfter(e, t);
const s = this.getNextSiblings();
if (n.insertAfter(e, t), s.length !== 0) {
const i = g(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 && p(t) && p(n) && (w(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 = v();
this.getChildren().forEach((o) => t.append(o));
const n = this.getParentOrThrow(), s = n.getParentOrThrow(), i = h(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 (; h(t); ) t = t.getParentOrThrow().getParentOrThrow(), n++;
return n;
}
setIndent(e) {
typeof e != "number" && d(117), (e = Math.floor(e)) >= 0 || d(199);
let t = this.getIndent();
for (; t !== e; ) t < e ? (ue(this), t++) : (he(this), t--);
return this;
}
canInsertAfter(e) {
return h(e);
}
canReplaceWith(e) {
return h(e);
}
canMergeWith(e) {
return h(e) || se(e);
}
extractWithChild(e, t) {
if (!S(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 g("bullet");
}
canMergeWhenEmpty() {
return !0;
}
}
function K(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(...b(o)), i) {
const l = t.getParent(), u = c(l) && l.getListType() === "check", m = t.getChecked();
u && !m || s.push(i.listitemUnchecked), u && m || s.push(i.listitemChecked), u && n.push(m ? i.listitemChecked : i.listitemUnchecked);
}
if (a !== void 0) {
const l = b(a);
t.getChildren().some((u) => c(u)) ? n.push(...l) : s.push(...l);
}
s.length > 0 && Q(r, ...s), n.length > 0 && X(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 fe(r) {
if (r.classList.contains("task-list-item")) {
for (const t of r.children) if (t.tagName === "INPUT") return de(t);
}
const e = r.getAttribute("aria-checked");
return { node: f(e === "true" || e !== "false" && void 0) };
}
function de(r) {
return r.getAttribute("type") !== "checkbox" ? { node: null } : { node: f(r.hasAttribute("checked")) };
}
function f(r) {
return q(new T(void 0, r));
}
function h(r) {
return r instanceof T;
}
class P extends Y {
static getType() {
return "list";
}
static clone(e) {
const t = e.__listType || H[e.__tag];
return new P(t, e.__start, e.__key);
}
constructor(e = "number", t = 1, n) {
super(n);
const s = H[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, z(s, e.theme, this), s;
}
updateDOM(e, t, n) {
return e.__tag !== this.__tag || (z(t, n.theme, this), !1);
}
static transform() {
return (e) => {
c(e) || d(163), function(t) {
const n = t.getNextSibling();
c(n) && t.getListType() === n.getListType() && w(t, n);
}(e), function(t) {
const n = t.getListType() !== "check";
let s = t.getStart();
for (const i of t.getChildren()) h(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: R, priority: 0 }), ul: () => ({ conversion: R, priority: 0 }) };
}
static importJSON(e) {
return g().updateFromJSON(e);
}
updateFromJSON(e) {
return super.updateFromJSON(e).setListType(e.listType).setStart(e.start);
}
exportDOM(e) {
const t = this.createDOM(e._config, e);
return j(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];
h(o) || (s === n && (s = [...n]), s[i] = f().append(!C(o) || c(o) || o.isInline() ? o : re(o.getTextContent())));
}
return super.splice(e, t, s);
}
extractWithChild(e) {
return h(e);
}
}
function z(r, e, t) {
const n = [], s = [], i = e.list;
if (i !== void 0) {
const o = i[`${t.__tag}Depth`] || [], a = ce(t) - 1, l = a % o.length, u = o[l], m = i[t.__tag];
let F;
const A = i.nested, I = i.checklist;
if (A !== void 0 && A.list && (F = A.list), m !== void 0 && n.push(m), I !== void 0 && t.__listType === "check" && n.push(I), u !== void 0) {
n.push(...b(u));
for (let _ = 0; _ < o.length; _++) _ !== l && s.push(t.__tag + _);
}
if (F !== void 0) {
const _ = b(F);
a > 1 ? n.push(..._) : s.push(..._);
}
}
s.length > 0 && Q(r, ...s), n.length > 0 && X(r, ...n);
}
function pe(r) {
const e = [];
for (let t = 0; t < r.length; t++) {
const n = r[t];
if (h(n)) {
e.push(n);
const s = n.getChildren();
s.length > 1 && s.forEach((i) => {
c(i) && e.push(D(i));
});
} else e.push(D(n));
}
return e;
}
function R(r) {
const e = r.nodeName.toLowerCase();
let t = null;
return e === "ol" ? t = g("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 (j(s) && s.hasAttribute("aria-checked")) return !0;
return !1;
}(r) ? g("check") : g("bullet")), { after: pe, node: t };
}
const H = { ol: "number", ul: "bullet" };
function g(r = "number", e = 1) {
return q(new P(r, e));
}
function c(r) {
return r instanceof P;
}
const me = L(), _e = L(), ye = L();
function xe(r) {
return te(r.registerCommand(_e, () => (W("number"), !0), x), r.registerCommand(me, () => (W("bullet"), !0), x), r.registerCommand(ye, () => (ae(), !0), x), r.registerCommand(le, () => ge(), x), r.registerNodeTransform(T, (e) => {
const t = e.getFirstChild();
if (t) {
if (oe(t)) {
const n = t.getStyle(), s = t.getFormat();
e.getTextStyle() !== n && e.setTextStyle(n), e.getTextFormat() !== s && e.setTextFormat(s);
}
} else {
const n = N();
S(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(ie, (e) => {
const t = e.getParent();
if (h(t) && e.is(t.getFirstChild())) {
const n = e.getStyle(), s = e.getFormat();
n === t.getTextStyle() && s === t.getTextFormat() || t.setTextStyle(n).setTextFormat(s);
}
}));
}
export {
h as H,
T as K,
g as Z,
me as e,
xe as i,
P as j,
_e as r,
ye as s,
c as t
};
//# sourceMappingURL=LexicalList.prod-BUcoZhe4.js.map