@umituz/web-design-system 4.0.0 → 4.0.3

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 CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@umituz/web-design-system",
3
- "version": "4.0.0",
3
+ "version": "4.0.3",
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",
@@ -52,7 +52,7 @@ export function getNextSizeVariant(current: SizeVariant): SizeVariant | null {
52
52
  if (index === -1 || index === SIZE_VARIANT_ORDER.length - 1) {
53
53
  return null;
54
54
  }
55
- return SIZE_VARIANT_ORDER[index + 1];
55
+ return SIZE_VARIANT_ORDER[index + 1] ?? null;
56
56
  }
57
57
 
58
58
  /**
@@ -63,7 +63,7 @@ export function getPrevSizeVariant(current: SizeVariant): SizeVariant | null {
63
63
  if (index <= 0) {
64
64
  return null;
65
65
  }
66
- return SIZE_VARIANT_ORDER[index - 1];
66
+ return SIZE_VARIANT_ORDER[index - 1] ?? null;
67
67
  }
68
68
 
69
69
  /**
@@ -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(([_, value]) => Boolean(value))
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
- callbackRef.current = callback;
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: any[]) => any>(
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
- valueRef.current = storedValue;
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 [matches, setMatches] = useState(false);
31
-
32
- useEffect(() => {
33
- // FIX: SSR-safe check
34
- if (typeof window === 'undefined') return;
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
- const query = createMediaQuery(breakpoint);
37
- const media = window.matchMedia(query);
38
- setMatches(media.matches);
42
+ const getSnapshot = useCallback(() => {
43
+ if (typeof window === 'undefined') return false;
44
+ return window.matchMedia(query).matches;
45
+ }, [query]);
39
46
 
40
- const listener = (e: MediaQueryListEvent) => setMatches(e.matches);
41
- media.addEventListener('change', listener);
42
- return () => media.removeEventListener('change', listener);
43
- }, [breakpoint]);
47
+ const getServerSnapshot = useCallback(() => false, []);
44
48
 
45
- return matches;
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 {
@@ -18,7 +18,7 @@ export const InputGroup = forwardRef<HTMLDivElement, InputGroupProps>(
18
18
  return (
19
19
  <div
20
20
  ref={ref}
21
- className="relative"
21
+ className={cn('relative', className)}
22
22
  {...props}
23
23
  >
24
24
  {leftElement && (
@@ -22,7 +22,7 @@ import {
22
22
  clampPageNumber,
23
23
  computePageBounds,
24
24
  } from '../../infrastructure/utils/calculation.utils';
25
- import type { BaseProps, ColorVariant } from '../../domain/types';
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 extends Record<string, unknown>>({
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,