@jobber/components 4.7.2 → 4.7.4-pre.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 +2 -6
- package/dist/Autocomplete/index.js +31 -31
- package/dist/DataTable/index.js +2 -2
- package/dist/FormField/index.js +1 -1
- package/dist/{FormField-76853659.js → FormField-03e36a98.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-73113193.js → InputText-0a76a9f9.js} +1 -1
- package/dist/InputTime/index.js +1 -1
- package/dist/{Option-26e09990.js → Option-1447547b.js} +1 -1
- package/dist/Select/index.js +2 -2
- package/package.json +5 -5
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="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>;
|
|
11
7
|
onOptionSelect(chosenOption: Option): void;
|
|
12
8
|
}
|
|
13
|
-
export declare function Menu({ visible, options, selectedOption, onOptionSelect,
|
|
9
|
+
export declare function Menu({ visible, options, selectedOption, onOptionSelect, }: MenuProps): JSX.Element;
|
|
14
10
|
export {};
|
|
@@ -8,15 +8,13 @@ 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');
|
|
13
11
|
var Text = require('../Text-e7ed0974.js');
|
|
14
12
|
var Icon = require('../Icon-405a216c.js');
|
|
15
13
|
var Heading = require('../Heading-a1191b15.js');
|
|
16
|
-
var InputText = require('../InputText-
|
|
14
|
+
var InputText = require('../InputText-0a76a9f9.js');
|
|
17
15
|
require('../Typography-fd6f932a.js');
|
|
18
16
|
require('@jobber/design');
|
|
19
|
-
require('../FormField-
|
|
17
|
+
require('../FormField-03e36a98.js');
|
|
20
18
|
require('uuid');
|
|
21
19
|
require('react-hook-form');
|
|
22
20
|
require('../Button-69409e46.js');
|
|
@@ -41,16 +39,19 @@ var IndexChange;
|
|
|
41
39
|
IndexChange[IndexChange["Previous"] = -1] = "Previous";
|
|
42
40
|
IndexChange[IndexChange["Next"] = 1] = "Next";
|
|
43
41
|
})(IndexChange || (IndexChange = {}));
|
|
44
|
-
function Menu({ visible, options, selectedOption, onOptionSelect,
|
|
42
|
+
function Menu({ visible, options, selectedOption, onOptionSelect, }) {
|
|
45
43
|
const [highlightedIndex, setHighlightedIndex] = React.useState(0);
|
|
46
|
-
const
|
|
44
|
+
const optionMenuClass = classnames__default["default"](styles.options, {
|
|
45
|
+
[styles.visible]: visible,
|
|
46
|
+
});
|
|
47
|
+
const menuDiv = React.useRef();
|
|
47
48
|
const detectSeparatorCondition = (option) => option.description || option.details;
|
|
48
49
|
const detectGroups = (option) => option.options;
|
|
49
50
|
const addSeparators = options.some(detectSeparatorCondition);
|
|
50
51
|
const initialHighlight = options.some(detectGroups) ? 1 : 0;
|
|
51
52
|
setupKeyListeners();
|
|
52
53
|
React.useEffect(() => setHighlightedIndex(initialHighlight), [options]);
|
|
53
|
-
|
|
54
|
+
return (React__default["default"].createElement("div", { className: optionMenuClass, ref: menuDiv }, options.map((option, index) => {
|
|
54
55
|
const optionClass = classnames__default["default"](styles.option, {
|
|
55
56
|
[styles.active]: index === highlightedIndex,
|
|
56
57
|
[styles.separator]: addSeparators,
|
|
@@ -68,28 +69,40 @@ function Menu({ visible, options, selectedOption, onOptionSelect, attachTo, }) {
|
|
|
68
69
|
option.details !== undefined && (React__default["default"].createElement("div", { className: styles.details },
|
|
69
70
|
React__default["default"].createElement(Text.Text, null, option.details))))));
|
|
70
71
|
})));
|
|
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]);
|
|
81
73
|
useOnKeyDown("ArrowDown", (event) => {
|
|
82
74
|
const indexChange = arrowKeyPress(event, IndexChange.Next);
|
|
83
75
|
if (indexChange) {
|
|
84
76
|
setHighlightedIndex(Math.min(options.length - 1, highlightedIndex + indexChange));
|
|
85
77
|
}
|
|
78
|
+
if (menuDiv.current) {
|
|
79
|
+
scrollMenuIfItemNotInView(menuDiv.current, "down");
|
|
80
|
+
}
|
|
86
81
|
});
|
|
87
82
|
useOnKeyDown("ArrowUp", (event) => {
|
|
88
83
|
const indexChange = arrowKeyPress(event, IndexChange.Previous);
|
|
89
84
|
if (indexChange) {
|
|
90
85
|
setHighlightedIndex(Math.max(0, highlightedIndex + indexChange));
|
|
91
86
|
}
|
|
87
|
+
if (menuDiv.current) {
|
|
88
|
+
scrollMenuIfItemNotInView(menuDiv.current, "up");
|
|
89
|
+
}
|
|
92
90
|
});
|
|
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
|
+
}
|
|
93
106
|
useOnKeyDown("Enter", (event) => {
|
|
94
107
|
if (!visible)
|
|
95
108
|
return;
|
|
@@ -128,18 +141,6 @@ function isGroup(option) {
|
|
|
128
141
|
return true;
|
|
129
142
|
return false;
|
|
130
143
|
}
|
|
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
|
-
}
|
|
143
144
|
|
|
144
145
|
/**
|
|
145
146
|
* Max statements disabled here to make room for the
|
|
@@ -151,7 +152,6 @@ function Autocomplete({ initialOptions = [], value, allowFreeForm = true, size =
|
|
|
151
152
|
const [options, setOptions] = React.useState(initialOptions);
|
|
152
153
|
const [menuVisible, setMenuVisible] = React.useState(false);
|
|
153
154
|
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 },
|
|
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, {
|
|
166
|
+
menuVisible && (React__default["default"].createElement(Menu, { 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-1447547b.js');
|
|
12
12
|
var Button = require('../Button-69409e46.js');
|
|
13
13
|
var Text = require('../Text-e7ed0974.js');
|
|
14
|
-
require('../FormField-
|
|
14
|
+
require('../FormField-03e36a98.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, { shouldValidate: true });
|
|
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-03e36a98.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-03e36a98.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-03e36a98.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-03e36a98.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 | HTMLSelectElement | HTMLTextAreaElement> | 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 | HTMLSelectElement | HTMLTextAreaElement> | 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 | HTMLSelectElement | HTMLTextAreaElement> | 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 | HTMLSelectElement | HTMLTextAreaElement> | 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-0a76a9f9.js');
|
|
6
6
|
require('react');
|
|
7
|
-
require('../FormField-
|
|
7
|
+
require('../FormField-03e36a98.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-03e36a98.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-03e36a98.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-03e36a98.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-1447547b.js');
|
|
6
6
|
require('react');
|
|
7
|
-
require('../FormField-
|
|
7
|
+
require('../FormField-03e36a98.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.7.
|
|
3
|
+
"version": "4.7.4-pre.0+0292e9ad",
|
|
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.33.1-pre.0+0292e9ad",
|
|
21
|
+
"@jobber/formatters": "^0.2.2",
|
|
22
|
+
"@jobber/hooks": "^2.0.2",
|
|
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": "0292e9ad55b21d3c36c70f9802a1883ba66bcca6"
|
|
86
86
|
}
|