namirasoft-site-react 1.4.547 → 1.4.549

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.
@@ -565,7 +565,9 @@ export class NSTable<RowType> extends Component<NSTableProps<RowType>, NSTableSt
565
565
  let childrenMap = this.buildChildrenMap();
566
566
  let indexOfRow = new Map<RowType, number>();
567
567
  this.state.rows.forEach((r, i) => indexOfRow.set(r, i));
568
- let renderRow = (rowValue: RowType, rowIndex: number, depth: number, parentKey: string): React.ReactNode[] =>
568
+ let INDENT = 16;
569
+ let lineColor = "rgba(20, 27, 92, 0.35)";
570
+ let renderRow = (rowValue: RowType, rowIndex: number, depth: number, parentKey: string, ancestorHasNext: boolean[], isLastChild: boolean): React.ReactNode[] =>
569
571
  {
570
572
  let row = { index: rowIndex, value: rowValue };
571
573
  let rowKey = this.props.getRowKey(row);
@@ -620,55 +622,114 @@ export class NSTable<RowType> extends Component<NSTableProps<RowType>, NSTableSt
620
622
  data-label={`${column.text}: `}
621
623
  width={column.formatter.width}
622
624
  className='py-3'
625
+ style={isFirstDataColumn && hierarchical ? { overflow: "visible" } : undefined}
623
626
  onClick={(e) =>
624
627
  {
625
628
  onColumnClick(e, column);
626
629
  onCellClick(e, cell);
627
630
  }}
628
631
  >
629
- {isFirstDataColumn && hierarchical && (
630
- <span
631
- data-cell-type="tree-toggle"
632
+ {isFirstDataColumn && hierarchical ? (
633
+ <div
632
634
  style={{
633
- display: "inline-flex",
635
+ display: "flex",
634
636
  alignItems: "center",
635
- justifyContent: "center",
636
- marginRight: 6,
637
- paddingLeft: depth * 16,
638
637
  }}
639
- onClick={(e) => e.stopPropagation()}
640
638
  >
641
- {hasChildren ? (
642
- <button
643
- type="button"
644
- onClick={(e) =>
645
- {
646
- e.stopPropagation();
647
- this.toggleExpanded(rowKey);
648
- }}
649
- style={{
650
- width: 18,
651
- height: 18,
652
- lineHeight: "16px",
653
- padding: 0,
654
- border: "1px solid rgba(20, 27, 92, 0.4)",
655
- borderRadius: 3,
656
- background: "#fff",
657
- cursor: "pointer",
658
- fontSize: 14,
659
- fontWeight: "bold",
660
- color: "rgba(20, 27, 92, 1)",
661
- }}
662
- aria-label={expanded ? "Collapse" : "Expand"}
663
- >
664
- {expanded ? "−" : "+"}
665
- </button>
666
- ) : (
667
- <span style={{ display: "inline-block", width: 18, height: 18 }} />
668
- )}
669
- </span>
639
+ {Array.from({ length: depth }).map((_, i) =>
640
+ {
641
+ let isLastLevel = i === depth - 1;
642
+ let drawVerticalTop = i < depth - 1 ? ancestorHasNext[i] : true;
643
+ let drawVerticalBottom = i < depth - 1 ? ancestorHasNext[i] : !isLastChild;
644
+ let drawHorizontal = isLastLevel;
645
+ return (
646
+ <span
647
+ key={i}
648
+ style={{
649
+ position: "relative",
650
+ display: "inline-block",
651
+ width: INDENT,
652
+ alignSelf: "stretch",
653
+ flex: "0 0 auto",
654
+ }}
655
+ >
656
+ {drawVerticalTop && (
657
+ <span style={{
658
+ position: "absolute",
659
+ left: INDENT / 2,
660
+ top: -24,
661
+ height: "calc(50% + 24px)",
662
+ width: 1,
663
+ background: lineColor,
664
+ }} />
665
+ )}
666
+ {drawVerticalBottom && (
667
+ <span style={{
668
+ position: "absolute",
669
+ left: INDENT / 2,
670
+ top: "50%",
671
+ height: "calc(50% + 24px)",
672
+ width: 1,
673
+ background: lineColor,
674
+ }} />
675
+ )}
676
+ {drawHorizontal && (
677
+ <span style={{
678
+ position: "absolute",
679
+ left: INDENT / 2,
680
+ top: "50%",
681
+ width: INDENT / 2,
682
+ height: 1,
683
+ background: lineColor,
684
+ }} />
685
+ )}
686
+ </span>
687
+ );
688
+ })}
689
+ <span
690
+ data-cell-type="tree-toggle"
691
+ style={{
692
+ display: "inline-flex",
693
+ alignItems: "center",
694
+ justifyContent: "center",
695
+ marginRight: 6,
696
+ }}
697
+ onClick={(e) => e.stopPropagation()}
698
+ >
699
+ {hasChildren ? (
700
+ <button
701
+ type="button"
702
+ onClick={(e) =>
703
+ {
704
+ e.stopPropagation();
705
+ this.toggleExpanded(rowKey);
706
+ }}
707
+ style={{
708
+ width: 18,
709
+ height: 18,
710
+ lineHeight: "16px",
711
+ padding: 0,
712
+ border: "1px solid rgba(20, 27, 92, 0.4)",
713
+ borderRadius: 3,
714
+ background: "#fff",
715
+ cursor: "pointer",
716
+ fontSize: 14,
717
+ fontWeight: "bold",
718
+ color: "rgba(20, 27, 92, 1)",
719
+ }}
720
+ aria-label={expanded ? "Collapse" : "Expand"}
721
+ >
722
+ {expanded ? "−" : "+"}
723
+ </button>
724
+ ) : (
725
+ <span style={{ display: "inline-block", width: 18, height: 18 }} />
726
+ )}
727
+ </span>
728
+ <span>{cell.formatted ?? ""}</span>
729
+ </div>
730
+ ) : (
731
+ <span>{cell.formatted ?? ""}</span>
670
732
  )}
671
- <span>{cell.formatted ?? ""}</span>
672
733
  </td>
673
734
  );
674
735
  })
@@ -677,10 +738,12 @@ export class NSTable<RowType> extends Component<NSTableProps<RowType>, NSTableSt
677
738
  );
678
739
  if (hierarchical && hasChildren && expanded)
679
740
  {
680
- children.forEach((child) =>
741
+ let childAncestors = [...ancestorHasNext, !isLastChild];
742
+ children.forEach((child, ci2) =>
681
743
  {
682
744
  let ci = indexOfRow.get(child) ?? -1;
683
- renderRow(child, ci, depth + 1, reactKey).forEach(n => nodes.push(n));
745
+ let lastChild = ci2 === children.length - 1;
746
+ renderRow(child, ci, depth + 1, reactKey, childAncestors, lastChild).forEach(n => nodes.push(n));
684
747
  });
685
748
  }
686
749
  return nodes;
@@ -704,7 +767,7 @@ export class NSTable<RowType> extends Component<NSTableProps<RowType>, NSTableSt
704
767
  {
705
768
  topLevel = this.state.rows;
706
769
  }
707
- content = topLevel.flatMap((rowValue) => renderRow(rowValue, indexOfRow.get(rowValue) ?? 0, 0, ""));
770
+ content = topLevel.flatMap((rowValue, i) => renderRow(rowValue, indexOfRow.get(rowValue) ?? 0, 0, "", [], i === topLevel.length - 1));
708
771
  }
709
772
 
710
773
  let getSortSign = (column: TableColumnInfo) =>
@@ -790,8 +853,8 @@ export class NSTable<RowType> extends Component<NSTableProps<RowType>, NSTableSt
790
853
  </tbody>
791
854
 
792
855
  <tfoot className={!show_pagination && !show_button_panel ? Styles.padding_0 : ""}>
793
- <tr>
794
- <td colSpan={this.getColumns(true).length + (this.props.checkbox ? 1 : 0)}>
856
+ <tr className={Styles.ns_tfoot_row}>
857
+ <td className={Styles.ns_tfoot_cell}>
795
858
  <div
796
859
  ref={this.TableScrollbar_Ref}
797
860
  className={Styles.ns_table_scrollbar}