@jobber/components 4.49.2-JOB-80005.2 → 4.49.2-JOB-80005.14
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/Banner/index.js +71 -9
- package/dist/Combobox/Combobox.d.ts +1 -12
- package/dist/Combobox/Combobox.types.d.ts +142 -0
- package/dist/Combobox/components/ComboboxAction/ComboboxAction.d.ts +2 -11
- package/dist/Combobox/components/ComboboxAction/index.d.ts +1 -1
- package/dist/Combobox/components/ComboboxContent/ComboboxContent.d.ts +2 -43
- package/dist/Combobox/components/ComboboxContent/ComboboxContentHeader/ComboboxContentHeader.d.ts +3 -0
- package/dist/Combobox/components/ComboboxContent/ComboboxContentHeader/index.d.ts +1 -0
- package/dist/Combobox/components/ComboboxContent/ComboboxContentList/ComboboxContentList.d.ts +3 -0
- package/dist/Combobox/components/ComboboxContent/ComboboxContentList/index.d.ts +1 -0
- package/dist/Combobox/components/ComboboxContent/ComboboxContentSearch/ComboboxContentSearch.d.ts +3 -0
- package/dist/Combobox/components/ComboboxContent/ComboboxContentSearch/index.d.ts +1 -0
- package/dist/Combobox/components/ComboboxTrigger/ComboboxTriggerButton/ComboboxTriggerButton.d.ts +1 -1
- package/dist/Combobox/components/ComboboxTrigger/ComboboxTriggerChip/ComboboxTriggerChip.d.ts +1 -1
- package/dist/Combobox/hooks/useComboboxAccessibility.d.ts +1 -1
- package/dist/Combobox/hooks/useComboboxContent.d.ts +3 -3
- package/dist/Combobox/hooks/useComboboxValidation.d.ts +7 -0
- package/dist/Combobox/index.d.ts +2 -2
- package/dist/Combobox/index.js +69 -43
- package/dist/DataList/DataList.d.ts +2 -1
- package/dist/DataList/DataList.types.d.ts +0 -1
- package/dist/DataList/components/DataListStatusBar/DataListStatusBar.d.ts +10 -0
- package/dist/DataList/components/DataListStatusBar/index.d.ts +1 -0
- package/dist/DataList/index.js +20 -7
- package/dist/DataTable/DataTable.d.ts +10 -10
- package/dist/DataTable/Pagination.d.ts +6 -5
- package/dist/DataTable/index.js +11 -5
- package/dist/Tabs/Tabs.d.ts +12 -1
- package/dist/Tabs/index.js +6 -2
- package/package.json +5 -5
- package/rollup.config.js +1 -0
- package/dist/Banner-ecd9a7cf.js +0 -76
- package/dist/Combobox/components/ComboboxContent/ComboboxList.d.ts +0 -15
- package/dist/Combobox/components/ComboboxContent/ComboboxSearch.d.ts +0 -7
package/dist/Banner/index.js
CHANGED
|
@@ -2,18 +2,80 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
require('
|
|
7
|
-
require('
|
|
8
|
-
require('
|
|
9
|
-
require('../
|
|
10
|
-
require('../
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var classnames = require('classnames');
|
|
7
|
+
var jobberHooks = require('@jobber/hooks/useResizeObserver');
|
|
8
|
+
var styleInject_es = require('../style-inject.es-9d2f5f4e.js');
|
|
9
|
+
var Icon = require('../Icon-405a216c.js');
|
|
10
|
+
var Text = require('../Text-54334431.js');
|
|
11
|
+
var Button = require('../Button-db6114a6.js');
|
|
11
12
|
require('@jobber/design');
|
|
12
|
-
require('../Text-54334431.js');
|
|
13
13
|
require('../Typography-83915c54.js');
|
|
14
|
-
require('../Button-db6114a6.js');
|
|
15
14
|
require('react-router-dom');
|
|
16
15
|
|
|
16
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
17
|
|
|
18
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
19
|
+
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
var css_248z$1 = ".meuT8gYQPJU- {\n display: -ms-flexbox;\n display: flex;\n position: relative;\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 padding: calc(16px * 1);\n padding: var(--space-base);\n color: rgb(66, 78, 86);\n color: var(--color-text);\n background-color: rgb(244, 244, 244);\n background-color: var(--color-surface--background);\n gap: calc(16px / 2);\n gap: var(--space-small);\n -ms-flex-align: center;\n align-items: center;\n}\n\n.y4BapyZr-fo- > a {\n color: rgb(66, 78, 86);\n color: var(--color-text);\n}\n\n.y4BapyZr-fo- > a:hover {\n color: rgb(1, 41, 57);\n color: var(--color-blue);\n}\n\n._6v1woNSLEvc- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n gap: calc(16px / 2);\n gap: var(--space-small);\n -ms-flex-wrap: nowrap;\n flex-wrap: nowrap;\n -ms-flex-pack: justify;\n justify-content: space-between;\n -ms-flex-align: start;\n align-items: flex-start;\n}\n\n@media (max-width: 489.98px) {\n\n._6v1woNSLEvc- {\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n}\n }\n\n@media (--small-screens-and-below) {\n\n._6v1woNSLEvc- {\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n}\n }\n\n.y4BapyZr-fo- {\n -ms-flex: 1;\n flex: 1;\n -ms-flex-item-align: center;\n align-self: center;\n}\n\n._6v1woNSLEvc- > *:last-child {\n margin-bottom: 0;\n}\n\n.bocgLmEhcTU- .y4BapyZr-fo- {\n -ms-flex: 1;\n flex: 1;\n}\n\n.rtNjEzmABX4- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex: 0 0 auto;\n flex: 0 0 auto;\n}\n\n@media (max-width: 489.98px) {\n\n.rtNjEzmABX4- {\n width: 100%;\n margin-top: calc(16px / 2);\n margin-top: var(--space-small);\n}\n }\n\n@media (--small-screens-and-below) {\n\n.rtNjEzmABX4- {\n width: 100%;\n margin-top: calc(16px / 2);\n margin-top: var(--space-small);\n}\n }\n\n.lunQ5SOfyLg- {\n margin: calc((16px / 8) * -1) 0;\n margin: calc(calc(16px / 8) * -1) 0;\n margin: calc(var(--space-smallest) * -1) 0;\n padding: calc(16px / 8);\n padding: var(--space-smallest);\n border: none;\n background-color: transparent;\n cursor: pointer;\n -webkit-appearance: none;\n appearance: none;\n -ms-flex: 0;\n flex: 0;\n -ms-flex-item-align: start;\n align-self: flex-start;\n}\n\n.lunQ5SOfyLg-:hover {\n background: rgba(0, 0, 0, 0.025);\n}\n\n.lunQ5SOfyLg-:focus {\n box-shadow: 0px 0px calc(16px / 4) calc(16px / 8)\n rgb(231, 213, 87);\n box-shadow: var(--shadow-focus);\n outline: none;\n background: rgba(0, 0, 0, 0.05);\n}\n";
|
|
22
|
+
var styles = {"banner":"meuT8gYQPJU-","bannerChildren":"y4BapyZr-fo-","bannerContent":"_6v1woNSLEvc-","medium":"bocgLmEhcTU-","bannerAction":"rtNjEzmABX4-","closeButton":"lunQ5SOfyLg-"};
|
|
23
|
+
styleInject_es.styleInject(css_248z$1);
|
|
24
|
+
|
|
25
|
+
var css_248z = ".wWW-2T7rCV0- {\n background-color: rgb(226, 241, 250);\n background-color: var(--color-informative--surface);\n}\n\n/* Our Banner \"surface\" colors should be lighter than they are so we're leaving the following alone for now */\n\n._7h8FUHIkVjg- {\n background-color: rgb(203, 223, 159);\n background-color: var(--color-green--lighter);\n}\n\n.d5fXcE1L0lc- {\n background-color: rgb(241, 231, 159);\n background-color: var(--color-yellow--lighter);\n}\n\n.oYaw-T3c0IU- {\n background-color: rgb(255, 206, 194);\n background-color: var(--color-red--lighter);\n}\n";
|
|
26
|
+
var types = {"notice":"wWW-2T7rCV0-","success":"_7h8FUHIkVjg-","warning":"d5fXcE1L0lc-","error":"oYaw-T3c0IU-"};
|
|
27
|
+
styleInject_es.styleInject(css_248z);
|
|
28
|
+
|
|
29
|
+
function BannerIcon({ icon }) {
|
|
30
|
+
return React__default["default"].createElement(Icon.Icon, { name: icon, color: "greyBlueDark" });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function Banner({ children, type, primaryAction, dismissible = true, icon, onDismiss, }) {
|
|
34
|
+
const [showBanner, setShowBanner] = React.useState(true);
|
|
35
|
+
const bannerWidths = {
|
|
36
|
+
small: 320,
|
|
37
|
+
medium: 480,
|
|
38
|
+
};
|
|
39
|
+
const [bannerRef, { width: bannerWidth = bannerWidths.small }] = jobberHooks.useResizeObserver({
|
|
40
|
+
widths: bannerWidths,
|
|
41
|
+
});
|
|
42
|
+
const iconColors = {
|
|
43
|
+
notice: "informative",
|
|
44
|
+
success: "success",
|
|
45
|
+
warning: "warning",
|
|
46
|
+
error: "critical",
|
|
47
|
+
};
|
|
48
|
+
if (primaryAction != undefined) {
|
|
49
|
+
primaryAction = Object.assign({
|
|
50
|
+
size: "small",
|
|
51
|
+
type: "tertiary",
|
|
52
|
+
variation: type === "notice" ? "learning" : "work",
|
|
53
|
+
}, primaryAction);
|
|
54
|
+
}
|
|
55
|
+
const bannerClassNames = classnames__default["default"](styles.banner, types[type], {
|
|
56
|
+
[styles.medium]: bannerWidth >= bannerWidths.medium,
|
|
57
|
+
});
|
|
58
|
+
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" },
|
|
59
|
+
React__default["default"].createElement("div", { className: styles.bannerContent },
|
|
60
|
+
icon && React__default["default"].createElement(BannerIcon, { icon: icon }),
|
|
61
|
+
React__default["default"].createElement("div", { className: styles.bannerChildren },
|
|
62
|
+
React__default["default"].createElement(BannerChildren, null, children)),
|
|
63
|
+
primaryAction && (React__default["default"].createElement("div", { className: styles.bannerAction },
|
|
64
|
+
React__default["default"].createElement(Button.Button, Object.assign({}, primaryAction))))),
|
|
65
|
+
dismissible && (React__default["default"].createElement("button", { className: styles.closeButton, onClick: handleClose, "aria-label": "Close this notification" },
|
|
66
|
+
React__default["default"].createElement(Icon.Icon, { name: "cross", color: iconColors[type] })))))));
|
|
67
|
+
function handleClose() {
|
|
68
|
+
setShowBanner(!showBanner);
|
|
69
|
+
onDismiss && onDismiss();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function BannerChildren({ children, }) {
|
|
73
|
+
if (!children)
|
|
74
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
75
|
+
if (children && typeof children === "string") {
|
|
76
|
+
return React__default["default"].createElement(Text.Text, null, children);
|
|
77
|
+
}
|
|
78
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null, children);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
exports.Banner = Banner;
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComboboxProps } from "@jobber/components/Combobox/Combobox.types";
|
|
2
2
|
import { ComboboxContent } from "./components/ComboboxContent";
|
|
3
3
|
import { ComboboxAction } from "./components/ComboboxAction";
|
|
4
4
|
import { ComboboxTriggerButton, ComboboxTriggerChip } from "./components/ComboboxTrigger";
|
|
5
|
-
export interface ComboboxProps {
|
|
6
|
-
readonly children: ReactElement | ReactElement[];
|
|
7
|
-
/**
|
|
8
|
-
* When `true`, `Combobox` will allow for multiple selections
|
|
9
|
-
*
|
|
10
|
-
* @default false
|
|
11
|
-
*/
|
|
12
|
-
readonly multiSelect?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare const COMBOBOX_TRIGGER_COUNT_ERROR_MESSAGE = "Combobox can only have one Trigger element";
|
|
15
|
-
export declare const COMBOBOX_REQUIRED_CHILDREN_ERROR_MESSAGE = "Combobox must have a Trigger and Combobox.Content element";
|
|
16
5
|
export declare const Combobox: {
|
|
17
6
|
(props: ComboboxProps): JSX.Element;
|
|
18
7
|
TriggerButton: typeof ComboboxTriggerButton;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
+
import { Dispatch, ReactElement, SetStateAction } from "react";
|
|
2
|
+
import { XOR } from "ts-xor";
|
|
1
3
|
import { ButtonProps } from "../Button";
|
|
4
|
+
export interface ComboboxProps {
|
|
5
|
+
readonly children: ReactElement | ReactElement[];
|
|
6
|
+
/**
|
|
7
|
+
* When `true`, `Combobox` will allow for multiple selections
|
|
8
|
+
*
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
readonly multiSelect?: boolean;
|
|
12
|
+
}
|
|
2
13
|
export interface ComboboxTriggerProps {
|
|
3
14
|
/**
|
|
4
15
|
* The label text of the trigger.
|
|
@@ -9,6 +20,137 @@ export interface ComboboxTriggerButtonProps extends ComboboxTriggerProps, Pick<B
|
|
|
9
20
|
}
|
|
10
21
|
export type ComboboxTriggerChipProps = ComboboxTriggerProps;
|
|
11
22
|
export interface ComboboxOption {
|
|
23
|
+
/**
|
|
24
|
+
* A unique identifier for the option.
|
|
25
|
+
*/
|
|
12
26
|
id: string | number;
|
|
27
|
+
/**
|
|
28
|
+
* The value to be visually displayed in the Combobox options list.
|
|
29
|
+
*/
|
|
13
30
|
label: string;
|
|
14
31
|
}
|
|
32
|
+
interface ComboboxCloseProps {
|
|
33
|
+
/**
|
|
34
|
+
* Callback function invoked upon the selection of an option. Provides the selected option(s) as an argument.
|
|
35
|
+
*/
|
|
36
|
+
readonly onSelect: (selection: ComboboxOption[]) => void;
|
|
37
|
+
}
|
|
38
|
+
interface ComboboxSelectProps {
|
|
39
|
+
/**
|
|
40
|
+
* Callback function invoked upon the Combobox menu closing. Provides the selected option(s) as an argument.
|
|
41
|
+
*/
|
|
42
|
+
readonly onClose: (selection: ComboboxOption[]) => void;
|
|
43
|
+
}
|
|
44
|
+
interface ComboboxContentBaseProps {
|
|
45
|
+
/**
|
|
46
|
+
* List of selectable options to display.
|
|
47
|
+
*/
|
|
48
|
+
readonly options: ComboboxOption[];
|
|
49
|
+
/**
|
|
50
|
+
* Optional action button(s) to display at the bottom of the list.
|
|
51
|
+
*/
|
|
52
|
+
readonly children?: ReactElement | ReactElement[];
|
|
53
|
+
/**
|
|
54
|
+
* Placeholder text to display in the search input. Defaults to "Search".
|
|
55
|
+
*/
|
|
56
|
+
readonly searchPlaceholder?: string;
|
|
57
|
+
/**
|
|
58
|
+
* The selected options of the Combobox.
|
|
59
|
+
*/
|
|
60
|
+
readonly selected: ComboboxOption[];
|
|
61
|
+
/**
|
|
62
|
+
* The encapsulating noun for the content of the combobox. Used
|
|
63
|
+
* in the empty state, and search placeholder. Should be pluralized.
|
|
64
|
+
*/
|
|
65
|
+
readonly subjectNoun?: string;
|
|
66
|
+
}
|
|
67
|
+
export type ComboboxContentProps = ComboboxContentBaseProps & XOR<ComboboxCloseProps, ComboboxSelectProps>;
|
|
68
|
+
export interface ComboboxSearchProps {
|
|
69
|
+
/**
|
|
70
|
+
* The placeholder for the search input.
|
|
71
|
+
*/
|
|
72
|
+
placeholder?: string;
|
|
73
|
+
/**
|
|
74
|
+
* The value of the search input
|
|
75
|
+
*/
|
|
76
|
+
searchValue: string;
|
|
77
|
+
/**
|
|
78
|
+
* The open state of the Combobox listbox.
|
|
79
|
+
*/
|
|
80
|
+
open: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Setter for the search input value.
|
|
83
|
+
*/
|
|
84
|
+
setSearchValue: Dispatch<SetStateAction<string>>;
|
|
85
|
+
}
|
|
86
|
+
export interface ComboboxHeaderProps {
|
|
87
|
+
/**
|
|
88
|
+
* Does the Combobox have any options visible in the list.
|
|
89
|
+
*/
|
|
90
|
+
readonly hasOptionsVisible: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* The noun to be used in the header label.
|
|
93
|
+
*/
|
|
94
|
+
readonly subjectNoun?: string;
|
|
95
|
+
/**
|
|
96
|
+
* The number of selected options.
|
|
97
|
+
*/
|
|
98
|
+
readonly selectedCount: number;
|
|
99
|
+
/**
|
|
100
|
+
* The function to call when the clear all button is clicked.
|
|
101
|
+
*/
|
|
102
|
+
readonly onClearAll: () => void;
|
|
103
|
+
/**
|
|
104
|
+
* The function to call when the select all button is clicked.
|
|
105
|
+
*/
|
|
106
|
+
readonly onSelectAll: () => void;
|
|
107
|
+
}
|
|
108
|
+
export interface ComboboxListProps {
|
|
109
|
+
/**
|
|
110
|
+
* The options to display in the list. May be the full set of the Combobox or could be filtered.
|
|
111
|
+
*/
|
|
112
|
+
readonly options: ComboboxOption[];
|
|
113
|
+
/**
|
|
114
|
+
* Used to determine if the empty state should be shown and given priority over the options list.
|
|
115
|
+
*/
|
|
116
|
+
readonly showEmptyState: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* The currently selected options.
|
|
119
|
+
*/
|
|
120
|
+
readonly selected: ComboboxOption[];
|
|
121
|
+
/**
|
|
122
|
+
* A ref to the list element.
|
|
123
|
+
*/
|
|
124
|
+
readonly optionsListRef: React.RefObject<HTMLUListElement>;
|
|
125
|
+
/**
|
|
126
|
+
* Setter for the first selected element, which is used to scroll the list to the first selected element on re-opening.
|
|
127
|
+
*/
|
|
128
|
+
readonly setFirstSelectedElement: React.Dispatch<SetStateAction<HTMLElement | null>>;
|
|
129
|
+
/**
|
|
130
|
+
* The callback function to call when an option is selected.
|
|
131
|
+
*/
|
|
132
|
+
readonly selectionHandler: (option: ComboboxOption) => void;
|
|
133
|
+
/**
|
|
134
|
+
* The current search term. Used in the no results message.
|
|
135
|
+
*/
|
|
136
|
+
readonly searchValue: string;
|
|
137
|
+
/**
|
|
138
|
+
* Determines if it is a single selection or multi selection Combobox.
|
|
139
|
+
*/
|
|
140
|
+
readonly multiselect: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* The noun to be used in the empty state message.
|
|
143
|
+
*/
|
|
144
|
+
readonly subjectNoun?: string;
|
|
145
|
+
}
|
|
146
|
+
export interface ComboboxActionProps {
|
|
147
|
+
/**
|
|
148
|
+
* The function to call when the action is clicked.
|
|
149
|
+
*/
|
|
150
|
+
onClick(event: React.MouseEvent<HTMLButtonElement>): void;
|
|
151
|
+
/**
|
|
152
|
+
* The label text of the action.
|
|
153
|
+
*/
|
|
154
|
+
readonly label: string;
|
|
155
|
+
}
|
|
156
|
+
export {};
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The function to call when the action is clicked.
|
|
5
|
-
*/
|
|
6
|
-
onClick(event: React.MouseEvent<HTMLButtonElement>): void;
|
|
7
|
-
/**
|
|
8
|
-
* The label text of the action.
|
|
9
|
-
*/
|
|
10
|
-
readonly label: string;
|
|
11
|
-
}
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ComboboxActionProps } from "@jobber/components/Combobox/Combobox.types";
|
|
12
3
|
export declare function ComboboxAction(props: ComboboxActionProps): JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ComboboxAction
|
|
1
|
+
export { ComboboxAction } from "./ComboboxAction";
|
|
@@ -1,44 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { ComboboxOption } from "../../Combobox.types";
|
|
4
|
-
interface ComboboxCloseProps {
|
|
5
|
-
/**
|
|
6
|
-
* Callback function invoked upon the selection of an option. Provides the selected option(s) as an argument.
|
|
7
|
-
*/
|
|
8
|
-
readonly onSelect: (selection: ComboboxOption[]) => void;
|
|
9
|
-
}
|
|
10
|
-
interface ComoboboxSelectProps {
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* Callback function invoked upon the Combobox menu closing. Provides the selected option(s) as an argument.
|
|
14
|
-
*/
|
|
15
|
-
readonly onClose: (selection: ComboboxOption[]) => void;
|
|
16
|
-
}
|
|
17
|
-
interface ComboboxContentBaseProps {
|
|
18
|
-
/**
|
|
19
|
-
* List of selectable options to display.
|
|
20
|
-
*/
|
|
21
|
-
readonly options: ComboboxOption[];
|
|
22
|
-
/**
|
|
23
|
-
* Optional action button(s) to display at the bottom of the list.
|
|
24
|
-
*/
|
|
25
|
-
readonly children?: ReactElement | ReactElement[];
|
|
26
|
-
/**
|
|
27
|
-
* Placeholder text to display in the search input. Defaults to "Search".
|
|
28
|
-
*/
|
|
29
|
-
readonly searchPlaceholder?: string;
|
|
30
|
-
/**
|
|
31
|
-
* pre selected option
|
|
32
|
-
* @default ""
|
|
33
|
-
* @type string
|
|
34
|
-
*/
|
|
35
|
-
readonly selected: ComboboxOption[];
|
|
36
|
-
/**
|
|
37
|
-
* The encapsulating noun for the content of the combobox. Used
|
|
38
|
-
* in the empty state, and search placeholder. Should be pluralized.
|
|
39
|
-
*/
|
|
40
|
-
readonly subjectNoun?: string;
|
|
41
|
-
}
|
|
42
|
-
type ComboboxContentProps = ComboboxContentBaseProps & XOR<ComboboxCloseProps, ComoboboxSelectProps>;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ComboboxContentProps } from "@jobber/components/Combobox/Combobox.types";
|
|
43
3
|
export declare function ComboboxContent(props: ComboboxContentProps): JSX.Element;
|
|
44
|
-
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ComboboxContentHeader } from "./ComboboxContentHeader";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ComboboxContentList } from "./ComboboxContentList";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ComboboxContentSearch } from "./ComboboxContentSearch";
|
package/dist/Combobox/components/ComboboxTrigger/ComboboxTriggerButton/ComboboxTriggerButton.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ComboboxTriggerButtonProps } from "
|
|
2
|
+
import { ComboboxTriggerButtonProps } from "@jobber/components/Combobox/Combobox.types";
|
|
3
3
|
export declare function ComboboxTriggerButton(props: ComboboxTriggerButtonProps): JSX.Element;
|
package/dist/Combobox/components/ComboboxTrigger/ComboboxTriggerChip/ComboboxTriggerChip.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ComboboxTriggerChipProps } from "
|
|
2
|
+
import { ComboboxTriggerChipProps } from "@jobber/components/Combobox/Combobox.types";
|
|
3
3
|
export declare function ComboboxTriggerChip(props: ComboboxTriggerChipProps): JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ComboboxOption } from "
|
|
2
|
+
import { ComboboxOption } from "@jobber/components/Combobox/Combobox.types";
|
|
3
3
|
export declare function useComboboxAccessibility(selectionCallback: (selection: ComboboxOption) => void, filteredOptions: ComboboxOption[], optionsListRef: React.RefObject<HTMLUListElement>, open: boolean, setOpen: (open: boolean) => void, wrapperRef: React.RefObject<HTMLDivElement>): {
|
|
4
4
|
popperRef: React.RefObject<HTMLDivElement>;
|
|
5
5
|
popperStyles: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ComboboxOption } from "
|
|
2
|
+
import { ComboboxOption } from "@jobber/components/Combobox/Combobox.types";
|
|
3
3
|
interface useComboboxContent {
|
|
4
4
|
searchValue: string;
|
|
5
5
|
setSearchValue: React.Dispatch<React.SetStateAction<string>>;
|
|
@@ -7,7 +7,7 @@ interface useComboboxContent {
|
|
|
7
7
|
filteredOptions: ComboboxOption[];
|
|
8
8
|
optionsListRef: React.RefObject<HTMLUListElement>;
|
|
9
9
|
selectedOptions: ComboboxOption[];
|
|
10
|
-
|
|
10
|
+
optionsSelectionHandler: (selected: ComboboxOption[]) => void;
|
|
11
11
|
}
|
|
12
|
-
export declare function useComboboxContent(options: ComboboxOption[], open: boolean, selected: ComboboxOption[], onClose: ((selection: ComboboxOption[]) => void) | undefined): useComboboxContent;
|
|
12
|
+
export declare function useComboboxContent(options: ComboboxOption[], open: boolean, selected: ComboboxOption[], onClose: ((selection: ComboboxOption[]) => void) | undefined, onSelect: ((selection: ComboboxOption[]) => void) | undefined): useComboboxContent;
|
|
13
13
|
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
export declare const COMBOBOX_TRIGGER_COUNT_ERROR_MESSAGE = "Combobox can only have one Trigger element";
|
|
3
|
+
export declare const COMBOBOX_REQUIRED_CHILDREN_ERROR_MESSAGE = "Combobox must have a Trigger and Combobox.Content element";
|
|
4
|
+
export declare function useComboboxValidation(children: ReactNode): {
|
|
5
|
+
triggerElement: ReactNode;
|
|
6
|
+
contentElement: ReactNode;
|
|
7
|
+
};
|
package/dist/Combobox/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { Combobox
|
|
1
|
+
export { Combobox } from "./Combobox";
|
|
2
2
|
export { ComboboxContextProvider } from "./ComboboxProvider";
|
|
3
|
-
export { ComboboxOption } from "./Combobox.types";
|
|
3
|
+
export { ComboboxOption, ComboboxProps } from "./Combobox.types";
|
package/dist/Combobox/index.js
CHANGED
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var useAssert = require('@jobber/hooks/useAssert');
|
|
7
6
|
var classnames = require('classnames');
|
|
8
7
|
var ReactDOM = require('react-dom');
|
|
9
8
|
var styleInject_es = require('../style-inject.es-9d2f5f4e.js');
|
|
10
9
|
var Icon = require('../Icon-405a216c.js');
|
|
11
10
|
var Text = require('../Text-54334431.js');
|
|
11
|
+
var Typography = require('../Typography-83915c54.js');
|
|
12
|
+
var Button = require('../Button-db6114a6.js');
|
|
12
13
|
var useRefocusOnActivator = require('@jobber/hooks/useRefocusOnActivator');
|
|
13
14
|
var useFocusTrap = require('@jobber/hooks/useFocusTrap');
|
|
14
15
|
var reactPopper = require('react-popper');
|
|
15
16
|
var useOnKeyDown = require('@jobber/hooks/useOnKeyDown');
|
|
16
|
-
var
|
|
17
|
-
var Button = require('../Button-db6114a6.js');
|
|
17
|
+
var useAssert = require('@jobber/hooks/useAssert');
|
|
18
18
|
require('@jobber/design');
|
|
19
19
|
require('react-router-dom');
|
|
20
20
|
|
|
@@ -24,15 +24,15 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
24
24
|
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
25
25
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
26
26
|
|
|
27
|
-
var css_248z$
|
|
28
|
-
var styles$
|
|
29
|
-
styleInject_es.styleInject(css_248z$
|
|
27
|
+
var css_248z$6 = ".m1w5vdUZ6rQ- {\n z-index: 1002;\n z-index: var(--elevation-tooltip);\n max-width: var(--popover--width);\n min-width: calc((16px * 4) * 3.75);\n min-width: calc(calc(16px * 4) * 3.75);\n min-width: calc(var(--space-extravagant) * 3.75);\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 margin-top: calc(16px / 2);\n margin-top: var(--space-small);\n border: calc(16px / 16) solid rgb(225, 225, 225);\n border: var(--border-base) solid var(--color-border);\n border-radius: calc(16px / 2);\n border-radius: var(--radius-larger);\n overflow: scroll;\n overflow-y: auto;\n background: rgba(255, 255, 255, 1);\n background: var(--color-surface);\n}\n\n/* CAUTION: Tests for content visibility assume this class' presence hides the content\n* so please be careful if you change this class name, or the css rules within.\n*/\n\n.m1w5vdUZ6rQ-.Zlkv2HA096A- {\n display: none;\n visibility: hidden;\n}\n\n.YQry-Rd6zfQ- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-direction: column;\n flex-direction: column;\n position: sticky;\n gap: calc(16px / 4);\n gap: var(--space-smaller);\n bottom: 0;\n width: 100%;\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n}\n\n.TcpqL34s4lI- {\n padding-bottom: calc(16px / 2);\n padding-bottom: var(--space-small);\n}\n";
|
|
28
|
+
var styles$6 = {"content":"m1w5vdUZ6rQ-","hidden":"Zlkv2HA096A-","actions":"YQry-Rd6zfQ-","actionPadding":"TcpqL34s4lI-"};
|
|
29
|
+
styleInject_es.styleInject(css_248z$6);
|
|
30
30
|
|
|
31
|
-
var css_248z$
|
|
32
|
-
var styles$
|
|
33
|
-
styleInject_es.styleInject(css_248z$
|
|
31
|
+
var css_248z$5 = ".MIyb-oFZg9w- {\n position: relative;\n}\n\n.WZPK91I4aJs- {\n width: 100%;\n padding: calc(16px * 1);\n padding: var(--space-base);\n padding-right: calc((16px * 1.5) * 2.25);\n padding-right: calc(calc(16px * 1.5) * 2.25);\n padding-right: calc(var(--space-large) * 2.25);\n border: none;\n border-bottom: calc(16px / 16) solid rgb(225, 225, 225);\n border-bottom: var(--border-base) solid var(--color-border);\n font-family: \"Inter\", Helvetica, Arial, sans-serif;\n font-family: var(--typography--fontFamily-normal);\n font-size: calc((16px * 1) * 0.875);\n font-size: calc(calc(16px * 1) * 0.875);\n font-size: var(--typography--fontSize-base);\n}\n\n._7loHrVUe-Rk- {\n position: absolute;\n top: 50%;\n right: calc(16px * 1);\n right: var(--space-base);\n z-index: 1002;\n z-index: var(--elevation-tooltip);\n width: calc(16px * 1.5);\n width: var(--space-large);\n height: calc(16px * 1.5);\n height: var(--space-large);\n padding: 0;\n border: none;\n border-radius: 100%;\n border-radius: var(--radius-circle);\n background-color: rgb(244, 244, 244);\n background-color: var(--color-surface--background);\n cursor: pointer;\n -webkit-transform: translateY(-50%);\n transform: translateY(-50%);\n}\n\n._7loHrVUe-Rk-:focus {\n box-shadow: 0px 0px calc(16px / 4) calc(16px / 8)\n rgb(231, 213, 87);\n box-shadow: var(--shadow-focus);\n}\n";
|
|
32
|
+
var styles$5 = {"search":"MIyb-oFZg9w-","searchInput":"WZPK91I4aJs-","clearSearch":"_7loHrVUe-Rk-"};
|
|
33
|
+
styleInject_es.styleInject(css_248z$5);
|
|
34
34
|
|
|
35
|
-
function
|
|
35
|
+
function ComboboxContentSearch(props) {
|
|
36
36
|
const searchRef = React.useRef(null);
|
|
37
37
|
React.useEffect(() => {
|
|
38
38
|
if (props.open) {
|
|
@@ -42,9 +42,9 @@ function ComboboxSearch(props) {
|
|
|
42
42
|
}, 0);
|
|
43
43
|
}
|
|
44
44
|
}, [props.open]);
|
|
45
|
-
return (React__default["default"].createElement("div", { className: styles$
|
|
46
|
-
React__default["default"].createElement("input", { type: "search", ref: searchRef, className: styles$
|
|
47
|
-
props.searchValue && (React__default["default"].createElement("button", { className: styles$
|
|
45
|
+
return (React__default["default"].createElement("div", { className: styles$5.search },
|
|
46
|
+
React__default["default"].createElement("input", { type: "search", ref: searchRef, className: styles$5.searchInput, placeholder: props.placeholder ? `Search ${props.placeholder}` : "Search", onChange: (event) => handleSearch(event), value: props.searchValue }),
|
|
47
|
+
props.searchValue && (React__default["default"].createElement("button", { className: styles$5.clearSearch, onClick: clearSearch, type: "button", "data-testid": "ATL-Combobox-Content-Search-Clear", "aria-label": "Clear search" },
|
|
48
48
|
React__default["default"].createElement(Icon.Icon, { name: "remove", size: "small" })))));
|
|
49
49
|
function clearSearch() {
|
|
50
50
|
var _a;
|
|
@@ -56,14 +56,14 @@ function ComboboxSearch(props) {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
var css_248z$
|
|
60
|
-
var styles$
|
|
61
|
-
styleInject_es.styleInject(css_248z$
|
|
59
|
+
var css_248z$4 = ".SgMzjOcdE-E- {\n position: relative;\n padding: calc(16px / 2) 0;\n padding: var(--space-small) 0;\n}\n\n.TwoTCjgcssc- {\n display: -ms-flexbox;\n display: flex;\n max-height: calc((16px / 2) * 33.33);\n max-height: calc(calc(16px / 2) * 33.33);\n max-height: calc(var(--space-small) * 33.33);\n margin: 0;\n padding: 0;\n overflow: scroll;\n list-style: none;\n -ms-flex-direction: column;\n flex-direction: column;\n gap: calc(16px / 4);\n gap: var(--space-smaller);\n}\n\n._2LVD-wjMRfQ- {\n display: -ms-flexbox;\n display: flex;\n min-height: calc((calc(16px * 3) - calc(16px / 4)));\n min-height: calc((var(--space-largest) - var(--space-smaller)));\n box-sizing: border-box;\n margin: 0 calc(16px / 2);\n margin: 0 var(--space-small);\n padding: calc(16px / 2);\n padding: var(--space-small);\n border-radius: calc(16px / 4);\n border-radius: var(--radius-large);\n color: rgb(1, 41, 57);\n color: var(--color-heading);\n font-weight: 500;\n cursor: pointer;\n transition: all 200ms;\n transition: all var(--timing-base);\n -ms-flex-pack: justify;\n justify-content: space-between;\n -ms-flex-align: center;\n align-items: center;\n}\n\n._2LVD-wjMRfQ-:hover,\n._2LVD-wjMRfQ-:focus {\n background-color: rgb(244, 244, 244);\n background-color: var(--color-surface--background);\n}\n\n._2LVD-wjMRfQ-:focus {\n box-shadow: 0px 0px calc(16px / 4) calc(16px / 8)\n rgb(231, 213, 87);\n box-shadow: var(--shadow-focus);\n}\n\n._8T5M7MGwCRE-,\n._4y5NXkNeIQM- {\n padding: calc(16px / 2) calc(16px * 1);\n padding: var(--space-small) var(--space-base);\n}\n\n.SgMzjOcdE-E-::after {\n content: \"\";\n display: block;\n position: absolute;\n right: 0;\n bottom: calc(16px / 2);\n bottom: var(--space-small);\n left: 0;\n height: calc(16px * 1);\n height: var(--space-base);\n background: linear-gradient(\n 180deg,\n rgba(255, 255, 255, 0) 0%,\n rgb(255, 255, 255) 100%\n );\n}\n\n.SgMzjOcdE-E-::before {\n content: \"\";\n display: block;\n position: absolute;\n top: calc(16px / 2);\n top: var(--space-small);\n right: 0;\n left: 0;\n height: calc(16px * 1);\n height: var(--space-base);\n background: linear-gradient(\n to bottom,\n rgba(255, 255, 255, 1),\n rgba(255, 255, 255, 0)\n );\n}\n";
|
|
60
|
+
var styles$4 = {"container":"SgMzjOcdE-E-","optionsList":"TwoTCjgcssc-","option":"_2LVD-wjMRfQ-","filterMessage":"_8T5M7MGwCRE-","emptyStateMessage":"_4y5NXkNeIQM-"};
|
|
61
|
+
styleInject_es.styleInject(css_248z$4);
|
|
62
62
|
|
|
63
|
-
function
|
|
63
|
+
function ComboboxContentList(props) {
|
|
64
64
|
let hasSeenFirstSelected = false;
|
|
65
|
-
return (React__default["default"].createElement("div", { className: styles$
|
|
66
|
-
!props.showEmptyState && props.options.length > 0 && (React__default["default"].createElement("ul", { className: styles$
|
|
65
|
+
return (React__default["default"].createElement("div", { className: styles$4.container },
|
|
66
|
+
!props.showEmptyState && props.options.length > 0 && (React__default["default"].createElement("ul", { className: styles$4.optionsList, role: "listbox", "aria-multiselectable": props.multiselect, ref: props.optionsListRef }, !props.showEmptyState &&
|
|
67
67
|
props.options.map(option => {
|
|
68
68
|
const isSelected = props.selected.some(selection => selection.id.toString() === option.id.toString());
|
|
69
69
|
return (React__default["default"].createElement("li", { ref: listItem => {
|
|
@@ -71,15 +71,15 @@ function ComboboxList(props) {
|
|
|
71
71
|
props.setFirstSelectedElement(listItem);
|
|
72
72
|
hasSeenFirstSelected = true;
|
|
73
73
|
}
|
|
74
|
-
}, key: option.id, tabIndex: -1, role: "option", "aria-selected": isSelected, onClick: () => props.selectionHandler(option), className: classnames__default["default"](styles$
|
|
74
|
+
}, key: option.id, tabIndex: -1, role: "option", "aria-selected": isSelected, onClick: () => props.selectionHandler(option), className: classnames__default["default"](styles$4.option) },
|
|
75
75
|
option.label,
|
|
76
76
|
isSelected && React__default["default"].createElement(Icon.Icon, { name: "checkmark", color: "blue" })));
|
|
77
77
|
}))),
|
|
78
|
-
!props.showEmptyState && props.options.length === 0 && (React__default["default"].createElement("div", { className: styles$
|
|
78
|
+
!props.showEmptyState && props.options.length === 0 && (React__default["default"].createElement("div", { className: styles$4.filterMessage },
|
|
79
79
|
React__default["default"].createElement(Text.Text, { variation: "subdued" },
|
|
80
80
|
"No results for ",
|
|
81
81
|
`“${props.searchValue}”`))),
|
|
82
|
-
props.showEmptyState && (React__default["default"].createElement("div", { className: styles$
|
|
82
|
+
props.showEmptyState && (React__default["default"].createElement("div", { className: styles$4.emptyStateMessage },
|
|
83
83
|
React__default["default"].createElement(Text.Text, { variation: "subdued" }, getZeroIndexStateText(props.subjectNoun))))));
|
|
84
84
|
}
|
|
85
85
|
function getZeroIndexStateText(subjectNoun) {
|
|
@@ -89,6 +89,30 @@ function getZeroIndexStateText(subjectNoun) {
|
|
|
89
89
|
return "No options yet";
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
var css_248z$3 = ".Q-mwo-g5Fi8- {\n display: -ms-flexbox;\n display: flex;\n padding: calc(16px * 1) calc(16px / 2) 0 calc(16px * 1);\n padding: var(--space-base) var(--space-small) 0 var(--space-base);\n -ms-flex-pack: justify;\n justify-content: space-between;\n gap: calc(16px / 4);\n gap: var(--space-smaller);\n}\n";
|
|
93
|
+
var styles$3 = {"header":"Q-mwo-g5Fi8-"};
|
|
94
|
+
styleInject_es.styleInject(css_248z$3);
|
|
95
|
+
|
|
96
|
+
function ComboboxContentHeader(props) {
|
|
97
|
+
const hasSelected = props.selectedCount > 0;
|
|
98
|
+
const actionLabel = hasSelected ? "Clear" : "Select all";
|
|
99
|
+
const label = getLabel(hasSelected, props.selectedCount, props.subjectNoun);
|
|
100
|
+
const handleSelectAll = hasSelected ? props.onClearAll : props.onSelectAll;
|
|
101
|
+
const showAction = hasSelected || props.hasOptionsVisible;
|
|
102
|
+
return (React__default["default"].createElement("div", { className: styles$3.header, "data-testid": "ATL-Combobox-Header" },
|
|
103
|
+
React__default["default"].createElement(Typography.Typography, { textColor: "heading", fontWeight: "semiBold" }, label),
|
|
104
|
+
showAction && (React__default["default"].createElement(Button.Button, { size: "small", label: actionLabel, type: "tertiary", onClick: handleSelectAll }))));
|
|
105
|
+
}
|
|
106
|
+
function getLabel(hasSelected, count, subjectNoun) {
|
|
107
|
+
if (hasSelected) {
|
|
108
|
+
return `${count} selected`;
|
|
109
|
+
}
|
|
110
|
+
if (subjectNoun) {
|
|
111
|
+
return `Select ${subjectNoun}`;
|
|
112
|
+
}
|
|
113
|
+
return "Select";
|
|
114
|
+
}
|
|
115
|
+
|
|
92
116
|
var css_248z$2 = ".W8qMZnORYxI- {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: 6;\n z-index: var(--elevation-menu);\n background-color: transparent;\n}\n";
|
|
93
117
|
var styles$2 = {"overlay":"W8qMZnORYxI-"};
|
|
94
118
|
styleInject_es.styleInject(css_248z$2);
|
|
@@ -104,13 +128,14 @@ function ComboboxContextProvider(props) {
|
|
|
104
128
|
props.children)));
|
|
105
129
|
}
|
|
106
130
|
|
|
107
|
-
function useComboboxContent(options, open, selected, onClose) {
|
|
131
|
+
function useComboboxContent(options, open, selected, onClose, onSelect) {
|
|
108
132
|
const [searchValue, setSearchValue] = React.useState("");
|
|
109
133
|
const [firstSelectedElement, setFirstSelectedElement] = React.useState(null);
|
|
110
134
|
const optionsListRef = React.useRef(null);
|
|
111
135
|
const filteredOptions = options.filter(option => option.label.toLowerCase().includes(searchValue.toLowerCase()));
|
|
112
136
|
const [internalSelected, setInternalSelected] = React.useState(selected);
|
|
113
137
|
const selectedOptions = onClose ? internalSelected : selected;
|
|
138
|
+
const optionsSelectionHandler = onSelect ? onSelect : setInternalSelected;
|
|
114
139
|
React.useEffect(() => {
|
|
115
140
|
if (!open && onClose) {
|
|
116
141
|
onClose(selectedOptions);
|
|
@@ -135,7 +160,7 @@ function useComboboxContent(options, open, selected, onClose) {
|
|
|
135
160
|
filteredOptions,
|
|
136
161
|
optionsListRef,
|
|
137
162
|
selectedOptions,
|
|
138
|
-
|
|
163
|
+
optionsSelectionHandler,
|
|
139
164
|
};
|
|
140
165
|
}
|
|
141
166
|
|
|
@@ -218,24 +243,26 @@ function useComboboxAccessibility(selectionCallback, filteredOptions, optionsLis
|
|
|
218
243
|
function ComboboxContent(props) {
|
|
219
244
|
const { open, setOpen, wrapperRef, multiselect } = React__default["default"].useContext(ComboboxContext);
|
|
220
245
|
const optionsExist = props.options.length > 0;
|
|
221
|
-
const { searchValue, setSearchValue, setFirstSelectedElement, filteredOptions, optionsListRef, selectedOptions,
|
|
246
|
+
const { searchValue, setSearchValue, setFirstSelectedElement, filteredOptions, optionsListRef, selectedOptions, optionsSelectionHandler, } = useComboboxContent(props.options, open, props.selected, props.onClose, props.onSelect);
|
|
222
247
|
const { popperRef, popperStyles, attributes } = useComboboxAccessibility(handleSelection, filteredOptions, optionsListRef, open, setOpen, wrapperRef);
|
|
223
|
-
const template = (React__default["default"].createElement("div", Object.assign({ ref: popperRef, id: "ATL-Combobox-Content", "data-testid": "ATL-Combobox-Content", tabIndex: 0, className: classnames__default["default"](styles$
|
|
224
|
-
React__default["default"].createElement(
|
|
225
|
-
React__default["default"].createElement(
|
|
226
|
-
|
|
227
|
-
|
|
248
|
+
const template = (React__default["default"].createElement("div", Object.assign({ ref: popperRef, id: "ATL-Combobox-Content", "data-testid": "ATL-Combobox-Content", tabIndex: 0, className: classnames__default["default"](styles$6.content, { [styles$6.hidden]: !open }), style: popperStyles.popper }, attributes.popper),
|
|
249
|
+
React__default["default"].createElement(ComboboxContentSearch, { open: open, placeholder: props.subjectNoun, searchValue: searchValue, setSearchValue: setSearchValue }),
|
|
250
|
+
multiselect && optionsExist && (React__default["default"].createElement(ComboboxContentHeader, { hasOptionsVisible: filteredOptions.length > 0, subjectNoun: props.subjectNoun, selectedCount: selectedOptions.length, onClearAll: () => {
|
|
251
|
+
optionsSelectionHandler([]);
|
|
252
|
+
}, onSelectAll: () => {
|
|
253
|
+
optionsSelectionHandler(filteredOptions);
|
|
254
|
+
} })),
|
|
255
|
+
React__default["default"].createElement(ComboboxContentList, { multiselect: multiselect, showEmptyState: !optionsExist, options: filteredOptions, selected: selectedOptions, optionsListRef: optionsListRef, setFirstSelectedElement: setFirstSelectedElement, selectionHandler: handleSelection, searchValue: searchValue, subjectNoun: props.subjectNoun }),
|
|
256
|
+
props.children && (React__default["default"].createElement("div", { className: styles$6.actions, role: "group" }, React__default["default"].Children.toArray(props.children).map((child, index, childrenArray) => (React__default["default"].createElement("div", { key: index, className: classnames__default["default"]({
|
|
257
|
+
[styles$6.actionPadding]: index === childrenArray.length - 1,
|
|
228
258
|
}) }, child)))))));
|
|
229
259
|
return ReactDOM__default["default"].createPortal(template, document.body);
|
|
230
260
|
function handleSelection(selection) {
|
|
231
|
-
const callbackHandler = props.onSelect
|
|
232
|
-
? props.onSelect
|
|
233
|
-
: setInternalSelected;
|
|
234
261
|
if (multiselect) {
|
|
235
|
-
handleMultiSelect(
|
|
262
|
+
handleMultiSelect(optionsSelectionHandler, selectedOptions, selection);
|
|
236
263
|
}
|
|
237
264
|
else {
|
|
238
|
-
handleSingleSelect(
|
|
265
|
+
handleSingleSelect(optionsSelectionHandler, selection);
|
|
239
266
|
}
|
|
240
267
|
}
|
|
241
268
|
function handleSingleSelect(selectCallback, selection) {
|
|
@@ -284,12 +311,6 @@ function ComboboxTriggerChip(props) {
|
|
|
284
311
|
|
|
285
312
|
const COMBOBOX_TRIGGER_COUNT_ERROR_MESSAGE = "Combobox can only have one Trigger element";
|
|
286
313
|
const COMBOBOX_REQUIRED_CHILDREN_ERROR_MESSAGE = "Combobox must have a Trigger and Combobox.Content element";
|
|
287
|
-
const Combobox = (props) => {
|
|
288
|
-
const { contentElement, triggerElement } = useComboboxValidation(props.children);
|
|
289
|
-
return (React__default["default"].createElement(ComboboxContextProvider, { multiselect: props.multiSelect },
|
|
290
|
-
triggerElement,
|
|
291
|
-
contentElement));
|
|
292
|
-
};
|
|
293
314
|
function useComboboxValidation(children) {
|
|
294
315
|
const childrenArray = React__default["default"].Children.toArray(children);
|
|
295
316
|
let triggerElement, contentElement, multipleTriggersFound = false;
|
|
@@ -318,12 +339,17 @@ function isTriggerElement(child) {
|
|
|
318
339
|
function isContentElement(child) {
|
|
319
340
|
return React__default["default"].isValidElement(child) && child.type === ComboboxContent;
|
|
320
341
|
}
|
|
342
|
+
|
|
343
|
+
const Combobox = (props) => {
|
|
344
|
+
const { contentElement, triggerElement } = useComboboxValidation(props.children);
|
|
345
|
+
return (React__default["default"].createElement(ComboboxContextProvider, { multiselect: props.multiSelect },
|
|
346
|
+
triggerElement,
|
|
347
|
+
contentElement));
|
|
348
|
+
};
|
|
321
349
|
Combobox.TriggerButton = ComboboxTriggerButton;
|
|
322
350
|
Combobox.TriggerChip = ComboboxTriggerChip;
|
|
323
351
|
Combobox.Content = ComboboxContent;
|
|
324
352
|
Combobox.Action = ComboboxAction;
|
|
325
353
|
|
|
326
|
-
exports.COMBOBOX_REQUIRED_CHILDREN_ERROR_MESSAGE = COMBOBOX_REQUIRED_CHILDREN_ERROR_MESSAGE;
|
|
327
|
-
exports.COMBOBOX_TRIGGER_COUNT_ERROR_MESSAGE = COMBOBOX_TRIGGER_COUNT_ERROR_MESSAGE;
|
|
328
354
|
exports.Combobox = Combobox;
|
|
329
355
|
exports.ComboboxContextProvider = ComboboxContextProvider;
|
|
@@ -8,6 +8,7 @@ import { DataListAction } from "./components/DataListAction";
|
|
|
8
8
|
import { DataListLayoutActions } from "./components/DataListLayoutActions";
|
|
9
9
|
import { DataListBulkActionProps, DataListObject, DataListProps } from "./DataList.types";
|
|
10
10
|
import { DataListBulkActions } from "./components/DataListBulkActions";
|
|
11
|
+
import { DataListStatusBar } from "./components/DataListStatusBar";
|
|
11
12
|
export declare function DataList<T extends DataListObject>({ selected, sorting, ...props }: DataListProps<T>): JSX.Element;
|
|
12
13
|
export declare namespace DataList {
|
|
13
14
|
var Layout: typeof DataListLayout;
|
|
@@ -19,5 +20,5 @@ export declare namespace DataList {
|
|
|
19
20
|
var BulkActions: typeof DataListBulkActions;
|
|
20
21
|
var ItemAction: typeof DataListAction;
|
|
21
22
|
var BatchAction: (props: DataListBulkActionProps) => JSX.Element;
|
|
22
|
-
var
|
|
23
|
+
var StatusBar: typeof DataListStatusBar;
|
|
23
24
|
}
|
|
@@ -158,7 +158,6 @@ export interface DataListContextProps<T extends DataListObject> extends DataList
|
|
|
158
158
|
readonly layoutComponents?: ReactElement<DataListLayoutProps<T>>[];
|
|
159
159
|
readonly itemActionComponent?: ReactElement<DataListItemActionsProps<T>>;
|
|
160
160
|
readonly bulkActionsComponent?: ReactElement<DataListItemActionsProps<T>>;
|
|
161
|
-
readonly bannerComponent?: ReactElement;
|
|
162
161
|
readonly layoutBreakpoints: Breakpoints[];
|
|
163
162
|
readonly registerLayoutBreakpoints: (breakpoint: Breakpoints) => void;
|
|
164
163
|
readonly layouts: {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
interface DataListStatusBarProps {
|
|
3
|
+
readonly children: ReactElement | ReactElement[];
|
|
4
|
+
}
|
|
5
|
+
export declare function DataListStatusBar(_: DataListStatusBarProps): null;
|
|
6
|
+
/**
|
|
7
|
+
* Renders the DataList.StatusBar component
|
|
8
|
+
*/
|
|
9
|
+
export declare function InternalDataListStatusBar(): JSX.Element | null;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./DataListStatusBar";
|
package/dist/DataList/index.js
CHANGED
|
@@ -37,7 +37,6 @@ var debounce = require('lodash/debounce');
|
|
|
37
37
|
var InputText = require('../InputText-ab237501.js');
|
|
38
38
|
var Spinner = require('../Spinner-9d8fc7ff.js');
|
|
39
39
|
var Icon = require('../Icon-405a216c.js');
|
|
40
|
-
var Banner = require('../Banner-ecd9a7cf.js');
|
|
41
40
|
require('uuid');
|
|
42
41
|
require('react-hook-form');
|
|
43
42
|
require('../ButtonDismiss-1ccb84ec.js');
|
|
@@ -45,7 +44,6 @@ require('lodash/sortBy');
|
|
|
45
44
|
require('@jobber/hooks/useLiveAnnounce');
|
|
46
45
|
require('../FormField-fa9254dc.js');
|
|
47
46
|
require('../InputValidation-377d6c62.js');
|
|
48
|
-
require('@jobber/hooks/useResizeObserver');
|
|
49
47
|
|
|
50
48
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
51
49
|
|
|
@@ -989,6 +987,23 @@ function DataListLayoutActionsWrapper({ children }) {
|
|
|
989
987
|
return React__default["default"].createElement("div", { className: styles.hidden }, children);
|
|
990
988
|
}
|
|
991
989
|
|
|
990
|
+
// This component is meant to capture the props of the DataList.Filters
|
|
991
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
992
|
+
function DataListStatusBar(_) {
|
|
993
|
+
return null;
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* Renders the DataList.StatusBar component
|
|
997
|
+
*/
|
|
998
|
+
function InternalDataListStatusBar() {
|
|
999
|
+
const { children: parentChildren } = useDataListContext();
|
|
1000
|
+
const component = getCompoundComponent(parentChildren, DataListStatusBar);
|
|
1001
|
+
if (!component)
|
|
1002
|
+
return null;
|
|
1003
|
+
const children = component === null || component === void 0 ? void 0 : component.props.children;
|
|
1004
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null, children && children);
|
|
1005
|
+
}
|
|
1006
|
+
|
|
992
1007
|
function DataList(_a) {
|
|
993
1008
|
var { selected = [], sorting } = _a, props = tslib_es6.__rest(_a, ["selected", "sorting"]);
|
|
994
1009
|
const [layoutBreakpoints, setLayoutBreakpoints] = React.useState([]);
|
|
@@ -999,14 +1014,12 @@ function DataList(_a) {
|
|
|
999
1014
|
const emptyStateComponents = getCompoundComponents(props.children, DataListEmptyState);
|
|
1000
1015
|
const itemActionComponent = getCompoundComponent(props.children, DataListItemActions);
|
|
1001
1016
|
const bulkActionsComponent = getCompoundComponent(props.children, DataListBulkActions);
|
|
1002
|
-
const bannerComponent = getCompoundComponent(props.children, Banner.Banner);
|
|
1003
1017
|
return (React__default["default"].createElement(DataListContext.Provider, { value: Object.assign(Object.assign({ searchComponent,
|
|
1004
1018
|
filterComponent,
|
|
1005
1019
|
layoutComponents,
|
|
1006
1020
|
emptyStateComponents,
|
|
1007
1021
|
itemActionComponent,
|
|
1008
1022
|
bulkActionsComponent,
|
|
1009
|
-
bannerComponent,
|
|
1010
1023
|
layoutBreakpoints,
|
|
1011
1024
|
registerLayoutBreakpoints,
|
|
1012
1025
|
layouts,
|
|
@@ -1022,7 +1035,7 @@ function DataList(_a) {
|
|
|
1022
1035
|
}
|
|
1023
1036
|
}
|
|
1024
1037
|
function InternalDataList() {
|
|
1025
|
-
const { data, title, totalCount, loadingState = "none", layoutComponents,
|
|
1038
|
+
const { data, title, totalCount, loadingState = "none", layoutComponents, } = useDataListContext();
|
|
1026
1039
|
const backToTopRef = React.useRef(null);
|
|
1027
1040
|
const initialLoading = loadingState === "initial";
|
|
1028
1041
|
const showEmptyState = !initialLoading && data.length === 0;
|
|
@@ -1036,7 +1049,7 @@ function InternalDataList() {
|
|
|
1036
1049
|
React__default["default"].createElement("div", { className: styles$e.headerFilters },
|
|
1037
1050
|
React__default["default"].createElement(InternalDataListFilters, null),
|
|
1038
1051
|
React__default["default"].createElement(InternalDataListSearch, null)),
|
|
1039
|
-
|
|
1052
|
+
React__default["default"].createElement(InternalDataListStatusBar, null),
|
|
1040
1053
|
React__default["default"].createElement(DataListHeader, null)),
|
|
1041
1054
|
initialLoading && React__default["default"].createElement(DataListLoadingState, null),
|
|
1042
1055
|
showEmptyState && React__default["default"].createElement(InternalDataListEmptyState, null),
|
|
@@ -1106,6 +1119,6 @@ DataList.BatchAction = function DataListBatchAction(props) {
|
|
|
1106
1119
|
/**
|
|
1107
1120
|
* Defines a banner that is going to rendered between the filters and the header.
|
|
1108
1121
|
*/
|
|
1109
|
-
DataList.
|
|
1122
|
+
DataList.StatusBar = DataListStatusBar;
|
|
1110
1123
|
|
|
1111
1124
|
exports.DataList = DataList;
|
|
@@ -7,51 +7,51 @@ export interface DataTableProps<T> {
|
|
|
7
7
|
* Typescript should infer T from typeof data.
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
|
-
data: T[];
|
|
10
|
+
readonly data: T[];
|
|
11
11
|
/**
|
|
12
12
|
* Should follow the @tanstack/react-table [ColumnDef](https://tanstack.com/table/v8/docs/guide/column-defs).
|
|
13
13
|
* [createColumnHelper](https://tanstack.com/table/v8/docs/guide/column-defs#column-helpers) is also exposed to make it more convenient
|
|
14
14
|
* to create columns.
|
|
15
15
|
*/
|
|
16
|
-
columns: ColumnDef<T>[];
|
|
16
|
+
readonly columns: ColumnDef<T>[];
|
|
17
17
|
/**
|
|
18
18
|
* Enables pagination, mostly follows:
|
|
19
19
|
* https://tanstack.com/table/v8/docs/api/features/pagination
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
|
-
pagination?: PaginationType;
|
|
22
|
+
readonly pagination?: PaginationType;
|
|
23
23
|
/**
|
|
24
24
|
* Enables sorting, mostly follows:
|
|
25
25
|
* https://tanstack.com/table/v8/docs/api/features/sorting#table-options
|
|
26
26
|
*
|
|
27
27
|
*/
|
|
28
|
-
sorting?: SortingType;
|
|
28
|
+
readonly sorting?: SortingType;
|
|
29
29
|
/**
|
|
30
30
|
* This will force the table to have the specified hight
|
|
31
31
|
*
|
|
32
32
|
*/
|
|
33
|
-
height?: number;
|
|
33
|
+
readonly height?: number;
|
|
34
34
|
/**
|
|
35
35
|
* When set to true makes the header sticky while scrolling vertically
|
|
36
36
|
*
|
|
37
37
|
*/
|
|
38
|
-
stickyHeader?: boolean;
|
|
38
|
+
readonly stickyHeader?: boolean;
|
|
39
39
|
/**
|
|
40
40
|
* Pins the firstColumn when scrolling horizontally
|
|
41
41
|
*
|
|
42
42
|
*/
|
|
43
|
-
pinFirstColumn?: boolean;
|
|
43
|
+
readonly pinFirstColumn?: boolean;
|
|
44
44
|
/**
|
|
45
45
|
* Enables row click action. The provided callback will be executed when the row is clicked.
|
|
46
46
|
*/
|
|
47
|
-
onRowClick?: (row: Row<T>) => void;
|
|
47
|
+
readonly onRowClick?: (row: Row<T>) => void;
|
|
48
48
|
/**
|
|
49
49
|
* The elements to display when the data table is empty
|
|
50
50
|
*/
|
|
51
|
-
emptyState?: ReactNode | ReactNode[];
|
|
51
|
+
readonly emptyState?: ReactNode | ReactNode[];
|
|
52
52
|
/**
|
|
53
53
|
* When true, shows the loading state of the DataTable
|
|
54
54
|
*/
|
|
55
|
-
loading?: boolean;
|
|
55
|
+
readonly loading?: boolean;
|
|
56
56
|
}
|
|
57
57
|
export declare function DataTable<T extends object>({ data, columns, pagination, sorting, height, stickyHeader, pinFirstColumn, onRowClick, emptyState, loading, }: DataTableProps<T>): JSX.Element;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Table } from "@tanstack/react-table";
|
|
3
3
|
interface PaginationProps<T> {
|
|
4
|
-
table: Table<T>;
|
|
5
|
-
itemsPerPage?: number[];
|
|
6
|
-
totalItems: number;
|
|
7
|
-
loading: boolean;
|
|
4
|
+
readonly table: Table<T>;
|
|
5
|
+
readonly itemsPerPage?: number[];
|
|
6
|
+
readonly totalItems: number;
|
|
7
|
+
readonly loading: boolean;
|
|
8
|
+
readonly onPageChange: () => void;
|
|
8
9
|
}
|
|
9
|
-
export declare function Pagination<T extends object>({ table, itemsPerPage, totalItems, loading, }: PaginationProps<T>): JSX.Element;
|
|
10
|
+
export declare function Pagination<T extends object>({ table, itemsPerPage, totalItems, loading, onPageChange, }: PaginationProps<T>): JSX.Element;
|
|
10
11
|
export {};
|
package/dist/DataTable/index.js
CHANGED
|
@@ -138,7 +138,7 @@ var styles$2 = {"pagination":"zn0VRVhObt0-","paginationInfo":"_1d4uh90gfSI-","pa
|
|
|
138
138
|
styleInject_es.styleInject(css_248z$2);
|
|
139
139
|
|
|
140
140
|
const defaultItemsPerPageOptions = ["10", "20", "30", "40", "50"];
|
|
141
|
-
function Pagination({ table, itemsPerPage, totalItems, loading, }) {
|
|
141
|
+
function Pagination({ table, itemsPerPage, totalItems, loading, onPageChange, }) {
|
|
142
142
|
const { pageIndex, pageSize } = table.getState().pagination;
|
|
143
143
|
const totalRows = totalItems;
|
|
144
144
|
const firstPosition = pageIndex * pageSize + 1;
|
|
@@ -154,8 +154,14 @@ function Pagination({ table, itemsPerPage, totalItems, loading, }) {
|
|
|
154
154
|
}, size: "small" }, itemsPerPageOptions.map(numOfPages => (React__default["default"].createElement(Option.SelectOption, { key: numOfPages, value: numOfPages }, numOfPages)))),
|
|
155
155
|
React__default["default"].createElement("span", { className: styles$2.paginationSelectLabel }, "per page")),
|
|
156
156
|
React__default["default"].createElement("div", { className: styles$2.paginationButtons },
|
|
157
|
-
React__default["default"].createElement(Button.Button, { type: "secondary", variation: "subtle", icon: "arrowLeft", ariaLabel: "arrowLeft", onClick: () =>
|
|
158
|
-
|
|
157
|
+
React__default["default"].createElement(Button.Button, { type: "secondary", variation: "subtle", icon: "arrowLeft", ariaLabel: "arrowLeft", onClick: () => {
|
|
158
|
+
table.previousPage();
|
|
159
|
+
onPageChange();
|
|
160
|
+
}, disabled: !table.getCanPreviousPage() }),
|
|
161
|
+
React__default["default"].createElement(Button.Button, { type: "secondary", variation: "subtle", icon: "arrowRight", ariaLabel: "arrowRight", onClick: () => {
|
|
162
|
+
table.nextPage();
|
|
163
|
+
onPageChange();
|
|
164
|
+
}, disabled: !table.getCanNextPage() })))));
|
|
159
165
|
}
|
|
160
166
|
|
|
161
167
|
var css_248z$1 = "._0FexNr-lIgA- {\n padding: calc(16px * 1);\n padding: var(--space-base);\n border-top: calc(16px / 8) solid rgb(225, 225, 225);\n border-top: var(--border-thick) solid var(--color-border);\n}\n\n.PKlqQjoQ6DY- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-pack: justify;\n justify-content: space-between;\n font-weight: bold;\n}\n\n.PKlqQjoQ6DY- * {\n text-align: left;\n}\n\n.ItTcVYUbVNM-,\n.ItTcVYUbVNM- * {\n font-weight: normal;\n text-align: right;\n}\n\n.PKlqQjoQ6DY-:not(:last-child) {\n padding-bottom: calc(16px / 2);\n padding-bottom: var(--space-small);\n}\n";
|
|
@@ -255,7 +261,7 @@ function DataTable({ data, columns, pagination, sorting, height, stickyHeader, p
|
|
|
255
261
|
});
|
|
256
262
|
const table = reactTable.useReactTable(tableSettings);
|
|
257
263
|
return (React__default["default"].createElement("div", { className: styles$3.dataTableContainer },
|
|
258
|
-
React__default["default"].createElement("div", { className: styles$3.tableContainer, style: { height }, ref: ref },
|
|
264
|
+
React__default["default"].createElement("div", { "data-testid": "ATL-DataTable-Container", className: styles$3.tableContainer, style: { height }, ref: ref },
|
|
259
265
|
React__default["default"].createElement("table", { className: tableClasses },
|
|
260
266
|
React__default["default"].createElement(Header, { table: table, sorting: sorting, onRowClick: onRowClick, stickyHeader: stickyHeader }),
|
|
261
267
|
React__default["default"].createElement(Body, { table: table, onRowClick: onRowClick, emptyState: emptyState, loading: loading }),
|
|
@@ -267,7 +273,7 @@ function DataTable({ data, columns, pagination, sorting, height, stickyHeader, p
|
|
|
267
273
|
exactWidth <= jobberHooks.Breakpoints.small ? (React__default["default"].createElement(Footer, { table: table })) : null,
|
|
268
274
|
pagination && (React__default["default"].createElement(Pagination, { table: table, itemsPerPage: pagination.itemsPerPage, totalItems: pagination.manualPagination
|
|
269
275
|
? pagination.totalItems
|
|
270
|
-
: table.getCoreRowModel().rows.length, loading: loading }))));
|
|
276
|
+
: table.getCoreRowModel().rows.length, loading: loading, onPageChange: () => { var _a; return (_a = ref.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0); } }))));
|
|
271
277
|
}
|
|
272
278
|
|
|
273
279
|
const mockContainerWidth = (exactWidth) => {
|
package/dist/Tabs/Tabs.d.ts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import React, { ReactElement, ReactNode } from "react";
|
|
2
2
|
interface TabsProps {
|
|
3
3
|
readonly children: ReactElement | ReactElement[];
|
|
4
|
+
/**
|
|
5
|
+
* Specifies the index of the tab that should be active on mount
|
|
6
|
+
*
|
|
7
|
+
* @default 0
|
|
8
|
+
*/
|
|
9
|
+
readonly defaultTab?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Callback that fires when the active tab changes
|
|
12
|
+
* @param newTabIndex
|
|
13
|
+
*/
|
|
14
|
+
onTabChange?(newTabIndex: number): void;
|
|
4
15
|
}
|
|
5
|
-
export declare function Tabs({ children }: TabsProps): JSX.Element;
|
|
16
|
+
export declare function Tabs({ children, defaultTab, onTabChange }: TabsProps): JSX.Element;
|
|
6
17
|
interface TabProps {
|
|
7
18
|
readonly label: string;
|
|
8
19
|
readonly children: ReactNode | ReactNode[];
|
package/dist/Tabs/index.js
CHANGED
|
@@ -16,8 +16,9 @@ var css_248z = ":root {\n --tab--height: calc(var(--space-larger) + var(--space
|
|
|
16
16
|
var styles = {"tabs":"-kxlqXO5UN0-","overflow":"qI4lWMSNH40-","overflowRight":"xohIah5wcoE-","overflowLeft":"qnY4S9sz-8g-","tabRow":"wdW31G8Trag-","tab":"MO7CXQ8xJXo-","selected":"kqof65gyv7g-","tabContent":"AimQioztR1U-"};
|
|
17
17
|
styleInject_es.styleInject(css_248z);
|
|
18
18
|
|
|
19
|
-
function Tabs({ children }) {
|
|
20
|
-
const
|
|
19
|
+
function Tabs({ children, defaultTab = 0, onTabChange }) {
|
|
20
|
+
const activeTabInitialValue = defaultTab < React__default["default"].Children.count(children) ? defaultTab : 0;
|
|
21
|
+
const [activeTab, setActiveTab] = React.useState(activeTabInitialValue);
|
|
21
22
|
const [overflowRight, setOverflowRight] = React.useState(false);
|
|
22
23
|
const [overflowLeft, setOverflowLeft] = React.useState(false);
|
|
23
24
|
const tabRow = React.useRef();
|
|
@@ -28,6 +29,9 @@ function Tabs({ children }) {
|
|
|
28
29
|
const activateTab = (index) => {
|
|
29
30
|
return () => {
|
|
30
31
|
setActiveTab(index);
|
|
32
|
+
if (onTabChange) {
|
|
33
|
+
onTabChange(index);
|
|
34
|
+
}
|
|
31
35
|
};
|
|
32
36
|
};
|
|
33
37
|
const activeTabProps = React__default["default"].Children.toArray(children)[activeTab].props;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "4.49.2-JOB-80005.
|
|
3
|
+
"version": "4.49.2-JOB-80005.14+badd0e94",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "rollup --config",
|
|
9
9
|
"bootstrap": "npm run clean; npm run build",
|
|
10
|
-
"clean": "rm -rf dist/* tsconfig.tsbuildinfo",
|
|
10
|
+
"clean": "rm -rf dist/* tsconfig.rollup.tsbuildinfo",
|
|
11
11
|
"entryPoints:build": "ts-node --project ../../tsconfig.bin.json ../../scripts/entryPoints.ts",
|
|
12
12
|
"entryPoints:clean": "npm run entryPoints:build clean",
|
|
13
13
|
"prepack": "npm run entryPoints:build",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@jobber/design": "^0.46.0",
|
|
23
23
|
"@jobber/formatters": "^0.2.2",
|
|
24
|
-
"@jobber/hooks": "^2.6.
|
|
24
|
+
"@jobber/hooks": "^2.6.2-JOB-80005.14+badd0e94",
|
|
25
25
|
"@popperjs/core": "^2.0.6",
|
|
26
26
|
"@std-proposal/temporal": "0.0.1",
|
|
27
27
|
"@tanstack/react-table": "8.5.13",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@testing-library/jest-dom": "^5.16.5",
|
|
57
57
|
"@testing-library/react": "^14.0.0",
|
|
58
58
|
"@testing-library/react-hooks": "^7.0.2",
|
|
59
|
-
"@testing-library/user-event": "^
|
|
59
|
+
"@testing-library/user-event": "^14.5.1",
|
|
60
60
|
"@types/glob": "^7.1.1",
|
|
61
61
|
"@types/react": "^18.0.28",
|
|
62
62
|
"@types/react-dom": "^18.0.11",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"> 1%",
|
|
85
85
|
"IE 10"
|
|
86
86
|
],
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "badd0e9463cb1af5d3e51ac1c2f8afb3a5b21c61"
|
|
88
88
|
}
|
package/rollup.config.js
CHANGED
package/dist/Banner-ecd9a7cf.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
var classnames = require('classnames');
|
|
5
|
-
var jobberHooks = require('@jobber/hooks/useResizeObserver');
|
|
6
|
-
var styleInject_es = require('./style-inject.es-9d2f5f4e.js');
|
|
7
|
-
var Icon = require('./Icon-405a216c.js');
|
|
8
|
-
var Text = require('./Text-54334431.js');
|
|
9
|
-
var Button = require('./Button-db6114a6.js');
|
|
10
|
-
|
|
11
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
-
|
|
13
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
14
|
-
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
15
|
-
|
|
16
|
-
var css_248z$1 = ".meuT8gYQPJU- {\n display: -ms-flexbox;\n display: flex;\n position: relative;\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 padding: calc(16px * 1);\n padding: var(--space-base);\n color: rgb(66, 78, 86);\n color: var(--color-text);\n background-color: rgb(244, 244, 244);\n background-color: var(--color-surface--background);\n gap: calc(16px / 2);\n gap: var(--space-small);\n -ms-flex-align: center;\n align-items: center;\n}\n\n.y4BapyZr-fo- > a {\n color: rgb(66, 78, 86);\n color: var(--color-text);\n}\n\n.y4BapyZr-fo- > a:hover {\n color: rgb(1, 41, 57);\n color: var(--color-blue);\n}\n\n._6v1woNSLEvc- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n gap: calc(16px / 2);\n gap: var(--space-small);\n -ms-flex-wrap: nowrap;\n flex-wrap: nowrap;\n -ms-flex-pack: justify;\n justify-content: space-between;\n -ms-flex-align: start;\n align-items: flex-start;\n}\n\n@media (max-width: 489.98px) {\n\n._6v1woNSLEvc- {\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n}\n }\n\n@media (--small-screens-and-below) {\n\n._6v1woNSLEvc- {\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n}\n }\n\n.y4BapyZr-fo- {\n -ms-flex: 1;\n flex: 1;\n -ms-flex-item-align: center;\n align-self: center;\n}\n\n._6v1woNSLEvc- > *:last-child {\n margin-bottom: 0;\n}\n\n.bocgLmEhcTU- .y4BapyZr-fo- {\n -ms-flex: 1;\n flex: 1;\n}\n\n.rtNjEzmABX4- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex: 0 0 auto;\n flex: 0 0 auto;\n}\n\n@media (max-width: 489.98px) {\n\n.rtNjEzmABX4- {\n width: 100%;\n margin-top: calc(16px / 2);\n margin-top: var(--space-small);\n}\n }\n\n@media (--small-screens-and-below) {\n\n.rtNjEzmABX4- {\n width: 100%;\n margin-top: calc(16px / 2);\n margin-top: var(--space-small);\n}\n }\n\n.lunQ5SOfyLg- {\n margin: calc((16px / 8) * -1) 0;\n margin: calc(calc(16px / 8) * -1) 0;\n margin: calc(var(--space-smallest) * -1) 0;\n padding: calc(16px / 8);\n padding: var(--space-smallest);\n border: none;\n background-color: transparent;\n cursor: pointer;\n -webkit-appearance: none;\n appearance: none;\n -ms-flex: 0;\n flex: 0;\n -ms-flex-item-align: start;\n align-self: flex-start;\n}\n\n.lunQ5SOfyLg-:hover {\n background: rgba(0, 0, 0, 0.025);\n}\n\n.lunQ5SOfyLg-:focus {\n box-shadow: 0px 0px calc(16px / 4) calc(16px / 8)\n rgb(231, 213, 87);\n box-shadow: var(--shadow-focus);\n outline: none;\n background: rgba(0, 0, 0, 0.05);\n}\n";
|
|
17
|
-
var styles = {"banner":"meuT8gYQPJU-","bannerChildren":"y4BapyZr-fo-","bannerContent":"_6v1woNSLEvc-","medium":"bocgLmEhcTU-","bannerAction":"rtNjEzmABX4-","closeButton":"lunQ5SOfyLg-"};
|
|
18
|
-
styleInject_es.styleInject(css_248z$1);
|
|
19
|
-
|
|
20
|
-
var css_248z = ".wWW-2T7rCV0- {\n background-color: rgb(226, 241, 250);\n background-color: var(--color-informative--surface);\n}\n\n/* Our Banner \"surface\" colors should be lighter than they are so we're leaving the following alone for now */\n\n._7h8FUHIkVjg- {\n background-color: rgb(203, 223, 159);\n background-color: var(--color-green--lighter);\n}\n\n.d5fXcE1L0lc- {\n background-color: rgb(241, 231, 159);\n background-color: var(--color-yellow--lighter);\n}\n\n.oYaw-T3c0IU- {\n background-color: rgb(255, 206, 194);\n background-color: var(--color-red--lighter);\n}\n";
|
|
21
|
-
var types = {"notice":"wWW-2T7rCV0-","success":"_7h8FUHIkVjg-","warning":"d5fXcE1L0lc-","error":"oYaw-T3c0IU-"};
|
|
22
|
-
styleInject_es.styleInject(css_248z);
|
|
23
|
-
|
|
24
|
-
function BannerIcon({ icon }) {
|
|
25
|
-
return React__default["default"].createElement(Icon.Icon, { name: icon, color: "greyBlueDark" });
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function Banner({ children, type, primaryAction, dismissible = true, icon, onDismiss, }) {
|
|
29
|
-
const [showBanner, setShowBanner] = React.useState(true);
|
|
30
|
-
const bannerWidths = {
|
|
31
|
-
small: 320,
|
|
32
|
-
medium: 480,
|
|
33
|
-
};
|
|
34
|
-
const [bannerRef, { width: bannerWidth = bannerWidths.small }] = jobberHooks.useResizeObserver({
|
|
35
|
-
widths: bannerWidths,
|
|
36
|
-
});
|
|
37
|
-
const iconColors = {
|
|
38
|
-
notice: "informative",
|
|
39
|
-
success: "success",
|
|
40
|
-
warning: "warning",
|
|
41
|
-
error: "critical",
|
|
42
|
-
};
|
|
43
|
-
if (primaryAction != undefined) {
|
|
44
|
-
primaryAction = Object.assign({
|
|
45
|
-
size: "small",
|
|
46
|
-
type: "tertiary",
|
|
47
|
-
variation: type === "notice" ? "learning" : "work",
|
|
48
|
-
}, primaryAction);
|
|
49
|
-
}
|
|
50
|
-
const bannerClassNames = classnames__default["default"](styles.banner, types[type], {
|
|
51
|
-
[styles.medium]: bannerWidth >= bannerWidths.medium,
|
|
52
|
-
});
|
|
53
|
-
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" },
|
|
54
|
-
React__default["default"].createElement("div", { className: styles.bannerContent },
|
|
55
|
-
icon && React__default["default"].createElement(BannerIcon, { icon: icon }),
|
|
56
|
-
React__default["default"].createElement("div", { className: styles.bannerChildren },
|
|
57
|
-
React__default["default"].createElement(BannerChildren, null, children)),
|
|
58
|
-
primaryAction && (React__default["default"].createElement("div", { className: styles.bannerAction },
|
|
59
|
-
React__default["default"].createElement(Button.Button, Object.assign({}, primaryAction))))),
|
|
60
|
-
dismissible && (React__default["default"].createElement("button", { className: styles.closeButton, onClick: handleClose, "aria-label": "Close this notification" },
|
|
61
|
-
React__default["default"].createElement(Icon.Icon, { name: "cross", color: iconColors[type] })))))));
|
|
62
|
-
function handleClose() {
|
|
63
|
-
setShowBanner(!showBanner);
|
|
64
|
-
onDismiss && onDismiss();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
function BannerChildren({ children, }) {
|
|
68
|
-
if (!children)
|
|
69
|
-
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
70
|
-
if (children && typeof children === "string") {
|
|
71
|
-
return React__default["default"].createElement(Text.Text, null, children);
|
|
72
|
-
}
|
|
73
|
-
return React__default["default"].createElement(React__default["default"].Fragment, null, children);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
exports.Banner = Banner;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React, { SetStateAction } from "react";
|
|
2
|
-
import { ComboboxOption } from "../../Combobox.types";
|
|
3
|
-
interface ComboboxListProps {
|
|
4
|
-
readonly options: ComboboxOption[];
|
|
5
|
-
readonly showEmptyState: boolean;
|
|
6
|
-
readonly selected: ComboboxOption[];
|
|
7
|
-
readonly optionsListRef: React.RefObject<HTMLUListElement>;
|
|
8
|
-
readonly setFirstSelectedElement: React.Dispatch<SetStateAction<HTMLElement | null>>;
|
|
9
|
-
readonly selectionHandler: (option: ComboboxOption) => void;
|
|
10
|
-
readonly searchValue: string;
|
|
11
|
-
readonly multiselect: boolean;
|
|
12
|
-
readonly subjectNoun?: string;
|
|
13
|
-
}
|
|
14
|
-
export declare function ComboboxList(props: ComboboxListProps): JSX.Element;
|
|
15
|
-
export {};
|