@dhis2-ui/select 10.9.2 → 10.10.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/index.js +18 -4
- package/build/cjs/locales/en/translations.json +7 -5
- package/build/cjs/simple-single-select/__stories__/DefaultPosition.js +38 -0
- package/build/cjs/simple-single-select/__stories__/Dense.js +22 -0
- package/build/cjs/simple-single-select/__stories__/Empty.js +20 -0
- package/build/cjs/simple-single-select/__stories__/EmptyWithEmptyNode.js +28 -0
- package/build/cjs/simple-single-select/__stories__/EmptyWithEmptyText.js +21 -0
- package/build/cjs/simple-single-select/__stories__/FlippedPosition.js +37 -0
- package/build/cjs/simple-single-select/__stories__/InfiniteLoading.js +61 -0
- package/build/cjs/simple-single-select/__stories__/Loading.js +20 -0
- package/build/cjs/simple-single-select/__stories__/ShiftedIntoView.js +28 -0
- package/build/cjs/simple-single-select/__stories__/WithClearButton.js +25 -0
- package/build/cjs/simple-single-select/__stories__/WithCustomLowMaxHeight.js +22 -0
- package/build/cjs/simple-single-select/__stories__/WithCustomOptions.js +48 -0
- package/build/cjs/simple-single-select/__stories__/WithDisabledOption.js +28 -0
- package/build/cjs/simple-single-select/__stories__/WithFilterField.js +36 -0
- package/build/cjs/simple-single-select/__stories__/WithInitialFocus.js +38 -0
- package/build/cjs/simple-single-select/__stories__/WithManyOptions.js +24 -0
- package/build/cjs/simple-single-select/__stories__/WithNoMatchText.js +30 -0
- package/build/cjs/simple-single-select/__stories__/WithOnBlur.js +23 -0
- package/build/cjs/simple-single-select/__stories__/WithOnFocus.js +23 -0
- package/build/cjs/simple-single-select/__stories__/WithOptionsAndDisabled.js +22 -0
- package/build/cjs/simple-single-select/__stories__/WithOptionsAndLoading.js +34 -0
- package/build/cjs/simple-single-select/__stories__/WithOptionsAndLoadingText.js +35 -0
- package/build/cjs/simple-single-select/__stories__/WithPlaceholder.js +23 -0
- package/build/cjs/simple-single-select/__stories__/WithPlaceholderAndSelection.js +25 -0
- package/build/cjs/simple-single-select/__stories__/WithPrefix.js +22 -0
- package/build/cjs/simple-single-select/__stories__/WithPrefixAndSelection.js +25 -0
- package/build/cjs/simple-single-select/__stories__/WithRTL.js +34 -0
- package/build/cjs/simple-single-select/__stories__/WithSelection.js +24 -0
- package/build/cjs/simple-single-select/__stories__/WithSelectionAndDisabled.js +25 -0
- package/build/cjs/simple-single-select/__stories__/WithoutOptionsAndLoading.js +21 -0
- package/build/cjs/simple-single-select/__stories__/WithoutSelection.js +22 -0
- package/build/cjs/simple-single-select/__stories__/options.js +77 -0
- package/build/cjs/simple-single-select/features/keyboard-interactions.test.e2e.js +441 -0
- package/build/cjs/simple-single-select/features/menu-positioning.test.e2e.js +152 -0
- package/build/cjs/simple-single-select/index.js +19 -0
- package/build/cjs/simple-single-select/is-option-hidden.js +22 -0
- package/build/cjs/simple-single-select/menu/empty.js +26 -0
- package/build/cjs/simple-single-select/menu/filter.js +60 -0
- package/build/cjs/simple-single-select/menu/index.js +12 -0
- package/build/cjs/simple-single-select/menu/loading.js +30 -0
- package/build/cjs/simple-single-select/menu/menu.js +158 -0
- package/build/cjs/simple-single-select/menu/no-match.js +28 -0
- package/build/cjs/simple-single-select/menu/option.js +120 -0
- package/build/cjs/simple-single-select/menu/options-list.js +97 -0
- package/build/cjs/simple-single-select/selected-value/clear-button.js +74 -0
- package/build/cjs/simple-single-select/selected-value/container.js +100 -0
- package/build/cjs/simple-single-select/selected-value/index.js +12 -0
- package/build/cjs/simple-single-select/selected-value/placeholder.js +30 -0
- package/build/cjs/simple-single-select/selected-value/prefix.js +30 -0
- package/build/cjs/simple-single-select/selected-value/selected-value.js +119 -0
- package/build/cjs/simple-single-select/shared-prop-types.js +14 -0
- package/build/cjs/simple-single-select/simple-single-select.e2e.stories.js +156 -0
- package/build/cjs/simple-single-select/simple-single-select.js +319 -0
- package/build/cjs/simple-single-select/simple-single-select.prod.stories.js +228 -0
- package/build/cjs/simple-single-select/simple-single-select.test.js +1106 -0
- package/build/cjs/simple-single-select/use-handle-key-press/index.js +19 -0
- package/build/cjs/simple-single-select/use-handle-key-press/use-focus-option.js +24 -0
- package/build/cjs/simple-single-select/use-handle-key-press/use-handle-key-press-on-combobox.js +177 -0
- package/build/cjs/simple-single-select/use-handle-key-press/use-handle-key-press-on-filter-input.js +106 -0
- package/build/cjs/simple-single-select/use-handle-key-press/use-handle-typing.js +81 -0
- package/build/cjs/simple-single-select/use-handle-key-press/use-highlight-first-option-on-previous-page.js +50 -0
- package/build/cjs/simple-single-select/use-handle-key-press/use-highlight-first-visible-option.js +30 -0
- package/build/cjs/simple-single-select/use-handle-key-press/use-highlight-last-option-on-next-page.js +50 -0
- package/build/cjs/simple-single-select/use-handle-key-press/use-highlight-last-visible-option.js +42 -0
- package/build/cjs/simple-single-select/use-handle-key-press/use-page-down.js +45 -0
- package/build/cjs/simple-single-select/use-handle-key-press/use-page-up.js +44 -0
- package/build/cjs/simple-single-select/use-handle-key-press/utils.js +46 -0
- package/build/cjs/simple-single-select-field/index.js +12 -0
- package/build/cjs/simple-single-select-field/simple-single-select-field.js +138 -0
- package/build/cjs/simple-single-select-field/simple-single-select-field.prod.stories.js +188 -0
- package/build/cjs/simple-single-select-field/simple-single-select-field.test.js +133 -0
- package/build/es/index.js +2 -0
- package/build/es/locales/en/translations.json +7 -5
- package/build/es/simple-single-select/__stories__/DefaultPosition.js +29 -0
- package/build/es/simple-single-select/__stories__/Dense.js +13 -0
- package/build/es/simple-single-select/__stories__/Empty.js +11 -0
- package/build/es/simple-single-select/__stories__/EmptyWithEmptyNode.js +19 -0
- package/build/es/simple-single-select/__stories__/EmptyWithEmptyText.js +12 -0
- package/build/es/simple-single-select/__stories__/FlippedPosition.js +28 -0
- package/build/es/simple-single-select/__stories__/InfiniteLoading.js +53 -0
- package/build/es/simple-single-select/__stories__/Loading.js +12 -0
- package/build/es/simple-single-select/__stories__/ShiftedIntoView.js +18 -0
- package/build/es/simple-single-select/__stories__/WithClearButton.js +16 -0
- package/build/es/simple-single-select/__stories__/WithCustomLowMaxHeight.js +13 -0
- package/build/es/simple-single-select/__stories__/WithCustomOptions.js +38 -0
- package/build/es/simple-single-select/__stories__/WithDisabledOption.js +19 -0
- package/build/es/simple-single-select/__stories__/WithFilterField.js +27 -0
- package/build/es/simple-single-select/__stories__/WithInitialFocus.js +29 -0
- package/build/es/simple-single-select/__stories__/WithManyOptions.js +15 -0
- package/build/es/simple-single-select/__stories__/WithNoMatchText.js +21 -0
- package/build/es/simple-single-select/__stories__/WithOnBlur.js +14 -0
- package/build/es/simple-single-select/__stories__/WithOnFocus.js +14 -0
- package/build/es/simple-single-select/__stories__/WithOptionsAndDisabled.js +13 -0
- package/build/es/simple-single-select/__stories__/WithOptionsAndLoading.js +25 -0
- package/build/es/simple-single-select/__stories__/WithOptionsAndLoadingText.js +26 -0
- package/build/es/simple-single-select/__stories__/WithPlaceholder.js +14 -0
- package/build/es/simple-single-select/__stories__/WithPlaceholderAndSelection.js +16 -0
- package/build/es/simple-single-select/__stories__/WithPrefix.js +13 -0
- package/build/es/simple-single-select/__stories__/WithPrefixAndSelection.js +16 -0
- package/build/es/simple-single-select/__stories__/WithRTL.js +25 -0
- package/build/es/simple-single-select/__stories__/WithSelection.js +15 -0
- package/build/es/simple-single-select/__stories__/WithSelectionAndDisabled.js +16 -0
- package/build/es/simple-single-select/__stories__/WithoutOptionsAndLoading.js +12 -0
- package/build/es/simple-single-select/__stories__/WithoutSelection.js +13 -0
- package/build/es/simple-single-select/__stories__/options.js +71 -0
- package/build/es/simple-single-select/features/keyboard-interactions.test.e2e.js +439 -0
- package/build/es/simple-single-select/features/menu-positioning.test.e2e.js +150 -0
- package/build/es/simple-single-select/index.js +2 -0
- package/build/es/simple-single-select/is-option-hidden.js +16 -0
- package/build/es/simple-single-select/menu/empty.js +19 -0
- package/build/es/simple-single-select/menu/filter.js +53 -0
- package/build/es/simple-single-select/menu/index.js +1 -0
- package/build/es/simple-single-select/menu/loading.js +23 -0
- package/build/es/simple-single-select/menu/menu.js +149 -0
- package/build/es/simple-single-select/menu/no-match.js +21 -0
- package/build/es/simple-single-select/menu/option.js +111 -0
- package/build/es/simple-single-select/menu/options-list.js +88 -0
- package/build/es/simple-single-select/selected-value/clear-button.js +68 -0
- package/build/es/simple-single-select/selected-value/container.js +91 -0
- package/build/es/simple-single-select/selected-value/index.js +1 -0
- package/build/es/simple-single-select/selected-value/placeholder.js +23 -0
- package/build/es/simple-single-select/selected-value/prefix.js +23 -0
- package/build/es/simple-single-select/selected-value/selected-value.js +112 -0
- package/build/es/simple-single-select/shared-prop-types.js +7 -0
- package/build/es/simple-single-select/simple-single-select.e2e.stories.js +142 -0
- package/build/es/simple-single-select/simple-single-select.js +310 -0
- package/build/es/simple-single-select/simple-single-select.prod.stories.js +36 -0
- package/build/es/simple-single-select/simple-single-select.test.js +1103 -0
- package/build/es/simple-single-select/use-handle-key-press/index.js +2 -0
- package/build/es/simple-single-select/use-handle-key-press/use-focus-option.js +18 -0
- package/build/es/simple-single-select/use-handle-key-press/use-handle-key-press-on-combobox.js +171 -0
- package/build/es/simple-single-select/use-handle-key-press/use-handle-key-press-on-filter-input.js +100 -0
- package/build/es/simple-single-select/use-handle-key-press/use-handle-typing.js +75 -0
- package/build/es/simple-single-select/use-handle-key-press/use-highlight-first-option-on-previous-page.js +44 -0
- package/build/es/simple-single-select/use-handle-key-press/use-highlight-first-visible-option.js +24 -0
- package/build/es/simple-single-select/use-handle-key-press/use-highlight-last-option-on-next-page.js +44 -0
- package/build/es/simple-single-select/use-handle-key-press/use-highlight-last-visible-option.js +36 -0
- package/build/es/simple-single-select/use-handle-key-press/use-page-down.js +39 -0
- package/build/es/simple-single-select/use-handle-key-press/use-page-up.js +38 -0
- package/build/es/simple-single-select/use-handle-key-press/utils.js +36 -0
- package/build/es/simple-single-select-field/index.js +1 -0
- package/build/es/simple-single-select-field/simple-single-select-field.js +131 -0
- package/build/es/simple-single-select-field/simple-single-select-field.prod.stories.js +172 -0
- package/build/es/simple-single-select-field/simple-single-select-field.test.js +130 -0
- package/package.json +15 -15
- package/types/index.d.ts +184 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
import { colors, spacers } from '@dhis2/ui-constants';
|
|
3
|
+
import { Input } from '@dhis2-ui/input';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import i18n from '../../locales/index.js';
|
|
7
|
+
export function Filter(_ref) {
|
|
8
|
+
let {
|
|
9
|
+
ariaControls,
|
|
10
|
+
dataTest,
|
|
11
|
+
label,
|
|
12
|
+
placeholder,
|
|
13
|
+
tabIndex,
|
|
14
|
+
value,
|
|
15
|
+
onChange,
|
|
16
|
+
onKeyDown
|
|
17
|
+
} = _ref;
|
|
18
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
19
|
+
"data-test": dataTest,
|
|
20
|
+
className: _JSXStyle.dynamic([["3850436710", [colors.white, spacers.dp8, spacers.dp8, spacers.dp4, spacers.dp8]]])
|
|
21
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
22
|
+
dense: true,
|
|
23
|
+
tabIndex: tabIndex,
|
|
24
|
+
ariaControls: ariaControls,
|
|
25
|
+
ariaHaspopup: "listbox",
|
|
26
|
+
ariaLabel: label || i18n.t('Search options'),
|
|
27
|
+
dataTest: `${dataTest}-input`,
|
|
28
|
+
value: value,
|
|
29
|
+
onChange: _ref2 => {
|
|
30
|
+
let {
|
|
31
|
+
value
|
|
32
|
+
} = _ref2;
|
|
33
|
+
return onChange(value);
|
|
34
|
+
},
|
|
35
|
+
type: "text",
|
|
36
|
+
name: "filter",
|
|
37
|
+
placeholder: placeholder,
|
|
38
|
+
onKeyDown: (_, e) => onKeyDown(e)
|
|
39
|
+
}), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
40
|
+
id: "3850436710",
|
|
41
|
+
dynamic: [colors.white, spacers.dp8, spacers.dp8, spacers.dp4, spacers.dp8]
|
|
42
|
+
}, [`div.__jsx-style-dynamic-selector{height:100%;-webkit-inset-block-start:0;-ms-intb-rlock-start:0;inset-block-start:0;background:${colors.white};}`]));
|
|
43
|
+
}
|
|
44
|
+
Filter.propTypes = {
|
|
45
|
+
ariaControls: PropTypes.string.isRequired,
|
|
46
|
+
value: PropTypes.string.isRequired,
|
|
47
|
+
onChange: PropTypes.func.isRequired,
|
|
48
|
+
dataTest: PropTypes.string,
|
|
49
|
+
label: PropTypes.string,
|
|
50
|
+
placeholder: PropTypes.string,
|
|
51
|
+
tabIndex: PropTypes.string,
|
|
52
|
+
onKeyDown: PropTypes.func
|
|
53
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Menu } from './menu.js';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
import { colors, spacers, theme } from '@dhis2/ui-constants';
|
|
3
|
+
import { CircularLoader } from '@dhis2-ui/loader';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
export function Loading(_ref) {
|
|
7
|
+
let {
|
|
8
|
+
message
|
|
9
|
+
} = _ref;
|
|
10
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
11
|
+
className: _JSXStyle.dynamic([["316664301", [spacers.dp16, colors.grey700, theme.fonts, spacers.dp8, spacers.dp24]]]) + " " + "container"
|
|
12
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
13
|
+
className: _JSXStyle.dynamic([["316664301", [spacers.dp16, colors.grey700, theme.fonts, spacers.dp8, spacers.dp24]]])
|
|
14
|
+
}, /*#__PURE__*/React.createElement(CircularLoader, {
|
|
15
|
+
small: true
|
|
16
|
+
})), message, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
17
|
+
id: "316664301",
|
|
18
|
+
dynamic: [spacers.dp16, colors.grey700, theme.fonts, spacers.dp8, spacers.dp24]
|
|
19
|
+
}, [`.container.__jsx-style-dynamic-selector{box-sizing:border-box;width:100%;height:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:${spacers.dp16};-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;color:${colors.grey700};font-family:${theme.fonts};font-size:13px;padding-block:${spacers.dp8};padding-inline:${spacers.dp24};background:rgba(255,255,255,0.8);}`]));
|
|
20
|
+
}
|
|
21
|
+
Loading.propTypes = {
|
|
22
|
+
message: PropTypes.string
|
|
23
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
import { colors, elevations } from '@dhis2/ui-constants';
|
|
3
|
+
import { Layer } from '@dhis2-ui/layer';
|
|
4
|
+
import { Popper } from '@dhis2-ui/popper';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import React, { useEffect, useState } from 'react';
|
|
7
|
+
import { optionProp } from '../shared-prop-types.js';
|
|
8
|
+
import { Empty } from './empty.js';
|
|
9
|
+
import { Filter } from './filter.js';
|
|
10
|
+
import { Loading } from './loading.js';
|
|
11
|
+
import { NoMatch } from './no-match.js';
|
|
12
|
+
import { OptionsList } from './options-list.js';
|
|
13
|
+
export function Menu(_ref) {
|
|
14
|
+
let {
|
|
15
|
+
comboBoxId,
|
|
16
|
+
focussedOptionIndex,
|
|
17
|
+
name,
|
|
18
|
+
options,
|
|
19
|
+
onChange,
|
|
20
|
+
optionComponent,
|
|
21
|
+
dataTest,
|
|
22
|
+
disabled,
|
|
23
|
+
empty,
|
|
24
|
+
filterLabel,
|
|
25
|
+
filterPlaceholder,
|
|
26
|
+
filterValue,
|
|
27
|
+
filterable,
|
|
28
|
+
hidden,
|
|
29
|
+
labelledBy,
|
|
30
|
+
listBoxRef,
|
|
31
|
+
loading,
|
|
32
|
+
loadingText,
|
|
33
|
+
maxHeight,
|
|
34
|
+
noMatchText,
|
|
35
|
+
optionUpdateStrategy,
|
|
36
|
+
selectRef,
|
|
37
|
+
selectedValue,
|
|
38
|
+
tabIndex,
|
|
39
|
+
onBlur,
|
|
40
|
+
onClose,
|
|
41
|
+
onEndReached,
|
|
42
|
+
onFilterChange,
|
|
43
|
+
onFilterInputKeyDown
|
|
44
|
+
} = _ref;
|
|
45
|
+
const [menuWidth, setWidth] = useState('auto');
|
|
46
|
+
const dataTestPrefix = `${dataTest}-menu`;
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (selectRef) {
|
|
49
|
+
const callback = () => setWidth(`${selectRef.offsetWidth}px`);
|
|
50
|
+
callback(); // We want to know the width as soon as the
|
|
51
|
+
|
|
52
|
+
selectRef.addEventListener('resize', callback);
|
|
53
|
+
return () => selectRef.removeEventListener('resize', callback);
|
|
54
|
+
}
|
|
55
|
+
}, [selectRef]);
|
|
56
|
+
if (hidden) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const hasNoFilterMatch = !options.length && filterValue &&
|
|
60
|
+
// We don't want to show the noMatchText when
|
|
61
|
+
// we're in the process of loading options
|
|
62
|
+
!loading;
|
|
63
|
+
const isEmpty = !options.length && !filterValue;
|
|
64
|
+
return /*#__PURE__*/React.createElement(Layer, {
|
|
65
|
+
onBackdropClick: onClose,
|
|
66
|
+
transparent: true
|
|
67
|
+
}, /*#__PURE__*/React.createElement(Popper, {
|
|
68
|
+
reference: selectRef,
|
|
69
|
+
placement: "bottom-start",
|
|
70
|
+
observeReferenceResize: true
|
|
71
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
72
|
+
style: {
|
|
73
|
+
width: menuWidth,
|
|
74
|
+
maxHeight
|
|
75
|
+
},
|
|
76
|
+
className: _JSXStyle.dynamic([["2949029222", [colors.white, colors.grey200, elevations.e300]]]) + " " + "menu"
|
|
77
|
+
}, filterable && /*#__PURE__*/React.createElement("div", {
|
|
78
|
+
className: _JSXStyle.dynamic([["2949029222", [colors.white, colors.grey200, elevations.e300]]]) + " " + "filter-container"
|
|
79
|
+
}, /*#__PURE__*/React.createElement(Filter, {
|
|
80
|
+
dataTest: `${dataTestPrefix}-filter`,
|
|
81
|
+
value: filterValue,
|
|
82
|
+
label: filterLabel,
|
|
83
|
+
ariaControls: `${name}-listbox`,
|
|
84
|
+
placeholder: filterPlaceholder,
|
|
85
|
+
tabIndex: tabIndex,
|
|
86
|
+
onChange: onFilterChange,
|
|
87
|
+
onKeyDown: onFilterInputKeyDown
|
|
88
|
+
})), isEmpty && /*#__PURE__*/React.createElement(Empty, null, empty), hasNoFilterMatch && /*#__PURE__*/React.createElement(NoMatch, null, noMatchText), /*#__PURE__*/React.createElement("div", {
|
|
89
|
+
className: _JSXStyle.dynamic([["2949029222", [colors.white, colors.grey200, elevations.e300]]]) + " " + "listbox-container"
|
|
90
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
91
|
+
className: _JSXStyle.dynamic([["2949029222", [colors.white, colors.grey200, elevations.e300]]]) + " " + "listbox-wrapper"
|
|
92
|
+
}, /*#__PURE__*/React.createElement(OptionsList, {
|
|
93
|
+
ref: listBoxRef,
|
|
94
|
+
comboBoxId: comboBoxId,
|
|
95
|
+
optionComponent: optionComponent,
|
|
96
|
+
dataTest: `${dataTestPrefix}-list`,
|
|
97
|
+
disabled: disabled,
|
|
98
|
+
focussedOptionIndex: focussedOptionIndex,
|
|
99
|
+
labelledBy: labelledBy,
|
|
100
|
+
loading: loading,
|
|
101
|
+
id: `${name}-listbox`,
|
|
102
|
+
optionUpdateStrategy: optionUpdateStrategy,
|
|
103
|
+
options: options,
|
|
104
|
+
selectedValue: selectedValue,
|
|
105
|
+
onBlur: onBlur,
|
|
106
|
+
onChange: onChange,
|
|
107
|
+
onEndReached: onEndReached
|
|
108
|
+
})), loading && /*#__PURE__*/React.createElement("div", {
|
|
109
|
+
className: _JSXStyle.dynamic([["2949029222", [colors.white, colors.grey200, elevations.e300]]]) + " " + "menu-loading-container"
|
|
110
|
+
}, /*#__PURE__*/React.createElement(Loading, {
|
|
111
|
+
message: loadingText
|
|
112
|
+
}))), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
113
|
+
id: "2949029222",
|
|
114
|
+
dynamic: [colors.white, colors.grey200, elevations.e300]
|
|
115
|
+
}, [`.menu.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;height:auto;background:${colors.white};border:1px solid ${colors.grey200};border-radius:3px;box-shadow:${elevations.e300};box-sizing:content-box;}`, ".listbox-container.__jsx-style-dynamic-selector{position:relative;-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;overflow:hidden;}", ".listbox-wrapper.__jsx-style-dynamic-selector{overflow:auto;-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;}", ".menu-loading-container.__jsx-style-dynamic-selector{position:absolute;left:0;top:0;width:100%;height:100%;}"]))));
|
|
116
|
+
}
|
|
117
|
+
Menu.propTypes = {
|
|
118
|
+
comboBoxId: PropTypes.string.isRequired,
|
|
119
|
+
focussedOptionIndex: PropTypes.number.isRequired,
|
|
120
|
+
listBoxRef: PropTypes.shape({
|
|
121
|
+
current: PropTypes.instanceOf(HTMLElement)
|
|
122
|
+
}).isRequired,
|
|
123
|
+
name: PropTypes.string.isRequired,
|
|
124
|
+
options: PropTypes.arrayOf(optionProp).isRequired,
|
|
125
|
+
onChange: PropTypes.func.isRequired,
|
|
126
|
+
dataTest: PropTypes.string,
|
|
127
|
+
disabled: PropTypes.bool,
|
|
128
|
+
empty: PropTypes.node,
|
|
129
|
+
filterLabel: PropTypes.string,
|
|
130
|
+
filterPlaceholder: PropTypes.string,
|
|
131
|
+
filterValue: PropTypes.string,
|
|
132
|
+
filterable: PropTypes.bool,
|
|
133
|
+
hidden: PropTypes.bool,
|
|
134
|
+
labelledBy: PropTypes.string,
|
|
135
|
+
loading: PropTypes.bool,
|
|
136
|
+
loadingText: PropTypes.string,
|
|
137
|
+
maxHeight: PropTypes.string,
|
|
138
|
+
noMatchText: PropTypes.string,
|
|
139
|
+
optionComponent: PropTypes.elementType,
|
|
140
|
+
optionUpdateStrategy: PropTypes.oneOf(['off', 'polite', 'assertive']),
|
|
141
|
+
selectRef: PropTypes.instanceOf(HTMLElement),
|
|
142
|
+
selectedValue: PropTypes.string,
|
|
143
|
+
tabIndex: PropTypes.string,
|
|
144
|
+
onBlur: PropTypes.func,
|
|
145
|
+
onClose: PropTypes.func,
|
|
146
|
+
onEndReached: PropTypes.func,
|
|
147
|
+
onFilterChange: PropTypes.func,
|
|
148
|
+
onFilterInputKeyDown: PropTypes.func
|
|
149
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
import { colors, spacers, theme } from '@dhis2/ui-constants';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
const NoMatch = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
children,
|
|
8
|
+
className
|
|
9
|
+
} = _ref;
|
|
10
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
11
|
+
className: _JSXStyle.dynamic([["3788156646", [colors.grey700, theme.fonts, spacers.dp8, spacers.dp24]]]) + " " + (className || "")
|
|
12
|
+
}, children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
13
|
+
id: "3788156646",
|
|
14
|
+
dynamic: [colors.grey700, theme.fonts, spacers.dp8, spacers.dp24]
|
|
15
|
+
}, [`div.__jsx-style-dynamic-selector{color:${colors.grey700};font-family:${theme.fonts};font-size:13px;line-height:16px;padding-block:${spacers.dp8};padding-inline:${spacers.dp24};text-align:center;}`]));
|
|
16
|
+
};
|
|
17
|
+
NoMatch.propTypes = {
|
|
18
|
+
children: PropTypes.string.isRequired,
|
|
19
|
+
className: PropTypes.string
|
|
20
|
+
};
|
|
21
|
+
export { NoMatch };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
|
+
import { colors, spacers } from '@dhis2/ui-constants';
|
|
4
|
+
import cx from 'classnames';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import React, { useEffect, useRef } from 'react';
|
|
7
|
+
const VISIBILE_INTERSECTION_RATIO = 0.99;
|
|
8
|
+
function DefaultStyle(_ref) {
|
|
9
|
+
let {
|
|
10
|
+
label,
|
|
11
|
+
disabled,
|
|
12
|
+
highlighted
|
|
13
|
+
} = _ref;
|
|
14
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
15
|
+
className: _JSXStyle.dynamic([["4038065645", [colors.grey900, spacers.dp8, spacers.dp12, spacers.dp16, colors.grey200, colors.teal700, colors.white, colors.grey500]]]) + " " + (cx('option', {
|
|
16
|
+
disabled,
|
|
17
|
+
active: highlighted
|
|
18
|
+
}) || "")
|
|
19
|
+
}, label, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
20
|
+
id: "4038065645",
|
|
21
|
+
dynamic: [colors.grey900, spacers.dp8, spacers.dp12, spacers.dp16, colors.grey200, colors.teal700, colors.white, colors.grey500]
|
|
22
|
+
}, [`span.__jsx-style-dynamic-selector{display:block;cursor:pointer;font-size:14px;-webkit-text-decoration:none;text-decoration:none;color:${colors.grey900};padding-block:${spacers.dp8};padding-inline:${spacers.dp12};line-height:${spacers.dp16};}`, `span.__jsx-style-dynamic-selector:hover{background-color:${colors.grey200};}`, `span.__jsx-style-dynamic-selector:active,span.active.__jsx-style-dynamic-selector{background-color:${colors.teal700};color:${colors.white};cursor:auto;}`, `span.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;}`, "span.disabled.__jsx-style-dynamic-selector:hover{background-color:initial;}"]));
|
|
23
|
+
}
|
|
24
|
+
DefaultStyle.propTypes = {
|
|
25
|
+
label: PropTypes.string.isRequired,
|
|
26
|
+
disabled: PropTypes.bool,
|
|
27
|
+
highlighted: PropTypes.bool
|
|
28
|
+
};
|
|
29
|
+
export function Option(_ref2) {
|
|
30
|
+
let {
|
|
31
|
+
comboBoxId,
|
|
32
|
+
index,
|
|
33
|
+
label,
|
|
34
|
+
value,
|
|
35
|
+
onClick,
|
|
36
|
+
component: StyleComponent = DefaultStyle,
|
|
37
|
+
dataTest,
|
|
38
|
+
disabled,
|
|
39
|
+
highlighted,
|
|
40
|
+
listBoxRef,
|
|
41
|
+
onBecameVisible,
|
|
42
|
+
...rest
|
|
43
|
+
} = _ref2;
|
|
44
|
+
const buttonRef = useRef();
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (onBecameVisible) {
|
|
47
|
+
const scrollableContainer = listBoxRef.current.parentNode;
|
|
48
|
+
const intersectionOptions = {
|
|
49
|
+
root: scrollableContainer,
|
|
50
|
+
threshold: VISIBILE_INTERSECTION_RATIO
|
|
51
|
+
};
|
|
52
|
+
const intersectionHandler = entries => {
|
|
53
|
+
entries.forEach(result => {
|
|
54
|
+
const {
|
|
55
|
+
intersectionRatio
|
|
56
|
+
} = result;
|
|
57
|
+
if (intersectionRatio >= VISIBILE_INTERSECTION_RATIO) {
|
|
58
|
+
onBecameVisible();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
const observer = new IntersectionObserver(intersectionHandler, intersectionOptions);
|
|
63
|
+
observer.observe(buttonRef.current);
|
|
64
|
+
return () => observer.disconnect();
|
|
65
|
+
}
|
|
66
|
+
}, [onBecameVisible, listBoxRef]);
|
|
67
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
68
|
+
ref: buttonRef,
|
|
69
|
+
id: `${comboBoxId}-${index}`,
|
|
70
|
+
"data-test": dataTest,
|
|
71
|
+
disabled: disabled,
|
|
72
|
+
role: "option",
|
|
73
|
+
"aria-selected": highlighted || 'false',
|
|
74
|
+
"aria-disabled": disabled,
|
|
75
|
+
"aria-label": label,
|
|
76
|
+
onClick: () => {
|
|
77
|
+
if (!disabled) {
|
|
78
|
+
onClick({
|
|
79
|
+
value,
|
|
80
|
+
label
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
className: "jsx-4228237498"
|
|
85
|
+
}, /*#__PURE__*/React.createElement(StyleComponent, _extends({
|
|
86
|
+
value: value,
|
|
87
|
+
label: label,
|
|
88
|
+
index: index,
|
|
89
|
+
disabled: disabled,
|
|
90
|
+
highlighted: highlighted
|
|
91
|
+
}, rest, {
|
|
92
|
+
className: "jsx-4228237498" + " " + (rest && rest.className != null && rest.className || "")
|
|
93
|
+
}), label), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
94
|
+
id: "4228237498"
|
|
95
|
+
}, ["button.jsx-4228237498{display:block;width:100%;padding:0;border:0;background:0;outline:0;text-align:start;}"]));
|
|
96
|
+
}
|
|
97
|
+
Option.propTypes = {
|
|
98
|
+
comboBoxId: PropTypes.string.isRequired,
|
|
99
|
+
index: PropTypes.number.isRequired,
|
|
100
|
+
label: PropTypes.string.isRequired,
|
|
101
|
+
value: PropTypes.string.isRequired,
|
|
102
|
+
onClick: PropTypes.func.isRequired,
|
|
103
|
+
component: PropTypes.elementType,
|
|
104
|
+
dataTest: PropTypes.string,
|
|
105
|
+
disabled: PropTypes.bool,
|
|
106
|
+
highlighted: PropTypes.bool,
|
|
107
|
+
listBoxRef: PropTypes.shape({
|
|
108
|
+
current: PropTypes.instanceOf(HTMLElement)
|
|
109
|
+
}),
|
|
110
|
+
onBecameVisible: PropTypes.func
|
|
111
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React, { forwardRef, useEffect } from 'react';
|
|
3
|
+
import { isOptionHidden } from '../is-option-hidden.js';
|
|
4
|
+
import { optionProp } from '../shared-prop-types.js';
|
|
5
|
+
import { Option } from './option.js';
|
|
6
|
+
export const OptionsList = /*#__PURE__*/forwardRef(function OptionsList(_ref, ref) {
|
|
7
|
+
let {
|
|
8
|
+
comboBoxId,
|
|
9
|
+
optionComponent,
|
|
10
|
+
focussedOptionIndex,
|
|
11
|
+
id,
|
|
12
|
+
labelledBy,
|
|
13
|
+
optionUpdateStrategy,
|
|
14
|
+
options,
|
|
15
|
+
selectedValue,
|
|
16
|
+
dataTest,
|
|
17
|
+
disabled,
|
|
18
|
+
loading,
|
|
19
|
+
onChange,
|
|
20
|
+
onBlur,
|
|
21
|
+
onEndReached
|
|
22
|
+
} = _ref;
|
|
23
|
+
// scrolls the highlighted option into view when:
|
|
24
|
+
// * the highlighted option changes
|
|
25
|
+
// * the menu opens
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const {
|
|
28
|
+
current: listBox
|
|
29
|
+
} = ref;
|
|
30
|
+
const highlightedOption = listBox.childNodes[focussedOptionIndex];
|
|
31
|
+
if (highlightedOption) {
|
|
32
|
+
const listBoxParent = listBox.parentNode;
|
|
33
|
+
const optionHidden = isOptionHidden(highlightedOption, listBoxParent);
|
|
34
|
+
if (optionHidden) {
|
|
35
|
+
highlightedOption.scrollIntoView();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}, [focussedOptionIndex, ref]);
|
|
39
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
ref: ref,
|
|
41
|
+
role: "listbox",
|
|
42
|
+
id: id,
|
|
43
|
+
"aria-labelledby": labelledBy,
|
|
44
|
+
"aria-live": optionUpdateStrategy,
|
|
45
|
+
"aria-busy": loading.toString(),
|
|
46
|
+
"data-test": dataTest,
|
|
47
|
+
onBlur: onBlur
|
|
48
|
+
}, options.map((_ref2, index) => {
|
|
49
|
+
let {
|
|
50
|
+
value,
|
|
51
|
+
label,
|
|
52
|
+
component,
|
|
53
|
+
disabled: optionDisabled = false
|
|
54
|
+
} = _ref2;
|
|
55
|
+
const isSelected = value === selectedValue;
|
|
56
|
+
const isLast = index === options.length - 1;
|
|
57
|
+
return /*#__PURE__*/React.createElement(Option, {
|
|
58
|
+
listBoxRef: ref,
|
|
59
|
+
dataTest: `${dataTest}-option`,
|
|
60
|
+
highlighted: focussedOptionIndex === index,
|
|
61
|
+
key: value,
|
|
62
|
+
value: value,
|
|
63
|
+
label: label,
|
|
64
|
+
index: index,
|
|
65
|
+
comboBoxId: comboBoxId,
|
|
66
|
+
disabled: disabled || optionDisabled,
|
|
67
|
+
onClick: isSelected ? () => null : onChange,
|
|
68
|
+
component: component || optionComponent,
|
|
69
|
+
onBecameVisible: isLast ? onEndReached : undefined
|
|
70
|
+
});
|
|
71
|
+
}));
|
|
72
|
+
});
|
|
73
|
+
OptionsList.propTypes = {
|
|
74
|
+
comboBoxId: PropTypes.string.isRequired,
|
|
75
|
+
focussedOptionIndex: PropTypes.number.isRequired,
|
|
76
|
+
id: PropTypes.string.isRequired,
|
|
77
|
+
options: PropTypes.arrayOf(optionProp).isRequired,
|
|
78
|
+
onChange: PropTypes.func.isRequired,
|
|
79
|
+
dataTest: PropTypes.string,
|
|
80
|
+
disabled: PropTypes.bool,
|
|
81
|
+
labelledBy: PropTypes.string,
|
|
82
|
+
loading: PropTypes.bool,
|
|
83
|
+
optionComponent: PropTypes.elementType,
|
|
84
|
+
optionUpdateStrategy: PropTypes.oneOf(['off', 'polite', 'assertive']),
|
|
85
|
+
selectedValue: PropTypes.string,
|
|
86
|
+
onBlur: PropTypes.func,
|
|
87
|
+
onEndReached: PropTypes.func
|
|
88
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
import { colors, theme } from '@dhis2/ui-constants';
|
|
3
|
+
import { Tooltip } from '@dhis2-ui/tooltip';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import i18n from '../../locales/index.js';
|
|
7
|
+
function ClearButton(_ref) {
|
|
8
|
+
let {
|
|
9
|
+
onClear,
|
|
10
|
+
clearText,
|
|
11
|
+
dataTest
|
|
12
|
+
} = _ref;
|
|
13
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
14
|
+
"aria-label": i18n.t('{{clearText}}', {
|
|
15
|
+
clearText
|
|
16
|
+
}),
|
|
17
|
+
"data-test": dataTest,
|
|
18
|
+
onClick: e => {
|
|
19
|
+
e.stopPropagation();
|
|
20
|
+
onClear();
|
|
21
|
+
},
|
|
22
|
+
className: _JSXStyle.dynamic([["2606883952", [colors.grey500, colors.grey800, colors.grey200, theme.focus]]])
|
|
23
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
24
|
+
width: "16",
|
|
25
|
+
height: "16",
|
|
26
|
+
viewBox: "0 0 16 16",
|
|
27
|
+
fill: "none",
|
|
28
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
29
|
+
className: _JSXStyle.dynamic([["2606883952", [colors.grey500, colors.grey800, colors.grey200, theme.focus]]])
|
|
30
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
31
|
+
d: "M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16Zm3.536-5.879a1 1 0 1 1-1.415 1.414l-2.12-2.12-2.122 2.121a1 1 0 1 1-1.415-1.414L6.586 8 4.464 5.878A1 1 0 1 1 5.88 4.464L8 6.586l2.121-2.121a1 1 0 1 1 1.415 1.414L9.415 8l2.12 2.121Z",
|
|
32
|
+
fill: "none",
|
|
33
|
+
className: _JSXStyle.dynamic([["2606883952", [colors.grey500, colors.grey800, colors.grey200, theme.focus]]])
|
|
34
|
+
})), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
35
|
+
id: "2606883952",
|
|
36
|
+
dynamic: [colors.grey500, colors.grey800, colors.grey200, theme.focus]
|
|
37
|
+
}, ["button.__jsx-style-dynamic-selector{background:none;border:none;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-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;cursor:pointer;height:24px;width:24px;border-radius:3px;}", `button.__jsx-style-dynamic-selector svg.__jsx-style-dynamic-selector path.__jsx-style-dynamic-selector{fill:${colors.grey500};}`, `button.__jsx-style-dynamic-selector:hover svg.__jsx-style-dynamic-selector path.__jsx-style-dynamic-selector{fill:${colors.grey800};}`, `button.__jsx-style-dynamic-selector:hover{background:${colors.grey200};}`, `button.__jsx-style-dynamic-selector:focus{outline:2px solid ${theme.focus};}`]));
|
|
38
|
+
}
|
|
39
|
+
ClearButton.propTypes = {
|
|
40
|
+
clearText: PropTypes.string.isRequired,
|
|
41
|
+
onClear: PropTypes.func.isRequired,
|
|
42
|
+
dataTest: PropTypes.string
|
|
43
|
+
};
|
|
44
|
+
function ClearButtonWithTooltip(_ref2) {
|
|
45
|
+
let {
|
|
46
|
+
onClear,
|
|
47
|
+
clearText,
|
|
48
|
+
dataTest
|
|
49
|
+
} = _ref2;
|
|
50
|
+
const clearButton = /*#__PURE__*/React.createElement(ClearButton, {
|
|
51
|
+
onClear: onClear,
|
|
52
|
+
dataTest: dataTest,
|
|
53
|
+
clearText: clearText
|
|
54
|
+
});
|
|
55
|
+
if (!clearText) {
|
|
56
|
+
return clearButton;
|
|
57
|
+
}
|
|
58
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
59
|
+
openDelay: 500,
|
|
60
|
+
content: clearText
|
|
61
|
+
}, clearButton);
|
|
62
|
+
}
|
|
63
|
+
ClearButtonWithTooltip.propTypes = {
|
|
64
|
+
clearText: PropTypes.string.isRequired,
|
|
65
|
+
onClear: PropTypes.func.isRequired,
|
|
66
|
+
dataTest: PropTypes.string
|
|
67
|
+
};
|
|
68
|
+
export { ClearButtonWithTooltip as ClearButton };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
import { colors, theme } from '@dhis2/ui-constants';
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import React, { forwardRef, useCallback, useEffect } from 'react';
|
|
6
|
+
export const Container = /*#__PURE__*/forwardRef(function Container(_ref, ref) {
|
|
7
|
+
let {
|
|
8
|
+
children,
|
|
9
|
+
comboBoxId,
|
|
10
|
+
autoFocus,
|
|
11
|
+
dataTest,
|
|
12
|
+
dense,
|
|
13
|
+
disabled,
|
|
14
|
+
error,
|
|
15
|
+
expanded,
|
|
16
|
+
labelledBy,
|
|
17
|
+
name,
|
|
18
|
+
placeholder,
|
|
19
|
+
tabIndex,
|
|
20
|
+
valid,
|
|
21
|
+
warning,
|
|
22
|
+
onBlur,
|
|
23
|
+
onClick: _onClick,
|
|
24
|
+
onFocus,
|
|
25
|
+
onKeyDown
|
|
26
|
+
} = _ref;
|
|
27
|
+
// Using useEffect so we have access to the ref, which will be set before
|
|
28
|
+
// the first call to the useEffect's callback
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (autoFocus) {
|
|
31
|
+
ref.current.focus();
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
// We want to run this only once:
|
|
35
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
36
|
+
[]);
|
|
37
|
+
const onClick = useCallback(function () {
|
|
38
|
+
if (!disabled) {
|
|
39
|
+
_onClick(...arguments);
|
|
40
|
+
}
|
|
41
|
+
}, [disabled, _onClick]);
|
|
42
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
43
|
+
"data-test": dataTest,
|
|
44
|
+
ref: ref,
|
|
45
|
+
"aria-controls": `${name}-listbox`,
|
|
46
|
+
"aria-expanded": expanded.toString(),
|
|
47
|
+
"aria-haspopup": "listbox",
|
|
48
|
+
"aria-labelledby": labelledBy,
|
|
49
|
+
"aria-placeholder": placeholder,
|
|
50
|
+
id: comboBoxId,
|
|
51
|
+
role: "combobox",
|
|
52
|
+
tabIndex: tabIndex,
|
|
53
|
+
onFocus: onFocus,
|
|
54
|
+
onBlur: onBlur,
|
|
55
|
+
onClick: onClick,
|
|
56
|
+
onKeyDown: e => {
|
|
57
|
+
e.stopPropagation();
|
|
58
|
+
onKeyDown(e);
|
|
59
|
+
},
|
|
60
|
+
className: _JSXStyle.dynamic([["2391216206", [colors.grey500, colors.grey900, theme.focus, theme.focus, theme.valid, theme.warning, theme.error, colors.grey100, colors.grey500, theme.disabled]]]) + " " + (cx({
|
|
61
|
+
error,
|
|
62
|
+
warning,
|
|
63
|
+
valid,
|
|
64
|
+
disabled,
|
|
65
|
+
dense
|
|
66
|
+
}) || "")
|
|
67
|
+
}, children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
68
|
+
id: "2391216206",
|
|
69
|
+
dynamic: [colors.grey500, colors.grey900, theme.focus, theme.focus, theme.valid, theme.warning, theme.error, colors.grey100, colors.grey500, theme.disabled]
|
|
70
|
+
}, [`div.__jsx-style-dynamic-selector{background-color:white;border-radius:3px;border:1px solid ${colors.grey500};box-sizing:border-box;min-height:40px;padding-block:6px;padding-inline:12px;box-shadow:inset 0 0 1px 0 rgba(48,54,60,0.1);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:${colors.grey900};font-size:14px;line-height:16px;}`, `div.__jsx-style-dynamic-selector:not(.disabled):focus,div.__jsx-style-dynamic-selector:not(.disabled):active{outline:none;box-shadow:inset 0 0 0 2px ${theme.focus};border-color:${theme.focus};}`, `div.valid.__jsx-style-dynamic-selector{border-color:${theme.valid};}`, `div.warning.__jsx-style-dynamic-selector{border-color:${theme.warning};}`, `div.error.__jsx-style-dynamic-selector{border-color:${theme.error};}`, `div.disabled.__jsx-style-dynamic-selector{background-color:${colors.grey100};border-color:${colors.grey500};color:${theme.disabled};cursor:not-allowed;}`, "div.dense.__jsx-style-dynamic-selector{padding-block:2px;padding-inline:8px;min-height:32px;}"]));
|
|
71
|
+
});
|
|
72
|
+
Container.propTypes = {
|
|
73
|
+
children: PropTypes.any.isRequired,
|
|
74
|
+
comboBoxId: PropTypes.string.isRequired,
|
|
75
|
+
name: PropTypes.string.isRequired,
|
|
76
|
+
onKeyDown: PropTypes.func.isRequired,
|
|
77
|
+
autoFocus: PropTypes.bool,
|
|
78
|
+
dataTest: PropTypes.string,
|
|
79
|
+
dense: PropTypes.bool,
|
|
80
|
+
disabled: PropTypes.bool,
|
|
81
|
+
error: PropTypes.bool,
|
|
82
|
+
expanded: PropTypes.bool,
|
|
83
|
+
labelledBy: PropTypes.string,
|
|
84
|
+
placeholder: PropTypes.string,
|
|
85
|
+
tabIndex: PropTypes.string,
|
|
86
|
+
valid: PropTypes.bool,
|
|
87
|
+
warning: PropTypes.bool,
|
|
88
|
+
onBlur: PropTypes.func,
|
|
89
|
+
onClick: PropTypes.func,
|
|
90
|
+
onFocus: PropTypes.func
|
|
91
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SelectedValue } from './selected-value.js';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
import { colors } from '@dhis2/ui-constants';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
export function Placeholder(_ref) {
|
|
6
|
+
let {
|
|
7
|
+
placeholder,
|
|
8
|
+
className,
|
|
9
|
+
dataTest
|
|
10
|
+
} = _ref;
|
|
11
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
12
|
+
"data-test": dataTest,
|
|
13
|
+
className: _JSXStyle.dynamic([["1027033961", [colors.grey600]]]) + " " + (className || "")
|
|
14
|
+
}, placeholder, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
15
|
+
id: "1027033961",
|
|
16
|
+
dynamic: [colors.grey600]
|
|
17
|
+
}, [`div.__jsx-style-dynamic-selector{color:${colors.grey600};-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}`]));
|
|
18
|
+
}
|
|
19
|
+
Placeholder.propTypes = {
|
|
20
|
+
dataTest: PropTypes.string.isRequired,
|
|
21
|
+
className: PropTypes.string,
|
|
22
|
+
placeholder: PropTypes.string
|
|
23
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
import { colors, spacers } from '@dhis2/ui-constants';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
export function Prefix(_ref) {
|
|
6
|
+
let {
|
|
7
|
+
prefix,
|
|
8
|
+
className,
|
|
9
|
+
dataTest
|
|
10
|
+
} = _ref;
|
|
11
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
12
|
+
"data-test": dataTest,
|
|
13
|
+
className: _JSXStyle.dynamic([["1343055987", [colors.grey600, spacers.dp12]]]) + " " + (className || "")
|
|
14
|
+
}, prefix, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
15
|
+
id: "1343055987",
|
|
16
|
+
dynamic: [colors.grey600, spacers.dp12]
|
|
17
|
+
}, [`div.__jsx-style-dynamic-selector{color:${colors.grey600};padding-inline-end:${spacers.dp12};font-size:14px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}`]));
|
|
18
|
+
}
|
|
19
|
+
Prefix.propTypes = {
|
|
20
|
+
dataTest: PropTypes.string.isRequired,
|
|
21
|
+
className: PropTypes.string,
|
|
22
|
+
prefix: PropTypes.string
|
|
23
|
+
};
|