@alkimi.org/ui-kit 0.1.14 → 0.1.15

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 (76) hide show
  1. package/README.github.md +49 -5
  2. package/README.md +69 -8
  3. package/README.npm.md +69 -8
  4. package/dist/HelveticaNowDisplay-Medium-CXVMKHU3.ttf +0 -0
  5. package/dist/HelveticaNowDisplay-Regular-O4IVE4NP.ttf +0 -0
  6. package/dist/chunk-2XHWLYXD.mjs +3 -0
  7. package/dist/chunk-2XHWLYXD.mjs.map +1 -0
  8. package/dist/chunk-74PDRKS7.js +3 -0
  9. package/dist/chunk-74PDRKS7.js.map +1 -0
  10. package/dist/chunk-BCAQUOTY.mjs +3 -0
  11. package/dist/chunk-BCAQUOTY.mjs.map +1 -0
  12. package/dist/chunk-FUYXCJOQ.js +3 -0
  13. package/dist/chunk-FUYXCJOQ.js.map +1 -0
  14. package/dist/chunk-IK3C7KV5.mjs +3 -0
  15. package/dist/chunk-IK3C7KV5.mjs.map +1 -0
  16. package/dist/chunk-JNEIOQGF.js +3 -0
  17. package/dist/chunk-JNEIOQGF.js.map +1 -0
  18. package/dist/chunk-R74QDO2Z.js +3 -0
  19. package/dist/chunk-R74QDO2Z.js.map +1 -0
  20. package/dist/chunk-S5TKCF6T.mjs +3 -0
  21. package/dist/chunk-S5TKCF6T.mjs.map +1 -0
  22. package/dist/chunk-SVWC2KRP.js +3 -0
  23. package/dist/chunk-SVWC2KRP.js.map +1 -0
  24. package/dist/chunk-WF73K6X2.mjs +3 -0
  25. package/dist/chunk-WF73K6X2.mjs.map +1 -0
  26. package/dist/chunk-WJXJQZGO.js +3 -0
  27. package/dist/chunk-WJXJQZGO.js.map +1 -0
  28. package/dist/chunk-XNHJPYUV.mjs +3 -0
  29. package/dist/chunk-XNHJPYUV.mjs.map +1 -0
  30. package/dist/components/GlitchLink.js +2 -88
  31. package/dist/components/GlitchLink.js.map +1 -1
  32. package/dist/components/GlitchLink.mjs +1 -57
  33. package/dist/components/GlitchLink.mjs.map +1 -1
  34. package/dist/components/PixelLoad.js +2 -181
  35. package/dist/components/PixelLoad.js.map +1 -1
  36. package/dist/components/PixelLoad.mjs +1 -146
  37. package/dist/components/PixelLoad.mjs.map +1 -1
  38. package/dist/components/TextDecoder.js +2 -284
  39. package/dist/components/TextDecoder.js.map +1 -1
  40. package/dist/components/TextDecoder.mjs +1 -257
  41. package/dist/components/TextDecoder.mjs.map +1 -1
  42. package/dist/components/button.d.mts +1 -1
  43. package/dist/components/button.d.ts +1 -1
  44. package/dist/components/button.js +2 -108
  45. package/dist/components/button.js.map +1 -1
  46. package/dist/components/button.mjs +2 -73
  47. package/dist/components/button.mjs.map +1 -1
  48. package/dist/components/card.js +2 -114
  49. package/dist/components/card.js.map +1 -1
  50. package/dist/components/card.mjs +2 -75
  51. package/dist/components/card.mjs.map +1 -1
  52. package/dist/components/tabs.d.mts +9 -0
  53. package/dist/components/tabs.d.ts +9 -0
  54. package/dist/components/tabs.js +3 -0
  55. package/dist/components/tabs.js.map +1 -0
  56. package/dist/components/tabs.mjs +3 -0
  57. package/dist/components/tabs.mjs.map +1 -0
  58. package/dist/fonts/fonts/HelveticaNowDisplay-Medium.ttf +0 -0
  59. package/dist/fonts/fonts/HelveticaNowDisplay-Regular.ttf +0 -0
  60. package/dist/index.css +1 -961
  61. package/dist/index.css.map +1 -1
  62. package/dist/index.d.mts +6 -9
  63. package/dist/index.d.ts +6 -9
  64. package/dist/index.js +2 -661
  65. package/dist/index.js.map +1 -1
  66. package/dist/index.mjs +2 -626
  67. package/dist/index.mjs.map +1 -1
  68. package/dist/styles.css +1 -961
  69. package/dist/styles.css.map +1 -1
  70. package/package.json +15 -39
  71. package/dist/lib/utils.d.mts +0 -5
  72. package/dist/lib/utils.d.ts +0 -5
  73. package/dist/lib/utils.js +0 -36
  74. package/dist/lib/utils.js.map +0 -1
  75. package/dist/lib/utils.mjs +0 -12
  76. package/dist/lib/utils.mjs.map +0 -1
package/dist/index.mjs CHANGED
@@ -1,627 +1,3 @@
1
- "use client"
2
-
3
- // src/components/button.tsx
4
- import * as React from "react";
5
- import { Slot } from "@radix-ui/react-slot";
6
- import { cva } from "class-variance-authority";
7
-
8
- // src/lib/utils.ts
9
- import { clsx } from "clsx";
10
- import { twMerge } from "tailwind-merge";
11
- function cn(...inputs) {
12
- return twMerge(clsx(inputs));
13
- }
14
-
15
- // src/components/button.tsx
16
- import { jsx, jsxs } from "react/jsx-runtime";
17
- var buttonVariants = cva(
18
- "inline-flex items-center cursor-pointer justify-center whitespace-nowrap rounded-3xl font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
19
- {
20
- variants: {
21
- variant: {
22
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
23
- destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
24
- outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
25
- secondary: "bg-secondary/80 text-secondary-foreground hover:bg-secondary",
26
- ghost: "hover:bg-accent hover:text-accent-foreground",
27
- link: "text-primary underline-offset-4 hover:underline"
28
- },
29
- size: {
30
- default: "h-9 px-4 py-2 text-base",
31
- sm: "h-8 text-sm px-3 py-2",
32
- lg: "h-10 px-8 py-2 text-base",
33
- icon: "h-9 w-9"
34
- }
35
- },
36
- defaultVariants: {
37
- variant: "default",
38
- size: "default"
39
- }
40
- }
41
- );
42
- var Button = React.forwardRef(
43
- ({
44
- className,
45
- variant,
46
- size,
47
- asChild = false,
48
- loading = false,
49
- icon,
50
- ...props
51
- }, ref) => {
52
- const Comp = asChild ? Slot : "button";
53
- return /* @__PURE__ */ jsxs(
54
- Comp,
55
- {
56
- className: cn(buttonVariants({ variant, size, className })),
57
- ref,
58
- disabled: loading || props.disabled,
59
- ...props,
60
- children: [
61
- loading && /* @__PURE__ */ jsx("div", { className: "mr-2 h-4 w-4 animate-spin rounded-full border border-primary-foreground border-t-transparent" }),
62
- !loading && icon && /* @__PURE__ */ jsx("span", { className: "mr-2", children: icon }),
63
- props.children
64
- ]
65
- }
66
- );
67
- }
68
- );
69
- Button.displayName = "Button";
70
-
71
- // src/components/tabs.tsx
72
- import * as TabsPrimitive from "@radix-ui/react-tabs";
73
- import { forwardRef as forwardRef2, useCallback, useEffect, useRef, useState } from "react";
74
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
75
- var Tabs = TabsPrimitive.Root;
76
- var TabsList = forwardRef2(({ className, ...props }, ref) => {
77
- const [indicatorStyle, setIndicatorStyle] = useState({
78
- left: 0,
79
- width: 0
80
- });
81
- const listRef = useRef(null);
82
- useEffect(() => {
83
- const updateIndicator = () => {
84
- if (!listRef.current) return;
85
- const activeTab = listRef.current.querySelector(
86
- '[data-state="active"]'
87
- );
88
- if (activeTab) {
89
- const listRect = listRef.current.getBoundingClientRect();
90
- const tabRect = activeTab.getBoundingClientRect();
91
- setIndicatorStyle({
92
- left: tabRect.left - listRect.left,
93
- width: tabRect.width
94
- });
95
- }
96
- };
97
- updateIndicator();
98
- const observer = new MutationObserver(updateIndicator);
99
- if (listRef.current) {
100
- observer.observe(listRef.current, {
101
- attributes: true,
102
- attributeFilter: ["data-state"],
103
- subtree: true
104
- });
105
- }
106
- window.addEventListener("resize", updateIndicator);
107
- return () => {
108
- observer.disconnect();
109
- window.removeEventListener("resize", updateIndicator);
110
- };
111
- }, []);
112
- const combinedRef = useCallback(
113
- (node) => {
114
- ;
115
- listRef.current = node;
116
- if (typeof ref === "function") {
117
- ref(node);
118
- } else if (ref) {
119
- ;
120
- ref.current = node;
121
- }
122
- },
123
- [ref]
124
- );
125
- return /* @__PURE__ */ jsxs2(
126
- TabsPrimitive.List,
127
- {
128
- ref: combinedRef,
129
- className: cn(
130
- "relative inline-flex items-center justify-center rounded-3xl bg-muted p-1 text-muted-foreground",
131
- className
132
- ),
133
- ...props,
134
- children: [
135
- /* @__PURE__ */ jsx2(
136
- "span",
137
- {
138
- className: "absolute h-[calc(100%-0.5rem)] rounded-3xl bg-background shadow-sm transition-all duration-200 ease-out",
139
- style: {
140
- left: `${indicatorStyle.left}px`,
141
- width: `${indicatorStyle.width}px`
142
- }
143
- }
144
- ),
145
- props.children
146
- ]
147
- }
148
- );
149
- });
150
- TabsList.displayName = TabsPrimitive.List.displayName;
151
- var TabsTrigger = forwardRef2(({ className, ...props }, ref) => /* @__PURE__ */ jsx2(
152
- TabsPrimitive.Trigger,
153
- {
154
- ref,
155
- className: cn(
156
- "relative inline-flex items-center justify-center whitespace-nowrap rounded-3xl px-3 py-1 text-sm font-medium ring-offset-background transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:text-foreground z-10",
157
- className
158
- ),
159
- ...props
160
- }
161
- ));
162
- TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
163
- var TabsContent = forwardRef2(({ className, ...props }, ref) => /* @__PURE__ */ jsx2(
164
- TabsPrimitive.Content,
165
- {
166
- ref,
167
- className: cn(
168
- "mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
169
- className
170
- ),
171
- ...props
172
- }
173
- ));
174
- TabsContent.displayName = TabsPrimitive.Content.displayName;
175
-
176
- // src/components/TextDecoder.tsx
177
- import React2, {
178
- useState as useState2,
179
- useEffect as useEffect2,
180
- useMemo,
181
- useRef as useRef2,
182
- Suspense
183
- } from "react";
184
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
185
- var SYMBOLS = ["\\", "-", "?", "/", "#", "!", "_", "+", "<", ">"];
186
- var MAX_ITERATIONS = 3;
187
- var SPEED = 400;
188
- var scrambleText = (input) => {
189
- if (!input) return "";
190
- return input.split(" ").map((word) => {
191
- if (!word) return "";
192
- const randomSymbol = SYMBOLS[Math.floor(Math.random() * SYMBOLS.length)];
193
- return randomSymbol.repeat(word.length);
194
- }).join(" ");
195
- };
196
- var extractText = (node) => {
197
- if (typeof node === "string" || typeof node === "number") {
198
- return String(node);
199
- }
200
- if (Array.isArray(node)) {
201
- return node.map(extractText).join("");
202
- }
203
- if (React2.isValidElement(node)) {
204
- const props = node.props;
205
- let result = "";
206
- if (typeof props.text === "string") {
207
- result += props.text;
208
- }
209
- if (typeof props.label === "string") {
210
- result += props.label;
211
- }
212
- if (typeof props.title === "string") {
213
- result += props.title;
214
- }
215
- if (props.children) {
216
- result += extractText(props.children);
217
- }
218
- return result;
219
- }
220
- return "";
221
- };
222
- var scrambleReactNode = (node, scrambledText, textStartIndex) => {
223
- if (typeof node === "string" || typeof node === "number") {
224
- const text = String(node);
225
- let scrambled = "";
226
- for (let i = 0; i < text.length; i++) {
227
- if (textStartIndex.current < scrambledText.length) {
228
- scrambled += scrambledText[textStartIndex.current];
229
- textStartIndex.current++;
230
- } else {
231
- scrambled += text[i];
232
- }
233
- }
234
- return scrambled;
235
- }
236
- if (Array.isArray(node)) {
237
- return node.map((child, index) => {
238
- const scrambledChild = scrambleReactNode(
239
- child,
240
- scrambledText,
241
- textStartIndex
242
- );
243
- if (React2.isValidElement(scrambledChild)) {
244
- const originalKey = React2.isValidElement(child) ? child.key : null;
245
- if (scrambledChild.key == null && originalKey == null) {
246
- return React2.cloneElement(scrambledChild, { key: `decoded-${index}` });
247
- }
248
- if (scrambledChild.key == null && originalKey != null) {
249
- return React2.cloneElement(scrambledChild, { key: originalKey });
250
- }
251
- }
252
- return scrambledChild;
253
- });
254
- }
255
- if (React2.isValidElement(node)) {
256
- const props = node.props;
257
- const newProps = { ...props };
258
- if (typeof props.text === "string") {
259
- const text = props.text;
260
- let scrambled = "";
261
- for (let i = 0; i < text.length; i++) {
262
- if (textStartIndex.current < scrambledText.length) {
263
- scrambled += scrambledText[textStartIndex.current];
264
- textStartIndex.current++;
265
- } else {
266
- scrambled += text[i];
267
- }
268
- }
269
- newProps.text = scrambled;
270
- }
271
- if (typeof props.label === "string") {
272
- const label = props.label;
273
- let scrambled = "";
274
- for (let i = 0; i < label.length; i++) {
275
- if (textStartIndex.current < scrambledText.length) {
276
- scrambled += scrambledText[textStartIndex.current];
277
- textStartIndex.current++;
278
- } else {
279
- scrambled += label[i];
280
- }
281
- }
282
- newProps.label = scrambled;
283
- }
284
- if (typeof props.title === "string") {
285
- const title = props.title;
286
- let scrambled = "";
287
- for (let i = 0; i < title.length; i++) {
288
- if (textStartIndex.current < scrambledText.length) {
289
- scrambled += scrambledText[textStartIndex.current];
290
- textStartIndex.current++;
291
- } else {
292
- scrambled += title[i];
293
- }
294
- }
295
- newProps.title = scrambled;
296
- }
297
- if (props.children) {
298
- newProps.children = scrambleReactNode(
299
- props.children,
300
- scrambledText,
301
- textStartIndex
302
- );
303
- }
304
- return React2.cloneElement(node, newProps);
305
- }
306
- return node;
307
- };
308
- var TextDecoder = ({ children, className, delay = 0 }) => {
309
- const [displayContent, setDisplayContent] = useState2(null);
310
- const [hasAnimated, setHasAnimated] = useState2(false);
311
- const [showDecoded, setShowDecoded] = useState2(true);
312
- const elementRef = useRef2(null);
313
- const fullText = useMemo(() => extractText(children), [children]);
314
- const initialScrambled = useMemo(() => scrambleText(fullText), [fullText]);
315
- useEffect2(() => {
316
- if (!hasAnimated && fullText) {
317
- const textStartIndex = { current: 0 };
318
- const scrambledContent = scrambleReactNode(
319
- children,
320
- initialScrambled,
321
- textStartIndex
322
- );
323
- setDisplayContent(scrambledContent);
324
- setShowDecoded(true);
325
- }
326
- }, [children, initialScrambled, hasAnimated, fullText]);
327
- useEffect2(() => {
328
- if (!fullText) {
329
- setDisplayContent(null);
330
- setShowDecoded(false);
331
- return;
332
- }
333
- if (hasAnimated) {
334
- setShowDecoded(false);
335
- return;
336
- }
337
- const element = elementRef.current;
338
- if (!element) return;
339
- let iteration = 0;
340
- let intervalId = null;
341
- let delayTimeoutId = null;
342
- const observer = new IntersectionObserver(
343
- (entries) => {
344
- const entry = entries[0];
345
- if (entry.isIntersecting && !hasAnimated) {
346
- delayTimeoutId = setTimeout(() => {
347
- const textStartIndex = { current: 0 };
348
- const scrambledContent = scrambleReactNode(
349
- children,
350
- initialScrambled,
351
- textStartIndex
352
- );
353
- setDisplayContent(scrambledContent);
354
- setShowDecoded(true);
355
- intervalId = setInterval(() => {
356
- iteration++;
357
- if (iteration >= MAX_ITERATIONS) {
358
- setHasAnimated(true);
359
- setShowDecoded(false);
360
- if (intervalId) clearInterval(intervalId);
361
- } else {
362
- const newScrambled = scrambleText(fullText);
363
- const textStartIndex2 = { current: 0 };
364
- const scrambledContent2 = scrambleReactNode(
365
- children,
366
- newScrambled,
367
- textStartIndex2
368
- );
369
- setDisplayContent(scrambledContent2);
370
- }
371
- }, SPEED);
372
- }, delay);
373
- observer.disconnect();
374
- }
375
- },
376
- {
377
- threshold: 0.1
378
- // Trigger when 10% of the element is visible
379
- }
380
- );
381
- observer.observe(element);
382
- return () => {
383
- observer.disconnect();
384
- if (intervalId) clearInterval(intervalId);
385
- if (delayTimeoutId) clearTimeout(delayTimeoutId);
386
- };
387
- }, [children, fullText, initialScrambled, hasAnimated, delay]);
388
- const ariaLabel = useMemo(() => extractText(children), [children]);
389
- return /* @__PURE__ */ jsxs3(
390
- "span",
391
- {
392
- ref: elementRef,
393
- "aria-label": ariaLabel,
394
- className: cn("inline-grid *:col-start-1 *:row-start-1", className),
395
- children: [
396
- /* @__PURE__ */ jsx3(
397
- "span",
398
- {
399
- className: cn(
400
- "transition-opacity duration-300",
401
- hasAnimated ? "opacity-100" : "opacity-0"
402
- ),
403
- children
404
- }
405
- ),
406
- showDecoded && displayContent && /* @__PURE__ */ jsx3("span", { className: "transition-opacity duration-300", children: displayContent })
407
- ]
408
- }
409
- );
410
- };
411
- var SuspenseDecodedText = (props) => {
412
- return /* @__PURE__ */ jsx3(
413
- Suspense,
414
- {
415
- fallback: /* @__PURE__ */ jsx3("span", { className: cn("opacity-0", props.className), children: props.children }),
416
- children: /* @__PURE__ */ jsx3(TextDecoder, { ...props })
417
- }
418
- );
419
- };
420
- var TextDecoder_default = SuspenseDecodedText;
421
-
422
- // src/components/GlitchLink.tsx
423
- import Link from "next/link";
424
- import {
425
- useState as useState3,
426
- cloneElement,
427
- isValidElement
428
- } from "react";
429
- import { Slot as Slot2 } from "@radix-ui/react-slot";
430
- import { jsx as jsx4 } from "react/jsx-runtime";
431
- var DEFAULT_SYMBOLS = ["/", "#", "*"];
432
- var GlitchLink = ({
433
- href,
434
- children,
435
- symbols = DEFAULT_SYMBOLS,
436
- className,
437
- asChild = false,
438
- ...props
439
- }) => {
440
- const [isHovering, setIsHovering] = useState3(false);
441
- const getTextContent = (node) => {
442
- if (typeof node === "string") return node;
443
- if (isValidElement(node) && node.props.children) {
444
- return getTextContent(node.props.children);
445
- }
446
- return "";
447
- };
448
- const text = getTextContent(children);
449
- const getRandomGlitch = () => {
450
- if (!isHovering || !text) return text;
451
- return text.split(" ").map((word) => {
452
- const randomLetterIndex = Math.floor(Math.random() * word.length);
453
- return word.replace(
454
- word[randomLetterIndex],
455
- symbols[Math.floor(Math.random() * symbols.length)]
456
- );
457
- }).join(" ");
458
- };
459
- const commonProps = {
460
- className,
461
- onMouseEnter: () => setIsHovering(true),
462
- onMouseLeave: () => setIsHovering(false),
463
- ...props
464
- };
465
- if (asChild && isValidElement(children)) {
466
- const content2 = text ? isHovering ? getRandomGlitch() : text : children;
467
- return /* @__PURE__ */ jsx4(Slot2, { ...commonProps, children: cloneElement(children, {}, content2) });
468
- }
469
- const content = text ? isHovering ? getRandomGlitch() : children : children;
470
- return /* @__PURE__ */ jsx4(Link, { href: href || "#", ...commonProps, children: content });
471
- };
472
- var GlitchLink_default = GlitchLink;
473
-
474
- // src/components/PixelLoad.tsx
475
- import Image from "next/image";
476
- import { useCallback as useCallback2, useEffect as useEffect3, useRef as useRef3, useState as useState4 } from "react";
477
- import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
478
- function isStaticImageData(src) {
479
- return typeof src === "object" && "src" in src;
480
- }
481
- function getImageSrc(src) {
482
- return isStaticImageData(src) ? src.src : src;
483
- }
484
- function PixelLoad({
485
- src,
486
- alt,
487
- duration = 600,
488
- steps = 15,
489
- className,
490
- onAnimationComplete,
491
- priority,
492
- quality,
493
- placeholder = "empty",
494
- blurDataURL,
495
- objectFit = "cover"
496
- }) {
497
- const containerRef = useRef3(null);
498
- const canvasRef = useRef3(null);
499
- const [status, setStatus] = useState4("loading");
500
- const [dimensions, setDimensions] = useState4(null);
501
- const imageSrc = getImageSrc(src);
502
- const drawPixelated = useCallback2(
503
- (ctx, img, pixelSize, w, h) => {
504
- ctx.imageSmoothingEnabled = false;
505
- const sw = Math.max(1, Math.floor(w / pixelSize));
506
- const sh = Math.max(1, Math.floor(h / pixelSize));
507
- ctx.clearRect(0, 0, w, h);
508
- ctx.drawImage(img, 0, 0, sw, sh);
509
- ctx.drawImage(canvasRef.current, 0, 0, sw, sh, 0, 0, w, h);
510
- },
511
- []
512
- );
513
- const runAnimation = useCallback2(
514
- (ctx, img, w, h) => {
515
- const minPixelSize = Math.max(w, h) / 4;
516
- const intervalMs = duration / steps;
517
- let currentStep = 0;
518
- setStatus("animating");
519
- const animate = () => {
520
- const progress = currentStep / steps;
521
- const pixelSize = Math.max(1, Math.floor(minPixelSize * (1 - progress)));
522
- drawPixelated(ctx, img, pixelSize, w, h);
523
- currentStep++;
524
- if (currentStep <= steps) {
525
- window.setTimeout(animate, intervalMs);
526
- } else {
527
- setStatus("complete");
528
- onAnimationComplete?.();
529
- }
530
- };
531
- animate();
532
- },
533
- [duration, steps, drawPixelated, onAnimationComplete]
534
- );
535
- useEffect3(() => {
536
- const container = containerRef.current;
537
- if (!container) return;
538
- const updateDimensions = () => {
539
- const { width, height } = container.getBoundingClientRect();
540
- setDimensions({ width: Math.floor(width), height: Math.floor(height) });
541
- };
542
- const resizeObserver = new ResizeObserver(updateDimensions);
543
- resizeObserver.observe(container);
544
- updateDimensions();
545
- return () => {
546
- resizeObserver.disconnect();
547
- };
548
- }, []);
549
- useEffect3(() => {
550
- if (!dimensions) return;
551
- if (dimensions.width <= 0 || dimensions.height <= 0) return;
552
- const canvas = canvasRef.current;
553
- if (!canvas) return;
554
- const ctx = canvas.getContext("2d");
555
- if (!ctx) return;
556
- canvas.width = dimensions.width;
557
- canvas.height = dimensions.height;
558
- const img = new window.Image();
559
- img.crossOrigin = "anonymous";
560
- img.onload = () => {
561
- const minPixelSize = Math.max(dimensions.width, dimensions.height) / 4;
562
- drawPixelated(ctx, img, minPixelSize, dimensions.width, dimensions.height);
563
- runAnimation(ctx, img, dimensions.width, dimensions.height);
564
- };
565
- img.onerror = () => {
566
- console.error("PixelLoad: Failed to load image");
567
- };
568
- img.src = imageSrc;
569
- return () => {
570
- img.onload = null;
571
- img.onerror = null;
572
- };
573
- }, [imageSrc, dimensions, runAnimation, drawPixelated]);
574
- const isComplete = status === "complete";
575
- const isAnimating = status === "animating" || status === "loading";
576
- return /* @__PURE__ */ jsxs4(
577
- "div",
578
- {
579
- ref: containerRef,
580
- className: `relative w-full h-full ${className || ""}`,
581
- children: [
582
- /* @__PURE__ */ jsx5(
583
- "canvas",
584
- {
585
- ref: canvasRef,
586
- className: "absolute top-0 left-0 w-full h-full",
587
- style: {
588
- objectFit,
589
- opacity: isComplete ? 0 : 1,
590
- zIndex: isAnimating ? 2 : 1
591
- },
592
- "aria-hidden": isComplete
593
- }
594
- ),
595
- isComplete && /* @__PURE__ */ jsx5(
596
- Image,
597
- {
598
- src,
599
- alt,
600
- fill: true,
601
- priority,
602
- quality,
603
- placeholder,
604
- blurDataURL,
605
- className: "opacity-100 transition-opacity duration-150 ease-out z-[1]",
606
- style: {
607
- objectFit
608
- }
609
- }
610
- )
611
- ]
612
- }
613
- );
614
- }
615
- export {
616
- Button,
617
- GlitchLink_default as GlitchLink,
618
- PixelLoad,
619
- Tabs,
620
- TabsContent,
621
- TabsList,
622
- TabsTrigger,
623
- TextDecoder_default as TextDecoder,
624
- buttonVariants,
625
- cn
626
- };
1
+ "use client";
2
+ import{b as l}from"./chunk-IK3C7KV5.mjs";import{a as c}from"./chunk-WF73K6X2.mjs";import{a as s}from"./chunk-BCAQUOTY.mjs";import{a as r,b as e}from"./chunk-XNHJPYUV.mjs";import{a as i,b as o,c as a,d as n}from"./chunk-2XHWLYXD.mjs";import{a as t}from"./chunk-S5TKCF6T.mjs";export{e as Button,l as GlitchLink,c as PixelLoad,i as Tabs,n as TabsContent,o as TabsList,a as TabsTrigger,s as TextDecoder,r as buttonVariants,t as cn};
627
3
  //# sourceMappingURL=index.mjs.map