@umami/react-zen 0.182.0 → 0.184.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 CHANGED
@@ -3,6 +3,7 @@ export { BreadcrumbProps, BreadcrumbsProps, DialogTrigger, FileTrigger, Focusabl
3
3
  import * as react from 'react';
4
4
  import { HTMLAttributes, ReactNode, ReactElement, Dispatch, SetStateAction } from 'react';
5
5
  import { UseFormProps, SubmitHandler, UseFormReturn, ControllerProps, ControllerRenderProps, FieldValues, ControllerFieldState, UseFormStateReturn, RegisterOptions } from 'react-hook-form';
6
+ import * as zustand from 'zustand';
6
7
 
7
8
  interface FormProps extends UseFormProps, Omit<HTMLAttributes<HTMLFormElement>, 'children'> {
8
9
  autoComplete?: string;
@@ -171,7 +172,7 @@ interface FormFieldArrayProps extends Omit<HTMLAttributes<HTMLDivElement>, 'chil
171
172
  rules?: RegisterOptions<FieldValues, string>;
172
173
  children: (props: any) => ReactNode;
173
174
  }
174
- declare function FormFieldArray({ name, description, label, rules, className, children, ...props }: FormFieldArrayProps): react.JSX.Element;
175
+ declare function FormFieldArray({ id, name, description, label, rules, className, children, ...props }: FormFieldArrayProps): react.JSX.Element;
175
176
 
176
177
  interface ButtonProps extends ButtonProps$1 {
177
178
  variant?: 'primary' | 'outline' | 'quiet' | 'danger' | 'zero';
@@ -222,11 +223,13 @@ declare function ToastProvider({ children, ...props }: ToastProviderProps): reac
222
223
 
223
224
  declare function useDebounce(value: string, delay: number): string;
224
225
 
225
- declare function setTheme(theme: string): void;
226
- declare function useTheme(defaultTheme?: string): {
227
- theme: string;
228
- setTheme: typeof setTheme;
229
- };
226
+ type Theme = 'light' | 'dark';
227
+ interface ThemeState {
228
+ theme: Theme;
229
+ setTheme: (theme: Theme) => void;
230
+ initTheme: (preferred?: Theme, colorScheme?: 'light' | 'dark' | 'system') => void;
231
+ }
232
+ declare const useTheme: zustand.UseBoundStore<zustand.StoreApi<ThemeState>>;
230
233
 
231
234
  type ToastVariant = 'success' | 'error';
232
235
  interface ToastOptions {
@@ -703,10 +706,7 @@ interface TextFieldProps extends TextFieldProps$1 {
703
706
  }
704
707
  declare function TextField({ value, defaultValue, label, placeholder, allowCopy, asTextArea, resize, onChange, isReadOnly, isDisabled, className, children, ...props }: TextFieldProps): react.JSX.Element;
705
708
 
706
- interface ThemeButtonProps extends ButtonProps {
707
- defaultTheme?: string;
708
- }
709
- declare function ThemeButton({ className, variant, defaultTheme, onPress, ...props }: ThemeButtonProps): react.JSX.Element;
709
+ declare function ThemeButton({ className, variant, onPress, ...props }: ButtonProps): react.JSX.Element;
710
710
 
711
711
  interface ToggleProps extends ToggleButtonProps {
712
712
  label?: string;
@@ -727,11 +727,11 @@ interface ToggleGroupItemProps extends TagProps {
727
727
  declare function ToggleGroupItem({ className, children, ...props }: ToggleGroupItemProps): react.JSX.Element;
728
728
 
729
729
  interface ZenProviderProps {
730
- theme?: string;
730
+ theme?: Theme;
731
731
  colorScheme?: 'light' | 'dark' | 'system';
732
732
  toast?: ToasterProps;
733
733
  children: ReactNode;
734
734
  }
735
- declare function ZenProvider({ children, ...props }: ZenProviderProps): react.JSX.Element;
735
+ declare function ZenProvider({ children, theme, colorScheme, toast, }: ZenProviderProps): react.JSX.Element;
736
736
 
737
- export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, AlertBanner, type AlertBannerProps, AlertDialog, type AlertDialogProps, Blockquote, type BlockquoteProps, Box, type BoxProps, Breadcrumb, Breadcrumbs, Button, type ButtonProps, Calendar, type CalendarProps, Checkbox, type CheckboxProps, Code, type CodeProps, Column, type ColumnProps, ComboBox, type ComboBoxProps, ConfirmationDialog, type ConfirmationDialogProps, Container, type ContainerProps, CopyButton, DataColumn, type DataColumnProps, DataTable, type DataTableProps, Dialog, type DialogProps, Dots, type DotsProps, Flexbox, type FlexboxProps, FloatingTooltip, type FloatingTooltipProps, Form, FormButtons, type FormButtonsProps, FormController, type FormControllerProps, FormField, FormFieldArray, type FormFieldArrayProps, type FormFieldProps, type FormProps, FormResetButton, type FormResetButtonProps, FormSubmitButton, Grid, type GridProps, Heading, type HeadingProps, type HoverButtonProps, HoverTrigger, Icon, type IconProps, Image, type ImageProps, InlineEditField, type InlineEditFieldProps, Label, type LabelProps, List, ListItem, type ListItemProps, type ListProps, ListSection, type ListSectionProps, ListSeparator, Loading, LoadingButton, type LoadingButtonProps, type LoadingProps, Menu, MenuItem, type MenuItemProps, type MenuProps, MenuSection, type MenuSectionProps, MenuSeparator, Modal, type ModalProps, NavMenu, NavMenuGroup, type NavMenuGroupProps, NavMenuItem, type NavMenuItemProps, type NavMenuProps, Navbar, NavbarContext, NavbarItem, type NavbarItemProps, type NavbarProps, type NavigationContext, PasswordField, type PasswordFieldProps, Popover, ProgressBar, type ProgressBarProps, ProgressCircle, type ProgressCircleProps, Radio, RadioGroup, type RadioGroupProps, Row, type RowProps, SearchField, type SearchFieldProps, Select, type SelectProps, Sidebar, SidebarHeader, SidebarItem, type SidebarItemProps, type SidebarProps, SidebarSection, Slider, type SliderProps, Slot, Spinner, type SpinnerProps, StatusLight, type StatusLightProps, SubMenuTrigger, type SubmenuTriggerProps, Switch, type SwitchProps, Tab, TabList, TabPanel, Table, TableBody, TableCell, type TableCellProps, TableColumn, type TableColumnProps, TableHeader, TableRow, Tabs, Text, TextField, type TextFieldProps, type TextProps, ThemeButton, type ThemeButtonProps, Toast, type ToastOptions, type ToastProps, ToastProvider, type ToastProviderProps, type ToastState, type ToastVariant, Toaster, type ToasterProps, Toggle, ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupProps, type ToggleProps, Tooltip, TooltipBubble, type TooltipBubbleProps, type TooltipProps, ZenProvider, type ZenProviderProps, useDebounce, useNavigationContext, useTheme, useToast };
737
+ export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, AlertBanner, type AlertBannerProps, AlertDialog, type AlertDialogProps, Blockquote, type BlockquoteProps, Box, type BoxProps, Breadcrumb, Breadcrumbs, Button, type ButtonProps, Calendar, type CalendarProps, Checkbox, type CheckboxProps, Code, type CodeProps, Column, type ColumnProps, ComboBox, type ComboBoxProps, ConfirmationDialog, type ConfirmationDialogProps, Container, type ContainerProps, CopyButton, DataColumn, type DataColumnProps, DataTable, type DataTableProps, Dialog, type DialogProps, Dots, type DotsProps, Flexbox, type FlexboxProps, FloatingTooltip, type FloatingTooltipProps, Form, FormButtons, type FormButtonsProps, FormController, type FormControllerProps, FormField, FormFieldArray, type FormFieldArrayProps, type FormFieldProps, type FormProps, FormResetButton, type FormResetButtonProps, FormSubmitButton, Grid, type GridProps, Heading, type HeadingProps, type HoverButtonProps, HoverTrigger, Icon, type IconProps, Image, type ImageProps, InlineEditField, type InlineEditFieldProps, Label, type LabelProps, List, ListItem, type ListItemProps, type ListProps, ListSection, type ListSectionProps, ListSeparator, Loading, LoadingButton, type LoadingButtonProps, type LoadingProps, Menu, MenuItem, type MenuItemProps, type MenuProps, MenuSection, type MenuSectionProps, MenuSeparator, Modal, type ModalProps, NavMenu, NavMenuGroup, type NavMenuGroupProps, NavMenuItem, type NavMenuItemProps, type NavMenuProps, Navbar, NavbarContext, NavbarItem, type NavbarItemProps, type NavbarProps, type NavigationContext, PasswordField, type PasswordFieldProps, Popover, ProgressBar, type ProgressBarProps, ProgressCircle, type ProgressCircleProps, Radio, RadioGroup, type RadioGroupProps, Row, type RowProps, SearchField, type SearchFieldProps, Select, type SelectProps, Sidebar, SidebarHeader, SidebarItem, type SidebarItemProps, type SidebarProps, SidebarSection, Slider, type SliderProps, Slot, Spinner, type SpinnerProps, StatusLight, type StatusLightProps, SubMenuTrigger, type SubmenuTriggerProps, Switch, type SwitchProps, Tab, TabList, TabPanel, Table, TableBody, TableCell, type TableCellProps, TableColumn, type TableColumnProps, TableHeader, TableRow, Tabs, Text, TextField, type TextFieldProps, type TextProps, ThemeButton, Toast, type ToastOptions, type ToastProps, ToastProvider, type ToastProviderProps, type ToastState, type ToastVariant, Toaster, type ToasterProps, Toggle, ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupProps, type ToggleProps, Tooltip, TooltipBubble, type TooltipBubbleProps, type TooltipProps, ZenProvider, type ZenProviderProps, useDebounce, useNavigationContext, useTheme, useToast };
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export { BreadcrumbProps, BreadcrumbsProps, DialogTrigger, FileTrigger, Focusabl
3
3
  import * as react from 'react';
4
4
  import { HTMLAttributes, ReactNode, ReactElement, Dispatch, SetStateAction } from 'react';
5
5
  import { UseFormProps, SubmitHandler, UseFormReturn, ControllerProps, ControllerRenderProps, FieldValues, ControllerFieldState, UseFormStateReturn, RegisterOptions } from 'react-hook-form';
6
+ import * as zustand from 'zustand';
6
7
 
7
8
  interface FormProps extends UseFormProps, Omit<HTMLAttributes<HTMLFormElement>, 'children'> {
8
9
  autoComplete?: string;
@@ -171,7 +172,7 @@ interface FormFieldArrayProps extends Omit<HTMLAttributes<HTMLDivElement>, 'chil
171
172
  rules?: RegisterOptions<FieldValues, string>;
172
173
  children: (props: any) => ReactNode;
173
174
  }
174
- declare function FormFieldArray({ name, description, label, rules, className, children, ...props }: FormFieldArrayProps): react.JSX.Element;
175
+ declare function FormFieldArray({ id, name, description, label, rules, className, children, ...props }: FormFieldArrayProps): react.JSX.Element;
175
176
 
176
177
  interface ButtonProps extends ButtonProps$1 {
177
178
  variant?: 'primary' | 'outline' | 'quiet' | 'danger' | 'zero';
@@ -222,11 +223,13 @@ declare function ToastProvider({ children, ...props }: ToastProviderProps): reac
222
223
 
223
224
  declare function useDebounce(value: string, delay: number): string;
224
225
 
225
- declare function setTheme(theme: string): void;
226
- declare function useTheme(defaultTheme?: string): {
227
- theme: string;
228
- setTheme: typeof setTheme;
229
- };
226
+ type Theme = 'light' | 'dark';
227
+ interface ThemeState {
228
+ theme: Theme;
229
+ setTheme: (theme: Theme) => void;
230
+ initTheme: (preferred?: Theme, colorScheme?: 'light' | 'dark' | 'system') => void;
231
+ }
232
+ declare const useTheme: zustand.UseBoundStore<zustand.StoreApi<ThemeState>>;
230
233
 
231
234
  type ToastVariant = 'success' | 'error';
232
235
  interface ToastOptions {
@@ -703,10 +706,7 @@ interface TextFieldProps extends TextFieldProps$1 {
703
706
  }
704
707
  declare function TextField({ value, defaultValue, label, placeholder, allowCopy, asTextArea, resize, onChange, isReadOnly, isDisabled, className, children, ...props }: TextFieldProps): react.JSX.Element;
705
708
 
706
- interface ThemeButtonProps extends ButtonProps {
707
- defaultTheme?: string;
708
- }
709
- declare function ThemeButton({ className, variant, defaultTheme, onPress, ...props }: ThemeButtonProps): react.JSX.Element;
709
+ declare function ThemeButton({ className, variant, onPress, ...props }: ButtonProps): react.JSX.Element;
710
710
 
711
711
  interface ToggleProps extends ToggleButtonProps {
712
712
  label?: string;
@@ -727,11 +727,11 @@ interface ToggleGroupItemProps extends TagProps {
727
727
  declare function ToggleGroupItem({ className, children, ...props }: ToggleGroupItemProps): react.JSX.Element;
728
728
 
729
729
  interface ZenProviderProps {
730
- theme?: string;
730
+ theme?: Theme;
731
731
  colorScheme?: 'light' | 'dark' | 'system';
732
732
  toast?: ToasterProps;
733
733
  children: ReactNode;
734
734
  }
735
- declare function ZenProvider({ children, ...props }: ZenProviderProps): react.JSX.Element;
735
+ declare function ZenProvider({ children, theme, colorScheme, toast, }: ZenProviderProps): react.JSX.Element;
736
736
 
737
- export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, AlertBanner, type AlertBannerProps, AlertDialog, type AlertDialogProps, Blockquote, type BlockquoteProps, Box, type BoxProps, Breadcrumb, Breadcrumbs, Button, type ButtonProps, Calendar, type CalendarProps, Checkbox, type CheckboxProps, Code, type CodeProps, Column, type ColumnProps, ComboBox, type ComboBoxProps, ConfirmationDialog, type ConfirmationDialogProps, Container, type ContainerProps, CopyButton, DataColumn, type DataColumnProps, DataTable, type DataTableProps, Dialog, type DialogProps, Dots, type DotsProps, Flexbox, type FlexboxProps, FloatingTooltip, type FloatingTooltipProps, Form, FormButtons, type FormButtonsProps, FormController, type FormControllerProps, FormField, FormFieldArray, type FormFieldArrayProps, type FormFieldProps, type FormProps, FormResetButton, type FormResetButtonProps, FormSubmitButton, Grid, type GridProps, Heading, type HeadingProps, type HoverButtonProps, HoverTrigger, Icon, type IconProps, Image, type ImageProps, InlineEditField, type InlineEditFieldProps, Label, type LabelProps, List, ListItem, type ListItemProps, type ListProps, ListSection, type ListSectionProps, ListSeparator, Loading, LoadingButton, type LoadingButtonProps, type LoadingProps, Menu, MenuItem, type MenuItemProps, type MenuProps, MenuSection, type MenuSectionProps, MenuSeparator, Modal, type ModalProps, NavMenu, NavMenuGroup, type NavMenuGroupProps, NavMenuItem, type NavMenuItemProps, type NavMenuProps, Navbar, NavbarContext, NavbarItem, type NavbarItemProps, type NavbarProps, type NavigationContext, PasswordField, type PasswordFieldProps, Popover, ProgressBar, type ProgressBarProps, ProgressCircle, type ProgressCircleProps, Radio, RadioGroup, type RadioGroupProps, Row, type RowProps, SearchField, type SearchFieldProps, Select, type SelectProps, Sidebar, SidebarHeader, SidebarItem, type SidebarItemProps, type SidebarProps, SidebarSection, Slider, type SliderProps, Slot, Spinner, type SpinnerProps, StatusLight, type StatusLightProps, SubMenuTrigger, type SubmenuTriggerProps, Switch, type SwitchProps, Tab, TabList, TabPanel, Table, TableBody, TableCell, type TableCellProps, TableColumn, type TableColumnProps, TableHeader, TableRow, Tabs, Text, TextField, type TextFieldProps, type TextProps, ThemeButton, type ThemeButtonProps, Toast, type ToastOptions, type ToastProps, ToastProvider, type ToastProviderProps, type ToastState, type ToastVariant, Toaster, type ToasterProps, Toggle, ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupProps, type ToggleProps, Tooltip, TooltipBubble, type TooltipBubbleProps, type TooltipProps, ZenProvider, type ZenProviderProps, useDebounce, useNavigationContext, useTheme, useToast };
737
+ export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, AlertBanner, type AlertBannerProps, AlertDialog, type AlertDialogProps, Blockquote, type BlockquoteProps, Box, type BoxProps, Breadcrumb, Breadcrumbs, Button, type ButtonProps, Calendar, type CalendarProps, Checkbox, type CheckboxProps, Code, type CodeProps, Column, type ColumnProps, ComboBox, type ComboBoxProps, ConfirmationDialog, type ConfirmationDialogProps, Container, type ContainerProps, CopyButton, DataColumn, type DataColumnProps, DataTable, type DataTableProps, Dialog, type DialogProps, Dots, type DotsProps, Flexbox, type FlexboxProps, FloatingTooltip, type FloatingTooltipProps, Form, FormButtons, type FormButtonsProps, FormController, type FormControllerProps, FormField, FormFieldArray, type FormFieldArrayProps, type FormFieldProps, type FormProps, FormResetButton, type FormResetButtonProps, FormSubmitButton, Grid, type GridProps, Heading, type HeadingProps, type HoverButtonProps, HoverTrigger, Icon, type IconProps, Image, type ImageProps, InlineEditField, type InlineEditFieldProps, Label, type LabelProps, List, ListItem, type ListItemProps, type ListProps, ListSection, type ListSectionProps, ListSeparator, Loading, LoadingButton, type LoadingButtonProps, type LoadingProps, Menu, MenuItem, type MenuItemProps, type MenuProps, MenuSection, type MenuSectionProps, MenuSeparator, Modal, type ModalProps, NavMenu, NavMenuGroup, type NavMenuGroupProps, NavMenuItem, type NavMenuItemProps, type NavMenuProps, Navbar, NavbarContext, NavbarItem, type NavbarItemProps, type NavbarProps, type NavigationContext, PasswordField, type PasswordFieldProps, Popover, ProgressBar, type ProgressBarProps, ProgressCircle, type ProgressCircleProps, Radio, RadioGroup, type RadioGroupProps, Row, type RowProps, SearchField, type SearchFieldProps, Select, type SelectProps, Sidebar, SidebarHeader, SidebarItem, type SidebarItemProps, type SidebarProps, SidebarSection, Slider, type SliderProps, Slot, Spinner, type SpinnerProps, StatusLight, type StatusLightProps, SubMenuTrigger, type SubmenuTriggerProps, Switch, type SwitchProps, Tab, TabList, TabPanel, Table, TableBody, TableCell, type TableCellProps, TableColumn, type TableColumnProps, TableHeader, TableRow, Tabs, Text, TextField, type TextFieldProps, type TextProps, ThemeButton, Toast, type ToastOptions, type ToastProps, ToastProvider, type ToastProviderProps, type ToastState, type ToastVariant, Toaster, type ToasterProps, Toggle, ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupProps, type ToggleProps, Tooltip, TooltipBubble, type TooltipBubbleProps, type TooltipProps, ZenProvider, type ZenProviderProps, useDebounce, useNavigationContext, useTheme, useToast };
package/dist/index.js CHANGED
@@ -41,12 +41,12 @@ var require_use_sync_external_store_shim_production = __commonJS({
41
41
  }
42
42
  var objectIs = "function" === typeof Object.is ? Object.is : is2;
43
43
  var useState19 = React5.useState;
44
- var useEffect13 = React5.useEffect;
45
- var useLayoutEffect2 = React5.useLayoutEffect;
44
+ var useEffect12 = React5.useEffect;
45
+ var useLayoutEffect3 = React5.useLayoutEffect;
46
46
  var useDebugValue = React5.useDebugValue;
47
47
  function useSyncExternalStore$2(subscribe, getSnapshot) {
48
48
  var value = getSnapshot(), _useState = useState19({ inst: { value, getSnapshot } }), inst = _useState[0].inst, forceUpdate = _useState[1];
49
- useLayoutEffect2(
49
+ useLayoutEffect3(
50
50
  function() {
51
51
  inst.value = value;
52
52
  inst.getSnapshot = getSnapshot;
@@ -54,7 +54,7 @@ var require_use_sync_external_store_shim_production = __commonJS({
54
54
  },
55
55
  [subscribe, value, getSnapshot]
56
56
  );
57
- useEffect13(
57
+ useEffect12(
58
58
  function() {
59
59
  checkIfSnapshotChanged(inst) && forceUpdate({ inst });
60
60
  return subscribe(function() {
@@ -107,7 +107,7 @@ var require_use_sync_external_store_shim_development = __commonJS({
107
107
  inst: { value, getSnapshot }
108
108
  });
109
109
  var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
110
- useLayoutEffect2(
110
+ useLayoutEffect3(
111
111
  function() {
112
112
  inst.value = value;
113
113
  inst.getSnapshot = getSnapshot;
@@ -115,7 +115,7 @@ var require_use_sync_external_store_shim_development = __commonJS({
115
115
  },
116
116
  [subscribe, value, getSnapshot]
117
117
  );
118
- useEffect13(
118
+ useEffect12(
119
119
  function() {
120
120
  checkIfSnapshotChanged(inst) && forceUpdate({ inst });
121
121
  return subscribe(function() {
@@ -141,7 +141,7 @@ var require_use_sync_external_store_shim_development = __commonJS({
141
141
  return getSnapshot();
142
142
  }
143
143
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
144
- var React5 = import_react198.default, objectIs = "function" === typeof Object.is ? Object.is : is2, useState19 = React5.useState, useEffect13 = React5.useEffect, useLayoutEffect2 = React5.useLayoutEffect, useDebugValue = React5.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
144
+ var React5 = import_react198.default, objectIs = "function" === typeof Object.is ? Object.is : is2, useState19 = React5.useState, useEffect12 = React5.useEffect, useLayoutEffect3 = React5.useLayoutEffect, useDebugValue = React5.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
145
145
  exports.useSyncExternalStore = void 0 !== React5.useSyncExternalStore ? React5.useSyncExternalStore : shim;
146
146
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
147
147
  })();
@@ -1933,8 +1933,8 @@ function $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, context) {
1933
1933
  mergedRef
1934
1934
  ];
1935
1935
  }
1936
- function $64fa3d84918910a7$export$9d4c57ee4c6ffdd8(initialState3 = true) {
1937
- let [hasSlot, setHasSlot] = (0, import_react23.useState)(initialState3);
1936
+ function $64fa3d84918910a7$export$9d4c57ee4c6ffdd8(initialState2 = true) {
1937
+ let [hasSlot, setHasSlot] = (0, import_react23.useState)(initialState2);
1938
1938
  let hasRun = (0, import_react23.useRef)(false);
1939
1939
  let ref = (0, import_react23.useCallback)((el) => {
1940
1940
  hasRun.current = true;
@@ -28589,6 +28589,7 @@ function FormField({
28589
28589
  var import_classnames8 = __toESM(require_classnames());
28590
28590
  var import_jsx_runtime15 = require("react/jsx-runtime");
28591
28591
  function FormFieldArray({
28592
+ id,
28592
28593
  name,
28593
28594
  description,
28594
28595
  label,
@@ -28597,16 +28598,18 @@ function FormFieldArray({
28597
28598
  children,
28598
28599
  ...props
28599
28600
  }) {
28601
+ const fieldId = useFieldId(id);
28600
28602
  const context = useFormContext();
28601
- const { formState, control } = context;
28603
+ const { formState, control, register } = context;
28602
28604
  const fieldProps = useFieldArray({
28603
28605
  control,
28604
28606
  name
28605
28607
  });
28608
+ register(name, rules);
28606
28609
  const errors = formState?.errors || {};
28607
28610
  const errorMessage = errors[name]?.message;
28608
28611
  return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { ...props, className: (0, import_classnames8.default)(FormField_default.input, className), children: [
28609
- label && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Label2, { children: label }),
28612
+ label && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Label2, { htmlFor: fieldId, children: label }),
28610
28613
  description && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: FormField_default.description, children: description }),
28611
28614
  errorMessage && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: FormField_default.error, children: errorMessage }),
28612
28615
  children({ ...context, ...fieldProps })
@@ -32366,13 +32369,13 @@ var createStoreImpl = (createState) => {
32366
32369
  }
32367
32370
  };
32368
32371
  const getState = () => state;
32369
- const getInitialState = () => initialState3;
32372
+ const getInitialState = () => initialState2;
32370
32373
  const subscribe = (listener) => {
32371
32374
  listeners.add(listener);
32372
32375
  return () => listeners.delete(listener);
32373
32376
  };
32374
32377
  const api = { setState, getState, getInitialState, subscribe };
32375
- const initialState3 = state = createState(setState, getState, api);
32378
+ const initialState2 = state = createState(setState, getState, api);
32376
32379
  return api;
32377
32380
  };
32378
32381
  var createStore = ((createState) => createState ? createStoreImpl(createState) : createStoreImpl);
@@ -32511,25 +32514,40 @@ function useDebounce(value, delay) {
32511
32514
 
32512
32515
  // src/components/hooks/useTheme.ts
32513
32516
  var import_react181 = require("react");
32514
- function getDefaultTheme() {
32515
- return typeof window !== "undefined" ? window?.matchMedia("(prefers-color-scheme: dark)")?.matches ? "dark" : "light" : "light";
32516
- }
32517
- var initialState2 = {
32518
- theme: getDefaultTheme()
32519
- };
32520
- var store2 = create(() => ({ ...initialState2 }));
32521
- function setTheme(theme) {
32522
- store2.setState({ theme });
32523
- document.documentElement.setAttribute("data-theme", theme);
32517
+ function resolveTheme(preferred, colorScheme) {
32518
+ if (preferred) {
32519
+ return preferred;
32520
+ }
32521
+ if (colorScheme === "light" || colorScheme === "dark") {
32522
+ return colorScheme;
32523
+ }
32524
+ if (typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches) {
32525
+ return "dark";
32526
+ }
32527
+ return "light";
32524
32528
  }
32525
- function useTheme(defaultTheme) {
32526
- const { theme } = store2();
32527
- (0, import_react181.useEffect)(() => {
32528
- if (defaultTheme) {
32529
- setTheme(defaultTheme);
32529
+ var useTheme = create((set2, get2) => ({
32530
+ theme: "light",
32531
+ setTheme: (theme) => {
32532
+ set2({ theme });
32533
+ if (typeof window !== "undefined") {
32534
+ localStorage.setItem("zen.theme", theme);
32535
+ document.documentElement.setAttribute("data-theme", theme);
32530
32536
  }
32531
- }, [defaultTheme]);
32532
- return { theme, setTheme };
32537
+ },
32538
+ initTheme: (preferred, colorScheme) => {
32539
+ if (typeof window === "undefined") return;
32540
+ const stored = localStorage.getItem("zen.theme");
32541
+ const initial = resolveTheme(preferred || stored || void 0, colorScheme);
32542
+ set2({ theme: initial });
32543
+ document.documentElement.setAttribute("data-theme", initial);
32544
+ }
32545
+ }));
32546
+ function useInitTheme(preferred, colorScheme) {
32547
+ const initTheme = useTheme((s) => s.initTheme);
32548
+ (0, import_react181.useLayoutEffect)(() => {
32549
+ initTheme(preferred, colorScheme);
32550
+ }, [preferred, colorScheme, initTheme]);
32533
32551
  }
32534
32552
 
32535
32553
  // src/components/Accordion.tsx
@@ -34215,14 +34233,8 @@ var ThemeButton_default = { "button": "ThemeButton_button__MDUzN" };
34215
34233
 
34216
34234
  // src/components/ThemeButton.tsx
34217
34235
  var import_jsx_runtime67 = require("react/jsx-runtime");
34218
- function ThemeButton({
34219
- className,
34220
- variant = "quiet",
34221
- defaultTheme,
34222
- onPress,
34223
- ...props
34224
- }) {
34225
- const { theme, setTheme: setTheme2 } = useTheme(defaultTheme);
34236
+ function ThemeButton({ className, variant = "quiet", onPress, ...props }) {
34237
+ const { theme, setTheme } = useTheme();
34226
34238
  const transitions = useTransition(theme, {
34227
34239
  initial: { opacity: 1 },
34228
34240
  from: {
@@ -34236,7 +34248,7 @@ function ThemeButton({
34236
34248
  }
34237
34249
  });
34238
34250
  function handleClick(e) {
34239
- setTheme2(theme === "light" ? "dark" : "light");
34251
+ setTheme(theme === "light" ? "dark" : "light");
34240
34252
  onPress?.(e);
34241
34253
  }
34242
34254
  return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
@@ -34329,11 +34341,16 @@ function ToggleGroupItem({ className, children, ...props }) {
34329
34341
 
34330
34342
  // src/components/ZenProvider.tsx
34331
34343
  var import_jsx_runtime70 = require("react/jsx-runtime");
34332
- var defaultToastCofig = {
34344
+ var defaultToastConfig = {
34333
34345
  duration: 3e3
34334
34346
  };
34335
- function ZenProvider({ children, ...props }) {
34336
- const { toast = defaultToastCofig } = props;
34347
+ function ZenProvider({
34348
+ children,
34349
+ theme,
34350
+ colorScheme,
34351
+ toast = defaultToastConfig
34352
+ }) {
34353
+ useInitTheme(theme, colorScheme);
34337
34354
  return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ToastProvider, { ...toast, children });
34338
34355
  }
34339
34356
  /*! Bundled license information:
package/dist/index.mjs CHANGED
@@ -35,12 +35,12 @@ var require_use_sync_external_store_shim_production = __commonJS({
35
35
  }
36
36
  var objectIs = "function" === typeof Object.is ? Object.is : is2;
37
37
  var useState19 = React5.useState;
38
- var useEffect13 = React5.useEffect;
39
- var useLayoutEffect2 = React5.useLayoutEffect;
38
+ var useEffect12 = React5.useEffect;
39
+ var useLayoutEffect3 = React5.useLayoutEffect;
40
40
  var useDebugValue = React5.useDebugValue;
41
41
  function useSyncExternalStore$2(subscribe, getSnapshot) {
42
42
  var value = getSnapshot(), _useState = useState19({ inst: { value, getSnapshot } }), inst = _useState[0].inst, forceUpdate = _useState[1];
43
- useLayoutEffect2(
43
+ useLayoutEffect3(
44
44
  function() {
45
45
  inst.value = value;
46
46
  inst.getSnapshot = getSnapshot;
@@ -48,7 +48,7 @@ var require_use_sync_external_store_shim_production = __commonJS({
48
48
  },
49
49
  [subscribe, value, getSnapshot]
50
50
  );
51
- useEffect13(
51
+ useEffect12(
52
52
  function() {
53
53
  checkIfSnapshotChanged(inst) && forceUpdate({ inst });
54
54
  return subscribe(function() {
@@ -101,7 +101,7 @@ var require_use_sync_external_store_shim_development = __commonJS({
101
101
  inst: { value, getSnapshot }
102
102
  });
103
103
  var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
104
- useLayoutEffect2(
104
+ useLayoutEffect3(
105
105
  function() {
106
106
  inst.value = value;
107
107
  inst.getSnapshot = getSnapshot;
@@ -109,7 +109,7 @@ var require_use_sync_external_store_shim_development = __commonJS({
109
109
  },
110
110
  [subscribe, value, getSnapshot]
111
111
  );
112
- useEffect13(
112
+ useEffect12(
113
113
  function() {
114
114
  checkIfSnapshotChanged(inst) && forceUpdate({ inst });
115
115
  return subscribe(function() {
@@ -135,7 +135,7 @@ var require_use_sync_external_store_shim_development = __commonJS({
135
135
  return getSnapshot();
136
136
  }
137
137
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
138
- var React5 = __import_react2, objectIs = "function" === typeof Object.is ? Object.is : is2, useState19 = React5.useState, useEffect13 = React5.useEffect, useLayoutEffect2 = React5.useLayoutEffect, useDebugValue = React5.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
138
+ var React5 = __import_react2, objectIs = "function" === typeof Object.is ? Object.is : is2, useState19 = React5.useState, useEffect12 = React5.useEffect, useLayoutEffect3 = React5.useLayoutEffect, useDebugValue = React5.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
139
139
  exports.useSyncExternalStore = void 0 !== React5.useSyncExternalStore ? React5.useSyncExternalStore : shim;
140
140
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
141
141
  })();
@@ -1814,8 +1814,8 @@ function $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, context) {
1814
1814
  mergedRef
1815
1815
  ];
1816
1816
  }
1817
- function $64fa3d84918910a7$export$9d4c57ee4c6ffdd8(initialState3 = true) {
1818
- let [hasSlot, setHasSlot] = (0, $iETbY$useState)(initialState3);
1817
+ function $64fa3d84918910a7$export$9d4c57ee4c6ffdd8(initialState2 = true) {
1818
+ let [hasSlot, setHasSlot] = (0, $iETbY$useState)(initialState2);
1819
1819
  let hasRun = (0, $iETbY$useRef)(false);
1820
1820
  let ref = (0, $iETbY$useCallback)((el) => {
1821
1821
  hasRun.current = true;
@@ -28470,6 +28470,7 @@ function FormField({
28470
28470
  var import_classnames8 = __toESM(require_classnames());
28471
28471
  import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
28472
28472
  function FormFieldArray({
28473
+ id,
28473
28474
  name,
28474
28475
  description,
28475
28476
  label,
@@ -28478,16 +28479,18 @@ function FormFieldArray({
28478
28479
  children,
28479
28480
  ...props
28480
28481
  }) {
28482
+ const fieldId = useFieldId(id);
28481
28483
  const context = useFormContext();
28482
- const { formState, control } = context;
28484
+ const { formState, control, register } = context;
28483
28485
  const fieldProps = useFieldArray({
28484
28486
  control,
28485
28487
  name
28486
28488
  });
28489
+ register(name, rules);
28487
28490
  const errors = formState?.errors || {};
28488
28491
  const errorMessage = errors[name]?.message;
28489
28492
  return /* @__PURE__ */ jsxs7("div", { ...props, className: (0, import_classnames8.default)(FormField_default.input, className), children: [
28490
- label && /* @__PURE__ */ jsx15(Label2, { children: label }),
28493
+ label && /* @__PURE__ */ jsx15(Label2, { htmlFor: fieldId, children: label }),
28491
28494
  description && /* @__PURE__ */ jsx15("div", { className: FormField_default.description, children: description }),
28492
28495
  errorMessage && /* @__PURE__ */ jsx15("div", { className: FormField_default.error, children: errorMessage }),
28493
28496
  children({ ...context, ...fieldProps })
@@ -32247,13 +32250,13 @@ var createStoreImpl = (createState) => {
32247
32250
  }
32248
32251
  };
32249
32252
  const getState = () => state;
32250
- const getInitialState = () => initialState3;
32253
+ const getInitialState = () => initialState2;
32251
32254
  const subscribe = (listener) => {
32252
32255
  listeners.add(listener);
32253
32256
  return () => listeners.delete(listener);
32254
32257
  };
32255
32258
  const api = { setState, getState, getInitialState, subscribe };
32256
- const initialState3 = state = createState(setState, getState, api);
32259
+ const initialState2 = state = createState(setState, getState, api);
32257
32260
  return api;
32258
32261
  };
32259
32262
  var createStore = ((createState) => createState ? createStoreImpl(createState) : createStoreImpl);
@@ -32391,26 +32394,41 @@ function useDebounce(value, delay) {
32391
32394
  }
32392
32395
 
32393
32396
  // src/components/hooks/useTheme.ts
32394
- import { useEffect as useEffect8 } from "react";
32395
- function getDefaultTheme() {
32396
- return typeof window !== "undefined" ? window?.matchMedia("(prefers-color-scheme: dark)")?.matches ? "dark" : "light" : "light";
32397
- }
32398
- var initialState2 = {
32399
- theme: getDefaultTheme()
32400
- };
32401
- var store2 = create(() => ({ ...initialState2 }));
32402
- function setTheme(theme) {
32403
- store2.setState({ theme });
32404
- document.documentElement.setAttribute("data-theme", theme);
32397
+ import { useLayoutEffect as useLayoutEffect2 } from "react";
32398
+ function resolveTheme(preferred, colorScheme) {
32399
+ if (preferred) {
32400
+ return preferred;
32401
+ }
32402
+ if (colorScheme === "light" || colorScheme === "dark") {
32403
+ return colorScheme;
32404
+ }
32405
+ if (typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches) {
32406
+ return "dark";
32407
+ }
32408
+ return "light";
32405
32409
  }
32406
- function useTheme(defaultTheme) {
32407
- const { theme } = store2();
32408
- useEffect8(() => {
32409
- if (defaultTheme) {
32410
- setTheme(defaultTheme);
32410
+ var useTheme = create((set2, get2) => ({
32411
+ theme: "light",
32412
+ setTheme: (theme) => {
32413
+ set2({ theme });
32414
+ if (typeof window !== "undefined") {
32415
+ localStorage.setItem("zen.theme", theme);
32416
+ document.documentElement.setAttribute("data-theme", theme);
32411
32417
  }
32412
- }, [defaultTheme]);
32413
- return { theme, setTheme };
32418
+ },
32419
+ initTheme: (preferred, colorScheme) => {
32420
+ if (typeof window === "undefined") return;
32421
+ const stored = localStorage.getItem("zen.theme");
32422
+ const initial = resolveTheme(preferred || stored || void 0, colorScheme);
32423
+ set2({ theme: initial });
32424
+ document.documentElement.setAttribute("data-theme", initial);
32425
+ }
32426
+ }));
32427
+ function useInitTheme(preferred, colorScheme) {
32428
+ const initTheme = useTheme((s) => s.initTheme);
32429
+ useLayoutEffect2(() => {
32430
+ initTheme(preferred, colorScheme);
32431
+ }, [preferred, colorScheme, initTheme]);
32414
32432
  }
32415
32433
 
32416
32434
  // src/components/Accordion.tsx
@@ -32915,7 +32933,7 @@ var import_classnames25 = __toESM(require_classnames());
32915
32933
  import { useState as useState10 } from "react";
32916
32934
 
32917
32935
  // src/components/TextField.tsx
32918
- import { useEffect as useEffect9, useState as useState9 } from "react";
32936
+ import { useEffect as useEffect8, useState as useState9 } from "react";
32919
32937
  var import_classnames24 = __toESM(require_classnames());
32920
32938
 
32921
32939
  // src/components/CopyButton.tsx
@@ -32968,7 +32986,7 @@ function TextField2({
32968
32986
  setInputValue(value2);
32969
32987
  return onChange?.(value2);
32970
32988
  };
32971
- useEffect9(() => {
32989
+ useEffect8(() => {
32972
32990
  setInputValue(value);
32973
32991
  }, [value]);
32974
32992
  return /* @__PURE__ */ jsxs20(Fragment6, { children: [
@@ -33187,7 +33205,7 @@ function Dots({ size = "md", className, ...props }) {
33187
33205
 
33188
33206
  // src/components/FloatingTooltip.tsx
33189
33207
  var import_classnames31 = __toESM(require_classnames());
33190
- import { useEffect as useEffect10, useState as useState11 } from "react";
33208
+ import { useEffect as useEffect9, useState as useState11 } from "react";
33191
33209
 
33192
33210
  // src/components/Tooltip.tsx
33193
33211
  var import_classnames30 = __toESM(require_classnames());
@@ -33214,7 +33232,7 @@ var FloatingTooltip_default = { "floating": "FloatingTooltip_floating__ZjM4N" };
33214
33232
  import { jsx as jsx45 } from "react/jsx-runtime";
33215
33233
  function FloatingTooltip({ className, style, children, ...props }) {
33216
33234
  const [position, setPosition] = useState11({ x: -1e3, y: -1e3 });
33217
- useEffect10(() => {
33235
+ useEffect9(() => {
33218
33236
  const handler = (e) => {
33219
33237
  setPosition({ x: e.clientX, y: e.clientY });
33220
33238
  };
@@ -33270,7 +33288,7 @@ function Heading2({
33270
33288
  }
33271
33289
 
33272
33290
  // src/components/HoverTrigger.tsx
33273
- import { useRef as useRef8, useState as useState12, useEffect as useEffect11 } from "react";
33291
+ import { useRef as useRef8, useState as useState12, useEffect as useEffect10 } from "react";
33274
33292
 
33275
33293
  // css-modules:E:\dev\umami-react-zen\src\components\HoverTrigger.module.css
33276
33294
  var HoverTrigger_default = { "wrapper": "HoverTrigger_wrapper__NGFlN" };
@@ -33291,7 +33309,7 @@ function HoverTrigger({
33291
33309
  const isOverMenu = useRef8(false);
33292
33310
  const isOverButton = useRef8(false);
33293
33311
  const timeout = useRef8(null);
33294
- useEffect11(() => {
33312
+ useEffect10(() => {
33295
33313
  if (isOpen !== open) {
33296
33314
  setOpen(isOpen);
33297
33315
  }
@@ -33771,7 +33789,7 @@ function Radio2({ children, className, ...props }) {
33771
33789
  }
33772
33790
 
33773
33791
  // src/components/SearchField.tsx
33774
- import { useState as useState17, useEffect as useEffect12 } from "react";
33792
+ import { useState as useState17, useEffect as useEffect11 } from "react";
33775
33793
  var import_classnames45 = __toESM(require_classnames());
33776
33794
  import { Fragment as Fragment12, jsx as jsx60, jsxs as jsxs35 } from "react/jsx-runtime";
33777
33795
  function SearchField2({
@@ -33799,7 +33817,7 @@ function SearchField2({
33799
33817
  onSearch?.("");
33800
33818
  onChange?.("");
33801
33819
  };
33802
- useEffect12(() => {
33820
+ useEffect11(() => {
33803
33821
  if (delay > 0) {
33804
33822
  onSearch?.(searchValue);
33805
33823
  }
@@ -34100,14 +34118,8 @@ var ThemeButton_default = { "button": "ThemeButton_button__MDUzN" };
34100
34118
 
34101
34119
  // src/components/ThemeButton.tsx
34102
34120
  import { jsx as jsx67, jsxs as jsxs41 } from "react/jsx-runtime";
34103
- function ThemeButton({
34104
- className,
34105
- variant = "quiet",
34106
- defaultTheme,
34107
- onPress,
34108
- ...props
34109
- }) {
34110
- const { theme, setTheme: setTheme2 } = useTheme(defaultTheme);
34121
+ function ThemeButton({ className, variant = "quiet", onPress, ...props }) {
34122
+ const { theme, setTheme } = useTheme();
34111
34123
  const transitions = useTransition(theme, {
34112
34124
  initial: { opacity: 1 },
34113
34125
  from: {
@@ -34121,7 +34133,7 @@ function ThemeButton({
34121
34133
  }
34122
34134
  });
34123
34135
  function handleClick(e) {
34124
- setTheme2(theme === "light" ? "dark" : "light");
34136
+ setTheme(theme === "light" ? "dark" : "light");
34125
34137
  onPress?.(e);
34126
34138
  }
34127
34139
  return /* @__PURE__ */ jsxs41(
@@ -34214,11 +34226,16 @@ function ToggleGroupItem({ className, children, ...props }) {
34214
34226
 
34215
34227
  // src/components/ZenProvider.tsx
34216
34228
  import { jsx as jsx70 } from "react/jsx-runtime";
34217
- var defaultToastCofig = {
34229
+ var defaultToastConfig = {
34218
34230
  duration: 3e3
34219
34231
  };
34220
- function ZenProvider({ children, ...props }) {
34221
- const { toast = defaultToastCofig } = props;
34232
+ function ZenProvider({
34233
+ children,
34234
+ theme,
34235
+ colorScheme,
34236
+ toast = defaultToastConfig
34237
+ }) {
34238
+ useInitTheme(theme, colorScheme);
34222
34239
  return /* @__PURE__ */ jsx70(ToastProvider, { ...toast, children });
34223
34240
  }
34224
34241
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umami/react-zen",
3
- "version": "0.182.0",
3
+ "version": "0.184.0",
4
4
  "description": "Modern, minimalist React component library",
5
5
  "author": "Umami <hello@umami.is>",
6
6
  "license": "MIT",