@jobber/components 4.68.1 → 4.68.2-JOB-84730.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/index.js +0 -0
- package/dist/DataList/index.js +0 -0
- package/dist/DataTable/index.js +0 -0
- package/dist/FormField/index.js +0 -0
- package/dist/FormField-f19f45b6.js +254 -0
- package/dist/InputDate/index.js +0 -0
- package/dist/InputEmail/index.js +0 -0
- package/dist/InputNumber/index.js +0 -0
- package/dist/{InputNumber-ef949161.js → InputNumber-dd8ef15e.js} +1 -1
- package/dist/InputPassword/index.js +0 -0
- package/dist/InputPhoneNumber/index.js +0 -0
- package/dist/InputText/index.js +0 -0
- package/dist/{InputText-9e159467.js → InputText-84f50e8c.js} +1 -1
- package/dist/InputTime/index.js +0 -0
- package/dist/{Option-290b5594.js → Option-7017d711.js} +1 -1
- package/dist/RecurringSelect/index.js +0 -0
- package/dist/Select/index.js +0 -0
- package/dist/Table/index.js +2 -2
- package/package.json +3 -3
- package/dist/FormField-181efe29.js +0 -0
|
Binary file
|
package/dist/DataList/index.js
CHANGED
|
Binary file
|
package/dist/DataTable/index.js
CHANGED
|
Binary file
|
package/dist/FormField/index.js
CHANGED
|
Binary file
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib_es6 = require('./tslib.es6-5b8768b7.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var uuid = require('uuid');
|
|
6
|
+
var reactHookForm = require('react-hook-form');
|
|
7
|
+
var styleInject_es = require('./style-inject.es-9d2f5f4e.js');
|
|
8
|
+
var classnames = require('classnames');
|
|
9
|
+
var useShowClear = require('@jobber/hooks/useShowClear');
|
|
10
|
+
var Button = require('./Button-163a0641.js');
|
|
11
|
+
var Icon = require('./Icon-405a216c.js');
|
|
12
|
+
var Text = require('./Text-4a2bc89f.js');
|
|
13
|
+
var InputValidation = require('./InputValidation-179f0926.js');
|
|
14
|
+
var Spinner = require('./Spinner-9d8fc7ff.js');
|
|
15
|
+
|
|
16
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
|
+
|
|
18
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
19
|
+
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
20
|
+
|
|
21
|
+
var css_248z$1 = ":root {\n /**\n * These `--public-field` properties are used in other components such\n * as InputGroup, therefore they must stay on :root\n **/\n --public-field--top-left-radius: var(--radius-base);\n --public-field--top-right-radius: var(--radius-base);\n --public-field--bottom-left-radius: var(--radius-base);\n --public-field--bottom-right-radius: var(--radius-base);\n}\n\n.geR7qBhrMfk- {\n width: 100%;\n}\n\n/**\n * Wrapper\n **/\n\n.nPGhTEEzsoU- {\n --field--placeholder-color: var(--color-greyBlue--light);\n --field--placeholder-offset: 50%;\n --field--placeholder-transform: -50%;\n\n --field--textAlign: left;\n\n --field--height: var(--space-largest);\n\n --field--padding-top: calc(var(--space-base) - var(--space-smallest));\n --field--padding-bottom: calc(var(--space-base) - var(--space-smallest));\n --field--padding-left: var(--space-base);\n --field--padding-right: var(--space-base);\n\n --field--value-color: var(--color-heading);\n --field--value-lineHeight: calc(var(--base-unit) * 1.25);\n\n --field--border-color: var(--color-border);\n --field--background-color: var(--color-surface);\n\n --field--base-elevation: var(--elevation-base);\n --field--label-elevation: calc(var(--field--base-elevation) + 1);\n --field--postfix-elevation: calc(var(--field--base-elevation) - 1);\n --field--postfix-action-elevation: calc(var(--field--base-elevation) + 2);\n\n display: -ms-flexbox;\n\n display: flex;\n width: 100%;\n height: calc(16px * 3);\n height: var(--field--height);\n border: calc(16px / 16) solid rgb(217, 223, 225);\n border: var(--border-base) solid var(--field--border-color);\n border-radius: calc(16px / 8);\n border-radius: var(--radius-base);\n border-top-right-radius: calc(16px / 8);\n border-top-right-radius: var(--public-field--top-right-radius);\n border-bottom-right-radius: calc(16px / 8);\n border-bottom-right-radius: var(--public-field--bottom-right-radius);\n border-bottom-left-radius: calc(16px / 8);\n border-bottom-left-radius: var(--public-field--bottom-left-radius);\n border-top-left-radius: calc(16px / 8);\n border-top-left-radius: var(--public-field--top-left-radius);\n color: rgb(1, 41, 57);\n color: var(--field--value-color);\n font-size: calc((16px * 1) * 0.875);\n font-size: calc(calc(16px * 1) * 0.875);\n font-size: var(--typography--fontSize-base);\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--field--background-color);\n}\n\n.nPGhTEEzsoU- * {\n box-sizing: border-box;\n}\n\n.nPGhTEEzsoU-:focus-within {\n position: relative;\n z-index: var(--field--base-elevation);\n box-shadow: 0px 0px 0px calc(16px / 8) rgba(255, 255, 255, 1),\n 0px 0px 0px calc(16px / 4) rgb(147, 161, 169);\n box-shadow: var(--shadow-focus);\n}\n\n.YhserUiOeFE-:not(:focus-within) input {\n color: var(--field--background-color);\n -webkit-text-fill-color: var(--field--background-color);\n}\n\n.YhserUiOeFE-:focus-within,\n.UIZq8hTmJVU- {\n --field--placeholder-color: var(--color-text--secondary);\n --field--placeholder-offset: var(--space-smallest);\n --field--placeholder-transform: 0;\n --field--padding-top: calc(var(--space-base) + var(--space-smaller));\n --field--padding-bottom: var(--space-small);\n}\n\n.YhserUiOeFE-.Ku8sWS0mLew-:focus-within,\n.UIZq8hTmJVU-.Ku8sWS0mLew- {\n --field--padding-top: calc(var(--space-large) + var(--space-smaller));\n}\n\n.nPGhTEEzsoU-.mgPacJ6Z71Y- {\n --field--placeholder-offset: 0;\n --field--placeholder-transform: 0;\n height: auto;\n min-height: auto;\n}\n\n.gJ-15M615eY-,\n.gJ-15M615eY-:focus-within {\n --field--border-color: var(--color-critical);\n position: relative;\n}\n\n._1rsTLm5GwcM- {\n --field--placeholder-color: var(--color-disabled);\n --field--value-color: var(--color-disabled);\n --field--background-color: var(--color-surface--background);\n --field--border-color: var(--color-disabled--secondary);\n}\n\n/* override iOS default styling for disabled input */\n\n._1rsTLm5GwcM- :disabled {\n -webkit-text-fill-color: var(--field--value-color);\n opacity: 1;\n}\n\n.o8D-H-lKfDk- {\n --field--padding-left: calc(var(--space-base) - var(--space-smaller));\n --field--padding-right: calc(var(--space-base) - var(--space-smaller));\n --field--padding-top: var(--space-small);\n --field--padding-bottom: var(--space-small);\n --field--height: calc(var(--space-larger) + var(--space-smaller));\n}\n\n.Ku8sWS0mLew- {\n --field--padding-left: var(--space-large);\n --field--padding-right: var(--space-large);\n --field--height: calc(var(--space-extravagant));\n}\n\n._5Hu2F3cBvng- {\n display: inline-block;\n width: auto;\n}\n\n.s1WLQs6ffD8- {\n --field--textAlign: center;\n}\n\n.a2r4QheWYIA- {\n --field--textAlign: right;\n}\n\n/**\n * The custom property --formField-maxLength is getting defined inside the\n * component.\n */\n\n.KdAnXK1gClo- {\n width: calc(\n (16px * var(--formField-maxLength)) + var(--field--padding-left) +\n var(--field--padding-right)\n );\n width: calc(\n (var(--base-unit) * var(--formField-maxLength)) + var(--field--padding-left) +\n var(--field--padding-right)\n );\n}\n\n/**\n * Input Wrapper\n **/\n\n.iQFhpFYnz-8- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex: 1;\n flex: 1;\n position: relative;\n /* Ensure input stays with the rest of the element stack */\n z-index: 0;\n z-index: var(--elevation-default);\n}\n\n.Yo2Wi9dpa-Y- {\n position: relative;\n -ms-flex: 1;\n flex: 1;\n}\n\n/**\n * Input\n **/\n\n.LSHPV7PwOTg- {\n position: relative;\n z-index: var(--field--base-elevation);\n width: 100%;\n height: 100%;\n padding-top: var(--field--padding-top);\n padding-bottom: var(--field--padding-bottom);\n padding-left: var(--field--padding-left);\n padding-right: var(--field--padding-right);\n border: none;\n border-radius: 0;\n color: inherit;\n font-family: inherit;\n font-size: inherit;\n line-height: var(--field--value-lineHeight);\n text-align: var(--field--textAlign);\n background: transparent;\n -webkit-appearance: none;\n appearance: none;\n}\n\n.LSHPV7PwOTg-:focus {\n outline: none;\n}\n\n.mgPacJ6Z71Y- .LSHPV7PwOTg- {\n resize: vertical;\n}\n\n.i31GQXcMz54- .LSHPV7PwOTg- {\n z-index: var(--field--label-elevation);\n}\n\n.LSHPV7PwOTg-:-webkit-autofill,\n.LSHPV7PwOTg-:-webkit-autofill:hover,\n.LSHPV7PwOTg-:-webkit-autofill:focus,\n.LSHPV7PwOTg-:-webkit-autofill:active {\n -webkit-box-shadow: 0 0 0 30px rgba(255, 255, 255, 1) inset !important;\n -webkit-box-shadow: 0 0 0 30px var(--color-surface) inset !important;\n}\n\n/**\n * Label\n **/\n\n._3xREbTN5pPg- {\n position: absolute;\n top: var(--field--placeholder-offset);\n z-index: var(--field--label-elevation);\n width: 100%;\n padding-left: var(--field--padding-left);\n padding-right: var(--field--padding-right);\n overflow: hidden;\n color: var(--field--placeholder-color);\n line-height: var(--field--value-lineHeight);\n text-align: var(--field--textAlign);\n text-overflow: ellipsis;\n white-space: nowrap;\n pointer-events: none;\n -webkit-transform: translateY(var(--field--placeholder-transform));\n transform: translateY(var(--field--placeholder-transform));\n transition: all 100ms;\n transition: all var(--timing-quick);\n}\n\n.mgPacJ6Z71Y- ._3xREbTN5pPg- {\n /* Changes the width so that the scrollbar on the textarea doesn't get cut off */\n width: calc(100% - var(--field--padding-right));\n padding-top: var(--field--padding-top);\n /* Remove padding on right to make use of the entire width */\n padding-right: 0;\n -webkit-transform: translateY(--field--placeholder-transform);\n transform: translateY(--field--placeholder-transform);\n}\n\n.UIZq8hTmJVU- ._3xREbTN5pPg-,\n.YhserUiOeFE-:focus-within ._3xREbTN5pPg- {\n font-size: calc((16px * 1) * 0.75);\n font-size: calc(calc(16px * 1) * 0.75);\n font-size: var(--typography--fontSize-small);\n}\n\n.mgPacJ6Z71Y-.UIZq8hTmJVU- ._3xREbTN5pPg- {\n padding-top: calc(16px / 8);\n padding-top: var(--space-smallest);\n background-color: var(--field--background-color);\n}\n\n.o8D-H-lKfDk-.UIZq8hTmJVU- ._3xREbTN5pPg-,\n.YhserUiOeFE-.o8D-H-lKfDk-.UIZq8hTmJVU-:focus-within ._3xREbTN5pPg- {\n display: none;\n}\n\n/**This is valid cascading order **/\n\n/* stylelint-disable-next-line no-descending-specificity */\n\n.Ku8sWS0mLew-.UIZq8hTmJVU- ._3xREbTN5pPg-,\n.YhserUiOeFE-.Ku8sWS0mLew-.UIZq8hTmJVU-:focus-within ._3xREbTN5pPg- {\n padding-top: calc(16px / 2);\n padding-top: var(--space-small);\n}\n\n/**\n * Postfix\n **/\n\n.VtnAk1HYMMk- {\n position: absolute;\n top: 50%;\n right: calc(16px * 1);\n right: var(--space-base);\n z-index: var(--field--postfix-elevation);\n -webkit-transform: translateY(-50%);\n transform: translateY(-50%);\n}\n\n/**\n * Affix\n **/\n\n.uPLklxvtfJw- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-align: center;\n align-items: center;\n -ms-flex-pack: center;\n justify-content: center;\n margin: 0 calc(var(--field--padding-left) * -1) 0 0;\n padding: 0 var(--field--padding-right) 0 var(--field--padding-left);\n}\n\n@supports (aspect-ratio: 1/1) {\n .uPLklxvtfJw- {\n /*\n * disabling property-no-unknown here as this is a real property\n * that stylelint just doesn't know about. We may be able to remove\n * this when we update our stylelint to not care about IE11.\n */\n /* stylelint-disable-next-line property-no-unknown */\n aspect-ratio: 1/1;\n padding: 0;\n }\n}\n\n.uPLklxvtfJw-.pYqqDvv57JE- {\n margin: 0 0 0 calc(var(--field--padding-right) * -1);\n}\n\n.uPLklxvtfJw-.eI44oQpuVlk- {\n position: relative;\n z-index: var(--field--postfix-action-elevation);\n}\n\n.jO8P2iSHilM- {\n display: -ms-flexbox;\n display: flex;\n margin: 0 calc((var(--field--padding-left) - calc(16px / 8)) * -1) 0 0;\n margin: 0 calc((var(--field--padding-left) - var(--space-smallest)) * -1) 0 0;\n padding: 0 0 0 var(--field--padding-left);\n line-height: var(--field--value-lineHeight);\n -ms-flex-align: center;\n align-items: center;\n -ms-flex: 0 0 auto;\n flex: 0 0 auto;\n}\n\n.jO8P2iSHilM-.pYqqDvv57JE- {\n margin: 0 0 0 calc((var(--field--padding-left) - calc(16px / 8)) * -1);\n margin: 0 0 0 calc((var(--field--padding-left) - var(--space-smallest)) * -1);\n padding: 0 var(--field--padding-left) 0 0;\n}\n\n.UIZq8hTmJVU-:not(.o8D-H-lKfDk-) .jO8P2iSHilM- {\n padding-top: var(--field--padding-top);\n padding-bottom: var(--field--padding-bottom);\n}\n\n._2GfgzNnLOSI- {\n margin-top: calc(16px / 4);\n margin-top: var(--space-smaller);\n}\n";
|
|
22
|
+
var styles$1 = {"container":"geR7qBhrMfk-","wrapper":"nPGhTEEzsoU-","timeInputLabel":"YhserUiOeFE-","miniLabel":"UIZq8hTmJVU-","large":"Ku8sWS0mLew-","textarea":"mgPacJ6Z71Y-","invalid":"gJ-15M615eY-","disabled":"_1rsTLm5GwcM-","small":"o8D-H-lKfDk-","inline":"_5Hu2F3cBvng-","center":"s1WLQs6ffD8-","right":"a2r4QheWYIA-","maxLength":"KdAnXK1gClo-","inputWrapper":"iQFhpFYnz-8-","childrenWrapper":"Yo2Wi9dpa-Y-","input":"LSHPV7PwOTg-","select":"i31GQXcMz54-","label":"_3xREbTN5pPg-","postfix":"VtnAk1HYMMk-","affixIcon":"uPLklxvtfJw-","suffix":"pYqqDvv57JE-","hasAction":"eI44oQpuVlk-","affixLabel":"jO8P2iSHilM-","description":"_2GfgzNnLOSI-"};
|
|
23
|
+
styleInject_es.styleInject(css_248z$1);
|
|
24
|
+
|
|
25
|
+
function AffixLabel({ label, variation = "prefix", labelRef, }) {
|
|
26
|
+
const affixLabelClass = classnames__default["default"](styles$1.affixLabel, {
|
|
27
|
+
[styles$1.suffix]: variation === "suffix",
|
|
28
|
+
});
|
|
29
|
+
return (React__default["default"].createElement("div", { ref: labelRef, className: affixLabelClass }, label));
|
|
30
|
+
}
|
|
31
|
+
function AffixIcon({ icon, onClick, ariaLabel, variation = "prefix", size, }) {
|
|
32
|
+
const affixIconClass = classnames__default["default"](styles$1.affixIcon, {
|
|
33
|
+
[styles$1.suffix]: variation === "suffix",
|
|
34
|
+
[styles$1.hasAction]: onClick,
|
|
35
|
+
});
|
|
36
|
+
const iconSize = size === "small" ? "small" : "base";
|
|
37
|
+
if (!icon)
|
|
38
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
39
|
+
return (React__default["default"].createElement("div", { className: affixIconClass }, onClick ? (React__default["default"].createElement(Button.Button
|
|
40
|
+
/**
|
|
41
|
+
* We can cast the ariaLabel here as a `Suffix`
|
|
42
|
+
* requires an ariaLabel if there is an action
|
|
43
|
+
*/
|
|
44
|
+
, {
|
|
45
|
+
/**
|
|
46
|
+
* We can cast the ariaLabel here as a `Suffix`
|
|
47
|
+
* requires an ariaLabel if there is an action
|
|
48
|
+
*/
|
|
49
|
+
ariaLabel: ariaLabel, icon: icon, onClick: onClick, variation: "subtle", type: "tertiary", size: iconSize })) : (React__default["default"].createElement(Icon.Icon, { name: icon, size: iconSize, color: "greyBlue" }))));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function FormFieldDescription({ id, description, }) {
|
|
53
|
+
return (React__default["default"].createElement("div", { id: id, className: styles$1.description },
|
|
54
|
+
React__default["default"].createElement(Text.Text, { size: "small", variation: "subdued" }, description)));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var css_248z = "._07kZJ5ltI5E- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-align: center;\n align-items: center;\n padding-left: calc(16px / 2);\n padding-left: var(--space-small);\n}\n\n.t1fFX8kDJh8- {\n display: -ms-flexbox;\n display: flex;\n position: relative;\n right: calc(16px * 1);\n right: var(--space-base);\n z-index: 1002;\n z-index: var(--elevation-tooltip);\n width: calc(16px * 1.5);\n width: var(--space-large);\n height: calc(16px * 1.5);\n height: var(--space-large);\n padding: 0;\n border: none;\n border-radius: 100%;\n border-radius: var(--radius-circle);\n background-color: rgb(238, 240, 242);\n background-color: var(--color-surface--background);\n cursor: pointer;\n -ms-flex-pack: center;\n justify-content: center;\n -ms-flex-align: center;\n align-items: center;\n}\n\n.t1fFX8kDJh8-:focus {\n outline: none;\n}\n\n.t1fFX8kDJh8-:hover,\n.t1fFX8kDJh8-:focus-visible {\n outline: none;\n background-color: rgb(238, 240, 242);\n background-color: var(--color-surface--background);\n}\n\n.t1fFX8kDJh8-:focus-visible {\n box-shadow: 0px 0px 0px calc(16px / 8) rgba(255, 255, 255, 1),\n 0px 0px 0px calc(16px / 4) rgb(147, 161, 169);\n box-shadow: var(--shadow-focus);\n}\n";
|
|
58
|
+
var styles = {"clearContainer":"_07kZJ5ltI5E-","clearInput":"t1fFX8kDJh8-"};
|
|
59
|
+
styleInject_es.styleInject(css_248z);
|
|
60
|
+
|
|
61
|
+
function ClearAction({ onClick }) {
|
|
62
|
+
return (React__default["default"].createElement("div", { className: styles.clearContainer },
|
|
63
|
+
React__default["default"].createElement("button", { className: styles.clearInput, onClick: onClick, type: "button", "aria-label": "Clear input" },
|
|
64
|
+
React__default["default"].createElement(Icon.Icon, { name: "remove", size: "small" }))));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function FormFieldWrapper({ align, description, descriptionIdentifier, placeholder, value, children, invalid, error, size, prefix, suffix, max, maxLength, type, disabled, inline, identifier, clearable, onClear, }) {
|
|
68
|
+
const wrapperClasses = classnames__default["default"](styles$1.wrapper, size && styles$1[size], align && styles$1[align], {
|
|
69
|
+
[styles$1.miniLabel]: (placeholder && value !== "") ||
|
|
70
|
+
(placeholder && type === "select") ||
|
|
71
|
+
// Naively assume that if the the type is tel, it is the InputPhoneNumber
|
|
72
|
+
(placeholder && type === "tel"),
|
|
73
|
+
[styles$1.textarea]: type === "textarea",
|
|
74
|
+
[styles$1.select]: type === "select",
|
|
75
|
+
[styles$1.invalid]: invalid !== null && invalid !== void 0 ? invalid : error,
|
|
76
|
+
[styles$1.disabled]: disabled,
|
|
77
|
+
[styles$1.maxLength]: maxLength,
|
|
78
|
+
[styles$1.timeInputLabel]: placeholder && type === "time" && placeholder && value === "",
|
|
79
|
+
});
|
|
80
|
+
const containerClasses = classnames__default["default"](styles$1.container, {
|
|
81
|
+
[styles$1.inline]: inline,
|
|
82
|
+
});
|
|
83
|
+
const wrapperInlineStyle = {
|
|
84
|
+
["--formField-maxLength"]: maxLength || max,
|
|
85
|
+
};
|
|
86
|
+
const prefixRef = React.useRef();
|
|
87
|
+
const suffixRef = React.useRef();
|
|
88
|
+
const [labelStyle, setLabelStyle] = React.useState({
|
|
89
|
+
paddingLeft: undefined,
|
|
90
|
+
paddingRight: undefined,
|
|
91
|
+
});
|
|
92
|
+
React.useEffect(() => {
|
|
93
|
+
setLabelStyle(getAffixPaddding);
|
|
94
|
+
}, [value]);
|
|
95
|
+
const [focused, setFocused] = React.useState(false);
|
|
96
|
+
const showClear = useShowClear.useShowClear({
|
|
97
|
+
clearable,
|
|
98
|
+
multiline: type === "textarea",
|
|
99
|
+
focused,
|
|
100
|
+
hasValue: Boolean(value),
|
|
101
|
+
disabled,
|
|
102
|
+
});
|
|
103
|
+
return (React__default["default"].createElement("div", { className: containerClasses, onFocus: () => setFocused(true), onBlur: () => setFocused(false) },
|
|
104
|
+
React__default["default"].createElement("div", { className: wrapperClasses, style: wrapperInlineStyle, "data-testid": "Form-Field-Wrapper" },
|
|
105
|
+
(prefix === null || prefix === void 0 ? void 0 : prefix.icon) && React__default["default"].createElement(AffixIcon, Object.assign({}, prefix, { size: size })),
|
|
106
|
+
React__default["default"].createElement("div", { className: styles$1.inputWrapper },
|
|
107
|
+
placeholder && (React__default["default"].createElement("label", { className: styles$1.label, htmlFor: identifier, style: (prefixRef === null || prefixRef === void 0 ? void 0 : prefixRef.current) || (suffixRef === null || suffixRef === void 0 ? void 0 : suffixRef.current)
|
|
108
|
+
? labelStyle
|
|
109
|
+
: undefined }, placeholder)),
|
|
110
|
+
(prefix === null || prefix === void 0 ? void 0 : prefix.label) && React__default["default"].createElement(AffixLabel, Object.assign({}, prefix, { labelRef: prefixRef })),
|
|
111
|
+
React__default["default"].createElement("div", { className: styles$1.childrenWrapper }, children)),
|
|
112
|
+
(suffix === null || suffix === void 0 ? void 0 : suffix.label) && (React__default["default"].createElement(AffixLabel, Object.assign({}, suffix, { labelRef: suffixRef, variation: "suffix" }))),
|
|
113
|
+
showClear && React__default["default"].createElement(ClearAction, { onClick: onClear }),
|
|
114
|
+
(suffix === null || suffix === void 0 ? void 0 : suffix.icon) && (React__default["default"].createElement(AffixIcon, Object.assign({}, suffix, { variation: "suffix", size: size })))),
|
|
115
|
+
description && !inline && (React__default["default"].createElement(FormFieldDescription, { id: descriptionIdentifier, description: description })),
|
|
116
|
+
error && !inline && React__default["default"].createElement(InputValidation.InputValidation, { message: error })));
|
|
117
|
+
function getAffixPaddding() {
|
|
118
|
+
const hasValue = value !== "";
|
|
119
|
+
const newPadding = {
|
|
120
|
+
paddingLeft: undefined,
|
|
121
|
+
paddingRight: undefined,
|
|
122
|
+
};
|
|
123
|
+
// Naively assume that if the the type is tel, it is the InputPhoneNumber
|
|
124
|
+
if (type === "tel")
|
|
125
|
+
return newPadding;
|
|
126
|
+
if ((prefixRef === null || prefixRef === void 0 ? void 0 : prefixRef.current) && !hasValue) {
|
|
127
|
+
const { offsetWidth } = prefixRef.current;
|
|
128
|
+
newPadding.paddingLeft = offset(offsetWidth);
|
|
129
|
+
}
|
|
130
|
+
if ((suffixRef === null || suffixRef === void 0 ? void 0 : suffixRef.current) && !hasValue) {
|
|
131
|
+
const { offsetWidth } = suffixRef.current;
|
|
132
|
+
newPadding.paddingRight = offset(offsetWidth);
|
|
133
|
+
}
|
|
134
|
+
function offset(width) {
|
|
135
|
+
return `calc(${width}px + var(--space-smallest)`;
|
|
136
|
+
}
|
|
137
|
+
return newPadding;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function FormFieldPostFix({ variation }) {
|
|
142
|
+
return (React__default["default"].createElement("span", { className: styles$1.postfix }, variation === "select" ? (React__default["default"].createElement(Icon.Icon, { name: "arrowDown" })) : (React__default["default"].createElement(Spinner.Spinner, { size: "small" }))));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Added 13th statement to accommodate getErrorMessage function
|
|
146
|
+
/*eslint max-statements: ["error", 13]*/
|
|
147
|
+
function FormField(props) {
|
|
148
|
+
var _a, _b;
|
|
149
|
+
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, clearable = "never", } = props;
|
|
150
|
+
const { control, formState: { errors }, setValue, watch, } = reactHookForm.useFormContext() != undefined
|
|
151
|
+
? reactHookForm.useFormContext()
|
|
152
|
+
: // If there isn't a Form Context being provided, get a form for this field.
|
|
153
|
+
reactHookForm.useForm({ mode: "onTouched" });
|
|
154
|
+
const [identifier] = React.useState(uuid.v1());
|
|
155
|
+
const [descriptionIdentifier] = React.useState(`descriptionUUID--${uuid.v1()}`);
|
|
156
|
+
/**
|
|
157
|
+
* Generate a name if one is not supplied, this is the name
|
|
158
|
+
* that will be used for react-hook-form and not neccessarily
|
|
159
|
+
* attached to the DOM
|
|
160
|
+
*/
|
|
161
|
+
const [controlledName] = React.useState(name ? name : `generatedName--${identifier}`);
|
|
162
|
+
React.useEffect(() => {
|
|
163
|
+
if (value != undefined) {
|
|
164
|
+
setValue(controlledName, value);
|
|
165
|
+
}
|
|
166
|
+
}, [value, watch(controlledName)]);
|
|
167
|
+
React.useImperativeHandle(actionsRef, () => ({
|
|
168
|
+
setValue: newValue => {
|
|
169
|
+
setValue(controlledName, newValue, { shouldValidate: true });
|
|
170
|
+
},
|
|
171
|
+
}));
|
|
172
|
+
const message = (_a = errors[controlledName]) === null || _a === void 0 ? void 0 : _a.message;
|
|
173
|
+
const error = getErrorMessage();
|
|
174
|
+
React.useEffect(() => handleValidation(), [error]);
|
|
175
|
+
return (React__default["default"].createElement(reactHookForm.Controller, { control: control, name: controlledName, rules: Object.assign({}, validations), defaultValue: (_b = value !== null && value !== void 0 ? value : defaultValue) !== null && _b !== void 0 ? _b : "", render: (_a) => {
|
|
176
|
+
var _b = _a.field, { onChange: onControllerChange, onBlur: onControllerBlur, name: controllerName } = _b, rest = tslib_es6.__rest(_b, ["onChange", "onBlur", "name"]);
|
|
177
|
+
const fieldProps = Object.assign(Object.assign(Object.assign({}, rest), { id: identifier, className: styles$1.input, name: (validations || name) && controllerName, disabled: disabled, readOnly: readonly, inputMode: keyboard, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus }), (description &&
|
|
178
|
+
!inline && { "aria-describedby": descriptionIdentifier }));
|
|
179
|
+
const textFieldProps = Object.assign(Object.assign({}, fieldProps), { onKeyDown: handleKeyDown });
|
|
180
|
+
return (React__default["default"].createElement(FormFieldWrapper, Object.assign({}, props, { value: rest.value, error: error, identifier: identifier, descriptionIdentifier: descriptionIdentifier, clearable: clearable, onClear: handleClear }), renderField()));
|
|
181
|
+
function renderField() {
|
|
182
|
+
switch (type) {
|
|
183
|
+
case "select":
|
|
184
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
185
|
+
React__default["default"].createElement("select", Object.assign({}, fieldProps), children),
|
|
186
|
+
React__default["default"].createElement(FormFieldPostFix, { variation: "select" })));
|
|
187
|
+
case "textarea":
|
|
188
|
+
return (React__default["default"].createElement("textarea", Object.assign({}, textFieldProps, { rows: rows, ref: inputRef })));
|
|
189
|
+
default:
|
|
190
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
191
|
+
React__default["default"].createElement("input", Object.assign({}, textFieldProps, { autoComplete: setAutocomplete(autocomplete), type: type, maxLength: maxLength, max: max, min: min, ref: inputRef })),
|
|
192
|
+
loading && React__default["default"].createElement(FormFieldPostFix, { variation: "spinner" }),
|
|
193
|
+
children));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function handleClear() {
|
|
197
|
+
var _a;
|
|
198
|
+
handleBlur();
|
|
199
|
+
setValue(controlledName, undefined, { shouldValidate: true });
|
|
200
|
+
onChange && onChange("");
|
|
201
|
+
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
202
|
+
}
|
|
203
|
+
function handleChange(event) {
|
|
204
|
+
let newValue;
|
|
205
|
+
newValue = event.currentTarget.value;
|
|
206
|
+
if (type === "number" && newValue.length > 0) {
|
|
207
|
+
newValue = parseFloat(newValue);
|
|
208
|
+
}
|
|
209
|
+
onChange && onChange(newValue, event);
|
|
210
|
+
onControllerChange(event);
|
|
211
|
+
}
|
|
212
|
+
function handleKeyDown(event) {
|
|
213
|
+
if (!onEnter)
|
|
214
|
+
return;
|
|
215
|
+
if (event.key !== "Enter")
|
|
216
|
+
return;
|
|
217
|
+
if (event.shiftKey || event.ctrlKey)
|
|
218
|
+
return;
|
|
219
|
+
event.preventDefault();
|
|
220
|
+
onEnter && onEnter(event);
|
|
221
|
+
}
|
|
222
|
+
function handleFocus(event) {
|
|
223
|
+
const target = event.currentTarget;
|
|
224
|
+
if (target.select) {
|
|
225
|
+
setTimeout(() => readonly && target.select());
|
|
226
|
+
}
|
|
227
|
+
onFocus && onFocus();
|
|
228
|
+
}
|
|
229
|
+
function handleBlur() {
|
|
230
|
+
onBlur && onBlur();
|
|
231
|
+
onControllerBlur();
|
|
232
|
+
}
|
|
233
|
+
} }));
|
|
234
|
+
function getErrorMessage() {
|
|
235
|
+
if (typeof message === "string") {
|
|
236
|
+
return message;
|
|
237
|
+
}
|
|
238
|
+
return "";
|
|
239
|
+
}
|
|
240
|
+
function handleValidation() {
|
|
241
|
+
onValidation && onValidation(error);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
function setAutocomplete(autocompleteSetting) {
|
|
245
|
+
if (autocompleteSetting === true) {
|
|
246
|
+
return undefined;
|
|
247
|
+
}
|
|
248
|
+
else if (autocompleteSetting === false) {
|
|
249
|
+
return "off";
|
|
250
|
+
}
|
|
251
|
+
return autocompleteSetting;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
exports.FormField = FormField;
|
package/dist/InputDate/index.js
CHANGED
|
Binary file
|
package/dist/InputEmail/index.js
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -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-f19f45b6.js');
|
|
5
5
|
|
|
6
6
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
7
7
|
|
|
Binary file
|
|
Binary file
|
package/dist/InputText/index.js
CHANGED
|
Binary file
|
|
@@ -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-f19f45b6.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
|
Binary file
|
|
@@ -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-f19f45b6.js');
|
|
5
5
|
|
|
6
6
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
7
7
|
|
|
Binary file
|
package/dist/Select/index.js
CHANGED
|
Binary file
|
package/dist/Table/index.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var styleInject_es = require('../style-inject.es-9d2f5f4e.js');
|
|
7
7
|
var classnames = require('classnames');
|
|
8
|
-
var
|
|
8
|
+
var formatters = require('@jobber/formatters');
|
|
9
9
|
|
|
10
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
11
|
|
|
@@ -39,7 +39,7 @@ function CellNumeric({ value }) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
function CellCurrency({ value, currency = undefined, }) {
|
|
42
|
-
return React__default["default"].createElement(CellNumeric, { value:
|
|
42
|
+
return React__default["default"].createElement(CellNumeric, { value: formatters.formatCurrency(value, currency) });
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
function Header({ children }) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "4.68.1",
|
|
3
|
+
"version": "4.68.2-JOB-84730.1+7de657bc",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@jobber/design": "^0.51.0",
|
|
23
|
-
"@jobber/formatters": "
|
|
23
|
+
"@jobber/formatters": "^0.2.2",
|
|
24
24
|
"@jobber/hooks": "^2.8.0",
|
|
25
25
|
"@popperjs/core": "^2.0.6",
|
|
26
26
|
"@std-proposal/temporal": "0.0.1",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"> 1%",
|
|
84
84
|
"IE 10"
|
|
85
85
|
],
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "7de657bc3fd18016fab74a15bdec5262514cc846"
|
|
87
87
|
}
|
|
Binary file
|