@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.
- package/build/cjs/index.js +0 -6
- package/build/cjs/locales/index.js +3 -69
- package/build/cjs/multi-select/__tests__/multi-select.test.js +1 -7
- package/build/cjs/multi-select/__tests__/selection-list.test.js +7 -18
- package/build/cjs/multi-select/features/accepts_blur_cb/index.js +1 -2
- package/build/cjs/multi-select/features/accepts_focus_cb/index.js +1 -2
- package/build/cjs/multi-select/features/accepts_initial_focus/index.js +1 -2
- package/build/cjs/multi-select/features/accepts_loading/index.js +0 -1
- package/build/cjs/multi-select/features/accepts_max_height/index.js +1 -2
- package/build/cjs/multi-select/features/accepts_placeholder/index.js +0 -1
- package/build/cjs/multi-select/features/accepts_prefix/index.js +0 -1
- package/build/cjs/multi-select/features/allows_invalid_options/index.js +0 -1
- package/build/cjs/multi-select/features/allows_selecting/index.js +2 -3
- package/build/cjs/multi-select/features/can_be_cleared/index.js +1 -2
- package/build/cjs/multi-select/features/can_be_disabled/index.js +0 -1
- package/build/cjs/multi-select/features/can_be_empty/index.js +0 -1
- package/build/cjs/multi-select/features/can_be_filtered/index.js +0 -1
- package/build/cjs/multi-select/features/can_be_opened_and_closed/index.js +0 -1
- package/build/cjs/multi-select/features/common/index.js +2 -3
- package/build/cjs/multi-select/features/duplicate_option_values/index.js +0 -1
- package/build/cjs/multi-select/features/menu_width_matches_input/index.js +1 -2
- package/build/cjs/multi-select/features/position/index.js +4 -5
- package/build/cjs/multi-select/features/position.feature +0 -1
- package/build/cjs/multi-select/features/shows_selections/index.js +0 -1
- package/build/cjs/multi-select/filterable-menu.js +1 -8
- package/build/cjs/multi-select/index.js +0 -1
- package/build/cjs/multi-select/input.js +6 -19
- package/build/cjs/multi-select/menu.js +16 -23
- package/build/cjs/multi-select/multi-select.e2e.stories.js +675 -0
- package/build/cjs/multi-select/multi-select.js +4 -21
- package/build/cjs/multi-select/{multi-select.stories.js → multi-select.prod.stories.js} +62 -101
- package/build/cjs/multi-select/selection-list.js +10 -18
- package/build/cjs/multi-select-field/__tests__/multi-select-field.test.js +1 -7
- package/build/cjs/multi-select-field/features/accepts_help_text/index.js +0 -1
- package/build/cjs/multi-select-field/features/accepts_label/index.js +0 -1
- package/build/cjs/multi-select-field/features/accepts_validation_text/index.js +0 -1
- package/build/cjs/multi-select-field/features/can_be_required/index.js +0 -1
- package/build/cjs/multi-select-field/features/has_default_clear_text/index.js +0 -1
- package/build/cjs/multi-select-field/features/has_default_empty_text/index.js +0 -1
- package/build/cjs/multi-select-field/features/has_default_filter_nomatch_text/index.js +0 -1
- package/build/cjs/multi-select-field/features/has_default_filter_placeholder/index.js +0 -1
- package/build/cjs/multi-select-field/features/has_default_loading_text/index.js +0 -1
- package/build/cjs/multi-select-field/index.js +0 -1
- package/build/cjs/multi-select-field/multi-select-field.e2e.stories.js +89 -0
- package/build/cjs/multi-select-field/multi-select-field.js +10 -51
- package/build/cjs/multi-select-field/{multi-select-field.stories.js → multi-select-field.prod.stories.js} +31 -39
- package/build/cjs/multi-select-option/index.js +0 -1
- package/build/cjs/multi-select-option/multi-select-option.js +4 -14
- package/build/cjs/select/__tests__/select.test.js +1 -7
- package/build/cjs/select/debounce/debounce.js +1 -8
- package/build/cjs/select/debounce/debounce.spec.js +0 -1
- package/build/cjs/select/empty.js +2 -9
- package/build/cjs/select/filter-input.js +3 -11
- package/build/cjs/select/filterable-menu.js +15 -29
- package/build/cjs/select/index.js +0 -8
- package/build/cjs/select/input-clear-button.js +3 -11
- package/build/cjs/select/input-placeholder.js +2 -11
- package/build/cjs/select/input-prefix.js +2 -11
- package/build/cjs/select/input-wrapper.js +2 -11
- package/build/cjs/select/loading.js +3 -12
- package/build/cjs/select/menu-wrapper.js +4 -13
- package/build/cjs/select/no-match.js +2 -9
- package/build/cjs/select/option-helpers.js +9 -18
- package/build/cjs/select/select.js +23 -69
- package/build/cjs/single-select/__tests__/selection.test.js +7 -18
- package/build/cjs/single-select/__tests__/single-select.test.js +1 -7
- package/build/cjs/single-select/features/accepts_blur_cb/index.js +1 -2
- package/build/cjs/single-select/features/accepts_focus_cb/index.js +1 -2
- package/build/cjs/single-select/features/accepts_initial_focus/index.js +1 -2
- package/build/cjs/single-select/features/accepts_loading/index.js +0 -1
- package/build/cjs/single-select/features/accepts_max_height/index.js +1 -2
- package/build/cjs/single-select/features/accepts_placeholder/index.js +0 -1
- package/build/cjs/single-select/features/accepts_prefix/index.js +0 -1
- package/build/cjs/single-select/features/allows_invalid_options/index.js +0 -1
- package/build/cjs/single-select/features/allows_selecting/index.js +2 -3
- package/build/cjs/single-select/features/can_be_cleared/index.js +1 -2
- package/build/cjs/single-select/features/can_be_disabled/index.js +0 -1
- package/build/cjs/single-select/features/can_be_empty/index.js +0 -1
- package/build/cjs/single-select/features/can_be_filtered/index.js +0 -1
- package/build/cjs/single-select/features/can_be_opened_and_closed/index.js +0 -1
- package/build/cjs/single-select/features/common/index.js +2 -3
- package/build/cjs/single-select/features/duplicate_option_values/index.js +0 -1
- package/build/cjs/single-select/features/menu_width_matches_input/index.js +1 -2
- package/build/cjs/single-select/features/position/index.js +3 -4
- package/build/cjs/single-select/features/shows_selections/index.js +0 -1
- package/build/cjs/single-select/filterable-menu.js +1 -8
- package/build/cjs/single-select/index.js +0 -1
- package/build/cjs/single-select/input.js +6 -19
- package/build/cjs/single-select/menu.js +12 -21
- package/build/cjs/single-select/selection.js +5 -17
- package/build/cjs/single-select/single-select.e2e.stories.js +633 -0
- package/build/cjs/single-select/single-select.js +4 -25
- package/build/cjs/single-select/{single-select.stories.js → single-select.prod.stories.js} +58 -95
- package/build/cjs/single-select-field/__tests__/single-select-field.test.js +1 -7
- package/build/cjs/single-select-field/features/accepts_help_text/index.js +0 -1
- package/build/cjs/single-select-field/features/accepts_label/index.js +0 -1
- package/build/cjs/single-select-field/features/accepts_validation_text/index.js +0 -1
- package/build/cjs/single-select-field/features/can_be_required/index.js +0 -1
- package/build/cjs/single-select-field/features/has_default_clear_text/index.js +0 -1
- package/build/cjs/single-select-field/features/has_default_empty_text/index.js +0 -1
- package/build/cjs/single-select-field/features/has_default_filter_nomatch_text/index.js +0 -1
- package/build/cjs/single-select-field/features/has_default_filter_placeholder/index.js +0 -1
- package/build/cjs/single-select-field/features/has_default_loading_text/index.js +0 -1
- package/build/cjs/single-select-field/index.js +0 -1
- package/build/cjs/single-select-field/single-select-field.e2e.stories.js +89 -0
- package/build/cjs/single-select-field/single-select-field.js +10 -51
- package/build/cjs/single-select-field/{single-select-field.stories.js → single-select-field.prod.stories.js} +31 -39
- package/build/cjs/single-select-option/index.js +0 -1
- package/build/cjs/single-select-option/single-select-option.js +2 -10
- package/build/es/multi-select/__tests__/selection-list.test.js +6 -3
- package/build/es/multi-select/features/accepts_blur_cb/index.js +1 -1
- package/build/es/multi-select/features/accepts_focus_cb/index.js +1 -1
- package/build/es/multi-select/features/accepts_initial_focus/index.js +1 -1
- package/build/es/multi-select/features/accepts_max_height/index.js +1 -1
- package/build/es/multi-select/features/allows_selecting/index.js +2 -2
- package/build/es/multi-select/features/can_be_cleared/index.js +1 -1
- package/build/es/multi-select/features/common/index.js +2 -2
- package/build/es/multi-select/features/menu_width_matches_input/index.js +1 -1
- package/build/es/multi-select/features/position/index.js +4 -4
- package/build/es/multi-select/features/position.feature +0 -1
- package/build/es/multi-select/filterable-menu.js +0 -2
- package/build/es/multi-select/input.js +5 -9
- package/build/es/multi-select/menu.js +15 -17
- package/build/es/multi-select/{multi-select.stories.e2e.js → multi-select.e2e.stories.js} +74 -42
- package/build/es/multi-select/multi-select.js +3 -9
- package/build/es/multi-select/{multi-select.stories.js → multi-select.prod.stories.js} +40 -24
- package/build/es/multi-select/selection-list.js +9 -12
- package/build/es/multi-select-field/{multi-select-field.stories.e2e.js → multi-select-field.e2e.stories.js} +18 -9
- package/build/es/multi-select-field/multi-select-field.js +4 -35
- package/build/es/multi-select-field/{multi-select-field.stories.js → multi-select-field.prod.stories.js} +19 -9
- package/build/es/multi-select-option/multi-select-option.js +3 -5
- package/build/es/select/debounce/debounce.js +1 -6
- package/build/es/select/empty.js +1 -3
- package/build/es/select/filter-input.js +2 -4
- package/build/es/select/filterable-menu.js +12 -15
- package/build/es/select/input-clear-button.js +2 -4
- package/build/es/select/input-placeholder.js +1 -5
- package/build/es/select/input-prefix.js +1 -5
- package/build/es/select/input-wrapper.js +1 -3
- package/build/es/select/loading.js +2 -2
- package/build/es/select/menu-wrapper.js +3 -5
- package/build/es/select/no-match.js +1 -3
- package/build/es/select/option-helpers.js +10 -6
- package/build/es/select/select.js +22 -51
- package/build/es/single-select/__tests__/selection.test.js +6 -3
- package/build/es/single-select/features/accepts_blur_cb/index.js +1 -1
- package/build/es/single-select/features/accepts_focus_cb/index.js +1 -1
- package/build/es/single-select/features/accepts_initial_focus/index.js +1 -1
- package/build/es/single-select/features/accepts_max_height/index.js +1 -1
- package/build/es/single-select/features/allows_selecting/index.js +2 -2
- package/build/es/single-select/features/can_be_cleared/index.js +1 -1
- package/build/es/single-select/features/common/index.js +2 -2
- package/build/es/single-select/features/menu_width_matches_input/index.js +1 -1
- package/build/es/single-select/features/position/index.js +3 -3
- package/build/es/single-select/input.js +5 -9
- package/build/es/single-select/menu.js +11 -15
- package/build/es/single-select/selection.js +4 -9
- package/build/es/single-select/{single-select.stories.e2e.js → single-select.e2e.stories.js} +68 -38
- package/build/es/single-select/single-select.js +3 -13
- package/build/es/single-select/{single-select.stories.js → single-select.prod.stories.js} +37 -24
- package/build/es/single-select-field/{single-select-field.stories.e2e.js → single-select-field.e2e.stories.js} +18 -9
- package/build/es/single-select-field/single-select-field.js +4 -35
- package/build/es/single-select-field/{single-select-field.stories.js → single-select-field.prod.stories.js} +19 -9
- package/build/es/single-select-option/single-select-option.js +1 -3
- package/package.json +18 -18
- package/build/cjs/multi-select/multi-select.stories.e2e.js +0 -618
- package/build/cjs/multi-select-field/multi-select-field.stories.e2e.js +0 -73
- package/build/cjs/single-select/single-select.stories.e2e.js +0 -579
- package/build/cjs/single-select-field/single-select-field.stories.e2e.js +0 -73
|
@@ -4,29 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.MultiSelect = void 0;
|
|
7
|
-
|
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
|
-
var _statusIcon = require("@dhis2-ui/status-icon");
|
|
11
|
-
|
|
12
8
|
var _propTypes = require("@dhis2/prop-types");
|
|
13
|
-
|
|
14
9
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
15
|
-
|
|
10
|
+
var _statusIcon = require("@dhis2-ui/status-icon");
|
|
16
11
|
var _propTypes2 = _interopRequireDefault(require("prop-types"));
|
|
17
|
-
|
|
18
12
|
var _react = _interopRequireDefault(require("react"));
|
|
19
|
-
|
|
20
13
|
var _index = require("../select/index.js");
|
|
21
|
-
|
|
22
14
|
var _filterableMenu = require("./filterable-menu.js");
|
|
23
|
-
|
|
24
15
|
var _input = require("./input.js");
|
|
25
|
-
|
|
26
16
|
var _menu = require("./menu.js");
|
|
27
|
-
|
|
28
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
-
|
|
17
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
30
18
|
const MultiSelect = _ref => {
|
|
31
19
|
let {
|
|
32
20
|
className,
|
|
@@ -98,7 +86,7 @@ const MultiSelect = _ref => {
|
|
|
98
86
|
dense: dense
|
|
99
87
|
}, children, loading && /*#__PURE__*/_react.default.createElement(_index.Loading, {
|
|
100
88
|
message: loadingText,
|
|
101
|
-
dataTest:
|
|
89
|
+
dataTest: `${dataTest}-loading`
|
|
102
90
|
}))), /*#__PURE__*/_react.default.createElement(_statusIcon.StatusIcon, {
|
|
103
91
|
error: error,
|
|
104
92
|
valid: valid,
|
|
@@ -106,9 +94,8 @@ const MultiSelect = _ref => {
|
|
|
106
94
|
}), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
107
95
|
id: "2180377457",
|
|
108
96
|
dynamic: [_uiConstants.spacers.dp8]
|
|
109
|
-
}, [
|
|
97
|
+
}, [`.root.__jsx-style-dynamic-selector{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:${_uiConstants.spacers.dp8};}`, ".root-input.__jsx-style-dynamic-selector{-webkit-flex:1;-ms-flex:1;flex:1;}"]));
|
|
110
98
|
};
|
|
111
|
-
|
|
112
99
|
exports.MultiSelect = MultiSelect;
|
|
113
100
|
MultiSelect.defaultProps = {
|
|
114
101
|
selected: [],
|
|
@@ -117,10 +104,8 @@ MultiSelect.defaultProps = {
|
|
|
117
104
|
MultiSelect.propTypes = {
|
|
118
105
|
children: _propTypes2.default.node,
|
|
119
106
|
className: _propTypes2.default.string,
|
|
120
|
-
|
|
121
107
|
/** Required if `clearable` prop is `true` */
|
|
122
108
|
clearText: (0, _propTypes.requiredIf)(props => props.clearable, _propTypes2.default.string),
|
|
123
|
-
|
|
124
109
|
/** Adds a 'clear' option to the menu */
|
|
125
110
|
clearable: _propTypes2.default.bool,
|
|
126
111
|
dataTest: _propTypes2.default.string,
|
|
@@ -129,7 +114,6 @@ MultiSelect.propTypes = {
|
|
|
129
114
|
empty: _propTypes2.default.node,
|
|
130
115
|
error: _uiConstants.sharedPropTypes.statusPropType,
|
|
131
116
|
filterPlaceholder: _propTypes2.default.string,
|
|
132
|
-
|
|
133
117
|
/** Adds a 'filter' field to the menu */
|
|
134
118
|
filterable: _propTypes2.default.bool,
|
|
135
119
|
initialFocus: _propTypes2.default.bool,
|
|
@@ -137,7 +121,6 @@ MultiSelect.propTypes = {
|
|
|
137
121
|
loading: _propTypes2.default.bool,
|
|
138
122
|
loadingText: _propTypes2.default.string,
|
|
139
123
|
maxHeight: _propTypes2.default.string,
|
|
140
|
-
|
|
141
124
|
/** Required if `filterable` prop is `true` */
|
|
142
125
|
noMatchText: (0, _propTypes.requiredIf)(props => props.filterable, _propTypes2.default.string),
|
|
143
126
|
placeholder: _propTypes2.default.string,
|
|
@@ -4,36 +4,35 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
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;
|
|
7
|
-
|
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
8
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
11
|
-
|
|
12
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
-
|
|
16
11
|
var _index = require("../index.js");
|
|
17
|
-
|
|
18
12
|
var _index2 = require("./index.js");
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
const description = `
|
|
17
|
+
Multiple selection allows the user to select more than one option from the list. Checkboxes are used to highlight the possibility of making more than one selection. Selected options are displayed as chips inside the input. Make sure to communicate clearly to the user if there is a limit to the number of selectable elements.
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
Use multiple selection wherever the user needs to make more than one selection. If the multiple selection is complex, requires a defined order or needs to made from different groups, consider using a transfer component instead.
|
|
23
20
|
|
|
24
|
-
|
|
21
|
+
Read more about using \`Select\` components at [Design System: Select](https://github.com/dhis2/design-system/blob/master/molecules/select.md).
|
|
25
22
|
|
|
26
|
-
|
|
23
|
+
\`\`\`js
|
|
24
|
+
import { MultiSelect, MultiSelectOption } from '@dhis2/ui'
|
|
25
|
+
\`\`\`
|
|
27
26
|
|
|
27
|
+
_**Note:** Due to demo limitations on this page, only one representative example is rendered here. For more (props-interactive) examples, see individual stories in the 'Canvas' tab._
|
|
28
|
+
`;
|
|
28
29
|
const eventHandler = handlerName => (payload, event) => {
|
|
29
|
-
console.log(
|
|
30
|
-
console.log(
|
|
30
|
+
console.log(`${handlerName} payload`, payload);
|
|
31
|
+
console.log(`${handlerName} event`, event);
|
|
31
32
|
};
|
|
32
|
-
|
|
33
33
|
const onChange = eventHandler('onChange');
|
|
34
34
|
const onFocus = eventHandler('onFocus');
|
|
35
35
|
const onBlur = eventHandler('onBlur');
|
|
36
|
-
|
|
37
36
|
const CustomMultiSelectOption = _ref => {
|
|
38
37
|
let {
|
|
39
38
|
label,
|
|
@@ -43,7 +42,6 @@ const CustomMultiSelectOption = _ref => {
|
|
|
43
42
|
onClick: e => onClick({}, e)
|
|
44
43
|
}, label);
|
|
45
44
|
};
|
|
46
|
-
|
|
47
45
|
CustomMultiSelectOption.propTypes = {
|
|
48
46
|
label: _propTypes.default.string,
|
|
49
47
|
onClick: _propTypes.default.func
|
|
@@ -58,7 +56,7 @@ const requiredIfArgType = {
|
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
58
|
};
|
|
61
|
-
var _default = {
|
|
59
|
+
var _default = exports.default = {
|
|
62
60
|
title: 'Multi Select',
|
|
63
61
|
component: _index2.MultiSelect,
|
|
64
62
|
parameters: {
|
|
@@ -80,20 +78,23 @@ var _default = {
|
|
|
80
78
|
onChange
|
|
81
79
|
},
|
|
82
80
|
argTypes: {
|
|
83
|
-
valid: {
|
|
81
|
+
valid: {
|
|
82
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
84
83
|
},
|
|
85
|
-
warning: {
|
|
84
|
+
warning: {
|
|
85
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
86
86
|
},
|
|
87
|
-
error: {
|
|
87
|
+
error: {
|
|
88
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
88
89
|
},
|
|
89
|
-
clearText: {
|
|
90
|
+
clearText: {
|
|
91
|
+
...requiredIfArgType
|
|
90
92
|
},
|
|
91
|
-
noMatchText: {
|
|
93
|
+
noMatchText: {
|
|
94
|
+
...requiredIfArgType
|
|
92
95
|
}
|
|
93
96
|
}
|
|
94
97
|
};
|
|
95
|
-
exports.default = _default;
|
|
96
|
-
|
|
97
98
|
const WithOptionsTemplate = args => /*#__PURE__*/_react.default.createElement(_index2.MultiSelect, args, /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
98
99
|
value: "1",
|
|
99
100
|
label: "option one"
|
|
@@ -104,37 +105,30 @@ const WithOptionsTemplate = args => /*#__PURE__*/_react.default.createElement(_i
|
|
|
104
105
|
value: "3",
|
|
105
106
|
label: "option three"
|
|
106
107
|
}));
|
|
107
|
-
|
|
108
108
|
const EmptyTemplate = args => /*#__PURE__*/_react.default.createElement(_index2.MultiSelect, args);
|
|
109
|
-
|
|
110
|
-
const WithOptionsAndOnChange = WithOptionsTemplate.bind({});
|
|
111
|
-
exports.WithOptionsAndOnChange = WithOptionsAndOnChange;
|
|
109
|
+
const WithOptionsAndOnChange = exports.WithOptionsAndOnChange = WithOptionsTemplate.bind({});
|
|
112
110
|
WithOptionsAndOnChange.storyName = 'With options and onChange';
|
|
113
|
-
const WithOptionsAndASelection = WithOptionsTemplate.bind({});
|
|
114
|
-
exports.WithOptionsAndASelection = WithOptionsAndASelection;
|
|
111
|
+
const WithOptionsAndASelection = exports.WithOptionsAndASelection = WithOptionsTemplate.bind({});
|
|
115
112
|
WithOptionsAndASelection.args = {
|
|
116
113
|
selected: ['1']
|
|
117
|
-
};
|
|
118
|
-
|
|
114
|
+
};
|
|
115
|
+
// Enable this story as the primary for the docs page
|
|
119
116
|
WithOptionsAndASelection.parameters = {
|
|
120
117
|
docs: {
|
|
121
118
|
disable: false
|
|
122
119
|
}
|
|
123
120
|
};
|
|
124
121
|
WithOptionsAndASelection.storyName = 'With options and a selection';
|
|
125
|
-
const WithOnFocus = WithOptionsTemplate.bind({});
|
|
126
|
-
exports.WithOnFocus = WithOnFocus;
|
|
122
|
+
const WithOnFocus = exports.WithOnFocus = WithOptionsTemplate.bind({});
|
|
127
123
|
WithOnFocus.args = {
|
|
128
124
|
onFocus
|
|
129
125
|
};
|
|
130
|
-
WithOnFocus.storyName = 'With
|
|
131
|
-
const WithOnBlur = WithOptionsTemplate.bind({});
|
|
132
|
-
exports.WithOnBlur = WithOnBlur;
|
|
126
|
+
WithOnFocus.storyName = 'With on focus';
|
|
127
|
+
const WithOnBlur = exports.WithOnBlur = WithOptionsTemplate.bind({});
|
|
133
128
|
WithOnBlur.args = {
|
|
134
129
|
onBlur
|
|
135
130
|
};
|
|
136
131
|
WithOnBlur.storyName = 'With onBlur';
|
|
137
|
-
|
|
138
132
|
const WithCustomOptionsAndOnChange = args => /*#__PURE__*/_react.default.createElement(_index2.MultiSelect, args, /*#__PURE__*/_react.default.createElement(CustomMultiSelectOption, {
|
|
139
133
|
value: "1",
|
|
140
134
|
label: "option one"
|
|
@@ -145,10 +139,8 @@ const WithCustomOptionsAndOnChange = args => /*#__PURE__*/_react.default.createE
|
|
|
145
139
|
value: "3",
|
|
146
140
|
label: "option three"
|
|
147
141
|
}));
|
|
148
|
-
|
|
149
142
|
exports.WithCustomOptionsAndOnChange = WithCustomOptionsAndOnChange;
|
|
150
143
|
WithCustomOptionsAndOnChange.storyName = 'With custom options and onChange';
|
|
151
|
-
|
|
152
144
|
const WithInvalidOptions = args => /*#__PURE__*/_react.default.createElement(_index2.MultiSelect, args, /*#__PURE__*/_react.default.createElement("div", null, "invalid one"), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
153
145
|
value: "1",
|
|
154
146
|
label: "option one"
|
|
@@ -159,9 +151,7 @@ const WithInvalidOptions = args => /*#__PURE__*/_react.default.createElement(_in
|
|
|
159
151
|
value: "3",
|
|
160
152
|
label: "option three"
|
|
161
153
|
}), null, undefined, false);
|
|
162
|
-
|
|
163
154
|
exports.WithInvalidOptions = WithInvalidOptions;
|
|
164
|
-
|
|
165
155
|
const WithInvalidFilterableOptions = args => /*#__PURE__*/_react.default.createElement(_index2.MultiSelect, args, /*#__PURE__*/_react.default.createElement("div", null, "invalid one"), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
166
156
|
value: "1",
|
|
167
157
|
label: "option one"
|
|
@@ -172,14 +162,12 @@ const WithInvalidFilterableOptions = args => /*#__PURE__*/_react.default.createE
|
|
|
172
162
|
value: "3",
|
|
173
163
|
label: "option three"
|
|
174
164
|
}));
|
|
175
|
-
|
|
176
165
|
exports.WithInvalidFilterableOptions = WithInvalidFilterableOptions;
|
|
177
166
|
WithInvalidFilterableOptions.args = {
|
|
178
167
|
filterable: true,
|
|
179
168
|
noMatchText: 'No match found'
|
|
180
169
|
};
|
|
181
|
-
const WithInitialFocus = EmptyTemplate.bind({});
|
|
182
|
-
exports.WithInitialFocus = WithInitialFocus;
|
|
170
|
+
const WithInitialFocus = exports.WithInitialFocus = EmptyTemplate.bind({});
|
|
183
171
|
WithInitialFocus.args = {
|
|
184
172
|
initialFocus: true
|
|
185
173
|
};
|
|
@@ -188,47 +176,40 @@ WithInitialFocus.parameters = {
|
|
|
188
176
|
disable: true
|
|
189
177
|
}
|
|
190
178
|
};
|
|
191
|
-
WithInitialFocus.storyName = 'With
|
|
192
|
-
const Dense = WithOptionsTemplate.bind({});
|
|
193
|
-
exports.Dense = Dense;
|
|
179
|
+
WithInitialFocus.storyName = 'With initial focus';
|
|
180
|
+
const Dense = exports.Dense = WithOptionsTemplate.bind({});
|
|
194
181
|
Dense.args = {
|
|
195
182
|
dense: true,
|
|
196
183
|
placeholder: 'Dense sized multi select'
|
|
197
184
|
};
|
|
198
185
|
Dense.storyName = 'Dense';
|
|
199
|
-
const DenseWithSelections = WithOptionsTemplate.bind({});
|
|
200
|
-
exports.DenseWithSelections = DenseWithSelections;
|
|
186
|
+
const DenseWithSelections = exports.DenseWithSelections = WithOptionsTemplate.bind({});
|
|
201
187
|
DenseWithSelections.args = {
|
|
202
188
|
dense: true,
|
|
203
189
|
selected: ['1', '2']
|
|
204
190
|
};
|
|
205
191
|
DenseWithSelections.storyName = 'Dense with selections';
|
|
206
|
-
const Empty = EmptyTemplate.bind({});
|
|
207
|
-
exports.
|
|
208
|
-
const EmptyWithEmptyText = EmptyTemplate.bind({});
|
|
209
|
-
exports.EmptyWithEmptyText = EmptyWithEmptyText;
|
|
192
|
+
const Empty = exports.Empty = EmptyTemplate.bind({});
|
|
193
|
+
const EmptyWithEmptyText = exports.EmptyWithEmptyText = EmptyTemplate.bind({});
|
|
210
194
|
EmptyWithEmptyText.args = {
|
|
211
195
|
empty: 'Custom empty text'
|
|
212
196
|
};
|
|
213
|
-
const EmptyWithEmptyComponent = EmptyTemplate.bind({});
|
|
214
|
-
exports.EmptyWithEmptyComponent = EmptyWithEmptyComponent;
|
|
197
|
+
const EmptyWithEmptyComponent = exports.EmptyWithEmptyComponent = EmptyTemplate.bind({});
|
|
215
198
|
EmptyWithEmptyComponent.args = {
|
|
216
199
|
empty: /*#__PURE__*/_react.default.createElement("div", {
|
|
217
200
|
className: "custom-empty"
|
|
218
201
|
}, "Custom empty component")
|
|
219
202
|
};
|
|
220
|
-
const WithOptionsAndLoading = WithOptionsTemplate.bind({});
|
|
221
|
-
exports.WithOptionsAndLoading = WithOptionsAndLoading;
|
|
203
|
+
const WithOptionsAndLoading = exports.WithOptionsAndLoading = WithOptionsTemplate.bind({});
|
|
222
204
|
WithOptionsAndLoading.args = {
|
|
223
205
|
loading: true
|
|
224
206
|
};
|
|
225
|
-
const WithOptionsLoadingAndLoadingText = WithOptionsTemplate.bind({});
|
|
226
|
-
|
|
227
|
-
|
|
207
|
+
const WithOptionsLoadingAndLoadingText = exports.WithOptionsLoadingAndLoadingText = WithOptionsTemplate.bind({});
|
|
208
|
+
WithOptionsLoadingAndLoadingText.args = {
|
|
209
|
+
...WithOptionsAndLoading.args,
|
|
228
210
|
loadingText: 'Loading options'
|
|
229
211
|
};
|
|
230
212
|
WithOptionsLoadingAndLoadingText.storyName = 'With options, loading and loading text';
|
|
231
|
-
|
|
232
213
|
const WithMoreThanTenOptions = args => /*#__PURE__*/_react.default.createElement(_index2.MultiSelect, args, /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
233
214
|
value: "1",
|
|
234
215
|
label: "option one"
|
|
@@ -266,9 +247,7 @@ const WithMoreThanTenOptions = args => /*#__PURE__*/_react.default.createElement
|
|
|
266
247
|
value: "12",
|
|
267
248
|
label: "option twelve"
|
|
268
249
|
}));
|
|
269
|
-
|
|
270
250
|
exports.WithMoreThanTenOptions = WithMoreThanTenOptions;
|
|
271
|
-
|
|
272
251
|
const WithMoreThanThreeOptionsAndA100PxMaxHeight = args => /*#__PURE__*/_react.default.createElement(_index2.MultiSelect, args, /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
273
252
|
value: "1",
|
|
274
253
|
label: "option one"
|
|
@@ -306,45 +285,40 @@ const WithMoreThanThreeOptionsAndA100PxMaxHeight = args => /*#__PURE__*/_react.d
|
|
|
306
285
|
value: "12",
|
|
307
286
|
label: "option twelve"
|
|
308
287
|
}));
|
|
309
|
-
|
|
310
288
|
exports.WithMoreThanThreeOptionsAndA100PxMaxHeight = WithMoreThanThreeOptionsAndA100PxMaxHeight;
|
|
311
289
|
WithMoreThanThreeOptionsAndA100PxMaxHeight.args = {
|
|
312
290
|
maxHeight: '100px'
|
|
313
291
|
};
|
|
314
292
|
WithMoreThanThreeOptionsAndA100PxMaxHeight.storyName = 'With more than three options and a 100px max-height';
|
|
315
|
-
const WithOptionsAndDisabled = WithOptionsTemplate.bind({});
|
|
316
|
-
exports.WithOptionsAndDisabled = WithOptionsAndDisabled;
|
|
293
|
+
const WithOptionsAndDisabled = exports.WithOptionsAndDisabled = WithOptionsTemplate.bind({});
|
|
317
294
|
WithOptionsAndDisabled.args = {
|
|
318
295
|
disabled: true
|
|
319
296
|
};
|
|
320
297
|
WithOptionsAndDisabled.storyName = 'With options and disabled';
|
|
321
|
-
const WithOptionsASelectionAndDisabled = WithOptionsTemplate.bind({});
|
|
322
|
-
|
|
323
|
-
|
|
298
|
+
const WithOptionsASelectionAndDisabled = exports.WithOptionsASelectionAndDisabled = WithOptionsTemplate.bind({});
|
|
299
|
+
WithOptionsASelectionAndDisabled.args = {
|
|
300
|
+
...WithOptionsAndDisabled.args,
|
|
324
301
|
...WithOptionsAndASelection.args
|
|
325
302
|
};
|
|
326
303
|
WithOptionsASelectionAndDisabled.storyName = 'With options, a selection and disabled';
|
|
327
|
-
const WithPrefix = WithOptionsTemplate.bind({});
|
|
328
|
-
exports.WithPrefix = WithPrefix;
|
|
304
|
+
const WithPrefix = exports.WithPrefix = WithOptionsTemplate.bind({});
|
|
329
305
|
WithPrefix.args = {
|
|
330
306
|
prefix: 'Prefix text'
|
|
331
307
|
};
|
|
332
|
-
const WithPrefixAndSelection = WithOptionsTemplate.bind({});
|
|
333
|
-
|
|
334
|
-
|
|
308
|
+
const WithPrefixAndSelection = exports.WithPrefixAndSelection = WithOptionsTemplate.bind({});
|
|
309
|
+
WithPrefixAndSelection.args = {
|
|
310
|
+
...WithPrefix.args,
|
|
335
311
|
...WithOptionsAndASelection.args
|
|
336
312
|
};
|
|
337
|
-
const WithPlaceholder = WithOptionsTemplate.bind({});
|
|
338
|
-
exports.WithPlaceholder = WithPlaceholder;
|
|
313
|
+
const WithPlaceholder = exports.WithPlaceholder = WithOptionsTemplate.bind({});
|
|
339
314
|
WithPlaceholder.args = {
|
|
340
315
|
placeholder: 'Placeholder text'
|
|
341
316
|
};
|
|
342
|
-
const WithPlaceholderAndSelection = WithOptionsTemplate.bind({});
|
|
343
|
-
|
|
344
|
-
|
|
317
|
+
const WithPlaceholderAndSelection = exports.WithPlaceholderAndSelection = WithOptionsTemplate.bind({});
|
|
318
|
+
WithPlaceholderAndSelection.args = {
|
|
319
|
+
...WithPlaceholder.args,
|
|
345
320
|
...WithOptionsAndASelection.args
|
|
346
321
|
};
|
|
347
|
-
|
|
348
322
|
const WithDisabledOptionAndOnChange = args => /*#__PURE__*/_react.default.createElement(_index2.MultiSelect, args, /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
349
323
|
value: "1",
|
|
350
324
|
label: "option one"
|
|
@@ -359,18 +333,14 @@ const WithDisabledOptionAndOnChange = args => /*#__PURE__*/_react.default.create
|
|
|
359
333
|
label: "disabled option",
|
|
360
334
|
disabled: true
|
|
361
335
|
}));
|
|
362
|
-
|
|
363
336
|
exports.WithDisabledOptionAndOnChange = WithDisabledOptionAndOnChange;
|
|
364
337
|
WithDisabledOptionAndOnChange.storyName = 'With disabled option and onChange';
|
|
365
|
-
const WithOptionsAndMultipleSelections = WithOptionsTemplate.bind({});
|
|
366
|
-
exports.WithOptionsAndMultipleSelections = WithOptionsAndMultipleSelections;
|
|
338
|
+
const WithOptionsAndMultipleSelections = exports.WithOptionsAndMultipleSelections = WithOptionsTemplate.bind({});
|
|
367
339
|
WithOptionsAndMultipleSelections.args = {
|
|
368
340
|
selected: ['1', '2']
|
|
369
341
|
};
|
|
370
|
-
|
|
371
342
|
const WithMultipleSelectionsWrapped = () => {
|
|
372
343
|
const [selected, setSelected] = _react.default.useState(['1', '2', '4', '6']);
|
|
373
|
-
|
|
374
344
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
375
345
|
style: {
|
|
376
346
|
maxWidth: 300
|
|
@@ -411,20 +381,18 @@ const WithMultipleSelectionsWrapped = () => {
|
|
|
411
381
|
label: "option seven"
|
|
412
382
|
})));
|
|
413
383
|
};
|
|
414
|
-
|
|
415
384
|
exports.WithMultipleSelectionsWrapped = WithMultipleSelectionsWrapped;
|
|
416
|
-
const WithClearButtonSelectionAndOnChange = WithOptionsTemplate.bind({});
|
|
417
|
-
|
|
418
|
-
|
|
385
|
+
const WithClearButtonSelectionAndOnChange = exports.WithClearButtonSelectionAndOnChange = WithOptionsTemplate.bind({});
|
|
386
|
+
WithClearButtonSelectionAndOnChange.args = {
|
|
387
|
+
...WithOptionsAndASelection.args,
|
|
419
388
|
clearable: true,
|
|
420
389
|
clearText: 'Clear'
|
|
421
390
|
};
|
|
422
391
|
WithClearButtonSelectionAndOnChange.storyName = 'With clear button, selection and onChange';
|
|
423
|
-
const WithFilterField = WithOptionsTemplate.bind({});
|
|
424
|
-
|
|
425
|
-
|
|
392
|
+
const WithFilterField = exports.WithFilterField = WithOptionsTemplate.bind({});
|
|
393
|
+
WithFilterField.args = {
|
|
394
|
+
...WithInvalidFilterableOptions.args
|
|
426
395
|
};
|
|
427
|
-
|
|
428
396
|
const DefaultPosition = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index2.MultiSelect, args, /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
429
397
|
value: "1",
|
|
430
398
|
label: "option one"
|
|
@@ -464,9 +432,7 @@ const DefaultPosition = args => /*#__PURE__*/_react.default.createElement(_react
|
|
|
464
432
|
})), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
465
433
|
id: "2006483503"
|
|
466
434
|
}, ["#root{margin-bottom:2000px;}"]));
|
|
467
|
-
|
|
468
435
|
exports.DefaultPosition = DefaultPosition;
|
|
469
|
-
|
|
470
436
|
const FlippedPosition = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index2.MultiSelect, args, /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
471
437
|
value: "1",
|
|
472
438
|
label: "option one"
|
|
@@ -506,9 +472,7 @@ const FlippedPosition = args => /*#__PURE__*/_react.default.createElement(_react
|
|
|
506
472
|
})), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
507
473
|
id: "1520050670"
|
|
508
474
|
}, ["html,body,#root{position:relative;height:500px;max-height:500px;}", "#root{padding-top:400px !important;}"]));
|
|
509
|
-
|
|
510
475
|
exports.FlippedPosition = FlippedPosition;
|
|
511
|
-
|
|
512
476
|
const ShiftedIntoView = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index2.MultiSelect, args, /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
513
477
|
value: "1",
|
|
514
478
|
label: "option one"
|
|
@@ -548,9 +512,7 @@ const ShiftedIntoView = args => /*#__PURE__*/_react.default.createElement(_react
|
|
|
548
512
|
})), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
549
513
|
id: "1828862170"
|
|
550
514
|
}, ["html,body,#root{position:relative;height:300px !important;max-height:300px;}", "#root{padding-top:130px !important;}"]));
|
|
551
|
-
|
|
552
515
|
exports.ShiftedIntoView = ShiftedIntoView;
|
|
553
|
-
|
|
554
516
|
const RTL = args => {
|
|
555
517
|
(0, _react.useEffect)(() => {
|
|
556
518
|
document.body.dir = 'rtl';
|
|
@@ -562,7 +524,6 @@ const RTL = args => {
|
|
|
562
524
|
dir: "rtl"
|
|
563
525
|
}, /*#__PURE__*/_react.default.createElement(WithOptionsTemplate, args));
|
|
564
526
|
};
|
|
565
|
-
|
|
566
527
|
exports.RTL = RTL;
|
|
567
528
|
RTL.args = {
|
|
568
529
|
selected: ['1', '2'],
|
|
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SelectionList = void 0;
|
|
7
|
-
|
|
8
7
|
var _chip = require("@dhis2-ui/chip");
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
10
|
var _index = require("../select/index.js");
|
|
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 createRemoveHandler = _ref => {
|
|
19
13
|
let {
|
|
20
14
|
selected,
|
|
@@ -29,7 +23,6 @@ const createRemoveHandler = _ref => {
|
|
|
29
23
|
onChange(data, e);
|
|
30
24
|
};
|
|
31
25
|
};
|
|
32
|
-
|
|
33
26
|
const SelectionList = _ref2 => {
|
|
34
27
|
let {
|
|
35
28
|
selected,
|
|
@@ -40,10 +33,8 @@ const SelectionList = _ref2 => {
|
|
|
40
33
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, selected.map(value => {
|
|
41
34
|
const isProduction = process.env.NODE_ENV === 'production';
|
|
42
35
|
const selectedOption = (0, _index.findOptionChild)(value, options);
|
|
43
|
-
|
|
44
36
|
if (!selectedOption) {
|
|
45
|
-
const message =
|
|
46
|
-
|
|
37
|
+
const message = `There is no option with the value: "${value}". ` + 'Make sure that all the values passed to the selected ' + 'prop match the value of an existing option.';
|
|
47
38
|
if (isProduction) {
|
|
48
39
|
// Don't crash the app if in production
|
|
49
40
|
console.error(message);
|
|
@@ -52,13 +43,15 @@ const SelectionList = _ref2 => {
|
|
|
52
43
|
throw new Error(message);
|
|
53
44
|
}
|
|
54
45
|
}
|
|
46
|
+
const isDisabled = selectedOption ?
|
|
47
|
+
// The chip should be disabled if the option or the select are disabled
|
|
48
|
+
selectedOption.props.disabled || disabled :
|
|
49
|
+
// If there is no selected option, just look at the select
|
|
50
|
+
disabled;
|
|
51
|
+
// Use the selected value if we do not have a label
|
|
52
|
+
const label = selectedOption ? selectedOption.props.label : value;
|
|
55
53
|
|
|
56
|
-
|
|
57
|
-
selectedOption.props.disabled || disabled : // If there is no selected option, just look at the select
|
|
58
|
-
disabled; // Use the selected value if we do not have a label
|
|
59
|
-
|
|
60
|
-
const label = selectedOption ? selectedOption.props.label : value; // Create an onRemove handler, but only if it's not disabled
|
|
61
|
-
|
|
54
|
+
// Create an onRemove handler, but only if it's not disabled
|
|
62
55
|
const onRemove = isDisabled ? undefined : createRemoveHandler({
|
|
63
56
|
selected,
|
|
64
57
|
onChange,
|
|
@@ -77,7 +70,6 @@ const SelectionList = _ref2 => {
|
|
|
77
70
|
}, label);
|
|
78
71
|
}));
|
|
79
72
|
};
|
|
80
|
-
|
|
81
73
|
exports.SelectionList = SelectionList;
|
|
82
74
|
SelectionList.propTypes = {
|
|
83
75
|
disabled: _propTypes.default.bool,
|
|
@@ -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 _multiSelectField = require("../multi-select-field.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
6
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
7
|
describe('<MultiSelect />', () => {
|
|
12
8
|
it('should call the onKeyDown callback when provided', () => {
|
|
13
9
|
const onKeyDown = jest.fn();
|
|
@@ -16,13 +12,11 @@ describe('<MultiSelect />', () => {
|
|
|
16
12
|
placeholder: "placeholder",
|
|
17
13
|
onKeyDown: onKeyDown
|
|
18
14
|
}));
|
|
19
|
-
|
|
20
15
|
_react.fireEvent.keyDown(_react.screen.getByTestId('dhis2-uicore-multiselect-placeholder'), {
|
|
21
16
|
key: 'Enter',
|
|
22
17
|
code: 'Enter',
|
|
23
18
|
charCode: 13
|
|
24
19
|
});
|
|
25
|
-
|
|
26
20
|
expect(onKeyDown).toHaveBeenCalledWith({
|
|
27
21
|
selected: []
|
|
28
22
|
}, expect.objectContaining({}));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a MultiSelectField with validation text is rendered', () => {
|
|
6
5
|
cy.visitStory('MultiSelectField', 'With validation text');
|
|
7
6
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a MultiSelectField with label and a required flag is rendered', () => {
|
|
6
5
|
cy.visitStory('MultiSelectField', 'With label and required status');
|
|
7
6
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a clearable MultiSelectField with selected option is rendered', () => {
|
|
6
5
|
cy.visitStory('MultiSelectField', 'With clearable and selected option');
|
|
7
6
|
});
|