semantic-forms 5.3.17 → 5.3.19

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.
@@ -786,6 +786,80 @@ form.settingsExample input[type=color] {
786
786
  </escape></code></pre>
787
787
 
788
788
  <p>The tab strip takes its colors from <code>--semanticFormsButtonGradientLight</code> and <code>--semanticFormsButtonGradientDark</code> for the unselected tabs, and <code>--semanticFormsFormSubBgColor</code> for the selected one, so it matches the buttons and fieldsets around it.</p>
789
+
790
+ <h3 id="verticaltabs">Vertical tabs</h3>
791
+
792
+ <p>Add the <code>vertical</code> class alongside <code>tabs</code> to put the tabs in a column down the side of the panels. The up and down arrow keys move between them in place of left and right, and the strip is marked with <code>aria-orientation="vertical"</code>. The strip is as wide as its longest tab up to 40% of the group, past which a tab's name is cut off with an ellipsis. Unselected vertical tabs are a flat fill halfway between <code>--semanticFormsButtonGradientLight</code> and <code>--semanticFormsButtonGradientDark</code> rather than a gradient.</p>
793
+
794
+ <pre><code class='language-html' lang='html'><escape>
795
+ <form class="semanticForms">
796
+ <div class="tabs vertical">
797
+ <fieldset>
798
+ <legend>General</legend>
799
+ <dl>
800
+ <div>
801
+ <dt><label for="vertical-tabs-ex-name">Name</label></dt>
802
+ <dd><input type="text" id="vertical-tabs-ex-name" name="vertical-tabs-ex-name"></dd>
803
+ </div>
804
+ </dl>
805
+ </fieldset>
806
+
807
+ <fieldset>
808
+ <legend>Playback</legend>
809
+ <dl>
810
+ <div>
811
+ <dt><label for="vertical-tabs-ex-crossfade">Crossfade</label></dt>
812
+ <dd><input type="checkbox" switch id="vertical-tabs-ex-crossfade" name="vertical-tabs-ex-crossfade"></dd>
813
+ </div>
814
+ </dl>
815
+ </fieldset>
816
+
817
+ <fieldset>
818
+ <legend>Appearance</legend>
819
+ <dl>
820
+ <div>
821
+ <dt><label for="vertical-tabs-ex-dark">Dark mode</label></dt>
822
+ <dd><input type="checkbox" switch id="vertical-tabs-ex-dark" name="vertical-tabs-ex-dark"></dd>
823
+ </div>
824
+ </dl>
825
+ </fieldset>
826
+ </div>
827
+ </form>
828
+ </escape></code></pre>
829
+
830
+ <form class="semanticForms">
831
+ <div class="tabs vertical">
832
+ <fieldset>
833
+ <legend>General</legend>
834
+ <dl>
835
+ <div>
836
+ <dt><label for="vertical-tabs-ex-name">Name</label></dt>
837
+ <dd><input type="text" id="vertical-tabs-ex-name" name="vertical-tabs-ex-name"></dd>
838
+ </div>
839
+ </dl>
840
+ </fieldset>
841
+
842
+ <fieldset>
843
+ <legend>Playback</legend>
844
+ <dl>
845
+ <div>
846
+ <dt><label for="vertical-tabs-ex-crossfade">Crossfade</label></dt>
847
+ <dd><input type="checkbox" switch id="vertical-tabs-ex-crossfade" name="vertical-tabs-ex-crossfade"></dd>
848
+ </div>
849
+ </dl>
850
+ </fieldset>
851
+
852
+ <fieldset>
853
+ <legend>Appearance</legend>
854
+ <dl>
855
+ <div>
856
+ <dt><label for="vertical-tabs-ex-dark">Dark mode</label></dt>
857
+ <dd><input type="checkbox" switch id="vertical-tabs-ex-dark" name="vertical-tabs-ex-dark"></dd>
858
+ </div>
859
+ </dl>
860
+ </fieldset>
861
+ </div>
862
+ </form>
789
863
  </article>
790
864
  </arg>
791
865
  </include>
@@ -3,6 +3,8 @@
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <!--! tells the browser the page has both modes, so it paints its own canvas, scrollbars and form controls to match before the stylesheets arrive. without it a visitor whose system is dark gets a white page first -->
7
+ <meta name="color-scheme" content="light dark">
6
8
  <meta name="format-detection" content="telephone=no">
7
9
  <title>Semantic Forms documentation</title>
8
10
  <meta name="description" content="Describe your website here">
@@ -61,6 +61,12 @@ body {
61
61
 
62
62
  <p>The pointer turns into a hand over buttons, checkboxes, selects and the like, as it does over a link. A desktop app, whose own controls keep the ordinary arrow, can set <code>--semanticFormsCursor</code> to change it, such as <code>form.semanticForms { --semanticFormsCursor: default }</code>.</p>
63
63
 
64
+ <h3 id="autofill">Autofilled fields</h3>
65
+
66
+ <p>A browser paints a field it filled for the visitor in a color of its own, which no background you set can override. Semantic Forms covers that color so your theme survives, and marks the field itself instead, with a bar down its leading edge drawn in <code>--semanticFormsAutofillColor</code>. That defaults to the system accent color, so it reads as something the browser did rather than part of your form.</p>
67
+
68
+ <p>The bar is drawn as a shadow inside the field, so it takes up no space and nothing on the page moves when a field is filled.</p>
69
+
64
70
  <h3 id="widthvariables">Controlling how wide fields get</h3>
65
71
 
66
72
  <p>Fields are laid out in a grid whose columns grow to fill the available width. Three variables control the sizing:</p>
@@ -36,6 +36,16 @@
36
36
 
37
37
  <p>If you make changes to the DOM after Semantic Forms is activated and want to activate any additional <code>semanticForms</code> forms you insert, you can re-scan for new forms by calling <code>semanticForms.reinitialize()</code> again. If you only want to reinitialize one form instead of all of them, call <code>semanticForms.reinitialize(formElement)</code>.</p>
38
38
 
39
+ <h3 id="sass">Including the styles from Sass</h3>
40
+
41
+ <p>If your own stylesheets are written in <a href="https://sass-lang.com">Sass</a>, you can pull Semantic Forms into them from its Sass source rather than including the compiled CSS file separately. With Sass's Node.js package importer enabled, which is <code>importers: [new sass.NodePackageImporter()]</code> in the JavaScript API or <code>--pkg-importer=node</code> on the command line:</p>
42
+
43
+ <pre><code class='language-scss'>@use "pkg:semantic-forms";</code></pre>
44
+
45
+ <p>Or, with your <code>node_modules</code> folder in Sass's load paths:</p>
46
+
47
+ <pre><code class='language-scss'>@use "semantic-forms/semanticForms";</code></pre>
48
+
39
49
  <h3 id="setinvalid">Marking a field invalid from JavaScript</h3>
40
50
 
41
51
  <p>A check the browser can't do itself, such as whether a name is already taken, can mark a field invalid the same way the browser's own validation does, with a message saying why:</p>
package/package.json CHANGED
@@ -8,15 +8,17 @@
8
8
  "url": "https://github.com/rooseveltframework/semantic-forms/graphs/contributors"
9
9
  }
10
10
  ],
11
- "version": "5.3.17",
11
+ "version": "5.3.19",
12
12
  "files": [
13
13
  "dist",
14
14
  "semanticForms.scss",
15
+ "styles",
15
16
  "docs/statics",
16
17
  "*.md"
17
18
  ],
18
19
  "exports": {
19
20
  ".": {
21
+ "sass": "./semanticForms.scss",
20
22
  "import": "./dist/semantic-forms.mjs",
21
23
  "require": "./dist/semantic-forms.cjs"
22
24
  },
@@ -33,14 +35,14 @@
33
35
  "readmeFilename": "README.md",
34
36
  "devDependencies": {
35
37
  "@jsdevtools/coverage-istanbul-loader": "3.0.5",
36
- "@playwright/test": "1.64.1",
38
+ "@playwright/test": "1.65.1",
37
39
  "eslint-plugin-html": "8.2.1",
38
40
  "nyc": "18.0.0",
39
- "sass": "1.106.1",
41
+ "sass": "1.108.2",
40
42
  "standard": "17.1.2",
41
43
  "terser-webpack-plugin": "5.6.1",
42
- "webpack": "5.112.2",
43
- "webpack-cli": "7.2.3"
44
+ "webpack": "5.113.0",
45
+ "webpack-cli": "7.3.1"
44
46
  },
45
47
  "scripts": {
46
48
  "prepare": "npm run build",
@@ -126,6 +126,25 @@
126
126
  margin-bottom: 15px;
127
127
  }
128
128
  }
129
+
130
+ // opening and closing the panel changes its height, and the marker beside the summary turns: both are motion, and both are dropped for a visitor who asked for less of it. the fade is a colour change rather than movement, so it is left running
131
+ @media (prefers-reduced-motion: reduce) {
132
+ @supports (interpolate-size: allow-keywords) {
133
+ transition: opacity 250ms ease-in, visibility 0ms ease-in 250ms;
134
+
135
+ &::details-content {
136
+ transition: none;
137
+ }
138
+ }
139
+
140
+ summary {
141
+ transition: none;
142
+
143
+ &::before {
144
+ transition: none;
145
+ }
146
+ }
147
+ }
129
148
  }
130
149
 
131
150
  details details,
@@ -0,0 +1,316 @@
1
+ @use 'layoutScope.scss' as *;
2
+
3
+ // the column classes size and place fields in the grid layout, so like the grid itself they do not apply inside a customLayout element: see layoutScope.scss
4
+ .semanticForms {
5
+ div#{$notCustomLayout} {
6
+ &[class*=colspan-] {
7
+ max-width: 100% !important;
8
+ }
9
+
10
+ &.colspan-full {
11
+ grid-column: 1 / -1;
12
+ }
13
+
14
+ &.colspan-5 {
15
+ grid-column-end: span 5;
16
+ }
17
+
18
+ &.colspan-4 {
19
+ grid-column-end: span 4;
20
+ }
21
+
22
+ &.colspan-3 {
23
+ grid-column-end: span 3;
24
+ }
25
+
26
+ &.colspan-2 {
27
+ grid-column-end: span 2;
28
+ }
29
+
30
+ &.colspan-1 {
31
+ grid-column-end: span 1;
32
+ }
33
+
34
+ // col-# places a field in a particular column. the colspan rules above put their span on grid-column-end rather than the shorthand, so setting the start here does not undo it: colspan decides how wide the field is and col decides which column it starts in
35
+ &.col-5 {
36
+ grid-column-start: 5;
37
+ }
38
+
39
+ &.col-4 {
40
+ grid-column-start: 4;
41
+ }
42
+
43
+ &.col-3 {
44
+ grid-column-start: 3;
45
+ }
46
+
47
+ &.col-2 {
48
+ grid-column-start: 2;
49
+ }
50
+
51
+ &.col-1 {
52
+ grid-column-start: 1;
53
+ }
54
+ }
55
+
56
+ fieldset[class*=colspan-] dl#{$notCustomLayout},
57
+ dl[class*='colspan-']#{$notCustomLayout} {
58
+ div {
59
+ max-width: 100% !important;
60
+ }
61
+ }
62
+
63
+ fieldset.colspan-full dl#{$notCustomLayout},
64
+ dl.colspan-full#{$notCustomLayout} {
65
+ grid-template-columns: repeat(auto-fit, minmax(var(--semanticFormsInputMinWidth), var(--semanticFormsInputColumnMaxWidth)));
66
+ }
67
+
68
+ fieldset.colspan-5 dl#{$notCustomLayout},
69
+ dl.colspan-5#{$notCustomLayout} {
70
+ grid-template-columns: repeat(5, minmax(var(--semanticFormsInputMinWidth), var(--semanticFormsInputColumnMaxWidth)));
71
+ }
72
+
73
+ fieldset.colspan-4 dl#{$notCustomLayout},
74
+ dl.colspan-4#{$notCustomLayout} {
75
+ grid-template-columns: repeat(4, minmax(var(--semanticFormsInputMinWidth), var(--semanticFormsInputColumnMaxWidth)));
76
+ }
77
+
78
+ fieldset.colspan-3 dl#{$notCustomLayout},
79
+ dl.colspan-3#{$notCustomLayout} {
80
+ grid-template-columns: repeat(3, minmax(var(--semanticFormsInputMinWidth), var(--semanticFormsInputColumnMaxWidth)));
81
+ }
82
+
83
+ fieldset.colspan-2 dl#{$notCustomLayout},
84
+ dl.colspan-2#{$notCustomLayout} {
85
+ grid-template-columns: repeat(2, minmax(var(--semanticFormsInputMinWidth), var(--semanticFormsInputColumnMaxWidth)));
86
+ }
87
+
88
+ fieldset.colspan-1 dl#{$notCustomLayout},
89
+ dl.colspan-1#{$notCustomLayout} {
90
+ grid-template-columns: repeat(1, minmax(var(--semanticFormsInputMinWidth), var(--semanticFormsInputColumnMaxWidth)));
91
+ }
92
+
93
+ fieldset.colspan-1 dl#{$notCustomLayout},
94
+ dl.colspan-1#{$notCustomLayout} {
95
+ dt:nth-of-type(n + 1),
96
+ dd:nth-of-type(n + 1) {
97
+ grid-column: 1;
98
+ }
99
+ }
100
+
101
+ fieldset.colspan-2 dl#{$notCustomLayout},
102
+ dl.colspan-2#{$notCustomLayout} {
103
+ dt:nth-of-type(2n + 1),
104
+ dd:nth-of-type(2n + 1) {
105
+ grid-column: 1;
106
+ }
107
+
108
+ dt:nth-of-type(2n + 2),
109
+ dd:nth-of-type(2n + 2) {
110
+ grid-column: 2;
111
+ }
112
+ }
113
+
114
+ fieldset.colspan-3 dl#{$notCustomLayout},
115
+ dl.colspan-3#{$notCustomLayout} {
116
+ dt:nth-of-type(3n + 1),
117
+ dd:nth-of-type(3n + 1) {
118
+ grid-column: 1;
119
+ }
120
+
121
+ dt:nth-of-type(3n + 2),
122
+ dd:nth-of-type(3n + 2) {
123
+ grid-column: 2;
124
+ }
125
+
126
+ dt:nth-of-type(3n + 3),
127
+ dd:nth-of-type(3n + 3) {
128
+ grid-column: 3;
129
+ }
130
+ }
131
+
132
+ fieldset.colspan-4 dl#{$notCustomLayout},
133
+ dl.colspan-4#{$notCustomLayout} {
134
+ dt:nth-of-type(4n + 1),
135
+ dd:nth-of-type(4n + 1) {
136
+ grid-column: 1;
137
+ }
138
+
139
+ dt:nth-of-type(4n + 2),
140
+ dd:nth-of-type(4n + 2) {
141
+ grid-column: 2;
142
+ }
143
+
144
+ dt:nth-of-type(4n + 3),
145
+ dd:nth-of-type(4n + 3) {
146
+ grid-column: 3;
147
+ }
148
+
149
+ dt:nth-of-type(4n + 4),
150
+ dd:nth-of-type(4n + 4) {
151
+ grid-column: 4;
152
+ }
153
+ }
154
+
155
+ fieldset.colspan-5 dl#{$notCustomLayout},
156
+ dl.colspan-5#{$notCustomLayout} {
157
+ dt:nth-of-type(5n + 1),
158
+ dd:nth-of-type(5n + 1) {
159
+ grid-column: 1;
160
+ }
161
+
162
+ dt:nth-of-type(5n + 2),
163
+ dd:nth-of-type(5n + 2) {
164
+ grid-column: 2;
165
+ }
166
+
167
+ dt:nth-of-type(5n + 3),
168
+ dd:nth-of-type(5n + 3) {
169
+ grid-column: 3;
170
+ }
171
+
172
+ dt:nth-of-type(5n + 4),
173
+ dd:nth-of-type(5n + 4) {
174
+ grid-column: 4;
175
+ }
176
+
177
+ dt:nth-of-type(5n + 5),
178
+ dd:nth-of-type(5n + 5) {
179
+ grid-column: 5;
180
+ }
181
+ }
182
+ }
183
+
184
+ // scoped to the library's own forms: a bare `fieldset` here would give every fieldset on the host page a container context, and the queries below would then lay out its <dl> children too
185
+ //
186
+ // only a form or fieldset holding a grid of fields is made a container, since it's the grid the queries lay out. a container is measured as though it were empty, so one sized by its contents, such as a form holding only a button, would otherwise shrink to nothing
187
+ form.semanticForms:has(dl#{$notCustomLayout}),
188
+ form.semanticForms fieldset:has(dl#{$notCustomLayout}) {
189
+ container: semanticForm / inline-size;
190
+
191
+ // max 7 columns
192
+ @container semanticForm (width >= 1810px) {
193
+ & fieldset dl#{$notCustomLayout},
194
+ & dl#{$notCustomLayout} {
195
+ grid-template-columns: repeat(7, minmax(var(--semanticFormsInputMinWidth), var(--semanticFormsInputColumnMaxWidth)));
196
+ }
197
+ }
198
+
199
+ // max 6 columns
200
+ @container semanticForm (width >= 1550px) and (width < 1810px) {
201
+ & fieldset dl#{$notCustomLayout},
202
+ & dl#{$notCustomLayout} {
203
+ grid-template-columns: repeat(6, minmax(var(--semanticFormsInputMinWidth), var(--semanticFormsInputColumnMaxWidth)));
204
+ }
205
+ }
206
+
207
+ // max 5 columns
208
+ @container semanticForm (width >= 1290px) and (width < 1550px) {
209
+ & fieldset dl#{$notCustomLayout},
210
+ & dl#{$notCustomLayout} {
211
+ grid-template-columns: repeat(5, minmax(var(--semanticFormsInputMinWidth), var(--semanticFormsInputColumnMaxWidth)));
212
+ }
213
+ }
214
+
215
+ // max 4 columns
216
+ @container semanticForm (width >= 1030px) and (width < 1290px) {
217
+ & fieldset dl#{$notCustomLayout},
218
+ & fieldset.colspan-5 dl#{$notCustomLayout},
219
+ & dl#{$notCustomLayout},
220
+ & dl.colspan-5#{$notCustomLayout} {
221
+ grid-template-columns: repeat(4, minmax(var(--semanticFormsInputMinWidth), var(--semanticFormsInputColumnMaxWidth)));
222
+
223
+ div.colspan-5 {
224
+ grid-column-end: span 4;
225
+ }
226
+
227
+ div.col-5 {
228
+ grid-column-start: auto;
229
+ }
230
+ }
231
+ }
232
+
233
+ // max 3 columns
234
+ @container semanticForm (width >= 850px) and (width < 1030px) {
235
+ & fieldset dl#{$notCustomLayout},
236
+ & fieldset.colspan-4 dl#{$notCustomLayout},
237
+ & fieldset.colspan-5 dl#{$notCustomLayout},
238
+ & dl#{$notCustomLayout},
239
+ & dl.colspan-4#{$notCustomLayout},
240
+ & dl.colspan-5#{$notCustomLayout} {
241
+ grid-template-columns: repeat(3, minmax(var(--semanticFormsInputMinWidth), var(--semanticFormsInputColumnMaxWidth)));
242
+
243
+ div.colspan-4,
244
+ div.colspan-5 {
245
+ grid-column-end: span 3;
246
+ }
247
+
248
+ div.col-4,
249
+ div.col-5 {
250
+ grid-column-start: auto;
251
+ }
252
+ }
253
+ }
254
+
255
+ // max 2 columns
256
+ @container semanticForm (width >= 510px) and (width < 850px) {
257
+ & fieldset dl#{$notCustomLayout},
258
+ & fieldset.colspan-3 dl#{$notCustomLayout},
259
+ & fieldset.colspan-4 dl#{$notCustomLayout},
260
+ & fieldset.colspan-5 dl#{$notCustomLayout},
261
+ & dl#{$notCustomLayout},
262
+ & dl.colspan-3#{$notCustomLayout},
263
+ & dl.colspan-4#{$notCustomLayout},
264
+ & dl.colspan-5#{$notCustomLayout} {
265
+ grid-template-columns: repeat(2, minmax(var(--semanticFormsInputMinWidth), var(--semanticFormsInputColumnMaxWidth)));
266
+
267
+ div.colspan-3,
268
+ div.colspan-4,
269
+ div.colspan-5 {
270
+ grid-column-end: span 2;
271
+ }
272
+
273
+ div.col-3,
274
+ div.col-4,
275
+ div.col-5 {
276
+ grid-column-start: auto;
277
+ }
278
+ }
279
+ }
280
+
281
+ // max 1 column
282
+ @container semanticForm (width < 510px) {
283
+ & fieldset dl#{$notCustomLayout},
284
+ & fieldset.colspan-2 dl#{$notCustomLayout},
285
+ & fieldset.colspan-3 dl#{$notCustomLayout},
286
+ & fieldset.colspan-4 dl#{$notCustomLayout},
287
+ & fieldset.colspan-5 dl#{$notCustomLayout},
288
+ & dl#{$notCustomLayout},
289
+ & dl.colspan-2#{$notCustomLayout},
290
+ & dl.colspan-3#{$notCustomLayout},
291
+ & dl.colspan-4#{$notCustomLayout},
292
+ & dl.colspan-5#{$notCustomLayout} {
293
+ grid-template-columns: 1fr;
294
+
295
+ div.colspan-2,
296
+ div.colspan-3,
297
+ div.colspan-4,
298
+ div.colspan-5 {
299
+ grid-column-end: span 1;
300
+ }
301
+
302
+ div.col-2,
303
+ div.col-3,
304
+ div.col-4,
305
+ div.col-5 {
306
+ grid-column-start: auto;
307
+ }
308
+ }
309
+ }
310
+ }
311
+
312
+ // a dialog or popover is sized by its contents, so a form in one is not made a container, which would shrink the dialog to nothing. its grid of fields lays itself out by the width it's given, as the base grid does
313
+ :is(dialog, [popover]) form.semanticForms:has(dl#{$notCustomLayout}),
314
+ :is(dialog, [popover]) form.semanticForms fieldset:has(dl#{$notCustomLayout}) {
315
+ container-type: normal;
316
+ }