doodleui-react 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.
package/dist/index.cjs ADDED
@@ -0,0 +1,1231 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var react = require('react');
5
+ var rough = require('roughjs');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+ var CheckboxPrimitive = require('@radix-ui/react-checkbox');
8
+ var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
9
+ var Dialog = require('@radix-ui/react-dialog');
10
+ var TooltipPrimitive = require('@radix-ui/react-tooltip');
11
+
12
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
+
14
+ function _interopNamespace(e) {
15
+ if (e && e.__esModule) return e;
16
+ var n = Object.create(null);
17
+ if (e) {
18
+ Object.keys(e).forEach(function (k) {
19
+ if (k !== 'default') {
20
+ var d = Object.getOwnPropertyDescriptor(e, k);
21
+ Object.defineProperty(n, k, d.get ? d : {
22
+ enumerable: true,
23
+ get: function () { return e[k]; }
24
+ });
25
+ }
26
+ });
27
+ }
28
+ n.default = e;
29
+ return Object.freeze(n);
30
+ }
31
+
32
+ var rough__default = /*#__PURE__*/_interopDefault(rough);
33
+ var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
34
+ var RadioGroupPrimitive__namespace = /*#__PURE__*/_interopNamespace(RadioGroupPrimitive);
35
+ var Dialog__namespace = /*#__PURE__*/_interopNamespace(Dialog);
36
+ var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
37
+
38
+ // src/types.ts
39
+ function toRoughOptions(props) {
40
+ const stroke = props.stroke ?? props.sketchColor ?? DEFAULT_INK;
41
+ const options = {
42
+ roughness: props.roughness ?? DEFAULT_ROUGHNESS,
43
+ bowing: props.bowing ?? DEFAULT_BOWING,
44
+ stroke,
45
+ strokeWidth: props.strokeWidth ?? DEFAULT_STROKE_WIDTH,
46
+ seed: props.seed
47
+ };
48
+ if (props.fill) {
49
+ options.fill = props.fill;
50
+ options.fillStyle = props.fillStyle ?? "hachure";
51
+ }
52
+ return options;
53
+ }
54
+ var DEFAULT_ROUGHNESS = 1.5;
55
+ var DEFAULT_BOWING = 1;
56
+ var DEFAULT_STROKE_WIDTH = 1.75;
57
+ var DEFAULT_INK = "#1f1d1a";
58
+ var DEFAULT_INSET = 3;
59
+ var SKETCH_COLORS = {
60
+ ink: DEFAULT_INK,
61
+ accent: "#e24b3b",
62
+ accentFill: "#f4c4bc",
63
+ secondaryFill: "#d7e3d4",
64
+ paper: "#eef0ea",
65
+ info: "#1d4e89",
66
+ warning: "#c47b17",
67
+ error: "#c0392b",
68
+ success: "#2d6a4f"
69
+ };
70
+
71
+ // src/utils.ts
72
+ function randomSeed() {
73
+ return Math.floor(Math.random() * 2 ** 31);
74
+ }
75
+ function cn(...parts) {
76
+ const value = parts.filter(Boolean).join(" ");
77
+ return value.length > 0 ? value : void 0;
78
+ }
79
+ var SketchSeedContext = react.createContext(null);
80
+ function SketchSeedProvider({
81
+ children,
82
+ initialSeed
83
+ }) {
84
+ const [seed, setSeed] = react.useState(() => initialSeed ?? randomSeed());
85
+ const shuffle = react.useCallback(() => {
86
+ setSeed(randomSeed());
87
+ }, []);
88
+ const value = react.useMemo(
89
+ () => ({ seed, shuffle, setSeed }),
90
+ [seed, shuffle]
91
+ );
92
+ return /* @__PURE__ */ jsxRuntime.jsx(SketchSeedContext.Provider, { value, children });
93
+ }
94
+ function useSketchSeed() {
95
+ const ctx = react.useContext(SketchSeedContext);
96
+ if (!ctx) {
97
+ throw new Error(
98
+ "useSketchSeed() must be used inside <SketchSeedProvider>. Wrap your tree so Shuffle can redraw every sketch."
99
+ );
100
+ }
101
+ return ctx;
102
+ }
103
+ function useOptionalSketchSeed() {
104
+ return react.useContext(SketchSeedContext);
105
+ }
106
+
107
+ // src/hooks/useResolvedSeed.ts
108
+ function useResolvedSeed(seed) {
109
+ const ctx = useOptionalSketchSeed();
110
+ const [fallback] = react.useState(randomSeed);
111
+ if (seed != null) return seed;
112
+ if (ctx) return ctx.seed;
113
+ return fallback;
114
+ }
115
+ function useElementSize(ref) {
116
+ const [size, setSize] = react.useState({ width: 0, height: 0 });
117
+ react.useLayoutEffect(() => {
118
+ const el = ref.current;
119
+ if (!el) return;
120
+ const update = () => {
121
+ setSize({ width: el.offsetWidth, height: el.offsetHeight });
122
+ };
123
+ update();
124
+ const observer = new ResizeObserver(update);
125
+ observer.observe(el);
126
+ return () => observer.disconnect();
127
+ }, [ref]);
128
+ return size;
129
+ }
130
+ function RoughSvg({
131
+ shape = "rectangle",
132
+ width: widthProp,
133
+ height: heightProp,
134
+ roughness,
135
+ seed: seedProp,
136
+ sketchColor,
137
+ bowing,
138
+ fillStyle,
139
+ strokeWidth,
140
+ fill,
141
+ inset = DEFAULT_INSET,
142
+ path,
143
+ className,
144
+ style
145
+ }) {
146
+ const containerRef = react.useRef(null);
147
+ const svgRef = react.useRef(null);
148
+ const measured = useElementSize(containerRef);
149
+ const seed = useResolvedSeed(seedProp);
150
+ const width = widthProp ?? measured.width;
151
+ const height = heightProp ?? measured.height;
152
+ react.useLayoutEffect(() => {
153
+ const svg = svgRef.current;
154
+ if (!svg || width < 2 || height < 2) return;
155
+ while (svg.firstChild) svg.removeChild(svg.firstChild);
156
+ const rc = rough__default.default.svg(svg);
157
+ const options = toRoughOptions({
158
+ roughness,
159
+ seed,
160
+ sketchColor,
161
+ bowing,
162
+ fillStyle,
163
+ strokeWidth,
164
+ fill
165
+ });
166
+ const x = inset;
167
+ const y = inset;
168
+ const w = Math.max(1, width - inset * 2);
169
+ const h = Math.max(1, height - inset * 2);
170
+ let node;
171
+ switch (shape) {
172
+ case "ellipse":
173
+ node = rc.ellipse(width / 2, height / 2, w, h, options);
174
+ break;
175
+ case "line":
176
+ node = rc.line(inset, height / 2, width - inset, height / 2, options);
177
+ break;
178
+ case "line-vertical":
179
+ node = rc.line(width / 2, inset, width / 2, height - inset, options);
180
+ break;
181
+ case "path":
182
+ if (!path) return;
183
+ node = rc.path(path, options);
184
+ break;
185
+ default:
186
+ node = rc.rectangle(x, y, w, h, options);
187
+ }
188
+ svg.appendChild(node);
189
+ }, [
190
+ width,
191
+ height,
192
+ shape,
193
+ roughness,
194
+ seed,
195
+ sketchColor,
196
+ bowing,
197
+ fillStyle,
198
+ strokeWidth,
199
+ fill,
200
+ inset,
201
+ path
202
+ ]);
203
+ const overlayStyle = {
204
+ position: "absolute",
205
+ inset: 0,
206
+ width: "100%",
207
+ height: "100%",
208
+ pointerEvents: "none",
209
+ overflow: "visible",
210
+ zIndex: 0,
211
+ ...style
212
+ };
213
+ return /* @__PURE__ */ jsxRuntime.jsx(
214
+ "div",
215
+ {
216
+ ref: containerRef,
217
+ "aria-hidden": "true",
218
+ className,
219
+ style: overlayStyle,
220
+ children: /* @__PURE__ */ jsxRuntime.jsx(
221
+ "svg",
222
+ {
223
+ ref: svgRef,
224
+ width: "100%",
225
+ height: "100%",
226
+ overflow: "visible",
227
+ style: { display: "block" }
228
+ }
229
+ )
230
+ }
231
+ );
232
+ }
233
+ var SketchBox = react.forwardRef(
234
+ function SketchBox2({
235
+ children,
236
+ className,
237
+ style,
238
+ contentClassName,
239
+ contentStyle,
240
+ shape = "rectangle",
241
+ fill,
242
+ fillStyle,
243
+ shadow = false,
244
+ roughness,
245
+ seed,
246
+ sketchColor,
247
+ bowing,
248
+ strokeWidth,
249
+ inset,
250
+ path,
251
+ ...rest
252
+ }, ref) {
253
+ return /* @__PURE__ */ jsxRuntime.jsxs(
254
+ "div",
255
+ {
256
+ ref,
257
+ className: cn(className),
258
+ style: { position: "relative", ...style },
259
+ ...rest,
260
+ children: [
261
+ shadow ? /* @__PURE__ */ jsxRuntime.jsx(
262
+ RoughSvg,
263
+ {
264
+ shape,
265
+ roughness: (roughness ?? 1.5) + 0.35,
266
+ seed,
267
+ sketchColor,
268
+ bowing,
269
+ fillStyle: "hachure",
270
+ fill: sketchColor ?? "#1f1d1a",
271
+ strokeWidth: 1,
272
+ inset,
273
+ style: { transform: "translate(5px, 6px)", opacity: 0.16 }
274
+ }
275
+ ) : null,
276
+ /* @__PURE__ */ jsxRuntime.jsx(
277
+ RoughSvg,
278
+ {
279
+ shape,
280
+ roughness,
281
+ seed,
282
+ sketchColor,
283
+ bowing,
284
+ fillStyle: fill ? fillStyle : shadow ? "solid" : fillStyle,
285
+ fill: fill ?? (shadow ? "#f7f6f2" : void 0),
286
+ strokeWidth,
287
+ inset,
288
+ path
289
+ }
290
+ ),
291
+ /* @__PURE__ */ jsxRuntime.jsx(
292
+ "div",
293
+ {
294
+ className: contentClassName,
295
+ style: { position: "relative", zIndex: 1, ...contentStyle },
296
+ children
297
+ }
298
+ )
299
+ ]
300
+ }
301
+ );
302
+ }
303
+ );
304
+ var SIZE_STYLES = {
305
+ sm: { fontSize: 13, padding: "4px 12px", minHeight: 30 },
306
+ md: { fontSize: 15, padding: "8px 16px", minHeight: 38 },
307
+ lg: { fontSize: 17, padding: "11px 22px", minHeight: 46 }
308
+ };
309
+ var Button = react.forwardRef(
310
+ function Button2({
311
+ children,
312
+ className,
313
+ style,
314
+ variant = "primary",
315
+ size = "md",
316
+ roughness,
317
+ seed,
318
+ sketchColor,
319
+ bowing,
320
+ fillStyle,
321
+ strokeWidth,
322
+ disabled,
323
+ onMouseEnter,
324
+ onMouseLeave,
325
+ ...rest
326
+ }, ref) {
327
+ const [hovered, setHovered] = react.useState(false);
328
+ const ink = sketchColor ?? SKETCH_COLORS.ink;
329
+ const fill = variant === "primary" ? SKETCH_COLORS.accentFill : variant === "secondary" ? SKETCH_COLORS.secondaryFill : void 0;
330
+ const stroke = variant === "ghost" && !hovered ? "transparent" : variant === "primary" ? sketchColor ?? SKETCH_COLORS.accent : ink;
331
+ return /* @__PURE__ */ jsxRuntime.jsxs(
332
+ "button",
333
+ {
334
+ ref,
335
+ type: "button",
336
+ className: cn(className),
337
+ disabled,
338
+ onMouseEnter: (event) => {
339
+ setHovered(true);
340
+ onMouseEnter?.(event);
341
+ },
342
+ onMouseLeave: (event) => {
343
+ setHovered(false);
344
+ onMouseLeave?.(event);
345
+ },
346
+ style: {
347
+ position: "relative",
348
+ display: "inline-flex",
349
+ alignItems: "center",
350
+ justifyContent: "center",
351
+ gap: 8,
352
+ border: "none",
353
+ background: "transparent",
354
+ cursor: disabled ? "not-allowed" : "pointer",
355
+ color: ink,
356
+ fontFamily: "inherit",
357
+ fontWeight: 600,
358
+ lineHeight: 1.2,
359
+ opacity: disabled ? 0.45 : 1,
360
+ ...SIZE_STYLES[size],
361
+ ...style
362
+ },
363
+ ...rest,
364
+ children: [
365
+ /* @__PURE__ */ jsxRuntime.jsx(
366
+ RoughSvg,
367
+ {
368
+ shape: "rectangle",
369
+ roughness,
370
+ seed,
371
+ sketchColor: stroke,
372
+ bowing,
373
+ fillStyle: fillStyle ?? "hachure",
374
+ fill,
375
+ strokeWidth: hovered ? (strokeWidth ?? 1.75) + 0.4 : strokeWidth
376
+ }
377
+ ),
378
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { position: "relative", zIndex: 1 }, children })
379
+ ]
380
+ }
381
+ );
382
+ }
383
+ );
384
+ var Input = react.forwardRef(function Input2({
385
+ className,
386
+ style,
387
+ label,
388
+ roughness,
389
+ seed,
390
+ sketchColor,
391
+ bowing,
392
+ fillStyle,
393
+ strokeWidth,
394
+ id,
395
+ onFocus,
396
+ onBlur,
397
+ ...rest
398
+ }, ref) {
399
+ const [focused, setFocused] = react.useState(false);
400
+ const ink = sketchColor ?? SKETCH_COLORS.ink;
401
+ const inputId = id;
402
+ return /* @__PURE__ */ jsxRuntime.jsxs(
403
+ "label",
404
+ {
405
+ htmlFor: inputId,
406
+ style: {
407
+ display: "flex",
408
+ flexDirection: "column",
409
+ gap: 6,
410
+ width: "100%"
411
+ },
412
+ children: [
413
+ label ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 13, fontWeight: 600, color: ink }, children: label }) : null,
414
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { position: "relative", display: "block" }, children: [
415
+ /* @__PURE__ */ jsxRuntime.jsx(
416
+ RoughSvg,
417
+ {
418
+ shape: "rectangle",
419
+ roughness,
420
+ seed,
421
+ sketchColor: focused ? SKETCH_COLORS.accent : ink,
422
+ bowing,
423
+ fillStyle,
424
+ strokeWidth: focused ? (strokeWidth ?? 1.75) + 0.35 : strokeWidth
425
+ }
426
+ ),
427
+ /* @__PURE__ */ jsxRuntime.jsx(
428
+ "input",
429
+ {
430
+ ref,
431
+ id: inputId,
432
+ className: cn(className),
433
+ onFocus: (event) => {
434
+ setFocused(true);
435
+ onFocus?.(event);
436
+ },
437
+ onBlur: (event) => {
438
+ setFocused(false);
439
+ onBlur?.(event);
440
+ },
441
+ style: {
442
+ position: "relative",
443
+ zIndex: 1,
444
+ width: "100%",
445
+ boxSizing: "border-box",
446
+ border: "none",
447
+ outline: "none",
448
+ background: "transparent",
449
+ color: ink,
450
+ fontFamily: "inherit",
451
+ fontSize: 15,
452
+ padding: "8px 12px",
453
+ ...style
454
+ },
455
+ ...rest
456
+ }
457
+ )
458
+ ] })
459
+ ]
460
+ }
461
+ );
462
+ });
463
+ var Textarea = react.forwardRef(
464
+ function Textarea2({
465
+ className,
466
+ style,
467
+ label,
468
+ roughness,
469
+ seed,
470
+ sketchColor,
471
+ bowing,
472
+ fillStyle,
473
+ strokeWidth,
474
+ id,
475
+ rows = 4,
476
+ onFocus,
477
+ onBlur,
478
+ ...rest
479
+ }, ref) {
480
+ const [focused, setFocused] = react.useState(false);
481
+ const ink = sketchColor ?? SKETCH_COLORS.ink;
482
+ return /* @__PURE__ */ jsxRuntime.jsxs(
483
+ "label",
484
+ {
485
+ htmlFor: id,
486
+ style: {
487
+ display: "flex",
488
+ flexDirection: "column",
489
+ gap: 6,
490
+ width: "100%"
491
+ },
492
+ children: [
493
+ label ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 13, fontWeight: 600, color: ink }, children: label }) : null,
494
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { position: "relative", display: "block" }, children: [
495
+ /* @__PURE__ */ jsxRuntime.jsx(
496
+ RoughSvg,
497
+ {
498
+ shape: "rectangle",
499
+ roughness,
500
+ seed,
501
+ sketchColor: focused ? SKETCH_COLORS.accent : ink,
502
+ bowing,
503
+ fillStyle,
504
+ strokeWidth: focused ? (strokeWidth ?? 1.75) + 0.35 : strokeWidth
505
+ }
506
+ ),
507
+ /* @__PURE__ */ jsxRuntime.jsx(
508
+ "textarea",
509
+ {
510
+ ref,
511
+ id,
512
+ rows,
513
+ className: cn(className),
514
+ onFocus: (event) => {
515
+ setFocused(true);
516
+ onFocus?.(event);
517
+ },
518
+ onBlur: (event) => {
519
+ setFocused(false);
520
+ onBlur?.(event);
521
+ },
522
+ style: {
523
+ position: "relative",
524
+ zIndex: 1,
525
+ width: "100%",
526
+ boxSizing: "border-box",
527
+ border: "none",
528
+ outline: "none",
529
+ background: "transparent",
530
+ color: ink,
531
+ fontFamily: "inherit",
532
+ fontSize: 15,
533
+ lineHeight: 1.5,
534
+ padding: "10px 12px",
535
+ resize: "vertical",
536
+ ...style
537
+ },
538
+ ...rest
539
+ }
540
+ )
541
+ ] })
542
+ ]
543
+ }
544
+ );
545
+ }
546
+ );
547
+ var BOX = 20;
548
+ var CHECK_PATH = "M 4.5 10.5 L 8.5 14.5 L 15.5 5.5";
549
+ var Checkbox = react.forwardRef(
550
+ function Checkbox2({
551
+ className,
552
+ style,
553
+ label,
554
+ roughness,
555
+ seed,
556
+ sketchColor,
557
+ bowing,
558
+ fillStyle,
559
+ strokeWidth,
560
+ checked,
561
+ defaultChecked,
562
+ onCheckedChange,
563
+ id,
564
+ ...rest
565
+ }, ref) {
566
+ const ink = sketchColor ?? SKETCH_COLORS.ink;
567
+ const generatedId = react.useId();
568
+ const inputId = id ?? generatedId;
569
+ return /* @__PURE__ */ jsxRuntime.jsxs(
570
+ "span",
571
+ {
572
+ className: cn(className),
573
+ style: {
574
+ display: "inline-flex",
575
+ alignItems: "center",
576
+ gap: 8,
577
+ cursor: "pointer",
578
+ userSelect: "none",
579
+ ...style
580
+ },
581
+ children: [
582
+ /* @__PURE__ */ jsxRuntime.jsxs(
583
+ CheckboxPrimitive__namespace.Root,
584
+ {
585
+ ref,
586
+ id: inputId,
587
+ checked,
588
+ defaultChecked,
589
+ onCheckedChange,
590
+ style: {
591
+ position: "relative",
592
+ width: BOX,
593
+ height: BOX,
594
+ padding: 0,
595
+ border: "none",
596
+ background: "transparent",
597
+ flexShrink: 0,
598
+ cursor: "pointer"
599
+ },
600
+ ...rest,
601
+ children: [
602
+ /* @__PURE__ */ jsxRuntime.jsx(
603
+ RoughSvg,
604
+ {
605
+ shape: "rectangle",
606
+ roughness,
607
+ seed,
608
+ sketchColor: ink,
609
+ bowing,
610
+ fillStyle,
611
+ strokeWidth: strokeWidth ?? 1.6,
612
+ inset: 1.5
613
+ }
614
+ ),
615
+ /* @__PURE__ */ jsxRuntime.jsx(
616
+ CheckboxPrimitive__namespace.Indicator,
617
+ {
618
+ style: {
619
+ position: "absolute",
620
+ inset: 0,
621
+ display: "block"
622
+ },
623
+ children: /* @__PURE__ */ jsxRuntime.jsx(
624
+ RoughSvg,
625
+ {
626
+ shape: "path",
627
+ path: CHECK_PATH,
628
+ roughness: (roughness ?? 1.5) * 0.7,
629
+ seed,
630
+ sketchColor: SKETCH_COLORS.accent,
631
+ bowing,
632
+ strokeWidth: (strokeWidth ?? 1.6) + 0.4,
633
+ inset: 0
634
+ }
635
+ )
636
+ }
637
+ )
638
+ ]
639
+ }
640
+ ),
641
+ label ? /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: inputId, style: { fontSize: 15, cursor: "pointer" }, children: label }) : null
642
+ ]
643
+ }
644
+ );
645
+ }
646
+ );
647
+ var RadioGroup = react.forwardRef(
648
+ function RadioGroup2({ className, style, children, ...rest }, ref) {
649
+ return /* @__PURE__ */ jsxRuntime.jsx(
650
+ RadioGroupPrimitive__namespace.Root,
651
+ {
652
+ ref,
653
+ className: cn(className),
654
+ style: {
655
+ display: "flex",
656
+ flexDirection: "column",
657
+ gap: 10,
658
+ ...style
659
+ },
660
+ ...rest,
661
+ children
662
+ }
663
+ );
664
+ }
665
+ );
666
+ var SIZE = 20;
667
+ var Radio = react.forwardRef(function Radio2({
668
+ className,
669
+ style,
670
+ label,
671
+ roughness,
672
+ seed,
673
+ sketchColor,
674
+ bowing,
675
+ fillStyle,
676
+ strokeWidth,
677
+ id,
678
+ ...rest
679
+ }, ref) {
680
+ const ink = sketchColor ?? SKETCH_COLORS.ink;
681
+ const generatedId = react.useId();
682
+ const inputId = id ?? generatedId;
683
+ return /* @__PURE__ */ jsxRuntime.jsxs(
684
+ "span",
685
+ {
686
+ className: cn(className),
687
+ style: {
688
+ display: "inline-flex",
689
+ alignItems: "center",
690
+ gap: 8,
691
+ cursor: "pointer",
692
+ userSelect: "none",
693
+ ...style
694
+ },
695
+ children: [
696
+ /* @__PURE__ */ jsxRuntime.jsxs(
697
+ RadioGroupPrimitive__namespace.Item,
698
+ {
699
+ ref,
700
+ id: inputId,
701
+ style: {
702
+ position: "relative",
703
+ width: SIZE,
704
+ height: SIZE,
705
+ padding: 0,
706
+ border: "none",
707
+ background: "transparent",
708
+ flexShrink: 0,
709
+ cursor: "pointer",
710
+ borderRadius: "50%"
711
+ },
712
+ ...rest,
713
+ children: [
714
+ /* @__PURE__ */ jsxRuntime.jsx(
715
+ RoughSvg,
716
+ {
717
+ shape: "ellipse",
718
+ roughness,
719
+ seed,
720
+ sketchColor: ink,
721
+ bowing,
722
+ fillStyle,
723
+ strokeWidth: strokeWidth ?? 1.6,
724
+ inset: 1.5
725
+ }
726
+ ),
727
+ /* @__PURE__ */ jsxRuntime.jsx(
728
+ RadioGroupPrimitive__namespace.Indicator,
729
+ {
730
+ style: {
731
+ position: "absolute",
732
+ inset: 0,
733
+ display: "block"
734
+ },
735
+ children: /* @__PURE__ */ jsxRuntime.jsx(
736
+ RoughSvg,
737
+ {
738
+ shape: "ellipse",
739
+ roughness: (roughness ?? 1.5) + 0.2,
740
+ seed,
741
+ sketchColor: SKETCH_COLORS.accent,
742
+ fill: SKETCH_COLORS.accent,
743
+ fillStyle: "solid",
744
+ bowing,
745
+ strokeWidth: 1,
746
+ inset: 6
747
+ }
748
+ )
749
+ }
750
+ )
751
+ ]
752
+ }
753
+ ),
754
+ label ? /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: inputId, style: { fontSize: 15, cursor: "pointer" }, children: label }) : null
755
+ ]
756
+ }
757
+ );
758
+ });
759
+ var Card = react.forwardRef(function Card2({
760
+ children,
761
+ className,
762
+ style,
763
+ shadow = true,
764
+ fill,
765
+ title,
766
+ footer,
767
+ roughness,
768
+ seed,
769
+ sketchColor,
770
+ bowing,
771
+ fillStyle,
772
+ strokeWidth,
773
+ ...rest
774
+ }, ref) {
775
+ const boxProps = {
776
+ shadow,
777
+ fill,
778
+ roughness,
779
+ seed,
780
+ sketchColor: sketchColor ?? SKETCH_COLORS.ink,
781
+ bowing,
782
+ fillStyle,
783
+ strokeWidth
784
+ };
785
+ return /* @__PURE__ */ jsxRuntime.jsxs(
786
+ SketchBox,
787
+ {
788
+ ref,
789
+ className: cn(className),
790
+ style,
791
+ contentStyle: { padding: "16px 18px" },
792
+ ...boxProps,
793
+ ...rest,
794
+ children: [
795
+ title ? /* @__PURE__ */ jsxRuntime.jsx(
796
+ "div",
797
+ {
798
+ style: {
799
+ fontWeight: 700,
800
+ fontSize: 16,
801
+ marginBottom: 10
802
+ },
803
+ children: title
804
+ }
805
+ ) : null,
806
+ children,
807
+ footer ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: 14, fontSize: 13, opacity: 0.8 }, children: footer }) : null
808
+ ]
809
+ }
810
+ );
811
+ });
812
+ var Badge = react.forwardRef(function Badge2({
813
+ children,
814
+ className,
815
+ style,
816
+ variant = "default",
817
+ roughness,
818
+ seed,
819
+ sketchColor,
820
+ bowing,
821
+ fillStyle,
822
+ strokeWidth,
823
+ ...rest
824
+ }, ref) {
825
+ const ink = variant === "accent" ? sketchColor ?? SKETCH_COLORS.accent : sketchColor ?? SKETCH_COLORS.ink;
826
+ const fill = variant === "accent" ? SKETCH_COLORS.accentFill : variant === "outline" ? void 0 : SKETCH_COLORS.secondaryFill;
827
+ return /* @__PURE__ */ jsxRuntime.jsx(
828
+ SketchBox,
829
+ {
830
+ className: cn(className),
831
+ style: {
832
+ display: "inline-flex",
833
+ verticalAlign: "middle",
834
+ ...style
835
+ },
836
+ contentStyle: {
837
+ padding: "2px 10px",
838
+ fontSize: 12,
839
+ fontWeight: 650,
840
+ lineHeight: 1.4,
841
+ letterSpacing: "0.01em"
842
+ },
843
+ fill,
844
+ fillStyle: fillStyle ?? "hachure",
845
+ roughness,
846
+ seed,
847
+ sketchColor: ink,
848
+ bowing,
849
+ strokeWidth: strokeWidth ?? 1.4,
850
+ ...rest,
851
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { ref, children })
852
+ }
853
+ );
854
+ });
855
+ var VARIANT_COLOR = {
856
+ info: SKETCH_COLORS.info,
857
+ warning: SKETCH_COLORS.warning,
858
+ error: SKETCH_COLORS.error,
859
+ success: SKETCH_COLORS.success
860
+ };
861
+ var VARIANT_FILL = {
862
+ info: "#d2deec",
863
+ warning: "#f3e2c0",
864
+ error: "#f3d0cc",
865
+ success: "#d3e8dc"
866
+ };
867
+ var Alert = react.forwardRef(function Alert2({
868
+ children,
869
+ className,
870
+ style,
871
+ variant = "info",
872
+ title,
873
+ roughness,
874
+ seed,
875
+ sketchColor,
876
+ bowing,
877
+ fillStyle,
878
+ strokeWidth,
879
+ role = "status",
880
+ ...rest
881
+ }, ref) {
882
+ const color = sketchColor ?? VARIANT_COLOR[variant];
883
+ return /* @__PURE__ */ jsxRuntime.jsxs(
884
+ SketchBox,
885
+ {
886
+ ref,
887
+ role,
888
+ className: cn(className),
889
+ style: { color, ...style },
890
+ contentStyle: { padding: "12px 16px" },
891
+ roughness,
892
+ seed,
893
+ sketchColor: color,
894
+ bowing,
895
+ fillStyle: fillStyle ?? "hachure",
896
+ fill: VARIANT_FILL[variant],
897
+ strokeWidth,
898
+ ...rest,
899
+ children: [
900
+ title ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontWeight: 700, marginBottom: 4, fontSize: 15 }, children: title }) : null,
901
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 14, lineHeight: 1.5, color: SKETCH_COLORS.ink }, children })
902
+ ]
903
+ }
904
+ );
905
+ });
906
+ function Modal({
907
+ open,
908
+ defaultOpen,
909
+ onOpenChange,
910
+ trigger,
911
+ title,
912
+ description,
913
+ children,
914
+ className,
915
+ roughness,
916
+ seed,
917
+ sketchColor,
918
+ bowing,
919
+ fillStyle,
920
+ strokeWidth
921
+ }) {
922
+ const ink = sketchColor ?? SKETCH_COLORS.ink;
923
+ return /* @__PURE__ */ jsxRuntime.jsxs(Dialog__namespace.Root, { open, defaultOpen, onOpenChange, children: [
924
+ trigger ? /* @__PURE__ */ jsxRuntime.jsx(Dialog__namespace.Trigger, { asChild: true, children: trigger }) : null,
925
+ /* @__PURE__ */ jsxRuntime.jsxs(Dialog__namespace.Portal, { children: [
926
+ /* @__PURE__ */ jsxRuntime.jsx(
927
+ Dialog__namespace.Overlay,
928
+ {
929
+ style: {
930
+ position: "fixed",
931
+ inset: 0,
932
+ background: "rgba(31, 29, 26, 0.38)",
933
+ zIndex: 70
934
+ }
935
+ }
936
+ ),
937
+ /* @__PURE__ */ jsxRuntime.jsx(
938
+ Dialog__namespace.Content,
939
+ {
940
+ className: cn(className),
941
+ style: {
942
+ position: "fixed",
943
+ left: "50%",
944
+ top: "50%",
945
+ transform: "translate(-50%, -50%)",
946
+ zIndex: 80,
947
+ width: "min(480px, calc(100vw - 32px))",
948
+ outline: "none"
949
+ },
950
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
951
+ SketchBox,
952
+ {
953
+ roughness,
954
+ seed,
955
+ sketchColor: ink,
956
+ bowing,
957
+ fillStyle: fillStyle ?? "solid",
958
+ fill: "#f7f6f2",
959
+ strokeWidth: strokeWidth ?? 2,
960
+ shadow: true,
961
+ contentStyle: { padding: "20px 22px 18px" },
962
+ children: [
963
+ /* @__PURE__ */ jsxRuntime.jsxs(
964
+ "div",
965
+ {
966
+ style: {
967
+ display: "flex",
968
+ alignItems: "flex-start",
969
+ justifyContent: "space-between",
970
+ gap: 12,
971
+ marginBottom: title ? 10 : 0
972
+ },
973
+ children: [
974
+ title ? /* @__PURE__ */ jsxRuntime.jsx(
975
+ Dialog__namespace.Title,
976
+ {
977
+ style: {
978
+ margin: 0,
979
+ fontSize: 18,
980
+ fontWeight: 700,
981
+ color: ink
982
+ },
983
+ children: title
984
+ }
985
+ ) : /* @__PURE__ */ jsxRuntime.jsx(Dialog__namespace.Title, { style: { position: "absolute", width: 1, height: 1, overflow: "hidden", clip: "rect(0 0 0 0)" }, children: "Dialog" }),
986
+ /* @__PURE__ */ jsxRuntime.jsx(Dialog__namespace.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
987
+ Button,
988
+ {
989
+ variant: "ghost",
990
+ size: "sm",
991
+ roughness,
992
+ seed,
993
+ sketchColor: ink,
994
+ "aria-label": "Close",
995
+ children: "Close"
996
+ }
997
+ ) })
998
+ ]
999
+ }
1000
+ ),
1001
+ description ? /* @__PURE__ */ jsxRuntime.jsx(
1002
+ Dialog__namespace.Description,
1003
+ {
1004
+ style: {
1005
+ margin: "0 0 14px",
1006
+ fontSize: 14,
1007
+ lineHeight: 1.5,
1008
+ color: ink,
1009
+ opacity: 0.8
1010
+ },
1011
+ children: description
1012
+ }
1013
+ ) : null,
1014
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children })
1015
+ ]
1016
+ }
1017
+ )
1018
+ }
1019
+ )
1020
+ ] })
1021
+ ] });
1022
+ }
1023
+ var ModalRoot = Dialog__namespace.Root;
1024
+ var ModalTrigger = Dialog__namespace.Trigger;
1025
+ var ModalClose = Dialog__namespace.Close;
1026
+ var ModalTitle = Dialog__namespace.Title;
1027
+ var ModalDescription = Dialog__namespace.Description;
1028
+ var Divider = react.forwardRef(
1029
+ function Divider2({
1030
+ className,
1031
+ style,
1032
+ orientation = "horizontal",
1033
+ roughness,
1034
+ seed,
1035
+ sketchColor,
1036
+ bowing,
1037
+ strokeWidth,
1038
+ ...rest
1039
+ }, ref) {
1040
+ const horizontal = orientation === "horizontal";
1041
+ return /* @__PURE__ */ jsxRuntime.jsx(
1042
+ "div",
1043
+ {
1044
+ ref,
1045
+ role: "separator",
1046
+ "aria-orientation": orientation,
1047
+ className: cn(className),
1048
+ style: {
1049
+ position: "relative",
1050
+ width: horizontal ? "100%" : 12,
1051
+ height: horizontal ? 12 : "100%",
1052
+ minHeight: horizontal ? 12 : 48,
1053
+ ...style
1054
+ },
1055
+ ...rest,
1056
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1057
+ RoughSvg,
1058
+ {
1059
+ shape: horizontal ? "line" : "line-vertical",
1060
+ roughness: roughness ?? 1.8,
1061
+ seed,
1062
+ sketchColor: sketchColor ?? SKETCH_COLORS.ink,
1063
+ bowing: bowing ?? 2,
1064
+ strokeWidth: strokeWidth ?? 1.5,
1065
+ inset: 4
1066
+ }
1067
+ )
1068
+ }
1069
+ );
1070
+ }
1071
+ );
1072
+ var Progress = react.forwardRef(
1073
+ function Progress2({
1074
+ className,
1075
+ style,
1076
+ value = 0,
1077
+ max = 100,
1078
+ roughness,
1079
+ seed,
1080
+ sketchColor,
1081
+ bowing,
1082
+ fillStyle,
1083
+ strokeWidth,
1084
+ ...rest
1085
+ }, ref) {
1086
+ const ink = sketchColor ?? SKETCH_COLORS.accent;
1087
+ const clamped = Math.min(max, Math.max(0, value));
1088
+ const percent = max === 0 ? 0 : clamped / max * 100;
1089
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1090
+ "div",
1091
+ {
1092
+ ref,
1093
+ role: "progressbar",
1094
+ "aria-valuemin": 0,
1095
+ "aria-valuemax": max,
1096
+ "aria-valuenow": clamped,
1097
+ className: cn(className),
1098
+ style: {
1099
+ position: "relative",
1100
+ width: "100%",
1101
+ height: 18,
1102
+ ...style
1103
+ },
1104
+ ...rest,
1105
+ children: [
1106
+ /* @__PURE__ */ jsxRuntime.jsx(
1107
+ RoughSvg,
1108
+ {
1109
+ shape: "rectangle",
1110
+ roughness,
1111
+ seed,
1112
+ sketchColor: SKETCH_COLORS.ink,
1113
+ bowing,
1114
+ strokeWidth: strokeWidth ?? 1.5,
1115
+ inset: 2
1116
+ }
1117
+ ),
1118
+ percent > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
1119
+ "div",
1120
+ {
1121
+ style: {
1122
+ position: "absolute",
1123
+ left: 5,
1124
+ top: 4,
1125
+ bottom: 4,
1126
+ width: `calc(${percent}% - 10px)`,
1127
+ minWidth: percent > 0 ? 8 : 0,
1128
+ overflow: "hidden"
1129
+ },
1130
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1131
+ RoughSvg,
1132
+ {
1133
+ shape: "rectangle",
1134
+ roughness: (roughness ?? 1.5) + 0.55,
1135
+ seed,
1136
+ sketchColor: ink,
1137
+ fill: ink,
1138
+ fillStyle: fillStyle ?? "hachure",
1139
+ bowing,
1140
+ strokeWidth: 1.1,
1141
+ inset: 1
1142
+ }
1143
+ )
1144
+ }
1145
+ ) : null
1146
+ ]
1147
+ }
1148
+ );
1149
+ }
1150
+ );
1151
+ var TooltipProvider = TooltipPrimitive__namespace.Provider;
1152
+ function Tooltip({
1153
+ content,
1154
+ children,
1155
+ side = "top",
1156
+ delayDuration = 200,
1157
+ className,
1158
+ roughness,
1159
+ seed,
1160
+ sketchColor,
1161
+ bowing,
1162
+ fillStyle,
1163
+ strokeWidth
1164
+ }) {
1165
+ const ink = sketchColor ?? SKETCH_COLORS.ink;
1166
+ return /* @__PURE__ */ jsxRuntime.jsxs(TooltipPrimitive__namespace.Root, { delayDuration, children: [
1167
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Trigger, { asChild: true, children }),
1168
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
1169
+ TooltipPrimitive__namespace.Content,
1170
+ {
1171
+ side,
1172
+ sideOffset: 8,
1173
+ className: cn(className),
1174
+ style: { zIndex: 60, outline: "none" },
1175
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1176
+ SketchBox,
1177
+ {
1178
+ roughness: roughness ?? 1.3,
1179
+ seed,
1180
+ sketchColor: ink,
1181
+ bowing,
1182
+ fillStyle: fillStyle ?? "solid",
1183
+ fill: "#f7f6f2",
1184
+ strokeWidth: strokeWidth ?? 1.4,
1185
+ contentStyle: {
1186
+ padding: "6px 10px",
1187
+ fontSize: 13,
1188
+ lineHeight: 1.35,
1189
+ color: ink,
1190
+ maxWidth: 240
1191
+ },
1192
+ children: content
1193
+ }
1194
+ )
1195
+ }
1196
+ ) })
1197
+ ] });
1198
+ }
1199
+
1200
+ exports.Alert = Alert;
1201
+ exports.Badge = Badge;
1202
+ exports.Button = Button;
1203
+ exports.Card = Card;
1204
+ exports.Checkbox = Checkbox;
1205
+ exports.DEFAULT_BOWING = DEFAULT_BOWING;
1206
+ exports.DEFAULT_INK = DEFAULT_INK;
1207
+ exports.DEFAULT_ROUGHNESS = DEFAULT_ROUGHNESS;
1208
+ exports.DEFAULT_STROKE_WIDTH = DEFAULT_STROKE_WIDTH;
1209
+ exports.Divider = Divider;
1210
+ exports.Input = Input;
1211
+ exports.Modal = Modal;
1212
+ exports.ModalClose = ModalClose;
1213
+ exports.ModalDescription = ModalDescription;
1214
+ exports.ModalRoot = ModalRoot;
1215
+ exports.ModalTitle = ModalTitle;
1216
+ exports.ModalTrigger = ModalTrigger;
1217
+ exports.Progress = Progress;
1218
+ exports.Radio = Radio;
1219
+ exports.RadioGroup = RadioGroup;
1220
+ exports.RoughSvg = RoughSvg;
1221
+ exports.SKETCH_COLORS = SKETCH_COLORS;
1222
+ exports.SketchBox = SketchBox;
1223
+ exports.SketchSeedProvider = SketchSeedProvider;
1224
+ exports.Textarea = Textarea;
1225
+ exports.Tooltip = Tooltip;
1226
+ exports.TooltipProvider = TooltipProvider;
1227
+ exports.toRoughOptions = toRoughOptions;
1228
+ exports.useResolvedSeed = useResolvedSeed;
1229
+ exports.useSketchSeed = useSketchSeed;
1230
+ //# sourceMappingURL=index.cjs.map
1231
+ //# sourceMappingURL=index.cjs.map