educoreapp2 1.0.65 → 1.0.66
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.
@@ -4,45 +4,81 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
-
var _react =
|
8
|
-
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
8
|
+
var _reactBootstrap = require("react-bootstrap");
|
9
|
+
require("bootstrap/dist/css/bootstrap.min.css");
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
9
12
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
10
13
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
11
14
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
12
|
-
class BaseAutocomplete extends _react.
|
15
|
+
class BaseAutocomplete extends _react.Component {
|
13
16
|
constructor(props) {
|
14
17
|
super(props);
|
18
|
+
_defineProperty(this, "fetchSuggestions", inputValue => {
|
19
|
+
if (inputValue.length > 2) {
|
20
|
+
this.setState({
|
21
|
+
loading: true
|
22
|
+
});
|
23
|
+
const list = this.props.list;
|
24
|
+
const filteredList = list.filter(item => item.name.toLowerCase().includes(inputValue.toLowerCase()));
|
25
|
+
this.setState({
|
26
|
+
suggestions: filteredList,
|
27
|
+
loading: false
|
28
|
+
});
|
29
|
+
}
|
30
|
+
});
|
15
31
|
_defineProperty(this, "handleInputChange", event => {
|
16
|
-
const value = event.target.value;
|
17
|
-
const suggestions = this.props.options.filter(option => option.toLowerCase().startsWith(value.toLowerCase()));
|
18
32
|
this.setState({
|
19
|
-
|
20
|
-
suggestions: suggestions
|
33
|
+
inputValue: event.target.value
|
21
34
|
});
|
22
35
|
});
|
23
|
-
_defineProperty(this, "handleSuggestionClick",
|
36
|
+
_defineProperty(this, "handleSuggestionClick", id => {
|
37
|
+
const selectedSuggestion = this.state.suggestions.find(s => s.id === id);
|
24
38
|
this.setState({
|
25
|
-
|
39
|
+
inputValue: selectedSuggestion.name,
|
26
40
|
suggestions: []
|
27
41
|
});
|
28
42
|
});
|
29
43
|
this.state = {
|
30
|
-
|
31
|
-
suggestions: []
|
44
|
+
inputValue: '',
|
45
|
+
suggestions: [],
|
46
|
+
loading: false
|
32
47
|
};
|
33
48
|
}
|
49
|
+
componentDidMount() {
|
50
|
+
this.fetchSuggestions(this.state.inputValue);
|
51
|
+
}
|
52
|
+
componentDidUpdate(prevProps, prevState) {
|
53
|
+
if (prevProps.list !== this.props.list || prevState.inputValue !== this.state.inputValue) {
|
54
|
+
this.fetchSuggestions(this.state.inputValue);
|
55
|
+
}
|
56
|
+
}
|
34
57
|
render() {
|
35
|
-
|
58
|
+
const {
|
59
|
+
inputValue,
|
60
|
+
suggestions,
|
61
|
+
loading
|
62
|
+
} = this.state;
|
63
|
+
return /*#__PURE__*/_react.default.createElement(_reactBootstrap.Form.Group, null, /*#__PURE__*/_react.default.createElement(_reactBootstrap.Form.Control, {
|
36
64
|
type: "text",
|
37
|
-
|
65
|
+
className: "form-control",
|
66
|
+
placeholder: "Search...",
|
67
|
+
value: inputValue,
|
38
68
|
onChange: this.handleInputChange,
|
39
|
-
|
40
|
-
}),
|
41
|
-
className: "
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
},
|
69
|
+
disabled: loading
|
70
|
+
}), loading ? /*#__PURE__*/_react.default.createElement("div", {
|
71
|
+
className: "spinner-border spinner-border-sm mr-2",
|
72
|
+
role: "status"
|
73
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
74
|
+
className: "sr-only"
|
75
|
+
}, "Loading...")) : /*#__PURE__*/_react.default.createElement("div", {
|
76
|
+
className: "autocomplete-suggestions"
|
77
|
+
}, suggestions.map(suggestion => /*#__PURE__*/_react.default.createElement("div", {
|
78
|
+
key: suggestion.id,
|
79
|
+
onClick: () => this.handleSuggestionClick(suggestion.id),
|
80
|
+
className: "suggestion"
|
81
|
+
}, suggestion.name))));
|
46
82
|
}
|
47
83
|
}
|
48
84
|
var _default = exports.default = BaseAutocomplete;
|