@dhis2-ui/select 9.11.0 → 9.11.1-beta.10

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 (169) hide show
  1. package/build/cjs/index.js +0 -6
  2. package/build/cjs/locales/index.js +3 -69
  3. package/build/cjs/multi-select/__tests__/multi-select.test.js +1 -7
  4. package/build/cjs/multi-select/__tests__/selection-list.test.js +7 -18
  5. package/build/cjs/multi-select/features/accepts_blur_cb/index.js +1 -2
  6. package/build/cjs/multi-select/features/accepts_focus_cb/index.js +1 -2
  7. package/build/cjs/multi-select/features/accepts_initial_focus/index.js +1 -2
  8. package/build/cjs/multi-select/features/accepts_loading/index.js +0 -1
  9. package/build/cjs/multi-select/features/accepts_max_height/index.js +1 -2
  10. package/build/cjs/multi-select/features/accepts_placeholder/index.js +0 -1
  11. package/build/cjs/multi-select/features/accepts_prefix/index.js +0 -1
  12. package/build/cjs/multi-select/features/allows_invalid_options/index.js +0 -1
  13. package/build/cjs/multi-select/features/allows_selecting/index.js +2 -3
  14. package/build/cjs/multi-select/features/can_be_cleared/index.js +1 -2
  15. package/build/cjs/multi-select/features/can_be_disabled/index.js +0 -1
  16. package/build/cjs/multi-select/features/can_be_empty/index.js +0 -1
  17. package/build/cjs/multi-select/features/can_be_filtered/index.js +0 -1
  18. package/build/cjs/multi-select/features/can_be_opened_and_closed/index.js +0 -1
  19. package/build/cjs/multi-select/features/common/index.js +2 -3
  20. package/build/cjs/multi-select/features/duplicate_option_values/index.js +0 -1
  21. package/build/cjs/multi-select/features/menu_width_matches_input/index.js +1 -2
  22. package/build/cjs/multi-select/features/position/index.js +4 -5
  23. package/build/cjs/multi-select/features/position.feature +0 -1
  24. package/build/cjs/multi-select/features/shows_selections/index.js +0 -1
  25. package/build/cjs/multi-select/filterable-menu.js +1 -8
  26. package/build/cjs/multi-select/index.js +0 -1
  27. package/build/cjs/multi-select/input.js +6 -19
  28. package/build/cjs/multi-select/menu.js +16 -23
  29. package/build/cjs/multi-select/multi-select.e2e.stories.js +675 -0
  30. package/build/cjs/multi-select/multi-select.js +4 -21
  31. package/build/cjs/multi-select/{multi-select.stories.js → multi-select.prod.stories.js} +62 -101
  32. package/build/cjs/multi-select/selection-list.js +10 -18
  33. package/build/cjs/multi-select-field/__tests__/multi-select-field.test.js +1 -7
  34. package/build/cjs/multi-select-field/features/accepts_help_text/index.js +0 -1
  35. package/build/cjs/multi-select-field/features/accepts_label/index.js +0 -1
  36. package/build/cjs/multi-select-field/features/accepts_validation_text/index.js +0 -1
  37. package/build/cjs/multi-select-field/features/can_be_required/index.js +0 -1
  38. package/build/cjs/multi-select-field/features/has_default_clear_text/index.js +0 -1
  39. package/build/cjs/multi-select-field/features/has_default_empty_text/index.js +0 -1
  40. package/build/cjs/multi-select-field/features/has_default_filter_nomatch_text/index.js +0 -1
  41. package/build/cjs/multi-select-field/features/has_default_filter_placeholder/index.js +0 -1
  42. package/build/cjs/multi-select-field/features/has_default_loading_text/index.js +0 -1
  43. package/build/cjs/multi-select-field/index.js +0 -1
  44. package/build/cjs/multi-select-field/multi-select-field.e2e.stories.js +89 -0
  45. package/build/cjs/multi-select-field/multi-select-field.js +10 -51
  46. package/build/cjs/multi-select-field/{multi-select-field.stories.js → multi-select-field.prod.stories.js} +31 -39
  47. package/build/cjs/multi-select-option/index.js +0 -1
  48. package/build/cjs/multi-select-option/multi-select-option.js +4 -14
  49. package/build/cjs/select/__tests__/select.test.js +1 -7
  50. package/build/cjs/select/debounce/debounce.js +1 -8
  51. package/build/cjs/select/debounce/debounce.spec.js +0 -1
  52. package/build/cjs/select/empty.js +2 -9
  53. package/build/cjs/select/filter-input.js +3 -11
  54. package/build/cjs/select/filterable-menu.js +15 -29
  55. package/build/cjs/select/index.js +0 -8
  56. package/build/cjs/select/input-clear-button.js +3 -11
  57. package/build/cjs/select/input-placeholder.js +2 -11
  58. package/build/cjs/select/input-prefix.js +2 -11
  59. package/build/cjs/select/input-wrapper.js +2 -11
  60. package/build/cjs/select/loading.js +3 -12
  61. package/build/cjs/select/menu-wrapper.js +4 -13
  62. package/build/cjs/select/no-match.js +2 -9
  63. package/build/cjs/select/option-helpers.js +9 -18
  64. package/build/cjs/select/select.js +23 -69
  65. package/build/cjs/single-select/__tests__/selection.test.js +7 -18
  66. package/build/cjs/single-select/__tests__/single-select.test.js +1 -7
  67. package/build/cjs/single-select/features/accepts_blur_cb/index.js +1 -2
  68. package/build/cjs/single-select/features/accepts_focus_cb/index.js +1 -2
  69. package/build/cjs/single-select/features/accepts_initial_focus/index.js +1 -2
  70. package/build/cjs/single-select/features/accepts_loading/index.js +0 -1
  71. package/build/cjs/single-select/features/accepts_max_height/index.js +1 -2
  72. package/build/cjs/single-select/features/accepts_placeholder/index.js +0 -1
  73. package/build/cjs/single-select/features/accepts_prefix/index.js +0 -1
  74. package/build/cjs/single-select/features/allows_invalid_options/index.js +0 -1
  75. package/build/cjs/single-select/features/allows_selecting/index.js +2 -3
  76. package/build/cjs/single-select/features/can_be_cleared/index.js +1 -2
  77. package/build/cjs/single-select/features/can_be_disabled/index.js +0 -1
  78. package/build/cjs/single-select/features/can_be_empty/index.js +0 -1
  79. package/build/cjs/single-select/features/can_be_filtered/index.js +0 -1
  80. package/build/cjs/single-select/features/can_be_opened_and_closed/index.js +0 -1
  81. package/build/cjs/single-select/features/common/index.js +2 -3
  82. package/build/cjs/single-select/features/duplicate_option_values/index.js +0 -1
  83. package/build/cjs/single-select/features/menu_width_matches_input/index.js +1 -2
  84. package/build/cjs/single-select/features/position/index.js +3 -4
  85. package/build/cjs/single-select/features/shows_selections/index.js +0 -1
  86. package/build/cjs/single-select/filterable-menu.js +1 -8
  87. package/build/cjs/single-select/index.js +0 -1
  88. package/build/cjs/single-select/input.js +6 -19
  89. package/build/cjs/single-select/menu.js +12 -21
  90. package/build/cjs/single-select/selection.js +5 -17
  91. package/build/cjs/single-select/single-select.e2e.stories.js +633 -0
  92. package/build/cjs/single-select/single-select.js +4 -25
  93. package/build/cjs/single-select/{single-select.stories.js → single-select.prod.stories.js} +58 -95
  94. package/build/cjs/single-select-field/__tests__/single-select-field.test.js +1 -7
  95. package/build/cjs/single-select-field/features/accepts_help_text/index.js +0 -1
  96. package/build/cjs/single-select-field/features/accepts_label/index.js +0 -1
  97. package/build/cjs/single-select-field/features/accepts_validation_text/index.js +0 -1
  98. package/build/cjs/single-select-field/features/can_be_required/index.js +0 -1
  99. package/build/cjs/single-select-field/features/has_default_clear_text/index.js +0 -1
  100. package/build/cjs/single-select-field/features/has_default_empty_text/index.js +0 -1
  101. package/build/cjs/single-select-field/features/has_default_filter_nomatch_text/index.js +0 -1
  102. package/build/cjs/single-select-field/features/has_default_filter_placeholder/index.js +0 -1
  103. package/build/cjs/single-select-field/features/has_default_loading_text/index.js +0 -1
  104. package/build/cjs/single-select-field/index.js +0 -1
  105. package/build/cjs/single-select-field/single-select-field.e2e.stories.js +89 -0
  106. package/build/cjs/single-select-field/single-select-field.js +10 -51
  107. package/build/cjs/single-select-field/{single-select-field.stories.js → single-select-field.prod.stories.js} +31 -39
  108. package/build/cjs/single-select-option/index.js +0 -1
  109. package/build/cjs/single-select-option/single-select-option.js +2 -10
  110. package/build/es/multi-select/__tests__/selection-list.test.js +6 -3
  111. package/build/es/multi-select/features/accepts_blur_cb/index.js +1 -1
  112. package/build/es/multi-select/features/accepts_focus_cb/index.js +1 -1
  113. package/build/es/multi-select/features/accepts_initial_focus/index.js +1 -1
  114. package/build/es/multi-select/features/accepts_max_height/index.js +1 -1
  115. package/build/es/multi-select/features/allows_selecting/index.js +2 -2
  116. package/build/es/multi-select/features/can_be_cleared/index.js +1 -1
  117. package/build/es/multi-select/features/common/index.js +2 -2
  118. package/build/es/multi-select/features/menu_width_matches_input/index.js +1 -1
  119. package/build/es/multi-select/features/position/index.js +4 -4
  120. package/build/es/multi-select/features/position.feature +0 -1
  121. package/build/es/multi-select/filterable-menu.js +0 -2
  122. package/build/es/multi-select/input.js +5 -9
  123. package/build/es/multi-select/menu.js +15 -17
  124. package/build/es/multi-select/{multi-select.stories.e2e.js → multi-select.e2e.stories.js} +74 -42
  125. package/build/es/multi-select/multi-select.js +3 -9
  126. package/build/es/multi-select/{multi-select.stories.js → multi-select.prod.stories.js} +40 -24
  127. package/build/es/multi-select/selection-list.js +9 -12
  128. package/build/es/multi-select-field/{multi-select-field.stories.e2e.js → multi-select-field.e2e.stories.js} +18 -9
  129. package/build/es/multi-select-field/multi-select-field.js +4 -35
  130. package/build/es/multi-select-field/{multi-select-field.stories.js → multi-select-field.prod.stories.js} +19 -9
  131. package/build/es/multi-select-option/multi-select-option.js +3 -5
  132. package/build/es/select/debounce/debounce.js +1 -6
  133. package/build/es/select/empty.js +1 -3
  134. package/build/es/select/filter-input.js +2 -4
  135. package/build/es/select/filterable-menu.js +12 -15
  136. package/build/es/select/input-clear-button.js +2 -4
  137. package/build/es/select/input-placeholder.js +1 -5
  138. package/build/es/select/input-prefix.js +1 -5
  139. package/build/es/select/input-wrapper.js +1 -3
  140. package/build/es/select/loading.js +2 -2
  141. package/build/es/select/menu-wrapper.js +3 -5
  142. package/build/es/select/no-match.js +1 -3
  143. package/build/es/select/option-helpers.js +10 -6
  144. package/build/es/select/select.js +22 -51
  145. package/build/es/single-select/__tests__/selection.test.js +6 -3
  146. package/build/es/single-select/features/accepts_blur_cb/index.js +1 -1
  147. package/build/es/single-select/features/accepts_focus_cb/index.js +1 -1
  148. package/build/es/single-select/features/accepts_initial_focus/index.js +1 -1
  149. package/build/es/single-select/features/accepts_max_height/index.js +1 -1
  150. package/build/es/single-select/features/allows_selecting/index.js +2 -2
  151. package/build/es/single-select/features/can_be_cleared/index.js +1 -1
  152. package/build/es/single-select/features/common/index.js +2 -2
  153. package/build/es/single-select/features/menu_width_matches_input/index.js +1 -1
  154. package/build/es/single-select/features/position/index.js +3 -3
  155. package/build/es/single-select/input.js +5 -9
  156. package/build/es/single-select/menu.js +11 -15
  157. package/build/es/single-select/selection.js +4 -9
  158. package/build/es/single-select/{single-select.stories.e2e.js → single-select.e2e.stories.js} +68 -38
  159. package/build/es/single-select/single-select.js +3 -13
  160. package/build/es/single-select/{single-select.stories.js → single-select.prod.stories.js} +37 -24
  161. package/build/es/single-select-field/{single-select-field.stories.e2e.js → single-select-field.e2e.stories.js} +18 -9
  162. package/build/es/single-select-field/single-select-field.js +4 -35
  163. package/build/es/single-select-field/{single-select-field.stories.js → single-select-field.prod.stories.js} +19 -9
  164. package/build/es/single-select-option/single-select-option.js +1 -3
  165. package/package.json +18 -18
  166. package/build/cjs/multi-select/multi-select.stories.e2e.js +0 -618
  167. package/build/cjs/multi-select-field/multi-select-field.stories.e2e.js +0 -73
  168. package/build/cjs/single-select/single-select.stories.e2e.js +0 -579
  169. package/build/cjs/single-select-field/single-select-field.stories.e2e.js +0 -73
@@ -4,29 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.SingleSelect = void 0;
7
-
8
7
  var _style = _interopRequireDefault(require("styled-jsx/style"));
9
-
10
- var _statusIcon = require("@dhis2-ui/status-icon");
11
-
12
8
  var _propTypes = require("@dhis2/prop-types");
13
-
14
9
  var _uiConstants = require("@dhis2/ui-constants");
15
-
10
+ var _statusIcon = require("@dhis2-ui/status-icon");
16
11
  var _propTypes2 = _interopRequireDefault(require("prop-types"));
17
-
18
12
  var _react = _interopRequireDefault(require("react"));
19
-
20
13
  var _index = require("../select/index.js");
21
-
22
14
  var _filterableMenu = require("./filterable-menu.js");
23
-
24
15
  var _input = require("./input.js");
25
-
26
16
  var _menu = require("./menu.js");
27
-
28
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
-
17
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
30
18
  const SingleSelect = _ref => {
31
19
  let {
32
20
  className,
@@ -98,7 +86,7 @@ const SingleSelect = _ref => {
98
86
  dense: dense
99
87
  }, children, loading && /*#__PURE__*/_react.default.createElement(_index.Loading, {
100
88
  message: loadingText,
101
- dataTest: "".concat(dataTest, "-loading")
89
+ dataTest: `${dataTest}-loading`
102
90
  }))), /*#__PURE__*/_react.default.createElement(_statusIcon.StatusIcon, {
103
91
  error: error,
104
92
  valid: valid,
@@ -106,9 +94,8 @@ const SingleSelect = _ref => {
106
94
  }), /*#__PURE__*/_react.default.createElement(_style.default, {
107
95
  id: "2180377457",
108
96
  dynamic: [_uiConstants.spacers.dp8]
109
- }, [".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;}"]));
97
+ }, [`.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;}"]));
110
98
  };
111
-
112
99
  exports.SingleSelect = SingleSelect;
113
100
  SingleSelect.defaultProps = {
114
101
  selected: '',
@@ -117,23 +104,18 @@ SingleSelect.defaultProps = {
117
104
  SingleSelect.propTypes = {
118
105
  children: _propTypes2.default.node,
119
106
  className: _propTypes2.default.string,
120
-
121
107
  /** Text on button that clears selection. Required if `clearable` prop is true */
122
108
  clearText: (0, _propTypes.requiredIf)(props => props.clearable, _propTypes2.default.string),
123
-
124
109
  /** Adds a button to clear selection */
125
110
  clearable: _propTypes2.default.bool,
126
111
  dataTest: _propTypes2.default.string,
127
112
  dense: _propTypes2.default.bool,
128
113
  disabled: _propTypes2.default.bool,
129
-
130
114
  /** Text or component to display when there are no options */
131
115
  empty: _propTypes2.default.node,
132
-
133
116
  /** Applies 'error' appearance for validation feedback. Mutually exclusive with `warning` and `valid` props */
134
117
  error: _uiConstants.sharedPropTypes.statusPropType,
135
118
  filterPlaceholder: _propTypes2.default.string,
136
-
137
119
  /** Adds a filter field to add text to filter options */
138
120
  filterable: _propTypes2.default.bool,
139
121
  initialFocus: _propTypes2.default.bool,
@@ -141,17 +123,14 @@ SingleSelect.propTypes = {
141
123
  loading: _propTypes2.default.bool,
142
124
  loadingText: _propTypes2.default.string,
143
125
  maxHeight: _propTypes2.default.string,
144
-
145
126
  /** Text to show when filter returns no results. Required if `filterable` prop is true */
146
127
  noMatchText: (0, _propTypes.requiredIf)(props => props.filterable, _propTypes2.default.string),
147
128
  placeholder: _propTypes2.default.string,
148
129
  prefix: _propTypes2.default.string,
149
130
  selected: _propTypes2.default.string,
150
131
  tabIndex: _propTypes2.default.string,
151
-
152
132
  /** Applies 'valid' appearance for validation feedback. Mutually exclusive with `warning` and `error` props */
153
133
  valid: _uiConstants.sharedPropTypes.statusPropType,
154
-
155
134
  /** Applies 'warning' appearance for validation feedback. Mutually exclusive with `valid` and `error` props */
156
135
  warning: _uiConstants.sharedPropTypes.statusPropType,
157
136
  onBlur: _propTypes2.default.func,
@@ -4,36 +4,33 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = exports.WithRTL = exports.WithPrefixAndSelection = exports.WithPrefix = exports.WithPlaceholderAndSelection = exports.WithPlaceholder = exports.WithOptionsLoadingAndLoadingText = exports.WithOptionsAndOnChange = 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.Dense = exports.DefaultPosition = void 0;
7
-
8
7
  var _style = _interopRequireDefault(require("styled-jsx/style"));
9
-
10
8
  var _uiConstants = require("@dhis2/ui-constants");
11
-
12
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
-
14
10
  var _react = _interopRequireWildcard(require("react"));
15
-
16
11
  var _index = require("../index.js");
17
-
18
12
  var _index2 = require("./index.js");
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+ const description = `
17
+ Use a select component wherever the user needs to make a selection of one or more options from a list of 6 or more options. If there are less than 6 options to choose from and space permits, use checkboxes for multiple selection and radio buttons for single selection. If the user needs to make a complex selection with a specific ordering, use a transfer instead.
19
18
 
20
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
-
22
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
+ Learn more about using Selects at [Design System: Select](https://github.com/dhis2/design-system/blob/master/molecules/select.md).
23
20
 
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
- const description = "\nUse a select component wherever the user needs to make a selection of one or more options from a list of 6 or more options. If there are less than 6 options to choose from and space permits, use checkboxes for multiple selection and radio buttons for single selection. If the user needs to make a complex selection with a specific ordering, use a transfer instead.\n\nLearn more about using Selects at [Design System: Select](https://github.com/dhis2/design-system/blob/master/molecules/select.md).\n\n```js\nimport { SingleSelect, SingleSelectOption } from '@dhis2/ui'\n```\n\n_**Note:** Due to demo limitations on this page, only one representative example is rendered here. For more (interactive) examples, see individual stories in the 'Canvas' tab._\n";
21
+ \`\`\`js
22
+ import { SingleSelect, SingleSelectOption } from '@dhis2/ui'
23
+ \`\`\`
27
24
 
25
+ _**Note:** Due to demo limitations on this page, only one representative example is rendered here. For more (interactive) examples, see individual stories in the 'Canvas' tab._
26
+ `;
28
27
  const eventHandler = handlerName => (payload, event) => {
29
- console.log("".concat(handlerName, " payload"), payload);
30
- console.log("".concat(handlerName, " event"), event);
28
+ console.log(`${handlerName} payload`, payload);
29
+ console.log(`${handlerName} event`, event);
31
30
  };
32
-
33
31
  const onChange = eventHandler('onChange');
34
32
  const onFocus = eventHandler('onFocus');
35
33
  const onBlur = eventHandler('onBlur');
36
-
37
34
  const CustomSingleSelectOption = _ref => {
38
35
  let {
39
36
  label,
@@ -43,7 +40,6 @@ const CustomSingleSelectOption = _ref => {
43
40
  onClick: e => onClick({}, e)
44
41
  }, label);
45
42
  };
46
-
47
43
  CustomSingleSelectOption.propTypes = {
48
44
  label: _propTypes.default.string,
49
45
  onClick: _propTypes.default.func
@@ -58,7 +54,7 @@ const requiredIfArgType = {
58
54
  }
59
55
  }
60
56
  };
61
- var _default = {
57
+ var _default = exports.default = {
62
58
  title: 'Single Select',
63
59
  component: _index2.SingleSelect,
64
60
  parameters: {
@@ -80,20 +76,23 @@ var _default = {
80
76
  onChange
81
77
  },
82
78
  argTypes: {
83
- valid: { ..._uiConstants.sharedPropTypes.statusArgType
79
+ valid: {
80
+ ..._uiConstants.sharedPropTypes.statusArgType
84
81
  },
85
- warning: { ..._uiConstants.sharedPropTypes.statusArgType
82
+ warning: {
83
+ ..._uiConstants.sharedPropTypes.statusArgType
86
84
  },
87
- error: { ..._uiConstants.sharedPropTypes.statusArgType
85
+ error: {
86
+ ..._uiConstants.sharedPropTypes.statusArgType
88
87
  },
89
- clearText: { ...requiredIfArgType
88
+ clearText: {
89
+ ...requiredIfArgType
90
90
  },
91
- noMatchText: { ...requiredIfArgType
91
+ noMatchText: {
92
+ ...requiredIfArgType
92
93
  }
93
94
  }
94
95
  };
95
- exports.default = _default;
96
-
97
96
  const WithOptionsTemplate = args => /*#__PURE__*/_react.default.createElement(_index2.SingleSelect, args, /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
98
97
  value: "1",
99
98
  label: "option one"
@@ -104,37 +103,30 @@ const WithOptionsTemplate = args => /*#__PURE__*/_react.default.createElement(_i
104
103
  value: "3",
105
104
  label: "option three"
106
105
  }));
107
-
108
106
  const EmptyTemplate = args => /*#__PURE__*/_react.default.createElement(_index2.SingleSelect, args);
109
-
110
- const WithOptionsAndOnChange = WithOptionsTemplate.bind({});
111
- exports.WithOptionsAndOnChange = WithOptionsAndOnChange;
107
+ const WithOptionsAndOnChange = exports.WithOptionsAndOnChange = WithOptionsTemplate.bind({});
112
108
  WithOptionsAndOnChange.storyName = 'With options and onChange';
113
- const WithOptionsAndASelection = WithOptionsTemplate.bind({});
114
- exports.WithOptionsAndASelection = WithOptionsAndASelection;
109
+ const WithOptionsAndASelection = exports.WithOptionsAndASelection = WithOptionsTemplate.bind({});
115
110
  WithOptionsAndASelection.args = {
116
111
  selected: '1'
117
- }; // Enable this story as the primary for docs as a representative example
118
-
112
+ };
113
+ // Enable this story as the primary for docs as a representative example
119
114
  WithOptionsAndASelection.parameters = {
120
115
  docs: {
121
116
  disable: false
122
117
  }
123
118
  };
124
119
  WithOptionsAndASelection.storyName = 'With options and a selection';
125
- const WithOnFocus = WithOptionsTemplate.bind({});
126
- exports.WithOnFocus = WithOnFocus;
120
+ const WithOnFocus = exports.WithOnFocus = WithOptionsTemplate.bind({});
127
121
  WithOnFocus.args = {
128
122
  onFocus
129
123
  };
130
- WithOnFocus.storyName = 'With onFocus';
131
- const WithOnBlur = WithOptionsTemplate.bind({});
132
- exports.WithOnBlur = WithOnBlur;
124
+ WithOnFocus.storyName = 'With on focus';
125
+ const WithOnBlur = exports.WithOnBlur = WithOptionsTemplate.bind({});
133
126
  WithOnBlur.args = {
134
127
  onBlur
135
128
  };
136
129
  WithOnBlur.storyName = 'With onBlur';
137
-
138
130
  const WithCustomOptionsAndOnChange = args => /*#__PURE__*/_react.default.createElement(_index2.SingleSelect, args, /*#__PURE__*/_react.default.createElement(CustomSingleSelectOption, {
139
131
  value: "1",
140
132
  label: "option one"
@@ -145,10 +137,8 @@ const WithCustomOptionsAndOnChange = args => /*#__PURE__*/_react.default.createE
145
137
  value: "3",
146
138
  label: "option three"
147
139
  }));
148
-
149
140
  exports.WithCustomOptionsAndOnChange = WithCustomOptionsAndOnChange;
150
141
  WithCustomOptionsAndOnChange.storyName = 'With custom options and onChange';
151
-
152
142
  const WithInvalidOptions = args => /*#__PURE__*/_react.default.createElement(_index2.SingleSelect, args, /*#__PURE__*/_react.default.createElement("div", null, "invalid one"), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
153
143
  value: "1",
154
144
  label: "option one"
@@ -159,9 +149,7 @@ const WithInvalidOptions = args => /*#__PURE__*/_react.default.createElement(_in
159
149
  value: "3",
160
150
  label: "option three"
161
151
  }), null, undefined, false);
162
-
163
152
  exports.WithInvalidOptions = WithInvalidOptions;
164
-
165
153
  const WithInvalidFilterableOptions = args => /*#__PURE__*/_react.default.createElement(_index2.SingleSelect, args, /*#__PURE__*/_react.default.createElement("div", null, "invalid one"), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
166
154
  value: "1",
167
155
  label: "option one"
@@ -172,14 +160,12 @@ const WithInvalidFilterableOptions = args => /*#__PURE__*/_react.default.createE
172
160
  value: "3",
173
161
  label: "option three"
174
162
  }));
175
-
176
163
  exports.WithInvalidFilterableOptions = WithInvalidFilterableOptions;
177
164
  WithInvalidFilterableOptions.args = {
178
165
  filterable: true,
179
166
  noMatchText: 'No match found'
180
167
  };
181
- const WithInitialFocus = EmptyTemplate.bind({});
182
- exports.WithInitialFocus = WithInitialFocus;
168
+ const WithInitialFocus = exports.WithInitialFocus = EmptyTemplate.bind({});
183
169
  WithInitialFocus.args = {
184
170
  initialFocus: true
185
171
  };
@@ -188,40 +174,33 @@ WithInitialFocus.parameters = {
188
174
  disable: true
189
175
  }
190
176
  };
191
- WithInitialFocus.storyName = 'With initialFocus';
192
- const Dense = WithOptionsTemplate.bind({});
193
- exports.Dense = Dense;
177
+ const Dense = exports.Dense = WithOptionsTemplate.bind({});
194
178
  Dense.args = {
195
179
  dense: true,
196
180
  placeholder: 'Dense sized select'
197
181
  };
198
182
  Dense.storyName = 'Dense';
199
- const Empty = EmptyTemplate.bind({});
200
- exports.Empty = Empty;
201
- const EmptyWithEmptyText = EmptyTemplate.bind({});
202
- exports.EmptyWithEmptyText = EmptyWithEmptyText;
183
+ const Empty = exports.Empty = EmptyTemplate.bind({});
184
+ const EmptyWithEmptyText = exports.EmptyWithEmptyText = EmptyTemplate.bind({});
203
185
  EmptyWithEmptyText.args = {
204
186
  empty: 'Custom empty text'
205
187
  };
206
- const EmptyWithEmptyComponent = EmptyTemplate.bind({});
207
- exports.EmptyWithEmptyComponent = EmptyWithEmptyComponent;
188
+ const EmptyWithEmptyComponent = exports.EmptyWithEmptyComponent = EmptyTemplate.bind({});
208
189
  EmptyWithEmptyComponent.args = {
209
190
  empty: /*#__PURE__*/_react.default.createElement("div", {
210
191
  className: "custom-empty"
211
192
  }, "Custom empty component")
212
193
  };
213
- const WithOptionsAndLoading = WithOptionsTemplate.bind({});
214
- exports.WithOptionsAndLoading = WithOptionsAndLoading;
194
+ const WithOptionsAndLoading = exports.WithOptionsAndLoading = WithOptionsTemplate.bind({});
215
195
  WithOptionsAndLoading.args = {
216
196
  loading: true
217
197
  };
218
- const WithOptionsLoadingAndLoadingText = WithOptionsTemplate.bind({});
219
- exports.WithOptionsLoadingAndLoadingText = WithOptionsLoadingAndLoadingText;
220
- WithOptionsLoadingAndLoadingText.args = { ...WithOptionsAndLoading.args,
198
+ const WithOptionsLoadingAndLoadingText = exports.WithOptionsLoadingAndLoadingText = WithOptionsTemplate.bind({});
199
+ WithOptionsLoadingAndLoadingText.args = {
200
+ ...WithOptionsAndLoading.args,
221
201
  loadingText: 'Loading options'
222
202
  };
223
203
  WithOptionsLoadingAndLoadingText.storyName = 'With options, loading and loading text';
224
-
225
204
  const WithMoreThanTenOptions = args => /*#__PURE__*/_react.default.createElement(_index2.SingleSelect, args, /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
226
205
  value: "1",
227
206
  label: "option one"
@@ -259,9 +238,7 @@ const WithMoreThanTenOptions = args => /*#__PURE__*/_react.default.createElement
259
238
  value: "12",
260
239
  label: "option twelve"
261
240
  }));
262
-
263
241
  exports.WithMoreThanTenOptions = WithMoreThanTenOptions;
264
-
265
242
  const WithMoreThanThreeOptionsAndA100PxMaxHeight = args => /*#__PURE__*/_react.default.createElement(_index2.SingleSelect, args, /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
266
243
  value: "1",
267
244
  label: "option one"
@@ -299,35 +276,31 @@ const WithMoreThanThreeOptionsAndA100PxMaxHeight = args => /*#__PURE__*/_react.d
299
276
  value: "12",
300
277
  label: "option twelve"
301
278
  }));
302
-
303
279
  exports.WithMoreThanThreeOptionsAndA100PxMaxHeight = WithMoreThanThreeOptionsAndA100PxMaxHeight;
304
280
  WithMoreThanThreeOptionsAndA100PxMaxHeight.args = {
305
281
  maxHeight: '100px'
306
282
  };
307
283
  WithMoreThanThreeOptionsAndA100PxMaxHeight.storyName = 'With more than three options and a 100px max-height';
308
- const WithOptionsAndDisabled = WithOptionsTemplate.bind({});
309
- exports.WithOptionsAndDisabled = WithOptionsAndDisabled;
284
+ const WithOptionsAndDisabled = exports.WithOptionsAndDisabled = WithOptionsTemplate.bind({});
310
285
  WithOptionsAndDisabled.args = {
311
286
  disabled: true
312
287
  };
313
288
  WithOptionsAndDisabled.storyName = 'With options and disabled';
314
- const WithOptionsASelectionAndDisabled = WithOptionsTemplate.bind({});
315
- exports.WithOptionsASelectionAndDisabled = WithOptionsASelectionAndDisabled;
316
- WithOptionsASelectionAndDisabled.args = { ...WithOptionsAndDisabled.args,
289
+ const WithOptionsASelectionAndDisabled = exports.WithOptionsASelectionAndDisabled = WithOptionsTemplate.bind({});
290
+ WithOptionsASelectionAndDisabled.args = {
291
+ ...WithOptionsAndDisabled.args,
317
292
  ...WithOptionsAndASelection.args
318
293
  };
319
294
  WithOptionsASelectionAndDisabled.storyName = 'With options, a selection and disabled';
320
- const WithPrefix = WithOptionsTemplate.bind({});
321
- exports.WithPrefix = WithPrefix;
295
+ const WithPrefix = exports.WithPrefix = WithOptionsTemplate.bind({});
322
296
  WithPrefix.args = {
323
297
  prefix: 'Prefix text'
324
298
  };
325
- const WithPrefixAndSelection = WithOptionsTemplate.bind({});
326
- exports.WithPrefixAndSelection = WithPrefixAndSelection;
327
- WithPrefixAndSelection.args = { ...WithPrefix.args,
299
+ const WithPrefixAndSelection = exports.WithPrefixAndSelection = WithOptionsTemplate.bind({});
300
+ WithPrefixAndSelection.args = {
301
+ ...WithPrefix.args,
328
302
  ...WithOptionsAndASelection.args
329
303
  };
330
-
331
304
  const WithRTL = args => {
332
305
  // as options are rendered in Portal, the body dir (of the iframe) needs to be set to 'rtl'
333
306
  (0, _react.useEffect)(() => {
@@ -349,24 +322,21 @@ const WithRTL = args => {
349
322
  label: "\u0627\u0644\u062E\u064A\u0627\u0631 3"
350
323
  })));
351
324
  };
352
-
353
325
  exports.WithRTL = WithRTL;
354
326
  WithRTL.args = {
355
327
  prefix: 'نص البادئة',
356
328
  ...WithOptionsAndASelection.args
357
329
  };
358
330
  WithRTL.storyName = 'RTL Text';
359
- const WithPlaceholder = WithOptionsTemplate.bind({});
360
- exports.WithPlaceholder = WithPlaceholder;
331
+ const WithPlaceholder = exports.WithPlaceholder = WithOptionsTemplate.bind({});
361
332
  WithPlaceholder.args = {
362
333
  placeholder: 'Placeholder text'
363
334
  };
364
- const WithPlaceholderAndSelection = WithOptionsTemplate.bind({});
365
- exports.WithPlaceholderAndSelection = WithPlaceholderAndSelection;
366
- WithPlaceholderAndSelection.args = { ...WithPlaceholder.args,
335
+ const WithPlaceholderAndSelection = exports.WithPlaceholderAndSelection = WithOptionsTemplate.bind({});
336
+ WithPlaceholderAndSelection.args = {
337
+ ...WithPlaceholder.args,
367
338
  ...WithOptionsAndASelection.args
368
339
  };
369
-
370
340
  const WithDisabledOptionAndOnChange = args => /*#__PURE__*/_react.default.createElement(_index2.SingleSelect, args, /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
371
341
  value: "1",
372
342
  label: "option one"
@@ -381,21 +351,19 @@ const WithDisabledOptionAndOnChange = args => /*#__PURE__*/_react.default.create
381
351
  label: "disabled option",
382
352
  disabled: true
383
353
  }));
384
-
385
354
  exports.WithDisabledOptionAndOnChange = WithDisabledOptionAndOnChange;
386
355
  WithDisabledOptionAndOnChange.storyName = 'With disabled option and onChange';
387
- const WithClearButtonSelectionAndOnChange = WithOptionsTemplate.bind({});
388
- exports.WithClearButtonSelectionAndOnChange = WithClearButtonSelectionAndOnChange;
389
- WithClearButtonSelectionAndOnChange.args = { ...WithOptionsAndASelection.args,
356
+ const WithClearButtonSelectionAndOnChange = exports.WithClearButtonSelectionAndOnChange = WithOptionsTemplate.bind({});
357
+ WithClearButtonSelectionAndOnChange.args = {
358
+ ...WithOptionsAndASelection.args,
390
359
  clearable: true,
391
360
  clearText: 'Clear'
392
361
  };
393
362
  WithClearButtonSelectionAndOnChange.storyName = 'With clear button, selection and onChange';
394
- const WithFilterField = WithOptionsTemplate.bind({});
395
- exports.WithFilterField = WithFilterField;
396
- WithFilterField.args = { ...WithInvalidFilterableOptions.args
363
+ const WithFilterField = exports.WithFilterField = WithOptionsTemplate.bind({});
364
+ WithFilterField.args = {
365
+ ...WithInvalidFilterableOptions.args
397
366
  };
398
-
399
367
  const DefaultPosition = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index2.SingleSelect, args, /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
400
368
  value: "1",
401
369
  label: "option one"
@@ -435,9 +403,7 @@ const DefaultPosition = args => /*#__PURE__*/_react.default.createElement(_react
435
403
  })), /*#__PURE__*/_react.default.createElement(_style.default, {
436
404
  id: "2006483503"
437
405
  }, ["#root{margin-bottom:2000px;}"]));
438
-
439
406
  exports.DefaultPosition = DefaultPosition;
440
-
441
407
  const FlippedPosition = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index2.SingleSelect, args, /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
442
408
  value: "1",
443
409
  label: "option one"
@@ -477,9 +443,7 @@ const FlippedPosition = args => /*#__PURE__*/_react.default.createElement(_react
477
443
  })), /*#__PURE__*/_react.default.createElement(_style.default, {
478
444
  id: "1520050670"
479
445
  }, ["html,body,#root{position:relative;height:500px;max-height:500px;}", "#root{padding-top:400px !important;}"]));
480
-
481
446
  exports.FlippedPosition = FlippedPosition;
482
-
483
447
  const ShiftedIntoView = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index2.SingleSelect, args, /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
484
448
  value: "1",
485
449
  label: "option one"
@@ -519,5 +483,4 @@ const ShiftedIntoView = args => /*#__PURE__*/_react.default.createElement(_react
519
483
  })), /*#__PURE__*/_react.default.createElement(_style.default, {
520
484
  id: "1828862170"
521
485
  }, ["html,body,#root{position:relative;height:300px !important;max-height:300px;}", "#root{padding-top:130px !important;}"]));
522
-
523
486
  exports.ShiftedIntoView = ShiftedIntoView;
@@ -1,13 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  var _react = require("@testing-library/react");
4
-
5
4
  var _react2 = _interopRequireDefault(require("react"));
6
-
7
5
  var _singleSelectField = require("../single-select-field.js");
8
-
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
-
6
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
7
  describe('<SingleSelect />', () => {
12
8
  it('should call the onKeyDown callback when provided', () => {
13
9
  const onKeyDown = jest.fn();
@@ -16,13 +12,11 @@ describe('<SingleSelect />', () => {
16
12
  placeholder: "placeholder",
17
13
  onKeyDown: onKeyDown
18
14
  }));
19
-
20
15
  _react.fireEvent.keyDown(_react.screen.getByTestId('dhis2-uicore-singleselect-placeholder'), {
21
16
  key: 'Enter',
22
17
  code: 'Enter',
23
18
  charCode: 13
24
19
  });
25
-
26
20
  expect(onKeyDown).toHaveBeenCalledWith({
27
21
  selected: ''
28
22
  }, expect.objectContaining({}));
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
4
-
5
4
  (0, _cypressCucumberPreprocessor.Given)('a SingleSelectField with help text is rendered', () => {
6
5
  cy.visitStory('SingleSelectField', 'With help text');
7
6
  });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
4
-
5
4
  (0, _cypressCucumberPreprocessor.Given)('a SingleSelectField with a label is rendered', () => {
6
5
  cy.visitStory('SingleSelectField', 'With label');
7
6
  });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
4
-
5
4
  (0, _cypressCucumberPreprocessor.Given)('a SingleSelectField with validation text is rendered', () => {
6
5
  cy.visitStory('SingleSelectField', 'With validation text');
7
6
  });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
4
-
5
4
  (0, _cypressCucumberPreprocessor.Given)('a SingleSelectField with label and a required flag is rendered', () => {
6
5
  cy.visitStory('SingleSelectField', 'With label and required status');
7
6
  });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
4
-
5
4
  (0, _cypressCucumberPreprocessor.Given)('a clearable SingleSelectField with selected option is rendered', () => {
6
5
  cy.visitStory('SingleSelectField', 'With clearable and selected option');
7
6
  });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
4
-
5
4
  (0, _cypressCucumberPreprocessor.Given)('an empty SingleSelectField is rendered', () => {
6
5
  cy.visitStory('SingleSelectField', 'Without options');
7
6
  });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
4
-
5
4
  (0, _cypressCucumberPreprocessor.Given)('a filterable SingleSelectField is rendered', () => {
6
5
  cy.visitStory('SingleSelectField', 'With filterable');
7
6
  });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
4
-
5
4
  (0, _cypressCucumberPreprocessor.Given)('a filterable SingleSelectField is rendered', () => {
6
5
  cy.visitStory('SingleSelectField', 'With filterable');
7
6
  });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
4
-
5
4
  (0, _cypressCucumberPreprocessor.Given)('a loading SingleSelectField is rendered', () => {
6
5
  cy.visitStory('SingleSelectField', 'With loading');
7
6
  });
@@ -9,5 +9,4 @@ Object.defineProperty(exports, "SingleSelectField", {
9
9
  return _singleSelectField.SingleSelectField;
10
10
  }
11
11
  });
12
-
13
12
  var _singleSelectField = require("./single-select-field.js");