@lendi-ui/auto-complete
Advanced tools
Comparing version 5.2.7 to 5.2.8
## [5.1.0] 2020-03-17 [FUNNEL-1124]( | ||
## 5.2.8 | ||
### Patch Changes | ||
- 1b8b0ce9: FUNNEL-2446 | Move to Experian address service (support postal address + street suffix + more robust address lookup) | ||
## 5.2.7 | ||
@@ -4,0 +10,0 @@ |
@@ -24,134 +24,134 @@ 'use strict'; | ||
function _templateObject12() { | ||
var data = _taggedTemplateLiteral(["\n top: ", ";\n width: ", ";\n height: ", ";\n "]); | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
_templateObject12 = function _templateObject12() { | ||
return data; | ||
}; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return data; | ||
} | ||
function _templateObject11() { | ||
var data = _taggedTemplateLiteral(["\n top: ", ";\n width: ", ";\n height: ", ";\n "]); | ||
_templateObject11 = function _templateObject11() { | ||
return data; | ||
return target; | ||
}; | ||
return data; | ||
return _extends.apply(this, arguments); | ||
} | ||
function _templateObject10() { | ||
var data = _taggedTemplateLiteral(["\n top: ", ";\n width: ", ";\n height: ", ";\n "]); | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {}; | ||
var target = {}; | ||
var sourceKeys = Object.keys(source); | ||
var key, i; | ||
_templateObject10 = function _templateObject10() { | ||
return data; | ||
}; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
target[key] = source[key]; | ||
} | ||
return data; | ||
return target; | ||
} | ||
function _templateObject9() { | ||
var data = _taggedTemplateLiteral(["\n ", ";\n"]); | ||
function _objectWithoutProperties(source, excluded) { | ||
if (source == null) return {}; | ||
var target = _objectWithoutPropertiesLoose(source, excluded); | ||
var key, i; | ||
_templateObject9 = function _templateObject9() { | ||
return data; | ||
}; | ||
if (Object.getOwnPropertySymbols) { | ||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source); | ||
return data; | ||
} | ||
for (i = 0; i < sourceSymbolKeys.length; i++) { | ||
key = sourceSymbolKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; | ||
target[key] = source[key]; | ||
} | ||
} | ||
function _templateObject8() { | ||
var data = _taggedTemplateLiteral(["\n ", ";\n"]); | ||
_templateObject8 = function _templateObject8() { | ||
return data; | ||
}; | ||
return data; | ||
return target; | ||
} | ||
function _templateObject7() { | ||
var data = _taggedTemplateLiteral(["\n cursor: pointer;\n"]); | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
try { | ||
var info = gen[key](arg); | ||
var value = info.value; | ||
} catch (error) { | ||
reject(error); | ||
return; | ||
} | ||
_templateObject7 = function _templateObject7() { | ||
return data; | ||
}; | ||
return data; | ||
if (info.done) { | ||
resolve(value); | ||
} else { | ||
Promise.resolve(value).then(_next, _throw); | ||
} | ||
} | ||
function _templateObject6() { | ||
var data = _taggedTemplateLiteral(["\n ", ";\n"]); | ||
function _asyncToGenerator(fn) { | ||
return function () { | ||
var self = this, | ||
args = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
_templateObject6 = function _templateObject6() { | ||
return data; | ||
}; | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
} | ||
return data; | ||
} | ||
function _throw(err) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
} | ||
function _templateObject5() { | ||
var data = _taggedTemplateLiteral(["\n ", ";\n min-width: 110px;\n"]); | ||
_templateObject5 = function _templateObject5() { | ||
return data; | ||
_next(undefined); | ||
}); | ||
}; | ||
return data; | ||
} | ||
function _templateObject4() { | ||
var data = _taggedTemplateLiteral(["\n background-color: initial;\n color: initial;\n "]); | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
_templateObject4 = function _templateObject4() { | ||
return data; | ||
}; | ||
return data; | ||
return obj; | ||
} | ||
function _templateObject3() { | ||
var data = _taggedTemplateLiteral(["\n ", ";\n ", ";\n "]); | ||
_templateObject3 = function _templateObject3() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _templateObject2() { | ||
var data = _taggedTemplateLiteral(["\n width: auto;\n word-wrap: break-word;\n list-style: none;\n ", ";\n ", ";\n\n font-family: ", ";\n :hover {\n ", ";\n ", " cursor: pointer;\n font-weight: 700;\n }\n\n ", ";\n"]); | ||
_templateObject2 = function _templateObject2() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _templateObject() { | ||
var data = _taggedTemplateLiteral(["\n ", ";\n ", ";\n ", ";\n border-radius: ", ";\n max-height: 192px;\n position: absolute;\n ", ";\n z-index: 1;\n ", ";\n overflow: auto;\n outline: none;\n width: ", ";\n"]); | ||
_templateObject = function _templateObject() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } | ||
var AutoCompleteList = styled__default['default'].ul(_templateObject(), spacing.m('nil'), spacing.py('xxs'), spacing.px('nil'), theme.select('borderRadius'), color.bg('shade.0'), depth.depth(1), props => props.customWidth ? props.customWidth + 'px' : 'auto'); | ||
var AutoCompleteListItem = styled__default['default'].li(_templateObject2(), spacing.px('sm'), spacing.py('xs'), theme.select('typography.body.fontFamily'), color.bg('secondary.500'), color.fg('shade.0'), (_ref) => { | ||
var AutoCompleteList = styled__default['default'].ul.withConfig({ | ||
displayName: "indexstyle__AutoCompleteList", | ||
componentId: "lui__sc-11thbm7-0" | ||
})(["", ";", ";", ";border-radius:", ";max-height:192px;position:absolute;", ";z-index:1;", ";overflow:auto;outline:none;width:", ";"], spacing.m('nil'), spacing.py('xxs'), spacing.px('nil'), theme.select('borderRadius'), color.bg('shade.0'), depth.depth(1), props => props.customWidth ? props.customWidth + 'px' : 'auto'); | ||
var AutoCompleteListItem = styled__default['default'].li.withConfig({ | ||
displayName: "indexstyle__AutoCompleteListItem", | ||
componentId: "lui__sc-11thbm7-1" | ||
})(["width:auto;word-wrap:break-word;list-style:none;", ";", ";font-family:", ";:hover{", ";", " cursor:pointer;font-weight:700;}", ";"], spacing.px('sm'), spacing.py('xs'), theme.select('typography.body.fontFamily'), color.bg('secondary.500'), color.fg('shade.0'), (_ref) => { | ||
var { | ||
isActive | ||
} = _ref; | ||
return isActive ? styled.css(_templateObject3(), color.bg('secondary.500'), color.fg('shade.0')) : styled.css(_templateObject4()); | ||
return isActive ? styled.css(["", ";", ";"], color.bg('secondary.500'), color.fg('shade.0')) : styled.css(["background-color:initial;color:initial;"]); | ||
}); | ||
var AutoCompleteWrapper = styled__default['default'].div(_templateObject5(), utils.normalise); | ||
var AfterIconWrapper = styled__default['default'].span(_templateObject6(), spacing.p('sm')); | ||
var CloseWrapper = styled__default['default'].span(_templateObject7()); | ||
var SpinnerWrapper = styled__default['default'](Spinner__default['default'])(_templateObject8(), (_ref2) => { | ||
var AutoCompleteWrapper = styled__default['default'].div.withConfig({ | ||
displayName: "indexstyle__AutoCompleteWrapper", | ||
componentId: "lui__sc-11thbm7-2" | ||
})(["", ";min-width:110px;"], utils.normalise); | ||
var AfterIconWrapper = styled__default['default'].span.withConfig({ | ||
displayName: "indexstyle__AfterIconWrapper", | ||
componentId: "lui__sc-11thbm7-3" | ||
})(["", ";"], spacing.p('sm')); | ||
var CloseWrapper = styled__default['default'].span.withConfig({ | ||
displayName: "indexstyle__CloseWrapper", | ||
componentId: "lui__sc-11thbm7-4" | ||
})(["cursor:pointer;"]); | ||
var SpinnerWrapper = styled__default['default'](Spinner__default['default']).withConfig({ | ||
displayName: "indexstyle__SpinnerWrapper", | ||
componentId: "lui__sc-11thbm7-5" | ||
})(["", ";"], (_ref2) => { | ||
var { | ||
@@ -162,3 +162,6 @@ size | ||
}); | ||
var CloseIcon = styled__default['default'](Close__default['default'])(_templateObject9(), (_ref3) => { | ||
var CloseIcon = styled__default['default'](Close__default['default']).withConfig({ | ||
displayName: "indexstyle__CloseIcon", | ||
componentId: "lui__sc-11thbm7-6" | ||
})(["", ";"], (_ref3) => { | ||
var { | ||
@@ -173,9 +176,9 @@ size | ||
case 'sm': | ||
return styled.css(_templateObject10(), utils.deriveSize(0.35), utils.deriveSize(1), utils.deriveSize(1)); | ||
return styled.css(["top:", ";width:", ";height:", ";"], utils.deriveSize(0.35), utils.deriveSize(1), utils.deriveSize(1)); | ||
case 'md': | ||
return styled.css(_templateObject11(), utils.deriveSize(0.45), utils.deriveSize(1.25), utils.deriveSize(1.25)); | ||
return styled.css(["top:", ";width:", ";height:", ";"], utils.deriveSize(0.45), utils.deriveSize(1.25), utils.deriveSize(1.25)); | ||
case 'lg': | ||
return styled.css(_templateObject12(), utils.deriveSize(0.35), utils.deriveSize(1.75), utils.deriveSize(1.75)); | ||
return styled.css(["top:", ";width:", ";height:", ";"], utils.deriveSize(0.35), utils.deriveSize(1.75), utils.deriveSize(1.75)); | ||
@@ -227,6 +230,2 @@ default: | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
function extractData(_x, _x2) { | ||
@@ -293,3 +292,7 @@ return _extractData.apply(this, arguments); | ||
function transformedItem(item) { | ||
function transformedItem() { | ||
var item = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { | ||
label: '', | ||
value: '' | ||
}; | ||
return { | ||
@@ -302,13 +305,2 @@ label: item.label.replace(/<\/?[^>]+(>|$)/g, ''), | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
function _asyncToGenerator$1(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var DEBOUNCE_WAIT = 300; | ||
@@ -350,3 +342,3 @@ var WINDOW_RESIZE_WAIT = 100; | ||
_defineProperty(this, "getFilteredData", /*#__PURE__*/function () { | ||
var _ref = _asyncToGenerator$1(function* (userInput) { | ||
var _ref = _asyncToGenerator(function* (userInput) { | ||
var { | ||
@@ -569,9 +561,2 @@ dataSource, | ||
function _extends$1() { _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); } | ||
function _objectWithoutProperties$1(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose$1(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose$1(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
class AutoCompleteStateless extends React.Component { | ||
@@ -581,7 +566,7 @@ constructor(_props) { | ||
_defineProperty$1(this, "inputWrapper", /*#__PURE__*/React.createRef()); | ||
_defineProperty(this, "inputWrapper", /*#__PURE__*/React.createRef()); | ||
_defineProperty$1(this, "menuContainerRef", /*#__PURE__*/React.createRef()); | ||
_defineProperty(this, "menuContainerRef", /*#__PURE__*/React.createRef()); | ||
_defineProperty$1(this, "state", { | ||
_defineProperty(this, "state", { | ||
isOpen: false, | ||
@@ -592,3 +577,3 @@ highlightedIndex: null, | ||
_defineProperty$1(this, "calcInputWidth", () => { | ||
_defineProperty(this, "calcInputWidth", () => { | ||
if (this.inputWrapper.current && this.inputWrapper.current.firstElementChild) { | ||
@@ -601,3 +586,3 @@ this.setState({ | ||
_defineProperty$1(this, "renderComposeMenu", children => { | ||
_defineProperty(this, "renderComposeMenu", children => { | ||
return /*#__PURE__*/React.createElement(AutoCompleteList, { | ||
@@ -609,3 +594,3 @@ customWidth: this.state.menuWidth, | ||
_defineProperty$1(this, "renderItem", (item, isHighlighted, index) => /*#__PURE__*/React.createElement(AutoCompleteListItem, { | ||
_defineProperty(this, "renderItem", (item, isHighlighted, index) => /*#__PURE__*/React.createElement(AutoCompleteListItem, { | ||
isActive: index === this.state.highlightedIndex, | ||
@@ -621,3 +606,3 @@ className: "".concat(isHighlighted ? 'selectedItem' : ''), | ||
_defineProperty$1(this, "renderAfterIcon", () => /*#__PURE__*/React.createElement(AfterIconWrapper, null, this.props.isLoading ? /*#__PURE__*/React.createElement(SpinnerWrapper, { | ||
_defineProperty(this, "renderAfterIcon", () => /*#__PURE__*/React.createElement(AfterIconWrapper, null, this.props.isLoading ? /*#__PURE__*/React.createElement(SpinnerWrapper, { | ||
size: this.props.size, | ||
@@ -632,3 +617,3 @@ variant: "dark" | ||
_defineProperty$1(this, "handleChange", event => { | ||
_defineProperty(this, "handleChange", event => { | ||
var { | ||
@@ -640,3 +625,3 @@ onChange = () => {} | ||
_defineProperty$1(this, "handleInputBlur", event => { | ||
_defineProperty(this, "handleInputBlur", event => { | ||
var selectCallback; | ||
@@ -667,3 +652,3 @@ var { | ||
_defineProperty$1(this, "selectItemFromMouse", item => { | ||
_defineProperty(this, "selectItemFromMouse", item => { | ||
this.setState({ | ||
@@ -677,3 +662,3 @@ isOpen: false, | ||
_defineProperty$1(this, "clearInput", () => { | ||
_defineProperty(this, "clearInput", () => { | ||
var { | ||
@@ -689,3 +674,3 @@ onReset = () => {} | ||
_defineProperty$1(this, "getFilteredItems", props => { | ||
_defineProperty(this, "getFilteredItems", props => { | ||
var items = props.dataSource; // some extra processing can be done here like make the input bold in the selections. | ||
@@ -697,3 +682,3 @@ | ||
_defineProperty$1(this, "isOpen", () => { | ||
_defineProperty(this, "isOpen", () => { | ||
return 'open' in this.props ? this.props.open : this.state.isOpen; | ||
@@ -845,7 +830,7 @@ }); | ||
} = _this$props, | ||
inputProps = _objectWithoutProperties$1(_this$props, ["dataSource", "value", "onChange", "placeholder", "size", "onSelectItem", "onMenuVisibilityChange"]); | ||
inputProps = _objectWithoutProperties(_this$props, ["dataSource", "value", "onChange", "placeholder", "size", "onSelectItem", "onMenuVisibilityChange"]); | ||
return /*#__PURE__*/React.createElement(AutoCompleteWrapper, { | ||
ref: this.inputWrapper | ||
}, /*#__PURE__*/React.createElement(textInput.Input, _extends$1({}, inputProps, { | ||
}, /*#__PURE__*/React.createElement(textInput.Input, _extends({}, inputProps, { | ||
size: size, | ||
@@ -865,5 +850,5 @@ placeholder: placeholder, | ||
_defineProperty$1(AutoCompleteStateless, "WINDOW_RESIZE_WAIT", 100); | ||
_defineProperty(AutoCompleteStateless, "WINDOW_RESIZE_WAIT", 100); | ||
exports.AutoComplete = AutoComplete; | ||
exports.AutoCompleteStateless = AutoCompleteStateless; |
@@ -17,113 +17,103 @@ "use strict"; | ||
function _templateObject12() { | ||
var data = _taggedTemplateLiteral([ "\n top: ", ";\n width: ", ";\n height: ", ";\n " ]); | ||
return _templateObject12 = function() { | ||
return data; | ||
}, data; | ||
function _extends() { | ||
return (_extends = Object.assign || function(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]); | ||
} | ||
return target; | ||
}).apply(this, arguments); | ||
} | ||
function _templateObject11() { | ||
var data = _taggedTemplateLiteral([ "\n top: ", ";\n width: ", ";\n height: ", ";\n " ]); | ||
return _templateObject11 = function() { | ||
return data; | ||
}, data; | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (null == source) return {}; | ||
var key, i, target = {}, sourceKeys = Object.keys(source); | ||
for (i = 0; i < sourceKeys.length; i++) key = sourceKeys[i], excluded.indexOf(key) >= 0 || (target[key] = source[key]); | ||
return target; | ||
} | ||
function _templateObject10() { | ||
var data = _taggedTemplateLiteral([ "\n top: ", ";\n width: ", ";\n height: ", ";\n " ]); | ||
return _templateObject10 = function() { | ||
return data; | ||
}, data; | ||
function _objectWithoutProperties(source, excluded) { | ||
if (null == source) return {}; | ||
var key, i, target = _objectWithoutPropertiesLoose(source, excluded); | ||
if (Object.getOwnPropertySymbols) { | ||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source); | ||
for (i = 0; i < sourceSymbolKeys.length; i++) key = sourceSymbolKeys[i], excluded.indexOf(key) >= 0 || Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]); | ||
} | ||
return target; | ||
} | ||
function _templateObject9() { | ||
var data = _taggedTemplateLiteral([ "\n ", ";\n" ]); | ||
return _templateObject9 = function() { | ||
return data; | ||
}, data; | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
try { | ||
var info = gen[key](arg), value = info.value; | ||
} catch (error) { | ||
return void reject(error); | ||
} | ||
info.done ? resolve(value) : Promise.resolve(value).then(_next, _throw); | ||
} | ||
function _templateObject8() { | ||
var data = _taggedTemplateLiteral([ "\n ", ";\n" ]); | ||
return _templateObject8 = function() { | ||
return data; | ||
}, data; | ||
function _asyncToGenerator(fn) { | ||
return function() { | ||
var self = this, args = arguments; | ||
return new Promise((function(resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
} | ||
function _throw(err) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
} | ||
_next(void 0); | ||
})); | ||
}; | ||
} | ||
function _templateObject7() { | ||
var data = _taggedTemplateLiteral([ "\n cursor: pointer;\n" ]); | ||
return _templateObject7 = function() { | ||
return data; | ||
}, data; | ||
function _defineProperty(obj, key, value) { | ||
return key in obj ? Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0 | ||
}) : obj[key] = value, obj; | ||
} | ||
function _templateObject6() { | ||
var data = _taggedTemplateLiteral([ "\n ", ";\n" ]); | ||
return _templateObject6 = function() { | ||
return data; | ||
}, data; | ||
} | ||
function _templateObject5() { | ||
var data = _taggedTemplateLiteral([ "\n ", ";\n min-width: 110px;\n" ]); | ||
return _templateObject5 = function() { | ||
return data; | ||
}, data; | ||
} | ||
function _templateObject4() { | ||
var data = _taggedTemplateLiteral([ "\n background-color: initial;\n color: initial;\n " ]); | ||
return _templateObject4 = function() { | ||
return data; | ||
}, data; | ||
} | ||
function _templateObject3() { | ||
var data = _taggedTemplateLiteral([ "\n ", ";\n ", ";\n " ]); | ||
return _templateObject3 = function() { | ||
return data; | ||
}, data; | ||
} | ||
function _templateObject2() { | ||
var data = _taggedTemplateLiteral([ "\n width: auto;\n word-wrap: break-word;\n list-style: none;\n ", ";\n ", ";\n\n font-family: ", ";\n :hover {\n ", ";\n ", " cursor: pointer;\n font-weight: 700;\n }\n\n ", ";\n" ]); | ||
return _templateObject2 = function() { | ||
return data; | ||
}, data; | ||
} | ||
function _templateObject() { | ||
var data = _taggedTemplateLiteral([ "\n ", ";\n ", ";\n ", ";\n border-radius: ", ";\n max-height: 192px;\n position: absolute;\n ", ";\n z-index: 1;\n ", ";\n overflow: auto;\n outline: none;\n width: ", ";\n" ]); | ||
return _templateObject = function() { | ||
return data; | ||
}, data; | ||
} | ||
function _taggedTemplateLiteral(strings, raw) { | ||
return raw || (raw = strings.slice(0)), Object.freeze(Object.defineProperties(strings, { | ||
raw: { | ||
value: Object.freeze(raw) | ||
} | ||
})); | ||
} | ||
var AutoCompleteList = styled__default.default.ul(_templateObject(), spacing.m("nil"), spacing.py("xxs"), spacing.px("nil"), theme.select("borderRadius"), color.bg("shade.0"), depth.depth(1), props => props.customWidth ? props.customWidth + "px" : "auto"), AutoCompleteListItem = styled__default.default.li(_templateObject2(), spacing.px("sm"), spacing.py("xs"), theme.select("typography.body.fontFamily"), color.bg("secondary.500"), color.fg("shade.0"), _ref => { | ||
var AutoCompleteList = styled__default.default.ul.withConfig({ | ||
displayName: "indexstyle__AutoCompleteList", | ||
componentId: "lui__sc-11thbm7-0" | ||
})([ "", ";", ";", ";border-radius:", ";max-height:192px;position:absolute;", ";z-index:1;", ";overflow:auto;outline:none;width:", ";" ], spacing.m("nil"), spacing.py("xxs"), spacing.px("nil"), theme.select("borderRadius"), color.bg("shade.0"), depth.depth(1), (props => props.customWidth ? props.customWidth + "px" : "auto")), AutoCompleteListItem = styled__default.default.li.withConfig({ | ||
displayName: "indexstyle__AutoCompleteListItem", | ||
componentId: "lui__sc-11thbm7-1" | ||
})([ "width:auto;word-wrap:break-word;list-style:none;", ";", ";font-family:", ";:hover{", ";", " cursor:pointer;font-weight:700;}", ";" ], spacing.px("sm"), spacing.py("xs"), theme.select("typography.body.fontFamily"), color.bg("secondary.500"), color.fg("shade.0"), (_ref => { | ||
var {isActive: isActive} = _ref; | ||
return isActive ? styled.css(_templateObject3(), color.bg("secondary.500"), color.fg("shade.0")) : styled.css(_templateObject4()); | ||
}), AutoCompleteWrapper = styled__default.default.div(_templateObject5(), utils.normalise), AfterIconWrapper = styled__default.default.span(_templateObject6(), spacing.p("sm")), CloseWrapper = styled__default.default.span(_templateObject7()), SpinnerWrapper = styled__default.default(Spinner__default.default)(_templateObject8(), _ref2 => { | ||
return isActive ? styled.css([ "", ";", ";" ], color.bg("secondary.500"), color.fg("shade.0")) : styled.css([ "background-color:initial;color:initial;" ]); | ||
})), AutoCompleteWrapper = styled__default.default.div.withConfig({ | ||
displayName: "indexstyle__AutoCompleteWrapper", | ||
componentId: "lui__sc-11thbm7-2" | ||
})([ "", ";min-width:110px;" ], utils.normalise), AfterIconWrapper = styled__default.default.span.withConfig({ | ||
displayName: "indexstyle__AfterIconWrapper", | ||
componentId: "lui__sc-11thbm7-3" | ||
})([ "", ";" ], spacing.p("sm")), CloseWrapper = styled__default.default.span.withConfig({ | ||
displayName: "indexstyle__CloseWrapper", | ||
componentId: "lui__sc-11thbm7-4" | ||
})([ "cursor:pointer;" ]), SpinnerWrapper = styled__default.default(Spinner__default.default).withConfig({ | ||
displayName: "indexstyle__SpinnerWrapper", | ||
componentId: "lui__sc-11thbm7-5" | ||
})([ "", ";" ], (_ref2 => { | ||
var {size: size} = _ref2; | ||
return iconBySizeMixin(size); | ||
}), CloseIcon = styled__default.default(Close__default.default)(_templateObject9(), _ref3 => { | ||
})), CloseIcon = styled__default.default(Close__default.default).withConfig({ | ||
displayName: "indexstyle__CloseIcon", | ||
componentId: "lui__sc-11thbm7-6" | ||
})([ "", ";" ], (_ref3 => { | ||
var {size: size} = _ref3; | ||
return iconBySizeMixin(size); | ||
}), iconBySizeMixin = size => breakpoint.map(size, val => { | ||
})), iconBySizeMixin = size => breakpoint.map(size, (val => { | ||
switch (val) { | ||
case "sm": | ||
return styled.css(_templateObject10(), utils.deriveSize(.35), utils.deriveSize(1), utils.deriveSize(1)); | ||
return styled.css([ "top:", ";width:", ";height:", ";" ], utils.deriveSize(.35), utils.deriveSize(1), utils.deriveSize(1)); | ||
case "md": | ||
return styled.css(_templateObject11(), utils.deriveSize(.45), utils.deriveSize(1.25), utils.deriveSize(1.25)); | ||
return styled.css([ "top:", ";width:", ";height:", ";" ], utils.deriveSize(.45), utils.deriveSize(1.25), utils.deriveSize(1.25)); | ||
case "lg": | ||
return styled.css(_templateObject12(), utils.deriveSize(.35), utils.deriveSize(1.75), utils.deriveSize(1.75)); | ||
return styled.css([ "top:", ";width:", ";height:", ";" ], utils.deriveSize(.35), utils.deriveSize(1.75), utils.deriveSize(1.75)); | ||
@@ -133,3 +123,3 @@ default: | ||
} | ||
}), KEY_UP = "ArrowUp", KEY_DOWN = "ArrowDown", KEY_ENTER = "Enter", KEY_TAB = "Tab", KEY_ESCAPE = "Escape"; | ||
})), KEY_UP = "ArrowUp", KEY_DOWN = "ArrowDown", KEY_ENTER = "Enter", KEY_TAB = "Tab", KEY_ESCAPE = "Escape"; | ||
@@ -145,3 +135,3 @@ class AutoCompleteMenuList extends React.Component { | ||
ref: innerRef | ||
}, filteredDataSource.map((option, index) => React.createElement(AutoCompleteListItem, { | ||
}, filteredDataSource.map(((option, index) => React.createElement(AutoCompleteListItem, { | ||
key: index, | ||
@@ -158,31 +148,6 @@ tabIndex: index, | ||
} | ||
})))); | ||
}))))); | ||
} | ||
} | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
try { | ||
var info = gen[key](arg), value = info.value; | ||
} catch (error) { | ||
return void reject(error); | ||
} | ||
info.done ? resolve(value) : Promise.resolve(value).then(_next, _throw); | ||
} | ||
function _asyncToGenerator(fn) { | ||
return function() { | ||
var self = this, args = arguments; | ||
return new Promise((function(resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
} | ||
function _throw(err) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
} | ||
_next(void 0); | ||
})); | ||
}; | ||
} | ||
function extractData(_x, _x2) { | ||
@@ -194,3 +159,3 @@ return _extractData.apply(this, arguments); | ||
return (_extractData = _asyncToGenerator((function*(userInput, dataSource) { | ||
return "" !== userInput ? (Array.isArray(dataSource) ? dataSource.filter(data => data.label.toLowerCase().indexOf(userInput.toLowerCase()) > -1) : yield dataSource(userInput)).map(d => makeInputKeyBold(d, userInput.toLowerCase())) : []; | ||
return "" !== userInput ? (Array.isArray(dataSource) ? dataSource.filter((data => data.label.toLowerCase().indexOf(userInput.toLowerCase()) > -1)) : yield dataSource(userInput)).map((d => makeInputKeyBold(d, userInput.toLowerCase()))) : []; | ||
}))).apply(this, arguments); | ||
@@ -217,3 +182,7 @@ } | ||
function transformedItem(item) { | ||
function transformedItem() { | ||
var item = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { | ||
label: "", | ||
value: "" | ||
}; | ||
return { | ||
@@ -225,63 +194,2 @@ label: item.label.replace(/<\/?[^>]+(>|$)/g, ""), | ||
function _extends() { | ||
return (_extends = Object.assign || function(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]); | ||
} | ||
return target; | ||
}).apply(this, arguments); | ||
} | ||
function _objectWithoutProperties(source, excluded) { | ||
if (null == source) return {}; | ||
var key, i, target = _objectWithoutPropertiesLoose(source, excluded); | ||
if (Object.getOwnPropertySymbols) { | ||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source); | ||
for (i = 0; i < sourceSymbolKeys.length; i++) key = sourceSymbolKeys[i], excluded.indexOf(key) >= 0 || Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]); | ||
} | ||
return target; | ||
} | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (null == source) return {}; | ||
var key, i, target = {}, sourceKeys = Object.keys(source); | ||
for (i = 0; i < sourceKeys.length; i++) key = sourceKeys[i], excluded.indexOf(key) >= 0 || (target[key] = source[key]); | ||
return target; | ||
} | ||
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) { | ||
try { | ||
var info = gen[key](arg), value = info.value; | ||
} catch (error) { | ||
return void reject(error); | ||
} | ||
info.done ? resolve(value) : Promise.resolve(value).then(_next, _throw); | ||
} | ||
function _asyncToGenerator$1(fn) { | ||
return function() { | ||
var self = this, args = arguments; | ||
return new Promise((function(resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
function _next(value) { | ||
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value); | ||
} | ||
function _throw(err) { | ||
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err); | ||
} | ||
_next(void 0); | ||
})); | ||
}; | ||
} | ||
function _defineProperty(obj, key, value) { | ||
return key in obj ? Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0 | ||
}) : obj[key] = value, obj; | ||
} | ||
var DEBOUNCE_WAIT = 300, WINDOW_RESIZE_WAIT = 100; | ||
@@ -300,3 +208,3 @@ | ||
}), _defineProperty(this, "menuContainerRef", React.createRef()), _defineProperty(this, "inputWrapper", React.createRef()), | ||
_defineProperty(this, "calcInputWidth", () => { | ||
_defineProperty(this, "calcInputWidth", (() => { | ||
if (this.inputWrapper && this.inputWrapper.current) { | ||
@@ -308,4 +216,4 @@ var inputChild = this.inputWrapper.current.firstElementChild; | ||
} | ||
}), _defineProperty(this, "getFilteredData", function() { | ||
var _ref = _asyncToGenerator$1((function*(userInput) { | ||
})), _defineProperty(this, "getFilteredData", function() { | ||
var _ref = _asyncToGenerator((function*(userInput) { | ||
var {dataSource: dataSource, backupOption: backupOption} = _this.props, filteredDataSource = yield extractData(userInput, dataSource); | ||
@@ -323,3 +231,3 @@ !filteredDataSource.length && backupOption && filteredDataSource.push(backupOption), | ||
}; | ||
}()), _defineProperty(this, "onHoverOff", e => { | ||
}()), _defineProperty(this, "onHoverOff", (e => { | ||
var theClickedElement = e.target.parentElement; | ||
@@ -329,3 +237,3 @@ this.inputWrapper.current.firstElementChild !== theClickedElement && this.setState({ | ||
}); | ||
}), _defineProperty(this, "renderAfterIcon", () => React.createElement(AfterIconWrapper, null, this.state.isLoading ? React.createElement(SpinnerWrapper, { | ||
})), _defineProperty(this, "renderAfterIcon", (() => React.createElement(AfterIconWrapper, null, this.state.isLoading ? React.createElement(SpinnerWrapper, { | ||
size: this.props.size, | ||
@@ -338,3 +246,3 @@ variant: "dark" | ||
size: this.props.size | ||
})))), _defineProperty(this, "listComponent", () => { | ||
}))))), _defineProperty(this, "listComponent", (() => { | ||
if (this.state.userInput && !this.state.isLoading && this.state.filteredDataSource.length > 0) return React.createElement(AutoCompleteMenuList, { | ||
@@ -349,3 +257,3 @@ onSelectItem: this.onSelectItem, | ||
}); | ||
}), _defineProperty(this, "onSelectItem", item => { | ||
})), _defineProperty(this, "onSelectItem", (item => { | ||
var {onSelectItem: onSelectItem = (() => {})} = this.props, textWithoutHTMLJunk = transformedItem(item).label; | ||
@@ -358,3 +266,3 @@ onSelectItem(transformedItem(item)), this.setState({ | ||
}); | ||
}), _defineProperty(this, "onChange", event => { | ||
})), _defineProperty(this, "onChange", (event => { | ||
event.persist(); | ||
@@ -368,4 +276,4 @@ var {onChange: onChange = (() => {})} = this.props; | ||
filteredDataSource: [] | ||
}, () => this.getFilteredData(event.target.value)); | ||
}), _defineProperty(this, "onKeyDown", event => { | ||
}, (() => this.getFilteredData(event.target.value))); | ||
})), _defineProperty(this, "onKeyDown", (event => { | ||
var {activeSelection: activeSelection, filteredDataSource: filteredDataSource} = this.state, {onSelectItem: onSelectItem = (() => {})} = this.props; | ||
@@ -379,5 +287,5 @@ switch (event.key) { | ||
showList: !1 | ||
}, () => { | ||
}, (() => { | ||
onSelectItem(transformedItem(filteredDataSource[activeSelection])); | ||
}); | ||
})); | ||
@@ -408,3 +316,3 @@ case KEY_UP: | ||
} | ||
}), _defineProperty(this, "clearInput", () => { | ||
})), _defineProperty(this, "clearInput", (() => { | ||
var {onSelectItem: onSelectItem = (() => {})} = this.props; | ||
@@ -416,7 +324,7 @@ return this.setState({ | ||
showList: !1 | ||
}, () => onSelectItem({ | ||
}, (() => onSelectItem({ | ||
label: "", | ||
value: "" | ||
})); | ||
}), this.getFilteredData = lodash.debounce(this.getFilteredData, DEBOUNCE_WAIT), | ||
}))); | ||
})), this.getFilteredData = lodash.debounce(this.getFilteredData, DEBOUNCE_WAIT), | ||
this.calcInputWidth = lodash.debounce(this.calcInputWidth, WINDOW_RESIZE_WAIT); | ||
@@ -455,53 +363,17 @@ } | ||
function _extends$1() { | ||
return (_extends$1 = Object.assign || function(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]); | ||
} | ||
return target; | ||
}).apply(this, arguments); | ||
} | ||
function _objectWithoutProperties$1(source, excluded) { | ||
if (null == source) return {}; | ||
var key, i, target = _objectWithoutPropertiesLoose$1(source, excluded); | ||
if (Object.getOwnPropertySymbols) { | ||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source); | ||
for (i = 0; i < sourceSymbolKeys.length; i++) key = sourceSymbolKeys[i], excluded.indexOf(key) >= 0 || Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]); | ||
} | ||
return target; | ||
} | ||
function _objectWithoutPropertiesLoose$1(source, excluded) { | ||
if (null == source) return {}; | ||
var key, i, target = {}, sourceKeys = Object.keys(source); | ||
for (i = 0; i < sourceKeys.length; i++) key = sourceKeys[i], excluded.indexOf(key) >= 0 || (target[key] = source[key]); | ||
return target; | ||
} | ||
function _defineProperty$1(obj, key, value) { | ||
return key in obj ? Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0 | ||
}) : obj[key] = value, obj; | ||
} | ||
class AutoCompleteStateless extends React.Component { | ||
constructor(_props) { | ||
super(_props), _defineProperty$1(this, "inputWrapper", React.createRef()), _defineProperty$1(this, "menuContainerRef", React.createRef()), | ||
_defineProperty$1(this, "state", { | ||
super(_props), _defineProperty(this, "inputWrapper", React.createRef()), _defineProperty(this, "menuContainerRef", React.createRef()), | ||
_defineProperty(this, "state", { | ||
isOpen: !1, | ||
highlightedIndex: null, | ||
menuWidth: 0 | ||
}), _defineProperty$1(this, "calcInputWidth", () => { | ||
}), _defineProperty(this, "calcInputWidth", (() => { | ||
this.inputWrapper.current && this.inputWrapper.current.firstElementChild && this.setState({ | ||
menuWidth: this.inputWrapper.current.firstElementChild.offsetWidth | ||
}); | ||
}), _defineProperty$1(this, "renderComposeMenu", children => React.createElement(AutoCompleteList, { | ||
})), _defineProperty(this, "renderComposeMenu", (children => React.createElement(AutoCompleteList, { | ||
customWidth: this.state.menuWidth, | ||
ref: this.menuContainerRef | ||
}, children)), _defineProperty$1(this, "renderItem", (item, isHighlighted, index) => React.createElement(AutoCompleteListItem, { | ||
}, children))), _defineProperty(this, "renderItem", ((item, isHighlighted, index) => React.createElement(AutoCompleteListItem, { | ||
isActive: index === this.state.highlightedIndex, | ||
@@ -515,3 +387,3 @@ className: "".concat(isHighlighted ? "selectedItem" : ""), | ||
} | ||
}))), _defineProperty$1(this, "renderAfterIcon", () => React.createElement(AfterIconWrapper, null, this.props.isLoading ? React.createElement(SpinnerWrapper, { | ||
})))), _defineProperty(this, "renderAfterIcon", (() => React.createElement(AfterIconWrapper, null, this.props.isLoading ? React.createElement(SpinnerWrapper, { | ||
size: this.props.size, | ||
@@ -524,6 +396,6 @@ variant: "dark" | ||
size: this.props.size | ||
})))), _defineProperty$1(this, "handleChange", event => { | ||
}))))), _defineProperty(this, "handleChange", (event => { | ||
var {onChange: onChange = (() => {})} = this.props; | ||
onChange(event); | ||
}), _defineProperty$1(this, "handleInputBlur", event => { | ||
})), _defineProperty(this, "handleInputBlur", (event => { | ||
var selectCallback, {highlightedIndex: highlightedIndex} = this.state; | ||
@@ -540,10 +412,10 @@ if (null !== highlightedIndex) { | ||
onBlur && onBlur(event); | ||
}), _defineProperty$1(this, "selectItemFromMouse", item => { | ||
})), _defineProperty(this, "selectItemFromMouse", (item => { | ||
this.setState({ | ||
isOpen: !1, | ||
highlightedIndex: null | ||
}, () => { | ||
}, (() => { | ||
this.props.onSelectItem(transformedItem(item)); | ||
}); | ||
}), _defineProperty$1(this, "clearInput", () => { | ||
})); | ||
})), _defineProperty(this, "clearInput", (() => { | ||
var {onReset: onReset = (() => {})} = this.props; | ||
@@ -554,6 +426,6 @@ this.setState({ | ||
}), onReset(); | ||
}), _defineProperty$1(this, "getFilteredItems", props => { | ||
})), _defineProperty(this, "getFilteredItems", (props => { | ||
var items = props.dataSource; | ||
return items = items.map(d => makeInputKeyBold(d, String(props.value).toLowerCase())); | ||
}), _defineProperty$1(this, "isOpen", () => "open" in this.props ? this.props.open : this.state.isOpen), | ||
return items = items.map((d => makeInputKeyBold(d, String(props.value).toLowerCase()))); | ||
})), _defineProperty(this, "isOpen", (() => "open" in this.props ? this.props.open : this.state.isOpen)), | ||
this.calcInputWidth = lodash.debounce(this.calcInputWidth, AutoCompleteStateless.WINDOW_RESIZE_WAIT); | ||
@@ -572,3 +444,3 @@ } | ||
renderMenu() { | ||
var children = this.getFilteredItems(this.props).map((item, index) => { | ||
var children = this.getFilteredItems(this.props).map(((item, index) => { | ||
var element = this.renderItem(item, this.state.highlightedIndex === index, index); | ||
@@ -579,3 +451,3 @@ return React.cloneElement(element, { | ||
}); | ||
}); | ||
})); | ||
return this.renderComposeMenu(children); | ||
@@ -615,5 +487,5 @@ } | ||
highlightedIndex: null | ||
}, () => { | ||
}, (() => { | ||
this.props.onSelectItem(transformedItem(item)); | ||
}); | ||
})); | ||
} | ||
@@ -641,6 +513,6 @@ return; | ||
render() { | ||
var open = this.isOpen(), _this$props = this.props, {dataSource: dataSource, value: value = "", onChange: onChange = (() => {}), placeholder: placeholder = "", size: size = "md", onSelectItem: onSelectItem = (() => {}), onMenuVisibilityChange: onMenuVisibilityChange} = _this$props, inputProps = _objectWithoutProperties$1(_this$props, [ "dataSource", "value", "onChange", "placeholder", "size", "onSelectItem", "onMenuVisibilityChange" ]); | ||
var open = this.isOpen(), _this$props = this.props, {dataSource: dataSource, value: value = "", onChange: onChange = (() => {}), placeholder: placeholder = "", size: size = "md", onSelectItem: onSelectItem = (() => {}), onMenuVisibilityChange: onMenuVisibilityChange} = _this$props, inputProps = _objectWithoutProperties(_this$props, [ "dataSource", "value", "onChange", "placeholder", "size", "onSelectItem", "onMenuVisibilityChange" ]); | ||
return React.createElement(AutoCompleteWrapper, { | ||
ref: this.inputWrapper | ||
}, React.createElement(textInput.Input, _extends$1({}, inputProps, { | ||
}, React.createElement(textInput.Input, _extends({}, inputProps, { | ||
size: size, | ||
@@ -658,3 +530,3 @@ placeholder: placeholder, | ||
_defineProperty$1(AutoCompleteStateless, "WINDOW_RESIZE_WAIT", 100), exports.AutoComplete = AutoComplete, | ||
_defineProperty(AutoCompleteStateless, "WINDOW_RESIZE_WAIT", 100), exports.AutoComplete = AutoComplete, | ||
exports.AutoCompleteStateless = AutoCompleteStateless; |
@@ -14,134 +14,134 @@ import { Component, createElement, createRef, cloneElement } from 'react'; | ||
function _templateObject12() { | ||
var data = _taggedTemplateLiteral(["\n top: ", ";\n width: ", ";\n height: ", ";\n "]); | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
_templateObject12 = function _templateObject12() { | ||
return data; | ||
}; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return data; | ||
} | ||
function _templateObject11() { | ||
var data = _taggedTemplateLiteral(["\n top: ", ";\n width: ", ";\n height: ", ";\n "]); | ||
_templateObject11 = function _templateObject11() { | ||
return data; | ||
return target; | ||
}; | ||
return data; | ||
return _extends.apply(this, arguments); | ||
} | ||
function _templateObject10() { | ||
var data = _taggedTemplateLiteral(["\n top: ", ";\n width: ", ";\n height: ", ";\n "]); | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {}; | ||
var target = {}; | ||
var sourceKeys = Object.keys(source); | ||
var key, i; | ||
_templateObject10 = function _templateObject10() { | ||
return data; | ||
}; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
target[key] = source[key]; | ||
} | ||
return data; | ||
return target; | ||
} | ||
function _templateObject9() { | ||
var data = _taggedTemplateLiteral(["\n ", ";\n"]); | ||
function _objectWithoutProperties(source, excluded) { | ||
if (source == null) return {}; | ||
var target = _objectWithoutPropertiesLoose(source, excluded); | ||
var key, i; | ||
_templateObject9 = function _templateObject9() { | ||
return data; | ||
}; | ||
if (Object.getOwnPropertySymbols) { | ||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source); | ||
return data; | ||
} | ||
for (i = 0; i < sourceSymbolKeys.length; i++) { | ||
key = sourceSymbolKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; | ||
target[key] = source[key]; | ||
} | ||
} | ||
function _templateObject8() { | ||
var data = _taggedTemplateLiteral(["\n ", ";\n"]); | ||
_templateObject8 = function _templateObject8() { | ||
return data; | ||
}; | ||
return data; | ||
return target; | ||
} | ||
function _templateObject7() { | ||
var data = _taggedTemplateLiteral(["\n cursor: pointer;\n"]); | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
try { | ||
var info = gen[key](arg); | ||
var value = info.value; | ||
} catch (error) { | ||
reject(error); | ||
return; | ||
} | ||
_templateObject7 = function _templateObject7() { | ||
return data; | ||
}; | ||
return data; | ||
if (info.done) { | ||
resolve(value); | ||
} else { | ||
Promise.resolve(value).then(_next, _throw); | ||
} | ||
} | ||
function _templateObject6() { | ||
var data = _taggedTemplateLiteral(["\n ", ";\n"]); | ||
function _asyncToGenerator(fn) { | ||
return function () { | ||
var self = this, | ||
args = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
_templateObject6 = function _templateObject6() { | ||
return data; | ||
}; | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
} | ||
return data; | ||
} | ||
function _throw(err) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
} | ||
function _templateObject5() { | ||
var data = _taggedTemplateLiteral(["\n ", ";\n min-width: 110px;\n"]); | ||
_templateObject5 = function _templateObject5() { | ||
return data; | ||
_next(undefined); | ||
}); | ||
}; | ||
return data; | ||
} | ||
function _templateObject4() { | ||
var data = _taggedTemplateLiteral(["\n background-color: initial;\n color: initial;\n "]); | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
_templateObject4 = function _templateObject4() { | ||
return data; | ||
}; | ||
return data; | ||
return obj; | ||
} | ||
function _templateObject3() { | ||
var data = _taggedTemplateLiteral(["\n ", ";\n ", ";\n "]); | ||
_templateObject3 = function _templateObject3() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _templateObject2() { | ||
var data = _taggedTemplateLiteral(["\n width: auto;\n word-wrap: break-word;\n list-style: none;\n ", ";\n ", ";\n\n font-family: ", ";\n :hover {\n ", ";\n ", " cursor: pointer;\n font-weight: 700;\n }\n\n ", ";\n"]); | ||
_templateObject2 = function _templateObject2() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _templateObject() { | ||
var data = _taggedTemplateLiteral(["\n ", ";\n ", ";\n ", ";\n border-radius: ", ";\n max-height: 192px;\n position: absolute;\n ", ";\n z-index: 1;\n ", ";\n overflow: auto;\n outline: none;\n width: ", ";\n"]); | ||
_templateObject = function _templateObject() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } | ||
var AutoCompleteList = styled.ul(_templateObject(), m('nil'), py('xxs'), px('nil'), select('borderRadius'), bg('shade.0'), depth(1), props => props.customWidth ? props.customWidth + 'px' : 'auto'); | ||
var AutoCompleteListItem = styled.li(_templateObject2(), px('sm'), py('xs'), select('typography.body.fontFamily'), bg('secondary.500'), fg('shade.0'), (_ref) => { | ||
var AutoCompleteList = styled.ul.withConfig({ | ||
displayName: "indexstyle__AutoCompleteList", | ||
componentId: "lui__sc-11thbm7-0" | ||
})(["", ";", ";", ";border-radius:", ";max-height:192px;position:absolute;", ";z-index:1;", ";overflow:auto;outline:none;width:", ";"], m('nil'), py('xxs'), px('nil'), select('borderRadius'), bg('shade.0'), depth(1), props => props.customWidth ? props.customWidth + 'px' : 'auto'); | ||
var AutoCompleteListItem = styled.li.withConfig({ | ||
displayName: "indexstyle__AutoCompleteListItem", | ||
componentId: "lui__sc-11thbm7-1" | ||
})(["width:auto;word-wrap:break-word;list-style:none;", ";", ";font-family:", ";:hover{", ";", " cursor:pointer;font-weight:700;}", ";"], px('sm'), py('xs'), select('typography.body.fontFamily'), bg('secondary.500'), fg('shade.0'), (_ref) => { | ||
var { | ||
isActive | ||
} = _ref; | ||
return isActive ? css(_templateObject3(), bg('secondary.500'), fg('shade.0')) : css(_templateObject4()); | ||
return isActive ? css(["", ";", ";"], bg('secondary.500'), fg('shade.0')) : css(["background-color:initial;color:initial;"]); | ||
}); | ||
var AutoCompleteWrapper = styled.div(_templateObject5(), normalise); | ||
var AfterIconWrapper = styled.span(_templateObject6(), p('sm')); | ||
var CloseWrapper = styled.span(_templateObject7()); | ||
var SpinnerWrapper = styled(Spinner)(_templateObject8(), (_ref2) => { | ||
var AutoCompleteWrapper = styled.div.withConfig({ | ||
displayName: "indexstyle__AutoCompleteWrapper", | ||
componentId: "lui__sc-11thbm7-2" | ||
})(["", ";min-width:110px;"], normalise); | ||
var AfterIconWrapper = styled.span.withConfig({ | ||
displayName: "indexstyle__AfterIconWrapper", | ||
componentId: "lui__sc-11thbm7-3" | ||
})(["", ";"], p('sm')); | ||
var CloseWrapper = styled.span.withConfig({ | ||
displayName: "indexstyle__CloseWrapper", | ||
componentId: "lui__sc-11thbm7-4" | ||
})(["cursor:pointer;"]); | ||
var SpinnerWrapper = styled(Spinner).withConfig({ | ||
displayName: "indexstyle__SpinnerWrapper", | ||
componentId: "lui__sc-11thbm7-5" | ||
})(["", ";"], (_ref2) => { | ||
var { | ||
@@ -152,3 +152,6 @@ size | ||
}); | ||
var CloseIcon = styled(Close)(_templateObject9(), (_ref3) => { | ||
var CloseIcon = styled(Close).withConfig({ | ||
displayName: "indexstyle__CloseIcon", | ||
componentId: "lui__sc-11thbm7-6" | ||
})(["", ";"], (_ref3) => { | ||
var { | ||
@@ -163,9 +166,9 @@ size | ||
case 'sm': | ||
return css(_templateObject10(), deriveSize(0.35), deriveSize(1), deriveSize(1)); | ||
return css(["top:", ";width:", ";height:", ";"], deriveSize(0.35), deriveSize(1), deriveSize(1)); | ||
case 'md': | ||
return css(_templateObject11(), deriveSize(0.45), deriveSize(1.25), deriveSize(1.25)); | ||
return css(["top:", ";width:", ";height:", ";"], deriveSize(0.45), deriveSize(1.25), deriveSize(1.25)); | ||
case 'lg': | ||
return css(_templateObject12(), deriveSize(0.35), deriveSize(1.75), deriveSize(1.75)); | ||
return css(["top:", ";width:", ";height:", ";"], deriveSize(0.35), deriveSize(1.75), deriveSize(1.75)); | ||
@@ -217,6 +220,2 @@ default: | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
function extractData(_x, _x2) { | ||
@@ -283,3 +282,7 @@ return _extractData.apply(this, arguments); | ||
function transformedItem(item) { | ||
function transformedItem() { | ||
var item = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { | ||
label: '', | ||
value: '' | ||
}; | ||
return { | ||
@@ -292,13 +295,2 @@ label: item.label.replace(/<\/?[^>]+(>|$)/g, ''), | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
function _asyncToGenerator$1(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var DEBOUNCE_WAIT = 300; | ||
@@ -340,3 +332,3 @@ var WINDOW_RESIZE_WAIT = 100; | ||
_defineProperty(this, "getFilteredData", /*#__PURE__*/function () { | ||
var _ref = _asyncToGenerator$1(function* (userInput) { | ||
var _ref = _asyncToGenerator(function* (userInput) { | ||
var { | ||
@@ -559,9 +551,2 @@ dataSource, | ||
function _extends$1() { _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); } | ||
function _objectWithoutProperties$1(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose$1(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose$1(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
class AutoCompleteStateless extends Component { | ||
@@ -571,7 +556,7 @@ constructor(_props) { | ||
_defineProperty$1(this, "inputWrapper", /*#__PURE__*/createRef()); | ||
_defineProperty(this, "inputWrapper", /*#__PURE__*/createRef()); | ||
_defineProperty$1(this, "menuContainerRef", /*#__PURE__*/createRef()); | ||
_defineProperty(this, "menuContainerRef", /*#__PURE__*/createRef()); | ||
_defineProperty$1(this, "state", { | ||
_defineProperty(this, "state", { | ||
isOpen: false, | ||
@@ -582,3 +567,3 @@ highlightedIndex: null, | ||
_defineProperty$1(this, "calcInputWidth", () => { | ||
_defineProperty(this, "calcInputWidth", () => { | ||
if (this.inputWrapper.current && this.inputWrapper.current.firstElementChild) { | ||
@@ -591,3 +576,3 @@ this.setState({ | ||
_defineProperty$1(this, "renderComposeMenu", children => { | ||
_defineProperty(this, "renderComposeMenu", children => { | ||
return /*#__PURE__*/createElement(AutoCompleteList, { | ||
@@ -599,3 +584,3 @@ customWidth: this.state.menuWidth, | ||
_defineProperty$1(this, "renderItem", (item, isHighlighted, index) => /*#__PURE__*/createElement(AutoCompleteListItem, { | ||
_defineProperty(this, "renderItem", (item, isHighlighted, index) => /*#__PURE__*/createElement(AutoCompleteListItem, { | ||
isActive: index === this.state.highlightedIndex, | ||
@@ -611,3 +596,3 @@ className: "".concat(isHighlighted ? 'selectedItem' : ''), | ||
_defineProperty$1(this, "renderAfterIcon", () => /*#__PURE__*/createElement(AfterIconWrapper, null, this.props.isLoading ? /*#__PURE__*/createElement(SpinnerWrapper, { | ||
_defineProperty(this, "renderAfterIcon", () => /*#__PURE__*/createElement(AfterIconWrapper, null, this.props.isLoading ? /*#__PURE__*/createElement(SpinnerWrapper, { | ||
size: this.props.size, | ||
@@ -622,3 +607,3 @@ variant: "dark" | ||
_defineProperty$1(this, "handleChange", event => { | ||
_defineProperty(this, "handleChange", event => { | ||
var { | ||
@@ -630,3 +615,3 @@ onChange = () => {} | ||
_defineProperty$1(this, "handleInputBlur", event => { | ||
_defineProperty(this, "handleInputBlur", event => { | ||
var selectCallback; | ||
@@ -657,3 +642,3 @@ var { | ||
_defineProperty$1(this, "selectItemFromMouse", item => { | ||
_defineProperty(this, "selectItemFromMouse", item => { | ||
this.setState({ | ||
@@ -667,3 +652,3 @@ isOpen: false, | ||
_defineProperty$1(this, "clearInput", () => { | ||
_defineProperty(this, "clearInput", () => { | ||
var { | ||
@@ -679,3 +664,3 @@ onReset = () => {} | ||
_defineProperty$1(this, "getFilteredItems", props => { | ||
_defineProperty(this, "getFilteredItems", props => { | ||
var items = props.dataSource; // some extra processing can be done here like make the input bold in the selections. | ||
@@ -687,3 +672,3 @@ | ||
_defineProperty$1(this, "isOpen", () => { | ||
_defineProperty(this, "isOpen", () => { | ||
return 'open' in this.props ? this.props.open : this.state.isOpen; | ||
@@ -835,7 +820,7 @@ }); | ||
} = _this$props, | ||
inputProps = _objectWithoutProperties$1(_this$props, ["dataSource", "value", "onChange", "placeholder", "size", "onSelectItem", "onMenuVisibilityChange"]); | ||
inputProps = _objectWithoutProperties(_this$props, ["dataSource", "value", "onChange", "placeholder", "size", "onSelectItem", "onMenuVisibilityChange"]); | ||
return /*#__PURE__*/createElement(AutoCompleteWrapper, { | ||
ref: this.inputWrapper | ||
}, /*#__PURE__*/createElement(Input, _extends$1({}, inputProps, { | ||
}, /*#__PURE__*/createElement(Input, _extends({}, inputProps, { | ||
size: size, | ||
@@ -855,4 +840,4 @@ placeholder: placeholder, | ||
_defineProperty$1(AutoCompleteStateless, "WINDOW_RESIZE_WAIT", 100); | ||
_defineProperty(AutoCompleteStateless, "WINDOW_RESIZE_WAIT", 100); | ||
export { AutoComplete, AutoCompleteStateless }; |
@@ -0,1 +1,2 @@ | ||
/// <reference types="react" /> | ||
import { DataSourceItem } from '../typings'; | ||
@@ -5,5 +6,5 @@ export declare function extractData(userInput: string, dataSource: DataSourceItem[] | ((input: string) => Promise<DataSourceItem[]>)): Promise<DataSourceItem[]>; | ||
export declare const getOffsetScrollTop: (menuContainer: any) => number; | ||
export declare function transformedItem(item: DataSourceItem): { | ||
export declare function transformedItem(item?: DataSourceItem): { | ||
label: string; | ||
value: string | number; | ||
value: import("react").ReactText; | ||
}; |
{ | ||
"name": "@lendi-ui/auto-complete", | ||
"version": "5.2.7", | ||
"version": "5.2.8", | ||
"license": "ISC", | ||
@@ -8,3 +8,5 @@ "source": "src/index.tsx", | ||
"module": "dist/auto-complete.esm.js", | ||
"files": ["dist"], | ||
"files": [ | ||
"dist" | ||
], | ||
"keywords": [], | ||
@@ -11,0 +13,0 @@ "author": "Lendi Devs", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
Found 1 instance in 1 package
90884
2033