ar-design 0.4.61 → 0.4.62

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.
@@ -82,6 +82,7 @@ interface IProps<T extends object> extends IChildren {
82
82
  actions?: Actions;
83
83
  rowBackgroundColor?: (item: T) => string;
84
84
  selections?: (selectionItems: T[]) => void;
85
+ selectionDisabled?: (item: T) => boolean;
85
86
  previousSelections?: T[];
86
87
  sortedParams?: (params: Sort<T>[], query: string) => void;
87
88
  searchedParams?: (params: SearchedParam | null, query: string, operator: FilterOperator) => void;
@@ -1,11 +1,12 @@
1
1
  "use client";
2
- import React, { useEffect, useState } from "react";
2
+ import React, { useCallback, useEffect, useState } from "react";
3
3
  import Input from "../../../form/input";
4
4
  import DatePicker from "../../../form/date-picker";
5
5
  import Select from "../../../form/select";
6
6
  import { ExtractKey } from "../Helpers";
7
7
  import Checkbox from "../../../form/checkbox";
8
8
  const Editable = function ({ c, item, trackByValue, onEditable, config }) {
9
+ // refs
9
10
  // variables
10
11
  const key = c.key;
11
12
  const itemValue = item[c.key];
@@ -17,15 +18,20 @@ const Editable = function ({ c, item, trackByValue, onEditable, config }) {
17
18
  const _vText = validation?.errors?.[`${c.key}_${trackByValue}`];
18
19
  // states
19
20
  const [_value, setValue] = useState(itemValue);
21
+ // methods
22
+ const handleChange = useCallback((value, set = true) => {
23
+ if (set)
24
+ setValue(value);
25
+ onEditable({ ...item, [key]: value }, trackByValue, ExtractKey(c.key));
26
+ }, [item]);
20
27
  // useEffects
21
- useEffect(() => setValue(itemValue), [item]);
28
+ useEffect(() => setValue(itemValue), [itemValue]);
29
+ // return
22
30
  switch (c.editable?.(item)?.type) {
23
31
  case "string":
24
32
  case "number":
25
33
  return (React.createElement(Input, { variant: "borderless", value: String(_value ?? ""), onChange: (event) => {
26
- const { value } = event.target;
27
- setValue(value);
28
- onEditable({ ...item, [key]: c.editable?.(item)?.type === "number" ? Number(value) : value }, trackByValue, ExtractKey(c.key));
34
+ handleChange(c.editable?.(item)?.type === "number" ? Number(event.target.value) : event.target.value);
29
35
  }, validation: { text: _vText }, ...(c.editable?.(item).where ? { disabled: c.editable?.(item).where } : {}) }));
30
36
  case "boolean":
31
37
  return (React.createElement(Checkbox, { variant: "borderless", color: "blue", checked: Boolean(_value), onChange: (event) => {
@@ -37,30 +43,15 @@ const Editable = function ({ c, item, trackByValue, onEditable, config }) {
37
43
  }, trackByValue, ExtractKey(c.key));
38
44
  }, validation: { text: _vText }, ...(c.editable?.(item).where ? { disabled: c.editable?.(item).where } : {}) }));
39
45
  case "decimal":
40
- return (React.createElement(Input.Decimal, { variant: "borderless", name: c.key, value: String(_value ?? ""), onChange: (event) => {
41
- const { value } = event.target;
42
- setValue(value);
43
- onEditable({ ...item, [key]: value }, trackByValue, ExtractKey(c.key));
44
- }, validation: { text: _vText }, locale: config.locale, ...(c.editable?.(item).where ? { disabled: c.editable?.(item).where } : {}) }));
46
+ return (React.createElement(Input.Decimal, { variant: "borderless", name: c.key, value: String(_value ?? ""), onChange: (event) => handleChange(event.target.value), validation: { text: _vText }, locale: config.locale, ...(c.editable?.(item).where ? { disabled: c.editable?.(item).where } : {}) }));
45
47
  case "input-formatted-decimal":
46
- return (React.createElement(Input.FormattedDecimal, { variant: "borderless", name: c.key, value: String(_value ?? ""), onChange: (event) => {
47
- const { value } = event.target;
48
- setValue(value);
49
- onEditable({ ...item, [key]: value }, trackByValue, ExtractKey(c.key));
50
- }, validation: { text: _vText }, locale: config.locale, ...(c.editable?.(item).where ? { disabled: c.editable?.(item).where } : {}) }));
48
+ return (React.createElement(Input.FormattedDecimal, { variant: "borderless", name: c.key, value: String(_value ?? ""), onChange: (event) => handleChange(event.target.value), validation: { text: _vText }, locale: config.locale, ...(c.editable?.(item).where ? { disabled: c.editable?.(item).where } : {}) }));
51
49
  case "date-picker":
52
- return (React.createElement(DatePicker, { variant: "borderless", value: String(_value ?? ""), onChange: (value) => {
53
- setValue(value);
54
- onEditable({ ...item, [key]: value }, trackByValue, ExtractKey(c.key));
55
- }, validation: { text: _vText }, ...(c.editable?.(item).where ? { disabled: c.editable?.(item).where } : {}) }));
50
+ return (React.createElement(DatePicker, { variant: "borderless", value: String(_value ?? ""), onChange: (value) => handleChange(value), validation: { text: _vText }, ...(c.editable?.(item).where ? { disabled: c.editable?.(item).where } : {}) }));
56
51
  case "single-select":
57
- return (React.createElement(Select, { variant: "borderless", value: selectItem, options: c.editable?.(item).options, onClick: async () => await c.editable?.(item)?.method?.(), onChange: (option) => {
58
- onEditable({ ...item, [key]: option?.value }, trackByValue, ExtractKey(c.key));
59
- }, validation: { text: _vText }, ...(c.editable?.(item).where ? { disabled: c.editable?.(item).where } : {}) }));
52
+ return (React.createElement(Select, { variant: "borderless", value: selectItem, options: c.editable?.(item).options, onClick: async () => await c.editable?.(item)?.method?.(), onChange: (option) => handleChange(option?.value, false), validation: { text: _vText }, ...(c.editable?.(item).where ? { disabled: c.editable?.(item).where } : {}) }));
60
53
  case "multiple-select":
61
- return (React.createElement(Select, { variant: "borderless", value: selectItems, options: c.editable?.(item).options, onClick: async () => await c.editable?.(item)?.method?.(), onChange: (options) => {
62
- onEditable({ ...item, [key]: options.map((option) => option.value) }, trackByValue, ExtractKey(c.key));
63
- }, validation: { text: _vText }, multiple: true, ...(c.editable?.(item).where ? { disabled: c.editable?.(item).where } : {}) }));
54
+ return (React.createElement(Select, { variant: "borderless", value: selectItems, options: c.editable?.(item).options, onClick: async () => await c.editable?.(item)?.method?.(), onChange: (options) => handleChange(options.map((option) => option.value), false), validation: { text: _vText }, multiple: true, ...(c.editable?.(item).where ? { disabled: c.editable?.(item).where } : {}) }));
64
55
  default:
65
56
  return null;
66
57
  }
@@ -25,12 +25,12 @@ interface IProps<T extends object> {
25
25
  methods: {
26
26
  trackBy?: (item: T) => string;
27
27
  selections?: (selectionItems: T[]) => void;
28
+ selectionDisabled?: (item: T) => boolean;
28
29
  onDnD?: (item: T[]) => void;
29
30
  onEditable?: (item: T, trackByValue: string, currentKey?: keyof T | null) => void;
30
31
  rowBackgroundColor?: (item: T) => string;
31
32
  };
32
33
  config: Config<T>;
33
34
  }
34
- declare function TBody<T extends object>({ data, columns, refs, methods, states, config }: IProps<T>): React.JSX.Element | React.JSX.Element[];
35
- declare const _default: typeof TBody;
35
+ declare const _default: <T extends object>(props: IProps<T>) => React.JSX.Element;
36
36
  export default _default;
@@ -1,11 +1,48 @@
1
+ "use client";
1
2
  import React, { Fragment, memo, useEffect, useRef, useState } from "react";
2
3
  import { ARIcon } from "../../../icons";
3
4
  import Checkbox from "../../../form/checkbox";
4
5
  import Editable from "./Editable";
5
6
  import { useTranslation } from "../../../../libs/core/application/hooks";
7
+ // SubitemList bağımsız bir bileşen.
8
+ // Böylece her render döngüsünde hafızada sıfırdan yaratılıp alt DOM elementlerini çökertmiyor.
9
+ const SubitemList = ({ items, columns, depth, level = 1, parentKey = "", config, methods, states, renderCell, }) => {
10
+ const _subrowSelector = config.subrow?.selector ?? "subitems";
11
+ const _subrowButton = config.subrow?.button ?? true;
12
+ if (config.subrow?.render) {
13
+ return (React.createElement("tr", { className: `subrow-item ${_subrowButton ? "type-b" : "type-a"}`, "data-level": level },
14
+ _subrowButton && React.createElement("td", { style: { ...config.subrow.render.styles, width: 0, minWidth: 0 } }),
15
+ React.createElement("td", { colSpan: columns.length || 1, style: { ...config.subrow.render.styles, padding: "7.5px 7.5px 7.5px 0" } }, config.subrow?.render.element(items) ?? React.createElement(React.Fragment, null))));
16
+ }
17
+ return (React.createElement(React.Fragment, null, items.map((subitem, subindex) => {
18
+ const id = methods.trackBy?.(subitem) ?? `sub-${subindex}`;
19
+ const key = `${parentKey}.${id}`;
20
+ const _subitem = subitem[_subrowSelector];
21
+ const isHasSubitems = _subrowSelector in subitem;
22
+ return (React.createElement(Fragment, { key: `subitem-wrapper-${key}` },
23
+ React.createElement("tr", { className: `subrow-item ${_subrowButton ? "type-b" : "type-a"}`, "data-level": level },
24
+ isHasSubitems && _subrowButton ? (React.createElement("td", { className: "subrow-col sticky sticky-left", "data-sticky-position": "left" },
25
+ React.createElement("div", { className: "subitem-open-button-wrapper" },
26
+ React.createElement("span", { className: `${(states.showSubitems.get[key] && "opened") ?? ""} ${!_subitem && "passive"}`, onClick: () => {
27
+ if (!_subitem)
28
+ return;
29
+ states.showSubitems.set((prev) => ({ ...prev, [key]: !prev[key] }));
30
+ } })))) : !isHasSubitems && _subrowButton ? (React.createElement("td", { style: { width: 0, minWidth: 0 } })) : null,
31
+ columns.map((column, cIndex) => renderCell({
32
+ item: subitem,
33
+ column,
34
+ index: subindex,
35
+ cIndex,
36
+ depth: depth * (config.isTreeView ? 2.25 : 1.75),
37
+ level,
38
+ height: 0,
39
+ isSubrows: true,
40
+ }))),
41
+ states.showSubitems.get[key] && _subitem && (React.createElement(SubitemList, { items: _subitem, columns: columns, depth: depth + 0.75, level: level + 1, parentKey: key, config: config, methods: methods, states: states, renderCell: renderCell }))));
42
+ })));
43
+ };
6
44
  function TBody({ data, columns, refs, methods, states, config }) {
7
45
  // refs
8
- const _hasMeasured = useRef(false);
9
46
  const _tBodyTR = useRef([]);
10
47
  const _tHeadTH = useRef([]);
11
48
  // states
@@ -17,63 +54,12 @@ function TBody({ data, columns, refs, methods, states, config }) {
17
54
  // hooks
18
55
  const { t } = useTranslation(String(config.locale ?? "tr"));
19
56
  // methods
20
- const renderRow = (item, index, deph, parentKey = "") => {
21
- const id = methods.trackBy?.(item) ?? index.toString();
22
- const key = parentKey ? `${parentKey}.${id}` : id;
23
- const _subitem = item[_subrowSelector];
24
- const isHasSubitems = _subrowSelector in item;
25
- return (React.createElement(Fragment, { key: `row-${index}` },
26
- React.createElement("tr", { ref: (element) => {
27
- _tBodyTR.current[index] = element;
28
- }, ...(methods.rowBackgroundColor ? { style: { backgroundColor: methods.rowBackgroundColor(item) } } : {}), ...(methods.onDnD && data.length > 1 ? { className: "draggable", draggable: true } : {}) },
29
- methods.selections && (React.createElement("td", { ref: (element) => {
30
- _tHeadTH.current[index] = element;
31
- }, className: "flex justify-content-center sticky sticky-left", "data-sticky-position": "left" },
32
- React.createElement(Checkbox, { key: Date.now(), ref: (element) => {
33
- if (!element)
34
- return;
35
- refs._checkboxItems.current[index] = element;
36
- }, variant: "filled", color: "green", checked: refs._selectionItems.current.some((selectionItem) => methods.trackBy?.(selectionItem) === methods.trackBy?.(item)), onChange: (event) => {
37
- const key = methods.trackBy?.(item);
38
- if (event.target.checked) {
39
- if (!refs._selectionItems.current.some((_item) => methods.trackBy?.(_item) === key)) {
40
- refs._selectionItems.current = [...refs._selectionItems.current, item];
41
- }
42
- }
43
- else {
44
- refs._selectionItems.current = refs._selectionItems.current.filter((_item) => methods.trackBy?.(_item) !== key);
45
- }
46
- methods.selections?.(refs._selectionItems.current);
47
- setTriggerForRender((prev) => !prev);
48
- } }))),
49
- isHasSubitems && _subrowButton ? (React.createElement("td", { className: "subrow-col sticky sticky-left", "data-sticky-position": "left" },
50
- React.createElement("div", { className: "subitem-open-button-wrapper" },
51
- React.createElement("span", { className: `subitem-open-button ${(states.showSubitems.get[key] && "opened") ?? ""} ${!_subitem && "passive"}`, onClick: () => {
52
- states.showSubitems.set((prev) => ({
53
- ...prev,
54
- [`${key}`]: !prev[`${key}`],
55
- }));
56
- } })))) : isHasSubitems && _subrowButton ? (React.createElement("td", { style: { width: 0, minWidth: 0 } })) : null,
57
- columns.map((column, cIndex) => {
58
- return renderCell({
59
- item,
60
- column,
61
- index,
62
- cIndex,
63
- depth: deph * (config.isTreeView ? 1.75 : 0),
64
- level: 0,
65
- height: rowHeights[index] ?? 0,
66
- });
67
- })),
68
- states.showSubitems.get[key] && item[_subrowSelector] && (React.createElement(SubitemList, { items: item[_subrowSelector], columns: columns, index: index, depth: 1.5, parentKey: key }))));
69
- };
70
57
  const renderCell = ({ item, column, index, cIndex, depth, level, height = 0, isSubrows = false }) => {
71
58
  let render;
72
- const isHasSubitems = _subrowSelector in item;
73
- // `column.key` bir string ise
59
+ // const isHasSubitems = _subrowSelector in item;
60
+ const itemTrackId = methods.trackBy?.(item) ?? index.toString();
74
61
  if (typeof column.key !== "object")
75
62
  render = column.render ? column.render(item) : item[column.key];
76
- // `column.key` bir nesne ise ve `nestedKey` mevcutsa
77
63
  else if (typeof column.key === "object") {
78
64
  const _item = item[column.key.field];
79
65
  if (_item && typeof _item === "object") {
@@ -89,83 +75,86 @@ function TBody({ data, columns, refs, methods, states, config }) {
89
75
  _className.push(`sticky-${column.config.sticky}`);
90
76
  if (column.config?.textWrap)
91
77
  _className.push(`text-${column.config.textWrap}`);
92
- return (React.createElement("td", { key: `cell-${index}-${cIndex}`, className: _className.join(" "), style: {
78
+ const firstCleanDataColumn = columns.find((col) => col.config?.sticky === undefined || col.config?.sticky !== "left");
79
+ const isTargetPaddingColumn = firstCleanDataColumn !== undefined && column === firstCleanDataColumn;
80
+ return (React.createElement("td", { key: `cell-${itemTrackId}-${cIndex}`, className: _className.join(" "), style: {
93
81
  ...(column.config?.sticky ? { height } : {}),
94
82
  ...(column.config?.width
95
83
  ? { width: column.config.width, minWidth: column.config.width, maxWidth: column.config.width }
96
84
  : {}),
97
85
  }, "data-sticky-position": column.config?.sticky },
98
86
  React.createElement("div", { style: {
99
- paddingLeft: cIndex === (methods.selections || (isHasSubitems && _subrowButton) ? 1 : 0)
100
- ? `${depth == 0 ? 1 : depth}rem`
101
- : "",
87
+ paddingLeft: isTargetPaddingColumn ? `${depth == 0 ? 1 : depth}rem` : "",
102
88
  }, className: "table-cell" },
103
89
  config.isTreeView && cIndex === 0 && (React.createElement(React.Fragment, null,
104
90
  isSubrows &&
105
- Array.from({ length: level }).map((_, i) => {
106
- if (i > 0)
107
- i *= 1.655;
108
- return (React.createElement("div", { key: `last-before-${i}`, style: { left: `${i + 0.65}rem` }, className: "last-before" }));
109
- }),
91
+ Array.from({ length: level }).map((_, i) => (React.createElement("div", { key: `last-before-${itemTrackId}-${i}`, style: { left: `${(i > 0 ? i * 1.655 : i) + 0.65}rem` }, className: "last-before" }))),
110
92
  React.createElement("div", { className: "before" }))),
111
- React.isValidElement(render) ? (render) : column.editable && methods.onEditable ? (React.createElement(Editable, { c: column, item: item, trackByValue: methods.trackBy?.(item) ?? "", onEditable: methods.onEditable, config: config })) : (React.createElement("span", null, render)),
93
+ React.isValidElement(render) ? (render) : column.editable && methods.onEditable ? (React.createElement(Editable, { key: `editable-${itemTrackId}-${String(column.key)}`, c: column, item: item, trackByValue: itemTrackId, onEditable: methods.onEditable, config: config })) : (React.createElement("span", null, render)),
112
94
  config.isTreeView && cIndex === 0 && (React.createElement("div", { className: "after" },
113
95
  React.createElement("div", { className: "circle" }))))));
114
96
  };
115
- const SubitemList = ({ items, columns, index, depth, level = 1, parentKey = "" }) => {
116
- if (config.subrow?.render) {
117
- return (React.createElement("tr", { className: `subrow-item ${_subrowButton ? "type-b" : "type-a"}`, "data-level": level },
118
- _subrowButton && React.createElement("td", { style: { ...config.subrow.render.styles, width: 0, minWidth: 0 } }),
119
- React.createElement("td", { colSpan: columns.length || 1, style: { ...config.subrow.render.styles, padding: "7.5px 7.5px 7.5px 0" } }, config.subrow?.render.element(items) ?? React.createElement(React.Fragment, null))));
120
- }
121
- return items.map((subitem, subindex) => {
122
- const id = methods.trackBy?.(subitem) ?? subindex.toString();
123
- const key = `${parentKey}.${id}`;
124
- const _subitem = subitem[_subrowSelector];
125
- const isHasSubitems = _subrowSelector in subitem;
126
- return (React.createElement(Fragment, { key: `subitem-${index}-${subindex}-${Math.random()}` },
127
- React.createElement("tr", { className: `subrow-item ${_subrowButton ? "type-b" : "type-a"}`, "data-level": level },
128
- isHasSubitems && _subrowButton ? (React.createElement("td", { className: "subrow-col sticky sticky-left", "data-sticky-position": "left" },
129
- React.createElement("div", { className: "subitem-open-button-wrapper" },
130
- React.createElement("span", { className: `${(states.showSubitems.get[key] && "opened") ?? ""} ${!_subitem && "passive"}`, onClick: () => {
131
- if (!_subitem)
132
- return;
133
- states.showSubitems.set((prev) => ({
134
- ...prev,
135
- [key]: !prev[key],
136
- }));
137
- } })))) : !isHasSubitems && _subrowButton ? (React.createElement("td", { style: { width: 0, minWidth: 0 } })) : null,
138
- !config.subrow?.render ? (columns.map((column, cIndex) => renderCell({
139
- item: subitem,
140
- column,
141
- index,
142
- cIndex,
143
- depth: depth * (config.isTreeView ? 2.25 : 1.75),
144
- level,
145
- height: 0,
146
- isSubrows: true,
147
- }))) : (React.createElement("td", { colSpan: columns.length || 1 }, config.subrow?.render.element(items) ?? React.createElement(React.Fragment, null)))),
148
- states.showSubitems.get[key] && _subitem && (React.createElement(SubitemList, { items: _subitem, columns: columns, index: subindex, depth: depth + 0.75, level: level + 1, parentKey: key }))));
149
- });
97
+ const renderRow = (item, index, deph, parentKey = "") => {
98
+ const id = methods.trackBy?.(item) ?? index.toString();
99
+ const key = parentKey ? `${parentKey}.${id}` : id;
100
+ const _subitem = item[_subrowSelector];
101
+ const isHasSubitems = _subrowSelector in item;
102
+ return (React.createElement(Fragment, { key: `row-wrapper-${id}` },
103
+ React.createElement("tr", { ref: (element) => {
104
+ _tBodyTR.current[index] = element;
105
+ }, ...(methods.rowBackgroundColor ? { style: { backgroundColor: methods.rowBackgroundColor(item) } } : {}), ...(methods.onDnD && data.length > 1 ? { className: "draggable", draggable: true } : {}) },
106
+ methods.selections && (React.createElement("td", { ref: (element) => {
107
+ _tHeadTH.current[index] = element;
108
+ }, className: "flex justify-content-center sticky sticky-left", "data-sticky-position": "left" },
109
+ React.createElement(Checkbox, { ref: (element) => {
110
+ if (element)
111
+ refs._checkboxItems.current[index] = element;
112
+ }, variant: "filled", color: "green", checked: refs._selectionItems.current.some((sItem) => methods.trackBy?.(sItem) === methods.trackBy?.(item)), onChange: (event) => {
113
+ const rKey = methods.trackBy?.(item);
114
+ if (event.target.checked) {
115
+ if (!refs._selectionItems.current.some((_item) => methods.trackBy?.(_item) === rKey)) {
116
+ refs._selectionItems.current = [...refs._selectionItems.current, item];
117
+ }
118
+ }
119
+ else {
120
+ refs._selectionItems.current = refs._selectionItems.current.filter((_item) => methods.trackBy?.(_item) !== rKey);
121
+ }
122
+ methods.selections?.(refs._selectionItems.current);
123
+ setTriggerForRender((prev) => !prev);
124
+ }, disabled: methods.selectionDisabled?.(item) }))),
125
+ isHasSubitems && _subrowButton ? (React.createElement("td", { className: "subrow-col sticky sticky-left", "data-sticky-position": "left" },
126
+ React.createElement("div", { className: "subitem-open-button-wrapper" },
127
+ React.createElement("span", { className: `subitem-open-button ${(states.showSubitems.get[key] && "opened") ?? ""} ${!_subitem && "passive"}`, onClick: () => {
128
+ states.showSubitems.set((prev) => ({ ...prev, [key]: !prev[key] }));
129
+ } })))) : isHasSubitems && _subrowButton ? (React.createElement("td", { style: { width: 0, minWidth: 0 } })) : null,
130
+ columns.map((column, cIndex) => renderCell({
131
+ item,
132
+ column,
133
+ index,
134
+ cIndex,
135
+ depth: deph * (config.isTreeView ? 1.75 : 0),
136
+ level: 0,
137
+ height: rowHeights[index] ?? 0,
138
+ }))),
139
+ states.showSubitems.get[key] && _subitem && (React.createElement(SubitemList, { items: _subitem, columns: columns, depth: 1.5, parentKey: key, config: config, methods: methods, states: states, renderCell: renderCell }))));
150
140
  };
151
141
  // useEffects
152
142
  useEffect(() => {
153
- if (_hasMeasured.current)
154
- return;
155
143
  if (!data || data.length === 0)
156
144
  return;
157
145
  const heights = _tBodyTR.current.map((el) => (el ? el.getBoundingClientRect().height : 0));
158
146
  setRowHeights(heights);
159
- setTriggerForRender((prev) => !prev);
160
- _hasMeasured.current = true;
161
- }, [data]);
147
+ }, [data.length]);
162
148
  useEffect(() => {
163
149
  if (Array.isArray(refs._checkboxItems.current) && refs._checkboxItems.current.length > 0) {
164
150
  const allChecked = refs._checkboxItems.current.every((item) => item?.checked === true);
165
151
  states.setSelectAll.set(allChecked);
166
152
  }
167
153
  }, [triggerForRender]);
168
- return data.length > 0 ? (data.map((item, index) => React.createElement(React.Fragment, { key: index }, renderRow(item, index, 1)))) : (React.createElement("tr", null,
154
+ return data.length > 0 ? (data.map((item, index) => {
155
+ const rowKey = methods.trackBy?.(item) ?? index.toString();
156
+ return React.createElement(React.Fragment, { key: `tbody-row-${rowKey}` }, renderRow(item, index, 1));
157
+ })) : (React.createElement("tr", null,
169
158
  React.createElement("td", { colSpan: columns.length || 1 },
170
159
  React.createElement("div", { className: "no-item" },
171
160
  React.createElement(ARIcon, { icon: "Inbox-Fill", fill: "var(--gray-300)", size: 64, style: { position: "relative", zIndex: 1 } }),
@@ -21,7 +21,7 @@ import TBody from "./body/TBody";
21
21
  import DatePicker from "../../form/date-picker";
22
22
  import { useTranslation } from "../../../libs/core/application/hooks";
23
23
  const { Row, Column } = Grid;
24
- const Table = forwardRef(({ children, trackBy, title, description, data, columns, actions, rowBackgroundColor, selections, previousSelections, sortedParams, searchedParams, onEditable, onDnD, pagination, config = { isSearchable: false }, }, ref) => {
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
25
  // refs
26
26
  const _innerRef = useRef(null);
27
27
  const _tableWrapper = useRef(null);
@@ -379,7 +379,8 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
379
379
  const indexOfFirstRow = indexOfLastRow - selectedPerPage;
380
380
  _data = _data.slice(indexOfFirstRow, indexOfLastRow);
381
381
  }
382
- handleScroll();
382
+ // Önemli, Data yenilenmesi durumunda sticky alanlar tazelenir.
383
+ setTimeout(() => handleScroll(), 0);
383
384
  return _data;
384
385
  }, [data, searchedText, currentPage, selectedPerPage, sortConfig, config.isServerSide]);
385
386
  // useEffects
@@ -579,6 +580,7 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
579
580
  });
580
581
  config.validation?.getChangeData?.(updatedData);
581
582
  }
583
+ handleScroll();
582
584
  }, [createTrigger]);
583
585
  useEffect(() => {
584
586
  setIsMobile(window.innerWidth <= 768);
@@ -698,6 +700,7 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
698
700
  }, methods: {
699
701
  trackBy: trackBy,
700
702
  selections: selections,
703
+ selectionDisabled: selectionDisabled,
701
704
  onDnD: onDnD,
702
705
  onEditable: onEditable,
703
706
  rowBackgroundColor: rowBackgroundColor,
@@ -732,11 +735,12 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
732
735
  setTimeout(() => handleScroll(), 0);
733
736
  } })))));
734
737
  });
735
- export default memo(Table, (prevProps, nextProps) => {
736
- const data = Utils.DeepEqual(prevProps.data, nextProps.data);
737
- const columns = Utils.DeepEqual(prevProps.columns, nextProps.columns);
738
- const actions = Utils.DeepEqual(prevProps.actions, nextProps.actions);
739
- const previousSelections = Utils.DeepEqual(prevProps.previousSelections, nextProps.previousSelections);
740
- const pagination = Utils.DeepEqual(prevProps.pagination, nextProps.pagination);
741
- return data && columns && actions && previousSelections && pagination;
742
- });
738
+ // export default memo(Table, <T extends object>(prevProps: IProps<T>, nextProps: IProps<T>) => {
739
+ // const data = Utils.DeepEqual(prevProps.data, nextProps.data);
740
+ // const columns = Utils.DeepEqual(prevProps.columns, nextProps.columns);
741
+ // const actions = Utils.DeepEqual(prevProps.actions, nextProps.actions);
742
+ // const previousSelections = Utils.DeepEqual(prevProps.previousSelections, nextProps.previousSelections);
743
+ // const pagination = Utils.DeepEqual(prevProps.pagination, nextProps.pagination);
744
+ // return data && columns && actions && previousSelections && pagination;
745
+ // }) as <T extends object>(props: IProps<T> & { ref?: React.Ref<HTMLTableElement> }) => React.JSX.Element;
746
+ export default memo(Table);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.4.61",
3
+ "version": "0.4.62",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",