@jobber/components 6.36.1 → 6.37.0
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/dist/Banner-cjs.js +1 -1
- package/dist/Banner-es.js +2 -2
- package/dist/Button/Button.d.ts +742 -6
- package/dist/Button/index.cjs +1 -1
- package/dist/Button-cjs.js +30 -13
- package/dist/Button-es.js +31 -14
- package/dist/ButtonDismiss-cjs.js +1 -1
- package/dist/ButtonDismiss-es.js +2 -2
- package/dist/Card-cjs.js +2 -2
- package/dist/Card-es.js +3 -3
- package/dist/Chip/Chip.d.ts +3 -2
- package/dist/Chip/Chip.types.d.ts +64 -0
- package/dist/Chip/index.cjs +1 -1
- package/dist/Chip-cjs.js +48 -23
- package/dist/Chip-es.js +49 -24
- package/dist/ChipDismissible-cjs.js +4 -4
- package/dist/ChipDismissible-es.js +5 -5
- package/dist/ComboboxActivator-cjs.js +1 -1
- package/dist/ComboboxActivator-es.js +3 -3
- package/dist/ComboboxContentHeader-cjs.js +1 -1
- package/dist/ComboboxContentHeader-es.js +2 -2
- package/dist/ComboboxTrigger-cjs.js +1 -1
- package/dist/ComboboxTrigger-es.js +2 -2
- package/dist/DataListActions-cjs.js +2 -2
- package/dist/DataListActions-es.js +3 -3
- package/dist/DataListEmptyState-cjs.js +1 -1
- package/dist/DataListEmptyState-es.js +2 -2
- package/dist/DataListHeader-cjs.js +1 -1
- package/dist/DataListHeader-es.js +2 -2
- package/dist/DataListItemActionsOverflow-cjs.js +1 -1
- package/dist/DataListItemActionsOverflow-es.js +2 -2
- package/dist/DataListLoadMore-cjs.js +1 -1
- package/dist/DataListLoadMore-es.js +2 -2
- package/dist/DataListSearch-cjs.js +1 -1
- package/dist/DataListSearch-es.js +2 -2
- package/dist/DataListSort-cjs.js +1 -1
- package/dist/DataListSort-es.js +2 -2
- package/dist/DataTable-cjs.js +2 -2
- package/dist/DataTable-es.js +3 -3
- package/dist/DatePicker-cjs.js +3 -3
- package/dist/DatePicker-es.js +4 -4
- package/dist/FeatureSwitch-cjs.js +1 -1
- package/dist/FeatureSwitch-es.js +2 -2
- package/dist/FormField-cjs.js +1 -1
- package/dist/FormField-es.js +2 -2
- package/dist/FormatFile-cjs.js +1 -1
- package/dist/FormatFile-es.js +2 -2
- package/dist/Gallery-cjs.js +1 -1
- package/dist/Gallery-es.js +2 -2
- package/dist/InputAvatar-cjs.js +1 -1
- package/dist/InputAvatar-es.js +2 -2
- package/dist/InputFile-cjs.js +1 -1
- package/dist/InputFile-es.js +2 -2
- package/dist/InternalChipDismissible-cjs.js +4 -4
- package/dist/InternalChipDismissible-es.js +6 -6
- package/dist/LightBox-cjs.js +2 -2
- package/dist/LightBox-es.js +3 -3
- package/dist/Menu-cjs.js +1 -1
- package/dist/Menu-es.js +2 -2
- package/dist/Modal-cjs.js +3 -3
- package/dist/Modal-es.js +4 -4
- package/dist/Page-cjs.js +2 -2
- package/dist/Page-es.js +3 -3
- package/dist/SideDrawer-cjs.js +2 -2
- package/dist/SideDrawer-es.js +3 -3
- package/dist/index.cjs +2 -2
- package/dist/showToast-cjs.js +2 -2
- package/dist/showToast-es.js +3 -3
- package/package.json +2 -2
package/dist/Button/index.cjs
CHANGED
package/dist/Button-cjs.js
CHANGED
|
@@ -68,28 +68,45 @@ function ButtonLabel(_a) {
|
|
|
68
68
|
return (React.createElement(Typography.Typography, Object.assign({ element: element, fontWeight: fontWeight, fontFamily: fontFamily, size: getTypeSizes(size) }, props)));
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
const ButtonComponent = React.forwardRef((props, ref) => {
|
|
72
72
|
const { size } = props;
|
|
73
73
|
return (React.createElement(ButtonProvider, { size: size },
|
|
74
|
-
React.createElement(ButtonWrapper, Object.assign({}, props))));
|
|
75
|
-
}
|
|
76
|
-
|
|
74
|
+
React.createElement(ButtonWrapper, Object.assign({}, props, { ref: ref }))));
|
|
75
|
+
});
|
|
76
|
+
ButtonComponent.displayName = "Button";
|
|
77
|
+
const ButtonWrapper = React.forwardRef(
|
|
78
|
+
// eslint-disable-next-line max-statements
|
|
79
|
+
(props, ref) => {
|
|
77
80
|
const { ariaControls, ariaHaspopup, ariaExpanded, ariaLabel, disabled = false, external, id, name, onClick, onMouseDown, role, value, submit, to, url, UNSAFE_className = {}, UNSAFE_style = {}, children, } = props;
|
|
78
81
|
const { combined } = useButtonStyles(props);
|
|
79
82
|
const buttonType = submit ? "submit" : "button";
|
|
80
83
|
const buttonClassNames = classnames(combined, UNSAFE_className.container);
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
// Base props common to all element types
|
|
85
|
+
const commonProps = Object.assign(Object.assign(Object.assign({ className: buttonClassNames, disabled,
|
|
86
|
+
id, style: UNSAFE_style.container }, (!disabled && { onClick: onClick })), (!disabled && { onMouseDown: onMouseDown })), { "aria-controls": ariaControls, "aria-haspopup": ariaHaspopup, "aria-expanded": ariaExpanded, "aria-label": ariaLabel, role: role });
|
|
83
87
|
const buttonInternals = children || React.createElement(ButtonContent, Object.assign({}, props));
|
|
84
88
|
if (to) {
|
|
85
|
-
|
|
89
|
+
// Props specific to Link
|
|
90
|
+
const linkProps = Object.assign(Object.assign({}, commonProps), { to: to });
|
|
91
|
+
return React.createElement(reactRouterDom.Link, Object.assign({}, linkProps), buttonInternals);
|
|
86
92
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
if (url) {
|
|
94
|
+
// Props specific to anchor
|
|
95
|
+
const anchorProps = Object.assign(Object.assign(Object.assign(Object.assign({}, commonProps), { href: !disabled ? url : undefined }), (external && { target: "_blank" })), { ref: ref });
|
|
96
|
+
return React.createElement("a", Object.assign({}, anchorProps), buttonInternals);
|
|
97
|
+
}
|
|
98
|
+
// Props specific to button
|
|
99
|
+
const buttonProps = Object.assign(Object.assign(Object.assign(Object.assign({}, commonProps), { type: buttonType }), (submit && { name, value })), { ref: ref });
|
|
100
|
+
// Explanation: "type" IS defined in the buttonProps object
|
|
101
|
+
// eslint-disable-next-line react/button-has-type
|
|
102
|
+
return React.createElement("button", Object.assign({}, buttonProps), buttonInternals);
|
|
103
|
+
});
|
|
104
|
+
ButtonWrapper.displayName = "ButtonWrapper";
|
|
105
|
+
const ButtonNamespace = Object.assign(ButtonComponent, {
|
|
106
|
+
Label: ButtonLabel,
|
|
107
|
+
Icon: ButtonIcon,
|
|
108
|
+
});
|
|
92
109
|
|
|
93
|
-
exports.
|
|
110
|
+
exports.ButtonNamespace = ButtonNamespace;
|
|
94
111
|
exports.useButtonContext = useButtonContext;
|
|
95
112
|
exports.useButtonStyles = useButtonStyles;
|
package/dist/Button-es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React__default, { createContext, useContext } from 'react';
|
|
1
|
+
import React__default, { createContext, useContext, forwardRef } from 'react';
|
|
2
2
|
import { Link } from 'react-router-dom';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import { _ as __rest } from './tslib.es6-es.js';
|
|
@@ -66,26 +66,43 @@ function ButtonLabel(_a) {
|
|
|
66
66
|
return (React__default.createElement(Typography, Object.assign({ element: element, fontWeight: fontWeight, fontFamily: fontFamily, size: getTypeSizes(size) }, props)));
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
const ButtonComponent = forwardRef((props, ref) => {
|
|
70
70
|
const { size } = props;
|
|
71
71
|
return (React__default.createElement(ButtonProvider, { size: size },
|
|
72
|
-
React__default.createElement(ButtonWrapper, Object.assign({}, props))));
|
|
73
|
-
}
|
|
74
|
-
|
|
72
|
+
React__default.createElement(ButtonWrapper, Object.assign({}, props, { ref: ref }))));
|
|
73
|
+
});
|
|
74
|
+
ButtonComponent.displayName = "Button";
|
|
75
|
+
const ButtonWrapper = forwardRef(
|
|
76
|
+
// eslint-disable-next-line max-statements
|
|
77
|
+
(props, ref) => {
|
|
75
78
|
const { ariaControls, ariaHaspopup, ariaExpanded, ariaLabel, disabled = false, external, id, name, onClick, onMouseDown, role, value, submit, to, url, UNSAFE_className = {}, UNSAFE_style = {}, children, } = props;
|
|
76
79
|
const { combined } = useButtonStyles(props);
|
|
77
80
|
const buttonType = submit ? "submit" : "button";
|
|
78
81
|
const buttonClassNames = classnames(combined, UNSAFE_className.container);
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
// Base props common to all element types
|
|
83
|
+
const commonProps = Object.assign(Object.assign(Object.assign({ className: buttonClassNames, disabled,
|
|
84
|
+
id, style: UNSAFE_style.container }, (!disabled && { onClick: onClick })), (!disabled && { onMouseDown: onMouseDown })), { "aria-controls": ariaControls, "aria-haspopup": ariaHaspopup, "aria-expanded": ariaExpanded, "aria-label": ariaLabel, role: role });
|
|
81
85
|
const buttonInternals = children || React__default.createElement(ButtonContent, Object.assign({}, props));
|
|
82
86
|
if (to) {
|
|
83
|
-
|
|
87
|
+
// Props specific to Link
|
|
88
|
+
const linkProps = Object.assign(Object.assign({}, commonProps), { to: to });
|
|
89
|
+
return React__default.createElement(Link, Object.assign({}, linkProps), buttonInternals);
|
|
84
90
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
if (url) {
|
|
92
|
+
// Props specific to anchor
|
|
93
|
+
const anchorProps = Object.assign(Object.assign(Object.assign(Object.assign({}, commonProps), { href: !disabled ? url : undefined }), (external && { target: "_blank" })), { ref: ref });
|
|
94
|
+
return React__default.createElement("a", Object.assign({}, anchorProps), buttonInternals);
|
|
95
|
+
}
|
|
96
|
+
// Props specific to button
|
|
97
|
+
const buttonProps = Object.assign(Object.assign(Object.assign(Object.assign({}, commonProps), { type: buttonType }), (submit && { name, value })), { ref: ref });
|
|
98
|
+
// Explanation: "type" IS defined in the buttonProps object
|
|
99
|
+
// eslint-disable-next-line react/button-has-type
|
|
100
|
+
return React__default.createElement("button", Object.assign({}, buttonProps), buttonInternals);
|
|
101
|
+
});
|
|
102
|
+
ButtonWrapper.displayName = "ButtonWrapper";
|
|
103
|
+
const ButtonNamespace = Object.assign(ButtonComponent, {
|
|
104
|
+
Label: ButtonLabel,
|
|
105
|
+
Icon: ButtonIcon,
|
|
106
|
+
});
|
|
90
107
|
|
|
91
|
-
export {
|
|
108
|
+
export { ButtonNamespace as B, useButtonContext as a, useButtonStyles as u };
|
|
@@ -5,7 +5,7 @@ var Button = require('./Button-cjs.js');
|
|
|
5
5
|
require('classnames');
|
|
6
6
|
|
|
7
7
|
function ButtonDismiss({ onClick, ariaLabel }) {
|
|
8
|
-
return (React.createElement(Button.
|
|
8
|
+
return (React.createElement(Button.ButtonNamespace, { ariaLabel: ariaLabel, icon: "remove", onClick: onClick, type: "tertiary", variation: "subtle" }));
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
exports.ButtonDismiss = ButtonDismiss;
|
package/dist/ButtonDismiss-es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
|
-
import { B as
|
|
2
|
+
import { B as ButtonNamespace } from './Button-es.js';
|
|
3
3
|
import 'classnames';
|
|
4
4
|
|
|
5
5
|
function ButtonDismiss({ onClick, ariaLabel }) {
|
|
6
|
-
return (React__default.createElement(
|
|
6
|
+
return (React__default.createElement(ButtonNamespace, { ariaLabel: ariaLabel, icon: "remove", onClick: onClick, type: "tertiary", variation: "subtle" }));
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export { ButtonDismiss as B };
|
package/dist/Card-cjs.js
CHANGED
|
@@ -59,9 +59,9 @@ function CardHeader({ title, header, }) {
|
|
|
59
59
|
return React.createElement(React.Fragment, null);
|
|
60
60
|
}
|
|
61
61
|
function renderHeaderAction(action) {
|
|
62
|
-
if ((action === null || action === void 0 ? void 0 : action.type) === Button.
|
|
62
|
+
if ((action === null || action === void 0 ? void 0 : action.type) === Button.ButtonNamespace) {
|
|
63
63
|
const props = Object.assign(Object.assign({ type: "tertiary" }, action.props), { size: "small" });
|
|
64
|
-
return action && React.createElement(Button.
|
|
64
|
+
return action && React.createElement(Button.ButtonNamespace, Object.assign({}, props));
|
|
65
65
|
}
|
|
66
66
|
if ((action === null || action === void 0 ? void 0 : action.type) === Menu.Menu) {
|
|
67
67
|
return action && React.createElement(Menu.Menu, Object.assign({}, action.props));
|
package/dist/Card-es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React__default, { useRef } from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
3
|
import { H as Heading } from './Heading-es.js';
|
|
4
|
-
import { B as
|
|
4
|
+
import { B as ButtonNamespace } from './Button-es.js';
|
|
5
5
|
import { M as Menu } from './Menu-es.js';
|
|
6
6
|
|
|
7
7
|
var styles = {"card":"-PlHaWx00Hw-","accent":"Iilm5Uhxo50-","clickable":"Vppn4k0fBsc-","header":"l3-Pkynq2zA-","spinning":"hvqmZrWenIs-"};
|
|
@@ -57,9 +57,9 @@ function CardHeader({ title, header, }) {
|
|
|
57
57
|
return React__default.createElement(React__default.Fragment, null);
|
|
58
58
|
}
|
|
59
59
|
function renderHeaderAction(action) {
|
|
60
|
-
if ((action === null || action === void 0 ? void 0 : action.type) ===
|
|
60
|
+
if ((action === null || action === void 0 ? void 0 : action.type) === ButtonNamespace) {
|
|
61
61
|
const props = Object.assign(Object.assign({ type: "tertiary" }, action.props), { size: "small" });
|
|
62
|
-
return action && React__default.createElement(
|
|
62
|
+
return action && React__default.createElement(ButtonNamespace, Object.assign({}, props));
|
|
63
63
|
}
|
|
64
64
|
if ((action === null || action === void 0 ? void 0 : action.type) === Menu) {
|
|
65
65
|
return action && React__default.createElement(Menu, Object.assign({}, action.props));
|
package/dist/Chip/Chip.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import { ChipPrefix } from "./components/ChipPrefix/Chip.Prefix";
|
|
2
3
|
import { ChipSuffix } from "./components/ChipSuffix/Chip.Suffix";
|
|
3
4
|
import { ChipProps } from "./Chip.types";
|
|
4
|
-
|
|
5
|
-
({ ariaLabel, disabled, heading, invalid, label, value, testID, onClick, onKeyDown, children, role, tabIndex, variation, }: ChipProps): JSX.Element;
|
|
5
|
+
declare const ChipNamespace: React.ForwardRefExoticComponent<ChipProps & React.RefAttributes<HTMLDivElement | HTMLButtonElement>> & {
|
|
6
6
|
Prefix: typeof ChipPrefix;
|
|
7
7
|
Suffix: typeof ChipSuffix;
|
|
8
8
|
};
|
|
9
|
+
export { ChipNamespace as Chip };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from "react";
|
|
2
|
+
export interface ChipProps extends PropsWithChildren {
|
|
3
|
+
/**
|
|
4
|
+
* Accessible label, which can be different from the primary label.
|
|
5
|
+
*/
|
|
6
|
+
readonly ariaLabel?: string;
|
|
7
|
+
/**
|
|
8
|
+
* The testing id for the chip if necessary.
|
|
9
|
+
*/
|
|
10
|
+
testID?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Disables both mouse and keyboard functionality, and updates the visual style of the Chip to appear disabled.
|
|
13
|
+
*/
|
|
14
|
+
readonly disabled?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Adds more prominent text to act as a heading. Will be displayed on the left with a | separator.
|
|
17
|
+
*/
|
|
18
|
+
readonly heading?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Changes Chip styling to inform the user of an issue.
|
|
21
|
+
*/
|
|
22
|
+
readonly invalid?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The content of the chip. Will be displayed on the right if you include a heading.
|
|
25
|
+
*/
|
|
26
|
+
readonly label: string;
|
|
27
|
+
/**
|
|
28
|
+
* The accessible role the Chip is fulfilling. Defaults to 'button'
|
|
29
|
+
*/
|
|
30
|
+
readonly role?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Used for accessibility purpopses, specifically using the tab key as navigation.
|
|
33
|
+
* @default 0
|
|
34
|
+
*/
|
|
35
|
+
readonly tabIndex?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Will be passed to onClick, when the user clicks on this Chip.
|
|
38
|
+
*/
|
|
39
|
+
readonly value?: string | number;
|
|
40
|
+
/**
|
|
41
|
+
* Button style variation. Does not affect functionality.
|
|
42
|
+
* @default "base"
|
|
43
|
+
*/
|
|
44
|
+
readonly variation?: ChipVariations;
|
|
45
|
+
/**
|
|
46
|
+
* Chip Click Callback. Sends an event and sometimes a value (SelectableChip).
|
|
47
|
+
*/
|
|
48
|
+
readonly onClick?: (value: string | number | undefined, ev: React.MouseEvent<HTMLButtonElement | HTMLDivElement>) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Callback. Called when you keydown on Chip. Ships the event, so you can get the key pushed.
|
|
51
|
+
*/
|
|
52
|
+
readonly onKeyDown?: (ev: React.KeyboardEvent<HTMLButtonElement | HTMLDivElement>) => void;
|
|
53
|
+
}
|
|
54
|
+
export type ChipVariations = "subtle" | "base";
|
|
55
|
+
export interface ChipSelectableProps extends ChipProps {
|
|
56
|
+
/**
|
|
57
|
+
* Is Chip selected?
|
|
58
|
+
*/
|
|
59
|
+
readonly selected?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Send this back onClick. Good for determining which Chip was clicked.
|
|
62
|
+
*/
|
|
63
|
+
readonly value?: string | number;
|
|
64
|
+
}
|
package/dist/Chip/index.cjs
CHANGED
package/dist/Chip-cjs.js
CHANGED
|
@@ -75,35 +75,56 @@ const allowedSuffixIcons = [
|
|
|
75
75
|
"arrowDown",
|
|
76
76
|
];
|
|
77
77
|
|
|
78
|
-
const
|
|
78
|
+
const ChipComponent = React.forwardRef(({ ariaLabel, disabled, heading, invalid, label, value, testID, onClick, onKeyDown, children, role = "button", tabIndex = 0, variation = "base", }, ref) => {
|
|
79
79
|
const classes = classnames(styles$1.chip, {
|
|
80
80
|
[styles$1.invalid]: invalid,
|
|
81
81
|
[styles$1.base]: variation === "base",
|
|
82
82
|
[styles$1.subtle]: variation === "subtle",
|
|
83
83
|
[styles$1.disabled]: disabled,
|
|
84
84
|
});
|
|
85
|
-
const prefix = useChildComponent.useChildComponent(children, d => d.type ===
|
|
86
|
-
const suffix = useChildComponent.useChildComponent(children, d => d.type ===
|
|
85
|
+
const prefix = useChildComponent.useChildComponent(children, d => d.type === ChipPrefix);
|
|
86
|
+
const suffix = useChildComponent.useChildComponent(children, d => d.type === ChipSuffix);
|
|
87
87
|
const [labelRef, labelFullyVisible] = useInView.useInView_2();
|
|
88
88
|
const [headingRef, headingFullyVisible] = useInView.useInView_2();
|
|
89
89
|
const tooltipMessage = getTooltipMessage(labelFullyVisible, headingFullyVisible, label, heading);
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
React.createElement(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
React.createElement(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
React.createElement(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
90
|
+
const chipContent = (React.createElement(React.Fragment, null,
|
|
91
|
+
prefix,
|
|
92
|
+
React.createElement("div", { className: styles$1.chipContent },
|
|
93
|
+
heading && (React.createElement(React.Fragment, null,
|
|
94
|
+
React.createElement(Typography.Typography, { size: "base", fontWeight: "medium" },
|
|
95
|
+
heading,
|
|
96
|
+
React.createElement("span", { ref: headingRef, className: styles$1.chipLabelRef })),
|
|
97
|
+
label && React.createElement("span", { className: styles$1.chipBar }))),
|
|
98
|
+
React.createElement(Typography.Typography, { size: "base" },
|
|
99
|
+
label,
|
|
100
|
+
React.createElement("span", { ref: labelRef, className: styles$1.chipLabelRef })),
|
|
101
|
+
!labelFullyVisible && (React.createElement("div", { className: styles$1.truncateGradient, "data-testid": "ATL-Chip-Truncation-Gradient" },
|
|
102
|
+
React.createElement("span", null)))),
|
|
103
|
+
suffix));
|
|
104
|
+
// Use createElement to properly handle the ref typing
|
|
105
|
+
return (React.createElement(Tooltip.Tooltip, { message: tooltipMessage, setTabIndex: false }, onClick
|
|
106
|
+
? React.createElement("button", {
|
|
107
|
+
className: classes,
|
|
108
|
+
onClick: (ev) => onClick === null || onClick === void 0 ? void 0 : onClick(value, ev),
|
|
109
|
+
tabIndex: disabled ? -1 : tabIndex,
|
|
110
|
+
onKeyDown,
|
|
111
|
+
"aria-label": ariaLabel,
|
|
112
|
+
disabled,
|
|
113
|
+
role,
|
|
114
|
+
"data-testid": testID,
|
|
115
|
+
type: "button",
|
|
116
|
+
ref,
|
|
117
|
+
}, chipContent)
|
|
118
|
+
: React.createElement("div", {
|
|
119
|
+
className: classes,
|
|
120
|
+
tabIndex: disabled ? -1 : tabIndex,
|
|
121
|
+
onKeyDown,
|
|
122
|
+
"aria-label": ariaLabel,
|
|
123
|
+
role,
|
|
124
|
+
"data-testid": testID,
|
|
125
|
+
ref,
|
|
126
|
+
}, chipContent)));
|
|
127
|
+
});
|
|
107
128
|
function getTooltipMessage(labelFullyVisible, headingFullyVisible, label, heading) {
|
|
108
129
|
let message = "";
|
|
109
130
|
if (heading && !headingFullyVisible) {
|
|
@@ -114,10 +135,14 @@ function getTooltipMessage(labelFullyVisible, headingFullyVisible, label, headin
|
|
|
114
135
|
}
|
|
115
136
|
return message;
|
|
116
137
|
}
|
|
117
|
-
|
|
118
|
-
Chip
|
|
138
|
+
ChipComponent.displayName = "Chip";
|
|
139
|
+
// Required to assign sub-components to the Chip component when it is a forwardRef
|
|
140
|
+
const ChipNamespace = Object.assign(ChipComponent, {
|
|
141
|
+
Prefix: ChipPrefix,
|
|
142
|
+
Suffix: ChipSuffix,
|
|
143
|
+
});
|
|
119
144
|
|
|
120
|
-
exports.
|
|
145
|
+
exports.ChipNamespace = ChipNamespace;
|
|
121
146
|
exports.InternalChipButton = InternalChipButton;
|
|
122
147
|
exports.styles = styles$1;
|
|
123
148
|
exports.styles$1 = styles;
|
package/dist/Chip-es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React__default, { useRef } from 'react';
|
|
1
|
+
import React__default, { useRef, forwardRef } from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
3
|
import { u as useInView_2 } from './useInView-es.js';
|
|
4
4
|
import { A as Avatar } from './Avatar-es.js';
|
|
@@ -73,35 +73,56 @@ const allowedSuffixIcons = [
|
|
|
73
73
|
"arrowDown",
|
|
74
74
|
];
|
|
75
75
|
|
|
76
|
-
const
|
|
76
|
+
const ChipComponent = forwardRef(({ ariaLabel, disabled, heading, invalid, label, value, testID, onClick, onKeyDown, children, role = "button", tabIndex = 0, variation = "base", }, ref) => {
|
|
77
77
|
const classes = classnames(styles$1.chip, {
|
|
78
78
|
[styles$1.invalid]: invalid,
|
|
79
79
|
[styles$1.base]: variation === "base",
|
|
80
80
|
[styles$1.subtle]: variation === "subtle",
|
|
81
81
|
[styles$1.disabled]: disabled,
|
|
82
82
|
});
|
|
83
|
-
const prefix = useChildComponent(children, d => d.type ===
|
|
84
|
-
const suffix = useChildComponent(children, d => d.type ===
|
|
83
|
+
const prefix = useChildComponent(children, d => d.type === ChipPrefix);
|
|
84
|
+
const suffix = useChildComponent(children, d => d.type === ChipSuffix);
|
|
85
85
|
const [labelRef, labelFullyVisible] = useInView_2();
|
|
86
86
|
const [headingRef, headingFullyVisible] = useInView_2();
|
|
87
87
|
const tooltipMessage = getTooltipMessage(labelFullyVisible, headingFullyVisible, label, heading);
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
React__default.createElement(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
React__default.createElement(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
React__default.createElement(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
88
|
+
const chipContent = (React__default.createElement(React__default.Fragment, null,
|
|
89
|
+
prefix,
|
|
90
|
+
React__default.createElement("div", { className: styles$1.chipContent },
|
|
91
|
+
heading && (React__default.createElement(React__default.Fragment, null,
|
|
92
|
+
React__default.createElement(Typography, { size: "base", fontWeight: "medium" },
|
|
93
|
+
heading,
|
|
94
|
+
React__default.createElement("span", { ref: headingRef, className: styles$1.chipLabelRef })),
|
|
95
|
+
label && React__default.createElement("span", { className: styles$1.chipBar }))),
|
|
96
|
+
React__default.createElement(Typography, { size: "base" },
|
|
97
|
+
label,
|
|
98
|
+
React__default.createElement("span", { ref: labelRef, className: styles$1.chipLabelRef })),
|
|
99
|
+
!labelFullyVisible && (React__default.createElement("div", { className: styles$1.truncateGradient, "data-testid": "ATL-Chip-Truncation-Gradient" },
|
|
100
|
+
React__default.createElement("span", null)))),
|
|
101
|
+
suffix));
|
|
102
|
+
// Use createElement to properly handle the ref typing
|
|
103
|
+
return (React__default.createElement(Tooltip, { message: tooltipMessage, setTabIndex: false }, onClick
|
|
104
|
+
? React__default.createElement("button", {
|
|
105
|
+
className: classes,
|
|
106
|
+
onClick: (ev) => onClick === null || onClick === void 0 ? void 0 : onClick(value, ev),
|
|
107
|
+
tabIndex: disabled ? -1 : tabIndex,
|
|
108
|
+
onKeyDown,
|
|
109
|
+
"aria-label": ariaLabel,
|
|
110
|
+
disabled,
|
|
111
|
+
role,
|
|
112
|
+
"data-testid": testID,
|
|
113
|
+
type: "button",
|
|
114
|
+
ref,
|
|
115
|
+
}, chipContent)
|
|
116
|
+
: React__default.createElement("div", {
|
|
117
|
+
className: classes,
|
|
118
|
+
tabIndex: disabled ? -1 : tabIndex,
|
|
119
|
+
onKeyDown,
|
|
120
|
+
"aria-label": ariaLabel,
|
|
121
|
+
role,
|
|
122
|
+
"data-testid": testID,
|
|
123
|
+
ref,
|
|
124
|
+
}, chipContent)));
|
|
125
|
+
});
|
|
105
126
|
function getTooltipMessage(labelFullyVisible, headingFullyVisible, label, heading) {
|
|
106
127
|
let message = "";
|
|
107
128
|
if (heading && !headingFullyVisible) {
|
|
@@ -112,7 +133,11 @@ function getTooltipMessage(labelFullyVisible, headingFullyVisible, label, headin
|
|
|
112
133
|
}
|
|
113
134
|
return message;
|
|
114
135
|
}
|
|
115
|
-
|
|
116
|
-
Chip
|
|
136
|
+
ChipComponent.displayName = "Chip";
|
|
137
|
+
// Required to assign sub-components to the Chip component when it is a forwardRef
|
|
138
|
+
const ChipNamespace = Object.assign(ChipComponent, {
|
|
139
|
+
Prefix: ChipPrefix,
|
|
140
|
+
Suffix: ChipSuffix,
|
|
141
|
+
});
|
|
117
142
|
|
|
118
|
-
export {
|
|
143
|
+
export { ChipNamespace as C, InternalChipButton as I, styles as a, styles$1 as s };
|
|
@@ -7,14 +7,14 @@ var Chip = require('./Chip-cjs.js');
|
|
|
7
7
|
|
|
8
8
|
function ChipSelectable(_a) {
|
|
9
9
|
var { selected } = _a, rest = tslib_es6.__rest(_a, ["selected"]);
|
|
10
|
-
return (React.createElement(Chip.
|
|
11
|
-
React.createElement(Chip.
|
|
10
|
+
return (React.createElement(Chip.ChipNamespace, Object.assign({}, rest),
|
|
11
|
+
React.createElement(Chip.ChipNamespace.Suffix, { className: selected ? Chip.styles.selected : "" },
|
|
12
12
|
React.createElement(Icon.Icon, { name: selected ? "checkmark" : "add", size: "small", color: "interactiveSubtle" }))));
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
function ChipDismissible(props) {
|
|
16
|
-
return (React.createElement(Chip.
|
|
17
|
-
React.createElement(Chip.
|
|
16
|
+
return (React.createElement(Chip.ChipNamespace, Object.assign({}, props),
|
|
17
|
+
React.createElement(Chip.ChipNamespace.Suffix, null,
|
|
18
18
|
React.createElement(Icon.Icon, { name: "cross", size: "small", color: "interactiveSubtle" }))));
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { _ as __rest } from './tslib.es6-es.js';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { I as Icon } from './Icon-es.js';
|
|
4
|
-
import { C as
|
|
4
|
+
import { C as ChipNamespace, s as styles } from './Chip-es.js';
|
|
5
5
|
|
|
6
6
|
function ChipSelectable(_a) {
|
|
7
7
|
var { selected } = _a, rest = __rest(_a, ["selected"]);
|
|
8
|
-
return (React__default.createElement(
|
|
9
|
-
React__default.createElement(
|
|
8
|
+
return (React__default.createElement(ChipNamespace, Object.assign({}, rest),
|
|
9
|
+
React__default.createElement(ChipNamespace.Suffix, { className: selected ? styles.selected : "" },
|
|
10
10
|
React__default.createElement(Icon, { name: selected ? "checkmark" : "add", size: "small", color: "interactiveSubtle" }))));
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
function ChipDismissible(props) {
|
|
14
|
-
return (React__default.createElement(
|
|
15
|
-
React__default.createElement(
|
|
14
|
+
return (React__default.createElement(ChipNamespace, Object.assign({}, props),
|
|
15
|
+
React__default.createElement(ChipNamespace.Suffix, null,
|
|
16
16
|
React__default.createElement(Icon, { name: "cross", size: "small", color: "interactiveSubtle" }))));
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -23,7 +23,7 @@ function ComboboxActivator(props) {
|
|
|
23
23
|
const { handleOpen } = React.useContext(ComboboxProvider.ComboboxContext);
|
|
24
24
|
const accessibilityAttributes = useComboboxActivatorAccessibility();
|
|
25
25
|
if (typeof props.children !== "function" &&
|
|
26
|
-
(props.children.type === Button.
|
|
26
|
+
(props.children.type === Button.ButtonNamespace || props.children.type === Chip.ChipNamespace)) {
|
|
27
27
|
return React.cloneElement(props.children, {
|
|
28
28
|
role: accessibilityAttributes.role,
|
|
29
29
|
onClick: handleOpen,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React__default, { useContext } from 'react';
|
|
2
|
-
import { B as
|
|
2
|
+
import { B as ButtonNamespace } from './Button-es.js';
|
|
3
3
|
import 'classnames';
|
|
4
|
-
import { C as
|
|
4
|
+
import { C as ChipNamespace } from './Chip-es.js';
|
|
5
5
|
import './tslib.es6-es.js';
|
|
6
6
|
import '@jobber/design';
|
|
7
7
|
import { a as ComboboxContext } from './ComboboxProvider-es.js';
|
|
@@ -21,7 +21,7 @@ function ComboboxActivator(props) {
|
|
|
21
21
|
const { handleOpen } = React__default.useContext(ComboboxContext);
|
|
22
22
|
const accessibilityAttributes = useComboboxActivatorAccessibility();
|
|
23
23
|
if (typeof props.children !== "function" &&
|
|
24
|
-
(props.children.type ===
|
|
24
|
+
(props.children.type === ButtonNamespace || props.children.type === ChipNamespace)) {
|
|
25
25
|
return React__default.cloneElement(props.children, {
|
|
26
26
|
role: accessibilityAttributes.role,
|
|
27
27
|
onClick: handleOpen,
|
|
@@ -15,7 +15,7 @@ function ComboboxContentHeader(props) {
|
|
|
15
15
|
const showAction = hasSelected || props.hasOptionsVisible;
|
|
16
16
|
return (React.createElement("div", { className: styles.header, "data-testid": "ATL-Combobox-Header" },
|
|
17
17
|
React.createElement(Typography.Typography, { textColor: "heading", fontWeight: "semiBold" }, label),
|
|
18
|
-
showAction && (React.createElement(Button.
|
|
18
|
+
showAction && (React.createElement(Button.ButtonNamespace, { size: "small", label: actionLabel, type: "tertiary", onClick: handleSelectAll }))));
|
|
19
19
|
}
|
|
20
20
|
function getLabel(hasSelected, count, subjectNoun) {
|
|
21
21
|
if (hasSelected) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import { T as Typography } from './Typography-es.js';
|
|
3
|
-
import { B as
|
|
3
|
+
import { B as ButtonNamespace } from './Button-es.js';
|
|
4
4
|
import 'classnames';
|
|
5
5
|
|
|
6
6
|
var styles = {"header":"nrNh3feibg8-","spinning":"rcoGBsZN55M-"};
|
|
@@ -13,7 +13,7 @@ function ComboboxContentHeader(props) {
|
|
|
13
13
|
const showAction = hasSelected || props.hasOptionsVisible;
|
|
14
14
|
return (React__default.createElement("div", { className: styles.header, "data-testid": "ATL-Combobox-Header" },
|
|
15
15
|
React__default.createElement(Typography, { textColor: "heading", fontWeight: "semiBold" }, label),
|
|
16
|
-
showAction && (React__default.createElement(
|
|
16
|
+
showAction && (React__default.createElement(ButtonNamespace, { size: "small", label: actionLabel, type: "tertiary", onClick: handleSelectAll }))));
|
|
17
17
|
}
|
|
18
18
|
function getLabel(hasSelected, count, subjectNoun) {
|
|
19
19
|
if (hasSelected) {
|
|
@@ -10,7 +10,7 @@ function ComboboxTrigger({ label = "Select", selected, }) {
|
|
|
10
10
|
const { handleOpen } = React.useContext(ComboboxProvider.ComboboxContext);
|
|
11
11
|
const hasSelection = selected.length;
|
|
12
12
|
const selectedLabel = selected.map(option => option.label).join(", ");
|
|
13
|
-
return (React.createElement(Chip.
|
|
13
|
+
return (React.createElement(Chip.ChipNamespace, { variation: hasSelection ? "base" : "subtle", label: hasSelection ? selectedLabel : "", ariaLabel: label, heading: label, onClick: handleOpen, role: "combobox" }, !hasSelection && (React.createElement(Chip.ChipNamespace.Suffix, null,
|
|
14
14
|
React.createElement(Icon.Icon, { name: "add", size: "small" })))));
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
|
-
import { C as
|
|
2
|
+
import { C as ChipNamespace } from './Chip-es.js';
|
|
3
3
|
import './tslib.es6-es.js';
|
|
4
4
|
import { I as Icon } from './Icon-es.js';
|
|
5
5
|
import { a as ComboboxContext } from './ComboboxProvider-es.js';
|
|
@@ -8,7 +8,7 @@ function ComboboxTrigger({ label = "Select", selected, }) {
|
|
|
8
8
|
const { handleOpen } = React__default.useContext(ComboboxContext);
|
|
9
9
|
const hasSelection = selected.length;
|
|
10
10
|
const selectedLabel = selected.map(option => option.label).join(", ");
|
|
11
|
-
return (React__default.createElement(
|
|
11
|
+
return (React__default.createElement(ChipNamespace, { variation: hasSelection ? "base" : "subtle", label: hasSelection ? selectedLabel : "", ariaLabel: label, heading: label, onClick: handleOpen, role: "combobox" }, !hasSelection && (React__default.createElement(ChipNamespace.Suffix, null,
|
|
12
12
|
React__default.createElement(Icon, { name: "add", size: "small" })))));
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -31,13 +31,13 @@ function DataListActions({ children, itemsToExpose = 2, }) {
|
|
|
31
31
|
const actionLabel = getActionLabel();
|
|
32
32
|
// If the action is always visible, we don't want a tooltip.
|
|
33
33
|
if (props.alwaysVisible) {
|
|
34
|
-
return (React.createElement(Button.
|
|
34
|
+
return (React.createElement(Button.ButtonNamespace, { ariaLabel: actionLabel, key: props.label, icon: props.icon, label: actionLabel, onClick: () => {
|
|
35
35
|
var _a;
|
|
36
36
|
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, activeItem);
|
|
37
37
|
}, type: "secondary", variation: "subtle" }));
|
|
38
38
|
}
|
|
39
39
|
return (React.createElement(Tooltip.Tooltip, { key: actionLabel, message: actionLabel },
|
|
40
|
-
React.createElement(Button.
|
|
40
|
+
React.createElement(Button.ButtonNamespace, { icon: props.icon, ariaLabel: actionLabel, onClick: () => {
|
|
41
41
|
var _a, _b;
|
|
42
42
|
if (activeItem) {
|
|
43
43
|
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, activeItem);
|