@jobber/components 6.28.0 → 6.29.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.
@@ -1,6 +1,9 @@
1
1
  import { IconNames } from "@jobber/design";
2
2
  import { LinkProps } from "react-router-dom";
3
3
  import { XOR } from "ts-xor";
4
+ import { CSSProperties } from "react";
5
+ import { TypographyProps } from "../Typography/Typography";
6
+ import { IconProps } from "../Icon/Icon";
4
7
  export type HTMLButtonType = "button" | "submit";
5
8
  export type ButtonVariation = "work" | "learning" | "subtle" | "destructive";
6
9
  export type ButtonSize = "small" | "base" | "large";
@@ -22,6 +25,30 @@ export interface ButtonFoundationProps {
22
25
  readonly ariaLabel?: string;
23
26
  onClick?(event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement>): void;
24
27
  onMouseDown?(event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement>): void;
28
+ /**
29
+ * **Use at your own risk:** Custom class names for specific elements. This should only be used as a
30
+ * **last resort**. Using this may result in unexpected side effects.
31
+ * **Note:** If you are applying fill override to buttonIcon.path, you will need to add !important due
32
+ * to Button's children element css inheritance.
33
+ * More information in the [Customizing components Guide](https://atlantis.getjobber.com/guides/customizing-components).
34
+ */
35
+ readonly UNSAFE_className?: {
36
+ container?: string;
37
+ buttonLabel?: TypographyProps["UNSAFE_className"];
38
+ buttonIcon?: IconProps["UNSAFE_className"];
39
+ };
40
+ /**
41
+ * **Use at your own risk:** Custom style for specific elements. This should only be used as a
42
+ * **last resort**. Using this may result in unexpected side effects.
43
+ * **Note:** If you are applying fill override to buttonIcon.path, you will need to add !important due
44
+ * to Button's children element css inheritance.
45
+ * More information in the [Customizing components Guide](https://atlantis.getjobber.com/guides/customizing-components).
46
+ */
47
+ readonly UNSAFE_style?: {
48
+ container?: CSSProperties;
49
+ buttonLabel?: TypographyProps["UNSAFE_style"];
50
+ buttonIcon?: IconProps["UNSAFE_style"];
51
+ };
25
52
  }
26
53
  interface ButtonNonComposableProps extends ButtonFoundationProps {
27
54
  readonly icon?: IconNames;
@@ -5,6 +5,6 @@ import { TypographyProps } from "../Typography";
5
5
  * For backwards compatibility with the legacy button
6
6
  * @deprecated Used composed solution instead
7
7
  */
8
- export declare function ButtonContent({ label, icon, size, iconOnRight, }: Pick<ButtonProps, "label" | "icon" | "size" | "iconOnRight">): JSX.Element;
9
- export declare function ButtonIcon({ size: sizeProp, ...props }: Pick<IconProps, "size" | "name" | "testID">): JSX.Element;
8
+ export declare function ButtonContent({ label, icon, size, iconOnRight, UNSAFE_className, UNSAFE_style, }: Pick<ButtonProps, "label" | "icon" | "size" | "iconOnRight" | "UNSAFE_className" | "UNSAFE_style">): JSX.Element;
9
+ export declare function ButtonIcon({ size: sizeProp, ...props }: Pick<IconProps, "size" | "name" | "testID" | "UNSAFE_className" | "UNSAFE_style">): JSX.Element;
10
10
  export declare function ButtonLabel({ element, fontWeight, fontFamily, size: sizeProp, ...props }: Omit<TypographyProps, "textColor">): JSX.Element;
@@ -39,11 +39,11 @@ function useButtonStyles({ size: sizeProp, disabled, fullWidth, loading, variati
39
39
  * For backwards compatibility with the legacy button
40
40
  * @deprecated Used composed solution instead
41
41
  */
42
- function ButtonContent({ label, icon, size = "base", iconOnRight = false, }) {
42
+ function ButtonContent({ label, icon, size = "base", iconOnRight = false, UNSAFE_className, UNSAFE_style, }) {
43
43
  return (React.createElement(React.Fragment, null,
44
- icon && !iconOnRight && React.createElement(ButtonIcon, { name: icon, size: size }),
45
- label && React.createElement(ButtonLabel, { size: size }, label),
46
- icon && iconOnRight && React.createElement(ButtonIcon, { name: icon, size: size })));
44
+ icon && !iconOnRight && (React.createElement(ButtonIcon, { name: icon, size: size, UNSAFE_className: UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.buttonIcon, UNSAFE_style: UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.buttonIcon })),
45
+ label && (React.createElement(ButtonLabel, { size: size, UNSAFE_className: UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.buttonLabel, UNSAFE_style: UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.buttonLabel }, label)),
46
+ icon && iconOnRight && (React.createElement(ButtonIcon, { name: icon, size: size, UNSAFE_className: UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.buttonIcon, UNSAFE_style: UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.buttonIcon }))));
47
47
  }
48
48
  function getTypeSizes(size) {
49
49
  switch (size) {
@@ -74,12 +74,13 @@ function Button(props) {
74
74
  React.createElement(ButtonWrapper, Object.assign({}, props))));
75
75
  }
76
76
  function ButtonWrapper(props) {
77
- const { ariaControls, ariaHaspopup, ariaExpanded, ariaLabel, disabled = false, external, id, name, onClick, onMouseDown, role, value, submit, to, url, } = props;
77
+ const { ariaControls, ariaHaspopup, ariaExpanded, ariaLabel, disabled = false, external, id, name, onClick, onMouseDown, role, value, submit, to, url, UNSAFE_className = {}, UNSAFE_style = {}, children, } = props;
78
78
  const { combined } = useButtonStyles(props);
79
79
  const buttonType = submit ? "submit" : "button";
80
- const tagProps = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ className: combined, disabled,
81
- id }, (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
- const buttonInternals = props.children || React.createElement(ButtonContent, Object.assign({}, props));
80
+ 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 });
83
+ const buttonInternals = children || React.createElement(ButtonContent, Object.assign({}, props));
83
84
  if (to) {
84
85
  return (React.createElement(reactRouterDom.Link, Object.assign({}, tagProps, { to: to }), buttonInternals));
85
86
  }
package/dist/Button-es.js CHANGED
@@ -37,11 +37,11 @@ function useButtonStyles({ size: sizeProp, disabled, fullWidth, loading, variati
37
37
  * For backwards compatibility with the legacy button
38
38
  * @deprecated Used composed solution instead
39
39
  */
40
- function ButtonContent({ label, icon, size = "base", iconOnRight = false, }) {
40
+ function ButtonContent({ label, icon, size = "base", iconOnRight = false, UNSAFE_className, UNSAFE_style, }) {
41
41
  return (React__default.createElement(React__default.Fragment, null,
42
- icon && !iconOnRight && React__default.createElement(ButtonIcon, { name: icon, size: size }),
43
- label && React__default.createElement(ButtonLabel, { size: size }, label),
44
- icon && iconOnRight && React__default.createElement(ButtonIcon, { name: icon, size: size })));
42
+ icon && !iconOnRight && (React__default.createElement(ButtonIcon, { name: icon, size: size, UNSAFE_className: UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.buttonIcon, UNSAFE_style: UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.buttonIcon })),
43
+ label && (React__default.createElement(ButtonLabel, { size: size, UNSAFE_className: UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.buttonLabel, UNSAFE_style: UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.buttonLabel }, label)),
44
+ icon && iconOnRight && (React__default.createElement(ButtonIcon, { name: icon, size: size, UNSAFE_className: UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.buttonIcon, UNSAFE_style: UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.buttonIcon }))));
45
45
  }
46
46
  function getTypeSizes(size) {
47
47
  switch (size) {
@@ -72,12 +72,13 @@ function Button(props) {
72
72
  React__default.createElement(ButtonWrapper, Object.assign({}, props))));
73
73
  }
74
74
  function ButtonWrapper(props) {
75
- const { ariaControls, ariaHaspopup, ariaExpanded, ariaLabel, disabled = false, external, id, name, onClick, onMouseDown, role, value, submit, to, url, } = props;
75
+ const { ariaControls, ariaHaspopup, ariaExpanded, ariaLabel, disabled = false, external, id, name, onClick, onMouseDown, role, value, submit, to, url, UNSAFE_className = {}, UNSAFE_style = {}, children, } = props;
76
76
  const { combined } = useButtonStyles(props);
77
77
  const buttonType = submit ? "submit" : "button";
78
- const tagProps = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ className: combined, disabled,
79
- id }, (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 });
80
- const buttonInternals = props.children || React__default.createElement(ButtonContent, Object.assign({}, props));
78
+ 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 });
81
+ const buttonInternals = children || React__default.createElement(ButtonContent, Object.assign({}, props));
81
82
  if (to) {
82
83
  return (React__default.createElement(Link, Object.assign({}, tagProps, { to: to }), buttonInternals));
83
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "6.28.0",
3
+ "version": "6.29.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -490,5 +490,5 @@
490
490
  "> 1%",
491
491
  "IE 10"
492
492
  ],
493
- "gitHead": "27d46e235ce983b4cbbf07db3b588188949e1515"
493
+ "gitHead": "c89f5374f8dcd1c9c19e79b39adb7cf1de8a5c02"
494
494
  }