virtual-ui-lib 1.0.19 → 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 +160 -2
- package/dist/index.mjs +157 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35,7 +35,9 @@ __export(index_exports, {
|
|
|
35
35
|
Dropdown: () => Dropdown,
|
|
36
36
|
EmptyState: () => EmptyState,
|
|
37
37
|
FormInput: () => FormInput,
|
|
38
|
-
GridLayout: () => GridLayout
|
|
38
|
+
GridLayout: () => GridLayout,
|
|
39
|
+
ImageUploadPreview: () => ImageUploadPreview,
|
|
40
|
+
Navbar: () => Navbar
|
|
39
41
|
});
|
|
40
42
|
module.exports = __toCommonJS(index_exports);
|
|
41
43
|
|
|
@@ -399,6 +401,160 @@ var GridLayout = ({
|
|
|
399
401
|
}
|
|
400
402
|
return /* @__PURE__ */ import_react7.default.createElement("div", { style: { display: "grid", gridTemplateColumns: `repeat(${cols}, 1fr)`, gap: spacing } }, items.map(renderItem));
|
|
401
403
|
};
|
|
404
|
+
|
|
405
|
+
// src/components/Navbar/Navbar.jsx
|
|
406
|
+
var import_react8 = __toESM(require("react"));
|
|
407
|
+
var Navbar = ({
|
|
408
|
+
logo = "Logo",
|
|
409
|
+
links = [{ name: "Home", href: "#" }, { name: "About", href: "#" }, { name: "Services", href: "#" }, { name: "Contact", href: "#" }],
|
|
410
|
+
bgColor = "#0f172a",
|
|
411
|
+
linkColor = "#f1f5f9",
|
|
412
|
+
hoverColor = "#7c3aed",
|
|
413
|
+
stickyColor = "#1e293b",
|
|
414
|
+
radius = "8px"
|
|
415
|
+
}) => {
|
|
416
|
+
const [isMobileMenuOpen, setMobileMenuOpen] = (0, import_react8.useState)(false);
|
|
417
|
+
const [isSticky, setSticky] = (0, import_react8.useState)(false);
|
|
418
|
+
(0, import_react8.useEffect)(() => {
|
|
419
|
+
const handleScroll = () => {
|
|
420
|
+
setSticky(window.scrollY > 50);
|
|
421
|
+
};
|
|
422
|
+
window.addEventListener("scroll", handleScroll);
|
|
423
|
+
return () => window.removeEventListener("scroll", handleScroll);
|
|
424
|
+
}, []);
|
|
425
|
+
return /* @__PURE__ */ import_react8.default.createElement("nav", { style: {
|
|
426
|
+
background: isSticky ? stickyColor : bgColor,
|
|
427
|
+
position: isSticky ? "fixed" : "relative",
|
|
428
|
+
width: "100%",
|
|
429
|
+
padding: "10px 20px",
|
|
430
|
+
boxShadow: isSticky ? "0 2px 10px rgba(0,0,0,0.2)" : "none",
|
|
431
|
+
transition: "background 0.3s ease"
|
|
432
|
+
} }, /* @__PURE__ */ import_react8.default.createElement("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" } }, /* @__PURE__ */ import_react8.default.createElement("div", { style: { color: linkColor, fontSize: "20px", fontWeight: "600" } }, logo), /* @__PURE__ */ import_react8.default.createElement("div", { style: { display: "flex", alignItems: "center" } }, /* @__PURE__ */ import_react8.default.createElement("ul", { style: { display: "flex", listStyle: "none", gap: "20px", margin: 0, padding: 0 } }, links.map((link) => /* @__PURE__ */ import_react8.default.createElement("li", { key: link.name }, /* @__PURE__ */ import_react8.default.createElement("a", { href: link.href, style: {
|
|
433
|
+
textDecoration: "none",
|
|
434
|
+
color: linkColor,
|
|
435
|
+
position: "relative",
|
|
436
|
+
fontSize: "16px",
|
|
437
|
+
transition: "color 0.3s"
|
|
438
|
+
}, onMouseOver: (e) => e.currentTarget.style.color = hoverColor, onMouseOut: (e) => e.currentTarget.style.color = linkColor }, link.name, /* @__PURE__ */ import_react8.default.createElement("span", { style: {
|
|
439
|
+
position: "absolute",
|
|
440
|
+
bottom: "-3px",
|
|
441
|
+
left: 0,
|
|
442
|
+
width: "100%",
|
|
443
|
+
height: "2px",
|
|
444
|
+
background: hoverColor,
|
|
445
|
+
transform: "scaleX(0)",
|
|
446
|
+
transition: "transform 0.3s ease"
|
|
447
|
+
}, className: "underline" }))))), /* @__PURE__ */ import_react8.default.createElement("button", { onClick: () => setMobileMenuOpen(true), style: {
|
|
448
|
+
background: "transparent",
|
|
449
|
+
color: linkColor,
|
|
450
|
+
border: "none",
|
|
451
|
+
cursor: "pointer",
|
|
452
|
+
fontSize: "16px",
|
|
453
|
+
marginLeft: "20px"
|
|
454
|
+
} }, "\u2630"))), isMobileMenuOpen && /* @__PURE__ */ import_react8.default.createElement("div", { style: {
|
|
455
|
+
position: "fixed",
|
|
456
|
+
top: 0,
|
|
457
|
+
right: 0,
|
|
458
|
+
width: "250px",
|
|
459
|
+
height: "100%",
|
|
460
|
+
background: bgColor,
|
|
461
|
+
boxShadow: "-4px 0 10px rgba(0,0,0,0.5)",
|
|
462
|
+
padding: "20px",
|
|
463
|
+
transform: "translateX(0)",
|
|
464
|
+
transition: "transform 0.3s ease"
|
|
465
|
+
} }, /* @__PURE__ */ import_react8.default.createElement("button", { onClick: () => setMobileMenuOpen(false), style: {
|
|
466
|
+
background: "transparent",
|
|
467
|
+
color: linkColor,
|
|
468
|
+
border: "none",
|
|
469
|
+
cursor: "pointer",
|
|
470
|
+
fontSize: "16px",
|
|
471
|
+
marginBottom: "20px"
|
|
472
|
+
} }, "\u2716"), /* @__PURE__ */ import_react8.default.createElement("ul", { style: { listStyle: "none", padding: 0 } }, links.map((link) => /* @__PURE__ */ import_react8.default.createElement("li", { key: link.name, style: { margin: "10px 0" } }, /* @__PURE__ */ import_react8.default.createElement("a", { href: link.href, style: {
|
|
473
|
+
textDecoration: "none",
|
|
474
|
+
color: linkColor,
|
|
475
|
+
fontSize: "18px",
|
|
476
|
+
transition: "color 0.3s"
|
|
477
|
+
}, onMouseOver: (e) => e.currentTarget.style.color = hoverColor, onMouseOut: (e) => e.currentTarget.style.color = linkColor }, link.name))))));
|
|
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
|
+
};
|
|
402
558
|
// Annotate the CommonJS export names for ESM import in node:
|
|
403
559
|
0 && (module.exports = {
|
|
404
560
|
AlertBanner,
|
|
@@ -407,5 +563,7 @@ var GridLayout = ({
|
|
|
407
563
|
Dropdown,
|
|
408
564
|
EmptyState,
|
|
409
565
|
FormInput,
|
|
410
|
-
GridLayout
|
|
566
|
+
GridLayout,
|
|
567
|
+
ImageUploadPreview,
|
|
568
|
+
Navbar
|
|
411
569
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -358,6 +358,160 @@ var GridLayout = ({
|
|
|
358
358
|
}
|
|
359
359
|
return /* @__PURE__ */ React7.createElement("div", { style: { display: "grid", gridTemplateColumns: `repeat(${cols}, 1fr)`, gap: spacing } }, items.map(renderItem));
|
|
360
360
|
};
|
|
361
|
+
|
|
362
|
+
// src/components/Navbar/Navbar.jsx
|
|
363
|
+
import React8, { useState as useState5, useEffect as useEffect4 } from "react";
|
|
364
|
+
var Navbar = ({
|
|
365
|
+
logo = "Logo",
|
|
366
|
+
links = [{ name: "Home", href: "#" }, { name: "About", href: "#" }, { name: "Services", href: "#" }, { name: "Contact", href: "#" }],
|
|
367
|
+
bgColor = "#0f172a",
|
|
368
|
+
linkColor = "#f1f5f9",
|
|
369
|
+
hoverColor = "#7c3aed",
|
|
370
|
+
stickyColor = "#1e293b",
|
|
371
|
+
radius = "8px"
|
|
372
|
+
}) => {
|
|
373
|
+
const [isMobileMenuOpen, setMobileMenuOpen] = useState5(false);
|
|
374
|
+
const [isSticky, setSticky] = useState5(false);
|
|
375
|
+
useEffect4(() => {
|
|
376
|
+
const handleScroll = () => {
|
|
377
|
+
setSticky(window.scrollY > 50);
|
|
378
|
+
};
|
|
379
|
+
window.addEventListener("scroll", handleScroll);
|
|
380
|
+
return () => window.removeEventListener("scroll", handleScroll);
|
|
381
|
+
}, []);
|
|
382
|
+
return /* @__PURE__ */ React8.createElement("nav", { style: {
|
|
383
|
+
background: isSticky ? stickyColor : bgColor,
|
|
384
|
+
position: isSticky ? "fixed" : "relative",
|
|
385
|
+
width: "100%",
|
|
386
|
+
padding: "10px 20px",
|
|
387
|
+
boxShadow: isSticky ? "0 2px 10px rgba(0,0,0,0.2)" : "none",
|
|
388
|
+
transition: "background 0.3s ease"
|
|
389
|
+
} }, /* @__PURE__ */ React8.createElement("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" } }, /* @__PURE__ */ React8.createElement("div", { style: { color: linkColor, fontSize: "20px", fontWeight: "600" } }, logo), /* @__PURE__ */ React8.createElement("div", { style: { display: "flex", alignItems: "center" } }, /* @__PURE__ */ React8.createElement("ul", { style: { display: "flex", listStyle: "none", gap: "20px", margin: 0, padding: 0 } }, links.map((link) => /* @__PURE__ */ React8.createElement("li", { key: link.name }, /* @__PURE__ */ React8.createElement("a", { href: link.href, style: {
|
|
390
|
+
textDecoration: "none",
|
|
391
|
+
color: linkColor,
|
|
392
|
+
position: "relative",
|
|
393
|
+
fontSize: "16px",
|
|
394
|
+
transition: "color 0.3s"
|
|
395
|
+
}, onMouseOver: (e) => e.currentTarget.style.color = hoverColor, onMouseOut: (e) => e.currentTarget.style.color = linkColor }, link.name, /* @__PURE__ */ React8.createElement("span", { style: {
|
|
396
|
+
position: "absolute",
|
|
397
|
+
bottom: "-3px",
|
|
398
|
+
left: 0,
|
|
399
|
+
width: "100%",
|
|
400
|
+
height: "2px",
|
|
401
|
+
background: hoverColor,
|
|
402
|
+
transform: "scaleX(0)",
|
|
403
|
+
transition: "transform 0.3s ease"
|
|
404
|
+
}, className: "underline" }))))), /* @__PURE__ */ React8.createElement("button", { onClick: () => setMobileMenuOpen(true), style: {
|
|
405
|
+
background: "transparent",
|
|
406
|
+
color: linkColor,
|
|
407
|
+
border: "none",
|
|
408
|
+
cursor: "pointer",
|
|
409
|
+
fontSize: "16px",
|
|
410
|
+
marginLeft: "20px"
|
|
411
|
+
} }, "\u2630"))), isMobileMenuOpen && /* @__PURE__ */ React8.createElement("div", { style: {
|
|
412
|
+
position: "fixed",
|
|
413
|
+
top: 0,
|
|
414
|
+
right: 0,
|
|
415
|
+
width: "250px",
|
|
416
|
+
height: "100%",
|
|
417
|
+
background: bgColor,
|
|
418
|
+
boxShadow: "-4px 0 10px rgba(0,0,0,0.5)",
|
|
419
|
+
padding: "20px",
|
|
420
|
+
transform: "translateX(0)",
|
|
421
|
+
transition: "transform 0.3s ease"
|
|
422
|
+
} }, /* @__PURE__ */ React8.createElement("button", { onClick: () => setMobileMenuOpen(false), style: {
|
|
423
|
+
background: "transparent",
|
|
424
|
+
color: linkColor,
|
|
425
|
+
border: "none",
|
|
426
|
+
cursor: "pointer",
|
|
427
|
+
fontSize: "16px",
|
|
428
|
+
marginBottom: "20px"
|
|
429
|
+
} }, "\u2716"), /* @__PURE__ */ React8.createElement("ul", { style: { listStyle: "none", padding: 0 } }, links.map((link) => /* @__PURE__ */ React8.createElement("li", { key: link.name, style: { margin: "10px 0" } }, /* @__PURE__ */ React8.createElement("a", { href: link.href, style: {
|
|
430
|
+
textDecoration: "none",
|
|
431
|
+
color: linkColor,
|
|
432
|
+
fontSize: "18px",
|
|
433
|
+
transition: "color 0.3s"
|
|
434
|
+
}, onMouseOver: (e) => e.currentTarget.style.color = hoverColor, onMouseOut: (e) => e.currentTarget.style.color = linkColor }, link.name))))));
|
|
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
|
+
};
|
|
361
515
|
export {
|
|
362
516
|
AlertBanner,
|
|
363
517
|
Button,
|
|
@@ -365,5 +519,7 @@ export {
|
|
|
365
519
|
Dropdown,
|
|
366
520
|
EmptyState,
|
|
367
521
|
FormInput,
|
|
368
|
-
GridLayout
|
|
522
|
+
GridLayout,
|
|
523
|
+
ImageUploadPreview,
|
|
524
|
+
Navbar
|
|
369
525
|
};
|