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