@eztrak/shared 0.7.3 → 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-KQHEJS62.mjs → chunk-QW67L4Z5.mjs} +173 -59
- package/dist/chunk-QW67L4Z5.mjs.map +1 -0
- package/dist/components/index.d.mts +65 -5
- package/dist/components/index.d.ts +65 -5
- package/dist/components/index.js +188 -68
- 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 +179 -65
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -2
- package/package.json +3 -1
- package/dist/chunk-KQHEJS62.mjs.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import react__default, { ReactNode, InputHTMLAttributes } from 'react';
|
|
2
|
+
import react__default, { ReactNode, InputHTMLAttributes, CSSProperties } from 'react';
|
|
3
|
+
import { PlacesType } from 'react-tooltip';
|
|
3
4
|
|
|
4
5
|
type EztrakTab = {
|
|
5
6
|
id: string;
|
|
@@ -161,6 +162,37 @@ interface LoaderProps {
|
|
|
161
162
|
|
|
162
163
|
declare const Loader: react__default.FC<LoaderProps>;
|
|
163
164
|
|
|
165
|
+
interface ToolTipProps {
|
|
166
|
+
text?: string | number | null;
|
|
167
|
+
placement?: PlacesType;
|
|
168
|
+
delayShow?: number;
|
|
169
|
+
delayHide?: number;
|
|
170
|
+
className?: string;
|
|
171
|
+
tooltipClassName?: string;
|
|
172
|
+
tooltipStyle?: CSSProperties;
|
|
173
|
+
wrapperTabIndex?: number;
|
|
174
|
+
disabled?: boolean;
|
|
175
|
+
children: ReactNode;
|
|
176
|
+
}
|
|
177
|
+
interface TooltipTextProps {
|
|
178
|
+
text?: string | number | null;
|
|
179
|
+
maxLength?: number;
|
|
180
|
+
fallback?: string;
|
|
181
|
+
placement?: PlacesType;
|
|
182
|
+
delayShow?: number;
|
|
183
|
+
delayHide?: number;
|
|
184
|
+
className?: string;
|
|
185
|
+
textClassName?: string;
|
|
186
|
+
tooltipClassName?: string;
|
|
187
|
+
tooltipStyle?: CSSProperties;
|
|
188
|
+
showTooltip?: boolean;
|
|
189
|
+
tooltipWhenTruncatedOnly?: boolean;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
declare function ToolTip({ text, placement, delayShow, delayHide, className, tooltipClassName, tooltipStyle, wrapperTabIndex, disabled, children, }: ToolTipProps): react.JSX.Element;
|
|
193
|
+
|
|
194
|
+
declare function TooltipText({ text, maxLength, fallback, placement, delayShow, delayHide, className, textClassName, tooltipClassName, tooltipStyle, showTooltip, tooltipWhenTruncatedOnly, }: TooltipTextProps): react.JSX.Element;
|
|
195
|
+
|
|
164
196
|
type CellEditorInputType = "text" | "number" | "date" | "dropdown";
|
|
165
197
|
interface DropdownOption {
|
|
166
198
|
value: string;
|
|
@@ -169,26 +201,54 @@ interface DropdownOption {
|
|
|
169
201
|
interface CellEditPayload {
|
|
170
202
|
propertyName: string;
|
|
171
203
|
propertyValue: string | number | null;
|
|
172
|
-
entityId
|
|
173
|
-
entityName
|
|
204
|
+
entityId?: string | number;
|
|
205
|
+
entityName?: string;
|
|
174
206
|
}
|
|
175
207
|
interface CustomCellEditorRef {
|
|
176
208
|
getValue: () => string | number | null | undefined;
|
|
177
209
|
isCancelBeforeStart: () => boolean;
|
|
178
210
|
isCancelAfterEnd: () => boolean;
|
|
211
|
+
/** Tells AG Grid to render this editor as a floating popup, free of column width */
|
|
212
|
+
isPopup: () => boolean;
|
|
179
213
|
}
|
|
180
214
|
interface CustomCellEditorProps {
|
|
181
215
|
value: string | number | null | undefined;
|
|
182
216
|
name: string;
|
|
183
217
|
inputType?: CellEditorInputType;
|
|
184
218
|
stopEditing: (cancel?: boolean) => void;
|
|
185
|
-
entityId
|
|
219
|
+
entityId?: string | number;
|
|
186
220
|
entityName?: string;
|
|
187
221
|
onSave: (payload: CellEditPayload) => Promise<void>;
|
|
222
|
+
/** Standard {value, label} dropdown options */
|
|
188
223
|
dropdownOptions?: DropdownOption[];
|
|
224
|
+
/** Raw options array with custom key shapes (use with valueKey/labelKey) */
|
|
225
|
+
customOptions?: Record<string, unknown>[];
|
|
226
|
+
/** Key to read as option value from customOptions items (default: "value") */
|
|
227
|
+
valueKey?: string;
|
|
228
|
+
/** Key to read as option label from customOptions items (default: "label") */
|
|
229
|
+
labelKey?: string;
|
|
230
|
+
/** Extra inline styles applied to the wrapper div (merged with default layout) */
|
|
231
|
+
containerStyle?: CSSProperties;
|
|
232
|
+
/** Tailwind/CSS class(es) for the wrapper div */
|
|
189
233
|
className?: string;
|
|
234
|
+
/** Tailwind/CSS class(es) applied directly to the <input> or <select> */
|
|
235
|
+
inputClassName?: string;
|
|
236
|
+
/** Replaces the built-in ButtonSpinner when isLoading is true */
|
|
237
|
+
loadingIndicator?: ReactNode;
|
|
238
|
+
/** Replaces the default FaCheck icon in the save button */
|
|
239
|
+
saveButtonContent?: ReactNode;
|
|
240
|
+
/** Replaces the default FaTimes icon in the cancel button */
|
|
241
|
+
cancelButtonContent?: ReactNode;
|
|
242
|
+
/** Inline styles for the save button */
|
|
243
|
+
saveButtonStyle?: CSSProperties;
|
|
244
|
+
/** Inline styles for the cancel button */
|
|
245
|
+
cancelButtonStyle?: CSSProperties;
|
|
246
|
+
/** Extra class(es) for the save button */
|
|
247
|
+
saveButtonClassName?: string;
|
|
248
|
+
/** Extra class(es) for the cancel button */
|
|
249
|
+
cancelButtonClassName?: string;
|
|
190
250
|
}
|
|
191
251
|
|
|
192
252
|
declare const CustomCellEditor: react.ForwardRefExoticComponent<CustomCellEditorProps & react.RefAttributes<CustomCellEditorRef>>;
|
|
193
253
|
|
|
194
|
-
export { type CellEditPayload, type CellEditorInputType, CustomCellEditor, type CustomCellEditorProps, type CustomCellEditorRef, CustomPagination, type CustomPaginationClassNames, type CustomPaginationProps, type DropdownOption, type EztrakTab, EztrakTabs, type EztrakTabsClassNames, type EztrakTabsProps, type LayoutStatus, Loader, type LoaderProps, Modal, type ModalProps, type PaginationData, ResetColumnsButton, type ResetColumnsButtonProps, ResetFiltersButton, type ResetFiltersButtonProps, type ResetFiltersButtonVariant, SearchInput, type SearchInputProps, TableLayoutToolbarControls, type TableLayoutToolbarControlsProps };
|
|
254
|
+
export { type CellEditPayload, type CellEditorInputType, CustomCellEditor, type CustomCellEditorProps, type CustomCellEditorRef, CustomPagination, type CustomPaginationClassNames, type CustomPaginationProps, type DropdownOption, type EztrakTab, EztrakTabs, type EztrakTabsClassNames, type EztrakTabsProps, type LayoutStatus, Loader, type LoaderProps, Modal, type ModalProps, type PaginationData, ResetColumnsButton, type ResetColumnsButtonProps, ResetFiltersButton, type ResetFiltersButtonProps, type ResetFiltersButtonVariant, SearchInput, type SearchInputProps, TableLayoutToolbarControls, type TableLayoutToolbarControlsProps, ToolTip, type ToolTipProps, TooltipText, type TooltipTextProps };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import react__default, { ReactNode, InputHTMLAttributes } from 'react';
|
|
2
|
+
import react__default, { ReactNode, InputHTMLAttributes, CSSProperties } from 'react';
|
|
3
|
+
import { PlacesType } from 'react-tooltip';
|
|
3
4
|
|
|
4
5
|
type EztrakTab = {
|
|
5
6
|
id: string;
|
|
@@ -161,6 +162,37 @@ interface LoaderProps {
|
|
|
161
162
|
|
|
162
163
|
declare const Loader: react__default.FC<LoaderProps>;
|
|
163
164
|
|
|
165
|
+
interface ToolTipProps {
|
|
166
|
+
text?: string | number | null;
|
|
167
|
+
placement?: PlacesType;
|
|
168
|
+
delayShow?: number;
|
|
169
|
+
delayHide?: number;
|
|
170
|
+
className?: string;
|
|
171
|
+
tooltipClassName?: string;
|
|
172
|
+
tooltipStyle?: CSSProperties;
|
|
173
|
+
wrapperTabIndex?: number;
|
|
174
|
+
disabled?: boolean;
|
|
175
|
+
children: ReactNode;
|
|
176
|
+
}
|
|
177
|
+
interface TooltipTextProps {
|
|
178
|
+
text?: string | number | null;
|
|
179
|
+
maxLength?: number;
|
|
180
|
+
fallback?: string;
|
|
181
|
+
placement?: PlacesType;
|
|
182
|
+
delayShow?: number;
|
|
183
|
+
delayHide?: number;
|
|
184
|
+
className?: string;
|
|
185
|
+
textClassName?: string;
|
|
186
|
+
tooltipClassName?: string;
|
|
187
|
+
tooltipStyle?: CSSProperties;
|
|
188
|
+
showTooltip?: boolean;
|
|
189
|
+
tooltipWhenTruncatedOnly?: boolean;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
declare function ToolTip({ text, placement, delayShow, delayHide, className, tooltipClassName, tooltipStyle, wrapperTabIndex, disabled, children, }: ToolTipProps): react.JSX.Element;
|
|
193
|
+
|
|
194
|
+
declare function TooltipText({ text, maxLength, fallback, placement, delayShow, delayHide, className, textClassName, tooltipClassName, tooltipStyle, showTooltip, tooltipWhenTruncatedOnly, }: TooltipTextProps): react.JSX.Element;
|
|
195
|
+
|
|
164
196
|
type CellEditorInputType = "text" | "number" | "date" | "dropdown";
|
|
165
197
|
interface DropdownOption {
|
|
166
198
|
value: string;
|
|
@@ -169,26 +201,54 @@ interface DropdownOption {
|
|
|
169
201
|
interface CellEditPayload {
|
|
170
202
|
propertyName: string;
|
|
171
203
|
propertyValue: string | number | null;
|
|
172
|
-
entityId
|
|
173
|
-
entityName
|
|
204
|
+
entityId?: string | number;
|
|
205
|
+
entityName?: string;
|
|
174
206
|
}
|
|
175
207
|
interface CustomCellEditorRef {
|
|
176
208
|
getValue: () => string | number | null | undefined;
|
|
177
209
|
isCancelBeforeStart: () => boolean;
|
|
178
210
|
isCancelAfterEnd: () => boolean;
|
|
211
|
+
/** Tells AG Grid to render this editor as a floating popup, free of column width */
|
|
212
|
+
isPopup: () => boolean;
|
|
179
213
|
}
|
|
180
214
|
interface CustomCellEditorProps {
|
|
181
215
|
value: string | number | null | undefined;
|
|
182
216
|
name: string;
|
|
183
217
|
inputType?: CellEditorInputType;
|
|
184
218
|
stopEditing: (cancel?: boolean) => void;
|
|
185
|
-
entityId
|
|
219
|
+
entityId?: string | number;
|
|
186
220
|
entityName?: string;
|
|
187
221
|
onSave: (payload: CellEditPayload) => Promise<void>;
|
|
222
|
+
/** Standard {value, label} dropdown options */
|
|
188
223
|
dropdownOptions?: DropdownOption[];
|
|
224
|
+
/** Raw options array with custom key shapes (use with valueKey/labelKey) */
|
|
225
|
+
customOptions?: Record<string, unknown>[];
|
|
226
|
+
/** Key to read as option value from customOptions items (default: "value") */
|
|
227
|
+
valueKey?: string;
|
|
228
|
+
/** Key to read as option label from customOptions items (default: "label") */
|
|
229
|
+
labelKey?: string;
|
|
230
|
+
/** Extra inline styles applied to the wrapper div (merged with default layout) */
|
|
231
|
+
containerStyle?: CSSProperties;
|
|
232
|
+
/** Tailwind/CSS class(es) for the wrapper div */
|
|
189
233
|
className?: string;
|
|
234
|
+
/** Tailwind/CSS class(es) applied directly to the <input> or <select> */
|
|
235
|
+
inputClassName?: string;
|
|
236
|
+
/** Replaces the built-in ButtonSpinner when isLoading is true */
|
|
237
|
+
loadingIndicator?: ReactNode;
|
|
238
|
+
/** Replaces the default FaCheck icon in the save button */
|
|
239
|
+
saveButtonContent?: ReactNode;
|
|
240
|
+
/** Replaces the default FaTimes icon in the cancel button */
|
|
241
|
+
cancelButtonContent?: ReactNode;
|
|
242
|
+
/** Inline styles for the save button */
|
|
243
|
+
saveButtonStyle?: CSSProperties;
|
|
244
|
+
/** Inline styles for the cancel button */
|
|
245
|
+
cancelButtonStyle?: CSSProperties;
|
|
246
|
+
/** Extra class(es) for the save button */
|
|
247
|
+
saveButtonClassName?: string;
|
|
248
|
+
/** Extra class(es) for the cancel button */
|
|
249
|
+
cancelButtonClassName?: string;
|
|
190
250
|
}
|
|
191
251
|
|
|
192
252
|
declare const CustomCellEditor: react.ForwardRefExoticComponent<CustomCellEditorProps & react.RefAttributes<CustomCellEditorRef>>;
|
|
193
253
|
|
|
194
|
-
export { type CellEditPayload, type CellEditorInputType, CustomCellEditor, type CustomCellEditorProps, type CustomCellEditorRef, CustomPagination, type CustomPaginationClassNames, type CustomPaginationProps, type DropdownOption, type EztrakTab, EztrakTabs, type EztrakTabsClassNames, type EztrakTabsProps, type LayoutStatus, Loader, type LoaderProps, Modal, type ModalProps, type PaginationData, ResetColumnsButton, type ResetColumnsButtonProps, ResetFiltersButton, type ResetFiltersButtonProps, type ResetFiltersButtonVariant, SearchInput, type SearchInputProps, TableLayoutToolbarControls, type TableLayoutToolbarControlsProps };
|
|
254
|
+
export { type CellEditPayload, type CellEditorInputType, CustomCellEditor, type CustomCellEditorProps, type CustomCellEditorRef, CustomPagination, type CustomPaginationClassNames, type CustomPaginationProps, type DropdownOption, type EztrakTab, EztrakTabs, type EztrakTabsClassNames, type EztrakTabsProps, type LayoutStatus, Loader, type LoaderProps, Modal, type ModalProps, type PaginationData, ResetColumnsButton, type ResetColumnsButtonProps, ResetFiltersButton, type ResetFiltersButtonProps, type ResetFiltersButtonVariant, SearchInput, type SearchInputProps, TableLayoutToolbarControls, type TableLayoutToolbarControlsProps, ToolTip, type ToolTipProps, TooltipText, type TooltipTextProps };
|
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,12 +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
|
|
984
|
-
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
|
+
}
|
|
985
1039
|
|
|
986
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
|
+
};
|
|
987
1049
|
var toDateInputValue = (date) => {
|
|
988
1050
|
if (!date) return "";
|
|
989
1051
|
let d;
|
|
@@ -1003,20 +1065,60 @@ var toDateInputValue = (date) => {
|
|
|
1003
1065
|
return `${year}-${month}-${day}`;
|
|
1004
1066
|
};
|
|
1005
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
|
+
|
|
1006
1106
|
// src/components/cell-editor/CustomCellEditor.tsx
|
|
1007
|
-
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");
|
|
1008
1110
|
function ButtonSpinner() {
|
|
1009
|
-
return /* @__PURE__ */ (0,
|
|
1111
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1010
1112
|
"svg",
|
|
1011
1113
|
{
|
|
1012
1114
|
className: "animate-spin",
|
|
1013
|
-
width:
|
|
1014
|
-
height:
|
|
1115
|
+
width: 12,
|
|
1116
|
+
height: 12,
|
|
1015
1117
|
viewBox: "0 0 24 24",
|
|
1016
1118
|
fill: "none",
|
|
1017
1119
|
"aria-hidden": true,
|
|
1018
1120
|
children: [
|
|
1019
|
-
/* @__PURE__ */ (0,
|
|
1121
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1020
1122
|
"circle",
|
|
1021
1123
|
{
|
|
1022
1124
|
cx: "12",
|
|
@@ -1027,7 +1129,7 @@ function ButtonSpinner() {
|
|
|
1027
1129
|
strokeOpacity: "0.25"
|
|
1028
1130
|
}
|
|
1029
1131
|
),
|
|
1030
|
-
/* @__PURE__ */ (0,
|
|
1132
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1031
1133
|
"path",
|
|
1032
1134
|
{
|
|
1033
1135
|
d: "M12 2a10 10 0 0 1 10 10",
|
|
@@ -1049,7 +1151,7 @@ function normalizeInitialValue(initialValue, inputType) {
|
|
|
1049
1151
|
}
|
|
1050
1152
|
return initialValue;
|
|
1051
1153
|
}
|
|
1052
|
-
var CustomCellEditor = (0,
|
|
1154
|
+
var CustomCellEditor = (0, import_react5.forwardRef)(
|
|
1053
1155
|
({
|
|
1054
1156
|
value: initialValue,
|
|
1055
1157
|
name,
|
|
@@ -1059,47 +1161,59 @@ var CustomCellEditor = (0, import_react4.forwardRef)(
|
|
|
1059
1161
|
entityName = "Record",
|
|
1060
1162
|
onSave,
|
|
1061
1163
|
dropdownOptions = [],
|
|
1062
|
-
|
|
1164
|
+
customOptions,
|
|
1165
|
+
valueKey = "value",
|
|
1166
|
+
labelKey = "label",
|
|
1167
|
+
containerStyle,
|
|
1168
|
+
className,
|
|
1169
|
+
inputClassName,
|
|
1170
|
+
loadingIndicator,
|
|
1171
|
+
saveButtonContent,
|
|
1172
|
+
cancelButtonContent,
|
|
1173
|
+
saveButtonStyle,
|
|
1174
|
+
cancelButtonStyle,
|
|
1175
|
+
saveButtonClassName,
|
|
1176
|
+
cancelButtonClassName
|
|
1063
1177
|
}, ref) => {
|
|
1064
1178
|
const normalizedInitial = normalizeInitialValue(initialValue, inputType);
|
|
1065
|
-
const [value, setValue] = (0,
|
|
1066
|
-
const [isLoading, setIsLoading] = (0,
|
|
1067
|
-
const inputRef = (0,
|
|
1068
|
-
const selectRef = (0,
|
|
1069
|
-
(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)(() => {
|
|
1184
|
+
if (customOptions && customOptions.length > 0) {
|
|
1185
|
+
return customOptions.map((opt) => ({
|
|
1186
|
+
value: String(opt[valueKey] ?? ""),
|
|
1187
|
+
label: String(opt[labelKey] ?? "")
|
|
1188
|
+
}));
|
|
1189
|
+
}
|
|
1190
|
+
return dropdownOptions;
|
|
1191
|
+
}, [customOptions, dropdownOptions, valueKey, labelKey]);
|
|
1192
|
+
const isDropdown = inputType === "dropdown" || normalizedOptions.length > 0;
|
|
1193
|
+
(0, import_react5.useImperativeHandle)(ref, () => ({
|
|
1070
1194
|
getValue: () => value,
|
|
1071
1195
|
isCancelBeforeStart: () => false,
|
|
1072
|
-
isCancelAfterEnd: () => false
|
|
1196
|
+
isCancelAfterEnd: () => false,
|
|
1197
|
+
isPopup: () => true
|
|
1073
1198
|
}));
|
|
1074
|
-
(0,
|
|
1075
|
-
if (
|
|
1076
|
-
|
|
1077
|
-
if (el2) {
|
|
1078
|
-
el2.focus();
|
|
1079
|
-
}
|
|
1199
|
+
(0, import_react5.useEffect)(() => {
|
|
1200
|
+
if (isDropdown) {
|
|
1201
|
+
selectRef.current?.focus();
|
|
1080
1202
|
return;
|
|
1081
1203
|
}
|
|
1082
1204
|
const el = inputRef.current;
|
|
1083
|
-
if (!el)
|
|
1084
|
-
return;
|
|
1085
|
-
}
|
|
1205
|
+
if (!el) return;
|
|
1086
1206
|
el.focus();
|
|
1087
1207
|
if (inputType !== "date") {
|
|
1088
1208
|
el.select();
|
|
1089
1209
|
}
|
|
1090
|
-
}, [inputType]);
|
|
1210
|
+
}, [isDropdown, inputType]);
|
|
1091
1211
|
const handleSave = async () => {
|
|
1092
|
-
if (isLoading)
|
|
1093
|
-
return;
|
|
1094
|
-
}
|
|
1212
|
+
if (isLoading) return;
|
|
1095
1213
|
if (String(value) === String(normalizedInitial)) {
|
|
1096
1214
|
stopEditing();
|
|
1097
1215
|
return;
|
|
1098
1216
|
}
|
|
1099
|
-
if (!entityId) {
|
|
1100
|
-
import_react_hot_toast2.default.error("Entity ID is required");
|
|
1101
|
-
return;
|
|
1102
|
-
}
|
|
1103
1217
|
if (!name) {
|
|
1104
1218
|
import_react_hot_toast2.default.error("Property name is required");
|
|
1105
1219
|
return;
|
|
@@ -1148,29 +1262,33 @@ var CustomCellEditor = (0, import_react4.forwardRef)(
|
|
|
1148
1262
|
setValue(event.target.value);
|
|
1149
1263
|
};
|
|
1150
1264
|
const isSaveDisabled = isLoading || String(value) === String(normalizedInitial);
|
|
1151
|
-
|
|
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";
|
|
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";
|
|
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";
|
|
1268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1152
1269
|
"div",
|
|
1153
1270
|
{
|
|
1154
1271
|
className: cn(
|
|
1155
|
-
"flex items-center
|
|
1272
|
+
"flex items-center gap-2 px-2 py-1 min-w-[320px] bg-white border border-gray-200 rounded-md shadow-md",
|
|
1156
1273
|
className
|
|
1157
1274
|
),
|
|
1275
|
+
style: containerStyle,
|
|
1158
1276
|
children: [
|
|
1159
|
-
|
|
1277
|
+
isDropdown ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1160
1278
|
"select",
|
|
1161
1279
|
{
|
|
1162
1280
|
ref: selectRef,
|
|
1163
1281
|
value: String(value),
|
|
1164
1282
|
onChange: handleDropdownChange,
|
|
1165
1283
|
onKeyDown: handleKeyDown,
|
|
1166
|
-
className:
|
|
1284
|
+
className: inputClassName ?? defaultInputClass,
|
|
1167
1285
|
disabled: isLoading,
|
|
1168
1286
|
children: [
|
|
1169
|
-
/* @__PURE__ */ (0,
|
|
1170
|
-
|
|
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))
|
|
1171
1289
|
]
|
|
1172
1290
|
}
|
|
1173
|
-
) : /* @__PURE__ */ (0,
|
|
1291
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1174
1292
|
"input",
|
|
1175
1293
|
{
|
|
1176
1294
|
ref: inputRef,
|
|
@@ -1178,35 +1296,35 @@ var CustomCellEditor = (0, import_react4.forwardRef)(
|
|
|
1178
1296
|
value: String(value),
|
|
1179
1297
|
onChange: handleInputChange,
|
|
1180
1298
|
onKeyDown: handleKeyDown,
|
|
1181
|
-
className:
|
|
1299
|
+
className: inputClassName ?? defaultInputClass,
|
|
1182
1300
|
placeholder: "...",
|
|
1183
1301
|
disabled: isLoading
|
|
1184
1302
|
}
|
|
1185
1303
|
),
|
|
1186
|
-
/* @__PURE__ */ (0,
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1304
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1305
|
+
"button",
|
|
1306
|
+
{
|
|
1307
|
+
type: "button",
|
|
1308
|
+
onClick: handleSave,
|
|
1309
|
+
disabled: isSaveDisabled,
|
|
1310
|
+
className: saveButtonClassName ?? (saveButtonStyle ? void 0 : defaultSaveBtnClass),
|
|
1311
|
+
style: saveButtonStyle,
|
|
1312
|
+
title: "Save (Enter)",
|
|
1313
|
+
children: isLoading ? loadingIndicator ?? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ButtonSpinner, {}) : saveButtonContent ?? "Save"
|
|
1314
|
+
}
|
|
1315
|
+
),
|
|
1316
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1317
|
+
"button",
|
|
1318
|
+
{
|
|
1319
|
+
type: "button",
|
|
1320
|
+
onClick: handleCancel,
|
|
1321
|
+
disabled: isLoading,
|
|
1322
|
+
className: cancelButtonClassName ?? (cancelButtonStyle ? void 0 : defaultCancelBtnClass),
|
|
1323
|
+
style: cancelButtonStyle,
|
|
1324
|
+
title: "Cancel (Escape)",
|
|
1325
|
+
children: cancelButtonContent ?? "Cancel"
|
|
1326
|
+
}
|
|
1327
|
+
)
|
|
1210
1328
|
]
|
|
1211
1329
|
}
|
|
1212
1330
|
);
|
|
@@ -1223,6 +1341,8 @@ CustomCellEditor.displayName = "CustomCellEditor";
|
|
|
1223
1341
|
ResetColumnsButton,
|
|
1224
1342
|
ResetFiltersButton,
|
|
1225
1343
|
SearchInput,
|
|
1226
|
-
TableLayoutToolbarControls
|
|
1344
|
+
TableLayoutToolbarControls,
|
|
1345
|
+
ToolTip,
|
|
1346
|
+
TooltipText
|
|
1227
1347
|
});
|
|
1228
1348
|
//# sourceMappingURL=index.js.map
|