@dhis2-ui/select 8.1.11 → 8.2.2

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.
Files changed (71) hide show
  1. package/build/cjs/multi-select/features/menu_width_matches_input/index.js +4 -2
  2. package/build/cjs/multi-select/features/position/index.js +12 -6
  3. package/build/cjs/multi-select/filterable-menu.js +25 -22
  4. package/build/cjs/multi-select/input.js +19 -18
  5. package/build/cjs/multi-select/menu.js +29 -25
  6. package/build/cjs/multi-select/multi-select.js +31 -30
  7. package/build/cjs/multi-select/multi-select.stories.e2e.js +30 -20
  8. package/build/cjs/multi-select/multi-select.stories.js +14 -23
  9. package/build/cjs/multi-select/selection-list.js +43 -37
  10. package/build/cjs/multi-select-field/multi-select-field.stories.js +5 -15
  11. package/build/cjs/multi-select-option/multi-select-option.js +31 -28
  12. package/build/cjs/select/debounce/debounce.js +8 -2
  13. package/build/cjs/select/empty.js +14 -11
  14. package/build/cjs/select/filter-input.js +24 -21
  15. package/build/cjs/select/filterable-menu.js +8 -7
  16. package/build/cjs/select/index.js +24 -24
  17. package/build/cjs/select/input-clear-button.js +16 -13
  18. package/build/cjs/select/input-placeholder.js +8 -6
  19. package/build/cjs/select/input-prefix.js +8 -6
  20. package/build/cjs/select/input-wrapper.js +15 -14
  21. package/build/cjs/select/loading.js +18 -15
  22. package/build/cjs/select/menu-wrapper.js +11 -10
  23. package/build/cjs/select/no-match.js +12 -9
  24. package/build/cjs/select/option-helpers.js +1 -1
  25. package/build/cjs/select/select.js +6 -6
  26. package/build/cjs/single-select/features/menu_width_matches_input/index.js +4 -2
  27. package/build/cjs/single-select/features/position/index.js +8 -4
  28. package/build/cjs/single-select/filterable-menu.js +25 -22
  29. package/build/cjs/single-select/input.js +19 -18
  30. package/build/cjs/single-select/menu.js +11 -10
  31. package/build/cjs/single-select/selection.js +8 -7
  32. package/build/cjs/single-select/single-select.js +31 -30
  33. package/build/cjs/single-select/single-select.stories.e2e.js +26 -17
  34. package/build/cjs/single-select/single-select.stories.js +14 -21
  35. package/build/cjs/single-select-field/single-select-field.stories.js +5 -15
  36. package/build/cjs/single-select-option/single-select-option.js +23 -20
  37. package/build/es/multi-select/features/menu_width_matches_input/index.js +4 -2
  38. package/build/es/multi-select/features/position/index.js +12 -6
  39. package/build/es/multi-select/filterable-menu.js +25 -22
  40. package/build/es/multi-select/input.js +19 -18
  41. package/build/es/multi-select/menu.js +28 -24
  42. package/build/es/multi-select/multi-select.js +31 -30
  43. package/build/es/multi-select/multi-select.stories.e2e.js +30 -20
  44. package/build/es/multi-select/multi-select.stories.js +13 -22
  45. package/build/es/multi-select/selection-list.js +43 -37
  46. package/build/es/multi-select-field/multi-select-field.stories.js +4 -14
  47. package/build/es/multi-select-option/multi-select-option.js +31 -28
  48. package/build/es/select/debounce/debounce.js +8 -2
  49. package/build/es/select/empty.js +14 -11
  50. package/build/es/select/filter-input.js +24 -21
  51. package/build/es/select/filterable-menu.js +8 -7
  52. package/build/es/select/input-clear-button.js +16 -13
  53. package/build/es/select/input-placeholder.js +8 -6
  54. package/build/es/select/input-prefix.js +8 -6
  55. package/build/es/select/input-wrapper.js +15 -14
  56. package/build/es/select/loading.js +18 -15
  57. package/build/es/select/menu-wrapper.js +11 -10
  58. package/build/es/select/no-match.js +12 -9
  59. package/build/es/select/select.js +6 -6
  60. package/build/es/single-select/features/menu_width_matches_input/index.js +4 -2
  61. package/build/es/single-select/features/position/index.js +8 -4
  62. package/build/es/single-select/filterable-menu.js +25 -22
  63. package/build/es/single-select/input.js +19 -18
  64. package/build/es/single-select/menu.js +11 -10
  65. package/build/es/single-select/selection.js +8 -7
  66. package/build/es/single-select/single-select.js +31 -30
  67. package/build/es/single-select/single-select.stories.e2e.js +26 -17
  68. package/build/es/single-select/single-select.stories.js +13 -20
  69. package/build/es/single-select-field/single-select-field.stories.js +4 -14
  70. package/build/es/single-select-option/single-select-option.js +23 -20
  71. package/package.json +14 -14
@@ -28,7 +28,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
28
28
  (0, _steps.Then)('the MultiSelect input is left aligned with the menu', () => {
29
29
  const selectDataTest = '[data-test="dhis2-uicore-multiselect"]';
30
30
  const menuDataTest = '[data-test="dhis2-uicore-select-menu-menuwrapper"]';
31
- cy.getAll(selectDataTest, menuDataTest).should(([inputs, menus]) => {
31
+ cy.getAll(selectDataTest, menuDataTest).should(_ref => {
32
+ let [inputs, menus] = _ref;
32
33
  expect(inputs.length).to.equal(1);
33
34
  expect(menus.length).to.equal(1);
34
35
  const $input = inputs[0];
@@ -41,7 +42,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
41
42
  (0, _steps.When)('the MultiSelect input and menu have the same width', () => {
42
43
  const inputSelector = '[data-test="dhis2-uicore-select"]';
43
44
  const menuSelector = '[data-test="dhis2-uicore-select-menu-menuwrapper"]';
44
- cy.getAll(inputSelector, menuSelector).should(([$input, $menu]) => {
45
+ cy.getAll(inputSelector, menuSelector).should(_ref2 => {
46
+ let [$input, $menu] = _ref2;
45
47
  const inputWidth = Math.round($input.outerWidth());
46
48
  const menuWidth = Math.round($menu.outerWidth());
47
49
  expect(inputWidth).to.equal(menuWidth);
@@ -36,7 +36,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
36
36
  (0, _steps.Then)('the Input remains the same height', () => {
37
37
  const emptyInputHeight = '@emptyInputHeight';
38
38
  const inputDataTest = '[data-test="dhis2-uicore-select-input"]';
39
- cy.getAll(emptyInputHeight, inputDataTest).should(([emptyInputHeight, inputs]) => {
39
+ cy.getAll(emptyInputHeight, inputDataTest).should(_ref => {
40
+ let [emptyInputHeight, inputs] = _ref;
40
41
  expect(inputs.length).to.equal(1);
41
42
  const $input = inputs[0];
42
43
  const inputRect = $input.getBoundingClientRect();
@@ -46,7 +47,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
46
47
  (0, _steps.Then)('the top of the menu is aligned with the bottom of the input', () => {
47
48
  const selectDataTest = '[data-test="dhis2-uicore-multiselect"]';
48
49
  const menuDataTest = '[data-test="dhis2-uicore-select-menu-menuwrapper"]';
49
- cy.getAll(selectDataTest, menuDataTest).should(([selects, menus]) => {
50
+ cy.getAll(selectDataTest, menuDataTest).should(_ref2 => {
51
+ let [selects, menus] = _ref2;
50
52
  expect(selects.length).to.equal(1);
51
53
  expect(menus.length).to.equal(1);
52
54
  const $select = selects[0];
@@ -59,7 +61,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
59
61
  (0, _steps.Then)('the bottom of the menu is aligned with the top of the input', () => {
60
62
  const selectDataTest = '[data-test="dhis2-uicore-multiselect"]';
61
63
  const menuDataTest = '[data-test="dhis2-uicore-select-menu-menuwrapper"]';
62
- cy.getAll(selectDataTest, menuDataTest).should(([selects, menus]) => {
64
+ cy.getAll(selectDataTest, menuDataTest).should(_ref3 => {
65
+ let [selects, menus] = _ref3;
63
66
  expect(selects.length).to.equal(1);
64
67
  expect(menus.length).to.equal(1);
65
68
  const $select = selects[0];
@@ -72,7 +75,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
72
75
  (0, _steps.Then)('it is rendered on top of the MultiSelect', () => {
73
76
  const selectDataTest = '[data-test="dhis2-uicore-multiselect"]';
74
77
  const menuDataTest = '[data-test="dhis2-uicore-select-menu-menuwrapper"]';
75
- cy.getAll(selectDataTest, menuDataTest).should(([selects, menus]) => {
78
+ cy.getAll(selectDataTest, menuDataTest).should(_ref4 => {
79
+ let [selects, menus] = _ref4;
76
80
  expect(selects.length).to.equal(1);
77
81
  expect(menus.length).to.equal(1);
78
82
  const $select = selects[0];
@@ -86,7 +90,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
86
90
  (0, _steps.Then)('the left of the Menu is aligned with the left of the Input', () => {
87
91
  const selectDataTest = '[data-test="dhis2-uicore-multiselect"]';
88
92
  const menuDataTest = '[data-test="dhis2-uicore-select-menu-menuwrapper"]';
89
- cy.getAll(selectDataTest, menuDataTest).should(([selects, menus]) => {
93
+ cy.getAll(selectDataTest, menuDataTest).should(_ref5 => {
94
+ let [selects, menus] = _ref5;
90
95
  expect(selects.length).to.equal(1);
91
96
  expect(menus.length).to.equal(1);
92
97
  const $select = selects[0];
@@ -99,7 +104,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
99
104
  (0, _steps.Then)('the Menu and the Input have an equal width', () => {
100
105
  const inputDataTest = '[data-test="dhis2-uicore-multiselect"] .root-input';
101
106
  const menuDataTest = '[data-test="dhis2-uicore-select-menu-menuwrapper"]';
102
- cy.getAll(inputDataTest, menuDataTest).should(([inputs, menus]) => {
107
+ cy.getAll(inputDataTest, menuDataTest).should(_ref6 => {
108
+ let [inputs, menus] = _ref6;
103
109
  expect(inputs.length).to.equal(1);
104
110
  expect(menus.length).to.equal(1);
105
111
  const $input = inputs[0];
@@ -15,28 +15,31 @@ var _menu = require("./menu.js");
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- const FilterableMenu = ({
19
- dataTest,
20
- options,
21
- onChange,
22
- selected,
23
- empty,
24
- handleClose,
25
- handleFocusInput,
26
- placeholder,
27
- noMatchText
28
- }) => /*#__PURE__*/_react.default.createElement(_index.FilterableMenu, {
29
- dataTest: dataTest,
30
- options: options,
31
- onChange: onChange,
32
- selected: selected,
33
- empty: empty,
34
- handleClose: handleClose,
35
- handleFocusInput: handleFocusInput,
36
- placeholder: placeholder,
37
- noMatchText: noMatchText,
38
- Menu: _menu.Menu
39
- });
18
+ const FilterableMenu = _ref => {
19
+ let {
20
+ dataTest,
21
+ options,
22
+ onChange,
23
+ selected,
24
+ empty,
25
+ handleClose,
26
+ handleFocusInput,
27
+ placeholder,
28
+ noMatchText
29
+ } = _ref;
30
+ return /*#__PURE__*/_react.default.createElement(_index.FilterableMenu, {
31
+ dataTest: dataTest,
32
+ options: options,
33
+ onChange: onChange,
34
+ selected: selected,
35
+ empty: empty,
36
+ handleClose: handleClose,
37
+ handleFocusInput: handleFocusInput,
38
+ placeholder: placeholder,
39
+ noMatchText: noMatchText,
40
+ Menu: _menu.Menu
41
+ });
42
+ };
40
43
 
41
44
  exports.FilterableMenu = FilterableMenu;
42
45
  FilterableMenu.propTypes = {
@@ -23,19 +23,20 @@ var _selectionList = require("./selection-list.js");
23
23
 
24
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
25
 
26
- const Input = ({
27
- selected,
28
- onChange,
29
- clearable,
30
- clearText,
31
- placeholder,
32
- dataTest,
33
- prefix,
34
- options,
35
- className,
36
- disabled,
37
- inputMaxHeight
38
- }) => {
26
+ const Input = _ref => {
27
+ let {
28
+ selected,
29
+ onChange,
30
+ clearable,
31
+ clearText,
32
+ placeholder,
33
+ dataTest,
34
+ prefix,
35
+ options,
36
+ className,
37
+ disabled,
38
+ inputMaxHeight
39
+ } = _ref;
39
40
  const hasSelection = selected.length > 0;
40
41
 
41
42
  const onClear = (_, e) => {
@@ -50,10 +51,10 @@ const Input = ({
50
51
  className: _style.default.dynamic([["1360178250", [_uiConstants.colors.grey900]], ["1331770409", [inputMaxHeight]]]) + " " + ((0, _classnames.default)('root', className) || "")
51
52
  }, /*#__PURE__*/_react.default.createElement(_index.InputPrefix, {
52
53
  prefix: prefix,
53
- dataTest: `${dataTest}-prefix`
54
+ dataTest: "".concat(dataTest, "-prefix")
54
55
  }), !hasSelection && !prefix && /*#__PURE__*/_react.default.createElement(_index.InputPlaceholder, {
55
56
  placeholder: placeholder,
56
- dataTest: `${dataTest}-placeholder`
57
+ dataTest: "".concat(dataTest, "-placeholder")
57
58
  }), hasSelection && /*#__PURE__*/_react.default.createElement("div", {
58
59
  className: _style.default.dynamic([["1360178250", [_uiConstants.colors.grey900]], ["1331770409", [inputMaxHeight]]]) + " " + "root-input"
59
60
  }, /*#__PURE__*/_react.default.createElement(_selectionList.SelectionList, {
@@ -66,14 +67,14 @@ const Input = ({
66
67
  }, /*#__PURE__*/_react.default.createElement(_index.InputClearButton, {
67
68
  onClear: onClear,
68
69
  clearText: clearText,
69
- dataTest: `${dataTest}-clear`
70
+ dataTest: "".concat(dataTest, "-clear")
70
71
  })), /*#__PURE__*/_react.default.createElement(_style.default, {
71
72
  id: "1360178250",
72
73
  dynamic: [_uiConstants.colors.grey900]
73
- }, [`.root.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:${_uiConstants.colors.grey900};font-size:14px;line-height:16px;}`, ".root-input.__jsx-style-dynamic-selector{overflow-y:auto;-webkit-flex:1;-ms-flex:1;flex:1;}", ".root-right.__jsx-style-dynamic-selector{margin-left:auto;margin-right:10px;}"]), /*#__PURE__*/_react.default.createElement(_style.default, {
74
+ }, [".root.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:".concat(_uiConstants.colors.grey900, ";font-size:14px;line-height:16px;}"), ".root-input.__jsx-style-dynamic-selector{overflow-y:auto;-webkit-flex:1;-ms-flex:1;flex:1;}", ".root-right.__jsx-style-dynamic-selector{margin-left:auto;margin-right:10px;}"]), /*#__PURE__*/_react.default.createElement(_style.default, {
74
75
  id: "1331770409",
75
76
  dynamic: [inputMaxHeight]
76
- }, [`.root-input.__jsx-style-dynamic-selector{max-height:${inputMaxHeight};}`]));
77
+ }, [".root-input.__jsx-style-dynamic-selector{max-height:".concat(inputMaxHeight, ";}")]));
77
78
  };
78
79
 
79
80
  exports.Input = Input;
@@ -18,36 +18,40 @@ const onDisabledClick = (_, e) => {
18
18
  e.preventDefault();
19
19
  };
20
20
 
21
- const createHandler = ({
22
- isActive,
23
- onChange,
24
- selected,
25
- value
26
- }) => (_, e) => {
27
- e.stopPropagation(); // If the option is currently selected remove it from the array of selected options
28
-
29
- if (isActive) {
30
- const filtered = (0, _index.removeOption)(value, selected);
21
+ const createHandler = _ref => {
22
+ let {
23
+ isActive,
24
+ onChange,
25
+ selected,
26
+ value
27
+ } = _ref;
28
+ return (_, e) => {
29
+ e.stopPropagation(); // If the option is currently selected remove it from the array of selected options
30
+
31
+ if (isActive) {
32
+ const filtered = (0, _index.removeOption)(value, selected);
33
+ const data = {
34
+ selected: filtered
35
+ };
36
+ return onChange(data, e);
37
+ } // Otherwise, add it to selected
38
+
39
+
31
40
  const data = {
32
- selected: filtered
41
+ selected: selected.concat([value])
33
42
  };
34
43
  return onChange(data, e);
35
- } // Otherwise, add it to selected
36
-
37
-
38
- const data = {
39
- selected: selected.concat([value])
40
44
  };
41
- return onChange(data, e);
42
45
  };
43
46
 
44
- const Menu = ({
45
- options,
46
- onChange,
47
- selected,
48
- empty,
49
- dataTest
50
- }) => {
47
+ const Menu = _ref2 => {
48
+ let {
49
+ options,
50
+ onChange,
51
+ selected,
52
+ empty,
53
+ dataTest
54
+ } = _ref2;
51
55
  const renderedOptions = (0, _index.filterIgnored)(options);
52
56
 
53
57
  if (_react.default.Children.count(renderedOptions) === 0) {
@@ -55,7 +59,7 @@ const Menu = ({
55
59
  if (typeof empty === 'string') {
56
60
  return /*#__PURE__*/_react.default.createElement(_index.Empty, {
57
61
  message: empty,
58
- dataTest: `${dataTest}-empty`
62
+ dataTest: "".concat(dataTest, "-empty")
59
63
  });
60
64
  } // Otherwise just render the supplied markup
61
65
 
@@ -27,34 +27,35 @@ var _menu = require("./menu.js");
27
27
 
28
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
29
 
30
- const MultiSelect = ({
31
- className,
32
- selected,
33
- tabIndex,
34
- maxHeight,
35
- inputMaxHeight,
36
- onChange,
37
- onFocus,
38
- onBlur,
39
- loading,
40
- error,
41
- warning,
42
- valid,
43
- disabled,
44
- children,
45
- clearable,
46
- clearText,
47
- filterable,
48
- filterPlaceholder,
49
- placeholder,
50
- prefix,
51
- empty,
52
- loadingText,
53
- noMatchText,
54
- initialFocus,
55
- dense,
56
- dataTest
57
- }) => {
30
+ const MultiSelect = _ref => {
31
+ let {
32
+ className,
33
+ selected,
34
+ tabIndex,
35
+ maxHeight,
36
+ inputMaxHeight,
37
+ onChange,
38
+ onFocus,
39
+ onBlur,
40
+ loading,
41
+ error,
42
+ warning,
43
+ valid,
44
+ disabled,
45
+ children,
46
+ clearable,
47
+ clearText,
48
+ filterable,
49
+ filterPlaceholder,
50
+ placeholder,
51
+ prefix,
52
+ empty,
53
+ loadingText,
54
+ noMatchText,
55
+ initialFocus,
56
+ dense,
57
+ dataTest
58
+ } = _ref;
58
59
  // If the select is filterable, use a filterable menu
59
60
  const menu = filterable ? /*#__PURE__*/_react.default.createElement(_filterableMenu.FilterableMenu, {
60
61
  dataTest: dataTest,
@@ -95,7 +96,7 @@ const MultiSelect = ({
95
96
  dense: dense
96
97
  }, children, loading && /*#__PURE__*/_react.default.createElement(_index.Loading, {
97
98
  message: loadingText,
98
- dataTest: `${dataTest}-loading`
99
+ dataTest: "".concat(dataTest, "-loading")
99
100
  }))), /*#__PURE__*/_react.default.createElement(_statusIcon.StatusIcon, {
100
101
  error: error,
101
102
  valid: valid,
@@ -103,7 +104,7 @@ const MultiSelect = ({
103
104
  }), /*#__PURE__*/_react.default.createElement(_style.default, {
104
105
  id: "2180377457",
105
106
  dynamic: [_uiConstants.spacers.dp8]
106
- }, [`.root.__jsx-style-dynamic-selector{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:${_uiConstants.spacers.dp8};}`, ".root-input.__jsx-style-dynamic-selector{-webkit-flex:1;-ms-flex:1;flex:1;}"]));
107
+ }, [".root.__jsx-style-dynamic-selector{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:".concat(_uiConstants.spacers.dp8, ";}"), ".root-input.__jsx-style-dynamic-selector{-webkit-flex:1;-ms-flex:1;flex:1;}"]));
107
108
  };
108
109
 
109
110
  exports.MultiSelect = MultiSelect;
@@ -26,12 +26,15 @@ window.onChange = window.Cypress && window.Cypress.cy.stub();
26
26
  window.onFocus = window.Cypress && window.Cypress.cy.stub();
27
27
  window.onBlur = window.Cypress && window.Cypress.cy.stub();
28
28
 
29
- const CustomMultiSelectOption = ({
30
- label,
31
- onClick
32
- }) => /*#__PURE__*/_react2.default.createElement("div", {
33
- onClick: e => onClick({}, e)
34
- }, label);
29
+ const CustomMultiSelectOption = _ref => {
30
+ let {
31
+ label,
32
+ onClick
33
+ } = _ref;
34
+ return /*#__PURE__*/_react2.default.createElement("div", {
35
+ onClick: e => onClick({}, e)
36
+ }, label);
37
+ };
35
38
 
36
39
  CustomMultiSelectOption.propTypes = {
37
40
  label: _propTypes.default.string,
@@ -545,9 +548,10 @@ const options = [{
545
548
  return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement(_multiSelect.MultiSelect, {
546
549
  className: "select",
547
550
  selected: values,
548
- onChange: ({
549
- selected
550
- }) => {
551
+ onChange: _ref2 => {
552
+ let {
553
+ selected
554
+ } = _ref2;
551
555
  window.onChange && window.onChange({
552
556
  selected
553
557
  });
@@ -586,17 +590,23 @@ const options = [{
586
590
  flexGrow: 1
587
591
  }
588
592
  }, /*#__PURE__*/_react2.default.createElement(_multiSelect.MultiSelect, {
589
- onChange: ({
590
- selected
591
- }) => console.log('size changed to ' + selected)
592
- }, options.map(({
593
- name,
594
- id
595
- }) => /*#__PURE__*/_react2.default.createElement(_index.MultiSelectOption, {
596
- key: id,
597
- value: id,
598
- label: name
599
- })))), toggle && /*#__PURE__*/_react2.default.createElement("div", {
593
+ onChange: _ref3 => {
594
+ let {
595
+ selected
596
+ } = _ref3;
597
+ return console.log('size changed to ' + selected);
598
+ }
599
+ }, options.map(_ref4 => {
600
+ let {
601
+ name,
602
+ id
603
+ } = _ref4;
604
+ return /*#__PURE__*/_react2.default.createElement(_index.MultiSelectOption, {
605
+ key: id,
606
+ value: id,
607
+ label: name
608
+ });
609
+ }))), toggle && /*#__PURE__*/_react2.default.createElement("div", {
600
610
  style: {
601
611
  padding: '30px',
602
612
  border: '1px solid green'
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.ShiftedIntoView = exports.FlippedPosition = exports.DefaultPosition = exports.WithFilterField = exports.WithClearButtonSelectionAndOnChange = exports.WithOptionsAndMultipleSelections = exports.WithDisabledOptionAndOnChange = exports.WithPlaceholderAndSelection = exports.WithPlaceholder = exports.WithPrefixAndSelection = exports.WithPrefix = exports.WithOptionsASelectionAndDisabled = exports.WithOptionsAndDisabled = exports.WithMoreThanThreeOptionsAndA100PxMaxHeight = exports.WithMoreThanTenOptions = exports.WithOptionsLoadingAndLoadingText = exports.WithOptionsAndLoading = exports.EmptyWithEmptyComponent = exports.EmptyWithEmptyText = exports.Empty = exports.WithInitialFocus = exports.WithInvalidFilterableOptions = exports.WithInvalidOptions = exports.WithCustomOptionsAndOnChange = exports.WithOnBlur = exports.WithOnFocus = exports.WithOptionsAndASelection = exports.WithOptionsAndOnChange = exports.default = void 0;
6
+ exports.default = exports.WithPrefixAndSelection = exports.WithPrefix = exports.WithPlaceholderAndSelection = exports.WithPlaceholder = exports.WithOptionsLoadingAndLoadingText = exports.WithOptionsAndOnChange = exports.WithOptionsAndMultipleSelections = exports.WithOptionsAndLoading = exports.WithOptionsAndDisabled = exports.WithOptionsAndASelection = exports.WithOptionsASelectionAndDisabled = exports.WithOnFocus = exports.WithOnBlur = exports.WithMoreThanThreeOptionsAndA100PxMaxHeight = exports.WithMoreThanTenOptions = exports.WithInvalidOptions = exports.WithInvalidFilterableOptions = exports.WithInitialFocus = exports.WithFilterField = exports.WithDisabledOptionAndOnChange = exports.WithCustomOptionsAndOnChange = exports.WithClearButtonSelectionAndOnChange = exports.ShiftedIntoView = exports.FlippedPosition = exports.EmptyWithEmptyText = exports.EmptyWithEmptyComponent = exports.Empty = exports.DefaultPosition = void 0;
7
7
 
8
8
  var _style = _interopRequireDefault(require("styled-jsx/style"));
9
9
 
@@ -19,35 +19,26 @@ var _index2 = require("./index.js");
19
19
 
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
21
 
22
- const description = `
23
- Multiple selection allows the user to select more than one option from the list. Checkboxes are used to highlight the possibility of making more than one selection. Selected options are displayed as chips inside the input. Make sure to communicate clearly to the user if there is a limit to the number of selectable elements.
24
-
25
- Use multiple selection wherever the user needs to make more than one selection. If the multiple selection is complex, requires a defined order or needs to made from different groups, consider using a transfer component instead.
26
-
27
- Read more about using \`Select\` components at [Design System: Select](https://github.com/dhis2/design-system/blob/master/molecules/select.md).
28
-
29
- \`\`\`js
30
- import { MultiSelect, MultiSelectOption } from '@dhis2/ui'
31
- \`\`\`
32
-
33
- _**Note:** Due to demo limitations on this page, only one representative example is rendered here. For more (props-interactive) examples, see individual stories in the 'Canvas' tab._
34
- `;
22
+ const description = "\nMultiple selection allows the user to select more than one option from the list. Checkboxes are used to highlight the possibility of making more than one selection. Selected options are displayed as chips inside the input. Make sure to communicate clearly to the user if there is a limit to the number of selectable elements.\n\nUse multiple selection wherever the user needs to make more than one selection. If the multiple selection is complex, requires a defined order or needs to made from different groups, consider using a transfer component instead.\n\nRead more about using `Select` components at [Design System: Select](https://github.com/dhis2/design-system/blob/master/molecules/select.md).\n\n```js\nimport { MultiSelect, MultiSelectOption } from '@dhis2/ui'\n```\n\n_**Note:** Due to demo limitations on this page, only one representative example is rendered here. For more (props-interactive) examples, see individual stories in the 'Canvas' tab._\n";
35
23
 
36
24
  const eventHandler = handlerName => (payload, event) => {
37
- console.log(`${handlerName} payload`, payload);
38
- console.log(`${handlerName} event`, event);
25
+ console.log("".concat(handlerName, " payload"), payload);
26
+ console.log("".concat(handlerName, " event"), event);
39
27
  };
40
28
 
41
29
  const onChange = eventHandler('onChange');
42
30
  const onFocus = eventHandler('onFocus');
43
31
  const onBlur = eventHandler('onBlur');
44
32
 
45
- const CustomMultiSelectOption = ({
46
- label,
47
- onClick
48
- }) => /*#__PURE__*/_react.default.createElement("div", {
49
- onClick: e => onClick({}, e)
50
- }, label);
33
+ const CustomMultiSelectOption = _ref => {
34
+ let {
35
+ label,
36
+ onClick
37
+ } = _ref;
38
+ return /*#__PURE__*/_react.default.createElement("div", {
39
+ onClick: e => onClick({}, e)
40
+ }, label);
41
+ };
51
42
 
52
43
  CustomMultiSelectOption.propTypes = {
53
44
  label: _propTypes.default.string,
@@ -64,7 +55,7 @@ const requiredIfArgType = {
64
55
  }
65
56
  };
66
57
  var _default = {
67
- title: 'Forms/Multi Select/Multi Select',
58
+ title: 'Multi Select',
68
59
  component: _index2.MultiSelect,
69
60
  parameters: {
70
61
  docs: {
@@ -15,50 +15,56 @@ var _index = require("../select/index.js");
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- const createRemoveHandler = ({
19
- selected,
20
- onChange,
21
- value
22
- }) => (_, e) => {
23
- const filtered = (0, _index.removeOption)(value, selected);
24
- const data = {
25
- selected: filtered
18
+ const createRemoveHandler = _ref => {
19
+ let {
20
+ selected,
21
+ onChange,
22
+ value
23
+ } = _ref;
24
+ return (_, e) => {
25
+ const filtered = (0, _index.removeOption)(value, selected);
26
+ const data = {
27
+ selected: filtered
28
+ };
29
+ onChange(data, e);
26
30
  };
27
- onChange(data, e);
28
31
  };
29
32
 
30
- const SelectionList = ({
31
- selected,
32
- onChange,
33
- disabled,
34
- options
35
- }) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, selected.map(value => {
36
- const selectedOption = (0, _index.findOptionChild)(value, options);
33
+ const SelectionList = _ref2 => {
34
+ let {
35
+ selected,
36
+ onChange,
37
+ disabled,
38
+ options
39
+ } = _ref2;
40
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, selected.map(value => {
41
+ const selectedOption = (0, _index.findOptionChild)(value, options);
37
42
 
38
- if (!selectedOption) {
39
- const message = `There is no option with the value: "${value}". ` + 'Make sure that all the values passed to the selected ' + 'prop match the value of an existing option.';
40
- throw new Error(message);
41
- } // The chip should be disabled if the option or the select are disabled
43
+ if (!selectedOption) {
44
+ const message = "There is no option with the value: \"".concat(value, "\". ") + 'Make sure that all the values passed to the selected ' + 'prop match the value of an existing option.';
45
+ throw new Error(message);
46
+ } // The chip should be disabled if the option or the select are disabled
42
47
 
43
48
 
44
- const isDisabled = selectedOption.props.disabled || disabled; // Create an onRemove handler, but only if it's not disabled
49
+ const isDisabled = selectedOption.props.disabled || disabled; // Create an onRemove handler, but only if it's not disabled
45
50
 
46
- const onRemove = isDisabled ? undefined : createRemoveHandler({
47
- selected,
48
- onChange,
49
- value
50
- });
51
- return /*#__PURE__*/_react.default.createElement(_chip.Chip, {
52
- key: value,
53
- onRemove: onRemove,
54
- disabled: isDisabled,
55
- marginBottom: "0",
56
- marginLeft: "0",
57
- marginTop: "0",
58
- overflow: true,
59
- dense: true
60
- }, selectedOption.props.label);
61
- }));
51
+ const onRemove = isDisabled ? undefined : createRemoveHandler({
52
+ selected,
53
+ onChange,
54
+ value
55
+ });
56
+ return /*#__PURE__*/_react.default.createElement(_chip.Chip, {
57
+ key: value,
58
+ onRemove: onRemove,
59
+ disabled: isDisabled,
60
+ marginBottom: "0",
61
+ marginLeft: "0",
62
+ marginTop: "0",
63
+ overflow: true,
64
+ dense: true
65
+ }, selectedOption.props.label);
66
+ }));
67
+ };
62
68
 
63
69
  exports.SelectionList = SelectionList;
64
70
  SelectionList.propTypes = {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.DefaultLoadingText = exports.DefaultFilterPlaceholderAndNoMatchText = exports.DefaultEmpty = exports.DefaultClearText = exports.InputWidth = exports.Required = exports.StatusError = exports.StatusWarning = exports.StatusValid = exports.WithHelpText = exports.Default = exports.default = void 0;
6
+ exports.default = exports.WithHelpText = exports.StatusWarning = exports.StatusValid = exports.StatusError = exports.Required = exports.InputWidth = exports.DefaultLoadingText = exports.DefaultFilterPlaceholderAndNoMatchText = exports.DefaultEmpty = exports.DefaultClearText = exports.Default = void 0;
7
7
 
8
8
  var _uiConstants = require("@dhis2/ui-constants");
9
9
 
@@ -15,19 +15,9 @@ var _index2 = require("./index.js");
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- const description = `
19
- \`MultiSelectField\` is a wrapper around a \`MultiSelect\` component that adds a label, help text, validation text, and other features.
18
+ const description = "\n`MultiSelectField` is a wrapper around a `MultiSelect` component that adds a label, help text, validation text, and other features.\n\nSee the MultiSelect for more information, and read more at [Design System: Select](https://github.com/dhis2/design-system/blob/master/molecules/select.md#multiple-selection).\n\n```js\nimport { MultiSelectField, MultiSelectOption } from '@dhis2/ui'\n```\n\n_**Note**: The dropdowns in some of the following stories won't appear correctly on this page. View these demos in the 'Canvas' tab._\n";
20
19
 
21
- See the MultiSelect for more information, and read more at [Design System: Select](https://github.com/dhis2/design-system/blob/master/molecules/select.md#multiple-selection).
22
-
23
- \`\`\`js
24
- import { MultiSelectField, MultiSelectOption } from '@dhis2/ui'
25
- \`\`\`
26
-
27
- _**Note**: The dropdowns in some of the following stories won't appear correctly on this page. View these demos in the 'Canvas' tab._
28
- `;
29
-
30
- const onChange = selected => alert(`Selected changed to: ${JSON.stringify(selected, null, 2)}`);
20
+ const onChange = selected => alert("Selected changed to: ".concat(JSON.stringify(selected, null, 2)));
31
21
 
32
22
  const options = [/*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
33
23
  key: "1",
@@ -71,7 +61,7 @@ const options = [/*#__PURE__*/_react.default.createElement(_index.MultiSelectOpt
71
61
  label: "ten"
72
62
  })];
73
63
  var _default = {
74
- title: 'Forms/Multi Select/Multi Select Field',
64
+ title: 'Multi Select Field',
75
65
  component: _index2.MultiSelectField,
76
66
  subcomponents: {
77
67
  MultiSelectOption: _index.MultiSelectOption
@@ -114,7 +104,7 @@ WithHelpText.args = {
114
104
  WithHelpText.parameters = {
115
105
  docs: {
116
106
  description: {
117
- story: `_**Note**: The dropdowns in the following stories won't appear correctly on this page. View these demos in the 'Canvas' tab._`
107
+ story: "_**Note**: The dropdowns in the following stories won't appear correctly on this page. View these demos in the 'Canvas' tab._"
118
108
  }
119
109
  }
120
110
  };