use-wc 1.0.0-pre.39 → 1.0.0-pre.40

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.
@@ -15,7 +15,9 @@
15
15
  }
16
16
 
17
17
  :is(button, a, details summary, use-widget):not([data-appear-as="native"]):focus-visible,
18
- :is(input, textarea, select, use-date, use-time, use-datetime, use-duration):not([data-appear-as="native"]):focus,
18
+ :is(input, textarea, select, use-date-input, use-time-input, use-datetime-input, use-duration-input):not(
19
+ [data-appear-as="native"]
20
+ ):focus,
19
21
  input[type="file"]:not([data-appear-as="native"]):focus-visible,
20
22
  use-dropdown:not([data-appear-as="native"])::part(trigger):focus-visible,
21
23
  [data-appear-as="input"]:has(input:focus) {
@@ -26,14 +28,14 @@
26
28
 
27
29
  :is(
28
30
  input:not(:is([type="checkbox"], [type="radio"], [type="range"], [type="file"], [data-appear-as])),
29
- select:not([data-appear-as="native"]),
31
+ select,
30
32
  textarea,
31
33
  [data-appear-as="input"],
32
- use-date:not([data-appear-as="native"]),
33
- use-time:not([data-appear-as="native"]),
34
- use-datetime:not([data-appear-as="native"]),
35
- use-duration:not([data-appear-as="native"])
36
- ),
34
+ use-date-input,
35
+ use-time-input,
36
+ use-datetime-input,
37
+ use-duration-input
38
+ ):not([data-appear-as="native"]),
37
39
  use-listbox-input:not([data-appear-as="native"])::part(listbox) {
38
40
  border: var(--usewc-layout-input-border) var(--usewc-effect-input-border-style)
39
41
  var(--usewc-color-input-border-static);
@@ -479,10 +481,58 @@
479
481
  }
480
482
 
481
483
  @layer web-components {
484
+ /* Composite datetime control — host gets the single input wrapper appearance via the main
485
+ input styling block. The date and time sub-inputs live in shadow DOM and are reached via
486
+ ::part(date) and ::part(time) to override their internal layout. Segment inputs are
487
+ re-exported via exportparts so ::part(segment-input) reaches them too. */
488
+ use-datetime-input:not([data-appear-as="native"]) {
489
+ display: inline-flex;
490
+ align-items: center;
491
+ width: fit-content;
492
+ gap: var(--usewc-layout-input-gap-inline);
493
+ padding-inline: calc(var(--usewc-layout-input-padding-inline) - var(--usewc-layout-input-segment-padding-inline));
494
+
495
+ &::part(date),
496
+ &::part(time) {
497
+ display: inline-flex;
498
+ align-items: center;
499
+ gap: var(--usewc-layout-input-segment-padding-inline);
500
+ }
501
+
502
+ &::part(segment-input) {
503
+ all: unset;
504
+ box-sizing: content-box;
505
+ appearance: none;
506
+ field-sizing: content;
507
+ background: var(--usewc-color-input-segment-background-static);
508
+ outline: none;
509
+ border-radius: var(--usewc-effect-input-border-radius);
510
+ min-width: 2ch;
511
+ width: fit-content;
512
+ text-align: end;
513
+ padding-inline: var(--usewc-layout-input-segment-padding-inline);
514
+ font-variant-numeric: tabular-nums;
515
+ }
516
+
517
+ &::part(segment-input-dayPeriod) {
518
+ text-align: center;
519
+ min-width: 2em;
520
+ padding-inline: 0;
521
+ }
522
+
523
+ &::part(segment-input):hover {
524
+ background: var(--usewc-color-input-segment-background-hover);
525
+ }
526
+
527
+ &::part(segment-input):focus,
528
+ &::selection {
529
+ background: var(--usewc-color-input-segment-background-focus);
530
+ color: var(--usewc-color-input-segment-text-focus);
531
+ }
532
+ }
533
+
482
534
  /* Segment based controls */
483
- :is(use-date, use-time, use-datetime, use-duration):not([data-appear-as="native"]),
484
- use-datetime::part(date),
485
- use-datetime::part(time) {
535
+ :is(use-date-input, use-time-input):not([data-appear-as="native"]) {
486
536
  display: inline-flex;
487
537
  align-items: center;
488
538
  width: fit-content;
@@ -521,17 +571,43 @@
521
571
  }
522
572
  }
523
573
 
524
- :is(use-datetime, use-duration):not([data-appear-as="native"]) {
574
+ use-duration-input:not([data-appear-as="native"]) {
575
+ display: inline-flex;
576
+ align-items: center;
577
+ width: fit-content;
525
578
  gap: var(--usewc-layout-input-gap-inline);
526
- }
527
-
528
- use-duration:not([data-appear-as="native"]) {
529
- padding-inline-end: var(--usewc-layout-input-padding-inline);
579
+ padding-inline: calc(var(--usewc-layout-input-padding-inline) - var(--usewc-layout-input-segment-padding-inline));
530
580
 
531
581
  &::part(segment) {
532
582
  display: inline-flex;
583
+ align-items: center;
533
584
  gap: var(--usewc-layout-input-segment-padding-inline);
534
585
  }
586
+
587
+ &::part(segment-input) {
588
+ all: unset;
589
+ box-sizing: content-box;
590
+ appearance: none;
591
+ field-sizing: content;
592
+ background: var(--usewc-color-input-segment-background-static);
593
+ outline: none;
594
+ border-radius: var(--usewc-effect-input-border-radius);
595
+ min-width: 2ch;
596
+ width: fit-content;
597
+ text-align: end;
598
+ padding-inline: var(--usewc-layout-input-segment-padding-inline);
599
+ font-variant-numeric: tabular-nums;
600
+ }
601
+
602
+ &::part(segment-input):hover {
603
+ background: var(--usewc-color-input-segment-background-hover);
604
+ }
605
+
606
+ &::part(segment-input):focus,
607
+ &::selection {
608
+ background: var(--usewc-color-input-segment-background-focus);
609
+ color: var(--usewc-color-input-segment-text-focus);
610
+ }
535
611
  }
536
612
 
537
613
  select:not([data-appear-as="native"]),
package/dist/use-wc.mjs CHANGED
@@ -367,9 +367,17 @@ let UseDateInput = class UseDateInput extends UseLocaleElement {
367
367
  ].join("-");
368
368
  this.#internals.setFormValue(this.#internalValue);
369
369
  }
370
+ #segmentMaximum = {
371
+ year: null,
372
+ month: 12,
373
+ day: 31
374
+ };
370
375
  #handleSegmentInput(segment) {
371
376
  return (event) => {
372
377
  const target = event.target;
378
+ const maximum = this.#segmentMaximum[segment];
379
+ const numericValue = parseInt(target.value, 10);
380
+ if (maximum !== null && !isNaN(numericValue) && numericValue > maximum) target.value = String(maximum);
373
381
  this.#valueData[segment] = target.value;
374
382
  this.#updateInternalValue();
375
383
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "use-wc",
3
- "version": "1.0.0-pre.39",
3
+ "version": "1.0.0-pre.40",
4
4
  "private": false,
5
5
  "homepage": "https://usewc.com",
6
6
  "bugs": "https://github.com/dang-rabbits/use-wc/issues",