@umami/react-zen 0.237.0 → 0.238.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/index.d.mts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +84 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/styles.css +145 -49
- package/styles.full.css +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3903,11 +3903,18 @@ function useDebounce(value, delay) {
|
|
|
3903
3903
|
}, [value, delay]);
|
|
3904
3904
|
return debouncedValue;
|
|
3905
3905
|
}
|
|
3906
|
-
var
|
|
3906
|
+
var PALETTES = ["neutral", "slate", "gray", "zinc", "stone"];
|
|
3907
|
+
var THEME_STORAGE_KEY = "theme";
|
|
3908
|
+
var PALETTE_STORAGE_KEY = "zen.palette";
|
|
3907
3909
|
function getThemeFromDOM() {
|
|
3908
3910
|
if (typeof window === "undefined") return "light";
|
|
3909
3911
|
return document.documentElement.classList.contains("dark") ? "dark" : "light";
|
|
3910
3912
|
}
|
|
3913
|
+
function getPaletteFromDOM() {
|
|
3914
|
+
if (typeof window === "undefined") return "neutral";
|
|
3915
|
+
const palette = document.documentElement.getAttribute("data-palette");
|
|
3916
|
+
return palette && PALETTES.includes(palette) ? palette : "neutral";
|
|
3917
|
+
}
|
|
3911
3918
|
function resolveTheme(preferred, colorScheme) {
|
|
3912
3919
|
if (preferred) {
|
|
3913
3920
|
return preferred;
|
|
@@ -3929,41 +3936,67 @@ function applyTheme(theme) {
|
|
|
3929
3936
|
document.documentElement.classList.remove("dark");
|
|
3930
3937
|
}
|
|
3931
3938
|
}
|
|
3939
|
+
function applyPalette(palette) {
|
|
3940
|
+
if (typeof window === "undefined") return;
|
|
3941
|
+
document.documentElement.setAttribute("data-palette", palette);
|
|
3942
|
+
}
|
|
3932
3943
|
var useTheme = create((set, get) => ({
|
|
3933
3944
|
theme: "light",
|
|
3945
|
+
palette: "neutral",
|
|
3934
3946
|
setTheme: (theme) => {
|
|
3935
3947
|
set({ theme });
|
|
3936
3948
|
if (typeof window !== "undefined") {
|
|
3937
|
-
localStorage.setItem(
|
|
3949
|
+
localStorage.setItem(THEME_STORAGE_KEY, theme);
|
|
3938
3950
|
applyTheme(theme);
|
|
3939
3951
|
}
|
|
3940
3952
|
},
|
|
3953
|
+
setPalette: (palette) => {
|
|
3954
|
+
set({ palette });
|
|
3955
|
+
if (typeof window !== "undefined") {
|
|
3956
|
+
localStorage.setItem(PALETTE_STORAGE_KEY, palette);
|
|
3957
|
+
applyPalette(palette);
|
|
3958
|
+
}
|
|
3959
|
+
},
|
|
3941
3960
|
syncTheme: () => {
|
|
3942
3961
|
const theme = getThemeFromDOM();
|
|
3943
|
-
|
|
3962
|
+
const palette = getPaletteFromDOM();
|
|
3963
|
+
const state = get();
|
|
3964
|
+
if (theme !== state.theme) {
|
|
3944
3965
|
set({ theme });
|
|
3945
3966
|
document.documentElement.setAttribute("data-theme", theme);
|
|
3946
3967
|
}
|
|
3968
|
+
if (palette !== state.palette) {
|
|
3969
|
+
set({ palette });
|
|
3970
|
+
}
|
|
3947
3971
|
},
|
|
3948
3972
|
initTheme: (preferred, colorScheme) => {
|
|
3949
3973
|
if (typeof window === "undefined") return;
|
|
3950
|
-
const stored = localStorage.getItem(
|
|
3974
|
+
const stored = localStorage.getItem(THEME_STORAGE_KEY);
|
|
3951
3975
|
const initial = resolveTheme(preferred || stored || void 0, colorScheme);
|
|
3952
3976
|
set({ theme: initial });
|
|
3953
3977
|
applyTheme(initial);
|
|
3978
|
+
},
|
|
3979
|
+
initPalette: (preferred) => {
|
|
3980
|
+
if (typeof window === "undefined") return;
|
|
3981
|
+
const stored = localStorage.getItem(PALETTE_STORAGE_KEY);
|
|
3982
|
+
const initial = preferred || (stored && PALETTES.includes(stored) ? stored : null) || "neutral";
|
|
3983
|
+
set({ palette: initial });
|
|
3984
|
+
applyPalette(initial);
|
|
3954
3985
|
}
|
|
3955
3986
|
}));
|
|
3956
|
-
function useInitTheme(preferred, colorScheme) {
|
|
3987
|
+
function useInitTheme(preferred, colorScheme, preferredPalette) {
|
|
3957
3988
|
const initTheme = useTheme((s) => s.initTheme);
|
|
3989
|
+
const initPalette = useTheme((s) => s.initPalette);
|
|
3958
3990
|
const syncTheme = useTheme((s) => s.syncTheme);
|
|
3959
3991
|
useLayoutEffect(() => {
|
|
3960
3992
|
initTheme(preferred, colorScheme);
|
|
3961
|
-
|
|
3993
|
+
initPalette(preferredPalette);
|
|
3994
|
+
}, [preferred, colorScheme, preferredPalette, initTheme, initPalette]);
|
|
3962
3995
|
useEffect(() => {
|
|
3963
3996
|
if (typeof window === "undefined") return;
|
|
3964
3997
|
const observer = new MutationObserver((mutations) => {
|
|
3965
3998
|
for (const mutation of mutations) {
|
|
3966
|
-
if (mutation.attributeName === "class") {
|
|
3999
|
+
if (mutation.attributeName === "class" || mutation.attributeName === "data-palette") {
|
|
3967
4000
|
syncTheme();
|
|
3968
4001
|
}
|
|
3969
4002
|
}
|
|
@@ -4403,6 +4436,43 @@ function NavMenuItem({ isSelected, className, children, ...props }) {
|
|
|
4403
4436
|
}
|
|
4404
4437
|
);
|
|
4405
4438
|
}
|
|
4439
|
+
var PALETTE_LABELS = {
|
|
4440
|
+
neutral: "Neutral",
|
|
4441
|
+
slate: "Slate",
|
|
4442
|
+
gray: "Gray",
|
|
4443
|
+
zinc: "Zinc",
|
|
4444
|
+
stone: "Stone"
|
|
4445
|
+
};
|
|
4446
|
+
function PaletteSwitcher({ className }) {
|
|
4447
|
+
const { palette, setPalette } = useTheme();
|
|
4448
|
+
return /* @__PURE__ */ jsx(
|
|
4449
|
+
"div",
|
|
4450
|
+
{
|
|
4451
|
+
className: cn(
|
|
4452
|
+
"inline-flex items-center bg-surface-base border border-edge rounded-md overflow-hidden",
|
|
4453
|
+
className
|
|
4454
|
+
),
|
|
4455
|
+
children: PALETTES.map((p) => /* @__PURE__ */ jsx(
|
|
4456
|
+
"button",
|
|
4457
|
+
{
|
|
4458
|
+
type: "button",
|
|
4459
|
+
onClick: () => setPalette(p),
|
|
4460
|
+
"aria-label": PALETTE_LABELS[p],
|
|
4461
|
+
"aria-pressed": palette === p,
|
|
4462
|
+
className: cn(
|
|
4463
|
+
"px-3 h-9 flex items-center justify-center cursor-pointer outline-none transition-colors text-sm",
|
|
4464
|
+
"[&:not(:first-child)]:border-l [&:not(:first-child)]:border-edge",
|
|
4465
|
+
"hover:bg-interactive",
|
|
4466
|
+
"focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",
|
|
4467
|
+
palette === p ? "bg-interactive text-foreground-primary" : "text-foreground-muted"
|
|
4468
|
+
),
|
|
4469
|
+
children: PALETTE_LABELS[p]
|
|
4470
|
+
},
|
|
4471
|
+
p
|
|
4472
|
+
))
|
|
4473
|
+
}
|
|
4474
|
+
);
|
|
4475
|
+
}
|
|
4406
4476
|
var SvgEyeSlash = (props) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 256 256", ...props, children: [
|
|
4407
4477
|
/* @__PURE__ */ jsx("path", { fill: "none", d: "M0 0h256v256H0z" }),
|
|
4408
4478
|
/* @__PURE__ */ jsx(
|
|
@@ -4997,7 +5067,7 @@ function ThemeButton({
|
|
|
4997
5067
|
}
|
|
4998
5068
|
);
|
|
4999
5069
|
}
|
|
5000
|
-
var
|
|
5070
|
+
var STORAGE_KEY = "theme-mode";
|
|
5001
5071
|
function getSystemTheme() {
|
|
5002
5072
|
if (typeof window === "undefined") return "light";
|
|
5003
5073
|
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
@@ -5006,7 +5076,7 @@ function ThemeSwitcher({ className }) {
|
|
|
5006
5076
|
const { setTheme } = useTheme();
|
|
5007
5077
|
const [mode, setMode] = useState("system");
|
|
5008
5078
|
useEffect(() => {
|
|
5009
|
-
const stored = localStorage.getItem(
|
|
5079
|
+
const stored = localStorage.getItem(STORAGE_KEY);
|
|
5010
5080
|
if (stored && ["light", "dark", "system"].includes(stored)) {
|
|
5011
5081
|
setMode(stored);
|
|
5012
5082
|
}
|
|
@@ -5017,7 +5087,7 @@ function ThemeSwitcher({ className }) {
|
|
|
5017
5087
|
} else {
|
|
5018
5088
|
setTheme(mode);
|
|
5019
5089
|
}
|
|
5020
|
-
localStorage.setItem(
|
|
5090
|
+
localStorage.setItem(STORAGE_KEY, mode);
|
|
5021
5091
|
}, [mode, setTheme]);
|
|
5022
5092
|
useEffect(() => {
|
|
5023
5093
|
if (mode !== "system") return;
|
|
@@ -5143,12 +5213,13 @@ function ZenProvider({
|
|
|
5143
5213
|
children,
|
|
5144
5214
|
theme,
|
|
5145
5215
|
colorScheme,
|
|
5216
|
+
palette,
|
|
5146
5217
|
toast: toast2 = defaultToastConfig
|
|
5147
5218
|
}) {
|
|
5148
|
-
useInitTheme(theme, colorScheme);
|
|
5219
|
+
useInitTheme(theme, colorScheme, palette);
|
|
5149
5220
|
return /* @__PURE__ */ jsx(ToastProvider, { ...toast2, children });
|
|
5150
5221
|
}
|
|
5151
5222
|
|
|
5152
|
-
export { Accordion, AccordionItem, AlertBanner, AlertDialog, Blockquote, Box, Breadcrumb, Breadcrumbs, Button, Calendar, Checkbox, Code, Column, ComboBox, ConfirmationDialog, Container, CopyButton, DataCard, DataColumn, DataTable, Dialog, Dots, Flexbox, FloatingTooltip, Form, FormButtons, FormController, FormField, FormFieldArray, FormResetButton, FormSubmitButton, Grid, Heading, HoverTrigger, Icon, IconLabel, Image, Label, List, ListItem, ListSection, ListSeparator, Loading, LoadingButton, Menu, MenuItem, MenuSection, MenuSeparator, Modal, NavMenu, NavMenuGroup, NavMenuItem, Navbar, NavbarContext, NavbarItem, PasswordField, Popover, ProgressBar, ProgressCircle, Radio, RadioGroup, Row, SearchField, Select, Sidebar, SidebarHeader, SidebarItem, SidebarSection, Slider, Spinner, StatusLight, SubMenuTrigger, Switch, Tab, TabList, TabPanel, Table, TableBody, TableCell, TableColumn, TableHeader, TableRow, Tabs, Text, TextField, ThemeButton, ThemeSwitcher, Toast, ToastContext, ToastProvider, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipBubble, ZenProvider, cn, getCssColorValue, isHeightPreset, isMaxHeightPreset, isMaxWidthPreset, isMinHeightPreset, isMinWidthPreset, isWidthPreset, mapAlignContent, mapAlignItems, mapAlignSelf, mapBackgroundColor, mapBorder, mapBorderColor, mapBorderRadius, mapBorderWidth, mapCursor, mapDisplay, mapFlexDirection, mapFlexWrap, mapFontSize, mapFontWeight, mapGap, mapGridAutoFlow, mapGridColumns, mapGridRows, mapHeadingSize, mapHeight, mapJustifyContent, mapJustifyItems, mapLetterSpacing, mapLineHeight, mapMargin, mapMaxHeight, mapMaxWidth, mapMinHeight, mapMinWidth, mapOpacity, mapOverflow, mapPadding, mapPointerEvents, mapPosition, mapShadow, mapStateStyles, mapTextAlign, mapTextColor, mapTextDecorationStyle, mapTextIndent, mapTextTransform, mapTextWrap, mapVerticalAlign, mapWhitespace, mapWidth, mapWordBreak, removeToast, resolveRender, useBreakpoint, useDebounce, useInitTheme, useNavigationContext, useTheme, useToast };
|
|
5223
|
+
export { Accordion, AccordionItem, AlertBanner, AlertDialog, Blockquote, Box, Breadcrumb, Breadcrumbs, Button, Calendar, Checkbox, Code, Column, ComboBox, ConfirmationDialog, Container, CopyButton, DataCard, DataColumn, DataTable, Dialog, Dots, Flexbox, FloatingTooltip, Form, FormButtons, FormController, FormField, FormFieldArray, FormResetButton, FormSubmitButton, Grid, Heading, HoverTrigger, Icon, IconLabel, Image, Label, List, ListItem, ListSection, ListSeparator, Loading, LoadingButton, Menu, MenuItem, MenuSection, MenuSeparator, Modal, NavMenu, NavMenuGroup, NavMenuItem, Navbar, NavbarContext, NavbarItem, PALETTES, PaletteSwitcher, PasswordField, Popover, ProgressBar, ProgressCircle, Radio, RadioGroup, Row, SearchField, Select, Sidebar, SidebarHeader, SidebarItem, SidebarSection, Slider, Spinner, StatusLight, SubMenuTrigger, Switch, Tab, TabList, TabPanel, Table, TableBody, TableCell, TableColumn, TableHeader, TableRow, Tabs, Text, TextField, ThemeButton, ThemeSwitcher, Toast, ToastContext, ToastProvider, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipBubble, ZenProvider, cn, getCssColorValue, isHeightPreset, isMaxHeightPreset, isMaxWidthPreset, isMinHeightPreset, isMinWidthPreset, isWidthPreset, mapAlignContent, mapAlignItems, mapAlignSelf, mapBackgroundColor, mapBorder, mapBorderColor, mapBorderRadius, mapBorderWidth, mapCursor, mapDisplay, mapFlexDirection, mapFlexWrap, mapFontSize, mapFontWeight, mapGap, mapGridAutoFlow, mapGridColumns, mapGridRows, mapHeadingSize, mapHeight, mapJustifyContent, mapJustifyItems, mapLetterSpacing, mapLineHeight, mapMargin, mapMaxHeight, mapMaxWidth, mapMinHeight, mapMinWidth, mapOpacity, mapOverflow, mapPadding, mapPointerEvents, mapPosition, mapShadow, mapStateStyles, mapTextAlign, mapTextColor, mapTextDecorationStyle, mapTextIndent, mapTextTransform, mapTextWrap, mapVerticalAlign, mapWhitespace, mapWidth, mapWordBreak, removeToast, resolveRender, useBreakpoint, useDebounce, useInitTheme, useNavigationContext, useTheme, useToast };
|
|
5153
5224
|
//# sourceMappingURL=index.mjs.map
|
|
5154
5225
|
//# sourceMappingURL=index.mjs.map
|