@react-aria/tag 3.0.0-rc.0 → 3.1.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/dist/import.mjs +91 -117
- package/dist/main.js +88 -115
- package/dist/main.js.map +1 -1
- package/dist/module.js +91 -117
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +35 -39
- package/dist/types.d.ts.map +1 -1
- package/package.json +12 -13
- package/src/index.ts +0 -2
- package/src/useTag.ts +39 -36
- package/src/useTagGroup.ts +51 -16
- package/src/TagKeyboardDelegate.ts +0 -79
package/dist/import.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {useId as $aIvin$useId,
|
|
1
|
+
import {useId as $aIvin$useId, useDescription as $aIvin$useDescription, filterDOMProps as $aIvin$filterDOMProps, mergeProps as $aIvin$mergeProps} from "@react-aria/utils";
|
|
2
2
|
import {useGridListItem as $aIvin$useGridListItem, useGridList as $aIvin$useGridList} from "@react-aria/gridlist";
|
|
3
3
|
import {useInteractionModality as $aIvin$useInteractionModality, useFocusWithin as $aIvin$useFocusWithin} from "@react-aria/interactions";
|
|
4
4
|
import {useLocalizedStringFormatter as $aIvin$useLocalizedStringFormatter, useLocale as $aIvin$useLocale} from "@react-aria/i18n";
|
|
5
|
-
import {useState as $aIvin$useState} from "react";
|
|
5
|
+
import {useState as $aIvin$useState, useRef as $aIvin$useRef, useEffect as $aIvin$useEffect} from "react";
|
|
6
|
+
import {ListKeyboardDelegate as $aIvin$ListKeyboardDelegate} from "@react-aria/selection";
|
|
6
7
|
import {useField as $aIvin$useField} from "@react-aria/label";
|
|
7
8
|
|
|
8
9
|
function $parcel$interopDefault(a) {
|
|
@@ -28,48 +29,7 @@ function $parcel$interopDefault(a) {
|
|
|
28
29
|
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
29
30
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
30
31
|
* governing permissions and limitations under the License.
|
|
31
|
-
*/
|
|
32
|
-
getFirstKey() {
|
|
33
|
-
return this.collection.getFirstKey();
|
|
34
|
-
}
|
|
35
|
-
getLastKey() {
|
|
36
|
-
return this.collection.getLastKey();
|
|
37
|
-
}
|
|
38
|
-
getKeyRightOf(key) {
|
|
39
|
-
return this.direction === "rtl" ? this.getKeyAbove(key) : this.getKeyBelow(key);
|
|
40
|
-
}
|
|
41
|
-
getKeyLeftOf(key) {
|
|
42
|
-
return this.direction === "rtl" ? this.getKeyBelow(key) : this.getKeyAbove(key);
|
|
43
|
-
}
|
|
44
|
-
getKeyBelow(key) {
|
|
45
|
-
let startItem = this.collection.getItem(key);
|
|
46
|
-
if (!startItem) return;
|
|
47
|
-
// Find the next item
|
|
48
|
-
key = this.collection.getKeyAfter(key);
|
|
49
|
-
if (key != null) return key;
|
|
50
|
-
else return this.collection.getFirstKey();
|
|
51
|
-
}
|
|
52
|
-
getKeyAbove(key) {
|
|
53
|
-
let startItem = this.collection.getItem(key);
|
|
54
|
-
if (!startItem) return;
|
|
55
|
-
// Find the previous item
|
|
56
|
-
key = this.collection.getKeyBefore(key);
|
|
57
|
-
if (key != null) return key;
|
|
58
|
-
else return this.collection.getLastKey();
|
|
59
|
-
}
|
|
60
|
-
getKeyPageAbove(key) {
|
|
61
|
-
return this.getKeyAbove(key);
|
|
62
|
-
}
|
|
63
|
-
getKeyPageBelow(key) {
|
|
64
|
-
return this.getKeyBelow(key);
|
|
65
|
-
}
|
|
66
|
-
constructor(collection, direction){
|
|
67
|
-
this.collection = collection;
|
|
68
|
-
this.direction = direction;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
32
|
+
*/
|
|
73
33
|
/*
|
|
74
34
|
* Copyright 2020 Adobe. All rights reserved.
|
|
75
35
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -81,7 +41,67 @@ function $parcel$interopDefault(a) {
|
|
|
81
41
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
82
42
|
* governing permissions and limitations under the License.
|
|
83
43
|
*/
|
|
84
|
-
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
const $d7323bca8d074eeb$export$653eddfc964b0f8a = new WeakMap();
|
|
51
|
+
function $d7323bca8d074eeb$export$4f8b5cda58b7e8ff(props, state, ref) {
|
|
52
|
+
let { direction: direction } = (0, $aIvin$useLocale)();
|
|
53
|
+
let keyboardDelegate = props.keyboardDelegate || new (0, $aIvin$ListKeyboardDelegate)({
|
|
54
|
+
collection: state.collection,
|
|
55
|
+
ref: ref,
|
|
56
|
+
orientation: "horizontal",
|
|
57
|
+
direction: direction,
|
|
58
|
+
disabledKeys: state.disabledKeys
|
|
59
|
+
});
|
|
60
|
+
let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $aIvin$useField)({
|
|
61
|
+
...props,
|
|
62
|
+
labelElementType: "span"
|
|
63
|
+
});
|
|
64
|
+
let { gridProps: gridProps } = (0, $aIvin$useGridList)({
|
|
65
|
+
...props,
|
|
66
|
+
...fieldProps,
|
|
67
|
+
keyboardDelegate: keyboardDelegate,
|
|
68
|
+
shouldFocusWrap: true
|
|
69
|
+
}, state, ref);
|
|
70
|
+
let [isFocusWithin, setFocusWithin] = (0, $aIvin$useState)(false);
|
|
71
|
+
let { focusWithinProps: focusWithinProps } = (0, $aIvin$useFocusWithin)({
|
|
72
|
+
onFocusWithinChange: setFocusWithin
|
|
73
|
+
});
|
|
74
|
+
let domProps = (0, $aIvin$filterDOMProps)(props);
|
|
75
|
+
// If the last tag is removed, focus the container.
|
|
76
|
+
let prevCount = (0, $aIvin$useRef)(state.collection.size);
|
|
77
|
+
(0, $aIvin$useEffect)(()=>{
|
|
78
|
+
if (prevCount.current > 0 && state.collection.size === 0 && isFocusWithin) ref.current.focus();
|
|
79
|
+
prevCount.current = state.collection.size;
|
|
80
|
+
}, [
|
|
81
|
+
state.collection.size,
|
|
82
|
+
isFocusWithin,
|
|
83
|
+
ref
|
|
84
|
+
]);
|
|
85
|
+
$d7323bca8d074eeb$export$653eddfc964b0f8a.set(state, {
|
|
86
|
+
onRemove: props.onRemove
|
|
87
|
+
});
|
|
88
|
+
return {
|
|
89
|
+
gridProps: (0, $aIvin$mergeProps)(gridProps, domProps, {
|
|
90
|
+
role: state.collection.size ? "grid" : null,
|
|
91
|
+
"aria-atomic": false,
|
|
92
|
+
"aria-relevant": "additions",
|
|
93
|
+
"aria-live": isFocusWithin ? "polite" : "off",
|
|
94
|
+
...focusWithinProps,
|
|
95
|
+
...fieldProps
|
|
96
|
+
}),
|
|
97
|
+
labelProps: labelProps,
|
|
98
|
+
descriptionProps: descriptionProps,
|
|
99
|
+
errorMessageProps: errorMessageProps
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
var $3bb15cc24d006ec5$exports = {};
|
|
85
105
|
var $84925f526f90eebd$exports = {};
|
|
86
106
|
$84925f526f90eebd$exports = {
|
|
87
107
|
"removeButtonLabel": `إزالة`,
|
|
@@ -320,7 +340,7 @@ $09cd168ab18773f4$exports = {
|
|
|
320
340
|
};
|
|
321
341
|
|
|
322
342
|
|
|
323
|
-
$
|
|
343
|
+
$3bb15cc24d006ec5$exports = {
|
|
324
344
|
"ar-AE": $84925f526f90eebd$exports,
|
|
325
345
|
"bg-BG": $c0650163dc1b6f9d$exports,
|
|
326
346
|
"cs-CZ": $b2b55661291de587$exports,
|
|
@@ -362,105 +382,59 @@ $4d1b62e0e67c00a4$exports = {
|
|
|
362
382
|
|
|
363
383
|
|
|
364
384
|
function $fc6126c82a4601f1$export$3f568fff7dff2f03(props, state, ref) {
|
|
365
|
-
let {
|
|
366
|
-
let stringFormatter = (0, $aIvin$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($
|
|
367
|
-
let labelId = (0, $aIvin$useId)();
|
|
385
|
+
let { item: item } = props;
|
|
386
|
+
let stringFormatter = (0, $aIvin$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($3bb15cc24d006ec5$exports))));
|
|
368
387
|
let buttonId = (0, $aIvin$useId)();
|
|
369
|
-
let {
|
|
388
|
+
let { onRemove: onRemove } = (0, $d7323bca8d074eeb$export$653eddfc964b0f8a).get(state) || {};
|
|
389
|
+
let { rowProps: rowProps , gridCellProps: gridCellProps , ...states } = (0, $aIvin$useGridListItem)({
|
|
370
390
|
node: item
|
|
371
391
|
}, state, ref);
|
|
372
392
|
// We want the group to handle keyboard navigation between tags.
|
|
373
393
|
delete rowProps.onKeyDownCapture;
|
|
374
|
-
|
|
394
|
+
delete states.descriptionProps;
|
|
375
395
|
let onKeyDown = (e)=>{
|
|
376
396
|
if (e.key === "Delete" || e.key === "Backspace") {
|
|
377
|
-
onRemove(item.key);
|
|
378
397
|
e.preventDefault();
|
|
398
|
+
if (state.selectionManager.isSelected(item.key)) onRemove(new Set(state.selectionManager.selectedKeys));
|
|
399
|
+
else onRemove(new Set([
|
|
400
|
+
item.key
|
|
401
|
+
]));
|
|
379
402
|
}
|
|
380
403
|
};
|
|
381
404
|
let modality = (0, $aIvin$useInteractionModality)();
|
|
382
405
|
if (modality === "virtual" && typeof window !== "undefined" && "ontouchstart" in window) modality = "touch";
|
|
383
|
-
let description =
|
|
406
|
+
let description = onRemove && (modality === "keyboard" || modality === "virtual") ? stringFormatter.format("removeDescription") : "";
|
|
384
407
|
let descProps = (0, $aIvin$useDescription)(description);
|
|
385
|
-
let domProps = (0, $aIvin$filterDOMProps)(props);
|
|
386
408
|
let isFocused = item.key === state.selectionManager.focusedKey;
|
|
409
|
+
// @ts-ignore - data attributes are ok but TS doesn't know about them.
|
|
410
|
+
let domProps = (0, $aIvin$filterDOMProps)(props);
|
|
387
411
|
return {
|
|
388
412
|
removeButtonProps: {
|
|
389
|
-
"aria-label": stringFormatter.format("removeButtonLabel",
|
|
390
|
-
|
|
391
|
-
}),
|
|
392
|
-
"aria-labelledby": `${buttonId} ${labelId}`,
|
|
413
|
+
"aria-label": stringFormatter.format("removeButtonLabel"),
|
|
414
|
+
"aria-labelledby": `${buttonId} ${rowProps.id}`,
|
|
393
415
|
id: buttonId,
|
|
394
|
-
onPress: ()=>
|
|
416
|
+
onPress: ()=>onRemove ? onRemove(new Set([
|
|
417
|
+
item.key
|
|
418
|
+
])) : null,
|
|
395
419
|
excludeFromTabOrder: true
|
|
396
420
|
},
|
|
397
|
-
|
|
398
|
-
id: labelId
|
|
399
|
-
},
|
|
400
|
-
rowProps: {
|
|
401
|
-
...rowProps,
|
|
421
|
+
rowProps: (0, $aIvin$mergeProps)(rowProps, domProps, {
|
|
402
422
|
tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,
|
|
403
|
-
onKeyDown:
|
|
423
|
+
onKeyDown: onRemove ? onKeyDown : undefined,
|
|
404
424
|
"aria-describedby": descProps["aria-describedby"]
|
|
405
|
-
},
|
|
406
|
-
gridCellProps: (0, $aIvin$mergeProps)(
|
|
425
|
+
}),
|
|
426
|
+
gridCellProps: (0, $aIvin$mergeProps)(gridCellProps, {
|
|
407
427
|
"aria-errormessage": props["aria-errormessage"],
|
|
408
428
|
"aria-label": props["aria-label"]
|
|
409
|
-
})
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
/*
|
|
415
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
416
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
417
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
418
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
419
|
-
*
|
|
420
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
421
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
422
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
423
|
-
* governing permissions and limitations under the License.
|
|
424
|
-
*/
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
function $d7323bca8d074eeb$export$4f8b5cda58b7e8ff(props, state, ref) {
|
|
432
|
-
let { direction: direction } = (0, $aIvin$useLocale)();
|
|
433
|
-
let keyboardDelegate = props.keyboardDelegate || new (0, $542448901dbd2c36$export$b00754732e683b92)(state.collection, direction);
|
|
434
|
-
let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $aIvin$useField)(props);
|
|
435
|
-
let { gridProps: gridProps } = (0, $aIvin$useGridList)({
|
|
436
|
-
...props,
|
|
437
|
-
...fieldProps,
|
|
438
|
-
keyboardDelegate: keyboardDelegate
|
|
439
|
-
}, state, ref);
|
|
440
|
-
// Don't want the grid to be focusable or accessible via keyboard
|
|
441
|
-
delete gridProps.tabIndex;
|
|
442
|
-
let [isFocusWithin, setFocusWithin] = (0, $aIvin$useState)(false);
|
|
443
|
-
let { focusWithinProps: focusWithinProps } = (0, $aIvin$useFocusWithin)({
|
|
444
|
-
onFocusWithinChange: setFocusWithin
|
|
445
|
-
});
|
|
446
|
-
let domProps = (0, $aIvin$filterDOMProps)(props);
|
|
447
|
-
return {
|
|
448
|
-
gridProps: (0, $aIvin$mergeProps)(gridProps, domProps, {
|
|
449
|
-
role: state.collection.size ? "grid" : null,
|
|
450
|
-
"aria-atomic": false,
|
|
451
|
-
"aria-relevant": "additions",
|
|
452
|
-
"aria-live": isFocusWithin ? "polite" : "off",
|
|
453
|
-
...focusWithinProps,
|
|
454
|
-
...fieldProps
|
|
455
429
|
}),
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
errorMessageProps: errorMessageProps
|
|
430
|
+
...states,
|
|
431
|
+
allowsRemoving: !!onRemove
|
|
459
432
|
};
|
|
460
433
|
}
|
|
461
434
|
|
|
462
435
|
|
|
463
436
|
|
|
464
437
|
|
|
465
|
-
|
|
438
|
+
|
|
439
|
+
export {$fc6126c82a4601f1$export$3f568fff7dff2f03 as useTag, $d7323bca8d074eeb$export$4f8b5cda58b7e8ff as useTagGroup};
|
|
466
440
|
//# sourceMappingURL=module.js.map
|
package/dist/main.js
CHANGED
|
@@ -3,6 +3,7 @@ var $bSzeT$reactariagridlist = require("@react-aria/gridlist");
|
|
|
3
3
|
var $bSzeT$reactariainteractions = require("@react-aria/interactions");
|
|
4
4
|
var $bSzeT$reactariai18n = require("@react-aria/i18n");
|
|
5
5
|
var $bSzeT$react = require("react");
|
|
6
|
+
var $bSzeT$reactariaselection = require("@react-aria/selection");
|
|
6
7
|
var $bSzeT$reactarialabel = require("@react-aria/label");
|
|
7
8
|
|
|
8
9
|
function $parcel$export(e, n, v, s) {
|
|
@@ -12,7 +13,6 @@ function $parcel$interopDefault(a) {
|
|
|
12
13
|
return a && a.__esModule ? a.default : a;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
$parcel$export(module.exports, "TagKeyboardDelegate", () => $d3d7c73f2e3f4edb$export$b00754732e683b92);
|
|
16
16
|
$parcel$export(module.exports, "useTag", () => $a442534c81d8ad16$export$3f568fff7dff2f03);
|
|
17
17
|
$parcel$export(module.exports, "useTagGroup", () => $09704b0efefe5140$export$4f8b5cda58b7e8ff);
|
|
18
18
|
/*
|
|
@@ -35,48 +35,7 @@ $parcel$export(module.exports, "useTagGroup", () => $09704b0efefe5140$export$4f8
|
|
|
35
35
|
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
36
36
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
37
37
|
* governing permissions and limitations under the License.
|
|
38
|
-
*/
|
|
39
|
-
getFirstKey() {
|
|
40
|
-
return this.collection.getFirstKey();
|
|
41
|
-
}
|
|
42
|
-
getLastKey() {
|
|
43
|
-
return this.collection.getLastKey();
|
|
44
|
-
}
|
|
45
|
-
getKeyRightOf(key) {
|
|
46
|
-
return this.direction === "rtl" ? this.getKeyAbove(key) : this.getKeyBelow(key);
|
|
47
|
-
}
|
|
48
|
-
getKeyLeftOf(key) {
|
|
49
|
-
return this.direction === "rtl" ? this.getKeyBelow(key) : this.getKeyAbove(key);
|
|
50
|
-
}
|
|
51
|
-
getKeyBelow(key) {
|
|
52
|
-
let startItem = this.collection.getItem(key);
|
|
53
|
-
if (!startItem) return;
|
|
54
|
-
// Find the next item
|
|
55
|
-
key = this.collection.getKeyAfter(key);
|
|
56
|
-
if (key != null) return key;
|
|
57
|
-
else return this.collection.getFirstKey();
|
|
58
|
-
}
|
|
59
|
-
getKeyAbove(key) {
|
|
60
|
-
let startItem = this.collection.getItem(key);
|
|
61
|
-
if (!startItem) return;
|
|
62
|
-
// Find the previous item
|
|
63
|
-
key = this.collection.getKeyBefore(key);
|
|
64
|
-
if (key != null) return key;
|
|
65
|
-
else return this.collection.getLastKey();
|
|
66
|
-
}
|
|
67
|
-
getKeyPageAbove(key) {
|
|
68
|
-
return this.getKeyAbove(key);
|
|
69
|
-
}
|
|
70
|
-
getKeyPageBelow(key) {
|
|
71
|
-
return this.getKeyBelow(key);
|
|
72
|
-
}
|
|
73
|
-
constructor(collection, direction){
|
|
74
|
-
this.collection = collection;
|
|
75
|
-
this.direction = direction;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
38
|
+
*/
|
|
80
39
|
/*
|
|
81
40
|
* Copyright 2020 Adobe. All rights reserved.
|
|
82
41
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -88,7 +47,67 @@ $parcel$export(module.exports, "useTagGroup", () => $09704b0efefe5140$export$4f8
|
|
|
88
47
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
89
48
|
* governing permissions and limitations under the License.
|
|
90
49
|
*/
|
|
91
|
-
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
const $09704b0efefe5140$export$653eddfc964b0f8a = new WeakMap();
|
|
57
|
+
function $09704b0efefe5140$export$4f8b5cda58b7e8ff(props, state, ref) {
|
|
58
|
+
let { direction: direction } = (0, $bSzeT$reactariai18n.useLocale)();
|
|
59
|
+
let keyboardDelegate = props.keyboardDelegate || new (0, $bSzeT$reactariaselection.ListKeyboardDelegate)({
|
|
60
|
+
collection: state.collection,
|
|
61
|
+
ref: ref,
|
|
62
|
+
orientation: "horizontal",
|
|
63
|
+
direction: direction,
|
|
64
|
+
disabledKeys: state.disabledKeys
|
|
65
|
+
});
|
|
66
|
+
let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $bSzeT$reactarialabel.useField)({
|
|
67
|
+
...props,
|
|
68
|
+
labelElementType: "span"
|
|
69
|
+
});
|
|
70
|
+
let { gridProps: gridProps } = (0, $bSzeT$reactariagridlist.useGridList)({
|
|
71
|
+
...props,
|
|
72
|
+
...fieldProps,
|
|
73
|
+
keyboardDelegate: keyboardDelegate,
|
|
74
|
+
shouldFocusWrap: true
|
|
75
|
+
}, state, ref);
|
|
76
|
+
let [isFocusWithin, setFocusWithin] = (0, $bSzeT$react.useState)(false);
|
|
77
|
+
let { focusWithinProps: focusWithinProps } = (0, $bSzeT$reactariainteractions.useFocusWithin)({
|
|
78
|
+
onFocusWithinChange: setFocusWithin
|
|
79
|
+
});
|
|
80
|
+
let domProps = (0, $bSzeT$reactariautils.filterDOMProps)(props);
|
|
81
|
+
// If the last tag is removed, focus the container.
|
|
82
|
+
let prevCount = (0, $bSzeT$react.useRef)(state.collection.size);
|
|
83
|
+
(0, $bSzeT$react.useEffect)(()=>{
|
|
84
|
+
if (prevCount.current > 0 && state.collection.size === 0 && isFocusWithin) ref.current.focus();
|
|
85
|
+
prevCount.current = state.collection.size;
|
|
86
|
+
}, [
|
|
87
|
+
state.collection.size,
|
|
88
|
+
isFocusWithin,
|
|
89
|
+
ref
|
|
90
|
+
]);
|
|
91
|
+
$09704b0efefe5140$export$653eddfc964b0f8a.set(state, {
|
|
92
|
+
onRemove: props.onRemove
|
|
93
|
+
});
|
|
94
|
+
return {
|
|
95
|
+
gridProps: (0, $bSzeT$reactariautils.mergeProps)(gridProps, domProps, {
|
|
96
|
+
role: state.collection.size ? "grid" : null,
|
|
97
|
+
"aria-atomic": false,
|
|
98
|
+
"aria-relevant": "additions",
|
|
99
|
+
"aria-live": isFocusWithin ? "polite" : "off",
|
|
100
|
+
...focusWithinProps,
|
|
101
|
+
...fieldProps
|
|
102
|
+
}),
|
|
103
|
+
labelProps: labelProps,
|
|
104
|
+
descriptionProps: descriptionProps,
|
|
105
|
+
errorMessageProps: errorMessageProps
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
var $b6a2538ff098a9ff$exports = {};
|
|
92
111
|
var $6a4ddf1abe55d42a$exports = {};
|
|
93
112
|
$6a4ddf1abe55d42a$exports = {
|
|
94
113
|
"removeButtonLabel": `إزالة`,
|
|
@@ -327,7 +346,7 @@ $a34b8398aee73e0f$exports = {
|
|
|
327
346
|
};
|
|
328
347
|
|
|
329
348
|
|
|
330
|
-
$
|
|
349
|
+
$b6a2538ff098a9ff$exports = {
|
|
331
350
|
"ar-AE": $6a4ddf1abe55d42a$exports,
|
|
332
351
|
"bg-BG": $1bdc82b10375b4a8$exports,
|
|
333
352
|
"cs-CZ": $e3fdf009dfe14bbc$exports,
|
|
@@ -369,104 +388,58 @@ $29abb9209b62cd49$exports = {
|
|
|
369
388
|
|
|
370
389
|
|
|
371
390
|
function $a442534c81d8ad16$export$3f568fff7dff2f03(props, state, ref) {
|
|
372
|
-
let {
|
|
373
|
-
let stringFormatter = (0, $bSzeT$reactariai18n.useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($
|
|
374
|
-
let labelId = (0, $bSzeT$reactariautils.useId)();
|
|
391
|
+
let { item: item } = props;
|
|
392
|
+
let stringFormatter = (0, $bSzeT$reactariai18n.useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($b6a2538ff098a9ff$exports))));
|
|
375
393
|
let buttonId = (0, $bSzeT$reactariautils.useId)();
|
|
376
|
-
let {
|
|
394
|
+
let { onRemove: onRemove } = (0, $09704b0efefe5140$export$653eddfc964b0f8a).get(state) || {};
|
|
395
|
+
let { rowProps: rowProps , gridCellProps: gridCellProps , ...states } = (0, $bSzeT$reactariagridlist.useGridListItem)({
|
|
377
396
|
node: item
|
|
378
397
|
}, state, ref);
|
|
379
398
|
// We want the group to handle keyboard navigation between tags.
|
|
380
399
|
delete rowProps.onKeyDownCapture;
|
|
381
|
-
|
|
400
|
+
delete states.descriptionProps;
|
|
382
401
|
let onKeyDown = (e)=>{
|
|
383
402
|
if (e.key === "Delete" || e.key === "Backspace") {
|
|
384
|
-
onRemove(item.key);
|
|
385
403
|
e.preventDefault();
|
|
404
|
+
if (state.selectionManager.isSelected(item.key)) onRemove(new Set(state.selectionManager.selectedKeys));
|
|
405
|
+
else onRemove(new Set([
|
|
406
|
+
item.key
|
|
407
|
+
]));
|
|
386
408
|
}
|
|
387
409
|
};
|
|
388
410
|
let modality = (0, $bSzeT$reactariainteractions.useInteractionModality)();
|
|
389
411
|
if (modality === "virtual" && typeof window !== "undefined" && "ontouchstart" in window) modality = "touch";
|
|
390
|
-
let description =
|
|
412
|
+
let description = onRemove && (modality === "keyboard" || modality === "virtual") ? stringFormatter.format("removeDescription") : "";
|
|
391
413
|
let descProps = (0, $bSzeT$reactariautils.useDescription)(description);
|
|
392
|
-
let domProps = (0, $bSzeT$reactariautils.filterDOMProps)(props);
|
|
393
414
|
let isFocused = item.key === state.selectionManager.focusedKey;
|
|
415
|
+
// @ts-ignore - data attributes are ok but TS doesn't know about them.
|
|
416
|
+
let domProps = (0, $bSzeT$reactariautils.filterDOMProps)(props);
|
|
394
417
|
return {
|
|
395
418
|
removeButtonProps: {
|
|
396
|
-
"aria-label": stringFormatter.format("removeButtonLabel",
|
|
397
|
-
|
|
398
|
-
}),
|
|
399
|
-
"aria-labelledby": `${buttonId} ${labelId}`,
|
|
419
|
+
"aria-label": stringFormatter.format("removeButtonLabel"),
|
|
420
|
+
"aria-labelledby": `${buttonId} ${rowProps.id}`,
|
|
400
421
|
id: buttonId,
|
|
401
|
-
onPress: ()=>
|
|
422
|
+
onPress: ()=>onRemove ? onRemove(new Set([
|
|
423
|
+
item.key
|
|
424
|
+
])) : null,
|
|
402
425
|
excludeFromTabOrder: true
|
|
403
426
|
},
|
|
404
|
-
|
|
405
|
-
id: labelId
|
|
406
|
-
},
|
|
407
|
-
rowProps: {
|
|
408
|
-
...rowProps,
|
|
427
|
+
rowProps: (0, $bSzeT$reactariautils.mergeProps)(rowProps, domProps, {
|
|
409
428
|
tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,
|
|
410
|
-
onKeyDown:
|
|
429
|
+
onKeyDown: onRemove ? onKeyDown : undefined,
|
|
411
430
|
"aria-describedby": descProps["aria-describedby"]
|
|
412
|
-
},
|
|
413
|
-
gridCellProps: (0, $bSzeT$reactariautils.mergeProps)(
|
|
431
|
+
}),
|
|
432
|
+
gridCellProps: (0, $bSzeT$reactariautils.mergeProps)(gridCellProps, {
|
|
414
433
|
"aria-errormessage": props["aria-errormessage"],
|
|
415
434
|
"aria-label": props["aria-label"]
|
|
416
|
-
})
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
/*
|
|
422
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
423
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
424
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
425
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
426
|
-
*
|
|
427
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
428
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
429
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
430
|
-
* governing permissions and limitations under the License.
|
|
431
|
-
*/
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
function $09704b0efefe5140$export$4f8b5cda58b7e8ff(props, state, ref) {
|
|
439
|
-
let { direction: direction } = (0, $bSzeT$reactariai18n.useLocale)();
|
|
440
|
-
let keyboardDelegate = props.keyboardDelegate || new (0, $d3d7c73f2e3f4edb$export$b00754732e683b92)(state.collection, direction);
|
|
441
|
-
let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $bSzeT$reactarialabel.useField)(props);
|
|
442
|
-
let { gridProps: gridProps } = (0, $bSzeT$reactariagridlist.useGridList)({
|
|
443
|
-
...props,
|
|
444
|
-
...fieldProps,
|
|
445
|
-
keyboardDelegate: keyboardDelegate
|
|
446
|
-
}, state, ref);
|
|
447
|
-
// Don't want the grid to be focusable or accessible via keyboard
|
|
448
|
-
delete gridProps.tabIndex;
|
|
449
|
-
let [isFocusWithin, setFocusWithin] = (0, $bSzeT$react.useState)(false);
|
|
450
|
-
let { focusWithinProps: focusWithinProps } = (0, $bSzeT$reactariainteractions.useFocusWithin)({
|
|
451
|
-
onFocusWithinChange: setFocusWithin
|
|
452
|
-
});
|
|
453
|
-
let domProps = (0, $bSzeT$reactariautils.filterDOMProps)(props);
|
|
454
|
-
return {
|
|
455
|
-
gridProps: (0, $bSzeT$reactariautils.mergeProps)(gridProps, domProps, {
|
|
456
|
-
role: state.collection.size ? "grid" : null,
|
|
457
|
-
"aria-atomic": false,
|
|
458
|
-
"aria-relevant": "additions",
|
|
459
|
-
"aria-live": isFocusWithin ? "polite" : "off",
|
|
460
|
-
...focusWithinProps,
|
|
461
|
-
...fieldProps
|
|
462
435
|
}),
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
errorMessageProps: errorMessageProps
|
|
436
|
+
...states,
|
|
437
|
+
allowsRemoving: !!onRemove
|
|
466
438
|
};
|
|
467
439
|
}
|
|
468
440
|
|
|
469
441
|
|
|
470
442
|
|
|
471
443
|
|
|
444
|
+
|
|
472
445
|
//# sourceMappingURL=main.js.map
|