@dreamcommerce/aurora 2.1.14-3 → 2.1.15-0
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/build/cjs/_virtual/debounce.js_commonjs-proxy +10 -0
- package/build/cjs/_virtual/debounce.js_commonjs-proxy.map +1 -0
- package/build/cjs/external/lodash/throttle.js +76 -0
- package/build/cjs/external/lodash/throttle.js.map +1 -0
- package/build/cjs/packages/aurora/src/components/controls/hoc/control_multi_select/index.js +2 -2
- package/build/cjs/packages/aurora/src/components/controls/hoc/control_select/index.js +2 -2
- package/build/cjs/packages/aurora/src/components/dropdown/components/select.js +3 -2
- package/build/cjs/packages/aurora/src/components/dropdown/components/select.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/dropdown/hoc/multiselect/index.js +2 -2
- package/build/cjs/packages/aurora/src/components/dropdown/hoc/select/index.js +4 -6
- package/build/cjs/packages/aurora/src/components/dropdown/hoc/select/index.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/dropdown/hoc/xhr_select/hooks/use_xhr_select.js +7 -4
- package/build/cjs/packages/aurora/src/components/dropdown/hoc/xhr_select/hooks/use_xhr_select.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/dropdown/hoc/xhr_select/hooks/use_xhr_select_constants.js +10 -0
- package/build/cjs/packages/aurora/src/components/dropdown/hoc/xhr_select/hooks/use_xhr_select_constants.js.map +1 -0
- package/build/cjs/packages/aurora/src/components/dropdown/hoc/xhr_select/xhr_select.js +1 -1
- package/build/esm/_virtual/debounce.js_commonjs-proxy +3 -0
- package/build/esm/_virtual/debounce.js_commonjs-proxy.map +1 -0
- package/build/esm/external/lodash/throttle.js +72 -0
- package/build/esm/external/lodash/throttle.js.map +1 -0
- package/build/esm/packages/aurora/src/components/controls/hoc/control_multi_select/index.js +2 -2
- package/build/esm/packages/aurora/src/components/controls/hoc/control_select/index.js +2 -2
- package/build/esm/packages/aurora/src/components/dropdown/components/select.js +3 -2
- package/build/esm/packages/aurora/src/components/dropdown/components/select.js.map +1 -1
- package/build/esm/packages/aurora/src/components/dropdown/hoc/multiselect/index.js +2 -2
- package/build/esm/packages/aurora/src/components/dropdown/hoc/select/index.js +4 -6
- package/build/esm/packages/aurora/src/components/dropdown/hoc/select/index.js.map +1 -1
- package/build/esm/packages/aurora/src/components/dropdown/hoc/xhr_select/hooks/use_xhr_select.js +7 -4
- package/build/esm/packages/aurora/src/components/dropdown/hoc/xhr_select/hooks/use_xhr_select.js.map +1 -1
- package/build/esm/packages/aurora/src/components/dropdown/hoc/xhr_select/hooks/use_xhr_select_constants.d.ts +2 -0
- package/build/esm/packages/aurora/src/components/dropdown/hoc/xhr_select/hooks/use_xhr_select_constants.js +5 -0
- package/build/esm/packages/aurora/src/components/dropdown/hoc/{select/select_constants.js.map → xhr_select/hooks/use_xhr_select_constants.js.map} +1 -1
- package/build/esm/packages/aurora/src/components/dropdown/hoc/xhr_select/xhr_select.js +1 -1
- package/build/esm/packages/aurora/src/components/dropdown/types.d.ts +2 -0
- package/package.json +1 -1
- package/build/cjs/packages/aurora/src/components/dropdown/hoc/select/select_constants.js +0 -8
- package/build/cjs/packages/aurora/src/components/dropdown/hoc/select/select_constants.js.map +0 -1
- package/build/esm/packages/aurora/src/components/dropdown/hoc/select/select_constants.d.ts +0 -1
- package/build/esm/packages/aurora/src/components/dropdown/hoc/select/select_constants.js +0 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,uBAAuB,gCAAoC;AAC3D;AACA;AACA;AACA;"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var isObject = require('./isObject.js');
|
|
6
|
+
var debounce = require('./debounce.js');
|
|
7
|
+
|
|
8
|
+
/** Error message constants. */
|
|
9
|
+
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates a throttled function that only invokes `func` at most once per
|
|
13
|
+
* every `wait` milliseconds. The throttled function comes with a `cancel`
|
|
14
|
+
* method to cancel delayed `func` invocations and a `flush` method to
|
|
15
|
+
* immediately invoke them. Provide `options` to indicate whether `func`
|
|
16
|
+
* should be invoked on the leading and/or trailing edge of the `wait`
|
|
17
|
+
* timeout. The `func` is invoked with the last arguments provided to the
|
|
18
|
+
* throttled function. Subsequent calls to the throttled function return the
|
|
19
|
+
* result of the last `func` invocation.
|
|
20
|
+
*
|
|
21
|
+
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
22
|
+
* invoked on the trailing edge of the timeout only if the throttled function
|
|
23
|
+
* is invoked more than once during the `wait` timeout.
|
|
24
|
+
*
|
|
25
|
+
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
26
|
+
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
27
|
+
*
|
|
28
|
+
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
29
|
+
* for details over the differences between `_.throttle` and `_.debounce`.
|
|
30
|
+
*
|
|
31
|
+
* @static
|
|
32
|
+
* @memberOf _
|
|
33
|
+
* @since 0.1.0
|
|
34
|
+
* @category Function
|
|
35
|
+
* @param {Function} func The function to throttle.
|
|
36
|
+
* @param {number} [wait=0] The number of milliseconds to throttle invocations to.
|
|
37
|
+
* @param {Object} [options={}] The options object.
|
|
38
|
+
* @param {boolean} [options.leading=true]
|
|
39
|
+
* Specify invoking on the leading edge of the timeout.
|
|
40
|
+
* @param {boolean} [options.trailing=true]
|
|
41
|
+
* Specify invoking on the trailing edge of the timeout.
|
|
42
|
+
* @returns {Function} Returns the new throttled function.
|
|
43
|
+
* @example
|
|
44
|
+
*
|
|
45
|
+
* // Avoid excessively updating the position while scrolling.
|
|
46
|
+
* jQuery(window).on('scroll', _.throttle(updatePosition, 100));
|
|
47
|
+
*
|
|
48
|
+
* // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
|
|
49
|
+
* var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
|
|
50
|
+
* jQuery(element).on('click', throttled);
|
|
51
|
+
*
|
|
52
|
+
* // Cancel the trailing throttled invocation.
|
|
53
|
+
* jQuery(window).on('popstate', throttled.cancel);
|
|
54
|
+
*/
|
|
55
|
+
function throttle(func, wait, options) {
|
|
56
|
+
var leading = true,
|
|
57
|
+
trailing = true;
|
|
58
|
+
|
|
59
|
+
if (typeof func != 'function') {
|
|
60
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
61
|
+
}
|
|
62
|
+
if (isObject['default'](options)) {
|
|
63
|
+
leading = 'leading' in options ? !!options.leading : leading;
|
|
64
|
+
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
|
65
|
+
}
|
|
66
|
+
return debounce['default'](func, wait, {
|
|
67
|
+
'leading': leading,
|
|
68
|
+
'maxWait': wait,
|
|
69
|
+
'trailing': trailing
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
var throttle_1 = throttle;
|
|
74
|
+
|
|
75
|
+
exports.default = throttle_1;
|
|
76
|
+
//# sourceMappingURL=throttle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -11,14 +11,14 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
11
11
|
|
|
12
12
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
13
13
|
|
|
14
|
-
const ControlMultiSelect = ({ label, isRequired, id, name, defaultValues, options, isWithGroups, isWithSearch, defaultIsOpen, defaultCloseOnClick, isReadonly, isDisabled, onChange, onToggle, errors, hint, hintOptions = { isFixed: true } }) => {
|
|
14
|
+
const ControlMultiSelect = ({ label, isRequired, id, name, defaultValues, options, isWithGroups, isWithSearch, defaultIsOpen, defaultCloseOnClick, isReadonly, isDisabled, onChange, onToggle, errors, hint, hintOptions = { isFixed: true }, hasCloseIcon }) => {
|
|
15
15
|
return (React__default['default'].createElement(index['default'], { errors: errors, name: name, id: id },
|
|
16
16
|
(label || hint) && (React__default['default'].createElement(index['default'].Label, { id: id, isRequired: isRequired },
|
|
17
17
|
label,
|
|
18
18
|
hint && React__default['default'].createElement(index$1['default'], { fixed: hintOptions.isFixed, spacingLeft: true, hint: hint }))),
|
|
19
19
|
React__default['default'].createElement(index['default'].Content, null,
|
|
20
20
|
React__default['default'].createElement(index['default'].Element, null,
|
|
21
|
-
React__default['default'].createElement(index$2['default'], { key: name, name: name, options: options, defaultValues: defaultValues, isWithGroups: isWithGroups, isWithSearch: isWithSearch, defaultIsOpen: defaultIsOpen, defaultCloseOnClick: defaultCloseOnClick, isReadonly: isReadonly, isDisabled: isDisabled, onChange: onChange, onToggle: onToggle }))),
|
|
21
|
+
React__default['default'].createElement(index$2['default'], { key: name, name: name, options: options, defaultValues: defaultValues, isWithGroups: isWithGroups, isWithSearch: isWithSearch, defaultIsOpen: defaultIsOpen, defaultCloseOnClick: defaultCloseOnClick, isReadonly: isReadonly, isDisabled: isDisabled, onChange: onChange, onToggle: onToggle, hasCloseIcon: hasCloseIcon }))),
|
|
22
22
|
React__default['default'].createElement(index['default'].Errors, null)));
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -26,14 +26,14 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
26
26
|
* />
|
|
27
27
|
* )
|
|
28
28
|
*/
|
|
29
|
-
const ControlSelect = ({ label, isRequired, id, name, defaultValues, options, isWithGroups, isWithSearch, defaultIsOpen, defaultCloseOnClick, isReadonly, isDisabled, onChange, onToggle, errors, hint, hintOptions = { isFixed: true }, placeholder, additionalInfo, onScroll, innerAdditionalContent, onSearch }) => {
|
|
29
|
+
const ControlSelect = ({ label, isRequired, id, name, defaultValues, options, isWithGroups, isWithSearch, defaultIsOpen, defaultCloseOnClick, isReadonly, isDisabled, onChange, onToggle, errors, hint, hintOptions = { isFixed: true }, placeholder, additionalInfo, onScroll, innerAdditionalContent, onSearch, hasCloseIcon }) => {
|
|
30
30
|
return (React__default['default'].createElement(index['default'], { errors: errors, name: name, id: id },
|
|
31
31
|
(label || hint) && (React__default['default'].createElement(index['default'].Label, { id: id, isRequired: isRequired },
|
|
32
32
|
label,
|
|
33
33
|
hint && React__default['default'].createElement(index$1['default'], { fixed: hintOptions.isFixed, spacingLeft: true, hint: hint }))),
|
|
34
34
|
React__default['default'].createElement(index['default'].Content, null,
|
|
35
35
|
React__default['default'].createElement(index['default'].Element, null,
|
|
36
|
-
React__default['default'].createElement(index$2['default'], { key: name, name: name, options: options, defaultValues: defaultValues, isWithGroups: isWithGroups, isWithSearch: isWithSearch, defaultIsOpen: defaultIsOpen, defaultCloseOnClick: defaultCloseOnClick, isReadonly: isReadonly, isDisabled: isDisabled, placeholder: placeholder, onChange: onChange, onToggle: onToggle, onScroll: onScroll, innerAdditionalContent: innerAdditionalContent, onSearch: onSearch }))),
|
|
36
|
+
React__default['default'].createElement(index$2['default'], { key: name, name: name, options: options, defaultValues: defaultValues, isWithGroups: isWithGroups, isWithSearch: isWithSearch, defaultIsOpen: defaultIsOpen, defaultCloseOnClick: defaultCloseOnClick, isReadonly: isReadonly, isDisabled: isDisabled, placeholder: placeholder, onChange: onChange, onToggle: onToggle, onScroll: onScroll, innerAdditionalContent: innerAdditionalContent, onSearch: onSearch, hasCloseIcon: hasCloseIcon }))),
|
|
37
37
|
React__default['default'].createElement(index['default'].Errors, null),
|
|
38
38
|
additionalInfo && React__default['default'].createElement(index['default'].AdditionalInfo, null, additionalInfo)));
|
|
39
39
|
};
|
|
@@ -37,7 +37,7 @@ isReadonly = false,
|
|
|
37
37
|
/**
|
|
38
38
|
* array of selected options
|
|
39
39
|
*/
|
|
40
|
-
selectedOptions, placeholder, onRemoveOptions }) => {
|
|
40
|
+
selectedOptions, placeholder, onRemoveOptions, hasCloseIcon }) => {
|
|
41
41
|
const ref = React.useRef(null);
|
|
42
42
|
/**
|
|
43
43
|
* get values from dropdown context
|
|
@@ -58,7 +58,8 @@ selectedOptions, placeholder, onRemoveOptions }) => {
|
|
|
58
58
|
onRemoveOptions && onRemoveOptions();
|
|
59
59
|
};
|
|
60
60
|
return (React__default['default'].createElement("div", { className: main_module['default']['select'], "aria-expanded": isOpen, "aria-haspopup": "listbox", ref: ref },
|
|
61
|
-
React__default['default'].createElement(input_wrapper['default'], { value: value, isFocused: Boolean(isOpen), isDisabled: isDisabled, isReadOnly: isReadonly, onClick: toggleDropdown, placeholder: placeholder, postElements: !!selectedOptions.length &&
|
|
61
|
+
React__default['default'].createElement(input_wrapper['default'], { value: value, isFocused: Boolean(isOpen), isDisabled: isDisabled, isReadOnly: isReadonly, onClick: toggleDropdown, placeholder: placeholder, postElements: !!selectedOptions.length &&
|
|
62
|
+
hasCloseIcon && (React__default['default'].createElement("button", { className: main_module$1['default'][css_classes.cssControlInputRemoveButton], onClick: handleOnClick },
|
|
62
63
|
React__default['default'].createElement(icon_close['default'], { size: "s" }))) }),
|
|
63
64
|
$hiddenInputs));
|
|
64
65
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -79,7 +79,7 @@ onToggle,
|
|
|
79
79
|
/**
|
|
80
80
|
* called on option change
|
|
81
81
|
*/
|
|
82
|
-
onChange }) => {
|
|
82
|
+
onChange, hasCloseIcon }) => {
|
|
83
83
|
/**
|
|
84
84
|
* reference to dropdown wrapper element
|
|
85
85
|
*/
|
|
@@ -106,7 +106,7 @@ onChange }) => {
|
|
|
106
106
|
use_set_options_on_close.useSetOptionsOnClose(isWithSearch, isOpen, setOptionsList, options);
|
|
107
107
|
return (React__default['default'].createElement(index.DropdownContext.Provider, { value: value },
|
|
108
108
|
React__default['default'].createElement("div", { ref: wrapperRef, className: main_module['default'][css_classes.cssDropdown] },
|
|
109
|
-
React__default['default'].createElement(index$1['default'].Select, { name: name, isReadonly: isReadonly, isDisabled: isDisabled, selectedOptions: selectedValues, onRemoveOptions: setSelectedValues }),
|
|
109
|
+
React__default['default'].createElement(index$1['default'].Select, { name: name, isReadonly: isReadonly, isDisabled: isDisabled, selectedOptions: selectedValues, onRemoveOptions: setSelectedValues, hasCloseIcon: hasCloseIcon }),
|
|
110
110
|
React__default['default'].createElement(index$1['default'].Content, null,
|
|
111
111
|
isWithSearch && React__default['default'].createElement(index$1['default'].Search, { onKeyUp: (ev) => utilities.handleSearchKeyUp(ev, options, setOptionsList) }),
|
|
112
112
|
React__default['default'].createElement(index$1['default'].List, { isWithGroups: isWithGroups }, optionsList === null || optionsList === void 0 ? void 0 : optionsList.map((option) => {
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var debounce = require('../../../../../../../external/lodash/debounce.js');
|
|
7
6
|
var index = require('../../context/index.js');
|
|
8
7
|
var css_classes = require('../../css_classes.js');
|
|
9
8
|
var main_module = require('../../../../css/dropdown/main.module.less.js');
|
|
@@ -12,7 +11,6 @@ var use_value = require('../../hooks/use_value.js');
|
|
|
12
11
|
var use_toggle = require('../../hooks/use_toggle.js');
|
|
13
12
|
var use_set_options_on_close = require('../../hooks/use_set_options_on_close.js');
|
|
14
13
|
var index$1 = require('../../index.js');
|
|
15
|
-
var select_constants = require('./select_constants.js');
|
|
16
14
|
|
|
17
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
16
|
|
|
@@ -85,7 +83,7 @@ onChange,
|
|
|
85
83
|
* Place where portal should be placed, by default to body
|
|
86
84
|
* this can be used to put modal inside modal
|
|
87
85
|
*/
|
|
88
|
-
portalContainer, placeholder, onScroll, innerAdditionalContent, onSearch }) => {
|
|
86
|
+
portalContainer, placeholder, onScroll, innerAdditionalContent, onSearch, hasCloseIcon }) => {
|
|
89
87
|
/**
|
|
90
88
|
* reference to dropdown wrapper element
|
|
91
89
|
*/
|
|
@@ -110,16 +108,16 @@ portalContainer, placeholder, onScroll, innerAdditionalContent, onSearch }) => {
|
|
|
110
108
|
* hook which resets options list to default on close if select has search and it was used
|
|
111
109
|
*/
|
|
112
110
|
use_set_options_on_close.useSetOptionsOnClose(isWithSearch, isOpen, setOptionsList, options);
|
|
113
|
-
const handleSearch =
|
|
111
|
+
const handleSearch = (ev) => {
|
|
114
112
|
onSearch && onSearch(ev);
|
|
115
113
|
utilities.handleSearchKeyUp(ev, options, setOptionsList);
|
|
116
|
-
}
|
|
114
|
+
};
|
|
117
115
|
React.useEffect(() => {
|
|
118
116
|
setOptionsList(options);
|
|
119
117
|
}, [options]);
|
|
120
118
|
return (React__default['default'].createElement(index.DropdownContext.Provider, { value: value },
|
|
121
119
|
React__default['default'].createElement("div", { ref: wrapperRef, className: main_module['default'][css_classes.cssDropdown] },
|
|
122
|
-
React__default['default'].createElement(index$1['default'].Select, { name: name, isReadonly: isReadonly, isDisabled: isDisabled, selectedOptions: selectedValues, placeholder: placeholder, onRemoveOptions: setSelectedValues }),
|
|
120
|
+
React__default['default'].createElement(index$1['default'].Select, { name: name, isReadonly: isReadonly, isDisabled: isDisabled, selectedOptions: selectedValues, placeholder: placeholder, onRemoveOptions: setSelectedValues, hasCloseIcon: hasCloseIcon }),
|
|
123
121
|
React__default['default'].createElement(index$1['default'].Content, { portalContainer: portalContainer },
|
|
124
122
|
isWithSearch && React__default['default'].createElement(index$1['default'].Search, { onKeyUp: (ev) => handleSearch(ev) }),
|
|
125
123
|
React__default['default'].createElement(index$1['default'].List, { isWithGroups: isWithGroups, onScroll: onScroll }, optionsList === null || optionsList === void 0 ? void 0 :
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
package/build/cjs/packages/aurora/src/components/dropdown/hoc/xhr_select/hooks/use_xhr_select.js
CHANGED
|
@@ -4,7 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var useTranslation = require('../../../../../../../../external/react-i18next/dist/es/useTranslation.js');
|
|
7
|
+
var debounce = require('../../../../../../../../external/lodash/debounce.js');
|
|
7
8
|
var xhr_select_constants = require('../xhr_select_constants.js');
|
|
9
|
+
var use_xhr_select_constants = require('./use_xhr_select_constants.js');
|
|
10
|
+
var throttle = require('../../../../../../../../external/lodash/throttle.js');
|
|
8
11
|
var xhr_select_response_parser = require('../http/xhr_select_response_parser.js');
|
|
9
12
|
|
|
10
13
|
const useXhrSelect = ({ url, fetchClient, onScroll }) => {
|
|
@@ -15,7 +18,7 @@ const useXhrSelect = ({ url, fetchClient, onScroll }) => {
|
|
|
15
18
|
const [search, setSearch] = React.useState(null);
|
|
16
19
|
const [t] = useTranslation.useTranslation();
|
|
17
20
|
const xhrSelectResponseParser = new xhr_select_response_parser.XhrSelectResponseParser();
|
|
18
|
-
const loadSelectDataOnScroll = (event) => {
|
|
21
|
+
const loadSelectDataOnScroll = throttle['default']((event) => {
|
|
19
22
|
onScroll && onScroll(event);
|
|
20
23
|
if ((selectData === null || selectData === void 0 ? void 0 : selectData.page) === (selectData === null || selectData === void 0 ? void 0 : selectData.pages))
|
|
21
24
|
return;
|
|
@@ -44,7 +47,7 @@ const useXhrSelect = ({ url, fetchClient, onScroll }) => {
|
|
|
44
47
|
}
|
|
45
48
|
});
|
|
46
49
|
}, xhr_select_constants.SCROLL_FETCH_TIMEOUT_IN_MS)));
|
|
47
|
-
};
|
|
50
|
+
}, use_xhr_select_constants.LOAD_DATA_ON_SCROLL_THROTTLE_TIME_IN_MS);
|
|
48
51
|
const resetScrollTimerAndError = () => {
|
|
49
52
|
clearTimeout(scrollTimer);
|
|
50
53
|
setScrollTimer(undefined);
|
|
@@ -53,7 +56,7 @@ const useXhrSelect = ({ url, fetchClient, onScroll }) => {
|
|
|
53
56
|
scrollError: ''
|
|
54
57
|
});
|
|
55
58
|
};
|
|
56
|
-
const loadSelectDataOnSearch = (ev) => {
|
|
59
|
+
const loadSelectDataOnSearch = debounce['default']((ev) => {
|
|
57
60
|
const currentSearch = ev.target.value;
|
|
58
61
|
if (currentSearch === search)
|
|
59
62
|
return;
|
|
@@ -74,7 +77,7 @@ const useXhrSelect = ({ url, fetchClient, onScroll }) => {
|
|
|
74
77
|
});
|
|
75
78
|
}
|
|
76
79
|
});
|
|
77
|
-
};
|
|
80
|
+
}, use_xhr_select_constants.SEARCH_DATA_DEBOUNCE_TIMEOUT_IN_MS);
|
|
78
81
|
const fetchXhrData = React.useCallback(({ url, handleResponseData, handleCatchErrors }) => {
|
|
79
82
|
fetchClient
|
|
80
83
|
.fetch({ method: 'get', url })
|
package/build/cjs/packages/aurora/src/components/dropdown/hoc/xhr_select/hooks/use_xhr_select.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,6BAA6B,0EAA8E;AAC3G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,6BAA6B,0EAA8E;AAC3G,uBAAuB,qDAAyD;AAChF;AACA;AACA,uBAAuB,qDAAyD;AAChF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const LOAD_DATA_ON_SCROLL_THROTTLE_TIME_IN_MS = 100;
|
|
6
|
+
const SEARCH_DATA_DEBOUNCE_TIMEOUT_IN_MS = 400;
|
|
7
|
+
|
|
8
|
+
exports.LOAD_DATA_ON_SCROLL_THROTTLE_TIME_IN_MS = LOAD_DATA_ON_SCROLL_THROTTLE_TIME_IN_MS;
|
|
9
|
+
exports.SEARCH_DATA_DEBOUNCE_TIMEOUT_IN_MS = SEARCH_DATA_DEBOUNCE_TIMEOUT_IN_MS;
|
|
10
|
+
//# sourceMappingURL=use_xhr_select_constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -61,7 +61,7 @@ const XhrSelect = ({ url, headerTitle, noItemsErrorMessage, onScroll, fetchClien
|
|
|
61
61
|
"..."));
|
|
62
62
|
if (!(selectData === null || selectData === void 0 ? void 0 : selectData.list.length) && search === null)
|
|
63
63
|
return React__default['default'].createElement(index['default'], { type: "alert" }, noItemsErrorMessage);
|
|
64
|
-
return (React__default['default'].createElement(index$2['default'], { ...props, isWithSearch: true, options: mapSelectDataToSelectOptions(selectData || { list: [] }), onScroll: loadSelectDataOnScroll, onSearch: loadSelectDataOnSearch, innerAdditionalContent: React__default['default'].createElement(React__default['default'].Fragment, null,
|
|
64
|
+
return (React__default['default'].createElement(index$2['default'], { ...props, isWithSearch: true, options: mapSelectDataToSelectOptions(selectData || { list: [] }), onScroll: loadSelectDataOnScroll, onSearch: loadSelectDataOnSearch, hasCloseIcon: true, innerAdditionalContent: React__default['default'].createElement(React__default['default'].Fragment, null,
|
|
65
65
|
errors.scrollError && (React__default['default'].createElement("div", { className: `${main_module['default'][css_classes.cssSelectAdditionalContent]} ${main_module['default'][css_classes.cssSelectError]}` },
|
|
66
66
|
React__default['default'].createElement(icon_warning['default'], { size: "m", className: main_module['default'][css_classes.cssSelectErrorIcon] }),
|
|
67
67
|
errors.scrollError)),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uBAAuB,gCAAoC;AAC3D,wBAAwB,gCAAoC;"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import isObject_1 from './isObject.js';
|
|
2
|
+
import debounce_1 from './debounce.js';
|
|
3
|
+
|
|
4
|
+
/** Error message constants. */
|
|
5
|
+
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Creates a throttled function that only invokes `func` at most once per
|
|
9
|
+
* every `wait` milliseconds. The throttled function comes with a `cancel`
|
|
10
|
+
* method to cancel delayed `func` invocations and a `flush` method to
|
|
11
|
+
* immediately invoke them. Provide `options` to indicate whether `func`
|
|
12
|
+
* should be invoked on the leading and/or trailing edge of the `wait`
|
|
13
|
+
* timeout. The `func` is invoked with the last arguments provided to the
|
|
14
|
+
* throttled function. Subsequent calls to the throttled function return the
|
|
15
|
+
* result of the last `func` invocation.
|
|
16
|
+
*
|
|
17
|
+
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
18
|
+
* invoked on the trailing edge of the timeout only if the throttled function
|
|
19
|
+
* is invoked more than once during the `wait` timeout.
|
|
20
|
+
*
|
|
21
|
+
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
22
|
+
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
23
|
+
*
|
|
24
|
+
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
25
|
+
* for details over the differences between `_.throttle` and `_.debounce`.
|
|
26
|
+
*
|
|
27
|
+
* @static
|
|
28
|
+
* @memberOf _
|
|
29
|
+
* @since 0.1.0
|
|
30
|
+
* @category Function
|
|
31
|
+
* @param {Function} func The function to throttle.
|
|
32
|
+
* @param {number} [wait=0] The number of milliseconds to throttle invocations to.
|
|
33
|
+
* @param {Object} [options={}] The options object.
|
|
34
|
+
* @param {boolean} [options.leading=true]
|
|
35
|
+
* Specify invoking on the leading edge of the timeout.
|
|
36
|
+
* @param {boolean} [options.trailing=true]
|
|
37
|
+
* Specify invoking on the trailing edge of the timeout.
|
|
38
|
+
* @returns {Function} Returns the new throttled function.
|
|
39
|
+
* @example
|
|
40
|
+
*
|
|
41
|
+
* // Avoid excessively updating the position while scrolling.
|
|
42
|
+
* jQuery(window).on('scroll', _.throttle(updatePosition, 100));
|
|
43
|
+
*
|
|
44
|
+
* // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
|
|
45
|
+
* var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
|
|
46
|
+
* jQuery(element).on('click', throttled);
|
|
47
|
+
*
|
|
48
|
+
* // Cancel the trailing throttled invocation.
|
|
49
|
+
* jQuery(window).on('popstate', throttled.cancel);
|
|
50
|
+
*/
|
|
51
|
+
function throttle(func, wait, options) {
|
|
52
|
+
var leading = true,
|
|
53
|
+
trailing = true;
|
|
54
|
+
|
|
55
|
+
if (typeof func != 'function') {
|
|
56
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
57
|
+
}
|
|
58
|
+
if (isObject_1(options)) {
|
|
59
|
+
leading = 'leading' in options ? !!options.leading : leading;
|
|
60
|
+
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
|
61
|
+
}
|
|
62
|
+
return debounce_1(func, wait, {
|
|
63
|
+
'leading': leading,
|
|
64
|
+
'maxWait': wait,
|
|
65
|
+
'trailing': trailing
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
var throttle_1 = throttle;
|
|
70
|
+
|
|
71
|
+
export default throttle_1;
|
|
72
|
+
//# sourceMappingURL=throttle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -3,14 +3,14 @@ import Control from '../../index.js';
|
|
|
3
3
|
import Hint from '../../../hint/index.js';
|
|
4
4
|
import Multiple from '../../../dropdown/hoc/multiselect/index.js';
|
|
5
5
|
|
|
6
|
-
const ControlMultiSelect = ({ label, isRequired, id, name, defaultValues, options, isWithGroups, isWithSearch, defaultIsOpen, defaultCloseOnClick, isReadonly, isDisabled, onChange, onToggle, errors, hint, hintOptions = { isFixed: true } }) => {
|
|
6
|
+
const ControlMultiSelect = ({ label, isRequired, id, name, defaultValues, options, isWithGroups, isWithSearch, defaultIsOpen, defaultCloseOnClick, isReadonly, isDisabled, onChange, onToggle, errors, hint, hintOptions = { isFixed: true }, hasCloseIcon }) => {
|
|
7
7
|
return (React.createElement(Control, { errors: errors, name: name, id: id },
|
|
8
8
|
(label || hint) && (React.createElement(Control.Label, { id: id, isRequired: isRequired },
|
|
9
9
|
label,
|
|
10
10
|
hint && React.createElement(Hint, { fixed: hintOptions.isFixed, spacingLeft: true, hint: hint }))),
|
|
11
11
|
React.createElement(Control.Content, null,
|
|
12
12
|
React.createElement(Control.Element, null,
|
|
13
|
-
React.createElement(Multiple, { key: name, name: name, options: options, defaultValues: defaultValues, isWithGroups: isWithGroups, isWithSearch: isWithSearch, defaultIsOpen: defaultIsOpen, defaultCloseOnClick: defaultCloseOnClick, isReadonly: isReadonly, isDisabled: isDisabled, onChange: onChange, onToggle: onToggle }))),
|
|
13
|
+
React.createElement(Multiple, { key: name, name: name, options: options, defaultValues: defaultValues, isWithGroups: isWithGroups, isWithSearch: isWithSearch, defaultIsOpen: defaultIsOpen, defaultCloseOnClick: defaultCloseOnClick, isReadonly: isReadonly, isDisabled: isDisabled, onChange: onChange, onToggle: onToggle, hasCloseIcon: hasCloseIcon }))),
|
|
14
14
|
React.createElement(Control.Errors, null)));
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -18,14 +18,14 @@ import Select from '../../../dropdown/hoc/select/index.js';
|
|
|
18
18
|
* />
|
|
19
19
|
* )
|
|
20
20
|
*/
|
|
21
|
-
const ControlSelect = ({ label, isRequired, id, name, defaultValues, options, isWithGroups, isWithSearch, defaultIsOpen, defaultCloseOnClick, isReadonly, isDisabled, onChange, onToggle, errors, hint, hintOptions = { isFixed: true }, placeholder, additionalInfo, onScroll, innerAdditionalContent, onSearch }) => {
|
|
21
|
+
const ControlSelect = ({ label, isRequired, id, name, defaultValues, options, isWithGroups, isWithSearch, defaultIsOpen, defaultCloseOnClick, isReadonly, isDisabled, onChange, onToggle, errors, hint, hintOptions = { isFixed: true }, placeholder, additionalInfo, onScroll, innerAdditionalContent, onSearch, hasCloseIcon }) => {
|
|
22
22
|
return (React.createElement(Control, { errors: errors, name: name, id: id },
|
|
23
23
|
(label || hint) && (React.createElement(Control.Label, { id: id, isRequired: isRequired },
|
|
24
24
|
label,
|
|
25
25
|
hint && React.createElement(Hint, { fixed: hintOptions.isFixed, spacingLeft: true, hint: hint }))),
|
|
26
26
|
React.createElement(Control.Content, null,
|
|
27
27
|
React.createElement(Control.Element, null,
|
|
28
|
-
React.createElement(Select, { key: name, name: name, options: options, defaultValues: defaultValues, isWithGroups: isWithGroups, isWithSearch: isWithSearch, defaultIsOpen: defaultIsOpen, defaultCloseOnClick: defaultCloseOnClick, isReadonly: isReadonly, isDisabled: isDisabled, placeholder: placeholder, onChange: onChange, onToggle: onToggle, onScroll: onScroll, innerAdditionalContent: innerAdditionalContent, onSearch: onSearch }))),
|
|
28
|
+
React.createElement(Select, { key: name, name: name, options: options, defaultValues: defaultValues, isWithGroups: isWithGroups, isWithSearch: isWithSearch, defaultIsOpen: defaultIsOpen, defaultCloseOnClick: defaultCloseOnClick, isReadonly: isReadonly, isDisabled: isDisabled, placeholder: placeholder, onChange: onChange, onToggle: onToggle, onScroll: onScroll, innerAdditionalContent: innerAdditionalContent, onSearch: onSearch, hasCloseIcon: hasCloseIcon }))),
|
|
29
29
|
React.createElement(Control.Errors, null),
|
|
30
30
|
additionalInfo && React.createElement(Control.AdditionalInfo, null, additionalInfo)));
|
|
31
31
|
};
|
|
@@ -29,7 +29,7 @@ isReadonly = false,
|
|
|
29
29
|
/**
|
|
30
30
|
* array of selected options
|
|
31
31
|
*/
|
|
32
|
-
selectedOptions, placeholder, onRemoveOptions }) => {
|
|
32
|
+
selectedOptions, placeholder, onRemoveOptions, hasCloseIcon }) => {
|
|
33
33
|
const ref = useRef(null);
|
|
34
34
|
/**
|
|
35
35
|
* get values from dropdown context
|
|
@@ -50,7 +50,8 @@ selectedOptions, placeholder, onRemoveOptions }) => {
|
|
|
50
50
|
onRemoveOptions && onRemoveOptions();
|
|
51
51
|
};
|
|
52
52
|
return (React.createElement("div", { className: cssClasses['select'], "aria-expanded": isOpen, "aria-haspopup": "listbox", ref: ref },
|
|
53
|
-
React.createElement(InputWrapper, { value: value, isFocused: Boolean(isOpen), isDisabled: isDisabled, isReadOnly: isReadonly, onClick: toggleDropdown, placeholder: placeholder, postElements: !!selectedOptions.length &&
|
|
53
|
+
React.createElement(InputWrapper, { value: value, isFocused: Boolean(isOpen), isDisabled: isDisabled, isReadOnly: isReadonly, onClick: toggleDropdown, placeholder: placeholder, postElements: !!selectedOptions.length &&
|
|
54
|
+
hasCloseIcon && (React.createElement("button", { className: inputCssClasses[cssControlInputRemoveButton], onClick: handleOnClick },
|
|
54
55
|
React.createElement(IconClose, { size: "s" }))) }),
|
|
55
56
|
$hiddenInputs));
|
|
56
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -71,7 +71,7 @@ onToggle,
|
|
|
71
71
|
/**
|
|
72
72
|
* called on option change
|
|
73
73
|
*/
|
|
74
|
-
onChange }) => {
|
|
74
|
+
onChange, hasCloseIcon }) => {
|
|
75
75
|
/**
|
|
76
76
|
* reference to dropdown wrapper element
|
|
77
77
|
*/
|
|
@@ -98,7 +98,7 @@ onChange }) => {
|
|
|
98
98
|
useSetOptionsOnClose(isWithSearch, isOpen, setOptionsList, options);
|
|
99
99
|
return (React.createElement(DropdownContext.Provider, { value: value },
|
|
100
100
|
React.createElement("div", { ref: wrapperRef, className: cssClasses[cssDropdown] },
|
|
101
|
-
React.createElement(Dropdown.Select, { name: name, isReadonly: isReadonly, isDisabled: isDisabled, selectedOptions: selectedValues, onRemoveOptions: setSelectedValues }),
|
|
101
|
+
React.createElement(Dropdown.Select, { name: name, isReadonly: isReadonly, isDisabled: isDisabled, selectedOptions: selectedValues, onRemoveOptions: setSelectedValues, hasCloseIcon: hasCloseIcon }),
|
|
102
102
|
React.createElement(Dropdown.Content, null,
|
|
103
103
|
isWithSearch && React.createElement(Dropdown.Search, { onKeyUp: (ev) => handleSearchKeyUp(ev, options, setOptionsList) }),
|
|
104
104
|
React.createElement(Dropdown.List, { isWithGroups: isWithGroups }, optionsList === null || optionsList === void 0 ? void 0 : optionsList.map((option) => {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { useRef, useState, useEffect } from 'react';
|
|
2
|
-
import debounce_1 from '../../../../../../../external/lodash/debounce.js';
|
|
3
2
|
import { DropdownContext } from '../../context/index.js';
|
|
4
3
|
import { cssDropdown } from '../../css_classes.js';
|
|
5
4
|
import cssClasses from '../../../../css/dropdown/main.module.less.js';
|
|
@@ -8,7 +7,6 @@ import { useValue } from '../../hooks/use_value.js';
|
|
|
8
7
|
import { useToggle } from '../../hooks/use_toggle.js';
|
|
9
8
|
import { useSetOptionsOnClose } from '../../hooks/use_set_options_on_close.js';
|
|
10
9
|
import Dropdown from '../../index.js';
|
|
11
|
-
import { SEARCH_DEBOUNCE_TIMEOUT_IN_MS } from './select_constants.js';
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* Select component. Build with Dropdown composed components.
|
|
@@ -77,7 +75,7 @@ onChange,
|
|
|
77
75
|
* Place where portal should be placed, by default to body
|
|
78
76
|
* this can be used to put modal inside modal
|
|
79
77
|
*/
|
|
80
|
-
portalContainer, placeholder, onScroll, innerAdditionalContent, onSearch }) => {
|
|
78
|
+
portalContainer, placeholder, onScroll, innerAdditionalContent, onSearch, hasCloseIcon }) => {
|
|
81
79
|
/**
|
|
82
80
|
* reference to dropdown wrapper element
|
|
83
81
|
*/
|
|
@@ -102,16 +100,16 @@ portalContainer, placeholder, onScroll, innerAdditionalContent, onSearch }) => {
|
|
|
102
100
|
* hook which resets options list to default on close if select has search and it was used
|
|
103
101
|
*/
|
|
104
102
|
useSetOptionsOnClose(isWithSearch, isOpen, setOptionsList, options);
|
|
105
|
-
const handleSearch =
|
|
103
|
+
const handleSearch = (ev) => {
|
|
106
104
|
onSearch && onSearch(ev);
|
|
107
105
|
handleSearchKeyUp(ev, options, setOptionsList);
|
|
108
|
-
}
|
|
106
|
+
};
|
|
109
107
|
useEffect(() => {
|
|
110
108
|
setOptionsList(options);
|
|
111
109
|
}, [options]);
|
|
112
110
|
return (React.createElement(DropdownContext.Provider, { value: value },
|
|
113
111
|
React.createElement("div", { ref: wrapperRef, className: cssClasses[cssDropdown] },
|
|
114
|
-
React.createElement(Dropdown.Select, { name: name, isReadonly: isReadonly, isDisabled: isDisabled, selectedOptions: selectedValues, placeholder: placeholder, onRemoveOptions: setSelectedValues }),
|
|
112
|
+
React.createElement(Dropdown.Select, { name: name, isReadonly: isReadonly, isDisabled: isDisabled, selectedOptions: selectedValues, placeholder: placeholder, onRemoveOptions: setSelectedValues, hasCloseIcon: hasCloseIcon }),
|
|
115
113
|
React.createElement(Dropdown.Content, { portalContainer: portalContainer },
|
|
116
114
|
isWithSearch && React.createElement(Dropdown.Search, { onKeyUp: (ev) => handleSearch(ev) }),
|
|
117
115
|
React.createElement(Dropdown.List, { isWithGroups: isWithGroups, onScroll: onScroll }, optionsList === null || optionsList === void 0 ? void 0 :
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
package/build/esm/packages/aurora/src/components/dropdown/hoc/xhr_select/hooks/use_xhr_select.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { useState, useCallback, useEffect } from 'react';
|
|
2
2
|
import { useTranslation } from '../../../../../../../../external/react-i18next/dist/es/useTranslation.js';
|
|
3
|
+
import debounce_1 from '../../../../../../../../external/lodash/debounce.js';
|
|
3
4
|
import { SCROLL_FETCH_TIMEOUT_IN_MS } from '../xhr_select_constants.js';
|
|
5
|
+
import { SEARCH_DATA_DEBOUNCE_TIMEOUT_IN_MS, LOAD_DATA_ON_SCROLL_THROTTLE_TIME_IN_MS } from './use_xhr_select_constants.js';
|
|
6
|
+
import throttle_1 from '../../../../../../../../external/lodash/throttle.js';
|
|
4
7
|
import { XhrSelectResponseParser } from '../http/xhr_select_response_parser.js';
|
|
5
8
|
|
|
6
9
|
const useXhrSelect = ({ url, fetchClient, onScroll }) => {
|
|
@@ -11,7 +14,7 @@ const useXhrSelect = ({ url, fetchClient, onScroll }) => {
|
|
|
11
14
|
const [search, setSearch] = useState(null);
|
|
12
15
|
const [t] = useTranslation();
|
|
13
16
|
const xhrSelectResponseParser = new XhrSelectResponseParser();
|
|
14
|
-
const loadSelectDataOnScroll = (event) => {
|
|
17
|
+
const loadSelectDataOnScroll = throttle_1((event) => {
|
|
15
18
|
onScroll && onScroll(event);
|
|
16
19
|
if ((selectData === null || selectData === void 0 ? void 0 : selectData.page) === (selectData === null || selectData === void 0 ? void 0 : selectData.pages))
|
|
17
20
|
return;
|
|
@@ -40,7 +43,7 @@ const useXhrSelect = ({ url, fetchClient, onScroll }) => {
|
|
|
40
43
|
}
|
|
41
44
|
});
|
|
42
45
|
}, SCROLL_FETCH_TIMEOUT_IN_MS)));
|
|
43
|
-
};
|
|
46
|
+
}, LOAD_DATA_ON_SCROLL_THROTTLE_TIME_IN_MS);
|
|
44
47
|
const resetScrollTimerAndError = () => {
|
|
45
48
|
clearTimeout(scrollTimer);
|
|
46
49
|
setScrollTimer(undefined);
|
|
@@ -49,7 +52,7 @@ const useXhrSelect = ({ url, fetchClient, onScroll }) => {
|
|
|
49
52
|
scrollError: ''
|
|
50
53
|
});
|
|
51
54
|
};
|
|
52
|
-
const loadSelectDataOnSearch = (ev) => {
|
|
55
|
+
const loadSelectDataOnSearch = debounce_1((ev) => {
|
|
53
56
|
const currentSearch = ev.target.value;
|
|
54
57
|
if (currentSearch === search)
|
|
55
58
|
return;
|
|
@@ -70,7 +73,7 @@ const useXhrSelect = ({ url, fetchClient, onScroll }) => {
|
|
|
70
73
|
});
|
|
71
74
|
}
|
|
72
75
|
});
|
|
73
|
-
};
|
|
76
|
+
}, SEARCH_DATA_DEBOUNCE_TIMEOUT_IN_MS);
|
|
74
77
|
const fetchXhrData = useCallback(({ url, handleResponseData, handleCatchErrors }) => {
|
|
75
78
|
fetchClient
|
|
76
79
|
.fetch({ method: 'get', url })
|
package/build/esm/packages/aurora/src/components/dropdown/hoc/xhr_select/hooks/use_xhr_select.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA,+BAA+B,0EAA8E;AAC7G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA,+BAA+B,0EAA8E;AAC7G,uBAAuB,qDAAyD;AAChF;AACA;AACA,uBAAuB,qDAAyD;AAChF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;"}
|
|
@@ -53,7 +53,7 @@ const XhrSelect = ({ url, headerTitle, noItemsErrorMessage, onScroll, fetchClien
|
|
|
53
53
|
"..."));
|
|
54
54
|
if (!(selectData === null || selectData === void 0 ? void 0 : selectData.list.length) && search === null)
|
|
55
55
|
return React.createElement(MessageBox, { type: "alert" }, noItemsErrorMessage);
|
|
56
|
-
return (React.createElement(ControlSelect, { ...props, isWithSearch: true, options: mapSelectDataToSelectOptions(selectData || { list: [] }), onScroll: loadSelectDataOnScroll, onSearch: loadSelectDataOnSearch, innerAdditionalContent: React.createElement(React.Fragment, null,
|
|
56
|
+
return (React.createElement(ControlSelect, { ...props, isWithSearch: true, options: mapSelectDataToSelectOptions(selectData || { list: [] }), onScroll: loadSelectDataOnScroll, onSearch: loadSelectDataOnSearch, hasCloseIcon: true, innerAdditionalContent: React.createElement(React.Fragment, null,
|
|
57
57
|
errors.scrollError && (React.createElement("div", { className: `${cssClasses[cssSelectAdditionalContent]} ${cssClasses[cssSelectError]}` },
|
|
58
58
|
React.createElement(IconWarning, { size: "m", className: cssClasses[cssSelectErrorIcon] }),
|
|
59
59
|
errors.scrollError)),
|
|
@@ -27,6 +27,7 @@ export interface IDropdownSelectProps {
|
|
|
27
27
|
isDisabled?: boolean;
|
|
28
28
|
isReadonly?: boolean;
|
|
29
29
|
placeholder?: string;
|
|
30
|
+
hasCloseIcon?: boolean;
|
|
30
31
|
onRemoveOptions?: (...args: any[]) => any;
|
|
31
32
|
}
|
|
32
33
|
export interface IDropdownLabelProps {
|
|
@@ -96,6 +97,7 @@ export interface ISelectProps extends IDropdownProps {
|
|
|
96
97
|
isWithSearch?: boolean;
|
|
97
98
|
placeholder?: string;
|
|
98
99
|
innerAdditionalContent?: React.ReactNode;
|
|
100
|
+
hasCloseIcon?: boolean;
|
|
99
101
|
onChange?: (selectedOption: ISelectOption) => void;
|
|
100
102
|
onScroll?: (event: React.UIEvent<HTMLElement>) => void;
|
|
101
103
|
onSearch?: (ev: React.KeyboardEvent<HTMLInputElement>) => void;
|
package/package.json
CHANGED
package/build/cjs/packages/aurora/src/components/dropdown/hoc/select/select_constants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const SEARCH_DEBOUNCE_TIMEOUT_IN_MS = 500;
|