ar-design 0.2.70 → 0.2.71

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.
@@ -186,18 +186,68 @@
186
186
  cursor: no-drop;
187
187
  }
188
188
 
189
+ /* For Rows */
190
+ .ar-table > .content > table > tbody > tr > td > .table-cell > .before {
191
+ position: absolute;
192
+ top: 0px;
193
+ content: "";
194
+ background: linear-gradient(0deg, var(--gray-200) 0%, var(--primary) 50%, var(--gray-200) 100%);
195
+ width: 2px;
196
+ height: 100%;
197
+ margin-left: -17.5px;
198
+ }
199
+ .ar-table > .content > table > tbody > tr:not(:has(+ tr)) > td > .table-cell > .before,
200
+ .ar-table > .content > table > tbody > tr:last-child > td > .table-cell > .before {
201
+ height: 50%;
202
+ background: linear-gradient(0deg, var(--gray-600) 0%, var(--gray-200) 100%);
203
+ }
204
+ .ar-table > .content > table > tbody > tr > td > .table-cell > .after {
205
+ position: absolute;
206
+ top: 50%;
207
+ transform: translateY(-50%);
208
+ content: "";
209
+ background-color: var(--primary);
210
+ width: 15px;
211
+ height: 2px;
212
+ margin-left: -17.5px;
213
+ }
214
+ .ar-table > .content > table > tbody > tr > td > .table-cell > .after > .circle {
215
+ position: absolute;
216
+ top: 50%;
217
+ transform: translateY(-50%);
218
+ right: 0;
219
+ content: "";
220
+ background-color: var(--primary);
221
+ width: 5px;
222
+ height: 5px;
223
+ border-radius: var(--border-radius-pill);
224
+ }
225
+
226
+ /* For Subrows */
189
227
  .ar-table > .content > table > tbody > tr.subrow-item > td > .table-cell > .before {
190
228
  position: absolute;
191
229
  top: 0px;
192
230
  content: "";
193
- background-color: var(--gray-600);
231
+ background: linear-gradient(0deg, var(--gray-200) 0%, var(--gray-600) 50%, var(--gray-200) 100%) !important;
194
232
  width: 2px;
195
233
  height: 100%;
196
234
  margin-left: -17.5px;
197
235
  }
236
+ .ar-table > .content > table > tbody > tr.subrow-item > td > .table-cell > .last-before {
237
+ position: absolute;
238
+ top: 0px;
239
+ content: "";
240
+ background: linear-gradient(0deg, var(--gray-200) 0%, var(--gray-600) 50%, var(--gray-200) 100%) !important;
241
+ width: 2px;
242
+ height: 100%;
243
+ }
244
+ .ar-table > .content > table > tbody > tr.subrow-item > td > .table-cell > .last-before:first-child {
245
+ background: linear-gradient(0deg, var(--gray-200) 0%, var(--primary) 50%, var(--gray-200) 100%) !important;
246
+ }
198
247
  .ar-table > .content > table > tbody > tr.subrow-item:not(:has(+ tr.subrow-item)) > td > .table-cell > .before,
199
248
  .ar-table > .content > table > tbody > tr.subrow-item:last-child > td > .table-cell > .before {
200
249
  height: 50%;
250
+ background: linear-gradient(0deg, var(--gray-600) 0%, var(--gray-200) 100%) !important;
201
251
  }
202
252
  .ar-table > .content > table > tbody > tr.subrow-item > td > .table-cell > .after {
203
253
  position: absolute;
@@ -209,6 +259,17 @@
209
259
  height: 2px;
210
260
  margin-left: -17.5px;
211
261
  }
262
+ .ar-table > .content > table > tbody > tr.subrow-item > td > .table-cell > .after > .circle {
263
+ position: absolute;
264
+ top: 50%;
265
+ transform: translateY(-50%);
266
+ right: 0;
267
+ content: "";
268
+ background-color: var(--gray-600);
269
+ width: 5px;
270
+ height: 5px;
271
+ border-radius: var(--border-radius-pill);
272
+ }
212
273
 
213
274
  @import url("./scroll.css");
214
275
  @import url("./filter-popup.css");
@@ -51,6 +51,7 @@ export type Config = {
51
51
  */
52
52
  button?: boolean;
53
53
  };
54
+ isTreeView?: boolean;
54
55
  };
55
56
  type ImportActionType = {
56
57
  /**
@@ -22,6 +22,6 @@ const MemoizedTHeadCell = function ({ columns }) {
22
22
  React.createElement("span", { style: { fontWeight: 500 } }, c.title)));
23
23
  })));
24
24
  };
25
- // 👇 React.memo kullanımı sırasında generic tipi koruyoruz
25
+ // React.memo kullanımı sırasında generic tipi koruyoruz.
26
26
  const THeadCell = React.memo(MemoizedTHeadCell);
27
27
  export default THeadCell;
@@ -341,7 +341,7 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
341
341
  setTimeout(() => handleScroll(), 0);
342
342
  return _data;
343
343
  }, [data, searchedText, currentPage]);
344
- const renderRow = (item, index) => {
344
+ const renderRow = (item, index, deph) => {
345
345
  const isHasSubitems = _subrowSelector in item;
346
346
  // TODO: Keylere bakılacak...
347
347
  return (React.createElement(Fragment, { key: `row-${index}` },
@@ -360,10 +360,10 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
360
360
  [`${index}`]: !prev[`${index}`],
361
361
  }));
362
362
  } }))))) : isHasSubitems && _subrowButton ? (React.createElement("td", { style: { width: 0, minWidth: 0 } })) : null,
363
- columns.map((c, cIndex) => renderCell(item, c, cIndex, index, 0))),
363
+ columns.map((c, cIndex) => renderCell(item, c, cIndex, index, deph * (config.isTreeView ? 1.75 : 0), 0))),
364
364
  showSubitems[index] && item[_subrowSelector] && (React.createElement(SubitemList, { items: item[_subrowSelector], columns: columns, index: index, depth: 1.5 }))));
365
365
  };
366
- const renderCell = (item, c, cIndex, index, depth) => {
366
+ const renderCell = (item, c, cIndex, index, depth, level, isSubrows = false) => {
367
367
  let render;
368
368
  // `c.key` bir string ise
369
369
  if (typeof c.key !== "object") {
@@ -387,20 +387,28 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
387
387
  _className.push(`align-content-${c.config.alignContent}`);
388
388
  if (c.config?.textWrap)
389
389
  _className.push(`text-${c.config.textWrap}`);
390
+ console.log(depth);
390
391
  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 },
391
392
  React.createElement("div", { style: { paddingLeft: `${depth == 0 ? 1 : depth}rem` }, className: "table-cell" },
392
- cIndex === 0 && React.createElement("div", { className: "before" }),
393
+ config.isTreeView && cIndex === 0 && (React.createElement(React.Fragment, null,
394
+ isSubrows &&
395
+ Array.from({ length: level }).map((_, i) => {
396
+ if (i > 0)
397
+ i *= 1.655;
398
+ return (React.createElement("div", { key: `last-before-${i}`, style: { left: `${i + 0.65}rem` }, className: "last-before" }));
399
+ }),
400
+ React.createElement("div", { className: "before" }))),
393
401
  React.isValidElement(render) ? render : String(render),
394
- cIndex === 0 && React.createElement("div", { className: "after" }))));
402
+ config.isTreeView && cIndex === 0 && (React.createElement("div", { className: "after" },
403
+ React.createElement("div", { className: "circle" }))))));
395
404
  };
396
- const SubitemList = ({ items, columns, index, depth }) => {
405
+ const SubitemList = ({ items, columns, index, depth, level = 1 }) => {
397
406
  return items.map((subitem, subindex) => {
398
407
  const _subitem = subitem[_subrowSelector];
399
408
  const isHasSubitems = _subrowSelector in subitem;
400
- console.log(isHasSubitems);
401
409
  // TODO: Keylere bakılacak...
402
410
  return (React.createElement(Fragment, { key: `subitem-${index}-${subindex}-${Math.random()}` },
403
- React.createElement("tr", { key: `subitem-${index}-${subindex}-${Math.random()}`, className: `subrow-item ${_subrowButton ? "type-b" : "type-a"}` },
411
+ React.createElement("tr", { key: `subitem-${index}-${subindex}-${Math.random()}`, className: `subrow-item ${_subrowButton ? "type-b" : "type-a"}`, "data-level": level },
404
412
  isHasSubitems && _subrowButton ? (React.createElement("td", null,
405
413
  React.createElement("div", { className: "subitem-open-button-wrapper" },
406
414
  React.createElement("span", { className: `${(showSubitems[`${index}.${subindex}`] && "opened") ?? ""} ${!_subitem && "passive"}`, onClick: () => {
@@ -411,8 +419,8 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
411
419
  [`${index}.${subindex}`]: !prev[`${index}.${subindex}`],
412
420
  }));
413
421
  } })))) : !isHasSubitems && _subrowButton ? (React.createElement("td", { style: { width: 0, minWidth: 0 } })) : null,
414
- columns.map((c, cIndex) => renderCell(subitem, c, cIndex, subindex, depth * 1.75))),
415
- showSubitems[`${index}.${subindex}`] && _subitem && (React.createElement(SubitemList, { key: `subitem-${index}-${subindex}-${Math.random()}`, items: _subitem, columns: columns, index: subindex, depth: depth * 1.5 }))));
422
+ columns.map((c, cIndex) => renderCell(subitem, c, cIndex, subindex, depth * (config.isTreeView ? 2.25 : 1.75), level, true))),
423
+ showSubitems[`${index}.${subindex}`] && _subitem && (React.createElement(SubitemList, { key: `subitem-${index}-${subindex}-${Math.random()}`, items: _subitem, columns: columns, index: subindex, depth: depth + 0.75, level: level + 1 }))));
416
424
  });
417
425
  };
418
426
  // useEffects
@@ -571,7 +579,7 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
571
579
  element: (React.createElement(ARIcon, { viewBox: "0 0 16 16", size: 24, icon: "Filter", fill: "var(--dark)", strokeWidth: 0 })),
572
580
  } }))))));
573
581
  })))),
574
- React.createElement("tbody", null, getData.map((item, index) => (React.createElement(React.Fragment, { key: index }, renderRow(item, index))))))),
582
+ React.createElement("tbody", null, getData.map((item, index) => (React.createElement(React.Fragment, { key: index }, renderRow(item, index, 1))))))),
575
583
  React.createElement(FilterPopup, { tableContent: _tableContent, coordinate: filterButtonCoordinate, buttons: _filterButton }, filterPopupContent),
576
584
  pagination && pagination.totalRecords > pagination.perPage && (React.createElement("div", { className: "footer" },
577
585
  React.createElement("span", null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.2.70",
3
+ "version": "0.2.71",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",