@eztrak/shared 0.7.4 → 0.8.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 +44 -2
- package/dist/{chunk-FSCPBM3X.mjs → chunk-QW67L4Z5.mjs} +112 -14
- package/dist/chunk-QW67L4Z5.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 +129 -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 +120 -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,72 @@ 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
|
+
delayShow,
|
|
1032
|
+
delayHide,
|
|
1033
|
+
className: tooltipClassName,
|
|
1034
|
+
style: { ...defaultTooltipStyle, ...tooltipStyle }
|
|
1035
|
+
}
|
|
1036
|
+
)
|
|
1037
|
+
] });
|
|
1038
|
+
}
|
|
984
1039
|
|
|
985
1040
|
// src/utils/helpers.ts
|
|
1041
|
+
var truncateText = (text, maxLength = 20) => {
|
|
1042
|
+
if (text === null || text === void 0) return "";
|
|
1043
|
+
const value = String(text);
|
|
1044
|
+
if (value.length <= maxLength) {
|
|
1045
|
+
return value;
|
|
1046
|
+
}
|
|
1047
|
+
return value.slice(0, maxLength - 3) + "...";
|
|
1048
|
+
};
|
|
986
1049
|
var toDateInputValue = (date) => {
|
|
987
1050
|
if (!date) return "";
|
|
988
1051
|
let d;
|
|
@@ -1002,10 +1065,50 @@ var toDateInputValue = (date) => {
|
|
|
1002
1065
|
return `${year}-${month}-${day}`;
|
|
1003
1066
|
};
|
|
1004
1067
|
|
|
1068
|
+
// src/components/tooltip/TooltipText.tsx
|
|
1069
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1070
|
+
function TooltipText({
|
|
1071
|
+
text = "",
|
|
1072
|
+
maxLength = 20,
|
|
1073
|
+
fallback = "-",
|
|
1074
|
+
placement = "top",
|
|
1075
|
+
delayShow,
|
|
1076
|
+
delayHide,
|
|
1077
|
+
className,
|
|
1078
|
+
textClassName,
|
|
1079
|
+
tooltipClassName,
|
|
1080
|
+
tooltipStyle,
|
|
1081
|
+
showTooltip = true,
|
|
1082
|
+
tooltipWhenTruncatedOnly = false
|
|
1083
|
+
}) {
|
|
1084
|
+
const hasValue = text !== null && text !== void 0 && text !== "";
|
|
1085
|
+
const fullText = hasValue ? String(text) : fallback;
|
|
1086
|
+
const displayText = truncateText(fullText, maxLength);
|
|
1087
|
+
const isTruncated = displayText !== fullText;
|
|
1088
|
+
const tooltipDisabled = !showTooltip || !hasValue || tooltipWhenTruncatedOnly && !isTruncated;
|
|
1089
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1090
|
+
ToolTip,
|
|
1091
|
+
{
|
|
1092
|
+
text: fullText,
|
|
1093
|
+
placement,
|
|
1094
|
+
delayShow,
|
|
1095
|
+
delayHide,
|
|
1096
|
+
className: cn("inline-block max-w-full", className),
|
|
1097
|
+
tooltipClassName,
|
|
1098
|
+
tooltipStyle,
|
|
1099
|
+
wrapperTabIndex: tooltipDisabled ? void 0 : 0,
|
|
1100
|
+
disabled: tooltipDisabled,
|
|
1101
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: cn("inline-block max-w-full align-bottom", textClassName), children: displayText })
|
|
1102
|
+
}
|
|
1103
|
+
);
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1005
1106
|
// src/components/cell-editor/CustomCellEditor.tsx
|
|
1006
|
-
var
|
|
1107
|
+
var import_react5 = require("react");
|
|
1108
|
+
var import_react_hot_toast2 = __toESM(require("react-hot-toast"));
|
|
1109
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1007
1110
|
function ButtonSpinner() {
|
|
1008
|
-
return /* @__PURE__ */ (0,
|
|
1111
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1009
1112
|
"svg",
|
|
1010
1113
|
{
|
|
1011
1114
|
className: "animate-spin",
|
|
@@ -1015,7 +1118,7 @@ function ButtonSpinner() {
|
|
|
1015
1118
|
fill: "none",
|
|
1016
1119
|
"aria-hidden": true,
|
|
1017
1120
|
children: [
|
|
1018
|
-
/* @__PURE__ */ (0,
|
|
1121
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1019
1122
|
"circle",
|
|
1020
1123
|
{
|
|
1021
1124
|
cx: "12",
|
|
@@ -1026,7 +1129,7 @@ function ButtonSpinner() {
|
|
|
1026
1129
|
strokeOpacity: "0.25"
|
|
1027
1130
|
}
|
|
1028
1131
|
),
|
|
1029
|
-
/* @__PURE__ */ (0,
|
|
1132
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1030
1133
|
"path",
|
|
1031
1134
|
{
|
|
1032
1135
|
d: "M12 2a10 10 0 0 1 10 10",
|
|
@@ -1048,7 +1151,7 @@ function normalizeInitialValue(initialValue, inputType) {
|
|
|
1048
1151
|
}
|
|
1049
1152
|
return initialValue;
|
|
1050
1153
|
}
|
|
1051
|
-
var CustomCellEditor = (0,
|
|
1154
|
+
var CustomCellEditor = (0, import_react5.forwardRef)(
|
|
1052
1155
|
({
|
|
1053
1156
|
value: initialValue,
|
|
1054
1157
|
name,
|
|
@@ -1073,11 +1176,11 @@ var CustomCellEditor = (0, import_react4.forwardRef)(
|
|
|
1073
1176
|
cancelButtonClassName
|
|
1074
1177
|
}, ref) => {
|
|
1075
1178
|
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,
|
|
1179
|
+
const [value, setValue] = (0, import_react5.useState)(normalizedInitial);
|
|
1180
|
+
const [isLoading, setIsLoading] = (0, import_react5.useState)(false);
|
|
1181
|
+
const inputRef = (0, import_react5.useRef)(null);
|
|
1182
|
+
const selectRef = (0, import_react5.useRef)(null);
|
|
1183
|
+
const normalizedOptions = (0, import_react5.useMemo)(() => {
|
|
1081
1184
|
if (customOptions && customOptions.length > 0) {
|
|
1082
1185
|
return customOptions.map((opt) => ({
|
|
1083
1186
|
value: String(opt[valueKey] ?? ""),
|
|
@@ -1087,13 +1190,13 @@ var CustomCellEditor = (0, import_react4.forwardRef)(
|
|
|
1087
1190
|
return dropdownOptions;
|
|
1088
1191
|
}, [customOptions, dropdownOptions, valueKey, labelKey]);
|
|
1089
1192
|
const isDropdown = inputType === "dropdown" || normalizedOptions.length > 0;
|
|
1090
|
-
(0,
|
|
1193
|
+
(0, import_react5.useImperativeHandle)(ref, () => ({
|
|
1091
1194
|
getValue: () => value,
|
|
1092
1195
|
isCancelBeforeStart: () => false,
|
|
1093
1196
|
isCancelAfterEnd: () => false,
|
|
1094
1197
|
isPopup: () => true
|
|
1095
1198
|
}));
|
|
1096
|
-
(0,
|
|
1199
|
+
(0, import_react5.useEffect)(() => {
|
|
1097
1200
|
if (isDropdown) {
|
|
1098
1201
|
selectRef.current?.focus();
|
|
1099
1202
|
return;
|
|
@@ -1162,7 +1265,7 @@ var CustomCellEditor = (0, import_react4.forwardRef)(
|
|
|
1162
1265
|
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
1266
|
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
1267
|
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,
|
|
1268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1166
1269
|
"div",
|
|
1167
1270
|
{
|
|
1168
1271
|
className: cn(
|
|
@@ -1171,7 +1274,7 @@ var CustomCellEditor = (0, import_react4.forwardRef)(
|
|
|
1171
1274
|
),
|
|
1172
1275
|
style: containerStyle,
|
|
1173
1276
|
children: [
|
|
1174
|
-
isDropdown ? /* @__PURE__ */ (0,
|
|
1277
|
+
isDropdown ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1175
1278
|
"select",
|
|
1176
1279
|
{
|
|
1177
1280
|
ref: selectRef,
|
|
@@ -1181,11 +1284,11 @@ var CustomCellEditor = (0, import_react4.forwardRef)(
|
|
|
1181
1284
|
className: inputClassName ?? defaultInputClass,
|
|
1182
1285
|
disabled: isLoading,
|
|
1183
1286
|
children: [
|
|
1184
|
-
/* @__PURE__ */ (0,
|
|
1185
|
-
normalizedOptions.map((opt) => /* @__PURE__ */ (0,
|
|
1287
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "", disabled: true, children: "Select option..." }),
|
|
1288
|
+
normalizedOptions.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: opt.value, children: opt.label }, opt.value))
|
|
1186
1289
|
]
|
|
1187
1290
|
}
|
|
1188
|
-
) : /* @__PURE__ */ (0,
|
|
1291
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1189
1292
|
"input",
|
|
1190
1293
|
{
|
|
1191
1294
|
ref: inputRef,
|
|
@@ -1198,7 +1301,7 @@ var CustomCellEditor = (0, import_react4.forwardRef)(
|
|
|
1198
1301
|
disabled: isLoading
|
|
1199
1302
|
}
|
|
1200
1303
|
),
|
|
1201
|
-
/* @__PURE__ */ (0,
|
|
1304
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1202
1305
|
"button",
|
|
1203
1306
|
{
|
|
1204
1307
|
type: "button",
|
|
@@ -1207,10 +1310,10 @@ var CustomCellEditor = (0, import_react4.forwardRef)(
|
|
|
1207
1310
|
className: saveButtonClassName ?? (saveButtonStyle ? void 0 : defaultSaveBtnClass),
|
|
1208
1311
|
style: saveButtonStyle,
|
|
1209
1312
|
title: "Save (Enter)",
|
|
1210
|
-
children: isLoading ? loadingIndicator ?? /* @__PURE__ */ (0,
|
|
1313
|
+
children: isLoading ? loadingIndicator ?? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ButtonSpinner, {}) : saveButtonContent ?? "Save"
|
|
1211
1314
|
}
|
|
1212
1315
|
),
|
|
1213
|
-
/* @__PURE__ */ (0,
|
|
1316
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1214
1317
|
"button",
|
|
1215
1318
|
{
|
|
1216
1319
|
type: "button",
|
|
@@ -1238,6 +1341,8 @@ CustomCellEditor.displayName = "CustomCellEditor";
|
|
|
1238
1341
|
ResetColumnsButton,
|
|
1239
1342
|
ResetFiltersButton,
|
|
1240
1343
|
SearchInput,
|
|
1241
|
-
TableLayoutToolbarControls
|
|
1344
|
+
TableLayoutToolbarControls,
|
|
1345
|
+
ToolTip,
|
|
1346
|
+
TooltipText
|
|
1242
1347
|
});
|
|
1243
1348
|
//# sourceMappingURL=index.js.map
|