dcim-topology2d 2.0.7 → 2.1.0

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.
Files changed (53) hide show
  1. package/chart-diagram/src/echarts/index.js +4 -1
  2. package/chart-diagram/src/utils/changeOptions.d.ts +1 -0
  3. package/chart-diagram/src/utils/changeOptions.js +49 -35
  4. package/chart-diagram/src/utils/conversion.d.ts +1 -0
  5. package/chart-diagram/src/utils/conversion.js +182 -22
  6. package/chart-diagram/src/utils/formatter.d.ts +1 -1
  7. package/chart-diagram/src/utils/formatter.js +96 -19
  8. package/chart-diagram/src/utils/index.d.ts +1 -0
  9. package/chart-diagram/src/utils/index.js +1 -0
  10. package/chart-diagram/src/utils/render.d.ts +1 -1
  11. package/chart-diagram/src/utils/render.js +47 -27
  12. package/chart-diagram/src/utils/surfaceParametricConversion.d.ts +3 -0
  13. package/chart-diagram/src/utils/surfaceParametricConversion.js +252 -0
  14. package/core/src/canvas.js +4 -3
  15. package/core/src/common.js +16 -10
  16. package/core/src/core.d.ts +2 -0
  17. package/core/src/core.js +61 -23
  18. package/core/src/element/common.d.ts +2 -1
  19. package/core/src/element/common.js +15 -15
  20. package/core/src/element/datePicker.d.ts +3 -0
  21. package/core/src/element/datePicker.js +47 -0
  22. package/core/src/element/index.d.ts +2 -1
  23. package/core/src/element/index.js +3 -1
  24. package/core/src/element/select.js +14 -2
  25. package/core/src/element/tab.js +14 -12
  26. package/core/src/element/time.d.ts +3 -0
  27. package/core/src/element/time.js +44 -0
  28. package/core/src/middles/default.js +8 -2
  29. package/core/src/middles/nodes/formDatePicker.d.ts +2 -0
  30. package/core/src/middles/nodes/formDatePicker.js +66 -0
  31. package/core/src/middles/nodes/formselect.js +7 -0
  32. package/core/src/middles/nodes/index.d.ts +3 -1
  33. package/core/src/middles/nodes/index.js +3 -0
  34. package/core/src/middles/nodes/time.d.ts +2 -0
  35. package/core/src/middles/nodes/time.js +98 -0
  36. package/core/src/models/node.js +27 -4
  37. package/core/src/preview.d.ts +1 -0
  38. package/core/src/preview.js +30 -6
  39. package/core/src/renderLayer.js +13 -2
  40. package/core/src/store/data.d.ts +10 -2
  41. package/core/src/store/data.js +14 -5
  42. package/core/src/utils/assignment.d.ts +2 -1
  43. package/core/src/utils/assignment.js +29 -12
  44. package/core/src/utils/conversion.d.ts +3 -1
  45. package/core/src/utils/conversion.js +46 -3
  46. package/core/src/utils/onmousevent.js +15 -12
  47. package/core/src/utils/params.js +5 -0
  48. package/package.json +1 -1
  49. package/static/echartsDefaultData.js +15 -4
  50. package/style/common.css +0 -3
  51. package/style/datePicker.css +44 -0
  52. package/style/editor.css +3 -0
  53. package/style/index.css +1 -0
@@ -35,20 +35,20 @@ export function createDiv(node) {
35
35
  return div;
36
36
  }
37
37
 
38
- // export function loadJS(url, callback, render) {
39
- // var loaderScript = document.createElement('script');
40
- // loaderScript.type = 'text/javascript';
41
- // loaderScript.src = url;
42
- // loaderScript.addEventListener('load', function () {
43
- // if (callback) {
44
- // callback();
45
- // }
46
- // // how to do
47
- // if (render) {
48
- // Store.set('LT:render', true);
49
- // }
50
- // });
51
- // document.body.appendChild(loaderScript);
52
- // }
38
+ export function loadJS(url) {
39
+ var loaderScript = document.createElement('script');
40
+ loaderScript.type = 'text/javascript';
41
+ loaderScript.src = url;
42
+ document.body.appendChild(loaderScript);
43
+ window.datePickerRegister = true;
44
+ return new Promise((resolve, reject) => {
45
+ loaderScript.onload = function () {
46
+ resolve(true);
47
+ };
48
+ loaderScript.onerror = (e) => {
49
+ reject(e);
50
+ };
51
+ });
52
+ }
53
53
 
54
54
  //# sourceMappingURL=dom.js.map
@@ -0,0 +1,3 @@
1
+ import { Node } from '../models';
2
+ export declare function createDatePickerElement(node: Node): HTMLElement;
3
+ export declare function setDataPickerElementStyle(node: Node): void;
@@ -0,0 +1,47 @@
1
+ import {commonStore} from "../store";
2
+ // 创建datePicker依赖DOM
3
+ export function createDatePickerElement(node) {
4
+ const pickerBarEle = document.createElement('div');
5
+ pickerBarEle.setAttribute('id', node.id);
6
+ pickerBarEle.setAttribute('class', 'topology-datePicker');
7
+ pickerBarEle.innerHTML = `<svg class="icon-date" viewBox="0 0 14 14" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="14.000000" height="14.000000" fill="none" customFrame="#000000">
8
+ \t<path id="icon-日历" d="M13.4167 1.16667L10.5 1.16667L10.5 0L9.33333 0L9.33333 1.16667L4.66667 1.16667L4.66667 0L3.5 0L3.5 1.16667L0.583333 1.16667C0.2625 1.16667 0 1.42917 0 1.75L0 13.4167C0 13.7375 0.2625 14 0.583333 14L13.4167 14C13.7375 14 14 13.7375 14 13.4167L14 1.75C14 1.42917 13.7375 1.16667 13.4167 1.16667ZM12.8333 12.8333L1.16667 12.8333L1.16667 4.66667L12.8333 4.66667L12.8333 12.8333ZM4.66667 7L2.33333 7L2.33333 5.83333L4.66667 5.83333L4.66667 7ZM8.16667 7L5.83333 7L5.83333 5.83333L8.16667 5.83333L8.16667 7ZM11.6667 7L9.33333 7L9.33333 5.83333L11.6667 5.83333L11.6667 7ZM4.66667 9.33333L2.33333 9.33333L2.33333 8.16667L4.66667 8.16667L4.66667 9.33333ZM8.16667 9.33333L5.83333 9.33333L5.83333 8.16667L8.16667 8.16667L8.16667 9.33333ZM11.6667 9.33333L9.33333 9.33333L9.33333 8.16667L11.6667 8.16667L11.6667 9.33333ZM4.66667 11.6667L2.33333 11.6667L2.33333 10.5L4.66667 10.5L4.66667 11.6667ZM8.16667 11.6667L5.83333 11.6667L5.83333 10.5L8.16667 10.5L8.16667 11.6667Z" fill="rgb(64,244,255)" fill-rule="nonzero" />
9
+ </svg>
10
+ <svg class="icon-arrow" viewBox="0 0 10 6" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="10.000000" height="6.000000" fill="none" customFrame="#000000">
11
+ <path id="箭头" d="M5 0C5.14734 0 5.28865 0.0632141 5.39284 0.175736L9.83728 4.97574C10.0542 5.21005 10.0542 5.58995 9.83728 5.82426C9.62032 6.05858 9.26857 6.05858 9.05161 5.82426L5 1.44853L0.948393 5.82426C0.731435 6.05858 0.379676 6.05858 0.162718 5.82426C-0.0542395 5.58995 -0.0542395 5.21005 0.162718 4.97574L4.60716 0.175736C4.71135 0.0632141 4.85266 0 5 0Z" fill="rgb(23,206,230)" fill-rule="evenodd" transform="matrix(1,0,0,-1,0,6)" />
12
+ </svg>
13
+ <input id='picker${node.id}' class="dataPickerInput" type="text" name='dataPicker${node.id}' placeholder="请选择" readonly />`;
14
+
15
+ return pickerBarEle;
16
+ }
17
+
18
+ // datePicker样式配置
19
+ export function setDataPickerElementStyle(node) {
20
+ const {pickerDataPool, data} = commonStore[node.TID];
21
+ const pickerDom = pickerDataPool[node.id].dom;
22
+
23
+ pickerDom.container.style.border = `${node.lineWidth}px solid ${node.strokeStyle}`;
24
+ pickerDom.container.style.borderRadius = `${node.borderRadius * 100}px`;
25
+ pickerDom.container.style.padding = `${node.paddingTop}px ${node.paddingRight}px ${node.paddingBottom}px ${node.paddingLeft}px`;
26
+
27
+ if (!pickerDom.iconDate) pickerDom.iconDate = pickerDom.container.querySelector('.icon-date');
28
+ if (!pickerDom.iconArrow) pickerDom.iconArrow = pickerDom.container.querySelector('.icon-arrow');
29
+ if (!pickerDom.input) pickerDom.input = pickerDom.container.querySelector('.dataPickerInput');
30
+
31
+ const round = `${node.font.fontSize + data.scale * 2}px`;
32
+ const parts = node.strokeStyle.match(/([\d.]+)/g);
33
+ const fillColor = parts ? `rgba(${parts[0]},${parts[1]},${parts[2]},1)` : node.strokeStyle;
34
+
35
+ pickerDom.iconDate.style.width = round;
36
+ pickerDom.iconDate.style.height = round;
37
+ pickerDom.iconDate.style.left = `${node.font.fontSize}px`;
38
+ pickerDom.iconDate.querySelector('path').style.fill = fillColor;
39
+
40
+ pickerDom.iconArrow.style.width = `${node.font.fontSize - data.scale * 2}px`;
41
+ pickerDom.iconArrow.style.height = `${node.font.fontSize - data.scale * 6}px`;
42
+ pickerDom.iconArrow.style.right = `${node.font.fontSize - data.scale * 2}px`;
43
+ pickerDom.iconArrow.querySelector('path').style.fill = fillColor;
44
+
45
+ pickerDom.input.style.fontSize = `${node.font.fontSize}px`;
46
+ pickerDom.input.style.color = node.font.color;
47
+ };
@@ -1,4 +1,5 @@
1
1
  export * from './common';
2
2
  export * from './iframe';
3
3
  export * from './select';
4
- export * from './tab';
4
+ export * from './tab';
5
+ export * from './datePicker';
@@ -1,4 +1,6 @@
1
1
  export * from './common';
2
2
  export * from './iframe';
3
3
  export * from './select';
4
- export * from './tab';
4
+ export * from './tab';
5
+ export * from './time';
6
+ export * from './datePicker';
@@ -206,14 +206,26 @@ export function getSelectedData(e, data, editData) {
206
206
  }
207
207
  if(staticType === selectStaticType.visible) {
208
208
  // 显示隐藏
209
+ const optionNode = data.formData.bindBlockId && currentStore.echartsOptionsPool[data.formData.bindBlockId];
210
+ if(optionNode) {
211
+ // 有绑定图表则切换图表数据
212
+ const selecteRealData = currentStore.selectRealDataPool[optionNode.data.id];
213
+
214
+ selectNode.node.selected.id = selecteRealData && selecteRealData[order] && selecteRealData[order].id;
215
+
216
+ currentStore.echartsRealDataPool[optionNode.data.id] = currentStore.echartsRealDataPool[node.id];
217
+
218
+ setMapDataOptions(optionNode.option, optionNode.data);
219
+ }
209
220
  const optionsVisibleData = currentStore.selectTabDataPool[data.id];
210
221
  if(!optionsVisibleData || !optionsVisibleData.size) return;
211
222
  for(const [key, value] of optionsVisibleData){
212
- const eque = node.id === value.tag;
223
+ const optionId = node.optionId || node.id;
224
+ const eque = optionId === value.tag;
213
225
  currentStore.data.pens[value.order].visible = eque;
214
226
  currentStore.data.pens[value.order].visibleSwitch = eque;
215
227
  value.visible = eque;
216
- setElementSwitchTabState(value);
228
+ setElementSwitchTabState(currentStore.data.pens[value.order]);
217
229
  }
218
230
  Store.set(`${data.TID}-LT:render`, true);
219
231
  }
@@ -2,22 +2,24 @@ import {jsonLength} from '../utils';
2
2
  import {commonStore} from "../store";
3
3
  // 设置tab切换显示隐藏时的 Dom元件状态
4
4
  export function setElementSwitchTabState(node) {
5
- if(node.name !== 'echarts' && (!node.children || !node.children.length)) return;
6
- if(typeof commonStore[node.TID].elementInteractivePoor.elementDataLength !== 'number') {
7
- commonStore[node.TID].elementInteractivePoor.elementDataLength = jsonLength(commonStore[node.TID].echartsDataPool) || jsonLength(commonStore[node.TID].selectDataPool);
8
- }
9
- if(!commonStore[node.TID].elementInteractivePoor.elementDataLength) return;
10
- const ele = commonStore[node.TID].echartsDataPool[node.id] && commonStore[node.TID].echartsDataPool[node.id].div ||
11
- commonStore[node.TID].selectDataPool[node.id] && commonStore[node.TID].selectDataPool[node.id].dom.selectEle;
12
- if(ele) {
13
- ele.style.display = !node.visible ? 'none': 'block';
14
- }else {
15
- commonStore[node.TID].data.dataResize = 1;
16
- }
17
5
  if(node.children && node.children.length) {
18
6
  node.children.map((ch) => {
19
7
  ch.visible = node.visible;
8
+ ch.visibleSwitch = node.visible;
20
9
  setElementSwitchTabState(ch);
21
10
  })
22
11
  }
12
+ if(!(node.name === 'echarts' || node.name === 'select')) return;
13
+ const currentStore = commonStore[node.TID];
14
+ if(typeof currentStore.elementInteractivePoor.elementDataLength !== 'number') {
15
+ currentStore.elementInteractivePoor.elementDataLength = jsonLength(currentStore.echartsDataPool) || jsonLength(currentStore.selectDataPool);
16
+ }
17
+ if(!currentStore.elementInteractivePoor.elementDataLength) return;
18
+ const ele = currentStore.echartsDataPool[node.id] && currentStore.echartsDataPool[node.id].div ||
19
+ currentStore.selectDataPool[node.id] && currentStore.selectDataPool[node.id].dom.selectEle;
20
+ if(ele) {
21
+ ele.style.display = !node.visible ? 'none': 'block';
22
+ }else {
23
+ currentStore.data.dataResize = 1;
24
+ }
23
25
  }
@@ -0,0 +1,3 @@
1
+ import { Node } from '../models';
2
+
3
+ export declare function createTimeElement(node: Node): HTMLTimeElement;
@@ -0,0 +1,44 @@
1
+ // 创建时间组件
2
+ export function createTimeElement(node) {
3
+ const timeBox = document.createElement('div');
4
+ // timeBox.scrolling = 'no';
5
+ timeBox.width = node.rect.width;
6
+ timeBox.height = node.rect.height;
7
+ let children =
8
+ `<div class="timeWrapper" style="display: flex;flex-direction: initial; justify-content: center; font-size: ${node.font.fontSize}px;width:100%;height:100%; line-height:${timeBox.height}px; color:${node.font.color}; font-family:${node.font.fontFamily}">`+
9
+ `<div class="timeList" style="position: relative;display: flex; flex-direction: column;flex:4;height: 100%;overflow: hidden;text-align: center;">
10
+ <div class="timeBox" style="position: relative;width: 100%;height: 100%;overflow: hidden;">
11
+ <div class="timeTextUp h" style="position: relative;clip-path: polygon(0 0,100% 0,100% 49%,0 49%); background-color: rgba(255,255,255,0.1);border-radius: 20px;height: 100%;">${node.h}</div>
12
+ <div class="timeTextDown h" style="position: absolute;clip-path: polygon(0 51%,100% 51%,100% 100%,0 100%);left: 0;top: 0;width: 100%;height: 100%; background-color: rgba(255,255,255,0.1);border-radius: 20px;">${node.h}</div>
13
+ </div>
14
+ </div>`+
15
+ `<div class="split" style="flex:1; position: relative;line-height:${timeBox.height}px">:</div>`+
16
+ `<div class="timeList" style="position: relative;display: flex; flex-direction: column;flex:4;height: 100%;overflow: hidden;text-align: center;">
17
+ <div class="timeBox" style="position: relative;width: 100%;height: 100%;overflow: hidden;">
18
+ <div class="timeTextUp m" style="position: relative;clip-path: polygon(0 0,100% 0,100% 49%,0 49%); background-color: rgba(255,255,255,0.1);border-radius: 20px; height: 100%;">${node.m}</div>
19
+ <div class="timeTextDown m" style="position: absolute;clip-path: polygon(0 51%,100% 51%,100% 100%,0 100%);left: 0;top: 0;width: 100%;height: 100%; background-color: rgba(255,255,255,0.1);border-radius: 20px;">${node.m}</div>
20
+ </div>
21
+ </div>`+
22
+ `<div class="split" style="flex:1; position: relative;line-height:${timeBox.height}px">:</div>`+
23
+ `<div class="timeList" style="position: relative;display: flex; flex-direction: column;flex:4;height: 100%;overflow: hidden;text-align: center;">
24
+ <div class="timeBox" style="position: relative;width: 100%;height: 100%;overflow: hidden;">
25
+ <div class="timeTextUp s" style="position: relative;clip-path: polygon(0 0,100% 0,100% 49%,0 49%); background-color: rgba(255,255,255,0.1);border-radius: 20px; height: 100%;">${node.s}</div>
26
+ <div class="timeTextDown s" style="position: absolute;clip-path: polygon(0 51%,100% 51%,100% 100%,0 100%);left: 0;top: 0;width: 100%;height: 100%; background-color: rgba(255,255,255,0.1);border-radius: 20px;">${node.s}</div>
27
+ </div>
28
+ </div>`+
29
+ `</div>`
30
+ timeBox.setAttribute('id', node.id);
31
+ timeBox.setAttribute('class', 'topology2dConfTime');
32
+ timeBox.innerHTML = children;
33
+ return timeBox;
34
+ }
35
+ export function updateTimeStyle(node, time) {
36
+ time.querySelector('.timeWrapper').style.lineHeight = node.rect.height+'px';
37
+ time.querySelector('.timeWrapper').style.fontSize = node.font.fontSize+'px';
38
+ time.querySelector('.timeWrapper').style.fontFamily = node.font.fontFamily;
39
+ time.querySelector('.timeWrapper').style.color = node.font.color;
40
+ time.querySelectorAll('.split').forEach(element => {
41
+ element.style.lineHeight = node.rect.height+'px';
42
+ });
43
+
44
+ }
@@ -5,7 +5,7 @@ import {
5
5
  twowayArrow, twowayArrowIconRect, twowayArrowTextRect,
6
6
  rectangle, rectangleIconRect, rectangleTextRect,
7
7
  diamond, diamondIconRect, diamondTextRect,
8
- text, file, formtable, tablePagination, iframePrimeval,formSelect,
8
+ text, file, formtable, tablePagination, iframePrimeval,formSelect, fromDatePicker,
9
9
  line as nodeLine, lineAnchors, lineIconRect, lineTextRect,
10
10
  circle, circleIconRect, circleTextRect, circleAnchors,
11
11
  triangle, triangleIconRect, triangleTextRect, triangleAnchors,
@@ -17,7 +17,7 @@ import {
17
17
  imageIconRect, imageTextRect,
18
18
  cube, cubeAnchors, cubeIconRect, cubeTextRect,
19
19
  people, peopleIconRect, peopleTextRect,
20
- arbitraryGraph, arbitraryGraphAnchors,
20
+ arbitraryGraph, arbitraryGraphAnchors,time
21
21
  } from './nodes';
22
22
  import {
23
23
  line,
@@ -62,6 +62,8 @@ export var drawArrowFns = {};
62
62
  function init() {
63
63
  console.log('Init middles.');
64
64
  // ********Default nodes.*******
65
+ // datePicker
66
+ drawNodeFns.datePicker = fromDatePicker;
65
67
  // select
66
68
  drawNodeFns.select = formSelect;
67
69
  // iframe
@@ -199,6 +201,10 @@ function init() {
199
201
  drawArrowFns.lineUp = lineUp;
200
202
  drawArrowFns.lineDown = lineDown;
201
203
  // ********end********
204
+ // 当前时间
205
+ drawNodeFns.time = time;
206
+ iconRectFns.time = rectangleIconRect;
207
+ textRectFns.time = rectangleTextRect;
202
208
  }
203
209
  init();
204
210
  // registerNode: Register a custom node.
@@ -0,0 +1,2 @@
1
+ import { Node } from '../../models';
2
+ export declare function fromDatePicker(ctx: CanvasRenderingContext2D, node: Node): void;
@@ -0,0 +1,66 @@
1
+ import {Store} from 'le5le-store';
2
+ import {rectangle} from './rectangle';
3
+ import { createDatePickerElement, loadJS, setDataPickerElementStyle } from '../../element';
4
+ import { s8 } from '../../utils';
5
+ import {commonStore} from "../../store";
6
+
7
+ export async function fromDatePicker(ctx, node) {
8
+ // 绘制一个底图,类似于占位符。
9
+ rectangle(ctx, node);
10
+
11
+ if (!window.datePickerRegister) {
12
+ //未注册datePicker插件
13
+ const datePickerRegisterData = await loadJS(`${window.location.origin}/libary/laydate/laydate.js`).catch((e) => {
14
+ console.error('datePicker插件加载失败>>>', e);
15
+ });
16
+ if(!datePickerRegisterData) return;
17
+ }
18
+
19
+ const currentStore = commonStore[node.TID];
20
+
21
+ if (!currentStore.pickerDataPool[node.id]) {
22
+ // 未创建该元件
23
+ node.elementId = s8();
24
+ const datePicker = createDatePickerElement(node);
25
+ currentStore.pickerDataPool[node.id] = {
26
+ dom: {
27
+ container: datePicker
28
+ }
29
+ }
30
+ document.body.appendChild(datePicker);
31
+ // 添加当前节点到div层
32
+ node.addToDiv();
33
+ setDataPickerElementStyle(node);
34
+ if(window.location.pathname.includes('workspace') && currentStore.options.type === 'topology') return;
35
+ const pickerOptions = Object.keys(node.pickerOptions).reduce((a,k) => (node.pickerOptions[k] && (a[k]=node.pickerOptions[k]), a), {}); // 过滤空数据
36
+ if((pickerOptions.min || pickerOptions.max) && (pickerOptions.type !== 'year' || pickerOptions.type !== 'month')){
37
+ // 字符转换
38
+ if(pickerOptions.min && isValidInteger(pickerOptions.min)) pickerOptions.min = Number(pickerOptions.min);
39
+ if(pickerOptions.max && isValidInteger(pickerOptions.max)) pickerOptions.max = Number(pickerOptions.max);
40
+ }
41
+ pickerOptions.elem = `#picker${node.id}`;
42
+ pickerOptions.done = function (val, date) {
43
+ node.formData.selected = val
44
+ date.value = val;
45
+ Store.set(`${node.TID}-EVENT:change`, {node, date});
46
+ }
47
+ setTimeout(() => {
48
+
49
+ laydate.render(pickerOptions);
50
+
51
+ }, 100)
52
+ }else {
53
+ if(node.formData.resetStyle) {
54
+ setDataPickerElementStyle(node);
55
+ node.formData.resetStyle = false;
56
+ }
57
+ // if(!node.formData.render) return;
58
+ // node.formData.render = false;
59
+ // const pickerOptions = Object.keys(node.pickerOptions).reduce((a,k) => (node.pickerOptions[k] && (a[k]=node.pickerOptions[k]), a), {}); // 过滤空数据
60
+ // Object.assign(node.formData.datePicker.config, pickerOptions);
61
+ //resetDatePicker(node);
62
+ }
63
+ }
64
+ function isValidInteger(str) {
65
+ return /^-?\d+$/.test(str) && str !== '-' && !str.startsWith('+');
66
+ }
@@ -38,7 +38,14 @@ export function formSelect(ctx, node) {
38
38
  let selectRealData = bindBlockId && currentStore.selectRealDataPool[bindBlockId];
39
39
  if(bindBlockId && selectRealData) {
40
40
  // select与echarts互相关联
41
+ if(node.formData.ids) {
42
+ const optionIds = node.formData.ids.split(',');
43
+ for (let i = 0; i < optionIds.length; i++) {
44
+ if(selectRealData[i]) selectRealData[i].optionId = optionIds[i];
45
+ }
46
+ }
41
47
  currentStore.selectDataPool[node.id].data = selectRealData;
48
+ currentStore.selectDataPool[node.id].node.selected.id = selectRealData[0].id;
42
49
  const echartsData = currentStore.echartsDataPool[bindBlockId];
43
50
  echartsData ? echartsData.bindId = node.id : currentStore.echartsDataPool[bindBlockId] = {
44
51
  bindId: node.id
@@ -45,4 +45,6 @@ export * from './text';
45
45
  export * from './triangle';
46
46
  export * from './triangle.anchor';
47
47
  export * from './triangle.rect';
48
- export * from './formoverflow';
48
+ export * from './formoverflow';
49
+ export * from './time';
50
+ export * from './formDatePicker';
@@ -46,4 +46,7 @@ export * from './triangle';
46
46
  export * from './triangle.anchor';
47
47
  export * from './triangle.rect';
48
48
  export * from './formoverflow';
49
+ export * from './time';
50
+ export * from './formDatePicker';
51
+
49
52
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ import { Node } from '../../models';
2
+ export declare function time(ctx: CanvasRenderingContext2D, node: Node): void;
@@ -0,0 +1,98 @@
1
+ export function time(ctx, node) {
2
+ var wr = node.borderRadius;
3
+ var hr = node.borderRadius;
4
+ if (node.borderRadius < 1) {
5
+ wr = node.rect.width * node.borderRadius;
6
+ hr = node.rect.height * node.borderRadius;
7
+ }
8
+ var r = wr < hr ? wr : hr;
9
+ if (node.rect.width < 2 * r) {
10
+ r = node.rect.width / 2;
11
+ }
12
+ if (node.rect.height < 2 * r) {
13
+ r = node.rect.height / 2;
14
+ }
15
+
16
+ // 背景
17
+ let x = node.rect.x;
18
+ let y = node.rect.y;
19
+ let width = node.rect.width * 0.29;
20
+ let height = node.rect.height;
21
+ let gap = node.rect.width * 0.065;
22
+ let {h, m, s} = node.time;
23
+
24
+ //绘制时
25
+ drawText(ctx, r, x, y, width, height, h, node, gap)
26
+
27
+ //绘制分
28
+ drawText(ctx, r, x+width+gap, y, width, height, m, node, gap)
29
+
30
+ //绘制秒
31
+ drawText(ctx, r, x+(width*2 + gap*2), y, width, height, s, node)
32
+
33
+ //恢复填充色
34
+ ctx.fillStyle = "#ffffff";
35
+
36
+
37
+ }
38
+
39
+ function drawText(ctx, r, x, y, width, height, hText, node, gap) {
40
+
41
+ //文字
42
+ let textfillStyle = node.font.color || "#ffffff";
43
+ let textBackground = node.font.background || '#ffffff1a';
44
+ ctx.font = '' + node.font.fontSize +"px " + node.font.fontFamily;
45
+ ctx.textBaseline = 'middle';
46
+ ctx.textAlign = 'center';
47
+
48
+ const centerX = width / 2;
49
+ const centerY = height / 2;
50
+ //绘制上半部分
51
+ ctx.save();
52
+ ctx.beginPath();
53
+ ctx.fillStyle = textBackground;
54
+ ctx.beginPath();
55
+ ctx.moveTo(x + r, y);
56
+ ctx.lineTo(x + width -r, y);
57
+ ctx.quadraticCurveTo(x + width, y, x+width, y+r);
58
+ ctx.lineTo(x+width, y + height/2 - 1);
59
+ ctx.lineTo(x, y + height/2 - 1);
60
+ ctx.lineTo(x, y+r);
61
+ ctx.quadraticCurveTo(x, y, x+r, y);
62
+ ctx.fill();
63
+ ctx.clip();
64
+
65
+ ctx.fillStyle = textfillStyle;
66
+ ctx.fillText(hText, x+centerX, y+centerY);
67
+ ctx.restore();
68
+ //绘制下半部分
69
+ ctx.save();
70
+ ctx.beginPath();
71
+ ctx.fillStyle = textBackground;
72
+ ctx.moveTo(x, y+height/2+1);
73
+ ctx.lineTo(x+width, y+height/2+1);
74
+ ctx.lineTo(x+width, y+height-r);
75
+ ctx.quadraticCurveTo(x+width, y+height, x+width-r, y+height);
76
+ ctx.lineTo(x+r, y+height);
77
+ ctx.quadraticCurveTo(x, y+height, x, y+height-r);
78
+ ctx.lineTo(x, y+height/2+2);
79
+ ctx.fill();
80
+ ctx.clip();
81
+
82
+ ctx.fillStyle = textfillStyle;
83
+ ctx.fillText(hText, x+centerX, y+centerY);
84
+ ctx.restore();
85
+
86
+ //绘制冒号
87
+ if(!gap) return
88
+
89
+ ctx.fillStyle = textfillStyle;
90
+ ctx.textBaseline = 'middle';
91
+ ctx.textAlign = 'center';
92
+ let metricss = ctx.measureText(":");
93
+ const fontHeights = metricss.actualBoundingBoxAscent + metricss.actualBoundingBoxDescent;
94
+ const centerYY = y + (height / 2) + (metricss.actualBoundingBoxAscent - fontHeights / 2);
95
+ ctx.fillText(":", x+width+(gap/2), centerYY);
96
+ ctx.restore();
97
+
98
+ }
@@ -57,6 +57,7 @@ var Node = /** @class */ (function (_super) {
57
57
  };
58
58
  _this.floorImageIndex = json.floorImageIndex || false;
59
59
  _this.formData = json.formData || null;
60
+ _this.pickerOptions = json.pickerOptions || null;
60
61
  _this.formStyle = json.formStyle || null;
61
62
  _this.formEvents = json.formEvents || [];
62
63
  _this.paginationData = json.paginationData || null;
@@ -144,6 +145,7 @@ var Node = /** @class */ (function (_super) {
144
145
  _this.video = json.video;
145
146
  _this.play = json.play;
146
147
  _this.nextPlay = json.nextPlay;
148
+ _this.time = json.time;
147
149
  if (json.elementLoaded !== undefined) {
148
150
  _this.elementId = null;
149
151
  _this.elementLoaded = false;
@@ -172,6 +174,16 @@ var Node = /** @class */ (function (_super) {
172
174
  _this.children = null;
173
175
  }
174
176
 
177
+ if(json.name === 'time') {
178
+ _this.animateFn = function() {
179
+ let date = new Date();
180
+ var hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
181
+ var minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
182
+ var second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
183
+ _this.time = {h: hour, m:minute, s:second}
184
+ }
185
+ }
186
+
175
187
  return _this;
176
188
  }
177
189
  Node.cloneState = function (json) {
@@ -657,10 +669,21 @@ var Node = /** @class */ (function (_super) {
657
669
  if (item.linear) {
658
670
  // 线条左右流动动画
659
671
  if([animateType.LeftFlow, animateType.RightFlow].includes(this.animateType) && item.state.lineDashOffset){
660
- const lineDashOffset = item.state.lineDashOffset;
661
- if (lineDashOffset > 100) item.state.lineDashOffset = 1;
662
- if (lineDashOffset < -100) item.state.lineDashOffset = -1;
663
- lineDashOffset > 0 ? item.state.lineDashOffset++ : item.state.lineDashOffset--;
672
+ let o = item.state.lineDashOffset;
673
+ switch (this.animateType) {
674
+ case animateType.LeftFlow:
675
+ o = Math.abs(o)
676
+ if (o > 100) o = 1;
677
+ o++
678
+
679
+ break;
680
+ case animateType.RightFlow:
681
+ o = Math.abs(o)*-1
682
+ if (o < -100) o = -1;
683
+ o--
684
+ break;
685
+ }
686
+ item.state.lineDashOffset = o
664
687
  this.lineDashOffset = item.state.lineDashOffset;
665
688
  }else if(([animateType.Show, animateType.Rotate].includes(this.animateType) || this.name === 'electricFan') && item.state.rotate !== item.initState.rotate) {
666
689
  // 旋转动画,判断逻辑先这么写,日后将所有动画统一在编辑器中配置,再做优化
@@ -4,6 +4,7 @@ import { Point } from './models';
4
4
  import {Common} from './common';
5
5
  export declare class Preview extends Common{
6
6
  constructor(parent: string | HTMLElement, options?: Options);
7
+ private eventChangeSubcribe;
7
8
  private scheduledAnimationFrame;
8
9
  private onMouseMove;
9
10
  private onmousedown;
@@ -35,6 +35,14 @@ var Preview = (function (_super) {
35
35
  var _this = _super.call(this, parent, options) || this;
36
36
  _this.offscreen.getRoutineLayer(['AnimateLayer']);
37
37
  _this.scheduledAnimationFrame = false;
38
+ _this.innerHeight = window.innerHeight || document.documentElement.clientHeight; // 初始化网页高度
39
+ _this.devicePixelInnerHeight = _this.innerHeight; // 初始化网页缩放高度
40
+ _this.devicePixelRatio = window.devicePixelRatio; // 初始化窗口分辨率
41
+ // 选中值发生变化时触发,目前用于日期切换
42
+ _this.eventChangeSubcribe = Store.subscribe(this.generateStoreKey('EVENT:change'), function (data) {
43
+ const {node, date} = data;
44
+ _this.dispatch('change', node, date); // eventOut外部事件
45
+ });
38
46
  _this.onMouseMove = function (e) {
39
47
  _this.store.data.dataResize = 0;
40
48
  // https://caniuse.com/#feat=mdn-api_mouseevent_buttons
@@ -105,7 +113,7 @@ var Preview = (function (_super) {
105
113
  if (visibleRange == '1') {
106
114
  _this.openCount++
107
115
  }
108
- this.render();
116
+ _this.render();
109
117
  break;
110
118
  case downDataType.Tabswitch:
111
119
  _this.switchStaticsCheckType(_this.moveIn.hoverNode, _this.moveIn.eventNode);
@@ -181,14 +189,29 @@ var Preview = (function (_super) {
181
189
  return false;
182
190
  };
183
191
  window.onresize = function () {
184
- const isFullScreen = document.fullscreenElement || document.webkitFullscreenElement || document.mozFullscreenElement;
185
- if(!isFullScreen && _this.isFullScreen){
186
- _this.moveIn.hoverNode.text = '全屏';
192
+ let isFullScreen = document.fullscreenElement || document.webkitFullscreenElement || document.mozFullscreenElement;
193
+ if((!isFullScreen && _this.isFullScreen) || window.keyControlFullScreen){
194
+ // F11或ESC退出全屏
195
+ if(!window.keyControlFullScreen) _this.moveIn.hoverNode.text = '全屏';
187
196
  _this.fitViewPreview(_this.isFullScreen);
188
197
  _this.isFullScreen = false;
198
+ window.keyControlFullScreen = false;
189
199
  }else {
190
- // pageZoomOnly 表示topology页面只全局缩放,不对局部缩放进行调整,不执行render重绘。通常用于无任何操作事件的topology驾驶舱
191
- if(_this.store.options.type === 'topology' || _this.store.options.type === 'pageZoomOnly') return;
200
+ const documentElementHeight = window.innerHeight || document.documentElement.clientHeight; // 每次窗口有变化就重新获取一次网页高度
201
+ if(window.devicePixelRatio !== _this.devicePixelRatio) {
202
+ _this.devicePixelInnerHeight = documentElementHeight;
203
+ _this.devicePixelRatio = window.devicePixelRatio;
204
+ }
205
+ if(_this.devicePixelInnerHeight < documentElementHeight && !isFullScreen) {
206
+ // 按F11 全屏
207
+ setTimeout(() => {
208
+ _this.fitViewPreview(false);
209
+ _this.isFullScreen = true;
210
+ }, 200);
211
+ window.keyControlFullScreen = true;
212
+ }
213
+ // topology编辑器或全屏下跳出程序
214
+ if(_this.store.options.type === 'topology' || window.keyControlFullScreen) return;
192
215
  const screenWidth = window.screen.width < 1920 ? 1920 : window.screen.width;
193
216
  const zoom = window.innerWidth < screenWidth ? document.documentElement.clientWidth / screenWidth : 1;
194
217
  _this.isResize = true;
@@ -303,6 +326,7 @@ var Preview = (function (_super) {
303
326
  };
304
327
  Preview.prototype.destroy = function () {
305
328
  this.destroyStatic();
329
+ if(this.eventChangeSubcribe) this.eventChangeSubcribe.unsubscribe();
306
330
  this.onMouseMove = null;
307
331
  this.onmousedown = null;
308
332
  this.onmouseup = null;
@@ -93,7 +93,7 @@ var RenderLayer = /** @class */ (function (_super) {
93
93
  this.bkImg.src = bkImage;
94
94
  this.bkImg.onload = function () {
95
95
  if(pixi && !_this.bkImgRect) {
96
- _this.bkImgRectResize({width: _this.canvas.width, height: _this.canvas.height});
96
+ _this.bkImgRectResize({width: _this.width, height: _this.height});
97
97
  _this.scale(_this.ratio, undefined, _this.scaleX, _this.scaleY);
98
98
  }else {
99
99
  //_this.bkImgRect = _this.coverRect(_this.canvas.width, _this.canvas.height, _this.bkImg.width, _this.bkImg.height);
@@ -137,10 +137,10 @@ var RenderLayer = /** @class */ (function (_super) {
137
137
  RenderLayer.prototype.bkImgRectResize = function (size) {
138
138
  const bkImageRect = commonStore[this.TID].data.bkImageRect;
139
139
  if(!size) return;
140
+ const { width, height } = size;
140
141
  if(bkImageRect) {
141
142
  let x = bkImageRect.x ? Number(bkImageRect.x) : 0;
142
143
  let y = bkImageRect.y ? Number(bkImageRect.y) : 0;
143
- const { width, height } = size;
144
144
  let bkWidth = bkImageRect.width ? Number(bkImageRect.width) : width;
145
145
  let bkHeight = bkImageRect.height ? Number(bkImageRect.height) : height;
146
146
  this.bkImgRect = {
@@ -157,6 +157,17 @@ var RenderLayer = /** @class */ (function (_super) {
157
157
  x,
158
158
  y
159
159
  };
160
+ }else {
161
+ this.bkImgRect = {
162
+ center: {
163
+ x: width / 2,
164
+ y: height / 2
165
+ },
166
+ x: 0,
167
+ y: 0,
168
+ width,
169
+ height
170
+ };
160
171
  }
161
172
  };
162
173