@classytic/fluid 0.2.1 → 0.3.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.
Files changed (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +149 -62
  3. package/dist/api-pagination-CJ0vR_w6.d.mts +34 -0
  4. package/dist/api-pagination-DBTE0yk4.mjs +190 -0
  5. package/dist/chunk-DQk6qfdC.mjs +18 -0
  6. package/dist/client/calendar.d.mts +105 -0
  7. package/dist/client/calendar.mjs +202 -0
  8. package/dist/client/core.d.mts +1614 -0
  9. package/dist/client/core.mjs +2779 -0
  10. package/dist/client/error.d.mts +125 -0
  11. package/dist/client/error.mjs +166 -0
  12. package/dist/client/hooks.d.mts +162 -0
  13. package/dist/client/hooks.mjs +447 -0
  14. package/dist/client/table.d.mts +84 -0
  15. package/dist/client/table.mjs +373 -0
  16. package/dist/client/theme.d.mts +6 -0
  17. package/dist/client/theme.mjs +65 -0
  18. package/dist/command.d.mts +134 -0
  19. package/dist/command.mjs +132 -0
  20. package/dist/compact.d.mts +359 -0
  21. package/dist/compact.mjs +892 -0
  22. package/dist/dashboard.d.mts +778 -0
  23. package/dist/dashboard.mjs +1617 -0
  24. package/dist/filter-utils-DqMmy_v-.mjs +72 -0
  25. package/dist/filter-utils-IZ0GtuPo.d.mts +40 -0
  26. package/dist/forms.d.mts +1549 -0
  27. package/dist/forms.mjs +3740 -0
  28. package/dist/index.d.mts +296 -0
  29. package/dist/index.mjs +432 -0
  30. package/dist/layouts.d.mts +215 -0
  31. package/dist/layouts.mjs +460 -0
  32. package/dist/search-context-DR7DBs7S.mjs +19 -0
  33. package/dist/search.d.mts +254 -0
  34. package/dist/search.mjs +523 -0
  35. package/dist/sheet-wrapper-CWNCvYMD.mjs +211 -0
  36. package/dist/use-base-search-BGgWnWaF.d.mts +35 -0
  37. package/dist/use-debounce-xmZucz5e.mjs +53 -0
  38. package/dist/use-keyboard-shortcut-Bl6YM5Q7.mjs +82 -0
  39. package/dist/use-keyboard-shortcut-_mRCh3QO.d.mts +24 -0
  40. package/dist/use-media-query-BnVNIKT4.mjs +17 -0
  41. package/dist/use-mobile-BX3SQVo2.mjs +20 -0
  42. package/dist/use-scroll-detection-CsgsQYvy.mjs +43 -0
  43. package/dist/utils-CDue7cEt.d.mts +6 -0
  44. package/dist/utils-DQ5SCVoW.mjs +10 -0
  45. package/package.json +85 -45
  46. package/styles.css +2 -2
  47. package/dist/chunk-GUHK2DTW.js +0 -15
  48. package/dist/chunk-GUHK2DTW.js.map +0 -1
  49. package/dist/chunk-H3NFL3GJ.js +0 -57
  50. package/dist/chunk-H3NFL3GJ.js.map +0 -1
  51. package/dist/chunk-J2YRTQE4.js +0 -293
  52. package/dist/chunk-J2YRTQE4.js.map +0 -1
  53. package/dist/compact.d.ts +0 -217
  54. package/dist/compact.js +0 -986
  55. package/dist/compact.js.map +0 -1
  56. package/dist/dashboard.d.ts +0 -386
  57. package/dist/dashboard.js +0 -1032
  58. package/dist/dashboard.js.map +0 -1
  59. package/dist/index.d.ts +0 -2141
  60. package/dist/index.js +0 -6460
  61. package/dist/index.js.map +0 -1
  62. package/dist/layout.d.ts +0 -25
  63. package/dist/layout.js +0 -4
  64. package/dist/layout.js.map +0 -1
  65. package/dist/search.d.ts +0 -172
  66. package/dist/search.js +0 -341
  67. package/dist/search.js.map +0 -1
  68. package/dist/use-base-search-AS5Z3SAy.d.ts +0 -64
  69. package/dist/utils-Cbsgs0XP.d.ts +0 -5
@@ -0,0 +1,125 @@
1
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
2
+ import { ComponentType, ReactNode } from "react";
3
+ import { FallbackProps } from "react-error-boundary";
4
+
5
+ //#region src/components/error-boundary.d.ts
6
+ interface ErrorBoundaryFallbackProps extends FallbackProps {}
7
+ interface ErrorBoundaryProps {
8
+ /** Custom fallback component. Defaults to FullPageErrorFallback. */
9
+ fallback?: ComponentType<FallbackProps>;
10
+ /** Called when an error is caught */
11
+ onError?: (error: unknown, info: {
12
+ componentStack?: string | null;
13
+ }) => void;
14
+ /** Called when the error boundary resets */
15
+ onReset?: () => void;
16
+ children: ReactNode;
17
+ }
18
+ interface FeatureErrorBoundaryProps {
19
+ /** Name of the feature section (shown in error message) */
20
+ featureName?: string;
21
+ /** Called when an error is caught */
22
+ onError?: (error: unknown, info: {
23
+ componentStack?: string | null;
24
+ }) => void;
25
+ /** Called when the error boundary resets */
26
+ onReset?: () => void;
27
+ children: ReactNode;
28
+ className?: string;
29
+ }
30
+ /**
31
+ * Full-page error fallback with retry and go-home buttons.
32
+ * Used as the default for ErrorBoundary.
33
+ */
34
+ declare function FullPageErrorFallback({
35
+ error,
36
+ resetErrorBoundary
37
+ }: FallbackProps): react_jsx_runtime0.JSX.Element;
38
+ /**
39
+ * Compact inline error fallback for feature sections.
40
+ * Used as the default for FeatureErrorBoundary.
41
+ */
42
+ declare function InlineErrorFallback({
43
+ error,
44
+ resetErrorBoundary,
45
+ featureName,
46
+ className
47
+ }: FallbackProps & {
48
+ featureName?: string;
49
+ className?: string;
50
+ }): react_jsx_runtime0.JSX.Element;
51
+ /**
52
+ * Global error boundary with full-page fallback.
53
+ *
54
+ * @example
55
+ * ```tsx
56
+ * <ErrorBoundary onError={(e) => logError(e)}>
57
+ * <App />
58
+ * </ErrorBoundary>
59
+ * ```
60
+ */
61
+ declare function ErrorBoundary({
62
+ fallback: FallbackComponent,
63
+ onError,
64
+ onReset,
65
+ children
66
+ }: ErrorBoundaryProps): react_jsx_runtime0.JSX.Element;
67
+ /**
68
+ * Feature-scoped error boundary with compact inline fallback.
69
+ *
70
+ * @example
71
+ * ```tsx
72
+ * <FeatureErrorBoundary featureName="Analytics">
73
+ * <AnalyticsDashboard />
74
+ * </FeatureErrorBoundary>
75
+ * ```
76
+ */
77
+ declare function FeatureErrorBoundary({
78
+ featureName,
79
+ onError,
80
+ onReset,
81
+ children,
82
+ className
83
+ }: FeatureErrorBoundaryProps): react_jsx_runtime0.JSX.Element;
84
+ //#endregion
85
+ //#region src/components/async-boundary.d.ts
86
+ interface AsyncBoundaryProps {
87
+ /** Suspense fallback (shown while loading) */
88
+ fallback?: ReactNode;
89
+ /** Error fallback component (shown on error) */
90
+ errorFallback?: ComponentType<FallbackProps>;
91
+ /** Called when an error is caught */
92
+ onError?: (error: unknown, info: {
93
+ componentStack?: string | null;
94
+ }) => void;
95
+ /** Called when the error boundary resets */
96
+ onReset?: () => void;
97
+ children: ReactNode;
98
+ }
99
+ /**
100
+ * AsyncBoundary — Suspense + ErrorBoundary combined.
101
+ *
102
+ * If `errorFallback` is provided, wraps in ErrorBoundary from react-error-boundary.
103
+ * Otherwise, renders Suspense only.
104
+ *
105
+ * @example
106
+ * ```tsx
107
+ * import { AsyncBoundary, InlineErrorFallback } from "@classytic/fluid/client";
108
+ *
109
+ * <AsyncBoundary
110
+ * fallback={<SkeletonTable rows={5} />}
111
+ * errorFallback={InlineErrorFallback}
112
+ * >
113
+ * <DataFetchingComponent />
114
+ * </AsyncBoundary>
115
+ * ```
116
+ */
117
+ declare function AsyncBoundary({
118
+ fallback,
119
+ errorFallback: ErrorFallback,
120
+ onError,
121
+ onReset,
122
+ children
123
+ }: AsyncBoundaryProps): react_jsx_runtime0.JSX.Element;
124
+ //#endregion
125
+ export { AsyncBoundary, type AsyncBoundaryProps, ErrorBoundary, type ErrorBoundaryFallbackProps, type ErrorBoundaryProps, FeatureErrorBoundary, type FeatureErrorBoundaryProps, FullPageErrorFallback, InlineErrorFallback };
@@ -0,0 +1,166 @@
1
+ "use client";
2
+
3
+ import { t as cn } from "../utils-DQ5SCVoW.mjs";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { Suspense } from "react";
6
+ import { AlertCircle, Home, RefreshCw } from "lucide-react";
7
+ import { Button } from "@/components/ui/button";
8
+ import { ErrorBoundary as ErrorBoundary$1 } from "react-error-boundary";
9
+
10
+ //#region src/components/error-boundary.tsx
11
+ /**
12
+ * Full-page error fallback with retry and go-home buttons.
13
+ * Used as the default for ErrorBoundary.
14
+ */
15
+ function FullPageErrorFallback({ error, resetErrorBoundary }) {
16
+ const isDev = process.env.NODE_ENV === "development";
17
+ const errorMessage = error instanceof Error ? error.message : String(error);
18
+ return /* @__PURE__ */ jsxs("div", {
19
+ className: "flex min-h-[50vh] flex-col items-center justify-center gap-4 p-6",
20
+ children: [
21
+ /* @__PURE__ */ jsx("div", {
22
+ className: "rounded-full bg-destructive/10 p-3",
23
+ children: /* @__PURE__ */ jsx(AlertCircle, { className: "h-8 w-8 text-destructive" })
24
+ }),
25
+ /* @__PURE__ */ jsxs("div", {
26
+ className: "text-center space-y-1.5",
27
+ children: [
28
+ /* @__PURE__ */ jsx("h2", {
29
+ className: "text-xl font-semibold",
30
+ children: "Something went wrong"
31
+ }),
32
+ /* @__PURE__ */ jsx("p", {
33
+ className: "text-sm text-muted-foreground max-w-md",
34
+ children: "An unexpected error occurred. Please try again or return to the home page."
35
+ }),
36
+ isDev && errorMessage && /* @__PURE__ */ jsx("pre", {
37
+ className: "mt-3 max-w-lg overflow-auto rounded-md bg-muted p-3 text-left text-xs text-destructive",
38
+ children: errorMessage
39
+ })
40
+ ]
41
+ }),
42
+ /* @__PURE__ */ jsxs("div", {
43
+ className: "flex gap-2",
44
+ children: [/* @__PURE__ */ jsxs(Button, {
45
+ variant: "outline",
46
+ onClick: resetErrorBoundary,
47
+ children: [/* @__PURE__ */ jsx(RefreshCw, { className: "mr-2 h-4 w-4" }), "Try Again"]
48
+ }), /* @__PURE__ */ jsxs(Button, {
49
+ onClick: () => window.location.href = "/",
50
+ children: [/* @__PURE__ */ jsx(Home, { className: "mr-2 h-4 w-4" }), "Go Home"]
51
+ })]
52
+ })
53
+ ]
54
+ });
55
+ }
56
+ /**
57
+ * Compact inline error fallback for feature sections.
58
+ * Used as the default for FeatureErrorBoundary.
59
+ */
60
+ function InlineErrorFallback({ error, resetErrorBoundary, featureName, className }) {
61
+ const isDev = process.env.NODE_ENV === "development";
62
+ const errorMessage = error instanceof Error ? error.message : String(error);
63
+ return /* @__PURE__ */ jsx("div", {
64
+ className: cn("rounded-lg border border-destructive/20 bg-destructive/5 p-4", className),
65
+ children: /* @__PURE__ */ jsxs("div", {
66
+ className: "flex items-start gap-3",
67
+ children: [/* @__PURE__ */ jsx(AlertCircle, { className: "h-5 w-5 text-destructive mt-0.5 shrink-0" }), /* @__PURE__ */ jsxs("div", {
68
+ className: "flex-1 min-w-0",
69
+ children: [
70
+ /* @__PURE__ */ jsx("h3", {
71
+ className: "text-sm font-medium",
72
+ children: featureName ? `Error loading ${featureName}` : "Something went wrong"
73
+ }),
74
+ isDev && errorMessage && /* @__PURE__ */ jsx("pre", {
75
+ className: "mt-1.5 text-xs text-destructive/80 whitespace-pre-wrap break-words",
76
+ children: errorMessage
77
+ }),
78
+ /* @__PURE__ */ jsxs(Button, {
79
+ variant: "outline",
80
+ size: "sm",
81
+ className: "mt-2 h-7 gap-1.5",
82
+ onClick: resetErrorBoundary,
83
+ children: [/* @__PURE__ */ jsx(RefreshCw, { className: "h-3 w-3" }), "Retry"]
84
+ })
85
+ ]
86
+ })]
87
+ })
88
+ });
89
+ }
90
+ /**
91
+ * Global error boundary with full-page fallback.
92
+ *
93
+ * @example
94
+ * ```tsx
95
+ * <ErrorBoundary onError={(e) => logError(e)}>
96
+ * <App />
97
+ * </ErrorBoundary>
98
+ * ```
99
+ */
100
+ function ErrorBoundary({ fallback: FallbackComponent = FullPageErrorFallback, onError, onReset, children }) {
101
+ return /* @__PURE__ */ jsx(ErrorBoundary$1, {
102
+ FallbackComponent,
103
+ onError,
104
+ onReset,
105
+ children
106
+ });
107
+ }
108
+ /**
109
+ * Feature-scoped error boundary with compact inline fallback.
110
+ *
111
+ * @example
112
+ * ```tsx
113
+ * <FeatureErrorBoundary featureName="Analytics">
114
+ * <AnalyticsDashboard />
115
+ * </FeatureErrorBoundary>
116
+ * ```
117
+ */
118
+ function FeatureErrorBoundary({ featureName = "Feature", onError, onReset, children, className }) {
119
+ return /* @__PURE__ */ jsx(ErrorBoundary$1, {
120
+ FallbackComponent: (props) => /* @__PURE__ */ jsx(InlineErrorFallback, {
121
+ ...props,
122
+ featureName,
123
+ className
124
+ }),
125
+ onError,
126
+ onReset,
127
+ children
128
+ });
129
+ }
130
+
131
+ //#endregion
132
+ //#region src/components/async-boundary.tsx
133
+ /**
134
+ * AsyncBoundary — Suspense + ErrorBoundary combined.
135
+ *
136
+ * If `errorFallback` is provided, wraps in ErrorBoundary from react-error-boundary.
137
+ * Otherwise, renders Suspense only.
138
+ *
139
+ * @example
140
+ * ```tsx
141
+ * import { AsyncBoundary, InlineErrorFallback } from "@classytic/fluid/client";
142
+ *
143
+ * <AsyncBoundary
144
+ * fallback={<SkeletonTable rows={5} />}
145
+ * errorFallback={InlineErrorFallback}
146
+ * >
147
+ * <DataFetchingComponent />
148
+ * </AsyncBoundary>
149
+ * ```
150
+ */
151
+ function AsyncBoundary({ fallback, errorFallback: ErrorFallback, onError, onReset, children }) {
152
+ const suspenseWrapped = /* @__PURE__ */ jsx(Suspense, {
153
+ fallback: fallback ?? null,
154
+ children
155
+ });
156
+ if (!ErrorFallback) return suspenseWrapped;
157
+ return /* @__PURE__ */ jsx(ErrorBoundary$1, {
158
+ FallbackComponent: ErrorFallback,
159
+ onError,
160
+ onReset,
161
+ children: suspenseWrapped
162
+ });
163
+ }
164
+
165
+ //#endregion
166
+ export { AsyncBoundary, ErrorBoundary, FeatureErrorBoundary, FullPageErrorFallback, InlineErrorFallback };
@@ -0,0 +1,162 @@
1
+ import { n as UseBaseSearchReturn, r as useBaseSearch, t as UseBaseSearchConfig } from "../use-base-search-BGgWnWaF.mjs";
2
+ import { n as useKeyboardShortcut, t as UseKeyboardShortcutOptions } from "../use-keyboard-shortcut-_mRCh3QO.mjs";
3
+ import { RefObject } from "react";
4
+
5
+ //#region src/hooks/use-mobile.d.ts
6
+ declare function useIsMobile(): boolean;
7
+ //#endregion
8
+ //#region src/hooks/use-media-query.d.ts
9
+ declare function useMediaQuery(query: string, defaultValue?: boolean): boolean;
10
+ //#endregion
11
+ //#region src/hooks/use-scroll-detection.d.ts
12
+ declare const useScrollDetection: (ref: RefObject<HTMLDivElement | null>, delay?: number) => {
13
+ checkScroll: () => void;
14
+ canScrollLeft: boolean;
15
+ canScrollRight: boolean;
16
+ isScrollable: boolean;
17
+ };
18
+ //#endregion
19
+ //#region src/hooks/use-debounce.d.ts
20
+ /**
21
+ * useDebounce — Returns a debounced version of the input value.
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * const [search, setSearch] = useState("");
26
+ * const debouncedSearch = useDebounce(search, 300);
27
+ *
28
+ * useEffect(() => {
29
+ * fetchResults(debouncedSearch);
30
+ * }, [debouncedSearch]);
31
+ * ```
32
+ */
33
+ declare function useDebounce<T>(value: T, delay?: number): T;
34
+ /**
35
+ * useDebouncedCallback — Returns a debounced version of a callback function.
36
+ *
37
+ * @example
38
+ * ```tsx
39
+ * const debouncedSave = useDebouncedCallback((value: string) => {
40
+ * saveToApi(value);
41
+ * }, 500);
42
+ *
43
+ * <Input onChange={(e) => debouncedSave(e.target.value)} />
44
+ * ```
45
+ */
46
+ declare function useDebouncedCallback<T extends (...args: any[]) => any>(callback: T, delay?: number): (...args: Parameters<T>) => void;
47
+ //#endregion
48
+ //#region src/hooks/use-copy-to-clipboard.d.ts
49
+ interface UseCopyToClipboardReturn {
50
+ /** Copy text to clipboard */
51
+ copy: (text: string) => Promise<boolean>;
52
+ /** Whether text was recently copied (resets after timeout) */
53
+ copied: boolean;
54
+ /** Any error that occurred during copy */
55
+ error: Error | null;
56
+ /** Reset the copied state manually */
57
+ reset: () => void;
58
+ }
59
+ /**
60
+ * useCopyToClipboard — Copy text to clipboard with status tracking.
61
+ *
62
+ * @param resetDelay - How long (ms) the `copied` state stays true. Default: 2000
63
+ *
64
+ * @example
65
+ * ```tsx
66
+ * const { copy, copied } = useCopyToClipboard();
67
+ *
68
+ * <Button onClick={() => copy(apiKey)}>
69
+ * {copied ? "Copied!" : "Copy API Key"}
70
+ * </Button>
71
+ * ```
72
+ */
73
+ declare function useCopyToClipboard(resetDelay?: number): UseCopyToClipboardReturn;
74
+ //#endregion
75
+ //#region src/hooks/use-local-storage.d.ts
76
+ /**
77
+ * useLocalStorage — Persist state in localStorage with type safety and optional expiry.
78
+ *
79
+ * @param key - The localStorage key
80
+ * @param initialValue - Default value if no stored value exists
81
+ * @param ttl - Time to live in milliseconds (optional)
82
+ *
83
+ * @example
84
+ * ```tsx
85
+ * const [theme, setTheme] = useLocalStorage("theme", "light");
86
+ * const [cache, setCache] = useLocalStorage("api-cache", {}, 60000); // 1 min TTL
87
+ * ```
88
+ */
89
+ declare function useLocalStorage<T>(key: string, initialValue: T, ttl?: number): [T, (value: T | ((prev: T) => T)) => void, () => void];
90
+ //#endregion
91
+ //#region src/lib/storage.d.ts
92
+ /**
93
+ * A utility module for handling localStorage operations with error handling and SSR safety
94
+ */
95
+ /**
96
+ * Gets an item from localStorage with parsing and expiry check
97
+ * @param {string} key - The key to retrieve from localStorage
98
+ * @param {any} defaultValue - Default value to return if key doesn't exist or on error
99
+ * @returns {any} The parsed value or defaultValue
100
+ */
101
+ declare const getStorageItem: <T>(key: string, defaultValue?: T | null) => T | null;
102
+ /**
103
+ * Sets an item in localStorage with serialization and optional expiry
104
+ * @param {string} key - The key to set in localStorage
105
+ * @param {any} value - The value to serialize and store
106
+ * @param {number} [ttl] - Time to live in milliseconds (optional)
107
+ * @returns {boolean} Success status
108
+ */
109
+ declare const setStorageItem: <T>(key: string, value: T, ttl?: number | null) => boolean;
110
+ /**
111
+ * Removes an item from localStorage
112
+ * @param {string} key - The key to remove from localStorage
113
+ * @returns {boolean} Success status
114
+ */
115
+ declare const removeStorageItem: (key: string) => boolean;
116
+ /**
117
+ * Clears all items from localStorage
118
+ * @returns {boolean} Success status
119
+ */
120
+ declare const clearStorage: () => boolean;
121
+ /**
122
+ * Checks if localStorage is empty for a specific key
123
+ * @param {string} key - The key to check in localStorage
124
+ * @returns {boolean} True if empty or doesn't exist
125
+ */
126
+ declare const isStorageEmpty: (key: string) => boolean;
127
+ /**
128
+ * Generates a UUID (v4)
129
+ * Uses crypto.randomUUID() when available, with a fallback for older environments.
130
+ * @returns {string} A random UUID
131
+ */
132
+ declare const generateUUID: () => string;
133
+ /**
134
+ * Common expiry durations in milliseconds
135
+ */
136
+ declare const TTL: {
137
+ readonly MINUTE: number;
138
+ readonly HOUR: number;
139
+ readonly DAY: number;
140
+ readonly WEEK: number;
141
+ readonly MONTH: number;
142
+ };
143
+ /**
144
+ * Shorthand object for all localStorage operations
145
+ */
146
+ declare const storage: {
147
+ get: <T>(key: string, defaultValue?: T | null) => T | null;
148
+ set: <T>(key: string, value: T, ttl?: number | null) => boolean;
149
+ remove: (key: string) => boolean;
150
+ clear: () => boolean;
151
+ isEmpty: (key: string) => boolean;
152
+ generateUUID: () => string;
153
+ TTL: {
154
+ readonly MINUTE: number;
155
+ readonly HOUR: number;
156
+ readonly DAY: number;
157
+ readonly WEEK: number;
158
+ readonly MONTH: number;
159
+ };
160
+ };
161
+ //#endregion
162
+ export { TTL, type UseBaseSearchConfig, type UseBaseSearchReturn, type UseCopyToClipboardReturn, type UseKeyboardShortcutOptions, clearStorage, generateUUID, getStorageItem, isStorageEmpty, removeStorageItem, setStorageItem, storage, useBaseSearch, useCopyToClipboard, useDebounce, useDebouncedCallback, useIsMobile, useKeyboardShortcut, useLocalStorage, useMediaQuery, useScrollDetection };