cnhis-design-vue 3.1.12-beta.6 → 3.1.12-beta.7

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 (49) hide show
  1. package/es/packages/fabric-chart/index.d.ts +195 -1
  2. package/es/packages/fabric-chart/src/FabricChart.vue.d.ts +196 -1
  3. package/es/packages/fabric-chart/src/FabricChart.vue_vue_type_script_setup_true_lang.js +269 -6
  4. package/es/packages/fabric-chart/src/components/PopupMenu.d.ts +46 -0
  5. package/es/packages/fabric-chart/src/components/PopupMenu.js +105 -0
  6. package/es/packages/fabric-chart/src/components/PopupTip.js +4 -0
  7. package/es/packages/fabric-chart/src/components/PopupTip.vue.d.ts +63 -0
  8. package/es/packages/fabric-chart/src/components/PopupTip.vue_vue_type_script_setup_true_lang.js +32 -0
  9. package/es/packages/fabric-chart/src/components/useStyle.d.ts +7 -0
  10. package/es/packages/fabric-chart/src/components/useStyle.js +36 -0
  11. package/es/packages/fabric-chart/src/hooks/constant.d.ts +14 -0
  12. package/es/packages/fabric-chart/src/hooks/constant.js +36 -0
  13. package/es/packages/fabric-chart/src/hooks/index.d.ts +9 -0
  14. package/es/packages/fabric-chart/src/hooks/index.js +9 -0
  15. package/es/packages/fabric-chart/src/hooks/useBottom.d.ts +4 -0
  16. package/es/packages/fabric-chart/src/hooks/useBottom.js +86 -0
  17. package/es/packages/fabric-chart/src/hooks/useCenter.d.ts +29 -0
  18. package/es/packages/fabric-chart/src/hooks/useCenter.js +475 -0
  19. package/es/packages/fabric-chart/src/hooks/useCumputedPoint.d.ts +7 -0
  20. package/es/packages/fabric-chart/src/hooks/useCumputedPoint.js +53 -0
  21. package/es/packages/fabric-chart/src/hooks/useDraw.d.ts +42 -0
  22. package/es/packages/fabric-chart/src/hooks/useDraw.js +86 -0
  23. package/es/packages/fabric-chart/src/hooks/useEvent.d.ts +1 -0
  24. package/es/packages/fabric-chart/src/hooks/useEvent.js +10 -0
  25. package/es/packages/fabric-chart/src/hooks/useGrid.d.ts +4 -0
  26. package/es/packages/fabric-chart/src/hooks/useGrid.js +44 -0
  27. package/es/packages/fabric-chart/src/hooks/useLeft.d.ts +4 -0
  28. package/es/packages/fabric-chart/src/hooks/useLeft.js +180 -0
  29. package/es/packages/fabric-chart/src/hooks/useOther.d.ts +4 -0
  30. package/es/packages/fabric-chart/src/hooks/useOther.js +34 -0
  31. package/es/packages/fabric-chart/src/hooks/useRight.d.ts +4 -0
  32. package/es/packages/fabric-chart/src/hooks/useRight.js +87 -0
  33. package/es/packages/fabric-chart/src/hooks/useShadow.d.ts +6 -0
  34. package/es/packages/fabric-chart/src/hooks/useShadow.js +127 -0
  35. package/es/packages/fabric-chart/src/hooks/useTop.d.ts +4 -0
  36. package/es/packages/fabric-chart/src/hooks/useTop.js +148 -0
  37. package/es/packages/fabric-chart/src/interface.d.ts +115 -0
  38. package/es/packages/fabric-chart/src/interface.js +3 -0
  39. package/es/packages/fabric-chart/src/utils/index.d.ts +2 -0
  40. package/es/packages/fabric-chart/src/utils/index.js +15334 -0
  41. package/es/packages/fabric-chart/style/index.css +43 -0
  42. package/es/packages/form-render/src/components/renderer/cascader.js +14 -0
  43. package/es/packages/form-render/src/components/renderer/checkbox.d.ts +2 -0
  44. package/es/packages/form-render/src/components/renderer/checkbox.js +4 -5
  45. package/es/packages/form-render/src/components/renderer/date.js +42 -10
  46. package/es/packages/form-render/src/components/renderer/select.js +11 -0
  47. package/es/packages/form-render/src/components/renderer/simpleComponent.js +0 -1
  48. package/es/packages/index.css +43 -0
  49. package/package.json +1 -1
@@ -1 +1,476 @@
1
+ import { reactive, onMounted, nextTick } from 'vue';
2
+ import { fabric } from '../utils/index.js';
3
+ import { defaultStyle, drawLine, drawPoint, defaultTextStyle } from './useDraw.js';
4
+ import useGrid from './useGrid.js';
5
+ import { useShadow } from './useShadow.js';
6
+ import { TEMPERATURE_MENU, PAIN_MENU } from './constant.js';
1
7
 
8
+ function isEffectiveNode(node) {
9
+ return (node == null ? void 0 : node.time) && ((node == null ? void 0 : node.value) || (node == null ? void 0 : node.value) === 0);
10
+ }
11
+ function useCenter(canvas, propItems, emits, cumputedX, cumputedY, getXValue, getYValue, addRenderItem) {
12
+ useGrid(canvas, propItems);
13
+ const {
14
+ left,
15
+ xScaleList,
16
+ yCellHeight,
17
+ originX,
18
+ endX,
19
+ originY,
20
+ endY,
21
+ itemList,
22
+ painIndex,
23
+ painHeight,
24
+ vitalSignsOriginY,
25
+ painOriginY
26
+ } = propItems;
27
+ const pointTipProps = reactive({
28
+ show: false,
29
+ point: { x: 0, y: 0 },
30
+ list: []
31
+ });
32
+ const pointMenuProps = reactive({
33
+ show: false,
34
+ point: { x: 0, y: 0 },
35
+ list: [],
36
+ target: null
37
+ });
38
+ const shadowLinesCache = /* @__PURE__ */ new Set();
39
+ onMounted(() => {
40
+ nextTick(() => {
41
+ init();
42
+ });
43
+ });
44
+ function init() {
45
+ drawShaDow();
46
+ left.yScaleValue.forEach((scaleValue) => {
47
+ scaleValue.dataList.forEach((item, dataIndex) => {
48
+ drawPolyLine(item, dataIndex, scaleValue);
49
+ });
50
+ });
51
+ setCanvasEvent();
52
+ }
53
+ function drawShaDow(target) {
54
+ var _a, _b;
55
+ const pulseObj = left.yScaleValue.find((item) => item.type === "pulse");
56
+ if (!pulseObj || !((_a = pulseObj.dataList) == null ? void 0 : _a.length))
57
+ return;
58
+ if (shadowLinesCache.size)
59
+ canvas.value.remove(...shadowLinesCache);
60
+ shadowLinesCache.clear();
61
+ const data = [];
62
+ if (((_b = pulseObj.dataList) == null ? void 0 : _b.length) > 1) {
63
+ let points1 = [];
64
+ let points2 = [];
65
+ const copyDataList = JSON.parse(JSON.stringify(pulseObj.dataList));
66
+ if (target) {
67
+ const { type, dataIndex, index } = target.origin || {};
68
+ if (type === "pulse") {
69
+ Object.assign(copyDataList[dataIndex].list[index], {
70
+ x: target.left,
71
+ y: target.top
72
+ });
73
+ }
74
+ }
75
+ const [data1, data2] = copyDataList;
76
+ const getPoint = (item) => {
77
+ return item.x && item.y ? {
78
+ x: item.x,
79
+ y: item.y
80
+ } : {
81
+ x: cumputedX(item.time),
82
+ y: cumputedY(pulseObj.type, pulseObj.list, item.value)
83
+ };
84
+ };
85
+ data1.list.forEach((item, index) => {
86
+ const point1 = getPoint(item);
87
+ const item2 = data2.list[index];
88
+ const point2 = item2 ? getPoint(item2) : null;
89
+ if (point2 && point1.x === point2.x && point1.y !== point2.y) {
90
+ points1.push(point1);
91
+ points2.push(point2);
92
+ const itemPrev = data1.list[index - 1];
93
+ const itemNext = data1.list[index + 1];
94
+ const itemNext2 = data2.list[index + 1];
95
+ if (itemPrev && points1.length === 1) {
96
+ const point = getPoint(itemPrev);
97
+ points1.unshift(point);
98
+ points2.unshift(point);
99
+ }
100
+ const pointNext = getPoint(itemNext);
101
+ const pointNext2 = itemNext2 ? getPoint(itemNext2) : null;
102
+ if (itemNext && pointNext2 && pointNext.x === pointNext2.x && pointNext.y === pointNext2.y) {
103
+ points1.push(pointNext);
104
+ points2.push(pointNext);
105
+ }
106
+ } else {
107
+ if (points1.length && points2.length) {
108
+ data.push({ points1, points2 });
109
+ points1 = [];
110
+ points2 = [];
111
+ }
112
+ }
113
+ });
114
+ }
115
+ if (data.length) {
116
+ const newData = data.reduce((pre, cur) => {
117
+ const arr1 = cur.points1.map((v) => [v.x, v.y]);
118
+ const arr2 = cur.points2.map((v) => [v.x, v.y]);
119
+ const [, ...newArr2] = arr2;
120
+ return pre.concat([[...arr1, ...newArr2.reverse()]]);
121
+ }, []);
122
+ const { createShadowLines } = useShadow();
123
+ newData.forEach((item) => {
124
+ const shadowLines = createShadowLines(item, pulseObj.shadowStyle._angle, pulseObj.shadowStyle.space);
125
+ shadowLines.forEach((l) => {
126
+ Object.assign(l, {
127
+ ...defaultStyle,
128
+ ...pulseObj.shadowStyle || {}
129
+ });
130
+ shadowLinesCache.add(l);
131
+ });
132
+ canvas.value.add(...shadowLines);
133
+ canvas.value.renderAll();
134
+ });
135
+ }
136
+ }
137
+ function setCanvasEvent() {
138
+ canvas.value.on("mouse:up", (event) => {
139
+ var _a;
140
+ if (event.button === 3) {
141
+ const { x = 0, y = 0 } = event.pointer || {};
142
+ if (x >= originX && x <= endX && y >= originY && y <= endY) {
143
+ pointTipProps.show = false;
144
+ pointMenuProps.point = { x, y };
145
+ pointMenuProps.show = true;
146
+ const { type } = ((_a = event.target) == null ? void 0 : _a.origin) || {};
147
+ if (event.target && (type === "temperature" || type === "pain")) {
148
+ if (type === "temperature") {
149
+ pointMenuProps.list = [...TEMPERATURE_MENU];
150
+ }
151
+ if (type === "pain") {
152
+ pointMenuProps.list = [...PAIN_MENU];
153
+ }
154
+ pointMenuProps.target = event.target;
155
+ } else {
156
+ pointMenuProps.target = null;
157
+ pointMenuProps.list = ["\u65B0\u589E\u8282\u70B9"];
158
+ itemList.forEach((v) => {
159
+ if (!getEqualXTypes(x).includes(v.bigType)) {
160
+ pointMenuProps.list.push({
161
+ renderItem: addRenderItem ? addRenderItem(v) : () => v.title,
162
+ origin: {
163
+ title: v.title,
164
+ unit: v.unit,
165
+ type: v.bigType,
166
+ dataIndex: v.dataIndex
167
+ },
168
+ pointer: event.pointer
169
+ });
170
+ }
171
+ });
172
+ if (pointMenuProps.list.length === 1) {
173
+ pointMenuProps.show = false;
174
+ console.log("\u5F53\u524D\u65F6\u95F4\u6BB5\u5185\u65E0\u53EF\u65B0\u589E\u8282\u70B9");
175
+ }
176
+ }
177
+ }
178
+ }
179
+ });
180
+ }
181
+ function getEqualXTypes(pointX) {
182
+ const types = [];
183
+ canvas.value.forEachObject((obj) => {
184
+ if (obj.origin && cumputedX(getXValue(pointX)) === obj.left) {
185
+ types.push(obj.origin.type);
186
+ }
187
+ });
188
+ return [...new Set(types)];
189
+ }
190
+ function drawPolyLine(item, dataIndex, scaleValue) {
191
+ const {
192
+ pointAttr = {},
193
+ lineAttr = {},
194
+ noRiseStyle = {},
195
+ verifiedStyle = {},
196
+ coolingStyle = {},
197
+ type = "circle"
198
+ } = item;
199
+ const pointList = [];
200
+ const lineList = [];
201
+ const otherList = [];
202
+ item.list.forEach((v, index) => {
203
+ const newY = scaleValue.type === "pain" ? painOriginY : vitalSignsOriginY;
204
+ let points = null;
205
+ if (isEffectiveNode(v)) {
206
+ const x = cumputedX(v.time);
207
+ const y = cumputedY(scaleValue.type, scaleValue.list, v.value);
208
+ if (isLimit(v.time)) {
209
+ points = [x, y < newY.originY ? newY.originY : y > newY.endY ? newY.endY : y];
210
+ }
211
+ }
212
+ const nextV = item.list[index + 1];
213
+ let nextPoint = null;
214
+ if (isEffectiveNode(nextV)) {
215
+ const nextX = cumputedX(nextV.time);
216
+ const nextY = cumputedY(scaleValue.type, scaleValue.list, nextV.value);
217
+ if (isLimit(nextV.time)) {
218
+ nextPoint = [
219
+ nextX,
220
+ nextY < newY.originY ? newY.originY : nextY > newY.endY ? newY.endY : nextY
221
+ ];
222
+ }
223
+ }
224
+ let coolLine, coolPoint, noRiseText, arrowGroup, verifiedText;
225
+ if (points && scaleValue.type === "temperature") {
226
+ if (v.noRise) {
227
+ if (typeof v.noRise === "string") {
228
+ noRiseText = drawText([points[0], points[1] + 5], {
229
+ value: v.noRise.split("").join("\n"),
230
+ originY: "top",
231
+ ...noRiseStyle
232
+ });
233
+ otherList.push(noRiseText);
234
+ } else {
235
+ const top = points[1] + yCellHeight * 2;
236
+ const arrowLine = drawLine([...points, points[0], top], {
237
+ ...lineAttr,
238
+ stroke: noRiseStyle.fill
239
+ });
240
+ const arrow = drawText([points[0] + 0.5, top + 3], {
241
+ value: "v",
242
+ originX: "center",
243
+ originY: "bottom",
244
+ fontSize: 16,
245
+ ...noRiseStyle
246
+ });
247
+ arrowGroup = new fabric.Group([arrowLine, arrow], {
248
+ ...defaultStyle,
249
+ originX: "center",
250
+ originY: "top"
251
+ });
252
+ otherList.push(arrowGroup);
253
+ }
254
+ }
255
+ if (v.verified) {
256
+ verifiedText = drawText([points[0], points[1] - 5], {
257
+ value: "v",
258
+ originX: "center",
259
+ originY: "bottom",
260
+ ...verifiedStyle
261
+ });
262
+ otherList.push(verifiedText);
263
+ }
264
+ if (v.physicalCooling || v.drugCooling) {
265
+ const coolingLineStyle = {
266
+ ...lineAttr,
267
+ stroke: coolingStyle.stroke,
268
+ strokeDashArray: [3, 3]
269
+ };
270
+ const coolY = cumputedY(scaleValue.type, scaleValue.list, v.physicalCooling || v.drugCooling);
271
+ coolLine = drawLine([...points, points[0], coolY], {
272
+ ...coolingLineStyle
273
+ });
274
+ coolPoint = drawPoint("circle", {
275
+ left: points[0],
276
+ top: coolY,
277
+ ...coolingStyle,
278
+ ...defaultStyle
279
+ });
280
+ coolLine && otherList.push(coolLine);
281
+ coolPoint && otherList.push(coolPoint);
282
+ }
283
+ }
284
+ let line;
285
+ let point;
286
+ let previousLine;
287
+ line = points && nextPoint && !v.breakpoint ? drawLine([...points, ...nextPoint], {
288
+ ...lineAttr
289
+ }) : null;
290
+ previousLine = lineList[index - 1];
291
+ const pointAttrNew = {
292
+ origin: {
293
+ data: v,
294
+ title: item.title,
295
+ unit: scaleValue.unit,
296
+ type: scaleValue.type,
297
+ dataIndex,
298
+ index
299
+ },
300
+ noRiseText,
301
+ arrowGroup,
302
+ verifiedText,
303
+ leftLine: previousLine,
304
+ rightLine: line,
305
+ coolLine,
306
+ coolPoint,
307
+ lockMovementX: true,
308
+ ...pointAttr
309
+ };
310
+ if (previousLine) {
311
+ point = drawPoint(type, {
312
+ left: previousLine.get("x2"),
313
+ top: previousLine.get("y2"),
314
+ ...pointAttrNew
315
+ });
316
+ } else {
317
+ if (points) {
318
+ pointAttrNew.leftLine = null;
319
+ point = drawPoint(type, {
320
+ left: points[0],
321
+ top: points[1],
322
+ ...pointAttrNew
323
+ });
324
+ }
325
+ }
326
+ lineList.push(line);
327
+ if (point) {
328
+ setPointEvent(point);
329
+ pointList.push(point);
330
+ }
331
+ });
332
+ Promise.all(pointList).then((res) => {
333
+ const lineListFilter = lineList.filter((v) => v);
334
+ let prevPoint = null;
335
+ res = res.filter((v) => {
336
+ if (v && prevPoint) {
337
+ prevPoint.nextPoint = v;
338
+ v.prevPoint = prevPoint;
339
+ }
340
+ prevPoint = v || prevPoint;
341
+ v == null ? void 0 : v.bringToFront();
342
+ return v;
343
+ });
344
+ Promise.all(otherList).then((r) => {
345
+ canvas.value.add(...lineListFilter, ...res, ...r);
346
+ res.forEach((v) => {
347
+ v == null ? void 0 : v.bringToFront();
348
+ });
349
+ canvas.value.requestRenderAll();
350
+ });
351
+ });
352
+ }
353
+ function setPointEvent(point) {
354
+ point.on("mouseover", () => {
355
+ setPopup(point);
356
+ });
357
+ point.on("mouseout", () => {
358
+ pointTipProps.show = false;
359
+ });
360
+ point.on("moving", () => {
361
+ moveLimit(point);
362
+ updateLine(point);
363
+ canvas.value.renderAll();
364
+ setPopup(point);
365
+ });
366
+ point.on("mouseup:before", (event) => {
367
+ pointTipProps.show = false;
368
+ if (event.e.button === 0) {
369
+ const { type } = point.origin;
370
+ const value = getYValue(type, point.top);
371
+ emits("change", {
372
+ ...point.origin,
373
+ data: {
374
+ ...point.origin.data,
375
+ value
376
+ }
377
+ });
378
+ }
379
+ });
380
+ }
381
+ function setPopup(point) {
382
+ const { title, unit, type, data } = point.origin;
383
+ pointTipProps.point = {
384
+ x: point.left,
385
+ y: point.top
386
+ };
387
+ const yValue = getYValue(type, point.top);
388
+ pointTipProps.list = [
389
+ `${title} ${yValue}${unit || ""}`,
390
+ `\u65F6\u95F4 ${((data == null ? void 0 : data.time) || getXValue(point.left)).slice(-5)}`
391
+ ];
392
+ pointTipProps.show = true;
393
+ }
394
+ function moveLimit(point) {
395
+ point.setCoords();
396
+ const newY = point.origin.type === "pain" ? painOriginY : vitalSignsOriginY;
397
+ if (point.top < newY.originY) {
398
+ point.set("top", newY.originY);
399
+ }
400
+ if (point.top > newY.endY) {
401
+ point.set("top", newY.endY);
402
+ }
403
+ }
404
+ function updateLine(point) {
405
+ if (point.leftLine) {
406
+ point.leftLine.setCoords();
407
+ point.leftLine.set({ x2: point.left, y2: point.top });
408
+ }
409
+ if (point.rightLine) {
410
+ point.rightLine.setCoords();
411
+ point.rightLine.set({ x1: point.left, y1: point.top });
412
+ }
413
+ if (point.coolLine) {
414
+ point.coolLine.setCoords();
415
+ point.coolLine.set({ x1: point.left, y1: point.top });
416
+ }
417
+ if (point.noRiseText) {
418
+ point.noRiseText.setCoords();
419
+ point.noRiseText.set({ left: point.left, top: point.top + 5 });
420
+ }
421
+ if (point.arrowGroup) {
422
+ point.arrowGroup.setCoords();
423
+ point.arrowGroup.set({ left: point.left, top: point.top });
424
+ }
425
+ if (point.verifiedText) {
426
+ point.verifiedText.setCoords();
427
+ point.verifiedText.set({ left: point.left, top: point.top - 5 });
428
+ }
429
+ drawShaDow(point);
430
+ }
431
+ function drawText([x, y], style) {
432
+ const text = new fabric.Text(style.value, {
433
+ ...defaultTextStyle,
434
+ left: x,
435
+ top: y,
436
+ ...style
437
+ });
438
+ return text;
439
+ }
440
+ function isLimit(time) {
441
+ const minMinute = Math.min(...xScaleList.map((v) => +v));
442
+ const maxMinute = Math.max(...xScaleList.map((v) => +v));
443
+ const getTime = new Date(time).getTime();
444
+ return getTime >= minMinute && getTime <= maxMinute;
445
+ }
446
+ function clickMenu({ item, target }) {
447
+ if (!target) {
448
+ emits("add", {
449
+ data: {
450
+ time: getXValue(item.pointer.x),
451
+ value: getYValue(item.origin.type, item.pointer.y)
452
+ },
453
+ ...item.origin
454
+ });
455
+ } else {
456
+ const data = {
457
+ time: target.origin.data.time,
458
+ value: target.origin.data.value
459
+ };
460
+ data[`${item.type}`] = item.value;
461
+ emits("change", {
462
+ ...target.origin,
463
+ data
464
+ });
465
+ }
466
+ }
467
+ return {
468
+ pointTipProps,
469
+ pointMenuProps,
470
+ clickMenu,
471
+ setPopup,
472
+ getEqualXTypes
473
+ };
474
+ }
475
+
476
+ export { useCenter };
@@ -0,0 +1,7 @@
1
+ import { IPropItems, IPointType } from '../interface';
2
+ export declare function useCumputedPoint(propItems: IPropItems): {
3
+ cumputedX: (value: number | string) => number;
4
+ cumputedY: (type: IPointType, scaleValueList: number[], value: number | string) => number;
5
+ getXValue: (pointX: number) => string;
6
+ getYValue: (type: IPointType, pointY: number) => number;
7
+ };
@@ -0,0 +1,53 @@
1
+ function useCumputedPoint(propItems) {
2
+ const {
3
+ xScaleList,
4
+ xScaleCell,
5
+ originX,
6
+ endY,
7
+ xCellWidth,
8
+ left,
9
+ vitalSignsOriginY,
10
+ painOriginY
11
+ } = propItems;
12
+ function cumputedX(value) {
13
+ const time = new Date(value).getTime();
14
+ const minScale = Math.min(...xScaleList.map((v) => +v));
15
+ const i = Math.floor((time - minScale) / xScaleCell);
16
+ if (xScaleList.includes(time)) {
17
+ return originX + xCellWidth * i;
18
+ }
19
+ return originX + xCellWidth * i + xCellWidth / 2;
20
+ }
21
+ function cumputedY(type, scaleValueList, value) {
22
+ const yScaleCell = propItems[`${type}YCell`];
23
+ const yCellUnit = +value - Math.min(...scaleValueList);
24
+ const newEndY = type === "pain" ? painOriginY.endY : vitalSignsOriginY.endY;
25
+ return newEndY - yScaleCell * yCellUnit;
26
+ }
27
+ function getXValue(pointX) {
28
+ const minScale = Math.min(...xScaleList.map((v) => +v));
29
+ const time = minScale + (pointX - originX) / xCellWidth * xScaleCell;
30
+ let d = new Date(time);
31
+ const month = `00${d.getMonth() + 1}`.slice(-2);
32
+ const day = `00${d.getDate()}`.slice(-2);
33
+ const date = `${d.getFullYear()}-${month}-${day} ${d.getHours()}:00`;
34
+ return date;
35
+ }
36
+ function getYValue(type, pointY) {
37
+ var _a;
38
+ const yScaleCell = propItems[`${type}YCell`];
39
+ const list = ((_a = left.yScaleValue.find((v) => v.type === type)) == null ? void 0 : _a.list) || [];
40
+ const minVal = list.length ? Math.min(...list) : 0;
41
+ const newEndY = type === "pain" ? painOriginY.endY : vitalSignsOriginY.endY;
42
+ const y = (newEndY - pointY) / yScaleCell + minVal;
43
+ return Math.floor(y * 100) / 100;
44
+ }
45
+ return {
46
+ cumputedX,
47
+ cumputedY,
48
+ getXValue,
49
+ getYValue
50
+ };
51
+ }
52
+
53
+ export { useCumputedPoint };
@@ -0,0 +1,42 @@
1
+ import { fabric } from '../utils';
2
+ import { ILineOptions, ITextOptions } from '../interface';
3
+ export declare const defaultStyle: {
4
+ evented: boolean;
5
+ selectable: boolean;
6
+ };
7
+ export declare const defaultBorderStyle: {
8
+ evented: boolean;
9
+ selectable: boolean;
10
+ stroke: string;
11
+ strokeWidth: number;
12
+ };
13
+ export declare const defaultLineStyle: {
14
+ evented: boolean;
15
+ selectable: boolean;
16
+ stroke: string;
17
+ strokeWidth: number;
18
+ strokeDashArray: number[];
19
+ };
20
+ export declare const defaultRectStyle: {
21
+ evented: boolean;
22
+ selectable: boolean;
23
+ fill: string;
24
+ stroke: string;
25
+ strokeWidth: number;
26
+ originX: string;
27
+ originY: string;
28
+ };
29
+ export declare const defaultTextStyle: {
30
+ evented: boolean;
31
+ selectable: boolean;
32
+ fontFamily: string;
33
+ fontSize: number;
34
+ fill: string;
35
+ centeredRotation: boolean;
36
+ originX: string;
37
+ originY: string;
38
+ lineHeight: number;
39
+ };
40
+ export declare function drawLine(points: number[], style: Partial<ILineOptions>): fabric.Line;
41
+ export declare function drawTextGroup(rectStyle: Partial<fabric.IRectOptions>, fontStyle: Partial<ITextOptions>, groupStyle: Partial<fabric.IGroupOptions>): fabric.Group;
42
+ export declare function drawPoint(type: string | undefined, style: any): fabric.Circle | fabric.Triangle;
@@ -1 +1,87 @@
1
+ import { fabric } from '../utils/index.js';
1
2
 
3
+ const defaultStyle = {
4
+ evented: false,
5
+ selectable: false
6
+ };
7
+ const defaultBorderStyle = {
8
+ stroke: "#999",
9
+ strokeWidth: 1,
10
+ ...defaultStyle
11
+ };
12
+ const defaultLineStyle = {
13
+ stroke: "#000",
14
+ strokeWidth: 1,
15
+ strokeDashArray: [0, 0],
16
+ ...defaultStyle
17
+ };
18
+ const defaultRectStyle = {
19
+ fill: "transparent",
20
+ stroke: "#999",
21
+ strokeWidth: 1,
22
+ originX: "center",
23
+ originY: "center",
24
+ ...defaultStyle
25
+ };
26
+ const defaultTextStyle = {
27
+ fontFamily: "\u5FAE\u8F6F\u96C5\u9ED1",
28
+ fontSize: 12,
29
+ fill: "#000",
30
+ centeredRotation: true,
31
+ originX: "center",
32
+ originY: "center",
33
+ lineHeight: 1,
34
+ ...defaultStyle
35
+ };
36
+ function drawLine(points, style) {
37
+ return new fabric.Line(points, {
38
+ ...defaultLineStyle,
39
+ ...style
40
+ });
41
+ }
42
+ function drawTextGroup(rectStyle, fontStyle, groupStyle) {
43
+ const rect = new fabric.Rect({
44
+ ...defaultRectStyle,
45
+ ...rectStyle
46
+ });
47
+ const texts = new fabric.Text(String(fontStyle.value), {
48
+ ...defaultTextStyle,
49
+ ...fontStyle
50
+ });
51
+ return new fabric.Group([rect, texts], {
52
+ ...groupStyle
53
+ });
54
+ }
55
+ function drawPoint(type = "circle", style) {
56
+ let point = null;
57
+ const newStyle = {
58
+ originX: "center",
59
+ originY: "center",
60
+ hasControls: false,
61
+ hasBorders: false,
62
+ ...style
63
+ };
64
+ switch (type) {
65
+ case "triangle":
66
+ point = new fabric.Triangle({
67
+ width: 20,
68
+ height: 20,
69
+ strokeWidth: 1,
70
+ scale: 1,
71
+ ...newStyle
72
+ });
73
+ break;
74
+ case "circle":
75
+ point = new fabric.Circle({
76
+ objectCaching: false,
77
+ strokeWidth: 1,
78
+ radius: 5,
79
+ scale: 1,
80
+ ...newStyle
81
+ });
82
+ break;
83
+ }
84
+ return point;
85
+ }
86
+
87
+ export { defaultBorderStyle, defaultLineStyle, defaultRectStyle, defaultStyle, defaultTextStyle, drawLine, drawPoint, drawTextGroup };
@@ -0,0 +1 @@
1
+ export declare function useEvent(element: HTMLCanvasElement | any): void;
@@ -0,0 +1,10 @@
1
+ import { useEventListener } from '@vueuse/core';
2
+
3
+ function useEvent(element) {
4
+ useEventListener(element.nextSibling, "contextmenu", (e) => {
5
+ e.preventDefault();
6
+ return false;
7
+ });
8
+ }
9
+
10
+ export { useEvent };
@@ -0,0 +1,4 @@
1
+ import { Ref } from 'vue';
2
+ import { fabric } from '../utils';
3
+ import { IPropItems } from '../interface';
4
+ export default function useGrid(canvas: Ref<fabric.Canvas>, propItems: IPropItems): void;