@react-aria/tag 3.0.0-nightly.3175 → 3.0.0-rc.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.
@@ -0,0 +1,466 @@
1
+ import {useId as $aIvin$useId, chain as $aIvin$chain, 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} from "react";
6
+ import {useField as $aIvin$useField} from "@react-aria/label";
7
+
8
+ function $parcel$interopDefault(a) {
9
+ return a && a.__esModule ? a.default : a;
10
+ }
11
+ /*
12
+ * Copyright 2020 Adobe. All rights reserved.
13
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
+ * you may not use this file except in compliance with the License. You may obtain a copy
15
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software distributed under
18
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
+ * OF ANY KIND, either express or implied. See the License for the specific language
20
+ * governing permissions and limitations under the License.
21
+ */ /*
22
+ * Copyright 2020 Adobe. All rights reserved.
23
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
24
+ * you may not use this file except in compliance with the License. You may obtain a copy
25
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
26
+ *
27
+ * Unless required by applicable law or agreed to in writing, software distributed under
28
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
29
+ * OF ANY KIND, either express or implied. See the License for the specific language
30
+ * governing permissions and limitations under the License.
31
+ */ class $542448901dbd2c36$export$b00754732e683b92 {
32
+ getFirstKey() {
33
+ return this.collection.getFirstKey();
34
+ }
35
+ getLastKey() {
36
+ return this.collection.getLastKey();
37
+ }
38
+ getKeyRightOf(key) {
39
+ return this.direction === "rtl" ? this.getKeyAbove(key) : this.getKeyBelow(key);
40
+ }
41
+ getKeyLeftOf(key) {
42
+ return this.direction === "rtl" ? this.getKeyBelow(key) : this.getKeyAbove(key);
43
+ }
44
+ getKeyBelow(key) {
45
+ let startItem = this.collection.getItem(key);
46
+ if (!startItem) return;
47
+ // Find the next item
48
+ key = this.collection.getKeyAfter(key);
49
+ if (key != null) return key;
50
+ else return this.collection.getFirstKey();
51
+ }
52
+ getKeyAbove(key) {
53
+ let startItem = this.collection.getItem(key);
54
+ if (!startItem) return;
55
+ // Find the previous item
56
+ key = this.collection.getKeyBefore(key);
57
+ if (key != null) return key;
58
+ else return this.collection.getLastKey();
59
+ }
60
+ getKeyPageAbove(key) {
61
+ return this.getKeyAbove(key);
62
+ }
63
+ getKeyPageBelow(key) {
64
+ return this.getKeyBelow(key);
65
+ }
66
+ constructor(collection, direction){
67
+ this.collection = collection;
68
+ this.direction = direction;
69
+ }
70
+ }
71
+
72
+
73
+ /*
74
+ * Copyright 2020 Adobe. All rights reserved.
75
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
76
+ * you may not use this file except in compliance with the License. You may obtain a copy
77
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
78
+ *
79
+ * Unless required by applicable law or agreed to in writing, software distributed under
80
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
81
+ * OF ANY KIND, either express or implied. See the License for the specific language
82
+ * governing permissions and limitations under the License.
83
+ */
84
+ var $4d1b62e0e67c00a4$exports = {};
85
+ var $84925f526f90eebd$exports = {};
86
+ $84925f526f90eebd$exports = {
87
+ "removeButtonLabel": `إزالة`,
88
+ "removeDescription": `اضغط على مفتاح DELETE لإزالة علامة.`
89
+ };
90
+
91
+
92
+ var $c0650163dc1b6f9d$exports = {};
93
+ $c0650163dc1b6f9d$exports = {
94
+ "removeButtonLabel": `Премахване`,
95
+ "removeDescription": `Натиснете Delete, за да премахнете маркера.`
96
+ };
97
+
98
+
99
+ var $b2b55661291de587$exports = {};
100
+ $b2b55661291de587$exports = {
101
+ "removeButtonLabel": `Odebrat`,
102
+ "removeDescription": `Stisknutím klávesy Delete odeberete značku.`
103
+ };
104
+
105
+
106
+ var $deb83970956f6d5b$exports = {};
107
+ $deb83970956f6d5b$exports = {
108
+ "removeButtonLabel": `Fjern`,
109
+ "removeDescription": `Tryk på Slet for at fjerne tag.`
110
+ };
111
+
112
+
113
+ var $aea1cb4c7ec97e1c$exports = {};
114
+ $aea1cb4c7ec97e1c$exports = {
115
+ "removeButtonLabel": `Entfernen`,
116
+ "removeDescription": `Auf „Löschen“ drücken, um das Tag zu entfernen.`
117
+ };
118
+
119
+
120
+ var $3618d917e503a8d3$exports = {};
121
+ $3618d917e503a8d3$exports = {
122
+ "removeButtonLabel": `Κατάργηση`,
123
+ "removeDescription": `Πατήστε Διαγραφή για να καταργήσετε την ετικέτα.`
124
+ };
125
+
126
+
127
+ var $9eb56bbbe8e31294$exports = {};
128
+ $9eb56bbbe8e31294$exports = {
129
+ "removeDescription": `Press Delete to remove tag.`,
130
+ "removeButtonLabel": `Remove`
131
+ };
132
+
133
+
134
+ var $361c604b0fc269a3$exports = {};
135
+ $361c604b0fc269a3$exports = {
136
+ "removeButtonLabel": `Quitar`,
137
+ "removeDescription": `Pulse Eliminar para quitar la etiqueta.`
138
+ };
139
+
140
+
141
+ var $2f00170f4ee3ca01$exports = {};
142
+ $2f00170f4ee3ca01$exports = {
143
+ "removeButtonLabel": `Eemalda`,
144
+ "removeDescription": `Sildi eemaldamiseks vajutage kustutusklahvi Delete.`
145
+ };
146
+
147
+
148
+ var $80ee16b64fab9fb5$exports = {};
149
+ $80ee16b64fab9fb5$exports = {
150
+ "removeButtonLabel": `Poista`,
151
+ "removeDescription": `Poista tunniste painamalla Poista-painiketta.`
152
+ };
153
+
154
+
155
+ var $be9d354476c08087$exports = {};
156
+ $be9d354476c08087$exports = {
157
+ "removeButtonLabel": `Supprimer`,
158
+ "removeDescription": `Appuyez sur Supprimer pour supprimer l’étiquette.`
159
+ };
160
+
161
+
162
+ var $ffeb903ba092eb35$exports = {};
163
+ $ffeb903ba092eb35$exports = {
164
+ "removeButtonLabel": `הסר`,
165
+ "removeDescription": `לחץ על מחק כדי להסיר תג.`
166
+ };
167
+
168
+
169
+ var $1df6722c6f19728b$exports = {};
170
+ $1df6722c6f19728b$exports = {
171
+ "removeButtonLabel": `Ukloni`,
172
+ "removeDescription": `Pritisnite Delete za uklanjanje oznake.`
173
+ };
174
+
175
+
176
+ var $093d57e325bc9071$exports = {};
177
+ $093d57e325bc9071$exports = {
178
+ "removeButtonLabel": `Eltávolítás`,
179
+ "removeDescription": `Nyomja meg a Delete billentyűt a címke eltávolításához.`
180
+ };
181
+
182
+
183
+ var $609dbdfbcad85bdb$exports = {};
184
+ $609dbdfbcad85bdb$exports = {
185
+ "removeButtonLabel": `Rimuovi`,
186
+ "removeDescription": `Premi Elimina per rimuovere il tag.`
187
+ };
188
+
189
+
190
+ var $c08e84f882644048$exports = {};
191
+ $c08e84f882644048$exports = {
192
+ "removeButtonLabel": `削除`,
193
+ "removeDescription": `タグを削除するには、Delete キーを押します。`
194
+ };
195
+
196
+
197
+ var $5cd130489822fa21$exports = {};
198
+ $5cd130489822fa21$exports = {
199
+ "removeButtonLabel": `제거`,
200
+ "removeDescription": `태그를 제거하려면 Delete 키를 누르십시오.`
201
+ };
202
+
203
+
204
+ var $ab5183739b6c5e7e$exports = {};
205
+ $ab5183739b6c5e7e$exports = {
206
+ "removeButtonLabel": `Pašalinti`,
207
+ "removeDescription": `Norėdami pašalinti žymą, paspauskite „Delete“ klavišą.`
208
+ };
209
+
210
+
211
+ var $dd84a0b574be3f23$exports = {};
212
+ $dd84a0b574be3f23$exports = {
213
+ "removeButtonLabel": `Noņemt`,
214
+ "removeDescription": `Nospiediet Delete [Dzēst], lai noņemtu tagu.`
215
+ };
216
+
217
+
218
+ var $85eee97d14eef7b5$exports = {};
219
+ $85eee97d14eef7b5$exports = {
220
+ "removeButtonLabel": `Fjern`,
221
+ "removeDescription": `Trykk på Slett for å fjerne taggen.`
222
+ };
223
+
224
+
225
+ var $18781839f93b0314$exports = {};
226
+ $18781839f93b0314$exports = {
227
+ "removeButtonLabel": `Verwijderen`,
228
+ "removeDescription": `Druk op Verwijderen om de tag te verwijderen.`
229
+ };
230
+
231
+
232
+ var $1c40ffbbfe9f3bda$exports = {};
233
+ $1c40ffbbfe9f3bda$exports = {
234
+ "removeButtonLabel": `Usuń`,
235
+ "removeDescription": `Naciśnij Usuń, aby usunąć znacznik.`
236
+ };
237
+
238
+
239
+ var $156880e329b1c717$exports = {};
240
+ $156880e329b1c717$exports = {
241
+ "removeButtonLabel": `Remover`,
242
+ "removeDescription": `Pressione Delete para remover a tag.`
243
+ };
244
+
245
+
246
+ var $b6d50b1d20768ce4$exports = {};
247
+ $b6d50b1d20768ce4$exports = {
248
+ "removeButtonLabel": `Eliminar`,
249
+ "removeDescription": `Prima Delete para eliminar a tag.`
250
+ };
251
+
252
+
253
+ var $d8c38c691b006187$exports = {};
254
+ $d8c38c691b006187$exports = {
255
+ "removeButtonLabel": `Îndepărtaţi`,
256
+ "removeDescription": `Apăsați pe Delete (Ștergere) pentru a elimina eticheta.`
257
+ };
258
+
259
+
260
+ var $ed9b4bf7ce1fb1d7$exports = {};
261
+ $ed9b4bf7ce1fb1d7$exports = {
262
+ "removeButtonLabel": `Удалить`,
263
+ "removeDescription": `Нажмите DELETE, чтобы удалить тег.`
264
+ };
265
+
266
+
267
+ var $51d8721afda4d678$exports = {};
268
+ $51d8721afda4d678$exports = {
269
+ "removeButtonLabel": `Odstrániť`,
270
+ "removeDescription": `Ak chcete odstrániť značku, stlačte kláves Delete.`
271
+ };
272
+
273
+
274
+ var $fd37a27baae493e8$exports = {};
275
+ $fd37a27baae493e8$exports = {
276
+ "removeButtonLabel": `Odstrani`,
277
+ "removeDescription": `Pritisnite Delete, da odstranite oznako.`
278
+ };
279
+
280
+
281
+ var $5505a1ca71ffd6f4$exports = {};
282
+ $5505a1ca71ffd6f4$exports = {
283
+ "removeButtonLabel": `Ukloni`,
284
+ "removeDescription": `Pritisnite Obriši da biste uklonili oznaku.`
285
+ };
286
+
287
+
288
+ var $33670e148c84ad02$exports = {};
289
+ $33670e148c84ad02$exports = {
290
+ "removeButtonLabel": `Ta bort`,
291
+ "removeDescription": `Tryck på Radera för att ta bort taggen.`
292
+ };
293
+
294
+
295
+ var $0bf46fdcdd7cb5f6$exports = {};
296
+ $0bf46fdcdd7cb5f6$exports = {
297
+ "removeButtonLabel": `Kaldır`,
298
+ "removeDescription": `Etiketi kaldırmak için Sil tuşuna basın.`
299
+ };
300
+
301
+
302
+ var $9d9765222bc08ca2$exports = {};
303
+ $9d9765222bc08ca2$exports = {
304
+ "removeButtonLabel": `Вилучити`,
305
+ "removeDescription": `Натисніть Delete, щоб вилучити тег.`
306
+ };
307
+
308
+
309
+ var $d737296cedcdee9f$exports = {};
310
+ $d737296cedcdee9f$exports = {
311
+ "removeButtonLabel": `删除`,
312
+ "removeDescription": `按下“删除”以删除标记。`
313
+ };
314
+
315
+
316
+ var $09cd168ab18773f4$exports = {};
317
+ $09cd168ab18773f4$exports = {
318
+ "removeButtonLabel": `移除`,
319
+ "removeDescription": `按 Delete 鍵以移除標記。`
320
+ };
321
+
322
+
323
+ $4d1b62e0e67c00a4$exports = {
324
+ "ar-AE": $84925f526f90eebd$exports,
325
+ "bg-BG": $c0650163dc1b6f9d$exports,
326
+ "cs-CZ": $b2b55661291de587$exports,
327
+ "da-DK": $deb83970956f6d5b$exports,
328
+ "de-DE": $aea1cb4c7ec97e1c$exports,
329
+ "el-GR": $3618d917e503a8d3$exports,
330
+ "en-US": $9eb56bbbe8e31294$exports,
331
+ "es-ES": $361c604b0fc269a3$exports,
332
+ "et-EE": $2f00170f4ee3ca01$exports,
333
+ "fi-FI": $80ee16b64fab9fb5$exports,
334
+ "fr-FR": $be9d354476c08087$exports,
335
+ "he-IL": $ffeb903ba092eb35$exports,
336
+ "hr-HR": $1df6722c6f19728b$exports,
337
+ "hu-HU": $093d57e325bc9071$exports,
338
+ "it-IT": $609dbdfbcad85bdb$exports,
339
+ "ja-JP": $c08e84f882644048$exports,
340
+ "ko-KR": $5cd130489822fa21$exports,
341
+ "lt-LT": $ab5183739b6c5e7e$exports,
342
+ "lv-LV": $dd84a0b574be3f23$exports,
343
+ "nb-NO": $85eee97d14eef7b5$exports,
344
+ "nl-NL": $18781839f93b0314$exports,
345
+ "pl-PL": $1c40ffbbfe9f3bda$exports,
346
+ "pt-BR": $156880e329b1c717$exports,
347
+ "pt-PT": $b6d50b1d20768ce4$exports,
348
+ "ro-RO": $d8c38c691b006187$exports,
349
+ "ru-RU": $ed9b4bf7ce1fb1d7$exports,
350
+ "sk-SK": $51d8721afda4d678$exports,
351
+ "sl-SI": $fd37a27baae493e8$exports,
352
+ "sr-SP": $5505a1ca71ffd6f4$exports,
353
+ "sv-SE": $33670e148c84ad02$exports,
354
+ "tr-TR": $0bf46fdcdd7cb5f6$exports,
355
+ "uk-UA": $9d9765222bc08ca2$exports,
356
+ "zh-CN": $d737296cedcdee9f$exports,
357
+ "zh-TW": $09cd168ab18773f4$exports
358
+ };
359
+
360
+
361
+
362
+
363
+
364
+ function $fc6126c82a4601f1$export$3f568fff7dff2f03(props, state, ref) {
365
+ let { allowsRemoving: allowsRemoving , item: item } = props;
366
+ let stringFormatter = (0, $aIvin$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($4d1b62e0e67c00a4$exports))));
367
+ let labelId = (0, $aIvin$useId)();
368
+ let buttonId = (0, $aIvin$useId)();
369
+ let { rowProps: rowProps , gridCellProps: gridCellProps } = (0, $aIvin$useGridListItem)({
370
+ node: item
371
+ }, state, ref);
372
+ // We want the group to handle keyboard navigation between tags.
373
+ delete rowProps.onKeyDownCapture;
374
+ let onRemove = (0, $aIvin$chain)(props.onRemove, state.onRemove);
375
+ let onKeyDown = (e)=>{
376
+ if (e.key === "Delete" || e.key === "Backspace") {
377
+ onRemove(item.key);
378
+ e.preventDefault();
379
+ }
380
+ };
381
+ let modality = (0, $aIvin$useInteractionModality)();
382
+ if (modality === "virtual" && typeof window !== "undefined" && "ontouchstart" in window) modality = "touch";
383
+ let description = allowsRemoving && (modality === "keyboard" || modality === "virtual") ? stringFormatter.format("removeDescription") : "";
384
+ let descProps = (0, $aIvin$useDescription)(description);
385
+ let domProps = (0, $aIvin$filterDOMProps)(props);
386
+ let isFocused = item.key === state.selectionManager.focusedKey;
387
+ return {
388
+ removeButtonProps: {
389
+ "aria-label": stringFormatter.format("removeButtonLabel", {
390
+ label: item.textValue
391
+ }),
392
+ "aria-labelledby": `${buttonId} ${labelId}`,
393
+ id: buttonId,
394
+ onPress: ()=>allowsRemoving && onRemove ? onRemove(item.key) : null,
395
+ excludeFromTabOrder: true
396
+ },
397
+ labelProps: {
398
+ id: labelId
399
+ },
400
+ rowProps: {
401
+ ...rowProps,
402
+ tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,
403
+ onKeyDown: allowsRemoving ? onKeyDown : null,
404
+ "aria-describedby": descProps["aria-describedby"]
405
+ },
406
+ gridCellProps: (0, $aIvin$mergeProps)(domProps, gridCellProps, {
407
+ "aria-errormessage": props["aria-errormessage"],
408
+ "aria-label": props["aria-label"]
409
+ })
410
+ };
411
+ }
412
+
413
+
414
+ /*
415
+ * Copyright 2020 Adobe. All rights reserved.
416
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
417
+ * you may not use this file except in compliance with the License. You may obtain a copy
418
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
419
+ *
420
+ * Unless required by applicable law or agreed to in writing, software distributed under
421
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
422
+ * OF ANY KIND, either express or implied. See the License for the specific language
423
+ * governing permissions and limitations under the License.
424
+ */
425
+
426
+
427
+
428
+
429
+
430
+
431
+ function $d7323bca8d074eeb$export$4f8b5cda58b7e8ff(props, state, ref) {
432
+ let { direction: direction } = (0, $aIvin$useLocale)();
433
+ let keyboardDelegate = props.keyboardDelegate || new (0, $542448901dbd2c36$export$b00754732e683b92)(state.collection, direction);
434
+ let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $aIvin$useField)(props);
435
+ let { gridProps: gridProps } = (0, $aIvin$useGridList)({
436
+ ...props,
437
+ ...fieldProps,
438
+ keyboardDelegate: keyboardDelegate
439
+ }, state, ref);
440
+ // Don't want the grid to be focusable or accessible via keyboard
441
+ delete gridProps.tabIndex;
442
+ let [isFocusWithin, setFocusWithin] = (0, $aIvin$useState)(false);
443
+ let { focusWithinProps: focusWithinProps } = (0, $aIvin$useFocusWithin)({
444
+ onFocusWithinChange: setFocusWithin
445
+ });
446
+ let domProps = (0, $aIvin$filterDOMProps)(props);
447
+ return {
448
+ gridProps: (0, $aIvin$mergeProps)(gridProps, domProps, {
449
+ role: state.collection.size ? "grid" : null,
450
+ "aria-atomic": false,
451
+ "aria-relevant": "additions",
452
+ "aria-live": isFocusWithin ? "polite" : "off",
453
+ ...focusWithinProps,
454
+ ...fieldProps
455
+ }),
456
+ labelProps: labelProps,
457
+ descriptionProps: descriptionProps,
458
+ errorMessageProps: errorMessageProps
459
+ };
460
+ }
461
+
462
+
463
+
464
+
465
+ export {$542448901dbd2c36$export$b00754732e683b92 as TagKeyboardDelegate, $fc6126c82a4601f1$export$3f568fff7dff2f03 as useTag, $d7323bca8d074eeb$export$4f8b5cda58b7e8ff as useTagGroup};
466
+ //# sourceMappingURL=module.js.map