@jobber/components 4.0.2 → 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 +10 -2
- package/dist/DatePicker/index.js +4 -5
- package/dist/{DatePicker-7c67e8d2.js → DatePicker-0696b0f0.js} +41 -38
- 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
|
@@ -2,8 +2,8 @@ import { ChangeEvent, ReactNode, RefObject } from "react";
|
|
|
2
2
|
import { RegisterOptions } from "react-hook-form";
|
|
3
3
|
import { XOR } from "ts-xor";
|
|
4
4
|
import { IconNames } from "../Icon";
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type FormFieldTypes = "text" | "password" | "number" | "time" | "textarea" | "select" | "email";
|
|
6
|
+
export type AutocompleteTypes = "one-time-code" | "address-line1" | "address-line2";
|
|
7
7
|
export interface FieldActionsRef {
|
|
8
8
|
setValue(value: string | number): void;
|
|
9
9
|
}
|
package/dist/FormField/index.js
CHANGED
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var FormField = require('../FormField-
|
|
6
|
-
require('../tslib.es6-
|
|
5
|
+
var FormField = require('../FormField-79a0a375.js');
|
|
6
|
+
require('../tslib.es6-efe27175.js');
|
|
7
7
|
require('react');
|
|
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
|
|
|
23
23
|
|
|
@@ -1,16 +1,16 @@
|
|
|
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 uuid = require('uuid');
|
|
6
6
|
var reactHookForm = require('react-hook-form');
|
|
7
7
|
var styleInject_es = require('./style-inject.es-dcee06b6.js');
|
|
8
8
|
var classnames = require('classnames');
|
|
9
|
-
var Button = require('./Button-
|
|
10
|
-
var Icon = require('./Icon-
|
|
11
|
-
var Text = require('./Text-
|
|
12
|
-
var InputValidation = require('./InputValidation-
|
|
13
|
-
var Spinner = require('./Spinner-
|
|
9
|
+
var Button = require('./Button-16e043ec.js');
|
|
10
|
+
var Icon = require('./Icon-405a216c.js');
|
|
11
|
+
var Text = require('./Text-7ce00adb.js');
|
|
12
|
+
var InputValidation = require('./InputValidation-97dd0dcf.js');
|
|
13
|
+
var Spinner = require('./Spinner-ae4c8a85.js');
|
|
14
14
|
|
|
15
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
16
|
|
|
@@ -21,22 +21,18 @@ var css = ":root {\n /**\n * These `--public-field` properties are used in ot
|
|
|
21
21
|
var styles = {"wrapper":"_2bOj_Hpd2VvA3mi9t4RcZO","miniLabel":"IVFKQabHAwX8Kn2aNj8gM","textarea":"_1hfSn_RRn6Enf7teCHrbV8","invalid":"_3H2M7GlXG4Qh417lRbpzS7","disabled":"_2xkImc45YUzsUp6bZ3Ik_4","small":"_2N7Ipv_CbNRzrdEGCrptrV","large":"_2RtHPlAJG3Hp2QD9Q9cfD_","inline-left":"_3AHR56Sam4H_gp9JyzxRLl","inline-right":"_3AHR56Sam4H_gp9JyzxRLl","inline":"_3AHR56Sam4H_gp9JyzxRLl","center":"_19KcCv1flBCB9mHUlTLkQL","right":"_1wVbgkkxLyHZUFsS-xEPlc","maxLength":"_1tABQjw4-IkgUE3cbBzs7r","inputWrapper":"_1WnxEaBZY0zLsD8oKwh20b","input":"_3koQsrzZZXPVxXmmESjSG_","select":"Ntcl388Qhhu4uLJc2d1Ll","label":"ktPFw5_r1v4MB-Ts5rPTG","postfix":"_1yJbSG5N0hfPjPkrih4Q99","affixIcon":"_1EBMzQ2qM74AhLWsJH_VD7","suffix":"_2k-tb4HuwDpSggx3JEm4Rp","hasAction":"_1Pm2Qo4Aw45IfKYq1qX4CW","affixLabel":"_2PE8Igv1VLxZ4mpQc6iiR4","description":"_1iN0xB6nTG687YOOopowf"};
|
|
22
22
|
styleInject_es.styleInject(css);
|
|
23
23
|
|
|
24
|
-
function AffixLabel(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
_b[styles.suffix] = variation === "suffix",
|
|
29
|
-
_b));
|
|
24
|
+
function AffixLabel({ label, variation = "prefix", labelRef, }) {
|
|
25
|
+
const affixLabelClass = classnames__default["default"](styles.affixLabel, {
|
|
26
|
+
[styles.suffix]: variation === "suffix",
|
|
27
|
+
});
|
|
30
28
|
return (React__default["default"].createElement("div", { ref: labelRef, className: affixLabelClass }, label));
|
|
31
29
|
}
|
|
32
|
-
function AffixIcon(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
_b));
|
|
39
|
-
var iconSize = size === "small" ? "small" : "base";
|
|
30
|
+
function AffixIcon({ icon, onClick, ariaLabel, variation = "prefix", size, }) {
|
|
31
|
+
const affixIconClass = classnames__default["default"](styles.affixIcon, {
|
|
32
|
+
[styles.suffix]: variation === "suffix",
|
|
33
|
+
[styles.hasAction]: onClick,
|
|
34
|
+
});
|
|
35
|
+
const iconSize = size === "small" ? "small" : "base";
|
|
40
36
|
if (!icon)
|
|
41
37
|
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
42
38
|
return (React__default["default"].createElement("div", { className: affixIconClass }, onClick ? (React__default["default"].createElement(Button.Button
|
|
@@ -52,123 +48,119 @@ function AffixIcon(_a) {
|
|
|
52
48
|
ariaLabel: ariaLabel, icon: icon, onClick: onClick, variation: "subtle", type: "tertiary", size: iconSize })) : (React__default["default"].createElement(Icon.Icon, { name: icon, size: iconSize, color: "greyBlue" }))));
|
|
53
49
|
}
|
|
54
50
|
|
|
55
|
-
function FormFieldDescription(
|
|
56
|
-
var id = _a.id, description = _a.description;
|
|
51
|
+
function FormFieldDescription({ id, description, }) {
|
|
57
52
|
return (React__default["default"].createElement("div", { id: id, className: styles.description },
|
|
58
53
|
React__default["default"].createElement(Text.Text, { size: "small", variation: "subdued" }, description)));
|
|
59
54
|
}
|
|
60
55
|
|
|
61
|
-
function FormFieldWrapper(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var wrapperClasses = classnames__default["default"](styles.wrapper, size && styles[size], align && styles[align], (_b = {},
|
|
65
|
-
_b[styles.miniLabel] = (placeholder && value !== "") ||
|
|
56
|
+
function FormFieldWrapper({ align, description, descriptionIdentifier, placeholder, value, children, invalid, error, size, prefix, suffix, max, maxLength, type, disabled, inline, identifier, }) {
|
|
57
|
+
const wrapperClasses = classnames__default["default"](styles.wrapper, size && styles[size], align && styles[align], {
|
|
58
|
+
[styles.miniLabel]: (placeholder && value !== "") ||
|
|
66
59
|
(placeholder && type === "select") ||
|
|
67
60
|
(placeholder && type === "time"),
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
61
|
+
[styles.textarea]: type === "textarea",
|
|
62
|
+
[styles.invalid]: invalid !== null && invalid !== void 0 ? invalid : error,
|
|
63
|
+
[styles.disabled]: disabled,
|
|
64
|
+
[styles.inline]: inline,
|
|
65
|
+
[styles.maxLength]: maxLength,
|
|
66
|
+
[styles.select]: type === "select",
|
|
67
|
+
});
|
|
68
|
+
const wrapperInlineStyle = {
|
|
69
|
+
["--formField-maxLength"]: maxLength || max,
|
|
70
|
+
};
|
|
71
|
+
const prefixRef = React.useRef();
|
|
72
|
+
const suffixRef = React.useRef();
|
|
73
|
+
const [labelStyle, setLabelStyle] = React.useState({
|
|
81
74
|
paddingLeft: undefined,
|
|
82
75
|
paddingRight: undefined,
|
|
83
|
-
})
|
|
84
|
-
React.useEffect(
|
|
76
|
+
});
|
|
77
|
+
React.useEffect(() => {
|
|
85
78
|
setLabelStyle(getAffixPaddding);
|
|
86
79
|
}, [value]);
|
|
87
80
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
88
81
|
React__default["default"].createElement("div", { className: wrapperClasses, style: wrapperInlineStyle },
|
|
89
|
-
(prefix === null || prefix === void 0 ? void 0 : prefix.icon) && React__default["default"].createElement(AffixIcon,
|
|
82
|
+
(prefix === null || prefix === void 0 ? void 0 : prefix.icon) && React__default["default"].createElement(AffixIcon, Object.assign({}, prefix, { size: size })),
|
|
90
83
|
React__default["default"].createElement("div", { className: styles.inputWrapper },
|
|
91
84
|
React__default["default"].createElement("label", { className: styles.label, htmlFor: identifier, style: (prefixRef === null || prefixRef === void 0 ? void 0 : prefixRef.current) || (suffixRef === null || suffixRef === void 0 ? void 0 : suffixRef.current) ? labelStyle : undefined }, placeholder),
|
|
92
|
-
(prefix === null || prefix === void 0 ? void 0 : prefix.label) && React__default["default"].createElement(AffixLabel,
|
|
85
|
+
(prefix === null || prefix === void 0 ? void 0 : prefix.label) && React__default["default"].createElement(AffixLabel, Object.assign({}, prefix, { labelRef: prefixRef })),
|
|
93
86
|
children,
|
|
94
|
-
(suffix === null || suffix === void 0 ? void 0 : suffix.label) && (React__default["default"].createElement(AffixLabel,
|
|
95
|
-
(suffix === null || suffix === void 0 ? void 0 : suffix.icon) && (React__default["default"].createElement(AffixIcon,
|
|
87
|
+
(suffix === null || suffix === void 0 ? void 0 : suffix.label) && (React__default["default"].createElement(AffixLabel, Object.assign({}, suffix, { labelRef: suffixRef, variation: "suffix" })))),
|
|
88
|
+
(suffix === null || suffix === void 0 ? void 0 : suffix.icon) && (React__default["default"].createElement(AffixIcon, Object.assign({}, suffix, { variation: "suffix", size: size })))),
|
|
96
89
|
description && !inline && (React__default["default"].createElement(FormFieldDescription, { id: descriptionIdentifier, description: description })),
|
|
97
90
|
error && !inline && React__default["default"].createElement(InputValidation.InputValidation, { message: error })));
|
|
98
91
|
function getAffixPaddding() {
|
|
99
|
-
|
|
100
|
-
|
|
92
|
+
const hasValue = value !== "";
|
|
93
|
+
const newPadding = {
|
|
101
94
|
paddingLeft: undefined,
|
|
102
95
|
paddingRight: undefined,
|
|
103
96
|
};
|
|
104
97
|
if ((prefixRef === null || prefixRef === void 0 ? void 0 : prefixRef.current) && !hasValue) {
|
|
105
|
-
|
|
98
|
+
const { offsetWidth } = prefixRef.current;
|
|
106
99
|
newPadding.paddingLeft = offset(offsetWidth);
|
|
107
100
|
}
|
|
108
101
|
if ((suffixRef === null || suffixRef === void 0 ? void 0 : suffixRef.current) && !hasValue) {
|
|
109
|
-
|
|
102
|
+
const { offsetWidth } = suffixRef.current;
|
|
110
103
|
newPadding.paddingRight = offset(offsetWidth);
|
|
111
104
|
}
|
|
112
105
|
function offset(width) {
|
|
113
|
-
return
|
|
106
|
+
return `calc(${width}px + var(--space-smallest)`;
|
|
114
107
|
}
|
|
115
108
|
return newPadding;
|
|
116
109
|
}
|
|
117
110
|
}
|
|
118
111
|
|
|
119
|
-
function FormFieldPostFix(
|
|
120
|
-
var variation = _a.variation;
|
|
112
|
+
function FormFieldPostFix({ variation }) {
|
|
121
113
|
return (React__default["default"].createElement("span", { className: styles.postfix }, variation === "select" ? (React__default["default"].createElement(Icon.Icon, { name: "arrowDown" })) : (React__default["default"].createElement(Spinner.Spinner, { size: "small" }))));
|
|
122
114
|
}
|
|
123
115
|
|
|
124
116
|
function FormField(props) {
|
|
125
117
|
var _a;
|
|
126
|
-
|
|
127
|
-
|
|
118
|
+
const { actionsRef, autocomplete = true, children, defaultValue, description, disabled, inputRef, inline, keyboard, max, maxLength, min, name, readonly, rows, loading, type = "text", validations, value, onChange, onEnter, onFocus, onBlur, onValidation, } = props;
|
|
119
|
+
const { control, errors, setValue, watch } = reactHookForm.useFormContext() != undefined
|
|
128
120
|
? reactHookForm.useFormContext()
|
|
129
|
-
: reactHookForm.useForm({ mode: "onTouched" })
|
|
130
|
-
|
|
131
|
-
|
|
121
|
+
: reactHookForm.useForm({ mode: "onTouched" });
|
|
122
|
+
const [identifier] = React.useState(uuid.v1());
|
|
123
|
+
const [descriptionIdentifier] = React.useState(`descriptionUUID--${uuid.v1()}`);
|
|
132
124
|
/**
|
|
133
125
|
* Generate a name if one is not supplied, this is the name
|
|
134
126
|
* that will be used for react-hook-form and not neccessarily
|
|
135
127
|
* attached to the DOM
|
|
136
128
|
*/
|
|
137
|
-
|
|
138
|
-
React.useEffect(
|
|
129
|
+
const [controlledName] = React.useState(name ? name : `generatedName--${identifier}`);
|
|
130
|
+
React.useEffect(() => {
|
|
139
131
|
if (value != undefined) {
|
|
140
132
|
setValue(controlledName, value);
|
|
141
133
|
}
|
|
142
134
|
}, [value, watch(controlledName)]);
|
|
143
|
-
React.useImperativeHandle(actionsRef,
|
|
144
|
-
setValue:
|
|
135
|
+
React.useImperativeHandle(actionsRef, () => ({
|
|
136
|
+
setValue: newValue => {
|
|
145
137
|
setValue(controlledName, newValue);
|
|
146
138
|
},
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
React.useEffect(
|
|
150
|
-
return (React__default["default"].createElement(reactHookForm.Controller, { control: control, name: controlledName, rules:
|
|
151
|
-
var
|
|
152
|
-
|
|
139
|
+
}));
|
|
140
|
+
const error = errors[controlledName] && errors[controlledName].message;
|
|
141
|
+
React.useEffect(() => handleValidation(), [error]);
|
|
142
|
+
return (React__default["default"].createElement(reactHookForm.Controller, { control: control, name: controlledName, rules: Object.assign({}, validations), defaultValue: (_a = value !== null && value !== void 0 ? value : defaultValue) !== null && _a !== void 0 ? _a : "", render: (_a) => {
|
|
143
|
+
var { onChange: onControllerChange, onBlur: onControllerBlur, name: controllerName } = _a, rest = tslib_es6.__rest(_a, ["onChange", "onBlur", "name"]);
|
|
144
|
+
const fieldProps = Object.assign(Object.assign(Object.assign({}, rest), { id: identifier, className: styles.input, name: (validations || name) && controllerName, disabled: disabled, readOnly: readonly, inputMode: keyboard, onChange: handleChange }), (description &&
|
|
153
145
|
!inline && { "aria-describedby": descriptionIdentifier }));
|
|
154
|
-
|
|
155
|
-
return (React__default["default"].createElement(FormFieldWrapper,
|
|
146
|
+
const textFieldProps = Object.assign(Object.assign({}, fieldProps), { onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown });
|
|
147
|
+
return (React__default["default"].createElement(FormFieldWrapper, Object.assign({}, props, { value: rest.value, error: error, identifier: identifier, descriptionIdentifier: descriptionIdentifier }), renderField()));
|
|
156
148
|
function renderField() {
|
|
157
149
|
switch (type) {
|
|
158
150
|
case "select":
|
|
159
151
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
160
|
-
React__default["default"].createElement("select",
|
|
152
|
+
React__default["default"].createElement("select", Object.assign({}, fieldProps), children),
|
|
161
153
|
React__default["default"].createElement(FormFieldPostFix, { variation: "select" })));
|
|
162
154
|
case "textarea":
|
|
163
|
-
return (React__default["default"].createElement("textarea",
|
|
155
|
+
return (React__default["default"].createElement("textarea", Object.assign({}, textFieldProps, { rows: rows, ref: inputRef })));
|
|
164
156
|
default:
|
|
165
157
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
166
|
-
React__default["default"].createElement("input",
|
|
158
|
+
React__default["default"].createElement("input", Object.assign({}, textFieldProps, { autoComplete: setAutocomplete(autocomplete), type: type, maxLength: maxLength, max: max, min: min, ref: inputRef })),
|
|
167
159
|
loading && React__default["default"].createElement(FormFieldPostFix, { variation: "spinner" })));
|
|
168
160
|
}
|
|
169
161
|
}
|
|
170
162
|
function handleChange(event) {
|
|
171
|
-
|
|
163
|
+
let newValue;
|
|
172
164
|
newValue = event.currentTarget.value;
|
|
173
165
|
if (type === "number" && newValue.length > 0) {
|
|
174
166
|
newValue = parseFloat(newValue);
|
|
@@ -187,8 +179,8 @@ function FormField(props) {
|
|
|
187
179
|
onEnter && onEnter(event);
|
|
188
180
|
}
|
|
189
181
|
function handleFocus(event) {
|
|
190
|
-
|
|
191
|
-
setTimeout(
|
|
182
|
+
const target = event.currentTarget;
|
|
183
|
+
setTimeout(() => readonly && target.select());
|
|
192
184
|
onFocus && onFocus();
|
|
193
185
|
}
|
|
194
186
|
function handleBlur() {
|
package/dist/FormatDate/index.js
CHANGED
|
@@ -8,9 +8,8 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
8
8
|
|
|
9
9
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
10
|
|
|
11
|
-
function FormatDate(
|
|
12
|
-
|
|
13
|
-
var dateObject;
|
|
11
|
+
function FormatDate({ date: inputDate }) {
|
|
12
|
+
let dateObject;
|
|
14
13
|
if (inputDate instanceof Date) {
|
|
15
14
|
dateObject = inputDate;
|
|
16
15
|
}
|
|
@@ -15,9 +15,8 @@ var css = "._2WQ6E_TFQTKhlZCeQv65zh {\n font-style: normal;\n}\n";
|
|
|
15
15
|
var styles = {"email":"_2WQ6E_TFQTKhlZCeQv65zh"};
|
|
16
16
|
styleInject_es.styleInject(css);
|
|
17
17
|
|
|
18
|
-
function FormatEmail(
|
|
19
|
-
|
|
20
|
-
var className = classnames__default["default"](styles.email);
|
|
18
|
+
function FormatEmail({ email }) {
|
|
19
|
+
const className = classnames__default["default"](styles.email);
|
|
21
20
|
return React__default["default"].createElement("address", { className: className }, email);
|
|
22
21
|
}
|
|
23
22
|
|
package/dist/FormatFile/index.js
CHANGED
|
@@ -2,30 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var FormatFile = require('../FormatFile-
|
|
5
|
+
var FormatFile = require('../FormatFile-3512f838.js');
|
|
6
6
|
require('react');
|
|
7
7
|
require('classnames');
|
|
8
8
|
require('filesize');
|
|
9
9
|
require('../style-inject.es-dcee06b6.js');
|
|
10
|
-
require('../
|
|
11
|
-
require('../Button-cd30df0f.js');
|
|
10
|
+
require('../Button-16e043ec.js');
|
|
12
11
|
require('react-router-dom');
|
|
13
|
-
require('../Icon-
|
|
12
|
+
require('../Icon-405a216c.js');
|
|
14
13
|
require('@jobber/design');
|
|
15
|
-
require('../Typography-
|
|
16
|
-
require('../ConfirmationModal-
|
|
14
|
+
require('../Typography-9262511f.js');
|
|
15
|
+
require('../ConfirmationModal-6a7beee2.js');
|
|
17
16
|
require('@jobber/hooks');
|
|
18
|
-
require('../Modal-
|
|
17
|
+
require('../Modal-757e83fd.js');
|
|
19
18
|
require('react-dom');
|
|
20
19
|
require('framer-motion');
|
|
21
|
-
require('../Heading-
|
|
22
|
-
require('../ButtonDismiss-
|
|
23
|
-
require('../Content-
|
|
24
|
-
require('../Markdown-
|
|
20
|
+
require('../Heading-7b203f7f.js');
|
|
21
|
+
require('../ButtonDismiss-3fb1eaf9.js');
|
|
22
|
+
require('../Content-05df8f7f.js');
|
|
23
|
+
require('../Markdown-be2dcd0c.js');
|
|
25
24
|
require('react-markdown');
|
|
26
|
-
require('../Text-
|
|
27
|
-
require('../Emphasis-
|
|
28
|
-
require('../ProgressBar-
|
|
25
|
+
require('../Text-7ce00adb.js');
|
|
26
|
+
require('../Emphasis-23dc2a0a.js');
|
|
27
|
+
require('../ProgressBar-f028b159.js');
|
|
29
28
|
|
|
30
29
|
|
|
31
30
|
|
|
@@ -4,13 +4,12 @@ var React = require('react');
|
|
|
4
4
|
var classnames = require('classnames');
|
|
5
5
|
var getHumanReadableFileSize = require('filesize');
|
|
6
6
|
var styleInject_es = require('./style-inject.es-dcee06b6.js');
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var ProgressBar = require('./ProgressBar-e9a49129.js');
|
|
7
|
+
var Button = require('./Button-16e043ec.js');
|
|
8
|
+
var ConfirmationModal = require('./ConfirmationModal-6a7beee2.js');
|
|
9
|
+
var Icon = require('./Icon-405a216c.js');
|
|
10
|
+
var Typography = require('./Typography-9262511f.js');
|
|
11
|
+
var Text = require('./Text-7ce00adb.js');
|
|
12
|
+
var ProgressBar = require('./ProgressBar-f028b159.js');
|
|
14
13
|
|
|
15
14
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
15
|
|
|
@@ -22,31 +21,28 @@ var css$1 = ":root {\n --file-card--height: calc(var(--space-base) * 3.5);\n -
|
|
|
22
21
|
var styles$1 = {"expanded":"_9dGq9pkZYNxwlhRwaVaWH","compact":"_24PiUzD_Hoe3p6hD_OxjbH","wrapper":"_26euKXXdGUFmchTL7YqSO7","large":"_2OuJNJWNnBmTTzGAUfSaM7","base":"_2GSQaEqbKQHd7Tf2XqJ5i1","thumbnail":"_1JreUit2_KSn_-iQ3vBhUn","clickable":"_3_8YVeas_gdmexLUKZ3mpR","hoverable":"_15spVvfm0lqLuhAwuIuWrm","progress":"_3Sb6hKDYDXwDcc69ByIdyl","contentBlock":"_2My-AZfFXfluwQURTvc6Z9","deleteButton":"_2pUMiqf0oiCus7WkVuTt57","deleteable":"_2g5hRVudATuiROg0LStgTs"};
|
|
23
22
|
styleInject_es.styleInject(css$1);
|
|
24
23
|
|
|
25
|
-
function FormatFileDeleteButton(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var _b = tslib_es6.__read(React.useState(false), 2), deleteConfirmationOpen = _b[0], setDeleteConfirmationOpen = _b[1];
|
|
24
|
+
function FormatFileDeleteButton({ size, onDelete }) {
|
|
25
|
+
const buttonSize = size === "base" ? "small" : "base";
|
|
26
|
+
const [deleteConfirmationOpen, setDeleteConfirmationOpen] = React.useState(false);
|
|
29
27
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
30
|
-
React__default["default"].createElement(Button.Button, { onClick:
|
|
31
|
-
React__default["default"].createElement(ConfirmationModal.ConfirmationModal, { title: "Confirm Deletion", message:
|
|
28
|
+
React__default["default"].createElement(Button.Button, { onClick: () => setDeleteConfirmationOpen(true), variation: "destructive", type: "tertiary", icon: "trash", ariaLabel: "Delete File", size: buttonSize }),
|
|
29
|
+
React__default["default"].createElement(ConfirmationModal.ConfirmationModal, { title: "Confirm Deletion", message: `Are you sure you want to delete this file?`, confirmLabel: "Delete", variation: "destructive", open: deleteConfirmationOpen, onConfirm: () => onDelete === null || onDelete === void 0 ? void 0 : onDelete(), onRequestClose: () => setDeleteConfirmationOpen(false) })));
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
var css = "._15Z4SPrC7I2WxqMysdwQxX {\n width: 100%;\n height: 100%;\n -o-object-fit: cover;\n object-fit: cover;\n}\n\n.VMZPGfgfpCH2eH5Mv9zgO {\n display: none;\n}\n\n.Z-gb7-3W6CcFd5uSiosLe {\n display: -ms-flexbox;\n display: flex;\n width: inherit;\n height: inherit;\n -ms-flex-align: center;\n align-items: center;\n -ms-flex-pack: center;\n justify-content: center;\n}\n\n.Z-gb7-3W6CcFd5uSiosLe::after {\n content: \"\";\n display: block;\n position: absolute;\n right: 0;\n bottom: 0;\n border: var(--border-base);\n border-radius: var(--radius-base);\n background: linear-gradient(\n 270deg,\n rgb(244, 244, 244) 38.46%,\n rgba(244, 244, 244, 0) 100%\n );\n}\n\n.Z-gb7-3W6CcFd5uSiosLe._3NVQrEqP9hGjbdbpOXGHQd::after {\n width: var(--space-base);\n height: var(--space-base);\n}\n\n.Z-gb7-3W6CcFd5uSiosLe._2AI9R5gNW3y8vFV4ev1tge::after {\n width: var(--space-large);\n height: var(--space-large);\n}\n\n._3VjXRD4ob2Fdq9YxmNRy2S {\n position: absolute;\n}\n\n._3NVQrEqP9hGjbdbpOXGHQd ._3VjXRD4ob2Fdq9YxmNRy2S {\n bottom: var(--space-smaller);\n left: var(--space-smaller);\n font-size: var(--typography--fontSize-smaller);\n}\n\n._2AI9R5gNW3y8vFV4ev1tge ._3VjXRD4ob2Fdq9YxmNRy2S {\n bottom: var(--space-small);\n left: var(--space-small);\n font-size: var(--typography--fontSize-small);\n}\n";
|
|
35
33
|
var styles = {"image":"_15Z4SPrC7I2WxqMysdwQxX","loading":"VMZPGfgfpCH2eH5Mv9zgO","content":"Z-gb7-3W6CcFd5uSiosLe","base":"_3NVQrEqP9hGjbdbpOXGHQd","large":"_2AI9R5gNW3y8vFV4ev1tge","fileName":"_3VjXRD4ob2Fdq9YxmNRy2S"};
|
|
36
34
|
styleInject_es.styleInject(css);
|
|
37
35
|
|
|
38
|
-
function InternalThumbnail(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var _e = tslib_es6.__read(React.useState(false), 2), imageLoaded = _e[0], setImageLoaded = _e[1];
|
|
43
|
-
var iconName = getIconNameFromType(file.type);
|
|
36
|
+
function InternalThumbnail({ name, hideName = false, size, file, }) {
|
|
37
|
+
const [imageSource, setImageSource] = React.useState();
|
|
38
|
+
const [imageLoaded, setImageLoaded] = React.useState(false);
|
|
39
|
+
const iconName = getIconNameFromType(file.type);
|
|
44
40
|
if (!imageSource && file.type.startsWith("image/")) {
|
|
45
|
-
file.src().then(
|
|
41
|
+
file.src().then(src => setImageSource(src));
|
|
46
42
|
}
|
|
47
|
-
|
|
43
|
+
const image = (React__default["default"].createElement("img", { src: imageSource, onLoad: () => {
|
|
48
44
|
setImageLoaded(true);
|
|
49
|
-
}, className: classnames__default["default"](styles.image,
|
|
45
|
+
}, className: classnames__default["default"](styles.image, { [styles.loading]: !imageLoaded }), alt: name, "data-testid": "internalThumbnailImage" }));
|
|
50
46
|
if (imageLoaded) {
|
|
51
47
|
return image;
|
|
52
48
|
}
|
|
@@ -70,22 +66,20 @@ function getIconNameFromType(mimeType) {
|
|
|
70
66
|
}
|
|
71
67
|
}
|
|
72
68
|
|
|
73
|
-
function FormatFile(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
_c));
|
|
88
|
-
var thumbnailContainerClassNames = classnames__default["default"](styles$1.thumbnail, styles$1[displaySize]);
|
|
69
|
+
function FormatFile({ file, display = "expanded", displaySize = "base", onDelete, onClick, }) {
|
|
70
|
+
const isComplete = file.progress >= 1;
|
|
71
|
+
const fileSize = getHumanReadableFileSize__default["default"](file.size);
|
|
72
|
+
const wrapperClassNames = classnames__default["default"](styles$1[display], {
|
|
73
|
+
[styles$1[displaySize]]: display === "compact",
|
|
74
|
+
});
|
|
75
|
+
const DetailsContainer = isComplete && onClick ? "button" : "div";
|
|
76
|
+
const detailsClassNames = classnames__default["default"](styles$1.wrapper, {
|
|
77
|
+
[styles$1[displaySize]]: display === "compact",
|
|
78
|
+
[styles$1.hoverable]: isHoverable({ display, isComplete, onClick, onDelete }),
|
|
79
|
+
[styles$1.clickable]: onClick,
|
|
80
|
+
[styles$1.deleteable]: display === "compact",
|
|
81
|
+
});
|
|
82
|
+
const thumbnailContainerClassNames = classnames__default["default"](styles$1.thumbnail, styles$1[displaySize]);
|
|
89
83
|
return (React__default["default"].createElement("div", { className: wrapperClassNames },
|
|
90
84
|
React__default["default"].createElement(DetailsContainer, { type: "button", className: detailsClassNames, onClick: isComplete ? onClick : undefined, tabIndex: 0, "aria-busy": !isComplete },
|
|
91
85
|
React__default["default"].createElement("div", { className: thumbnailContainerClassNames },
|
|
@@ -98,8 +92,7 @@ function FormatFile(_a) {
|
|
|
98
92
|
isComplete && onDelete && (React__default["default"].createElement("div", { className: styles$1.deleteButton },
|
|
99
93
|
React__default["default"].createElement(FormatFileDeleteButton, { size: display === "expanded" ? "large" : displaySize, onDelete: onDelete })))));
|
|
100
94
|
}
|
|
101
|
-
function isHoverable(
|
|
102
|
-
var display = _a.display, isComplete = _a.isComplete, onClick = _a.onClick, onDelete = _a.onDelete;
|
|
95
|
+
function isHoverable({ display, isComplete, onClick, onDelete, }) {
|
|
103
96
|
if (display === "compact") {
|
|
104
97
|
return Boolean(isComplete && (onClick || onDelete));
|
|
105
98
|
}
|
|
@@ -8,9 +8,8 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
8
8
|
|
|
9
9
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
10
|
|
|
11
|
-
function FormatRelativeDateTime(
|
|
12
|
-
|
|
13
|
-
var dateObject;
|
|
11
|
+
function FormatRelativeDateTime({ date: inputDate, }) {
|
|
12
|
+
let dateObject;
|
|
14
13
|
if (inputDate instanceof Date) {
|
|
15
14
|
dateObject = inputDate;
|
|
16
15
|
}
|
|
@@ -20,9 +19,9 @@ function FormatRelativeDateTime(_a) {
|
|
|
20
19
|
else {
|
|
21
20
|
dateObject = new Date(inputDate.toJSON());
|
|
22
21
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
const now = Date.now() / 1000; //seconds
|
|
23
|
+
const date = dateObject;
|
|
24
|
+
const delta = now - date.getTime() / 1000; //seconds;
|
|
26
25
|
switch (relativeTimeRange(delta)) {
|
|
27
26
|
case "less than an hour":
|
|
28
27
|
return React__default["default"].createElement(React__default["default"].Fragment, null, showMinutes(Math.round(delta / 60)));
|
package/dist/FormatTime/index.js
CHANGED
|
@@ -8,9 +8,8 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
8
8
|
|
|
9
9
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
10
|
|
|
11
|
-
function FormatTime(
|
|
12
|
-
|
|
13
|
-
var dateObject;
|
|
11
|
+
function FormatTime({ time: inputTime, use24HourClock, }) {
|
|
12
|
+
let dateObject;
|
|
14
13
|
if (inputTime instanceof Date) {
|
|
15
14
|
dateObject = inputTime;
|
|
16
15
|
}
|
|
@@ -18,10 +17,10 @@ function FormatTime(_a) {
|
|
|
18
17
|
dateObject = new Date(inputTime);
|
|
19
18
|
}
|
|
20
19
|
else {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const currentDate = new Date();
|
|
21
|
+
const currentYear = currentDate.getFullYear();
|
|
22
|
+
const currentMonth = currentDate.getMonth();
|
|
23
|
+
const currentDay = currentDate.getDay();
|
|
25
24
|
dateObject = new Date(currentYear, currentMonth, currentDay, inputTime.hour, inputTime.minute, inputTime.second, inputTime.millisecond);
|
|
26
25
|
}
|
|
27
26
|
return React__default["default"].createElement(React__default["default"].Fragment, null, formatCivilTime(dateObject, use24HourClock));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IconNames } from "../Icon";
|
|
2
2
|
import { FileUpload } from "../InputFile";
|
|
3
|
-
export
|
|
4
|
-
export
|
|
3
|
+
export type Sizes = "small" | "base" | "large" | "extraLarge";
|
|
4
|
+
export type FileIconsNames = Extract<IconNames, "file" | "excel" | "pdf" | "video" | "word">;
|
|
5
5
|
export interface GalleryProps {
|
|
6
6
|
/**
|
|
7
7
|
* The size of the files and their spacing in the gallery
|