@jobber/components 4.46.0 → 4.46.1-JOB-79340.32
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/Chip.d.ts +1 -0
- package/Chip.js +17 -0
- package/Flex.d.ts +1 -0
- package/Flex.js +17 -0
- package/dist/Autocomplete/index.js +7 -7
- package/dist/Avatar/Avatar.d.ts +1 -1
- package/dist/Avatar/index.d.ts +1 -1
- package/dist/Banner/index.js +3 -3
- package/dist/Button/index.js +2 -2
- package/dist/{Button-d89f2271.js → Button-db6114a6.js} +1 -1
- package/dist/ButtonDismiss/index.js +3 -3
- package/dist/{ButtonDismiss-250840a4.js → ButtonDismiss-1ccb84ec.js} +1 -1
- package/dist/Card/index.js +5 -5
- package/dist/{Card-69304e99.js → Card-116af709.js} +3 -3
- package/dist/Checkbox/index.js +3 -3
- package/dist/{Checkbox-eac63b7f.js → Checkbox-bc4bc968.js} +1 -1
- package/dist/Chip/Chip.d.ts +8 -0
- package/dist/Chip/Chip.types.d.d.ts +68 -0
- package/dist/Chip/components/ChipDismissible/ChipDismissible.d.ts +3 -0
- package/dist/Chip/components/ChipPrefix/Chip.Prefix.d.ts +6 -0
- package/dist/Chip/components/ChipSelectable/ChipSelectable.d.ts +3 -0
- package/dist/Chip/components/ChipSuffix/Chip.Suffix.d.ts +10 -0
- package/dist/Chip/hooks/index.d.ts +1 -0
- package/dist/Chip/hooks/useChildComponent.d.ts +8 -0
- package/dist/Chip/index.d.ts +4 -0
- package/dist/Chip/index.js +35 -0
- package/dist/Chip-00e281e9.js +73 -0
- package/dist/Chips/ChipsTypes.d.ts +10 -6
- package/dist/Chips/InternalChipDismissible/InternalChipDismissibleTypes.d.ts +1 -1
- package/dist/Chips/InternalChipDismissible/hooks/useInternalChipDismissible.d.ts +1 -1
- package/dist/Chips/InternalChipSingleSelect.d.ts +1 -1
- package/dist/Chips/index.d.ts +5 -1
- package/dist/Chips/index.js +122 -18
- package/dist/{Chip-4d8e6370.js → Chips-5ff2b9d2.js} +62 -169
- 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 -32
- 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 +8 -4
- package/dist/Combobox/hooks/useComboboxValidation.d.ts +7 -0
- package/dist/Combobox/index.d.ts +2 -2
- package/dist/Combobox/index.js +112 -53
- package/dist/ConfirmationModal/index.js +9 -9
- package/dist/{ConfirmationModal-92f07027.js → ConfirmationModal-285c3cbe.js} +2 -2
- package/dist/Content/Content.d.ts +1 -1
- package/dist/DataDump/index.js +6 -6
- package/dist/DataList/DataList.types.d.ts +9 -1
- package/dist/DataList/components/DataListSearch/DataListSearch.d.ts +1 -1
- package/dist/DataList/index.js +47 -24
- package/dist/DataTable/index.js +6 -6
- package/dist/DatePicker/index.js +3 -3
- package/dist/{DatePicker-39d2dc8b.js → DatePicker-49213434.js} +2 -2
- package/dist/DescriptionList/index.js +1 -1
- package/dist/Disclosure/index.js +1 -1
- package/dist/Drawer/index.js +4 -4
- package/dist/Emphasis/index.js +2 -2
- package/dist/{Emphasis-cc3456ac.js → Emphasis-e10dde65.js} +1 -1
- package/dist/FeatureSwitch/index.js +7 -7
- 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/FormField/index.js +5 -5
- package/dist/{FormField-bef41ec9.js → FormField-fa9254dc.js} +3 -3
- package/dist/FormatFile/index.js +10 -10
- package/dist/{FormatFile-a470c0f2.js → FormatFile-6423c3b5.js} +4 -4
- package/dist/Gallery/index.js +11 -11
- package/dist/Heading/index.js +2 -2
- package/dist/{Heading-4562900a.js → Heading-4cde9989.js} +1 -1
- package/dist/InlineLabel/index.js +2 -2
- package/dist/{InlineLabel-3d461632.js → InlineLabel-a24706c4.js} +1 -1
- package/dist/InputAvatar/index.js +3 -3
- package/dist/InputDate/index.js +6 -6
- package/dist/InputEmail/index.js +5 -5
- package/dist/InputFile/index.js +3 -3
- package/dist/{InputFile-d327dee3.js → InputFile-25c3369b.js} +2 -2
- package/dist/InputNumber/index.js +6 -6
- package/dist/{InputNumber-5640fb55.js → InputNumber-ea9fcee1.js} +1 -1
- package/dist/InputPassword/index.js +5 -5
- package/dist/InputPhoneNumber/index.js +5 -5
- package/dist/InputText/index.js +6 -6
- package/dist/{InputText-5ac5cfe0.js → InputText-ab237501.js} +1 -1
- package/dist/InputTime/index.js +5 -5
- package/dist/InputValidation/index.js +3 -3
- package/dist/{InputValidation-4e809bdd.js → InputValidation-377d6c62.js} +1 -1
- package/dist/LightBox/index.js +4 -4
- package/dist/{LightBox-02ca409e.js → LightBox-93ef99b9.js} +2 -2
- package/dist/List/index.js +5 -5
- package/dist/Markdown/index.js +5 -5
- package/dist/{Markdown-b37cf9ec.js → Markdown-d53b01bf.js} +3 -3
- package/dist/Menu/index.js +3 -3
- package/dist/{Menu-cec53b50.js → Menu-2e64307a.js} +2 -2
- package/dist/Modal/index.js +5 -5
- package/dist/{Modal-dcdc0032.js → Modal-c17cc105.js} +3 -3
- package/dist/MultiSelect/index.js +3 -3
- package/dist/{Option-9f4a65da.js → Option-07a24acd.js} +1 -1
- package/dist/Page/index.js +7 -7
- package/dist/Popover/index.js +4 -4
- package/dist/{Popover-d401fb54.js → Popover-7c966790.js} +1 -1
- package/dist/RadioGroup/index.js +3 -3
- package/dist/{RadioGroup-46833fac.js → RadioGroup-9bdd8a59.js} +1 -1
- package/dist/RecurringSelect/index.js +8 -8
- package/dist/Select/index.js +6 -6
- package/dist/StatusLabel/index.js +2 -2
- package/dist/Switch/index.js +2 -2
- package/dist/{Switch-165f01e3.js → Switch-cc9b645c.js} +1 -1
- package/dist/Tabs/index.js +1 -1
- package/dist/Text/index.js +2 -2
- package/dist/{Text-59bde58c.js → Text-54334431.js} +1 -1
- package/dist/Toast/index.js +2 -2
- package/dist/Tooltip/index.js +1 -3
- package/dist/{Tooltip-59dbab5b.js → Tooltip-ae33a335.js} +5 -7
- package/dist/Typography/index.js +1 -1
- package/dist/{Typography-9bff9c91.js → Typography-83915c54.js} +2 -2
- package/package.json +6 -6
- package/rollup.config.js +1 -0
- package/dist/Combobox/components/ComboboxContent/ComboboxList.d.ts +0 -14
- package/dist/Combobox/components/ComboboxContent/ComboboxSearch.d.ts +0 -7
|
@@ -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,33 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
interface ComboboxContentProps {
|
|
4
|
-
/**
|
|
5
|
-
* List of selectable options to display.
|
|
6
|
-
*/
|
|
7
|
-
readonly options: ComboboxOption[];
|
|
8
|
-
/**
|
|
9
|
-
* Callback function invoked upon the selection of an option. Provides the selected option as an argument.
|
|
10
|
-
*/
|
|
11
|
-
readonly onSelect: (selection: ComboboxOption) => void;
|
|
12
|
-
/**
|
|
13
|
-
* Optional action button(s) to display at the bottom of the list.
|
|
14
|
-
*/
|
|
15
|
-
readonly children?: ReactElement | ReactElement[];
|
|
16
|
-
/**
|
|
17
|
-
* Placeholder text to display in the search input. Defaults to "Search".
|
|
18
|
-
*/
|
|
19
|
-
readonly searchPlaceholder?: string;
|
|
20
|
-
/**
|
|
21
|
-
* pre selected option
|
|
22
|
-
* @default ""
|
|
23
|
-
* @type string
|
|
24
|
-
*/
|
|
25
|
-
readonly selected: ComboboxOption | null;
|
|
26
|
-
/**
|
|
27
|
-
* The encapsulating noun for the content of the combobox. Used
|
|
28
|
-
* in the empty state, and search placeholder. Should be pluralized.
|
|
29
|
-
*/
|
|
30
|
-
readonly subjectNoun?: string;
|
|
31
|
-
}
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ComboboxContentProps } from "@jobber/components/Combobox/Combobox.types";
|
|
32
3
|
export declare function ComboboxContent(props: ComboboxContentProps): JSX.Element;
|
|
33
|
-
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,9 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ComboboxOption } from "
|
|
3
|
-
|
|
2
|
+
import { ComboboxOption } from "@jobber/components/Combobox/Combobox.types";
|
|
3
|
+
interface useComboboxContent {
|
|
4
4
|
searchValue: string;
|
|
5
5
|
setSearchValue: React.Dispatch<React.SetStateAction<string>>;
|
|
6
|
-
|
|
6
|
+
setFirstSelectedElement: React.Dispatch<React.SetStateAction<HTMLElement | null>>;
|
|
7
7
|
filteredOptions: ComboboxOption[];
|
|
8
8
|
optionsListRef: React.RefObject<HTMLUListElement>;
|
|
9
|
-
|
|
9
|
+
selectedOptions: ComboboxOption[];
|
|
10
|
+
optionsSelectionHandler: (selected: ComboboxOption[]) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function useComboboxContent(options: ComboboxOption[], open: boolean, selected: ComboboxOption[], onClose: ((selection: ComboboxOption[]) => void) | undefined, onSelect: ((selection: ComboboxOption[]) => void) | undefined): useComboboxContent;
|
|
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
|
-
var Text = require('../Text-
|
|
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-d89f2271.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,30 +56,30 @@ 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
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
function ComboboxContentList(props) {
|
|
64
|
+
let hasSeenFirstSelected = false;
|
|
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 &&
|
|
66
67
|
props.options.map(option => {
|
|
67
|
-
|
|
68
|
-
const isSelected = option.id.toString() === ((_a = props.selected) === null || _a === void 0 ? void 0 : _a.id.toString());
|
|
68
|
+
const isSelected = props.selected.some(selection => selection.id.toString() === option.id.toString());
|
|
69
69
|
return (React__default["default"].createElement("li", { ref: listItem => {
|
|
70
|
-
if (isSelected)
|
|
71
|
-
props.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}) },
|
|
70
|
+
if (isSelected && !hasSeenFirstSelected) {
|
|
71
|
+
props.setFirstSelectedElement(listItem);
|
|
72
|
+
hasSeenFirstSelected = true;
|
|
73
|
+
}
|
|
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,24 +128,39 @@ function ComboboxContextProvider(props) {
|
|
|
104
128
|
props.children)));
|
|
105
129
|
}
|
|
106
130
|
|
|
107
|
-
function useComboboxContent(options, open) {
|
|
131
|
+
function useComboboxContent(options, open, selected, onClose, onSelect) {
|
|
108
132
|
const [searchValue, setSearchValue] = React.useState("");
|
|
109
|
-
const [
|
|
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()));
|
|
136
|
+
const [internalSelected, setInternalSelected] = React.useState(selected);
|
|
137
|
+
const selectedOptions = onClose ? internalSelected : selected;
|
|
138
|
+
const optionsSelectionHandler = onSelect ? onSelect : setInternalSelected;
|
|
139
|
+
React.useEffect(() => {
|
|
140
|
+
if (!open && onClose) {
|
|
141
|
+
onClose(selectedOptions);
|
|
142
|
+
}
|
|
143
|
+
}, [open, onClose, selectedOptions]);
|
|
112
144
|
React.useEffect(() => {
|
|
113
|
-
if (open &&
|
|
114
|
-
|
|
145
|
+
if (open && firstSelectedElement) {
|
|
146
|
+
firstSelectedElement === null || firstSelectedElement === void 0 ? void 0 : firstSelectedElement.scrollIntoView({
|
|
115
147
|
block: "nearest",
|
|
116
148
|
});
|
|
117
149
|
}
|
|
118
|
-
}, [open,
|
|
150
|
+
}, [open, firstSelectedElement]);
|
|
151
|
+
React.useEffect(() => {
|
|
152
|
+
if (selectedOptions.length === 0) {
|
|
153
|
+
setFirstSelectedElement(null);
|
|
154
|
+
}
|
|
155
|
+
}, [selectedOptions]);
|
|
119
156
|
return {
|
|
120
157
|
searchValue,
|
|
121
158
|
setSearchValue,
|
|
122
|
-
|
|
159
|
+
setFirstSelectedElement,
|
|
123
160
|
filteredOptions,
|
|
124
161
|
optionsListRef,
|
|
162
|
+
selectedOptions,
|
|
163
|
+
optionsSelectionHandler,
|
|
125
164
|
};
|
|
126
165
|
}
|
|
127
166
|
|
|
@@ -202,23 +241,44 @@ function useComboboxAccessibility(selectionCallback, filteredOptions, optionsLis
|
|
|
202
241
|
}
|
|
203
242
|
|
|
204
243
|
function ComboboxContent(props) {
|
|
205
|
-
const { open, setOpen, wrapperRef } = React__default["default"].useContext(ComboboxContext);
|
|
244
|
+
const { open, setOpen, wrapperRef, multiselect } = React__default["default"].useContext(ComboboxContext);
|
|
206
245
|
const optionsExist = props.options.length > 0;
|
|
207
|
-
const { searchValue, setSearchValue,
|
|
246
|
+
const { searchValue, setSearchValue, setFirstSelectedElement, filteredOptions, optionsListRef, selectedOptions, optionsSelectionHandler, } = useComboboxContent(props.options, open, props.selected, props.onClose, props.onSelect);
|
|
208
247
|
const { popperRef, popperStyles, attributes } = useComboboxAccessibility(handleSelection, filteredOptions, optionsListRef, open, setOpen, wrapperRef);
|
|
209
|
-
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$
|
|
210
|
-
React__default["default"].createElement(
|
|
211
|
-
React__default["default"].createElement(
|
|
212
|
-
|
|
213
|
-
|
|
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,
|
|
214
258
|
}) }, child)))))));
|
|
215
259
|
return ReactDOM__default["default"].createPortal(template, document.body);
|
|
216
260
|
function handleSelection(selection) {
|
|
217
|
-
|
|
261
|
+
if (multiselect) {
|
|
262
|
+
handleMultiSelect(optionsSelectionHandler, selectedOptions, selection);
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
handleSingleSelect(optionsSelectionHandler, selection);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function handleSingleSelect(selectCallback, selection) {
|
|
269
|
+
selectCallback([selection]);
|
|
218
270
|
setSearchValue("");
|
|
219
271
|
setOpen(false);
|
|
220
272
|
}
|
|
221
273
|
}
|
|
274
|
+
function handleMultiSelect(selectCallback, selected, selection) {
|
|
275
|
+
if (selected.some(s => s.id === selection.id)) {
|
|
276
|
+
selectCallback(selected.filter(s => s.id !== selection.id));
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
selectCallback([...selected, selection]);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
222
282
|
|
|
223
283
|
var css_248z$1 = ".Ow9wSNnGP-g- {\n width: 100%;\n box-sizing: border-box;\n padding: 0 calc(16px / 2);\n padding: 0 var(--space-small);\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n}\n\n.ncp0nKHQ7d8- {\n position: relative;\n width: 100%;\n min-height: calc((calc(16px * 3) - calc(16px / 2)));\n min-height: calc((var(--space-largest) - var(--space-small)));\n padding: calc(16px / 2) 0;\n padding: var(--space-small) 0;\n border: none;\n border-radius: calc(16px / 4);\n border-radius: var(--radius-large);\n text-align: left;\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n cursor: pointer;\n transition: all 200ms;\n transition: all var(--timing-base);\n}\n\n.ncp0nKHQ7d8-:focus {\n box-shadow: 0px 0px calc(16px / 4) calc(16px / 8)\n rgb(231, 213, 87);\n box-shadow: var(--shadow-focus);\n background-color: rgb(244, 244, 244);\n background-color: var(--color-surface--background);\n}\n\n.ncp0nKHQ7d8-:hover {\n background-color: rgb(244, 244, 244);\n background-color: var(--color-surface--background);\n}\n\n.ncp0nKHQ7d8- span {\n margin-left: calc(16px / 2);\n margin-left: var(--space-small);\n}\n";
|
|
224
284
|
var styles$1 = {"actionContainer":"Ow9wSNnGP-g-","actionButton":"ncp0nKHQ7d8-"};
|
|
@@ -226,7 +286,7 @@ styleInject_es.styleInject(css_248z$1);
|
|
|
226
286
|
|
|
227
287
|
function ComboboxAction(props) {
|
|
228
288
|
return (React__default["default"].createElement("div", { className: styles$1.actionContainer },
|
|
229
|
-
React__default["default"].createElement("button", { className: styles$1.actionButton, onClick: props.onClick, "aria-label": props.label },
|
|
289
|
+
React__default["default"].createElement("button", { className: styles$1.actionButton, onClick: props.onClick, type: "button", "aria-label": props.label },
|
|
230
290
|
React__default["default"].createElement(Typography.Typography, { element: "span", size: "base", textColor: "green", fontWeight: "semiBold" }, props.label))));
|
|
231
291
|
}
|
|
232
292
|
|
|
@@ -241,7 +301,7 @@ styleInject_es.styleInject(css_248z);
|
|
|
241
301
|
|
|
242
302
|
function ComboboxTriggerChip(props) {
|
|
243
303
|
const { open, setOpen } = React__default["default"].useContext(ComboboxContext);
|
|
244
|
-
return (React__default["default"].createElement("button", { className: styles.trigger, role: "combobox", "aria-expanded": open, "aria-haspopup": "listbox", "aria-controls": "ATL-Combobox-Content", "aria-autocomplete": "list", onClick: () => {
|
|
304
|
+
return (React__default["default"].createElement("button", { className: styles.trigger, role: "combobox", type: "button", "aria-expanded": open, "aria-haspopup": "listbox", "aria-controls": "ATL-Combobox-Content", "aria-autocomplete": "list", onClick: () => {
|
|
245
305
|
setOpen(!open);
|
|
246
306
|
} },
|
|
247
307
|
React__default["default"].createElement(Typography.Typography, { fontWeight: "semiBold", textColor: "heading" }, props.label),
|
|
@@ -251,12 +311,6 @@ function ComboboxTriggerChip(props) {
|
|
|
251
311
|
|
|
252
312
|
const COMBOBOX_TRIGGER_COUNT_ERROR_MESSAGE = "Combobox can only have one Trigger element";
|
|
253
313
|
const COMBOBOX_REQUIRED_CHILDREN_ERROR_MESSAGE = "Combobox must have a Trigger and Combobox.Content element";
|
|
254
|
-
const Combobox = (props) => {
|
|
255
|
-
const { contentElement, triggerElement } = useComboboxValidation(props.children);
|
|
256
|
-
return (React__default["default"].createElement(ComboboxContextProvider, { multiselect: props.multiSelect },
|
|
257
|
-
triggerElement,
|
|
258
|
-
contentElement));
|
|
259
|
-
};
|
|
260
314
|
function useComboboxValidation(children) {
|
|
261
315
|
const childrenArray = React__default["default"].Children.toArray(children);
|
|
262
316
|
let triggerElement, contentElement, multipleTriggersFound = false;
|
|
@@ -285,12 +339,17 @@ function isTriggerElement(child) {
|
|
|
285
339
|
function isContentElement(child) {
|
|
286
340
|
return React__default["default"].isValidElement(child) && child.type === ComboboxContent;
|
|
287
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
|
+
};
|
|
288
349
|
Combobox.TriggerButton = ComboboxTriggerButton;
|
|
289
350
|
Combobox.TriggerChip = ComboboxTriggerChip;
|
|
290
351
|
Combobox.Content = ComboboxContent;
|
|
291
352
|
Combobox.Action = ComboboxAction;
|
|
292
353
|
|
|
293
|
-
exports.COMBOBOX_REQUIRED_CHILDREN_ERROR_MESSAGE = COMBOBOX_REQUIRED_CHILDREN_ERROR_MESSAGE;
|
|
294
|
-
exports.COMBOBOX_TRIGGER_COUNT_ERROR_MESSAGE = COMBOBOX_TRIGGER_COUNT_ERROR_MESSAGE;
|
|
295
354
|
exports.Combobox = Combobox;
|
|
296
355
|
exports.ComboboxContextProvider = ComboboxContextProvider;
|