@dhis2-ui/select 10.12.13 → 10.13.0
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.
- package/build/cjs/locales/en/translations.json +2 -0
- package/build/cjs/multi-select/input.js +20 -11
- package/build/cjs/multi-select/multi-select.js +5 -1
- package/build/cjs/multi-select/multi-select.prod.stories.js +42 -1
- package/build/es/locales/en/translations.json +2 -0
- package/build/es/multi-select/input.js +16 -7
- package/build/es/multi-select/multi-select.js +5 -1
- package/build/es/multi-select/multi-select.prod.stories.js +40 -0
- package/package.json +15 -15
- package/types/index.d.ts +4 -0
|
@@ -10,7 +10,8 @@ var _uiConstants = require("@dhis2/ui-constants");
|
|
|
10
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
11
|
var _propTypes2 = _interopRequireDefault(require("prop-types"));
|
|
12
12
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
var _index = require("../
|
|
13
|
+
var _index = _interopRequireDefault(require("../locales/index.js"));
|
|
14
|
+
var _index2 = require("../select/index.js");
|
|
14
15
|
var _selectionList = require("./selection-list.js");
|
|
15
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
17
|
const Input = _ref => {
|
|
@@ -25,9 +26,11 @@ const Input = _ref => {
|
|
|
25
26
|
options,
|
|
26
27
|
className,
|
|
27
28
|
disabled,
|
|
28
|
-
inputMaxHeight = '100px'
|
|
29
|
+
inputMaxHeight = '100px',
|
|
30
|
+
collapseSelectionAfter
|
|
29
31
|
} = _ref;
|
|
30
32
|
const hasSelection = selected.length > 0;
|
|
33
|
+
const shouldCollapse = hasSelection && typeof collapseSelectionAfter === 'number' && selected.length > collapseSelectionAfter;
|
|
31
34
|
const onClear = e => {
|
|
32
35
|
const data = {
|
|
33
36
|
selected: []
|
|
@@ -36,30 +39,35 @@ const Input = _ref => {
|
|
|
36
39
|
onChange(data, e);
|
|
37
40
|
};
|
|
38
41
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
39
|
-
className: _style.default.dynamic([["
|
|
40
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
42
|
+
className: _style.default.dynamic([["3188585639", [_uiConstants.colors.grey900]], ["1331770409", [inputMaxHeight]]]) + " " + ((0, _classnames.default)('root', className) || "")
|
|
43
|
+
}, /*#__PURE__*/_react.default.createElement(_index2.InputPrefix, {
|
|
41
44
|
prefix: prefix,
|
|
42
45
|
dataTest: `${dataTest}-prefix`
|
|
43
|
-
}), !hasSelection && !prefix && /*#__PURE__*/_react.default.createElement(
|
|
46
|
+
}), !hasSelection && !prefix && /*#__PURE__*/_react.default.createElement(_index2.InputPlaceholder, {
|
|
44
47
|
placeholder: placeholder,
|
|
45
48
|
dataTest: `${dataTest}-placeholder`
|
|
46
|
-
}), hasSelection && /*#__PURE__*/_react.default.createElement("
|
|
47
|
-
|
|
49
|
+
}), hasSelection && shouldCollapse && /*#__PURE__*/_react.default.createElement("span", {
|
|
50
|
+
"data-test": `${dataTest}-selection-count`,
|
|
51
|
+
className: _style.default.dynamic([["3188585639", [_uiConstants.colors.grey900]], ["1331770409", [inputMaxHeight]]]) + " " + "collapsed-selection-text"
|
|
52
|
+
}, _index.default.t('{{count}} selected', {
|
|
53
|
+
count: selected.length
|
|
54
|
+
})), hasSelection && !shouldCollapse && /*#__PURE__*/_react.default.createElement("div", {
|
|
55
|
+
className: _style.default.dynamic([["3188585639", [_uiConstants.colors.grey900]], ["1331770409", [inputMaxHeight]]]) + " " + "root-input"
|
|
48
56
|
}, /*#__PURE__*/_react.default.createElement(_selectionList.SelectionList, {
|
|
49
57
|
selected: selected,
|
|
50
58
|
onChange: onChange,
|
|
51
59
|
options: options,
|
|
52
60
|
disabled: disabled
|
|
53
61
|
})), hasSelection && clearable && !disabled && /*#__PURE__*/_react.default.createElement("div", {
|
|
54
|
-
className: _style.default.dynamic([["
|
|
55
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
62
|
+
className: _style.default.dynamic([["3188585639", [_uiConstants.colors.grey900]], ["1331770409", [inputMaxHeight]]]) + " " + "root-right"
|
|
63
|
+
}, /*#__PURE__*/_react.default.createElement(_index2.InputClearButton, {
|
|
56
64
|
onClear: onClear,
|
|
57
65
|
clearText: clearText,
|
|
58
66
|
dataTest: `${dataTest}-clear`
|
|
59
67
|
})), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
60
|
-
id: "
|
|
68
|
+
id: "3188585639",
|
|
61
69
|
dynamic: [_uiConstants.colors.grey900]
|
|
62
|
-
}, [`.root.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:${_uiConstants.colors.grey900};font-size:14px;line-height:16px;}`, ".root-input.__jsx-style-dynamic-selector{overflow-y:auto;-webkit-flex:1;-ms-flex:1;flex:1;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-flow:wrap;-ms-flex-flow:wrap;flex-flow:wrap;gap:4px;}", ".root-right.__jsx-style-dynamic-selector{margin-inline-start:auto;}"]), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
70
|
+
}, [`.root.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:${_uiConstants.colors.grey900};font-size:14px;line-height:16px;}`, ".root-input.__jsx-style-dynamic-selector{overflow-y:auto;-webkit-flex:1;-ms-flex:1;flex:1;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-flow:wrap;-ms-flex-flow:wrap;flex-flow:wrap;gap:4px;}", ".root-right.__jsx-style-dynamic-selector{margin-inline-start:auto;}", ".collapsed-selection-text.__jsx-style-dynamic-selector{-webkit-flex:1;-ms-flex:1;flex:1;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}"]), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
63
71
|
id: "1331770409",
|
|
64
72
|
dynamic: [inputMaxHeight]
|
|
65
73
|
}, [`.root-input.__jsx-style-dynamic-selector{max-height:${inputMaxHeight};}`]));
|
|
@@ -70,6 +78,7 @@ Input.propTypes = {
|
|
|
70
78
|
className: _propTypes2.default.string,
|
|
71
79
|
clearText: (0, _propTypes.requiredIf)(props => props.clearable, _propTypes2.default.string),
|
|
72
80
|
clearable: _propTypes2.default.bool,
|
|
81
|
+
collapseSelectionAfter: _propTypes2.default.number,
|
|
73
82
|
disabled: _propTypes2.default.bool,
|
|
74
83
|
inputMaxHeight: _propTypes2.default.string,
|
|
75
84
|
options: _propTypes2.default.node,
|
|
@@ -45,6 +45,7 @@ const MultiSelect = _ref => {
|
|
|
45
45
|
noMatchText,
|
|
46
46
|
initialFocus,
|
|
47
47
|
dense,
|
|
48
|
+
collapseSelectionAfter,
|
|
48
49
|
dataTest = 'dhis2-uicore-multiselect'
|
|
49
50
|
} = _ref;
|
|
50
51
|
// If the select is filterable, use a filterable menu
|
|
@@ -71,7 +72,8 @@ const MultiSelect = _ref => {
|
|
|
71
72
|
dataTest: dataTest,
|
|
72
73
|
placeholder: placeholder,
|
|
73
74
|
prefix: prefix,
|
|
74
|
-
inputMaxHeight: inputMaxHeight
|
|
75
|
+
inputMaxHeight: inputMaxHeight,
|
|
76
|
+
collapseSelectionAfter: collapseSelectionAfter
|
|
75
77
|
}),
|
|
76
78
|
menu: menu,
|
|
77
79
|
tabIndex: tabIndex,
|
|
@@ -106,6 +108,8 @@ MultiSelect.propTypes = {
|
|
|
106
108
|
clearText: (0, _propTypes.requiredIf)(props => props.clearable, _propTypes2.default.string),
|
|
107
109
|
/** Adds a 'clear' option to the menu */
|
|
108
110
|
clearable: _propTypes2.default.bool,
|
|
111
|
+
/** When the number of selected items exceeds this threshold, chips are replaced with "X selected" text */
|
|
112
|
+
collapseSelectionAfter: _propTypes2.default.number,
|
|
109
113
|
dataTest: _propTypes2.default.string,
|
|
110
114
|
dense: _propTypes2.default.bool,
|
|
111
115
|
disabled: _propTypes2.default.bool,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.WithPrefixAndSelection = exports.WithPrefix = exports.WithPlaceholderAndSelection = exports.WithPlaceholder = exports.WithOptionsLoadingAndLoadingText = exports.WithOptionsAndOnChange = exports.WithOptionsAndMultipleSelections = exports.WithOptionsAndLoading = exports.WithOptionsAndDisabled = exports.WithOptionsAndASelection = exports.WithOptionsASelectionAndDisabled = exports.WithOnFocus = exports.WithOnBlur = exports.WithMultipleSelectionsWrapped = exports.WithMoreThanThreeOptionsAndA100PxMaxHeight = exports.WithMoreThanTenOptions = exports.WithInvalidOptions = exports.WithInvalidFilterableOptions = exports.WithInitialFocus = exports.WithFilterField = exports.WithDisabledOptionAndOnChange = exports.WithCustomOptionsAndOnChange = exports.WithClearButtonSelectionAndOnChange = exports.ShiftedIntoView = exports.RTL = exports.FlippedPosition = exports.EmptyWithEmptyText = exports.EmptyWithEmptyComponent = exports.Empty = exports.DenseWithSelections = exports.Dense = exports.DefaultPosition = void 0;
|
|
6
|
+
exports.default = exports.WithPrefixAndSelection = exports.WithPrefix = exports.WithPlaceholderAndSelection = exports.WithPlaceholder = exports.WithOptionsLoadingAndLoadingText = exports.WithOptionsAndOnChange = exports.WithOptionsAndMultipleSelections = exports.WithOptionsAndLoading = exports.WithOptionsAndDisabled = exports.WithOptionsAndASelection = exports.WithOptionsASelectionAndDisabled = exports.WithOnFocus = exports.WithOnBlur = exports.WithMultipleSelectionsWrapped = exports.WithMoreThanThreeOptionsAndA100PxMaxHeight = exports.WithMoreThanTenOptions = exports.WithInvalidOptions = exports.WithInvalidFilterableOptions = exports.WithInitialFocus = exports.WithFilterField = exports.WithDisabledOptionAndOnChange = exports.WithCustomOptionsAndOnChange = exports.WithClearButtonSelectionAndOnChange = exports.ShiftedIntoView = exports.RTL = exports.FlippedPosition = exports.EmptyWithEmptyText = exports.EmptyWithEmptyComponent = exports.Empty = exports.DenseWithSelections = exports.Dense = exports.DefaultPosition = exports.CollapseSelectionAfterThreshold = void 0;
|
|
7
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
8
8
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -513,6 +513,47 @@ const ShiftedIntoView = args => /*#__PURE__*/_react.default.createElement(_react
|
|
|
513
513
|
id: "1828862170"
|
|
514
514
|
}, ["html,body,#root{position:relative;height:300px !important;max-height:300px;}", "#root{padding-top:130px !important;}"]));
|
|
515
515
|
exports.ShiftedIntoView = ShiftedIntoView;
|
|
516
|
+
const CollapseSelectionAfterThreshold = () => {
|
|
517
|
+
const [selected, setSelected] = _react.default.useState(['1', '3', '5']);
|
|
518
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
519
|
+
style: {
|
|
520
|
+
maxWidth: 400
|
|
521
|
+
}
|
|
522
|
+
}, /*#__PURE__*/_react.default.createElement(_index2.MultiSelect, {
|
|
523
|
+
className: "select",
|
|
524
|
+
selected: selected,
|
|
525
|
+
onChange: _ref3 => {
|
|
526
|
+
let {
|
|
527
|
+
selected
|
|
528
|
+
} = _ref3;
|
|
529
|
+
return setSelected(selected);
|
|
530
|
+
},
|
|
531
|
+
collapseSelectionAfter: 2,
|
|
532
|
+
prefix: "Prefix text",
|
|
533
|
+
clearable: true,
|
|
534
|
+
clearText: "Clear all"
|
|
535
|
+
}, /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
536
|
+
value: "1",
|
|
537
|
+
label: "option one"
|
|
538
|
+
}), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
539
|
+
value: "2",
|
|
540
|
+
label: "option two"
|
|
541
|
+
}), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
542
|
+
value: "3",
|
|
543
|
+
label: "option three"
|
|
544
|
+
}), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
545
|
+
value: "4",
|
|
546
|
+
label: "option four"
|
|
547
|
+
}), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
548
|
+
value: "5",
|
|
549
|
+
label: "option five"
|
|
550
|
+
}), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
551
|
+
value: "6",
|
|
552
|
+
label: "option six"
|
|
553
|
+
})));
|
|
554
|
+
};
|
|
555
|
+
exports.CollapseSelectionAfterThreshold = CollapseSelectionAfterThreshold;
|
|
556
|
+
CollapseSelectionAfterThreshold.storyName = 'Collapse selection after threshold';
|
|
516
557
|
const RTL = args => {
|
|
517
558
|
(0, _react.useEffect)(() => {
|
|
518
559
|
document.body.dir = 'rtl';
|
|
@@ -4,6 +4,7 @@ import { colors } from '@dhis2/ui-constants';
|
|
|
4
4
|
import cx from 'classnames';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import React from 'react';
|
|
7
|
+
import i18n from '../locales/index.js';
|
|
7
8
|
import { InputClearButton, InputPlaceholder, InputPrefix } from '../select/index.js';
|
|
8
9
|
import { SelectionList } from './selection-list.js';
|
|
9
10
|
const Input = _ref => {
|
|
@@ -18,9 +19,11 @@ const Input = _ref => {
|
|
|
18
19
|
options,
|
|
19
20
|
className,
|
|
20
21
|
disabled,
|
|
21
|
-
inputMaxHeight = '100px'
|
|
22
|
+
inputMaxHeight = '100px',
|
|
23
|
+
collapseSelectionAfter
|
|
22
24
|
} = _ref;
|
|
23
25
|
const hasSelection = selected.length > 0;
|
|
26
|
+
const shouldCollapse = hasSelection && typeof collapseSelectionAfter === 'number' && selected.length > collapseSelectionAfter;
|
|
24
27
|
const onClear = e => {
|
|
25
28
|
const data = {
|
|
26
29
|
selected: []
|
|
@@ -29,30 +32,35 @@ const Input = _ref => {
|
|
|
29
32
|
onChange(data, e);
|
|
30
33
|
};
|
|
31
34
|
return /*#__PURE__*/React.createElement("div", {
|
|
32
|
-
className: _JSXStyle.dynamic([["
|
|
35
|
+
className: _JSXStyle.dynamic([["3188585639", [colors.grey900]], ["1331770409", [inputMaxHeight]]]) + " " + (cx('root', className) || "")
|
|
33
36
|
}, /*#__PURE__*/React.createElement(InputPrefix, {
|
|
34
37
|
prefix: prefix,
|
|
35
38
|
dataTest: `${dataTest}-prefix`
|
|
36
39
|
}), !hasSelection && !prefix && /*#__PURE__*/React.createElement(InputPlaceholder, {
|
|
37
40
|
placeholder: placeholder,
|
|
38
41
|
dataTest: `${dataTest}-placeholder`
|
|
39
|
-
}), hasSelection && /*#__PURE__*/React.createElement("
|
|
40
|
-
|
|
42
|
+
}), hasSelection && shouldCollapse && /*#__PURE__*/React.createElement("span", {
|
|
43
|
+
"data-test": `${dataTest}-selection-count`,
|
|
44
|
+
className: _JSXStyle.dynamic([["3188585639", [colors.grey900]], ["1331770409", [inputMaxHeight]]]) + " " + "collapsed-selection-text"
|
|
45
|
+
}, i18n.t('{{count}} selected', {
|
|
46
|
+
count: selected.length
|
|
47
|
+
})), hasSelection && !shouldCollapse && /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: _JSXStyle.dynamic([["3188585639", [colors.grey900]], ["1331770409", [inputMaxHeight]]]) + " " + "root-input"
|
|
41
49
|
}, /*#__PURE__*/React.createElement(SelectionList, {
|
|
42
50
|
selected: selected,
|
|
43
51
|
onChange: onChange,
|
|
44
52
|
options: options,
|
|
45
53
|
disabled: disabled
|
|
46
54
|
})), hasSelection && clearable && !disabled && /*#__PURE__*/React.createElement("div", {
|
|
47
|
-
className: _JSXStyle.dynamic([["
|
|
55
|
+
className: _JSXStyle.dynamic([["3188585639", [colors.grey900]], ["1331770409", [inputMaxHeight]]]) + " " + "root-right"
|
|
48
56
|
}, /*#__PURE__*/React.createElement(InputClearButton, {
|
|
49
57
|
onClear: onClear,
|
|
50
58
|
clearText: clearText,
|
|
51
59
|
dataTest: `${dataTest}-clear`
|
|
52
60
|
})), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
53
|
-
id: "
|
|
61
|
+
id: "3188585639",
|
|
54
62
|
dynamic: [colors.grey900]
|
|
55
|
-
}, [`.root.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:${colors.grey900};font-size:14px;line-height:16px;}`, ".root-input.__jsx-style-dynamic-selector{overflow-y:auto;-webkit-flex:1;-ms-flex:1;flex:1;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-flow:wrap;-ms-flex-flow:wrap;flex-flow:wrap;gap:4px;}", ".root-right.__jsx-style-dynamic-selector{margin-inline-start:auto;}"]), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
63
|
+
}, [`.root.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:${colors.grey900};font-size:14px;line-height:16px;}`, ".root-input.__jsx-style-dynamic-selector{overflow-y:auto;-webkit-flex:1;-ms-flex:1;flex:1;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-flow:wrap;-ms-flex-flow:wrap;flex-flow:wrap;gap:4px;}", ".root-right.__jsx-style-dynamic-selector{margin-inline-start:auto;}", ".collapsed-selection-text.__jsx-style-dynamic-selector{-webkit-flex:1;-ms-flex:1;flex:1;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}"]), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
56
64
|
id: "1331770409",
|
|
57
65
|
dynamic: [inputMaxHeight]
|
|
58
66
|
}, [`.root-input.__jsx-style-dynamic-selector{max-height:${inputMaxHeight};}`]));
|
|
@@ -62,6 +70,7 @@ Input.propTypes = {
|
|
|
62
70
|
className: PropTypes.string,
|
|
63
71
|
clearText: requiredIf(props => props.clearable, PropTypes.string),
|
|
64
72
|
clearable: PropTypes.bool,
|
|
73
|
+
collapseSelectionAfter: PropTypes.number,
|
|
65
74
|
disabled: PropTypes.bool,
|
|
66
75
|
inputMaxHeight: PropTypes.string,
|
|
67
76
|
options: PropTypes.node,
|
|
@@ -39,6 +39,7 @@ const MultiSelect = _ref => {
|
|
|
39
39
|
noMatchText,
|
|
40
40
|
initialFocus,
|
|
41
41
|
dense,
|
|
42
|
+
collapseSelectionAfter,
|
|
42
43
|
dataTest = 'dhis2-uicore-multiselect'
|
|
43
44
|
} = _ref;
|
|
44
45
|
// If the select is filterable, use a filterable menu
|
|
@@ -65,7 +66,8 @@ const MultiSelect = _ref => {
|
|
|
65
66
|
dataTest: dataTest,
|
|
66
67
|
placeholder: placeholder,
|
|
67
68
|
prefix: prefix,
|
|
68
|
-
inputMaxHeight: inputMaxHeight
|
|
69
|
+
inputMaxHeight: inputMaxHeight,
|
|
70
|
+
collapseSelectionAfter: collapseSelectionAfter
|
|
69
71
|
}),
|
|
70
72
|
menu: menu,
|
|
71
73
|
tabIndex: tabIndex,
|
|
@@ -99,6 +101,8 @@ MultiSelect.propTypes = {
|
|
|
99
101
|
clearText: requiredIf(props => props.clearable, PropTypes.string),
|
|
100
102
|
/** Adds a 'clear' option to the menu */
|
|
101
103
|
clearable: PropTypes.bool,
|
|
104
|
+
/** When the number of selected items exceeds this threshold, chips are replaced with "X selected" text */
|
|
105
|
+
collapseSelectionAfter: PropTypes.number,
|
|
102
106
|
dataTest: PropTypes.string,
|
|
103
107
|
dense: PropTypes.bool,
|
|
104
108
|
disabled: PropTypes.bool,
|
|
@@ -494,6 +494,46 @@ export const ShiftedIntoView = args => /*#__PURE__*/React.createElement(React.Fr
|
|
|
494
494
|
})), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
495
495
|
id: "1828862170"
|
|
496
496
|
}, ["html,body,#root{position:relative;height:300px !important;max-height:300px;}", "#root{padding-top:130px !important;}"]));
|
|
497
|
+
export const CollapseSelectionAfterThreshold = () => {
|
|
498
|
+
const [selected, setSelected] = React.useState(['1', '3', '5']);
|
|
499
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
500
|
+
style: {
|
|
501
|
+
maxWidth: 400
|
|
502
|
+
}
|
|
503
|
+
}, /*#__PURE__*/React.createElement(MultiSelect, {
|
|
504
|
+
className: "select",
|
|
505
|
+
selected: selected,
|
|
506
|
+
onChange: _ref3 => {
|
|
507
|
+
let {
|
|
508
|
+
selected
|
|
509
|
+
} = _ref3;
|
|
510
|
+
return setSelected(selected);
|
|
511
|
+
},
|
|
512
|
+
collapseSelectionAfter: 2,
|
|
513
|
+
prefix: "Prefix text",
|
|
514
|
+
clearable: true,
|
|
515
|
+
clearText: "Clear all"
|
|
516
|
+
}, /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
517
|
+
value: "1",
|
|
518
|
+
label: "option one"
|
|
519
|
+
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
520
|
+
value: "2",
|
|
521
|
+
label: "option two"
|
|
522
|
+
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
523
|
+
value: "3",
|
|
524
|
+
label: "option three"
|
|
525
|
+
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
526
|
+
value: "4",
|
|
527
|
+
label: "option four"
|
|
528
|
+
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
529
|
+
value: "5",
|
|
530
|
+
label: "option five"
|
|
531
|
+
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
532
|
+
value: "6",
|
|
533
|
+
label: "option six"
|
|
534
|
+
})));
|
|
535
|
+
};
|
|
536
|
+
CollapseSelectionAfterThreshold.storyName = 'Collapse selection after threshold';
|
|
497
537
|
export const RTL = args => {
|
|
498
538
|
useEffect(() => {
|
|
499
539
|
document.body.dir = 'rtl';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/select",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.13.0",
|
|
4
4
|
"description": "UI Select",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,21 +33,21 @@
|
|
|
33
33
|
"styled-jsx": "^4"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@dhis2-ui/box": "10.
|
|
37
|
-
"@dhis2-ui/button": "10.
|
|
38
|
-
"@dhis2-ui/card": "10.
|
|
39
|
-
"@dhis2-ui/checkbox": "10.
|
|
40
|
-
"@dhis2-ui/chip": "10.
|
|
41
|
-
"@dhis2-ui/field": "10.
|
|
42
|
-
"@dhis2-ui/input": "10.
|
|
43
|
-
"@dhis2-ui/layer": "10.
|
|
44
|
-
"@dhis2-ui/loader": "10.
|
|
45
|
-
"@dhis2-ui/popper": "10.
|
|
46
|
-
"@dhis2-ui/status-icon": "10.
|
|
47
|
-
"@dhis2-ui/tooltip": "10.
|
|
36
|
+
"@dhis2-ui/box": "10.13.0",
|
|
37
|
+
"@dhis2-ui/button": "10.13.0",
|
|
38
|
+
"@dhis2-ui/card": "10.13.0",
|
|
39
|
+
"@dhis2-ui/checkbox": "10.13.0",
|
|
40
|
+
"@dhis2-ui/chip": "10.13.0",
|
|
41
|
+
"@dhis2-ui/field": "10.13.0",
|
|
42
|
+
"@dhis2-ui/input": "10.13.0",
|
|
43
|
+
"@dhis2-ui/layer": "10.13.0",
|
|
44
|
+
"@dhis2-ui/loader": "10.13.0",
|
|
45
|
+
"@dhis2-ui/popper": "10.13.0",
|
|
46
|
+
"@dhis2-ui/status-icon": "10.13.0",
|
|
47
|
+
"@dhis2-ui/tooltip": "10.13.0",
|
|
48
48
|
"@dhis2/prop-types": "^3.1.2",
|
|
49
|
-
"@dhis2/ui-constants": "10.
|
|
50
|
-
"@dhis2/ui-icons": "10.
|
|
49
|
+
"@dhis2/ui-constants": "10.13.0",
|
|
50
|
+
"@dhis2/ui-icons": "10.13.0",
|
|
51
51
|
"classnames": "^2.3.1",
|
|
52
52
|
"prop-types": "^15.7.2"
|
|
53
53
|
},
|
package/types/index.d.ts
CHANGED
|
@@ -51,6 +51,10 @@ export interface MultiSelectProps {
|
|
|
51
51
|
* Adds a 'clear' option to the menu
|
|
52
52
|
*/
|
|
53
53
|
clearable?: boolean
|
|
54
|
+
/**
|
|
55
|
+
* When the number of selected items exceeds this threshold, chips are replaced with "X selected" text
|
|
56
|
+
*/
|
|
57
|
+
collapseSelectionAfter?: number
|
|
54
58
|
dataTest?: string
|
|
55
59
|
dense?: boolean
|
|
56
60
|
disabled?: boolean
|