UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) • 3.71 kB
import{__decorate as f}from"tslib";import{Rect as C}from"@expofp/geometry";import{update as B}from"@expofp/renderer";import s from"color";import S from"color-interpolate";import{computed as d}from"mobx";import m from"../../../../data";import{getFpSvgJs as y}from"../../../../data/fp-payloads";import{createShapeDef as k}from"../../../../engine/defs";import D,{boothStore as I,heatmapStore as L,layersStore as u,uiState as i}from"../../../../store";import{LayersMode as P}from"../../../../store/LayerStore";import l from"../../../../tools/settings";import{planReaction as g}from"../../../../utils/plan-reactions.js";import{getBoothStatusColor as v}from"./booth-fill-color.js";import{BoothDrawerBaseWithoutPainter as w}from"./BoothDrawerBase";import{buildPathDef as x}from"./config-bg";export default function A(h){return new n(h)}export function pathToShapeDef(h,o){const e=[];for(const t of h){const r=x({index:t.index,color:t.color,unblinking:t.unblinking},o);r&&e.push(r)}return e}class n extends w{constructor(o){if(super(o),o.paths){const e=pathToShapeDef(o.paths,D.layerStore.mode!==P.Default?o.layer.name:"");o.shapes=e.map(t=>{const r=i.monochrome?s(t.color).grayscale().rgb().string():this.getBoothColor().string();return t.color==="transparent"?t.color=r:t.defaultColor=t.color,t})}else{const e=o.borderColor==="none"?0:isNaN(o.borderWidth)?I.borderWidth:o.borderWidth,t=this.booth.rect.expand(-e/2),r=this.getBoothColor().string();o.shapes=[k(new C(t.center,t.size,this.booth.rotate,this.booth.elevation),r)]}g(()=>this.booth.hover,()=>!this.booth.selected&&this.update()),g(()=>[u.layersLoaded,this.booth.skipDim,this.booth.selected,this.boothShape.selectBgAnimationPart],()=>this.update())}getShape(){return this.booth.shapes}update(){if(u.layersLoaded)for(const o of this.booth.shapes){if(o.dim=this.booth.skipDim?0:void 0,o.color&&!o.unblinking){const e=o.defaultColor?this.getBoothPathColor(o.defaultColor):this.getBoothColor();o.color=e.string()}B(o)}}get poiHighlighted(){const o=this.booth;return!o.selected&&o.poiTypeId!=null&&o.skipDim}getBoothPathColor(o){if(i.heatmap)return this.getHeatmapColor();const e=this.booth,t=l.colors.booths.selected;let r=s(this.poiHighlighted?t:o).hsl();if(e.selected){if(y().__fpSettings?.fpVer){const c=this.selectedColorInterpolateFunc(this.boothShape.selectBgAnimationPart),p=s(c==="none"?t:c);return i.monochrome?p.grayscale():p}const a=s(t).hsl(),b=a.lightness()*this.boothShape.selectBgAnimationPart;r=r.hue(a.hue()).lightness(b)}else e.hover&&(r=r.darken(.1));return i.monochrome&&(r=r.grayscale()),r}getHeatmapColor(){const o=this.booth,e=L.getHeatmapColorForBooth(o);if(o.selected){const t=this.selectedColorInterpolateFunc(this.boothShape.selectBgAnimationPart);return s(t==="none"?"#f33":t)}return o.hover?e.darken(.2).alpha(e.alpha()*1.5):e}get defaultColor(){return v(this.booth)}get selectedColorInterpolateFunc(){const o=l.colors.booths.seectedLight||(s(this.booth.labelColor||l.boothLabelColor).isLight()?"#000":"#fff"),e=i.selectedRoute?l?.colors?.booths?.wayfinding?.selected:l?.colors?.booths?.selected;return S([o,e])}getBoothColor(){const o=this.booth;if(i.heatmap)return this.getHeatmapColor();let e;o.error?e="#f33":m.isRebooking?e=this.defaultColor:o.selected?e=this.selectedColorInterpolateFunc(this.boothShape.selectBgAnimationPart):this.poiHighlighted?e=l.colors.booths.selected:e=this.defaultColor;let t;try{t=s(e==="none"?"#f33":e)}catch{t=s(this.defaultColor)}return(o.hover&&!o.selected||o.selected&&m.isRebooking)&&(t=t.darken(.2).alpha(t.alpha()*1.5)),(i.monochrome||i.heatmapYah)&&(t=t.grayscale()),t}}f([d({keepAlive:!0})],n.prototype,"defaultColor",null),f([d({keepAlive:!0})],n.prototype,"selectedColorInterpolateFunc",null);