@3t-transform/threeteeui 0.0.6 → 0.0.8

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 (121) hide show
  1. package/dist/cjs/{index-8a7479e4.js → index-8a4cb9bc.js} +256 -407
  2. package/dist/cjs/loader.cjs.js +4 -3
  3. package/dist/cjs/tttx-button.cjs.entry.js +28 -0
  4. package/dist/cjs/tttx-checkbox.cjs.entry.js +28 -0
  5. package/dist/cjs/tttx-form.cjs.entry.js +58 -0
  6. package/dist/cjs/tttx-icon.cjs.entry.js +1845 -5
  7. package/dist/cjs/tttx-input.cjs.entry.js +44 -0
  8. package/dist/cjs/tttx-loading-spinner.cjs.entry.js +26 -0
  9. package/dist/cjs/tttx-popover-content.cjs.entry.js +23 -0
  10. package/dist/cjs/tttx.cjs.js +7 -3
  11. package/dist/collection/collection-manifest.json +9 -5
  12. package/dist/collection/components/atoms/tttx-button/tttx-button.css +61 -0
  13. package/dist/collection/components/atoms/tttx-button/tttx-button.js +93 -0
  14. package/dist/collection/components/atoms/tttx-button/tttx-button.stories.js +27 -0
  15. package/dist/collection/components/atoms/tttx-icon/tttx-icon.css +101 -0
  16. package/dist/collection/components/atoms/tttx-icon/tttx-icon.js +114 -0
  17. package/dist/collection/components/atoms/tttx-icon/tttx-icon.stories.js +47 -0
  18. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.css +48 -0
  19. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.js +66 -0
  20. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.js +15 -0
  21. package/dist/collection/components/atoms/tttx-popover-content/tttx-popover-content.css +30 -0
  22. package/dist/collection/components/atoms/tttx-popover-content/tttx-popover-content.js +96 -0
  23. package/dist/collection/components/atoms/tttx-popover-content/tttx-popover-content.stories.js +23 -0
  24. package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.css +135 -0
  25. package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.js +101 -0
  26. package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.stories.js +13 -0
  27. package/dist/collection/components/molecules/tttx-form/tttx-form.js +109 -0
  28. package/dist/collection/components/molecules/tttx-form/tttx-form.stories.js +33 -0
  29. package/dist/collection/components/molecules/tttx-input/tttx-input.css +149 -0
  30. package/dist/collection/components/molecules/tttx-input/tttx-input.js +259 -0
  31. package/dist/collection/components/molecules/tttx-input/tttx-input.stories.js +106 -0
  32. package/dist/collection/components/palette.stories.js +88 -0
  33. package/dist/collection/icons.js +2838 -0
  34. package/dist/components/index.d.ts +16 -3
  35. package/dist/components/index.js +7 -3
  36. package/dist/components/{tttx-worksheet.d.ts → tttx-button.d.ts} +4 -4
  37. package/dist/components/tttx-button.js +45 -0
  38. package/dist/components/tttx-checkbox.d.ts +11 -0
  39. package/dist/components/tttx-checkbox.js +46 -0
  40. package/dist/components/{tttx-page.d.ts → tttx-form.d.ts} +4 -4
  41. package/dist/components/tttx-form.js +75 -0
  42. package/dist/components/tttx-icon.js +1 -32
  43. package/dist/components/tttx-icon2.js +1875 -0
  44. package/dist/components/tttx-input.d.ts +11 -0
  45. package/dist/components/tttx-input.js +77 -0
  46. package/dist/components/tttx-loading-spinner.d.ts +11 -0
  47. package/dist/components/tttx-loading-spinner.js +43 -0
  48. package/dist/components/tttx-popover-content.d.ts +11 -0
  49. package/dist/components/tttx-popover-content.js +42 -0
  50. package/dist/esm/{index-854ff56f.js → index-9654537d.js} +254 -408
  51. package/dist/esm/loader.js +4 -3
  52. package/dist/esm/polyfills/css-shim.js +1 -1
  53. package/dist/esm/tttx-button.entry.js +24 -0
  54. package/dist/esm/tttx-checkbox.entry.js +24 -0
  55. package/dist/esm/tttx-form.entry.js +54 -0
  56. package/dist/esm/tttx-icon.entry.js +1845 -5
  57. package/dist/esm/tttx-input.entry.js +40 -0
  58. package/dist/esm/tttx-loading-spinner.entry.js +22 -0
  59. package/dist/esm/tttx-popover-content.entry.js +19 -0
  60. package/dist/esm/tttx.js +4 -3
  61. package/dist/tttx/p-1884203f.entry.js +1 -0
  62. package/dist/tttx/p-317b13d3.entry.js +1 -0
  63. package/dist/tttx/p-3cb692d6.entry.js +1 -0
  64. package/dist/tttx/p-3cd7ad04.entry.js +1 -0
  65. package/dist/tttx/p-674e2f18.entry.js +1 -0
  66. package/dist/tttx/p-a23389f1.entry.js +1 -0
  67. package/dist/tttx/p-b6cc2780.js +2 -0
  68. package/dist/tttx/p-f30a0e84.entry.js +1 -0
  69. package/dist/tttx/tttx.esm.js +1 -1
  70. package/dist/types/components/atoms/tttx-button/tttx-button.d.ts +9 -0
  71. package/dist/types/components/atoms/tttx-button/tttx-button.stories.d.ts +20 -0
  72. package/dist/types/components/atoms/tttx-icon/tttx-icon.d.ts +14 -0
  73. package/dist/types/components/atoms/tttx-icon/tttx-icon.stories.d.ts +21 -0
  74. package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.d.ts +6 -0
  75. package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.d.ts +5 -0
  76. package/dist/types/components/atoms/tttx-popover-content/tttx-popover-content.d.ts +7 -0
  77. package/dist/types/components/atoms/tttx-popover-content/tttx-popover-content.stories.d.ts +18 -0
  78. package/dist/types/components/atoms/ttx-checkbox/tttx-checkbox.d.ts +9 -0
  79. package/dist/types/{docs/template.stories.d.ts → components/atoms/ttx-checkbox/tttx-checkbox.stories.d.ts} +1 -0
  80. package/dist/types/components/molecules/tttx-form/tttx-form.d.ts +11 -0
  81. package/dist/types/components/molecules/tttx-form/tttx-form.stories.d.ts +13 -0
  82. package/dist/types/components/molecules/tttx-input/tttx-input.d.ts +20 -0
  83. package/dist/types/components/molecules/tttx-input/tttx-input.stories.d.ts +60 -0
  84. package/dist/types/components/palette.stories.d.ts +6 -0
  85. package/dist/types/components.d.ts +142 -38
  86. package/dist/types/icons.d.ts +2 -0
  87. package/dist/types/stencil-public-runtime.d.ts +59 -3
  88. package/loader/index.d.ts +9 -0
  89. package/package.json +33 -25
  90. package/readme.md +14 -32
  91. package/dist/cjs/toolbar-656be6e6.js +0 -34259
  92. package/dist/cjs/tttx-page.cjs.entry.js +0 -927
  93. package/dist/cjs/tttx-worksheet.cjs.entry.js +0 -47
  94. package/dist/collection/components/components/tttx-icon/tttx-icon.css +0 -89
  95. package/dist/collection/components/components/tttx-icon/tttx-icon.js +0 -59
  96. package/dist/collection/components/components/tttx-icon/tttx-icon.stories.js +0 -40
  97. package/dist/collection/components/patterns/tttx-page/tttx-page.css +0 -162
  98. package/dist/collection/components/patterns/tttx-page/tttx-page.js +0 -213
  99. package/dist/collection/components/patterns/tttx-page/tttx-page.stories.js +0 -80
  100. package/dist/collection/components/patterns/tttx-worksheet/tttx-worksheet.css +0 -134
  101. package/dist/collection/components/patterns/tttx-worksheet/tttx-worksheet.js +0 -70
  102. package/dist/collection/components/patterns/tttx-worksheet/tttx-worksheet.stories.js +0 -44
  103. package/dist/collection/docs/template.stories.js +0 -10
  104. package/dist/components/tttx-page.js +0 -953
  105. package/dist/components/tttx-worksheet.js +0 -6
  106. package/dist/components/tttx-worksheet2.js +0 -34288
  107. package/dist/esm/toolbar-cede4385.js +0 -34231
  108. package/dist/esm/tttx-page.entry.js +0 -923
  109. package/dist/esm/tttx-worksheet.entry.js +0 -43
  110. package/dist/tttx/p-4b57de2e.entry.js +0 -1
  111. package/dist/tttx/p-61f78304.entry.js +0 -1
  112. package/dist/tttx/p-7244abd4.entry.js +0 -1
  113. package/dist/tttx/p-d038fe18.js +0 -1
  114. package/dist/tttx/p-ddfeb0ba.js +0 -2
  115. package/dist/tttx/tttx.css +0 -1
  116. package/dist/types/components/components/tttx-icon/tttx-icon.d.ts +0 -5
  117. package/dist/types/components/components/tttx-icon/tttx-icon.stories.d.ts +0 -24
  118. package/dist/types/components/patterns/tttx-page/tttx-page.d.ts +0 -21
  119. package/dist/types/components/patterns/tttx-page/tttx-page.stories.d.ts +0 -48
  120. package/dist/types/components/patterns/tttx-worksheet/tttx-worksheet.d.ts +0 -9
  121. package/dist/types/components/patterns/tttx-worksheet/tttx-worksheet.stories.d.ts +0 -23
@@ -0,0 +1,66 @@
1
+ import { h } from '@stencil/core';
2
+ export class TttxLoadingSpinner {
3
+ constructor() {
4
+ this.loadingMessage = undefined;
5
+ this.size = 'large';
6
+ }
7
+ renderLoadingMessage() {
8
+ if (!this.loadingMessage)
9
+ return '';
10
+ return h("div", { class: 'loading-text' }, "Loading, please wait...");
11
+ }
12
+ render() {
13
+ return h("div", { class: 'spinner-container' }, h("div", { class: "loading-box" }, h("span", { class: `spinner ${this.size}` })), this.renderLoadingMessage());
14
+ }
15
+ static get is() { return "tttx-loading-spinner"; }
16
+ static get encapsulation() { return "shadow"; }
17
+ static get originalStyleUrls() {
18
+ return {
19
+ "$": ["tttx-loading-spinner.scss"]
20
+ };
21
+ }
22
+ static get styleUrls() {
23
+ return {
24
+ "$": ["tttx-loading-spinner.css"]
25
+ };
26
+ }
27
+ static get properties() {
28
+ return {
29
+ "loadingMessage": {
30
+ "type": "boolean",
31
+ "mutable": true,
32
+ "complexType": {
33
+ "original": "boolean",
34
+ "resolved": "boolean",
35
+ "references": {}
36
+ },
37
+ "required": false,
38
+ "optional": false,
39
+ "docs": {
40
+ "tags": [],
41
+ "text": ""
42
+ },
43
+ "attribute": "loading-message",
44
+ "reflect": false
45
+ },
46
+ "size": {
47
+ "type": "string",
48
+ "mutable": true,
49
+ "complexType": {
50
+ "original": "'small' | 'large'",
51
+ "resolved": "\"large\" | \"small\"",
52
+ "references": {}
53
+ },
54
+ "required": false,
55
+ "optional": false,
56
+ "docs": {
57
+ "tags": [],
58
+ "text": ""
59
+ },
60
+ "attribute": "size",
61
+ "reflect": false,
62
+ "defaultValue": "'large'"
63
+ }
64
+ };
65
+ }
66
+ }
@@ -0,0 +1,15 @@
1
+ export default {
2
+ title: 'atoms/TTTX Loading Spinner',
3
+ component: 'tttx-loading-spinner',
4
+ argTypes: {
5
+ loadingMessage: {
6
+ control: 'boolean',
7
+ },
8
+ size: {
9
+ control: { type: 'inline-radio', options: ['small', 'large'] },
10
+ },
11
+ },
12
+ };
13
+ export const Example = { render: (args) => {
14
+ return `<tttx-loading-spinner ${args.loadingMessage ? 'loading-message' : ''} size='${args.size}'/>`;
15
+ } };
@@ -0,0 +1,30 @@
1
+ .material-symbols-rounded {
2
+ font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
3
+ }
4
+
5
+ :host {
6
+ display: block;
7
+ max-width: 400px;
8
+ }
9
+
10
+ h4 {
11
+ margin: 0;
12
+ font-size: 15px;
13
+ font-weight: 700;
14
+ color: black;
15
+ margin-bottom: 4px;
16
+ }
17
+
18
+ p {
19
+ margin: 0;
20
+ font-size: 14px;
21
+ font-weight: normal;
22
+ color: black;
23
+ margin-bottom: 4px;
24
+ }
25
+
26
+ .linky {
27
+ color: #1479c6;
28
+ text-decoration: none;
29
+ cursor: pointer;
30
+ }
@@ -0,0 +1,96 @@
1
+ import { Host, h } from '@stencil/core';
2
+ export class TttxPopoverContent {
3
+ constructor() {
4
+ this.header = undefined;
5
+ this.body = undefined;
6
+ this.linkcontext = undefined;
7
+ this.linktext = undefined;
8
+ }
9
+ render() {
10
+ return (h(Host, null, this.header && h("h4", null, this.header), this.body && h("p", null, this.body), this.linkcontext && h("span", { class: "linky", onClick: (evt) => console.log(this.linkcontext, evt) }, this.linktext || 'More Information')));
11
+ }
12
+ static get is() { return "tttx-popover-content"; }
13
+ static get encapsulation() { return "shadow"; }
14
+ static get originalStyleUrls() {
15
+ return {
16
+ "$": ["tttx-popover-content.scss"]
17
+ };
18
+ }
19
+ static get styleUrls() {
20
+ return {
21
+ "$": ["tttx-popover-content.css"]
22
+ };
23
+ }
24
+ static get properties() {
25
+ return {
26
+ "header": {
27
+ "type": "string",
28
+ "mutable": false,
29
+ "complexType": {
30
+ "original": "string",
31
+ "resolved": "string",
32
+ "references": {}
33
+ },
34
+ "required": false,
35
+ "optional": false,
36
+ "docs": {
37
+ "tags": [],
38
+ "text": ""
39
+ },
40
+ "attribute": "header",
41
+ "reflect": false
42
+ },
43
+ "body": {
44
+ "type": "string",
45
+ "mutable": false,
46
+ "complexType": {
47
+ "original": "string",
48
+ "resolved": "string",
49
+ "references": {}
50
+ },
51
+ "required": false,
52
+ "optional": false,
53
+ "docs": {
54
+ "tags": [],
55
+ "text": ""
56
+ },
57
+ "attribute": "body",
58
+ "reflect": false
59
+ },
60
+ "linkcontext": {
61
+ "type": "string",
62
+ "mutable": false,
63
+ "complexType": {
64
+ "original": "string",
65
+ "resolved": "string",
66
+ "references": {}
67
+ },
68
+ "required": false,
69
+ "optional": false,
70
+ "docs": {
71
+ "tags": [],
72
+ "text": ""
73
+ },
74
+ "attribute": "linkcontext",
75
+ "reflect": false
76
+ },
77
+ "linktext": {
78
+ "type": "string",
79
+ "mutable": false,
80
+ "complexType": {
81
+ "original": "string",
82
+ "resolved": "string",
83
+ "references": {}
84
+ },
85
+ "required": false,
86
+ "optional": false,
87
+ "docs": {
88
+ "tags": [],
89
+ "text": ""
90
+ },
91
+ "attribute": "linktext",
92
+ "reflect": false
93
+ }
94
+ };
95
+ }
96
+ }
@@ -0,0 +1,23 @@
1
+ export default {
2
+ title: 'Atoms/PopoverContent',
3
+ component: 'tttx-popover-content',
4
+ argTypes: {
5
+ header: {
6
+ control: {
7
+ type: 'text',
8
+ }
9
+ },
10
+ body: {
11
+ control: {
12
+ type: 'text',
13
+ }
14
+ },
15
+ },
16
+ };
17
+ const Template = ({ header, body, linkcontext }) => `<tttx-popover-content header="${header}" body="${body}" linkcontext="${linkcontext}" />`;
18
+ export const Basic = Template.bind({});
19
+ Basic.args = {
20
+ header: 'HEADER',
21
+ body: 'BODY',
22
+ linkcontext: 'TESTING123'
23
+ };
@@ -0,0 +1,135 @@
1
+ .material-symbols-rounded {
2
+ font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
3
+ }
4
+
5
+ .material-symbols-rounded {
6
+ font-family: "Material Symbols Rounded", sans-serif;
7
+ font-weight: 400;
8
+ font-style: normal;
9
+ font-size: 24px;
10
+ line-height: 1;
11
+ letter-spacing: normal;
12
+ text-transform: none;
13
+ display: inline-block;
14
+ white-space: nowrap;
15
+ word-wrap: normal;
16
+ direction: ltr;
17
+ text-rendering: optimizeLegibility;
18
+ -webkit-font-smoothing: antialiased;
19
+ color: #9e9e9e;
20
+ }
21
+
22
+ .field {
23
+ clear: both;
24
+ }
25
+
26
+ .container {
27
+ display: flex;
28
+ flex-wrap: wrap;
29
+ box-sizing: border-box;
30
+ height: 36px;
31
+ border: 1px solid #c8c8c8;
32
+ border-radius: 4px;
33
+ }
34
+
35
+ .icon-left,
36
+ .icon-right {
37
+ flex-basis: 24px;
38
+ }
39
+
40
+ .icon-left span,
41
+ .icon-right span {
42
+ font-size: 24px;
43
+ line-height: 24px;
44
+ text-align: center;
45
+ display: block;
46
+ width: 24px;
47
+ height: 24px;
48
+ margin-top: 4px;
49
+ }
50
+
51
+ .icon-left span {
52
+ margin-left: 4px;
53
+ }
54
+
55
+ .icon-right span {
56
+ margin-right: 4px;
57
+ }
58
+
59
+ .input {
60
+ flex-grow: 1;
61
+ border: none;
62
+ outline: none;
63
+ font-size: 16px;
64
+ padding: 8px 16px;
65
+ background-color: transparent;
66
+ }
67
+
68
+ .iconleft .input {
69
+ padding-left: 4px;
70
+ }
71
+
72
+ .iconright .input {
73
+ padding-right: 4px;
74
+ }
75
+
76
+ .label {
77
+ display: block;
78
+ height: 18px;
79
+ font-weight: 600;
80
+ color: #212121;
81
+ font-size: 16px;
82
+ margin-bottom: 4px;
83
+ z-index: 1;
84
+ }
85
+
86
+ .disabled {
87
+ background: #f0f0f0;
88
+ color: #9e9e9e;
89
+ border-color: #c8c8c8;
90
+ }
91
+
92
+ .focused {
93
+ border-color: #1479c6;
94
+ }
95
+
96
+ .errormsg {
97
+ display: flex;
98
+ justify-content: center;
99
+ align-items: center;
100
+ float: left;
101
+ margin-bottom: 16px;
102
+ box-sizing: border-box;
103
+ background-color: transparent;
104
+ height: 26px;
105
+ font-size: 14px;
106
+ border-radius: none;
107
+ z-index: 2;
108
+ color: #DC0000;
109
+ }
110
+
111
+ .errormsg .validationicon {
112
+ width: 16px;
113
+ height: 16px;
114
+ font-size: 16px;
115
+ margin-right: 4px;
116
+ vertical-align: middle;
117
+ color: #DC0000;
118
+ }
119
+
120
+ .danger {
121
+ color: #DC0000;
122
+ }
123
+
124
+ .optional {
125
+ color: #757575;
126
+ font-weight: normal;
127
+ }
128
+
129
+ :host {
130
+ display: block;
131
+ }
132
+
133
+ .spacing {
134
+ margin-bottom: 16px;
135
+ }
@@ -0,0 +1,101 @@
1
+ import { Host, h } from '@stencil/core';
2
+ export class TttxCheckbox {
3
+ constructor() {
4
+ this.value = undefined;
5
+ this.label = undefined;
6
+ this.required = undefined;
7
+ }
8
+ handleClick(event) {
9
+ const target = event.target;
10
+ this.value = target.checked;
11
+ this.valueChanged.emit(target.checked);
12
+ }
13
+ render() {
14
+ return (h(Host, null, h("div", { class: "field spacing" }, this.label && h("label", { class: "label" }, this.label, !this.required ? h("span", { class: "optional" }, " (optional)") : ''), h("input", { type: "checkbox", class: "input", onChange: event => this.handleClick(event), checked: this.value }))));
15
+ }
16
+ static get is() { return "tttx-checkbox"; }
17
+ static get encapsulation() { return "shadow"; }
18
+ static get originalStyleUrls() {
19
+ return {
20
+ "$": ["tttx-checkbox.scss"]
21
+ };
22
+ }
23
+ static get styleUrls() {
24
+ return {
25
+ "$": ["tttx-checkbox.css"]
26
+ };
27
+ }
28
+ static get properties() {
29
+ return {
30
+ "value": {
31
+ "type": "boolean",
32
+ "mutable": false,
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": "value",
45
+ "reflect": false
46
+ },
47
+ "label": {
48
+ "type": "string",
49
+ "mutable": false,
50
+ "complexType": {
51
+ "original": "string",
52
+ "resolved": "string",
53
+ "references": {}
54
+ },
55
+ "required": false,
56
+ "optional": false,
57
+ "docs": {
58
+ "tags": [],
59
+ "text": ""
60
+ },
61
+ "attribute": "label",
62
+ "reflect": false
63
+ },
64
+ "required": {
65
+ "type": "boolean",
66
+ "mutable": false,
67
+ "complexType": {
68
+ "original": "boolean",
69
+ "resolved": "boolean",
70
+ "references": {}
71
+ },
72
+ "required": false,
73
+ "optional": false,
74
+ "docs": {
75
+ "tags": [],
76
+ "text": ""
77
+ },
78
+ "attribute": "required",
79
+ "reflect": false
80
+ }
81
+ };
82
+ }
83
+ static get events() {
84
+ return [{
85
+ "method": "valueChanged",
86
+ "name": "valueChanged",
87
+ "bubbles": true,
88
+ "cancelable": true,
89
+ "composed": true,
90
+ "docs": {
91
+ "tags": [],
92
+ "text": ""
93
+ },
94
+ "complexType": {
95
+ "original": "boolean",
96
+ "resolved": "boolean",
97
+ "references": {}
98
+ }
99
+ }];
100
+ }
101
+ }
@@ -0,0 +1,13 @@
1
+ export default {
2
+ title: 'Atoms/Checkbox',
3
+ component: 'tttx-checkbox',
4
+ };
5
+ const Template = ({ value }) => `
6
+ <tttx-checkbox
7
+ ${value ? 'value="true"' : ''}
8
+ ></tttx-checkbox>
9
+ `;
10
+ export const Default = Template.bind({});
11
+ Default.args = {
12
+ value: false
13
+ };
@@ -0,0 +1,109 @@
1
+ import { h } from '@stencil/core';
2
+ export class TttxForm {
3
+ constructor() {
4
+ this.fetchFormData = () => {
5
+ let validForm = true;
6
+ const formData = {};
7
+ const elements = this.el.querySelectorAll(`[${this.dataAttribute}]`);
8
+ elements.forEach((element) => {
9
+ const inputElement = element;
10
+ validForm = validForm ? this.validateFormField(inputElement) : false;
11
+ formData[inputElement.getAttribute(this.dataAttribute)] = inputElement.value;
12
+ });
13
+ return validForm ? formData : null;
14
+ };
15
+ this.dataAttribute = 'form-data';
16
+ this.functionAttribute = 'function-data';
17
+ }
18
+ validateFormField(element) {
19
+ let isValid = true;
20
+ const isRequired = element.hasAttribute("required");
21
+ if (isRequired && !element.value) {
22
+ // required and not set, show error
23
+ element.setAttribute("showerrormsg", "true");
24
+ isValid = false;
25
+ }
26
+ else {
27
+ // required and set, ensure error does not show
28
+ element.removeAttribute("showerrormsg");
29
+ }
30
+ return isValid;
31
+ }
32
+ componentDidLoad() {
33
+ const elements = this.el.querySelectorAll(`[${this.functionAttribute}]`);
34
+ elements.forEach((element) => {
35
+ element.addEventListener('click', event => {
36
+ event.preventDefault();
37
+ const formData = this.fetchFormData();
38
+ if (formData) {
39
+ // only emit event if form data is valid
40
+ this.formSubmit.emit(this.fetchFormData());
41
+ }
42
+ });
43
+ });
44
+ }
45
+ render() {
46
+ return (h("div", null, h("slot", null)));
47
+ }
48
+ static get is() { return "tttx-form"; }
49
+ static get encapsulation() { return "shadow"; }
50
+ static get properties() {
51
+ return {
52
+ "dataAttribute": {
53
+ "type": "string",
54
+ "mutable": false,
55
+ "complexType": {
56
+ "original": "string",
57
+ "resolved": "string",
58
+ "references": {}
59
+ },
60
+ "required": false,
61
+ "optional": false,
62
+ "docs": {
63
+ "tags": [],
64
+ "text": ""
65
+ },
66
+ "attribute": "data-attribute",
67
+ "reflect": false,
68
+ "defaultValue": "'form-data'"
69
+ },
70
+ "functionAttribute": {
71
+ "type": "string",
72
+ "mutable": false,
73
+ "complexType": {
74
+ "original": "string",
75
+ "resolved": "string",
76
+ "references": {}
77
+ },
78
+ "required": false,
79
+ "optional": false,
80
+ "docs": {
81
+ "tags": [],
82
+ "text": ""
83
+ },
84
+ "attribute": "function-attribute",
85
+ "reflect": false,
86
+ "defaultValue": "'function-data'"
87
+ }
88
+ };
89
+ }
90
+ static get events() {
91
+ return [{
92
+ "method": "formSubmit",
93
+ "name": "formSubmit",
94
+ "bubbles": true,
95
+ "cancelable": true,
96
+ "composed": true,
97
+ "docs": {
98
+ "tags": [],
99
+ "text": ""
100
+ },
101
+ "complexType": {
102
+ "original": "any",
103
+ "resolved": "any",
104
+ "references": {}
105
+ }
106
+ }];
107
+ }
108
+ static get elementRef() { return "el"; }
109
+ }
@@ -0,0 +1,33 @@
1
+ export default {
2
+ title: 'molecules/TTTX Form',
3
+ component: 'tttx-form',
4
+ parameters: {
5
+ actions: {
6
+ handles: ['formSubmit'],
7
+ },
8
+ },
9
+ };
10
+ export const CreateUserTemplate = () => `
11
+ <tttx-form>
12
+ <tttx-input label="Email Address" form-data="email" errormsg="Email is required" required showerrormsg></tttx-input>
13
+ <tttx-input label="Password" form-data="password" type="password" errormsg="Enter a password" required showerrormsg></tttx-input>
14
+ <tttx-input label="Repeat Password" form-data="repeatpassword" type="password" errormsg="Repeat your password" required showerrormsg></tttx-input>
15
+ <tttx-checkbox label="Has Signed GDPR" form-data="gdpr" required></tttx-checkbox>
16
+ <tttx-button font-color="font-white" button-style="primary-blue" function-data="submit">Create User</tttx-button>
17
+ </tttx-form>
18
+ `;
19
+ export const LoginTemplate = () => `
20
+ <tttx-form>
21
+ <tttx-input label="Email" form-data="email" errormsg="email is required" required></tttx-input>
22
+ <tttx-input label="Password" form-data="password" type="password" errormsg="password is required" required></tttx-input>
23
+ <tttx-checkbox label="Remember my Password" form-data="rememberpassword" required></tttx-checkbox>
24
+ <tttx-button font-color="font-white" button-style="primary-blue" function-data="submit">Log In</tttx-button>
25
+ </tttx-form>
26
+ `;
27
+ export const TextBoxExample = () => `
28
+ <tttx-form>
29
+ <tttx-text-box form-data="firstname" label="First Name" errormsg="Field is required" required></tttx-text-box>
30
+ <tttx-text-box form-data="lastname" label="Last Name"></tttx-text-box>
31
+ <tttx-button font-color="font-white" button-style="primary-blue" function-data="submit">Submit</tttx-button>
32
+ </tttx-form>
33
+ `;