@ntbjs/react-components 1.1.0-beta.41 → 1.1.0-beta.42
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.
|
@@ -31,16 +31,18 @@ var Instructions = React__default['default'].forwardRef(function Instructions(_r
|
|
|
31
31
|
var clickToAdd = _ref.clickToAdd,
|
|
32
32
|
customAddMessage = _ref.customAddMessage,
|
|
33
33
|
selectedOption = _ref.selectedOption,
|
|
34
|
+
loadOptions = _ref.loadOptions,
|
|
34
35
|
readOnly = _ref.readOnly,
|
|
35
36
|
name = _ref.name,
|
|
36
37
|
lightBackground = _ref.lightBackground,
|
|
37
|
-
options = _ref.options,
|
|
38
38
|
autoSelect = _ref.autoSelect,
|
|
39
|
+
subscribeCurrentValueProp = _ref.subscribeCurrentValue,
|
|
39
40
|
onChangeProp = _ref.onChange,
|
|
40
41
|
onFocusProp = _ref.onFocus,
|
|
41
42
|
onBlurProp = _ref.onBlur,
|
|
42
43
|
onUpdateCallback = _ref.onUpdateCallback,
|
|
43
|
-
|
|
44
|
+
loadingMessageFunc = _ref.loadingMessageFunc,
|
|
45
|
+
props = defaultTheme._objectWithoutProperties(_ref, ["clickToAdd", "customAddMessage", "selectedOption", "loadOptions", "readOnly", "name", "lightBackground", "autoSelect", "subscribeCurrentValue", "onChange", "onFocus", "onBlur", "onUpdateCallback", "loadingMessageFunc"]);
|
|
44
46
|
|
|
45
47
|
var _useState = React.useState(false),
|
|
46
48
|
_useState2 = defaultTheme._slicedToArray(_useState, 2),
|
|
@@ -77,6 +79,11 @@ var Instructions = React__default['default'].forwardRef(function Instructions(_r
|
|
|
77
79
|
currentValue = _useState14[0],
|
|
78
80
|
setCurrentValue = _useState14[1];
|
|
79
81
|
|
|
82
|
+
React.useEffect(function () {
|
|
83
|
+
if (lodash.isFunction(subscribeCurrentValueProp)) {
|
|
84
|
+
subscribeCurrentValueProp(currentValue);
|
|
85
|
+
}
|
|
86
|
+
}, [currentValue]);
|
|
80
87
|
React.useEffect(function () {
|
|
81
88
|
handleChange(selected);
|
|
82
89
|
}, [selected]);
|
|
@@ -117,36 +124,6 @@ var Instructions = React__default['default'].forwardRef(function Instructions(_r
|
|
|
117
124
|
}
|
|
118
125
|
}, [onBlurProp]);
|
|
119
126
|
|
|
120
|
-
var filterOptions = function filterOptions(inputValue) {
|
|
121
|
-
return options.filter(function (option) {
|
|
122
|
-
return option.label.toLowerCase().includes(inputValue.toLowerCase());
|
|
123
|
-
});
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
var loadOptions = function loadOptions(inputValue, prevOptions) {
|
|
127
|
-
var pageLength = 10;
|
|
128
|
-
var filteredOptions;
|
|
129
|
-
|
|
130
|
-
if (!inputValue) {
|
|
131
|
-
filteredOptions = options;
|
|
132
|
-
} else {
|
|
133
|
-
filteredOptions = filterOptions(inputValue);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
var hasMore = filteredOptions.length > prevOptions.length + pageLength;
|
|
137
|
-
var slicedOptions = filteredOptions.slice(prevOptions.length, prevOptions.length + pageLength);
|
|
138
|
-
return {
|
|
139
|
-
options: slicedOptions,
|
|
140
|
-
hasMore: hasMore
|
|
141
|
-
};
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
var loadOptionsPromise = function loadOptionsPromise(inputValue, prevOptions) {
|
|
145
|
-
return new Promise(function (resolve) {
|
|
146
|
-
resolve(loadOptions(inputValue, prevOptions));
|
|
147
|
-
});
|
|
148
|
-
};
|
|
149
|
-
|
|
150
127
|
var handleMouseEnter = function handleMouseEnter() {
|
|
151
128
|
setIsHovered(true);
|
|
152
129
|
};
|
|
@@ -190,7 +167,8 @@ var Instructions = React__default['default'].forwardRef(function Instructions(_r
|
|
|
190
167
|
warning: true,
|
|
191
168
|
creatable: false,
|
|
192
169
|
value: selectedOption,
|
|
193
|
-
loadOptions:
|
|
170
|
+
loadOptions: loadOptions,
|
|
171
|
+
loadingMessageFunc: loadingMessageFunc,
|
|
194
172
|
onChange: handleChange
|
|
195
173
|
}))), React__default['default'].createElement(InstructionsArea, null, React__default['default'].createElement(TextArea.TextArea, {
|
|
196
174
|
noBorder: true,
|
|
@@ -213,12 +191,15 @@ Instructions.defaultProps = {
|
|
|
213
191
|
Instructions.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
214
192
|
name: defaultTheme.PropTypes.string,
|
|
215
193
|
selectedOption: defaultTheme.PropTypes.any,
|
|
194
|
+
loadOptions: defaultTheme.PropTypes.func,
|
|
195
|
+
loadingMessageFunc: defaultTheme.PropTypes.func,
|
|
216
196
|
clickToAdd: defaultTheme.PropTypes.bool,
|
|
217
197
|
customAddMessage: defaultTheme.PropTypes.string,
|
|
218
198
|
autoSelect: defaultTheme.PropTypes.bool,
|
|
219
199
|
readOnly: defaultTheme.PropTypes.bool,
|
|
220
200
|
lightBackground: defaultTheme.PropTypes.bool,
|
|
221
201
|
options: defaultTheme.PropTypes.array,
|
|
202
|
+
subscribeCurrentValue: defaultTheme.PropTypes.func,
|
|
222
203
|
onChange: defaultTheme.PropTypes.func,
|
|
223
204
|
onFocus: defaultTheme.PropTypes.func,
|
|
224
205
|
onBlur: defaultTheme.PropTypes.func,
|
package/package.json
CHANGED
package/widgets/index.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var AssetGallery = require('../AssetGallery-f082c487.js');
|
|
6
6
|
var ContextMenu = require('../ContextMenu-59c2a64f.js');
|
|
7
7
|
var AssetPreviewTopBar = require('../AssetPreviewTopBar-020a6f96.js');
|
|
8
|
-
var Instructions = require('../Instructions-
|
|
8
|
+
var Instructions = require('../Instructions-fc596e6a.js');
|
|
9
9
|
require('../defaultTheme-870f7df1.js');
|
|
10
10
|
require('styled-components');
|
|
11
11
|
require('react');
|