@3t-transform/threeteeui 0.2.75 → 0.2.76
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/loader.cjs.js +1 -1
- package/dist/cjs/tttx-button.cjs.entry.js +2 -2
- package/dist/cjs/tttx-form.cjs.entry.js +78 -49
- package/dist/cjs/tttx-keyvalue-block.cjs.entry.js +17 -14
- package/dist/cjs/tttx-list.cjs.entry.js +1 -1
- package/dist/cjs/tttx-standalone-input.cjs.entry.js +8 -3
- package/dist/cjs/tttx-tag.cjs.entry.js +1 -1
- package/dist/cjs/tttx.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/atoms/tttx-button/tttx-button.css +1 -1
- package/dist/collection/components/atoms/tttx-button/tttx-button.js +1 -2
- package/dist/collection/components/atoms/tttx-button/tttx-button.stories.js +1 -1
- package/dist/collection/components/atoms/tttx-icon/tttx-icon.js +0 -1
- package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.css +14 -5
- package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.js +46 -18
- package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.js +85 -29
- package/dist/collection/components/atoms/tttx-tag/tttx-tag.css +1 -1
- package/dist/collection/components/atoms/tttx-tag/tttx-tag.js +0 -1
- package/dist/collection/components/atoms/tttx-tag/tttx-tag.stories.js +1 -1
- package/dist/collection/components/molecules/tttx-form/lib/setErrorState.js +14 -3
- package/dist/collection/components/molecules/tttx-form/lib/validityCheck.js +15 -13
- package/dist/collection/components/molecules/tttx-form/tttx-form.css +107 -177
- package/dist/collection/components/molecules/tttx-form/tttx-form.js +56 -36
- package/dist/collection/components/molecules/tttx-list/tttx-list.css +1 -1
- package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.css +102 -198
- package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.js +7 -2
- package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.js +23 -5
- package/dist/components/tttx-button2.js +2 -2
- package/dist/components/tttx-form.js +79 -50
- package/dist/components/tttx-keyvalue-block.js +21 -16
- package/dist/components/tttx-list.js +1 -1
- package/dist/components/tttx-standalone-input2.js +8 -3
- package/dist/components/tttx-tag.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/tttx-button.entry.js +2 -2
- package/dist/esm/tttx-form.entry.js +78 -49
- package/dist/esm/tttx-keyvalue-block.entry.js +17 -14
- package/dist/esm/tttx-list.entry.js +1 -1
- package/dist/esm/tttx-standalone-input.entry.js +8 -3
- package/dist/esm/tttx-tag.entry.js +1 -1
- package/dist/esm/tttx.js +1 -1
- package/dist/tttx/p-09b92178.entry.js +1 -0
- package/dist/tttx/{p-750cf31b.entry.js → p-129df5a2.entry.js} +1 -1
- package/dist/tttx/{p-a6582ab0.entry.js → p-25acdd4c.entry.js} +1 -1
- package/dist/tttx/{p-5b7b8539.entry.js → p-4ade2866.entry.js} +1 -1
- package/dist/tttx/p-b30a1025.entry.js +1 -0
- package/dist/tttx/p-d1ff1456.entry.js +1 -0
- package/dist/tttx/tttx.esm.js +1 -1
- package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.d.ts +7 -1
- package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.d.ts +6 -4
- package/dist/types/components/molecules/tttx-form/lib/setErrorState.d.ts +3 -2
- package/dist/types/components/molecules/tttx-form/lib/validityCheck.d.ts +5 -7
- package/dist/types/components/molecules/tttx-form/tttx-form.d.ts +74 -29
- package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.d.ts +7 -0
- package/dist/types/components.d.ts +7 -4
- package/package.json +1 -1
- package/dist/tttx/p-6fe0af4e.entry.js +0 -1
- package/dist/tttx/p-818574fe.entry.js +0 -1
- package/dist/tttx/p-895526aa.entry.js +0 -1
|
@@ -6,168 +6,120 @@
|
|
|
6
6
|
font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
font-
|
|
9
|
+
label {
|
|
10
|
+
font-weight: 500;
|
|
11
|
+
font-size: 16px;
|
|
12
|
+
line-height: 19px;
|
|
13
|
+
color: #212121;
|
|
14
|
+
}
|
|
15
|
+
label .optional {
|
|
16
|
+
color: #757575;
|
|
11
17
|
font-weight: normal;
|
|
12
|
-
font-style: normal;
|
|
13
|
-
font-size: 24px;
|
|
14
|
-
line-height: 1;
|
|
15
|
-
letter-spacing: normal;
|
|
16
|
-
text-transform: none;
|
|
17
|
-
display: inline-block;
|
|
18
|
-
white-space: nowrap;
|
|
19
|
-
word-wrap: normal;
|
|
20
|
-
direction: ltr;
|
|
21
|
-
text-rendering: optimizeLegibility;
|
|
22
|
-
-webkit-font-smoothing: antialiased;
|
|
23
|
-
color: #9e9e9e;
|
|
24
18
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.icon-right {
|
|
28
|
-
flex-basis: 24px;
|
|
19
|
+
label .outer-container {
|
|
20
|
+
position: relative;
|
|
29
21
|
}
|
|
30
|
-
|
|
31
|
-
.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
line-height: 24px;
|
|
35
|
-
text-align: center;
|
|
36
|
-
display: block;
|
|
37
|
-
width: 24px;
|
|
22
|
+
label .outer-container .left-icons,
|
|
23
|
+
label .outer-container .right-icons {
|
|
24
|
+
display: flex;
|
|
25
|
+
position: absolute;
|
|
38
26
|
height: 24px;
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.icon-left span {
|
|
43
|
-
margin-left: 4px;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.icon-right span {
|
|
47
|
-
margin-right: 4px;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.icon-right {
|
|
51
|
-
margin-top: 5px;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.icon-left {
|
|
55
|
-
margin-top: 5px;
|
|
56
|
-
margin-left: 4px;
|
|
27
|
+
gap: 8px;
|
|
57
28
|
}
|
|
58
|
-
|
|
59
|
-
.
|
|
60
|
-
|
|
29
|
+
label .outer-container .left-icons tttx-icon,
|
|
30
|
+
label .outer-container .right-icons tttx-icon {
|
|
31
|
+
height: 24px;
|
|
32
|
+
width: 24px;
|
|
61
33
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
padding-right: 4px;
|
|
34
|
+
label .outer-container .left-icons {
|
|
35
|
+
left: 8px;
|
|
65
36
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
position: absolute;
|
|
69
|
-
margin-top: 9px;
|
|
70
|
-
margin-left: 4px;
|
|
37
|
+
label .outer-container .right-icons {
|
|
38
|
+
right: 8px;
|
|
71
39
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
display: flex;
|
|
75
|
-
justify-content: center;
|
|
76
|
-
align-items: center;
|
|
77
|
-
float: left;
|
|
78
|
-
margin-bottom: 16px;
|
|
40
|
+
label .outer-container input {
|
|
41
|
+
color: #212121;
|
|
79
42
|
box-sizing: border-box;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.errormsg .validationicon {
|
|
90
|
-
width: 16px;
|
|
91
|
-
height: 16px;
|
|
92
|
-
font-size: 16px;
|
|
93
|
-
line-height: 19px;
|
|
94
|
-
margin-right: 4px;
|
|
95
|
-
vertical-align: middle;
|
|
96
|
-
color: #dc0000;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.danger {
|
|
100
|
-
color: #dc0000;
|
|
43
|
+
border: 1px solid #d5d5d5;
|
|
44
|
+
border-radius: 4px;
|
|
45
|
+
padding: 0;
|
|
46
|
+
padding-left: 16px;
|
|
47
|
+
padding-right: 16px;
|
|
48
|
+
margin-top: 4px;
|
|
49
|
+
/* iPhone OS fix */
|
|
101
50
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
color: #757575;
|
|
105
|
-
font-weight: normal;
|
|
51
|
+
label .outer-container input.has-input-icon {
|
|
52
|
+
padding-left: 40px;
|
|
106
53
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
display: block;
|
|
110
|
-
position: relative;
|
|
111
|
-
line-height: 21px;
|
|
54
|
+
label .outer-container input.has-input-icon.has-left-icon {
|
|
55
|
+
padding-left: 72px;
|
|
112
56
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
display: flex;
|
|
116
|
-
white-space: nowrap;
|
|
117
|
-
align-items: center;
|
|
57
|
+
label .outer-container input.has-left-icon {
|
|
58
|
+
padding-left: 40px;
|
|
118
59
|
}
|
|
119
|
-
label
|
|
120
|
-
|
|
121
|
-
width: 100%;
|
|
122
|
-
display: flex;
|
|
123
|
-
align-items: center;
|
|
124
|
-
gap: 4px;
|
|
125
|
-
position: relative;
|
|
60
|
+
label .outer-container input.has-right-icon {
|
|
61
|
+
padding-right: 40px;
|
|
126
62
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
font-weight: 500;
|
|
130
|
-
font-size: 16px;
|
|
131
|
-
line-height: 19px;
|
|
132
|
-
margin-bottom: 16px;
|
|
63
|
+
label .outer-container input.invalid {
|
|
64
|
+
border: 1px solid #dc0000;
|
|
133
65
|
}
|
|
134
|
-
|
|
135
|
-
input:not([type=submit]) {
|
|
66
|
+
label .outer-container input:not([type=submit]) {
|
|
136
67
|
font-family: "Roboto", serif;
|
|
137
|
-
box-sizing: border-box;
|
|
138
68
|
width: 100%;
|
|
139
69
|
height: 36px;
|
|
140
|
-
padding: 0 16px;
|
|
141
70
|
font-size: 16px;
|
|
142
71
|
line-height: 19px;
|
|
143
|
-
border: 1px solid #d5d5d5;
|
|
144
|
-
border-radius: 4px;
|
|
145
|
-
margin-top: 4px;
|
|
146
72
|
}
|
|
147
|
-
|
|
148
|
-
/* iPhone OS fix */
|
|
149
|
-
input[type=date] {
|
|
73
|
+
label .outer-container input[type=date] {
|
|
150
74
|
background: white;
|
|
151
75
|
display: block;
|
|
152
76
|
min-width: calc(100% - 18px);
|
|
153
77
|
line-height: 37px;
|
|
154
78
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
79
|
+
label .outer-container input[readonly] {
|
|
80
|
+
cursor: default;
|
|
81
|
+
pointer-events: none;
|
|
82
|
+
user-select: none;
|
|
83
|
+
color: gray;
|
|
161
84
|
}
|
|
162
|
-
|
|
163
|
-
border:
|
|
85
|
+
label .outer-container input:focus {
|
|
86
|
+
border-color: #1479c6;
|
|
164
87
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
padding: 0 32px;
|
|
88
|
+
label .outer-container input:focus-visible {
|
|
89
|
+
outline: none;
|
|
168
90
|
}
|
|
169
|
-
|
|
170
|
-
|
|
91
|
+
label .outer-container.inputBlock {
|
|
92
|
+
display: flex;
|
|
93
|
+
align-items: center;
|
|
94
|
+
line-height: 21px;
|
|
95
|
+
}
|
|
96
|
+
label .outer-container.inputBlock .left-icons,
|
|
97
|
+
label .outer-container.inputBlock .right-icons {
|
|
98
|
+
margin-top: 4px;
|
|
99
|
+
}
|
|
100
|
+
label .outer-container.inputBlock.readonly {
|
|
101
|
+
pointer-events: none;
|
|
102
|
+
user-select: none;
|
|
103
|
+
color: gray;
|
|
104
|
+
}
|
|
105
|
+
label .outer-container.inputInline {
|
|
106
|
+
display: flex;
|
|
107
|
+
white-space: nowrap;
|
|
108
|
+
align-items: center;
|
|
109
|
+
margin: 0;
|
|
110
|
+
}
|
|
111
|
+
label .outer-container.inputInline input {
|
|
112
|
+
margin-top: 0;
|
|
113
|
+
}
|
|
114
|
+
label .secondarylabel {
|
|
115
|
+
color: #757575;
|
|
116
|
+
font-size: 14px;
|
|
117
|
+
line-height: 16px;
|
|
118
|
+
font-weight: normal;
|
|
119
|
+
display: flex;
|
|
120
|
+
margin-top: 4px;
|
|
121
|
+
}
|
|
122
|
+
label .errorBubble {
|
|
171
123
|
position: relative;
|
|
172
124
|
font-size: 14px;
|
|
173
125
|
line-height: 16px;
|
|
@@ -181,54 +133,30 @@ input ~ .errorBubble {
|
|
|
181
133
|
justify-items: center;
|
|
182
134
|
margin-top: 4px;
|
|
183
135
|
}
|
|
184
|
-
|
|
185
|
-
input ~ .errorBubble:not(.visible) {
|
|
136
|
+
label .errorBubble:not(.visible) {
|
|
186
137
|
display: none;
|
|
187
138
|
}
|
|
188
|
-
|
|
189
|
-
input ~ .errorBubble span {
|
|
139
|
+
label .errorBubble span {
|
|
190
140
|
color: #dc0000;
|
|
191
141
|
font-size: 16px;
|
|
192
142
|
margin-right: 4px;
|
|
193
143
|
}
|
|
194
144
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
font-
|
|
198
|
-
font-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
.secondarylabel {
|
|
213
|
-
color: #757575;
|
|
214
|
-
font-size: 14px;
|
|
215
|
-
line-height: 16px;
|
|
216
|
-
font-weight: normal;
|
|
217
|
-
display: flex;
|
|
218
|
-
margin-top: 4px;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
label.inputBlock.readonly {
|
|
222
|
-
pointer-events: none;
|
|
223
|
-
user-select: none;
|
|
224
|
-
color: gray;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
input[readonly] {
|
|
228
|
-
cursor: default;
|
|
229
|
-
pointer-events: none;
|
|
230
|
-
user-select: none;
|
|
231
|
-
color: gray;
|
|
145
|
+
.material-symbols-rounded {
|
|
146
|
+
font-family: "Material Symbols Rounded", sans-serif;
|
|
147
|
+
font-weight: 400;
|
|
148
|
+
font-style: normal;
|
|
149
|
+
font-size: 24px;
|
|
150
|
+
line-height: 1;
|
|
151
|
+
letter-spacing: normal;
|
|
152
|
+
text-transform: none;
|
|
153
|
+
display: inline-block;
|
|
154
|
+
white-space: nowrap;
|
|
155
|
+
word-wrap: normal;
|
|
156
|
+
direction: ltr;
|
|
157
|
+
text-rendering: optimizeLegibility;
|
|
158
|
+
-webkit-font-smoothing: antialiased;
|
|
159
|
+
color: #9e9e9e;
|
|
232
160
|
}
|
|
233
161
|
|
|
234
162
|
button {
|
|
@@ -251,7 +179,7 @@ button {
|
|
|
251
179
|
justify-content: left;
|
|
252
180
|
align-items: center;
|
|
253
181
|
font-size: 14px;
|
|
254
|
-
font-weight:
|
|
182
|
+
font-weight: 500;
|
|
255
183
|
}
|
|
256
184
|
|
|
257
185
|
.button-content {
|
|
@@ -394,8 +322,10 @@ fieldset {
|
|
|
394
322
|
border: none;
|
|
395
323
|
}
|
|
396
324
|
|
|
397
|
-
label
|
|
398
|
-
display:
|
|
325
|
+
label {
|
|
326
|
+
display: block;
|
|
327
|
+
position: relative;
|
|
328
|
+
margin-bottom: 16px;
|
|
399
329
|
}
|
|
400
330
|
|
|
401
331
|
.inlineLabel {
|
|
@@ -18,11 +18,8 @@ export class TttxForm {
|
|
|
18
18
|
// If the formSchema changes and the form data is uncontrolled, store the data since the fields will be removed to avoid form duplication
|
|
19
19
|
if (!this.data && this.form && this._formSchema) {
|
|
20
20
|
const formData = new FormData(this.form);
|
|
21
|
-
this._data = Object.fromEntries(Object.keys(this._formSchema.properties).map(
|
|
22
|
-
return [
|
|
23
|
-
formKey,
|
|
24
|
-
formData.get(formKey)
|
|
25
|
-
];
|
|
21
|
+
this._data = Object.fromEntries(Object.keys(this._formSchema.properties).map(formKey => {
|
|
22
|
+
return [formKey, formData.get(formKey)];
|
|
26
23
|
}));
|
|
27
24
|
}
|
|
28
25
|
// Check if the new value is a string, indicating that it needs to be parsed
|
|
@@ -47,7 +44,7 @@ export class TttxForm {
|
|
|
47
44
|
* Handles the focus event for a form field and emits a "dataChanged" event
|
|
48
45
|
* to the parent component with the field name and its new value.
|
|
49
46
|
*
|
|
50
|
-
* @param {
|
|
47
|
+
* @param {KeyboardEvent | Event} event - The focus event triggered by the field.
|
|
51
48
|
* @return {void}
|
|
52
49
|
*/
|
|
53
50
|
fieldChanged(event) {
|
|
@@ -99,20 +96,22 @@ export class TttxForm {
|
|
|
99
96
|
* Creates a new HTMLSelectElement with a set of options.
|
|
100
97
|
*
|
|
101
98
|
* @param {string} formKey - The name of the dropdown field, as specified in the form schema.
|
|
102
|
-
* @param {
|
|
99
|
+
* @param {object} formProperties - An object containing additional properties, such as the field type and options properties.
|
|
103
100
|
* @param {'select'} formProperties.type - The type of form field. In this case, it will always be "select".
|
|
104
|
-
* @param {
|
|
105
|
-
* @param {
|
|
106
|
-
* @param {string} formProperties.options.label - The visible value of the option.
|
|
107
|
-
* @param {string} formProperties.options.value - The actual value of the option.
|
|
101
|
+
* @param {object} formProperties.validation - A set of validation rules for the field.
|
|
102
|
+
* @param {Array<{label:string, value:string, placeholder?:boolean}>} formProperties.options - A list of properties to pass to the select options.
|
|
103
|
+
* @param {string} formProperties.options[].label - The visible value of the option.
|
|
104
|
+
* @param {string} formProperties.options[].value - The actual value of the option.
|
|
105
|
+
* @param {boolean} [formProperties.options[].placeholder]
|
|
108
106
|
*/
|
|
109
107
|
createSelect(formKey, formProperties) {
|
|
108
|
+
var _a;
|
|
110
109
|
const select = document.createElement('select');
|
|
111
110
|
select.setAttribute('name', formKey);
|
|
112
111
|
formProperties.options.forEach(optionProperties => {
|
|
113
112
|
this.appendOption(select, optionProperties);
|
|
114
113
|
});
|
|
115
|
-
if (this._data
|
|
114
|
+
if ((_a = this._data) === null || _a === void 0 ? void 0 : _a[formKey])
|
|
116
115
|
select.classList.remove('placeholder');
|
|
117
116
|
return select;
|
|
118
117
|
}
|
|
@@ -120,8 +119,10 @@ export class TttxForm {
|
|
|
120
119
|
* Appends an option to a select element
|
|
121
120
|
*
|
|
122
121
|
* @param {HTMLSelectElement} select - The select elements to attach the option to.
|
|
123
|
-
* @param {
|
|
124
|
-
* @param {
|
|
122
|
+
* @param {Object} optionProperties
|
|
123
|
+
* @param {string} optionProperties.value - The value of the option.
|
|
124
|
+
* @param {string} optionProperties.label - The label which will be displayed on the form for the option.
|
|
125
|
+
* @param {boolean} [optionProperties.placeholder]
|
|
125
126
|
*/
|
|
126
127
|
appendOption(select, optionProperties) {
|
|
127
128
|
const option = document.createElement('option');
|
|
@@ -141,7 +142,7 @@ export class TttxForm {
|
|
|
141
142
|
* and sets its autocomplete and autocapitalization properties to off.
|
|
142
143
|
*
|
|
143
144
|
* @param {string} formKey - The name of the input field, as specified in the form schema.
|
|
144
|
-
* @param {
|
|
145
|
+
* @param {Record<string, any>} formProperties - An object containing additional properties for the input field, such as its type and placeholder value.
|
|
145
146
|
* @param {string} formProperties.type - The type of the input field (e.g., "text", "email", "number", etc.).
|
|
146
147
|
* @param {string} [formProperties.placeholder] - An optional placeholder value to display in the input field.
|
|
147
148
|
* @return {HTMLInputElement} - The new input element.
|
|
@@ -169,12 +170,19 @@ export class TttxForm {
|
|
|
169
170
|
* the input element (e.g., "required" will set the "required" and "data-required" attributes,
|
|
170
171
|
* "pattern" will set the "pattern" and "data-pattern" attributes, etc.).
|
|
171
172
|
*
|
|
172
|
-
* @param {
|
|
173
|
-
* @param {
|
|
174
|
-
* @param {
|
|
175
|
-
* @param {
|
|
176
|
-
* @param {
|
|
177
|
-
* @param {
|
|
173
|
+
* @param {FormField} input - The input element to apply validation attributes to.
|
|
174
|
+
* @param {object} validation - An object containing the validation rules for the input field.
|
|
175
|
+
* @param {object} [validation.required] - An object containing a "message" property to display if the field is required.
|
|
176
|
+
* @param {string} [validation.required.message]
|
|
177
|
+
* @param {object} [validation.pattern] - An object containing a "pattern" property to match against the field value, and a "message" property to display if the pattern doesn't match.
|
|
178
|
+
* @param {string} [validation.pattern.pattern]
|
|
179
|
+
* @param {string} [validation.pattern.message]
|
|
180
|
+
* @param {object} [validation.badInput] - An object containing a "message" property to display if the field value is invalid.
|
|
181
|
+
* @param {string} [validation.badInput.message]
|
|
182
|
+
* @param {object} [validation.minmax] - An object containing "min" and "max" properties to validate the field value against, and a "message" property to display if the value is out of range.
|
|
183
|
+
* @param {string} [validation.minmax.min]
|
|
184
|
+
* @param {string} [validation.minmax.max]
|
|
185
|
+
* @param {string} [validation.minmax.message]
|
|
178
186
|
* @param {string} [validation.maxlength] - The maximum length of the input field.
|
|
179
187
|
* @return {void}
|
|
180
188
|
*/
|
|
@@ -217,6 +225,13 @@ export class TttxForm {
|
|
|
217
225
|
// Return the error bubble element
|
|
218
226
|
return errorBubble;
|
|
219
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
*
|
|
230
|
+
* @param {Record<string, any>} formProperties
|
|
231
|
+
* @param {HTMLInputElement | HTMLSelectElement} input
|
|
232
|
+
* @param {HTMLLabelElement} label
|
|
233
|
+
* @returns {void}
|
|
234
|
+
*/
|
|
220
235
|
appendCheckboxInput(formProperties, input, label) {
|
|
221
236
|
if (formProperties.label) {
|
|
222
237
|
const lineBreak = document.createElement('br');
|
|
@@ -236,15 +251,16 @@ export class TttxForm {
|
|
|
236
251
|
* and appends the input element and error bubble element to it. If the form property has
|
|
237
252
|
* no validation object, it adds an "optional" span element to the label.
|
|
238
253
|
*
|
|
239
|
-
* @param {
|
|
240
|
-
* @param {HTMLInputElement} input - The input element to associate with the label.
|
|
254
|
+
* @param {Record<string, any>} formProperties - An object containing properties for the form field, including its label text and validation rules.
|
|
255
|
+
* @param {HTMLInputElement | HTMLSelectElement} input - The input element to associate with the label.
|
|
241
256
|
* @param {HTMLDivElement} errorBubble - The error bubble element to display error messages in.
|
|
242
257
|
* @return {HTMLLabelElement} - The new label element.
|
|
243
258
|
*/
|
|
244
259
|
createLabel(formProperties, input, errorBubble) {
|
|
260
|
+
const outerContainer = document.createElement('div');
|
|
261
|
+
outerContainer.className = 'outer-container inputBlock';
|
|
245
262
|
// Create a new <label> element with the "inputBlock" class and the specified text
|
|
246
263
|
const label = document.createElement('label');
|
|
247
|
-
label.className = 'inputBlock';
|
|
248
264
|
label.innerText = formProperties.label;
|
|
249
265
|
// If the form property has no validation object, add an "optional" span element to the label
|
|
250
266
|
if (!formProperties.validation) {
|
|
@@ -257,12 +273,14 @@ export class TttxForm {
|
|
|
257
273
|
label.classList.add('readonly');
|
|
258
274
|
}
|
|
259
275
|
if (formProperties.type === 'checkbox') {
|
|
260
|
-
label.className += ' inlineBlock';
|
|
261
276
|
this.appendCheckboxInput(formProperties, input, label);
|
|
262
277
|
}
|
|
263
278
|
else {
|
|
264
|
-
// Append the input element and error bubble element to the
|
|
265
|
-
|
|
279
|
+
// Append the input element and error bubble element to the outerContainer
|
|
280
|
+
outerContainer.appendChild(input);
|
|
281
|
+
}
|
|
282
|
+
if (formProperties.type !== 'checkbox') {
|
|
283
|
+
label.appendChild(outerContainer);
|
|
266
284
|
}
|
|
267
285
|
label.appendChild(errorBubble);
|
|
268
286
|
// Return the label element
|
|
@@ -319,18 +337,18 @@ export class TttxForm {
|
|
|
319
337
|
const properties = this._formSchema.properties;
|
|
320
338
|
const propertyKeys = Object.keys(properties);
|
|
321
339
|
propertyKeys.forEach(formKey => {
|
|
322
|
-
var _a;
|
|
340
|
+
var _a, _b;
|
|
323
341
|
const formInput = formItems.querySelector(`[name=${formKey}]`);
|
|
324
342
|
// Bind events to form input elements
|
|
325
343
|
formInput.oninvalid = this.validityCheckWrapper.bind(this);
|
|
326
344
|
formInput.onblur = this.validityCheckWrapper.bind(this);
|
|
327
345
|
formInput.onkeyup = this.fieldChanged.bind(this);
|
|
328
346
|
formInput.onchange = this.fieldChanged.bind(this);
|
|
329
|
-
if (this._data
|
|
347
|
+
if (((_a = this._data) === null || _a === void 0 ? void 0 : _a[formKey]) !== undefined && this._data[formKey] !== null) {
|
|
330
348
|
formInput.value = this._data[formKey];
|
|
331
349
|
}
|
|
332
350
|
// If explicitly setting input as invalid, set invalid state and error message on render
|
|
333
|
-
if ((
|
|
351
|
+
if ((_b = properties[formKey].form.validation) === null || _b === void 0 ? void 0 : _b.invalid) {
|
|
334
352
|
const errorMessage = properties[formKey].form.validation.invalid.message;
|
|
335
353
|
formInput.setCustomValidity(errorMessage); // Prevents the invalid styling from resetting on blur
|
|
336
354
|
setErrorState(formInput, true, errorMessage);
|
|
@@ -354,8 +372,6 @@ export class TttxForm {
|
|
|
354
372
|
* and emits a "dataSubmitted" event with the form data. The fieldset element is assigned
|
|
355
373
|
* to the "fieldset" instance variable using a ref, so it can be populated with form elements
|
|
356
374
|
* later on.
|
|
357
|
-
*
|
|
358
|
-
* @return {JSX.Element} - The rendered form template as a JSX element.
|
|
359
375
|
*/
|
|
360
376
|
render() {
|
|
361
377
|
return (h(Host, null, h("form", { ref: el => (this.form = el), onSubmit: this.doSubmit.bind(this) }, h("fieldset", { ref: el => (this.fieldset = el) }), h("input", { type: "submit", ref: el => (this.submitButton = el), style: { display: 'none' } }))));
|
|
@@ -375,12 +391,16 @@ export class TttxForm {
|
|
|
375
391
|
static get properties() {
|
|
376
392
|
return {
|
|
377
393
|
"formschema": {
|
|
378
|
-
"type": "
|
|
394
|
+
"type": "string",
|
|
379
395
|
"mutable": true,
|
|
380
396
|
"complexType": {
|
|
381
|
-
"original": "any",
|
|
382
|
-
"resolved": "any",
|
|
383
|
-
"references": {
|
|
397
|
+
"original": "Record<string, any> | string",
|
|
398
|
+
"resolved": "string | { [x: string]: any; }",
|
|
399
|
+
"references": {
|
|
400
|
+
"Record": {
|
|
401
|
+
"location": "global"
|
|
402
|
+
}
|
|
403
|
+
}
|
|
384
404
|
},
|
|
385
405
|
"required": false,
|
|
386
406
|
"optional": false,
|