@ntbjs/react-components 1.1.0-beta.40 → 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,17 +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
39
  subscribeCurrentValueProp = _ref.subscribeCurrentValue,
40
40
  onChangeProp = _ref.onChange,
41
41
  onFocusProp = _ref.onFocus,
42
42
  onBlurProp = _ref.onBlur,
43
43
  onUpdateCallback = _ref.onUpdateCallback,
44
- props = defaultTheme._objectWithoutProperties(_ref, ["clickToAdd", "customAddMessage", "selectedOption", "readOnly", "name", "lightBackground", "options", "autoSelect", "subscribeCurrentValue", "onChange", "onFocus", "onBlur", "onUpdateCallback"]);
44
+ loadingMessageFunc = _ref.loadingMessageFunc,
45
+ props = defaultTheme._objectWithoutProperties(_ref, ["clickToAdd", "customAddMessage", "selectedOption", "loadOptions", "readOnly", "name", "lightBackground", "autoSelect", "subscribeCurrentValue", "onChange", "onFocus", "onBlur", "onUpdateCallback", "loadingMessageFunc"]);
45
46
 
46
47
  var _useState = React.useState(false),
47
48
  _useState2 = defaultTheme._slicedToArray(_useState, 2),
@@ -78,6 +79,25 @@ var Instructions = React__default['default'].forwardRef(function Instructions(_r
78
79
  currentValue = _useState14[0],
79
80
  setCurrentValue = _useState14[1];
80
81
 
82
+ React.useEffect(function () {
83
+ if (lodash.isFunction(subscribeCurrentValueProp)) {
84
+ subscribeCurrentValueProp(currentValue);
85
+ }
86
+ }, [currentValue]);
87
+ React.useEffect(function () {
88
+ handleChange(selected);
89
+ }, [selected]);
90
+ React.useEffect(function () {
91
+ if (selectedOption) {
92
+ setCurrentValue(selectedOption.value);
93
+ }
94
+ }, [selectedOption]);
95
+ React.useEffect(function () {
96
+ if (addInstructions) {
97
+ setCurrentValue(customMessage);
98
+ setInitialHover(true);
99
+ }
100
+ }, [addInstructions, handleOnFocus]);
81
101
  var onChange = React.useCallback(function (event) {
82
102
  setCurrentValue(event.target.value);
83
103
 
@@ -104,36 +124,6 @@ var Instructions = React__default['default'].forwardRef(function Instructions(_r
104
124
  }
105
125
  }, [onBlurProp]);
106
126
 
107
- var filterOptions = function filterOptions(inputValue) {
108
- return options.filter(function (option) {
109
- return option.label.toLowerCase().includes(inputValue.toLowerCase());
110
- });
111
- };
112
-
113
- var loadOptions = function loadOptions(inputValue, prevOptions) {
114
- var pageLength = 10;
115
- var filteredOptions;
116
-
117
- if (!inputValue) {
118
- filteredOptions = options;
119
- } else {
120
- filteredOptions = filterOptions(inputValue);
121
- }
122
-
123
- var hasMore = filteredOptions.length > prevOptions.length + pageLength;
124
- var slicedOptions = filteredOptions.slice(prevOptions.length, prevOptions.length + pageLength);
125
- return {
126
- options: slicedOptions,
127
- hasMore: hasMore
128
- };
129
- };
130
-
131
- var loadOptionsPromise = function loadOptionsPromise(inputValue, prevOptions) {
132
- return new Promise(function (resolve) {
133
- resolve(loadOptions(inputValue, prevOptions));
134
- });
135
- };
136
-
137
127
  var handleMouseEnter = function handleMouseEnter() {
138
128
  setIsHovered(true);
139
129
  };
@@ -165,25 +155,6 @@ var Instructions = React__default['default'].forwardRef(function Instructions(_r
165
155
  }
166
156
  };
167
157
 
168
- React.useEffect(function () {
169
- if (lodash.isFunction(subscribeCurrentValueProp)) {
170
- subscribeCurrentValueProp(currentValue);
171
- }
172
- }, [currentValue]);
173
- React.useEffect(function () {
174
- handleChange(selected);
175
- }, [selected]);
176
- React.useEffect(function () {
177
- if (selectedOption) {
178
- setCurrentValue(selectedOption.value);
179
- }
180
- }, [selectedOption]);
181
- React.useEffect(function () {
182
- if (addInstructions) {
183
- setCurrentValue(customMessage);
184
- setInitialHover(true);
185
- }
186
- }, [addInstructions, handleOnFocus]);
187
158
  return React__default['default'].createElement(Instructions$1, defaultTheme._extends({
188
159
  ref: forwardedRef,
189
160
  initialHover: initialHover,
@@ -196,7 +167,8 @@ var Instructions = React__default['default'].forwardRef(function Instructions(_r
196
167
  warning: true,
197
168
  creatable: false,
198
169
  value: selectedOption,
199
- loadOptions: loadOptionsPromise,
170
+ loadOptions: loadOptions,
171
+ loadingMessageFunc: loadingMessageFunc,
200
172
  onChange: handleChange
201
173
  }))), React__default['default'].createElement(InstructionsArea, null, React__default['default'].createElement(TextArea.TextArea, {
202
174
  noBorder: true,
@@ -219,6 +191,8 @@ Instructions.defaultProps = {
219
191
  Instructions.propTypes = process.env.NODE_ENV !== "production" ? {
220
192
  name: defaultTheme.PropTypes.string,
221
193
  selectedOption: defaultTheme.PropTypes.any,
194
+ loadOptions: defaultTheme.PropTypes.func,
195
+ loadingMessageFunc: defaultTheme.PropTypes.func,
222
196
  clickToAdd: defaultTheme.PropTypes.bool,
223
197
  customAddMessage: defaultTheme.PropTypes.string,
224
198
  autoSelect: defaultTheme.PropTypes.bool,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ntbjs/react-components",
3
- "version": "1.1.0-beta.40",
3
+ "version": "1.1.0-beta.42",
4
4
  "description": "NTBs common front-end design utilities and React components.",
5
5
  "scripts": {
6
6
  "build": "cross-env NODE_ENV=production rollup -c",
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var Instructions = require('../../Instructions-8fc0fc8c.js');
3
+ var Instructions = require('../../Instructions-fc596e6a.js');
4
4
  require('../../defaultTheme-870f7df1.js');
5
5
  require('styled-components');
6
6
  require('react');
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-8fc0fc8c.js');
8
+ var Instructions = require('../Instructions-fc596e6a.js');
9
9
  require('../defaultTheme-870f7df1.js');
10
10
  require('styled-components');
11
11
  require('react');