@jobber/components 4.0.0 → 4.0.1-pre.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/dist/Autocomplete/Autocomplete.d.ts +1 -1
- package/dist/Autocomplete/Option.d.ts +2 -2
- package/dist/Autocomplete/index.js +51 -67
- package/dist/Avatar/Avatar.d.ts +2 -2
- package/dist/Avatar/index.js +2 -2
- package/dist/{Avatar-cfd04e86.js → Avatar-89cfd0a6.js} +14 -18
- package/dist/Banner/Banner.d.ts +1 -1
- package/dist/Banner/index.js +15 -19
- package/dist/Button/Button.d.ts +1 -1
- package/dist/Button/index.js +3 -4
- package/dist/{Button-cd30df0f.js → Button-16e043ec.js} +21 -24
- package/dist/ButtonDismiss/index.js +4 -5
- package/dist/{ButtonDismiss-a9590195.js → ButtonDismiss-3fb1eaf9.js} +2 -3
- package/dist/Card/Card.d.ts +1 -1
- package/dist/Card/index.js +6 -7
- package/dist/Card/types.d.ts +1 -1
- package/dist/{Card-b9f8d6f3.js → Card-edab9c3c.js} +18 -22
- package/dist/Checkbox/Checkbox.d.ts +1 -1
- package/dist/Checkbox/index.js +4 -5
- package/dist/{Checkbox-5103d2b9.js → Checkbox-c1efc2f6.js} +10 -12
- package/dist/Chips/ChipsTypes.d.ts +1 -1
- package/dist/Chips/InternalChipDismissible/InternalChipDismissibleTypes.d.ts +1 -1
- package/dist/Chips/InternalChipDismissible/hooks/useInternalChipDismissible.d.ts +1 -1
- package/dist/Chips/InternalChipDismissible/hooks/useInternalChipDismissibleInput.d.ts +3 -3
- package/dist/Chips/InternalChipMultiSelect.d.ts +1 -1
- package/dist/Chips/InternalChipSingleSelect.d.ts +1 -1
- package/dist/Chips/index.js +165 -185
- package/dist/ConfirmationModal/ConfirmationModal.d.ts +1 -1
- package/dist/ConfirmationModal/index.js +11 -12
- package/dist/{ConfirmationModal-e95f46d7.js → ConfirmationModal-6a7beee2.js} +28 -31
- package/dist/Content/index.js +1 -1
- package/dist/{Content-18de5fbb.js → Content-05df8f7f.js} +2 -3
- package/dist/Countdown/Countdown.d.ts +1 -1
- package/dist/Countdown/computeTimeUnit.d.ts +1 -1
- package/dist/Countdown/index.js +15 -18
- package/dist/DataDump/index.js +9 -11
- package/dist/DataTable/Footer.d.ts +1 -1
- package/dist/DataTable/createTableSettings.d.ts +2 -2
- package/dist/DataTable/index.js +74 -106
- package/dist/DataTable/test-utilities/helpers.d.ts +1 -1
- package/dist/DataTable/types.d.ts +2 -2
- package/dist/DatePicker/DatePicker.d.ts +1 -1
- package/dist/DatePicker/index.js +4 -5
- package/dist/{DatePicker-7c67e8d2.js → DatePicker-af21ae91.js} +31 -36
- package/dist/DescriptionList/index.js +5 -10
- package/dist/Disclosure/index.js +8 -10
- package/dist/Divider/index.js +8 -10
- package/dist/Drawer/index.js +10 -14
- package/dist/Emphasis/index.js +2 -3
- package/dist/{Emphasis-75a3f411.js → Emphasis-23dc2a0a.js} +4 -6
- package/dist/FeatureSwitch/index.js +15 -17
- package/dist/Form/index.js +23 -33
- package/dist/FormField/FormFieldTypes.d.ts +2 -2
- package/dist/FormField/index.js +8 -8
- package/dist/{FormField-76068c0b.js → FormField-1e444bb6.js} +68 -76
- package/dist/FormatDate/index.js +2 -3
- package/dist/FormatEmail/index.js +2 -3
- package/dist/FormatFile/index.js +13 -14
- package/dist/{FormatFile-18e8a54a.js → FormatFile-3512f838.js} +33 -40
- package/dist/FormatRelativeDateTime/index.js +5 -6
- package/dist/FormatTime/index.js +6 -7
- package/dist/Gallery/GalleryTypes.d.ts +2 -2
- package/dist/Gallery/index.js +31 -33
- package/dist/Heading/index.js +2 -3
- package/dist/{Heading-a9a66964.js → Heading-7b203f7f.js} +4 -6
- package/dist/Icon/index.js +1 -1
- package/dist/{Icon-d5ad1a6d.js → Icon-405a216c.js} +7 -8
- package/dist/InlineLabel/InlineLabel.d.ts +1 -1
- package/dist/InlineLabel/index.js +4 -6
- package/dist/InputAvatar/index.js +15 -20
- package/dist/InputDate/index.js +15 -15
- package/dist/InputEmail/InputEmail.d.ts +1 -1
- package/dist/InputEmail/index.js +12 -12
- package/dist/InputFile/index.js +6 -6
- package/dist/{InputFile-e108a7f8.js → InputFile-5e0ed2b5.js} +48 -62
- package/dist/InputGroup/index.js +4 -5
- package/dist/InputNumber/index.js +22 -22
- package/dist/InputPassword/index.js +12 -12
- package/dist/InputText/InputText.d.ts +1 -1
- package/dist/InputText/index.js +9 -9
- package/dist/{InputText-523d0e48.js → InputText-12b112a9.js} +23 -24
- package/dist/InputTime/index.js +27 -27
- package/dist/InputValidation/index.js +4 -5
- package/dist/{InputValidation-06a8a7ba.js → InputValidation-97dd0dcf.js} +7 -8
- package/dist/LightBox/index.js +5 -6
- package/dist/{LightBox-1ad62669.js → LightBox-dd1afa97.js} +22 -26
- package/dist/List/index.js +26 -32
- package/dist/Markdown/index.js +6 -7
- package/dist/{Markdown-b53e0308.js → Markdown-be2dcd0c.js} +12 -18
- package/dist/Menu/index.js +4 -5
- package/dist/{Menu-826cfb89.js → Menu-d6a7d17b.js} +31 -36
- package/dist/Modal/index.js +6 -7
- package/dist/{Modal-cc3bd7bf.js → Modal-757e83fd.js} +13 -17
- package/dist/MultiSelect/index.js +53 -60
- package/dist/MultiSelect/types.d.ts +1 -1
- package/dist/{Option-fdf21181.js → Option-13150f4a.js} +3 -5
- package/dist/Page/Page.d.ts +1 -1
- package/dist/Page/index.js +21 -24
- package/dist/Popover/index.js +11 -13
- package/dist/ProgressBar/index.js +1 -1
- package/dist/{ProgressBar-e9a49129.js → ProgressBar-f028b159.js} +3 -4
- package/dist/RadioGroup/RadioOption.d.ts +2 -2
- package/dist/RadioGroup/index.js +9 -13
- package/dist/RecurringSelect/types.d.ts +2 -2
- package/dist/Select/Select.d.ts +1 -1
- package/dist/Select/index.js +9 -9
- package/dist/Spinner/index.js +1 -1
- package/dist/{Spinner-e4e9c8eb.js → Spinner-ae4c8a85.js} +5 -7
- package/dist/StatusLabel/StatusLabel.d.ts +1 -1
- package/dist/StatusLabel/index.js +6 -9
- package/dist/Switch/index.js +2 -3
- package/dist/{Switch-f03b70fc.js → Switch-7ac32f7b.js} +12 -16
- package/dist/Table/index.js +9 -17
- package/dist/Tabs/index.js +28 -34
- package/dist/Text/index.js +2 -3
- package/dist/{Text-e012fb46.js → Text-7ce00adb.js} +4 -5
- package/dist/Toast/Toast.d.ts +2 -2
- package/dist/Toast/index.js +31 -32
- package/dist/Tooltip/index.js +3 -4
- package/dist/Tooltip/useTooltipPositioning.d.ts +1 -1
- package/dist/{Tooltip-041feb00.js → Tooltip-1090a43d.js} +25 -28
- package/dist/Typography/Typography.d.ts +1 -1
- package/dist/Typography/index.js +1 -2
- package/dist/{Typography-fbe0ed6e.js → Typography-9262511f.js} +5 -7
- package/dist/tslib.es6-efe27175.js +38 -0
- package/package.json +3 -3
- package/dist/tslib.es6-5b50eb8e.js +0 -103
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { XOR } from "ts-xor";
|
|
3
3
|
import { GroupOption, Option } from "./Option";
|
|
4
4
|
import { FormFieldProps } from "../FormField";
|
|
5
|
-
|
|
5
|
+
type OptionCollection = XOR<Option[], GroupOption[]>;
|
|
6
6
|
interface AutocompleteProps extends Pick<FormFieldProps, "size" | "onBlur" | "onFocus" | "invalid"> {
|
|
7
7
|
/**
|
|
8
8
|
* Initial options to show when user first focuses the Autocomplete
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { XOR } from "ts-xor";
|
|
2
|
-
|
|
2
|
+
type OptionValue = string | number;
|
|
3
3
|
interface BaseOption {
|
|
4
4
|
label: string;
|
|
5
5
|
}
|
|
@@ -11,5 +11,5 @@ export interface Option extends BaseOption {
|
|
|
11
11
|
export interface GroupOption extends BaseOption {
|
|
12
12
|
options: Option[];
|
|
13
13
|
}
|
|
14
|
-
export
|
|
14
|
+
export type AnyOption = XOR<Option, GroupOption>;
|
|
15
15
|
export {};
|
|
@@ -2,26 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var tslib_es6 = require('../tslib.es6-
|
|
5
|
+
var tslib_es6 = require('../tslib.es6-efe27175.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var debounce = require('lodash/debounce');
|
|
8
8
|
var styleInject_es = require('../style-inject.es-dcee06b6.js');
|
|
9
9
|
var classnames = require('classnames');
|
|
10
10
|
var useEventListener = require('@use-it/event-listener');
|
|
11
|
-
var Text = require('../Text-
|
|
12
|
-
var Icon = require('../Icon-
|
|
13
|
-
var Heading = require('../Heading-
|
|
14
|
-
var InputText = require('../InputText-
|
|
15
|
-
require('../Typography-
|
|
11
|
+
var Text = require('../Text-7ce00adb.js');
|
|
12
|
+
var Icon = require('../Icon-405a216c.js');
|
|
13
|
+
var Heading = require('../Heading-7b203f7f.js');
|
|
14
|
+
var InputText = require('../InputText-12b112a9.js');
|
|
15
|
+
require('../Typography-9262511f.js');
|
|
16
16
|
require('@jobber/design');
|
|
17
|
-
require('../FormField-
|
|
17
|
+
require('../FormField-1e444bb6.js');
|
|
18
18
|
require('uuid');
|
|
19
19
|
require('react-hook-form');
|
|
20
|
-
require('../Button-
|
|
20
|
+
require('../Button-16e043ec.js');
|
|
21
21
|
require('react-router-dom');
|
|
22
|
-
require('../InputValidation-
|
|
22
|
+
require('../InputValidation-97dd0dcf.js');
|
|
23
23
|
require('framer-motion');
|
|
24
|
-
require('../Spinner-
|
|
24
|
+
require('../Spinner-ae4c8a85.js');
|
|
25
25
|
|
|
26
26
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
27
27
|
|
|
@@ -39,28 +39,23 @@ var IndexChange;
|
|
|
39
39
|
IndexChange[IndexChange["Previous"] = -1] = "Previous";
|
|
40
40
|
IndexChange[IndexChange["Next"] = 1] = "Next";
|
|
41
41
|
})(IndexChange || (IndexChange = {}));
|
|
42
|
-
function Menu(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
53
|
-
var detectGroups = function (option) { return option.options; };
|
|
54
|
-
var addSeparators = options.some(detectSeparatorCondition);
|
|
55
|
-
var initialHighlight = options.some(detectGroups) ? 1 : 0;
|
|
42
|
+
function Menu({ visible, options, selectedOption, onOptionSelect, }) {
|
|
43
|
+
const [highlightedIndex, setHighlightedIndex] = React.useState(0);
|
|
44
|
+
const optionMenuClass = classnames__default["default"](styles.options, {
|
|
45
|
+
[styles.visible]: visible,
|
|
46
|
+
});
|
|
47
|
+
const menuDiv = React.useRef();
|
|
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;
|
|
56
52
|
setupKeyListeners();
|
|
57
|
-
React.useEffect(
|
|
58
|
-
return (React__default["default"].createElement("div", { className: optionMenuClass, ref: menuDiv }, options.map(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
_a));
|
|
53
|
+
React.useEffect(() => setHighlightedIndex(initialHighlight), [options]);
|
|
54
|
+
return (React__default["default"].createElement("div", { className: optionMenuClass, ref: menuDiv }, options.map((option, index) => {
|
|
55
|
+
const optionClass = classnames__default["default"](styles.option, {
|
|
56
|
+
[styles.active]: index === highlightedIndex,
|
|
57
|
+
[styles.separator]: addSeparators,
|
|
58
|
+
});
|
|
64
59
|
if (isGroup(option)) {
|
|
65
60
|
return (React__default["default"].createElement("div", { key: option.label, className: styles.heading },
|
|
66
61
|
React__default["default"].createElement(Heading.Heading, { level: 5 }, option.label)));
|
|
@@ -75,8 +70,8 @@ function Menu(_a) {
|
|
|
75
70
|
React__default["default"].createElement(Text.Text, null, option.details))))));
|
|
76
71
|
})));
|
|
77
72
|
function setupKeyListeners() {
|
|
78
|
-
useOnKeyDown("ArrowDown",
|
|
79
|
-
|
|
73
|
+
useOnKeyDown("ArrowDown", (event) => {
|
|
74
|
+
const indexChange = arrowKeyPress(event, IndexChange.Next);
|
|
80
75
|
if (indexChange) {
|
|
81
76
|
setHighlightedIndex(Math.min(options.length - 1, highlightedIndex + indexChange));
|
|
82
77
|
}
|
|
@@ -84,8 +79,8 @@ function Menu(_a) {
|
|
|
84
79
|
scrollMenuIfItemNotInView(menuDiv.current, "down");
|
|
85
80
|
}
|
|
86
81
|
});
|
|
87
|
-
useOnKeyDown("ArrowUp",
|
|
88
|
-
|
|
82
|
+
useOnKeyDown("ArrowUp", (event) => {
|
|
83
|
+
const indexChange = arrowKeyPress(event, IndexChange.Previous);
|
|
89
84
|
if (indexChange) {
|
|
90
85
|
setHighlightedIndex(Math.max(0, highlightedIndex + indexChange));
|
|
91
86
|
}
|
|
@@ -94,13 +89,13 @@ function Menu(_a) {
|
|
|
94
89
|
}
|
|
95
90
|
});
|
|
96
91
|
function scrollMenuIfItemNotInView(menuDivElement, direction) {
|
|
97
|
-
|
|
92
|
+
const itemDiv = menuDivElement.querySelector(`button.${styles.option}:nth-child(${highlightedIndex + 1})`);
|
|
98
93
|
if (!itemDiv)
|
|
99
94
|
return;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
95
|
+
const menuTop = menuDivElement.getBoundingClientRect().top;
|
|
96
|
+
const { top: itemTop, height: itemHeight, bottom: itemBottom, } = itemDiv.getBoundingClientRect();
|
|
97
|
+
const itemTrueBottom = itemBottom + itemHeight;
|
|
98
|
+
const menuBottom = menuDivElement.getBoundingClientRect().bottom;
|
|
104
99
|
if (direction == "up" && itemTop - itemHeight < menuTop) {
|
|
105
100
|
menuDivElement.scrollTop -= itemHeight;
|
|
106
101
|
}
|
|
@@ -108,7 +103,7 @@ function Menu(_a) {
|
|
|
108
103
|
menuDivElement.scrollTop += itemHeight;
|
|
109
104
|
}
|
|
110
105
|
}
|
|
111
|
-
useOnKeyDown("Enter",
|
|
106
|
+
useOnKeyDown("Enter", (event) => {
|
|
112
107
|
if (!visible)
|
|
113
108
|
return;
|
|
114
109
|
if (isGroup(options[highlightedIndex]))
|
|
@@ -121,7 +116,7 @@ function Menu(_a) {
|
|
|
121
116
|
if (!visible)
|
|
122
117
|
return;
|
|
123
118
|
event.preventDefault();
|
|
124
|
-
|
|
119
|
+
const requestedIndex = options[highlightedIndex + direction];
|
|
125
120
|
return requestedIndex && isGroup(requestedIndex)
|
|
126
121
|
? direction + direction
|
|
127
122
|
: direction;
|
|
@@ -134,8 +129,8 @@ function isOptionSelected(selectedOption, option) {
|
|
|
134
129
|
function useOnKeyDown(keyName, handler) {
|
|
135
130
|
// Pending: https://github.com/donavon/use-event-listener/pull/12
|
|
136
131
|
// The types in useEventListener mistakenly require a SyntheticEvent for the passed generic.
|
|
137
|
-
useEventListener__default["default"]("keydown",
|
|
138
|
-
|
|
132
|
+
useEventListener__default["default"]("keydown", event => {
|
|
133
|
+
const newEvent = event;
|
|
139
134
|
if (newEvent.key === keyName) {
|
|
140
135
|
handler(newEvent);
|
|
141
136
|
}
|
|
@@ -152,18 +147,17 @@ function isGroup(option) {
|
|
|
152
147
|
* debounce functions.
|
|
153
148
|
*/
|
|
154
149
|
// eslint-disable-next-line max-statements
|
|
155
|
-
function Autocomplete(
|
|
156
|
-
var
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
React.useEffect(function () {
|
|
150
|
+
function Autocomplete({ initialOptions = [], value, allowFreeForm = true, size = undefined, invalid, debounce: debounceRate = 300, onChange, getOptions, placeholder, onBlur, onFocus, }) {
|
|
151
|
+
var _a;
|
|
152
|
+
const [options, setOptions] = React.useState(initialOptions);
|
|
153
|
+
const [menuVisible, setMenuVisible] = React.useState(false);
|
|
154
|
+
const [inputText, setInputText] = React.useState((_a = value === null || value === void 0 ? void 0 : value.label) !== null && _a !== void 0 ? _a : "");
|
|
155
|
+
const delayedSearch = debounce__default["default"](updateSearch, debounceRate);
|
|
156
|
+
React.useEffect(() => {
|
|
163
157
|
delayedSearch();
|
|
164
158
|
return delayedSearch.cancel;
|
|
165
159
|
}, [inputText]);
|
|
166
|
-
React.useEffect(
|
|
160
|
+
React.useEffect(() => {
|
|
167
161
|
var _a;
|
|
168
162
|
updateInput((_a = value === null || value === void 0 ? void 0 : value.label) !== null && _a !== void 0 ? _a : "");
|
|
169
163
|
}, [value]);
|
|
@@ -177,20 +171,10 @@ function Autocomplete(_a) {
|
|
|
177
171
|
}
|
|
178
172
|
}
|
|
179
173
|
function updateSearch() {
|
|
180
|
-
return tslib_es6.__awaiter(this, void 0, void 0, function () {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
case 0: return [4 /*yield*/, getOptions(inputText)];
|
|
185
|
-
case 1:
|
|
186
|
-
updatedOptions = _a.sent();
|
|
187
|
-
filteredOptions = updatedOptions.filter(function (option) {
|
|
188
|
-
return "options" in option && option.options ? option.options.length > 0 : true;
|
|
189
|
-
});
|
|
190
|
-
setOptions(mapToOptions(filteredOptions));
|
|
191
|
-
return [2 /*return*/];
|
|
192
|
-
}
|
|
193
|
-
});
|
|
174
|
+
return tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
175
|
+
const updatedOptions = yield getOptions(inputText);
|
|
176
|
+
const filteredOptions = updatedOptions.filter((option) => "options" in option && option.options ? option.options.length > 0 : true);
|
|
177
|
+
setOptions(mapToOptions(filteredOptions));
|
|
194
178
|
});
|
|
195
179
|
}
|
|
196
180
|
function handleMenuChange(chosenOption) {
|
package/dist/Avatar/Avatar.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { XOR } from "ts-xor";
|
|
3
|
-
|
|
3
|
+
type AvatarSize = "base" | "large" | "small";
|
|
4
4
|
interface AvatarFoundationProps {
|
|
5
5
|
/**
|
|
6
6
|
* A url for the image that will be displayed
|
|
@@ -33,6 +33,6 @@ interface AvatarWithImageProps extends AvatarFoundationProps {
|
|
|
33
33
|
interface AvatarWithInitialsProps extends AvatarFoundationProps {
|
|
34
34
|
readonly initials: string;
|
|
35
35
|
}
|
|
36
|
-
export
|
|
36
|
+
export type AvatarProps = XOR<AvatarWithImageProps, AvatarWithInitialsProps>;
|
|
37
37
|
export declare function Avatar({ imageUrl, name, initials, size, color, }: AvatarProps): JSX.Element;
|
|
38
38
|
export {};
|
package/dist/Avatar/index.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var Avatar = require('../Avatar-
|
|
5
|
+
var Avatar = require('../Avatar-89cfd0a6.js');
|
|
6
6
|
require('react');
|
|
7
7
|
require('classnames');
|
|
8
8
|
require('../style-inject.es-dcee06b6.js');
|
|
9
9
|
require('color');
|
|
10
|
-
require('../Icon-
|
|
10
|
+
require('../Icon-405a216c.js');
|
|
11
11
|
require('@jobber/design');
|
|
12
12
|
|
|
13
13
|
|
|
@@ -4,7 +4,7 @@ var React = require('react');
|
|
|
4
4
|
var classnames = require('classnames');
|
|
5
5
|
var styleInject_es = require('./style-inject.es-dcee06b6.js');
|
|
6
6
|
var Color = require('color');
|
|
7
|
-
var Icon = require('./Icon-
|
|
7
|
+
var Icon = require('./Icon-405a216c.js');
|
|
8
8
|
|
|
9
9
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
10
|
|
|
@@ -40,7 +40,7 @@ function deconstructCssCustomProperty(color) {
|
|
|
40
40
|
/**
|
|
41
41
|
* Rips apart the `var(--custom-property)` into just `--custom-property`.
|
|
42
42
|
*/
|
|
43
|
-
|
|
43
|
+
const customProperty = color
|
|
44
44
|
.replace("var(", "")
|
|
45
45
|
.slice(0, -1)
|
|
46
46
|
.split(" ")
|
|
@@ -50,32 +50,28 @@ function deconstructCssCustomProperty(color) {
|
|
|
50
50
|
.trim();
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
function Avatar(
|
|
54
|
-
|
|
55
|
-
var imageUrl = _a.imageUrl, name = _a.name, initials = _a.initials, _c = _a.size, size = _c === void 0 ? "base" : _c, color = _a.color;
|
|
56
|
-
var style = {
|
|
53
|
+
function Avatar({ imageUrl, name, initials, size = "base", color, }) {
|
|
54
|
+
const style = {
|
|
57
55
|
backgroundColor: color,
|
|
58
56
|
borderColor: color,
|
|
59
57
|
};
|
|
60
58
|
if (imageUrl) {
|
|
61
|
-
style.backgroundImage =
|
|
59
|
+
style.backgroundImage = `url(${imageUrl})`;
|
|
62
60
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
+
});
|
|
68
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 }))));
|
|
69
67
|
}
|
|
70
|
-
function Initials(
|
|
71
|
-
var _b;
|
|
72
|
-
var initials = _a.initials, _c = _a.dark, dark = _c === void 0 ? false : _c, _d = _a.iconSize, iconSize = _d === void 0 ? "base" : _d;
|
|
68
|
+
function Initials({ initials, dark = false, iconSize = "base", }) {
|
|
73
69
|
if (!initials) {
|
|
74
70
|
return (React__default["default"].createElement(Icon.Icon, { name: "person", color: dark ? "white" : "blue", size: iconSize }));
|
|
75
71
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
const className = classnames__default["default"](styles.initials, {
|
|
73
|
+
[styles.smallInitials]: initials.length > 2,
|
|
74
|
+
});
|
|
79
75
|
return React__default["default"].createElement("span", { className: className }, initials.substr(0, 3));
|
|
80
76
|
}
|
|
81
77
|
|
package/dist/Banner/Banner.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { ButtonProps } from "../Button";
|
|
3
|
-
export
|
|
3
|
+
export type BannerType = "notice" | "success" | "warning" | "error";
|
|
4
4
|
interface BannerProps {
|
|
5
5
|
readonly children: ReactNode;
|
|
6
6
|
readonly type: BannerType;
|
package/dist/Banner/index.js
CHANGED
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var tslib_es6 = require('../tslib.es6-5b50eb8e.js');
|
|
6
5
|
var React = require('react');
|
|
7
6
|
var classnames = require('classnames');
|
|
8
7
|
var jobberHooks = require('@jobber/hooks');
|
|
9
8
|
var styleInject_es = require('../style-inject.es-dcee06b6.js');
|
|
10
|
-
var Icon = require('../Icon-
|
|
11
|
-
var Text = require('../Text-
|
|
12
|
-
var Button = require('../Button-
|
|
9
|
+
var Icon = require('../Icon-405a216c.js');
|
|
10
|
+
var Text = require('../Text-7ce00adb.js');
|
|
11
|
+
var Button = require('../Button-16e043ec.js');
|
|
13
12
|
require('@jobber/design');
|
|
14
|
-
require('../Typography-
|
|
13
|
+
require('../Typography-9262511f.js');
|
|
15
14
|
require('react-router-dom');
|
|
16
15
|
|
|
17
16
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -27,18 +26,16 @@ var css = ".nw7Tf4jicBNmfENtxh7tG {\n background-color: var(--color-informative
|
|
|
27
26
|
var types = {"notice":"nw7Tf4jicBNmfENtxh7tG","success":"myY4eq0vr_r4Twz0QcBwu","warning":"eExwEf69eCfam2C6Ekk5D","error":"_1U_-uPZepxvaZPO5hh8G4O"};
|
|
28
27
|
styleInject_es.styleInject(css);
|
|
29
28
|
|
|
30
|
-
function Banner(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var _d = tslib_es6.__read(React.useState(true), 2), showBanner = _d[0], setShowBanner = _d[1];
|
|
34
|
-
var bannerWidths = {
|
|
29
|
+
function Banner({ children, type, primaryAction, dismissible = true, onDismiss, }) {
|
|
30
|
+
const [showBanner, setShowBanner] = React.useState(true);
|
|
31
|
+
const bannerWidths = {
|
|
35
32
|
small: 320,
|
|
36
33
|
medium: 480,
|
|
37
34
|
};
|
|
38
|
-
|
|
35
|
+
const [bannerRef, { width: bannerWidth = bannerWidths.small }] = jobberHooks.useResizeObserver({
|
|
39
36
|
widths: bannerWidths,
|
|
40
|
-
})
|
|
41
|
-
|
|
37
|
+
});
|
|
38
|
+
const iconColors = {
|
|
42
39
|
notice: "informative",
|
|
43
40
|
success: "success",
|
|
44
41
|
warning: "warning",
|
|
@@ -51,15 +48,15 @@ function Banner(_a) {
|
|
|
51
48
|
variation: type === "notice" ? "learning" : "work",
|
|
52
49
|
}, primaryAction);
|
|
53
50
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
const bannerClassNames = classnames__default["default"](styles.banner, types[type], {
|
|
52
|
+
[styles.medium]: bannerWidth >= bannerWidths.medium,
|
|
53
|
+
});
|
|
57
54
|
return (React__default["default"].createElement(React__default["default"].Fragment, null, showBanner && (React__default["default"].createElement("div", { className: bannerClassNames, ref: bannerRef, role: type === "error" ? "alert" : "status" },
|
|
58
55
|
React__default["default"].createElement("div", { className: styles.bannerContent },
|
|
59
56
|
React__default["default"].createElement("div", { className: styles.bannerChildren },
|
|
60
57
|
React__default["default"].createElement(BannerChildren, null, children)),
|
|
61
58
|
primaryAction && (React__default["default"].createElement("div", { className: styles.bannerAction },
|
|
62
|
-
React__default["default"].createElement(Button.Button,
|
|
59
|
+
React__default["default"].createElement(Button.Button, Object.assign({}, primaryAction))))),
|
|
63
60
|
dismissible && (React__default["default"].createElement("button", { className: styles.closeButton, onClick: handleClose, "aria-label": "Close this notification" },
|
|
64
61
|
React__default["default"].createElement(Icon.Icon, { name: "cross", color: iconColors[type] })))))));
|
|
65
62
|
function handleClose() {
|
|
@@ -67,8 +64,7 @@ function Banner(_a) {
|
|
|
67
64
|
onDismiss && onDismiss();
|
|
68
65
|
}
|
|
69
66
|
}
|
|
70
|
-
function BannerChildren(
|
|
71
|
-
var children = _a.children;
|
|
67
|
+
function BannerChildren({ children }) {
|
|
72
68
|
if (!children)
|
|
73
69
|
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
74
70
|
if (children && typeof children === "string") {
|
package/dist/Button/Button.d.ts
CHANGED
|
@@ -59,6 +59,6 @@ interface SubmitButtonProps extends Omit<ButtonFoundationProps, "external" | "on
|
|
|
59
59
|
*/
|
|
60
60
|
submit: boolean;
|
|
61
61
|
}
|
|
62
|
-
export
|
|
62
|
+
export type ButtonProps = XOR<BaseActionProps, XOR<DestructiveActionProps, SubmitActionProps>> & XOR<SubmitButtonProps, XOR<ButtonLinkProps, ButtonAnchorProps>> & XOR<ButtonIconProps, ButtonLabelProps>;
|
|
63
63
|
export declare function Button(props: ButtonProps): JSX.Element;
|
|
64
64
|
export {};
|
package/dist/Button/index.js
CHANGED
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var Button = require('../Button-
|
|
6
|
-
require('../tslib.es6-5b50eb8e.js');
|
|
5
|
+
var Button = require('../Button-16e043ec.js');
|
|
7
6
|
require('react');
|
|
8
7
|
require('classnames');
|
|
9
8
|
require('react-router-dom');
|
|
10
9
|
require('../style-inject.es-dcee06b6.js');
|
|
11
|
-
require('../Icon-
|
|
10
|
+
require('../Icon-405a216c.js');
|
|
12
11
|
require('@jobber/design');
|
|
13
|
-
require('../Typography-
|
|
12
|
+
require('../Typography-9262511f.js');
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var tslib_es6 = require('./tslib.es6-5b50eb8e.js');
|
|
4
3
|
var React = require('react');
|
|
5
4
|
var classnames = require('classnames');
|
|
6
5
|
var reactRouterDom = require('react-router-dom');
|
|
7
6
|
var styleInject_es = require('./style-inject.es-dcee06b6.js');
|
|
8
|
-
var Icon = require('./Icon-
|
|
9
|
-
var Typography = require('./Typography-
|
|
7
|
+
var Icon = require('./Icon-405a216c.js');
|
|
8
|
+
var Typography = require('./Typography-9262511f.js');
|
|
10
9
|
|
|
11
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
11
|
|
|
@@ -18,30 +17,28 @@ var styles = {"button":"mvrsWRM8T3kCECXcDS2gd","work":"_32HTPrDFyNRObzZRUxmhK6",
|
|
|
18
17
|
styleInject_es.styleInject(css);
|
|
19
18
|
|
|
20
19
|
function Button(props) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var buttonInternals = React__default["default"].createElement(ButtonInternals, tslib_es6.__assign({}, props));
|
|
20
|
+
const { ariaControls, ariaHaspopup, ariaExpanded, ariaLabel, disabled = false, external, fullWidth, icon, label, iconOnRight, id, loading, onClick, onMouseDown, size = "base", type = "primary", url, to, variation = "work", submit, } = props;
|
|
21
|
+
const buttonClassNames = classnames__default["default"](styles.button, styles[size], {
|
|
22
|
+
[styles.onlyIcon]: icon && !label,
|
|
23
|
+
[styles.hasIconAndLabel]: icon && label,
|
|
24
|
+
[styles.iconOnRight]: iconOnRight,
|
|
25
|
+
[styles[variation]]: variation,
|
|
26
|
+
[styles[type]]: type,
|
|
27
|
+
[styles.disabled]: disabled,
|
|
28
|
+
[styles.fullWidth]: fullWidth,
|
|
29
|
+
[styles.loading]: loading,
|
|
30
|
+
});
|
|
31
|
+
const buttonType = submit ? "submit" : "button";
|
|
32
|
+
const tagProps = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ className: buttonClassNames, disabled,
|
|
33
|
+
id }, (!disabled && { href: url })), (!disabled && { onClick: onClick })), (!disabled && { onMouseDown: onMouseDown })), (external && { target: "_blank" })), (url === undefined && to === undefined && { type: buttonType })), { "aria-controls": ariaControls, "aria-haspopup": ariaHaspopup, "aria-expanded": ariaExpanded, "aria-label": ariaLabel });
|
|
34
|
+
const buttonInternals = React__default["default"].createElement(ButtonInternals, Object.assign({}, props));
|
|
37
35
|
if (to) {
|
|
38
|
-
return (React__default["default"].createElement(reactRouterDom.Link,
|
|
36
|
+
return (React__default["default"].createElement(reactRouterDom.Link, Object.assign({}, tagProps, { to: to }), buttonInternals));
|
|
39
37
|
}
|
|
40
|
-
|
|
41
|
-
return React__default["default"].createElement(Tag,
|
|
38
|
+
const Tag = url ? "a" : "button";
|
|
39
|
+
return React__default["default"].createElement(Tag, Object.assign({}, tagProps), buttonInternals);
|
|
42
40
|
}
|
|
43
|
-
function ButtonInternals(
|
|
44
|
-
var label = _a.label, icon = _a.icon, _b = _a.size, size = _b === void 0 ? "base" : _b;
|
|
41
|
+
function ButtonInternals({ label, icon, size = "base" }) {
|
|
45
42
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
46
43
|
icon && React__default["default"].createElement(Icon.Icon, { name: icon, size: size }),
|
|
47
44
|
React__default["default"].createElement(Typography.Typography, { element: "span", fontWeight: "extraBold", fontFamily: "base", size: getTypeSizes(size) }, label)));
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var ButtonDismiss = require('../ButtonDismiss-
|
|
5
|
+
var ButtonDismiss = require('../ButtonDismiss-3fb1eaf9.js');
|
|
6
6
|
require('react');
|
|
7
|
-
require('../Button-
|
|
8
|
-
require('../tslib.es6-5b50eb8e.js');
|
|
7
|
+
require('../Button-16e043ec.js');
|
|
9
8
|
require('classnames');
|
|
10
9
|
require('react-router-dom');
|
|
11
10
|
require('../style-inject.es-dcee06b6.js');
|
|
12
|
-
require('../Icon-
|
|
11
|
+
require('../Icon-405a216c.js');
|
|
13
12
|
require('@jobber/design');
|
|
14
|
-
require('../Typography-
|
|
13
|
+
require('../Typography-9262511f.js');
|
|
15
14
|
|
|
16
15
|
|
|
17
16
|
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var Button = require('./Button-
|
|
4
|
+
var Button = require('./Button-16e043ec.js');
|
|
5
5
|
|
|
6
6
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
7
7
|
|
|
8
8
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
9
9
|
|
|
10
|
-
function ButtonDismiss(
|
|
11
|
-
var onClick = _a.onClick, ariaLabel = _a.ariaLabel;
|
|
10
|
+
function ButtonDismiss({ onClick, ariaLabel }) {
|
|
12
11
|
return (React__default["default"].createElement(Button.Button, { ariaLabel: ariaLabel, icon: "remove", onClick: onClick, type: "tertiary", variation: "subtle" }));
|
|
13
12
|
}
|
|
14
13
|
|
package/dist/Card/Card.d.ts
CHANGED
|
@@ -14,6 +14,6 @@ interface LinkCardProps extends CardProps {
|
|
|
14
14
|
interface ClickableCardProps extends CardProps {
|
|
15
15
|
onClick(event: React.MouseEvent<HTMLAnchorElement | HTMLDivElement>): void;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
type CardPropOptions = XOR<CardProps, XOR<LinkCardProps, ClickableCardProps>>;
|
|
18
18
|
export declare function Card({ accent, header, children, onClick, title, url, external, }: CardPropOptions): JSX.Element;
|
|
19
19
|
export {};
|
package/dist/Card/index.js
CHANGED
|
@@ -2,18 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var Card = require('../Card-
|
|
6
|
-
require('../tslib.es6-5b50eb8e.js');
|
|
5
|
+
var Card = require('../Card-edab9c3c.js');
|
|
7
6
|
require('react');
|
|
8
7
|
require('classnames');
|
|
9
8
|
require('../style-inject.es-dcee06b6.js');
|
|
10
|
-
require('../Heading-
|
|
11
|
-
require('../Typography-
|
|
12
|
-
require('../Button-
|
|
9
|
+
require('../Heading-7b203f7f.js');
|
|
10
|
+
require('../Typography-9262511f.js');
|
|
11
|
+
require('../Button-16e043ec.js');
|
|
13
12
|
require('react-router-dom');
|
|
14
|
-
require('../Icon-
|
|
13
|
+
require('../Icon-405a216c.js');
|
|
15
14
|
require('@jobber/design');
|
|
16
|
-
require('../Menu-
|
|
15
|
+
require('../Menu-d6a7d17b.js');
|
|
17
16
|
require('uuid');
|
|
18
17
|
require('framer-motion');
|
|
19
18
|
require('@jobber/hooks');
|
package/dist/Card/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ReactElement, ReactNode } from "react";
|
|
|
2
2
|
import colors from "./colors.css";
|
|
3
3
|
import { ButtonProps } from "../Button";
|
|
4
4
|
import { MenuProps } from "../Menu";
|
|
5
|
-
export
|
|
5
|
+
export type ActionProps = ReactElement<Omit<ButtonProps, "size" | "fullWidth"> | MenuProps>;
|
|
6
6
|
export interface HeaderActionProps {
|
|
7
7
|
/**
|
|
8
8
|
* The title of the card.
|