@linzjs/step-ag-grid 8.4.3 → 9.0.0
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/README.md +4 -4
- package/dist/index.css +3 -0
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +5 -4
- package/dist/src/utils/textMatcher.d.ts +1 -1
- package/dist/src/utils/textMatcher.test.d.ts +1 -0
- package/dist/step-ag-grid.esm.js +464 -689
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +42 -42
- package/src/components/Grid.tsx +29 -27
- package/src/components/gridForm/GridFormDropDown.tsx +2 -2
- package/src/components/gridForm/GridFormMultiSelect.tsx +12 -6
- package/src/components/gridForm/GridFormSubComponentTextArea.tsx +0 -1
- package/src/components/gridForm/GridFormSubComponentTextInput.tsx +0 -1
- package/src/lui/TextAreaInput.tsx +1 -1
- package/src/lui/TextInputFormatted.tsx +1 -1
- package/src/react-menu3/components/ControlledMenu.tsx +19 -6
- package/src/stories/grid/GridKeyboardInteractions.stories.tsx +261 -0
- package/src/stories/grid/{GridPopoutBearing.stories.tsx → GridPopoverEditBearing.stories.tsx} +4 -4
- package/src/stories/grid/{GridPopoutEditDropDown.stories.tsx → GridPopoverEditDropDown.stories.tsx} +0 -0
- package/src/stories/grid/{GridPopoutEditMultiSelect.stories.tsx → GridPopoverEditMultiSelect.stories.tsx} +0 -0
- package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +10 -1
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +1 -1
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +1 -1
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +153 -0
- package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +1 -1
- package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +1 -1
- package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +1 -1
- package/src/stories/react-menu/ReactMenu.stories.tsx +66 -3
- package/src/styles/Grid.scss +3 -0
- package/src/utils/testUtil.ts +1 -0
- package/src/utils/textMatcher.test.ts +38 -0
- package/src/utils/textMatcher.ts +9 -2
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -1416,6 +1416,26 @@ var ControlledMenuFr = function (_a, externalRef) {
|
|
|
1416
1416
|
ev.stopPropagation();
|
|
1417
1417
|
return;
|
|
1418
1418
|
}
|
|
1419
|
+
var invokeSave = function (reason) {
|
|
1420
|
+
var _a, _b;
|
|
1421
|
+
if (!(saveButtonRef === null || saveButtonRef === void 0 ? void 0 : saveButtonRef.current))
|
|
1422
|
+
return;
|
|
1423
|
+
(_a = saveButtonRef.current) === null || _a === void 0 ? void 0 : _a.setAttribute("data-reason", reason);
|
|
1424
|
+
(_b = saveButtonRef === null || saveButtonRef === void 0 ? void 0 : saveButtonRef.current) === null || _b === void 0 ? void 0 : _b.click();
|
|
1425
|
+
};
|
|
1426
|
+
var allowTabToSave = activeElement.getAttribute("data-allowtabtosave") == "true";
|
|
1427
|
+
if (allowTabToSave) {
|
|
1428
|
+
if (isDown) {
|
|
1429
|
+
ev.preventDefault();
|
|
1430
|
+
ev.stopPropagation();
|
|
1431
|
+
lastTabDownEl.current = activeElement;
|
|
1432
|
+
}
|
|
1433
|
+
else {
|
|
1434
|
+
lastTabDownEl.current == activeElement &&
|
|
1435
|
+
invokeSave(ev.shiftKey ? CloseReason.TAB_BACKWARD : CloseReason.TAB_FORWARD);
|
|
1436
|
+
}
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1419
1439
|
var inputElsIterator = thisDocument.querySelectorAll(".szh-menu--state-open input,textarea");
|
|
1420
1440
|
var inputEls = [];
|
|
1421
1441
|
inputElsIterator.forEach(function (el) { return inputEls.push(el); });
|
|
@@ -1428,14 +1448,6 @@ var ControlledMenuFr = function (_a, externalRef) {
|
|
|
1428
1448
|
return;
|
|
1429
1449
|
var isTextArea = activeElement.nodeName === "TEXTAREA";
|
|
1430
1450
|
var suppressEnterAutoSave = activeElement.getAttribute("data-disableenterautosave") == "true" || isTextArea;
|
|
1431
|
-
var allowTabToSave = activeElement.getAttribute("data-allowtabtosave") == "true";
|
|
1432
|
-
var invokeSave = function (reason) {
|
|
1433
|
-
var _a, _b;
|
|
1434
|
-
if (!(saveButtonRef === null || saveButtonRef === void 0 ? void 0 : saveButtonRef.current))
|
|
1435
|
-
return;
|
|
1436
|
-
(_a = saveButtonRef.current) === null || _a === void 0 ? void 0 : _a.setAttribute("data-reason", reason);
|
|
1437
|
-
(_b = saveButtonRef === null || saveButtonRef === void 0 ? void 0 : saveButtonRef.current) === null || _b === void 0 ? void 0 : _b.click();
|
|
1438
|
-
};
|
|
1439
1451
|
switch (activeElement.nodeName) {
|
|
1440
1452
|
case "TEXTAREA":
|
|
1441
1453
|
case "INPUT": {
|
|
@@ -2968,7 +2980,7 @@ var Grid = function (params) {
|
|
|
2968
2980
|
}, [columnDefs === null || columnDefs === void 0 ? void 0 : columnDefs.length, sizeColumnsToFit]);
|
|
2969
2981
|
return (jsxs("div", __assign({ "data-testid": params["data-testid"], className: clsx("Grid-container", "ag-theme-alpine", staleGrid && "Grid-sortIsStale", gridReady && params.rowData && "Grid-ready") }, { children: [params.quickFilter && (jsx("div", __assign({ className: "Grid-quickFilter" }, { children: jsx("input", { "aria-label": "Search", className: "lui-margin-top-xxs lui-margin-bottom-xxs Grid-quickFilterBox", type: "text", placeholder: (_a = params.quickFilterPlaceholder) !== null && _a !== void 0 ? _a : "Search...", value: internalQuickFilter, onChange: function (event) {
|
|
2970
2982
|
setInternalQuickFilter(event.target.value);
|
|
2971
|
-
} }) }))), jsx(AgGridReact, { animateRows: params.animateRows, rowClassRules: params.rowClassRules, defaultColDef: params.defaultColDef, getRowId: function (params) { return "".concat(params.data.id); }, suppressRowClickSelection: true, rowSelection: (_b = params.rowSelection) !== null && _b !== void 0 ? _b : "multiple", suppressBrowserResizeObserver: true, colResizeDefault: "shift", onFirstDataRendered: sizeColumnsToFit, onGridSizeChanged: sizeColumnsToFit, suppressClickEdit: true, onCellKeyPress: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, domLayout: params.domLayout, columnDefs: columnDefs, rowData: params.rowData, noRowsOverlayComponent: noRowsOverlayComponent, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: (_c = params.postSortRows) !== null && _c !== void 0 ? _c : postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection, onColumnMoved: params.onColumnMoved, alwaysShowVerticalScroll: params.alwaysShowVerticalScroll })] })));
|
|
2983
|
+
} }) }))), jsx("div", __assign({ style: { flex: 1 } }, { children: jsx(AgGridReact, { animateRows: params.animateRows, rowClassRules: params.rowClassRules, defaultColDef: params.defaultColDef, getRowId: function (params) { return "".concat(params.data.id); }, suppressRowClickSelection: true, rowSelection: (_b = params.rowSelection) !== null && _b !== void 0 ? _b : "multiple", suppressBrowserResizeObserver: true, colResizeDefault: "shift", onFirstDataRendered: sizeColumnsToFit, onGridSizeChanged: sizeColumnsToFit, suppressClickEdit: true, onCellKeyPress: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, domLayout: params.domLayout, columnDefs: columnDefs, rowData: params.rowData, noRowsOverlayComponent: noRowsOverlayComponent, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: (_c = params.postSortRows) !== null && _c !== void 0 ? _c : postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection, onColumnMoved: params.onColumnMoved, alwaysShowVerticalScroll: params.alwaysShowVerticalScroll }) }))] })));
|
|
2972
2984
|
};
|
|
2973
2985
|
|
|
2974
2986
|
var GridCellMultiSelectClassRules = {
|
|
@@ -3199,9 +3211,16 @@ function getDefaultExportFromCjs (x) {
|
|
|
3199
3211
|
}
|
|
3200
3212
|
|
|
3201
3213
|
function getAugmentedNamespace(n) {
|
|
3214
|
+
if (n.__esModule) return n;
|
|
3202
3215
|
var f = n.default;
|
|
3203
3216
|
if (typeof f == "function") {
|
|
3204
|
-
var a = function () {
|
|
3217
|
+
var a = function a () {
|
|
3218
|
+
if (this instanceof a) {
|
|
3219
|
+
var args = [null];
|
|
3220
|
+
args.push.apply(args, arguments);
|
|
3221
|
+
var Ctor = Function.bind.apply(f, args);
|
|
3222
|
+
return new Ctor();
|
|
3223
|
+
}
|
|
3205
3224
|
return f.apply(this, arguments);
|
|
3206
3225
|
};
|
|
3207
3226
|
a.prototype = f.prototype;
|
|
@@ -3324,6 +3343,163 @@ var FormError = function (props) {
|
|
|
3324
3343
|
return (jsxs(Fragment$1, { children: [props.error && (jsx("span", __assign({ className: "LuiTextInput-error", style: { paddingLeft: 0 } }, { children: props.error }))), props.helpText && !props.error && jsx("span", __assign({ className: "helpText" }, { children: props.helpText }))] }));
|
|
3325
3344
|
};
|
|
3326
3345
|
|
|
3346
|
+
function escapeStringRegexp(string) {
|
|
3347
|
+
if (typeof string !== 'string') {
|
|
3348
|
+
throw new TypeError('Expected a string');
|
|
3349
|
+
}
|
|
3350
|
+
|
|
3351
|
+
// Escape characters with special meaning either inside or outside character sets.
|
|
3352
|
+
// Use a simple backslash escape when it’s always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
|
|
3353
|
+
return string
|
|
3354
|
+
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
|
|
3355
|
+
.replace(/-/g, '\\x2d');
|
|
3356
|
+
}
|
|
3357
|
+
|
|
3358
|
+
const regexpCache = new Map();
|
|
3359
|
+
|
|
3360
|
+
const sanitizeArray = (input, inputName) => {
|
|
3361
|
+
if (!Array.isArray(input)) {
|
|
3362
|
+
switch (typeof input) {
|
|
3363
|
+
case 'string':
|
|
3364
|
+
input = [input];
|
|
3365
|
+
break;
|
|
3366
|
+
case 'undefined':
|
|
3367
|
+
input = [];
|
|
3368
|
+
break;
|
|
3369
|
+
default:
|
|
3370
|
+
throw new TypeError(`Expected '${inputName}' to be a string or an array, but got a type of '${typeof input}'`);
|
|
3371
|
+
}
|
|
3372
|
+
}
|
|
3373
|
+
|
|
3374
|
+
return input.filter(string => {
|
|
3375
|
+
if (typeof string !== 'string') {
|
|
3376
|
+
if (typeof string === 'undefined') {
|
|
3377
|
+
return false;
|
|
3378
|
+
}
|
|
3379
|
+
|
|
3380
|
+
throw new TypeError(`Expected '${inputName}' to be an array of strings, but found a type of '${typeof string}' in the array`);
|
|
3381
|
+
}
|
|
3382
|
+
|
|
3383
|
+
return true;
|
|
3384
|
+
});
|
|
3385
|
+
};
|
|
3386
|
+
|
|
3387
|
+
const makeRegexp = (pattern, options) => {
|
|
3388
|
+
options = {
|
|
3389
|
+
caseSensitive: false,
|
|
3390
|
+
...options,
|
|
3391
|
+
};
|
|
3392
|
+
|
|
3393
|
+
const cacheKey = pattern + JSON.stringify(options);
|
|
3394
|
+
|
|
3395
|
+
if (regexpCache.has(cacheKey)) {
|
|
3396
|
+
return regexpCache.get(cacheKey);
|
|
3397
|
+
}
|
|
3398
|
+
|
|
3399
|
+
const negated = pattern[0] === '!';
|
|
3400
|
+
|
|
3401
|
+
if (negated) {
|
|
3402
|
+
pattern = pattern.slice(1);
|
|
3403
|
+
}
|
|
3404
|
+
|
|
3405
|
+
pattern = escapeStringRegexp(pattern).replace(/\\\*/g, '[\\s\\S]*');
|
|
3406
|
+
|
|
3407
|
+
const regexp = new RegExp(`^${pattern}$`, options.caseSensitive ? '' : 'i');
|
|
3408
|
+
regexp.negated = negated;
|
|
3409
|
+
regexpCache.set(cacheKey, regexp);
|
|
3410
|
+
|
|
3411
|
+
return regexp;
|
|
3412
|
+
};
|
|
3413
|
+
|
|
3414
|
+
const baseMatcher = (inputs, patterns, options, firstMatchOnly) => {
|
|
3415
|
+
inputs = sanitizeArray(inputs, 'inputs');
|
|
3416
|
+
patterns = sanitizeArray(patterns, 'patterns');
|
|
3417
|
+
|
|
3418
|
+
if (patterns.length === 0) {
|
|
3419
|
+
return [];
|
|
3420
|
+
}
|
|
3421
|
+
|
|
3422
|
+
patterns = patterns.map(pattern => makeRegexp(pattern, options));
|
|
3423
|
+
|
|
3424
|
+
const {allPatterns} = options || {};
|
|
3425
|
+
const result = [];
|
|
3426
|
+
|
|
3427
|
+
for (const input of inputs) {
|
|
3428
|
+
// String is included only if it matches at least one non-negated pattern supplied.
|
|
3429
|
+
// Note: the `allPatterns` option requires every non-negated pattern to be matched once.
|
|
3430
|
+
// Matching a negated pattern excludes the string.
|
|
3431
|
+
let matches;
|
|
3432
|
+
const didFit = [...patterns].fill(false);
|
|
3433
|
+
|
|
3434
|
+
for (const [index, pattern] of patterns.entries()) {
|
|
3435
|
+
if (pattern.test(input)) {
|
|
3436
|
+
didFit[index] = true;
|
|
3437
|
+
matches = !pattern.negated;
|
|
3438
|
+
|
|
3439
|
+
if (!matches) {
|
|
3440
|
+
break;
|
|
3441
|
+
}
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
|
|
3445
|
+
if (
|
|
3446
|
+
!(
|
|
3447
|
+
matches === false
|
|
3448
|
+
|| (matches === undefined && patterns.some(pattern => !pattern.negated))
|
|
3449
|
+
|| (allPatterns && didFit.some((yes, index) => !yes && !patterns[index].negated))
|
|
3450
|
+
)
|
|
3451
|
+
) {
|
|
3452
|
+
result.push(input);
|
|
3453
|
+
|
|
3454
|
+
if (firstMatchOnly) {
|
|
3455
|
+
break;
|
|
3456
|
+
}
|
|
3457
|
+
}
|
|
3458
|
+
}
|
|
3459
|
+
|
|
3460
|
+
return result;
|
|
3461
|
+
};
|
|
3462
|
+
|
|
3463
|
+
function isMatch(inputs, patterns, options) {
|
|
3464
|
+
return baseMatcher(inputs, patterns, options, true).length > 0;
|
|
3465
|
+
}
|
|
3466
|
+
|
|
3467
|
+
/**
|
|
3468
|
+
* Text matching with wildcards and multiple matchers.
|
|
3469
|
+
*
|
|
3470
|
+
* "L" => L*
|
|
3471
|
+
* "=L" => L
|
|
3472
|
+
* "*L*" => *L*
|
|
3473
|
+
* "*L" => *L
|
|
3474
|
+
* "A B" => A* and B*
|
|
3475
|
+
* "A B, C" => (A* and B*) or C*
|
|
3476
|
+
* "!A" => all values must not match A
|
|
3477
|
+
* Returns true if there's a text match.
|
|
3478
|
+
*/
|
|
3479
|
+
var textMatch = function (text, filter) {
|
|
3480
|
+
if (text == null)
|
|
3481
|
+
return true;
|
|
3482
|
+
var superFilters = filter
|
|
3483
|
+
.split(",")
|
|
3484
|
+
.map(function (sf) { return sf.trim(); })
|
|
3485
|
+
.filter(function (sf) { return sf; })
|
|
3486
|
+
.map(function (r) {
|
|
3487
|
+
return r
|
|
3488
|
+
.split(/\s+/)
|
|
3489
|
+
.map(function (f) { return (f.startsWith("=") ? f.slice(1) : f + "*"); })
|
|
3490
|
+
.join(" ");
|
|
3491
|
+
});
|
|
3492
|
+
var _a = partition(superFilters, function (superFilters) { return superFilters.startsWith("!"); }), negativeFilters = _a[0], positiveFilters = _a[1];
|
|
3493
|
+
var values = text.replaceAll(",", " ").trim().split(/\s+/);
|
|
3494
|
+
return ((isEmpty(positiveFilters) || // Not filtered
|
|
3495
|
+
positiveFilters.some(function (superFilter) {
|
|
3496
|
+
var subFilters = superFilter.split(/\s+/).map(function (s) { return s.replaceAll(/([!?])/g, "\\$1"); });
|
|
3497
|
+
return subFilters.every(function (subFilter) { return values.some(function (value) { return isMatch(value, subFilter); }); });
|
|
3498
|
+
})) &&
|
|
3499
|
+
(isEmpty(negativeFilters) ||
|
|
3500
|
+
negativeFilters.every(function (superFilter) { return values.every(function (value) { return isMatch(value, superFilter); }); })));
|
|
3501
|
+
};
|
|
3502
|
+
|
|
3327
3503
|
var MenuSeparatorString = "_____MENU_SEPARATOR_____";
|
|
3328
3504
|
var MenuSeparator = Object.freeze({ value: MenuSeparatorString });
|
|
3329
3505
|
var MenuHeaderString = "_____MENU_HEADER_____";
|
|
@@ -3417,8 +3593,7 @@ var GridFormDropDown = function (props) {
|
|
|
3417
3593
|
console.error("Cannot filter non-string labels", option);
|
|
3418
3594
|
return undefined;
|
|
3419
3595
|
}
|
|
3420
|
-
|
|
3421
|
-
return str.toLowerCase().indexOf(filter.toLowerCase()) !== -1 ? option : undefined;
|
|
3596
|
+
return textMatch(option.label || "", filter) ? option : undefined;
|
|
3422
3597
|
})
|
|
3423
3598
|
.filter(function (r) { return r !== undefined; }));
|
|
3424
3599
|
}
|
|
@@ -3492,200 +3667,49 @@ var GridFormDropDown = function (props) {
|
|
|
3492
3667
|
showHeader = null;
|
|
3493
3668
|
if (item.value === MenuSeparatorString) {
|
|
3494
3669
|
return jsx(MenuDivider, {}, "$$divider_".concat(index));
|
|
3495
|
-
}
|
|
3496
|
-
else if (item.value === MenuHeaderString) {
|
|
3497
|
-
lastHeader = jsx(MenuHeader, { children: item.label }, "$$header_".concat(index));
|
|
3498
|
-
return jsx(Fragment$1, {});
|
|
3499
|
-
}
|
|
3500
|
-
else {
|
|
3501
|
-
if (lastHeader) {
|
|
3502
|
-
showHeader = lastHeader;
|
|
3503
|
-
lastHeader = null;
|
|
3504
|
-
}
|
|
3505
|
-
}
|
|
3506
|
-
return ((!filteredValues || filteredValues.includes(item)) && (jsxs(Fragment, { children: [showHeader, jsxs("div", { children: [jsxs(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onFocus: function () {
|
|
3507
|
-
if (selectedItem !== item) {
|
|
3508
|
-
setSelectedItem(item);
|
|
3509
|
-
setSubSelectedValue(null);
|
|
3510
|
-
subComponentIsValid.current = true;
|
|
3511
|
-
if (item.subComponent) {
|
|
3512
|
-
subComponentInitialValue.current = null;
|
|
3513
|
-
}
|
|
3514
|
-
}
|
|
3515
|
-
}, onClick: function (e) {
|
|
3516
|
-
e.keepOpen = !!item.subComponent;
|
|
3517
|
-
} }, { children: [(_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)), item.subComponent ? "..." : ""] }), "".concat(fieldToString(field), "-").concat(index)), item.subComponent && selectedItem === item && (jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function () { return (jsx(GridSubComponentContext.Provider, __assign({ value: {
|
|
3518
|
-
context: { options: options },
|
|
3519
|
-
data: data,
|
|
3520
|
-
value: subSelectedValue,
|
|
3521
|
-
setValue: function (value) {
|
|
3522
|
-
setSubSelectedValue(value);
|
|
3523
|
-
if (subComponentInitialValue.current === null) {
|
|
3524
|
-
// copy the default value of the subcomponent, so we can change detect on save
|
|
3525
|
-
subComponentInitialValue.current = JSON.stringify(value);
|
|
3526
|
-
}
|
|
3527
|
-
},
|
|
3528
|
-
setValid: function (valid) {
|
|
3529
|
-
subComponentIsValid.current = valid;
|
|
3530
|
-
},
|
|
3531
|
-
triggerSave: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3532
|
-
return __generator(this, function (_a) {
|
|
3533
|
-
return [2 /*return*/];
|
|
3534
|
-
});
|
|
3535
|
-
}); }
|
|
3536
|
-
} }, { children: item.subComponent && (jsx("div", __assign({ className: "subComponent" }, { children: jsx(item.subComponent, {}) }))) }))); } }), "".concat(item.label, "_subcomponent")))] }, "menu-wrapper-".concat(index))] }, "".concat(index))));
|
|
3537
|
-
})] }) }))] }));
|
|
3538
|
-
};
|
|
3539
|
-
|
|
3540
|
-
function escapeStringRegexp(string) {
|
|
3541
|
-
if (typeof string !== 'string') {
|
|
3542
|
-
throw new TypeError('Expected a string');
|
|
3543
|
-
}
|
|
3544
|
-
|
|
3545
|
-
// Escape characters with special meaning either inside or outside character sets.
|
|
3546
|
-
// Use a simple backslash escape when it’s always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
|
|
3547
|
-
return string
|
|
3548
|
-
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
|
|
3549
|
-
.replace(/-/g, '\\x2d');
|
|
3550
|
-
}
|
|
3551
|
-
|
|
3552
|
-
const regexpCache = new Map();
|
|
3553
|
-
|
|
3554
|
-
const sanitizeArray = (input, inputName) => {
|
|
3555
|
-
if (!Array.isArray(input)) {
|
|
3556
|
-
switch (typeof input) {
|
|
3557
|
-
case 'string':
|
|
3558
|
-
input = [input];
|
|
3559
|
-
break;
|
|
3560
|
-
case 'undefined':
|
|
3561
|
-
input = [];
|
|
3562
|
-
break;
|
|
3563
|
-
default:
|
|
3564
|
-
throw new TypeError(`Expected '${inputName}' to be a string or an array, but got a type of '${typeof input}'`);
|
|
3565
|
-
}
|
|
3566
|
-
}
|
|
3567
|
-
|
|
3568
|
-
return input.filter(string => {
|
|
3569
|
-
if (typeof string !== 'string') {
|
|
3570
|
-
if (typeof string === 'undefined') {
|
|
3571
|
-
return false;
|
|
3572
|
-
}
|
|
3573
|
-
|
|
3574
|
-
throw new TypeError(`Expected '${inputName}' to be an array of strings, but found a type of '${typeof string}' in the array`);
|
|
3575
|
-
}
|
|
3576
|
-
|
|
3577
|
-
return true;
|
|
3578
|
-
});
|
|
3579
|
-
};
|
|
3580
|
-
|
|
3581
|
-
const makeRegexp = (pattern, options) => {
|
|
3582
|
-
options = {
|
|
3583
|
-
caseSensitive: false,
|
|
3584
|
-
...options,
|
|
3585
|
-
};
|
|
3586
|
-
|
|
3587
|
-
const cacheKey = pattern + JSON.stringify(options);
|
|
3588
|
-
|
|
3589
|
-
if (regexpCache.has(cacheKey)) {
|
|
3590
|
-
return regexpCache.get(cacheKey);
|
|
3591
|
-
}
|
|
3592
|
-
|
|
3593
|
-
const negated = pattern[0] === '!';
|
|
3594
|
-
|
|
3595
|
-
if (negated) {
|
|
3596
|
-
pattern = pattern.slice(1);
|
|
3597
|
-
}
|
|
3598
|
-
|
|
3599
|
-
pattern = escapeStringRegexp(pattern).replace(/\\\*/g, '[\\s\\S]*');
|
|
3600
|
-
|
|
3601
|
-
const regexp = new RegExp(`^${pattern}$`, options.caseSensitive ? '' : 'i');
|
|
3602
|
-
regexp.negated = negated;
|
|
3603
|
-
regexpCache.set(cacheKey, regexp);
|
|
3604
|
-
|
|
3605
|
-
return regexp;
|
|
3606
|
-
};
|
|
3607
|
-
|
|
3608
|
-
const baseMatcher = (inputs, patterns, options, firstMatchOnly) => {
|
|
3609
|
-
inputs = sanitizeArray(inputs, 'inputs');
|
|
3610
|
-
patterns = sanitizeArray(patterns, 'patterns');
|
|
3611
|
-
|
|
3612
|
-
if (patterns.length === 0) {
|
|
3613
|
-
return [];
|
|
3614
|
-
}
|
|
3615
|
-
|
|
3616
|
-
patterns = patterns.map(pattern => makeRegexp(pattern, options));
|
|
3617
|
-
|
|
3618
|
-
const {allPatterns} = options || {};
|
|
3619
|
-
const result = [];
|
|
3620
|
-
|
|
3621
|
-
for (const input of inputs) {
|
|
3622
|
-
// String is included only if it matches at least one non-negated pattern supplied.
|
|
3623
|
-
// Note: the `allPatterns` option requires every non-negated pattern to be matched once.
|
|
3624
|
-
// Matching a negated pattern excludes the string.
|
|
3625
|
-
let matches;
|
|
3626
|
-
const didFit = [...patterns].fill(false);
|
|
3627
|
-
|
|
3628
|
-
for (const [index, pattern] of patterns.entries()) {
|
|
3629
|
-
if (pattern.test(input)) {
|
|
3630
|
-
didFit[index] = true;
|
|
3631
|
-
matches = !pattern.negated;
|
|
3632
|
-
|
|
3633
|
-
if (!matches) {
|
|
3634
|
-
break;
|
|
3635
|
-
}
|
|
3636
|
-
}
|
|
3637
|
-
}
|
|
3638
|
-
|
|
3639
|
-
if (
|
|
3640
|
-
!(
|
|
3641
|
-
matches === false
|
|
3642
|
-
|| (matches === undefined && patterns.some(pattern => !pattern.negated))
|
|
3643
|
-
|| (allPatterns && didFit.some((yes, index) => !yes && !patterns[index].negated))
|
|
3644
|
-
)
|
|
3645
|
-
) {
|
|
3646
|
-
result.push(input);
|
|
3647
|
-
|
|
3648
|
-
if (firstMatchOnly) {
|
|
3649
|
-
break;
|
|
3650
|
-
}
|
|
3651
|
-
}
|
|
3652
|
-
}
|
|
3653
|
-
|
|
3654
|
-
return result;
|
|
3655
|
-
};
|
|
3656
|
-
|
|
3657
|
-
function isMatch(inputs, patterns, options) {
|
|
3658
|
-
return baseMatcher(inputs, patterns, options, true).length > 0;
|
|
3659
|
-
}
|
|
3660
|
-
|
|
3661
|
-
/**
|
|
3662
|
-
* Text matching with wildcards and multiple matchers.
|
|
3663
|
-
*
|
|
3664
|
-
* "L" => L*
|
|
3665
|
-
* "L*" => L*
|
|
3666
|
-
* "*L*" => *L*
|
|
3667
|
-
* "*L" => *L
|
|
3668
|
-
* "A B" => A* and B*
|
|
3669
|
-
* "A B, C" => (A* and B*) or C*
|
|
3670
|
-
* "!A" => all values must not match A
|
|
3671
|
-
* Returns true if there's a text match.
|
|
3672
|
-
*/
|
|
3673
|
-
var textMatch = function (text, filter) {
|
|
3674
|
-
if (text == null)
|
|
3675
|
-
return true;
|
|
3676
|
-
var superFilters = filter
|
|
3677
|
-
.split(",")
|
|
3678
|
-
.map(function (sf) { return sf.trim(); })
|
|
3679
|
-
.filter(function (sf) { return sf; });
|
|
3680
|
-
var _a = partition(superFilters, function (superFilters) { return superFilters.startsWith("!"); }), negativeFilters = _a[0], positiveFilters = _a[1];
|
|
3681
|
-
var values = text.replaceAll(",", " ").trim().split(/\s+/);
|
|
3682
|
-
return ((isEmpty(positiveFilters) || // Not filtered
|
|
3683
|
-
positiveFilters.some(function (superFilter) {
|
|
3684
|
-
var subFilters = superFilter.split(/\s+/).map(function (s) { return s.replaceAll(/([!?])/g, "\\$1"); });
|
|
3685
|
-
return subFilters.every(function (subFilter) { return values.some(function (value) { return isMatch(value, subFilter); }); });
|
|
3686
|
-
})) &&
|
|
3687
|
-
(isEmpty(negativeFilters) ||
|
|
3688
|
-
negativeFilters.every(function (superFilter) { return values.every(function (value) { return isMatch(value, superFilter); }); })));
|
|
3670
|
+
}
|
|
3671
|
+
else if (item.value === MenuHeaderString) {
|
|
3672
|
+
lastHeader = jsx(MenuHeader, { children: item.label }, "$$header_".concat(index));
|
|
3673
|
+
return jsx(Fragment$1, {});
|
|
3674
|
+
}
|
|
3675
|
+
else {
|
|
3676
|
+
if (lastHeader) {
|
|
3677
|
+
showHeader = lastHeader;
|
|
3678
|
+
lastHeader = null;
|
|
3679
|
+
}
|
|
3680
|
+
}
|
|
3681
|
+
return ((!filteredValues || filteredValues.includes(item)) && (jsxs(Fragment, { children: [showHeader, jsxs("div", { children: [jsxs(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onFocus: function () {
|
|
3682
|
+
if (selectedItem !== item) {
|
|
3683
|
+
setSelectedItem(item);
|
|
3684
|
+
setSubSelectedValue(null);
|
|
3685
|
+
subComponentIsValid.current = true;
|
|
3686
|
+
if (item.subComponent) {
|
|
3687
|
+
subComponentInitialValue.current = null;
|
|
3688
|
+
}
|
|
3689
|
+
}
|
|
3690
|
+
}, onClick: function (e) {
|
|
3691
|
+
e.keepOpen = !!item.subComponent;
|
|
3692
|
+
} }, { children: [(_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)), item.subComponent ? "..." : ""] }), "".concat(fieldToString(field), "-").concat(index)), item.subComponent && selectedItem === item && (jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function () { return (jsx(GridSubComponentContext.Provider, __assign({ value: {
|
|
3693
|
+
context: { options: options },
|
|
3694
|
+
data: data,
|
|
3695
|
+
value: subSelectedValue,
|
|
3696
|
+
setValue: function (value) {
|
|
3697
|
+
setSubSelectedValue(value);
|
|
3698
|
+
if (subComponentInitialValue.current === null) {
|
|
3699
|
+
// copy the default value of the subcomponent, so we can change detect on save
|
|
3700
|
+
subComponentInitialValue.current = JSON.stringify(value);
|
|
3701
|
+
}
|
|
3702
|
+
},
|
|
3703
|
+
setValid: function (valid) {
|
|
3704
|
+
subComponentIsValid.current = valid;
|
|
3705
|
+
},
|
|
3706
|
+
triggerSave: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3707
|
+
return __generator(this, function (_a) {
|
|
3708
|
+
return [2 /*return*/];
|
|
3709
|
+
});
|
|
3710
|
+
}); }
|
|
3711
|
+
} }, { children: item.subComponent && (jsx("div", __assign({ className: "subComponent" }, { children: jsx(item.subComponent, {}) }))) }))); } }), "".concat(item.label, "_subcomponent")))] }, "menu-wrapper-".concat(index))] }, "".concat(index))));
|
|
3712
|
+
})] }) }))] }));
|
|
3689
3713
|
};
|
|
3690
3714
|
|
|
3691
3715
|
var GridFormMultiSelect = function (props) {
|
|
@@ -3784,10 +3808,11 @@ var GridFormMultiSelect = function (props) {
|
|
|
3784
3808
|
invalid: invalid,
|
|
3785
3809
|
save: save
|
|
3786
3810
|
}), popoverWrapper = _f.popoverWrapper, triggerSave = _f.triggerSave;
|
|
3787
|
-
return popoverWrapper(jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormMultiSelect-container" }, { children: options && (jsxs(Fragment$1, { children: [props.filtered && (jsx(FilterInput, __assign({}, { headerGroups: headerGroups, options: options, setOptions: setOptions, filter: filter, setFilter: setFilter, triggerSave: triggerSave }, { filterHelpText: props.filterHelpText, onSelectFilter: props.onSelectFilter, filterPlaceholder: props.filterPlaceholder }))), headerGroups &&
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3811
|
+
return popoverWrapper(jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormMultiSelect-container" }, { children: options && (jsxs(Fragment$1, { children: [props.filtered && (jsx(FilterInput, __assign({}, { headerGroups: headerGroups, options: options, setOptions: setOptions, filter: filter, setFilter: setFilter, triggerSave: triggerSave }, { filterHelpText: props.filterHelpText, onSelectFilter: props.onSelectFilter, filterPlaceholder: props.filterPlaceholder }))), headerGroups &&
|
|
3812
|
+
(isEmpty(headerGroups) || !toPairs(headerGroups).some(function (_a) {
|
|
3813
|
+
_a[0]; var options = _a[1];
|
|
3814
|
+
return !isEmpty(options);
|
|
3815
|
+
})) && (jsx(MenuItem, __assign({ className: "GridMultiSelect-noOptions", disabled: true }, { children: (_a = props.noOptionsMessage) !== null && _a !== void 0 ? _a : "No Options" }), "noOptions")), headerGroups && !isEmpty(headerGroups) && (jsx("div", __assign({ className: "GridFormMultiSelect-options" }, { children: headers.map(function (header, index) {
|
|
3791
3816
|
var subOptions = headerGroups["".concat(header.filter)];
|
|
3792
3817
|
return (!isEmpty(subOptions) && (jsxs(Fragment, { children: [header.header && jsx(MenuHeader, { children: header.header }), subOptions.map(function (item, index) {
|
|
3793
3818
|
return item.value === MenuSeparatorString ? (jsx(MenuDivider, {}, "div_".concat(index))) : (jsxs(Fragment, { children: [jsx(MenuRadioItem, { item: item, options: options, setOptions: setOptions }), item.checked && item.subComponent && (jsx(MenuSubComponent, __assign({}, { item: item, options: options, setOptions: setOptions, data: data, triggerSave: triggerSave }, { subComponentIsValid: subComponentIsValidRef.current })))] }, "val_".concat(item.value)));
|
|
@@ -4166,7 +4191,7 @@ var css_248z$1 = ".LuiTextInput{margin-bottom:0}.LuiTextInput-formatted{color:#b
|
|
|
4166
4191
|
styleInject(css_248z$1);
|
|
4167
4192
|
|
|
4168
4193
|
var TextInputFormatted = function (props) {
|
|
4169
|
-
return (jsxs("div", __assign({ className: clsx("LuiTextInput Grid-popoverContainer", props.error && "hasError", props.className) }, { children: [jsxs("span", __assign({ className: "LuiTextInput-inputWrapper" }, { children: [jsx("input", __assign({ type: "text", spellCheck: true, defaultValue: props.value }, omit(props, ["error", "value", "helpText", "formatted", "className"]), { className: "LuiTextInput-input", onMouseEnter: function (e) {
|
|
4194
|
+
return (jsxs("div", __assign({ className: clsx("LuiTextInput Grid-popoverContainer", props.error && "hasError", props.className) }, { children: [jsxs("span", __assign({ className: "LuiTextInput-inputWrapper" }, { children: [jsx("input", __assign({ type: "text", spellCheck: true, defaultValue: props.value }, omit(props, ["error", "value", "helpText", "formatted", "className", "allowTabToSave"]), { className: "LuiTextInput-input", onMouseEnter: function (e) {
|
|
4170
4195
|
e.currentTarget.focus();
|
|
4171
4196
|
props.onMouseEnter && props.onMouseEnter(e);
|
|
4172
4197
|
}, "data-allowtabtosave": props.allowTabToSave })), jsx("span", __assign({ className: "LuiTextInput-formatted" }, { children: props.formatted }))] })), jsx(FormError, { error: props.error, helpText: props.helpText })] })));
|
|
@@ -4347,7 +4372,7 @@ var useGenerateOrDefaultId = function (idFromProps) {
|
|
|
4347
4372
|
var TextAreaInput = function (props) {
|
|
4348
4373
|
var _a;
|
|
4349
4374
|
var id = useGenerateOrDefaultId(props === null || props === void 0 ? void 0 : props.id);
|
|
4350
|
-
return (jsxs("div", __assign({ className: clsx("LuiTextAreaInput Grid-popoverContainer", props.disabled ? "isDisabled" : "", props.error ? "hasError" : "", props.className) }, { children: [jsxs("label", __assign({ htmlFor: id }, { children: [props.mandatory != null && jsx("span", __assign({ className: "LuiTextAreaInput-mandatory" }, { children: "*" })), props.label != null && jsx("span", __assign({ className: "LuiTextAreaInput-label" }, { children: props.label })), jsx("div", __assign({ className: "LuiTextAreaInput-wrapper" }, { children: jsx("textarea", __assign({ rows: 5 }, omit(props, ["error", "value", "helpText", "formatted", "className"]), { id: id, value: (_a = props.value) !== null && _a !== void 0 ? _a : "", spellCheck: true, onMouseEnter: function (e) {
|
|
4375
|
+
return (jsxs("div", __assign({ className: clsx("LuiTextAreaInput Grid-popoverContainer", props.disabled ? "isDisabled" : "", props.error ? "hasError" : "", props.className) }, { children: [jsxs("label", __assign({ htmlFor: id }, { children: [props.mandatory != null && jsx("span", __assign({ className: "LuiTextAreaInput-mandatory" }, { children: "*" })), props.label != null && jsx("span", __assign({ className: "LuiTextAreaInput-label" }, { children: props.label })), jsx("div", __assign({ className: "LuiTextAreaInput-wrapper" }, { children: jsx("textarea", __assign({ rows: 5 }, omit(props, ["error", "value", "helpText", "formatted", "className", "allowTabToSave"]), { id: id, value: (_a = props.value) !== null && _a !== void 0 ? _a : "", spellCheck: true, onMouseEnter: function (e) {
|
|
4351
4376
|
if (document.activeElement != e.currentTarget) {
|
|
4352
4377
|
e.currentTarget.focus();
|
|
4353
4378
|
e.currentTarget.selectionStart = e.currentTarget.value.length;
|
|
@@ -4498,7 +4523,7 @@ var GridFormSubComponentTextInput = function (props) {
|
|
|
4498
4523
|
useEffect(function () {
|
|
4499
4524
|
setValid(value != null && invalid() == null);
|
|
4500
4525
|
}, [setValid, invalid, value]);
|
|
4501
|
-
return (jsx(TextInputFormatted, { value: value, error: invalid(), onChange: function (e) { return setValue(e.target.value); }, helpText: helpText,
|
|
4526
|
+
return (jsx(TextInputFormatted, { value: value, error: invalid(), onChange: function (e) { return setValue(e.target.value); }, helpText: helpText, placeholder: props.placeholder, style: { width: "100%" }, allowTabToSave: true }));
|
|
4502
4527
|
};
|
|
4503
4528
|
|
|
4504
4529
|
var GridFormSubComponentTextArea = function (props) {
|
|
@@ -4514,7 +4539,7 @@ var GridFormSubComponentTextArea = function (props) {
|
|
|
4514
4539
|
useEffect(function () {
|
|
4515
4540
|
setValid(value != null && invalid() == null);
|
|
4516
4541
|
}, [setValid, invalid, value]);
|
|
4517
|
-
return (jsx("div", __assign({ className: clsx("FreeTextInput", props.className) }, { children: jsx(TextAreaInput, { className: "free-text-input", value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), helpText: helpText,
|
|
4542
|
+
return (jsx("div", __assign({ className: clsx("FreeTextInput", props.className) }, { children: jsx(TextAreaInput, { className: "free-text-input", value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), helpText: helpText, placeholder: props.placeholder, allowTabToSave: true }) })));
|
|
4518
4543
|
};
|
|
4519
4544
|
|
|
4520
4545
|
var css_248z = ".ActionButton{align-items:center;display:flex}.ActionButton-minimal.lui-button-lg.lui-button-icon-right{padding-right:38px}.ActionButton.lui-button-lg.lui-button-icon-right:not(.ActionButton-tight) .LuiIcon{margin:0 4px}.ActionButton.ActionButton-tight.lui-button-lg.lui-button-icon-right .LuiIcon{margin:0}.ActionButton-iconOnly.lui-button-lg.lui-button-icon-right:not(.ActionButton-tight){padding:8px 5px}.ActionButton-iconOnly.lui-button-lg.lui-button-icon-right.ActionButton-tight{padding:0}.ActionButton-minimalArea{position:relative}.ActionButton-minimalAreaDisplay{position:absolute}.ActionButton-minimalAreaExpand{visibility:hidden}.ActionButton-inProgress.lui-button-lg.lui-button-icon-right{background-color:#e2f3f7;color:#007198;cursor:progress}.ActionButton-inProgress.lui-button-lg.lui-button-icon-right svg *{fill:#0000}.ActionButton-fill{justify-content:center;width:100%}";
|
|
@@ -4705,9 +4730,17 @@ function _asyncToGenerator(fn) {
|
|
|
4705
4730
|
};
|
|
4706
4731
|
}
|
|
4707
4732
|
|
|
4708
|
-
var
|
|
4733
|
+
var regeneratorRuntimeExports = {};
|
|
4734
|
+
var regeneratorRuntime$1 = {
|
|
4735
|
+
get exports(){ return regeneratorRuntimeExports; },
|
|
4736
|
+
set exports(v){ regeneratorRuntimeExports = v; },
|
|
4737
|
+
};
|
|
4709
4738
|
|
|
4710
|
-
var
|
|
4739
|
+
var _typeofExports = {};
|
|
4740
|
+
var _typeof$1 = {
|
|
4741
|
+
get exports(){ return _typeofExports; },
|
|
4742
|
+
set exports(v){ _typeofExports = v; },
|
|
4743
|
+
};
|
|
4711
4744
|
|
|
4712
4745
|
(function (module) {
|
|
4713
4746
|
function _typeof(obj) {
|
|
@@ -4723,7 +4756,7 @@ var _typeof$1 = {exports: {}};
|
|
|
4723
4756
|
} (_typeof$1));
|
|
4724
4757
|
|
|
4725
4758
|
(function (module) {
|
|
4726
|
-
var _typeof =
|
|
4759
|
+
var _typeof = _typeofExports["default"];
|
|
4727
4760
|
function _regeneratorRuntime() {
|
|
4728
4761
|
module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
|
4729
4762
|
return exports;
|
|
@@ -4859,14 +4892,9 @@ var _typeof$1 = {exports: {}};
|
|
|
4859
4892
|
};
|
|
4860
4893
|
}
|
|
4861
4894
|
function maybeInvokeDelegate(delegate, context) {
|
|
4862
|
-
var
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
4866
|
-
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
4867
|
-
}
|
|
4868
|
-
return ContinueSentinel;
|
|
4869
|
-
}
|
|
4895
|
+
var methodName = context.method,
|
|
4896
|
+
method = delegate.iterator[methodName];
|
|
4897
|
+
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
4870
4898
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
4871
4899
|
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
4872
4900
|
var info = record.arg;
|
|
@@ -4895,9 +4923,7 @@ var _typeof$1 = {exports: {}};
|
|
|
4895
4923
|
if (!isNaN(iterable.length)) {
|
|
4896
4924
|
var i = -1,
|
|
4897
4925
|
next = function next() {
|
|
4898
|
-
for (; ++i < iterable.length;)
|
|
4899
|
-
if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
4900
|
-
}
|
|
4926
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
4901
4927
|
return next.value = undefined, next.done = !0, next;
|
|
4902
4928
|
};
|
|
4903
4929
|
return next.next = next;
|
|
@@ -4943,9 +4969,7 @@ var _typeof$1 = {exports: {}};
|
|
|
4943
4969
|
}), exports.keys = function (val) {
|
|
4944
4970
|
var object = Object(val),
|
|
4945
4971
|
keys = [];
|
|
4946
|
-
for (var key in object)
|
|
4947
|
-
keys.push(key);
|
|
4948
|
-
}
|
|
4972
|
+
for (var key in object) keys.push(key);
|
|
4949
4973
|
return keys.reverse(), function next() {
|
|
4950
4974
|
for (; keys.length;) {
|
|
4951
4975
|
var key = keys.pop();
|
|
@@ -4956,9 +4980,7 @@ var _typeof$1 = {exports: {}};
|
|
|
4956
4980
|
}, exports.values = values, Context.prototype = {
|
|
4957
4981
|
constructor: Context,
|
|
4958
4982
|
reset: function reset(skipTempReset) {
|
|
4959
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this)
|
|
4960
|
-
"t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
4961
|
-
}
|
|
4983
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
4962
4984
|
},
|
|
4963
4985
|
stop: function stop() {
|
|
4964
4986
|
this.done = !0;
|
|
@@ -5041,7 +5063,7 @@ var _typeof$1 = {exports: {}};
|
|
|
5041
5063
|
|
|
5042
5064
|
// TODO(Babel 8): Remove this file.
|
|
5043
5065
|
|
|
5044
|
-
var runtime =
|
|
5066
|
+
var runtime = regeneratorRuntimeExports();
|
|
5045
5067
|
var regenerator = runtime;
|
|
5046
5068
|
|
|
5047
5069
|
// Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
|
|
@@ -5057,7 +5079,11 @@ try {
|
|
|
5057
5079
|
|
|
5058
5080
|
var build$1 = {};
|
|
5059
5081
|
|
|
5060
|
-
var
|
|
5082
|
+
var ansiStylesExports = {};
|
|
5083
|
+
var ansiStyles = {
|
|
5084
|
+
get exports(){ return ansiStylesExports; },
|
|
5085
|
+
set exports(v){ ansiStylesExports = v; },
|
|
5086
|
+
};
|
|
5061
5087
|
|
|
5062
5088
|
(function (module) {
|
|
5063
5089
|
|
|
@@ -5549,7 +5575,7 @@ ConvertAnsi.test = ConvertAnsi.serialize = ConvertAnsi.default = void 0;
|
|
|
5549
5575
|
|
|
5550
5576
|
var _ansiRegex = _interopRequireDefault$d(ansiRegex);
|
|
5551
5577
|
|
|
5552
|
-
var _ansiStyles$1 = _interopRequireDefault$d(
|
|
5578
|
+
var _ansiStyles$1 = _interopRequireDefault$d(ansiStylesExports);
|
|
5553
5579
|
|
|
5554
5580
|
function _interopRequireDefault$d(obj) {
|
|
5555
5581
|
return obj && obj.__esModule ? obj : {default: obj};
|
|
@@ -6268,7 +6294,11 @@ Immutable.default = _default$2l;
|
|
|
6268
6294
|
|
|
6269
6295
|
var ReactElement = {};
|
|
6270
6296
|
|
|
6271
|
-
var
|
|
6297
|
+
var reactIsExports = {};
|
|
6298
|
+
var reactIs = {
|
|
6299
|
+
get exports(){ return reactIsExports; },
|
|
6300
|
+
set exports(v){ reactIsExports = v; },
|
|
6301
|
+
};
|
|
6272
6302
|
|
|
6273
6303
|
var reactIs_production_min = {};
|
|
6274
6304
|
|
|
@@ -6540,7 +6570,7 @@ Object.defineProperty(ReactElement, '__esModule', {
|
|
|
6540
6570
|
});
|
|
6541
6571
|
ReactElement.test = ReactElement.serialize = ReactElement.default = void 0;
|
|
6542
6572
|
|
|
6543
|
-
var ReactIs = _interopRequireWildcard$2(
|
|
6573
|
+
var ReactIs = _interopRequireWildcard$2(reactIsExports);
|
|
6544
6574
|
|
|
6545
6575
|
var _markup$1 = markup;
|
|
6546
6576
|
|
|
@@ -6787,7 +6817,7 @@ var default_1 = build$1.default = DEFAULT_OPTIONS_1 = build$1.DEFAULT_OPTIONS =
|
|
|
6787
6817
|
var format_1 = build$1.format = format;
|
|
6788
6818
|
var plugins_1 = build$1.plugins = void 0;
|
|
6789
6819
|
|
|
6790
|
-
var _ansiStyles = _interopRequireDefault$b(
|
|
6820
|
+
var _ansiStyles = _interopRequireDefault$b(ansiStylesExports);
|
|
6791
6821
|
|
|
6792
6822
|
var _collections = collections;
|
|
6793
6823
|
|
|
@@ -7379,9 +7409,9 @@ default_1 = build$1.default = _default$2i;
|
|
|
7379
7409
|
var index = /*#__PURE__*/_mergeNamespaces({
|
|
7380
7410
|
__proto__: null,
|
|
7381
7411
|
get DEFAULT_OPTIONS () { return DEFAULT_OPTIONS_1; },
|
|
7412
|
+
get default () { return default_1; },
|
|
7382
7413
|
format: format_1,
|
|
7383
|
-
get plugins () { return plugins_1; }
|
|
7384
|
-
get default () { return default_1; }
|
|
7414
|
+
get plugins () { return plugins_1; }
|
|
7385
7415
|
}, [build$1]);
|
|
7386
7416
|
|
|
7387
7417
|
/**
|
|
@@ -14760,7 +14790,11 @@ var getIntrinsic = function GetIntrinsic(name, allowMissing) {
|
|
|
14760
14790
|
return value;
|
|
14761
14791
|
};
|
|
14762
14792
|
|
|
14763
|
-
var
|
|
14793
|
+
var callBindExports = {};
|
|
14794
|
+
var callBind$4 = {
|
|
14795
|
+
get exports(){ return callBindExports; },
|
|
14796
|
+
set exports(v){ callBindExports = v; },
|
|
14797
|
+
};
|
|
14764
14798
|
|
|
14765
14799
|
(function (module) {
|
|
14766
14800
|
|
|
@@ -14813,7 +14847,7 @@ var callBind$4 = {exports: {}};
|
|
|
14813
14847
|
|
|
14814
14848
|
var GetIntrinsic$5 = getIntrinsic;
|
|
14815
14849
|
|
|
14816
|
-
var callBind$3 =
|
|
14850
|
+
var callBind$3 = callBindExports;
|
|
14817
14851
|
|
|
14818
14852
|
var $indexOf = callBind$3(GetIntrinsic$5('String.prototype.indexOf'));
|
|
14819
14853
|
|
|
@@ -14972,7 +15006,7 @@ var shim$5 = function shimObjectIs() {
|
|
|
14972
15006
|
};
|
|
14973
15007
|
|
|
14974
15008
|
var define$2 = defineProperties_1;
|
|
14975
|
-
var callBind$2 =
|
|
15009
|
+
var callBind$2 = callBindExports;
|
|
14976
15010
|
|
|
14977
15011
|
var implementation$6 = implementation$8;
|
|
14978
15012
|
var getPolyfill$4 = polyfill$4;
|
|
@@ -15045,7 +15079,11 @@ var isRegex$1 = hasToStringTag$6
|
|
|
15045
15079
|
return $toString$2(value) === regexClass;
|
|
15046
15080
|
};
|
|
15047
15081
|
|
|
15048
|
-
var
|
|
15082
|
+
var implementationExports = {};
|
|
15083
|
+
var implementation$5 = {
|
|
15084
|
+
get exports(){ return implementationExports; },
|
|
15085
|
+
set exports(v){ implementationExports = v; },
|
|
15086
|
+
};
|
|
15049
15087
|
|
|
15050
15088
|
var functionsHaveNames = function functionsHaveNames() {
|
|
15051
15089
|
return typeof function f() {}.name === 'string';
|
|
@@ -15118,7 +15156,7 @@ var functionsHaveNames_1 = functionsHaveNames;
|
|
|
15118
15156
|
}
|
|
15119
15157
|
} (implementation$5));
|
|
15120
15158
|
|
|
15121
|
-
var implementation$4 =
|
|
15159
|
+
var implementation$4 = implementationExports;
|
|
15122
15160
|
|
|
15123
15161
|
var supportsDescriptors$1 = defineProperties_1.supportsDescriptors;
|
|
15124
15162
|
var $gOPD$1 = Object.getOwnPropertyDescriptor;
|
|
@@ -15179,9 +15217,9 @@ var shim$3 = function shimFlags() {
|
|
|
15179
15217
|
};
|
|
15180
15218
|
|
|
15181
15219
|
var define$1 = defineProperties_1;
|
|
15182
|
-
var callBind$1 =
|
|
15220
|
+
var callBind$1 = callBindExports;
|
|
15183
15221
|
|
|
15184
|
-
var implementation$3 =
|
|
15222
|
+
var implementation$3 = implementationExports;
|
|
15185
15223
|
var getPolyfill$2 = polyfill$2;
|
|
15186
15224
|
var shim$2 = shim$3;
|
|
15187
15225
|
|
|
@@ -15293,7 +15331,11 @@ var isBooleanObject = function isBoolean(value) {
|
|
|
15293
15331
|
return hasToStringTag$2 && Symbol.toStringTag in value ? tryBooleanObject(value) : $toString$1(value) === boolClass;
|
|
15294
15332
|
};
|
|
15295
15333
|
|
|
15296
|
-
var
|
|
15334
|
+
var isSymbolExports = {};
|
|
15335
|
+
var isSymbol$2 = {
|
|
15336
|
+
get exports(){ return isSymbolExports; },
|
|
15337
|
+
set exports(v){ isSymbolExports = v; },
|
|
15338
|
+
};
|
|
15297
15339
|
|
|
15298
15340
|
var toStr$3 = Object.prototype.toString;
|
|
15299
15341
|
var hasSymbols$1 = hasSymbols$4();
|
|
@@ -15329,7 +15371,11 @@ if (hasSymbols$1) {
|
|
|
15329
15371
|
};
|
|
15330
15372
|
}
|
|
15331
15373
|
|
|
15332
|
-
var
|
|
15374
|
+
var isBigintExports = {};
|
|
15375
|
+
var isBigint = {
|
|
15376
|
+
get exports(){ return isBigintExports; },
|
|
15377
|
+
set exports(v){ isBigintExports = v; },
|
|
15378
|
+
};
|
|
15333
15379
|
|
|
15334
15380
|
var $BigInt = typeof BigInt !== 'undefined' && BigInt;
|
|
15335
15381
|
|
|
@@ -15380,8 +15426,8 @@ if (hasBigInts) {
|
|
|
15380
15426
|
var isString$1 = isString$2;
|
|
15381
15427
|
var isNumber$1 = isNumberObject;
|
|
15382
15428
|
var isBoolean$1 = isBooleanObject;
|
|
15383
|
-
var isSymbol$1 =
|
|
15384
|
-
var isBigInt$1 =
|
|
15429
|
+
var isSymbol$1 = isSymbolExports;
|
|
15430
|
+
var isBigInt$1 = isBigintExports;
|
|
15385
15431
|
|
|
15386
15432
|
// eslint-disable-next-line consistent-return
|
|
15387
15433
|
var whichBoxedPrimitive$1 = function whichBoxedPrimitive(value) {
|
|
@@ -15529,7 +15575,11 @@ var isWeakmap = exported || function isWeakMap(x) {
|
|
|
15529
15575
|
return false;
|
|
15530
15576
|
};
|
|
15531
15577
|
|
|
15532
|
-
var
|
|
15578
|
+
var isWeaksetExports = {};
|
|
15579
|
+
var isWeakset = {
|
|
15580
|
+
get exports(){ return isWeaksetExports; },
|
|
15581
|
+
set exports(v){ isWeaksetExports = v; },
|
|
15582
|
+
};
|
|
15533
15583
|
|
|
15534
15584
|
var GetIntrinsic$3 = getIntrinsic;
|
|
15535
15585
|
var callBound$4 = callBound$8;
|
|
@@ -15569,7 +15619,7 @@ if ($setHas$1) {
|
|
|
15569
15619
|
var isMap$1 = isMap$2;
|
|
15570
15620
|
var isSet$1 = isSet$2;
|
|
15571
15621
|
var isWeakMap$1 = isWeakmap;
|
|
15572
|
-
var isWeakSet$1 =
|
|
15622
|
+
var isWeakSet$1 = isWeaksetExports;
|
|
15573
15623
|
|
|
15574
15624
|
var whichCollection$1 = function whichCollection(value) {
|
|
15575
15625
|
if (value && typeof value === 'object') {
|
|
@@ -16675,7 +16725,7 @@ var shim$1 = function shimAssign() {
|
|
|
16675
16725
|
};
|
|
16676
16726
|
|
|
16677
16727
|
var defineProperties = defineProperties_1;
|
|
16678
|
-
var callBind =
|
|
16728
|
+
var callBind = callBindExports;
|
|
16679
16729
|
|
|
16680
16730
|
var implementation = implementation$2;
|
|
16681
16731
|
var getPolyfill = polyfill$1;
|
|
@@ -17299,7 +17349,11 @@ var elementRoles_1 = lib.elementRoles = elementRoles;
|
|
|
17299
17349
|
var roleElements = _roleElementMap.default;
|
|
17300
17350
|
var roleElements_1 = lib.roleElements = roleElements;
|
|
17301
17351
|
|
|
17302
|
-
var
|
|
17352
|
+
var lzStringExports = {};
|
|
17353
|
+
var lzString$1 = {
|
|
17354
|
+
get exports(){ return lzStringExports; },
|
|
17355
|
+
set exports(v){ lzStringExports = v; },
|
|
17356
|
+
};
|
|
17303
17357
|
|
|
17304
17358
|
(function (module) {
|
|
17305
17359
|
// Copyright (c) 2013 Pieroxy <pieroxy@pieroxy.net>
|
|
@@ -17802,83 +17856,72 @@ var lzString$1 = {exports: {}};
|
|
|
17802
17856
|
}
|
|
17803
17857
|
} (lzString$1));
|
|
17804
17858
|
|
|
17805
|
-
var lzString =
|
|
17859
|
+
var lzString = lzStringExports;
|
|
17806
17860
|
|
|
17807
17861
|
/**
|
|
17808
17862
|
* Source: https://github.com/facebook/jest/blob/e7bb6a1e26ffab90611b2593912df15b69315611/packages/pretty-format/src/plugins/DOMElement.ts
|
|
17809
17863
|
*/
|
|
17810
|
-
|
|
17811
17864
|
/* eslint-disable -- trying to stay as close to the original as possible */
|
|
17812
|
-
|
|
17813
17865
|
/* istanbul ignore file */
|
|
17866
|
+
|
|
17814
17867
|
function escapeHTML(str) {
|
|
17815
17868
|
return str.replace(/</g, '<').replace(/>/g, '>');
|
|
17816
|
-
}
|
|
17817
|
-
|
|
17818
|
-
|
|
17869
|
+
}
|
|
17870
|
+
// Return empty string if keys is empty.
|
|
17819
17871
|
const printProps = (keys, props, config, indentation, depth, refs, printer) => {
|
|
17820
17872
|
const indentationNext = indentation + config.indent;
|
|
17821
17873
|
const colors = config.colors;
|
|
17822
17874
|
return keys.map(key => {
|
|
17823
17875
|
const value = props[key];
|
|
17824
17876
|
let printed = printer(value, config, indentationNext, depth, refs);
|
|
17825
|
-
|
|
17826
17877
|
if (typeof value !== 'string') {
|
|
17827
17878
|
if (printed.indexOf('\n') !== -1) {
|
|
17828
17879
|
printed = config.spacingOuter + indentationNext + printed + config.spacingOuter + indentation;
|
|
17829
17880
|
}
|
|
17830
|
-
|
|
17831
17881
|
printed = '{' + printed + '}';
|
|
17832
17882
|
}
|
|
17833
|
-
|
|
17834
17883
|
return config.spacingInner + indentation + colors.prop.open + key + colors.prop.close + '=' + colors.value.open + printed + colors.value.close;
|
|
17835
17884
|
}).join('');
|
|
17836
|
-
};
|
|
17837
|
-
|
|
17885
|
+
};
|
|
17838
17886
|
|
|
17839
|
-
|
|
17887
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType#node_type_constants
|
|
17888
|
+
const NodeTypeTextNode = 3;
|
|
17840
17889
|
|
|
17890
|
+
// Return empty string if children is empty.
|
|
17841
17891
|
const printChildren = (children, config, indentation, depth, refs, printer) => children.map(child => {
|
|
17842
17892
|
const printedChild = typeof child === 'string' ? printText(child, config) : printer(child, config, indentation, depth, refs);
|
|
17843
|
-
|
|
17844
17893
|
if (printedChild === '' && typeof child === 'object' && child !== null && child.nodeType !== NodeTypeTextNode) {
|
|
17845
17894
|
// A plugin serialized this Node to '' meaning we should ignore it.
|
|
17846
17895
|
return '';
|
|
17847
17896
|
}
|
|
17848
|
-
|
|
17849
17897
|
return config.spacingOuter + indentation + printedChild;
|
|
17850
17898
|
}).join('');
|
|
17851
|
-
|
|
17852
17899
|
const printText = (text, config) => {
|
|
17853
17900
|
const contentColor = config.colors.content;
|
|
17854
17901
|
return contentColor.open + escapeHTML(text) + contentColor.close;
|
|
17855
17902
|
};
|
|
17856
|
-
|
|
17857
17903
|
const printComment = (comment, config) => {
|
|
17858
17904
|
const commentColor = config.colors.comment;
|
|
17859
17905
|
return commentColor.open + '<!--' + escapeHTML(comment) + '-->' + commentColor.close;
|
|
17860
|
-
};
|
|
17906
|
+
};
|
|
17907
|
+
|
|
17908
|
+
// Separate the functions to format props, children, and element,
|
|
17861
17909
|
// so a plugin could override a particular function, if needed.
|
|
17862
17910
|
// Too bad, so sad: the traditional (but unnecessary) space
|
|
17863
17911
|
// in a self-closing tagColor requires a second test of printedProps.
|
|
17864
|
-
|
|
17865
|
-
|
|
17866
17912
|
const printElement = (type, printedProps, printedChildren, config, indentation) => {
|
|
17867
17913
|
const tagColor = config.colors.tag;
|
|
17868
17914
|
return tagColor.open + '<' + type + (printedProps && tagColor.close + printedProps + config.spacingOuter + indentation + tagColor.open) + (printedChildren ? '>' + tagColor.close + printedChildren + config.spacingOuter + indentation + tagColor.open + '</' + type : (printedProps && !config.min ? '' : ' ') + '/') + '>' + tagColor.close;
|
|
17869
17915
|
};
|
|
17870
|
-
|
|
17871
17916
|
const printElementAsLeaf = (type, config) => {
|
|
17872
17917
|
const tagColor = config.colors.tag;
|
|
17873
17918
|
return tagColor.open + '<' + type + tagColor.close + ' …' + tagColor.open + ' />' + tagColor.close;
|
|
17874
17919
|
};
|
|
17875
|
-
|
|
17876
17920
|
const ELEMENT_NODE$1 = 1;
|
|
17877
17921
|
const TEXT_NODE$1 = 3;
|
|
17878
17922
|
const COMMENT_NODE$1 = 8;
|
|
17879
17923
|
const FRAGMENT_NODE = 11;
|
|
17880
17924
|
const ELEMENT_REGEXP = /^((HTML|SVG)\w*)?Element$/;
|
|
17881
|
-
|
|
17882
17925
|
const testNode = val => {
|
|
17883
17926
|
const constructorName = val.constructor.name;
|
|
17884
17927
|
const {
|
|
@@ -17888,41 +17931,32 @@ const testNode = val => {
|
|
|
17888
17931
|
const isCustomElement = typeof tagName === 'string' && tagName.includes('-') || typeof val.hasAttribute === 'function' && val.hasAttribute('is');
|
|
17889
17932
|
return nodeType === ELEMENT_NODE$1 && (ELEMENT_REGEXP.test(constructorName) || isCustomElement) || nodeType === TEXT_NODE$1 && constructorName === 'Text' || nodeType === COMMENT_NODE$1 && constructorName === 'Comment' || nodeType === FRAGMENT_NODE && constructorName === 'DocumentFragment';
|
|
17890
17933
|
};
|
|
17891
|
-
|
|
17892
17934
|
function nodeIsText(node) {
|
|
17893
17935
|
return node.nodeType === TEXT_NODE$1;
|
|
17894
17936
|
}
|
|
17895
|
-
|
|
17896
17937
|
function nodeIsComment(node) {
|
|
17897
17938
|
return node.nodeType === COMMENT_NODE$1;
|
|
17898
17939
|
}
|
|
17899
|
-
|
|
17900
17940
|
function nodeIsFragment(node) {
|
|
17901
17941
|
return node.nodeType === FRAGMENT_NODE;
|
|
17902
17942
|
}
|
|
17903
|
-
|
|
17904
17943
|
function createDOMElementFilter(filterNode) {
|
|
17905
17944
|
return {
|
|
17906
17945
|
test: val => {
|
|
17907
17946
|
var _val$constructor2;
|
|
17908
|
-
|
|
17909
17947
|
return (val == null ? void 0 : (_val$constructor2 = val.constructor) == null ? void 0 : _val$constructor2.name) && testNode(val);
|
|
17910
17948
|
},
|
|
17911
17949
|
serialize: (node, config, indentation, depth, refs, printer) => {
|
|
17912
17950
|
if (nodeIsText(node)) {
|
|
17913
17951
|
return printText(node.data, config);
|
|
17914
17952
|
}
|
|
17915
|
-
|
|
17916
17953
|
if (nodeIsComment(node)) {
|
|
17917
17954
|
return printComment(node.data, config);
|
|
17918
17955
|
}
|
|
17919
|
-
|
|
17920
17956
|
const type = nodeIsFragment(node) ? "DocumentFragment" : node.tagName.toLowerCase();
|
|
17921
|
-
|
|
17922
17957
|
if (++depth > config.maxDepth) {
|
|
17923
17958
|
return printElementAsLeaf(type, config);
|
|
17924
17959
|
}
|
|
17925
|
-
|
|
17926
17960
|
return printElement(type, printProps(nodeIsFragment(node) ? [] : Array.from(node.attributes).map(attr => attr.name).sort(), nodeIsFragment(node) ? {} : Array.from(node.attributes).reduce((props, attribute) => {
|
|
17927
17961
|
props[attribute.name] = attribute.value;
|
|
17928
17962
|
return props;
|
|
@@ -17935,16 +17969,16 @@ function createDOMElementFilter(filterNode) {
|
|
|
17935
17969
|
let chalk = null;
|
|
17936
17970
|
let readFileSync = null;
|
|
17937
17971
|
let codeFrameColumns = null;
|
|
17938
|
-
|
|
17939
17972
|
try {
|
|
17940
17973
|
const nodeRequire = module && module.require;
|
|
17941
17974
|
readFileSync = nodeRequire.call(module, 'fs').readFileSync;
|
|
17942
17975
|
codeFrameColumns = nodeRequire.call(module, '@babel/code-frame').codeFrameColumns;
|
|
17943
17976
|
chalk = nodeRequire.call(module, 'chalk');
|
|
17944
|
-
} catch {
|
|
17945
|
-
|
|
17946
|
-
|
|
17977
|
+
} catch {
|
|
17978
|
+
// We're in a browser environment
|
|
17979
|
+
}
|
|
17947
17980
|
|
|
17981
|
+
// frame has the form "at myMethod (location/to/my/file.js:10:2)"
|
|
17948
17982
|
function getCodeFrame(frame) {
|
|
17949
17983
|
const locationStart = frame.indexOf('(') + 1;
|
|
17950
17984
|
const locationEnd = frame.indexOf(')');
|
|
@@ -17952,13 +17986,11 @@ function getCodeFrame(frame) {
|
|
|
17952
17986
|
const frameLocationElements = frameLocation.split(':');
|
|
17953
17987
|
const [filename, line, column] = [frameLocationElements[0], parseInt(frameLocationElements[1], 10), parseInt(frameLocationElements[2], 10)];
|
|
17954
17988
|
let rawFileContents = '';
|
|
17955
|
-
|
|
17956
17989
|
try {
|
|
17957
17990
|
rawFileContents = readFileSync(filename, 'utf-8');
|
|
17958
17991
|
} catch {
|
|
17959
17992
|
return '';
|
|
17960
17993
|
}
|
|
17961
|
-
|
|
17962
17994
|
const codeFrame = codeFrameColumns(rawFileContents, {
|
|
17963
17995
|
start: {
|
|
17964
17996
|
line,
|
|
@@ -17970,15 +18002,12 @@ function getCodeFrame(frame) {
|
|
|
17970
18002
|
});
|
|
17971
18003
|
return chalk.dim(frameLocation) + "\n" + codeFrame + "\n";
|
|
17972
18004
|
}
|
|
17973
|
-
|
|
17974
18005
|
function getUserCodeFrame() {
|
|
17975
18006
|
// If we couldn't load dependencies, we can't generate the user trace
|
|
17976
|
-
|
|
17977
18007
|
/* istanbul ignore next */
|
|
17978
18008
|
if (!readFileSync || !codeFrameColumns) {
|
|
17979
18009
|
return '';
|
|
17980
18010
|
}
|
|
17981
|
-
|
|
17982
18011
|
const err = new Error();
|
|
17983
18012
|
const firstClientCodeFrame = err.stack.split('\n').slice(1) // Remove first line which has the form "Error: TypeError"
|
|
17984
18013
|
.find(frame => !frame.includes('node_modules/')); // Ignore frames from 3rd party libraries
|
|
@@ -17989,30 +18018,27 @@ function getUserCodeFrame() {
|
|
|
17989
18018
|
// Constant node.nodeType for text nodes, see:
|
|
17990
18019
|
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType#Node_type_constants
|
|
17991
18020
|
const TEXT_NODE$2 = 3;
|
|
17992
|
-
|
|
17993
18021
|
function jestFakeTimersAreEnabled$1() {
|
|
17994
18022
|
/* istanbul ignore else */
|
|
17995
18023
|
// eslint-disable-next-line
|
|
17996
18024
|
if (typeof jest !== 'undefined' && jest !== null) {
|
|
17997
|
-
return (
|
|
17998
|
-
|
|
18025
|
+
return (
|
|
18026
|
+
// legacy timers
|
|
18027
|
+
setTimeout._isMockFunction === true ||
|
|
18028
|
+
// modern timers
|
|
17999
18029
|
Object.prototype.hasOwnProperty.call(setTimeout, 'clock')
|
|
18000
18030
|
);
|
|
18001
|
-
}
|
|
18002
|
-
|
|
18003
|
-
|
|
18031
|
+
}
|
|
18032
|
+
// istanbul ignore next
|
|
18004
18033
|
return false;
|
|
18005
18034
|
}
|
|
18006
|
-
|
|
18007
18035
|
function getDocument$1() {
|
|
18008
18036
|
/* istanbul ignore if */
|
|
18009
18037
|
if (typeof window === 'undefined') {
|
|
18010
18038
|
throw new Error('Could not find default container');
|
|
18011
18039
|
}
|
|
18012
|
-
|
|
18013
18040
|
return window.document;
|
|
18014
18041
|
}
|
|
18015
|
-
|
|
18016
18042
|
function getWindowFromNode$1(node) {
|
|
18017
18043
|
if (node.defaultView) {
|
|
18018
18044
|
// node is document
|
|
@@ -18036,32 +18062,27 @@ function getWindowFromNode$1(node) {
|
|
|
18036
18062
|
throw new Error("The given node is not an Element, the node type is: " + typeof node + ".");
|
|
18037
18063
|
}
|
|
18038
18064
|
}
|
|
18039
|
-
|
|
18040
18065
|
function checkContainerType$1(container) {
|
|
18041
18066
|
if (!container || !(typeof container.querySelector === 'function') || !(typeof container.querySelectorAll === 'function')) {
|
|
18042
18067
|
throw new TypeError("Expected container to be an Element, a Document or a DocumentFragment but got " + getTypeName(container) + ".");
|
|
18043
18068
|
}
|
|
18044
|
-
|
|
18045
18069
|
function getTypeName(object) {
|
|
18046
18070
|
if (typeof object === 'object') {
|
|
18047
18071
|
return object === null ? 'null' : object.constructor.name;
|
|
18048
18072
|
}
|
|
18049
|
-
|
|
18050
18073
|
return typeof object;
|
|
18051
18074
|
}
|
|
18052
18075
|
}
|
|
18053
18076
|
|
|
18054
18077
|
const shouldHighlight = () => {
|
|
18055
18078
|
let colors;
|
|
18056
|
-
|
|
18057
18079
|
try {
|
|
18058
18080
|
var _process, _process$env;
|
|
18059
|
-
|
|
18060
18081
|
colors = JSON.parse((_process = process) == null ? void 0 : (_process$env = _process.env) == null ? void 0 : _process$env.COLORS);
|
|
18061
|
-
} catch (e) {
|
|
18082
|
+
} catch (e) {
|
|
18083
|
+
// If this throws, process?.env?.COLORS wasn't parsable. Since we only
|
|
18062
18084
|
// care about `true` or `false`, we can safely ignore the error.
|
|
18063
18085
|
}
|
|
18064
|
-
|
|
18065
18086
|
if (typeof colors === 'boolean') {
|
|
18066
18087
|
// If `colors` is set explicitly (both `true` and `false`), use that value.
|
|
18067
18088
|
return colors;
|
|
@@ -18070,52 +18091,44 @@ const shouldHighlight = () => {
|
|
|
18070
18091
|
return typeof process !== 'undefined' && process.versions !== undefined && process.versions.node !== undefined;
|
|
18071
18092
|
}
|
|
18072
18093
|
};
|
|
18073
|
-
|
|
18074
18094
|
const {
|
|
18075
18095
|
DOMCollection
|
|
18076
|
-
} = plugins_1;
|
|
18096
|
+
} = plugins_1;
|
|
18077
18097
|
|
|
18098
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType#node_type_constants
|
|
18078
18099
|
const ELEMENT_NODE = 1;
|
|
18079
|
-
const COMMENT_NODE = 8;
|
|
18100
|
+
const COMMENT_NODE = 8;
|
|
18080
18101
|
|
|
18102
|
+
// https://github.com/facebook/jest/blob/615084195ae1ae61ddd56162c62bbdda17587569/packages/pretty-format/src/plugins/DOMElement.ts#L50
|
|
18081
18103
|
function filterCommentsAndDefaultIgnoreTagsTags(value) {
|
|
18082
18104
|
return value.nodeType !== COMMENT_NODE && (value.nodeType !== ELEMENT_NODE || !value.matches(getConfig().defaultIgnore));
|
|
18083
18105
|
}
|
|
18084
|
-
|
|
18085
18106
|
function prettyDOM(dom, maxLength, options) {
|
|
18086
18107
|
if (options === void 0) {
|
|
18087
18108
|
options = {};
|
|
18088
18109
|
}
|
|
18089
|
-
|
|
18090
18110
|
if (!dom) {
|
|
18091
18111
|
dom = getDocument$1().body;
|
|
18092
18112
|
}
|
|
18093
|
-
|
|
18094
18113
|
if (typeof maxLength !== 'number') {
|
|
18095
18114
|
maxLength = typeof process !== 'undefined' && process.env.DEBUG_PRINT_LIMIT || 7000;
|
|
18096
18115
|
}
|
|
18097
|
-
|
|
18098
18116
|
if (maxLength === 0) {
|
|
18099
18117
|
return '';
|
|
18100
18118
|
}
|
|
18101
|
-
|
|
18102
18119
|
if (dom.documentElement) {
|
|
18103
18120
|
dom = dom.documentElement;
|
|
18104
18121
|
}
|
|
18105
|
-
|
|
18106
18122
|
let domTypeName = typeof dom;
|
|
18107
|
-
|
|
18108
18123
|
if (domTypeName === 'object') {
|
|
18109
18124
|
domTypeName = dom.constructor.name;
|
|
18110
18125
|
} else {
|
|
18111
18126
|
// To don't fall with `in` operator
|
|
18112
18127
|
dom = {};
|
|
18113
18128
|
}
|
|
18114
|
-
|
|
18115
18129
|
if (!('outerHTML' in dom)) {
|
|
18116
18130
|
throw new TypeError("Expected an element or document but got " + domTypeName);
|
|
18117
18131
|
}
|
|
18118
|
-
|
|
18119
18132
|
const {
|
|
18120
18133
|
filterNode = filterCommentsAndDefaultIgnoreTagsTags,
|
|
18121
18134
|
...prettyFormatOptions
|
|
@@ -18128,10 +18141,8 @@ function prettyDOM(dom, maxLength, options) {
|
|
|
18128
18141
|
});
|
|
18129
18142
|
return maxLength !== undefined && dom.outerHTML.length > maxLength ? debugContent.slice(0, maxLength) + "..." : debugContent;
|
|
18130
18143
|
}
|
|
18131
|
-
|
|
18132
18144
|
const logDOM = function () {
|
|
18133
18145
|
const userCodeFrame = getUserCodeFrame();
|
|
18134
|
-
|
|
18135
18146
|
if (userCodeFrame) {
|
|
18136
18147
|
console.log(prettyDOM(...arguments) + "\n\n" + userCodeFrame);
|
|
18137
18148
|
} else {
|
|
@@ -18163,7 +18174,6 @@ let config = {
|
|
|
18163
18174
|
showOriginalStackTrace: false,
|
|
18164
18175
|
// throw errors w/ suggestions for better queries. Opt in so off by default.
|
|
18165
18176
|
throwSuggestions: false,
|
|
18166
|
-
|
|
18167
18177
|
// called when getBy* queries fail. (message, container) => Error
|
|
18168
18178
|
getElementError(message, container) {
|
|
18169
18179
|
const prettifiedDOM = prettyDOM(container);
|
|
@@ -18171,7 +18181,6 @@ let config = {
|
|
|
18171
18181
|
error.name = 'TestingLibraryElementError';
|
|
18172
18182
|
return error;
|
|
18173
18183
|
},
|
|
18174
|
-
|
|
18175
18184
|
_disableExpensiveErrorDiagnostics: false,
|
|
18176
18185
|
computedStyleSupportsPseudoElements: false
|
|
18177
18186
|
};
|
|
@@ -18188,10 +18197,11 @@ function configure(newConfig) {
|
|
|
18188
18197
|
// Pass the existing config out to the provided function
|
|
18189
18198
|
// and accept a delta in return
|
|
18190
18199
|
newConfig = newConfig(config);
|
|
18191
|
-
}
|
|
18192
|
-
|
|
18200
|
+
}
|
|
18193
18201
|
|
|
18194
|
-
|
|
18202
|
+
// Merge the incoming config delta
|
|
18203
|
+
config = {
|
|
18204
|
+
...config,
|
|
18195
18205
|
...newConfig
|
|
18196
18206
|
};
|
|
18197
18207
|
}
|
|
@@ -18200,46 +18210,37 @@ function getConfig() {
|
|
|
18200
18210
|
}
|
|
18201
18211
|
|
|
18202
18212
|
const labelledNodeNames = ['button', 'meter', 'output', 'progress', 'select', 'textarea', 'input'];
|
|
18203
|
-
|
|
18204
18213
|
function getTextContent(node) {
|
|
18205
18214
|
if (labelledNodeNames.includes(node.nodeName.toLowerCase())) {
|
|
18206
18215
|
return '';
|
|
18207
18216
|
}
|
|
18208
|
-
|
|
18209
18217
|
if (node.nodeType === TEXT_NODE$2) return node.textContent;
|
|
18210
18218
|
return Array.from(node.childNodes).map(childNode => getTextContent(childNode)).join('');
|
|
18211
18219
|
}
|
|
18212
|
-
|
|
18213
18220
|
function getLabelContent(element) {
|
|
18214
18221
|
let textContent;
|
|
18215
|
-
|
|
18216
18222
|
if (element.tagName.toLowerCase() === 'label') {
|
|
18217
18223
|
textContent = getTextContent(element);
|
|
18218
18224
|
} else {
|
|
18219
18225
|
textContent = element.value || element.textContent;
|
|
18220
18226
|
}
|
|
18221
|
-
|
|
18222
18227
|
return textContent;
|
|
18223
|
-
}
|
|
18224
|
-
|
|
18228
|
+
}
|
|
18225
18229
|
|
|
18230
|
+
// Based on https://github.com/eps1lon/dom-accessibility-api/pull/352
|
|
18226
18231
|
function getRealLabels(element) {
|
|
18227
18232
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- types are not aware of older browsers that don't implement `labels`
|
|
18228
18233
|
if (element.labels !== undefined) {
|
|
18229
18234
|
var _labels;
|
|
18230
|
-
|
|
18231
18235
|
return (_labels = element.labels) != null ? _labels : [];
|
|
18232
18236
|
}
|
|
18233
|
-
|
|
18234
18237
|
if (!isLabelable(element)) return [];
|
|
18235
18238
|
const labels = element.ownerDocument.querySelectorAll('label');
|
|
18236
18239
|
return Array.from(labels).filter(label => label.control === element);
|
|
18237
18240
|
}
|
|
18238
|
-
|
|
18239
18241
|
function isLabelable(element) {
|
|
18240
18242
|
return /BUTTON|METER|OUTPUT|PROGRESS|SELECT|TEXTAREA/.test(element.tagName) || element.tagName === 'INPUT' && element.getAttribute('type') !== 'hidden';
|
|
18241
18243
|
}
|
|
18242
|
-
|
|
18243
18244
|
function getLabels(container, element, _temp) {
|
|
18244
18245
|
let {
|
|
18245
18246
|
selector = '*'
|
|
@@ -18272,15 +18273,12 @@ function assertNotNullOrUndefined(matcher) {
|
|
|
18272
18273
|
"It looks like " + matcher + " was passed instead of a matcher. Did you do something like getByText(" + matcher + ")?");
|
|
18273
18274
|
}
|
|
18274
18275
|
}
|
|
18275
|
-
|
|
18276
18276
|
function fuzzyMatches(textToMatch, node, matcher, normalizer) {
|
|
18277
18277
|
if (typeof textToMatch !== 'string') {
|
|
18278
18278
|
return false;
|
|
18279
18279
|
}
|
|
18280
|
-
|
|
18281
18280
|
assertNotNullOrUndefined(matcher);
|
|
18282
18281
|
const normalizedText = normalizer(textToMatch);
|
|
18283
|
-
|
|
18284
18282
|
if (typeof matcher === 'string' || typeof matcher === 'number') {
|
|
18285
18283
|
return normalizedText.toLowerCase().includes(matcher.toString().toLowerCase());
|
|
18286
18284
|
} else if (typeof matcher === 'function') {
|
|
@@ -18289,15 +18287,12 @@ function fuzzyMatches(textToMatch, node, matcher, normalizer) {
|
|
|
18289
18287
|
return matchRegExp(matcher, normalizedText);
|
|
18290
18288
|
}
|
|
18291
18289
|
}
|
|
18292
|
-
|
|
18293
18290
|
function matches(textToMatch, node, matcher, normalizer) {
|
|
18294
18291
|
if (typeof textToMatch !== 'string') {
|
|
18295
18292
|
return false;
|
|
18296
18293
|
}
|
|
18297
|
-
|
|
18298
18294
|
assertNotNullOrUndefined(matcher);
|
|
18299
18295
|
const normalizedText = normalizer(textToMatch);
|
|
18300
|
-
|
|
18301
18296
|
if (matcher instanceof Function) {
|
|
18302
18297
|
return matcher(normalizedText, node);
|
|
18303
18298
|
} else if (matcher instanceof RegExp) {
|
|
@@ -18306,7 +18301,6 @@ function matches(textToMatch, node, matcher, normalizer) {
|
|
|
18306
18301
|
return normalizedText === String(matcher);
|
|
18307
18302
|
}
|
|
18308
18303
|
}
|
|
18309
|
-
|
|
18310
18304
|
function getDefaultNormalizer(_temp) {
|
|
18311
18305
|
let {
|
|
18312
18306
|
trim = true,
|
|
@@ -18319,6 +18313,7 @@ function getDefaultNormalizer(_temp) {
|
|
|
18319
18313
|
return normalizedText;
|
|
18320
18314
|
};
|
|
18321
18315
|
}
|
|
18316
|
+
|
|
18322
18317
|
/**
|
|
18323
18318
|
* Constructs a normalizer to pass to functions in matches.js
|
|
18324
18319
|
* @param {boolean|undefined} trim The user-specified value for `trim`, without
|
|
@@ -18329,14 +18324,12 @@ function getDefaultNormalizer(_temp) {
|
|
|
18329
18324
|
* @returns {Function} A normalizer
|
|
18330
18325
|
*/
|
|
18331
18326
|
|
|
18332
|
-
|
|
18333
18327
|
function makeNormalizer(_ref) {
|
|
18334
18328
|
let {
|
|
18335
18329
|
trim,
|
|
18336
18330
|
collapseWhitespace,
|
|
18337
18331
|
normalizer
|
|
18338
18332
|
} = _ref;
|
|
18339
|
-
|
|
18340
18333
|
if (!normalizer) {
|
|
18341
18334
|
// No custom normalizer specified. Just use default.
|
|
18342
18335
|
return getDefaultNormalizer({
|
|
@@ -18344,23 +18337,18 @@ function makeNormalizer(_ref) {
|
|
|
18344
18337
|
collapseWhitespace
|
|
18345
18338
|
});
|
|
18346
18339
|
}
|
|
18347
|
-
|
|
18348
18340
|
if (typeof trim !== 'undefined' || typeof collapseWhitespace !== 'undefined') {
|
|
18349
18341
|
// They've also specified a value for trim or collapseWhitespace
|
|
18350
18342
|
throw new Error('trim and collapseWhitespace are not supported with a normalizer. ' + 'If you want to use the default trim and collapseWhitespace logic in your normalizer, ' + 'use "getDefaultNormalizer({trim, collapseWhitespace})" and compose that into your normalizer');
|
|
18351
18343
|
}
|
|
18352
|
-
|
|
18353
18344
|
return normalizer;
|
|
18354
18345
|
}
|
|
18355
|
-
|
|
18356
18346
|
function matchRegExp(matcher, text) {
|
|
18357
18347
|
const match = matcher.test(text);
|
|
18358
|
-
|
|
18359
18348
|
if (matcher.global && matcher.lastIndex !== 0) {
|
|
18360
18349
|
console.warn("To match all elements we had to reset the lastIndex of the RegExp because the global flag is enabled. We encourage to remove the global flag from the RegExp.");
|
|
18361
18350
|
matcher.lastIndex = 0;
|
|
18362
18351
|
}
|
|
18363
|
-
|
|
18364
18352
|
return match;
|
|
18365
18353
|
}
|
|
18366
18354
|
|
|
@@ -18368,33 +18356,29 @@ function getNodeText(node) {
|
|
|
18368
18356
|
if (node.matches('input[type=submit], input[type=button], input[type=reset]')) {
|
|
18369
18357
|
return node.value;
|
|
18370
18358
|
}
|
|
18371
|
-
|
|
18372
18359
|
return Array.from(node.childNodes).filter(child => child.nodeType === TEXT_NODE$2 && Boolean(child.textContent)).map(c => c.textContent).join('');
|
|
18373
18360
|
}
|
|
18374
18361
|
|
|
18375
18362
|
const elementRoleList = buildElementRoleList(elementRoles_1);
|
|
18363
|
+
|
|
18376
18364
|
/**
|
|
18377
18365
|
* @param {Element} element -
|
|
18378
18366
|
* @returns {boolean} - `true` if `element` and its subtree are inaccessible
|
|
18379
18367
|
*/
|
|
18380
|
-
|
|
18381
18368
|
function isSubtreeInaccessible(element) {
|
|
18382
18369
|
if (element.hidden === true) {
|
|
18383
18370
|
return true;
|
|
18384
18371
|
}
|
|
18385
|
-
|
|
18386
18372
|
if (element.getAttribute('aria-hidden') === 'true') {
|
|
18387
18373
|
return true;
|
|
18388
18374
|
}
|
|
18389
|
-
|
|
18390
18375
|
const window = element.ownerDocument.defaultView;
|
|
18391
|
-
|
|
18392
18376
|
if (window.getComputedStyle(element).display === 'none') {
|
|
18393
18377
|
return true;
|
|
18394
18378
|
}
|
|
18395
|
-
|
|
18396
18379
|
return false;
|
|
18397
18380
|
}
|
|
18381
|
+
|
|
18398
18382
|
/**
|
|
18399
18383
|
* Partial implementation https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion
|
|
18400
18384
|
* which should only be used for elements with a non-presentational role i.e.
|
|
@@ -18409,35 +18393,27 @@ function isSubtreeInaccessible(element) {
|
|
|
18409
18393
|
* can be used to return cached results from previous isSubtreeInaccessible calls
|
|
18410
18394
|
* @returns {boolean} true if excluded, otherwise false
|
|
18411
18395
|
*/
|
|
18412
|
-
|
|
18413
|
-
|
|
18414
18396
|
function isInaccessible(element, options) {
|
|
18415
18397
|
if (options === void 0) {
|
|
18416
18398
|
options = {};
|
|
18417
18399
|
}
|
|
18418
|
-
|
|
18419
18400
|
const {
|
|
18420
18401
|
isSubtreeInaccessible: isSubtreeInaccessibleImpl = isSubtreeInaccessible
|
|
18421
18402
|
} = options;
|
|
18422
|
-
const window = element.ownerDocument.defaultView;
|
|
18423
|
-
|
|
18403
|
+
const window = element.ownerDocument.defaultView;
|
|
18404
|
+
// since visibility is inherited we can exit early
|
|
18424
18405
|
if (window.getComputedStyle(element).visibility === 'hidden') {
|
|
18425
18406
|
return true;
|
|
18426
18407
|
}
|
|
18427
|
-
|
|
18428
18408
|
let currentElement = element;
|
|
18429
|
-
|
|
18430
18409
|
while (currentElement) {
|
|
18431
18410
|
if (isSubtreeInaccessibleImpl(currentElement)) {
|
|
18432
18411
|
return true;
|
|
18433
18412
|
}
|
|
18434
|
-
|
|
18435
18413
|
currentElement = currentElement.parentElement;
|
|
18436
18414
|
}
|
|
18437
|
-
|
|
18438
18415
|
return false;
|
|
18439
18416
|
}
|
|
18440
|
-
|
|
18441
18417
|
function getImplicitAriaRoles(currentNode) {
|
|
18442
18418
|
// eslint bug here:
|
|
18443
18419
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -18449,10 +18425,8 @@ function getImplicitAriaRoles(currentNode) {
|
|
|
18449
18425
|
return [...roles];
|
|
18450
18426
|
}
|
|
18451
18427
|
}
|
|
18452
|
-
|
|
18453
18428
|
return [];
|
|
18454
18429
|
}
|
|
18455
|
-
|
|
18456
18430
|
function buildElementRoleList(elementRolesMap) {
|
|
18457
18431
|
function makeElementSelector(_ref) {
|
|
18458
18432
|
let {
|
|
@@ -18466,7 +18440,6 @@ function buildElementRoleList(elementRolesMap) {
|
|
|
18466
18440
|
constraints = []
|
|
18467
18441
|
} = _ref2;
|
|
18468
18442
|
const shouldNotExist = constraints.indexOf('undefined') !== -1;
|
|
18469
|
-
|
|
18470
18443
|
if (shouldNotExist) {
|
|
18471
18444
|
return ":not([" + attributeName + "])";
|
|
18472
18445
|
} else if (value) {
|
|
@@ -18476,14 +18449,12 @@ function buildElementRoleList(elementRolesMap) {
|
|
|
18476
18449
|
}
|
|
18477
18450
|
}).join('');
|
|
18478
18451
|
}
|
|
18479
|
-
|
|
18480
18452
|
function getSelectorSpecificity(_ref3) {
|
|
18481
18453
|
let {
|
|
18482
18454
|
attributes = []
|
|
18483
18455
|
} = _ref3;
|
|
18484
18456
|
return attributes.length;
|
|
18485
18457
|
}
|
|
18486
|
-
|
|
18487
18458
|
function bySelectorSpecificity(_ref4, _ref5) {
|
|
18488
18459
|
let {
|
|
18489
18460
|
specificity: leftSpecificity
|
|
@@ -18493,34 +18464,32 @@ function buildElementRoleList(elementRolesMap) {
|
|
|
18493
18464
|
} = _ref5;
|
|
18494
18465
|
return rightSpecificity - leftSpecificity;
|
|
18495
18466
|
}
|
|
18496
|
-
|
|
18497
18467
|
function match(element) {
|
|
18498
18468
|
let {
|
|
18499
18469
|
attributes = []
|
|
18500
|
-
} = element;
|
|
18470
|
+
} = element;
|
|
18501
18471
|
|
|
18472
|
+
// https://github.com/testing-library/dom-testing-library/issues/814
|
|
18502
18473
|
const typeTextIndex = attributes.findIndex(attribute => attribute.value && attribute.name === 'type' && attribute.value === 'text');
|
|
18503
|
-
|
|
18504
18474
|
if (typeTextIndex >= 0) {
|
|
18505
18475
|
// not using splice to not mutate the attributes array
|
|
18506
18476
|
attributes = [...attributes.slice(0, typeTextIndex), ...attributes.slice(typeTextIndex + 1)];
|
|
18507
18477
|
}
|
|
18508
|
-
|
|
18509
|
-
|
|
18478
|
+
const selector = makeElementSelector({
|
|
18479
|
+
...element,
|
|
18510
18480
|
attributes
|
|
18511
18481
|
});
|
|
18512
18482
|
return node => {
|
|
18513
18483
|
if (typeTextIndex >= 0 && node.type !== 'text') {
|
|
18514
18484
|
return false;
|
|
18515
18485
|
}
|
|
18516
|
-
|
|
18517
18486
|
return node.matches(selector);
|
|
18518
18487
|
};
|
|
18519
18488
|
}
|
|
18489
|
+
let result = [];
|
|
18520
18490
|
|
|
18521
|
-
|
|
18491
|
+
// eslint bug here:
|
|
18522
18492
|
// eslint-disable-next-line no-unused-vars
|
|
18523
|
-
|
|
18524
18493
|
for (const [element, roles] of elementRolesMap.entries()) {
|
|
18525
18494
|
result = [...result, {
|
|
18526
18495
|
match: match(element),
|
|
@@ -18528,38 +18497,34 @@ function buildElementRoleList(elementRolesMap) {
|
|
|
18528
18497
|
specificity: getSelectorSpecificity(element)
|
|
18529
18498
|
}];
|
|
18530
18499
|
}
|
|
18531
|
-
|
|
18532
18500
|
return result.sort(bySelectorSpecificity);
|
|
18533
18501
|
}
|
|
18534
|
-
|
|
18535
18502
|
function getRoles(container, _temp) {
|
|
18536
18503
|
let {
|
|
18537
18504
|
hidden = false
|
|
18538
18505
|
} = _temp === void 0 ? {} : _temp;
|
|
18539
|
-
|
|
18540
18506
|
function flattenDOM(node) {
|
|
18541
18507
|
return [node, ...Array.from(node.children).reduce((acc, child) => [...acc, ...flattenDOM(child)], [])];
|
|
18542
18508
|
}
|
|
18543
|
-
|
|
18544
18509
|
return flattenDOM(container).filter(element => {
|
|
18545
18510
|
return hidden === false ? isInaccessible(element) === false : true;
|
|
18546
18511
|
}).reduce((acc, node) => {
|
|
18547
|
-
let roles = [];
|
|
18548
|
-
|
|
18512
|
+
let roles = [];
|
|
18513
|
+
// TODO: This violates html-aria which does not allow any role on every element
|
|
18549
18514
|
if (node.hasAttribute('role')) {
|
|
18550
18515
|
roles = node.getAttribute('role').split(' ').slice(0, 1);
|
|
18551
18516
|
} else {
|
|
18552
18517
|
roles = getImplicitAriaRoles(node);
|
|
18553
18518
|
}
|
|
18554
|
-
|
|
18555
|
-
|
|
18519
|
+
return roles.reduce((rolesAcc, role) => Array.isArray(rolesAcc[role]) ? {
|
|
18520
|
+
...rolesAcc,
|
|
18556
18521
|
[role]: [...rolesAcc[role], node]
|
|
18557
|
-
} : {
|
|
18522
|
+
} : {
|
|
18523
|
+
...rolesAcc,
|
|
18558
18524
|
[role]: [node]
|
|
18559
18525
|
}, acc);
|
|
18560
18526
|
}, {});
|
|
18561
18527
|
}
|
|
18562
|
-
|
|
18563
18528
|
function prettyRoles(dom, _ref6) {
|
|
18564
18529
|
let {
|
|
18565
18530
|
hidden,
|
|
@@ -18567,8 +18532,8 @@ function prettyRoles(dom, _ref6) {
|
|
|
18567
18532
|
} = _ref6;
|
|
18568
18533
|
const roles = getRoles(dom, {
|
|
18569
18534
|
hidden
|
|
18570
|
-
});
|
|
18571
|
-
|
|
18535
|
+
});
|
|
18536
|
+
// We prefer to skip generic role, we don't recommend it
|
|
18572
18537
|
return Object.entries(roles).filter(_ref7 => {
|
|
18573
18538
|
let [role] = _ref7;
|
|
18574
18539
|
return role !== 'generic';
|
|
@@ -18580,20 +18545,17 @@ function prettyRoles(dom, _ref6) {
|
|
|
18580
18545
|
computedStyleSupportsPseudoElements: getConfig().computedStyleSupportsPseudoElements
|
|
18581
18546
|
}) + "\":\n";
|
|
18582
18547
|
const domString = prettyDOM(el.cloneNode(false));
|
|
18583
|
-
|
|
18584
18548
|
if (includeDescription) {
|
|
18585
18549
|
const descriptionString = "Description \"" + computeAccessibleDescription(el, {
|
|
18586
18550
|
computedStyleSupportsPseudoElements: getConfig().computedStyleSupportsPseudoElements
|
|
18587
18551
|
}) + "\":\n";
|
|
18588
18552
|
return "" + nameString + descriptionString + domString;
|
|
18589
18553
|
}
|
|
18590
|
-
|
|
18591
18554
|
return "" + nameString + domString;
|
|
18592
18555
|
}).join('\n\n');
|
|
18593
18556
|
return role + ":\n\n" + elementsString + "\n\n" + delimiterBar;
|
|
18594
18557
|
}).join('\n');
|
|
18595
18558
|
}
|
|
18596
|
-
|
|
18597
18559
|
const logRoles = function (dom, _temp2) {
|
|
18598
18560
|
let {
|
|
18599
18561
|
hidden = false
|
|
@@ -18602,28 +18564,26 @@ const logRoles = function (dom, _temp2) {
|
|
|
18602
18564
|
hidden
|
|
18603
18565
|
}));
|
|
18604
18566
|
};
|
|
18567
|
+
|
|
18605
18568
|
/**
|
|
18606
18569
|
* @param {Element} element -
|
|
18607
18570
|
* @returns {boolean | undefined} - false/true if (not)selected, undefined if not selectable
|
|
18608
18571
|
*/
|
|
18609
|
-
|
|
18610
|
-
|
|
18611
18572
|
function computeAriaSelected(element) {
|
|
18612
18573
|
// implicit value from html-aam mappings: https://www.w3.org/TR/html-aam-1.0/#html-attribute-state-and-property-mappings
|
|
18613
18574
|
// https://www.w3.org/TR/html-aam-1.0/#details-id-97
|
|
18614
18575
|
if (element.tagName === 'OPTION') {
|
|
18615
18576
|
return element.selected;
|
|
18616
|
-
}
|
|
18617
|
-
|
|
18577
|
+
}
|
|
18618
18578
|
|
|
18579
|
+
// explicit value
|
|
18619
18580
|
return checkBooleanAttribute(element, 'aria-selected');
|
|
18620
18581
|
}
|
|
18582
|
+
|
|
18621
18583
|
/**
|
|
18622
18584
|
* @param {Element} element -
|
|
18623
18585
|
* @returns {boolean | undefined} - false/true if (not)checked, undefined if not checked-able
|
|
18624
18586
|
*/
|
|
18625
|
-
|
|
18626
|
-
|
|
18627
18587
|
function computeAriaChecked(element) {
|
|
18628
18588
|
// implicit value from html-aam mappings: https://www.w3.org/TR/html-aam-1.0/#html-attribute-state-and-property-mappings
|
|
18629
18589
|
// https://www.w3.org/TR/html-aam-1.0/#details-id-56
|
|
@@ -18631,66 +18591,56 @@ function computeAriaChecked(element) {
|
|
|
18631
18591
|
if ('indeterminate' in element && element.indeterminate) {
|
|
18632
18592
|
return undefined;
|
|
18633
18593
|
}
|
|
18634
|
-
|
|
18635
18594
|
if ('checked' in element) {
|
|
18636
18595
|
return element.checked;
|
|
18637
|
-
}
|
|
18638
|
-
|
|
18596
|
+
}
|
|
18639
18597
|
|
|
18598
|
+
// explicit value
|
|
18640
18599
|
return checkBooleanAttribute(element, 'aria-checked');
|
|
18641
18600
|
}
|
|
18601
|
+
|
|
18642
18602
|
/**
|
|
18643
18603
|
* @param {Element} element -
|
|
18644
18604
|
* @returns {boolean | undefined} - false/true if (not)pressed, undefined if not press-able
|
|
18645
18605
|
*/
|
|
18646
|
-
|
|
18647
|
-
|
|
18648
18606
|
function computeAriaPressed(element) {
|
|
18649
18607
|
// https://www.w3.org/TR/wai-aria-1.1/#aria-pressed
|
|
18650
18608
|
return checkBooleanAttribute(element, 'aria-pressed');
|
|
18651
18609
|
}
|
|
18610
|
+
|
|
18652
18611
|
/**
|
|
18653
18612
|
* @param {Element} element -
|
|
18654
18613
|
* @returns {boolean | string | null} -
|
|
18655
18614
|
*/
|
|
18656
|
-
|
|
18657
|
-
|
|
18658
18615
|
function computeAriaCurrent(element) {
|
|
18659
18616
|
var _ref9, _checkBooleanAttribut;
|
|
18660
|
-
|
|
18661
18617
|
// https://www.w3.org/TR/wai-aria-1.1/#aria-current
|
|
18662
18618
|
return (_ref9 = (_checkBooleanAttribut = checkBooleanAttribute(element, 'aria-current')) != null ? _checkBooleanAttribut : element.getAttribute('aria-current')) != null ? _ref9 : false;
|
|
18663
18619
|
}
|
|
18620
|
+
|
|
18664
18621
|
/**
|
|
18665
18622
|
* @param {Element} element -
|
|
18666
18623
|
* @returns {boolean | undefined} - false/true if (not)expanded, undefined if not expand-able
|
|
18667
18624
|
*/
|
|
18668
|
-
|
|
18669
|
-
|
|
18670
18625
|
function computeAriaExpanded(element) {
|
|
18671
18626
|
// https://www.w3.org/TR/wai-aria-1.1/#aria-expanded
|
|
18672
18627
|
return checkBooleanAttribute(element, 'aria-expanded');
|
|
18673
18628
|
}
|
|
18674
|
-
|
|
18675
18629
|
function checkBooleanAttribute(element, attribute) {
|
|
18676
18630
|
const attributeValue = element.getAttribute(attribute);
|
|
18677
|
-
|
|
18678
18631
|
if (attributeValue === 'true') {
|
|
18679
18632
|
return true;
|
|
18680
18633
|
}
|
|
18681
|
-
|
|
18682
18634
|
if (attributeValue === 'false') {
|
|
18683
18635
|
return false;
|
|
18684
18636
|
}
|
|
18685
|
-
|
|
18686
18637
|
return undefined;
|
|
18687
18638
|
}
|
|
18639
|
+
|
|
18688
18640
|
/**
|
|
18689
18641
|
* @param {Element} element -
|
|
18690
18642
|
* @returns {number | undefined} - number if implicit heading or aria-level present, otherwise undefined
|
|
18691
18643
|
*/
|
|
18692
|
-
|
|
18693
|
-
|
|
18694
18644
|
function computeHeadingLevel(element) {
|
|
18695
18645
|
// https://w3c.github.io/html-aam/#el-h1-h6
|
|
18696
18646
|
// https://w3c.github.io/html-aam/#el-h1-h6
|
|
@@ -18701,15 +18651,14 @@ function computeHeadingLevel(element) {
|
|
|
18701
18651
|
H4: 4,
|
|
18702
18652
|
H5: 5,
|
|
18703
18653
|
H6: 6
|
|
18704
|
-
};
|
|
18654
|
+
};
|
|
18655
|
+
// explicit aria-level value
|
|
18705
18656
|
// https://www.w3.org/TR/wai-aria-1.2/#aria-level
|
|
18706
|
-
|
|
18707
18657
|
const ariaLevelAttribute = element.getAttribute('aria-level') && Number(element.getAttribute('aria-level'));
|
|
18708
18658
|
return ariaLevelAttribute || implicitHeadingLevels[element.tagName];
|
|
18709
18659
|
}
|
|
18710
18660
|
|
|
18711
18661
|
const normalize = getDefaultNormalizer();
|
|
18712
|
-
|
|
18713
18662
|
function escapeRegExp(string) {
|
|
18714
18663
|
return string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
18715
18664
|
}
|
|
@@ -18717,7 +18666,6 @@ function escapeRegExp(string) {
|
|
|
18717
18666
|
function getRegExpMatcher(string) {
|
|
18718
18667
|
return new RegExp(escapeRegExp(string.toLowerCase()), 'i');
|
|
18719
18668
|
}
|
|
18720
|
-
|
|
18721
18669
|
function makeSuggestion(queryName, element, content, _ref) {
|
|
18722
18670
|
let {
|
|
18723
18671
|
variant,
|
|
@@ -18726,20 +18674,16 @@ function makeSuggestion(queryName, element, content, _ref) {
|
|
|
18726
18674
|
let warning = '';
|
|
18727
18675
|
const queryOptions = {};
|
|
18728
18676
|
const queryArgs = [['Role', 'TestId'].includes(queryName) ? content : getRegExpMatcher(content)];
|
|
18729
|
-
|
|
18730
18677
|
if (name) {
|
|
18731
18678
|
queryOptions.name = getRegExpMatcher(name);
|
|
18732
18679
|
}
|
|
18733
|
-
|
|
18734
18680
|
if (queryName === 'Role' && isInaccessible(element)) {
|
|
18735
18681
|
queryOptions.hidden = true;
|
|
18736
18682
|
warning = "Element is inaccessible. This means that the element and all its children are invisible to screen readers.\n If you are using the aria-hidden prop, make sure this is the right choice for your case.\n ";
|
|
18737
18683
|
}
|
|
18738
|
-
|
|
18739
18684
|
if (Object.keys(queryOptions).length > 0) {
|
|
18740
18685
|
queryArgs.push(queryOptions);
|
|
18741
18686
|
}
|
|
18742
|
-
|
|
18743
18687
|
const queryMethod = variant + "By" + queryName;
|
|
18744
18688
|
return {
|
|
18745
18689
|
queryName,
|
|
@@ -18747,12 +18691,10 @@ function makeSuggestion(queryName, element, content, _ref) {
|
|
|
18747
18691
|
queryArgs,
|
|
18748
18692
|
variant,
|
|
18749
18693
|
warning,
|
|
18750
|
-
|
|
18751
18694
|
toString() {
|
|
18752
18695
|
if (warning) {
|
|
18753
18696
|
console.warn(warning);
|
|
18754
18697
|
}
|
|
18755
|
-
|
|
18756
18698
|
let [text, options] = queryArgs;
|
|
18757
18699
|
text = typeof text === 'string' ? "'" + text + "'" : text;
|
|
18758
18700
|
options = options ? ", { " + Object.entries(options).map(_ref2 => {
|
|
@@ -18761,29 +18703,23 @@ function makeSuggestion(queryName, element, content, _ref) {
|
|
|
18761
18703
|
}).join(', ') + " }" : '';
|
|
18762
18704
|
return queryMethod + "(" + text + options + ")";
|
|
18763
18705
|
}
|
|
18764
|
-
|
|
18765
18706
|
};
|
|
18766
18707
|
}
|
|
18767
|
-
|
|
18768
18708
|
function canSuggest(currentMethod, requestedMethod, data) {
|
|
18769
18709
|
return data && (!requestedMethod || requestedMethod.toLowerCase() === currentMethod.toLowerCase());
|
|
18770
18710
|
}
|
|
18771
|
-
|
|
18772
18711
|
function getSuggestedQuery(element, variant, method) {
|
|
18773
18712
|
var _element$getAttribute, _getImplicitAriaRoles;
|
|
18774
|
-
|
|
18775
18713
|
if (variant === void 0) {
|
|
18776
18714
|
variant = 'get';
|
|
18777
18715
|
}
|
|
18778
|
-
|
|
18779
18716
|
// don't create suggestions for script and style elements
|
|
18780
18717
|
if (element.matches(getConfig().defaultIgnore)) {
|
|
18781
18718
|
return undefined;
|
|
18782
|
-
}
|
|
18783
|
-
|
|
18719
|
+
}
|
|
18784
18720
|
|
|
18721
|
+
//We prefer to suggest something else if the role is generic
|
|
18785
18722
|
const role = (_element$getAttribute = element.getAttribute('role')) != null ? _element$getAttribute : (_getImplicitAriaRoles = getImplicitAriaRoles(element)) == null ? void 0 : _getImplicitAriaRoles[0];
|
|
18786
|
-
|
|
18787
18723
|
if (role !== 'generic' && canSuggest('Role', method, role)) {
|
|
18788
18724
|
return makeSuggestion('Role', element, role, {
|
|
18789
18725
|
variant,
|
|
@@ -18792,70 +18728,55 @@ function getSuggestedQuery(element, variant, method) {
|
|
|
18792
18728
|
})
|
|
18793
18729
|
});
|
|
18794
18730
|
}
|
|
18795
|
-
|
|
18796
18731
|
const labelText = getLabels(document, element).map(label => label.content).join(' ');
|
|
18797
|
-
|
|
18798
18732
|
if (canSuggest('LabelText', method, labelText)) {
|
|
18799
18733
|
return makeSuggestion('LabelText', element, labelText, {
|
|
18800
18734
|
variant
|
|
18801
18735
|
});
|
|
18802
18736
|
}
|
|
18803
|
-
|
|
18804
18737
|
const placeholderText = element.getAttribute('placeholder');
|
|
18805
|
-
|
|
18806
18738
|
if (canSuggest('PlaceholderText', method, placeholderText)) {
|
|
18807
18739
|
return makeSuggestion('PlaceholderText', element, placeholderText, {
|
|
18808
18740
|
variant
|
|
18809
18741
|
});
|
|
18810
18742
|
}
|
|
18811
|
-
|
|
18812
18743
|
const textContent = normalize(getNodeText(element));
|
|
18813
|
-
|
|
18814
18744
|
if (canSuggest('Text', method, textContent)) {
|
|
18815
18745
|
return makeSuggestion('Text', element, textContent, {
|
|
18816
18746
|
variant
|
|
18817
18747
|
});
|
|
18818
18748
|
}
|
|
18819
|
-
|
|
18820
18749
|
if (canSuggest('DisplayValue', method, element.value)) {
|
|
18821
18750
|
return makeSuggestion('DisplayValue', element, normalize(element.value), {
|
|
18822
18751
|
variant
|
|
18823
18752
|
});
|
|
18824
18753
|
}
|
|
18825
|
-
|
|
18826
18754
|
const alt = element.getAttribute('alt');
|
|
18827
|
-
|
|
18828
18755
|
if (canSuggest('AltText', method, alt)) {
|
|
18829
18756
|
return makeSuggestion('AltText', element, alt, {
|
|
18830
18757
|
variant
|
|
18831
18758
|
});
|
|
18832
18759
|
}
|
|
18833
|
-
|
|
18834
18760
|
const title = element.getAttribute('title');
|
|
18835
|
-
|
|
18836
18761
|
if (canSuggest('Title', method, title)) {
|
|
18837
18762
|
return makeSuggestion('Title', element, title, {
|
|
18838
18763
|
variant
|
|
18839
18764
|
});
|
|
18840
18765
|
}
|
|
18841
|
-
|
|
18842
18766
|
const testId = element.getAttribute(getConfig().testIdAttribute);
|
|
18843
|
-
|
|
18844
18767
|
if (canSuggest('TestId', method, testId)) {
|
|
18845
18768
|
return makeSuggestion('TestId', element, testId, {
|
|
18846
18769
|
variant
|
|
18847
18770
|
});
|
|
18848
18771
|
}
|
|
18849
|
-
|
|
18850
18772
|
return undefined;
|
|
18851
18773
|
}
|
|
18852
18774
|
|
|
18775
|
+
// This is so the stack trace the developer sees is one that's
|
|
18853
18776
|
// closer to their code (because async stack traces are hard to follow).
|
|
18854
|
-
|
|
18855
18777
|
function copyStackTrace(target, source) {
|
|
18856
18778
|
target.stack = source.stack.replace(source.message, target.message);
|
|
18857
18779
|
}
|
|
18858
|
-
|
|
18859
18780
|
function waitFor(callback, _ref) {
|
|
18860
18781
|
let {
|
|
18861
18782
|
container = getDocument$1(),
|
|
@@ -18874,59 +18795,55 @@ function waitFor(callback, _ref) {
|
|
|
18874
18795
|
characterData: true
|
|
18875
18796
|
}
|
|
18876
18797
|
} = _ref;
|
|
18877
|
-
|
|
18878
18798
|
if (typeof callback !== 'function') {
|
|
18879
18799
|
throw new TypeError('Received `callback` arg must be a function');
|
|
18880
18800
|
}
|
|
18881
|
-
|
|
18882
18801
|
return new Promise(async (resolve, reject) => {
|
|
18883
18802
|
let lastError, intervalId, observer;
|
|
18884
18803
|
let finished = false;
|
|
18885
18804
|
let promiseStatus = 'idle';
|
|
18886
18805
|
const overallTimeoutTimer = setTimeout(handleTimeout, timeout);
|
|
18887
18806
|
const usingJestFakeTimers = jestFakeTimersAreEnabled$1();
|
|
18888
|
-
|
|
18889
18807
|
if (usingJestFakeTimers) {
|
|
18890
18808
|
const {
|
|
18891
18809
|
unstable_advanceTimersWrapper: advanceTimersWrapper
|
|
18892
18810
|
} = getConfig();
|
|
18893
|
-
checkCallback();
|
|
18811
|
+
checkCallback();
|
|
18812
|
+
// this is a dangerous rule to disable because it could lead to an
|
|
18894
18813
|
// infinite loop. However, eslint isn't smart enough to know that we're
|
|
18895
18814
|
// setting finished inside `onDone` which will be called when we're done
|
|
18896
18815
|
// waiting or when we've timed out.
|
|
18897
18816
|
// eslint-disable-next-line no-unmodified-loop-condition
|
|
18898
|
-
|
|
18899
18817
|
while (!finished) {
|
|
18900
18818
|
if (!jestFakeTimersAreEnabled$1()) {
|
|
18901
18819
|
const error = new Error("Changed from using fake timers to real timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to real timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830");
|
|
18902
18820
|
if (!showOriginalStackTrace) copyStackTrace(error, stackTraceError);
|
|
18903
18821
|
reject(error);
|
|
18904
18822
|
return;
|
|
18905
|
-
}
|
|
18823
|
+
}
|
|
18824
|
+
// we *could* (maybe should?) use `advanceTimersToNextTimer` but it's
|
|
18906
18825
|
// possible that could make this loop go on forever if someone is using
|
|
18907
18826
|
// third party code that's setting up recursive timers so rapidly that
|
|
18908
18827
|
// the user's timer's don't get a chance to resolve. So we'll advance
|
|
18909
18828
|
// by an interval instead. (We have a test for this case).
|
|
18910
|
-
|
|
18911
|
-
|
|
18912
18829
|
advanceTimersWrapper(() => {
|
|
18913
18830
|
jest.advanceTimersByTime(interval);
|
|
18914
|
-
});
|
|
18831
|
+
});
|
|
18832
|
+
|
|
18833
|
+
// It's really important that checkCallback is run *before* we flush
|
|
18915
18834
|
// in-flight promises. To be honest, I'm not sure why, and I can't quite
|
|
18916
18835
|
// think of a way to reproduce the problem in a test, but I spent
|
|
18917
18836
|
// an entire day banging my head against a wall on this.
|
|
18918
|
-
|
|
18919
18837
|
checkCallback();
|
|
18920
|
-
|
|
18921
18838
|
if (finished) {
|
|
18922
18839
|
break;
|
|
18923
|
-
}
|
|
18840
|
+
}
|
|
18841
|
+
|
|
18842
|
+
// In this rare case, we *need* to wait for in-flight promises
|
|
18924
18843
|
// to resolve before continuing. We don't need to take advantage
|
|
18925
18844
|
// of parallelization so we're fine.
|
|
18926
18845
|
// https://stackoverflow.com/a/59243586/971592
|
|
18927
18846
|
// eslint-disable-next-line no-await-in-loop
|
|
18928
|
-
|
|
18929
|
-
|
|
18930
18847
|
await advanceTimersWrapper(async () => {
|
|
18931
18848
|
await new Promise(r => {
|
|
18932
18849
|
setTimeout(r, 0);
|
|
@@ -18941,7 +18858,6 @@ function waitFor(callback, _ref) {
|
|
|
18941
18858
|
reject(e);
|
|
18942
18859
|
return;
|
|
18943
18860
|
}
|
|
18944
|
-
|
|
18945
18861
|
intervalId = setInterval(checkRealTimersCallback, interval);
|
|
18946
18862
|
const {
|
|
18947
18863
|
MutationObserver
|
|
@@ -18950,23 +18866,19 @@ function waitFor(callback, _ref) {
|
|
|
18950
18866
|
observer.observe(container, mutationObserverOptions);
|
|
18951
18867
|
checkCallback();
|
|
18952
18868
|
}
|
|
18953
|
-
|
|
18954
18869
|
function onDone(error, result) {
|
|
18955
18870
|
finished = true;
|
|
18956
18871
|
clearTimeout(overallTimeoutTimer);
|
|
18957
|
-
|
|
18958
18872
|
if (!usingJestFakeTimers) {
|
|
18959
18873
|
clearInterval(intervalId);
|
|
18960
18874
|
observer.disconnect();
|
|
18961
18875
|
}
|
|
18962
|
-
|
|
18963
18876
|
if (error) {
|
|
18964
18877
|
reject(error);
|
|
18965
18878
|
} else {
|
|
18966
18879
|
resolve(result);
|
|
18967
18880
|
}
|
|
18968
18881
|
}
|
|
18969
|
-
|
|
18970
18882
|
function checkRealTimersCallback() {
|
|
18971
18883
|
if (jestFakeTimersAreEnabled$1()) {
|
|
18972
18884
|
const error = new Error("Changed from using real timers to fake timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to fake timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830");
|
|
@@ -18976,13 +18888,10 @@ function waitFor(callback, _ref) {
|
|
|
18976
18888
|
return checkCallback();
|
|
18977
18889
|
}
|
|
18978
18890
|
}
|
|
18979
|
-
|
|
18980
18891
|
function checkCallback() {
|
|
18981
18892
|
if (promiseStatus === 'pending') return;
|
|
18982
|
-
|
|
18983
18893
|
try {
|
|
18984
18894
|
const result = runWithExpensiveErrorDiagnosticsDisabled(callback);
|
|
18985
|
-
|
|
18986
18895
|
if (typeof (result == null ? void 0 : result.then) === 'function') {
|
|
18987
18896
|
promiseStatus = 'pending';
|
|
18988
18897
|
result.then(resolvedValue => {
|
|
@@ -18994,36 +18903,30 @@ function waitFor(callback, _ref) {
|
|
|
18994
18903
|
});
|
|
18995
18904
|
} else {
|
|
18996
18905
|
onDone(null, result);
|
|
18997
|
-
}
|
|
18998
|
-
|
|
18906
|
+
}
|
|
18907
|
+
// If `callback` throws, wait for the next mutation, interval, or timeout.
|
|
18999
18908
|
} catch (error) {
|
|
19000
18909
|
// Save the most recent callback error to reject the promise with it in the event of a timeout
|
|
19001
18910
|
lastError = error;
|
|
19002
18911
|
}
|
|
19003
18912
|
}
|
|
19004
|
-
|
|
19005
18913
|
function handleTimeout() {
|
|
19006
18914
|
let error;
|
|
19007
|
-
|
|
19008
18915
|
if (lastError) {
|
|
19009
18916
|
error = lastError;
|
|
19010
|
-
|
|
19011
18917
|
if (!showOriginalStackTrace && error.name === 'TestingLibraryElementError') {
|
|
19012
18918
|
copyStackTrace(error, stackTraceError);
|
|
19013
18919
|
}
|
|
19014
18920
|
} else {
|
|
19015
18921
|
error = new Error('Timed out in waitFor.');
|
|
19016
|
-
|
|
19017
18922
|
if (!showOriginalStackTrace) {
|
|
19018
18923
|
copyStackTrace(error, stackTraceError);
|
|
19019
18924
|
}
|
|
19020
18925
|
}
|
|
19021
|
-
|
|
19022
18926
|
onDone(onTimeout(error), null);
|
|
19023
18927
|
}
|
|
19024
18928
|
});
|
|
19025
18929
|
}
|
|
19026
|
-
|
|
19027
18930
|
function waitForWrapper(callback, options) {
|
|
19028
18931
|
// create the error here so its stack trace is as close to the
|
|
19029
18932
|
// calling code as possible
|
|
@@ -19033,6 +18936,7 @@ function waitForWrapper(callback, options) {
|
|
|
19033
18936
|
...options
|
|
19034
18937
|
}));
|
|
19035
18938
|
}
|
|
18939
|
+
|
|
19036
18940
|
/*
|
|
19037
18941
|
eslint
|
|
19038
18942
|
max-lines-per-function: ["error", {"max": 200}],
|
|
@@ -19041,11 +18945,9 @@ eslint
|
|
|
19041
18945
|
function getElementError(message, container) {
|
|
19042
18946
|
return getConfig().getElementError(message, container);
|
|
19043
18947
|
}
|
|
19044
|
-
|
|
19045
18948
|
function getMultipleElementsFoundError(message, container) {
|
|
19046
18949
|
return getElementError(message + "\n\n(If this is intentional, then use the `*AllBy*` variant of the query (like `queryAllByText`, `getAllByText`, or `findAllByText`)).", container);
|
|
19047
18950
|
}
|
|
19048
|
-
|
|
19049
18951
|
function queryAllByAttribute(attribute, container, text, _temp) {
|
|
19050
18952
|
let {
|
|
19051
18953
|
exact = true,
|
|
@@ -19061,61 +18963,51 @@ function queryAllByAttribute(attribute, container, text, _temp) {
|
|
|
19061
18963
|
});
|
|
19062
18964
|
return Array.from(container.querySelectorAll("[" + attribute + "]")).filter(node => matcher(node.getAttribute(attribute), node, text, matchNormalizer));
|
|
19063
18965
|
}
|
|
19064
|
-
|
|
19065
18966
|
function queryByAttribute(attribute, container, text, options) {
|
|
19066
18967
|
const els = queryAllByAttribute(attribute, container, text, options);
|
|
19067
|
-
|
|
19068
18968
|
if (els.length > 1) {
|
|
19069
18969
|
throw getMultipleElementsFoundError("Found multiple elements by [" + attribute + "=" + text + "]", container);
|
|
19070
18970
|
}
|
|
19071
|
-
|
|
19072
18971
|
return els[0] || null;
|
|
19073
|
-
}
|
|
18972
|
+
}
|
|
18973
|
+
|
|
18974
|
+
// this accepts a query function and returns a function which throws an error
|
|
19074
18975
|
// if more than one elements is returned, otherwise it returns the first
|
|
19075
18976
|
// element or null
|
|
19076
|
-
|
|
19077
|
-
|
|
19078
18977
|
function makeSingleQuery(allQuery, getMultipleError) {
|
|
19079
18978
|
return function (container) {
|
|
19080
18979
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
19081
18980
|
args[_key - 1] = arguments[_key];
|
|
19082
18981
|
}
|
|
19083
|
-
|
|
19084
18982
|
const els = allQuery(container, ...args);
|
|
19085
|
-
|
|
19086
18983
|
if (els.length > 1) {
|
|
19087
18984
|
const elementStrings = els.map(element => getElementError(null, element).message).join('\n\n');
|
|
19088
18985
|
throw getMultipleElementsFoundError(getMultipleError(container, ...args) + "\n\nHere are the matching elements:\n\n" + elementStrings, container);
|
|
19089
18986
|
}
|
|
19090
|
-
|
|
19091
18987
|
return els[0] || null;
|
|
19092
18988
|
};
|
|
19093
18989
|
}
|
|
19094
|
-
|
|
19095
18990
|
function getSuggestionError(suggestion, container) {
|
|
19096
18991
|
return getConfig().getElementError("A better query is available, try this:\n" + suggestion.toString() + "\n", container);
|
|
19097
|
-
}
|
|
19098
|
-
// if an empty list of elements is returned
|
|
19099
|
-
|
|
18992
|
+
}
|
|
19100
18993
|
|
|
18994
|
+
// this accepts a query function and returns a function which throws an error
|
|
18995
|
+
// if an empty list of elements is returned
|
|
19101
18996
|
function makeGetAllQuery(allQuery, getMissingError) {
|
|
19102
18997
|
return function (container) {
|
|
19103
18998
|
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
19104
18999
|
args[_key2 - 1] = arguments[_key2];
|
|
19105
19000
|
}
|
|
19106
|
-
|
|
19107
19001
|
const els = allQuery(container, ...args);
|
|
19108
|
-
|
|
19109
19002
|
if (!els.length) {
|
|
19110
19003
|
throw getConfig().getElementError(getMissingError(container, ...args), container);
|
|
19111
19004
|
}
|
|
19112
|
-
|
|
19113
19005
|
return els;
|
|
19114
19006
|
};
|
|
19115
|
-
}
|
|
19116
|
-
// waitFor and passing a function which invokes the getter.
|
|
19117
|
-
|
|
19007
|
+
}
|
|
19118
19008
|
|
|
19009
|
+
// this accepts a getter query function and returns a function which calls
|
|
19010
|
+
// waitFor and passing a function which invokes the getter.
|
|
19119
19011
|
function makeFindQuery(getter) {
|
|
19120
19012
|
return (container, text, options, waitForOptions) => {
|
|
19121
19013
|
return waitForWrapper(() => {
|
|
@@ -19126,60 +19018,51 @@ function makeFindQuery(getter) {
|
|
|
19126
19018
|
});
|
|
19127
19019
|
};
|
|
19128
19020
|
}
|
|
19129
|
-
|
|
19130
19021
|
const wrapSingleQueryWithSuggestion = (query, queryAllByName, variant) => function (container) {
|
|
19131
19022
|
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
19132
19023
|
args[_key3 - 1] = arguments[_key3];
|
|
19133
19024
|
}
|
|
19134
|
-
|
|
19135
19025
|
const element = query(container, ...args);
|
|
19136
19026
|
const [{
|
|
19137
19027
|
suggest = getConfig().throwSuggestions
|
|
19138
19028
|
} = {}] = args.slice(-1);
|
|
19139
|
-
|
|
19140
19029
|
if (element && suggest) {
|
|
19141
19030
|
const suggestion = getSuggestedQuery(element, variant);
|
|
19142
|
-
|
|
19143
19031
|
if (suggestion && !queryAllByName.endsWith(suggestion.queryName)) {
|
|
19144
19032
|
throw getSuggestionError(suggestion.toString(), container);
|
|
19145
19033
|
}
|
|
19146
19034
|
}
|
|
19147
|
-
|
|
19148
19035
|
return element;
|
|
19149
19036
|
};
|
|
19150
|
-
|
|
19151
19037
|
const wrapAllByQueryWithSuggestion = (query, queryAllByName, variant) => function (container) {
|
|
19152
19038
|
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
19153
19039
|
args[_key4 - 1] = arguments[_key4];
|
|
19154
19040
|
}
|
|
19155
|
-
|
|
19156
19041
|
const els = query(container, ...args);
|
|
19157
19042
|
const [{
|
|
19158
19043
|
suggest = getConfig().throwSuggestions
|
|
19159
19044
|
} = {}] = args.slice(-1);
|
|
19160
|
-
|
|
19161
19045
|
if (els.length && suggest) {
|
|
19162
19046
|
// get a unique list of all suggestion messages. We are only going to make a suggestion if
|
|
19163
19047
|
// all the suggestions are the same
|
|
19164
19048
|
const uniqueSuggestionMessages = [...new Set(els.map(element => {
|
|
19165
19049
|
var _getSuggestedQuery;
|
|
19166
|
-
|
|
19167
19050
|
return (_getSuggestedQuery = getSuggestedQuery(element, variant)) == null ? void 0 : _getSuggestedQuery.toString();
|
|
19168
19051
|
}))];
|
|
19169
|
-
|
|
19170
|
-
|
|
19171
|
-
uniqueSuggestionMessages.length === 1 && !queryAllByName.endsWith(
|
|
19052
|
+
if (
|
|
19053
|
+
// only want to suggest if all the els have the same suggestion.
|
|
19054
|
+
uniqueSuggestionMessages.length === 1 && !queryAllByName.endsWith(
|
|
19055
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- TODO: Can this be null at runtime?
|
|
19172
19056
|
getSuggestedQuery(els[0], variant).queryName)) {
|
|
19173
19057
|
throw getSuggestionError(uniqueSuggestionMessages[0], container);
|
|
19174
19058
|
}
|
|
19175
19059
|
}
|
|
19176
|
-
|
|
19177
19060
|
return els;
|
|
19178
|
-
};
|
|
19061
|
+
};
|
|
19062
|
+
|
|
19063
|
+
// TODO: This deviates from the published declarations
|
|
19179
19064
|
// However, the implementation always required a dyadic (after `container`) not variadic `queryAllBy` considering the implementation of `makeFindQuery`
|
|
19180
19065
|
// This is at least statically true and can be verified by accepting `QueryMethod<Arguments, HTMLElement[]>`
|
|
19181
|
-
|
|
19182
|
-
|
|
19183
19066
|
function buildQueries(queryAllBy, getMultipleError, getMissingError) {
|
|
19184
19067
|
const queryBy = wrapSingleQueryWithSuggestion(makeSingleQuery(queryAllBy, getMultipleError), queryAllBy.name, 'query');
|
|
19185
19068
|
const getAllBy = makeGetAllQuery(queryAllBy, getMissingError);
|
|
@@ -19218,7 +19101,6 @@ function queryAllLabels(container) {
|
|
|
19218
19101
|
return textToMatch !== null;
|
|
19219
19102
|
});
|
|
19220
19103
|
}
|
|
19221
|
-
|
|
19222
19104
|
const queryAllLabelsByText = function (container, text, _temp) {
|
|
19223
19105
|
let {
|
|
19224
19106
|
exact = true,
|
|
@@ -19246,7 +19128,6 @@ const queryAllLabelsByText = function (container, text, _temp) {
|
|
|
19246
19128
|
return node;
|
|
19247
19129
|
});
|
|
19248
19130
|
};
|
|
19249
|
-
|
|
19250
19131
|
const queryAllByLabelText = function (container, text, _temp2) {
|
|
19251
19132
|
let {
|
|
19252
19133
|
selector = '*',
|
|
@@ -19273,47 +19154,40 @@ const queryAllByLabelText = function (container, text, _temp2) {
|
|
|
19273
19154
|
});
|
|
19274
19155
|
const labelsValue = labelList.filter(label => Boolean(label.content)).map(label => label.content);
|
|
19275
19156
|
if (matcher(labelsValue.join(' '), labelledElement, text, matchNormalizer)) labelledElements.push(labelledElement);
|
|
19276
|
-
|
|
19277
19157
|
if (labelsValue.length > 1) {
|
|
19278
19158
|
labelsValue.forEach((labelValue, index) => {
|
|
19279
19159
|
if (matcher(labelValue, labelledElement, text, matchNormalizer)) labelledElements.push(labelledElement);
|
|
19280
19160
|
const labelsFiltered = [...labelsValue];
|
|
19281
19161
|
labelsFiltered.splice(index, 1);
|
|
19282
|
-
|
|
19283
19162
|
if (labelsFiltered.length > 1) {
|
|
19284
19163
|
if (matcher(labelsFiltered.join(' '), labelledElement, text, matchNormalizer)) labelledElements.push(labelledElement);
|
|
19285
19164
|
}
|
|
19286
19165
|
});
|
|
19287
19166
|
}
|
|
19288
|
-
|
|
19289
19167
|
return labelledElements;
|
|
19290
19168
|
}, []).concat(queryAllByAttribute('aria-label', container, text, {
|
|
19291
19169
|
exact,
|
|
19292
19170
|
normalizer: matchNormalizer
|
|
19293
19171
|
}));
|
|
19294
19172
|
return Array.from(new Set(matchingLabelledElements)).filter(element => element.matches(selector));
|
|
19295
|
-
};
|
|
19173
|
+
};
|
|
19174
|
+
|
|
19175
|
+
// the getAll* query would normally look like this:
|
|
19296
19176
|
// const getAllByLabelText = makeGetAllQuery(
|
|
19297
19177
|
// queryAllByLabelText,
|
|
19298
19178
|
// (c, text) => `Unable to find a label with the text of: ${text}`,
|
|
19299
19179
|
// )
|
|
19300
19180
|
// however, we can give a more helpful error message than the generic one,
|
|
19301
19181
|
// so we're writing this one out by hand.
|
|
19302
|
-
|
|
19303
|
-
|
|
19304
19182
|
const getAllByLabelText = function (container, text) {
|
|
19305
19183
|
for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
19306
19184
|
rest[_key - 2] = arguments[_key];
|
|
19307
19185
|
}
|
|
19308
|
-
|
|
19309
19186
|
const els = queryAllByLabelText(container, text, ...rest);
|
|
19310
|
-
|
|
19311
19187
|
if (!els.length) {
|
|
19312
19188
|
const labels = queryAllLabelsByText(container, text, ...rest);
|
|
19313
|
-
|
|
19314
19189
|
if (labels.length) {
|
|
19315
19190
|
const tagNames = labels.map(label => getTagNameOfElementAssociatedWithLabelViaFor(container, label)).filter(tagName => !!tagName);
|
|
19316
|
-
|
|
19317
19191
|
if (tagNames.length) {
|
|
19318
19192
|
throw getConfig().getElementError(tagNames.map(tagName => "Found a label with the text of: " + text + ", however the element associated with this label (<" + tagName + " />) is non-labellable [https://html.spec.whatwg.org/multipage/forms.html#category-label]. If you really need to label a <" + tagName + " />, you can use aria-label or aria-labelledby instead.").join('\n\n'), container);
|
|
19319
19193
|
} else {
|
|
@@ -19323,24 +19197,19 @@ const getAllByLabelText = function (container, text) {
|
|
|
19323
19197
|
throw getConfig().getElementError("Unable to find a label with the text of: " + text, container);
|
|
19324
19198
|
}
|
|
19325
19199
|
}
|
|
19326
|
-
|
|
19327
19200
|
return els;
|
|
19328
19201
|
};
|
|
19329
|
-
|
|
19330
19202
|
function getTagNameOfElementAssociatedWithLabelViaFor(container, label) {
|
|
19331
19203
|
const htmlFor = label.getAttribute('for');
|
|
19332
|
-
|
|
19333
19204
|
if (!htmlFor) {
|
|
19334
19205
|
return null;
|
|
19335
19206
|
}
|
|
19336
|
-
|
|
19337
19207
|
const element = container.querySelector("[id=\"" + htmlFor + "\"]");
|
|
19338
19208
|
return element ? element.tagName.toLowerCase() : null;
|
|
19339
|
-
}
|
|
19340
|
-
|
|
19209
|
+
}
|
|
19341
19210
|
|
|
19211
|
+
// the reason mentioned above is the same reason we're not using buildQueries
|
|
19342
19212
|
const getMultipleError$7 = (c, text) => "Found multiple elements with the text of: " + text;
|
|
19343
|
-
|
|
19344
19213
|
const queryByLabelText = wrapSingleQueryWithSuggestion(makeSingleQuery(queryAllByLabelText, getMultipleError$7), queryAllByLabelText.name, 'query');
|
|
19345
19214
|
const getByLabelText = makeSingleQuery(getAllByLabelText, getMultipleError$7);
|
|
19346
19215
|
const findAllByLabelText = makeFindQuery(wrapAllByQueryWithSuggestion(getAllByLabelText, getAllByLabelText.name, 'findAll'));
|
|
@@ -19353,15 +19222,11 @@ const queryAllByPlaceholderText = function () {
|
|
|
19353
19222
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
19354
19223
|
args[_key] = arguments[_key];
|
|
19355
19224
|
}
|
|
19356
|
-
|
|
19357
19225
|
checkContainerType$1(args[0]);
|
|
19358
19226
|
return queryAllByAttribute('placeholder', ...args);
|
|
19359
19227
|
};
|
|
19360
|
-
|
|
19361
19228
|
const getMultipleError$6 = (c, text) => "Found multiple elements with the placeholder text of: " + text;
|
|
19362
|
-
|
|
19363
19229
|
const getMissingError$6 = (c, text) => "Unable to find an element with the placeholder text of: " + text;
|
|
19364
|
-
|
|
19365
19230
|
const queryAllByPlaceholderTextWithSuggestions = wrapAllByQueryWithSuggestion(queryAllByPlaceholderText, queryAllByPlaceholderText.name, 'queryAll');
|
|
19366
19231
|
const [queryByPlaceholderText, getAllByPlaceholderText, getByPlaceholderText, findAllByPlaceholderText, findByPlaceholderText] = buildQueries(queryAllByPlaceholderText, getMultipleError$6, getMissingError$6);
|
|
19367
19232
|
|
|
@@ -19382,22 +19247,18 @@ const queryAllByText = function (container, text, _temp) {
|
|
|
19382
19247
|
normalizer
|
|
19383
19248
|
});
|
|
19384
19249
|
let baseArray = [];
|
|
19385
|
-
|
|
19386
19250
|
if (typeof container.matches === 'function' && container.matches(selector)) {
|
|
19387
19251
|
baseArray = [container];
|
|
19388
19252
|
}
|
|
19389
|
-
|
|
19390
|
-
|
|
19253
|
+
return [...baseArray, ...Array.from(container.querySelectorAll(selector))]
|
|
19254
|
+
// TODO: `matches` according lib.dom.d.ts can get only `string` but according our code it can handle also boolean :)
|
|
19391
19255
|
.filter(node => !ignore || !node.matches(ignore)).filter(node => matcher(getNodeText(node), node, text, matchNormalizer));
|
|
19392
19256
|
};
|
|
19393
|
-
|
|
19394
19257
|
const getMultipleError$5 = (c, text) => "Found multiple elements with the text: " + text;
|
|
19395
|
-
|
|
19396
19258
|
const getMissingError$5 = function (c, text, options) {
|
|
19397
19259
|
if (options === void 0) {
|
|
19398
19260
|
options = {};
|
|
19399
19261
|
}
|
|
19400
|
-
|
|
19401
19262
|
const {
|
|
19402
19263
|
collapseWhitespace,
|
|
19403
19264
|
trim,
|
|
@@ -19414,7 +19275,6 @@ const getMissingError$5 = function (c, text, options) {
|
|
|
19414
19275
|
const isCustomSelector = (selector != null ? selector : '*') !== '*';
|
|
19415
19276
|
return "Unable to find an element with the text: " + (isNormalizedDifferent ? normalizedText + " (normalized from '" + text + "')" : text) + (isCustomSelector ? ", which matches selector '" + selector + "'" : '') + ". This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.";
|
|
19416
19277
|
};
|
|
19417
|
-
|
|
19418
19278
|
const queryAllByTextWithSuggestions = wrapAllByQueryWithSuggestion(queryAllByText, queryAllByText.name, 'queryAll');
|
|
19419
19279
|
const [queryByText, getAllByText, getByText, findAllByText, findByText] = buildQueries(queryAllByText, getMultipleError$5, getMissingError$5);
|
|
19420
19280
|
|
|
@@ -19441,38 +19301,29 @@ const queryAllByDisplayValue = function (container, value, _temp) {
|
|
|
19441
19301
|
}
|
|
19442
19302
|
});
|
|
19443
19303
|
};
|
|
19444
|
-
|
|
19445
19304
|
const getMultipleError$4 = (c, value) => "Found multiple elements with the display value: " + value + ".";
|
|
19446
|
-
|
|
19447
19305
|
const getMissingError$4 = (c, value) => "Unable to find an element with the display value: " + value + ".";
|
|
19448
|
-
|
|
19449
19306
|
const queryAllByDisplayValueWithSuggestions = wrapAllByQueryWithSuggestion(queryAllByDisplayValue, queryAllByDisplayValue.name, 'queryAll');
|
|
19450
19307
|
const [queryByDisplayValue, getAllByDisplayValue, getByDisplayValue, findAllByDisplayValue, findByDisplayValue] = buildQueries(queryAllByDisplayValue, getMultipleError$4, getMissingError$4);
|
|
19451
19308
|
|
|
19309
|
+
// Valid tags are img, input, area and custom elements
|
|
19452
19310
|
const VALID_TAG_REGEXP = /^(img|input|area|.+-.+)$/i;
|
|
19453
|
-
|
|
19454
19311
|
const queryAllByAltText = function (container, alt, options) {
|
|
19455
19312
|
if (options === void 0) {
|
|
19456
19313
|
options = {};
|
|
19457
19314
|
}
|
|
19458
|
-
|
|
19459
19315
|
checkContainerType$1(container);
|
|
19460
19316
|
return queryAllByAttribute('alt', container, alt, options).filter(node => VALID_TAG_REGEXP.test(node.tagName));
|
|
19461
19317
|
};
|
|
19462
|
-
|
|
19463
19318
|
const getMultipleError$3 = (c, alt) => "Found multiple elements with the alt text: " + alt;
|
|
19464
|
-
|
|
19465
19319
|
const getMissingError$3 = (c, alt) => "Unable to find an element with the alt text: " + alt;
|
|
19466
|
-
|
|
19467
19320
|
const queryAllByAltTextWithSuggestions = wrapAllByQueryWithSuggestion(queryAllByAltText, queryAllByAltText.name, 'queryAll');
|
|
19468
19321
|
const [queryByAltText, getAllByAltText, getByAltText, findAllByAltText, findByAltText] = buildQueries(queryAllByAltText, getMultipleError$3, getMissingError$3);
|
|
19469
19322
|
|
|
19470
19323
|
const isSvgTitle = node => {
|
|
19471
19324
|
var _node$parentElement;
|
|
19472
|
-
|
|
19473
19325
|
return node.tagName.toLowerCase() === 'title' && ((_node$parentElement = node.parentElement) == null ? void 0 : _node$parentElement.tagName.toLowerCase()) === 'svg';
|
|
19474
19326
|
};
|
|
19475
|
-
|
|
19476
19327
|
const queryAllByTitle = function (container, text, _temp) {
|
|
19477
19328
|
let {
|
|
19478
19329
|
exact = true,
|
|
@@ -19489,11 +19340,8 @@ const queryAllByTitle = function (container, text, _temp) {
|
|
|
19489
19340
|
});
|
|
19490
19341
|
return Array.from(container.querySelectorAll('[title], svg > title')).filter(node => matcher(node.getAttribute('title'), node, text, matchNormalizer) || isSvgTitle(node) && matcher(getNodeText(node), node, text, matchNormalizer));
|
|
19491
19342
|
};
|
|
19492
|
-
|
|
19493
19343
|
const getMultipleError$2 = (c, title) => "Found multiple elements with the title: " + title + ".";
|
|
19494
|
-
|
|
19495
19344
|
const getMissingError$2 = (c, title) => "Unable to find an element with the title: " + title + ".";
|
|
19496
|
-
|
|
19497
19345
|
const queryAllByTitleWithSuggestions = wrapAllByQueryWithSuggestion(queryAllByTitle, queryAllByTitle.name, 'queryAll');
|
|
19498
19346
|
const [queryByTitle, getAllByTitle, getByTitle, findAllByTitle, findByTitle] = buildQueries(queryAllByTitle, getMultipleError$2, getMissingError$2);
|
|
19499
19347
|
|
|
@@ -19521,37 +19369,29 @@ function queryAllByRole(container, role, _temp) {
|
|
|
19521
19369
|
trim,
|
|
19522
19370
|
normalizer
|
|
19523
19371
|
});
|
|
19524
|
-
|
|
19525
19372
|
if (selected !== undefined) {
|
|
19526
19373
|
var _allRoles$get;
|
|
19527
|
-
|
|
19528
19374
|
// guard against unknown roles
|
|
19529
19375
|
if (((_allRoles$get = roles_1.get(role)) == null ? void 0 : _allRoles$get.props['aria-selected']) === undefined) {
|
|
19530
19376
|
throw new Error("\"aria-selected\" is not supported on role \"" + role + "\".");
|
|
19531
19377
|
}
|
|
19532
19378
|
}
|
|
19533
|
-
|
|
19534
19379
|
if (checked !== undefined) {
|
|
19535
19380
|
var _allRoles$get2;
|
|
19536
|
-
|
|
19537
19381
|
// guard against unknown roles
|
|
19538
19382
|
if (((_allRoles$get2 = roles_1.get(role)) == null ? void 0 : _allRoles$get2.props['aria-checked']) === undefined) {
|
|
19539
19383
|
throw new Error("\"aria-checked\" is not supported on role \"" + role + "\".");
|
|
19540
19384
|
}
|
|
19541
19385
|
}
|
|
19542
|
-
|
|
19543
19386
|
if (pressed !== undefined) {
|
|
19544
19387
|
var _allRoles$get3;
|
|
19545
|
-
|
|
19546
19388
|
// guard against unknown roles
|
|
19547
19389
|
if (((_allRoles$get3 = roles_1.get(role)) == null ? void 0 : _allRoles$get3.props['aria-pressed']) === undefined) {
|
|
19548
19390
|
throw new Error("\"aria-pressed\" is not supported on role \"" + role + "\".");
|
|
19549
19391
|
}
|
|
19550
19392
|
}
|
|
19551
|
-
|
|
19552
19393
|
if (current !== undefined) {
|
|
19553
19394
|
var _allRoles$get4;
|
|
19554
|
-
|
|
19555
19395
|
/* istanbul ignore next */
|
|
19556
19396
|
// guard against unknown roles
|
|
19557
19397
|
// All currently released ARIA versions support `aria-current` on all roles.
|
|
@@ -19560,89 +19400,71 @@ function queryAllByRole(container, role, _temp) {
|
|
|
19560
19400
|
throw new Error("\"aria-current\" is not supported on role \"" + role + "\".");
|
|
19561
19401
|
}
|
|
19562
19402
|
}
|
|
19563
|
-
|
|
19564
19403
|
if (level !== undefined) {
|
|
19565
19404
|
// guard against using `level` option with any role other than `heading`
|
|
19566
19405
|
if (role !== 'heading') {
|
|
19567
19406
|
throw new Error("Role \"" + role + "\" cannot have \"level\" property.");
|
|
19568
19407
|
}
|
|
19569
19408
|
}
|
|
19570
|
-
|
|
19571
19409
|
if (expanded !== undefined) {
|
|
19572
19410
|
var _allRoles$get5;
|
|
19573
|
-
|
|
19574
19411
|
// guard against unknown roles
|
|
19575
19412
|
if (((_allRoles$get5 = roles_1.get(role)) == null ? void 0 : _allRoles$get5.props['aria-expanded']) === undefined) {
|
|
19576
19413
|
throw new Error("\"aria-expanded\" is not supported on role \"" + role + "\".");
|
|
19577
19414
|
}
|
|
19578
19415
|
}
|
|
19579
|
-
|
|
19580
19416
|
const subtreeIsInaccessibleCache = new WeakMap();
|
|
19581
|
-
|
|
19582
19417
|
function cachedIsSubtreeInaccessible(element) {
|
|
19583
19418
|
if (!subtreeIsInaccessibleCache.has(element)) {
|
|
19584
19419
|
subtreeIsInaccessibleCache.set(element, isSubtreeInaccessible(element));
|
|
19585
19420
|
}
|
|
19586
|
-
|
|
19587
19421
|
return subtreeIsInaccessibleCache.get(element);
|
|
19588
19422
|
}
|
|
19589
|
-
|
|
19590
|
-
|
|
19423
|
+
return Array.from(container.querySelectorAll(
|
|
19424
|
+
// Only query elements that can be matched by the following filters
|
|
19591
19425
|
makeRoleSelector(role, exact, normalizer ? matchNormalizer : undefined))).filter(node => {
|
|
19592
19426
|
const isRoleSpecifiedExplicitly = node.hasAttribute('role');
|
|
19593
|
-
|
|
19594
19427
|
if (isRoleSpecifiedExplicitly) {
|
|
19595
19428
|
const roleValue = node.getAttribute('role');
|
|
19596
|
-
|
|
19597
19429
|
if (queryFallbacks) {
|
|
19598
19430
|
return roleValue.split(' ').filter(Boolean).some(text => matcher(text, node, role, matchNormalizer));
|
|
19599
|
-
}
|
|
19600
|
-
|
|
19601
|
-
|
|
19431
|
+
}
|
|
19432
|
+
// if a custom normalizer is passed then let normalizer handle the role value
|
|
19602
19433
|
if (normalizer) {
|
|
19603
19434
|
return matcher(roleValue, node, role, matchNormalizer);
|
|
19604
|
-
}
|
|
19605
|
-
|
|
19606
|
-
|
|
19435
|
+
}
|
|
19436
|
+
// other wise only send the first word to match
|
|
19607
19437
|
const [firstWord] = roleValue.split(' ');
|
|
19608
19438
|
return matcher(firstWord, node, role, matchNormalizer);
|
|
19609
19439
|
}
|
|
19610
|
-
|
|
19611
19440
|
const implicitRoles = getImplicitAriaRoles(node);
|
|
19612
19441
|
return implicitRoles.some(implicitRole => matcher(implicitRole, node, role, matchNormalizer));
|
|
19613
19442
|
}).filter(element => {
|
|
19614
19443
|
if (selected !== undefined) {
|
|
19615
19444
|
return selected === computeAriaSelected(element);
|
|
19616
19445
|
}
|
|
19617
|
-
|
|
19618
19446
|
if (checked !== undefined) {
|
|
19619
19447
|
return checked === computeAriaChecked(element);
|
|
19620
19448
|
}
|
|
19621
|
-
|
|
19622
19449
|
if (pressed !== undefined) {
|
|
19623
19450
|
return pressed === computeAriaPressed(element);
|
|
19624
19451
|
}
|
|
19625
|
-
|
|
19626
19452
|
if (current !== undefined) {
|
|
19627
19453
|
return current === computeAriaCurrent(element);
|
|
19628
19454
|
}
|
|
19629
|
-
|
|
19630
19455
|
if (expanded !== undefined) {
|
|
19631
19456
|
return expanded === computeAriaExpanded(element);
|
|
19632
19457
|
}
|
|
19633
|
-
|
|
19634
19458
|
if (level !== undefined) {
|
|
19635
19459
|
return level === computeHeadingLevel(element);
|
|
19636
|
-
}
|
|
19637
|
-
|
|
19638
|
-
|
|
19460
|
+
}
|
|
19461
|
+
// don't care if aria attributes are unspecified
|
|
19639
19462
|
return true;
|
|
19640
19463
|
}).filter(element => {
|
|
19641
19464
|
if (name === undefined) {
|
|
19642
19465
|
// Don't care
|
|
19643
19466
|
return true;
|
|
19644
19467
|
}
|
|
19645
|
-
|
|
19646
19468
|
return matches(computeAccessibleName(element, {
|
|
19647
19469
|
computedStyleSupportsPseudoElements: getConfig().computedStyleSupportsPseudoElements
|
|
19648
19470
|
}), element, name, text => text);
|
|
@@ -19651,7 +19473,6 @@ function queryAllByRole(container, role, _temp) {
|
|
|
19651
19473
|
// Don't care
|
|
19652
19474
|
return true;
|
|
19653
19475
|
}
|
|
19654
|
-
|
|
19655
19476
|
return matches(computeAccessibleDescription(element, {
|
|
19656
19477
|
computedStyleSupportsPseudoElements: getConfig().computedStyleSupportsPseudoElements
|
|
19657
19478
|
}), element, description, text => text);
|
|
@@ -19661,15 +19482,12 @@ function queryAllByRole(container, role, _temp) {
|
|
|
19661
19482
|
}) === false : true;
|
|
19662
19483
|
});
|
|
19663
19484
|
}
|
|
19664
|
-
|
|
19665
19485
|
function makeRoleSelector(role, exact, customNormalizer) {
|
|
19666
19486
|
var _roleElements$get;
|
|
19667
|
-
|
|
19668
19487
|
if (typeof role !== 'string') {
|
|
19669
19488
|
// For non-string role parameters we can not determine the implicitRoleSelectors.
|
|
19670
19489
|
return '*';
|
|
19671
19490
|
}
|
|
19672
|
-
|
|
19673
19491
|
const explicitRoleSelector = exact && !customNormalizer ? "*[role~=\"" + role + "\"]" : '*[role]';
|
|
19674
19492
|
const roleRelations = (_roleElements$get = roleElements_1.get(role)) != null ? _roleElements$get : new Set();
|
|
19675
19493
|
const implicitRoleSelectors = new Set(Array.from(roleRelations).map(_ref => {
|
|
@@ -19677,16 +19495,15 @@ function makeRoleSelector(role, exact, customNormalizer) {
|
|
|
19677
19495
|
name
|
|
19678
19496
|
} = _ref;
|
|
19679
19497
|
return name;
|
|
19680
|
-
}));
|
|
19498
|
+
}));
|
|
19499
|
+
|
|
19500
|
+
// Current transpilation config sometimes assumes `...` is always applied to arrays.
|
|
19681
19501
|
// `...` is equivalent to `Array.prototype.concat` for arrays.
|
|
19682
19502
|
// If you replace this code with `[explicitRoleSelector, ...implicitRoleSelectors]`, make sure every transpilation target retains the `...` in favor of `Array.prototype.concat`.
|
|
19683
|
-
|
|
19684
19503
|
return [explicitRoleSelector].concat(Array.from(implicitRoleSelectors)).join(',');
|
|
19685
19504
|
}
|
|
19686
|
-
|
|
19687
19505
|
const getNameHint = name => {
|
|
19688
19506
|
let nameHint = '';
|
|
19689
|
-
|
|
19690
19507
|
if (name === undefined) {
|
|
19691
19508
|
nameHint = '';
|
|
19692
19509
|
} else if (typeof name === 'string') {
|
|
@@ -19694,28 +19511,23 @@ const getNameHint = name => {
|
|
|
19694
19511
|
} else {
|
|
19695
19512
|
nameHint = " and name `" + name + "`";
|
|
19696
19513
|
}
|
|
19697
|
-
|
|
19698
19514
|
return nameHint;
|
|
19699
19515
|
};
|
|
19700
|
-
|
|
19701
19516
|
const getMultipleError$1 = function (c, role, _temp2) {
|
|
19702
19517
|
let {
|
|
19703
19518
|
name
|
|
19704
19519
|
} = _temp2 === void 0 ? {} : _temp2;
|
|
19705
19520
|
return "Found multiple elements with the role \"" + role + "\"" + getNameHint(name);
|
|
19706
19521
|
};
|
|
19707
|
-
|
|
19708
19522
|
const getMissingError$1 = function (container, role, _temp3) {
|
|
19709
19523
|
let {
|
|
19710
19524
|
hidden = getConfig().defaultHidden,
|
|
19711
19525
|
name,
|
|
19712
19526
|
description
|
|
19713
19527
|
} = _temp3 === void 0 ? {} : _temp3;
|
|
19714
|
-
|
|
19715
19528
|
if (getConfig()._disableExpensiveErrorDiagnostics) {
|
|
19716
19529
|
return "Unable to find role=\"" + role + "\"" + getNameHint(name);
|
|
19717
19530
|
}
|
|
19718
|
-
|
|
19719
19531
|
let roles = '';
|
|
19720
19532
|
Array.from(container.children).forEach(childElement => {
|
|
19721
19533
|
roles += prettyRoles(childElement, {
|
|
@@ -19724,7 +19536,6 @@ const getMissingError$1 = function (container, role, _temp3) {
|
|
|
19724
19536
|
});
|
|
19725
19537
|
});
|
|
19726
19538
|
let roleMessage;
|
|
19727
|
-
|
|
19728
19539
|
if (roles.length === 0) {
|
|
19729
19540
|
if (hidden === false) {
|
|
19730
19541
|
roleMessage = 'There are no accessible roles. But there might be some inaccessible roles. ' + 'If you wish to access them, then set the `hidden` option to `true`. ' + 'Learn more about this here: https://testing-library.com/docs/dom-testing-library/api-queries#byrole';
|
|
@@ -19734,9 +19545,7 @@ const getMissingError$1 = function (container, role, _temp3) {
|
|
|
19734
19545
|
} else {
|
|
19735
19546
|
roleMessage = ("\nHere are the " + (hidden === false ? 'accessible' : 'available') + " roles:\n\n " + roles.replace(/\n/g, '\n ').replace(/\n\s\s\n/g, '\n\n') + "\n").trim();
|
|
19736
19547
|
}
|
|
19737
|
-
|
|
19738
19548
|
let nameHint = '';
|
|
19739
|
-
|
|
19740
19549
|
if (name === undefined) {
|
|
19741
19550
|
nameHint = '';
|
|
19742
19551
|
} else if (typeof name === 'string') {
|
|
@@ -19744,9 +19553,7 @@ const getMissingError$1 = function (container, role, _temp3) {
|
|
|
19744
19553
|
} else {
|
|
19745
19554
|
nameHint = " and name `" + name + "`";
|
|
19746
19555
|
}
|
|
19747
|
-
|
|
19748
19556
|
let descriptionHint = '';
|
|
19749
|
-
|
|
19750
19557
|
if (description === undefined) {
|
|
19751
19558
|
descriptionHint = '';
|
|
19752
19559
|
} else if (typeof description === 'string') {
|
|
@@ -19754,28 +19561,21 @@ const getMissingError$1 = function (container, role, _temp3) {
|
|
|
19754
19561
|
} else {
|
|
19755
19562
|
descriptionHint = " and description `" + description + "`";
|
|
19756
19563
|
}
|
|
19757
|
-
|
|
19758
19564
|
return ("\nUnable to find an " + (hidden === false ? 'accessible ' : '') + "element with the role \"" + role + "\"" + nameHint + descriptionHint + "\n\n" + roleMessage).trim();
|
|
19759
19565
|
};
|
|
19760
|
-
|
|
19761
19566
|
const queryAllByRoleWithSuggestions = wrapAllByQueryWithSuggestion(queryAllByRole, queryAllByRole.name, 'queryAll');
|
|
19762
19567
|
const [queryByRole, getAllByRole, getByRole, findAllByRole, findByRole] = buildQueries(queryAllByRole, getMultipleError$1, getMissingError$1);
|
|
19763
19568
|
|
|
19764
19569
|
const getTestIdAttribute = () => getConfig().testIdAttribute;
|
|
19765
|
-
|
|
19766
19570
|
const queryAllByTestId = function () {
|
|
19767
19571
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
19768
19572
|
args[_key] = arguments[_key];
|
|
19769
19573
|
}
|
|
19770
|
-
|
|
19771
19574
|
checkContainerType$1(args[0]);
|
|
19772
19575
|
return queryAllByAttribute(getTestIdAttribute(), ...args);
|
|
19773
19576
|
};
|
|
19774
|
-
|
|
19775
19577
|
const getMultipleError = (c, id) => "Found multiple elements by: [" + getTestIdAttribute() + "=\"" + id + "\"]";
|
|
19776
|
-
|
|
19777
19578
|
const getMissingError = (c, id) => "Unable to find an element by: [" + getTestIdAttribute() + "=\"" + id + "\"]";
|
|
19778
|
-
|
|
19779
19579
|
const queryAllByTestIdWithSuggestions = wrapAllByQueryWithSuggestion(queryAllByTestId, queryAllByTestId.name, 'queryAll');
|
|
19780
19580
|
const [queryByTestId, getAllByTestId, getByTestId, findAllByTestId, findByTestId] = buildQueries(queryAllByTestId, getMultipleError, getMissingError);
|
|
19781
19581
|
|
|
@@ -19841,16 +19641,13 @@ var queries = /*#__PURE__*/Object.freeze({
|
|
|
19841
19641
|
* @param {Object} initialValue for reducer
|
|
19842
19642
|
* @returns {FuncMap} returns object of functions bound to container
|
|
19843
19643
|
*/
|
|
19844
|
-
|
|
19845
19644
|
function getQueriesForElement(element, queries$1, initialValue) {
|
|
19846
19645
|
if (queries$1 === void 0) {
|
|
19847
19646
|
queries$1 = queries;
|
|
19848
19647
|
}
|
|
19849
|
-
|
|
19850
19648
|
if (initialValue === void 0) {
|
|
19851
19649
|
initialValue = {};
|
|
19852
19650
|
}
|
|
19853
|
-
|
|
19854
19651
|
return Object.keys(queries$1).reduce((helpers, key) => {
|
|
19855
19652
|
const fn = queries$1[key];
|
|
19856
19653
|
helpers[key] = fn.bind(null, element);
|
|
@@ -19858,56 +19655,47 @@ function getQueriesForElement(element, queries$1, initialValue) {
|
|
|
19858
19655
|
}, initialValue);
|
|
19859
19656
|
}
|
|
19860
19657
|
|
|
19861
|
-
const isRemoved = result => !result || Array.isArray(result) && !result.length;
|
|
19862
|
-
// As the name implies, waitForElementToBeRemoved should check `present` --> `removed`
|
|
19863
|
-
|
|
19658
|
+
const isRemoved = result => !result || Array.isArray(result) && !result.length;
|
|
19864
19659
|
|
|
19660
|
+
// Check if the element is not present.
|
|
19661
|
+
// As the name implies, waitForElementToBeRemoved should check `present` --> `removed`
|
|
19865
19662
|
function initialCheck(elements) {
|
|
19866
19663
|
if (isRemoved(elements)) {
|
|
19867
19664
|
throw new Error('The element(s) given to waitForElementToBeRemoved are already removed. waitForElementToBeRemoved requires that the element(s) exist(s) before waiting for removal.');
|
|
19868
19665
|
}
|
|
19869
19666
|
}
|
|
19870
|
-
|
|
19871
19667
|
async function waitForElementToBeRemoved(callback, options) {
|
|
19872
19668
|
// created here so we get a nice stacktrace
|
|
19873
19669
|
const timeoutError = new Error('Timed out in waitForElementToBeRemoved.');
|
|
19874
|
-
|
|
19875
19670
|
if (typeof callback !== 'function') {
|
|
19876
19671
|
initialCheck(callback);
|
|
19877
19672
|
const elements = Array.isArray(callback) ? callback : [callback];
|
|
19878
19673
|
const getRemainingElements = elements.map(element => {
|
|
19879
19674
|
let parent = element.parentElement;
|
|
19880
19675
|
if (parent === null) return () => null;
|
|
19881
|
-
|
|
19882
19676
|
while (parent.parentElement) parent = parent.parentElement;
|
|
19883
|
-
|
|
19884
19677
|
return () => parent.contains(element) ? element : null;
|
|
19885
19678
|
});
|
|
19886
|
-
|
|
19887
19679
|
callback = () => getRemainingElements.map(c => c()).filter(Boolean);
|
|
19888
19680
|
}
|
|
19889
|
-
|
|
19890
19681
|
initialCheck(callback());
|
|
19891
19682
|
return waitForWrapper(() => {
|
|
19892
19683
|
let result;
|
|
19893
|
-
|
|
19894
19684
|
try {
|
|
19895
19685
|
result = callback();
|
|
19896
19686
|
} catch (error) {
|
|
19897
19687
|
if (error.name === 'TestingLibraryElementError') {
|
|
19898
19688
|
return undefined;
|
|
19899
19689
|
}
|
|
19900
|
-
|
|
19901
19690
|
throw error;
|
|
19902
19691
|
}
|
|
19903
|
-
|
|
19904
19692
|
if (!isRemoved(result)) {
|
|
19905
19693
|
throw timeoutError;
|
|
19906
19694
|
}
|
|
19907
|
-
|
|
19908
19695
|
return undefined;
|
|
19909
19696
|
}, options);
|
|
19910
19697
|
}
|
|
19698
|
+
|
|
19911
19699
|
/*
|
|
19912
19700
|
eslint
|
|
19913
19701
|
require-await: "off"
|
|
@@ -20431,7 +20219,7 @@ const eventMap = {
|
|
|
20431
20219
|
// Events
|
|
20432
20220
|
load: {
|
|
20433
20221
|
// TODO: load events can be UIEvent or Event depending on what generated them
|
|
20434
|
-
// This is
|
|
20222
|
+
// This is where this abstraction breaks down.
|
|
20435
20223
|
// But the common targets are <img />, <script /> and window.
|
|
20436
20224
|
// Neither of these targets receive a UIEvent
|
|
20437
20225
|
EventType: 'Event',
|
|
@@ -20584,6 +20372,21 @@ const eventMap = {
|
|
|
20584
20372
|
bubbles: true,
|
|
20585
20373
|
cancelable: false
|
|
20586
20374
|
}
|
|
20375
|
+
},
|
|
20376
|
+
// window events
|
|
20377
|
+
offline: {
|
|
20378
|
+
EventType: 'Event',
|
|
20379
|
+
defaultInit: {
|
|
20380
|
+
bubbles: false,
|
|
20381
|
+
cancelable: false
|
|
20382
|
+
}
|
|
20383
|
+
},
|
|
20384
|
+
online: {
|
|
20385
|
+
EventType: 'Event',
|
|
20386
|
+
defaultInit: {
|
|
20387
|
+
bubbles: false,
|
|
20388
|
+
cancelable: false
|
|
20389
|
+
}
|
|
20587
20390
|
}
|
|
20588
20391
|
};
|
|
20589
20392
|
const eventAliasMap = {
|
|
@@ -20595,26 +20398,22 @@ function fireEvent(element, event) {
|
|
|
20595
20398
|
if (!event) {
|
|
20596
20399
|
throw new Error("Unable to fire an event - please provide an event object.");
|
|
20597
20400
|
}
|
|
20598
|
-
|
|
20599
20401
|
if (!element) {
|
|
20600
20402
|
throw new Error("Unable to fire a \"" + event.type + "\" event - please provide a DOM element.");
|
|
20601
20403
|
}
|
|
20602
|
-
|
|
20603
20404
|
return element.dispatchEvent(event);
|
|
20604
20405
|
});
|
|
20605
20406
|
}
|
|
20606
|
-
|
|
20607
20407
|
function createEvent(eventName, node, init, _temp) {
|
|
20608
20408
|
let {
|
|
20609
20409
|
EventType = 'Event',
|
|
20610
20410
|
defaultInit = {}
|
|
20611
20411
|
} = _temp === void 0 ? {} : _temp;
|
|
20612
|
-
|
|
20613
20412
|
if (!node) {
|
|
20614
20413
|
throw new Error("Unable to fire a \"" + eventName + "\" event - please provide a DOM element.");
|
|
20615
20414
|
}
|
|
20616
|
-
|
|
20617
|
-
|
|
20415
|
+
const eventInit = {
|
|
20416
|
+
...defaultInit,
|
|
20618
20417
|
...init
|
|
20619
20418
|
};
|
|
20620
20419
|
const {
|
|
@@ -20624,11 +20423,9 @@ function createEvent(eventName, node, init, _temp) {
|
|
|
20624
20423
|
...targetProperties
|
|
20625
20424
|
} = {}
|
|
20626
20425
|
} = eventInit;
|
|
20627
|
-
|
|
20628
20426
|
if (value !== undefined) {
|
|
20629
20427
|
setNativeValue(node, value);
|
|
20630
20428
|
}
|
|
20631
|
-
|
|
20632
20429
|
if (files !== undefined) {
|
|
20633
20430
|
// input.files is a read-only property so this is not allowed:
|
|
20634
20431
|
// input.files = [file]
|
|
@@ -20640,13 +20437,11 @@ function createEvent(eventName, node, init, _temp) {
|
|
|
20640
20437
|
value: files
|
|
20641
20438
|
});
|
|
20642
20439
|
}
|
|
20643
|
-
|
|
20644
20440
|
Object.assign(node, targetProperties);
|
|
20645
20441
|
const window = getWindowFromNode$1(node);
|
|
20646
20442
|
const EventConstructor = window[EventType] || window.Event;
|
|
20647
20443
|
let event;
|
|
20648
20444
|
/* istanbul ignore else */
|
|
20649
|
-
|
|
20650
20445
|
if (typeof EventConstructor === 'function') {
|
|
20651
20446
|
event = new EventConstructor(eventName, eventInit);
|
|
20652
20447
|
} else {
|
|
@@ -20662,13 +20457,12 @@ function createEvent(eventName, node, init, _temp) {
|
|
|
20662
20457
|
Object.keys(otherInit).forEach(eventKey => {
|
|
20663
20458
|
event[eventKey] = otherInit[eventKey];
|
|
20664
20459
|
});
|
|
20665
|
-
}
|
|
20666
|
-
|
|
20460
|
+
}
|
|
20667
20461
|
|
|
20462
|
+
// DataTransfer is not supported in jsdom: https://github.com/jsdom/jsdom/issues/1568
|
|
20668
20463
|
const dataTransferProperties = ['dataTransfer', 'clipboardData'];
|
|
20669
20464
|
dataTransferProperties.forEach(dataTransferKey => {
|
|
20670
20465
|
const dataTransferValue = eventInit[dataTransferKey];
|
|
20671
|
-
|
|
20672
20466
|
if (typeof dataTransferValue === 'object') {
|
|
20673
20467
|
/* istanbul ignore if */
|
|
20674
20468
|
if (typeof window.DataTransfer === 'function') {
|
|
@@ -20689,23 +20483,21 @@ function createEvent(eventName, node, init, _temp) {
|
|
|
20689
20483
|
});
|
|
20690
20484
|
return event;
|
|
20691
20485
|
}
|
|
20692
|
-
|
|
20693
20486
|
Object.keys(eventMap).forEach(key => {
|
|
20694
20487
|
const {
|
|
20695
20488
|
EventType,
|
|
20696
20489
|
defaultInit
|
|
20697
20490
|
} = eventMap[key];
|
|
20698
20491
|
const eventName = key.toLowerCase();
|
|
20699
|
-
|
|
20700
20492
|
createEvent[key] = (node, init) => createEvent(eventName, node, init, {
|
|
20701
20493
|
EventType,
|
|
20702
20494
|
defaultInit
|
|
20703
20495
|
});
|
|
20704
|
-
|
|
20705
20496
|
fireEvent[key] = (node, init) => fireEvent(node, createEvent[key](node, init));
|
|
20706
|
-
});
|
|
20707
|
-
// https://github.com/facebook/react/issues/10135#issuecomment-401496776
|
|
20497
|
+
});
|
|
20708
20498
|
|
|
20499
|
+
// function written after some investigation here:
|
|
20500
|
+
// https://github.com/facebook/react/issues/10135#issuecomment-401496776
|
|
20709
20501
|
function setNativeValue(element, value) {
|
|
20710
20502
|
const {
|
|
20711
20503
|
set: valueSetter
|
|
@@ -20714,7 +20506,6 @@ function setNativeValue(element, value) {
|
|
|
20714
20506
|
const {
|
|
20715
20507
|
set: prototypeValueSetter
|
|
20716
20508
|
} = Object.getOwnPropertyDescriptor(prototype, 'value') || {};
|
|
20717
|
-
|
|
20718
20509
|
if (prototypeValueSetter && valueSetter !== prototypeValueSetter) {
|
|
20719
20510
|
prototypeValueSetter.call(element, value);
|
|
20720
20511
|
} else {
|
|
@@ -20727,56 +20518,46 @@ function setNativeValue(element, value) {
|
|
|
20727
20518
|
}
|
|
20728
20519
|
}
|
|
20729
20520
|
}
|
|
20730
|
-
|
|
20731
20521
|
Object.keys(eventAliasMap).forEach(aliasKey => {
|
|
20732
20522
|
const key = eventAliasMap[aliasKey];
|
|
20733
|
-
|
|
20734
20523
|
fireEvent[aliasKey] = function () {
|
|
20735
20524
|
return fireEvent[key](...arguments);
|
|
20736
20525
|
};
|
|
20737
20526
|
});
|
|
20527
|
+
|
|
20738
20528
|
/* eslint complexity:["error", 9] */
|
|
20739
20529
|
|
|
20740
20530
|
// WARNING: `lz-string` only has a default export but statically we assume named exports are allowd
|
|
20741
|
-
|
|
20742
20531
|
function unindent(string) {
|
|
20743
20532
|
// remove white spaces first, to save a few bytes.
|
|
20744
20533
|
// testing-playground will reformat on load any ways.
|
|
20745
20534
|
return string.replace(/[ \t]*[\n][ \t]*/g, '\n');
|
|
20746
20535
|
}
|
|
20747
|
-
|
|
20748
20536
|
function encode(value) {
|
|
20749
20537
|
return lzString.compressToEncodedURIComponent(unindent(value));
|
|
20750
20538
|
}
|
|
20751
|
-
|
|
20752
20539
|
function getPlaygroundUrl(markup) {
|
|
20753
20540
|
return "https://testing-playground.com/#markup=" + encode(markup);
|
|
20754
20541
|
}
|
|
20755
|
-
|
|
20756
20542
|
const debug = (element, maxLength, options) => Array.isArray(element) ? element.forEach(el => logDOM(el, maxLength, options)) : logDOM(element, maxLength, options);
|
|
20757
|
-
|
|
20758
20543
|
const logTestingPlaygroundURL = function (element) {
|
|
20759
20544
|
if (element === void 0) {
|
|
20760
20545
|
element = getDocument$1().body;
|
|
20761
20546
|
}
|
|
20762
|
-
|
|
20763
20547
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
20764
20548
|
if (!element || !('innerHTML' in element)) {
|
|
20765
20549
|
console.log("The element you're providing isn't a valid DOM element.");
|
|
20766
20550
|
return;
|
|
20767
|
-
}
|
|
20768
|
-
|
|
20769
|
-
|
|
20551
|
+
}
|
|
20552
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
20770
20553
|
if (!element.innerHTML) {
|
|
20771
20554
|
console.log("The provided element doesn't have any children.");
|
|
20772
20555
|
return;
|
|
20773
20556
|
}
|
|
20774
|
-
|
|
20775
20557
|
const playgroundUrl = getPlaygroundUrl(element.innerHTML);
|
|
20776
20558
|
console.log("Open this URL in your browser\n\n" + playgroundUrl);
|
|
20777
20559
|
return playgroundUrl;
|
|
20778
20560
|
};
|
|
20779
|
-
|
|
20780
20561
|
const initialValue = {
|
|
20781
20562
|
debug,
|
|
20782
20563
|
logTestingPlaygroundURL
|
|
@@ -20789,13 +20570,11 @@ const screen = typeof document !== 'undefined' && document.body // eslint-disabl
|
|
|
20789
20570
|
helpers[key] = () => {
|
|
20790
20571
|
throw new TypeError('For queries bound to document.body a global document has to be available... Learn more: https://testing-library.com/s/screen-global-error');
|
|
20791
20572
|
};
|
|
20792
|
-
|
|
20793
20573
|
return helpers;
|
|
20794
20574
|
}, initialValue);
|
|
20795
20575
|
|
|
20796
20576
|
var dom_esm = /*#__PURE__*/Object.freeze({
|
|
20797
20577
|
__proto__: null,
|
|
20798
|
-
prettyFormat: index,
|
|
20799
20578
|
buildQueries: buildQueries,
|
|
20800
20579
|
configure: configure,
|
|
20801
20580
|
createEvent: createEvent,
|
|
@@ -20847,6 +20626,7 @@ var dom_esm = /*#__PURE__*/Object.freeze({
|
|
|
20847
20626
|
makeGetAllQuery: makeGetAllQuery,
|
|
20848
20627
|
makeSingleQuery: makeSingleQuery,
|
|
20849
20628
|
prettyDOM: prettyDOM,
|
|
20629
|
+
prettyFormat: index,
|
|
20850
20630
|
queries: queries,
|
|
20851
20631
|
queryAllByAltText: queryAllByAltTextWithSuggestions,
|
|
20852
20632
|
queryAllByAttribute: queryAllByAttribute,
|
|
@@ -21738,30 +21518,27 @@ helpers.jestFakeTimersAreEnabled = jestFakeTimersAreEnabled;
|
|
|
21738
21518
|
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType#Node_type_constants
|
|
21739
21519
|
const TEXT_NODE = 3;
|
|
21740
21520
|
helpers.TEXT_NODE = TEXT_NODE;
|
|
21741
|
-
|
|
21742
21521
|
function jestFakeTimersAreEnabled() {
|
|
21743
21522
|
/* istanbul ignore else */
|
|
21744
21523
|
// eslint-disable-next-line
|
|
21745
21524
|
if (typeof jest !== 'undefined' && jest !== null) {
|
|
21746
|
-
return (
|
|
21747
|
-
|
|
21525
|
+
return (
|
|
21526
|
+
// legacy timers
|
|
21527
|
+
setTimeout._isMockFunction === true ||
|
|
21528
|
+
// modern timers
|
|
21748
21529
|
Object.prototype.hasOwnProperty.call(setTimeout, 'clock')
|
|
21749
21530
|
);
|
|
21750
|
-
}
|
|
21751
|
-
|
|
21752
|
-
|
|
21531
|
+
}
|
|
21532
|
+
// istanbul ignore next
|
|
21753
21533
|
return false;
|
|
21754
21534
|
}
|
|
21755
|
-
|
|
21756
21535
|
function getDocument() {
|
|
21757
21536
|
/* istanbul ignore if */
|
|
21758
21537
|
if (typeof window === 'undefined') {
|
|
21759
21538
|
throw new Error('Could not find default container');
|
|
21760
21539
|
}
|
|
21761
|
-
|
|
21762
21540
|
return window.document;
|
|
21763
21541
|
}
|
|
21764
|
-
|
|
21765
21542
|
function getWindowFromNode(node) {
|
|
21766
21543
|
if (node.defaultView) {
|
|
21767
21544
|
// node is document
|
|
@@ -21785,17 +21562,14 @@ function getWindowFromNode(node) {
|
|
|
21785
21562
|
throw new Error(`The given node is not an Element, the node type is: ${typeof node}.`);
|
|
21786
21563
|
}
|
|
21787
21564
|
}
|
|
21788
|
-
|
|
21789
21565
|
function checkContainerType(container) {
|
|
21790
21566
|
if (!container || !(typeof container.querySelector === 'function') || !(typeof container.querySelectorAll === 'function')) {
|
|
21791
21567
|
throw new TypeError(`Expected container to be an Element, a Document or a DocumentFragment but got ${getTypeName(container)}.`);
|
|
21792
21568
|
}
|
|
21793
|
-
|
|
21794
21569
|
function getTypeName(object) {
|
|
21795
21570
|
if (typeof object === 'object') {
|
|
21796
21571
|
return object === null ? 'null' : object.constructor.name;
|
|
21797
21572
|
}
|
|
21798
|
-
|
|
21799
21573
|
return typeof object;
|
|
21800
21574
|
}
|
|
21801
21575
|
}
|
|
@@ -24828,6 +24602,7 @@ var clickMenuOption = function (menuOptionText) { return __awaiter(void 0, void
|
|
|
24828
24602
|
case 0: return [4 /*yield*/, findMenuOption(menuOptionText)];
|
|
24829
24603
|
case 1:
|
|
24830
24604
|
menuOption = _a.sent();
|
|
24605
|
+
// eslint-disable-next-line testing-library/await-async-utils
|
|
24831
24606
|
userEvent.click(menuOption);
|
|
24832
24607
|
return [2 /*return*/];
|
|
24833
24608
|
}
|