@undefine-ui/design-system 2.5.0 → 2.6.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.cts CHANGED
@@ -1,6 +1,6 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
1
  import * as react from 'react';
3
2
  import { SetStateAction, ElementType } from 'react';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import { Breakpoint, Shadows, Components, Theme, SxProps as SxProps$1 } from '@mui/material/styles';
5
5
  import * as _mui_material from '@mui/material';
6
6
  import { SxProps, Theme as Theme$1 } from '@mui/material';
@@ -108,6 +108,50 @@ interface UseBooleanReturnType {
108
108
  */
109
109
  declare const useBoolean: (defaultValue?: boolean) => UseBooleanReturnType;
110
110
 
111
+ /**
112
+ * A custom hook for managing popover state and interactions.
113
+ *
114
+ * Provides utilities to control the open/close state of a popover component,
115
+ * track the anchor element, and handle user interactions.
116
+ *
117
+ * @returns An object containing:
118
+ * - `open` (boolean): Whether the popover is currently open
119
+ * - `anchorEl` (HTMLElement | null): The element the popover is anchored to
120
+ * - `onOpen` (function): Handler to open the popover on a mouse event
121
+ * - `onClose` (function): Handler to close the popover
122
+ * - `setAnchorEl` (function): Direct setter for the anchor element
123
+ *
124
+ * @example
125
+ * ```tsx
126
+ * function MyComponent() {
127
+ * const popover = usePopover();
128
+ *
129
+ * return (
130
+ * <>
131
+ * <Button onClick={popover.onOpen}>
132
+ * Open Menu
133
+ * </Button>
134
+ * <Popover
135
+ * open={popover.open}
136
+ * anchorEl={popover.anchorEl}
137
+ * onClose={popover.onClose}
138
+ * >
139
+ * <MenuItem onClick={popover.onClose}>Option 1</MenuItem>
140
+ * <MenuItem onClick={popover.onClose}>Option 2</MenuItem>
141
+ * </Popover>
142
+ * </>
143
+ * );
144
+ * }
145
+ * ```
146
+ */
147
+ declare const usePopover: () => {
148
+ open: boolean;
149
+ anchorEl: HTMLElement | null;
150
+ onOpen: (event: React.MouseEvent<HTMLElement>) => void;
151
+ onClose: () => void;
152
+ setAnchorEl: react.Dispatch<react.SetStateAction<HTMLElement | null>>;
153
+ };
154
+
111
155
  declare const STORAGE_KEY = "app-settings";
112
156
  type SettingsValueProps = {
113
157
  colorScheme: 'light' | 'dark';
@@ -1752,4 +1796,4 @@ interface LoadingScreenProps extends BoxProps {
1752
1796
  declare const LoadingScreen: ({ portal, sx, ...rest }: LoadingScreenProps) => react_jsx_runtime.JSX.Element;
1753
1797
  declare const SplashScreen: ({ portal, sx, ...rest }: LoadingScreenProps) => react_jsx_runtime.JSX.Element;
1754
1798
 
1755
- export { AnimatedLogo, BellNotification, CheckboxDefault, CheckboxIndeterminate, CheckboxSelect, ClipboardCheck, CloudUpload, type ColorSchema, Copy, CopyButton, type CustomShadowOptions, type CustomSpacingOptions, Eye, EyeClosed, Field, Form, Icon, type IconProps, type IconType, InfoCircleFill, InfoCircleOutline, KeyCommand, Loader, LoadingScreen, LocalStorageAvailable, LocalStorageGetItem, Logo, LongArrowUpLeftSolid, NavArrowDown, NavArrowLeft, NavArrowRight, RHFAutocomplete, type RHFAutocompleteProps, RHFCheckbox, type RHFCheckboxProps, RHFMultiCheckbox, type RHFMultiCheckboxOption, type RHFMultiCheckboxProps, RHFMultiSwitch, RHFRadioGroup, type RHFRadioGroupProps, RHFSwitch, RHFTextField, RHFUpload, type RHFUploadProps, RadioDefault, RadioSelect, type RadiusOptions, STORAGE_KEY, Search, Settings, SettingsConsumer, SettingsContext, type SettingsContextProps, SettingsProvider, type SettingsValueProps, SplashScreen, Table, type TableNoRowsProps, TablePagination, ThemeProvider, Trash, Upload, type UploadProps, type UseBooleanReturnType, type UseSetStateReturnType, UserFill, UserOutline, XMark, XMarkSolid, action, background, baseAction, basePalette, bgBlur, bgGradient, border, borderGradient, breakpoints, colorSchemes, common, components, createPaletteChannel, createShadowColor, createTheme, customShadows, customSpacing, darkPalette, defaultSettings, error, fCurrency, fData, fNumber, fPercent, fShortenNumber, getCurrencySymbol, getInitColorSchemeScript, getStorage, grey, hexToRgbChannel, hideScrollX, hideScrollY, icon, iconClasses, info, isEqual, lightPalette, maxLine, mediaQueries, menuItem, neutral, orderBy, paper, paramCase, primary, primaryFont, pxToRem, radius, remToPx, removeStorage, responsiveFontSizes, schemeConfig, secondary, secondaryFont, sentenceCase, setFont, setStorage, shadows, snakeCase, stylesMode, success, surface, tertiaryFont, text, textGradient, typography, updateComponentsWithSettings, updateCoreWithSettings, useBoolean, useCopyToClipboard, useEventListener, useLocalStorage, useResponsive, useScrollOffSetTop, useSetState, useSettings, useWidth, varAlpha, warning };
1799
+ export { AnimatedLogo, BellNotification, CheckboxDefault, CheckboxIndeterminate, CheckboxSelect, ClipboardCheck, CloudUpload, type ColorSchema, Copy, CopyButton, type CustomShadowOptions, type CustomSpacingOptions, Eye, EyeClosed, Field, Form, Icon, type IconProps, type IconType, InfoCircleFill, InfoCircleOutline, KeyCommand, Loader, LoadingScreen, LocalStorageAvailable, LocalStorageGetItem, Logo, LongArrowUpLeftSolid, NavArrowDown, NavArrowLeft, NavArrowRight, RHFAutocomplete, type RHFAutocompleteProps, RHFCheckbox, type RHFCheckboxProps, RHFMultiCheckbox, type RHFMultiCheckboxOption, type RHFMultiCheckboxProps, RHFMultiSwitch, RHFRadioGroup, type RHFRadioGroupProps, RHFSwitch, RHFTextField, RHFUpload, type RHFUploadProps, RadioDefault, RadioSelect, type RadiusOptions, STORAGE_KEY, Search, Settings, SettingsConsumer, SettingsContext, type SettingsContextProps, SettingsProvider, type SettingsValueProps, SplashScreen, Table, type TableNoRowsProps, TablePagination, ThemeProvider, Trash, Upload, type UploadProps, type UseBooleanReturnType, type UseSetStateReturnType, UserFill, UserOutline, XMark, XMarkSolid, action, background, baseAction, basePalette, bgBlur, bgGradient, border, borderGradient, breakpoints, colorSchemes, common, components, createPaletteChannel, createShadowColor, createTheme, customShadows, customSpacing, darkPalette, defaultSettings, error, fCurrency, fData, fNumber, fPercent, fShortenNumber, getCurrencySymbol, getInitColorSchemeScript, getStorage, grey, hexToRgbChannel, hideScrollX, hideScrollY, icon, iconClasses, info, isEqual, lightPalette, maxLine, mediaQueries, menuItem, neutral, orderBy, paper, paramCase, primary, primaryFont, pxToRem, radius, remToPx, removeStorage, responsiveFontSizes, schemeConfig, secondary, secondaryFont, sentenceCase, setFont, setStorage, shadows, snakeCase, stylesMode, success, surface, tertiaryFont, text, textGradient, typography, updateComponentsWithSettings, updateCoreWithSettings, useBoolean, useCopyToClipboard, useEventListener, useLocalStorage, usePopover, useResponsive, useScrollOffSetTop, useSetState, useSettings, useWidth, varAlpha, warning };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
1
  import * as react from 'react';
3
2
  import { SetStateAction, ElementType } from 'react';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import { Breakpoint, Shadows, Components, Theme, SxProps as SxProps$1 } from '@mui/material/styles';
5
5
  import * as _mui_material from '@mui/material';
6
6
  import { SxProps, Theme as Theme$1 } from '@mui/material';
@@ -108,6 +108,50 @@ interface UseBooleanReturnType {
108
108
  */
109
109
  declare const useBoolean: (defaultValue?: boolean) => UseBooleanReturnType;
110
110
 
111
+ /**
112
+ * A custom hook for managing popover state and interactions.
113
+ *
114
+ * Provides utilities to control the open/close state of a popover component,
115
+ * track the anchor element, and handle user interactions.
116
+ *
117
+ * @returns An object containing:
118
+ * - `open` (boolean): Whether the popover is currently open
119
+ * - `anchorEl` (HTMLElement | null): The element the popover is anchored to
120
+ * - `onOpen` (function): Handler to open the popover on a mouse event
121
+ * - `onClose` (function): Handler to close the popover
122
+ * - `setAnchorEl` (function): Direct setter for the anchor element
123
+ *
124
+ * @example
125
+ * ```tsx
126
+ * function MyComponent() {
127
+ * const popover = usePopover();
128
+ *
129
+ * return (
130
+ * <>
131
+ * <Button onClick={popover.onOpen}>
132
+ * Open Menu
133
+ * </Button>
134
+ * <Popover
135
+ * open={popover.open}
136
+ * anchorEl={popover.anchorEl}
137
+ * onClose={popover.onClose}
138
+ * >
139
+ * <MenuItem onClick={popover.onClose}>Option 1</MenuItem>
140
+ * <MenuItem onClick={popover.onClose}>Option 2</MenuItem>
141
+ * </Popover>
142
+ * </>
143
+ * );
144
+ * }
145
+ * ```
146
+ */
147
+ declare const usePopover: () => {
148
+ open: boolean;
149
+ anchorEl: HTMLElement | null;
150
+ onOpen: (event: React.MouseEvent<HTMLElement>) => void;
151
+ onClose: () => void;
152
+ setAnchorEl: react.Dispatch<react.SetStateAction<HTMLElement | null>>;
153
+ };
154
+
111
155
  declare const STORAGE_KEY = "app-settings";
112
156
  type SettingsValueProps = {
113
157
  colorScheme: 'light' | 'dark';
@@ -1752,4 +1796,4 @@ interface LoadingScreenProps extends BoxProps {
1752
1796
  declare const LoadingScreen: ({ portal, sx, ...rest }: LoadingScreenProps) => react_jsx_runtime.JSX.Element;
1753
1797
  declare const SplashScreen: ({ portal, sx, ...rest }: LoadingScreenProps) => react_jsx_runtime.JSX.Element;
1754
1798
 
1755
- export { AnimatedLogo, BellNotification, CheckboxDefault, CheckboxIndeterminate, CheckboxSelect, ClipboardCheck, CloudUpload, type ColorSchema, Copy, CopyButton, type CustomShadowOptions, type CustomSpacingOptions, Eye, EyeClosed, Field, Form, Icon, type IconProps, type IconType, InfoCircleFill, InfoCircleOutline, KeyCommand, Loader, LoadingScreen, LocalStorageAvailable, LocalStorageGetItem, Logo, LongArrowUpLeftSolid, NavArrowDown, NavArrowLeft, NavArrowRight, RHFAutocomplete, type RHFAutocompleteProps, RHFCheckbox, type RHFCheckboxProps, RHFMultiCheckbox, type RHFMultiCheckboxOption, type RHFMultiCheckboxProps, RHFMultiSwitch, RHFRadioGroup, type RHFRadioGroupProps, RHFSwitch, RHFTextField, RHFUpload, type RHFUploadProps, RadioDefault, RadioSelect, type RadiusOptions, STORAGE_KEY, Search, Settings, SettingsConsumer, SettingsContext, type SettingsContextProps, SettingsProvider, type SettingsValueProps, SplashScreen, Table, type TableNoRowsProps, TablePagination, ThemeProvider, Trash, Upload, type UploadProps, type UseBooleanReturnType, type UseSetStateReturnType, UserFill, UserOutline, XMark, XMarkSolid, action, background, baseAction, basePalette, bgBlur, bgGradient, border, borderGradient, breakpoints, colorSchemes, common, components, createPaletteChannel, createShadowColor, createTheme, customShadows, customSpacing, darkPalette, defaultSettings, error, fCurrency, fData, fNumber, fPercent, fShortenNumber, getCurrencySymbol, getInitColorSchemeScript, getStorage, grey, hexToRgbChannel, hideScrollX, hideScrollY, icon, iconClasses, info, isEqual, lightPalette, maxLine, mediaQueries, menuItem, neutral, orderBy, paper, paramCase, primary, primaryFont, pxToRem, radius, remToPx, removeStorage, responsiveFontSizes, schemeConfig, secondary, secondaryFont, sentenceCase, setFont, setStorage, shadows, snakeCase, stylesMode, success, surface, tertiaryFont, text, textGradient, typography, updateComponentsWithSettings, updateCoreWithSettings, useBoolean, useCopyToClipboard, useEventListener, useLocalStorage, useResponsive, useScrollOffSetTop, useSetState, useSettings, useWidth, varAlpha, warning };
1799
+ export { AnimatedLogo, BellNotification, CheckboxDefault, CheckboxIndeterminate, CheckboxSelect, ClipboardCheck, CloudUpload, type ColorSchema, Copy, CopyButton, type CustomShadowOptions, type CustomSpacingOptions, Eye, EyeClosed, Field, Form, Icon, type IconProps, type IconType, InfoCircleFill, InfoCircleOutline, KeyCommand, Loader, LoadingScreen, LocalStorageAvailable, LocalStorageGetItem, Logo, LongArrowUpLeftSolid, NavArrowDown, NavArrowLeft, NavArrowRight, RHFAutocomplete, type RHFAutocompleteProps, RHFCheckbox, type RHFCheckboxProps, RHFMultiCheckbox, type RHFMultiCheckboxOption, type RHFMultiCheckboxProps, RHFMultiSwitch, RHFRadioGroup, type RHFRadioGroupProps, RHFSwitch, RHFTextField, RHFUpload, type RHFUploadProps, RadioDefault, RadioSelect, type RadiusOptions, STORAGE_KEY, Search, Settings, SettingsConsumer, SettingsContext, type SettingsContextProps, SettingsProvider, type SettingsValueProps, SplashScreen, Table, type TableNoRowsProps, TablePagination, ThemeProvider, Trash, Upload, type UploadProps, type UseBooleanReturnType, type UseSetStateReturnType, UserFill, UserOutline, XMark, XMarkSolid, action, background, baseAction, basePalette, bgBlur, bgGradient, border, borderGradient, breakpoints, colorSchemes, common, components, createPaletteChannel, createShadowColor, createTheme, customShadows, customSpacing, darkPalette, defaultSettings, error, fCurrency, fData, fNumber, fPercent, fShortenNumber, getCurrencySymbol, getInitColorSchemeScript, getStorage, grey, hexToRgbChannel, hideScrollX, hideScrollY, icon, iconClasses, info, isEqual, lightPalette, maxLine, mediaQueries, menuItem, neutral, orderBy, paper, paramCase, primary, primaryFont, pxToRem, radius, remToPx, removeStorage, responsiveFontSizes, schemeConfig, secondary, secondaryFont, sentenceCase, setFont, setStorage, shadows, snakeCase, stylesMode, success, surface, tertiaryFont, text, textGradient, typography, updateComponentsWithSettings, updateCoreWithSettings, useBoolean, useCopyToClipboard, useEventListener, useLocalStorage, usePopover, useResponsive, useScrollOffSetTop, useSetState, useSettings, useWidth, varAlpha, warning };
package/dist/index.js CHANGED
@@ -159,6 +159,25 @@ var useBoolean = (defaultValue) => {
159
159
  return memoizedValue;
160
160
  };
161
161
 
162
+ // src/hooks/usePopover.ts
163
+ import { useState as useState2, useCallback as useCallback2 } from "react";
164
+ var usePopover = () => {
165
+ const [anchorEl, setAnchorEl] = useState2(null);
166
+ const onOpen = useCallback2((event) => {
167
+ setAnchorEl(event.currentTarget);
168
+ }, []);
169
+ const onClose = useCallback2(() => {
170
+ setAnchorEl(null);
171
+ }, []);
172
+ return {
173
+ open: !!anchorEl,
174
+ anchorEl,
175
+ onOpen,
176
+ onClose,
177
+ setAnchorEl
178
+ };
179
+ };
180
+
162
181
  // src/hooks/useSettings.ts
163
182
  import { useContext } from "react";
164
183
 
@@ -406,12 +425,12 @@ var defaultSettings = {
406
425
  };
407
426
 
408
427
  // src/contexts/settings/context.tsx
409
- import { useMemo as useMemo3, useState as useState3, useCallback as useCallback3, createContext } from "react";
428
+ import { useMemo as useMemo3, useState as useState4, useCallback as useCallback4, createContext } from "react";
410
429
 
411
430
  // src/hooks/useLocalStorage.ts
412
- import { useMemo as useMemo2, useState as useState2, useEffect, useCallback as useCallback2 } from "react";
431
+ import { useMemo as useMemo2, useState as useState3, useEffect, useCallback as useCallback3 } from "react";
413
432
  var useLocalStorage = (key, initialState) => {
414
- const [state, set] = useState2(initialState);
433
+ const [state, set] = useState3(initialState);
415
434
  const multiValue = initialState && typeof initialState === "object";
416
435
  const canReset = !isEqual(state, initialState);
417
436
  useEffect(() => {
@@ -424,7 +443,7 @@ var useLocalStorage = (key, initialState) => {
424
443
  }
425
444
  }
426
445
  }, [key, multiValue]);
427
- const setState = useCallback2(
446
+ const setState = useCallback3(
428
447
  (updateState) => {
429
448
  if (multiValue) {
430
449
  set((prevValue) => {
@@ -438,7 +457,7 @@ var useLocalStorage = (key, initialState) => {
438
457
  },
439
458
  [key, multiValue]
440
459
  );
441
- const setField = useCallback2(
460
+ const setField = useCallback3(
442
461
  (name, updateValue) => {
443
462
  if (multiValue) {
444
463
  setState({ [name]: updateValue });
@@ -446,7 +465,7 @@ var useLocalStorage = (key, initialState) => {
446
465
  },
447
466
  [multiValue, setState]
448
467
  );
449
- const resetState = useCallback2(() => {
468
+ const resetState = useCallback3(() => {
450
469
  set(initialState);
451
470
  removeStorage(key);
452
471
  }, [initialState, key]);
@@ -515,11 +534,11 @@ var SettingsConsumer = SettingsContext.Consumer;
515
534
  var SettingsProvider = ({ children, settings }) => {
516
535
  const localStorage2 = useLocalStorage(STORAGE_KEY, settings);
517
536
  const values = localStorage2;
518
- const [openDrawer, setOpenDrawer] = useState3(false);
519
- const onToggleDrawer = useCallback3(() => {
537
+ const [openDrawer, setOpenDrawer] = useState4(false);
538
+ const onToggleDrawer = useCallback4(() => {
520
539
  setOpenDrawer((prev) => !prev);
521
540
  }, []);
522
- const onCloseDrawer = useCallback3(() => {
541
+ const onCloseDrawer = useCallback4(() => {
523
542
  setOpenDrawer(false);
524
543
  }, []);
525
544
  const memoizedValue = useMemo3(
@@ -555,20 +574,20 @@ var useSettings = () => {
555
574
  };
556
575
 
557
576
  // src/hooks/useSetState.ts
558
- import { useMemo as useMemo4, useState as useState4, useCallback as useCallback4 } from "react";
577
+ import { useMemo as useMemo4, useState as useState5, useCallback as useCallback5 } from "react";
559
578
  var useSetState = (initialState) => {
560
- const [state, set] = useState4(initialState);
579
+ const [state, set] = useState5(initialState);
561
580
  const canReset = !isEqual(state, initialState);
562
- const setState = useCallback4((updateState) => {
581
+ const setState = useCallback5((updateState) => {
563
582
  set((prevValue) => ({ ...prevValue, ...updateState }));
564
583
  }, []);
565
- const setField = useCallback4(
584
+ const setField = useCallback5(
566
585
  (name, updateValue) => {
567
586
  setState({ [name]: updateValue });
568
587
  },
569
588
  [setState]
570
589
  );
571
- const onResetState = useCallback4(() => {
590
+ const onResetState = useCallback5(() => {
572
591
  set(initialState);
573
592
  }, [initialState]);
574
593
  const memoizedValue = useMemo4(
@@ -644,11 +663,11 @@ var useEventListener = ({
644
663
  };
645
664
 
646
665
  // src/hooks/useCopyToClipboard.ts
647
- import { useMemo as useMemo6, useState as useState5, useCallback as useCallback5 } from "react";
666
+ import { useMemo as useMemo6, useState as useState6, useCallback as useCallback6 } from "react";
648
667
  var useCopyToClipboard = () => {
649
- const [copiedText, setCopiedText] = useState5("");
650
- const [isCopied, setIsCopied] = useState5(false);
651
- const copy = useCallback5(
668
+ const [copiedText, setCopiedText] = useState6("");
669
+ const [isCopied, setIsCopied] = useState6(false);
670
+ const copy = useCallback6(
652
671
  async (text2) => {
653
672
  if (!navigator?.clipboard) {
654
673
  console.warn("Clipboard not supported");
@@ -676,11 +695,11 @@ var useCopyToClipboard = () => {
676
695
  };
677
696
 
678
697
  // src/hooks/useScrollOffsetTop.ts
679
- import { useRef as useRef2, useMemo as useMemo7, useState as useState6, useEffect as useEffect3, useCallback as useCallback6 } from "react";
698
+ import { useRef as useRef2, useMemo as useMemo7, useState as useState7, useEffect as useEffect3, useCallback as useCallback7 } from "react";
680
699
  var useScrollOffSetTop = (top = 0) => {
681
700
  const elementRef = useRef2(null);
682
- const [offsetTop, setOffsetTop] = useState6(false);
683
- const handleScrollChange = useCallback6(() => {
701
+ const [offsetTop, setOffsetTop] = useState7(false);
702
+ const handleScrollChange = useCallback7(() => {
684
703
  const scrollHeight = Math.round(window.scrollY);
685
704
  if (elementRef?.current) {
686
705
  const rect = elementRef.current.getBoundingClientRect();
@@ -7174,6 +7193,7 @@ export {
7174
7193
  useCopyToClipboard,
7175
7194
  useEventListener,
7176
7195
  useLocalStorage,
7196
+ usePopover,
7177
7197
  useResponsive,
7178
7198
  useScrollOffSetTop,
7179
7199
  useSetState,