@operato/scene-legend 10.0.0-beta.22 → 10.0.0-beta.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { Component, ComponentNature, Properties, Shape } from '@hatiolab/things-scene';
1
+ import { ComponentNature, Properties, Shape } from '@hatiolab/things-scene';
2
2
  declare const LegendItem_base: (new (...args: any[]) => {
3
3
  contains(x: number, y: number): boolean;
4
4
  get path(): {
@@ -49,7 +49,7 @@ declare const LegendItem_base: (new (...args: any[]) => {
49
49
  get disposed(): boolean;
50
50
  isLayer(): boolean;
51
51
  isGroup(): boolean;
52
- isContainer(): this is import("@hatiolab/things-scene/dist-types/types/component").Container;
52
+ isContainer(): this is import("@hatiolab/things-scene").Container;
53
53
  isLine(): boolean;
54
54
  isRoot(): boolean;
55
55
  isRootModel(): boolean;
@@ -65,9 +65,9 @@ declare const LegendItem_base: (new (...args: any[]) => {
65
65
  get(property: any): any;
66
66
  set(props: any, propval?: any): any;
67
67
  getState(property: any): any;
68
- setState(props: any, propval?: any): any;
68
+ setState(props: Partial<import("@hatiolab/things-scene").State> | string, propval?: any): any;
69
69
  get model(): any;
70
- get state(): any;
70
+ get state(): import("@hatiolab/things-scene").State;
71
71
  get hierarchy(): any;
72
72
  get volatile(): never[];
73
73
  _applyProps(target: any, props: any, options: any): any;
@@ -103,7 +103,7 @@ declare const LegendItem_base: (new (...args: any[]) => {
103
103
  draw(context?: import("@hatiolab/things-scene").SceneRenderContext): void;
104
104
  prerender(context: import("@hatiolab/things-scene").SceneRenderContext): void;
105
105
  postrender(context: import("@hatiolab/things-scene").SceneRenderContext): void;
106
- prepare(resolve: (component: Component) => void, reject: (reason: any) => void): void;
106
+ prepare(resolve: (component: import("@hatiolab/things-scene").Component) => void, reject: (reason: any) => void): void;
107
107
  prepareIf(condition: boolean): void;
108
108
  drawText(context: import("@hatiolab/things-scene").SceneRenderContext): void;
109
109
  drawStroke(context: import("@hatiolab/things-scene").SceneRenderContext, override?: Record<string, unknown>): void;
@@ -154,16 +154,16 @@ declare const LegendItem_base: (new (...args: any[]) => {
154
154
  get started(): boolean;
155
155
  set started(v: boolean): any;
156
156
  get controls(): import("@hatiolab/things-scene").Control[] | undefined;
157
- findFirst(finder: string | ((c: Component) => boolean), ...others: any[]): Component | undefined;
158
- findAll(s: string | ((c: Component) => boolean), ...others: any[]): any[] | undefined;
159
- capture(x: number, y: number, except?: (c: Component) => boolean): any;
157
+ findFirst(finder: string | ((c: import("@hatiolab/things-scene").Component) => boolean), ...others: any[]): import("@hatiolab/things-scene").Component | undefined;
158
+ findAll(s: string | ((c: import("@hatiolab/things-scene").Component) => boolean), ...others: any[]): any[] | undefined;
159
+ capture(x: number, y: number, except?: (c: import("@hatiolab/things-scene").Component) => boolean): any;
160
160
  findAnchor(name: string): any;
161
- isDescendible(container: Component): boolean;
161
+ isDescendible(container: import("@hatiolab/things-scene").Component): boolean;
162
162
  getContext(component?: unknown): any;
163
- get root(): Component;
164
- get rootModel(): Component;
165
- get parent(): Component;
166
- set parent(v: Component): any;
163
+ get root(): import("@hatiolab/things-scene").Component;
164
+ get rootModel(): import("@hatiolab/things-scene").Component;
165
+ get parent(): import("@hatiolab/things-scene").Component;
166
+ set parent(v: import("@hatiolab/things-scene").Component): any;
167
167
  get scalable(): boolean;
168
168
  get stuck(): boolean;
169
169
  get capturable(): boolean;
@@ -188,20 +188,20 @@ declare const LegendItem_base: (new (...args: any[]) => {
188
188
  ondropfile(transfered: FileList, files: string[]): void;
189
189
  transcoordS2P(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
190
190
  transcoordP2S(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
191
- transcoordS2T(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
192
- transcoordT2P(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
193
- transcoordT2S(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
194
- transcoordS2TR(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
195
- transcoordS2O(x: number, y: number, target: Component): import("@hatiolab/things-scene").POINT;
196
- transcoordC2S(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
197
- transcoordS2C(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
191
+ transcoordS2T(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
192
+ transcoordT2P(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
193
+ transcoordT2S(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
194
+ transcoordS2TR(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
195
+ transcoordS2O(x: number, y: number, target: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
196
+ transcoordC2S(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
197
+ transcoordS2C(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
198
198
  toParent(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
199
199
  fromParent(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
200
- toScene(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
201
- fromScene(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
202
- toLocal(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
203
- toGlobal(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
204
- toOther(x: number, y: number, target: Component): import("@hatiolab/things-scene").POINT;
200
+ toScene(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
201
+ fromScene(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
202
+ toLocal(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
203
+ toGlobal(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
204
+ toOther(x: number, y: number, target: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
205
205
  on(name: string | object, callback: Function, context?: any): any;
206
206
  off(name?: string | object, callback?: Function, context?: any): any;
207
207
  once(name: string | object, callback: Function, context?: any): any;
@@ -211,24 +211,24 @@ declare const LegendItem_base: (new (...args: any[]) => {
211
211
  onchange(after: Record<string, any>, before: Record<string, any>): void;
212
212
  calculateBounds?(): void;
213
213
  oncreate_element?(element: HTMLElement): void;
214
- removeComponent(component: Component, ghost?: boolean): void;
215
- addComponent(component: Component, ghost?: boolean): void;
216
- insertComponentAt(component: Component, index: number, ghost?: boolean): void;
217
- getOverlay(component: Component): HTMLElement | undefined;
218
- findById(id: string): Component | undefined;
219
- findByRefid(ref: string | number): Component | undefined;
220
- findAllById(id: string): Component[];
214
+ removeComponent(component: import("@hatiolab/things-scene").Component, ghost?: boolean): void;
215
+ addComponent(component: import("@hatiolab/things-scene").Component, ghost?: boolean): void;
216
+ insertComponentAt(component: import("@hatiolab/things-scene").Component, index: number, ghost?: boolean): void;
217
+ getOverlay(component: import("@hatiolab/things-scene").Component): HTMLElement | undefined;
218
+ findById(id: string): import("@hatiolab/things-scene").Component | undefined;
219
+ findByRefid(ref: string | number): import("@hatiolab/things-scene").Component | undefined;
220
+ findAllById(id: string): import("@hatiolab/things-scene").Component[];
221
221
  resize(): void;
222
222
  fit(type?: string): void;
223
- get components(): Component[] | undefined;
223
+ get components(): import("@hatiolab/things-scene").Component[] | undefined;
224
224
  get layout(): any;
225
225
  get auxOverlay(): HTMLElement | undefined;
226
226
  get isReady(): boolean;
227
227
  get unitScale(): number;
228
- get selected(): Component[];
229
- set selected(_v: Component[]): any;
230
- get focused(): Component | null;
231
- set focused(_v: Component | null): any;
228
+ get selected(): import("@hatiolab/things-scene").Component[];
229
+ set selected(_v: import("@hatiolab/things-scene").Component[]): any;
230
+ get focused(): import("@hatiolab/things-scene").Component | null;
231
+ set focused(_v: import("@hatiolab/things-scene").Component | null): any;
232
232
  get hasSameParentForAllSelected(): boolean;
233
233
  set hasSameParentForAllSelected(_v: boolean): any;
234
234
  get fitMode(): string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"legend-item.js","sourceRoot":"","sources":["../src/legend-item.ts"],"names":[],"mappings":";AAAA;;GAEG;AACH,OAAO,EAA0C,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAEhH,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;IAChB,UAAU,EAAE,EAAE;CACf,CAAA;AAGc,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,QAAQ,CAAC,KAAK,CAAC;IACrD,MAAM,CAAC,OAAiC;QACtC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QAE7C,OAAO,CAAC,SAAS,EAAE,CAAA;QAEnB,IAAI,CAAC,GAAG,MAAM,GAAG,CAAC,CAAA;QAClB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAEb,OAAO,CAAC,IAAI,EAAE,CAAA;QAEd,OAAO,CAAC,SAAS,GAAG,KAAK,CAAA;QACzB,OAAO,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,CAAA;QACjE,OAAO,CAAC,WAAW,GAAG,kBAAkB,CAAA;QACxC,OAAO,CAAC,UAAU,GAAG,CAAC,CAAA;QACtB,OAAO,CAAC,aAAa,GAAG,CAAC,CAAA;QACzB,OAAO,CAAC,aAAa,GAAG,CAAC,CAAA;QACzB,OAAO,CAAC,IAAI,EAAE,CAAA;QAEd,OAAO,CAAC,OAAO,EAAE,CAAA;IACnB,CAAC;IAED,QAAQ,CAAC,KAAiB;QACxB,IAAI,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC;YAAE,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC3E,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,KAAK,CAAA;IACd,CAAC;IAED,IAAI,MAAM;QACR,OAAO,MAAM,CAAA;IACf,CAAC;CACF,CAAA;AArCoB,UAAU;IAD9B,cAAc,CAAC,aAAa,CAAC;GACT,UAAU,CAqC9B;eArCoB,UAAU","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\nimport { Component, ComponentNature, Properties, RectPath, Shape, sceneComponent } from '@hatiolab/things-scene'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: false,\n rotatable: false,\n properties: []\n}\n\n@sceneComponent('legend-item')\nexport default class LegendItem extends RectPath(Shape) {\n render(context: CanvasRenderingContext2D) {\n var { left, top, height, color } = this.state\n\n context.beginPath()\n\n var c = height / 2\n var r = c / 2\n\n context.save()\n\n context.fillStyle = color\n context.ellipse(left + c, top + c, r, r, 0, 0, Math.PI * 2, true)\n context.shadowColor = 'rgba(0,0,0,0.15)'\n context.shadowBlur = 2\n context.shadowOffsetX = 1\n context.shadowOffsetY = 2\n context.fill()\n\n context.restore()\n }\n\n onchange(after: Properties) {\n if (after.hasOwnProperty('height')) this.set('paddingLeft', after.height)\n }\n\n get stuck() {\n return true\n }\n\n get capturable() {\n return false\n }\n\n get nature() {\n return NATURE\n }\n}\n"]}
1
+ {"version":3,"file":"legend-item.js","sourceRoot":"","sources":["../src/legend-item.ts"],"names":[],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,IAAI,KAAK;QACP,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,KAAK,CAAA;IACd,CAAC;IAED,IAAI,MAAM;QACR,OAAO,MAAM,CAAA;IACf,CAAC;CACF,CAAA;AArCoB,UAAU;IAD9B,cAAc,CAAC,aAAa,CAAC;GACT,UAAU,CAqC9B;eArCoB,UAAU","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\nimport { ComponentNature, Properties, RectPath, Shape, sceneComponent } from '@hatiolab/things-scene'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: false,\n rotatable: false,\n properties: []\n}\n\n@sceneComponent('legend-item')\nexport default class LegendItem extends RectPath(Shape) {\n render(context: CanvasRenderingContext2D) {\n var { left, top, height, color } = this.state\n\n context.beginPath()\n\n var c = height / 2\n var r = c / 2\n\n context.save()\n\n context.fillStyle = color\n context.ellipse(left + c, top + c, r, r, 0, 0, Math.PI * 2, true)\n context.shadowColor = 'rgba(0,0,0,0.15)'\n context.shadowBlur = 2\n context.shadowOffsetX = 1\n context.shadowOffsetY = 2\n context.fill()\n\n context.restore()\n }\n\n onchange(after: Properties) {\n if (after.hasOwnProperty('height')) this.set('paddingLeft', after.height)\n }\n\n get stuck() {\n return true\n }\n\n get capturable() {\n return false\n }\n\n get nature() {\n return NATURE\n }\n}\n"]}
package/dist/legend.d.ts CHANGED
@@ -10,14 +10,7 @@ export default class Legend extends Container {
10
10
  ondragmove: (point: POSITION, index: number, component: Component) => void;
11
11
  };
12
12
  }[];
13
- get layout(): {
14
- reflow(container: import("@hatiolab/things-scene/dist-types/types/component").Container): void;
15
- capturables(container: import("@hatiolab/things-scene/dist-types/types/component").Container): import("@hatiolab/things-scene").ComponentInterface[];
16
- drawables(container: import("@hatiolab/things-scene/dist-types/types/component").Container): import("@hatiolab/things-scene").ComponentInterface[];
17
- isStuck(component: import("@hatiolab/things-scene").ComponentInterface): boolean;
18
- keyNavigate(container: import("@hatiolab/things-scene/dist-types/types/component").Container, component: import("@hatiolab/things-scene").ComponentInterface, e: KeyboardEvent): import("@hatiolab/things-scene").ComponentInterface | undefined;
19
- joinType: boolean;
20
- };
13
+ get layout(): any;
21
14
  get nature(): ComponentNature;
22
15
  rebuildLegendItems(): void;
23
16
  get hasTextProperty(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"legend.js","sourceRoot":"","sources":["../src/legend.ts"],"names":[],"mappings":";AAAA;;GAEG;AACH,OAAO,EAGL,SAAS,EACT,KAAK,EAGL,WAAW,EACX,cAAc,EACf,MAAM,wBAAwB,CAAA;AAE/B,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,MAAM;SACb;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,SAAS;SAChB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,WAAW;YAClB,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE;oBACP;wBACE,OAAO,EAAE,YAAY;wBACrB,KAAK,EAAE,YAAY;qBACpB;oBACD;wBACE,OAAO,EAAE,UAAU;wBACnB,KAAK,EAAE,UAAU;qBAClB;iBACF;aACF;SACF;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,OAAO;YACd,IAAI,EAAE,OAAO;SACd;QACD;YACE,IAAI,EAAE,eAAe;YACrB,KAAK,EAAE,EAAE;YACT,IAAI,EAAE,QAAQ;SACf;KACF;IACD,IAAI,EAAE,wBAAwB;CAC/B,CAAA;AAED,IAAI,cAAc,GAAG;IACnB,UAAU,EAAE,UAAU,KAAe,EAAE,KAAa,EAAE,SAAoB;QACxE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MA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P,YAAY,EAAE;gBACZ,IAAI;gBACJ,OAAO;aACR;SACF,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAA;IACb,CAAC;IAED,QAAQ,CAAC,KAAiB,EAAE,MAAkB;QAC5C,IAAI,CAAC,kBAAkB,EAAE,CAAA;IAC3B,CAAC;CACF,CAAA;AAzJoB,MAAM;IAD1B,cAAc,CAAC,QAAQ,CAAC;GACJ,MAAM,CAyJ1B;eAzJoB,MAAM","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\nimport {\n Component,\n ComponentNature,\n Container,\n Model,\n POSITION,\n Properties,\n TableLayout,\n sceneComponent\n} from '@hatiolab/things-scene'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'number',\n label: 'rows',\n name: 'rows'\n },\n {\n type: 'number',\n label: 'columns',\n name: 'columns'\n },\n {\n type: 'select',\n label: 'direction',\n name: 'direction',\n property: {\n options: [\n {\n display: 'Horizontal',\n value: 'horizontal'\n },\n {\n display: 'Vertical',\n value: 'vertical'\n }\n ]\n }\n },\n {\n type: 'number',\n label: 'round',\n name: 'round'\n },\n {\n type: 'legend-status',\n label: '',\n name: 'status'\n }\n ],\n help: 'scene/component/legend'\n}\n\nvar controlHandler = {\n ondragmove: function (point: POSITION, index: number, component: Component) {\n var { left, top, width, height } = component.model\n /*\n * point의 좌표는 부모 레이어 기준의 x, y 값이다.\n * 따라서, 도형의 회전을 감안한 좌표로의 변환이 필요하다.\n * Transcoord시에는 point좌표가 부모까지 transcoord되어있는 상태이므로,\n * 컴포넌트자신에 대한 transcoord만 필요하다.(마지막 파라미터를 false로).\n */\n var transcoorded = component.transcoordP2S(point.x, point.y)\n var round = ((transcoorded.x - left) / (width / 2)) * 100\n\n round = roundSet(round, width, height)\n\n component.set({ round })\n }\n}\n\nfunction roundSet(round: number, width: number, height: number) {\n var max = width > height ? (height / width) * 100 : 100\n\n if (round >= max) round = max\n else if (round <= 0) round = 0\n\n return round\n}\n\n@sceneComponent('legend')\nexport default class Legend extends Container {\n async ready() {\n await super.ready()\n\n this.rebuildLegendItems()\n }\n\n get showMoveHandle() {\n return false\n }\n\n render(context: CanvasRenderingContext2D) {\n var { round = 0 } = this.state\n\n var { left, top, width, height } = this.bounds\n\n // 박스 그리기\n context.beginPath()\n\n round = roundSet(round, width, height)\n\n if (round > 0) {\n var radius = (round / 100) * (width / 2)\n\n context.moveTo(left + radius, top)\n context.lineTo(left + width - radius, top)\n context.quadraticCurveTo(left + width, top, left + width, top + radius)\n context.lineTo(left + width, top + height - radius)\n context.quadraticCurveTo(left + width, top + height, left + width - radius, top + height)\n context.lineTo(left + radius, top + height)\n context.quadraticCurveTo(left, top + height, left, top + height - radius)\n context.lineTo(left, top + radius)\n context.quadraticCurveTo(left, top, left + radius, top)\n\n this.model.padding = {\n top: round / 2,\n left: round / 2,\n right: round / 2,\n bottom: round / 2\n }\n } else {\n context.rect(left, top, width, height)\n }\n\n this.drawFill(context)\n this.drawStroke(context)\n }\n\n get controls() {\n var { left, top, width, round, height } = this.state\n round = round == undefined ? 0 : roundSet(round, width, height)\n\n return [\n {\n x: left + (width / 2) * (round / 100),\n y: top,\n handler: controlHandler\n }\n ]\n }\n\n get layout() {\n return TableLayout\n }\n\n get nature() {\n return NATURE\n }\n\n rebuildLegendItems() {\n if (this.components.length) {\n this.components.slice().forEach((m: any) => m.dispose())\n }\n\n var {\n left,\n top,\n width,\n height,\n fillStyle,\n strokeStyle,\n fontColor,\n fontFamily,\n fontSize,\n lineHeight,\n textAlign = 'left',\n round = 0,\n italic,\n bold,\n lineWidth = 0,\n rows,\n columns,\n status = {}\n } = this.state\n\n let statusRanges: {\n min: string\n max: string\n description: string\n color: string\n }[] = status.ranges || []\n\n var count = statusRanges.length\n\n this.add(\n statusRanges.map(range =>\n Model.compile({\n type: 'legend-item',\n text: range.description || `${range.min || ''} ~ ${range.max || ''}`,\n width: 1,\n height: 1,\n color: range.color,\n fontColor,\n fontFamily,\n fontSize,\n lineHeight,\n italic,\n bold,\n textAlign\n } as any, this.app)\n )\n )\n\n var rows, columns\n\n if (!columns && !rows) {\n rows = count\n columns = 1\n } else if (columns && !rows) {\n rows = Math.ceil(count / Number(columns))\n } else if (rows && !columns) {\n columns = Math.ceil(count / Number(rows))\n }\n\n this.set({\n layoutConfig: {\n rows,\n columns\n }\n })\n }\n\n get hasTextProperty() {\n return true\n }\n\n get textHidden() {\n return true\n }\n\n onchange(after: Properties, before: Properties) {\n this.rebuildLegendItems()\n }\n}\n"]}
1
+ {"version":3,"file":"legend.js","sourceRoot":"","sources":["../src/legend.ts"],"names":[],"mappings":";AAAA;;GAEG;AACH,OAAO,EAGL,SAAS,EACT,KAAK,EAGL,WAAW,EACX,cAAc,EACf,MAAM,wBAAwB,CAAA;AAE/B,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,MAAM;SACb;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,SAAS;SAChB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,WAAW;YAClB,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE;oBACP;wBACE,OAAO,EAAE,YAAY;wBACrB,KAAK,EAAE,YAAY;qBACpB;oBACD;wBACE,OAAO,EAAE,UAAU;wBACnB,KAAK,EAAE,UAAU;qBAClB;iBACF;aACF;SACF;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,OAAO;YACd,IAAI,EAAE,OAAO;SACd;QACD;YACE,IAAI,EAAE,eAAe;YACrB,KAAK,EAAE,EAAE;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AC,CAAA;QAC3C,CAAC;aAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAC5B,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;QAC3C,CAAC;QAED,IAAI,CAAC,GAAG,CAAC;YACP,YAAY,EAAE;gBACZ,IAAI;gBACJ,OAAO;aACR;SACF,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAA;IACb,CAAC;IAED,QAAQ,CAAC,KAAiB,EAAE,MAAkB;QAC5C,IAAI,CAAC,kBAAkB,EAAE,CAAA;IAC3B,CAAC;CACF,CAAA;AAzJoB,MAAM;IAD1B,cAAc,CAAC,QAAQ,CAAC;GACJ,MAAM,CAyJ1B;eAzJoB,MAAM","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\nimport {\n Component,\n ComponentNature,\n Container,\n Model,\n POSITION,\n Properties,\n TableLayout,\n sceneComponent\n} from '@hatiolab/things-scene'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'number',\n label: 'rows',\n name: 'rows'\n },\n {\n type: 'number',\n label: 'columns',\n name: 'columns'\n },\n {\n type: 'select',\n label: 'direction',\n name: 'direction',\n property: {\n options: [\n {\n display: 'Horizontal',\n value: 'horizontal'\n },\n {\n display: 'Vertical',\n value: 'vertical'\n }\n ]\n }\n },\n {\n type: 'number',\n label: 'round',\n name: 'round'\n },\n {\n type: 'legend-status',\n label: '',\n name: 'status'\n }\n ],\n help: 'scene/component/legend'\n}\n\nvar controlHandler = {\n ondragmove: function (point: POSITION, index: number, component: Component) {\n var { left, top, width, height } = component.model\n /*\n * point의 좌표는 부모 레이어 기준의 x, y 값이다.\n * 따라서, 도형의 회전을 감안한 좌표로의 변환이 필요하다.\n * Transcoord시에는 point좌표가 부모까지 transcoord되어있는 상태이므로,\n * 컴포넌트자신에 대한 transcoord만 필요하다.(마지막 파라미터를 false로).\n */\n var transcoorded = component.transcoordP2S(point.x, point.y)\n var round = ((transcoorded.x - left) / (width / 2)) * 100\n\n round = roundSet(round, width, height)\n\n component.set({ round })\n }\n}\n\nfunction roundSet(round: number, width: number, height: number) {\n var max = width > height ? (height / width) * 100 : 100\n\n if (round >= max) round = max\n else if (round <= 0) round = 0\n\n return round\n}\n\n@sceneComponent('legend')\nexport default class Legend extends Container {\n async ready() {\n await super.ready()\n\n this.rebuildLegendItems()\n }\n\n get showMoveHandle() {\n return false\n }\n\n render(context: CanvasRenderingContext2D) {\n var { round = 0 } = this.state\n\n var { left, top, width, height } = this.bounds\n\n // 박스 그리기\n context.beginPath()\n\n round = roundSet(round, width, height)\n\n if (round > 0) {\n var radius = (round / 100) * (width / 2)\n\n context.moveTo(left + radius, top)\n context.lineTo(left + width - radius, top)\n context.quadraticCurveTo(left + width, top, left + width, top + radius)\n context.lineTo(left + width, top + height - radius)\n context.quadraticCurveTo(left + width, top + height, left + width - radius, top + height)\n context.lineTo(left + radius, top + height)\n context.quadraticCurveTo(left, top + height, left, top + height - radius)\n context.lineTo(left, top + radius)\n context.quadraticCurveTo(left, top, left + radius, top)\n\n this.model.padding = {\n top: round / 2,\n left: round / 2,\n right: round / 2,\n bottom: round / 2\n }\n } else {\n context.rect(left, top, width, height)\n }\n\n this.drawFill(context)\n this.drawStroke(context)\n }\n\n get controls() {\n var { left, top, width, round, height } = this.state\n round = round == undefined ? 0 : roundSet(round, width, height)\n\n return [\n {\n x: left + (width / 2) * (round / 100),\n y: top,\n handler: controlHandler\n }\n ]\n }\n\n get layout(): any {\n return TableLayout\n }\n\n get nature() {\n return NATURE\n }\n\n rebuildLegendItems() {\n if (this.components.length) {\n this.components.slice().forEach((m: any) => m.dispose())\n }\n\n var {\n left,\n top,\n width,\n height,\n fillStyle,\n strokeStyle,\n fontColor,\n fontFamily,\n fontSize,\n lineHeight,\n textAlign = 'left',\n round = 0,\n italic,\n bold,\n lineWidth = 0,\n rows,\n columns,\n status = {}\n } = this.state\n\n let statusRanges: {\n min: string\n max: string\n description: string\n color: string\n }[] = status.ranges || []\n\n var count = statusRanges.length\n\n this.add(\n statusRanges.map(range =>\n Model.compile({\n type: 'legend-item',\n text: range.description || `${range.min || ''} ~ ${range.max || ''}`,\n width: 1,\n height: 1,\n color: range.color,\n fontColor,\n fontFamily,\n fontSize,\n lineHeight,\n italic,\n bold,\n textAlign\n } as any, this.app)\n )\n )\n\n var rows, columns\n\n if (!columns && !rows) {\n rows = count\n columns = 1\n } else if (columns && !rows) {\n rows = Math.ceil(count / Number(columns))\n } else if (rows && !columns) {\n columns = Math.ceil(count / Number(rows))\n }\n\n this.set({\n layoutConfig: {\n rows,\n columns\n }\n })\n }\n\n get hasTextProperty() {\n return true\n }\n\n get textHidden() {\n return true\n }\n\n onchange(after: Properties, before: Properties) {\n this.rebuildLegendItems()\n }\n}\n"]}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@operato/scene-legend",
3
3
  "description": "Legend component for things-scene.",
4
4
  "author": "heartyoh",
5
- "version": "10.0.0-beta.22",
5
+ "version": "10.0.0-beta.30",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.js",
@@ -60,5 +60,5 @@
60
60
  "prettier --write"
61
61
  ]
62
62
  },
63
- "gitHead": "f48e52f4f5fdc30ec06af9da7cf253f6e29cfb0e"
63
+ "gitHead": "06b35b1726ec4f27ee76657ce341c6c6f3ba1b3a"
64
64
  }