ui-kit-ck-consultant 0.5.238 → 0.5.240

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,75 @@ 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
+ if (_this.props && _this.props.children) {
735
+ _this.getArray(_this.props.children).forEach(function (children) {
736
+ if (children.props && children.props.children) {
737
+ _this.getArray(children.props.children).forEach(function (line) {
738
+ if (line.props && line.props.children) {
739
+ _this.getArray(line.props.children).forEach(function (column) {
740
+ dataCSV += (column.props.children || '').toString() + ";";
741
+ });
742
+
743
+ dataCSV += '\n';
744
+ }
745
+ });
746
+ }
747
+ });
748
+ }
749
+
750
+ var link = document.createElement('a');
751
+ link.href = "data:text/csv;charset=utf-8," + encodeURIComponent(dataCSV);
752
+ link.download = _this.props.nameCSV || 'file.csv';
753
+ link.click();
754
+ };
755
+
756
+ return _this;
714
757
  }
715
758
 
716
759
  var _proto = Table.prototype;
717
760
 
718
761
  _proto.render = function render() {
719
- var _classNames;
762
+ var _classNames,
763
+ _this2 = this;
720
764
 
721
765
  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", {
766
+ return /*#__PURE__*/React.createElement(Fragment$1, null, this.props.isCSV ? /*#__PURE__*/React.createElement("div", {
767
+ className: "d-flex"
768
+ }, /*#__PURE__*/React.createElement(Button, {
769
+ text: "T\xE9l\xE9charger CSV",
770
+ className: "w-auto ml-auto mb-10",
771
+ onClick: function onClick() {
772
+ return _this2.getCSV();
773
+ }
774
+ })) : null, /*#__PURE__*/React.createElement("table", {
723
775
  className: tableClass,
724
776
  style: this.props.style
725
777
  }, this.props.children, this.props.empty ? /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
726
778
  colSpan: "100"
727
779
  }, /*#__PURE__*/React.createElement("div", {
728
780
  className: style$9.trEmpty
729
- }, this.props.empty)))) : false);
781
+ }, this.props.empty)))) : false));
730
782
  };
731
783
 
732
784
  return Table;