@loadsmart/loadsmart-ui 8.0.6 → 8.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DragDropFile.context.js +29 -0
- package/dist/DragDropFile.context.js.map +1 -0
- package/dist/index.js +7545 -8177
- package/dist/index.js.map +1 -1
- package/dist/styles/typography.d.ts +1 -1
- package/dist/testing/index.js +318 -219
- package/dist/testing/index.js.map +1 -1
- package/dist/themes.js +2322 -0
- package/dist/themes.js.map +1 -0
- package/dist/theming/index.js +10 -18
- package/dist/theming/index.js.map +1 -1
- package/dist/toArray.js +16 -0
- package/dist/toArray.js.map +1 -0
- package/dist/tools/index.js +2 -7
- package/dist/tools/vite-plugin-replace-jsx-runtime.d.ts +7 -0
- package/dist/tools.js +98 -0
- package/dist/tools.js.map +1 -0
- package/package.json +4 -3
- package/dist/DragDropFile.context-oKnUu6d3.js +0 -33
- package/dist/DragDropFile.context-oKnUu6d3.js.map +0 -1
- package/dist/miranda-compatibility.theme-CIu9fa89.js +0 -2528
- package/dist/miranda-compatibility.theme-CIu9fa89.js.map +0 -1
- package/dist/prop-Fs2axl9W.js +0 -75
- package/dist/prop-Fs2axl9W.js.map +0 -1
- package/dist/toArray-BJJzFRD1.js +0 -13
- package/dist/toArray-BJJzFRD1.js.map +0 -1
- package/dist/tools/index.js.map +0 -1
|
@@ -20,5 +20,5 @@ export declare const typographyProperties: TypographyProperties;
|
|
|
20
20
|
* @param variant Name of the variant
|
|
21
21
|
* @param options Add boldness, italics and color
|
|
22
22
|
*/
|
|
23
|
-
declare function typography<P>(variant?: TypographyVariants | ((props: P) => string), options?: TypographyOptions):
|
|
23
|
+
declare function typography<P>(variant?: TypographyVariants | ((props: P) => string), options?: TypographyOptions): ((props: P) => FlattenInterpolation<ThemeProps<any>> | ((props: unknown) => FlattenInterpolation<ThemeProps<any>> | /*elided*/ any)) | FlattenInterpolation<ThemeProps<any>>;
|
|
24
24
|
export default typography;
|
package/dist/testing/index.js
CHANGED
|
@@ -1,281 +1,380 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { alice } from "../themes.js";
|
|
2
|
+
import { toArray } from "../toArray.js";
|
|
3
|
+
import { DragDropFileContext } from "../DragDropFile.context.js";
|
|
4
|
+
import React from "react";
|
|
3
5
|
import { isFunction } from "@loadsmart/utils-function";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { D as DragDropFileContext } from "../DragDropFile.context-oKnUu6d3.js";
|
|
6
|
+
import { act, createEvent, fireEvent, queries, render, waitFor, waitForElementToBeRemoved, within } from "@testing-library/react";
|
|
7
|
+
//#region src/testing/DatePickerEvent/DatePickerEvent.ts
|
|
7
8
|
function getContainerFromInput(input) {
|
|
8
|
-
|
|
9
|
+
return input.parentNode.parentNode.parentNode.parentNode;
|
|
9
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Expand the `DatePicker` calendar, if it not already expanded.
|
|
13
|
+
* @param input - You can refer to this element by the label you applied to the `DatePicker`
|
|
14
|
+
*/
|
|
10
15
|
async function expand$2(input) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
expect(queries.getByRole(datePickerContainer, "menu")).toBeInTheDocument();
|
|
18
|
-
});
|
|
16
|
+
const datePickerContainer = getContainerFromInput(input);
|
|
17
|
+
if (queries.queryByRole(datePickerContainer, "menu")) return;
|
|
18
|
+
fireEvent.click(input);
|
|
19
|
+
await waitFor(() => {
|
|
20
|
+
expect(queries.getByRole(datePickerContainer, "menu")).toBeInTheDocument();
|
|
21
|
+
});
|
|
19
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Collapse the `DatePicker` calendar, if it not already collapsed.
|
|
25
|
+
* @param input - You can refer to this element by the label you applied to the `DatePicker`
|
|
26
|
+
*/
|
|
20
27
|
async function collapse$2(input) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
expect(queries.queryByRole(datePickerContainer, "menu")).not.toBeInTheDocument();
|
|
28
|
-
});
|
|
28
|
+
const datePickerContainer = getContainerFromInput(input);
|
|
29
|
+
if (!queries.queryByRole(datePickerContainer, "menu")) return;
|
|
30
|
+
fireEvent.click(queries.getByText(datePickerContainer, "Close"));
|
|
31
|
+
await waitFor(() => {
|
|
32
|
+
expect(queries.queryByRole(datePickerContainer, "menu")).not.toBeInTheDocument();
|
|
33
|
+
});
|
|
29
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Pick (select) the provided day in the current month/year.
|
|
37
|
+
* Notice that we programmatically expand the `DatePicker` calendar before picking the date.
|
|
38
|
+
* @param day - Label for the day to be picked, formatted as mm/dd/yyyy.
|
|
39
|
+
* @param input - You can refer to this element by the label you applied to the `DatePicker`
|
|
40
|
+
*/
|
|
30
41
|
async function pick$1(day, input) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
await collapse$2(input);
|
|
42
|
+
const datePickerContainer = getContainerFromInput(input);
|
|
43
|
+
await expand$2(input);
|
|
44
|
+
act(() => {
|
|
45
|
+
input.focus();
|
|
46
|
+
});
|
|
47
|
+
const dayElement = queries.getByLabelText(datePickerContainer, day);
|
|
48
|
+
if (dayElement.getAttribute("aria-checked") == "false") fireEvent.click(dayElement);
|
|
49
|
+
await collapse$2(input);
|
|
41
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Clear the selection, if there are any options selected.
|
|
53
|
+
* @param input - You can refer to this element by the label you applied to the `DatePicker`
|
|
54
|
+
*/
|
|
42
55
|
async function clear$2(input) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
56
|
+
const datePickerContainer = getContainerFromInput(input);
|
|
57
|
+
const clearButton = queries.getByLabelText(datePickerContainer, "Clear selection");
|
|
58
|
+
fireEvent.click(clearButton);
|
|
59
|
+
await collapse$2(input);
|
|
47
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Get options elements currently selected in the `DatePicker` calendar.
|
|
63
|
+
* @param input - You can refer to this element by the label you applied to the `DatePicker`
|
|
64
|
+
*/
|
|
48
65
|
async function getSelectedDates$1(input) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
await collapse$2(input);
|
|
55
|
-
return selectedDays;
|
|
66
|
+
const datePickerContainer = getContainerFromInput(input);
|
|
67
|
+
await expand$2(input);
|
|
68
|
+
const selectedDays = queries.queryAllByRole(datePickerContainer, "checkbox", { checked: true });
|
|
69
|
+
await collapse$2(input);
|
|
70
|
+
return selectedDays;
|
|
56
71
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
72
|
+
var datePickerEvent = {
|
|
73
|
+
getContainer: getContainerFromInput,
|
|
74
|
+
expand: expand$2,
|
|
75
|
+
collapse: collapse$2,
|
|
76
|
+
pick: pick$1,
|
|
77
|
+
clear: clear$2,
|
|
78
|
+
getSelectedDates: getSelectedDates$1
|
|
64
79
|
};
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/testing/DatePickerEvent/DateRangePickerEvent.ts
|
|
82
|
+
/**
|
|
83
|
+
* Expand the `DatePicker` calendar, if it not already expanded.
|
|
84
|
+
* @param input - You can refer to this element by the label you applied to the `DatePicker`
|
|
85
|
+
*/
|
|
65
86
|
async function expand$1(input) {
|
|
66
|
-
|
|
87
|
+
await datePickerEvent.expand(input);
|
|
67
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Collapse the `DatePicker` calendar, if it not already collapsed.
|
|
91
|
+
* @param input - You can refer to this element by the label you applied to the `DatePicker`
|
|
92
|
+
*/
|
|
68
93
|
async function collapse$1(input) {
|
|
69
|
-
|
|
94
|
+
await datePickerEvent.collapse(input);
|
|
70
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Pick (select) the provided day in the current month/year.
|
|
98
|
+
* Notice that we programmatically expand the `DatePicker` calendar before picking the date.
|
|
99
|
+
* @param day - Label for the day to be picked, formatted as mm/dd/yyyy.
|
|
100
|
+
* @param input - You can refer to this element by the label you applied to the `DatePicker`
|
|
101
|
+
*/
|
|
71
102
|
async function pick(range, input) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
103
|
+
const dateRangePickerContainer = datePickerEvent.getContainer(input);
|
|
104
|
+
await expand$1(input);
|
|
105
|
+
const [rangeStart, rangeEnd] = range;
|
|
106
|
+
if (rangeStart != null) {
|
|
107
|
+
const dateRangeStartInput = queries.getByTestId(dateRangePickerContainer, "input-date-range-start");
|
|
108
|
+
await datePickerEvent.pick(rangeStart, dateRangeStartInput);
|
|
109
|
+
}
|
|
110
|
+
if (rangeEnd != null) {
|
|
111
|
+
const dateRangeEndInput = queries.getByTestId(dateRangePickerContainer, "input-date-range-end");
|
|
112
|
+
await datePickerEvent.pick(rangeEnd, dateRangeEndInput);
|
|
113
|
+
}
|
|
114
|
+
await collapse$1(input);
|
|
84
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Clear the selection, if there are any options selected.
|
|
118
|
+
* @param input - You can refer to this element by the label you applied to the `DatePicker`
|
|
119
|
+
*/
|
|
85
120
|
async function clear$1(input) {
|
|
86
|
-
|
|
121
|
+
await datePickerEvent.clear(input);
|
|
87
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Get options elements currently selected in the `DatePicker` calendar.
|
|
125
|
+
* @param input - You can refer to this element by the label you applied to the `DatePicker`
|
|
126
|
+
*/
|
|
88
127
|
async function getSelectedDates(input) {
|
|
89
|
-
|
|
128
|
+
return datePickerEvent.getSelectedDates(input);
|
|
90
129
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
130
|
+
var dateRangePickerEvent = {
|
|
131
|
+
getContainer: datePickerEvent.getContainer,
|
|
132
|
+
expand: expand$1,
|
|
133
|
+
collapse: collapse$1,
|
|
134
|
+
pick,
|
|
135
|
+
clear: clear$1,
|
|
136
|
+
getSelectedDates
|
|
98
137
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/testing/DragDropFileEvent/DragDropFileEvent.ts
|
|
140
|
+
/**
|
|
141
|
+
* Get the input dropzone, which is the input parent (label).
|
|
142
|
+
* @param input - You can refer to this element by the aria-label you provide to the DragDropFile component
|
|
143
|
+
*/
|
|
144
|
+
var getDropZoneFromInput = (input) => input.parentNode;
|
|
145
|
+
/**
|
|
146
|
+
* Simulates the onDragOver event on the drop zone.
|
|
147
|
+
* @param input - You can refer to this element by the aria-label you provide to the DragDropFile component
|
|
148
|
+
*/
|
|
149
|
+
var dragOver = (input) => {
|
|
150
|
+
const dropzone = getDropZoneFromInput(input);
|
|
151
|
+
fireEvent(dropzone, createEvent.dragOver(dropzone));
|
|
104
152
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Simulates the onDragLeave event on the drop zone.
|
|
155
|
+
* @param input - You can refer to this element by the aria-label you provide to the DragDropFile component
|
|
156
|
+
*/
|
|
157
|
+
var dragLeave = (input) => {
|
|
158
|
+
const dropzone = getDropZoneFromInput(input);
|
|
159
|
+
fireEvent(dropzone, createEvent.dragLeave(dropzone));
|
|
109
160
|
};
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
161
|
+
/**
|
|
162
|
+
* Simulates the onDrop event on the drop zone. You can provide a list of files or a single file.
|
|
163
|
+
* @param input - You can refer to this element by the aria-label you provide to the DragDropFile component
|
|
164
|
+
*/
|
|
165
|
+
var dropFiles = (input, files) => {
|
|
166
|
+
const dropzone = getDropZoneFromInput(input);
|
|
167
|
+
const fileDropEvent = createEvent.drop(dropzone);
|
|
168
|
+
Object.defineProperty(fileDropEvent, "dataTransfer", { value: { files: toArray(files) } });
|
|
169
|
+
fireEvent(dropzone, fileDropEvent);
|
|
119
170
|
};
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
171
|
+
var DragDropFileEvent = {
|
|
172
|
+
dragOver,
|
|
173
|
+
dragLeave,
|
|
174
|
+
dropFiles
|
|
124
175
|
};
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/testing/SelectEvent/SelectEvent.ts
|
|
125
178
|
function getSelectContainer(input) {
|
|
126
|
-
|
|
179
|
+
return input.parentNode.parentNode.parentNode;
|
|
127
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Please, make sure to call expand before trying to get the menu container
|
|
183
|
+
*/
|
|
128
184
|
function getSelectMenu(input) {
|
|
129
|
-
|
|
185
|
+
return input.parentNode.parentNode.nextSibling;
|
|
130
186
|
}
|
|
131
187
|
function getSelectTriggerHandle(input) {
|
|
132
|
-
|
|
188
|
+
return input.parentNode.nextSibling.nextSibling;
|
|
133
189
|
}
|
|
134
190
|
function getSelectSearchContainer(input) {
|
|
135
|
-
|
|
191
|
+
return input.parentNode;
|
|
136
192
|
}
|
|
137
193
|
function isSelectMenuExpanded(input) {
|
|
138
|
-
|
|
139
|
-
|
|
194
|
+
/**
|
|
195
|
+
* Once the select is expanded, we have the following structure:
|
|
196
|
+
* +-------------+
|
|
197
|
+
* | Close button (visually hidden)
|
|
198
|
+
* +-------------+
|
|
199
|
+
* | DropdownTrigger
|
|
200
|
+
* +-------------+
|
|
201
|
+
* | Popover
|
|
202
|
+
* +-------------+
|
|
203
|
+
*
|
|
204
|
+
* This, if the container has 3 children, we assume the menu is expanded
|
|
205
|
+
*/
|
|
206
|
+
return getSelectContainer(input).children.length === 3;
|
|
140
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* This is needed because some datasources might be asynchronous.
|
|
210
|
+
* To ensure that the data they retrieve will be available, we wait for the
|
|
211
|
+
* querying phase to finish.
|
|
212
|
+
* @param input - You can refer to this element by the label you applied to the `Select`.
|
|
213
|
+
*/
|
|
141
214
|
async function waitForPendingQuery(input) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
await waitForElementToBeRemoved(() => within(searchContainer).queryByTestId("select-trigger-loading"), {
|
|
147
|
-
timeout: 2500
|
|
148
|
-
});
|
|
215
|
+
const searchContainer = getSelectSearchContainer(input);
|
|
216
|
+
if (!within(searchContainer).queryByTestId("select-trigger-loading")) return;
|
|
217
|
+
await waitForElementToBeRemoved(() => within(searchContainer).queryByTestId("select-trigger-loading"), { timeout: 2500 });
|
|
149
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Expand the `Select` menu, if it not already expanded.
|
|
221
|
+
* input - You can refer to this element by the label you applied to the `Select`.
|
|
222
|
+
*/
|
|
150
223
|
async function expand(input) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
224
|
+
await waitForPendingQuery(input);
|
|
225
|
+
if (isSelectMenuExpanded(input)) return;
|
|
226
|
+
const triggerHandle = getSelectTriggerHandle(input);
|
|
227
|
+
await waitFor(() => {
|
|
228
|
+
expect(triggerHandle).toBeEnabled();
|
|
229
|
+
});
|
|
230
|
+
/**
|
|
231
|
+
* Using act and a manually dispatched event so we can account for the
|
|
232
|
+
* state changes that happen when the search input is clicked.
|
|
233
|
+
* This is mainly related to the `handleEvent` from the `useClickOutside` hook.
|
|
234
|
+
*/
|
|
235
|
+
act(() => {
|
|
236
|
+
input.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
237
|
+
});
|
|
238
|
+
await waitFor(() => {
|
|
239
|
+
expect(within(getSelectContainer(input)).getByRole("listbox")).toBeInTheDocument();
|
|
240
|
+
});
|
|
167
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* Collapse the `Select` menu, if it not already collapsed.
|
|
244
|
+
* @param input - You can refer to this element by the label you applied to the `Select`.
|
|
245
|
+
*/
|
|
168
246
|
async function collapse(input) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
expect(within(getSelectContainer(input)).queryByRole("listbox")).not.toBeInTheDocument();
|
|
176
|
-
});
|
|
247
|
+
if (!isSelectMenuExpanded(input)) return;
|
|
248
|
+
const triggerHandle = getSelectTriggerHandle(input);
|
|
249
|
+
fireEvent.click(triggerHandle);
|
|
250
|
+
await waitFor(() => {
|
|
251
|
+
expect(within(getSelectContainer(input)).queryByRole("listbox")).not.toBeInTheDocument();
|
|
252
|
+
});
|
|
177
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* Select the provided option(s), if they are present in the menu.
|
|
256
|
+
* Notice that we programatically expand the `Select` menu before select the item
|
|
257
|
+
* @param option - Label for the option to be selected.
|
|
258
|
+
* @param input - You can refer to this element by the label you applied to the `Select`.
|
|
259
|
+
*/
|
|
178
260
|
async function select(option, input) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
261
|
+
await expand(input);
|
|
262
|
+
const optionElement = await within(getSelectMenu(input)).findByLabelText(option);
|
|
263
|
+
if (optionElement.getAttribute("aria-selected") == "false") {
|
|
264
|
+
/**
|
|
265
|
+
* This is a replacement for the `userEvent.click`.
|
|
266
|
+
* We are adopting this approach to remove the peer dep to @testing-library/user-event for
|
|
267
|
+
* applications using this helper, so they are not tied to the same user-event as this library.
|
|
268
|
+
* It follows the same sequence of event stated in the documentation available at:
|
|
269
|
+
* https://testing-library.com/docs/guide-events/#interactions-vs-events
|
|
270
|
+
*/
|
|
271
|
+
fireEvent.mouseDown(optionElement);
|
|
272
|
+
act(() => {
|
|
273
|
+
optionElement.focus();
|
|
274
|
+
});
|
|
275
|
+
fireEvent.mouseUp(optionElement);
|
|
276
|
+
fireEvent.click(optionElement);
|
|
277
|
+
}
|
|
278
|
+
await collapse(input);
|
|
191
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* Unselect the provided option(s), if they are present in the menu AND are selected.
|
|
282
|
+
* Notice that we programatically expand the `Select` menu before select the item
|
|
283
|
+
* @param option - Label for the option to be unselected.
|
|
284
|
+
* @param input - You can refer to this element by the label you applied to the `Select`.
|
|
285
|
+
*/
|
|
192
286
|
async function unselect(option, input) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
fireEvent.click(optionElement);
|
|
198
|
-
}
|
|
199
|
-
await collapse(input);
|
|
287
|
+
await expand(input);
|
|
288
|
+
const optionElement = await within(getSelectMenu(input)).findByLabelText(option);
|
|
289
|
+
if (optionElement.getAttribute("aria-selected") === "true") fireEvent.click(optionElement);
|
|
290
|
+
await collapse(input);
|
|
200
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* Clear the selection, if there are any options selected.
|
|
294
|
+
* @param input - You can refer to this element by the label you applied to the `Select`.
|
|
295
|
+
*/
|
|
201
296
|
async function clear(input) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
fireEvent.click(clearButton);
|
|
297
|
+
await waitForPendingQuery(input);
|
|
298
|
+
const clearButton = within(getSelectSearchContainer(input)).getByTestId("select-trigger-clear");
|
|
299
|
+
fireEvent.click(clearButton);
|
|
206
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Perform search based on the given `query`. It will fail if the option is not found.
|
|
303
|
+
* @param query - Search term.
|
|
304
|
+
* @param input - You can refer to this element by the label you applied to the `Select`.
|
|
305
|
+
*/
|
|
207
306
|
async function search(query, input) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
await waitForPendingQuery(input);
|
|
214
|
-
const menuContainer = getSelectMenu(input);
|
|
215
|
-
await within(menuContainer).findAllByRole("option");
|
|
307
|
+
fireEvent.change(input, { target: { value: query } });
|
|
308
|
+
await waitForPendingQuery(input);
|
|
309
|
+
await within(getSelectMenu(input)).findAllByRole("option");
|
|
216
310
|
}
|
|
311
|
+
/**
|
|
312
|
+
* Get options elements currently available in the `Select` menu.
|
|
313
|
+
* @param input - You can refer to this element by the label you applied to the `Select`.
|
|
314
|
+
*/
|
|
217
315
|
async function getOptions(input) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
return options;
|
|
316
|
+
await expand(input);
|
|
317
|
+
const options = within(getSelectMenu(input)).queryAllByRole("option");
|
|
318
|
+
await collapse(input);
|
|
319
|
+
return options;
|
|
223
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* Get options elements currently selected in the `Select` menu.
|
|
323
|
+
* @param input - You can refer to this element by the label you applied to the `Select`.
|
|
324
|
+
*/
|
|
224
325
|
async function getSelectedOptions(input) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
await collapse(input);
|
|
236
|
-
return selectedOptions;
|
|
326
|
+
await expand(input);
|
|
327
|
+
const menuContainer = getSelectMenu(input);
|
|
328
|
+
let selectedOptions = [];
|
|
329
|
+
try {
|
|
330
|
+
selectedOptions = await within(menuContainer).findAllByRole("option", { selected: true });
|
|
331
|
+
} catch {
|
|
332
|
+
selectedOptions = [];
|
|
333
|
+
}
|
|
334
|
+
await collapse(input);
|
|
335
|
+
return selectedOptions;
|
|
237
336
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
337
|
+
var selectEvent = {
|
|
338
|
+
select,
|
|
339
|
+
unselect,
|
|
340
|
+
clear,
|
|
341
|
+
search,
|
|
342
|
+
expand,
|
|
343
|
+
collapse,
|
|
344
|
+
getOptions,
|
|
345
|
+
getSelectedOptions,
|
|
346
|
+
isMenuExpanded: isSelectMenuExpanded
|
|
248
347
|
};
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region src/testing/getInterpolatedStyles/getInterpolatedStyles.ts
|
|
350
|
+
/**
|
|
351
|
+
* Use this function to simulate the CSS that would be generated by styled-components
|
|
352
|
+
* @param styles - A `css` reference with interpolated styles
|
|
353
|
+
* @returns The final CSS
|
|
354
|
+
*/
|
|
249
355
|
function getInterpolatedStyles(styles) {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
return interpolation;
|
|
257
|
-
}).join("");
|
|
356
|
+
return toArray(styles).map((interpolation) => {
|
|
357
|
+
while (isFunction(interpolation)) interpolation = interpolation({ theme: alice });
|
|
358
|
+
return interpolation;
|
|
359
|
+
}).join("");
|
|
258
360
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
361
|
+
//#endregion
|
|
362
|
+
//#region src/testing/renderWithDragDropFileProvider/renderWithDragDropFileProvider.tsx
|
|
363
|
+
var defaultContextValueMock = {
|
|
364
|
+
fileList: [],
|
|
365
|
+
onFilesAdded: jest.fn(),
|
|
366
|
+
onRetryUpload: jest.fn(),
|
|
367
|
+
onRemoveFile: jest.fn()
|
|
264
368
|
};
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
369
|
+
var renderWithDragDropFileProvider = (ui, customContext) => {
|
|
370
|
+
const contextValue = {
|
|
371
|
+
...defaultContextValueMock,
|
|
372
|
+
...customContext
|
|
373
|
+
};
|
|
374
|
+
const renderedUi = (children) => /* @__PURE__ */ React.createElement(DragDropFileContext.Provider, { value: contextValue }, children);
|
|
375
|
+
return render(renderedUi(ui));
|
|
272
376
|
};
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
selectEvent as SelectEvent,
|
|
278
|
-
getInterpolatedStyles,
|
|
279
|
-
renderWithDragDropFileProvider
|
|
280
|
-
};
|
|
281
|
-
//# sourceMappingURL=index.js.map
|
|
377
|
+
//#endregion
|
|
378
|
+
export { datePickerEvent as DatePickerEvent, dateRangePickerEvent as DateRangePickerEvent, DragDropFileEvent, selectEvent as SelectEvent, getInterpolatedStyles, renderWithDragDropFileProvider };
|
|
379
|
+
|
|
380
|
+
//# sourceMappingURL=index.js.map
|