input-duration 3.0.3 → 3.1.0
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 +109 -4
- package/docs/bootstrap.html +104 -0
- package/docs/index.html +22 -12
- package/index.js +37 -22
- package/package.json +1 -1
- package/readme/rendering/androidBad.png +0 -0
- package/readme/rendering/androidGood.png +0 -0
- package/readme/rendering/bob.txt +1 -0
- package/readme/rendering/chromeBoth.png +0 -0
- package/readme/rendering/iosBad.png +0 -0
- package/readme/rendering/iosGood.png +0 -0
- package/readme/rendering/safariBoth.png +0 -0
package/README.md
CHANGED
|
@@ -54,12 +54,15 @@ HTML's built-in `<input type="time">` is for choosing a time of day, not enterin
|
|
|
54
54
|
The component supplies its own segmented layout instead of the browser's native time-picker UI, so the displayed format does not change with browser or locale. It is built from native number inputs, however, so details such as the on-screen keyboard and interaction can still vary by device and browser; this is consistency of the value's presentation, not a guarantee of pixel-identical rendering. Milliseconds can be entered as three digits; the input's step controls increment in 10 ms intervals.
|
|
55
55
|
|
|
56
56
|
The control's styles are scoped inside its Shadow DOM, so global styles and resets from Tailwind or other CSS libraries do not leak into its internal layout. The control inherits its font and text color from its surrounding page.
|
|
57
|
+
|
|
57
58
|
<br>
|
|
58
59
|
<p>
|
|
59
60
|
<div>
|
|
60
61
|
</div>
|
|
61
62
|
<div align="center">
|
|
62
63
|
<a href="https://stephanluis.github.io/input-duration/" target="_blank">Demo</a>
|
|
64
|
+
·
|
|
65
|
+
<a href="https://stephanluis.github.io/input-duration/bootstrap.html" target="_blank">Bootstrap Demo</a>
|
|
63
66
|
·
|
|
64
67
|
<a href="https://codesandbox.io/s/peaceful-waterfall-6mxpg2?file=/index.html" target="_blank">
|
|
65
68
|
Fiddle
|
|
@@ -86,7 +89,41 @@ The goal is a small JavaScript duration input that gives countdowns and elapsed-
|
|
|
86
89
|
|
|
87
90
|
<i>Does this lose any functionality?</i> No! `document.querySelector('#bob').value` has a getter and setter, so values can be set and retrieved from JavaScript or the HTML attribute.
|
|
88
91
|
|
|
89
|
-
|
|
92
|
+
### Screenshots
|
|
93
|
+
|
|
94
|
+
The desktop comparisons show how a native time input represents a time of day, while `input-duration` displays an elapsed duration in a fixed format.
|
|
95
|
+
|
|
96
|
+
<p> 💔 the native time input on the left; 🏁 `input-duration` is shown on the right.</p>
|
|
97
|
+
|
|
98
|
+
<h4>Chrome</h4>
|
|
99
|
+
<img src="readme/rendering/chromeBoth.png" alt="Chrome comparison of a native time input and input-duration" width="100%"/>
|
|
100
|
+
|
|
101
|
+
<h4>Safari</h4>
|
|
102
|
+
<img src="readme/rendering/safariBoth.png" alt="Safari comparison of a native time input and input-duration" width="100%"/>
|
|
103
|
+
|
|
104
|
+
The mobile screenshots show the native time picker alongside `input-duration` on each platform.
|
|
105
|
+
|
|
106
|
+
<table>
|
|
107
|
+
<thead>
|
|
108
|
+
<tr>
|
|
109
|
+
<th>Device</th>
|
|
110
|
+
<th> 💔 Native time input<br/></th>
|
|
111
|
+
<th> 🏁 input-duration</th>
|
|
112
|
+
</tr>
|
|
113
|
+
</thead>
|
|
114
|
+
<tbody>
|
|
115
|
+
<tr>
|
|
116
|
+
<th>Android</th>
|
|
117
|
+
<td><img src="readme/rendering/androidBad.png" alt="Android native time picker" width="200"/></td>
|
|
118
|
+
<td><img src="readme/rendering/androidGood.png" alt="input-duration on Android with the numeric keyboard" width="200"/></td>
|
|
119
|
+
</tr>
|
|
120
|
+
<tr>
|
|
121
|
+
<th>iOS</th>
|
|
122
|
+
<td><img src="readme/rendering/iosBad.png" alt="iOS native time picker" width="200"/></td>
|
|
123
|
+
<td><img src="readme/rendering/iosGood.png" alt="input-duration on iOS with the numeric keyboard" width="200"/></td>
|
|
124
|
+
</tr>
|
|
125
|
+
</tbody>
|
|
126
|
+
</table>
|
|
90
127
|
|
|
91
128
|
Native time inputs are useful when the user is choosing a time on a clock. A duration is different: `30:00:00.125` means thirty hours, not 6 AM the next day. Keeping those concepts separate avoids date, timezone, and 12/24-hour display concerns when collecting a duration.
|
|
92
129
|
|
|
@@ -115,6 +152,8 @@ Here's why:
|
|
|
115
152
|
</li>
|
|
116
153
|
<li><a href="#usage">Usage</a></li>
|
|
117
154
|
<li><a href="#roadmap">Roadmap</a></li>
|
|
155
|
+
<li><a href="#related-duration-controls">Related duration controls</a></li>
|
|
156
|
+
<li><a href="#future-partners">Future partners</a></li>
|
|
118
157
|
<li><a href="#cross-browser-testing">Cross-browser testing</a></li>
|
|
119
158
|
<li><a href="#contributing">Contributing</a></li>
|
|
120
159
|
<li><a href="#license">License</a></li>
|
|
@@ -223,6 +262,35 @@ document.querySelector('#bob').value = '44:04:04.444'
|
|
|
223
262
|
|
|
224
263
|
```
|
|
225
264
|
|
|
265
|
+
### Bootstrap styling
|
|
266
|
+
|
|
267
|
+
The component keeps its Shadow DOM, so Bootstrap's CSS selectors do not directly style its internal fields. Instead, map Bootstrap theme variables to the component's CSS custom properties. This is additive: without overrides, the component retains its default appearance.
|
|
268
|
+
|
|
269
|
+
```css
|
|
270
|
+
input-duration {
|
|
271
|
+
--input-duration-border-color: var(--bs-border-color);
|
|
272
|
+
--input-duration-border-radius: var(--bs-border-radius);
|
|
273
|
+
--input-duration-background: var(--bs-body-bg);
|
|
274
|
+
--input-duration-color: var(--bs-body-color);
|
|
275
|
+
--input-duration-focus-color: var(--bs-primary);
|
|
276
|
+
--input-duration-focus-outline: 0.25rem solid rgba(var(--bs-primary-rgb), 0.25);
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
The internal control and its fields, dividers, and icon are also exposed as Shadow Parts for targeted styling:
|
|
281
|
+
|
|
282
|
+
```css
|
|
283
|
+
input-duration::part(control) {
|
|
284
|
+
padding: 0.375rem 0.75rem;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
input-duration::part(field) {
|
|
288
|
+
font-size: 1rem;
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
Available parts are `control`, `field` (also `field-hours`, `field-minutes`, `field-seconds`, and `field-milliseconds`), `divider` (also `divider-hours-minutes`, `divider-minutes-seconds`, and `divider-seconds-milliseconds`), and `icon`. Supported CSS custom properties are `--input-duration-gap`, `--input-duration-padding`, `--input-duration-border-color`, `--input-duration-border-radius`, `--input-duration-background`, `--input-duration-color`, `--input-duration-focus-color`, `--input-duration-focus-outline`, `--input-duration-focus-outline-offset`, `--input-duration-divider-color`, `--input-duration-divider-opacity`, `--input-duration-disabled-color`, and `--input-duration-icon-color`.
|
|
293
|
+
|
|
226
294
|
and
|
|
227
295
|
|
|
228
296
|
```sh
|
|
@@ -244,18 +312,55 @@ _For more documentation, please refer to the jscocs on [input-duration Docs](ht
|
|
|
244
312
|
- [x] Emperically determine <input type="time"> behaviour of Input (time) on Chrome
|
|
245
313
|
- [x] Reverse engineer input behaviour (arrows, digits, 0 addition, etc.)
|
|
246
314
|
- [x] Cross browser/ cross os manual tests
|
|
247
|
-
- [ ] Get Chrome behavioural specification for <input type="time">
|
|
248
315
|
- [ ] Add end to end multi-browser, multi-os Selinium tests
|
|
249
|
-
- [
|
|
316
|
+
- [X] Update demo page (either PM.com or JSfiddle type)
|
|
250
317
|
- [ ] Multi-language documentation (Google translate of this page?)
|
|
251
318
|
- [ ] Chinese
|
|
252
319
|
- [ ] Spanish
|
|
253
|
-
|
|
320
|
+
|
|
321
|
+
### 2026
|
|
322
|
+
|
|
323
|
+
- [ ] Document and verify a versioned Chrome `<input type="time">` behavior profile: compare the [WHATWG standard](https://html.spec.whatwg.org/multipage/input.html#time-state-(type=time)) with [Blink's implementation](https://chromium.googlesource.com/chromium/src/+/main/third_party/blink/renderer/core/html/forms/time_input_type.cc) and [time-input tests](https://chromium.googlesource.com/chromium/src/+/main/third_party/blink/web_tests/fast/forms/time/) (including [multiple-field UI tests](https://chromium.googlesource.com/chromium/src/+/main/third_party/blink/web_tests/fast/forms/time-multiple-fields/)). Record Chrome version, OS, and locale; verify relevant keyboard and segment-editing behavior, then adapt `input-duration` where appropriate without assuming platform-specific time-picker UI is universal.
|
|
324
|
+
- [ ] Add configurable duration segments and presentation, including optional days, hiding units, and custom dividers. Keep `HH:mm:ss.SSS` as the default. ([html-duration-picker.js](https://nadchif.github.io/html-duration-picker.js/), [input-duration-element](https://muan.github.io/input-duration-element/))
|
|
325
|
+
- [ ] Support declarative minimum and maximum values with consistent validation and boundary behavior. ([html-duration-picker.js](https://nadchif.github.io/html-duration-picker.js/))
|
|
326
|
+
- [ ] Improve accessibility with per-segment labels, group semantics, and documented screen-reader and keyboard behavior. ([time-input-polyfill](https://github.com/Dan503/time-input-polyfill/) demonstrates accessible time-field interactions.)
|
|
327
|
+
- [ ] Participate in native HTML forms, including named submission, required/validity, disabled state, and form reset/restore behavior. ([duration-input example](https://gist.github.com/Wigny/97cc83ea5179e7b8ab5a044fb14deb9a))
|
|
328
|
+
- [ ] Offer optional ISO 8601 duration serialization and `Temporal.Duration` interoperability without breaking the existing `HH:mm:ss.SSS` value format. ([WHATWG discussion](https://github.com/whatwg/html/issues/5488#issuecomment-3961032394), [duration-input example](https://gist.github.com/Wigny/97cc83ea5179e7b8ab5a044fb14deb9a))
|
|
254
329
|
|
|
255
330
|
See the [open issues](https://github.com/StephanLuis/input-duration/issues) for a full list of proposed features (and known issues).
|
|
256
331
|
|
|
257
332
|
<p align="right">(<a href="#top">back to top</a>)</p>
|
|
258
333
|
|
|
334
|
+
<!-- RELATED DURATION CONTROLS -->
|
|
335
|
+
## Related duration controls
|
|
336
|
+
|
|
337
|
+
This comparison summarizes capabilities described in each project's documentation; a dash means the feature is not documented, not necessarily unsupported. "Estimated users" is approximated by npm package downloads from 2026-10-28 through 2026-11-03, not unique people; downloads can include CI, repeated installs, and automated systems, and omit CDN or other use. The Wigny entry is a gist example rather than a maintained library, so no npm download figure is available.
|
|
338
|
+
|
|
339
|
+
| Control | Display / units | Value representation | Bounds | Precision / interaction | Estimated users* |
|
|
340
|
+
|---|---|---|---|---|---:|
|
|
341
|
+
| [input-duration](https://github.com/StephanLuis/input-duration) | Fixed `HH:mm:ss.SSS` (00–99 hours); `noHours()` can hide hours | `HH:mm:ss.SSS` string via `.value` | No public min/max options documented | Milliseconds; digit entry, arrow navigation and increment | [~748](https://api.npmjs.org/downloads/point/last-week/input-duration) |
|
|
342
|
+
| [timepoint-selection](https://github.com/naomiaro/timepoint-selection) | Selectable `dd:hh:mm:ss`, `dd:hh:mm`, `hh:mm:ss`, `hh:mm`, or `mm:ss`; custom unit labels | Numeric seconds through `getValue()` / `setValue()` | Configurable maximum / rollover | Seconds; keyboard navigation, arrow increments, rollover | [~22](https://api.npmjs.org/downloads/point/last-week/timepoint-selection) |
|
|
343
|
+
| [html-duration-picker.js](https://github.com/nadchif/html-duration-picker.js) | `HH:MM:SS`; optional hidden seconds | Formatted text in an enhanced native `<input>` | Configurable minimum and maximum durations | Seconds in documented formats; interaction details not specified | [~905](https://api.npmjs.org/downloads/point/last-week/html-duration-picker) |
|
|
344
|
+
| [muan/input-duration-element](https://github.com/muan/input-duration-element) | Hours, minutes, seconds; customizable dividers/slots | Numeric seconds; `value` and `change` event | `max` documented; `min` and validation listed as TODOs | Demo covers durations up to 180 seconds; precision beyond seconds not specified | [~9](https://api.npmjs.org/downloads/point/last-week/input-duration-element) |
|
|
345
|
+
| [segmented-input](https://github.com/jimmywarting/segmented-input) | Duration preset or custom parsing/formatting and segments | Formatted string in an enhanced native `<input>` | Per-segment `min`, `max`, and `step`; custom validity | Duration preset shown to seconds; arrow-key segment navigation and adjustment | [~4](https://api.npmjs.org/downloads/point/last-week/segmented-input) |
|
|
346
|
+
| [Wigny duration-input example](https://gist.github.com/Wigny/97cc83ea5179e7b8ab5a044fb14deb9a) | Markup-defined hour, minute, and second segments | ISO 8601 duration string; form-associated custom element | No public min/max API documented | Fractional seconds; keyboard segment navigation and adjustment | N/A (gist) |
|
|
347
|
+
|
|
348
|
+
These projects illustrate possible directions—such as optional units, configurable formatting, bounds, alternate value formats, and native form participation—without implying that every feature is a fit for `input-duration`.
|
|
349
|
+
|
|
350
|
+
<p align="right">(<a href="#top">back to top</a>)</p>
|
|
351
|
+
|
|
352
|
+
<!-- FUTURE PARTNERS -->
|
|
353
|
+
## Future partners
|
|
354
|
+
|
|
355
|
+
Potential integration targets only; these projects are not affiliated with or endorsing `input-duration`.
|
|
356
|
+
|
|
357
|
+
- [React Hook Form](https://react-hook-form.com/docs/usecontroller/controller) — provide a tested `Controller` adapter/example that synchronizes the custom element's value, events, ref, and validation.
|
|
358
|
+
- [Formik](https://formik.org/docs/api/field) — add a custom `Field` example to connect duration values to Formik-managed forms.
|
|
359
|
+
- [Angular Reactive Forms](https://angular.dev/api/forms/ControlValueAccessor) — provide a `ControlValueAccessor` adapter for model-to-view updates, user changes, touched state, and disabled state.
|
|
360
|
+
- [Shoelace](https://shoelace.style/) — document how to use the framework-agnostic duration element alongside Shoelace form controls in a consistent design system.
|
|
361
|
+
|
|
362
|
+
<p align="right">(<a href="#top">back to top</a>)</p>
|
|
363
|
+
|
|
259
364
|
<!-- TESTSTATUS -->
|
|
260
365
|
## Cross-browser testing
|
|
261
366
|
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<meta name="description" content="See input-duration styled with Bootstrap 5 using CSS custom properties and Shadow Parts.">
|
|
7
|
+
<title>Bootstrap demo — input-duration</title>
|
|
8
|
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
9
|
+
<style>
|
|
10
|
+
input-duration {
|
|
11
|
+
--input-duration-gap: 0.1em;
|
|
12
|
+
--input-duration-padding: 0.375rem 0.75rem;
|
|
13
|
+
--input-duration-border-color: var(--bs-border-color);
|
|
14
|
+
--input-duration-border-radius: var(--bs-border-radius);
|
|
15
|
+
--input-duration-background: var(--bs-body-bg);
|
|
16
|
+
--input-duration-color: var(--bs-body-color);
|
|
17
|
+
--input-duration-focus-color: var(--bs-primary);
|
|
18
|
+
--input-duration-focus-outline: 0.25rem solid rgba(var(--bs-primary-rgb), 0.25);
|
|
19
|
+
--input-duration-focus-outline-offset: 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
input-duration::part(control) {
|
|
23
|
+
min-height: calc(1.5em + 0.75rem + 2px);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
input-duration::part(field) {
|
|
27
|
+
font-size: 1rem;
|
|
28
|
+
}
|
|
29
|
+
</style>
|
|
30
|
+
</head>
|
|
31
|
+
<body>
|
|
32
|
+
<main class="container py-5">
|
|
33
|
+
<div class="row justify-content-center">
|
|
34
|
+
<div class="col-lg-8">
|
|
35
|
+
<a class="link-secondary text-decoration-none" href="./">← Main demo</a>
|
|
36
|
+
<header class="my-4">
|
|
37
|
+
<p class="text-uppercase text-primary fw-semibold small mb-2">input-duration + Bootstrap 5</p>
|
|
38
|
+
<h1 class="display-5 fw-semibold">A duration input that fits your Bootstrap theme</h1>
|
|
39
|
+
<p class="lead text-secondary mt-3">
|
|
40
|
+
The component keeps its Shadow DOM. Bootstrap’s global selectors do not reach inside it;
|
|
41
|
+
this page maps Bootstrap theme variables to the component’s public styling hooks instead.
|
|
42
|
+
</p>
|
|
43
|
+
</header>
|
|
44
|
+
|
|
45
|
+
<section class="card shadow-sm" aria-labelledby="example-heading">
|
|
46
|
+
<div class="card-body p-4">
|
|
47
|
+
<h2 class="h4 card-title" id="example-heading">Maintenance window</h2>
|
|
48
|
+
<p class="card-text text-secondary">Set a duration of more than a day, down to milliseconds.</p>
|
|
49
|
+
<label class="form-label fw-medium" id="duration-label">Duration</label>
|
|
50
|
+
<div>
|
|
51
|
+
<input-duration id="duration" value="30:00:00.042" role="group"
|
|
52
|
+
aria-labelledby="duration-label"
|
|
53
|
+
aria-describedby="duration-help"
|
|
54
|
+
aria-label="Duration in hours, minutes, seconds, and milliseconds"></input-duration>
|
|
55
|
+
</div>
|
|
56
|
+
<div class="form-text mt-3" id="duration-help">
|
|
57
|
+
Current value: <output id="duration-value">30:00:00.042</output>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</section>
|
|
61
|
+
|
|
62
|
+
<section class="mt-4" aria-labelledby="integration-heading">
|
|
63
|
+
<h2 class="h5" id="integration-heading">How the styling works</h2>
|
|
64
|
+
<p>
|
|
65
|
+
CSS custom properties bring in Bootstrap colors, border radius, spacing, and focus-ring
|
|
66
|
+
styling. Shadow Parts provide targeted access to the control and its internal fields.
|
|
67
|
+
</p>
|
|
68
|
+
<pre class="bg-body-tertiary border rounded p-3"><code>input-duration {
|
|
69
|
+
--input-duration-border-color: var(--bs-border-color);
|
|
70
|
+
--input-duration-border-radius: var(--bs-border-radius);
|
|
71
|
+
--input-duration-focus-color: var(--bs-primary);
|
|
72
|
+
--input-duration-focus-outline: 0.25rem solid rgba(var(--bs-primary-rgb), 0.25);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
input-duration::part(field) {
|
|
76
|
+
font-size: 1rem;
|
|
77
|
+
}</code></pre>
|
|
78
|
+
</section>
|
|
79
|
+
|
|
80
|
+
<footer class="border-top mt-5 pt-3 text-secondary small">
|
|
81
|
+
<a href="https://github.com/StephanLuis/input-duration">Source on GitHub</a>
|
|
82
|
+
<span class="mx-2" aria-hidden="true">·</span>
|
|
83
|
+
<a href="https://github.com/StephanLuis/input-duration#usage">Styling API documentation</a>
|
|
84
|
+
</footer>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
</main>
|
|
88
|
+
<script type="module">
|
|
89
|
+
import 'https://cdn.jsdelivr.net/npm/input-duration/+esm';
|
|
90
|
+
|
|
91
|
+
const duration = document.querySelector('#duration');
|
|
92
|
+
const output = document.querySelector('#duration-value');
|
|
93
|
+
|
|
94
|
+
duration.addEventListener('input', () => {
|
|
95
|
+
output.value = duration.value;
|
|
96
|
+
output.textContent = duration.value;
|
|
97
|
+
});
|
|
98
|
+
duration.addEventListener('change', () => {
|
|
99
|
+
output.value = duration.value;
|
|
100
|
+
output.textContent = duration.value;
|
|
101
|
+
});
|
|
102
|
+
</script>
|
|
103
|
+
</body>
|
|
104
|
+
</html>
|
package/docs/index.html
CHANGED
|
@@ -89,16 +89,25 @@
|
|
|
89
89
|
line-height: 1.6;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
.
|
|
93
|
-
display:
|
|
94
|
-
margin
|
|
95
|
-
padding:
|
|
96
|
-
border: 1px solid
|
|
97
|
-
border-radius:
|
|
98
|
-
background:
|
|
99
|
-
color: #
|
|
100
|
-
font-size: .
|
|
101
|
-
|
|
92
|
+
.get-started {
|
|
93
|
+
display: table;
|
|
94
|
+
margin: 30px auto 0;
|
|
95
|
+
padding: 13px 22px;
|
|
96
|
+
border: 1px solid var(--blue);
|
|
97
|
+
border-radius: 10px;
|
|
98
|
+
background: var(--blue);
|
|
99
|
+
color: #fff;
|
|
100
|
+
font-size: 1.05rem;
|
|
101
|
+
text-decoration: none;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.get-started:hover {
|
|
105
|
+
background: #1d4f87;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.get-started:focus-visible {
|
|
109
|
+
outline: 3px solid #8bb9e8;
|
|
110
|
+
outline-offset: 3px;
|
|
102
111
|
}
|
|
103
112
|
|
|
104
113
|
.comparison {
|
|
@@ -234,7 +243,6 @@
|
|
|
234
243
|
<p class="eyebrow">A small input, solves a very big problem</p>
|
|
235
244
|
<h1>Time is not a duration.</h1>
|
|
236
245
|
<p class="intro">You need to set a maintenance window. It’ll take 30 hours and 42 milliseconds. Surely a time picker can handle that?</p>
|
|
237
|
-
<p class="scenario">The task: run X for 30 hours and 42 milliseconds</p>
|
|
238
246
|
</header>
|
|
239
247
|
|
|
240
248
|
<section class="comparison" aria-label="Compare a time-of-day input with a duration input">
|
|
@@ -262,9 +270,11 @@
|
|
|
262
270
|
That's the gap <a href="InputDuration.html">input-duration</a> fills. Read the
|
|
263
271
|
<a href="https://github.com/StephanLuis/input-duration">source on GitHub</a>.
|
|
264
272
|
</footer>
|
|
273
|
+
<p class="demo-link"><a href="bootstrap.html">See the Bootstrap 5 demo</a></p>
|
|
274
|
+
<a class="get-started" href="https://github.com/StephanLuis/input-duration#getting-started">Get Started</a>
|
|
265
275
|
</main>
|
|
266
276
|
<script type="module">
|
|
267
|
-
import 'https://cdn.jsdelivr.net/npm/input-duration
|
|
277
|
+
import 'https://cdn.jsdelivr.net/npm/input-duration/+esm';
|
|
268
278
|
|
|
269
279
|
const clockInput = document.querySelector('#clock-time');
|
|
270
280
|
const clockResult = document.querySelector('#clock-result');
|
package/index.js
CHANGED
|
@@ -237,18 +237,19 @@ class InputDuration extends HTMLElement {
|
|
|
237
237
|
var spanIn = document.createElement("div");
|
|
238
238
|
|
|
239
239
|
spanIn.classList.add('timeCase');
|
|
240
|
+
spanIn.setAttribute('part', 'control');
|
|
240
241
|
|
|
241
242
|
var template = document.createElement('template');
|
|
242
243
|
|
|
243
244
|
template.innerHTML = `
|
|
244
|
-
<input type="number" class="sH D2 ts_digit" name="startHours" data-tp="1" min="-1" max="100" value="00" >
|
|
245
|
-
<span class="bds-h">:</span>
|
|
246
|
-
<input type="number" class="sM D2 ts_digit" name="startMinutes" data-tp="2" min="-1" max="60" value="00">
|
|
247
|
-
<span class="bds-m">:</span>
|
|
248
|
-
<input type="number" class="sS D2 ts_digit" name="startSeconds" data-tp="3" min="-1" max="60" value="00">
|
|
249
|
-
<span class="bds-s">.</span>
|
|
250
|
-
<input type="number" class="sMS D3 ts_digit" name="startMilliSecs" data-tp="4" min="-10" max="1010" step="10" value="000">
|
|
251
|
-
<div id="svgContainer">
|
|
245
|
+
<input type="number" class="sH D2 ts_digit" part="field field-hours" name="startHours" data-tp="1" min="-1" max="100" value="00" >
|
|
246
|
+
<span class="bds-h" part="divider divider-hours-minutes">:</span>
|
|
247
|
+
<input type="number" class="sM D2 ts_digit" part="field field-minutes" name="startMinutes" data-tp="2" min="-1" max="60" value="00">
|
|
248
|
+
<span class="bds-m" part="divider divider-minutes-seconds">:</span>
|
|
249
|
+
<input type="number" class="sS D2 ts_digit" part="field field-seconds" name="startSeconds" data-tp="3" min="-1" max="60" value="00">
|
|
250
|
+
<span class="bds-s" part="divider divider-seconds-milliseconds">.</span>
|
|
251
|
+
<input type="number" class="sMS D3 ts_digit" part="field field-milliseconds" name="startMilliSecs" data-tp="4" min="-10" max="1010" step="10" value="000">
|
|
252
|
+
<div id="svgContainer" part="icon">
|
|
252
253
|
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true"
|
|
253
254
|
focusable="false" data-prefix="fal" data-icon="stopwatch" class="svg-inline--fa fa-stopwatch fa-w-14"
|
|
254
255
|
role="img" viewBox="0 0 448 512">
|
|
@@ -261,27 +262,41 @@ class InputDuration extends HTMLElement {
|
|
|
261
262
|
color: inherit;
|
|
262
263
|
font: inherit;
|
|
263
264
|
vertical-align: middle;
|
|
265
|
+
--input-duration-gap: 0.08em;
|
|
266
|
+
--input-duration-padding: 0.4em 0.55em;
|
|
267
|
+
--input-duration-border-color: #9aa6b2;
|
|
268
|
+
--input-duration-border-radius: 0.4em;
|
|
269
|
+
--input-duration-background: transparent;
|
|
270
|
+
--input-duration-color: inherit;
|
|
271
|
+
--input-duration-focus-color: #2196f3;
|
|
272
|
+
--input-duration-focus-outline: 3px solid #2196f3;
|
|
273
|
+
--input-duration-focus-outline-offset: 2px;
|
|
274
|
+
--input-duration-divider-color: currentColor;
|
|
275
|
+
--input-duration-divider-opacity: 0.7;
|
|
276
|
+
--input-duration-disabled-color: GrayText;
|
|
277
|
+
--input-duration-icon-color: inherit;
|
|
264
278
|
}
|
|
265
279
|
|
|
266
|
-
.timeCase
|
|
280
|
+
.timeCase,
|
|
281
|
+
.timeCase[part~="control"] {
|
|
267
282
|
display: inline-flex;
|
|
268
283
|
align-items: center;
|
|
269
|
-
gap:
|
|
284
|
+
gap: var(--input-duration-gap);
|
|
270
285
|
max-width: 100%;
|
|
271
|
-
padding:
|
|
272
|
-
border: 1px solid
|
|
273
|
-
border-radius:
|
|
274
|
-
background:
|
|
275
|
-
color:
|
|
286
|
+
padding: var(--input-duration-padding);
|
|
287
|
+
border: 1px solid var(--input-duration-border-color);
|
|
288
|
+
border-radius: var(--input-duration-border-radius);
|
|
289
|
+
background: var(--input-duration-background);
|
|
290
|
+
color: var(--input-duration-color);
|
|
276
291
|
font-variant-numeric: tabular-nums;
|
|
277
292
|
line-height: 1.4;
|
|
278
293
|
white-space: nowrap;
|
|
279
294
|
}
|
|
280
295
|
|
|
281
296
|
.timeCase:focus-within {
|
|
282
|
-
border-color:
|
|
283
|
-
outline:
|
|
284
|
-
outline-offset:
|
|
297
|
+
border-color: var(--input-duration-focus-color);
|
|
298
|
+
outline: var(--input-duration-focus-outline);
|
|
299
|
+
outline-offset: var(--input-duration-focus-outline-offset);
|
|
285
300
|
}
|
|
286
301
|
|
|
287
302
|
.timeCase input {
|
|
@@ -313,8 +328,8 @@ class InputDuration extends HTMLElement {
|
|
|
313
328
|
}
|
|
314
329
|
|
|
315
330
|
.timeCase span {
|
|
316
|
-
color:
|
|
317
|
-
opacity:
|
|
331
|
+
color: var(--input-duration-divider-color);
|
|
332
|
+
opacity: var(--input-duration-divider-opacity);
|
|
318
333
|
}
|
|
319
334
|
|
|
320
335
|
#svgContainer {
|
|
@@ -325,7 +340,7 @@ class InputDuration extends HTMLElement {
|
|
|
325
340
|
align-items: center;
|
|
326
341
|
justify-content: center;
|
|
327
342
|
margin-left: 0.2em;
|
|
328
|
-
color:
|
|
343
|
+
color: var(--input-duration-icon-color);
|
|
329
344
|
}
|
|
330
345
|
|
|
331
346
|
#svgContainer svg {
|
|
@@ -336,7 +351,7 @@ class InputDuration extends HTMLElement {
|
|
|
336
351
|
|
|
337
352
|
.timeCase input:disabled {
|
|
338
353
|
background: transparent;
|
|
339
|
-
color:
|
|
354
|
+
color: var(--input-duration-disabled-color);
|
|
340
355
|
cursor: not-allowed;
|
|
341
356
|
opacity: 0.65;
|
|
342
357
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "input-duration",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"author": "Stephan Luis <stephan@learnsense.org>",
|
|
5
5
|
"description": "A JavaScript web component for entering durations up to 99 hours in a fixed HH:mm:ss.SSS format, with millisecond precision for countdown timers and elapsed time.",
|
|
6
6
|
"browser": "./index.js",
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
x
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|