@deque/cauldron-react 6.20.2-canary.0e5ecb77 → 6.20.2-canary.1acc4c90
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.
|
@@ -21,6 +21,7 @@ interface BaseComboboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElem
|
|
|
21
21
|
renderNoResults?: (() => React.JSX.Element) | React.ReactElement;
|
|
22
22
|
portal?: React.RefObject<HTMLElement> | HTMLElement;
|
|
23
23
|
inputRef?: React.Ref<HTMLInputElement>;
|
|
24
|
+
description?: React.ReactNode;
|
|
24
25
|
}
|
|
25
26
|
interface SingleSelectComboboxProps extends BaseComboboxProps {
|
|
26
27
|
value?: ComboboxValue;
|
package/lib/index.js
CHANGED
|
@@ -1781,15 +1781,16 @@ var AnchoredOverlay = React.forwardRef(function (_a, refProp) {
|
|
|
1781
1781
|
? reactDom$1.autoPlacement({
|
|
1782
1782
|
alignment: getAutoAlignment(initialPlacement)
|
|
1783
1783
|
})
|
|
1784
|
-
: reactDom$1.flip(
|
|
1784
|
+
: reactDom$1.flip({
|
|
1785
|
+
fallbackAxisSideDirection: 'start'
|
|
1786
|
+
}),
|
|
1785
1787
|
reactDom$1.shift({ crossAxis: false })
|
|
1786
1788
|
].filter(Boolean),
|
|
1787
1789
|
elements: {
|
|
1788
|
-
reference: resolveElement(target)
|
|
1789
|
-
floating: ref.current
|
|
1790
|
+
reference: resolveElement(target)
|
|
1790
1791
|
},
|
|
1791
1792
|
whileElementsMounted: dom.autoUpdate
|
|
1792
|
-
}), floatingStyles = _f.floatingStyles, placement = _f.placement, middlewareData = _f.middlewareData;
|
|
1793
|
+
}), refs = _f.refs, floatingStyles = _f.floatingStyles, placement = _f.placement, middlewareData = _f.middlewareData;
|
|
1793
1794
|
useEscapeKey({
|
|
1794
1795
|
active: open,
|
|
1795
1796
|
capture: true,
|
|
@@ -1819,7 +1820,10 @@ var AnchoredOverlay = React.forwardRef(function (_a, refProp) {
|
|
|
1819
1820
|
});
|
|
1820
1821
|
}
|
|
1821
1822
|
}, [onShiftChange, (_b = middlewareData.shift) === null || _b === void 0 ? void 0 : _b.x, (_c = middlewareData.shift) === null || _c === void 0 ? void 0 : _c.y]);
|
|
1822
|
-
var AnchoredOverlayComponent = (React__default["default"].createElement(Component, tslib.__assign({ ref:
|
|
1823
|
+
var AnchoredOverlayComponent = (React__default["default"].createElement(Component, tslib.__assign({ ref: function (element) {
|
|
1824
|
+
refs.setFloating(element);
|
|
1825
|
+
ref.current = element;
|
|
1826
|
+
} }, props, { style: tslib.__assign(tslib.__assign({}, floatingStyles), style) }), children));
|
|
1823
1827
|
if (portal && !isBrowser()) {
|
|
1824
1828
|
return null;
|
|
1825
1829
|
}
|
|
@@ -3963,12 +3967,13 @@ function useComboboxContext() {
|
|
|
3963
3967
|
* const intersectionRef = useIntersectionRef<HTMLElement>(elementRef)
|
|
3964
3968
|
* return <span ref={elementRef}>...</span>
|
|
3965
3969
|
*/
|
|
3966
|
-
function useIntersectionRef(
|
|
3970
|
+
function useIntersectionRef(elementOrRef, intersectionObserverOptions) {
|
|
3967
3971
|
if (intersectionObserverOptions === void 0) { intersectionObserverOptions = {
|
|
3968
3972
|
root: null,
|
|
3969
3973
|
threshold: 1.0
|
|
3970
3974
|
}; }
|
|
3971
3975
|
var intersectionRef = React.useRef(null);
|
|
3976
|
+
var element = resolveElement(elementOrRef);
|
|
3972
3977
|
React.useEffect(function () {
|
|
3973
3978
|
// istanbul ignore else
|
|
3974
3979
|
if ('IntersectionObserver' in globalThis &&
|
|
@@ -3976,8 +3981,7 @@ function useIntersectionRef(element, intersectionObserverOptions) {
|
|
|
3976
3981
|
if (typeof element === 'undefined' || element === null) {
|
|
3977
3982
|
return;
|
|
3978
3983
|
}
|
|
3979
|
-
if (!(element instanceof HTMLElement)
|
|
3980
|
-
!(element.current instanceof HTMLElement)) {
|
|
3984
|
+
if (!(element instanceof HTMLElement)) {
|
|
3981
3985
|
console.warn('An element or ref was provided to useIntersectionRef that was not an HTMLElement.');
|
|
3982
3986
|
return;
|
|
3983
3987
|
}
|
|
@@ -3986,7 +3990,7 @@ function useIntersectionRef(element, intersectionObserverOptions) {
|
|
|
3986
3990
|
intersectionRef.current = entry;
|
|
3987
3991
|
};
|
|
3988
3992
|
var observer_1 = new IntersectionObserver(handleIntersection, intersectionObserverOptions);
|
|
3989
|
-
observer_1.observe(element
|
|
3993
|
+
observer_1.observe(element);
|
|
3990
3994
|
return function () {
|
|
3991
3995
|
observer_1.disconnect();
|
|
3992
3996
|
};
|
|
@@ -4156,7 +4160,7 @@ var ComboboxNoResults = function (_a) {
|
|
|
4156
4160
|
return (React__default["default"].createElement("div", { className: "ComboboxListbox__empty", role: "alert", "aria-live": "polite" }, children || 'No results found.'));
|
|
4157
4161
|
};
|
|
4158
4162
|
var Combobox = React.forwardRef(function (_a, ref) {
|
|
4159
|
-
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, propInputValue = _a.inputValue, defaultInputValue = _a.defaultInputValue, _c = _a.multiselect, multiselect = _c === void 0 ? false : _c, _d = _a.requiredText, requiredText = _d === void 0 ? 'Required' : _d, error = _a.error, _e = _a.autocomplete, autocomplete = _e === void 0 ? 'manual' : _e, onSelectionChange = _a.onSelectionChange, onActiveChange = _a.onActiveChange, onChange = _a.onChange, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onBlur = _a.onBlur, name = _a.name, renderNoResults = _a.renderNoResults, portal = _a.portal, _f = _a.inputRef, propInputRef = _f === void 0 ? null : _f, ariaDescribedby = _a["aria-describedby"], _g = _a.disabled, disabled = _g === void 0 ? false : _g, props = tslib.__rest(_a, ["id", "className", "label", "children", "options", "value", "defaultValue", "inputValue", "defaultInputValue", "multiselect", "requiredText", "error", "autocomplete", "onSelectionChange", "onActiveChange", "onChange", "onKeyDown", "onFocus", "onBlur", "name", "renderNoResults", "portal", "inputRef", 'aria-describedby', "disabled"]);
|
|
4163
|
+
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, propInputValue = _a.inputValue, defaultInputValue = _a.defaultInputValue, _c = _a.multiselect, multiselect = _c === void 0 ? false : _c, _d = _a.requiredText, requiredText = _d === void 0 ? 'Required' : _d, error = _a.error, _e = _a.autocomplete, autocomplete = _e === void 0 ? 'manual' : _e, onSelectionChange = _a.onSelectionChange, onActiveChange = _a.onActiveChange, onChange = _a.onChange, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onBlur = _a.onBlur, name = _a.name, renderNoResults = _a.renderNoResults, portal = _a.portal, _f = _a.inputRef, propInputRef = _f === void 0 ? null : _f, description = _a.description, ariaDescribedby = _a["aria-describedby"], _g = _a.disabled, disabled = _g === void 0 ? false : _g, props = tslib.__rest(_a, ["id", "className", "label", "children", "options", "value", "defaultValue", "inputValue", "defaultInputValue", "multiselect", "requiredText", "error", "autocomplete", "onSelectionChange", "onActiveChange", "onChange", "onKeyDown", "onFocus", "onBlur", "name", "renderNoResults", "portal", "inputRef", "description", 'aria-describedby', "disabled"]);
|
|
4160
4164
|
var _h = tslib.__read(React.useState(new Map()), 2), matchingOptions = _h[0], setMatchingOptions = _h[1];
|
|
4161
4165
|
var _j = tslib.__read(React.useState(function () {
|
|
4162
4166
|
var value = defaultValue || propValue;
|
|
@@ -4500,9 +4504,15 @@ var Combobox = React.forwardRef(function (_a, ref) {
|
|
|
4500
4504
|
comboboxOptions,
|
|
4501
4505
|
noMatchingOptions));
|
|
4502
4506
|
var errorId = "".concat(id, "-error");
|
|
4503
|
-
var
|
|
4504
|
-
|
|
4505
|
-
|
|
4507
|
+
var descriptionId = "".concat(id, "-description");
|
|
4508
|
+
var describedby = ariaDescribedby;
|
|
4509
|
+
if (description) {
|
|
4510
|
+
describedby = addIdRef(describedby, descriptionId);
|
|
4511
|
+
}
|
|
4512
|
+
if (error) {
|
|
4513
|
+
describedby = addIdRef(describedby, errorId);
|
|
4514
|
+
}
|
|
4515
|
+
var inputProps = tslib.__assign(tslib.__assign({}, props), { 'aria-describedby': describedby });
|
|
4506
4516
|
return (React__default["default"].createElement("div", { id: id, className: classNames__default["default"]('Combobox', { 'Combobox--multiselect': multiselect }, className), ref: comboboxRef },
|
|
4507
4517
|
name &&
|
|
4508
4518
|
formValues.map(function (formValue, index) { return (React__default["default"].createElement("input", { type: "hidden", key: index, name: name, value: formValue })); }),
|
|
@@ -4512,6 +4522,10 @@ var Combobox = React.forwardRef(function (_a, ref) {
|
|
|
4512
4522
|
}), id: "".concat(id, "-label"), htmlFor: "".concat(id, "-input") },
|
|
4513
4523
|
React__default["default"].createElement("span", null, label),
|
|
4514
4524
|
isRequired && (React__default["default"].createElement("span", { className: "Field__required-text", "aria-hidden": "true" }, requiredText))),
|
|
4525
|
+
description && (React__default["default"].createElement("span", { className: "Field__description", id: descriptionId }, description)),
|
|
4526
|
+
hasError && (React__default["default"].createElement("div", { className: "Field__error", id: errorId },
|
|
4527
|
+
React__default["default"].createElement(Icon, { type: "caution" }),
|
|
4528
|
+
error)),
|
|
4515
4529
|
React__default["default"].createElement(TextFieldWrapper, { className: classNames__default["default"]({ 'TextFieldWrapper--error': hasError }),
|
|
4516
4530
|
// We're handling click here to open the listbox when the wrapping element is clicked,
|
|
4517
4531
|
// there's already keyboard handlers to open the listbox on the input element
|
|
@@ -4541,8 +4555,7 @@ var Combobox = React.forwardRef(function (_a, ref) {
|
|
|
4541
4555
|
: portal.current ||
|
|
4542
4556
|
// eslint-disable-next-line ssr-friendly/no-dom-globals-in-react-fc
|
|
4543
4557
|
/* istanbul ignore next: default fallback value */ document.body)
|
|
4544
|
-
: comboboxListbox)
|
|
4545
|
-
hasError && (React__default["default"].createElement("div", { className: "Error", id: errorId }, error))));
|
|
4558
|
+
: comboboxListbox)));
|
|
4546
4559
|
});
|
|
4547
4560
|
Combobox.displayName = 'Combobox';
|
|
4548
4561
|
|
|
@@ -4621,25 +4634,25 @@ var Popover = React.forwardRef(function (_a, ref) {
|
|
|
4621
4634
|
targetElement === null || targetElement === void 0 ? void 0 : targetElement.setAttribute('aria-haspopup', 'true');
|
|
4622
4635
|
}
|
|
4623
4636
|
}, [targetElement, id, show]);
|
|
4624
|
-
var
|
|
4637
|
+
var handleClosePopover = function () {
|
|
4638
|
+
isolator === null || isolator === void 0 ? void 0 : isolator.deactivate();
|
|
4639
|
+
if (show) {
|
|
4640
|
+
onClose();
|
|
4641
|
+
}
|
|
4642
|
+
};
|
|
4643
|
+
var handleClickOutside = React.useCallback(function (e) {
|
|
4625
4644
|
if (e.target === targetElement) {
|
|
4626
4645
|
return;
|
|
4627
4646
|
}
|
|
4628
4647
|
if (show) {
|
|
4629
4648
|
handleClosePopover();
|
|
4630
4649
|
}
|
|
4631
|
-
};
|
|
4650
|
+
}, [show, targetElement, handleClosePopover]);
|
|
4632
4651
|
var attachIsolator = function () {
|
|
4633
4652
|
if (popoverRef === null || popoverRef === void 0 ? void 0 : popoverRef.current) {
|
|
4634
4653
|
setIsolator(new AriaIsolate(popoverRef === null || popoverRef === void 0 ? void 0 : popoverRef.current));
|
|
4635
4654
|
}
|
|
4636
4655
|
};
|
|
4637
|
-
var handleClosePopover = function () {
|
|
4638
|
-
isolator === null || isolator === void 0 ? void 0 : isolator.deactivate();
|
|
4639
|
-
if (show) {
|
|
4640
|
-
onClose();
|
|
4641
|
-
}
|
|
4642
|
-
};
|
|
4643
4656
|
useEscapeKey({
|
|
4644
4657
|
callback: handleClosePopover,
|
|
4645
4658
|
active: show
|
|
@@ -5054,10 +5067,10 @@ var ActionListSeparator = React.forwardRef(function (_a, ref) {
|
|
|
5054
5067
|
ActionListSeparator.displayName = 'ActionListSeparator';
|
|
5055
5068
|
|
|
5056
5069
|
var ActionListLinkItem = React.forwardRef(function (_a, ref) {
|
|
5057
|
-
var
|
|
5070
|
+
var className = _a.className;
|
|
5058
5071
|
// ActionListLinkItem should not be able to be "selected"
|
|
5059
5072
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5060
|
-
_a.selected; var props = tslib.__rest(_a, ["
|
|
5073
|
+
_a.selected; var props = tslib.__rest(_a, ["className", "selected"]);
|
|
5061
5074
|
var contextRole = useActionListContext().role;
|
|
5062
5075
|
var listItemRole = React.useMemo(function () {
|
|
5063
5076
|
if (contextRole === 'menu') {
|
|
@@ -5069,7 +5082,7 @@ var ActionListLinkItem = React.forwardRef(function (_a, ref) {
|
|
|
5069
5082
|
}
|
|
5070
5083
|
return undefined;
|
|
5071
5084
|
}, [contextRole]);
|
|
5072
|
-
return (React__default["default"].createElement(ActionListItem, tslib.__assign({
|
|
5085
|
+
return (React__default["default"].createElement(ActionListItem, tslib.__assign({ ref: ref, className: classNames__default["default"]('Link ActionListLinkItem', className), as: "a", role: listItemRole, tabIndex: listItemRole === 'menuitem' ? -1 : undefined }, props)));
|
|
5073
5086
|
});
|
|
5074
5087
|
ActionListLinkItem.displayName = 'ActionListLinkItem';
|
|
5075
5088
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MutableRefObject } from 'react';
|
|
2
|
+
import type { ElementOrRef } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* When a component needs to track intersection via a ref, useIntersectionRef
|
|
4
5
|
* will return a ref object containing the results from IntersectionObserver
|
|
@@ -9,4 +10,4 @@ import type { MutableRefObject } from 'react';
|
|
|
9
10
|
* const intersectionRef = useIntersectionRef<HTMLElement>(elementRef)
|
|
10
11
|
* return <span ref={elementRef}>...</span>
|
|
11
12
|
*/
|
|
12
|
-
export default function useIntersectionRef<T extends HTMLElement>(
|
|
13
|
+
export default function useIntersectionRef<T extends HTMLElement>(elementOrRef: ElementOrRef<T>, intersectionObserverOptions?: IntersectionObserverInit): MutableRefObject<IntersectionObserverEntry | null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deque/cauldron-react",
|
|
3
|
-
"version": "6.20.2-canary.
|
|
3
|
+
"version": "6.20.2-canary.1acc4c90",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Fully accessible react components library for Deque Cauldron",
|
|
6
6
|
"homepage": "https://cauldron.dequelabs.com/",
|