@undefine-ui/design-system 2.11.0 → 2.12.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/README.md +7 -7
- package/dist/index.cjs +103 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +110 -1
- package/dist/index.d.ts +110 -1
- package/dist/index.js +96 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -234,6 +234,115 @@ type UseSetStateReturnType<T> = {
|
|
|
234
234
|
*/
|
|
235
235
|
declare const useSetState: <T extends Record<string, any>>(initialState: T) => UseSetStateReturnType<T>;
|
|
236
236
|
|
|
237
|
+
interface CountdownState {
|
|
238
|
+
days: string;
|
|
239
|
+
hours: string;
|
|
240
|
+
minutes: string;
|
|
241
|
+
seconds: string;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* A custom hook for creating a countdown timer to a specific date/time.
|
|
245
|
+
*
|
|
246
|
+
* Calculates and returns the time remaining until a target date, automatically
|
|
247
|
+
* updating every second. Returns zero values when the target time is reached.
|
|
248
|
+
*
|
|
249
|
+
* @param date - The target date/time as a Date object, ISO string, or Unix timestamp
|
|
250
|
+
*
|
|
251
|
+
* @returns An object containing:
|
|
252
|
+
* - `days` (string): Days remaining, zero-padded (e.g., "00", "05", "12")
|
|
253
|
+
* - `hours` (string): Hours remaining, zero-padded (e.g., "00", "23")
|
|
254
|
+
* - `minutes` (string): Minutes remaining, zero-padded (e.g., "00", "59")
|
|
255
|
+
* - `seconds` (string): Seconds remaining, zero-padded (e.g., "00", "59")
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* ```tsx
|
|
259
|
+
* function EventCountdown() {
|
|
260
|
+
* const countdown = useCountdownDate(new Date('2025-12-31T23:59:59'));
|
|
261
|
+
*
|
|
262
|
+
* return (
|
|
263
|
+
* <div>
|
|
264
|
+
* <h2>Time Until New Year:</h2>
|
|
265
|
+
* <p>
|
|
266
|
+
* {countdown.days} days, {countdown.hours} hours,
|
|
267
|
+
* {countdown.minutes} minutes, {countdown.seconds} seconds
|
|
268
|
+
* </p>
|
|
269
|
+
* </div>
|
|
270
|
+
* );
|
|
271
|
+
* }
|
|
272
|
+
* ```
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```tsx
|
|
276
|
+
* // Using Unix timestamp
|
|
277
|
+
* const countdown = useCountdownDate(1735689599000);
|
|
278
|
+
*
|
|
279
|
+
* // Using ISO string
|
|
280
|
+
* const countdown = useCountdownDate('2025-12-31T23:59:59Z');
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
declare const useCountdownDate: (date: Date | string | number) => CountdownState;
|
|
284
|
+
interface UseCountdownSecondsReturn {
|
|
285
|
+
counting: boolean;
|
|
286
|
+
countdown: number;
|
|
287
|
+
startCountdown: () => void;
|
|
288
|
+
setCountdown: React.Dispatch<React.SetStateAction<number>>;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* A custom hook for creating a countdown timer that counts down from a specified number of seconds.
|
|
292
|
+
*
|
|
293
|
+
* Provides manual control to start the countdown and tracks whether counting is in progress.
|
|
294
|
+
* Automatically cleans up intervals on unmount.
|
|
295
|
+
*
|
|
296
|
+
* @param initCountdown - Initial number of seconds for the countdown
|
|
297
|
+
*
|
|
298
|
+
* @returns An object containing:
|
|
299
|
+
* - `counting` (boolean): Whether countdown is actively running (between 0 and initCountdown)
|
|
300
|
+
* - `countdown` (number): Current countdown value in seconds
|
|
301
|
+
* - `startCountdown` (function): Function to start or restart the countdown
|
|
302
|
+
* - `setCountdown` (function): Direct setter for the countdown value
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
* ```tsx
|
|
306
|
+
* function OTPTimer() {
|
|
307
|
+
* const { countdown, counting, startCountdown } = useCountdownSeconds(60);
|
|
308
|
+
*
|
|
309
|
+
* return (
|
|
310
|
+
* <div>
|
|
311
|
+
* <p>Resend code in: {countdown}s</p>
|
|
312
|
+
* <button onClick={startCountdown} disabled={counting}>
|
|
313
|
+
* {counting ? 'Waiting...' : 'Resend Code'}
|
|
314
|
+
* </button>
|
|
315
|
+
* </div>
|
|
316
|
+
* );
|
|
317
|
+
* }
|
|
318
|
+
* ```
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* ```tsx
|
|
322
|
+
* function SessionTimer() {
|
|
323
|
+
* const { countdown, counting, startCountdown, setCountdown } = useCountdownSeconds(300);
|
|
324
|
+
*
|
|
325
|
+
* useEffect(() => {
|
|
326
|
+
* // Start countdown when component mounts
|
|
327
|
+
* startCountdown();
|
|
328
|
+
* }, [startCountdown]);
|
|
329
|
+
*
|
|
330
|
+
* const extendSession = () => {
|
|
331
|
+
* // Add 60 more seconds
|
|
332
|
+
* setCountdown((prev) => prev + 60);
|
|
333
|
+
* };
|
|
334
|
+
*
|
|
335
|
+
* return (
|
|
336
|
+
* <div>
|
|
337
|
+
* <p>Session expires in: {Math.floor(countdown / 60)}:{countdown % 60}</p>
|
|
338
|
+
* <button onClick={extendSession}>Extend Session</button>
|
|
339
|
+
* </div>
|
|
340
|
+
* );
|
|
341
|
+
* }
|
|
342
|
+
* ```
|
|
343
|
+
*/
|
|
344
|
+
declare const useCountdownSeconds: (initCountdown: number) => UseCountdownSecondsReturn;
|
|
345
|
+
|
|
237
346
|
type ReturnType = boolean;
|
|
238
347
|
type Query = 'up' | 'down' | 'between' | 'only';
|
|
239
348
|
type Value = Breakpoint | number;
|
|
@@ -1817,4 +1926,4 @@ interface LoadingScreenProps extends BoxProps {
|
|
|
1817
1926
|
declare const LoadingScreen: ({ portal, sx, ...rest }: LoadingScreenProps) => react_jsx_runtime.JSX.Element;
|
|
1818
1927
|
declare const SplashScreen: ({ portal, sx, ...rest }: LoadingScreenProps) => react_jsx_runtime.JSX.Element;
|
|
1819
1928
|
|
|
1820
|
-
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, OTPInput, type OTPInputProps, RHFAutocomplete, type RHFAutocompleteProps, RHFCheckbox, type RHFCheckboxProps, RHFMultiCheckbox, type RHFMultiCheckboxOption, type RHFMultiCheckboxProps, RHFMultiSwitch, RHFOTPInput, type RHFOTPInputProps, 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, formatFullname, getCurrencySymbol, getInitColorSchemeScript, getInitials, 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, splitFullname, stylesMode, success, surface, tertiaryFont, text, textGradient, typography, updateComponentsWithSettings, updateCoreWithSettings, useBoolean, useCopyToClipboard, useEventListener, useLocalStorage, usePopover, useResponsive, useScrollOffSetTop, useSetState, useSettings, useWidth, varAlpha, warning };
|
|
1929
|
+
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, OTPInput, type OTPInputProps, RHFAutocomplete, type RHFAutocompleteProps, RHFCheckbox, type RHFCheckboxProps, RHFMultiCheckbox, type RHFMultiCheckboxOption, type RHFMultiCheckboxProps, RHFMultiSwitch, RHFOTPInput, type RHFOTPInputProps, 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, formatFullname, getCurrencySymbol, getInitColorSchemeScript, getInitials, 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, splitFullname, stylesMode, success, surface, tertiaryFont, text, textGradient, typography, updateComponentsWithSettings, updateCoreWithSettings, useBoolean, useCopyToClipboard, useCountdownDate, useCountdownSeconds, useEventListener, useLocalStorage, usePopover, useResponsive, useScrollOffSetTop, useSetState, useSettings, useWidth, varAlpha, warning };
|
package/dist/index.d.ts
CHANGED
|
@@ -234,6 +234,115 @@ type UseSetStateReturnType<T> = {
|
|
|
234
234
|
*/
|
|
235
235
|
declare const useSetState: <T extends Record<string, any>>(initialState: T) => UseSetStateReturnType<T>;
|
|
236
236
|
|
|
237
|
+
interface CountdownState {
|
|
238
|
+
days: string;
|
|
239
|
+
hours: string;
|
|
240
|
+
minutes: string;
|
|
241
|
+
seconds: string;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* A custom hook for creating a countdown timer to a specific date/time.
|
|
245
|
+
*
|
|
246
|
+
* Calculates and returns the time remaining until a target date, automatically
|
|
247
|
+
* updating every second. Returns zero values when the target time is reached.
|
|
248
|
+
*
|
|
249
|
+
* @param date - The target date/time as a Date object, ISO string, or Unix timestamp
|
|
250
|
+
*
|
|
251
|
+
* @returns An object containing:
|
|
252
|
+
* - `days` (string): Days remaining, zero-padded (e.g., "00", "05", "12")
|
|
253
|
+
* - `hours` (string): Hours remaining, zero-padded (e.g., "00", "23")
|
|
254
|
+
* - `minutes` (string): Minutes remaining, zero-padded (e.g., "00", "59")
|
|
255
|
+
* - `seconds` (string): Seconds remaining, zero-padded (e.g., "00", "59")
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* ```tsx
|
|
259
|
+
* function EventCountdown() {
|
|
260
|
+
* const countdown = useCountdownDate(new Date('2025-12-31T23:59:59'));
|
|
261
|
+
*
|
|
262
|
+
* return (
|
|
263
|
+
* <div>
|
|
264
|
+
* <h2>Time Until New Year:</h2>
|
|
265
|
+
* <p>
|
|
266
|
+
* {countdown.days} days, {countdown.hours} hours,
|
|
267
|
+
* {countdown.minutes} minutes, {countdown.seconds} seconds
|
|
268
|
+
* </p>
|
|
269
|
+
* </div>
|
|
270
|
+
* );
|
|
271
|
+
* }
|
|
272
|
+
* ```
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```tsx
|
|
276
|
+
* // Using Unix timestamp
|
|
277
|
+
* const countdown = useCountdownDate(1735689599000);
|
|
278
|
+
*
|
|
279
|
+
* // Using ISO string
|
|
280
|
+
* const countdown = useCountdownDate('2025-12-31T23:59:59Z');
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
declare const useCountdownDate: (date: Date | string | number) => CountdownState;
|
|
284
|
+
interface UseCountdownSecondsReturn {
|
|
285
|
+
counting: boolean;
|
|
286
|
+
countdown: number;
|
|
287
|
+
startCountdown: () => void;
|
|
288
|
+
setCountdown: React.Dispatch<React.SetStateAction<number>>;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* A custom hook for creating a countdown timer that counts down from a specified number of seconds.
|
|
292
|
+
*
|
|
293
|
+
* Provides manual control to start the countdown and tracks whether counting is in progress.
|
|
294
|
+
* Automatically cleans up intervals on unmount.
|
|
295
|
+
*
|
|
296
|
+
* @param initCountdown - Initial number of seconds for the countdown
|
|
297
|
+
*
|
|
298
|
+
* @returns An object containing:
|
|
299
|
+
* - `counting` (boolean): Whether countdown is actively running (between 0 and initCountdown)
|
|
300
|
+
* - `countdown` (number): Current countdown value in seconds
|
|
301
|
+
* - `startCountdown` (function): Function to start or restart the countdown
|
|
302
|
+
* - `setCountdown` (function): Direct setter for the countdown value
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
* ```tsx
|
|
306
|
+
* function OTPTimer() {
|
|
307
|
+
* const { countdown, counting, startCountdown } = useCountdownSeconds(60);
|
|
308
|
+
*
|
|
309
|
+
* return (
|
|
310
|
+
* <div>
|
|
311
|
+
* <p>Resend code in: {countdown}s</p>
|
|
312
|
+
* <button onClick={startCountdown} disabled={counting}>
|
|
313
|
+
* {counting ? 'Waiting...' : 'Resend Code'}
|
|
314
|
+
* </button>
|
|
315
|
+
* </div>
|
|
316
|
+
* );
|
|
317
|
+
* }
|
|
318
|
+
* ```
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* ```tsx
|
|
322
|
+
* function SessionTimer() {
|
|
323
|
+
* const { countdown, counting, startCountdown, setCountdown } = useCountdownSeconds(300);
|
|
324
|
+
*
|
|
325
|
+
* useEffect(() => {
|
|
326
|
+
* // Start countdown when component mounts
|
|
327
|
+
* startCountdown();
|
|
328
|
+
* }, [startCountdown]);
|
|
329
|
+
*
|
|
330
|
+
* const extendSession = () => {
|
|
331
|
+
* // Add 60 more seconds
|
|
332
|
+
* setCountdown((prev) => prev + 60);
|
|
333
|
+
* };
|
|
334
|
+
*
|
|
335
|
+
* return (
|
|
336
|
+
* <div>
|
|
337
|
+
* <p>Session expires in: {Math.floor(countdown / 60)}:{countdown % 60}</p>
|
|
338
|
+
* <button onClick={extendSession}>Extend Session</button>
|
|
339
|
+
* </div>
|
|
340
|
+
* );
|
|
341
|
+
* }
|
|
342
|
+
* ```
|
|
343
|
+
*/
|
|
344
|
+
declare const useCountdownSeconds: (initCountdown: number) => UseCountdownSecondsReturn;
|
|
345
|
+
|
|
237
346
|
type ReturnType = boolean;
|
|
238
347
|
type Query = 'up' | 'down' | 'between' | 'only';
|
|
239
348
|
type Value = Breakpoint | number;
|
|
@@ -1817,4 +1926,4 @@ interface LoadingScreenProps extends BoxProps {
|
|
|
1817
1926
|
declare const LoadingScreen: ({ portal, sx, ...rest }: LoadingScreenProps) => react_jsx_runtime.JSX.Element;
|
|
1818
1927
|
declare const SplashScreen: ({ portal, sx, ...rest }: LoadingScreenProps) => react_jsx_runtime.JSX.Element;
|
|
1819
1928
|
|
|
1820
|
-
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, OTPInput, type OTPInputProps, RHFAutocomplete, type RHFAutocompleteProps, RHFCheckbox, type RHFCheckboxProps, RHFMultiCheckbox, type RHFMultiCheckboxOption, type RHFMultiCheckboxProps, RHFMultiSwitch, RHFOTPInput, type RHFOTPInputProps, 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, formatFullname, getCurrencySymbol, getInitColorSchemeScript, getInitials, 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, splitFullname, stylesMode, success, surface, tertiaryFont, text, textGradient, typography, updateComponentsWithSettings, updateCoreWithSettings, useBoolean, useCopyToClipboard, useEventListener, useLocalStorage, usePopover, useResponsive, useScrollOffSetTop, useSetState, useSettings, useWidth, varAlpha, warning };
|
|
1929
|
+
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, OTPInput, type OTPInputProps, RHFAutocomplete, type RHFAutocompleteProps, RHFCheckbox, type RHFCheckboxProps, RHFMultiCheckbox, type RHFMultiCheckboxOption, type RHFMultiCheckboxProps, RHFMultiSwitch, RHFOTPInput, type RHFOTPInputProps, 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, formatFullname, getCurrencySymbol, getInitColorSchemeScript, getInitials, 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, splitFullname, stylesMode, success, surface, tertiaryFont, text, textGradient, typography, updateComponentsWithSettings, updateCoreWithSettings, useBoolean, useCopyToClipboard, useCountdownDate, useCountdownSeconds, useEventListener, useLocalStorage, usePopover, useResponsive, useScrollOffSetTop, useSetState, useSettings, useWidth, varAlpha, warning };
|
package/dist/index.js
CHANGED
|
@@ -622,6 +622,82 @@ var useSetState = (initialState) => {
|
|
|
622
622
|
return memoizedValue;
|
|
623
623
|
};
|
|
624
624
|
|
|
625
|
+
// src/hooks/useCountdown.tsx
|
|
626
|
+
import { useRef, useState as useState6, useEffect as useEffect2, useCallback as useCallback6 } from "react";
|
|
627
|
+
var useCountdownDate = (date) => {
|
|
628
|
+
const targetTime = typeof date === "number" ? date : typeof date === "string" ? new Date(date).valueOf() : date.valueOf();
|
|
629
|
+
const [countdown, setCountdown] = useState6({
|
|
630
|
+
days: "00",
|
|
631
|
+
hours: "00",
|
|
632
|
+
minutes: "00",
|
|
633
|
+
seconds: "00"
|
|
634
|
+
});
|
|
635
|
+
const setNewTime = useCallback6(() => {
|
|
636
|
+
const now = Date.now();
|
|
637
|
+
const distanceToNow = targetTime - now;
|
|
638
|
+
if (distanceToNow <= 0) {
|
|
639
|
+
setCountdown({
|
|
640
|
+
days: "00",
|
|
641
|
+
hours: "00",
|
|
642
|
+
minutes: "00",
|
|
643
|
+
seconds: "00"
|
|
644
|
+
});
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
const getDays = Math.floor(distanceToNow / (1e3 * 60 * 60 * 24));
|
|
648
|
+
const getHours = `0${Math.floor(distanceToNow % (1e3 * 60 * 60 * 24) / (1e3 * 60 * 60))}`.slice(-2);
|
|
649
|
+
const getMinutes = `0${Math.floor(distanceToNow % (1e3 * 60 * 60) / (1e3 * 60))}`.slice(-2);
|
|
650
|
+
const getSeconds = `0${Math.floor(distanceToNow % (1e3 * 60) / 1e3)}`.slice(-2);
|
|
651
|
+
setCountdown({
|
|
652
|
+
days: getDays < 10 ? `0${getDays}` : `${getDays}`,
|
|
653
|
+
hours: getHours,
|
|
654
|
+
minutes: getMinutes,
|
|
655
|
+
seconds: getSeconds
|
|
656
|
+
});
|
|
657
|
+
}, [targetTime]);
|
|
658
|
+
useEffect2(() => {
|
|
659
|
+
setNewTime();
|
|
660
|
+
const interval = setInterval(setNewTime, 1e3);
|
|
661
|
+
return () => clearInterval(interval);
|
|
662
|
+
}, [setNewTime]);
|
|
663
|
+
return countdown;
|
|
664
|
+
};
|
|
665
|
+
var useCountdownSeconds = (initCountdown) => {
|
|
666
|
+
const [countdown, setCountdown] = useState6(initCountdown);
|
|
667
|
+
const intervalIdRef = useRef(null);
|
|
668
|
+
const remainingSecondsRef = useRef(initCountdown);
|
|
669
|
+
const startCountdown = useCallback6(() => {
|
|
670
|
+
if (intervalIdRef.current) {
|
|
671
|
+
clearInterval(intervalIdRef.current);
|
|
672
|
+
}
|
|
673
|
+
remainingSecondsRef.current = initCountdown;
|
|
674
|
+
setCountdown(initCountdown);
|
|
675
|
+
intervalIdRef.current = setInterval(() => {
|
|
676
|
+
remainingSecondsRef.current -= 1;
|
|
677
|
+
if (remainingSecondsRef.current <= 0) {
|
|
678
|
+
if (intervalIdRef.current) clearInterval(intervalIdRef.current);
|
|
679
|
+
setCountdown(0);
|
|
680
|
+
} else {
|
|
681
|
+
setCountdown(remainingSecondsRef.current);
|
|
682
|
+
}
|
|
683
|
+
}, 1e3);
|
|
684
|
+
}, [initCountdown]);
|
|
685
|
+
useEffect2(() => {
|
|
686
|
+
return () => {
|
|
687
|
+
if (intervalIdRef.current) {
|
|
688
|
+
clearInterval(intervalIdRef.current);
|
|
689
|
+
}
|
|
690
|
+
};
|
|
691
|
+
}, []);
|
|
692
|
+
const counting = countdown > 0 && countdown < initCountdown;
|
|
693
|
+
return {
|
|
694
|
+
counting,
|
|
695
|
+
countdown,
|
|
696
|
+
startCountdown,
|
|
697
|
+
setCountdown
|
|
698
|
+
};
|
|
699
|
+
};
|
|
700
|
+
|
|
625
701
|
// src/hooks/useResponsive.ts
|
|
626
702
|
import { useMemo as useMemo5 } from "react";
|
|
627
703
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
@@ -656,19 +732,19 @@ var useWidth = () => {
|
|
|
656
732
|
};
|
|
657
733
|
|
|
658
734
|
// src/hooks/useEventListener.ts
|
|
659
|
-
import { useRef, useEffect as
|
|
660
|
-
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect :
|
|
735
|
+
import { useRef as useRef2, useEffect as useEffect3, useLayoutEffect } from "react";
|
|
736
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect3;
|
|
661
737
|
var useEventListener = ({
|
|
662
738
|
eventName,
|
|
663
739
|
handler,
|
|
664
740
|
element,
|
|
665
741
|
options
|
|
666
742
|
}) => {
|
|
667
|
-
const savedHandler =
|
|
743
|
+
const savedHandler = useRef2(handler);
|
|
668
744
|
useIsomorphicLayoutEffect(() => {
|
|
669
745
|
savedHandler.current = handler;
|
|
670
746
|
}, [handler]);
|
|
671
|
-
|
|
747
|
+
useEffect3(() => {
|
|
672
748
|
const targetElement = element?.current || window;
|
|
673
749
|
if (!(targetElement && targetElement.addEventListener)) {
|
|
674
750
|
return;
|
|
@@ -682,11 +758,11 @@ var useEventListener = ({
|
|
|
682
758
|
};
|
|
683
759
|
|
|
684
760
|
// src/hooks/useCopyToClipboard.ts
|
|
685
|
-
import { useMemo as useMemo6, useState as
|
|
761
|
+
import { useMemo as useMemo6, useState as useState7, useCallback as useCallback7 } from "react";
|
|
686
762
|
var useCopyToClipboard = () => {
|
|
687
|
-
const [copiedText, setCopiedText] =
|
|
688
|
-
const [isCopied, setIsCopied] =
|
|
689
|
-
const copy =
|
|
763
|
+
const [copiedText, setCopiedText] = useState7("");
|
|
764
|
+
const [isCopied, setIsCopied] = useState7(false);
|
|
765
|
+
const copy = useCallback7(
|
|
690
766
|
async (text2) => {
|
|
691
767
|
if (!navigator?.clipboard) {
|
|
692
768
|
console.warn("Clipboard not supported");
|
|
@@ -714,11 +790,11 @@ var useCopyToClipboard = () => {
|
|
|
714
790
|
};
|
|
715
791
|
|
|
716
792
|
// src/hooks/useScrollOffsetTop.ts
|
|
717
|
-
import { useRef as
|
|
793
|
+
import { useRef as useRef3, useMemo as useMemo7, useState as useState8, useEffect as useEffect4, useCallback as useCallback8 } from "react";
|
|
718
794
|
var useScrollOffSetTop = (top = 0) => {
|
|
719
|
-
const elementRef =
|
|
720
|
-
const [offsetTop, setOffsetTop] =
|
|
721
|
-
const handleScrollChange =
|
|
795
|
+
const elementRef = useRef3(null);
|
|
796
|
+
const [offsetTop, setOffsetTop] = useState8(false);
|
|
797
|
+
const handleScrollChange = useCallback8(() => {
|
|
722
798
|
const scrollHeight = Math.round(window.scrollY);
|
|
723
799
|
if (elementRef?.current) {
|
|
724
800
|
const rect = elementRef.current.getBoundingClientRect();
|
|
@@ -728,7 +804,7 @@ var useScrollOffSetTop = (top = 0) => {
|
|
|
728
804
|
setOffsetTop(scrollHeight > top);
|
|
729
805
|
}
|
|
730
806
|
}, [top]);
|
|
731
|
-
|
|
807
|
+
useEffect4(() => {
|
|
732
808
|
handleScrollChange();
|
|
733
809
|
window.addEventListener("scroll", handleScrollChange, { passive: true });
|
|
734
810
|
return () => {
|
|
@@ -6187,7 +6263,7 @@ var UploadProgress = ({ progress: progress2 = 20 }) => {
|
|
|
6187
6263
|
};
|
|
6188
6264
|
|
|
6189
6265
|
// src/components/Upload/components/MultiFilePreview.tsx
|
|
6190
|
-
import { useRef as
|
|
6266
|
+
import { useRef as useRef4 } from "react";
|
|
6191
6267
|
import Box9 from "@mui/material/Box";
|
|
6192
6268
|
import IconButton2 from "@mui/material/IconButton";
|
|
6193
6269
|
|
|
@@ -6255,7 +6331,7 @@ var DeleteButton = ({ sx, ...rest }) => {
|
|
|
6255
6331
|
// src/components/Upload/components/MultiFilePreview.tsx
|
|
6256
6332
|
import { jsx as jsx48, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
6257
6333
|
var MultiFilePreview = ({ files, onRemove }) => {
|
|
6258
|
-
const scrollRef =
|
|
6334
|
+
const scrollRef = useRef4(null);
|
|
6259
6335
|
const handleScroll = (direction) => {
|
|
6260
6336
|
if (scrollRef.current) {
|
|
6261
6337
|
const scrollAmount = 300;
|
|
@@ -6710,7 +6786,7 @@ var RHFUpload = ({ name, multiple, helperText, ...rest }) => {
|
|
|
6710
6786
|
import { Controller as Controller3, useFormContext as useFormContext3 } from "react-hook-form";
|
|
6711
6787
|
|
|
6712
6788
|
// src/components/OTPInput/index.tsx
|
|
6713
|
-
import { useRef as
|
|
6789
|
+
import { useRef as useRef5, useState as useState9 } from "react";
|
|
6714
6790
|
import { useTheme as useTheme2 } from "@mui/material/styles";
|
|
6715
6791
|
import Box13 from "@mui/material/Box";
|
|
6716
6792
|
import FormHelperText3 from "@mui/material/FormHelperText";
|
|
@@ -6720,8 +6796,8 @@ import { Fragment, jsx as jsx53, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
|
6720
6796
|
var OTPInput = (props) => {
|
|
6721
6797
|
const { length = 6, onChange, onComplete, error: error2, helperText, containerProps, ...rest } = props;
|
|
6722
6798
|
const theme = useTheme2();
|
|
6723
|
-
const [otp, setOtp] =
|
|
6724
|
-
const inputsRef =
|
|
6799
|
+
const [otp, setOtp] = useState9(Array(length).fill(""));
|
|
6800
|
+
const inputsRef = useRef5([]);
|
|
6725
6801
|
const handleChange = (value, index) => {
|
|
6726
6802
|
if (!/^[0-9]$/.test(value) && value !== "") return;
|
|
6727
6803
|
const newOtp = [...otp];
|
|
@@ -7434,6 +7510,8 @@ export {
|
|
|
7434
7510
|
updateCoreWithSettings,
|
|
7435
7511
|
useBoolean,
|
|
7436
7512
|
useCopyToClipboard,
|
|
7513
|
+
useCountdownDate,
|
|
7514
|
+
useCountdownSeconds,
|
|
7437
7515
|
useEventListener,
|
|
7438
7516
|
useLocalStorage,
|
|
7439
7517
|
usePopover,
|