@dhis2-ui/select 9.11.0 → 9.11.1-beta.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 (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,17 +4,24 @@ import PropTypes from 'prop-types';
4
4
  import React, { useEffect } from 'react';
5
5
  import { SingleSelectOption } from '../index.js';
6
6
  import { SingleSelect } from './index.js';
7
- 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";
7
+ const description = `
8
+ 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.
8
9
 
10
+ Learn more about using Selects at [Design System: Select](https://github.com/dhis2/design-system/blob/master/molecules/select.md).
11
+
12
+ \`\`\`js
13
+ import { SingleSelect, SingleSelectOption } from '@dhis2/ui'
14
+ \`\`\`
15
+
16
+ _**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._
17
+ `;
9
18
  const eventHandler = handlerName => (payload, event) => {
10
- console.log("".concat(handlerName, " payload"), payload);
11
- console.log("".concat(handlerName, " event"), event);
19
+ console.log(`${handlerName} payload`, payload);
20
+ console.log(`${handlerName} event`, event);
12
21
  };
13
-
14
22
  const onChange = eventHandler('onChange');
15
23
  const onFocus = eventHandler('onFocus');
16
24
  const onBlur = eventHandler('onBlur');
17
-
18
25
  const CustomSingleSelectOption = _ref => {
19
26
  let {
20
27
  label,
@@ -24,7 +31,6 @@ const CustomSingleSelectOption = _ref => {
24
31
  onClick: e => onClick({}, e)
25
32
  }, label);
26
33
  };
27
-
28
34
  CustomSingleSelectOption.propTypes = {
29
35
  label: PropTypes.string,
30
36
  onClick: PropTypes.func
@@ -61,19 +67,23 @@ export default {
61
67
  onChange
62
68
  },
63
69
  argTypes: {
64
- valid: { ...sharedPropTypes.statusArgType
70
+ valid: {
71
+ ...sharedPropTypes.statusArgType
65
72
  },
66
- warning: { ...sharedPropTypes.statusArgType
73
+ warning: {
74
+ ...sharedPropTypes.statusArgType
67
75
  },
68
- error: { ...sharedPropTypes.statusArgType
76
+ error: {
77
+ ...sharedPropTypes.statusArgType
69
78
  },
70
- clearText: { ...requiredIfArgType
79
+ clearText: {
80
+ ...requiredIfArgType
71
81
  },
72
- noMatchText: { ...requiredIfArgType
82
+ noMatchText: {
83
+ ...requiredIfArgType
73
84
  }
74
85
  }
75
86
  };
76
-
77
87
  const WithOptionsTemplate = args => /*#__PURE__*/React.createElement(SingleSelect, args, /*#__PURE__*/React.createElement(SingleSelectOption, {
78
88
  value: "1",
79
89
  label: "option one"
@@ -84,16 +94,14 @@ const WithOptionsTemplate = args => /*#__PURE__*/React.createElement(SingleSelec
84
94
  value: "3",
85
95
  label: "option three"
86
96
  }));
87
-
88
97
  const EmptyTemplate = args => /*#__PURE__*/React.createElement(SingleSelect, args);
89
-
90
98
  export const WithOptionsAndOnChange = WithOptionsTemplate.bind({});
91
99
  WithOptionsAndOnChange.storyName = 'With options and onChange';
92
100
  export const WithOptionsAndASelection = WithOptionsTemplate.bind({});
93
101
  WithOptionsAndASelection.args = {
94
102
  selected: '1'
95
- }; // Enable this story as the primary for docs as a representative example
96
-
103
+ };
104
+ // Enable this story as the primary for docs as a representative example
97
105
  WithOptionsAndASelection.parameters = {
98
106
  docs: {
99
107
  disable: false
@@ -104,7 +112,7 @@ export const WithOnFocus = WithOptionsTemplate.bind({});
104
112
  WithOnFocus.args = {
105
113
  onFocus
106
114
  };
107
- WithOnFocus.storyName = 'With onFocus';
115
+ WithOnFocus.storyName = 'With on focus';
108
116
  export const WithOnBlur = WithOptionsTemplate.bind({});
109
117
  WithOnBlur.args = {
110
118
  onBlur
@@ -154,7 +162,6 @@ WithInitialFocus.parameters = {
154
162
  disable: true
155
163
  }
156
164
  };
157
- WithInitialFocus.storyName = 'With initialFocus';
158
165
  export const Dense = WithOptionsTemplate.bind({});
159
166
  Dense.args = {
160
167
  dense: true,
@@ -177,7 +184,8 @@ WithOptionsAndLoading.args = {
177
184
  loading: true
178
185
  };
179
186
  export const WithOptionsLoadingAndLoadingText = WithOptionsTemplate.bind({});
180
- WithOptionsLoadingAndLoadingText.args = { ...WithOptionsAndLoading.args,
187
+ WithOptionsLoadingAndLoadingText.args = {
188
+ ...WithOptionsAndLoading.args,
181
189
  loadingText: 'Loading options'
182
190
  };
183
191
  WithOptionsLoadingAndLoadingText.storyName = 'With options, loading and loading text';
@@ -265,7 +273,8 @@ WithOptionsAndDisabled.args = {
265
273
  };
266
274
  WithOptionsAndDisabled.storyName = 'With options and disabled';
267
275
  export const WithOptionsASelectionAndDisabled = WithOptionsTemplate.bind({});
268
- WithOptionsASelectionAndDisabled.args = { ...WithOptionsAndDisabled.args,
276
+ WithOptionsASelectionAndDisabled.args = {
277
+ ...WithOptionsAndDisabled.args,
269
278
  ...WithOptionsAndASelection.args
270
279
  };
271
280
  WithOptionsASelectionAndDisabled.storyName = 'With options, a selection and disabled';
@@ -274,7 +283,8 @@ WithPrefix.args = {
274
283
  prefix: 'Prefix text'
275
284
  };
276
285
  export const WithPrefixAndSelection = WithOptionsTemplate.bind({});
277
- WithPrefixAndSelection.args = { ...WithPrefix.args,
286
+ WithPrefixAndSelection.args = {
287
+ ...WithPrefix.args,
278
288
  ...WithOptionsAndASelection.args
279
289
  };
280
290
  export const WithRTL = args => {
@@ -308,7 +318,8 @@ WithPlaceholder.args = {
308
318
  placeholder: 'Placeholder text'
309
319
  };
310
320
  export const WithPlaceholderAndSelection = WithOptionsTemplate.bind({});
311
- WithPlaceholderAndSelection.args = { ...WithPlaceholder.args,
321
+ WithPlaceholderAndSelection.args = {
322
+ ...WithPlaceholder.args,
312
323
  ...WithOptionsAndASelection.args
313
324
  };
314
325
  export const WithDisabledOptionAndOnChange = args => /*#__PURE__*/React.createElement(SingleSelect, args, /*#__PURE__*/React.createElement(SingleSelectOption, {
@@ -327,13 +338,15 @@ export const WithDisabledOptionAndOnChange = args => /*#__PURE__*/React.createEl
327
338
  }));
328
339
  WithDisabledOptionAndOnChange.storyName = 'With disabled option and onChange';
329
340
  export const WithClearButtonSelectionAndOnChange = WithOptionsTemplate.bind({});
330
- WithClearButtonSelectionAndOnChange.args = { ...WithOptionsAndASelection.args,
341
+ WithClearButtonSelectionAndOnChange.args = {
342
+ ...WithOptionsAndASelection.args,
331
343
  clearable: true,
332
344
  clearText: 'Clear'
333
345
  };
334
346
  WithClearButtonSelectionAndOnChange.storyName = 'With clear button, selection and onChange';
335
347
  export const WithFilterField = WithOptionsTemplate.bind({});
336
- WithFilterField.args = { ...WithInvalidFilterableOptions.args
348
+ WithFilterField.args = {
349
+ ...WithInvalidFilterableOptions.args
337
350
  };
338
351
  export const DefaultPosition = args => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SingleSelect, args, /*#__PURE__*/React.createElement(SingleSelectOption, {
339
352
  value: "1",
@@ -1,8 +1,10 @@
1
- import { storiesOf } from '@storybook/react';
2
1
  import React from 'react';
3
2
  import { SingleSelectOption } from '../index.js';
4
3
  import { SingleSelectField } from './index.js';
5
- storiesOf('SingleSelectField', module).add('With label', () => /*#__PURE__*/React.createElement(SingleSelectField, {
4
+ export default {
5
+ title: 'SingleSelectField'
6
+ };
7
+ export const WithLabel = () => /*#__PURE__*/React.createElement(SingleSelectField, {
6
8
  label: "The label"
7
9
  }, /*#__PURE__*/React.createElement(SingleSelectOption, {
8
10
  value: "1",
@@ -13,7 +15,8 @@ storiesOf('SingleSelectField', module).add('With label', () => /*#__PURE__*/Reac
13
15
  }), /*#__PURE__*/React.createElement(SingleSelectOption, {
14
16
  value: "3",
15
17
  label: "three"
16
- }))).add('With help text', () => /*#__PURE__*/React.createElement(SingleSelectField, {
18
+ }));
19
+ export const WithHelpText = () => /*#__PURE__*/React.createElement(SingleSelectField, {
17
20
  helpText: "The help text"
18
21
  }, /*#__PURE__*/React.createElement(SingleSelectOption, {
19
22
  value: "1",
@@ -24,7 +27,8 @@ storiesOf('SingleSelectField', module).add('With label', () => /*#__PURE__*/Reac
24
27
  }), /*#__PURE__*/React.createElement(SingleSelectOption, {
25
28
  value: "3",
26
29
  label: "three"
27
- }))).add('With validation text', () => /*#__PURE__*/React.createElement(SingleSelectField, {
30
+ }));
31
+ export const WithValidationText = () => /*#__PURE__*/React.createElement(SingleSelectField, {
28
32
  validationText: "The validation text"
29
33
  }, /*#__PURE__*/React.createElement(SingleSelectOption, {
30
34
  value: "1",
@@ -35,7 +39,8 @@ storiesOf('SingleSelectField', module).add('With label', () => /*#__PURE__*/Reac
35
39
  }), /*#__PURE__*/React.createElement(SingleSelectOption, {
36
40
  value: "3",
37
41
  label: "three"
38
- }))).add('With label and required status', () => /*#__PURE__*/React.createElement(SingleSelectField, {
42
+ }));
43
+ export const WithLabelAndRequiredStatus = () => /*#__PURE__*/React.createElement(SingleSelectField, {
39
44
  label: "The label",
40
45
  required: true
41
46
  }, /*#__PURE__*/React.createElement(SingleSelectOption, {
@@ -47,19 +52,23 @@ storiesOf('SingleSelectField', module).add('With label', () => /*#__PURE__*/Reac
47
52
  }), /*#__PURE__*/React.createElement(SingleSelectOption, {
48
53
  value: "3",
49
54
  label: "three"
50
- }))).add('With clearable and selected option', () => /*#__PURE__*/React.createElement(SingleSelectField, {
55
+ }));
56
+ export const WithClearableAndSelectedOption = () => /*#__PURE__*/React.createElement(SingleSelectField, {
51
57
  selected: "1",
52
58
  clearable: true
53
59
  }, /*#__PURE__*/React.createElement(SingleSelectOption, {
54
60
  key: "1",
55
61
  value: "1",
56
62
  label: "One"
57
- }))).add('With filterable', () => /*#__PURE__*/React.createElement(SingleSelectField, {
63
+ }));
64
+ export const WithFilterable = () => /*#__PURE__*/React.createElement(SingleSelectField, {
58
65
  filterable: true
59
66
  }, /*#__PURE__*/React.createElement(SingleSelectOption, {
60
67
  key: "1",
61
68
  value: "1",
62
69
  label: "One"
63
- }))).add('With loading', () => /*#__PURE__*/React.createElement(SingleSelectField, {
70
+ }));
71
+ export const WithLoading = () => /*#__PURE__*/React.createElement(SingleSelectField, {
64
72
  loading: true
65
- })).add('Without options', () => /*#__PURE__*/React.createElement(SingleSelectField, null));
73
+ });
74
+ export const WithoutOptions = () => /*#__PURE__*/React.createElement(SingleSelectField, null);
@@ -1,19 +1,18 @@
1
+ import { sharedPropTypes } from '@dhis2/ui-constants';
1
2
  import { Box } from '@dhis2-ui/box';
2
3
  import { Field } from '@dhis2-ui/field';
3
- import { sharedPropTypes } from '@dhis2/ui-constants';
4
4
  import PropTypes from 'prop-types';
5
5
  import React from 'react';
6
- import { SingleSelect } from '../index.js';
7
- import i18n from '../locales/index.js'; // TODO: translate
6
+ import i18n from '../locales/index.js';
7
+ import { SingleSelect } from '../single-select/index.js';
8
8
 
9
+ // TODO: translate
9
10
  const translate = (prop, interpolationObject) => {
10
11
  if (typeof prop === 'function') {
11
12
  return prop(interpolationObject);
12
13
  }
13
-
14
14
  return prop;
15
15
  };
16
-
17
16
  class SingleSelectField extends React.Component {
18
17
  render() {
19
18
  const {
@@ -91,9 +90,7 @@ class SingleSelectField extends React.Component {
91
90
  dense: dense
92
91
  }, children)));
93
92
  }
94
-
95
93
  }
96
-
97
94
  SingleSelectField.defaultProps = {
98
95
  dataTest: 'dhis2-uiwidgets-singleselectfield',
99
96
  selected: '',
@@ -107,90 +104,62 @@ SingleSelectField.propTypes = {
107
104
  /** Should be `SingleSelectOption` components */
108
105
  children: PropTypes.node,
109
106
  className: PropTypes.string,
110
-
111
107
  /** Label for the button that clears selections */
112
108
  clearText: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
113
-
114
109
  /** Adds a button to the SingleSelect that clears selections when pressed */
115
110
  clearable: PropTypes.bool,
116
111
  dataTest: PropTypes.string,
117
-
118
112
  /** Makes the SingleSelect smaller */
119
113
  dense: PropTypes.bool,
120
-
121
114
  /** Disables the SingleSelect */
122
115
  disabled: PropTypes.bool,
123
-
124
116
  /** Text to display when there are no options */
125
117
  empty: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
126
-
127
118
  /** Adds 'error' appearance for validation feedback. Mutually exclusive with 'valid' and 'warning' props */
128
119
  error: sharedPropTypes.statusPropType,
129
-
130
120
  /** Placeholder text to show in the filter field when it is empty */
131
121
  filterPlaceholder: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
132
-
133
122
  /** Adds a field to filter options */
134
123
  filterable: PropTypes.bool,
135
-
136
124
  /** Useful guiding text to display below the SingleSelect */
137
125
  helpText: PropTypes.string,
138
-
139
126
  /** Grabs initial focus on the page */
140
127
  initialFocus: PropTypes.bool,
141
-
142
128
  /** Constrains the height of the input */
143
129
  inputMaxHeight: PropTypes.string,
144
-
145
130
  /** Sets the width of the input. Can be any valid CSS measurement */
146
131
  inputWidth: PropTypes.string,
147
-
148
132
  /** Text for the label above the SingleSelect */
149
133
  label: PropTypes.string,
150
-
151
134
  /** Applies a loading appearance to the dropdown options */
152
135
  loading: PropTypes.bool,
153
-
154
136
  /** Text to display when `loading` is true */
155
137
  loadingText: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
156
-
157
138
  /** Constrains height of the SingleSelect */
158
139
  maxHeight: PropTypes.string,
159
-
160
140
  /** Text to display when there are no filter results */
161
141
  noMatchText: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
162
-
163
142
  /** Placeholder text when the SingleSelect is empty */
164
143
  placeholder: PropTypes.string,
165
-
166
144
  /** Leading text to prefix selections */
167
145
  prefix: PropTypes.string,
168
-
169
146
  /** Indicates that a selection is required */
170
147
  required: PropTypes.bool,
171
-
172
148
  /** Selected item in the SingleSelect (the string should refer to the item's `value` attribute) */
173
149
  selected: PropTypes.string,
174
150
  tabIndex: PropTypes.string,
175
-
176
151
  /** Adds 'valid' appearance for validation feedback. Mutually exclusive with 'error' and 'warning' props */
177
152
  valid: sharedPropTypes.statusPropType,
178
-
179
153
  /** Text to provide form validation feedback. Receives styles according to validation status */
180
154
  validationText: PropTypes.string,
181
-
182
155
  /** Adds 'warning' appearance for validation feedback. Mutually exclusive with 'valid' and 'error' props */
183
156
  warning: sharedPropTypes.statusPropType,
184
-
185
157
  /** Called with signature `({ selected: string }, event)` */
186
158
  onBlur: PropTypes.func,
187
-
188
159
  /** Called with signature `({ selected: string }, event)` */
189
160
  onChange: PropTypes.func,
190
-
191
161
  /** Called with signature `({ selected: string }, event)` */
192
162
  onFocus: PropTypes.func,
193
-
194
163
  /** Called with signature `({ selected: string }, event)` */
195
164
  onKeyDown: PropTypes.func
196
165
  };
@@ -2,10 +2,18 @@ import { sharedPropTypes } from '@dhis2/ui-constants';
2
2
  import React from 'react';
3
3
  import { SingleSelectOption } from '../index.js';
4
4
  import { SingleSelectField } from './index.js';
5
- const description = "\n`SingleSelectField` is a wrapper around a `SingleSelect` component that adds a label, help text, validation text, and other features.\n\nSee the SingleSelect 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 { SingleSelectField, SingleSelectOption } 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";
5
+ const description = `
6
+ \`SingleSelectField\` is a wrapper around a \`SingleSelect\` component that adds a label, help text, validation text, and other features.
6
7
 
7
- const onChange = selected => alert("Selected changed to: ".concat(JSON.stringify(selected, null, 2)));
8
+ See the SingleSelect for more information, and read more at [Design System: Select](https://github.com/dhis2/design-system/blob/master/molecules/select.md#multiple-selection).
8
9
 
10
+ \`\`\`js
11
+ import { SingleSelectField, SingleSelectOption } from '@dhis2/ui'
12
+ \`\`\`
13
+
14
+ _**Note**: The dropdowns in some of the following stories won't appear correctly on this page. View these demos in the 'Canvas' tab._
15
+ `;
16
+ const onChange = selected => alert(`Selected changed to: ${JSON.stringify(selected, null, 2)}`);
9
17
  const options = [/*#__PURE__*/React.createElement(SingleSelectOption, {
10
18
  key: "1",
11
19
  value: "1",
@@ -61,24 +69,26 @@ export default {
61
69
  }
62
70
  },
63
71
  // default args for stories
64
- args: { // Fix default prop issues - causes 'i18n is not defined' error
72
+ args: {
73
+ // Fix default prop issues - causes 'i18n is not defined' error
65
74
  ...SingleSelectField.defaultProps,
66
75
  label: 'Default label',
67
76
  children: options,
68
77
  onChange: onChange
69
78
  },
70
79
  argTypes: {
71
- valid: { ...sharedPropTypes.statusArgType
80
+ valid: {
81
+ ...sharedPropTypes.statusArgType
72
82
  },
73
- warning: { ...sharedPropTypes.statusArgType
83
+ warning: {
84
+ ...sharedPropTypes.statusArgType
74
85
  },
75
- error: { ...sharedPropTypes.statusArgType
86
+ error: {
87
+ ...sharedPropTypes.statusArgType
76
88
  }
77
89
  }
78
90
  };
79
-
80
91
  const Template = args => /*#__PURE__*/React.createElement(SingleSelectField, args);
81
-
82
92
  export const Default = Template.bind({});
83
93
  export const WithHelpText = Template.bind({});
84
94
  WithHelpText.args = {
@@ -87,7 +97,7 @@ WithHelpText.args = {
87
97
  WithHelpText.parameters = {
88
98
  docs: {
89
99
  description: {
90
- story: "_**Note**: The dropdowns in the following stories won't appear correctly on this page. View these demos in the 'Canvas' tab._"
100
+ story: `_**Note**: The dropdowns in the following stories won't appear correctly on this page. View these demos in the 'Canvas' tab._`
91
101
  }
92
102
  }
93
103
  };
@@ -3,7 +3,6 @@ import { colors, spacers } from '@dhis2/ui-constants';
3
3
  import cx from 'classnames';
4
4
  import PropTypes from 'prop-types';
5
5
  import React from 'react';
6
-
7
6
  const SingleSelectOption = _ref => {
8
7
  let {
9
8
  label,
@@ -26,9 +25,8 @@ const SingleSelectOption = _ref => {
26
25
  }, label, /*#__PURE__*/React.createElement(_JSXStyle, {
27
26
  id: "3808134379",
28
27
  dynamic: [colors.grey900, spacers.dp8, spacers.dp12, colors.grey200, colors.teal700, colors.white, colors.grey500]
29
- }, ["div.__jsx-style-dynamic-selector{cursor:pointer;font-size:14px;-webkit-text-decoration:none;text-decoration:none;color:".concat(colors.grey900, ";padding-block:").concat(spacers.dp8, ";padding-inline:").concat(spacers.dp12, ";}"), "div.__jsx-style-dynamic-selector:hover{background-color:".concat(colors.grey200, ";}"), "div.__jsx-style-dynamic-selector:active,div.active.__jsx-style-dynamic-selector{background-color:".concat(colors.teal700, ";color:").concat(colors.white, ";cursor:auto;}"), "div.disabled.__jsx-style-dynamic-selector{color:".concat(colors.grey500, ";cursor:not-allowed;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}"), "div.disabled.__jsx-style-dynamic-selector:hover{background-color:initial;}"]));
28
+ }, [`div.__jsx-style-dynamic-selector{cursor:pointer;font-size:14px;-webkit-text-decoration:none;text-decoration:none;color:${colors.grey900};padding-block:${spacers.dp8};padding-inline:${spacers.dp12};}`, `div.__jsx-style-dynamic-selector:hover{background-color:${colors.grey200};}`, `div.__jsx-style-dynamic-selector:active,div.active.__jsx-style-dynamic-selector{background-color:${colors.teal700};color:${colors.white};cursor:auto;}`, `div.disabled.__jsx-style-dynamic-selector{color:${colors.grey500};cursor:not-allowed;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}`, "div.disabled.__jsx-style-dynamic-selector:hover{background-color:initial;}"]));
30
29
  };
31
-
32
30
  SingleSelectOption.defaultProps = {
33
31
  dataTest: 'dhis2-uicore-singleselectoption'
34
32
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/select",
3
- "version": "9.11.0",
3
+ "version": "9.11.1-beta.2",
4
4
  "description": "UI Select",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,32 +22,32 @@
22
22
  "access": "public"
23
23
  },
24
24
  "scripts": {
25
- "start": "start-storybook -c ../../storybook/config --port 5000",
25
+ "start": "storybook dev -c ../../storybook/config --port 5000",
26
26
  "build": "d2-app-scripts build",
27
27
  "test": "d2-app-scripts test --jestConfig ../../jest.config.shared.js"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@dhis2/d2-i18n": "^1",
31
- "react": "^16.8",
32
- "react-dom": "^16.8",
31
+ "react": "^16.13",
32
+ "react-dom": "^16.13",
33
33
  "styled-jsx": "^4"
34
34
  },
35
35
  "dependencies": {
36
- "@dhis2-ui/box": "9.11.0",
37
- "@dhis2-ui/button": "9.11.0",
38
- "@dhis2-ui/card": "9.11.0",
39
- "@dhis2-ui/checkbox": "9.11.0",
40
- "@dhis2-ui/chip": "9.11.0",
41
- "@dhis2-ui/field": "9.11.0",
42
- "@dhis2-ui/input": "9.11.0",
43
- "@dhis2-ui/layer": "9.11.0",
44
- "@dhis2-ui/loader": "9.11.0",
45
- "@dhis2-ui/popper": "9.11.0",
46
- "@dhis2-ui/status-icon": "9.11.0",
47
- "@dhis2-ui/tooltip": "9.11.0",
36
+ "@dhis2-ui/box": "9.11.1-beta.2",
37
+ "@dhis2-ui/button": "9.11.1-beta.2",
38
+ "@dhis2-ui/card": "9.11.1-beta.2",
39
+ "@dhis2-ui/checkbox": "9.11.1-beta.2",
40
+ "@dhis2-ui/chip": "9.11.1-beta.2",
41
+ "@dhis2-ui/field": "9.11.1-beta.2",
42
+ "@dhis2-ui/input": "9.11.1-beta.2",
43
+ "@dhis2-ui/layer": "9.11.1-beta.2",
44
+ "@dhis2-ui/loader": "9.11.1-beta.2",
45
+ "@dhis2-ui/popper": "9.11.1-beta.2",
46
+ "@dhis2-ui/status-icon": "9.11.1-beta.2",
47
+ "@dhis2-ui/tooltip": "9.11.1-beta.2",
48
48
  "@dhis2/prop-types": "^3.1.2",
49
- "@dhis2/ui-constants": "9.11.0",
50
- "@dhis2/ui-icons": "9.11.0",
49
+ "@dhis2/ui-constants": "9.11.1-beta.2",
50
+ "@dhis2/ui-icons": "9.11.1-beta.2",
51
51
  "classnames": "^2.3.1",
52
52
  "prop-types": "^15.7.2"
53
53
  },