UNPKG

ant-design-x-vue-next

Version:

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

2 lines (1 loc) 1.55 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),C=require("./catalog.js"),h=require("./context.js"),w={class:"ant-x-card-box"},_=t.defineComponent({name:"AXXCardBox",__name:"Box",props:{components:{default:()=>({})},commands:{default:()=>[]},allowedCatalogIds:null,onAction:{type:Function}},setup(f,{expose:p}){const o=f;function m(e){const a={};return Object.entries(e||{}).forEach(([r,n])=>{a[r]=t.markRaw(n)}),a}const d=t.reactive(new Map),i=t.reactive(new Map);let s=0;const l=t.reactive({components:m(o.components),commandQueue:o.commands||[],onAction:o.onAction,allowedCatalogIds:o.allowedCatalogIds,catalogMap:d,surfaceCatalogMap:i});return t.provide(h.boxContextKey,l),t.watch(()=>o.components,e=>{l.components=m(e)}),t.watch(()=>o.onAction,e=>{l.onAction=e}),t.watch(()=>o.allowedCatalogIds,e=>{l.allowedCatalogIds=e}),t.watch(()=>o.commands,e=>{const a=e||[];if(l.commandQueue=a,!a.length){s=0;return}a.length<s&&(s=0);const r=a.slice(s);if(r.length){for(const n of r){if("createSurface"in n){const{surfaceId:g,catalogId:c}=n.createSurface;c&&(i.set(g,c),C.loadCatalog(c,o.allowedCatalogIds).then(u=>{d.has(c)||d.set(c,u)}).catch(u=>{console.error(`Failed to load catalog ${c}:`,u)}))}"deleteSurface"in n&&i.delete(n.deleteSurface.surfaceId)}s=a.length}},{immediate:!0,deep:!0}),p({emitAction:e=>{var a;return(a=o.onAction)==null?void 0:a.call(o,e)}}),(e,a)=>(t.openBlock(),t.createElementBlock("div",w,[t.renderSlot(e.$slots,"default")]))}});exports.default=_;