@eztrak/shared 0.7.4 → 0.8.1
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 +44 -2
- package/dist/{chunk-FSCPBM3X.mjs → chunk-7XUPO3ZQ.mjs} +113 -14
- package/dist/chunk-7XUPO3ZQ.mjs.map +1 -0
- package/dist/components/index.d.mts +33 -1
- package/dist/components/index.d.ts +33 -1
- package/dist/components/index.js +130 -24
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +7 -3
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +121 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -2
- package/package.json +3 -1
- package/dist/chunk-FSCPBM3X.mjs.map +0 -1
package/dist/components/index.js
CHANGED
|
@@ -38,7 +38,9 @@ __export(components_exports, {
|
|
|
38
38
|
ResetColumnsButton: () => ResetColumnsButton,
|
|
39
39
|
ResetFiltersButton: () => ResetFiltersButton,
|
|
40
40
|
SearchInput: () => SearchInput,
|
|
41
|
-
TableLayoutToolbarControls: () => TableLayoutToolbarControls
|
|
41
|
+
TableLayoutToolbarControls: () => TableLayoutToolbarControls,
|
|
42
|
+
ToolTip: () => ToolTip,
|
|
43
|
+
TooltipText: () => TooltipText
|
|
42
44
|
});
|
|
43
45
|
module.exports = __toCommonJS(components_exports);
|
|
44
46
|
|
|
@@ -978,11 +980,73 @@ function Modal({
|
|
|
978
980
|
return (0, import_react_dom.createPortal)(modalContent, modalRoot);
|
|
979
981
|
}
|
|
980
982
|
|
|
981
|
-
// src/components/
|
|
983
|
+
// src/components/tooltip/ToolTip.tsx
|
|
982
984
|
var import_react4 = require("react");
|
|
983
|
-
var
|
|
985
|
+
var import_react_tooltip = require("react-tooltip");
|
|
986
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
987
|
+
var defaultTooltipStyle = {
|
|
988
|
+
color: "#fff",
|
|
989
|
+
borderRadius: "5px",
|
|
990
|
+
zIndex: 999,
|
|
991
|
+
textAlign: "justify",
|
|
992
|
+
maxWidth: "300px",
|
|
993
|
+
whiteSpace: "pre-wrap",
|
|
994
|
+
wordWrap: "break-word",
|
|
995
|
+
overflowWrap: "break-word"
|
|
996
|
+
};
|
|
997
|
+
function ToolTip({
|
|
998
|
+
text = "tool tip",
|
|
999
|
+
placement = "top",
|
|
1000
|
+
delayShow,
|
|
1001
|
+
delayHide,
|
|
1002
|
+
className,
|
|
1003
|
+
tooltipClassName,
|
|
1004
|
+
tooltipStyle,
|
|
1005
|
+
wrapperTabIndex,
|
|
1006
|
+
disabled = false,
|
|
1007
|
+
children
|
|
1008
|
+
}) {
|
|
1009
|
+
const generatedId = (0, import_react4.useId)();
|
|
1010
|
+
const tooltipId = `eztrak-tooltip-${generatedId.replace(/:/g, "")}`;
|
|
1011
|
+
const tooltipText = String(text ?? "");
|
|
1012
|
+
if (disabled || !tooltipText) {
|
|
1013
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className, children });
|
|
1014
|
+
}
|
|
1015
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
1016
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1017
|
+
"span",
|
|
1018
|
+
{
|
|
1019
|
+
className,
|
|
1020
|
+
"data-tooltip-id": tooltipId,
|
|
1021
|
+
"data-tooltip-content": tooltipText,
|
|
1022
|
+
tabIndex: wrapperTabIndex,
|
|
1023
|
+
children
|
|
1024
|
+
}
|
|
1025
|
+
),
|
|
1026
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1027
|
+
import_react_tooltip.Tooltip,
|
|
1028
|
+
{
|
|
1029
|
+
id: tooltipId,
|
|
1030
|
+
place: placement,
|
|
1031
|
+
positionStrategy: "fixed",
|
|
1032
|
+
delayShow,
|
|
1033
|
+
delayHide,
|
|
1034
|
+
className: tooltipClassName,
|
|
1035
|
+
style: { ...defaultTooltipStyle, ...tooltipStyle }
|
|
1036
|
+
}
|
|
1037
|
+
)
|
|
1038
|
+
] });
|
|
1039
|
+
}
|
|
984
1040
|
|
|
985
1041
|
// src/utils/helpers.ts
|
|
1042
|
+
var truncateText = (text, maxLength = 20) => {
|
|
1043
|
+
if (text === null || text === void 0) return "";
|
|
1044
|
+
const value = String(text);
|
|
1045
|
+
if (value.length <= maxLength) {
|
|
1046
|
+
return value;
|
|
1047
|
+
}
|
|
1048
|
+
return value.slice(0, maxLength - 3) + "...";
|
|
1049
|
+
};
|
|
986
1050
|
var toDateInputValue = (date) => {
|
|
987
1051
|
if (!date) return "";
|
|
988
1052
|
let d;
|
|
@@ -1002,10 +1066,50 @@ var toDateInputValue = (date) => {
|
|
|
1002
1066
|
return `${year}-${month}-${day}`;
|
|
1003
1067
|
};
|
|
1004
1068
|
|
|
1069
|
+
// src/components/tooltip/TooltipText.tsx
|
|
1070
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1071
|
+
function TooltipText({
|
|
1072
|
+
text = "",
|
|
1073
|
+
maxLength = 20,
|
|
1074
|
+
fallback = "-",
|
|
1075
|
+
placement = "top",
|
|
1076
|
+
delayShow,
|
|
1077
|
+
delayHide,
|
|
1078
|
+
className,
|
|
1079
|
+
textClassName,
|
|
1080
|
+
tooltipClassName,
|
|
1081
|
+
tooltipStyle,
|
|
1082
|
+
showTooltip = true,
|
|
1083
|
+
tooltipWhenTruncatedOnly = false
|
|
1084
|
+
}) {
|
|
1085
|
+
const hasValue = text !== null && text !== void 0 && text !== "";
|
|
1086
|
+
const fullText = hasValue ? String(text) : fallback;
|
|
1087
|
+
const displayText = truncateText(fullText, maxLength);
|
|
1088
|
+
const isTruncated = displayText !== fullText;
|
|
1089
|
+
const tooltipDisabled = !showTooltip || !hasValue || tooltipWhenTruncatedOnly && !isTruncated;
|
|
1090
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1091
|
+
ToolTip,
|
|
1092
|
+
{
|
|
1093
|
+
text: fullText,
|
|
1094
|
+
placement,
|
|
1095
|
+
delayShow,
|
|
1096
|
+
delayHide,
|
|
1097
|
+
className: cn("inline-block max-w-full", className),
|
|
1098
|
+
tooltipClassName,
|
|
1099
|
+
tooltipStyle,
|
|
1100
|
+
wrapperTabIndex: tooltipDisabled ? void 0 : 0,
|
|
1101
|
+
disabled: tooltipDisabled,
|
|
1102
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: cn("inline-block max-w-full align-bottom", textClassName), children: displayText })
|
|
1103
|
+
}
|
|
1104
|
+
);
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1005
1107
|
// src/components/cell-editor/CustomCellEditor.tsx
|
|
1006
|
-
var
|
|
1108
|
+
var import_react5 = require("react");
|
|
1109
|
+
var import_react_hot_toast2 = __toESM(require("react-hot-toast"));
|
|
1110
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1007
1111
|
function ButtonSpinner() {
|
|
1008
|
-
return /* @__PURE__ */ (0,
|
|
1112
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1009
1113
|
"svg",
|
|
1010
1114
|
{
|
|
1011
1115
|
className: "animate-spin",
|
|
@@ -1015,7 +1119,7 @@ function ButtonSpinner() {
|
|
|
1015
1119
|
fill: "none",
|
|
1016
1120
|
"aria-hidden": true,
|
|
1017
1121
|
children: [
|
|
1018
|
-
/* @__PURE__ */ (0,
|
|
1122
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1019
1123
|
"circle",
|
|
1020
1124
|
{
|
|
1021
1125
|
cx: "12",
|
|
@@ -1026,7 +1130,7 @@ function ButtonSpinner() {
|
|
|
1026
1130
|
strokeOpacity: "0.25"
|
|
1027
1131
|
}
|
|
1028
1132
|
),
|
|
1029
|
-
/* @__PURE__ */ (0,
|
|
1133
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1030
1134
|
"path",
|
|
1031
1135
|
{
|
|
1032
1136
|
d: "M12 2a10 10 0 0 1 10 10",
|
|
@@ -1048,7 +1152,7 @@ function normalizeInitialValue(initialValue, inputType) {
|
|
|
1048
1152
|
}
|
|
1049
1153
|
return initialValue;
|
|
1050
1154
|
}
|
|
1051
|
-
var CustomCellEditor = (0,
|
|
1155
|
+
var CustomCellEditor = (0, import_react5.forwardRef)(
|
|
1052
1156
|
({
|
|
1053
1157
|
value: initialValue,
|
|
1054
1158
|
name,
|
|
@@ -1073,11 +1177,11 @@ var CustomCellEditor = (0, import_react4.forwardRef)(
|
|
|
1073
1177
|
cancelButtonClassName
|
|
1074
1178
|
}, ref) => {
|
|
1075
1179
|
const normalizedInitial = normalizeInitialValue(initialValue, inputType);
|
|
1076
|
-
const [value, setValue] = (0,
|
|
1077
|
-
const [isLoading, setIsLoading] = (0,
|
|
1078
|
-
const inputRef = (0,
|
|
1079
|
-
const selectRef = (0,
|
|
1080
|
-
const normalizedOptions = (0,
|
|
1180
|
+
const [value, setValue] = (0, import_react5.useState)(normalizedInitial);
|
|
1181
|
+
const [isLoading, setIsLoading] = (0, import_react5.useState)(false);
|
|
1182
|
+
const inputRef = (0, import_react5.useRef)(null);
|
|
1183
|
+
const selectRef = (0, import_react5.useRef)(null);
|
|
1184
|
+
const normalizedOptions = (0, import_react5.useMemo)(() => {
|
|
1081
1185
|
if (customOptions && customOptions.length > 0) {
|
|
1082
1186
|
return customOptions.map((opt) => ({
|
|
1083
1187
|
value: String(opt[valueKey] ?? ""),
|
|
@@ -1087,13 +1191,13 @@ var CustomCellEditor = (0, import_react4.forwardRef)(
|
|
|
1087
1191
|
return dropdownOptions;
|
|
1088
1192
|
}, [customOptions, dropdownOptions, valueKey, labelKey]);
|
|
1089
1193
|
const isDropdown = inputType === "dropdown" || normalizedOptions.length > 0;
|
|
1090
|
-
(0,
|
|
1194
|
+
(0, import_react5.useImperativeHandle)(ref, () => ({
|
|
1091
1195
|
getValue: () => value,
|
|
1092
1196
|
isCancelBeforeStart: () => false,
|
|
1093
1197
|
isCancelAfterEnd: () => false,
|
|
1094
1198
|
isPopup: () => true
|
|
1095
1199
|
}));
|
|
1096
|
-
(0,
|
|
1200
|
+
(0, import_react5.useEffect)(() => {
|
|
1097
1201
|
if (isDropdown) {
|
|
1098
1202
|
selectRef.current?.focus();
|
|
1099
1203
|
return;
|
|
@@ -1162,7 +1266,7 @@ var CustomCellEditor = (0, import_react4.forwardRef)(
|
|
|
1162
1266
|
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";
|
|
1163
1267
|
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";
|
|
1164
1268
|
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";
|
|
1165
|
-
return /* @__PURE__ */ (0,
|
|
1269
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1166
1270
|
"div",
|
|
1167
1271
|
{
|
|
1168
1272
|
className: cn(
|
|
@@ -1171,7 +1275,7 @@ var CustomCellEditor = (0, import_react4.forwardRef)(
|
|
|
1171
1275
|
),
|
|
1172
1276
|
style: containerStyle,
|
|
1173
1277
|
children: [
|
|
1174
|
-
isDropdown ? /* @__PURE__ */ (0,
|
|
1278
|
+
isDropdown ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1175
1279
|
"select",
|
|
1176
1280
|
{
|
|
1177
1281
|
ref: selectRef,
|
|
@@ -1181,11 +1285,11 @@ var CustomCellEditor = (0, import_react4.forwardRef)(
|
|
|
1181
1285
|
className: inputClassName ?? defaultInputClass,
|
|
1182
1286
|
disabled: isLoading,
|
|
1183
1287
|
children: [
|
|
1184
|
-
/* @__PURE__ */ (0,
|
|
1185
|
-
normalizedOptions.map((opt) => /* @__PURE__ */ (0,
|
|
1288
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "", disabled: true, children: "Select option..." }),
|
|
1289
|
+
normalizedOptions.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: opt.value, children: opt.label }, opt.value))
|
|
1186
1290
|
]
|
|
1187
1291
|
}
|
|
1188
|
-
) : /* @__PURE__ */ (0,
|
|
1292
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1189
1293
|
"input",
|
|
1190
1294
|
{
|
|
1191
1295
|
ref: inputRef,
|
|
@@ -1198,7 +1302,7 @@ var CustomCellEditor = (0, import_react4.forwardRef)(
|
|
|
1198
1302
|
disabled: isLoading
|
|
1199
1303
|
}
|
|
1200
1304
|
),
|
|
1201
|
-
/* @__PURE__ */ (0,
|
|
1305
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1202
1306
|
"button",
|
|
1203
1307
|
{
|
|
1204
1308
|
type: "button",
|
|
@@ -1207,10 +1311,10 @@ var CustomCellEditor = (0, import_react4.forwardRef)(
|
|
|
1207
1311
|
className: saveButtonClassName ?? (saveButtonStyle ? void 0 : defaultSaveBtnClass),
|
|
1208
1312
|
style: saveButtonStyle,
|
|
1209
1313
|
title: "Save (Enter)",
|
|
1210
|
-
children: isLoading ? loadingIndicator ?? /* @__PURE__ */ (0,
|
|
1314
|
+
children: isLoading ? loadingIndicator ?? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ButtonSpinner, {}) : saveButtonContent ?? "Save"
|
|
1211
1315
|
}
|
|
1212
1316
|
),
|
|
1213
|
-
/* @__PURE__ */ (0,
|
|
1317
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1214
1318
|
"button",
|
|
1215
1319
|
{
|
|
1216
1320
|
type: "button",
|
|
@@ -1238,6 +1342,8 @@ CustomCellEditor.displayName = "CustomCellEditor";
|
|
|
1238
1342
|
ResetColumnsButton,
|
|
1239
1343
|
ResetFiltersButton,
|
|
1240
1344
|
SearchInput,
|
|
1241
|
-
TableLayoutToolbarControls
|
|
1345
|
+
TableLayoutToolbarControls,
|
|
1346
|
+
ToolTip,
|
|
1347
|
+
TooltipText
|
|
1242
1348
|
});
|
|
1243
1349
|
//# sourceMappingURL=index.js.map
|