UNPKG

ant-design-x-vue-next

Version:

Ant Design X for Vue — community continuation aligned with @ant-design/x

86 lines (85 loc) 2.42 kB
import { defineComponent as h, reactive as f, provide as w, watch as r, createElementBlock as x, openBlock as I, renderSlot as A, markRaw as _ } from "vue"; import { loadCatalog as S } from "./catalog.mjs"; import { boxContextKey as B } from "./context.mjs"; const M = { class: "ant-x-card-box" }, y = /* @__PURE__ */ h({ name: "AXXCardBox", __name: "Box", props: { components: { default: () => ({}) }, commands: { default: () => [] }, allowedCatalogIds: null, onAction: { type: Function } }, setup(p, { expose: g }) { const o = p; function u(e) { const t = {}; return Object.entries(e || {}).forEach(([s, n]) => { t[s] = _(n); }), t; } const d = f(/* @__PURE__ */ new Map()), i = f(/* @__PURE__ */ new Map()); let c = 0; const l = f({ components: u(o.components), commandQueue: o.commands || [], onAction: o.onAction, allowedCatalogIds: o.allowedCatalogIds, catalogMap: d, surfaceCatalogMap: i }); return w(B, l), r( () => o.components, (e) => { l.components = u(e); } ), r( () => o.onAction, (e) => { l.onAction = e; } ), r( () => o.allowedCatalogIds, (e) => { l.allowedCatalogIds = e; } ), r( () => o.commands, (e) => { const t = e || []; if (l.commandQueue = t, !t.length) { c = 0; return; } t.length < c && (c = 0); const s = t.slice(c); if (s.length) { for (const n of s) { if ("createSurface" in n) { const { surfaceId: C, catalogId: a } = n.createSurface; a && (i.set(C, a), S(a, o.allowedCatalogIds).then((m) => { d.has(a) || d.set(a, m); }).catch((m) => { console.error(`Failed to load catalog ${a}:`, m); })); } "deleteSurface" in n && i.delete(n.deleteSurface.surfaceId); } c = t.length; } }, { immediate: !0, deep: !0 } ), g({ /** Host should call this when an action is handled at app level if needed */ emitAction: (e) => { var t; return (t = o.onAction) == null ? void 0 : t.call(o, e); } }), (e, t) => (I(), x("div", M, [ A(e.$slots, "default") ])); } }); export { y as default };