@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.
Files changed (69) hide show
  1. package/dist/Banner-cjs.js +1 -1
  2. package/dist/Banner-es.js +2 -2
  3. package/dist/Button/Button.d.ts +742 -6
  4. package/dist/Button/index.cjs +1 -1
  5. package/dist/Button-cjs.js +30 -13
  6. package/dist/Button-es.js +31 -14
  7. package/dist/ButtonDismiss-cjs.js +1 -1
  8. package/dist/ButtonDismiss-es.js +2 -2
  9. package/dist/Card-cjs.js +2 -2
  10. package/dist/Card-es.js +3 -3
  11. package/dist/Chip/Chip.d.ts +3 -2
  12. package/dist/Chip/Chip.types.d.ts +64 -0
  13. package/dist/Chip/index.cjs +1 -1
  14. package/dist/Chip-cjs.js +48 -23
  15. package/dist/Chip-es.js +49 -24
  16. package/dist/ChipDismissible-cjs.js +4 -4
  17. package/dist/ChipDismissible-es.js +5 -5
  18. package/dist/ComboboxActivator-cjs.js +1 -1
  19. package/dist/ComboboxActivator-es.js +3 -3
  20. package/dist/ComboboxContentHeader-cjs.js +1 -1
  21. package/dist/ComboboxContentHeader-es.js +2 -2
  22. package/dist/ComboboxTrigger-cjs.js +1 -1
  23. package/dist/ComboboxTrigger-es.js +2 -2
  24. package/dist/DataListActions-cjs.js +2 -2
  25. package/dist/DataListActions-es.js +3 -3
  26. package/dist/DataListEmptyState-cjs.js +1 -1
  27. package/dist/DataListEmptyState-es.js +2 -2
  28. package/dist/DataListHeader-cjs.js +1 -1
  29. package/dist/DataListHeader-es.js +2 -2
  30. package/dist/DataListItemActionsOverflow-cjs.js +1 -1
  31. package/dist/DataListItemActionsOverflow-es.js +2 -2
  32. package/dist/DataListLoadMore-cjs.js +1 -1
  33. package/dist/DataListLoadMore-es.js +2 -2
  34. package/dist/DataListSearch-cjs.js +1 -1
  35. package/dist/DataListSearch-es.js +2 -2
  36. package/dist/DataListSort-cjs.js +1 -1
  37. package/dist/DataListSort-es.js +2 -2
  38. package/dist/DataTable-cjs.js +2 -2
  39. package/dist/DataTable-es.js +3 -3
  40. package/dist/DatePicker-cjs.js +3 -3
  41. package/dist/DatePicker-es.js +4 -4
  42. package/dist/FeatureSwitch-cjs.js +1 -1
  43. package/dist/FeatureSwitch-es.js +2 -2
  44. package/dist/FormField-cjs.js +1 -1
  45. package/dist/FormField-es.js +2 -2
  46. package/dist/FormatFile-cjs.js +1 -1
  47. package/dist/FormatFile-es.js +2 -2
  48. package/dist/Gallery-cjs.js +1 -1
  49. package/dist/Gallery-es.js +2 -2
  50. package/dist/InputAvatar-cjs.js +1 -1
  51. package/dist/InputAvatar-es.js +2 -2
  52. package/dist/InputFile-cjs.js +1 -1
  53. package/dist/InputFile-es.js +2 -2
  54. package/dist/InternalChipDismissible-cjs.js +4 -4
  55. package/dist/InternalChipDismissible-es.js +6 -6
  56. package/dist/LightBox-cjs.js +2 -2
  57. package/dist/LightBox-es.js +3 -3
  58. package/dist/Menu-cjs.js +1 -1
  59. package/dist/Menu-es.js +2 -2
  60. package/dist/Modal-cjs.js +3 -3
  61. package/dist/Modal-es.js +4 -4
  62. package/dist/Page-cjs.js +2 -2
  63. package/dist/Page-es.js +3 -3
  64. package/dist/SideDrawer-cjs.js +2 -2
  65. package/dist/SideDrawer-es.js +3 -3
  66. package/dist/index.cjs +2 -2
  67. package/dist/showToast-cjs.js +2 -2
  68. package/dist/showToast-es.js +3 -3
  69. package/package.json +2 -2
@@ -11,6 +11,6 @@ require('../Typography-cjs.js');
11
11
 
12
12
 
13
13
 
14
- exports.Button = Button.Button;
14
+ exports.Button = Button.ButtonNamespace;
15
15
  exports.useButtonContext = Button.useButtonContext;
16
16
  exports.useButtonStyles = Button.useButtonStyles;
@@ -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
- function Button(props) {
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
- function ButtonWrapper(props) {
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
- const tagProps = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ className: buttonClassNames, disabled,
82
- id, style: UNSAFE_style.container }, (submit && { name, value })), (!disabled && { href: url })), (!disabled && { onClick: onClick })), (!disabled && { onMouseDown: onMouseDown })), (external && { target: "_blank" })), (url === undefined && to === undefined && { type: buttonType })), { "aria-controls": ariaControls, "aria-haspopup": ariaHaspopup, "aria-expanded": ariaExpanded, "aria-label": ariaLabel, role: role });
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
- return (React.createElement(reactRouterDom.Link, Object.assign({}, tagProps, { to: to }), buttonInternals));
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
- const Tag = url ? "a" : "button";
88
- return React.createElement(Tag, Object.assign({}, tagProps), buttonInternals);
89
- }
90
- Button.Label = ButtonLabel;
91
- Button.Icon = ButtonIcon;
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.Button = Button;
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
- function Button(props) {
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
- function ButtonWrapper(props) {
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
- const tagProps = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ className: buttonClassNames, disabled,
80
- id, style: UNSAFE_style.container }, (submit && { name, value })), (!disabled && { href: url })), (!disabled && { onClick: onClick })), (!disabled && { onMouseDown: onMouseDown })), (external && { target: "_blank" })), (url === undefined && to === undefined && { type: buttonType })), { "aria-controls": ariaControls, "aria-haspopup": ariaHaspopup, "aria-expanded": ariaExpanded, "aria-label": ariaLabel, role: role });
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
- return (React__default.createElement(Link, Object.assign({}, tagProps, { to: to }), buttonInternals));
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
- const Tag = url ? "a" : "button";
86
- return React__default.createElement(Tag, Object.assign({}, tagProps), buttonInternals);
87
- }
88
- Button.Label = ButtonLabel;
89
- Button.Icon = ButtonIcon;
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 { Button as B, useButtonContext as a, useButtonStyles as u };
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.Button, { ariaLabel: ariaLabel, icon: "remove", onClick: onClick, type: "tertiary", variation: "subtle" }));
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;
@@ -1,9 +1,9 @@
1
1
  import React__default from 'react';
2
- import { B as Button } from './Button-es.js';
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(Button, { ariaLabel: ariaLabel, icon: "remove", onClick: onClick, type: "tertiary", variation: "subtle" }));
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.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.Button, Object.assign({}, props));
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 Button } from './Button-es.js';
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) === Button) {
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(Button, Object.assign({}, props));
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));
@@ -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
- export declare const Chip: {
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
+ }
@@ -21,6 +21,6 @@ require('../tslib.es6-cjs.js');
21
21
 
22
22
 
23
23
 
24
- exports.Chip = Chip.Chip;
24
+ exports.Chip = Chip.ChipNamespace;
25
25
  exports.ChipDismissible = ChipDismissible.ChipDismissible;
26
26
  exports.ChipSelectable = ChipDismissible.ChipSelectable;
package/dist/Chip-cjs.js CHANGED
@@ -75,35 +75,56 @@ const allowedSuffixIcons = [
75
75
  "arrowDown",
76
76
  ];
77
77
 
78
- const Chip = ({ ariaLabel, disabled, heading, invalid, label, value, testID, onClick, onKeyDown, children, role = "button", tabIndex = 0, variation = "base", }) => {
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 === Chip.Prefix);
86
- const suffix = useChildComponent.useChildComponent(children, d => d.type === Chip.Suffix);
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 Tag = onClick ? "button" : "div";
91
- return (React.createElement(Tooltip.Tooltip, { message: tooltipMessage, setTabIndex: false },
92
- React.createElement(Tag, { className: classes, onClick: (ev) => onClick === null || onClick === void 0 ? void 0 : onClick(value, ev), tabIndex: disabled ? -1 : tabIndex, onKeyDown: onKeyDown, "aria-label": ariaLabel, disabled: disabled, role: role, "data-testid": testID, type: "button" },
93
- prefix,
94
- React.createElement("div", { className: styles$1.chipContent },
95
- heading && (React.createElement(React.Fragment, null,
96
- React.createElement(Typography.Typography, { size: "base", fontWeight: "medium" },
97
- heading,
98
- React.createElement("span", { ref: headingRef, className: styles$1.chipLabelRef })),
99
- label && React.createElement("span", { className: styles$1.chipBar }))),
100
- React.createElement(Typography.Typography, { size: "base" },
101
- label,
102
- React.createElement("span", { ref: labelRef, className: styles$1.chipLabelRef })),
103
- !labelFullyVisible && (React.createElement("div", { className: styles$1.truncateGradient, "data-testid": "ATL-Chip-Truncation-Gradient" },
104
- React.createElement("span", null)))),
105
- suffix)));
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
- Chip.Prefix = ChipPrefix;
118
- Chip.Suffix = ChipSuffix;
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.Chip = Chip;
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 Chip = ({ ariaLabel, disabled, heading, invalid, label, value, testID, onClick, onKeyDown, children, role = "button", tabIndex = 0, variation = "base", }) => {
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 === Chip.Prefix);
84
- const suffix = useChildComponent(children, d => d.type === Chip.Suffix);
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 Tag = onClick ? "button" : "div";
89
- return (React__default.createElement(Tooltip, { message: tooltipMessage, setTabIndex: false },
90
- React__default.createElement(Tag, { className: classes, onClick: (ev) => onClick === null || onClick === void 0 ? void 0 : onClick(value, ev), tabIndex: disabled ? -1 : tabIndex, onKeyDown: onKeyDown, "aria-label": ariaLabel, disabled: disabled, role: role, "data-testid": testID, type: "button" },
91
- prefix,
92
- React__default.createElement("div", { className: styles$1.chipContent },
93
- heading && (React__default.createElement(React__default.Fragment, null,
94
- React__default.createElement(Typography, { size: "base", fontWeight: "medium" },
95
- heading,
96
- React__default.createElement("span", { ref: headingRef, className: styles$1.chipLabelRef })),
97
- label && React__default.createElement("span", { className: styles$1.chipBar }))),
98
- React__default.createElement(Typography, { size: "base" },
99
- label,
100
- React__default.createElement("span", { ref: labelRef, className: styles$1.chipLabelRef })),
101
- !labelFullyVisible && (React__default.createElement("div", { className: styles$1.truncateGradient, "data-testid": "ATL-Chip-Truncation-Gradient" },
102
- React__default.createElement("span", null)))),
103
- suffix)));
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
- Chip.Prefix = ChipPrefix;
116
- Chip.Suffix = ChipSuffix;
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 { Chip as C, InternalChipButton as I, styles as a, styles$1 as s };
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.Chip, Object.assign({}, rest),
11
- React.createElement(Chip.Chip.Suffix, { className: selected ? Chip.styles.selected : "" },
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.Chip, Object.assign({}, props),
17
- React.createElement(Chip.Chip.Suffix, null,
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 Chip, s as styles } from './Chip-es.js';
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(Chip, Object.assign({}, rest),
9
- React__default.createElement(Chip.Suffix, { className: selected ? styles.selected : "" },
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(Chip, Object.assign({}, props),
15
- React__default.createElement(Chip.Suffix, null,
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.Button || props.children.type === Chip.Chip)) {
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 Button } from './Button-es.js';
2
+ import { B as ButtonNamespace } from './Button-es.js';
3
3
  import 'classnames';
4
- import { C as Chip } from './Chip-es.js';
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 === Button || props.children.type === Chip)) {
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.Button, { size: "small", label: actionLabel, type: "tertiary", onClick: handleSelectAll }))));
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 Button } from './Button-es.js';
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(Button, { size: "small", label: actionLabel, type: "tertiary", onClick: handleSelectAll }))));
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.Chip, { variation: hasSelection ? "base" : "subtle", label: hasSelection ? selectedLabel : "", ariaLabel: label, heading: label, onClick: handleOpen, role: "combobox" }, !hasSelection && (React.createElement(Chip.Chip.Suffix, null,
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 Chip } from './Chip-es.js';
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(Chip, { variation: hasSelection ? "base" : "subtle", label: hasSelection ? selectedLabel : "", ariaLabel: label, heading: label, onClick: handleOpen, role: "combobox" }, !hasSelection && (React__default.createElement(Chip.Suffix, null,
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.Button, { ariaLabel: actionLabel, key: props.label, icon: props.icon, label: actionLabel, onClick: () => {
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.Button, { icon: props.icon, ariaLabel: actionLabel, onClick: () => {
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);