uiplex 1.4.0 → 1.5.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 (47) hide show
  1. package/README.md +182 -0
  2. package/dist/Alert/Alert.d.ts +13 -0
  3. package/dist/Alert/Alert.d.ts.map +1 -0
  4. package/dist/Alert/index.d.ts +3 -0
  5. package/dist/Alert/index.d.ts.map +1 -0
  6. package/dist/Avatar/Avatar.d.ts +17 -0
  7. package/dist/Avatar/Avatar.d.ts.map +1 -0
  8. package/dist/Avatar/index.d.ts +3 -0
  9. package/dist/Avatar/index.d.ts.map +1 -0
  10. package/dist/Badge/Badge.d.ts +13 -0
  11. package/dist/Badge/Badge.d.ts.map +1 -0
  12. package/dist/Badge/index.d.ts +3 -0
  13. package/dist/Badge/index.d.ts.map +1 -0
  14. package/dist/Card/Card.d.ts +48 -0
  15. package/dist/Card/Card.d.ts.map +1 -0
  16. package/dist/Card/index.d.ts +3 -0
  17. package/dist/Card/index.d.ts.map +1 -0
  18. package/dist/DateTimePicker/DateTimePicker.d.ts +17 -0
  19. package/dist/DateTimePicker/DateTimePicker.d.ts.map +1 -0
  20. package/dist/DateTimePicker/index.d.ts +3 -0
  21. package/dist/DateTimePicker/index.d.ts.map +1 -0
  22. package/dist/Drawer/Drawer.d.ts +37 -0
  23. package/dist/Drawer/Drawer.d.ts.map +1 -0
  24. package/dist/Drawer/index.d.ts +3 -0
  25. package/dist/Drawer/index.d.ts.map +1 -0
  26. package/dist/Skeleton/Skeleton.d.ts +12 -0
  27. package/dist/Skeleton/Skeleton.d.ts.map +1 -0
  28. package/dist/Skeleton/index.d.ts +3 -0
  29. package/dist/Skeleton/index.d.ts.map +1 -0
  30. package/dist/Switch/Switch.d.ts +22 -0
  31. package/dist/Switch/Switch.d.ts.map +1 -0
  32. package/dist/Switch/index.d.ts +3 -0
  33. package/dist/Switch/index.d.ts.map +1 -0
  34. package/dist/Table/Table.d.ts +49 -0
  35. package/dist/Table/Table.d.ts.map +1 -0
  36. package/dist/Table/index.d.ts +3 -0
  37. package/dist/Table/index.d.ts.map +1 -0
  38. package/dist/Upload/Upload.d.ts +14 -0
  39. package/dist/Upload/Upload.d.ts.map +1 -0
  40. package/dist/Upload/index.d.ts +3 -0
  41. package/dist/Upload/index.d.ts.map +1 -0
  42. package/dist/index.cjs +286 -0
  43. package/dist/index.css +963 -0
  44. package/dist/index.d.ts +30 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +261 -1
  47. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -1364,6 +1364,266 @@ const Breadcrumb = ({ items, separator = "/", className = "", style, ...props })
1364
1364
  }, className: `ui-breadcrumb__link ${isLastItem(index) ? "ui-breadcrumb__link--current" : ""}`.trim(), "aria-current": isLastItem(index) ? "page" : undefined, children: item.label })) : (jsxRuntime.jsx("span", { className: `ui-breadcrumb__text ${isLastItem(index) ? "ui-breadcrumb__text--current" : ""}`.trim(), "aria-current": isLastItem(index) ? "page" : undefined, children: item.label })), !isLastItem(index) && (jsxRuntime.jsx("span", { className: "ui-breadcrumb__separator", "aria-hidden": "true", children: separator }))] }, index))) }) }));
1365
1365
  };
1366
1366
 
1367
+ const Table = ({ children, variant = "default", size = "md", className = "", style, ...props }) => {
1368
+ const classes = [
1369
+ "ui-table",
1370
+ `ui-table--${variant}`,
1371
+ `ui-table--${size}`,
1372
+ className,
1373
+ ]
1374
+ .filter(Boolean)
1375
+ .join(" ");
1376
+ return (jsxRuntime.jsx("div", { className: "ui-table__wrapper", children: jsxRuntime.jsx("table", { className: classes, style: style, ...props, children: children }) }));
1377
+ };
1378
+ const TableHead = ({ children, className = "", style, ...props }) => (jsxRuntime.jsx("thead", { className: `ui-table__head ${className}`.trim(), style: style, ...props, children: children }));
1379
+ const TableBody = ({ children, className = "", style, ...props }) => (jsxRuntime.jsx("tbody", { className: `ui-table__body ${className}`.trim(), style: style, ...props, children: children }));
1380
+ const TableFooter = ({ children, className = "", style, ...props }) => (jsxRuntime.jsx("tfoot", { className: `ui-table__foot ${className}`.trim(), style: style, ...props, children: children }));
1381
+ const TableRow = ({ children, className = "", style, ...props }) => (jsxRuntime.jsx("tr", { className: `ui-table__row ${className}`.trim(), style: style, ...props, children: children }));
1382
+ const TableHeader = ({ children, className = "", style, ...props }) => (jsxRuntime.jsx("th", { className: `ui-table__header ${className}`.trim(), style: style, ...props, children: children }));
1383
+ const TableCell = ({ children, className = "", style, ...props }) => (jsxRuntime.jsx("td", { className: `ui-table__cell ${className}`.trim(), style: style, ...props, children: children }));
1384
+
1385
+ const Alert = ({ children, variant = "info", title, onClose, className = "", style, ...props }) => {
1386
+ const classes = [
1387
+ "ui-alert",
1388
+ `ui-alert--${variant}`,
1389
+ className,
1390
+ ]
1391
+ .filter(Boolean)
1392
+ .join(" ");
1393
+ return (jsxRuntime.jsxs("div", { className: classes, style: style, role: "alert", ...props, children: [jsxRuntime.jsxs("div", { className: "ui-alert__content", children: [title && jsxRuntime.jsx("div", { className: "ui-alert__title", children: title }), jsxRuntime.jsx("div", { className: "ui-alert__message", children: children })] }), onClose && (jsxRuntime.jsx("button", { type: "button", className: "ui-alert__close", onClick: onClose, "aria-label": "Close alert", children: "\u00D7" }))] }));
1394
+ };
1395
+
1396
+ const Badge = ({ children, variant = "default", size = "md", className = "", style, ...props }) => {
1397
+ const classes = [
1398
+ "ui-badge",
1399
+ `ui-badge--${variant}`,
1400
+ `ui-badge--${size}`,
1401
+ className,
1402
+ ]
1403
+ .filter(Boolean)
1404
+ .join(" ");
1405
+ return (jsxRuntime.jsx("span", { className: classes, style: style, ...props, children: children }));
1406
+ };
1407
+
1408
+ const getInitials = (name) => {
1409
+ return name
1410
+ .trim()
1411
+ .split(/\s+/)
1412
+ .map((part) => part[0])
1413
+ .join("")
1414
+ .toUpperCase()
1415
+ .slice(0, 2);
1416
+ };
1417
+ const Avatar = ({ src, alt = "", name, size = "md", backgroundColor, color, className = "", style, ...props }) => {
1418
+ const [imgError, setImgError] = React.useState(false);
1419
+ const showImage = src && !imgError;
1420
+ const initials = name ? getInitials(name) : null;
1421
+ const classes = [
1422
+ "ui-avatar",
1423
+ `ui-avatar--${size}`,
1424
+ className,
1425
+ ]
1426
+ .filter(Boolean)
1427
+ .join(" ");
1428
+ const mergedStyle = {
1429
+ ...(backgroundColor && { backgroundColor }),
1430
+ ...(color && { color }),
1431
+ ...style,
1432
+ };
1433
+ return (jsxRuntime.jsx("div", { className: classes, style: mergedStyle, ...props, children: showImage ? (jsxRuntime.jsx("img", { src: src, alt: alt, className: "ui-avatar__img", onError: () => setImgError(true) })) : (jsxRuntime.jsx("span", { className: "ui-avatar__fallback", "aria-hidden": !!alt, children: initials || (alt ? alt[0].toUpperCase() : "?") })) }));
1434
+ };
1435
+
1436
+ const Card = ({ children, variant = "default", className = "", style, ...props }) => {
1437
+ const classes = [
1438
+ "ui-card",
1439
+ variant === "dark" && "ui-card--dark",
1440
+ variant === "light" && "ui-card--light",
1441
+ className,
1442
+ ]
1443
+ .filter(Boolean)
1444
+ .join(" ");
1445
+ return (jsxRuntime.jsx("div", { className: classes, style: style, ...props, children: children }));
1446
+ };
1447
+ const CardImage = ({ src, alt, className = "", style, ...props }) => {
1448
+ return (jsxRuntime.jsx("div", { className: "ui-card__image-wrapper", children: jsxRuntime.jsx("img", { src: src, alt: alt, className: `ui-card__image ${className}`.trim(), style: style, ...props }) }));
1449
+ };
1450
+ const CardHeader = ({ children, className = "", style, ...props }) => (jsxRuntime.jsx("div", { className: `ui-card__header ${className}`.trim(), style: style, ...props, children: children }));
1451
+ const CardBody = ({ children, className = "", style, ...props }) => (jsxRuntime.jsx("div", { className: `ui-card__body ${className}`.trim(), style: style, ...props, children: children }));
1452
+ const CardFooter = ({ children, className = "", style, ...props }) => (jsxRuntime.jsx("div", { className: `ui-card__footer ${className}`.trim(), style: style, ...props, children: children }));
1453
+ const CardTitle = ({ children, className = "", style, ...props }) => (jsxRuntime.jsx("div", { className: `ui-card__title ${className}`.trim(), style: style, ...props, children: children }));
1454
+ const CardSubtitle = ({ children, className = "", style, ...props }) => (jsxRuntime.jsx("div", { className: `ui-card__subtitle ${className}`.trim(), style: style, ...props, children: children }));
1455
+
1456
+ const Switch = ({ checked, defaultChecked = false, onChange, disabled = false, size = "md", leftLabel, rightLabel, label, labelPosition = "right", className = "", id, ...props }) => {
1457
+ const [uncontrolledChecked, setUncontrolledChecked] = React.useState(defaultChecked);
1458
+ const isControlled = checked !== undefined;
1459
+ const isChecked = isControlled ? checked : uncontrolledChecked;
1460
+ const handleChange = (e) => {
1461
+ if (!isControlled)
1462
+ setUncontrolledChecked(e.target.checked);
1463
+ onChange?.(e.target.checked);
1464
+ };
1465
+ const switchId = id || `ui-switch-${React.useId()}`;
1466
+ const classes = [
1467
+ "ui-switch",
1468
+ `ui-switch--${size}`,
1469
+ disabled && "ui-switch--disabled",
1470
+ isChecked && "ui-switch--checked",
1471
+ className,
1472
+ ]
1473
+ .filter(Boolean)
1474
+ .join(" ");
1475
+ const resolvedLeft = leftLabel ?? (label && labelPosition === "left" ? label : undefined);
1476
+ const resolvedRight = rightLabel ?? (label && labelPosition === "right" ? label : undefined);
1477
+ const ariaLabel = [resolvedLeft, resolvedRight].filter(Boolean).join(" ") || undefined;
1478
+ const trackAndThumb = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("input", { type: "checkbox", id: switchId, role: "switch", checked: isChecked, disabled: disabled, onChange: handleChange, className: "ui-switch__input", "aria-checked": isChecked, "aria-label": ariaLabel, ...props }), jsxRuntime.jsx("span", { className: "ui-switch__track", children: jsxRuntime.jsx("span", { className: "ui-switch__thumb" }) })] }));
1479
+ return (jsxRuntime.jsxs("label", { className: classes, htmlFor: switchId, children: [resolvedLeft != null && jsxRuntime.jsx("span", { className: "ui-switch__label", children: resolvedLeft }), trackAndThumb, resolvedRight != null && jsxRuntime.jsx("span", { className: "ui-switch__label", children: resolvedRight })] }));
1480
+ };
1481
+
1482
+ const getInputType = (mode) => {
1483
+ switch (mode) {
1484
+ case "date":
1485
+ return "date";
1486
+ case "time":
1487
+ return "time";
1488
+ case "datetime":
1489
+ return "datetime-local";
1490
+ default:
1491
+ return "date";
1492
+ }
1493
+ };
1494
+ const DateTimePicker = ({ mode = "date", size = "md", value, defaultValue, onChange, min, max, disabled = false, className = "", id, ...props }) => {
1495
+ const inputType = getInputType(mode);
1496
+ const inputId = id || `ui-datetime-${React.useId()}`;
1497
+ const classes = [
1498
+ "ui-datetime-picker",
1499
+ `ui-datetime-picker--${mode}`,
1500
+ `ui-datetime-picker--${size}`,
1501
+ disabled && "ui-datetime-picker--disabled",
1502
+ className,
1503
+ ]
1504
+ .filter(Boolean)
1505
+ .join(" ");
1506
+ const handleChange = (e) => {
1507
+ onChange?.(e.target.value);
1508
+ };
1509
+ return (jsxRuntime.jsx("div", { className: classes, children: jsxRuntime.jsx("input", { id: inputId, type: inputType, value: value, defaultValue: defaultValue, onChange: handleChange, min: min, max: max, disabled: disabled, className: "ui-datetime-picker__input", ...props }) }));
1510
+ };
1511
+
1512
+ const defaultPlaceholder = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("span", { className: "ui-upload__icon", children: "\u2191" }), jsxRuntime.jsx("span", { className: "ui-upload__text", children: "Drag and drop or click to upload" })] }));
1513
+ const Upload = ({ onFileSelect, onFilesChange, accept, multiple = false, disabled = false, maxSize, children = defaultPlaceholder, className = "", }) => {
1514
+ const inputRef = React.useRef(null);
1515
+ const [isDragOver, setIsDragOver] = React.useState(false);
1516
+ const [error, setError] = React.useState(null);
1517
+ const handleFiles = (files) => {
1518
+ setError(null);
1519
+ if (!files || files.length === 0) {
1520
+ onFilesChange?.(null);
1521
+ return;
1522
+ }
1523
+ const fileArray = Array.from(files);
1524
+ if (maxSize) {
1525
+ const oversized = fileArray.filter((f) => f.size > maxSize);
1526
+ if (oversized.length > 0) {
1527
+ setError(`Some files exceed ${Math.round(maxSize / 1024)}KB`);
1528
+ return;
1529
+ }
1530
+ }
1531
+ onFileSelect?.(fileArray);
1532
+ onFilesChange?.(files);
1533
+ };
1534
+ const handleChange = (e) => {
1535
+ handleFiles(e.target.files);
1536
+ e.target.value = "";
1537
+ };
1538
+ const handleClick = () => {
1539
+ if (!disabled)
1540
+ inputRef.current?.click();
1541
+ };
1542
+ const handleDragOver = (e) => {
1543
+ e.preventDefault();
1544
+ e.stopPropagation();
1545
+ if (!disabled)
1546
+ setIsDragOver(true);
1547
+ };
1548
+ const handleDragLeave = (e) => {
1549
+ e.preventDefault();
1550
+ e.stopPropagation();
1551
+ setIsDragOver(false);
1552
+ };
1553
+ const handleDrop = (e) => {
1554
+ e.preventDefault();
1555
+ e.stopPropagation();
1556
+ setIsDragOver(false);
1557
+ if (disabled)
1558
+ return;
1559
+ handleFiles(e.dataTransfer.files);
1560
+ };
1561
+ const classes = [
1562
+ "ui-upload",
1563
+ disabled && "ui-upload--disabled",
1564
+ isDragOver && "ui-upload--dragover",
1565
+ error && "ui-upload--error",
1566
+ className,
1567
+ ]
1568
+ .filter(Boolean)
1569
+ .join(" ");
1570
+ return (jsxRuntime.jsxs("div", { className: classes, onClick: handleClick, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop, children: [jsxRuntime.jsx("input", { ref: inputRef, type: "file", className: "ui-upload__input", accept: accept, multiple: multiple, disabled: disabled, onChange: handleChange, tabIndex: -1, "aria-label": "Upload files" }), jsxRuntime.jsx("div", { className: "ui-upload__content", children: children }), error && jsxRuntime.jsx("div", { className: "ui-upload__error", children: error })] }));
1571
+ };
1572
+
1573
+ const Skeleton = ({ variant = "text", width, height, className = "", style, ...props }) => {
1574
+ const classes = [
1575
+ "ui-skeleton",
1576
+ `ui-skeleton--${variant}`,
1577
+ className,
1578
+ ]
1579
+ .filter(Boolean)
1580
+ .join(" ");
1581
+ const mergedStyle = {
1582
+ ...(width !== undefined && { width: typeof width === "number" ? `${width}px` : width }),
1583
+ ...(height !== undefined && { height: typeof height === "number" ? `${height}px` : height }),
1584
+ ...style,
1585
+ };
1586
+ return jsxRuntime.jsx("div", { className: classes, style: mergedStyle, "aria-busy": "true", "aria-live": "polite", ...props });
1587
+ };
1588
+
1589
+ const DrawerCloseButton = ({ onClose, className = "", }) => (jsxRuntime.jsx("button", { type: "button", className: `ui-drawer__close ${className}`, onClick: onClose, "aria-label": "Close drawer", children: jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntime.jsx("path", { d: "M12 4L4 12M4 4l8 8", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }));
1590
+ const DrawerHeader = ({ children, className = "", }) => jsxRuntime.jsx("div", { className: `ui-drawer__header ${className}`, children: children });
1591
+ const DrawerBody = ({ children, className = "", }) => jsxRuntime.jsx("div", { className: `ui-drawer__body ${className}`, children: children });
1592
+ const DrawerFooter = ({ children, className = "", }) => jsxRuntime.jsx("div", { className: `ui-drawer__footer ${className}`, children: children });
1593
+ const Drawer = ({ isOpen, onClose, children, placement = "right", size = "md", closeOnOverlayClick = true, closeOnEsc = true, level = 0, className = "", }) => {
1594
+ const drawerRef = React.useRef(null);
1595
+ const zIndex = 1000 + level * 10;
1596
+ React.useEffect(() => {
1597
+ if (!isOpen)
1598
+ return;
1599
+ const handleEsc = (e) => {
1600
+ if (closeOnEsc && e.key === "Escape")
1601
+ onClose();
1602
+ };
1603
+ document.addEventListener("keydown", handleEsc);
1604
+ document.body.style.overflow = "hidden";
1605
+ return () => {
1606
+ document.removeEventListener("keydown", handleEsc);
1607
+ document.body.style.overflow = "";
1608
+ };
1609
+ }, [isOpen, closeOnEsc, onClose]);
1610
+ if (!isOpen)
1611
+ return null;
1612
+ const handleOverlayClick = (e) => {
1613
+ if (closeOnOverlayClick && e.target === e.currentTarget)
1614
+ onClose();
1615
+ };
1616
+ const contentClasses = [
1617
+ "ui-drawer__content",
1618
+ `ui-drawer__content--${placement}`,
1619
+ `ui-drawer__content--${size}`,
1620
+ className,
1621
+ ]
1622
+ .filter(Boolean)
1623
+ .join(" ");
1624
+ return (jsxRuntime.jsxs("div", { className: "ui-drawer", ref: drawerRef, style: { zIndex }, role: "dialog", "aria-modal": "true", children: [jsxRuntime.jsx("div", { className: "ui-drawer__overlay", onClick: handleOverlayClick, "aria-hidden": "true" }), jsxRuntime.jsx("div", { className: contentClasses, children: children })] }));
1625
+ };
1626
+
1367
1627
  const useDisclosure = (defaultIsOpen = false) => {
1368
1628
  const [isOpen, setIsOpen] = React.useState(defaultIsOpen);
1369
1629
  const onOpen = React.useCallback(() => {
@@ -1579,13 +1839,29 @@ exports.Accordion = Accordion;
1579
1839
  exports.AccordionButton = AccordionButton;
1580
1840
  exports.AccordionItem = AccordionItem;
1581
1841
  exports.AccordionPanel = AccordionPanel;
1842
+ exports.Alert = Alert;
1843
+ exports.Avatar = Avatar;
1844
+ exports.Badge = Badge;
1582
1845
  exports.Box = Box;
1583
1846
  exports.Breadcrumb = Breadcrumb;
1584
1847
  exports.Button = Button;
1848
+ exports.Card = Card;
1849
+ exports.CardBody = CardBody;
1850
+ exports.CardFooter = CardFooter;
1851
+ exports.CardHeader = CardHeader;
1852
+ exports.CardImage = CardImage;
1853
+ exports.CardSubtitle = CardSubtitle;
1854
+ exports.CardTitle = CardTitle;
1585
1855
  exports.Checkbox = Checkbox;
1586
1856
  exports.CheckboxGroup = CheckboxGroup;
1587
1857
  exports.CircularProgress = CircularProgress;
1588
1858
  exports.CircularProgressLabel = CircularProgressLabel;
1859
+ exports.DateTimePicker = DateTimePicker;
1860
+ exports.Drawer = Drawer;
1861
+ exports.DrawerBody = DrawerBody;
1862
+ exports.DrawerCloseButton = DrawerCloseButton;
1863
+ exports.DrawerFooter = DrawerFooter;
1864
+ exports.DrawerHeader = DrawerHeader;
1589
1865
  exports.Flex = Flex;
1590
1866
  exports.FormControl = FormControl;
1591
1867
  exports.FormErrorMessage = FormErrorMessage;
@@ -1611,10 +1887,19 @@ exports.PopoverHeader = PopoverHeader;
1611
1887
  exports.Radio = Radio;
1612
1888
  exports.RadioGroup = RadioGroup;
1613
1889
  exports.Select = Select;
1890
+ exports.Skeleton = Skeleton;
1891
+ exports.Switch = Switch;
1614
1892
  exports.Tab = Tab;
1615
1893
  exports.TabList = TabList;
1616
1894
  exports.TabPanel = TabPanel;
1617
1895
  exports.TabPanels = TabPanels;
1896
+ exports.Table = Table;
1897
+ exports.TableBody = TableBody;
1898
+ exports.TableCell = TableCell;
1899
+ exports.TableFooter = TableFooter;
1900
+ exports.TableHead = TableHead;
1901
+ exports.TableHeader = TableHeader;
1902
+ exports.TableRow = TableRow;
1618
1903
  exports.Tabs = Tabs;
1619
1904
  exports.Text = Text;
1620
1905
  exports.Textarea = Textarea;
@@ -1626,6 +1911,7 @@ exports.ToastComponent = Toast;
1626
1911
  exports.ToastContainer = ToastContainer;
1627
1912
  exports.ToastContainerGlobal = ToastContainerGlobal;
1628
1913
  exports.Tooltip = Tooltip;
1914
+ exports.Upload = Upload;
1629
1915
  exports.useDisclosure = useDisclosure;
1630
1916
  exports.useOutsideClick = useOutsideClick;
1631
1917
  exports.useTheme = useTheme;