@dhis2-ui/select 9.12.0-alpha.4 → 9.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/multi-select/__tests__/multi-select.test.js +1 -1
- package/build/cjs/multi-select/__tests__/selection-list.test.js +4 -4
- package/build/cjs/multi-select/input.js +1 -4
- package/build/cjs/multi-select/menu.js +1 -4
- package/build/cjs/multi-select/multi-select.js +4 -6
- package/build/cjs/multi-select-field/__tests__/multi-select-field.test.js +1 -1
- package/build/cjs/multi-select-field/multi-select-field.js +12 -9
- package/build/cjs/multi-select-field/multi-select-field.prod.stories.js +6 -1
- package/build/cjs/multi-select-option/multi-select-option.js +1 -4
- package/build/cjs/select/__tests__/select.test.js +1 -1
- package/build/cjs/select/input-wrapper.js +1 -4
- package/build/cjs/select/menu-wrapper.js +2 -6
- package/build/cjs/select/select.js +2 -2
- package/build/cjs/single-select/__tests__/selection.test.js +4 -4
- package/build/cjs/single-select/__tests__/single-select.test.js +1 -1
- package/build/cjs/single-select/input.js +1 -4
- package/build/cjs/single-select/menu.js +1 -4
- package/build/cjs/single-select/single-select.js +2 -6
- package/build/cjs/single-select-field/__tests__/single-select-field.test.js +1 -1
- package/build/cjs/single-select-field/single-select-field.e2e.stories.js +2 -27
- package/build/cjs/single-select-field/single-select-field.js +12 -9
- package/build/cjs/single-select-field/single-select-field.prod.stories.js +7 -1
- package/build/cjs/single-select-option/single-select-option.js +1 -4
- package/build/es/multi-select/__tests__/multi-select.test.js +1 -1
- package/build/es/multi-select/__tests__/selection-list.test.js +4 -4
- package/build/es/multi-select/input.js +1 -4
- package/build/es/multi-select/menu.js +1 -4
- package/build/es/multi-select/multi-select.js +5 -6
- package/build/es/multi-select-field/__tests__/multi-select-field.test.js +1 -1
- package/build/es/multi-select-field/multi-select-field.js +12 -9
- package/build/es/multi-select-field/multi-select-field.prod.stories.js +6 -1
- package/build/es/multi-select-option/multi-select-option.js +1 -4
- package/build/es/select/__tests__/select.test.js +1 -1
- package/build/es/select/input-wrapper.js +1 -4
- package/build/es/select/menu-wrapper.js +2 -6
- package/build/es/select/select.js +2 -2
- package/build/es/single-select/__tests__/selection.test.js +4 -4
- package/build/es/single-select/__tests__/single-select.test.js +1 -1
- package/build/es/single-select/input.js +1 -4
- package/build/es/single-select/menu.js +1 -4
- package/build/es/single-select/single-select.js +2 -6
- package/build/es/single-select-field/__tests__/single-select-field.test.js +1 -1
- package/build/es/single-select-field/single-select-field.e2e.stories.js +1 -25
- package/build/es/single-select-field/single-select-field.js +12 -9
- package/build/es/single-select-field/single-select-field.prod.stories.js +7 -1
- package/build/es/single-select-option/single-select-option.js +1 -4
- package/package.json +19 -19
- package/build/cjs/single-select-field/features/can_show_conditionally/index.js +0 -23
- package/build/cjs/single-select-field/features/can_show_conditionally.feature +0 -7
- package/build/es/single-select-field/features/can_show_conditionally/index.js +0 -21
- package/build/es/single-select-field/features/can_show_conditionally.feature +0 -7
|
@@ -7,7 +7,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
7
7
|
describe('<MultiSelect />', () => {
|
|
8
8
|
it('should call the onKeyDown callback when provided', () => {
|
|
9
9
|
const onKeyDown = jest.fn();
|
|
10
|
-
(0, _react.render)(
|
|
10
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(_multiSelect.MultiSelect, {
|
|
11
11
|
placeholder: "placeholder",
|
|
12
12
|
onKeyDown: onKeyDown
|
|
13
13
|
}));
|
|
@@ -35,7 +35,7 @@ describe('<SelectionList />', () => {
|
|
|
35
35
|
});
|
|
36
36
|
const selected = ['value'];
|
|
37
37
|
expect(() => {
|
|
38
|
-
(0, _react.render)(
|
|
38
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(_selectionList.SelectionList, {
|
|
39
39
|
selected: selected,
|
|
40
40
|
options: options,
|
|
41
41
|
disabled: false,
|
|
@@ -53,7 +53,7 @@ describe('<SelectionList />', () => {
|
|
|
53
53
|
const selected = ['value'];
|
|
54
54
|
const {
|
|
55
55
|
getByText
|
|
56
|
-
} = (0, _react.render)(
|
|
56
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_selectionList.SelectionList, {
|
|
57
57
|
selected: selected,
|
|
58
58
|
options: options,
|
|
59
59
|
disabled: false,
|
|
@@ -69,7 +69,7 @@ describe('<SelectionList />', () => {
|
|
|
69
69
|
value: "1"
|
|
70
70
|
});
|
|
71
71
|
const selected = ['value'];
|
|
72
|
-
(0, _react.render)(
|
|
72
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(_selectionList.SelectionList, {
|
|
73
73
|
selected: selected,
|
|
74
74
|
options: options,
|
|
75
75
|
disabled: false,
|
|
@@ -88,7 +88,7 @@ describe('<SelectionList />', () => {
|
|
|
88
88
|
});
|
|
89
89
|
const selected = ['value'];
|
|
90
90
|
expect(() => {
|
|
91
|
-
(0, _react.render)(
|
|
91
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(_selectionList.SelectionList, {
|
|
92
92
|
selected: selected,
|
|
93
93
|
options: options,
|
|
94
94
|
disabled: false,
|
|
@@ -25,7 +25,7 @@ const Input = _ref => {
|
|
|
25
25
|
options,
|
|
26
26
|
className,
|
|
27
27
|
disabled,
|
|
28
|
-
inputMaxHeight
|
|
28
|
+
inputMaxHeight = '100px'
|
|
29
29
|
} = _ref;
|
|
30
30
|
const hasSelection = selected.length > 0;
|
|
31
31
|
const onClear = e => {
|
|
@@ -65,9 +65,6 @@ const Input = _ref => {
|
|
|
65
65
|
}, [`.root-input.__jsx-style-dynamic-selector{max-height:${inputMaxHeight};}`]));
|
|
66
66
|
};
|
|
67
67
|
exports.Input = Input;
|
|
68
|
-
Input.defaultProps = {
|
|
69
|
-
inputMaxHeight: '100px'
|
|
70
|
-
};
|
|
71
68
|
Input.propTypes = {
|
|
72
69
|
dataTest: _propTypes2.default.string.isRequired,
|
|
73
70
|
className: _propTypes2.default.string,
|
|
@@ -43,7 +43,7 @@ const Menu = _ref2 => {
|
|
|
43
43
|
options,
|
|
44
44
|
onChange,
|
|
45
45
|
selected,
|
|
46
|
-
empty,
|
|
46
|
+
empty = '',
|
|
47
47
|
dataTest
|
|
48
48
|
} = _ref2;
|
|
49
49
|
const renderedOptions = (0, _index.filterIgnored)(options);
|
|
@@ -92,9 +92,6 @@ const Menu = _ref2 => {
|
|
|
92
92
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
|
|
93
93
|
};
|
|
94
94
|
exports.Menu = Menu;
|
|
95
|
-
Menu.defaultProps = {
|
|
96
|
-
empty: ''
|
|
97
|
-
};
|
|
98
95
|
Menu.propTypes = {
|
|
99
96
|
dataTest: _propTypes.default.string.isRequired,
|
|
100
97
|
empty: _propTypes.default.node,
|
|
@@ -15,10 +15,12 @@ var _filterableMenu = require("./filterable-menu.js");
|
|
|
15
15
|
var _input = require("./input.js");
|
|
16
16
|
var _menu = require("./menu.js");
|
|
17
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
+
// stable object reference
|
|
19
|
+
const staticArr = [];
|
|
18
20
|
const MultiSelect = _ref => {
|
|
19
21
|
let {
|
|
20
22
|
className,
|
|
21
|
-
selected,
|
|
23
|
+
selected = staticArr,
|
|
22
24
|
tabIndex,
|
|
23
25
|
maxHeight,
|
|
24
26
|
inputMaxHeight,
|
|
@@ -43,7 +45,7 @@ const MultiSelect = _ref => {
|
|
|
43
45
|
noMatchText,
|
|
44
46
|
initialFocus,
|
|
45
47
|
dense,
|
|
46
|
-
dataTest
|
|
48
|
+
dataTest = 'dhis2-uicore-multiselect'
|
|
47
49
|
} = _ref;
|
|
48
50
|
// If the select is filterable, use a filterable menu
|
|
49
51
|
const menu = filterable ? /*#__PURE__*/_react.default.createElement(_filterableMenu.FilterableMenu, {
|
|
@@ -97,10 +99,6 @@ const MultiSelect = _ref => {
|
|
|
97
99
|
}, [`.root.__jsx-style-dynamic-selector{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:${_uiConstants.spacers.dp8};}`, ".root-input.__jsx-style-dynamic-selector{-webkit-flex:1;-ms-flex:1;flex:1;}"]));
|
|
98
100
|
};
|
|
99
101
|
exports.MultiSelect = MultiSelect;
|
|
100
|
-
MultiSelect.defaultProps = {
|
|
101
|
-
selected: [],
|
|
102
|
-
dataTest: 'dhis2-uicore-multiselect'
|
|
103
|
-
};
|
|
104
102
|
MultiSelect.propTypes = {
|
|
105
103
|
children: _propTypes2.default.node,
|
|
106
104
|
className: _propTypes2.default.string,
|
|
@@ -7,7 +7,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
7
7
|
describe('<MultiSelect />', () => {
|
|
8
8
|
it('should call the onKeyDown callback when provided', () => {
|
|
9
9
|
const onKeyDown = jest.fn();
|
|
10
|
-
(0, _react.render)(
|
|
10
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(_multiSelectField.MultiSelectField, {
|
|
11
11
|
label: "label",
|
|
12
12
|
placeholder: "placeholder",
|
|
13
13
|
onKeyDown: onKeyDown
|
|
@@ -12,6 +12,9 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
12
12
|
var _index = _interopRequireDefault(require("../locales/index.js"));
|
|
13
13
|
var _index2 = require("../multi-select/index.js");
|
|
14
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
17
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
18
|
// TODO: translate
|
|
16
19
|
const translate = (prop, interpolationObject) => {
|
|
17
20
|
if (typeof prop === 'function') {
|
|
@@ -34,7 +37,7 @@ class MultiSelectField extends _react.default.Component {
|
|
|
34
37
|
disabled,
|
|
35
38
|
warning,
|
|
36
39
|
loading,
|
|
37
|
-
selected,
|
|
40
|
+
selected = MultiSelectField.defaultProps.selected,
|
|
38
41
|
tabIndex,
|
|
39
42
|
helpText,
|
|
40
43
|
validationText,
|
|
@@ -43,17 +46,17 @@ class MultiSelectField extends _react.default.Component {
|
|
|
43
46
|
inputWidth,
|
|
44
47
|
children,
|
|
45
48
|
clearable,
|
|
46
|
-
clearText,
|
|
49
|
+
clearText = MultiSelectField.defaultProps.clearText,
|
|
47
50
|
filterable,
|
|
48
|
-
filterPlaceholder,
|
|
51
|
+
filterPlaceholder = MultiSelectField.defaultProps.filterPlaceholder,
|
|
49
52
|
placeholder,
|
|
50
53
|
prefix,
|
|
51
|
-
empty,
|
|
52
|
-
loadingText,
|
|
53
|
-
noMatchText,
|
|
54
|
+
empty = MultiSelectField.defaultProps.empty,
|
|
55
|
+
loadingText = MultiSelectField.defaultProps.loadingText,
|
|
56
|
+
noMatchText = MultiSelectField.defaultProps.noMatchText,
|
|
54
57
|
initialFocus,
|
|
55
58
|
dense,
|
|
56
|
-
dataTest
|
|
59
|
+
dataTest = MultiSelectField.defaultProps.dataTest
|
|
57
60
|
} = this.props;
|
|
58
61
|
return /*#__PURE__*/_react.default.createElement(_field.Field, {
|
|
59
62
|
className: className,
|
|
@@ -98,7 +101,7 @@ class MultiSelectField extends _react.default.Component {
|
|
|
98
101
|
}
|
|
99
102
|
}
|
|
100
103
|
exports.MultiSelectField = MultiSelectField;
|
|
101
|
-
MultiSelectField
|
|
104
|
+
_defineProperty(MultiSelectField, "defaultProps", {
|
|
102
105
|
selected: [],
|
|
103
106
|
dataTest: 'dhis2-uiwidgets-multiselectfield',
|
|
104
107
|
clearText: () => _index.default.t('Clear'),
|
|
@@ -106,7 +109,7 @@ MultiSelectField.defaultProps = {
|
|
|
106
109
|
filterPlaceholder: () => _index.default.t('Type to filter options'),
|
|
107
110
|
loadingText: () => _index.default.t('Loading options'),
|
|
108
111
|
noMatchText: () => _index.default.t('No options found')
|
|
109
|
-
};
|
|
112
|
+
});
|
|
110
113
|
MultiSelectField.propTypes = {
|
|
111
114
|
/** Should be `MultiSelectOption` components */
|
|
112
115
|
children: _propTypes.default.node,
|
|
@@ -78,7 +78,12 @@ var _default = exports.default = {
|
|
|
78
78
|
// default args for stories
|
|
79
79
|
args: {
|
|
80
80
|
// Fix default prop issues - causes 'i18n is not defined' error
|
|
81
|
-
|
|
81
|
+
dataTest: 'dhis2-uiwidgets-multiselectfield',
|
|
82
|
+
clearText: 'Clear',
|
|
83
|
+
empty: 'No data found',
|
|
84
|
+
filterPlaceholder: 'Type to filter options',
|
|
85
|
+
loadingText: 'Loading options',
|
|
86
|
+
noMatchText: 'No options found',
|
|
82
87
|
label: 'Default label',
|
|
83
88
|
selected: ['1'],
|
|
84
89
|
children: options,
|
|
@@ -28,7 +28,7 @@ const MultiSelectOption = _ref => {
|
|
|
28
28
|
disabled,
|
|
29
29
|
onClick,
|
|
30
30
|
className,
|
|
31
|
-
dataTest,
|
|
31
|
+
dataTest = 'dhis2-uicore-multiselectoption',
|
|
32
32
|
value
|
|
33
33
|
} = _ref;
|
|
34
34
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -52,9 +52,6 @@ const MultiSelectOption = _ref => {
|
|
|
52
52
|
}, [`div.__jsx-style-dynamic-selector:hover{background-color:${_uiConstants.colors.grey200};}`, "div.disabled.__jsx-style-dynamic-selector:hover{background-color:initial;}"]));
|
|
53
53
|
};
|
|
54
54
|
exports.MultiSelectOption = MultiSelectOption;
|
|
55
|
-
MultiSelectOption.defaultProps = {
|
|
56
|
-
dataTest: 'dhis2-uicore-multiselectoption'
|
|
57
|
-
};
|
|
58
55
|
MultiSelectOption.propTypes = {
|
|
59
56
|
label: _propTypes.default.string.isRequired,
|
|
60
57
|
value: _propTypes.default.string.isRequired,
|
|
@@ -7,7 +7,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
7
7
|
describe('<Select />', () => {
|
|
8
8
|
it('should call the onKeyDown callback when provided', () => {
|
|
9
9
|
const onKeyDown = jest.fn();
|
|
10
|
-
(0, _react.render)(
|
|
10
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(_select.Select, {
|
|
11
11
|
input: /*#__PURE__*/_react2.default.createElement("input", {
|
|
12
12
|
type: "text"
|
|
13
13
|
}),
|
|
@@ -16,7 +16,7 @@ const InputWrapper = _ref => {
|
|
|
16
16
|
dataTest,
|
|
17
17
|
onToggle,
|
|
18
18
|
children,
|
|
19
|
-
tabIndex,
|
|
19
|
+
tabIndex = '0',
|
|
20
20
|
error,
|
|
21
21
|
warning,
|
|
22
22
|
valid,
|
|
@@ -48,9 +48,6 @@ const InputWrapper = _ref => {
|
|
|
48
48
|
}, [`.root.__jsx-style-dynamic-selector{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;background-color:white;border-radius:3px;border:1px solid ${_uiConstants.colors.grey500};box-sizing:border-box;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;min-height:40px;padding-block:6px;padding-inline:12px;box-shadow:inset 0 0 1px 0 rgba(48,54,60,0.1);}`, `.root.__jsx-style-dynamic-selector:not(.disabled):focus,.root.__jsx-style-dynamic-selector:not(.disabled):active{outline:none;box-shadow:inset 0 0 0 2px ${_uiConstants.theme.focus};border-color:${_uiConstants.theme.focus};}`, `.root.valid.__jsx-style-dynamic-selector{border-color:${_uiConstants.theme.valid};}`, `.root.warning.__jsx-style-dynamic-selector{border-color:${_uiConstants.theme.warning};}`, `.root.error.__jsx-style-dynamic-selector{border-color:${_uiConstants.theme.error};}`, `.root.disabled.__jsx-style-dynamic-selector{background-color:${_uiConstants.colors.grey100};border-color:${_uiConstants.colors.grey500};color:${_uiConstants.theme.disabled};cursor:not-allowed;}`, ".root.dense.__jsx-style-dynamic-selector{padding-block:2px;padding-inline:8px;min-height:32px;}", ".root-children.__jsx-style-dynamic-selector{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;}", ".root-right.__jsx-style-dynamic-selector{margin-block-start:4px;margin-inline-start:8px;}"]));
|
|
49
49
|
};
|
|
50
50
|
exports.InputWrapper = InputWrapper;
|
|
51
|
-
InputWrapper.defaultProps = {
|
|
52
|
-
tabIndex: '0'
|
|
53
|
-
};
|
|
54
51
|
InputWrapper.propTypes = {
|
|
55
52
|
dataTest: _propTypes.default.string.isRequired,
|
|
56
53
|
inputRef: _propTypes.default.object.isRequired,
|
|
@@ -15,15 +15,14 @@ const MenuWrapper = _ref => {
|
|
|
15
15
|
let {
|
|
16
16
|
children,
|
|
17
17
|
dataTest,
|
|
18
|
-
maxHeight,
|
|
18
|
+
maxHeight = '280px',
|
|
19
19
|
menuWidth,
|
|
20
20
|
onClick,
|
|
21
21
|
selectRef
|
|
22
22
|
} = _ref;
|
|
23
23
|
return /*#__PURE__*/_react.default.createElement(_layer.Layer, {
|
|
24
24
|
onBackdropClick: onClick,
|
|
25
|
-
transparent: true
|
|
26
|
-
disablePortal: true
|
|
25
|
+
transparent: true
|
|
27
26
|
}, /*#__PURE__*/_react.default.createElement(_popper.Popper, {
|
|
28
27
|
reference: selectRef,
|
|
29
28
|
placement: "bottom-start",
|
|
@@ -37,9 +36,6 @@ const MenuWrapper = _ref => {
|
|
|
37
36
|
}, [`div.__jsx-style-dynamic-selector{width:${menuWidth};height:auto;max-height:${maxHeight};overflow:auto;background:${_uiConstants.colors.white};border:1px solid ${_uiConstants.colors.grey200};border-radius:3px;box-shadow:${_uiConstants.elevations.e300};}`]))));
|
|
38
37
|
};
|
|
39
38
|
exports.MenuWrapper = MenuWrapper;
|
|
40
|
-
MenuWrapper.defaultProps = {
|
|
41
|
-
maxHeight: '280px'
|
|
42
|
-
};
|
|
43
39
|
MenuWrapper.propTypes = {
|
|
44
40
|
dataTest: _propTypes.default.string.isRequired,
|
|
45
41
|
menuWidth: _propTypes.default.string.isRequired,
|
|
@@ -219,9 +219,9 @@ class Select extends _react.Component {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
exports.Select = Select;
|
|
222
|
-
Select
|
|
222
|
+
_defineProperty(Select, "defaultProps", {
|
|
223
223
|
dataTest: 'dhis2-uicore-select'
|
|
224
|
-
};
|
|
224
|
+
});
|
|
225
225
|
Select.propTypes = {
|
|
226
226
|
input: _propTypes.default.element.isRequired,
|
|
227
227
|
menu: _propTypes.default.element.isRequired,
|
|
@@ -35,7 +35,7 @@ describe('<Selection />', () => {
|
|
|
35
35
|
});
|
|
36
36
|
const selected = 'value';
|
|
37
37
|
expect(() => {
|
|
38
|
-
(0, _react.render)(
|
|
38
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(_selection.Selection, {
|
|
39
39
|
selected: selected,
|
|
40
40
|
options: options,
|
|
41
41
|
disabled: false,
|
|
@@ -53,7 +53,7 @@ describe('<Selection />', () => {
|
|
|
53
53
|
const selected = 'value';
|
|
54
54
|
const {
|
|
55
55
|
getByText
|
|
56
|
-
} = (0, _react.render)(
|
|
56
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_selection.Selection, {
|
|
57
57
|
selected: selected,
|
|
58
58
|
options: options,
|
|
59
59
|
disabled: false,
|
|
@@ -69,7 +69,7 @@ describe('<Selection />', () => {
|
|
|
69
69
|
value: "1"
|
|
70
70
|
});
|
|
71
71
|
const selected = 'value';
|
|
72
|
-
(0, _react.render)(
|
|
72
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(_selection.Selection, {
|
|
73
73
|
selected: selected,
|
|
74
74
|
options: options,
|
|
75
75
|
disabled: false,
|
|
@@ -88,7 +88,7 @@ describe('<Selection />', () => {
|
|
|
88
88
|
});
|
|
89
89
|
const selected = 'value';
|
|
90
90
|
expect(() => {
|
|
91
|
-
(0, _react.render)(
|
|
91
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(_selection.Selection, {
|
|
92
92
|
selected: selected,
|
|
93
93
|
options: options,
|
|
94
94
|
disabled: false,
|
|
@@ -7,7 +7,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
7
7
|
describe('<SingleSelect />', () => {
|
|
8
8
|
it('should call the onKeyDown callback when provided', () => {
|
|
9
9
|
const onKeyDown = jest.fn();
|
|
10
|
-
(0, _react.render)(
|
|
10
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(_singleSelect.SingleSelect, {
|
|
11
11
|
placeholder: "placeholder",
|
|
12
12
|
onKeyDown: onKeyDown
|
|
13
13
|
}));
|
|
@@ -25,7 +25,7 @@ const Input = _ref => {
|
|
|
25
25
|
options,
|
|
26
26
|
className,
|
|
27
27
|
disabled,
|
|
28
|
-
inputMaxHeight
|
|
28
|
+
inputMaxHeight = '100px'
|
|
29
29
|
} = _ref;
|
|
30
30
|
const hasSelection = selected && typeof selected === 'string';
|
|
31
31
|
const onClear = e => {
|
|
@@ -63,9 +63,6 @@ const Input = _ref => {
|
|
|
63
63
|
}, [`.root-input.__jsx-style-dynamic-selector{max-height:${inputMaxHeight};}`]));
|
|
64
64
|
};
|
|
65
65
|
exports.Input = Input;
|
|
66
|
-
Input.defaultProps = {
|
|
67
|
-
inputMaxHeight: '100px'
|
|
68
|
-
};
|
|
69
66
|
Input.propTypes = {
|
|
70
67
|
dataTest: _propTypes2.default.string.isRequired,
|
|
71
68
|
className: _propTypes2.default.string,
|
|
@@ -17,7 +17,7 @@ const Menu = _ref => {
|
|
|
17
17
|
options,
|
|
18
18
|
onChange,
|
|
19
19
|
selected,
|
|
20
|
-
empty,
|
|
20
|
+
empty = '',
|
|
21
21
|
handleFocusInput,
|
|
22
22
|
handleClose,
|
|
23
23
|
dataTest
|
|
@@ -70,9 +70,6 @@ const Menu = _ref => {
|
|
|
70
70
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
|
|
71
71
|
};
|
|
72
72
|
exports.Menu = Menu;
|
|
73
|
-
Menu.defaultProps = {
|
|
74
|
-
empty: ''
|
|
75
|
-
};
|
|
76
73
|
Menu.propTypes = {
|
|
77
74
|
dataTest: _propTypes.default.string.isRequired,
|
|
78
75
|
empty: _propTypes.default.node,
|
|
@@ -18,7 +18,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
18
18
|
const SingleSelect = _ref => {
|
|
19
19
|
let {
|
|
20
20
|
className,
|
|
21
|
-
selected,
|
|
21
|
+
selected = '',
|
|
22
22
|
tabIndex,
|
|
23
23
|
maxHeight,
|
|
24
24
|
inputMaxHeight,
|
|
@@ -43,7 +43,7 @@ const SingleSelect = _ref => {
|
|
|
43
43
|
noMatchText,
|
|
44
44
|
initialFocus,
|
|
45
45
|
dense,
|
|
46
|
-
dataTest
|
|
46
|
+
dataTest = 'dhis2-uicore-singleselect'
|
|
47
47
|
} = _ref;
|
|
48
48
|
// If the select is filterable, use a filterable menu
|
|
49
49
|
const menu = filterable ? /*#__PURE__*/_react.default.createElement(_filterableMenu.FilterableMenu, {
|
|
@@ -97,10 +97,6 @@ const SingleSelect = _ref => {
|
|
|
97
97
|
}, [`.root.__jsx-style-dynamic-selector{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:${_uiConstants.spacers.dp8};}`, ".root-input.__jsx-style-dynamic-selector{-webkit-flex:1;-ms-flex:1;flex:1;}"]));
|
|
98
98
|
};
|
|
99
99
|
exports.SingleSelect = SingleSelect;
|
|
100
|
-
SingleSelect.defaultProps = {
|
|
101
|
-
selected: '',
|
|
102
|
-
dataTest: 'dhis2-uicore-singleselect'
|
|
103
|
-
};
|
|
104
100
|
SingleSelect.propTypes = {
|
|
105
101
|
children: _propTypes2.default.node,
|
|
106
102
|
className: _propTypes2.default.string,
|
|
@@ -7,7 +7,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
7
7
|
describe('<SingleSelect />', () => {
|
|
8
8
|
it('should call the onKeyDown callback when provided', () => {
|
|
9
9
|
const onKeyDown = jest.fn();
|
|
10
|
-
(0, _react.render)(
|
|
10
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(_singleSelectField.SingleSelectField, {
|
|
11
11
|
label: "label",
|
|
12
12
|
placeholder: "placeholder",
|
|
13
13
|
onKeyDown: onKeyDown
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.WithoutOptions = exports.WithValidationText = exports.WithLoading = exports.WithLabelAndRequiredStatus = exports.WithLabel = exports.
|
|
7
|
-
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
6
|
+
exports.default = exports.WithoutOptions = exports.WithValidationText = exports.WithLoading = exports.WithLabelAndRequiredStatus = exports.WithLabel = exports.WithHelpText = exports.WithFilterable = exports.WithClearableAndSelectedOption = void 0;
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
8
|
var _index = require("../index.js");
|
|
10
9
|
var _index2 = require("./index.js");
|
|
@@ -87,28 +86,4 @@ const WithLoading = () => /*#__PURE__*/_react.default.createElement(_index2.Sing
|
|
|
87
86
|
});
|
|
88
87
|
exports.WithLoading = WithLoading;
|
|
89
88
|
const WithoutOptions = () => /*#__PURE__*/_react.default.createElement(_index2.SingleSelectField, null);
|
|
90
|
-
exports.WithoutOptions = WithoutOptions;
|
|
91
|
-
const WithHiddenParent = () => {
|
|
92
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
93
|
-
className: "jsx-3657609608" + " " + "container"
|
|
94
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
95
|
-
className: "jsx-3657609608" + " " + "hoverSpan"
|
|
96
|
-
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
97
|
-
className: "jsx-3657609608"
|
|
98
|
-
}, "Hover over me"), /*#__PURE__*/_react.default.createElement("div", {
|
|
99
|
-
className: "jsx-3657609608" + " " + "hiddenSelect"
|
|
100
|
-
}, /*#__PURE__*/_react.default.createElement(_index2.SingleSelectField, {
|
|
101
|
-
dataTest: "hoverable-select-field",
|
|
102
|
-
label: "Choose something",
|
|
103
|
-
onChange: () => {}
|
|
104
|
-
}, /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
105
|
-
value: "1",
|
|
106
|
-
label: "one"
|
|
107
|
-
}), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
108
|
-
value: "2",
|
|
109
|
-
label: "two"
|
|
110
|
-
}))))), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
111
|
-
id: "3657609608"
|
|
112
|
-
}, [".container.jsx-3657609608{width:100%;height:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;font-size:1rem;}", ".hiddenSelect.jsx-3657609608{display:none;}", ".hoverSpan.jsx-3657609608:hover .hiddenSelect.jsx-3657609608{display:block;}"]));
|
|
113
|
-
};
|
|
114
|
-
exports.WithHiddenParent = WithHiddenParent;
|
|
89
|
+
exports.WithoutOptions = WithoutOptions;
|
|
@@ -12,6 +12,9 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
12
12
|
var _index = _interopRequireDefault(require("../locales/index.js"));
|
|
13
13
|
var _index2 = require("../single-select/index.js");
|
|
14
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
17
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
18
|
// TODO: translate
|
|
16
19
|
const translate = (prop, interpolationObject) => {
|
|
17
20
|
if (typeof prop === 'function') {
|
|
@@ -34,7 +37,7 @@ class SingleSelectField extends _react.default.Component {
|
|
|
34
37
|
warning,
|
|
35
38
|
disabled,
|
|
36
39
|
loading,
|
|
37
|
-
selected,
|
|
40
|
+
selected = SingleSelectField.defaultProps.selected,
|
|
38
41
|
tabIndex,
|
|
39
42
|
helpText,
|
|
40
43
|
validationText,
|
|
@@ -43,17 +46,17 @@ class SingleSelectField extends _react.default.Component {
|
|
|
43
46
|
inputWidth,
|
|
44
47
|
children,
|
|
45
48
|
clearable,
|
|
46
|
-
clearText,
|
|
49
|
+
clearText = SingleSelectField.defaultProps.clearText,
|
|
47
50
|
filterable,
|
|
48
|
-
filterPlaceholder,
|
|
51
|
+
filterPlaceholder = SingleSelectField.defaultProps.filterPlaceholder,
|
|
49
52
|
placeholder,
|
|
50
53
|
prefix,
|
|
51
|
-
empty,
|
|
52
|
-
loadingText,
|
|
53
|
-
noMatchText,
|
|
54
|
+
empty = SingleSelectField.defaultProps.empty,
|
|
55
|
+
loadingText = SingleSelectField.defaultProps.loadingText,
|
|
56
|
+
noMatchText = SingleSelectField.defaultProps.noMatchText,
|
|
54
57
|
initialFocus,
|
|
55
58
|
dense,
|
|
56
|
-
dataTest
|
|
59
|
+
dataTest = SingleSelectField.defaultProps.dataTest
|
|
57
60
|
} = this.props;
|
|
58
61
|
return /*#__PURE__*/_react.default.createElement(_field.Field, {
|
|
59
62
|
className: className,
|
|
@@ -98,7 +101,7 @@ class SingleSelectField extends _react.default.Component {
|
|
|
98
101
|
}
|
|
99
102
|
}
|
|
100
103
|
exports.SingleSelectField = SingleSelectField;
|
|
101
|
-
SingleSelectField
|
|
104
|
+
_defineProperty(SingleSelectField, "defaultProps", {
|
|
102
105
|
dataTest: 'dhis2-uiwidgets-singleselectfield',
|
|
103
106
|
selected: '',
|
|
104
107
|
clearText: () => _index.default.t('Clear'),
|
|
@@ -106,7 +109,7 @@ SingleSelectField.defaultProps = {
|
|
|
106
109
|
filterPlaceholder: () => _index.default.t('Type to filter options'),
|
|
107
110
|
loadingText: () => _index.default.t('Loading options'),
|
|
108
111
|
noMatchText: () => _index.default.t('No options found')
|
|
109
|
-
};
|
|
112
|
+
});
|
|
110
113
|
SingleSelectField.propTypes = {
|
|
111
114
|
/** Should be `SingleSelectOption` components */
|
|
112
115
|
children: _propTypes.default.node,
|
|
@@ -78,7 +78,13 @@ var _default = exports.default = {
|
|
|
78
78
|
// default args for stories
|
|
79
79
|
args: {
|
|
80
80
|
// Fix default prop issues - causes 'i18n is not defined' error
|
|
81
|
-
|
|
81
|
+
dataTest: 'dhis2-uiwidgets-singleselectfield',
|
|
82
|
+
selected: '',
|
|
83
|
+
clearText: 'Clear',
|
|
84
|
+
empty: 'No data found',
|
|
85
|
+
filterPlaceholder: 'Type to filter options',
|
|
86
|
+
loadingText: 'Loading options',
|
|
87
|
+
noMatchText: 'No options found',
|
|
82
88
|
label: 'Default label',
|
|
83
89
|
children: options,
|
|
84
90
|
onChange: onChange
|
|
@@ -17,7 +17,7 @@ const SingleSelectOption = _ref => {
|
|
|
17
17
|
disabled,
|
|
18
18
|
onClick,
|
|
19
19
|
className,
|
|
20
|
-
dataTest,
|
|
20
|
+
dataTest = 'dhis2-uicore-singleselectoption',
|
|
21
21
|
value
|
|
22
22
|
} = _ref;
|
|
23
23
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -35,9 +35,6 @@ const SingleSelectOption = _ref => {
|
|
|
35
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;}"]));
|
|
36
36
|
};
|
|
37
37
|
exports.SingleSelectOption = SingleSelectOption;
|
|
38
|
-
SingleSelectOption.defaultProps = {
|
|
39
|
-
dataTest: 'dhis2-uicore-singleselectoption'
|
|
40
|
-
};
|
|
41
38
|
SingleSelectOption.propTypes = {
|
|
42
39
|
label: _propTypes.default.string.isRequired,
|
|
43
40
|
value: _propTypes.default.string.isRequired,
|
|
@@ -4,7 +4,7 @@ import { MultiSelect } from '../multi-select.js';
|
|
|
4
4
|
describe('<MultiSelect />', () => {
|
|
5
5
|
it('should call the onKeyDown callback when provided', () => {
|
|
6
6
|
const onKeyDown = jest.fn();
|
|
7
|
-
render(
|
|
7
|
+
render(/*#__PURE__*/React.createElement(MultiSelect, {
|
|
8
8
|
placeholder: "placeholder",
|
|
9
9
|
onKeyDown: onKeyDown
|
|
10
10
|
}));
|
|
@@ -32,7 +32,7 @@ describe('<SelectionList />', () => {
|
|
|
32
32
|
});
|
|
33
33
|
const selected = ['value'];
|
|
34
34
|
expect(() => {
|
|
35
|
-
render(
|
|
35
|
+
render(/*#__PURE__*/React.createElement(SelectionList, {
|
|
36
36
|
selected: selected,
|
|
37
37
|
options: options,
|
|
38
38
|
disabled: false,
|
|
@@ -50,7 +50,7 @@ describe('<SelectionList />', () => {
|
|
|
50
50
|
const selected = ['value'];
|
|
51
51
|
const {
|
|
52
52
|
getByText
|
|
53
|
-
} = render(
|
|
53
|
+
} = render(/*#__PURE__*/React.createElement(SelectionList, {
|
|
54
54
|
selected: selected,
|
|
55
55
|
options: options,
|
|
56
56
|
disabled: false,
|
|
@@ -66,7 +66,7 @@ describe('<SelectionList />', () => {
|
|
|
66
66
|
value: "1"
|
|
67
67
|
});
|
|
68
68
|
const selected = ['value'];
|
|
69
|
-
render(
|
|
69
|
+
render(/*#__PURE__*/React.createElement(SelectionList, {
|
|
70
70
|
selected: selected,
|
|
71
71
|
options: options,
|
|
72
72
|
disabled: false,
|
|
@@ -85,7 +85,7 @@ describe('<SelectionList />', () => {
|
|
|
85
85
|
});
|
|
86
86
|
const selected = ['value'];
|
|
87
87
|
expect(() => {
|
|
88
|
-
render(
|
|
88
|
+
render(/*#__PURE__*/React.createElement(SelectionList, {
|
|
89
89
|
selected: selected,
|
|
90
90
|
options: options,
|
|
91
91
|
disabled: false,
|
|
@@ -18,7 +18,7 @@ const Input = _ref => {
|
|
|
18
18
|
options,
|
|
19
19
|
className,
|
|
20
20
|
disabled,
|
|
21
|
-
inputMaxHeight
|
|
21
|
+
inputMaxHeight = '100px'
|
|
22
22
|
} = _ref;
|
|
23
23
|
const hasSelection = selected.length > 0;
|
|
24
24
|
const onClear = e => {
|
|
@@ -57,9 +57,6 @@ const Input = _ref => {
|
|
|
57
57
|
dynamic: [inputMaxHeight]
|
|
58
58
|
}, [`.root-input.__jsx-style-dynamic-selector{max-height:${inputMaxHeight};}`]));
|
|
59
59
|
};
|
|
60
|
-
Input.defaultProps = {
|
|
61
|
-
inputMaxHeight: '100px'
|
|
62
|
-
};
|
|
63
60
|
Input.propTypes = {
|
|
64
61
|
dataTest: PropTypes.string.isRequired,
|
|
65
62
|
className: PropTypes.string,
|
|
@@ -36,7 +36,7 @@ const Menu = _ref2 => {
|
|
|
36
36
|
options,
|
|
37
37
|
onChange,
|
|
38
38
|
selected,
|
|
39
|
-
empty,
|
|
39
|
+
empty = '',
|
|
40
40
|
dataTest
|
|
41
41
|
} = _ref2;
|
|
42
42
|
const renderedOptions = filterIgnored(options);
|
|
@@ -84,9 +84,6 @@ const Menu = _ref2 => {
|
|
|
84
84
|
});
|
|
85
85
|
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
86
86
|
};
|
|
87
|
-
Menu.defaultProps = {
|
|
88
|
-
empty: ''
|
|
89
|
-
};
|
|
90
87
|
Menu.propTypes = {
|
|
91
88
|
dataTest: PropTypes.string.isRequired,
|
|
92
89
|
empty: PropTypes.node,
|