@ntbjs/react-components 1.1.0-beta.21 → 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,46 +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
- onChangeProp = _ref.onChange,
38
- props = defaultTheme._objectWithoutProperties(_ref, ["clickToAdd", "customAddMessage", "selectedOption", "readOnly", "lightBackground", "options", "onChange"]);
39
-
40
- var filterOptions = function filterOptions(inputValue) {
41
- return options.filter(function (option) {
42
- return option.label.toLowerCase().includes(inputValue.toLowerCase());
43
- });
44
- };
45
-
46
- var onChange = React.useCallback(function (event) {
47
- setCurrentValue(event.target.value);
48
-
49
- if (lodash.isFunction(onChangeProp)) {
50
- onChangeProp(event);
51
- }
52
- }, [onChangeProp]);
53
-
54
- var loadOptions = function loadOptions(inputValue, prevOptions) {
55
- var pageLength = 10;
56
- var filteredOptions;
57
-
58
- if (!inputValue) {
59
- filteredOptions = options;
60
- } else {
61
- filteredOptions = filterOptions(inputValue);
62
- }
63
-
64
- var hasMore = filteredOptions.length > prevOptions.length + pageLength;
65
- var slicedOptions = filteredOptions.slice(prevOptions.length, prevOptions.length + pageLength);
66
- return {
67
- options: slicedOptions,
68
- hasMore: hasMore
69
- };
70
- };
71
-
72
- var loadOptionsPromise = function loadOptionsPromise(inputValue, prevOptions) {
73
- return new Promise(function (resolve) {
74
- resolve(loadOptions(inputValue, prevOptions));
75
- });
76
- };
37
+ subscribeCurrentValueProp = _ref.subscribeCurrentValue,
38
+ props = defaultTheme._objectWithoutProperties(_ref, ["clickToAdd", "customAddMessage", "selectedOption", "readOnly", "lightBackground", "options", "subscribeCurrentValue"]);
77
39
 
78
40
  var _useState = React.useState(false),
79
41
  _useState2 = defaultTheme._slicedToArray(_useState, 2),
@@ -110,6 +72,36 @@ var Instructions = React__default['default'].forwardRef(function Instructions(_r
110
72
  currentValue = _useState14[0],
111
73
  setCurrentValue = _useState14[1];
112
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
+
113
105
  var handleMouseEnter = function handleMouseEnter() {
114
106
  setIsHovered(true);
115
107
  };
@@ -152,6 +144,11 @@ var Instructions = React__default['default'].forwardRef(function Instructions(_r
152
144
  }
153
145
  };
154
146
 
147
+ React.useEffect(function () {
148
+ if (lodash.isFunction(subscribeCurrentValueProp)) {
149
+ subscribeCurrentValueProp(currentValue);
150
+ }
151
+ }, [currentValue]);
155
152
  React.useEffect(function () {
156
153
  handleChange(selected);
157
154
  }, [selected]);
@@ -169,7 +166,6 @@ var Instructions = React__default['default'].forwardRef(function Instructions(_r
169
166
  return React__default['default'].createElement(Instructions$1, defaultTheme._extends({
170
167
  ref: forwardedRef,
171
168
  initialHover: initialHover,
172
- onChange: onChange,
173
169
  onMouseEnter: handleMouseEnter,
174
170
  onMouseLeave: handleMouseLeave
175
171
  }, props), React__default['default'].createElement(TopBarContainer, {
@@ -204,7 +200,7 @@ Instructions.propTypes = process.env.NODE_ENV !== "production" ? {
204
200
  readOnly: defaultTheme.PropTypes.bool,
205
201
  lightBackground: defaultTheme.PropTypes.bool,
206
202
  options: defaultTheme.PropTypes.array,
207
- onChange: defaultTheme.PropTypes.func
203
+ subscribeCurrentValue: defaultTheme.PropTypes.func
208
204
  } : {};
209
205
 
210
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.21",
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-98d6fe45.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-98d6fe45.js');
8
+ var Instructions = require('../Instructions-f8301b0b.js');
9
9
  require('../defaultTheme-870f7df1.js');
10
10
  require('styled-components');
11
11
  require('react');