@digital-realty/ix-timer 3.2.14

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 ix-timer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # \<ix-timer>
2
+
3
+ This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm i @digital-realty/ix-timer
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```html
14
+ <script type="module">
15
+ import '@digital-realty/ix-timer/ix-timer.js';
16
+ </script>
17
+
18
+ <ix-timer></ix-timer>
19
+ ```
20
+ ### In React
21
+ ```html
22
+ <script type="module">
23
+ import { IxButton } from '@digital-realty/ix-timer/IxButton'
24
+ </script>
25
+ ```
26
+
27
+
28
+ ## Demo and Documentation
29
+
30
+ Full documentation and demo are available at [DLR Component Gallery](https://inxn-p1-uicomponentgallery.azurewebsites.net/?path=/story/inxn-ix-timer--default).
@@ -0,0 +1,11 @@
1
+ import { LitElement } from 'lit';
2
+ import '@digital-realty/ix-icon/ix-icon.js';
3
+ export declare class IxTimer extends LitElement {
4
+ label: string;
5
+ duration: number;
6
+ onFinished?: any;
7
+ private timer?;
8
+ constructor();
9
+ connectedCallback(): void;
10
+ render(): import("lit").TemplateResult<1>;
11
+ }
@@ -0,0 +1,37 @@
1
+ import { __decorate } from "tslib";
2
+ import { html, LitElement } from 'lit';
3
+ import { asyncReplace } from 'lit/directives/async-replace.js';
4
+ import { property, state } from 'lit/decorators.js';
5
+ import '@digital-realty/ix-icon/ix-icon.js';
6
+ import countDownAsync from './countDownAsync.js';
7
+ export class IxTimer extends LitElement {
8
+ constructor() {
9
+ super();
10
+ this.label = '';
11
+ this.duration = 10;
12
+ this.onFinished = () => { };
13
+ }
14
+ connectedCallback() {
15
+ super.connectedCallback();
16
+ this.timer = countDownAsync(this.duration, this.onFinished);
17
+ }
18
+ render() {
19
+ return html ` <div class="timer-container">
20
+ <ix-icon>timer</ix-icon>
21
+ ${this.label} ${this.timer ? asyncReplace(this.timer) : ''}s
22
+ </div>`;
23
+ }
24
+ }
25
+ __decorate([
26
+ property({ type: String })
27
+ ], IxTimer.prototype, "label", void 0);
28
+ __decorate([
29
+ property({ type: Number })
30
+ ], IxTimer.prototype, "duration", void 0);
31
+ __decorate([
32
+ property({ attribute: false })
33
+ ], IxTimer.prototype, "onFinished", void 0);
34
+ __decorate([
35
+ state()
36
+ ], IxTimer.prototype, "timer", void 0);
37
+ //# sourceMappingURL=IxTimer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IxTimer.js","sourceRoot":"","sources":["../src/IxTimer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,oCAAoC,CAAC;AAC5C,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,MAAM,OAAO,OAAQ,SAAQ,UAAU;IAUrC;QACE,KAAK,EAAE,CAAC;QAVkB,UAAK,GAAG,EAAE,CAAC;QAEX,aAAQ,GAAG,EAAE,CAAC;QASxC,IAAI,CAAC,UAAU,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;IAC7B,CAAC;IAEQ,iBAAiB;QACxB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC9D,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA;;QAEP,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;WACrD,CAAC;IACV,CAAC;CACF;AAzB6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCAAY;AAEX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAe;AAEV;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;2CAAkB;AAGzC;IADP,KAAK,EAAE;sCAC+B","sourcesContent":["import { html, LitElement } from 'lit';\nimport { asyncReplace } from 'lit/directives/async-replace.js';\nimport { property, state } from 'lit/decorators.js';\nimport '@digital-realty/ix-icon/ix-icon.js';\nimport countDownAsync from './countDownAsync.js';\n\nexport class IxTimer extends LitElement {\n @property({ type: String }) label = '';\n\n @property({ type: Number }) duration = 10;\n\n @property({ attribute: false }) onFinished?: any;\n\n @state()\n private timer?: AsyncGenerator<number>;\n\n constructor() {\n super();\n this.onFinished = () => {};\n }\n\n override connectedCallback() {\n super.connectedCallback();\n this.timer = countDownAsync(this.duration, this.onFinished);\n }\n\n override render() {\n return html` <div class=\"timer-container\">\n <ix-icon>timer</ix-icon>\n ${this.label} ${this.timer ? asyncReplace(this.timer) : ''}s\n </div>`;\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ declare function countDownAsync(duration: number, onFinished?: () => void): AsyncGenerator<number, void, unknown>;
2
+ export default countDownAsync;
@@ -0,0 +1,12 @@
1
+ async function* countDownAsync(duration, onFinished) {
2
+ let currentDuration = duration;
3
+ while (currentDuration > 0) {
4
+ yield (currentDuration -= 1);
5
+ /* eslint-disable */
6
+ await new Promise(r => setTimeout(r, 1000));
7
+ /* eslint-enable */
8
+ }
9
+ onFinished === null || onFinished === void 0 ? void 0 : onFinished();
10
+ }
11
+ export default countDownAsync;
12
+ //# sourceMappingURL=countDownAsync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"countDownAsync.js","sourceRoot":"","sources":["../src/countDownAsync.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,CAAC,CAAC,cAAc,CAAC,QAAgB,EAAE,UAAuB;IACtE,IAAI,eAAe,GAAG,QAAQ,CAAC;IAC/B,OAAO,eAAe,GAAG,CAAC,EAAE,CAAC;QAC3B,MAAM,CAAC,eAAe,IAAI,CAAC,CAAC,CAAC;QAC7B,oBAAoB;QACpB,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;QAC5C,mBAAmB;IACrB,CAAC;IACD,UAAU,aAAV,UAAU,uBAAV,UAAU,EAAI,CAAC;AACjB,CAAC;AAED,eAAe,cAAc,CAAC","sourcesContent":["async function* countDownAsync(duration: number, onFinished?: () => void) {\n let currentDuration = duration;\n while (currentDuration > 0) {\n yield (currentDuration -= 1);\n /* eslint-disable */\n await new Promise(r => setTimeout(r, 1000));\n /* eslint-enable */\n }\n onFinished?.();\n}\n\nexport default countDownAsync;\n"]}
@@ -0,0 +1 @@
1
+ export { IxTimer } from './IxTimer.js';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { IxTimer } from './IxTimer.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { IxTimer } from './IxTimer.js';\n"]}
@@ -0,0 +1,4 @@
1
+ import { IxTimer } from './IxTimer.js';
2
+ export declare class IxTimerStyled extends IxTimer {
3
+ static styles: import("lit").CSSResult;
4
+ }
@@ -0,0 +1,17 @@
1
+ import { css } from 'lit';
2
+ import { IxTimer } from './IxTimer.js';
3
+ export class IxTimerStyled extends IxTimer {
4
+ }
5
+ IxTimerStyled.styles = css `
6
+ .timer-container {
7
+ display: flex;
8
+ justify-content: center;
9
+ align-items: center;
10
+ }
11
+ ix-icon {
12
+ font-size: 16px;
13
+ margin-top: 4px;
14
+ }
15
+ `;
16
+ window.customElements.define('ix-timer', IxTimerStyled);
17
+ //# sourceMappingURL=ix-timer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ix-timer.js","sourceRoot":"","sources":["../src/ix-timer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,OAAO,aAAc,SAAQ,OAAO;;AACxB,oBAAM,GAAG,GAAG,CAAA;;;;;;;;;;GAU3B,CAAC;AAGJ,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import { css } from 'lit';\nimport { IxTimer } from './IxTimer.js';\n\nexport class IxTimerStyled extends IxTimer {\n static override styles = css`\n .timer-container {\n display: flex;\n justify-content: center;\n align-items: center;\n }\n ix-icon {\n font-size: 16px;\n margin-top: 4px;\n }\n `;\n}\n\nwindow.customElements.define('ix-timer', IxTimerStyled);\n"]}
@@ -0,0 +1,2 @@
1
+ import { IxTimer as IxTimerLit } from '../IxTimer.js';
2
+ export declare const IxTimer: import("@lit/react").ReactWebComponent<IxTimerLit, {}>;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { createComponent } from '@lit/react';
3
+ import { IxTimer as IxTimerLit } from '../IxTimer.js';
4
+ customElements.define('ix-timer', IxTimerLit);
5
+ export const IxTimer = createComponent({
6
+ tagName: 'ix-timer',
7
+ elementClass: IxTimerLit,
8
+ react: React,
9
+ });
10
+ //# sourceMappingURL=IxTimer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IxTimer.js","sourceRoot":"","sources":["../../src/react/IxTimer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AAEtD,cAAc,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAE9C,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC;IACrC,OAAO,EAAE,UAAU;IACnB,YAAY,EAAE,UAAU;IACxB,KAAK,EAAE,KAAK;CACb,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { createComponent } from '@lit/react';\nimport { IxTimer as IxTimerLit } from '../IxTimer.js';\n\ncustomElements.define('ix-timer', IxTimerLit);\n\nexport const IxTimer = createComponent({\n tagName: 'ix-timer',\n elementClass: IxTimerLit,\n react: React,\n});\n"]}
package/package.json ADDED
@@ -0,0 +1,106 @@
1
+ {
2
+ "name": "@digital-realty/ix-timer",
3
+ "description": "Webcomponent ix-timer following open-wc recommendations",
4
+ "license": "MIT",
5
+ "author": "Digital Realty",
6
+ "version": "3.2.14",
7
+ "type": "module",
8
+ "main": "dist/index.js",
9
+ "module": "dist/index.js",
10
+ "exports": {
11
+ ".": "./dist/index.js",
12
+ "./ix-timer.js": "./dist/ix-timer.js",
13
+ "./IxTimer": "./dist/react/IxTimer.js"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "scripts": {
19
+ "analyze": "cem analyze --litelement",
20
+ "start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
21
+ "build": "tsc && npm run analyze -- --exclude dist",
22
+ "prepublish": "tsc && npm run analyze -- --exclude dist",
23
+ "lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
24
+ "format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
25
+ "test": "tsc && wtr --coverage",
26
+ "test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\""
27
+ },
28
+ "dependencies": {
29
+ "@digital-realty/ix-icon": "*",
30
+ "@lit/react": "^1.0.2",
31
+ "lit": "^2.0.2",
32
+ "react": "^18.2.0"
33
+ },
34
+ "devDependencies": {
35
+ "@custom-elements-manifest/analyzer": "^0.4.17",
36
+ "@open-wc/eslint-config": "^9.2.1",
37
+ "@open-wc/testing": "^3.1.6",
38
+ "@types/react": "^18.2.22",
39
+ "@typescript-eslint/eslint-plugin": "^5.48.0",
40
+ "@typescript-eslint/parser": "^5.48.0",
41
+ "@web/dev-server": "^0.1.34",
42
+ "@web/test-runner": "^0.14.0",
43
+ "concurrently": "^5.3.0",
44
+ "eslint": "^8.31.0",
45
+ "eslint-config-prettier": "^8.3.0",
46
+ "husky": "^4.3.8",
47
+ "lint-staged": "^10.5.4",
48
+ "prettier": "^2.4.1",
49
+ "tslib": "^2.3.1",
50
+ "typescript": "^5.1.6"
51
+ },
52
+ "customElements": "custom-elements.json",
53
+ "eslintConfig": {
54
+ "parser": "@typescript-eslint/parser",
55
+ "root": true,
56
+ "extends": [
57
+ "@open-wc/eslint-config",
58
+ "eslint-config-prettier",
59
+ "plugin:json/recommended"
60
+ ],
61
+ "plugins": [
62
+ "@typescript-eslint"
63
+ ],
64
+ "rules": {
65
+ "no-unused-vars": "off",
66
+ "@typescript-eslint/no-unused-vars": [
67
+ "error"
68
+ ],
69
+ "class-methods-use-this": "off",
70
+ "import/no-unresolved": "off",
71
+ "import/extensions": [
72
+ "error",
73
+ "always",
74
+ {
75
+ "ignorePackages": true
76
+ }
77
+ ]
78
+ },
79
+ "globals": {
80
+ "ShadowRootInit": true
81
+ }
82
+ },
83
+ "prettier": {
84
+ "singleQuote": true,
85
+ "arrowParens": "avoid"
86
+ },
87
+ "husky": {
88
+ "hooks": {
89
+ "pre-commit": "lint-staged"
90
+ }
91
+ },
92
+ "lint-staged": {
93
+ "*.ts": [
94
+ "eslint --fix",
95
+ "prettier --write"
96
+ ]
97
+ },
98
+ "files": [
99
+ "/dist",
100
+ "!/dist/test",
101
+ "package.json",
102
+ "README.md",
103
+ "LICENSE"
104
+ ],
105
+ "gitHead": "2cb2757c95df9570672b39b8506c31642d683a45"
106
+ }