@umami/react-zen 0.236.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 -5
- package/dist/index.d.ts +14 -5
- package/dist/index.js +84 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -16
- 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
|
@@ -2457,8 +2457,6 @@ var Box = forwardRef(function Box2({
|
|
|
2457
2457
|
display,
|
|
2458
2458
|
color,
|
|
2459
2459
|
backgroundColor,
|
|
2460
|
-
fontSize,
|
|
2461
|
-
fontWeight,
|
|
2462
2460
|
border,
|
|
2463
2461
|
borderWidth,
|
|
2464
2462
|
borderColor,
|
|
@@ -2527,8 +2525,6 @@ var Box = forwardRef(function Box2({
|
|
|
2527
2525
|
mapDisplay(display),
|
|
2528
2526
|
mapTextColor(toStringValue(color)),
|
|
2529
2527
|
mapBackgroundColor(toStringValue(backgroundColor)),
|
|
2530
|
-
mapFontSize(fontSize),
|
|
2531
|
-
mapFontWeight(fontWeight),
|
|
2532
2528
|
mapBorder(border),
|
|
2533
2529
|
mapBorderWidth(borderWidth),
|
|
2534
2530
|
mapBorderColor(toStringValue(borderColor)),
|
|
@@ -3907,11 +3903,18 @@ function useDebounce(value, delay) {
|
|
|
3907
3903
|
}, [value, delay]);
|
|
3908
3904
|
return debouncedValue;
|
|
3909
3905
|
}
|
|
3910
|
-
var
|
|
3906
|
+
var PALETTES = ["neutral", "slate", "gray", "zinc", "stone"];
|
|
3907
|
+
var THEME_STORAGE_KEY = "theme";
|
|
3908
|
+
var PALETTE_STORAGE_KEY = "zen.palette";
|
|
3911
3909
|
function getThemeFromDOM() {
|
|
3912
3910
|
if (typeof window === "undefined") return "light";
|
|
3913
3911
|
return document.documentElement.classList.contains("dark") ? "dark" : "light";
|
|
3914
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
|
+
}
|
|
3915
3918
|
function resolveTheme(preferred, colorScheme) {
|
|
3916
3919
|
if (preferred) {
|
|
3917
3920
|
return preferred;
|
|
@@ -3933,41 +3936,67 @@ function applyTheme(theme) {
|
|
|
3933
3936
|
document.documentElement.classList.remove("dark");
|
|
3934
3937
|
}
|
|
3935
3938
|
}
|
|
3939
|
+
function applyPalette(palette) {
|
|
3940
|
+
if (typeof window === "undefined") return;
|
|
3941
|
+
document.documentElement.setAttribute("data-palette", palette);
|
|
3942
|
+
}
|
|
3936
3943
|
var useTheme = create((set, get) => ({
|
|
3937
3944
|
theme: "light",
|
|
3945
|
+
palette: "neutral",
|
|
3938
3946
|
setTheme: (theme) => {
|
|
3939
3947
|
set({ theme });
|
|
3940
3948
|
if (typeof window !== "undefined") {
|
|
3941
|
-
localStorage.setItem(
|
|
3949
|
+
localStorage.setItem(THEME_STORAGE_KEY, theme);
|
|
3942
3950
|
applyTheme(theme);
|
|
3943
3951
|
}
|
|
3944
3952
|
},
|
|
3953
|
+
setPalette: (palette) => {
|
|
3954
|
+
set({ palette });
|
|
3955
|
+
if (typeof window !== "undefined") {
|
|
3956
|
+
localStorage.setItem(PALETTE_STORAGE_KEY, palette);
|
|
3957
|
+
applyPalette(palette);
|
|
3958
|
+
}
|
|
3959
|
+
},
|
|
3945
3960
|
syncTheme: () => {
|
|
3946
3961
|
const theme = getThemeFromDOM();
|
|
3947
|
-
|
|
3962
|
+
const palette = getPaletteFromDOM();
|
|
3963
|
+
const state = get();
|
|
3964
|
+
if (theme !== state.theme) {
|
|
3948
3965
|
set({ theme });
|
|
3949
3966
|
document.documentElement.setAttribute("data-theme", theme);
|
|
3950
3967
|
}
|
|
3968
|
+
if (palette !== state.palette) {
|
|
3969
|
+
set({ palette });
|
|
3970
|
+
}
|
|
3951
3971
|
},
|
|
3952
3972
|
initTheme: (preferred, colorScheme) => {
|
|
3953
3973
|
if (typeof window === "undefined") return;
|
|
3954
|
-
const stored = localStorage.getItem(
|
|
3974
|
+
const stored = localStorage.getItem(THEME_STORAGE_KEY);
|
|
3955
3975
|
const initial = resolveTheme(preferred || stored || void 0, colorScheme);
|
|
3956
3976
|
set({ theme: initial });
|
|
3957
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);
|
|
3958
3985
|
}
|
|
3959
3986
|
}));
|
|
3960
|
-
function useInitTheme(preferred, colorScheme) {
|
|
3987
|
+
function useInitTheme(preferred, colorScheme, preferredPalette) {
|
|
3961
3988
|
const initTheme = useTheme((s) => s.initTheme);
|
|
3989
|
+
const initPalette = useTheme((s) => s.initPalette);
|
|
3962
3990
|
const syncTheme = useTheme((s) => s.syncTheme);
|
|
3963
3991
|
useLayoutEffect(() => {
|
|
3964
3992
|
initTheme(preferred, colorScheme);
|
|
3965
|
-
|
|
3993
|
+
initPalette(preferredPalette);
|
|
3994
|
+
}, [preferred, colorScheme, preferredPalette, initTheme, initPalette]);
|
|
3966
3995
|
useEffect(() => {
|
|
3967
3996
|
if (typeof window === "undefined") return;
|
|
3968
3997
|
const observer = new MutationObserver((mutations) => {
|
|
3969
3998
|
for (const mutation of mutations) {
|
|
3970
|
-
if (mutation.attributeName === "class") {
|
|
3999
|
+
if (mutation.attributeName === "class" || mutation.attributeName === "data-palette") {
|
|
3971
4000
|
syncTheme();
|
|
3972
4001
|
}
|
|
3973
4002
|
}
|
|
@@ -4407,6 +4436,43 @@ function NavMenuItem({ isSelected, className, children, ...props }) {
|
|
|
4407
4436
|
}
|
|
4408
4437
|
);
|
|
4409
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
|
+
}
|
|
4410
4476
|
var SvgEyeSlash = (props) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 256 256", ...props, children: [
|
|
4411
4477
|
/* @__PURE__ */ jsx("path", { fill: "none", d: "M0 0h256v256H0z" }),
|
|
4412
4478
|
/* @__PURE__ */ jsx(
|
|
@@ -5001,7 +5067,7 @@ function ThemeButton({
|
|
|
5001
5067
|
}
|
|
5002
5068
|
);
|
|
5003
5069
|
}
|
|
5004
|
-
var
|
|
5070
|
+
var STORAGE_KEY = "theme-mode";
|
|
5005
5071
|
function getSystemTheme() {
|
|
5006
5072
|
if (typeof window === "undefined") return "light";
|
|
5007
5073
|
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
@@ -5010,7 +5076,7 @@ function ThemeSwitcher({ className }) {
|
|
|
5010
5076
|
const { setTheme } = useTheme();
|
|
5011
5077
|
const [mode, setMode] = useState("system");
|
|
5012
5078
|
useEffect(() => {
|
|
5013
|
-
const stored = localStorage.getItem(
|
|
5079
|
+
const stored = localStorage.getItem(STORAGE_KEY);
|
|
5014
5080
|
if (stored && ["light", "dark", "system"].includes(stored)) {
|
|
5015
5081
|
setMode(stored);
|
|
5016
5082
|
}
|
|
@@ -5021,7 +5087,7 @@ function ThemeSwitcher({ className }) {
|
|
|
5021
5087
|
} else {
|
|
5022
5088
|
setTheme(mode);
|
|
5023
5089
|
}
|
|
5024
|
-
localStorage.setItem(
|
|
5090
|
+
localStorage.setItem(STORAGE_KEY, mode);
|
|
5025
5091
|
}, [mode, setTheme]);
|
|
5026
5092
|
useEffect(() => {
|
|
5027
5093
|
if (mode !== "system") return;
|
|
@@ -5147,12 +5213,13 @@ function ZenProvider({
|
|
|
5147
5213
|
children,
|
|
5148
5214
|
theme,
|
|
5149
5215
|
colorScheme,
|
|
5216
|
+
palette,
|
|
5150
5217
|
toast: toast2 = defaultToastConfig
|
|
5151
5218
|
}) {
|
|
5152
|
-
useInitTheme(theme, colorScheme);
|
|
5219
|
+
useInitTheme(theme, colorScheme, palette);
|
|
5153
5220
|
return /* @__PURE__ */ jsx(ToastProvider, { ...toast2, children });
|
|
5154
5221
|
}
|
|
5155
5222
|
|
|
5156
|
-
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 };
|
|
5157
5224
|
//# sourceMappingURL=index.mjs.map
|
|
5158
5225
|
//# sourceMappingURL=index.mjs.map
|