ar-design 0.2.50 → 0.2.52
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.
|
@@ -136,6 +136,7 @@
|
|
|
136
136
|
border-bottom: none;
|
|
137
137
|
}
|
|
138
138
|
.ar-table > .content > table > tbody > tr > td {
|
|
139
|
+
position: relative;
|
|
139
140
|
z-index: 1;
|
|
140
141
|
}
|
|
141
142
|
.ar-table > .content > table > tbody > tr > td.type-of-number {
|
|
@@ -153,7 +154,6 @@
|
|
|
153
154
|
justify-content: flex-end;
|
|
154
155
|
align-items: center;
|
|
155
156
|
}
|
|
156
|
-
|
|
157
157
|
.ar-table > .content > table > tbody > tr > td.text-wrap {
|
|
158
158
|
text-wrap: wrap;
|
|
159
159
|
}
|
|
@@ -184,4 +184,50 @@
|
|
|
184
184
|
cursor: no-drop;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
+
.ar-table > .content > table > tbody > tr.subrow-item {
|
|
188
|
+
background-color: rgba(var(--warning-rgb), 0.1);
|
|
189
|
+
border-bottom: solid 1px rgba(var(--warning-rgb), 0.35);
|
|
190
|
+
}
|
|
191
|
+
.ar-table > .content > table > tbody > tr.subrow-item:last-child {
|
|
192
|
+
background-color: rgba(var(--warning-rgb), 0.1);
|
|
193
|
+
border-bottom: none;
|
|
194
|
+
}
|
|
195
|
+
.ar-table > .content > table > tbody > tr.subrow-item.type-a > td:nth-child(1)::before {
|
|
196
|
+
position: absolute;
|
|
197
|
+
top: 0;
|
|
198
|
+
left: 0;
|
|
199
|
+
content: "";
|
|
200
|
+
background-color: rgba(var(--warning-rgb), 0.35);
|
|
201
|
+
width: 2px;
|
|
202
|
+
height: 100%;
|
|
203
|
+
}
|
|
204
|
+
.ar-table > .content > table > tbody > tr.subrow-item.type-a > td:nth-child(1)::after {
|
|
205
|
+
position: absolute;
|
|
206
|
+
top: 50%;
|
|
207
|
+
left: 2px;
|
|
208
|
+
content: "";
|
|
209
|
+
background-color: rgba(var(--warning-rgb), 0.35);
|
|
210
|
+
width: 25px;
|
|
211
|
+
height: 2px;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.ar-table > .content > table > tbody > tr.subrow-item.type-b > td:nth-child(2)::before {
|
|
215
|
+
position: absolute;
|
|
216
|
+
top: 0;
|
|
217
|
+
left: 0;
|
|
218
|
+
content: "";
|
|
219
|
+
background-color: rgba(var(--warning-rgb), 0.35);
|
|
220
|
+
width: 2px;
|
|
221
|
+
height: 100%;
|
|
222
|
+
}
|
|
223
|
+
.ar-table > .content > table > tbody > tr.subrow-item.type-b > td:nth-child(2)::after {
|
|
224
|
+
position: absolute;
|
|
225
|
+
top: 50%;
|
|
226
|
+
left: 2px;
|
|
227
|
+
content: "";
|
|
228
|
+
background-color: rgba(var(--warning-rgb), 0.35);
|
|
229
|
+
width: 25px;
|
|
230
|
+
height: 2px;
|
|
231
|
+
}
|
|
232
|
+
|
|
187
233
|
@import url("./scroll.css");
|
|
@@ -21,7 +21,7 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
|
|
|
21
21
|
// variables
|
|
22
22
|
const _subrowOpenAutomatically = config.subrow?.openAutomatically ?? false;
|
|
23
23
|
const _subrowSelector = config.subrow?.selector ?? "subitems";
|
|
24
|
-
const _subrowButton = config.subrow?.button ??
|
|
24
|
+
const _subrowButton = config.subrow?.button ?? true;
|
|
25
25
|
// className
|
|
26
26
|
const _tableClassName = ["ar-table", "scroll"];
|
|
27
27
|
// states
|
|
@@ -217,6 +217,28 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
|
|
|
217
217
|
setTimeout(() => handleScroll(), 0);
|
|
218
218
|
return _data;
|
|
219
219
|
}, [data, searchedText, currentPage]);
|
|
220
|
+
const renderRow = (item, index) => {
|
|
221
|
+
const isHasSubitems = _subrowSelector in item;
|
|
222
|
+
// TODO: Keylere bakılacak...
|
|
223
|
+
return (React.createElement(Fragment, { key: `row-${index}` },
|
|
224
|
+
React.createElement("tr", { key: `row-${index}` },
|
|
225
|
+
selections && (React.createElement("td", { className: "sticky-left", "data-sticky-position": "left" },
|
|
226
|
+
React.createElement(Checkbox, { ref: (element) => (_checkboxItems.current[index] = element), status: "primary", checked: selectionItems.some((selectionItem) => JSON.stringify(selectionItem) === JSON.stringify(item)), onChange: (event) => {
|
|
227
|
+
if (event.target.checked)
|
|
228
|
+
setSelectionItems((prev) => [...prev, item]);
|
|
229
|
+
else
|
|
230
|
+
setSelectionItems((prev) => prev.filter((_item) => _item !== item));
|
|
231
|
+
} }))),
|
|
232
|
+
_subrowButton && isHasSubitems ? (React.createElement("td", null, item[_subrowSelector] && (React.createElement("div", { className: "subitem-open-button-wrapper" },
|
|
233
|
+
React.createElement("span", { className: `subitem-open-button ${(showSubitems[index] && "opened") ?? ""}`, onClick: () => {
|
|
234
|
+
setShowSubitems((prev) => ({
|
|
235
|
+
...prev,
|
|
236
|
+
[`${index}`]: !prev[`${index}`],
|
|
237
|
+
}));
|
|
238
|
+
} }))))) : _subrowButton ? (React.createElement("td", { style: { width: 0, minWidth: 0 } })) : null,
|
|
239
|
+
columns.map((c, cIndex) => renderCell(item, c, cIndex, index, 0))),
|
|
240
|
+
showSubitems[index] && item[_subrowSelector] && (React.createElement(SubitemList, { items: item[_subrowSelector], columns: columns, index: index, depth: 1.5 }))));
|
|
241
|
+
};
|
|
220
242
|
const renderCell = (item, c, cIndex, index, depth) => {
|
|
221
243
|
let render;
|
|
222
244
|
// `c.key` bir string ise
|
|
@@ -241,38 +263,16 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
|
|
|
241
263
|
_className.push(`align-content-${c.config.alignContent}`);
|
|
242
264
|
if (c.config?.textWrap)
|
|
243
265
|
_className.push(`text-${c.config.textWrap}`);
|
|
244
|
-
return (React.createElement("td", { key: `cell-${index}-${cIndex}`, className: _className.join(" "), style: c.config?.width ? { minWidth: c.config.width, maxWidth: c.config.width
|
|
245
|
-
React.createElement("div", { className: "table-cell" }, React.isValidElement(render) ? render : String(render))));
|
|
246
|
-
};
|
|
247
|
-
const renderRow = (item, index) => {
|
|
248
|
-
const isHasSubitems = _subrowSelector in item;
|
|
249
|
-
// TODO: Keylere bakılacak...
|
|
250
|
-
return (React.createElement(Fragment, { key: `row-${index}` },
|
|
251
|
-
React.createElement("tr", { key: `row-${index}` },
|
|
252
|
-
selections && (React.createElement("td", { className: "sticky-left", "data-sticky-position": "left" },
|
|
253
|
-
React.createElement(Checkbox, { ref: (element) => (_checkboxItems.current[index] = element), status: "primary", checked: selectionItems.some((selectionItem) => JSON.stringify(selectionItem) === JSON.stringify(item)), onChange: (event) => {
|
|
254
|
-
if (event.target.checked)
|
|
255
|
-
setSelectionItems((prev) => [...prev, item]);
|
|
256
|
-
else
|
|
257
|
-
setSelectionItems((prev) => prev.filter((_item) => _item !== item));
|
|
258
|
-
} }))),
|
|
259
|
-
_subrowButton && isHasSubitems ? (React.createElement("td", null, item[_subrowSelector] && (React.createElement("div", { className: "subitem-open-button-wrapper" },
|
|
260
|
-
React.createElement("span", { className: `subitem-open-button ${(showSubitems[index] && "opened") ?? ""}`, onClick: () => {
|
|
261
|
-
setShowSubitems((prev) => ({
|
|
262
|
-
...prev,
|
|
263
|
-
[`${index}`]: !prev[`${index}`],
|
|
264
|
-
}));
|
|
265
|
-
} }))))) : _subrowButton ? (React.createElement("td", { style: { width: 0, minWidth: 0 } })) : null,
|
|
266
|
-
columns.map((c, cIndex) => renderCell(item, c, cIndex, index, 0))),
|
|
267
|
-
showSubitems[index] && item[_subrowSelector] && (React.createElement(SubitemList, { items: item[_subrowSelector], columns: columns, index: index, depth: 1.5 }))));
|
|
266
|
+
return (React.createElement("td", { key: `cell-${index}-${cIndex}`, className: _className.join(" "), style: c.config?.width ? { minWidth: c.config.width, maxWidth: c.config.width } : {}, "data-sticky-position": c.config?.sticky },
|
|
267
|
+
React.createElement("div", { style: { paddingLeft: `${depth == 0 ? 1 : depth}rem` }, className: "table-cell" }, React.isValidElement(render) ? render : String(render))));
|
|
268
268
|
};
|
|
269
269
|
const SubitemList = ({ items, columns, index, depth }) => {
|
|
270
270
|
return items.map((subitem, subindex) => {
|
|
271
271
|
const _subitem = subitem[_subrowSelector];
|
|
272
272
|
// TODO: Keylere bakılacak...
|
|
273
273
|
return (React.createElement(Fragment, { key: `subitem-${index}-${subindex}-${Math.random()}` },
|
|
274
|
-
React.createElement("tr", { key: `subitem-${index}-${subindex}-${Math.random()}` },
|
|
275
|
-
_subrowSelector in subitem && _subrowButton
|
|
274
|
+
React.createElement("tr", { key: `subitem-${index}-${subindex}-${Math.random()}`, className: `subrow-item ${_subrowButton ? "type-b" : "type-a"}` },
|
|
275
|
+
_subrowSelector in subitem && _subrowButton ? (React.createElement("td", null,
|
|
276
276
|
React.createElement("div", { className: "subitem-open-button-wrapper" },
|
|
277
277
|
React.createElement("span", { className: `${(showSubitems[`${index}.${subindex}`] && "opened") ?? ""} ${!_subitem && "passive"}`, onClick: () => {
|
|
278
278
|
if (!_subitem)
|
|
@@ -281,7 +281,7 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
|
|
|
281
281
|
...prev,
|
|
282
282
|
[`${index}.${subindex}`]: !prev[`${index}.${subindex}`],
|
|
283
283
|
}));
|
|
284
|
-
} })))),
|
|
284
|
+
} })))) : _subrowButton ? (React.createElement("td", { style: { width: 0, minWidth: 0 } })) : null,
|
|
285
285
|
columns.map((c, cIndex) => renderCell(subitem, c, cIndex, subindex, depth * 1.5))),
|
|
286
286
|
showSubitems[`${index}.${subindex}`] && _subitem && (React.createElement(SubitemList, { key: `subitem-${index}-${subindex}-${Math.random()}`, items: _subitem, columns: columns, index: subindex, depth: depth * 1.5 }))));
|
|
287
287
|
});
|