@mailstep/design-system 0.6.76 → 0.6.77
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/package.json +1 -1
- package/ui/Elements/SingleSelect/SingleSelect.d.ts +1 -0
- package/ui/Elements/SingleSelect/SingleSelect.js +9 -4
- package/ui/index.es.js +2236 -2233
- package/ui/index.umd.js +280 -280
package/package.json
CHANGED
|
@@ -15,6 +15,7 @@ export type Props = Omit<SelectProps, 'onChange' | 'loadOptions'> & {
|
|
|
15
15
|
initialOptions?: Option[];
|
|
16
16
|
loadOptions?: (fulltext: string, byId: boolean) => Promise<Option[]>;
|
|
17
17
|
form?: any;
|
|
18
|
+
shouldReloadOptions?: boolean;
|
|
18
19
|
};
|
|
19
20
|
declare const SingleSelect: (props: Props) => JSX.Element;
|
|
20
21
|
export default SingleSelect;
|
|
@@ -81,8 +81,8 @@ var getOptionValue = function (selectedOption) {
|
|
|
81
81
|
};
|
|
82
82
|
var loadingMessage = function () { return i18n._({ id: 'components.dropdown.loading', message: 'Loading...' }); };
|
|
83
83
|
var SingleSelect = function (props) {
|
|
84
|
-
var name = props.name, onChange = props.onChange, onBlur = props.onBlur, onValueChange = props.onValueChange, loadOptions = props.loadOptions, _a = props.asyncLoadMinChars, asyncLoadMinChars = _a === void 0 ? 0 : _a, isLocked = props.isLocked, _b = props.lockedText, lockedText = _b === void 0 ? i18n._({ id: 'components.dropdown.notReact', message: 'Select related values first...' }) : _b, disabled = props.disabled, _c = props.placeholder, placeholder = _c === void 0 ? i18n._({ id: 'components.dropdown.placeholder', message: 'Select...' }) : _c, preload = props.preload, initialOptions = props.initialOptions, onCreateOption = props.onCreateOption, options = props.options, filterOption = props.filterOption;
|
|
85
|
-
var
|
|
84
|
+
var name = props.name, onChange = props.onChange, onBlur = props.onBlur, onValueChange = props.onValueChange, loadOptions = props.loadOptions, _a = props.asyncLoadMinChars, asyncLoadMinChars = _a === void 0 ? 0 : _a, isLocked = props.isLocked, _b = props.lockedText, lockedText = _b === void 0 ? i18n._({ id: 'components.dropdown.notReact', message: 'Select related values first...' }) : _b, disabled = props.disabled, _c = props.placeholder, placeholder = _c === void 0 ? i18n._({ id: 'components.dropdown.placeholder', message: 'Select...' }) : _c, preload = props.preload, initialOptions = props.initialOptions, onCreateOption = props.onCreateOption, options = props.options, filterOption = props.filterOption, _d = props.shouldReloadOptions, shouldReloadOptions = _d === void 0 ? false : _d;
|
|
85
|
+
var _e = useState(false), isCreating = _e[0], setIsCreating = _e[1];
|
|
86
86
|
var asAsync = !!loadOptions || !!onCreateOption;
|
|
87
87
|
var noOptionsMessage = useCallback(function (inputValue) {
|
|
88
88
|
return loadOptions && inputValue.length < asyncLoadMinChars
|
|
@@ -111,13 +111,13 @@ var SingleSelect = function (props) {
|
|
|
111
111
|
return loadOptions(inputValue, false);
|
|
112
112
|
}
|
|
113
113
|
}, [onCreateOption, loadOptions, asyncLoadMinChars, options]);
|
|
114
|
-
var
|
|
114
|
+
var _f = useState(options || []), loadedDefaultOptions = _f[0], setLoadedDefaultOptions = _f[1];
|
|
115
115
|
useEffect(function () {
|
|
116
116
|
if (loadOptions && preload && !props.value)
|
|
117
117
|
loadOptions('', false).then(setLoadedDefaultOptions);
|
|
118
118
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
119
119
|
}, [loadOptions]); // this is intentional
|
|
120
|
-
var
|
|
120
|
+
var _g = useState(null), storedSelectedOption = _g[0], setStoredSelectedOption = _g[1];
|
|
121
121
|
useEffect(function () {
|
|
122
122
|
if (initialOptions && initialOptions.length) {
|
|
123
123
|
var selectedOption = initialOptions.find(function (option) { return option.value == props.value; }) || null;
|
|
@@ -129,6 +129,11 @@ var SingleSelect = function (props) {
|
|
|
129
129
|
// ignored because of props.value, this only finds option for initial value
|
|
130
130
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
131
131
|
}, [initialOptions, setStoredSelectedOption]);
|
|
132
|
+
useEffect(function () {
|
|
133
|
+
if (shouldReloadOptions) {
|
|
134
|
+
setLoadedDefaultOptions(options || []);
|
|
135
|
+
}
|
|
136
|
+
}, [options]);
|
|
132
137
|
var handleChange = useCallback(function (option) { return __awaiter(void 0, void 0, void 0, function () {
|
|
133
138
|
var value, newOption;
|
|
134
139
|
var _a, _b, _c, _d;
|