input-duration 3.0.3 → 3.2.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 CHANGED
@@ -54,19 +54,22 @@ 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
66
69
  </a> ·
67
70
  <a href="https://6mxpg2.csb.app/" target="_blank">Fiddle's Output</a>
68
71
  ·
69
- <a href="https://stephanluis.github.io/input-duration/" target="_blank">Docs</a>
72
+ <a href="https://stephanluis.github.io/input-duration/InputDuration.html" target="_blank">API Docs</a>
70
73
  ·
71
74
  <a href="https://github.com/StephanLuis/input-duration/issues">Bugs</a>
72
75
  ·
@@ -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
- <img src="readme/safariBad.png" alt="Example comparing a native time input with input-duration" width="80%"/>
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>
@@ -215,6 +254,22 @@ input-duration requires a `<input-duration>` element . There's no more HTML tha
215
254
 
216
255
  ```
217
256
 
257
+ Individual duration fields can be hidden with boolean attributes:
258
+
259
+ ```html
260
+ <input-duration no-hours no-minutes no-seconds no-microseconds></input-duration>
261
+ ```
262
+
263
+ Use `hideHours()`, `hideMinutes()`, `hideSeconds()`, and `hideMicroSeconds()` to hide fields, and the corresponding `show*()` methods to show them again. The existing `noHours()`, `noMinutes()`, `noSeconds()`, and `noMicroSeconds()` methods remain available as aliases for the `hide*()` methods. Hidden fields do not change the component's `HH:mm:ss.SSS` value format.
264
+
265
+ Customize the separators with the `hours-divider`, `minutes-divider`, `seconds-divider`, and `microseconds-divider` attributes. The first three replace the separators between fields; `microseconds-divider` adds an optional suffix after milliseconds. For example:
266
+
267
+ ```html
268
+ <input-duration hours-divider="h " minutes-divider="m " seconds-divider="s " microseconds-divider="ms"></input-duration>
269
+ ```
270
+
271
+ The equivalent methods are `setHoursDivider(text)`, `setMinutesDivider(text)`, `setSecondsDivider(text)`, and `setMicroSecondsDivider(text)`. Pass text as a string; it is rendered as text, not HTML. Remove an attribute to restore its default separator (or remove the milliseconds suffix).
272
+
218
273
  If you would like to get or set values or to disable input-duration elemet, javascipt can do that:
219
274
 
220
275
  ```sh
@@ -223,6 +278,35 @@ document.querySelector('#bob').value = '44:04:04.444'
223
278
 
224
279
  ```
225
280
 
281
+ ### Bootstrap styling
282
+
283
+ 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.
284
+
285
+ ```css
286
+ input-duration {
287
+ --input-duration-border-color: var(--bs-border-color);
288
+ --input-duration-border-radius: var(--bs-border-radius);
289
+ --input-duration-background: var(--bs-body-bg);
290
+ --input-duration-color: var(--bs-body-color);
291
+ --input-duration-focus-color: var(--bs-primary);
292
+ --input-duration-focus-outline: 0.25rem solid rgba(var(--bs-primary-rgb), 0.25);
293
+ }
294
+ ```
295
+
296
+ The internal control and its fields, dividers, and icon are also exposed as Shadow Parts for targeted styling:
297
+
298
+ ```css
299
+ input-duration::part(control) {
300
+ padding: 0.375rem 0.75rem;
301
+ }
302
+
303
+ input-duration::part(field) {
304
+ font-size: 1rem;
305
+ }
306
+ ```
307
+
308
+ 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`.
309
+
226
310
  and
227
311
 
228
312
  ```sh
@@ -232,7 +316,7 @@ document.querySelector('#bob').disable()
232
316
  ```
233
317
  so the inputs are modified.
234
318
 
235
- _For more documentation, please refer to the jscocs on [input-duration Docs](https://stephanluis.github.io/input-duration/)_
319
+ For the generated JSDoc API reference, see the [input-duration API documentation](https://stephanluis.github.io/input-duration/InputDuration.html).
236
320
 
237
321
  <p align="right">(<a href="#top">back to top</a>)</p>
238
322
 
@@ -244,18 +328,55 @@ _For more documentation, please refer to the jscocs on [input-duration Docs](ht
244
328
  - [x] Emperically determine <input type="time"> behaviour of Input (time) on Chrome
245
329
  - [x] Reverse engineer input behaviour (arrows, digits, 0 addition, etc.)
246
330
  - [x] Cross browser/ cross os manual tests
247
- - [ ] Get Chrome behavioural specification for <input type="time">
248
331
  - [ ] Add end to end multi-browser, multi-os Selinium tests
249
- - [ ] Update demo page (either PM.com or JSfiddle type)
332
+ - [X] Update demo page (either PM.com or JSfiddle type)
250
333
  - [ ] Multi-language documentation (Google translate of this page?)
251
334
  - [ ] Chinese
252
335
  - [ ] Spanish
253
- - [ ] min and max values (sorry for the moment you'll have to do those yourself in js)
336
+
337
+ ### 2026
338
+
339
+ - [ ] 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.
340
+ - [ ] 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/))
341
+ - [ ] Support declarative minimum and maximum values with consistent validation and boundary behavior. ([html-duration-picker.js](https://nadchif.github.io/html-duration-picker.js/))
342
+ - [ ] 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.)
343
+ - [ ] 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))
344
+ - [ ] 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
345
 
255
346
  See the [open issues](https://github.com/StephanLuis/input-duration/issues) for a full list of proposed features (and known issues).
256
347
 
257
348
  <p align="right">(<a href="#top">back to top</a>)</p>
258
349
 
350
+ <!-- RELATED DURATION CONTROLS -->
351
+ ## Related duration controls
352
+
353
+ 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.
354
+
355
+ | Control | Display / units | Value representation | Bounds | Precision / interaction | Estimated users* |
356
+ |---|---|---|---|---|---:|
357
+ | [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) |
358
+ | [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) |
359
+ | [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) |
360
+ | [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) |
361
+ | [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) |
362
+ | [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) |
363
+
364
+ 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`.
365
+
366
+ <p align="right">(<a href="#top">back to top</a>)</p>
367
+
368
+ <!-- FUTURE PARTNERS -->
369
+ ## Future partners
370
+
371
+ Potential integration targets only; these projects are not affiliated with or endorsing `input-duration`.
372
+
373
+ - [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.
374
+ - [Formik](https://formik.org/docs/api/field) — add a custom `Field` example to connect duration values to Formik-managed forms.
375
+ - [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.
376
+ - [Shoelace](https://shoelace.style/) — document how to use the framework-agnostic duration element alongside Shoelace form controls in a consistent design system.
377
+
378
+ <p align="right">(<a href="#top">back to top</a>)</p>
379
+
259
380
  <!-- TESTSTATUS -->
260
381
  ## Cross-browser testing
261
382