@ngrok/mantle 0.90.4 → 0.91.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordion.d.ts +3 -5
- package/dist/agent.json +7 -7
- package/dist/{alert-CTAmHdLa.d.ts → alert-BV0VWU2o.d.ts} +5 -7
- package/dist/{alert-xJELJxL4.js → alert-BVQcPzmf.js} +1 -1
- package/dist/alert-center.d.ts +2 -4
- package/dist/alert-center.js +1 -1
- package/dist/alert-dialog.d.ts +5 -7
- package/dist/alert-dialog.js +1 -1
- package/dist/alert.d.ts +1 -1
- package/dist/alert.js +1 -1
- package/dist/anchor.d.ts +2 -6
- package/dist/app-layout.d.ts +3 -7
- package/dist/app-layout.js +1 -1
- package/dist/area-chart.d.ts +2 -4
- package/dist/area-chart.js +1 -1
- package/dist/{as-child-D23mGo4f.d.ts → as-child-DFxX3U2i.d.ts} +0 -2
- package/dist/avatar.d.ts +2 -4
- package/dist/badge.d.ts +3 -5
- package/dist/bar-chart.d.ts +2 -4
- package/dist/bar-chart.js +1 -1
- package/dist/breadcrumb.d.ts +2 -6
- package/dist/breadcrumb.js +1 -1
- package/dist/browser-only.d.ts +0 -2
- package/dist/{button-BZT5f79d.d.ts → button-BFAvonp1.d.ts} +3 -7
- package/dist/{button-mzUR1U0Y.d.ts → button-BOCRKR5v.d.ts} +3 -7
- package/dist/button-CZ-q7fYv.js +1 -0
- package/dist/button-Cwrv2Mwv.js +1 -0
- package/dist/{button-BRjAW1ec.d.ts → button-Dt9LZMT5.d.ts} +5 -7
- package/dist/{button-BCoI4bhP.d.ts → button-L4exxu_L.d.ts} +0 -2
- package/dist/button.d.ts +4 -4
- package/dist/button.js +1 -1
- package/dist/calendar.d.ts +1 -3
- package/dist/card.d.ts +3 -5
- package/dist/centered-layout.d.ts +9 -32
- package/dist/chart-D2LtDZtV.js +2 -0
- package/dist/{chart-23KQ1ZNO.d.ts → chart-ynMysD16.d.ts} +40 -15
- package/dist/checkbox.d.ts +2 -4
- package/dist/{choice-BCiyqLgO.d.ts → choice-BLR0_MeB.d.ts} +3 -5
- package/dist/choice.d.ts +1 -1
- package/dist/{code-block-D5eDP379.d.ts → code-block-Bqw9VyK_.d.ts} +0 -22
- package/dist/code-block.d.ts +4 -12
- package/dist/code-block.js +6 -6
- package/dist/code-block_highlight-utils.d.ts +1 -1
- package/dist/code.d.ts +2 -4
- package/dist/color.d.ts +1 -1
- package/dist/combobox.d.ts +4 -6
- package/dist/combobox.js +1 -1
- package/dist/command.d.ts +3 -13
- package/dist/command.js +1 -1
- package/dist/cx.d.ts +0 -6
- package/dist/{data-slot-CChfb_cv.d.ts → data-slot-B-LqAcBB.d.ts} +0 -2
- package/dist/data-table.d.ts +5 -9
- package/dist/data-table.js +1 -1
- package/dist/description-list.d.ts +3 -5
- package/dist/{dialog-C9QGvVNG.js → dialog-D333NTyf.js} +1 -1
- package/dist/{dialog-CgwSNHs1.d.ts → dialog-DedsCsnk.d.ts} +3 -5
- package/dist/{dialog-CZYD3xL-.d.ts → dialog-Dp0QGWwo.d.ts} +0 -2
- package/dist/dialog.d.ts +2 -2
- package/dist/dialog.js +1 -1
- package/dist/{direction-BjU0bPST.d.ts → direction-CpRzTtZh.d.ts} +0 -2
- package/dist/{dropdown-menu-Cef0Cz2B.d.ts → dropdown-menu-ByQQIsQE.d.ts} +2 -4
- package/dist/dropdown-menu.d.ts +1 -2
- package/dist/empty.d.ts +3 -5
- package/dist/{field-7QeiTFwl.d.ts → field-V_gnkcmN.d.ts} +0 -2
- package/dist/field.d.ts +7 -15
- package/dist/field.js +1 -1
- package/dist/flag.d.ts +1 -5
- package/dist/hooks.d.ts +1 -37
- package/dist/hover-card.d.ts +1 -3
- package/dist/{icon-ucVgZeXn.d.ts → icon-ByLVhdYq.d.ts} +2 -4
- package/dist/{icon-D1RY5Tcj.d.ts → icon-CgNqu-fl.d.ts} +0 -2
- package/dist/{icon-r2NvfTWW.d.ts → icon-DXDyhy2N.d.ts} +2 -4
- package/dist/icon.d.ts +3 -3
- package/dist/icons-DykpsXNX.js +1 -0
- package/dist/icons.d.ts +3 -17
- package/dist/icons.js +1 -1
- package/dist/{in-view-Ch5vJtWo.d.ts → in-view-B3nMAzfE.d.ts} +0 -6
- package/dist/{index-DorCusfG.d.ts → index-BZhHLrBi.d.ts} +0 -2
- package/dist/{index-DA4ig3gj.d.ts → index-C6s5cGCr.d.ts} +2 -10
- package/dist/{input-eEKzP3cE.js → input-CpQ6jlpI.js} +1 -1
- package/dist/{input-bbB1tC0h.d.ts → input-Dx5owTCc.d.ts} +2 -6
- package/dist/input.d.ts +3 -7
- package/dist/input.js +1 -1
- package/dist/kbd.d.ts +1 -3
- package/dist/{label-C-KbNls8.d.ts → label-Dn5CPJUj.d.ts} +1 -3
- package/dist/label.d.ts +1 -1
- package/dist/layer-container.d.ts +0 -2
- package/dist/line-chart.d.ts +2 -4
- package/dist/line-chart.js +1 -1
- package/dist/list.d.ts +2 -8
- package/dist/live-region.d.ts +2 -4
- package/dist/llms.txt +4 -4
- package/dist/main.d.ts +1 -3
- package/dist/mantle-dark.css +2 -12
- package/dist/mantle.css +75 -13
- package/dist/media-object.d.ts +2 -4
- package/dist/migrations/0011-eliminate-high-contrast.yml +869 -0
- package/dist/multi-select.d.ts +4 -6
- package/dist/multi-select.js +1 -1
- package/dist/otp-input.d.ts +3 -5
- package/dist/pagination.d.ts +3 -7
- package/dist/pagination.js +1 -1
- package/dist/{popover-Dvls7-j4.d.ts → popover-BfB2I9G0.d.ts} +1 -3
- package/dist/popover.d.ts +1 -1
- package/dist/progress.d.ts +1 -7
- package/dist/qr-code.d.ts +2 -4
- package/dist/radio-group.d.ts +2 -4
- package/dist/radio-group.js +1 -1
- package/dist/sandbar.d.ts +5 -8
- package/dist/sandbar.js +1 -1
- package/dist/sandboxed-on-click.d.ts +1 -3
- package/dist/scatter-plot.d.ts +2 -4
- package/dist/scatter-plot.js +1 -1
- package/dist/{select-DlohFa54.d.ts → select-CRp_ndSJ.d.ts} +3 -5
- package/dist/select-iMsy6TFv.js +1 -0
- package/dist/select.d.ts +1 -1
- package/dist/select.js +1 -1
- package/dist/selectable-list.d.ts +3 -5
- package/dist/selectable-list.js +1 -1
- package/dist/{separator-BWGjCIl7.d.ts → separator-DNovVsrx.d.ts} +3 -5
- package/dist/separator.d.ts +1 -1
- package/dist/{sheet-CAFS09pT.js → sheet-gMTepUM_.js} +1 -1
- package/dist/sheet.d.ts +3 -5
- package/dist/sheet.js +1 -1
- package/dist/sidebar.d.ts +5 -9
- package/dist/sidebar.js +1 -1
- package/dist/{skeleton-zfqoDAxT.js → skeleton-DBpI-ko5.js} +1 -1
- package/dist/skeleton.d.ts +2 -4
- package/dist/skeleton.js +1 -1
- package/dist/skip-to-main-link.d.ts +1 -3
- package/dist/slider.d.ts +1 -3
- package/dist/{slot-Q996Hqk9.d.ts → slot-C0OCJjdJ.d.ts} +2 -4
- package/dist/slot.d.ts +1 -1
- package/dist/split-button.d.ts +5 -7
- package/dist/split-button.js +1 -1
- package/dist/strata.d.ts +2 -4
- package/dist/switch.d.ts +2 -4
- package/dist/{table-BhzITa19.d.ts → table-vT6Okwfa.d.ts} +1 -3
- package/dist/table.d.ts +1 -1
- package/dist/tabs.d.ts +3 -5
- package/dist/text-area.d.ts +2 -4
- package/dist/text-area.js +1 -1
- package/dist/theme-BD0ly6jo.js +1 -0
- package/dist/theme-switcher.d.ts +67 -213
- package/dist/theme-switcher.js +1 -1
- package/dist/{theme-6OxNhf6l.d.ts → theme-w1CrMM-x.d.ts} +3 -5
- package/dist/theme.d.ts +78 -177
- package/dist/theme.js +1 -1
- package/dist/toast.d.ts +4 -6
- package/dist/toast.js +1 -1
- package/dist/{tooltip-CngH7Kl6.d.ts → tooltip-NcLIeBy5.d.ts} +1 -3
- package/dist/tooltip.d.ts +1 -1
- package/dist/truncated-text.d.ts +2 -4
- package/dist/types.d.ts +3 -3
- package/dist/utils.d.ts +2 -4
- package/dist/visually-hidden.d.ts +2 -4
- package/dist/well.d.ts +3 -5
- package/dist/{with-style-props-Dq5Vntqy.d.ts → with-style-props-CuT30s0W.d.ts} +0 -2
- package/package.json +2 -10
- package/dist/button-Bkl_QYpp.js +0 -1
- package/dist/button-b2HKEIE2.js +0 -1
- package/dist/chart-BfJ835dr.js +0 -2
- package/dist/dropdown-menu-DMA8dGxZ.d.ts +0 -1
- package/dist/icons-CW9lV9E1.js +0 -1
- package/dist/mantle-dark-high-contrast.css +0 -354
- package/dist/mantle-light-high-contrast.css +0 -353
- package/dist/select-Os5GVejP.js +0 -1
- package/dist/theme-Dzem-qRB.js +0 -1
package/dist/theme-switcher.d.ts
CHANGED
|
@@ -1,47 +1,43 @@
|
|
|
1
|
-
import { t as WithDataSlot } from "./data-slot-
|
|
2
|
-
import { t as WithStyleProps } from "./with-style-props-
|
|
3
|
-
import { n as IconButtonProps, r as IconButtonAppearance } from "./button-
|
|
4
|
-
import { t as DropdownMenu } from "./dropdown-menu-Cef0Cz2B.js";
|
|
5
|
-
import "./dropdown-menu-DMA8dGxZ.js";
|
|
6
|
-
import { ComponentProps } from "react";
|
|
7
|
-
//#region src/components/theme-switcher/theme-switcher.d.ts
|
|
1
|
+
import { t as WithDataSlot } from "./data-slot-B-LqAcBB.js";
|
|
2
|
+
import { t as WithStyleProps } from "./with-style-props-CuT30s0W.js";
|
|
3
|
+
import { n as IconButtonProps, r as IconButtonAppearance } from "./button-BFAvonp1.js";
|
|
8
4
|
/**
|
|
9
|
-
* The props for the `
|
|
5
|
+
* The props for the `ThemeDropdownMenuItem` component.
|
|
10
6
|
*/
|
|
11
|
-
type
|
|
7
|
+
type ThemeDropdownMenuItemProps = WithStyleProps & {
|
|
8
|
+
/**
|
|
9
|
+
* The visible label of the item. When set, it is also the accessible
|
|
10
|
+
* name. When omitted, the label is "Theme", and the accessible name also
|
|
11
|
+
* says which theme the next press shows, such as "Theme: Switch to dark
|
|
12
|
+
* theme". Set it for localization.
|
|
13
|
+
*/
|
|
14
|
+
label?: string;
|
|
15
|
+
};
|
|
12
16
|
/**
|
|
13
17
|
* Must render inside a `DropdownMenu.Content` or `DropdownMenu.SubContent` —
|
|
14
18
|
* the type system cannot express this constraint, so it is on you to uphold it.
|
|
15
19
|
*
|
|
16
|
-
* The
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* existing menu (e.g. an account menu submenu); for a standalone picker,
|
|
22
|
-
* reach for `ThemeSwitcher` instead.
|
|
20
|
+
* The light/dark toggle for an existing menu, such as an account menu: one
|
|
21
|
+
* "Theme" row that ends in the `ThemeSwitcher` icon. It is the menu form of
|
|
22
|
+
* `ThemeSwitcher`. A press flips the theme the same way a `ThemeSwitcher`
|
|
23
|
+
* click does, and the icon swaps between the sun and the moon. The menu stays
|
|
24
|
+
* open, and the new theme grows in a circle from the icon.
|
|
23
25
|
*
|
|
24
|
-
*
|
|
25
|
-
* `
|
|
26
|
-
*
|
|
26
|
+
* Reads and writes the theme via `useTheme`, so it must render inside a
|
|
27
|
+
* `ThemeProvider`. Under a provider with `forceTheme`, it shows the forced
|
|
28
|
+
* theme and is disabled. For a control in a header or toolbar, use
|
|
29
|
+
* `ThemeSwitcher` instead.
|
|
27
30
|
*
|
|
28
|
-
*
|
|
31
|
+
* **Data attributes:**
|
|
29
32
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* </DropdownMenu.Trigger>
|
|
37
|
-
* <DropdownMenu.Content>
|
|
38
|
-
* <ThemeDropdownMenuRadioGroup />
|
|
39
|
-
* </DropdownMenu.Content>
|
|
40
|
-
* </DropdownMenu.Root>
|
|
41
|
-
* ```
|
|
33
|
+
* | Data Attribute | Value | Description |
|
|
34
|
+
* | --- | --- | --- |
|
|
35
|
+
* | `data-slot` | `"theme-dropdown-menu-item"` | On the item element. |
|
|
36
|
+
* | `data-slot` | `"theme-dropdown-menu-item-label"` | On the `<span>` that holds the `label`. |
|
|
37
|
+
*
|
|
38
|
+
* @see https://mantle.ngrok.com/components/forms/theme-switcher#themedropdownmenuitem
|
|
42
39
|
*
|
|
43
40
|
* @example
|
|
44
|
-
* Embedded in a submenu of an existing menu (e.g. an account menu):
|
|
45
41
|
* ```tsx
|
|
46
42
|
* <DropdownMenu.Root>
|
|
47
43
|
* <DropdownMenu.Trigger asChild>
|
|
@@ -49,210 +45,68 @@ type ThemeDropdownMenuRadioGroupProps = WithStyleProps & Pick<ComponentProps<"di
|
|
|
49
45
|
* </DropdownMenu.Trigger>
|
|
50
46
|
* <DropdownMenu.Content>
|
|
51
47
|
* <DropdownMenu.Item>Profile</DropdownMenu.Item>
|
|
52
|
-
* <
|
|
53
|
-
* <DropdownMenu.SubTrigger>Theme</DropdownMenu.SubTrigger>
|
|
54
|
-
* <DropdownMenu.SubContent>
|
|
55
|
-
* <ThemeDropdownMenuRadioGroup />
|
|
56
|
-
* </DropdownMenu.SubContent>
|
|
57
|
-
* </DropdownMenu.Sub>
|
|
48
|
+
* <ThemeDropdownMenuItem />
|
|
58
49
|
* </DropdownMenu.Content>
|
|
59
50
|
* </DropdownMenu.Root>
|
|
60
51
|
* ```
|
|
61
52
|
*/
|
|
62
|
-
declare
|
|
63
|
-
/**
|
|
64
|
-
* The props for the `ThemeSwitcher.Root` component. Identical to
|
|
65
|
-
* `DropdownMenu.Root`'s props — `Root` forwards everything through.
|
|
66
|
-
*/
|
|
67
|
-
type ThemeSwitcherRootProps = ComponentProps<typeof DropdownMenu.Root>;
|
|
68
|
-
/**
|
|
69
|
-
* The stateful root of the theme switcher: a thin forwarding wrapper over
|
|
70
|
-
* `DropdownMenu.Root` that owns the menu's open/closed state. Renders no DOM
|
|
71
|
-
* of its own. Compose `ThemeSwitcher.Trigger` and `ThemeSwitcher.Content`
|
|
72
|
-
* inside it.
|
|
73
|
-
*
|
|
74
|
-
* @see https://mantle.ngrok.com/components/forms/theme-switcher
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* ```tsx
|
|
78
|
-
* <ThemeSwitcher.Root>
|
|
79
|
-
* <ThemeSwitcher.Trigger />
|
|
80
|
-
* <ThemeSwitcher.Content />
|
|
81
|
-
* </ThemeSwitcher.Root>
|
|
82
|
-
* ```
|
|
83
|
-
*/
|
|
84
|
-
declare const Root: (props: ThemeSwitcherRootProps) => import("react").JSX.Element;
|
|
53
|
+
declare function ThemeDropdownMenuItem({ className, label, style }: ThemeDropdownMenuItemProps): import("react").JSX.Element;
|
|
85
54
|
/**
|
|
86
|
-
* The props for the `ThemeSwitcher
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
55
|
+
* The props for the `ThemeSwitcher` component. Forwards `IconButton`'s props,
|
|
56
|
+
* except the parts the switcher owns: `icon` (the SSR-safe themed icon) and
|
|
57
|
+
* `intent` (always `"neutral"`). `asChild` and `children` are removed: the
|
|
58
|
+
* switcher renders only its icon (the `label` renders as `aria-label`), so
|
|
59
|
+
* both would be silently meaningless. `appearance` and `label` become optional
|
|
60
|
+
* with theme-switcher defaults.
|
|
92
61
|
*/
|
|
93
|
-
type
|
|
62
|
+
type ThemeSwitcherProps = Omit<IconButtonProps, "appearance" | "asChild" | "children" | "icon" | "intent" | "label"> & WithDataSlot & {
|
|
94
63
|
/**
|
|
95
|
-
* The visual style of the
|
|
96
|
-
*
|
|
97
|
-
* quietly in headers and toolbars.
|
|
64
|
+
* The visual style of the `IconButton`. Optional here: `ThemeSwitcher`
|
|
65
|
+
* defaults to `"ghost"` so it sits quietly in headers and toolbars.
|
|
98
66
|
*
|
|
99
67
|
* @default "ghost"
|
|
100
68
|
*/
|
|
101
69
|
appearance?: IconButtonAppearance;
|
|
102
70
|
/**
|
|
103
|
-
* The accessible name
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
71
|
+
* The accessible name of the button, rendered as its `aria-label`. When
|
|
72
|
+
* omitted, the name says which theme the next click shows, such as
|
|
73
|
+
* "Switch to dark theme" or "Switch to light theme (system default)".
|
|
74
|
+
* Set it for localization.
|
|
107
75
|
*/
|
|
108
76
|
label?: string;
|
|
109
77
|
};
|
|
110
78
|
/**
|
|
111
|
-
* The
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* `
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* </ThemeSwitcher.Root>
|
|
126
|
-
* ```
|
|
127
|
-
*/
|
|
128
|
-
declare const Trigger: ({ appearance, "data-slot": dataSlot, disabled, label, ref, ...props }: ThemeSwitcherTriggerProps) => import("react").JSX.Element;
|
|
129
|
-
/**
|
|
130
|
-
* The props for the `ThemeSwitcher.Content` component. Identical to
|
|
131
|
-
* `DropdownMenu.Content`'s props — positioning and collision behavior
|
|
132
|
-
* (`align`, `side`, `collisionPadding`, …) plus `className`/`style` all
|
|
133
|
-
* forward through.
|
|
134
|
-
*/
|
|
135
|
-
type ThemeSwitcherContentProps = ComponentProps<typeof DropdownMenu.Content> & WithDataSlot;
|
|
136
|
-
/**
|
|
137
|
-
* The popover the trigger opens: a thin forwarding wrapper over
|
|
138
|
-
* `DropdownMenu.Content`. When `children` are omitted (or `null`/`undefined`)
|
|
139
|
-
* it renders `ThemeDropdownMenuRadioGroup`, the five-theme radio group; pass
|
|
140
|
-
* `children` to own the menu contents instead (compose
|
|
141
|
-
* `ThemeDropdownMenuRadioGroup` yourself alongside extra items). Any
|
|
142
|
-
* non-nullish children replace the default entirely, including render-nothing
|
|
143
|
-
* values like `false`; a lone `{condition && <Item />}` child suppresses the
|
|
144
|
-
* radio group when the condition is false.
|
|
79
|
+
* The canonical theme control for headers and toolbars: an `IconButton`
|
|
80
|
+
* (ghost by default) that shows the applied theme and flips between light and
|
|
81
|
+
* dark on each click. The new theme grows in a circle from the button in a
|
|
82
|
+
* view transition, and swaps at once under reduced motion. It stores three
|
|
83
|
+
* states with two visible ones. A click
|
|
84
|
+
* shows the opposite of the applied theme, and stores `"system"` instead of a
|
|
85
|
+
* pin when that opposite matches the OS preference. So a second click always
|
|
86
|
+
* returns the user to the OS default.
|
|
87
|
+
*
|
|
88
|
+
* Reads and writes the theme via `useTheme`, so it must render inside a
|
|
89
|
+
* `ThemeProvider`. Under a provider with `forceTheme`, it shows the forced
|
|
90
|
+
* theme and is disabled, because a click cannot change what the page shows. The icon is SSR-safe: a `Skeleton` renders until
|
|
91
|
+
* hydration, then the icon of the applied theme. To put the same control in
|
|
92
|
+
* an existing menu, use `ThemeDropdownMenuItem`.
|
|
145
93
|
*
|
|
146
94
|
* @see https://mantle.ngrok.com/components/forms/theme-switcher
|
|
147
|
-
*
|
|
148
|
-
* @example
|
|
149
|
-
* ```tsx
|
|
150
|
-
* <ThemeSwitcher.Root>
|
|
151
|
-
* <ThemeSwitcher.Trigger />
|
|
152
|
-
* <ThemeSwitcher.Content align="end" collisionPadding={{ right: 16 }} />
|
|
153
|
-
* </ThemeSwitcher.Root>
|
|
154
|
-
* ```
|
|
155
|
-
*
|
|
156
|
-
* @example
|
|
157
|
-
* Extending the menu beyond theme selection:
|
|
158
|
-
* ```tsx
|
|
159
|
-
* <ThemeSwitcher.Content>
|
|
160
|
-
* <ThemeDropdownMenuRadioGroup />
|
|
161
|
-
* <DropdownMenu.Separator />
|
|
162
|
-
* <DropdownMenu.Item>Appearance settings…</DropdownMenu.Item>
|
|
163
|
-
* </ThemeSwitcher.Content>
|
|
164
|
-
* ```
|
|
165
|
-
*/
|
|
166
|
-
declare const Content: ({ children, "data-slot": dataSlot, ...props }: ThemeSwitcherContentProps) => import("react").JSX.Element;
|
|
167
|
-
/**
|
|
168
|
-
* The canonical picker for mantle's theme system: a compact `IconButton`
|
|
169
|
-
* trigger (ghost by default) that opens a `DropdownMenu` hosting
|
|
170
|
-
* `ThemeDropdownMenuRadioGroup`, the theme-selection radio group.
|
|
171
|
-
*
|
|
172
|
-
* Reads and writes the active theme via `useTheme`, so it must render inside
|
|
173
|
-
* a `ThemeProvider` — `useTheme` throws outside of one.
|
|
174
|
-
*
|
|
175
|
-
* To embed theme selection in an existing menu instead (e.g. an account menu
|
|
176
|
-
* submenu), use `ThemeDropdownMenuRadioGroup` directly.
|
|
177
|
-
*
|
|
178
|
-
* @see https://mantle.ngrok.com/components/forms/theme-switcher
|
|
179
|
-
*
|
|
180
|
-
* @example
|
|
181
|
-
* Composition:
|
|
182
|
-
* ```
|
|
183
|
-
* ThemeSwitcher.Root
|
|
184
|
-
* ├── ThemeSwitcher.Trigger
|
|
185
|
-
* └── ThemeSwitcher.Content
|
|
186
|
-
* ```
|
|
95
|
+
* @see https://lea.verou.me/blog/2026/dark-mode-toggles/
|
|
187
96
|
*
|
|
188
97
|
* @example
|
|
189
98
|
* ```tsx
|
|
190
99
|
* <ThemeProvider>
|
|
191
100
|
* <header>
|
|
192
|
-
* <ThemeSwitcher
|
|
193
|
-
* <ThemeSwitcher.Trigger />
|
|
194
|
-
* <ThemeSwitcher.Content />
|
|
195
|
-
* </ThemeSwitcher.Root>
|
|
101
|
+
* <ThemeSwitcher />
|
|
196
102
|
* </header>
|
|
197
103
|
* </ThemeProvider>
|
|
198
104
|
* ```
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```tsx
|
|
108
|
+
* <ThemeSwitcher appearance="outlined" label="Cambiar tema" />
|
|
109
|
+
* ```
|
|
199
110
|
*/
|
|
200
|
-
declare
|
|
201
|
-
|
|
202
|
-
* The stateful root: a thin forwarding wrapper over `DropdownMenu.Root`
|
|
203
|
-
* that owns the menu's open/closed state. Renders no DOM of its own.
|
|
204
|
-
*
|
|
205
|
-
* @see https://mantle.ngrok.com/components/forms/theme-switcher
|
|
206
|
-
*
|
|
207
|
-
* @example
|
|
208
|
-
* ```tsx
|
|
209
|
-
* <ThemeSwitcher.Root>
|
|
210
|
-
* <ThemeSwitcher.Trigger />
|
|
211
|
-
* <ThemeSwitcher.Content />
|
|
212
|
-
* </ThemeSwitcher.Root>
|
|
213
|
-
* ```
|
|
214
|
-
*/
|
|
215
|
-
readonly Root: typeof Root;
|
|
216
|
-
/**
|
|
217
|
-
* The button that opens the theme menu: an `IconButton` (ghost by default)
|
|
218
|
-
* wired up as the menu trigger. The trigger icon is SSR-safe: the applied
|
|
219
|
-
* theme is unknowable server-side, so a `Skeleton` renders until hydration,
|
|
220
|
-
* then the icon matching the applied theme. The icon is owned by the trigger;
|
|
221
|
-
* to render a completely custom trigger, compose `DropdownMenu` +
|
|
222
|
-
* `ThemeDropdownMenuRadioGroup` directly instead.
|
|
223
|
-
*
|
|
224
|
-
* @see https://mantle.ngrok.com/components/forms/theme-switcher
|
|
225
|
-
*
|
|
226
|
-
* @example
|
|
227
|
-
* ```tsx
|
|
228
|
-
* <ThemeSwitcher.Root>
|
|
229
|
-
* <ThemeSwitcher.Trigger appearance="outlined" label="Choose a theme" />
|
|
230
|
-
* <ThemeSwitcher.Content />
|
|
231
|
-
* </ThemeSwitcher.Root>
|
|
232
|
-
* ```
|
|
233
|
-
*/
|
|
234
|
-
readonly Trigger: typeof Trigger;
|
|
235
|
-
/**
|
|
236
|
-
* The popover the trigger opens: a thin forwarding wrapper over
|
|
237
|
-
* `DropdownMenu.Content`. When `children` are omitted (or `null`/`undefined`)
|
|
238
|
-
* it renders `ThemeDropdownMenuRadioGroup`, the five-theme radio group; pass
|
|
239
|
-
* `children` to own the menu contents instead (compose
|
|
240
|
-
* `ThemeDropdownMenuRadioGroup` yourself alongside extra items). Any
|
|
241
|
-
* non-nullish children replace the default entirely, including render-nothing
|
|
242
|
-
* values like `false`; a lone `{condition && <Item />}` child suppresses the
|
|
243
|
-
* radio group when the condition is false.
|
|
244
|
-
*
|
|
245
|
-
* @see https://mantle.ngrok.com/components/forms/theme-switcher
|
|
246
|
-
*
|
|
247
|
-
* @example
|
|
248
|
-
* ```tsx
|
|
249
|
-
* <ThemeSwitcher.Root>
|
|
250
|
-
* <ThemeSwitcher.Trigger />
|
|
251
|
-
* <ThemeSwitcher.Content align="end" collisionPadding={{ right: 16 }} />
|
|
252
|
-
* </ThemeSwitcher.Root>
|
|
253
|
-
* ```
|
|
254
|
-
*/
|
|
255
|
-
readonly Content: typeof Content;
|
|
256
|
-
};
|
|
257
|
-
//#endregion
|
|
258
|
-
export { ThemeDropdownMenuRadioGroup, type ThemeDropdownMenuRadioGroupProps, ThemeSwitcher, type ThemeSwitcherContentProps, type ThemeSwitcherRootProps, type ThemeSwitcherTriggerProps };
|
|
111
|
+
declare function ThemeSwitcher({ appearance, "data-slot": dataSlot, disabled, label, onClick, ...props }: ThemeSwitcherProps): import("react").JSX.Element;
|
|
112
|
+
export { ThemeDropdownMenuItem, type ThemeDropdownMenuItemProps, ThemeSwitcher, type ThemeSwitcherProps };
|
package/dist/theme-switcher.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./data-slot-EM6s2WEU.js";import{
|
|
1
|
+
import{t as e}from"./cx-CK7o_rVv.js";import{t}from"./data-slot-EM6s2WEU.js";import{r as n}from"./button-CZ-q7fYv.js";import{t as r}from"./button-Cwrv2Mwv.js";import{t as i}from"./use-matches-media-query-m860lols.js";import{t as a}from"./use-is-hydrated-DDCqXmju.js";import{t as o}from"./browser-only-Crr3sgA0.js";import{t as s}from"./skeleton-DBpI-ko5.js";import{t as c}from"./dropdown-menu-j4RbBbGa.js";import{c as l,p as u,s as d,u as f}from"./theme-BD0ly6jo.js";import{n as p}from"./icons-DykpsXNX.js";import{c as m}from"react/compiler-runtime";import{useRef as h}from"react";import{jsx as g,jsxs as _}from"react/jsx-runtime";const v={light:/* @__PURE__ */ g(p,{theme:`light`}),dark:/* @__PURE__ */ g(p,{theme:`dark`})};function y(t){let r=m(23),{className:a,label:o,style:s}=t,[p,y]=f(),b=d(),S=l(),C=i(`(prefers-color-scheme: dark)`),w=h(null),T,E;if(r[0]!==o||r[1]!==C||r[2]!==p){let e=u({theme:p,prefersDarkMode:C});T=c.Item,E=o==null?`Theme: ${x(e,{prefersDarkMode:C})}`:void 0,r[0]=o,r[1]=C,r[2]=p,r[3]=T,r[4]=E}else T=r[3],E=r[4];let D;r[5]===a?D=r[6]:(D=e(`gap-2`,a),r[5]=a,r[6]=D);let O=S!=null,k;r[7]!==C||r[8]!==y?(k=e=>{e.preventDefault(),y(e=>u({theme:e,prefersDarkMode:C}),{origin:w.current})},r[7]=C,r[8]=y,r[9]=k):k=r[9];let A=o??`Theme`,j;r[10]===A?j=r[11]:(j=/* @__PURE__ */ g(`span`,{"data-slot":`theme-dropdown-menu-item-label`,className:`flex-1`,children:A}),r[10]=A,r[11]=j);let M;r[12]===b?M=r[13]:(M=/* @__PURE__ */ g(`span`,{ref:w,"aria-hidden":!0,className:`flex size-7 shrink-0 items-center justify-center text-muted [&_svg]:size-5`,children:/* @__PURE__ */ g(n,{active:b,icons:v})}),r[12]=b,r[13]=M);let N;return r[14]!==T||r[15]!==s||r[16]!==E||r[17]!==D||r[18]!==O||r[19]!==k||r[20]!==j||r[21]!==M?(N=/* @__PURE__ */ _(T,{"aria-label":E,"data-slot":`theme-dropdown-menu-item`,className:D,disabled:O,style:s,onSelect:k,children:[j,M]}),r[14]=T,r[15]=s,r[16]=E,r[17]=D,r[18]=O,r[19]=k,r[20]=j,r[21]=M,r[22]=N):N=r[22],N}function b(e){let c=m(28),p,h,_,y,b,S;c[0]===e?(p=c[1],h=c[2],_=c[3],y=c[4],b=c[5],S=c[6]):({appearance:S,"data-slot":p,disabled:h,label:_,onClick:y,...b}=e,c[0]=e,c[1]=p,c[2]=h,c[3]=_,c[4]=y,c[5]=b,c[6]=S);let C=S===void 0?`ghost`:S,[w,T]=f(),E=d(),D=l(),O=i(`(prefers-color-scheme: dark)`),k=a(),A;if(c[7]!==k||c[8]!==O||c[9]!==w){let e=u({theme:w,prefersDarkMode:O});A=k?x(e,{prefersDarkMode:O}):`Toggle theme`,c[7]=k,c[8]=O,c[9]=w,c[10]=A}else A=c[10];let j=A,M;c[11]===p?M=c[12]:(M=t(p,`theme-switcher`),c[11]=p,c[12]=M);let N=D!=null||h,P;c[13]===Symbol.for(`react.memo_cache_sentinel`)?(P=/* @__PURE__ */ g(s,{asChild:!0,className:`rounded-full size-5`,children:/* @__PURE__ */ g(`span`,{})}),c[13]=P):P=c[13];let F;c[14]===E?F=c[15]:(F=/* @__PURE__ */ g(o,{fallback:P,children:()=>/* @__PURE__ */ g(n,{active:E,icons:v})}),c[14]=E,c[15]=F);let I=_??(D==null?j:`Theme set by this page`),L;c[16]!==y||c[17]!==O||c[18]!==T?(L=e=>{y?.(e),e.defaultPrevented||T(e=>u({theme:e,prefersDarkMode:O}),{origin:e.currentTarget})},c[16]=y,c[17]=O,c[18]=T,c[19]=L):L=c[19];let R;return c[20]!==C||c[21]!==b||c[22]!==M||c[23]!==N||c[24]!==F||c[25]!==I||c[26]!==L?(R=/* @__PURE__ */ g(r,{appearance:C,"data-slot":M,disabled:N,intent:`neutral`,icon:F,label:I,onClick:L,...b}),c[20]=C,c[21]=b,c[22]=M,c[23]=N,c[24]=F,c[25]=I,c[26]=L,c[27]=R):R=c[27],R}function x(e,{prefersDarkMode:t}){return e===`system`?t?`Switch to dark theme (system default)`:`Switch to light theme (system default)`:`Switch to ${e} theme`}export{y as ThemeDropdownMenuItem,b as ThemeSwitcher};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
//#region src/components/theme/themes.d.ts
|
|
2
1
|
/**
|
|
3
|
-
* The
|
|
2
|
+
* The two concrete themes `"system"` resolves to.
|
|
4
3
|
*
|
|
5
4
|
* @see https://mantle.ngrok.com/components/primitives/theme
|
|
6
5
|
*/
|
|
7
|
-
declare const resolvedThemes: readonly ["light", "dark"
|
|
6
|
+
declare const resolvedThemes: readonly ["light", "dark"];
|
|
8
7
|
/**
|
|
9
8
|
* One concrete theme, never `"system"`.
|
|
10
9
|
*
|
|
@@ -16,7 +15,7 @@ type ResolvedTheme = (typeof resolvedThemes)[number];
|
|
|
16
15
|
*
|
|
17
16
|
* @see https://mantle.ngrok.com/components/primitives/theme
|
|
18
17
|
*/
|
|
19
|
-
declare const themes: readonly ["system", "light", "dark"
|
|
18
|
+
declare const themes: readonly ["system", "light", "dark"];
|
|
20
19
|
/**
|
|
21
20
|
* One theme a consumer can set, including `"system"`.
|
|
22
21
|
*
|
|
@@ -47,5 +46,4 @@ declare const $resolvedTheme: <T extends ResolvedTheme = ResolvedTheme>(value: T
|
|
|
47
46
|
* @see https://mantle.ngrok.com/components/primitives/theme
|
|
48
47
|
*/
|
|
49
48
|
declare function isResolvedTheme(value: unknown): value is ResolvedTheme;
|
|
50
|
-
//#endregion
|
|
51
49
|
export { isResolvedTheme as a, themes as c, Theme as i, $theme as n, isTheme as o, ResolvedTheme as r, resolvedThemes as s, $resolvedTheme as t };
|