ar-design 0.4.63 → 0.4.65
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/assets/css/components/data-display/card/styles.css +2 -2
- package/dist/assets/css/components/data-display/dnd/styles.css +3 -3
- package/dist/assets/css/components/data-display/syntax-highlighter/syntax-highlighter.css +2 -2
- package/dist/assets/css/components/feedback/alert/styles.css +2 -2
- package/dist/assets/css/components/feedback/drawer/styles.css +3 -3
- package/dist/assets/css/components/feedback/modal/styles.css +15 -11
- package/dist/assets/css/components/feedback/progress/progress.css +3 -3
- package/dist/assets/css/components/form/button/styles.css +10 -7
- package/dist/assets/css/components/form/checkbox/checkbox.css +2 -2
- package/dist/assets/css/components/form/date-picker/date-picker.css +10 -10
- package/dist/assets/css/components/form/input/styles.css +15 -12
- package/dist/assets/css/components/form/radio/radio.css +2 -2
- package/dist/assets/css/components/form/select/styles.css +2 -2
- package/dist/assets/css/components/form/switch/styles.css +7 -3
- package/dist/assets/css/components/layout/layout.css +10 -10
- package/dist/assets/css/components/navigation/steps/styles.css +5 -3
- package/dist/assets/css/core/ar-core.css +25 -20
- package/dist/assets/css/core/utils.css +3 -0
- package/dist/components/data-display/diagram/index.js +1 -0
- package/dist/components/data-display/table/FilterPopup.js +8 -12
- package/dist/components/data-display/table/PropertiesPopup.js +10 -19
- package/dist/components/data-display/table/THeadCell.js +9 -8
- package/dist/components/data-display/table/body/TBody.js +54 -38
- package/dist/components/data-display/table/index.js +69 -176
- package/dist/components/feedback/popover/index.js +6 -0
- package/dist/components/feedback/tooltip/index.js +63 -16
- package/dist/components/form/date-picker/Props.d.ts +0 -1
- package/dist/components/form/input/otp/Otp.js +94 -79
- package/dist/components/form/radio/IProps.d.ts +0 -22
- package/dist/components/form/switch/IProps.d.ts +0 -11
- package/package.json +2 -2
|
@@ -22,7 +22,6 @@ import DatePicker from "../../form/date-picker";
|
|
|
22
22
|
import { useTranslation } from "../../../libs/core/application/hooks";
|
|
23
23
|
const { Row, Column } = Grid;
|
|
24
24
|
const Table = forwardRef(({ children, trackBy, title, description, data, columns, actions, rowBackgroundColor, selections, selectionDisabled, previousSelections, sortedParams, searchedParams, onEditable, onDnD, pagination, config = { isSearchable: false }, }, ref) => {
|
|
25
|
-
// refs
|
|
26
25
|
const _innerRef = useRef(null);
|
|
27
26
|
const _tableWrapper = useRef(null);
|
|
28
27
|
const _tableContent = useRef(null);
|
|
@@ -30,59 +29,42 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
30
29
|
const _dragItem = useRef(null);
|
|
31
30
|
const _checkboxItems = useRef([]);
|
|
32
31
|
const _filterCheckboxItems = useRef([]);
|
|
33
|
-
// refs -> Search
|
|
34
32
|
const _searchTextInputs = useRef([]);
|
|
35
33
|
const _searchTimeOut = useRef(null);
|
|
36
|
-
// refs -> Properties
|
|
37
34
|
const _propertiesButton = useRef([]);
|
|
38
|
-
// refs -> Filter
|
|
39
35
|
const _filterButton = useRef([]);
|
|
40
|
-
// refs -> Selection
|
|
41
36
|
const _selectionItems = useRef([]);
|
|
42
37
|
const lastSentRef = useRef([]);
|
|
43
|
-
// variables
|
|
44
38
|
const _subrowOpenAutomatically = config.subrow?.openAutomatically ?? false;
|
|
45
39
|
const _subrowSelector = config.subrow?.selector ?? "subitems";
|
|
46
|
-
const _subrowButton = config.subrow?.button ??
|
|
47
|
-
// className
|
|
40
|
+
const _subrowButton = config.subrow?.button ?? false;
|
|
48
41
|
const _tableClassName = ["ar-table", "scroll"];
|
|
49
|
-
// states
|
|
50
42
|
const [selectAll, setSelectAll] = useState(false);
|
|
51
43
|
const [showSubitems, setShowSubitems] = useState({});
|
|
52
|
-
// states -> Action Buttons
|
|
53
44
|
const [createTrigger, setCreateTrigger] = useState(false);
|
|
54
|
-
// states -> Search
|
|
55
45
|
const [searchedText, setSearchedText] = useState(null);
|
|
56
46
|
const [_searchedParams, setSearchedParams] = useState(null);
|
|
57
47
|
const [checkboxSelectedParams, setCheckboxSelectedParams] = useState(null);
|
|
58
|
-
// states -> Sort
|
|
59
48
|
const [sortConfig, setSortConfig] = useState([]);
|
|
60
49
|
const [sortCurrentColumn, setSortCurrentColumn] = useState(null);
|
|
61
|
-
// states -> Properties
|
|
62
50
|
const [openProperties, setOpenProperties] = useState(false);
|
|
63
51
|
const [propertiesButtonCoordinate, setPropertiesButtonCoordinate] = useState({
|
|
64
52
|
x: 0,
|
|
65
53
|
y: 0,
|
|
66
54
|
});
|
|
67
|
-
// states -> Filter
|
|
68
55
|
const [filterButtonCoordinate, setFilterButtonCoordinate] = useState({ x: 0, y: 0 });
|
|
69
56
|
const [filterPopupContent, setFilterPopupContent] = useState(null);
|
|
70
57
|
const [filterPopupOption, setFilterPopupOption] = useState(null);
|
|
71
58
|
const [filterPopupOptionSearchText, setFilterPopupOptionSearchText] = useState(null);
|
|
72
|
-
// states -> Filter Fields Backup
|
|
73
59
|
const [openFilter, setOpenFilter] = useState(false);
|
|
74
60
|
const [filterCurrentColumn, setFilterCurrentColumn] = useState(null);
|
|
75
61
|
const [filterCurrentDataType, setFilterCurrentDataType] = useState(null);
|
|
76
62
|
const [filterCurrentIndex, setFilterCurrentIndex] = useState(null);
|
|
77
|
-
// states -> Pagination
|
|
78
63
|
const [totalRecords, setTotalRecords] = useState(0);
|
|
79
64
|
const [currentPage, setCurrentPage] = useState(1);
|
|
80
65
|
const [selectedPerPage, setSelectedPerPage] = useState(pagination?.perPage ?? 10);
|
|
81
|
-
// states -> Mobil
|
|
82
66
|
const [isMobile, setIsMobile] = useState(false);
|
|
83
|
-
// hooks
|
|
84
67
|
const { t } = useTranslation(String(config.locale ?? "tr"));
|
|
85
|
-
// Dışarıdan gelen ref'i _innerRef'e bağla.
|
|
86
68
|
useImperativeHandle(ref, () => _innerRef.current);
|
|
87
69
|
if (config && Object.keys(config.scroll || {}).length > 0) {
|
|
88
70
|
if (_tableContent.current && config.scroll) {
|
|
@@ -91,7 +73,6 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
91
73
|
}
|
|
92
74
|
}
|
|
93
75
|
}
|
|
94
|
-
// methods
|
|
95
76
|
const handleScroll = useCallback(() => {
|
|
96
77
|
if (!_tableWrapper.current)
|
|
97
78
|
return;
|
|
@@ -105,12 +86,10 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
105
86
|
.filter((node) => node.nodeType === Node.ELEMENT_NODE)
|
|
106
87
|
.filter((child) => child.dataset.stickyPosition === "right")
|
|
107
88
|
.reverse();
|
|
108
|
-
// Calculate positions and minimize `getBoundingClientRect` calls
|
|
109
89
|
const leftRects = leftChildren.map((child) => child.getBoundingClientRect());
|
|
110
90
|
const rightRects = rightChildren.map((child) => child.getBoundingClientRect());
|
|
111
91
|
const leftPrevious = leftRects.map((rect) => Math.abs(rect.right - wrapperRect.left));
|
|
112
92
|
const rightPrevious = rightRects.map((rect) => Math.abs(rect.left - wrapperRect.right));
|
|
113
|
-
// #region Left
|
|
114
93
|
leftChildren.forEach((child, index) => {
|
|
115
94
|
const prevLeft = index > 0 ? leftPrevious[index - 1] : 0;
|
|
116
95
|
if (index > 0) {
|
|
@@ -128,8 +107,6 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
128
107
|
if (child.nodeName === "TD")
|
|
129
108
|
child.style.zIndex = `5`;
|
|
130
109
|
});
|
|
131
|
-
// #endregion
|
|
132
|
-
// #region Right
|
|
133
110
|
rightChildren.forEach((child, index) => {
|
|
134
111
|
const prevRight = index > 0 ? rightPrevious[index - 1] : 0;
|
|
135
112
|
if (index > 0) {
|
|
@@ -145,7 +122,6 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
145
122
|
else
|
|
146
123
|
child.classList.add("sticky");
|
|
147
124
|
});
|
|
148
|
-
// #endregion
|
|
149
125
|
});
|
|
150
126
|
};
|
|
151
127
|
const theadElements = _tableWrapper.current.querySelectorAll("table > thead > tr");
|
|
@@ -156,12 +132,12 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
156
132
|
});
|
|
157
133
|
}, []);
|
|
158
134
|
const handleResize = useMemo(() => {
|
|
159
|
-
return (
|
|
135
|
+
return () => {
|
|
160
136
|
setIsMobile(window.innerWidth <= 768);
|
|
161
137
|
};
|
|
162
138
|
}, []);
|
|
163
139
|
const handleSearch = useCallback((name, value, dataType) => {
|
|
164
|
-
const operator = filterPopupOption?.key
|
|
140
|
+
const operator = filterPopupOption?.key === name
|
|
165
141
|
? filterPopupOption.option?.value
|
|
166
142
|
: FilterOperator.Contains;
|
|
167
143
|
if (config.isServerSide) {
|
|
@@ -180,16 +156,16 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
180
156
|
setSearchedText((prev) => {
|
|
181
157
|
const _state = { ...prev };
|
|
182
158
|
if (value === "") {
|
|
183
|
-
delete _state[name];
|
|
159
|
+
delete _state[name];
|
|
184
160
|
}
|
|
185
161
|
else {
|
|
186
|
-
_state[name] = { value: value, operator: operator };
|
|
162
|
+
_state[name] = { value: value, operator: operator };
|
|
187
163
|
}
|
|
188
164
|
return _state;
|
|
189
165
|
});
|
|
190
166
|
}
|
|
191
167
|
setCurrentPage(1);
|
|
192
|
-
}, [filterPopupOption]);
|
|
168
|
+
}, [filterPopupOption, config.isServerSide, pagination, selectedPerPage]);
|
|
193
169
|
const handleCheckboxChange = useCallback(async (event) => {
|
|
194
170
|
event.stopPropagation();
|
|
195
171
|
const { name, value, checked } = event.target;
|
|
@@ -199,7 +175,7 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
199
175
|
checked ? updatedSet.add(value) : updatedSet.delete(value);
|
|
200
176
|
const updatedArray = Array.from(updatedSet).map((v) => ({
|
|
201
177
|
value: v,
|
|
202
|
-
operator: FilterOperator.Equals,
|
|
178
|
+
operator: FilterOperator.Equals,
|
|
203
179
|
}));
|
|
204
180
|
return {
|
|
205
181
|
...prev,
|
|
@@ -211,15 +187,12 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
211
187
|
const key = ExtractKey(c.key);
|
|
212
188
|
if (!key)
|
|
213
189
|
return;
|
|
214
|
-
const value = Array.isArray(searchedText?.[key])
|
|
215
|
-
|
|
216
|
-
: searchedText?.[key]?.value;
|
|
217
|
-
const handleChange = (value) => {
|
|
190
|
+
const value = Array.isArray(searchedText?.[key]) ? "" : searchedText?.[key]?.value;
|
|
191
|
+
const handleChange = (val) => {
|
|
218
192
|
const input = _searchTextInputs.current[index ?? 0];
|
|
219
193
|
if (input) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
input.dispatchEvent(event);
|
|
194
|
+
input.value = val;
|
|
195
|
+
handleSearch(key, val, dataType);
|
|
223
196
|
}
|
|
224
197
|
};
|
|
225
198
|
setFilterPopupContent(() => {
|
|
@@ -237,16 +210,15 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
237
210
|
case "boolean":
|
|
238
211
|
return (React.createElement(Row, null,
|
|
239
212
|
React.createElement(Column, { size: 12 },
|
|
240
|
-
React.createElement(Input, { value:
|
|
213
|
+
React.createElement(Input, { value: filterPopupOptionSearchText ?? "", onChange: (event) => setFilterPopupOptionSearchText(event.target.value), placeholder: t("Table.Filters.Search.Input.Placeholder") })),
|
|
241
214
|
React.createElement(Column, { size: 12 }, c.filters
|
|
242
215
|
?.filter((filter) => filter.text.toLocaleLowerCase().includes(filterPopupOptionSearchText?.toLocaleLowerCase() ?? ""))
|
|
243
216
|
?.map((filter, fIndex) => {
|
|
244
217
|
const name = typeof c.key !== "object" ? String(c.key) : String(c.key.field);
|
|
245
|
-
return (React.createElement("div",
|
|
218
|
+
return (React.createElement("div", { key: `filter-check-${fIndex}` },
|
|
246
219
|
React.createElement(Checkbox, { ref: (element) => {
|
|
247
|
-
if (
|
|
248
|
-
|
|
249
|
-
_filterCheckboxItems.current[fIndex] = element;
|
|
220
|
+
if (element)
|
|
221
|
+
_filterCheckboxItems.current[fIndex] = element;
|
|
250
222
|
}, variant: "filled", color: "green", label: filter.text, name: name, value: filter.value, checked: Array.isArray(checkboxSelectedParams?.[name]) &&
|
|
251
223
|
checkboxSelectedParams?.[name]?.some((f) => String(f.value) === String(filter.value)), onChange: async (event) => await handleCheckboxChange(event) })));
|
|
252
224
|
}))));
|
|
@@ -255,17 +227,14 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
255
227
|
}
|
|
256
228
|
});
|
|
257
229
|
};
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
if (!searchedText || Object.keys(searchedText).length === 0)
|
|
230
|
+
const deepSearch = (item, searchParams) => {
|
|
231
|
+
if (!searchParams || Object.keys(searchParams).length === 0)
|
|
261
232
|
return true;
|
|
262
233
|
const applyOperator = (value, filter) => {
|
|
263
234
|
if (Array.isArray(value)) {
|
|
264
|
-
|
|
265
|
-
return value.some((item) => applyOperator(item, filter));
|
|
235
|
+
return value.some((arrItem) => applyOperator(arrItem, filter));
|
|
266
236
|
}
|
|
267
237
|
if (typeof value === "object" && value !== null) {
|
|
268
|
-
// Eğer obje ise, içindeki değerlerden biri eşleşirse true dön
|
|
269
238
|
return Object.values(value).some((v) => applyOperator(v, filter));
|
|
270
239
|
}
|
|
271
240
|
const text = String(value ?? "").toLocaleLowerCase();
|
|
@@ -291,7 +260,7 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
291
260
|
return false;
|
|
292
261
|
}
|
|
293
262
|
};
|
|
294
|
-
return Object.entries(
|
|
263
|
+
return Object.entries(searchParams).every(([key, param]) => {
|
|
295
264
|
const _itemValue = item[key];
|
|
296
265
|
if (Array.isArray(param)) {
|
|
297
266
|
if (param.length === 0)
|
|
@@ -302,42 +271,10 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
302
271
|
return applyOperator(_itemValue, param);
|
|
303
272
|
}
|
|
304
273
|
});
|
|
305
|
-
// Eğer değer bir sayı veya string ise, aranan metinle eşleşip eşleşmediğini kontrol ediyoruz.
|
|
306
|
-
// return Object.entries(searchedText).every(([key, param]) => {
|
|
307
|
-
// const _itemValue = item[key as keyof typeof item];
|
|
308
|
-
// if (typeof _itemValue === "number" || typeof _itemValue === "string" || typeof _itemValue === "boolean") {
|
|
309
|
-
// if (Array.isArray(param)) {
|
|
310
|
-
// if (param.length === 0) return true;
|
|
311
|
-
// else return param.some((v) => _itemValue.toString().toLocaleLowerCase().includes(v.toLocaleLowerCase()));
|
|
312
|
-
// }
|
|
313
|
-
// return _itemValue
|
|
314
|
-
// .toString()
|
|
315
|
-
// .toLocaleLowerCase()
|
|
316
|
-
// .includes(param.toLocaleLowerCase() ?? "");
|
|
317
|
-
// }
|
|
318
|
-
// if (typeof _itemValue === "object") {
|
|
319
|
-
// if (Array.isArray(param)) {
|
|
320
|
-
// if (param.length === 0) return true;
|
|
321
|
-
// else {
|
|
322
|
-
// return param.some((v) => {
|
|
323
|
-
// if (Array.isArray(_itemValue)) {
|
|
324
|
-
// return Object.values(_itemValue?.[0 as keyof typeof _itemValue] ?? {}).some((objValue) => {
|
|
325
|
-
// return String(objValue).toLocaleLowerCase().includes(String(v).toLocaleLowerCase());
|
|
326
|
-
// });
|
|
327
|
-
// }
|
|
328
|
-
// });
|
|
329
|
-
// }
|
|
330
|
-
// }
|
|
331
|
-
// }
|
|
332
|
-
// if (Array.isArray(_itemValue)) {
|
|
333
|
-
// console.log("Buradasın", _itemValue);
|
|
334
|
-
// }
|
|
335
|
-
// return false;
|
|
336
|
-
// });
|
|
337
274
|
};
|
|
338
|
-
const openAllSubrowsRecursively = (
|
|
275
|
+
const openAllSubrowsRecursively = (targetData, parentKey = "") => {
|
|
339
276
|
let result = {};
|
|
340
|
-
|
|
277
|
+
targetData.forEach((item) => {
|
|
341
278
|
const id = trackBy?.(item);
|
|
342
279
|
const key = parentKey ? `${parentKey}.${id}` : `${id}`;
|
|
343
280
|
const subitems = item[_subrowSelector];
|
|
@@ -360,16 +297,15 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
360
297
|
else {
|
|
361
298
|
setTotalRecords(data.length);
|
|
362
299
|
}
|
|
363
|
-
// Sorting...
|
|
364
300
|
if (sortConfig.length > 0 && !config.isServerSide) {
|
|
365
301
|
_data.sort((a, b) => {
|
|
366
|
-
for (const
|
|
367
|
-
const aValue = a[
|
|
368
|
-
const bValue = b[
|
|
302
|
+
for (const sCfg of sortConfig) {
|
|
303
|
+
const aValue = a[sCfg.key];
|
|
304
|
+
const bValue = b[sCfg.key];
|
|
369
305
|
if (aValue < bValue)
|
|
370
|
-
return
|
|
306
|
+
return sCfg.direction === "asc" ? -1 : 1;
|
|
371
307
|
if (aValue > bValue)
|
|
372
|
-
return
|
|
308
|
+
return sCfg.direction === "asc" ? 1 : -1;
|
|
373
309
|
}
|
|
374
310
|
return 0;
|
|
375
311
|
});
|
|
@@ -379,18 +315,15 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
379
315
|
const indexOfFirstRow = indexOfLastRow - selectedPerPage;
|
|
380
316
|
_data = _data.slice(indexOfFirstRow, indexOfLastRow);
|
|
381
317
|
}
|
|
382
|
-
// Önemli, Data yenilenmesi durumunda sticky alanlar tazelenir.
|
|
383
318
|
setTimeout(() => handleScroll(), 0);
|
|
384
319
|
return _data;
|
|
385
320
|
}, [data, searchedText, currentPage, selectedPerPage, sortConfig, config.isServerSide]);
|
|
386
|
-
// useEffects
|
|
387
321
|
useEffect(() => {
|
|
388
322
|
if (!previousSelections || previousSelections.length === 0) {
|
|
389
323
|
_selectionItems.current = [];
|
|
390
324
|
return;
|
|
391
325
|
}
|
|
392
326
|
const validSelections = data.filter((item) => previousSelections.some((selected) => trackBy?.(selected) === trackBy?.(item)));
|
|
393
|
-
// Gereksiz overwrite’i engelle.
|
|
394
327
|
if (!Utils.DeepEqual(_selectionItems.current, validSelections)) {
|
|
395
328
|
_selectionItems.current = validSelections;
|
|
396
329
|
}
|
|
@@ -411,7 +344,6 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
411
344
|
const searchRecord = {};
|
|
412
345
|
Object.entries(_searchedParams ?? {}).forEach(([key, value]) => {
|
|
413
346
|
if (Array.isArray(value)) {
|
|
414
|
-
// Çoklu filtre değerleri varsa virgülle birleştir.
|
|
415
347
|
searchRecord[key] = value.map((v) => v.value).join(",");
|
|
416
348
|
}
|
|
417
349
|
else if (value && typeof value === "object") {
|
|
@@ -423,9 +355,7 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
423
355
|
const key = column.key;
|
|
424
356
|
const filterValue = _searchedParams?.[key];
|
|
425
357
|
const filterArray = Array.isArray(filterValue) ? filterValue : filterValue ? [filterValue] : [];
|
|
426
|
-
|
|
427
|
-
const searchedParamLength = filterArray.length;
|
|
428
|
-
if (getParamsLength === searchedParamLength) {
|
|
358
|
+
if ((column.filters?.length ?? 0) === filterArray.length) {
|
|
429
359
|
query.delete(column.key);
|
|
430
360
|
}
|
|
431
361
|
});
|
|
@@ -460,40 +390,32 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
460
390
|
}
|
|
461
391
|
}, [selections, trackBy]);
|
|
462
392
|
useEffect(() => {
|
|
463
|
-
// Filter Content alanı re-render işlemi.
|
|
464
393
|
if (filterCurrentColumn && filterCurrentDataType) {
|
|
465
394
|
handleFilterPopupContent(filterCurrentColumn, filterCurrentDataType, filterCurrentIndex);
|
|
466
395
|
}
|
|
467
396
|
}, [checkboxSelectedParams, filterPopupOption, filterPopupOptionSearchText]);
|
|
468
397
|
useLayoutEffect(() => {
|
|
469
|
-
// @DND
|
|
470
398
|
if (!onDnD || !_tBody.current || data.length === 0)
|
|
471
399
|
return;
|
|
472
400
|
_tBody.current.childNodes.forEach((item) => {
|
|
473
401
|
const _item = item;
|
|
474
|
-
// Events
|
|
475
402
|
_item.ondragstart = (event) => {
|
|
476
403
|
const dragItem = event.currentTarget;
|
|
477
404
|
_dragItem.current = dragItem;
|
|
478
405
|
dragItem.classList.add("drag-item");
|
|
479
406
|
if (event.dataTransfer) {
|
|
480
|
-
// 1. Geçici bir kapsayıcı oluştur
|
|
481
407
|
const shadowContainer = document.createElement("div");
|
|
482
408
|
shadowContainer.style.position = "absolute";
|
|
483
409
|
shadowContainer.style.top = "-9999px";
|
|
484
410
|
shadowContainer.style.left = "-9999px";
|
|
485
411
|
document.body.appendChild(shadowContainer);
|
|
486
412
|
if (config.dnd?.renderItem) {
|
|
487
|
-
// 2a. React Node varsa: createRoot ile render et
|
|
488
413
|
const root = createRoot(shadowContainer);
|
|
489
|
-
// flushSync kullanıyoruz çünkü setDragImage çağrılmadan önce
|
|
490
|
-
// DOM'un hemen güncellenmesi gerekiyor.
|
|
491
414
|
flushSync(() => {
|
|
492
415
|
root.render(config.dnd?.renderItem);
|
|
493
416
|
});
|
|
494
417
|
}
|
|
495
418
|
else {
|
|
496
|
-
// 2b. React Node yoksa: Varsayılan HTML string
|
|
497
419
|
shadowContainer.innerHTML = `
|
|
498
420
|
<div class="ar-dnd-shadow" style="background: white; padding: 10px; border: 1px solid #ccc;">
|
|
499
421
|
<i class="bi bi-gear-wide-connected"></i>
|
|
@@ -501,13 +423,11 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
501
423
|
</div>
|
|
502
424
|
`;
|
|
503
425
|
}
|
|
504
|
-
// 3. Tarayıcıya bu elementi sürükleme görseli yapmasını söyle
|
|
505
|
-
// (0, 0) koordinatları mouse'un görselin neresinde duracağını belirler
|
|
506
426
|
event.dataTransfer.setDragImage(shadowContainer, 20, 20);
|
|
507
|
-
// 4. Temizlik: Görsel hafızaya alındıktan sonra DOM'dan kaldırabiliriz
|
|
508
|
-
// Bir sonraki event loop'ta silmek en güvenlisidir
|
|
509
427
|
setTimeout(() => {
|
|
510
|
-
document.body.
|
|
428
|
+
if (document.body.contains(shadowContainer)) {
|
|
429
|
+
document.body.removeChild(shadowContainer);
|
|
430
|
+
}
|
|
511
431
|
}, 0);
|
|
512
432
|
}
|
|
513
433
|
};
|
|
@@ -515,12 +435,10 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
515
435
|
event.preventDefault();
|
|
516
436
|
const overItem = event.currentTarget;
|
|
517
437
|
const rect = overItem.getBoundingClientRect();
|
|
518
|
-
// Otomatik scroll.
|
|
519
438
|
if (rect.top < 250)
|
|
520
439
|
window.scrollBy(0, -20);
|
|
521
440
|
if (rect.bottom > window.innerHeight - 150)
|
|
522
441
|
window.scrollBy(0, 20);
|
|
523
|
-
// Gerçek taşıma işlemi.
|
|
524
442
|
if (_dragItem.current !== overItem) {
|
|
525
443
|
if (_tBody.current && _dragItem.current) {
|
|
526
444
|
const dragItemIndex = [..._tBody.current.children].indexOf(_dragItem.current);
|
|
@@ -537,13 +455,13 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
537
455
|
}
|
|
538
456
|
};
|
|
539
457
|
_item.ondragend = (event) => {
|
|
540
|
-
const
|
|
541
|
-
|
|
542
|
-
|
|
458
|
+
const dragEndItem = event.currentTarget;
|
|
459
|
+
dragEndItem.classList.remove("drag-item");
|
|
460
|
+
dragEndItem.classList.add("end-item");
|
|
543
461
|
setTimeout(() => {
|
|
544
|
-
|
|
545
|
-
if (
|
|
546
|
-
|
|
462
|
+
dragEndItem.classList.remove("end-item");
|
|
463
|
+
if (dragEndItem.classList.length === 0)
|
|
464
|
+
dragEndItem.removeAttribute("class");
|
|
547
465
|
}, 1000);
|
|
548
466
|
};
|
|
549
467
|
});
|
|
@@ -552,14 +470,14 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
552
470
|
if (!_tBody.current)
|
|
553
471
|
return;
|
|
554
472
|
_tBody.current.childNodes.forEach((item) => {
|
|
555
|
-
const
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
473
|
+
const cleanupItem = item;
|
|
474
|
+
cleanupItem.ondragstart = null;
|
|
475
|
+
cleanupItem.ondragover = null;
|
|
476
|
+
cleanupItem.ondragend = null;
|
|
559
477
|
});
|
|
560
478
|
_tBody.current.ondragover = null;
|
|
561
479
|
};
|
|
562
|
-
}, [data]);
|
|
480
|
+
}, [data, onDnD]);
|
|
563
481
|
useLayoutEffect(() => {
|
|
564
482
|
if (!pagination?.currentPage)
|
|
565
483
|
return;
|
|
@@ -590,6 +508,8 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
590
508
|
}
|
|
591
509
|
return () => {
|
|
592
510
|
window.removeEventListener("resize", handleResize);
|
|
511
|
+
if (_searchTimeOut.current)
|
|
512
|
+
clearTimeout(_searchTimeOut.current);
|
|
593
513
|
};
|
|
594
514
|
}, []);
|
|
595
515
|
const filterOption = [
|
|
@@ -613,71 +533,53 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
613
533
|
if (_checkboxItems.current.length > 0) {
|
|
614
534
|
setSelectAll(event.target.checked);
|
|
615
535
|
_checkboxItems.current.forEach((item) => {
|
|
616
|
-
if (item)
|
|
617
|
-
|
|
618
|
-
item.click();
|
|
619
|
-
}
|
|
536
|
+
if (item && item.checked !== event.target.checked)
|
|
537
|
+
item.click();
|
|
620
538
|
});
|
|
621
539
|
}
|
|
622
540
|
} }))),
|
|
623
541
|
data.some((item) => _subrowSelector in item) && _subrowButton && (React.createElement("th", { className: "subrow-col sticky sticky-left", "data-sticky-position": "left", style: { bottom: 0 } })),
|
|
624
|
-
React.createElement(THeadCell, { refs: {
|
|
625
|
-
propertiesButton: _propertiesButton,
|
|
626
|
-
}, states: {
|
|
542
|
+
React.createElement(THeadCell, { refs: { propertiesButton: _propertiesButton }, states: {
|
|
627
543
|
open: { get: openProperties, set: setOpenProperties },
|
|
628
544
|
sort: { get: sortConfig, set: setSortConfig },
|
|
629
545
|
sortCurrentColumn: { set: setSortCurrentColumn },
|
|
630
546
|
propertiesButtonCoordinate: { set: setPropertiesButtonCoordinate },
|
|
631
547
|
}, methods: { handleScroll }, columns: columns, config: config })),
|
|
632
548
|
config?.isSearchable && (React.createElement("tr", { key: "isSearchable" },
|
|
633
|
-
selections &&
|
|
634
|
-
data.some((item) => _subrowSelector in item) && _subrowButton && (React.createElement("th", {
|
|
549
|
+
selections && React.createElement("th", { className: "selection-col sticky-left", "data-sticky-position": "left" }),
|
|
550
|
+
data.some((item) => _subrowSelector in item) && _subrowButton && (React.createElement("th", { className: "subrow-col sticky sticky-left", "data-sticky-position": "left" })),
|
|
635
551
|
columns.map((c, cIndex) => {
|
|
636
552
|
let _className = [];
|
|
637
553
|
const key = typeof c.key !== "object" ? String(c.key) : String(c.key.field);
|
|
638
554
|
const csrValue = Array.isArray(searchedText?.[key])
|
|
639
|
-
? ""
|
|
555
|
+
? ""
|
|
640
556
|
: searchedText?.[key]?.value;
|
|
641
557
|
const ssrValue = Array.isArray(_searchedParams?.[key])
|
|
642
|
-
? ""
|
|
558
|
+
? ""
|
|
643
559
|
: _searchedParams?.[key]?.value;
|
|
644
560
|
if (c.config?.sticky)
|
|
645
561
|
_className.push(`sticky-${c.config.sticky}`);
|
|
646
|
-
if (c.config?.alignContent)
|
|
562
|
+
if (c.config?.alignContent)
|
|
647
563
|
_className.push(`align-content-${c.config.alignContent}`);
|
|
648
|
-
}
|
|
649
|
-
return (React.createElement("th", { key: `column-${cIndex}`, ...(_className.length > 0 && {
|
|
650
|
-
className: `${_className.map((c) => c).join(" ")}`,
|
|
651
|
-
}), ...(c.config?.sticky && {
|
|
652
|
-
"data-sticky-position": c.config.sticky,
|
|
653
|
-
}) }, c.key && (React.createElement("div", { className: "filter-field" }, c.filterDataType === "date" ? (React.createElement(DatePicker, { value: (config.isServerSide ? ssrValue : csrValue) ?? "", name: key, onClick: () => {
|
|
654
|
-
handleScroll();
|
|
655
|
-
}, onChange: (value) => handleSearch(key, value, c.filterDataType), style: { height: "2rem" }, config: { isClock: true, isFooterButton: true, locale: config.locale }, disabled: !c.key || !!c.filters })) : (React.createElement(React.Fragment, null,
|
|
564
|
+
return (React.createElement("th", { key: `column-search-${cIndex}`, ...(_className.length > 0 && { className: `${_className.join(" ")}` }), ...(c.config?.sticky && { "data-sticky-position": c.config.sticky }) }, c.key && (React.createElement("div", { className: "filter-field" }, c.filterDataType === "date" ? (React.createElement(DatePicker, { value: (config.isServerSide ? ssrValue : csrValue) ?? "", name: key, onClick: () => handleScroll(), onChange: (value) => handleSearch(key, value, c.filterDataType), style: { height: "2rem" }, config: { isClock: true, isFooterButton: true, locale: config.locale }, disabled: !c.key || !!c.filters })) : (React.createElement(React.Fragment, null,
|
|
656
565
|
React.createElement(Input, { ref: (element) => {
|
|
657
|
-
if (
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
}, variant: c.key && !c.filters ? "outlined" : "filled", style: { height: "2rem" }, value: (config.isServerSide ? ssrValue : csrValue) ?? "", name: key, onClick: () => {
|
|
661
|
-
handleScroll();
|
|
662
|
-
}, onInput: (event) => handleSearch(event.currentTarget.name, event.currentTarget.value), disabled: !c.key || !!c.filters }),
|
|
566
|
+
if (element)
|
|
567
|
+
_searchTextInputs.current[cIndex] = element;
|
|
568
|
+
}, variant: c.key && !c.filters ? "outlined" : "filled", style: { height: "2rem" }, value: (config.isServerSide ? ssrValue : csrValue) ?? "", name: key, onClick: () => handleScroll(), onInput: (event) => handleSearch(event.currentTarget.name, event.currentTarget.value), disabled: !c.key || !!c.filters }),
|
|
663
569
|
React.createElement("span", { ref: (element) => {
|
|
664
|
-
if (
|
|
665
|
-
|
|
666
|
-
_filterButton.current[cIndex] = element;
|
|
570
|
+
if (element)
|
|
571
|
+
_filterButton.current[cIndex] = element;
|
|
667
572
|
}, onClick: (event) => {
|
|
668
573
|
event.preventDefault();
|
|
669
574
|
event.stopPropagation();
|
|
670
|
-
// Temizlik...
|
|
671
575
|
setFilterPopupOptionSearchText("");
|
|
672
576
|
const rect = event.currentTarget.getBoundingClientRect();
|
|
673
577
|
const screenCenterX = window.innerWidth / 2;
|
|
674
|
-
// const screenCenterY = window.innerHeight / 2;
|
|
675
578
|
const coordinateX = rect.x > screenCenterX ? rect.x + rect.width - 225 : rect.x;
|
|
676
579
|
const coordinateY = rect.y + rect.height;
|
|
677
|
-
// data içindeki alanların tiplerini bulmak için kullanılmaktadır
|
|
678
580
|
const getDataFirstItem = { ...data[0] };
|
|
679
|
-
const
|
|
680
|
-
const getValueByKey = getDataFirstItem[
|
|
581
|
+
const searchKey = typeof c.key !== "object" ? String(c.key) : String(c.key.field);
|
|
582
|
+
const getValueByKey = getDataFirstItem[searchKey];
|
|
681
583
|
let dataType = typeof getValueByKey;
|
|
682
584
|
if (getValueByKey == null)
|
|
683
585
|
dataType = "string";
|
|
@@ -705,29 +607,20 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
705
607
|
onEditable: onEditable,
|
|
706
608
|
rowBackgroundColor: rowBackgroundColor,
|
|
707
609
|
}, config: config })))),
|
|
708
|
-
React.createElement(FilterPopup, { refs: {
|
|
709
|
-
|
|
710
|
-
buttons: _filterButton,
|
|
711
|
-
}, states: {
|
|
712
|
-
open: { get: openFilter, set: setOpenFilter },
|
|
713
|
-
}, coordinate: filterButtonCoordinate }, filterPopupContent),
|
|
714
|
-
config.isProperties && (React.createElement(PropertiesPopup, { refs: {
|
|
715
|
-
tableContent: _tableContent,
|
|
716
|
-
buttons: _propertiesButton,
|
|
717
|
-
}, states: {
|
|
610
|
+
React.createElement(FilterPopup, { refs: { tableContent: _tableContent, buttons: _filterButton }, states: { open: { get: openFilter, set: setOpenFilter } }, coordinate: filterButtonCoordinate }, filterPopupContent),
|
|
611
|
+
config.isProperties && (React.createElement(PropertiesPopup, { refs: { tableContent: _tableContent, buttons: _propertiesButton }, states: {
|
|
718
612
|
open: { get: openProperties, set: setOpenProperties },
|
|
719
613
|
sort: { get: sortConfig, set: setSortConfig, currentColumn: sortCurrentColumn },
|
|
720
614
|
}, methods: { handleScroll }, coordinate: propertiesButtonCoordinate, config: config })),
|
|
721
615
|
React.createElement("div", { className: "footer" },
|
|
722
|
-
React.createElement("span", null, isMobile ? (React.createElement(
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
pagination?.totalRecords || getData.length))) : (t("Table.Pagination.Information.Text", (currentPage - 1) * selectedPerPage + 1, Math.min(currentPage * selectedPerPage, pagination?.totalRecords || getData.length), pagination?.totalRecords || getData.length))),
|
|
616
|
+
React.createElement("span", null, isMobile ? (React.createElement("strong", null,
|
|
617
|
+
(currentPage - 1) * selectedPerPage + 1,
|
|
618
|
+
" -",
|
|
619
|
+
" ",
|
|
620
|
+
Math.min(currentPage * selectedPerPage, pagination?.totalRecords || getData.length),
|
|
621
|
+
" of",
|
|
622
|
+
" ",
|
|
623
|
+
pagination?.totalRecords || getData.length)) : (t("Table.Pagination.Information.Text", (currentPage - 1) * selectedPerPage + 1, Math.min(currentPage * selectedPerPage, pagination?.totalRecords || getData.length), pagination?.totalRecords || getData.length))),
|
|
731
624
|
pagination && (React.createElement(Pagination, { totalRecords: config.isServerSide ? pagination.totalRecords : (totalRecords ?? 0), currentPage: currentPage, perPage: selectedPerPage, onChange: (currentPage, perPage) => {
|
|
732
625
|
setCurrentPage(currentPage);
|
|
733
626
|
setSelectedPerPage(perPage);
|
|
@@ -15,6 +15,7 @@ const Popover = ({ children, title, message, content, onConfirm, windowBlur, ful
|
|
|
15
15
|
_arPopoverClassName.push("full-width");
|
|
16
16
|
// states
|
|
17
17
|
const [open, setOpen] = useState(false);
|
|
18
|
+
const [mounted, setMounted] = useState(false);
|
|
18
19
|
// methods
|
|
19
20
|
const handleClickOutSide = (event) => {
|
|
20
21
|
const target = event.target;
|
|
@@ -64,8 +65,13 @@ const Popover = ({ children, title, message, content, onConfirm, windowBlur, ful
|
|
|
64
65
|
document.removeEventListener("keydown", handleKeys);
|
|
65
66
|
};
|
|
66
67
|
}, [open]);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
setMounted(true);
|
|
70
|
+
return () => setMounted(false);
|
|
71
|
+
}, []);
|
|
67
72
|
return (React.createElement("div", { ref: _arPopoverWrapper, className: _arPopoverClassName.map((c) => c).join(" "), role: "dialog" },
|
|
68
73
|
open &&
|
|
74
|
+
mounted &&
|
|
69
75
|
ReactDOM.createPortal(React.createElement("div", { ref: _arPopover, className: "ar-popover" },
|
|
70
76
|
title && (React.createElement("div", { className: "title" },
|
|
71
77
|
React.createElement(Title, { Level: "h4" }, title))),
|