@dhis2-ui/select 10.16.3-alpha.1 → 10.16.4
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/locales/index.js +94 -57
- package/build/cjs/multi-select/features/menu_width_matches_input/index.js +2 -4
- package/build/cjs/multi-select/features/position/index.js +6 -12
- package/build/cjs/multi-select/filterable-menu.js +22 -25
- package/build/cjs/multi-select/input.js +14 -15
- package/build/cjs/multi-select/menu.js +24 -28
- package/build/cjs/multi-select/multi-select.e2e.stories.js +21 -32
- package/build/cjs/multi-select/multi-select.js +30 -31
- package/build/cjs/multi-select/multi-select.prod.stories.js +13 -21
- package/build/cjs/multi-select/selection-list.js +51 -57
- package/build/cjs/multi-select-option/multi-select-option.js +27 -30
- package/build/cjs/select/debounce/debounce.js +2 -6
- package/build/cjs/select/empty.js +11 -14
- package/build/cjs/select/filter-input.js +21 -24
- package/build/cjs/select/filterable-menu.js +6 -8
- package/build/cjs/select/input-clear-button.js +28 -31
- package/build/cjs/select/input-placeholder.js +5 -6
- package/build/cjs/select/input-prefix.js +5 -6
- package/build/cjs/select/input-wrapper.js +13 -14
- package/build/cjs/select/loading.js +15 -18
- package/build/cjs/select/menu-wrapper.js +8 -9
- package/build/cjs/select/no-match.js +9 -12
- package/build/cjs/select/select.js +3 -4
- package/build/cjs/simple-single-select/__stories__/DefaultPosition.js +1 -2
- package/build/cjs/simple-single-select/__stories__/Dense.js +1 -2
- package/build/cjs/simple-single-select/__stories__/Empty.js +1 -2
- package/build/cjs/simple-single-select/__stories__/EmptyWithEmptyNode.js +1 -2
- package/build/cjs/simple-single-select/__stories__/EmptyWithEmptyText.js +1 -2
- package/build/cjs/simple-single-select/__stories__/FlippedPosition.js +1 -2
- package/build/cjs/simple-single-select/__stories__/InfiniteLoading.js +1 -2
- package/build/cjs/simple-single-select/__stories__/ShiftedIntoView.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithClearButton.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithCustomLowMaxHeight.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithCustomOptions.js +17 -21
- package/build/cjs/simple-single-select/__stories__/WithDisabledOption.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithFilterField.js +5 -9
- package/build/cjs/simple-single-select/__stories__/WithInitialFocus.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithManyOptions.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithMultipleSelectsAndScrollableParent.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithNoMatchText.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithOnBlur.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithOnFocus.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithOptionsAndDisabled.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithOptionsAndLoading.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithOptionsAndLoadingText.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithPlaceholder.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithPlaceholderAndSelection.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithPrefix.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithPrefixAndSelection.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithRTL.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithScrollingParent.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithSelection.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithSelectionAndDisabled.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithServerSideFilteringDemo.js +25 -36
- package/build/cjs/simple-single-select/__stories__/WithSimpleFilteringDemo.js +4 -6
- package/build/cjs/simple-single-select/__stories__/WithoutOptionsAndLoading.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithoutSelection.js +1 -2
- package/build/cjs/simple-single-select/__stories__/simple-single-select-server-side-filtering/CustomDataProvider.js +19 -26
- package/build/cjs/simple-single-select/features/keyboard-interactions.test.e2e.js +9 -18
- package/build/cjs/simple-single-select/features/menu-positioning.test.e2e.js +8 -16
- package/build/cjs/simple-single-select/menu/empty.js +8 -11
- package/build/cjs/simple-single-select/menu/filter.js +11 -12
- package/build/cjs/simple-single-select/menu/loading.js +3 -4
- package/build/cjs/simple-single-select/menu/menu.js +26 -28
- package/build/cjs/simple-single-select/menu/no-match.js +9 -12
- package/build/cjs/simple-single-select/menu/option.js +20 -23
- package/build/cjs/simple-single-select/menu/options-list.js +23 -26
- package/build/cjs/simple-single-select/selected-value/clear-button.js +5 -6
- package/build/cjs/simple-single-select/selected-value/container.js +23 -25
- package/build/cjs/simple-single-select/selected-value/placeholder.js +5 -6
- package/build/cjs/simple-single-select/selected-value/prefix.js +5 -6
- package/build/cjs/simple-single-select/selected-value/selected-value.js +34 -35
- package/build/cjs/simple-single-select/simple-single-select.e2e.stories.js +1 -2
- package/build/cjs/simple-single-select/simple-single-select.js +47 -50
- package/build/cjs/simple-single-select/simple-single-select.test.js +14 -24
- package/build/cjs/simple-single-select/use-handle-key-press/use-focus-option.js +5 -6
- package/build/cjs/simple-single-select/use-handle-key-press/use-handle-key-press-on-combobox.js +31 -34
- package/build/cjs/simple-single-select/use-handle-key-press/use-handle-key-press-on-filter-input.js +11 -12
- package/build/cjs/simple-single-select/use-handle-key-press/use-handle-typing.js +10 -14
- package/build/cjs/simple-single-select/use-handle-key-press/use-highlight-first-option-on-previous-page.js +6 -7
- package/build/cjs/simple-single-select/use-handle-key-press/use-highlight-first-visible-option.js +5 -6
- package/build/cjs/simple-single-select/use-handle-key-press/use-highlight-last-option-on-next-page.js +6 -7
- package/build/cjs/simple-single-select/use-handle-key-press/use-highlight-last-visible-option.js +5 -6
- package/build/cjs/simple-single-select/use-handle-key-press/use-page-down.js +6 -7
- package/build/cjs/simple-single-select/use-handle-key-press/use-page-up.js +6 -7
- package/build/cjs/simple-single-select/use-handle-key-press/utils.js +17 -22
- package/build/cjs/simple-single-select-field/simple-single-select-field.js +3 -6
- package/build/cjs/simple-single-select-field/simple-single-select-field.prod.stories.js +1 -2
- package/build/cjs/simple-single-select-field/simple-single-select-field.test.js +3 -6
- package/build/cjs/single-select/features/menu_width_matches_input/index.js +2 -4
- package/build/cjs/single-select/features/position/index.js +4 -8
- package/build/cjs/single-select/filterable-menu.js +22 -25
- package/build/cjs/single-select/input.js +13 -14
- package/build/cjs/single-select/menu.js +9 -10
- package/build/cjs/single-select/selection.js +5 -6
- package/build/cjs/single-select/single-select.e2e.stories.js +18 -28
- package/build/cjs/single-select/single-select.js +29 -30
- package/build/cjs/single-select/single-select.prod.stories.js +7 -11
- package/build/cjs/single-select-option/single-select-option.js +25 -28
- package/build/es/locales/index.js +70 -33
- package/build/es/multi-select/features/menu_width_matches_input/index.js +2 -4
- package/build/es/multi-select/features/position/index.js +6 -12
- package/build/es/multi-select/filterable-menu.js +22 -25
- package/build/es/multi-select/input.js +14 -15
- package/build/es/multi-select/menu.js +24 -28
- package/build/es/multi-select/multi-select.e2e.stories.js +20 -30
- package/build/es/multi-select/multi-select.js +30 -31
- package/build/es/multi-select/multi-select.prod.stories.js +12 -19
- package/build/es/multi-select/selection-list.js +51 -57
- package/build/es/multi-select-option/multi-select-option.js +27 -30
- package/build/es/select/debounce/debounce.js +2 -6
- package/build/es/select/empty.js +11 -14
- package/build/es/select/filter-input.js +21 -24
- package/build/es/select/filterable-menu.js +5 -6
- package/build/es/select/input-clear-button.js +28 -31
- package/build/es/select/input-placeholder.js +5 -6
- package/build/es/select/input-prefix.js +5 -6
- package/build/es/select/input-wrapper.js +13 -14
- package/build/es/select/loading.js +15 -18
- package/build/es/select/menu-wrapper.js +8 -9
- package/build/es/select/no-match.js +9 -12
- package/build/es/select/select.js +2 -2
- package/build/es/simple-single-select/__stories__/WithCustomOptions.js +16 -19
- package/build/es/simple-single-select/__stories__/WithFilterField.js +4 -7
- package/build/es/simple-single-select/__stories__/WithServerSideFilteringDemo.js +24 -34
- package/build/es/simple-single-select/__stories__/WithSimpleFilteringDemo.js +3 -4
- package/build/es/simple-single-select/__stories__/simple-single-select-server-side-filtering/CustomDataProvider.js +19 -26
- package/build/es/simple-single-select/features/keyboard-interactions.test.e2e.js +9 -18
- package/build/es/simple-single-select/features/menu-positioning.test.e2e.js +8 -16
- package/build/es/simple-single-select/menu/empty.js +8 -11
- package/build/es/simple-single-select/menu/filter.js +11 -12
- package/build/es/simple-single-select/menu/loading.js +3 -4
- package/build/es/simple-single-select/menu/menu.js +25 -26
- package/build/es/simple-single-select/menu/no-match.js +9 -12
- package/build/es/simple-single-select/menu/option.js +19 -21
- package/build/es/simple-single-select/menu/options-list.js +22 -24
- package/build/es/simple-single-select/selected-value/clear-button.js +5 -6
- package/build/es/simple-single-select/selected-value/container.js +22 -23
- package/build/es/simple-single-select/selected-value/placeholder.js +5 -6
- package/build/es/simple-single-select/selected-value/prefix.js +5 -6
- package/build/es/simple-single-select/selected-value/selected-value.js +34 -35
- package/build/es/simple-single-select/simple-single-select.js +46 -48
- package/build/es/simple-single-select/simple-single-select.test.js +13 -22
- package/build/es/simple-single-select/use-handle-key-press/use-focus-option.js +5 -6
- package/build/es/simple-single-select/use-handle-key-press/use-handle-key-press-on-combobox.js +31 -34
- package/build/es/simple-single-select/use-handle-key-press/use-handle-key-press-on-filter-input.js +11 -12
- package/build/es/simple-single-select/use-handle-key-press/use-handle-typing.js +10 -14
- package/build/es/simple-single-select/use-handle-key-press/use-highlight-first-option-on-previous-page.js +6 -7
- package/build/es/simple-single-select/use-handle-key-press/use-highlight-first-visible-option.js +5 -6
- package/build/es/simple-single-select/use-handle-key-press/use-highlight-last-option-on-next-page.js +6 -7
- package/build/es/simple-single-select/use-handle-key-press/use-highlight-last-visible-option.js +5 -6
- package/build/es/simple-single-select/use-handle-key-press/use-page-down.js +6 -7
- package/build/es/simple-single-select/use-handle-key-press/use-page-up.js +6 -7
- package/build/es/simple-single-select/use-handle-key-press/utils.js +17 -22
- package/build/es/simple-single-select-field/simple-single-select-field.js +3 -6
- package/build/es/simple-single-select-field/simple-single-select-field.test.js +3 -6
- package/build/es/single-select/features/menu_width_matches_input/index.js +2 -4
- package/build/es/single-select/features/position/index.js +4 -8
- package/build/es/single-select/filterable-menu.js +22 -25
- package/build/es/single-select/input.js +13 -14
- package/build/es/single-select/menu.js +9 -10
- package/build/es/single-select/selection.js +5 -6
- package/build/es/single-select/single-select.e2e.stories.js +17 -26
- package/build/es/single-select/single-select.js +29 -30
- package/build/es/single-select/single-select.prod.stories.js +6 -9
- package/build/es/single-select-option/single-select-option.js +25 -28
- package/package.json +15 -15
- package/src/locales/index.js +102 -33
|
@@ -2,67 +2,61 @@ import { Chip } from '@dhis2-ui/chip';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { removeOption, findOptionChild } from '../select/index.js';
|
|
5
|
-
const createRemoveHandler =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const data = {
|
|
14
|
-
selected: filtered
|
|
15
|
-
};
|
|
16
|
-
onChange(data, e);
|
|
5
|
+
const createRemoveHandler = ({
|
|
6
|
+
selected,
|
|
7
|
+
onChange,
|
|
8
|
+
value
|
|
9
|
+
}) => (_, e) => {
|
|
10
|
+
const filtered = removeOption(value, selected);
|
|
11
|
+
const data = {
|
|
12
|
+
selected: filtered
|
|
17
13
|
};
|
|
14
|
+
onChange(data, e);
|
|
18
15
|
};
|
|
19
|
-
const SelectionList =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// Throw error if not in production for maximum visibility
|
|
36
|
-
throw new Error(message);
|
|
37
|
-
}
|
|
16
|
+
const SelectionList = ({
|
|
17
|
+
selected,
|
|
18
|
+
onChange,
|
|
19
|
+
disabled,
|
|
20
|
+
options
|
|
21
|
+
}) => /*#__PURE__*/React.createElement(React.Fragment, null, selected.map(value => {
|
|
22
|
+
const isProduction = process.env.NODE_ENV === 'production';
|
|
23
|
+
const selectedOption = findOptionChild(value, options);
|
|
24
|
+
if (!selectedOption) {
|
|
25
|
+
const message = `There is no option with the value: "${value}". ` + 'Make sure that all the values passed to the selected ' + 'prop match the value of an existing option.';
|
|
26
|
+
if (isProduction) {
|
|
27
|
+
// Don't crash the app if in production
|
|
28
|
+
console.error(message);
|
|
29
|
+
} else {
|
|
30
|
+
// Throw error if not in production for maximum visibility
|
|
31
|
+
throw new Error(message);
|
|
38
32
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
33
|
+
}
|
|
34
|
+
const isDisabled = selectedOption ?
|
|
35
|
+
// The chip should be disabled if the option or the select are disabled
|
|
36
|
+
selectedOption.props.disabled || disabled :
|
|
37
|
+
// If there is no selected option, just look at the select
|
|
38
|
+
disabled;
|
|
39
|
+
// Use the selected value if we do not have a label
|
|
40
|
+
const label = selectedOption ? selectedOption.props.label : value;
|
|
46
41
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
};
|
|
42
|
+
// Create an onRemove handler, but only if it's not disabled
|
|
43
|
+
const onRemove = isDisabled ? undefined : createRemoveHandler({
|
|
44
|
+
selected,
|
|
45
|
+
onChange,
|
|
46
|
+
value
|
|
47
|
+
});
|
|
48
|
+
return /*#__PURE__*/React.createElement(Chip, {
|
|
49
|
+
key: value,
|
|
50
|
+
onRemove: onRemove,
|
|
51
|
+
disabled: isDisabled,
|
|
52
|
+
marginBottom: 0,
|
|
53
|
+
marginLeft: 0,
|
|
54
|
+
marginTop: 0,
|
|
55
|
+
marginRight: 0,
|
|
56
|
+
overflow: true,
|
|
57
|
+
dense: true
|
|
58
|
+
}, label);
|
|
59
|
+
}));
|
|
66
60
|
SelectionList.propTypes = {
|
|
67
61
|
disabled: PropTypes.bool,
|
|
68
62
|
options: PropTypes.node,
|
|
@@ -14,37 +14,34 @@ const {
|
|
|
14
14
|
}, [`.jsx-2013783366{padding:${spacers.dp8} ${spacers.dp12};}`]),
|
|
15
15
|
className: "jsx-2013783366"
|
|
16
16
|
};
|
|
17
|
-
const MultiSelectOption =
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const MultiSelectOption = ({
|
|
18
|
+
label,
|
|
19
|
+
active,
|
|
20
|
+
disabled,
|
|
21
|
+
onClick,
|
|
22
|
+
className,
|
|
23
|
+
dataTest = 'dhis2-uicore-multiselectoption',
|
|
24
|
+
value
|
|
25
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
26
|
+
"data-test": dataTest,
|
|
27
|
+
"data-value": value,
|
|
28
|
+
"data-label": label,
|
|
29
|
+
className: _JSXStyle.dynamic([["2722881483", [colors.grey200, colors.teal050]]]) + " " + (cx(className, {
|
|
20
30
|
active,
|
|
21
|
-
disabled
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}, /*#__PURE__*/React.createElement(Checkbox, {
|
|
36
|
-
name: label,
|
|
37
|
-
className: checkboxClassname,
|
|
38
|
-
checked: active,
|
|
39
|
-
label: label,
|
|
40
|
-
onChange: onClick,
|
|
41
|
-
disabled: disabled,
|
|
42
|
-
dense: true
|
|
43
|
-
}), styles, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
44
|
-
id: "2722881483",
|
|
45
|
-
dynamic: [colors.grey200, colors.teal050]
|
|
46
|
-
}, [`div.__jsx-style-dynamic-selector:hover{background-color:${colors.grey200};}`, `div.active.__jsx-style-dynamic-selector{background-color:${colors.teal050};}`, "div.active.__jsx-style-dynamic-selector:hover{background-color:#e6f4f4;}", "div.disabled.__jsx-style-dynamic-selector:hover{background-color:initial;}"]));
|
|
47
|
-
};
|
|
31
|
+
disabled
|
|
32
|
+
}) || "")
|
|
33
|
+
}, /*#__PURE__*/React.createElement(Checkbox, {
|
|
34
|
+
name: label,
|
|
35
|
+
className: checkboxClassname,
|
|
36
|
+
checked: active,
|
|
37
|
+
label: label,
|
|
38
|
+
onChange: onClick,
|
|
39
|
+
disabled: disabled,
|
|
40
|
+
dense: true
|
|
41
|
+
}), styles, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
42
|
+
id: "2722881483",
|
|
43
|
+
dynamic: [colors.grey200, colors.teal050]
|
|
44
|
+
}, [`div.__jsx-style-dynamic-selector:hover{background-color:${colors.grey200};}`, `div.active.__jsx-style-dynamic-selector{background-color:${colors.teal050};}`, "div.active.__jsx-style-dynamic-selector:hover{background-color:#e6f4f4;}", "div.disabled.__jsx-style-dynamic-selector:hover{background-color:initial;}"]));
|
|
48
45
|
MultiSelectOption.propTypes = {
|
|
49
46
|
label: PropTypes.string.isRequired,
|
|
50
47
|
value: PropTypes.string.isRequired,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
var _this = this;
|
|
2
1
|
/**
|
|
3
2
|
* Returns a function, that, as long as it continues to be invoked, will not be triggered. The
|
|
4
3
|
* function will be called after it stops being called for N milliseconds. If `immediate` is
|
|
@@ -7,11 +6,8 @@ var _this = this;
|
|
|
7
6
|
|
|
8
7
|
export const debounce = (func, wait, immediate) => {
|
|
9
8
|
let timeout;
|
|
10
|
-
return
|
|
11
|
-
|
|
12
|
-
args[_key] = arguments[_key];
|
|
13
|
-
}
|
|
14
|
-
const context = _this;
|
|
9
|
+
return (...args) => {
|
|
10
|
+
const context = this;
|
|
15
11
|
const later = () => {
|
|
16
12
|
timeout = null;
|
|
17
13
|
if (!immediate) {
|
package/build/es/select/empty.js
CHANGED
|
@@ -2,20 +2,17 @@ import _JSXStyle from "styled-jsx/style";
|
|
|
2
2
|
import { colors, spacers, theme } from '@dhis2/ui-constants';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
const Empty =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
dynamic: [colors.grey700, theme.fonts, spacers.dp8, spacers.dp24]
|
|
17
|
-
}, [`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;}`]));
|
|
18
|
-
};
|
|
5
|
+
const Empty = ({
|
|
6
|
+
message,
|
|
7
|
+
className,
|
|
8
|
+
dataTest
|
|
9
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
10
|
+
"data-test": dataTest,
|
|
11
|
+
className: _JSXStyle.dynamic([["3788156646", [colors.grey700, theme.fonts, spacers.dp8, spacers.dp24]]]) + " " + (className || "")
|
|
12
|
+
}, message, /*#__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;}`]));
|
|
19
16
|
Empty.propTypes = {
|
|
20
17
|
dataTest: PropTypes.string.isRequired,
|
|
21
18
|
message: PropTypes.string.isRequired,
|
|
@@ -3,30 +3,27 @@ import { spacers, colors } from '@dhis2/ui-constants';
|
|
|
3
3
|
import { Input } from '@dhis2-ui/input';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import React from 'react';
|
|
6
|
-
const FilterInput =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
dynamic: [colors.white, spacers.dp8, spacers.dp8, spacers.dp4, spacers.dp8]
|
|
28
|
-
}, [`div.__jsx-style-dynamic-selector{position:-webkit-sticky;position:sticky;-webkit-inset-block-start:0;-ms-intb-rlock-start:0;inset-block-start:0;background:${colors.white};padding-block-start:${spacers.dp8};padding-inline-end:${spacers.dp8};padding-block-end:${spacers.dp4};padding-inline-start:${spacers.dp8};z-index:1;}`]));
|
|
29
|
-
};
|
|
6
|
+
const FilterInput = ({
|
|
7
|
+
value,
|
|
8
|
+
onChange,
|
|
9
|
+
placeholder,
|
|
10
|
+
className,
|
|
11
|
+
dataTest
|
|
12
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
13
|
+
className: _JSXStyle.dynamic([["730881408", [colors.white, spacers.dp8, spacers.dp8, spacers.dp4, spacers.dp8]]]) + " " + (className || "")
|
|
14
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
15
|
+
dense: true,
|
|
16
|
+
dataTest: dataTest,
|
|
17
|
+
value: value,
|
|
18
|
+
onChange: onChange,
|
|
19
|
+
type: "text",
|
|
20
|
+
name: "filter",
|
|
21
|
+
placeholder: placeholder,
|
|
22
|
+
initialFocus: true
|
|
23
|
+
}), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
24
|
+
id: "730881408",
|
|
25
|
+
dynamic: [colors.white, spacers.dp8, spacers.dp8, spacers.dp4, spacers.dp8]
|
|
26
|
+
}, [`div.__jsx-style-dynamic-selector{position:-webkit-sticky;position:sticky;-webkit-inset-block-start:0;-ms-intb-rlock-start:0;inset-block-start:0;background:${colors.white};padding-block-start:${spacers.dp8};padding-inline-end:${spacers.dp8};padding-block-end:${spacers.dp4};padding-inline-start:${spacers.dp8};z-index:1;}`]));
|
|
30
27
|
FilterInput.propTypes = {
|
|
31
28
|
dataTest: PropTypes.string.isRequired,
|
|
32
29
|
value: PropTypes.string.isRequired,
|
|
@@ -8,15 +8,14 @@ import { FilterInput } from './filter-input.js';
|
|
|
8
8
|
import { NoMatch } from './no-match.js';
|
|
9
9
|
import { filterIgnored, checkIfValidOption } from './option-helpers.js';
|
|
10
10
|
export class FilterableMenu extends Component {
|
|
11
|
-
constructor() {
|
|
12
|
-
super(...
|
|
11
|
+
constructor(...args) {
|
|
12
|
+
super(...args);
|
|
13
13
|
_defineProperty(this, "state", {
|
|
14
14
|
filter: ''
|
|
15
15
|
});
|
|
16
|
-
_defineProperty(this, "onFilterChange",
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} = _ref;
|
|
16
|
+
_defineProperty(this, "onFilterChange", ({
|
|
17
|
+
value
|
|
18
|
+
}) => {
|
|
20
19
|
this.setState({
|
|
21
20
|
filter: value
|
|
22
21
|
});
|
|
@@ -3,37 +3,34 @@ import { colors, theme } from '@dhis2/ui-constants';
|
|
|
3
3
|
import { Tooltip } from '@dhis2-ui/tooltip';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import React from 'react';
|
|
6
|
-
const InputClearButton =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
dynamic: [colors.grey500, colors.grey800, colors.grey200, theme.focus]
|
|
35
|
-
}, ["button.__jsx-style-dynamic-selector{background:none;border:none;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;-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{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;}", `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};}`])));
|
|
36
|
-
};
|
|
6
|
+
const InputClearButton = ({
|
|
7
|
+
onClear,
|
|
8
|
+
clearText,
|
|
9
|
+
className,
|
|
10
|
+
dataTest
|
|
11
|
+
}) => /*#__PURE__*/React.createElement(Tooltip, {
|
|
12
|
+
openDelay: 500,
|
|
13
|
+
content: clearText
|
|
14
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
15
|
+
"data-test": dataTest,
|
|
16
|
+
onClick: onClear,
|
|
17
|
+
type: "button",
|
|
18
|
+
className: _JSXStyle.dynamic([["2859518049", [colors.grey500, colors.grey800, colors.grey200, theme.focus]]]) + " " + (className || "")
|
|
19
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
20
|
+
width: "16",
|
|
21
|
+
height: "16",
|
|
22
|
+
viewBox: "0 0 16 16",
|
|
23
|
+
fill: "none",
|
|
24
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
25
|
+
className: _JSXStyle.dynamic([["2859518049", [colors.grey500, colors.grey800, colors.grey200, theme.focus]]])
|
|
26
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
27
|
+
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",
|
|
28
|
+
fill: "none",
|
|
29
|
+
className: _JSXStyle.dynamic([["2859518049", [colors.grey500, colors.grey800, colors.grey200, theme.focus]]])
|
|
30
|
+
})), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
31
|
+
id: "2859518049",
|
|
32
|
+
dynamic: [colors.grey500, colors.grey800, colors.grey200, theme.focus]
|
|
33
|
+
}, ["button.__jsx-style-dynamic-selector{background:none;border:none;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;-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{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;}", `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};}`])));
|
|
37
34
|
InputClearButton.propTypes = {
|
|
38
35
|
clearText: PropTypes.string.isRequired,
|
|
39
36
|
dataTest: PropTypes.string.isRequired,
|
|
@@ -2,12 +2,11 @@ import _JSXStyle from "styled-jsx/style";
|
|
|
2
2
|
import { colors } from '@dhis2/ui-constants';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
const InputPlaceholder =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} = _ref;
|
|
5
|
+
const InputPlaceholder = ({
|
|
6
|
+
placeholder,
|
|
7
|
+
className,
|
|
8
|
+
dataTest
|
|
9
|
+
}) => {
|
|
11
10
|
if (!placeholder) {
|
|
12
11
|
return null;
|
|
13
12
|
}
|
|
@@ -2,12 +2,11 @@ import _JSXStyle from "styled-jsx/style";
|
|
|
2
2
|
import { colors, spacers } from '@dhis2/ui-constants';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
const InputPrefix =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} = _ref;
|
|
5
|
+
const InputPrefix = ({
|
|
6
|
+
prefix,
|
|
7
|
+
className,
|
|
8
|
+
dataTest
|
|
9
|
+
}) => {
|
|
11
10
|
if (!prefix) {
|
|
12
11
|
return null;
|
|
13
12
|
}
|
|
@@ -4,20 +4,19 @@ import { IconChevronDown16 } from '@dhis2/ui-icons';
|
|
|
4
4
|
import cx from 'classnames';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import React from 'react';
|
|
7
|
-
const InputWrapper =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} = _ref;
|
|
7
|
+
const InputWrapper = ({
|
|
8
|
+
dataTest,
|
|
9
|
+
onToggle,
|
|
10
|
+
children,
|
|
11
|
+
tabIndex = '0',
|
|
12
|
+
error,
|
|
13
|
+
warning,
|
|
14
|
+
valid,
|
|
15
|
+
disabled,
|
|
16
|
+
dense,
|
|
17
|
+
className,
|
|
18
|
+
inputRef
|
|
19
|
+
}) => {
|
|
21
20
|
const classNames = cx(className, 'root', {
|
|
22
21
|
error,
|
|
23
22
|
warning,
|
|
@@ -4,24 +4,21 @@ import { CircularLoader } from '@dhis2-ui/loader';
|
|
|
4
4
|
import cx from 'classnames';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import React from 'react';
|
|
7
|
-
export const Loading =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
dynamic: [spacers.dp16, colors.grey700, theme.fonts, spacers.dp8, spacers.dp24]
|
|
23
|
-
}, [`.container.__jsx-style-dynamic-selector{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};}`]));
|
|
24
|
-
};
|
|
7
|
+
export const Loading = ({
|
|
8
|
+
message,
|
|
9
|
+
className,
|
|
10
|
+
dataTest
|
|
11
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
12
|
+
"data-test": dataTest,
|
|
13
|
+
className: _JSXStyle.dynamic([["3603755746", [spacers.dp16, colors.grey700, theme.fonts, spacers.dp8, spacers.dp24]]]) + " " + (cx(className, 'container') || "")
|
|
14
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
15
|
+
className: _JSXStyle.dynamic([["3603755746", [spacers.dp16, colors.grey700, theme.fonts, spacers.dp8, spacers.dp24]]])
|
|
16
|
+
}, /*#__PURE__*/React.createElement(CircularLoader, {
|
|
17
|
+
small: true
|
|
18
|
+
})), message, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
19
|
+
id: "3603755746",
|
|
20
|
+
dynamic: [spacers.dp16, colors.grey700, theme.fonts, spacers.dp8, spacers.dp24]
|
|
21
|
+
}, [`.container.__jsx-style-dynamic-selector{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};}`]));
|
|
25
22
|
Loading.propTypes = {
|
|
26
23
|
dataTest: PropTypes.string.isRequired,
|
|
27
24
|
className: PropTypes.string,
|
|
@@ -4,15 +4,14 @@ import { Layer } from '@dhis2-ui/layer';
|
|
|
4
4
|
import { Popper } from '@dhis2-ui/popper';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import React from 'react';
|
|
7
|
-
const MenuWrapper =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} = _ref;
|
|
7
|
+
const MenuWrapper = ({
|
|
8
|
+
children,
|
|
9
|
+
dataTest,
|
|
10
|
+
maxHeight = '280px',
|
|
11
|
+
menuWidth,
|
|
12
|
+
onClick,
|
|
13
|
+
selectRef
|
|
14
|
+
}) => {
|
|
16
15
|
return /*#__PURE__*/React.createElement(Layer, {
|
|
17
16
|
onBackdropClick: onClick,
|
|
18
17
|
transparent: true
|
|
@@ -2,18 +2,15 @@ import _JSXStyle from "styled-jsx/style";
|
|
|
2
2
|
import { colors, spacers, theme } from '@dhis2/ui-constants';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
const NoMatch =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
};
|
|
5
|
+
const NoMatch = ({
|
|
6
|
+
message,
|
|
7
|
+
className
|
|
8
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
9
|
+
className: _JSXStyle.dynamic([["3788156646", [colors.grey700, theme.fonts, spacers.dp8, spacers.dp24]]]) + " " + (className || "")
|
|
10
|
+
}, message, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
11
|
+
id: "3788156646",
|
|
12
|
+
dynamic: [colors.grey700, theme.fonts, spacers.dp8, spacers.dp24]
|
|
13
|
+
}, [`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;}`]));
|
|
17
14
|
NoMatch.propTypes = {
|
|
18
15
|
message: PropTypes.string.isRequired,
|
|
19
16
|
className: PropTypes.string
|
|
@@ -15,8 +15,8 @@ const SPACE_KEY = 32;
|
|
|
15
15
|
const UP_KEY = 38;
|
|
16
16
|
const DOWN_KEY = 40;
|
|
17
17
|
export class Select extends Component {
|
|
18
|
-
constructor() {
|
|
19
|
-
super(...
|
|
18
|
+
constructor(...args) {
|
|
19
|
+
super(...args);
|
|
20
20
|
_defineProperty(this, "state", {
|
|
21
21
|
open: false,
|
|
22
22
|
menuWidth: 'auto'
|
|
@@ -2,25 +2,22 @@ import _JSXStyle from "styled-jsx/style";
|
|
|
2
2
|
import React, { useState, useMemo } from 'react';
|
|
3
3
|
import { SimpleSingleSelect } from '../simple-single-select.js';
|
|
4
4
|
import { options } from './options.js';
|
|
5
|
-
const CustomOption =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
id: "3497546720"
|
|
22
|
-
}, [".container.jsx-3497546720{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;color:white;cursor:pointer;height:30px;}", ".label.jsx-3497546720{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;background:green;padding:5px 10px;}", ".label.jsx-3497546720:hover{background:blue;}", ".button.jsx-3497546720{height:30px;width:30px;padding:0;border:0;background:none;background:white;cursor:pointer;font-size:20px;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;color:black;}", ".button.jsx-3497546720:hover{background:black;color:white;}"]));
|
|
23
|
-
};
|
|
5
|
+
const CustomOption = ({
|
|
6
|
+
label
|
|
7
|
+
}) => /*#__PURE__*/React.createElement("span", {
|
|
8
|
+
className: "jsx-3497546720" + " " + "container"
|
|
9
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
10
|
+
className: "jsx-3497546720" + " " + "label"
|
|
11
|
+
}, label), /*#__PURE__*/React.createElement("span", {
|
|
12
|
+
role: "button",
|
|
13
|
+
onClick: e => {
|
|
14
|
+
e.stopPropagation();
|
|
15
|
+
alert('Custom "button" clicked!');
|
|
16
|
+
},
|
|
17
|
+
className: "jsx-3497546720" + " " + "button"
|
|
18
|
+
}, "x"), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
19
|
+
id: "3497546720"
|
|
20
|
+
}, [".container.jsx-3497546720{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;color:white;cursor:pointer;height:30px;}", ".label.jsx-3497546720{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;background:green;padding:5px 10px;}", ".label.jsx-3497546720:hover{background:blue;}", ".button.jsx-3497546720{height:30px;width:30px;padding:0;border:0;background:none;background:white;cursor:pointer;font-size:20px;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;color:black;}", ".button.jsx-3497546720:hover{background:black;color:white;}"]));
|
|
24
21
|
export const WithCustomOptions = () => {
|
|
25
22
|
const [selected, setSelected] = useState(null);
|
|
26
23
|
const optionsWithCustomStyle = useMemo(() => {
|
|
@@ -5,13 +5,10 @@ export const WithFilterField = () => {
|
|
|
5
5
|
const [selected, setSelected] = useState(null);
|
|
6
6
|
const [filterValue, setFilterValue] = useState('');
|
|
7
7
|
const filteredOptions = useMemo(() => {
|
|
8
|
-
return filterValue ? options.filter(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} = _ref;
|
|
13
|
-
return label.match(new RegExp(filterValue), 'i') && value !== '';
|
|
14
|
-
}) : options;
|
|
8
|
+
return filterValue ? options.filter(({
|
|
9
|
+
label,
|
|
10
|
+
value
|
|
11
|
+
}) => label.match(new RegExp(filterValue), 'i') && value !== '') : options;
|
|
15
12
|
}, [filterValue]);
|
|
16
13
|
return /*#__PURE__*/React.createElement(SimpleSingleSelect, {
|
|
17
14
|
name: "simple",
|