@jobber/components 7.2.0 → 7.4.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 (90) hide show
  1. package/dist/Button/Button.d.ts +8 -2
  2. package/dist/Button/index.cjs +1 -1
  3. package/dist/Button/index.mjs +1 -1
  4. package/dist/Button-cjs.js +35 -10
  5. package/dist/Button-es.js +35 -10
  6. package/dist/ButtonDismiss/index.cjs +1 -1
  7. package/dist/ButtonDismiss/index.mjs +1 -1
  8. package/dist/Card/index.cjs +1 -1
  9. package/dist/Card/index.mjs +1 -1
  10. package/dist/Checkbox/Checkbox.d.ts +6 -2
  11. package/dist/Checkbox/Checkbox.types.d.ts +2 -55
  12. package/dist/Checkbox/index.cjs +7 -92
  13. package/dist/Checkbox/index.d.ts +2 -5
  14. package/dist/Checkbox/index.mjs +6 -95
  15. package/dist/Checkbox-cjs.js +41 -0
  16. package/dist/Checkbox-es.js +39 -0
  17. package/dist/Chips/InternalChipDismissible/index.cjs +1 -1
  18. package/dist/Chips/InternalChipDismissible/index.mjs +1 -1
  19. package/dist/Chips/index.cjs +1 -1
  20. package/dist/Chips/index.mjs +1 -1
  21. package/dist/Combobox/components/ComboboxActivator/index.cjs +1 -1
  22. package/dist/Combobox/components/ComboboxActivator/index.mjs +1 -1
  23. package/dist/Combobox/components/ComboboxContent/ComboboxContentHeader/index.cjs +1 -1
  24. package/dist/Combobox/components/ComboboxContent/ComboboxContentHeader/index.mjs +1 -1
  25. package/dist/ConfirmationModal/index.cjs +1 -1
  26. package/dist/ConfirmationModal/index.mjs +1 -1
  27. package/dist/DataDump/index.cjs +1 -1
  28. package/dist/DataDump/index.mjs +1 -1
  29. package/dist/DataList/components/DataListActions/index.cjs +1 -1
  30. package/dist/DataList/components/DataListActions/index.mjs +1 -1
  31. package/dist/DataList/components/DataListBulkActions/index.cjs +1 -1
  32. package/dist/DataList/components/DataListBulkActions/index.mjs +1 -1
  33. package/dist/DataList/components/DataListHeader/index.cjs +2 -3
  34. package/dist/DataList/components/DataListHeader/index.mjs +2 -3
  35. package/dist/DataList/components/DataListItem/index.cjs +2 -3
  36. package/dist/DataList/components/DataListItem/index.mjs +2 -3
  37. package/dist/DataList/components/DataListItemActions/index.cjs +1 -1
  38. package/dist/DataList/components/DataListItemActions/index.mjs +1 -1
  39. package/dist/DataList/components/DataListItemActionsOverflow/index.cjs +1 -1
  40. package/dist/DataList/components/DataListItemActionsOverflow/index.mjs +1 -1
  41. package/dist/DataList/components/DataListItems/index.cjs +2 -3
  42. package/dist/DataList/components/DataListItems/index.mjs +2 -3
  43. package/dist/DataList/components/DataListLayout/index.cjs +2 -3
  44. package/dist/DataList/components/DataListLayout/index.mjs +2 -3
  45. package/dist/DataList/components/DataListLayoutActions/index.cjs +1 -1
  46. package/dist/DataList/components/DataListLayoutActions/index.mjs +1 -1
  47. package/dist/DataList/components/DataListLoadMore/index.cjs +1 -1
  48. package/dist/DataList/components/DataListLoadMore/index.mjs +1 -1
  49. package/dist/DataList/components/DataListSearch/index.cjs +1 -1
  50. package/dist/DataList/components/DataListSearch/index.mjs +1 -1
  51. package/dist/DataList/index.cjs +2 -2
  52. package/dist/DataList/index.mjs +2 -2
  53. package/dist/DataListHeader-cjs.js +2 -3
  54. package/dist/DataListHeader-es.js +2 -3
  55. package/dist/DataListItem-cjs.js +2 -2
  56. package/dist/DataListItem-es.js +1 -1
  57. package/dist/DatePicker/index.cjs +1 -1
  58. package/dist/DatePicker/index.mjs +1 -1
  59. package/dist/Drawer/index.cjs +1 -1
  60. package/dist/Drawer/index.mjs +1 -1
  61. package/dist/FeatureSwitch/index.cjs +1 -1
  62. package/dist/FeatureSwitch/index.mjs +1 -1
  63. package/dist/FormField/index.cjs +1 -1
  64. package/dist/FormField/index.mjs +1 -1
  65. package/dist/InputPassword/index.cjs +1 -1
  66. package/dist/InputPassword/index.mjs +1 -1
  67. package/dist/LightBox/index.cjs +1 -1
  68. package/dist/LightBox/index.mjs +1 -1
  69. package/dist/Menu/index.cjs +1 -1
  70. package/dist/Menu/index.mjs +1 -1
  71. package/dist/Modal/index.cjs +1 -1
  72. package/dist/Modal/index.mjs +1 -1
  73. package/dist/MultiSelect/index.cjs +1 -3
  74. package/dist/MultiSelect/index.mjs +1 -3
  75. package/dist/MultiSelect-cjs.js +2 -2
  76. package/dist/MultiSelect-es.js +1 -1
  77. package/dist/RecurringSelect/index.cjs +1 -1
  78. package/dist/RecurringSelect/index.mjs +1 -1
  79. package/dist/SideDrawer/index.cjs +1 -1
  80. package/dist/SideDrawer/index.mjs +1 -1
  81. package/dist/Toast/index.cjs +1 -1
  82. package/dist/Toast/index.mjs +1 -1
  83. package/dist/docs/Button/Button.md +4 -4
  84. package/dist/docs/Checkbox/Checkbox.md +24 -10
  85. package/dist/docs/Icon/Icon.md +1 -0
  86. package/dist/docs/usage-guidelines/usage-guidelines.md +0 -1
  87. package/dist/index.cjs +2 -2
  88. package/dist/index.mjs +1 -1
  89. package/package.json +3 -3
  90. package/dist/Checkbox/Checkbox.rebuilt.d.ts +0 -7
@@ -1,7 +1,13 @@
1
1
  import React from "react";
2
- import { type ButtonProps } from "./Button.types";
2
+ import type { ButtonProps } from "./Button.types";
3
3
  import { ButtonIcon, ButtonLabel } from "./ButtonInternals";
4
- declare function Button(props: ButtonProps): React.JSX.Element;
4
+ type ButtonElement = HTMLAnchorElement | HTMLButtonElement;
5
+ type ButtonRuntimeProps = ButtonProps & React.HTMLAttributes<ButtonElement> & {
6
+ readonly className?: string;
7
+ readonly ref?: React.Ref<ButtonElement>;
8
+ readonly style?: React.CSSProperties;
9
+ };
10
+ declare function Button(props: ButtonRuntimeProps): React.JSX.Element;
5
11
  declare namespace Button {
6
12
  var Label: typeof ButtonLabel;
7
13
  var Icon: typeof ButtonIcon;
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  var Button = require('../Button-cjs.js');
4
+ require('../tslib.es6-cjs.js');
4
5
  require('react');
5
6
  require('react-router-dom');
6
7
  require('classnames');
7
- require('../tslib.es6-cjs.js');
8
8
  require('../Icon-cjs.js');
9
9
  require('@jobber/design');
10
10
  require('../Typography-cjs.js');
@@ -1,8 +1,8 @@
1
1
  export { B as Button, a as useButtonContext, u as useButtonStyles } from '../Button-es.js';
2
+ import '../tslib.es6-es.js';
2
3
  import 'react';
3
4
  import 'react-router-dom';
4
5
  import 'classnames';
5
- import '../tslib.es6-es.js';
6
6
  import '../Icon-es.js';
7
7
  import '@jobber/design';
8
8
  import '../Typography-es.js';
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ var tslib_es6 = require('./tslib.es6-cjs.js');
3
4
  var React = require('react');
4
5
  var reactRouterDom = require('react-router-dom');
5
6
  var classnames = require('classnames');
6
- var tslib_es6 = require('./tslib.es6-cjs.js');
7
7
  var Icon = require('./Icon-cjs.js');
8
8
  var Typography = require('./Typography-cjs.js');
9
9
 
@@ -74,22 +74,47 @@ function Button(props) {
74
74
  return (React.createElement(ButtonProvider, { size: size },
75
75
  React.createElement(ButtonWrapper, Object.assign({}, props))));
76
76
  }
77
+ // eslint-disable-next-line max-statements
77
78
  function ButtonWrapper(props) {
78
- const { ariaControls, ariaHaspopup, ariaExpanded, ariaLabel, disabled = false, external, id, name, onClick, onMouseDown, loading, role, value, submit, to, url, UNSAFE_className = {}, UNSAFE_style = {}, children, } = props;
79
+ const { ariaControls, ariaHaspopup, ariaExpanded, ariaLabel, "aria-controls": ariaControlsProp, "aria-haspopup": ariaHaspopupProp, "aria-expanded": ariaExpandedProp, "aria-label": ariaLabelProp, disabled = false, external, id, name, onClick, onMouseDown, loading, role, value, submit, fullWidth: _fullWidth, icon: _icon, iconOnRight: _iconOnRight, label: _label, size: _size, to, type: _type, url, variation: _variation, UNSAFE_className = {}, UNSAFE_style = {}, children, className, style, ref, onKeyDown, onKeyUp, onFocus, onBlur, onPointerDown, onPointerUp, onPointerEnter, onPointerLeave, onMouseEnter, onMouseLeave, onTouchStart, onTouchEnd, onContextMenu, tabIndex, title } = props, rest = tslib_es6.__rest(props, ["ariaControls", "ariaHaspopup", "ariaExpanded", "ariaLabel", "aria-controls", "aria-haspopup", "aria-expanded", "aria-label", "disabled", "external", "id", "name", "onClick", "onMouseDown", "loading", "role", "value", "submit", "fullWidth", "icon", "iconOnRight", "label", "size", "to", "type", "url", "variation", "UNSAFE_className", "UNSAFE_style", "children", "className", "style", "ref", "onKeyDown", "onKeyUp", "onFocus", "onBlur", "onPointerDown", "onPointerUp", "onPointerEnter", "onPointerLeave", "onMouseEnter", "onMouseLeave", "onTouchStart", "onTouchEnd", "onContextMenu", "tabIndex", "title"]);
79
80
  const { combined } = useButtonStyles(props);
80
- const buttonType = submit ? "submit" : "button";
81
- const buttonClassNames = classnames(combined, UNSAFE_className.container);
82
- const tagProps = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ className: buttonClassNames, disabled,
83
- id, style: UNSAFE_style.container }, (submit && { name, value })), (!disabled && { href: url })), (!disabled && { onClick: onClick })), (!disabled && { onMouseDown: onMouseDown })), (external && {
81
+ const isLinkButton = Boolean(url || to);
82
+ const buttonClassNames = classnames(combined, UNSAFE_className.container, className);
83
+ const sharedTagProps = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { className: buttonClassNames, id, style: Object.assign(Object.assign({}, style), UNSAFE_style.container) }), (!disabled && {
84
+ onClick: (event) => {
85
+ onClick === null || onClick === void 0 ? void 0 : onClick(event);
86
+ },
87
+ })), (!disabled && {
88
+ onMouseDown: (event) => {
89
+ onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
90
+ },
91
+ })), (external && {
84
92
  target: "_blank",
85
93
  rel: "noopener noreferrer",
86
- })), (url === undefined && to === undefined && { type: buttonType })), { "aria-controls": ariaControls, "aria-haspopup": ariaHaspopup, "aria-busy": loading, "aria-expanded": ariaExpanded, "aria-label": ariaLabel, role: role });
94
+ })), { "aria-disabled": disabled && isLinkButton ? true : undefined, "aria-controls": ariaControls !== null && ariaControls !== void 0 ? ariaControls : ariaControlsProp, "aria-haspopup": ariaHaspopup !== null && ariaHaspopup !== void 0 ? ariaHaspopup : ariaHaspopupProp, "aria-busy": loading, "aria-expanded": ariaExpanded !== null && ariaExpanded !== void 0 ? ariaExpanded : ariaExpandedProp, "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : ariaLabelProp, role,
95
+ tabIndex,
96
+ title,
97
+ onKeyDown,
98
+ onKeyUp,
99
+ onFocus,
100
+ onBlur,
101
+ onPointerDown,
102
+ onPointerUp,
103
+ onPointerEnter,
104
+ onPointerLeave,
105
+ onMouseEnter,
106
+ onMouseLeave,
107
+ onTouchStart,
108
+ onTouchEnd,
109
+ onContextMenu });
87
110
  const buttonInternals = children || React.createElement(ButtonContent, Object.assign({}, props));
88
111
  if (to) {
89
- return (React.createElement(reactRouterDom.Link, Object.assign({}, tagProps, { to: to }), buttonInternals));
112
+ return (React.createElement(reactRouterDom.Link, Object.assign({}, sharedTagProps, { to: to }), buttonInternals));
113
+ }
114
+ if (url) {
115
+ return (React.createElement("a", Object.assign({}, sharedTagProps, { ref: ref, href: !disabled ? url : undefined }), buttonInternals));
90
116
  }
91
- const Tag = url ? "a" : "button";
92
- return React.createElement(Tag, Object.assign({}, tagProps), buttonInternals);
117
+ return (React.createElement("button", Object.assign({}, sharedTagProps, { ref: ref, type: submit ? "submit" : "button", disabled: disabled }, (submit ? { name, value } : {})), buttonInternals));
93
118
  }
94
119
  Button.Label = ButtonLabel;
95
120
  Button.Icon = ButtonIcon;
package/dist/Button-es.js CHANGED
@@ -1,7 +1,7 @@
1
+ import { _ as __rest } from './tslib.es6-es.js';
1
2
  import React__default, { createContext, useContext } from 'react';
2
3
  import { Link } from 'react-router-dom';
3
4
  import classnames from 'classnames';
4
- import { _ as __rest } from './tslib.es6-es.js';
5
5
  import { I as Icon } from './Icon-es.js';
6
6
  import { T as Typography } from './Typography-es.js';
7
7
 
@@ -72,22 +72,47 @@ function Button(props) {
72
72
  return (React__default.createElement(ButtonProvider, { size: size },
73
73
  React__default.createElement(ButtonWrapper, Object.assign({}, props))));
74
74
  }
75
+ // eslint-disable-next-line max-statements
75
76
  function ButtonWrapper(props) {
76
- const { ariaControls, ariaHaspopup, ariaExpanded, ariaLabel, disabled = false, external, id, name, onClick, onMouseDown, loading, role, value, submit, to, url, UNSAFE_className = {}, UNSAFE_style = {}, children, } = props;
77
+ const { ariaControls, ariaHaspopup, ariaExpanded, ariaLabel, "aria-controls": ariaControlsProp, "aria-haspopup": ariaHaspopupProp, "aria-expanded": ariaExpandedProp, "aria-label": ariaLabelProp, disabled = false, external, id, name, onClick, onMouseDown, loading, role, value, submit, fullWidth: _fullWidth, icon: _icon, iconOnRight: _iconOnRight, label: _label, size: _size, to, type: _type, url, variation: _variation, UNSAFE_className = {}, UNSAFE_style = {}, children, className, style, ref, onKeyDown, onKeyUp, onFocus, onBlur, onPointerDown, onPointerUp, onPointerEnter, onPointerLeave, onMouseEnter, onMouseLeave, onTouchStart, onTouchEnd, onContextMenu, tabIndex, title } = props, rest = __rest(props, ["ariaControls", "ariaHaspopup", "ariaExpanded", "ariaLabel", "aria-controls", "aria-haspopup", "aria-expanded", "aria-label", "disabled", "external", "id", "name", "onClick", "onMouseDown", "loading", "role", "value", "submit", "fullWidth", "icon", "iconOnRight", "label", "size", "to", "type", "url", "variation", "UNSAFE_className", "UNSAFE_style", "children", "className", "style", "ref", "onKeyDown", "onKeyUp", "onFocus", "onBlur", "onPointerDown", "onPointerUp", "onPointerEnter", "onPointerLeave", "onMouseEnter", "onMouseLeave", "onTouchStart", "onTouchEnd", "onContextMenu", "tabIndex", "title"]);
77
78
  const { combined } = useButtonStyles(props);
78
- const buttonType = submit ? "submit" : "button";
79
- const buttonClassNames = classnames(combined, UNSAFE_className.container);
80
- const tagProps = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ className: buttonClassNames, disabled,
81
- id, style: UNSAFE_style.container }, (submit && { name, value })), (!disabled && { href: url })), (!disabled && { onClick: onClick })), (!disabled && { onMouseDown: onMouseDown })), (external && {
79
+ const isLinkButton = Boolean(url || to);
80
+ const buttonClassNames = classnames(combined, UNSAFE_className.container, className);
81
+ const sharedTagProps = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { className: buttonClassNames, id, style: Object.assign(Object.assign({}, style), UNSAFE_style.container) }), (!disabled && {
82
+ onClick: (event) => {
83
+ onClick === null || onClick === void 0 ? void 0 : onClick(event);
84
+ },
85
+ })), (!disabled && {
86
+ onMouseDown: (event) => {
87
+ onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
88
+ },
89
+ })), (external && {
82
90
  target: "_blank",
83
91
  rel: "noopener noreferrer",
84
- })), (url === undefined && to === undefined && { type: buttonType })), { "aria-controls": ariaControls, "aria-haspopup": ariaHaspopup, "aria-busy": loading, "aria-expanded": ariaExpanded, "aria-label": ariaLabel, role: role });
92
+ })), { "aria-disabled": disabled && isLinkButton ? true : undefined, "aria-controls": ariaControls !== null && ariaControls !== void 0 ? ariaControls : ariaControlsProp, "aria-haspopup": ariaHaspopup !== null && ariaHaspopup !== void 0 ? ariaHaspopup : ariaHaspopupProp, "aria-busy": loading, "aria-expanded": ariaExpanded !== null && ariaExpanded !== void 0 ? ariaExpanded : ariaExpandedProp, "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : ariaLabelProp, role,
93
+ tabIndex,
94
+ title,
95
+ onKeyDown,
96
+ onKeyUp,
97
+ onFocus,
98
+ onBlur,
99
+ onPointerDown,
100
+ onPointerUp,
101
+ onPointerEnter,
102
+ onPointerLeave,
103
+ onMouseEnter,
104
+ onMouseLeave,
105
+ onTouchStart,
106
+ onTouchEnd,
107
+ onContextMenu });
85
108
  const buttonInternals = children || React__default.createElement(ButtonContent, Object.assign({}, props));
86
109
  if (to) {
87
- return (React__default.createElement(Link, Object.assign({}, tagProps, { to: to }), buttonInternals));
110
+ return (React__default.createElement(Link, Object.assign({}, sharedTagProps, { to: to }), buttonInternals));
111
+ }
112
+ if (url) {
113
+ return (React__default.createElement("a", Object.assign({}, sharedTagProps, { ref: ref, href: !disabled ? url : undefined }), buttonInternals));
88
114
  }
89
- const Tag = url ? "a" : "button";
90
- return React__default.createElement(Tag, Object.assign({}, tagProps), buttonInternals);
115
+ return (React__default.createElement("button", Object.assign({}, sharedTagProps, { ref: ref, type: submit ? "submit" : "button", disabled: disabled }, (submit ? { name, value } : {})), buttonInternals));
91
116
  }
92
117
  Button.Label = ButtonLabel;
93
118
  Button.Icon = ButtonIcon;
@@ -3,9 +3,9 @@
3
3
  var ButtonDismiss = require('../ButtonDismiss-cjs.js');
4
4
  require('react');
5
5
  require('../Button-cjs.js');
6
+ require('../tslib.es6-cjs.js');
6
7
  require('react-router-dom');
7
8
  require('classnames');
8
- require('../tslib.es6-cjs.js');
9
9
  require('../Icon-cjs.js');
10
10
  require('@jobber/design');
11
11
  require('../Typography-cjs.js');
@@ -1,9 +1,9 @@
1
1
  export { B as ButtonDismiss } from '../ButtonDismiss-es.js';
2
2
  import 'react';
3
3
  import '../Button-es.js';
4
+ import '../tslib.es6-es.js';
4
5
  import 'react-router-dom';
5
6
  import 'classnames';
6
- import '../tslib.es6-es.js';
7
7
  import '../Icon-es.js';
8
8
  import '@jobber/design';
9
9
  import '../Typography-es.js';
@@ -6,8 +6,8 @@ require('classnames');
6
6
  require('../Heading-cjs.js');
7
7
  require('../Typography-cjs.js');
8
8
  require('../Button-cjs.js');
9
- require('react-router-dom');
10
9
  require('../tslib.es6-cjs.js');
10
+ require('react-router-dom');
11
11
  require('../Icon-cjs.js');
12
12
  require('@jobber/design');
13
13
  require('../Menu-cjs.js');
@@ -4,8 +4,8 @@ import 'classnames';
4
4
  import '../Heading-es.js';
5
5
  import '../Typography-es.js';
6
6
  import '../Button-es.js';
7
- import 'react-router-dom';
8
7
  import '../tslib.es6-es.js';
8
+ import 'react-router-dom';
9
9
  import '../Icon-es.js';
10
10
  import '@jobber/design';
11
11
  import '../Menu-es.js';
@@ -1,3 +1,7 @@
1
1
  import React from "react";
2
- import type { CheckboxLegacyProps } from "./Checkbox.types";
3
- export declare function CheckboxLegacy({ checked, defaultChecked, disabled, label, name, value, indeterminate, description, children, onBlur, onChange, onFocus, }: CheckboxLegacyProps): React.JSX.Element;
2
+ export declare const Checkbox: React.ForwardRefExoticComponent<import("./Checkbox.types").CheckboxCoreProps & import("../sharedHelpers/types").AriaInputProps & import("../sharedHelpers/types").FocusEvents<HTMLInputElement> & import("../sharedHelpers/types").MouseEvents<HTMLInputElement> & Pick<import("../sharedHelpers/types").HTMLInputBaseProps, "id" | "name" | "disabled"> & {
3
+ label?: string | React.ReactElement;
4
+ description?: React.ReactNode;
5
+ invalid?: boolean;
6
+ onChange?(newValue: boolean, event: React.ChangeEvent<HTMLInputElement>): void;
7
+ } & React.RefAttributes<HTMLInputElement>>;
@@ -1,6 +1,5 @@
1
1
  import type { ReactElement, ReactNode } from "react";
2
- import type { XOR } from "ts-xor";
3
- import type { AriaInputProps, FocusEvents, HTMLInputBaseProps, MouseEvents, RebuiltInputCommonProps } from "../sharedHelpers/types";
2
+ import type { AriaInputProps, FocusEvents, HTMLInputBaseProps, MouseEvents } from "../sharedHelpers/types";
4
3
  /**
5
4
  * Shared checkbox-specific props used by both legacy and rebuilt versions
6
5
  */
@@ -26,52 +25,7 @@ export interface CheckboxCoreProps {
26
25
  */
27
26
  readonly value?: string;
28
27
  }
29
- /**
30
- * Base props for legacy checkbox
31
- */
32
- export interface BaseCheckboxProps extends CheckboxCoreProps {
33
- /**
34
- * Disables the checkbox.
35
- */
36
- readonly disabled?: boolean;
37
- /**
38
- * Checkbox input name
39
- */
40
- readonly name?: string;
41
- /**
42
- * Further description of the label
43
- */
44
- readonly description?: ReactNode;
45
- /**
46
- * ID for the checkbox input
47
- */
48
- readonly id?: string;
49
- /**
50
- * Called when the checkbox value changes
51
- */
52
- onChange?(newValue: boolean): void;
53
- /**
54
- * Called when the checkbox is focused
55
- */
56
- onFocus?(event: React.FocusEvent<HTMLInputElement>): void;
57
- /**
58
- * Called when the checkbox loses focus
59
- */
60
- onBlur?(event: React.FocusEvent<HTMLInputElement>): void;
61
- }
62
- interface CheckboxLabelProps extends BaseCheckboxProps {
63
- /**
64
- * Label that shows up beside the checkbox.
65
- */
66
- readonly label?: string;
67
- }
68
- interface CheckboxChildrenProps extends BaseCheckboxProps {
69
- /**
70
- * Component children, which shows up as a label
71
- */
72
- readonly children?: ReactElement;
73
- }
74
- export type CheckboxRebuiltProps = CheckboxCoreProps & AriaInputProps & FocusEvents<HTMLInputElement> & MouseEvents<HTMLInputElement> & Pick<HTMLInputBaseProps, "id" | "name" | "disabled"> & Pick<RebuiltInputCommonProps, "version"> & {
28
+ export type CheckboxProps = CheckboxCoreProps & AriaInputProps & FocusEvents<HTMLInputElement> & MouseEvents<HTMLInputElement> & Pick<HTMLInputBaseProps, "id" | "name" | "disabled"> & {
75
29
  /**
76
30
  * Label that shows up beside the checkbox.
77
31
  * String will be rendered with the default markup.
@@ -95,10 +49,3 @@ export type CheckboxRebuiltProps = CheckboxCoreProps & AriaInputProps & FocusEve
95
49
  */
96
50
  onChange?(newValue: boolean, event: React.ChangeEvent<HTMLInputElement>): void;
97
51
  };
98
- /**
99
- * @deprecated Use the v2 Checkbox component instead (version={2}).
100
- */
101
- export type CheckboxLegacyProps = XOR<CheckboxLabelProps, CheckboxChildrenProps> & {
102
- version?: 1;
103
- };
104
- export {};
@@ -1,99 +1,14 @@
1
1
  'use strict';
2
2
 
3
- var React = require('react');
4
- var tslib_es6 = require('../tslib.es6-cjs.js');
5
- var classnames = require('classnames');
6
- var reactHookForm = require('react-hook-form');
7
- var Icon = require('../Icon-cjs.js');
8
- var Text = require('../Text-cjs.js');
9
- var filterDataAttributes = require('../filterDataAttributes-cjs.js');
3
+ var Checkbox = require('../Checkbox-cjs.js');
4
+ require('react');
5
+ require('classnames');
6
+ require('../Icon-cjs.js');
10
7
  require('@jobber/design');
8
+ require('../Text-cjs.js');
11
9
  require('../Typography-cjs.js');
10
+ require('../filterDataAttributes-cjs.js');
12
11
 
13
- var styles = {"checkBoxParent":"YxKKPXAU10s-","wrapper":"KxWx-msbH9c-","disabled":"TKr3J-6ARFo-","checkHolder":"NO34ZbhNqhI-","input":"XnCmS-EzK2M-","checkBox":"_-8JCQE6SA9s-","indeterminate":"rqHq3ff9In0-","invalid":"Gqnclw4WaeQ-","label":"l8z5TxzVvqA-","description":"DcBfVgpiWa4-","spinning":"rFBN9M5-4Ok-"};
14
12
 
15
- function CheckboxLegacy({ checked, defaultChecked, disabled, label, name, value, indeterminate = false, description, children, onBlur, onChange, onFocus, }) {
16
- const { control, setValue, watch } = reactHookForm.useFormContext() != undefined
17
- ? reactHookForm.useFormContext()
18
- : // If there isn't a Form Context being provided, get a form for this field.
19
- reactHookForm.useForm({ mode: "onTouched" });
20
- const [identifier] = React.useState(React.useId());
21
- /**
22
- * Generate a name if one is not supplied, this is the name
23
- * that will be used for react-hook-form and not neccessarily
24
- * attached to the DOM
25
- */
26
- const [controlledName] = React.useState(name ? name : `generatedName--${identifier}`);
27
- React.useEffect(() => {
28
- if (value != undefined) {
29
- setValue(controlledName, value);
30
- }
31
- }, [value, watch(controlledName)]);
32
- const wrapperClassName = classnames(styles.wrapper, disabled && styles.disabled);
33
- const inputClassName = classnames(styles.input, {
34
- [styles.indeterminate]: indeterminate,
35
- });
36
- const iconName = indeterminate ? "minus2" : "checkmark";
37
- const labelText = label ? React.createElement(Text.Text, null, label) : children;
38
- return (React.createElement(reactHookForm.Controller, { control: control, name: controlledName, defaultValue: defaultChecked, render: (_a) => {
39
- var _b = _a.field, { onChange: onControllerChange, name: controllerName } = _b, rest = tslib_es6.__rest(_b, ["onChange", "name"]);
40
- const fieldProps = Object.assign(Object.assign({}, rest), { id: identifier, className: inputClassName, name: name && controllerName, onChange: handleChange, disabled: disabled });
41
- return (React.createElement("div", { className: styles.checkBoxParent },
42
- React.createElement("label", { className: wrapperClassName },
43
- React.createElement("span", { className: styles.checkHolder },
44
- React.createElement("input", Object.assign({}, fieldProps, { type: "checkbox", checked: checked, defaultChecked: defaultChecked, "aria-label": label, onChange: handleChange, onFocus: onFocus, onBlur: onBlur })),
45
- React.createElement("span", { className: styles.checkBox },
46
- React.createElement(Icon.Icon, { name: iconName, color: "surface" }))),
47
- labelText && React.createElement("span", { className: styles.label }, labelText)),
48
- description && (React.createElement("div", { className: styles.description },
49
- React.createElement(Text.Text, { variation: "subdued", size: "small" }, description)))));
50
- function handleChange(event) {
51
- const newChecked = event.currentTarget.checked;
52
- onChange && onChange(newChecked);
53
- onControllerChange(event);
54
- }
55
- } }));
56
- }
57
13
 
58
- const CheckboxRebuilt = React.forwardRef(function CheckboxRebuiltInternal(props, ref) {
59
- const { checked, defaultChecked, disabled, label, name, value, indeterminate = false, description, id, onBlur, onChange, onFocus, onClick, onMouseDown, onMouseUp, onPointerDown, onPointerUp, invalid, } = props;
60
- const descriptionIdentifier = React.useId();
61
- const descriptionVisible = Boolean(description);
62
- const wrapperClassName = classnames(styles.wrapper, disabled && styles.disabled, invalid && styles.invalid);
63
- const isInvalid = Boolean(invalid);
64
- const inputClassName = classnames(styles.input, {
65
- [styles.indeterminate]: indeterminate,
66
- });
67
- const dataAttrs = filterDataAttributes.filterDataAttributes(props);
68
- const iconName = indeterminate ? "minus2" : "checkmark";
69
- const labelContent = typeof label === "string" ? React.createElement(Text.Text, null, label) : label;
70
- const descriptionContent = typeof description === "string" ? (React.createElement(Text.Text, { size: "small", variation: "subdued" }, description)) : (description);
71
- function handleChange(event) {
72
- const newChecked = event.currentTarget.checked;
73
- onChange === null || onChange === void 0 ? void 0 : onChange(newChecked, event);
74
- }
75
- return (React.createElement("div", { className: styles.checkBoxParent },
76
- React.createElement("label", { className: wrapperClassName },
77
- React.createElement("span", { className: styles.checkHolder },
78
- React.createElement("input", Object.assign({ ref: ref, type: "checkbox", id: id, className: inputClassName, name: name, "aria-label": props["aria-label"], "aria-describedby": descriptionVisible
79
- ? descriptionIdentifier
80
- : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-required": props["aria-required"], checked: checked, value: value, defaultChecked: defaultChecked, disabled: disabled, onChange: handleChange, onFocus: onFocus, onBlur: onBlur, onClick: onClick, onMouseDown: onMouseDown, onMouseUp: onMouseUp, onPointerDown: onPointerDown, onPointerUp: onPointerUp }, dataAttrs)),
81
- React.createElement("span", { className: styles.checkBox },
82
- React.createElement(Icon.Icon, { name: iconName, color: "surface" }))),
83
- labelContent && React.createElement("span", { className: styles.label }, labelContent)),
84
- description && (React.createElement("div", { id: descriptionIdentifier, className: styles.description }, descriptionContent))));
85
- });
86
- CheckboxRebuilt.displayName = "CheckboxRebuilt";
87
-
88
- function isNewCheckboxProps(props) {
89
- return props.version === 2;
90
- }
91
- const Checkbox = React.forwardRef(function CheckboxShim(props, ref) {
92
- if (isNewCheckboxProps(props)) {
93
- return React.createElement(CheckboxRebuilt, Object.assign({}, props, { ref: ref }));
94
- }
95
- return React.createElement(CheckboxLegacy, Object.assign({}, props));
96
- });
97
- Checkbox.displayName = "Checkbox";
98
-
99
- exports.Checkbox = Checkbox;
14
+ exports.Checkbox = Checkbox.Checkbox;
@@ -1,5 +1,2 @@
1
- import React from "react";
2
- import type { CheckboxLegacyProps, CheckboxRebuiltProps } from "./Checkbox.types";
3
- type CheckboxShimProps = CheckboxLegacyProps | CheckboxRebuiltProps;
4
- export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxShimProps & React.RefAttributes<HTMLInputElement>>;
5
- export type { CheckboxLegacyProps, CheckboxRebuiltProps };
1
+ export { Checkbox } from "./Checkbox";
2
+ export type { CheckboxProps } from "./Checkbox.types";
@@ -1,97 +1,8 @@
1
- import React__default, { useState, useId, useEffect, forwardRef } from 'react';
2
- import { _ as __rest } from '../tslib.es6-es.js';
3
- import classnames from 'classnames';
4
- import { useFormContext, useForm, Controller } from 'react-hook-form';
5
- import { I as Icon } from '../Icon-es.js';
6
- import { T as Text } from '../Text-es.js';
7
- import { f as filterDataAttributes } from '../filterDataAttributes-es.js';
1
+ export { C as Checkbox } from '../Checkbox-es.js';
2
+ import 'react';
3
+ import 'classnames';
4
+ import '../Icon-es.js';
8
5
  import '@jobber/design';
6
+ import '../Text-es.js';
9
7
  import '../Typography-es.js';
10
-
11
- var styles = {"checkBoxParent":"YxKKPXAU10s-","wrapper":"KxWx-msbH9c-","disabled":"TKr3J-6ARFo-","checkHolder":"NO34ZbhNqhI-","input":"XnCmS-EzK2M-","checkBox":"_-8JCQE6SA9s-","indeterminate":"rqHq3ff9In0-","invalid":"Gqnclw4WaeQ-","label":"l8z5TxzVvqA-","description":"DcBfVgpiWa4-","spinning":"rFBN9M5-4Ok-"};
12
-
13
- function CheckboxLegacy({ checked, defaultChecked, disabled, label, name, value, indeterminate = false, description, children, onBlur, onChange, onFocus, }) {
14
- const { control, setValue, watch } = useFormContext() != undefined
15
- ? useFormContext()
16
- : // If there isn't a Form Context being provided, get a form for this field.
17
- useForm({ mode: "onTouched" });
18
- const [identifier] = useState(useId());
19
- /**
20
- * Generate a name if one is not supplied, this is the name
21
- * that will be used for react-hook-form and not neccessarily
22
- * attached to the DOM
23
- */
24
- const [controlledName] = useState(name ? name : `generatedName--${identifier}`);
25
- useEffect(() => {
26
- if (value != undefined) {
27
- setValue(controlledName, value);
28
- }
29
- }, [value, watch(controlledName)]);
30
- const wrapperClassName = classnames(styles.wrapper, disabled && styles.disabled);
31
- const inputClassName = classnames(styles.input, {
32
- [styles.indeterminate]: indeterminate,
33
- });
34
- const iconName = indeterminate ? "minus2" : "checkmark";
35
- const labelText = label ? React__default.createElement(Text, null, label) : children;
36
- return (React__default.createElement(Controller, { control: control, name: controlledName, defaultValue: defaultChecked, render: (_a) => {
37
- var _b = _a.field, { onChange: onControllerChange, name: controllerName } = _b, rest = __rest(_b, ["onChange", "name"]);
38
- const fieldProps = Object.assign(Object.assign({}, rest), { id: identifier, className: inputClassName, name: name && controllerName, onChange: handleChange, disabled: disabled });
39
- return (React__default.createElement("div", { className: styles.checkBoxParent },
40
- React__default.createElement("label", { className: wrapperClassName },
41
- React__default.createElement("span", { className: styles.checkHolder },
42
- React__default.createElement("input", Object.assign({}, fieldProps, { type: "checkbox", checked: checked, defaultChecked: defaultChecked, "aria-label": label, onChange: handleChange, onFocus: onFocus, onBlur: onBlur })),
43
- React__default.createElement("span", { className: styles.checkBox },
44
- React__default.createElement(Icon, { name: iconName, color: "surface" }))),
45
- labelText && React__default.createElement("span", { className: styles.label }, labelText)),
46
- description && (React__default.createElement("div", { className: styles.description },
47
- React__default.createElement(Text, { variation: "subdued", size: "small" }, description)))));
48
- function handleChange(event) {
49
- const newChecked = event.currentTarget.checked;
50
- onChange && onChange(newChecked);
51
- onControllerChange(event);
52
- }
53
- } }));
54
- }
55
-
56
- const CheckboxRebuilt = forwardRef(function CheckboxRebuiltInternal(props, ref) {
57
- const { checked, defaultChecked, disabled, label, name, value, indeterminate = false, description, id, onBlur, onChange, onFocus, onClick, onMouseDown, onMouseUp, onPointerDown, onPointerUp, invalid, } = props;
58
- const descriptionIdentifier = useId();
59
- const descriptionVisible = Boolean(description);
60
- const wrapperClassName = classnames(styles.wrapper, disabled && styles.disabled, invalid && styles.invalid);
61
- const isInvalid = Boolean(invalid);
62
- const inputClassName = classnames(styles.input, {
63
- [styles.indeterminate]: indeterminate,
64
- });
65
- const dataAttrs = filterDataAttributes(props);
66
- const iconName = indeterminate ? "minus2" : "checkmark";
67
- const labelContent = typeof label === "string" ? React__default.createElement(Text, null, label) : label;
68
- const descriptionContent = typeof description === "string" ? (React__default.createElement(Text, { size: "small", variation: "subdued" }, description)) : (description);
69
- function handleChange(event) {
70
- const newChecked = event.currentTarget.checked;
71
- onChange === null || onChange === void 0 ? void 0 : onChange(newChecked, event);
72
- }
73
- return (React__default.createElement("div", { className: styles.checkBoxParent },
74
- React__default.createElement("label", { className: wrapperClassName },
75
- React__default.createElement("span", { className: styles.checkHolder },
76
- React__default.createElement("input", Object.assign({ ref: ref, type: "checkbox", id: id, className: inputClassName, name: name, "aria-label": props["aria-label"], "aria-describedby": descriptionVisible
77
- ? descriptionIdentifier
78
- : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-required": props["aria-required"], checked: checked, value: value, defaultChecked: defaultChecked, disabled: disabled, onChange: handleChange, onFocus: onFocus, onBlur: onBlur, onClick: onClick, onMouseDown: onMouseDown, onMouseUp: onMouseUp, onPointerDown: onPointerDown, onPointerUp: onPointerUp }, dataAttrs)),
79
- React__default.createElement("span", { className: styles.checkBox },
80
- React__default.createElement(Icon, { name: iconName, color: "surface" }))),
81
- labelContent && React__default.createElement("span", { className: styles.label }, labelContent)),
82
- description && (React__default.createElement("div", { id: descriptionIdentifier, className: styles.description }, descriptionContent))));
83
- });
84
- CheckboxRebuilt.displayName = "CheckboxRebuilt";
85
-
86
- function isNewCheckboxProps(props) {
87
- return props.version === 2;
88
- }
89
- const Checkbox = forwardRef(function CheckboxShim(props, ref) {
90
- if (isNewCheckboxProps(props)) {
91
- return React__default.createElement(CheckboxRebuilt, Object.assign({}, props, { ref: ref }));
92
- }
93
- return React__default.createElement(CheckboxLegacy, Object.assign({}, props));
94
- });
95
- Checkbox.displayName = "Checkbox";
96
-
97
- export { Checkbox };
8
+ import '../filterDataAttributes-es.js';
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var classnames = require('classnames');
5
+ var Icon = require('./Icon-cjs.js');
6
+ var Text = require('./Text-cjs.js');
7
+ var filterDataAttributes = require('./filterDataAttributes-cjs.js');
8
+
9
+ var styles = {"checkBoxParent":"YxKKPXAU10s-","wrapper":"KxWx-msbH9c-","disabled":"TKr3J-6ARFo-","checkHolder":"NO34ZbhNqhI-","input":"XnCmS-EzK2M-","checkBox":"_-8JCQE6SA9s-","indeterminate":"rqHq3ff9In0-","invalid":"Gqnclw4WaeQ-","label":"l8z5TxzVvqA-","description":"DcBfVgpiWa4-","spinning":"rFBN9M5-4Ok-"};
10
+
11
+ const Checkbox = React.forwardRef(function CheckboxInternal(props, ref) {
12
+ const { checked, defaultChecked, disabled, label, name, value, indeterminate = false, description, id, onBlur, onChange, onFocus, onClick, onMouseDown, onMouseUp, onPointerDown, onPointerUp, invalid, } = props;
13
+ const descriptionIdentifier = React.useId();
14
+ const descriptionVisible = Boolean(description);
15
+ const wrapperClassName = classnames(styles.wrapper, disabled && styles.disabled, invalid && styles.invalid);
16
+ const isInvalid = Boolean(invalid);
17
+ const inputClassName = classnames(styles.input, {
18
+ [styles.indeterminate]: indeterminate,
19
+ });
20
+ const dataAttrs = filterDataAttributes.filterDataAttributes(props);
21
+ const iconName = indeterminate ? "minus2" : "checkmark";
22
+ const labelContent = typeof label === "string" ? React.createElement(Text.Text, null, label) : label;
23
+ const descriptionContent = typeof description === "string" ? (React.createElement(Text.Text, { size: "small", variation: "subdued" }, description)) : (description);
24
+ function handleChange(event) {
25
+ const newChecked = event.currentTarget.checked;
26
+ onChange === null || onChange === void 0 ? void 0 : onChange(newChecked, event);
27
+ }
28
+ return (React.createElement("div", { className: styles.checkBoxParent },
29
+ React.createElement("label", { className: wrapperClassName },
30
+ React.createElement("span", { className: styles.checkHolder },
31
+ React.createElement("input", Object.assign({ ref: ref, type: "checkbox", id: id, className: inputClassName, name: name, "aria-label": props["aria-label"], "aria-describedby": descriptionVisible
32
+ ? descriptionIdentifier
33
+ : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-required": props["aria-required"], checked: checked, value: value, defaultChecked: defaultChecked, disabled: disabled, onChange: handleChange, onFocus: onFocus, onBlur: onBlur, onClick: onClick, onMouseDown: onMouseDown, onMouseUp: onMouseUp, onPointerDown: onPointerDown, onPointerUp: onPointerUp }, dataAttrs)),
34
+ React.createElement("span", { className: styles.checkBox },
35
+ React.createElement(Icon.Icon, { name: iconName, color: "surface" }))),
36
+ labelContent && React.createElement("span", { className: styles.label }, labelContent)),
37
+ description && (React.createElement("div", { id: descriptionIdentifier, className: styles.description }, descriptionContent))));
38
+ });
39
+ Checkbox.displayName = "Checkbox";
40
+
41
+ exports.Checkbox = Checkbox;
@@ -0,0 +1,39 @@
1
+ import React__default, { forwardRef, useId } from 'react';
2
+ import classnames from 'classnames';
3
+ import { I as Icon } from './Icon-es.js';
4
+ import { T as Text } from './Text-es.js';
5
+ import { f as filterDataAttributes } from './filterDataAttributes-es.js';
6
+
7
+ var styles = {"checkBoxParent":"YxKKPXAU10s-","wrapper":"KxWx-msbH9c-","disabled":"TKr3J-6ARFo-","checkHolder":"NO34ZbhNqhI-","input":"XnCmS-EzK2M-","checkBox":"_-8JCQE6SA9s-","indeterminate":"rqHq3ff9In0-","invalid":"Gqnclw4WaeQ-","label":"l8z5TxzVvqA-","description":"DcBfVgpiWa4-","spinning":"rFBN9M5-4Ok-"};
8
+
9
+ const Checkbox = forwardRef(function CheckboxInternal(props, ref) {
10
+ const { checked, defaultChecked, disabled, label, name, value, indeterminate = false, description, id, onBlur, onChange, onFocus, onClick, onMouseDown, onMouseUp, onPointerDown, onPointerUp, invalid, } = props;
11
+ const descriptionIdentifier = useId();
12
+ const descriptionVisible = Boolean(description);
13
+ const wrapperClassName = classnames(styles.wrapper, disabled && styles.disabled, invalid && styles.invalid);
14
+ const isInvalid = Boolean(invalid);
15
+ const inputClassName = classnames(styles.input, {
16
+ [styles.indeterminate]: indeterminate,
17
+ });
18
+ const dataAttrs = filterDataAttributes(props);
19
+ const iconName = indeterminate ? "minus2" : "checkmark";
20
+ const labelContent = typeof label === "string" ? React__default.createElement(Text, null, label) : label;
21
+ const descriptionContent = typeof description === "string" ? (React__default.createElement(Text, { size: "small", variation: "subdued" }, description)) : (description);
22
+ function handleChange(event) {
23
+ const newChecked = event.currentTarget.checked;
24
+ onChange === null || onChange === void 0 ? void 0 : onChange(newChecked, event);
25
+ }
26
+ return (React__default.createElement("div", { className: styles.checkBoxParent },
27
+ React__default.createElement("label", { className: wrapperClassName },
28
+ React__default.createElement("span", { className: styles.checkHolder },
29
+ React__default.createElement("input", Object.assign({ ref: ref, type: "checkbox", id: id, className: inputClassName, name: name, "aria-label": props["aria-label"], "aria-describedby": descriptionVisible
30
+ ? descriptionIdentifier
31
+ : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-required": props["aria-required"], checked: checked, value: value, defaultChecked: defaultChecked, disabled: disabled, onChange: handleChange, onFocus: onFocus, onBlur: onBlur, onClick: onClick, onMouseDown: onMouseDown, onMouseUp: onMouseUp, onPointerDown: onPointerDown, onPointerUp: onPointerUp }, dataAttrs)),
32
+ React__default.createElement("span", { className: styles.checkBox },
33
+ React__default.createElement(Icon, { name: iconName, color: "surface" }))),
34
+ labelContent && React__default.createElement("span", { className: styles.label }, labelContent)),
35
+ description && (React__default.createElement("div", { id: descriptionIdentifier, className: styles.description }, descriptionContent))));
36
+ });
37
+ Checkbox.displayName = "Checkbox";
38
+
39
+ export { Checkbox as C };
@@ -29,8 +29,8 @@ require('classnames');
29
29
  require('../../Text-cjs.js');
30
30
  require('../../Typography-cjs.js');
31
31
  require('../../Button-cjs.js');
32
- require('react-router-dom');
33
32
  require('../../tslib.es6-cjs.js');
33
+ require('react-router-dom');
34
34
  require('../../Spinner-cjs.js');
35
35
  require('../../Chip-cjs.js');
36
36
  require('../../Avatar-cjs.js');