virtual-ui-lib 1.0.20 → 1.0.22

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.js CHANGED
@@ -32,10 +32,12 @@ __export(index_exports, {
32
32
  AlertBanner: () => AlertBanner,
33
33
  Button: () => Button,
34
34
  Card: () => Card,
35
+ CopyButton: () => CopyButton,
35
36
  Dropdown: () => Dropdown,
36
37
  EmptyState: () => EmptyState,
37
38
  FormInput: () => FormInput,
38
39
  GridLayout: () => GridLayout,
40
+ ImageUploadPreview: () => ImageUploadPreview,
39
41
  Navbar: () => Navbar
40
42
  });
41
43
  module.exports = __toCommonJS(index_exports);
@@ -475,14 +477,136 @@ var Navbar = ({
475
477
  transition: "color 0.3s"
476
478
  }, onMouseOver: (e) => e.currentTarget.style.color = hoverColor, onMouseOut: (e) => e.currentTarget.style.color = linkColor }, link.name))))));
477
479
  };
480
+
481
+ // src/components/ImageUploadPreview/ImageUploadPreview.jsx
482
+ var import_react9 = __toESM(require("react"));
483
+ var ImageUploadPreview = ({
484
+ width = "300px",
485
+ height = "200px",
486
+ bg = "#1e293b",
487
+ borderColor = "#7c3aed",
488
+ errorColor = "#dc2626",
489
+ borderRadius = "12px",
490
+ onImageChange
491
+ }) => {
492
+ const [image, setImage] = (0, import_react9.useState)(null);
493
+ const [error, setError] = (0, import_react9.useState)(false);
494
+ const handleImageChange = (e) => {
495
+ const file = e.target.files[0];
496
+ const validTypes = ["image/png", "image/jpeg", "image/jpg"];
497
+ if (validTypes.includes(file.type)) {
498
+ setError(false);
499
+ const reader = new FileReader();
500
+ reader.onload = () => {
501
+ setImage(reader.result);
502
+ if (onImageChange) onImageChange(reader.result);
503
+ };
504
+ reader.readAsDataURL(file);
505
+ } else {
506
+ setError(true);
507
+ }
508
+ };
509
+ const handleRemove = () => {
510
+ setImage(null);
511
+ setError(false);
512
+ };
513
+ return /* @__PURE__ */ import_react9.default.createElement("div", { style: {
514
+ display: "flex",
515
+ justifyContent: "center",
516
+ alignItems: "center",
517
+ width,
518
+ height,
519
+ background: bg,
520
+ border: `2px solid ${error ? errorColor : borderColor}`,
521
+ borderRadius,
522
+ position: "relative",
523
+ overflow: "hidden",
524
+ transition: "border-color 0.3s"
525
+ } }, !image && !error && /* @__PURE__ */ import_react9.default.createElement("input", { type: "file", onChange: handleImageChange, style: { display: "none" }, id: "file-input" }), !image && !error && /* @__PURE__ */ import_react9.default.createElement("label", { htmlFor: "file-input", style: { color: "#f1f5f9", cursor: "pointer", textAlign: "center" } }, "Upload Image"), error && /* @__PURE__ */ import_react9.default.createElement("p", { style: { color: errorColor, fontSize: "14px", textAlign: "center" } }, "Invalid image type!"), image && /* @__PURE__ */ import_react9.default.createElement("div", { style: {
526
+ position: "absolute",
527
+ top: 0,
528
+ left: 0,
529
+ right: 0,
530
+ bottom: 0,
531
+ display: "flex",
532
+ justifyContent: "center",
533
+ alignItems: "center",
534
+ background: "rgba(0,0,0,0.6)",
535
+ transition: "opacity 0.3s",
536
+ opacity: 1
537
+ } }, /* @__PURE__ */ import_react9.default.createElement("img", { src: image, alt: "Preview", style: {
538
+ maxWidth: "100%",
539
+ maxHeight: "100%",
540
+ objectFit: "cover",
541
+ transition: "transform 0.3s",
542
+ borderRadius,
543
+ cursor: "zoom-in"
544
+ }, onMouseEnter: (e) => e.currentTarget.style.transform = "scale(1.05)", onMouseLeave: (e) => e.currentTarget.style.transform = "scale(1)" })), image && /* @__PURE__ */ import_react9.default.createElement("button", { onClick: handleRemove, style: {
545
+ position: "absolute",
546
+ top: "10px",
547
+ right: "10px",
548
+ background: "rgba(255,255,255,0.8)",
549
+ color: "#dc2626",
550
+ border: "none",
551
+ borderRadius: "50%",
552
+ width: "30px",
553
+ height: "30px",
554
+ cursor: "pointer",
555
+ fontSize: "16px",
556
+ transition: "background 0.3s"
557
+ }, onMouseEnter: (e) => e.currentTarget.style.background = "rgba(255,255,255,1)", onMouseLeave: (e) => e.currentTarget.style.background = "rgba(255,255,255,0.8)" }, "\xD7"));
558
+ };
559
+
560
+ // src/components/CopyButton/CopyButton.jsx
561
+ var import_react10 = __toESM(require("react"));
562
+ var CopyButton = ({
563
+ text = "Copy",
564
+ bg = "#2563eb",
565
+ color = "white",
566
+ radius = "8px",
567
+ icon = /* @__PURE__ */ import_react10.default.createElement("span", { role: "img", "aria-label": "copy" }, "\u{1F4CB}"),
568
+ padding = "10px 15px",
569
+ shadow = "0 4px 14px rgba(37,99,235,0.4)"
570
+ }) => {
571
+ const [copied, setCopied] = (0, import_react10.useState)(false);
572
+ const handleCopy = () => {
573
+ navigator.clipboard.writeText(text);
574
+ setCopied(true);
575
+ setTimeout(() => setCopied(false), 2e3);
576
+ };
577
+ return /* @__PURE__ */ import_react10.default.createElement(
578
+ "button",
579
+ {
580
+ onClick: handleCopy,
581
+ style: {
582
+ background: bg,
583
+ color,
584
+ border: "none",
585
+ borderRadius: radius,
586
+ padding,
587
+ cursor: "pointer",
588
+ fontWeight: "600",
589
+ boxShadow: shadow,
590
+ display: "flex",
591
+ alignItems: "center",
592
+ gap: "8px",
593
+ transition: "background 0.3s"
594
+ }
595
+ },
596
+ icon,
597
+ copied ? "Copied!" : text
598
+ );
599
+ };
478
600
  // Annotate the CommonJS export names for ESM import in node:
479
601
  0 && (module.exports = {
480
602
  AlertBanner,
481
603
  Button,
482
604
  Card,
605
+ CopyButton,
483
606
  Dropdown,
484
607
  EmptyState,
485
608
  FormInput,
486
609
  GridLayout,
610
+ ImageUploadPreview,
487
611
  Navbar
488
612
  });
package/dist/index.mjs CHANGED
@@ -433,13 +433,135 @@ var Navbar = ({
433
433
  transition: "color 0.3s"
434
434
  }, onMouseOver: (e) => e.currentTarget.style.color = hoverColor, onMouseOut: (e) => e.currentTarget.style.color = linkColor }, link.name))))));
435
435
  };
436
+
437
+ // src/components/ImageUploadPreview/ImageUploadPreview.jsx
438
+ import React9, { useState as useState6 } from "react";
439
+ var ImageUploadPreview = ({
440
+ width = "300px",
441
+ height = "200px",
442
+ bg = "#1e293b",
443
+ borderColor = "#7c3aed",
444
+ errorColor = "#dc2626",
445
+ borderRadius = "12px",
446
+ onImageChange
447
+ }) => {
448
+ const [image, setImage] = useState6(null);
449
+ const [error, setError] = useState6(false);
450
+ const handleImageChange = (e) => {
451
+ const file = e.target.files[0];
452
+ const validTypes = ["image/png", "image/jpeg", "image/jpg"];
453
+ if (validTypes.includes(file.type)) {
454
+ setError(false);
455
+ const reader = new FileReader();
456
+ reader.onload = () => {
457
+ setImage(reader.result);
458
+ if (onImageChange) onImageChange(reader.result);
459
+ };
460
+ reader.readAsDataURL(file);
461
+ } else {
462
+ setError(true);
463
+ }
464
+ };
465
+ const handleRemove = () => {
466
+ setImage(null);
467
+ setError(false);
468
+ };
469
+ return /* @__PURE__ */ React9.createElement("div", { style: {
470
+ display: "flex",
471
+ justifyContent: "center",
472
+ alignItems: "center",
473
+ width,
474
+ height,
475
+ background: bg,
476
+ border: `2px solid ${error ? errorColor : borderColor}`,
477
+ borderRadius,
478
+ position: "relative",
479
+ overflow: "hidden",
480
+ transition: "border-color 0.3s"
481
+ } }, !image && !error && /* @__PURE__ */ React9.createElement("input", { type: "file", onChange: handleImageChange, style: { display: "none" }, id: "file-input" }), !image && !error && /* @__PURE__ */ React9.createElement("label", { htmlFor: "file-input", style: { color: "#f1f5f9", cursor: "pointer", textAlign: "center" } }, "Upload Image"), error && /* @__PURE__ */ React9.createElement("p", { style: { color: errorColor, fontSize: "14px", textAlign: "center" } }, "Invalid image type!"), image && /* @__PURE__ */ React9.createElement("div", { style: {
482
+ position: "absolute",
483
+ top: 0,
484
+ left: 0,
485
+ right: 0,
486
+ bottom: 0,
487
+ display: "flex",
488
+ justifyContent: "center",
489
+ alignItems: "center",
490
+ background: "rgba(0,0,0,0.6)",
491
+ transition: "opacity 0.3s",
492
+ opacity: 1
493
+ } }, /* @__PURE__ */ React9.createElement("img", { src: image, alt: "Preview", style: {
494
+ maxWidth: "100%",
495
+ maxHeight: "100%",
496
+ objectFit: "cover",
497
+ transition: "transform 0.3s",
498
+ borderRadius,
499
+ cursor: "zoom-in"
500
+ }, onMouseEnter: (e) => e.currentTarget.style.transform = "scale(1.05)", onMouseLeave: (e) => e.currentTarget.style.transform = "scale(1)" })), image && /* @__PURE__ */ React9.createElement("button", { onClick: handleRemove, style: {
501
+ position: "absolute",
502
+ top: "10px",
503
+ right: "10px",
504
+ background: "rgba(255,255,255,0.8)",
505
+ color: "#dc2626",
506
+ border: "none",
507
+ borderRadius: "50%",
508
+ width: "30px",
509
+ height: "30px",
510
+ cursor: "pointer",
511
+ fontSize: "16px",
512
+ transition: "background 0.3s"
513
+ }, onMouseEnter: (e) => e.currentTarget.style.background = "rgba(255,255,255,1)", onMouseLeave: (e) => e.currentTarget.style.background = "rgba(255,255,255,0.8)" }, "\xD7"));
514
+ };
515
+
516
+ // src/components/CopyButton/CopyButton.jsx
517
+ import React10, { useState as useState7 } from "react";
518
+ var CopyButton = ({
519
+ text = "Copy",
520
+ bg = "#2563eb",
521
+ color = "white",
522
+ radius = "8px",
523
+ icon = /* @__PURE__ */ React10.createElement("span", { role: "img", "aria-label": "copy" }, "\u{1F4CB}"),
524
+ padding = "10px 15px",
525
+ shadow = "0 4px 14px rgba(37,99,235,0.4)"
526
+ }) => {
527
+ const [copied, setCopied] = useState7(false);
528
+ const handleCopy = () => {
529
+ navigator.clipboard.writeText(text);
530
+ setCopied(true);
531
+ setTimeout(() => setCopied(false), 2e3);
532
+ };
533
+ return /* @__PURE__ */ React10.createElement(
534
+ "button",
535
+ {
536
+ onClick: handleCopy,
537
+ style: {
538
+ background: bg,
539
+ color,
540
+ border: "none",
541
+ borderRadius: radius,
542
+ padding,
543
+ cursor: "pointer",
544
+ fontWeight: "600",
545
+ boxShadow: shadow,
546
+ display: "flex",
547
+ alignItems: "center",
548
+ gap: "8px",
549
+ transition: "background 0.3s"
550
+ }
551
+ },
552
+ icon,
553
+ copied ? "Copied!" : text
554
+ );
555
+ };
436
556
  export {
437
557
  AlertBanner,
438
558
  Button,
439
559
  Card,
560
+ CopyButton,
440
561
  Dropdown,
441
562
  EmptyState,
442
563
  FormInput,
443
564
  GridLayout,
565
+ ImageUploadPreview,
444
566
  Navbar
445
567
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "virtual-ui-lib",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "description": "Virtual UI React Component Library",
5
5
  "author": "Ankush",
6
6
  "license": "ISC",