virtual-ui-lib 1.0.20 → 1.0.21

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
@@ -36,6 +36,7 @@ __export(index_exports, {
36
36
  EmptyState: () => EmptyState,
37
37
  FormInput: () => FormInput,
38
38
  GridLayout: () => GridLayout,
39
+ ImageUploadPreview: () => ImageUploadPreview,
39
40
  Navbar: () => Navbar
40
41
  });
41
42
  module.exports = __toCommonJS(index_exports);
@@ -475,6 +476,85 @@ var Navbar = ({
475
476
  transition: "color 0.3s"
476
477
  }, onMouseOver: (e) => e.currentTarget.style.color = hoverColor, onMouseOut: (e) => e.currentTarget.style.color = linkColor }, link.name))))));
477
478
  };
479
+
480
+ // src/components/ImageUploadPreview/ImageUploadPreview.jsx
481
+ var import_react9 = __toESM(require("react"));
482
+ var ImageUploadPreview = ({
483
+ width = "300px",
484
+ height = "200px",
485
+ bg = "#1e293b",
486
+ borderColor = "#7c3aed",
487
+ errorColor = "#dc2626",
488
+ borderRadius = "12px",
489
+ onImageChange
490
+ }) => {
491
+ const [image, setImage] = (0, import_react9.useState)(null);
492
+ const [error, setError] = (0, import_react9.useState)(false);
493
+ const handleImageChange = (e) => {
494
+ const file = e.target.files[0];
495
+ const validTypes = ["image/png", "image/jpeg", "image/jpg"];
496
+ if (validTypes.includes(file.type)) {
497
+ setError(false);
498
+ const reader = new FileReader();
499
+ reader.onload = () => {
500
+ setImage(reader.result);
501
+ if (onImageChange) onImageChange(reader.result);
502
+ };
503
+ reader.readAsDataURL(file);
504
+ } else {
505
+ setError(true);
506
+ }
507
+ };
508
+ const handleRemove = () => {
509
+ setImage(null);
510
+ setError(false);
511
+ };
512
+ return /* @__PURE__ */ import_react9.default.createElement("div", { style: {
513
+ display: "flex",
514
+ justifyContent: "center",
515
+ alignItems: "center",
516
+ width,
517
+ height,
518
+ background: bg,
519
+ border: `2px solid ${error ? errorColor : borderColor}`,
520
+ borderRadius,
521
+ position: "relative",
522
+ overflow: "hidden",
523
+ transition: "border-color 0.3s"
524
+ } }, !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: {
525
+ position: "absolute",
526
+ top: 0,
527
+ left: 0,
528
+ right: 0,
529
+ bottom: 0,
530
+ display: "flex",
531
+ justifyContent: "center",
532
+ alignItems: "center",
533
+ background: "rgba(0,0,0,0.6)",
534
+ transition: "opacity 0.3s",
535
+ opacity: 1
536
+ } }, /* @__PURE__ */ import_react9.default.createElement("img", { src: image, alt: "Preview", style: {
537
+ maxWidth: "100%",
538
+ maxHeight: "100%",
539
+ objectFit: "cover",
540
+ transition: "transform 0.3s",
541
+ borderRadius,
542
+ cursor: "zoom-in"
543
+ }, 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: {
544
+ position: "absolute",
545
+ top: "10px",
546
+ right: "10px",
547
+ background: "rgba(255,255,255,0.8)",
548
+ color: "#dc2626",
549
+ border: "none",
550
+ borderRadius: "50%",
551
+ width: "30px",
552
+ height: "30px",
553
+ cursor: "pointer",
554
+ fontSize: "16px",
555
+ transition: "background 0.3s"
556
+ }, onMouseEnter: (e) => e.currentTarget.style.background = "rgba(255,255,255,1)", onMouseLeave: (e) => e.currentTarget.style.background = "rgba(255,255,255,0.8)" }, "\xD7"));
557
+ };
478
558
  // Annotate the CommonJS export names for ESM import in node:
479
559
  0 && (module.exports = {
480
560
  AlertBanner,
@@ -484,5 +564,6 @@ var Navbar = ({
484
564
  EmptyState,
485
565
  FormInput,
486
566
  GridLayout,
567
+ ImageUploadPreview,
487
568
  Navbar
488
569
  });
package/dist/index.mjs CHANGED
@@ -433,6 +433,85 @@ 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
+ };
436
515
  export {
437
516
  AlertBanner,
438
517
  Button,
@@ -441,5 +520,6 @@ export {
441
520
  EmptyState,
442
521
  FormInput,
443
522
  GridLayout,
523
+ ImageUploadPreview,
444
524
  Navbar
445
525
  };
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.21",
4
4
  "description": "Virtual UI React Component Library",
5
5
  "author": "Ankush",
6
6
  "license": "ISC",