@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
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var AnimatedPresence = require('../AnimatedPresence-20a02aaa.js');
|
|
6
|
+
require('react');
|
|
7
|
+
require('framer-motion');
|
|
8
|
+
require('@jobber/design');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.AnimatedPresence = AnimatedPresence.AnimatedPresence;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var framerMotion = require('framer-motion');
|
|
5
|
+
var design = require('@jobber/design');
|
|
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
|
+
const TIMING_QUICK = toSeconds(design.tokens["timing-quick"]);
|
|
12
|
+
const TIMING_BASE = toSeconds(design.tokens["timing-base"]);
|
|
13
|
+
const baseTransition = {
|
|
14
|
+
visible: { opacity: 1 },
|
|
15
|
+
hidden: { opacity: 0 },
|
|
16
|
+
};
|
|
17
|
+
const fade = {
|
|
18
|
+
visible: { opacity: 1 },
|
|
19
|
+
hidden: { opacity: 0 },
|
|
20
|
+
};
|
|
21
|
+
const popIn = {
|
|
22
|
+
visible: Object.assign({ scale: 1 }, baseTransition.visible),
|
|
23
|
+
hidden: Object.assign({ scale: 0.95 }, baseTransition.hidden),
|
|
24
|
+
};
|
|
25
|
+
const fromTop = {
|
|
26
|
+
visible: Object.assign({ y: 0 }, baseTransition.visible),
|
|
27
|
+
hidden: Object.assign({ y: -design.tokens["space-base"] }, baseTransition.hidden),
|
|
28
|
+
};
|
|
29
|
+
const fromBottom = {
|
|
30
|
+
visible: Object.assign({ y: 0 }, baseTransition.visible),
|
|
31
|
+
hidden: Object.assign({ y: design.tokens["space-base"] }, baseTransition.hidden),
|
|
32
|
+
};
|
|
33
|
+
const fromLeft = {
|
|
34
|
+
visible: Object.assign({ x: 0 }, baseTransition.visible),
|
|
35
|
+
hidden: Object.assign({ x: -design.tokens["space-base"] }, baseTransition.hidden),
|
|
36
|
+
};
|
|
37
|
+
const fromRight = {
|
|
38
|
+
visible: Object.assign({ x: 0 }, baseTransition.visible),
|
|
39
|
+
hidden: Object.assign({ x: design.tokens["space-base"] }, baseTransition.hidden),
|
|
40
|
+
};
|
|
41
|
+
const fromLeftToRight = {
|
|
42
|
+
initial: Object.assign({ x: -design.tokens["space-base"] }, baseTransition.hidden),
|
|
43
|
+
visible: Object.assign({ x: 0 }, baseTransition.visible),
|
|
44
|
+
hidden: Object.assign({ x: design.tokens["space-base"] }, baseTransition.hidden),
|
|
45
|
+
};
|
|
46
|
+
const fromRightToLeft = {
|
|
47
|
+
initial: Object.assign({ x: design.tokens["space-base"] }, baseTransition.hidden),
|
|
48
|
+
visible: Object.assign({ x: 0 }, baseTransition.visible),
|
|
49
|
+
hidden: Object.assign({ x: -design.tokens["space-base"] }, baseTransition.hidden),
|
|
50
|
+
};
|
|
51
|
+
function toSeconds(ms) {
|
|
52
|
+
return ms / 1000;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function usePreviousValue(value) {
|
|
56
|
+
const [previousValue, setPreviousValue] = React.useState(value);
|
|
57
|
+
React.useEffect(() => {
|
|
58
|
+
setPreviousValue(value);
|
|
59
|
+
}, [value]);
|
|
60
|
+
return [previousValue, setPreviousValue];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const transitions = {
|
|
64
|
+
fromBottom,
|
|
65
|
+
fromTop,
|
|
66
|
+
fromLeft,
|
|
67
|
+
fromRight,
|
|
68
|
+
popIn,
|
|
69
|
+
fromLeftToRight,
|
|
70
|
+
fromRightToLeft,
|
|
71
|
+
fade,
|
|
72
|
+
};
|
|
73
|
+
function AnimatedPresence(props) {
|
|
74
|
+
const shouldReduceMotion = framerMotion.useReducedMotion();
|
|
75
|
+
if (shouldReduceMotion) {
|
|
76
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null, props.children);
|
|
77
|
+
}
|
|
78
|
+
return React__default["default"].createElement(InternalAnimatedPresence, Object.assign({}, props));
|
|
79
|
+
}
|
|
80
|
+
function InternalAnimatedPresence({ transition = "fromTop", initial = false, children, }) {
|
|
81
|
+
const transitionVariation = transitions[transition];
|
|
82
|
+
const hasInitialTransition = "initial" in transitionVariation;
|
|
83
|
+
const childCount = React.Children.count(children);
|
|
84
|
+
// Set the initial value to 0 so it staggers the animation on mount when
|
|
85
|
+
// initial is true.
|
|
86
|
+
const [lastChildIndex, setLastChildIndex] = usePreviousValue(0);
|
|
87
|
+
// Whenever the children count changes, update the last index.
|
|
88
|
+
React.useEffect(() => {
|
|
89
|
+
setLastChildIndex(childCount - 1);
|
|
90
|
+
}, [childCount]);
|
|
91
|
+
return (React__default["default"].createElement(framerMotion.AnimatePresence, { initial: initial, mode: "popLayout" }, React.Children.map(children, (child, i) => child && (React__default["default"].createElement(framerMotion.motion.div, { layout: true, variants: transitionVariation, initial: hasInitialTransition ? "initial" : "hidden", animate: "visible", exit: "hidden", transition: {
|
|
92
|
+
duration: TIMING_BASE,
|
|
93
|
+
delay: generateDelayTime(i),
|
|
94
|
+
} }, child)))));
|
|
95
|
+
function generateDelayTime(index) {
|
|
96
|
+
// Don't add a delay if it's already rendered.
|
|
97
|
+
if (lastChildIndex > index)
|
|
98
|
+
return 0;
|
|
99
|
+
// Stagger the animation starting after the previous last child index.
|
|
100
|
+
return (index - lastChildIndex) * TIMING_QUICK;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
exports.AnimatedPresence = AnimatedPresence;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var AnimatedSwitcher = require('../AnimatedSwitcher-3d45ec5d.js');
|
|
6
|
+
require('react');
|
|
7
|
+
require('framer-motion');
|
|
8
|
+
require('../Icon-405a216c.js');
|
|
9
|
+
require('@jobber/design');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
exports.AnimatedSwitcher = AnimatedSwitcher.AnimatedSwitcher;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var framerMotion = require('framer-motion');
|
|
5
|
+
var Icon = require('./Icon-405a216c.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
|
+
const DURATION_SIMPLE = 0.1;
|
|
12
|
+
const DURATION_AVERAGE = 0.2;
|
|
13
|
+
const FADE = {
|
|
14
|
+
visible: { opacity: 1 },
|
|
15
|
+
hidden: { opacity: 0 },
|
|
16
|
+
};
|
|
17
|
+
const SLIDE_IN_UP = {
|
|
18
|
+
visible: { y: 0, opacity: 1 },
|
|
19
|
+
hidden: { y: "10%", opacity: 0 },
|
|
20
|
+
};
|
|
21
|
+
const SLIDE_IN_DOWN = {
|
|
22
|
+
visible: { y: 0, opacity: 1 },
|
|
23
|
+
hidden: { y: "-10%", opacity: 0 },
|
|
24
|
+
};
|
|
25
|
+
const SPIN_COUNTER_CLOCK_WISE = {
|
|
26
|
+
visible: {
|
|
27
|
+
rotate: 0,
|
|
28
|
+
scale: 1,
|
|
29
|
+
transition: { duration: DURATION_AVERAGE, ease: "easeOut" },
|
|
30
|
+
},
|
|
31
|
+
hidden: {
|
|
32
|
+
rotate: 180,
|
|
33
|
+
scale: 0.6,
|
|
34
|
+
transition: { duration: DURATION_AVERAGE, ease: "easeIn" },
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
const SPIN_CLOCK_WISE = {
|
|
38
|
+
visible: {
|
|
39
|
+
rotate: 0,
|
|
40
|
+
scale: 1,
|
|
41
|
+
transition: { duration: DURATION_AVERAGE, ease: "easeOut" },
|
|
42
|
+
},
|
|
43
|
+
hidden: {
|
|
44
|
+
rotate: -180,
|
|
45
|
+
scale: 0.6,
|
|
46
|
+
transition: { duration: DURATION_AVERAGE, ease: "easeIn" },
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
function AnimatedSwitcher({ initialChild, switched, switchTo, type = "slideFromBottom", }) {
|
|
51
|
+
const [ref, setRef] = React.useState(null);
|
|
52
|
+
const isSwitchingBetweenIcons = initialChild.type === Icon.Icon && switchTo.type === Icon.Icon;
|
|
53
|
+
const { key, transition, child, duration } = getChildData();
|
|
54
|
+
return (React__default["default"].createElement(framerMotion.AnimatePresence, { mode: "wait", initial: false },
|
|
55
|
+
React__default["default"].createElement(framerMotion.motion.div, { ref: setRef, key: key, variants: transition, initial: "hidden", animate: "visible", exit: "hidden", transition: { duration }, style: { display: getDisplayValue() } }, child)));
|
|
56
|
+
function getDisplayValue() {
|
|
57
|
+
if (ref === null || ref === void 0 ? void 0 : ref.firstElementChild) {
|
|
58
|
+
return window.getComputedStyle(ref.firstElementChild).display;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function getChildData() {
|
|
62
|
+
let data = { key: `${initialChild.type}_1`, child: initialChild };
|
|
63
|
+
if (switched) {
|
|
64
|
+
data = { key: `${switchTo.type}_2`, child: switchTo };
|
|
65
|
+
}
|
|
66
|
+
return Object.assign(Object.assign({}, data), { transition: getTransitionType(), duration: getTransitionDuration() });
|
|
67
|
+
}
|
|
68
|
+
function getTransitionType() {
|
|
69
|
+
if (isSwitchingBetweenIcons) {
|
|
70
|
+
if (switched)
|
|
71
|
+
return SPIN_COUNTER_CLOCK_WISE;
|
|
72
|
+
return SPIN_CLOCK_WISE;
|
|
73
|
+
}
|
|
74
|
+
else if (type === "fade") {
|
|
75
|
+
return FADE;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
if (switched)
|
|
79
|
+
return SLIDE_IN_UP;
|
|
80
|
+
return SLIDE_IN_DOWN;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function getTransitionDuration() {
|
|
84
|
+
switch (type) {
|
|
85
|
+
case "fade":
|
|
86
|
+
return DURATION_AVERAGE;
|
|
87
|
+
default:
|
|
88
|
+
return DURATION_SIMPLE;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
AnimatedSwitcher.Icon = function AnimatedSwitcherIcon({ switchToIcon, switched, initialIcon, }) {
|
|
93
|
+
return (React__default["default"].createElement(AnimatedSwitcher, { switched: switched, initialChild: React__default["default"].createElement(Icon.Icon, { name: initialIcon }), switchTo: React__default["default"].createElement(Icon.Icon, { name: switchToIcon }) }));
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
exports.AnimatedSwitcher = AnimatedSwitcher;
|
|
@@ -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 debounce = require('lodash/debounce');
|
|
8
|
+
var styleInject_es = require('../style-inject.es-9d2f5f4e.js');
|
|
9
|
+
var classnames = require('classnames');
|
|
10
|
+
var ReactDOM = require('react-dom');
|
|
11
|
+
var reactPopper = require('react-popper');
|
|
12
|
+
var useOnKeyDown = require('@jobber/hooks/useOnKeyDown');
|
|
13
|
+
var useSafeLayoutEffect = require('@jobber/hooks/useSafeLayoutEffect');
|
|
14
|
+
var Text = require('../Text-259af966.js');
|
|
15
|
+
var Icon = require('../Icon-405a216c.js');
|
|
16
|
+
var Heading = require('../Heading-1e8e4bd3.js');
|
|
17
|
+
var InputText = require('../InputText-55b6cb65.js');
|
|
18
|
+
require('../Typography-c45bf216.js');
|
|
19
|
+
require('@jobber/design');
|
|
20
|
+
require('../getAtlantisConfig-0f3e8af2.js');
|
|
21
|
+
require('../FormField-6ff183f8.js');
|
|
22
|
+
require('react-hook-form');
|
|
23
|
+
require('@jobber/hooks/useShowClear');
|
|
24
|
+
require('../Button-b73a5e01.js');
|
|
25
|
+
require('react-router-dom');
|
|
26
|
+
require('../InputValidation-05e839fa.js');
|
|
27
|
+
require('framer-motion');
|
|
28
|
+
require('../Spinner-9d8fc7ff.js');
|
|
29
|
+
|
|
30
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
31
|
+
|
|
32
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
33
|
+
var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
|
|
34
|
+
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
35
|
+
|
|
36
|
+
var css_248z = ".v0Cys9vQ-NE- {\n position: relative;\n width: 100%;\n}\n\n.CX-N-e0e6og- {\n display: none;\n position: absolute;\n z-index: calc(6 + 1001);\n z-index: calc(var(--elevation-menu) + var(--elevation-modal));\n width: 100%;\n /* Unfortunately this is how we define our line item picker height in jobber online.\n This is a concession to maintain visual parity. */\n max-height: 300px;\n box-shadow: 0px calc(16px / 16) calc(16px / 4) 0px\n rgba(0, 0, 0, 0.1),\n 0px calc(16px / 4) 12px 0px rgba(0, 0, 0, 0.05);\n box-shadow: var(--shadow-base);\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n border: calc(16px / 16) solid var(--color-color-border);\n border: var(--border-base) solid var(--color-color-border);\n border-radius: calc(16px / 8);\n border-radius: var(--radius-base);\n overflow: auto;\n scroll-behavior: smooth;\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n}\n\n.CX-N-e0e6og- h5 {\n padding: calc(16px / 2) 0 calc(16px / 4) calc(16px / 2);\n padding: var(--space-small) 0 var(--space-smaller) var(--space-small);\n border-bottom: calc(16px / 16) solid rgb(1, 41, 57);\n border-bottom: var(--border-base) solid var(--color-border--section);\n}\n\n.CX-N-e0e6og-._4PlUaegVpkk- {\n display: block;\n}\n\n.CX-N-e0e6og-._4PlUaegVpkk-:empty {\n display: none;\n}\n\n.ucQtG0iwqbo- {\n display: -ms-flexbox;\n display: flex;\n width: 100%;\n -ms-flex-direction: row;\n flex-direction: row;\n -ms-flex-wrap: nowrap;\n flex-wrap: nowrap;\n -ms-flex-pack: start;\n justify-content: flex-start;\n -ms-flex-line-pack: stretch;\n align-content: stretch;\n -ms-flex-align: center;\n align-items: center;\n padding: calc(16px / 2);\n padding: var(--space-small);\n border: none;\n text-align: left;\n list-style: none;\n background-color: transparent;\n cursor: pointer;\n transition: all 200ms;\n transition: all var(--timing-base);\n}\n\n.ucQtG0iwqbo-:hover,\n.ucQtG0iwqbo-:focus,\n.ucQtG0iwqbo-.r8HS-ma79QE- {\n background-color: rgb(244, 246, 250);\n background-color: var(--color-surface--hover);\n outline-color: rgb(147, 161, 169);\n outline-color: var(--color-focus);\n}\n\n.ucQtG0iwqbo-.ydwLX44YFZc-:not(:last-child) {\n border-bottom: calc(16px / 16) solid rgb(217, 223, 225);\n border-bottom: var(--border-base) solid var(--color-border);\n}\n\n.CX-N-e0e6og-:hover .ucQtG0iwqbo-.r8HS-ma79QE-:not(:hover) {\n background-color: transparent;\n outline-color: transparent;\n}\n\n.v0Cys9vQ-NE- .PvUgNoAUG7A-:not(:first-child) {\n padding-top: calc(16px / 2);\n padding-top: var(--space-small);\n}\n\n.ucQtG0iwqbo- .DAOOFUZ1BRM- {\n -ms-flex: 0 1 auto;\n flex: 0 1 auto;\n -ms-flex-item-align: auto;\n align-self: auto;\n width: calc(16px * 1.5);\n width: var(--space-large);\n}\n\n.ucQtG0iwqbo- .cjKJFup6hGY- {\n display: -ms-inline-flexbox;\n display: inline-flex;\n -ms-flex: 1 100%;\n flex: 1 100%;\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n}\n\n.ucQtG0iwqbo- .hG5zNBuI2wA- {\n -ms-flex: 2;\n flex: 2;\n}\n\n.ucQtG0iwqbo- ._3CwjFCbhqi4- {\n -ms-flex: 1;\n flex: 1;\n -ms-flex-item-align: end;\n align-self: flex-end;\n text-align: right;\n}\n";
|
|
37
|
+
var styles = {"autocomplete":"v0Cys9vQ-NE-","options":"CX-N-e0e6og-","visible":"_4PlUaegVpkk-","option":"ucQtG0iwqbo-","active":"r8HS-ma79QE-","separator":"ydwLX44YFZc-","heading":"PvUgNoAUG7A-","icon":"DAOOFUZ1BRM-","text":"cjKJFup6hGY-","label":"hG5zNBuI2wA-","details":"_3CwjFCbhqi4-"};
|
|
38
|
+
styleInject_es.styleInject(css_248z);
|
|
39
|
+
|
|
40
|
+
var IndexChange;
|
|
41
|
+
(function (IndexChange) {
|
|
42
|
+
IndexChange[IndexChange["Previous"] = -1] = "Previous";
|
|
43
|
+
IndexChange[IndexChange["Next"] = 1] = "Next";
|
|
44
|
+
})(IndexChange || (IndexChange = {}));
|
|
45
|
+
function Menu({ visible, options, selectedOption, onOptionSelect, attachTo, }) {
|
|
46
|
+
const [highlightedIndex, setHighlightedIndex] = React.useState(0);
|
|
47
|
+
const { menuRef, setMenuRef, styles: popperStyles, attributes, targetWidth, } = useRepositionMenu(attachTo, visible);
|
|
48
|
+
const detectSeparatorCondition = (option) => option.description || option.details;
|
|
49
|
+
const detectGroups = (option) => option.options;
|
|
50
|
+
const addSeparators = options.some(detectSeparatorCondition);
|
|
51
|
+
const initialHighlight = options.some(detectGroups) ? 1 : 0;
|
|
52
|
+
setupKeyListeners();
|
|
53
|
+
React.useEffect(() => setHighlightedIndex(initialHighlight), [options]);
|
|
54
|
+
const menu = (React__default["default"].createElement("div", Object.assign({ className: classnames__default["default"](styles.options, { [styles.visible]: visible }), ref: setMenuRef, style: Object.assign(Object.assign({}, popperStyles.popper), { width: targetWidth }) }, attributes.popper), options.map((option, index) => {
|
|
55
|
+
const optionClass = classnames__default["default"](styles.option, {
|
|
56
|
+
[styles.active]: index === highlightedIndex,
|
|
57
|
+
[styles.separator]: addSeparators,
|
|
58
|
+
});
|
|
59
|
+
if (isGroup(option)) {
|
|
60
|
+
return (React__default["default"].createElement("div", { key: option.label, className: styles.heading },
|
|
61
|
+
React__default["default"].createElement(Heading.Heading, { level: 5 }, option.label)));
|
|
62
|
+
}
|
|
63
|
+
return (React__default["default"].createElement("button", { className: optionClass, key: option.value, onMouseDown: onOptionSelect.bind(undefined, option) },
|
|
64
|
+
React__default["default"].createElement("div", { className: styles.icon }, isOptionSelected(selectedOption, option) && (React__default["default"].createElement(Icon.Icon, { name: "checkmark", size: "small" }))),
|
|
65
|
+
React__default["default"].createElement("div", { className: styles.text },
|
|
66
|
+
React__default["default"].createElement("div", { className: styles.label },
|
|
67
|
+
React__default["default"].createElement(Text.Text, null, option.label),
|
|
68
|
+
option.description !== undefined && (React__default["default"].createElement(Text.Text, { variation: "subdued" }, option.description))),
|
|
69
|
+
option.details !== undefined && (React__default["default"].createElement("div", { className: styles.details },
|
|
70
|
+
React__default["default"].createElement(Text.Text, null, option.details))))));
|
|
71
|
+
})));
|
|
72
|
+
return ReactDOM.createPortal(menu, document.body);
|
|
73
|
+
function setupKeyListeners() {
|
|
74
|
+
React.useEffect(() => {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
(_b = (_a = menuRef === null || menuRef === void 0 ? void 0 : menuRef.children[highlightedIndex]) === null || _a === void 0 ? void 0 : _a.scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
77
|
+
behavior: "smooth",
|
|
78
|
+
block: "nearest",
|
|
79
|
+
inline: "start",
|
|
80
|
+
});
|
|
81
|
+
}, [highlightedIndex]);
|
|
82
|
+
useOnKeyDown.useOnKeyDown((event) => {
|
|
83
|
+
const indexChange = arrowKeyPress(event, IndexChange.Next);
|
|
84
|
+
if (indexChange) {
|
|
85
|
+
setHighlightedIndex(Math.min(options.length - 1, highlightedIndex + indexChange));
|
|
86
|
+
}
|
|
87
|
+
}, "ArrowDown");
|
|
88
|
+
useOnKeyDown.useOnKeyDown((event) => {
|
|
89
|
+
const indexChange = arrowKeyPress(event, IndexChange.Previous);
|
|
90
|
+
if (indexChange) {
|
|
91
|
+
setHighlightedIndex(Math.max(0, highlightedIndex + indexChange));
|
|
92
|
+
}
|
|
93
|
+
}, "ArrowUp");
|
|
94
|
+
useOnKeyDown.useOnKeyDown((event) => {
|
|
95
|
+
if (!visible)
|
|
96
|
+
return;
|
|
97
|
+
if (isGroup(options[highlightedIndex]))
|
|
98
|
+
return;
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
onOptionSelect(options[highlightedIndex]);
|
|
101
|
+
}, "Enter");
|
|
102
|
+
}
|
|
103
|
+
function arrowKeyPress(event, direction) {
|
|
104
|
+
if (!visible)
|
|
105
|
+
return;
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
const requestedIndex = options[highlightedIndex + direction];
|
|
108
|
+
return requestedIndex && isGroup(requestedIndex)
|
|
109
|
+
? direction + direction
|
|
110
|
+
: direction;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function isOptionSelected(selectedOption, option) {
|
|
114
|
+
return selectedOption && selectedOption.value === option.value;
|
|
115
|
+
}
|
|
116
|
+
function isGroup(option) {
|
|
117
|
+
if (option.options)
|
|
118
|
+
return true;
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
function useRepositionMenu(attachTo, visible = false) {
|
|
122
|
+
var _a;
|
|
123
|
+
const [menuRef, setMenuRef] = React.useState();
|
|
124
|
+
const popper = reactPopper.usePopper(attachTo.current, menuRef, {
|
|
125
|
+
modifiers: [
|
|
126
|
+
{ name: "offset", options: { offset: [0, 8] } },
|
|
127
|
+
{ name: "flip", options: { fallbackPlacements: ["top"] } },
|
|
128
|
+
],
|
|
129
|
+
});
|
|
130
|
+
useSafeLayoutEffect.useSafeLayoutEffect(() => {
|
|
131
|
+
var _a;
|
|
132
|
+
(_a = popper === null || popper === void 0 ? void 0 : popper.update) === null || _a === void 0 ? void 0 : _a.call(popper);
|
|
133
|
+
}, [visible]);
|
|
134
|
+
const targetWidth = (_a = attachTo.current) === null || _a === void 0 ? void 0 : _a.clientWidth;
|
|
135
|
+
return Object.assign(Object.assign({}, popper), { menuRef, setMenuRef, targetWidth });
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Max statements increased to make room for the debounce functions
|
|
139
|
+
/* eslint max-statements: ["error", 14] */
|
|
140
|
+
function AutocompleteInternal(_a, ref) {
|
|
141
|
+
var _b;
|
|
142
|
+
var { initialOptions = [], value, allowFreeForm = true, size = undefined, debounce: debounceRate = 300, onChange, getOptions, placeholder, onBlur, onFocus, validations } = _a, inputProps = tslib_es6.__rest(_a, ["initialOptions", "value", "allowFreeForm", "size", "debounce", "onChange", "getOptions", "placeholder", "onBlur", "onFocus", "validations"]);
|
|
143
|
+
const [options, setOptions] = React.useState(initialOptions);
|
|
144
|
+
const [menuVisible, setMenuVisible] = React.useState(false);
|
|
145
|
+
const [inputText, setInputText] = React.useState((_b = value === null || value === void 0 ? void 0 : value.label) !== null && _b !== void 0 ? _b : "");
|
|
146
|
+
const autocompleteRef = React.useRef(null);
|
|
147
|
+
const delayedSearch = debounce__default["default"](updateSearch, debounceRate);
|
|
148
|
+
React.useEffect(() => {
|
|
149
|
+
delayedSearch();
|
|
150
|
+
return delayedSearch.cancel;
|
|
151
|
+
}, [inputText]);
|
|
152
|
+
React.useEffect(() => {
|
|
153
|
+
var _a;
|
|
154
|
+
updateInput((_a = value === null || value === void 0 ? void 0 : value.label) !== null && _a !== void 0 ? _a : "");
|
|
155
|
+
}, [value]);
|
|
156
|
+
return (React__default["default"].createElement("div", { className: styles.autocomplete, ref: autocompleteRef },
|
|
157
|
+
React__default["default"].createElement(InputText.InputText, Object.assign({ ref: ref, autocomplete: false, size: size, value: inputText, onChange: handleInputChange, placeholder: placeholder, onFocus: handleInputFocus, onBlur: handleInputBlur, validations: validations }, inputProps)),
|
|
158
|
+
menuVisible && (React__default["default"].createElement(Menu, { attachTo: autocompleteRef, visible: menuVisible && options.length > 0, options: options, selectedOption: value, onOptionSelect: handleMenuChange }))));
|
|
159
|
+
function updateInput(newText) {
|
|
160
|
+
setInputText(newText);
|
|
161
|
+
if (newText === "") {
|
|
162
|
+
setOptions(mapToOptions(initialOptions));
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function updateSearch() {
|
|
166
|
+
return tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
const updatedOptions = yield getOptions(inputText);
|
|
168
|
+
const filteredOptions = updatedOptions.filter((option) => "options" in option && option.options ? option.options.length > 0 : true);
|
|
169
|
+
setOptions(mapToOptions(filteredOptions));
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function handleMenuChange(chosenOption) {
|
|
173
|
+
onChange(chosenOption);
|
|
174
|
+
updateInput(chosenOption.label);
|
|
175
|
+
setMenuVisible(false);
|
|
176
|
+
}
|
|
177
|
+
function handleInputChange(newText) {
|
|
178
|
+
updateInput(newText);
|
|
179
|
+
if (allowFreeForm) {
|
|
180
|
+
onChange({ label: newText });
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function handleInputBlur() {
|
|
184
|
+
setMenuVisible(false);
|
|
185
|
+
if (value == undefined || value.label !== inputText) {
|
|
186
|
+
setInputText("");
|
|
187
|
+
onChange(undefined);
|
|
188
|
+
}
|
|
189
|
+
onBlur && onBlur();
|
|
190
|
+
}
|
|
191
|
+
function handleInputFocus() {
|
|
192
|
+
setMenuVisible(true);
|
|
193
|
+
if (onFocus) {
|
|
194
|
+
onFocus();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function mapToOptions(items) {
|
|
199
|
+
return items.reduce(function (result, item) {
|
|
200
|
+
result = result.concat([item]);
|
|
201
|
+
if (item.options) {
|
|
202
|
+
result = result.concat(item.options);
|
|
203
|
+
}
|
|
204
|
+
return result;
|
|
205
|
+
}, []);
|
|
206
|
+
}
|
|
207
|
+
const Autocomplete = React.forwardRef(AutocompleteInternal);
|
|
208
|
+
|
|
209
|
+
exports.Autocomplete = Autocomplete;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var Avatar = require('../Avatar-76a799fa.js');
|
|
6
|
+
require('react');
|
|
7
|
+
require('classnames');
|
|
8
|
+
require('../style-inject.es-9d2f5f4e.js');
|
|
9
|
+
require('color');
|
|
10
|
+
require('../Icon-405a216c.js');
|
|
11
|
+
require('@jobber/design');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.Avatar = Avatar.Avatar;
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
var Color = require('color');
|
|
7
|
+
var Icon = require('./Icon-405a216c.js');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
|
+
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
13
|
+
var Color__default = /*#__PURE__*/_interopDefaultLegacy(Color);
|
|
14
|
+
|
|
15
|
+
var css_248z = ":root {\n --avatar-size: calc(var(--base-unit) * 2);\n --avatar-border-size: var(--border-base);\n}\n\n.WniTNadEyPk- {\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 width: calc(16px * 2);\n width: var(--avatar-size);\n height: calc(16px * 2);\n height: var(--avatar-size);\n min-width: calc(16px * 2);\n min-width: var(--avatar-size);\n min-height: calc(16px * 2);\n min-height: var(--avatar-size);\n border-radius: 100%;\n border-radius: var(--radius-circle);\n color: rgb(1, 41, 57);\n color: var(--color-heading);\n font-size: calc(16px * 2);\n font-size: var(--avatar-size);\n -webkit-font-smoothing: antialiased;\n background: no-repeat center center rgba(101, 120, 132, 1);\n background: no-repeat center center var(--color-greyBlue);\n background-size: cover;\n}\n\n.WniTNadEyPk-:focus {\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 outline: none;\n}\n\n._8Pqn2uZpaZg- {\n --avatar-size: calc(var(--base-unit) * 4.5);\n --avatar-border-size: var(--border-thick);\n}\n\n.S-edTXYA-7E- {\n --avatar-size: calc(var(--base-unit) * 1.5);\n}\n\n.S1iBGElfOUA- {\n color: rgba(255, 255, 255, 1);\n color: var(--color-text--reverse);\n}\n\n.ErPhpHHpiBQ- {\n font-size: calc((16px * 2) / 2);\n font-size: calc(calc(16px * 2) / 2);\n font-size: calc(var(--avatar-size) / 2);\n text-transform: uppercase;\n}\n\n.aC-d-mngrIc- {\n font-size: calc((16px * 2) / 2.25);\n font-size: calc(calc(16px * 2) / 2.25);\n font-size: calc(var(--avatar-size) / 2.25);\n}\n\n.nR0S-GzjDnQ- {\n width: calc((16px * 2) - (calc(16px / 16) * 2));\n width: calc(calc(16px * 2) - (calc(16px / 16) * 2));\n width: calc(var(--avatar-size) - (var(--avatar-border-size) * 2));\n height: calc((16px * 2) - (calc(16px / 16) * 2));\n height: calc(calc(16px * 2) - (calc(16px / 16) * 2));\n height: calc(var(--avatar-size) - (var(--avatar-border-size) * 2));\n box-shadow: 0 0 0 calc(16px / 8) rgba(255, 255, 255, 1) inset;\n box-shadow: 0 0 0 var(--border-thick) var(--color-white) inset;\n border-style: solid;\n border-width: calc(16px / 16);\n border-width: var(--avatar-border-size);\n}\n";
|
|
16
|
+
var styles = {"avatar":"WniTNadEyPk-","large":"_8Pqn2uZpaZg-","small":"S-edTXYA-7E-","isDark":"S1iBGElfOUA-","initials":"ErPhpHHpiBQ-","smallInitials":"aC-d-mngrIc-","hasBorder":"nR0S-GzjDnQ-"};
|
|
17
|
+
styleInject_es.styleInject(css_248z);
|
|
18
|
+
|
|
19
|
+
function isDark(colorToCheck) {
|
|
20
|
+
if (colorToCheck == undefined) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if (colorToCheck) {
|
|
24
|
+
try {
|
|
25
|
+
return Color__default["default"](deconstructCssCustomProperty(colorToCheck)).isDark();
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
console.log(err);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
function deconstructCssCustomProperty(color) {
|
|
34
|
+
if (!color) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (!color.toLowerCase().startsWith("var(")) {
|
|
38
|
+
return color;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Rips apart the `var(--custom-property)` into just `--custom-property`.
|
|
42
|
+
*/
|
|
43
|
+
const customProperty = color
|
|
44
|
+
.replace("var(", "")
|
|
45
|
+
.slice(0, -1)
|
|
46
|
+
.split(" ")
|
|
47
|
+
.join("");
|
|
48
|
+
return getComputedStyle(document.documentElement)
|
|
49
|
+
.getPropertyValue(customProperty)
|
|
50
|
+
.trim();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function Avatar({ imageUrl, name, initials, size = "base", color, }) {
|
|
54
|
+
const style = {
|
|
55
|
+
backgroundColor: color,
|
|
56
|
+
borderColor: color,
|
|
57
|
+
};
|
|
58
|
+
if (imageUrl) {
|
|
59
|
+
style.backgroundImage = `url(${imageUrl})`;
|
|
60
|
+
}
|
|
61
|
+
const shouldBeDark = color == undefined || isDark(color);
|
|
62
|
+
const className = classnames__default["default"](styles.avatar, size !== "base" && styles[size], {
|
|
63
|
+
[styles.hasBorder]: imageUrl && color,
|
|
64
|
+
[styles.isDark]: shouldBeDark,
|
|
65
|
+
});
|
|
66
|
+
return (React__default["default"].createElement("div", { className: className, style: style, role: imageUrl && "img", "aria-label": name }, !imageUrl && (React__default["default"].createElement(Initials, { initials: initials, dark: shouldBeDark, iconSize: size }))));
|
|
67
|
+
}
|
|
68
|
+
function Initials({ initials, dark = false, iconSize = "base", }) {
|
|
69
|
+
if (!initials) {
|
|
70
|
+
return (React__default["default"].createElement(Icon.Icon, { name: "person", color: dark ? "white" : "blue", size: iconSize }));
|
|
71
|
+
}
|
|
72
|
+
const className = classnames__default["default"](styles.initials, {
|
|
73
|
+
[styles.smallInitials]: initials.length > 2,
|
|
74
|
+
});
|
|
75
|
+
return React__default["default"].createElement("span", { className: className }, initials.substr(0, 3));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
exports.Avatar = Avatar;
|