@deque/cauldron-react 5.8.0 → 5.8.1-canary.5921a8e6
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/lib/components/Combobox/Combobox.d.ts +30 -0
- package/lib/components/Combobox/ComboboxContext.d.ts +22 -0
- package/lib/components/Combobox/ComboboxGroup.d.ts +7 -0
- package/lib/components/Combobox/ComboboxOption.d.ts +12 -0
- package/lib/components/Combobox/index.d.ts +3 -0
- package/lib/components/Listbox/Listbox.d.ts +16 -0
- package/lib/components/Listbox/ListboxContext.d.ts +27 -0
- package/lib/components/Listbox/ListboxGroup.d.ts +9 -0
- package/lib/components/Listbox/ListboxOption.d.ts +10 -0
- package/lib/components/Listbox/index.d.ts +4 -0
- package/lib/components/Popover/index.d.ts +31 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +756 -7
- package/lib/utils/useIntersectionRef.d.ts +12 -0
- package/package.json +3 -3
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ContentNode } from '../../types';
|
|
3
|
+
import ComboboxOption from './ComboboxOption';
|
|
4
|
+
import type { ComboboxValue } from './ComboboxOption';
|
|
5
|
+
import type { ListboxOption } from '../Listbox/ListboxContext';
|
|
6
|
+
interface ComboboxOption {
|
|
7
|
+
key?: string;
|
|
8
|
+
label: string;
|
|
9
|
+
value?: ComboboxValue;
|
|
10
|
+
description?: string;
|
|
11
|
+
}
|
|
12
|
+
interface ComboboxProps extends React.InputHTMLAttributes<Omit<HTMLInputElement, 'value' | 'defaultValue'>> {
|
|
13
|
+
label: ContentNode;
|
|
14
|
+
options?: ComboboxOption[];
|
|
15
|
+
value?: ComboboxValue;
|
|
16
|
+
defaultValue?: ComboboxValue;
|
|
17
|
+
requiredText?: React.ReactNode;
|
|
18
|
+
error?: React.ReactNode;
|
|
19
|
+
autocomplete?: 'none' | 'manual' | 'automatic';
|
|
20
|
+
onSelectionChange?: <T extends HTMLElement = HTMLElement>({ target, value, previousValue }: {
|
|
21
|
+
target: T;
|
|
22
|
+
value: ComboboxValue;
|
|
23
|
+
previousValue: ComboboxValue;
|
|
24
|
+
}) => void;
|
|
25
|
+
onActiveChange?: (option: ListboxOption) => void;
|
|
26
|
+
renderNoResults?: (() => JSX.Element) | React.ReactElement;
|
|
27
|
+
portal?: React.RefObject<HTMLElement> | HTMLElement;
|
|
28
|
+
}
|
|
29
|
+
declare const Combobox: React.ForwardRefExoticComponent<ComboboxProps & React.RefAttributes<HTMLInputElement>>;
|
|
30
|
+
export default Combobox;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ComboboxValue } from './ComboboxOption';
|
|
3
|
+
type ComboboxContext = {
|
|
4
|
+
autocomplete: 'none' | 'manual' | 'automatic';
|
|
5
|
+
inputValue: ComboboxValue;
|
|
6
|
+
selectedValue: ComboboxValue;
|
|
7
|
+
matchingOptions: Map<HTMLElement, ComboboxOptionState>;
|
|
8
|
+
setMatchingOptions: React.Dispatch<React.SetStateAction<Map<HTMLElement, ComboboxOptionState>>>;
|
|
9
|
+
matches: (<T extends string = string>(value: T) => boolean) | boolean;
|
|
10
|
+
};
|
|
11
|
+
export type ComboboxOptionState = {
|
|
12
|
+
selected: boolean;
|
|
13
|
+
value: ComboboxValue;
|
|
14
|
+
};
|
|
15
|
+
type ComboboxProvider = {
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
matches: ((inputValue: string, value: string) => boolean) | boolean;
|
|
18
|
+
} & Omit<ComboboxContext, 'matches'>;
|
|
19
|
+
declare const ComboboxContext: React.Context<ComboboxContext>;
|
|
20
|
+
declare function ComboboxProvider({ autocomplete, inputValue, selectedValue, matches, matchingOptions, setMatchingOptions, children }: ComboboxProvider): JSX.Element;
|
|
21
|
+
declare function useComboboxContext(): ComboboxContext;
|
|
22
|
+
export { ComboboxProvider, useComboboxContext };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ContentNode } from '../../types';
|
|
3
|
+
interface ComboboxGroupProps extends React.HTMLAttributes<HTMLUListElement> {
|
|
4
|
+
label: ContentNode;
|
|
5
|
+
}
|
|
6
|
+
declare const ComboboxGroup: React.ForwardRefExoticComponent<ComboboxGroupProps & React.RefAttributes<HTMLUListElement>>;
|
|
7
|
+
export default ComboboxGroup;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ListboxValue } from '../Listbox/ListboxOption';
|
|
3
|
+
import type { ContentNode } from '../../types';
|
|
4
|
+
export type ComboboxValue = Exclude<ListboxValue, number>;
|
|
5
|
+
interface ComboboxOptionProps extends React.HTMLAttributes<HTMLLIElement> {
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
value?: ComboboxValue;
|
|
8
|
+
description?: ContentNode;
|
|
9
|
+
children: string;
|
|
10
|
+
}
|
|
11
|
+
declare const ComboboxOption: React.ForwardRefExoticComponent<ComboboxOptionProps & React.RefAttributes<HTMLLIElement>>;
|
|
12
|
+
export default ComboboxOption;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ListboxOption } from './ListboxContext';
|
|
3
|
+
import type { ListboxValue } from './ListboxOption';
|
|
4
|
+
interface ListboxProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onSelect'> {
|
|
5
|
+
as?: React.ElementType | string;
|
|
6
|
+
value?: ListboxValue;
|
|
7
|
+
navigation?: 'cycle' | 'bound';
|
|
8
|
+
onSelectionChange?: <T extends HTMLElement = HTMLElement>({ value }: {
|
|
9
|
+
target: T;
|
|
10
|
+
previousValue: ListboxValue;
|
|
11
|
+
value: ListboxValue;
|
|
12
|
+
}) => void;
|
|
13
|
+
onActiveChange?: (option: ListboxOption) => void;
|
|
14
|
+
}
|
|
15
|
+
declare const Listbox: React.ForwardRefExoticComponent<ListboxProps & React.RefAttributes<HTMLElement>>;
|
|
16
|
+
export default Listbox;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type UnknownElement<T> = T extends Element ? T : HTMLElement;
|
|
3
|
+
type UnknownValue<T> = T extends string ? T : number;
|
|
4
|
+
type ListboxOption<Element = HTMLElement, Value = string | number> = {
|
|
5
|
+
element: UnknownElement<Element>;
|
|
6
|
+
value?: UnknownValue<Value>;
|
|
7
|
+
};
|
|
8
|
+
type ListboxContext<T extends ListboxOption> = {
|
|
9
|
+
options: T[];
|
|
10
|
+
active: T | null;
|
|
11
|
+
selected: T | null;
|
|
12
|
+
setOptions: React.Dispatch<React.SetStateAction<T[]>>;
|
|
13
|
+
onSelect: (option: T) => void;
|
|
14
|
+
};
|
|
15
|
+
type ListboxProvider<T extends ListboxOption> = {
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
} & ListboxContext<T>;
|
|
18
|
+
declare const ListboxContext: React.Context<{
|
|
19
|
+
options: never[];
|
|
20
|
+
active: null;
|
|
21
|
+
selected: null;
|
|
22
|
+
setOptions: () => null;
|
|
23
|
+
onSelect: () => null;
|
|
24
|
+
}>;
|
|
25
|
+
declare function ListboxProvider<T extends ListboxOption>({ options, active, selected, setOptions, onSelect, children }: ListboxProvider<T>): JSX.Element;
|
|
26
|
+
declare function useListboxContext<T extends ListboxOption>(): ListboxContext<T>;
|
|
27
|
+
export { ListboxProvider, useListboxContext, ListboxOption };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ContentNode } from '../../types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
interface ListboxGroupProps extends React.HTMLAttributes<HTMLElement> {
|
|
4
|
+
as?: React.ElementType | string;
|
|
5
|
+
groupLabelProps?: React.HTMLAttributes<HTMLLIElement>;
|
|
6
|
+
label: ContentNode;
|
|
7
|
+
}
|
|
8
|
+
declare const ListboxGroup: React.ForwardRefExoticComponent<ListboxGroupProps & React.RefAttributes<HTMLElement>>;
|
|
9
|
+
export default ListboxGroup;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type ListboxValue = Readonly<string | number | undefined>;
|
|
3
|
+
interface ListboxOptionsProps extends React.HTMLAttributes<HTMLElement> {
|
|
4
|
+
as?: React.ElementType | string;
|
|
5
|
+
value?: ListboxValue;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
activeClass?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const ListboxOption: React.ForwardRefExoticComponent<ListboxOptionsProps & React.RefAttributes<HTMLElement>>;
|
|
10
|
+
export default ListboxOption;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { Placement } from '@popperjs/core';
|
|
3
|
+
import { Cauldron } from '../../types';
|
|
4
|
+
export type PopoverVariant = 'prompt' | 'custom';
|
|
5
|
+
type BaseProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
6
|
+
target: React.RefObject<HTMLElement> | HTMLElement;
|
|
7
|
+
variant?: PopoverVariant;
|
|
8
|
+
show: boolean;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
placement?: Placement;
|
|
11
|
+
portal?: React.RefObject<HTMLElement> | HTMLElement;
|
|
12
|
+
};
|
|
13
|
+
type CustomProps = BaseProps & {
|
|
14
|
+
variant: 'custom';
|
|
15
|
+
applyButtonText?: string;
|
|
16
|
+
onApply?: () => void;
|
|
17
|
+
closeButtonText?: string;
|
|
18
|
+
infoText?: ReactNode;
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
} & Cauldron.LabelProps;
|
|
21
|
+
type PromptProps = BaseProps & {
|
|
22
|
+
variant: 'prompt';
|
|
23
|
+
applyButtonText?: string;
|
|
24
|
+
onApply: () => void;
|
|
25
|
+
closeButtonText?: string;
|
|
26
|
+
infoText: ReactNode;
|
|
27
|
+
children?: ReactNode;
|
|
28
|
+
};
|
|
29
|
+
export type PopoverProps = PromptProps | CustomProps;
|
|
30
|
+
declare const Popover: React.ForwardRefExoticComponent<PopoverProps & React.RefAttributes<HTMLDivElement>>;
|
|
31
|
+
export default Popover;
|
package/lib/index.d.ts
CHANGED
|
@@ -52,6 +52,9 @@ export { default as FieldWrap } from './components/FieldWrap';
|
|
|
52
52
|
export { default as Breadcrumb, BreadcrumbItem, BreadcrumbLink } from './components/Breadcrumb';
|
|
53
53
|
export { default as TwoColumnPanel, ColumnHeader, ColumnGroupHeader, ColumnLeft, ColumnRight, ColumnList } from './components/TwoColumnPanel';
|
|
54
54
|
export { default as Notice } from './components/Notice';
|
|
55
|
+
export { default as Listbox, ListboxOption, ListboxGroup } from './components/Listbox';
|
|
56
|
+
export { default as Combobox, ComboboxOption, ComboboxGroup } from './components/Combobox';
|
|
57
|
+
export { default as Popover } from './components/Popover';
|
|
55
58
|
/**
|
|
56
59
|
* Helpers / Utils
|
|
57
60
|
*/
|
package/lib/index.js
CHANGED
|
@@ -12,11 +12,11 @@ var reactDom = require('react-dom');
|
|
|
12
12
|
var FocusTrap = require('focus-trap-react');
|
|
13
13
|
var reactPopper = require('react-popper');
|
|
14
14
|
var focusable = require('focusable');
|
|
15
|
-
var SyntaxHighlighter = require('react-syntax-highlighter/dist/
|
|
16
|
-
var js = require('react-syntax-highlighter/dist/
|
|
17
|
-
var css = require('react-syntax-highlighter/dist/
|
|
18
|
-
var xml = require('react-syntax-highlighter/dist/
|
|
19
|
-
var yaml = require('react-syntax-highlighter/dist/
|
|
15
|
+
var SyntaxHighlighter = require('react-syntax-highlighter/dist/cjs/light');
|
|
16
|
+
var js = require('react-syntax-highlighter/dist/cjs/languages/hljs/javascript');
|
|
17
|
+
var css = require('react-syntax-highlighter/dist/cjs/languages/hljs/css');
|
|
18
|
+
var xml = require('react-syntax-highlighter/dist/cjs/languages/hljs/xml');
|
|
19
|
+
var yaml = require('react-syntax-highlighter/dist/cjs/languages/hljs/yaml');
|
|
20
20
|
|
|
21
21
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
22
|
|
|
@@ -961,7 +961,7 @@ var ClickOutsideListener = /** @class */ (function (_super) {
|
|
|
961
961
|
return ClickOutsideListener;
|
|
962
962
|
}(React__default["default"].Component));
|
|
963
963
|
|
|
964
|
-
var _a$
|
|
964
|
+
var _a$2 = tslib.__read([38, 40, 9, 13, 32, 27], 6), up = _a$2[0], down$1 = _a$2[1], tab = _a$2[2], enter = _a$2[3], space = _a$2[4], esc = _a$2[5];
|
|
965
965
|
var OptionsMenuList = /** @class */ (function (_super) {
|
|
966
966
|
tslib.__extends(OptionsMenuList, _super);
|
|
967
967
|
function OptionsMenuList(props) {
|
|
@@ -1096,7 +1096,7 @@ var OptionsMenuList = /** @class */ (function (_super) {
|
|
|
1096
1096
|
return OptionsMenuList;
|
|
1097
1097
|
}(React__default["default"].Component));
|
|
1098
1098
|
|
|
1099
|
-
var _a = tslib.__read([40], 1), down = _a[0];
|
|
1099
|
+
var _a$1 = tslib.__read([40], 1), down = _a$1[0];
|
|
1100
1100
|
var OptionsMenu = /** @class */ (function (_super) {
|
|
1101
1101
|
tslib.__extends(OptionsMenu, _super);
|
|
1102
1102
|
function OptionsMenu(props) {
|
|
@@ -3943,6 +3943,748 @@ Notice.propTypes = {
|
|
|
3943
3943
|
icon: PropTypes__default["default"].string
|
|
3944
3944
|
};
|
|
3945
3945
|
|
|
3946
|
+
/* istanbul ignore next */
|
|
3947
|
+
var ListboxContext = React.createContext({
|
|
3948
|
+
options: [],
|
|
3949
|
+
active: null,
|
|
3950
|
+
selected: null,
|
|
3951
|
+
setOptions: function () { return null; },
|
|
3952
|
+
onSelect: function () { return null; }
|
|
3953
|
+
});
|
|
3954
|
+
function ListboxProvider(_a) {
|
|
3955
|
+
var options = _a.options, active = _a.active, selected = _a.selected, setOptions = _a.setOptions, onSelect = _a.onSelect, children = _a.children;
|
|
3956
|
+
var Provider = ListboxContext.Provider;
|
|
3957
|
+
var value = React.useMemo(function () { return ({
|
|
3958
|
+
options: options,
|
|
3959
|
+
active: active,
|
|
3960
|
+
selected: selected,
|
|
3961
|
+
setOptions: setOptions,
|
|
3962
|
+
onSelect: onSelect
|
|
3963
|
+
}); }, [options, active, selected, setOptions]);
|
|
3964
|
+
return React__default["default"].createElement(Provider, { value: value }, children);
|
|
3965
|
+
}
|
|
3966
|
+
function useListboxContext() {
|
|
3967
|
+
return React.useContext(ListboxContext);
|
|
3968
|
+
}
|
|
3969
|
+
|
|
3970
|
+
var keys = ['ArrowUp', 'ArrowDown', 'Home', 'End', 'Enter', ' '];
|
|
3971
|
+
// id for listbox options should always be defined since it should
|
|
3972
|
+
// be provide via the author, or auto-generated via the component
|
|
3973
|
+
var getOptionId = function (option) {
|
|
3974
|
+
return option.element.getAttribute('id');
|
|
3975
|
+
};
|
|
3976
|
+
var isDisabledOption = function (option) {
|
|
3977
|
+
return option.element.getAttribute('aria-disabled') === 'true';
|
|
3978
|
+
};
|
|
3979
|
+
var optionMatchesValue = function (option, value) {
|
|
3980
|
+
return typeof option.value !== null &&
|
|
3981
|
+
typeof option.value !== 'undefined' &&
|
|
3982
|
+
option.value === value;
|
|
3983
|
+
};
|
|
3984
|
+
var Listbox = React.forwardRef(function (_a, ref) {
|
|
3985
|
+
var _b = _a.as, Component = _b === void 0 ? 'ul' : _b, children = _a.children, defaultValue = _a.defaultValue, value = _a.value, _c = _a.navigation, navigation = _c === void 0 ? 'bound' : _c, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onSelectionChange = _a.onSelectionChange, onActiveChange = _a.onActiveChange, props = tslib.__rest(_a, ["as", "children", "defaultValue", "value", "navigation", "onKeyDown", "onFocus", "onSelectionChange", "onActiveChange"]);
|
|
3986
|
+
var _d = tslib.__read(React.useState([]), 2), options = _d[0], setOptions = _d[1];
|
|
3987
|
+
var _e = tslib.__read(React.useState(null), 2), activeOption = _e[0], setActiveOption = _e[1];
|
|
3988
|
+
var _f = tslib.__read(React.useState(null), 2), selectedOption = _f[0], setSelectedOption = _f[1];
|
|
3989
|
+
var listboxRef = useSharedRef(ref);
|
|
3990
|
+
var isControlled = typeof value !== 'undefined';
|
|
3991
|
+
React.useLayoutEffect(function () {
|
|
3992
|
+
if (!isControlled && selectedOption) {
|
|
3993
|
+
return;
|
|
3994
|
+
}
|
|
3995
|
+
var listboxValue = isControlled ? value : defaultValue;
|
|
3996
|
+
var matchingOption = options.find(function (option) {
|
|
3997
|
+
return optionMatchesValue(option, listboxValue);
|
|
3998
|
+
});
|
|
3999
|
+
setSelectedOption(matchingOption || null);
|
|
4000
|
+
setActiveOption(matchingOption || null);
|
|
4001
|
+
}, [isControlled, options, value]);
|
|
4002
|
+
React.useEffect(function () {
|
|
4003
|
+
if (activeOption) {
|
|
4004
|
+
onActiveChange === null || onActiveChange === void 0 ? void 0 : onActiveChange(activeOption);
|
|
4005
|
+
}
|
|
4006
|
+
}, [activeOption]);
|
|
4007
|
+
var handleSelect = React.useCallback(function (option) {
|
|
4008
|
+
setActiveOption(option);
|
|
4009
|
+
// istanbul ignore else
|
|
4010
|
+
if (!isControlled) {
|
|
4011
|
+
setSelectedOption(option);
|
|
4012
|
+
}
|
|
4013
|
+
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange({
|
|
4014
|
+
target: option.element,
|
|
4015
|
+
value: option.value,
|
|
4016
|
+
previousValue: selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value
|
|
4017
|
+
});
|
|
4018
|
+
}, [isControlled, selectedOption]);
|
|
4019
|
+
var handleKeyDown = React.useCallback(function (event) {
|
|
4020
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
4021
|
+
if (!keys.includes(event.key)) {
|
|
4022
|
+
return;
|
|
4023
|
+
}
|
|
4024
|
+
event.preventDefault();
|
|
4025
|
+
var enabledOptions = options.filter(function (option) { return !isDisabledOption(option); });
|
|
4026
|
+
// istanbul ignore next
|
|
4027
|
+
if (!enabledOptions.length) {
|
|
4028
|
+
return;
|
|
4029
|
+
}
|
|
4030
|
+
var _a = tslib.__read(keys, 6), up = _a[0], down = _a[1], home = _a[2], end = _a[3], enter = _a[4], space = _a[5];
|
|
4031
|
+
var firstOption = enabledOptions[0];
|
|
4032
|
+
if (!activeOption) {
|
|
4033
|
+
setActiveOption(firstOption);
|
|
4034
|
+
return;
|
|
4035
|
+
}
|
|
4036
|
+
var lastOption = enabledOptions[enabledOptions.length - 1];
|
|
4037
|
+
var currentOption = activeOption;
|
|
4038
|
+
var currentIndex = enabledOptions.findIndex(function (_a) {
|
|
4039
|
+
var element = _a.element;
|
|
4040
|
+
return element === currentOption.element;
|
|
4041
|
+
});
|
|
4042
|
+
var allowCyclicalNavigation = navigation === 'cycle';
|
|
4043
|
+
switch (event.key) {
|
|
4044
|
+
case up:
|
|
4045
|
+
var previousOption = currentIndex === 0 && allowCyclicalNavigation
|
|
4046
|
+
? lastOption
|
|
4047
|
+
: enabledOptions[Math.max(currentIndex - 1, 0)];
|
|
4048
|
+
setActiveOption(previousOption);
|
|
4049
|
+
break;
|
|
4050
|
+
case down:
|
|
4051
|
+
var nextOption = currentIndex === enabledOptions.length - 1 &&
|
|
4052
|
+
allowCyclicalNavigation
|
|
4053
|
+
? firstOption
|
|
4054
|
+
: enabledOptions[Math.min(currentIndex + 1, enabledOptions.length - 1)];
|
|
4055
|
+
setActiveOption(nextOption);
|
|
4056
|
+
break;
|
|
4057
|
+
case home:
|
|
4058
|
+
setActiveOption(firstOption);
|
|
4059
|
+
break;
|
|
4060
|
+
case end:
|
|
4061
|
+
setActiveOption(lastOption);
|
|
4062
|
+
break;
|
|
4063
|
+
case enter:
|
|
4064
|
+
case space:
|
|
4065
|
+
activeOption && handleSelect(activeOption);
|
|
4066
|
+
break;
|
|
4067
|
+
}
|
|
4068
|
+
}, [options, activeOption, navigation]);
|
|
4069
|
+
var handleFocus = React.useCallback(function (event) {
|
|
4070
|
+
if (!activeOption && !selectedOption) {
|
|
4071
|
+
var firstOption = options.find(function (option) { return !isDisabledOption(option); });
|
|
4072
|
+
// istanbul ignore else
|
|
4073
|
+
if (firstOption) {
|
|
4074
|
+
setActiveOption(firstOption);
|
|
4075
|
+
}
|
|
4076
|
+
// istanbul ignore else
|
|
4077
|
+
}
|
|
4078
|
+
else if (event.target === listboxRef.current) {
|
|
4079
|
+
setActiveOption(selectedOption);
|
|
4080
|
+
}
|
|
4081
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
4082
|
+
}, [options, activeOption, selectedOption]);
|
|
4083
|
+
return (React__default["default"].createElement(Component, tslib.__assign({ role: "listbox", ref: listboxRef, tabIndex: "0", onKeyDown: handleKeyDown, onFocus: handleFocus, "aria-activedescendant": activeOption ? getOptionId(activeOption) : undefined }, props),
|
|
4084
|
+
React__default["default"].createElement(ListboxProvider, { options: options, active: activeOption, selected: selectedOption, setOptions: setOptions, onSelect: handleSelect }, children)));
|
|
4085
|
+
});
|
|
4086
|
+
Listbox.displayName = 'Listbox';
|
|
4087
|
+
|
|
4088
|
+
function isElementPreceding(a, b) {
|
|
4089
|
+
return !!(b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING);
|
|
4090
|
+
}
|
|
4091
|
+
var ListboxOption = React.forwardRef(function (_a, ref) {
|
|
4092
|
+
var _b;
|
|
4093
|
+
var _c;
|
|
4094
|
+
var propId = _a.id, className = _a.className, _d = _a.as, Component = _d === void 0 ? 'li' : _d, children = _a.children, value = _a.value, disabled = _a.disabled, _e = _a.activeClass, activeClass = _e === void 0 ? 'ListboxOption--active' : _e, onClick = _a.onClick, props = tslib.__rest(_a, ["id", "className", "as", "children", "value", "disabled", "activeClass", "onClick"]);
|
|
4095
|
+
var _f = useListboxContext(), active = _f.active, selected = _f.selected, setOptions = _f.setOptions, onSelect = _f.onSelect;
|
|
4096
|
+
var listboxOptionRef = useSharedRef(ref);
|
|
4097
|
+
var _g = tslib.__read(propId ? [propId] : nextId.useId(1, 'listbox-option'), 1), id = _g[0];
|
|
4098
|
+
var isActive = active !== null && active.element === listboxOptionRef.current;
|
|
4099
|
+
var isSelected = selected !== null && selected.element === listboxOptionRef.current;
|
|
4100
|
+
var optionValue = typeof value !== 'undefined'
|
|
4101
|
+
? value
|
|
4102
|
+
: (_c = listboxOptionRef.current) === null || _c === void 0 ? void 0 : _c.innerText;
|
|
4103
|
+
React.useEffect(function () {
|
|
4104
|
+
var element = listboxOptionRef.current;
|
|
4105
|
+
setOptions(function (options) {
|
|
4106
|
+
var e_1, _a;
|
|
4107
|
+
var option = { element: element, value: optionValue };
|
|
4108
|
+
// istanbul ignore next
|
|
4109
|
+
if (!element)
|
|
4110
|
+
return options;
|
|
4111
|
+
// Elements are frequently appended, so check to see if the newly rendered
|
|
4112
|
+
// element follows the last element first before any other checks
|
|
4113
|
+
if (!options.length ||
|
|
4114
|
+
isElementPreceding(options[options.length - 1].element, option.element)) {
|
|
4115
|
+
return tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(options), false), [option], false);
|
|
4116
|
+
}
|
|
4117
|
+
try {
|
|
4118
|
+
for (var options_1 = tslib.__values(options), options_1_1 = options_1.next(); !options_1_1.done; options_1_1 = options_1.next()) {
|
|
4119
|
+
var opt = options_1_1.value;
|
|
4120
|
+
if (isElementPreceding(element, opt.element)) {
|
|
4121
|
+
var index = options.indexOf(opt);
|
|
4122
|
+
return tslib.__spreadArray(tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(options.slice(0, index)), false), [
|
|
4123
|
+
option
|
|
4124
|
+
], false), tslib.__read(options.slice(index)), false);
|
|
4125
|
+
}
|
|
4126
|
+
}
|
|
4127
|
+
}
|
|
4128
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
4129
|
+
finally {
|
|
4130
|
+
try {
|
|
4131
|
+
if (options_1_1 && !options_1_1.done && (_a = options_1.return)) _a.call(options_1);
|
|
4132
|
+
}
|
|
4133
|
+
finally { if (e_1) throw e_1.error; }
|
|
4134
|
+
}
|
|
4135
|
+
// istanbul ignore next
|
|
4136
|
+
// this should never happen, but just in case fall back to options
|
|
4137
|
+
return options;
|
|
4138
|
+
});
|
|
4139
|
+
return function () {
|
|
4140
|
+
setOptions(function (opts) { return opts.filter(function (opt) { return opt.element !== element; }); });
|
|
4141
|
+
};
|
|
4142
|
+
}, [optionValue]);
|
|
4143
|
+
var handleClick = React.useCallback(function (event) {
|
|
4144
|
+
if (disabled) {
|
|
4145
|
+
return;
|
|
4146
|
+
}
|
|
4147
|
+
onSelect({ element: listboxOptionRef.current, value: optionValue });
|
|
4148
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
4149
|
+
}, [optionValue]);
|
|
4150
|
+
return (React__default["default"].createElement(Component, tslib.__assign({ id: id, className: classNames__default["default"](className, (_b = {},
|
|
4151
|
+
_b[activeClass] = isActive,
|
|
4152
|
+
_b)), role: "option", ref: listboxOptionRef, "aria-disabled": typeof disabled === 'boolean' ? disabled : undefined, "aria-selected": isSelected, onClick: handleClick }, props), children));
|
|
4153
|
+
});
|
|
4154
|
+
ListboxOption.displayName = 'ListboxOption';
|
|
4155
|
+
|
|
4156
|
+
var ListboxGroup = React.forwardRef(function (_a, ref) {
|
|
4157
|
+
var _b = _a.as, Component = _b === void 0 ? 'ul' : _b, children = _a.children, propId = _a.id, label = _a.label, groupLabelProps = _a.groupLabelProps, props = tslib.__rest(_a, ["as", "children", "id", "label", "groupLabelProps"]);
|
|
4158
|
+
var _c = tslib.__read(propId ? [propId] : nextId.useId(1, 'listbox-group-label'), 1), id = _c[0];
|
|
4159
|
+
return (React__default["default"].createElement(Component, tslib.__assign({ role: "group", ref: ref, "aria-labelledby": id }, props),
|
|
4160
|
+
React__default["default"].createElement("li", tslib.__assign({ role: "presentation", id: id }, groupLabelProps), label),
|
|
4161
|
+
children));
|
|
4162
|
+
});
|
|
4163
|
+
ListboxGroup.displayName = 'ListboxGroup';
|
|
4164
|
+
|
|
4165
|
+
/* istanbul ignore next */
|
|
4166
|
+
var ComboboxContext = React.createContext({
|
|
4167
|
+
autocomplete: 'manual',
|
|
4168
|
+
inputValue: undefined,
|
|
4169
|
+
selectedValue: undefined,
|
|
4170
|
+
matches: true,
|
|
4171
|
+
matchingOptions: new Map(),
|
|
4172
|
+
setMatchingOptions: function () { return null; }
|
|
4173
|
+
});
|
|
4174
|
+
function ComboboxProvider(_a) {
|
|
4175
|
+
var autocomplete = _a.autocomplete, inputValue = _a.inputValue, selectedValue = _a.selectedValue, matches = _a.matches, matchingOptions = _a.matchingOptions, setMatchingOptions = _a.setMatchingOptions, children = _a.children;
|
|
4176
|
+
var Provider = ComboboxContext.Provider;
|
|
4177
|
+
var contextValue = React.useMemo(function () { return ({
|
|
4178
|
+
autocomplete: autocomplete,
|
|
4179
|
+
inputValue: inputValue,
|
|
4180
|
+
selectedValue: selectedValue,
|
|
4181
|
+
matches: typeof matches === 'function' && !!inputValue
|
|
4182
|
+
? function (value) { return matches(inputValue, value); }
|
|
4183
|
+
: true,
|
|
4184
|
+
matchingOptions: matchingOptions,
|
|
4185
|
+
setMatchingOptions: setMatchingOptions
|
|
4186
|
+
}); }, [
|
|
4187
|
+
autocomplete,
|
|
4188
|
+
inputValue,
|
|
4189
|
+
selectedValue,
|
|
4190
|
+
matches,
|
|
4191
|
+
matchingOptions,
|
|
4192
|
+
setMatchingOptions
|
|
4193
|
+
]);
|
|
4194
|
+
return React__default["default"].createElement(Provider, { value: contextValue }, children);
|
|
4195
|
+
}
|
|
4196
|
+
function useComboboxContext() {
|
|
4197
|
+
return React.useContext(ComboboxContext);
|
|
4198
|
+
}
|
|
4199
|
+
|
|
4200
|
+
/**
|
|
4201
|
+
* When a component needs to track intersection via a ref, useIntersectionRef
|
|
4202
|
+
* will return a ref object containing the results from IntersectionObserver
|
|
4203
|
+
* for the current intersection entry.
|
|
4204
|
+
*
|
|
4205
|
+
* @example
|
|
4206
|
+
* const elementRef = useRef<HTMLElement>()
|
|
4207
|
+
* const intersectionRef = useIntersectionRef<HTMLElement>(elementRef)
|
|
4208
|
+
* return <span ref={elementRef}>...</span>
|
|
4209
|
+
*/
|
|
4210
|
+
function useIntersectionRef(element, intersectionObserverOptions) {
|
|
4211
|
+
if (intersectionObserverOptions === void 0) { intersectionObserverOptions = {
|
|
4212
|
+
root: null,
|
|
4213
|
+
threshold: 1.0
|
|
4214
|
+
}; }
|
|
4215
|
+
var intersectionRef = React.useRef(null);
|
|
4216
|
+
React.useEffect(function () {
|
|
4217
|
+
// istanbul ignore else
|
|
4218
|
+
if ('IntersectionObserver' in globalThis &&
|
|
4219
|
+
typeof IntersectionObserver === 'function') {
|
|
4220
|
+
if (typeof element === 'undefined' || element === null) {
|
|
4221
|
+
return;
|
|
4222
|
+
}
|
|
4223
|
+
if (!(element instanceof HTMLElement) &&
|
|
4224
|
+
!(element.current instanceof HTMLElement)) {
|
|
4225
|
+
console.warn('An element or ref was provided to useIntersectionRef that was not an HTMLElement.');
|
|
4226
|
+
return;
|
|
4227
|
+
}
|
|
4228
|
+
var handleIntersection = function (_a) {
|
|
4229
|
+
var _b = tslib.__read(_a, 1), entry = _b[0];
|
|
4230
|
+
intersectionRef.current = entry;
|
|
4231
|
+
};
|
|
4232
|
+
var observer_1 = new IntersectionObserver(handleIntersection, intersectionObserverOptions);
|
|
4233
|
+
observer_1.observe(element instanceof HTMLElement ? element : element.current);
|
|
4234
|
+
return function () {
|
|
4235
|
+
observer_1.disconnect();
|
|
4236
|
+
};
|
|
4237
|
+
}
|
|
4238
|
+
}, [element]);
|
|
4239
|
+
return intersectionRef;
|
|
4240
|
+
}
|
|
4241
|
+
|
|
4242
|
+
var ComboboxMatch = function (_a) {
|
|
4243
|
+
var text = _a.children;
|
|
4244
|
+
var inputValue = useComboboxContext().inputValue;
|
|
4245
|
+
if (!(inputValue === null || inputValue === void 0 ? void 0 : inputValue.length)) {
|
|
4246
|
+
return React__default["default"].createElement("span", null, text);
|
|
4247
|
+
}
|
|
4248
|
+
var matchStart = text.toLowerCase().indexOf(inputValue === null || inputValue === void 0 ? void 0 : inputValue.toLowerCase());
|
|
4249
|
+
if (matchStart === -1) {
|
|
4250
|
+
return React__default["default"].createElement("span", null, text);
|
|
4251
|
+
}
|
|
4252
|
+
var matchLength = inputValue.length;
|
|
4253
|
+
var matchBefore = text.substring(0, matchStart);
|
|
4254
|
+
var match = text.substring(matchStart, matchLength + matchStart);
|
|
4255
|
+
var matchAfter = text.substring(matchStart + matchLength);
|
|
4256
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
4257
|
+
React__default["default"].createElement("span", null, matchBefore),
|
|
4258
|
+
React__default["default"].createElement("em", { className: "ComboboxOption__match" }, match),
|
|
4259
|
+
React__default["default"].createElement("span", null, matchAfter)));
|
|
4260
|
+
};
|
|
4261
|
+
var ComboboxOption = React.forwardRef(function (_a, ref) {
|
|
4262
|
+
var className = _a.className, children = _a.children, disabled = _a.disabled, propId = _a.id, description = _a.description, propValue = _a.value, props = tslib.__rest(_a, ["className", "children", "disabled", "id", "description", "value"]);
|
|
4263
|
+
var _b = tslib.__read(propId ? [propId] : nextId.useId(1, 'combobox-option'), 1), id = _b[0];
|
|
4264
|
+
var _c = useListboxContext(), selected = _c.selected, active = _c.active;
|
|
4265
|
+
var _d = useComboboxContext(), matches = _d.matches, setMatchingOptions = _d.setMatchingOptions;
|
|
4266
|
+
var comboboxOptionRef = useSharedRef(ref);
|
|
4267
|
+
var intersectionRef = useIntersectionRef(comboboxOptionRef, {
|
|
4268
|
+
root: null,
|
|
4269
|
+
threshold: 1.0
|
|
4270
|
+
});
|
|
4271
|
+
var isActive = !!(active === null || active === void 0 ? void 0 : active.element) && active.element === comboboxOptionRef.current;
|
|
4272
|
+
var isSelected = !!(selected === null || selected === void 0 ? void 0 : selected.element) && selected.element === comboboxOptionRef.current;
|
|
4273
|
+
var isMatching = (typeof matches === 'boolean' && matches) ||
|
|
4274
|
+
(typeof matches === 'function' && matches(children));
|
|
4275
|
+
// istanbul ignore next
|
|
4276
|
+
React.useLayoutEffect(function () {
|
|
4277
|
+
var intersectionEntry = intersectionRef.current;
|
|
4278
|
+
if (!intersectionEntry || !isActive) {
|
|
4279
|
+
return;
|
|
4280
|
+
}
|
|
4281
|
+
var rect = comboboxOptionRef.current.getBoundingClientRect();
|
|
4282
|
+
var isInViewport = rect.top >= 0 &&
|
|
4283
|
+
rect.left >= 0 &&
|
|
4284
|
+
rect.bottom <= window.innerHeight &&
|
|
4285
|
+
rect.right <= window.innerWidth;
|
|
4286
|
+
if (!isInViewport || !intersectionEntry.isIntersecting) {
|
|
4287
|
+
comboboxOptionRef.current.scrollIntoView({
|
|
4288
|
+
inline: 'nearest',
|
|
4289
|
+
block: rect.top <= 0 ? 'end' : 'nearest'
|
|
4290
|
+
});
|
|
4291
|
+
}
|
|
4292
|
+
}, [isActive]);
|
|
4293
|
+
React.useEffect(function () {
|
|
4294
|
+
if (isMatching) {
|
|
4295
|
+
setMatchingOptions(function (options) {
|
|
4296
|
+
return new Map(options.set(comboboxOptionRef.current, {
|
|
4297
|
+
value: children,
|
|
4298
|
+
selected: isSelected
|
|
4299
|
+
}));
|
|
4300
|
+
});
|
|
4301
|
+
}
|
|
4302
|
+
return function () {
|
|
4303
|
+
setMatchingOptions(function (options) {
|
|
4304
|
+
options.forEach(function (_value, element) {
|
|
4305
|
+
// istanbul ignore else
|
|
4306
|
+
if (!element.isConnected) {
|
|
4307
|
+
options.delete(element);
|
|
4308
|
+
}
|
|
4309
|
+
});
|
|
4310
|
+
return new Map(options);
|
|
4311
|
+
});
|
|
4312
|
+
};
|
|
4313
|
+
}, [isMatching, isSelected]);
|
|
4314
|
+
if (!isMatching) {
|
|
4315
|
+
return null;
|
|
4316
|
+
}
|
|
4317
|
+
return (React__default["default"].createElement(ListboxOption, tslib.__assign({ as: "li", className: classNames__default["default"]('ComboboxOption', className, {
|
|
4318
|
+
'ComboboxOption--disabled': disabled
|
|
4319
|
+
}), activeClass: "ComboboxOption--active", ref: comboboxOptionRef, disabled: disabled, id: id, value: propValue }, props),
|
|
4320
|
+
React__default["default"].createElement("span", null,
|
|
4321
|
+
React__default["default"].createElement(ComboboxMatch, null, children),
|
|
4322
|
+
description && (React__default["default"].createElement("div", { className: "ComboboxOption__description" }, description))),
|
|
4323
|
+
isSelected ? React__default["default"].createElement(Icon, { type: "check-solid" }) : null));
|
|
4324
|
+
});
|
|
4325
|
+
ComboboxOption.displayName = 'ComboboxOption';
|
|
4326
|
+
|
|
4327
|
+
// Event Keys
|
|
4328
|
+
var _a = tslib.__read(['Enter', 'Escape', 'Home', 'End'], 4), Enter = _a[0], Escape = _a[1], Home = _a[2], End = _a[3];
|
|
4329
|
+
var defaultAutoCompleteMatches = function (inputValue, value) {
|
|
4330
|
+
// istanbul ignore if
|
|
4331
|
+
if (!value) {
|
|
4332
|
+
return true;
|
|
4333
|
+
}
|
|
4334
|
+
return value.toLowerCase().includes(inputValue.toLowerCase());
|
|
4335
|
+
};
|
|
4336
|
+
var ComboboxNoResults = function (_a) {
|
|
4337
|
+
var children = _a.children;
|
|
4338
|
+
return (React__default["default"].createElement("div", { className: "ComboboxListbox__empty", role: "alert", "aria-live": "polite" }, children || 'No results found.'));
|
|
4339
|
+
};
|
|
4340
|
+
var Combobox = React.forwardRef(function (_a, ref) {
|
|
4341
|
+
var propId = _a.id, className = _a.className, label = _a.label, children = _a.children, _b = _a.options, options = _b === void 0 ? [] : _b, propValue = _a.value, defaultValue = _a.defaultValue, _c = _a.requiredText, requiredText = _c === void 0 ? 'Required' : _c, error = _a.error, _d = _a.autocomplete, autocomplete = _d === void 0 ? 'manual' : _d, onSelectionChange = _a.onSelectionChange, onActiveChange = _a.onActiveChange, onChange = _a.onChange, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onBlur = _a.onBlur, renderNoResults = _a.renderNoResults, portal = _a.portal, props = tslib.__rest(_a, ["id", "className", "label", "children", "options", "value", "defaultValue", "requiredText", "error", "autocomplete", "onSelectionChange", "onActiveChange", "onChange", "onKeyDown", "onFocus", "onBlur", "renderNoResults", "portal"]);
|
|
4342
|
+
var _e = tslib.__read(React.useState(defaultValue || propValue || ''), 2), value = _e[0], setValue = _e[1];
|
|
4343
|
+
var _f = tslib.__read(React.useState(new Map()), 2), matchingOptions = _f[0], setMatchingOptions = _f[1];
|
|
4344
|
+
var _g = tslib.__read(React.useState(value || ''), 2), selectedValue = _g[0], setSelectedValue = _g[1];
|
|
4345
|
+
var _h = tslib.__read(React.useState(false), 2), open = _h[0], setOpen = _h[1];
|
|
4346
|
+
var _j = tslib.__read(React.useState(null), 2), activeDescendant = _j[0], setActiveDescendant = _j[1];
|
|
4347
|
+
var _k = tslib.__read(propId ? [propId] : nextId.useId(1, 'combobox'), 1), id = _k[0];
|
|
4348
|
+
var comboboxRef = useSharedRef(ref);
|
|
4349
|
+
var inputRef = React.useRef(null);
|
|
4350
|
+
var listboxRef = React.useRef(null);
|
|
4351
|
+
var isControlled = typeof propValue !== 'undefined';
|
|
4352
|
+
var isRequired = !!props.required;
|
|
4353
|
+
var isAutoComplete = autocomplete !== 'none';
|
|
4354
|
+
var hasError = !!error;
|
|
4355
|
+
var comboboxOptions = children ||
|
|
4356
|
+
options.map(function (option, index) { return (React__default["default"].createElement(ComboboxOption, { key: option.key || index, id: "".concat(id, "-option-").concat(index + 1), description: option.description }, option.label)); });
|
|
4357
|
+
var triggerListboxKeyDown = React__default["default"].useCallback(function (key) {
|
|
4358
|
+
var _a;
|
|
4359
|
+
(_a = listboxRef.current) === null || _a === void 0 ? void 0 : _a.dispatchEvent(new KeyboardEvent('keydown', {
|
|
4360
|
+
key: key,
|
|
4361
|
+
bubbles: true,
|
|
4362
|
+
cancelable: true
|
|
4363
|
+
}));
|
|
4364
|
+
}, [listboxRef]);
|
|
4365
|
+
React.useEffect(function () {
|
|
4366
|
+
if (!isAutoComplete) {
|
|
4367
|
+
return;
|
|
4368
|
+
}
|
|
4369
|
+
if (!open && selectedValue && value !== selectedValue) {
|
|
4370
|
+
setValue(selectedValue);
|
|
4371
|
+
}
|
|
4372
|
+
if (!open) {
|
|
4373
|
+
setActiveDescendant(null);
|
|
4374
|
+
}
|
|
4375
|
+
if (open && autocomplete === 'automatic' && !selectedValue) {
|
|
4376
|
+
// Fire an Home keydown event on listbox to ensure the first item is selected
|
|
4377
|
+
triggerListboxKeyDown(Home);
|
|
4378
|
+
}
|
|
4379
|
+
}, [open]);
|
|
4380
|
+
React.useEffect(function () {
|
|
4381
|
+
if (autocomplete === 'manual') {
|
|
4382
|
+
setActiveDescendant(null);
|
|
4383
|
+
}
|
|
4384
|
+
else if (autocomplete === 'automatic' &&
|
|
4385
|
+
matchingOptions.size &&
|
|
4386
|
+
!selectedValue) {
|
|
4387
|
+
// Fire a home keydown event on listbox to ensure the first item is selected
|
|
4388
|
+
requestAnimationFrame(function () {
|
|
4389
|
+
triggerListboxKeyDown(Home);
|
|
4390
|
+
});
|
|
4391
|
+
}
|
|
4392
|
+
}, [matchingOptions]);
|
|
4393
|
+
var handleFocus = React.useCallback(function (event) {
|
|
4394
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
4395
|
+
// istanbul ignore else
|
|
4396
|
+
if (!event.defaultPrevented) {
|
|
4397
|
+
setOpen(true);
|
|
4398
|
+
if (selectedValue && value === selectedValue && isAutoComplete) {
|
|
4399
|
+
setValue('');
|
|
4400
|
+
}
|
|
4401
|
+
}
|
|
4402
|
+
}, [onFocus, value, selectedValue]);
|
|
4403
|
+
var handleInputClick = React.useCallback(function (event) {
|
|
4404
|
+
var _a;
|
|
4405
|
+
setOpen(true);
|
|
4406
|
+
if (selectedValue && value === selectedValue && isAutoComplete) {
|
|
4407
|
+
setValue('');
|
|
4408
|
+
}
|
|
4409
|
+
if (event.target !== inputRef.current) {
|
|
4410
|
+
// ensure focus is set on the input field
|
|
4411
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
4412
|
+
}
|
|
4413
|
+
}, [value, selectedValue]);
|
|
4414
|
+
var handleComboboxOptionMouseDown = React.useCallback(function (event) {
|
|
4415
|
+
// prevent blur from triggering when activating combobox options
|
|
4416
|
+
event.preventDefault();
|
|
4417
|
+
}, []);
|
|
4418
|
+
var handleComboboxOptionClick = React.useCallback(function () {
|
|
4419
|
+
var _a;
|
|
4420
|
+
// maintain focus on the input
|
|
4421
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
4422
|
+
}, []);
|
|
4423
|
+
var handleBlur = React.useCallback(function (event) {
|
|
4424
|
+
var _a;
|
|
4425
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
4426
|
+
setOpen(false);
|
|
4427
|
+
if (autocomplete === 'automatic' && activeDescendant) {
|
|
4428
|
+
var stringValue = ((_a = activeDescendant.value) === null || _a === void 0 ? void 0 : _a.toString()) ||
|
|
4429
|
+
/* istanbul ignore next: default value */ '';
|
|
4430
|
+
setValue(stringValue);
|
|
4431
|
+
setSelectedValue(stringValue);
|
|
4432
|
+
}
|
|
4433
|
+
}, [autocomplete, activeDescendant, onBlur]);
|
|
4434
|
+
var handleKeyDown = React.useCallback(function (event) {
|
|
4435
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
4436
|
+
var enterKeypress = event.key === Enter;
|
|
4437
|
+
var escKeypress = event.key === Escape;
|
|
4438
|
+
var arrowKeypress = ['ArrowDown', 'ArrowUp'].includes(event.key);
|
|
4439
|
+
if ([Home, End].includes(event.key)) {
|
|
4440
|
+
// prevent the page from scrolling and allow start/end option activation
|
|
4441
|
+
event.preventDefault();
|
|
4442
|
+
}
|
|
4443
|
+
if (escKeypress) {
|
|
4444
|
+
setOpen(false);
|
|
4445
|
+
return;
|
|
4446
|
+
}
|
|
4447
|
+
// Selection should not open the listbox or be
|
|
4448
|
+
// forwarded to the listbox component when closed
|
|
4449
|
+
if (enterKeypress && !open) {
|
|
4450
|
+
return;
|
|
4451
|
+
}
|
|
4452
|
+
setOpen(true);
|
|
4453
|
+
if (!open && arrowKeypress && selectedValue && isAutoComplete) {
|
|
4454
|
+
// If the user opens the combobox again with a selected value
|
|
4455
|
+
// just clear out the field to restore filtering capabilities
|
|
4456
|
+
setValue('');
|
|
4457
|
+
}
|
|
4458
|
+
// Space should not trigger selection since the user could be typing
|
|
4459
|
+
// a value for autocompletion. Additionally when not open and there's
|
|
4460
|
+
// an active descendent we do not want to forward keydown events.
|
|
4461
|
+
if (event.key === ' ' ||
|
|
4462
|
+
(!open && activeDescendant) ||
|
|
4463
|
+
(enterKeypress && !activeDescendant)) {
|
|
4464
|
+
return;
|
|
4465
|
+
}
|
|
4466
|
+
// forward input events to listbox
|
|
4467
|
+
triggerListboxKeyDown(event.key);
|
|
4468
|
+
// Close combobox with keyboard selections
|
|
4469
|
+
if (enterKeypress && activeDescendant) {
|
|
4470
|
+
setOpen(false);
|
|
4471
|
+
}
|
|
4472
|
+
}, [onKeyDown, isAutoComplete, open, selectedValue, activeDescendant]);
|
|
4473
|
+
React.useEffect(function () {
|
|
4474
|
+
if (typeof propValue !== 'undefined') {
|
|
4475
|
+
setValue(propValue);
|
|
4476
|
+
}
|
|
4477
|
+
}, [propValue]);
|
|
4478
|
+
var handleChange = React.useCallback(function (event) {
|
|
4479
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
4480
|
+
// istanbul ignore else
|
|
4481
|
+
if (!isControlled) {
|
|
4482
|
+
setValue(event.target.value);
|
|
4483
|
+
}
|
|
4484
|
+
}, [isControlled, onChange]);
|
|
4485
|
+
var handleSelectionChange = React.useCallback(function (_a) {
|
|
4486
|
+
var target = _a.target, listboxValue = _a.value, previousValue = _a.previousValue;
|
|
4487
|
+
var stringValue = (listboxValue === null || listboxValue === void 0 ? void 0 : listboxValue.toString()) || /* istanbul ignore next */ '';
|
|
4488
|
+
// istanbul ignore else
|
|
4489
|
+
if (!isControlled) {
|
|
4490
|
+
setValue(stringValue);
|
|
4491
|
+
}
|
|
4492
|
+
setSelectedValue(stringValue);
|
|
4493
|
+
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange({
|
|
4494
|
+
target: target,
|
|
4495
|
+
value: stringValue,
|
|
4496
|
+
previousValue: previousValue === null || previousValue === void 0 ? void 0 : previousValue.toString()
|
|
4497
|
+
});
|
|
4498
|
+
setOpen(false);
|
|
4499
|
+
}, [isControlled, onSelectionChange]);
|
|
4500
|
+
var handleActiveChange = React.useCallback(function (option) {
|
|
4501
|
+
// istanbul ignore else
|
|
4502
|
+
if (option.element) {
|
|
4503
|
+
setActiveDescendant(option);
|
|
4504
|
+
}
|
|
4505
|
+
onActiveChange === null || onActiveChange === void 0 ? void 0 : onActiveChange(option);
|
|
4506
|
+
}, []);
|
|
4507
|
+
var NoMatchingOptions = React__default["default"].useMemo(function () {
|
|
4508
|
+
return React__default["default"].isValidElement(renderNoResults)
|
|
4509
|
+
? function () { return React__default["default"].createElement(ComboboxNoResults, null, renderNoResults); }
|
|
4510
|
+
: typeof renderNoResults === 'function'
|
|
4511
|
+
? function () { return React__default["default"].createElement(ComboboxNoResults, null, renderNoResults()); }
|
|
4512
|
+
: ComboboxNoResults;
|
|
4513
|
+
}, [renderNoResults]);
|
|
4514
|
+
var noMatchingOptions = !!(value === null || value === void 0 ? void 0 : value.length) && !matchingOptions.size && (React__default["default"].createElement(NoMatchingOptions, null));
|
|
4515
|
+
var comboboxListbox = (React__default["default"].createElement(Listbox, { className: classNames__default["default"]('Combobox__listbox', {
|
|
4516
|
+
'Combobox__listbox--open': open
|
|
4517
|
+
}), role: "listbox", "aria-labelledby": "".concat(id, "-label"), id: "".concat(id, "-listbox"), value: selectedValue, onMouseDown: handleComboboxOptionMouseDown, onClick: handleComboboxOptionClick, onSelectionChange: handleSelectionChange, onActiveChange: handleActiveChange, ref: listboxRef, tabIndex: undefined, "aria-activedescendant": "" },
|
|
4518
|
+
comboboxOptions,
|
|
4519
|
+
noMatchingOptions));
|
|
4520
|
+
return (React__default["default"].createElement("div", { id: id, className: classNames__default["default"]('Combobox', className), ref: comboboxRef },
|
|
4521
|
+
React__default["default"].createElement("label", { className: classNames__default["default"]('Field__label', {
|
|
4522
|
+
'Field__label--is-required': isRequired,
|
|
4523
|
+
'Field__label--has-error': hasError
|
|
4524
|
+
}), id: "".concat(id, "-label"), htmlFor: "".concat(id, "-input") },
|
|
4525
|
+
React__default["default"].createElement("span", null, label),
|
|
4526
|
+
isRequired && (React__default["default"].createElement("span", { className: "Field__required-text" }, requiredText))),
|
|
4527
|
+
React__default["default"].createElement("div", { className: classNames__default["default"]('Combobox__input', {
|
|
4528
|
+
'Combobox__input--error': hasError
|
|
4529
|
+
}),
|
|
4530
|
+
// We're handling click here to open the listbox when the wrapping element is clicked,
|
|
4531
|
+
// there's already keyboard handlers to open the listbox on the input element
|
|
4532
|
+
onClick: handleInputClick },
|
|
4533
|
+
React__default["default"].createElement("input", tslib.__assign({ type: "text", id: "".concat(id, "-input"), ref: inputRef, value: value, role: "combobox", "aria-autocomplete": !isAutoComplete ? 'none' : 'list', "aria-controls": "".concat(id, "-listbox"), "aria-expanded": open, "aria-haspopup": "listbox", "aria-activedescendant": open && activeDescendant ? activeDescendant.element.id : undefined }, props, { onChange: handleChange, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: handleBlur })),
|
|
4534
|
+
React__default["default"].createElement("span", { className: "Combobox__arrow" })),
|
|
4535
|
+
React__default["default"].createElement(ComboboxProvider, { autocomplete: autocomplete, inputValue: value, selectedValue: selectedValue, matches: !isAutoComplete || defaultAutoCompleteMatches, matchingOptions: matchingOptions, setMatchingOptions: setMatchingOptions }, portal
|
|
4536
|
+
? reactDom.createPortal(comboboxListbox, portal instanceof HTMLElement
|
|
4537
|
+
? portal
|
|
4538
|
+
: portal.current ||
|
|
4539
|
+
/* istanbul ignore next: default fallback value */ document.body)
|
|
4540
|
+
: comboboxListbox),
|
|
4541
|
+
hasError && (React__default["default"].createElement("div", { className: "Error", id: "".concat(id, "-error") }, error))));
|
|
4542
|
+
});
|
|
4543
|
+
Combobox.displayName = 'Combobox';
|
|
4544
|
+
|
|
4545
|
+
var ComboboxGroup = React.forwardRef(function (_a, ref) {
|
|
4546
|
+
var className = _a.className, children = _a.children, label = _a.label, props = tslib.__rest(_a, ["className", "children", "label"]);
|
|
4547
|
+
var _b = useComboboxContext(), inputValue = _b.inputValue, autocomplete = _b.autocomplete, matchingOptions = _b.matchingOptions;
|
|
4548
|
+
var comboboxGroupRef = useSharedRef(ref);
|
|
4549
|
+
// istanbul ignore next
|
|
4550
|
+
var showGroup = React.useMemo(function () {
|
|
4551
|
+
if (autocomplete === 'none' || !(inputValue === null || inputValue === void 0 ? void 0 : inputValue.length)) {
|
|
4552
|
+
return true;
|
|
4553
|
+
}
|
|
4554
|
+
var elements = Array.from(matchingOptions.keys());
|
|
4555
|
+
return !!elements.find(function (element) { var _a; return (_a = comboboxGroupRef.current) === null || _a === void 0 ? void 0 : _a.contains(element); });
|
|
4556
|
+
}, [inputValue, autocomplete, matchingOptions]);
|
|
4557
|
+
return (React__default["default"].createElement(ListboxGroup, tslib.__assign({ as: "ul", className: classNames__default["default"]('ComboboxGroup', className, {
|
|
4558
|
+
'ComboboxGroup--hidden': !showGroup
|
|
4559
|
+
}), "aria-hidden": !showGroup, ref: comboboxGroupRef, label: label, groupLabelProps: { className: 'ComboboxGroup__label' } }, props), children));
|
|
4560
|
+
});
|
|
4561
|
+
ComboboxGroup.displayName = 'ComboboxGroup';
|
|
4562
|
+
|
|
4563
|
+
var PromptPopoverContent = function (_a) {
|
|
4564
|
+
var onClose = _a.onClose, _b = _a.applyButtonText, applyButtonText = _b === void 0 ? 'Apply' : _b, onApply = _a.onApply, _c = _a.closeButtonText, closeButtonText = _c === void 0 ? 'Close' : _c, infoText = _a.infoText, infoTextId = _a.infoTextId;
|
|
4565
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
4566
|
+
React__default["default"].createElement("span", { id: infoTextId }, infoText),
|
|
4567
|
+
React__default["default"].createElement(Button, { className: "Popover__apply", onClick: onApply, thin: true }, applyButtonText),
|
|
4568
|
+
React__default["default"].createElement(Button, { className: "Popover__close", variant: "secondary", onClick: onClose, thin: true }, closeButtonText)));
|
|
4569
|
+
};
|
|
4570
|
+
var Popover = React.forwardRef(function (_a, ref) {
|
|
4571
|
+
var propId = _a.id, _b = _a.placement, initialPlacement = _b === void 0 ? 'auto' : _b, children = _a.children, portal = _a.portal, target = _a.target, _c = _a.variant, variant = _c === void 0 ? 'custom' : _c, _d = _a.show, show = _d === void 0 ? false : _d, onClose = _a.onClose, className = _a.className, applyButtonText = _a.applyButtonText, closeButtonText = _a.closeButtonText, infoText = _a.infoText, onApply = _a.onApply, props = tslib.__rest(_a, ["id", "placement", "children", "portal", "target", "variant", "show", "onClose", "className", "applyButtonText", "closeButtonText", "infoText", "onApply"]);
|
|
4572
|
+
var _e = tslib.__read(propId ? [propId] : nextId.useId(1, 'popover'), 1), id = _e[0];
|
|
4573
|
+
var _f = tslib.__read(React.useState(null), 2), targetElement = _f[0], setTargetElement = _f[1];
|
|
4574
|
+
var _g = tslib.__read(React.useState(null), 2), isolator = _g[0], setIsolator = _g[1];
|
|
4575
|
+
var popoverRef = useSharedRef(ref);
|
|
4576
|
+
var _h = tslib.__read(React.useState(null), 2), arrowElement = _h[0], setArrowElement = _h[1];
|
|
4577
|
+
var _j = reactPopper.usePopper(targetElement, popoverRef === null || popoverRef === void 0 ? void 0 : popoverRef.current, {
|
|
4578
|
+
placement: initialPlacement,
|
|
4579
|
+
modifiers: [
|
|
4580
|
+
{ name: 'preventOverflow', options: { padding: 8 } },
|
|
4581
|
+
{ name: 'flip' },
|
|
4582
|
+
{ name: 'offset', options: { offset: [0, 8] } },
|
|
4583
|
+
{ name: 'arrow', options: { padding: 5, element: arrowElement } }
|
|
4584
|
+
]
|
|
4585
|
+
}), styles = _j.styles, attributes = _j.attributes;
|
|
4586
|
+
var placement = (attributes.popper &&
|
|
4587
|
+
attributes.popper['data-popper-placement']) ||
|
|
4588
|
+
initialPlacement;
|
|
4589
|
+
var additionalProps = variant === 'prompt' ? { 'aria-labelledby': "".concat(id, "-label") } : {};
|
|
4590
|
+
// Keep targetElement in sync with target prop
|
|
4591
|
+
React.useEffect(function () {
|
|
4592
|
+
var targetElement = target && 'current' in target ? target.current : target;
|
|
4593
|
+
setTargetElement(targetElement);
|
|
4594
|
+
}, [target]);
|
|
4595
|
+
React.useEffect(function () {
|
|
4596
|
+
return function () {
|
|
4597
|
+
isolator === null || isolator === void 0 ? void 0 : isolator.deactivate();
|
|
4598
|
+
};
|
|
4599
|
+
}, []);
|
|
4600
|
+
React.useEffect(function () {
|
|
4601
|
+
if (!isolator)
|
|
4602
|
+
return;
|
|
4603
|
+
if (show) {
|
|
4604
|
+
isolator.activate();
|
|
4605
|
+
}
|
|
4606
|
+
else {
|
|
4607
|
+
isolator.deactivate();
|
|
4608
|
+
}
|
|
4609
|
+
return function () {
|
|
4610
|
+
isolator === null || isolator === void 0 ? void 0 : isolator.deactivate();
|
|
4611
|
+
};
|
|
4612
|
+
}, [show, isolator]);
|
|
4613
|
+
React.useEffect(function () {
|
|
4614
|
+
if (popoverRef.current)
|
|
4615
|
+
attachIsolator();
|
|
4616
|
+
}, [popoverRef.current]);
|
|
4617
|
+
React.useEffect(function () {
|
|
4618
|
+
if (show && popoverRef.current) {
|
|
4619
|
+
// Find the first focusable element inside the container
|
|
4620
|
+
var firstFocusableElement = popoverRef.current.querySelector(focusableSelector);
|
|
4621
|
+
if (firstFocusableElement instanceof HTMLElement) {
|
|
4622
|
+
firstFocusableElement.focus();
|
|
4623
|
+
}
|
|
4624
|
+
}
|
|
4625
|
+
targetElement === null || targetElement === void 0 ? void 0 : targetElement.setAttribute('aria-expanded', Boolean(show).toString());
|
|
4626
|
+
}, [show, popoverRef.current]);
|
|
4627
|
+
React.useEffect(function () {
|
|
4628
|
+
var handleEscape = function (event) {
|
|
4629
|
+
if (event.key === 'Escape' ||
|
|
4630
|
+
event.key === 'Esc' ||
|
|
4631
|
+
event.keyCode === 27) {
|
|
4632
|
+
handleClosePopover();
|
|
4633
|
+
}
|
|
4634
|
+
};
|
|
4635
|
+
if (show) {
|
|
4636
|
+
document.body.addEventListener('keyup', handleEscape);
|
|
4637
|
+
}
|
|
4638
|
+
else {
|
|
4639
|
+
document.body.removeEventListener('keyup', handleEscape);
|
|
4640
|
+
}
|
|
4641
|
+
return function () {
|
|
4642
|
+
document.body.removeEventListener('keyup', handleEscape);
|
|
4643
|
+
};
|
|
4644
|
+
}, [show]);
|
|
4645
|
+
React.useEffect(function () {
|
|
4646
|
+
var attrText = targetElement === null || targetElement === void 0 ? void 0 : targetElement.getAttribute('aria-controls');
|
|
4647
|
+
var hasPopupAttr = targetElement === null || targetElement === void 0 ? void 0 : targetElement.getAttribute('aria-haspopup');
|
|
4648
|
+
if (!(attrText === null || attrText === void 0 ? void 0 : attrText.includes(id)) && show) {
|
|
4649
|
+
targetElement === null || targetElement === void 0 ? void 0 : targetElement.setAttribute('aria-controls', id);
|
|
4650
|
+
}
|
|
4651
|
+
if (!hasPopupAttr) {
|
|
4652
|
+
targetElement === null || targetElement === void 0 ? void 0 : targetElement.setAttribute('aria-haspopup', 'true');
|
|
4653
|
+
}
|
|
4654
|
+
}, [targetElement, id, show]);
|
|
4655
|
+
var handleClickOutside = function () {
|
|
4656
|
+
if (show) {
|
|
4657
|
+
handleClosePopover();
|
|
4658
|
+
}
|
|
4659
|
+
};
|
|
4660
|
+
var attachIsolator = function () {
|
|
4661
|
+
if (popoverRef === null || popoverRef === void 0 ? void 0 : popoverRef.current) {
|
|
4662
|
+
setIsolator(new AriaIsolate(popoverRef === null || popoverRef === void 0 ? void 0 : popoverRef.current));
|
|
4663
|
+
}
|
|
4664
|
+
};
|
|
4665
|
+
var handleClosePopover = function () {
|
|
4666
|
+
isolator === null || isolator === void 0 ? void 0 : isolator.deactivate();
|
|
4667
|
+
if (show) {
|
|
4668
|
+
onClose();
|
|
4669
|
+
}
|
|
4670
|
+
};
|
|
4671
|
+
if (!show || !isBrowser())
|
|
4672
|
+
return null;
|
|
4673
|
+
return reactDom.createPortal(React__default["default"].createElement(FocusTrap__default["default"], { focusTrapOptions: {
|
|
4674
|
+
allowOutsideClick: true,
|
|
4675
|
+
fallbackFocus: '.Popover__borderLeft'
|
|
4676
|
+
} },
|
|
4677
|
+
React__default["default"].createElement(ClickOutsideListener, { onClickOutside: handleClickOutside },
|
|
4678
|
+
React__default["default"].createElement("div", tslib.__assign({ id: id, className: classNames__default["default"]('Popover', "Popover--".concat(placement), className, {
|
|
4679
|
+
'Popover--hidden': !show,
|
|
4680
|
+
'Popover--prompt': variant === 'prompt'
|
|
4681
|
+
}), ref: popoverRef, role: "dialog", style: styles.popper }, attributes.popper, props, additionalProps),
|
|
4682
|
+
React__default["default"].createElement("div", { className: "Popover__popoverArrow", ref: setArrowElement, style: styles.arrow }),
|
|
4683
|
+
React__default["default"].createElement("div", { className: "Popover__borderLeft" }),
|
|
4684
|
+
variant === 'prompt' ? (React__default["default"].createElement(PromptPopoverContent, { applyButtonText: applyButtonText, onApply: onApply, closeButtonText: closeButtonText, infoText: infoText || '', onClose: handleClosePopover, infoTextId: "".concat(id, "-label") })) : (children)))), (portal && 'current' in portal ? portal.current : portal) || document.body);
|
|
4685
|
+
});
|
|
4686
|
+
Popover.displayName = 'Popover';
|
|
4687
|
+
|
|
3946
4688
|
var LIGHT_THEME_CLASS = 'cauldron--theme-light';
|
|
3947
4689
|
var DARK_THEME_CLASS = 'cauldron--theme-dark';
|
|
3948
4690
|
var ThemeContext = React.createContext({
|
|
@@ -4033,6 +4775,9 @@ exports.ColumnHeader = ColumnHeader;
|
|
|
4033
4775
|
exports.ColumnLeft = ColumnLeft;
|
|
4034
4776
|
exports.ColumnList = ColumnList;
|
|
4035
4777
|
exports.ColumnRight = ColumnRight;
|
|
4778
|
+
exports.Combobox = Combobox;
|
|
4779
|
+
exports.ComboboxGroup = ComboboxGroup;
|
|
4780
|
+
exports.ComboboxOption = ComboboxOption;
|
|
4036
4781
|
exports.DescriptionDetails = DescriptionDetails;
|
|
4037
4782
|
exports.DescriptionList = DescriptionList;
|
|
4038
4783
|
exports.DescriptionListItem = DescriptionListItem;
|
|
@@ -4048,6 +4793,9 @@ exports.IssuePanel = IssuePanel;
|
|
|
4048
4793
|
exports.Layout = Layout;
|
|
4049
4794
|
exports.Line = Line;
|
|
4050
4795
|
exports.Link = Link;
|
|
4796
|
+
exports.Listbox = Listbox;
|
|
4797
|
+
exports.ListboxGroup = ListboxGroup;
|
|
4798
|
+
exports.ListboxOption = ListboxOption;
|
|
4051
4799
|
exports.Loader = Loader;
|
|
4052
4800
|
exports.LoaderOverlay = LoaderOverlay;
|
|
4053
4801
|
exports.Main = Main;
|
|
@@ -4071,6 +4819,7 @@ exports.PanelContent = PanelContent;
|
|
|
4071
4819
|
exports.PanelHeader = PanelHeader;
|
|
4072
4820
|
exports.PanelTrigger = PanelTrigger$1;
|
|
4073
4821
|
exports.Pointout = Pointout;
|
|
4822
|
+
exports.Popover = Popover;
|
|
4074
4823
|
exports.ProgressBar = ProgressBar;
|
|
4075
4824
|
exports.RadioCardGroup = RadioCardGroup;
|
|
4076
4825
|
exports.RadioGroup = RadioGroup;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MutableRefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* When a component needs to track intersection via a ref, useIntersectionRef
|
|
4
|
+
* will return a ref object containing the results from IntersectionObserver
|
|
5
|
+
* for the current intersection entry.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const elementRef = useRef<HTMLElement>()
|
|
9
|
+
* const intersectionRef = useIntersectionRef<HTMLElement>(elementRef)
|
|
10
|
+
* return <span ref={elementRef}>...</span>
|
|
11
|
+
*/
|
|
12
|
+
export default function useIntersectionRef<T extends HTMLElement>(element: T | MutableRefObject<T>, intersectionObserverOptions?: IntersectionObserverInit): MutableRefObject<IntersectionObserverEntry | null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deque/cauldron-react",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.1-canary.5921a8e6",
|
|
4
4
|
"description": "Fully accessible react components library for Deque Cauldron",
|
|
5
5
|
"homepage": "https://cauldron.dequelabs.com/",
|
|
6
6
|
"publishConfig": {
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"**/__tests__/demo/**/*.js"
|
|
111
111
|
],
|
|
112
112
|
"collectCoverageFrom": [
|
|
113
|
-
"**/src/**/*.tsx"
|
|
113
|
+
"**/src/**/*.{ts,tsx}"
|
|
114
114
|
],
|
|
115
115
|
"moduleNameMapper": {
|
|
116
116
|
"\\.(css|less)$": "<rootDir>/__tests__/styleMock.js",
|
|
@@ -119,4 +119,4 @@
|
|
|
119
119
|
"\\.svg$": "<rootDir>/__tests__/svgMock.js"
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
}
|
|
122
|
+
}
|