@nightshadeui/canvas 3.1.0 → 3.2.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.
@@ -1,4 +1,9 @@
1
- declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
1
+ declare const _default: typeof __VLS_export;
2
+ export default _default;
3
+ export type __VLS_LocalComponents = {};
4
+ export type __VLS_GlobalComponents = import('vue').GlobalComponents;
5
+ export type __VLS_LocalDirectives = {};
6
+ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
2
7
  canvas: {
3
8
  type: ObjectConstructor;
4
9
  required: true;
@@ -9,5 +14,4 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
9
14
  required: true;
10
15
  };
11
16
  }>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
12
- export default _default;
13
17
  //# sourceMappingURL=CanvasBoxSelect.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CanvasBoxSelect.vue.d.ts","sourceRoot":"","sources":["../../src/components/CanvasBoxSelect.vue"],"names":[],"mappings":"AASA;"}
1
+ {"version":3,"file":"CanvasBoxSelect.vue.d.ts","sourceRoot":"","sources":["../../src/components/CanvasBoxSelect.vue"],"names":[],"mappings":"AASA;wBA+C0B,OAAO,YAAY;;oCAE/B,EAAE;qCACF,OAAO,KAAK,EAAE,gBAAgB;oCAG9B,EAAE;AA0BhB;;;;;;;;;;kGAMG"}
@@ -1,4 +1,9 @@
1
- declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
1
+ declare const _default: typeof __VLS_export;
2
+ export default _default;
3
+ export type __VLS_LocalComponents = {};
4
+ export type __VLS_GlobalComponents = import('vue').GlobalComponents;
5
+ export type __VLS_LocalDirectives = {};
6
+ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
2
7
  canvas: {
3
8
  type: ObjectConstructor;
4
9
  required: true;
@@ -16,5 +21,4 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
16
21
  required: true;
17
22
  };
18
23
  }>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
19
- export default _default;
20
24
  //# sourceMappingURL=CanvasDebugCoords.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CanvasDebugCoords.vue.d.ts","sourceRoot":"","sources":["../../src/components/CanvasDebugCoords.vue"],"names":[],"mappings":"AA0BA;"}
1
+ {"version":3,"file":"CanvasDebugCoords.vue.d.ts","sourceRoot":"","sources":["../../src/components/CanvasDebugCoords.vue"],"names":[],"mappings":"AA0BA;wBAwF0B,OAAO,YAAY;;oCAE/B,EAAE;qCACF,OAAO,KAAK,EAAE,gBAAgB;oCAG9B,EAAE;AAiIhB;;;;;;;;;;;;;;;;;kGAgCG"}
@@ -1,4 +1,11 @@
1
- declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
1
+ import { default as CanvasObjectResize } from './CanvasObjectResize.vue';
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
4
+ export type __VLS_LocalComponents = typeof __VLS_componentsOption;
5
+ export type __VLS_GlobalComponents = import('vue').GlobalComponents;
6
+ export type __VLS_LocalDirectives = {};
7
+ export type __VLS_Slots = ReturnType<typeof __VLS_template>["__VLS_Slots"];
8
+ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
2
9
  canvas: {
3
10
  type: ObjectConstructor;
4
11
  required: true;
@@ -112,5 +119,18 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
112
119
  };
113
120
  }>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
114
121
  }, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
115
- export default _default;
122
+ declare namespace __VLS_componentsOption {
123
+ export { CanvasObjectResize };
124
+ }
125
+ declare function __VLS_template(): {
126
+ __VLS_Slots: {
127
+ default?: (props: {
128
+ canvas: Record<string, any>;
129
+ objectId: string;
130
+ isSelected: any;
131
+ coords: any;
132
+ pos: Record<string, any>;
133
+ }) => any;
134
+ };
135
+ };
116
136
  //# sourceMappingURL=CanvasObject.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CanvasObject.vue.d.ts","sourceRoot":"","sources":["../../src/components/CanvasObject.vue"],"names":[],"mappings":"AAiBA;"}
1
+ {"version":3,"file":"CanvasObject.vue.d.ts","sourceRoot":"","sources":["../../src/components/CanvasObject.vue"],"names":[],"mappings":"AAiBA;wBAmJ0B,OAAO,YAAY;;oCAK/B,OAAO,sBAAsB;qCAC7B,OAAO,KAAK,EAAE,gBAAgB;oCAG9B,EAAE;0BA2CF,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,aAAa,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qEAuHG;;;;AAjKH;;kBAiCc,CAAC,KAAK;;;;;;SAAgB,KAAK,GAAG;;EAM3C;+BArD8B,0BAA0B"}
@@ -1,4 +1,9 @@
1
- declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
1
+ declare const _default: typeof __VLS_export;
2
+ export default _default;
3
+ export type __VLS_LocalComponents = {};
4
+ export type __VLS_GlobalComponents = import('vue').GlobalComponents;
5
+ export type __VLS_LocalDirectives = {};
6
+ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
2
7
  canvasObject: {
3
8
  type: ObjectConstructor;
4
9
  required: true;
@@ -17,5 +22,4 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
17
22
  required: true;
18
23
  };
19
24
  }>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
20
- export default _default;
21
25
  //# sourceMappingURL=CanvasObjectResize.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CanvasObjectResize.vue.d.ts","sourceRoot":"","sources":["../../src/components/CanvasObjectResize.vue"],"names":[],"mappings":"AAOA;"}
1
+ {"version":3,"file":"CanvasObjectResize.vue.d.ts","sourceRoot":"","sources":["../../src/components/CanvasObjectResize.vue"],"names":[],"mappings":"AAOA;wBAkG0B,OAAO,YAAY;;oCAE/B,EAAE;qCACF,OAAO,KAAK,EAAE,gBAAgB;oCAG9B,EAAE;AAgChB;;;;;;;;;;;;;;;;;;kGAOG"}
@@ -1,4 +1,11 @@
1
- declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
1
+ import { default as CanvasBoxSelect } from './CanvasBoxSelect.vue';
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
4
+ export type __VLS_LocalComponents = typeof __VLS_componentsOption;
5
+ export type __VLS_GlobalComponents = import('vue').GlobalComponents;
6
+ export type __VLS_LocalDirectives = {};
7
+ export type __VLS_Slots = ReturnType<typeof __VLS_template>["__VLS_Slots"];
8
+ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
2
9
  canvas: {
3
10
  type: ObjectConstructor;
4
11
  required: true;
@@ -23,5 +30,16 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
23
30
  };
24
31
  }>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
25
32
  }, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
26
- export default _default;
33
+ declare namespace __VLS_componentsOption {
34
+ export { CanvasBoxSelect };
35
+ }
36
+ declare function __VLS_template(): {
37
+ __VLS_Slots: {
38
+ default?: (props: {}) => any;
39
+ } & {
40
+ origin?: (props: {}) => any;
41
+ } & {
42
+ overlays?: (props: {}) => any;
43
+ };
44
+ };
27
45
  //# sourceMappingURL=CanvasView.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CanvasView.vue.d.ts","sourceRoot":"","sources":["../../src/components/CanvasView.vue"],"names":[],"mappings":"AA8BA;"}
1
+ {"version":3,"file":"CanvasView.vue.d.ts","sourceRoot":"","sources":["../../src/components/CanvasView.vue"],"names":[],"mappings":"AA8BA;wBA6G0B,OAAO,YAAY;;oCAK/B,OAAO,sBAAsB;qCAC7B,OAAO,KAAK,EAAE,gBAAgB;oCAG9B,EAAE;0BAoEF,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,aAAa,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;qEA0BG;;;;AA7FH;;kBAwDc,CAAC,KAAK,IAAgB,KAAK,GAAG;;iBAC/B,CAAC,KAAK,IAAgB,KAAK,GAAG;;mBAC5B,CAAC,KAAK,IAAiB,KAAK,GAAG;;EAM7C;4BA9E2B,uBAAuB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nightshadeui/canvas",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "Nightshade canvas viewport primitives",
5
5
  "author": "Boris Okunskiy",
6
6
  "license": "ISC",
@@ -25,8 +25,8 @@
25
25
  "vue": "^3.5.22"
26
26
  },
27
27
  "dependencies": {
28
- "@nightshadeui/util": "3.1.0",
29
- "@flexent/init-decorator": "^2.6.0",
28
+ "@nightshadeui/util": "3.2.0",
29
+ "@flexent/init-decorator": "^2.22.0",
30
30
  "mesh-ioc": "^4.3.1",
31
31
  "nanoevent": "^1.0.0"
32
32
  }
@@ -1,5 +1,4 @@
1
1
  import {
2
- createGridDotsSvg,
3
2
  DomEventProxy,
4
3
  getCssColorVar,
5
4
  getCssVarNumber,
@@ -45,19 +44,7 @@ export class CanvasViewport {
45
44
  }
46
45
 
47
46
  getCanvasStyle() {
48
- const majorColor = getCssColorVar(this.viewportEl, '--CanvasView-grid-major-fill', 'var(--border-deep)');
49
- const minorColor = getCssColorVar(this.viewportEl, '--CanvasView-grid-minor-fill', 'var(--border-base)');
50
- const subdivisions = getCssVarNumber(this.viewportEl, '--CanvasView-grid-subdivisions', 4);
51
- const majorRadius = getCssVarNumber(this.viewportEl, '--CanvasView-grid-major-radius', 2);
52
- const minorRadius = getCssVarNumber(this.viewportEl, '--CanvasView-grid-minor-radius', 1);
53
- const svg = createGridDotsSvg(
54
- this.space.cellSize,
55
- subdivisions,
56
- majorColor,
57
- majorRadius,
58
- minorColor,
59
- minorRadius,
60
- );
47
+ const svg = this.createGridSvg();
61
48
  const url = `data:image/svg+xml;base64,${window.btoa(svg)}`;
62
49
  return {
63
50
  background: `url(${url}) repeat`,
@@ -124,6 +111,36 @@ export class CanvasViewport {
124
111
  });
125
112
  }
126
113
 
114
+ /** One grid cell: minor dots at every subdivision, major dots at the corners. */
115
+ private createGridSvg() {
116
+ const cellSize = this.space.cellSize;
117
+ const subdivisions = getCssVarNumber(this.viewportEl, '--CanvasView-grid-subdivisions', 4);
118
+ const step = Math.round(cellSize / subdivisions);
119
+ const minorCoords = Array.from({ length: subdivisions + 1 }, (_, i) => i * step);
120
+ minorCoords[subdivisions] = cellSize;
121
+ const layers = [
122
+ {
123
+ coords: minorCoords,
124
+ radius: getCssVarNumber(this.viewportEl, '--CanvasView-grid-minor-radius', 1),
125
+ fill: getCssColorVar(this.viewportEl, '--CanvasView-grid-minor-fill', 'var(--border-base)'),
126
+ },
127
+ {
128
+ coords: [0, cellSize],
129
+ radius: getCssVarNumber(this.viewportEl, '--CanvasView-grid-major-radius', 2),
130
+ fill: getCssColorVar(this.viewportEl, '--CanvasView-grid-major-fill', 'var(--border-deep)'),
131
+ },
132
+ ];
133
+ const circles = layers
134
+ .filter(layer => layer.radius > 0)
135
+ .flatMap(layer => layer.coords.flatMap(x => layer.coords.map(y =>
136
+ `<circle cx="${x}" cy="${y}" r="${layer.radius}" fill="${layer.fill}"/>`)));
137
+ return [
138
+ `<svg xmlns="http://www.w3.org/2000/svg" width="${cellSize}" height="${cellSize}" viewBox="0 0 ${cellSize} ${cellSize}">`,
139
+ ...circles,
140
+ '</svg>',
141
+ ].join('');
142
+ }
143
+
127
144
  private setViewportScroll(pos: Point) {
128
145
  if (!this.viewportEl) {
129
146
  return;