@jobber/components 4.49.1 → 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/Flex.d.ts +1 -0
- package/Flex.js +17 -0
- package/dist/Banner/Banner.d.ts +1 -2
- package/dist/Banner/index.d.ts +1 -1
- package/dist/Banner/index.js +1 -1
- package/dist/{Chip-53832bb2.js → Chip-4f7af21e.js} +1 -1
- package/dist/Chips/index.js +3 -3
- 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/Content/Content.d.ts +1 -1
- package/dist/DataList/DataList.d.ts +2 -0
- 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 +24 -2
- 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/Flex/Flex.d.ts +32 -0
- package/dist/Flex/Flex.types.d.ts +6 -0
- package/dist/Flex/index.d.ts +1 -0
- package/dist/Flex/index.js +40 -0
- package/dist/Tabs/Tabs.d.ts +12 -1
- package/dist/Tabs/index.js +6 -2
- package/dist/Tooltip/index.js +1 -3
- package/dist/{Tooltip-d5257798.js → Tooltip-ae33a335.js} +5 -7
- package/package.json +6 -6
- package/rollup.config.js +1 -0
- package/dist/Combobox/components/ComboboxContent/ComboboxList.d.ts +0 -15
- package/dist/Combobox/components/ComboboxContent/ComboboxSearch.d.ts +0 -7
package/Flex.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./dist/Flex";
|
package/Flex.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var Flex = require("./dist/Flex");
|
|
8
|
+
|
|
9
|
+
Object.keys(Flex).forEach(function(key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
Object.defineProperty(exports, key, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function get() {
|
|
14
|
+
return Flex[key];
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
});
|
package/dist/Banner/Banner.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ReactNode } from "react";
|
|
|
2
2
|
import { IconNames } from "@jobber/design";
|
|
3
3
|
import { ButtonProps } from "../Button";
|
|
4
4
|
export type BannerType = "notice" | "success" | "warning" | "error";
|
|
5
|
-
interface BannerProps {
|
|
5
|
+
export interface BannerProps {
|
|
6
6
|
readonly children: ReactNode;
|
|
7
7
|
readonly type: BannerType;
|
|
8
8
|
/**
|
|
@@ -21,4 +21,3 @@ interface BannerProps {
|
|
|
21
21
|
onDismiss?(): void;
|
|
22
22
|
}
|
|
23
23
|
export declare function Banner({ children, type, primaryAction, dismissible, icon, onDismiss, }: BannerProps): JSX.Element;
|
|
24
|
-
export {};
|
package/dist/Banner/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Banner, BannerType } from "./Banner";
|
|
1
|
+
export { Banner, BannerType, BannerProps } from "./Banner";
|
package/dist/Banner/index.js
CHANGED
|
@@ -69,7 +69,7 @@ function Banner({ children, type, primaryAction, dismissible = true, icon, onDis
|
|
|
69
69
|
onDismiss && onDismiss();
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
function BannerChildren({ children }) {
|
|
72
|
+
function BannerChildren({ children, }) {
|
|
73
73
|
if (!children)
|
|
74
74
|
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
75
75
|
if (children && typeof children === "string") {
|
|
@@ -8,7 +8,7 @@ var useAssert = require('@jobber/hooks/useAssert');
|
|
|
8
8
|
var Icon = require('./Icon-405a216c.js');
|
|
9
9
|
var Avatar = require('./Avatar-1aa30ee1.js');
|
|
10
10
|
var Typography = require('./Typography-83915c54.js');
|
|
11
|
-
var Tooltip = require('./Tooltip-
|
|
11
|
+
var Tooltip = require('./Tooltip-ae33a335.js');
|
|
12
12
|
var sortBy = require('lodash/sortBy');
|
|
13
13
|
var useLiveAnnounce = require('@jobber/hooks/useLiveAnnounce');
|
|
14
14
|
var debounce = require('lodash/debounce');
|
package/dist/Chips/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var Chip = require('../Chip-
|
|
6
|
+
var Chip = require('../Chip-4f7af21e.js');
|
|
7
7
|
require('uuid');
|
|
8
8
|
require('../style-inject.es-9d2f5f4e.js');
|
|
9
9
|
require('classnames');
|
|
@@ -13,14 +13,14 @@ require('@jobber/design');
|
|
|
13
13
|
require('../Avatar-1aa30ee1.js');
|
|
14
14
|
require('color');
|
|
15
15
|
require('../Typography-83915c54.js');
|
|
16
|
-
require('../Tooltip-
|
|
16
|
+
require('../Tooltip-ae33a335.js');
|
|
17
17
|
require('react-dom');
|
|
18
18
|
require('framer-motion');
|
|
19
19
|
require('react-popper');
|
|
20
|
-
require('../Text-54334431.js');
|
|
21
20
|
require('lodash/sortBy');
|
|
22
21
|
require('@jobber/hooks/useLiveAnnounce');
|
|
23
22
|
require('lodash/debounce');
|
|
23
|
+
require('../Text-54334431.js');
|
|
24
24
|
require('../Button-db6114a6.js');
|
|
25
25
|
require('react-router-dom');
|
|
26
26
|
require('../Spinner-9d8fc7ff.js');
|
|
@@ -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,4 +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;
|
|
23
|
+
var StatusBar: typeof DataListStatusBar;
|
|
22
24
|
}
|
|
@@ -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
|
@@ -11,7 +11,7 @@ var noop = require('lodash/noop');
|
|
|
11
11
|
var design = require('@jobber/design');
|
|
12
12
|
var framerMotion = require('framer-motion');
|
|
13
13
|
var classnames = require('classnames');
|
|
14
|
-
var Tooltip = require('../Tooltip-
|
|
14
|
+
var Tooltip = require('../Tooltip-ae33a335.js');
|
|
15
15
|
var Button = require('../Button-db6114a6.js');
|
|
16
16
|
var useInView = require('@jobber/hooks/useInView');
|
|
17
17
|
var isEmpty = require('lodash/isEmpty');
|
|
@@ -27,7 +27,7 @@ var reactRouterDom = require('react-router-dom');
|
|
|
27
27
|
var AnimatedSwitcher = require('../AnimatedSwitcher-d1e1ddcf.js');
|
|
28
28
|
var Popover = require('../Popover-7c966790.js');
|
|
29
29
|
var Content = require('../Content-2ca1ffe1.js');
|
|
30
|
-
var Chip = require('../Chip-
|
|
30
|
+
var Chip = require('../Chip-4f7af21e.js');
|
|
31
31
|
require('@jobber/hooks/useAssert');
|
|
32
32
|
require('../Avatar-1aa30ee1.js');
|
|
33
33
|
require('color');
|
|
@@ -987,6 +987,23 @@ function DataListLayoutActionsWrapper({ children }) {
|
|
|
987
987
|
return React__default["default"].createElement("div", { className: styles.hidden }, children);
|
|
988
988
|
}
|
|
989
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
|
+
|
|
990
1007
|
function DataList(_a) {
|
|
991
1008
|
var { selected = [], sorting } = _a, props = tslib_es6.__rest(_a, ["selected", "sorting"]);
|
|
992
1009
|
const [layoutBreakpoints, setLayoutBreakpoints] = React.useState([]);
|
|
@@ -1032,6 +1049,7 @@ function InternalDataList() {
|
|
|
1032
1049
|
React__default["default"].createElement("div", { className: styles$e.headerFilters },
|
|
1033
1050
|
React__default["default"].createElement(InternalDataListFilters, null),
|
|
1034
1051
|
React__default["default"].createElement(InternalDataListSearch, null)),
|
|
1052
|
+
React__default["default"].createElement(InternalDataListStatusBar, null),
|
|
1035
1053
|
React__default["default"].createElement(DataListHeader, null)),
|
|
1036
1054
|
initialLoading && React__default["default"].createElement(DataListLoadingState, null),
|
|
1037
1055
|
showEmptyState && React__default["default"].createElement(InternalDataListEmptyState, null),
|
|
@@ -1098,5 +1116,9 @@ DataList.ItemAction = DataListAction;
|
|
|
1098
1116
|
DataList.BatchAction = function DataListBatchAction(props) {
|
|
1099
1117
|
return React__default["default"].createElement(DataListAction, Object.assign({}, props));
|
|
1100
1118
|
};
|
|
1119
|
+
/**
|
|
1120
|
+
* Defines a banner that is going to rendered between the filters and the header.
|
|
1121
|
+
*/
|
|
1122
|
+
DataList.StatusBar = DataListStatusBar;
|
|
1101
1123
|
|
|
1102
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) => {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
import { ColumnKeys, Direction, Spacing } from "./Flex.types";
|
|
3
|
+
interface FlexProps extends PropsWithChildren {
|
|
4
|
+
/**
|
|
5
|
+
* Determine how the children gets laid out
|
|
6
|
+
*
|
|
7
|
+
* **Supported keys**
|
|
8
|
+
* - `"grow"` - Grows to the space available. If all children are set to
|
|
9
|
+
* grow, then they'll have equal width.
|
|
10
|
+
* - `"shrink"` - Shrinks to the smallest size possible. Normally the size of
|
|
11
|
+
* the child.
|
|
12
|
+
*/
|
|
13
|
+
readonly template: ColumnKeys[];
|
|
14
|
+
/**
|
|
15
|
+
* Adjusts the alignment of the Flex children.
|
|
16
|
+
*/
|
|
17
|
+
readonly align?: "start" | "end" | "center";
|
|
18
|
+
/**
|
|
19
|
+
* The spacing between the children.
|
|
20
|
+
*
|
|
21
|
+
* @default "base"
|
|
22
|
+
*/
|
|
23
|
+
readonly gap?: Spacing;
|
|
24
|
+
/**
|
|
25
|
+
* The direction of the content.
|
|
26
|
+
*
|
|
27
|
+
* @default "row"
|
|
28
|
+
*/
|
|
29
|
+
readonly direction?: Direction;
|
|
30
|
+
}
|
|
31
|
+
export declare function Flex({ align, children, direction, gap, template, }: FlexProps): JSX.Element;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type ColumnKeys = "shrink" | "grow";
|
|
2
|
+
export type Direction = "row" | "column";
|
|
3
|
+
export declare const spacing: readonly ["none", "smallest", "smaller", "small", "base", "large"];
|
|
4
|
+
type ValuesOfSpacing<T extends typeof spacing> = T[number];
|
|
5
|
+
export type Spacing = ValuesOfSpacing<typeof spacing>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Flex } from "./Flex";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var classnames = require('classnames');
|
|
7
|
+
var styleInject_es = require('../style-inject.es-9d2f5f4e.js');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
|
+
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
13
|
+
|
|
14
|
+
var css_248z = "._8VpnrMKmsqQ- {\n display: grid;\n /* If this gets wrapped in a flex container, it should take the remaining space */\n -ms-flex: 1;\n flex: 1;\n}\n\n.ooF1YfV4Usc- {\n gap: calc(16px / 8);\n gap: var(--space-smallest);\n}\n\n.ppCZfXq-Kqc- {\n gap: calc(16px / 4);\n gap: var(--space-smaller);\n}\n\n.tElkBalXH3g- {\n gap: calc(16px / 2);\n gap: var(--space-small);\n}\n\n._4u3OwUKxxbg- {\n gap: calc(16px * 1);\n gap: var(--space-base);\n}\n\n.RL7CJla0AAI- {\n gap: calc(16px * 1.5);\n gap: var(--space-large);\n}\n\n.fV4cvFYkhgo- {\n gap: 0;\n}\n\n._04xVVjZgr-0- {\n -ms-flex-align: start;\n align-items: start;\n}\n\n.Nc3zrqHHYSg- {\n -ms-flex-align: center;\n align-items: center;\n}\n\n.qA-v50wBX1U- {\n -ms-flex-align: end;\n align-items: end;\n}\n";
|
|
15
|
+
var styles = {"flexible":"_8VpnrMKmsqQ-","smallestGap":"ooF1YfV4Usc-","smallerGap":"ppCZfXq-Kqc-","smallGap":"tElkBalXH3g-","baseGap":"_4u3OwUKxxbg-","largeGap":"RL7CJla0AAI-","noneGap":"fV4cvFYkhgo-","startAlign":"_04xVVjZgr-0-","centerAlign":"Nc3zrqHHYSg-","endAlign":"qA-v50wBX1U-"};
|
|
16
|
+
styleInject_es.styleInject(css_248z);
|
|
17
|
+
|
|
18
|
+
function Flex({ align = "center", children, direction = "row", gap = "base", template, }) {
|
|
19
|
+
return (React__default["default"].createElement("div", { className: classnames__default["default"](styles.flexible, {
|
|
20
|
+
[styles[`${gap}Gap`]]: Boolean(gap),
|
|
21
|
+
[styles[`${align}Align`]]: Boolean(align),
|
|
22
|
+
}), style: generateGridStylesFromTemplate(direction, template) }, children));
|
|
23
|
+
}
|
|
24
|
+
function generateGridStylesFromTemplate(direction, layoutTemplate) {
|
|
25
|
+
const containerStyles = {};
|
|
26
|
+
const templateKeys = {
|
|
27
|
+
row: "gridTemplateColumns",
|
|
28
|
+
column: "gridTemplateRows",
|
|
29
|
+
};
|
|
30
|
+
const templateValues = {
|
|
31
|
+
grow: "1fr",
|
|
32
|
+
shrink: "max-content",
|
|
33
|
+
};
|
|
34
|
+
containerStyles[templateKeys[direction]] = layoutTemplate
|
|
35
|
+
.map(key => templateValues[key])
|
|
36
|
+
.join(" ");
|
|
37
|
+
return containerStyles;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
exports.Flex = Flex;
|
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/dist/Tooltip/index.js
CHANGED
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var Tooltip = require('../Tooltip-
|
|
5
|
+
var Tooltip = require('../Tooltip-ae33a335.js');
|
|
6
6
|
require('react');
|
|
7
7
|
require('classnames');
|
|
8
8
|
require('react-dom');
|
|
9
9
|
require('framer-motion');
|
|
10
10
|
require('../style-inject.es-9d2f5f4e.js');
|
|
11
11
|
require('react-popper');
|
|
12
|
-
require('../Text-54334431.js');
|
|
13
|
-
require('../Typography-83915c54.js');
|
|
14
12
|
|
|
15
13
|
|
|
16
14
|
|
|
@@ -6,7 +6,6 @@ var ReactDOM = require('react-dom');
|
|
|
6
6
|
var framerMotion = require('framer-motion');
|
|
7
7
|
var styleInject_es = require('./style-inject.es-9d2f5f4e.js');
|
|
8
8
|
var reactPopper = require('react-popper');
|
|
9
|
-
var Text = require('./Text-54334431.js');
|
|
10
9
|
|
|
11
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
11
|
|
|
@@ -14,8 +13,8 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
14
13
|
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
15
14
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
16
15
|
|
|
17
|
-
var css_248z = ":root {\n --tooltip--arrow-size: var(--space-small);\n --tooltip--offset: calc(-1 *
|
|
18
|
-
var styles = {"shadowActivator":"q07bkGoq714-","tooltipWrapper":"dkCTRfc3vYk-","tooltip":"yAFP4gRKlTM-","arrow":"j9KgRON7iTU-","above":"B6uh34-qEuA-","below":"Wft7Ug-lXEc-"};
|
|
16
|
+
var css_248z = ":root {\n --tooltip--arrow-size: var(--space-small);\n --tooltip--offset: calc(-1 * var(--space-smaller));\n --tooltip--surface: var(--color-surface--reverse);\n}\n\n.q07bkGoq714- {\n display: none;\n}\n\n.dkCTRfc3vYk- {\n display: inline-block;\n position: absolute;\n z-index: 1002;\n z-index: var(--elevation-tooltip);\n}\n\n.yAFP4gRKlTM- {\n display: inline-block;\n position: relative;\n max-width: calc(16px * 15);\n max-width: calc(var(--base-unit) * 15);\n padding: calc((16px * 1) - (16px / 8)) calc(16px * 1);\n padding: calc(calc(16px * 1) - calc(16px / 8)) calc(16px * 1);\n padding: calc(var(--space-base) - var(--space-smallest)) var(--space-base);\n border-radius: calc(16px / 2);\n border-radius: var(--radius-larger);\n background-color: rgb(1, 41, 57);\n background-color: var(--tooltip--surface);\n}\n\n.yAFP4gRKlTM- .j9KgRON7iTU-,\n.yAFP4gRKlTM- .j9KgRON7iTU-::after {\n width: calc(16px / 2);\n width: var(--tooltip--arrow-size);\n height: calc(16px / 2);\n height: var(--tooltip--arrow-size);\n background-color: transparent;\n}\n\n.yAFP4gRKlTM- .j9KgRON7iTU-::after {\n content: \"\";\n display: block;\n position: absolute;\n background-color: rgb(1, 41, 57);\n background-color: var(--tooltip--surface);\n -webkit-transform: rotate(45deg);\n transform: rotate(45deg);\n}\n\n.B6uh34-qEuA- {\n padding-bottom: calc(16px / 2);\n padding-bottom: var(--space-small);\n}\n\n.B6uh34-qEuA- .yAFP4gRKlTM- {\n -webkit-transform-origin: bottom center;\n transform-origin: bottom center;\n}\n\n.B6uh34-qEuA- .yAFP4gRKlTM- .j9KgRON7iTU- {\n bottom: calc(-1 * (16px / 4));\n bottom: calc(-1 * calc(16px / 4));\n bottom: var(--tooltip--offset);\n}\n\n.B6uh34-qEuA- .yAFP4gRKlTM- .j9KgRON7iTU-::after {\n border-top-width: 0;\n border-left-width: 0;\n}\n\n.Wft7Ug-lXEc- {\n padding-top: calc(16px / 2);\n padding-top: var(--space-small);\n}\n\n.Wft7Ug-lXEc- .yAFP4gRKlTM- {\n -webkit-transform-origin: top center;\n transform-origin: top center;\n}\n\n.Wft7Ug-lXEc- .yAFP4gRKlTM- .j9KgRON7iTU- {\n top: calc(-1 * (16px / 4));\n top: calc(-1 * calc(16px / 4));\n top: var(--tooltip--offset);\n}\n\n.Wft7Ug-lXEc- .yAFP4gRKlTM- .j9KgRON7iTU-::after {\n border-bottom-width: 0;\n border-right-width: 0;\n}\n\n.TpdeLUuiQMg- {\n margin: 0;\n color: rgba(255, 255, 255, 1);\n color: var(--color-text--reverse);\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 font-weight: 600;\n line-height: 1.25;\n line-height: var(--typography--lineHeight-base);\n}\n";
|
|
17
|
+
var styles = {"shadowActivator":"q07bkGoq714-","tooltipWrapper":"dkCTRfc3vYk-","tooltip":"yAFP4gRKlTM-","arrow":"j9KgRON7iTU-","above":"B6uh34-qEuA-","below":"Wft7Ug-lXEc-","tooltipMessage":"TpdeLUuiQMg-"};
|
|
19
18
|
styleInject_es.styleInject(css_248z);
|
|
20
19
|
|
|
21
20
|
function useTooltipPositioning() {
|
|
@@ -52,11 +51,10 @@ function Tooltip({ message, children }) {
|
|
|
52
51
|
children,
|
|
53
52
|
React__default["default"].createElement(TooltipPortal, null, show && (React__default["default"].createElement("div", Object.assign({ className: toolTipClassNames, style: popperStyles.popper, ref: setTooltipRef, role: "tooltip" }, attributes.popper),
|
|
54
53
|
React__default["default"].createElement(framerMotion.motion.div, { className: styles.tooltip, variants: variation, initial: "startOrStop", animate: "done", exit: "startOrStop", transition: {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
stiffness: 300,
|
|
54
|
+
damping: 50,
|
|
55
|
+
stiffness: 500,
|
|
58
56
|
} },
|
|
59
|
-
React__default["default"].createElement(
|
|
57
|
+
React__default["default"].createElement("p", { className: styles.tooltipMessage }, message),
|
|
60
58
|
React__default["default"].createElement("div", { ref: setArrowRef, style: popperStyles.arrow, className: styles.arrow })))))));
|
|
61
59
|
function initializeListeners() {
|
|
62
60
|
const showTooltip = () => {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "4.49.
|
|
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",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@jobber/design": "^0.46.0",
|
|
23
|
-
"@jobber/formatters": "
|
|
24
|
-
"@jobber/hooks": "^2.6.
|
|
23
|
+
"@jobber/formatters": "^0.2.2",
|
|
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
|
@@ -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 {};
|