@jobber/components 6.111.3 → 6.111.5

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.
@@ -59,7 +59,7 @@ function ButtonIcon(_a) {
59
59
  var { size: sizeProp } = _a, props = tslib_es6.__rest(_a, ["size"]);
60
60
  const { size: contextSize } = useButtonContext();
61
61
  const size = sizeProp || contextSize;
62
- return React.createElement(Icon.Icon, Object.assign({}, props, { size: size, "aria-hidden": "true" }));
62
+ return React.createElement(Icon.Icon, Object.assign({}, props, { size: size }));
63
63
  }
64
64
  function ButtonLabel(_a) {
65
65
  var { element = "span", fontWeight = "semiBold", fontFamily = "base", size: sizeProp } = _a, props = tslib_es6.__rest(_a, ["element", "fontWeight", "fontFamily", "size"]);
package/dist/Button-es.js CHANGED
@@ -57,7 +57,7 @@ function ButtonIcon(_a) {
57
57
  var { size: sizeProp } = _a, props = __rest(_a, ["size"]);
58
58
  const { size: contextSize } = useButtonContext();
59
59
  const size = sizeProp || contextSize;
60
- return React__default.createElement(Icon, Object.assign({}, props, { size: size, "aria-hidden": "true" }));
60
+ return React__default.createElement(Icon, Object.assign({}, props, { size: size }));
61
61
  }
62
62
  function ButtonLabel(_a) {
63
63
  var { element = "span", fontWeight = "semiBold", fontFamily = "base", size: sizeProp } = _a, props = __rest(_a, ["element", "fontWeight", "fontFamily", "size"]);
@@ -1,4 +1,4 @@
1
- import type { AriaAttributes, CSSProperties } from "react";
1
+ import type { CSSProperties } from "react";
2
2
  import React from "react";
3
3
  import type { IconColorNames, IconNames, IconSizes } from "@jobber/design";
4
4
  export type { IconColorNames, IconNames } from "@jobber/design";
@@ -24,11 +24,6 @@ export interface IconProps {
24
24
  * Used to locate this view in end-to-end tests
25
25
  */
26
26
  readonly testID?: string;
27
- /**
28
- * Indicates whether the element is exposed to an accessibility API.
29
- * @see {@link https://www.w3.org/TR/wai-aria-1.2/#aria-hidden}
30
- */
31
- readonly "aria-hidden"?: AriaAttributes["aria-hidden"];
32
27
  /**
33
28
  * **Use at your own risk:** Custom classnames for specific elements. This should only be used as a
34
29
  * **last resort**. Using this may result in unexpected side effects.
@@ -48,4 +43,4 @@ export interface IconProps {
48
43
  path?: CSSProperties;
49
44
  };
50
45
  }
51
- export declare function Icon({ name, color, customColor, size, testID, UNSAFE_className, UNSAFE_style, "aria-hidden": ariaHidden, }: IconProps): React.JSX.Element;
46
+ export declare function Icon({ name, color, customColor, size, testID, UNSAFE_className, UNSAFE_style, }: IconProps): React.JSX.Element;
package/dist/Icon-cjs.js CHANGED
@@ -3,7 +3,7 @@
3
3
  var React = require('react');
4
4
  var design = require('@jobber/design');
5
5
 
6
- function Icon({ name, color, customColor, size = "base", testID, UNSAFE_className, UNSAFE_style, "aria-hidden": ariaHidden, }) {
6
+ function Icon({ name, color, customColor, size = "base", testID, UNSAFE_className, UNSAFE_style, }) {
7
7
  let icon;
8
8
  const { svgStyle, pathStyle, paths, viewBox } = design.getIcon({
9
9
  name,
@@ -17,7 +17,7 @@ function Icon({ name, color, customColor, size = "base", testID, UNSAFE_classNam
17
17
  else {
18
18
  icon = paths.map((path) => (React.createElement("path", { key: path, style: Object.assign(Object.assign({}, pathStyle), UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.path), className: UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.path, d: path, fill: customColor })));
19
19
  }
20
- return (React.createElement("svg", { "aria-hidden": ariaHidden, xmlns: "http://www.w3.org/2000/svg", viewBox: viewBox, style: Object.assign(Object.assign({}, svgStyle), UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.svg), className: UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.svg, "data-testid": testID || name }, icon));
20
+ return (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: viewBox, style: Object.assign(Object.assign({}, svgStyle), UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.svg), className: UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.svg, "data-testid": testID || name }, icon));
21
21
  }
22
22
  function getIconColor(name, color) {
23
23
  if (name === "truck") {
package/dist/Icon-es.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import React__default from 'react';
2
2
  import { getIcon } from '@jobber/design';
3
3
 
4
- function Icon({ name, color, customColor, size = "base", testID, UNSAFE_className, UNSAFE_style, "aria-hidden": ariaHidden, }) {
4
+ function Icon({ name, color, customColor, size = "base", testID, UNSAFE_className, UNSAFE_style, }) {
5
5
  let icon;
6
6
  const { svgStyle, pathStyle, paths, viewBox } = getIcon({
7
7
  name,
@@ -15,7 +15,7 @@ function Icon({ name, color, customColor, size = "base", testID, UNSAFE_classNam
15
15
  else {
16
16
  icon = paths.map((path) => (React__default.createElement("path", { key: path, style: Object.assign(Object.assign({}, pathStyle), UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.path), className: UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.path, d: path, fill: customColor })));
17
17
  }
18
- return (React__default.createElement("svg", { "aria-hidden": ariaHidden, xmlns: "http://www.w3.org/2000/svg", viewBox: viewBox, style: Object.assign(Object.assign({}, svgStyle), UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.svg), className: UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.svg, "data-testid": testID || name }, icon));
18
+ return (React__default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: viewBox, style: Object.assign(Object.assign({}, svgStyle), UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.svg), className: UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.svg, "data-testid": testID || name }, icon));
19
19
  }
20
20
  function getIconColor(name, color) {
21
21
  if (name === "truck") {
@@ -41,5 +41,16 @@ interface LightBoxProps {
41
41
  */
42
42
  readonly boxSizing?: CSSProperties["boxSizing"];
43
43
  }
44
+ export declare const slideVariants: {
45
+ enter: (directionRef: React.RefObject<number>) => {
46
+ x: string;
47
+ };
48
+ center: {
49
+ x: number;
50
+ };
51
+ exit: (directionRef: React.RefObject<number>) => {
52
+ x: string;
53
+ };
54
+ };
44
55
  export declare function LightBox({ boxSizing, open, images, imageIndex, onRequestClose, }: LightBoxProps): React.JSX.Element;
45
56
  export {};
@@ -17,20 +17,16 @@ const swipeConfidenceThreshold = 10000;
17
17
  const swipePower = (offset, velocity) => {
18
18
  return Math.abs(offset) * velocity;
19
19
  };
20
- const variants = {
21
- enter: (direction) => {
22
- return {
23
- x: direction > 0 ? "150%" : "-150%",
24
- };
25
- },
20
+ const slideVariants = {
21
+ enter: (directionRef) => ({
22
+ x: directionRef.current > 0 ? "150%" : "-150%",
23
+ }),
26
24
  center: {
27
25
  x: 0,
28
26
  },
29
- exit: (direction) => {
30
- return {
31
- x: direction < 0 ? "150%" : "-150%",
32
- };
33
- },
27
+ exit: (directionRef) => ({
28
+ x: directionRef.current < 0 ? "150%" : "-150%",
29
+ }),
34
30
  };
35
31
  const imageTransition = {
36
32
  x: { duration: 0.65, ease: [0.42, 0, 0, 1.03] },
@@ -42,7 +38,7 @@ const BUTTON_DEBOUNCE_DELAY = 250;
42
38
  const MOVEMENT_DEBOUNCE_DELAY = 1000;
43
39
  function LightBox({ boxSizing = "content-box", open, images, imageIndex = 0, onRequestClose, }) {
44
40
  const [currentImageIndex, setCurrentImageIndex] = React.useState(imageIndex);
45
- const [direction, setDirection] = React.useState(0);
41
+ const directionRef = React.useRef(0);
46
42
  const [mouseIsStationary, setMouseIsStationary] = React.useState(true);
47
43
  const lightboxRef = jobberHooks.useFocusTrap(open);
48
44
  const selectedThumbnailRef = React.useRef(null);
@@ -94,7 +90,7 @@ function LightBox({ boxSizing = "content-box", open, images, imageIndex = 0, onR
94
90
  React.createElement(ButtonDismiss.ButtonDismiss, { ariaLabel: "Close", onClick: handleRequestClose })))),
95
91
  React.createElement("div", { className: styles.imageArea },
96
92
  React.createElement(framerMotion.AnimatePresence, { initial: false },
97
- React.createElement(framerMotion.motion.img, { key: currentImageIndex, variants: variants, src: images[currentImageIndex].url, custom: direction, className: styles.image, initial: "enter", alt: images[currentImageIndex].alt ||
93
+ React.createElement(framerMotion.motion.img, { key: currentImageIndex, variants: slideVariants, src: images[currentImageIndex].url, custom: directionRef, className: styles.image, initial: "enter", alt: images[currentImageIndex].alt ||
98
94
  images[currentImageIndex].title ||
99
95
  "", animate: "center", exit: "exit", transition: imageTransition, drag: "x", dragConstraints: { left: 0, right: 0 }, dragElastic: 1, onDragEnd: handleOnDragEnd }))),
100
96
  images.length > 1 && (React.createElement(React.Fragment, null,
@@ -116,11 +112,11 @@ function LightBox({ boxSizing = "content-box", open, images, imageIndex = 0, onR
116
112
  ? ReactDOM.createPortal(template, document.body)
117
113
  : template;
118
114
  function handleMovePrevious() {
119
- setDirection(-1);
115
+ directionRef.current = -1;
120
116
  setCurrentImageIndex((currentImageIndex + images.length - 1) % images.length);
121
117
  }
122
118
  function handleMoveNext() {
123
- setDirection(1);
119
+ directionRef.current = 1;
124
120
  setCurrentImageIndex((currentImageIndex + 1) % images.length);
125
121
  }
126
122
  function handleRequestClose() {
@@ -137,10 +133,10 @@ function LightBox({ boxSizing = "content-box", open, images, imageIndex = 0, onR
137
133
  }
138
134
  function handleThumbnailClick(index) {
139
135
  if (index < currentImageIndex) {
140
- setDirection(-1);
136
+ directionRef.current = -1;
141
137
  }
142
138
  else {
143
- setDirection(1);
139
+ directionRef.current = 1;
144
140
  }
145
141
  setCurrentImageIndex(index);
146
142
  }
@@ -15,20 +15,16 @@ const swipeConfidenceThreshold = 10000;
15
15
  const swipePower = (offset, velocity) => {
16
16
  return Math.abs(offset) * velocity;
17
17
  };
18
- const variants = {
19
- enter: (direction) => {
20
- return {
21
- x: direction > 0 ? "150%" : "-150%",
22
- };
23
- },
18
+ const slideVariants = {
19
+ enter: (directionRef) => ({
20
+ x: directionRef.current > 0 ? "150%" : "-150%",
21
+ }),
24
22
  center: {
25
23
  x: 0,
26
24
  },
27
- exit: (direction) => {
28
- return {
29
- x: direction < 0 ? "150%" : "-150%",
30
- };
31
- },
25
+ exit: (directionRef) => ({
26
+ x: directionRef.current < 0 ? "150%" : "-150%",
27
+ }),
32
28
  };
33
29
  const imageTransition = {
34
30
  x: { duration: 0.65, ease: [0.42, 0, 0, 1.03] },
@@ -40,7 +36,7 @@ const BUTTON_DEBOUNCE_DELAY = 250;
40
36
  const MOVEMENT_DEBOUNCE_DELAY = 1000;
41
37
  function LightBox({ boxSizing = "content-box", open, images, imageIndex = 0, onRequestClose, }) {
42
38
  const [currentImageIndex, setCurrentImageIndex] = useState(imageIndex);
43
- const [direction, setDirection] = useState(0);
39
+ const directionRef = useRef(0);
44
40
  const [mouseIsStationary, setMouseIsStationary] = useState(true);
45
41
  const lightboxRef = useFocusTrap(open);
46
42
  const selectedThumbnailRef = useRef(null);
@@ -92,7 +88,7 @@ function LightBox({ boxSizing = "content-box", open, images, imageIndex = 0, onR
92
88
  React__default.createElement(ButtonDismiss, { ariaLabel: "Close", onClick: handleRequestClose })))),
93
89
  React__default.createElement("div", { className: styles.imageArea },
94
90
  React__default.createElement(AnimatePresence, { initial: false },
95
- React__default.createElement(motion.img, { key: currentImageIndex, variants: variants, src: images[currentImageIndex].url, custom: direction, className: styles.image, initial: "enter", alt: images[currentImageIndex].alt ||
91
+ React__default.createElement(motion.img, { key: currentImageIndex, variants: slideVariants, src: images[currentImageIndex].url, custom: directionRef, className: styles.image, initial: "enter", alt: images[currentImageIndex].alt ||
96
92
  images[currentImageIndex].title ||
97
93
  "", animate: "center", exit: "exit", transition: imageTransition, drag: "x", dragConstraints: { left: 0, right: 0 }, dragElastic: 1, onDragEnd: handleOnDragEnd }))),
98
94
  images.length > 1 && (React__default.createElement(React__default.Fragment, null,
@@ -114,11 +110,11 @@ function LightBox({ boxSizing = "content-box", open, images, imageIndex = 0, onR
114
110
  ? ReactDOM__default.createPortal(template, document.body)
115
111
  : template;
116
112
  function handleMovePrevious() {
117
- setDirection(-1);
113
+ directionRef.current = -1;
118
114
  setCurrentImageIndex((currentImageIndex + images.length - 1) % images.length);
119
115
  }
120
116
  function handleMoveNext() {
121
- setDirection(1);
117
+ directionRef.current = 1;
122
118
  setCurrentImageIndex((currentImageIndex + 1) % images.length);
123
119
  }
124
120
  function handleRequestClose() {
@@ -135,10 +131,10 @@ function LightBox({ boxSizing = "content-box", open, images, imageIndex = 0, onR
135
131
  }
136
132
  function handleThumbnailClick(index) {
137
133
  if (index < currentImageIndex) {
138
- setDirection(-1);
134
+ directionRef.current = -1;
139
135
  }
140
136
  else {
141
- setDirection(1);
137
+ directionRef.current = 1;
142
138
  }
143
139
  setCurrentImageIndex(index);
144
140
  }
@@ -72,7 +72,6 @@ function Tooltip({ message, children, preferredPlacement = "top", setTabIndex =
72
72
  ? `${(_d = floatingStyles.arrow) === null || _d === void 0 ? void 0 : _d.y}px`
73
73
  : "",
74
74
  };
75
- const tooltipId = React.useId();
76
75
  return (React.createElement(React.Fragment, null,
77
76
  React.createElement("span", { className: styles.shadowActivator, ref: shadowRef }),
78
77
  children,
@@ -82,7 +81,7 @@ function Tooltip({ message, children, preferredPlacement = "top", setTabIndex =
82
81
  duration: 0.15,
83
82
  delay: 0.3,
84
83
  } },
85
- React.createElement("p", { className: styles.tooltipMessage, id: tooltipId }, message),
84
+ React.createElement("p", { className: styles.tooltipMessage }, message),
86
85
  React.createElement("div", { ref: setArrowRef, style: arrowStyles, className: styles.arrow })))))));
87
86
  function initializeListeners() {
88
87
  const showTooltip = () => {
@@ -95,14 +94,11 @@ function Tooltip({ message, children, preferredPlacement = "top", setTabIndex =
95
94
  var _a;
96
95
  if ((_a = shadowRef === null || shadowRef === void 0 ? void 0 : shadowRef.current) === null || _a === void 0 ? void 0 : _a.nextElementSibling) {
97
96
  const activator = shadowRef.current.nextElementSibling;
98
- // Manually inject "aria-labelledby" and "tabindex" to let the screen
97
+ // Manually inject "aria-description" and "tabindex" to let the screen
99
98
  // readers read the tooltip message.
100
99
  // This is to avoid having to add those attribute as a prop on every
101
100
  // component we have.
102
- // WARNING: This is an anti pattern that should be removed in the future.
103
- // for now, we will leverage the fact that aria-labelledby overrides aria-label, avoiding
104
- // double announcements of the same element assuming it uses "aria-label" as its mechanism.
105
- activator.setAttribute("aria-labelledby", tooltipId);
101
+ activator.setAttribute("aria-description", message);
106
102
  if (setTabIndex) {
107
103
  activator.setAttribute("tabindex", "0"); // enable focus
108
104
  }
@@ -1,4 +1,4 @@
1
- import React__default, { useRef, useState, useId } from 'react';
1
+ import React__default, { useRef, useState } from 'react';
2
2
  import classnames from 'classnames';
3
3
  import { u as useFloating, s as shift, f as flip, a as arrow, h as hide, b as autoUpdate, l as limitShift, F as FloatingPortal } from './floating-ui.react-es.js';
4
4
  import { motion } from 'framer-motion';
@@ -70,7 +70,6 @@ function Tooltip({ message, children, preferredPlacement = "top", setTabIndex =
70
70
  ? `${(_d = floatingStyles.arrow) === null || _d === void 0 ? void 0 : _d.y}px`
71
71
  : "",
72
72
  };
73
- const tooltipId = useId();
74
73
  return (React__default.createElement(React__default.Fragment, null,
75
74
  React__default.createElement("span", { className: styles.shadowActivator, ref: shadowRef }),
76
75
  children,
@@ -80,7 +79,7 @@ function Tooltip({ message, children, preferredPlacement = "top", setTabIndex =
80
79
  duration: 0.15,
81
80
  delay: 0.3,
82
81
  } },
83
- React__default.createElement("p", { className: styles.tooltipMessage, id: tooltipId }, message),
82
+ React__default.createElement("p", { className: styles.tooltipMessage }, message),
84
83
  React__default.createElement("div", { ref: setArrowRef, style: arrowStyles, className: styles.arrow })))))));
85
84
  function initializeListeners() {
86
85
  const showTooltip = () => {
@@ -93,14 +92,11 @@ function Tooltip({ message, children, preferredPlacement = "top", setTabIndex =
93
92
  var _a;
94
93
  if ((_a = shadowRef === null || shadowRef === void 0 ? void 0 : shadowRef.current) === null || _a === void 0 ? void 0 : _a.nextElementSibling) {
95
94
  const activator = shadowRef.current.nextElementSibling;
96
- // Manually inject "aria-labelledby" and "tabindex" to let the screen
95
+ // Manually inject "aria-description" and "tabindex" to let the screen
97
96
  // readers read the tooltip message.
98
97
  // This is to avoid having to add those attribute as a prop on every
99
98
  // component we have.
100
- // WARNING: This is an anti pattern that should be removed in the future.
101
- // for now, we will leverage the fact that aria-labelledby overrides aria-label, avoiding
102
- // double announcements of the same element assuming it uses "aria-label" as its mechanism.
103
- activator.setAttribute("aria-labelledby", tooltipId);
99
+ activator.setAttribute("aria-description", message);
104
100
  if (setTabIndex) {
105
101
  activator.setAttribute("tabindex", "0"); // enable focus
106
102
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "6.111.3",
3
+ "version": "6.111.5",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -538,5 +538,5 @@
538
538
  "> 1%",
539
539
  "IE 10"
540
540
  ],
541
- "gitHead": "f84b3ba0749a6d33ce4367a68d357db3727562e5"
541
+ "gitHead": "74ad056f656ebfec2d55cc1f52703abbd8aaaecc"
542
542
  }