use-wc 1.0.0-pre.60 → 1.0.0-pre.62

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.
@@ -767,6 +767,132 @@
767
767
  }
768
768
  ]
769
769
  },
770
+ {
771
+ "kind": "javascript-module",
772
+ "path": "src/elements/use-date-input/use-date-input.ts",
773
+ "declarations": [
774
+ {
775
+ "kind": "class",
776
+ "description": "Displays a date picker using segmented inputs for year, month, and day.\n\nUses browser locale for formatting and ARIA labels.",
777
+ "name": "UseDateInput",
778
+ "members": [
779
+ {
780
+ "kind": "field",
781
+ "name": "yearInput",
782
+ "type": {
783
+ "text": "HTMLInputElement"
784
+ }
785
+ },
786
+ {
787
+ "kind": "field",
788
+ "name": "monthInput",
789
+ "type": {
790
+ "text": "HTMLInputElement"
791
+ }
792
+ },
793
+ {
794
+ "kind": "field",
795
+ "name": "dayInput",
796
+ "type": {
797
+ "text": "HTMLInputElement"
798
+ }
799
+ },
800
+ {
801
+ "kind": "field",
802
+ "name": "id"
803
+ },
804
+ {
805
+ "kind": "field",
806
+ "name": "disabled",
807
+ "default": "false",
808
+ "type": {
809
+ "text": "boolean"
810
+ },
811
+ "attribute": "disabled"
812
+ },
813
+ {
814
+ "kind": "field",
815
+ "name": "readOnly",
816
+ "default": "false",
817
+ "type": {
818
+ "text": "boolean"
819
+ },
820
+ "attribute": "readonly"
821
+ },
822
+ {
823
+ "kind": "field",
824
+ "name": "value",
825
+ "type": {
826
+ "text": "string"
827
+ },
828
+ "default": "YYYY-MM-DD",
829
+ "attribute": "value"
830
+ }
831
+ ],
832
+ "attributes": [
833
+ {
834
+ "name": "disabled",
835
+ "default": "false",
836
+ "type": {
837
+ "text": "boolean"
838
+ },
839
+ "fieldName": "disabled"
840
+ },
841
+ {
842
+ "name": "readonly",
843
+ "default": "false",
844
+ "type": {
845
+ "text": "boolean"
846
+ },
847
+ "fieldName": "readOnly"
848
+ },
849
+ {
850
+ "name": "value",
851
+ "type": {
852
+ "text": "string"
853
+ },
854
+ "default": "YYYY-MM-DD",
855
+ "fieldName": "value"
856
+ },
857
+ {
858
+ "name": "lang",
859
+ "type": {
860
+ "text": "string"
861
+ },
862
+ "fieldName": "lang",
863
+ "inheritedFrom": {
864
+ "name": "UseLocaleElement",
865
+ "module": "src/elements/use-locale-element/use-locale-element.ts"
866
+ }
867
+ }
868
+ ],
869
+ "superclass": {
870
+ "name": "UseLocaleElement",
871
+ "module": "/src/elements/use-locale-element/use-locale-element"
872
+ },
873
+ "tagName": "use-date-input",
874
+ "customElement": true
875
+ }
876
+ ],
877
+ "exports": [
878
+ {
879
+ "kind": "js",
880
+ "name": "UseDateInput",
881
+ "declaration": {
882
+ "name": "UseDateInput",
883
+ "module": "src/elements/use-date-input/use-date-input.ts"
884
+ }
885
+ },
886
+ {
887
+ "kind": "custom-element-definition",
888
+ "name": "use-date-input",
889
+ "declaration": {
890
+ "name": "UseDateInput",
891
+ "module": "src/elements/use-date-input/use-date-input.ts"
892
+ }
893
+ }
894
+ ]
895
+ },
770
896
  {
771
897
  "kind": "javascript-module",
772
898
  "path": "src/elements/use-date-picker/use-date-picker.ts",
@@ -1430,132 +1556,6 @@
1430
1556
  }
1431
1557
  ]
1432
1558
  },
1433
- {
1434
- "kind": "javascript-module",
1435
- "path": "src/elements/use-date-input/use-date-input.ts",
1436
- "declarations": [
1437
- {
1438
- "kind": "class",
1439
- "description": "Displays a date picker using segmented inputs for year, month, and day.\n\nUses browser locale for formatting and ARIA labels.",
1440
- "name": "UseDateInput",
1441
- "members": [
1442
- {
1443
- "kind": "field",
1444
- "name": "yearInput",
1445
- "type": {
1446
- "text": "HTMLInputElement"
1447
- }
1448
- },
1449
- {
1450
- "kind": "field",
1451
- "name": "monthInput",
1452
- "type": {
1453
- "text": "HTMLInputElement"
1454
- }
1455
- },
1456
- {
1457
- "kind": "field",
1458
- "name": "dayInput",
1459
- "type": {
1460
- "text": "HTMLInputElement"
1461
- }
1462
- },
1463
- {
1464
- "kind": "field",
1465
- "name": "id"
1466
- },
1467
- {
1468
- "kind": "field",
1469
- "name": "disabled",
1470
- "default": "false",
1471
- "type": {
1472
- "text": "boolean"
1473
- },
1474
- "attribute": "disabled"
1475
- },
1476
- {
1477
- "kind": "field",
1478
- "name": "readOnly",
1479
- "default": "false",
1480
- "type": {
1481
- "text": "boolean"
1482
- },
1483
- "attribute": "readonly"
1484
- },
1485
- {
1486
- "kind": "field",
1487
- "name": "value",
1488
- "type": {
1489
- "text": "string"
1490
- },
1491
- "default": "YYYY-MM-DD",
1492
- "attribute": "value"
1493
- }
1494
- ],
1495
- "attributes": [
1496
- {
1497
- "name": "disabled",
1498
- "default": "false",
1499
- "type": {
1500
- "text": "boolean"
1501
- },
1502
- "fieldName": "disabled"
1503
- },
1504
- {
1505
- "name": "readonly",
1506
- "default": "false",
1507
- "type": {
1508
- "text": "boolean"
1509
- },
1510
- "fieldName": "readOnly"
1511
- },
1512
- {
1513
- "name": "value",
1514
- "type": {
1515
- "text": "string"
1516
- },
1517
- "default": "YYYY-MM-DD",
1518
- "fieldName": "value"
1519
- },
1520
- {
1521
- "name": "lang",
1522
- "type": {
1523
- "text": "string"
1524
- },
1525
- "fieldName": "lang",
1526
- "inheritedFrom": {
1527
- "name": "UseLocaleElement",
1528
- "module": "src/elements/use-locale-element/use-locale-element.ts"
1529
- }
1530
- }
1531
- ],
1532
- "superclass": {
1533
- "name": "UseLocaleElement",
1534
- "module": "/src/elements/use-locale-element/use-locale-element"
1535
- },
1536
- "tagName": "use-date-input",
1537
- "customElement": true
1538
- }
1539
- ],
1540
- "exports": [
1541
- {
1542
- "kind": "js",
1543
- "name": "UseDateInput",
1544
- "declaration": {
1545
- "name": "UseDateInput",
1546
- "module": "src/elements/use-date-input/use-date-input.ts"
1547
- }
1548
- },
1549
- {
1550
- "kind": "custom-element-definition",
1551
- "name": "use-date-input",
1552
- "declaration": {
1553
- "name": "UseDateInput",
1554
- "module": "src/elements/use-date-input/use-date-input.ts"
1555
- }
1556
- }
1557
- ]
1558
- },
1559
1559
  {
1560
1560
  "kind": "javascript-module",
1561
1561
  "path": "src/elements/use-datetime-input/use-datetime-input.ts",
@@ -1158,13 +1158,16 @@
1158
1158
  @layer use-theme.badge {
1159
1159
  use-badge {
1160
1160
  --usewc-layout-badge-offset: calc(var(--usewc-layout-badge-dot-size) / 3);
1161
- display: inline-block;
1161
+ display: inline-flex;
1162
+ align-items: center;
1163
+ justify-content: center;
1162
1164
  line-height: 1.5;
1163
1165
  border-radius: var(--usewc-effect-badge-border-radius);
1164
1166
  background: var(--usewc-color-badge-background-static);
1165
1167
  color: var(--usewc-color-badge-text-static);
1166
1168
  font-size: var(--usewc-font-badge-size);
1167
1169
  font-weight: var(--usewc-font-badge-weight);
1170
+ font-variant-numeric: tabular-nums;
1168
1171
  border: var(--usewc-layout-badge-border) solid var(--usewc-color-badge-border);
1169
1172
 
1170
1173
  use-theme-escape & {
@@ -1172,8 +1175,16 @@
1172
1175
  }
1173
1176
  }
1174
1177
 
1178
+ /* A content badge is at least as wide as it is tall — `block-size: 1lh` fixes the height to
1179
+ one line so a longer count can't grow it, `min-inline-size: 1lh` makes a single-glyph badge
1180
+ a circle, and a longer count grows the width out into a pill while the height holds.
1181
+ `tabular-nums` above keeps every digit the same advance width, so `1` and `8`, or `11` and
1182
+ `88`, are identical in size. The inline padding is `em`-relative and small enough that a
1183
+ one-digit count still clears the `1lh` floor rather than widening past it. */
1175
1184
  use-badge:not([dot]) {
1176
1185
  --usewc-layout-badge-offset: 0.5lh;
1186
+ block-size: 1lh;
1187
+ min-inline-size: 1lh;
1177
1188
  padding-inline: var(--usewc-layout-badge-padding-inline);
1178
1189
 
1179
1190
  use-theme-escape & {
@@ -1810,7 +1821,7 @@
1810
1821
  }
1811
1822
 
1812
1823
  /* Popover — a native `[popover]` element already provides the overlay mechanics (top-layer
1813
- promotion, light-dismiss, `::backdrop`) for free. Themed by default, like the rest of this
1824
+ promotion, light-dismiss) for free. Themed by default, like the rest of this
1814
1825
  family's native elements — `:not(.appearance-native)` is the escape hatch, matching
1815
1826
  `input.css`/`select.css`'s convention, not an opt-in class like `dialog.drawer` (a `<dialog>`
1816
1827
  needs a class for that one variant since plain and drawer dialogs share one tag; `[popover]`
@@ -1819,6 +1830,11 @@
1819
1830
  otherwise — this only replaces the UA default chrome with the shared `surface` tokens,
1820
1831
  matching `dialog`/`use-card`.
1821
1832
 
1833
+ The `::backdrop` is deliberately left at its transparent UA default: a `[popover]` at
1834
+ `popover="auto"` is non-modal — the page stays interactive and an outside click dismisses it
1835
+ — so a tint would misrepresent it as modal. That backdrop tint lives in `dialog.css`, where
1836
+ `showModal()` makes it real.
1837
+
1822
1838
  `:not(use-menu)` excludes the one component that self-applies `popover="auto"` and ships its
1823
1839
  own distinct chrome in `menu.css`: cascade layers always beat specificity, so without this
1824
1840
  exclusion `use-menu:popover-open`'s more specific rule would still lose to this layer, which
@@ -1840,14 +1856,6 @@
1840
1856
  all: revert-layer;
1841
1857
  }
1842
1858
  }
1843
-
1844
- [popover]:not(use-menu, .appearance-native)::backdrop {
1845
- background: var(--usewc-color-surface-backdrop);
1846
-
1847
- use-theme-escape & {
1848
- all: revert-layer;
1849
- }
1850
- }
1851
1859
  }
1852
1860
 
1853
1861
  /* Shell — `use-shell` is a theme-only tag (no registration, styled by tag name like
@@ -1910,11 +1918,25 @@
1910
1918
 
1911
1919
  /* Surface regions — header/poster/footer styling shared by the three surface hosts (`dialog`,
1912
1920
  `use-card`, `[popover]`), scoped to them specifically rather than to bare `use-shell`: this is
1913
- a surface-family visual convention (avatar sizing, trailing-action pinning, a footer rule),
1914
- not something every generic `use-shell` consumer elsewhere in the app should inherit.
1921
+ a surface-family visual convention (the anchored-gap offset, avatar sizing, trailing-action
1922
+ pinning, a footer rule), not something every generic `use-shell` consumer should inherit.
1915
1923
  Everything here rides on top of `shell.css`'s flex mechanic — this only adds padding, gaps,
1916
1924
  and per-region treatment. */
1917
1925
  @layer use-theme.surface {
1926
+ /* An anchored surface keeps a small gap from its anchor, the same convention `use-menu`
1927
+ follows in `menu.css`. Scoped to `use-anchored`'s direct child — the one reliable "this is
1928
+ anchored" signal — so a standalone `[popover]` or modal `<dialog>` elsewhere keeps its UA
1929
+ centering. `margin-block` (both edges) so the gap survives a `position-try` flip to the
1930
+ other side. The open-state check mirrors the positioning util: `:popover-open` for a
1931
+ popover, `[open]` for a `<dialog>`. */
1932
+ use-anchored > :is(dialog, [popover]):not(use-menu, .appearance-native):is([open], :popover-open) {
1933
+ margin-block: var(--usewc-layout-surface-anchor-offset);
1934
+
1935
+ use-theme-escape & {
1936
+ all: revert-layer;
1937
+ }
1938
+ }
1939
+
1918
1940
  :is(dialog:not(.appearance-native), use-card, [popover]:not(use-menu, .appearance-native)) > figure {
1919
1941
  margin: 0;
1920
1942
 
package/dist/tokens.css CHANGED
@@ -532,15 +532,14 @@
532
532
  --usewc-font-button-extra-large-size: var(--usewc-font-size-20);
533
533
  --usewc-layout-button-extra-large-line-height: var(--usewc-line-height-32);
534
534
 
535
- /* Badge */
536
- --usewc-color-badge-background-static: var(--usewc-color-brand-accent);
537
- /* Scaled rather than a fixed white/black: the accent is light enough (2.99:1 with white text,
538
- vs. 7.03:1 with black) that a static color would misjudge it, and would silently stop
539
- matching if the accent itself is ever overridden. */
540
- --usewc-color-badge-text-static: contrast-color(var(--usewc-color-badge-background-static));
535
+ /* Badge — a rose fill with white text: a warm pink-red that stays clear of the danger red's
536
+ hue and the primary blue, so a count badge doesn't read as an error or a button. The fill
537
+ is a fixed shade in both themes (like the primary/danger fills), so no dark-mode override
538
+ is needed. */
539
+ --usewc-color-badge-background-static: oklch(0.62 0.2 12);
540
+ --usewc-color-badge-text-static: var(--usewc-color-white);
541
541
  --usewc-color-badge-border: var(--usewc-color-document-background);
542
- --usewc-layout-badge-padding-inline: var(--usewc-space-6);
543
- --usewc-layout-badge-min-size: var(--usewc-space-16);
542
+ --usewc-layout-badge-padding-inline: var(--usewc-space-4-relative);
544
543
  --usewc-layout-badge-dot-size: var(--usewc-space-12);
545
544
  --usewc-layout-badge-border: var(--usewc-space-1);
546
545
  --usewc-font-badge-size: var(--usewc-font-size-12);
@@ -612,7 +611,7 @@
612
611
  --usewc-color-popover-menu-item-background-hover: var(--usewc-color-selector-background-hover);
613
612
  --usewc-color-popover-menu-item-background-active: var(--usewc-color-selector-background-hover);
614
613
  --usewc-effect-popover-menu-item-border-radius: var(--usewc-effect-border-radius-4);
615
- --usewc-layout-popover-menu-anchor-offset: var(--usewc-space-4);
614
+ --usewc-layout-popover-menu-anchor-offset: var(--usewc-layout-surface-anchor-offset);
616
615
  --usewc-layout-popover-menu-padding: var(--usewc-space-4);
617
616
  --usewc-layout-popover-menu-border: var(--usewc-space-1-relative);
618
617
  --usewc-effect-popover-menu-border-style: var(--usewc-effect-border-solid);
@@ -639,11 +638,13 @@
639
638
  --usewc-font-code-size: var(--usewc-font-size-14);
640
639
 
641
640
  /* Surface — shared by every surface host (dialog, use-card, [popover]): the visible chrome
642
- (background/border/radius/shadow), the backdrop behind an overlaid one, and the internal
643
- header/poster/footer region layout they all apply the same way. */
641
+ (background/border/radius/shadow), the backdrop behind a modal `<dialog>` (non-modal
642
+ `[popover]` keeps its transparent UA backdrop), the gap an anchored surface keeps from its
643
+ anchor, and the internal header/poster/footer region layout they all apply the same way. */
644
644
  --usewc-color-surface-background: var(--usewc-color-canvas-background);
645
645
  --usewc-color-surface-border: var(--usewc-color-button-base-border-static);
646
646
  --usewc-color-surface-backdrop: oklch(0% 0 0 / 0.4);
647
+ --usewc-layout-surface-anchor-offset: var(--usewc-space-4);
647
648
  --usewc-layout-surface-border: var(--usewc-space-1);
648
649
  --usewc-effect-surface-border-radius: var(--usewc-effect-border-radius-8);
649
650
  --usewc-effect-surface-shadow: var(--usewc-effect-shadow-raised);
package/dist/use-wc.mjs CHANGED
@@ -4471,21 +4471,22 @@ let UseBadge = class UseBadge extends LitElement {
4471
4471
  align-items: center;
4472
4472
  justify-content: center;
4473
4473
  box-sizing: border-box;
4474
- min-inline-size: 1rem;
4475
- min-block-size: 1rem;
4476
- padding-inline: 0.375rem;
4474
+ padding-inline: 0.25em;
4477
4475
  border-radius: 9999px;
4478
4476
  background: CanvasText;
4479
4477
  border: 1px solid currentColor;
4480
4478
  color: Canvas;
4481
4479
  font-size: 0.75rem;
4482
4480
  font-weight: 500;
4483
- line-height: 1;
4481
+ line-height: 1.5;
4482
+ font-variant-numeric: tabular-nums;
4484
4483
  white-space: nowrap;
4485
4484
  }
4486
4485
 
4487
4486
  :host(:not([dot])) {
4488
4487
  --usewc-badge-offset: 0.5lh;
4488
+ block-size: 1lh;
4489
+ min-inline-size: 1lh;
4489
4490
  }
4490
4491
 
4491
4492
  :host(:state(anchored)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "use-wc",
3
- "version": "1.0.0-pre.60",
3
+ "version": "1.0.0-pre.62",
4
4
  "private": false,
5
5
  "homepage": "https://usewc.com",
6
6
  "bugs": "https://github.com/dang-rabbits/use-wc/issues",
@@ -63,6 +63,17 @@
63
63
  "attributes": [],
64
64
  "references": []
65
65
  },
66
+ {
67
+ "name": "use-date-input",
68
+ "description": "Displays a date picker using segmented inputs for year, month, and day.\n\nUses browser locale for formatting and ARIA labels.\n---\n",
69
+ "attributes": [
70
+ { "name": "disabled", "values": [] },
71
+ { "name": "readonly", "values": [] },
72
+ { "name": "value", "values": [] },
73
+ { "name": "lang", "values": [] }
74
+ ],
75
+ "references": []
76
+ },
66
77
  {
67
78
  "name": "use-date-picker",
68
79
  "description": "A day-granularity date picker. Value format: YYYY-MM-DD.\n\nCustomize day rendering on an instance:\n```ts\ndatePicker.renderDay = ({ day, date }, html) =>\n date === \"2026-03-17\" ? html`<strong>${day}</strong>` : String(day);\n```\n\nOr override on a subclass to apply it to every instance, falling back to\n`super.renderDay(...)` for dates you don't want to customize:\n```ts\nclass MyDatePicker extends UseDatePicker {\n renderDay(data: { day: number; date: string }, html: LitHtml) {\n if (data.date === \"2026-03-17\") {\n return html`<strong>${data.day}</strong>`;\n }\n return super.renderDay(data, html);\n }\n}\n```\n---\n\n\n### **Events:**\n - **use-change** - Fired on selection with detail `{ value: string }`\n\n### **Methods:**\n - **renderDay(data: _{ day: number; date: string }_, _html: _LitHtml_): _TemplateResult | string_** - See UseCalendarRenderDay. Assigning a new function on an\ninstance (e.g. via `.renderDay=${fn}` in a Lit template) after first\nrender does not schedule a re-render on its own — call `requestUpdate()`\nif needed.\n\nDeclared as a regular method rather than a class field so subclass\noverrides can call `super.renderDay(data, html)` to fall back to the\ndefault (or a parent override's) rendering.\n\n### **Slots:**\n - **header-start** - Content before the title in the header\n- **title** - Title showing the month and year\n- **controls** - Navigation controls (previous, today, next buttons)\n- **header-end** - Content after the controls in the header\n- **date-{YYYY-MM-DD}** - Per-date content that replaces the default day number\n\n### **CSS Parts:**\n - **header** - The header container\n- **title** - The title text\n- **title-month** - The month part of the title\n- **title-literal** - Literal text in the title\n- **title-year** - The year part of the title\n- **controls** - The controls slot container\n- **control** - Individual control button\n- **control-previous** - Previous month button\n- **control-today** - Today button\n- **control-next** - Next month button\n- **grid** - The main calendar grid\n- **grid-header** - The header row with day names\n- **grid-header-cell** - Individual day name header cell\n- **grid-body** - The container for calendar weeks\n- **row** - A row of days\n- **day** - A day cell\n- **day-empty** - An empty day cell (from previous/next month)\n- **day-selected** - A selected day cell\n- **day-today** - The current date cell\n- **day-disabled** - A disabled date cell\n- **title-button** - The clickable button wrapping the month/year title\n- **picker** - The scrollable month/year picker panel (replaces grid when open)\n- **picker-year-section** - Container for one year's label and month grid\n- **picker-year-label** - The year heading inside a year section\n- **picker-months** - The 4-column month grid inside a year section\n- **picker-month** - An individual month button\n- **picker-month-current** - Applied to the currently selected month button",
@@ -96,17 +107,6 @@
96
107
  ],
97
108
  "references": []
98
109
  },
99
- {
100
- "name": "use-date-input",
101
- "description": "Displays a date picker using segmented inputs for year, month, and day.\n\nUses browser locale for formatting and ARIA labels.\n---\n",
102
- "attributes": [
103
- { "name": "disabled", "values": [] },
104
- { "name": "readonly", "values": [] },
105
- { "name": "value", "values": [] },
106
- { "name": "lang", "values": [] }
107
- ],
108
- "references": []
109
- },
110
110
  {
111
111
  "name": "use-datetime-input",
112
112
  "description": "Displays a date and time picker by combining `use-date` and `use-time`.\n\nThe value format is ISO 8601-like: `YYYY-MM-DDTHH:MM:SS.mmm`.\n---\n",