@jobber/components 4.66.3 → 4.66.5
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/DataList/DataList.types.d.ts +1 -1
- package/dist/DataList/index.js +20 -3
- package/dist/InputAvatar/InputAvatar.d.ts +1 -1
- package/dist/InputFile/InputFile.d.ts +1 -1
- package/dist/InputGroup/index.js +1 -1
- package/dist/{InputGroup-3fdde16b.js → InputGroup-8d4fd4eb.js} +1 -1
- package/dist/MultiSelect/DropDownMenu.d.ts +1 -1
- package/dist/MultiSelect/MultiSelect.d.ts +1 -1
- package/dist/MultiSelect/index.js +25 -37
- package/dist/RecurringSelect/index.js +1 -1
- package/package.json +2 -2
- package/dist/MultiSelect/utils.d.ts +0 -3
package/dist/DataList/index.js
CHANGED
|
@@ -477,8 +477,17 @@ function DataListActions({ children, itemsToExpose = 2, }) {
|
|
|
477
477
|
return null;
|
|
478
478
|
if (!props.icon)
|
|
479
479
|
return null;
|
|
480
|
-
|
|
481
|
-
|
|
480
|
+
function getActionLabel() {
|
|
481
|
+
if (typeof props.label === "string") {
|
|
482
|
+
return props.label;
|
|
483
|
+
}
|
|
484
|
+
if (activeItem) {
|
|
485
|
+
return props.label(activeItem);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
const actionLabel = getActionLabel();
|
|
489
|
+
return (React__default["default"].createElement(Tooltip.Tooltip, { key: actionLabel, message: actionLabel },
|
|
490
|
+
React__default["default"].createElement(Button.Button, { icon: props.icon, ariaLabel: actionLabel, onClick: () => {
|
|
482
491
|
var _a, _b;
|
|
483
492
|
if (activeItem) {
|
|
484
493
|
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, activeItem);
|
|
@@ -1047,9 +1056,17 @@ function DataListAction({ label, icon, destructive, visible = () => true, onClic
|
|
|
1047
1056
|
return null;
|
|
1048
1057
|
}
|
|
1049
1058
|
const color = destructive ? "critical" : "heading";
|
|
1059
|
+
function getActionLabel() {
|
|
1060
|
+
if (typeof label === "string") {
|
|
1061
|
+
return label;
|
|
1062
|
+
}
|
|
1063
|
+
if (activeItem) {
|
|
1064
|
+
return label(activeItem);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1050
1067
|
return (React__default["default"].createElement("button", { type: "button", className: styles$1.action, onClick: handleClick },
|
|
1051
1068
|
React__default["default"].createElement(Typography.Typography, { textColor: color },
|
|
1052
|
-
React__default["default"].createElement("span", { className: styles$1.label },
|
|
1069
|
+
React__default["default"].createElement("span", { className: styles$1.label }, getActionLabel())),
|
|
1053
1070
|
icon && React__default["default"].createElement(Icon.Icon, { name: icon, color: color })));
|
|
1054
1071
|
function handleClick() {
|
|
1055
1072
|
if (activeItem) {
|
|
@@ -7,7 +7,7 @@ interface InputAvatarProps extends Omit<AvatarProps, "size"> {
|
|
|
7
7
|
* to upload the file.
|
|
8
8
|
*
|
|
9
9
|
* More info is available at:
|
|
10
|
-
* https://atlantis.getjobber.com/components
|
|
10
|
+
* https://atlantis.getjobber.com/?path=/docs/components-forms-and-inputs-inputfile-docs--page#getuploadparams
|
|
11
11
|
*/
|
|
12
12
|
getUploadParams(file: File): UploadParams | Promise<UploadParams>;
|
|
13
13
|
/**
|
|
@@ -97,7 +97,7 @@ interface InputFileProps {
|
|
|
97
97
|
* to upload the file.
|
|
98
98
|
*
|
|
99
99
|
* More info is available at:
|
|
100
|
-
* https://atlantis.getjobber.com/components
|
|
100
|
+
* https://atlantis.getjobber.com/?path=/docs/components-forms-and-inputs-inputfile-docs--page#getuploadparams
|
|
101
101
|
*/
|
|
102
102
|
getUploadParams(file: File): UploadParams | Promise<UploadParams>;
|
|
103
103
|
/**
|
package/dist/InputGroup/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var InputGroup = require('../InputGroup-
|
|
5
|
+
var InputGroup = require('../InputGroup-8d4fd4eb.js');
|
|
6
6
|
require('react');
|
|
7
7
|
require('classnames');
|
|
8
8
|
require('../style-inject.es-9d2f5f4e.js');
|
|
@@ -23,7 +23,7 @@ function isInvalidGroupNesting(childs) {
|
|
|
23
23
|
return React__default["default"].Children.toArray(childs).some(child => {
|
|
24
24
|
if (child.type === InputGroup &&
|
|
25
25
|
child.props.flowDirection != "horizontal") {
|
|
26
|
-
console.error(`ERROR: InputGroup not rendered: nesting 'flowDirection="vertical"' columns not supported.`, `https://atlantis.getjobber.com/components
|
|
26
|
+
console.error(`ERROR: InputGroup not rendered: nesting 'flowDirection="vertical"' columns not supported.`, `https://atlantis.getjobber.com/?path=/story/components-forms-and-inputs-inputgroup-web--nested`);
|
|
27
27
|
return true;
|
|
28
28
|
}
|
|
29
29
|
return false;
|
|
@@ -9,7 +9,7 @@ interface DropDownMenuProps {
|
|
|
9
9
|
/**
|
|
10
10
|
* Change handler.
|
|
11
11
|
*/
|
|
12
|
-
setOptions: Dispatch<React.SetStateAction<Options>>;
|
|
12
|
+
readonly setOptions: Dispatch<React.SetStateAction<Options>>;
|
|
13
13
|
}
|
|
14
14
|
export declare function DropDownMenu({ options, setOptions }: DropDownMenuProps): JSX.Element;
|
|
15
15
|
export {};
|
|
@@ -16,7 +16,7 @@ interface MultiSelectProps {
|
|
|
16
16
|
/**
|
|
17
17
|
* Change handler
|
|
18
18
|
*/
|
|
19
|
-
onOptionsChange: Dispatch<React.SetStateAction<Options>>;
|
|
19
|
+
readonly onOptionsChange: Dispatch<React.SetStateAction<Options>>;
|
|
20
20
|
/**
|
|
21
21
|
* Adjusts the interface to either have small or large spacing.
|
|
22
22
|
*/
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var classnames = require('classnames');
|
|
7
|
-
var useOnKeyDown = require('@jobber/hooks/useOnKeyDown');
|
|
8
7
|
var styleInject_es = require('../style-inject.es-9d2f5f4e.js');
|
|
9
8
|
var Checkbox = require('../Checkbox-ad7ec2e7.js');
|
|
10
9
|
var Text = require('../Text-4a2bc89f.js');
|
|
@@ -28,19 +27,6 @@ var css_248z = "._0SStdD4KRHs- {\n display: -ms-flexbox;\n display: flex;\n p
|
|
|
28
27
|
var styles = {"dropDownMenuContainer":"_0SStdD4KRHs-","option":"mFSgwOQZJm0-","active":"SepF4gvOxq8-"};
|
|
29
28
|
styleInject_es.styleInject(css_248z);
|
|
30
29
|
|
|
31
|
-
function handleKeyboardShortcut(setupKeyListeners) {
|
|
32
|
-
function callback(event) {
|
|
33
|
-
const { metaKey, ctrlKey, key, target } = event;
|
|
34
|
-
const shouldTriggerShortcut = target instanceof HTMLButtonElement ? metaKey || ctrlKey : true;
|
|
35
|
-
if (!shouldTriggerShortcut)
|
|
36
|
-
return;
|
|
37
|
-
event.preventDefault();
|
|
38
|
-
event.stopPropagation();
|
|
39
|
-
setupKeyListeners(key);
|
|
40
|
-
}
|
|
41
|
-
return { callback };
|
|
42
|
-
}
|
|
43
|
-
|
|
44
30
|
function DropDownMenu({ options, setOptions }) {
|
|
45
31
|
const [highlightedIndex, setHighlightedIndex] = React.useState(0);
|
|
46
32
|
const menuDiv = React.useRef();
|
|
@@ -78,40 +64,32 @@ function DropDownMenu({ options, setOptions }) {
|
|
|
78
64
|
menuDivElement.scrollTop += itemHeight;
|
|
79
65
|
}
|
|
80
66
|
}
|
|
81
|
-
function
|
|
67
|
+
function handleKeyDown(event) {
|
|
68
|
+
const { key, metaKey, ctrlKey } = event;
|
|
69
|
+
if (metaKey || ctrlKey)
|
|
70
|
+
return;
|
|
82
71
|
switch (key) {
|
|
83
|
-
case "Enter":
|
|
84
|
-
case " ": {
|
|
72
|
+
case "Enter": {
|
|
85
73
|
if (highlightedIndex >= 0) {
|
|
86
74
|
handleOptionClick(options[highlightedIndex]);
|
|
87
75
|
}
|
|
88
76
|
break;
|
|
89
77
|
}
|
|
90
78
|
case "ArrowDown": {
|
|
91
|
-
|
|
92
|
-
handleOptionFocus(newIndex);
|
|
93
|
-
scrollMenuIfItemNotInView(menuDiv.current, "down");
|
|
79
|
+
handlePressDown(event);
|
|
94
80
|
break;
|
|
95
81
|
}
|
|
96
82
|
case "ArrowUp": {
|
|
97
|
-
|
|
98
|
-
handleOptionFocus(newIndex);
|
|
99
|
-
scrollMenuIfItemNotInView(menuDiv.current, "up");
|
|
83
|
+
handlePressUp(event);
|
|
100
84
|
break;
|
|
101
85
|
}
|
|
102
86
|
}
|
|
103
87
|
}
|
|
104
|
-
useOnKeyDown.useOnKeyDown(handleKeyboardShortcut(setupKeyListeners).callback, [
|
|
105
|
-
"Enter",
|
|
106
|
-
" ",
|
|
107
|
-
"ArrowDown",
|
|
108
|
-
"ArrowUp",
|
|
109
|
-
]);
|
|
110
88
|
React.useEffect(() => {
|
|
111
89
|
// focus first option
|
|
112
90
|
handleOptionFocus(0);
|
|
113
91
|
}, [menuDiv]);
|
|
114
|
-
return (React__default["default"].createElement("ul", { "data-testid": "dropdown-menu", className: styles.dropDownMenuContainer, ref: menuDiv }, options.map((option, index) => {
|
|
92
|
+
return (React__default["default"].createElement("ul", { "data-testid": "dropdown-menu", className: styles.dropDownMenuContainer, ref: menuDiv, onKeyDown: handleKeyDown }, options.map((option, index) => {
|
|
115
93
|
const optionClass = classnames__default["default"](styles.option, {
|
|
116
94
|
[styles.active]: index === highlightedIndex,
|
|
117
95
|
});
|
|
@@ -122,6 +100,18 @@ function DropDownMenu({ options, setOptions }) {
|
|
|
122
100
|
}, onMouseOver: e => handleOptionHover(e, index) },
|
|
123
101
|
React__default["default"].createElement(Checkbox.Checkbox, { label: option.label, checked: option.checked, onFocus: () => setHighlightedIndex(index) })));
|
|
124
102
|
})));
|
|
103
|
+
function handlePressUp(event) {
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
const newIndex = Math.max(0, highlightedIndex - 1);
|
|
106
|
+
handleOptionFocus(newIndex);
|
|
107
|
+
scrollMenuIfItemNotInView(menuDiv.current, "up");
|
|
108
|
+
}
|
|
109
|
+
function handlePressDown(event) {
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
const newIndex = Math.min(options.length - 1, highlightedIndex + 1);
|
|
112
|
+
handleOptionFocus(newIndex);
|
|
113
|
+
scrollMenuIfItemNotInView(menuDiv.current, "down");
|
|
114
|
+
}
|
|
125
115
|
}
|
|
126
116
|
|
|
127
117
|
// eslint-disable-next-line max-statements
|
|
@@ -146,7 +136,10 @@ function MultiSelect({ defaultLabel, allSelectedLabel, options, onOptionsChange,
|
|
|
146
136
|
setMenuVisible(false);
|
|
147
137
|
}
|
|
148
138
|
};
|
|
149
|
-
function
|
|
139
|
+
function handleKeydown(event) {
|
|
140
|
+
const { key, metaKey, ctrlKey } = event;
|
|
141
|
+
if (metaKey || ctrlKey)
|
|
142
|
+
return;
|
|
150
143
|
switch (key) {
|
|
151
144
|
case "Enter":
|
|
152
145
|
case " ": {
|
|
@@ -162,11 +155,6 @@ function MultiSelect({ defaultLabel, allSelectedLabel, options, onOptionsChange,
|
|
|
162
155
|
}
|
|
163
156
|
}
|
|
164
157
|
}
|
|
165
|
-
useOnKeyDown.useOnKeyDown(handleKeyboardShortcut(setupKeyListeners).callback, [
|
|
166
|
-
"Enter",
|
|
167
|
-
" ",
|
|
168
|
-
"Escape",
|
|
169
|
-
]);
|
|
170
158
|
React.useEffect(() => {
|
|
171
159
|
document.addEventListener("mousedown", handleClickOutside);
|
|
172
160
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
@@ -185,7 +173,7 @@ function MultiSelect({ defaultLabel, allSelectedLabel, options, onOptionsChange,
|
|
|
185
173
|
setLabel(selectedLabels.join(", "));
|
|
186
174
|
}
|
|
187
175
|
}, [options]);
|
|
188
|
-
return (React__default["default"].createElement("div", { ref: multiSelectContainer, className: styles$1.multiSelectContainer },
|
|
176
|
+
return (React__default["default"].createElement("div", { ref: multiSelectContainer, className: styles$1.multiSelectContainer, onKeyDown: handleKeydown },
|
|
189
177
|
React__default["default"].createElement("div", { "data-testid": "multi-select", className: multiSelectClass, onClick: handleMenuVisibility, onFocus: () => setFocused(true), onBlur: () => setFocused(false), tabIndex: 0, ref: multiSelectRef, role: "button", "aria-label": `${defaultLabel}: ${label}`, "aria-multiselectable": true, "aria-haspopup": true },
|
|
190
178
|
React__default["default"].createElement(Text.Text, null, label),
|
|
191
179
|
React__default["default"].createElement(Icon.Icon, { name: "arrowDown" })),
|
|
@@ -11,7 +11,7 @@ require('classnames');
|
|
|
11
11
|
require('../Typography-973b122e.js');
|
|
12
12
|
var Option = require('../Option-469029b5.js');
|
|
13
13
|
var InputNumber = require('../InputNumber-d9ebabaa.js');
|
|
14
|
-
var InputGroup = require('../InputGroup-
|
|
14
|
+
var InputGroup = require('../InputGroup-8d4fd4eb.js');
|
|
15
15
|
var Content = require('../Content-2ca1ffe1.js');
|
|
16
16
|
require('../FormField-dfc061ca.js');
|
|
17
17
|
require('../tslib.es6-5b8768b7.js');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "4.66.
|
|
3
|
+
"version": "4.66.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"> 1%",
|
|
84
84
|
"IE 10"
|
|
85
85
|
],
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "57d527093ccd90b30d13e0cfeaac47df72e4c3eb"
|
|
87
87
|
}
|