ar-design 0.2.47 → 0.2.48

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.
@@ -184,18 +184,23 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
184
184
  return false;
185
185
  });
186
186
  };
187
+ const openAllSubrowsRecursively = (data, parentKey = "") => {
188
+ let result = {};
189
+ data.forEach((item, index) => {
190
+ const key = parentKey ? `${parentKey}.${index}` : `${index}`;
191
+ const subitems = item[_subrowSelector];
192
+ if (subitems && Array.isArray(subitems) && subitems.length > 0) {
193
+ const nested = openAllSubrowsRecursively(subitems, key);
194
+ result[key] = true;
195
+ result = { ...result, ...nested };
196
+ }
197
+ });
198
+ return result;
199
+ };
187
200
  const getData = useMemo(() => {
188
201
  let _data = [...data];
189
- if (_subrowOpenAutomatically) {
190
- data.forEach((item, index) => {
191
- if (_subrowSelector in item) {
192
- setShowSubitems((prev) => ({
193
- ...prev,
194
- [`${index}`]: true,
195
- }));
196
- }
197
- });
198
- }
202
+ if (_subrowOpenAutomatically)
203
+ setShowSubitems(openAllSubrowsRecursively(data));
199
204
  if (searchedText && Object.keys(searchedText).length > 0) {
200
205
  _data = _data.filter((item) => deepSearch(item, searchedText));
201
206
  setTotalRecords(_data.length);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.2.47",
3
+ "version": "0.2.48",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",