@dhis2-ui/select 9.12.0-alpha.4 → 9.12.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/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/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/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/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/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/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/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/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/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/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 +15 -15
- 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
|
@@ -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,
|
|
@@ -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,
|
|
@@ -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,
|
|
@@ -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,
|
|
@@ -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,
|
|
@@ -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,
|
|
@@ -8,10 +8,13 @@ import { Loading as CommonLoading, Select } from '../select/index.js';
|
|
|
8
8
|
import { FilterableMenu } from './filterable-menu.js';
|
|
9
9
|
import { Input } from './input.js';
|
|
10
10
|
import { Menu } from './menu.js';
|
|
11
|
+
|
|
12
|
+
// stable object reference
|
|
13
|
+
const staticArr = [];
|
|
11
14
|
const MultiSelect = _ref => {
|
|
12
15
|
let {
|
|
13
16
|
className,
|
|
14
|
-
selected,
|
|
17
|
+
selected = staticArr,
|
|
15
18
|
tabIndex,
|
|
16
19
|
maxHeight,
|
|
17
20
|
inputMaxHeight,
|
|
@@ -36,7 +39,7 @@ const MultiSelect = _ref => {
|
|
|
36
39
|
noMatchText,
|
|
37
40
|
initialFocus,
|
|
38
41
|
dense,
|
|
39
|
-
dataTest
|
|
42
|
+
dataTest = 'dhis2-uicore-multiselect'
|
|
40
43
|
} = _ref;
|
|
41
44
|
// If the select is filterable, use a filterable menu
|
|
42
45
|
const menu = filterable ? /*#__PURE__*/React.createElement(FilterableMenu, {
|
|
@@ -89,10 +92,6 @@ const MultiSelect = _ref => {
|
|
|
89
92
|
dynamic: [spacers.dp8]
|
|
90
93
|
}, [`.root.__jsx-style-dynamic-selector{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:${spacers.dp8};}`, ".root-input.__jsx-style-dynamic-selector{-webkit-flex:1;-ms-flex:1;flex:1;}"]));
|
|
91
94
|
};
|
|
92
|
-
MultiSelect.defaultProps = {
|
|
93
|
-
selected: [],
|
|
94
|
-
dataTest: 'dhis2-uicore-multiselect'
|
|
95
|
-
};
|
|
96
95
|
MultiSelect.propTypes = {
|
|
97
96
|
children: PropTypes.node,
|
|
98
97
|
className: PropTypes.string,
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
+
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); }
|
|
1
4
|
import { sharedPropTypes } from '@dhis2/ui-constants';
|
|
2
5
|
import { Box } from '@dhis2-ui/box';
|
|
3
6
|
import { Field } from '@dhis2-ui/field';
|
|
@@ -28,7 +31,7 @@ class MultiSelectField extends React.Component {
|
|
|
28
31
|
disabled,
|
|
29
32
|
warning,
|
|
30
33
|
loading,
|
|
31
|
-
selected,
|
|
34
|
+
selected = MultiSelectField.defaultProps.selected,
|
|
32
35
|
tabIndex,
|
|
33
36
|
helpText,
|
|
34
37
|
validationText,
|
|
@@ -37,17 +40,17 @@ class MultiSelectField extends React.Component {
|
|
|
37
40
|
inputWidth,
|
|
38
41
|
children,
|
|
39
42
|
clearable,
|
|
40
|
-
clearText,
|
|
43
|
+
clearText = MultiSelectField.defaultProps.clearText,
|
|
41
44
|
filterable,
|
|
42
|
-
filterPlaceholder,
|
|
45
|
+
filterPlaceholder = MultiSelectField.defaultProps.filterPlaceholder,
|
|
43
46
|
placeholder,
|
|
44
47
|
prefix,
|
|
45
|
-
empty,
|
|
46
|
-
loadingText,
|
|
47
|
-
noMatchText,
|
|
48
|
+
empty = MultiSelectField.defaultProps.empty,
|
|
49
|
+
loadingText = MultiSelectField.defaultProps.loadingText,
|
|
50
|
+
noMatchText = MultiSelectField.defaultProps.noMatchText,
|
|
48
51
|
initialFocus,
|
|
49
52
|
dense,
|
|
50
|
-
dataTest
|
|
53
|
+
dataTest = MultiSelectField.defaultProps.dataTest
|
|
51
54
|
} = this.props;
|
|
52
55
|
return /*#__PURE__*/React.createElement(Field, {
|
|
53
56
|
className: className,
|
|
@@ -91,7 +94,7 @@ class MultiSelectField extends React.Component {
|
|
|
91
94
|
}, children)));
|
|
92
95
|
}
|
|
93
96
|
}
|
|
94
|
-
MultiSelectField
|
|
97
|
+
_defineProperty(MultiSelectField, "defaultProps", {
|
|
95
98
|
selected: [],
|
|
96
99
|
dataTest: 'dhis2-uiwidgets-multiselectfield',
|
|
97
100
|
clearText: () => i18n.t('Clear'),
|
|
@@ -99,7 +102,7 @@ MultiSelectField.defaultProps = {
|
|
|
99
102
|
filterPlaceholder: () => i18n.t('Type to filter options'),
|
|
100
103
|
loadingText: () => i18n.t('Loading options'),
|
|
101
104
|
noMatchText: () => i18n.t('No options found')
|
|
102
|
-
};
|
|
105
|
+
});
|
|
103
106
|
MultiSelectField.propTypes = {
|
|
104
107
|
/** Should be `MultiSelectOption` components */
|
|
105
108
|
children: PropTypes.node,
|
|
@@ -71,7 +71,12 @@ export default {
|
|
|
71
71
|
// default args for stories
|
|
72
72
|
args: {
|
|
73
73
|
// Fix default prop issues - causes 'i18n is not defined' error
|
|
74
|
-
|
|
74
|
+
dataTest: 'dhis2-uiwidgets-multiselectfield',
|
|
75
|
+
clearText: 'Clear',
|
|
76
|
+
empty: 'No data found',
|
|
77
|
+
filterPlaceholder: 'Type to filter options',
|
|
78
|
+
loadingText: 'Loading options',
|
|
79
|
+
noMatchText: 'No options found',
|
|
75
80
|
label: 'Default label',
|
|
76
81
|
selected: ['1'],
|
|
77
82
|
children: options,
|
|
@@ -21,7 +21,7 @@ const MultiSelectOption = _ref => {
|
|
|
21
21
|
disabled,
|
|
22
22
|
onClick,
|
|
23
23
|
className,
|
|
24
|
-
dataTest,
|
|
24
|
+
dataTest = 'dhis2-uicore-multiselectoption',
|
|
25
25
|
value
|
|
26
26
|
} = _ref;
|
|
27
27
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -44,9 +44,6 @@ const MultiSelectOption = _ref => {
|
|
|
44
44
|
dynamic: [colors.grey200]
|
|
45
45
|
}, [`div.__jsx-style-dynamic-selector:hover{background-color:${colors.grey200};}`, "div.disabled.__jsx-style-dynamic-selector:hover{background-color:initial;}"]));
|
|
46
46
|
};
|
|
47
|
-
MultiSelectOption.defaultProps = {
|
|
48
|
-
dataTest: 'dhis2-uicore-multiselectoption'
|
|
49
|
-
};
|
|
50
47
|
MultiSelectOption.propTypes = {
|
|
51
48
|
label: PropTypes.string.isRequired,
|
|
52
49
|
value: PropTypes.string.isRequired,
|
|
@@ -9,7 +9,7 @@ const InputWrapper = _ref => {
|
|
|
9
9
|
dataTest,
|
|
10
10
|
onToggle,
|
|
11
11
|
children,
|
|
12
|
-
tabIndex,
|
|
12
|
+
tabIndex = '0',
|
|
13
13
|
error,
|
|
14
14
|
warning,
|
|
15
15
|
valid,
|
|
@@ -40,9 +40,6 @@ const InputWrapper = _ref => {
|
|
|
40
40
|
dynamic: [colors.grey500, theme.focus, theme.focus, theme.valid, theme.warning, theme.error, colors.grey100, colors.grey500, theme.disabled]
|
|
41
41
|
}, [`.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 ${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 ${theme.focus};border-color:${theme.focus};}`, `.root.valid.__jsx-style-dynamic-selector{border-color:${theme.valid};}`, `.root.warning.__jsx-style-dynamic-selector{border-color:${theme.warning};}`, `.root.error.__jsx-style-dynamic-selector{border-color:${theme.error};}`, `.root.disabled.__jsx-style-dynamic-selector{background-color:${colors.grey100};border-color:${colors.grey500};color:${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;}"]));
|
|
42
42
|
};
|
|
43
|
-
InputWrapper.defaultProps = {
|
|
44
|
-
tabIndex: '0'
|
|
45
|
-
};
|
|
46
43
|
InputWrapper.propTypes = {
|
|
47
44
|
dataTest: PropTypes.string.isRequired,
|
|
48
45
|
inputRef: PropTypes.object.isRequired,
|
|
@@ -8,15 +8,14 @@ const MenuWrapper = _ref => {
|
|
|
8
8
|
let {
|
|
9
9
|
children,
|
|
10
10
|
dataTest,
|
|
11
|
-
maxHeight,
|
|
11
|
+
maxHeight = '280px',
|
|
12
12
|
menuWidth,
|
|
13
13
|
onClick,
|
|
14
14
|
selectRef
|
|
15
15
|
} = _ref;
|
|
16
16
|
return /*#__PURE__*/React.createElement(Layer, {
|
|
17
17
|
onBackdropClick: onClick,
|
|
18
|
-
transparent: true
|
|
19
|
-
disablePortal: true
|
|
18
|
+
transparent: true
|
|
20
19
|
}, /*#__PURE__*/React.createElement(Popper, {
|
|
21
20
|
reference: selectRef,
|
|
22
21
|
placement: "bottom-start",
|
|
@@ -29,9 +28,6 @@ const MenuWrapper = _ref => {
|
|
|
29
28
|
dynamic: [menuWidth, maxHeight, colors.white, colors.grey200, elevations.e300]
|
|
30
29
|
}, [`div.__jsx-style-dynamic-selector{width:${menuWidth};height:auto;max-height:${maxHeight};overflow:auto;background:${colors.white};border:1px solid ${colors.grey200};border-radius:3px;box-shadow:${elevations.e300};}`]))));
|
|
31
30
|
};
|
|
32
|
-
MenuWrapper.defaultProps = {
|
|
33
|
-
maxHeight: '280px'
|
|
34
|
-
};
|
|
35
31
|
MenuWrapper.propTypes = {
|
|
36
32
|
dataTest: PropTypes.string.isRequired,
|
|
37
33
|
menuWidth: PropTypes.string.isRequired,
|
|
@@ -210,9 +210,9 @@ export class Select extends Component {
|
|
|
210
210
|
}, menu));
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
|
-
Select
|
|
213
|
+
_defineProperty(Select, "defaultProps", {
|
|
214
214
|
dataTest: 'dhis2-uicore-select'
|
|
215
|
-
};
|
|
215
|
+
});
|
|
216
216
|
Select.propTypes = {
|
|
217
217
|
input: PropTypes.element.isRequired,
|
|
218
218
|
menu: PropTypes.element.isRequired,
|
|
@@ -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 && typeof selected === 'string';
|
|
24
24
|
const onClear = e => {
|
|
@@ -55,9 +55,6 @@ const Input = _ref => {
|
|
|
55
55
|
dynamic: [inputMaxHeight]
|
|
56
56
|
}, [`.root-input.__jsx-style-dynamic-selector{max-height:${inputMaxHeight};}`]));
|
|
57
57
|
};
|
|
58
|
-
Input.defaultProps = {
|
|
59
|
-
inputMaxHeight: '100px'
|
|
60
|
-
};
|
|
61
58
|
Input.propTypes = {
|
|
62
59
|
dataTest: PropTypes.string.isRequired,
|
|
63
60
|
className: PropTypes.string,
|
|
@@ -10,7 +10,7 @@ const Menu = _ref => {
|
|
|
10
10
|
options,
|
|
11
11
|
onChange,
|
|
12
12
|
selected,
|
|
13
|
-
empty,
|
|
13
|
+
empty = '',
|
|
14
14
|
handleFocusInput,
|
|
15
15
|
handleClose,
|
|
16
16
|
dataTest
|
|
@@ -62,9 +62,6 @@ const Menu = _ref => {
|
|
|
62
62
|
});
|
|
63
63
|
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
64
64
|
};
|
|
65
|
-
Menu.defaultProps = {
|
|
66
|
-
empty: ''
|
|
67
|
-
};
|
|
68
65
|
Menu.propTypes = {
|
|
69
66
|
dataTest: PropTypes.string.isRequired,
|
|
70
67
|
empty: PropTypes.node,
|
|
@@ -11,7 +11,7 @@ import { Menu } from './menu.js';
|
|
|
11
11
|
const SingleSelect = _ref => {
|
|
12
12
|
let {
|
|
13
13
|
className,
|
|
14
|
-
selected,
|
|
14
|
+
selected = '',
|
|
15
15
|
tabIndex,
|
|
16
16
|
maxHeight,
|
|
17
17
|
inputMaxHeight,
|
|
@@ -36,7 +36,7 @@ const SingleSelect = _ref => {
|
|
|
36
36
|
noMatchText,
|
|
37
37
|
initialFocus,
|
|
38
38
|
dense,
|
|
39
|
-
dataTest
|
|
39
|
+
dataTest = 'dhis2-uicore-singleselect'
|
|
40
40
|
} = _ref;
|
|
41
41
|
// If the select is filterable, use a filterable menu
|
|
42
42
|
const menu = filterable ? /*#__PURE__*/React.createElement(FilterableMenu, {
|
|
@@ -89,10 +89,6 @@ const SingleSelect = _ref => {
|
|
|
89
89
|
dynamic: [spacers.dp8]
|
|
90
90
|
}, [`.root.__jsx-style-dynamic-selector{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:${spacers.dp8};}`, ".root-input.__jsx-style-dynamic-selector{-webkit-flex:1;-ms-flex:1;flex:1;}"]));
|
|
91
91
|
};
|
|
92
|
-
SingleSelect.defaultProps = {
|
|
93
|
-
selected: '',
|
|
94
|
-
dataTest: 'dhis2-uicore-singleselect'
|
|
95
|
-
};
|
|
96
92
|
SingleSelect.propTypes = {
|
|
97
93
|
children: PropTypes.node,
|
|
98
94
|
className: PropTypes.string,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _JSXStyle from "styled-jsx/style";
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { SingleSelectOption } from '../index.js';
|
|
4
3
|
import { SingleSelectField } from './index.js';
|
|
@@ -72,27 +71,4 @@ export const WithFilterable = () => /*#__PURE__*/React.createElement(SingleSelec
|
|
|
72
71
|
export const WithLoading = () => /*#__PURE__*/React.createElement(SingleSelectField, {
|
|
73
72
|
loading: true
|
|
74
73
|
});
|
|
75
|
-
export const WithoutOptions = () => /*#__PURE__*/React.createElement(SingleSelectField, null);
|
|
76
|
-
export const WithHiddenParent = () => {
|
|
77
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
78
|
-
className: "jsx-3657609608" + " " + "container"
|
|
79
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
80
|
-
className: "jsx-3657609608" + " " + "hoverSpan"
|
|
81
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
82
|
-
className: "jsx-3657609608"
|
|
83
|
-
}, "Hover over me"), /*#__PURE__*/React.createElement("div", {
|
|
84
|
-
className: "jsx-3657609608" + " " + "hiddenSelect"
|
|
85
|
-
}, /*#__PURE__*/React.createElement(SingleSelectField, {
|
|
86
|
-
dataTest: "hoverable-select-field",
|
|
87
|
-
label: "Choose something",
|
|
88
|
-
onChange: () => {}
|
|
89
|
-
}, /*#__PURE__*/React.createElement(SingleSelectOption, {
|
|
90
|
-
value: "1",
|
|
91
|
-
label: "one"
|
|
92
|
-
}), /*#__PURE__*/React.createElement(SingleSelectOption, {
|
|
93
|
-
value: "2",
|
|
94
|
-
label: "two"
|
|
95
|
-
}))))), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
96
|
-
id: "3657609608"
|
|
97
|
-
}, [".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;}"]));
|
|
98
|
-
};
|
|
74
|
+
export const WithoutOptions = () => /*#__PURE__*/React.createElement(SingleSelectField, null);
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
+
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); }
|
|
1
4
|
import { sharedPropTypes } from '@dhis2/ui-constants';
|
|
2
5
|
import { Box } from '@dhis2-ui/box';
|
|
3
6
|
import { Field } from '@dhis2-ui/field';
|
|
@@ -28,7 +31,7 @@ class SingleSelectField extends React.Component {
|
|
|
28
31
|
warning,
|
|
29
32
|
disabled,
|
|
30
33
|
loading,
|
|
31
|
-
selected,
|
|
34
|
+
selected = SingleSelectField.defaultProps.selected,
|
|
32
35
|
tabIndex,
|
|
33
36
|
helpText,
|
|
34
37
|
validationText,
|
|
@@ -37,17 +40,17 @@ class SingleSelectField extends React.Component {
|
|
|
37
40
|
inputWidth,
|
|
38
41
|
children,
|
|
39
42
|
clearable,
|
|
40
|
-
clearText,
|
|
43
|
+
clearText = SingleSelectField.defaultProps.clearText,
|
|
41
44
|
filterable,
|
|
42
|
-
filterPlaceholder,
|
|
45
|
+
filterPlaceholder = SingleSelectField.defaultProps.filterPlaceholder,
|
|
43
46
|
placeholder,
|
|
44
47
|
prefix,
|
|
45
|
-
empty,
|
|
46
|
-
loadingText,
|
|
47
|
-
noMatchText,
|
|
48
|
+
empty = SingleSelectField.defaultProps.empty,
|
|
49
|
+
loadingText = SingleSelectField.defaultProps.loadingText,
|
|
50
|
+
noMatchText = SingleSelectField.defaultProps.noMatchText,
|
|
48
51
|
initialFocus,
|
|
49
52
|
dense,
|
|
50
|
-
dataTest
|
|
53
|
+
dataTest = SingleSelectField.defaultProps.dataTest
|
|
51
54
|
} = this.props;
|
|
52
55
|
return /*#__PURE__*/React.createElement(Field, {
|
|
53
56
|
className: className,
|
|
@@ -91,7 +94,7 @@ class SingleSelectField extends React.Component {
|
|
|
91
94
|
}, children)));
|
|
92
95
|
}
|
|
93
96
|
}
|
|
94
|
-
SingleSelectField
|
|
97
|
+
_defineProperty(SingleSelectField, "defaultProps", {
|
|
95
98
|
dataTest: 'dhis2-uiwidgets-singleselectfield',
|
|
96
99
|
selected: '',
|
|
97
100
|
clearText: () => i18n.t('Clear'),
|
|
@@ -99,7 +102,7 @@ SingleSelectField.defaultProps = {
|
|
|
99
102
|
filterPlaceholder: () => i18n.t('Type to filter options'),
|
|
100
103
|
loadingText: () => i18n.t('Loading options'),
|
|
101
104
|
noMatchText: () => i18n.t('No options found')
|
|
102
|
-
};
|
|
105
|
+
});
|
|
103
106
|
SingleSelectField.propTypes = {
|
|
104
107
|
/** Should be `SingleSelectOption` components */
|
|
105
108
|
children: PropTypes.node,
|
|
@@ -71,7 +71,13 @@ export default {
|
|
|
71
71
|
// default args for stories
|
|
72
72
|
args: {
|
|
73
73
|
// Fix default prop issues - causes 'i18n is not defined' error
|
|
74
|
-
|
|
74
|
+
dataTest: 'dhis2-uiwidgets-singleselectfield',
|
|
75
|
+
selected: '',
|
|
76
|
+
clearText: 'Clear',
|
|
77
|
+
empty: 'No data found',
|
|
78
|
+
filterPlaceholder: 'Type to filter options',
|
|
79
|
+
loadingText: 'Loading options',
|
|
80
|
+
noMatchText: 'No options found',
|
|
75
81
|
label: 'Default label',
|
|
76
82
|
children: options,
|
|
77
83
|
onChange: onChange
|
|
@@ -10,7 +10,7 @@ const SingleSelectOption = _ref => {
|
|
|
10
10
|
disabled,
|
|
11
11
|
onClick,
|
|
12
12
|
className,
|
|
13
|
-
dataTest,
|
|
13
|
+
dataTest = 'dhis2-uicore-singleselectoption',
|
|
14
14
|
value
|
|
15
15
|
} = _ref;
|
|
16
16
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -27,9 +27,6 @@ const SingleSelectOption = _ref => {
|
|
|
27
27
|
dynamic: [colors.grey900, spacers.dp8, spacers.dp12, colors.grey200, colors.teal700, colors.white, colors.grey500]
|
|
28
28
|
}, [`div.__jsx-style-dynamic-selector{cursor:pointer;font-size:14px;-webkit-text-decoration:none;text-decoration:none;color:${colors.grey900};padding-block:${spacers.dp8};padding-inline:${spacers.dp12};}`, `div.__jsx-style-dynamic-selector:hover{background-color:${colors.grey200};}`, `div.__jsx-style-dynamic-selector:active,div.active.__jsx-style-dynamic-selector{background-color:${colors.teal700};color:${colors.white};cursor:auto;}`, `div.disabled.__jsx-style-dynamic-selector{color:${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;}"]));
|
|
29
29
|
};
|
|
30
|
-
SingleSelectOption.defaultProps = {
|
|
31
|
-
dataTest: 'dhis2-uicore-singleselectoption'
|
|
32
|
-
};
|
|
33
30
|
SingleSelectOption.propTypes = {
|
|
34
31
|
label: PropTypes.string.isRequired,
|
|
35
32
|
value: PropTypes.string.isRequired,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/select",
|
|
3
|
-
"version": "9.12.0
|
|
3
|
+
"version": "9.12.0",
|
|
4
4
|
"description": "UI Select",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,21 +33,21 @@
|
|
|
33
33
|
"styled-jsx": "^4"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@dhis2-ui/box": "9.12.0
|
|
37
|
-
"@dhis2-ui/button": "9.12.0
|
|
38
|
-
"@dhis2-ui/card": "9.12.0
|
|
39
|
-
"@dhis2-ui/checkbox": "9.12.0
|
|
40
|
-
"@dhis2-ui/chip": "9.12.0
|
|
41
|
-
"@dhis2-ui/field": "9.12.0
|
|
42
|
-
"@dhis2-ui/input": "9.12.0
|
|
43
|
-
"@dhis2-ui/layer": "9.12.0
|
|
44
|
-
"@dhis2-ui/loader": "9.12.0
|
|
45
|
-
"@dhis2-ui/popper": "9.12.0
|
|
46
|
-
"@dhis2-ui/status-icon": "9.12.0
|
|
47
|
-
"@dhis2-ui/tooltip": "9.12.0
|
|
36
|
+
"@dhis2-ui/box": "9.12.0",
|
|
37
|
+
"@dhis2-ui/button": "9.12.0",
|
|
38
|
+
"@dhis2-ui/card": "9.12.0",
|
|
39
|
+
"@dhis2-ui/checkbox": "9.12.0",
|
|
40
|
+
"@dhis2-ui/chip": "9.12.0",
|
|
41
|
+
"@dhis2-ui/field": "9.12.0",
|
|
42
|
+
"@dhis2-ui/input": "9.12.0",
|
|
43
|
+
"@dhis2-ui/layer": "9.12.0",
|
|
44
|
+
"@dhis2-ui/loader": "9.12.0",
|
|
45
|
+
"@dhis2-ui/popper": "9.12.0",
|
|
46
|
+
"@dhis2-ui/status-icon": "9.12.0",
|
|
47
|
+
"@dhis2-ui/tooltip": "9.12.0",
|
|
48
48
|
"@dhis2/prop-types": "^3.1.2",
|
|
49
|
-
"@dhis2/ui-constants": "9.12.0
|
|
50
|
-
"@dhis2/ui-icons": "9.12.0
|
|
49
|
+
"@dhis2/ui-constants": "9.12.0",
|
|
50
|
+
"@dhis2/ui-icons": "9.12.0",
|
|
51
51
|
"classnames": "^2.3.1",
|
|
52
52
|
"prop-types": "^15.7.2"
|
|
53
53
|
},
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
(0, _cypressCucumberPreprocessor.Given)('a Select is hidden initially', () => {
|
|
5
|
-
cy.visitStory('SingleSelectField', 'With hidden parent');
|
|
6
|
-
});
|
|
7
|
-
(0, _cypressCucumberPreprocessor.When)('someone hovers over it to show it', () => {
|
|
8
|
-
cy.get('.container .hiddenSelect').invoke('attr', 'style', 'display: block');
|
|
9
|
-
});
|
|
10
|
-
(0, _cypressCucumberPreprocessor.When)('clicks the select', () => {
|
|
11
|
-
cy.get('[data-test="dhis2-uicore-select"]').click();
|
|
12
|
-
});
|
|
13
|
-
(0, _cypressCucumberPreprocessor.Then)('the select dropdown should be in the correct position', () => {
|
|
14
|
-
cy.get('[data-test="hoverable-select-field"]').should('be.visible');
|
|
15
|
-
cy.get('[data-test="dhis2-uicore-singleselectoption"]').should($selectField => {
|
|
16
|
-
const {
|
|
17
|
-
top,
|
|
18
|
-
left
|
|
19
|
-
} = $selectField.offset();
|
|
20
|
-
expect(top).to.be.greaterThan(0);
|
|
21
|
-
expect(left).to.be.greaterThan(0);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Given, Then, When } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
|
-
Given('a Select is hidden initially', () => {
|
|
3
|
-
cy.visitStory('SingleSelectField', 'With hidden parent');
|
|
4
|
-
});
|
|
5
|
-
When('someone hovers over it to show it', () => {
|
|
6
|
-
cy.get('.container .hiddenSelect').invoke('attr', 'style', 'display: block');
|
|
7
|
-
});
|
|
8
|
-
When('clicks the select', () => {
|
|
9
|
-
cy.get('[data-test="dhis2-uicore-select"]').click();
|
|
10
|
-
});
|
|
11
|
-
Then('the select dropdown should be in the correct position', () => {
|
|
12
|
-
cy.get('[data-test="hoverable-select-field"]').should('be.visible');
|
|
13
|
-
cy.get('[data-test="dhis2-uicore-singleselectoption"]').should($selectField => {
|
|
14
|
-
const {
|
|
15
|
-
top,
|
|
16
|
-
left
|
|
17
|
-
} = $selectField.offset();
|
|
18
|
-
expect(top).to.be.greaterThan(0);
|
|
19
|
-
expect(left).to.be.greaterThan(0);
|
|
20
|
-
});
|
|
21
|
-
});
|