semantic-forms 5.1.2 → 5.1.3
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/CHANGELOG.md +6 -1
- package/dist/semantic-forms.cjs +5 -3
- package/dist/semantic-forms.cjs.map +1 -1
- package/dist/semantic-forms.css +1 -0
- package/dist/semantic-forms.css.map +1 -1
- package/dist/semantic-forms.js +5 -3
- package/dist/semantic-forms.js.map +1 -1
- package/dist/semantic-forms.min.js +1 -1
- package/dist/semantic-forms.min.js.map +1 -1
- package/dist/semantic-forms.min.mjs +1 -1
- package/dist/semantic-forms.min.mjs.map +1 -1
- package/dist/semantic-forms.mjs +5 -3
- package/dist/semantic-forms.mjs.map +1 -1
- package/docs/statics/pages/fullDemo.html +11 -8
- package/docs/statics/pages/layouts/main.html +4 -4
- package/docs/statics/pages/usage.html +20 -0
- package/package.json +2 -2
- package/semanticForms.js +18 -8
- package/semanticForms.scss +10 -9
|
@@ -503,6 +503,26 @@
|
|
|
503
503
|
</dl>
|
|
504
504
|
</form>
|
|
505
505
|
|
|
506
|
+
<h4 id="rangeInputsThatDisplayValues">Range inputs that display values</h4>
|
|
507
|
+
|
|
508
|
+
<p>Add a class of <code>displayValue</code> to any <code><!--#<input type="range">--></code> element to make its value display on the label:</p>
|
|
509
|
+
|
|
510
|
+
<pre><code class='language-html' lang='html'><escape>
|
|
511
|
+
<form class="semanticForms">
|
|
512
|
+
<dl>
|
|
513
|
+
<dt><label for="rangeValue">Range value</label></dt>
|
|
514
|
+
<dd><input id="rangeValue" name="rangeValue" type="range" class="displayValue"></dd>
|
|
515
|
+
</dl>
|
|
516
|
+
</form>
|
|
517
|
+
</escape></code></pre>
|
|
518
|
+
|
|
519
|
+
<form class="semanticForms">
|
|
520
|
+
<dl>
|
|
521
|
+
<dt><label for="rangeValue">Range value</label></dt>
|
|
522
|
+
<dd><input id="rangeValue" name="rangeValue" type="range" class="displayValue"></dd>
|
|
523
|
+
</dl>
|
|
524
|
+
</form>
|
|
525
|
+
|
|
506
526
|
<h3 id="lightanddarkmode">Light mode and dark mode</h3>
|
|
507
527
|
|
|
508
528
|
<p>Light mode and dark mode will be detected automatically based on operating system preference. To set it manually, you can apply an additional class of <code>light</code> or <code>dark</code> to your <code><!--#<form>--></code> elements to force the mode.</p>
|
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": "5.1.
|
|
11
|
+
"version": "5.1.3",
|
|
12
12
|
"files": [
|
|
13
13
|
"dist",
|
|
14
14
|
"semanticForms.scss",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@jsdevtools/coverage-istanbul-loader": "3.0.5",
|
|
24
24
|
"@playwright/test": "1.54.2",
|
|
25
|
-
"eslint": "9.
|
|
25
|
+
"eslint": "9.33.0",
|
|
26
26
|
"eslint-plugin-html": "8.1.3",
|
|
27
27
|
"express": "5.1.0",
|
|
28
28
|
"nodemon": "3.1.10",
|
package/semanticForms.js
CHANGED
|
@@ -149,7 +149,7 @@ const semanticForms = () => {
|
|
|
149
149
|
clearBtn.innerHTML = '<svg viewBox="0 0 16 16" width="18" height="18"><path d="M 1 1 L 15 15 M 1 15 L 15 1" fill="none" stroke-width="2" stroke="currentColor" />'
|
|
150
150
|
clearBtn.classList.add('clear')
|
|
151
151
|
clearBtn.id = `semanticFormsClearButton_${input.id}`
|
|
152
|
-
clearBtn.addEventListener('click', (
|
|
152
|
+
clearBtn.addEventListener('click', () => {
|
|
153
153
|
input.previousValue = input.value
|
|
154
154
|
input.value = ''
|
|
155
155
|
input.focus()
|
|
@@ -157,7 +157,7 @@ const semanticForms = () => {
|
|
|
157
157
|
})
|
|
158
158
|
insertAfter(clearBtn, dd.querySelector('label'))
|
|
159
159
|
}
|
|
160
|
-
input.addEventListener('focus',
|
|
160
|
+
input.addEventListener('focus', event => {
|
|
161
161
|
if (event.target.nodeName === 'INPUT') lastFocusedInput = event.target
|
|
162
162
|
})
|
|
163
163
|
// #endregion
|
|
@@ -179,14 +179,24 @@ const semanticForms = () => {
|
|
|
179
179
|
// handle file input clear btn, cannot be handled with CSS
|
|
180
180
|
if (type === 'file') {
|
|
181
181
|
const clearBtn = input.parentElement.querySelector('.clear')
|
|
182
|
-
input.addEventListener('input',
|
|
183
|
-
clearBtn.style.display =
|
|
182
|
+
input.addEventListener('input', event => {
|
|
183
|
+
clearBtn.style.display = event.target.files.length ? 'flex' : 'none'
|
|
184
184
|
})
|
|
185
185
|
clearBtn.addEventListener('click', () => {
|
|
186
186
|
clearBtn.style.display = 'none'
|
|
187
187
|
})
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
// handle range inputs with a class to display the value
|
|
191
|
+
if (type === 'range' && input.classList.contains('displayValue')) {
|
|
192
|
+
const label = input.parentNode.parentNode.querySelector('dd label')
|
|
193
|
+
label.innerHTML += `<span class="seperator">: </span><output>${input.value}</output>`
|
|
194
|
+
input.addEventListener('input', event => {
|
|
195
|
+
const output = event.target.parentNode.parentNode.querySelector('output')
|
|
196
|
+
output.innerHTML = event.target.value
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
|
|
190
200
|
// #region show password button
|
|
191
201
|
if (type === 'password' && input.getAttribute('data-no-reveal') === null) {
|
|
192
202
|
const showBtn = document.createElement('button')
|
|
@@ -202,7 +212,7 @@ const semanticForms = () => {
|
|
|
202
212
|
console.error(`semantic-forms: Found an input (${input.id || input.getAttribute('name')}) that is not inside a <dd> element.`)
|
|
203
213
|
continue
|
|
204
214
|
}
|
|
205
|
-
showBtn.addEventListener('click', (
|
|
215
|
+
showBtn.addEventListener('click', () => {
|
|
206
216
|
if (input.type === 'password') {
|
|
207
217
|
showBtn.innerHTML = passwordHide
|
|
208
218
|
showBtn.title = input.getAttribute('data-hide-password-text') || 'Hide password'
|
|
@@ -248,7 +258,7 @@ const semanticForms = () => {
|
|
|
248
258
|
// handle undo/redo
|
|
249
259
|
let lastFocusedInput
|
|
250
260
|
let lastClearFieldPressed
|
|
251
|
-
document.addEventListener('keydown',
|
|
261
|
+
document.addEventListener('keydown', event => {
|
|
252
262
|
if ((event.ctrlKey || event.metaKey) && event.key === 'z' && !event.shiftKey) {
|
|
253
263
|
// undo clearing a field
|
|
254
264
|
if (lastFocusedInput) {
|
|
@@ -274,7 +284,7 @@ const semanticForms = () => {
|
|
|
274
284
|
|
|
275
285
|
// monitor changes to the DOM and enhance new semanticForms forms that get added
|
|
276
286
|
if (!window.semanticFormsObserver) {
|
|
277
|
-
window.semanticFormsObserver = new window.MutationObserver(
|
|
287
|
+
window.semanticFormsObserver = new window.MutationObserver(mutations => {
|
|
278
288
|
let stop = false
|
|
279
289
|
for (const mutation of mutations) {
|
|
280
290
|
for (const node of mutation.addedNodes) {
|
|
@@ -289,7 +299,7 @@ const semanticForms = () => {
|
|
|
289
299
|
window.semanticFormsObserver.observe(document.body, { attributes: false, childList: true, characterData: false, subtree: true })
|
|
290
300
|
}
|
|
291
301
|
|
|
292
|
-
semanticForms.reinitialize =
|
|
302
|
+
semanticForms.reinitialize = form => {
|
|
293
303
|
form.classList.remove('semanticFormsActive')
|
|
294
304
|
semanticForms()
|
|
295
305
|
}
|
package/semanticForms.scss
CHANGED
|
@@ -81,9 +81,9 @@ html:not(.light) {
|
|
|
81
81
|
}
|
|
82
82
|
// #endregion
|
|
83
83
|
|
|
84
|
-
form.semanticForms,
|
|
85
|
-
form.semanticForms.light,
|
|
86
|
-
table.semanticForms,
|
|
84
|
+
form.semanticForms,
|
|
85
|
+
form.semanticForms.light,
|
|
86
|
+
table.semanticForms,
|
|
87
87
|
table.semanticForms.light {
|
|
88
88
|
font-family: var(--semanticFormsFontFamily);
|
|
89
89
|
width: 100%;
|
|
@@ -193,7 +193,7 @@ table.semanticForms.light {
|
|
|
193
193
|
|
|
194
194
|
select {
|
|
195
195
|
cursor: pointer;
|
|
196
|
-
|
|
196
|
+
|
|
197
197
|
&:not([multiple]) {
|
|
198
198
|
// custom dropdown graphic on select element
|
|
199
199
|
background-image: var(--semanticFormsSelectIcon);
|
|
@@ -240,7 +240,7 @@ table.semanticForms.light {
|
|
|
240
240
|
& + label.floatLabelFormAnimatedLabel {
|
|
241
241
|
left: 32px !important; // override float label
|
|
242
242
|
}
|
|
243
|
-
|
|
243
|
+
|
|
244
244
|
&:focus,
|
|
245
245
|
&:not(:placeholder-shown) {
|
|
246
246
|
& + label.floatLabelFormAnimatedLabel {
|
|
@@ -310,6 +310,7 @@ table.semanticForms.light {
|
|
|
310
310
|
padding: 5px 25px;
|
|
311
311
|
font-size: 100%;
|
|
312
312
|
line-height: 1;
|
|
313
|
+
user-select: none;
|
|
313
314
|
|
|
314
315
|
&:active {
|
|
315
316
|
background-image: linear-gradient(to bottom, var(--semanticFormsButtonGradientDark) 0%, var(--semanticFormsButtonGradientLight) 100%);
|
|
@@ -409,7 +410,7 @@ table.semanticForms.light {
|
|
|
409
410
|
@supports (scrollbar-color: auto) {
|
|
410
411
|
textarea {
|
|
411
412
|
scrollbar-color: var(--semanticFormsScrollbarColor) transparent;
|
|
412
|
-
|
|
413
|
+
|
|
413
414
|
&::-webkit-resizer {
|
|
414
415
|
border: none;
|
|
415
416
|
background-image: var(--semanticFormsCustomResizer);
|
|
@@ -419,7 +420,7 @@ table.semanticForms.light {
|
|
|
419
420
|
margin: 0 2px 2px 0;
|
|
420
421
|
}
|
|
421
422
|
}
|
|
422
|
-
|
|
423
|
+
|
|
423
424
|
select[multiple] {
|
|
424
425
|
scrollbar-color: var(--semanticFormsScrollbarColor) transparent;
|
|
425
426
|
}
|
|
@@ -1167,7 +1168,7 @@ table.semanticForms {
|
|
|
1167
1168
|
th:last-of-type, td:last-of-type {
|
|
1168
1169
|
border-right: none;
|
|
1169
1170
|
}
|
|
1170
|
-
|
|
1171
|
+
|
|
1171
1172
|
tbody {
|
|
1172
1173
|
tr:last-of-type {
|
|
1173
1174
|
th, td {
|
|
@@ -1180,6 +1181,6 @@ table.semanticForms {
|
|
|
1180
1181
|
menu:has(li > input, li > label, li > button, li > select, li > textarea) {
|
|
1181
1182
|
width: max-content;
|
|
1182
1183
|
}
|
|
1183
|
-
|
|
1184
|
+
|
|
1184
1185
|
}
|
|
1185
1186
|
// #endregion
|