@umituz/web-design-system 4.0.0 → 4.0.2
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/package.json +2 -1
- package/src/infrastructure/utils/cn.util.ts +1 -1
- package/src/presentation/hooks/useClickOutside.ts +3 -1
- package/src/presentation/hooks/useDebounce.ts +1 -1
- package/src/presentation/hooks/useLocalStorage.ts +4 -2
- package/src/presentation/hooks/useMediaQuery.ts +18 -14
- package/src/presentation/molecules/CodeBlock.tsx +0 -1
- package/src/presentation/molecules/InputGroup.tsx +1 -1
- package/src/presentation/organisms/DataTable.tsx +2 -4
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/web-design-system",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"private": false,
|
|
5
|
+
"type": "module",
|
|
5
6
|
"description": "Web Design System - Tailwind v4 authored, precompiled CSS shipped. Atomic Design components (Atoms, Molecules, Organisms, Templates) for React applications.",
|
|
6
7
|
"main": "./src/index.ts",
|
|
7
8
|
"types": "./src/index.ts",
|
|
@@ -68,7 +68,7 @@ function generateCacheKey(inputs: ClassValue[]): string {
|
|
|
68
68
|
// Handle objects (like conditional objects in clsx)
|
|
69
69
|
return JSON.stringify(
|
|
70
70
|
Object.entries(input)
|
|
71
|
-
.filter(([
|
|
71
|
+
.filter(([, value]) => Boolean(value))
|
|
72
72
|
.map(([key]) => key)
|
|
73
73
|
.sort()
|
|
74
74
|
);
|
|
@@ -13,7 +13,9 @@ export function useClickOutside<T extends HTMLElement>(
|
|
|
13
13
|
// Use a ref to keep the latest callback without retriggering the effect
|
|
14
14
|
// on every render — callers commonly pass inline functions.
|
|
15
15
|
const callbackRef = useRef(callback);
|
|
16
|
-
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
callbackRef.current = callback;
|
|
18
|
+
});
|
|
17
19
|
|
|
18
20
|
useEffect(() => {
|
|
19
21
|
if (!enabled) return;
|
|
@@ -34,7 +34,7 @@ export function useDebounce<T>(value: T, delay: number = TIMING.DEBOUNCE_DEFAULT
|
|
|
34
34
|
* useThrottle Hook
|
|
35
35
|
* @description Throttle a function to limit execution rate
|
|
36
36
|
*/
|
|
37
|
-
export function useThrottle<T extends (...args:
|
|
37
|
+
export function useThrottle<T extends (...args: unknown[]) => unknown>(
|
|
38
38
|
func: T,
|
|
39
39
|
delay: number = TIMING.THROTTLE_DEFAULT_MS
|
|
40
40
|
): T {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @description LocalStorage state management with safe error surfacing
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { useCallback, useState, useRef } from 'react';
|
|
6
|
+
import { useCallback, useEffect, useState, useRef } from 'react';
|
|
7
7
|
|
|
8
8
|
const isBrowser = (): boolean =>
|
|
9
9
|
typeof window !== 'undefined' && typeof window.localStorage !== 'undefined';
|
|
@@ -26,7 +26,9 @@ export function useLocalStorage<T>(
|
|
|
26
26
|
const [storedValue, setStoredValue] = useState<T>(() => readInitial(key, initialValue));
|
|
27
27
|
|
|
28
28
|
const valueRef = useRef(storedValue);
|
|
29
|
-
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
valueRef.current = storedValue;
|
|
31
|
+
}, [storedValue]);
|
|
30
32
|
|
|
31
33
|
const setValue = useCallback(
|
|
32
34
|
(value: T | ((prev: T) => T)) => {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @description Enhanced responsive breakpoint detection with helper functions
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { useEffect, useState, useCallback, useRef, useMemo } from 'react';
|
|
6
|
+
import { useEffect, useState, useCallback, useRef, useMemo, useSyncExternalStore } from 'react';
|
|
7
7
|
import type {
|
|
8
8
|
Breakpoint,
|
|
9
9
|
UseBreakpointReturn,
|
|
@@ -27,22 +27,26 @@ import { TIMING } from '../../infrastructure/constants/timing.constants';
|
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
export function useMediaQuery(breakpoint: Breakpoint): boolean {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
const query = useMemo(() => createMediaQuery(breakpoint), [breakpoint]);
|
|
31
|
+
|
|
32
|
+
const subscribe = useCallback(
|
|
33
|
+
(onStoreChange: () => void) => {
|
|
34
|
+
if (typeof window === 'undefined') return () => {};
|
|
35
|
+
const media = window.matchMedia(query);
|
|
36
|
+
media.addEventListener('change', onStoreChange);
|
|
37
|
+
return () => media.removeEventListener('change', onStoreChange);
|
|
38
|
+
},
|
|
39
|
+
[query]
|
|
40
|
+
);
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
const getSnapshot = useCallback(() => {
|
|
43
|
+
if (typeof window === 'undefined') return false;
|
|
44
|
+
return window.matchMedia(query).matches;
|
|
45
|
+
}, [query]);
|
|
39
46
|
|
|
40
|
-
|
|
41
|
-
media.addEventListener('change', listener);
|
|
42
|
-
return () => media.removeEventListener('change', listener);
|
|
43
|
-
}, [breakpoint]);
|
|
47
|
+
const getServerSnapshot = useCallback(() => false, []);
|
|
44
48
|
|
|
45
|
-
return
|
|
49
|
+
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
/**
|
|
@@ -8,7 +8,6 @@ import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
|
|
|
8
8
|
import { vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism';
|
|
9
9
|
import { ChevronDown, ChevronUp, Check, Copy } from 'lucide-react';
|
|
10
10
|
import { cn } from '../../infrastructure/utils';
|
|
11
|
-
import { TIMING } from '../../infrastructure/constants/timing.constants';
|
|
12
11
|
import type { BaseProps } from '../../domain/types';
|
|
13
12
|
|
|
14
13
|
export interface CodeBlockProps extends BaseProps {
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
clampPageNumber,
|
|
23
23
|
computePageBounds,
|
|
24
24
|
} from '../../infrastructure/utils/calculation.utils';
|
|
25
|
-
import type { BaseProps
|
|
25
|
+
import type { BaseProps } from '../../domain/types';
|
|
26
26
|
import type { MediumSizes } from '../../infrastructure/constants';
|
|
27
27
|
|
|
28
28
|
export interface Column<T> {
|
|
@@ -39,7 +39,6 @@ export interface DataTableProps<T> extends BaseProps {
|
|
|
39
39
|
columns: Column<T>[];
|
|
40
40
|
caption?: string;
|
|
41
41
|
size?: MediumSizes;
|
|
42
|
-
variant?: ColorVariant;
|
|
43
42
|
sortable?: boolean;
|
|
44
43
|
paginated?: boolean;
|
|
45
44
|
pageSize?: number;
|
|
@@ -50,13 +49,12 @@ export interface DataTableProps<T> extends BaseProps {
|
|
|
50
49
|
onRowClick?: (row: T) => void;
|
|
51
50
|
}
|
|
52
51
|
|
|
53
|
-
export function DataTable<T
|
|
52
|
+
export function DataTable<T>({
|
|
54
53
|
className,
|
|
55
54
|
data,
|
|
56
55
|
columns,
|
|
57
56
|
caption,
|
|
58
57
|
size = 'md',
|
|
59
|
-
variant = 'primary',
|
|
60
58
|
sortable = false,
|
|
61
59
|
paginated = false,
|
|
62
60
|
pageSize = 10,
|