@jobber/components 7.1.2 → 7.2.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.
@@ -2,7 +2,13 @@ import React from "react";
2
2
  import { ChipPrefix } from "./components/ChipPrefix/Chip.Prefix";
3
3
  import { ChipSuffix } from "./components/ChipSuffix/Chip.Suffix";
4
4
  import type { ChipProps } from "./Chip.types";
5
- export declare const Chip: React.ForwardRefExoticComponent<ChipProps & React.RefAttributes<HTMLDivElement | HTMLButtonElement>> & {
5
+ type ChipElement = HTMLButtonElement | HTMLDivElement;
6
+ export declare const Chip: React.ForwardRefExoticComponent<ChipProps & React.HTMLAttributes<ChipElement> & {
7
+ readonly "data-testid"?: string;
8
+ readonly className?: string;
9
+ readonly style?: React.CSSProperties;
10
+ } & React.RefAttributes<HTMLDivElement | HTMLButtonElement>> & {
6
11
  Prefix: typeof ChipPrefix;
7
12
  Suffix: typeof ChipSuffix;
8
13
  };
14
+ export {};
@@ -44,9 +44,14 @@ export interface ChipProps extends PropsWithChildren {
44
44
  */
45
45
  readonly variation?: ChipVariations;
46
46
  /**
47
- * Chip Click Callback. Sends an event and sometimes a value (SelectableChip).
47
+ * Chip click callback using a standard event-first signature.
48
48
  */
49
- readonly onClick?: (value: string | number | undefined, ev: React.MouseEvent<HTMLButtonElement | HTMLDivElement>) => void;
49
+ readonly onClick?: (ev: React.MouseEvent<HTMLButtonElement | HTMLDivElement>) => void;
50
+ /**
51
+ * Value-first click callback retained as an upgrade path for existing consumers.
52
+ * @deprecated Prefer `onClick` with a closure over the value.
53
+ */
54
+ readonly onClickValue?: (value: string | number | undefined, ev: React.MouseEvent<HTMLButtonElement | HTMLDivElement>) => void;
50
55
  /**
51
56
  * Callback. Called when you keydown on Chip. Ships the event, so you can get the key pushed.
52
57
  */
@@ -2,6 +2,7 @@
2
2
 
3
3
  var Chip = require('../Chip-cjs.js');
4
4
  var ChipDismissible = require('../ChipDismissible-cjs.js');
5
+ require('../tslib.es6-cjs.js');
5
6
  require('react');
6
7
  require('classnames');
7
8
  require('@jobber/hooks');
@@ -18,7 +19,6 @@ require('react/jsx-runtime');
18
19
  require('react-dom');
19
20
  require('../floating-ui.react-dom-cjs.js');
20
21
  require('framer-motion');
21
- require('../tslib.es6-cjs.js');
22
22
 
23
23
 
24
24
 
@@ -1,5 +1,6 @@
1
1
  export { C as Chip } from '../Chip-es.js';
2
2
  export { a as ChipDismissible, C as ChipSelectable } from '../ChipDismissible-es.js';
3
+ import '../tslib.es6-es.js';
3
4
  import 'react';
4
5
  import 'classnames';
5
6
  import '@jobber/hooks';
@@ -16,4 +17,3 @@ import 'react/jsx-runtime';
16
17
  import 'react-dom';
17
18
  import '../floating-ui.react-dom-es.js';
18
19
  import 'framer-motion';
19
- import '../tslib.es6-es.js';
package/dist/Chip-cjs.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var tslib_es6 = require('./tslib.es6-cjs.js');
3
4
  var React = require('react');
4
5
  var classnames = require('classnames');
5
6
  var jobberHooks = require('@jobber/hooks');
@@ -64,13 +65,14 @@ function ChipSuffix({ children, className, onClick, testID, ariaLabel, }) {
64
65
  return (React.createElement("span", { className: classnames(onClick ? styles$1.clickableSuffix : styles$1.suffix, className, !singleChild && styles$1.empty), onClick: handleClick, onKeyPress: handleClick, role: onClick ? "button" : undefined, tabIndex: onClick ? 0 : undefined, "data-testid": testID, "aria-label": ariaLabel }, singleChild));
65
66
  }
66
67
 
67
- const ChipComponent = React.forwardRef(({ ariaLabel, disabled, heading, invalid, label, value, testID, onClick, onKeyDown, children, role = "button", tabIndex = 0, variation = "base", }, ref) => {
68
+ const ChipComponent = React.forwardRef((_a, ref) => {
69
+ var { ariaLabel, "aria-label": ariaLabelProp, disabled, heading, invalid, label, value, testID, onClick, onClickValue, onKeyDown, children, role = "button", tabIndex = 0, variation = "base", className, style, onFocus, onBlur, onPointerDown, onPointerUp, onPointerEnter, onPointerLeave, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, onTouchStart, onTouchEnd, onContextMenu, title, "data-testid": dataTestId } = _a, rest = tslib_es6.__rest(_a, ["ariaLabel", "aria-label", "disabled", "heading", "invalid", "label", "value", "testID", "onClick", "onClickValue", "onKeyDown", "children", "role", "tabIndex", "variation", "className", "style", "onFocus", "onBlur", "onPointerDown", "onPointerUp", "onPointerEnter", "onPointerLeave", "onMouseDown", "onMouseUp", "onMouseEnter", "onMouseLeave", "onTouchStart", "onTouchEnd", "onContextMenu", "title", "data-testid"]);
68
70
  const classes = classnames(styles$1.chip, {
69
71
  [styles$1.invalid]: invalid,
70
72
  [styles$1.base]: variation === "base",
71
73
  [styles$1.subtle]: variation === "subtle",
72
74
  [styles$1.disabled]: disabled,
73
- });
75
+ }, className);
74
76
  const prefix = useChildComponent.useChildComponent(children, d => d.type === ChipPrefix);
75
77
  const suffix = useChildComponent.useChildComponent(children, d => d.type === ChipSuffix);
76
78
  const [labelRef, labelFullyVisible] = jobberHooks.useInView();
@@ -90,29 +92,42 @@ const ChipComponent = React.forwardRef(({ ariaLabel, disabled, heading, invalid,
90
92
  !labelFullyVisible && (React.createElement("div", { className: styles$1.truncateGradient, "data-testid": "ATL-Chip-Truncation-Gradient" },
91
93
  React.createElement("span", null)))),
92
94
  suffix));
93
- // Use createElement to properly handle the ref typing
94
- return (React.createElement(Tooltip.Tooltip, { message: tooltipMessage, setTabIndex: false }, onClick
95
- ? React.createElement("button", {
96
- className: classes,
97
- onClick: (ev) => onClick === null || onClick === void 0 ? void 0 : onClick(value, ev),
98
- tabIndex: disabled ? -1 : tabIndex,
99
- onKeyDown,
100
- "aria-label": ariaLabel,
101
- disabled,
102
- role,
103
- "data-testid": testID,
104
- type: "button",
105
- ref,
106
- }, chipContent)
107
- : React.createElement("div", {
108
- className: classes,
109
- tabIndex: disabled ? -1 : tabIndex,
110
- onKeyDown,
111
- "aria-label": ariaLabel,
112
- role,
113
- "data-testid": testID,
114
- ref,
115
- }, chipContent)));
95
+ const isClickable = Boolean(onClick || onClickValue);
96
+ const handleClick = (ev) => {
97
+ onClick === null || onClick === void 0 ? void 0 : onClick(ev);
98
+ onClickValue === null || onClickValue === void 0 ? void 0 : onClickValue(value, ev);
99
+ };
100
+ return (React.createElement(Tooltip.Tooltip, { message: tooltipMessage, setTabIndex: false }, isClickable
101
+ ? React.createElement("button", Object.assign(Object.assign({}, rest), { className: classes, style, onClick: handleClick, tabIndex: disabled ? -1 : tabIndex, onKeyDown,
102
+ onFocus,
103
+ onBlur,
104
+ onPointerDown,
105
+ onPointerUp,
106
+ onPointerEnter,
107
+ onPointerLeave,
108
+ onMouseDown,
109
+ onMouseUp,
110
+ onMouseEnter,
111
+ onMouseLeave,
112
+ onTouchStart,
113
+ onTouchEnd,
114
+ onContextMenu, "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : ariaLabelProp, disabled,
115
+ role, "data-testid": testID !== null && testID !== void 0 ? testID : dataTestId, title, type: "button", ref }), chipContent)
116
+ : React.createElement("div", Object.assign(Object.assign({}, rest), { className: classes, style, tabIndex: disabled ? -1 : tabIndex, onKeyDown,
117
+ onFocus,
118
+ onBlur,
119
+ onPointerDown,
120
+ onPointerUp,
121
+ onPointerEnter,
122
+ onPointerLeave,
123
+ onMouseDown,
124
+ onMouseUp,
125
+ onMouseEnter,
126
+ onMouseLeave,
127
+ onTouchStart,
128
+ onTouchEnd,
129
+ onContextMenu, "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : ariaLabelProp, role, "data-testid": testID !== null && testID !== void 0 ? testID : dataTestId, title,
130
+ ref }), chipContent)));
116
131
  });
117
132
  function getTooltipMessage(labelFullyVisible, headingFullyVisible, label, heading) {
118
133
  let message = "";
package/dist/Chip-es.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { _ as __rest } from './tslib.es6-es.js';
1
2
  import React__default, { useRef, forwardRef } from 'react';
2
3
  import classnames from 'classnames';
3
4
  import { useInView } from '@jobber/hooks';
@@ -62,13 +63,14 @@ function ChipSuffix({ children, className, onClick, testID, ariaLabel, }) {
62
63
  return (React__default.createElement("span", { className: classnames(onClick ? styles$1.clickableSuffix : styles$1.suffix, className, !singleChild && styles$1.empty), onClick: handleClick, onKeyPress: handleClick, role: onClick ? "button" : undefined, tabIndex: onClick ? 0 : undefined, "data-testid": testID, "aria-label": ariaLabel }, singleChild));
63
64
  }
64
65
 
65
- const ChipComponent = forwardRef(({ ariaLabel, disabled, heading, invalid, label, value, testID, onClick, onKeyDown, children, role = "button", tabIndex = 0, variation = "base", }, ref) => {
66
+ const ChipComponent = forwardRef((_a, ref) => {
67
+ var { ariaLabel, "aria-label": ariaLabelProp, disabled, heading, invalid, label, value, testID, onClick, onClickValue, onKeyDown, children, role = "button", tabIndex = 0, variation = "base", className, style, onFocus, onBlur, onPointerDown, onPointerUp, onPointerEnter, onPointerLeave, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, onTouchStart, onTouchEnd, onContextMenu, title, "data-testid": dataTestId } = _a, rest = __rest(_a, ["ariaLabel", "aria-label", "disabled", "heading", "invalid", "label", "value", "testID", "onClick", "onClickValue", "onKeyDown", "children", "role", "tabIndex", "variation", "className", "style", "onFocus", "onBlur", "onPointerDown", "onPointerUp", "onPointerEnter", "onPointerLeave", "onMouseDown", "onMouseUp", "onMouseEnter", "onMouseLeave", "onTouchStart", "onTouchEnd", "onContextMenu", "title", "data-testid"]);
66
68
  const classes = classnames(styles$1.chip, {
67
69
  [styles$1.invalid]: invalid,
68
70
  [styles$1.base]: variation === "base",
69
71
  [styles$1.subtle]: variation === "subtle",
70
72
  [styles$1.disabled]: disabled,
71
- });
73
+ }, className);
72
74
  const prefix = useChildComponent(children, d => d.type === ChipPrefix);
73
75
  const suffix = useChildComponent(children, d => d.type === ChipSuffix);
74
76
  const [labelRef, labelFullyVisible] = useInView();
@@ -88,29 +90,42 @@ const ChipComponent = forwardRef(({ ariaLabel, disabled, heading, invalid, label
88
90
  !labelFullyVisible && (React__default.createElement("div", { className: styles$1.truncateGradient, "data-testid": "ATL-Chip-Truncation-Gradient" },
89
91
  React__default.createElement("span", null)))),
90
92
  suffix));
91
- // Use createElement to properly handle the ref typing
92
- return (React__default.createElement(Tooltip, { message: tooltipMessage, setTabIndex: false }, onClick
93
- ? React__default.createElement("button", {
94
- className: classes,
95
- onClick: (ev) => onClick === null || onClick === void 0 ? void 0 : onClick(value, ev),
96
- tabIndex: disabled ? -1 : tabIndex,
97
- onKeyDown,
98
- "aria-label": ariaLabel,
99
- disabled,
100
- role,
101
- "data-testid": testID,
102
- type: "button",
103
- ref,
104
- }, chipContent)
105
- : React__default.createElement("div", {
106
- className: classes,
107
- tabIndex: disabled ? -1 : tabIndex,
108
- onKeyDown,
109
- "aria-label": ariaLabel,
110
- role,
111
- "data-testid": testID,
112
- ref,
113
- }, chipContent)));
93
+ const isClickable = Boolean(onClick || onClickValue);
94
+ const handleClick = (ev) => {
95
+ onClick === null || onClick === void 0 ? void 0 : onClick(ev);
96
+ onClickValue === null || onClickValue === void 0 ? void 0 : onClickValue(value, ev);
97
+ };
98
+ return (React__default.createElement(Tooltip, { message: tooltipMessage, setTabIndex: false }, isClickable
99
+ ? React__default.createElement("button", Object.assign(Object.assign({}, rest), { className: classes, style, onClick: handleClick, tabIndex: disabled ? -1 : tabIndex, onKeyDown,
100
+ onFocus,
101
+ onBlur,
102
+ onPointerDown,
103
+ onPointerUp,
104
+ onPointerEnter,
105
+ onPointerLeave,
106
+ onMouseDown,
107
+ onMouseUp,
108
+ onMouseEnter,
109
+ onMouseLeave,
110
+ onTouchStart,
111
+ onTouchEnd,
112
+ onContextMenu, "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : ariaLabelProp, disabled,
113
+ role, "data-testid": testID !== null && testID !== void 0 ? testID : dataTestId, title, type: "button", ref }), chipContent)
114
+ : React__default.createElement("div", Object.assign(Object.assign({}, rest), { className: classes, style, tabIndex: disabled ? -1 : tabIndex, onKeyDown,
115
+ onFocus,
116
+ onBlur,
117
+ onPointerDown,
118
+ onPointerUp,
119
+ onPointerEnter,
120
+ onPointerLeave,
121
+ onMouseDown,
122
+ onMouseUp,
123
+ onMouseEnter,
124
+ onMouseLeave,
125
+ onTouchStart,
126
+ onTouchEnd,
127
+ onContextMenu, "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : ariaLabelProp, role, "data-testid": testID !== null && testID !== void 0 ? testID : dataTestId, title,
128
+ ref }), chipContent)));
114
129
  });
115
130
  function getTooltipMessage(labelFullyVisible, headingFullyVisible, label, heading) {
116
131
  let message = "";
@@ -3,6 +3,7 @@
3
3
  var ComboboxTrigger = require('../../../ComboboxTrigger-cjs.js');
4
4
  require('react');
5
5
  require('../../../Chip-cjs.js');
6
+ require('../../../tslib.es6-cjs.js');
6
7
  require('classnames');
7
8
  require('@jobber/hooks');
8
9
  require('../../../Avatar-cjs.js');
@@ -18,7 +19,6 @@ require('react/jsx-runtime');
18
19
  require('react-dom');
19
20
  require('../../../floating-ui.react-dom-cjs.js');
20
21
  require('framer-motion');
21
- require('../../../tslib.es6-cjs.js');
22
22
  require('../../../ComboboxProvider-cjs.js');
23
23
 
24
24
 
@@ -1,6 +1,7 @@
1
1
  export { C as ComboboxTrigger } from '../../../ComboboxTrigger-es.js';
2
2
  import 'react';
3
3
  import '../../../Chip-es.js';
4
+ import '../../../tslib.es6-es.js';
4
5
  import 'classnames';
5
6
  import '@jobber/hooks';
6
7
  import '../../../Avatar-es.js';
@@ -16,5 +17,4 @@ import 'react/jsx-runtime';
16
17
  import 'react-dom';
17
18
  import '../../../floating-ui.react-dom-es.js';
18
19
  import 'framer-motion';
19
- import '../../../tslib.es6-es.js';
20
20
  import '../../../ComboboxProvider-es.js';
@@ -14,7 +14,7 @@ var Chip = require('./Chip-cjs.js');
14
14
  require('./tslib.es6-cjs.js');
15
15
 
16
16
  function InternalChip({ label, active = false, disabled = false, invalid = false, prefix, suffix, tabIndex, ariaLabel, onClick, onKeyDown, }) {
17
- return (React.createElement(Chip.Chip, { disabled: disabled, invalid: invalid, onKeyDown: onKeyDown, testID: "ATL-InternalChip", ariaLabel: ariaLabel, tabIndex: tabIndex, variation: active ? "base" : "subtle", role: tabIndex !== undefined ? "option" : undefined, onClick: onClick ? (_, ev) => onClick(ev) : undefined, label: label },
17
+ return (React.createElement(Chip.Chip, { disabled: disabled, invalid: invalid, onKeyDown: onKeyDown, testID: "ATL-InternalChip", ariaLabel: ariaLabel, tabIndex: tabIndex, variation: active ? "base" : "subtle", role: tabIndex !== undefined ? "option" : undefined, onClick: onClick, label: label },
18
18
  prefix && React.createElement(Chip.Chip.Prefix, null, prefix),
19
19
  suffix && React.createElement(Chip.Chip.Suffix, null, suffix)));
20
20
  }
@@ -12,7 +12,7 @@ import { C as Chip, I as InternalChipButton } from './Chip-es.js';
12
12
  import './tslib.es6-es.js';
13
13
 
14
14
  function InternalChip({ label, active = false, disabled = false, invalid = false, prefix, suffix, tabIndex, ariaLabel, onClick, onKeyDown, }) {
15
- return (React__default.createElement(Chip, { disabled: disabled, invalid: invalid, onKeyDown: onKeyDown, testID: "ATL-InternalChip", ariaLabel: ariaLabel, tabIndex: tabIndex, variation: active ? "base" : "subtle", role: tabIndex !== undefined ? "option" : undefined, onClick: onClick ? (_, ev) => onClick(ev) : undefined, label: label },
15
+ return (React__default.createElement(Chip, { disabled: disabled, invalid: invalid, onKeyDown: onKeyDown, testID: "ATL-InternalChip", ariaLabel: ariaLabel, tabIndex: tabIndex, variation: active ? "base" : "subtle", role: tabIndex !== undefined ? "option" : undefined, onClick: onClick, label: label },
16
16
  prefix && React__default.createElement(Chip.Prefix, null, prefix),
17
17
  suffix && React__default.createElement(Chip.Suffix, null, suffix)));
18
18
  }
@@ -362,11 +362,13 @@ those more complex selection flows.
362
362
  |------|------|----------|---------|-------------|
363
363
  | `label` | `string` | Yes | — | The content of the chip. Will be displayed on the right if you include a heading. |
364
364
  | `ariaLabel` | `string` | No | — | Accessible label, which can be different from the primary label. |
365
+ | `data-testid` | `string` | No | — | |
365
366
  | `disabled` | `boolean` | No | — | Disables both mouse and keyboard functionality, and updates the visual style of the Chip to appear disabled. |
366
367
  | `heading` | `string` | No | — | Adds more prominent text to act as a heading. Will be displayed on the left with a | separator. |
367
368
  | `invalid` | `boolean` | No | — | Changes Chip styling to inform the user of an issue. |
368
- | `onClick` | `(value: string | number, ev: MouseEvent<HTMLButtonElement | HTMLDivElement, MouseEvent>) => void` | No | — | Chip Click Callback. Sends an event and sometimes a value (SelectableChip). |
369
- | `onKeyDown` | `(ev: KeyboardEvent<HTMLButtonElement | HTMLDivElement>) => void` | No | — | Callback. Called when you keydown on Chip. Ships the event, so you can get the key pushed. |
369
+ | `onClick` | `((ev: MouseEvent<HTMLButtonElement | HTMLDivElement, MouseEvent>) => void) & MouseEventHandler<ChipElement>` | No | — | Chip click callback using a standard event-first signature. |
370
+ | `onClickValue` | `(value: string | number, ev: MouseEvent<HTMLButtonElement | HTMLDivElement, MouseEvent>) => void` | No | — | Value-first click callback retained as an upgrade path for existing consumers. @deprecated Prefer `onClick` with a cl... |
371
+ | `onKeyDown` | `((ev: KeyboardEvent<HTMLButtonElement | HTMLDivElement>) => void) & KeyboardEventHandler<ChipElement>` | No | — | Callback. Called when you keydown on Chip. Ships the event, so you can get the key pushed. |
370
372
  | `ref` | `Ref<HTMLButtonElement | HTMLDivElement>` | No | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (... |
371
373
  | `role` | `string` | No | `button` | The accessible role the Chip is fulfilling. Defaults to 'button' |
372
374
  | `tabIndex` | `number` | No | `0` | Used for accessibility purpopses, specifically using the tab key as navigation. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "7.1.2",
3
+ "version": "7.2.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -583,5 +583,5 @@
583
583
  "> 1%",
584
584
  "IE 10"
585
585
  ],
586
- "gitHead": "51968df8e0c2cc9dab415e165643c88284e8bf28"
586
+ "gitHead": "3e24f22e0704d0c879ccd8d76c37ac0ff9866094"
587
587
  }