ar-design 0.2.34 → 0.2.35

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.
@@ -9,7 +9,7 @@ import Input from "../../form/input";
9
9
  import Popover from "../../feedback/popover";
10
10
  import Utils from "../../../libs/infrastructure/shared/Utils";
11
11
  import Upload from "../../form/upload";
12
- const Table = forwardRef(({ children, title, description, data, columns, actions, selections, previousSelections, searchedParams, pagination, config = { isSearchable: false, subrowSelector: "subitems" }, }, ref) => {
12
+ const Table = forwardRef(({ children, title, description, data, columns, actions, selections, previousSelections, searchedParams, pagination, config = { isSearchable: false }, }, ref) => {
13
13
  // refs
14
14
  const _tableWrapper = useRef(null);
15
15
  const _tableContent = useRef(null);
@@ -18,6 +18,8 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
18
18
  // refs -> Search
19
19
  const _searchTextInputs = useRef([]);
20
20
  const _searchTimeOut = useRef(null);
21
+ // variables
22
+ const _subrowSelector = config.subrowSelector ?? "subitems";
21
23
  // className
22
24
  const _tableClassName = ["ar-table", "scroll"];
23
25
  // states
@@ -227,21 +229,21 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
227
229
  else
228
230
  setSelectionItems((prev) => prev.filter((_item) => _item !== item));
229
231
  } }))),
230
- data.some((item) => config.subrowSelector ?? "subitems" in item) && (React.createElement("td", { style: { width: 1 } }, item[config.subrowSelector] && (React.createElement("span", { className: `subitem-open-button ${showSubitems[index] && "opened"}`, onClick: () => {
232
+ data.some((item) => _subrowSelector in item) && (React.createElement("td", { style: { width: 1 } }, item[_subrowSelector] && (React.createElement("span", { className: `subitem-open-button ${showSubitems[index] && "opened"}`, onClick: () => {
231
233
  setShowSubitems((prev) => ({
232
234
  ...prev,
233
235
  [`${index}`]: !prev[`${index}`],
234
236
  }));
235
237
  } })))),
236
238
  columns.map((c, cIndex) => renderCell(item, c, cIndex, index))),
237
- showSubitems[index] && item[config.subrowSelector] && (React.createElement(SubitemList, { items: item[config.subrowSelector], columns: columns, index: index, depth: 1.5 }))));
239
+ showSubitems[index] && item[_subrowSelector] && (React.createElement(SubitemList, { items: item[_subrowSelector], columns: columns, index: index, depth: 1.5 }))));
238
240
  };
239
241
  const SubitemList = ({ items, columns, index, depth }) => {
240
242
  return items.map((subitem, subindex) => {
241
- const x = subitem[config.subrowSelector];
243
+ const x = subitem[_subrowSelector];
242
244
  return (React.createElement(React.Fragment, null,
243
245
  React.createElement("tr", { key: `subitem-${index}-${subindex}` },
244
- data.some((item) => config.subrowSelector ?? "subitems" in item) && (React.createElement("td", { style: { paddingLeft: `${depth * 1.5}rem` } },
246
+ data.some((item) => _subrowSelector in item) && (React.createElement("td", { style: { paddingLeft: `${depth * 1.5}rem` } },
245
247
  React.createElement("span", { className: `subitem-open-button ${showSubitems[`${index}.${subindex}`] && "opened"} ${!x && "passive"}`, onClick: () => {
246
248
  if (!x)
247
249
  return;
@@ -316,7 +318,7 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
316
318
  React.createElement("table", { ref: ref },
317
319
  React.createElement("thead", null,
318
320
  React.createElement("tr", { key: "selection" },
319
- data.some((item) => config.subrowSelector ?? "subitems" in item) && React.createElement("td", { style: { width: 1 } }),
321
+ data.some((item) => _subrowSelector in item) && React.createElement("td", { style: { width: 1 } }),
320
322
  selections && (React.createElement("th", { className: "selection-col sticky-left", "data-sticky-position": "left" },
321
323
  React.createElement(Checkbox, { variant: "filled", status: "primary", checked: selectAll, onChange: (event) => {
322
324
  if (_checkboxItems.current.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.2.34",
3
+ "version": "0.2.35",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",