fuse-importer 0.25.3 → 0.25.4

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.
@@ -59,6 +59,7 @@ var ImporterDropzone = function () {
59
59
  reader.onabort = function () { return console.log("file reading was aborted"); };
60
60
  reader.onerror = function () { return console.log("file reading has failed"); };
61
61
  reader.onload = function (event) {
62
+ var _a;
62
63
  var results = event.target.result;
63
64
  var getDataFromFile = function (fileResults) {
64
65
  var workBook = XLSX.read(fileResults, {
@@ -71,14 +72,9 @@ var ImporterDropzone = function () {
71
72
  return XLSX.utils.sheet_to_json(sheet, { header: 1, raw: false });
72
73
  };
73
74
  var fileData = getDataFromFile(results);
74
- var filteredArray = fileData
75
- .map(function (subArray) {
76
- return subArray.filter(function (value) { return value || value === 0 || value === false; });
77
- })
78
- .filter(function (subArray) { return subArray.length > 0; });
79
- var headersCount = filteredArray[0].length;
75
+ var headersCount = (_a = fileData[0]) === null || _a === void 0 ? void 0 : _a.length;
80
76
  if (validHeadersCount(headersCount)) {
81
- setUploadedData(filteredArray);
77
+ setUploadedData(fileData);
82
78
  }
83
79
  setIsUploading(false);
84
80
  };
@@ -81,11 +81,10 @@ export var ImporterContextProvider = function (_a) {
81
81
  ]);
82
82
  var uploadedDataHeaders = useMemo(function () {
83
83
  var _a;
84
- var initialParsing = (_a = uploadedData === null || uploadedData === void 0 ? void 0 : uploadedData[0]) === null || _a === void 0 ? void 0 : _a.map(function (ud) {
85
- return typeof ud === "number" ? ud.toString() : ud;
86
- });
87
- var onlyValidValues = initialParsing === null || initialParsing === void 0 ? void 0 : initialParsing.filter(function (val) { return val; });
88
- return (onlyValidValues === null || onlyValidValues === void 0 ? void 0 : onlyValidValues.length) ? onlyValidValues : [];
84
+ return uploadedData &&
85
+ ((_a = uploadedData[0]) === null || _a === void 0 ? void 0 : _a.map(function (ud) {
86
+ return typeof ud === "number" ? ud.toString() : ud;
87
+ }));
89
88
  }, [uploadedData]);
90
89
  useEffect(function () {
91
90
  if (!templateHeaderMatchings)
@@ -49,7 +49,7 @@ var ClickableArea = styled(Div)(function (_a) {
49
49
  var Autocomplete = function (_a) {
50
50
  var _b = _a.label, label = _b === void 0 ? null : _b, _c = _a.isDisabled, isDisabled = _c === void 0 ? false : _c, _d = _a.isInputDisabled, isInputDisabled = _d === void 0 ? false : _d, _e = _a.placeholder, placeholder = _e === void 0 ? "general:autocomplete.placeholder" : _e, value = _a.value, icon = _a.icon, onChange = _a.onChange, placement = _a.placement, options = _a.options, onToggle = _a.onToggle, id = _a.id, labelTooltip = _a.labelTooltip, props = __rest(_a, ["label", "isDisabled", "isInputDisabled", "placeholder", "value", "icon", "onChange", "placement", "options", "onToggle", "id", "labelTooltip"]);
51
51
  var _f = useState(false), updatedText = _f[0], setUpdatedText = _f[1];
52
- var selectedLabel = useMemo(function () { var _a; return ((_a = options.find(function (o) { return o.value === value; })) === null || _a === void 0 ? void 0 : _a.label) || ""; }, [value]);
52
+ var selectedLabel = useMemo(function () { var _a; return ((_a = options === null || options === void 0 ? void 0 : options.find(function (o) { return (o === null || o === void 0 ? void 0 : o.value) === value; })) === null || _a === void 0 ? void 0 : _a.label) || ""; }, [value]);
53
53
  var _g = useState(selectedLabel), text = _g[0], setText = _g[1];
54
54
  var _h = useState(false), isMenuOpen = _h[0], setIsMenuOpen = _h[1];
55
55
  var _j = useState(null), referenceElement = _j[0], setReferenceElement = _j[1];
@@ -70,7 +70,8 @@ var Autocomplete = function (_a) {
70
70
  onToggle(isMenuOpen);
71
71
  }, [isMenuOpen]);
72
72
  var onSelect = function (v) {
73
- setText(options.find(function (o) { return o.value === v; }).label);
73
+ var _a;
74
+ setText((_a = options.find(function (o) { return (o === null || o === void 0 ? void 0 : o.value) === v; })) === null || _a === void 0 ? void 0 : _a.label);
74
75
  onChange(v);
75
76
  setIsMenuOpen(false);
76
77
  };
@@ -91,7 +92,7 @@ var Autocomplete = function (_a) {
91
92
  setText(selectedLabel);
92
93
  setIsMenuOpen(false);
93
94
  }
94
- }, label: label, isDisabled: isDisabled || isInputDisabled, placeholder: t(placeholder), value: text, onChange: function (v) { return setText(v); }, icon: isDisabled ? null : inputIconUI, labelTooltip: labelTooltip }) })), !isDisabled && filteredOptions.length > 0 && (_jsx(SelectMenu, __assign({ referenceElement: referenceElement, placement: placement, isOpen: isMenuOpen, onClose: function () { return setIsMenuOpen(false); } }, { children: filteredOptions.map(function (o, index) { return (_jsx(Div, { children: _jsx(MenuItem, __assign({ id: id ? "".concat(id, "-option-").concat(o.label) : null, isSelected: value === o.value, onClick: function () { return onSelect(o.value); } }, { children: o.label })) }, index)); }) })))] })));
95
+ }, label: label, isDisabled: isDisabled || isInputDisabled, placeholder: t(placeholder), value: text, onChange: function (v) { return setText(v); }, icon: isDisabled ? null : inputIconUI, labelTooltip: labelTooltip }) })), !isDisabled && filteredOptions.length > 0 && (_jsx(SelectMenu, __assign({ referenceElement: referenceElement, placement: placement, isOpen: isMenuOpen, onClose: function () { return setIsMenuOpen(false); } }, { children: filteredOptions.map(function (o, index) { return (_jsx(Div, { children: _jsx(MenuItem, __assign({ id: id ? "".concat(id, "-option-").concat(o.label) : null, isSelected: value === (o === null || o === void 0 ? void 0 : o.value), onClick: function () { return onSelect(o === null || o === void 0 ? void 0 : o.value); } }, { children: o.label })) }, index)); }) })))] })));
95
96
  };
96
97
  var chevronDownIcon = (_jsx("svg", __assign({ width: "16", height: "9", viewBox: "0 0 16 9", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: _jsx("path", { d: "M14.9263 1L7.9631 7.96317L0.999928 1", stroke: "black", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })));
97
98
  var clearIcon = (_jsxs("svg", __assign({ width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [_jsx("path", { d: "M4 4L12.5161 12.5161", stroke: "#333333", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), _jsx("path", { d: "M4 12.5161L12.5161 3.99998", stroke: "#333333", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] })));