semantic-forms 4.0.0 → 4.0.2
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/README.md +14 -0
- package/package.json +3 -3
- package/semanticForms.css +38 -19
- package/semanticForms.js +1 -0
- package/semanticForms.scss +31 -12
package/README.md
CHANGED
|
@@ -300,6 +300,20 @@ Inputs with the `required` attribute will result in a visual indicator (*) being
|
|
|
300
300
|
</form>
|
|
301
301
|
```
|
|
302
302
|
|
|
303
|
+
You can set a paragraph of text below a field to only appear when a field is invalid with the `data-invalid-text` attribute:
|
|
304
|
+
|
|
305
|
+
```html
|
|
306
|
+
<form class="semanticForms">
|
|
307
|
+
<dl>
|
|
308
|
+
<dt><label for="password">Password label</label><dt>
|
|
309
|
+
<dd>
|
|
310
|
+
<input type="password" name="password" id="password" minlength="8">
|
|
311
|
+
<p data-invalid-text>Password must be at least 8 characters long.</p>
|
|
312
|
+
</dd>
|
|
313
|
+
</dl>
|
|
314
|
+
</form>
|
|
315
|
+
```
|
|
316
|
+
|
|
303
317
|
You can adjust the tooltip text of the asterisk with the `data-asterisk-text` attribute:
|
|
304
318
|
|
|
305
319
|
```html
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"url": "https://github.com/rooseveltframework/semantic-forms/graphs/contributors"
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
|
-
"version": "4.0.
|
|
11
|
+
"version": "4.0.2",
|
|
12
12
|
"files": [
|
|
13
13
|
"semanticForms.css",
|
|
14
14
|
"semanticForms.js",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"eslint": "9.10.0",
|
|
23
23
|
"eslint-plugin-html": "8.1.1",
|
|
24
|
-
"nodemon": "
|
|
25
|
-
"sass": "1.
|
|
24
|
+
"nodemon": "3.1.6",
|
|
25
|
+
"sass": "1.79.1",
|
|
26
26
|
"serve": "14.2.3",
|
|
27
27
|
"standard": "17.1.2"
|
|
28
28
|
},
|
package/semanticForms.css
CHANGED
|
@@ -93,13 +93,20 @@ form.semanticForms dl dd {
|
|
|
93
93
|
position: relative;
|
|
94
94
|
}
|
|
95
95
|
form.semanticForms dl dd:not(.checkboxes, .radios) {
|
|
96
|
-
display: flex;
|
|
97
96
|
gap: 10px;
|
|
98
97
|
max-width: 100%;
|
|
99
98
|
}
|
|
100
99
|
form.semanticForms dl dd:not(.checkboxes, .radios):not(.singleCheckbox) {
|
|
100
|
+
display: flex;
|
|
101
101
|
flex-direction: column;
|
|
102
102
|
}
|
|
103
|
+
form.semanticForms dl dd:not(.checkboxes, .radios).singleCheckbox {
|
|
104
|
+
display: grid;
|
|
105
|
+
grid-template-columns: min-content 1fr;
|
|
106
|
+
}
|
|
107
|
+
form.semanticForms dl dd:not(.checkboxes, .radios).singleCheckbox > :not(input[type=checkbox], label) {
|
|
108
|
+
grid-column: 1/-1;
|
|
109
|
+
}
|
|
103
110
|
form.semanticForms dl dd.checkboxes ul, form.semanticForms dl dd.radios ul {
|
|
104
111
|
display: flex;
|
|
105
112
|
flex-direction: column;
|
|
@@ -165,14 +172,14 @@ form.semanticForms textarea[disabled] {
|
|
|
165
172
|
cursor: not-allowed;
|
|
166
173
|
opacity: 0.5;
|
|
167
174
|
}
|
|
168
|
-
form.semanticForms input:not([type=submit], [type=reset], [type=image], [type=checkbox], [type=radio])[disabled]
|
|
169
|
-
form.semanticForms select[disabled]
|
|
170
|
-
form.semanticForms textarea[disabled]
|
|
175
|
+
form.semanticForms input:not([type=submit], [type=reset], [type=image], [type=checkbox], [type=radio])[disabled] ~ label:first-of-type,
|
|
176
|
+
form.semanticForms select[disabled] ~ label:first-of-type,
|
|
177
|
+
form.semanticForms textarea[disabled] ~ label:first-of-type {
|
|
171
178
|
opacity: 0.5;
|
|
172
179
|
}
|
|
173
|
-
form.semanticForms input:not([type=submit], [type=reset], [type=image], [type=checkbox], [type=radio])[disabled]
|
|
174
|
-
form.semanticForms select[disabled]
|
|
175
|
-
form.semanticForms textarea[disabled]
|
|
180
|
+
form.semanticForms input:not([type=submit], [type=reset], [type=image], [type=checkbox], [type=radio])[disabled] ~ label + button,
|
|
181
|
+
form.semanticForms select[disabled] ~ label + button,
|
|
182
|
+
form.semanticForms textarea[disabled] ~ label + button {
|
|
176
183
|
display: none;
|
|
177
184
|
}
|
|
178
185
|
form.semanticForms input:not([type=submit], [type=reset], [type=image]):focus,
|
|
@@ -196,8 +203,8 @@ form.semanticForms input[type=radio] {
|
|
|
196
203
|
height: 1.4em;
|
|
197
204
|
cursor: pointer;
|
|
198
205
|
}
|
|
199
|
-
form.semanticForms input[type=checkbox]
|
|
200
|
-
form.semanticForms input[type=radio]
|
|
206
|
+
form.semanticForms input[type=checkbox] ~ label:first-of-type,
|
|
207
|
+
form.semanticForms input[type=radio] ~ label:first-of-type {
|
|
201
208
|
color: var(--formTextColor) !important;
|
|
202
209
|
}
|
|
203
210
|
form.semanticForms input[type=file] {
|
|
@@ -239,12 +246,12 @@ form.semanticForms button.clear {
|
|
|
239
246
|
align-items: center;
|
|
240
247
|
justify-content: center;
|
|
241
248
|
}
|
|
242
|
-
form.semanticForms textarea
|
|
249
|
+
form.semanticForms textarea ~ .clear {
|
|
243
250
|
bottom: auto;
|
|
244
251
|
}
|
|
245
|
-
form.semanticForms input:placeholder-shown
|
|
246
|
-
form.semanticForms textarea:placeholder-shown
|
|
247
|
-
form.semanticForms input[type=file]
|
|
252
|
+
form.semanticForms input:placeholder-shown ~ .clear,
|
|
253
|
+
form.semanticForms textarea:placeholder-shown ~ .clear,
|
|
254
|
+
form.semanticForms input[type=file] ~ .clear {
|
|
248
255
|
display: none;
|
|
249
256
|
}
|
|
250
257
|
form.semanticForms input[type=submit],
|
|
@@ -288,15 +295,15 @@ form.semanticForms .floatLabelForm div {
|
|
|
288
295
|
position: relative;
|
|
289
296
|
width: 100%;
|
|
290
297
|
}
|
|
291
|
-
form.semanticForms .floatLabelForm div dd:not(.singleCheckbox, .checkboxes, .radios) input:not([type=submit], [type=reset], [type=image]):focus:not([type=checkbox], [type=radio])
|
|
292
|
-
form.semanticForms .floatLabelForm div dd:not(.singleCheckbox, .checkboxes, .radios) select:focus:not([type=checkbox], [type=radio])
|
|
293
|
-
form.semanticForms .floatLabelForm div dd:not(.singleCheckbox, .checkboxes, .radios) select:not(:placeholder-shown, [type=checkbox], [type=radio])
|
|
294
|
-
form.semanticForms .floatLabelForm div dd:not(.singleCheckbox, .checkboxes, .radios) textarea:focus:not([type=checkbox], [type=radio])
|
|
295
|
-
form.semanticForms .floatLabelForm div dd:not(.singleCheckbox, .checkboxes, .radios) textarea:not(:placeholder-shown, [type=checkbox], [type=radio])
|
|
298
|
+
form.semanticForms .floatLabelForm div dd:not(.singleCheckbox, .checkboxes, .radios) input:not([type=submit], [type=reset], [type=image]):focus:not([type=checkbox], [type=radio]) ~ label:first-of-type, form.semanticForms .floatLabelForm div dd:not(.singleCheckbox, .checkboxes, .radios) input:not([type=submit], [type=reset], [type=image]):not(:placeholder-shown, [type=checkbox], [type=radio]) ~ label:first-of-type,
|
|
299
|
+
form.semanticForms .floatLabelForm div dd:not(.singleCheckbox, .checkboxes, .radios) select:focus:not([type=checkbox], [type=radio]) ~ label:first-of-type,
|
|
300
|
+
form.semanticForms .floatLabelForm div dd:not(.singleCheckbox, .checkboxes, .radios) select:not(:placeholder-shown, [type=checkbox], [type=radio]) ~ label:first-of-type,
|
|
301
|
+
form.semanticForms .floatLabelForm div dd:not(.singleCheckbox, .checkboxes, .radios) textarea:focus:not([type=checkbox], [type=radio]) ~ label:first-of-type,
|
|
302
|
+
form.semanticForms .floatLabelForm div dd:not(.singleCheckbox, .checkboxes, .radios) textarea:not(:placeholder-shown, [type=checkbox], [type=radio]) ~ label:first-of-type {
|
|
296
303
|
color: var(--formTextColor) !important;
|
|
297
304
|
transform: translateY(-150%) scale(0.7);
|
|
298
305
|
}
|
|
299
|
-
form.semanticForms .floatLabelForm div dd:not(.singleCheckbox, .checkboxes, .radios) select
|
|
306
|
+
form.semanticForms .floatLabelForm div dd:not(.singleCheckbox, .checkboxes, .radios) select ~ label:first-of-type {
|
|
300
307
|
color: var(--formTextColor) !important;
|
|
301
308
|
}
|
|
302
309
|
form.semanticForms .floatLabelForm div dd:not(.singleCheckbox, .checkboxes, .radios) label:first-of-type {
|
|
@@ -496,6 +503,10 @@ form.semanticForms.lowFlow fieldset.colspan-1 dl, form.semanticForms.lowFlow dl.
|
|
|
496
503
|
form.semanticForms.lowFlow fieldset.colspan-1 dl dt:nth-of-type(n + 1), form.semanticForms.lowFlow fieldset.colspan-1 dl dd:nth-of-type(n + 1), form.semanticForms.lowFlow dl.colspan-1 dt:nth-of-type(n + 1), form.semanticForms.lowFlow dl.colspan-1 dd:nth-of-type(n + 1) {
|
|
497
504
|
grid-column: 1;
|
|
498
505
|
}
|
|
506
|
+
form.semanticForms [data-invalid-text] {
|
|
507
|
+
display: none;
|
|
508
|
+
color: var(--invalid);
|
|
509
|
+
}
|
|
499
510
|
form.semanticForms input:not([type=submit], [type=reset], [type=image]).invalid, form.semanticForms input:not([type=submit], [type=reset], [type=image]):user-invalid,
|
|
500
511
|
form.semanticForms select.invalid,
|
|
501
512
|
form.semanticForms select:user-invalid,
|
|
@@ -510,6 +521,14 @@ form.semanticForms textarea.invalid ~ label:nth-of-type(2),
|
|
|
510
521
|
form.semanticForms textarea:user-invalid ~ label:nth-of-type(2) {
|
|
511
522
|
color: var(--invalid) !important;
|
|
512
523
|
}
|
|
524
|
+
form.semanticForms input:not([type=submit], [type=reset], [type=image]).invalid ~ [data-invalid-text], form.semanticForms input:not([type=submit], [type=reset], [type=image]):user-invalid ~ [data-invalid-text],
|
|
525
|
+
form.semanticForms select.invalid ~ [data-invalid-text],
|
|
526
|
+
form.semanticForms select:user-invalid ~ [data-invalid-text],
|
|
527
|
+
form.semanticForms textarea.invalid ~ [data-invalid-text],
|
|
528
|
+
form.semanticForms textarea:user-invalid ~ [data-invalid-text] {
|
|
529
|
+
font-size: small;
|
|
530
|
+
display: flex;
|
|
531
|
+
}
|
|
513
532
|
form.semanticForms input:-webkit-autofill,
|
|
514
533
|
form.semanticForms input:-webkit-autofill:hover,
|
|
515
534
|
form.semanticForms input:-webkit-autofill:focus,
|
package/semanticForms.js
CHANGED
package/semanticForms.scss
CHANGED
|
@@ -92,7 +92,6 @@ form.semanticForms {
|
|
|
92
92
|
background: var(--nestedInput);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
|
|
96
95
|
}
|
|
97
96
|
|
|
98
97
|
dl {
|
|
@@ -105,14 +104,23 @@ form.semanticForms {
|
|
|
105
104
|
position: relative;
|
|
106
105
|
|
|
107
106
|
&:not(.checkboxes, .radios) {
|
|
108
|
-
display: flex;
|
|
109
107
|
gap: 10px;
|
|
110
108
|
max-width: 100%;
|
|
111
109
|
|
|
112
110
|
// places all items within the <dd> horizontally
|
|
113
111
|
&:not(.singleCheckbox) {
|
|
112
|
+
display: flex;
|
|
114
113
|
flex-direction: column;
|
|
115
114
|
}
|
|
115
|
+
|
|
116
|
+
&.singleCheckbox {
|
|
117
|
+
display: grid;
|
|
118
|
+
grid-template-columns: min-content 1fr;
|
|
119
|
+
|
|
120
|
+
& > :not(input[type='checkbox'], label) {
|
|
121
|
+
grid-column: 1 / -1;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
116
124
|
}
|
|
117
125
|
|
|
118
126
|
&.checkboxes ul, &.radios ul {
|
|
@@ -195,11 +203,11 @@ form.semanticForms {
|
|
|
195
203
|
cursor: not-allowed;
|
|
196
204
|
opacity: 0.5;
|
|
197
205
|
|
|
198
|
-
|
|
206
|
+
~ label:first-of-type {
|
|
199
207
|
opacity: 0.5;
|
|
200
208
|
}
|
|
201
209
|
|
|
202
|
-
|
|
210
|
+
~ label + button {
|
|
203
211
|
display: none;
|
|
204
212
|
}
|
|
205
213
|
}
|
|
@@ -235,7 +243,7 @@ form.semanticForms {
|
|
|
235
243
|
height: 1.4em;
|
|
236
244
|
cursor: pointer;
|
|
237
245
|
|
|
238
|
-
&
|
|
246
|
+
& ~ label:first-of-type {
|
|
239
247
|
color: var(--formTextColor) !important;
|
|
240
248
|
}
|
|
241
249
|
}
|
|
@@ -288,14 +296,14 @@ form.semanticForms {
|
|
|
288
296
|
}
|
|
289
297
|
|
|
290
298
|
// custom styling of clear button on textarea
|
|
291
|
-
textarea
|
|
299
|
+
textarea ~ .clear {
|
|
292
300
|
bottom: auto;
|
|
293
301
|
}
|
|
294
302
|
|
|
295
303
|
// hide clear button while placeholder text is visible
|
|
296
|
-
input:placeholder-shown
|
|
297
|
-
textarea:placeholder-shown
|
|
298
|
-
input[type=file]
|
|
304
|
+
input:placeholder-shown ~ .clear,
|
|
305
|
+
textarea:placeholder-shown ~ .clear,
|
|
306
|
+
input[type=file] ~ .clear {
|
|
299
307
|
display: none;
|
|
300
308
|
}
|
|
301
309
|
|
|
@@ -349,14 +357,14 @@ form.semanticForms {
|
|
|
349
357
|
input:not([type='submit'], [type='reset'], [type='image']),
|
|
350
358
|
select,
|
|
351
359
|
textarea {
|
|
352
|
-
&:focus:not([type=checkbox], [type=radio])
|
|
353
|
-
&:not(:placeholder-shown, [type=checkbox], [type=radio])
|
|
360
|
+
&:focus:not([type=checkbox], [type=radio]) ~ label:first-of-type,
|
|
361
|
+
&:not(:placeholder-shown, [type=checkbox], [type=radio]) ~ label:first-of-type {
|
|
354
362
|
color: var(--formTextColor) !important;
|
|
355
363
|
transform: translateY(-150%) scale(0.7);
|
|
356
364
|
}
|
|
357
365
|
}
|
|
358
366
|
|
|
359
|
-
select
|
|
367
|
+
select ~ label:first-of-type {
|
|
360
368
|
// force label to be correct color
|
|
361
369
|
color: var(--formTextColor) !important;
|
|
362
370
|
}
|
|
@@ -651,6 +659,11 @@ form.semanticForms {
|
|
|
651
659
|
// #endregion
|
|
652
660
|
|
|
653
661
|
// #region invalid styling
|
|
662
|
+
[data-invalid-text] {
|
|
663
|
+
display: none;
|
|
664
|
+
color: var(--invalid);
|
|
665
|
+
}
|
|
666
|
+
|
|
654
667
|
input:not([type='submit'], [type='reset'], [type='image']),
|
|
655
668
|
select,
|
|
656
669
|
textarea {
|
|
@@ -661,7 +674,13 @@ form.semanticForms {
|
|
|
661
674
|
~ label:nth-of-type(2) {
|
|
662
675
|
color: var(--invalid) !important;
|
|
663
676
|
}
|
|
677
|
+
|
|
678
|
+
~ [data-invalid-text] {
|
|
679
|
+
font-size: small;
|
|
680
|
+
display: flex;
|
|
681
|
+
}
|
|
664
682
|
}
|
|
683
|
+
|
|
665
684
|
}
|
|
666
685
|
// #endregion
|
|
667
686
|
|