impact-ui 4.0.2 → 4.0.3-tableV36.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/dist/_virtual/index2.js +2 -2
- package/dist/_virtual/index3.js +2 -2
- package/dist/components/AccordionModern/index.js +1 -1
- package/dist/components/Badge/index.js +1 -1
- package/dist/components/BottomSheet/index.d.ts +1 -1
- package/dist/components/BottomSheet/index.d.ts.map +1 -1
- package/dist/components/BottomSheet/index.js +7 -1
- package/dist/components/Breadcrumbs/index.js +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/ButtonGroup/index.js +1 -1
- package/dist/components/Chart/ChartSkeleton.d.ts +23 -0
- package/dist/components/Chart/ChartSkeleton.d.ts.map +1 -0
- package/dist/components/Chart/ChartSkeleton.js +171 -0
- package/dist/components/Chart/index.d.ts +4 -1
- package/dist/components/Chart/index.d.ts.map +1 -1
- package/dist/components/Chart/index.js +15 -3
- package/dist/components/Chatbot/index.js +1 -1
- package/dist/components/Chips/index.js +1 -1
- package/dist/components/CommentsPanel/CommentsPanel.impl.js +1 -1
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/DateRangePicker/index.js +1 -1
- package/dist/components/FileUpload/index.js +1 -1
- package/dist/components/FilterPanel/index.js +1 -1
- package/dist/components/FiltersStrip/FilterSlider.js +1 -1
- package/dist/components/FiltersStrip/index.js +1 -1
- package/dist/components/Input/index.js +1 -1
- package/dist/components/KeyboardShortCuts/ShortcutLandingPage.js +1 -1
- package/dist/components/KeyboardShortCuts/ShortcutModal.js +1 -1
- package/dist/components/KeyboardShortCuts/allSetBox.js +1 -1
- package/dist/components/KeyboardShortCuts/index.js +1 -1
- package/dist/components/KeyboardShortCuts/tutorial.js +1 -1
- package/dist/components/Loader/Loader.types.d.ts +3 -3
- package/dist/components/Loader/Loader.types.d.ts.map +1 -1
- package/dist/components/Loader/index.d.ts.map +1 -1
- package/dist/components/Loader/index.js +4 -2
- package/dist/components/Menu/IconMenuItem.js +1 -1
- package/dist/components/Menu/NestedMenuItem.js +1 -1
- package/dist/components/Menu/index.js +1 -1
- package/dist/components/Menu/nestedMenuItemsFromObject.js +1 -1
- package/dist/components/Modal/index.js +1 -1
- package/dist/components/MonthPicker/index.js +1 -1
- package/dist/components/MonthRangePicker/index.js +1 -1
- package/dist/components/Panel/index.js +1 -1
- package/dist/components/Popover/index.js +1 -1
- package/dist/components/Prompt/index.js +1 -1
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +2 -2
- package/dist/components/Skeleton/Skeleton.types.d.ts +39 -0
- package/dist/components/Skeleton/Skeleton.types.d.ts.map +1 -0
- package/dist/components/Skeleton/index.d.ts +13 -0
- package/dist/components/Skeleton/index.d.ts.map +1 -0
- package/dist/components/Skeleton/index.js +94 -0
- package/dist/components/Stepper/index.js +1 -1
- package/dist/components/Table/AdvanceSearchModalItem.js +1 -1
- package/dist/components/Table/AgGridHeader.d.ts.map +1 -1
- package/dist/components/Table/AgGridHeader.js +33 -24
- package/dist/components/Table/NewAdvanceSearchModal/NewAdvanceSearchModalItem.js +1 -1
- package/dist/components/Table/index.js +1 -1
- package/dist/components/TableChat/EmptyContainer.js +1 -1
- package/dist/components/TableChat/TableChatSidePanel.js +1 -1
- package/dist/components/TableChat/components/TableChatLeftSection/AddChatContainer/AddChatContainer.js +1 -1
- package/dist/components/TableChat/components/TableChatLeftSection/TableChatChannelHeader.js +1 -1
- package/dist/components/TableChat/components/TableChatRightSection/AvatarGroup/AvatarGroup.js +1 -1
- package/dist/components/TableChat/components/TableChatRightSection/ChatDefaultMessageType/ChatDefaultMessageType.js +1 -1
- package/dist/components/TableChat/components/TableChatRightSection/ChatDeleteMessageType/ChatDeletedMessageType.js +1 -1
- package/dist/components/TableChat/components/TableChatRightSection/ChatHeader/ChatHeader.js +1 -1
- package/dist/components/TableChat/components/TableChatRightSection/ChatInput/ChatInput.js +1 -1
- package/dist/components/TableChat/components/TableChatRightSection/ChatMessages/ChatMessage.js +1 -1
- package/dist/components/TableChat/components/TableChatRightSection/ChatNotificationSettings/ChatNotificationSettings.js +1 -1
- package/dist/components/TableChat/components/TableChatRightSection/TableChatRightSection.js +1 -1
- package/dist/components/TableChat/components/TextEditor/EditorToolbar.js +1 -1
- package/dist/components/TableChat/components/TextEditor/Mention.js +1 -1
- package/dist/components/TableChat/components/TextEditor/MentionList.js +1 -1
- package/dist/components/TableOld/AgGridHeader.d.ts.map +1 -1
- package/dist/components/TableOld/AgGridHeader.js +15 -13
- package/dist/components/TableOld/index.js +1 -1
- package/dist/components/TableV36/AdvanceSearchModalItem.d.ts +27 -0
- package/dist/components/TableV36/AdvanceSearchModalItem.d.ts.map +1 -0
- package/dist/components/TableV36/AdvanceSortModal.d.ts +8 -0
- package/dist/components/TableV36/AdvanceSortModal.d.ts.map +1 -0
- package/dist/components/TableV36/AdvanceSortModal.js +297 -0
- package/dist/components/TableV36/AgGridHeader.d.ts +16 -0
- package/dist/components/TableV36/AgGridHeader.d.ts.map +1 -0
- package/dist/components/TableV36/AgGridHeader.js +799 -0
- package/dist/components/TableV36/CommentsPortal.d.ts +31 -0
- package/dist/components/TableV36/CommentsPortal.d.ts.map +1 -0
- package/dist/components/TableV36/CommentsPortal.js +362 -0
- package/dist/components/TableV36/NewAdvanceSearchModal/NewAdvanceSearchModal.d.ts +13 -0
- package/dist/components/TableV36/NewAdvanceSearchModal/NewAdvanceSearchModal.d.ts.map +1 -0
- package/dist/components/TableV36/NewAdvanceSearchModal/NewAdvanceSearchModal.js +282 -0
- package/dist/components/TableV36/NewAdvanceSearchModal/NewAdvanceSearchModalItem.d.ts +16 -0
- package/dist/components/TableV36/NewAdvanceSearchModal/NewAdvanceSearchModalItem.d.ts.map +1 -0
- package/dist/components/TableV36/NewAdvanceSearchModal/NewAdvanceSearchModalItem.js +302 -0
- package/dist/components/TableV36/NoComments.d.ts +16 -0
- package/dist/components/TableV36/NoComments.d.ts.map +1 -0
- package/dist/components/TableV36/NoComments.js +237 -0
- package/dist/components/TableV36/Table.types.d.ts +89 -0
- package/dist/components/TableV36/Table.types.d.ts.map +1 -0
- package/dist/components/TableV36/actionBar.d.ts +7 -0
- package/dist/components/TableV36/actionBar.d.ts.map +1 -0
- package/dist/components/TableV36/actionBar.js +31 -0
- package/dist/components/TableV36/advanceSearchModal.d.ts +20 -0
- package/dist/components/TableV36/advanceSearchModal.d.ts.map +1 -0
- package/dist/components/TableV36/filterUtils.d.ts +133 -0
- package/dist/components/TableV36/filterUtils.d.ts.map +1 -0
- package/dist/components/TableV36/filterUtils.js +478 -0
- package/dist/components/TableV36/index.d.ts +3 -0
- package/dist/components/TableV36/index.d.ts.map +1 -0
- package/dist/components/TableV36/index.js +1603 -0
- package/dist/components/TableV36/mockData.d.ts +39 -0
- package/dist/components/TableV36/mockData.d.ts.map +1 -0
- package/dist/components/TableV36/tableFunctions.d.ts +63 -0
- package/dist/components/TableV36/tableFunctions.d.ts.map +1 -0
- package/dist/components/TableV36/tableFunctions.js +1796 -0
- package/dist/components/TableV36/tableHeader.d.ts +80 -0
- package/dist/components/TableV36/tableHeader.d.ts.map +1 -0
- package/dist/components/TableV36/tableHeader.js +396 -0
- package/dist/components/TableV36/tableIcons.d.ts +3 -0
- package/dist/components/TableV36/tableIcons.d.ts.map +1 -0
- package/dist/components/TableV36/tableMoreOptions.d.ts +52 -0
- package/dist/components/TableV36/tableMoreOptions.d.ts.map +1 -0
- package/dist/components/TableV36/tableMoreOptions.js +324 -0
- package/dist/components/TableV36/tablePagination.d.ts +7 -0
- package/dist/components/TableV36/tablePagination.d.ts.map +1 -0
- package/dist/components/TableV36/tablePagination.js +67 -0
- package/dist/components/TableV36/tableSettings.d.ts +41 -0
- package/dist/components/TableV36/tableSettings.d.ts.map +1 -0
- package/dist/components/TableV36/tableSettings.js +317 -0
- package/dist/components/TableV36/withCommentIcon.d.ts +7 -0
- package/dist/components/TableV36/withCommentIcon.d.ts.map +1 -0
- package/dist/components/TableV36/withCommentIcon.js +108 -0
- package/dist/components/Tag/index.js +1 -1
- package/dist/components/TextArea/index.js +1 -1
- package/dist/components/common/MentionEditor/MentionList/index.js +1 -1
- package/dist/components/common/MentionEditor/index.js +1 -1
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +5 -0
- package/dist/mcp-component-registry.json +1 -1
- package/dist/node_modules/prop-types/index.js +1 -1
- package/dist/node_modules/react-is/index.js +1 -1
- package/dist/styles/style.css +1 -1
- package/dist/utils/helper.d.ts +1 -0
- package/dist/utils/helper.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
import moment from "moment";
|
|
2
|
+
import { TEXT_FILTER_OPTIONS, NON_TEXT_FILTER_OPTIONS, DATE_FILTER_OPTIONS, convertToOptions } from "../../utils/helper.js";
|
|
3
|
+
const getOperatorListForColumn = (columnDef) => {
|
|
4
|
+
if (columnDef == null ? void 0 : columnDef.operationFilterOptions) {
|
|
5
|
+
return columnDef.operationFilterOptions;
|
|
6
|
+
}
|
|
7
|
+
if (columnDef == null ? void 0 : columnDef.thirdOptionAsDateRangePicker) {
|
|
8
|
+
return [{ label: "In range", value: "inRange" }];
|
|
9
|
+
}
|
|
10
|
+
switch (columnDef == null ? void 0 : columnDef.filter) {
|
|
11
|
+
case "agDateColumnFilter":
|
|
12
|
+
return DATE_FILTER_OPTIONS;
|
|
13
|
+
case "agNumberColumnFilter":
|
|
14
|
+
return NON_TEXT_FILTER_OPTIONS;
|
|
15
|
+
case "agTextColumnFilter":
|
|
16
|
+
if ((columnDef == null ? void 0 : columnDef.dataType) === "boolean") {
|
|
17
|
+
return [
|
|
18
|
+
{ label: "Equals", value: "equals" },
|
|
19
|
+
{ label: "Not equal", value: "notEqual" }
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
if ((columnDef == null ? void 0 : columnDef.type) === "number") {
|
|
23
|
+
return TEXT_FILTER_OPTIONS;
|
|
24
|
+
}
|
|
25
|
+
return TEXT_FILTER_OPTIONS;
|
|
26
|
+
}
|
|
27
|
+
if ((columnDef == null ? void 0 : columnDef.dataType) === "boolean") {
|
|
28
|
+
return [
|
|
29
|
+
{ label: "Equals", value: "equals" },
|
|
30
|
+
{ label: "Not equal", value: "notEqual" }
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
if ((columnDef == null ? void 0 : columnDef.type) === "number") {
|
|
34
|
+
return NON_TEXT_FILTER_OPTIONS;
|
|
35
|
+
}
|
|
36
|
+
return TEXT_FILTER_OPTIONS;
|
|
37
|
+
};
|
|
38
|
+
const getDefaultOperationForColumn = (columnDef, filter = null) => {
|
|
39
|
+
const operatorList = getOperatorListForColumn(columnDef);
|
|
40
|
+
const equalsOption = operatorList.find((opt) => opt.value === "equals");
|
|
41
|
+
if (columnDef == null ? void 0 : columnDef.thirdOptionAsDateRangePicker) {
|
|
42
|
+
return { label: "In range", value: "inRange" };
|
|
43
|
+
}
|
|
44
|
+
const prefersEquals = (columnDef == null ? void 0 : columnDef.filter) === "agDateColumnFilter" || (filter == null ? void 0 : filter.filterType) === "date" || (columnDef == null ? void 0 : columnDef.filter) === "agNumberColumnFilter" || (columnDef == null ? void 0 : columnDef.dataType) === "boolean" || (filter == null ? void 0 : filter.filterType) === "boolean" || (columnDef == null ? void 0 : columnDef.type) === "number" && (columnDef == null ? void 0 : columnDef.filter) === "agNumberColumnFilter";
|
|
45
|
+
if (prefersEquals && equalsOption) {
|
|
46
|
+
return equalsOption;
|
|
47
|
+
}
|
|
48
|
+
return operatorList[0];
|
|
49
|
+
};
|
|
50
|
+
const cleanNumericValue = (value) => {
|
|
51
|
+
if (typeof value !== "string") {
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
return value.replace(/[$€£¥₹,\s%]/g, "");
|
|
55
|
+
};
|
|
56
|
+
const parseFilterValue = (value, columnDef) => {
|
|
57
|
+
const type = columnDef == null ? void 0 : columnDef.type;
|
|
58
|
+
const filter = columnDef == null ? void 0 : columnDef.filter;
|
|
59
|
+
let parsedValue;
|
|
60
|
+
let filterType = "contains";
|
|
61
|
+
if (value && typeof value === "object" && (value == null ? void 0 : value.startDate) !== void 0 && (value == null ? void 0 : value.endDate) !== void 0) {
|
|
62
|
+
const startDate = moment.isMoment(value.startDate) ? value.startDate : moment(value.startDate);
|
|
63
|
+
const endDate = moment.isMoment(value.endDate) ? value.endDate : moment(value.endDate);
|
|
64
|
+
parsedValue = {
|
|
65
|
+
startDate: startDate.isValid() ? startDate.format("YYYY-MM-DD") : null,
|
|
66
|
+
endDate: endDate.isValid() ? endDate.format("YYYY-MM-DD") : null
|
|
67
|
+
};
|
|
68
|
+
return { parsedValue, filterType };
|
|
69
|
+
}
|
|
70
|
+
if (filter === "agDateColumnFilter") {
|
|
71
|
+
filterType = "equals";
|
|
72
|
+
if (value && typeof value === "object" && moment.isMoment(value)) {
|
|
73
|
+
parsedValue = value.format("YYYY-MM-DD");
|
|
74
|
+
return { parsedValue, filterType };
|
|
75
|
+
}
|
|
76
|
+
if (value && typeof value === "string") {
|
|
77
|
+
const dateMoment = moment(value, ["MM-DD-YYYY", "YYYY-MM-DD", "MM/DD/YYYY"], true);
|
|
78
|
+
if (dateMoment.isValid()) {
|
|
79
|
+
parsedValue = dateMoment.format("YYYY-MM-DD");
|
|
80
|
+
return { parsedValue, filterType };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (value && typeof value === "object" && typeof (value == null ? void 0 : value.format) === "function") {
|
|
84
|
+
parsedValue = value.format("YYYY-MM-DD");
|
|
85
|
+
return { parsedValue, filterType };
|
|
86
|
+
}
|
|
87
|
+
parsedValue = void 0;
|
|
88
|
+
return { parsedValue, filterType };
|
|
89
|
+
}
|
|
90
|
+
if (filter === "agNumberColumnFilter" || type === "number") {
|
|
91
|
+
const cleanedValue = cleanNumericValue(value);
|
|
92
|
+
const numericValue = parseFloat(cleanedValue);
|
|
93
|
+
if (isNaN(numericValue) || cleanedValue === "") {
|
|
94
|
+
return { parsedValue: null, filterType };
|
|
95
|
+
}
|
|
96
|
+
parsedValue = numericValue;
|
|
97
|
+
filterType = "equals";
|
|
98
|
+
return { parsedValue, filterType };
|
|
99
|
+
}
|
|
100
|
+
parsedValue = typeof value === "string" ? value : typeof value === "object" && (value == null ? void 0 : value.value) ? value.value : value;
|
|
101
|
+
return { parsedValue, filterType };
|
|
102
|
+
};
|
|
103
|
+
const isColumnDataString = (api, columnId) => {
|
|
104
|
+
let firstValue = null;
|
|
105
|
+
api.forEachNode((node) => {
|
|
106
|
+
if (firstValue === null && node.data) {
|
|
107
|
+
firstValue = node.data[columnId];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
return typeof firstValue === "string";
|
|
111
|
+
};
|
|
112
|
+
const buildFilterModelEntry = (parsedValue, filterType, columnDef, operationType = null) => {
|
|
113
|
+
const type = columnDef == null ? void 0 : columnDef.type;
|
|
114
|
+
const filter = columnDef == null ? void 0 : columnDef.filter;
|
|
115
|
+
const operator = operationType || filterType;
|
|
116
|
+
if (operator === "blank" || operator === "notBlank") {
|
|
117
|
+
let filterTypeForBlank = "text";
|
|
118
|
+
if (filter === "agDateColumnFilter") {
|
|
119
|
+
filterTypeForBlank = "date";
|
|
120
|
+
} else if (filter === "agNumberColumnFilter" || type === "number") {
|
|
121
|
+
filterTypeForBlank = "number";
|
|
122
|
+
} else if ((columnDef == null ? void 0 : columnDef.dataType) === "boolean" && filter === "agTextColumnFilter") {
|
|
123
|
+
filterTypeForBlank = "text";
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
filterType: filterTypeForBlank,
|
|
127
|
+
type: operator
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (parsedValue === null || parsedValue === void 0 || parsedValue === "") {
|
|
131
|
+
return void 0;
|
|
132
|
+
}
|
|
133
|
+
if (Array.isArray(parsedValue)) {
|
|
134
|
+
const validValues = parsedValue.filter((v) => v !== null && v !== void 0 && v !== "");
|
|
135
|
+
if (validValues.length === 0) {
|
|
136
|
+
return void 0;
|
|
137
|
+
}
|
|
138
|
+
if (validValues.length === 1) {
|
|
139
|
+
return buildFilterModelEntry(
|
|
140
|
+
String(typeof validValues[0] === "object" ? validValues[0].value : validValues[0]),
|
|
141
|
+
filterType,
|
|
142
|
+
columnDef,
|
|
143
|
+
operationType
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
const filterTypeStr = filter === "agDateColumnFilter" ? "date" : filter === "agNumberColumnFilter" || type === "number" ? "number" : "text";
|
|
147
|
+
const conditions = validValues.map((val) => ({
|
|
148
|
+
filterType: filterTypeStr,
|
|
149
|
+
type: operator,
|
|
150
|
+
filter: String(val.value)
|
|
151
|
+
}));
|
|
152
|
+
return {
|
|
153
|
+
filterType: filterTypeStr,
|
|
154
|
+
operator: (columnDef == null ? void 0 : columnDef.operator) || "OR",
|
|
155
|
+
conditions
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (filter === "agDateColumnFilter" && typeof parsedValue === "object" && parsedValue.startDate && parsedValue.endDate) {
|
|
159
|
+
return {
|
|
160
|
+
filterType: "date",
|
|
161
|
+
type: "inRange",
|
|
162
|
+
dateFrom: parsedValue.startDate,
|
|
163
|
+
dateTo: parsedValue.endDate
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
if (filter === "agDateColumnFilter") {
|
|
167
|
+
return {
|
|
168
|
+
filterType: "date",
|
|
169
|
+
type: operator,
|
|
170
|
+
dateFrom: parsedValue
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
if (filter === "agNumberColumnFilter") {
|
|
174
|
+
return {
|
|
175
|
+
filterType: "number",
|
|
176
|
+
type: operator,
|
|
177
|
+
filter: parsedValue
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
if ((columnDef == null ? void 0 : columnDef.dataType) === "boolean") {
|
|
181
|
+
return {
|
|
182
|
+
filterType: "text",
|
|
183
|
+
type: operator,
|
|
184
|
+
filter: String(parsedValue)
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
if (type === "number" && filter === "agTextColumnFilter") {
|
|
188
|
+
return {
|
|
189
|
+
filterType: "text",
|
|
190
|
+
type: operator,
|
|
191
|
+
filter: String(parsedValue)
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
if (type === "number") {
|
|
195
|
+
return {
|
|
196
|
+
filterType: "number",
|
|
197
|
+
type: operator,
|
|
198
|
+
filter: parsedValue
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
const filterEntry = {
|
|
202
|
+
type: operator,
|
|
203
|
+
filter: parsedValue,
|
|
204
|
+
filterType: "text"
|
|
205
|
+
};
|
|
206
|
+
return filterEntry;
|
|
207
|
+
};
|
|
208
|
+
const findColumnDef = (colDefs, field) => {
|
|
209
|
+
var _a;
|
|
210
|
+
for (const col of colDefs) {
|
|
211
|
+
if (col.children) {
|
|
212
|
+
const found = findColumnDef(col.children, field);
|
|
213
|
+
if (found) return found;
|
|
214
|
+
}
|
|
215
|
+
if (col.toShowDuplicateColumnInAdvanceSearch && col.columnFieldsInAdvanceSearch) {
|
|
216
|
+
const index = (_a = col.columnFieldsInAdvanceSearch) == null ? void 0 : _a.indexOf(field);
|
|
217
|
+
if (index !== -1) {
|
|
218
|
+
return {
|
|
219
|
+
...col,
|
|
220
|
+
currentColumnField: `${field}${index + 1}`
|
|
221
|
+
// add index + 1
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
} else if (col.colId && col.colId === field || col.field && col.field === field) {
|
|
225
|
+
return col;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return null;
|
|
229
|
+
};
|
|
230
|
+
const parseInlineSearchValue = (value, columnDef, api, columnId) => {
|
|
231
|
+
const type = columnDef == null ? void 0 : columnDef.type;
|
|
232
|
+
const filter = columnDef == null ? void 0 : columnDef.filter;
|
|
233
|
+
if (filter === "agDateColumnFilter") {
|
|
234
|
+
if (value && typeof value === "object" && (value == null ? void 0 : value.startDate) !== void 0 && (value == null ? void 0 : value.endDate) !== void 0) {
|
|
235
|
+
const startDate = moment.isMoment(value.startDate) ? value.startDate : moment(value.startDate);
|
|
236
|
+
const endDate = moment.isMoment(value.endDate) ? value.endDate : moment(value.endDate);
|
|
237
|
+
return {
|
|
238
|
+
parsedValue: {
|
|
239
|
+
startDate: startDate.isValid() ? startDate.format("YYYY-MM-DD") : null,
|
|
240
|
+
endDate: endDate.isValid() ? endDate.format("YYYY-MM-DD") : null
|
|
241
|
+
},
|
|
242
|
+
filterType: "inRange"
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
if (value && typeof value === "object" && moment.isMoment(value)) {
|
|
246
|
+
return {
|
|
247
|
+
parsedValue: value.format("YYYY-MM-DD"),
|
|
248
|
+
filterType: "equals"
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
if (value && typeof value === "string") {
|
|
252
|
+
const dateMoment = moment(value, ["MM-DD-YYYY", "YYYY-MM-DD", "MM/DD/YYYY"]);
|
|
253
|
+
if (dateMoment.isValid()) {
|
|
254
|
+
return {
|
|
255
|
+
parsedValue: dateMoment.format("YYYY-MM-DD"),
|
|
256
|
+
filterType: "equals"
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return { parsedValue: void 0, filterType: "equals" };
|
|
261
|
+
}
|
|
262
|
+
if (filter === "agNumberColumnFilter" || type === "number") {
|
|
263
|
+
const cleanedValue = cleanNumericValue(value);
|
|
264
|
+
const parsedNumber = parseFloat(cleanedValue);
|
|
265
|
+
if (isNaN(parsedNumber) || cleanedValue === "") {
|
|
266
|
+
return { parsedValue: null, filterType: "contains" };
|
|
267
|
+
}
|
|
268
|
+
const isStringColumn = isColumnDataString(api, columnId);
|
|
269
|
+
if (isStringColumn) {
|
|
270
|
+
return { parsedValue: value, filterType: "contains" };
|
|
271
|
+
} else {
|
|
272
|
+
return { parsedValue: parsedNumber, filterType: "equals" };
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
if ((columnDef == null ? void 0 : columnDef.dataType) === "boolean") {
|
|
276
|
+
return { parsedValue: value, filterType: "equals" };
|
|
277
|
+
}
|
|
278
|
+
return { parsedValue: value, filterType: "contains" };
|
|
279
|
+
};
|
|
280
|
+
const isValidFilterValue = (parsedValue) => {
|
|
281
|
+
if (parsedValue === null || parsedValue === void 0) {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
if (typeof parsedValue === "number" && isNaN(parsedValue)) {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
if (typeof parsedValue === "string" && parsedValue.trim() === "") {
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
if (typeof parsedValue === "object" && parsedValue.startDate !== void 0 && parsedValue.endDate !== void 0) {
|
|
291
|
+
return parsedValue.startDate !== null && parsedValue.endDate !== null;
|
|
292
|
+
}
|
|
293
|
+
return true;
|
|
294
|
+
};
|
|
295
|
+
const getColumnLabel = (columnId, columnDef, colDefs) => {
|
|
296
|
+
let label = (columnDef == null ? void 0 : columnDef.headerName) || columnId;
|
|
297
|
+
if (colDefs) {
|
|
298
|
+
const columnOptions = convertToOptions(colDefs);
|
|
299
|
+
const columnOption = columnOptions.find((opt) => opt.value === columnId);
|
|
300
|
+
if (columnOption == null ? void 0 : columnOption.label) {
|
|
301
|
+
label = columnOption.label;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return label;
|
|
305
|
+
};
|
|
306
|
+
const hasValidFilterValue = (filter) => {
|
|
307
|
+
if (!filter || filter === void 0 || filter === null) {
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
const hasValue = filter.filter !== void 0 && filter.filter !== null && filter.filter !== "" || filter.dateFrom !== void 0 && filter.dateFrom !== null && filter.dateFrom !== "";
|
|
311
|
+
return hasValue;
|
|
312
|
+
};
|
|
313
|
+
const convertFilterToModalFormat = (columnId, filter, columnDef, colDefs) => {
|
|
314
|
+
var _a;
|
|
315
|
+
const columnLabel = getColumnLabel(columnId, columnDef, colDefs);
|
|
316
|
+
let value = (filter == null ? void 0 : filter.filter) || "";
|
|
317
|
+
if (filter == null ? void 0 : filter.dateFrom) {
|
|
318
|
+
if (typeof filter.dateFrom === "string") {
|
|
319
|
+
value = (_a = filter.dateFrom.split(" ")) == null ? void 0 : _a[0];
|
|
320
|
+
} else if (filter.dateFrom instanceof Date) {
|
|
321
|
+
value = moment(filter.dateFrom).format("YYYY-MM-DD");
|
|
322
|
+
} else {
|
|
323
|
+
value = filter.dateFrom;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
let operationType = filter == null ? void 0 : filter.type;
|
|
327
|
+
let operationLabel;
|
|
328
|
+
if (!operationType) {
|
|
329
|
+
const defaultOp = getDefaultOperationForColumn(columnDef, filter);
|
|
330
|
+
operationType = defaultOp.value;
|
|
331
|
+
operationLabel = defaultOp.label;
|
|
332
|
+
} else {
|
|
333
|
+
operationLabel = operationType.charAt(0).toUpperCase() + operationType.slice(1);
|
|
334
|
+
}
|
|
335
|
+
return {
|
|
336
|
+
column: {
|
|
337
|
+
label: columnLabel,
|
|
338
|
+
value: columnId,
|
|
339
|
+
type: (filter == null ? void 0 : filter.filterType) || "text"
|
|
340
|
+
},
|
|
341
|
+
operation: {
|
|
342
|
+
label: operationLabel,
|
|
343
|
+
value: operationType
|
|
344
|
+
},
|
|
345
|
+
value
|
|
346
|
+
};
|
|
347
|
+
};
|
|
348
|
+
const getColumnDefById = (api, colId, colDefs) => {
|
|
349
|
+
const column = api == null ? void 0 : api.getColumn(colId);
|
|
350
|
+
if (column) {
|
|
351
|
+
return column.getColDef();
|
|
352
|
+
}
|
|
353
|
+
if (colDefs) {
|
|
354
|
+
return findColumnDef(colDefs, colId);
|
|
355
|
+
}
|
|
356
|
+
return null;
|
|
357
|
+
};
|
|
358
|
+
const convertActiveFiltersToModalFormat = (filterModel, api, colDefs) => {
|
|
359
|
+
return Object.keys(filterModel).filter((colId) => hasValidFilterValue(filterModel[colId])).map((colId) => {
|
|
360
|
+
const filter = filterModel[colId];
|
|
361
|
+
const colDef = getColumnDefById(api, colId, colDefs);
|
|
362
|
+
return convertFilterToModalFormat(colId, filter, colDef, colDefs);
|
|
363
|
+
});
|
|
364
|
+
};
|
|
365
|
+
const prepareValueForModal = (inputValue, columnDef, getOptionFromDropdownValue) => {
|
|
366
|
+
const columnType = columnDef == null ? void 0 : columnDef.type;
|
|
367
|
+
switch (columnType) {
|
|
368
|
+
case "dropdown":
|
|
369
|
+
case "select":
|
|
370
|
+
if ((columnDef == null ? void 0 : columnDef.thirdOptionDropdownOptions) && inputValue) {
|
|
371
|
+
const optionObject = getOptionFromDropdownValue(inputValue, columnDef);
|
|
372
|
+
return typeof optionObject === "object" && optionObject !== null && optionObject.label ? optionObject : inputValue;
|
|
373
|
+
}
|
|
374
|
+
return inputValue;
|
|
375
|
+
case "date":
|
|
376
|
+
return inputValue;
|
|
377
|
+
case "number":
|
|
378
|
+
return inputValue;
|
|
379
|
+
case "text":
|
|
380
|
+
default:
|
|
381
|
+
if ((columnDef == null ? void 0 : columnDef.thirdOptionDropdownOptions) && inputValue) {
|
|
382
|
+
const optionObject = getOptionFromDropdownValue(inputValue, columnDef);
|
|
383
|
+
return typeof optionObject === "object" && optionObject !== null && optionObject.label ? optionObject : inputValue;
|
|
384
|
+
}
|
|
385
|
+
return inputValue;
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
const createModalFilterEntry = (columnId, value, columnDef, colDefs) => {
|
|
389
|
+
return {
|
|
390
|
+
column: {
|
|
391
|
+
label: getColumnLabel(columnId, columnDef, colDefs),
|
|
392
|
+
value: columnId,
|
|
393
|
+
type: (columnDef == null ? void 0 : columnDef.type) || "text"
|
|
394
|
+
},
|
|
395
|
+
operation: getDefaultOperationForColumn(columnDef),
|
|
396
|
+
value
|
|
397
|
+
};
|
|
398
|
+
};
|
|
399
|
+
const updateOrAddFilter = (existingFilters, columnId, value, columnDef, colDefs) => {
|
|
400
|
+
const isAlreadyPresent = existingFilters.find((f) => {
|
|
401
|
+
var _a;
|
|
402
|
+
return ((_a = f == null ? void 0 : f.column) == null ? void 0 : _a.value) === columnId;
|
|
403
|
+
});
|
|
404
|
+
if (isAlreadyPresent) {
|
|
405
|
+
return existingFilters.map((f) => {
|
|
406
|
+
var _a;
|
|
407
|
+
return ((_a = f == null ? void 0 : f.column) == null ? void 0 : _a.value) === columnId ? { ...f, value } : f;
|
|
408
|
+
});
|
|
409
|
+
} else {
|
|
410
|
+
return [...existingFilters, createModalFilterEntry(columnId, value, columnDef, colDefs)];
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
const syncFiltersWithModal = (api, currentColumnId, inputValue, columnDef, colDefs, setValue, setInitialFilters, getOptionFromDropdownValue) => {
|
|
414
|
+
try {
|
|
415
|
+
const currentFilterModel = (api == null ? void 0 : api.getFilterModel()) || {};
|
|
416
|
+
const filtersFromModel = convertActiveFiltersToModalFormat(currentFilterModel, api, colDefs);
|
|
417
|
+
const valueForModal = prepareValueForModal(inputValue, columnDef, getOptionFromDropdownValue);
|
|
418
|
+
const updatedFilters = updateOrAddFilter(
|
|
419
|
+
filtersFromModel,
|
|
420
|
+
currentColumnId,
|
|
421
|
+
valueForModal,
|
|
422
|
+
columnDef,
|
|
423
|
+
colDefs
|
|
424
|
+
);
|
|
425
|
+
setValue == null ? void 0 : setValue("filters", updatedFilters);
|
|
426
|
+
setInitialFilters == null ? void 0 : setInitialFilters(updatedFilters);
|
|
427
|
+
} catch (err) {
|
|
428
|
+
console.warn("Error syncing modal filters:", err);
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
const buildAdvanceSearchFilterModel = (formValues, colDefs) => {
|
|
432
|
+
const filterModel = {};
|
|
433
|
+
if (!formValues || !Array.isArray(formValues)) {
|
|
434
|
+
return filterModel;
|
|
435
|
+
}
|
|
436
|
+
formValues.forEach((value) => {
|
|
437
|
+
var _a, _b;
|
|
438
|
+
if (!((_a = value == null ? void 0 : value.column) == null ? void 0 : _a.value) || !((_b = value == null ? void 0 : value.operation) == null ? void 0 : _b.value)) {
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
const columnDef = findColumnDef(colDefs, value.column.value);
|
|
442
|
+
if (!columnDef) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
const { parsedValue, filterType } = parseFilterValue(value.value, columnDef);
|
|
446
|
+
if (!isValidFilterValue(parsedValue)) {
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
const columnKey = columnDef.colId || value.column.value;
|
|
450
|
+
const filterEntry = buildFilterModelEntry(
|
|
451
|
+
parsedValue,
|
|
452
|
+
filterType,
|
|
453
|
+
columnDef,
|
|
454
|
+
value.operation.value
|
|
455
|
+
);
|
|
456
|
+
if (filterEntry) {
|
|
457
|
+
filterModel[columnKey] = filterEntry;
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
return filterModel;
|
|
461
|
+
};
|
|
462
|
+
export {
|
|
463
|
+
buildAdvanceSearchFilterModel,
|
|
464
|
+
buildFilterModelEntry,
|
|
465
|
+
cleanNumericValue,
|
|
466
|
+
convertFilterToModalFormat,
|
|
467
|
+
findColumnDef,
|
|
468
|
+
getColumnLabel,
|
|
469
|
+
getDefaultOperationForColumn,
|
|
470
|
+
getOperatorListForColumn,
|
|
471
|
+
hasValidFilterValue,
|
|
472
|
+
isColumnDataString,
|
|
473
|
+
isValidFilterValue,
|
|
474
|
+
parseFilterValue,
|
|
475
|
+
parseInlineSearchValue,
|
|
476
|
+
syncFiltersWithModal,
|
|
477
|
+
updateOrAddFilter
|
|
478
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TableV36/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,sCAAsC,CAAC;AAC9C,OAAO,8CAA8C,CAAC;AACtD,OAAO,qBAAqB,CAAC;AAq1D7B,eAAO,MAAM,QAAQ,mFAUnB,CAAC"}
|