@deque/cauldron-react 3.0.1-canary.db7b06be → 3.0.1-canary.dda42da8
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/Address/index.d.ts +2 -2
- package/lib/components/IconButton/index.d.ts +10 -3
- package/lib/components/Loader/index.d.ts +2 -3
- package/lib/components/Panel/index.d.ts +1 -1
- package/lib/components/SideBar/SideBar.d.ts +1 -0
- package/lib/components/Stepper/index.d.ts +2 -0
- package/lib/components/Table/TableCell.d.ts +2 -2
- package/lib/components/Table/TableHeader.d.ts +2 -2
- package/lib/components/Tabs/Tabs.d.ts +5 -1
- package/lib/index.js +58 -26
- package/lib/utils/polymorphic-type/index.d.ts +40 -0
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ export declare const Address: {
|
|
|
13
13
|
};
|
|
14
14
|
declare type AddressLineProps = React.HTMLAttributes<HTMLElement>;
|
|
15
15
|
export declare const AddressLine: {
|
|
16
|
-
({ children, className, ...other }: AddressLineProps):
|
|
16
|
+
({ children, className, ...other }: AddressLineProps): JSX.Element | null;
|
|
17
17
|
displayName: string;
|
|
18
18
|
propTypes: {
|
|
19
19
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
@@ -26,7 +26,7 @@ interface AddressCityStateZipProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
26
26
|
zip: React.ReactNode;
|
|
27
27
|
}
|
|
28
28
|
export declare const AddressCityStateZip: {
|
|
29
|
-
({ city, state, zip, className, ...other }: AddressCityStateZipProps):
|
|
29
|
+
({ city, state, zip, className, ...other }: AddressCityStateZipProps): JSX.Element | null;
|
|
30
30
|
displayName: string;
|
|
31
31
|
propTypes: {
|
|
32
32
|
city: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as Polymorphic from '../../utils/polymorphic-type';
|
|
2
2
|
import { IconType } from '../Icon';
|
|
3
3
|
import { TooltipProps } from '../Tooltip';
|
|
4
|
-
export interface
|
|
4
|
+
export interface IconButtonOwnProps {
|
|
5
5
|
icon: IconType;
|
|
6
6
|
label: string;
|
|
7
7
|
tooltipPlacement?: TooltipProps['placement'];
|
|
@@ -9,5 +9,12 @@ export interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonEl
|
|
|
9
9
|
tooltipPortal?: TooltipProps['portal'];
|
|
10
10
|
variant?: 'primary' | 'secondary' | 'error';
|
|
11
11
|
}
|
|
12
|
-
declare
|
|
12
|
+
declare type PolymorphicIconButton = Polymorphic.ForwardRefComponent<'button', IconButtonOwnProps>;
|
|
13
|
+
/**
|
|
14
|
+
* Unfortunately, eslint does not recognize that this Polymorphic component has a displayName set
|
|
15
|
+
*
|
|
16
|
+
* We might be able to remove this if we upgrade eslint and associated plugins
|
|
17
|
+
* See: https://github.com/dequelabs/cauldron/issues/451
|
|
18
|
+
*/
|
|
19
|
+
declare const IconButton: PolymorphicIconButton;
|
|
13
20
|
export default IconButton;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
export interface LoaderProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
-
label
|
|
4
|
+
label?: string;
|
|
5
5
|
}
|
|
6
|
-
declare function Loader({
|
|
6
|
+
declare function Loader({ className, label, ...other }: LoaderProps): JSX.Element;
|
|
7
7
|
declare namespace Loader {
|
|
8
8
|
var propTypes: {
|
|
9
|
-
label: PropTypes.Requireable<string>;
|
|
10
9
|
className: PropTypes.Requireable<string>;
|
|
11
10
|
};
|
|
12
11
|
var displayName: string;
|
|
@@ -5,7 +5,7 @@ declare const Panel: {
|
|
|
5
5
|
({ className, title, actions, children }: {
|
|
6
6
|
className?: string | undefined;
|
|
7
7
|
title?: string | undefined;
|
|
8
|
-
actions?:
|
|
8
|
+
actions?: import("../../utils/polymorphic-type").ForwardRefComponent<"button", import("../IconButton").IconButtonOwnProps>[] | undefined;
|
|
9
9
|
children: React.ReactNode;
|
|
10
10
|
}): JSX.Element;
|
|
11
11
|
displayName: string;
|
|
@@ -9,6 +9,7 @@ interface StepWithChildren extends BaseStepProps {
|
|
|
9
9
|
}
|
|
10
10
|
interface StepWithTooltip extends BaseStepProps {
|
|
11
11
|
tooltip: React.ReactNode;
|
|
12
|
+
tooltipText: string;
|
|
12
13
|
}
|
|
13
14
|
declare type StepProps = StepWithChildren | StepWithTooltip;
|
|
14
15
|
export declare const Step: {
|
|
@@ -17,6 +18,7 @@ export declare const Step: {
|
|
|
17
18
|
propTypes: {
|
|
18
19
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
19
20
|
tooltip: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
21
|
+
tooltipText: PropTypes.Requireable<string>;
|
|
20
22
|
className: PropTypes.Requireable<string>;
|
|
21
23
|
};
|
|
22
24
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { TdHTMLAttributes } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
interface TableCellProps {
|
|
3
|
+
interface TableCellProps extends TdHTMLAttributes<HTMLTableCellElement> {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
className?: string;
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ThHTMLAttributes } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
interface TableHeaderProps {
|
|
3
|
+
interface TableHeaderProps extends ThHTMLAttributes<HTMLTableCellElement> {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
className?: string;
|
|
6
6
|
}
|
|
@@ -6,9 +6,13 @@ declare type TabsProps = {
|
|
|
6
6
|
initialActiveIndex?: number;
|
|
7
7
|
thin?: boolean;
|
|
8
8
|
className?: string;
|
|
9
|
+
onChange?: ({ activeTabIndex, target }: {
|
|
10
|
+
activeTabIndex: number;
|
|
11
|
+
target: HTMLLIElement | null;
|
|
12
|
+
}) => void;
|
|
9
13
|
} & Cauldron.LabelProps;
|
|
10
14
|
declare const Tabs: {
|
|
11
|
-
({ children, thin, initialActiveIndex, className, ...labelProp }: TabsProps): JSX.Element;
|
|
15
|
+
({ children, thin, initialActiveIndex, className, onChange, ...labelProp }: TabsProps): JSX.Element;
|
|
12
16
|
displayName: string;
|
|
13
17
|
propTypes: {
|
|
14
18
|
children: PropTypes.Validator<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
|
package/lib/index.js
CHANGED
|
@@ -1150,11 +1150,11 @@ var SideBar = /** @class */ (function (_super) {
|
|
|
1150
1150
|
var _a = this.state, animateClass = _a.animateClass, wide = _a.wide;
|
|
1151
1151
|
// disabling no-unused-vars to prevent onDismiss from being passed through to dom element
|
|
1152
1152
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1153
|
-
var _b = this.props, children = _b.children, className = _b.className, show = _b.show, onDismiss = _b.onDismiss, other = tslib.__rest(_b, ["children", "className", "show", "onDismiss"]);
|
|
1153
|
+
var _b = this.props, children = _b.children, className = _b.className, show = _b.show, onDismiss = _b.onDismiss, navProps = _b.navProps, other = tslib.__rest(_b, ["children", "className", "show", "onDismiss", "navProps"]);
|
|
1154
1154
|
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
1155
1155
|
return (React__default.createElement(React.Fragment, null,
|
|
1156
1156
|
React__default.createElement(ClickOutsideListener, { onClickOutside: this.handleClickOutside },
|
|
1157
|
-
React__default.createElement("nav",
|
|
1157
|
+
React__default.createElement("nav", tslib.__assign({}, navProps),
|
|
1158
1158
|
React__default.createElement("ul", tslib.__assign({ className: classNames('SideBar', className, animateClass) }, other, { ref: this.navList, onKeyDown: this.onKeyDown }), children))),
|
|
1159
1159
|
React__default.createElement(Scrim, { show: !wide && show })));
|
|
1160
1160
|
/* eslint-enable jsx-a11y/no-noninteractive-element-interactions */
|
|
@@ -1617,21 +1617,52 @@ var TooltipContent = function (_a) {
|
|
|
1617
1617
|
return (React__default.createElement("div", tslib.__assign({ className: classNames('TooltipContent', className) }, other)));
|
|
1618
1618
|
};
|
|
1619
1619
|
|
|
1620
|
+
/**
|
|
1621
|
+
* Unfortunately, eslint does not recognize that this Polymorphic component has a displayName set
|
|
1622
|
+
*
|
|
1623
|
+
* We might be able to remove this if we upgrade eslint and associated plugins
|
|
1624
|
+
* See: https://github.com/dequelabs/cauldron/issues/451
|
|
1625
|
+
*/
|
|
1626
|
+
// eslint-disable-next-line react/display-name
|
|
1620
1627
|
var IconButton = React.forwardRef(function (_a, ref) {
|
|
1621
|
-
var icon = _a.icon, label = _a.label,
|
|
1622
|
-
var
|
|
1623
|
-
React.useImperativeHandle(ref, function () { return
|
|
1628
|
+
var _b = _a.as, Component = _b === void 0 ? 'button' : _b, icon = _a.icon, label = _a.label, _c = _a.tooltipPlacement, tooltipPlacement = _c === void 0 ? 'auto' : _c, tooltipVariant = _a.tooltipVariant, tooltipPortal = _a.tooltipPortal, className = _a.className, _d = _a.variant, variant = _d === void 0 ? 'secondary' : _d, disabled = _a.disabled, _e = _a.tabIndex, tabIndex = _e === void 0 ? 0 : _e, other = tslib.__rest(_a, ["as", "icon", "label", "tooltipPlacement", "tooltipVariant", "tooltipPortal", "className", "variant", "disabled", "tabIndex"]);
|
|
1629
|
+
var internalRef = React.useRef();
|
|
1630
|
+
React.useImperativeHandle(ref, function () { return internalRef.current; });
|
|
1631
|
+
// Configure additional properties based on the type of the Component
|
|
1632
|
+
// for accessibility
|
|
1633
|
+
var accessibilityProps = {};
|
|
1634
|
+
if (Component === 'button') {
|
|
1635
|
+
accessibilityProps.type = 'button';
|
|
1636
|
+
}
|
|
1637
|
+
else {
|
|
1638
|
+
// We don't need to set an anchor's role, since it would be redundant
|
|
1639
|
+
if (Component !== 'a') {
|
|
1640
|
+
accessibilityProps.role = other.href || other.to ? 'link' : 'button';
|
|
1641
|
+
}
|
|
1642
|
+
if (disabled) {
|
|
1643
|
+
accessibilityProps['aria-disabled'] = disabled;
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
React.useEffect(function () {
|
|
1647
|
+
var _a;
|
|
1648
|
+
if (!disabled) {
|
|
1649
|
+
return;
|
|
1650
|
+
}
|
|
1651
|
+
(_a = internalRef.current) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-label', label);
|
|
1652
|
+
}, [disabled]);
|
|
1624
1653
|
return (React__default.createElement(React__default.Fragment, null,
|
|
1625
|
-
React__default.createElement(
|
|
1654
|
+
React__default.createElement(Component, tslib.__assign({ className: classNames(className, {
|
|
1626
1655
|
IconButton: true,
|
|
1627
1656
|
'IconButton--primary': variant === 'primary',
|
|
1628
1657
|
'IconButton--secondary': variant === 'secondary',
|
|
1629
1658
|
'IconButton--error': variant === 'error'
|
|
1630
|
-
}), ref:
|
|
1659
|
+
}), ref: internalRef, disabled: disabled, tabIndex: disabled ? -1 : tabIndex }, accessibilityProps, other),
|
|
1631
1660
|
React__default.createElement(Icon, { type: icon })),
|
|
1632
|
-
!disabled && (React__default.createElement(Tooltip, { target:
|
|
1661
|
+
!disabled && (React__default.createElement(Tooltip, { target: internalRef, placement: tooltipPlacement, variant: tooltipVariant, portal: tooltipPortal, association: "aria-labelledby", hideElementOnHidden: true }, label))));
|
|
1633
1662
|
});
|
|
1634
1663
|
IconButton.propTypes = {
|
|
1664
|
+
// @ts-expect-error
|
|
1665
|
+
as: PropTypes.elementType,
|
|
1635
1666
|
// @ts-expect-error
|
|
1636
1667
|
icon: PropTypes.string.isRequired,
|
|
1637
1668
|
label: PropTypes.string.isRequired,
|
|
@@ -2162,22 +2193,18 @@ Link.propTypes = {
|
|
|
2162
2193
|
Link.displayName = 'Link';
|
|
2163
2194
|
|
|
2164
2195
|
function Loader(_a) {
|
|
2165
|
-
var
|
|
2166
|
-
var props = tslib.__assign(tslib.__assign({}, other), { className: classNames('Loader', className)
|
|
2167
|
-
if (label) {
|
|
2168
|
-
props
|
|
2169
|
-
props
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
props['aria-
|
|
2173
|
-
// According to the ARIA 1.2 spec (https://www.w3.org/TR/wai-aria-1.2/#progressbar),
|
|
2174
|
-
// the aria-valuenow attribute SHOULD be omitted because the "value" of our progress
|
|
2175
|
-
// is "indeterminate".
|
|
2196
|
+
var className = _a.className, label = _a.label, other = tslib.__rest(_a, ["className", "label"]);
|
|
2197
|
+
var props = tslib.__assign(tslib.__assign({}, other), { className: classNames('Loader', className) });
|
|
2198
|
+
if (label === null || label === void 0 ? void 0 : label.length) {
|
|
2199
|
+
props['role'] = 'alert';
|
|
2200
|
+
props.children = React__default.createElement(Offscreen, null, label);
|
|
2201
|
+
}
|
|
2202
|
+
else {
|
|
2203
|
+
props['aria-hidden'] = true;
|
|
2176
2204
|
}
|
|
2177
2205
|
return React__default.createElement("div", tslib.__assign({}, props));
|
|
2178
2206
|
}
|
|
2179
2207
|
Loader.propTypes = {
|
|
2180
|
-
label: PropTypes.string,
|
|
2181
2208
|
className: PropTypes.string
|
|
2182
2209
|
};
|
|
2183
2210
|
Loader.displayName = 'Loader';
|
|
@@ -8024,8 +8051,9 @@ Tab.propTypes = {
|
|
|
8024
8051
|
};
|
|
8025
8052
|
|
|
8026
8053
|
var Tabs = function (_a) {
|
|
8027
|
-
var children = _a.children, thin = _a.thin, _b = _a.initialActiveIndex, initialActiveIndex = _b === void 0 ? 0 : _b, className = _a.className, labelProp = tslib.__rest(_a, ["children", "thin", "initialActiveIndex", "className"]);
|
|
8054
|
+
var children = _a.children, thin = _a.thin, _b = _a.initialActiveIndex, initialActiveIndex = _b === void 0 ? 0 : _b, className = _a.className, onChange = _a.onChange, labelProp = tslib.__rest(_a, ["children", "thin", "initialActiveIndex", "className", "onChange"]);
|
|
8028
8055
|
var _c = React.useState(initialActiveIndex), activeIndex = _c[0], setActiveIndex = _c[1];
|
|
8056
|
+
var tabsRef = React.useRef(null);
|
|
8029
8057
|
var focusedTabRef = React.useRef(null);
|
|
8030
8058
|
var tabs = React__default.Children.toArray(children).filter(function (child) { return child.type === Tab; });
|
|
8031
8059
|
var tabCount = tabs.length;
|
|
@@ -8090,10 +8118,13 @@ var Tabs = function (_a) {
|
|
|
8090
8118
|
useDidUpdate(function () {
|
|
8091
8119
|
var _a;
|
|
8092
8120
|
(_a = focusedTabRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
8121
|
+
if (typeof onChange === 'function') {
|
|
8122
|
+
onChange({ activeTabIndex: activeIndex, target: focusedTabRef.current });
|
|
8123
|
+
}
|
|
8093
8124
|
}, [activeIndex]);
|
|
8094
8125
|
return (React__default.createElement("div", { className: classNames('Tabs', className, {
|
|
8095
8126
|
'Tabs--thin': thin
|
|
8096
|
-
}) },
|
|
8127
|
+
}), ref: tabsRef },
|
|
8097
8128
|
React__default.createElement("ul", tslib.__assign({ role: "tablist", className: "Tablist" }, labelProp, { onKeyDown: handleKeyDown }), tabComponents)));
|
|
8098
8129
|
};
|
|
8099
8130
|
Tabs.displayName = 'Tabs';
|
|
@@ -8162,7 +8193,7 @@ var Step = function (props) {
|
|
|
8162
8193
|
// list items, therefore it is safe to clobber
|
|
8163
8194
|
// it with the contents of the tooltip in the
|
|
8164
8195
|
// tab stop's accessible name.
|
|
8165
|
-
association: "aria-labelledby" },
|
|
8196
|
+
association: "aria-labelledby", "aria-label": isTooltip(props) ? props.tooltipText : undefined },
|
|
8166
8197
|
React__default.createElement("div", { className: "Stepper__step-indicator" }))) : (React__default.createElement(React__default.Fragment, null,
|
|
8167
8198
|
React__default.createElement("div", { className: "Stepper__step-indicator" }),
|
|
8168
8199
|
'children' in props && (React__default.createElement("div", { className: "Stepper__step-label" }, props.children)))))));
|
|
@@ -8171,6 +8202,7 @@ Step.displayName = 'Step';
|
|
|
8171
8202
|
Step.propTypes = {
|
|
8172
8203
|
children: PropTypes.node,
|
|
8173
8204
|
tooltip: PropTypes.node,
|
|
8205
|
+
tooltipText: PropTypes.string,
|
|
8174
8206
|
className: PropTypes.string
|
|
8175
8207
|
};
|
|
8176
8208
|
var Stepper = function (_a) {
|
|
@@ -8216,7 +8248,7 @@ Address.propTypes = {
|
|
|
8216
8248
|
};
|
|
8217
8249
|
var AddressLine = function (_a) {
|
|
8218
8250
|
var children = _a.children, className = _a.className, other = tslib.__rest(_a, ["children", "className"]);
|
|
8219
|
-
return
|
|
8251
|
+
return children ? (React__default.createElement("div", tslib.__assign({ className: classNames('Address__line', className) }, other), children)) : null;
|
|
8220
8252
|
};
|
|
8221
8253
|
AddressLine.displayName = 'AddressLine';
|
|
8222
8254
|
AddressLine.propTypes = {
|
|
@@ -8225,9 +8257,9 @@ AddressLine.propTypes = {
|
|
|
8225
8257
|
};
|
|
8226
8258
|
var AddressCityStateZip = function (_a) {
|
|
8227
8259
|
var city = _a.city, state = _a.state, zip = _a.zip, className = _a.className, other = tslib.__rest(_a, ["city", "state", "zip", "className"]);
|
|
8228
|
-
return
|
|
8260
|
+
return city || state || zip ? (React__default.createElement("div", tslib.__assign({ className: classNames('Address__city-state-zip', className) }, other), [[city, state].filter(Boolean).join(', '), zip]
|
|
8229
8261
|
.filter(Boolean)
|
|
8230
|
-
.join(' ')));
|
|
8262
|
+
.join(' '))) : null;
|
|
8231
8263
|
};
|
|
8232
8264
|
AddressCityStateZip.displayName = 'AddressCityStateZip';
|
|
8233
8265
|
AddressCityStateZip.propTypes = {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Based on @radix-ui/polymorphic:
|
|
3
|
+
* https://github.com/radix-ui/primitives/blob/main/packages/react/polymorphic/src/polymorphic.ts
|
|
4
|
+
*/
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
declare type Merge<P1 = {}, P2 = {}> = Omit<P1, keyof P2> & P2;
|
|
7
|
+
/**
|
|
8
|
+
* Infers the OwnProps if E is a ForwardRefExoticComponentWithAs
|
|
9
|
+
*/
|
|
10
|
+
declare type OwnProps<E> = E extends ForwardRefComponent<any, infer P> ? P : {};
|
|
11
|
+
/**
|
|
12
|
+
* Infers the JSX.IntrinsicElement if E is a ForwardRefExoticComponentWithAs
|
|
13
|
+
*/
|
|
14
|
+
declare type IntrinsicElement<E> = E extends ForwardRefComponent<infer I, any> ? I : never;
|
|
15
|
+
declare type ForwardRefExoticComponent<E, OwnProps> = React.ForwardRefExoticComponent<Merge<E extends React.ElementType ? React.ComponentPropsWithRef<E> : never, OwnProps & {
|
|
16
|
+
as?: E;
|
|
17
|
+
}>>;
|
|
18
|
+
interface ForwardRefComponent<IntrinsicElementString, OwnProps = {}
|
|
19
|
+
/**
|
|
20
|
+
* Extends original type to ensure built in React types play nice
|
|
21
|
+
* with polymorphic components still e.g. `React.ElementRef` etc.
|
|
22
|
+
*/
|
|
23
|
+
> extends ForwardRefExoticComponent<IntrinsicElementString, OwnProps> {
|
|
24
|
+
/**
|
|
25
|
+
* When `as` prop is passed, use this overload.
|
|
26
|
+
* Merges original own props (without DOM props) and the inferred props
|
|
27
|
+
* from `as` element with the own props taking precendence.
|
|
28
|
+
*
|
|
29
|
+
* We explicitly avoid `React.ElementType` and manually narrow the prop types
|
|
30
|
+
* so that events are typed when using JSX.IntrinsicElements.
|
|
31
|
+
*/
|
|
32
|
+
<As = IntrinsicElementString>(props: As extends '' ? {
|
|
33
|
+
as: keyof JSX.IntrinsicElements;
|
|
34
|
+
} : As extends React.ComponentType<infer P> ? Merge<P, OwnProps & {
|
|
35
|
+
as: As;
|
|
36
|
+
}> : As extends keyof JSX.IntrinsicElements ? Merge<JSX.IntrinsicElements[As], OwnProps & {
|
|
37
|
+
as: As;
|
|
38
|
+
}> : never): React.ReactElement | null;
|
|
39
|
+
}
|
|
40
|
+
export { ForwardRefComponent, OwnProps, IntrinsicElement, Merge };
|