@revolist/vue3-datagrid
Version:
Vue 3 DataGrid Spreadsheet component with native Vue 3 cell render support
218 lines (217 loc) • 5.42 kB
JavaScript
import { defineComponent as A, ref as I, getCurrentInstance as g, inject as _, h as O, createVNode as S, render as E, defineAsyncComponent as z } from "vue";
import { defineCustomElements as D } from "@revolist/revogrid/loader";
export * from "@revolist/revogrid/loader";
export * from "@revolist/revogrid";
const p = "routerLink", R = "navManager", L = "router", M = "aria", f = /* @__PURE__ */ Symbol(), w = { default: f }, V = (e) => e?.split(" ") || [], G = (e, t, s = []) => [...Array.from(e.value?.classList || []), ...s].filter(
(r, i, n) => !t.has(r) && n.indexOf(r) === i
), N = (e, t, s = [], r, i) => {
const n = A((o, { attrs: c, slots: m, emit: $ }) => {
o[r];
const v = I(), C = new Set(V(c.class)), y = g()?.appContext?.provides[R] ? _(R) : void 0, x = (d) => {
const { routerLink: h } = o;
if (h !== f)
if (y !== void 0) {
d.preventDefault();
let l = { event: d };
for (const u in o) {
const a = o[u];
o.hasOwnProperty(u) && u.startsWith(L) && a !== f && (l[u] = a);
}
y.navigate(l);
} else
console.warn("Tried to navigate, but no router was found. Make sure you have mounted Vue Router.");
};
return () => {
o[r], V(c.class).forEach((a) => {
C.add(a);
});
const d = o.onClick, h = (a) => {
d !== void 0 && d(a), a.defaultPrevented || x(a);
};
let l = {
ref: v,
class: G(v, C),
onClick: h
};
for (const a in o) {
const b = o[a];
(o.hasOwnProperty(a) && b !== f || a.startsWith(M)) && (l[a] = b);
}
return o[p] !== f && (l = {
...l,
href: o[p]
}), O(e, l, m.default && m.default());
};
});
return typeof n != "function" && (n.name = e, n.props = {
[p]: w
}, s.forEach((o) => {
n.props[o] = w;
})), n;
}, U = /* @__PURE__ */ N("revo-grid", void 0, [
"rowHeaders",
"frameSize",
"rowSize",
"colSize",
"range",
"readonly",
"resize",
"noHorizontalScrollTransfer",
"canFocus",
"useClipboard",
"columns",
"source",
"pinnedTopSource",
"pinnedBottomSource",
"rowDefinitions",
"editors",
"applyOnClose",
"plugins",
"columnTypes",
"theme",
"themeDefinitions",
"rowClass",
"autoSizeColumn",
"filter",
"sorting",
"focusTemplate",
"canMoveColumns",
"trimmedRows",
"exporting",
"grouping",
"stretch",
"additionalData",
"disableVirtualX",
"virtualX",
"disableVirtualY",
"hideAttribution",
"jobsBeforeRender",
"registerVNode",
"accessible",
"rtl",
"canDrag",
"contentsizechanged",
"beforeedit",
"beforerangeedit",
"afteredit",
"beforeautofill",
"beforerange",
"afterfocus",
"roworderchanged",
"beforesorting",
"beforesourcesortingapply",
"beforesortingapply",
"aftersortingapply",
"rowdragstart",
"headerclick",
"beforecellfocus",
"beforefocuslost",
"beforesourceset",
"beforeanysource",
"aftersourceset",
"afteranysource",
"beforecolumnsgather",
"beforecolumnsset",
"beforecolumnapplied",
"aftercolumnsset",
"beforefilterapply",
"beforefiltertrimmed",
"beforetrimmed",
"aftertrimmed",
"viewportscroll",
"beforeexport",
"beforeeditstart",
"aftercolumnresize",
"beforerowdefinition",
"filterconfigchanged",
"sortingconfigchanged",
"rowheaderschanged",
"beforegridrender",
"aftergridrender",
"aftergridinit",
"additionaldatachanged",
"afterthemechanged",
"created"
]);
function k(e, t) {
t?.appContext && (e.appContext = t.appContext);
}
const T = (e, t, s, r, i = null) => {
if (!t)
return i?.destroy?.(), { vueInstance: null, destroy: () => null, el: null };
let n = t._vnode;
if (n) {
k(n, r);
for (const c in s)
n.component.props[c] = s[c];
} else
n = S(e, s), k(n, r), E(n, t);
return { vueInstance: n, destroy: () => E(null, t), el: t };
}, K = (e, t) => {
const s = g();
return (r, i, n) => {
const o = t ? { ...t, ...i } : i;
o.addition = n;
let c = null;
return r("span", {
key: `${i.prop}-${i.rowIndex || 0}`,
ref: (m) => {
c = T(e, m, o, s, c);
}
});
};
};
class F {
constructor(t, s, r, i, n) {
this.VueEditorConstructor = t, this.column = s, this.save = r, this.close = i, this.vInstance = n, this.element = null;
}
// optional, called after editor rendered
componentDidRender() {
}
// optional, called after editor destroyed
disconnectedCallback() {
this.vueEl?.destroy(), this.vueEl = void 0;
}
render(t) {
return t("span", {
key: `${this.column.prop}-${this.editCell?.rowIndex || 0}`,
ref: (s) => {
const r = {
...this.editCell,
column: this.column,
save: this.save,
close: this.close
};
this.vueEl = T(
this.VueEditorConstructor,
s,
r,
this.vInstance
);
}
});
}
}
const j = (e) => {
const t = g();
return function(s, r, i) {
return new F(
e,
s,
r,
i,
t
);
};
};
function X(e) {
return !!e && (typeof e == "object" || typeof e == "function") && typeof e.then == "function";
}
const P = D?.(), q = z(async () => (X(P) && await P, U));
export {
q as VGrid,
j as VGridVueEditor,
K as VGridVueTemplate,
T as VGridVueTemplateConstructor,
q as default
};