@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/README.md +38 -1
- package/dist/{chunk-7XUPO3ZQ.mjs → chunk-2MTTG7D2.mjs} +118 -21
- package/dist/chunk-2MTTG7D2.mjs.map +1 -0
- package/dist/components/index.d.mts +20 -2
- package/dist/components/index.d.ts +20 -2
- package/dist/components/index.js +118 -20
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +3 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +118 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -1
- package/package.json +1 -1
- package/dist/chunk-7XUPO3ZQ.mjs.map +0 -1
package/dist/components/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/components/index.ts
|
|
31
31
|
var components_exports = {};
|
|
32
32
|
__export(components_exports, {
|
|
33
|
+
CardSkeleton: () => CardSkeleton,
|
|
33
34
|
CustomCellEditor: () => CustomCellEditor,
|
|
34
35
|
CustomPagination: () => CustomPagination,
|
|
35
36
|
EztrakTabs: () => EztrakTabs,
|
|
@@ -980,10 +981,106 @@ function Modal({
|
|
|
980
981
|
return (0, import_react_dom.createPortal)(modalContent, modalRoot);
|
|
981
982
|
}
|
|
982
983
|
|
|
984
|
+
// src/components/skeleton/CardSkeleton.tsx
|
|
985
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
986
|
+
var DEFAULT_LINE_WIDTHS = ["w-32", "w-48"];
|
|
987
|
+
function shouldShowAvatar(variant, showAvatar) {
|
|
988
|
+
return showAvatar ?? variant === "profile";
|
|
989
|
+
}
|
|
990
|
+
function shouldShowImage(variant, showImage) {
|
|
991
|
+
return showImage ?? variant === "image";
|
|
992
|
+
}
|
|
993
|
+
function AvatarSkeleton({ className }) {
|
|
994
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
995
|
+
"svg",
|
|
996
|
+
{
|
|
997
|
+
className: cn("w-10 h-10 text-gray-200 dark:text-gray-700", className),
|
|
998
|
+
"aria-hidden": "true",
|
|
999
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1000
|
+
fill: "currentColor",
|
|
1001
|
+
viewBox: "0 0 20 20",
|
|
1002
|
+
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" })
|
|
1003
|
+
}
|
|
1004
|
+
);
|
|
1005
|
+
}
|
|
1006
|
+
function SkeletonBlock({
|
|
1007
|
+
widthClass,
|
|
1008
|
+
className,
|
|
1009
|
+
isFirst
|
|
1010
|
+
}) {
|
|
1011
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1012
|
+
"div",
|
|
1013
|
+
{
|
|
1014
|
+
className: cn(
|
|
1015
|
+
isFirst ? "h-2.5 mb-2" : "h-2",
|
|
1016
|
+
"bg-gray-200 rounded-full dark:bg-gray-700",
|
|
1017
|
+
widthClass,
|
|
1018
|
+
className
|
|
1019
|
+
)
|
|
1020
|
+
}
|
|
1021
|
+
);
|
|
1022
|
+
}
|
|
1023
|
+
function CardSkeleton({
|
|
1024
|
+
variant = "profile",
|
|
1025
|
+
count = 1,
|
|
1026
|
+
lines = 2,
|
|
1027
|
+
lineWidths = DEFAULT_LINE_WIDTHS,
|
|
1028
|
+
showAvatar,
|
|
1029
|
+
showImage,
|
|
1030
|
+
animationDuration = "0.7s",
|
|
1031
|
+
className,
|
|
1032
|
+
style,
|
|
1033
|
+
avatarClassName,
|
|
1034
|
+
imageClassName,
|
|
1035
|
+
contentClassName,
|
|
1036
|
+
lineClassName,
|
|
1037
|
+
srLabel = "Loading...",
|
|
1038
|
+
...props
|
|
1039
|
+
}) {
|
|
1040
|
+
const skeletons = Array.from({ length: Math.max(1, count) }, (_, index) => {
|
|
1041
|
+
const renderAvatar = shouldShowAvatar(variant, showAvatar);
|
|
1042
|
+
const renderImage = shouldShowImage(variant, showImage);
|
|
1043
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1044
|
+
"div",
|
|
1045
|
+
{
|
|
1046
|
+
className: cn("animate-pulse md:p-6 dark:border-gray-700", className),
|
|
1047
|
+
style: { animationDuration, ...style },
|
|
1048
|
+
...props,
|
|
1049
|
+
children: [
|
|
1050
|
+
renderImage ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1051
|
+
"div",
|
|
1052
|
+
{
|
|
1053
|
+
className: cn(
|
|
1054
|
+
"mb-4 h-32 w-full rounded-xl bg-gray-200 dark:bg-gray-700",
|
|
1055
|
+
imageClassName
|
|
1056
|
+
)
|
|
1057
|
+
}
|
|
1058
|
+
) : null,
|
|
1059
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: cn("flex items-center mt-4 gap-4", contentClassName), children: [
|
|
1060
|
+
renderAvatar ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(AvatarSkeleton, { className: avatarClassName }) : null,
|
|
1061
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: Array.from({ length: Math.max(1, lines) }, (_2, lineIndex) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1062
|
+
SkeletonBlock,
|
|
1063
|
+
{
|
|
1064
|
+
widthClass: lineWidths[lineIndex] ?? lineWidths[lineWidths.length - 1] ?? DEFAULT_LINE_WIDTHS[1],
|
|
1065
|
+
className: lineClassName,
|
|
1066
|
+
isFirst: lineIndex === 0
|
|
1067
|
+
},
|
|
1068
|
+
lineIndex
|
|
1069
|
+
)) })
|
|
1070
|
+
] }),
|
|
1071
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "sr-only", children: srLabel })
|
|
1072
|
+
]
|
|
1073
|
+
},
|
|
1074
|
+
index
|
|
1075
|
+
);
|
|
1076
|
+
});
|
|
1077
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: skeletons });
|
|
1078
|
+
}
|
|
1079
|
+
|
|
983
1080
|
// src/components/tooltip/ToolTip.tsx
|
|
984
1081
|
var import_react4 = require("react");
|
|
985
1082
|
var import_react_tooltip = require("react-tooltip");
|
|
986
|
-
var
|
|
1083
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
987
1084
|
var defaultTooltipStyle = {
|
|
988
1085
|
color: "#fff",
|
|
989
1086
|
borderRadius: "5px",
|
|
@@ -1010,10 +1107,10 @@ function ToolTip({
|
|
|
1010
1107
|
const tooltipId = `eztrak-tooltip-${generatedId.replace(/:/g, "")}`;
|
|
1011
1108
|
const tooltipText = String(text ?? "");
|
|
1012
1109
|
if (disabled || !tooltipText) {
|
|
1013
|
-
return /* @__PURE__ */ (0,
|
|
1110
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className, children });
|
|
1014
1111
|
}
|
|
1015
|
-
return /* @__PURE__ */ (0,
|
|
1016
|
-
/* @__PURE__ */ (0,
|
|
1112
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
1113
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1017
1114
|
"span",
|
|
1018
1115
|
{
|
|
1019
1116
|
className,
|
|
@@ -1023,7 +1120,7 @@ function ToolTip({
|
|
|
1023
1120
|
children
|
|
1024
1121
|
}
|
|
1025
1122
|
),
|
|
1026
|
-
/* @__PURE__ */ (0,
|
|
1123
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1027
1124
|
import_react_tooltip.Tooltip,
|
|
1028
1125
|
{
|
|
1029
1126
|
id: tooltipId,
|
|
@@ -1067,7 +1164,7 @@ var toDateInputValue = (date) => {
|
|
|
1067
1164
|
};
|
|
1068
1165
|
|
|
1069
1166
|
// src/components/tooltip/TooltipText.tsx
|
|
1070
|
-
var
|
|
1167
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1071
1168
|
function TooltipText({
|
|
1072
1169
|
text = "",
|
|
1073
1170
|
maxLength = 20,
|
|
@@ -1087,7 +1184,7 @@ function TooltipText({
|
|
|
1087
1184
|
const displayText = truncateText(fullText, maxLength);
|
|
1088
1185
|
const isTruncated = displayText !== fullText;
|
|
1089
1186
|
const tooltipDisabled = !showTooltip || !hasValue || tooltipWhenTruncatedOnly && !isTruncated;
|
|
1090
|
-
return /* @__PURE__ */ (0,
|
|
1187
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1091
1188
|
ToolTip,
|
|
1092
1189
|
{
|
|
1093
1190
|
text: fullText,
|
|
@@ -1099,7 +1196,7 @@ function TooltipText({
|
|
|
1099
1196
|
tooltipStyle,
|
|
1100
1197
|
wrapperTabIndex: tooltipDisabled ? void 0 : 0,
|
|
1101
1198
|
disabled: tooltipDisabled,
|
|
1102
|
-
children: /* @__PURE__ */ (0,
|
|
1199
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: cn("inline-block max-w-full align-bottom", textClassName), children: displayText })
|
|
1103
1200
|
}
|
|
1104
1201
|
);
|
|
1105
1202
|
}
|
|
@@ -1107,9 +1204,9 @@ function TooltipText({
|
|
|
1107
1204
|
// src/components/cell-editor/CustomCellEditor.tsx
|
|
1108
1205
|
var import_react5 = require("react");
|
|
1109
1206
|
var import_react_hot_toast2 = __toESM(require("react-hot-toast"));
|
|
1110
|
-
var
|
|
1207
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1111
1208
|
function ButtonSpinner() {
|
|
1112
|
-
return /* @__PURE__ */ (0,
|
|
1209
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1113
1210
|
"svg",
|
|
1114
1211
|
{
|
|
1115
1212
|
className: "animate-spin",
|
|
@@ -1119,7 +1216,7 @@ function ButtonSpinner() {
|
|
|
1119
1216
|
fill: "none",
|
|
1120
1217
|
"aria-hidden": true,
|
|
1121
1218
|
children: [
|
|
1122
|
-
/* @__PURE__ */ (0,
|
|
1219
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1123
1220
|
"circle",
|
|
1124
1221
|
{
|
|
1125
1222
|
cx: "12",
|
|
@@ -1130,7 +1227,7 @@ function ButtonSpinner() {
|
|
|
1130
1227
|
strokeOpacity: "0.25"
|
|
1131
1228
|
}
|
|
1132
1229
|
),
|
|
1133
|
-
/* @__PURE__ */ (0,
|
|
1230
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1134
1231
|
"path",
|
|
1135
1232
|
{
|
|
1136
1233
|
d: "M12 2a10 10 0 0 1 10 10",
|
|
@@ -1266,7 +1363,7 @@ var CustomCellEditor = (0, import_react5.forwardRef)(
|
|
|
1266
1363
|
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";
|
|
1267
1364
|
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";
|
|
1268
1365
|
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";
|
|
1269
|
-
return /* @__PURE__ */ (0,
|
|
1366
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1270
1367
|
"div",
|
|
1271
1368
|
{
|
|
1272
1369
|
className: cn(
|
|
@@ -1275,7 +1372,7 @@ var CustomCellEditor = (0, import_react5.forwardRef)(
|
|
|
1275
1372
|
),
|
|
1276
1373
|
style: containerStyle,
|
|
1277
1374
|
children: [
|
|
1278
|
-
isDropdown ? /* @__PURE__ */ (0,
|
|
1375
|
+
isDropdown ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1279
1376
|
"select",
|
|
1280
1377
|
{
|
|
1281
1378
|
ref: selectRef,
|
|
@@ -1285,11 +1382,11 @@ var CustomCellEditor = (0, import_react5.forwardRef)(
|
|
|
1285
1382
|
className: inputClassName ?? defaultInputClass,
|
|
1286
1383
|
disabled: isLoading,
|
|
1287
1384
|
children: [
|
|
1288
|
-
/* @__PURE__ */ (0,
|
|
1289
|
-
normalizedOptions.map((opt) => /* @__PURE__ */ (0,
|
|
1385
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: "", disabled: true, children: "Select option..." }),
|
|
1386
|
+
normalizedOptions.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: opt.value, children: opt.label }, opt.value))
|
|
1290
1387
|
]
|
|
1291
1388
|
}
|
|
1292
|
-
) : /* @__PURE__ */ (0,
|
|
1389
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1293
1390
|
"input",
|
|
1294
1391
|
{
|
|
1295
1392
|
ref: inputRef,
|
|
@@ -1302,7 +1399,7 @@ var CustomCellEditor = (0, import_react5.forwardRef)(
|
|
|
1302
1399
|
disabled: isLoading
|
|
1303
1400
|
}
|
|
1304
1401
|
),
|
|
1305
|
-
/* @__PURE__ */ (0,
|
|
1402
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1306
1403
|
"button",
|
|
1307
1404
|
{
|
|
1308
1405
|
type: "button",
|
|
@@ -1311,10 +1408,10 @@ var CustomCellEditor = (0, import_react5.forwardRef)(
|
|
|
1311
1408
|
className: saveButtonClassName ?? (saveButtonStyle ? void 0 : defaultSaveBtnClass),
|
|
1312
1409
|
style: saveButtonStyle,
|
|
1313
1410
|
title: "Save (Enter)",
|
|
1314
|
-
children: isLoading ? loadingIndicator ?? /* @__PURE__ */ (0,
|
|
1411
|
+
children: isLoading ? loadingIndicator ?? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ButtonSpinner, {}) : saveButtonContent ?? "Save"
|
|
1315
1412
|
}
|
|
1316
1413
|
),
|
|
1317
|
-
/* @__PURE__ */ (0,
|
|
1414
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1318
1415
|
"button",
|
|
1319
1416
|
{
|
|
1320
1417
|
type: "button",
|
|
@@ -1334,6 +1431,7 @@ var CustomCellEditor = (0, import_react5.forwardRef)(
|
|
|
1334
1431
|
CustomCellEditor.displayName = "CustomCellEditor";
|
|
1335
1432
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1336
1433
|
0 && (module.exports = {
|
|
1434
|
+
CardSkeleton,
|
|
1337
1435
|
CustomCellEditor,
|
|
1338
1436
|
CustomPagination,
|
|
1339
1437
|
EztrakTabs,
|