@uva-glass/component-library
Version:
React components UvA
93 lines (92 loc) • 2.93 kB
JavaScript
import { Z as T, A as i, I as w, s as p, J as u, U as b, e as E, D, $ as g, V as I, B as R, O as x } from "../../../../LexicalTable.prod-BBI7yaOy.js";
import { A as S } from "../../../../Lexical.prod-BAE-wnll.js";
import { TableWrapperNode as N } from "../../nodes/TableWrapperNode/TableWrapperNode.js";
const v = 32, a = 48, W = 1, A = 200, F = 320, B = (t, e) => {
const n = R(0, 0, !1);
for (let o = 0; o < t; o++) {
const r = g();
for (let s = 0; s < e; s++) {
const l = x(0, void 0, void 0);
l.append(S()), r.append(l);
}
n.append(r);
}
return n;
}, P = (t) => {
const e = D(t), n = e.getNextSibling() || e.getPreviousSibling(), o = e.getParentOrThrow();
if (o.getChildrenSize() > 1 ? e.remove() : o.remove(), n !== null) {
const r = n.getFirstDescendant();
r && r.select();
}
}, O = (t) => {
const e = T(t);
if (!e)
throw new Error("Selected node is not a TableCellNode");
const n = e.getParent();
n instanceof N ? n.remove() : e.remove();
}, H = (t, e) => {
if (!i(t))
throw new Error("Selected node is not a TableCellNode");
const n = g();
I(e === "insertRowBelow");
const o = n.getFirstDescendant();
o && o.select();
}, U = (t, e) => {
if (!i(t))
throw new Error("Selected node is not a TableCellNode");
const n = w(t);
let o = u(t);
const r = n.getChildren(), s = b(t), l = E(e === "insertColumnLeft");
if (!l) return;
const d = u(l);
if (d === -1) return;
const c = n.getColWidths();
if (!c) return;
const C = c.map(
(m, h) => h === d ? a : m - Math.ceil(a / (c.length - 1))
);
n.setColWidths(C), o = e === "insertColumnLeft" ? o : o + 1;
const f = r[s].getChildren()[o];
f && f.select();
}, M = (t) => {
if (!i(t))
throw new Error("Selected node is not a TableCellNode");
(w(t).getFirstChild()?.getChildrenSize() || 0) === 1 ? O(t) : p();
}, V = (t) => {
const e = t.getRootElement();
if (!e || typeof window > "u") return 0;
const n = e.getBoundingClientRect(), o = window.getComputedStyle(e), r = parseFloat(o.paddingLeft || "0") + parseFloat(o.paddingRight || "0") + a;
return Math.max(0, n.width - r);
}, z = (t, e, n) => {
if (!t) return 0;
const o = n.getElementByKey(t.getKey());
if (!o) return 0;
const r = window.getComputedStyle(o);
return parseInt(r.width) - e * W - 1;
}, J = (t) => {
const e = t.getChildren();
for (const n of e) {
const o = n.getChildren();
for (const r of o)
if (i(r) && r.getTextContent().trim().length > 0)
return !0;
}
return !1;
};
export {
W as BORDER_WIDTHS,
a as DEFAULT_COL_WIDTH,
F as DEFAULT_EDITOR_WIDTH,
v as MIN_COLUMN_WIDTH,
A as PREVENT_OPEN_DELAY,
B as createTable,
M as deleteColumn,
P as deleteRow,
O as deleteTable,
V as getEditorContentWidth,
z as getEditorParrentCellWidth,
U as insertColumn,
H as insertRow,
J as tableHasContent
};
//# sourceMappingURL=helpers.js.map