colibri-ui 0.8.84 → 0.8.86
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/Accordion/Accordion.module.css +4 -0
- package/Accordion/index.js +15 -23
- package/Autocomplete/Autocomplete.js +101 -132
- package/Avatar/Avatar.module.css +6 -0
- package/Avatar/index.js +102 -89
- package/Badge/Badge.module.css +2 -1
- package/Badge/Control/index.js +5 -3
- package/Badge/index.js +16 -16
- package/Button/index.js +23 -20
- package/Button/tokens.js +2 -2
- package/Calendar/Calendar.js +171 -269
- package/Card/Card.js +26 -32
- package/Checkbox/index.js +46 -43
- package/Chip/Chip.module.css +2 -1
- package/Chip/index.js +15 -15
- package/ClickOutside/index.js +10 -13
- package/CodeField/CodeField.js +113 -170
- package/Counter/Counter.module.css +2 -1
- package/Counter/index.js +21 -20
- package/Datepicker/components/DatePicker/index.js +81 -102
- package/Datepicker/index.js +17 -16
- package/DotsLoader/index.js +23 -15
- package/Drawer/Drawer.js +75 -97
- package/Drawer/Drawer.module.css +2 -1
- package/Dropdown/index.js +55 -68
- package/Dropzone/Dropzone.js +78 -168
- package/Dropzone/Dropzone.module.css +2 -1
- package/Editable/Editable.js +44 -57
- package/Grid/Item/index.js +11 -13
- package/Grid/index.js +15 -21
- package/Icons/ArrowNext.js +7 -8
- package/Icons/Cart.js +7 -8
- package/Icons/Check.js +7 -8
- package/Icons/Chevron.js +7 -8
- package/Icons/Close.js +6 -6
- package/Icons/Copy.js +7 -8
- package/Icons/Cross.js +6 -6
- package/Icons/CrossFill.js +7 -8
- package/Icons/Edit.js +7 -8
- package/Icons/Exit.js +7 -8
- package/Icons/EyeClosed.js +7 -8
- package/Icons/EyeOpen.js +7 -8
- package/Icons/Help.js +6 -6
- package/Icons/Info.js +7 -8
- package/Icons/Minus.js +7 -8
- package/Icons/More.js +7 -8
- package/Icons/Plus.js +7 -8
- package/Icons/Setting.js +7 -8
- package/Icons/Shield.js +7 -8
- package/Icons/Trash.js +7 -8
- package/Icons/User.js +7 -8
- package/Image/Image.module.css +4 -0
- package/Image/index.d.ts +1 -1
- package/Image/index.js +44 -37
- package/Input/index.d.ts +1 -1
- package/Input/index.js +37 -25
- package/Input/index.props.d.ts +1 -1
- package/InputRadio/index.js +32 -24
- package/List/List.js +81 -76
- package/Menu/Menu.module.css +2 -1
- package/Menu/components/MenuItem/index.js +17 -14
- package/Menu/index.js +22 -23
- package/Modal/components/Body/index.js +9 -8
- package/Modal/components/Close/Close.module.css +4 -0
- package/Modal/components/Close/index.js +13 -14
- package/Modal/components/Content/index.js +5 -6
- package/Modal/components/Footer/index.js +5 -3
- package/Modal/components/Header/index.js +13 -12
- package/Modal/components/Title/index.js +10 -9
- package/Modal/context.js +3 -3
- package/Modal/index.js +46 -68
- package/MultiSelect/components/MenuOverlay/index.js +48 -61
- package/MultiSelect/components/MenuOverlayItem/index.js +13 -14
- package/MultiSelect/index.js +72 -100
- package/MultiSelect/index.module.css +2 -1
- package/MultiSelect/utils/index.js +8 -18
- package/NumberInput/NumberInput.js +80 -112
- package/Portal/index.js +6 -10
- package/Progress/Progress.js +45 -58
- package/RadioGroup/Radio.js +29 -32
- package/RadioGroup/index.js +43 -46
- package/Rating/Rating.js +50 -63
- package/Select/components/MenuOverlay/index.js +16 -25
- package/Select/components/MenuOverlayItem/index.js +13 -11
- package/Select/index.js +39 -48
- package/Select/index.module.css +2 -1
- package/Separator/index.js +5 -6
- package/Sheet/Sheet.js +89 -121
- package/Sheet/Sheet.module.css +4 -2
- package/Skeleton/index.js +25 -30
- package/Slider/Slider.js +83 -119
- package/Status/index.js +17 -18
- package/Switch/Switch.module.css +2 -1
- package/Switch/index.js +22 -15
- package/TabsMenu/Tab/Tab.js +14 -10
- package/TabsMenu/Tab/Tab.module.css +2 -1
- package/TabsMenu/index.js +25 -26
- package/TabsPanels/Panel/index.js +6 -4
- package/TabsPanels/index.js +13 -10
- package/TextArea/index.d.ts +1 -1
- package/TextArea/index.js +30 -19
- package/Theme/breakpoints.js +5 -11
- package/Theme/colors/theme_buenos_aires.js +14 -14
- package/Theme/colors/theme_jaipur.js +14 -14
- package/Theme/global.css +0 -1
- package/Theme/index.js +1 -1
- package/TimeSelect/Label/index.js +11 -13
- package/TimeSelect/helpers.js +23 -42
- package/TimeSelect/index.js +32 -38
- package/Tooltip/index.js +36 -42
- package/Typography/index.js +17 -13
- package/Typography/index.props.d.ts +3 -0
- package/base/BaseInput/index.js +10 -8
- package/base/FormField/index.d.ts +1 -1
- package/base/FormField/index.js +27 -22
- package/base/FormField/index.props.d.ts +4 -0
- package/base/InputRoot/index.js +27 -27
- package/esm/Accordion/Accordion.module.css +4 -0
- package/esm/Accordion/index.js +15 -21
- package/esm/Autocomplete/Autocomplete.js +101 -130
- package/esm/Avatar/Avatar.module.css +6 -0
- package/esm/Avatar/index.js +102 -88
- package/esm/Badge/Badge.module.css +2 -1
- package/esm/Badge/Control/index.js +5 -3
- package/esm/Badge/index.js +16 -15
- package/esm/Button/index.js +23 -19
- package/esm/Button/tokens.js +2 -2
- package/esm/Calendar/Calendar.js +171 -267
- package/esm/Card/Card.js +26 -32
- package/esm/Checkbox/index.js +46 -42
- package/esm/Chip/Chip.module.css +2 -1
- package/esm/Chip/index.js +15 -14
- package/esm/ClickOutside/index.js +10 -13
- package/esm/CodeField/CodeField.js +113 -169
- package/esm/Counter/Counter.module.css +2 -1
- package/esm/Counter/index.js +21 -19
- package/esm/Datepicker/components/DatePicker/index.js +81 -101
- package/esm/Datepicker/index.js +17 -16
- package/esm/DotsLoader/index.js +23 -14
- package/esm/Drawer/Drawer.js +75 -96
- package/esm/Drawer/Drawer.module.css +2 -1
- package/esm/Dropdown/index.js +55 -66
- package/esm/Dropzone/Dropzone.js +78 -165
- package/esm/Dropzone/Dropzone.module.css +2 -1
- package/esm/Editable/Editable.js +44 -56
- package/esm/Grid/Item/index.js +11 -12
- package/esm/Grid/index.js +15 -21
- package/esm/Icons/ArrowNext.js +7 -8
- package/esm/Icons/Cart.js +7 -8
- package/esm/Icons/Check.js +7 -8
- package/esm/Icons/Chevron.js +7 -8
- package/esm/Icons/Close.js +6 -6
- package/esm/Icons/Copy.js +7 -8
- package/esm/Icons/Cross.js +6 -6
- package/esm/Icons/CrossFill.js +7 -8
- package/esm/Icons/Edit.js +7 -8
- package/esm/Icons/Exit.js +7 -8
- package/esm/Icons/EyeClosed.js +7 -8
- package/esm/Icons/EyeOpen.js +7 -8
- package/esm/Icons/Help.js +6 -6
- package/esm/Icons/Info.js +7 -8
- package/esm/Icons/Minus.js +7 -8
- package/esm/Icons/More.js +7 -8
- package/esm/Icons/Plus.js +7 -8
- package/esm/Icons/Setting.js +7 -8
- package/esm/Icons/Shield.js +7 -8
- package/esm/Icons/Trash.js +7 -8
- package/esm/Icons/User.js +7 -8
- package/esm/Image/Image.module.css +4 -0
- package/esm/Image/index.d.ts +1 -1
- package/esm/Image/index.js +44 -36
- package/esm/Input/index.d.ts +1 -1
- package/esm/Input/index.js +38 -26
- package/esm/Input/index.props.d.ts +1 -1
- package/esm/InputRadio/index.js +32 -23
- package/esm/List/List.js +81 -75
- package/esm/Menu/Menu.module.css +2 -1
- package/esm/Menu/components/MenuItem/index.js +17 -13
- package/esm/Menu/index.js +22 -23
- package/esm/Modal/components/Body/index.js +9 -7
- package/esm/Modal/components/Close/Close.module.css +4 -0
- package/esm/Modal/components/Close/index.js +13 -14
- package/esm/Modal/components/Content/index.js +5 -6
- package/esm/Modal/components/Footer/index.js +5 -3
- package/esm/Modal/components/Header/index.js +13 -11
- package/esm/Modal/components/Title/index.js +10 -9
- package/esm/Modal/context.js +3 -3
- package/esm/Modal/index.js +50 -70
- package/esm/MultiSelect/components/MenuOverlay/index.js +48 -60
- package/esm/MultiSelect/components/MenuOverlayItem/index.js +13 -14
- package/esm/MultiSelect/index.js +72 -97
- package/esm/MultiSelect/index.module.css +2 -1
- package/esm/MultiSelect/utils/index.js +8 -14
- package/esm/NumberInput/NumberInput.js +80 -111
- package/esm/Portal/index.js +6 -9
- package/esm/Progress/Progress.js +45 -58
- package/esm/RadioGroup/Radio.js +29 -32
- package/esm/RadioGroup/index.js +43 -45
- package/esm/Rating/Rating.js +50 -63
- package/esm/Select/components/MenuOverlay/index.js +16 -24
- package/esm/Select/components/MenuOverlayItem/index.js +13 -11
- package/esm/Select/index.js +39 -46
- package/esm/Select/index.module.css +2 -1
- package/esm/Separator/index.js +5 -6
- package/esm/Sheet/Sheet.js +89 -119
- package/esm/Sheet/Sheet.module.css +4 -2
- package/esm/Skeleton/index.js +25 -30
- package/esm/Slider/Slider.js +83 -119
- package/esm/Status/index.js +17 -17
- package/esm/Switch/Switch.module.css +2 -1
- package/esm/Switch/index.js +22 -14
- package/esm/TabsMenu/Tab/Tab.js +14 -9
- package/esm/TabsMenu/Tab/Tab.module.css +2 -1
- package/esm/TabsMenu/index.js +25 -26
- package/esm/TabsPanels/Panel/index.js +6 -4
- package/esm/TabsPanels/index.js +13 -10
- package/esm/TextArea/index.d.ts +1 -1
- package/esm/TextArea/index.js +31 -20
- package/esm/Theme/breakpoints.js +5 -11
- package/esm/Theme/colors/theme_buenos_aires.js +14 -14
- package/esm/Theme/colors/theme_jaipur.js +14 -14
- package/esm/Theme/global.css +0 -1
- package/esm/Theme/index.js +1 -1
- package/esm/TimeSelect/Label/index.js +11 -13
- package/esm/TimeSelect/helpers.js +22 -37
- package/esm/TimeSelect/index.js +32 -38
- package/esm/Tooltip/index.js +36 -41
- package/esm/Typography/index.js +17 -12
- package/esm/Typography/index.props.d.ts +3 -0
- package/esm/base/BaseInput/index.js +10 -8
- package/esm/base/FormField/index.d.ts +1 -1
- package/esm/base/FormField/index.js +27 -21
- package/esm/base/FormField/index.props.d.ts +4 -0
- package/esm/base/InputRoot/index.js +27 -26
- package/esm/helpers/date/index.js +4 -8
- package/esm/hooks/useMediaSizes/index.js +9 -15
- package/esm/hooks/useModalStack/index.js +6 -9
- package/esm/hooks/useOnClickOutside/index.js +6 -6
- package/esm/hooks/useScrollLock/index.js +10 -9
- package/esm/hooks/useTrapFocus/index.js +8 -10
- package/esm/lib/keyboard.js +2 -4
- package/helpers/date/index.js +21 -32
- package/hooks/useMediaSizes/index.js +9 -15
- package/hooks/useModalStack/index.js +6 -9
- package/hooks/useOnClickOutside/index.js +6 -6
- package/hooks/useScrollLock/index.js +10 -9
- package/hooks/useTrapFocus/index.js +8 -10
- package/lib/keyboard.js +2 -4
- package/package.json +5 -1
package/Accordion/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
-
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
5
3
|
var React = require('react');
|
|
6
4
|
var clsx = require('clsx');
|
|
7
5
|
require('../Icons/index.js');
|
|
@@ -11,30 +9,23 @@ var Chevron = require('../Icons/Chevron.js');
|
|
|
11
9
|
|
|
12
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
11
|
|
|
14
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefault(_defineProperty);
|
|
15
|
-
var _slicedToArray__default = /*#__PURE__*/_interopDefault(_slicedToArray);
|
|
16
12
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
17
13
|
var clsx__default = /*#__PURE__*/_interopDefault(clsx);
|
|
18
14
|
var styles__default = /*#__PURE__*/_interopDefault(styles);
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var contentRef = React.useRef(null);
|
|
32
|
-
var toggleAccordion = function toggleAccordion() {
|
|
33
|
-
return setIsOpen(!isOpen);
|
|
34
|
-
};
|
|
35
|
-
React.useEffect(function () {
|
|
16
|
+
const Accordion = ({
|
|
17
|
+
title,
|
|
18
|
+
boldTitle = false,
|
|
19
|
+
children,
|
|
20
|
+
className,
|
|
21
|
+
tabIndex
|
|
22
|
+
}) => {
|
|
23
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
24
|
+
const contentRef = React.useRef(null);
|
|
25
|
+
const toggleAccordion = () => setIsOpen(!isOpen);
|
|
26
|
+
React.useEffect(() => {
|
|
36
27
|
if (contentRef.current) {
|
|
37
|
-
contentRef.current.style.blockSize = isOpen ?
|
|
28
|
+
contentRef.current.style.blockSize = isOpen ? `${contentRef.current.scrollHeight}px` : "0";
|
|
38
29
|
}
|
|
39
30
|
}, [isOpen]);
|
|
40
31
|
return /*#__PURE__*/React__default.default.createElement("div", {
|
|
@@ -45,12 +36,13 @@ var Accordion = function Accordion(_ref) {
|
|
|
45
36
|
className: styles__default.default.button,
|
|
46
37
|
onClick: toggleAccordion,
|
|
47
38
|
type: "button",
|
|
48
|
-
role: "button",
|
|
49
39
|
"aria-expanded": isOpen,
|
|
50
40
|
tabIndex: tabIndex,
|
|
51
41
|
"aria-label": "Toggle"
|
|
52
42
|
}, /*#__PURE__*/React__default.default.createElement(Chevron.Chevron, {
|
|
53
|
-
className: clsx__default.default(styles__default.default.chevron,
|
|
43
|
+
className: clsx__default.default(styles__default.default.chevron, {
|
|
44
|
+
[styles__default.default["chevron_open"]]: Boolean(isOpen)
|
|
45
|
+
}),
|
|
54
46
|
width: 20,
|
|
55
47
|
height: 20
|
|
56
48
|
}), /*#__PURE__*/React__default.default.createElement(index.Typography, {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
-
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
5
3
|
var tslib = require('tslib');
|
|
6
4
|
var React = require('react');
|
|
7
5
|
var clsx = require('clsx');
|
|
@@ -12,118 +10,89 @@ var styles = require('./Autocomplete.module.css');
|
|
|
12
10
|
|
|
13
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
12
|
|
|
15
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefault(_defineProperty);
|
|
16
|
-
var _slicedToArray__default = /*#__PURE__*/_interopDefault(_slicedToArray);
|
|
17
13
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
18
14
|
var clsx__default = /*#__PURE__*/_interopDefault(clsx);
|
|
19
15
|
var styles__default = /*#__PURE__*/_interopDefault(styles);
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
size = _props$size === void 0 ? "m" : _props$size,
|
|
58
|
-
_props$listMaxHeight = props.listMaxHeight,
|
|
59
|
-
listMaxHeight = _props$listMaxHeight === void 0 ? "var(--component-autocomplete-list-max-height)" : _props$listMaxHeight,
|
|
60
|
-
containerClassName = props.containerClassName,
|
|
61
|
-
className = props.className,
|
|
62
|
-
disabled = props.disabled,
|
|
63
|
-
readOnly = props.readOnly,
|
|
64
|
-
required = props.required,
|
|
65
|
-
id = props.id,
|
|
66
|
-
_onFocus = props.onFocus,
|
|
67
|
-
onBlur = props.onBlur,
|
|
68
|
-
onKeyDown = props.onKeyDown,
|
|
17
|
+
const AutocompleteInner = (props, forwardedRef) => {
|
|
18
|
+
const {
|
|
19
|
+
options,
|
|
20
|
+
value,
|
|
21
|
+
defaultValue = "",
|
|
22
|
+
onValueChange,
|
|
23
|
+
onOptionSelect,
|
|
24
|
+
filterOption,
|
|
25
|
+
renderOption,
|
|
26
|
+
getOptionKey = option => option.value,
|
|
27
|
+
minQueryLength = 0,
|
|
28
|
+
open,
|
|
29
|
+
defaultOpen = false,
|
|
30
|
+
onOpenChange,
|
|
31
|
+
openOnFocus = true,
|
|
32
|
+
loading = false,
|
|
33
|
+
loadingText = "Loading...",
|
|
34
|
+
emptyText = "No results found",
|
|
35
|
+
label,
|
|
36
|
+
hint,
|
|
37
|
+
hasError,
|
|
38
|
+
success,
|
|
39
|
+
clearable = true,
|
|
40
|
+
clearLabel = "Clear value",
|
|
41
|
+
size = "m",
|
|
42
|
+
listMaxHeight = "var(--component-autocomplete-list-max-height)",
|
|
43
|
+
containerClassName,
|
|
44
|
+
className,
|
|
45
|
+
disabled,
|
|
46
|
+
readOnly,
|
|
47
|
+
required,
|
|
48
|
+
id,
|
|
49
|
+
onFocus,
|
|
50
|
+
onBlur,
|
|
51
|
+
onKeyDown
|
|
52
|
+
} = props,
|
|
69
53
|
inputProps = tslib.__rest(props, ["options", "value", "defaultValue", "onValueChange", "onOptionSelect", "filterOption", "renderOption", "getOptionKey", "minQueryLength", "open", "defaultOpen", "onOpenChange", "openOnFocus", "loading", "loadingText", "emptyText", "label", "hint", "hasError", "success", "clearable", "clearLabel", "size", "listMaxHeight", "containerClassName", "className", "disabled", "readOnly", "required", "id", "onFocus", "onBlur", "onKeyDown"]);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
activeIndex = _useState6[0],
|
|
85
|
-
setActiveIndex = _useState6[1];
|
|
86
|
-
var rootRef = React.useRef(null);
|
|
87
|
-
var controlRef = React.useRef(null);
|
|
88
|
-
var inputRef = React.useRef(null);
|
|
89
|
-
var optionRefs = React.useRef([]);
|
|
90
|
-
var query = controlled ? value : internalValue;
|
|
91
|
-
var isOpen = open !== null && open !== void 0 ? open : internalOpen;
|
|
92
|
-
var setInputRef = function setInputRef(node) {
|
|
54
|
+
const generatedId = React.useId();
|
|
55
|
+
const inputId = id !== null && id !== void 0 ? id : generatedId;
|
|
56
|
+
const listId = `${inputId}-listbox`;
|
|
57
|
+
const controlled = value !== undefined;
|
|
58
|
+
const [internalValue, setInternalValue] = React.useState(defaultValue);
|
|
59
|
+
const [internalOpen, setInternalOpen] = React.useState(defaultOpen);
|
|
60
|
+
const [activeIndex, setActiveIndex] = React.useState(-1);
|
|
61
|
+
const rootRef = React.useRef(null);
|
|
62
|
+
const controlRef = React.useRef(null);
|
|
63
|
+
const inputRef = React.useRef(null);
|
|
64
|
+
const optionRefs = React.useRef([]);
|
|
65
|
+
const query = controlled ? value : internalValue;
|
|
66
|
+
const isOpen = open !== null && open !== void 0 ? open : internalOpen;
|
|
67
|
+
const setInputRef = node => {
|
|
93
68
|
inputRef.current = node;
|
|
94
69
|
if (typeof forwardedRef === "function") forwardedRef(node);else if (forwardedRef) forwardedRef.current = node;
|
|
95
70
|
};
|
|
96
|
-
|
|
71
|
+
const setOpen = React.useCallback(next => {
|
|
97
72
|
if (open === undefined) setInternalOpen(next);
|
|
98
73
|
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(next);
|
|
99
74
|
if (!next) setActiveIndex(-1);
|
|
100
75
|
}, [onOpenChange, open]);
|
|
101
|
-
|
|
76
|
+
const filteredOptions = React.useMemo(() => {
|
|
102
77
|
if (query.length < minQueryLength) return [];
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
};
|
|
107
|
-
return options.filter(function (option) {
|
|
108
|
-
return predicate(option, query);
|
|
109
|
-
});
|
|
78
|
+
const normalized = query.trim().toLocaleLowerCase();
|
|
79
|
+
const predicate = filterOption !== null && filterOption !== void 0 ? filterOption : option => option.label.toLocaleLowerCase().includes(normalized);
|
|
80
|
+
return options.filter(option => predicate(option, query));
|
|
110
81
|
}, [filterOption, minQueryLength, options, query]);
|
|
111
|
-
|
|
112
|
-
React.useEffect(
|
|
82
|
+
const showPopup = isOpen && !disabled && !readOnly && query.length >= minQueryLength;
|
|
83
|
+
React.useEffect(() => {
|
|
113
84
|
if (!showPopup) return undefined;
|
|
114
|
-
|
|
85
|
+
const closeOutside = event => {
|
|
115
86
|
var _a;
|
|
116
87
|
if (!((_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target))) setOpen(false);
|
|
117
88
|
};
|
|
118
89
|
document.addEventListener("mousedown", closeOutside);
|
|
119
|
-
return
|
|
120
|
-
return document.removeEventListener("mousedown", closeOutside);
|
|
121
|
-
};
|
|
90
|
+
return () => document.removeEventListener("mousedown", closeOutside);
|
|
122
91
|
}, [setOpen, showPopup]);
|
|
123
|
-
React.useEffect(
|
|
92
|
+
React.useEffect(() => {
|
|
124
93
|
setActiveIndex(-1);
|
|
125
94
|
}, [query]);
|
|
126
|
-
React.useEffect(
|
|
95
|
+
React.useEffect(() => {
|
|
127
96
|
var _a;
|
|
128
97
|
if (activeIndex >= 0) {
|
|
129
98
|
(_a = optionRefs.current[activeIndex]) === null || _a === void 0 ? void 0 : _a.scrollIntoView({
|
|
@@ -131,11 +100,11 @@ var AutocompleteInner = function AutocompleteInner(props, forwardedRef) {
|
|
|
131
100
|
});
|
|
132
101
|
}
|
|
133
102
|
}, [activeIndex]);
|
|
134
|
-
|
|
103
|
+
const changeValue = next => {
|
|
135
104
|
if (!controlled) setInternalValue(next);
|
|
136
105
|
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(next);
|
|
137
106
|
};
|
|
138
|
-
|
|
107
|
+
const selectOption = option => {
|
|
139
108
|
var _a;
|
|
140
109
|
if (option.disabled) return;
|
|
141
110
|
changeValue(option.label);
|
|
@@ -143,21 +112,21 @@ var AutocompleteInner = function AutocompleteInner(props, forwardedRef) {
|
|
|
143
112
|
setOpen(false);
|
|
144
113
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
145
114
|
};
|
|
146
|
-
|
|
115
|
+
const moveActive = direction => {
|
|
147
116
|
if (!showPopup) setOpen(true);
|
|
148
117
|
if (!filteredOptions.length) return;
|
|
149
|
-
|
|
150
|
-
for (
|
|
118
|
+
let next = activeIndex;
|
|
119
|
+
for (let attempts = 0; attempts < filteredOptions.length; attempts += 1) {
|
|
151
120
|
next = (next + direction + filteredOptions.length) % filteredOptions.length;
|
|
152
121
|
if (!filteredOptions[next].disabled) break;
|
|
153
122
|
}
|
|
154
123
|
setActiveIndex(next);
|
|
155
124
|
};
|
|
156
|
-
|
|
125
|
+
const handleChange = (_event, next) => {
|
|
157
126
|
changeValue(next);
|
|
158
127
|
setOpen(next.length >= minQueryLength);
|
|
159
128
|
};
|
|
160
|
-
|
|
129
|
+
const handleKeyDown = event => {
|
|
161
130
|
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
162
131
|
if (event.defaultPrevented) return;
|
|
163
132
|
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
@@ -171,40 +140,38 @@ var AutocompleteInner = function AutocompleteInner(props, forwardedRef) {
|
|
|
171
140
|
setOpen(false);
|
|
172
141
|
} else if (event.key === "Home" && showPopup) {
|
|
173
142
|
event.preventDefault();
|
|
174
|
-
|
|
175
|
-
return !option.disabled;
|
|
176
|
-
});
|
|
143
|
+
const first = filteredOptions.findIndex(option => !option.disabled);
|
|
177
144
|
setActiveIndex(first);
|
|
178
145
|
} else if (event.key === "End" && showPopup) {
|
|
179
146
|
event.preventDefault();
|
|
180
|
-
|
|
147
|
+
let last = filteredOptions.length - 1;
|
|
181
148
|
while (last >= 0 && filteredOptions[last].disabled) last -= 1;
|
|
182
149
|
setActiveIndex(last);
|
|
183
150
|
} else if (event.key === "Tab") {
|
|
184
151
|
setOpen(false);
|
|
185
152
|
}
|
|
186
153
|
};
|
|
187
|
-
|
|
154
|
+
const clearButton = clearable && query && !disabled && !readOnly && (/*#__PURE__*/React__default.default.createElement("button", {
|
|
188
155
|
type: "button",
|
|
189
156
|
className: styles__default.default.clear,
|
|
190
157
|
"aria-label": clearLabel,
|
|
191
|
-
onMouseDown:
|
|
192
|
-
|
|
193
|
-
},
|
|
194
|
-
onClick: function onClick() {
|
|
158
|
+
onMouseDown: event => event.preventDefault(),
|
|
159
|
+
onClick: () => {
|
|
195
160
|
var _a;
|
|
196
161
|
changeValue("");
|
|
197
162
|
setOpen(openOnFocus && minQueryLength === 0);
|
|
198
163
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
199
164
|
}
|
|
200
165
|
}, /*#__PURE__*/React__default.default.createElement(Cross.Cross, null)));
|
|
201
|
-
|
|
166
|
+
const endIcon = /*#__PURE__*/React__default.default.createElement("span", {
|
|
202
167
|
className: styles__default.default["end-icons"]
|
|
203
168
|
}, clearButton, /*#__PURE__*/React__default.default.createElement(Chevron.Chevron, {
|
|
204
|
-
className: clsx__default.default(styles__default.default.chevron,
|
|
169
|
+
className: clsx__default.default(styles__default.default.chevron, {
|
|
170
|
+
[styles__default.default["chevron_open"]]: showPopup
|
|
171
|
+
}),
|
|
205
172
|
"aria-hidden": "true"
|
|
206
173
|
}));
|
|
207
|
-
|
|
174
|
+
const popup = showPopup && (/*#__PURE__*/React__default.default.createElement("div", {
|
|
208
175
|
className: styles__default.default.popup
|
|
209
176
|
}, /*#__PURE__*/React__default.default.createElement("ul", {
|
|
210
177
|
id: listId,
|
|
@@ -218,37 +185,37 @@ var AutocompleteInner = function AutocompleteInner(props, forwardedRef) {
|
|
|
218
185
|
className: styles__default.default.message
|
|
219
186
|
}, loadingText)) : filteredOptions.length === 0 ? (/*#__PURE__*/React__default.default.createElement("li", {
|
|
220
187
|
className: styles__default.default.message
|
|
221
|
-
}, emptyText)) : filteredOptions.map(
|
|
222
|
-
|
|
223
|
-
|
|
188
|
+
}, emptyText)) : filteredOptions.map((option, index) => {
|
|
189
|
+
const active = index === activeIndex;
|
|
190
|
+
const selected = option.label === query;
|
|
224
191
|
return /*#__PURE__*/React__default.default.createElement("li", {
|
|
225
|
-
ref:
|
|
192
|
+
ref: node => {
|
|
226
193
|
optionRefs.current[index] = node;
|
|
227
194
|
},
|
|
228
|
-
id:
|
|
195
|
+
id: `${listId}-${index}`,
|
|
229
196
|
key: getOptionKey(option),
|
|
230
197
|
role: "option",
|
|
231
198
|
"aria-selected": selected,
|
|
232
199
|
"aria-disabled": option.disabled || undefined,
|
|
233
|
-
className: clsx__default.default(styles__default.default.option,
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
200
|
+
className: clsx__default.default(styles__default.default.option, {
|
|
201
|
+
[styles__default.default.active]: active,
|
|
202
|
+
[styles__default.default.selected]: selected,
|
|
203
|
+
[styles__default.default["option_disabled"]]: option.disabled
|
|
204
|
+
}),
|
|
205
|
+
onMouseDown: event => event.preventDefault(),
|
|
206
|
+
onMouseEnter: () => {
|
|
238
207
|
if (!option.disabled) setActiveIndex(index);
|
|
239
208
|
},
|
|
240
|
-
onKeyDown:
|
|
209
|
+
onKeyDown: event => {
|
|
241
210
|
if (event.key === "Enter" || event.key === " ") {
|
|
242
211
|
event.preventDefault();
|
|
243
212
|
selectOption(option);
|
|
244
213
|
}
|
|
245
214
|
},
|
|
246
|
-
onClick:
|
|
247
|
-
return selectOption(option);
|
|
248
|
-
}
|
|
215
|
+
onClick: () => selectOption(option)
|
|
249
216
|
}, renderOption ? renderOption(option, {
|
|
250
|
-
active
|
|
251
|
-
selected
|
|
217
|
+
active,
|
|
218
|
+
selected
|
|
252
219
|
}) : (/*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, option.contentLeft && (/*#__PURE__*/React__default.default.createElement("span", {
|
|
253
220
|
className: styles__default.default.side
|
|
254
221
|
}, option.contentLeft)), /*#__PURE__*/React__default.default.createElement("span", {
|
|
@@ -259,7 +226,9 @@ var AutocompleteInner = function AutocompleteInner(props, forwardedRef) {
|
|
|
259
226
|
}))));
|
|
260
227
|
return /*#__PURE__*/React__default.default.createElement("div", {
|
|
261
228
|
ref: rootRef,
|
|
262
|
-
className: clsx__default.default(styles__default.default.root, styles__default.default[
|
|
229
|
+
className: clsx__default.default(styles__default.default.root, styles__default.default[`size_${size}`], {
|
|
230
|
+
[styles__default.default.success]: success
|
|
231
|
+
}, containerClassName)
|
|
263
232
|
}, /*#__PURE__*/React__default.default.createElement(index.Input, Object.assign({}, inputProps, {
|
|
264
233
|
id: inputId,
|
|
265
234
|
type: "text",
|
|
@@ -267,7 +236,7 @@ var AutocompleteInner = function AutocompleteInner(props, forwardedRef) {
|
|
|
267
236
|
"aria-autocomplete": "list",
|
|
268
237
|
"aria-expanded": showPopup,
|
|
269
238
|
"aria-controls": showPopup ? listId : undefined,
|
|
270
|
-
"aria-activedescendant": activeIndex >= 0 ?
|
|
239
|
+
"aria-activedescendant": activeIndex >= 0 ? `${listId}-${activeIndex}` : undefined,
|
|
271
240
|
"aria-invalid": hasError || undefined,
|
|
272
241
|
autoComplete: "off",
|
|
273
242
|
className: clsx__default.default(styles__default.default.field, className),
|
|
@@ -286,13 +255,13 @@ var AutocompleteInner = function AutocompleteInner(props, forwardedRef) {
|
|
|
286
255
|
value: query,
|
|
287
256
|
onBlur: onBlur,
|
|
288
257
|
onChange: handleChange,
|
|
289
|
-
onFocus:
|
|
290
|
-
|
|
258
|
+
onFocus: event => {
|
|
259
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
291
260
|
if (openOnFocus && query.length >= minQueryLength) setOpen(true);
|
|
292
261
|
},
|
|
293
262
|
onKeyDown: handleKeyDown
|
|
294
263
|
})));
|
|
295
264
|
};
|
|
296
|
-
|
|
265
|
+
const Autocomplete = /*#__PURE__*/React.forwardRef(AutocompleteInner);
|
|
297
266
|
|
|
298
267
|
exports.Autocomplete = Autocomplete;
|
package/Avatar/Avatar.module.css
CHANGED
|
@@ -143,4 +143,10 @@
|
|
|
143
143
|
100% {
|
|
144
144
|
transform: rotate(360deg);
|
|
145
145
|
}
|
|
146
|
+
}
|
|
147
|
+
.avatar-wrapper:focus-visible,
|
|
148
|
+
.avatar-initials:focus-visible,
|
|
149
|
+
.avatar-stub:focus-visible {
|
|
150
|
+
outline: var(--focus-ring-width) solid var(--color-focus-ring);
|
|
151
|
+
outline-offset: var(--focus-ring-width);
|
|
146
152
|
}
|