@ntbjs/react-components 1.1.0-beta.41 → 1.1.0-beta.43
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,20 @@ 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
|
+
availableOptions = _ref.availableOptions,
|
|
45
|
+
loadingMessageFunc = _ref.loadingMessageFunc,
|
|
46
|
+
placeholder = _ref.placeholder,
|
|
47
|
+
props = defaultTheme._objectWithoutProperties(_ref, ["clickToAdd", "customAddMessage", "selectedOption", "loadOptions", "readOnly", "name", "lightBackground", "autoSelect", "subscribeCurrentValue", "onChange", "onFocus", "onBlur", "onUpdateCallback", "availableOptions", "loadingMessageFunc", "placeholder"]);
|
|
44
48
|
|
|
45
49
|
var _useState = React.useState(false),
|
|
46
50
|
_useState2 = defaultTheme._slicedToArray(_useState, 2),
|
|
@@ -77,6 +81,11 @@ var Instructions = React__default['default'].forwardRef(function Instructions(_r
|
|
|
77
81
|
currentValue = _useState14[0],
|
|
78
82
|
setCurrentValue = _useState14[1];
|
|
79
83
|
|
|
84
|
+
React.useEffect(function () {
|
|
85
|
+
if (lodash.isFunction(subscribeCurrentValueProp)) {
|
|
86
|
+
subscribeCurrentValueProp(currentValue);
|
|
87
|
+
}
|
|
88
|
+
}, [currentValue]);
|
|
80
89
|
React.useEffect(function () {
|
|
81
90
|
handleChange(selected);
|
|
82
91
|
}, [selected]);
|
|
@@ -117,36 +126,6 @@ var Instructions = React__default['default'].forwardRef(function Instructions(_r
|
|
|
117
126
|
}
|
|
118
127
|
}, [onBlurProp]);
|
|
119
128
|
|
|
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
129
|
var handleMouseEnter = function handleMouseEnter() {
|
|
151
130
|
setIsHovered(true);
|
|
152
131
|
};
|
|
@@ -178,6 +157,16 @@ var Instructions = React__default['default'].forwardRef(function Instructions(_r
|
|
|
178
157
|
}
|
|
179
158
|
};
|
|
180
159
|
|
|
160
|
+
var sharedSelectProps = {
|
|
161
|
+
ref: forwardedRef,
|
|
162
|
+
options: loadOptions ? undefined : availableOptions,
|
|
163
|
+
loadOptions: loadOptions,
|
|
164
|
+
loadingMessage: loadingMessageFunc,
|
|
165
|
+
value: {
|
|
166
|
+
selectedOption: selectedOption
|
|
167
|
+
},
|
|
168
|
+
placeholder: placeholder
|
|
169
|
+
};
|
|
181
170
|
return React__default['default'].createElement(Instructions$1, defaultTheme._extends({
|
|
182
171
|
ref: forwardedRef,
|
|
183
172
|
initialHover: initialHover,
|
|
@@ -186,13 +175,11 @@ var Instructions = React__default['default'].forwardRef(function Instructions(_r
|
|
|
186
175
|
}, props), React__default['default'].createElement(TopBarContainer, {
|
|
187
176
|
initialHover: initialHover,
|
|
188
177
|
className: isHovered && !readOnly && 'slide-in'
|
|
189
|
-
}, React__default['default'].createElement(SelectContainer, null, React__default['default'].createElement(AutocompleteSelect.AutocompleteSelect, {
|
|
178
|
+
}, React__default['default'].createElement(SelectContainer, null, React__default['default'].createElement(AutocompleteSelect.AutocompleteSelect, defaultTheme._extends({
|
|
190
179
|
warning: true,
|
|
191
180
|
creatable: false,
|
|
192
|
-
value: selectedOption,
|
|
193
|
-
loadOptions: loadOptionsPromise,
|
|
194
181
|
onChange: handleChange
|
|
195
|
-
}))), React__default['default'].createElement(InstructionsArea, null, React__default['default'].createElement(TextArea.TextArea, {
|
|
182
|
+
}, sharedSelectProps)))), React__default['default'].createElement(InstructionsArea, null, React__default['default'].createElement(TextArea.TextArea, {
|
|
196
183
|
noBorder: true,
|
|
197
184
|
lightBackground: background,
|
|
198
185
|
readOnly: readOnly,
|
|
@@ -212,13 +199,18 @@ Instructions.defaultProps = {
|
|
|
212
199
|
};
|
|
213
200
|
Instructions.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
214
201
|
name: defaultTheme.PropTypes.string,
|
|
202
|
+
placeholder: defaultTheme.PropTypes.string,
|
|
215
203
|
selectedOption: defaultTheme.PropTypes.any,
|
|
204
|
+
loadOptions: defaultTheme.PropTypes.func,
|
|
205
|
+
loadingMessageFunc: defaultTheme.PropTypes.func,
|
|
216
206
|
clickToAdd: defaultTheme.PropTypes.bool,
|
|
217
207
|
customAddMessage: defaultTheme.PropTypes.string,
|
|
218
208
|
autoSelect: defaultTheme.PropTypes.bool,
|
|
219
209
|
readOnly: defaultTheme.PropTypes.bool,
|
|
210
|
+
availableOptions: defaultTheme.PropTypes.arrayOf(defaultTheme.PropTypes.object),
|
|
220
211
|
lightBackground: defaultTheme.PropTypes.bool,
|
|
221
212
|
options: defaultTheme.PropTypes.array,
|
|
213
|
+
subscribeCurrentValue: defaultTheme.PropTypes.func,
|
|
222
214
|
onChange: defaultTheme.PropTypes.func,
|
|
223
215
|
onFocus: defaultTheme.PropTypes.func,
|
|
224
216
|
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-91831689.js');
|
|
9
9
|
require('../defaultTheme-870f7df1.js');
|
|
10
10
|
require('styled-components');
|
|
11
11
|
require('react');
|