@jobber/components 4.85.4-CJS-to-ESM.1 → 4.85.4
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/.eslintrc.js +10 -0
- package/dist/AnimatedPresence/index.js +12 -0
- package/dist/AnimatedPresence-20a02aaa.js +104 -0
- package/dist/AnimatedSwitcher/index.js +13 -0
- package/dist/AnimatedSwitcher-3d45ec5d.js +96 -0
- package/dist/Autocomplete/index.js +209 -0
- package/dist/Avatar/index.js +15 -0
- package/dist/Avatar-76a799fa.js +78 -0
- package/dist/Banner/index.js +110 -0
- package/dist/Button/index.js +16 -0
- package/dist/Button-b73a5e01.js +57 -0
- package/dist/ButtonDismiss/index.js +17 -0
- package/dist/ButtonDismiss-350af163.js +14 -0
- package/dist/Card/colors.css.d.ts +89 -0
- package/dist/Card/index.js +24 -0
- package/dist/Card-e3144022.js +93 -0
- package/dist/Checkbox/index.js +18 -0
- package/dist/Checkbox-787e2e47.js +63 -0
- package/dist/Chip/index.js +41 -0
- package/dist/Chip-3d1bfddc.js +89 -0
- package/dist/Chips/index.js +524 -0
- package/dist/Combobox/index.js +40 -0
- package/dist/Combobox-a24c8241.js +479 -0
- package/dist/ConfirmationModal/index.js +31 -0
- package/dist/ConfirmationModal-52e16873.js +100 -0
- package/dist/Content/Spacing.css.d.ts +13 -0
- package/dist/Content/index.js +12 -0
- package/dist/Content-e3f7b6fc.js +24 -0
- package/dist/Countdown/index.js +72 -0
- package/dist/DataDump/index.js +37 -0
- package/dist/DataList/index.js +1335 -0
- package/dist/DataTable/index.js +301 -0
- package/dist/DatePicker/index.js +20 -0
- package/dist/DatePicker-64c5ab1a.js +134 -0
- package/dist/DescriptionList/index.js +24 -0
- package/dist/Disclosure/index.js +46 -0
- package/dist/Divider/index.js +29 -0
- package/dist/Drawer/index.js +49 -0
- package/dist/Emphasis/index.js +13 -0
- package/dist/Emphasis-bda56d3b.js +19 -0
- package/dist/FeatureSwitch/index.js +70 -0
- package/dist/Flex/index.js +12 -0
- package/dist/Flex-d490c4db.js +38 -0
- package/dist/Form/index.js +56 -0
- package/dist/FormField/index.js +24 -0
- package/dist/FormField-6ff183f8.js +253 -0
- package/dist/FormatDate/index.js +11 -0
- package/dist/FormatDate-70ea5b43.js +34 -0
- package/dist/FormatEmail/index.js +23 -0
- package/dist/FormatFile/index.js +36 -0
- package/dist/FormatFile-f036902d.js +162 -0
- package/dist/FormatRelativeDateTime/index.js +72 -0
- package/dist/FormatTime/index.js +36 -0
- package/dist/Gallery/Gallery.css.d.ts +9 -0
- package/dist/Gallery/index.js +99 -0
- package/dist/Glimmer/index.js +15 -0
- package/dist/Glimmer/style/Shape.css.d.ts +9 -0
- package/dist/Glimmer/style/Sizes.css.d.ts +10 -0
- package/dist/Glimmer/style/Timing.css.d.ts +6 -0
- package/dist/Glimmer-84dee1ed.js +77 -0
- package/dist/Grid/GridAlign.css.d.ts +8 -0
- package/dist/Grid/index.js +76 -0
- package/dist/Heading/index.js +14 -0
- package/dist/Heading-1e8e4bd3.js +55 -0
- package/dist/Icon/index.js +11 -0
- package/dist/Icon-405a216c.js +40 -0
- package/dist/InlineLabel/index.js +13 -0
- package/dist/InlineLabel-a6557829.js +28 -0
- package/dist/InputAvatar/index.js +70 -0
- package/dist/InputDate/index.js +57 -0
- package/dist/InputEmail/index.js +43 -0
- package/dist/InputFile/index.js +25 -0
- package/dist/InputFile-bb945071.js +190 -0
- package/dist/InputGroup/index.js +12 -0
- package/dist/InputGroup-8d4fd4eb.js +33 -0
- package/dist/InputNumber/index.js +25 -0
- package/dist/InputNumber-d451b52e.js +62 -0
- package/dist/InputPassword/index.js +41 -0
- package/dist/InputPhoneNumber/index.js +116 -0
- package/dist/InputText/index.js +26 -0
- package/dist/InputText-55b6cb65.js +102 -0
- package/dist/InputTime/index.js +209 -0
- package/dist/InputValidation/index.js +17 -0
- package/dist/InputValidation-05e839fa.js +29 -0
- package/dist/LightBox/index.js +24 -0
- package/dist/LightBox-a89d8863.js +117 -0
- package/dist/Link/index.js +15 -0
- package/dist/List/index.js +93 -0
- package/dist/Markdown/index.js +19 -0
- package/dist/Markdown-f7c55304.js +62 -0
- package/dist/Menu/index.js +21 -0
- package/dist/Menu-083fc4c4.js +139 -0
- package/dist/Modal/Sizes.css.d.ts +6 -0
- package/dist/Modal/index.js +25 -0
- package/dist/Modal-c336cac6.js +71 -0
- package/dist/MultiSelect/index.js +182 -0
- package/dist/Option-3c4d377e.js +19 -0
- package/dist/Page/index.js +78 -0
- package/dist/Popover/index.js +61 -0
- package/dist/ProgressBar/Sizes.css.d.ts +7 -0
- package/dist/ProgressBar/index.js +12 -0
- package/dist/ProgressBar-b68edc8f.js +43 -0
- package/dist/RadioGroup/index.js +15 -0
- package/dist/RadioGroup-17b67ade.js +46 -0
- package/dist/RecurringSelect/index.js +227 -0
- package/dist/Select/index.js +26 -0
- package/dist/Spinner/index.js +12 -0
- package/dist/Spinner-9d8fc7ff.js +24 -0
- package/dist/StatusIndicator/index.js +11 -0
- package/dist/StatusIndicator-b179d06e.js +18 -0
- package/dist/StatusLabel/index.js +29 -0
- package/dist/Switch/index.js +13 -0
- package/dist/Switch-7d4aa7c3.js +56 -0
- package/dist/Table/index.js +66 -0
- package/dist/Tabs/index.js +80 -0
- package/dist/Text/index.js +13 -0
- package/dist/Text-259af966.js +31 -0
- package/dist/Toast/index.js +111 -0
- package/dist/Tooltip/index.js +16 -0
- package/dist/Tooltip-ef3d6ef4.js +112 -0
- package/dist/Typography/css/Emphasis.css.d.ts +6 -0
- package/dist/Typography/css/FontFamilies.css.d.ts +6 -0
- package/dist/Typography/css/FontSizes.css.d.ts +12 -0
- package/dist/Typography/css/FontWeights.css.d.ts +10 -0
- package/dist/Typography/css/TextAlignment.css.d.ts +7 -0
- package/dist/Typography/css/TextCases.css.d.ts +7 -0
- package/dist/Typography/css/TextColors.css.d.ts +22 -0
- package/dist/Typography/css/Truncate.css.d.ts +5 -0
- package/dist/Typography/css/Typography.css.d.ts +5 -0
- package/dist/Typography/index.js +12 -0
- package/dist/Typography-c45bf216.js +62 -0
- package/dist/getAtlantisConfig-0f3e8af2.js +13 -0
- package/dist/style-inject.es-9d2f5f4e.js +30 -0
- package/dist/tslib.es6-754e2961.js +46 -0
- package/package.json +4 -371
- package/rollup.config.js +77 -21
- package/dist/index.cjs +0 -6721
- package/dist/index.d.ts +0 -73
- package/dist/index.esm.js +0 -6603
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var InputGroup = require('../InputGroup-8d4fd4eb.js');
|
|
6
|
+
require('react');
|
|
7
|
+
require('classnames');
|
|
8
|
+
require('../style-inject.es-9d2f5f4e.js');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.InputGroup = InputGroup.InputGroup;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var classnames = require('classnames');
|
|
5
|
+
var styleInject_es = require('./style-inject.es-9d2f5f4e.js');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
|
+
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
11
|
+
|
|
12
|
+
var css_248z = "._4bvHwa3-qBA- > *:not(:last-child) {\n margin-bottom: -1px !important;\n}\n\n.bHm4WuX8ToY- {\n display: -ms-flexbox;\n display: flex;\n}\n\n.bHm4WuX8ToY- > *:not(:last-child) {\n margin-bottom: auto;\n margin-right: -1px;\n}\n\n/* Border corners are rounded on the outside edges of the group */\n\n.nmDPgrXofeE- {\n --public-field--top-left-radius: 0;\n --public-field--top-right-radius: 0;\n --public-field--bottom-left-radius: 0;\n --public-field--bottom-right-radius: 0;\n}\n\n._4bvHwa3-qBA- > :first-child:not(.bHm4WuX8ToY-) {\n --public-field--top-left-radius: var(--radius-base);\n --public-field--top-right-radius: var(--radius-base);\n}\n\n._4bvHwa3-qBA- > :last-child:not(.bHm4WuX8ToY-) {\n --public-field--bottom-left-radius: var(--radius-base);\n --public-field--bottom-right-radius: var(--radius-base);\n}\n\n/* First Horizontal Input Group */\n\n.bHm4WuX8ToY-:first-child > :first-child {\n --public-field--top-left-radius: var(--radius-base);\n}\n\n.bHm4WuX8ToY-:first-child > :last-child {\n --public-field--top-right-radius: var(--radius-base);\n}\n\n/* Last Horizontal Input Group */\n\n.bHm4WuX8ToY-:last-child > :first-child {\n --public-field--bottom-left-radius: var(--radius-base);\n}\n\n.bHm4WuX8ToY-:last-child > :last-child {\n --public-field--bottom-right-radius: var(--radius-base);\n}\n";
|
|
13
|
+
var styles = {"vertical":"_4bvHwa3-qBA-","horizontal":"bHm4WuX8ToY-","inputGroup":"nmDPgrXofeE-"};
|
|
14
|
+
styleInject_es.styleInject(css_248z);
|
|
15
|
+
|
|
16
|
+
function InputGroup({ children, flowDirection = "vertical", }) {
|
|
17
|
+
if (isInvalidGroupNesting(children))
|
|
18
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
19
|
+
const className = classnames__default["default"](styles.inputGroup, styles[flowDirection]);
|
|
20
|
+
return React__default["default"].createElement("div", { className: className }, children);
|
|
21
|
+
}
|
|
22
|
+
function isInvalidGroupNesting(childs) {
|
|
23
|
+
return React__default["default"].Children.toArray(childs).some(child => {
|
|
24
|
+
if (child.type === InputGroup &&
|
|
25
|
+
child.props.flowDirection != "horizontal") {
|
|
26
|
+
console.error(`ERROR: InputGroup not rendered: nesting 'flowDirection="vertical"' columns not supported.`, `https://atlantis.getjobber.com/?path=/story/components-forms-and-inputs-inputgroup-web--nested`);
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.InputGroup = InputGroup;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var InputNumber = require('../InputNumber-d451b52e.js');
|
|
6
|
+
require('react');
|
|
7
|
+
require('../FormField-6ff183f8.js');
|
|
8
|
+
require('../tslib.es6-754e2961.js');
|
|
9
|
+
require('react-hook-form');
|
|
10
|
+
require('../style-inject.es-9d2f5f4e.js');
|
|
11
|
+
require('classnames');
|
|
12
|
+
require('@jobber/hooks/useShowClear');
|
|
13
|
+
require('../Button-b73a5e01.js');
|
|
14
|
+
require('react-router-dom');
|
|
15
|
+
require('../Icon-405a216c.js');
|
|
16
|
+
require('@jobber/design');
|
|
17
|
+
require('../Typography-c45bf216.js');
|
|
18
|
+
require('../Text-259af966.js');
|
|
19
|
+
require('../InputValidation-05e839fa.js');
|
|
20
|
+
require('framer-motion');
|
|
21
|
+
require('../Spinner-9d8fc7ff.js');
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
exports.InputNumber = InputNumber.InputNumber;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var FormField = require('./FormField-6ff183f8.js');
|
|
5
|
+
|
|
6
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
7
|
+
|
|
8
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
9
|
+
|
|
10
|
+
function InputNumberInternal(props, ref) {
|
|
11
|
+
var _a;
|
|
12
|
+
const inputRef = React.createRef();
|
|
13
|
+
React.useImperativeHandle(ref, () => ({
|
|
14
|
+
blur: () => {
|
|
15
|
+
const input = inputRef.current;
|
|
16
|
+
if (input) {
|
|
17
|
+
input.blur();
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
focus: () => {
|
|
21
|
+
const input = inputRef.current;
|
|
22
|
+
if (input) {
|
|
23
|
+
input.focus();
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
}));
|
|
27
|
+
return (React__default["default"].createElement(FormField.FormField, Object.assign({}, props, { type: "number", inputRef: inputRef, onChange: handleChange, validations: Object.assign(Object.assign({}, props.validations), { validate: customValidators((_a = props.validations) === null || _a === void 0 ? void 0 : _a.validate) }) })));
|
|
28
|
+
function customValidators(validators) {
|
|
29
|
+
if (validators == null) {
|
|
30
|
+
return getOverLimitMessage;
|
|
31
|
+
}
|
|
32
|
+
else if (typeof validators === "function") {
|
|
33
|
+
return {
|
|
34
|
+
customValidation: validators,
|
|
35
|
+
getOverLimitMessage,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return Object.assign(Object.assign({}, validators), { getOverLimitMessage });
|
|
39
|
+
}
|
|
40
|
+
function handleChange(newValue) {
|
|
41
|
+
props.onChange && props.onChange(newValue);
|
|
42
|
+
}
|
|
43
|
+
function getOverLimitMessage(value) {
|
|
44
|
+
const isOverMax = props.max != undefined && value && value > props.max;
|
|
45
|
+
const isUnderMin = props.min != undefined && value && value < props.min;
|
|
46
|
+
if (isOverMax || isUnderMin || (value && value.toString() === "")) {
|
|
47
|
+
if (props.min != undefined && props.max === undefined) {
|
|
48
|
+
return `Enter a number that is greater than or equal to ${props.min}`;
|
|
49
|
+
}
|
|
50
|
+
else if (props.max != undefined && props.min === undefined) {
|
|
51
|
+
return `Enter a number that is less than or equal to ${props.max}`;
|
|
52
|
+
}
|
|
53
|
+
else if (props.min != undefined && props.max != undefined) {
|
|
54
|
+
return `Enter a number between ${props.min} and ${props.max}`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const InputNumber = React.forwardRef(InputNumberInternal);
|
|
61
|
+
|
|
62
|
+
exports.InputNumber = InputNumber;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var FormField = require('../FormField-6ff183f8.js');
|
|
7
|
+
require('../tslib.es6-754e2961.js');
|
|
8
|
+
require('react-hook-form');
|
|
9
|
+
require('../style-inject.es-9d2f5f4e.js');
|
|
10
|
+
require('classnames');
|
|
11
|
+
require('@jobber/hooks/useShowClear');
|
|
12
|
+
require('../Button-b73a5e01.js');
|
|
13
|
+
require('react-router-dom');
|
|
14
|
+
require('../Icon-405a216c.js');
|
|
15
|
+
require('@jobber/design');
|
|
16
|
+
require('../Typography-c45bf216.js');
|
|
17
|
+
require('../Text-259af966.js');
|
|
18
|
+
require('../InputValidation-05e839fa.js');
|
|
19
|
+
require('framer-motion');
|
|
20
|
+
require('../Spinner-9d8fc7ff.js');
|
|
21
|
+
|
|
22
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
|
+
|
|
24
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
25
|
+
|
|
26
|
+
function InputPassword(props) {
|
|
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
|
+
suffix: {
|
|
31
|
+
ariaLabel: visible ? "Hide password" : "Show password",
|
|
32
|
+
icon: visible ? "eye" : "eyeCrossed",
|
|
33
|
+
onClick: () => setVisibility(!visible),
|
|
34
|
+
},
|
|
35
|
+
}), { type: visible ? "text" : "password", onChange: handleChange })));
|
|
36
|
+
function handleChange(newValue) {
|
|
37
|
+
props.onChange && props.onChange(newValue);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
exports.InputPassword = InputPassword;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib_es6 = require('../tslib.es6-754e2961.js');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var reactHookForm = require('react-hook-form');
|
|
8
|
+
var styleInject_es = require('../style-inject.es-9d2f5f4e.js');
|
|
9
|
+
var FormField = require('../FormField-6ff183f8.js');
|
|
10
|
+
require('classnames');
|
|
11
|
+
require('@jobber/hooks/useShowClear');
|
|
12
|
+
require('../Button-b73a5e01.js');
|
|
13
|
+
require('react-router-dom');
|
|
14
|
+
require('../Icon-405a216c.js');
|
|
15
|
+
require('@jobber/design');
|
|
16
|
+
require('../Typography-c45bf216.js');
|
|
17
|
+
require('../Text-259af966.js');
|
|
18
|
+
require('../InputValidation-05e839fa.js');
|
|
19
|
+
require('framer-motion');
|
|
20
|
+
require('../Spinner-9d8fc7ff.js');
|
|
21
|
+
|
|
22
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
|
+
|
|
24
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
25
|
+
|
|
26
|
+
var css_248z = ".L7WK-i5uaOk- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-align: center;\n align-items: center;\n position: absolute;\n top: 0;\n right: 0;\n left: 0;\n z-index: 1;\n z-index: var(--elevation-base);\n height: var(--field--height);\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 color: rgb(181, 181, 181);\n color: var(--color-grey);\n font-family: inherit;\n font-size: inherit;\n line-height: var(--field--value-lineHeight);\n pointer-events: none;\n}\n\n.q1wXBupm5Xc- {\n visibility: hidden;\n opacity: 0;\n}\n";
|
|
27
|
+
var styles = {"mask":"L7WK-i5uaOk-","hiddenValue":"q1wXBupm5Xc-"};
|
|
28
|
+
styleInject_es.styleInject(css_248z);
|
|
29
|
+
|
|
30
|
+
function InputMask({ children, delimiter = "*", pattern, strict = true, }) {
|
|
31
|
+
const { value: inputValue, onChange } = children.props;
|
|
32
|
+
const [isMasking, setIsMasking] = React.useState(!inputValue);
|
|
33
|
+
const stringifiedValue = String(inputValue || "");
|
|
34
|
+
const placeholderValue = pattern
|
|
35
|
+
.replace(new RegExp(`\\${delimiter}`, "g"), "_")
|
|
36
|
+
.slice(stringifiedValue.length);
|
|
37
|
+
const inputMask = (React__default["default"].createElement("div", { className: styles.mask, "aria-hidden": "true" },
|
|
38
|
+
React__default["default"].createElement("span", { className: styles.hiddenValue }, stringifiedValue),
|
|
39
|
+
placeholderValue));
|
|
40
|
+
return React.cloneElement(children, {
|
|
41
|
+
onChange: handleChange,
|
|
42
|
+
children: isMasking && inputMask,
|
|
43
|
+
});
|
|
44
|
+
function handleChange(value) {
|
|
45
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(formatValue(value));
|
|
46
|
+
}
|
|
47
|
+
function formatValue(value) {
|
|
48
|
+
const { cleanValueChars, patternChars, specialChars, isOverCharLimit } = getMaskingInfo(value);
|
|
49
|
+
if (!strict && isOverCharLimit) {
|
|
50
|
+
setIsMasking(false);
|
|
51
|
+
return cleanValueChars.join("");
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
setIsMasking(true);
|
|
55
|
+
return patternChars.reduce(getMaskedValue(cleanValueChars, specialChars), "");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function getMaskingInfo(value) {
|
|
59
|
+
const patternChars = pattern.split("");
|
|
60
|
+
const specialChars = patternChars.filter(char => char !== delimiter);
|
|
61
|
+
const cleanValueChars = value
|
|
62
|
+
.split("")
|
|
63
|
+
.filter(char => !specialChars.includes(char))
|
|
64
|
+
// Since this is only used in InputPhoneNumber, we can restrict it to
|
|
65
|
+
// just numbers for now.
|
|
66
|
+
.map(Number)
|
|
67
|
+
.filter(num => !isNaN(num));
|
|
68
|
+
const isOverCharLimit = cleanValueChars.length > patternChars.length - specialChars.length;
|
|
69
|
+
return { cleanValueChars, patternChars, specialChars, isOverCharLimit };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function getMaskedValue(cleanVal, specialChars) {
|
|
73
|
+
return (result, nextCharacter) => {
|
|
74
|
+
if (!cleanVal.length)
|
|
75
|
+
return result;
|
|
76
|
+
if (specialChars.includes(nextCharacter))
|
|
77
|
+
return result + nextCharacter;
|
|
78
|
+
const nextValue = cleanVal.shift();
|
|
79
|
+
return result + nextValue;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function InputPhoneNumber(_a) {
|
|
84
|
+
var { required } = _a, props = tslib_es6.__rest(_a, ["required"]);
|
|
85
|
+
const { placeholder, validations, pattern = "(***) ***-****" } = props;
|
|
86
|
+
const errorSubject = placeholder || "Phone number";
|
|
87
|
+
const { getValues } = reactHookForm.useFormContext() != undefined
|
|
88
|
+
? reactHookForm.useFormContext()
|
|
89
|
+
: // If there isn't a Form Context being provided, get a form for this field.
|
|
90
|
+
reactHookForm.useForm({ mode: "onTouched" });
|
|
91
|
+
return (React__default["default"].createElement(InputMask, { pattern: pattern, strict: false },
|
|
92
|
+
React__default["default"].createElement(FormField.FormField, Object.assign({}, props, { type: "tel", validations: Object.assign(Object.assign({ required: {
|
|
93
|
+
value: Boolean(required),
|
|
94
|
+
message: `${errorSubject} is required`,
|
|
95
|
+
} }, validations), { validate: getPhoneNumberValidation }) }))));
|
|
96
|
+
function getPhoneNumberValidation(value) {
|
|
97
|
+
// Get unique characters that aren't * in the pattern
|
|
98
|
+
const patternNonDelimterCharacters = pattern
|
|
99
|
+
.split("")
|
|
100
|
+
.filter(char => char !== "*")
|
|
101
|
+
.filter((char, index, arr) => arr.indexOf(char) === index);
|
|
102
|
+
const specialCharacters = patternNonDelimterCharacters.join(" ");
|
|
103
|
+
// Remove special characters from pattern
|
|
104
|
+
const cleanValue = value.replace(new RegExp(`[${specialCharacters}]`, "g"), "");
|
|
105
|
+
const cleanValueRequiredLength = (pattern.match(/\*/g) || []).length;
|
|
106
|
+
if (cleanValue.length > 0 && cleanValue.length < cleanValueRequiredLength) {
|
|
107
|
+
return `${errorSubject} must contain ${cleanValueRequiredLength} or more digits`;
|
|
108
|
+
}
|
|
109
|
+
if (typeof (validations === null || validations === void 0 ? void 0 : validations.validate) === "function") {
|
|
110
|
+
return validations.validate(value, getValues);
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
exports.InputPhoneNumber = InputPhoneNumber;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var InputText = require('../InputText-55b6cb65.js');
|
|
6
|
+
require('react');
|
|
7
|
+
require('@jobber/hooks/useSafeLayoutEffect');
|
|
8
|
+
require('../FormField-6ff183f8.js');
|
|
9
|
+
require('../tslib.es6-754e2961.js');
|
|
10
|
+
require('react-hook-form');
|
|
11
|
+
require('../style-inject.es-9d2f5f4e.js');
|
|
12
|
+
require('classnames');
|
|
13
|
+
require('@jobber/hooks/useShowClear');
|
|
14
|
+
require('../Button-b73a5e01.js');
|
|
15
|
+
require('react-router-dom');
|
|
16
|
+
require('../Icon-405a216c.js');
|
|
17
|
+
require('@jobber/design');
|
|
18
|
+
require('../Typography-c45bf216.js');
|
|
19
|
+
require('../Text-259af966.js');
|
|
20
|
+
require('../InputValidation-05e839fa.js');
|
|
21
|
+
require('framer-motion');
|
|
22
|
+
require('../Spinner-9d8fc7ff.js');
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
exports.InputText = InputText.InputText;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var useSafeLayoutEffect = require('@jobber/hooks/useSafeLayoutEffect');
|
|
5
|
+
var FormField = require('./FormField-6ff183f8.js');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
|
+
|
|
11
|
+
function InputTextInternal(props, ref) {
|
|
12
|
+
const inputRef = React.useRef(null);
|
|
13
|
+
const actionsRef = React.useRef(null);
|
|
14
|
+
const rowRange = getRowRange();
|
|
15
|
+
React.useImperativeHandle(ref, () => ({
|
|
16
|
+
insert: (text) => {
|
|
17
|
+
insertText(text);
|
|
18
|
+
},
|
|
19
|
+
blur: () => {
|
|
20
|
+
const input = inputRef.current;
|
|
21
|
+
if (input) {
|
|
22
|
+
input.blur();
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
focus: () => {
|
|
26
|
+
const input = inputRef.current;
|
|
27
|
+
if (input) {
|
|
28
|
+
input.focus();
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
scrollIntoView: arg => {
|
|
32
|
+
const input = inputRef.current;
|
|
33
|
+
if (input) {
|
|
34
|
+
input.scrollIntoView(arg);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
}));
|
|
38
|
+
useSafeLayoutEffect.useSafeLayoutEffect(() => {
|
|
39
|
+
if (inputRef && inputRef.current instanceof HTMLTextAreaElement) {
|
|
40
|
+
resize(inputRef.current);
|
|
41
|
+
}
|
|
42
|
+
}, [inputRef.current]);
|
|
43
|
+
return (React__default["default"].createElement(FormField.FormField, Object.assign({}, props, { type: props.multiline ? "textarea" : "text", inputRef: inputRef, actionsRef: actionsRef, onChange: handleChange, rows: rowRange.min })));
|
|
44
|
+
function handleChange(newValue) {
|
|
45
|
+
props.onChange && props.onChange(newValue);
|
|
46
|
+
if (inputRef && inputRef.current instanceof HTMLTextAreaElement) {
|
|
47
|
+
resize(inputRef.current);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function getRowRange() {
|
|
51
|
+
if (props.rows === undefined) {
|
|
52
|
+
return { min: 3, max: 3 };
|
|
53
|
+
}
|
|
54
|
+
else if (typeof props.rows === "object") {
|
|
55
|
+
return { min: props.rows.min, max: props.rows.max };
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return { min: props.rows, max: props.rows };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function resize(textArea) {
|
|
62
|
+
if (rowRange.min === rowRange.max)
|
|
63
|
+
return;
|
|
64
|
+
textArea.style.height = "auto";
|
|
65
|
+
textArea.style.height = textAreaHeight(textArea) + "px";
|
|
66
|
+
}
|
|
67
|
+
function textAreaHeight(textArea) {
|
|
68
|
+
const { lineHeight, borderBottomWidth, borderTopWidth, paddingBottom, paddingTop, } = window.getComputedStyle(textArea);
|
|
69
|
+
const maxHeight = rowRange.max * parseFloat(lineHeight) +
|
|
70
|
+
parseFloat(borderTopWidth) +
|
|
71
|
+
parseFloat(borderBottomWidth) +
|
|
72
|
+
parseFloat(paddingTop) +
|
|
73
|
+
parseFloat(paddingBottom);
|
|
74
|
+
const scrollHeight = textArea.scrollHeight +
|
|
75
|
+
parseFloat(borderTopWidth) +
|
|
76
|
+
parseFloat(borderBottomWidth);
|
|
77
|
+
return Math.min(scrollHeight, maxHeight);
|
|
78
|
+
}
|
|
79
|
+
function insertText(text) {
|
|
80
|
+
var _a;
|
|
81
|
+
const input = inputRef.current;
|
|
82
|
+
if (input) {
|
|
83
|
+
insertAtCursor(input, text);
|
|
84
|
+
const newValue = input.value;
|
|
85
|
+
(_a = actionsRef.current) === null || _a === void 0 ? void 0 : _a.setValue(newValue);
|
|
86
|
+
props.onChange && props.onChange(newValue);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const InputText = React.forwardRef(InputTextInternal);
|
|
91
|
+
function insertAtCursor(input, newText) {
|
|
92
|
+
const start = input.selectionStart || 0;
|
|
93
|
+
const end = input.selectionEnd || 0;
|
|
94
|
+
const text = input.value;
|
|
95
|
+
const before = text.substring(0, start);
|
|
96
|
+
const after = text.substring(end, text.length);
|
|
97
|
+
input.value = before + newText + after;
|
|
98
|
+
input.selectionStart = input.selectionEnd = start + newText.length;
|
|
99
|
+
input.focus();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
exports.InputText = InputText;
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib_es6 = require('../tslib.es6-754e2961.js');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var temporal = require('@std-proposal/temporal');
|
|
8
|
+
var debounce = require('lodash/debounce');
|
|
9
|
+
var FormField = require('../FormField-6ff183f8.js');
|
|
10
|
+
require('react-hook-form');
|
|
11
|
+
require('../style-inject.es-9d2f5f4e.js');
|
|
12
|
+
require('classnames');
|
|
13
|
+
require('@jobber/hooks/useShowClear');
|
|
14
|
+
require('../Button-b73a5e01.js');
|
|
15
|
+
require('react-router-dom');
|
|
16
|
+
require('../Icon-405a216c.js');
|
|
17
|
+
require('@jobber/design');
|
|
18
|
+
require('../Typography-c45bf216.js');
|
|
19
|
+
require('../Text-259af966.js');
|
|
20
|
+
require('../InputValidation-05e839fa.js');
|
|
21
|
+
require('framer-motion');
|
|
22
|
+
require('../Spinner-9d8fc7ff.js');
|
|
23
|
+
|
|
24
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
25
|
+
|
|
26
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
27
|
+
var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
|
|
28
|
+
|
|
29
|
+
function civilTimeToHTMLTime(civilTime) {
|
|
30
|
+
if (civilTime == undefined) {
|
|
31
|
+
return "";
|
|
32
|
+
}
|
|
33
|
+
const timeString = civilTime.toString();
|
|
34
|
+
return timeString.slice(0, 5);
|
|
35
|
+
}
|
|
36
|
+
function htmlTimeToCivilTime(timeString) {
|
|
37
|
+
try {
|
|
38
|
+
return temporal.CivilTime.fromString(timeString + ":00.000000000");
|
|
39
|
+
}
|
|
40
|
+
catch (_a) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const DEBOUNCE_TIME = 300;
|
|
46
|
+
function useTimePredict({ value, handleChange }) {
|
|
47
|
+
const IS_12_HOUR_FORMAT = React.useRef(Intl.DateTimeFormat(navigator.language, {
|
|
48
|
+
hour: "numeric",
|
|
49
|
+
}).resolvedOptions().hour12);
|
|
50
|
+
const [typedTime, setTypedTime] = React.useState("");
|
|
51
|
+
const predictTime = React.useCallback(debounce__default["default"](() => {
|
|
52
|
+
if (value)
|
|
53
|
+
return;
|
|
54
|
+
handleChange(predictHours(typedTime, IS_12_HOUR_FORMAT.current));
|
|
55
|
+
}, DEBOUNCE_TIME), [typedTime, value, handleChange]);
|
|
56
|
+
/**
|
|
57
|
+
* Predict the hour when user types a number
|
|
58
|
+
*/
|
|
59
|
+
React.useEffect(() => {
|
|
60
|
+
/**
|
|
61
|
+
* Don't try to predict if the user types 0 as the user would almost always
|
|
62
|
+
* type another number after 0.
|
|
63
|
+
*/
|
|
64
|
+
if (typedTime && typedTime !== "0") {
|
|
65
|
+
predictTime();
|
|
66
|
+
if ((IS_12_HOUR_FORMAT && typedTime !== "1") || typedTime.length === 2) {
|
|
67
|
+
// Immediately predict the hour
|
|
68
|
+
predictTime.flush();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return predictTime.cancel;
|
|
72
|
+
}, [typedTime]);
|
|
73
|
+
/**
|
|
74
|
+
* Reset typed time when the value changed
|
|
75
|
+
*/
|
|
76
|
+
React.useEffect(() => {
|
|
77
|
+
setTypedTime("");
|
|
78
|
+
}, [value]);
|
|
79
|
+
return {
|
|
80
|
+
setTypedTime,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function predictHours(time, is12HourFormat = false) {
|
|
84
|
+
const today = new Date();
|
|
85
|
+
const currentHour = today.getHours();
|
|
86
|
+
const parsedTime = parseInt(time, 10);
|
|
87
|
+
let predictedTime;
|
|
88
|
+
if (is12HourFormat) {
|
|
89
|
+
predictedTime = predict12Hours(parsedTime, currentHour);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
predictedTime = predict24Hours(time, parsedTime, currentHour);
|
|
93
|
+
}
|
|
94
|
+
return formatHour(predictedTime);
|
|
95
|
+
}
|
|
96
|
+
function predict12Hours(parsedTime, currentHour) {
|
|
97
|
+
/**
|
|
98
|
+
* We need to predict what the user wants when they type 1 since it could be
|
|
99
|
+
* 10, 11, 12, or 1.
|
|
100
|
+
*
|
|
101
|
+
* If the current hour is over 12PM, we can skip this and go to the next logic.
|
|
102
|
+
*/
|
|
103
|
+
if (parsedTime === 1 && currentHour < 12) {
|
|
104
|
+
if (currentHour < 10) {
|
|
105
|
+
return 10;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
return currentHour + 1;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Typing 1-5 predicts that the user want that exact hour on the afternoon.
|
|
113
|
+
*/
|
|
114
|
+
if (parsedTime <= 5) {
|
|
115
|
+
return parsedTime + 12;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Typing 13-15 predicts that the user want the 2nd number as the minute interval.
|
|
119
|
+
*/
|
|
120
|
+
if (parsedTime > 12 && parsedTime <= 15) {
|
|
121
|
+
const timeArray = parsedTime.toString().split("").map(Number); // 13 -> [1, 3]
|
|
122
|
+
const convertToHoursAndMinutes = timeArray.map((time, i) => {
|
|
123
|
+
if (i === 0)
|
|
124
|
+
return time + 12; // 1 -> 13 as 1PM
|
|
125
|
+
if (i === 1)
|
|
126
|
+
return time * 10; // 3 -> 30 as 30 minutes
|
|
127
|
+
});
|
|
128
|
+
return Number(convertToHoursAndMinutes.join("")); // [13, 30] -> 1330
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Anything after 5 will be predicted to be set as AM.
|
|
132
|
+
*/
|
|
133
|
+
return parsedTime;
|
|
134
|
+
}
|
|
135
|
+
function predict24Hours(time, parsedTime, currentHour) {
|
|
136
|
+
/**
|
|
137
|
+
* Typing 1 could be predicted from 10 to 19.
|
|
138
|
+
* Typing 01 skips this logic and sets the time to 01:00.
|
|
139
|
+
*/
|
|
140
|
+
if (parsedTime === 1 && time !== "01") {
|
|
141
|
+
if (currentHour < 10 || currentHour > 19) {
|
|
142
|
+
return 10;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
return currentHour + 1;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Typing 2 could be predicted from 20 to 24.
|
|
150
|
+
* Typing 02 skips this logic and sets the time to 02:00.
|
|
151
|
+
*/
|
|
152
|
+
if (parsedTime === 2 && time !== "02") {
|
|
153
|
+
if (currentHour < 20) {
|
|
154
|
+
return 20;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
return currentHour + 1;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Typing 24 or 00 is set to midnight. This ensures the time doesn't get set
|
|
162
|
+
* to 24 as that would be invalid.
|
|
163
|
+
*/
|
|
164
|
+
if (parsedTime === 24 || time === "00") {
|
|
165
|
+
return 0;
|
|
166
|
+
}
|
|
167
|
+
return parsedTime;
|
|
168
|
+
}
|
|
169
|
+
function formatHour(time) {
|
|
170
|
+
if (time > 99) {
|
|
171
|
+
const splitTime = time.toString().split("");
|
|
172
|
+
if (splitTime.length === 3)
|
|
173
|
+
splitTime.unshift("0"); // 130 -> 0130
|
|
174
|
+
splitTime.splice(2, 0, ":"); // 0130 -> 01:30
|
|
175
|
+
return splitTime.join("");
|
|
176
|
+
}
|
|
177
|
+
if (time < 10) {
|
|
178
|
+
return `0${time}:00`;
|
|
179
|
+
}
|
|
180
|
+
return `${time}:00`;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function InputTime(_a) {
|
|
184
|
+
var { defaultValue, value, onChange } = _a, params = tslib_es6.__rest(_a, ["defaultValue", "value", "onChange"]);
|
|
185
|
+
const ref = React.useRef(null);
|
|
186
|
+
const { setTypedTime } = useTimePredict({ value, handleChange });
|
|
187
|
+
const fieldProps = Object.assign(Object.assign(Object.assign({ onChange: handleChange }, (defaultValue && { defaultValue: civilTimeToHTMLTime(defaultValue) })), (!defaultValue && { value: civilTimeToHTMLTime(value) })), params);
|
|
188
|
+
return (React__default["default"].createElement(FormField.FormField, Object.assign({ inputRef: ref, type: "time" }, fieldProps, { onBlur: handleBlur, onKeyUp: e => {
|
|
189
|
+
var _a;
|
|
190
|
+
(_a = fieldProps.onKeyUp) === null || _a === void 0 ? void 0 : _a.call(fieldProps, e);
|
|
191
|
+
!isNaN(parseInt(e.key, 10)) && setTypedTime(prev => prev + e.key);
|
|
192
|
+
} })));
|
|
193
|
+
function handleChange(newValue) {
|
|
194
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(htmlTimeToCivilTime(newValue));
|
|
195
|
+
}
|
|
196
|
+
function handleBlur() {
|
|
197
|
+
var _a;
|
|
198
|
+
(_a = params.onBlur) === null || _a === void 0 ? void 0 : _a.call(params);
|
|
199
|
+
// Time inputs doesn't clear the typed value when it's invalid. This should
|
|
200
|
+
// force it to reset the input value when the typed value is invalid.
|
|
201
|
+
if (ref.current) {
|
|
202
|
+
if (!ref.current.checkValidity()) {
|
|
203
|
+
ref.current.value = "";
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
exports.InputTime = InputTime;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var InputValidation = require('../InputValidation-05e839fa.js');
|
|
6
|
+
require('react');
|
|
7
|
+
require('framer-motion');
|
|
8
|
+
require('../style-inject.es-9d2f5f4e.js');
|
|
9
|
+
require('../Text-259af966.js');
|
|
10
|
+
require('../Typography-c45bf216.js');
|
|
11
|
+
require('classnames');
|
|
12
|
+
require('../Icon-405a216c.js');
|
|
13
|
+
require('@jobber/design');
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
exports.InputValidation = InputValidation.InputValidation;
|