@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
|
@@ -6,7 +6,6 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { InputClearButton, InputPlaceholder, InputPrefix } from '../select/index.js';
|
|
8
8
|
import { SelectionList } from './selection-list.js';
|
|
9
|
-
|
|
10
9
|
const Input = _ref => {
|
|
11
10
|
let {
|
|
12
11
|
selected,
|
|
@@ -22,7 +21,6 @@ const Input = _ref => {
|
|
|
22
21
|
inputMaxHeight
|
|
23
22
|
} = _ref;
|
|
24
23
|
const hasSelection = selected.length > 0;
|
|
25
|
-
|
|
26
24
|
const onClear = e => {
|
|
27
25
|
const data = {
|
|
28
26
|
selected: []
|
|
@@ -30,15 +28,14 @@ const Input = _ref => {
|
|
|
30
28
|
e.stopPropagation();
|
|
31
29
|
onChange(data, e);
|
|
32
30
|
};
|
|
33
|
-
|
|
34
31
|
return /*#__PURE__*/React.createElement("div", {
|
|
35
32
|
className: _JSXStyle.dynamic([["64009541", [colors.grey900]], ["1331770409", [inputMaxHeight]]]) + " " + (cx('root', className) || "")
|
|
36
33
|
}, /*#__PURE__*/React.createElement(InputPrefix, {
|
|
37
34
|
prefix: prefix,
|
|
38
|
-
dataTest:
|
|
35
|
+
dataTest: `${dataTest}-prefix`
|
|
39
36
|
}), !hasSelection && !prefix && /*#__PURE__*/React.createElement(InputPlaceholder, {
|
|
40
37
|
placeholder: placeholder,
|
|
41
|
-
dataTest:
|
|
38
|
+
dataTest: `${dataTest}-placeholder`
|
|
42
39
|
}), hasSelection && /*#__PURE__*/React.createElement("div", {
|
|
43
40
|
className: _JSXStyle.dynamic([["64009541", [colors.grey900]], ["1331770409", [inputMaxHeight]]]) + " " + "root-input"
|
|
44
41
|
}, /*#__PURE__*/React.createElement(SelectionList, {
|
|
@@ -51,16 +48,15 @@ const Input = _ref => {
|
|
|
51
48
|
}, /*#__PURE__*/React.createElement(InputClearButton, {
|
|
52
49
|
onClear: onClear,
|
|
53
50
|
clearText: clearText,
|
|
54
|
-
dataTest:
|
|
51
|
+
dataTest: `${dataTest}-clear`
|
|
55
52
|
})), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
56
53
|
id: "64009541",
|
|
57
54
|
dynamic: [colors.grey900]
|
|
58
|
-
}, [
|
|
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, {
|
|
59
56
|
id: "1331770409",
|
|
60
57
|
dynamic: [inputMaxHeight]
|
|
61
|
-
}, [
|
|
58
|
+
}, [`.root-input.__jsx-style-dynamic-selector{max-height:${inputMaxHeight};}`]));
|
|
62
59
|
};
|
|
63
|
-
|
|
64
60
|
Input.defaultProps = {
|
|
65
61
|
inputMaxHeight: '100px'
|
|
66
62
|
};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Empty, filterIgnored, checkIfValidOption, removeOption, findOption } from '../select/index.js';
|
|
4
|
-
|
|
5
4
|
const onDisabledClick = (_, e) => {
|
|
6
5
|
e.stopPropagation();
|
|
7
6
|
e.preventDefault();
|
|
8
7
|
};
|
|
9
|
-
|
|
10
8
|
const createHandler = _ref => {
|
|
11
9
|
let {
|
|
12
10
|
isActive,
|
|
@@ -15,24 +13,24 @@ const createHandler = _ref => {
|
|
|
15
13
|
value
|
|
16
14
|
} = _ref;
|
|
17
15
|
return (_, e) => {
|
|
18
|
-
e.stopPropagation();
|
|
16
|
+
e.stopPropagation();
|
|
19
17
|
|
|
18
|
+
// If the option is currently selected remove it from the array of selected options
|
|
20
19
|
if (isActive) {
|
|
21
20
|
const filtered = removeOption(value, selected);
|
|
22
21
|
const data = {
|
|
23
22
|
selected: filtered
|
|
24
23
|
};
|
|
25
24
|
return onChange(data, e);
|
|
26
|
-
}
|
|
27
|
-
|
|
25
|
+
}
|
|
28
26
|
|
|
27
|
+
// Otherwise, add it to selected
|
|
29
28
|
const data = {
|
|
30
29
|
selected: selected.concat([value])
|
|
31
30
|
};
|
|
32
31
|
return onChange(data, e);
|
|
33
32
|
};
|
|
34
33
|
};
|
|
35
|
-
|
|
36
34
|
const Menu = _ref2 => {
|
|
37
35
|
let {
|
|
38
36
|
options,
|
|
@@ -42,35 +40,35 @@ const Menu = _ref2 => {
|
|
|
42
40
|
dataTest
|
|
43
41
|
} = _ref2;
|
|
44
42
|
const renderedOptions = filterIgnored(options);
|
|
45
|
-
|
|
46
43
|
if (React.Children.count(renderedOptions) === 0) {
|
|
47
44
|
// If it's a string, supply it to our <Empty> component so it looks better
|
|
48
45
|
if (typeof empty === 'string') {
|
|
49
46
|
return /*#__PURE__*/React.createElement(Empty, {
|
|
50
47
|
message: empty,
|
|
51
|
-
dataTest:
|
|
48
|
+
dataTest: `${dataTest}-empty`
|
|
52
49
|
});
|
|
53
|
-
}
|
|
54
|
-
|
|
50
|
+
}
|
|
55
51
|
|
|
52
|
+
// Otherwise just render the supplied markup
|
|
56
53
|
return empty;
|
|
57
54
|
}
|
|
58
|
-
|
|
59
55
|
const children = React.Children.map(options, child => {
|
|
60
|
-
const isValidOption = checkIfValidOption(child);
|
|
56
|
+
const isValidOption = checkIfValidOption(child);
|
|
61
57
|
|
|
58
|
+
// Return early if the child isn't an option, to prevent attaching handlers etc.
|
|
62
59
|
if (!isValidOption) {
|
|
63
60
|
return child;
|
|
64
61
|
}
|
|
65
|
-
|
|
66
62
|
const {
|
|
67
63
|
value,
|
|
68
64
|
label,
|
|
69
65
|
disabled: isDisabled
|
|
70
|
-
} = child.props;
|
|
66
|
+
} = child.props;
|
|
71
67
|
|
|
72
|
-
|
|
68
|
+
// Active means the option is currently selected
|
|
69
|
+
const isActive = !!findOption(value, selected);
|
|
73
70
|
|
|
71
|
+
// Create the appropriate click handler for the option
|
|
74
72
|
const onClick = isDisabled ? onDisabledClick : createHandler({
|
|
75
73
|
isActive,
|
|
76
74
|
onChange,
|
|
@@ -78,14 +76,14 @@ const Menu = _ref2 => {
|
|
|
78
76
|
value,
|
|
79
77
|
label
|
|
80
78
|
});
|
|
81
|
-
return /*#__PURE__*/React.cloneElement(child, {
|
|
79
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
80
|
+
...child.props,
|
|
82
81
|
onClick,
|
|
83
82
|
active: isActive
|
|
84
83
|
});
|
|
85
84
|
});
|
|
86
85
|
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
87
86
|
};
|
|
88
|
-
|
|
89
87
|
Menu.defaultProps = {
|
|
90
88
|
empty: ''
|
|
91
89
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _JSXStyle from "styled-jsx/style";
|
|
2
2
|
import { Button } from '@dhis2-ui/button';
|
|
3
3
|
import { Modal, ModalTitle, ModalContent } from '@dhis2-ui/modal';
|
|
4
|
-
import { storiesOf } from '@storybook/react';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
6
5
|
import React, { useState } from 'react';
|
|
7
6
|
import { MultiSelectOption } from '../index.js';
|
|
@@ -9,7 +8,6 @@ import { MultiSelect } from './multi-select.js';
|
|
|
9
8
|
window.onChange = window.Cypress && window.Cypress.cy.stub();
|
|
10
9
|
window.onFocus = window.Cypress && window.Cypress.cy.stub();
|
|
11
10
|
window.onBlur = window.Cypress && window.Cypress.cy.stub();
|
|
12
|
-
|
|
13
11
|
const CustomMultiSelectOption = _ref => {
|
|
14
12
|
let {
|
|
15
13
|
label,
|
|
@@ -19,7 +17,6 @@ const CustomMultiSelectOption = _ref => {
|
|
|
19
17
|
onClick: e => onClick({}, e)
|
|
20
18
|
}, label);
|
|
21
19
|
};
|
|
22
|
-
|
|
23
20
|
CustomMultiSelectOption.propTypes = {
|
|
24
21
|
label: PropTypes.string,
|
|
25
22
|
onClick: PropTypes.func
|
|
@@ -37,7 +34,10 @@ const options = [{
|
|
|
37
34
|
name: 'bar',
|
|
38
35
|
id: '4'
|
|
39
36
|
}];
|
|
40
|
-
|
|
37
|
+
export default {
|
|
38
|
+
title: 'MultiSelect'
|
|
39
|
+
};
|
|
40
|
+
export const WithOptions = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
41
41
|
className: "select"
|
|
42
42
|
}, /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
43
43
|
value: "1",
|
|
@@ -48,7 +48,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
48
48
|
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
49
49
|
value: "3",
|
|
50
50
|
label: "option three"
|
|
51
|
-
}))
|
|
51
|
+
}));
|
|
52
|
+
export const WithOptionsAndOnChange = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
52
53
|
className: "select",
|
|
53
54
|
onChange: window.onChange
|
|
54
55
|
}, /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
@@ -60,7 +61,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
60
61
|
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
61
62
|
value: "3",
|
|
62
63
|
label: "option three"
|
|
63
|
-
}))
|
|
64
|
+
}));
|
|
65
|
+
export const WithOnFocus = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
64
66
|
className: "select",
|
|
65
67
|
onFocus: window.onFocus
|
|
66
68
|
}, /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
@@ -72,7 +74,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
72
74
|
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
73
75
|
value: "3",
|
|
74
76
|
label: "option three"
|
|
75
|
-
}))
|
|
77
|
+
}));
|
|
78
|
+
export const WithOnBlur = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
76
79
|
className: "select",
|
|
77
80
|
onBlur: window.onBlur
|
|
78
81
|
}, /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
@@ -84,7 +87,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
84
87
|
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
85
88
|
value: "3",
|
|
86
89
|
label: "option three"
|
|
87
|
-
}))
|
|
90
|
+
}));
|
|
91
|
+
export const WithCustomOptionsAndOnChange = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
88
92
|
className: "select",
|
|
89
93
|
onChange: window.onChange
|
|
90
94
|
}, /*#__PURE__*/React.createElement(CustomMultiSelectOption, {
|
|
@@ -96,7 +100,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
96
100
|
}), /*#__PURE__*/React.createElement(CustomMultiSelectOption, {
|
|
97
101
|
value: "3",
|
|
98
102
|
label: "option three"
|
|
99
|
-
}))
|
|
103
|
+
}));
|
|
104
|
+
export const WithInvalidOptions = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
100
105
|
className: "select"
|
|
101
106
|
}, /*#__PURE__*/React.createElement("div", null, "invalid one"), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
102
107
|
value: "1",
|
|
@@ -107,7 +112,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
107
112
|
}), /*#__PURE__*/React.createElement("div", null, "invalid three"), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
108
113
|
value: "3",
|
|
109
114
|
label: "option three"
|
|
110
|
-
}), null, undefined, false)
|
|
115
|
+
}), null, undefined, false);
|
|
116
|
+
export const WithInvalidFilterableOptions = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
111
117
|
filterable: true,
|
|
112
118
|
className: "select",
|
|
113
119
|
noMatchText: "No match"
|
|
@@ -120,20 +126,25 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
120
126
|
}), /*#__PURE__*/React.createElement("div", null, "invalid three"), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
121
127
|
value: "3",
|
|
122
128
|
label: "option three"
|
|
123
|
-
}))
|
|
129
|
+
}));
|
|
130
|
+
export const WithInitialFocus = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
124
131
|
className: "select",
|
|
125
132
|
initialFocus: true
|
|
126
|
-
})
|
|
133
|
+
});
|
|
134
|
+
export const Empty = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
127
135
|
className: "select"
|
|
128
|
-
})
|
|
136
|
+
});
|
|
137
|
+
export const EmptyWithEmptyText = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
129
138
|
className: "select",
|
|
130
139
|
empty: "Custom empty text"
|
|
131
|
-
})
|
|
140
|
+
});
|
|
141
|
+
export const EmptyWithEmptyComponent = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
132
142
|
className: "select",
|
|
133
143
|
empty: /*#__PURE__*/React.createElement("div", {
|
|
134
144
|
className: "custom-empty"
|
|
135
145
|
}, "Custom empty component")
|
|
136
|
-
})
|
|
146
|
+
});
|
|
147
|
+
export const WithOptionsAndLoading = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
137
148
|
className: "select",
|
|
138
149
|
loading: true
|
|
139
150
|
}, /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
@@ -145,7 +156,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
145
156
|
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
146
157
|
value: "3",
|
|
147
158
|
label: "option three"
|
|
148
|
-
}))
|
|
159
|
+
}));
|
|
160
|
+
export const WithOptionsLoadingAndLoadingText = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
149
161
|
className: "select",
|
|
150
162
|
loadingText: "Loading options",
|
|
151
163
|
loading: true
|
|
@@ -158,7 +170,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
158
170
|
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
159
171
|
value: "3",
|
|
160
172
|
label: "option three"
|
|
161
|
-
}))
|
|
173
|
+
}));
|
|
174
|
+
export const WithMoreThanTenOptions = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
162
175
|
className: "select"
|
|
163
176
|
}, /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
164
177
|
value: "1",
|
|
@@ -196,7 +209,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
196
209
|
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
197
210
|
value: "12",
|
|
198
211
|
label: "option twelve"
|
|
199
|
-
}))
|
|
212
|
+
}));
|
|
213
|
+
export const WithMoreThanThreeOptionsAndA100pxMaxHeight = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
200
214
|
className: "select",
|
|
201
215
|
maxHeight: "100px"
|
|
202
216
|
}, /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
@@ -235,7 +249,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
235
249
|
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
236
250
|
value: "12",
|
|
237
251
|
label: "option twelve"
|
|
238
|
-
}))
|
|
252
|
+
}));
|
|
253
|
+
export const WithOptionsASelectionAndDisabled = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
239
254
|
disabled: true,
|
|
240
255
|
className: "select",
|
|
241
256
|
selected: ['1']
|
|
@@ -248,7 +263,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
248
263
|
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
249
264
|
value: "3",
|
|
250
265
|
label: "option three"
|
|
251
|
-
}))
|
|
266
|
+
}));
|
|
267
|
+
export const WithOptionsAndDisabled = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
252
268
|
disabled: true,
|
|
253
269
|
className: "select"
|
|
254
270
|
}, /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
@@ -260,7 +276,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
260
276
|
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
261
277
|
value: "3",
|
|
262
278
|
label: "option three"
|
|
263
|
-
}))
|
|
279
|
+
}));
|
|
280
|
+
export const WithPrefix = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
264
281
|
className: "select",
|
|
265
282
|
prefix: "Prefix text"
|
|
266
283
|
}, /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
@@ -272,7 +289,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
272
289
|
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
273
290
|
value: "3",
|
|
274
291
|
label: "option three"
|
|
275
|
-
}))
|
|
292
|
+
}));
|
|
293
|
+
export const WithPrefixAndSelection = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
276
294
|
className: "select",
|
|
277
295
|
prefix: "Prefix text",
|
|
278
296
|
selected: ['1']
|
|
@@ -285,7 +303,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
285
303
|
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
286
304
|
value: "3",
|
|
287
305
|
label: "option three"
|
|
288
|
-
}))
|
|
306
|
+
}));
|
|
307
|
+
export const WithPlaceholder = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
289
308
|
className: "select",
|
|
290
309
|
placeholder: "Placeholder text"
|
|
291
310
|
}, /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
@@ -297,7 +316,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
297
316
|
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
298
317
|
value: "3",
|
|
299
318
|
label: "option three"
|
|
300
|
-
}))
|
|
319
|
+
}));
|
|
320
|
+
export const WithPlaceholderAndSelection = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
301
321
|
className: "select",
|
|
302
322
|
selected: ['1'],
|
|
303
323
|
placeholder: "Placeholder text"
|
|
@@ -310,7 +330,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
310
330
|
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
311
331
|
value: "3",
|
|
312
332
|
label: "option three"
|
|
313
|
-
}))
|
|
333
|
+
}));
|
|
334
|
+
export const WithDisabledOptionAndOnChange = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
314
335
|
className: "select",
|
|
315
336
|
onChange: window.onChange
|
|
316
337
|
}, /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
@@ -326,7 +347,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
326
347
|
value: "4",
|
|
327
348
|
label: "disabled option",
|
|
328
349
|
disabled: true
|
|
329
|
-
}))
|
|
350
|
+
}));
|
|
351
|
+
export const WithOptionsAndASelection = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
330
352
|
className: "select",
|
|
331
353
|
selected: ['1']
|
|
332
354
|
}, /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
@@ -338,7 +360,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
338
360
|
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
339
361
|
value: "3",
|
|
340
362
|
label: "option three"
|
|
341
|
-
}))
|
|
363
|
+
}));
|
|
364
|
+
export const WithOptionsASelectionAndOnChange = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
342
365
|
className: "select",
|
|
343
366
|
selected: ['1'],
|
|
344
367
|
onChange: window.onChange
|
|
@@ -351,7 +374,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
351
374
|
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
352
375
|
value: "3",
|
|
353
376
|
label: "option three"
|
|
354
|
-
}))
|
|
377
|
+
}));
|
|
378
|
+
export const WithOptionsAndMultipleSelections = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
355
379
|
className: "select",
|
|
356
380
|
selected: ['1', '2']
|
|
357
381
|
}, /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
@@ -363,7 +387,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
363
387
|
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
364
388
|
value: "3",
|
|
365
389
|
label: "option three"
|
|
366
|
-
}))
|
|
390
|
+
}));
|
|
391
|
+
export const WithClearButtonSelectionAndOnChange = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
367
392
|
clearable: true,
|
|
368
393
|
clearText: "Clear",
|
|
369
394
|
className: "select",
|
|
@@ -378,7 +403,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
378
403
|
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
379
404
|
value: "3",
|
|
380
405
|
label: "option three"
|
|
381
|
-
}))
|
|
406
|
+
}));
|
|
407
|
+
export const WithFilterField = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
382
408
|
filterable: true,
|
|
383
409
|
noMatchText: "No match found",
|
|
384
410
|
className: "select"
|
|
@@ -391,7 +417,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
391
417
|
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
392
418
|
value: "3",
|
|
393
419
|
label: "option three"
|
|
394
|
-
}))
|
|
420
|
+
}));
|
|
421
|
+
export const DefaultPosition = () => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MultiSelect, {
|
|
395
422
|
className: "select"
|
|
396
423
|
}, /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
397
424
|
value: "1",
|
|
@@ -430,8 +457,9 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
430
457
|
value: "12",
|
|
431
458
|
label: "option twelve"
|
|
432
459
|
})), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
433
|
-
id: "
|
|
434
|
-
}, ["#root{height:2000px !important;}"]))
|
|
460
|
+
id: "2883393180"
|
|
461
|
+
}, ["#storybook-root{height:2000px !important;}"]));
|
|
462
|
+
export const FlippedPosition = () => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MultiSelect, {
|
|
435
463
|
className: "select"
|
|
436
464
|
}, /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
437
465
|
value: "1",
|
|
@@ -470,8 +498,9 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
470
498
|
value: "12",
|
|
471
499
|
label: "option twelve"
|
|
472
500
|
})), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
473
|
-
id: "
|
|
474
|
-
}, ["html,body,#root{position:relative;height:500px;max-height:500px;}", "#root{padding-top:400px !important;}"]))
|
|
501
|
+
id: "979451016"
|
|
502
|
+
}, ["html,body,#storybook-root{position:relative;height:500px;max-height:500px;}", "#storybook-root{padding-top:400px !important;}"]));
|
|
503
|
+
export const ShiftedIntoView = () => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MultiSelect, {
|
|
475
504
|
className: "select"
|
|
476
505
|
}, /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
477
506
|
value: "1",
|
|
@@ -510,8 +539,9 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
510
539
|
value: "12",
|
|
511
540
|
label: "option twelve"
|
|
512
541
|
})), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
513
|
-
id: "
|
|
514
|
-
}, ["html,body,#root{position:relative;height:300px !important;max-height:300px;}", "#root{padding-top:130px !important;}"]))
|
|
542
|
+
id: "438540012"
|
|
543
|
+
}, ["html,body,#storybook-root{position:relative;height:300px !important;max-height:300px;}", "#storybook-root{padding-top:130px !important;}"]));
|
|
544
|
+
export const WithDuplicateSelectedOptionValues = () => /*#__PURE__*/React.createElement(MultiSelect, {
|
|
515
545
|
className: "select",
|
|
516
546
|
selected: ['1']
|
|
517
547
|
}, /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
@@ -526,7 +556,8 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
526
556
|
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
527
557
|
value: "3",
|
|
528
558
|
label: "option three"
|
|
529
|
-
}))
|
|
559
|
+
}));
|
|
560
|
+
export const WithOptionsThatCanBeAddedToTheInput = () => {
|
|
530
561
|
const [values, setValues] = React.useState([]);
|
|
531
562
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MultiSelect, {
|
|
532
563
|
className: "select",
|
|
@@ -550,9 +581,10 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
550
581
|
value: "3",
|
|
551
582
|
label: "option three"
|
|
552
583
|
})), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
553
|
-
id: "
|
|
554
|
-
}, ["#root{height:2000px !important;}"]));
|
|
555
|
-
}
|
|
584
|
+
id: "4252233386"
|
|
585
|
+
}, ["#storybook-root{height:2000px !important;}"]));
|
|
586
|
+
};
|
|
587
|
+
export const MenuWidthChanging = () => {
|
|
556
588
|
const [toggle, setToggle] = useState(false);
|
|
557
589
|
return /*#__PURE__*/React.createElement("div", {
|
|
558
590
|
className: "App"
|
|
@@ -598,4 +630,4 @@ storiesOf('MultiSelect', module).add('With options', () => /*#__PURE__*/React.cr
|
|
|
598
630
|
}, "Stuff")), /*#__PURE__*/React.createElement(Button, {
|
|
599
631
|
onClick: () => setToggle(!toggle)
|
|
600
632
|
}, "Toggle"))));
|
|
601
|
-
}
|
|
633
|
+
};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import _JSXStyle from "styled-jsx/style";
|
|
2
|
-
import { StatusIcon } from '@dhis2-ui/status-icon';
|
|
3
2
|
import { requiredIf } from '@dhis2/prop-types';
|
|
4
3
|
import { spacers, sharedPropTypes } from '@dhis2/ui-constants';
|
|
4
|
+
import { StatusIcon } from '@dhis2-ui/status-icon';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { Loading as CommonLoading, Select } from '../select/index.js';
|
|
8
8
|
import { FilterableMenu } from './filterable-menu.js';
|
|
9
9
|
import { Input } from './input.js';
|
|
10
10
|
import { Menu } from './menu.js';
|
|
11
|
-
|
|
12
11
|
const MultiSelect = _ref => {
|
|
13
12
|
let {
|
|
14
13
|
className,
|
|
@@ -80,7 +79,7 @@ const MultiSelect = _ref => {
|
|
|
80
79
|
dense: dense
|
|
81
80
|
}, children, loading && /*#__PURE__*/React.createElement(CommonLoading, {
|
|
82
81
|
message: loadingText,
|
|
83
|
-
dataTest:
|
|
82
|
+
dataTest: `${dataTest}-loading`
|
|
84
83
|
}))), /*#__PURE__*/React.createElement(StatusIcon, {
|
|
85
84
|
error: error,
|
|
86
85
|
valid: valid,
|
|
@@ -88,9 +87,8 @@ const MultiSelect = _ref => {
|
|
|
88
87
|
}), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
89
88
|
id: "2180377457",
|
|
90
89
|
dynamic: [spacers.dp8]
|
|
91
|
-
}, [
|
|
90
|
+
}, [`.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;}"]));
|
|
92
91
|
};
|
|
93
|
-
|
|
94
92
|
MultiSelect.defaultProps = {
|
|
95
93
|
selected: [],
|
|
96
94
|
dataTest: 'dhis2-uicore-multiselect'
|
|
@@ -98,10 +96,8 @@ MultiSelect.defaultProps = {
|
|
|
98
96
|
MultiSelect.propTypes = {
|
|
99
97
|
children: PropTypes.node,
|
|
100
98
|
className: PropTypes.string,
|
|
101
|
-
|
|
102
99
|
/** Required if `clearable` prop is `true` */
|
|
103
100
|
clearText: requiredIf(props => props.clearable, PropTypes.string),
|
|
104
|
-
|
|
105
101
|
/** Adds a 'clear' option to the menu */
|
|
106
102
|
clearable: PropTypes.bool,
|
|
107
103
|
dataTest: PropTypes.string,
|
|
@@ -110,7 +106,6 @@ MultiSelect.propTypes = {
|
|
|
110
106
|
empty: PropTypes.node,
|
|
111
107
|
error: sharedPropTypes.statusPropType,
|
|
112
108
|
filterPlaceholder: PropTypes.string,
|
|
113
|
-
|
|
114
109
|
/** Adds a 'filter' field to the menu */
|
|
115
110
|
filterable: PropTypes.bool,
|
|
116
111
|
initialFocus: PropTypes.bool,
|
|
@@ -118,7 +113,6 @@ MultiSelect.propTypes = {
|
|
|
118
113
|
loading: PropTypes.bool,
|
|
119
114
|
loadingText: PropTypes.string,
|
|
120
115
|
maxHeight: PropTypes.string,
|
|
121
|
-
|
|
122
116
|
/** Required if `filterable` prop is `true` */
|
|
123
117
|
noMatchText: requiredIf(props => props.filterable, PropTypes.string),
|
|
124
118
|
placeholder: PropTypes.string,
|