@react-aria/tag 3.0.0-nightly.3180 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.js CHANGED
@@ -1,212 +1,340 @@
1
- import {GridKeyboardDelegate as $aIvin$GridKeyboardDelegate, useGridRow as $aIvin$useGridRow, useGridCell as $aIvin$useGridCell} from "@react-aria/grid";
2
- import {useId as $aIvin$useId, filterDOMProps as $aIvin$filterDOMProps, mergeProps as $aIvin$mergeProps} from "@react-aria/utils";
3
- import {useMessageFormatter as $aIvin$useMessageFormatter} from "@react-aria/i18n";
4
- import {useState as $aIvin$useState} from "react";
5
- import {useFocusWithin as $aIvin$useFocusWithin} from "@react-aria/interactions";
6
-
7
- function $parcel$export(e, n, v, s) {
8
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
9
- }
1
+ import {useId as $aIvin$useId, useDescription as $aIvin$useDescription, 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 {useInteractionModality as $aIvin$useInteractionModality, useFocusWithin as $aIvin$useFocusWithin} from "@react-aria/interactions";
4
+ import {useLocalizedStringFormatter as $aIvin$useLocalizedStringFormatter, useLocale as $aIvin$useLocale} from "@react-aria/i18n";
5
+ import {useState as $aIvin$useState, useRef as $aIvin$useRef, useEffect as $aIvin$useEffect} from "react";
6
+ import {ListKeyboardDelegate as $aIvin$ListKeyboardDelegate} from "@react-aria/selection";
7
+ import {useField as $aIvin$useField} from "@react-aria/label";
8
+
10
9
  function $parcel$interopDefault(a) {
11
10
  return a && a.__esModule ? a.default : a;
12
11
  }
13
- var $542448901dbd2c36$exports = {};
14
-
15
- $parcel$export($542448901dbd2c36$exports, "TagKeyboardDelegate", () => $542448901dbd2c36$export$b00754732e683b92);
16
-
17
- class $542448901dbd2c36$export$b00754732e683b92 extends $aIvin$GridKeyboardDelegate {
18
- getKeyRightOf(key) {
19
- return this.direction === 'rtl' ? this.getKeyAbove(key) : this.getKeyBelow(key);
20
- }
21
- getKeyLeftOf(key) {
22
- return this.direction === 'rtl' ? this.getKeyBelow(key) : this.getKeyAbove(key);
23
- }
24
- getKeyBelow(key) {
25
- let startItem = this.collection.getItem(key);
26
- if (!startItem) return;
27
- // If focus was on a cell, start searching from the parent row
28
- if (this.isCell(startItem)) key = startItem.parentKey;
29
- // Find the next item
30
- key = this.findNextKey(key);
31
- if (key != null) {
32
- // If focus was on a cell, focus the cell with the same index in the next row.
33
- if (this.isCell(startItem)) {
34
- let item = this.collection.getItem(key);
35
- let newKey = [
36
- ...item.childNodes
37
- ][startItem.index].key;
38
- // Ignore disabled tags
39
- if (this.disabledKeys.has(newKey)) return this.getKeyBelow(newKey);
40
- return newKey;
41
- }
42
- // Otherwise, focus the next row
43
- if (this.focusMode === 'row') return key;
44
- }
45
- }
46
- getKeyAbove(key) {
47
- let startItem = this.collection.getItem(key);
48
- if (!startItem) return;
49
- // If focus is on a cell, start searching from the parent row
50
- if (this.isCell(startItem)) key = startItem.parentKey;
51
- // Find the previous item
52
- key = this.findPreviousKey(key);
53
- if (key != null) {
54
- // If focus was on a cell, focus the cell with the same index in the previous row.
55
- if (this.isCell(startItem)) {
56
- let item = this.collection.getItem(key);
57
- let newKey = [
58
- ...item.childNodes
59
- ][startItem.index].key;
60
- // ignore disabled tags
61
- if (this.disabledKeys.has(newKey)) return this.getKeyAbove(newKey);
62
- return newKey;
63
- }
64
- // Otherwise, focus the previous row
65
- if (this.focusMode === 'row') return key;
66
- }
67
- }
12
+ /*
13
+ * Copyright 2020 Adobe. All rights reserved.
14
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
15
+ * you may not use this file except in compliance with the License. You may obtain a copy
16
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software distributed under
19
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
20
+ * OF ANY KIND, either express or implied. See the License for the specific language
21
+ * governing permissions and limitations under the License.
22
+ */ /*
23
+ * Copyright 2020 Adobe. All rights reserved.
24
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
25
+ * you may not use this file except in compliance with the License. You may obtain a copy
26
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
27
+ *
28
+ * Unless required by applicable law or agreed to in writing, software distributed under
29
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
30
+ * OF ANY KIND, either express or implied. See the License for the specific language
31
+ * governing permissions and limitations under the License.
32
+ */
33
+ /*
34
+ * Copyright 2020 Adobe. All rights reserved.
35
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
36
+ * you may not use this file except in compliance with the License. You may obtain a copy
37
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
38
+ *
39
+ * Unless required by applicable law or agreed to in writing, software distributed under
40
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
41
+ * OF ANY KIND, either express or implied. See the License for the specific language
42
+ * governing permissions and limitations under the License.
43
+ */
44
+
45
+
46
+
47
+
48
+
49
+
50
+ const $d7323bca8d074eeb$export$653eddfc964b0f8a = new WeakMap();
51
+ function $d7323bca8d074eeb$export$4f8b5cda58b7e8ff(props, state, ref) {
52
+ let { direction: direction } = (0, $aIvin$useLocale)();
53
+ let keyboardDelegate = props.keyboardDelegate || new (0, $aIvin$ListKeyboardDelegate)({
54
+ collection: state.collection,
55
+ ref: ref,
56
+ orientation: "horizontal",
57
+ direction: direction,
58
+ disabledKeys: state.disabledKeys
59
+ });
60
+ let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $aIvin$useField)(props);
61
+ let { gridProps: gridProps } = (0, $aIvin$useGridList)({
62
+ ...props,
63
+ ...fieldProps,
64
+ keyboardDelegate: keyboardDelegate,
65
+ shouldFocusWrap: true
66
+ }, state, ref);
67
+ let [isFocusWithin, setFocusWithin] = (0, $aIvin$useState)(false);
68
+ let { focusWithinProps: focusWithinProps } = (0, $aIvin$useFocusWithin)({
69
+ onFocusWithinChange: setFocusWithin
70
+ });
71
+ let domProps = (0, $aIvin$filterDOMProps)(props);
72
+ // If the last tag is removed, focus the container.
73
+ let prevCount = (0, $aIvin$useRef)(state.collection.size);
74
+ (0, $aIvin$useEffect)(()=>{
75
+ if (prevCount.current > 0 && state.collection.size === 0 && isFocusWithin) ref.current.focus();
76
+ prevCount.current = state.collection.size;
77
+ }, [
78
+ state.collection.size,
79
+ isFocusWithin,
80
+ ref
81
+ ]);
82
+ $d7323bca8d074eeb$export$653eddfc964b0f8a.set(state, {
83
+ onRemove: props.onRemove
84
+ });
85
+ return {
86
+ gridProps: (0, $aIvin$mergeProps)(gridProps, domProps, {
87
+ role: state.collection.size ? "grid" : null,
88
+ "aria-atomic": false,
89
+ "aria-relevant": "additions",
90
+ "aria-live": isFocusWithin ? "polite" : "off",
91
+ ...focusWithinProps,
92
+ ...fieldProps
93
+ }),
94
+ labelProps: labelProps,
95
+ descriptionProps: descriptionProps,
96
+ errorMessageProps: errorMessageProps
97
+ };
68
98
  }
69
99
 
70
100
 
71
- var $fc6126c82a4601f1$exports = {};
72
-
73
- $parcel$export($fc6126c82a4601f1$exports, "useTag", () => $fc6126c82a4601f1$export$3f568fff7dff2f03);
74
-
75
101
  var $4d1b62e0e67c00a4$exports = {};
76
102
  var $84925f526f90eebd$exports = {};
77
- $84925f526f90eebd$exports = JSON.parse("{\"remove\":\"إزالة\"}");
103
+ $84925f526f90eebd$exports = {
104
+ "removeButtonLabel": `إزالة`,
105
+ "removeDescription": `اضغط على مفتاح DELETE لإزالة علامة.`
106
+ };
78
107
 
79
108
 
80
109
  var $c0650163dc1b6f9d$exports = {};
81
- $c0650163dc1b6f9d$exports = JSON.parse("{\"remove\":\"Премахване\"}");
110
+ $c0650163dc1b6f9d$exports = {
111
+ "removeButtonLabel": `Премахване`,
112
+ "removeDescription": `Натиснете Delete, за да премахнете маркера.`
113
+ };
82
114
 
83
115
 
84
116
  var $b2b55661291de587$exports = {};
85
- $b2b55661291de587$exports = JSON.parse("{\"remove\":\"Odebrat\"}");
117
+ $b2b55661291de587$exports = {
118
+ "removeButtonLabel": `Odebrat`,
119
+ "removeDescription": `Stisknutím klávesy Delete odeberete značku.`
120
+ };
86
121
 
87
122
 
88
123
  var $deb83970956f6d5b$exports = {};
89
- $deb83970956f6d5b$exports = JSON.parse("{\"remove\":\"Fjern\"}");
124
+ $deb83970956f6d5b$exports = {
125
+ "removeButtonLabel": `Fjern`,
126
+ "removeDescription": `Tryk på Slet for at fjerne tag.`
127
+ };
90
128
 
91
129
 
92
130
  var $aea1cb4c7ec97e1c$exports = {};
93
- $aea1cb4c7ec97e1c$exports = JSON.parse("{\"remove\":\"Entfernen\"}");
131
+ $aea1cb4c7ec97e1c$exports = {
132
+ "removeButtonLabel": `Entfernen`,
133
+ "removeDescription": `Auf „Löschen“ drücken, um das Tag zu entfernen.`
134
+ };
94
135
 
95
136
 
96
137
  var $3618d917e503a8d3$exports = {};
97
- $3618d917e503a8d3$exports = JSON.parse("{\"remove\":\"Κατάργηση\"}");
138
+ $3618d917e503a8d3$exports = {
139
+ "removeButtonLabel": `Κατάργηση`,
140
+ "removeDescription": `Πατήστε Διαγραφή για να καταργήσετε την ετικέτα.`
141
+ };
98
142
 
99
143
 
100
144
  var $9eb56bbbe8e31294$exports = {};
101
- $9eb56bbbe8e31294$exports = JSON.parse("{\"remove\":\"Remove\"}");
145
+ $9eb56bbbe8e31294$exports = {
146
+ "removeDescription": `Press Delete to remove tag.`,
147
+ "removeButtonLabel": `Remove`
148
+ };
102
149
 
103
150
 
104
151
  var $361c604b0fc269a3$exports = {};
105
- $361c604b0fc269a3$exports = JSON.parse("{\"remove\":\"Quitar\"}");
152
+ $361c604b0fc269a3$exports = {
153
+ "removeButtonLabel": `Quitar`,
154
+ "removeDescription": `Pulse Eliminar para quitar la etiqueta.`
155
+ };
106
156
 
107
157
 
108
158
  var $2f00170f4ee3ca01$exports = {};
109
- $2f00170f4ee3ca01$exports = JSON.parse("{\"remove\":\"Eemalda\"}");
159
+ $2f00170f4ee3ca01$exports = {
160
+ "removeButtonLabel": `Eemalda`,
161
+ "removeDescription": `Sildi eemaldamiseks vajutage kustutusklahvi Delete.`
162
+ };
110
163
 
111
164
 
112
165
  var $80ee16b64fab9fb5$exports = {};
113
- $80ee16b64fab9fb5$exports = JSON.parse("{\"remove\":\"Poista\"}");
166
+ $80ee16b64fab9fb5$exports = {
167
+ "removeButtonLabel": `Poista`,
168
+ "removeDescription": `Poista tunniste painamalla Poista-painiketta.`
169
+ };
114
170
 
115
171
 
116
172
  var $be9d354476c08087$exports = {};
117
- $be9d354476c08087$exports = JSON.parse("{\"remove\":\"Supprimer\"}");
173
+ $be9d354476c08087$exports = {
174
+ "removeButtonLabel": `Supprimer`,
175
+ "removeDescription": `Appuyez sur Supprimer pour supprimer l’étiquette.`
176
+ };
118
177
 
119
178
 
120
179
  var $ffeb903ba092eb35$exports = {};
121
- $ffeb903ba092eb35$exports = JSON.parse("{\"remove\":\"הסר\"}");
180
+ $ffeb903ba092eb35$exports = {
181
+ "removeButtonLabel": `הסר`,
182
+ "removeDescription": `לחץ על מחק כדי להסיר תג.`
183
+ };
122
184
 
123
185
 
124
186
  var $1df6722c6f19728b$exports = {};
125
- $1df6722c6f19728b$exports = JSON.parse("{\"remove\":\"Ukloni\"}");
187
+ $1df6722c6f19728b$exports = {
188
+ "removeButtonLabel": `Ukloni`,
189
+ "removeDescription": `Pritisnite Delete za uklanjanje oznake.`
190
+ };
126
191
 
127
192
 
128
193
  var $093d57e325bc9071$exports = {};
129
- $093d57e325bc9071$exports = JSON.parse("{\"remove\":\"Eltávolítás\"}");
194
+ $093d57e325bc9071$exports = {
195
+ "removeButtonLabel": `Eltávolítás`,
196
+ "removeDescription": `Nyomja meg a Delete billentyűt a címke eltávolításához.`
197
+ };
130
198
 
131
199
 
132
200
  var $609dbdfbcad85bdb$exports = {};
133
- $609dbdfbcad85bdb$exports = JSON.parse("{\"remove\":\"Rimuovi\"}");
201
+ $609dbdfbcad85bdb$exports = {
202
+ "removeButtonLabel": `Rimuovi`,
203
+ "removeDescription": `Premi Elimina per rimuovere il tag.`
204
+ };
134
205
 
135
206
 
136
207
  var $c08e84f882644048$exports = {};
137
- $c08e84f882644048$exports = JSON.parse("{\"remove\":\"削除\"}");
208
+ $c08e84f882644048$exports = {
209
+ "removeButtonLabel": `削除`,
210
+ "removeDescription": `タグを削除するには、Delete キーを押します。`
211
+ };
138
212
 
139
213
 
140
214
  var $5cd130489822fa21$exports = {};
141
- $5cd130489822fa21$exports = JSON.parse("{\"remove\":\"제거\"}");
215
+ $5cd130489822fa21$exports = {
216
+ "removeButtonLabel": `제거`,
217
+ "removeDescription": `태그를 제거하려면 Delete 키를 누르십시오.`
218
+ };
142
219
 
143
220
 
144
221
  var $ab5183739b6c5e7e$exports = {};
145
- $ab5183739b6c5e7e$exports = JSON.parse("{\"remove\":\"Pašalinti\"}");
222
+ $ab5183739b6c5e7e$exports = {
223
+ "removeButtonLabel": `Pašalinti`,
224
+ "removeDescription": `Norėdami pašalinti žymą, paspauskite „Delete“ klavišą.`
225
+ };
146
226
 
147
227
 
148
228
  var $dd84a0b574be3f23$exports = {};
149
- $dd84a0b574be3f23$exports = JSON.parse("{\"remove\":\"Noņemt\"}");
229
+ $dd84a0b574be3f23$exports = {
230
+ "removeButtonLabel": `Noņemt`,
231
+ "removeDescription": `Nospiediet Delete [Dzēst], lai noņemtu tagu.`
232
+ };
150
233
 
151
234
 
152
235
  var $85eee97d14eef7b5$exports = {};
153
- $85eee97d14eef7b5$exports = JSON.parse("{\"remove\":\"Fjern\"}");
236
+ $85eee97d14eef7b5$exports = {
237
+ "removeButtonLabel": `Fjern`,
238
+ "removeDescription": `Trykk på Slett for å fjerne taggen.`
239
+ };
154
240
 
155
241
 
156
242
  var $18781839f93b0314$exports = {};
157
- $18781839f93b0314$exports = JSON.parse("{\"remove\":\"Verwijderen\"}");
243
+ $18781839f93b0314$exports = {
244
+ "removeButtonLabel": `Verwijderen`,
245
+ "removeDescription": `Druk op Verwijderen om de tag te verwijderen.`
246
+ };
158
247
 
159
248
 
160
249
  var $1c40ffbbfe9f3bda$exports = {};
161
- $1c40ffbbfe9f3bda$exports = JSON.parse("{\"remove\":\"Usuń\"}");
250
+ $1c40ffbbfe9f3bda$exports = {
251
+ "removeButtonLabel": `Usuń`,
252
+ "removeDescription": `Naciśnij Usuń, aby usunąć znacznik.`
253
+ };
162
254
 
163
255
 
164
256
  var $156880e329b1c717$exports = {};
165
- $156880e329b1c717$exports = JSON.parse("{\"remove\":\"Remover\"}");
257
+ $156880e329b1c717$exports = {
258
+ "removeButtonLabel": `Remover`,
259
+ "removeDescription": `Pressione Delete para remover a tag.`
260
+ };
166
261
 
167
262
 
168
263
  var $b6d50b1d20768ce4$exports = {};
169
- $b6d50b1d20768ce4$exports = JSON.parse("{\"remove\":\"Eliminar\"}");
264
+ $b6d50b1d20768ce4$exports = {
265
+ "removeButtonLabel": `Eliminar`,
266
+ "removeDescription": `Prima Delete para eliminar a tag.`
267
+ };
170
268
 
171
269
 
172
270
  var $d8c38c691b006187$exports = {};
173
- $d8c38c691b006187$exports = JSON.parse("{\"remove\":\"Îndepărtaţi\"}");
271
+ $d8c38c691b006187$exports = {
272
+ "removeButtonLabel": `Îndepărtaţi`,
273
+ "removeDescription": `Apăsați pe Delete (Ștergere) pentru a elimina eticheta.`
274
+ };
174
275
 
175
276
 
176
277
  var $ed9b4bf7ce1fb1d7$exports = {};
177
- $ed9b4bf7ce1fb1d7$exports = JSON.parse("{\"remove\":\"Удалить\"}");
278
+ $ed9b4bf7ce1fb1d7$exports = {
279
+ "removeButtonLabel": `Удалить`,
280
+ "removeDescription": `Нажмите DELETE, чтобы удалить тег.`
281
+ };
178
282
 
179
283
 
180
284
  var $51d8721afda4d678$exports = {};
181
- $51d8721afda4d678$exports = JSON.parse("{\"remove\":\"Odstrániť\"}");
285
+ $51d8721afda4d678$exports = {
286
+ "removeButtonLabel": `Odstrániť`,
287
+ "removeDescription": `Ak chcete odstrániť značku, stlačte kláves Delete.`
288
+ };
182
289
 
183
290
 
184
291
  var $fd37a27baae493e8$exports = {};
185
- $fd37a27baae493e8$exports = JSON.parse("{\"remove\":\"Odstrani\"}");
292
+ $fd37a27baae493e8$exports = {
293
+ "removeButtonLabel": `Odstrani`,
294
+ "removeDescription": `Pritisnite Delete, da odstranite oznako.`
295
+ };
186
296
 
187
297
 
188
298
  var $5505a1ca71ffd6f4$exports = {};
189
- $5505a1ca71ffd6f4$exports = JSON.parse("{\"remove\":\"Ukloni\"}");
299
+ $5505a1ca71ffd6f4$exports = {
300
+ "removeButtonLabel": `Ukloni`,
301
+ "removeDescription": `Pritisnite Obriši da biste uklonili oznaku.`
302
+ };
190
303
 
191
304
 
192
305
  var $33670e148c84ad02$exports = {};
193
- $33670e148c84ad02$exports = JSON.parse("{\"remove\":\"Ta bort\"}");
306
+ $33670e148c84ad02$exports = {
307
+ "removeButtonLabel": `Ta bort`,
308
+ "removeDescription": `Tryck på Radera för att ta bort taggen.`
309
+ };
194
310
 
195
311
 
196
312
  var $0bf46fdcdd7cb5f6$exports = {};
197
- $0bf46fdcdd7cb5f6$exports = JSON.parse("{\"remove\":\"Kaldır\"}");
313
+ $0bf46fdcdd7cb5f6$exports = {
314
+ "removeButtonLabel": `Kaldır`,
315
+ "removeDescription": `Etiketi kaldırmak için Sil tuşuna basın.`
316
+ };
198
317
 
199
318
 
200
319
  var $9d9765222bc08ca2$exports = {};
201
- $9d9765222bc08ca2$exports = JSON.parse("{\"remove\":\"Видалити\"}");
320
+ $9d9765222bc08ca2$exports = {
321
+ "removeButtonLabel": `Вилучити`,
322
+ "removeDescription": `Натисніть Delete, щоб вилучити тег.`
323
+ };
202
324
 
203
325
 
204
326
  var $d737296cedcdee9f$exports = {};
205
- $d737296cedcdee9f$exports = JSON.parse("{\"remove\":\"删除\"}");
327
+ $d737296cedcdee9f$exports = {
328
+ "removeButtonLabel": `删除`,
329
+ "removeDescription": `按下“删除”以删除标记。`
330
+ };
206
331
 
207
332
 
208
333
  var $09cd168ab18773f4$exports = {};
209
- $09cd168ab18773f4$exports = JSON.parse("{\"remove\":\"移除\"}");
334
+ $09cd168ab18773f4$exports = {
335
+ "removeButtonLabel": `移除`,
336
+ "removeDescription": `按 Delete 鍵以移除標記。`
337
+ };
210
338
 
211
339
 
212
340
  $4d1b62e0e67c00a4$exports = {
@@ -249,95 +377,61 @@ $4d1b62e0e67c00a4$exports = {
249
377
 
250
378
 
251
379
 
252
- function $fc6126c82a4601f1$export$3f568fff7dff2f03(props, state) {
253
- let { isFocused: isFocused } = props;
254
- const { isDisabled: isDisabled , isRemovable: isRemovable , onRemove: onRemove , children: children , item: item , tagRef: tagRef , tagRowRef: tagRowRef } = props;
255
- const formatMessage = $aIvin$useMessageFormatter((/*@__PURE__*/$parcel$interopDefault($4d1b62e0e67c00a4$exports)));
256
- const removeString = formatMessage('remove');
257
- const labelId = $aIvin$useId();
258
- const buttonId = $aIvin$useId();
259
- let { rowProps: rowProps } = $aIvin$useGridRow({
380
+
381
+ function $fc6126c82a4601f1$export$3f568fff7dff2f03(props, state, ref) {
382
+ let { item: item } = props;
383
+ let stringFormatter = (0, $aIvin$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($4d1b62e0e67c00a4$exports))));
384
+ let buttonId = (0, $aIvin$useId)();
385
+ let { onRemove: onRemove } = (0, $d7323bca8d074eeb$export$653eddfc964b0f8a).get(state) || {};
386
+ let { rowProps: rowProps , gridCellProps: gridCellProps , ...states } = (0, $aIvin$useGridListItem)({
260
387
  node: item
261
- }, state, tagRowRef);
262
- // Don't want the row to be focusable or accessible via keyboard
263
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
264
- let { tabIndex: tabIndex , ...otherRowProps } = rowProps;
265
- let { gridCellProps: gridCellProps } = $aIvin$useGridCell({
266
- node: [
267
- ...item.childNodes
268
- ][0],
269
- focusMode: 'cell'
270
- }, state, tagRef);
271
- function onKeyDown(e) {
272
- if (e.key === 'Delete' || e.key === 'Backspace') {
273
- onRemove(children, e);
388
+ }, state, ref);
389
+ // We want the group to handle keyboard navigation between tags.
390
+ delete rowProps.onKeyDownCapture;
391
+ delete states.descriptionProps;
392
+ let onKeyDown = (e)=>{
393
+ if (e.key === "Delete" || e.key === "Backspace") {
274
394
  e.preventDefault();
275
- }
276
- }
277
- const pressProps = {
278
- onPress: (e)=>{
279
- return onRemove === null || onRemove === void 0 ? void 0 : onRemove(children, e);
395
+ if (state.selectionManager.isSelected(item.key)) onRemove(new Set(state.selectionManager.selectedKeys));
396
+ else onRemove(new Set([
397
+ item.key
398
+ ]));
280
399
  }
281
400
  };
282
- isFocused = isFocused || state.selectionManager.focusedKey === item.childNodes[0].key;
283
- let domProps = $aIvin$filterDOMProps(props);
401
+ let modality = (0, $aIvin$useInteractionModality)();
402
+ if (modality === "virtual" && typeof window !== "undefined" && "ontouchstart" in window) modality = "touch";
403
+ let description = onRemove && (modality === "keyboard" || modality === "virtual") ? stringFormatter.format("removeDescription") : "";
404
+ let descProps = (0, $aIvin$useDescription)(description);
405
+ let isFocused = item.key === state.selectionManager.focusedKey;
406
+ // @ts-ignore - data attributes are ok but TS doesn't know about them.
407
+ let domProps = (0, $aIvin$filterDOMProps)(props);
284
408
  return {
285
- clearButtonProps: $aIvin$mergeProps(pressProps, {
286
- 'aria-label': removeString,
287
- 'aria-labelledby': `${buttonId} ${labelId}`,
409
+ removeButtonProps: {
410
+ "aria-label": stringFormatter.format("removeButtonLabel"),
411
+ "aria-labelledby": `${buttonId} ${rowProps.id}`,
288
412
  id: buttonId,
289
- isDisabled: isDisabled
290
- }),
291
- labelProps: {
292
- id: labelId
413
+ onPress: ()=>onRemove ? onRemove(new Set([
414
+ item.key
415
+ ])) : null,
416
+ excludeFromTabOrder: true
293
417
  },
294
- tagRowProps: otherRowProps,
295
- tagProps: $aIvin$mergeProps(domProps, gridCellProps, {
296
- 'aria-disabled': isDisabled,
297
- 'aria-errormessage': props['aria-errormessage'],
298
- 'aria-label': props['aria-label'],
299
- onKeyDown: !isDisabled && isRemovable ? onKeyDown : null,
300
- tabIndex: (isFocused || state.selectionManager.focusedKey == null) && !isDisabled ? 0 : -1,
301
- onFocus () {
302
- state.selectionManager.setFocusedKey(item.childNodes[0].key);
303
- },
304
- ref: tagRef
305
- })
418
+ rowProps: (0, $aIvin$mergeProps)(rowProps, domProps, {
419
+ tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,
420
+ onKeyDown: onRemove ? onKeyDown : undefined,
421
+ "aria-describedby": descProps["aria-describedby"]
422
+ }),
423
+ gridCellProps: (0, $aIvin$mergeProps)(gridCellProps, {
424
+ "aria-errormessage": props["aria-errormessage"],
425
+ "aria-label": props["aria-label"]
426
+ }),
427
+ ...states,
428
+ allowsRemoving: !!onRemove
306
429
  };
307
430
  }
308
431
 
309
432
 
310
- var $d7323bca8d074eeb$exports = {};
311
-
312
- $parcel$export($d7323bca8d074eeb$exports, "useTagGroup", () => $d7323bca8d074eeb$export$4f8b5cda58b7e8ff);
313
-
314
-
315
-
316
- function $d7323bca8d074eeb$export$4f8b5cda58b7e8ff(props, listState) {
317
- let { isDisabled: isDisabled } = props;
318
- let [isFocusWithin, setFocusWithin] = $aIvin$useState(false);
319
- let { focusWithinProps: focusWithinProps } = $aIvin$useFocusWithin({
320
- onFocusWithinChange: setFocusWithin
321
- });
322
- let allKeys = [
323
- ...listState.collection.getKeys()
324
- ];
325
- if (!allKeys.some((key)=>!listState.disabledKeys.has(key)
326
- )) isDisabled = true;
327
- let domProps = $aIvin$filterDOMProps(props);
328
- return {
329
- tagGroupProps: $aIvin$mergeProps(domProps, {
330
- 'aria-atomic': false,
331
- 'aria-relevant': 'additions',
332
- 'aria-live': isFocusWithin ? 'polite' : 'off',
333
- 'aria-disabled': isDisabled === true,
334
- ...focusWithinProps
335
- })
336
- };
337
- }
338
-
339
433
 
340
434
 
341
435
 
342
- export {$542448901dbd2c36$export$b00754732e683b92 as TagKeyboardDelegate, $fc6126c82a4601f1$export$3f568fff7dff2f03 as useTag, $d7323bca8d074eeb$export$4f8b5cda58b7e8ff as useTagGroup};
436
+ export {$fc6126c82a4601f1$export$3f568fff7dff2f03 as useTag, $d7323bca8d074eeb$export$4f8b5cda58b7e8ff as useTagGroup};
343
437
  //# sourceMappingURL=module.js.map