@eztrak/shared 0.8.1 → 0.9.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.js CHANGED
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
+ CardSkeleton: () => CardSkeleton,
33
34
  CustomCellEditor: () => CustomCellEditor,
34
35
  CustomPagination: () => CustomPagination,
35
36
  EztrakTabs: () => EztrakTabs,
@@ -1318,10 +1319,106 @@ function Modal({
1318
1319
  return (0, import_react_dom.createPortal)(modalContent, modalRoot);
1319
1320
  }
1320
1321
 
1322
+ // src/components/skeleton/CardSkeleton.tsx
1323
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1324
+ var DEFAULT_LINE_WIDTHS = ["w-32", "w-48"];
1325
+ function shouldShowAvatar(variant, showAvatar) {
1326
+ return showAvatar ?? variant === "profile";
1327
+ }
1328
+ function shouldShowImage(variant, showImage) {
1329
+ return showImage ?? variant === "image";
1330
+ }
1331
+ function AvatarSkeleton({ className }) {
1332
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1333
+ "svg",
1334
+ {
1335
+ className: cn("w-10 h-10 text-gray-200 dark:text-gray-700", className),
1336
+ "aria-hidden": "true",
1337
+ xmlns: "http://www.w3.org/2000/svg",
1338
+ fill: "currentColor",
1339
+ viewBox: "0 0 20 20",
1340
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M10 0a10 10 0 1 0 10 10A10.011 10.011 0 0 0 10 0Zm0 5a3 3 0 1 1 0 6 3 3 0 0 1 0-6Zm0 13a8.949 8.949 0 0 1-4.951-1.488A3.987 3.987 0 0 1 9 13h2a3.987 3.987 0 0 1 3.951 3.512A8.949 8.949 0 0 1 10 18Z" })
1341
+ }
1342
+ );
1343
+ }
1344
+ function SkeletonBlock({
1345
+ widthClass,
1346
+ className,
1347
+ isFirst
1348
+ }) {
1349
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1350
+ "div",
1351
+ {
1352
+ className: cn(
1353
+ isFirst ? "h-2.5 mb-2" : "h-2",
1354
+ "bg-gray-200 rounded-full dark:bg-gray-700",
1355
+ widthClass,
1356
+ className
1357
+ )
1358
+ }
1359
+ );
1360
+ }
1361
+ function CardSkeleton({
1362
+ variant = "profile",
1363
+ count = 1,
1364
+ lines = 2,
1365
+ lineWidths = DEFAULT_LINE_WIDTHS,
1366
+ showAvatar,
1367
+ showImage,
1368
+ animationDuration = "0.7s",
1369
+ className,
1370
+ style,
1371
+ avatarClassName,
1372
+ imageClassName,
1373
+ contentClassName,
1374
+ lineClassName,
1375
+ srLabel = "Loading...",
1376
+ ...props
1377
+ }) {
1378
+ const skeletons = Array.from({ length: Math.max(1, count) }, (_, index) => {
1379
+ const renderAvatar = shouldShowAvatar(variant, showAvatar);
1380
+ const renderImage = shouldShowImage(variant, showImage);
1381
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1382
+ "div",
1383
+ {
1384
+ className: cn("animate-pulse md:p-6 dark:border-gray-700", className),
1385
+ style: { animationDuration, ...style },
1386
+ ...props,
1387
+ children: [
1388
+ renderImage ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1389
+ "div",
1390
+ {
1391
+ className: cn(
1392
+ "mb-4 h-32 w-full rounded-xl bg-gray-200 dark:bg-gray-700",
1393
+ imageClassName
1394
+ )
1395
+ }
1396
+ ) : null,
1397
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: cn("flex items-center mt-4 gap-4", contentClassName), children: [
1398
+ renderAvatar ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(AvatarSkeleton, { className: avatarClassName }) : null,
1399
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: Array.from({ length: Math.max(1, lines) }, (_2, lineIndex) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1400
+ SkeletonBlock,
1401
+ {
1402
+ widthClass: lineWidths[lineIndex] ?? lineWidths[lineWidths.length - 1] ?? DEFAULT_LINE_WIDTHS[1],
1403
+ className: lineClassName,
1404
+ isFirst: lineIndex === 0
1405
+ },
1406
+ lineIndex
1407
+ )) })
1408
+ ] }),
1409
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "sr-only", children: srLabel })
1410
+ ]
1411
+ },
1412
+ index
1413
+ );
1414
+ });
1415
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: skeletons });
1416
+ }
1417
+
1321
1418
  // src/components/tooltip/ToolTip.tsx
1322
1419
  var import_react6 = require("react");
1323
1420
  var import_react_tooltip = require("react-tooltip");
1324
- var import_jsx_runtime7 = require("react/jsx-runtime");
1421
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1325
1422
  var defaultTooltipStyle = {
1326
1423
  color: "#fff",
1327
1424
  borderRadius: "5px",
@@ -1348,10 +1445,10 @@ function ToolTip({
1348
1445
  const tooltipId = `eztrak-tooltip-${generatedId.replace(/:/g, "")}`;
1349
1446
  const tooltipText = String(text ?? "");
1350
1447
  if (disabled || !tooltipText) {
1351
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className, children });
1448
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className, children });
1352
1449
  }
1353
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1354
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1450
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1451
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1355
1452
  "span",
1356
1453
  {
1357
1454
  className,
@@ -1361,7 +1458,7 @@ function ToolTip({
1361
1458
  children
1362
1459
  }
1363
1460
  ),
1364
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1461
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1365
1462
  import_react_tooltip.Tooltip,
1366
1463
  {
1367
1464
  id: tooltipId,
@@ -1377,7 +1474,7 @@ function ToolTip({
1377
1474
  }
1378
1475
 
1379
1476
  // src/components/tooltip/TooltipText.tsx
1380
- var import_jsx_runtime8 = require("react/jsx-runtime");
1477
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1381
1478
  function TooltipText({
1382
1479
  text = "",
1383
1480
  maxLength = 20,
@@ -1397,7 +1494,7 @@ function TooltipText({
1397
1494
  const displayText = truncateText(fullText, maxLength);
1398
1495
  const isTruncated = displayText !== fullText;
1399
1496
  const tooltipDisabled = !showTooltip || !hasValue || tooltipWhenTruncatedOnly && !isTruncated;
1400
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1497
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1401
1498
  ToolTip,
1402
1499
  {
1403
1500
  text: fullText,
@@ -1409,7 +1506,7 @@ function TooltipText({
1409
1506
  tooltipStyle,
1410
1507
  wrapperTabIndex: tooltipDisabled ? void 0 : 0,
1411
1508
  disabled: tooltipDisabled,
1412
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: cn("inline-block max-w-full align-bottom", textClassName), children: displayText })
1509
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: cn("inline-block max-w-full align-bottom", textClassName), children: displayText })
1413
1510
  }
1414
1511
  );
1415
1512
  }
@@ -1417,9 +1514,9 @@ function TooltipText({
1417
1514
  // src/components/cell-editor/CustomCellEditor.tsx
1418
1515
  var import_react7 = require("react");
1419
1516
  var import_react_hot_toast2 = __toESM(require("react-hot-toast"));
1420
- var import_jsx_runtime9 = require("react/jsx-runtime");
1517
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1421
1518
  function ButtonSpinner() {
1422
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1519
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1423
1520
  "svg",
1424
1521
  {
1425
1522
  className: "animate-spin",
@@ -1429,7 +1526,7 @@ function ButtonSpinner() {
1429
1526
  fill: "none",
1430
1527
  "aria-hidden": true,
1431
1528
  children: [
1432
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1529
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1433
1530
  "circle",
1434
1531
  {
1435
1532
  cx: "12",
@@ -1440,7 +1537,7 @@ function ButtonSpinner() {
1440
1537
  strokeOpacity: "0.25"
1441
1538
  }
1442
1539
  ),
1443
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1540
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1444
1541
  "path",
1445
1542
  {
1446
1543
  d: "M12 2a10 10 0 0 1 10 10",
@@ -1576,7 +1673,7 @@ var CustomCellEditor = (0, import_react7.forwardRef)(
1576
1673
  const defaultInputClass = "w-48 px-2 py-1 text-sm border border-gray-200 rounded-md bg-white focus:outline-none focus:ring-1 focus:ring-blue-400";
1577
1674
  const defaultSaveBtnClass = "px-3 py-1 text-sm font-medium text-white bg-green-500 rounded-md hover:bg-green-600 disabled:opacity-50 whitespace-nowrap shrink-0";
1578
1675
  const defaultCancelBtnClass = "px-3 py-1 text-sm font-medium text-white bg-red-500 rounded-md hover:bg-red-600 disabled:opacity-50 whitespace-nowrap shrink-0";
1579
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1676
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1580
1677
  "div",
1581
1678
  {
1582
1679
  className: cn(
@@ -1585,7 +1682,7 @@ var CustomCellEditor = (0, import_react7.forwardRef)(
1585
1682
  ),
1586
1683
  style: containerStyle,
1587
1684
  children: [
1588
- isDropdown ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1685
+ isDropdown ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1589
1686
  "select",
1590
1687
  {
1591
1688
  ref: selectRef,
@@ -1595,11 +1692,11 @@ var CustomCellEditor = (0, import_react7.forwardRef)(
1595
1692
  className: inputClassName ?? defaultInputClass,
1596
1693
  disabled: isLoading,
1597
1694
  children: [
1598
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "", disabled: true, children: "Select option..." }),
1599
- normalizedOptions.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: opt.value, children: opt.label }, opt.value))
1695
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: "", disabled: true, children: "Select option..." }),
1696
+ normalizedOptions.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: opt.value, children: opt.label }, opt.value))
1600
1697
  ]
1601
1698
  }
1602
- ) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1699
+ ) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1603
1700
  "input",
1604
1701
  {
1605
1702
  ref: inputRef,
@@ -1612,7 +1709,7 @@ var CustomCellEditor = (0, import_react7.forwardRef)(
1612
1709
  disabled: isLoading
1613
1710
  }
1614
1711
  ),
1615
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1712
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1616
1713
  "button",
1617
1714
  {
1618
1715
  type: "button",
@@ -1621,10 +1718,10 @@ var CustomCellEditor = (0, import_react7.forwardRef)(
1621
1718
  className: saveButtonClassName ?? (saveButtonStyle ? void 0 : defaultSaveBtnClass),
1622
1719
  style: saveButtonStyle,
1623
1720
  title: "Save (Enter)",
1624
- children: isLoading ? loadingIndicator ?? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ButtonSpinner, {}) : saveButtonContent ?? "Save"
1721
+ children: isLoading ? loadingIndicator ?? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ButtonSpinner, {}) : saveButtonContent ?? "Save"
1625
1722
  }
1626
1723
  ),
1627
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1724
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1628
1725
  "button",
1629
1726
  {
1630
1727
  type: "button",
@@ -1644,6 +1741,7 @@ var CustomCellEditor = (0, import_react7.forwardRef)(
1644
1741
  CustomCellEditor.displayName = "CustomCellEditor";
1645
1742
  // Annotate the CommonJS export names for ESM import in node:
1646
1743
  0 && (module.exports = {
1744
+ CardSkeleton,
1647
1745
  CustomCellEditor,
1648
1746
  CustomPagination,
1649
1747
  EztrakTabs,