use-wc 1.0.0-pre.57 → 1.0.0-pre.59
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/custom-elements.json +244 -65
- package/dist/design-system.css +310 -0
- package/dist/docs/use-intl-number.md +30 -0
- package/dist/tokens.css +18 -0
- package/dist/use-wc.d.mts +47 -1
- package/dist/use-wc.mjs +107 -1
- package/package.json +1 -1
- package/vscode.html-custom-data.json +58 -6
package/custom-elements.json
CHANGED
|
@@ -702,6 +702,71 @@
|
|
|
702
702
|
}
|
|
703
703
|
]
|
|
704
704
|
},
|
|
705
|
+
{
|
|
706
|
+
"kind": "javascript-module",
|
|
707
|
+
"path": "src/elements/use-caret/use-caret.ts",
|
|
708
|
+
"declarations": [
|
|
709
|
+
{
|
|
710
|
+
"kind": "class",
|
|
711
|
+
"description": "`use-caret` supplies the caret icon and label layout for a consumer who wants to own the\ninvoking button itself. It renders inside a plain `<button>`\nthat carries the native `popovertarget` attribute, pointing at a `use-menu`:\n\n```html\n<button id=\"thing\" popovertarget=\"thing-menu\">\n <use-caret>Menu</use-caret>\n</button>\n<use-menu id=\"thing-menu\" aria-label=\"Menu\">\n <button role=\"menuitem\">First thing</button>\n</use-menu>\n```\n\n`use-menu` finds this button on its own via `popovertarget` and anchors to it — no\n`anchortarget` needed here; that's only for a menu with more than one invoker. See `use-menu`'s\nown docs for that case.\n\nThe button is entirely the consumer's own element — their classes, their content, their event\nhandlers. `use-caret` contributes no interactivity of its own: no internal button, no focus\ntarget, no state. It only renders the label and caret glyph, so consumers get a consistent\nvisual trigger without giving up control of the button.\n\nThe caret direction is derived rather than configured: a trigger nested inside a `use-menu`\nis understood to open a submenu and renders pointing sideways; a top-level trigger renders\npointing down.\n\nSwapping in a different caret **per instance** is a slot: put your own element in the `icon`\nslot and it replaces `part(icon-default)` entirely for that trigger.\n\nSwapping the default caret **for every trigger in the app** doesn't need touching this\ncomponent's `render()` at all — style `::part(icon-default)` from an outside stylesheet, the\nsame way any shadow DOM part is themed:\n\n```css\nuse-caret::part(icon-default) {\n mask-image: url(\"/icons/my-caret.svg\");\n}\n```\n\n(When the design system's `theme.css` is loaded, this is already wired to a token —\n`--usewc-effect-dropdown-trigger-icon-mask-image` — so redefining that custom property has\nthe same effect without writing a `::part()` rule at all.)\n\n`::part()` only reaches CSS-expressible changes (a mask, a background, a transform). For\nanything else — different markup, an icon font, logic beyond a mask — set the static `icon`\nand `nestedIcon` hooks. Every `<use-caret>` in the page picks them up; consumers keep writing\nthe same tag, no new element to register or remember to use instead. `icon` supplies a\ntop-level trigger's glyph, `nestedIcon` a submenu trigger's — set whichever apply; an unset one\nkeeps the built-in ▼/▶ for that case. Set them once, as early as possible (an app's entry\npoint, before any triggers connect) — Lit calls `render()` fresh on every update, so an\nalready-connected instance only reflects the change once something causes it to re-render:\n\n```ts\n// A bare string or TemplateResult is used as-is, on every trigger of that kind:\nUseCaret.icon = \"▾\";\nUseCaret.nestedIcon = \"▸\";\n\n// A function is called on every render instead:\nUseCaret.nestedIcon = (html) => html`<my-icon name=\"chevron-right\"></my-icon>`;\n```\n\nThe function form is called with the component's own `html` tag as its (optional) first\nargument rather than requiring the caller to import one — a page can end up with more than one\ncopy of `lit-html` in its module graph, and a `TemplateResult` built from a *different* copy\nthan the one this component renders with can silently fail to render. Taking `html` in as a\nparameter sidesteps that: whatever's returned is guaranteed to come from the same `lit-html`\nthis component already uses. A bare string skips the concern entirely.\n\nOnly need to change the icon on **some** triggers, not every one in the app? Extend the\nclass, override `render()` normally, and register the subclass under a different tag name so\nit coexists with the built-in element instead of replacing it everywhere:\n\n```ts\nclass MyCaret extends UseCaret {\n override render() {\n return html`<slot></slot><slot name=\"icon\"><my-icon name=\"chevron\"></my-icon></slot>`;\n }\n}\ncustomElements.define(\"my-caret\", MyCaret);\n```",
|
|
712
|
+
"name": "UseCaret",
|
|
713
|
+
"slots": [
|
|
714
|
+
{
|
|
715
|
+
"description": "Trigger label content.",
|
|
716
|
+
"name": "default"
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
"description": "Replaces the default caret glyph.",
|
|
720
|
+
"name": "icon"
|
|
721
|
+
}
|
|
722
|
+
],
|
|
723
|
+
"members": [
|
|
724
|
+
{
|
|
725
|
+
"kind": "field",
|
|
726
|
+
"name": "icon",
|
|
727
|
+
"type": {
|
|
728
|
+
"text": "((html: HtmlTag) => TemplateResult | string) | TemplateResult | string | undefined"
|
|
729
|
+
},
|
|
730
|
+
"static": true,
|
|
731
|
+
"description": "Global override for a top-level trigger's caret. When set, every non-nested `<use-caret>` in\nthe page renders this inside `part(icon-default)` instead of the built-in ▼ character. A\nplain string or `TemplateResult` is used as-is; the function form is called with the\ncomponent's own `html` tag, so a returned template is guaranteed to come from the same\n`lit-html` instance this component renders with. Unset (the default) keeps the built-in ▼."
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
"kind": "field",
|
|
735
|
+
"name": "nestedIcon",
|
|
736
|
+
"type": {
|
|
737
|
+
"text": "((html: HtmlTag) => TemplateResult | string) | TemplateResult | string | undefined"
|
|
738
|
+
},
|
|
739
|
+
"static": true,
|
|
740
|
+
"description": "Global override for a submenu trigger's caret — the counterpart to icon for a\n`<use-caret>` nested inside a `use-menu`. Unset (the default) keeps the built-in ▶."
|
|
741
|
+
}
|
|
742
|
+
],
|
|
743
|
+
"superclass": {
|
|
744
|
+
"name": "LitElement",
|
|
745
|
+
"package": "lit"
|
|
746
|
+
},
|
|
747
|
+
"tagName": "use-caret",
|
|
748
|
+
"customElement": true
|
|
749
|
+
}
|
|
750
|
+
],
|
|
751
|
+
"exports": [
|
|
752
|
+
{
|
|
753
|
+
"kind": "js",
|
|
754
|
+
"name": "UseCaret",
|
|
755
|
+
"declaration": {
|
|
756
|
+
"name": "UseCaret",
|
|
757
|
+
"module": "src/elements/use-caret/use-caret.ts"
|
|
758
|
+
}
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
"kind": "custom-element-definition",
|
|
762
|
+
"name": "use-caret",
|
|
763
|
+
"declaration": {
|
|
764
|
+
"name": "UseCaret",
|
|
765
|
+
"module": "src/elements/use-caret/use-caret.ts"
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
]
|
|
769
|
+
},
|
|
705
770
|
{
|
|
706
771
|
"kind": "javascript-module",
|
|
707
772
|
"path": "src/elements/use-date-input/use-date-input.ts",
|
|
@@ -828,71 +893,6 @@
|
|
|
828
893
|
}
|
|
829
894
|
]
|
|
830
895
|
},
|
|
831
|
-
{
|
|
832
|
-
"kind": "javascript-module",
|
|
833
|
-
"path": "src/elements/use-caret/use-caret.ts",
|
|
834
|
-
"declarations": [
|
|
835
|
-
{
|
|
836
|
-
"kind": "class",
|
|
837
|
-
"description": "`use-caret` supplies the caret icon and label layout for a consumer who wants to own the\ninvoking button itself. It renders inside a plain `<button>`\nthat carries the native `popovertarget` attribute, pointing at a `use-menu`:\n\n```html\n<button id=\"thing\" popovertarget=\"thing-menu\">\n <use-caret>Menu</use-caret>\n</button>\n<use-menu id=\"thing-menu\" aria-label=\"Menu\">\n <button role=\"menuitem\">First thing</button>\n</use-menu>\n```\n\n`use-menu` finds this button on its own via `popovertarget` and anchors to it — no\n`anchortarget` needed here; that's only for a menu with more than one invoker. See `use-menu`'s\nown docs for that case.\n\nThe button is entirely the consumer's own element — their classes, their content, their event\nhandlers. `use-caret` contributes no interactivity of its own: no internal button, no focus\ntarget, no state. It only renders the label and caret glyph, so consumers get a consistent\nvisual trigger without giving up control of the button.\n\nThe caret direction is derived rather than configured: a trigger nested inside a `use-menu`\nis understood to open a submenu and renders pointing sideways; a top-level trigger renders\npointing down.\n\nSwapping in a different caret **per instance** is a slot: put your own element in the `icon`\nslot and it replaces `part(icon-default)` entirely for that trigger.\n\nSwapping the default caret **for every trigger in the app** doesn't need touching this\ncomponent's `render()` at all — style `::part(icon-default)` from an outside stylesheet, the\nsame way any shadow DOM part is themed:\n\n```css\nuse-caret::part(icon-default) {\n mask-image: url(\"/icons/my-caret.svg\");\n}\n```\n\n(When the design system's `theme.css` is loaded, this is already wired to a token —\n`--usewc-effect-dropdown-trigger-icon-mask-image` — so redefining that custom property has\nthe same effect without writing a `::part()` rule at all.)\n\n`::part()` only reaches CSS-expressible changes (a mask, a background, a transform). For\nanything else — different markup, an icon font, logic beyond a mask — set the static `icon`\nand `nestedIcon` hooks. Every `<use-caret>` in the page picks them up; consumers keep writing\nthe same tag, no new element to register or remember to use instead. `icon` supplies a\ntop-level trigger's glyph, `nestedIcon` a submenu trigger's — set whichever apply; an unset one\nkeeps the built-in ▼/▶ for that case. Set them once, as early as possible (an app's entry\npoint, before any triggers connect) — Lit calls `render()` fresh on every update, so an\nalready-connected instance only reflects the change once something causes it to re-render:\n\n```ts\n// A bare string or TemplateResult is used as-is, on every trigger of that kind:\nUseCaret.icon = \"▾\";\nUseCaret.nestedIcon = \"▸\";\n\n// A function is called on every render instead:\nUseCaret.nestedIcon = (html) => html`<my-icon name=\"chevron-right\"></my-icon>`;\n```\n\nThe function form is called with the component's own `html` tag as its (optional) first\nargument rather than requiring the caller to import one — a page can end up with more than one\ncopy of `lit-html` in its module graph, and a `TemplateResult` built from a *different* copy\nthan the one this component renders with can silently fail to render. Taking `html` in as a\nparameter sidesteps that: whatever's returned is guaranteed to come from the same `lit-html`\nthis component already uses. A bare string skips the concern entirely.\n\nOnly need to change the icon on **some** triggers, not every one in the app? Extend the\nclass, override `render()` normally, and register the subclass under a different tag name so\nit coexists with the built-in element instead of replacing it everywhere:\n\n```ts\nclass MyCaret extends UseCaret {\n override render() {\n return html`<slot></slot><slot name=\"icon\"><my-icon name=\"chevron\"></my-icon></slot>`;\n }\n}\ncustomElements.define(\"my-caret\", MyCaret);\n```",
|
|
838
|
-
"name": "UseCaret",
|
|
839
|
-
"slots": [
|
|
840
|
-
{
|
|
841
|
-
"description": "Trigger label content.",
|
|
842
|
-
"name": "default"
|
|
843
|
-
},
|
|
844
|
-
{
|
|
845
|
-
"description": "Replaces the default caret glyph.",
|
|
846
|
-
"name": "icon"
|
|
847
|
-
}
|
|
848
|
-
],
|
|
849
|
-
"members": [
|
|
850
|
-
{
|
|
851
|
-
"kind": "field",
|
|
852
|
-
"name": "icon",
|
|
853
|
-
"type": {
|
|
854
|
-
"text": "((html: HtmlTag) => TemplateResult | string) | TemplateResult | string | undefined"
|
|
855
|
-
},
|
|
856
|
-
"static": true,
|
|
857
|
-
"description": "Global override for a top-level trigger's caret. When set, every non-nested `<use-caret>` in\nthe page renders this inside `part(icon-default)` instead of the built-in ▼ character. A\nplain string or `TemplateResult` is used as-is; the function form is called with the\ncomponent's own `html` tag, so a returned template is guaranteed to come from the same\n`lit-html` instance this component renders with. Unset (the default) keeps the built-in ▼."
|
|
858
|
-
},
|
|
859
|
-
{
|
|
860
|
-
"kind": "field",
|
|
861
|
-
"name": "nestedIcon",
|
|
862
|
-
"type": {
|
|
863
|
-
"text": "((html: HtmlTag) => TemplateResult | string) | TemplateResult | string | undefined"
|
|
864
|
-
},
|
|
865
|
-
"static": true,
|
|
866
|
-
"description": "Global override for a submenu trigger's caret — the counterpart to icon for a\n`<use-caret>` nested inside a `use-menu`. Unset (the default) keeps the built-in ▶."
|
|
867
|
-
}
|
|
868
|
-
],
|
|
869
|
-
"superclass": {
|
|
870
|
-
"name": "LitElement",
|
|
871
|
-
"package": "lit"
|
|
872
|
-
},
|
|
873
|
-
"tagName": "use-caret",
|
|
874
|
-
"customElement": true
|
|
875
|
-
}
|
|
876
|
-
],
|
|
877
|
-
"exports": [
|
|
878
|
-
{
|
|
879
|
-
"kind": "js",
|
|
880
|
-
"name": "UseCaret",
|
|
881
|
-
"declaration": {
|
|
882
|
-
"name": "UseCaret",
|
|
883
|
-
"module": "src/elements/use-caret/use-caret.ts"
|
|
884
|
-
}
|
|
885
|
-
},
|
|
886
|
-
{
|
|
887
|
-
"kind": "custom-element-definition",
|
|
888
|
-
"name": "use-caret",
|
|
889
|
-
"declaration": {
|
|
890
|
-
"name": "UseCaret",
|
|
891
|
-
"module": "src/elements/use-caret/use-caret.ts"
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
]
|
|
895
|
-
},
|
|
896
896
|
{
|
|
897
897
|
"kind": "javascript-module",
|
|
898
898
|
"path": "src/elements/use-date-picker/use-date-picker.ts",
|
|
@@ -2748,6 +2748,185 @@
|
|
|
2748
2748
|
}
|
|
2749
2749
|
]
|
|
2750
2750
|
},
|
|
2751
|
+
{
|
|
2752
|
+
"kind": "javascript-module",
|
|
2753
|
+
"path": "src/elements/use-intl-number/use-intl-number.ts",
|
|
2754
|
+
"declarations": [
|
|
2755
|
+
{
|
|
2756
|
+
"kind": "class",
|
|
2757
|
+
"description": "Displays a localized, human-readable representation of a number using\n[`Intl.NumberFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat).\nRenders a semantic `<data>` element in its shadow root with a machine-readable\n`value` attribute and formatted inner text.\n\nSet `numberstyle` to control what kind of number is formatted (see\n[`style`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#style)):\n- `decimal` (default) → plain number, e.g. `1,234.5`\n- `percent` → percentage, e.g. `42%` (value is the fraction, so `0.42` renders `42%`)\n- `currency` → currency amount, requires `currency`\n- `unit` → measurement, requires `unit`\n\nLocale is resolved from the nearest ancestor `[lang]` attribute, or\n`navigator.language` if none is found. Set `lang` directly on the element to override.",
|
|
2758
|
+
"name": "UseIntlNumber",
|
|
2759
|
+
"members": [
|
|
2760
|
+
{
|
|
2761
|
+
"kind": "field",
|
|
2762
|
+
"name": "value",
|
|
2763
|
+
"type": {
|
|
2764
|
+
"text": "string | undefined"
|
|
2765
|
+
},
|
|
2766
|
+
"attribute": "value"
|
|
2767
|
+
},
|
|
2768
|
+
{
|
|
2769
|
+
"kind": "field",
|
|
2770
|
+
"name": "numberstyle",
|
|
2771
|
+
"type": {
|
|
2772
|
+
"text": "string | undefined"
|
|
2773
|
+
},
|
|
2774
|
+
"attribute": "numberstyle"
|
|
2775
|
+
},
|
|
2776
|
+
{
|
|
2777
|
+
"kind": "field",
|
|
2778
|
+
"name": "currency",
|
|
2779
|
+
"type": {
|
|
2780
|
+
"text": "string | undefined"
|
|
2781
|
+
},
|
|
2782
|
+
"attribute": "currency"
|
|
2783
|
+
},
|
|
2784
|
+
{
|
|
2785
|
+
"kind": "field",
|
|
2786
|
+
"name": "currencydisplay",
|
|
2787
|
+
"type": {
|
|
2788
|
+
"text": "string | undefined"
|
|
2789
|
+
},
|
|
2790
|
+
"attribute": "currencydisplay"
|
|
2791
|
+
},
|
|
2792
|
+
{
|
|
2793
|
+
"kind": "field",
|
|
2794
|
+
"name": "currencysign",
|
|
2795
|
+
"type": {
|
|
2796
|
+
"text": "string | undefined"
|
|
2797
|
+
},
|
|
2798
|
+
"attribute": "currencysign"
|
|
2799
|
+
},
|
|
2800
|
+
{
|
|
2801
|
+
"kind": "field",
|
|
2802
|
+
"name": "unit",
|
|
2803
|
+
"type": {
|
|
2804
|
+
"text": "string | undefined"
|
|
2805
|
+
},
|
|
2806
|
+
"attribute": "unit"
|
|
2807
|
+
},
|
|
2808
|
+
{
|
|
2809
|
+
"kind": "field",
|
|
2810
|
+
"name": "unitdisplay",
|
|
2811
|
+
"type": {
|
|
2812
|
+
"text": "string | undefined"
|
|
2813
|
+
},
|
|
2814
|
+
"attribute": "unitdisplay"
|
|
2815
|
+
},
|
|
2816
|
+
{
|
|
2817
|
+
"kind": "field",
|
|
2818
|
+
"name": "signdisplay",
|
|
2819
|
+
"type": {
|
|
2820
|
+
"text": "string | undefined"
|
|
2821
|
+
},
|
|
2822
|
+
"attribute": "signdisplay"
|
|
2823
|
+
}
|
|
2824
|
+
],
|
|
2825
|
+
"attributes": [
|
|
2826
|
+
{
|
|
2827
|
+
"type": {
|
|
2828
|
+
"text": "string | undefined"
|
|
2829
|
+
},
|
|
2830
|
+
"description": "Numeric amount to format",
|
|
2831
|
+
"name": "value",
|
|
2832
|
+
"fieldName": "value"
|
|
2833
|
+
},
|
|
2834
|
+
{
|
|
2835
|
+
"type": {
|
|
2836
|
+
"text": "string | undefined"
|
|
2837
|
+
},
|
|
2838
|
+
"description": "Format style: `decimal` | `percent` | `currency` | `unit`",
|
|
2839
|
+
"name": "numberstyle",
|
|
2840
|
+
"fieldName": "numberstyle"
|
|
2841
|
+
},
|
|
2842
|
+
{
|
|
2843
|
+
"type": {
|
|
2844
|
+
"text": "string | undefined"
|
|
2845
|
+
},
|
|
2846
|
+
"description": "[ISO 4217 currency code](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currency), e.g. `USD`, `EUR`, `JPY`. Required when numberstyle is `currency`",
|
|
2847
|
+
"name": "currency",
|
|
2848
|
+
"fieldName": "currency"
|
|
2849
|
+
},
|
|
2850
|
+
{
|
|
2851
|
+
"type": {
|
|
2852
|
+
"text": "string | undefined"
|
|
2853
|
+
},
|
|
2854
|
+
"description": "[How the currency is denoted](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencydisplay): `symbol` | `narrowSymbol` | `code` | `name`",
|
|
2855
|
+
"name": "currencydisplay",
|
|
2856
|
+
"fieldName": "currencydisplay"
|
|
2857
|
+
},
|
|
2858
|
+
{
|
|
2859
|
+
"type": {
|
|
2860
|
+
"text": "string | undefined"
|
|
2861
|
+
},
|
|
2862
|
+
"description": "[Sign convention](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencysign): `standard` (minus sign) | `accounting` (parenthesized negatives)",
|
|
2863
|
+
"name": "currencysign",
|
|
2864
|
+
"fieldName": "currencysign"
|
|
2865
|
+
},
|
|
2866
|
+
{
|
|
2867
|
+
"type": {
|
|
2868
|
+
"text": "string | undefined"
|
|
2869
|
+
},
|
|
2870
|
+
"description": "[Unit identifier](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#unit), e.g. `kilometer-per-hour`, `liter`. Required when numberstyle is `unit`",
|
|
2871
|
+
"name": "unit",
|
|
2872
|
+
"fieldName": "unit"
|
|
2873
|
+
},
|
|
2874
|
+
{
|
|
2875
|
+
"type": {
|
|
2876
|
+
"text": "string | undefined"
|
|
2877
|
+
},
|
|
2878
|
+
"description": "[How the unit is denoted](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#unitdisplay): `short` | `narrow` | `long`",
|
|
2879
|
+
"name": "unitdisplay",
|
|
2880
|
+
"fieldName": "unitdisplay"
|
|
2881
|
+
},
|
|
2882
|
+
{
|
|
2883
|
+
"type": {
|
|
2884
|
+
"text": "string | undefined"
|
|
2885
|
+
},
|
|
2886
|
+
"description": "[When to show the sign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#signdisplay): `auto` | `always` | `exceptZero` | `never`",
|
|
2887
|
+
"name": "signdisplay",
|
|
2888
|
+
"fieldName": "signdisplay"
|
|
2889
|
+
},
|
|
2890
|
+
{
|
|
2891
|
+
"name": "lang",
|
|
2892
|
+
"type": {
|
|
2893
|
+
"text": "string"
|
|
2894
|
+
},
|
|
2895
|
+
"fieldName": "lang",
|
|
2896
|
+
"description": "BCP 47 locale tag. Inherits from nearest ancestor `[lang]` if not set.",
|
|
2897
|
+
"inheritedFrom": {
|
|
2898
|
+
"name": "UseLocaleElement",
|
|
2899
|
+
"module": "src/elements/use-locale-element/use-locale-element.ts"
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
],
|
|
2903
|
+
"superclass": {
|
|
2904
|
+
"name": "UseLocaleElement",
|
|
2905
|
+
"module": "/src/elements/use-locale-element/use-locale-element"
|
|
2906
|
+
},
|
|
2907
|
+
"tagName": "use-intl-number",
|
|
2908
|
+
"customElement": true
|
|
2909
|
+
}
|
|
2910
|
+
],
|
|
2911
|
+
"exports": [
|
|
2912
|
+
{
|
|
2913
|
+
"kind": "js",
|
|
2914
|
+
"name": "UseIntlNumber",
|
|
2915
|
+
"declaration": {
|
|
2916
|
+
"name": "UseIntlNumber",
|
|
2917
|
+
"module": "src/elements/use-intl-number/use-intl-number.ts"
|
|
2918
|
+
}
|
|
2919
|
+
},
|
|
2920
|
+
{
|
|
2921
|
+
"kind": "custom-element-definition",
|
|
2922
|
+
"name": "use-intl-number",
|
|
2923
|
+
"declaration": {
|
|
2924
|
+
"name": "UseIntlNumber",
|
|
2925
|
+
"module": "src/elements/use-intl-number/use-intl-number.ts"
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
]
|
|
2929
|
+
},
|
|
2751
2930
|
{
|
|
2752
2931
|
"kind": "javascript-module",
|
|
2753
2932
|
"path": "src/elements/use-listbox-input/use-listbox-input.ts",
|
package/dist/design-system.css
CHANGED
|
@@ -1241,3 +1241,313 @@
|
|
|
1241
1241
|
}
|
|
1242
1242
|
}
|
|
1243
1243
|
|
|
1244
|
+
/* Grid — a cell holding a use-intl-number reads as tabular data, so it defaults to end-aligned
|
|
1245
|
+
text with tabular-nums, which locks every digit to the same width so values stack and compare
|
|
1246
|
+
cleanly down a column. text-align and font-variant-numeric are both inherited, so setting them
|
|
1247
|
+
on use-gridcell reaches the formatted text inside use-intl-number's shadow root without needing
|
|
1248
|
+
a rule scoped to use-intl-number itself. */
|
|
1249
|
+
@layer use-theme.grid {
|
|
1250
|
+
use-gridcell:has(use-intl-number) {
|
|
1251
|
+
text-align: end;
|
|
1252
|
+
font-variant-numeric: tabular-nums;
|
|
1253
|
+
|
|
1254
|
+
use-theme-escape & {
|
|
1255
|
+
all: revert-layer;
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
/* Card — `use-card` is a theme-only tag, styled like `use-field`/`use-selector` with no
|
|
1261
|
+
registration behind it: an author can still add `role`/ARIA directly on `<use-card>` for real
|
|
1262
|
+
semantics, the same as any other element, just not for free the way `<article>`/`<section>`
|
|
1263
|
+
give an implicit landmark. It supplies the surface chrome (background/border/radius/shadow);
|
|
1264
|
+
`shell.css` (declared later, so it wins on `display`) makes it a flex column, and
|
|
1265
|
+
`surface.css` styles its header/footer/figure regions. `.outlined` drops the shadow and keeps
|
|
1266
|
+
the border, for a flatter, less "floating" card. */
|
|
1267
|
+
@layer use-theme.card {
|
|
1268
|
+
use-card {
|
|
1269
|
+
display: block;
|
|
1270
|
+
overflow: hidden;
|
|
1271
|
+
background: var(--usewc-color-surface-background);
|
|
1272
|
+
border: var(--usewc-layout-surface-border) solid var(--usewc-color-surface-border);
|
|
1273
|
+
border-radius: var(--usewc-effect-surface-border-radius);
|
|
1274
|
+
box-shadow: var(--usewc-effect-surface-shadow);
|
|
1275
|
+
color: var(--usewc-color-document-text);
|
|
1276
|
+
|
|
1277
|
+
use-theme-escape & {
|
|
1278
|
+
all: revert-layer;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
use-card.outlined {
|
|
1283
|
+
box-shadow: none;
|
|
1284
|
+
|
|
1285
|
+
use-theme-escape & {
|
|
1286
|
+
all: revert-layer;
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
/* Dialog — a native `<dialog>` already provides the overlay mechanics (top-layer promotion,
|
|
1292
|
+
`::backdrop`, focus trapping, Esc-to-close) for free once shown with `.showModal()`. Themed by
|
|
1293
|
+
default, like the rest of this family's native elements — `:not(.appearance-native)` is the
|
|
1294
|
+
escape hatch, not an opt-in class. The default look centers (the UA default for `<dialog>`, so
|
|
1295
|
+
no extra positioning is needed) and constrains its size; `.drawer` is the one variant that
|
|
1296
|
+
needs an opt-in class, since it pins to a block-size-100dvh edge panel instead — the positioning
|
|
1297
|
+
itself, not just the chrome, changes. That's what makes `use-shell-fill` (see `shell.css`)
|
|
1298
|
+
matter for a drawer specifically — the body scrolls while header/footer stay put. */
|
|
1299
|
+
@layer use-theme.dialog {
|
|
1300
|
+
dialog:not(.appearance-native) {
|
|
1301
|
+
padding: 0;
|
|
1302
|
+
overflow: hidden;
|
|
1303
|
+
border: var(--usewc-layout-surface-border) solid var(--usewc-color-surface-border);
|
|
1304
|
+
border-radius: var(--usewc-effect-surface-border-radius);
|
|
1305
|
+
background: var(--usewc-color-surface-background);
|
|
1306
|
+
box-shadow: var(--usewc-effect-surface-shadow);
|
|
1307
|
+
color: var(--usewc-color-document-text);
|
|
1308
|
+
inline-size: min(32rem, 100% - var(--usewc-space-surface-padding) * 2);
|
|
1309
|
+
max-block-size: min(80dvh, 100% - var(--usewc-space-surface-padding) * 2);
|
|
1310
|
+
|
|
1311
|
+
use-theme-escape & {
|
|
1312
|
+
all: revert-layer;
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
dialog:not(.appearance-native)::backdrop {
|
|
1317
|
+
background: var(--usewc-color-surface-backdrop);
|
|
1318
|
+
|
|
1319
|
+
use-theme-escape & {
|
|
1320
|
+
all: revert-layer;
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
/* inset-inline-start: auto resets the UA stylesheet's own `dialog:modal { inset: 0 }` (all
|
|
1325
|
+
four sides, not just block) — without it, left/start stays pinned at 0 alongside our
|
|
1326
|
+
inset-inline-end: 0 and an explicit inline-size, which is over-constrained: the browser
|
|
1327
|
+
drops the property that conflicts with the direction-implied one (inset-inline-start in
|
|
1328
|
+
LTR), pinning the drawer to the start edge instead of the end edge it's meant to sit on. */
|
|
1329
|
+
dialog.drawer:not(.appearance-native) {
|
|
1330
|
+
position: fixed;
|
|
1331
|
+
inset-block: 0;
|
|
1332
|
+
inset-inline-start: auto;
|
|
1333
|
+
inset-inline-end: 0;
|
|
1334
|
+
margin: 0;
|
|
1335
|
+
max-block-size: none;
|
|
1336
|
+
block-size: 100dvh;
|
|
1337
|
+
inline-size: min(24rem, 100%);
|
|
1338
|
+
border-radius: 0;
|
|
1339
|
+
border-block: none;
|
|
1340
|
+
border-inline-end: none;
|
|
1341
|
+
|
|
1342
|
+
use-theme-escape & {
|
|
1343
|
+
all: revert-layer;
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
/* Popover — a native `[popover]` element already provides the overlay mechanics (top-layer
|
|
1349
|
+
promotion, light-dismiss, `::backdrop`) for free. Themed by default, like the rest of this
|
|
1350
|
+
family's native elements — `:not(.appearance-native)` is the escape hatch, matching
|
|
1351
|
+
`input.css`/`select.css`'s convention, not an opt-in class like `dialog.drawer` (a `<dialog>`
|
|
1352
|
+
needs a class for that one variant since plain and drawer dialogs share one tag; `[popover]`
|
|
1353
|
+
is already a specific enough signal on its own). Anchor positioning (`anchor-name`/
|
|
1354
|
+
`position-anchor`) is left to the author, the same way plain `[popover]` elements work
|
|
1355
|
+
otherwise — this only replaces the UA default chrome with the shared `surface` tokens,
|
|
1356
|
+
matching `dialog`/`use-card`.
|
|
1357
|
+
|
|
1358
|
+
`:not(use-menu)` excludes the one component that self-applies `popover="auto"` and ships its
|
|
1359
|
+
own distinct chrome in `menu.css`: cascade layers always beat specificity, so without this
|
|
1360
|
+
exclusion `use-menu:popover-open`'s more specific rule would still lose to this layer, which
|
|
1361
|
+
is declared later. */
|
|
1362
|
+
@layer use-theme.popover {
|
|
1363
|
+
[popover]:not(use-menu, .appearance-native) {
|
|
1364
|
+
margin: 0;
|
|
1365
|
+
padding: 0;
|
|
1366
|
+
overflow: hidden;
|
|
1367
|
+
border: var(--usewc-layout-surface-border) solid var(--usewc-color-surface-border);
|
|
1368
|
+
border-radius: var(--usewc-effect-surface-border-radius);
|
|
1369
|
+
background: var(--usewc-color-surface-background);
|
|
1370
|
+
box-shadow: var(--usewc-effect-surface-shadow);
|
|
1371
|
+
color: var(--usewc-color-document-text);
|
|
1372
|
+
max-inline-size: min(24rem, 100% - var(--usewc-space-surface-padding) * 2);
|
|
1373
|
+
max-block-size: min(80dvh, 100% - var(--usewc-space-surface-padding) * 2);
|
|
1374
|
+
|
|
1375
|
+
use-theme-escape & {
|
|
1376
|
+
all: revert-layer;
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
[popover]:not(use-menu, .appearance-native)::backdrop {
|
|
1381
|
+
background: var(--usewc-color-surface-backdrop);
|
|
1382
|
+
|
|
1383
|
+
use-theme-escape & {
|
|
1384
|
+
all: revert-layer;
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
/* Shell — `use-shell` is a theme-only tag (no registration, styled by tag name like
|
|
1390
|
+
`use-field`/`use-selector`/`use-card`) providing a generic flex-column-with-one-growing-region
|
|
1391
|
+
mechanic, usable anywhere in an app that wants it — not specific to card/dialog/popover
|
|
1392
|
+
surfaces. Every direct child defaults to `flex: 0 0 auto` (fixed, doesn't grow or shrink) and
|
|
1393
|
+
`min-block-size: 0`; `use-shell-fill` is the one region that grows to fill the remaining
|
|
1394
|
+
space and scrolls its own overflow, wherever it appears.
|
|
1395
|
+
|
|
1396
|
+
The three surface hosts (`dialog`, `use-card`, `[popover]`) participate in the same mechanic
|
|
1397
|
+
directly — no `use-shell` wrapper needed inside them — since they're already the flex
|
|
1398
|
+
container an author nests header/use-shell-fill/footer straight into. This layer is declared
|
|
1399
|
+
after `card.css`/`dialog.css`/`popover.css`, so its `display: flex` wins over their own
|
|
1400
|
+
`display: block` for `use-card` (dialog/popover don't set `display` themselves, so there's
|
|
1401
|
+
nothing to override there).
|
|
1402
|
+
|
|
1403
|
+
`dialog` and `[popover]` are scoped to `:modal`/`:popover-open` here, unlike the chrome rules
|
|
1404
|
+
in `dialog.css`/`popover.css` — a closed `<dialog>`/`[popover]` is `display: none` by the UA
|
|
1405
|
+
stylesheet, and normal-importance author CSS always beats normal-importance UA CSS regardless
|
|
1406
|
+
of layers, so an unconditional `display: flex` here would un-hide a closed one. Chrome
|
|
1407
|
+
properties (background/border/shadow/sizing) don't have this problem — they're inert on a
|
|
1408
|
+
`display: none` element either way — only `display` itself does. */
|
|
1409
|
+
@layer use-theme.shell {
|
|
1410
|
+
use-shell,
|
|
1411
|
+
dialog:modal:not(.appearance-native),
|
|
1412
|
+
use-card,
|
|
1413
|
+
[popover]:popover-open:not(use-menu, .appearance-native) {
|
|
1414
|
+
display: flex;
|
|
1415
|
+
flex-direction: column;
|
|
1416
|
+
min-block-size: 0;
|
|
1417
|
+
|
|
1418
|
+
use-theme-escape & {
|
|
1419
|
+
all: revert-layer;
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
use-shell > :not(use-shell-fill),
|
|
1424
|
+
dialog:modal:not(.appearance-native) > :not(use-shell-fill),
|
|
1425
|
+
use-card > :not(use-shell-fill),
|
|
1426
|
+
[popover]:popover-open:not(use-menu, .appearance-native) > :not(use-shell-fill) {
|
|
1427
|
+
flex: 0 0 auto;
|
|
1428
|
+
min-block-size: 0;
|
|
1429
|
+
|
|
1430
|
+
use-theme-escape & {
|
|
1431
|
+
all: revert-layer;
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
use-shell-fill {
|
|
1436
|
+
display: block;
|
|
1437
|
+
flex: 1 1 auto;
|
|
1438
|
+
min-block-size: 0;
|
|
1439
|
+
overflow: auto;
|
|
1440
|
+
|
|
1441
|
+
use-theme-escape & {
|
|
1442
|
+
all: revert-layer;
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
/* Surface regions — header/poster/footer styling shared by the three surface hosts (`dialog`,
|
|
1448
|
+
`use-card`, `[popover]`), scoped to them specifically rather than to bare `use-shell`: this is
|
|
1449
|
+
a surface-family visual convention (avatar sizing, trailing-action pinning, a footer rule),
|
|
1450
|
+
not something every generic `use-shell` consumer elsewhere in the app should inherit.
|
|
1451
|
+
Everything here rides on top of `shell.css`'s flex mechanic — this only adds padding, gaps,
|
|
1452
|
+
and per-region treatment. */
|
|
1453
|
+
@layer use-theme.surface {
|
|
1454
|
+
:is(dialog:not(.appearance-native), use-card, [popover]:not(use-menu, .appearance-native)) > figure {
|
|
1455
|
+
margin: 0;
|
|
1456
|
+
|
|
1457
|
+
use-theme-escape & {
|
|
1458
|
+
all: revert-layer;
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
:is(dialog:not(.appearance-native), use-card, [popover]:not(use-menu, .appearance-native)) > figure > img {
|
|
1463
|
+
display: block;
|
|
1464
|
+
inline-size: 100%;
|
|
1465
|
+
block-size: auto;
|
|
1466
|
+
object-fit: cover;
|
|
1467
|
+
|
|
1468
|
+
use-theme-escape & {
|
|
1469
|
+
all: revert-layer;
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
:is(dialog:not(.appearance-native), use-card, [popover]:not(use-menu, .appearance-native)) > header {
|
|
1474
|
+
display: flex;
|
|
1475
|
+
align-items: center;
|
|
1476
|
+
gap: var(--usewc-space-surface-gap);
|
|
1477
|
+
padding: var(--usewc-space-surface-padding);
|
|
1478
|
+
|
|
1479
|
+
use-theme-escape & {
|
|
1480
|
+
all: revert-layer;
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
:is(dialog:not(.appearance-native), use-card, [popover]:not(use-menu, .appearance-native)) > header > img.avatar {
|
|
1485
|
+
flex: none;
|
|
1486
|
+
inline-size: var(--usewc-layout-surface-avatar-size);
|
|
1487
|
+
block-size: var(--usewc-layout-surface-avatar-size);
|
|
1488
|
+
border-radius: var(--usewc-effect-surface-avatar-border-radius);
|
|
1489
|
+
object-fit: cover;
|
|
1490
|
+
|
|
1491
|
+
use-theme-escape & {
|
|
1492
|
+
all: revert-layer;
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
:is(dialog:not(.appearance-native), use-card, [popover]:not(use-menu, .appearance-native)) > header > hgroup {
|
|
1497
|
+
flex: 1;
|
|
1498
|
+
min-inline-size: 0;
|
|
1499
|
+
|
|
1500
|
+
use-theme-escape & {
|
|
1501
|
+
all: revert-layer;
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
:is(dialog:not(.appearance-native), use-card, [popover]:not(use-menu, .appearance-native))
|
|
1506
|
+
> header
|
|
1507
|
+
> *:last-child:not(:first-child) {
|
|
1508
|
+
margin-inline-start: auto;
|
|
1509
|
+
|
|
1510
|
+
use-theme-escape & {
|
|
1511
|
+
all: revert-layer;
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
:is(dialog:not(.appearance-native), use-card, [popover]:not(use-menu, .appearance-native)) > use-shell-fill {
|
|
1516
|
+
padding: var(--usewc-space-surface-padding);
|
|
1517
|
+
|
|
1518
|
+
use-theme-escape & {
|
|
1519
|
+
all: revert-layer;
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
:is(dialog:not(.appearance-native), use-card, [popover]:not(use-menu, .appearance-native)) > header + use-shell-fill {
|
|
1524
|
+
padding-block-start: 0;
|
|
1525
|
+
|
|
1526
|
+
use-theme-escape & {
|
|
1527
|
+
all: revert-layer;
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
:is(dialog:not(.appearance-native), use-card, [popover]:not(use-menu, .appearance-native)) > footer {
|
|
1532
|
+
display: flex;
|
|
1533
|
+
align-items: center;
|
|
1534
|
+
gap: var(--usewc-space-surface-gap);
|
|
1535
|
+
padding: var(--usewc-space-surface-padding);
|
|
1536
|
+
border-block-start: var(--usewc-layout-surface-border) solid var(--usewc-color-surface-footer-border);
|
|
1537
|
+
|
|
1538
|
+
use-theme-escape & {
|
|
1539
|
+
all: revert-layer;
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
:is(dialog:not(.appearance-native), use-card, [popover]:not(use-menu, .appearance-native))
|
|
1544
|
+
> footer
|
|
1545
|
+
> *:last-child:not(:first-child) {
|
|
1546
|
+
margin-inline-start: auto;
|
|
1547
|
+
|
|
1548
|
+
use-theme-escape & {
|
|
1549
|
+
all: revert-layer;
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# `use-intl-number`
|
|
2
|
+
|
|
3
|
+
Displays a localized, human-readable representation of a number using
|
|
4
|
+
[`Intl.NumberFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat).
|
|
5
|
+
Renders a semantic `<data>` element in its shadow root with a machine-readable
|
|
6
|
+
`value` attribute and formatted inner text.
|
|
7
|
+
|
|
8
|
+
Set `numberstyle` to control what kind of number is formatted (see
|
|
9
|
+
[`style`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#style)):
|
|
10
|
+
- `decimal` (default) → plain number, e.g. `1,234.5`
|
|
11
|
+
- `percent` → percentage, e.g. `42%` (value is the fraction, so `0.42` renders `42%`)
|
|
12
|
+
- `currency` → currency amount, requires `currency`
|
|
13
|
+
- `unit` → measurement, requires `unit`
|
|
14
|
+
|
|
15
|
+
Locale is resolved from the nearest ancestor `[lang]` attribute, or
|
|
16
|
+
`navigator.language` if none is found. Set `lang` directly on the element to override.
|
|
17
|
+
|
|
18
|
+
## Attributes
|
|
19
|
+
|
|
20
|
+
| Name | Type | Default | Description |
|
|
21
|
+
| --- | --- | --- | --- |
|
|
22
|
+
| value | `string \| undefined` | - | Numeric amount to format |
|
|
23
|
+
| numberstyle | `string \| undefined` | - | Format style: `decimal` \| `percent` \| `currency` \| `unit` |
|
|
24
|
+
| currency | `string \| undefined` | - | [ISO 4217 currency code](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currency), e.g. `USD`, `EUR`, `JPY`. Required when numberstyle is `currency` |
|
|
25
|
+
| currencydisplay | `string \| undefined` | - | [How the currency is denoted](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencydisplay): `symbol` \| `narrowSymbol` \| `code` \| `name` |
|
|
26
|
+
| currencysign | `string \| undefined` | - | [Sign convention](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencysign): `standard` (minus sign) \| `accounting` (parenthesized negatives) |
|
|
27
|
+
| unit | `string \| undefined` | - | [Unit identifier](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#unit), e.g. `kilometer-per-hour`, `liter`. Required when numberstyle is `unit` |
|
|
28
|
+
| unitdisplay | `string \| undefined` | - | [How the unit is denoted](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#unitdisplay): `short` \| `narrow` \| `long` |
|
|
29
|
+
| signdisplay | `string \| undefined` | - | [When to show the sign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#signdisplay): `auto` \| `always` \| `exceptZero` \| `never` |
|
|
30
|
+
| lang | `string` | - | BCP 47 locale tag. Inherits from nearest ancestor `[lang]` if not set. |
|
package/dist/tokens.css
CHANGED
|
@@ -119,6 +119,7 @@
|
|
|
119
119
|
--usewc-effect-border-radius-8: 0.5rem;
|
|
120
120
|
--usewc-effect-border-radius-full: 100%;
|
|
121
121
|
--usewc-effect-border-radius-pill: 9999px;
|
|
122
|
+
--usewc-effect-shadow-raised: 0 1px 2px oklch(0% 0 0 / 0.06), 0 4px 12px oklch(0% 0 0 / 0.1);
|
|
122
123
|
|
|
123
124
|
/**
|
|
124
125
|
* Icon
|
|
@@ -576,6 +577,22 @@
|
|
|
576
577
|
--usewc-color-code-background: oklch(from var(--usewc-color-red-600) l c h / 0.125);
|
|
577
578
|
--usewc-color-code-border: var(--usewc-color-transparent);
|
|
578
579
|
--usewc-font-code-size: var(--usewc-font-size-14);
|
|
580
|
+
|
|
581
|
+
/* Surface — shared by every surface host (dialog, use-card, [popover]): the visible chrome
|
|
582
|
+
(background/border/radius/shadow), the backdrop behind an overlaid one, and the internal
|
|
583
|
+
header/poster/footer region layout they all apply the same way. */
|
|
584
|
+
--usewc-color-surface-background: var(--usewc-color-canvas-background);
|
|
585
|
+
--usewc-color-surface-border: var(--usewc-color-button-base-border-static);
|
|
586
|
+
--usewc-color-surface-backdrop: oklch(0% 0 0 / 0.4);
|
|
587
|
+
--usewc-layout-surface-border: var(--usewc-space-1);
|
|
588
|
+
--usewc-effect-surface-border-radius: var(--usewc-effect-border-radius-8);
|
|
589
|
+
--usewc-effect-surface-shadow: var(--usewc-effect-shadow-raised);
|
|
590
|
+
--usewc-effect-surface-transition-duration: 200ms;
|
|
591
|
+
--usewc-space-surface-padding: var(--usewc-space-16);
|
|
592
|
+
--usewc-space-surface-gap: var(--usewc-space-12);
|
|
593
|
+
--usewc-layout-surface-avatar-size: var(--usewc-space-32);
|
|
594
|
+
--usewc-effect-surface-avatar-border-radius: var(--usewc-effect-border-radius-full);
|
|
595
|
+
--usewc-color-surface-footer-border: var(--usewc-color-surface-border);
|
|
579
596
|
}
|
|
580
597
|
|
|
581
598
|
@media (prefers-color-scheme: dark) {
|
|
@@ -661,6 +678,7 @@
|
|
|
661
678
|
--usewc-color-selector-background-hover: oklch(from var(--usewc-color-gray-700) l c h / 0.5);
|
|
662
679
|
--usewc-effect-select-trigger-background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 16L5.0718 8.5L18.9282 8.5L12 16Z' fill='rgb(229,231,235)' /%3E%3C/svg%3E");
|
|
663
680
|
--usewc-effect-menu-item-checkmark-background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 13L10 18L19 7' stroke='rgb(229,231,235)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C%2Fsvg%3E");
|
|
681
|
+
--usewc-color-surface-backdrop: oklch(0% 0 0 / 0.6);
|
|
664
682
|
}
|
|
665
683
|
}
|
|
666
684
|
|
package/dist/use-wc.d.mts
CHANGED
|
@@ -1406,6 +1406,52 @@ declare global {
|
|
|
1406
1406
|
}
|
|
1407
1407
|
}
|
|
1408
1408
|
//#endregion
|
|
1409
|
+
//#region src/elements/use-intl-number/use-intl-number.d.ts
|
|
1410
|
+
/**
|
|
1411
|
+
* Displays a localized, human-readable representation of a number using
|
|
1412
|
+
* [`Intl.NumberFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat).
|
|
1413
|
+
* Renders a semantic `<data>` element in its shadow root with a machine-readable
|
|
1414
|
+
* `value` attribute and formatted inner text.
|
|
1415
|
+
*
|
|
1416
|
+
* Set `numberstyle` to control what kind of number is formatted (see
|
|
1417
|
+
* [`style`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#style)):
|
|
1418
|
+
* - `decimal` (default) → plain number, e.g. `1,234.5`
|
|
1419
|
+
* - `percent` → percentage, e.g. `42%` (value is the fraction, so `0.42` renders `42%`)
|
|
1420
|
+
* - `currency` → currency amount, requires `currency`
|
|
1421
|
+
* - `unit` → measurement, requires `unit`
|
|
1422
|
+
*
|
|
1423
|
+
* Locale is resolved from the nearest ancestor `[lang]` attribute, or
|
|
1424
|
+
* `navigator.language` if none is found. Set `lang` directly on the element to override.
|
|
1425
|
+
*
|
|
1426
|
+
* @attr {string} value - Numeric amount to format
|
|
1427
|
+
* @attr {string} numberstyle - Format style: `decimal` | `percent` | `currency` | `unit`
|
|
1428
|
+
* @attr {string} currency - [ISO 4217 currency code](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currency), e.g. `USD`, `EUR`, `JPY`. Required when numberstyle is `currency`
|
|
1429
|
+
* @attr {string} currencydisplay - [How the currency is denoted](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencydisplay): `symbol` | `narrowSymbol` | `code` | `name`
|
|
1430
|
+
* @attr {string} currencysign - [Sign convention](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencysign): `standard` (minus sign) | `accounting` (parenthesized negatives)
|
|
1431
|
+
* @attr {string} unit - [Unit identifier](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#unit), e.g. `kilometer-per-hour`, `liter`. Required when numberstyle is `unit`
|
|
1432
|
+
* @attr {string} unitdisplay - [How the unit is denoted](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#unitdisplay): `short` | `narrow` | `long`
|
|
1433
|
+
* @attr {string} signdisplay - [When to show the sign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#signdisplay): `auto` | `always` | `exceptZero` | `never`
|
|
1434
|
+
* @attr {string} lang - BCP 47 locale tag. Inherits from nearest ancestor `[lang]` if not set.
|
|
1435
|
+
*/
|
|
1436
|
+
declare class UseIntlNumber extends UseLocaleElement {
|
|
1437
|
+
#private;
|
|
1438
|
+
static styles: import("lit").CSSResult;
|
|
1439
|
+
value?: string;
|
|
1440
|
+
numberstyle?: string;
|
|
1441
|
+
currency?: string;
|
|
1442
|
+
currencydisplay?: string;
|
|
1443
|
+
currencysign?: string;
|
|
1444
|
+
unit?: string;
|
|
1445
|
+
unitdisplay?: string;
|
|
1446
|
+
signdisplay?: string;
|
|
1447
|
+
render(): TemplateResult$1<1>;
|
|
1448
|
+
}
|
|
1449
|
+
declare global {
|
|
1450
|
+
interface HTMLElementTagNameMap {
|
|
1451
|
+
"use-intl-number": UseIntlNumber;
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
//#endregion
|
|
1409
1455
|
//#region src/elements/use-badge/use-badge.d.ts
|
|
1410
1456
|
/**
|
|
1411
1457
|
* `use-badge` renders a small indicator anchored to another element's corner, using
|
|
@@ -1508,4 +1554,4 @@ declare global {
|
|
|
1508
1554
|
}
|
|
1509
1555
|
}
|
|
1510
1556
|
//#endregion
|
|
1511
|
-
export { UseAnchored, UseBadge, UseCalendarBase, UseCalendarRenderDay, UseCaret, UseDateInput, UseDatePicker, UseDatetimeInput, UseDurationInput, UseFocusgroup, UseIntlDatetime, UseListboxInput, UseMenu, UseMonthPicker, UseMonthPickerRenderMonth, UseOption, UseScrollarea, UseTimeInput, UseTree, UseTreeitem, UseWeekPicker, UseWidget };
|
|
1557
|
+
export { UseAnchored, UseBadge, UseCalendarBase, UseCalendarRenderDay, UseCaret, UseDateInput, UseDatePicker, UseDatetimeInput, UseDurationInput, UseFocusgroup, UseIntlDatetime, UseIntlNumber, UseListboxInput, UseMenu, UseMonthPicker, UseMonthPickerRenderMonth, UseOption, UseScrollarea, UseTimeInput, UseTree, UseTreeitem, UseWeekPicker, UseWidget };
|
package/dist/use-wc.mjs
CHANGED
|
@@ -4290,6 +4290,112 @@ __decorate([property({ type: String })], UseIntlDatetime.prototype, "datestyle",
|
|
|
4290
4290
|
__decorate([property({ type: String })], UseIntlDatetime.prototype, "timestyle", void 0);
|
|
4291
4291
|
UseIntlDatetime = __decorate([customElement("use-intl-datetime")], UseIntlDatetime);
|
|
4292
4292
|
//#endregion
|
|
4293
|
+
//#region src/elements/use-intl-number/use-intl-number.ts
|
|
4294
|
+
const NUMBER_STYLES = [
|
|
4295
|
+
"decimal",
|
|
4296
|
+
"percent",
|
|
4297
|
+
"currency",
|
|
4298
|
+
"unit"
|
|
4299
|
+
];
|
|
4300
|
+
const CURRENCY_DISPLAYS = [
|
|
4301
|
+
"symbol",
|
|
4302
|
+
"narrowSymbol",
|
|
4303
|
+
"code",
|
|
4304
|
+
"name"
|
|
4305
|
+
];
|
|
4306
|
+
const CURRENCY_SIGNS = ["standard", "accounting"];
|
|
4307
|
+
const SIGN_DISPLAYS = [
|
|
4308
|
+
"auto",
|
|
4309
|
+
"always",
|
|
4310
|
+
"exceptZero",
|
|
4311
|
+
"never"
|
|
4312
|
+
];
|
|
4313
|
+
const UNIT_DISPLAYS = [
|
|
4314
|
+
"short",
|
|
4315
|
+
"narrow",
|
|
4316
|
+
"long"
|
|
4317
|
+
];
|
|
4318
|
+
let UseIntlNumber = class UseIntlNumber extends UseLocaleElement {
|
|
4319
|
+
static {
|
|
4320
|
+
this.styles = css`
|
|
4321
|
+
:host {
|
|
4322
|
+
display: contents;
|
|
4323
|
+
}
|
|
4324
|
+
`;
|
|
4325
|
+
}
|
|
4326
|
+
#resolveNumberStyle() {
|
|
4327
|
+
return NUMBER_STYLES.includes(this.numberstyle) ? this.numberstyle : "decimal";
|
|
4328
|
+
}
|
|
4329
|
+
#resolveCurrencyDisplay() {
|
|
4330
|
+
return CURRENCY_DISPLAYS.includes(this.currencydisplay) ? this.currencydisplay : "symbol";
|
|
4331
|
+
}
|
|
4332
|
+
#resolveCurrencySign() {
|
|
4333
|
+
return CURRENCY_SIGNS.includes(this.currencysign) ? this.currencysign : "standard";
|
|
4334
|
+
}
|
|
4335
|
+
#resolveUnitDisplay() {
|
|
4336
|
+
return UNIT_DISPLAYS.includes(this.unitdisplay) ? this.unitdisplay : "short";
|
|
4337
|
+
}
|
|
4338
|
+
#resolveSignDisplay() {
|
|
4339
|
+
return SIGN_DISPLAYS.includes(this.signdisplay) ? this.signdisplay : "auto";
|
|
4340
|
+
}
|
|
4341
|
+
#resolveOptions(style) {
|
|
4342
|
+
if (style === "currency") {
|
|
4343
|
+
if (!this.currency) return null;
|
|
4344
|
+
return {
|
|
4345
|
+
style,
|
|
4346
|
+
currency: this.currency,
|
|
4347
|
+
currencyDisplay: this.#resolveCurrencyDisplay(),
|
|
4348
|
+
currencySign: this.#resolveCurrencySign(),
|
|
4349
|
+
signDisplay: this.#resolveSignDisplay()
|
|
4350
|
+
};
|
|
4351
|
+
}
|
|
4352
|
+
if (style === "unit") {
|
|
4353
|
+
if (!this.unit) return null;
|
|
4354
|
+
return {
|
|
4355
|
+
style,
|
|
4356
|
+
unit: this.unit,
|
|
4357
|
+
unitDisplay: this.#resolveUnitDisplay(),
|
|
4358
|
+
signDisplay: this.#resolveSignDisplay()
|
|
4359
|
+
};
|
|
4360
|
+
}
|
|
4361
|
+
return {
|
|
4362
|
+
style,
|
|
4363
|
+
signDisplay: this.#resolveSignDisplay()
|
|
4364
|
+
};
|
|
4365
|
+
}
|
|
4366
|
+
#computeFormatted() {
|
|
4367
|
+
const value = this.value ?? "";
|
|
4368
|
+
const locale = this.lang;
|
|
4369
|
+
if (!value || value.trim() === "") return null;
|
|
4370
|
+
const amount = Number(value);
|
|
4371
|
+
if (isNaN(amount)) return null;
|
|
4372
|
+
const options = this.#resolveOptions(this.#resolveNumberStyle());
|
|
4373
|
+
if (!options) return null;
|
|
4374
|
+
try {
|
|
4375
|
+
return {
|
|
4376
|
+
valueAttr: String(amount),
|
|
4377
|
+
text: new Intl.NumberFormat(locale, options).format(amount)
|
|
4378
|
+
};
|
|
4379
|
+
} catch {
|
|
4380
|
+
return null;
|
|
4381
|
+
}
|
|
4382
|
+
}
|
|
4383
|
+
render() {
|
|
4384
|
+
const result = this.#computeFormatted();
|
|
4385
|
+
if (!result) return html`<data></data>`;
|
|
4386
|
+
return html`<data value=${result.valueAttr}>${result.text}</data>`;
|
|
4387
|
+
}
|
|
4388
|
+
};
|
|
4389
|
+
__decorate([property({ type: String })], UseIntlNumber.prototype, "value", void 0);
|
|
4390
|
+
__decorate([property({ type: String })], UseIntlNumber.prototype, "numberstyle", void 0);
|
|
4391
|
+
__decorate([property({ type: String })], UseIntlNumber.prototype, "currency", void 0);
|
|
4392
|
+
__decorate([property({ type: String })], UseIntlNumber.prototype, "currencydisplay", void 0);
|
|
4393
|
+
__decorate([property({ type: String })], UseIntlNumber.prototype, "currencysign", void 0);
|
|
4394
|
+
__decorate([property({ type: String })], UseIntlNumber.prototype, "unit", void 0);
|
|
4395
|
+
__decorate([property({ type: String })], UseIntlNumber.prototype, "unitdisplay", void 0);
|
|
4396
|
+
__decorate([property({ type: String })], UseIntlNumber.prototype, "signdisplay", void 0);
|
|
4397
|
+
UseIntlNumber = __decorate([customElement("use-intl-number")], UseIntlNumber);
|
|
4398
|
+
//#endregion
|
|
4293
4399
|
//#region src/elements/use-badge/use-badge.ts
|
|
4294
4400
|
let UseBadge = class UseBadge extends LitElement {
|
|
4295
4401
|
#internals;
|
|
@@ -4446,4 +4552,4 @@ __decorate([property({
|
|
|
4446
4552
|
})], UseBadge.prototype, "options", void 0);
|
|
4447
4553
|
UseBadge = __decorate([customElement("use-badge")], UseBadge);
|
|
4448
4554
|
//#endregion
|
|
4449
|
-
export { UseAnchored, UseBadge, UseCalendarBase, UseCaret, UseDateInput, UseDatePicker, UseDatetimeInput, UseDurationInput, UseFocusgroup, UseIntlDatetime, UseListboxInput, UseMenu, UseMonthPicker, UseOption, UseScrollarea, UseTimeInput, UseTree, UseTreeitem, UseWeekPicker, UseWidget };
|
|
4555
|
+
export { UseAnchored, UseBadge, UseCalendarBase, UseCaret, UseDateInput, UseDatePicker, UseDatetimeInput, UseDurationInput, UseFocusgroup, UseIntlDatetime, UseIntlNumber, UseListboxInput, UseMenu, UseMonthPicker, UseOption, UseScrollarea, UseTimeInput, UseTree, UseTreeitem, UseWeekPicker, UseWidget };
|
package/package.json
CHANGED
|
@@ -57,6 +57,12 @@
|
|
|
57
57
|
"attributes": [{ "name": "date", "values": [] }],
|
|
58
58
|
"references": []
|
|
59
59
|
},
|
|
60
|
+
{
|
|
61
|
+
"name": "use-caret",
|
|
62
|
+
"description": "`use-caret` supplies the caret icon and label layout for a consumer who wants to own the\ninvoking button itself. It renders inside a plain `<button>`\nthat carries the native `popovertarget` attribute, pointing at a `use-menu`:\n\n```html\n<button id=\"thing\" popovertarget=\"thing-menu\">\n <use-caret>Menu</use-caret>\n</button>\n<use-menu id=\"thing-menu\" aria-label=\"Menu\">\n <button role=\"menuitem\">First thing</button>\n</use-menu>\n```\n\n`use-menu` finds this button on its own via `popovertarget` and anchors to it — no\n`anchortarget` needed here; that's only for a menu with more than one invoker. See `use-menu`'s\nown docs for that case.\n\nThe button is entirely the consumer's own element — their classes, their content, their event\nhandlers. `use-caret` contributes no interactivity of its own: no internal button, no focus\ntarget, no state. It only renders the label and caret glyph, so consumers get a consistent\nvisual trigger without giving up control of the button.\n\nThe caret direction is derived rather than configured: a trigger nested inside a `use-menu`\nis understood to open a submenu and renders pointing sideways; a top-level trigger renders\npointing down.\n\nSwapping in a different caret **per instance** is a slot: put your own element in the `icon`\nslot and it replaces `part(icon-default)` entirely for that trigger.\n\nSwapping the default caret **for every trigger in the app** doesn't need touching this\ncomponent's `render()` at all — style `::part(icon-default)` from an outside stylesheet, the\nsame way any shadow DOM part is themed:\n\n```css\nuse-caret::part(icon-default) {\n mask-image: url(\"/icons/my-caret.svg\");\n}\n```\n\n(When the design system's `theme.css` is loaded, this is already wired to a token —\n`--usewc-effect-dropdown-trigger-icon-mask-image` — so redefining that custom property has\nthe same effect without writing a `::part()` rule at all.)\n\n`::part()` only reaches CSS-expressible changes (a mask, a background, a transform). For\nanything else — different markup, an icon font, logic beyond a mask — set the static `icon`\nand `nestedIcon` hooks. Every `<use-caret>` in the page picks them up; consumers keep writing\nthe same tag, no new element to register or remember to use instead. `icon` supplies a\ntop-level trigger's glyph, `nestedIcon` a submenu trigger's — set whichever apply; an unset one\nkeeps the built-in ▼/▶ for that case. Set them once, as early as possible (an app's entry\npoint, before any triggers connect) — Lit calls `render()` fresh on every update, so an\nalready-connected instance only reflects the change once something causes it to re-render:\n\n```ts\n// A bare string or TemplateResult is used as-is, on every trigger of that kind:\nUseCaret.icon = \"▾\";\nUseCaret.nestedIcon = \"▸\";\n\n// A function is called on every render instead:\nUseCaret.nestedIcon = (html) => html`<my-icon name=\"chevron-right\"></my-icon>`;\n```\n\nThe function form is called with the component's own `html` tag as its (optional) first\nargument rather than requiring the caller to import one — a page can end up with more than one\ncopy of `lit-html` in its module graph, and a `TemplateResult` built from a *different* copy\nthan the one this component renders with can silently fail to render. Taking `html` in as a\nparameter sidesteps that: whatever's returned is guaranteed to come from the same `lit-html`\nthis component already uses. A bare string skips the concern entirely.\n\nOnly need to change the icon on **some** triggers, not every one in the app? Extend the\nclass, override `render()` normally, and register the subclass under a different tag name so\nit coexists with the built-in element instead of replacing it everywhere:\n\n```ts\nclass MyCaret extends UseCaret {\n override render() {\n return html`<slot></slot><slot name=\"icon\"><my-icon name=\"chevron\"></my-icon></slot>`;\n }\n}\ncustomElements.define(\"my-caret\", MyCaret);\n```\n---\n\n\n### **Slots:**\n - **default** - Trigger label content.\n- **icon** - Replaces the default caret glyph.",
|
|
63
|
+
"attributes": [],
|
|
64
|
+
"references": []
|
|
65
|
+
},
|
|
60
66
|
{
|
|
61
67
|
"name": "use-date-input",
|
|
62
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",
|
|
@@ -68,12 +74,6 @@
|
|
|
68
74
|
],
|
|
69
75
|
"references": []
|
|
70
76
|
},
|
|
71
|
-
{
|
|
72
|
-
"name": "use-caret",
|
|
73
|
-
"description": "`use-caret` supplies the caret icon and label layout for a consumer who wants to own the\ninvoking button itself. It renders inside a plain `<button>`\nthat carries the native `popovertarget` attribute, pointing at a `use-menu`:\n\n```html\n<button id=\"thing\" popovertarget=\"thing-menu\">\n <use-caret>Menu</use-caret>\n</button>\n<use-menu id=\"thing-menu\" aria-label=\"Menu\">\n <button role=\"menuitem\">First thing</button>\n</use-menu>\n```\n\n`use-menu` finds this button on its own via `popovertarget` and anchors to it — no\n`anchortarget` needed here; that's only for a menu with more than one invoker. See `use-menu`'s\nown docs for that case.\n\nThe button is entirely the consumer's own element — their classes, their content, their event\nhandlers. `use-caret` contributes no interactivity of its own: no internal button, no focus\ntarget, no state. It only renders the label and caret glyph, so consumers get a consistent\nvisual trigger without giving up control of the button.\n\nThe caret direction is derived rather than configured: a trigger nested inside a `use-menu`\nis understood to open a submenu and renders pointing sideways; a top-level trigger renders\npointing down.\n\nSwapping in a different caret **per instance** is a slot: put your own element in the `icon`\nslot and it replaces `part(icon-default)` entirely for that trigger.\n\nSwapping the default caret **for every trigger in the app** doesn't need touching this\ncomponent's `render()` at all — style `::part(icon-default)` from an outside stylesheet, the\nsame way any shadow DOM part is themed:\n\n```css\nuse-caret::part(icon-default) {\n mask-image: url(\"/icons/my-caret.svg\");\n}\n```\n\n(When the design system's `theme.css` is loaded, this is already wired to a token —\n`--usewc-effect-dropdown-trigger-icon-mask-image` — so redefining that custom property has\nthe same effect without writing a `::part()` rule at all.)\n\n`::part()` only reaches CSS-expressible changes (a mask, a background, a transform). For\nanything else — different markup, an icon font, logic beyond a mask — set the static `icon`\nand `nestedIcon` hooks. Every `<use-caret>` in the page picks them up; consumers keep writing\nthe same tag, no new element to register or remember to use instead. `icon` supplies a\ntop-level trigger's glyph, `nestedIcon` a submenu trigger's — set whichever apply; an unset one\nkeeps the built-in ▼/▶ for that case. Set them once, as early as possible (an app's entry\npoint, before any triggers connect) — Lit calls `render()` fresh on every update, so an\nalready-connected instance only reflects the change once something causes it to re-render:\n\n```ts\n// A bare string or TemplateResult is used as-is, on every trigger of that kind:\nUseCaret.icon = \"▾\";\nUseCaret.nestedIcon = \"▸\";\n\n// A function is called on every render instead:\nUseCaret.nestedIcon = (html) => html`<my-icon name=\"chevron-right\"></my-icon>`;\n```\n\nThe function form is called with the component's own `html` tag as its (optional) first\nargument rather than requiring the caller to import one — a page can end up with more than one\ncopy of `lit-html` in its module graph, and a `TemplateResult` built from a *different* copy\nthan the one this component renders with can silently fail to render. Taking `html` in as a\nparameter sidesteps that: whatever's returned is guaranteed to come from the same `lit-html`\nthis component already uses. A bare string skips the concern entirely.\n\nOnly need to change the icon on **some** triggers, not every one in the app? Extend the\nclass, override `render()` normally, and register the subclass under a different tag name so\nit coexists with the built-in element instead of replacing it everywhere:\n\n```ts\nclass MyCaret extends UseCaret {\n override render() {\n return html`<slot></slot><slot name=\"icon\"><my-icon name=\"chevron\"></my-icon></slot>`;\n }\n}\ncustomElements.define(\"my-caret\", MyCaret);\n```\n---\n\n\n### **Slots:**\n - **default** - Trigger label content.\n- **icon** - Replaces the default caret glyph.",
|
|
74
|
-
"attributes": [],
|
|
75
|
-
"references": []
|
|
76
|
-
},
|
|
77
77
|
{
|
|
78
78
|
"name": "use-date-picker",
|
|
79
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",
|
|
@@ -252,6 +252,58 @@
|
|
|
252
252
|
],
|
|
253
253
|
"references": []
|
|
254
254
|
},
|
|
255
|
+
{
|
|
256
|
+
"name": "use-intl-number",
|
|
257
|
+
"description": "Displays a localized, human-readable representation of a number using\n[`Intl.NumberFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat).\nRenders a semantic `<data>` element in its shadow root with a machine-readable\n`value` attribute and formatted inner text.\n\nSet `numberstyle` to control what kind of number is formatted (see\n[`style`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#style)):\n- `decimal` (default) → plain number, e.g. `1,234.5`\n- `percent` → percentage, e.g. `42%` (value is the fraction, so `0.42` renders `42%`)\n- `currency` → currency amount, requires `currency`\n- `unit` → measurement, requires `unit`\n\nLocale is resolved from the nearest ancestor `[lang]` attribute, or\n`navigator.language` if none is found. Set `lang` directly on the element to override.\n---\n",
|
|
258
|
+
"attributes": [
|
|
259
|
+
{
|
|
260
|
+
"name": "value",
|
|
261
|
+
"description": "Numeric amount to format",
|
|
262
|
+
"values": []
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"name": "numberstyle",
|
|
266
|
+
"description": "Format style: `decimal` | `percent` | `currency` | `unit`",
|
|
267
|
+
"values": []
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
"name": "currency",
|
|
271
|
+
"description": "[ISO 4217 currency code](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currency), e.g. `USD`, `EUR`, `JPY`. Required when numberstyle is `currency`",
|
|
272
|
+
"values": []
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
"name": "currencydisplay",
|
|
276
|
+
"description": "[How the currency is denoted](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencydisplay): `symbol` | `narrowSymbol` | `code` | `name`",
|
|
277
|
+
"values": []
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
"name": "currencysign",
|
|
281
|
+
"description": "[Sign convention](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencysign): `standard` (minus sign) | `accounting` (parenthesized negatives)",
|
|
282
|
+
"values": []
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
"name": "unit",
|
|
286
|
+
"description": "[Unit identifier](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#unit), e.g. `kilometer-per-hour`, `liter`. Required when numberstyle is `unit`",
|
|
287
|
+
"values": []
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"name": "unitdisplay",
|
|
291
|
+
"description": "[How the unit is denoted](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#unitdisplay): `short` | `narrow` | `long`",
|
|
292
|
+
"values": []
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
"name": "signdisplay",
|
|
296
|
+
"description": "[When to show the sign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#signdisplay): `auto` | `always` | `exceptZero` | `never`",
|
|
297
|
+
"values": []
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
"name": "lang",
|
|
301
|
+
"description": "BCP 47 locale tag. Inherits from nearest ancestor `[lang]` if not set.",
|
|
302
|
+
"values": []
|
|
303
|
+
}
|
|
304
|
+
],
|
|
305
|
+
"references": []
|
|
306
|
+
},
|
|
255
307
|
{
|
|
256
308
|
"name": "use-listbox-input",
|
|
257
309
|
"description": "\n---\n\n\n### **Events:**\n - **use-change**\n\n### **Slots:**\n - **default** - NodeList of `use-option` elements",
|