UNPKG

ant-design-x-vue-next

Version:

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

2 lines (1 loc) 1.23 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./utils.js");function s(e){return e!==null&&typeof e=="object"&&typeof e.literalString=="string"}function f(e){return e!==null&&typeof e=="object"&&Array.isArray(e.explicitList)}function d(e){const[c,t]=Object.entries(e.component)[0],i={};for(const[n,o]of Object.entries(t))["child","children"].includes(n)||(l.isPathObject(o)?i[n]=o.path:s(o)?i[n]=o.literalString:i[n]=o);let r=[];return t.children?f(t.children)?r=t.children.explicitList:Array.isArray(t.children)&&(r=t.children):t.child&&(r=[t.child]),{type:c,props:i,...r.length>0&&{children:r}}}function u(e){const c=e.component,t={};for(const[r,n]of Object.entries(e))["id","component","child","children"].includes(r)||(t[r]=l.isPathObject(n)?n.path:n);const i=e.children??(e.child?[e.child]:[]);return{type:c,props:t,...i.length>0&&{children:i}}}function a(){const e=new Map;function c(t,i="v0.8"){if(!Array.isArray(t)||t.length===0)return e.get("root")??null;if(i==="v0.8")for(const r of t)e.set(r.id,d(r));else for(const r of t)e.set(r.id,u(r));return e.get("root")??null}return{transform:c,getById:t=>e.get(t),reset:()=>e.clear()}}exports.createComponentTransformer=a;