@expofp/floorplan
Version:
Interactive floor plan library for expos and events
2 lines (1 loc) • 1.53 kB
JavaScript
import{select as d}from"d3-selection";import{getLayerSvg as m,gtePathByIndex as p}from"../../../../data/svg";import{meshToShapeDef as g,rectToShapeDef as i}from"../../../../renderer";import h from"../../../../store";import{LayersMode as u}from"../../../../store/LayerStore";export const BG_LAYER_NAME="bg",FG_LAYER_NAME="fg";export default async function x(t){let o=[],n=[];const a=[],r=d(m(t)).select(`[data-layer="${t.name}"]`),c=r.selectAll(":scope > *:not([data-tagname='efp-booth']):not(g[data-is-editable='false']) path, :scope > path").nodes(),f=r.selectAll(":scope g[data-layer] > g[data-is-editable='false'] path, :scope > g[data-is-editable='false'] path, :scope > path[data-tagname='ptext']").nodes(),l=h.layerStore.mode!==u.Default?t.rootParent?.name||t.name:"";for(const e of c){const s=+e.getAttribute("data-index");e.tagName==="path"&&s!==-1?o.push(buildPathDef({color:e.style.fill,index:s},l)):e.tagName==="rect"&&o.push(i(e))}for(const e of f){const s=+e.getAttribute("data-index");e.tagName==="path"&&s!==-1?n.push(buildPathDef({color:e.style.fill,index:s},l)):e.tagName==="rect"&&n.push(i(e))}return a.push({name:BG_LAYER_NAME,children:o.filter(e=>e)}),a.push({name:FG_LAYER_NAME,children:n.filter(e=>e)}),Promise.resolve({name:t.name,children:a.filter(e=>e.children.length)})}export function buildPathDef(t,o){if(t.index===-1||Number.isNaN(t.index))return;(!t.color||t.color==="none")&&(t.color="transparent");const n=parseInt(t.index.toString()),a=p(n,o),r=g(a,t.color);return r.unblinking=t.unblinking,r}