ui-kit-ck-consultant 0.6.11 → 0.6.13

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.
@@ -881,32 +881,55 @@ var Table = /*#__PURE__*/function (_React$Component) {
881
881
  };
882
882
 
883
883
  _this.getCSV = function (callback) {
884
+ extractText = function extractText(node) {
885
+ if (typeof node === 'string') return node.trim();
886
+ if (Array.isArray(node)) return node.map(_this.extractText).join(' ');
887
+ if (node.props && node.props.children) return _this.extractText(node.props.children);
888
+ return '';
889
+ };
890
+
884
891
  var dataCSV = '';
885
892
 
886
893
  if (_this.props && _this.props.children) {
887
- _this.getArray(_this.props.children).forEach(function (children) {
888
- if (children.props && children.props.children) {
889
- _this.getArray(children.props.children).forEach(function (line) {
890
- if (line.props && line.props.children) {
891
- _this.getArray(line.props.children).forEach(function (column) {
892
- if (column && column.props && column.props.children && column.props.children.props && column.props.children.props.children && column.props.children.props.children.props && column.props.children.props.children.props.children && column.props.children.props.children.props.children.props && column.props.children.props.children.props.children.props.text) {
893
- dataCSV += column.props.children.props.text + ";";
894
- } else if (column && column.props && column.props.children && column.props.children.props && column.props.children.props.children && column.props.children.props.children.props && column.props.children.props.children.props.text) {
895
- dataCSV += column.props.children.props.text + ";";
896
- } else if (column && column.props && column.props.children && column.props.children.props && column.props.children.props.text) {
897
- dataCSV += column.props.children.props.text + ";";
898
- } else if (column && column.props && column.props.children) {
899
- dataCSV += column.props.children.toString() + ";";
900
- } else {
901
- dataCSV += ';';
902
- }
903
- });
894
+ var table = _this.getArray(_this.props.children).find(function (child) {
895
+ return child.type === 'table';
896
+ });
897
+
898
+ if (table) {
899
+ var thead = _this.getArray(table.props.children).find(function (child) {
900
+ return child.type === 'thead';
901
+ });
902
+
903
+ var tbody = _this.getArray(table.props.children).find(function (child) {
904
+ return child.type === 'tbody';
905
+ });
904
906
 
905
- dataCSV += '\n';
907
+ if (thead) {
908
+ var headerRow = _this.getArray(thead.props.children).find(function (row) {
909
+ return row.type === 'tr';
910
+ });
911
+
912
+ if (headerRow) {
913
+ var headers = _this.getArray(headerRow.props.children).map(function (th) {
914
+ return th.props && th.props.children ? _this.extractText(th.props.children) : '';
915
+ }).join(';');
916
+
917
+ dataCSV += headers + '\n';
918
+ }
919
+ }
920
+
921
+ if (tbody) {
922
+ _this.getArray(tbody.props.children).forEach(function (row) {
923
+ if (row.type === 'tr') {
924
+ var rowData = _this.getArray(row.props.children).map(function (td) {
925
+ return td.props && td.props.children ? _this.extractText(td.props.children) : '';
926
+ }).join(';');
927
+
928
+ dataCSV += rowData + '\n';
906
929
  }
907
930
  });
908
931
  }
909
- });
932
+ }
910
933
  }
911
934
 
912
935
  var link = document.createElement('a');