@nuralyui/image 0.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.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Google Laabidi Aymen
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ import { LitElement } from 'lit';
7
+ import '../image.component';
8
+ import '../../../helpers/ThemeHandler';
9
+ export declare class ImageDemoElement extends LitElement {
10
+ render(): import("lit").TemplateResult<1>;
11
+ }
12
+ declare global {
13
+ interface HTMLElementTagNameMap {
14
+ 'hy-image-demo': ImageDemoElement;
15
+ }
16
+ }
17
+ //# sourceMappingURL=image-demo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-demo.d.ts","sourceRoot":"","sources":["../../../../src/components/image/demo/image-demo.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,UAAU,EAAO,MAAM,KAAK,CAAC;AAErC,OAAO,oBAAoB,CAAC;AAC5B,OAAO,+BAA+B,CAAC;AAEvC,qBACa,gBAAiB,SAAQ,UAAU;IACrC,MAAM;CA4ChB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,eAAe,EAAE,gBAAgB,CAAC;KACnC;CACF"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Google Laabidi Aymen
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
7
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
8
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9
+ 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;
10
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
11
+ };
12
+ import { LitElement, html } from 'lit';
13
+ import { customElement } from 'lit/decorators.js';
14
+ import '../image.component';
15
+ import '../../../helpers/ThemeHandler';
16
+ let ImageDemoElement = class ImageDemoElement extends LitElement {
17
+ render() {
18
+ return html `
19
+ <theme-handler>
20
+ <h2>With valid src and alt</h2>
21
+ <hy-image
22
+ .src="${'https://picsum.photos/200'}"
23
+ .alt="${'Image'}"
24
+ ></hy-image>
25
+ <h2>With custom width and height</h2>
26
+
27
+ <hy-image
28
+ .src="${'https://picsum.photos/200'}"
29
+ .width="${'100px'}"
30
+ .height="${'300px'}">
31
+ </hy-image>
32
+
33
+ <h2>With custom width and height and invalid src</h2>
34
+
35
+ <hy-image
36
+ .src="${'https://picsffum.photos/200'}"
37
+ .width="${'100px'}"
38
+ .height="${'300px'}">
39
+ </hy-image>
40
+
41
+ <h2>With invalid src and valid fallback provided</h2>
42
+ <hy-image
43
+ .src="${'https://picdsum.photos/200'}"
44
+ .fallback="${'https://placehold.co/50?text=image'}">
45
+ </hy-image>
46
+ <h2>With invalid src no fallback provided and without alt </h2>
47
+ <hy-image
48
+ .src="${'https://picdsum.photos/200'}"
49
+ ></hy-image>
50
+ <h2>With invalid src, invalid fallback provided and with alt</h2>
51
+ <hy-image
52
+ .src="${'https://picdsum.photos/200'}"
53
+ .fallback="${'https://placehfold.jp/150x150.png'}"
54
+ .alt="${'image'}"
55
+ >
56
+ </hy-image>
57
+
58
+ </theme-handler>
59
+ `;
60
+ }
61
+ };
62
+ ImageDemoElement = __decorate([
63
+ customElement('hy-image-demo')
64
+ ], ImageDemoElement);
65
+ export { ImageDemoElement };
66
+ //# sourceMappingURL=image-demo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-demo.js","sourceRoot":"","sources":["../../../../src/components/image/demo/image-demo.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;;;AAEH,OAAO,EAAC,UAAU,EAAE,IAAI,EAAC,MAAM,KAAK,CAAC;AACrC,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAChD,OAAO,oBAAoB,CAAC;AAC5B,OAAO,+BAA+B,CAAC;AAGvC,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,UAAU;IACrC,MAAM;QACb,OAAO,IAAI,CAAA;;;;oBAIK,2BAA2B;oBAC3B,OAAO;;;;;iBAKV,2BAA2B;mBACzB,OAAO;oBACN,OAAO;;;;;;iBAMV,6BAA6B;mBAC3B,OAAO;oBACN,OAAO;;;;;oBAKP,4BAA4B;yBACvB,oCAAoC;;;;qBAIxC,4BAA4B;;;;qBAI5B,4BAA4B;0BACvB,mCAAmC;qBACxC,OAAO;;;;;KAKvB,CAAC;IACJ,CAAC;CACF,CAAA;AA7CY,gBAAgB;IAD5B,aAAa,CAAC,eAAe,CAAC;GAClB,gBAAgB,CA6C5B;SA7CY,gBAAgB","sourcesContent":["/**\n * @license\n * Copyright 2023 Google Laabidi Aymen\n * SPDX-License-Identifier: MIT\n */\n\nimport {LitElement, html} from 'lit';\nimport {customElement} from 'lit/decorators.js';\nimport '../image.component';\nimport '../../../helpers/ThemeHandler';\n\n@customElement('hy-image-demo')\nexport class ImageDemoElement extends LitElement {\n override render() {\n return html`\n <theme-handler>\n <h2>With valid src and alt</h2>\n <hy-image\n .src=\"${'https://picsum.photos/200'}\"\n .alt=\"${'Image'}\"\n ></hy-image>\n <h2>With custom width and height</h2>\n\n <hy-image\n .src=\"${'https://picsum.photos/200'}\"\n .width=\"${'100px'}\"\n .height=\"${'300px'}\">\n </hy-image> \n\n <h2>With custom width and height and invalid src</h2>\n\n <hy-image\n .src=\"${'https://picsffum.photos/200'}\"\n .width=\"${'100px'}\"\n .height=\"${'300px'}\">\n </hy-image> \n\n <h2>With invalid src and valid fallback provided</h2>\n <hy-image\n .src=\"${'https://picdsum.photos/200'}\"\n .fallback=\"${'https://placehold.co/50?text=image'}\">\n </hy-image>\n <h2>With invalid src no fallback provided and without alt </h2>\n <hy-image\n .src=\"${'https://picdsum.photos/200'}\"\n ></hy-image>\n <h2>With invalid src, invalid fallback provided and with alt</h2>\n <hy-image\n .src=\"${'https://picdsum.photos/200'}\"\n .fallback=\"${'https://placehfold.jp/150x150.png'}\"\n .alt=\"${'image'}\"\n >\n </hy-image>\n\n </theme-handler>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'hy-image-demo': ImageDemoElement;\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import { LitElement, PropertyValues } from "lit";
2
+ export declare class HyImage extends LitElement {
3
+ src: string;
4
+ fallback: null;
5
+ width: string;
6
+ height: string;
7
+ alt: string;
8
+ image: string;
9
+ defaultFallBack: string;
10
+ willUpdate(_changedProperties: PropertyValues): void;
11
+ private handleError;
12
+ render(): import("lit").TemplateResult<1>;
13
+ }
14
+ //# sourceMappingURL=image.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.component.d.ts","sourceRoot":"","sources":["../../../src/components/image/image.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAC,cAAc,EAAO,MAAM,KAAK,CAAC;AAGrD,qBACa,OAAQ,SAAQ,UAAU;IAGnC,GAAG,EAAE,MAAM,CAAA;IAGX,QAAQ,OAAK;IAGb,KAAK,SAAO;IAGZ,MAAM,SAAO;IAGb,GAAG,SAAG;IAGN,KAAK,SAAG;IACR,eAAe,SAAqC;IAG3C,UAAU,CAAC,kBAAkB,EAAE,cAAc,GAAG,IAAI;IAO7D,OAAO,CAAC,WAAW;IAgBV,MAAM;CAYlB"}
@@ -0,0 +1,73 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { LitElement, html } from "lit";
8
+ import { customElement, property, state } from "lit/decorators.js";
9
+ let HyImage = class HyImage extends LitElement {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.fallback = null;
13
+ this.width = 'auto';
14
+ this.height = 'auto';
15
+ this.alt = '';
16
+ this.image = '';
17
+ this.defaultFallBack = 'https://placehold.co/50?text=image';
18
+ }
19
+ willUpdate(_changedProperties) {
20
+ if (_changedProperties.has('fallback') || _changedProperties.has('src')) {
21
+ this.image = this.src;
22
+ }
23
+ }
24
+ handleError() {
25
+ this.dispatchEvent(new CustomEvent('onError', {
26
+ bubbles: true,
27
+ composed: true,
28
+ detail: {
29
+ error: `error loading image ${this.image}`
30
+ }
31
+ }));
32
+ if (this.fallback && this.image !== this.fallback && this.image != this.defaultFallBack) {
33
+ this.image = this.fallback;
34
+ }
35
+ else if (this.image != this.defaultFallBack) {
36
+ this.image = this.defaultFallBack;
37
+ }
38
+ }
39
+ render() {
40
+ return html `
41
+ <img
42
+ src=${this.image}
43
+ @error=${this.handleError}
44
+ style="width:${this.width}; height:${this.height}"
45
+ alt=${this.alt}
46
+ />
47
+
48
+ `;
49
+ }
50
+ };
51
+ __decorate([
52
+ property()
53
+ ], HyImage.prototype, "src", void 0);
54
+ __decorate([
55
+ property()
56
+ ], HyImage.prototype, "fallback", void 0);
57
+ __decorate([
58
+ property()
59
+ ], HyImage.prototype, "width", void 0);
60
+ __decorate([
61
+ property()
62
+ ], HyImage.prototype, "height", void 0);
63
+ __decorate([
64
+ property()
65
+ ], HyImage.prototype, "alt", void 0);
66
+ __decorate([
67
+ state()
68
+ ], HyImage.prototype, "image", void 0);
69
+ HyImage = __decorate([
70
+ customElement('hy-image')
71
+ ], HyImage);
72
+ export { HyImage };
73
+ //# sourceMappingURL=image.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.component.js","sourceRoot":"","sources":["../../../src/components/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AK;iBACP,IAAI,CAAC,WAAW;uBACV,IAAI,CAAC,KAAK,YAAY,IAAI,CAAC,MAAM;cAC1C,IAAI,CAAC,GAAG;;;SAGb,CAAA;IACL,CAAC;CAEJ,CAAA;AAtDG;IADC,QAAQ,EAAE;oCACA;AAGX;IADC,QAAQ,EAAE;yCACE;AAGb;IADC,QAAQ,EAAE;sCACC;AAGZ;IADC,QAAQ,EAAE;uCACE;AAGb;IADC,QAAQ,EAAE;oCACL;AAGN;IADC,KAAK,EAAE;sCACA;AAlBC,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CAyDnB;SAzDY,OAAO","sourcesContent":["import { LitElement,PropertyValues,html } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\n\n@customElement('hy-image')\nexport class HyImage extends LitElement{\n\n @property()\n src!:string\n\n @property()\n fallback=null\n \n @property()\n width='auto'\n\n @property()\n height='auto'\n\n @property()\n alt=''\n\n @state()\n image=''\n defaultFallBack='https://placehold.co/50?text=image'\n\n\n override willUpdate(_changedProperties: PropertyValues): void {\n if(_changedProperties.has('fallback') || _changedProperties.has('src')){\n this.image = this.src;\n }\n }\n\n \n private handleError(){\n this.dispatchEvent(new CustomEvent('onError', {\n bubbles: true,\n composed: true,\n detail: {\n error:`error loading image ${this.image}`\n }\n }))\n if(this.fallback && this.image!== this.fallback && this.image!=this.defaultFallBack){\n this.image = this.fallback\n }\n else if(this.image!=this.defaultFallBack){\n this.image = this.defaultFallBack\n }\n }\n\n override render(){\n return html`\n <img \n src=${this.image}\n @error=${this.handleError}\n style=\"width:${this.width}; height:${this.height}\"\n alt=${this.alt}\n />\n \n `\n }\n\n}"]}
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './image.component.js';
2
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/image/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
package/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './image.component.js';
2
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/image/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC","sourcesContent":["export * from './image.component.js';\n"]}
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@nuralyui/image",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1"
9
+ },
10
+ "author": "Labidi Aymen",
11
+ "license": "ISC"
12
+ }