@decisiv/ui-components 2.0.1-alpha.213 → 2.0.1-alpha.214

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DropdownList/index.tsx"],"names":[],"mappings":";AAgBA,OAAO,EACL,QAAQ,IAAI,YAAY,EACxB,MAAM,IAAI,UAAU,EAErB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAIlD,OAAO,EACL,YAAY,IAAI,oBAAoB,EACpC,gBAAgB,EAChB,MAAM,IAAI,kBAAkB,EAC5B,KAAK,IAAI,iBAAiB,GAC3B,CAAC;AAEF,oBAAY,KAAK,GAAG,gBAAgB,EAAE,CAAC;AACvC,oBAAY,QAAQ,GAAG,YAAY,CAAC;AACpC,oBAAY,MAAM,GAAG,UAAU,CAAC;AAEhC,iBAAS,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CA+L/C;kBA/LQ,YAAY;;;;;;;;AAuNrB,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DropdownList/index.tsx"],"names":[],"mappings":";AAgBA,OAAO,EACL,QAAQ,IAAI,YAAY,EACxB,MAAM,IAAI,UAAU,EAErB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAIlD,OAAO,EACL,YAAY,IAAI,oBAAoB,EACpC,gBAAgB,EAChB,MAAM,IAAI,kBAAkB,EAC5B,KAAK,IAAI,iBAAiB,GAC3B,CAAC;AAEF,oBAAY,KAAK,GAAG,gBAAgB,EAAE,CAAC;AACvC,oBAAY,QAAQ,GAAG,YAAY,CAAC;AACpC,oBAAY,MAAM,GAAG,UAAU,CAAC;AAEhC,iBAAS,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CA0M/C;kBA1MQ,YAAY;;;;;;;;AAkOrB,eAAe,YAAY,CAAC"}
@@ -95,7 +95,8 @@ function DropdownList(props) {
95
95
  maxHeight = props.maxHeight,
96
96
  maxWidth = props.maxWidth,
97
97
  minWidth = props.minWidth,
98
- rest = _objectWithoutProperties(props, ["actions", "borderRadius", "containerSelector", "defaultSelectedIds", "defaultVisible", "defaultFooter", "focusOnShowing", "listRef", "onChange", "onHide", "onShow", "placement", "selectedIds", "showArrow", "target", "visible", "zIndex", "PanelComponent", "maxHeight", "maxWidth", "minWidth"]); // Use a ref callback to get more control over re-rendering when a ref is stored.
98
+ multiple = props.multiple,
99
+ rest = _objectWithoutProperties(props, ["actions", "borderRadius", "containerSelector", "defaultSelectedIds", "defaultVisible", "defaultFooter", "focusOnShowing", "listRef", "onChange", "onHide", "onShow", "placement", "selectedIds", "showArrow", "target", "visible", "zIndex", "PanelComponent", "maxHeight", "maxWidth", "minWidth", "multiple"]); // Use a ref callback to get more control over re-rendering when a ref is stored.
99
100
  // Specifically, the scroll to selected item on first render of dropdown requires this.
100
101
 
101
102
 
@@ -159,7 +160,12 @@ function DropdownList(props) {
159
160
  var handleOnChange = (0, _react.useCallback)(function (selection) {
160
161
  onChange && onChange(Array.isArray(selection) ? selection : [selection]);
161
162
  defaultFooter && setSelected(selection) && setSaved(selection);
162
- }, [onChange, setSelected, setSaved, defaultFooter]);
163
+
164
+ if (!multiple) {
165
+ setShowing(false);
166
+ popRef && popRef.current && popRef.current.hide() && popRef.current.targetNode && popRef.current.targetNode.focus();
167
+ }
168
+ }, [onChange, setSelected, setSaved, defaultFooter, setShowing]);
163
169
  var handleOnApply = (0, _react.useCallback)(function () {
164
170
  setSaved(selected);
165
171
  popRef && popRef.current && popRef.current.hide();
@@ -227,7 +233,8 @@ function DropdownList(props) {
227
233
  onKeyDown: onKeyDown,
228
234
  maxHeight: maxHeight,
229
235
  maxWidth: maxWidth,
230
- minWidth: minWidth
236
+ minWidth: minWidth,
237
+ multiple: multiple
231
238
  }, rest)))));
232
239
  }
233
240
 
@@ -199,7 +199,7 @@ describe('DropdownList', function () {
199
199
  expect(onChange).toHaveBeenCalledWith([item0Id]);
200
200
  expect(baseElement).toMatchSnapshot();
201
201
  });
202
- it('does not automatically hide the options', function () {
202
+ it('automatically hide the options', function () {
203
203
  var _render7 = render(_react.default.createElement(_.default, defaultProps)),
204
204
  baseElement = _render7.baseElement,
205
205
  getByText = _render7.getByText;
@@ -208,38 +208,19 @@ describe('DropdownList', function () {
208
208
 
209
209
  _react2.fireEvent.click((0, _react2.getByText)(baseElement, item0Label));
210
210
 
211
- expect((0, _react2.queryByText)(baseElement, item0Label)).toBeTruthy();
212
- });
213
- it('does not allow multiple selections', function () {
214
- var onChange = jest.fn();
215
-
216
- var _render8 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
217
- onChange: onChange
218
- }))),
219
- baseElement = _render8.baseElement,
220
- getByText = _render8.getByText;
221
-
222
- _react2.fireEvent.click(getByText(targetButtonText));
223
-
224
- _react2.fireEvent.click((0, _react2.getByText)(baseElement, item0Label));
225
-
226
- expect(onChange).toHaveBeenCalledWith([item0Id]);
227
-
228
- _react2.fireEvent.click((0, _react2.getByText)(baseElement, item2Label));
229
-
230
- expect(onChange).toHaveBeenCalledWith([item2Id]);
211
+ expect((0, _react2.queryByText)(baseElement, item0Label)).toBeFalsy();
231
212
  });
232
213
  });
233
214
  describe('multiple options', function () {
234
215
  it('calls the onChange prop with the selection ids', function () {
235
216
  var onChange = jest.fn();
236
217
 
237
- var _render9 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
218
+ var _render8 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
238
219
  onChange: onChange,
239
220
  multiple: true
240
221
  }))),
241
- baseElement = _render9.baseElement,
242
- getByText = _render9.getByText;
222
+ baseElement = _render8.baseElement,
223
+ getByText = _render8.getByText;
243
224
 
244
225
  _react2.fireEvent.click(getByText(targetButtonText));
245
226
 
@@ -251,11 +232,11 @@ describe('DropdownList', function () {
251
232
  expect(baseElement).toMatchSnapshot();
252
233
  });
253
234
  it('does not automatically hide the options', function () {
254
- var _render10 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
235
+ var _render9 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
255
236
  multiple: true
256
237
  }))),
257
- baseElement = _render10.baseElement,
258
- getByText = _render10.getByText;
238
+ baseElement = _render9.baseElement,
239
+ getByText = _render9.getByText;
259
240
 
260
241
  _react2.fireEvent.click(getByText(targetButtonText));
261
242
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decisiv/ui-components",
3
- "version": "2.0.1-alpha.213+efaad97",
3
+ "version": "2.0.1-alpha.214+896898c",
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": "efaad97908f3df65c4b151668dd96147235f946f"
74
+ "gitHead": "896898ccffaece0ac325ee1b11376d0f011b5f93"
75
75
  }