@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
|
@@ -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,
|
|
@@ -4,7 +4,7 @@ import { MultiSelectField } from '../multi-select-field.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(MultiSelectField, {
|
|
8
8
|
label: "label",
|
|
9
9
|
placeholder: "placeholder",
|
|
10
10
|
onKeyDown: onKeyDown
|
|
@@ -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,
|
|
@@ -4,7 +4,7 @@ import { Select } from '../select.js';
|
|
|
4
4
|
describe('<Select />', () => {
|
|
5
5
|
it('should call the onKeyDown callback when provided', () => {
|
|
6
6
|
const onKeyDown = jest.fn();
|
|
7
|
-
render(
|
|
7
|
+
render(/*#__PURE__*/React.createElement(Select, {
|
|
8
8
|
input: /*#__PURE__*/React.createElement("input", {
|
|
9
9
|
type: "text"
|
|
10
10
|
}),
|
|
@@ -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,
|
|
@@ -32,7 +32,7 @@ describe('<Selection />', () => {
|
|
|
32
32
|
});
|
|
33
33
|
const selected = 'value';
|
|
34
34
|
expect(() => {
|
|
35
|
-
render(
|
|
35
|
+
render(/*#__PURE__*/React.createElement(Selection, {
|
|
36
36
|
selected: selected,
|
|
37
37
|
options: options,
|
|
38
38
|
disabled: false,
|
|
@@ -50,7 +50,7 @@ describe('<Selection />', () => {
|
|
|
50
50
|
const selected = 'value';
|
|
51
51
|
const {
|
|
52
52
|
getByText
|
|
53
|
-
} = render(
|
|
53
|
+
} = render(/*#__PURE__*/React.createElement(Selection, {
|
|
54
54
|
selected: selected,
|
|
55
55
|
options: options,
|
|
56
56
|
disabled: false,
|
|
@@ -66,7 +66,7 @@ describe('<Selection />', () => {
|
|
|
66
66
|
value: "1"
|
|
67
67
|
});
|
|
68
68
|
const selected = 'value';
|
|
69
|
-
render(
|
|
69
|
+
render(/*#__PURE__*/React.createElement(Selection, {
|
|
70
70
|
selected: selected,
|
|
71
71
|
options: options,
|
|
72
72
|
disabled: false,
|
|
@@ -85,7 +85,7 @@ describe('<Selection />', () => {
|
|
|
85
85
|
});
|
|
86
86
|
const selected = 'value';
|
|
87
87
|
expect(() => {
|
|
88
|
-
render(
|
|
88
|
+
render(/*#__PURE__*/React.createElement(Selection, {
|
|
89
89
|
selected: selected,
|
|
90
90
|
options: options,
|
|
91
91
|
disabled: false,
|
|
@@ -4,7 +4,7 @@ import { SingleSelect } from '../single-select.js';
|
|
|
4
4
|
describe('<SingleSelect />', () => {
|
|
5
5
|
it('should call the onKeyDown callback when provided', () => {
|
|
6
6
|
const onKeyDown = jest.fn();
|
|
7
|
-
render(
|
|
7
|
+
render(/*#__PURE__*/React.createElement(SingleSelect, {
|
|
8
8
|
placeholder: "placeholder",
|
|
9
9
|
onKeyDown: onKeyDown
|
|
10
10
|
}));
|
|
@@ -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,
|
|
@@ -4,7 +4,7 @@ import { SingleSelectField } from '../single-select-field.js';
|
|
|
4
4
|
describe('<SingleSelect />', () => {
|
|
5
5
|
it('should call the onKeyDown callback when provided', () => {
|
|
6
6
|
const onKeyDown = jest.fn();
|
|
7
|
-
render(
|
|
7
|
+
render(/*#__PURE__*/React.createElement(SingleSelectField, {
|
|
8
8
|
label: "label",
|
|
9
9
|
placeholder: "placeholder",
|
|
10
10
|
onKeyDown: onKeyDown
|
|
@@ -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.
|
|
3
|
+
"version": "9.13.0",
|
|
4
4
|
"description": "UI Select",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,26 +28,26 @@
|
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@dhis2/d2-i18n": "^1",
|
|
31
|
-
"react": "^16.13",
|
|
32
|
-
"react-dom": "^16.13",
|
|
31
|
+
"react": "^16.13 || ^18",
|
|
32
|
+
"react-dom": "^16.13 || ^18",
|
|
33
33
|
"styled-jsx": "^4"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@dhis2-ui/box": "9.
|
|
37
|
-
"@dhis2-ui/button": "9.
|
|
38
|
-
"@dhis2-ui/card": "9.
|
|
39
|
-
"@dhis2-ui/checkbox": "9.
|
|
40
|
-
"@dhis2-ui/chip": "9.
|
|
41
|
-
"@dhis2-ui/field": "9.
|
|
42
|
-
"@dhis2-ui/input": "9.
|
|
43
|
-
"@dhis2-ui/layer": "9.
|
|
44
|
-
"@dhis2-ui/loader": "9.
|
|
45
|
-
"@dhis2-ui/popper": "9.
|
|
46
|
-
"@dhis2-ui/status-icon": "9.
|
|
47
|
-
"@dhis2-ui/tooltip": "9.
|
|
36
|
+
"@dhis2-ui/box": "9.13.0",
|
|
37
|
+
"@dhis2-ui/button": "9.13.0",
|
|
38
|
+
"@dhis2-ui/card": "9.13.0",
|
|
39
|
+
"@dhis2-ui/checkbox": "9.13.0",
|
|
40
|
+
"@dhis2-ui/chip": "9.13.0",
|
|
41
|
+
"@dhis2-ui/field": "9.13.0",
|
|
42
|
+
"@dhis2-ui/input": "9.13.0",
|
|
43
|
+
"@dhis2-ui/layer": "9.13.0",
|
|
44
|
+
"@dhis2-ui/loader": "9.13.0",
|
|
45
|
+
"@dhis2-ui/popper": "9.13.0",
|
|
46
|
+
"@dhis2-ui/status-icon": "9.13.0",
|
|
47
|
+
"@dhis2-ui/tooltip": "9.13.0",
|
|
48
48
|
"@dhis2/prop-types": "^3.1.2",
|
|
49
|
-
"@dhis2/ui-constants": "9.
|
|
50
|
-
"@dhis2/ui-icons": "9.
|
|
49
|
+
"@dhis2/ui-constants": "9.13.0",
|
|
50
|
+
"@dhis2/ui-icons": "9.13.0",
|
|
51
51
|
"classnames": "^2.3.1",
|
|
52
52
|
"prop-types": "^15.7.2"
|
|
53
53
|
},
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
],
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@dhis2/d2-i18n": "^1.1.0",
|
|
60
|
-
"react": "
|
|
61
|
-
"react-dom": "
|
|
60
|
+
"react": "^18.3.1",
|
|
61
|
+
"react-dom": "^18.3.1",
|
|
62
62
|
"styled-jsx": "^4.0.1"
|
|
63
63
|
},
|
|
64
64
|
"types": "types"
|
|
@@ -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
|
-
});
|