@leafer-in/html 1.0.0-rc.9 → 1.0.1

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.
package/dist/html.cjs ADDED
@@ -0,0 +1,88 @@
1
+ 'use strict';
2
+
3
+ var draw = require('@leafer-ui/draw');
4
+
5
+ /******************************************************************************
6
+ Copyright (c) Microsoft Corporation.
7
+
8
+ Permission to use, copy, modify, and/or distribute this software for any
9
+ purpose with or without fee is hereby granted.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
+ PERFORMANCE OF THIS SOFTWARE.
18
+ ***************************************************************************** */
19
+ /* global Reflect, Promise, SuppressedError, Symbol */
20
+
21
+
22
+ function __decorate(decorators, target, key, desc) {
23
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
24
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
25
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
26
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
27
+ }
28
+
29
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
30
+ var e = new Error(message);
31
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
32
+ };
33
+
34
+ class HTMLTextData extends draw.ImageData {
35
+ setText(value) {
36
+ this._text = value;
37
+ this.__htmlChanged = true;
38
+ }
39
+ }
40
+
41
+ exports.HTMLText = class HTMLText extends draw.Image {
42
+ get __tag() { return 'HTMLText'; }
43
+ constructor(data) {
44
+ super(data);
45
+ }
46
+ __updateBoxBounds() {
47
+ if (this.__.__htmlChanged) {
48
+ const div = document.createElement('div');
49
+ const { style } = div;
50
+ style.all = 'initial';
51
+ style.position = 'absolute';
52
+ style.visibility = 'hidden';
53
+ div.innerHTML = this.text;
54
+ document.body.appendChild(div);
55
+ const { width, height } = div.getBoundingClientRect();
56
+ const italicWidth = 10;
57
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${width + italicWidth}" height="${height}">
58
+ <foreignObject width="${width + italicWidth}" height="${height}">
59
+ <style>
60
+ * {
61
+ margin: 0;
62
+ padding: 0;
63
+ box-sizing: border-box;
64
+ }
65
+ </style>
66
+ <body xmlns="http://www.w3.org/1999/xhtml">
67
+ ${this.text}
68
+ </body>
69
+ </foreignObject>
70
+ </svg>`;
71
+ this.__.__setImageFill('data:image/svg+xml,' + encodeURIComponent(svg));
72
+ this.__.__htmlChanged = false;
73
+ div.remove();
74
+ }
75
+ super.__updateBoxBounds();
76
+ }
77
+ };
78
+ __decorate([
79
+ draw.dataProcessor(HTMLTextData)
80
+ ], exports.HTMLText.prototype, "__", void 0);
81
+ __decorate([
82
+ draw.boundsType('')
83
+ ], exports.HTMLText.prototype, "text", void 0);
84
+ exports.HTMLText = __decorate([
85
+ draw.registerUI()
86
+ ], exports.HTMLText);
87
+
88
+ exports.HTMLTextData = HTMLTextData;
package/dist/html.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ImageData, dataProcessor, boundsType, registerUI, Image } from '@leafer-ui/core';
1
+ import { ImageData, dataProcessor, boundsType, registerUI, Image } from '@leafer-ui/draw';
2
2
 
3
3
  /******************************************************************************
4
4
  Copyright (c) Microsoft Corporation.
@@ -83,4 +83,4 @@ HTMLText = __decorate([
83
83
  registerUI()
84
84
  ], HTMLText);
85
85
 
86
- export { HTMLText };
86
+ export { HTMLText, HTMLTextData };
@@ -1 +1 @@
1
- import{ImageData as e,dataProcessor as t,boundsType as n,registerUI as o,Image as i}from"@leafer-ui/core";function r(e,t,n,o){var i,r=arguments.length,s=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,o);else for(var d=e.length-1;d>=0;d--)(i=e[d])&&(s=(r<3?i(s):r>3?i(t,n,s):i(t,n))||s);return r>3&&s&&Object.defineProperty(t,n,s),s}"function"==typeof SuppressedError&&SuppressedError;let s=class extends i{get __tag(){return"HTMLText"}constructor(e){super(e)}__updateBoxBounds(){if(this.__.__htmlChanged){const e=document.createElement("div"),{style:t}=e;t.all="initial",t.position="absolute",t.visibility="hidden",e.innerHTML=this.text,document.body.appendChild(e);const{width:n,height:o}=e.getBoundingClientRect(),i=10,r=`<svg xmlns="http://www.w3.org/2000/svg" width="${n+i}" height="${o}">\n <foreignObject width="${n+i}" height="${o}">\n <style>\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n </style>\n <body xmlns="http://www.w3.org/1999/xhtml">\n ${this.text}\n </body>\n </foreignObject>\n </svg>`;this.__.__setImageFill("data:image/svg+xml,"+encodeURIComponent(r)),this.__.__htmlChanged=!1,e.remove()}super.__updateBoxBounds()}};r([t(class extends e{setText(e){this._text=e,this.__htmlChanged=!0}})],s.prototype,"__",void 0),r([n("")],s.prototype,"text",void 0),s=r([o()],s);export{s as HTMLText};
1
+ import{ImageData as t,dataProcessor as e,boundsType as n,registerUI as o,Image as i}from"@leafer-ui/draw";function r(t,e,n,o){var i,r=arguments.length,s=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,o);else for(var d=t.length-1;d>=0;d--)(i=t[d])&&(s=(r<3?i(s):r>3?i(e,n,s):i(e,n))||s);return r>3&&s&&Object.defineProperty(e,n,s),s}"function"==typeof SuppressedError&&SuppressedError;class s extends t{setText(t){this._text=t,this.__htmlChanged=!0}}let d=class extends i{get __tag(){return"HTMLText"}constructor(t){super(t)}__updateBoxBounds(){if(this.__.__htmlChanged){const t=document.createElement("div"),{style:e}=t;e.all="initial",e.position="absolute",e.visibility="hidden",t.innerHTML=this.text,document.body.appendChild(t);const{width:n,height:o}=t.getBoundingClientRect(),i=10,r=`<svg xmlns="http://www.w3.org/2000/svg" width="${n+i}" height="${o}">\n <foreignObject width="${n+i}" height="${o}">\n <style>\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n </style>\n <body xmlns="http://www.w3.org/1999/xhtml">\n ${this.text}\n </body>\n </foreignObject>\n </svg>`;this.__.__setImageFill("data:image/svg+xml,"+encodeURIComponent(r)),this.__.__htmlChanged=!1,t.remove()}super.__updateBoxBounds()}};r([e(s)],d.prototype,"__",void 0),r([n("")],d.prototype,"text",void 0),d=r([o()],d);export{d as HTMLText,s as HTMLTextData};
package/dist/html.js CHANGED
@@ -1,5 +1,5 @@
1
1
  this.LeaferIN = this.LeaferIN || {};
2
- this.LeaferIN.html = (function (exports, core) {
2
+ this.LeaferIN.html = (function (exports, draw) {
3
3
  'use strict';
4
4
 
5
5
  /******************************************************************************
@@ -31,14 +31,14 @@ this.LeaferIN.html = (function (exports, core) {
31
31
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
32
32
  };
33
33
 
34
- class HTMLTextData extends core.ImageData {
34
+ class HTMLTextData extends draw.ImageData {
35
35
  setText(value) {
36
36
  this._text = value;
37
37
  this.__htmlChanged = true;
38
38
  }
39
39
  }
40
40
 
41
- exports.HTMLText = class HTMLText extends core.Image {
41
+ exports.HTMLText = class HTMLText extends draw.Image {
42
42
  get __tag() { return 'HTMLText'; }
43
43
  constructor(data) {
44
44
  super(data);
@@ -76,15 +76,17 @@ this.LeaferIN.html = (function (exports, core) {
76
76
  }
77
77
  };
78
78
  __decorate([
79
- core.dataProcessor(HTMLTextData)
79
+ draw.dataProcessor(HTMLTextData)
80
80
  ], exports.HTMLText.prototype, "__", void 0);
81
81
  __decorate([
82
- core.boundsType('')
82
+ draw.boundsType('')
83
83
  ], exports.HTMLText.prototype, "text", void 0);
84
84
  exports.HTMLText = __decorate([
85
- core.registerUI()
85
+ draw.registerUI()
86
86
  ], exports.HTMLText);
87
87
 
88
+ exports.HTMLTextData = HTMLTextData;
89
+
88
90
  return exports;
89
91
 
90
92
  })({}, LeaferUI);
@@ -0,0 +1 @@
1
+ "use strict";var e=require("@leafer-ui/draw");function t(e,t,n,o){var r,s=arguments.length,i=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,o);else for(var d=e.length-1;d>=0;d--)(r=e[d])&&(i=(s<3?r(i):s>3?r(t,n,i):r(t,n))||i);return s>3&&i&&Object.defineProperty(t,n,i),i}"function"==typeof SuppressedError&&SuppressedError;class n extends e.ImageData{setText(e){this._text=e,this.__htmlChanged=!0}}exports.HTMLText=class extends e.Image{get __tag(){return"HTMLText"}constructor(e){super(e)}__updateBoxBounds(){if(this.__.__htmlChanged){const e=document.createElement("div"),{style:t}=e;t.all="initial",t.position="absolute",t.visibility="hidden",e.innerHTML=this.text,document.body.appendChild(e);const{width:n,height:o}=e.getBoundingClientRect(),r=10,s=`<svg xmlns="http://www.w3.org/2000/svg" width="${n+r}" height="${o}">\n <foreignObject width="${n+r}" height="${o}">\n <style>\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n </style>\n <body xmlns="http://www.w3.org/1999/xhtml">\n ${this.text}\n </body>\n </foreignObject>\n </svg>`;this.__.__setImageFill("data:image/svg+xml,"+encodeURIComponent(s)),this.__.__htmlChanged=!1,e.remove()}super.__updateBoxBounds()}},t([e.dataProcessor(n)],exports.HTMLText.prototype,"__",void 0),t([e.boundsType("")],exports.HTMLText.prototype,"text",void 0),exports.HTMLText=t([e.registerUI()],exports.HTMLText),exports.HTMLTextData=n;
package/dist/html.min.js CHANGED
@@ -1 +1 @@
1
- this.LeaferIN=this.LeaferIN||{},this.LeaferIN.html=function(e,t){"use strict";function n(e,t,n,o){var i,r=arguments.length,s=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,o);else for(var d=e.length-1;d>=0;d--)(i=e[d])&&(s=(r<3?i(s):r>3?i(t,n,s):i(t,n))||s);return r>3&&s&&Object.defineProperty(t,n,s),s}"function"==typeof SuppressedError&&SuppressedError;class o extends t.ImageData{setText(e){this._text=e,this.__htmlChanged=!0}}return e.HTMLText=class extends t.Image{get __tag(){return"HTMLText"}constructor(e){super(e)}__updateBoxBounds(){if(this.__.__htmlChanged){const e=document.createElement("div"),{style:t}=e;t.all="initial",t.position="absolute",t.visibility="hidden",e.innerHTML=this.text,document.body.appendChild(e);const{width:n,height:o}=e.getBoundingClientRect(),i=10,r=`<svg xmlns="http://www.w3.org/2000/svg" width="${n+i}" height="${o}">\n <foreignObject width="${n+i}" height="${o}">\n <style>\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n </style>\n <body xmlns="http://www.w3.org/1999/xhtml">\n ${this.text}\n </body>\n </foreignObject>\n </svg>`;this.__.__setImageFill("data:image/svg+xml,"+encodeURIComponent(r)),this.__.__htmlChanged=!1,e.remove()}super.__updateBoxBounds()}},n([t.dataProcessor(o)],e.HTMLText.prototype,"__",void 0),n([t.boundsType("")],e.HTMLText.prototype,"text",void 0),e.HTMLText=n([t.registerUI()],e.HTMLText),e}({},LeaferUI);
1
+ this.LeaferIN=this.LeaferIN||{},this.LeaferIN.html=function(e,t){"use strict";function n(e,t,n,o){var i,r=arguments.length,s=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,o);else for(var d=e.length-1;d>=0;d--)(i=e[d])&&(s=(r<3?i(s):r>3?i(t,n,s):i(t,n))||s);return r>3&&s&&Object.defineProperty(t,n,s),s}"function"==typeof SuppressedError&&SuppressedError;class o extends t.ImageData{setText(e){this._text=e,this.__htmlChanged=!0}}return e.HTMLText=class extends t.Image{get __tag(){return"HTMLText"}constructor(e){super(e)}__updateBoxBounds(){if(this.__.__htmlChanged){const e=document.createElement("div"),{style:t}=e;t.all="initial",t.position="absolute",t.visibility="hidden",e.innerHTML=this.text,document.body.appendChild(e);const{width:n,height:o}=e.getBoundingClientRect(),i=10,r=`<svg xmlns="http://www.w3.org/2000/svg" width="${n+i}" height="${o}">\n <foreignObject width="${n+i}" height="${o}">\n <style>\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n </style>\n <body xmlns="http://www.w3.org/1999/xhtml">\n ${this.text}\n </body>\n </foreignObject>\n </svg>`;this.__.__setImageFill("data:image/svg+xml,"+encodeURIComponent(r)),this.__.__htmlChanged=!1,e.remove()}super.__updateBoxBounds()}},n([t.dataProcessor(o)],e.HTMLText.prototype,"__",void 0),n([t.boundsType("")],e.HTMLText.prototype,"text",void 0),e.HTMLText=n([t.registerUI()],e.HTMLText),e.HTMLTextData=o,e}({},LeaferUI);
package/package.json CHANGED
@@ -1,13 +1,19 @@
1
1
  {
2
2
  "name": "@leafer-in/html",
3
- "version": "1.0.0-rc.9",
3
+ "version": "1.0.1",
4
4
  "description": "@leafer-in/html",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
7
+ "type": "module",
7
8
  "main": "dist/html.esm.js",
9
+ "exports": {
10
+ "import": "./dist/html.esm.js",
11
+ "require": "./dist/html.cjs",
12
+ "types": "./types/index.d.ts"
13
+ },
14
+ "types": "types/index.d.ts",
8
15
  "unpkg": "dist/html.js",
9
16
  "jsdelivr": "dist/html.js",
10
- "types": "types/index.d.ts",
11
17
  "files": [
12
18
  "src",
13
19
  "types",
@@ -28,10 +34,8 @@
28
34
  "leaferjs"
29
35
  ],
30
36
  "dependencies": {
31
- "@leafer-ui/core": "1.0.0-rc.9"
32
- },
33
- "devDependencies": {
34
- "@leafer-ui/interface": "1.0.0-rc.9",
35
- "@leafer-in/interface": "1.0.0-rc.9"
37
+ "@leafer-ui/draw": "1.0.1",
38
+ "@leafer-ui/interface": "1.0.1",
39
+ "@leafer-in/interface": "1.0.1"
36
40
  }
37
41
  }
package/src/HTMLText.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { IString, IImage } from '@leafer-ui/interface'
2
- import { Image, boundsType, registerUI, dataProcessor } from '@leafer-ui/core'
2
+ import { Image, boundsType, registerUI, dataProcessor } from '@leafer-ui/draw'
3
3
 
4
4
  import { IHTMLTextData, IHTMLTextInputData } from '@leafer-in/interface'
5
5
 
@@ -15,7 +15,7 @@ export class HTMLText extends Image implements IImage {
15
15
  declare public __: IHTMLTextData
16
16
 
17
17
  @boundsType('')
18
- public text: IString
18
+ public text?: IString
19
19
 
20
20
  constructor(data?: IHTMLTextInputData) {
21
21
  super(data)
@@ -1,5 +1,5 @@
1
1
  import { IString } from '@leafer-ui/interface'
2
- import { ImageData } from '@leafer-ui/core'
2
+ import { ImageData } from '@leafer-ui/draw'
3
3
 
4
4
  import { IHTMLTextData } from '@leafer-in/interface'
5
5
 
package/src/index.ts CHANGED
@@ -1 +1,2 @@
1
- export { HTMLText } from './HTMLText'
1
+ export { HTMLText } from './HTMLText'
2
+ export { HTMLTextData } from './data/HTMLTextData'
package/types/index.d.ts CHANGED
@@ -1,13 +1,19 @@
1
1
  import { IImage, IString } from '@leafer-ui/interface';
2
- import { Image } from '@leafer-ui/core';
2
+ import { Image, ImageData } from '@leafer-ui/draw';
3
3
  import { IHTMLTextData, IHTMLTextInputData } from '@leafer-in/interface';
4
4
 
5
5
  declare class HTMLText extends Image implements IImage {
6
6
  get __tag(): string;
7
7
  __: IHTMLTextData;
8
- text: IString;
8
+ text?: IString;
9
9
  constructor(data?: IHTMLTextInputData);
10
10
  __updateBoxBounds(): void;
11
11
  }
12
12
 
13
- export { HTMLText };
13
+ declare class HTMLTextData extends ImageData implements IHTMLTextData {
14
+ _text: string;
15
+ __htmlChanged: boolean;
16
+ setText(value: IString): void;
17
+ }
18
+
19
+ export { HTMLText, HTMLTextData };