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