@3t-transform/threeteeui 0.1.3 → 0.1.5

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.
Files changed (101) hide show
  1. package/dist/cjs/{index-451f61dd.js → index-906c2757.js} +102 -3
  2. package/dist/cjs/loader.cjs.js +4 -3
  3. package/dist/cjs/{tttx-button.cjs.entry.js → tttx-button_2.cjs.entry.js} +50 -24
  4. package/dist/cjs/tttx-form.cjs.entry.js +364 -364
  5. package/dist/cjs/tttx-keyvalue-block.cjs.entry.js +57 -57
  6. package/dist/cjs/tttx-list.cjs.entry.js +43 -43
  7. package/dist/cjs/tttx-loading-spinner.cjs.entry.js +16 -16
  8. package/dist/cjs/tttx-standalone-input.cjs.entry.js +58 -61
  9. package/dist/cjs/tttx.cjs.js +7 -3
  10. package/dist/collection/collection-manifest.json +2 -2
  11. package/dist/collection/components/atoms/tttx-button/tttx-button.js +116 -110
  12. package/dist/collection/components/atoms/tttx-button/tttx-button.stories.js +14 -14
  13. package/dist/collection/components/atoms/tttx-icon/tttx-icon.css +0 -4
  14. package/dist/collection/components/atoms/tttx-icon/tttx-icon.js +62 -62
  15. package/dist/collection/components/atoms/tttx-icon/tttx-icon.stories.js +22 -22
  16. package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.js +107 -107
  17. package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.js +38 -38
  18. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.js +67 -67
  19. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.js +17 -17
  20. package/dist/collection/components/molecules/tttx-form/lib/setErrorState.js +35 -35
  21. package/dist/collection/components/molecules/tttx-form/lib/validityCheck.js +58 -58
  22. package/dist/collection/components/molecules/tttx-form/tttx-form.css +3 -26
  23. package/dist/collection/components/molecules/tttx-form/tttx-form.js +364 -364
  24. package/dist/collection/components/molecules/tttx-form/tttx-form.stories.js +127 -127
  25. package/dist/collection/components/molecules/tttx-list/tttx-list.js +105 -105
  26. package/dist/collection/components/molecules/tttx-list/tttx-list.stories.js +43 -43
  27. package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.css +3 -26
  28. package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.js +572 -627
  29. package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.js +135 -148
  30. package/dist/collection/components/palette.stories.js +7 -7
  31. package/dist/collection/docs/gettingstarted-developer.stories.js +5 -5
  32. package/dist/collection/icons.js +2838 -2838
  33. package/dist/collection/index.js +1 -1
  34. package/dist/collection/shared/domsanitiser.options.js +14 -14
  35. package/dist/collection/transform-tag-name.js +5 -0
  36. package/dist/components/index.d.ts +9 -0
  37. package/dist/components/index.js +1 -1
  38. package/dist/components/tttx-button.js +59 -48
  39. package/dist/components/tttx-form.js +381 -381
  40. package/dist/components/tttx-icon2.js +29 -29
  41. package/dist/components/tttx-keyvalue-block.js +74 -74
  42. package/dist/components/tttx-list.js +65 -65
  43. package/dist/components/tttx-loading-spinner.js +33 -33
  44. package/dist/components/tttx-standalone-input.js +102 -108
  45. package/dist/esm/{index-0350f122.js → index-4010ad69.js} +101 -4
  46. package/dist/esm/loader.js +4 -3
  47. package/dist/esm/polyfills/core-js.js +0 -0
  48. package/dist/esm/polyfills/css-shim.js +1 -1
  49. package/dist/esm/polyfills/dom.js +0 -0
  50. package/dist/esm/polyfills/es5-html-element.js +0 -0
  51. package/dist/esm/polyfills/index.js +0 -0
  52. package/dist/esm/polyfills/system.js +0 -0
  53. package/dist/esm/{tttx-button.entry.js → tttx-button_2.entry.js} +50 -25
  54. package/dist/esm/tttx-form.entry.js +364 -364
  55. package/dist/esm/tttx-keyvalue-block.entry.js +57 -57
  56. package/dist/esm/tttx-list.entry.js +43 -43
  57. package/dist/esm/tttx-loading-spinner.entry.js +16 -16
  58. package/dist/esm/tttx-standalone-input.entry.js +58 -61
  59. package/dist/esm/tttx.js +4 -3
  60. package/dist/tttx/p-083eeedc.entry.js +1 -0
  61. package/dist/tttx/{p-1b015a9d.entry.js → p-3281444a.entry.js} +1 -1
  62. package/dist/tttx/p-5687f4ad.js +2 -0
  63. package/dist/tttx/p-5c9a1626.entry.js +3 -0
  64. package/dist/tttx/p-931e42c9.entry.js +1 -0
  65. package/dist/tttx/p-b5c1dd86.entry.js +1 -0
  66. package/dist/tttx/{p-a0179cb1.entry.js → p-dab7ee1b.entry.js} +1 -1
  67. package/dist/tttx/tttx.esm.js +1 -1
  68. package/dist/types/components/atoms/tttx-button/tttx-button.d.ts +13 -10
  69. package/dist/types/components/atoms/tttx-button/tttx-button.stories.d.ts +10 -10
  70. package/dist/types/components/atoms/tttx-icon/tttx-icon.d.ts +5 -5
  71. package/dist/types/components/atoms/tttx-icon/tttx-icon.stories.d.ts +20 -20
  72. package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.d.ts +7 -7
  73. package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.d.ts +9 -9
  74. package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.d.ts +6 -6
  75. package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.d.ts +17 -17
  76. package/dist/types/components/molecules/tttx-form/lib/setErrorState.d.ts +13 -13
  77. package/dist/types/components/molecules/tttx-form/lib/validityCheck.d.ts +17 -17
  78. package/dist/types/components/molecules/tttx-form/tttx-form.d.ts +114 -114
  79. package/dist/types/components/molecules/tttx-form/tttx-form.stories.d.ts +13 -13
  80. package/dist/types/components/molecules/tttx-list/tttx-list.d.ts +11 -11
  81. package/dist/types/components/molecules/tttx-list/tttx-list.stories.d.ts +14 -14
  82. package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.d.ts +53 -56
  83. package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.d.ts +106 -122
  84. package/dist/types/components/palette.stories.d.ts +6 -6
  85. package/dist/types/components.d.ts +0 -6
  86. package/dist/types/docs/gettingstarted-developer.stories.d.ts +5 -5
  87. package/dist/types/icons.d.ts +2 -2
  88. package/dist/types/index.d.ts +1 -1
  89. package/dist/types/shared/domsanitiser.options.d.ts +10 -10
  90. package/dist/types/stencil-public-runtime.d.ts +59 -3
  91. package/dist/types/transform-tag-name.d.ts +1 -0
  92. package/loader/index.d.ts +9 -0
  93. package/package.json +1 -1
  94. package/dist/cjs/tttx-icon.cjs.entry.js +0 -21
  95. package/dist/esm/tttx-icon.entry.js +0 -17
  96. package/dist/tttx/p-4f3958fa.entry.js +0 -1
  97. package/dist/tttx/p-62869344.js +0 -2
  98. package/dist/tttx/p-92465671.entry.js +0 -1
  99. package/dist/tttx/p-bfdf5c4e.entry.js +0 -1
  100. package/dist/tttx/p-c773116b.entry.js +0 -1
  101. package/dist/tttx/p-cd1565e0.entry.js +0 -3
@@ -1,107 +1,107 @@
1
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2
- import { h, Host } from '@stencil/core';
3
- export class TttxKeyvalueBlock {
4
- constructor() {
5
- this.keyvalues = undefined;
6
- this.horizontal = undefined;
7
- }
8
- renderSingleElements(values) {
9
- const keys = Object.keys(values);
10
- const elements = [];
11
- for (let i = 0; i < keys.length; i++) {
12
- if (this.horizontal) {
13
- elements.push(h("div", null, h("dt", null, keys[i]), h("dd", null, values[keys[i]])));
14
- }
15
- else {
16
- elements.push(h("dt", null, keys[i]));
17
- elements.push(h("dd", null, values[keys[i]]));
18
- }
19
- }
20
- return elements;
21
- }
22
- renderArrayElements(values) {
23
- const elements = [];
24
- for (let i = 0; i < values.length; i++) {
25
- const value = values[i];
26
- if (this.horizontal) {
27
- elements.push(h("div", null, h("dt", { class: 'mainTitle' }, value.title), h("dt", { class: 'subTitle' }, value.subTitle), h("dd", null, value.data)));
28
- }
29
- else {
30
- elements.push(h("dt", { class: 'mainTitle' }, value.title));
31
- elements.push(h("dt", { class: 'subTitle' }, value.subTitle));
32
- elements.push(h("dd", null, value.data));
33
- }
34
- }
35
- return elements;
36
- }
37
- render() {
38
- if (!this.keyvalues) {
39
- return;
40
- }
41
- let values;
42
- if (typeof this.keyvalues === 'string') {
43
- values = JSON.parse(this.keyvalues);
44
- }
45
- else {
46
- values = this.keyvalues;
47
- }
48
- let elements;
49
- if (Array.isArray(values)) {
50
- elements = this.renderArrayElements(values);
51
- }
52
- else {
53
- elements = this.renderSingleElements(values);
54
- }
55
- return (h(Host, null, h("dl", { class: this.horizontal ? 'horizontal' : null }, elements)));
56
- }
57
- static get is() { return "tttx-keyvalue-block"; }
58
- static get encapsulation() { return "shadow"; }
59
- static get originalStyleUrls() {
60
- return {
61
- "$": ["tttx-keyvalue-block.scss"]
62
- };
63
- }
64
- static get styleUrls() {
65
- return {
66
- "$": ["tttx-keyvalue-block.css"]
67
- };
68
- }
69
- static get properties() {
70
- return {
71
- "keyvalues": {
72
- "type": "any",
73
- "mutable": false,
74
- "complexType": {
75
- "original": "any | any[] | string",
76
- "resolved": "any",
77
- "references": {}
78
- },
79
- "required": false,
80
- "optional": false,
81
- "docs": {
82
- "tags": [],
83
- "text": ""
84
- },
85
- "attribute": "keyvalues",
86
- "reflect": false
87
- },
88
- "horizontal": {
89
- "type": "boolean",
90
- "mutable": false,
91
- "complexType": {
92
- "original": "boolean",
93
- "resolved": "boolean",
94
- "references": {}
95
- },
96
- "required": false,
97
- "optional": false,
98
- "docs": {
99
- "tags": [],
100
- "text": ""
101
- },
102
- "attribute": "horizontal",
103
- "reflect": false
104
- }
105
- };
106
- }
107
- }
1
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2
+ import { h, Host } from '@stencil/core';
3
+ export class TttxKeyvalueBlock {
4
+ constructor() {
5
+ this.keyvalues = undefined;
6
+ this.horizontal = undefined;
7
+ }
8
+ renderSingleElements(values) {
9
+ const keys = Object.keys(values);
10
+ const elements = [];
11
+ for (let i = 0; i < keys.length; i++) {
12
+ if (this.horizontal) {
13
+ elements.push(h("div", null, h("dt", null, keys[i]), h("dd", null, values[keys[i]])));
14
+ }
15
+ else {
16
+ elements.push(h("dt", null, keys[i]));
17
+ elements.push(h("dd", null, values[keys[i]]));
18
+ }
19
+ }
20
+ return elements;
21
+ }
22
+ renderArrayElements(values) {
23
+ const elements = [];
24
+ for (let i = 0; i < values.length; i++) {
25
+ const value = values[i];
26
+ if (this.horizontal) {
27
+ elements.push(h("div", null, h("dt", { class: 'mainTitle' }, value.title), h("dt", { class: 'subTitle' }, value.subTitle), h("dd", null, value.data)));
28
+ }
29
+ else {
30
+ elements.push(h("dt", { class: 'mainTitle' }, value.title));
31
+ elements.push(h("dt", { class: 'subTitle' }, value.subTitle));
32
+ elements.push(h("dd", null, value.data));
33
+ }
34
+ }
35
+ return elements;
36
+ }
37
+ render() {
38
+ if (!this.keyvalues) {
39
+ return;
40
+ }
41
+ let values;
42
+ if (typeof this.keyvalues === 'string') {
43
+ values = JSON.parse(this.keyvalues);
44
+ }
45
+ else {
46
+ values = this.keyvalues;
47
+ }
48
+ let elements;
49
+ if (Array.isArray(values)) {
50
+ elements = this.renderArrayElements(values);
51
+ }
52
+ else {
53
+ elements = this.renderSingleElements(values);
54
+ }
55
+ return (h(Host, null, h("dl", { class: this.horizontal ? 'horizontal' : null }, elements)));
56
+ }
57
+ static get is() { return "tttx-keyvalue-block"; }
58
+ static get encapsulation() { return "shadow"; }
59
+ static get originalStyleUrls() {
60
+ return {
61
+ "$": ["tttx-keyvalue-block.scss"]
62
+ };
63
+ }
64
+ static get styleUrls() {
65
+ return {
66
+ "$": ["tttx-keyvalue-block.css"]
67
+ };
68
+ }
69
+ static get properties() {
70
+ return {
71
+ "keyvalues": {
72
+ "type": "any",
73
+ "mutable": false,
74
+ "complexType": {
75
+ "original": "any | any[] | string",
76
+ "resolved": "any",
77
+ "references": {}
78
+ },
79
+ "required": false,
80
+ "optional": false,
81
+ "docs": {
82
+ "tags": [],
83
+ "text": ""
84
+ },
85
+ "attribute": "keyvalues",
86
+ "reflect": false
87
+ },
88
+ "horizontal": {
89
+ "type": "boolean",
90
+ "mutable": false,
91
+ "complexType": {
92
+ "original": "boolean",
93
+ "resolved": "boolean",
94
+ "references": {}
95
+ },
96
+ "required": false,
97
+ "optional": false,
98
+ "docs": {
99
+ "tags": [],
100
+ "text": ""
101
+ },
102
+ "attribute": "horizontal",
103
+ "reflect": false
104
+ }
105
+ };
106
+ }
107
+ }
@@ -1,38 +1,38 @@
1
- export default {
2
- title: 'atoms/Key Value Block',
3
- component: 'tttx-keyvalue-block'
4
- };
5
- const keyValues = {
6
- 'Name': 'John Doe',
7
- 'Date of birth': '14 Jan 1981',
8
- 'Start of postcode': 'AB10'
9
- };
10
- export const KeyValueBlock = () => {
11
- return `<tttx-keyvalue-block keyvalues='${JSON.stringify(keyValues)}' />`;
12
- };
13
- const keyValueArray = [
14
- {
15
- title: "Electrical Designer",
16
- subTitle: "Satchwell",
17
- data: "18 Oct 2021 - Present"
18
- },
19
- {
20
- title: "Electrical Inspector",
21
- subTitle: "Fastned",
22
- data: "20 Dec 2016 - 10 Oct 2021"
23
- },
24
- {
25
- title: "Electrical Tech Prof I - Eng",
26
- subTitle: "Voltech",
27
- data: "20 Dec 2009 - 20 Nov 2016"
28
- },
29
- ];
30
- export const KeyValueSubtitleBlock = () => {
31
- return `<tttx-keyvalue-block keyvalues='${JSON.stringify(keyValueArray)}' />`;
32
- };
33
- export const HorizontalKeyValueBlock = () => {
34
- return `<tttx-keyvalue-block horizontal='true' keyvalues='${JSON.stringify(keyValues)}' />`;
35
- };
36
- export const HorizontalKeyValueSubtitleBlock = () => {
37
- return `<tttx-keyvalue-block horizontal='true' keyvalues='${JSON.stringify(keyValueArray)}' />`;
38
- };
1
+ export default {
2
+ title: 'atoms/Key Value Block',
3
+ component: 'tttx-keyvalue-block'
4
+ };
5
+ const keyValues = {
6
+ 'Name': 'John Doe',
7
+ 'Date of birth': '14 Jan 1981',
8
+ 'Start of postcode': 'AB10'
9
+ };
10
+ export const KeyValueBlock = () => {
11
+ return `<tttx-keyvalue-block keyvalues='${JSON.stringify(keyValues)}' />`;
12
+ };
13
+ const keyValueArray = [
14
+ {
15
+ title: "Electrical Designer",
16
+ subTitle: "Satchwell",
17
+ data: "18 Oct 2021 - Present"
18
+ },
19
+ {
20
+ title: "Electrical Inspector",
21
+ subTitle: "Fastned",
22
+ data: "20 Dec 2016 - 10 Oct 2021"
23
+ },
24
+ {
25
+ title: "Electrical Tech Prof I - Eng",
26
+ subTitle: "Voltech",
27
+ data: "20 Dec 2009 - 20 Nov 2016"
28
+ },
29
+ ];
30
+ export const KeyValueSubtitleBlock = () => {
31
+ return `<tttx-keyvalue-block keyvalues='${JSON.stringify(keyValueArray)}' />`;
32
+ };
33
+ export const HorizontalKeyValueBlock = () => {
34
+ return `<tttx-keyvalue-block horizontal='true' keyvalues='${JSON.stringify(keyValues)}' />`;
35
+ };
36
+ export const HorizontalKeyValueSubtitleBlock = () => {
37
+ return `<tttx-keyvalue-block horizontal='true' keyvalues='${JSON.stringify(keyValueArray)}' />`;
38
+ };
@@ -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
+ }
@@ -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;
@@ -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;