@jobber/components 6.19.1 → 6.20.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.
|
@@ -285,6 +285,10 @@ export interface DataListActionProps<T extends DataListObject> {
|
|
|
285
285
|
* The URL to navigate to when the action is clicked.
|
|
286
286
|
*/
|
|
287
287
|
readonly actionUrl?: string;
|
|
288
|
+
/**
|
|
289
|
+
* Determine if the action is always visible. It is not recommended to set this to true on more then one action.
|
|
290
|
+
*/
|
|
291
|
+
readonly alwaysVisible?: boolean;
|
|
288
292
|
}
|
|
289
293
|
export interface DataListActionsProps<T extends DataListObject> {
|
|
290
294
|
/**
|
|
@@ -150,8 +150,11 @@ function getExposedActions(childrenArray, childCount = 2) {
|
|
|
150
150
|
const firstNChildren = childrenArray.slice(0, childCount);
|
|
151
151
|
return firstNChildren.reduce((result, child, i) => {
|
|
152
152
|
const hasIcon = Boolean(child.props.icon);
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
const isAlwaysVisible = child.props.alwaysVisible; // If true, the child action will always be visible and not nested in the dropdown.
|
|
154
|
+
if (isAlwaysVisible === false ||
|
|
155
|
+
(isAlwaysVisible === undefined && !hasIcon)) {
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
155
158
|
const isLastChildAdded = result.length === i;
|
|
156
159
|
// If it's the first child or if the previous child was added, then add this child.
|
|
157
160
|
if (i === 0 || (i < childCount && isLastChildAdded)) {
|
|
@@ -148,8 +148,11 @@ function getExposedActions(childrenArray, childCount = 2) {
|
|
|
148
148
|
const firstNChildren = childrenArray.slice(0, childCount);
|
|
149
149
|
return firstNChildren.reduce((result, child, i) => {
|
|
150
150
|
const hasIcon = Boolean(child.props.icon);
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
const isAlwaysVisible = child.props.alwaysVisible; // If true, the child action will always be visible and not nested in the dropdown.
|
|
152
|
+
if (isAlwaysVisible === false ||
|
|
153
|
+
(isAlwaysVisible === undefined && !hasIcon)) {
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
153
156
|
const isLastChildAdded = result.length === i;
|
|
154
157
|
// If it's the first child or if the previous child was added, then add this child.
|
|
155
158
|
if (i === 0 || (i < childCount && isLastChildAdded)) {
|
|
@@ -14,10 +14,11 @@ function DataListActions({ children, itemsToExpose = 2, }) {
|
|
|
14
14
|
childrenArray.splice(0, exposedActions.length);
|
|
15
15
|
return (React.createElement(React.Fragment, null,
|
|
16
16
|
exposedActions.map(({ props }) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (!
|
|
17
|
+
const isVisible = props.visible ? props.visible(activeItem) : true;
|
|
18
|
+
const hasIconOrAlwaysVisible = props.icon || props.alwaysVisible;
|
|
19
|
+
if (!isVisible || !hasIconOrAlwaysVisible) {
|
|
20
20
|
return null;
|
|
21
|
+
}
|
|
21
22
|
function getActionLabel() {
|
|
22
23
|
if (typeof props.label === "string") {
|
|
23
24
|
return props.label;
|
|
@@ -27,6 +28,13 @@ function DataListActions({ children, itemsToExpose = 2, }) {
|
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
const actionLabel = getActionLabel();
|
|
31
|
+
// If the action is always visible, we don't want a tooltip.
|
|
32
|
+
if (props.alwaysVisibled) {
|
|
33
|
+
return (React.createElement(Button.Button, { ariaLabel: actionLabel, key: props.label, icon: props.icon, label: actionLabel, onClick: () => {
|
|
34
|
+
var _a;
|
|
35
|
+
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, activeItem);
|
|
36
|
+
}, type: "secondary", variation: "subtle" }));
|
|
37
|
+
}
|
|
30
38
|
return (React.createElement(Tooltip.Tooltip, { key: actionLabel, message: actionLabel },
|
|
31
39
|
React.createElement(Button.Button, { icon: props.icon, ariaLabel: actionLabel, onClick: () => {
|
|
32
40
|
var _a, _b;
|
|
@@ -12,10 +12,11 @@ function DataListActions({ children, itemsToExpose = 2, }) {
|
|
|
12
12
|
childrenArray.splice(0, exposedActions.length);
|
|
13
13
|
return (React.createElement(React.Fragment, null,
|
|
14
14
|
exposedActions.map(({ props }) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (!
|
|
15
|
+
const isVisible = props.visible ? props.visible(activeItem) : true;
|
|
16
|
+
const hasIconOrAlwaysVisible = props.icon || props.alwaysVisible;
|
|
17
|
+
if (!isVisible || !hasIconOrAlwaysVisible) {
|
|
18
18
|
return null;
|
|
19
|
+
}
|
|
19
20
|
function getActionLabel() {
|
|
20
21
|
if (typeof props.label === "string") {
|
|
21
22
|
return props.label;
|
|
@@ -25,6 +26,13 @@ function DataListActions({ children, itemsToExpose = 2, }) {
|
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
const actionLabel = getActionLabel();
|
|
29
|
+
// If the action is always visible, we don't want a tooltip.
|
|
30
|
+
if (props.alwaysVisibled) {
|
|
31
|
+
return (React.createElement(Button, { ariaLabel: actionLabel, key: props.label, icon: props.icon, label: actionLabel, onClick: () => {
|
|
32
|
+
var _a;
|
|
33
|
+
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, activeItem);
|
|
34
|
+
}, type: "secondary", variation: "subtle" }));
|
|
35
|
+
}
|
|
28
36
|
return (React.createElement(Tooltip, { key: actionLabel, message: actionLabel },
|
|
29
37
|
React.createElement(Button, { icon: props.icon, ariaLabel: actionLabel, onClick: () => {
|
|
30
38
|
var _a, _b;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.20.0",
|
|
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": "
|
|
492
|
+
"gitHead": "2558b87c3c62b4adb43d4fd74f8d0a2e747061eb"
|
|
493
493
|
}
|