@decisiv/ui-components 2.0.1-alpha.206 → 2.0.1-alpha.207
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/lib/components/Combobox/index.d.ts.map +1 -1
- package/lib/components/Combobox/index.js +11 -5
- package/lib/components/Combobox/index.test.js +55 -0
- package/lib/components/Combobox/schema.d.ts.map +1 -1
- package/lib/components/Combobox/schema.js +1 -0
- package/lib/components/Combobox/types.d.ts +1 -0
- package/lib/components/Combobox/types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Combobox/index.tsx"],"names":[],"mappings":"AASA,OAAc,EAGZ,sBAAsB,EAQvB,MAAM,OAAO,CAAC;AA2Bf,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAQ,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Combobox/index.tsx"],"names":[],"mappings":"AASA,OAAc,EAGZ,sBAAsB,EAQvB,MAAM,OAAO,CAAC;AA2Bf,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAQ,MAAM,SAAS,CAAC;AAskBhE,QAAA,MAAM,eAAe,EAAE,sBAAsB,CAC3C,gBAAgB,EAChB,aAAa,CACS,CAAC;AAOzB,eAAe,eAAe,CAAC"}
|
|
@@ -124,7 +124,8 @@ function Combobox(props, ref) {
|
|
|
124
124
|
variant = _props$variant === void 0 ? 'sync' : _props$variant,
|
|
125
125
|
zIndex = props.zIndex,
|
|
126
126
|
containerSelector = props.containerSelector,
|
|
127
|
-
pointerEvents = props.pointerEvents
|
|
127
|
+
pointerEvents = props.pointerEvents,
|
|
128
|
+
externalIsPopoverVisible = props.isPopoverVisible;
|
|
128
129
|
|
|
129
130
|
var _useCombobox = (0, _useCombobox2.default)(props),
|
|
130
131
|
getInputFieldProps = _useCombobox.getInputFieldProps,
|
|
@@ -161,6 +162,8 @@ function Combobox(props, ref) {
|
|
|
161
162
|
setIsPopoverVisibleState = _useState6[1];
|
|
162
163
|
|
|
163
164
|
var previousIsPopoverVisible = (0, _usePrevious.default)(isPopoverVisible);
|
|
165
|
+
var isControlled = externalIsPopoverVisible !== undefined;
|
|
166
|
+
var popoverVisibleStateToUse = isControlled ? externalIsPopoverVisible : isPopoverVisible;
|
|
164
167
|
/**
|
|
165
168
|
* Combobox controls the Popover instead of relying on the Popover's internal state.
|
|
166
169
|
* The Popover's onShow/ onHide handlers only function when the Popover is _not_
|
|
@@ -169,6 +172,8 @@ function Combobox(props, ref) {
|
|
|
169
172
|
*/
|
|
170
173
|
|
|
171
174
|
(0, _react.useEffect)(function () {
|
|
175
|
+
if (isControlled) return;
|
|
176
|
+
|
|
172
177
|
if (previousIsPopoverVisible && !isPopoverVisible && onHide) {
|
|
173
178
|
onHide();
|
|
174
179
|
}
|
|
@@ -176,17 +181,18 @@ function Combobox(props, ref) {
|
|
|
176
181
|
if (!previousIsPopoverVisible && isPopoverVisible && onShow) {
|
|
177
182
|
onShow();
|
|
178
183
|
}
|
|
179
|
-
}, [isPopoverVisible, previousIsPopoverVisible, onShow, onHide]);
|
|
184
|
+
}, [isControlled, isPopoverVisible, previousIsPopoverVisible, onShow, onHide]);
|
|
180
185
|
/**
|
|
181
186
|
* Update the dropdown list visibility.
|
|
182
187
|
*/
|
|
183
188
|
|
|
184
189
|
var updateIsPopoverVisible = (0, _react.useCallback)(function (arg) {
|
|
190
|
+
if (isControlled) return;
|
|
185
191
|
if (arg === true || arg === false) setIsPopoverVisibleState(arg);
|
|
186
192
|
if (arg === 'toggle') setIsPopoverVisibleState(function (old) {
|
|
187
193
|
return !old;
|
|
188
194
|
});
|
|
189
|
-
}, [setIsPopoverVisibleState]);
|
|
195
|
+
}, [isControlled, setIsPopoverVisibleState]);
|
|
190
196
|
/**
|
|
191
197
|
* This generates a flat list of the options (including those in categories)
|
|
192
198
|
* in the order they are presented in the dropdown list. Filtering disabled elements.
|
|
@@ -521,7 +527,7 @@ function Combobox(props, ref) {
|
|
|
521
527
|
hasClearButton: Boolean(value),
|
|
522
528
|
id: targetId,
|
|
523
529
|
inputFieldLabel: label,
|
|
524
|
-
isPopoverVisible:
|
|
530
|
+
isPopoverVisible: popoverVisibleStateToUse,
|
|
525
531
|
name: name,
|
|
526
532
|
multiple: multiple,
|
|
527
533
|
selectedValues: selectedValues,
|
|
@@ -562,7 +568,7 @@ function Combobox(props, ref) {
|
|
|
562
568
|
showArrow: false,
|
|
563
569
|
showCheckbox: !multiple,
|
|
564
570
|
target: popoverTargetRef,
|
|
565
|
-
visible: Boolean(
|
|
571
|
+
visible: Boolean(popoverVisibleStateToUse || loading),
|
|
566
572
|
renderOptionLabel: renderOptionLabel,
|
|
567
573
|
zIndex: zIndex,
|
|
568
574
|
pointerEvents: pointerEvents
|
|
@@ -1058,4 +1058,59 @@ describe('Combobox', function () {
|
|
|
1058
1058
|
});
|
|
1059
1059
|
});
|
|
1060
1060
|
});
|
|
1061
|
+
describe('when the isPopoverVisible is true', function () {
|
|
1062
|
+
it('opens the popover', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
1063
|
+
var _render34, baseElement;
|
|
1064
|
+
|
|
1065
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
1066
|
+
while (1) {
|
|
1067
|
+
switch (_context2.prev = _context2.next) {
|
|
1068
|
+
case 0:
|
|
1069
|
+
_render34 = render(_react.default.createElement(_.default, {
|
|
1070
|
+
label: "test",
|
|
1071
|
+
options: defaultOptions,
|
|
1072
|
+
hideLabel: true,
|
|
1073
|
+
isPopoverVisible: true
|
|
1074
|
+
})), baseElement = _render34.baseElement;
|
|
1075
|
+
defaultOptions.forEach(function (_ref6) {
|
|
1076
|
+
var label = _ref6.label;
|
|
1077
|
+
expect((0, _react2.queryByText)(baseElement, label)).toBeInTheDocument();
|
|
1078
|
+
});
|
|
1079
|
+
|
|
1080
|
+
case 2:
|
|
1081
|
+
case "end":
|
|
1082
|
+
return _context2.stop();
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
}, _callee2);
|
|
1086
|
+
})));
|
|
1087
|
+
it('does not automatically close the popover', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
1088
|
+
var _render35, baseElement, queryByLabelText;
|
|
1089
|
+
|
|
1090
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
1091
|
+
while (1) {
|
|
1092
|
+
switch (_context3.prev = _context3.next) {
|
|
1093
|
+
case 0:
|
|
1094
|
+
_render35 = render(_react.default.createElement(_.default, {
|
|
1095
|
+
label: "test",
|
|
1096
|
+
options: defaultOptions,
|
|
1097
|
+
hideLabel: true,
|
|
1098
|
+
isPopoverVisible: true
|
|
1099
|
+
})), baseElement = _render35.baseElement, queryByLabelText = _render35.queryByLabelText;
|
|
1100
|
+
|
|
1101
|
+
_react2.fireEvent.click(queryByLabelText(defaultOptions[0].label));
|
|
1102
|
+
|
|
1103
|
+
defaultOptions.forEach(function (_ref8) {
|
|
1104
|
+
var label = _ref8.label;
|
|
1105
|
+
expect((0, _react2.queryByText)(baseElement, label)).toBeInTheDocument();
|
|
1106
|
+
});
|
|
1107
|
+
|
|
1108
|
+
case 3:
|
|
1109
|
+
case "end":
|
|
1110
|
+
return _context3.stop();
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
}, _callee3);
|
|
1114
|
+
})));
|
|
1115
|
+
});
|
|
1061
1116
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/components/Combobox/schema.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,MAAM,KAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/components/Combobox/schema.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,MAAM,KAAwC,CAAC;AAkGrD,eAAe,MAAM,CAAC"}
|
|
@@ -43,6 +43,7 @@ schema.propTypes = _objectSpread({}, (0, _omit.default)(_InputField.schema.makeP
|
|
|
43
43
|
value: _reactDesc.PropTypes.string.description('The value for an option in the dropdown list.')
|
|
44
44
|
})).description('The array of data for the options that will be rendered'),
|
|
45
45
|
inputValue: _reactDesc.PropTypes.string.description('The text value for the input field. If provided, controlling the Combobox must be handled externally. Overrides `defaultInputValue`.'),
|
|
46
|
+
isPopoverVisible: _reactDesc.PropTypes.bool.description("Whether or not the Combobox's popover should be visible. Setting this prop makes the Combobox's popover a \"controlled\" component."),
|
|
46
47
|
value: _reactDesc.PropTypes.oneOfType([_reactDesc.PropTypes.string, _reactDesc.PropTypes.arrayOf(_reactDesc.PropTypes.shape({
|
|
47
48
|
id: _reactDesc.PropTypes.string,
|
|
48
49
|
label: _reactDesc.PropTypes.string,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Combobox/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,oBAAY,gBAAgB,GAAG,gBAAgB,CAAC;AAEhD,aAAK,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AAEhC,UAAU,aAAa;IACrB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,aACf,SAAQ,IAAI,CACR,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAC3C,UAAU,GAAG,OAAO,CACrB,EACD,IAAI,CAA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ED,oBAAY,eAAe,GAAG,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC;AAEpE,oBAAY,IAAI,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,EAAE,GAAG,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;AAE/E,MAAM,WAAW,WAAW;IAC1B,kBAAkB,EAAE,MAAM,eAAe,CAAC;IAC1C,kBAAkB,EAAE,MAAM,CAAC;IAC3B,qBAAqB,EAAE,CAAC,kBAAkB,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9D;AAED,MAAM,WAAW,WAAY,SAAQ,mBAAmB,CAAC,gBAAgB,CAAC;IACxE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC;IACvB,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,aAAa,GAAG,SAAS,CAAC;IAC1D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,sBAAsB,EAAE,MAAM,IAAI,CAAC;CACpC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decisiv/ui-components",
|
|
3
|
-
"version": "2.0.1-alpha.
|
|
3
|
+
"version": "2.0.1-alpha.207+7ba6abc",
|
|
4
4
|
"description": "Decisiv's design system React components",
|
|
5
5
|
"author": "Decisiv UI Development Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
73
|
"private": false,
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "7ba6abc7838c58aa2cbe7a117b03d3a308528738"
|
|
75
75
|
}
|