@react-aria/tag 3.0.0-nightly.1930 → 3.0.0-nightly.1933
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/main.js +51 -75
- package/dist/main.js.map +1 -1
- package/dist/module.js +53 -77
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +22 -15
- package/dist/types.d.ts.map +1 -1
- package/package.json +10 -10
- package/src/TagKeyboardDelegate.ts +19 -47
- package/src/index.ts +1 -1
- package/src/useTag.ts +36 -35
- package/src/useTagGroup.ts +24 -10
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var $bSzeT$reactariagrid = require("@react-aria/grid");
|
|
2
1
|
var $bSzeT$reactariautils = require("@react-aria/utils");
|
|
2
|
+
var $bSzeT$reactariagridlist = require("@react-aria/gridlist");
|
|
3
3
|
var $bSzeT$reactariai18n = require("@react-aria/i18n");
|
|
4
4
|
var $bSzeT$react = require("react");
|
|
5
5
|
var $bSzeT$reactariainteractions = require("@react-aria/interactions");
|
|
@@ -34,21 +34,12 @@ $parcel$export(module.exports, "useTagGroup", () => $09704b0efefe5140$export$4f8
|
|
|
34
34
|
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
35
35
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
36
36
|
* governing permissions and limitations under the License.
|
|
37
|
-
*/
|
|
38
|
-
class $d3d7c73f2e3f4edb$export$b00754732e683b92 extends (0, $bSzeT$reactariagrid.GridKeyboardDelegate) {
|
|
37
|
+
*/ class $d3d7c73f2e3f4edb$export$b00754732e683b92 {
|
|
39
38
|
getFirstKey() {
|
|
40
|
-
|
|
41
|
-
let item = this.collection.getItem(key);
|
|
42
|
-
return [
|
|
43
|
-
...item.childNodes
|
|
44
|
-
][0].key;
|
|
39
|
+
return this.collection.getFirstKey();
|
|
45
40
|
}
|
|
46
41
|
getLastKey() {
|
|
47
|
-
|
|
48
|
-
let item = this.collection.getItem(key);
|
|
49
|
-
return [
|
|
50
|
-
...item.childNodes
|
|
51
|
-
][0].key;
|
|
42
|
+
return this.collection.getLastKey();
|
|
52
43
|
}
|
|
53
44
|
getKeyRightOf(key) {
|
|
54
45
|
return this.direction === "rtl" ? this.getKeyAbove(key) : this.getKeyBelow(key);
|
|
@@ -59,40 +50,18 @@ class $d3d7c73f2e3f4edb$export$b00754732e683b92 extends (0, $bSzeT$reactariagrid
|
|
|
59
50
|
getKeyBelow(key) {
|
|
60
51
|
let startItem = this.collection.getItem(key);
|
|
61
52
|
if (!startItem) return;
|
|
62
|
-
// If focus was on a cell, start searching from the parent row
|
|
63
|
-
if (this.isCell(startItem)) key = startItem.parentKey;
|
|
64
53
|
// Find the next item
|
|
65
|
-
key = this.
|
|
66
|
-
if (key != null)
|
|
67
|
-
|
|
68
|
-
if (this.isCell(startItem)) {
|
|
69
|
-
let item = this.collection.getItem(key);
|
|
70
|
-
return [
|
|
71
|
-
...item.childNodes
|
|
72
|
-
][startItem.index].key;
|
|
73
|
-
}
|
|
74
|
-
// Otherwise, focus the next row
|
|
75
|
-
if (this.focusMode === "row") return key;
|
|
76
|
-
} else return this.getFirstKey();
|
|
54
|
+
key = this.collection.getKeyAfter(key);
|
|
55
|
+
if (key != null) return key;
|
|
56
|
+
else return this.collection.getFirstKey();
|
|
77
57
|
}
|
|
78
58
|
getKeyAbove(key) {
|
|
79
59
|
let startItem = this.collection.getItem(key);
|
|
80
60
|
if (!startItem) return;
|
|
81
|
-
// If focus is on a cell, start searching from the parent row
|
|
82
|
-
if (this.isCell(startItem)) key = startItem.parentKey;
|
|
83
61
|
// Find the previous item
|
|
84
|
-
key = this.
|
|
85
|
-
if (key != null)
|
|
86
|
-
|
|
87
|
-
if (this.isCell(startItem)) {
|
|
88
|
-
let item = this.collection.getItem(key);
|
|
89
|
-
return [
|
|
90
|
-
...item.childNodes
|
|
91
|
-
][startItem.index].key;
|
|
92
|
-
}
|
|
93
|
-
// Otherwise, focus the previous row
|
|
94
|
-
if (this.focusMode === "row") return key;
|
|
95
|
-
} else return this.getLastKey();
|
|
62
|
+
key = this.collection.getKeyBefore(key);
|
|
63
|
+
if (key != null) return key;
|
|
64
|
+
else return this.collection.getLastKey();
|
|
96
65
|
}
|
|
97
66
|
getKeyPageAbove(key) {
|
|
98
67
|
return this.getKeyAbove(key);
|
|
@@ -100,6 +69,10 @@ class $d3d7c73f2e3f4edb$export$b00754732e683b92 extends (0, $bSzeT$reactariagrid
|
|
|
100
69
|
getKeyPageBelow(key) {
|
|
101
70
|
return this.getKeyBelow(key);
|
|
102
71
|
}
|
|
72
|
+
constructor(collection, direction){
|
|
73
|
+
this.collection = collection;
|
|
74
|
+
this.direction = direction;
|
|
75
|
+
}
|
|
103
76
|
}
|
|
104
77
|
|
|
105
78
|
|
|
@@ -153,7 +126,7 @@ $9ec4c01646bfc149$exports = {
|
|
|
153
126
|
|
|
154
127
|
var $0b797b6d677cd5c7$exports = {};
|
|
155
128
|
$0b797b6d677cd5c7$exports = {
|
|
156
|
-
"remove": `
|
|
129
|
+
"remove": `Press Space or Delete to remove tag.`
|
|
157
130
|
};
|
|
158
131
|
|
|
159
132
|
|
|
@@ -360,52 +333,43 @@ $29abb9209b62cd49$exports = {
|
|
|
360
333
|
|
|
361
334
|
|
|
362
335
|
function $a442534c81d8ad16$export$3f568fff7dff2f03(props, state) {
|
|
363
|
-
let { isFocused: isFocused } = props;
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
let { rowProps: rowProps } = (0, $bSzeT$reactariagrid.useGridRow)({
|
|
336
|
+
let { isFocused: isFocused , allowsRemoving: allowsRemoving , item: item , tagRowRef: tagRowRef } = props;
|
|
337
|
+
let stringFormatter = (0, $bSzeT$reactariai18n.useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($29abb9209b62cd49$exports))));
|
|
338
|
+
let removeString = stringFormatter.format("remove");
|
|
339
|
+
let labelId = (0, $bSzeT$reactariautils.useId)();
|
|
340
|
+
let buttonId = (0, $bSzeT$reactariautils.useId)();
|
|
341
|
+
let { rowProps: rowProps , gridCellProps: gridCellProps } = (0, $bSzeT$reactariagridlist.useGridListItem)({
|
|
370
342
|
node: item
|
|
371
343
|
}, state, tagRowRef);
|
|
372
|
-
//
|
|
373
|
-
|
|
374
|
-
let
|
|
375
|
-
let
|
|
376
|
-
node: [
|
|
377
|
-
...item.childNodes
|
|
378
|
-
][0],
|
|
379
|
-
focusMode: "cell"
|
|
380
|
-
}, state, tagRef);
|
|
381
|
-
function onKeyDown(e) {
|
|
344
|
+
// We want the group to handle keyboard navigation between tags.
|
|
345
|
+
delete rowProps.onKeyDownCapture;
|
|
346
|
+
let onRemove = (0, $bSzeT$reactariautils.chain)(props.onRemove, state.onRemove);
|
|
347
|
+
let onKeyDown = (e)=>{
|
|
382
348
|
if (e.key === "Delete" || e.key === "Backspace" || e.key === " ") {
|
|
383
|
-
onRemove(item.
|
|
349
|
+
onRemove(item.key);
|
|
384
350
|
e.preventDefault();
|
|
385
351
|
}
|
|
386
|
-
}
|
|
387
|
-
const pressProps = {
|
|
388
|
-
onPress: ()=>{
|
|
389
|
-
return onRemove === null || onRemove === void 0 ? void 0 : onRemove(item.childNodes[0].key);
|
|
390
|
-
}
|
|
391
352
|
};
|
|
392
|
-
isFocused = isFocused || state.selectionManager.focusedKey === item.
|
|
353
|
+
isFocused = isFocused || state.selectionManager.focusedKey === item.key;
|
|
393
354
|
let domProps = (0, $bSzeT$reactariautils.filterDOMProps)(props);
|
|
394
355
|
return {
|
|
395
|
-
clearButtonProps:
|
|
356
|
+
clearButtonProps: {
|
|
396
357
|
"aria-label": removeString,
|
|
397
358
|
"aria-labelledby": `${buttonId} ${labelId}`,
|
|
398
|
-
id: buttonId
|
|
399
|
-
|
|
359
|
+
id: buttonId,
|
|
360
|
+
onPress: ()=>allowsRemoving && onRemove ? onRemove(item.key) : null
|
|
361
|
+
},
|
|
400
362
|
labelProps: {
|
|
401
363
|
id: labelId
|
|
402
364
|
},
|
|
403
|
-
tagRowProps:
|
|
365
|
+
tagRowProps: {
|
|
366
|
+
...rowProps,
|
|
367
|
+
tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,
|
|
368
|
+
onKeyDown: allowsRemoving ? onKeyDown : null
|
|
369
|
+
},
|
|
404
370
|
tagProps: (0, $bSzeT$reactariautils.mergeProps)(domProps, gridCellProps, {
|
|
405
371
|
"aria-errormessage": props["aria-errormessage"],
|
|
406
|
-
"aria-label": props["aria-label"]
|
|
407
|
-
onKeyDown: allowsRemoving ? onKeyDown : null,
|
|
408
|
-
tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1
|
|
372
|
+
"aria-label": props["aria-label"]
|
|
409
373
|
})
|
|
410
374
|
};
|
|
411
375
|
}
|
|
@@ -424,14 +388,26 @@ function $a442534c81d8ad16$export$3f568fff7dff2f03(props, state) {
|
|
|
424
388
|
*/
|
|
425
389
|
|
|
426
390
|
|
|
427
|
-
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
function $09704b0efefe5140$export$4f8b5cda58b7e8ff(props, state, ref) {
|
|
395
|
+
let { direction: direction } = (0, $bSzeT$reactariai18n.useLocale)();
|
|
396
|
+
let keyboardDelegate = new (0, $d3d7c73f2e3f4edb$export$b00754732e683b92)(state.collection, direction);
|
|
397
|
+
let { gridProps: gridProps } = (0, $bSzeT$reactariagridlist.useGridList)({
|
|
398
|
+
...props,
|
|
399
|
+
keyboardDelegate: keyboardDelegate
|
|
400
|
+
}, state, ref);
|
|
401
|
+
// Don't want the grid to be focusable or accessible via keyboard
|
|
402
|
+
delete gridProps.role;
|
|
403
|
+
delete gridProps.tabIndex;
|
|
428
404
|
let [isFocusWithin, setFocusWithin] = (0, $bSzeT$react.useState)(false);
|
|
429
405
|
let { focusWithinProps: focusWithinProps } = (0, $bSzeT$reactariainteractions.useFocusWithin)({
|
|
430
406
|
onFocusWithinChange: setFocusWithin
|
|
431
407
|
});
|
|
432
408
|
let domProps = (0, $bSzeT$reactariautils.filterDOMProps)(props);
|
|
433
409
|
return {
|
|
434
|
-
tagGroupProps: (0, $bSzeT$reactariautils.mergeProps)(domProps, {
|
|
410
|
+
tagGroupProps: (0, $bSzeT$reactariautils.mergeProps)(gridProps, domProps, {
|
|
435
411
|
"aria-atomic": false,
|
|
436
412
|
"aria-relevant": "additions",
|
|
437
413
|
"aria-live": isFocusWithin ? "polite" : "off",
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;AAIO,MAAM,kDAA+B,CAAA,GAAA,yCAAoB,AAAD;IAC7D,cAAc;QACZ,IAAI,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW;QACrC,IAAI,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;QAEnC,OAAO;eAAI,KAAK,UAAU;SAAC,CAAC,EAAE,CAAC,GAAG;IACpC;IAEA,aAAa;QACX,IAAI,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU;QACpC,IAAI,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;QAEnC,OAAO;eAAI,KAAK,UAAU;SAAC,CAAC,EAAE,CAAC,GAAG;IACpC;IAEA,cAAc,GAAQ,EAAE;QACtB,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,IAAI,CAAC,WAAW,CAAC,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI;IACjF;IAEA,aAAa,GAAQ,EAAE;QACrB,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,IAAI,CAAC,WAAW,CAAC,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI;IACjF;IAEA,YAAY,GAAG,EAAE;QACf,IAAI,YAAY,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;QACxC,IAAI,CAAC,WACH;QAGF,8DAA8D;QAC9D,IAAI,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AAa,MAAM,gBAAgB,CAAC,UAAU,IAAI,IAAI,GAAI,IAAI,EAAE;QAC7E;IACF;AACF;;;AoCrFA;;;;;;;;;;CAUC,GAED;;;AAeO,SAAS,0CAAY,KAAwB,EAAgB;IAClE,IAAI,CAAC,eAAe,eAAe,GAAG,CAAA,GAAA,qBAAO,EAAE,KAAK;IACpD,IAAI,oBAAC,iBAAgB,EAAC,GAAG,CAAA,GAAA,2CAAc,AAAD,EAAE;QACtC,qBAAqB;IACvB;IACA,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE;IAC9B,OAAO;QACL,eAAe,CAAA,GAAA,gCAAU,AAAD,EAAE,UAAU;YAClC,eAAe,KAAK;YACpB,iBAAiB;YACjB,aAAa,gBAAgB,WAAW,KAAK;YAC7C,GAAG,gBAAgB;QACrB;IACF;AACF;;","sources":["packages/@react-aria/tag/src/index.ts","packages/@react-aria/tag/src/TagKeyboardDelegate.ts","packages/@react-aria/tag/src/useTag.ts","packages/@react-aria/tag/intl/*.js","packages/@react-aria/tag/intl/ar-AE.json","packages/@react-aria/tag/intl/bg-BG.json","packages/@react-aria/tag/intl/cs-CZ.json","packages/@react-aria/tag/intl/da-DK.json","packages/@react-aria/tag/intl/de-DE.json","packages/@react-aria/tag/intl/el-GR.json","packages/@react-aria/tag/intl/en-US.json","packages/@react-aria/tag/intl/es-ES.json","packages/@react-aria/tag/intl/et-EE.json","packages/@react-aria/tag/intl/fi-FI.json","packages/@react-aria/tag/intl/fr-FR.json","packages/@react-aria/tag/intl/he-IL.json","packages/@react-aria/tag/intl/hr-HR.json","packages/@react-aria/tag/intl/hu-HU.json","packages/@react-aria/tag/intl/it-IT.json","packages/@react-aria/tag/intl/ja-JP.json","packages/@react-aria/tag/intl/ko-KR.json","packages/@react-aria/tag/intl/lt-LT.json","packages/@react-aria/tag/intl/lv-LV.json","packages/@react-aria/tag/intl/nb-NO.json","packages/@react-aria/tag/intl/nl-NL.json","packages/@react-aria/tag/intl/pl-PL.json","packages/@react-aria/tag/intl/pt-BR.json","packages/@react-aria/tag/intl/pt-PT.json","packages/@react-aria/tag/intl/ro-RO.json","packages/@react-aria/tag/intl/ru-RU.json","packages/@react-aria/tag/intl/sk-SK.json","packages/@react-aria/tag/intl/sl-SI.json","packages/@react-aria/tag/intl/sr-SP.json","packages/@react-aria/tag/intl/sv-SE.json","packages/@react-aria/tag/intl/tr-TR.json","packages/@react-aria/tag/intl/uk-UA.json","packages/@react-aria/tag/intl/zh-CN.json","packages/@react-aria/tag/intl/zh-TW.json","packages/@react-aria/tag/src/useTagGroup.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {TagKeyboardDelegate} from './TagKeyboardDelegate';\nexport {useTag} from './useTag';\nexport {useTagGroup} from './useTagGroup';\n\nexport type {TagProps} from '@react-types/tag';\nexport type {AriaTagGroupProps, TagGroupAria} from './useTagGroup';\nexport type {TagAria} from './useTag';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {GridCollection} from '@react-types/grid';\nimport {GridKeyboardDelegate} from '@react-aria/grid';\nimport {Key} from 'react';\n\nexport class TagKeyboardDelegate<T> extends GridKeyboardDelegate<T, GridCollection<T>> {\n getFirstKey() {\n let key = this.collection.getFirstKey();\n let item = this.collection.getItem(key);\n\n return [...item.childNodes][0].key;\n }\n\n getLastKey() {\n let key = this.collection.getLastKey();\n let item = this.collection.getItem(key);\n\n return [...item.childNodes][0].key;\n }\n\n getKeyRightOf(key: Key) {\n return this.direction === 'rtl' ? this.getKeyAbove(key) : this.getKeyBelow(key);\n }\n\n getKeyLeftOf(key: Key) {\n return this.direction === 'rtl' ? this.getKeyBelow(key) : this.getKeyAbove(key);\n }\n\n getKeyBelow(key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // If focus was on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey;\n }\n\n // Find the next item\n key = this.findNextKey(key);\n if (key != null) {\n // If focus was on a cell, focus the cell with the same index in the next row.\n if (this.isCell(startItem)) {\n let item = this.collection.getItem(key);\n\n return [...item.childNodes][startItem.index].key;\n }\n\n // Otherwise, focus the next row\n if (this.focusMode === 'row') {\n return key;\n }\n } else {\n return this.getFirstKey();\n }\n }\n\n getKeyAbove(key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // If focus is on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey;\n }\n\n // Find the previous item\n key = this.findPreviousKey(key);\n if (key != null) {\n // If focus was on a cell, focus the cell with the same index in the previous row.\n if (this.isCell(startItem)) {\n let item = this.collection.getItem(key);\n return [...item.childNodes][startItem.index].key;\n }\n\n // Otherwise, focus the previous row\n if (this.focusMode === 'row') {\n return key;\n }\n } else {\n return this.getLastKey();\n }\n }\n\n getKeyPageAbove(key) {\n return this.getKeyAbove(key);\n }\n\n getKeyPageBelow(key) {\n return this.getKeyBelow(key);\n }\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ButtonHTMLAttributes, KeyboardEvent} from 'react';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {GridState} from '@react-stately/grid';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {TagProps} from '@react-types/tag';\nimport {useGridCell, useGridRow} from '@react-aria/grid';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\n\nexport interface TagAria {\n labelProps: DOMAttributes,\n tagProps: DOMAttributes,\n tagRowProps: DOMAttributes,\n clearButtonProps: ButtonHTMLAttributes<HTMLButtonElement>\n}\n\nexport function useTag(props: TagProps<any>, state: GridState<any, any>): TagAria {\n let {isFocused} = props;\n const {\n allowsRemoving,\n onRemove,\n item,\n tagRef,\n tagRowRef\n } = props;\n const stringFormatter = useLocalizedStringFormatter(intlMessages);\n const removeString = stringFormatter.format('remove');\n const labelId = useId();\n const buttonId = useId();\n\n let {rowProps} = useGridRow({\n node: item\n }, state, tagRowRef);\n // Don't want the row to be focusable or accessible via keyboard\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n let {tabIndex, ...otherRowProps} = rowProps;\n\n let {gridCellProps} = useGridCell({\n node: [...item.childNodes][0],\n focusMode: 'cell'\n }, state, tagRef);\n\n function onKeyDown(e: KeyboardEvent) {\n if (e.key === 'Delete' || e.key === 'Backspace' || e.key === ' ') {\n onRemove(item.childNodes[0].key);\n e.preventDefault();\n }\n }\n const pressProps = {\n onPress: () => onRemove?.(item.childNodes[0].key)\n };\n\n isFocused = isFocused || state.selectionManager.focusedKey === item.childNodes[0].key;\n let domProps = filterDOMProps(props);\n return {\n clearButtonProps: mergeProps(pressProps, {\n 'aria-label': removeString,\n 'aria-labelledby': `${buttonId} ${labelId}`,\n id: buttonId\n }),\n labelProps: {\n id: labelId\n },\n tagRowProps: otherRowProps,\n tagProps: mergeProps(domProps, gridCellProps, {\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-label': props['aria-label'],\n onKeyDown: allowsRemoving ? onKeyDown : null,\n tabIndex: (isFocused || state.selectionManager.focusedKey == null) ? 0 : -1\n })\n };\n}\n","const _temp0 = require(\"./ar-AE.json\");\nconst _temp1 = require(\"./bg-BG.json\");\nconst _temp2 = require(\"./cs-CZ.json\");\nconst _temp3 = require(\"./da-DK.json\");\nconst _temp4 = require(\"./de-DE.json\");\nconst _temp5 = require(\"./el-GR.json\");\nconst _temp6 = require(\"./en-US.json\");\nconst _temp7 = require(\"./es-ES.json\");\nconst _temp8 = require(\"./et-EE.json\");\nconst _temp9 = require(\"./fi-FI.json\");\nconst _temp10 = require(\"./fr-FR.json\");\nconst _temp11 = require(\"./he-IL.json\");\nconst _temp12 = require(\"./hr-HR.json\");\nconst _temp13 = require(\"./hu-HU.json\");\nconst _temp14 = require(\"./it-IT.json\");\nconst _temp15 = require(\"./ja-JP.json\");\nconst _temp16 = require(\"./ko-KR.json\");\nconst _temp17 = require(\"./lt-LT.json\");\nconst _temp18 = require(\"./lv-LV.json\");\nconst _temp19 = require(\"./nb-NO.json\");\nconst _temp20 = require(\"./nl-NL.json\");\nconst _temp21 = require(\"./pl-PL.json\");\nconst _temp22 = require(\"./pt-BR.json\");\nconst _temp23 = require(\"./pt-PT.json\");\nconst _temp24 = require(\"./ro-RO.json\");\nconst _temp25 = require(\"./ru-RU.json\");\nconst _temp26 = require(\"./sk-SK.json\");\nconst _temp27 = require(\"./sl-SI.json\");\nconst _temp28 = require(\"./sr-SP.json\");\nconst _temp29 = require(\"./sv-SE.json\");\nconst _temp30 = require(\"./tr-TR.json\");\nconst _temp31 = require(\"./uk-UA.json\");\nconst _temp32 = require(\"./zh-CN.json\");\nconst _temp33 = require(\"./zh-TW.json\");\nmodule.exports = {\n \"ar-AE\": _temp0,\n \"bg-BG\": _temp1,\n \"cs-CZ\": _temp2,\n \"da-DK\": _temp3,\n \"de-DE\": _temp4,\n \"el-GR\": _temp5,\n \"en-US\": _temp6,\n \"es-ES\": _temp7,\n \"et-EE\": _temp8,\n \"fi-FI\": _temp9,\n \"fr-FR\": _temp10,\n \"he-IL\": _temp11,\n \"hr-HR\": _temp12,\n \"hu-HU\": _temp13,\n \"it-IT\": _temp14,\n \"ja-JP\": _temp15,\n \"ko-KR\": _temp16,\n \"lt-LT\": _temp17,\n \"lv-LV\": _temp18,\n \"nb-NO\": _temp19,\n \"nl-NL\": _temp20,\n \"pl-PL\": _temp21,\n \"pt-BR\": _temp22,\n \"pt-PT\": _temp23,\n \"ro-RO\": _temp24,\n \"ru-RU\": _temp25,\n \"sk-SK\": _temp26,\n \"sl-SI\": _temp27,\n \"sr-SP\": _temp28,\n \"sv-SE\": _temp29,\n \"tr-TR\": _temp30,\n \"uk-UA\": _temp31,\n \"zh-CN\": _temp32,\n \"zh-TW\": _temp33\n}","{\n \"remove\": \"إزالة\"\n}\n","{\n \"remove\": \"Премахване\"\n}\n","{\n \"remove\": \"Odebrat\"\n}\n","{\n \"remove\": \"Fjern\"\n}\n","{\n \"remove\": \"Entfernen\"\n}\n","{\n \"remove\": \"Κατάργηση\"\n}\n","{\n \"remove\": \"Remove\"\n}\n","{\n \"remove\": \"Quitar\"\n}\n","{\n \"remove\": \"Eemalda\"\n}\n","{\n \"remove\": \"Poista\"\n}\n","{\n \"remove\": \"Supprimer\"\n}\n","{\n \"remove\": \"הסר\"\n}\n","{\n \"remove\": \"Ukloni\"\n}\n","{\n \"remove\": \"Eltávolítás\"\n}\n","{\n \"remove\": \"Rimuovi\"\n}\n","{\n \"remove\": \"削除\"\n}\n","{\n \"remove\": \"제거\"\n}\n","{\n \"remove\": \"Pašalinti\"\n}\n","{\n \"remove\": \"Noņemt\"\n}\n","{\n \"remove\": \"Fjern\"\n}\n","{\n \"remove\": \"Verwijderen\"\n}\n","{\n \"remove\": \"Usuń\"\n}\n","{\n \"remove\": \"Remover\"\n}\n","{\n \"remove\": \"Eliminar\"\n}\n","{\n \"remove\": \"Îndepărtaţi\"\n}\n","{\n \"remove\": \"Удалить\"\n}\n","{\n \"remove\": \"Odstrániť\"\n}\n","{\n \"remove\": \"Odstrani\"\n}\n","{\n \"remove\": \"Ukloni\"\n}\n","{\n \"remove\": \"Ta bort\"\n}\n","{\n \"remove\": \"Kaldır\"\n}\n","{\n \"remove\": \"Видалити\"\n}\n","{\n \"remove\": \"删除\"\n}\n","{\n \"remove\": \"移除\"\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, DOMProps} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {ReactNode, useState} from 'react';\nimport {useFocusWithin} from '@react-aria/interactions';\n\nexport interface AriaTagGroupProps extends DOMProps {\n children: ReactNode,\n isReadOnly?: boolean, // removes close button\n validationState?: 'valid' | 'invalid'\n}\n\nexport interface TagGroupAria {\n tagGroupProps: DOMAttributes\n}\n\nexport function useTagGroup(props: AriaTagGroupProps): TagGroupAria {\n let [isFocusWithin, setFocusWithin] = useState(false);\n let {focusWithinProps} = useFocusWithin({\n onFocusWithinChange: setFocusWithin\n });\n let domProps = filterDOMProps(props);\n return {\n tagGroupProps: mergeProps(domProps, {\n 'aria-atomic': false,\n 'aria-relevant': 'additions',\n 'aria-live': isFocusWithin ? 'polite' : 'off',\n ...focusWithinProps\n } as DOMAttributes)\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;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AC,UAAS,EAAC,GAAG,CAAA,GAAA,8BAAS,AAAD;IAC1B,IAAI,mBAAmB,IAAI,CAAA,GAAA,yCAAmB,AAAD,EAAE,MAAM,UAAU,EAAE;IACjE,IAAI,aAAC,UAAS,EAAC,GAAG,CAAA,GAAA,oCAAW,AAAD,EAAE;QAAC,GAAG,KAAK;0BAAE;IAAgB,GAAG,OAAO;IAEnE,iEAAiE;IACjE,OAAO,UAAU,IAAI;IACrB,OAAO,UAAU,QAAQ;IAEzB,IAAI,CAAC,eAAe,eAAe,GAAG,CAAA,GAAA,qBAAO,EAAE,KAAK;IACpD,IAAI,oBAAC,iBAAgB,EAAC,GAAG,CAAA,GAAA,2CAAc,AAAD,EAAE;QACtC,qBAAqB;IACvB;IACA,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE;IAC9B,OAAO;QACL,eAAe,CAAA,GAAA,gCAAU,AAAD,EAAE,WAAW,UAAU;YAC7C,eAAe,KAAK;YACpB,iBAAiB;YACjB,aAAa,gBAAgB,WAAW,KAAK;YAC7C,GAAG,gBAAgB;QACrB;IACF;AACF;;","sources":["packages/@react-aria/tag/src/index.ts","packages/@react-aria/tag/src/TagKeyboardDelegate.ts","packages/@react-aria/tag/src/useTag.ts","packages/@react-aria/tag/intl/*.js","packages/@react-aria/tag/intl/ar-AE.json","packages/@react-aria/tag/intl/bg-BG.json","packages/@react-aria/tag/intl/cs-CZ.json","packages/@react-aria/tag/intl/da-DK.json","packages/@react-aria/tag/intl/de-DE.json","packages/@react-aria/tag/intl/el-GR.json","packages/@react-aria/tag/intl/en-US.json","packages/@react-aria/tag/intl/es-ES.json","packages/@react-aria/tag/intl/et-EE.json","packages/@react-aria/tag/intl/fi-FI.json","packages/@react-aria/tag/intl/fr-FR.json","packages/@react-aria/tag/intl/he-IL.json","packages/@react-aria/tag/intl/hr-HR.json","packages/@react-aria/tag/intl/hu-HU.json","packages/@react-aria/tag/intl/it-IT.json","packages/@react-aria/tag/intl/ja-JP.json","packages/@react-aria/tag/intl/ko-KR.json","packages/@react-aria/tag/intl/lt-LT.json","packages/@react-aria/tag/intl/lv-LV.json","packages/@react-aria/tag/intl/nb-NO.json","packages/@react-aria/tag/intl/nl-NL.json","packages/@react-aria/tag/intl/pl-PL.json","packages/@react-aria/tag/intl/pt-BR.json","packages/@react-aria/tag/intl/pt-PT.json","packages/@react-aria/tag/intl/ro-RO.json","packages/@react-aria/tag/intl/ru-RU.json","packages/@react-aria/tag/intl/sk-SK.json","packages/@react-aria/tag/intl/sl-SI.json","packages/@react-aria/tag/intl/sr-SP.json","packages/@react-aria/tag/intl/sv-SE.json","packages/@react-aria/tag/intl/tr-TR.json","packages/@react-aria/tag/intl/uk-UA.json","packages/@react-aria/tag/intl/zh-CN.json","packages/@react-aria/tag/intl/zh-TW.json","packages/@react-aria/tag/src/useTagGroup.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {TagKeyboardDelegate} from './TagKeyboardDelegate';\nexport {useTag} from './useTag';\nexport {useTagGroup} from './useTagGroup';\n\nexport type {TagProps} from '@react-types/tag';\nexport type {TagGroupAria} from './useTagGroup';\nexport type {TagAria} from './useTag';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, Direction, KeyboardDelegate} from '@react-types/shared';\nimport {Key} from 'react';\n\nexport class TagKeyboardDelegate<T> implements KeyboardDelegate {\n private collection: Collection<T>;\n private direction: Direction;\n\n constructor(collection: Collection<T>, direction: Direction) {\n this.collection = collection;\n this.direction = direction;\n }\n\n getFirstKey() {\n return this.collection.getFirstKey();\n }\n\n getLastKey() {\n return this.collection.getLastKey();\n }\n \n getKeyRightOf(key: Key) {\n return this.direction === 'rtl' ? this.getKeyAbove(key) : this.getKeyBelow(key);\n }\n\n getKeyLeftOf(key: Key) {\n return this.direction === 'rtl' ? this.getKeyBelow(key) : this.getKeyAbove(key);\n }\n\n getKeyBelow(key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // Find the next item\n key = this.collection.getKeyAfter(key);\n if (key != null) {\n return key;\n } else {\n return this.collection.getFirstKey();\n }\n }\n\n getKeyAbove(key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // Find the previous item\n key = this.collection.getKeyBefore(key);\n if (key != null) {\n return key;\n } else {\n return this.collection.getLastKey();\n }\n }\n\n getKeyPageAbove(key) {\n return this.getKeyAbove(key);\n }\n\n getKeyPageBelow(key) {\n return this.getKeyBelow(key);\n }\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {chain, filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {DOMAttributes} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {KeyboardEvent} from 'react';\nimport type {TagGroupState} from '@react-stately/tag';\nimport {TagProps} from '@react-types/tag';\nimport {useGridListItem} from '@react-aria/gridlist';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\n\nexport interface TagAria {\n labelProps: DOMAttributes,\n tagProps: DOMAttributes,\n tagRowProps: DOMAttributes,\n clearButtonProps: AriaButtonProps\n}\n\n/**\n * Provides the behavior and accessibility implementation for a tag component.\n * @param props - Props to be applied to the tag.\n * @param state - State for the tag group, as returned by `useTagGroupState`.\n */\nexport function useTag<T>(props: TagProps<T>, state: TagGroupState<T>): TagAria {\n let {\n isFocused,\n allowsRemoving,\n item,\n tagRowRef\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages);\n let removeString = stringFormatter.format('remove');\n let labelId = useId();\n let buttonId = useId();\n\n let {rowProps, gridCellProps} = useGridListItem({\n node: item\n }, state, tagRowRef);\n\n // We want the group to handle keyboard navigation between tags.\n delete rowProps.onKeyDownCapture;\n\n let onRemove = chain(props.onRemove, state.onRemove);\n\n let onKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Delete' || e.key === 'Backspace' || e.key === ' ') {\n onRemove(item.key);\n e.preventDefault();\n }\n };\n\n isFocused = isFocused || state.selectionManager.focusedKey === item.key;\n let domProps = filterDOMProps(props);\n return {\n clearButtonProps: {\n 'aria-label': removeString,\n 'aria-labelledby': `${buttonId} ${labelId}`,\n id: buttonId,\n onPress: () => allowsRemoving && onRemove ? onRemove(item.key) : null\n },\n labelProps: {\n id: labelId\n },\n tagRowProps: {\n ...rowProps,\n tabIndex: (isFocused || state.selectionManager.focusedKey == null) ? 0 : -1,\n onKeyDown: allowsRemoving ? onKeyDown : null\n },\n tagProps: mergeProps(domProps, gridCellProps, {\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-label': props['aria-label']\n })\n };\n}\n","const _temp0 = require(\"./ar-AE.json\");\nconst _temp1 = require(\"./bg-BG.json\");\nconst _temp2 = require(\"./cs-CZ.json\");\nconst _temp3 = require(\"./da-DK.json\");\nconst _temp4 = require(\"./de-DE.json\");\nconst _temp5 = require(\"./el-GR.json\");\nconst _temp6 = require(\"./en-US.json\");\nconst _temp7 = require(\"./es-ES.json\");\nconst _temp8 = require(\"./et-EE.json\");\nconst _temp9 = require(\"./fi-FI.json\");\nconst _temp10 = require(\"./fr-FR.json\");\nconst _temp11 = require(\"./he-IL.json\");\nconst _temp12 = require(\"./hr-HR.json\");\nconst _temp13 = require(\"./hu-HU.json\");\nconst _temp14 = require(\"./it-IT.json\");\nconst _temp15 = require(\"./ja-JP.json\");\nconst _temp16 = require(\"./ko-KR.json\");\nconst _temp17 = require(\"./lt-LT.json\");\nconst _temp18 = require(\"./lv-LV.json\");\nconst _temp19 = require(\"./nb-NO.json\");\nconst _temp20 = require(\"./nl-NL.json\");\nconst _temp21 = require(\"./pl-PL.json\");\nconst _temp22 = require(\"./pt-BR.json\");\nconst _temp23 = require(\"./pt-PT.json\");\nconst _temp24 = require(\"./ro-RO.json\");\nconst _temp25 = require(\"./ru-RU.json\");\nconst _temp26 = require(\"./sk-SK.json\");\nconst _temp27 = require(\"./sl-SI.json\");\nconst _temp28 = require(\"./sr-SP.json\");\nconst _temp29 = require(\"./sv-SE.json\");\nconst _temp30 = require(\"./tr-TR.json\");\nconst _temp31 = require(\"./uk-UA.json\");\nconst _temp32 = require(\"./zh-CN.json\");\nconst _temp33 = require(\"./zh-TW.json\");\nmodule.exports = {\n \"ar-AE\": _temp0,\n \"bg-BG\": _temp1,\n \"cs-CZ\": _temp2,\n \"da-DK\": _temp3,\n \"de-DE\": _temp4,\n \"el-GR\": _temp5,\n \"en-US\": _temp6,\n \"es-ES\": _temp7,\n \"et-EE\": _temp8,\n \"fi-FI\": _temp9,\n \"fr-FR\": _temp10,\n \"he-IL\": _temp11,\n \"hr-HR\": _temp12,\n \"hu-HU\": _temp13,\n \"it-IT\": _temp14,\n \"ja-JP\": _temp15,\n \"ko-KR\": _temp16,\n \"lt-LT\": _temp17,\n \"lv-LV\": _temp18,\n \"nb-NO\": _temp19,\n \"nl-NL\": _temp20,\n \"pl-PL\": _temp21,\n \"pt-BR\": _temp22,\n \"pt-PT\": _temp23,\n \"ro-RO\": _temp24,\n \"ru-RU\": _temp25,\n \"sk-SK\": _temp26,\n \"sl-SI\": _temp27,\n \"sr-SP\": _temp28,\n \"sv-SE\": _temp29,\n \"tr-TR\": _temp30,\n \"uk-UA\": _temp31,\n \"zh-CN\": _temp32,\n \"zh-TW\": _temp33\n}","{\n \"remove\": \"إزالة\"\n}\n","{\n \"remove\": \"Премахване\"\n}\n","{\n \"remove\": \"Odebrat\"\n}\n","{\n \"remove\": \"Fjern\"\n}\n","{\n \"remove\": \"Entfernen\"\n}\n","{\n \"remove\": \"Κατάργηση\"\n}\n","{\n \"remove\": \"Press Space or Delete to remove tag.\"\n}\n","{\n \"remove\": \"Quitar\"\n}\n","{\n \"remove\": \"Eemalda\"\n}\n","{\n \"remove\": \"Poista\"\n}\n","{\n \"remove\": \"Supprimer\"\n}\n","{\n \"remove\": \"הסר\"\n}\n","{\n \"remove\": \"Ukloni\"\n}\n","{\n \"remove\": \"Eltávolítás\"\n}\n","{\n \"remove\": \"Rimuovi\"\n}\n","{\n \"remove\": \"削除\"\n}\n","{\n \"remove\": \"제거\"\n}\n","{\n \"remove\": \"Pašalinti\"\n}\n","{\n \"remove\": \"Noņemt\"\n}\n","{\n \"remove\": \"Fjern\"\n}\n","{\n \"remove\": \"Verwijderen\"\n}\n","{\n \"remove\": \"Usuń\"\n}\n","{\n \"remove\": \"Remover\"\n}\n","{\n \"remove\": \"Eliminar\"\n}\n","{\n \"remove\": \"Îndepărtaţi\"\n}\n","{\n \"remove\": \"Удалить\"\n}\n","{\n \"remove\": \"Odstrániť\"\n}\n","{\n \"remove\": \"Odstrani\"\n}\n","{\n \"remove\": \"Ukloni\"\n}\n","{\n \"remove\": \"Ta bort\"\n}\n","{\n \"remove\": \"Kaldır\"\n}\n","{\n \"remove\": \"Видалити\"\n}\n","{\n \"remove\": \"删除\"\n}\n","{\n \"remove\": \"移除\"\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaTagGroupProps} from '@react-types/tag';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {RefObject, useState} from 'react';\nimport type {TagGroupState} from '@react-stately/tag';\nimport {TagKeyboardDelegate} from './TagKeyboardDelegate';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useGridList} from '@react-aria/gridlist';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface TagGroupAria {\n tagGroupProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a tag group component.\n * Tags allow users to categorize content. They can represent keywords or people, and are grouped to describe an item or a search request.\n * @param props - Props to be applied to the tag group.\n * @param state - State for the tag group, as returned by `useTagGroupState`.\n * @param ref - A ref to a DOM element for the tag group.\n */\nexport function useTagGroup<T>(props: AriaTagGroupProps<T>, state: TagGroupState<T>, ref: RefObject<HTMLElement>): TagGroupAria {\n let {direction} = useLocale();\n let keyboardDelegate = new TagKeyboardDelegate(state.collection, direction);\n let {gridProps} = useGridList({...props, keyboardDelegate}, state, ref);\n\n // Don't want the grid to be focusable or accessible via keyboard\n delete gridProps.role;\n delete gridProps.tabIndex;\n\n let [isFocusWithin, setFocusWithin] = useState(false);\n let {focusWithinProps} = useFocusWithin({\n onFocusWithinChange: setFocusWithin\n });\n let domProps = filterDOMProps(props);\n return {\n tagGroupProps: mergeProps(gridProps, domProps, {\n 'aria-atomic': false,\n 'aria-relevant': 'additions',\n 'aria-live': isFocusWithin ? 'polite' : 'off',\n ...focusWithinProps\n } as DOMAttributes)\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {useLocalizedStringFormatter as $aIvin$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
1
|
+
import {useId as $aIvin$useId, chain as $aIvin$chain, filterDOMProps as $aIvin$filterDOMProps, mergeProps as $aIvin$mergeProps} from "@react-aria/utils";
|
|
2
|
+
import {useGridListItem as $aIvin$useGridListItem, useGridList as $aIvin$useGridList} from "@react-aria/gridlist";
|
|
3
|
+
import {useLocalizedStringFormatter as $aIvin$useLocalizedStringFormatter, useLocale as $aIvin$useLocale} from "@react-aria/i18n";
|
|
4
4
|
import {useState as $aIvin$useState} from "react";
|
|
5
5
|
import {useFocusWithin as $aIvin$useFocusWithin} from "@react-aria/interactions";
|
|
6
6
|
|
|
@@ -27,21 +27,12 @@ function $parcel$interopDefault(a) {
|
|
|
27
27
|
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
28
28
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
29
29
|
* governing permissions and limitations under the License.
|
|
30
|
-
*/
|
|
31
|
-
class $542448901dbd2c36$export$b00754732e683b92 extends (0, $aIvin$GridKeyboardDelegate) {
|
|
30
|
+
*/ class $542448901dbd2c36$export$b00754732e683b92 {
|
|
32
31
|
getFirstKey() {
|
|
33
|
-
|
|
34
|
-
let item = this.collection.getItem(key);
|
|
35
|
-
return [
|
|
36
|
-
...item.childNodes
|
|
37
|
-
][0].key;
|
|
32
|
+
return this.collection.getFirstKey();
|
|
38
33
|
}
|
|
39
34
|
getLastKey() {
|
|
40
|
-
|
|
41
|
-
let item = this.collection.getItem(key);
|
|
42
|
-
return [
|
|
43
|
-
...item.childNodes
|
|
44
|
-
][0].key;
|
|
35
|
+
return this.collection.getLastKey();
|
|
45
36
|
}
|
|
46
37
|
getKeyRightOf(key) {
|
|
47
38
|
return this.direction === "rtl" ? this.getKeyAbove(key) : this.getKeyBelow(key);
|
|
@@ -52,40 +43,18 @@ class $542448901dbd2c36$export$b00754732e683b92 extends (0, $aIvin$GridKeyboardD
|
|
|
52
43
|
getKeyBelow(key) {
|
|
53
44
|
let startItem = this.collection.getItem(key);
|
|
54
45
|
if (!startItem) return;
|
|
55
|
-
// If focus was on a cell, start searching from the parent row
|
|
56
|
-
if (this.isCell(startItem)) key = startItem.parentKey;
|
|
57
46
|
// Find the next item
|
|
58
|
-
key = this.
|
|
59
|
-
if (key != null)
|
|
60
|
-
|
|
61
|
-
if (this.isCell(startItem)) {
|
|
62
|
-
let item = this.collection.getItem(key);
|
|
63
|
-
return [
|
|
64
|
-
...item.childNodes
|
|
65
|
-
][startItem.index].key;
|
|
66
|
-
}
|
|
67
|
-
// Otherwise, focus the next row
|
|
68
|
-
if (this.focusMode === "row") return key;
|
|
69
|
-
} else return this.getFirstKey();
|
|
47
|
+
key = this.collection.getKeyAfter(key);
|
|
48
|
+
if (key != null) return key;
|
|
49
|
+
else return this.collection.getFirstKey();
|
|
70
50
|
}
|
|
71
51
|
getKeyAbove(key) {
|
|
72
52
|
let startItem = this.collection.getItem(key);
|
|
73
53
|
if (!startItem) return;
|
|
74
|
-
// If focus is on a cell, start searching from the parent row
|
|
75
|
-
if (this.isCell(startItem)) key = startItem.parentKey;
|
|
76
54
|
// Find the previous item
|
|
77
|
-
key = this.
|
|
78
|
-
if (key != null)
|
|
79
|
-
|
|
80
|
-
if (this.isCell(startItem)) {
|
|
81
|
-
let item = this.collection.getItem(key);
|
|
82
|
-
return [
|
|
83
|
-
...item.childNodes
|
|
84
|
-
][startItem.index].key;
|
|
85
|
-
}
|
|
86
|
-
// Otherwise, focus the previous row
|
|
87
|
-
if (this.focusMode === "row") return key;
|
|
88
|
-
} else return this.getLastKey();
|
|
55
|
+
key = this.collection.getKeyBefore(key);
|
|
56
|
+
if (key != null) return key;
|
|
57
|
+
else return this.collection.getLastKey();
|
|
89
58
|
}
|
|
90
59
|
getKeyPageAbove(key) {
|
|
91
60
|
return this.getKeyAbove(key);
|
|
@@ -93,6 +62,10 @@ class $542448901dbd2c36$export$b00754732e683b92 extends (0, $aIvin$GridKeyboardD
|
|
|
93
62
|
getKeyPageBelow(key) {
|
|
94
63
|
return this.getKeyBelow(key);
|
|
95
64
|
}
|
|
65
|
+
constructor(collection, direction){
|
|
66
|
+
this.collection = collection;
|
|
67
|
+
this.direction = direction;
|
|
68
|
+
}
|
|
96
69
|
}
|
|
97
70
|
|
|
98
71
|
|
|
@@ -146,7 +119,7 @@ $3618d917e503a8d3$exports = {
|
|
|
146
119
|
|
|
147
120
|
var $9eb56bbbe8e31294$exports = {};
|
|
148
121
|
$9eb56bbbe8e31294$exports = {
|
|
149
|
-
"remove": `
|
|
122
|
+
"remove": `Press Space or Delete to remove tag.`
|
|
150
123
|
};
|
|
151
124
|
|
|
152
125
|
|
|
@@ -353,52 +326,43 @@ $4d1b62e0e67c00a4$exports = {
|
|
|
353
326
|
|
|
354
327
|
|
|
355
328
|
function $fc6126c82a4601f1$export$3f568fff7dff2f03(props, state) {
|
|
356
|
-
let { isFocused: isFocused } = props;
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
let { rowProps: rowProps } = (0, $aIvin$useGridRow)({
|
|
329
|
+
let { isFocused: isFocused , allowsRemoving: allowsRemoving , item: item , tagRowRef: tagRowRef } = props;
|
|
330
|
+
let stringFormatter = (0, $aIvin$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($4d1b62e0e67c00a4$exports))));
|
|
331
|
+
let removeString = stringFormatter.format("remove");
|
|
332
|
+
let labelId = (0, $aIvin$useId)();
|
|
333
|
+
let buttonId = (0, $aIvin$useId)();
|
|
334
|
+
let { rowProps: rowProps , gridCellProps: gridCellProps } = (0, $aIvin$useGridListItem)({
|
|
363
335
|
node: item
|
|
364
336
|
}, state, tagRowRef);
|
|
365
|
-
//
|
|
366
|
-
|
|
367
|
-
let
|
|
368
|
-
let
|
|
369
|
-
node: [
|
|
370
|
-
...item.childNodes
|
|
371
|
-
][0],
|
|
372
|
-
focusMode: "cell"
|
|
373
|
-
}, state, tagRef);
|
|
374
|
-
function onKeyDown(e) {
|
|
337
|
+
// We want the group to handle keyboard navigation between tags.
|
|
338
|
+
delete rowProps.onKeyDownCapture;
|
|
339
|
+
let onRemove = (0, $aIvin$chain)(props.onRemove, state.onRemove);
|
|
340
|
+
let onKeyDown = (e)=>{
|
|
375
341
|
if (e.key === "Delete" || e.key === "Backspace" || e.key === " ") {
|
|
376
|
-
onRemove(item.
|
|
342
|
+
onRemove(item.key);
|
|
377
343
|
e.preventDefault();
|
|
378
344
|
}
|
|
379
|
-
}
|
|
380
|
-
const pressProps = {
|
|
381
|
-
onPress: ()=>{
|
|
382
|
-
return onRemove === null || onRemove === void 0 ? void 0 : onRemove(item.childNodes[0].key);
|
|
383
|
-
}
|
|
384
345
|
};
|
|
385
|
-
isFocused = isFocused || state.selectionManager.focusedKey === item.
|
|
346
|
+
isFocused = isFocused || state.selectionManager.focusedKey === item.key;
|
|
386
347
|
let domProps = (0, $aIvin$filterDOMProps)(props);
|
|
387
348
|
return {
|
|
388
|
-
clearButtonProps:
|
|
349
|
+
clearButtonProps: {
|
|
389
350
|
"aria-label": removeString,
|
|
390
351
|
"aria-labelledby": `${buttonId} ${labelId}`,
|
|
391
|
-
id: buttonId
|
|
392
|
-
|
|
352
|
+
id: buttonId,
|
|
353
|
+
onPress: ()=>allowsRemoving && onRemove ? onRemove(item.key) : null
|
|
354
|
+
},
|
|
393
355
|
labelProps: {
|
|
394
356
|
id: labelId
|
|
395
357
|
},
|
|
396
|
-
tagRowProps:
|
|
358
|
+
tagRowProps: {
|
|
359
|
+
...rowProps,
|
|
360
|
+
tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,
|
|
361
|
+
onKeyDown: allowsRemoving ? onKeyDown : null
|
|
362
|
+
},
|
|
397
363
|
tagProps: (0, $aIvin$mergeProps)(domProps, gridCellProps, {
|
|
398
364
|
"aria-errormessage": props["aria-errormessage"],
|
|
399
|
-
"aria-label": props["aria-label"]
|
|
400
|
-
onKeyDown: allowsRemoving ? onKeyDown : null,
|
|
401
|
-
tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1
|
|
365
|
+
"aria-label": props["aria-label"]
|
|
402
366
|
})
|
|
403
367
|
};
|
|
404
368
|
}
|
|
@@ -417,14 +381,26 @@ function $fc6126c82a4601f1$export$3f568fff7dff2f03(props, state) {
|
|
|
417
381
|
*/
|
|
418
382
|
|
|
419
383
|
|
|
420
|
-
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
function $d7323bca8d074eeb$export$4f8b5cda58b7e8ff(props, state, ref) {
|
|
388
|
+
let { direction: direction } = (0, $aIvin$useLocale)();
|
|
389
|
+
let keyboardDelegate = new (0, $542448901dbd2c36$export$b00754732e683b92)(state.collection, direction);
|
|
390
|
+
let { gridProps: gridProps } = (0, $aIvin$useGridList)({
|
|
391
|
+
...props,
|
|
392
|
+
keyboardDelegate: keyboardDelegate
|
|
393
|
+
}, state, ref);
|
|
394
|
+
// Don't want the grid to be focusable or accessible via keyboard
|
|
395
|
+
delete gridProps.role;
|
|
396
|
+
delete gridProps.tabIndex;
|
|
421
397
|
let [isFocusWithin, setFocusWithin] = (0, $aIvin$useState)(false);
|
|
422
398
|
let { focusWithinProps: focusWithinProps } = (0, $aIvin$useFocusWithin)({
|
|
423
399
|
onFocusWithinChange: setFocusWithin
|
|
424
400
|
});
|
|
425
401
|
let domProps = (0, $aIvin$filterDOMProps)(props);
|
|
426
402
|
return {
|
|
427
|
-
tagGroupProps: (0, $aIvin$mergeProps)(domProps, {
|
|
403
|
+
tagGroupProps: (0, $aIvin$mergeProps)(gridProps, domProps, {
|
|
428
404
|
"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C,iBAAgB,EAAC,GAAG,CAAA,GAAA,qBAAc,AAAD,EAAE;QACtC,qBAAqB;IACvB;IACA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE;IAC9B,OAAO;QACL,eAAe,CAAA,GAAA,iBAAU,AAAD,EAAE,UAAU;YAClC,eAAe,KAAK;YACpB,iBAAiB;YACjB,aAAa,gBAAgB,WAAW,KAAK;YAC7C,GAAG,gBAAgB;QACrB;IACF;AACF;;","sources":["packages/@react-aria/tag/src/index.ts","packages/@react-aria/tag/src/TagKeyboardDelegate.ts","packages/@react-aria/tag/src/useTag.ts","packages/@react-aria/tag/intl/*.js","packages/@react-aria/tag/intl/ar-AE.json","packages/@react-aria/tag/intl/bg-BG.json","packages/@react-aria/tag/intl/cs-CZ.json","packages/@react-aria/tag/intl/da-DK.json","packages/@react-aria/tag/intl/de-DE.json","packages/@react-aria/tag/intl/el-GR.json","packages/@react-aria/tag/intl/en-US.json","packages/@react-aria/tag/intl/es-ES.json","packages/@react-aria/tag/intl/et-EE.json","packages/@react-aria/tag/intl/fi-FI.json","packages/@react-aria/tag/intl/fr-FR.json","packages/@react-aria/tag/intl/he-IL.json","packages/@react-aria/tag/intl/hr-HR.json","packages/@react-aria/tag/intl/hu-HU.json","packages/@react-aria/tag/intl/it-IT.json","packages/@react-aria/tag/intl/ja-JP.json","packages/@react-aria/tag/intl/ko-KR.json","packages/@react-aria/tag/intl/lt-LT.json","packages/@react-aria/tag/intl/lv-LV.json","packages/@react-aria/tag/intl/nb-NO.json","packages/@react-aria/tag/intl/nl-NL.json","packages/@react-aria/tag/intl/pl-PL.json","packages/@react-aria/tag/intl/pt-BR.json","packages/@react-aria/tag/intl/pt-PT.json","packages/@react-aria/tag/intl/ro-RO.json","packages/@react-aria/tag/intl/ru-RU.json","packages/@react-aria/tag/intl/sk-SK.json","packages/@react-aria/tag/intl/sl-SI.json","packages/@react-aria/tag/intl/sr-SP.json","packages/@react-aria/tag/intl/sv-SE.json","packages/@react-aria/tag/intl/tr-TR.json","packages/@react-aria/tag/intl/uk-UA.json","packages/@react-aria/tag/intl/zh-CN.json","packages/@react-aria/tag/intl/zh-TW.json","packages/@react-aria/tag/src/useTagGroup.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {TagKeyboardDelegate} from './TagKeyboardDelegate';\nexport {useTag} from './useTag';\nexport {useTagGroup} from './useTagGroup';\n\nexport type {TagProps} from '@react-types/tag';\nexport type {AriaTagGroupProps, TagGroupAria} from './useTagGroup';\nexport type {TagAria} from './useTag';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {GridCollection} from '@react-types/grid';\nimport {GridKeyboardDelegate} from '@react-aria/grid';\nimport {Key} from 'react';\n\nexport class TagKeyboardDelegate<T> extends GridKeyboardDelegate<T, GridCollection<T>> {\n getFirstKey() {\n let key = this.collection.getFirstKey();\n let item = this.collection.getItem(key);\n\n return [...item.childNodes][0].key;\n }\n\n getLastKey() {\n let key = this.collection.getLastKey();\n let item = this.collection.getItem(key);\n\n return [...item.childNodes][0].key;\n }\n\n getKeyRightOf(key: Key) {\n return this.direction === 'rtl' ? this.getKeyAbove(key) : this.getKeyBelow(key);\n }\n\n getKeyLeftOf(key: Key) {\n return this.direction === 'rtl' ? this.getKeyBelow(key) : this.getKeyAbove(key);\n }\n\n getKeyBelow(key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // If focus was on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey;\n }\n\n // Find the next item\n key = this.findNextKey(key);\n if (key != null) {\n // If focus was on a cell, focus the cell with the same index in the next row.\n if (this.isCell(startItem)) {\n let item = this.collection.getItem(key);\n\n return [...item.childNodes][startItem.index].key;\n }\n\n // Otherwise, focus the next row\n if (this.focusMode === 'row') {\n return key;\n }\n } else {\n return this.getFirstKey();\n }\n }\n\n getKeyAbove(key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // If focus is on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey;\n }\n\n // Find the previous item\n key = this.findPreviousKey(key);\n if (key != null) {\n // If focus was on a cell, focus the cell with the same index in the previous row.\n if (this.isCell(startItem)) {\n let item = this.collection.getItem(key);\n return [...item.childNodes][startItem.index].key;\n }\n\n // Otherwise, focus the previous row\n if (this.focusMode === 'row') {\n return key;\n }\n } else {\n return this.getLastKey();\n }\n }\n\n getKeyPageAbove(key) {\n return this.getKeyAbove(key);\n }\n\n getKeyPageBelow(key) {\n return this.getKeyBelow(key);\n }\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ButtonHTMLAttributes, KeyboardEvent} from 'react';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {GridState} from '@react-stately/grid';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {TagProps} from '@react-types/tag';\nimport {useGridCell, useGridRow} from '@react-aria/grid';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\n\nexport interface TagAria {\n labelProps: DOMAttributes,\n tagProps: DOMAttributes,\n tagRowProps: DOMAttributes,\n clearButtonProps: ButtonHTMLAttributes<HTMLButtonElement>\n}\n\nexport function useTag(props: TagProps<any>, state: GridState<any, any>): TagAria {\n let {isFocused} = props;\n const {\n allowsRemoving,\n onRemove,\n item,\n tagRef,\n tagRowRef\n } = props;\n const stringFormatter = useLocalizedStringFormatter(intlMessages);\n const removeString = stringFormatter.format('remove');\n const labelId = useId();\n const buttonId = useId();\n\n let {rowProps} = useGridRow({\n node: item\n }, state, tagRowRef);\n // Don't want the row to be focusable or accessible via keyboard\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n let {tabIndex, ...otherRowProps} = rowProps;\n\n let {gridCellProps} = useGridCell({\n node: [...item.childNodes][0],\n focusMode: 'cell'\n }, state, tagRef);\n\n function onKeyDown(e: KeyboardEvent) {\n if (e.key === 'Delete' || e.key === 'Backspace' || e.key === ' ') {\n onRemove(item.childNodes[0].key);\n e.preventDefault();\n }\n }\n const pressProps = {\n onPress: () => onRemove?.(item.childNodes[0].key)\n };\n\n isFocused = isFocused || state.selectionManager.focusedKey === item.childNodes[0].key;\n let domProps = filterDOMProps(props);\n return {\n clearButtonProps: mergeProps(pressProps, {\n 'aria-label': removeString,\n 'aria-labelledby': `${buttonId} ${labelId}`,\n id: buttonId\n }),\n labelProps: {\n id: labelId\n },\n tagRowProps: otherRowProps,\n tagProps: mergeProps(domProps, gridCellProps, {\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-label': props['aria-label'],\n onKeyDown: allowsRemoving ? onKeyDown : null,\n tabIndex: (isFocused || state.selectionManager.focusedKey == null) ? 0 : -1\n })\n };\n}\n","const _temp0 = require(\"./ar-AE.json\");\nconst _temp1 = require(\"./bg-BG.json\");\nconst _temp2 = require(\"./cs-CZ.json\");\nconst _temp3 = require(\"./da-DK.json\");\nconst _temp4 = require(\"./de-DE.json\");\nconst _temp5 = require(\"./el-GR.json\");\nconst _temp6 = require(\"./en-US.json\");\nconst _temp7 = require(\"./es-ES.json\");\nconst _temp8 = require(\"./et-EE.json\");\nconst _temp9 = require(\"./fi-FI.json\");\nconst _temp10 = require(\"./fr-FR.json\");\nconst _temp11 = require(\"./he-IL.json\");\nconst _temp12 = require(\"./hr-HR.json\");\nconst _temp13 = require(\"./hu-HU.json\");\nconst _temp14 = require(\"./it-IT.json\");\nconst _temp15 = require(\"./ja-JP.json\");\nconst _temp16 = require(\"./ko-KR.json\");\nconst _temp17 = require(\"./lt-LT.json\");\nconst _temp18 = require(\"./lv-LV.json\");\nconst _temp19 = require(\"./nb-NO.json\");\nconst _temp20 = require(\"./nl-NL.json\");\nconst _temp21 = require(\"./pl-PL.json\");\nconst _temp22 = require(\"./pt-BR.json\");\nconst _temp23 = require(\"./pt-PT.json\");\nconst _temp24 = require(\"./ro-RO.json\");\nconst _temp25 = require(\"./ru-RU.json\");\nconst _temp26 = require(\"./sk-SK.json\");\nconst _temp27 = require(\"./sl-SI.json\");\nconst _temp28 = require(\"./sr-SP.json\");\nconst _temp29 = require(\"./sv-SE.json\");\nconst _temp30 = require(\"./tr-TR.json\");\nconst _temp31 = require(\"./uk-UA.json\");\nconst _temp32 = require(\"./zh-CN.json\");\nconst _temp33 = require(\"./zh-TW.json\");\nmodule.exports = {\n \"ar-AE\": _temp0,\n \"bg-BG\": _temp1,\n \"cs-CZ\": _temp2,\n \"da-DK\": _temp3,\n \"de-DE\": _temp4,\n \"el-GR\": _temp5,\n \"en-US\": _temp6,\n \"es-ES\": _temp7,\n \"et-EE\": _temp8,\n \"fi-FI\": _temp9,\n \"fr-FR\": _temp10,\n \"he-IL\": _temp11,\n \"hr-HR\": _temp12,\n \"hu-HU\": _temp13,\n \"it-IT\": _temp14,\n \"ja-JP\": _temp15,\n \"ko-KR\": _temp16,\n \"lt-LT\": _temp17,\n \"lv-LV\": _temp18,\n \"nb-NO\": _temp19,\n \"nl-NL\": _temp20,\n \"pl-PL\": _temp21,\n \"pt-BR\": _temp22,\n \"pt-PT\": _temp23,\n \"ro-RO\": _temp24,\n \"ru-RU\": _temp25,\n \"sk-SK\": _temp26,\n \"sl-SI\": _temp27,\n \"sr-SP\": _temp28,\n \"sv-SE\": _temp29,\n \"tr-TR\": _temp30,\n \"uk-UA\": _temp31,\n \"zh-CN\": _temp32,\n \"zh-TW\": _temp33\n}","{\n \"remove\": \"إزالة\"\n}\n","{\n \"remove\": \"Премахване\"\n}\n","{\n \"remove\": \"Odebrat\"\n}\n","{\n \"remove\": \"Fjern\"\n}\n","{\n \"remove\": \"Entfernen\"\n}\n","{\n \"remove\": \"Κατάργηση\"\n}\n","{\n \"remove\": \"Remove\"\n}\n","{\n \"remove\": \"Quitar\"\n}\n","{\n \"remove\": \"Eemalda\"\n}\n","{\n \"remove\": \"Poista\"\n}\n","{\n \"remove\": \"Supprimer\"\n}\n","{\n \"remove\": \"הסר\"\n}\n","{\n \"remove\": \"Ukloni\"\n}\n","{\n \"remove\": \"Eltávolítás\"\n}\n","{\n \"remove\": \"Rimuovi\"\n}\n","{\n \"remove\": \"削除\"\n}\n","{\n \"remove\": \"제거\"\n}\n","{\n \"remove\": \"Pašalinti\"\n}\n","{\n \"remove\": \"Noņemt\"\n}\n","{\n \"remove\": \"Fjern\"\n}\n","{\n \"remove\": \"Verwijderen\"\n}\n","{\n \"remove\": \"Usuń\"\n}\n","{\n \"remove\": \"Remover\"\n}\n","{\n \"remove\": \"Eliminar\"\n}\n","{\n \"remove\": \"Îndepărtaţi\"\n}\n","{\n \"remove\": \"Удалить\"\n}\n","{\n \"remove\": \"Odstrániť\"\n}\n","{\n \"remove\": \"Odstrani\"\n}\n","{\n \"remove\": \"Ukloni\"\n}\n","{\n \"remove\": \"Ta bort\"\n}\n","{\n \"remove\": \"Kaldır\"\n}\n","{\n \"remove\": \"Видалити\"\n}\n","{\n \"remove\": \"删除\"\n}\n","{\n \"remove\": \"移除\"\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, DOMProps} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {ReactNode, useState} from 'react';\nimport {useFocusWithin} from '@react-aria/interactions';\n\nexport interface AriaTagGroupProps extends DOMProps {\n children: ReactNode,\n isReadOnly?: boolean, // removes close button\n validationState?: 'valid' | 'invalid'\n}\n\nexport interface TagGroupAria {\n tagGroupProps: DOMAttributes\n}\n\nexport function useTagGroup(props: AriaTagGroupProps): TagGroupAria {\n let [isFocusWithin, setFocusWithin] = useState(false);\n let {focusWithinProps} = useFocusWithin({\n onFocusWithinChange: setFocusWithin\n });\n let domProps = filterDOMProps(props);\n return {\n tagGroupProps: mergeProps(domProps, {\n 'aria-atomic': false,\n 'aria-relevant': 'additions',\n 'aria-live': isFocusWithin ? 'polite' : 'off',\n ...focusWithinProps\n } as DOMAttributes)\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED,AAGO,MAAM;IASX,cAAc;QACZ,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW;IACpC;IAEA,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU;IACnC;IAEA,cAAc,GAAQ,EAAE;QACtB,OAAO,IAAI,CAAC,SAAS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,iEAAiE;IACjE,OAAO,UAAU,IAAI;IACrB,OAAO,UAAU,QAAQ;IAEzB,IAAI,CAAC,eAAe,eAAe,GAAG,CAAA,GAAA,eAAO,EAAE,KAAK;IACpD,IAAI,oBAAC,iBAAgB,EAAC,GAAG,CAAA,GAAA,qBAAc,AAAD,EAAE;QACtC,qBAAqB;IACvB;IACA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE;IAC9B,OAAO;QACL,eAAe,CAAA,GAAA,iBAAU,AAAD,EAAE,WAAW,UAAU;YAC7C,eAAe,KAAK;YACpB,iBAAiB;YACjB,aAAa,gBAAgB,WAAW,KAAK;YAC7C,GAAG,gBAAgB;QACrB;IACF;AACF;;","sources":["packages/@react-aria/tag/src/index.ts","packages/@react-aria/tag/src/TagKeyboardDelegate.ts","packages/@react-aria/tag/src/useTag.ts","packages/@react-aria/tag/intl/*.js","packages/@react-aria/tag/intl/ar-AE.json","packages/@react-aria/tag/intl/bg-BG.json","packages/@react-aria/tag/intl/cs-CZ.json","packages/@react-aria/tag/intl/da-DK.json","packages/@react-aria/tag/intl/de-DE.json","packages/@react-aria/tag/intl/el-GR.json","packages/@react-aria/tag/intl/en-US.json","packages/@react-aria/tag/intl/es-ES.json","packages/@react-aria/tag/intl/et-EE.json","packages/@react-aria/tag/intl/fi-FI.json","packages/@react-aria/tag/intl/fr-FR.json","packages/@react-aria/tag/intl/he-IL.json","packages/@react-aria/tag/intl/hr-HR.json","packages/@react-aria/tag/intl/hu-HU.json","packages/@react-aria/tag/intl/it-IT.json","packages/@react-aria/tag/intl/ja-JP.json","packages/@react-aria/tag/intl/ko-KR.json","packages/@react-aria/tag/intl/lt-LT.json","packages/@react-aria/tag/intl/lv-LV.json","packages/@react-aria/tag/intl/nb-NO.json","packages/@react-aria/tag/intl/nl-NL.json","packages/@react-aria/tag/intl/pl-PL.json","packages/@react-aria/tag/intl/pt-BR.json","packages/@react-aria/tag/intl/pt-PT.json","packages/@react-aria/tag/intl/ro-RO.json","packages/@react-aria/tag/intl/ru-RU.json","packages/@react-aria/tag/intl/sk-SK.json","packages/@react-aria/tag/intl/sl-SI.json","packages/@react-aria/tag/intl/sr-SP.json","packages/@react-aria/tag/intl/sv-SE.json","packages/@react-aria/tag/intl/tr-TR.json","packages/@react-aria/tag/intl/uk-UA.json","packages/@react-aria/tag/intl/zh-CN.json","packages/@react-aria/tag/intl/zh-TW.json","packages/@react-aria/tag/src/useTagGroup.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {TagKeyboardDelegate} from './TagKeyboardDelegate';\nexport {useTag} from './useTag';\nexport {useTagGroup} from './useTagGroup';\n\nexport type {TagProps} from '@react-types/tag';\nexport type {TagGroupAria} from './useTagGroup';\nexport type {TagAria} from './useTag';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, Direction, KeyboardDelegate} from '@react-types/shared';\nimport {Key} from 'react';\n\nexport class TagKeyboardDelegate<T> implements KeyboardDelegate {\n private collection: Collection<T>;\n private direction: Direction;\n\n constructor(collection: Collection<T>, direction: Direction) {\n this.collection = collection;\n this.direction = direction;\n }\n\n getFirstKey() {\n return this.collection.getFirstKey();\n }\n\n getLastKey() {\n return this.collection.getLastKey();\n }\n \n getKeyRightOf(key: Key) {\n return this.direction === 'rtl' ? this.getKeyAbove(key) : this.getKeyBelow(key);\n }\n\n getKeyLeftOf(key: Key) {\n return this.direction === 'rtl' ? this.getKeyBelow(key) : this.getKeyAbove(key);\n }\n\n getKeyBelow(key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // Find the next item\n key = this.collection.getKeyAfter(key);\n if (key != null) {\n return key;\n } else {\n return this.collection.getFirstKey();\n }\n }\n\n getKeyAbove(key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // Find the previous item\n key = this.collection.getKeyBefore(key);\n if (key != null) {\n return key;\n } else {\n return this.collection.getLastKey();\n }\n }\n\n getKeyPageAbove(key) {\n return this.getKeyAbove(key);\n }\n\n getKeyPageBelow(key) {\n return this.getKeyBelow(key);\n }\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {chain, filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {DOMAttributes} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {KeyboardEvent} from 'react';\nimport type {TagGroupState} from '@react-stately/tag';\nimport {TagProps} from '@react-types/tag';\nimport {useGridListItem} from '@react-aria/gridlist';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\n\nexport interface TagAria {\n labelProps: DOMAttributes,\n tagProps: DOMAttributes,\n tagRowProps: DOMAttributes,\n clearButtonProps: AriaButtonProps\n}\n\n/**\n * Provides the behavior and accessibility implementation for a tag component.\n * @param props - Props to be applied to the tag.\n * @param state - State for the tag group, as returned by `useTagGroupState`.\n */\nexport function useTag<T>(props: TagProps<T>, state: TagGroupState<T>): TagAria {\n let {\n isFocused,\n allowsRemoving,\n item,\n tagRowRef\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages);\n let removeString = stringFormatter.format('remove');\n let labelId = useId();\n let buttonId = useId();\n\n let {rowProps, gridCellProps} = useGridListItem({\n node: item\n }, state, tagRowRef);\n\n // We want the group to handle keyboard navigation between tags.\n delete rowProps.onKeyDownCapture;\n\n let onRemove = chain(props.onRemove, state.onRemove);\n\n let onKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Delete' || e.key === 'Backspace' || e.key === ' ') {\n onRemove(item.key);\n e.preventDefault();\n }\n };\n\n isFocused = isFocused || state.selectionManager.focusedKey === item.key;\n let domProps = filterDOMProps(props);\n return {\n clearButtonProps: {\n 'aria-label': removeString,\n 'aria-labelledby': `${buttonId} ${labelId}`,\n id: buttonId,\n onPress: () => allowsRemoving && onRemove ? onRemove(item.key) : null\n },\n labelProps: {\n id: labelId\n },\n tagRowProps: {\n ...rowProps,\n tabIndex: (isFocused || state.selectionManager.focusedKey == null) ? 0 : -1,\n onKeyDown: allowsRemoving ? onKeyDown : null\n },\n tagProps: mergeProps(domProps, gridCellProps, {\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-label': props['aria-label']\n })\n };\n}\n","const _temp0 = require(\"./ar-AE.json\");\nconst _temp1 = require(\"./bg-BG.json\");\nconst _temp2 = require(\"./cs-CZ.json\");\nconst _temp3 = require(\"./da-DK.json\");\nconst _temp4 = require(\"./de-DE.json\");\nconst _temp5 = require(\"./el-GR.json\");\nconst _temp6 = require(\"./en-US.json\");\nconst _temp7 = require(\"./es-ES.json\");\nconst _temp8 = require(\"./et-EE.json\");\nconst _temp9 = require(\"./fi-FI.json\");\nconst _temp10 = require(\"./fr-FR.json\");\nconst _temp11 = require(\"./he-IL.json\");\nconst _temp12 = require(\"./hr-HR.json\");\nconst _temp13 = require(\"./hu-HU.json\");\nconst _temp14 = require(\"./it-IT.json\");\nconst _temp15 = require(\"./ja-JP.json\");\nconst _temp16 = require(\"./ko-KR.json\");\nconst _temp17 = require(\"./lt-LT.json\");\nconst _temp18 = require(\"./lv-LV.json\");\nconst _temp19 = require(\"./nb-NO.json\");\nconst _temp20 = require(\"./nl-NL.json\");\nconst _temp21 = require(\"./pl-PL.json\");\nconst _temp22 = require(\"./pt-BR.json\");\nconst _temp23 = require(\"./pt-PT.json\");\nconst _temp24 = require(\"./ro-RO.json\");\nconst _temp25 = require(\"./ru-RU.json\");\nconst _temp26 = require(\"./sk-SK.json\");\nconst _temp27 = require(\"./sl-SI.json\");\nconst _temp28 = require(\"./sr-SP.json\");\nconst _temp29 = require(\"./sv-SE.json\");\nconst _temp30 = require(\"./tr-TR.json\");\nconst _temp31 = require(\"./uk-UA.json\");\nconst _temp32 = require(\"./zh-CN.json\");\nconst _temp33 = require(\"./zh-TW.json\");\nmodule.exports = {\n \"ar-AE\": _temp0,\n \"bg-BG\": _temp1,\n \"cs-CZ\": _temp2,\n \"da-DK\": _temp3,\n \"de-DE\": _temp4,\n \"el-GR\": _temp5,\n \"en-US\": _temp6,\n \"es-ES\": _temp7,\n \"et-EE\": _temp8,\n \"fi-FI\": _temp9,\n \"fr-FR\": _temp10,\n \"he-IL\": _temp11,\n \"hr-HR\": _temp12,\n \"hu-HU\": _temp13,\n \"it-IT\": _temp14,\n \"ja-JP\": _temp15,\n \"ko-KR\": _temp16,\n \"lt-LT\": _temp17,\n \"lv-LV\": _temp18,\n \"nb-NO\": _temp19,\n \"nl-NL\": _temp20,\n \"pl-PL\": _temp21,\n \"pt-BR\": _temp22,\n \"pt-PT\": _temp23,\n \"ro-RO\": _temp24,\n \"ru-RU\": _temp25,\n \"sk-SK\": _temp26,\n \"sl-SI\": _temp27,\n \"sr-SP\": _temp28,\n \"sv-SE\": _temp29,\n \"tr-TR\": _temp30,\n \"uk-UA\": _temp31,\n \"zh-CN\": _temp32,\n \"zh-TW\": _temp33\n}","{\n \"remove\": \"إزالة\"\n}\n","{\n \"remove\": \"Премахване\"\n}\n","{\n \"remove\": \"Odebrat\"\n}\n","{\n \"remove\": \"Fjern\"\n}\n","{\n \"remove\": \"Entfernen\"\n}\n","{\n \"remove\": \"Κατάργηση\"\n}\n","{\n \"remove\": \"Press Space or Delete to remove tag.\"\n}\n","{\n \"remove\": \"Quitar\"\n}\n","{\n \"remove\": \"Eemalda\"\n}\n","{\n \"remove\": \"Poista\"\n}\n","{\n \"remove\": \"Supprimer\"\n}\n","{\n \"remove\": \"הסר\"\n}\n","{\n \"remove\": \"Ukloni\"\n}\n","{\n \"remove\": \"Eltávolítás\"\n}\n","{\n \"remove\": \"Rimuovi\"\n}\n","{\n \"remove\": \"削除\"\n}\n","{\n \"remove\": \"제거\"\n}\n","{\n \"remove\": \"Pašalinti\"\n}\n","{\n \"remove\": \"Noņemt\"\n}\n","{\n \"remove\": \"Fjern\"\n}\n","{\n \"remove\": \"Verwijderen\"\n}\n","{\n \"remove\": \"Usuń\"\n}\n","{\n \"remove\": \"Remover\"\n}\n","{\n \"remove\": \"Eliminar\"\n}\n","{\n \"remove\": \"Îndepărtaţi\"\n}\n","{\n \"remove\": \"Удалить\"\n}\n","{\n \"remove\": \"Odstrániť\"\n}\n","{\n \"remove\": \"Odstrani\"\n}\n","{\n \"remove\": \"Ukloni\"\n}\n","{\n \"remove\": \"Ta bort\"\n}\n","{\n \"remove\": \"Kaldır\"\n}\n","{\n \"remove\": \"Видалити\"\n}\n","{\n \"remove\": \"删除\"\n}\n","{\n \"remove\": \"移除\"\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaTagGroupProps} from '@react-types/tag';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {RefObject, useState} from 'react';\nimport type {TagGroupState} from '@react-stately/tag';\nimport {TagKeyboardDelegate} from './TagKeyboardDelegate';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useGridList} from '@react-aria/gridlist';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface TagGroupAria {\n tagGroupProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a tag group component.\n * Tags allow users to categorize content. They can represent keywords or people, and are grouped to describe an item or a search request.\n * @param props - Props to be applied to the tag group.\n * @param state - State for the tag group, as returned by `useTagGroupState`.\n * @param ref - A ref to a DOM element for the tag group.\n */\nexport function useTagGroup<T>(props: AriaTagGroupProps<T>, state: TagGroupState<T>, ref: RefObject<HTMLElement>): TagGroupAria {\n let {direction} = useLocale();\n let keyboardDelegate = new TagKeyboardDelegate(state.collection, direction);\n let {gridProps} = useGridList({...props, keyboardDelegate}, state, ref);\n\n // Don't want the grid to be focusable or accessible via keyboard\n delete gridProps.role;\n delete gridProps.tabIndex;\n\n let [isFocusWithin, setFocusWithin] = useState(false);\n let {focusWithinProps} = useFocusWithin({\n onFocusWithinChange: setFocusWithin\n });\n let domProps = filterDOMProps(props);\n return {\n tagGroupProps: mergeProps(gridProps, domProps, {\n 'aria-atomic': false,\n 'aria-relevant': 'additions',\n 'aria-live': isFocusWithin ? 'polite' : 'off',\n ...focusWithinProps\n } as DOMAttributes)\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { Collection, Direction, KeyboardDelegate, DOMAttributes } from "@react-types/shared";
|
|
2
|
+
import { Key, RefObject } from "react";
|
|
3
|
+
import { AriaButtonProps } from "@react-types/button";
|
|
4
|
+
import { TagGroupState } from "@react-stately/tag";
|
|
5
|
+
import { TagProps, AriaTagGroupProps } from "@react-types/tag";
|
|
6
|
+
export class TagKeyboardDelegate<T> implements KeyboardDelegate {
|
|
7
|
+
constructor(collection: Collection<T>, direction: Direction);
|
|
8
8
|
getFirstKey(): Key;
|
|
9
9
|
getLastKey(): Key;
|
|
10
10
|
getKeyRightOf(key: Key): any;
|
|
@@ -18,18 +18,25 @@ export interface TagAria {
|
|
|
18
18
|
labelProps: DOMAttributes;
|
|
19
19
|
tagProps: DOMAttributes;
|
|
20
20
|
tagRowProps: DOMAttributes;
|
|
21
|
-
clearButtonProps:
|
|
22
|
-
}
|
|
23
|
-
export function useTag(props: TagProps<any>, state: GridState<any, any>): TagAria;
|
|
24
|
-
export interface AriaTagGroupProps extends DOMProps {
|
|
25
|
-
children: ReactNode;
|
|
26
|
-
isReadOnly?: boolean;
|
|
27
|
-
validationState?: 'valid' | 'invalid';
|
|
21
|
+
clearButtonProps: AriaButtonProps;
|
|
28
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Provides the behavior and accessibility implementation for a tag component.
|
|
25
|
+
* @param props - Props to be applied to the tag.
|
|
26
|
+
* @param state - State for the tag group, as returned by `useTagGroupState`.
|
|
27
|
+
*/
|
|
28
|
+
export function useTag<T>(props: TagProps<T>, state: TagGroupState<T>): TagAria;
|
|
29
29
|
export interface TagGroupAria {
|
|
30
30
|
tagGroupProps: DOMAttributes;
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Provides the behavior and accessibility implementation for a tag group component.
|
|
34
|
+
* Tags allow users to categorize content. They can represent keywords or people, and are grouped to describe an item or a search request.
|
|
35
|
+
* @param props - Props to be applied to the tag group.
|
|
36
|
+
* @param state - State for the tag group, as returned by `useTagGroupState`.
|
|
37
|
+
* @param ref - A ref to a DOM element for the tag group.
|
|
38
|
+
*/
|
|
39
|
+
export function useTagGroup<T>(props: AriaTagGroupProps<T>, state: TagGroupState<T>, ref: RefObject<HTMLElement>): TagGroupAria;
|
|
33
40
|
export type { TagProps } from '@react-types/tag';
|
|
34
41
|
|
|
35
42
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;AAeA,iCAAiC,CAAC,CAAE,YAAW,gBAAgB;gBAIjD,UAAU,EAAE,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS;IAK3D,WAAW;IAIX,UAAU;IAIV,aAAa,CAAC,GAAG,EAAE,GAAG;IAItB,YAAY,CAAC,GAAG,EAAE,GAAG;IAIrB,WAAW,CAAC,GAAG,KAAA;IAef,WAAW,CAAC,GAAG,KAAA;IAef,eAAe,CAAC,GAAG,KAAA;IAInB,eAAe,CAAC,GAAG,KAAA;CAGpB;ACrDD;IACE,UAAU,EAAE,aAAa,CAAC;IAC1B,QAAQ,EAAE,aAAa,CAAC;IACxB,WAAW,EAAE,aAAa,CAAC;IAC3B,gBAAgB,EAAE,eAAe,CAAA;CAClC;AAED;;;;GAIG;AACH,uBAAuB,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,GAAG,OAAO,CAkD9E;AChED;IACE,aAAa,EAAE,aAAa,CAAA;CAC7B;AAED;;;;;;GAMG;AACH,4BAA4B,CAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,YAAY,CAsB9H;ACvCD,YAAY,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC","sources":["packages/@react-aria/tag/src/packages/@react-aria/tag/src/TagKeyboardDelegate.ts","packages/@react-aria/tag/src/packages/@react-aria/tag/src/useTag.ts","packages/@react-aria/tag/src/packages/@react-aria/tag/src/useTagGroup.ts","packages/@react-aria/tag/src/packages/@react-aria/tag/src/index.ts","packages/@react-aria/tag/src/index.ts"],"sourcesContent":[null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {TagKeyboardDelegate} from './TagKeyboardDelegate';\nexport {useTag} from './useTag';\nexport {useTagGroup} from './useTagGroup';\n\nexport type {TagProps} from '@react-types/tag';\nexport type {TagGroupAria} from './useTagGroup';\nexport type {TagAria} from './useTag';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/tag",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.1933+080488a85",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -17,14 +17,14 @@
|
|
|
17
17
|
"url": "https://github.com/adobe/react-spectrum"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@react-aria/
|
|
21
|
-
"@react-aria/i18n": "3.0.0-nightly.
|
|
22
|
-
"@react-aria/interactions": "3.0.0-nightly.
|
|
23
|
-
"@react-aria/utils": "3.0.0-nightly.
|
|
24
|
-
"@react-stately/
|
|
25
|
-
"@react-types/
|
|
26
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
27
|
-
"@react-types/tag": "3.0.0-nightly.
|
|
20
|
+
"@react-aria/gridlist": "3.1.3-nightly.3633+080488a85",
|
|
21
|
+
"@react-aria/i18n": "3.0.0-nightly.1933+080488a85",
|
|
22
|
+
"@react-aria/interactions": "3.0.0-nightly.1933+080488a85",
|
|
23
|
+
"@react-aria/utils": "3.0.0-nightly.1933+080488a85",
|
|
24
|
+
"@react-stately/tag": "3.0.0-nightly.3633+080488a85",
|
|
25
|
+
"@react-types/button": "3.7.1-nightly.3633+080488a85",
|
|
26
|
+
"@react-types/shared": "3.0.0-nightly.1933+080488a85",
|
|
27
|
+
"@react-types/tag": "3.0.0-nightly.1933+080488a85",
|
|
28
28
|
"@swc/helpers": "^0.4.14"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "080488a859be32a1ee30f4f9fdcc4d5e8331a144"
|
|
37
37
|
}
|
|
@@ -10,25 +10,26 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
import {GridKeyboardDelegate} from '@react-aria/grid';
|
|
13
|
+
import {Collection, Direction, KeyboardDelegate} from '@react-types/shared';
|
|
15
14
|
import {Key} from 'react';
|
|
16
15
|
|
|
17
|
-
export class TagKeyboardDelegate<T>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
let item = this.collection.getItem(key);
|
|
16
|
+
export class TagKeyboardDelegate<T> implements KeyboardDelegate {
|
|
17
|
+
private collection: Collection<T>;
|
|
18
|
+
private direction: Direction;
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
constructor(collection: Collection<T>, direction: Direction) {
|
|
21
|
+
this.collection = collection;
|
|
22
|
+
this.direction = direction;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
let item = this.collection.getItem(key);
|
|
28
|
-
|
|
29
|
-
return [...item.childNodes][0].key;
|
|
25
|
+
getFirstKey() {
|
|
26
|
+
return this.collection.getFirstKey();
|
|
30
27
|
}
|
|
31
28
|
|
|
29
|
+
getLastKey() {
|
|
30
|
+
return this.collection.getLastKey();
|
|
31
|
+
}
|
|
32
|
+
|
|
32
33
|
getKeyRightOf(key: Key) {
|
|
33
34
|
return this.direction === 'rtl' ? this.getKeyAbove(key) : this.getKeyBelow(key);
|
|
34
35
|
}
|
|
@@ -43,27 +44,12 @@ export class TagKeyboardDelegate<T> extends GridKeyboardDelegate<T, GridCollecti
|
|
|
43
44
|
return;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
// If focus was on a cell, start searching from the parent row
|
|
47
|
-
if (this.isCell(startItem)) {
|
|
48
|
-
key = startItem.parentKey;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
47
|
// Find the next item
|
|
52
|
-
key = this.
|
|
48
|
+
key = this.collection.getKeyAfter(key);
|
|
53
49
|
if (key != null) {
|
|
54
|
-
|
|
55
|
-
if (this.isCell(startItem)) {
|
|
56
|
-
let item = this.collection.getItem(key);
|
|
57
|
-
|
|
58
|
-
return [...item.childNodes][startItem.index].key;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Otherwise, focus the next row
|
|
62
|
-
if (this.focusMode === 'row') {
|
|
63
|
-
return key;
|
|
64
|
-
}
|
|
50
|
+
return key;
|
|
65
51
|
} else {
|
|
66
|
-
return this.getFirstKey();
|
|
52
|
+
return this.collection.getFirstKey();
|
|
67
53
|
}
|
|
68
54
|
}
|
|
69
55
|
|
|
@@ -73,26 +59,12 @@ export class TagKeyboardDelegate<T> extends GridKeyboardDelegate<T, GridCollecti
|
|
|
73
59
|
return;
|
|
74
60
|
}
|
|
75
61
|
|
|
76
|
-
// If focus is on a cell, start searching from the parent row
|
|
77
|
-
if (this.isCell(startItem)) {
|
|
78
|
-
key = startItem.parentKey;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
62
|
// Find the previous item
|
|
82
|
-
key = this.
|
|
63
|
+
key = this.collection.getKeyBefore(key);
|
|
83
64
|
if (key != null) {
|
|
84
|
-
|
|
85
|
-
if (this.isCell(startItem)) {
|
|
86
|
-
let item = this.collection.getItem(key);
|
|
87
|
-
return [...item.childNodes][startItem.index].key;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Otherwise, focus the previous row
|
|
91
|
-
if (this.focusMode === 'row') {
|
|
92
|
-
return key;
|
|
93
|
-
}
|
|
65
|
+
return key;
|
|
94
66
|
} else {
|
|
95
|
-
return this.getLastKey();
|
|
67
|
+
return this.collection.getLastKey();
|
|
96
68
|
}
|
|
97
69
|
}
|
|
98
70
|
|
package/src/index.ts
CHANGED
|
@@ -15,5 +15,5 @@ export {useTag} from './useTag';
|
|
|
15
15
|
export {useTagGroup} from './useTagGroup';
|
|
16
16
|
|
|
17
17
|
export type {TagProps} from '@react-types/tag';
|
|
18
|
-
export type {
|
|
18
|
+
export type {TagGroupAria} from './useTagGroup';
|
|
19
19
|
export type {TagAria} from './useTag';
|
package/src/useTag.ts
CHANGED
|
@@ -10,14 +10,15 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import {AriaButtonProps} from '@react-types/button';
|
|
14
|
+
import {chain, filterDOMProps, mergeProps, useId} from '@react-aria/utils';
|
|
14
15
|
import {DOMAttributes} from '@react-types/shared';
|
|
15
|
-
import {filterDOMProps, mergeProps, useId} from '@react-aria/utils';
|
|
16
|
-
import {GridState} from '@react-stately/grid';
|
|
17
16
|
// @ts-ignore
|
|
18
17
|
import intlMessages from '../intl/*.json';
|
|
18
|
+
import {KeyboardEvent} from 'react';
|
|
19
|
+
import type {TagGroupState} from '@react-stately/tag';
|
|
19
20
|
import {TagProps} from '@react-types/tag';
|
|
20
|
-
import {
|
|
21
|
+
import {useGridListItem} from '@react-aria/gridlist';
|
|
21
22
|
import {useLocalizedStringFormatter} from '@react-aria/i18n';
|
|
22
23
|
|
|
23
24
|
|
|
@@ -25,62 +26,62 @@ export interface TagAria {
|
|
|
25
26
|
labelProps: DOMAttributes,
|
|
26
27
|
tagProps: DOMAttributes,
|
|
27
28
|
tagRowProps: DOMAttributes,
|
|
28
|
-
clearButtonProps:
|
|
29
|
+
clearButtonProps: AriaButtonProps
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Provides the behavior and accessibility implementation for a tag component.
|
|
34
|
+
* @param props - Props to be applied to the tag.
|
|
35
|
+
* @param state - State for the tag group, as returned by `useTagGroupState`.
|
|
36
|
+
*/
|
|
37
|
+
export function useTag<T>(props: TagProps<T>, state: TagGroupState<T>): TagAria {
|
|
38
|
+
let {
|
|
39
|
+
isFocused,
|
|
34
40
|
allowsRemoving,
|
|
35
|
-
onRemove,
|
|
36
41
|
item,
|
|
37
|
-
tagRef,
|
|
38
42
|
tagRowRef
|
|
39
43
|
} = props;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
let stringFormatter = useLocalizedStringFormatter(intlMessages);
|
|
45
|
+
let removeString = stringFormatter.format('remove');
|
|
46
|
+
let labelId = useId();
|
|
47
|
+
let buttonId = useId();
|
|
44
48
|
|
|
45
|
-
let {rowProps} =
|
|
49
|
+
let {rowProps, gridCellProps} = useGridListItem({
|
|
46
50
|
node: item
|
|
47
51
|
}, state, tagRowRef);
|
|
48
|
-
// Don't want the row to be focusable or accessible via keyboard
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
50
|
-
let {tabIndex, ...otherRowProps} = rowProps;
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
// We want the group to handle keyboard navigation between tags.
|
|
54
|
+
delete rowProps.onKeyDownCapture;
|
|
55
|
+
|
|
56
|
+
let onRemove = chain(props.onRemove, state.onRemove);
|
|
56
57
|
|
|
57
|
-
|
|
58
|
+
let onKeyDown = (e: KeyboardEvent) => {
|
|
58
59
|
if (e.key === 'Delete' || e.key === 'Backspace' || e.key === ' ') {
|
|
59
|
-
onRemove(item.
|
|
60
|
+
onRemove(item.key);
|
|
60
61
|
e.preventDefault();
|
|
61
62
|
}
|
|
62
|
-
}
|
|
63
|
-
const pressProps = {
|
|
64
|
-
onPress: () => onRemove?.(item.childNodes[0].key)
|
|
65
63
|
};
|
|
66
64
|
|
|
67
|
-
isFocused = isFocused || state.selectionManager.focusedKey === item.
|
|
65
|
+
isFocused = isFocused || state.selectionManager.focusedKey === item.key;
|
|
68
66
|
let domProps = filterDOMProps(props);
|
|
69
67
|
return {
|
|
70
|
-
clearButtonProps:
|
|
68
|
+
clearButtonProps: {
|
|
71
69
|
'aria-label': removeString,
|
|
72
70
|
'aria-labelledby': `${buttonId} ${labelId}`,
|
|
73
|
-
id: buttonId
|
|
74
|
-
|
|
71
|
+
id: buttonId,
|
|
72
|
+
onPress: () => allowsRemoving && onRemove ? onRemove(item.key) : null
|
|
73
|
+
},
|
|
75
74
|
labelProps: {
|
|
76
75
|
id: labelId
|
|
77
76
|
},
|
|
78
|
-
tagRowProps:
|
|
77
|
+
tagRowProps: {
|
|
78
|
+
...rowProps,
|
|
79
|
+
tabIndex: (isFocused || state.selectionManager.focusedKey == null) ? 0 : -1,
|
|
80
|
+
onKeyDown: allowsRemoving ? onKeyDown : null
|
|
81
|
+
},
|
|
79
82
|
tagProps: mergeProps(domProps, gridCellProps, {
|
|
80
83
|
'aria-errormessage': props['aria-errormessage'],
|
|
81
|
-
'aria-label': props['aria-label']
|
|
82
|
-
onKeyDown: allowsRemoving ? onKeyDown : null,
|
|
83
|
-
tabIndex: (isFocused || state.selectionManager.focusedKey == null) ? 0 : -1
|
|
84
|
+
'aria-label': props['aria-label']
|
|
84
85
|
})
|
|
85
86
|
};
|
|
86
87
|
}
|
package/src/useTagGroup.ts
CHANGED
|
@@ -10,29 +10,43 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import {AriaTagGroupProps} from '@react-types/tag';
|
|
14
|
+
import {DOMAttributes} from '@react-types/shared';
|
|
14
15
|
import {filterDOMProps, mergeProps} from '@react-aria/utils';
|
|
15
|
-
import {
|
|
16
|
+
import {RefObject, useState} from 'react';
|
|
17
|
+
import type {TagGroupState} from '@react-stately/tag';
|
|
18
|
+
import {TagKeyboardDelegate} from './TagKeyboardDelegate';
|
|
16
19
|
import {useFocusWithin} from '@react-aria/interactions';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
children: ReactNode,
|
|
20
|
-
isReadOnly?: boolean, // removes close button
|
|
21
|
-
validationState?: 'valid' | 'invalid'
|
|
22
|
-
}
|
|
20
|
+
import {useGridList} from '@react-aria/gridlist';
|
|
21
|
+
import {useLocale} from '@react-aria/i18n';
|
|
23
22
|
|
|
24
23
|
export interface TagGroupAria {
|
|
25
24
|
tagGroupProps: DOMAttributes
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Provides the behavior and accessibility implementation for a tag group component.
|
|
29
|
+
* Tags allow users to categorize content. They can represent keywords or people, and are grouped to describe an item or a search request.
|
|
30
|
+
* @param props - Props to be applied to the tag group.
|
|
31
|
+
* @param state - State for the tag group, as returned by `useTagGroupState`.
|
|
32
|
+
* @param ref - A ref to a DOM element for the tag group.
|
|
33
|
+
*/
|
|
34
|
+
export function useTagGroup<T>(props: AriaTagGroupProps<T>, state: TagGroupState<T>, ref: RefObject<HTMLElement>): TagGroupAria {
|
|
35
|
+
let {direction} = useLocale();
|
|
36
|
+
let keyboardDelegate = new TagKeyboardDelegate(state.collection, direction);
|
|
37
|
+
let {gridProps} = useGridList({...props, keyboardDelegate}, state, ref);
|
|
38
|
+
|
|
39
|
+
// Don't want the grid to be focusable or accessible via keyboard
|
|
40
|
+
delete gridProps.role;
|
|
41
|
+
delete gridProps.tabIndex;
|
|
42
|
+
|
|
29
43
|
let [isFocusWithin, setFocusWithin] = useState(false);
|
|
30
44
|
let {focusWithinProps} = useFocusWithin({
|
|
31
45
|
onFocusWithinChange: setFocusWithin
|
|
32
46
|
});
|
|
33
47
|
let domProps = filterDOMProps(props);
|
|
34
48
|
return {
|
|
35
|
-
tagGroupProps: mergeProps(domProps, {
|
|
49
|
+
tagGroupProps: mergeProps(gridProps, domProps, {
|
|
36
50
|
'aria-atomic': false,
|
|
37
51
|
'aria-relevant': 'additions',
|
|
38
52
|
'aria-live': isFocusWithin ? 'polite' : 'off',
|