@dhis2-ui/select 8.2.0 → 8.2.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 (71) hide show
  1. package/build/cjs/multi-select/features/menu_width_matches_input/index.js +4 -2
  2. package/build/cjs/multi-select/features/position/index.js +12 -6
  3. package/build/cjs/multi-select/filterable-menu.js +25 -22
  4. package/build/cjs/multi-select/input.js +19 -18
  5. package/build/cjs/multi-select/menu.js +29 -25
  6. package/build/cjs/multi-select/multi-select.js +31 -30
  7. package/build/cjs/multi-select/multi-select.stories.e2e.js +30 -20
  8. package/build/cjs/multi-select/multi-select.stories.js +14 -23
  9. package/build/cjs/multi-select/selection-list.js +43 -37
  10. package/build/cjs/multi-select-field/multi-select-field.stories.js +5 -15
  11. package/build/cjs/multi-select-option/multi-select-option.js +31 -28
  12. package/build/cjs/select/debounce/debounce.js +8 -2
  13. package/build/cjs/select/empty.js +14 -11
  14. package/build/cjs/select/filter-input.js +24 -21
  15. package/build/cjs/select/filterable-menu.js +8 -7
  16. package/build/cjs/select/index.js +24 -24
  17. package/build/cjs/select/input-clear-button.js +16 -13
  18. package/build/cjs/select/input-placeholder.js +8 -6
  19. package/build/cjs/select/input-prefix.js +8 -6
  20. package/build/cjs/select/input-wrapper.js +15 -14
  21. package/build/cjs/select/loading.js +18 -15
  22. package/build/cjs/select/menu-wrapper.js +11 -10
  23. package/build/cjs/select/no-match.js +12 -9
  24. package/build/cjs/select/option-helpers.js +1 -1
  25. package/build/cjs/select/select.js +6 -6
  26. package/build/cjs/single-select/features/menu_width_matches_input/index.js +4 -2
  27. package/build/cjs/single-select/features/position/index.js +8 -4
  28. package/build/cjs/single-select/filterable-menu.js +25 -22
  29. package/build/cjs/single-select/input.js +19 -18
  30. package/build/cjs/single-select/menu.js +11 -10
  31. package/build/cjs/single-select/selection.js +8 -7
  32. package/build/cjs/single-select/single-select.js +31 -30
  33. package/build/cjs/single-select/single-select.stories.e2e.js +26 -17
  34. package/build/cjs/single-select/single-select.stories.js +14 -21
  35. package/build/cjs/single-select-field/single-select-field.stories.js +5 -15
  36. package/build/cjs/single-select-option/single-select-option.js +23 -20
  37. package/build/es/multi-select/features/menu_width_matches_input/index.js +4 -2
  38. package/build/es/multi-select/features/position/index.js +12 -6
  39. package/build/es/multi-select/filterable-menu.js +25 -22
  40. package/build/es/multi-select/input.js +19 -18
  41. package/build/es/multi-select/menu.js +28 -24
  42. package/build/es/multi-select/multi-select.js +31 -30
  43. package/build/es/multi-select/multi-select.stories.e2e.js +30 -20
  44. package/build/es/multi-select/multi-select.stories.js +13 -22
  45. package/build/es/multi-select/selection-list.js +43 -37
  46. package/build/es/multi-select-field/multi-select-field.stories.js +4 -14
  47. package/build/es/multi-select-option/multi-select-option.js +31 -28
  48. package/build/es/select/debounce/debounce.js +8 -2
  49. package/build/es/select/empty.js +14 -11
  50. package/build/es/select/filter-input.js +24 -21
  51. package/build/es/select/filterable-menu.js +8 -7
  52. package/build/es/select/input-clear-button.js +16 -13
  53. package/build/es/select/input-placeholder.js +8 -6
  54. package/build/es/select/input-prefix.js +8 -6
  55. package/build/es/select/input-wrapper.js +15 -14
  56. package/build/es/select/loading.js +18 -15
  57. package/build/es/select/menu-wrapper.js +11 -10
  58. package/build/es/select/no-match.js +12 -9
  59. package/build/es/select/select.js +6 -6
  60. package/build/es/single-select/features/menu_width_matches_input/index.js +4 -2
  61. package/build/es/single-select/features/position/index.js +8 -4
  62. package/build/es/single-select/filterable-menu.js +25 -22
  63. package/build/es/single-select/input.js +19 -18
  64. package/build/es/single-select/menu.js +11 -10
  65. package/build/es/single-select/selection.js +8 -7
  66. package/build/es/single-select/single-select.js +31 -30
  67. package/build/es/single-select/single-select.stories.e2e.js +26 -17
  68. package/build/es/single-select/single-select.stories.js +13 -20
  69. package/build/es/single-select-field/single-select-field.stories.js +4 -14
  70. package/build/es/single-select-option/single-select-option.js +23 -20
  71. package/package.json +14 -14
@@ -5,15 +5,16 @@ import PropTypes from 'prop-types';
5
5
  import React from 'react';
6
6
  import { findOptionChild } from '../select/index.js';
7
7
 
8
- const Selection = ({
9
- options,
10
- selected,
11
- className
12
- }) => {
8
+ const Selection = _ref => {
9
+ let {
10
+ options,
11
+ selected,
12
+ className
13
+ } = _ref;
13
14
  const selectedOption = findOptionChild(selected, options);
14
15
 
15
16
  if (!selectedOption) {
16
- const message = `There is no option with the value: "${selected}". ` + 'Make sure that the value passed to the selected ' + 'prop matches the value of an existing option.';
17
+ const message = "There is no option with the value: \"".concat(selected, "\". ") + 'Make sure that the value passed to the selected ' + 'prop matches the value of an existing option.';
17
18
  throw new Error(message);
18
19
  }
19
20
 
@@ -26,7 +27,7 @@ const Selection = ({
26
27
  }, icon), label, /*#__PURE__*/React.createElement(_JSXStyle, {
27
28
  id: "2368250986",
28
29
  dynamic: [spacers.dp8, spacers.dp16, spacers.dp16]
29
- }, [".root.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}", `.root-icon.__jsx-style-dynamic-selector{margin-right:${spacers.dp8};width:${spacers.dp16};height:${spacers.dp16};overflow:hidden;}`]));
30
+ }, [".root.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}", ".root-icon.__jsx-style-dynamic-selector{margin-right:".concat(spacers.dp8, ";width:").concat(spacers.dp16, ";height:").concat(spacers.dp16, ";overflow:hidden;}")]));
30
31
  };
31
32
 
32
33
  Selection.propTypes = {
@@ -9,34 +9,35 @@ import { FilterableMenu } from './filterable-menu.js';
9
9
  import { Input } from './input.js';
10
10
  import { Menu } from './menu.js';
11
11
 
12
- const SingleSelect = ({
13
- className,
14
- selected,
15
- tabIndex,
16
- maxHeight,
17
- inputMaxHeight,
18
- onChange,
19
- onFocus,
20
- onBlur,
21
- loading,
22
- error,
23
- warning,
24
- valid,
25
- disabled,
26
- children,
27
- clearable,
28
- clearText,
29
- filterable,
30
- filterPlaceholder,
31
- placeholder,
32
- prefix,
33
- empty,
34
- loadingText,
35
- noMatchText,
36
- initialFocus,
37
- dense,
38
- dataTest
39
- }) => {
12
+ const SingleSelect = _ref => {
13
+ let {
14
+ className,
15
+ selected,
16
+ tabIndex,
17
+ maxHeight,
18
+ inputMaxHeight,
19
+ onChange,
20
+ onFocus,
21
+ onBlur,
22
+ loading,
23
+ error,
24
+ warning,
25
+ valid,
26
+ disabled,
27
+ children,
28
+ clearable,
29
+ clearText,
30
+ filterable,
31
+ filterPlaceholder,
32
+ placeholder,
33
+ prefix,
34
+ empty,
35
+ loadingText,
36
+ noMatchText,
37
+ initialFocus,
38
+ dense,
39
+ dataTest
40
+ } = _ref;
40
41
  // If the select is filterable, use a filterable menu
41
42
  const menu = filterable ? /*#__PURE__*/React.createElement(FilterableMenu, {
42
43
  dataTest: dataTest,
@@ -77,7 +78,7 @@ const SingleSelect = ({
77
78
  dense: dense
78
79
  }, children, loading && /*#__PURE__*/React.createElement(CommonLoading, {
79
80
  message: loadingText,
80
- dataTest: `${dataTest}-loading`
81
+ dataTest: "".concat(dataTest, "-loading")
81
82
  }))), /*#__PURE__*/React.createElement(StatusIcon, {
82
83
  error: error,
83
84
  valid: valid,
@@ -85,7 +86,7 @@ const SingleSelect = ({
85
86
  }), /*#__PURE__*/React.createElement(_JSXStyle, {
86
87
  id: "2180377457",
87
88
  dynamic: [spacers.dp8]
88
- }, [`.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:${spacers.dp8};}`, ".root-input.__jsx-style-dynamic-selector{-webkit-flex:1;-ms-flex:1;flex:1;}"]));
89
+ }, [".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(spacers.dp8, ";}"), ".root-input.__jsx-style-dynamic-selector{-webkit-flex:1;-ms-flex:1;flex:1;}"]));
89
90
  };
90
91
 
91
92
  SingleSelect.defaultProps = {
@@ -10,12 +10,15 @@ window.onChange = window.Cypress && window.Cypress.cy.stub();
10
10
  window.onFocus = window.Cypress && window.Cypress.cy.stub();
11
11
  window.onBlur = window.Cypress && window.Cypress.cy.stub();
12
12
 
13
- const CustomSingleSelectOption = ({
14
- label,
15
- onClick
16
- }) => /*#__PURE__*/React.createElement("div", {
17
- onClick: e => onClick({}, e)
18
- }, label);
13
+ const CustomSingleSelectOption = _ref => {
14
+ let {
15
+ label,
16
+ onClick
17
+ } = _ref;
18
+ return /*#__PURE__*/React.createElement("div", {
19
+ onClick: e => onClick({}, e)
20
+ }, label);
21
+ };
19
22
 
20
23
  CustomSingleSelectOption.propTypes = {
21
24
  label: PropTypes.string,
@@ -532,17 +535,23 @@ storiesOf('SingleSelect', module).add('With options', () => /*#__PURE__*/React.c
532
535
  flexGrow: 1
533
536
  }
534
537
  }, /*#__PURE__*/React.createElement(SingleSelect, {
535
- onChange: ({
536
- selected
537
- }) => console.log('size changed to ' + selected)
538
- }, options.map(({
539
- name,
540
- id
541
- }) => /*#__PURE__*/React.createElement(SingleSelectOption, {
542
- key: id,
543
- value: id,
544
- label: name
545
- })))), toggle && /*#__PURE__*/React.createElement("div", {
538
+ onChange: _ref2 => {
539
+ let {
540
+ selected
541
+ } = _ref2;
542
+ return console.log('size changed to ' + selected);
543
+ }
544
+ }, options.map(_ref3 => {
545
+ let {
546
+ name,
547
+ id
548
+ } = _ref3;
549
+ return /*#__PURE__*/React.createElement(SingleSelectOption, {
550
+ key: id,
551
+ value: id,
552
+ label: name
553
+ });
554
+ }))), toggle && /*#__PURE__*/React.createElement("div", {
546
555
  style: {
547
556
  padding: '30px',
548
557
  border: '1px solid green'
@@ -4,33 +4,26 @@ import PropTypes from 'prop-types';
4
4
  import React from 'react';
5
5
  import { SingleSelectOption } from '../index.js';
6
6
  import { SingleSelect } from './index.js';
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.
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
- `;
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";
18
8
 
19
9
  const eventHandler = handlerName => (payload, event) => {
20
- console.log(`${handlerName} payload`, payload);
21
- console.log(`${handlerName} event`, event);
10
+ console.log("".concat(handlerName, " payload"), payload);
11
+ console.log("".concat(handlerName, " event"), event);
22
12
  };
23
13
 
24
14
  const onChange = eventHandler('onChange');
25
15
  const onFocus = eventHandler('onFocus');
26
16
  const onBlur = eventHandler('onBlur');
27
17
 
28
- const CustomSingleSelectOption = ({
29
- label,
30
- onClick
31
- }) => /*#__PURE__*/React.createElement("div", {
32
- onClick: e => onClick({}, e)
33
- }, label);
18
+ const CustomSingleSelectOption = _ref => {
19
+ let {
20
+ label,
21
+ onClick
22
+ } = _ref;
23
+ return /*#__PURE__*/React.createElement("div", {
24
+ onClick: e => onClick({}, e)
25
+ }, label);
26
+ };
34
27
 
35
28
  CustomSingleSelectOption.propTypes = {
36
29
  label: PropTypes.string,
@@ -47,7 +40,7 @@ const requiredIfArgType = {
47
40
  }
48
41
  };
49
42
  export default {
50
- title: 'Forms/Single Select/Single Select',
43
+ title: 'Single Select',
51
44
  component: SingleSelect,
52
45
  parameters: {
53
46
  docs: {
@@ -2,19 +2,9 @@ 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 = `
6
- \`SingleSelectField\` is a wrapper around a \`SingleSelect\` component that adds a label, help text, validation text, and other features.
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";
7
6
 
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).
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
-
17
- const onChange = selected => alert(`Selected changed to: ${JSON.stringify(selected, null, 2)}`);
7
+ const onChange = selected => alert("Selected changed to: ".concat(JSON.stringify(selected, null, 2)));
18
8
 
19
9
  const options = [/*#__PURE__*/React.createElement(SingleSelectOption, {
20
10
  key: "1",
@@ -58,7 +48,7 @@ const options = [/*#__PURE__*/React.createElement(SingleSelectOption, {
58
48
  label: "ten"
59
49
  })];
60
50
  export default {
61
- title: 'Forms/Single Select/Single Select Field',
51
+ title: 'Single Select Field',
62
52
  component: SingleSelectField,
63
53
  subcomponents: {
64
54
  SingleSelectOption
@@ -97,7 +87,7 @@ WithHelpText.args = {
97
87
  WithHelpText.parameters = {
98
88
  docs: {
99
89
  description: {
100
- story: `_**Note**: The dropdowns in the following stories won't appear correctly on this page. View these demos in the 'Canvas' tab._`
90
+ story: "_**Note**: The dropdowns in the following stories won't appear correctly on this page. View these demos in the 'Canvas' tab._"
101
91
  }
102
92
  }
103
93
  };
@@ -4,27 +4,30 @@ import cx from 'classnames';
4
4
  import PropTypes from 'prop-types';
5
5
  import React from 'react';
6
6
 
7
- const SingleSelectOption = ({
8
- label,
9
- active,
10
- disabled,
11
- onClick,
12
- className,
13
- dataTest,
14
- value
15
- }) => /*#__PURE__*/React.createElement("div", {
16
- onClick: e => onClick({}, e),
17
- "data-test": dataTest,
18
- "data-value": value,
19
- "data-label": label,
20
- className: _JSXStyle.dynamic([["2046100779", [colors.grey900, spacers.dp8, spacers.dp12, colors.grey200, colors.teal700, colors.white, colors.grey500]]]) + " " + (cx(className, {
7
+ const SingleSelectOption = _ref => {
8
+ let {
9
+ label,
10
+ active,
21
11
  disabled,
22
- active
23
- }) || "")
24
- }, label, /*#__PURE__*/React.createElement(_JSXStyle, {
25
- id: "2046100779",
26
- dynamic: [colors.grey900, spacers.dp8, spacers.dp12, colors.grey200, colors.teal700, colors.white, colors.grey500]
27
- }, [`div.__jsx-style-dynamic-selector{cursor:pointer;font-size:14px;-webkit-text-decoration:none;text-decoration:none;color:${colors.grey900};padding:${spacers.dp8} ${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;}"]));
12
+ onClick,
13
+ className,
14
+ dataTest,
15
+ value
16
+ } = _ref;
17
+ return /*#__PURE__*/React.createElement("div", {
18
+ onClick: e => onClick({}, e),
19
+ "data-test": dataTest,
20
+ "data-value": value,
21
+ "data-label": label,
22
+ className: _JSXStyle.dynamic([["2046100779", [colors.grey900, spacers.dp8, spacers.dp12, colors.grey200, colors.teal700, colors.white, colors.grey500]]]) + " " + (cx(className, {
23
+ disabled,
24
+ active
25
+ }) || "")
26
+ }, label, /*#__PURE__*/React.createElement(_JSXStyle, {
27
+ id: "2046100779",
28
+ 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:").concat(spacers.dp8, " ").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;}"]));
30
+ };
28
31
 
29
32
  SingleSelectOption.defaultProps = {
30
33
  dataTest: 'dhis2-uicore-singleselectoption'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/select",
3
- "version": "8.2.0",
3
+ "version": "8.2.1",
4
4
  "description": "UI Select",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,19 +33,19 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@dhis2/prop-types": "^3.0.0-beta.1",
36
- "@dhis2-ui/box": "8.2.0",
37
- "@dhis2-ui/button": "8.2.0",
38
- "@dhis2-ui/card": "8.2.0",
39
- "@dhis2-ui/checkbox": "8.2.0",
40
- "@dhis2-ui/chip": "8.2.0",
41
- "@dhis2-ui/field": "8.2.0",
42
- "@dhis2-ui/input": "8.2.0",
43
- "@dhis2-ui/layer": "8.2.0",
44
- "@dhis2-ui/loader": "8.2.0",
45
- "@dhis2-ui/popper": "8.2.0",
46
- "@dhis2-ui/status-icon": "8.2.0",
47
- "@dhis2/ui-constants": "8.2.0",
48
- "@dhis2/ui-icons": "8.2.0",
36
+ "@dhis2-ui/box": "8.2.1",
37
+ "@dhis2-ui/button": "8.2.1",
38
+ "@dhis2-ui/card": "8.2.1",
39
+ "@dhis2-ui/checkbox": "8.2.1",
40
+ "@dhis2-ui/chip": "8.2.1",
41
+ "@dhis2-ui/field": "8.2.1",
42
+ "@dhis2-ui/input": "8.2.1",
43
+ "@dhis2-ui/layer": "8.2.1",
44
+ "@dhis2-ui/loader": "8.2.1",
45
+ "@dhis2-ui/popper": "8.2.1",
46
+ "@dhis2-ui/status-icon": "8.2.1",
47
+ "@dhis2/ui-constants": "8.2.1",
48
+ "@dhis2/ui-icons": "8.2.1",
49
49
  "classnames": "^2.3.1",
50
50
  "prop-types": "^15.7.2"
51
51
  },