@eztrak/shared 0.8.0 → 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,11 +1458,12 @@ 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,
1368
1465
  place: placement,
1466
+ positionStrategy: "fixed",
1369
1467
  delayShow,
1370
1468
  delayHide,
1371
1469
  className: tooltipClassName,
@@ -1376,7 +1474,7 @@ function ToolTip({
1376
1474
  }
1377
1475
 
1378
1476
  // src/components/tooltip/TooltipText.tsx
1379
- var import_jsx_runtime8 = require("react/jsx-runtime");
1477
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1380
1478
  function TooltipText({
1381
1479
  text = "",
1382
1480
  maxLength = 20,
@@ -1396,7 +1494,7 @@ function TooltipText({
1396
1494
  const displayText = truncateText(fullText, maxLength);
1397
1495
  const isTruncated = displayText !== fullText;
1398
1496
  const tooltipDisabled = !showTooltip || !hasValue || tooltipWhenTruncatedOnly && !isTruncated;
1399
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1497
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1400
1498
  ToolTip,
1401
1499
  {
1402
1500
  text: fullText,
@@ -1408,7 +1506,7 @@ function TooltipText({
1408
1506
  tooltipStyle,
1409
1507
  wrapperTabIndex: tooltipDisabled ? void 0 : 0,
1410
1508
  disabled: tooltipDisabled,
1411
- 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 })
1412
1510
  }
1413
1511
  );
1414
1512
  }
@@ -1416,9 +1514,9 @@ function TooltipText({
1416
1514
  // src/components/cell-editor/CustomCellEditor.tsx
1417
1515
  var import_react7 = require("react");
1418
1516
  var import_react_hot_toast2 = __toESM(require("react-hot-toast"));
1419
- var import_jsx_runtime9 = require("react/jsx-runtime");
1517
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1420
1518
  function ButtonSpinner() {
1421
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1519
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1422
1520
  "svg",
1423
1521
  {
1424
1522
  className: "animate-spin",
@@ -1428,7 +1526,7 @@ function ButtonSpinner() {
1428
1526
  fill: "none",
1429
1527
  "aria-hidden": true,
1430
1528
  children: [
1431
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1529
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1432
1530
  "circle",
1433
1531
  {
1434
1532
  cx: "12",
@@ -1439,7 +1537,7 @@ function ButtonSpinner() {
1439
1537
  strokeOpacity: "0.25"
1440
1538
  }
1441
1539
  ),
1442
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1540
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1443
1541
  "path",
1444
1542
  {
1445
1543
  d: "M12 2a10 10 0 0 1 10 10",
@@ -1575,7 +1673,7 @@ var CustomCellEditor = (0, import_react7.forwardRef)(
1575
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";
1576
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";
1577
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";
1578
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1676
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1579
1677
  "div",
1580
1678
  {
1581
1679
  className: cn(
@@ -1584,7 +1682,7 @@ var CustomCellEditor = (0, import_react7.forwardRef)(
1584
1682
  ),
1585
1683
  style: containerStyle,
1586
1684
  children: [
1587
- isDropdown ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1685
+ isDropdown ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1588
1686
  "select",
1589
1687
  {
1590
1688
  ref: selectRef,
@@ -1594,11 +1692,11 @@ var CustomCellEditor = (0, import_react7.forwardRef)(
1594
1692
  className: inputClassName ?? defaultInputClass,
1595
1693
  disabled: isLoading,
1596
1694
  children: [
1597
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "", disabled: true, children: "Select option..." }),
1598
- 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))
1599
1697
  ]
1600
1698
  }
1601
- ) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1699
+ ) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1602
1700
  "input",
1603
1701
  {
1604
1702
  ref: inputRef,
@@ -1611,7 +1709,7 @@ var CustomCellEditor = (0, import_react7.forwardRef)(
1611
1709
  disabled: isLoading
1612
1710
  }
1613
1711
  ),
1614
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1712
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1615
1713
  "button",
1616
1714
  {
1617
1715
  type: "button",
@@ -1620,10 +1718,10 @@ var CustomCellEditor = (0, import_react7.forwardRef)(
1620
1718
  className: saveButtonClassName ?? (saveButtonStyle ? void 0 : defaultSaveBtnClass),
1621
1719
  style: saveButtonStyle,
1622
1720
  title: "Save (Enter)",
1623
- 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"
1624
1722
  }
1625
1723
  ),
1626
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1724
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1627
1725
  "button",
1628
1726
  {
1629
1727
  type: "button",
@@ -1643,6 +1741,7 @@ var CustomCellEditor = (0, import_react7.forwardRef)(
1643
1741
  CustomCellEditor.displayName = "CustomCellEditor";
1644
1742
  // Annotate the CommonJS export names for ESM import in node:
1645
1743
  0 && (module.exports = {
1744
+ CardSkeleton,
1646
1745
  CustomCellEditor,
1647
1746
  CustomPagination,
1648
1747
  EztrakTabs,