@ntbjs/react-components 1.1.0-beta.20 → 1.1.0-beta.22

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.
@@ -34,37 +34,8 @@ var Instructions = React__default['default'].forwardRef(function Instructions(_r
34
34
  readOnly = _ref.readOnly,
35
35
  lightBackground = _ref.lightBackground,
36
36
  options = _ref.options,
37
- props = defaultTheme._objectWithoutProperties(_ref, ["clickToAdd", "customAddMessage", "selectedOption", "readOnly", "lightBackground", "options"]);
38
-
39
- var filterOptions = function filterOptions(inputValue) {
40
- return options.filter(function (option) {
41
- return option.label.toLowerCase().includes(inputValue.toLowerCase());
42
- });
43
- };
44
-
45
- var loadOptions = function loadOptions(inputValue, prevOptions) {
46
- var pageLength = 10;
47
- var filteredOptions;
48
-
49
- if (!inputValue) {
50
- filteredOptions = options;
51
- } else {
52
- filteredOptions = filterOptions(inputValue);
53
- }
54
-
55
- var hasMore = filteredOptions.length > prevOptions.length + pageLength;
56
- var slicedOptions = filteredOptions.slice(prevOptions.length, prevOptions.length + pageLength);
57
- return {
58
- options: slicedOptions,
59
- hasMore: hasMore
60
- };
61
- };
62
-
63
- var loadOptionsPromise = function loadOptionsPromise(inputValue, prevOptions) {
64
- return new Promise(function (resolve) {
65
- resolve(loadOptions(inputValue, prevOptions));
66
- });
67
- };
37
+ subscribeCurrentValueProp = _ref.subscribeCurrentValue,
38
+ props = defaultTheme._objectWithoutProperties(_ref, ["clickToAdd", "customAddMessage", "selectedOption", "readOnly", "lightBackground", "options", "subscribeCurrentValue"]);
68
39
 
69
40
  var _useState = React.useState(false),
70
41
  _useState2 = defaultTheme._slicedToArray(_useState, 2),
@@ -101,6 +72,36 @@ var Instructions = React__default['default'].forwardRef(function Instructions(_r
101
72
  currentValue = _useState14[0],
102
73
  setCurrentValue = _useState14[1];
103
74
 
75
+ var filterOptions = function filterOptions(inputValue) {
76
+ return options.filter(function (option) {
77
+ return option.label.toLowerCase().includes(inputValue.toLowerCase());
78
+ });
79
+ };
80
+
81
+ var loadOptions = function loadOptions(inputValue, prevOptions) {
82
+ var pageLength = 10;
83
+ var filteredOptions;
84
+
85
+ if (!inputValue) {
86
+ filteredOptions = options;
87
+ } else {
88
+ filteredOptions = filterOptions(inputValue);
89
+ }
90
+
91
+ var hasMore = filteredOptions.length > prevOptions.length + pageLength;
92
+ var slicedOptions = filteredOptions.slice(prevOptions.length, prevOptions.length + pageLength);
93
+ return {
94
+ options: slicedOptions,
95
+ hasMore: hasMore
96
+ };
97
+ };
98
+
99
+ var loadOptionsPromise = function loadOptionsPromise(inputValue, prevOptions) {
100
+ return new Promise(function (resolve) {
101
+ resolve(loadOptions(inputValue, prevOptions));
102
+ });
103
+ };
104
+
104
105
  var handleMouseEnter = function handleMouseEnter() {
105
106
  setIsHovered(true);
106
107
  };
@@ -143,6 +144,11 @@ var Instructions = React__default['default'].forwardRef(function Instructions(_r
143
144
  }
144
145
  };
145
146
 
147
+ React.useEffect(function () {
148
+ if (lodash.isFunction(subscribeCurrentValueProp)) {
149
+ subscribeCurrentValueProp(currentValue);
150
+ }
151
+ }, [currentValue]);
146
152
  React.useEffect(function () {
147
153
  handleChange(selected);
148
154
  }, [selected]);
@@ -168,7 +174,7 @@ var Instructions = React__default['default'].forwardRef(function Instructions(_r
168
174
  }, React__default['default'].createElement(SelectContainer, null, React__default['default'].createElement(AutocompleteSelect.AutocompleteSelect, {
169
175
  warning: true,
170
176
  creatable: false,
171
- defaultValue: selectedOption,
177
+ value: selectedOption,
172
178
  loadOptions: loadOptionsPromise,
173
179
  onChange: handleChange
174
180
  }))), React__default['default'].createElement(InstructionsArea, null, React__default['default'].createElement(TextArea.TextArea, {
@@ -193,7 +199,8 @@ Instructions.propTypes = process.env.NODE_ENV !== "production" ? {
193
199
  disabled: defaultTheme.PropTypes.bool,
194
200
  readOnly: defaultTheme.PropTypes.bool,
195
201
  lightBackground: defaultTheme.PropTypes.bool,
196
- options: defaultTheme.PropTypes.array
202
+ options: defaultTheme.PropTypes.array,
203
+ subscribeCurrentValue: defaultTheme.PropTypes.func
197
204
  } : {};
198
205
 
199
206
  exports.Instructions = Instructions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ntbjs/react-components",
3
- "version": "1.1.0-beta.20",
3
+ "version": "1.1.0-beta.22",
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-dfb20ca2.js');
3
+ var Instructions = require('../../Instructions-f8301b0b.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-763861f4.js');
6
6
  var ContextMenu = require('../ContextMenu-ccb7a26a.js');
7
7
  var AssetPreviewTopBar = require('../AssetPreviewTopBar-020a6f96.js');
8
- var Instructions = require('../Instructions-dfb20ca2.js');
8
+ var Instructions = require('../Instructions-f8301b0b.js');
9
9
  require('../defaultTheme-870f7df1.js');
10
10
  require('styled-components');
11
11
  require('react');