@3t-transform/threeteeui 0.1.5 → 0.1.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.
- package/dist/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/css-shim-211819bc.js +6 -0
- package/dist/cjs/dom-9deb26c8.js +75 -0
- package/dist/cjs/index-11cfdabe.js +3297 -0
- package/dist/cjs/{index-906c2757.js → index-451f61dd.js} +3 -102
- package/dist/cjs/loader.cjs.js +19 -4
- package/dist/cjs/shadow-css-bf3843d2.js +389 -0
- package/dist/cjs/{tttx-button_2.cjs.entry.js → tttx-button.cjs.entry.js} +24 -50
- package/dist/cjs/tttx-form.cjs.entry.js +364 -364
- package/dist/cjs/tttx-icon.cjs.entry.js +21 -0
- package/dist/cjs/tttx-keyvalue-block.cjs.entry.js +57 -57
- package/dist/cjs/tttx-list.cjs.entry.js +76 -46
- package/dist/cjs/tttx-loading-spinner.cjs.entry.js +16 -16
- package/dist/cjs/tttx-standalone-input.cjs.entry.js +61 -58
- package/dist/cjs/tttx-toolbar.cjs.entry.js +20 -0
- package/dist/cjs/tttx.cjs.js +117 -9
- package/dist/collection/collection-manifest.json +4 -3
- package/dist/collection/components/atoms/tttx-button/test/tttx-button.e2e.js +9 -0
- package/dist/collection/components/atoms/tttx-button/test/tttx-button.spec.js +83 -0
- package/dist/collection/components/atoms/tttx-button/tttx-button.js +110 -116
- package/dist/collection/components/atoms/tttx-button/tttx-button.stories.js +14 -14
- package/dist/collection/components/atoms/tttx-icon/test/tttx-icon.e2e.js +9 -0
- package/dist/collection/components/atoms/tttx-icon/test/tttx-icon.spec.js +16 -0
- package/dist/collection/components/atoms/tttx-icon/tttx-icon.css +4 -0
- package/dist/collection/components/atoms/tttx-icon/tttx-icon.js +62 -62
- package/dist/collection/components/atoms/tttx-icon/tttx-icon.stories.js +22 -22
- package/dist/collection/components/atoms/tttx-keyvalue-block/test/tttx-keyvalue-block.spec.js +216 -0
- package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.js +107 -107
- package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.js +38 -38
- package/dist/collection/components/atoms/tttx-loading-spinner/Test/tttx-loading-spinner.spec.js +64 -0
- package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.js +67 -67
- package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.js +17 -17
- package/dist/collection/components/molecules/tttx-form/lib/setErrorState.js +35 -35
- package/dist/collection/components/molecules/tttx-form/lib/setErrorState.spec.js +38 -0
- package/dist/collection/components/molecules/tttx-form/lib/validityCheck.js +58 -58
- package/dist/collection/components/molecules/tttx-form/lib/validityCheck.spec.js +214 -0
- package/dist/collection/components/molecules/tttx-form/test/tttx-form.e2e.js +9 -0
- package/dist/collection/components/molecules/tttx-form/test/tttx-form.spec.js +232 -0
- package/dist/collection/components/molecules/tttx-form/tttx-form.css +32 -3
- package/dist/collection/components/molecules/tttx-form/tttx-form.js +364 -364
- package/dist/collection/components/molecules/tttx-form/tttx-form.stories.js +127 -127
- package/dist/collection/components/molecules/tttx-list/test/ttttx-list.spec.e2e.js +26 -0
- package/dist/collection/components/molecules/tttx-list/test/tttx-list.spec.js +183 -0
- package/dist/collection/components/molecules/tttx-list/tttx-list.js +105 -105
- package/dist/collection/components/molecules/tttx-list/tttx-list.stories.js +43 -43
- package/dist/collection/components/molecules/tttx-standalone-input/test/tttx-standalone-input.e2e.js +9 -0
- package/dist/collection/components/molecules/tttx-standalone-input/test/tttx-standalone-input.spec.js +219 -0
- package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.css +32 -3
- package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.js +627 -572
- package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.js +148 -135
- package/dist/collection/components/molecules/tttx-toolbar/test/tttx-toolbar.test.js +0 -0
- package/dist/collection/components/molecules/tttx-toolbar/tttx-toolbar.css +30 -0
- package/dist/collection/components/molecules/tttx-toolbar/tttx-toolbar.js +44 -0
- package/dist/collection/components/molecules/tttx-toolbar/tttx-toolbar.stories.js +20 -0
- package/dist/collection/components/palette.stories.js +7 -7
- package/dist/collection/docs/gettingstarted-developer.stories.js +5 -5
- package/dist/collection/icons.js +2838 -2838
- package/dist/collection/index.js +1 -1
- package/dist/collection/shared/domsanitiser.options.js +14 -14
- package/dist/collection/shared/test/domsanitiser.options.spec.js +23 -0
- package/dist/components/index.d.ts +1 -9
- package/dist/components/index.js +6 -1
- package/dist/components/tttx-button.js +48 -59
- package/dist/components/tttx-form.js +381 -381
- package/dist/components/tttx-icon2.js +29 -29
- package/dist/components/tttx-keyvalue-block.js +74 -74
- package/dist/components/tttx-list.js +98 -68
- package/dist/components/tttx-loading-spinner.js +33 -33
- package/dist/components/tttx-standalone-input.js +108 -102
- package/dist/components/tttx-toolbar.d.ts +11 -0
- package/dist/components/tttx-toolbar.js +36 -0
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/css-shim-9d54a2f2.js +4 -0
- package/dist/esm/dom-6be6f662.js +73 -0
- package/dist/esm/{index-4010ad69.js → index-0350f122.js} +4 -101
- package/dist/esm/index-dbe25028.js +3262 -0
- package/dist/esm/loader.js +19 -4
- package/dist/esm/polyfills/core-js.js +0 -0
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/polyfills/dom.js +0 -0
- package/dist/esm/polyfills/es5-html-element.js +0 -0
- package/dist/esm/polyfills/index.js +0 -0
- package/dist/esm/polyfills/system.js +0 -0
- package/dist/esm/shadow-css-ed4599f8.js +387 -0
- package/dist/esm/{tttx-button_2.entry.js → tttx-button.entry.js} +25 -50
- package/dist/esm/tttx-form.entry.js +364 -364
- package/dist/esm/tttx-icon.entry.js +17 -0
- package/dist/esm/tttx-keyvalue-block.entry.js +57 -57
- package/dist/esm/tttx-list.entry.js +76 -46
- package/dist/esm/tttx-loading-spinner.entry.js +16 -16
- package/dist/esm/tttx-standalone-input.entry.js +61 -58
- package/dist/esm/tttx-toolbar.entry.js +16 -0
- package/dist/esm/tttx.js +117 -6
- package/dist/tttx/app-globals-0f993ce5.js +3 -0
- package/dist/tttx/css-shim-9d54a2f2.js +4 -0
- package/dist/tttx/dom-6be6f662.js +73 -0
- package/dist/tttx/index-dbe25028.js +3262 -0
- package/dist/tttx/index.esm.js +1 -0
- package/dist/tttx/p-0a85dda4.entry.js +1 -0
- package/dist/tttx/{p-3281444a.entry.js → p-1b015a9d.entry.js} +1 -1
- package/dist/tttx/p-4f3958fa.entry.js +1 -0
- package/dist/tttx/p-5cae1beb.entry.js +1 -0
- package/dist/tttx/p-62869344.js +2 -0
- package/dist/tttx/p-92465671.entry.js +1 -0
- package/dist/tttx/{p-dab7ee1b.entry.js → p-a0179cb1.entry.js} +1 -1
- package/dist/tttx/p-cc6644c9.entry.js +1 -0
- package/dist/tttx/p-cd1565e0.entry.js +3 -0
- package/dist/tttx/shadow-css-ed4599f8.js +387 -0
- package/dist/tttx/tttx-button.entry.js +30 -0
- package/dist/tttx/tttx-form.entry.js +373 -0
- package/dist/tttx/tttx-icon.entry.js +17 -0
- package/dist/tttx/tttx-keyvalue-block.entry.js +63 -0
- package/dist/tttx/tttx-list.entry.js +1730 -0
- package/dist/tttx/tttx-loading-spinner.entry.js +22 -0
- package/dist/tttx/tttx-standalone-input.entry.js +66 -0
- package/dist/tttx/tttx-toolbar.entry.js +16 -0
- package/dist/tttx/tttx.esm.js +129 -1
- package/dist/types/components/atoms/tttx-button/test/tttx-button.e2e.d.ts +1 -0
- package/dist/types/components/atoms/tttx-button/test/tttx-button.spec.d.ts +1 -0
- package/dist/types/components/atoms/tttx-button/tttx-button.d.ts +10 -13
- package/dist/types/components/atoms/tttx-button/tttx-button.stories.d.ts +10 -10
- package/dist/types/components/atoms/tttx-icon/test/tttx-icon.e2e.d.ts +1 -0
- package/dist/types/components/atoms/tttx-icon/test/tttx-icon.spec.d.ts +1 -0
- package/dist/types/components/atoms/tttx-icon/tttx-icon.d.ts +5 -5
- package/dist/types/components/atoms/tttx-icon/tttx-icon.stories.d.ts +20 -20
- package/dist/types/components/atoms/tttx-keyvalue-block/test/tttx-keyvalue-block.spec.d.ts +1 -0
- package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.d.ts +7 -7
- package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.d.ts +9 -9
- package/dist/types/components/atoms/tttx-loading-spinner/Test/tttx-loading-spinner.spec.d.ts +1 -0
- package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.d.ts +6 -6
- package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.d.ts +17 -17
- package/dist/types/components/molecules/tttx-form/lib/setErrorState.d.ts +13 -13
- package/dist/types/components/molecules/tttx-form/lib/setErrorState.spec.d.ts +1 -0
- package/dist/types/components/molecules/tttx-form/lib/validityCheck.d.ts +17 -17
- package/dist/types/components/molecules/tttx-form/lib/validityCheck.spec.d.ts +1 -0
- package/dist/types/components/molecules/tttx-form/test/tttx-form.e2e.d.ts +1 -0
- package/dist/types/components/molecules/tttx-form/test/tttx-form.spec.d.ts +1 -0
- package/dist/types/components/molecules/tttx-form/tttx-form.d.ts +114 -114
- package/dist/types/components/molecules/tttx-form/tttx-form.stories.d.ts +13 -13
- package/dist/types/components/molecules/tttx-list/test/ttttx-list.spec.e2e.d.ts +1 -0
- package/dist/types/components/molecules/tttx-list/test/tttx-list.spec.d.ts +1 -0
- package/dist/types/components/molecules/tttx-list/tttx-list.d.ts +11 -11
- package/dist/types/components/molecules/tttx-list/tttx-list.stories.d.ts +14 -14
- package/dist/types/components/molecules/tttx-standalone-input/test/tttx-standalone-input.e2e.d.ts +1 -0
- package/dist/types/components/molecules/tttx-standalone-input/test/tttx-standalone-input.spec.d.ts +1 -0
- package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.d.ts +56 -53
- package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.d.ts +122 -106
- package/dist/types/components/molecules/tttx-toolbar/test/tttx-toolbar.test.d.ts +0 -0
- package/dist/types/components/molecules/tttx-toolbar/tttx-toolbar.d.ts +4 -0
- package/dist/types/components/molecules/tttx-toolbar/tttx-toolbar.stories.d.ts +13 -0
- package/dist/types/components/palette.stories.d.ts +6 -6
- package/dist/types/components.d.ts +21 -0
- package/dist/types/docs/gettingstarted-developer.stories.d.ts +5 -5
- package/dist/types/icons.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/shared/domsanitiser.options.d.ts +10 -10
- package/dist/types/shared/test/domsanitiser.options.spec.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +3 -59
- package/loader/index.d.ts +0 -9
- package/package.json +1 -1
- package/dist/collection/transform-tag-name.js +0 -5
- package/dist/tttx/p-083eeedc.entry.js +0 -1
- package/dist/tttx/p-5687f4ad.js +0 -2
- package/dist/tttx/p-5c9a1626.entry.js +0 -3
- package/dist/tttx/p-931e42c9.entry.js +0 -1
- package/dist/tttx/p-b5c1dd86.entry.js +0 -1
- package/dist/types/transform-tag-name.d.ts +0 -1
package/dist/collection/components/atoms/tttx-loading-spinner/Test/tttx-loading-spinner.spec.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { newSpecPage } from '@stencil/core/testing';
|
|
2
|
+
import { TttxLoadingSpinner } from '../tttx-loading-spinner';
|
|
3
|
+
describe('tttx-loading-spinner', () => {
|
|
4
|
+
it('renders the loading text when the loading message prop is set to true', async () => {
|
|
5
|
+
const page = await newSpecPage({
|
|
6
|
+
components: [TttxLoadingSpinner],
|
|
7
|
+
html: '<tttx-loading-spinner></tttx-loading-spinner>',
|
|
8
|
+
});
|
|
9
|
+
page.rootInstance.loadingMessage = true;
|
|
10
|
+
await page.waitForChanges();
|
|
11
|
+
expect(page.root).toEqualHtml(`
|
|
12
|
+
<tttx-loading-spinner>
|
|
13
|
+
<mock:shadow-root>
|
|
14
|
+
<div class='spinner-container'><div class="loading-box"><span class='spinner large'></span></div><div class='loading-text'>Loading, please wait...</div></div>
|
|
15
|
+
</mock:shadow-root>
|
|
16
|
+
</tttx-loading-spinner>
|
|
17
|
+
`);
|
|
18
|
+
});
|
|
19
|
+
it('renders without the loading text when the loading message prop is set to false', async () => {
|
|
20
|
+
const page = await newSpecPage({
|
|
21
|
+
components: [TttxLoadingSpinner],
|
|
22
|
+
html: '<tttx-loading-spinner></tttx-loading-spinner>',
|
|
23
|
+
});
|
|
24
|
+
page.rootInstance.loadingMessage = false;
|
|
25
|
+
await page.waitForChanges();
|
|
26
|
+
expect(page.root).toEqualHtml(`
|
|
27
|
+
<tttx-loading-spinner>
|
|
28
|
+
<mock:shadow-root>
|
|
29
|
+
<div class='spinner-container'><div class="loading-box"><span class='spinner large'></span></div></div>
|
|
30
|
+
</mock:shadow-root>
|
|
31
|
+
</tttx-loading-spinner>
|
|
32
|
+
`);
|
|
33
|
+
});
|
|
34
|
+
it('renders the small spinner when the size prop is set to small', async () => {
|
|
35
|
+
const page = await newSpecPage({
|
|
36
|
+
components: [TttxLoadingSpinner],
|
|
37
|
+
html: '<tttx-loading-spinner></tttx-loading-spinner>',
|
|
38
|
+
});
|
|
39
|
+
page.rootInstance.size = 'small';
|
|
40
|
+
await page.waitForChanges();
|
|
41
|
+
expect(page.root).toEqualHtml(`
|
|
42
|
+
<tttx-loading-spinner>
|
|
43
|
+
<mock:shadow-root>
|
|
44
|
+
<div class='spinner-container'><div class="loading-box"><span class='spinner small'></span></div></div>
|
|
45
|
+
</mock:shadow-root>
|
|
46
|
+
</tttx-loading-spinner>
|
|
47
|
+
`);
|
|
48
|
+
});
|
|
49
|
+
it('renders the large spinner when the size prop is set to large', async () => {
|
|
50
|
+
const page = await newSpecPage({
|
|
51
|
+
components: [TttxLoadingSpinner],
|
|
52
|
+
html: '<tttx-loading-spinner></tttx-loading-spinner>',
|
|
53
|
+
});
|
|
54
|
+
page.rootInstance.size = 'large';
|
|
55
|
+
await page.waitForChanges();
|
|
56
|
+
expect(page.root).toEqualHtml(`
|
|
57
|
+
<tttx-loading-spinner>
|
|
58
|
+
<mock:shadow-root>
|
|
59
|
+
<div class='spinner-container'><div class="loading-box"><span class='spinner large'></span></div></div>
|
|
60
|
+
</mock:shadow-root>
|
|
61
|
+
</tttx-loading-spinner>
|
|
62
|
+
`);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2
|
-
import { h } from '@stencil/core';
|
|
3
|
-
export class TttxLoadingSpinner {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.loadingMessage = undefined;
|
|
6
|
-
this.size = 'large';
|
|
7
|
-
}
|
|
8
|
-
renderLoadingMessage() {
|
|
9
|
-
if (!this.loadingMessage)
|
|
10
|
-
return '';
|
|
11
|
-
return h("div", { class: "loading-text" }, "Loading, please wait...");
|
|
12
|
-
}
|
|
13
|
-
render() {
|
|
14
|
-
return (h("div", { class: "spinner-container" }, h("div", { class: "loading-box" }, h("span", { class: `spinner ${this.size}` })), this.renderLoadingMessage()));
|
|
15
|
-
}
|
|
16
|
-
static get is() { return "tttx-loading-spinner"; }
|
|
17
|
-
static get encapsulation() { return "shadow"; }
|
|
18
|
-
static get originalStyleUrls() {
|
|
19
|
-
return {
|
|
20
|
-
"$": ["tttx-loading-spinner.scss"]
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
static get styleUrls() {
|
|
24
|
-
return {
|
|
25
|
-
"$": ["tttx-loading-spinner.css"]
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
static get properties() {
|
|
29
|
-
return {
|
|
30
|
-
"loadingMessage": {
|
|
31
|
-
"type": "boolean",
|
|
32
|
-
"mutable": true,
|
|
33
|
-
"complexType": {
|
|
34
|
-
"original": "boolean",
|
|
35
|
-
"resolved": "boolean",
|
|
36
|
-
"references": {}
|
|
37
|
-
},
|
|
38
|
-
"required": false,
|
|
39
|
-
"optional": false,
|
|
40
|
-
"docs": {
|
|
41
|
-
"tags": [],
|
|
42
|
-
"text": ""
|
|
43
|
-
},
|
|
44
|
-
"attribute": "loading-message",
|
|
45
|
-
"reflect": false
|
|
46
|
-
},
|
|
47
|
-
"size": {
|
|
48
|
-
"type": "string",
|
|
49
|
-
"mutable": true,
|
|
50
|
-
"complexType": {
|
|
51
|
-
"original": "'small' | 'large'",
|
|
52
|
-
"resolved": "\"large\" | \"small\"",
|
|
53
|
-
"references": {}
|
|
54
|
-
},
|
|
55
|
-
"required": false,
|
|
56
|
-
"optional": false,
|
|
57
|
-
"docs": {
|
|
58
|
-
"tags": [],
|
|
59
|
-
"text": ""
|
|
60
|
-
},
|
|
61
|
-
"attribute": "size",
|
|
62
|
-
"reflect": false,
|
|
63
|
-
"defaultValue": "'large'"
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import { h } from '@stencil/core';
|
|
3
|
+
export class TttxLoadingSpinner {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.loadingMessage = undefined;
|
|
6
|
+
this.size = 'large';
|
|
7
|
+
}
|
|
8
|
+
renderLoadingMessage() {
|
|
9
|
+
if (!this.loadingMessage)
|
|
10
|
+
return '';
|
|
11
|
+
return h("div", { class: "loading-text" }, "Loading, please wait...");
|
|
12
|
+
}
|
|
13
|
+
render() {
|
|
14
|
+
return (h("div", { class: "spinner-container" }, h("div", { class: "loading-box" }, h("span", { class: `spinner ${this.size}` })), this.renderLoadingMessage()));
|
|
15
|
+
}
|
|
16
|
+
static get is() { return "tttx-loading-spinner"; }
|
|
17
|
+
static get encapsulation() { return "shadow"; }
|
|
18
|
+
static get originalStyleUrls() {
|
|
19
|
+
return {
|
|
20
|
+
"$": ["tttx-loading-spinner.scss"]
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
static get styleUrls() {
|
|
24
|
+
return {
|
|
25
|
+
"$": ["tttx-loading-spinner.css"]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
static get properties() {
|
|
29
|
+
return {
|
|
30
|
+
"loadingMessage": {
|
|
31
|
+
"type": "boolean",
|
|
32
|
+
"mutable": true,
|
|
33
|
+
"complexType": {
|
|
34
|
+
"original": "boolean",
|
|
35
|
+
"resolved": "boolean",
|
|
36
|
+
"references": {}
|
|
37
|
+
},
|
|
38
|
+
"required": false,
|
|
39
|
+
"optional": false,
|
|
40
|
+
"docs": {
|
|
41
|
+
"tags": [],
|
|
42
|
+
"text": ""
|
|
43
|
+
},
|
|
44
|
+
"attribute": "loading-message",
|
|
45
|
+
"reflect": false
|
|
46
|
+
},
|
|
47
|
+
"size": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"mutable": true,
|
|
50
|
+
"complexType": {
|
|
51
|
+
"original": "'small' | 'large'",
|
|
52
|
+
"resolved": "\"large\" | \"small\"",
|
|
53
|
+
"references": {}
|
|
54
|
+
},
|
|
55
|
+
"required": false,
|
|
56
|
+
"optional": false,
|
|
57
|
+
"docs": {
|
|
58
|
+
"tags": [],
|
|
59
|
+
"text": ""
|
|
60
|
+
},
|
|
61
|
+
"attribute": "size",
|
|
62
|
+
"reflect": false,
|
|
63
|
+
"defaultValue": "'large'"
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
title: 'atoms/Loading Spinner',
|
|
3
|
-
component: 'tttx-loading-spinner',
|
|
4
|
-
argTypes: {
|
|
5
|
-
loadingMessage: {
|
|
6
|
-
control: 'boolean',
|
|
7
|
-
},
|
|
8
|
-
size: {
|
|
9
|
-
control: { type: 'radio' },
|
|
10
|
-
options: ['small', 'large'],
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
export const Example = args => {
|
|
15
|
-
const size = args.size || 'large';
|
|
16
|
-
return `<tttx-loading-spinner ${args.loadingMessage ? 'loading-message' : ''} size='${size}' />`;
|
|
17
|
-
};
|
|
1
|
+
export default {
|
|
2
|
+
title: 'atoms/Loading Spinner',
|
|
3
|
+
component: 'tttx-loading-spinner',
|
|
4
|
+
argTypes: {
|
|
5
|
+
loadingMessage: {
|
|
6
|
+
control: 'boolean',
|
|
7
|
+
},
|
|
8
|
+
size: {
|
|
9
|
+
control: { type: 'radio' },
|
|
10
|
+
options: ['small', 'large'],
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export const Example = args => {
|
|
15
|
+
const size = args.size || 'large';
|
|
16
|
+
return `<tttx-loading-spinner ${args.loadingMessage ? 'loading-message' : ''} size='${size}' />`;
|
|
17
|
+
};
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sets the error state of an input field by updating its class and error message.
|
|
3
|
-
* If an error was detected, it sets the input field's class to "invalid" and
|
|
4
|
-
* displays the error message in an error bubble. If no error was detected,
|
|
5
|
-
* it removes the "invalid" class from the input field and clears the error bubble.
|
|
6
|
-
*
|
|
7
|
-
* @param {HTMLInputElement} target - The input field to update.
|
|
8
|
-
* @param {boolean} hasError - Whether an error was detected in the field.
|
|
9
|
-
* @param {string} errorMessage - The error message to display (if any).
|
|
10
|
-
* @return {void}
|
|
11
|
-
*/
|
|
12
|
-
function setErrorState(target, hasError, errorMessage) {
|
|
13
|
-
// Find the error bubble element for the input field
|
|
14
|
-
const errorBubble = target.parentElement.querySelector('.errorBubble');
|
|
15
|
-
// If an error was detected, set the input field's class to "invalid" and display the error message in the error bubble
|
|
16
|
-
if (hasError) {
|
|
17
|
-
target.className = 'invalid';
|
|
18
|
-
const errorIcon = document.createElement('span');
|
|
19
|
-
// Set the class of the error icon to a pre-defined CSS class that specifies the icon's appearance
|
|
20
|
-
errorIcon.className = 'material-symbols-rounded';
|
|
21
|
-
// Set the text content of the error icon to the word "warning"
|
|
22
|
-
errorIcon.textContent = 'warning';
|
|
23
|
-
// errorBubble.replaceChildren cannot be used here because the tests don't support this new feature :(
|
|
24
|
-
errorBubble.innerHTML = '';
|
|
25
|
-
errorBubble.append(errorIcon);
|
|
26
|
-
errorBubble.append(errorMessage);
|
|
27
|
-
// errorBubble.replaceChildren(errorIcon, errorMessage);
|
|
28
|
-
}
|
|
29
|
-
// If no error was detected, remove the "invalid" class from the input field and clear the error bubble
|
|
30
|
-
else {
|
|
31
|
-
target.className = '';
|
|
32
|
-
errorBubble.innerHTML = '';
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export default setErrorState;
|
|
1
|
+
/**
|
|
2
|
+
* Sets the error state of an input field by updating its class and error message.
|
|
3
|
+
* If an error was detected, it sets the input field's class to "invalid" and
|
|
4
|
+
* displays the error message in an error bubble. If no error was detected,
|
|
5
|
+
* it removes the "invalid" class from the input field and clears the error bubble.
|
|
6
|
+
*
|
|
7
|
+
* @param {HTMLInputElement} target - The input field to update.
|
|
8
|
+
* @param {boolean} hasError - Whether an error was detected in the field.
|
|
9
|
+
* @param {string} errorMessage - The error message to display (if any).
|
|
10
|
+
* @return {void}
|
|
11
|
+
*/
|
|
12
|
+
function setErrorState(target, hasError, errorMessage) {
|
|
13
|
+
// Find the error bubble element for the input field
|
|
14
|
+
const errorBubble = target.parentElement.querySelector('.errorBubble');
|
|
15
|
+
// If an error was detected, set the input field's class to "invalid" and display the error message in the error bubble
|
|
16
|
+
if (hasError) {
|
|
17
|
+
target.className = 'invalid';
|
|
18
|
+
const errorIcon = document.createElement('span');
|
|
19
|
+
// Set the class of the error icon to a pre-defined CSS class that specifies the icon's appearance
|
|
20
|
+
errorIcon.className = 'material-symbols-rounded';
|
|
21
|
+
// Set the text content of the error icon to the word "warning"
|
|
22
|
+
errorIcon.textContent = 'warning';
|
|
23
|
+
// errorBubble.replaceChildren cannot be used here because the tests don't support this new feature :(
|
|
24
|
+
errorBubble.innerHTML = '';
|
|
25
|
+
errorBubble.append(errorIcon);
|
|
26
|
+
errorBubble.append(errorMessage);
|
|
27
|
+
// errorBubble.replaceChildren(errorIcon, errorMessage);
|
|
28
|
+
}
|
|
29
|
+
// If no error was detected, remove the "invalid" class from the input field and clear the error bubble
|
|
30
|
+
else {
|
|
31
|
+
target.className = '';
|
|
32
|
+
errorBubble.innerHTML = '';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export default setErrorState;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import setErrorState from './setErrorState';
|
|
2
|
+
describe('setErrorState', () => {
|
|
3
|
+
let target;
|
|
4
|
+
let errorBubble;
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
target = document.createElement('input');
|
|
7
|
+
errorBubble = document.createElement('div');
|
|
8
|
+
errorBubble.className = 'errorBubble';
|
|
9
|
+
target.parentElement = document.createElement('div');
|
|
10
|
+
target.parentElement.appendChild(errorBubble);
|
|
11
|
+
});
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
target = null;
|
|
14
|
+
errorBubble = null;
|
|
15
|
+
});
|
|
16
|
+
test('should set error state correctly when hasError is true', () => {
|
|
17
|
+
setErrorState(target, true, 'Invalid value');
|
|
18
|
+
expect(target.className).toBe('invalid');
|
|
19
|
+
expect(errorBubble.innerHTML).toBe('<span class="material-symbols-rounded">warning</span>Invalid value');
|
|
20
|
+
});
|
|
21
|
+
test('should clear error state correctly when hasError is false', () => {
|
|
22
|
+
target.className = 'invalid';
|
|
23
|
+
errorBubble.innerHTML = '<span class="material-symbols-rounded">warning</span>Invalid value';
|
|
24
|
+
setErrorState(target, false, '');
|
|
25
|
+
expect(target.className).toBe('');
|
|
26
|
+
expect(errorBubble.innerHTML).toBe('');
|
|
27
|
+
});
|
|
28
|
+
test('should set error state correctly with custom error message', () => {
|
|
29
|
+
setErrorState(target, true, 'Custom error message');
|
|
30
|
+
expect(target.className).toBe('invalid');
|
|
31
|
+
expect(errorBubble.innerHTML).toBe('<span class="material-symbols-rounded">warning</span>Custom error message');
|
|
32
|
+
});
|
|
33
|
+
test('should set error state correctly with no error message', () => {
|
|
34
|
+
setErrorState(target, true, '');
|
|
35
|
+
expect(target.className).toBe('invalid');
|
|
36
|
+
expect(errorBubble.innerHTML).toBe('<span class="material-symbols-rounded">warning</span> ');
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validates the input field on focusout event by checking its validity state,
|
|
3
|
-
* sets an error message if there's an issue, and emits a "dataChanged" event to
|
|
4
|
-
* the parent component with the field name and its new value.
|
|
5
|
-
*
|
|
6
|
-
* @param {Event} event - The focusout event triggered by the input field.
|
|
7
|
-
* @return {void}
|
|
8
|
-
*/
|
|
9
|
-
function validityCheck(event) {
|
|
10
|
-
var _a, _b, _c, _d;
|
|
11
|
-
event.preventDefault();
|
|
12
|
-
const target = event.target;
|
|
13
|
-
let hasError = true;
|
|
14
|
-
let errorMessage = '';
|
|
15
|
-
// validity object on HTML5 inputs has the following options
|
|
16
|
-
// badInput
|
|
17
|
-
// customError
|
|
18
|
-
// patternMismatch
|
|
19
|
-
// rangeOverflow
|
|
20
|
-
// rangeUnderflow
|
|
21
|
-
// stepMismatch
|
|
22
|
-
// tooLong
|
|
23
|
-
// tooShort
|
|
24
|
-
// typeMismatch
|
|
25
|
-
// valid
|
|
26
|
-
// valueMissing
|
|
27
|
-
// customErrors can be set with
|
|
28
|
-
// target.setCustomValidity('custom error!');
|
|
29
|
-
// and cleared with
|
|
30
|
-
// target.setCustomValidity('');
|
|
31
|
-
// Check the validity of the input field and set an error message if needed
|
|
32
|
-
switch (true) {
|
|
33
|
-
// The field is required, but has no value
|
|
34
|
-
case target.validity.valueMissing:
|
|
35
|
-
errorMessage = (_a = target.dataset.required) !== null && _a !== void 0 ? _a : 'This field is required';
|
|
36
|
-
break;
|
|
37
|
-
// The field's value does not match the expected pattern
|
|
38
|
-
case target.validity.patternMismatch:
|
|
39
|
-
errorMessage = (_b = target.dataset.pattern) !== null && _b !== void 0 ? _b : 'Incorrect format';
|
|
40
|
-
break;
|
|
41
|
-
// The field's value is not of the correct input type
|
|
42
|
-
case target.validity.badInput:
|
|
43
|
-
// IE string in a number field
|
|
44
|
-
errorMessage = (_c = target.dataset.badinput) !== null && _c !== void 0 ? _c : 'Wrong input type';
|
|
45
|
-
break;
|
|
46
|
-
// The field's value is above or below the range set in the "min" and "max" attributes
|
|
47
|
-
case target.validity.rangeOverflow || target.validity.rangeUnderflow:
|
|
48
|
-
// IE date or number is above or below value set in min or max tags
|
|
49
|
-
errorMessage = (_d = target.dataset.range) !== null && _d !== void 0 ? _d : 'Invalid value';
|
|
50
|
-
break;
|
|
51
|
-
// No error detected
|
|
52
|
-
default:
|
|
53
|
-
hasError = false;
|
|
54
|
-
}
|
|
55
|
-
// Return the error state
|
|
56
|
-
return { target, hasError, errorMessage };
|
|
57
|
-
}
|
|
58
|
-
export default validityCheck;
|
|
1
|
+
/**
|
|
2
|
+
* Validates the input field on focusout event by checking its validity state,
|
|
3
|
+
* sets an error message if there's an issue, and emits a "dataChanged" event to
|
|
4
|
+
* the parent component with the field name and its new value.
|
|
5
|
+
*
|
|
6
|
+
* @param {Event} event - The focusout event triggered by the input field.
|
|
7
|
+
* @return {void}
|
|
8
|
+
*/
|
|
9
|
+
function validityCheck(event) {
|
|
10
|
+
var _a, _b, _c, _d;
|
|
11
|
+
event.preventDefault();
|
|
12
|
+
const target = event.target;
|
|
13
|
+
let hasError = true;
|
|
14
|
+
let errorMessage = '';
|
|
15
|
+
// validity object on HTML5 inputs has the following options
|
|
16
|
+
// badInput
|
|
17
|
+
// customError
|
|
18
|
+
// patternMismatch
|
|
19
|
+
// rangeOverflow
|
|
20
|
+
// rangeUnderflow
|
|
21
|
+
// stepMismatch
|
|
22
|
+
// tooLong
|
|
23
|
+
// tooShort
|
|
24
|
+
// typeMismatch
|
|
25
|
+
// valid
|
|
26
|
+
// valueMissing
|
|
27
|
+
// customErrors can be set with
|
|
28
|
+
// target.setCustomValidity('custom error!');
|
|
29
|
+
// and cleared with
|
|
30
|
+
// target.setCustomValidity('');
|
|
31
|
+
// Check the validity of the input field and set an error message if needed
|
|
32
|
+
switch (true) {
|
|
33
|
+
// The field is required, but has no value
|
|
34
|
+
case target.validity.valueMissing:
|
|
35
|
+
errorMessage = (_a = target.dataset.required) !== null && _a !== void 0 ? _a : 'This field is required';
|
|
36
|
+
break;
|
|
37
|
+
// The field's value does not match the expected pattern
|
|
38
|
+
case target.validity.patternMismatch:
|
|
39
|
+
errorMessage = (_b = target.dataset.pattern) !== null && _b !== void 0 ? _b : 'Incorrect format';
|
|
40
|
+
break;
|
|
41
|
+
// The field's value is not of the correct input type
|
|
42
|
+
case target.validity.badInput:
|
|
43
|
+
// IE string in a number field
|
|
44
|
+
errorMessage = (_c = target.dataset.badinput) !== null && _c !== void 0 ? _c : 'Wrong input type';
|
|
45
|
+
break;
|
|
46
|
+
// The field's value is above or below the range set in the "min" and "max" attributes
|
|
47
|
+
case target.validity.rangeOverflow || target.validity.rangeUnderflow:
|
|
48
|
+
// IE date or number is above or below value set in min or max tags
|
|
49
|
+
errorMessage = (_d = target.dataset.range) !== null && _d !== void 0 ? _d : 'Invalid value';
|
|
50
|
+
break;
|
|
51
|
+
// No error detected
|
|
52
|
+
default:
|
|
53
|
+
hasError = false;
|
|
54
|
+
}
|
|
55
|
+
// Return the error state
|
|
56
|
+
return { target, hasError, errorMessage };
|
|
57
|
+
}
|
|
58
|
+
export default validityCheck;
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import validityCheck from './validityCheck';
|
|
2
|
+
// badInput
|
|
3
|
+
// customError
|
|
4
|
+
// patternMismatch
|
|
5
|
+
// rangeOverflow
|
|
6
|
+
// rangeUnderflow
|
|
7
|
+
// stepMismatch
|
|
8
|
+
// tooLong
|
|
9
|
+
// tooShort
|
|
10
|
+
// typeMismatch
|
|
11
|
+
// valid
|
|
12
|
+
// valueMissing
|
|
13
|
+
describe('validityCheck', () => {
|
|
14
|
+
it('should return a valid response when there are no validation issues', async () => {
|
|
15
|
+
const preventDefault = jest.fn();
|
|
16
|
+
const event = {
|
|
17
|
+
target: {
|
|
18
|
+
value: 'test',
|
|
19
|
+
validity: {
|
|
20
|
+
valid: true
|
|
21
|
+
},
|
|
22
|
+
dataset: {}
|
|
23
|
+
},
|
|
24
|
+
preventDefault
|
|
25
|
+
};
|
|
26
|
+
const result = validityCheck(event);
|
|
27
|
+
expect(preventDefault).toHaveBeenCalledTimes(1);
|
|
28
|
+
expect(result).toStrictEqual({
|
|
29
|
+
"errorMessage": "",
|
|
30
|
+
"hasError": false,
|
|
31
|
+
"target": event.target
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
it('should return the required property when there is a value missing', async () => {
|
|
35
|
+
const preventDefault = jest.fn();
|
|
36
|
+
const event = {
|
|
37
|
+
target: {
|
|
38
|
+
dataset: {
|
|
39
|
+
required: 'This is required'
|
|
40
|
+
},
|
|
41
|
+
value: 'test',
|
|
42
|
+
validity: {
|
|
43
|
+
valid: false,
|
|
44
|
+
valueMissing: true
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
preventDefault
|
|
48
|
+
};
|
|
49
|
+
const result = validityCheck(event);
|
|
50
|
+
expect(preventDefault).toHaveBeenCalledTimes(1);
|
|
51
|
+
expect(result).toStrictEqual({
|
|
52
|
+
"errorMessage": "This is required",
|
|
53
|
+
"hasError": true,
|
|
54
|
+
"target": event.target
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
it('should return a default error message property when there is a value missing', async () => {
|
|
58
|
+
const preventDefault = jest.fn();
|
|
59
|
+
const event = {
|
|
60
|
+
target: {
|
|
61
|
+
dataset: {},
|
|
62
|
+
value: 'test',
|
|
63
|
+
validity: {
|
|
64
|
+
valid: false,
|
|
65
|
+
valueMissing: true
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
preventDefault
|
|
69
|
+
};
|
|
70
|
+
const result = validityCheck(event);
|
|
71
|
+
expect(preventDefault).toHaveBeenCalledTimes(1);
|
|
72
|
+
expect(result).toStrictEqual({
|
|
73
|
+
"errorMessage": 'This field is required',
|
|
74
|
+
"hasError": true,
|
|
75
|
+
"target": event.target
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
it('should return the pattern property when there is a patternMismatch', async () => {
|
|
79
|
+
const preventDefault = jest.fn();
|
|
80
|
+
const event = {
|
|
81
|
+
target: {
|
|
82
|
+
dataset: {
|
|
83
|
+
pattern: 'Incorrect format CUSTOM'
|
|
84
|
+
},
|
|
85
|
+
value: 'test',
|
|
86
|
+
validity: {
|
|
87
|
+
valid: false,
|
|
88
|
+
patternMismatch: true
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
preventDefault
|
|
92
|
+
};
|
|
93
|
+
const result = validityCheck(event);
|
|
94
|
+
expect(preventDefault).toHaveBeenCalledTimes(1);
|
|
95
|
+
expect(result).toStrictEqual({
|
|
96
|
+
"errorMessage": "Incorrect format CUSTOM",
|
|
97
|
+
"hasError": true,
|
|
98
|
+
"target": event.target
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
it('should return the a default error message when there is a patternMismatch', async () => {
|
|
102
|
+
const preventDefault = jest.fn();
|
|
103
|
+
const event = {
|
|
104
|
+
target: {
|
|
105
|
+
dataset: {},
|
|
106
|
+
value: 'test',
|
|
107
|
+
validity: {
|
|
108
|
+
valid: false,
|
|
109
|
+
patternMismatch: true
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
preventDefault
|
|
113
|
+
};
|
|
114
|
+
const result = validityCheck(event);
|
|
115
|
+
expect(preventDefault).toHaveBeenCalledTimes(1);
|
|
116
|
+
expect(result).toStrictEqual({
|
|
117
|
+
"errorMessage": 'Incorrect format',
|
|
118
|
+
"hasError": true,
|
|
119
|
+
"target": event.target
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
it('should return the badinput error message property when there is a badInput', async () => {
|
|
123
|
+
const preventDefault = jest.fn();
|
|
124
|
+
const event = {
|
|
125
|
+
target: {
|
|
126
|
+
dataset: {
|
|
127
|
+
badinput: 'There is a bad input'
|
|
128
|
+
},
|
|
129
|
+
value: 'test',
|
|
130
|
+
validity: {
|
|
131
|
+
valid: false,
|
|
132
|
+
badInput: true
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
preventDefault
|
|
136
|
+
};
|
|
137
|
+
const result = validityCheck(event);
|
|
138
|
+
expect(preventDefault).toHaveBeenCalledTimes(1);
|
|
139
|
+
expect(result).toStrictEqual({
|
|
140
|
+
"errorMessage": "There is a bad input",
|
|
141
|
+
"hasError": true,
|
|
142
|
+
"target": event.target
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
it('should return a default error message property when there is a badInput', async () => {
|
|
146
|
+
const preventDefault = jest.fn();
|
|
147
|
+
const event = {
|
|
148
|
+
target: {
|
|
149
|
+
value: 'test',
|
|
150
|
+
validity: {
|
|
151
|
+
valid: false,
|
|
152
|
+
badInput: true
|
|
153
|
+
},
|
|
154
|
+
dataset: {}
|
|
155
|
+
},
|
|
156
|
+
preventDefault
|
|
157
|
+
};
|
|
158
|
+
const result = validityCheck(event);
|
|
159
|
+
expect(preventDefault).toHaveBeenCalledTimes(1);
|
|
160
|
+
expect(result).toStrictEqual({
|
|
161
|
+
"errorMessage": 'Wrong input type',
|
|
162
|
+
"hasError": true,
|
|
163
|
+
"target": event.target
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
it('should return a message for an item out of range (underflow) with custom message', async () => {
|
|
167
|
+
const preventDefault = jest.fn();
|
|
168
|
+
const event = {
|
|
169
|
+
target: {
|
|
170
|
+
value: '0',
|
|
171
|
+
validity: {
|
|
172
|
+
valid: false,
|
|
173
|
+
rangeOverflow: true
|
|
174
|
+
},
|
|
175
|
+
dataset: {
|
|
176
|
+
range: 'Value is out of range'
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
preventDefault
|
|
180
|
+
};
|
|
181
|
+
const result = validityCheck(event);
|
|
182
|
+
expect(preventDefault).toHaveBeenCalledTimes(1);
|
|
183
|
+
expect(result).toStrictEqual({
|
|
184
|
+
"errorMessage": "Value is out of range",
|
|
185
|
+
"hasError": true,
|
|
186
|
+
"target": event.target
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
it('should return a message for an item out of range (underflow)', async () => {
|
|
190
|
+
const preventDefault = jest.fn();
|
|
191
|
+
const event = {
|
|
192
|
+
target: {
|
|
193
|
+
value: '0',
|
|
194
|
+
validity: {
|
|
195
|
+
valid: false,
|
|
196
|
+
rangeOverflow: true
|
|
197
|
+
},
|
|
198
|
+
dataset: {}
|
|
199
|
+
},
|
|
200
|
+
preventDefault
|
|
201
|
+
};
|
|
202
|
+
const result = validityCheck(event);
|
|
203
|
+
expect(preventDefault).toHaveBeenCalledTimes(1);
|
|
204
|
+
expect(result).toStrictEqual({
|
|
205
|
+
"errorMessage": "Invalid value",
|
|
206
|
+
"hasError": true,
|
|
207
|
+
"target": event.target
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
// it('target.validity.rangeOverflow', async () => {
|
|
211
|
+
// });
|
|
212
|
+
// it('target.validity.rangeUnderflow', async () => {
|
|
213
|
+
// });
|
|
214
|
+
});
|