ui-kit-ck-consultant 0.5.237 → 0.5.239

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.
@@ -710,23 +710,69 @@ var Table = /*#__PURE__*/function (_React$Component) {
710
710
  _inheritsLoose(Table, _React$Component);
711
711
 
712
712
  function Table() {
713
- return _React$Component.apply(this, arguments) || this;
713
+ var _this;
714
+
715
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
716
+ args[_key] = arguments[_key];
717
+ }
718
+
719
+ _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
720
+
721
+ _this.getArray = function (data) {
722
+ if (data && Array.isArray(data)) {
723
+ return data;
724
+ } else if (data) {
725
+ return [data];
726
+ } else {
727
+ return [];
728
+ }
729
+ };
730
+
731
+ _this.getCSV = function () {
732
+ var dataCSV = '';
733
+
734
+ _this.getArray(_this.props.children).forEach(function (children) {
735
+ _this.getArray(children.props.children).forEach(function (line) {
736
+ _this.getArray(line.props.children).forEach(function (column) {
737
+ dataCSV += (column.props.children || '').toString() + ";";
738
+ });
739
+
740
+ dataCSV += '\n';
741
+ });
742
+ });
743
+
744
+ var link = document.createElement('a');
745
+ link.href = "data:text/csv;charset=utf-8," + encodeURIComponent(dataCSV);
746
+ link.download = 'file.csv';
747
+ link.click();
748
+ };
749
+
750
+ return _this;
714
751
  }
715
752
 
716
753
  var _proto = Table.prototype;
717
754
 
718
755
  _proto.render = function render() {
719
- var _classNames;
756
+ var _classNames,
757
+ _this2 = this;
720
758
 
721
759
  var tableClass = classNames$1((_classNames = {}, _classNames[style$9.table] = true, _classNames[style$9.tableEmpty] = !!this.props.empty, _classNames[style$9.radiusTopLeft] = !!this.props.radiusTopLeft, _classNames[style$9.radiusTopRight] = !!this.props.radiusTopRight, _classNames[this.props.className] = !!this.props.className, _classNames));
722
- return /*#__PURE__*/React.createElement("table", {
760
+ return /*#__PURE__*/React.createElement(Fragment$1, null, this.props.isCSV ? /*#__PURE__*/React.createElement("div", {
761
+ className: "d-flex"
762
+ }, /*#__PURE__*/React.createElement(Button, {
763
+ text: "T\xE9l\xE9charger CSV",
764
+ className: "w-auto ml-auto mb-10",
765
+ onClick: function onClick() {
766
+ return _this2.getCSV();
767
+ }
768
+ })) : null, /*#__PURE__*/React.createElement("table", {
723
769
  className: tableClass,
724
770
  style: this.props.style
725
771
  }, this.props.children, this.props.empty ? /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
726
772
  colSpan: "100"
727
773
  }, /*#__PURE__*/React.createElement("div", {
728
774
  className: style$9.trEmpty
729
- }, this.props.empty)))) : false);
775
+ }, this.props.empty)))) : false));
730
776
  };
731
777
 
732
778
  return Table;