@dhis2-ui/select 10.16.5 → 10.17.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/multi-select.js +8 -0
- package/build/cjs/multi-select/multi-select.prod.stories.js +40 -1
- package/build/cjs/multi-select-field/multi-select-field.js +8 -0
- package/build/cjs/multi-select-field/multi-select-field.prod.stories.js +42 -2
- package/build/cjs/select/menu-wrapper.js +17 -6
- package/build/cjs/select/select.js +18 -12
- package/build/cjs/single-select/single-select.js +8 -0
- package/build/cjs/single-select/single-select.prod.stories.js +41 -2
- package/build/cjs/single-select-field/single-select-field.js +8 -0
- package/build/cjs/single-select-field/single-select-field.prod.stories.js +42 -2
- package/build/es/multi-select/multi-select.js +8 -0
- package/build/es/multi-select/multi-select.prod.stories.js +37 -0
- package/build/es/multi-select-field/multi-select-field.js +8 -0
- package/build/es/multi-select-field/multi-select-field.prod.stories.js +41 -1
- package/build/es/select/menu-wrapper.js +17 -6
- package/build/es/select/select.js +18 -12
- package/build/es/single-select/single-select.js +8 -0
- package/build/es/single-select/single-select.prod.stories.js +38 -1
- package/build/es/single-select-field/single-select-field.js +8 -0
- package/build/es/single-select-field/single-select-field.prod.stories.js +41 -1
- package/package.json +15 -15
- package/src/multi-select/multi-select.js +8 -0
- package/src/multi-select/multi-select.prod.stories.js +26 -0
- package/src/multi-select-field/multi-select-field.js +8 -0
- package/src/multi-select-field/multi-select-field.prod.stories.js +31 -0
- package/src/select/menu-wrapper.js +19 -3
- package/src/select/select.js +18 -12
- package/src/single-select/single-select.js +8 -0
- package/src/single-select/single-select.prod.stories.js +26 -0
- package/src/single-select-field/single-select-field.js +8 -0
- package/src/single-select-field/single-select-field.prod.stories.js +31 -0
|
@@ -22,6 +22,8 @@ const MultiSelect = ({
|
|
|
22
22
|
selected = staticArr,
|
|
23
23
|
tabIndex,
|
|
24
24
|
maxHeight,
|
|
25
|
+
menuMinWidth,
|
|
26
|
+
menuMaxWidth,
|
|
25
27
|
inputMaxHeight,
|
|
26
28
|
onChange,
|
|
27
29
|
onFocus,
|
|
@@ -77,6 +79,8 @@ const MultiSelect = ({
|
|
|
77
79
|
menu: menu,
|
|
78
80
|
tabIndex: tabIndex,
|
|
79
81
|
maxHeight: maxHeight,
|
|
82
|
+
menuMinWidth: menuMinWidth,
|
|
83
|
+
menuMaxWidth: menuMaxWidth,
|
|
80
84
|
onChange: onChange,
|
|
81
85
|
onFocus: onFocus,
|
|
82
86
|
onKeyDown: onKeyDown,
|
|
@@ -122,6 +126,10 @@ MultiSelect.propTypes = {
|
|
|
122
126
|
loading: _propTypes2.default.bool,
|
|
123
127
|
loadingText: _propTypes2.default.string,
|
|
124
128
|
maxHeight: _propTypes2.default.string,
|
|
129
|
+
/** See [dropdown menu width](https://developers.dhis2.org/docs/ui/components/select#dropdown-menu-width) */
|
|
130
|
+
menuMaxWidth: _propTypes2.default.string,
|
|
131
|
+
/** See [dropdown menu width](https://developers.dhis2.org/docs/ui/components/select#dropdown-menu-width) */
|
|
132
|
+
menuMinWidth: _propTypes2.default.string,
|
|
125
133
|
/** Required if `filterable` prop is `true` */
|
|
126
134
|
noMatchText: (0, _propTypes.requiredIf)(props => props.filterable, _propTypes2.default.string),
|
|
127
135
|
placeholder: _propTypes2.default.string,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.WithPrefixAndSelection = exports.WithPrefix = exports.WithPlaceholderAndSelection = exports.WithPlaceholder = exports.WithOptionsLoadingAndLoadingText = exports.WithOptionsAndOnChange = exports.WithOptionsAndMultipleSelections = exports.WithOptionsAndLoading = exports.WithOptionsAndDisabled = exports.WithOptionsAndASelection = exports.WithOptionsASelectionAndDisabled = exports.WithOnFocus = exports.WithOnBlur = exports.WithMultipleSelectionsWrapped = exports.WithMoreThanThreeOptionsAndA100PxMaxHeight = exports.WithMoreThanTenOptions = exports.WithInvalidOptions = exports.WithInvalidFilterableOptions = exports.WithInitialFocus = exports.WithFilterField = exports.WithDisabledOptionAndOnChange = exports.WithCustomOptionsAndOnChange = exports.WithClearButtonSelectionAndOnChange = exports.ShiftedIntoView = exports.RTL = exports.FlippedPosition = exports.EmptyWithEmptyText = exports.EmptyWithEmptyComponent = exports.Empty = exports.DenseWithSelections = exports.Dense = exports.DefaultPosition = exports.CollapseSelectionAfterThreshold = void 0;
|
|
6
|
+
exports.default = exports.WithPrefixAndSelection = exports.WithPrefix = exports.WithPlaceholderAndSelection = exports.WithPlaceholder = exports.WithOptionsLoadingAndLoadingText = exports.WithOptionsAndOnChange = exports.WithOptionsAndMultipleSelections = exports.WithOptionsAndLoading = exports.WithOptionsAndDisabled = exports.WithOptionsAndASelection = exports.WithOptionsASelectionAndDisabled = exports.WithOnFocus = exports.WithOnBlur = exports.WithMultipleSelectionsWrapped = exports.WithMoreThanThreeOptionsAndA100PxMaxHeight = exports.WithMoreThanTenOptions = exports.WithMenuMinWidth = exports.WithMenuMaxWidth = exports.WithInvalidOptions = exports.WithInvalidFilterableOptions = exports.WithInitialFocus = exports.WithFilterField = exports.WithDisabledOptionAndOnChange = exports.WithCustomOptionsAndOnChange = exports.WithClearButtonSelectionAndOnChange = exports.ShiftedIntoView = exports.RTL = exports.FlippedPosition = exports.EmptyWithEmptyText = exports.EmptyWithEmptyComponent = exports.Empty = exports.DenseWithSelections = exports.Dense = exports.DefaultPosition = exports.CollapseSelectionAfterThreshold = void 0;
|
|
7
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
8
8
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -561,4 +561,43 @@ exports.RTL = RTL;
|
|
|
561
561
|
RTL.args = {
|
|
562
562
|
selected: ['1', '2'],
|
|
563
563
|
prefix: 'RTL text'
|
|
564
|
+
};
|
|
565
|
+
const WithMenuMaxWidth = args => /*#__PURE__*/_react.default.createElement("div", {
|
|
566
|
+
style: {
|
|
567
|
+
width: 120
|
|
568
|
+
}
|
|
569
|
+
}, /*#__PURE__*/_react.default.createElement(_index2.MultiSelect, args, /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
570
|
+
value: "1",
|
|
571
|
+
label: "option one"
|
|
572
|
+
}), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
573
|
+
value: "2",
|
|
574
|
+
label: "option two"
|
|
575
|
+
}), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
576
|
+
value: "3",
|
|
577
|
+
label: "A much longer option label"
|
|
578
|
+
})));
|
|
579
|
+
exports.WithMenuMaxWidth = WithMenuMaxWidth;
|
|
580
|
+
WithMenuMaxWidth.args = {
|
|
581
|
+
menuMaxWidth: '200px'
|
|
582
|
+
};
|
|
583
|
+
const WithMenuMinWidth = args => /*#__PURE__*/_react.default.createElement("div", {
|
|
584
|
+
style: {
|
|
585
|
+
width: 120
|
|
586
|
+
}
|
|
587
|
+
}, /*#__PURE__*/_react.default.createElement(_index2.MultiSelect, args, /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
588
|
+
value: "1",
|
|
589
|
+
label: "option one"
|
|
590
|
+
}), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
591
|
+
value: "2",
|
|
592
|
+
label: "option two"
|
|
593
|
+
}), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
594
|
+
value: "3",
|
|
595
|
+
label: "option three"
|
|
596
|
+
}), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
597
|
+
value: "4",
|
|
598
|
+
label: "A longer option that exceeds the minimum"
|
|
599
|
+
})));
|
|
600
|
+
exports.WithMenuMinWidth = WithMenuMinWidth;
|
|
601
|
+
WithMenuMinWidth.args = {
|
|
602
|
+
menuMinWidth: '240px'
|
|
564
603
|
};
|
|
@@ -42,6 +42,8 @@ class MultiSelectField extends _react.default.Component {
|
|
|
42
42
|
helpText,
|
|
43
43
|
validationText,
|
|
44
44
|
maxHeight,
|
|
45
|
+
menuMinWidth,
|
|
46
|
+
menuMaxWidth,
|
|
45
47
|
inputMaxHeight,
|
|
46
48
|
inputWidth,
|
|
47
49
|
children,
|
|
@@ -76,6 +78,8 @@ class MultiSelectField extends _react.default.Component {
|
|
|
76
78
|
selected: selected,
|
|
77
79
|
tabIndex: tabIndex,
|
|
78
80
|
maxHeight: maxHeight,
|
|
81
|
+
menuMinWidth: menuMinWidth,
|
|
82
|
+
menuMaxWidth: menuMaxWidth,
|
|
79
83
|
inputMaxHeight: inputMaxHeight,
|
|
80
84
|
onChange: onChange,
|
|
81
85
|
onFocus: onFocus,
|
|
@@ -147,6 +151,10 @@ MultiSelectField.propTypes = {
|
|
|
147
151
|
loadingText: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]),
|
|
148
152
|
/** Constrains height of the MultiSelect */
|
|
149
153
|
maxHeight: _propTypes.default.string,
|
|
154
|
+
/** See [dropdown menu width](https://developers.dhis2.org/docs/ui/components/select#dropdown-menu-width) */
|
|
155
|
+
menuMaxWidth: _propTypes.default.string,
|
|
156
|
+
/** See [dropdown menu width](https://developers.dhis2.org/docs/ui/components/select#dropdown-menu-width) */
|
|
157
|
+
menuMinWidth: _propTypes.default.string,
|
|
150
158
|
/** Text to display when there are no filter results */
|
|
151
159
|
noMatchText: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]),
|
|
152
160
|
/** Placeholder text when the MultiSelect is empty */
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
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;
|
|
6
|
+
exports.default = exports.WithMenuMinWidth = exports.WithMenuMaxWidth = exports.WithHelpText = exports.StatusWarning = exports.StatusValid = exports.StatusError = exports.Required = exports.InputWidth = exports.DefaultLoadingText = exports.DefaultFilterPlaceholderAndNoMatchText = exports.DefaultEmpty = exports.DefaultClearText = exports.Default = void 0;
|
|
7
7
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _index = require("../index.js");
|
|
@@ -174,4 +174,44 @@ DefaultLoadingText.args = {
|
|
|
174
174
|
loading: true,
|
|
175
175
|
...DefaultEmpty.args
|
|
176
176
|
};
|
|
177
|
-
DefaultLoadingText.storyName = 'Default: loadingText';
|
|
177
|
+
DefaultLoadingText.storyName = 'Default: loadingText';
|
|
178
|
+
const WithMenuMaxWidth = exports.WithMenuMaxWidth = Template.bind({});
|
|
179
|
+
WithMenuMaxWidth.args = {
|
|
180
|
+
inputWidth: '120px',
|
|
181
|
+
menuMaxWidth: '200px',
|
|
182
|
+
children: [/*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
183
|
+
key: "1",
|
|
184
|
+
value: "1",
|
|
185
|
+
label: "option one"
|
|
186
|
+
}), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
187
|
+
key: "2",
|
|
188
|
+
value: "2",
|
|
189
|
+
label: "option two"
|
|
190
|
+
}), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
191
|
+
key: "3",
|
|
192
|
+
value: "3",
|
|
193
|
+
label: "A much longer option label"
|
|
194
|
+
})]
|
|
195
|
+
};
|
|
196
|
+
const WithMenuMinWidth = exports.WithMenuMinWidth = Template.bind({});
|
|
197
|
+
WithMenuMinWidth.args = {
|
|
198
|
+
inputWidth: '120px',
|
|
199
|
+
menuMinWidth: '240px',
|
|
200
|
+
children: [/*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
201
|
+
key: "1",
|
|
202
|
+
value: "1",
|
|
203
|
+
label: "option one"
|
|
204
|
+
}), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
205
|
+
key: "2",
|
|
206
|
+
value: "2",
|
|
207
|
+
label: "option two"
|
|
208
|
+
}), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
209
|
+
key: "3",
|
|
210
|
+
value: "3",
|
|
211
|
+
label: "option three"
|
|
212
|
+
}), /*#__PURE__*/_react.default.createElement(_index.MultiSelectOption, {
|
|
213
|
+
key: "4",
|
|
214
|
+
value: "4",
|
|
215
|
+
label: "A longer option that exceeds the minimum"
|
|
216
|
+
})]
|
|
217
|
+
};
|
|
@@ -14,11 +14,20 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
14
14
|
const MenuWrapper = ({
|
|
15
15
|
children,
|
|
16
16
|
dataTest,
|
|
17
|
+
inputWidth,
|
|
17
18
|
maxHeight = '280px',
|
|
18
|
-
|
|
19
|
+
menuMaxWidth,
|
|
20
|
+
menuMinWidth,
|
|
19
21
|
onClick,
|
|
20
22
|
selectRef
|
|
21
23
|
}) => {
|
|
24
|
+
// menuMinWidth or menuMaxWidth enables flexible sizing (fit-content), with
|
|
25
|
+
// min-width = max(input, menuMinWidth). Without them, width matches the input.
|
|
26
|
+
const flexible = menuMinWidth || menuMaxWidth;
|
|
27
|
+
const width = flexible ? 'fit-content' : inputWidth;
|
|
28
|
+
const flexibleMinWidth = menuMinWidth ? `max(${inputWidth}, ${menuMinWidth})` : inputWidth;
|
|
29
|
+
const minWidth = flexible ? flexibleMinWidth : 'auto';
|
|
30
|
+
const maxWidth = menuMaxWidth || 'none';
|
|
22
31
|
return /*#__PURE__*/_react.default.createElement(_layer.Layer, {
|
|
23
32
|
onBackdropClick: onClick,
|
|
24
33
|
transparent: true
|
|
@@ -28,18 +37,20 @@ const MenuWrapper = ({
|
|
|
28
37
|
observeReferenceResize: true
|
|
29
38
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
30
39
|
"data-test": `${dataTest}-menuwrapper`,
|
|
31
|
-
className: _style.default.dynamic([["
|
|
40
|
+
className: _style.default.dynamic([["3752211706", [width, minWidth, maxWidth, maxHeight, _uiConstants.colors.white, _uiConstants.colors.grey200, _uiConstants.elevations.popover]]])
|
|
32
41
|
}, children, /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
33
|
-
id: "
|
|
34
|
-
dynamic: [
|
|
35
|
-
}, [`div.__jsx-style-dynamic-selector{width:${
|
|
42
|
+
id: "3752211706",
|
|
43
|
+
dynamic: [width, minWidth, maxWidth, maxHeight, _uiConstants.colors.white, _uiConstants.colors.grey200, _uiConstants.elevations.popover]
|
|
44
|
+
}, [`div.__jsx-style-dynamic-selector{width:${width};min-width:${minWidth};max-width:${maxWidth};height:auto;max-height:${maxHeight};overflow:auto;background:${_uiConstants.colors.white};border:1px solid ${_uiConstants.colors.grey200};border-radius:3px;box-shadow:${_uiConstants.elevations.popover};}`]))));
|
|
36
45
|
};
|
|
37
46
|
exports.MenuWrapper = MenuWrapper;
|
|
38
47
|
MenuWrapper.propTypes = {
|
|
39
48
|
dataTest: _propTypes.default.string.isRequired,
|
|
40
|
-
|
|
49
|
+
inputWidth: _propTypes.default.string.isRequired,
|
|
41
50
|
selectRef: _propTypes.default.object.isRequired,
|
|
42
51
|
children: _propTypes.default.node,
|
|
43
52
|
maxHeight: _propTypes.default.string,
|
|
53
|
+
menuMaxWidth: _propTypes.default.string,
|
|
54
|
+
menuMinWidth: _propTypes.default.string,
|
|
44
55
|
onClick: _propTypes.default.func
|
|
45
56
|
};
|
|
@@ -26,7 +26,7 @@ class Select extends _react.Component {
|
|
|
26
26
|
super(...args);
|
|
27
27
|
_defineProperty(this, "state", {
|
|
28
28
|
open: false,
|
|
29
|
-
|
|
29
|
+
inputWidth: 'auto'
|
|
30
30
|
});
|
|
31
31
|
_defineProperty(this, "selectRef", /*#__PURE__*/_react.default.createRef());
|
|
32
32
|
_defineProperty(this, "inputRef", /*#__PURE__*/_react.default.createRef());
|
|
@@ -40,10 +40,10 @@ class Select extends _react.Component {
|
|
|
40
40
|
* See: https://nolanlawson.com/2018/09/25/accurately-measuring-layout-on-the-web
|
|
41
41
|
*/
|
|
42
42
|
_defineProperty(this, "onResize", (0, _debounce.debounce)(() => {
|
|
43
|
-
const
|
|
44
|
-
if (this.state.
|
|
43
|
+
const inputWidth = this.getInputWidth();
|
|
44
|
+
if (this.state.inputWidth !== inputWidth) {
|
|
45
45
|
this.setState({
|
|
46
|
-
|
|
46
|
+
inputWidth
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
}, 50));
|
|
@@ -66,7 +66,7 @@ class Select extends _react.Component {
|
|
|
66
66
|
_defineProperty(this, "handleOpen", () => {
|
|
67
67
|
this.setState({
|
|
68
68
|
open: true,
|
|
69
|
-
|
|
69
|
+
inputWidth: this.getInputWidth()
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
72
|
_defineProperty(this, "handleClose", () => {
|
|
@@ -145,29 +145,29 @@ class Select extends _react.Component {
|
|
|
145
145
|
this.inputRef.current.focus();
|
|
146
146
|
}
|
|
147
147
|
this.setState({
|
|
148
|
-
|
|
148
|
+
inputWidth: this.getInputWidth()
|
|
149
149
|
});
|
|
150
150
|
window.addEventListener('resize', this.onResize);
|
|
151
151
|
}
|
|
152
152
|
componentWillUnmount() {
|
|
153
153
|
window.removeEventListener('resize', this.onResize);
|
|
154
154
|
}
|
|
155
|
-
|
|
155
|
+
getInputWidth() {
|
|
156
156
|
const {
|
|
157
157
|
offsetWidth
|
|
158
158
|
} = this.inputRef.current;
|
|
159
159
|
const {
|
|
160
|
-
|
|
160
|
+
inputWidth
|
|
161
161
|
} = this.state;
|
|
162
|
-
if (offsetWidth && `${offsetWidth}px` !==
|
|
162
|
+
if (offsetWidth && `${offsetWidth}px` !== inputWidth) {
|
|
163
163
|
return `${offsetWidth}px`;
|
|
164
164
|
}
|
|
165
|
-
return
|
|
165
|
+
return inputWidth;
|
|
166
166
|
}
|
|
167
167
|
render() {
|
|
168
168
|
const {
|
|
169
169
|
open,
|
|
170
|
-
|
|
170
|
+
inputWidth
|
|
171
171
|
} = this.state;
|
|
172
172
|
const {
|
|
173
173
|
children,
|
|
@@ -176,6 +176,8 @@ class Select extends _react.Component {
|
|
|
176
176
|
onChange,
|
|
177
177
|
tabIndex,
|
|
178
178
|
maxHeight,
|
|
179
|
+
menuMinWidth,
|
|
180
|
+
menuMaxWidth,
|
|
179
181
|
error,
|
|
180
182
|
warning,
|
|
181
183
|
valid,
|
|
@@ -222,7 +224,9 @@ class Select extends _react.Component {
|
|
|
222
224
|
onClick: this.onOutsideClick,
|
|
223
225
|
maxHeight: maxHeight,
|
|
224
226
|
selectRef: this.selectRef,
|
|
225
|
-
|
|
227
|
+
inputWidth: inputWidth,
|
|
228
|
+
menuMinWidth: menuMinWidth,
|
|
229
|
+
menuMaxWidth: menuMaxWidth,
|
|
226
230
|
dataTest: `${dataTest}-menu`
|
|
227
231
|
}, menu));
|
|
228
232
|
}
|
|
@@ -243,6 +247,8 @@ Select.propTypes = {
|
|
|
243
247
|
error: _uiConstants.sharedPropTypes.statusPropType,
|
|
244
248
|
initialFocus: _propTypes.default.bool,
|
|
245
249
|
maxHeight: _propTypes.default.string,
|
|
250
|
+
menuMaxWidth: _propTypes.default.string,
|
|
251
|
+
menuMinWidth: _propTypes.default.string,
|
|
246
252
|
tabIndex: _propTypes.default.string,
|
|
247
253
|
valid: _uiConstants.sharedPropTypes.statusPropType,
|
|
248
254
|
warning: _uiConstants.sharedPropTypes.statusPropType,
|
|
@@ -20,6 +20,8 @@ const SingleSelect = ({
|
|
|
20
20
|
selected = '',
|
|
21
21
|
tabIndex,
|
|
22
22
|
maxHeight,
|
|
23
|
+
menuMinWidth,
|
|
24
|
+
menuMaxWidth,
|
|
23
25
|
inputMaxHeight,
|
|
24
26
|
onChange,
|
|
25
27
|
onFocus,
|
|
@@ -73,6 +75,8 @@ const SingleSelect = ({
|
|
|
73
75
|
menu: menu,
|
|
74
76
|
tabIndex: tabIndex,
|
|
75
77
|
maxHeight: maxHeight,
|
|
78
|
+
menuMinWidth: menuMinWidth,
|
|
79
|
+
menuMaxWidth: menuMaxWidth,
|
|
76
80
|
onChange: onChange,
|
|
77
81
|
onFocus: onFocus,
|
|
78
82
|
onKeyDown: onKeyDown,
|
|
@@ -118,6 +122,10 @@ SingleSelect.propTypes = {
|
|
|
118
122
|
loading: _propTypes2.default.bool,
|
|
119
123
|
loadingText: _propTypes2.default.string,
|
|
120
124
|
maxHeight: _propTypes2.default.string,
|
|
125
|
+
/** See [dropdown menu width](https://developers.dhis2.org/docs/ui/components/select#dropdown-menu-width) */
|
|
126
|
+
menuMaxWidth: _propTypes2.default.string,
|
|
127
|
+
/** See [dropdown menu width](https://developers.dhis2.org/docs/ui/components/select#dropdown-menu-width) */
|
|
128
|
+
menuMinWidth: _propTypes2.default.string,
|
|
121
129
|
/** Text to show when filter returns no results. Required if `filterable` prop is true */
|
|
122
130
|
noMatchText: (0, _propTypes.requiredIf)(props => props.filterable, _propTypes2.default.string),
|
|
123
131
|
placeholder: _propTypes2.default.string,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.WithRTL = exports.WithPrefixAndSelection = exports.WithPrefix = exports.WithPlaceholderAndSelection = exports.WithPlaceholder = exports.WithOptionsLoadingAndLoadingText = exports.WithOptionsAndOnChange = exports.WithOptionsAndLoading = exports.WithOptionsAndDisabled = exports.WithOptionsAndASelection = exports.WithOptionsASelectionAndDisabled = exports.WithOnFocus = exports.WithOnBlur = exports.WithMoreThanThreeOptionsAndA100PxMaxHeight = exports.WithMoreThanTenOptions = exports.WithInvalidOptions = exports.WithInvalidFilterableOptions = exports.WithInitialFocus = exports.WithFilterField = exports.WithDisabledOptionAndOnChange = exports.WithCustomOptionsAndOnChange = exports.WithClearButtonSelectionAndOnChange = exports.ShiftedIntoView = exports.FlippedPosition = exports.EmptyWithEmptyText = exports.EmptyWithEmptyComponent = exports.Empty = exports.Dense = exports.DefaultPosition = void 0;
|
|
6
|
+
exports.default = exports.WithRTL = exports.WithPrefixAndSelection = exports.WithPrefix = exports.WithPlaceholderAndSelection = exports.WithPlaceholder = exports.WithOptionsLoadingAndLoadingText = exports.WithOptionsAndOnChange = exports.WithOptionsAndLoading = exports.WithOptionsAndDisabled = exports.WithOptionsAndASelection = exports.WithOptionsASelectionAndDisabled = exports.WithOnFocus = exports.WithOnBlur = exports.WithMoreThanThreeOptionsAndA100PxMaxHeight = exports.WithMoreThanTenOptions = exports.WithMenuMinWidth = exports.WithMenuMaxWidth = exports.WithInvalidOptions = exports.WithInvalidFilterableOptions = exports.WithInitialFocus = exports.WithFilterField = exports.WithDisabledOptionAndOnChange = exports.WithCustomOptionsAndOnChange = exports.WithClearButtonSelectionAndOnChange = exports.ShiftedIntoView = exports.FlippedPosition = exports.EmptyWithEmptyText = exports.EmptyWithEmptyComponent = exports.Empty = exports.Dense = exports.DefaultPosition = void 0;
|
|
7
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
8
8
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -480,4 +480,43 @@ const ShiftedIntoView = args => /*#__PURE__*/_react.default.createElement(_react
|
|
|
480
480
|
})), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
481
481
|
id: "1828862170"
|
|
482
482
|
}, ["html,body,#root{position:relative;height:300px !important;max-height:300px;}", "#root{padding-top:130px !important;}"]));
|
|
483
|
-
exports.ShiftedIntoView = ShiftedIntoView;
|
|
483
|
+
exports.ShiftedIntoView = ShiftedIntoView;
|
|
484
|
+
const WithMenuMaxWidth = args => /*#__PURE__*/_react.default.createElement("div", {
|
|
485
|
+
style: {
|
|
486
|
+
width: 120
|
|
487
|
+
}
|
|
488
|
+
}, /*#__PURE__*/_react.default.createElement(_index2.SingleSelect, args, /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
489
|
+
value: "1",
|
|
490
|
+
label: "option one"
|
|
491
|
+
}), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
492
|
+
value: "2",
|
|
493
|
+
label: "option two"
|
|
494
|
+
}), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
495
|
+
value: "3",
|
|
496
|
+
label: "A much longer option label"
|
|
497
|
+
})));
|
|
498
|
+
exports.WithMenuMaxWidth = WithMenuMaxWidth;
|
|
499
|
+
WithMenuMaxWidth.args = {
|
|
500
|
+
menuMaxWidth: '200px'
|
|
501
|
+
};
|
|
502
|
+
const WithMenuMinWidth = args => /*#__PURE__*/_react.default.createElement("div", {
|
|
503
|
+
style: {
|
|
504
|
+
width: 120
|
|
505
|
+
}
|
|
506
|
+
}, /*#__PURE__*/_react.default.createElement(_index2.SingleSelect, args, /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
507
|
+
value: "1",
|
|
508
|
+
label: "option one"
|
|
509
|
+
}), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
510
|
+
value: "2",
|
|
511
|
+
label: "option two"
|
|
512
|
+
}), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
513
|
+
value: "3",
|
|
514
|
+
label: "option three"
|
|
515
|
+
}), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
516
|
+
value: "4",
|
|
517
|
+
label: "A longer option that exceeds the minimum"
|
|
518
|
+
})));
|
|
519
|
+
exports.WithMenuMinWidth = WithMenuMinWidth;
|
|
520
|
+
WithMenuMinWidth.args = {
|
|
521
|
+
menuMinWidth: '240px'
|
|
522
|
+
};
|
|
@@ -42,6 +42,8 @@ class SingleSelectField extends _react.default.Component {
|
|
|
42
42
|
helpText,
|
|
43
43
|
validationText,
|
|
44
44
|
maxHeight,
|
|
45
|
+
menuMinWidth,
|
|
46
|
+
menuMaxWidth,
|
|
45
47
|
inputMaxHeight,
|
|
46
48
|
inputWidth,
|
|
47
49
|
children,
|
|
@@ -76,6 +78,8 @@ class SingleSelectField extends _react.default.Component {
|
|
|
76
78
|
selected: selected,
|
|
77
79
|
tabIndex: tabIndex,
|
|
78
80
|
maxHeight: maxHeight,
|
|
81
|
+
menuMinWidth: menuMinWidth,
|
|
82
|
+
menuMaxWidth: menuMaxWidth,
|
|
79
83
|
inputMaxHeight: inputMaxHeight,
|
|
80
84
|
onChange: onChange,
|
|
81
85
|
onFocus: onFocus,
|
|
@@ -147,6 +151,10 @@ SingleSelectField.propTypes = {
|
|
|
147
151
|
loadingText: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]),
|
|
148
152
|
/** Constrains height of the SingleSelect */
|
|
149
153
|
maxHeight: _propTypes.default.string,
|
|
154
|
+
/** See [dropdown menu width](https://developers.dhis2.org/docs/ui/components/select#dropdown-menu-width) */
|
|
155
|
+
menuMaxWidth: _propTypes.default.string,
|
|
156
|
+
/** See [dropdown menu width](https://developers.dhis2.org/docs/ui/components/select#dropdown-menu-width) */
|
|
157
|
+
menuMinWidth: _propTypes.default.string,
|
|
150
158
|
/** Text to display when there are no filter results */
|
|
151
159
|
noMatchText: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]),
|
|
152
160
|
/** Placeholder text when the SingleSelect is empty */
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.WithHelpText = exports.StatusWarning = exports.StatusValid = exports.StatusError = exports.StatusDisabled = exports.Required = exports.InputWidth = exports.DefaultLoadingText = exports.DefaultFilterPlaceholderAndNoMatchText = exports.DefaultEmpty = exports.DefaultClearText = exports.Default = void 0;
|
|
6
|
+
exports.default = exports.WithMenuMinWidth = exports.WithMenuMaxWidth = exports.WithHelpText = exports.StatusWarning = exports.StatusValid = exports.StatusError = exports.StatusDisabled = exports.Required = exports.InputWidth = exports.DefaultLoadingText = exports.DefaultFilterPlaceholderAndNoMatchText = exports.DefaultEmpty = exports.DefaultClearText = exports.Default = void 0;
|
|
7
7
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _index = require("../index.js");
|
|
@@ -180,4 +180,44 @@ DefaultLoadingText.args = {
|
|
|
180
180
|
loading: true,
|
|
181
181
|
...DefaultEmpty.args
|
|
182
182
|
};
|
|
183
|
-
DefaultLoadingText.storyName = 'Default: loadingText';
|
|
183
|
+
DefaultLoadingText.storyName = 'Default: loadingText';
|
|
184
|
+
const WithMenuMaxWidth = exports.WithMenuMaxWidth = Template.bind({});
|
|
185
|
+
WithMenuMaxWidth.args = {
|
|
186
|
+
inputWidth: '120px',
|
|
187
|
+
menuMaxWidth: '200px',
|
|
188
|
+
children: [/*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
189
|
+
key: "1",
|
|
190
|
+
value: "1",
|
|
191
|
+
label: "option one"
|
|
192
|
+
}), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
193
|
+
key: "2",
|
|
194
|
+
value: "2",
|
|
195
|
+
label: "option two"
|
|
196
|
+
}), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
197
|
+
key: "3",
|
|
198
|
+
value: "3",
|
|
199
|
+
label: "A much longer option label"
|
|
200
|
+
})]
|
|
201
|
+
};
|
|
202
|
+
const WithMenuMinWidth = exports.WithMenuMinWidth = Template.bind({});
|
|
203
|
+
WithMenuMinWidth.args = {
|
|
204
|
+
inputWidth: '120px',
|
|
205
|
+
menuMinWidth: '240px',
|
|
206
|
+
children: [/*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
207
|
+
key: "1",
|
|
208
|
+
value: "1",
|
|
209
|
+
label: "option one"
|
|
210
|
+
}), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
211
|
+
key: "2",
|
|
212
|
+
value: "2",
|
|
213
|
+
label: "option two"
|
|
214
|
+
}), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
215
|
+
key: "3",
|
|
216
|
+
value: "3",
|
|
217
|
+
label: "option three"
|
|
218
|
+
}), /*#__PURE__*/_react.default.createElement(_index.SingleSelectOption, {
|
|
219
|
+
key: "4",
|
|
220
|
+
value: "4",
|
|
221
|
+
label: "A longer option that exceeds the minimum"
|
|
222
|
+
})]
|
|
223
|
+
};
|
|
@@ -16,6 +16,8 @@ const MultiSelect = ({
|
|
|
16
16
|
selected = staticArr,
|
|
17
17
|
tabIndex,
|
|
18
18
|
maxHeight,
|
|
19
|
+
menuMinWidth,
|
|
20
|
+
menuMaxWidth,
|
|
19
21
|
inputMaxHeight,
|
|
20
22
|
onChange,
|
|
21
23
|
onFocus,
|
|
@@ -71,6 +73,8 @@ const MultiSelect = ({
|
|
|
71
73
|
menu: menu,
|
|
72
74
|
tabIndex: tabIndex,
|
|
73
75
|
maxHeight: maxHeight,
|
|
76
|
+
menuMinWidth: menuMinWidth,
|
|
77
|
+
menuMaxWidth: menuMaxWidth,
|
|
74
78
|
onChange: onChange,
|
|
75
79
|
onFocus: onFocus,
|
|
76
80
|
onKeyDown: onKeyDown,
|
|
@@ -115,6 +119,10 @@ MultiSelect.propTypes = {
|
|
|
115
119
|
loading: PropTypes.bool,
|
|
116
120
|
loadingText: PropTypes.string,
|
|
117
121
|
maxHeight: PropTypes.string,
|
|
122
|
+
/** See [dropdown menu width](https://developers.dhis2.org/docs/ui/components/select#dropdown-menu-width) */
|
|
123
|
+
menuMaxWidth: PropTypes.string,
|
|
124
|
+
/** See [dropdown menu width](https://developers.dhis2.org/docs/ui/components/select#dropdown-menu-width) */
|
|
125
|
+
menuMinWidth: PropTypes.string,
|
|
118
126
|
/** Required if `filterable` prop is `true` */
|
|
119
127
|
noMatchText: requiredIf(props => props.filterable, PropTypes.string),
|
|
120
128
|
placeholder: PropTypes.string,
|
|
@@ -541,4 +541,41 @@ export const RTL = args => {
|
|
|
541
541
|
RTL.args = {
|
|
542
542
|
selected: ['1', '2'],
|
|
543
543
|
prefix: 'RTL text'
|
|
544
|
+
};
|
|
545
|
+
export const WithMenuMaxWidth = args => /*#__PURE__*/React.createElement("div", {
|
|
546
|
+
style: {
|
|
547
|
+
width: 120
|
|
548
|
+
}
|
|
549
|
+
}, /*#__PURE__*/React.createElement(MultiSelect, args, /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
550
|
+
value: "1",
|
|
551
|
+
label: "option one"
|
|
552
|
+
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
553
|
+
value: "2",
|
|
554
|
+
label: "option two"
|
|
555
|
+
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
556
|
+
value: "3",
|
|
557
|
+
label: "A much longer option label"
|
|
558
|
+
})));
|
|
559
|
+
WithMenuMaxWidth.args = {
|
|
560
|
+
menuMaxWidth: '200px'
|
|
561
|
+
};
|
|
562
|
+
export const WithMenuMinWidth = args => /*#__PURE__*/React.createElement("div", {
|
|
563
|
+
style: {
|
|
564
|
+
width: 120
|
|
565
|
+
}
|
|
566
|
+
}, /*#__PURE__*/React.createElement(MultiSelect, args, /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
567
|
+
value: "1",
|
|
568
|
+
label: "option one"
|
|
569
|
+
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
570
|
+
value: "2",
|
|
571
|
+
label: "option two"
|
|
572
|
+
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
573
|
+
value: "3",
|
|
574
|
+
label: "option three"
|
|
575
|
+
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
576
|
+
value: "4",
|
|
577
|
+
label: "A longer option that exceeds the minimum"
|
|
578
|
+
})));
|
|
579
|
+
WithMenuMinWidth.args = {
|
|
580
|
+
menuMinWidth: '240px'
|
|
544
581
|
};
|
|
@@ -36,6 +36,8 @@ class MultiSelectField extends React.Component {
|
|
|
36
36
|
helpText,
|
|
37
37
|
validationText,
|
|
38
38
|
maxHeight,
|
|
39
|
+
menuMinWidth,
|
|
40
|
+
menuMaxWidth,
|
|
39
41
|
inputMaxHeight,
|
|
40
42
|
inputWidth,
|
|
41
43
|
children,
|
|
@@ -70,6 +72,8 @@ class MultiSelectField extends React.Component {
|
|
|
70
72
|
selected: selected,
|
|
71
73
|
tabIndex: tabIndex,
|
|
72
74
|
maxHeight: maxHeight,
|
|
75
|
+
menuMinWidth: menuMinWidth,
|
|
76
|
+
menuMaxWidth: menuMaxWidth,
|
|
73
77
|
inputMaxHeight: inputMaxHeight,
|
|
74
78
|
onChange: onChange,
|
|
75
79
|
onFocus: onFocus,
|
|
@@ -140,6 +144,10 @@ MultiSelectField.propTypes = {
|
|
|
140
144
|
loadingText: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
|
141
145
|
/** Constrains height of the MultiSelect */
|
|
142
146
|
maxHeight: PropTypes.string,
|
|
147
|
+
/** See [dropdown menu width](https://developers.dhis2.org/docs/ui/components/select#dropdown-menu-width) */
|
|
148
|
+
menuMaxWidth: PropTypes.string,
|
|
149
|
+
/** See [dropdown menu width](https://developers.dhis2.org/docs/ui/components/select#dropdown-menu-width) */
|
|
150
|
+
menuMinWidth: PropTypes.string,
|
|
143
151
|
/** Text to display when there are no filter results */
|
|
144
152
|
noMatchText: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
|
145
153
|
/** Placeholder text when the MultiSelect is empty */
|
|
@@ -167,4 +167,44 @@ DefaultLoadingText.args = {
|
|
|
167
167
|
loading: true,
|
|
168
168
|
...DefaultEmpty.args
|
|
169
169
|
};
|
|
170
|
-
DefaultLoadingText.storyName = 'Default: loadingText';
|
|
170
|
+
DefaultLoadingText.storyName = 'Default: loadingText';
|
|
171
|
+
export const WithMenuMaxWidth = Template.bind({});
|
|
172
|
+
WithMenuMaxWidth.args = {
|
|
173
|
+
inputWidth: '120px',
|
|
174
|
+
menuMaxWidth: '200px',
|
|
175
|
+
children: [/*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
176
|
+
key: "1",
|
|
177
|
+
value: "1",
|
|
178
|
+
label: "option one"
|
|
179
|
+
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
180
|
+
key: "2",
|
|
181
|
+
value: "2",
|
|
182
|
+
label: "option two"
|
|
183
|
+
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
184
|
+
key: "3",
|
|
185
|
+
value: "3",
|
|
186
|
+
label: "A much longer option label"
|
|
187
|
+
})]
|
|
188
|
+
};
|
|
189
|
+
export const WithMenuMinWidth = Template.bind({});
|
|
190
|
+
WithMenuMinWidth.args = {
|
|
191
|
+
inputWidth: '120px',
|
|
192
|
+
menuMinWidth: '240px',
|
|
193
|
+
children: [/*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
194
|
+
key: "1",
|
|
195
|
+
value: "1",
|
|
196
|
+
label: "option one"
|
|
197
|
+
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
198
|
+
key: "2",
|
|
199
|
+
value: "2",
|
|
200
|
+
label: "option two"
|
|
201
|
+
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
202
|
+
key: "3",
|
|
203
|
+
value: "3",
|
|
204
|
+
label: "option three"
|
|
205
|
+
}), /*#__PURE__*/React.createElement(MultiSelectOption, {
|
|
206
|
+
key: "4",
|
|
207
|
+
value: "4",
|
|
208
|
+
label: "A longer option that exceeds the minimum"
|
|
209
|
+
})]
|
|
210
|
+
};
|