@dhis2-ui/select 8.1.11 → 8.2.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/multi-select/features/menu_width_matches_input/index.js +4 -2
- package/build/cjs/multi-select/features/position/index.js +12 -6
- package/build/cjs/multi-select/filterable-menu.js +25 -22
- package/build/cjs/multi-select/input.js +19 -18
- package/build/cjs/multi-select/menu.js +29 -25
- package/build/cjs/multi-select/multi-select.js +31 -30
- package/build/cjs/multi-select/multi-select.stories.e2e.js +30 -20
- package/build/cjs/multi-select/multi-select.stories.js +14 -23
- package/build/cjs/multi-select/selection-list.js +43 -37
- package/build/cjs/multi-select-field/multi-select-field.stories.js +5 -15
- package/build/cjs/multi-select-option/multi-select-option.js +31 -28
- package/build/cjs/select/debounce/debounce.js +8 -2
- package/build/cjs/select/empty.js +14 -11
- package/build/cjs/select/filter-input.js +24 -21
- package/build/cjs/select/filterable-menu.js +8 -7
- package/build/cjs/select/index.js +24 -24
- package/build/cjs/select/input-clear-button.js +16 -13
- package/build/cjs/select/input-placeholder.js +8 -6
- package/build/cjs/select/input-prefix.js +8 -6
- package/build/cjs/select/input-wrapper.js +15 -14
- package/build/cjs/select/loading.js +18 -15
- package/build/cjs/select/menu-wrapper.js +11 -10
- package/build/cjs/select/no-match.js +12 -9
- package/build/cjs/select/option-helpers.js +1 -1
- package/build/cjs/select/select.js +6 -6
- package/build/cjs/single-select/features/menu_width_matches_input/index.js +4 -2
- package/build/cjs/single-select/features/position/index.js +8 -4
- package/build/cjs/single-select/filterable-menu.js +25 -22
- package/build/cjs/single-select/input.js +19 -18
- package/build/cjs/single-select/menu.js +11 -10
- package/build/cjs/single-select/selection.js +8 -7
- package/build/cjs/single-select/single-select.js +31 -30
- package/build/cjs/single-select/single-select.stories.e2e.js +26 -17
- package/build/cjs/single-select/single-select.stories.js +14 -21
- package/build/cjs/single-select-field/single-select-field.stories.js +5 -15
- package/build/cjs/single-select-option/single-select-option.js +23 -20
- package/build/es/multi-select/features/menu_width_matches_input/index.js +4 -2
- package/build/es/multi-select/features/position/index.js +12 -6
- package/build/es/multi-select/filterable-menu.js +25 -22
- package/build/es/multi-select/input.js +19 -18
- package/build/es/multi-select/menu.js +28 -24
- package/build/es/multi-select/multi-select.js +31 -30
- package/build/es/multi-select/multi-select.stories.e2e.js +30 -20
- package/build/es/multi-select/multi-select.stories.js +13 -22
- package/build/es/multi-select/selection-list.js +43 -37
- package/build/es/multi-select-field/multi-select-field.stories.js +4 -14
- package/build/es/multi-select-option/multi-select-option.js +31 -28
- package/build/es/select/debounce/debounce.js +8 -2
- package/build/es/select/empty.js +14 -11
- package/build/es/select/filter-input.js +24 -21
- package/build/es/select/filterable-menu.js +8 -7
- package/build/es/select/input-clear-button.js +16 -13
- package/build/es/select/input-placeholder.js +8 -6
- package/build/es/select/input-prefix.js +8 -6
- package/build/es/select/input-wrapper.js +15 -14
- package/build/es/select/loading.js +18 -15
- package/build/es/select/menu-wrapper.js +11 -10
- package/build/es/select/no-match.js +12 -9
- package/build/es/select/select.js +6 -6
- package/build/es/single-select/features/menu_width_matches_input/index.js +4 -2
- package/build/es/single-select/features/position/index.js +8 -4
- package/build/es/single-select/filterable-menu.js +25 -22
- package/build/es/single-select/input.js +19 -18
- package/build/es/single-select/menu.js +11 -10
- package/build/es/single-select/selection.js +8 -7
- package/build/es/single-select/single-select.js +31 -30
- package/build/es/single-select/single-select.stories.e2e.js +26 -17
- package/build/es/single-select/single-select.stories.js +13 -20
- package/build/es/single-select-field/single-select-field.stories.js +4 -14
- package/build/es/single-select-option/single-select-option.js +23 -20
- package/package.json +14 -14
|
@@ -28,7 +28,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
|
|
|
28
28
|
(0, _steps.Then)('the SingleSelect input is left aligned with the menu', () => {
|
|
29
29
|
const selectDataTest = '[data-test="dhis2-uicore-singleselect"]';
|
|
30
30
|
const menuDataTest = '[data-test="dhis2-uicore-select-menu-menuwrapper"]';
|
|
31
|
-
cy.getAll(selectDataTest, menuDataTest).should(
|
|
31
|
+
cy.getAll(selectDataTest, menuDataTest).should(_ref => {
|
|
32
|
+
let [inputs, menus] = _ref;
|
|
32
33
|
expect(inputs.length).to.equal(1);
|
|
33
34
|
expect(menus.length).to.equal(1);
|
|
34
35
|
const $input = inputs[0];
|
|
@@ -41,7 +42,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
|
|
|
41
42
|
(0, _steps.When)('the SingleSelect input and menu have the same width', () => {
|
|
42
43
|
const inputSelector = '[data-test="dhis2-uicore-select"]';
|
|
43
44
|
const menuSelector = '[data-test="dhis2-uicore-select-menu-menuwrapper"]';
|
|
44
|
-
cy.getAll(inputSelector, menuSelector).should(
|
|
45
|
+
cy.getAll(inputSelector, menuSelector).should(_ref2 => {
|
|
46
|
+
let [$input, $menu] = _ref2;
|
|
45
47
|
const inputWidth = Math.round($input.outerWidth());
|
|
46
48
|
const menuWidth = Math.round($menu.outerWidth());
|
|
47
49
|
expect(inputWidth).to.equal(menuWidth);
|
|
@@ -24,7 +24,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
|
|
|
24
24
|
(0, _steps.Then)('the top of the menu is aligned with the bottom of the input', () => {
|
|
25
25
|
const selectDataTest = '[data-test="dhis2-uicore-singleselect"]';
|
|
26
26
|
const menuDataTest = '[data-test="dhis2-uicore-select-menu-menuwrapper"]';
|
|
27
|
-
cy.getAll(selectDataTest, menuDataTest).should(
|
|
27
|
+
cy.getAll(selectDataTest, menuDataTest).should(_ref => {
|
|
28
|
+
let [selects, menus] = _ref;
|
|
28
29
|
expect(selects.length).to.equal(1);
|
|
29
30
|
expect(menus.length).to.equal(1);
|
|
30
31
|
const $select = selects[0];
|
|
@@ -37,7 +38,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
|
|
|
37
38
|
(0, _steps.Then)('the bottom of the menu is aligned with the top of the input', () => {
|
|
38
39
|
const selectDataTest = '[data-test="dhis2-uicore-singleselect"]';
|
|
39
40
|
const menuDataTest = '[data-test="dhis2-uicore-select-menu-menuwrapper"]';
|
|
40
|
-
cy.getAll(selectDataTest, menuDataTest).should(
|
|
41
|
+
cy.getAll(selectDataTest, menuDataTest).should(_ref2 => {
|
|
42
|
+
let [selects, menus] = _ref2;
|
|
41
43
|
expect(selects.length).to.equal(1);
|
|
42
44
|
expect(menus.length).to.equal(1);
|
|
43
45
|
const $select = selects[0];
|
|
@@ -50,7 +52,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
|
|
|
50
52
|
(0, _steps.Then)('it is rendered on top of the SingleSelect', () => {
|
|
51
53
|
const selectDataTest = '[data-test="dhis2-uicore-singleselect"]';
|
|
52
54
|
const menuDataTest = '[data-test="dhis2-uicore-select-menu-menuwrapper"]';
|
|
53
|
-
cy.getAll(selectDataTest, menuDataTest).should(
|
|
55
|
+
cy.getAll(selectDataTest, menuDataTest).should(_ref3 => {
|
|
56
|
+
let [selects, menus] = _ref3;
|
|
54
57
|
expect(selects.length).to.equal(1);
|
|
55
58
|
expect(menus.length).to.equal(1);
|
|
56
59
|
const $select = selects[0];
|
|
@@ -64,7 +67,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
|
|
|
64
67
|
(0, _steps.Then)('the left of the SingleSelect is aligned with the left of the anchor', () => {
|
|
65
68
|
const selectDataTest = '[data-test="dhis2-uicore-singleselect"]';
|
|
66
69
|
const menuDataTest = '[data-test="dhis2-uicore-select-menu-menuwrapper"]';
|
|
67
|
-
cy.getAll(selectDataTest, menuDataTest).should(
|
|
70
|
+
cy.getAll(selectDataTest, menuDataTest).should(_ref4 => {
|
|
71
|
+
let [selects, menus] = _ref4;
|
|
68
72
|
expect(selects.length).to.equal(1);
|
|
69
73
|
expect(menus.length).to.equal(1);
|
|
70
74
|
const $select = selects[0];
|
|
@@ -15,28 +15,31 @@ var _menu = require("./menu.js");
|
|
|
15
15
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
|
|
18
|
-
const FilterableMenu =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
18
|
+
const FilterableMenu = _ref => {
|
|
19
|
+
let {
|
|
20
|
+
dataTest,
|
|
21
|
+
options,
|
|
22
|
+
onChange,
|
|
23
|
+
selected,
|
|
24
|
+
empty,
|
|
25
|
+
handleClose,
|
|
26
|
+
handleFocusInput,
|
|
27
|
+
placeholder,
|
|
28
|
+
noMatchText
|
|
29
|
+
} = _ref;
|
|
30
|
+
return /*#__PURE__*/_react.default.createElement(_index.FilterableMenu, {
|
|
31
|
+
dataTest: dataTest,
|
|
32
|
+
options: options,
|
|
33
|
+
onChange: onChange,
|
|
34
|
+
selected: selected,
|
|
35
|
+
empty: empty,
|
|
36
|
+
handleClose: handleClose,
|
|
37
|
+
handleFocusInput: handleFocusInput,
|
|
38
|
+
placeholder: placeholder,
|
|
39
|
+
noMatchText: noMatchText,
|
|
40
|
+
Menu: _menu.Menu
|
|
41
|
+
});
|
|
42
|
+
};
|
|
40
43
|
|
|
41
44
|
exports.FilterableMenu = FilterableMenu;
|
|
42
45
|
FilterableMenu.propTypes = {
|
|
@@ -23,19 +23,20 @@ var _selection = require("./selection.js");
|
|
|
23
23
|
|
|
24
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
25
|
|
|
26
|
-
const Input =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
const Input = _ref => {
|
|
27
|
+
let {
|
|
28
|
+
selected,
|
|
29
|
+
onChange,
|
|
30
|
+
clearable,
|
|
31
|
+
clearText,
|
|
32
|
+
placeholder,
|
|
33
|
+
dataTest,
|
|
34
|
+
prefix,
|
|
35
|
+
options,
|
|
36
|
+
className,
|
|
37
|
+
disabled,
|
|
38
|
+
inputMaxHeight
|
|
39
|
+
} = _ref;
|
|
39
40
|
const hasSelection = selected && typeof selected === 'string';
|
|
40
41
|
|
|
41
42
|
const onClear = (_, e) => {
|
|
@@ -50,10 +51,10 @@ const Input = ({
|
|
|
50
51
|
className: _style.default.dynamic([["1360178250", [_uiConstants.colors.grey900]], ["1331770409", [inputMaxHeight]]]) + " " + ((0, _classnames.default)('root', className) || "")
|
|
51
52
|
}, /*#__PURE__*/_react.default.createElement(_index.InputPrefix, {
|
|
52
53
|
prefix: prefix,
|
|
53
|
-
dataTest:
|
|
54
|
+
dataTest: "".concat(dataTest, "-prefix")
|
|
54
55
|
}), !hasSelection && !prefix && /*#__PURE__*/_react.default.createElement(_index.InputPlaceholder, {
|
|
55
56
|
placeholder: placeholder,
|
|
56
|
-
dataTest:
|
|
57
|
+
dataTest: "".concat(dataTest, "-placeholder")
|
|
57
58
|
}), hasSelection && /*#__PURE__*/_react.default.createElement("div", {
|
|
58
59
|
className: _style.default.dynamic([["1360178250", [_uiConstants.colors.grey900]], ["1331770409", [inputMaxHeight]]]) + " " + "root-input"
|
|
59
60
|
}, /*#__PURE__*/_react.default.createElement(_selection.Selection, {
|
|
@@ -64,14 +65,14 @@ const Input = ({
|
|
|
64
65
|
}, /*#__PURE__*/_react.default.createElement(_index.InputClearButton, {
|
|
65
66
|
onClear: onClear,
|
|
66
67
|
clearText: clearText,
|
|
67
|
-
dataTest:
|
|
68
|
+
dataTest: "".concat(dataTest, "-clear")
|
|
68
69
|
})), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
69
70
|
id: "1360178250",
|
|
70
71
|
dynamic: [_uiConstants.colors.grey900]
|
|
71
|
-
}, [
|
|
72
|
+
}, [".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:".concat(_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;}", ".root-right.__jsx-style-dynamic-selector{margin-left:auto;margin-right:10px;}"]), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
72
73
|
id: "1331770409",
|
|
73
74
|
dynamic: [inputMaxHeight]
|
|
74
|
-
}, [
|
|
75
|
+
}, [".root-input.__jsx-style-dynamic-selector{max-height:".concat(inputMaxHeight, ";}")]));
|
|
75
76
|
};
|
|
76
77
|
|
|
77
78
|
exports.Input = Input;
|
|
@@ -18,15 +18,16 @@ const onIgnoredClick = (_, e) => {
|
|
|
18
18
|
e.preventDefault();
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
const Menu =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
const Menu = _ref => {
|
|
22
|
+
let {
|
|
23
|
+
options,
|
|
24
|
+
onChange,
|
|
25
|
+
selected,
|
|
26
|
+
empty,
|
|
27
|
+
handleFocusInput,
|
|
28
|
+
handleClose,
|
|
29
|
+
dataTest
|
|
30
|
+
} = _ref;
|
|
30
31
|
const renderedOptions = (0, _index.filterIgnored)(options);
|
|
31
32
|
|
|
32
33
|
if (_react.default.Children.count(renderedOptions) === 0) {
|
|
@@ -34,7 +35,7 @@ const Menu = ({
|
|
|
34
35
|
if (typeof empty === 'string') {
|
|
35
36
|
return /*#__PURE__*/_react.default.createElement(_index.Empty, {
|
|
36
37
|
message: empty,
|
|
37
|
-
dataTest:
|
|
38
|
+
dataTest: "".concat(dataTest, "-empty")
|
|
38
39
|
});
|
|
39
40
|
} // Otherwise just render the supplied markup
|
|
40
41
|
|
|
@@ -19,15 +19,16 @@ var _index = require("../select/index.js");
|
|
|
19
19
|
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
21
|
|
|
22
|
-
const Selection =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
const Selection = _ref => {
|
|
23
|
+
let {
|
|
24
|
+
options,
|
|
25
|
+
selected,
|
|
26
|
+
className
|
|
27
|
+
} = _ref;
|
|
27
28
|
const selectedOption = (0, _index.findOptionChild)(selected, options);
|
|
28
29
|
|
|
29
30
|
if (!selectedOption) {
|
|
30
|
-
const message =
|
|
31
|
+
const message = "There is no option with the value: \"".concat(selected, "\". ") + 'Make sure that the value passed to the selected ' + 'prop matches the value of an existing option.';
|
|
31
32
|
throw new Error(message);
|
|
32
33
|
}
|
|
33
34
|
|
|
@@ -40,7 +41,7 @@ const Selection = ({
|
|
|
40
41
|
}, icon), label, /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
41
42
|
id: "2368250986",
|
|
42
43
|
dynamic: [_uiConstants.spacers.dp8, _uiConstants.spacers.dp16, _uiConstants.spacers.dp16]
|
|
43
|
-
}, [".root.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}",
|
|
44
|
+
}, [".root.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}", ".root-icon.__jsx-style-dynamic-selector{margin-right:".concat(_uiConstants.spacers.dp8, ";width:").concat(_uiConstants.spacers.dp16, ";height:").concat(_uiConstants.spacers.dp16, ";overflow:hidden;}")]));
|
|
44
45
|
};
|
|
45
46
|
|
|
46
47
|
exports.Selection = Selection;
|
|
@@ -27,34 +27,35 @@ var _menu = require("./menu.js");
|
|
|
27
27
|
|
|
28
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
29
|
|
|
30
|
-
const SingleSelect =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
30
|
+
const SingleSelect = _ref => {
|
|
31
|
+
let {
|
|
32
|
+
className,
|
|
33
|
+
selected,
|
|
34
|
+
tabIndex,
|
|
35
|
+
maxHeight,
|
|
36
|
+
inputMaxHeight,
|
|
37
|
+
onChange,
|
|
38
|
+
onFocus,
|
|
39
|
+
onBlur,
|
|
40
|
+
loading,
|
|
41
|
+
error,
|
|
42
|
+
warning,
|
|
43
|
+
valid,
|
|
44
|
+
disabled,
|
|
45
|
+
children,
|
|
46
|
+
clearable,
|
|
47
|
+
clearText,
|
|
48
|
+
filterable,
|
|
49
|
+
filterPlaceholder,
|
|
50
|
+
placeholder,
|
|
51
|
+
prefix,
|
|
52
|
+
empty,
|
|
53
|
+
loadingText,
|
|
54
|
+
noMatchText,
|
|
55
|
+
initialFocus,
|
|
56
|
+
dense,
|
|
57
|
+
dataTest
|
|
58
|
+
} = _ref;
|
|
58
59
|
// If the select is filterable, use a filterable menu
|
|
59
60
|
const menu = filterable ? /*#__PURE__*/_react.default.createElement(_filterableMenu.FilterableMenu, {
|
|
60
61
|
dataTest: dataTest,
|
|
@@ -95,7 +96,7 @@ const SingleSelect = ({
|
|
|
95
96
|
dense: dense
|
|
96
97
|
}, children, loading && /*#__PURE__*/_react.default.createElement(_index.Loading, {
|
|
97
98
|
message: loadingText,
|
|
98
|
-
dataTest:
|
|
99
|
+
dataTest: "".concat(dataTest, "-loading")
|
|
99
100
|
}))), /*#__PURE__*/_react.default.createElement(_statusIcon.StatusIcon, {
|
|
100
101
|
error: error,
|
|
101
102
|
valid: valid,
|
|
@@ -103,7 +104,7 @@ const SingleSelect = ({
|
|
|
103
104
|
}), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
104
105
|
id: "2180377457",
|
|
105
106
|
dynamic: [_uiConstants.spacers.dp8]
|
|
106
|
-
}, [
|
|
107
|
+
}, [".root.__jsx-style-dynamic-selector{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:".concat(_uiConstants.spacers.dp8, ";}"), ".root-input.__jsx-style-dynamic-selector{-webkit-flex:1;-ms-flex:1;flex:1;}"]));
|
|
107
108
|
};
|
|
108
109
|
|
|
109
110
|
exports.SingleSelect = SingleSelect;
|
|
@@ -26,12 +26,15 @@ window.onChange = window.Cypress && window.Cypress.cy.stub();
|
|
|
26
26
|
window.onFocus = window.Cypress && window.Cypress.cy.stub();
|
|
27
27
|
window.onBlur = window.Cypress && window.Cypress.cy.stub();
|
|
28
28
|
|
|
29
|
-
const CustomSingleSelectOption =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
const CustomSingleSelectOption = _ref => {
|
|
30
|
+
let {
|
|
31
|
+
label,
|
|
32
|
+
onClick
|
|
33
|
+
} = _ref;
|
|
34
|
+
return /*#__PURE__*/_react2.default.createElement("div", {
|
|
35
|
+
onClick: e => onClick({}, e)
|
|
36
|
+
}, label);
|
|
37
|
+
};
|
|
35
38
|
|
|
36
39
|
CustomSingleSelectOption.propTypes = {
|
|
37
40
|
label: _propTypes.default.string,
|
|
@@ -548,17 +551,23 @@ const options = [{
|
|
|
548
551
|
flexGrow: 1
|
|
549
552
|
}
|
|
550
553
|
}, /*#__PURE__*/_react2.default.createElement(_index2.SingleSelect, {
|
|
551
|
-
onChange:
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
554
|
+
onChange: _ref2 => {
|
|
555
|
+
let {
|
|
556
|
+
selected
|
|
557
|
+
} = _ref2;
|
|
558
|
+
return console.log('size changed to ' + selected);
|
|
559
|
+
}
|
|
560
|
+
}, options.map(_ref3 => {
|
|
561
|
+
let {
|
|
562
|
+
name,
|
|
563
|
+
id
|
|
564
|
+
} = _ref3;
|
|
565
|
+
return /*#__PURE__*/_react2.default.createElement(_index.SingleSelectOption, {
|
|
566
|
+
key: id,
|
|
567
|
+
value: id,
|
|
568
|
+
label: name
|
|
569
|
+
});
|
|
570
|
+
}))), toggle && /*#__PURE__*/_react2.default.createElement("div", {
|
|
562
571
|
style: {
|
|
563
572
|
padding: '30px',
|
|
564
573
|
border: '1px solid green'
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.default = exports.WithPrefixAndSelection = exports.WithPrefix = exports.WithPlaceholderAndSelection = exports.WithPlaceholder = exports.WithOptionsLoadingAndLoadingText = exports.WithOptionsAndOnChange = exports.WithOptionsAndLoading = exports.WithOptionsAndDisabled = exports.WithOptionsAndASelection = exports.WithOptionsASelectionAndDisabled = exports.WithOnFocus = exports.WithOnBlur = exports.WithMoreThanThreeOptionsAndA100PxMaxHeight = exports.WithMoreThanTenOptions = exports.WithInvalidOptions = exports.WithInvalidFilterableOptions = exports.WithInitialFocus = exports.WithFilterField = exports.WithDisabledOptionAndOnChange = exports.WithCustomOptionsAndOnChange = exports.WithClearButtonSelectionAndOnChange = exports.ShiftedIntoView = exports.FlippedPosition = exports.EmptyWithEmptyText = exports.EmptyWithEmptyComponent = exports.Empty = exports.DefaultPosition = void 0;
|
|
7
7
|
|
|
8
8
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
9
|
|
|
@@ -19,33 +19,26 @@ var _index2 = require("./index.js");
|
|
|
19
19
|
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
21
|
|
|
22
|
-
const description =
|
|
23
|
-
Use a select component wherever the user needs to make a selection of one or more options from a list of 6 or more options. If there are less than 6 options to choose from and space permits, use checkboxes for multiple selection and radio buttons for single selection. If the user needs to make a complex selection with a specific ordering, use a transfer instead.
|
|
24
|
-
|
|
25
|
-
Learn more about using Selects at [Design System: Select](https://github.com/dhis2/design-system/blob/master/molecules/select.md).
|
|
26
|
-
|
|
27
|
-
\`\`\`js
|
|
28
|
-
import { SingleSelect, SingleSelectOption } from '@dhis2/ui'
|
|
29
|
-
\`\`\`
|
|
30
|
-
|
|
31
|
-
_**Note:** Due to demo limitations on this page, only one representative example is rendered here. For more (interactive) examples, see individual stories in the 'Canvas' tab._
|
|
32
|
-
`;
|
|
22
|
+
const description = "\nUse a select component wherever the user needs to make a selection of one or more options from a list of 6 or more options. If there are less than 6 options to choose from and space permits, use checkboxes for multiple selection and radio buttons for single selection. If the user needs to make a complex selection with a specific ordering, use a transfer instead.\n\nLearn more about using Selects at [Design System: Select](https://github.com/dhis2/design-system/blob/master/molecules/select.md).\n\n```js\nimport { SingleSelect, SingleSelectOption } from '@dhis2/ui'\n```\n\n_**Note:** Due to demo limitations on this page, only one representative example is rendered here. For more (interactive) examples, see individual stories in the 'Canvas' tab._\n";
|
|
33
23
|
|
|
34
24
|
const eventHandler = handlerName => (payload, event) => {
|
|
35
|
-
console.log(
|
|
36
|
-
console.log(
|
|
25
|
+
console.log("".concat(handlerName, " payload"), payload);
|
|
26
|
+
console.log("".concat(handlerName, " event"), event);
|
|
37
27
|
};
|
|
38
28
|
|
|
39
29
|
const onChange = eventHandler('onChange');
|
|
40
30
|
const onFocus = eventHandler('onFocus');
|
|
41
31
|
const onBlur = eventHandler('onBlur');
|
|
42
32
|
|
|
43
|
-
const CustomSingleSelectOption =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
33
|
+
const CustomSingleSelectOption = _ref => {
|
|
34
|
+
let {
|
|
35
|
+
label,
|
|
36
|
+
onClick
|
|
37
|
+
} = _ref;
|
|
38
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
39
|
+
onClick: e => onClick({}, e)
|
|
40
|
+
}, label);
|
|
41
|
+
};
|
|
49
42
|
|
|
50
43
|
CustomSingleSelectOption.propTypes = {
|
|
51
44
|
label: _propTypes.default.string,
|
|
@@ -62,7 +55,7 @@ const requiredIfArgType = {
|
|
|
62
55
|
}
|
|
63
56
|
};
|
|
64
57
|
var _default = {
|
|
65
|
-
title: '
|
|
58
|
+
title: 'Single Select',
|
|
66
59
|
component: _index2.SingleSelect,
|
|
67
60
|
parameters: {
|
|
68
61
|
docs: {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.default = exports.WithHelpText = exports.StatusWarning = exports.StatusValid = exports.StatusError = exports.Required = exports.InputWidth = exports.DefaultLoadingText = exports.DefaultFilterPlaceholderAndNoMatchText = exports.DefaultEmpty = exports.DefaultClearText = exports.Default = void 0;
|
|
7
7
|
|
|
8
8
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
9
9
|
|
|
@@ -15,19 +15,9 @@ var _index2 = require("./index.js");
|
|
|
15
15
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
|
|
18
|
-
const description = `
|
|
19
|
-
\`SingleSelectField\` is a wrapper around a \`SingleSelect\` component that adds a label, help text, validation text, and other features.
|
|
18
|
+
const description = "\n`SingleSelectField` is a wrapper around a `SingleSelect` component that adds a label, help text, validation text, and other features.\n\nSee the SingleSelect for more information, and read more at [Design System: Select](https://github.com/dhis2/design-system/blob/master/molecules/select.md#multiple-selection).\n\n```js\nimport { SingleSelectField, SingleSelectOption } from '@dhis2/ui'\n```\n\n_**Note**: The dropdowns in some of the following stories won't appear correctly on this page. View these demos in the 'Canvas' tab._\n";
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
\`\`\`js
|
|
24
|
-
import { SingleSelectField, SingleSelectOption } from '@dhis2/ui'
|
|
25
|
-
\`\`\`
|
|
26
|
-
|
|
27
|
-
_**Note**: The dropdowns in some of the following stories won't appear correctly on this page. View these demos in the 'Canvas' tab._
|
|
28
|
-
`;
|
|
29
|
-
|
|
30
|
-
const onChange = selected => alert(`Selected changed to: ${JSON.stringify(selected, null, 2)}`);
|
|
20
|
+
const onChange = selected => alert("Selected changed to: ".concat(JSON.stringify(selected, null, 2)));
|
|
31
21
|
|
|
32
22
|
const options = [/*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
33
23
|
key: "1",
|
|
@@ -71,7 +61,7 @@ const options = [/*#__PURE__*/_react.default.createElement(_index.SingleSelectOp
|
|
|
71
61
|
label: "ten"
|
|
72
62
|
})];
|
|
73
63
|
var _default = {
|
|
74
|
-
title: '
|
|
64
|
+
title: 'Single Select Field',
|
|
75
65
|
component: _index2.SingleSelectField,
|
|
76
66
|
subcomponents: {
|
|
77
67
|
SingleSelectOption: _index.SingleSelectOption
|
|
@@ -113,7 +103,7 @@ WithHelpText.args = {
|
|
|
113
103
|
WithHelpText.parameters = {
|
|
114
104
|
docs: {
|
|
115
105
|
description: {
|
|
116
|
-
story:
|
|
106
|
+
story: "_**Note**: The dropdowns in the following stories won't appear correctly on this page. View these demos in the 'Canvas' tab._"
|
|
117
107
|
}
|
|
118
108
|
}
|
|
119
109
|
};
|
|
@@ -17,27 +17,30 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
17
17
|
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
|
|
20
|
-
const SingleSelectOption =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
onClick,
|
|
25
|
-
className,
|
|
26
|
-
dataTest,
|
|
27
|
-
value
|
|
28
|
-
}) => /*#__PURE__*/_react.default.createElement("div", {
|
|
29
|
-
onClick: e => onClick({}, e),
|
|
30
|
-
"data-test": dataTest,
|
|
31
|
-
"data-value": value,
|
|
32
|
-
"data-label": label,
|
|
33
|
-
className: _style.default.dynamic([["2046100779", [_uiConstants.colors.grey900, _uiConstants.spacers.dp8, _uiConstants.spacers.dp12, _uiConstants.colors.grey200, _uiConstants.colors.teal700, _uiConstants.colors.white, _uiConstants.colors.grey500]]]) + " " + ((0, _classnames.default)(className, {
|
|
20
|
+
const SingleSelectOption = _ref => {
|
|
21
|
+
let {
|
|
22
|
+
label,
|
|
23
|
+
active,
|
|
34
24
|
disabled,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
25
|
+
onClick,
|
|
26
|
+
className,
|
|
27
|
+
dataTest,
|
|
28
|
+
value
|
|
29
|
+
} = _ref;
|
|
30
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
31
|
+
onClick: e => onClick({}, e),
|
|
32
|
+
"data-test": dataTest,
|
|
33
|
+
"data-value": value,
|
|
34
|
+
"data-label": label,
|
|
35
|
+
className: _style.default.dynamic([["2046100779", [_uiConstants.colors.grey900, _uiConstants.spacers.dp8, _uiConstants.spacers.dp12, _uiConstants.colors.grey200, _uiConstants.colors.teal700, _uiConstants.colors.white, _uiConstants.colors.grey500]]]) + " " + ((0, _classnames.default)(className, {
|
|
36
|
+
disabled,
|
|
37
|
+
active
|
|
38
|
+
}) || "")
|
|
39
|
+
}, label, /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
40
|
+
id: "2046100779",
|
|
41
|
+
dynamic: [_uiConstants.colors.grey900, _uiConstants.spacers.dp8, _uiConstants.spacers.dp12, _uiConstants.colors.grey200, _uiConstants.colors.teal700, _uiConstants.colors.white, _uiConstants.colors.grey500]
|
|
42
|
+
}, ["div.__jsx-style-dynamic-selector{cursor:pointer;font-size:14px;-webkit-text-decoration:none;text-decoration:none;color:".concat(_uiConstants.colors.grey900, ";padding:").concat(_uiConstants.spacers.dp8, " ").concat(_uiConstants.spacers.dp12, ";}"), "div.__jsx-style-dynamic-selector:hover{background-color:".concat(_uiConstants.colors.grey200, ";}"), "div.__jsx-style-dynamic-selector:active,div.active.__jsx-style-dynamic-selector{background-color:".concat(_uiConstants.colors.teal700, ";color:").concat(_uiConstants.colors.white, ";cursor:auto;}"), "div.disabled.__jsx-style-dynamic-selector{color:".concat(_uiConstants.colors.grey500, ";cursor:not-allowed;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}"), "div.disabled.__jsx-style-dynamic-selector:hover{background-color:initial;}"]));
|
|
43
|
+
};
|
|
41
44
|
|
|
42
45
|
exports.SingleSelectOption = SingleSelectOption;
|
|
43
46
|
SingleSelectOption.defaultProps = {
|
|
@@ -24,7 +24,8 @@ When('the MultiSelect menu is open', () => {
|
|
|
24
24
|
Then('the MultiSelect input is left aligned with the menu', () => {
|
|
25
25
|
const selectDataTest = '[data-test="dhis2-uicore-multiselect"]';
|
|
26
26
|
const menuDataTest = '[data-test="dhis2-uicore-select-menu-menuwrapper"]';
|
|
27
|
-
cy.getAll(selectDataTest, menuDataTest).should(
|
|
27
|
+
cy.getAll(selectDataTest, menuDataTest).should(_ref => {
|
|
28
|
+
let [inputs, menus] = _ref;
|
|
28
29
|
expect(inputs.length).to.equal(1);
|
|
29
30
|
expect(menus.length).to.equal(1);
|
|
30
31
|
const $input = inputs[0];
|
|
@@ -37,7 +38,8 @@ Then('the MultiSelect input is left aligned with the menu', () => {
|
|
|
37
38
|
When('the MultiSelect input and menu have the same width', () => {
|
|
38
39
|
const inputSelector = '[data-test="dhis2-uicore-select"]';
|
|
39
40
|
const menuSelector = '[data-test="dhis2-uicore-select-menu-menuwrapper"]';
|
|
40
|
-
cy.getAll(inputSelector, menuSelector).should(
|
|
41
|
+
cy.getAll(inputSelector, menuSelector).should(_ref2 => {
|
|
42
|
+
let [$input, $menu] = _ref2;
|
|
41
43
|
const inputWidth = Math.round($input.outerWidth());
|
|
42
44
|
const menuWidth = Math.round($menu.outerWidth());
|
|
43
45
|
expect(inputWidth).to.equal(menuWidth);
|
|
@@ -32,7 +32,8 @@ When('an option is clicked', () => {
|
|
|
32
32
|
Then('the Input remains the same height', () => {
|
|
33
33
|
const emptyInputHeight = '@emptyInputHeight';
|
|
34
34
|
const inputDataTest = '[data-test="dhis2-uicore-select-input"]';
|
|
35
|
-
cy.getAll(emptyInputHeight, inputDataTest).should(
|
|
35
|
+
cy.getAll(emptyInputHeight, inputDataTest).should(_ref => {
|
|
36
|
+
let [emptyInputHeight, inputs] = _ref;
|
|
36
37
|
expect(inputs.length).to.equal(1);
|
|
37
38
|
const $input = inputs[0];
|
|
38
39
|
const inputRect = $input.getBoundingClientRect();
|
|
@@ -42,7 +43,8 @@ Then('the Input remains the same height', () => {
|
|
|
42
43
|
Then('the top of the menu is aligned with the bottom of the input', () => {
|
|
43
44
|
const selectDataTest = '[data-test="dhis2-uicore-multiselect"]';
|
|
44
45
|
const menuDataTest = '[data-test="dhis2-uicore-select-menu-menuwrapper"]';
|
|
45
|
-
cy.getAll(selectDataTest, menuDataTest).should(
|
|
46
|
+
cy.getAll(selectDataTest, menuDataTest).should(_ref2 => {
|
|
47
|
+
let [selects, menus] = _ref2;
|
|
46
48
|
expect(selects.length).to.equal(1);
|
|
47
49
|
expect(menus.length).to.equal(1);
|
|
48
50
|
const $select = selects[0];
|
|
@@ -55,7 +57,8 @@ Then('the top of the menu is aligned with the bottom of the input', () => {
|
|
|
55
57
|
Then('the bottom of the menu is aligned with the top of the input', () => {
|
|
56
58
|
const selectDataTest = '[data-test="dhis2-uicore-multiselect"]';
|
|
57
59
|
const menuDataTest = '[data-test="dhis2-uicore-select-menu-menuwrapper"]';
|
|
58
|
-
cy.getAll(selectDataTest, menuDataTest).should(
|
|
60
|
+
cy.getAll(selectDataTest, menuDataTest).should(_ref3 => {
|
|
61
|
+
let [selects, menus] = _ref3;
|
|
59
62
|
expect(selects.length).to.equal(1);
|
|
60
63
|
expect(menus.length).to.equal(1);
|
|
61
64
|
const $select = selects[0];
|
|
@@ -68,7 +71,8 @@ Then('the bottom of the menu is aligned with the top of the input', () => {
|
|
|
68
71
|
Then('it is rendered on top of the MultiSelect', () => {
|
|
69
72
|
const selectDataTest = '[data-test="dhis2-uicore-multiselect"]';
|
|
70
73
|
const menuDataTest = '[data-test="dhis2-uicore-select-menu-menuwrapper"]';
|
|
71
|
-
cy.getAll(selectDataTest, menuDataTest).should(
|
|
74
|
+
cy.getAll(selectDataTest, menuDataTest).should(_ref4 => {
|
|
75
|
+
let [selects, menus] = _ref4;
|
|
72
76
|
expect(selects.length).to.equal(1);
|
|
73
77
|
expect(menus.length).to.equal(1);
|
|
74
78
|
const $select = selects[0];
|
|
@@ -82,7 +86,8 @@ Then('it is rendered on top of the MultiSelect', () => {
|
|
|
82
86
|
Then('the left of the Menu is aligned with the left of the Input', () => {
|
|
83
87
|
const selectDataTest = '[data-test="dhis2-uicore-multiselect"]';
|
|
84
88
|
const menuDataTest = '[data-test="dhis2-uicore-select-menu-menuwrapper"]';
|
|
85
|
-
cy.getAll(selectDataTest, menuDataTest).should(
|
|
89
|
+
cy.getAll(selectDataTest, menuDataTest).should(_ref5 => {
|
|
90
|
+
let [selects, menus] = _ref5;
|
|
86
91
|
expect(selects.length).to.equal(1);
|
|
87
92
|
expect(menus.length).to.equal(1);
|
|
88
93
|
const $select = selects[0];
|
|
@@ -95,7 +100,8 @@ Then('the left of the Menu is aligned with the left of the Input', () => {
|
|
|
95
100
|
Then('the Menu and the Input have an equal width', () => {
|
|
96
101
|
const inputDataTest = '[data-test="dhis2-uicore-multiselect"] .root-input';
|
|
97
102
|
const menuDataTest = '[data-test="dhis2-uicore-select-menu-menuwrapper"]';
|
|
98
|
-
cy.getAll(inputDataTest, menuDataTest).should(
|
|
103
|
+
cy.getAll(inputDataTest, menuDataTest).should(_ref6 => {
|
|
104
|
+
let [inputs, menus] = _ref6;
|
|
99
105
|
expect(inputs.length).to.equal(1);
|
|
100
106
|
expect(menus.length).to.equal(1);
|
|
101
107
|
const $input = inputs[0];
|