@undefine-ui/design-system 2.2.0 → 2.4.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
@@ -89,6 +89,23 @@ interface UseBooleanReturnType {
89
89
  onToggle: () => void;
90
90
  setValue: React.Dispatch<React.SetStateAction<boolean>>;
91
91
  }
92
+ /**
93
+ * Custom hook for managing boolean state with helper functions.
94
+ *
95
+ * @param {boolean} [defaultValue=false] - The initial boolean value
96
+ * @returns {UseBooleanReturnType} Object containing:
97
+ * - value: Current boolean state
98
+ * - onTrue: Function to set value to true
99
+ * - onFalse: Function to set value to false
100
+ * - onToggle: Function to toggle the value
101
+ * - setValue: Direct state setter
102
+ *
103
+ * @example
104
+ * const modal = useBoolean();
105
+ *
106
+ * <Button onClick={modal.onTrue}>Open Modal</Button>
107
+ * <Modal open={modal.value} onClose={modal.onFalse} />
108
+ */
92
109
  declare const useBoolean: (defaultValue?: boolean) => UseBooleanReturnType;
93
110
 
94
111
  declare const STORAGE_KEY = "app-settings";
@@ -118,14 +135,102 @@ interface SettingsProviderProps {
118
135
  }
119
136
  declare const SettingsProvider: ({ children, settings }: SettingsProviderProps) => react_jsx_runtime.JSX.Element;
120
137
 
138
+ /**
139
+ * Custom hook for accessing the design system settings context.
140
+ * Must be used within a SettingsProvider.
141
+ *
142
+ * @returns {SettingsContextValue} The settings context value containing:
143
+ * - Current theme settings (colorScheme, contrast, direction, etc.)
144
+ * - Functions to update settings (onUpdate, onUpdateField, onReset)
145
+ *
146
+ * @throws {Error} If used outside of SettingsProvider
147
+ *
148
+ * @example
149
+ * const { colorScheme, onUpdateField } = useSettings();
150
+ *
151
+ * <Button onClick={() => onUpdateField('colorScheme', 'dark')}>
152
+ * Toggle Dark Mode
153
+ * </Button>
154
+ */
121
155
  declare const useSettings: () => SettingsContextProps;
122
156
 
157
+ type UseSetStateReturnType<T> = {
158
+ state: T;
159
+ setState: (updateState: SetStateAction<T>) => void;
160
+ setField: (name: keyof T, updateValue: T[keyof T]) => void;
161
+ onResetState: () => void;
162
+ canReset: boolean;
163
+ };
164
+ /**
165
+ * Custom hook for managing complex object state with field-level updates.
166
+ * Similar to useState but optimized for objects with helper functions.
167
+ *
168
+ * @template T - The type of the state object (must be a record)
169
+ * @param {T} initialState - The initial state object
170
+ * @returns {UseSetStateReturnType<T>} Object containing:
171
+ * - state: Current state object
172
+ * - setState: Function to update state (merges with previous state)
173
+ * - setField: Function to update a single field
174
+ * - onResetState: Function to reset to initial state
175
+ * - canReset: Boolean indicating if state differs from initial
176
+ *
177
+ * @example
178
+ * const { state, setField, onResetState } = useSetState({ name: '', age: 0 });
179
+ *
180
+ * setField('name', 'John');
181
+ * setField('age', 25);
182
+ * onResetState();
183
+ */
184
+ declare const useSetState: <T extends Record<string, any>>(initialState: T) => UseSetStateReturnType<T>;
185
+
123
186
  type ReturnType = boolean;
124
187
  type Query = 'up' | 'down' | 'between' | 'only';
125
188
  type Value = Breakpoint | number;
189
+ /**
190
+ * Custom hook for responsive design with MUI breakpoints.
191
+ *
192
+ * @param {Query} query - The type of breakpoint query ('up' | 'down' | 'between' | 'only')
193
+ * @param {Value} [start] - The starting breakpoint or number
194
+ * @param {Value} [end] - The ending breakpoint (only used with 'between')
195
+ * @returns {boolean} True if the media query matches
196
+ *
197
+ * @example
198
+ * const isMobile = useResponsive('down', 'sm');
199
+ * const isDesktop = useResponsive('up', 'md');
200
+ * const isTablet = useResponsive('between', 'sm', 'md');
201
+ */
126
202
  declare const useResponsive: (query: Query, start?: Value, end?: Value) => ReturnType;
203
+ /**
204
+ * Custom hook that returns the current MUI breakpoint.
205
+ *
206
+ * @returns {Breakpoint} The current breakpoint ('xs' | 'sm' | 'md' | 'lg' | 'xl')
207
+ *
208
+ * @example
209
+ * const width = useWidth();
210
+ * // Returns 'xs', 'sm', 'md', 'lg', or 'xl' based on viewport
211
+ */
127
212
  declare const useWidth: () => "sm" | "md" | "lg" | "xs" | "xl" | "2xl";
128
213
 
214
+ /**
215
+ * Custom hook for managing state synchronized with localStorage.
216
+ * Supports both primitive values and objects with field-level updates.
217
+ *
218
+ * @template T - The type of the state value
219
+ * @param {string} key - The localStorage key
220
+ * @param {T} initialState - The initial state value
221
+ * @returns {Object} Object containing:
222
+ * - state: Current state value
223
+ * - setState: Function to update the entire state
224
+ * - setField: Function to update a single field (for objects)
225
+ * - resetState: Function to reset to initial state
226
+ * - canReset: Boolean indicating if state differs from initial
227
+ *
228
+ * @example
229
+ * const { state, setState, setField } = useLocalStorage('user', { name: '', age: 0 });
230
+ *
231
+ * setField('name', 'John');
232
+ * setState({ name: 'Jane', age: 25 });
233
+ */
129
234
  declare const useLocalStorage: <T>(key: string, initialState: T) => {
130
235
  state: T;
131
236
  setState: (updateState: SetStateAction<T>) => void;
@@ -133,10 +238,41 @@ declare const useLocalStorage: <T>(key: string, initialState: T) => {
133
238
  resetState: () => void;
134
239
  canReset: boolean;
135
240
  };
241
+ /**
242
+ * Retrieves a value from localStorage and parses it as JSON.
243
+ *
244
+ * @template T - The expected return type
245
+ * @param {string} key - The localStorage key
246
+ * @returns {T | null} The parsed value or null if not found or error occurs
247
+ */
136
248
  declare const getStorage: <T>(key: string) => T | null;
249
+ /**
250
+ * Stores a value in localStorage as JSON string.
251
+ *
252
+ * @template T - The type of value to store
253
+ * @param {string} key - The localStorage key
254
+ * @param {T} value - The value to store
255
+ */
137
256
  declare const setStorage: <T>(key: string, value: T) => void;
257
+ /**
258
+ * Removes a value from localStorage.
259
+ *
260
+ * @param {string} key - The localStorage key to remove
261
+ */
138
262
  declare const removeStorage: (key: string) => void;
263
+ /**
264
+ * Checks if localStorage is available in the current environment.
265
+ *
266
+ * @returns {boolean} True if localStorage is available, false otherwise
267
+ */
139
268
  declare const LocalStorageAvailable: () => boolean;
269
+ /**
270
+ * Gets an item from localStorage with fallback to default value.
271
+ *
272
+ * @param {string} key - The localStorage key
273
+ * @param {string} [defaultValue=''] - The default value if key doesn't exist
274
+ * @returns {string | undefined} The stored value or default value
275
+ */
140
276
  declare const LocalStorageGetItem: (key: string, defaultValue?: string) => string | undefined;
141
277
 
142
278
  type useEventListenerOptions = {
@@ -145,14 +281,69 @@ type useEventListenerOptions = {
145
281
  element?: React.RefObject<HTMLElement>;
146
282
  options?: AddEventListenerOptions;
147
283
  };
284
+ /**
285
+ * Custom hook for adding event listeners with automatic cleanup.
286
+ * Uses isomorphic layout effect for SSR compatibility.
287
+ *
288
+ * @param {Object} params - Hook parameters
289
+ * @param {string} params.eventName - The name of the event to listen for
290
+ * @param {Function} params.handler - The event handler function
291
+ * @param {React.RefObject<HTMLElement>} [params.element] - Optional element ref (defaults to window)
292
+ * @param {AddEventListenerOptions} [params.options] - Optional event listener options
293
+ *
294
+ * @example
295
+ * const ref = useRef<HTMLDivElement>(null);
296
+ *
297
+ * useEventListener({
298
+ * eventName: 'click',
299
+ * handler: (e) => console.log('Clicked!'),
300
+ * element: ref
301
+ * });
302
+ */
148
303
  declare const useEventListener: ({ eventName, handler, element, options }: useEventListenerOptions) => void;
149
304
 
305
+ /**
306
+ * Custom hook for copying text to clipboard with status tracking.
307
+ *
308
+ * @returns {Object} Object containing:
309
+ * - copy: Async function to copy text to clipboard
310
+ * - copiedText: The last successfully copied text
311
+ * - isCopied: Boolean indicating if text was recently copied (resets after 2s)
312
+ *
313
+ * @example
314
+ * const { copy, isCopied } = useCopyToClipboard();
315
+ *
316
+ * <Button onClick={() => copy('Hello World')}>
317
+ * {isCopied ? 'Copied!' : 'Copy'}
318
+ * </Button>
319
+ */
150
320
  declare const useCopyToClipboard: () => {
151
321
  copy: (text: string) => Promise<boolean>;
152
322
  copiedText: string;
153
323
  isCopied: boolean;
154
324
  };
155
325
 
326
+ /**
327
+ * Custom hook for tracking if an element or window has scrolled past a threshold.
328
+ *
329
+ * @param {number} [top=0] - The threshold in pixels
330
+ * @returns {Object} Object containing:
331
+ * - elementRef: Ref to attach to an element for element-specific tracking
332
+ * - offsetTop: Boolean indicating if scrolled past threshold
333
+ *
334
+ * @example
335
+ * // Track global scroll position
336
+ * const { offsetTop } = useScrollOffSetTop(80);
337
+ *
338
+ * // Track specific element position
339
+ * const { offsetTop, elementRef } = useScrollOffSetTop(80);
340
+ * <div ref={elementRef}>Content</div>
341
+ */
342
+ declare const useScrollOffSetTop: (top?: number) => {
343
+ elementRef: React.RefObject<HTMLElement | null>;
344
+ offsetTop: boolean;
345
+ };
346
+
156
347
  interface RadiusOptions {
157
348
  'radius-0': string;
158
349
  'radius-2xs': string;
@@ -1552,4 +1743,4 @@ interface LoadingScreenProps extends BoxProps {
1552
1743
  declare const LoadingScreen: ({ portal, sx, ...rest }: LoadingScreenProps) => react_jsx_runtime.JSX.Element;
1553
1744
  declare const SplashScreen: ({ portal, sx, ...rest }: LoadingScreenProps) => react_jsx_runtime.JSX.Element;
1554
1745
 
1555
- export { AnimatedLogo, CheckboxDefault, CheckboxIndeterminate, CheckboxSelect, ClipboardCheck, CloudUpload, type ColorSchema, Copy, CopyButton, type CustomShadowOptions, type CustomSpacingOptions, Eye, EyeClosed, Field, Form, Icon, type IconProps, type IconType, InfoCircleFill, InfoCircleOutline, 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, SettingsConsumer, SettingsContext, type SettingsContextProps, SettingsProvider, type SettingsValueProps, SplashScreen, Table, type TableNoRowsProps, TablePagination, ThemeProvider, Trash, Upload, type UploadProps, type UseBooleanReturnType, 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, useSettings, useWidth, varAlpha, warning };
1746
+ export { AnimatedLogo, CheckboxDefault, CheckboxIndeterminate, CheckboxSelect, ClipboardCheck, CloudUpload, type ColorSchema, Copy, CopyButton, type CustomShadowOptions, type CustomSpacingOptions, Eye, EyeClosed, Field, Form, Icon, type IconProps, type IconType, InfoCircleFill, InfoCircleOutline, 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, 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 };
package/dist/index.d.ts CHANGED
@@ -89,6 +89,23 @@ interface UseBooleanReturnType {
89
89
  onToggle: () => void;
90
90
  setValue: React.Dispatch<React.SetStateAction<boolean>>;
91
91
  }
92
+ /**
93
+ * Custom hook for managing boolean state with helper functions.
94
+ *
95
+ * @param {boolean} [defaultValue=false] - The initial boolean value
96
+ * @returns {UseBooleanReturnType} Object containing:
97
+ * - value: Current boolean state
98
+ * - onTrue: Function to set value to true
99
+ * - onFalse: Function to set value to false
100
+ * - onToggle: Function to toggle the value
101
+ * - setValue: Direct state setter
102
+ *
103
+ * @example
104
+ * const modal = useBoolean();
105
+ *
106
+ * <Button onClick={modal.onTrue}>Open Modal</Button>
107
+ * <Modal open={modal.value} onClose={modal.onFalse} />
108
+ */
92
109
  declare const useBoolean: (defaultValue?: boolean) => UseBooleanReturnType;
93
110
 
94
111
  declare const STORAGE_KEY = "app-settings";
@@ -118,14 +135,102 @@ interface SettingsProviderProps {
118
135
  }
119
136
  declare const SettingsProvider: ({ children, settings }: SettingsProviderProps) => react_jsx_runtime.JSX.Element;
120
137
 
138
+ /**
139
+ * Custom hook for accessing the design system settings context.
140
+ * Must be used within a SettingsProvider.
141
+ *
142
+ * @returns {SettingsContextValue} The settings context value containing:
143
+ * - Current theme settings (colorScheme, contrast, direction, etc.)
144
+ * - Functions to update settings (onUpdate, onUpdateField, onReset)
145
+ *
146
+ * @throws {Error} If used outside of SettingsProvider
147
+ *
148
+ * @example
149
+ * const { colorScheme, onUpdateField } = useSettings();
150
+ *
151
+ * <Button onClick={() => onUpdateField('colorScheme', 'dark')}>
152
+ * Toggle Dark Mode
153
+ * </Button>
154
+ */
121
155
  declare const useSettings: () => SettingsContextProps;
122
156
 
157
+ type UseSetStateReturnType<T> = {
158
+ state: T;
159
+ setState: (updateState: SetStateAction<T>) => void;
160
+ setField: (name: keyof T, updateValue: T[keyof T]) => void;
161
+ onResetState: () => void;
162
+ canReset: boolean;
163
+ };
164
+ /**
165
+ * Custom hook for managing complex object state with field-level updates.
166
+ * Similar to useState but optimized for objects with helper functions.
167
+ *
168
+ * @template T - The type of the state object (must be a record)
169
+ * @param {T} initialState - The initial state object
170
+ * @returns {UseSetStateReturnType<T>} Object containing:
171
+ * - state: Current state object
172
+ * - setState: Function to update state (merges with previous state)
173
+ * - setField: Function to update a single field
174
+ * - onResetState: Function to reset to initial state
175
+ * - canReset: Boolean indicating if state differs from initial
176
+ *
177
+ * @example
178
+ * const { state, setField, onResetState } = useSetState({ name: '', age: 0 });
179
+ *
180
+ * setField('name', 'John');
181
+ * setField('age', 25);
182
+ * onResetState();
183
+ */
184
+ declare const useSetState: <T extends Record<string, any>>(initialState: T) => UseSetStateReturnType<T>;
185
+
123
186
  type ReturnType = boolean;
124
187
  type Query = 'up' | 'down' | 'between' | 'only';
125
188
  type Value = Breakpoint | number;
189
+ /**
190
+ * Custom hook for responsive design with MUI breakpoints.
191
+ *
192
+ * @param {Query} query - The type of breakpoint query ('up' | 'down' | 'between' | 'only')
193
+ * @param {Value} [start] - The starting breakpoint or number
194
+ * @param {Value} [end] - The ending breakpoint (only used with 'between')
195
+ * @returns {boolean} True if the media query matches
196
+ *
197
+ * @example
198
+ * const isMobile = useResponsive('down', 'sm');
199
+ * const isDesktop = useResponsive('up', 'md');
200
+ * const isTablet = useResponsive('between', 'sm', 'md');
201
+ */
126
202
  declare const useResponsive: (query: Query, start?: Value, end?: Value) => ReturnType;
203
+ /**
204
+ * Custom hook that returns the current MUI breakpoint.
205
+ *
206
+ * @returns {Breakpoint} The current breakpoint ('xs' | 'sm' | 'md' | 'lg' | 'xl')
207
+ *
208
+ * @example
209
+ * const width = useWidth();
210
+ * // Returns 'xs', 'sm', 'md', 'lg', or 'xl' based on viewport
211
+ */
127
212
  declare const useWidth: () => "sm" | "md" | "lg" | "xs" | "xl" | "2xl";
128
213
 
214
+ /**
215
+ * Custom hook for managing state synchronized with localStorage.
216
+ * Supports both primitive values and objects with field-level updates.
217
+ *
218
+ * @template T - The type of the state value
219
+ * @param {string} key - The localStorage key
220
+ * @param {T} initialState - The initial state value
221
+ * @returns {Object} Object containing:
222
+ * - state: Current state value
223
+ * - setState: Function to update the entire state
224
+ * - setField: Function to update a single field (for objects)
225
+ * - resetState: Function to reset to initial state
226
+ * - canReset: Boolean indicating if state differs from initial
227
+ *
228
+ * @example
229
+ * const { state, setState, setField } = useLocalStorage('user', { name: '', age: 0 });
230
+ *
231
+ * setField('name', 'John');
232
+ * setState({ name: 'Jane', age: 25 });
233
+ */
129
234
  declare const useLocalStorage: <T>(key: string, initialState: T) => {
130
235
  state: T;
131
236
  setState: (updateState: SetStateAction<T>) => void;
@@ -133,10 +238,41 @@ declare const useLocalStorage: <T>(key: string, initialState: T) => {
133
238
  resetState: () => void;
134
239
  canReset: boolean;
135
240
  };
241
+ /**
242
+ * Retrieves a value from localStorage and parses it as JSON.
243
+ *
244
+ * @template T - The expected return type
245
+ * @param {string} key - The localStorage key
246
+ * @returns {T | null} The parsed value or null if not found or error occurs
247
+ */
136
248
  declare const getStorage: <T>(key: string) => T | null;
249
+ /**
250
+ * Stores a value in localStorage as JSON string.
251
+ *
252
+ * @template T - The type of value to store
253
+ * @param {string} key - The localStorage key
254
+ * @param {T} value - The value to store
255
+ */
137
256
  declare const setStorage: <T>(key: string, value: T) => void;
257
+ /**
258
+ * Removes a value from localStorage.
259
+ *
260
+ * @param {string} key - The localStorage key to remove
261
+ */
138
262
  declare const removeStorage: (key: string) => void;
263
+ /**
264
+ * Checks if localStorage is available in the current environment.
265
+ *
266
+ * @returns {boolean} True if localStorage is available, false otherwise
267
+ */
139
268
  declare const LocalStorageAvailable: () => boolean;
269
+ /**
270
+ * Gets an item from localStorage with fallback to default value.
271
+ *
272
+ * @param {string} key - The localStorage key
273
+ * @param {string} [defaultValue=''] - The default value if key doesn't exist
274
+ * @returns {string | undefined} The stored value or default value
275
+ */
140
276
  declare const LocalStorageGetItem: (key: string, defaultValue?: string) => string | undefined;
141
277
 
142
278
  type useEventListenerOptions = {
@@ -145,14 +281,69 @@ type useEventListenerOptions = {
145
281
  element?: React.RefObject<HTMLElement>;
146
282
  options?: AddEventListenerOptions;
147
283
  };
284
+ /**
285
+ * Custom hook for adding event listeners with automatic cleanup.
286
+ * Uses isomorphic layout effect for SSR compatibility.
287
+ *
288
+ * @param {Object} params - Hook parameters
289
+ * @param {string} params.eventName - The name of the event to listen for
290
+ * @param {Function} params.handler - The event handler function
291
+ * @param {React.RefObject<HTMLElement>} [params.element] - Optional element ref (defaults to window)
292
+ * @param {AddEventListenerOptions} [params.options] - Optional event listener options
293
+ *
294
+ * @example
295
+ * const ref = useRef<HTMLDivElement>(null);
296
+ *
297
+ * useEventListener({
298
+ * eventName: 'click',
299
+ * handler: (e) => console.log('Clicked!'),
300
+ * element: ref
301
+ * });
302
+ */
148
303
  declare const useEventListener: ({ eventName, handler, element, options }: useEventListenerOptions) => void;
149
304
 
305
+ /**
306
+ * Custom hook for copying text to clipboard with status tracking.
307
+ *
308
+ * @returns {Object} Object containing:
309
+ * - copy: Async function to copy text to clipboard
310
+ * - copiedText: The last successfully copied text
311
+ * - isCopied: Boolean indicating if text was recently copied (resets after 2s)
312
+ *
313
+ * @example
314
+ * const { copy, isCopied } = useCopyToClipboard();
315
+ *
316
+ * <Button onClick={() => copy('Hello World')}>
317
+ * {isCopied ? 'Copied!' : 'Copy'}
318
+ * </Button>
319
+ */
150
320
  declare const useCopyToClipboard: () => {
151
321
  copy: (text: string) => Promise<boolean>;
152
322
  copiedText: string;
153
323
  isCopied: boolean;
154
324
  };
155
325
 
326
+ /**
327
+ * Custom hook for tracking if an element or window has scrolled past a threshold.
328
+ *
329
+ * @param {number} [top=0] - The threshold in pixels
330
+ * @returns {Object} Object containing:
331
+ * - elementRef: Ref to attach to an element for element-specific tracking
332
+ * - offsetTop: Boolean indicating if scrolled past threshold
333
+ *
334
+ * @example
335
+ * // Track global scroll position
336
+ * const { offsetTop } = useScrollOffSetTop(80);
337
+ *
338
+ * // Track specific element position
339
+ * const { offsetTop, elementRef } = useScrollOffSetTop(80);
340
+ * <div ref={elementRef}>Content</div>
341
+ */
342
+ declare const useScrollOffSetTop: (top?: number) => {
343
+ elementRef: React.RefObject<HTMLElement | null>;
344
+ offsetTop: boolean;
345
+ };
346
+
156
347
  interface RadiusOptions {
157
348
  'radius-0': string;
158
349
  'radius-2xs': string;
@@ -1552,4 +1743,4 @@ interface LoadingScreenProps extends BoxProps {
1552
1743
  declare const LoadingScreen: ({ portal, sx, ...rest }: LoadingScreenProps) => react_jsx_runtime.JSX.Element;
1553
1744
  declare const SplashScreen: ({ portal, sx, ...rest }: LoadingScreenProps) => react_jsx_runtime.JSX.Element;
1554
1745
 
1555
- export { AnimatedLogo, CheckboxDefault, CheckboxIndeterminate, CheckboxSelect, ClipboardCheck, CloudUpload, type ColorSchema, Copy, CopyButton, type CustomShadowOptions, type CustomSpacingOptions, Eye, EyeClosed, Field, Form, Icon, type IconProps, type IconType, InfoCircleFill, InfoCircleOutline, 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, SettingsConsumer, SettingsContext, type SettingsContextProps, SettingsProvider, type SettingsValueProps, SplashScreen, Table, type TableNoRowsProps, TablePagination, ThemeProvider, Trash, Upload, type UploadProps, type UseBooleanReturnType, 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, useSettings, useWidth, varAlpha, warning };
1746
+ export { AnimatedLogo, CheckboxDefault, CheckboxIndeterminate, CheckboxSelect, ClipboardCheck, CloudUpload, type ColorSchema, Copy, CopyButton, type CustomShadowOptions, type CustomSpacingOptions, Eye, EyeClosed, Field, Form, Icon, type IconProps, type IconType, InfoCircleFill, InfoCircleOutline, 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, 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 };
package/dist/index.js CHANGED
@@ -554,13 +554,43 @@ var useSettings = () => {
554
554
  return context;
555
555
  };
556
556
 
557
+ // src/hooks/useSetState.ts
558
+ import { useMemo as useMemo4, useState as useState4, useCallback as useCallback4 } from "react";
559
+ var useSetState = (initialState) => {
560
+ const [state, set] = useState4(initialState);
561
+ const canReset = !isEqual(state, initialState);
562
+ const setState = useCallback4((updateState) => {
563
+ set((prevValue) => ({ ...prevValue, ...updateState }));
564
+ }, []);
565
+ const setField = useCallback4(
566
+ (name, updateValue) => {
567
+ setState({ [name]: updateValue });
568
+ },
569
+ [setState]
570
+ );
571
+ const onResetState = useCallback4(() => {
572
+ set(initialState);
573
+ }, [initialState]);
574
+ const memoizedValue = useMemo4(
575
+ () => ({
576
+ state,
577
+ setState,
578
+ setField,
579
+ onResetState,
580
+ canReset
581
+ }),
582
+ [canReset, onResetState, setField, setState, state]
583
+ );
584
+ return memoizedValue;
585
+ };
586
+
557
587
  // src/hooks/useResponsive.ts
558
- import { useMemo as useMemo4 } from "react";
588
+ import { useMemo as useMemo5 } from "react";
559
589
  import useMediaQuery from "@mui/material/useMediaQuery";
560
590
  import { useTheme } from "@mui/material/styles";
561
591
  var useResponsive = (query, start, end) => {
562
592
  const theme = useTheme();
563
- const getQuery = useMemo4(() => {
593
+ const getQuery = useMemo5(() => {
564
594
  switch (query) {
565
595
  case "up":
566
596
  return theme.breakpoints.up(start);
@@ -579,7 +609,7 @@ var useResponsive = (query, start, end) => {
579
609
  };
580
610
  var useWidth = () => {
581
611
  const theme = useTheme();
582
- const keys = useMemo4(() => [...theme.breakpoints.keys].reverse(), [theme]);
612
+ const keys = useMemo5(() => [...theme.breakpoints.keys].reverse(), [theme]);
583
613
  const width = keys.reduce((output, key) => {
584
614
  const matches = useMediaQuery(theme.breakpoints.up(key));
585
615
  return !output && matches ? key : output;
@@ -614,11 +644,11 @@ var useEventListener = ({
614
644
  };
615
645
 
616
646
  // src/hooks/useCopyToClipboard.ts
617
- import { useMemo as useMemo5, useState as useState4, useCallback as useCallback4 } from "react";
647
+ import { useMemo as useMemo6, useState as useState5, useCallback as useCallback5 } from "react";
618
648
  var useCopyToClipboard = () => {
619
- const [copiedText, setCopiedText] = useState4("");
620
- const [isCopied, setIsCopied] = useState4(false);
621
- const copy = useCallback4(
649
+ const [copiedText, setCopiedText] = useState5("");
650
+ const [isCopied, setIsCopied] = useState5(false);
651
+ const copy = useCallback5(
622
652
  async (text2) => {
623
653
  if (!navigator?.clipboard) {
624
654
  console.warn("Clipboard not supported");
@@ -638,13 +668,39 @@ var useCopyToClipboard = () => {
638
668
  },
639
669
  [setCopiedText]
640
670
  );
641
- const memoizedValue = useMemo5(
671
+ const memoizedValue = useMemo6(
642
672
  () => ({ copy, copiedText, isCopied }),
643
673
  [copy, copiedText, isCopied]
644
674
  );
645
675
  return memoizedValue;
646
676
  };
647
677
 
678
+ // src/hooks/useScrollOffsetTop.ts
679
+ import { useRef as useRef2, useMemo as useMemo7, useState as useState6, useEffect as useEffect3, useCallback as useCallback6 } from "react";
680
+ var useScrollOffSetTop = (top = 0) => {
681
+ const elementRef = useRef2(null);
682
+ const [offsetTop, setOffsetTop] = useState6(false);
683
+ const handleScrollChange = useCallback6(() => {
684
+ const scrollHeight = Math.round(window.scrollY);
685
+ if (elementRef?.current) {
686
+ const rect = elementRef.current.getBoundingClientRect();
687
+ const elementTop = Math.round(rect.top);
688
+ setOffsetTop(elementTop < top);
689
+ } else {
690
+ setOffsetTop(scrollHeight > top);
691
+ }
692
+ }, [top]);
693
+ useEffect3(() => {
694
+ handleScrollChange();
695
+ window.addEventListener("scroll", handleScrollChange, { passive: true });
696
+ return () => {
697
+ window.removeEventListener("scroll", handleScrollChange);
698
+ };
699
+ }, [handleScrollChange]);
700
+ const memoizedValue = useMemo7(() => ({ elementRef, offsetTop }), [offsetTop]);
701
+ return memoizedValue;
702
+ };
703
+
648
704
  // src/theme/core/radius.ts
649
705
  function radius(baseRadius) {
650
706
  return {
@@ -5927,7 +5983,7 @@ var UploadProgress = ({ progress: progress2 = 20 }) => {
5927
5983
  };
5928
5984
 
5929
5985
  // src/components/Upload/components/MultiFilePreview.tsx
5930
- import { useRef as useRef2 } from "react";
5986
+ import { useRef as useRef3 } from "react";
5931
5987
  import Box9 from "@mui/material/Box";
5932
5988
  import IconButton2 from "@mui/material/IconButton";
5933
5989
 
@@ -5995,7 +6051,7 @@ var DeleteButton = ({ sx, ...rest }) => {
5995
6051
  // src/components/Upload/components/MultiFilePreview.tsx
5996
6052
  import { jsx as jsx45, jsxs as jsxs24 } from "react/jsx-runtime";
5997
6053
  var MultiFilePreview = ({ files, onRemove }) => {
5998
- const scrollRef = useRef2(null);
6054
+ const scrollRef = useRef3(null);
5999
6055
  const handleScroll = (direction) => {
6000
6056
  if (scrollRef.current) {
6001
6057
  const scrollAmount = 300;
@@ -6967,6 +7023,8 @@ export {
6967
7023
  useEventListener,
6968
7024
  useLocalStorage,
6969
7025
  useResponsive,
7026
+ useScrollOffSetTop,
7027
+ useSetState,
6970
7028
  useSettings,
6971
7029
  useWidth,
6972
7030
  varAlpha,