@jobber/components 4.1.0 → 4.1.1
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/Autocomplete.d.ts +1 -1
- package/dist/Autocomplete/Option.d.ts +2 -2
- package/dist/Autocomplete/index.js +51 -67
- package/dist/Avatar/Avatar.d.ts +2 -2
- package/dist/Avatar/index.js +2 -2
- package/dist/{Avatar-cfd04e86.js → Avatar-89cfd0a6.js} +14 -18
- package/dist/Banner/Banner.d.ts +1 -1
- package/dist/Banner/index.js +15 -19
- package/dist/Button/Button.d.ts +1 -1
- package/dist/Button/index.js +3 -4
- package/dist/{Button-cd30df0f.js → Button-16e043ec.js} +21 -24
- package/dist/ButtonDismiss/index.js +4 -5
- package/dist/{ButtonDismiss-a9590195.js → ButtonDismiss-3fb1eaf9.js} +2 -3
- package/dist/Card/Card.d.ts +1 -1
- package/dist/Card/index.js +6 -7
- package/dist/Card/types.d.ts +1 -1
- package/dist/{Card-b9f8d6f3.js → Card-edab9c3c.js} +18 -22
- package/dist/Checkbox/Checkbox.d.ts +1 -1
- package/dist/Checkbox/index.js +4 -5
- package/dist/{Checkbox-5103d2b9.js → Checkbox-c1efc2f6.js} +10 -12
- package/dist/Chips/ChipsTypes.d.ts +1 -1
- package/dist/Chips/InternalChipDismissible/InternalChipDismissibleTypes.d.ts +1 -1
- package/dist/Chips/InternalChipDismissible/hooks/useInternalChipDismissible.d.ts +1 -1
- package/dist/Chips/InternalChipDismissible/hooks/useInternalChipDismissibleInput.d.ts +3 -3
- package/dist/Chips/InternalChipMultiSelect.d.ts +1 -1
- package/dist/Chips/InternalChipSingleSelect.d.ts +1 -1
- package/dist/Chips/index.js +165 -185
- package/dist/ConfirmationModal/ConfirmationModal.d.ts +1 -1
- package/dist/ConfirmationModal/index.js +11 -12
- package/dist/{ConfirmationModal-e95f46d7.js → ConfirmationModal-6a7beee2.js} +28 -31
- package/dist/Content/index.js +1 -1
- package/dist/{Content-18de5fbb.js → Content-05df8f7f.js} +2 -3
- package/dist/Countdown/Countdown.d.ts +1 -1
- package/dist/Countdown/computeTimeUnit.d.ts +1 -1
- package/dist/Countdown/index.js +15 -18
- package/dist/DataDump/index.js +9 -11
- package/dist/DataTable/Footer.d.ts +1 -1
- package/dist/DataTable/createTableSettings.d.ts +2 -2
- package/dist/DataTable/index.js +74 -106
- package/dist/DataTable/test-utilities/helpers.d.ts +1 -1
- package/dist/DataTable/types.d.ts +2 -2
- package/dist/DatePicker/DatePicker.d.ts +1 -1
- package/dist/DatePicker/index.js +4 -5
- package/dist/{DatePicker-cf813028.js → DatePicker-0696b0f0.js} +31 -36
- package/dist/DescriptionList/index.js +5 -10
- package/dist/Disclosure/index.js +8 -10
- package/dist/Divider/index.js +8 -10
- package/dist/Drawer/index.js +10 -14
- package/dist/Emphasis/index.js +2 -3
- package/dist/{Emphasis-75a3f411.js → Emphasis-23dc2a0a.js} +4 -6
- package/dist/FeatureSwitch/index.js +15 -17
- package/dist/Form/index.js +23 -33
- package/dist/FormField/FormFieldTypes.d.ts +2 -2
- package/dist/FormField/index.js +8 -8
- package/dist/{FormField-ac310b6f.js → FormField-79a0a375.js} +68 -76
- package/dist/FormatDate/index.js +2 -3
- package/dist/FormatEmail/index.js +2 -3
- package/dist/FormatFile/index.js +13 -14
- package/dist/{FormatFile-18e8a54a.js → FormatFile-3512f838.js} +33 -40
- package/dist/FormatRelativeDateTime/index.js +5 -6
- package/dist/FormatTime/index.js +6 -7
- package/dist/Gallery/GalleryTypes.d.ts +2 -2
- package/dist/Gallery/index.js +31 -33
- package/dist/Heading/index.js +2 -3
- package/dist/{Heading-a9a66964.js → Heading-7b203f7f.js} +4 -6
- package/dist/Icon/index.js +1 -1
- package/dist/{Icon-d5ad1a6d.js → Icon-405a216c.js} +7 -8
- package/dist/InlineLabel/InlineLabel.d.ts +1 -1
- package/dist/InlineLabel/index.js +4 -6
- package/dist/InputAvatar/index.js +15 -20
- package/dist/InputDate/index.js +15 -15
- package/dist/InputEmail/InputEmail.d.ts +1 -1
- package/dist/InputEmail/index.js +12 -12
- package/dist/InputFile/index.js +6 -6
- package/dist/{InputFile-e108a7f8.js → InputFile-5e0ed2b5.js} +48 -62
- package/dist/InputGroup/index.js +4 -5
- package/dist/InputNumber/index.js +22 -22
- package/dist/InputPassword/index.js +12 -12
- package/dist/InputText/InputText.d.ts +1 -1
- package/dist/InputText/index.js +9 -9
- package/dist/{InputText-70f7d947.js → InputText-95ea24f9.js} +23 -24
- package/dist/InputTime/index.js +27 -27
- package/dist/InputValidation/index.js +4 -5
- package/dist/{InputValidation-06a8a7ba.js → InputValidation-97dd0dcf.js} +7 -8
- package/dist/LightBox/index.js +5 -6
- package/dist/{LightBox-1ad62669.js → LightBox-dd1afa97.js} +22 -26
- package/dist/List/index.js +26 -32
- package/dist/Markdown/index.js +6 -7
- package/dist/{Markdown-b53e0308.js → Markdown-be2dcd0c.js} +12 -18
- package/dist/Menu/index.js +4 -5
- package/dist/{Menu-826cfb89.js → Menu-d6a7d17b.js} +31 -36
- package/dist/Modal/index.js +6 -7
- package/dist/{Modal-cc3bd7bf.js → Modal-757e83fd.js} +13 -17
- package/dist/MultiSelect/index.js +53 -60
- package/dist/MultiSelect/types.d.ts +1 -1
- package/dist/{Option-7d5de76b.js → Option-4b665afd.js} +3 -5
- package/dist/Page/Page.d.ts +1 -1
- package/dist/Page/index.js +21 -24
- package/dist/Popover/index.js +11 -13
- package/dist/ProgressBar/index.js +1 -1
- package/dist/{ProgressBar-e9a49129.js → ProgressBar-f028b159.js} +3 -4
- package/dist/RadioGroup/RadioOption.d.ts +2 -2
- package/dist/RadioGroup/index.js +9 -13
- package/dist/RecurringSelect/types.d.ts +2 -2
- package/dist/Select/Select.d.ts +1 -1
- package/dist/Select/index.js +9 -9
- package/dist/Spinner/index.js +1 -1
- package/dist/{Spinner-e4e9c8eb.js → Spinner-ae4c8a85.js} +5 -7
- package/dist/StatusLabel/StatusLabel.d.ts +1 -1
- package/dist/StatusLabel/index.js +6 -9
- package/dist/Switch/index.js +2 -3
- package/dist/{Switch-f03b70fc.js → Switch-7ac32f7b.js} +12 -16
- package/dist/Table/index.js +9 -17
- package/dist/Tabs/index.js +28 -34
- package/dist/Text/index.js +2 -3
- package/dist/{Text-e012fb46.js → Text-7ce00adb.js} +4 -5
- package/dist/Toast/Toast.d.ts +2 -2
- package/dist/Toast/index.js +31 -32
- package/dist/Tooltip/index.js +3 -4
- package/dist/Tooltip/useTooltipPositioning.d.ts +1 -1
- package/dist/{Tooltip-041feb00.js → Tooltip-1090a43d.js} +25 -28
- package/dist/Typography/Typography.d.ts +1 -1
- package/dist/Typography/index.js +1 -2
- package/dist/{Typography-fbe0ed6e.js → Typography-9262511f.js} +5 -7
- package/dist/tslib.es6-efe27175.js +38 -0
- package/package.json +3 -3
- package/dist/tslib.es6-5b50eb8e.js +0 -103
package/dist/InputFile/index.js
CHANGED
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var InputFile = require('../InputFile-
|
|
6
|
-
require('../tslib.es6-
|
|
5
|
+
var InputFile = require('../InputFile-5e0ed2b5.js');
|
|
6
|
+
require('../tslib.es6-efe27175.js');
|
|
7
7
|
require('react');
|
|
8
8
|
require('classnames');
|
|
9
9
|
require('react-dropzone');
|
|
10
10
|
require('axios');
|
|
11
11
|
require('uuid');
|
|
12
12
|
require('../style-inject.es-dcee06b6.js');
|
|
13
|
-
require('../Button-
|
|
13
|
+
require('../Button-16e043ec.js');
|
|
14
14
|
require('react-router-dom');
|
|
15
|
-
require('../Icon-
|
|
15
|
+
require('../Icon-405a216c.js');
|
|
16
16
|
require('@jobber/design');
|
|
17
|
-
require('../Typography-
|
|
18
|
-
require('../Content-
|
|
17
|
+
require('../Typography-9262511f.js');
|
|
18
|
+
require('../Content-05df8f7f.js');
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var tslib_es6 = require('./tslib.es6-
|
|
3
|
+
var tslib_es6 = require('./tslib.es6-efe27175.js');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var classnames = require('classnames');
|
|
6
6
|
var reactDropzone = require('react-dropzone');
|
|
7
7
|
var axios = require('axios');
|
|
8
8
|
var uuid = require('uuid');
|
|
9
9
|
var styleInject_es = require('./style-inject.es-dcee06b6.js');
|
|
10
|
-
var Button = require('./Button-
|
|
11
|
-
var Content = require('./Content-
|
|
12
|
-
var Typography = require('./Typography-
|
|
10
|
+
var Button = require('./Button-16e043ec.js');
|
|
11
|
+
var Content = require('./Content-05df8f7f.js');
|
|
12
|
+
var Typography = require('./Typography-9262511f.js');
|
|
13
13
|
|
|
14
14
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
15
|
|
|
@@ -21,10 +21,8 @@ var css = "._2CgKZHQp30gXtQyW8h2Ex_ {\n font-size: 0;\n line-height: 0;\n -we
|
|
|
21
21
|
var styles = {"dropZoneBase":"_2CgKZHQp30gXtQyW8h2Ex_","dropZone":"_3nre5MPe67v_oDs44x2IDC","active":"_1wLTm5Es7oqZzzwFiOySeN"};
|
|
22
22
|
styleInject_es.styleInject(css);
|
|
23
23
|
|
|
24
|
-
function InputFile(
|
|
25
|
-
|
|
26
|
-
var _c = _a.variation, variation = _c === void 0 ? "dropzone" : _c, _d = _a.size, size = _d === void 0 ? "base" : _d, providedButtonLabel = _a.buttonLabel, _e = _a.allowMultiple, allowMultiple = _e === void 0 ? false : _e, _f = _a.allowedTypes, allowedTypes = _f === void 0 ? "all" : _f, getUploadParams = _a.getUploadParams, onUploadStart = _a.onUploadStart, onUploadProgress = _a.onUploadProgress, onUploadComplete = _a.onUploadComplete;
|
|
27
|
-
var options = {
|
|
24
|
+
function InputFile({ variation = "dropzone", size = "base", buttonLabel: providedButtonLabel, allowMultiple = false, allowedTypes = "all", getUploadParams, onUploadStart, onUploadProgress, onUploadComplete, }) {
|
|
25
|
+
const options = {
|
|
28
26
|
multiple: allowMultiple,
|
|
29
27
|
onDrop: React.useCallback(handleDrop, []),
|
|
30
28
|
};
|
|
@@ -34,66 +32,54 @@ function InputFile(_a) {
|
|
|
34
32
|
else if (allowedTypes === "basicImages") {
|
|
35
33
|
options.accept = "image/png, image/jpg, image/jpeg";
|
|
36
34
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return (React__default["default"].createElement("div",
|
|
44
|
-
React__default["default"].createElement("input",
|
|
35
|
+
const { getRootProps, getInputProps, isDragActive } = reactDropzone.useDropzone(options);
|
|
36
|
+
const { buttonLabel, hintText } = getLabels(providedButtonLabel, allowMultiple, allowedTypes);
|
|
37
|
+
const dropZone = classnames__default["default"](styles.dropZoneBase, {
|
|
38
|
+
[styles.dropZone]: variation === "dropzone",
|
|
39
|
+
[styles.active]: isDragActive,
|
|
40
|
+
});
|
|
41
|
+
return (React__default["default"].createElement("div", Object.assign({}, getRootProps({ className: dropZone }), { tabIndex: variation === "button" ? -1 : 0 }),
|
|
42
|
+
React__default["default"].createElement("input", Object.assign({}, getInputProps())),
|
|
45
43
|
variation === "dropzone" && (React__default["default"].createElement(Content.Content, { spacing: "small" },
|
|
46
44
|
React__default["default"].createElement(Button.Button, { label: buttonLabel, size: "small", type: "secondary" }),
|
|
47
45
|
size === "base" && (React__default["default"].createElement(Typography.Typography, { size: "small", textColor: "textSecondary" }, hintText)))),
|
|
48
46
|
variation === "button" && (React__default["default"].createElement(Button.Button, { label: buttonLabel, size: size, type: "secondary", fullWidth: true }))));
|
|
49
47
|
function handleDrop(acceptedFiles) {
|
|
50
|
-
acceptedFiles.forEach(
|
|
48
|
+
acceptedFiles.forEach(file => {
|
|
51
49
|
uploadFile(file);
|
|
52
50
|
});
|
|
53
51
|
}
|
|
54
52
|
function uploadFile(file) {
|
|
55
|
-
return tslib_es6.__awaiter(this, void 0, void 0, function () {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
url: url,
|
|
73
|
-
httpMethod: httpMethod,
|
|
74
|
-
fields: fields,
|
|
75
|
-
file: file,
|
|
76
|
-
handleUploadProgress: handleUploadProgress,
|
|
77
|
-
});
|
|
78
|
-
axios__default["default"].request(axiosConfig).then(handleUploadComplete);
|
|
79
|
-
return [2 /*return*/];
|
|
80
|
-
}
|
|
53
|
+
return tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const { url, key = uuid.v1(), fields = {}, httpMethod = "POST", } = yield getUploadParams(file);
|
|
55
|
+
const fileUpload = getFileUpload(file, key);
|
|
56
|
+
onUploadStart && onUploadStart(Object.assign({}, fileUpload));
|
|
57
|
+
const handleUploadProgress = (progressEvent) => {
|
|
58
|
+
onUploadProgress &&
|
|
59
|
+
onUploadProgress(Object.assign(Object.assign({}, fileUpload), { progress: progressEvent.loaded / progressEvent.total }));
|
|
60
|
+
};
|
|
61
|
+
const handleUploadComplete = () => {
|
|
62
|
+
onUploadComplete === null || onUploadComplete === void 0 ? void 0 : onUploadComplete(Object.assign(Object.assign({}, fileUpload), { progress: 1 }));
|
|
63
|
+
};
|
|
64
|
+
const axiosConfig = createAxiosConfig({
|
|
65
|
+
url,
|
|
66
|
+
httpMethod,
|
|
67
|
+
fields,
|
|
68
|
+
file,
|
|
69
|
+
handleUploadProgress,
|
|
81
70
|
});
|
|
71
|
+
axios__default["default"].request(axiosConfig).then(handleUploadComplete);
|
|
82
72
|
});
|
|
83
73
|
}
|
|
84
74
|
}
|
|
85
|
-
function createAxiosConfig(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
var headers;
|
|
75
|
+
function createAxiosConfig({ url, httpMethod = "POST", fields = {}, file, handleUploadProgress, }) {
|
|
76
|
+
let data;
|
|
77
|
+
let headers;
|
|
89
78
|
if (httpMethod === "POST") {
|
|
90
|
-
|
|
91
|
-
Object.entries(fields).forEach(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
});
|
|
95
|
-
formData_1.append("file", file);
|
|
96
|
-
data = formData_1;
|
|
79
|
+
const formData = new FormData();
|
|
80
|
+
Object.entries(fields).forEach(([field, value]) => formData.append(field, value));
|
|
81
|
+
formData.append("file", file);
|
|
82
|
+
data = formData;
|
|
97
83
|
headers = { "X-Requested-With": "XMLHttpRequest" };
|
|
98
84
|
}
|
|
99
85
|
else {
|
|
@@ -109,8 +95,8 @@ function createAxiosConfig(_a) {
|
|
|
109
95
|
};
|
|
110
96
|
}
|
|
111
97
|
function getLabels(providedButtonLabel, multiple, allowedTypes) {
|
|
112
|
-
|
|
113
|
-
|
|
98
|
+
let buttonLabel = multiple ? "Upload Files" : "Upload File";
|
|
99
|
+
let hintText = multiple
|
|
114
100
|
? "or drag files here to upload"
|
|
115
101
|
: "or drag a file here to upload";
|
|
116
102
|
if (allowedTypes === "images" || allowedTypes === "basicImages") {
|
|
@@ -121,7 +107,7 @@ function getLabels(providedButtonLabel, multiple, allowedTypes) {
|
|
|
121
107
|
}
|
|
122
108
|
if (providedButtonLabel)
|
|
123
109
|
buttonLabel = providedButtonLabel;
|
|
124
|
-
return { buttonLabel
|
|
110
|
+
return { buttonLabel, hintText };
|
|
125
111
|
}
|
|
126
112
|
function getFileUpload(file, key) {
|
|
127
113
|
return {
|
|
@@ -133,9 +119,9 @@ function getFileUpload(file, key) {
|
|
|
133
119
|
src: getSrc,
|
|
134
120
|
};
|
|
135
121
|
function getSrc() {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
reader.onload =
|
|
122
|
+
const promise = new Promise((resolve, reject) => {
|
|
123
|
+
const reader = new FileReader();
|
|
124
|
+
reader.onload = event => {
|
|
139
125
|
if (event.target &&
|
|
140
126
|
event.target.result &&
|
|
141
127
|
typeof event.target.result === "string") {
|
|
@@ -159,8 +145,8 @@ function getFileUpload(file, key) {
|
|
|
159
145
|
* @returns FileUpload[] updated set of files.
|
|
160
146
|
*/
|
|
161
147
|
function updateFiles(updatedFile, files) {
|
|
162
|
-
|
|
163
|
-
|
|
148
|
+
const newFiles = [...files];
|
|
149
|
+
const index = files.findIndex(file => file.key === updatedFile.key);
|
|
164
150
|
if (index !== -1) {
|
|
165
151
|
newFiles[index] = updatedFile;
|
|
166
152
|
}
|
package/dist/InputGroup/index.js
CHANGED
|
@@ -15,18 +15,17 @@ var css = "._1UKIybTcnyfJQlTx901rF5 > *:not(:last-child) {\n margin-bottom: -1p
|
|
|
15
15
|
var styles = {"vertical":"_1UKIybTcnyfJQlTx901rF5","horizontal":"_26qQBed5Rzu9i2ZIDEaESr","inputGroup":"_3kywSyvvwSdmNSTOqX-AQA"};
|
|
16
16
|
styleInject_es.styleInject(css);
|
|
17
17
|
|
|
18
|
-
function InputGroup(
|
|
19
|
-
var children = _a.children, _b = _a.flowDirection, flowDirection = _b === void 0 ? "vertical" : _b;
|
|
18
|
+
function InputGroup({ children, flowDirection = "vertical", }) {
|
|
20
19
|
if (isInvalidGroupNesting(children))
|
|
21
20
|
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
22
|
-
|
|
21
|
+
const className = classnames__default["default"](styles.inputGroup, styles[flowDirection]);
|
|
23
22
|
return React__default["default"].createElement("div", { className: className }, children);
|
|
24
23
|
}
|
|
25
24
|
function isInvalidGroupNesting(childs) {
|
|
26
|
-
return React__default["default"].Children.toArray(childs).some(
|
|
25
|
+
return React__default["default"].Children.toArray(childs).some(child => {
|
|
27
26
|
if (child.type === InputGroup &&
|
|
28
27
|
child.props.flowDirection != "horizontal") {
|
|
29
|
-
console.error(
|
|
28
|
+
console.error(`ERROR: InputGroup not rendered: nesting 'flowDirection="vertical"' columns not supported.`, `https://atlantis.getjobber.com/components/input-group#nested-example`);
|
|
30
29
|
return true;
|
|
31
30
|
}
|
|
32
31
|
return false;
|
|
@@ -2,64 +2,64 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var tslib_es6 = require('../tslib.es6-5b50eb8e.js');
|
|
6
5
|
var React = require('react');
|
|
7
|
-
var FormField = require('../FormField-
|
|
6
|
+
var FormField = require('../FormField-79a0a375.js');
|
|
7
|
+
require('../tslib.es6-efe27175.js');
|
|
8
8
|
require('uuid');
|
|
9
9
|
require('react-hook-form');
|
|
10
10
|
require('../style-inject.es-dcee06b6.js');
|
|
11
11
|
require('classnames');
|
|
12
|
-
require('../Button-
|
|
12
|
+
require('../Button-16e043ec.js');
|
|
13
13
|
require('react-router-dom');
|
|
14
|
-
require('../Icon-
|
|
14
|
+
require('../Icon-405a216c.js');
|
|
15
15
|
require('@jobber/design');
|
|
16
|
-
require('../Typography-
|
|
17
|
-
require('../Text-
|
|
18
|
-
require('../InputValidation-
|
|
16
|
+
require('../Typography-9262511f.js');
|
|
17
|
+
require('../Text-7ce00adb.js');
|
|
18
|
+
require('../InputValidation-97dd0dcf.js');
|
|
19
19
|
require('framer-motion');
|
|
20
|
-
require('../Spinner-
|
|
20
|
+
require('../Spinner-ae4c8a85.js');
|
|
21
21
|
|
|
22
22
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
23
|
|
|
24
24
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
25
25
|
|
|
26
26
|
function InputNumberInternal(props, ref) {
|
|
27
|
-
|
|
28
|
-
React.useImperativeHandle(ref,
|
|
29
|
-
blur:
|
|
30
|
-
|
|
27
|
+
const inputRef = React.createRef();
|
|
28
|
+
React.useImperativeHandle(ref, () => ({
|
|
29
|
+
blur: () => {
|
|
30
|
+
const input = inputRef.current;
|
|
31
31
|
if (input) {
|
|
32
32
|
input.blur();
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
|
-
focus:
|
|
36
|
-
|
|
35
|
+
focus: () => {
|
|
36
|
+
const input = inputRef.current;
|
|
37
37
|
if (input) {
|
|
38
38
|
input.focus();
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
|
-
})
|
|
42
|
-
return (React__default["default"].createElement(FormField.FormField,
|
|
41
|
+
}));
|
|
42
|
+
return (React__default["default"].createElement(FormField.FormField, Object.assign({}, props, { type: "number", inputRef: inputRef, onChange: handleChange, validations: Object.assign(Object.assign({}, props.validations), { validate: getOverLimitMessage }) })));
|
|
43
43
|
function handleChange(newValue) {
|
|
44
44
|
props.onChange && props.onChange(newValue);
|
|
45
45
|
}
|
|
46
46
|
function getOverLimitMessage(value) {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
const isOverMax = props.max != undefined && value && value > props.max;
|
|
48
|
+
const isUnderMin = props.min != undefined && value && value < props.min;
|
|
49
49
|
if (isOverMax || isUnderMin || (value && value.toString() === "")) {
|
|
50
50
|
if (props.min != undefined && props.max === undefined) {
|
|
51
|
-
return
|
|
51
|
+
return `Enter a number that is greater than or equal to ${props.min}`;
|
|
52
52
|
}
|
|
53
53
|
else if (props.max != undefined && props.min === undefined) {
|
|
54
|
-
return
|
|
54
|
+
return `Enter a number that is less than or equal to ${props.max}`;
|
|
55
55
|
}
|
|
56
56
|
else if (props.min != undefined && props.max != undefined) {
|
|
57
|
-
return
|
|
57
|
+
return `Enter a number between ${props.min} and ${props.max}`;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
return true;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
const InputNumber = React.forwardRef(InputNumberInternal);
|
|
64
64
|
|
|
65
65
|
exports.InputNumber = InputNumber;
|
|
@@ -2,35 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var tslib_es6 = require('../tslib.es6-5b50eb8e.js');
|
|
6
5
|
var React = require('react');
|
|
7
|
-
var FormField = require('../FormField-
|
|
6
|
+
var FormField = require('../FormField-79a0a375.js');
|
|
7
|
+
require('../tslib.es6-efe27175.js');
|
|
8
8
|
require('uuid');
|
|
9
9
|
require('react-hook-form');
|
|
10
10
|
require('../style-inject.es-dcee06b6.js');
|
|
11
11
|
require('classnames');
|
|
12
|
-
require('../Button-
|
|
12
|
+
require('../Button-16e043ec.js');
|
|
13
13
|
require('react-router-dom');
|
|
14
|
-
require('../Icon-
|
|
14
|
+
require('../Icon-405a216c.js');
|
|
15
15
|
require('@jobber/design');
|
|
16
|
-
require('../Typography-
|
|
17
|
-
require('../Text-
|
|
18
|
-
require('../InputValidation-
|
|
16
|
+
require('../Typography-9262511f.js');
|
|
17
|
+
require('../Text-7ce00adb.js');
|
|
18
|
+
require('../InputValidation-97dd0dcf.js');
|
|
19
19
|
require('framer-motion');
|
|
20
|
-
require('../Spinner-
|
|
20
|
+
require('../Spinner-ae4c8a85.js');
|
|
21
21
|
|
|
22
22
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
23
|
|
|
24
24
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
25
25
|
|
|
26
26
|
function InputPassword(props) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return (React__default["default"].createElement(FormField.FormField,
|
|
27
|
+
const { hasVisibility = false } = props;
|
|
28
|
+
const [visible, setVisibility] = React.useState(false);
|
|
29
|
+
return (React__default["default"].createElement(FormField.FormField, Object.assign({}, props, (hasVisibility && {
|
|
30
30
|
suffix: {
|
|
31
31
|
ariaLabel: visible ? "Hide password" : "Show password",
|
|
32
32
|
icon: visible ? "eye" : "eyeCrossed",
|
|
33
|
-
onClick:
|
|
33
|
+
onClick: () => setVisibility(!visible),
|
|
34
34
|
},
|
|
35
35
|
}), { type: visible ? "text" : "password", onChange: handleChange })));
|
|
36
36
|
function handleChange(newValue) {
|
|
@@ -25,5 +25,5 @@ interface MultilineProps extends BaseProps {
|
|
|
25
25
|
*/
|
|
26
26
|
readonly rows?: number | RowRange;
|
|
27
27
|
}
|
|
28
|
-
export declare const InputText: React.ForwardRefExoticComponent<(import("ts-xor/dist/types/Without.type").Without<BaseProps, MultilineProps> & MultilineProps
|
|
28
|
+
export declare const InputText: React.ForwardRefExoticComponent<((import("ts-xor/dist/types/Without.type").Without<BaseProps, MultilineProps> & MultilineProps) | (import("ts-xor/dist/types/Without.type").Without<MultilineProps, BaseProps> & BaseProps)) & React.RefAttributes<InputTextRef>>;
|
|
29
29
|
export {};
|
package/dist/InputText/index.js
CHANGED
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var InputText = require('../InputText-
|
|
6
|
-
require('../tslib.es6-5b50eb8e.js');
|
|
5
|
+
var InputText = require('../InputText-95ea24f9.js');
|
|
7
6
|
require('react');
|
|
8
|
-
require('../FormField-
|
|
7
|
+
require('../FormField-79a0a375.js');
|
|
8
|
+
require('../tslib.es6-efe27175.js');
|
|
9
9
|
require('uuid');
|
|
10
10
|
require('react-hook-form');
|
|
11
11
|
require('../style-inject.es-dcee06b6.js');
|
|
12
12
|
require('classnames');
|
|
13
|
-
require('../Button-
|
|
13
|
+
require('../Button-16e043ec.js');
|
|
14
14
|
require('react-router-dom');
|
|
15
|
-
require('../Icon-
|
|
15
|
+
require('../Icon-405a216c.js');
|
|
16
16
|
require('@jobber/design');
|
|
17
|
-
require('../Typography-
|
|
18
|
-
require('../Text-
|
|
19
|
-
require('../InputValidation-
|
|
17
|
+
require('../Typography-9262511f.js');
|
|
18
|
+
require('../Text-7ce00adb.js');
|
|
19
|
+
require('../InputValidation-97dd0dcf.js');
|
|
20
20
|
require('framer-motion');
|
|
21
|
-
require('../Spinner-
|
|
21
|
+
require('../Spinner-ae4c8a85.js');
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var tslib_es6 = require('./tslib.es6-5b50eb8e.js');
|
|
4
3
|
var React = require('react');
|
|
5
|
-
var FormField = require('./FormField-
|
|
4
|
+
var FormField = require('./FormField-79a0a375.js');
|
|
6
5
|
|
|
7
6
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
7
|
|
|
9
8
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
9
|
|
|
11
10
|
function InputTextInternal(props, ref) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
React.useImperativeHandle(ref,
|
|
16
|
-
insert:
|
|
11
|
+
const inputRef = React.createRef();
|
|
12
|
+
const actionsRef = React.createRef();
|
|
13
|
+
const rowRange = getRowRange();
|
|
14
|
+
React.useImperativeHandle(ref, () => ({
|
|
15
|
+
insert: (text) => {
|
|
17
16
|
insertText(text);
|
|
18
17
|
},
|
|
19
|
-
blur:
|
|
20
|
-
|
|
18
|
+
blur: () => {
|
|
19
|
+
const input = inputRef.current;
|
|
21
20
|
if (input) {
|
|
22
21
|
input.blur();
|
|
23
22
|
}
|
|
24
23
|
},
|
|
25
|
-
focus:
|
|
26
|
-
|
|
24
|
+
focus: () => {
|
|
25
|
+
const input = inputRef.current;
|
|
27
26
|
if (input) {
|
|
28
27
|
input.focus();
|
|
29
28
|
}
|
|
30
29
|
},
|
|
31
|
-
})
|
|
32
|
-
return (React__default["default"].createElement(FormField.FormField,
|
|
30
|
+
}));
|
|
31
|
+
return (React__default["default"].createElement(FormField.FormField, Object.assign({}, props, { type: props.multiline ? "textarea" : "text", inputRef: inputRef, actionsRef: actionsRef, onChange: handleChange, rows: rowRange.min })));
|
|
33
32
|
function handleChange(newValue) {
|
|
34
33
|
props.onChange && props.onChange(newValue);
|
|
35
34
|
if (inputRef && inputRef.current instanceof HTMLTextAreaElement) {
|
|
@@ -54,35 +53,35 @@ function InputTextInternal(props, ref) {
|
|
|
54
53
|
textArea.style.height = textAreaHeight(textArea) + "px";
|
|
55
54
|
}
|
|
56
55
|
function textAreaHeight(textArea) {
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
const { lineHeight, borderBottomWidth, borderTopWidth, paddingBottom, paddingTop, } = window.getComputedStyle(textArea);
|
|
57
|
+
const maxHeight = rowRange.max * parseFloat(lineHeight) +
|
|
59
58
|
parseFloat(borderTopWidth) +
|
|
60
59
|
parseFloat(borderBottomWidth) +
|
|
61
60
|
parseFloat(paddingTop) +
|
|
62
61
|
parseFloat(paddingBottom);
|
|
63
|
-
|
|
62
|
+
const scrollHeight = textArea.scrollHeight +
|
|
64
63
|
parseFloat(borderTopWidth) +
|
|
65
64
|
parseFloat(borderBottomWidth);
|
|
66
65
|
return Math.min(scrollHeight, maxHeight);
|
|
67
66
|
}
|
|
68
67
|
function insertText(text) {
|
|
69
68
|
var _a;
|
|
70
|
-
|
|
69
|
+
const input = inputRef.current;
|
|
71
70
|
if (input) {
|
|
72
71
|
insertAtCursor(input, text);
|
|
73
|
-
|
|
72
|
+
const newValue = input.value;
|
|
74
73
|
(_a = actionsRef.current) === null || _a === void 0 ? void 0 : _a.setValue(newValue);
|
|
75
74
|
props.onChange && props.onChange(newValue);
|
|
76
75
|
}
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
|
-
|
|
78
|
+
const InputText = React.forwardRef(InputTextInternal);
|
|
80
79
|
function insertAtCursor(input, newText) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
const start = input.selectionStart || 0;
|
|
81
|
+
const end = input.selectionEnd || 0;
|
|
82
|
+
const text = input.value;
|
|
83
|
+
const before = text.substring(0, start);
|
|
84
|
+
const after = text.substring(end, text.length);
|
|
86
85
|
input.value = before + newText + after;
|
|
87
86
|
input.selectionStart = input.selectionEnd = start + newText.length;
|
|
88
87
|
input.focus();
|
package/dist/InputTime/index.js
CHANGED
|
@@ -2,24 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var tslib_es6 = require('../tslib.es6-
|
|
5
|
+
var tslib_es6 = require('../tslib.es6-efe27175.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-79a0a375.js');
|
|
10
10
|
require('uuid');
|
|
11
11
|
require('react-hook-form');
|
|
12
12
|
require('../style-inject.es-dcee06b6.js');
|
|
13
13
|
require('classnames');
|
|
14
|
-
require('../Button-
|
|
14
|
+
require('../Button-16e043ec.js');
|
|
15
15
|
require('react-router-dom');
|
|
16
|
-
require('../Icon-
|
|
16
|
+
require('../Icon-405a216c.js');
|
|
17
17
|
require('@jobber/design');
|
|
18
|
-
require('../Typography-
|
|
19
|
-
require('../Text-
|
|
20
|
-
require('../InputValidation-
|
|
18
|
+
require('../Typography-9262511f.js');
|
|
19
|
+
require('../Text-7ce00adb.js');
|
|
20
|
+
require('../InputValidation-97dd0dcf.js');
|
|
21
21
|
require('framer-motion');
|
|
22
|
-
require('../Spinner-
|
|
22
|
+
require('../Spinner-ae4c8a85.js');
|
|
23
23
|
|
|
24
24
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
25
25
|
|
|
@@ -884,7 +884,7 @@ function civilTimeToHTMLTime(civilTime) {
|
|
|
884
884
|
if (civilTime == undefined) {
|
|
885
885
|
return "";
|
|
886
886
|
}
|
|
887
|
-
|
|
887
|
+
const timeString = civilTime.toString();
|
|
888
888
|
return timeString.slice(0, 5);
|
|
889
889
|
}
|
|
890
890
|
function htmlTimeToCivilTime(timeString) {
|
|
@@ -897,13 +897,13 @@ function htmlTimeToCivilTime(timeString) {
|
|
|
897
897
|
}
|
|
898
898
|
|
|
899
899
|
function InputTimeSafari(_a) {
|
|
900
|
-
var
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
React.useLayoutEffect(
|
|
906
|
-
|
|
900
|
+
var { defaultValue, value, onChange } = _a, params = tslib_es6.__rest(_a, ["defaultValue", "value", "onChange"]);
|
|
901
|
+
const inputTime = React__default["default"].createRef();
|
|
902
|
+
const debouncedHandleChange = debounce__default["default"](handleChange, 1000);
|
|
903
|
+
const changeHandler = generateEventHandler(debouncedHandleChange);
|
|
904
|
+
const blurHandler = generateEventHandler(handleChange);
|
|
905
|
+
React.useLayoutEffect(() => {
|
|
906
|
+
const input = inputTime.current;
|
|
907
907
|
new TimePolyfill(input);
|
|
908
908
|
if (value) {
|
|
909
909
|
input.value = civilTimeToHTMLTime(value);
|
|
@@ -915,13 +915,13 @@ function InputTimeSafari(_a) {
|
|
|
915
915
|
}
|
|
916
916
|
input.addEventListener("change", changeHandler);
|
|
917
917
|
input.addEventListener("blur", blurHandler);
|
|
918
|
-
return
|
|
918
|
+
return () => {
|
|
919
919
|
window.removeEventListener("change", changeHandler);
|
|
920
920
|
window.removeEventListener("blur", blurHandler);
|
|
921
921
|
};
|
|
922
922
|
}, []);
|
|
923
|
-
React.useLayoutEffect(
|
|
924
|
-
|
|
923
|
+
React.useLayoutEffect(() => {
|
|
924
|
+
const input = inputTime.current;
|
|
925
925
|
if (value) {
|
|
926
926
|
input.value = civilTimeToHTMLTime(value);
|
|
927
927
|
input.polyfill.update();
|
|
@@ -931,13 +931,13 @@ function InputTimeSafari(_a) {
|
|
|
931
931
|
input.polyfill.update();
|
|
932
932
|
}
|
|
933
933
|
}, [value, defaultValue]);
|
|
934
|
-
return React__default["default"].createElement(FormField.FormField,
|
|
934
|
+
return React__default["default"].createElement(FormField.FormField, Object.assign({ inputRef: inputTime, type: "time" }, params));
|
|
935
935
|
function handleChange(newValue) {
|
|
936
936
|
onChange && onChange(htmlTimeToCivilTime(newValue));
|
|
937
937
|
}
|
|
938
938
|
function generateEventHandler(handler) {
|
|
939
|
-
return
|
|
940
|
-
|
|
939
|
+
return (event) => {
|
|
940
|
+
const newValue = event.currentTarget.dataset.value;
|
|
941
941
|
if (newValue != undefined) {
|
|
942
942
|
handler(newValue);
|
|
943
943
|
}
|
|
@@ -946,16 +946,16 @@ function InputTimeSafari(_a) {
|
|
|
946
946
|
}
|
|
947
947
|
|
|
948
948
|
function InputTime(_a) {
|
|
949
|
-
var
|
|
950
|
-
|
|
949
|
+
var { defaultValue, value, onChange } = _a, params = tslib_es6.__rest(_a, ["defaultValue", "value", "onChange"]);
|
|
950
|
+
const handleChange = (newValue) => {
|
|
951
951
|
onChange && onChange(htmlTimeToCivilTime(newValue));
|
|
952
952
|
};
|
|
953
953
|
if (supportsTime) {
|
|
954
|
-
|
|
955
|
-
return React__default["default"].createElement(FormField.FormField,
|
|
954
|
+
const fieldProps = Object.assign(Object.assign(Object.assign({ onChange: handleChange }, (defaultValue && { defaultValue: civilTimeToHTMLTime(defaultValue) })), (!defaultValue && { value: civilTimeToHTMLTime(value) })), params);
|
|
955
|
+
return React__default["default"].createElement(FormField.FormField, Object.assign({ type: "time" }, fieldProps));
|
|
956
956
|
}
|
|
957
957
|
else {
|
|
958
|
-
return (React__default["default"].createElement(InputTimeSafari,
|
|
958
|
+
return (React__default["default"].createElement(InputTimeSafari, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChange }, params)));
|
|
959
959
|
}
|
|
960
960
|
}
|
|
961
961
|
|