warqadui 0.0.53 → 0.0.57

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.
package/dist/index.js CHANGED
@@ -3314,7 +3314,7 @@ var TableRow = import_react16.default.memo(
3314
3314
  ] });
3315
3315
  },
3316
3316
  (prev, next) => {
3317
- return prev.row.original === next.row.original && prev.row.getIsExpanded() === next.row.getIsExpanded() && prev.row.getIsSelected() === next.row.getIsSelected() && prev.rowPadding === next.rowPadding && prev.verticalLines === next.verticalLines;
3317
+ return prev.row.original === next.row.original && prev.row.getIsExpanded() === next.row.getIsExpanded() && prev.row.getIsSelected() === next.row.getIsSelected() && prev.rowPadding === next.rowPadding && prev.verticalLines === next.verticalLines && prev.renderSubComponent === next.renderSubComponent && prev.hasSubComponent === next.hasSubComponent;
3318
3318
  }
3319
3319
  );
3320
3320
  function PostTable({
@@ -3343,10 +3343,10 @@ function PostTable({
3343
3343
  const [columnVisibility, setColumnVisibility] = (0, import_react16.useState)({});
3344
3344
  const [expanded, setExpanded] = (0, import_react16.useState)(() => {
3345
3345
  const initialState = {};
3346
- if (defaultExpanded && renderSubComponent && controlledData) {
3347
- controlledData.forEach((row, idx) => {
3346
+ if (defaultExpanded && renderSubComponent && (controlledData || []).length > 0) {
3347
+ (controlledData || []).forEach((row, idx) => {
3348
3348
  if (hasSubComponent(row)) {
3349
- initialState[idx] = true;
3349
+ initialState[idx.toString()] = true;
3350
3350
  }
3351
3351
  });
3352
3352
  }
@@ -3356,6 +3356,19 @@ function PostTable({
3356
3356
  const isControlled = controlledData !== void 0;
3357
3357
  const data = isControlled ? controlledData : internalData;
3358
3358
  const entryRowRef = (0, import_react16.useRef)(null);
3359
+ const hasInitializedExpansion = (0, import_react16.useRef)(false);
3360
+ (0, import_react16.useEffect)(() => {
3361
+ if (defaultExpanded && renderSubComponent && !hasInitializedExpansion.current && (data || []).length > 0) {
3362
+ const initialState = {};
3363
+ data.forEach((row, idx) => {
3364
+ if (hasSubComponent(row)) {
3365
+ initialState[idx.toString()] = true;
3366
+ }
3367
+ });
3368
+ setExpanded(initialState);
3369
+ hasInitializedExpansion.current = true;
3370
+ }
3371
+ }, [data, defaultExpanded, hasSubComponent, renderSubComponent]);
3359
3372
  const focusAndScrollEntryRow = () => {
3360
3373
  setTimeout(() => {
3361
3374
  if (entryRowRef.current) {
@@ -3468,6 +3481,13 @@ function PostTable({
3468
3481
  if (editingIndex2 !== null) {
3469
3482
  setEditingIndex(null);
3470
3483
  } else {
3484
+ if (defaultExpanded && renderSubComponent && hasSubComponent(entryToPass)) {
3485
+ const newIndex = updated.length - 1;
3486
+ setExpanded((prev) => ({
3487
+ ...typeof prev === "object" ? prev : {},
3488
+ [newIndex.toString()]: true
3489
+ }));
3490
+ }
3471
3491
  setTimeout(() => focusAndScrollEntryRow(), 0);
3472
3492
  }
3473
3493
  }, []);
@@ -3602,7 +3622,7 @@ function PostTable({
3602
3622
  });
3603
3623
  }
3604
3624
  return finalColumns;
3605
- }, [userColumns, actionColumn, index]);
3625
+ }, [userColumns, actionColumn, index, renderSubComponent, hasSubComponent]);
3606
3626
  const table = (0, import_react_table2.useReactTable)({
3607
3627
  data,
3608
3628
  columns,
@@ -7619,7 +7639,6 @@ var Guard = () => {
7619
7639
  url: "/users/me",
7620
7640
  v: 1
7621
7641
  });
7622
- console.log("res", res);
7623
7642
  login(res?.data);
7624
7643
  setIsLoggedIn(true);
7625
7644
  setIsFetched(true);
package/dist/index.mjs CHANGED
@@ -3271,7 +3271,7 @@ var TableRow = React9.memo(
3271
3271
  ] });
3272
3272
  },
3273
3273
  (prev, next) => {
3274
- return prev.row.original === next.row.original && prev.row.getIsExpanded() === next.row.getIsExpanded() && prev.row.getIsSelected() === next.row.getIsSelected() && prev.rowPadding === next.rowPadding && prev.verticalLines === next.verticalLines;
3274
+ return prev.row.original === next.row.original && prev.row.getIsExpanded() === next.row.getIsExpanded() && prev.row.getIsSelected() === next.row.getIsSelected() && prev.rowPadding === next.rowPadding && prev.verticalLines === next.verticalLines && prev.renderSubComponent === next.renderSubComponent && prev.hasSubComponent === next.hasSubComponent;
3275
3275
  }
3276
3276
  );
3277
3277
  function PostTable({
@@ -3300,10 +3300,10 @@ function PostTable({
3300
3300
  const [columnVisibility, setColumnVisibility] = useState15({});
3301
3301
  const [expanded, setExpanded] = useState15(() => {
3302
3302
  const initialState = {};
3303
- if (defaultExpanded && renderSubComponent && controlledData) {
3304
- controlledData.forEach((row, idx) => {
3303
+ if (defaultExpanded && renderSubComponent && (controlledData || []).length > 0) {
3304
+ (controlledData || []).forEach((row, idx) => {
3305
3305
  if (hasSubComponent(row)) {
3306
- initialState[idx] = true;
3306
+ initialState[idx.toString()] = true;
3307
3307
  }
3308
3308
  });
3309
3309
  }
@@ -3313,6 +3313,19 @@ function PostTable({
3313
3313
  const isControlled = controlledData !== void 0;
3314
3314
  const data = isControlled ? controlledData : internalData;
3315
3315
  const entryRowRef = useRef5(null);
3316
+ const hasInitializedExpansion = useRef5(false);
3317
+ useEffect10(() => {
3318
+ if (defaultExpanded && renderSubComponent && !hasInitializedExpansion.current && (data || []).length > 0) {
3319
+ const initialState = {};
3320
+ data.forEach((row, idx) => {
3321
+ if (hasSubComponent(row)) {
3322
+ initialState[idx.toString()] = true;
3323
+ }
3324
+ });
3325
+ setExpanded(initialState);
3326
+ hasInitializedExpansion.current = true;
3327
+ }
3328
+ }, [data, defaultExpanded, hasSubComponent, renderSubComponent]);
3316
3329
  const focusAndScrollEntryRow = () => {
3317
3330
  setTimeout(() => {
3318
3331
  if (entryRowRef.current) {
@@ -3425,6 +3438,13 @@ function PostTable({
3425
3438
  if (editingIndex2 !== null) {
3426
3439
  setEditingIndex(null);
3427
3440
  } else {
3441
+ if (defaultExpanded && renderSubComponent && hasSubComponent(entryToPass)) {
3442
+ const newIndex = updated.length - 1;
3443
+ setExpanded((prev) => ({
3444
+ ...typeof prev === "object" ? prev : {},
3445
+ [newIndex.toString()]: true
3446
+ }));
3447
+ }
3428
3448
  setTimeout(() => focusAndScrollEntryRow(), 0);
3429
3449
  }
3430
3450
  }, []);
@@ -3559,7 +3579,7 @@ function PostTable({
3559
3579
  });
3560
3580
  }
3561
3581
  return finalColumns;
3562
- }, [userColumns, actionColumn, index]);
3582
+ }, [userColumns, actionColumn, index, renderSubComponent, hasSubComponent]);
3563
3583
  const table = useReactTable2({
3564
3584
  data,
3565
3585
  columns,
@@ -7603,7 +7623,6 @@ var Guard = () => {
7603
7623
  url: "/users/me",
7604
7624
  v: 1
7605
7625
  });
7606
- console.log("res", res);
7607
7626
  login(res?.data);
7608
7627
  setIsLoggedIn(true);
7609
7628
  setIsFetched(true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "warqadui",
3
- "version": "0.0.53",
3
+ "version": "0.0.57",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",