@jobber/components 6.18.0 → 6.19.1

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,53 +1,2 @@
1
- import { ReactElement } from "react";
2
- import { XOR } from "ts-xor";
3
- interface BaseCheckboxProps {
4
- /**
5
- * Determines if the checkbox is checked or not.
6
- */
7
- readonly checked?: boolean;
8
- /**
9
- * Initial checked value of the checkbox. Only use this when you need to
10
- * pre-populate the checked attribute that is not controlled by the component's
11
- * state. If a state is controlling it, use the `checked` prop instead.
12
- */
13
- readonly defaultChecked?: boolean;
14
- /**
15
- * Disables the checkbox.
16
- */
17
- readonly disabled?: boolean;
18
- /**
19
- * When `true` the checkbox to appears in indeterminate.
20
- *
21
- * @default false
22
- */
23
- readonly indeterminate?: boolean;
24
- /**
25
- * Checkbox input name
26
- */
27
- readonly name?: string;
28
- /**
29
- * Value of the checkbox.
30
- */
31
- readonly value?: string;
32
- /**
33
- * Further description of the label
34
- */
35
- readonly description?: string;
36
- onChange?(newValue: boolean): void;
37
- onFocus?(): void;
38
- }
39
- interface CheckboxLabelProps extends BaseCheckboxProps {
40
- /**
41
- * Label that shows up beside the checkbox.
42
- */
43
- readonly label?: string;
44
- }
45
- interface CheckboxChildrenProps extends BaseCheckboxProps {
46
- /**
47
- * Component children, which shows up as a label
48
- */
49
- readonly children?: ReactElement;
50
- }
51
- type CheckboxProps = XOR<CheckboxLabelProps, CheckboxChildrenProps>;
52
- export declare function Checkbox({ checked, defaultChecked, disabled, label, name, value, indeterminate, description, children, onChange, onFocus, }: CheckboxProps): JSX.Element;
53
- export {};
1
+ import { CheckboxLegacyProps } from "./Checkbox.types";
2
+ export declare function CheckboxLegacy({ checked, defaultChecked, disabled, label, name, value, indeterminate, description, children, onBlur, onChange, onFocus, }: CheckboxLegacyProps): JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { CheckboxRebuiltProps } from "./Checkbox.types";
2
+ export declare function CheckboxRebuilt({ checked, defaultChecked, disabled, label, name, value, indeterminate, description, id, onBlur, onChange, onFocus, }: CheckboxRebuiltProps): JSX.Element;
@@ -0,0 +1,91 @@
1
+ import { ReactElement } from "react";
2
+ import { XOR } from "ts-xor";
3
+ export interface BaseCheckboxProps {
4
+ /**
5
+ * Determines if the checkbox is checked or not.
6
+ */
7
+ readonly checked?: boolean;
8
+ /**
9
+ * Initial checked value of the checkbox. Only use this when you need to
10
+ * pre-populate the checked attribute that is not controlled by the component's
11
+ * state. If a state is controlling it, use the `checked` prop instead.
12
+ */
13
+ readonly defaultChecked?: boolean;
14
+ /**
15
+ * Disables the checkbox.
16
+ */
17
+ readonly disabled?: boolean;
18
+ /**
19
+ * When `true` the checkbox to appears in indeterminate.
20
+ *
21
+ * @default false
22
+ */
23
+ readonly indeterminate?: boolean;
24
+ /**
25
+ * Checkbox input name
26
+ */
27
+ readonly name?: string;
28
+ /**
29
+ * Value of the checkbox.
30
+ */
31
+ readonly value?: string;
32
+ /**
33
+ * Further description of the label
34
+ */
35
+ readonly description?: string;
36
+ /**
37
+ * ID for the checkbox input
38
+ */
39
+ readonly id?: string;
40
+ /**
41
+ * Called when the checkbox value changes
42
+ */
43
+ onChange?(newValue: boolean): void;
44
+ /**
45
+ * Called when the checkbox is focused
46
+ */
47
+ onFocus?(event: React.FocusEvent<HTMLInputElement>): void;
48
+ /**
49
+ * Called when the checkbox loses focus
50
+ */
51
+ onBlur?(event: React.FocusEvent<HTMLInputElement>): void;
52
+ }
53
+ interface CheckboxLabelProps extends BaseCheckboxProps {
54
+ /**
55
+ * Label that shows up beside the checkbox.
56
+ */
57
+ readonly label?: string;
58
+ }
59
+ interface CheckboxChildrenProps extends BaseCheckboxProps {
60
+ /**
61
+ * Component children, which shows up as a label
62
+ */
63
+ readonly children?: ReactElement;
64
+ }
65
+ export type CheckboxRebuiltProps = Omit<BaseCheckboxProps, "label" | "description" | "children" | "onChange"> & {
66
+ /**
67
+ * Label that shows up beside the checkbox.
68
+ * String will be rendered with the default markup.
69
+ * ReactElement will be rendered with provided positionining.
70
+ */
71
+ label?: string | ReactElement;
72
+ /**
73
+ * Additional description of the checkbox.
74
+ * String will be rendered with the default markup.
75
+ * ReactElement will be rendered with provided positioning.
76
+ */
77
+ description?: string | ReactElement;
78
+ /**
79
+ * Called when the checkbox value changes.
80
+ * Includes the change event as a second argument.
81
+ */
82
+ onChange?(newValue: boolean, event: React.ChangeEvent<HTMLInputElement>): void;
83
+ /**
84
+ * Version 2 is highly experimental, avoid using it unless you have talked with Atlantis first.
85
+ */
86
+ version: 2;
87
+ };
88
+ export type CheckboxLegacyProps = XOR<CheckboxLabelProps, CheckboxChildrenProps> & {
89
+ version?: 1;
90
+ };
91
+ export {};
@@ -1,15 +1,89 @@
1
1
  'use strict';
2
2
 
3
- var Checkbox = require('../Checkbox-cjs.js');
4
- require('../tslib.es6-cjs.js');
5
- require('react');
6
- require('classnames');
7
- require('react-hook-form');
8
- require('../Icon-cjs.js');
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
9
  require('@jobber/design');
10
- require('../Text-cjs.js');
11
10
  require('../Typography-cjs.js');
12
11
 
12
+ var styles = {"checkBoxParent":"YxKKPXAU10s-","wrapper":"KxWx-msbH9c-","disabled":"TKr3J-6ARFo-","checkHolder":"NO34ZbhNqhI-","input":"XnCmS-EzK2M-","checkBox":"_-8JCQE6SA9s-","indeterminate":"rqHq3ff9In0-","label":"l8z5TxzVvqA-","description":"DcBfVgpiWa4-","spinning":"rFBN9M5-4Ok-"};
13
13
 
14
+ function CheckboxLegacy({ checked, defaultChecked, disabled, label, name, value, indeterminate = false, description, children, onBlur, onChange, onFocus, }) {
15
+ const { control, setValue, watch } = reactHookForm.useFormContext() != undefined
16
+ ? reactHookForm.useFormContext()
17
+ : // If there isn't a Form Context being provided, get a form for this field.
18
+ reactHookForm.useForm({ mode: "onTouched" });
19
+ const [identifier] = React.useState(React.useId());
20
+ /**
21
+ * Generate a name if one is not supplied, this is the name
22
+ * that will be used for react-hook-form and not neccessarily
23
+ * attached to the DOM
24
+ */
25
+ const [controlledName] = React.useState(name ? name : `generatedName--${identifier}`);
26
+ React.useEffect(() => {
27
+ if (value != undefined) {
28
+ setValue(controlledName, value);
29
+ }
30
+ }, [value, watch(controlledName)]);
31
+ const wrapperClassName = classnames(styles.wrapper, disabled && styles.disabled);
32
+ const inputClassName = classnames(styles.input, {
33
+ [styles.indeterminate]: indeterminate,
34
+ });
35
+ const iconName = indeterminate ? "minus2" : "checkmark";
36
+ const labelText = label ? React.createElement(Text.Text, null, label) : children;
37
+ return (React.createElement(reactHookForm.Controller, { control: control, name: controlledName, defaultValue: defaultChecked, render: (_a) => {
38
+ var _b = _a.field, { onChange: onControllerChange, name: controllerName } = _b, rest = tslib_es6.__rest(_b, ["onChange", "name"]);
39
+ const fieldProps = Object.assign(Object.assign({}, rest), { id: identifier, className: inputClassName, name: name && controllerName, onChange: handleChange, disabled: disabled });
40
+ return (React.createElement("div", { className: styles.checkBoxParent },
41
+ React.createElement("label", { className: wrapperClassName },
42
+ React.createElement("span", { className: styles.checkHolder },
43
+ React.createElement("input", Object.assign({}, fieldProps, { type: "checkbox", checked: checked, defaultChecked: defaultChecked, "aria-label": label, onChange: handleChange, onFocus: onFocus, onBlur: onBlur })),
44
+ React.createElement("span", { className: styles.checkBox },
45
+ React.createElement(Icon.Icon, { name: iconName, color: "surface" }))),
46
+ labelText && React.createElement("span", { className: styles.label }, labelText)),
47
+ description && (React.createElement("div", { className: styles.description },
48
+ React.createElement(Text.Text, { variation: "subdued", size: "small" }, description)))));
49
+ function handleChange(event) {
50
+ const newChecked = event.currentTarget.checked;
51
+ onChange && onChange(newChecked);
52
+ onControllerChange(event);
53
+ }
54
+ } }));
55
+ }
14
56
 
15
- exports.Checkbox = Checkbox.Checkbox;
57
+ function CheckboxRebuilt({ checked, defaultChecked, disabled, label, name, value, indeterminate = false, description, id, onBlur, onChange, onFocus, }) {
58
+ const wrapperClassName = classnames(styles.wrapper, disabled && styles.disabled);
59
+ const inputClassName = classnames(styles.input, {
60
+ [styles.indeterminate]: indeterminate,
61
+ });
62
+ const iconName = indeterminate ? "minus2" : "checkmark";
63
+ const labelContent = typeof label === "string" ? React.createElement(Text.Text, null, label) : label;
64
+ const descriptionContent = typeof description === "string" ? (React.createElement(Text.Text, { size: "small", variation: "subdued" }, description)) : (description);
65
+ function handleChange(event) {
66
+ const newChecked = event.currentTarget.checked;
67
+ onChange === null || onChange === void 0 ? void 0 : onChange(newChecked, event);
68
+ }
69
+ return (React.createElement("div", { className: styles.checkBoxParent },
70
+ React.createElement("label", { className: wrapperClassName },
71
+ React.createElement("span", { className: styles.checkHolder },
72
+ React.createElement("input", { type: "checkbox", id: id, className: inputClassName, name: name, checked: checked, value: value, defaultChecked: defaultChecked, disabled: disabled, onChange: handleChange, onFocus: onFocus, onBlur: onBlur }),
73
+ React.createElement("span", { className: styles.checkBox },
74
+ React.createElement(Icon.Icon, { name: iconName, color: "surface" }))),
75
+ labelContent && React.createElement("span", { className: styles.label }, labelContent)),
76
+ description && (React.createElement("div", { className: styles.description }, descriptionContent))));
77
+ }
78
+
79
+ function isNewCheckboxProps(props) {
80
+ return props.version === 2;
81
+ }
82
+ function Checkbox(props) {
83
+ if (isNewCheckboxProps(props)) {
84
+ return React.createElement(CheckboxRebuilt, Object.assign({}, props));
85
+ }
86
+ return React.createElement(CheckboxLegacy, Object.assign({}, props));
87
+ }
88
+
89
+ exports.Checkbox = Checkbox;
@@ -1 +1,4 @@
1
- export { Checkbox } from "./Checkbox";
1
+ import { CheckboxLegacyProps, CheckboxRebuiltProps } from "./Checkbox.types";
2
+ type CheckboxShimProps = CheckboxLegacyProps | CheckboxRebuiltProps;
3
+ export declare function Checkbox(props: CheckboxShimProps): JSX.Element;
4
+ export type { CheckboxLegacyProps, CheckboxRebuiltProps };
@@ -1,9 +1,87 @@
1
- export { C as Checkbox } from '../Checkbox-es.js';
2
- import '../tslib.es6-es.js';
3
- import 'react';
4
- import 'classnames';
5
- import 'react-hook-form';
6
- import '../Icon-es.js';
1
+ import React, { useState, useId, useEffect } 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
7
  import '@jobber/design';
8
- import '../Text-es.js';
9
8
  import '../Typography-es.js';
9
+
10
+ var styles = {"checkBoxParent":"YxKKPXAU10s-","wrapper":"KxWx-msbH9c-","disabled":"TKr3J-6ARFo-","checkHolder":"NO34ZbhNqhI-","input":"XnCmS-EzK2M-","checkBox":"_-8JCQE6SA9s-","indeterminate":"rqHq3ff9In0-","label":"l8z5TxzVvqA-","description":"DcBfVgpiWa4-","spinning":"rFBN9M5-4Ok-"};
11
+
12
+ function CheckboxLegacy({ checked, defaultChecked, disabled, label, name, value, indeterminate = false, description, children, onBlur, onChange, onFocus, }) {
13
+ const { control, setValue, watch } = useFormContext() != undefined
14
+ ? useFormContext()
15
+ : // If there isn't a Form Context being provided, get a form for this field.
16
+ useForm({ mode: "onTouched" });
17
+ const [identifier] = useState(useId());
18
+ /**
19
+ * Generate a name if one is not supplied, this is the name
20
+ * that will be used for react-hook-form and not neccessarily
21
+ * attached to the DOM
22
+ */
23
+ const [controlledName] = useState(name ? name : `generatedName--${identifier}`);
24
+ useEffect(() => {
25
+ if (value != undefined) {
26
+ setValue(controlledName, value);
27
+ }
28
+ }, [value, watch(controlledName)]);
29
+ const wrapperClassName = classnames(styles.wrapper, disabled && styles.disabled);
30
+ const inputClassName = classnames(styles.input, {
31
+ [styles.indeterminate]: indeterminate,
32
+ });
33
+ const iconName = indeterminate ? "minus2" : "checkmark";
34
+ const labelText = label ? React.createElement(Text, null, label) : children;
35
+ return (React.createElement(Controller, { control: control, name: controlledName, defaultValue: defaultChecked, render: (_a) => {
36
+ var _b = _a.field, { onChange: onControllerChange, name: controllerName } = _b, rest = __rest(_b, ["onChange", "name"]);
37
+ const fieldProps = Object.assign(Object.assign({}, rest), { id: identifier, className: inputClassName, name: name && controllerName, onChange: handleChange, disabled: disabled });
38
+ return (React.createElement("div", { className: styles.checkBoxParent },
39
+ React.createElement("label", { className: wrapperClassName },
40
+ React.createElement("span", { className: styles.checkHolder },
41
+ React.createElement("input", Object.assign({}, fieldProps, { type: "checkbox", checked: checked, defaultChecked: defaultChecked, "aria-label": label, onChange: handleChange, onFocus: onFocus, onBlur: onBlur })),
42
+ React.createElement("span", { className: styles.checkBox },
43
+ React.createElement(Icon, { name: iconName, color: "surface" }))),
44
+ labelText && React.createElement("span", { className: styles.label }, labelText)),
45
+ description && (React.createElement("div", { className: styles.description },
46
+ React.createElement(Text, { variation: "subdued", size: "small" }, description)))));
47
+ function handleChange(event) {
48
+ const newChecked = event.currentTarget.checked;
49
+ onChange && onChange(newChecked);
50
+ onControllerChange(event);
51
+ }
52
+ } }));
53
+ }
54
+
55
+ function CheckboxRebuilt({ checked, defaultChecked, disabled, label, name, value, indeterminate = false, description, id, onBlur, onChange, onFocus, }) {
56
+ const wrapperClassName = classnames(styles.wrapper, disabled && styles.disabled);
57
+ const inputClassName = classnames(styles.input, {
58
+ [styles.indeterminate]: indeterminate,
59
+ });
60
+ const iconName = indeterminate ? "minus2" : "checkmark";
61
+ const labelContent = typeof label === "string" ? React.createElement(Text, null, label) : label;
62
+ const descriptionContent = typeof description === "string" ? (React.createElement(Text, { size: "small", variation: "subdued" }, description)) : (description);
63
+ function handleChange(event) {
64
+ const newChecked = event.currentTarget.checked;
65
+ onChange === null || onChange === void 0 ? void 0 : onChange(newChecked, event);
66
+ }
67
+ return (React.createElement("div", { className: styles.checkBoxParent },
68
+ React.createElement("label", { className: wrapperClassName },
69
+ React.createElement("span", { className: styles.checkHolder },
70
+ React.createElement("input", { type: "checkbox", id: id, className: inputClassName, name: name, checked: checked, value: value, defaultChecked: defaultChecked, disabled: disabled, onChange: handleChange, onFocus: onFocus, onBlur: onBlur }),
71
+ React.createElement("span", { className: styles.checkBox },
72
+ React.createElement(Icon, { name: iconName, color: "surface" }))),
73
+ labelContent && React.createElement("span", { className: styles.label }, labelContent)),
74
+ description && (React.createElement("div", { className: styles.description }, descriptionContent))));
75
+ }
76
+
77
+ function isNewCheckboxProps(props) {
78
+ return props.version === 2;
79
+ }
80
+ function Checkbox(props) {
81
+ if (isNewCheckboxProps(props)) {
82
+ return React.createElement(CheckboxRebuilt, Object.assign({}, props));
83
+ }
84
+ return React.createElement(CheckboxLegacy, Object.assign({}, props));
85
+ }
86
+
87
+ export { Checkbox };
@@ -29,7 +29,7 @@ require('../../../AnimatedSwitcher-cjs.js');
29
29
  require('framer-motion');
30
30
  require('../../../Button-cjs.js');
31
31
  require('react-router-dom');
32
- require('../../../Checkbox-cjs.js');
32
+ require('../../../Checkbox/index.cjs');
33
33
  require('../../../tslib.es6-cjs.js');
34
34
  require('react-hook-form');
35
35
  require('../../../DataList.module-cjs.js');
@@ -27,7 +27,7 @@ import '../../../AnimatedSwitcher-es.js';
27
27
  import 'framer-motion';
28
28
  import '../../../Button-es.js';
29
29
  import 'react-router-dom';
30
- import '../../../Checkbox-es.js';
30
+ import '../../../Checkbox/index.mjs';
31
31
  import '../../../tslib.es6-es.js';
32
32
  import 'react-hook-form';
33
33
  import '../../../DataList.module-es.js';
@@ -38,7 +38,7 @@ require('../../../Heading-cjs.js');
38
38
  require('../../../DataListLayoutContext-cjs2.js');
39
39
  require('../../../DataListItemActionsOverflow-cjs.js');
40
40
  require('../../../DataListActionsMenu-cjs.js');
41
- require('../../../Checkbox-cjs.js');
41
+ require('../../../Checkbox/index.cjs');
42
42
  require('../../../tslib.es6-cjs.js');
43
43
  require('react-hook-form');
44
44
  require('../../../useBatchSelect-cjs.js');
@@ -36,7 +36,7 @@ import '../../../Heading-es.js';
36
36
  import '../../../DataListLayoutContext-es2.js';
37
37
  import '../../../DataListItemActionsOverflow-es.js';
38
38
  import '../../../DataListActionsMenu-es.js';
39
- import '../../../Checkbox-es.js';
39
+ import '../../../Checkbox/index.mjs';
40
40
  import '../../../tslib.es6-es.js';
41
41
  import 'react-hook-form';
42
42
  import '../../../useBatchSelect-es.js';
@@ -39,7 +39,7 @@ require('../../../Heading-cjs.js');
39
39
  require('../../../DataListLayoutContext-cjs2.js');
40
40
  require('../../../DataListItemActionsOverflow-cjs.js');
41
41
  require('../../../DataListActionsMenu-cjs.js');
42
- require('../../../Checkbox-cjs.js');
42
+ require('../../../Checkbox/index.cjs');
43
43
  require('../../../tslib.es6-cjs.js');
44
44
  require('react-hook-form');
45
45
  require('../../../useBatchSelect-cjs.js');
@@ -37,7 +37,7 @@ import '../../../Heading-es.js';
37
37
  import '../../../DataListLayoutContext-es2.js';
38
38
  import '../../../DataListItemActionsOverflow-es.js';
39
39
  import '../../../DataListActionsMenu-es.js';
40
- import '../../../Checkbox-es.js';
40
+ import '../../../Checkbox/index.mjs';
41
41
  import '../../../tslib.es6-es.js';
42
42
  import 'react-hook-form';
43
43
  import '../../../useBatchSelect-es.js';
@@ -40,7 +40,7 @@ require('../../../Heading-cjs.js');
40
40
  require('../../../DataListLayoutContext-cjs2.js');
41
41
  require('../../../DataListItemActionsOverflow-cjs.js');
42
42
  require('../../../DataListActionsMenu-cjs.js');
43
- require('../../../Checkbox-cjs.js');
43
+ require('../../../Checkbox/index.cjs');
44
44
  require('../../../tslib.es6-cjs.js');
45
45
  require('react-hook-form');
46
46
  require('../../../useBatchSelect-cjs.js');
@@ -38,7 +38,7 @@ import '../../../Heading-es.js';
38
38
  import '../../../DataListLayoutContext-es2.js';
39
39
  import '../../../DataListItemActionsOverflow-es.js';
40
40
  import '../../../DataListActionsMenu-es.js';
41
- import '../../../Checkbox-es.js';
41
+ import '../../../Checkbox/index.mjs';
42
42
  import '../../../tslib.es6-es.js';
43
43
  import 'react-hook-form';
44
44
  import '../../../useBatchSelect-es.js';
@@ -49,7 +49,7 @@ require('../Heading-cjs.js');
49
49
  require('../DataListLayoutContext-cjs2.js');
50
50
  require('../DataListItemActionsOverflow-cjs.js');
51
51
  require('../DataListActionsMenu-cjs.js');
52
- require('../Checkbox-cjs.js');
52
+ require('../Checkbox/index.cjs');
53
53
  require('react-hook-form');
54
54
  require('../useBatchSelect-cjs.js');
55
55
  require('../DataListItemClickable-cjs.js');
@@ -47,7 +47,7 @@ import '../Heading-es.js';
47
47
  import '../DataListLayoutContext-es2.js';
48
48
  import '../DataListItemActionsOverflow-es.js';
49
49
  import '../DataListActionsMenu-es.js';
50
- import '../Checkbox-es.js';
50
+ import '../Checkbox/index.mjs';
51
51
  import 'react-hook-form';
52
52
  import '../useBatchSelect-es.js';
53
53
  import '../DataListItemClickable-es.js';
@@ -8,7 +8,7 @@ var classnames = require('classnames');
8
8
  var AnimatedSwitcher = require('./AnimatedSwitcher-cjs.js');
9
9
  var Text = require('./Text-cjs.js');
10
10
  var Button = require('./Button-cjs.js');
11
- var Checkbox = require('./Checkbox-cjs.js');
11
+ var Checkbox_index = require('./Checkbox/index.cjs');
12
12
  var DataList_module = require('./DataList.module-cjs.js');
13
13
  var DataListBulkActions = require('./DataListBulkActions-cjs.js');
14
14
  var useBatchSelect = require('./useBatchSelect-cjs.js');
@@ -27,7 +27,7 @@ function DataListHeaderCheckbox({ children }) {
27
27
  React.createElement("div", { className: classnames(DataList_module.styles.selectAllCheckbox, {
28
28
  [DataList_module.styles.visible]: canSelectAll,
29
29
  }) },
30
- React.createElement(Checkbox.Checkbox, { checked: isAllSelected(), indeterminate: isIndeterminate(), onChange: handleSelectAll },
30
+ React.createElement(Checkbox_index.Checkbox, { checked: isAllSelected(), indeterminate: isIndeterminate(), onChange: handleSelectAll },
31
31
  React.createElement("div", { className: DataList_module.styles.srOnly }, selectedLabel))),
32
32
  React.createElement(AnimatedSwitcher.AnimatedSwitcher, { switched: hasAtLeastOneSelected, initialChild: children, switchTo: React.createElement("div", { className: DataList_module.styles.batchSelectContainer },
33
33
  React.createElement("div", { className: DataList_module.styles.headerBatchSelect },
@@ -6,7 +6,7 @@ import classnames from 'classnames';
6
6
  import { A as AnimatedSwitcher } from './AnimatedSwitcher-es.js';
7
7
  import { T as Text } from './Text-es.js';
8
8
  import { B as Button } from './Button-es.js';
9
- import { C as Checkbox } from './Checkbox-es.js';
9
+ import { Checkbox } from './Checkbox/index.mjs';
10
10
  import { s as styles } from './DataList.module-es.js';
11
11
  import { I as InternalDataListBulkActions } from './DataListBulkActions-es.js';
12
12
  import { u as useBatchSelect } from './useBatchSelect-es.js';
@@ -8,7 +8,7 @@ var DataListItemActions = require('./DataListItemActions-cjs.js');
8
8
  var DataListActionsMenu = require('./DataListActionsMenu-cjs.js');
9
9
  var DataListLayoutContext$1 = require('./DataListLayoutContext-cjs2.js');
10
10
  var DataList_utils = require('./DataList.utils-cjs.js');
11
- var Checkbox = require('./Checkbox-cjs.js');
11
+ var Checkbox_index = require('./Checkbox/index.cjs');
12
12
  var useBatchSelect = require('./useBatchSelect-cjs.js');
13
13
  var DataList_module = require('./DataList.module-cjs.js');
14
14
  var DataListItemClickable = require('./DataListItemClickable-cjs.js');
@@ -22,7 +22,7 @@ function DataListItemInternal({ children, item, }) {
22
22
  [DataList_module.styles.selected]: hasAtLeastOneSelected,
23
23
  }) },
24
24
  children,
25
- React.createElement(Checkbox.Checkbox, { checked: getIsChecked(), onChange: handleChange })));
25
+ React.createElement(Checkbox_index.Checkbox, { checked: getIsChecked(), onChange: handleChange })));
26
26
  function getIsChecked() {
27
27
  const isItemInSelectedIDs = selectedIDs.includes(item.id);
28
28
  // If we're in a "select all" state, the selectedID's becomes a list of
@@ -6,7 +6,7 @@ import { I as InternalDataListItemActions } from './DataListItemActions-es.js';
6
6
  import { D as DataListActionsMenu } from './DataListActionsMenu-es.js';
7
7
  import { D as DataListLayoutActionsContext } from './DataListLayoutContext-es2.js';
8
8
  import { d as generateListItemElement } from './DataList.utils-es.js';
9
- import { C as Checkbox } from './Checkbox-es.js';
9
+ import { Checkbox } from './Checkbox/index.mjs';
10
10
  import { u as useBatchSelect } from './useBatchSelect-es.js';
11
11
  import { s as styles } from './DataList.module-es.js';
12
12
  import { D as DataListItemClickable } from './DataListItemClickable-es.js';
@@ -3,7 +3,7 @@
3
3
  var MultiSelect = require('../MultiSelect-cjs.js');
4
4
  require('react');
5
5
  require('classnames');
6
- require('../Checkbox-cjs.js');
6
+ require('../Checkbox/index.cjs');
7
7
  require('../tslib.es6-cjs.js');
8
8
  require('react-hook-form');
9
9
  require('../Icon-cjs.js');
@@ -1,7 +1,7 @@
1
1
  export { M as MultiSelect } from '../MultiSelect-es.js';
2
2
  import 'react';
3
3
  import 'classnames';
4
- import '../Checkbox-es.js';
4
+ import '../Checkbox/index.mjs';
5
5
  import '../tslib.es6-es.js';
6
6
  import 'react-hook-form';
7
7
  import '../Icon-es.js';
@@ -2,7 +2,7 @@
2
2
 
3
3
  var React = require('react');
4
4
  var classnames = require('classnames');
5
- var Checkbox = require('./Checkbox-cjs.js');
5
+ var Checkbox_index = require('./Checkbox/index.cjs');
6
6
  var Text = require('./Text-cjs.js');
7
7
  var Icon = require('./Icon-cjs.js');
8
8
 
@@ -81,7 +81,7 @@ function DropDownMenu({ options, setOptions }) {
81
81
  event.preventDefault();
82
82
  handleOptionClick(option);
83
83
  }, onMouseOver: e => handleOptionHover(e, index) },
84
- React.createElement(Checkbox.Checkbox, { label: option.label, checked: option.checked, onFocus: () => setHighlightedIndex(index) })));
84
+ React.createElement(Checkbox_index.Checkbox, { label: option.label, checked: option.checked, onFocus: () => setHighlightedIndex(index) })));
85
85
  })));
86
86
  function handlePressUp(event) {
87
87
  event.preventDefault();
@@ -1,6 +1,6 @@
1
1
  import React, { useState, useRef, useCallback, useEffect } from 'react';
2
2
  import classnames from 'classnames';
3
- import { C as Checkbox } from './Checkbox-es.js';
3
+ import { Checkbox } from './Checkbox/index.mjs';
4
4
  import { T as Text } from './Text-es.js';
5
5
  import { I as Icon } from './Icon-es.js';
6
6
 
package/dist/index.cjs CHANGED
@@ -21,7 +21,7 @@ var Box = require('./Box-cjs.js');
21
21
  var Button = require('./Button-cjs.js');
22
22
  var ButtonDismiss = require('./ButtonDismiss-cjs.js');
23
23
  var Card = require('./Card-cjs.js');
24
- var Checkbox = require('./Checkbox-cjs.js');
24
+ var Checkbox_index = require('./Checkbox/index.cjs');
25
25
  var Chip = require('./Chip-cjs.js');
26
26
  var ChipDismissible = require('./ChipDismissible-cjs.js');
27
27
  var Chips = require('./Chips-cjs.js');
@@ -199,7 +199,7 @@ exports.Box = Box.Box;
199
199
  exports.Button = Button.Button;
200
200
  exports.ButtonDismiss = ButtonDismiss.ButtonDismiss;
201
201
  exports.Card = Card.Card;
202
- exports.Checkbox = Checkbox.Checkbox;
202
+ exports.Checkbox = Checkbox_index.Checkbox;
203
203
  exports.Chip = Chip.Chip;
204
204
  exports.ChipDismissible = ChipDismissible.ChipDismissible;
205
205
  exports.ChipSelectable = ChipDismissible.ChipSelectable;
package/dist/index.mjs CHANGED
@@ -19,7 +19,7 @@ export { B as Box } from './Box-es.js';
19
19
  export { B as Button } from './Button-es.js';
20
20
  export { B as ButtonDismiss } from './ButtonDismiss-es.js';
21
21
  export { C as Card } from './Card-es.js';
22
- export { C as Checkbox } from './Checkbox-es.js';
22
+ export { Checkbox } from './Checkbox/index.mjs';
23
23
  export { C as Chip } from './Chip-es.js';
24
24
  export { a as ChipDismissible, C as ChipSelectable } from './ChipDismissible-es.js';
25
25
  export { C as Chips } from './Chips-es.js';
package/dist/styles.css CHANGED
@@ -7452,22 +7452,29 @@ html.atlantisLightBoxActive {
7452
7452
  gap: var(--space-small);
7453
7453
  -ms-flex-negative: 0;
7454
7454
  flex-shrink: 0;
7455
-
7456
- scrollbar-width: thin;
7457
- scrollbar-color: hsl(198, 35%, 21%) transparent;
7458
- scrollbar-color: var(--color-interactive--subtle) transparent;
7459
7455
  }
7460
- ._3TfQLQEE3GQ-::-webkit-scrollbar {
7461
- height: 8px;
7462
- }
7463
- ._3TfQLQEE3GQ-::-webkit-scrollbar-track {
7464
- background: transparent;
7456
+ @supports (scrollbar-color: #000 #000) {
7457
+ ._3TfQLQEE3GQ- {
7458
+ scrollbar-width: thin; /* Safari version 18.3: Bug causes this rule to undermine other scrollbar styling */
7459
+ scrollbar-color: hsl(198, 35%, 21%) transparent;
7460
+ scrollbar-color: var(--color-interactive--subtle) transparent;
7461
+ }
7465
7462
  }
7466
- ._3TfQLQEE3GQ-::-webkit-scrollbar-thumb {
7467
- border-radius: 4px;
7468
- border-radius: var(--radius-small);
7469
- background: hsl(198, 35%, 21%);
7470
- background: var(--color-interactive--subtle);
7463
+ @supports not (scrollbar-color: #000 #000) {
7464
+ ._3TfQLQEE3GQ-::-webkit-scrollbar {
7465
+ height: 8px;
7466
+ }
7467
+
7468
+ ._3TfQLQEE3GQ-::-webkit-scrollbar-track {
7469
+ background: transparent;
7470
+ }
7471
+
7472
+ ._3TfQLQEE3GQ-::-webkit-scrollbar-thumb {
7473
+ border-radius: 4px;
7474
+ border-radius: var(--radius-small);
7475
+ background: hsl(198, 35%, 21%);
7476
+ background: var(--color-interactive--subtle);
7477
+ }
7471
7478
  }
7472
7479
  .eBMzUOlcfQ4- {
7473
7480
  width: 100%;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "6.18.0",
3
+ "version": "6.19.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -489,5 +489,5 @@
489
489
  "> 1%",
490
490
  "IE 10"
491
491
  ],
492
- "gitHead": "c3b013c987b47e1576110136ac4ce45acbe5e7ba"
492
+ "gitHead": "8bdfcad7ad4f56fc40d669239db76f46243542d7"
493
493
  }
@@ -1,55 +0,0 @@
1
- 'use strict';
2
-
3
- var tslib_es6 = require('./tslib.es6-cjs.js');
4
- var React = require('react');
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
-
10
- var styles = {"checkBoxParent":"YxKKPXAU10s-","wrapper":"KxWx-msbH9c-","disabled":"TKr3J-6ARFo-","checkHolder":"NO34ZbhNqhI-","input":"XnCmS-EzK2M-","checkBox":"_-8JCQE6SA9s-","indeterminate":"rqHq3ff9In0-","label":"l8z5TxzVvqA-","description":"DcBfVgpiWa4-","spinning":"rFBN9M5-4Ok-"};
11
-
12
- function Checkbox({ checked, defaultChecked, disabled, label, name, value, indeterminate = false, description, children, onChange, onFocus, }) {
13
- const { control, setValue, watch } = reactHookForm.useFormContext() != undefined
14
- ? reactHookForm.useFormContext()
15
- : // If there isn't a Form Context being provided, get a form for this field.
16
- reactHookForm.useForm({ mode: "onTouched" });
17
- const [identifier] = React.useState(React.useId());
18
- /**
19
- * Generate a name if one is not supplied, this is the name
20
- * that will be used for react-hook-form and not neccessarily
21
- * attached to the DOM
22
- */
23
- const [controlledName] = React.useState(name ? name : `generatedName--${identifier}`);
24
- React.useEffect(() => {
25
- if (value != undefined) {
26
- setValue(controlledName, value);
27
- }
28
- }, [value, watch(controlledName)]);
29
- const wrapperClassName = classnames(styles.wrapper, disabled && styles.disabled);
30
- const inputClassName = classnames(styles.input, {
31
- [styles.indeterminate]: indeterminate,
32
- });
33
- const iconName = indeterminate ? "minus2" : "checkmark";
34
- const labelText = label ? React.createElement(Text.Text, null, label) : children;
35
- return (React.createElement(reactHookForm.Controller, { control: control, name: controlledName, defaultValue: defaultChecked, render: (_a) => {
36
- var _b = _a.field, { onChange: onControllerChange, name: controllerName } = _b, rest = tslib_es6.__rest(_b, ["onChange", "name"]);
37
- const fieldProps = Object.assign(Object.assign({}, rest), { id: identifier, className: inputClassName, name: name && controllerName, onChange: handleChange, disabled: disabled });
38
- return (React.createElement("div", { className: styles.checkBoxParent },
39
- React.createElement("label", { className: wrapperClassName },
40
- React.createElement("span", { className: styles.checkHolder },
41
- React.createElement("input", Object.assign({}, fieldProps, { type: "checkbox", checked: checked, defaultChecked: defaultChecked, "aria-label": label, onChange: handleChange, onFocus: onFocus })),
42
- React.createElement("span", { className: styles.checkBox },
43
- React.createElement(Icon.Icon, { name: iconName, color: "surface" }))),
44
- labelText && React.createElement("span", { className: styles.label }, labelText)),
45
- description && (React.createElement("div", { className: styles.description },
46
- React.createElement(Text.Text, { variation: "subdued", size: "small" }, description)))));
47
- function handleChange(event) {
48
- const newChecked = event.currentTarget.checked;
49
- onChange && onChange(newChecked);
50
- onControllerChange(event);
51
- }
52
- } }));
53
- }
54
-
55
- exports.Checkbox = Checkbox;
@@ -1,53 +0,0 @@
1
- import { _ as __rest } from './tslib.es6-es.js';
2
- import React, { useState, useId, useEffect } from 'react';
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
-
8
- var styles = {"checkBoxParent":"YxKKPXAU10s-","wrapper":"KxWx-msbH9c-","disabled":"TKr3J-6ARFo-","checkHolder":"NO34ZbhNqhI-","input":"XnCmS-EzK2M-","checkBox":"_-8JCQE6SA9s-","indeterminate":"rqHq3ff9In0-","label":"l8z5TxzVvqA-","description":"DcBfVgpiWa4-","spinning":"rFBN9M5-4Ok-"};
9
-
10
- function Checkbox({ checked, defaultChecked, disabled, label, name, value, indeterminate = false, description, children, onChange, onFocus, }) {
11
- const { control, setValue, watch } = useFormContext() != undefined
12
- ? useFormContext()
13
- : // If there isn't a Form Context being provided, get a form for this field.
14
- useForm({ mode: "onTouched" });
15
- const [identifier] = useState(useId());
16
- /**
17
- * Generate a name if one is not supplied, this is the name
18
- * that will be used for react-hook-form and not neccessarily
19
- * attached to the DOM
20
- */
21
- const [controlledName] = useState(name ? name : `generatedName--${identifier}`);
22
- useEffect(() => {
23
- if (value != undefined) {
24
- setValue(controlledName, value);
25
- }
26
- }, [value, watch(controlledName)]);
27
- const wrapperClassName = classnames(styles.wrapper, disabled && styles.disabled);
28
- const inputClassName = classnames(styles.input, {
29
- [styles.indeterminate]: indeterminate,
30
- });
31
- const iconName = indeterminate ? "minus2" : "checkmark";
32
- const labelText = label ? React.createElement(Text, null, label) : children;
33
- return (React.createElement(Controller, { control: control, name: controlledName, defaultValue: defaultChecked, render: (_a) => {
34
- var _b = _a.field, { onChange: onControllerChange, name: controllerName } = _b, rest = __rest(_b, ["onChange", "name"]);
35
- const fieldProps = Object.assign(Object.assign({}, rest), { id: identifier, className: inputClassName, name: name && controllerName, onChange: handleChange, disabled: disabled });
36
- return (React.createElement("div", { className: styles.checkBoxParent },
37
- React.createElement("label", { className: wrapperClassName },
38
- React.createElement("span", { className: styles.checkHolder },
39
- React.createElement("input", Object.assign({}, fieldProps, { type: "checkbox", checked: checked, defaultChecked: defaultChecked, "aria-label": label, onChange: handleChange, onFocus: onFocus })),
40
- React.createElement("span", { className: styles.checkBox },
41
- React.createElement(Icon, { name: iconName, color: "surface" }))),
42
- labelText && React.createElement("span", { className: styles.label }, labelText)),
43
- description && (React.createElement("div", { className: styles.description },
44
- React.createElement(Text, { variation: "subdued", size: "small" }, description)))));
45
- function handleChange(event) {
46
- const newChecked = event.currentTarget.checked;
47
- onChange && onChange(newChecked);
48
- onControllerChange(event);
49
- }
50
- } }));
51
- }
52
-
53
- export { Checkbox as C };