@dhis2-ui/select 9.10.3 → 9.11.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.WithoutOptions = exports.WithValidationText = exports.WithLoading = exports.WithLabelAndRequiredStatus = exports.WithLabel = exports.WithHelpText = exports.WithFilterable = exports.WithClearableAndSelectedOption = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _index = require("../index.js");
9
+ var _index2 = require("./index.js");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ var _default = exports.default = {
12
+ title: 'MultiSelectField'
13
+ };
14
+ const WithLabel = () => /*#__PURE__*/_react.default.createElement(_index2.MultiSelectField, {
15
+ label: "The label"
16
+ }, /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
17
+ value: "1",
18
+ label: "one"
19
+ }), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
20
+ value: "2",
21
+ label: "two"
22
+ }), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
23
+ value: "3",
24
+ label: "three"
25
+ }));
26
+ exports.WithLabel = WithLabel;
27
+ const WithHelpText = () => /*#__PURE__*/_react.default.createElement(_index2.MultiSelectField, {
28
+ helpText: "The help text"
29
+ }, /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
30
+ value: "1",
31
+ label: "one"
32
+ }), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
33
+ value: "2",
34
+ label: "two"
35
+ }), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
36
+ value: "3",
37
+ label: "three"
38
+ }));
39
+ exports.WithHelpText = WithHelpText;
40
+ const WithValidationText = () => /*#__PURE__*/_react.default.createElement(_index2.MultiSelectField, {
41
+ validationText: "The validation text"
42
+ }, /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
43
+ value: "1",
44
+ label: "one"
45
+ }), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
46
+ value: "2",
47
+ label: "two"
48
+ }), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
49
+ value: "3",
50
+ label: "three"
51
+ }));
52
+ exports.WithValidationText = WithValidationText;
53
+ const WithLabelAndRequiredStatus = () => /*#__PURE__*/_react.default.createElement(_index2.MultiSelectField, {
54
+ label: "The label",
55
+ required: true
56
+ }, /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
57
+ value: "1",
58
+ label: "one"
59
+ }), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
60
+ value: "2",
61
+ label: "two"
62
+ }), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
63
+ value: "3",
64
+ label: "three"
65
+ }));
66
+ exports.WithLabelAndRequiredStatus = WithLabelAndRequiredStatus;
67
+ const WithClearableAndSelectedOption = () => /*#__PURE__*/_react.default.createElement(_index2.MultiSelectField, {
68
+ selected: ['1'],
69
+ clearable: true
70
+ }, /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
71
+ key: "1",
72
+ value: "1",
73
+ label: "One"
74
+ }));
75
+ exports.WithClearableAndSelectedOption = WithClearableAndSelectedOption;
76
+ const WithFilterable = () => /*#__PURE__*/_react.default.createElement(_index2.MultiSelectField, {
77
+ filterable: true
78
+ }, /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
79
+ key: "1",
80
+ value: "1",
81
+ label: "One"
82
+ }));
83
+ exports.WithFilterable = WithFilterable;
84
+ const WithLoading = () => /*#__PURE__*/_react.default.createElement(_index2.MultiSelectField, {
85
+ loading: true
86
+ });
87
+ exports.WithLoading = WithLoading;
88
+ const WithoutOptions = () => /*#__PURE__*/_react.default.createElement(_index2.MultiSelectField, null);
89
+ exports.WithoutOptions = WithoutOptions;
@@ -4,32 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.MultiSelectField = void 0;
7
-
7
+ var _uiConstants = require("@dhis2/ui-constants");
8
8
  var _box = require("@dhis2-ui/box");
9
-
10
9
  var _field = require("@dhis2-ui/field");
11
-
12
- var _uiConstants = require("@dhis2/ui-constants");
13
-
14
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
15
-
16
11
  var _react = _interopRequireDefault(require("react"));
17
-
18
- var _index = require("../index.js");
19
-
20
- var _index2 = _interopRequireDefault(require("../locales/index.js"));
21
-
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
-
12
+ var _index = _interopRequireDefault(require("../locales/index.js"));
13
+ var _index2 = require("../multi-select/index.js");
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
24
15
  // TODO: translate
25
16
  const translate = (prop, interpolationObject) => {
26
17
  if (typeof prop === 'function') {
27
18
  return prop(interpolationObject);
28
19
  }
29
-
30
20
  return prop;
31
21
  };
32
-
33
22
  class MultiSelectField extends _react.default.Component {
34
23
  render() {
35
24
  const {
@@ -80,7 +69,7 @@ class MultiSelectField extends _react.default.Component {
80
69
  }, /*#__PURE__*/_react.default.createElement(_box.Box, {
81
70
  width: inputWidth,
82
71
  minWidth: "100px"
83
- }, /*#__PURE__*/_react.default.createElement(_index.MultiSelect, {
72
+ }, /*#__PURE__*/_react.default.createElement(_index2.MultiSelect, {
84
73
  selected: selected,
85
74
  tabIndex: tabIndex,
86
75
  maxHeight: maxHeight,
@@ -107,107 +96,77 @@ class MultiSelectField extends _react.default.Component {
107
96
  dense: dense
108
97
  }, children)));
109
98
  }
110
-
111
99
  }
112
-
113
100
  exports.MultiSelectField = MultiSelectField;
114
101
  MultiSelectField.defaultProps = {
115
102
  selected: [],
116
103
  dataTest: 'dhis2-uiwidgets-multiselectfield',
117
- clearText: () => _index2.default.t('Clear'),
118
- empty: () => _index2.default.t('No data found'),
119
- filterPlaceholder: () => _index2.default.t('Type to filter options'),
120
- loadingText: () => _index2.default.t('Loading options'),
121
- noMatchText: () => _index2.default.t('No options found')
104
+ clearText: () => _index.default.t('Clear'),
105
+ empty: () => _index.default.t('No data found'),
106
+ filterPlaceholder: () => _index.default.t('Type to filter options'),
107
+ loadingText: () => _index.default.t('Loading options'),
108
+ noMatchText: () => _index.default.t('No options found')
122
109
  };
123
110
  MultiSelectField.propTypes = {
124
111
  /** Should be `MultiSelectOption` components */
125
112
  children: _propTypes.default.node,
126
113
  className: _propTypes.default.string,
127
-
128
114
  /** Label for the button that clears selections */
129
115
  clearText: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]),
130
-
131
116
  /** Adds a button to the MultiSelect that clears selections when pressed */
132
117
  clearable: _propTypes.default.bool,
133
118
  dataTest: _propTypes.default.string,
134
-
135
119
  /** Makes the MultiSelect smaller */
136
120
  dense: _propTypes.default.bool,
137
-
138
121
  /** Disables the MultiSelect */
139
122
  disabled: _propTypes.default.bool,
140
-
141
123
  /** Text to display when there are no options */
142
124
  empty: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
143
-
144
125
  /** Adds 'error' appearance for validation feedback. Mutually exclusive with 'valid' and 'warning' props */
145
126
  error: _uiConstants.sharedPropTypes.statusPropType,
146
-
147
127
  /** Placeholder text to show in the filter field when it is empty */
148
128
  filterPlaceholder: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
149
-
150
129
  /** Adds a field to filter options */
151
130
  filterable: _propTypes.default.bool,
152
-
153
131
  /** Useful guiding text to display below the MultiSelect */
154
132
  helpText: _propTypes.default.string,
155
-
156
133
  /** Grabs initial focus on the page */
157
134
  initialFocus: _propTypes.default.bool,
158
-
159
135
  /** Constrains the height of the input */
160
136
  inputMaxHeight: _propTypes.default.string,
161
-
162
137
  /** Sets the width of the input. Can be any valid CSS measurement */
163
138
  inputWidth: _propTypes.default.string,
164
-
165
139
  /** Text for the label above the MultiSelect */
166
140
  label: _propTypes.default.string,
167
-
168
141
  /** Applies a loading appearance to the dropdown options */
169
142
  loading: _propTypes.default.bool,
170
-
171
143
  /** Text to display when `loading` is true */
172
144
  loadingText: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]),
173
-
174
145
  /** Constrains height of the MultiSelect */
175
146
  maxHeight: _propTypes.default.string,
176
-
177
147
  /** Text to display when there are no filter results */
178
148
  noMatchText: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]),
179
-
180
149
  /** Placeholder text when the MultiSelect is empty */
181
150
  placeholder: _propTypes.default.string,
182
-
183
151
  /** Leading text to prefix selections */
184
152
  prefix: _propTypes.default.string,
185
-
186
153
  /** Indicates that a selection is required */
187
154
  required: _propTypes.default.bool,
188
-
189
155
  /** Selected items in the MultiSelect (each string should refer to the item's `value` attribute) */
190
156
  selected: _propTypes.default.arrayOf(_propTypes.default.string),
191
157
  tabIndex: _propTypes.default.string,
192
-
193
158
  /** Adds 'valid' appearance for validation feedback. Mutually exclusive with 'error' and 'warning' props */
194
159
  valid: _uiConstants.sharedPropTypes.statusPropType,
195
-
196
160
  /** Text to provide form validation feedback. Receives styles according to validation status */
197
161
  validationText: _propTypes.default.string,
198
-
199
162
  /** Adds 'warning' appearance for validation feedback. Mutually exclusive with 'valid' and 'error' props */
200
163
  warning: _uiConstants.sharedPropTypes.statusPropType,
201
-
202
164
  /** Called with signature `({ selected: [String] }, event)` */
203
165
  onBlur: _propTypes.default.func,
204
-
205
166
  /** Called with signature `({ selected: [String] }, event)` */
206
167
  onChange: _propTypes.default.func,
207
-
208
168
  /** Called with signature `({ selected: [String] }, event)` */
209
169
  onFocus: _propTypes.default.func,
210
-
211
170
  /** Called with signature `({ selected: [String] }, event)` */
212
171
  onKeyDown: _propTypes.default.func
213
172
  };
@@ -4,21 +4,23 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
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
-
8
7
  var _uiConstants = require("@dhis2/ui-constants");
9
-
10
8
  var _react = _interopRequireDefault(require("react"));
11
-
12
9
  var _index = require("../index.js");
13
-
14
10
  var _index2 = require("./index.js");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ const description = `
13
+ \`MultiSelectField\` is a wrapper around a \`MultiSelect\` component that adds a label, help text, validation text, and other features.
15
14
 
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ 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).
17
16
 
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";
19
-
20
- const onChange = selected => alert("Selected changed to: ".concat(JSON.stringify(selected, null, 2)));
17
+ \`\`\`js
18
+ import { MultiSelectField, MultiSelectOption } from '@dhis2/ui'
19
+ \`\`\`
21
20
 
21
+ _**Note**: The dropdowns in some of the following stories won't appear correctly on this page. View these demos in the 'Canvas' tab._
22
+ `;
23
+ const onChange = selected => alert(`Selected changed to: ${JSON.stringify(selected, null, 2)}`);
22
24
  const options = [/*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
23
25
  key: "1",
24
26
  value: "1",
@@ -60,7 +62,7 @@ const options = [/*#__PURE__*/_react.default.createElement(_index.MultiSelectOpt
60
62
  value: "10",
61
63
  label: "ten"
62
64
  })];
63
- var _default = {
65
+ var _default = exports.default = {
64
66
  title: 'Multi Select Field',
65
67
  component: _index2.MultiSelectField,
66
68
  subcomponents: {
@@ -74,7 +76,8 @@ var _default = {
74
76
  }
75
77
  },
76
78
  // default args for stories
77
- args: { // Fix default prop issues - causes 'i18n is not defined' error
79
+ args: {
80
+ // Fix default prop issues - causes 'i18n is not defined' error
78
81
  ..._index2.MultiSelectField.defaultProps,
79
82
  label: 'Default label',
80
83
  selected: ['1'],
@@ -82,70 +85,62 @@ var _default = {
82
85
  onChange: onChange
83
86
  },
84
87
  argTypes: {
85
- valid: { ..._uiConstants.sharedPropTypes.statusArgType
88
+ valid: {
89
+ ..._uiConstants.sharedPropTypes.statusArgType
86
90
  },
87
- warning: { ..._uiConstants.sharedPropTypes.statusArgType
91
+ warning: {
92
+ ..._uiConstants.sharedPropTypes.statusArgType
88
93
  },
89
- error: { ..._uiConstants.sharedPropTypes.statusArgType
94
+ error: {
95
+ ..._uiConstants.sharedPropTypes.statusArgType
90
96
  }
91
97
  }
92
98
  };
93
- exports.default = _default;
94
-
95
99
  const Template = args => /*#__PURE__*/_react.default.createElement(_index2.MultiSelectField, args);
96
-
97
- const Default = Template.bind({});
98
- exports.Default = Default;
99
- const WithHelpText = Template.bind({});
100
- exports.WithHelpText = WithHelpText;
100
+ const Default = exports.Default = Template.bind({});
101
+ const WithHelpText = exports.WithHelpText = Template.bind({});
101
102
  WithHelpText.args = {
102
103
  helpText: 'Helpful text.'
103
104
  };
104
105
  WithHelpText.parameters = {
105
106
  docs: {
106
107
  description: {
107
- story: "_**Note**: The dropdowns in the following stories won't appear correctly on this page. View these demos in the 'Canvas' tab._"
108
+ story: `_**Note**: The dropdowns in the following stories won't appear correctly on this page. View these demos in the 'Canvas' tab._`
108
109
  }
109
110
  }
110
111
  };
111
- const StatusValid = Template.bind({});
112
- exports.StatusValid = StatusValid;
112
+ const StatusValid = exports.StatusValid = Template.bind({});
113
113
  StatusValid.args = {
114
114
  valid: true,
115
115
  validationText: 'Totally valid!',
116
116
  ...WithHelpText.args
117
117
  };
118
118
  StatusValid.storyName = 'Status: Valid';
119
- const StatusWarning = Template.bind({});
120
- exports.StatusWarning = StatusWarning;
119
+ const StatusWarning = exports.StatusWarning = Template.bind({});
121
120
  StatusWarning.args = {
122
121
  warning: true,
123
122
  validationText: 'Hm, not quite, I warn thee!',
124
123
  ...WithHelpText.args
125
124
  };
126
125
  StatusWarning.storyName = 'Status: Warning';
127
- const StatusError = Template.bind({});
128
- exports.StatusError = StatusError;
126
+ const StatusError = exports.StatusError = Template.bind({});
129
127
  StatusError.args = {
130
128
  error: true,
131
129
  validationText: 'That value is wrong. Sorry!',
132
130
  ...WithHelpText.args
133
131
  };
134
132
  StatusError.storyName = 'Status: Error';
135
- const Required = Template.bind({});
136
- exports.Required = Required;
133
+ const Required = exports.Required = Template.bind({});
137
134
  Required.args = {
138
135
  required: true
139
136
  };
140
- const InputWidth = Template.bind({});
141
- exports.InputWidth = InputWidth;
137
+ const InputWidth = exports.InputWidth = Template.bind({});
142
138
  InputWidth.args = {
143
139
  inputWidth: '200px',
144
140
  label: 'A very long label indeed, well at least longer than the input field to show how it looks and works and stuff',
145
141
  required: true
146
142
  };
147
- const DefaultClearText = Template.bind({});
148
- exports.DefaultClearText = DefaultClearText;
143
+ const DefaultClearText = exports.DefaultClearText = Template.bind({});
149
144
  DefaultClearText.args = {
150
145
  clearable: true,
151
146
  children: /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
@@ -156,23 +151,20 @@ DefaultClearText.args = {
156
151
  label: null
157
152
  };
158
153
  DefaultClearText.storyName = 'Default: clearText';
159
- const DefaultEmpty = Template.bind({});
160
- exports.DefaultEmpty = DefaultEmpty;
154
+ const DefaultEmpty = exports.DefaultEmpty = Template.bind({});
161
155
  DefaultEmpty.args = {
162
156
  children: null,
163
157
  selected: [],
164
158
  label: null
165
159
  };
166
160
  DefaultEmpty.storyName = 'Default: empty';
167
- const DefaultFilterPlaceholderAndNoMatchText = Template.bind({});
168
- exports.DefaultFilterPlaceholderAndNoMatchText = DefaultFilterPlaceholderAndNoMatchText;
161
+ const DefaultFilterPlaceholderAndNoMatchText = exports.DefaultFilterPlaceholderAndNoMatchText = Template.bind({});
169
162
  DefaultFilterPlaceholderAndNoMatchText.args = {
170
163
  filterable: true,
171
164
  ...DefaultEmpty.args
172
165
  };
173
166
  DefaultFilterPlaceholderAndNoMatchText.storyName = 'Default: filterPlaceholder and noMatchText';
174
- const DefaultLoadingText = Template.bind({});
175
- exports.DefaultLoadingText = DefaultLoadingText;
167
+ const DefaultLoadingText = exports.DefaultLoadingText = Template.bind({});
176
168
  DefaultLoadingText.args = {
177
169
  loading: true,
178
170
  ...DefaultEmpty.args
@@ -9,5 +9,4 @@ Object.defineProperty(exports, "MultiSelectOption", {
9
9
  return _multiSelectOption.MultiSelectOption;
10
10
  }
11
11
  });
12
-
13
12
  var _multiSelectOption = require("./multi-select-option.js");
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.MultiSelectOption = void 0;
7
-
8
7
  var _style = _interopRequireDefault(require("styled-jsx/style"));
9
-
10
- var _checkbox = require("@dhis2-ui/checkbox");
11
-
12
8
  var _uiConstants = require("@dhis2/ui-constants");
13
-
9
+ var _checkbox = require("@dhis2-ui/checkbox");
14
10
  var _classnames = _interopRequireDefault(require("classnames"));
15
-
16
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
17
-
18
12
  var _react = _interopRequireDefault(require("react"));
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
14
  // Padding has to be set on the label, so that the entire area is clickable
23
15
  const {
24
16
  styles,
@@ -26,10 +18,9 @@ const {
26
18
  } = {
27
19
  styles: /*#__PURE__*/_react.default.createElement(_style.default, {
28
20
  id: "2013783366"
29
- }, [".jsx-2013783366{padding:".concat(_uiConstants.spacers.dp8, " ").concat(_uiConstants.spacers.dp12, ";}")]),
21
+ }, [`.jsx-2013783366{padding:${_uiConstants.spacers.dp8} ${_uiConstants.spacers.dp12};}`]),
30
22
  className: "jsx-2013783366"
31
23
  };
32
-
33
24
  const MultiSelectOption = _ref => {
34
25
  let {
35
26
  label,
@@ -58,9 +49,8 @@ const MultiSelectOption = _ref => {
58
49
  }), styles, /*#__PURE__*/_react.default.createElement(_style.default, {
59
50
  id: "3813980210",
60
51
  dynamic: [_uiConstants.colors.grey200]
61
- }, ["div.__jsx-style-dynamic-selector:hover{background-color:".concat(_uiConstants.colors.grey200, ";}"), "div.disabled.__jsx-style-dynamic-selector:hover{background-color:initial;}"]));
52
+ }, [`div.__jsx-style-dynamic-selector:hover{background-color:${_uiConstants.colors.grey200};}`, "div.disabled.__jsx-style-dynamic-selector:hover{background-color:initial;}"]));
62
53
  };
63
-
64
54
  exports.MultiSelectOption = MultiSelectOption;
65
55
  MultiSelectOption.defaultProps = {
66
56
  dataTest: 'dhis2-uicore-multiselectoption'
@@ -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 _select = require("../select.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('<Select />', () => {
12
8
  it('should call the onKeyDown callback when provided', () => {
13
9
  const onKeyDown = jest.fn();
@@ -19,13 +15,11 @@ describe('<Select />', () => {
19
15
  selected: "",
20
16
  onKeyDown: onKeyDown
21
17
  }));
22
-
23
18
  _react.fireEvent.keyDown(_react.screen.getByRole('textbox'), {
24
19
  key: 'Enter',
25
20
  code: 'Enter',
26
21
  charCode: 13
27
22
  });
28
-
29
23
  expect(onKeyDown).toHaveBeenCalledWith({
30
24
  selected: ''
31
25
  }, expect.objectContaining({}));
@@ -4,39 +4,32 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.debounce = void 0;
7
-
8
7
  var _this = void 0;
9
-
10
8
  /**
11
9
  * Returns a function, that, as long as it continues to be invoked, will not be triggered. The
12
10
  * function will be called after it stops being called for N milliseconds. If `immediate` is
13
11
  * passed, trigger the function on the leading edge, instead of the trailing.
14
12
  */
13
+
15
14
  const debounce = (func, wait, immediate) => {
16
15
  let timeout;
17
16
  return function () {
18
17
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
19
18
  args[_key] = arguments[_key];
20
19
  }
21
-
22
20
  const context = _this;
23
-
24
21
  const later = () => {
25
22
  timeout = null;
26
-
27
23
  if (!immediate) {
28
24
  func.apply(context, args);
29
25
  }
30
26
  };
31
-
32
27
  const callNow = immediate && !timeout;
33
28
  clearTimeout(timeout);
34
29
  timeout = setTimeout(later, wait);
35
-
36
30
  if (callNow) {
37
31
  func.apply(context, args);
38
32
  }
39
33
  };
40
34
  };
41
-
42
35
  exports.debounce = debounce;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _debounce = require("./debounce.js");
4
-
5
4
  beforeEach(() => {
6
5
  jest.useFakeTimers();
7
6
  });
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Empty = 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 = _interopRequireDefault(require("react"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
12
  const Empty = _ref => {
19
13
  let {
20
14
  message,
@@ -27,9 +21,8 @@ const Empty = _ref => {
27
21
  }, message, /*#__PURE__*/_react.default.createElement(_style.default, {
28
22
  id: "3788156646",
29
23
  dynamic: [_uiConstants.colors.grey700, _uiConstants.theme.fonts, _uiConstants.spacers.dp8, _uiConstants.spacers.dp24]
30
- }, ["div.__jsx-style-dynamic-selector{color:".concat(_uiConstants.colors.grey700, ";font-family:").concat(_uiConstants.theme.fonts, ";font-size:13px;line-height:16px;padding-block:").concat(_uiConstants.spacers.dp8, ";padding-inline:").concat(_uiConstants.spacers.dp24, ";text-align:center;}")]));
24
+ }, [`div.__jsx-style-dynamic-selector{color:${_uiConstants.colors.grey700};font-family:${_uiConstants.theme.fonts};font-size:13px;line-height:16px;padding-block:${_uiConstants.spacers.dp8};padding-inline:${_uiConstants.spacers.dp24};text-align:center;}`]));
31
25
  };
32
-
33
26
  exports.Empty = Empty;
34
27
  Empty.propTypes = {
35
28
  dataTest: _propTypes.default.string.isRequired,
@@ -4,19 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.FilterInput = void 0;
7
-
8
7
  var _style = _interopRequireDefault(require("styled-jsx/style"));
9
-
10
- var _input = require("@dhis2-ui/input");
11
-
12
8
  var _uiConstants = require("@dhis2/ui-constants");
13
-
9
+ var _input = require("@dhis2-ui/input");
14
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
15
-
16
11
  var _react = _interopRequireDefault(require("react"));
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
13
  const FilterInput = _ref => {
21
14
  let {
22
15
  value,
@@ -39,9 +32,8 @@ const FilterInput = _ref => {
39
32
  }), /*#__PURE__*/_react.default.createElement(_style.default, {
40
33
  id: "730881408",
41
34
  dynamic: [_uiConstants.colors.white, _uiConstants.spacers.dp8, _uiConstants.spacers.dp8, _uiConstants.spacers.dp4, _uiConstants.spacers.dp8]
42
- }, ["div.__jsx-style-dynamic-selector{position:-webkit-sticky;position:sticky;-webkit-inset-block-start:0;-ms-intb-rlock-start:0;inset-block-start:0;background:".concat(_uiConstants.colors.white, ";padding-block-start:").concat(_uiConstants.spacers.dp8, ";padding-inline-end:").concat(_uiConstants.spacers.dp8, ";padding-block-end:").concat(_uiConstants.spacers.dp4, ";padding-inline-start:").concat(_uiConstants.spacers.dp8, ";z-index:1;}")]));
35
+ }, [`div.__jsx-style-dynamic-selector{position:-webkit-sticky;position:sticky;-webkit-inset-block-start:0;-ms-intb-rlock-start:0;inset-block-start:0;background:${_uiConstants.colors.white};padding-block-start:${_uiConstants.spacers.dp8};padding-inline-end:${_uiConstants.spacers.dp8};padding-block-end:${_uiConstants.spacers.dp4};padding-inline-start:${_uiConstants.spacers.dp8};z-index:1;}`]));
43
36
  };
44
-
45
37
  exports.FilterInput = FilterInput;
46
38
  FilterInput.propTypes = {
47
39
  dataTest: _propTypes.default.string.isRequired,