@targetprocess/dropdown-field 12.32.2-alpha.0 → 12.32.3-ci.1
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.
- package/__tests__/DropdownField.tests.jsx +3 -1
- package/dist/dropdown-field.es.js +113 -139
- package/dist/dropdown-field.js +120 -145
- package/package.json +6 -6
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* © Copyright IBM Corp. 2026
|
|
3
|
+
*********************************************************************/
|
|
2
4
|
import React from 'react'
|
|
3
5
|
import {mount} from 'enzyme'
|
|
4
6
|
import {DropdownField} from '../DropdownField'
|
|
@@ -3,121 +3,101 @@ import classnames from 'classnames';
|
|
|
3
3
|
import { Select } from '@targetprocess/select';
|
|
4
4
|
import { Popover } from '@targetprocess/popover';
|
|
5
5
|
import { Field } from '@targetprocess/field';
|
|
6
|
-
import {
|
|
6
|
+
import { ChevronIcon, LoadingIcon } from '@targetprocess/icons';
|
|
7
7
|
|
|
8
|
-
function
|
|
9
|
-
if (
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
function _assertThisInitialized(e) {
|
|
9
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
10
|
+
return e;
|
|
11
|
+
}
|
|
12
|
+
function _callSuper(t, o, e) {
|
|
13
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
12
14
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(
|
|
15
|
+
function _classCallCheck(a, n) {
|
|
16
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
17
|
+
}
|
|
18
|
+
function _defineProperties(e, r) {
|
|
19
|
+
for (var t = 0; t < r.length; t++) {
|
|
20
|
+
var o = r[t];
|
|
21
|
+
o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
|
-
function _createClass(
|
|
23
|
-
|
|
24
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
25
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
24
|
+
function _createClass(e, r, t) {
|
|
25
|
+
return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
|
|
26
26
|
writable: false
|
|
27
|
-
});
|
|
28
|
-
return Constructor;
|
|
27
|
+
}), e;
|
|
29
28
|
}
|
|
30
|
-
function _defineProperty(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
writable: true
|
|
38
|
-
});
|
|
39
|
-
} else {
|
|
40
|
-
obj[key] = value;
|
|
41
|
-
}
|
|
42
|
-
return obj;
|
|
29
|
+
function _defineProperty(e, r, t) {
|
|
30
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
31
|
+
value: t,
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true
|
|
35
|
+
}) : e[r] = t, e;
|
|
43
36
|
}
|
|
44
37
|
function _extends() {
|
|
45
|
-
_extends = Object.assign ? Object.assign.bind() : function (
|
|
46
|
-
for (var
|
|
47
|
-
var
|
|
48
|
-
for (var
|
|
49
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
50
|
-
target[key] = source[key];
|
|
51
|
-
}
|
|
52
|
-
}
|
|
38
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
39
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
40
|
+
var t = arguments[e];
|
|
41
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
53
42
|
}
|
|
54
|
-
return
|
|
55
|
-
};
|
|
56
|
-
return _extends.apply(this, arguments);
|
|
43
|
+
return n;
|
|
44
|
+
}, _extends.apply(null, arguments);
|
|
57
45
|
}
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
46
|
+
function _getPrototypeOf(t) {
|
|
47
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
48
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
49
|
+
}, _getPrototypeOf(t);
|
|
50
|
+
}
|
|
51
|
+
function _inherits(t, e) {
|
|
52
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
53
|
+
t.prototype = Object.create(e && e.prototype, {
|
|
63
54
|
constructor: {
|
|
64
|
-
value:
|
|
55
|
+
value: t,
|
|
65
56
|
writable: true,
|
|
66
57
|
configurable: true
|
|
67
58
|
}
|
|
68
|
-
})
|
|
69
|
-
Object.defineProperty(subClass, "prototype", {
|
|
59
|
+
}), Object.defineProperty(t, "prototype", {
|
|
70
60
|
writable: false
|
|
71
|
-
});
|
|
72
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
61
|
+
}), e && _setPrototypeOf(t, e);
|
|
73
62
|
}
|
|
74
|
-
function
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
return
|
|
63
|
+
function _isNativeReflectConstruct() {
|
|
64
|
+
try {
|
|
65
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
66
|
+
} catch (t) {}
|
|
67
|
+
return (_isNativeReflectConstruct = function () {
|
|
68
|
+
return !!t;
|
|
69
|
+
})();
|
|
79
70
|
}
|
|
80
|
-
function
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
};
|
|
85
|
-
return _setPrototypeOf(o, p);
|
|
71
|
+
function _possibleConstructorReturn(t, e) {
|
|
72
|
+
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|
73
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
74
|
+
return _assertThisInitialized(t);
|
|
86
75
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
return self;
|
|
92
|
-
}
|
|
93
|
-
function _possibleConstructorReturn(self, call) {
|
|
94
|
-
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
95
|
-
return call;
|
|
96
|
-
} else if (call !== void 0) {
|
|
97
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
98
|
-
}
|
|
99
|
-
return _assertThisInitialized(self);
|
|
76
|
+
function _setPrototypeOf(t, e) {
|
|
77
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
78
|
+
return t.__proto__ = e, t;
|
|
79
|
+
}, _setPrototypeOf(t, e);
|
|
100
80
|
}
|
|
101
|
-
function _toPrimitive(
|
|
102
|
-
if (
|
|
103
|
-
var
|
|
104
|
-
if (
|
|
105
|
-
var
|
|
106
|
-
if (
|
|
81
|
+
function _toPrimitive(t, e) {
|
|
82
|
+
if ("object" != typeof t || !t) return t;
|
|
83
|
+
var r;
|
|
84
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
85
|
+
var i = r.call(t, e);
|
|
86
|
+
if ("object" != typeof i) return i;
|
|
107
87
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
108
88
|
}
|
|
109
|
-
return (
|
|
89
|
+
return (String )(t);
|
|
110
90
|
}
|
|
111
|
-
function _toPropertyKey(
|
|
112
|
-
var
|
|
113
|
-
return
|
|
91
|
+
function _toPropertyKey(t) {
|
|
92
|
+
var i = _toPrimitive(t, "string");
|
|
93
|
+
return "symbol" == typeof i ? i : i + "";
|
|
114
94
|
}
|
|
115
95
|
|
|
116
96
|
function styleInject(css, ref) {
|
|
117
97
|
if ( ref === void 0 ) ref = {};
|
|
118
98
|
var insertAt = ref.insertAt;
|
|
119
99
|
|
|
120
|
-
if (
|
|
100
|
+
if (typeof document === 'undefined') { return; }
|
|
121
101
|
|
|
122
102
|
var head = document.head || document.getElementsByTagName('head')[0];
|
|
123
103
|
var style = document.createElement('style');
|
|
@@ -140,9 +120,9 @@ function styleInject(css, ref) {
|
|
|
140
120
|
}
|
|
141
121
|
}
|
|
142
122
|
|
|
143
|
-
var
|
|
144
|
-
var styles = {"popover-body--no-gutters":"popover-body--no-gutters__dropdown-field__12-32-
|
|
145
|
-
styleInject(
|
|
123
|
+
var css_248z = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n.popover-body--no-gutters__dropdown-field__12-32-3-ci-1 {\n padding: 0;\n}\n";
|
|
124
|
+
var styles = {"popover-body--no-gutters":"popover-body--no-gutters__dropdown-field__12-32-3-ci-1"};
|
|
125
|
+
styleInject(css_248z);
|
|
146
126
|
|
|
147
127
|
var dropdownInnerSpace = 4;
|
|
148
128
|
var boxShadowGutter = 3;
|
|
@@ -153,35 +133,33 @@ var boxShadowGutter = 3;
|
|
|
153
133
|
**/
|
|
154
134
|
|
|
155
135
|
var DropdownField = /*#__PURE__*/function (_React$Component) {
|
|
156
|
-
_inherits(DropdownField, _React$Component);
|
|
157
136
|
function DropdownField() {
|
|
158
|
-
var _getPrototypeOf2;
|
|
159
137
|
var _this;
|
|
160
138
|
_classCallCheck(this, DropdownField);
|
|
161
139
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
162
140
|
args[_key] = arguments[_key];
|
|
163
141
|
}
|
|
164
|
-
_this =
|
|
165
|
-
_defineProperty(
|
|
142
|
+
_this = _callSuper(this, DropdownField, [].concat(args));
|
|
143
|
+
_defineProperty(_this, "state", {
|
|
166
144
|
isOpen: false,
|
|
167
145
|
currentValue: {
|
|
168
146
|
displayText: ''
|
|
169
147
|
}
|
|
170
148
|
});
|
|
171
|
-
_defineProperty(
|
|
149
|
+
_defineProperty(_this, "isControlledOpen", function () {
|
|
172
150
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props;
|
|
173
151
|
return typeof props.isOpen !== 'undefined' && props.isOpen !== null;
|
|
174
152
|
});
|
|
175
|
-
_defineProperty(
|
|
153
|
+
_defineProperty(_this, "isStateless", function () {
|
|
176
154
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props;
|
|
177
155
|
return typeof props.selectedItem !== 'undefined' && props.selectedItem !== null;
|
|
178
156
|
});
|
|
179
|
-
_defineProperty(
|
|
157
|
+
_defineProperty(_this, "onSetOpened", function (isOpen) {
|
|
180
158
|
return _this.props.onSetOpened ? _this.props.onSetOpened(isOpen) : _this.setState({
|
|
181
159
|
isOpen: isOpen
|
|
182
160
|
});
|
|
183
161
|
});
|
|
184
|
-
_defineProperty(
|
|
162
|
+
_defineProperty(_this, "onSelectItem", function (item) {
|
|
185
163
|
var onItemSelected = _this.props.onItemSelected;
|
|
186
164
|
_this.setState(_extends({}, _this.isStateless() ? {} : {
|
|
187
165
|
currentValue: item
|
|
@@ -194,21 +172,46 @@ var DropdownField = /*#__PURE__*/function (_React$Component) {
|
|
|
194
172
|
});
|
|
195
173
|
return _this;
|
|
196
174
|
}
|
|
197
|
-
|
|
175
|
+
_inherits(DropdownField, _React$Component);
|
|
176
|
+
return _createClass(DropdownField, [{
|
|
177
|
+
key: "body",
|
|
178
|
+
get: function get() {
|
|
179
|
+
var _this$props = this.props,
|
|
180
|
+
items = _this$props.items,
|
|
181
|
+
search = _this$props.search,
|
|
182
|
+
virtualization = _this$props.virtualization,
|
|
183
|
+
itemListMaxHeight = _this$props.itemListMaxHeight,
|
|
184
|
+
_this$props$className = _this$props.classNames,
|
|
185
|
+
selectClassName = _this$props$className.selectClassName,
|
|
186
|
+
popoverClassName = _this$props$className.popoverClassName;
|
|
187
|
+
return /*#__PURE__*/React.createElement(Popover.Body, {
|
|
188
|
+
classNameBody: classnames(popoverClassName, styles['popover-body--no-gutters'])
|
|
189
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
190
|
+
searchEnabled: true,
|
|
191
|
+
className: selectClassName,
|
|
192
|
+
itemListMaxHeight: itemListMaxHeight,
|
|
193
|
+
showCheckbox: false,
|
|
194
|
+
search: search,
|
|
195
|
+
virtualization: virtualization,
|
|
196
|
+
items: items,
|
|
197
|
+
onItemSelectionChange: this.onSelectItem
|
|
198
|
+
}));
|
|
199
|
+
}
|
|
200
|
+
}, {
|
|
198
201
|
key: "render",
|
|
199
202
|
value: function render() {
|
|
200
203
|
var _this2 = this;
|
|
201
|
-
var _this$
|
|
202
|
-
isLoading = _this$
|
|
203
|
-
errorMessage = _this$
|
|
204
|
-
selectedItem = _this$
|
|
205
|
-
placeholder = _this$
|
|
206
|
-
search = _this$
|
|
207
|
-
classNames = _this$
|
|
204
|
+
var _this$props2 = this.props,
|
|
205
|
+
isLoading = _this$props2.isLoading,
|
|
206
|
+
errorMessage = _this$props2.errorMessage,
|
|
207
|
+
selectedItem = _this$props2.selectedItem,
|
|
208
|
+
placeholder = _this$props2.placeholder,
|
|
209
|
+
search = _this$props2.search,
|
|
210
|
+
classNames = _this$props2.classNames;
|
|
208
211
|
var isOpen = this.isControlledOpen() ? this.props.isOpen : this.state.isOpen;
|
|
209
212
|
var currentValue = this.isStateless() ? selectedItem : this.state.currentValue;
|
|
210
213
|
var isSearch = Boolean(search);
|
|
211
|
-
return React.createElement(Popover, {
|
|
214
|
+
return /*#__PURE__*/React.createElement(Popover, {
|
|
212
215
|
onOuterAction: function onOuterAction() {
|
|
213
216
|
return _this2.onSetOpened(false);
|
|
214
217
|
},
|
|
@@ -222,7 +225,7 @@ var DropdownField = /*#__PURE__*/function (_React$Component) {
|
|
|
222
225
|
};
|
|
223
226
|
},
|
|
224
227
|
showTip: false
|
|
225
|
-
}, React.createElement(Field, {
|
|
228
|
+
}, /*#__PURE__*/React.createElement(Field, {
|
|
226
229
|
disableEdit: true,
|
|
227
230
|
className: classNames.fieldClassName,
|
|
228
231
|
message: errorMessage,
|
|
@@ -231,39 +234,14 @@ var DropdownField = /*#__PURE__*/function (_React$Component) {
|
|
|
231
234
|
},
|
|
232
235
|
value: currentValue.displayText,
|
|
233
236
|
editing: isOpen,
|
|
234
|
-
icon: isLoading ? React.createElement(LoadingIcon, null) : null,
|
|
237
|
+
icon: isLoading ? /*#__PURE__*/React.createElement(LoadingIcon, null) : null,
|
|
235
238
|
placeholder: placeholder,
|
|
236
239
|
editModeProps: {
|
|
237
|
-
rightElement: React.createElement(ChevronIcon, null)
|
|
240
|
+
rightElement: /*#__PURE__*/React.createElement(ChevronIcon, null)
|
|
238
241
|
}
|
|
239
242
|
}));
|
|
240
243
|
}
|
|
241
|
-
}, {
|
|
242
|
-
key: "body",
|
|
243
|
-
get: function get() {
|
|
244
|
-
var _this$props2 = this.props,
|
|
245
|
-
items = _this$props2.items,
|
|
246
|
-
search = _this$props2.search,
|
|
247
|
-
virtualization = _this$props2.virtualization,
|
|
248
|
-
itemListMaxHeight = _this$props2.itemListMaxHeight,
|
|
249
|
-
_this$props2$classNam = _this$props2.classNames,
|
|
250
|
-
selectClassName = _this$props2$classNam.selectClassName,
|
|
251
|
-
popoverClassName = _this$props2$classNam.popoverClassName;
|
|
252
|
-
return React.createElement(Popover.Body, {
|
|
253
|
-
classNameBody: classnames(popoverClassName, styles['popover-body--no-gutters'])
|
|
254
|
-
}, React.createElement(Select, {
|
|
255
|
-
searchEnabled: true,
|
|
256
|
-
className: selectClassName,
|
|
257
|
-
itemListMaxHeight: itemListMaxHeight,
|
|
258
|
-
showCheckbox: false,
|
|
259
|
-
search: search,
|
|
260
|
-
virtualization: virtualization,
|
|
261
|
-
items: items,
|
|
262
|
-
onItemSelectionChange: this.onSelectItem
|
|
263
|
-
}));
|
|
264
|
-
}
|
|
265
244
|
}]);
|
|
266
|
-
return DropdownField;
|
|
267
245
|
}(React.Component);
|
|
268
246
|
_defineProperty(DropdownField, "defaultProps", {
|
|
269
247
|
placeholder: 'Choose option',
|
|
@@ -272,8 +250,4 @@ _defineProperty(DropdownField, "defaultProps", {
|
|
|
272
250
|
items: []
|
|
273
251
|
});
|
|
274
252
|
|
|
275
|
-
/*********************************************************************
|
|
276
|
-
* © Copyright IBM Corp. 2024
|
|
277
|
-
*********************************************************************/
|
|
278
|
-
|
|
279
253
|
export { DropdownField };
|
package/dist/dropdown-field.js
CHANGED
|
@@ -1,129 +1,110 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
-
|
|
7
|
-
var React = _interopDefault(require('react'));
|
|
8
|
-
var classnames = _interopDefault(require('classnames'));
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var classnames = require('classnames');
|
|
9
5
|
var select = require('@targetprocess/select');
|
|
10
6
|
var popover = require('@targetprocess/popover');
|
|
11
7
|
var field = require('@targetprocess/field');
|
|
12
8
|
var icons = require('@targetprocess/icons');
|
|
13
9
|
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
13
|
+
var classnames__default = /*#__PURE__*/_interopDefaultCompat(classnames);
|
|
14
|
+
|
|
15
|
+
function _assertThisInitialized(e) {
|
|
16
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
17
|
+
return e;
|
|
18
|
+
}
|
|
19
|
+
function _callSuper(t, o, e) {
|
|
20
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
21
|
+
}
|
|
22
|
+
function _classCallCheck(a, n) {
|
|
23
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
18
24
|
}
|
|
19
|
-
function _defineProperties(
|
|
20
|
-
for (var
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
descriptor.configurable = true;
|
|
24
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
25
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
25
|
+
function _defineProperties(e, r) {
|
|
26
|
+
for (var t = 0; t < r.length; t++) {
|
|
27
|
+
var o = r[t];
|
|
28
|
+
o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
|
-
function _createClass(
|
|
29
|
-
|
|
30
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
31
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
31
|
+
function _createClass(e, r, t) {
|
|
32
|
+
return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
|
|
32
33
|
writable: false
|
|
33
|
-
});
|
|
34
|
-
return Constructor;
|
|
34
|
+
}), e;
|
|
35
35
|
}
|
|
36
|
-
function _defineProperty(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
writable: true
|
|
44
|
-
});
|
|
45
|
-
} else {
|
|
46
|
-
obj[key] = value;
|
|
47
|
-
}
|
|
48
|
-
return obj;
|
|
36
|
+
function _defineProperty(e, r, t) {
|
|
37
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
38
|
+
value: t,
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
writable: true
|
|
42
|
+
}) : e[r] = t, e;
|
|
49
43
|
}
|
|
50
44
|
function _extends() {
|
|
51
|
-
_extends = Object.assign ? Object.assign.bind() : function (
|
|
52
|
-
for (var
|
|
53
|
-
var
|
|
54
|
-
for (var
|
|
55
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
56
|
-
target[key] = source[key];
|
|
57
|
-
}
|
|
58
|
-
}
|
|
45
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
46
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
47
|
+
var t = arguments[e];
|
|
48
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
59
49
|
}
|
|
60
|
-
return
|
|
61
|
-
};
|
|
62
|
-
return _extends.apply(this, arguments);
|
|
50
|
+
return n;
|
|
51
|
+
}, _extends.apply(null, arguments);
|
|
63
52
|
}
|
|
64
|
-
function
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
53
|
+
function _getPrototypeOf(t) {
|
|
54
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
55
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
56
|
+
}, _getPrototypeOf(t);
|
|
57
|
+
}
|
|
58
|
+
function _inherits(t, e) {
|
|
59
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
60
|
+
t.prototype = Object.create(e && e.prototype, {
|
|
69
61
|
constructor: {
|
|
70
|
-
value:
|
|
62
|
+
value: t,
|
|
71
63
|
writable: true,
|
|
72
64
|
configurable: true
|
|
73
65
|
}
|
|
74
|
-
})
|
|
75
|
-
Object.defineProperty(subClass, "prototype", {
|
|
66
|
+
}), Object.defineProperty(t, "prototype", {
|
|
76
67
|
writable: false
|
|
77
|
-
});
|
|
78
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
68
|
+
}), e && _setPrototypeOf(t, e);
|
|
79
69
|
}
|
|
80
|
-
function
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
return
|
|
70
|
+
function _isNativeReflectConstruct() {
|
|
71
|
+
try {
|
|
72
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
73
|
+
} catch (t) {}
|
|
74
|
+
return (_isNativeReflectConstruct = function () {
|
|
75
|
+
return !!t;
|
|
76
|
+
})();
|
|
85
77
|
}
|
|
86
|
-
function
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
};
|
|
91
|
-
return _setPrototypeOf(o, p);
|
|
78
|
+
function _possibleConstructorReturn(t, e) {
|
|
79
|
+
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|
80
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
81
|
+
return _assertThisInitialized(t);
|
|
92
82
|
}
|
|
93
|
-
function
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
return self;
|
|
98
|
-
}
|
|
99
|
-
function _possibleConstructorReturn(self, call) {
|
|
100
|
-
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
101
|
-
return call;
|
|
102
|
-
} else if (call !== void 0) {
|
|
103
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
104
|
-
}
|
|
105
|
-
return _assertThisInitialized(self);
|
|
83
|
+
function _setPrototypeOf(t, e) {
|
|
84
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
85
|
+
return t.__proto__ = e, t;
|
|
86
|
+
}, _setPrototypeOf(t, e);
|
|
106
87
|
}
|
|
107
|
-
function _toPrimitive(
|
|
108
|
-
if (
|
|
109
|
-
var
|
|
110
|
-
if (
|
|
111
|
-
var
|
|
112
|
-
if (
|
|
88
|
+
function _toPrimitive(t, e) {
|
|
89
|
+
if ("object" != typeof t || !t) return t;
|
|
90
|
+
var r;
|
|
91
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
92
|
+
var i = r.call(t, e);
|
|
93
|
+
if ("object" != typeof i) return i;
|
|
113
94
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
114
95
|
}
|
|
115
|
-
return (
|
|
96
|
+
return (String )(t);
|
|
116
97
|
}
|
|
117
|
-
function _toPropertyKey(
|
|
118
|
-
var
|
|
119
|
-
return
|
|
98
|
+
function _toPropertyKey(t) {
|
|
99
|
+
var i = _toPrimitive(t, "string");
|
|
100
|
+
return "symbol" == typeof i ? i : i + "";
|
|
120
101
|
}
|
|
121
102
|
|
|
122
103
|
function styleInject(css, ref) {
|
|
123
104
|
if ( ref === void 0 ) ref = {};
|
|
124
105
|
var insertAt = ref.insertAt;
|
|
125
106
|
|
|
126
|
-
if (
|
|
107
|
+
if (typeof document === 'undefined') { return; }
|
|
127
108
|
|
|
128
109
|
var head = document.head || document.getElementsByTagName('head')[0];
|
|
129
110
|
var style = document.createElement('style');
|
|
@@ -146,9 +127,9 @@ function styleInject(css, ref) {
|
|
|
146
127
|
}
|
|
147
128
|
}
|
|
148
129
|
|
|
149
|
-
var
|
|
150
|
-
var styles = {"popover-body--no-gutters":"popover-body--no-gutters__dropdown-field__12-32-
|
|
151
|
-
styleInject(
|
|
130
|
+
var css_248z = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n.popover-body--no-gutters__dropdown-field__12-32-3-ci-1 {\n padding: 0;\n}\n";
|
|
131
|
+
var styles = {"popover-body--no-gutters":"popover-body--no-gutters__dropdown-field__12-32-3-ci-1"};
|
|
132
|
+
styleInject(css_248z);
|
|
152
133
|
|
|
153
134
|
var dropdownInnerSpace = 4;
|
|
154
135
|
var boxShadowGutter = 3;
|
|
@@ -159,35 +140,33 @@ var boxShadowGutter = 3;
|
|
|
159
140
|
**/
|
|
160
141
|
|
|
161
142
|
var DropdownField = /*#__PURE__*/function (_React$Component) {
|
|
162
|
-
_inherits(DropdownField, _React$Component);
|
|
163
143
|
function DropdownField() {
|
|
164
|
-
var _getPrototypeOf2;
|
|
165
144
|
var _this;
|
|
166
145
|
_classCallCheck(this, DropdownField);
|
|
167
146
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
168
147
|
args[_key] = arguments[_key];
|
|
169
148
|
}
|
|
170
|
-
_this =
|
|
171
|
-
_defineProperty(
|
|
149
|
+
_this = _callSuper(this, DropdownField, [].concat(args));
|
|
150
|
+
_defineProperty(_this, "state", {
|
|
172
151
|
isOpen: false,
|
|
173
152
|
currentValue: {
|
|
174
153
|
displayText: ''
|
|
175
154
|
}
|
|
176
155
|
});
|
|
177
|
-
_defineProperty(
|
|
156
|
+
_defineProperty(_this, "isControlledOpen", function () {
|
|
178
157
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props;
|
|
179
158
|
return typeof props.isOpen !== 'undefined' && props.isOpen !== null;
|
|
180
159
|
});
|
|
181
|
-
_defineProperty(
|
|
160
|
+
_defineProperty(_this, "isStateless", function () {
|
|
182
161
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props;
|
|
183
162
|
return typeof props.selectedItem !== 'undefined' && props.selectedItem !== null;
|
|
184
163
|
});
|
|
185
|
-
_defineProperty(
|
|
164
|
+
_defineProperty(_this, "onSetOpened", function (isOpen) {
|
|
186
165
|
return _this.props.onSetOpened ? _this.props.onSetOpened(isOpen) : _this.setState({
|
|
187
166
|
isOpen: isOpen
|
|
188
167
|
});
|
|
189
168
|
});
|
|
190
|
-
_defineProperty(
|
|
169
|
+
_defineProperty(_this, "onSelectItem", function (item) {
|
|
191
170
|
var onItemSelected = _this.props.onItemSelected;
|
|
192
171
|
_this.setState(_extends({}, _this.isStateless() ? {} : {
|
|
193
172
|
currentValue: item
|
|
@@ -200,21 +179,46 @@ var DropdownField = /*#__PURE__*/function (_React$Component) {
|
|
|
200
179
|
});
|
|
201
180
|
return _this;
|
|
202
181
|
}
|
|
203
|
-
|
|
182
|
+
_inherits(DropdownField, _React$Component);
|
|
183
|
+
return _createClass(DropdownField, [{
|
|
184
|
+
key: "body",
|
|
185
|
+
get: function get() {
|
|
186
|
+
var _this$props = this.props,
|
|
187
|
+
items = _this$props.items,
|
|
188
|
+
search = _this$props.search,
|
|
189
|
+
virtualization = _this$props.virtualization,
|
|
190
|
+
itemListMaxHeight = _this$props.itemListMaxHeight,
|
|
191
|
+
_this$props$className = _this$props.classNames,
|
|
192
|
+
selectClassName = _this$props$className.selectClassName,
|
|
193
|
+
popoverClassName = _this$props$className.popoverClassName;
|
|
194
|
+
return /*#__PURE__*/React__default.default.createElement(popover.Popover.Body, {
|
|
195
|
+
classNameBody: classnames__default.default(popoverClassName, styles['popover-body--no-gutters'])
|
|
196
|
+
}, /*#__PURE__*/React__default.default.createElement(select.Select, {
|
|
197
|
+
searchEnabled: true,
|
|
198
|
+
className: selectClassName,
|
|
199
|
+
itemListMaxHeight: itemListMaxHeight,
|
|
200
|
+
showCheckbox: false,
|
|
201
|
+
search: search,
|
|
202
|
+
virtualization: virtualization,
|
|
203
|
+
items: items,
|
|
204
|
+
onItemSelectionChange: this.onSelectItem
|
|
205
|
+
}));
|
|
206
|
+
}
|
|
207
|
+
}, {
|
|
204
208
|
key: "render",
|
|
205
209
|
value: function render() {
|
|
206
210
|
var _this2 = this;
|
|
207
|
-
var _this$
|
|
208
|
-
isLoading = _this$
|
|
209
|
-
errorMessage = _this$
|
|
210
|
-
selectedItem = _this$
|
|
211
|
-
placeholder = _this$
|
|
212
|
-
search = _this$
|
|
213
|
-
classNames = _this$
|
|
211
|
+
var _this$props2 = this.props,
|
|
212
|
+
isLoading = _this$props2.isLoading,
|
|
213
|
+
errorMessage = _this$props2.errorMessage,
|
|
214
|
+
selectedItem = _this$props2.selectedItem,
|
|
215
|
+
placeholder = _this$props2.placeholder,
|
|
216
|
+
search = _this$props2.search,
|
|
217
|
+
classNames = _this$props2.classNames;
|
|
214
218
|
var isOpen = this.isControlledOpen() ? this.props.isOpen : this.state.isOpen;
|
|
215
219
|
var currentValue = this.isStateless() ? selectedItem : this.state.currentValue;
|
|
216
220
|
var isSearch = Boolean(search);
|
|
217
|
-
return
|
|
221
|
+
return /*#__PURE__*/React__default.default.createElement(popover.Popover, {
|
|
218
222
|
onOuterAction: function onOuterAction() {
|
|
219
223
|
return _this2.onSetOpened(false);
|
|
220
224
|
},
|
|
@@ -228,7 +232,7 @@ var DropdownField = /*#__PURE__*/function (_React$Component) {
|
|
|
228
232
|
};
|
|
229
233
|
},
|
|
230
234
|
showTip: false
|
|
231
|
-
},
|
|
235
|
+
}, /*#__PURE__*/React__default.default.createElement(field.Field, {
|
|
232
236
|
disableEdit: true,
|
|
233
237
|
className: classNames.fieldClassName,
|
|
234
238
|
message: errorMessage,
|
|
@@ -237,40 +241,15 @@ var DropdownField = /*#__PURE__*/function (_React$Component) {
|
|
|
237
241
|
},
|
|
238
242
|
value: currentValue.displayText,
|
|
239
243
|
editing: isOpen,
|
|
240
|
-
icon: isLoading ?
|
|
244
|
+
icon: isLoading ? /*#__PURE__*/React__default.default.createElement(icons.LoadingIcon, null) : null,
|
|
241
245
|
placeholder: placeholder,
|
|
242
246
|
editModeProps: {
|
|
243
|
-
rightElement:
|
|
247
|
+
rightElement: /*#__PURE__*/React__default.default.createElement(icons.ChevronIcon, null)
|
|
244
248
|
}
|
|
245
249
|
}));
|
|
246
250
|
}
|
|
247
|
-
}, {
|
|
248
|
-
key: "body",
|
|
249
|
-
get: function get() {
|
|
250
|
-
var _this$props2 = this.props,
|
|
251
|
-
items = _this$props2.items,
|
|
252
|
-
search = _this$props2.search,
|
|
253
|
-
virtualization = _this$props2.virtualization,
|
|
254
|
-
itemListMaxHeight = _this$props2.itemListMaxHeight,
|
|
255
|
-
_this$props2$classNam = _this$props2.classNames,
|
|
256
|
-
selectClassName = _this$props2$classNam.selectClassName,
|
|
257
|
-
popoverClassName = _this$props2$classNam.popoverClassName;
|
|
258
|
-
return React.createElement(popover.Popover.Body, {
|
|
259
|
-
classNameBody: classnames(popoverClassName, styles['popover-body--no-gutters'])
|
|
260
|
-
}, React.createElement(select.Select, {
|
|
261
|
-
searchEnabled: true,
|
|
262
|
-
className: selectClassName,
|
|
263
|
-
itemListMaxHeight: itemListMaxHeight,
|
|
264
|
-
showCheckbox: false,
|
|
265
|
-
search: search,
|
|
266
|
-
virtualization: virtualization,
|
|
267
|
-
items: items,
|
|
268
|
-
onItemSelectionChange: this.onSelectItem
|
|
269
|
-
}));
|
|
270
|
-
}
|
|
271
251
|
}]);
|
|
272
|
-
|
|
273
|
-
}(React.Component);
|
|
252
|
+
}(React__default.default.Component);
|
|
274
253
|
_defineProperty(DropdownField, "defaultProps", {
|
|
275
254
|
placeholder: 'Choose option',
|
|
276
255
|
isLoading: false,
|
|
@@ -278,8 +257,4 @@ _defineProperty(DropdownField, "defaultProps", {
|
|
|
278
257
|
items: []
|
|
279
258
|
});
|
|
280
259
|
|
|
281
|
-
/*********************************************************************
|
|
282
|
-
* © Copyright IBM Corp. 2024
|
|
283
|
-
*********************************************************************/
|
|
284
|
-
|
|
285
260
|
exports.DropdownField = DropdownField;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@targetprocess/dropdown-field",
|
|
3
|
-
"version": "12.32.
|
|
3
|
+
"version": "12.32.3-ci.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/dropdown-field.js",
|
|
6
6
|
"module": "dist/dropdown-field.es.js",
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"prepack": "node -r ../../.ts-node.js ../../config/rollup.config.js ."
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@targetprocess/field": "^12.32.
|
|
14
|
-
"@targetprocess/icons": "^12.32.
|
|
15
|
-
"@targetprocess/popover": "^12.32.
|
|
16
|
-
"@targetprocess/select": "^12.32.
|
|
13
|
+
"@targetprocess/field": "^12.32.3-ci.1",
|
|
14
|
+
"@targetprocess/icons": "^12.32.3-ci.1",
|
|
15
|
+
"@targetprocess/popover": "^12.32.3-ci.1",
|
|
16
|
+
"@targetprocess/select": "^12.32.3-ci.1",
|
|
17
17
|
"classnames": "^2.2.5",
|
|
18
18
|
"prop-types": "^15.6.0",
|
|
19
19
|
"react": "^16.7.0"
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"sideEffects": false,
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "9118ae26a5a5e2e85665813ff070fb44d48f65bd"
|
|
29
29
|
}
|