@catalystsoftware/ui 1.0.2 → 1.0.5
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/data/tailwind.config.js +261 -3821
- package/dist/components/catalyst-ui/buttons/burger.tsx +207 -0
- package/dist/components/catalyst-ui/core/data-display/timeline.tsx +210 -0
- package/dist/components/catalyst-ui/core/feedback/alert.tsx +491 -0
- package/dist/components/catalyst-ui/core/feedback/spinner-1.tsx +65 -0
- package/dist/components/catalyst-ui/core/feedback/toast.tsx +1857 -0
- package/dist/components/catalyst-ui/core/navigation/menu.tsx +164 -0
- package/dist/components/catalyst-ui/forms/toggle-class.tsx +176 -0
- package/dist/components/catalyst-ui/hooks/use-copy-to-clipboard.tsx +419 -0
- package/dist/components/catalyst-ui/hooks/use-counter.tsx +13 -0
- package/dist/components/catalyst-ui/hooks/use-event-listener.tsx +23 -0
- package/dist/components/catalyst-ui/hooks/use-export-markdown.tsx +47 -0
- package/dist/components/catalyst-ui/hooks/use-focus.tsx +17 -0
- package/dist/components/catalyst-ui/hooks/use-interval.tsx +23 -0
- package/dist/components/catalyst-ui/hooks/use-is-client.tsx +16 -0
- package/dist/components/catalyst-ui/hooks/use-media-query.tsx +19 -0
- package/dist/components/catalyst-ui/hooks/use-mobile.tsx +19 -0
- package/dist/components/catalyst-ui/hooks/use-resize-observer.tsx +81 -0
- package/dist/components/catalyst-ui/hooks/use-timeout.tsx +21 -0
- package/dist/components/catalyst-ui/hooks/use-timer.tsx +209 -0
- package/dist/components/catalyst-ui/hooks/use-toggle.tsx +12 -0
- package/dist/components/catalyst-ui/media/image.tsx +13 -0
- package/dist/components/catalyst-ui/overlays/dual-sidebar.tsx +4142 -0
- package/dist/components/catalyst-ui/overlays/sidebar-original.tsx +726 -0
- package/dist/components/catalyst-ui/primitives/accordion.tsx +250 -0
- package/dist/components/catalyst-ui/primitives/alert-dialog.tsx +126 -0
- package/dist/components/catalyst-ui/primitives/aspect-ratio.tsx +9 -0
- package/dist/components/catalyst-ui/primitives/avatar.tsx +296 -0
- package/dist/components/catalyst-ui/primitives/badge.tsx +57 -0
- package/dist/components/catalyst-ui/primitives/breadcrumb.tsx +101 -0
- package/dist/components/catalyst-ui/primitives/button.tsx +265 -0
- package/dist/components/catalyst-ui/primitives/calendar-v4.tsx +208 -0
- package/dist/components/catalyst-ui/primitives/calendar.tsx +295 -0
- package/dist/components/catalyst-ui/primitives/card.tsx +618 -0
- package/dist/components/catalyst-ui/primitives/carousel.tsx +238 -0
- package/dist/components/catalyst-ui/primitives/chart.tsx +347 -0
- package/dist/components/catalyst-ui/primitives/checkbox.tsx +225 -0
- package/dist/components/catalyst-ui/primitives/collapsible.tsx +212 -0
- package/dist/components/catalyst-ui/primitives/command.tsx +393 -0
- package/dist/components/catalyst-ui/primitives/context-menu.tsx +236 -0
- package/dist/components/catalyst-ui/primitives/dialog.tsx +471 -0
- package/dist/components/catalyst-ui/primitives/drawer.tsx +761 -0
- package/dist/components/catalyst-ui/primitives/dropdown-menu.tsx +290 -0
- package/dist/components/catalyst-ui/primitives/empty.tsx +104 -0
- package/dist/components/catalyst-ui/primitives/field.tsx +244 -0
- package/dist/components/catalyst-ui/primitives/hover-card.tsx +124 -0
- package/dist/components/catalyst-ui/primitives/input-otp.tsx +76 -0
- package/dist/components/catalyst-ui/primitives/input.tsx +64 -0
- package/dist/components/catalyst-ui/primitives/item.tsx +196 -0
- package/dist/components/catalyst-ui/primitives/kbd.tsx +75 -0
- package/dist/components/catalyst-ui/primitives/label.tsx +24 -0
- package/dist/components/catalyst-ui/primitives/navigation-menu.tsx +150 -0
- package/dist/components/catalyst-ui/primitives/pagination.tsx +198 -0
- package/dist/components/catalyst-ui/primitives/popover.tsx +232 -0
- package/dist/components/catalyst-ui/primitives/progress.tsx +34 -0
- package/dist/components/catalyst-ui/primitives/radio-group.tsx +43 -0
- package/dist/components/catalyst-ui/primitives/resizable.tsx +56 -0
- package/dist/components/catalyst-ui/primitives/select.tsx +155 -0
- package/dist/components/catalyst-ui/primitives/separator.tsx +74 -0
- package/dist/components/catalyst-ui/primitives/sheet.tsx +126 -0
- package/dist/components/catalyst-ui/primitives/skeleton.tsx +15 -0
- package/dist/components/catalyst-ui/primitives/slider.tsx +27 -0
- package/dist/components/catalyst-ui/primitives/switch.tsx +187 -0
- package/dist/components/catalyst-ui/primitives/tabs.tsx +335 -0
- package/dist/components/catalyst-ui/primitives/textarea.tsx +24 -0
- package/dist/components/catalyst-ui/primitives/toggle-group.tsx +55 -0
- package/dist/components/catalyst-ui/primitives/toggle.tsx +42 -0
- package/dist/components/catalyst-ui/primitives/tooltip.tsx +116 -0
- package/dist/components/catalyst-ui/utils/basic-auth.tsx +40 -0
- package/dist/components/catalyst-ui/utils/context-storage.tsx +19 -0
- package/dist/components/catalyst-ui/utils/cors-middleware.tsx +71 -0
- package/dist/components/catalyst-ui/utils/deferred-content.tsx +595 -0
- package/dist/components/catalyst-ui/utils/honeypot-middleware.tsx +38 -0
- package/dist/components/catalyst-ui/utils/incId.tsx +75 -0
- package/dist/components/catalyst-ui/utils/jwk-auth.tsx +36 -0
- package/dist/components/catalyst-ui/utils/request-id.tsx +14 -0
- package/dist/components/catalyst-ui/utils/secure-headers.tsx +37 -0
- package/dist/components/catalyst-ui/utils/server-timing.tsx +23 -0
- package/dist/components/catalyst-ui/utils/utils.ts +43 -0
- package/dist/components/catalyst-ui/utils/with-cookie.tsx +43 -0
- package/dist/components/catalyst-ui/x/accordian-x.tsx +428 -0
- package/dist/components/catalyst-ui/x/alert-x.tsx +413 -0
- package/dist/components/catalyst-ui/x/animated-text-x.tsx +2242 -0
- package/dist/components/catalyst-ui/x/avatar-x.tsx +515 -0
- package/dist/components/catalyst-ui/x/badge-x.tsx +670 -0
- package/dist/components/catalyst-ui/x/button-X.tsx +2857 -0
- package/dist/components/catalyst-ui/x/button-group-x.tsx +847 -0
- package/dist/components/catalyst-ui/x/calendar-x.tsx +1910 -0
- package/dist/components/catalyst-ui/x/card-x.tsx +2597 -0
- package/dist/components/catalyst-ui/x/checkbox-x.tsx +656 -0
- package/dist/components/catalyst-ui/x/collapsible-x.tsx +1360 -0
- package/dist/components/catalyst-ui/x/combobox-x.tsx +911 -0
- package/dist/components/catalyst-ui/x/data-table-x.tsx +1753 -0
- package/dist/components/catalyst-ui/x/date-picker-x.tsx +648 -0
- package/dist/components/catalyst-ui/x/dialog-x.tsx +659 -0
- package/dist/components/catalyst-ui/x/dropdown-menu-x.tsx +612 -0
- package/dist/components/catalyst-ui/x/hover-card-x.tsx +375 -0
- package/dist/components/catalyst-ui/x/icon-x.tsx +840 -0
- package/dist/components/catalyst-ui/x/input-mask-x.tsx +981 -0
- package/dist/components/catalyst-ui/x/input-otp-x.tsx +659 -0
- package/dist/components/catalyst-ui/x/loader-x.tsx +1757 -0
- package/dist/components/catalyst-ui/x/pagination-x.tsx +622 -0
- package/dist/components/catalyst-ui/x/popover-x.tsx +744 -0
- package/dist/components/catalyst-ui/x/radio-group-x.tsx +499 -0
- package/dist/components/catalyst-ui/x/select-x.tsx +1127 -0
- package/dist/components/catalyst-ui/x/sheet-x.tsx +668 -0
- package/dist/components/catalyst-ui/x/switch-x.tsx +681 -0
- package/dist/components/catalyst-ui/x/table-x.tsx +574 -0
- package/dist/components/catalyst-ui/x/tabs-x.tsx +839 -0
- package/dist/components/catalyst-ui/x/textarea-x.tsx +1263 -0
- package/dist/components/catalyst-ui/x/tooltip-x.tsx +396 -0
- package/dist/components/catalyst-ui/x/tracker-x.tsx +560 -0
- package/dist/data/bg-data.tsx +901 -0
- package/dist/data/buttons-data.tsx +2327 -0
- package/dist/data/charts-data.tsx +102 -0
- package/dist/data/chat-data.tsx +83 -0
- package/dist/data/code-data.tsx +1040 -0
- package/dist/data/comboboxes-data.tsx +1843 -0
- package/dist/data/command-data.tsx +1381 -0
- package/dist/data/core-data.tsx +15953 -0
- package/dist/data/crm-data.tsx +47 -0
- package/dist/data/data.tsx +159 -0
- package/dist/data/date-and-time-data.tsx +554 -0
- package/dist/data/dependencies.tsx +7 -0
- package/dist/data/ecommerce-data.tsx +1387 -0
- package/dist/data/forms-data.tsx +7890 -0
- package/dist/data/hooks-data.tsx +5487 -0
- package/dist/data/index.ts +34 -0
- package/dist/data/inputs-data.tsx +557 -0
- package/dist/data/interactive-data.tsx +5394 -0
- package/dist/data/lofi-data.tsx +18295 -0
- package/dist/data/marketing-data.tsx +2546 -0
- package/dist/data/media-data.tsx +1510 -0
- package/dist/data/motion-data.tsx +5801 -0
- package/dist/data/overlay-data.tsx +4136 -0
- package/dist/data/pdf-data.tsx +124 -0
- package/dist/data/pos-data.tsx +213 -0
- package/dist/data/postcss.config.js +6 -0
- package/dist/data/primitive-data.tsx +5170 -0
- package/dist/data/prompt-data.tsx +1226 -0
- package/dist/data/requiredLibs.ts +4 -0
- package/dist/data/sandbox-data.tsx +1 -0
- package/dist/data/sidebars-data.tsx +5421 -0
- package/dist/data/stacks-data.tsx +32 -0
- package/dist/data/table-data.tsx +706 -0
- package/dist/data/tailwind.config.js +270 -0
- package/dist/data/tailwind.config.ngin.js +3830 -0
- package/dist/data/tailwind.css +431 -0
- package/dist/data/tools-data.tsx +6910 -0
- package/dist/data/typography-data.tsx +2050 -0
- package/dist/data/utils-data.tsx +6500 -0
- package/dist/data/x-data.tsx +1171 -0
- package/dist/data.tsx +159 -0
- package/package.json +1 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -362
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// app/hooks/index.ts
|
|
2
|
+
import { useState, useEffect, useRef, useCallback } from 'react';
|
|
3
|
+
|
|
4
|
+
export function useTimeout(callback: () => void, delay: number | null) {
|
|
5
|
+
const savedCallback = useRef<() => void>();
|
|
6
|
+
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
savedCallback.current = callback;
|
|
9
|
+
}, [callback]);
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (delay !== null) {
|
|
13
|
+
const id = setTimeout(() => {
|
|
14
|
+
if (savedCallback.current) {
|
|
15
|
+
savedCallback.current();
|
|
16
|
+
}
|
|
17
|
+
}, delay);
|
|
18
|
+
return () => clearTimeout(id);
|
|
19
|
+
}
|
|
20
|
+
}, [delay]);
|
|
21
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback, useRef } from "react";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export type UseTimerReturn = {
|
|
5
|
+
/** Total elapsed seconds */
|
|
6
|
+
elapsedTime: number
|
|
7
|
+
/** Current milliseconds (0-999) */
|
|
8
|
+
milliseconds: number
|
|
9
|
+
/** Formatted time strings */
|
|
10
|
+
formattedTime: {
|
|
11
|
+
seconds: string
|
|
12
|
+
milliseconds: string
|
|
13
|
+
display: string
|
|
14
|
+
}
|
|
15
|
+
/** Whether timer is currently running */
|
|
16
|
+
isRunning: boolean
|
|
17
|
+
/** Reset timer to 0 */
|
|
18
|
+
reset: () => void
|
|
19
|
+
/** Start the timer */
|
|
20
|
+
start: () => void
|
|
21
|
+
/** Stop the timer */
|
|
22
|
+
stop: () => void
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function useTimer({
|
|
26
|
+
loading = false,
|
|
27
|
+
onTick,
|
|
28
|
+
resetOnLoadingChange = true,
|
|
29
|
+
format = "SS.MS",
|
|
30
|
+
}: UseTimerOptions = {}): UseTimerReturn {
|
|
31
|
+
const [elapsedTime, setElapsedTime] = useState(0)
|
|
32
|
+
const [milliseconds, setMilliseconds] = useState(0)
|
|
33
|
+
const [isRunning, setIsRunning] = useState(false)
|
|
34
|
+
const startTimeRef = useRef<number>(0)
|
|
35
|
+
const rafRef = useRef<number | null>(null)
|
|
36
|
+
|
|
37
|
+
const reset = useCallback(() => {
|
|
38
|
+
setElapsedTime(0)
|
|
39
|
+
setMilliseconds(0)
|
|
40
|
+
startTimeRef.current = 0
|
|
41
|
+
}, [])
|
|
42
|
+
|
|
43
|
+
const start = useCallback(() => {
|
|
44
|
+
setIsRunning(true)
|
|
45
|
+
startTimeRef.current = performance.now()
|
|
46
|
+
}, [])
|
|
47
|
+
|
|
48
|
+
const stop = useCallback(() => {
|
|
49
|
+
setIsRunning(false)
|
|
50
|
+
if (rafRef.current) {
|
|
51
|
+
cancelAnimationFrame(rafRef.current)
|
|
52
|
+
}
|
|
53
|
+
}, [])
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (!isRunning) return
|
|
57
|
+
|
|
58
|
+
const updateTimer = () => {
|
|
59
|
+
const now = performance.now()
|
|
60
|
+
const elapsed = now - startTimeRef.current
|
|
61
|
+
|
|
62
|
+
const newElapsedTime = Math.floor(elapsed / 1000)
|
|
63
|
+
const newMilliseconds = Math.floor(elapsed % 1000)
|
|
64
|
+
|
|
65
|
+
setElapsedTime(newElapsedTime)
|
|
66
|
+
setMilliseconds(newMilliseconds)
|
|
67
|
+
|
|
68
|
+
rafRef.current = requestAnimationFrame(updateTimer)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
rafRef.current = requestAnimationFrame(updateTimer)
|
|
72
|
+
|
|
73
|
+
return () => {
|
|
74
|
+
if (rafRef.current) {
|
|
75
|
+
cancelAnimationFrame(rafRef.current)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}, [isRunning])
|
|
79
|
+
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (loading) {
|
|
82
|
+
if (resetOnLoadingChange) {
|
|
83
|
+
reset()
|
|
84
|
+
}
|
|
85
|
+
start()
|
|
86
|
+
} else {
|
|
87
|
+
stop()
|
|
88
|
+
}
|
|
89
|
+
}, [loading, resetOnLoadingChange, reset, start, stop])
|
|
90
|
+
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (onTick) {
|
|
93
|
+
onTick(elapsedTime, milliseconds)
|
|
94
|
+
}
|
|
95
|
+
}, [elapsedTime, milliseconds, onTick])
|
|
96
|
+
|
|
97
|
+
const formatTime = useCallback(
|
|
98
|
+
(totalSeconds: number, ms: number) => {
|
|
99
|
+
const hours = Math.floor(totalSeconds / 3600)
|
|
100
|
+
const minutes = Math.floor((totalSeconds % 3600) / 60)
|
|
101
|
+
const seconds = totalSeconds % 60
|
|
102
|
+
|
|
103
|
+
switch (format) {
|
|
104
|
+
case "HH:MM:SS":
|
|
105
|
+
return {
|
|
106
|
+
seconds: seconds.toString().padStart(2, "0"),
|
|
107
|
+
milliseconds: Math.floor(ms / 10)
|
|
108
|
+
.toString()
|
|
109
|
+
.padStart(2, "0"),
|
|
110
|
+
display: `${hours.toString().padStart(2, "0")}:${minutes
|
|
111
|
+
.toString()
|
|
112
|
+
.padStart(2, "0")}:${seconds.toString().padStart(2, "0")}`,
|
|
113
|
+
}
|
|
114
|
+
case "MM:SS":
|
|
115
|
+
const totalMinutes = Math.floor(totalSeconds / 60)
|
|
116
|
+
const remainingSeconds = totalSeconds % 60
|
|
117
|
+
return {
|
|
118
|
+
seconds: remainingSeconds.toString().padStart(2, "0"),
|
|
119
|
+
milliseconds: Math.floor(ms / 10)
|
|
120
|
+
.toString()
|
|
121
|
+
.padStart(2, "0"),
|
|
122
|
+
display: `${totalMinutes
|
|
123
|
+
.toString()
|
|
124
|
+
.padStart(2, "0")}:${remainingSeconds
|
|
125
|
+
.toString()
|
|
126
|
+
.padStart(2, "0")}`,
|
|
127
|
+
}
|
|
128
|
+
case "SS.MS":
|
|
129
|
+
default:
|
|
130
|
+
return {
|
|
131
|
+
seconds: totalSeconds.toString().padStart(2, "0"),
|
|
132
|
+
milliseconds: Math.floor(ms / 10)
|
|
133
|
+
.toString()
|
|
134
|
+
.padStart(2, "0"),
|
|
135
|
+
display: `${totalSeconds.toString().padStart(2, "0")}.${Math.floor(
|
|
136
|
+
ms / 10
|
|
137
|
+
)
|
|
138
|
+
.toString()
|
|
139
|
+
.padStart(2, "0")}`,
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
[format]
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
const formattedTime = formatTime(elapsedTime, milliseconds)
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
elapsedTime,
|
|
150
|
+
milliseconds,
|
|
151
|
+
formattedTime,
|
|
152
|
+
isRunning,
|
|
153
|
+
reset,
|
|
154
|
+
start,
|
|
155
|
+
stop,
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
/**export function useTimer({ interval, callback, immediate = false }: TimerOptions) {
|
|
163
|
+
const [isRunning, setIsRunning] = useState(false);
|
|
164
|
+
const intervalRef = useRef<NodeJS.Timeout>();
|
|
165
|
+
const callbackRef = useRef(callback);
|
|
166
|
+
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
callbackRef.current = callback;
|
|
169
|
+
}, [callback]);
|
|
170
|
+
|
|
171
|
+
const start = useCallback(() => {
|
|
172
|
+
if (intervalRef.current) return;
|
|
173
|
+
|
|
174
|
+
setIsRunning(true);
|
|
175
|
+
if (immediate) callbackRef.current();
|
|
176
|
+
|
|
177
|
+
intervalRef.current = setInterval(() => {
|
|
178
|
+
callbackRef.current();
|
|
179
|
+
}, interval);
|
|
180
|
+
}, [interval, immediate]);
|
|
181
|
+
|
|
182
|
+
const stop = useCallback(() => {
|
|
183
|
+
if (intervalRef.current) {
|
|
184
|
+
clearInterval(intervalRef.current);
|
|
185
|
+
intervalRef.current = undefined;
|
|
186
|
+
}
|
|
187
|
+
setIsRunning(false);
|
|
188
|
+
}, []);
|
|
189
|
+
|
|
190
|
+
const reset = useCallback(() => {
|
|
191
|
+
stop();
|
|
192
|
+
start();
|
|
193
|
+
}, [stop, start]);
|
|
194
|
+
|
|
195
|
+
useEffect(() => {
|
|
196
|
+
return () => {
|
|
197
|
+
if (intervalRef.current) {
|
|
198
|
+
clearInterval(intervalRef.current);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
}, []);
|
|
202
|
+
|
|
203
|
+
return { start, stop, reset, isRunning };
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// app/hooks/index.ts
|
|
2
|
+
import { useState, useEffect, useRef, useCallback } from 'react';
|
|
3
|
+
|
|
4
|
+
export function useToggle(initialValue = false) {
|
|
5
|
+
const [value, setValue] = useState<boolean>(initialValue);
|
|
6
|
+
|
|
7
|
+
const toggle = useCallback(() => setValue(v => !v), []);
|
|
8
|
+
const setTrue = useCallback(() => setValue(true), []);
|
|
9
|
+
const setFalse = useCallback(() => setValue(false), []);
|
|
10
|
+
|
|
11
|
+
return [value, toggle, setTrue, setFalse] as const;
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cn } from "~/components/catalyst-ui";
|
|
2
|
+
|
|
3
|
+
interface Props
|
|
4
|
+
extends React.DetailedHTMLProps<
|
|
5
|
+
React.ImgHTMLAttributes<HTMLImageElement>,
|
|
6
|
+
HTMLImageElement
|
|
7
|
+
> {}
|
|
8
|
+
|
|
9
|
+
export function Image({ src, alt, className, ...props }: Props) {
|
|
10
|
+
return (
|
|
11
|
+
<img src={src} alt={alt} className={cn("rounded", className)} {...props} />
|
|
12
|
+
);
|
|
13
|
+
}
|