@jobber/components 6.62.0 → 6.62.2
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.
package/dist/Checkbox/index.cjs
CHANGED
|
@@ -55,6 +55,7 @@ function CheckboxLegacy({ checked, defaultChecked, disabled, label, name, value,
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
const CheckboxRebuilt = React.forwardRef(function CheckboxRebuiltInternal({ checked, defaultChecked, disabled, label, name, value, indeterminate = false, description, id, onBlur, onChange, onFocus, invalid, }, ref) {
|
|
58
|
+
const descriptionIdentifier = React.useId();
|
|
58
59
|
const wrapperClassName = classnames(styles.wrapper, disabled && styles.disabled, invalid && styles.invalid);
|
|
59
60
|
const inputClassName = classnames(styles.input, {
|
|
60
61
|
[styles.indeterminate]: indeterminate,
|
|
@@ -69,11 +70,11 @@ const CheckboxRebuilt = React.forwardRef(function CheckboxRebuiltInternal({ chec
|
|
|
69
70
|
return (React.createElement("div", { className: styles.checkBoxParent },
|
|
70
71
|
React.createElement("label", { className: wrapperClassName },
|
|
71
72
|
React.createElement("span", { className: styles.checkHolder },
|
|
72
|
-
React.createElement("input", { ref: ref, 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("input", { ref: ref, type: "checkbox", id: id, className: inputClassName, name: name, "aria-describedby": description ? descriptionIdentifier : undefined, checked: checked, value: value, defaultChecked: defaultChecked, disabled: disabled, onChange: handleChange, onFocus: onFocus, onBlur: onBlur }),
|
|
73
74
|
React.createElement("span", { className: styles.checkBox },
|
|
74
75
|
React.createElement(Icon.Icon, { name: iconName, color: "surface" }))),
|
|
75
76
|
labelContent && React.createElement("span", { className: styles.label }, labelContent)),
|
|
76
|
-
description && (React.createElement("div", { className: styles.description }, descriptionContent))));
|
|
77
|
+
description && (React.createElement("div", { id: descriptionIdentifier, className: styles.description }, descriptionContent))));
|
|
77
78
|
});
|
|
78
79
|
CheckboxRebuilt.displayName = "CheckboxRebuilt";
|
|
79
80
|
|
package/dist/Checkbox/index.mjs
CHANGED
|
@@ -53,6 +53,7 @@ function CheckboxLegacy({ checked, defaultChecked, disabled, label, name, value,
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
const CheckboxRebuilt = forwardRef(function CheckboxRebuiltInternal({ checked, defaultChecked, disabled, label, name, value, indeterminate = false, description, id, onBlur, onChange, onFocus, invalid, }, ref) {
|
|
56
|
+
const descriptionIdentifier = useId();
|
|
56
57
|
const wrapperClassName = classnames(styles.wrapper, disabled && styles.disabled, invalid && styles.invalid);
|
|
57
58
|
const inputClassName = classnames(styles.input, {
|
|
58
59
|
[styles.indeterminate]: indeterminate,
|
|
@@ -67,11 +68,11 @@ const CheckboxRebuilt = forwardRef(function CheckboxRebuiltInternal({ checked, d
|
|
|
67
68
|
return (React__default.createElement("div", { className: styles.checkBoxParent },
|
|
68
69
|
React__default.createElement("label", { className: wrapperClassName },
|
|
69
70
|
React__default.createElement("span", { className: styles.checkHolder },
|
|
70
|
-
React__default.createElement("input", { ref: ref, type: "checkbox", id: id, className: inputClassName, name: name, checked: checked, value: value, defaultChecked: defaultChecked, disabled: disabled, onChange: handleChange, onFocus: onFocus, onBlur: onBlur }),
|
|
71
|
+
React__default.createElement("input", { ref: ref, type: "checkbox", id: id, className: inputClassName, name: name, "aria-describedby": description ? descriptionIdentifier : undefined, checked: checked, value: value, defaultChecked: defaultChecked, disabled: disabled, onChange: handleChange, onFocus: onFocus, onBlur: onBlur }),
|
|
71
72
|
React__default.createElement("span", { className: styles.checkBox },
|
|
72
73
|
React__default.createElement(Icon, { name: iconName, color: "surface" }))),
|
|
73
74
|
labelContent && React__default.createElement("span", { className: styles.label }, labelContent)),
|
|
74
|
-
description && (React__default.createElement("div", { className: styles.description }, descriptionContent))));
|
|
75
|
+
description && (React__default.createElement("div", { id: descriptionIdentifier, className: styles.description }, descriptionContent))));
|
|
75
76
|
});
|
|
76
77
|
CheckboxRebuilt.displayName = "CheckboxRebuilt";
|
|
77
78
|
|
|
@@ -3,5 +3,7 @@ import { ReactElement } from "react-markdown/lib/react-markdown";
|
|
|
3
3
|
interface DataListHeaderCheckbox {
|
|
4
4
|
readonly children: ReactElement;
|
|
5
5
|
}
|
|
6
|
+
export declare const DATA_LIST_HEADER_CHECKBOX_TEST_ID = "ATL-DataList-header-checkbox";
|
|
7
|
+
export declare const DATA_LIST_HEADER_BATCH_SELECT_TEST_ID = "ATL-DataList-header-batch-select";
|
|
6
8
|
export declare function DataListHeaderCheckbox({ children }: DataListHeaderCheckbox): React.JSX.Element;
|
|
7
9
|
export {};
|
|
@@ -14,28 +14,25 @@ var DataListBulkActions = require('./DataListBulkActions-cjs.js');
|
|
|
14
14
|
var useBatchSelect = require('./useBatchSelect-cjs.js');
|
|
15
15
|
var useActiveLayout = require('./useActiveLayout-cjs.js');
|
|
16
16
|
|
|
17
|
+
const DATA_LIST_HEADER_CHECKBOX_TEST_ID = "ATL-DataList-header-checkbox";
|
|
18
|
+
const DATA_LIST_HEADER_BATCH_SELECT_TEST_ID = "ATL-DataList-header-batch-select";
|
|
17
19
|
function DataListHeaderCheckbox({ children }) {
|
|
18
20
|
const { sm } = useResponsiveSizing.useResponsiveSizing();
|
|
19
21
|
const { data, totalCount } = DataListContext.useDataListContext();
|
|
20
|
-
const { canSelectAll, hasAtLeastOneSelected, isSelectAll, selectedCount, selectedIDs, selected, onSelectAll, onSelect, } = useBatchSelect.useBatchSelect();
|
|
21
|
-
// If there's no
|
|
22
|
-
|
|
22
|
+
const { canSelect, canSelectAll, hasAtLeastOneSelected, isSelectAll, selectedCount, selectedIDs, selected, onSelectAll, onSelect, } = useBatchSelect.useBatchSelect();
|
|
23
|
+
// If there's no onSelect, we don't need to render the checkbox.
|
|
24
|
+
// We'll still render the (invisible) checkbox even if only onSelect is provided for alignment.
|
|
25
|
+
if (!canSelect)
|
|
23
26
|
return children;
|
|
24
27
|
const deselectText = sm ? "Deselect All" : "Deselect";
|
|
25
28
|
const selectedLabel = selectedCount ? `${selectedCount} selected` : "";
|
|
26
29
|
return (React.createElement("div", { className: DataList_module.styles.selectable },
|
|
27
|
-
React.createElement("div", { className: classnames(DataList_module.styles.selectAllCheckbox, {
|
|
30
|
+
React.createElement("div", { "data-testid": DATA_LIST_HEADER_CHECKBOX_TEST_ID, className: classnames(DataList_module.styles.selectAllCheckbox, {
|
|
28
31
|
[DataList_module.styles.visible]: canSelectAll,
|
|
29
32
|
}) },
|
|
30
33
|
React.createElement(Checkbox_index.Checkbox, { checked: isAllSelected(), indeterminate: isIndeterminate(), onChange: handleSelectAll },
|
|
31
34
|
React.createElement("div", { className: DataList_module.styles.srOnly }, selectedLabel))),
|
|
32
|
-
React.createElement(
|
|
33
|
-
React.createElement("div", { className: DataList_module.styles.headerBatchSelect },
|
|
34
|
-
Boolean(selectedCount) && React.createElement(Text.Text, null,
|
|
35
|
-
selectedCount,
|
|
36
|
-
" selected"),
|
|
37
|
-
React.createElement(Button.Button, { label: deselectText, onClick: () => onSelect === null || onSelect === void 0 ? void 0 : onSelect([]), type: "tertiary" })),
|
|
38
|
-
React.createElement(DataListBulkActions.InternalDataListBulkActions, null)) })));
|
|
35
|
+
React.createElement(ColumnHeaderContent, { canSelectAll: canSelectAll, hasAtLeastOneSelected: hasAtLeastOneSelected, selectedCount: selectedCount, deselectText: deselectText, onSelect: onSelect }, children)));
|
|
39
36
|
function isIndeterminate() {
|
|
40
37
|
if (isSelectAll)
|
|
41
38
|
return selectedIDs.length > 0;
|
|
@@ -69,18 +66,33 @@ function DataListHeaderCheckbox({ children }) {
|
|
|
69
66
|
return 0;
|
|
70
67
|
}
|
|
71
68
|
}
|
|
69
|
+
function ColumnHeaderContent({ canSelectAll, children, hasAtLeastOneSelected, selectedCount, deselectText, onSelect, }) {
|
|
70
|
+
if (canSelectAll) {
|
|
71
|
+
return (React.createElement(AnimatedSwitcher.AnimatedSwitcher, { switched: hasAtLeastOneSelected, initialChild: children, switchTo: React.createElement("div", { "data-testid": DATA_LIST_HEADER_BATCH_SELECT_TEST_ID, className: DataList_module.styles.batchSelectContainer },
|
|
72
|
+
React.createElement("div", { className: DataList_module.styles.headerBatchSelect },
|
|
73
|
+
Boolean(selectedCount) && React.createElement(Text.Text, null,
|
|
74
|
+
selectedCount,
|
|
75
|
+
" selected"),
|
|
76
|
+
React.createElement(Button.Button, { label: deselectText, onClick: () => onSelect === null || onSelect === void 0 ? void 0 : onSelect([]), type: "tertiary" })),
|
|
77
|
+
React.createElement(DataListBulkActions.InternalDataListBulkActions, null)) }));
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
return children;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
72
83
|
|
|
73
84
|
function DataListHeader() {
|
|
74
85
|
const breakpoints = useResponsiveSizing.useResponsiveSizing();
|
|
75
86
|
const { headerVisibility = { xs: true, sm: true, md: true, lg: true, xl: true }, headers, layoutBreakpoints, } = DataListContext.useDataListContext();
|
|
76
|
-
const { hasAtLeastOneSelected } = useBatchSelect.useBatchSelect();
|
|
87
|
+
const { hasAtLeastOneSelected, canSelect, canSelectAll } = useBatchSelect.useBatchSelect();
|
|
77
88
|
const size = getVisibleSize();
|
|
78
89
|
const { layout } = useActiveLayout.useActiveLayout();
|
|
79
90
|
const visible = headerVisibility[size];
|
|
80
|
-
if ((
|
|
91
|
+
if (isHeaderHidden(visible, hasAtLeastOneSelected, layout, canSelect, canSelectAll)) {
|
|
81
92
|
return null;
|
|
93
|
+
}
|
|
82
94
|
const headerData = DataList_utils.generateHeaderElements(headers);
|
|
83
|
-
if (!headerData)
|
|
95
|
+
if (!headerData || !layout)
|
|
84
96
|
return null;
|
|
85
97
|
return (React.createElement("div", { className: DataList_module.styles.headerTitles },
|
|
86
98
|
React.createElement(DataListHeaderCheckbox, null, layout(headerData))));
|
|
@@ -91,5 +103,14 @@ function DataListHeader() {
|
|
|
91
103
|
return visibleHeaderSize || layoutBreakpoints[0];
|
|
92
104
|
}
|
|
93
105
|
}
|
|
106
|
+
function isHeaderHidden(visible, hasAtLeastOneSelected, layout, canSelect, canSelectAll) {
|
|
107
|
+
// When the horizontal area is too small and the data starts to wrap
|
|
108
|
+
// we want to hide the headers that will no longer align with the content
|
|
109
|
+
// The exception is when we have onSelectAll AND one or more are selected
|
|
110
|
+
// because then we show the "header" in its select-all UI variation state
|
|
111
|
+
const isHiddenForSelect = !visible && canSelect && !canSelectAll;
|
|
112
|
+
const isHiddenForSelectAll = !visible && !hasAtLeastOneSelected;
|
|
113
|
+
return !layout || isHiddenForSelect || isHiddenForSelectAll;
|
|
114
|
+
}
|
|
94
115
|
|
|
95
116
|
exports.DataListHeader = DataListHeader;
|
|
@@ -12,28 +12,25 @@ import { I as InternalDataListBulkActions } from './DataListBulkActions-es.js';
|
|
|
12
12
|
import { u as useBatchSelect } from './useBatchSelect-es.js';
|
|
13
13
|
import { u as useActiveLayout } from './useActiveLayout-es.js';
|
|
14
14
|
|
|
15
|
+
const DATA_LIST_HEADER_CHECKBOX_TEST_ID = "ATL-DataList-header-checkbox";
|
|
16
|
+
const DATA_LIST_HEADER_BATCH_SELECT_TEST_ID = "ATL-DataList-header-batch-select";
|
|
15
17
|
function DataListHeaderCheckbox({ children }) {
|
|
16
18
|
const { sm } = useResponsiveSizing();
|
|
17
19
|
const { data, totalCount } = useDataListContext();
|
|
18
|
-
const { canSelectAll, hasAtLeastOneSelected, isSelectAll, selectedCount, selectedIDs, selected, onSelectAll, onSelect, } = useBatchSelect();
|
|
19
|
-
// If there's no
|
|
20
|
-
|
|
20
|
+
const { canSelect, canSelectAll, hasAtLeastOneSelected, isSelectAll, selectedCount, selectedIDs, selected, onSelectAll, onSelect, } = useBatchSelect();
|
|
21
|
+
// If there's no onSelect, we don't need to render the checkbox.
|
|
22
|
+
// We'll still render the (invisible) checkbox even if only onSelect is provided for alignment.
|
|
23
|
+
if (!canSelect)
|
|
21
24
|
return children;
|
|
22
25
|
const deselectText = sm ? "Deselect All" : "Deselect";
|
|
23
26
|
const selectedLabel = selectedCount ? `${selectedCount} selected` : "";
|
|
24
27
|
return (React__default.createElement("div", { className: styles.selectable },
|
|
25
|
-
React__default.createElement("div", { className: classnames(styles.selectAllCheckbox, {
|
|
28
|
+
React__default.createElement("div", { "data-testid": DATA_LIST_HEADER_CHECKBOX_TEST_ID, className: classnames(styles.selectAllCheckbox, {
|
|
26
29
|
[styles.visible]: canSelectAll,
|
|
27
30
|
}) },
|
|
28
31
|
React__default.createElement(Checkbox, { checked: isAllSelected(), indeterminate: isIndeterminate(), onChange: handleSelectAll },
|
|
29
32
|
React__default.createElement("div", { className: styles.srOnly }, selectedLabel))),
|
|
30
|
-
React__default.createElement(
|
|
31
|
-
React__default.createElement("div", { className: styles.headerBatchSelect },
|
|
32
|
-
Boolean(selectedCount) && React__default.createElement(Text, null,
|
|
33
|
-
selectedCount,
|
|
34
|
-
" selected"),
|
|
35
|
-
React__default.createElement(Button, { label: deselectText, onClick: () => onSelect === null || onSelect === void 0 ? void 0 : onSelect([]), type: "tertiary" })),
|
|
36
|
-
React__default.createElement(InternalDataListBulkActions, null)) })));
|
|
33
|
+
React__default.createElement(ColumnHeaderContent, { canSelectAll: canSelectAll, hasAtLeastOneSelected: hasAtLeastOneSelected, selectedCount: selectedCount, deselectText: deselectText, onSelect: onSelect }, children)));
|
|
37
34
|
function isIndeterminate() {
|
|
38
35
|
if (isSelectAll)
|
|
39
36
|
return selectedIDs.length > 0;
|
|
@@ -67,18 +64,33 @@ function DataListHeaderCheckbox({ children }) {
|
|
|
67
64
|
return 0;
|
|
68
65
|
}
|
|
69
66
|
}
|
|
67
|
+
function ColumnHeaderContent({ canSelectAll, children, hasAtLeastOneSelected, selectedCount, deselectText, onSelect, }) {
|
|
68
|
+
if (canSelectAll) {
|
|
69
|
+
return (React__default.createElement(AnimatedSwitcher, { switched: hasAtLeastOneSelected, initialChild: children, switchTo: React__default.createElement("div", { "data-testid": DATA_LIST_HEADER_BATCH_SELECT_TEST_ID, className: styles.batchSelectContainer },
|
|
70
|
+
React__default.createElement("div", { className: styles.headerBatchSelect },
|
|
71
|
+
Boolean(selectedCount) && React__default.createElement(Text, null,
|
|
72
|
+
selectedCount,
|
|
73
|
+
" selected"),
|
|
74
|
+
React__default.createElement(Button, { label: deselectText, onClick: () => onSelect === null || onSelect === void 0 ? void 0 : onSelect([]), type: "tertiary" })),
|
|
75
|
+
React__default.createElement(InternalDataListBulkActions, null)) }));
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return children;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
70
81
|
|
|
71
82
|
function DataListHeader() {
|
|
72
83
|
const breakpoints = useResponsiveSizing();
|
|
73
84
|
const { headerVisibility = { xs: true, sm: true, md: true, lg: true, xl: true }, headers, layoutBreakpoints, } = useDataListContext();
|
|
74
|
-
const { hasAtLeastOneSelected } = useBatchSelect();
|
|
85
|
+
const { hasAtLeastOneSelected, canSelect, canSelectAll } = useBatchSelect();
|
|
75
86
|
const size = getVisibleSize();
|
|
76
87
|
const { layout } = useActiveLayout();
|
|
77
88
|
const visible = headerVisibility[size];
|
|
78
|
-
if ((
|
|
89
|
+
if (isHeaderHidden(visible, hasAtLeastOneSelected, layout, canSelect, canSelectAll)) {
|
|
79
90
|
return null;
|
|
91
|
+
}
|
|
80
92
|
const headerData = generateHeaderElements(headers);
|
|
81
|
-
if (!headerData)
|
|
93
|
+
if (!headerData || !layout)
|
|
82
94
|
return null;
|
|
83
95
|
return (React__default.createElement("div", { className: styles.headerTitles },
|
|
84
96
|
React__default.createElement(DataListHeaderCheckbox, null, layout(headerData))));
|
|
@@ -89,5 +101,14 @@ function DataListHeader() {
|
|
|
89
101
|
return visibleHeaderSize || layoutBreakpoints[0];
|
|
90
102
|
}
|
|
91
103
|
}
|
|
104
|
+
function isHeaderHidden(visible, hasAtLeastOneSelected, layout, canSelect, canSelectAll) {
|
|
105
|
+
// When the horizontal area is too small and the data starts to wrap
|
|
106
|
+
// we want to hide the headers that will no longer align with the content
|
|
107
|
+
// The exception is when we have onSelectAll AND one or more are selected
|
|
108
|
+
// because then we show the "header" in its select-all UI variation state
|
|
109
|
+
const isHiddenForSelect = !visible && canSelect && !canSelectAll;
|
|
110
|
+
const isHiddenForSelectAll = !visible && !hasAtLeastOneSelected;
|
|
111
|
+
return !layout || isHiddenForSelect || isHiddenForSelectAll;
|
|
112
|
+
}
|
|
92
113
|
|
|
93
114
|
export { DataListHeader as D };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "6.62.
|
|
3
|
+
"version": "6.62.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -542,5 +542,5 @@
|
|
|
542
542
|
"> 1%",
|
|
543
543
|
"IE 10"
|
|
544
544
|
],
|
|
545
|
-
"gitHead": "
|
|
545
|
+
"gitHead": "a4cb5a5d369226f54f7c8ec5684ddef1131dffbd"
|
|
546
546
|
}
|