@constructive-io/ui 0.1.0

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 (176) hide show
  1. package/dist/components/alert-dialog.d.ts +31 -0
  2. package/dist/components/alert-dialog.js +314 -0
  3. package/dist/components/alert-dialog.js.map +1 -0
  4. package/dist/components/alert.d.ts +14 -0
  5. package/dist/components/alert.js +38 -0
  6. package/dist/components/alert.js.map +1 -0
  7. package/dist/components/autocomplete.d.ts +28 -0
  8. package/dist/components/autocomplete.js +395 -0
  9. package/dist/components/autocomplete.js.map +1 -0
  10. package/dist/components/avatar.d.ts +13 -0
  11. package/dist/components/avatar.js +37 -0
  12. package/dist/components/avatar.js.map +1 -0
  13. package/dist/components/badge.d.ts +15 -0
  14. package/dist/components/badge.js +43 -0
  15. package/dist/components/badge.js.map +1 -0
  16. package/dist/components/breadcrumb.d.ts +14 -0
  17. package/dist/components/breadcrumb.js +154 -0
  18. package/dist/components/breadcrumb.js.map +1 -0
  19. package/dist/components/button.d.ts +17 -0
  20. package/dist/components/button.js +62 -0
  21. package/dist/components/button.js.map +1 -0
  22. package/dist/components/calendar-rac.d.ts +13 -0
  23. package/dist/components/calendar-rac.js +82 -0
  24. package/dist/components/calendar-rac.js.map +1 -0
  25. package/dist/components/card.d.ts +19 -0
  26. package/dist/components/card.js +75 -0
  27. package/dist/components/card.js.map +1 -0
  28. package/dist/components/checkbox-group.d.ts +7 -0
  29. package/dist/components/checkbox-group.js +16 -0
  30. package/dist/components/checkbox-group.js.map +1 -0
  31. package/dist/components/checkbox.d.ts +8 -0
  32. package/dist/components/checkbox.js +67 -0
  33. package/dist/components/checkbox.js.map +1 -0
  34. package/dist/components/collapsible.d.ts +54 -0
  35. package/dist/components/collapsible.js +121 -0
  36. package/dist/components/collapsible.js.map +1 -0
  37. package/dist/components/combobox.d.ts +44 -0
  38. package/dist/components/combobox.js +486 -0
  39. package/dist/components/combobox.js.map +1 -0
  40. package/dist/components/command.d.ts +43 -0
  41. package/dist/components/command.js +690 -0
  42. package/dist/components/command.js.map +1 -0
  43. package/dist/components/dialog.d.ts +35 -0
  44. package/dist/components/dialog.js +440 -0
  45. package/dist/components/dialog.js.map +1 -0
  46. package/dist/components/dock.d.ts +31 -0
  47. package/dist/components/dock.js +111 -0
  48. package/dist/components/dock.js.map +1 -0
  49. package/dist/components/drawer.d.ts +16 -0
  50. package/dist/components/drawer.js +147 -0
  51. package/dist/components/drawer.js.map +1 -0
  52. package/dist/components/dropdown-menu.d.ts +50 -0
  53. package/dist/components/dropdown-menu.js +380 -0
  54. package/dist/components/dropdown-menu.js.map +1 -0
  55. package/dist/components/field.d.ts +51 -0
  56. package/dist/components/field.js +115 -0
  57. package/dist/components/field.js.map +1 -0
  58. package/dist/components/flickering-grid.d.ts +15 -0
  59. package/dist/components/flickering-grid.js +147 -0
  60. package/dist/components/flickering-grid.js.map +1 -0
  61. package/dist/components/form-control.d.ts +15 -0
  62. package/dist/components/form-control.js +173 -0
  63. package/dist/components/form-control.js.map +1 -0
  64. package/dist/components/form.d.ts +37 -0
  65. package/dist/components/form.js +179 -0
  66. package/dist/components/form.js.map +1 -0
  67. package/dist/components/input-group.d.ts +18 -0
  68. package/dist/components/input-group.js +177 -0
  69. package/dist/components/input-group.js.map +1 -0
  70. package/dist/components/input.d.ts +11 -0
  71. package/dist/components/input.js +60 -0
  72. package/dist/components/input.js.map +1 -0
  73. package/dist/components/json-input.d.ts +25 -0
  74. package/dist/components/json-input.js +351 -0
  75. package/dist/components/json-input.js.map +1 -0
  76. package/dist/components/label.d.ts +11 -0
  77. package/dist/components/label.js +27 -0
  78. package/dist/components/label.js.map +1 -0
  79. package/dist/components/motion-grid.d.ts +20 -0
  80. package/dist/components/motion-grid.js +81 -0
  81. package/dist/components/motion-grid.js.map +1 -0
  82. package/dist/components/multi-select.d.ts +198 -0
  83. package/dist/components/multi-select.js +882 -0
  84. package/dist/components/multi-select.js.map +1 -0
  85. package/dist/components/page-header.d.ts +17 -0
  86. package/dist/components/page-header.js +17 -0
  87. package/dist/components/page-header.js.map +1 -0
  88. package/dist/components/pagination.d.ts +19 -0
  89. package/dist/components/pagination.js +144 -0
  90. package/dist/components/pagination.js.map +1 -0
  91. package/dist/components/popover.d.ts +35 -0
  92. package/dist/components/popover.js +188 -0
  93. package/dist/components/popover.js.map +1 -0
  94. package/dist/components/portal.d.ts +108 -0
  95. package/dist/components/portal.js +75 -0
  96. package/dist/components/portal.js.map +1 -0
  97. package/dist/components/progress.d.ts +10 -0
  98. package/dist/components/progress.js +30 -0
  99. package/dist/components/progress.js.map +1 -0
  100. package/dist/components/progressive-blur-scroll-container.d.ts +25 -0
  101. package/dist/components/progressive-blur-scroll-container.js +142 -0
  102. package/dist/components/progressive-blur-scroll-container.js.map +1 -0
  103. package/dist/components/progressive-blur.d.ts +16 -0
  104. package/dist/components/progressive-blur.js +68 -0
  105. package/dist/components/progressive-blur.js.map +1 -0
  106. package/dist/components/radio-group.d.ts +10 -0
  107. package/dist/components/radio-group.js +37 -0
  108. package/dist/components/radio-group.js.map +1 -0
  109. package/dist/components/record-picker.d.ts +16 -0
  110. package/dist/components/record-picker.js +366 -0
  111. package/dist/components/record-picker.js.map +1 -0
  112. package/dist/components/resizable.d.ts +11 -0
  113. package/dist/components/resizable.js +52 -0
  114. package/dist/components/resizable.js.map +1 -0
  115. package/dist/components/responsive-diagram.d.ts +10 -0
  116. package/dist/components/responsive-diagram.js +63 -0
  117. package/dist/components/responsive-diagram.js.map +1 -0
  118. package/dist/components/scroll-area.d.ts +12 -0
  119. package/dist/components/scroll-area.js +69 -0
  120. package/dist/components/scroll-area.js.map +1 -0
  121. package/dist/components/select.d.ts +47 -0
  122. package/dist/components/select.js +287 -0
  123. package/dist/components/select.js.map +1 -0
  124. package/dist/components/separator.d.ts +11 -0
  125. package/dist/components/separator.js +24 -0
  126. package/dist/components/separator.js.map +1 -0
  127. package/dist/components/sheet.d.ts +112 -0
  128. package/dist/components/sheet.js +600 -0
  129. package/dist/components/sheet.js.map +1 -0
  130. package/dist/components/sidebar.d.ts +77 -0
  131. package/dist/components/sidebar.js +1217 -0
  132. package/dist/components/sidebar.js.map +1 -0
  133. package/dist/components/skeleton.d.ts +7 -0
  134. package/dist/components/skeleton.js +16 -0
  135. package/dist/components/skeleton.js.map +1 -0
  136. package/dist/components/sonner.d.ts +10 -0
  137. package/dist/components/sonner.js +23 -0
  138. package/dist/components/sonner.js.map +1 -0
  139. package/dist/components/stack/index.d.ts +663 -0
  140. package/dist/components/stack/index.js +1418 -0
  141. package/dist/components/stack/index.js.map +1 -0
  142. package/dist/components/stepper.d.ts +30 -0
  143. package/dist/components/stepper.js +280 -0
  144. package/dist/components/stepper.js.map +1 -0
  145. package/dist/components/switch.d.ts +8 -0
  146. package/dist/components/switch.js +40 -0
  147. package/dist/components/switch.js.map +1 -0
  148. package/dist/components/table.d.ts +15 -0
  149. package/dist/components/table.js +65 -0
  150. package/dist/components/table.js.map +1 -0
  151. package/dist/components/tabs.d.ts +10 -0
  152. package/dist/components/tabs.js +48 -0
  153. package/dist/components/tabs.js.map +1 -0
  154. package/dist/components/tags.d.ts +42 -0
  155. package/dist/components/tags.js +728 -0
  156. package/dist/components/tags.js.map +1 -0
  157. package/dist/components/textarea.d.ts +10 -0
  158. package/dist/components/textarea.js +54 -0
  159. package/dist/components/textarea.js.map +1 -0
  160. package/dist/components/toast/index.d.ts +52 -0
  161. package/dist/components/toast/index.js +221 -0
  162. package/dist/components/toast/index.js.map +1 -0
  163. package/dist/components/tooltip.d.ts +29 -0
  164. package/dist/components/tooltip.js +174 -0
  165. package/dist/components/tooltip.js.map +1 -0
  166. package/dist/components/unlink-button.d.ts +14 -0
  167. package/dist/components/unlink-button.js +91 -0
  168. package/dist/components/unlink-button.js.map +1 -0
  169. package/dist/index.cjs +7692 -0
  170. package/dist/index.cjs.map +1 -0
  171. package/dist/index.d.cts +2157 -0
  172. package/dist/index.d.ts +2157 -0
  173. package/dist/index.js +7375 -0
  174. package/dist/index.js.map +1 -0
  175. package/package.json +490 -0
  176. package/src/styles/globals.css +397 -0
@@ -0,0 +1,147 @@
1
+ "use client";
2
+ import { useRef, useState, useMemo, useCallback, useEffect } from 'react';
3
+ import { clsx } from 'clsx';
4
+ import { twMerge } from 'tailwind-merge';
5
+ import { jsx } from 'react/jsx-runtime';
6
+
7
+ function cn(...inputs) {
8
+ return twMerge(clsx(inputs));
9
+ }
10
+ var FlickeringGrid = ({
11
+ squareSize = 4,
12
+ gridGap = 6,
13
+ flickerChance = 0.3,
14
+ color = "rgb(0, 0, 0)",
15
+ width,
16
+ height,
17
+ className,
18
+ maxOpacity = 0.3,
19
+ ...props
20
+ }) => {
21
+ const canvasRef = useRef(null);
22
+ const containerRef = useRef(null);
23
+ const [isInView, setIsInView] = useState(false);
24
+ const [canvasSize, setCanvasSize] = useState({ width: 0, height: 0 });
25
+ const memoizedColor = useMemo(() => {
26
+ const toRGBA = (color2) => {
27
+ if (typeof window === "undefined") {
28
+ return `rgba(0, 0, 0,`;
29
+ }
30
+ const canvas = document.createElement("canvas");
31
+ canvas.width = canvas.height = 1;
32
+ const ctx = canvas.getContext("2d");
33
+ if (!ctx) return "rgba(255, 0, 0,";
34
+ ctx.fillStyle = color2;
35
+ ctx.fillRect(0, 0, 1, 1);
36
+ const [r, g, b] = Array.from(ctx.getImageData(0, 0, 1, 1).data);
37
+ return `rgba(${r}, ${g}, ${b},`;
38
+ };
39
+ return toRGBA(color);
40
+ }, [color]);
41
+ const setupCanvas = useCallback(
42
+ (canvas, width2, height2) => {
43
+ const dpr = window.devicePixelRatio || 1;
44
+ canvas.width = width2 * dpr;
45
+ canvas.height = height2 * dpr;
46
+ canvas.style.width = `${width2}px`;
47
+ canvas.style.height = `${height2}px`;
48
+ const cols = Math.floor(width2 / (squareSize + gridGap));
49
+ const rows = Math.floor(height2 / (squareSize + gridGap));
50
+ const squares = new Float32Array(cols * rows);
51
+ for (let i = 0; i < squares.length; i++) {
52
+ squares[i] = Math.random() * maxOpacity;
53
+ }
54
+ return { cols, rows, squares, dpr };
55
+ },
56
+ [squareSize, gridGap, maxOpacity]
57
+ );
58
+ const updateSquares = useCallback(
59
+ (squares, deltaTime) => {
60
+ for (let i = 0; i < squares.length; i++) {
61
+ if (Math.random() < flickerChance * deltaTime) {
62
+ squares[i] = Math.random() * maxOpacity;
63
+ }
64
+ }
65
+ },
66
+ [flickerChance, maxOpacity]
67
+ );
68
+ const drawGrid = useCallback(
69
+ (ctx, width2, height2, cols, rows, squares, dpr) => {
70
+ ctx.clearRect(0, 0, width2, height2);
71
+ ctx.fillStyle = "transparent";
72
+ ctx.fillRect(0, 0, width2, height2);
73
+ for (let i = 0; i < cols; i++) {
74
+ for (let j = 0; j < rows; j++) {
75
+ const opacity = squares[i * rows + j];
76
+ ctx.fillStyle = `${memoizedColor}${opacity})`;
77
+ ctx.fillRect(
78
+ i * (squareSize + gridGap) * dpr,
79
+ j * (squareSize + gridGap) * dpr,
80
+ squareSize * dpr,
81
+ squareSize * dpr
82
+ );
83
+ }
84
+ }
85
+ },
86
+ [memoizedColor, squareSize, gridGap]
87
+ );
88
+ useEffect(() => {
89
+ const canvas = canvasRef.current;
90
+ const container = containerRef.current;
91
+ if (!canvas || !container) return;
92
+ const ctx = canvas.getContext("2d");
93
+ if (!ctx) return;
94
+ let animationFrameId;
95
+ let gridParams;
96
+ const updateCanvasSize = () => {
97
+ const newWidth = width || container.clientWidth;
98
+ const newHeight = height || container.clientHeight;
99
+ setCanvasSize({ width: newWidth, height: newHeight });
100
+ gridParams = setupCanvas(canvas, newWidth, newHeight);
101
+ };
102
+ updateCanvasSize();
103
+ let lastTime = 0;
104
+ const animate = (time) => {
105
+ if (!isInView) return;
106
+ const deltaTime = (time - lastTime) / 1e3;
107
+ lastTime = time;
108
+ updateSquares(gridParams.squares, deltaTime);
109
+ drawGrid(ctx, canvas.width, canvas.height, gridParams.cols, gridParams.rows, gridParams.squares, gridParams.dpr);
110
+ animationFrameId = requestAnimationFrame(animate);
111
+ };
112
+ const resizeObserver = new ResizeObserver(() => {
113
+ updateCanvasSize();
114
+ });
115
+ resizeObserver.observe(container);
116
+ const intersectionObserver = new IntersectionObserver(
117
+ ([entry]) => {
118
+ setIsInView(entry.isIntersecting);
119
+ },
120
+ { threshold: 0 }
121
+ );
122
+ intersectionObserver.observe(canvas);
123
+ if (isInView) {
124
+ animationFrameId = requestAnimationFrame(animate);
125
+ }
126
+ return () => {
127
+ cancelAnimationFrame(animationFrameId);
128
+ resizeObserver.disconnect();
129
+ intersectionObserver.disconnect();
130
+ };
131
+ }, [setupCanvas, updateSquares, drawGrid, width, height, isInView]);
132
+ return /* @__PURE__ */ jsx("div", { ref: containerRef, className: cn(`h-full w-full ${className}`), ...props, children: /* @__PURE__ */ jsx(
133
+ "canvas",
134
+ {
135
+ ref: canvasRef,
136
+ className: "pointer-events-none",
137
+ style: {
138
+ width: canvasSize.width,
139
+ height: canvasSize.height
140
+ }
141
+ }
142
+ ) });
143
+ };
144
+
145
+ export { FlickeringGrid };
146
+ //# sourceMappingURL=flickering-grid.js.map
147
+ //# sourceMappingURL=flickering-grid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/utils.ts","../../src/components/flickering-grid.tsx"],"names":["color","width","height"],"mappings":";;;;;AAGO,SAAS,MAAM,MAAA,EAAsB;AAC1C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC7B;ACYO,IAAM,iBAAgD,CAAC;AAAA,EAC7D,UAAA,GAAa,CAAA;AAAA,EACb,OAAA,GAAU,CAAA;AAAA,EACV,aAAA,GAAgB,GAAA;AAAA,EAChB,KAAA,GAAQ,cAAA;AAAA,EACR,KAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA,GAAa,GAAA;AAAA,EACb,GAAG;AACJ,CAAA,KAAM;AACL,EAAA,MAAM,SAAA,GAAY,OAA0B,IAAI,CAAA;AAChD,EAAA,MAAM,YAAA,GAAe,OAAuB,IAA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AI,oBAAA;AAAA,MAChC,CAAC,CAAC,KAAK,CAAA,KAAM;AACZ,QAAA,WAAA,CAAY,MAAM,cAAc,CAAA;AAAA,MACjC,CAAA;AAAA,MACA,EAAE,WAAW,CAAA;AAAE,KAChB;AAEA,IAAA,oBAAA,CAAqB,QAAQ,MAAM,CAAA;AAEnC,IAAA,IAAI,QAAA,EAAU;AACb,MAAA,gBAAA,GAAmB,sBAAsB,OAAO,CAAA;AAAA,IACjD;AAEA,IAAA,OAAO,MAAM;AACZ,MAAA,oBAAA,CAAqB,gBAAgB,CAAA;AACrC,MAAA,cAAA,CAAe,UAAA,EAAW;AAC1B,MAAA,oBAAA,CAAqB,UAAA,EAAW;AAAA,IACjC,CAAA;AAAA,EACD,CAAA,EAAG,CAAC,WAAA,EAAa,aAAA,EAAe,UAAU,KAAA,EAAO,MAAA,EAAQ,QAAQ,CAAC,CAAA;AAElE,EAAA,uBACC,GAAA,CAAC,KAAA,EAAA,EAAI,GAAA,EAAK,YAAA,EAAc,SAAA,EAAW,EAAA,CAAG,CAAA,cAAA,EAAiB,SAAS,CAAA,CAAE,CAAA,EAAI,GAAG,KAAA,EACxE,QAAA,kBAAA,GAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACA,GAAA,EAAK,SAAA;AAAA,MACL,SAAA,EAAU,qBAAA;AAAA,MACV,KAAA,EAAO;AAAA,QACN,OAAO,UAAA,CAAW,KAAA;AAAA,QAClB,QAAQ,UAAA,CAAW;AAAA;AACpB;AAAA,GACD,EACD,CAAA;AAEF","file":"flickering-grid.js","sourcesContent":["import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","'use client';\n\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { cn } from '../lib/utils';\n\ninterface FlickeringGridProps extends React.HTMLAttributes<HTMLDivElement> {\n\tsquareSize?: number;\n\tgridGap?: number;\n\tflickerChance?: number;\n\tcolor?: string;\n\twidth?: number;\n\theight?: number;\n\tclassName?: string;\n\tmaxOpacity?: number;\n}\n\nexport const FlickeringGrid: React.FC<FlickeringGridProps> = ({\n\tsquareSize = 4,\n\tgridGap = 6,\n\tflickerChance = 0.3,\n\tcolor = 'rgb(0, 0, 0)',\n\twidth,\n\theight,\n\tclassName,\n\tmaxOpacity = 0.3,\n\t...props\n}) => {\n\tconst canvasRef = useRef<HTMLCanvasElement>(null);\n\tconst containerRef = useRef<HTMLDivElement>(null);\n\tconst [isInView, setIsInView] = useState(false);\n\tconst [canvasSize, setCanvasSize] = useState({ width: 0, height: 0 });\n\n\tconst memoizedColor = useMemo(() => {\n\t\tconst toRGBA = (color: string) => {\n\t\t\tif (typeof window === 'undefined') {\n\t\t\t\treturn `rgba(0, 0, 0,`;\n\t\t\t}\n\t\t\tconst canvas = document.createElement('canvas');\n\t\t\tcanvas.width = canvas.height = 1;\n\t\t\tconst ctx = canvas.getContext('2d');\n\t\t\tif (!ctx) return 'rgba(255, 0, 0,';\n\t\t\tctx.fillStyle = color;\n\t\t\tctx.fillRect(0, 0, 1, 1);\n\t\t\tconst [r, g, b] = Array.from(ctx.getImageData(0, 0, 1, 1).data);\n\t\t\treturn `rgba(${r}, ${g}, ${b},`;\n\t\t};\n\t\treturn toRGBA(color);\n\t}, [color]);\n\n\tconst setupCanvas = useCallback(\n\t\t(canvas: HTMLCanvasElement, width: number, height: number) => {\n\t\t\tconst dpr = window.devicePixelRatio || 1;\n\t\t\tcanvas.width = width * dpr;\n\t\t\tcanvas.height = height * dpr;\n\t\t\tcanvas.style.width = `${width}px`;\n\t\t\tcanvas.style.height = `${height}px`;\n\t\t\tconst cols = Math.floor(width / (squareSize + gridGap));\n\t\t\tconst rows = Math.floor(height / (squareSize + gridGap));\n\n\t\t\tconst squares = new Float32Array(cols * rows);\n\t\t\tfor (let i = 0; i < squares.length; i++) {\n\t\t\t\tsquares[i] = Math.random() * maxOpacity;\n\t\t\t}\n\n\t\t\treturn { cols, rows, squares, dpr };\n\t\t},\n\t\t[squareSize, gridGap, maxOpacity],\n\t);\n\n\tconst updateSquares = useCallback(\n\t\t(squares: Float32Array, deltaTime: number) => {\n\t\t\tfor (let i = 0; i < squares.length; i++) {\n\t\t\t\tif (Math.random() < flickerChance * deltaTime) {\n\t\t\t\t\tsquares[i] = Math.random() * maxOpacity;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[flickerChance, maxOpacity],\n\t);\n\n\tconst drawGrid = useCallback(\n\t\t(\n\t\t\tctx: CanvasRenderingContext2D,\n\t\t\twidth: number,\n\t\t\theight: number,\n\t\t\tcols: number,\n\t\t\trows: number,\n\t\t\tsquares: Float32Array,\n\t\t\tdpr: number,\n\t\t) => {\n\t\t\tctx.clearRect(0, 0, width, height);\n\t\t\tctx.fillStyle = 'transparent';\n\t\t\tctx.fillRect(0, 0, width, height);\n\n\t\t\tfor (let i = 0; i < cols; i++) {\n\t\t\t\tfor (let j = 0; j < rows; j++) {\n\t\t\t\t\tconst opacity = squares[i * rows + j];\n\t\t\t\t\tctx.fillStyle = `${memoizedColor}${opacity})`;\n\t\t\t\t\tctx.fillRect(\n\t\t\t\t\t\ti * (squareSize + gridGap) * dpr,\n\t\t\t\t\t\tj * (squareSize + gridGap) * dpr,\n\t\t\t\t\t\tsquareSize * dpr,\n\t\t\t\t\t\tsquareSize * dpr,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[memoizedColor, squareSize, gridGap],\n\t);\n\n\tuseEffect(() => {\n\t\tconst canvas = canvasRef.current;\n\t\tconst container = containerRef.current;\n\t\tif (!canvas || !container) return;\n\n\t\tconst ctx = canvas.getContext('2d');\n\t\tif (!ctx) return;\n\n\t\tlet animationFrameId: number;\n\t\tlet gridParams: ReturnType<typeof setupCanvas>;\n\n\t\tconst updateCanvasSize = () => {\n\t\t\tconst newWidth = width || container.clientWidth;\n\t\t\tconst newHeight = height || container.clientHeight;\n\t\t\tsetCanvasSize({ width: newWidth, height: newHeight });\n\t\t\tgridParams = setupCanvas(canvas, newWidth, newHeight);\n\t\t};\n\n\t\tupdateCanvasSize();\n\n\t\tlet lastTime = 0;\n\t\tconst animate = (time: number) => {\n\t\t\tif (!isInView) return;\n\n\t\t\tconst deltaTime = (time - lastTime) / 1000;\n\t\t\tlastTime = time;\n\n\t\t\tupdateSquares(gridParams.squares, deltaTime);\n\t\t\tdrawGrid(ctx, canvas.width, canvas.height, gridParams.cols, gridParams.rows, gridParams.squares, gridParams.dpr);\n\t\t\tanimationFrameId = requestAnimationFrame(animate);\n\t\t};\n\n\t\tconst resizeObserver = new ResizeObserver(() => {\n\t\t\tupdateCanvasSize();\n\t\t});\n\n\t\tresizeObserver.observe(container);\n\n\t\tconst intersectionObserver = new IntersectionObserver(\n\t\t\t([entry]) => {\n\t\t\t\tsetIsInView(entry.isIntersecting);\n\t\t\t},\n\t\t\t{ threshold: 0 },\n\t\t);\n\n\t\tintersectionObserver.observe(canvas);\n\n\t\tif (isInView) {\n\t\t\tanimationFrameId = requestAnimationFrame(animate);\n\t\t}\n\n\t\treturn () => {\n\t\t\tcancelAnimationFrame(animationFrameId);\n\t\t\tresizeObserver.disconnect();\n\t\t\tintersectionObserver.disconnect();\n\t\t};\n\t}, [setupCanvas, updateSquares, drawGrid, width, height, isInView]);\n\n\treturn (\n\t\t<div ref={containerRef} className={cn(`h-full w-full ${className}`)} {...props}>\n\t\t\t<canvas\n\t\t\t\tref={canvasRef}\n\t\t\t\tclassName='pointer-events-none'\n\t\t\t\tstyle={{\n\t\t\t\t\twidth: canvasSize.width,\n\t\t\t\t\theight: canvasSize.height,\n\t\t\t\t}}\n\t\t\t/>\n\t\t</div>\n\t);\n};\n"]}
@@ -0,0 +1,15 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+
4
+ type FormControlLayout = 'stacked' | 'floating';
5
+ interface FormControlProps {
6
+ children: React.ReactElement;
7
+ label: string;
8
+ id?: string;
9
+ layout?: FormControlLayout;
10
+ error?: string;
11
+ className?: string;
12
+ }
13
+ declare function FormControl({ children, label, id, layout, error, className }: FormControlProps): react_jsx_runtime.JSX.Element;
14
+
15
+ export { FormControl, type FormControlLayout };
@@ -0,0 +1,173 @@
1
+ "use client";
2
+ import * as React from 'react';
3
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
4
+ import { clsx } from 'clsx';
5
+ import { twMerge } from 'tailwind-merge';
6
+
7
+ function composeRefs(...refs) {
8
+ return (node) => {
9
+ refs.forEach((ref) => {
10
+ if (typeof ref === "function") {
11
+ ref(node);
12
+ } else if (ref != null) {
13
+ ref.current = node;
14
+ }
15
+ });
16
+ };
17
+ }
18
+ function mergeProps(slotProps, childProps) {
19
+ const overrideProps = { ...childProps };
20
+ for (const propName in childProps) {
21
+ if (propName === "ref") continue;
22
+ const slotPropValue = slotProps[propName];
23
+ const childPropValue = childProps[propName];
24
+ if (/^on[A-Z]/.test(propName) && typeof slotPropValue === "function" && typeof childPropValue === "function") {
25
+ overrideProps[propName] = (...args) => {
26
+ childPropValue(...args);
27
+ slotPropValue(...args);
28
+ };
29
+ } else if (propName === "className" && typeof slotPropValue === "string" && typeof childPropValue === "string") {
30
+ overrideProps[propName] = `${slotPropValue} ${childPropValue}`.trim();
31
+ } else if (propName === "style" && typeof slotPropValue === "object" && typeof childPropValue === "object") {
32
+ overrideProps[propName] = { ...slotPropValue, ...childPropValue };
33
+ }
34
+ }
35
+ return { ...slotProps, ...overrideProps };
36
+ }
37
+ function isSlottable(child) {
38
+ return React.isValidElement(child);
39
+ }
40
+ var Slot = React.forwardRef((props, forwardedRef) => {
41
+ const { children, ...slotProps } = props;
42
+ if (isSlottable(children)) {
43
+ const childProps = children.props;
44
+ const childRef = childProps.ref;
45
+ return React.cloneElement(children, {
46
+ ...mergeProps(slotProps, childProps),
47
+ ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef
48
+ });
49
+ }
50
+ if (React.Children.count(children) > 1) {
51
+ const childrenArray = React.Children.toArray(children);
52
+ const slottableChild = childrenArray.find(
53
+ (child) => React.isValidElement(child) && child.type === Slottable
54
+ );
55
+ if (slottableChild) {
56
+ const newElement = slottableChild.props.children;
57
+ if (isSlottable(newElement)) {
58
+ const newElementProps = newElement.props;
59
+ const newChildren = childrenArray.map((child) => {
60
+ if (child === slottableChild) {
61
+ return React.Children.count(newElementProps.children) > 1 ? React.Children.only(null) : newElementProps.children;
62
+ }
63
+ return child;
64
+ });
65
+ const childRef = newElementProps.ref;
66
+ return React.cloneElement(newElement, {
67
+ ...mergeProps(slotProps, newElementProps),
68
+ ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef,
69
+ children: newChildren
70
+ });
71
+ }
72
+ }
73
+ }
74
+ return /* @__PURE__ */ jsx(Fragment, { children });
75
+ });
76
+ Slot.displayName = "Slot";
77
+ function Slottable({ children }) {
78
+ return /* @__PURE__ */ jsx(Fragment, { children });
79
+ }
80
+ function cn(...inputs) {
81
+ return twMerge(clsx(inputs));
82
+ }
83
+ function Label({ className, ...props }) {
84
+ return /* @__PURE__ */ jsx(
85
+ "label",
86
+ {
87
+ "data-slot": "label",
88
+ className: cn(
89
+ `text-foreground text-sm leading-4 font-medium select-none group-data-[disabled=true]:pointer-events-none
90
+ group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50
91
+ data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,
92
+ className
93
+ ),
94
+ ...props
95
+ }
96
+ );
97
+ }
98
+ function FormControl({ children, label, id, layout = "stacked", error, className }) {
99
+ const generatedId = React.useId();
100
+ const inputId = id || generatedId;
101
+ const errorId = error ? `${inputId}-error` : void 0;
102
+ const childProps = {
103
+ id: inputId,
104
+ "aria-invalid": error ? true : void 0,
105
+ "aria-describedby": errorId
106
+ };
107
+ if (layout === "floating") {
108
+ childProps.placeholder = " ";
109
+ }
110
+ const childWithProps = React.cloneElement(children, childProps);
111
+ if (layout === "floating") {
112
+ return /* @__PURE__ */ jsxs("div", { className: cn("space-y-1", className), children: [
113
+ /* @__PURE__ */ jsxs(
114
+ "div",
115
+ {
116
+ className: cn(
117
+ "relative",
118
+ // Float label when focused
119
+ "has-[input:focus-visible]:[&_[data-slot=form-control-label]]:top-2",
120
+ "has-[input:focus-visible]:[&_[data-slot=form-control-label]]:translate-y-0",
121
+ "has-[input:focus-visible]:[&_[data-slot=form-control-label]]:scale-[0.7]",
122
+ "has-[input:focus-visible]:[&_[data-slot=form-control-label]]:text-primary/80",
123
+ // Float label when there's a value
124
+ "has-[input:not(:placeholder-shown)]:[&_[data-slot=form-control-label]]:top-2",
125
+ "has-[input:not(:placeholder-shown)]:[&_[data-slot=form-control-label]]:translate-y-0",
126
+ "has-[input:not(:placeholder-shown)]:[&_[data-slot=form-control-label]]:scale-[0.7]",
127
+ // Error
128
+ error && "has-[input:focus-visible]:[&_[data-slot=form-control-label]]:text-destructive"
129
+ ),
130
+ children: [
131
+ /* @__PURE__ */ jsx(
132
+ Slot,
133
+ {
134
+ className: cn(
135
+ error && "border-destructive focus-visible:ring-destructive/20"
136
+ ),
137
+ children: childWithProps
138
+ }
139
+ ),
140
+ /* @__PURE__ */ jsx(
141
+ Label,
142
+ {
143
+ htmlFor: inputId,
144
+ "data-slot": "form-control-label",
145
+ className: cn(
146
+ // Base: centered when empty
147
+ "pointer-events-none absolute start-3 top-1/2 -translate-y-1/2",
148
+ // Small, subtle typography
149
+ "origin-left text-[13px] leading-none font-normal text-muted-foreground/60 select-none",
150
+ // Snappy transition
151
+ "transition-[top,transform,color] duration-200 ease-out",
152
+ // Error state
153
+ error && "text-destructive"
154
+ ),
155
+ children: label
156
+ }
157
+ )
158
+ ]
159
+ }
160
+ ),
161
+ error && /* @__PURE__ */ jsx("p", { id: errorId, className: "text-destructive text-xs", role: "alert", children: error })
162
+ ] });
163
+ }
164
+ return /* @__PURE__ */ jsxs("div", { className: cn("grid gap-2", className), children: [
165
+ /* @__PURE__ */ jsx(Label, { htmlFor: inputId, className: cn(error && "text-destructive"), children: label }),
166
+ childWithProps,
167
+ error && /* @__PURE__ */ jsx("p", { id: errorId, className: "text-destructive text-sm", role: "alert", children: error })
168
+ ] });
169
+ }
170
+
171
+ export { FormControl };
172
+ //# sourceMappingURL=form-control.js.map
173
+ //# sourceMappingURL=form-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/slot.tsx","../../src/lib/utils.ts","../../src/components/label.tsx","../../src/components/form-control.tsx"],"names":["jsx","React2"],"mappings":";;;;;AAQA,SAAS,eAAkB,IAAA,EAA0D;AACpF,EAAA,OAAO,CAAC,IAAA,KAAS;AAChB,IAAA,IAAA,CAAK,OAAA,CAAQ,CAAC,GAAA,KAAQ;AACrB,MAAA,IAAI,OAAO,QAAQ,UAAA,EAAY;AAC9B,QAAA,GAAA,CAAI,IAAI,CAAA;AAAA,MACT,CAAA,MAAA,IAAW,OAAO,IAAA,EAAM;AACvB,QAAC,IAAyC,OAAA,GAAU,IAAA;AAAA,MACrD;AAAA,IACD,CAAC,CAAA;AAAA,EACF,CAAA;AACD;AAMA,SAAS,UAAA,CACR,WACA,UAAA,EAC0B;AAC1B,EAAA,MAAM,aAAA,GAAyC,EAAE,GAAG,UAAA,EAAW;AAE/D,EAAA,KAAA,MAAW,YAAY,UAAA,EAAY;AAElC,IAAA,IAAI,aAAa,KAAA,EAAO;AAExB,IAAA,MAAM,aAAA,GAAgB,UAAU,QAAQ,CAAA;AACxC,IAAA,MAAM,cAAA,GAAiB,WAAW,QAAQ,CAAA;AAG1C,IAAA,IAAI,UAAA,CAAW,KAAK,QAAQ,CAAA,IAAK,OAAO,aAAA,KAAkB,UAAA,IAAc,OAAO,cAAA,KAAmB,UAAA,EAAY;AAC7G,MAAA,aAAA,CAAc,QAAQ,CAAA,GAAI,CAAA,GAAI,IAAA,KAAoB;AACjD,QAAA,cAAA,CAAe,GAAG,IAAI,CAAA;AACtB,QAAA,aAAA,CAAc,GAAG,IAAI,CAAA;AAAA,MAC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ourcesContent":["'use client';\n\nimport * as React from 'react';\n\n/**\n * Merges refs into a single callback ref.\n * React 19 compatible - handles refs as regular props.\n */\nfunction composeRefs<T>(...refs: (React.Ref<T> | undefined)[]): React.RefCallback<T> {\n\treturn (node) => {\n\t\trefs.forEach((ref) => {\n\t\t\tif (typeof ref === 'function') {\n\t\t\t\tref(node);\n\t\t\t} else if (ref != null) {\n\t\t\t\t(ref as React.MutableRefObject<T | null>).current = node;\n\t\t\t}\n\t\t});\n\t};\n}\n\n/**\n * Merges props, handling special cases for className, style, and event handlers.\n * Excludes 'ref' from merging as it's handled separately.\n */\nfunction mergeProps(\n\tslotProps: Record<string, unknown>,\n\tchildProps: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst overrideProps: Record<string, unknown> = { ...childProps };\n\n\tfor (const propName in childProps) {\n\t\t// Skip ref - handled separately for composition\n\t\tif (propName === 'ref') continue;\n\n\t\tconst slotPropValue = slotProps[propName];\n\t\tconst childPropValue = childProps[propName];\n\n\t\t// Compose event handlers\n\t\tif (/^on[A-Z]/.test(propName) && typeof slotPropValue === 'function' && typeof childPropValue === 'function') {\n\t\t\toverrideProps[propName] = (...args: unknown[]) => {\n\t\t\t\tchildPropValue(...args);\n\t\t\t\tslotPropValue(...args);\n\t\t\t};\n\t\t}\n\t\t// Merge className\n\t\telse if (propName === 'className' && typeof slotPropValue === 'string' && typeof childPropValue === 'string') {\n\t\t\toverrideProps[propName] = `${slotPropValue} ${childPropValue}`.trim();\n\t\t}\n\t\t// Merge style\n\t\telse if (propName === 'style' && typeof slotPropValue === 'object' && typeof childPropValue === 'object') {\n\t\t\toverrideProps[propName] = { ...slotPropValue, ...childPropValue };\n\t\t}\n\t}\n\n\treturn { ...slotProps, ...overrideProps };\n}\n\n/**\n * Merges props from a parent component with a child element's props,\n * including proper ref composition. Use this in render prop patterns\n * where the parent needs to merge its props with the child's.\n *\n * @param parentProps - Props from the parent component (e.g., triggerProps from Base UI)\n * @param childElement - The child React element whose props will be merged\n * @returns Merged props object ready to pass to React.cloneElement\n */\nfunction mergePropsWithRef<T = HTMLElement>(\n\tparentProps: Record<string, unknown>,\n\tchildElement: React.ReactElement,\n): Record<string, unknown> {\n\tconst childProps = childElement.props as Record<string, unknown>;\n\tconst parentRef = parentProps.ref as React.Ref<T> | undefined;\n\tconst childRef = childProps.ref as React.Ref<T> | undefined;\n\n\tconst mergedProps = mergeProps(parentProps, childProps);\n\n\t// Compose refs if either exists\n\tif (parentRef || childRef) {\n\t\tmergedProps.ref = composeRefs(parentRef, childRef);\n\t}\n\n\treturn mergedProps;\n}\n\n/**\n * Check if a value is a valid slottable child (single React element).\n */\nfunction isSlottable(child: React.ReactNode): child is React.ReactElement {\n\treturn React.isValidElement(child);\n}\n\nexport interface SlotProps extends React.HTMLAttributes<HTMLElement> {\n\tchildren?: React.ReactNode;\n}\n\n/**\n * Slot component - renders its child element with merged props.\n * Used for the `asChild` pattern where parent props are passed to child.\n * React 19 compatible - accesses ref from props instead of element.ref.\n */\nconst Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n\tconst { children, ...slotProps } = props;\n\n\t// Handle single child\n\tif (isSlottable(children)) {\n\t\tconst childProps = children.props as Record<string, unknown>;\n\t\t// React 19: ref is now a regular prop, not element.ref\n\t\tconst childRef = childProps.ref as React.Ref<HTMLElement> | undefined;\n\n\t\treturn React.cloneElement(children, {\n\t\t\t...mergeProps(slotProps, childProps),\n\t\t\tref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef,\n\t\t} as React.Attributes);\n\t}\n\n\t// Handle multiple children - wrap Slottable content\n\tif (React.Children.count(children) > 1) {\n\t\tconst childrenArray = React.Children.toArray(children);\n\t\tconst slottableChild = childrenArray.find(\n\t\t\t(child) => React.isValidElement(child) && child.type === Slottable,\n\t\t) as React.ReactElement<{ children: React.ReactNode }> | undefined;\n\n\t\tif (slottableChild) {\n\t\t\tconst newElement = slottableChild.props.children;\n\t\t\tif (isSlottable(newElement)) {\n\t\t\t\tconst newElementProps = newElement.props as Record<string, unknown> & { children?: React.ReactNode };\n\t\t\t\tconst newChildren = childrenArray.map((child) => {\n\t\t\t\t\tif (child === slottableChild) {\n\t\t\t\t\t\treturn React.Children.count(newElementProps.children) > 1\n\t\t\t\t\t\t\t? React.Children.only(null)\n\t\t\t\t\t\t\t: newElementProps.children;\n\t\t\t\t\t}\n\t\t\t\t\treturn child;\n\t\t\t\t});\n\n\t\t\t\t// React 19: ref is now a regular prop\n\t\t\t\tconst childRef = newElementProps.ref as React.Ref<HTMLElement> | undefined;\n\n\t\t\t\treturn React.cloneElement(newElement, {\n\t\t\t\t\t...mergeProps(slotProps, newElementProps),\n\t\t\t\t\tref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef,\n\t\t\t\t\tchildren: newChildren,\n\t\t\t\t} as React.Attributes);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Fallback: render children as-is (shouldn't normally happen with proper usage)\n\treturn <>{children}</>;\n});\n\nSlot.displayName = 'Slot';\n\n/**\n * Slottable component - marks content that should receive slot props.\n * Used when Slot has multiple children and you want to specify which one receives props.\n */\nfunction Slottable({ children }: { children: React.ReactNode }) {\n\treturn <>{children}</>;\n}\n\nexport { Slot, Slottable, composeRefs, mergeProps, mergePropsWithRef };\n","import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","'use client';\n\nimport * as React from 'react';\n\nimport { cn } from '../lib/utils';\n\ntype LabelProps = React.ComponentProps<'label'>;\n\n/**\n * Label component for form controls.\n * Uses a standard HTML label element for maximum compatibility.\n */\nfunction Label({ className, ...props }: LabelProps) {\n\treturn (\n\t\t<label\n\t\t\tdata-slot=\"label\"\n\t\t\tclassName={cn(\n\t\t\t\t`text-foreground text-sm leading-4 font-medium select-none group-data-[disabled=true]:pointer-events-none\n\t\t\t\tgroup-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50\n\t\t\t\tdata-[disabled]:pointer-events-none data-[disabled]:opacity-50`,\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nexport { Label };\nexport type { LabelProps };\n","'use client';\n\nimport * as React from 'react';\nimport { Slot } from '../lib/slot';\n\nimport { cn } from '../lib/utils';\nimport { Label } from './label';\n\ntype FormControlLayout = 'stacked' | 'floating';\n\ninterface FormControlProps {\n children: React.ReactElement;\n label: string;\n id?: string;\n layout?: FormControlLayout;\n error?: string;\n className?: string;\n}\n\nfunction FormControl({ children, label, id, layout = 'stacked', error, className }: FormControlProps) {\n const generatedId = React.useId();\n const inputId = id || generatedId;\n const errorId = error ? `${inputId}-error` : undefined;\n\n const childProps: Record<string, unknown> = {\n id: inputId,\n 'aria-invalid': error ? true : undefined,\n 'aria-describedby': errorId,\n };\n\n if (layout === 'floating') {\n childProps.placeholder = ' ';\n }\n\n const childWithProps = React.cloneElement(children, childProps);\n\n if (layout === 'floating') {\n return (\n <div className={cn('space-y-1', className)}>\n <div\n className={cn(\n 'relative',\n // Float label when focused\n 'has-[input:focus-visible]:[&_[data-slot=form-control-label]]:top-2',\n 'has-[input:focus-visible]:[&_[data-slot=form-control-label]]:translate-y-0',\n 'has-[input:focus-visible]:[&_[data-slot=form-control-label]]:scale-[0.7]',\n 'has-[input:focus-visible]:[&_[data-slot=form-control-label]]:text-primary/80',\n // Float label when there's a value\n 'has-[input:not(:placeholder-shown)]:[&_[data-slot=form-control-label]]:top-2',\n 'has-[input:not(:placeholder-shown)]:[&_[data-slot=form-control-label]]:translate-y-0',\n 'has-[input:not(:placeholder-shown)]:[&_[data-slot=form-control-label]]:scale-[0.7]',\n // Error\n error && 'has-[input:focus-visible]:[&_[data-slot=form-control-label]]:text-destructive',\n )}\n >\n <Slot\n className={cn(\n error && 'border-destructive focus-visible:ring-destructive/20',\n )}\n >\n {childWithProps}\n </Slot>\n <Label\n htmlFor={inputId}\n data-slot='form-control-label'\n className={cn(\n // Base: centered when empty\n 'pointer-events-none absolute start-3 top-1/2 -translate-y-1/2',\n // Small, subtle typography\n 'origin-left text-[13px] leading-none font-normal text-muted-foreground/60 select-none',\n // Snappy transition\n 'transition-[top,transform,color] duration-200 ease-out',\n // Error state\n error && 'text-destructive',\n )}\n >\n {label}\n </Label>\n </div>\n {error && (\n <p id={errorId} className='text-destructive text-xs' role='alert'>\n {error}\n </p>\n )}\n </div>\n );\n }\n\n return (\n <div className={cn('grid gap-2', className)}>\n <Label htmlFor={inputId} className={cn(error && 'text-destructive')}>\n {label}\n </Label>\n {childWithProps}\n {error && (\n <p id={errorId} className='text-destructive text-sm' role='alert'>\n {error}\n </p>\n )}\n </div>\n );\n}\n\nexport { FormControl, type FormControlLayout };\n"]}
@@ -0,0 +1,37 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react_hook_form from 'react-hook-form';
3
+ import { FieldValues, FieldPath, ControllerProps } from 'react-hook-form';
4
+ import * as React from 'react';
5
+ import { Label } from './label.js';
6
+
7
+ interface SlotProps extends React.HTMLAttributes<HTMLElement> {
8
+ children?: React.ReactNode;
9
+ }
10
+ /**
11
+ * Slot component - renders its child element with merged props.
12
+ * Used for the `asChild` pattern where parent props are passed to child.
13
+ * React 19 compatible - accesses ref from props instead of element.ref.
14
+ */
15
+ declare const Slot: React.ForwardRefExoticComponent<SlotProps & React.RefAttributes<HTMLElement>>;
16
+
17
+ declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>(props: react_hook_form.FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
18
+ declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: ControllerProps<TFieldValues, TName>) => react_jsx_runtime.JSX.Element;
19
+ declare const useFormField: () => {
20
+ invalid: boolean;
21
+ isDirty: boolean;
22
+ isTouched: boolean;
23
+ isValidating: boolean;
24
+ error?: react_hook_form.FieldError;
25
+ id: string;
26
+ name: string;
27
+ formItemId: string;
28
+ formDescriptionId: string;
29
+ formMessageId: string;
30
+ };
31
+ declare function FormItem({ className, ...props }: React.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
32
+ declare function FormLabel({ className, ...props }: React.ComponentProps<typeof Label>): react_jsx_runtime.JSX.Element;
33
+ declare function FormControl({ ...props }: React.ComponentProps<typeof Slot>): react_jsx_runtime.JSX.Element;
34
+ declare function FormDescription({ className, ...props }: React.ComponentProps<'p'>): react_jsx_runtime.JSX.Element;
35
+ declare function FormMessage({ className, ...props }: React.ComponentProps<'p'>): react_jsx_runtime.JSX.Element | null;
36
+
37
+ export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField };
@@ -0,0 +1,179 @@
1
+ "use client";
2
+ import * as React from 'react';
3
+ import { jsx, Fragment } from 'react/jsx-runtime';
4
+ import { FormProvider, Controller, useFormContext, useFormState } from 'react-hook-form';
5
+ import { clsx } from 'clsx';
6
+ import { twMerge } from 'tailwind-merge';
7
+
8
+ function composeRefs(...refs) {
9
+ return (node) => {
10
+ refs.forEach((ref) => {
11
+ if (typeof ref === "function") {
12
+ ref(node);
13
+ } else if (ref != null) {
14
+ ref.current = node;
15
+ }
16
+ });
17
+ };
18
+ }
19
+ function mergeProps(slotProps, childProps) {
20
+ const overrideProps = { ...childProps };
21
+ for (const propName in childProps) {
22
+ if (propName === "ref") continue;
23
+ const slotPropValue = slotProps[propName];
24
+ const childPropValue = childProps[propName];
25
+ if (/^on[A-Z]/.test(propName) && typeof slotPropValue === "function" && typeof childPropValue === "function") {
26
+ overrideProps[propName] = (...args) => {
27
+ childPropValue(...args);
28
+ slotPropValue(...args);
29
+ };
30
+ } else if (propName === "className" && typeof slotPropValue === "string" && typeof childPropValue === "string") {
31
+ overrideProps[propName] = `${slotPropValue} ${childPropValue}`.trim();
32
+ } else if (propName === "style" && typeof slotPropValue === "object" && typeof childPropValue === "object") {
33
+ overrideProps[propName] = { ...slotPropValue, ...childPropValue };
34
+ }
35
+ }
36
+ return { ...slotProps, ...overrideProps };
37
+ }
38
+ function isSlottable(child) {
39
+ return React.isValidElement(child);
40
+ }
41
+ var Slot = React.forwardRef((props, forwardedRef) => {
42
+ const { children, ...slotProps } = props;
43
+ if (isSlottable(children)) {
44
+ const childProps = children.props;
45
+ const childRef = childProps.ref;
46
+ return React.cloneElement(children, {
47
+ ...mergeProps(slotProps, childProps),
48
+ ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef
49
+ });
50
+ }
51
+ if (React.Children.count(children) > 1) {
52
+ const childrenArray = React.Children.toArray(children);
53
+ const slottableChild = childrenArray.find(
54
+ (child) => React.isValidElement(child) && child.type === Slottable
55
+ );
56
+ if (slottableChild) {
57
+ const newElement = slottableChild.props.children;
58
+ if (isSlottable(newElement)) {
59
+ const newElementProps = newElement.props;
60
+ const newChildren = childrenArray.map((child) => {
61
+ if (child === slottableChild) {
62
+ return React.Children.count(newElementProps.children) > 1 ? React.Children.only(null) : newElementProps.children;
63
+ }
64
+ return child;
65
+ });
66
+ const childRef = newElementProps.ref;
67
+ return React.cloneElement(newElement, {
68
+ ...mergeProps(slotProps, newElementProps),
69
+ ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef,
70
+ children: newChildren
71
+ });
72
+ }
73
+ }
74
+ }
75
+ return /* @__PURE__ */ jsx(Fragment, { children });
76
+ });
77
+ Slot.displayName = "Slot";
78
+ function Slottable({ children }) {
79
+ return /* @__PURE__ */ jsx(Fragment, { children });
80
+ }
81
+ function cn(...inputs) {
82
+ return twMerge(clsx(inputs));
83
+ }
84
+ function Label({ className, ...props }) {
85
+ return /* @__PURE__ */ jsx(
86
+ "label",
87
+ {
88
+ "data-slot": "label",
89
+ className: cn(
90
+ `text-foreground text-sm leading-4 font-medium select-none group-data-[disabled=true]:pointer-events-none
91
+ group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50
92
+ data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,
93
+ className
94
+ ),
95
+ ...props
96
+ }
97
+ );
98
+ }
99
+ var Form = FormProvider;
100
+ var FormFieldContext = React.createContext({});
101
+ var FormField = ({
102
+ ...props
103
+ }) => {
104
+ return /* @__PURE__ */ jsx(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsx(Controller, { ...props }) });
105
+ };
106
+ var useFormField = () => {
107
+ const fieldContext = React.useContext(FormFieldContext);
108
+ const itemContext = React.useContext(FormItemContext);
109
+ const { getFieldState } = useFormContext();
110
+ const formState = useFormState({ name: fieldContext.name });
111
+ const fieldState = getFieldState(fieldContext.name, formState);
112
+ if (!fieldContext) {
113
+ throw new Error("useFormField should be used within <FormField>");
114
+ }
115
+ const { id } = itemContext;
116
+ return {
117
+ id,
118
+ name: fieldContext.name,
119
+ formItemId: `${id}-form-item`,
120
+ formDescriptionId: `${id}-form-item-description`,
121
+ formMessageId: `${id}-form-item-message`,
122
+ ...fieldState
123
+ };
124
+ };
125
+ var FormItemContext = React.createContext({});
126
+ function FormItem({ className, ...props }) {
127
+ const id = React.useId();
128
+ return /* @__PURE__ */ jsx(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsx("div", { "data-slot": "form-item", className: cn("grid gap-2", className), ...props }) });
129
+ }
130
+ function FormLabel({ className, ...props }) {
131
+ const { error, formItemId } = useFormField();
132
+ return /* @__PURE__ */ jsx(
133
+ Label,
134
+ {
135
+ "data-slot": "form-label",
136
+ "data-error": !!error,
137
+ className: cn("data-[error=true]:text-destructive", className),
138
+ htmlFor: formItemId,
139
+ ...props
140
+ }
141
+ );
142
+ }
143
+ function FormControl({ ...props }) {
144
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
145
+ return /* @__PURE__ */ jsx(
146
+ Slot,
147
+ {
148
+ "data-slot": "form-control",
149
+ id: formItemId,
150
+ "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
151
+ "aria-invalid": !!error,
152
+ ...props
153
+ }
154
+ );
155
+ }
156
+ function FormDescription({ className, ...props }) {
157
+ const { formDescriptionId } = useFormField();
158
+ return /* @__PURE__ */ jsx(
159
+ "p",
160
+ {
161
+ "data-slot": "form-description",
162
+ id: formDescriptionId,
163
+ className: cn("text-muted-foreground text-sm", className),
164
+ ...props
165
+ }
166
+ );
167
+ }
168
+ function FormMessage({ className, ...props }) {
169
+ const { error, formMessageId } = useFormField();
170
+ const body = error ? String(error?.message ?? "") : props.children;
171
+ if (!body) {
172
+ return null;
173
+ }
174
+ return /* @__PURE__ */ jsx("p", { "data-slot": "form-message", id: formMessageId, className: cn("text-destructive text-sm", className), ...props, children: body });
175
+ }
176
+
177
+ export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField };
178
+ //# sourceMappingURL=form.js.map
179
+ //# sourceMappingURL=form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/slot.tsx","../../src/lib/utils.ts","../../src/components/label.tsx","../../src/components/form.tsx"],"names":["jsx","React2"],"mappings":";;;;;;AAQA,SAAS,eAAkB,IAAA,EAA0D;AACpF,EAAA,OAAO,CAAC,IAAA,KAAS;AAChB,IAAA,IAAA,CAAK,OAAA,CAAQ,CAAC,GAAA,KAAQ;AACrB,MAAA,IAAI,OAAO,QAAQ,UAAA,EAAY;AAC9B,QAAA,GAAA,CAAI,IAAI,CAAA;AAAA,MACT,CAAA,MAAA,IAAW,OAAO,IAAA,EAAM;AACvB,QAAC,IAAyC,OAAA,GAAU,IAAA;AAAA,MACrD;AAAA,IACD,CAAC,CAAA;AAAA,EACF,CAAA;AACD;AAMA,SAAS,UAAA,CACR,WACA,UAAA,EAC0B;AAC1B,EAAA,MAAM,aAAA,GAAyC,EAAE,GAAG,UAAA,EAAW;AAE/D,EAAA,KAAA,MAAW,YAAY,UAAA,EAAY;AAElC,IAAA,IAAI,aAAa,KAAA,EAAO;AAExB,IAAA,MAAM,aAAA,GAAgB,UAAU,QAAQ,CAAA;AACxC,IAAA,MA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AAA,EAAI,aAAA,EAAe,SAAA,EAAW,EAAA,CAAG,0BAAA,EAA4B,SAAS,CAAA,EAAI,GAAG,OACvG,QAAA,EAAA,IAAA,EACF,CAAA;AAEF","file":"form.js","sourcesContent":["'use client';\n\nimport * as React from 'react';\n\n/**\n * Merges refs into a single callback ref.\n * React 19 compatible - handles refs as regular props.\n */\nfunction composeRefs<T>(...refs: (React.Ref<T> | undefined)[]): React.RefCallback<T> {\n\treturn (node) => {\n\t\trefs.forEach((ref) => {\n\t\t\tif (typeof ref === 'function') {\n\t\t\t\tref(node);\n\t\t\t} else if (ref != null) {\n\t\t\t\t(ref as React.MutableRefObject<T | null>).current = node;\n\t\t\t}\n\t\t});\n\t};\n}\n\n/**\n * Merges props, handling special cases for className, style, and event handlers.\n * Excludes 'ref' from merging as it's handled separately.\n */\nfunction mergeProps(\n\tslotProps: Record<string, unknown>,\n\tchildProps: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst overrideProps: Record<string, unknown> = { ...childProps };\n\n\tfor (const propName in childProps) {\n\t\t// Skip ref - handled separately for composition\n\t\tif (propName === 'ref') continue;\n\n\t\tconst slotPropValue = slotProps[propName];\n\t\tconst childPropValue = childProps[propName];\n\n\t\t// Compose event handlers\n\t\tif (/^on[A-Z]/.test(propName) && typeof slotPropValue === 'function' && typeof childPropValue === 'function') {\n\t\t\toverrideProps[propName] = (...args: unknown[]) => {\n\t\t\t\tchildPropValue(...args);\n\t\t\t\tslotPropValue(...args);\n\t\t\t};\n\t\t}\n\t\t// Merge className\n\t\telse if (propName === 'className' && typeof slotPropValue === 'string' && typeof childPropValue === 'string') {\n\t\t\toverrideProps[propName] = `${slotPropValue} ${childPropValue}`.trim();\n\t\t}\n\t\t// Merge style\n\t\telse if (propName === 'style' && typeof slotPropValue === 'object' && typeof childPropValue === 'object') {\n\t\t\toverrideProps[propName] = { ...slotPropValue, ...childPropValue };\n\t\t}\n\t}\n\n\treturn { ...slotProps, ...overrideProps };\n}\n\n/**\n * Merges props from a parent component with a child element's props,\n * including proper ref composition. Use this in render prop patterns\n * where the parent needs to merge its props with the child's.\n *\n * @param parentProps - Props from the parent component (e.g., triggerProps from Base UI)\n * @param childElement - The child React element whose props will be merged\n * @returns Merged props object ready to pass to React.cloneElement\n */\nfunction mergePropsWithRef<T = HTMLElement>(\n\tparentProps: Record<string, unknown>,\n\tchildElement: React.ReactElement,\n): Record<string, unknown> {\n\tconst childProps = childElement.props as Record<string, unknown>;\n\tconst parentRef = parentProps.ref as React.Ref<T> | undefined;\n\tconst childRef = childProps.ref as React.Ref<T> | undefined;\n\n\tconst mergedProps = mergeProps(parentProps, childProps);\n\n\t// Compose refs if either exists\n\tif (parentRef || childRef) {\n\t\tmergedProps.ref = composeRefs(parentRef, childRef);\n\t}\n\n\treturn mergedProps;\n}\n\n/**\n * Check if a value is a valid slottable child (single React element).\n */\nfunction isSlottable(child: React.ReactNode): child is React.ReactElement {\n\treturn React.isValidElement(child);\n}\n\nexport interface SlotProps extends React.HTMLAttributes<HTMLElement> {\n\tchildren?: React.ReactNode;\n}\n\n/**\n * Slot component - renders its child element with merged props.\n * Used for the `asChild` pattern where parent props are passed to child.\n * React 19 compatible - accesses ref from props instead of element.ref.\n */\nconst Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n\tconst { children, ...slotProps } = props;\n\n\t// Handle single child\n\tif (isSlottable(children)) {\n\t\tconst childProps = children.props as Record<string, unknown>;\n\t\t// React 19: ref is now a regular prop, not element.ref\n\t\tconst childRef = childProps.ref as React.Ref<HTMLElement> | undefined;\n\n\t\treturn React.cloneElement(children, {\n\t\t\t...mergeProps(slotProps, childProps),\n\t\t\tref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef,\n\t\t} as React.Attributes);\n\t}\n\n\t// Handle multiple children - wrap Slottable content\n\tif (React.Children.count(children) > 1) {\n\t\tconst childrenArray = React.Children.toArray(children);\n\t\tconst slottableChild = childrenArray.find(\n\t\t\t(child) => React.isValidElement(child) && child.type === Slottable,\n\t\t) as React.ReactElement<{ children: React.ReactNode }> | undefined;\n\n\t\tif (slottableChild) {\n\t\t\tconst newElement = slottableChild.props.children;\n\t\t\tif (isSlottable(newElement)) {\n\t\t\t\tconst newElementProps = newElement.props as Record<string, unknown> & { children?: React.ReactNode };\n\t\t\t\tconst newChildren = childrenArray.map((child) => {\n\t\t\t\t\tif (child === slottableChild) {\n\t\t\t\t\t\treturn React.Children.count(newElementProps.children) > 1\n\t\t\t\t\t\t\t? React.Children.only(null)\n\t\t\t\t\t\t\t: newElementProps.children;\n\t\t\t\t\t}\n\t\t\t\t\treturn child;\n\t\t\t\t});\n\n\t\t\t\t// React 19: ref is now a regular prop\n\t\t\t\tconst childRef = newElementProps.ref as React.Ref<HTMLElement> | undefined;\n\n\t\t\t\treturn React.cloneElement(newElement, {\n\t\t\t\t\t...mergeProps(slotProps, newElementProps),\n\t\t\t\t\tref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef,\n\t\t\t\t\tchildren: newChildren,\n\t\t\t\t} as React.Attributes);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Fallback: render children as-is (shouldn't normally happen with proper usage)\n\treturn <>{children}</>;\n});\n\nSlot.displayName = 'Slot';\n\n/**\n * Slottable component - marks content that should receive slot props.\n * Used when Slot has multiple children and you want to specify which one receives props.\n */\nfunction Slottable({ children }: { children: React.ReactNode }) {\n\treturn <>{children}</>;\n}\n\nexport { Slot, Slottable, composeRefs, mergeProps, mergePropsWithRef };\n","import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","'use client';\n\nimport * as React from 'react';\n\nimport { cn } from '../lib/utils';\n\ntype LabelProps = React.ComponentProps<'label'>;\n\n/**\n * Label component for form controls.\n * Uses a standard HTML label element for maximum compatibility.\n */\nfunction Label({ className, ...props }: LabelProps) {\n\treturn (\n\t\t<label\n\t\t\tdata-slot=\"label\"\n\t\t\tclassName={cn(\n\t\t\t\t`text-foreground text-sm leading-4 font-medium select-none group-data-[disabled=true]:pointer-events-none\n\t\t\t\tgroup-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50\n\t\t\t\tdata-[disabled]:pointer-events-none data-[disabled]:opacity-50`,\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nexport { Label };\nexport type { LabelProps };\n","'use client';\n\nimport * as React from 'react';\nimport { Slot } from '../lib/slot';\nimport {\n\tController,\n\tFormProvider,\n\tuseFormContext,\n\tuseFormState,\n\ttype ControllerProps,\n\ttype FieldPath,\n\ttype FieldValues,\n} from 'react-hook-form';\n\nimport { cn } from '../lib/utils';\nimport { Label } from './label';\n\nconst Form = FormProvider;\n\ntype FormFieldContextValue<\n\tTFieldValues extends FieldValues = FieldValues,\n\tTName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n\tname: TName;\n};\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue);\n\nconst FormField = <\n\tTFieldValues extends FieldValues = FieldValues,\n\tTName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n\t...props\n}: ControllerProps<TFieldValues, TName>) => {\n\treturn (\n\t\t<FormFieldContext.Provider value={{ name: props.name }}>\n\t\t\t<Controller {...props} />\n\t\t</FormFieldContext.Provider>\n\t);\n};\n\nconst useFormField = () => {\n\tconst fieldContext = React.useContext(FormFieldContext);\n\tconst itemContext = React.useContext(FormItemContext);\n\tconst { getFieldState } = useFormContext();\n\tconst formState = useFormState({ name: fieldContext.name });\n\tconst fieldState = getFieldState(fieldContext.name, formState);\n\n\tif (!fieldContext) {\n\t\tthrow new Error('useFormField should be used within <FormField>');\n\t}\n\n\tconst { id } = itemContext;\n\n\treturn {\n\t\tid,\n\t\tname: fieldContext.name,\n\t\tformItemId: `${id}-form-item`,\n\t\tformDescriptionId: `${id}-form-item-description`,\n\t\tformMessageId: `${id}-form-item-message`,\n\t\t...fieldState,\n\t};\n};\n\ntype FormItemContextValue = {\n\tid: string;\n};\n\nconst FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue);\n\nfunction FormItem({ className, ...props }: React.ComponentProps<'div'>) {\n\tconst id = React.useId();\n\n\treturn (\n\t\t<FormItemContext.Provider value={{ id }}>\n\t\t\t<div data-slot='form-item' className={cn('grid gap-2', className)} {...props} />\n\t\t</FormItemContext.Provider>\n\t);\n}\n\nfunction FormLabel({ className, ...props }: React.ComponentProps<typeof Label>) {\n\tconst { error, formItemId } = useFormField();\n\n\treturn (\n\t\t<Label\n\t\t\tdata-slot='form-label'\n\t\t\tdata-error={!!error}\n\t\t\tclassName={cn('data-[error=true]:text-destructive', className)}\n\t\t\thtmlFor={formItemId}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction FormControl({ ...props }: React.ComponentProps<typeof Slot>) {\n\tconst { error, formItemId, formDescriptionId, formMessageId } = useFormField();\n\n\treturn (\n\t\t<Slot\n\t\t\tdata-slot='form-control'\n\t\t\tid={formItemId}\n\t\t\taria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}\n\t\t\taria-invalid={!!error}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction FormDescription({ className, ...props }: React.ComponentProps<'p'>) {\n\tconst { formDescriptionId } = useFormField();\n\n\treturn (\n\t\t<p\n\t\t\tdata-slot='form-description'\n\t\t\tid={formDescriptionId}\n\t\t\tclassName={cn('text-muted-foreground text-sm', className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction FormMessage({ className, ...props }: React.ComponentProps<'p'>) {\n\tconst { error, formMessageId } = useFormField();\n\tconst body = error ? String(error?.message ?? '') : props.children;\n\n\tif (!body) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<p data-slot='form-message' id={formMessageId} className={cn('text-destructive text-sm', className)} {...props}>\n\t\t\t{body}\n\t\t</p>\n\t);\n}\n\nexport { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField };\n"]}