@jobber/components 4.7.4-timing.0 → 4.8.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.
- package/dist/Autocomplete/Menu.d.ts +6 -2
- package/dist/Autocomplete/index.js +31 -31
- package/dist/DataTable/index.js +2 -2
- package/dist/FormField/index.js +1 -1
- package/dist/{FormField-03e36a98.js → FormField-76853659.js} +1 -1
- package/dist/InputDate/index.js +1 -1
- package/dist/InputEmail/index.js +1 -1
- package/dist/InputNumber/index.js +1 -1
- package/dist/InputPassword/index.js +1 -1
- package/dist/InputText/InputText.d.ts +4 -4
- package/dist/InputText/index.js +2 -2
- package/dist/{InputText-0a76a9f9.js → InputText-73113193.js} +1 -1
- package/dist/InputTime/index.js +1 -1
- package/dist/{Option-1447547b.js → Option-26e09990.js} +1 -1
- package/dist/Select/index.js +2 -2
- package/package.json +5 -5
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import React, { RefObject } from "react";
|
|
2
2
|
import { Option } from "./Option";
|
|
3
3
|
interface MenuProps {
|
|
4
4
|
readonly visible: boolean;
|
|
5
5
|
readonly options: Option[];
|
|
6
6
|
readonly selectedOption?: Option;
|
|
7
|
+
/**
|
|
8
|
+
* Element that it's attached to when the menu opens.
|
|
9
|
+
*/
|
|
10
|
+
readonly attachTo: RefObject<Element | null>;
|
|
7
11
|
onOptionSelect(chosenOption: Option): void;
|
|
8
12
|
}
|
|
9
|
-
export declare function Menu({ visible, options, selectedOption, onOptionSelect, }: MenuProps):
|
|
13
|
+
export declare function Menu({ visible, options, selectedOption, onOptionSelect, attachTo, }: MenuProps): React.ReactPortal;
|
|
10
14
|
export {};
|
|
@@ -8,13 +8,15 @@ var debounce = require('lodash/debounce');
|
|
|
8
8
|
var styleInject_es = require('../style-inject.es-9d2f5f4e.js');
|
|
9
9
|
var classnames = require('classnames');
|
|
10
10
|
var useEventListener = require('@use-it/event-listener');
|
|
11
|
+
var ReactDOM = require('react-dom');
|
|
12
|
+
var reactPopper = require('react-popper');
|
|
11
13
|
var Text = require('../Text-e7ed0974.js');
|
|
12
14
|
var Icon = require('../Icon-405a216c.js');
|
|
13
15
|
var Heading = require('../Heading-a1191b15.js');
|
|
14
|
-
var InputText = require('../InputText-
|
|
16
|
+
var InputText = require('../InputText-73113193.js');
|
|
15
17
|
require('../Typography-fd6f932a.js');
|
|
16
18
|
require('@jobber/design');
|
|
17
|
-
require('../FormField-
|
|
19
|
+
require('../FormField-76853659.js');
|
|
18
20
|
require('uuid');
|
|
19
21
|
require('react-hook-form');
|
|
20
22
|
require('../Button-69409e46.js');
|
|
@@ -39,19 +41,16 @@ var IndexChange;
|
|
|
39
41
|
IndexChange[IndexChange["Previous"] = -1] = "Previous";
|
|
40
42
|
IndexChange[IndexChange["Next"] = 1] = "Next";
|
|
41
43
|
})(IndexChange || (IndexChange = {}));
|
|
42
|
-
function Menu({ visible, options, selectedOption, onOptionSelect, }) {
|
|
44
|
+
function Menu({ visible, options, selectedOption, onOptionSelect, attachTo, }) {
|
|
43
45
|
const [highlightedIndex, setHighlightedIndex] = React.useState(0);
|
|
44
|
-
const
|
|
45
|
-
[styles.visible]: visible,
|
|
46
|
-
});
|
|
47
|
-
const menuDiv = React.useRef();
|
|
46
|
+
const { menuRef, setMenuRef, styles: popperStyles, attributes, targetWidth, } = useRepositionMenu(attachTo);
|
|
48
47
|
const detectSeparatorCondition = (option) => option.description || option.details;
|
|
49
48
|
const detectGroups = (option) => option.options;
|
|
50
49
|
const addSeparators = options.some(detectSeparatorCondition);
|
|
51
50
|
const initialHighlight = options.some(detectGroups) ? 1 : 0;
|
|
52
51
|
setupKeyListeners();
|
|
53
52
|
React.useEffect(() => setHighlightedIndex(initialHighlight), [options]);
|
|
54
|
-
|
|
53
|
+
const menu = (React__default["default"].createElement("div", Object.assign({ className: classnames__default["default"](styles.options, { [styles.visible]: visible }), ref: setMenuRef, style: Object.assign(Object.assign({}, popperStyles.popper), { width: targetWidth }) }, attributes.popper), options.map((option, index) => {
|
|
55
54
|
const optionClass = classnames__default["default"](styles.option, {
|
|
56
55
|
[styles.active]: index === highlightedIndex,
|
|
57
56
|
[styles.separator]: addSeparators,
|
|
@@ -69,40 +68,28 @@ function Menu({ visible, options, selectedOption, onOptionSelect, }) {
|
|
|
69
68
|
option.details !== undefined && (React__default["default"].createElement("div", { className: styles.details },
|
|
70
69
|
React__default["default"].createElement(Text.Text, null, option.details))))));
|
|
71
70
|
})));
|
|
71
|
+
return ReactDOM.createPortal(menu, document.body);
|
|
72
72
|
function setupKeyListeners() {
|
|
73
|
+
React.useEffect(() => {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
(_b = menuRef === null || menuRef === void 0 ? void 0 : (_a = menuRef.children[highlightedIndex]).scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
76
|
+
behavior: "smooth",
|
|
77
|
+
block: "nearest",
|
|
78
|
+
inline: "start",
|
|
79
|
+
});
|
|
80
|
+
}, [highlightedIndex]);
|
|
73
81
|
useOnKeyDown("ArrowDown", (event) => {
|
|
74
82
|
const indexChange = arrowKeyPress(event, IndexChange.Next);
|
|
75
83
|
if (indexChange) {
|
|
76
84
|
setHighlightedIndex(Math.min(options.length - 1, highlightedIndex + indexChange));
|
|
77
85
|
}
|
|
78
|
-
if (menuDiv.current) {
|
|
79
|
-
scrollMenuIfItemNotInView(menuDiv.current, "down");
|
|
80
|
-
}
|
|
81
86
|
});
|
|
82
87
|
useOnKeyDown("ArrowUp", (event) => {
|
|
83
88
|
const indexChange = arrowKeyPress(event, IndexChange.Previous);
|
|
84
89
|
if (indexChange) {
|
|
85
90
|
setHighlightedIndex(Math.max(0, highlightedIndex + indexChange));
|
|
86
91
|
}
|
|
87
|
-
if (menuDiv.current) {
|
|
88
|
-
scrollMenuIfItemNotInView(menuDiv.current, "up");
|
|
89
|
-
}
|
|
90
92
|
});
|
|
91
|
-
function scrollMenuIfItemNotInView(menuDivElement, direction) {
|
|
92
|
-
const itemDiv = menuDivElement.querySelector(`button.${styles.option}:nth-child(${highlightedIndex + 1})`);
|
|
93
|
-
if (!itemDiv)
|
|
94
|
-
return;
|
|
95
|
-
const menuTop = menuDivElement.getBoundingClientRect().top;
|
|
96
|
-
const { top: itemTop, height: itemHeight, bottom: itemBottom, } = itemDiv.getBoundingClientRect();
|
|
97
|
-
const itemTrueBottom = itemBottom + itemHeight;
|
|
98
|
-
const menuBottom = menuDivElement.getBoundingClientRect().bottom;
|
|
99
|
-
if (direction == "up" && itemTop - itemHeight < menuTop) {
|
|
100
|
-
menuDivElement.scrollTop -= itemHeight;
|
|
101
|
-
}
|
|
102
|
-
else if (direction == "down" && itemTrueBottom > menuBottom) {
|
|
103
|
-
menuDivElement.scrollTop += itemHeight;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
93
|
useOnKeyDown("Enter", (event) => {
|
|
107
94
|
if (!visible)
|
|
108
95
|
return;
|
|
@@ -141,6 +128,18 @@ function isGroup(option) {
|
|
|
141
128
|
return true;
|
|
142
129
|
return false;
|
|
143
130
|
}
|
|
131
|
+
function useRepositionMenu(attachTo) {
|
|
132
|
+
var _a;
|
|
133
|
+
const [menuRef, setMenuRef] = React.useState();
|
|
134
|
+
const popper = reactPopper.usePopper(attachTo.current, menuRef, {
|
|
135
|
+
modifiers: [
|
|
136
|
+
{ name: "offset", options: { offset: [0, 8] } },
|
|
137
|
+
{ name: "flip", options: { fallbackPlacements: ["top"] } },
|
|
138
|
+
],
|
|
139
|
+
});
|
|
140
|
+
const targetWidth = (_a = attachTo.current) === null || _a === void 0 ? void 0 : _a.clientWidth;
|
|
141
|
+
return Object.assign(Object.assign({}, popper), { menuRef, setMenuRef, targetWidth });
|
|
142
|
+
}
|
|
144
143
|
|
|
145
144
|
/**
|
|
146
145
|
* Max statements disabled here to make room for the
|
|
@@ -152,6 +151,7 @@ function Autocomplete({ initialOptions = [], value, allowFreeForm = true, size =
|
|
|
152
151
|
const [options, setOptions] = React.useState(initialOptions);
|
|
153
152
|
const [menuVisible, setMenuVisible] = React.useState(false);
|
|
154
153
|
const [inputText, setInputText] = React.useState((_a = value === null || value === void 0 ? void 0 : value.label) !== null && _a !== void 0 ? _a : "");
|
|
154
|
+
const autocompleteRef = React.useRef(null);
|
|
155
155
|
const delayedSearch = debounce__default["default"](updateSearch, debounceRate);
|
|
156
156
|
React.useEffect(() => {
|
|
157
157
|
delayedSearch();
|
|
@@ -161,9 +161,9 @@ function Autocomplete({ initialOptions = [], value, allowFreeForm = true, size =
|
|
|
161
161
|
var _a;
|
|
162
162
|
updateInput((_a = value === null || value === void 0 ? void 0 : value.label) !== null && _a !== void 0 ? _a : "");
|
|
163
163
|
}, [value]);
|
|
164
|
-
return (React__default["default"].createElement("div", { className: styles.autocomplete },
|
|
164
|
+
return (React__default["default"].createElement("div", { className: styles.autocomplete, ref: autocompleteRef },
|
|
165
165
|
React__default["default"].createElement(InputText.InputText, { autocomplete: false, size: size, invalid: invalid, value: inputText, onChange: handleInputChange, placeholder: placeholder, onFocus: handleInputFocus, onBlur: handleInputBlur }),
|
|
166
|
-
menuVisible && (React__default["default"].createElement(Menu, { visible: true, options: options, selectedOption: value, onOptionSelect: handleMenuChange }))));
|
|
166
|
+
menuVisible && (React__default["default"].createElement(Menu, { attachTo: autocompleteRef, visible: true, options: options, selectedOption: value, onOptionSelect: handleMenuChange }))));
|
|
167
167
|
function updateInput(newText) {
|
|
168
168
|
setInputText(newText);
|
|
169
169
|
if (newText === "") {
|
package/dist/DataTable/index.js
CHANGED
|
@@ -8,10 +8,10 @@ var React = require('react');
|
|
|
8
8
|
var jobberHooks = require('@jobber/hooks');
|
|
9
9
|
var styleInject_es = require('../style-inject.es-9d2f5f4e.js');
|
|
10
10
|
var tslib_es6 = require('../tslib.es6-5b8768b7.js');
|
|
11
|
-
var Option = require('../Option-
|
|
11
|
+
var Option = require('../Option-26e09990.js');
|
|
12
12
|
var Button = require('../Button-69409e46.js');
|
|
13
13
|
var Text = require('../Text-e7ed0974.js');
|
|
14
|
-
require('../FormField-
|
|
14
|
+
require('../FormField-76853659.js');
|
|
15
15
|
require('uuid');
|
|
16
16
|
require('react-hook-form');
|
|
17
17
|
require('../Icon-405a216c.js');
|
package/dist/FormField/index.js
CHANGED
|
@@ -130,7 +130,7 @@ function FormField(props) {
|
|
|
130
130
|
const [controlledName] = React.useState(name ? name : `generatedName--${identifier}`);
|
|
131
131
|
React.useEffect(() => {
|
|
132
132
|
if (value != undefined) {
|
|
133
|
-
setValue(controlledName, value
|
|
133
|
+
setValue(controlledName, value);
|
|
134
134
|
}
|
|
135
135
|
}, [value, watch(controlledName)]);
|
|
136
136
|
React.useImperativeHandle(actionsRef, () => ({
|
package/dist/InputDate/index.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var lodash = require('lodash');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var FormField = require('../FormField-
|
|
7
|
+
var FormField = require('../FormField-76853659.js');
|
|
8
8
|
var DatePicker = require('../DatePicker-b704c15b.js');
|
|
9
9
|
require('../tslib.es6-5b8768b7.js');
|
|
10
10
|
require('uuid');
|
package/dist/InputEmail/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var FormField = require('../FormField-
|
|
6
|
+
var FormField = require('../FormField-76853659.js');
|
|
7
7
|
require('../tslib.es6-5b8768b7.js');
|
|
8
8
|
require('uuid');
|
|
9
9
|
require('react-hook-form');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var FormField = require('../FormField-
|
|
6
|
+
var FormField = require('../FormField-76853659.js');
|
|
7
7
|
require('../tslib.es6-5b8768b7.js');
|
|
8
8
|
require('uuid');
|
|
9
9
|
require('react-hook-form');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var FormField = require('../FormField-
|
|
6
|
+
var FormField = require('../FormField-76853659.js');
|
|
7
7
|
require('../tslib.es6-5b8768b7.js');
|
|
8
8
|
require('uuid');
|
|
9
9
|
require('react-hook-form');
|
|
@@ -18,7 +18,7 @@ export declare const InputText: React.ForwardRefExoticComponent<({
|
|
|
18
18
|
readonly inline?: boolean | undefined;
|
|
19
19
|
loading?: boolean | undefined;
|
|
20
20
|
readonly name?: string | undefined;
|
|
21
|
-
onChange?: ((newValue: string | number | boolean | Date, event?: React.ChangeEvent<HTMLInputElement |
|
|
21
|
+
onChange?: ((newValue: string | number | boolean | Date, event?: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement> | undefined) => void) | undefined;
|
|
22
22
|
onValidation?: ((message: string) => void) | undefined;
|
|
23
23
|
readonly placeholder?: string | undefined;
|
|
24
24
|
readonly size?: "large" | "small" | undefined;
|
|
@@ -28,7 +28,7 @@ export declare const InputText: React.ForwardRefExoticComponent<({
|
|
|
28
28
|
onFocus?: (() => void) | undefined;
|
|
29
29
|
onBlur?: (() => void) | undefined;
|
|
30
30
|
readonly autocomplete?: boolean | import("../FormField").AutocompleteTypes | undefined;
|
|
31
|
-
inputRef?: React.RefObject<HTMLInputElement |
|
|
31
|
+
inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement> | undefined;
|
|
32
32
|
readonly keyboard?: "numeric" | "decimal" | undefined;
|
|
33
33
|
readonly maxLength?: number | undefined;
|
|
34
34
|
readonly suffix?: {
|
|
@@ -66,7 +66,7 @@ export declare const InputText: React.ForwardRefExoticComponent<({
|
|
|
66
66
|
readonly inline?: boolean | undefined;
|
|
67
67
|
loading?: boolean | undefined;
|
|
68
68
|
readonly name?: string | undefined;
|
|
69
|
-
onChange?: ((newValue: string | number | boolean | Date, event?: React.ChangeEvent<HTMLInputElement |
|
|
69
|
+
onChange?: ((newValue: string | number | boolean | Date, event?: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement> | undefined) => void) | undefined;
|
|
70
70
|
onValidation?: ((message: string) => void) | undefined;
|
|
71
71
|
readonly placeholder?: string | undefined;
|
|
72
72
|
readonly size?: "large" | "small" | undefined;
|
|
@@ -76,7 +76,7 @@ export declare const InputText: React.ForwardRefExoticComponent<({
|
|
|
76
76
|
onFocus?: (() => void) | undefined;
|
|
77
77
|
onBlur?: (() => void) | undefined;
|
|
78
78
|
readonly autocomplete?: boolean | import("../FormField").AutocompleteTypes | undefined;
|
|
79
|
-
inputRef?: React.RefObject<HTMLInputElement |
|
|
79
|
+
inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement> | undefined;
|
|
80
80
|
readonly keyboard?: "numeric" | "decimal" | undefined;
|
|
81
81
|
readonly maxLength?: number | undefined;
|
|
82
82
|
readonly suffix?: {
|
package/dist/InputText/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var InputText = require('../InputText-
|
|
5
|
+
var InputText = require('../InputText-73113193.js');
|
|
6
6
|
require('react');
|
|
7
|
-
require('../FormField-
|
|
7
|
+
require('../FormField-76853659.js');
|
|
8
8
|
require('../tslib.es6-5b8768b7.js');
|
|
9
9
|
require('uuid');
|
|
10
10
|
require('react-hook-form');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var FormField = require('./FormField-
|
|
4
|
+
var FormField = require('./FormField-76853659.js');
|
|
5
5
|
|
|
6
6
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
7
7
|
|
package/dist/InputTime/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var tslib_es6 = require('../tslib.es6-5b8768b7.js');
|
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var debounce = require('lodash/debounce');
|
|
8
8
|
var temporal = require('@std-proposal/temporal');
|
|
9
|
-
var FormField = require('../FormField-
|
|
9
|
+
var FormField = require('../FormField-76853659.js');
|
|
10
10
|
require('uuid');
|
|
11
11
|
require('react-hook-form');
|
|
12
12
|
require('../style-inject.es-9d2f5f4e.js');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var FormField = require('./FormField-
|
|
4
|
+
var FormField = require('./FormField-76853659.js');
|
|
5
5
|
|
|
6
6
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
7
7
|
|
package/dist/Select/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var Option = require('../Option-
|
|
5
|
+
var Option = require('../Option-26e09990.js');
|
|
6
6
|
require('react');
|
|
7
|
-
require('../FormField-
|
|
7
|
+
require('../FormField-76853659.js');
|
|
8
8
|
require('../tslib.es6-5b8768b7.js');
|
|
9
9
|
require('uuid');
|
|
10
10
|
require('react-hook-form');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"dist/*"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@jobber/design": "^0.
|
|
21
|
-
"@jobber/formatters": "
|
|
22
|
-
"@jobber/hooks": "
|
|
20
|
+
"@jobber/design": "^0.34.0",
|
|
21
|
+
"@jobber/formatters": "*",
|
|
22
|
+
"@jobber/hooks": "*",
|
|
23
23
|
"@popperjs/core": "^2.0.6",
|
|
24
24
|
"@std-proposal/temporal": "0.0.1",
|
|
25
25
|
"@tanstack/react-table": "8.5.13",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"> 1%",
|
|
83
83
|
"IE 10"
|
|
84
84
|
],
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "ac2690b2838431ddd1d77c79944385f8820f8476"
|
|
86
86
|
}
|