@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
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WithoutOptions = exports.WithValidationText = exports.WithLoading = exports.WithLabelAndRequiredStatus = exports.WithLabel = exports.WithHelpText = exports.WithFilterable = exports.WithClearableAndSelectedOption = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _index = require("../index.js");
|
|
9
|
+
var _index2 = require("./index.js");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
var _default = exports.default = {
|
|
12
|
+
title: 'SingleSelectField'
|
|
13
|
+
};
|
|
14
|
+
const WithLabel = () => /*#__PURE__*/_react.default.createElement(_index2.SingleSelectField, {
|
|
15
|
+
label: "The label"
|
|
16
|
+
}, /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
17
|
+
value: "1",
|
|
18
|
+
label: "one"
|
|
19
|
+
}), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
20
|
+
value: "2",
|
|
21
|
+
label: "two"
|
|
22
|
+
}), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
23
|
+
value: "3",
|
|
24
|
+
label: "three"
|
|
25
|
+
}));
|
|
26
|
+
exports.WithLabel = WithLabel;
|
|
27
|
+
const WithHelpText = () => /*#__PURE__*/_react.default.createElement(_index2.SingleSelectField, {
|
|
28
|
+
helpText: "The help text"
|
|
29
|
+
}, /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
30
|
+
value: "1",
|
|
31
|
+
label: "one"
|
|
32
|
+
}), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
33
|
+
value: "2",
|
|
34
|
+
label: "two"
|
|
35
|
+
}), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
36
|
+
value: "3",
|
|
37
|
+
label: "three"
|
|
38
|
+
}));
|
|
39
|
+
exports.WithHelpText = WithHelpText;
|
|
40
|
+
const WithValidationText = () => /*#__PURE__*/_react.default.createElement(_index2.SingleSelectField, {
|
|
41
|
+
validationText: "The validation text"
|
|
42
|
+
}, /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
43
|
+
value: "1",
|
|
44
|
+
label: "one"
|
|
45
|
+
}), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
46
|
+
value: "2",
|
|
47
|
+
label: "two"
|
|
48
|
+
}), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
49
|
+
value: "3",
|
|
50
|
+
label: "three"
|
|
51
|
+
}));
|
|
52
|
+
exports.WithValidationText = WithValidationText;
|
|
53
|
+
const WithLabelAndRequiredStatus = () => /*#__PURE__*/_react.default.createElement(_index2.SingleSelectField, {
|
|
54
|
+
label: "The label",
|
|
55
|
+
required: true
|
|
56
|
+
}, /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
57
|
+
value: "1",
|
|
58
|
+
label: "one"
|
|
59
|
+
}), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
60
|
+
value: "2",
|
|
61
|
+
label: "two"
|
|
62
|
+
}), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
63
|
+
value: "3",
|
|
64
|
+
label: "three"
|
|
65
|
+
}));
|
|
66
|
+
exports.WithLabelAndRequiredStatus = WithLabelAndRequiredStatus;
|
|
67
|
+
const WithClearableAndSelectedOption = () => /*#__PURE__*/_react.default.createElement(_index2.SingleSelectField, {
|
|
68
|
+
selected: "1",
|
|
69
|
+
clearable: true
|
|
70
|
+
}, /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
71
|
+
key: "1",
|
|
72
|
+
value: "1",
|
|
73
|
+
label: "One"
|
|
74
|
+
}));
|
|
75
|
+
exports.WithClearableAndSelectedOption = WithClearableAndSelectedOption;
|
|
76
|
+
const WithFilterable = () => /*#__PURE__*/_react.default.createElement(_index2.SingleSelectField, {
|
|
77
|
+
filterable: true
|
|
78
|
+
}, /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
79
|
+
key: "1",
|
|
80
|
+
value: "1",
|
|
81
|
+
label: "One"
|
|
82
|
+
}));
|
|
83
|
+
exports.WithFilterable = WithFilterable;
|
|
84
|
+
const WithLoading = () => /*#__PURE__*/_react.default.createElement(_index2.SingleSelectField, {
|
|
85
|
+
loading: true
|
|
86
|
+
});
|
|
87
|
+
exports.WithLoading = WithLoading;
|
|
88
|
+
const WithoutOptions = () => /*#__PURE__*/_react.default.createElement(_index2.SingleSelectField, null);
|
|
89
|
+
exports.WithoutOptions = WithoutOptions;
|
|
@@ -4,32 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SingleSelectField = void 0;
|
|
7
|
-
|
|
7
|
+
var _uiConstants = require("@dhis2/ui-constants");
|
|
8
8
|
var _box = require("@dhis2-ui/box");
|
|
9
|
-
|
|
10
9
|
var _field = require("@dhis2-ui/field");
|
|
11
|
-
|
|
12
|
-
var _uiConstants = require("@dhis2/ui-constants");
|
|
13
|
-
|
|
14
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
|
|
16
11
|
var _react = _interopRequireDefault(require("react"));
|
|
17
|
-
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
var _index2 = _interopRequireDefault(require("../locales/index.js"));
|
|
21
|
-
|
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
12
|
+
var _index = _interopRequireDefault(require("../locales/index.js"));
|
|
13
|
+
var _index2 = require("../single-select/index.js");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
15
|
// TODO: translate
|
|
25
16
|
const translate = (prop, interpolationObject) => {
|
|
26
17
|
if (typeof prop === 'function') {
|
|
27
18
|
return prop(interpolationObject);
|
|
28
19
|
}
|
|
29
|
-
|
|
30
20
|
return prop;
|
|
31
21
|
};
|
|
32
|
-
|
|
33
22
|
class SingleSelectField extends _react.default.Component {
|
|
34
23
|
render() {
|
|
35
24
|
const {
|
|
@@ -80,7 +69,7 @@ class SingleSelectField extends _react.default.Component {
|
|
|
80
69
|
}, /*#__PURE__*/_react.default.createElement(_box.Box, {
|
|
81
70
|
width: inputWidth,
|
|
82
71
|
minWidth: "100px"
|
|
83
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
72
|
+
}, /*#__PURE__*/_react.default.createElement(_index2.SingleSelect, {
|
|
84
73
|
selected: selected,
|
|
85
74
|
tabIndex: tabIndex,
|
|
86
75
|
maxHeight: maxHeight,
|
|
@@ -107,107 +96,77 @@ class SingleSelectField extends _react.default.Component {
|
|
|
107
96
|
dense: dense
|
|
108
97
|
}, children)));
|
|
109
98
|
}
|
|
110
|
-
|
|
111
99
|
}
|
|
112
|
-
|
|
113
100
|
exports.SingleSelectField = SingleSelectField;
|
|
114
101
|
SingleSelectField.defaultProps = {
|
|
115
102
|
dataTest: 'dhis2-uiwidgets-singleselectfield',
|
|
116
103
|
selected: '',
|
|
117
|
-
clearText: () =>
|
|
118
|
-
empty: () =>
|
|
119
|
-
filterPlaceholder: () =>
|
|
120
|
-
loadingText: () =>
|
|
121
|
-
noMatchText: () =>
|
|
104
|
+
clearText: () => _index.default.t('Clear'),
|
|
105
|
+
empty: () => _index.default.t('No data found'),
|
|
106
|
+
filterPlaceholder: () => _index.default.t('Type to filter options'),
|
|
107
|
+
loadingText: () => _index.default.t('Loading options'),
|
|
108
|
+
noMatchText: () => _index.default.t('No options found')
|
|
122
109
|
};
|
|
123
110
|
SingleSelectField.propTypes = {
|
|
124
111
|
/** Should be `SingleSelectOption` components */
|
|
125
112
|
children: _propTypes.default.node,
|
|
126
113
|
className: _propTypes.default.string,
|
|
127
|
-
|
|
128
114
|
/** Label for the button that clears selections */
|
|
129
115
|
clearText: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]),
|
|
130
|
-
|
|
131
116
|
/** Adds a button to the SingleSelect that clears selections when pressed */
|
|
132
117
|
clearable: _propTypes.default.bool,
|
|
133
118
|
dataTest: _propTypes.default.string,
|
|
134
|
-
|
|
135
119
|
/** Makes the SingleSelect smaller */
|
|
136
120
|
dense: _propTypes.default.bool,
|
|
137
|
-
|
|
138
121
|
/** Disables the SingleSelect */
|
|
139
122
|
disabled: _propTypes.default.bool,
|
|
140
|
-
|
|
141
123
|
/** Text to display when there are no options */
|
|
142
124
|
empty: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
143
|
-
|
|
144
125
|
/** Adds 'error' appearance for validation feedback. Mutually exclusive with 'valid' and 'warning' props */
|
|
145
126
|
error: _uiConstants.sharedPropTypes.statusPropType,
|
|
146
|
-
|
|
147
127
|
/** Placeholder text to show in the filter field when it is empty */
|
|
148
128
|
filterPlaceholder: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
149
|
-
|
|
150
129
|
/** Adds a field to filter options */
|
|
151
130
|
filterable: _propTypes.default.bool,
|
|
152
|
-
|
|
153
131
|
/** Useful guiding text to display below the SingleSelect */
|
|
154
132
|
helpText: _propTypes.default.string,
|
|
155
|
-
|
|
156
133
|
/** Grabs initial focus on the page */
|
|
157
134
|
initialFocus: _propTypes.default.bool,
|
|
158
|
-
|
|
159
135
|
/** Constrains the height of the input */
|
|
160
136
|
inputMaxHeight: _propTypes.default.string,
|
|
161
|
-
|
|
162
137
|
/** Sets the width of the input. Can be any valid CSS measurement */
|
|
163
138
|
inputWidth: _propTypes.default.string,
|
|
164
|
-
|
|
165
139
|
/** Text for the label above the SingleSelect */
|
|
166
140
|
label: _propTypes.default.string,
|
|
167
|
-
|
|
168
141
|
/** Applies a loading appearance to the dropdown options */
|
|
169
142
|
loading: _propTypes.default.bool,
|
|
170
|
-
|
|
171
143
|
/** Text to display when `loading` is true */
|
|
172
144
|
loadingText: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]),
|
|
173
|
-
|
|
174
145
|
/** Constrains height of the SingleSelect */
|
|
175
146
|
maxHeight: _propTypes.default.string,
|
|
176
|
-
|
|
177
147
|
/** Text to display when there are no filter results */
|
|
178
148
|
noMatchText: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]),
|
|
179
|
-
|
|
180
149
|
/** Placeholder text when the SingleSelect is empty */
|
|
181
150
|
placeholder: _propTypes.default.string,
|
|
182
|
-
|
|
183
151
|
/** Leading text to prefix selections */
|
|
184
152
|
prefix: _propTypes.default.string,
|
|
185
|
-
|
|
186
153
|
/** Indicates that a selection is required */
|
|
187
154
|
required: _propTypes.default.bool,
|
|
188
|
-
|
|
189
155
|
/** Selected item in the SingleSelect (the string should refer to the item's `value` attribute) */
|
|
190
156
|
selected: _propTypes.default.string,
|
|
191
157
|
tabIndex: _propTypes.default.string,
|
|
192
|
-
|
|
193
158
|
/** Adds 'valid' appearance for validation feedback. Mutually exclusive with 'error' and 'warning' props */
|
|
194
159
|
valid: _uiConstants.sharedPropTypes.statusPropType,
|
|
195
|
-
|
|
196
160
|
/** Text to provide form validation feedback. Receives styles according to validation status */
|
|
197
161
|
validationText: _propTypes.default.string,
|
|
198
|
-
|
|
199
162
|
/** Adds 'warning' appearance for validation feedback. Mutually exclusive with 'valid' and 'error' props */
|
|
200
163
|
warning: _uiConstants.sharedPropTypes.statusPropType,
|
|
201
|
-
|
|
202
164
|
/** Called with signature `({ selected: string }, event)` */
|
|
203
165
|
onBlur: _propTypes.default.func,
|
|
204
|
-
|
|
205
166
|
/** Called with signature `({ selected: string }, event)` */
|
|
206
167
|
onChange: _propTypes.default.func,
|
|
207
|
-
|
|
208
168
|
/** Called with signature `({ selected: string }, event)` */
|
|
209
169
|
onFocus: _propTypes.default.func,
|
|
210
|
-
|
|
211
170
|
/** Called with signature `({ selected: string }, event)` */
|
|
212
171
|
onKeyDown: _propTypes.default.func
|
|
213
172
|
};
|
|
@@ -4,21 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
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
|
-
|
|
8
7
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _index = require("../index.js");
|
|
13
|
-
|
|
14
10
|
var _index2 = require("./index.js");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
const description = `
|
|
13
|
+
\`SingleSelectField\` is a wrapper around a \`SingleSelect\` component that adds a label, help text, validation text, and other features.
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
See the SingleSelect for more information, and read more at [Design System: Select](https://github.com/dhis2/design-system/blob/master/molecules/select.md#multiple-selection).
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
\`\`\`js
|
|
18
|
+
import { SingleSelectField, SingleSelectOption } from '@dhis2/ui'
|
|
19
|
+
\`\`\`
|
|
21
20
|
|
|
21
|
+
_**Note**: The dropdowns in some of the following stories won't appear correctly on this page. View these demos in the 'Canvas' tab._
|
|
22
|
+
`;
|
|
23
|
+
const onChange = selected => alert(`Selected changed to: ${JSON.stringify(selected, null, 2)}`);
|
|
22
24
|
const options = [/*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
23
25
|
key: "1",
|
|
24
26
|
value: "1",
|
|
@@ -60,7 +62,7 @@ const options = [/*#__PURE__*/_react.default.createElement(_index.SingleSelectOp
|
|
|
60
62
|
value: "10",
|
|
61
63
|
label: "ten"
|
|
62
64
|
})];
|
|
63
|
-
var _default = {
|
|
65
|
+
var _default = exports.default = {
|
|
64
66
|
title: 'Single Select Field',
|
|
65
67
|
component: _index2.SingleSelectField,
|
|
66
68
|
subcomponents: {
|
|
@@ -74,77 +76,70 @@ var _default = {
|
|
|
74
76
|
}
|
|
75
77
|
},
|
|
76
78
|
// default args for stories
|
|
77
|
-
args: {
|
|
79
|
+
args: {
|
|
80
|
+
// Fix default prop issues - causes 'i18n is not defined' error
|
|
78
81
|
..._index2.SingleSelectField.defaultProps,
|
|
79
82
|
label: 'Default label',
|
|
80
83
|
children: options,
|
|
81
84
|
onChange: onChange
|
|
82
85
|
},
|
|
83
86
|
argTypes: {
|
|
84
|
-
valid: {
|
|
87
|
+
valid: {
|
|
88
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
85
89
|
},
|
|
86
|
-
warning: {
|
|
90
|
+
warning: {
|
|
91
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
87
92
|
},
|
|
88
|
-
error: {
|
|
93
|
+
error: {
|
|
94
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
};
|
|
92
|
-
exports.default = _default;
|
|
93
|
-
|
|
94
98
|
const Template = args => /*#__PURE__*/_react.default.createElement(_index2.SingleSelectField, args);
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
exports.Default = Default;
|
|
98
|
-
const WithHelpText = Template.bind({});
|
|
99
|
-
exports.WithHelpText = WithHelpText;
|
|
99
|
+
const Default = exports.Default = Template.bind({});
|
|
100
|
+
const WithHelpText = exports.WithHelpText = Template.bind({});
|
|
100
101
|
WithHelpText.args = {
|
|
101
102
|
helpText: 'Helpful text.'
|
|
102
103
|
};
|
|
103
104
|
WithHelpText.parameters = {
|
|
104
105
|
docs: {
|
|
105
106
|
description: {
|
|
106
|
-
story:
|
|
107
|
+
story: `_**Note**: The dropdowns in the following stories won't appear correctly on this page. View these demos in the 'Canvas' tab._`
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
};
|
|
110
|
-
const StatusValid = Template.bind({});
|
|
111
|
-
exports.StatusValid = StatusValid;
|
|
111
|
+
const StatusValid = exports.StatusValid = Template.bind({});
|
|
112
112
|
StatusValid.args = {
|
|
113
113
|
valid: true,
|
|
114
114
|
validationText: 'Totally valid!',
|
|
115
115
|
...WithHelpText.args
|
|
116
116
|
};
|
|
117
117
|
StatusValid.storyName = 'Status: Valid';
|
|
118
|
-
const StatusWarning = Template.bind({});
|
|
119
|
-
exports.StatusWarning = StatusWarning;
|
|
118
|
+
const StatusWarning = exports.StatusWarning = Template.bind({});
|
|
120
119
|
StatusWarning.args = {
|
|
121
120
|
warning: true,
|
|
122
121
|
validationText: 'Hm, not quite, I warn thee!',
|
|
123
122
|
...WithHelpText.args
|
|
124
123
|
};
|
|
125
124
|
StatusWarning.storyName = 'Status: Warning';
|
|
126
|
-
const StatusError = Template.bind({});
|
|
127
|
-
exports.StatusError = StatusError;
|
|
125
|
+
const StatusError = exports.StatusError = Template.bind({});
|
|
128
126
|
StatusError.args = {
|
|
129
127
|
error: true,
|
|
130
128
|
validationText: 'That value is wrong. Sorry!',
|
|
131
129
|
...WithHelpText.args
|
|
132
130
|
};
|
|
133
131
|
StatusError.storyName = 'Status: Error';
|
|
134
|
-
const Required = Template.bind({});
|
|
135
|
-
exports.Required = Required;
|
|
132
|
+
const Required = exports.Required = Template.bind({});
|
|
136
133
|
Required.args = {
|
|
137
134
|
required: true
|
|
138
135
|
};
|
|
139
|
-
const InputWidth = Template.bind({});
|
|
140
|
-
exports.InputWidth = InputWidth;
|
|
136
|
+
const InputWidth = exports.InputWidth = Template.bind({});
|
|
141
137
|
InputWidth.args = {
|
|
142
138
|
inputWidth: '200px',
|
|
143
139
|
label: 'A very long label indeed, well at least longer than the input field to show how it looks and works and stuff',
|
|
144
140
|
required: true
|
|
145
141
|
};
|
|
146
|
-
const DefaultClearText = Template.bind({});
|
|
147
|
-
exports.DefaultClearText = DefaultClearText;
|
|
142
|
+
const DefaultClearText = exports.DefaultClearText = Template.bind({});
|
|
148
143
|
DefaultClearText.args = {
|
|
149
144
|
selected: '1',
|
|
150
145
|
clearable: true,
|
|
@@ -156,22 +151,19 @@ DefaultClearText.args = {
|
|
|
156
151
|
})
|
|
157
152
|
};
|
|
158
153
|
DefaultClearText.storyName = 'Default: clearText';
|
|
159
|
-
const DefaultEmpty = Template.bind({});
|
|
160
|
-
exports.DefaultEmpty = DefaultEmpty;
|
|
154
|
+
const DefaultEmpty = exports.DefaultEmpty = Template.bind({});
|
|
161
155
|
DefaultEmpty.args = {
|
|
162
156
|
children: null,
|
|
163
157
|
label: null
|
|
164
158
|
};
|
|
165
159
|
DefaultEmpty.storyName = 'Default: empty';
|
|
166
|
-
const DefaultFilterPlaceholderAndNoMatchText = Template.bind({});
|
|
167
|
-
exports.DefaultFilterPlaceholderAndNoMatchText = DefaultFilterPlaceholderAndNoMatchText;
|
|
160
|
+
const DefaultFilterPlaceholderAndNoMatchText = exports.DefaultFilterPlaceholderAndNoMatchText = Template.bind({});
|
|
168
161
|
DefaultFilterPlaceholderAndNoMatchText.args = {
|
|
169
162
|
filterable: true,
|
|
170
163
|
...DefaultEmpty.args
|
|
171
164
|
};
|
|
172
165
|
DefaultFilterPlaceholderAndNoMatchText.storyName = 'Default: filterPlaceholder and noMatchText';
|
|
173
|
-
const DefaultLoadingText = Template.bind({});
|
|
174
|
-
exports.DefaultLoadingText = DefaultLoadingText;
|
|
166
|
+
const DefaultLoadingText = exports.DefaultLoadingText = Template.bind({});
|
|
175
167
|
DefaultLoadingText.args = {
|
|
176
168
|
loading: true,
|
|
177
169
|
...DefaultEmpty.args
|
|
@@ -4,19 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SingleSelectOption = 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 _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
|
|
16
11
|
var _react = _interopRequireDefault(require("react"));
|
|
17
|
-
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
13
|
const SingleSelectOption = _ref => {
|
|
21
14
|
let {
|
|
22
15
|
label,
|
|
@@ -39,9 +32,8 @@ const SingleSelectOption = _ref => {
|
|
|
39
32
|
}, label, /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
40
33
|
id: "3808134379",
|
|
41
34
|
dynamic: [_uiConstants.colors.grey900, _uiConstants.spacers.dp8, _uiConstants.spacers.dp12, _uiConstants.colors.grey200, _uiConstants.colors.teal700, _uiConstants.colors.white, _uiConstants.colors.grey500]
|
|
42
|
-
}, [
|
|
35
|
+
}, [`div.__jsx-style-dynamic-selector{cursor:pointer;font-size:14px;-webkit-text-decoration:none;text-decoration:none;color:${_uiConstants.colors.grey900};padding-block:${_uiConstants.spacers.dp8};padding-inline:${_uiConstants.spacers.dp12};}`, `div.__jsx-style-dynamic-selector:hover{background-color:${_uiConstants.colors.grey200};}`, `div.__jsx-style-dynamic-selector:active,div.active.__jsx-style-dynamic-selector{background-color:${_uiConstants.colors.teal700};color:${_uiConstants.colors.white};cursor:auto;}`, `div.disabled.__jsx-style-dynamic-selector{color:${_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
36
|
};
|
|
44
|
-
|
|
45
37
|
exports.SingleSelectOption = SingleSelectOption;
|
|
46
38
|
SingleSelectOption.defaultProps = {
|
|
47
39
|
dataTest: 'dhis2-uicore-singleselectoption'
|
|
@@ -8,15 +8,18 @@ describe('<SelectionList />', () => {
|
|
|
8
8
|
beforeEach(() => {
|
|
9
9
|
// Ensure process.env is also reset for cached modules
|
|
10
10
|
jest.resetModules();
|
|
11
|
-
process.env = {
|
|
12
|
-
|
|
11
|
+
process.env = {
|
|
12
|
+
...env
|
|
13
|
+
};
|
|
13
14
|
|
|
15
|
+
// Allow spying on console.error and silence rendering errors
|
|
14
16
|
jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
15
17
|
});
|
|
16
18
|
afterEach(() => {
|
|
17
19
|
// Restore process.env to original state
|
|
18
|
-
process.env = env;
|
|
20
|
+
process.env = env;
|
|
19
21
|
|
|
22
|
+
// Restore all mocks back to original values
|
|
20
23
|
jest.restoreAllMocks();
|
|
21
24
|
});
|
|
22
25
|
describe('production', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Given, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given('a MultiSelect with onBlur handler is rendered', () => {
|
|
3
|
-
cy.visitStory('MultiSelect', 'With
|
|
3
|
+
cy.visitStory('MultiSelect', 'With on blur');
|
|
4
4
|
});
|
|
5
5
|
Then('the onBlur handler is called', () => {
|
|
6
6
|
cy.window().should(win => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Given, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given('a MultiSelect with onFocus handler is rendered', () => {
|
|
3
|
-
cy.visitStory('MultiSelect', 'With
|
|
3
|
+
cy.visitStory('MultiSelect', 'With on focus');
|
|
4
4
|
});
|
|
5
5
|
Then('the onFocus handler is called', () => {
|
|
6
6
|
cy.window().should(win => {
|
|
@@ -3,7 +3,7 @@ Given('a MultiSelect with more than ten options is rendered', () => {
|
|
|
3
3
|
cy.visitStory('MultiSelect', 'With more than ten options');
|
|
4
4
|
});
|
|
5
5
|
Given('a MultiSelect with more than three options and a 100px max-height is rendered', () => {
|
|
6
|
-
cy.visitStory('MultiSelect', 'With more than three options and a
|
|
6
|
+
cy.visitStory('MultiSelect', 'With more than three options and a 100 px max-height');
|
|
7
7
|
});
|
|
8
8
|
Then('has the default max-height', () => {
|
|
9
9
|
cy.get('[data-test="dhis2-uicore-select-menu-menuwrapper"]').should('have.css', 'max-height', '280px');
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given('a MultiSelect with a disabled option and onChange handler is rendered', () => {
|
|
3
|
-
cy.visitStory('MultiSelect', 'With disabled option and
|
|
3
|
+
cy.visitStory('MultiSelect', 'With disabled option and on change');
|
|
4
4
|
});
|
|
5
5
|
Given('a MultiSelect with custom options and onChange handler is rendered', () => {
|
|
6
|
-
cy.visitStory('MultiSelect', 'With custom options and
|
|
6
|
+
cy.visitStory('MultiSelect', 'With custom options and on change');
|
|
7
7
|
});
|
|
8
8
|
When('an option is clicked', () => {
|
|
9
9
|
cy.contains('option one').click();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given('a clearable MultiSelect with a selection and onchange handler is rendered', () => {
|
|
3
|
-
cy.visitStory('MultiSelect', 'With clear button, selection and
|
|
3
|
+
cy.visitStory('MultiSelect', 'With clear button, selection and on change');
|
|
4
4
|
});
|
|
5
5
|
When('the clear button is clicked', () => {
|
|
6
6
|
cy.get('[data-test="dhis2-uicore-multiselect-clear"]').click();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given('a MultiSelect with options and onChange handler is rendered', () => {
|
|
3
|
-
cy.visitStory('MultiSelect', 'With options and
|
|
3
|
+
cy.visitStory('MultiSelect', 'With options and on change');
|
|
4
4
|
});
|
|
5
5
|
Given('a MultiSelect with options, a selection and onChange handler is rendered', () => {
|
|
6
|
-
cy.visitStory('MultiSelect', 'With options, a selection and
|
|
6
|
+
cy.visitStory('MultiSelect', 'With options, a selection and on change');
|
|
7
7
|
});
|
|
8
8
|
Given('a MultiSelect is rendered to which options can be added', () => {
|
|
9
9
|
cy.visitStory('MultiSelect', 'With options that can be added to the input');
|
|
@@ -6,7 +6,7 @@ Given('a MultiSelect with hidden sibling elements', () => {
|
|
|
6
6
|
});
|
|
7
7
|
});
|
|
8
8
|
When('the button is clicked', () => {
|
|
9
|
-
cy.get('button').click();
|
|
9
|
+
cy.get('[data-test="dhis2-uicore-button"]').click();
|
|
10
10
|
});
|
|
11
11
|
Then('the siblings are displayed', () => {
|
|
12
12
|
cy.get('.toggler').should('exist').and('have.length', 2);
|
|
@@ -50,7 +50,7 @@ Then('the top of the menu is aligned with the bottom of the input', () => {
|
|
|
50
50
|
const $menu = menus[0];
|
|
51
51
|
const selectRect = $select.getBoundingClientRect();
|
|
52
52
|
const menuRect = $menu.getBoundingClientRect();
|
|
53
|
-
expect(menuRect.top).to.
|
|
53
|
+
expect(menuRect.top).to.be.closeTo(selectRect.bottom, 1);
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
56
|
Then('the bottom of the menu is aligned with the top of the input', () => {
|
|
@@ -64,7 +64,7 @@ Then('the bottom of the menu is aligned with the top of the input', () => {
|
|
|
64
64
|
const $menu = menus[0];
|
|
65
65
|
const selectRect = $select.getBoundingClientRect();
|
|
66
66
|
const menuRect = $menu.getBoundingClientRect();
|
|
67
|
-
expect(selectRect.top).to.
|
|
67
|
+
expect(selectRect.top).to.be.closeTo(menuRect.bottom, 1);
|
|
68
68
|
});
|
|
69
69
|
});
|
|
70
70
|
Then('it is rendered on top of the MultiSelect', () => {
|
|
@@ -93,7 +93,7 @@ Then('the left of the Menu is aligned with the left of the Input', () => {
|
|
|
93
93
|
const $menu = menus[0];
|
|
94
94
|
const selectRect = $select.getBoundingClientRect();
|
|
95
95
|
const menuRect = $menu.getBoundingClientRect();
|
|
96
|
-
expect(selectRect.left).to.
|
|
96
|
+
expect(selectRect.left).to.be.closeTo(menuRect.left, 1);
|
|
97
97
|
});
|
|
98
98
|
});
|
|
99
99
|
Then('the Menu and the Input have an equal width', () => {
|
|
@@ -107,6 +107,6 @@ Then('the Menu and the Input have an equal width', () => {
|
|
|
107
107
|
const $menu = menus[0];
|
|
108
108
|
const inputRect = $input.getBoundingClientRect();
|
|
109
109
|
const menuRect = $menu.getBoundingClientRect();
|
|
110
|
-
expect(inputRect.width).to.
|
|
110
|
+
expect(inputRect.width).to.be.closeTo(menuRect.width, 1);
|
|
111
111
|
});
|
|
112
112
|
});
|
|
@@ -2,7 +2,6 @@ import PropTypes from 'prop-types';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { FilterableMenu as CommonFilterableMenu } from '../select/index.js';
|
|
4
4
|
import { Menu } from './menu.js';
|
|
5
|
-
|
|
6
5
|
const FilterableMenu = _ref => {
|
|
7
6
|
let {
|
|
8
7
|
dataTest,
|
|
@@ -28,7 +27,6 @@ const FilterableMenu = _ref => {
|
|
|
28
27
|
Menu: Menu
|
|
29
28
|
});
|
|
30
29
|
};
|
|
31
|
-
|
|
32
30
|
FilterableMenu.propTypes = {
|
|
33
31
|
dataTest: PropTypes.string.isRequired,
|
|
34
32
|
noMatchText: PropTypes.string.isRequired,
|