@depup/react-aria-components 1.19.0-depup.27 → 1.20.0-depup.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/PreviewTrigger/package.json +5 -0
- package/README.md +2 -2
- package/TokenField/package.json +5 -0
- package/changes.json +1 -1
- package/dist/exports/GridList.cjs.map +1 -1
- package/dist/exports/GridList.js.map +1 -1
- package/dist/exports/GridList.mjs.map +1 -1
- package/dist/exports/PreviewTrigger.cjs +26 -0
- package/dist/exports/PreviewTrigger.cjs.map +1 -0
- package/dist/exports/PreviewTrigger.js +21 -0
- package/dist/exports/PreviewTrigger.js.map +1 -0
- package/dist/exports/PreviewTrigger.mjs +21 -0
- package/dist/exports/PreviewTrigger.mjs.map +1 -0
- package/dist/exports/TokenField.cjs +31 -0
- package/dist/exports/TokenField.cjs.map +1 -0
- package/dist/exports/TokenField.js +21 -0
- package/dist/exports/TokenField.js.map +1 -0
- package/dist/exports/TokenField.mjs +21 -0
- package/dist/exports/TokenField.mjs.map +1 -0
- package/dist/exports/Tree.cjs.map +1 -1
- package/dist/exports/Tree.js.map +1 -1
- package/dist/exports/Tree.mjs.map +1 -1
- package/dist/exports/index.cjs +12 -0
- package/dist/exports/index.cjs.map +1 -1
- package/dist/exports/index.js +7 -1
- package/dist/exports/index.js.map +1 -1
- package/dist/exports/index.mjs +7 -1
- package/dist/exports/index.mjs.map +1 -1
- package/dist/private/Checkbox.cjs.map +1 -1
- package/dist/private/Checkbox.js.map +1 -1
- package/dist/private/Checkbox.mjs.map +1 -1
- package/dist/private/ComboBox.cjs +21 -2
- package/dist/private/ComboBox.cjs.map +1 -1
- package/dist/private/ComboBox.js +21 -2
- package/dist/private/ComboBox.js.map +1 -1
- package/dist/private/ComboBox.mjs +21 -2
- package/dist/private/ComboBox.mjs.map +1 -1
- package/dist/private/Dialog.cjs +15 -1
- package/dist/private/Dialog.cjs.map +1 -1
- package/dist/private/Dialog.js +15 -1
- package/dist/private/Dialog.js.map +1 -1
- package/dist/private/Dialog.mjs +15 -1
- package/dist/private/Dialog.mjs.map +1 -1
- package/dist/private/DragAndDrop.cjs +1 -0
- package/dist/private/DragAndDrop.cjs.map +1 -1
- package/dist/private/DragAndDrop.js +1 -0
- package/dist/private/DragAndDrop.js.map +1 -1
- package/dist/private/DragAndDrop.mjs +1 -0
- package/dist/private/DragAndDrop.mjs.map +1 -1
- package/dist/private/DropZone.cjs +5 -2
- package/dist/private/DropZone.cjs.map +1 -1
- package/dist/private/DropZone.js +5 -3
- package/dist/private/DropZone.js.map +1 -1
- package/dist/private/DropZone.mjs +5 -2
- package/dist/private/DropZone.mjs.map +1 -1
- package/dist/private/FileTrigger.cjs +1 -0
- package/dist/private/FileTrigger.cjs.map +1 -1
- package/dist/private/FileTrigger.js +1 -0
- package/dist/private/FileTrigger.js.map +1 -1
- package/dist/private/FileTrigger.mjs +1 -0
- package/dist/private/FileTrigger.mjs.map +1 -1
- package/dist/private/GridLayout.cjs +3 -1
- package/dist/private/GridLayout.cjs.map +1 -1
- package/dist/private/GridLayout.js +3 -1
- package/dist/private/GridLayout.js.map +1 -1
- package/dist/private/GridLayout.mjs +3 -1
- package/dist/private/GridLayout.mjs.map +1 -1
- package/dist/private/GridList.cjs +12 -1
- package/dist/private/GridList.cjs.map +1 -1
- package/dist/private/GridList.js +12 -1
- package/dist/private/GridList.js.map +1 -1
- package/dist/private/GridList.mjs +12 -1
- package/dist/private/GridList.mjs.map +1 -1
- package/dist/private/ListBox.cjs +9 -1
- package/dist/private/ListBox.cjs.map +1 -1
- package/dist/private/ListBox.js +9 -1
- package/dist/private/ListBox.js.map +1 -1
- package/dist/private/ListBox.mjs +9 -1
- package/dist/private/ListBox.mjs.map +1 -1
- package/dist/private/Menu.cjs +4 -2
- package/dist/private/Menu.cjs.map +1 -1
- package/dist/private/Menu.js +4 -2
- package/dist/private/Menu.js.map +1 -1
- package/dist/private/Menu.mjs +4 -2
- package/dist/private/Menu.mjs.map +1 -1
- package/dist/private/Meter.cjs +2 -1
- package/dist/private/Meter.cjs.map +1 -1
- package/dist/private/Meter.js +2 -1
- package/dist/private/Meter.js.map +1 -1
- package/dist/private/Meter.mjs +2 -1
- package/dist/private/Meter.mjs.map +1 -1
- package/dist/private/Modal.cjs +2 -0
- package/dist/private/Modal.cjs.map +1 -1
- package/dist/private/Modal.js +2 -0
- package/dist/private/Modal.js.map +1 -1
- package/dist/private/Modal.mjs +2 -0
- package/dist/private/Modal.mjs.map +1 -1
- package/dist/private/Popover.cjs +34 -9
- package/dist/private/Popover.cjs.map +1 -1
- package/dist/private/Popover.js +34 -9
- package/dist/private/Popover.js.map +1 -1
- package/dist/private/Popover.mjs +34 -9
- package/dist/private/Popover.mjs.map +1 -1
- package/dist/private/PreviewTrigger.cjs +88 -0
- package/dist/private/PreviewTrigger.cjs.map +1 -0
- package/dist/private/PreviewTrigger.js +80 -0
- package/dist/private/PreviewTrigger.js.map +1 -0
- package/dist/private/PreviewTrigger.mjs +79 -0
- package/dist/private/PreviewTrigger.mjs.map +1 -0
- package/dist/private/ProgressBar.cjs +6 -1
- package/dist/private/ProgressBar.cjs.map +1 -1
- package/dist/private/ProgressBar.js +6 -1
- package/dist/private/ProgressBar.js.map +1 -1
- package/dist/private/ProgressBar.mjs +6 -1
- package/dist/private/ProgressBar.mjs.map +1 -1
- package/dist/private/Select.cjs.map +1 -1
- package/dist/private/Select.js.map +1 -1
- package/dist/private/Select.mjs.map +1 -1
- package/dist/private/Table.cjs +26 -14
- package/dist/private/Table.cjs.map +1 -1
- package/dist/private/Table.js +26 -14
- package/dist/private/Table.js.map +1 -1
- package/dist/private/Table.mjs +26 -14
- package/dist/private/Table.mjs.map +1 -1
- package/dist/private/TableLayout.cjs +3 -1
- package/dist/private/TableLayout.cjs.map +1 -1
- package/dist/private/TableLayout.js +3 -1
- package/dist/private/TableLayout.js.map +1 -1
- package/dist/private/TableLayout.mjs +3 -1
- package/dist/private/TableLayout.mjs.map +1 -1
- package/dist/private/TagGroup.cjs +1 -0
- package/dist/private/TagGroup.cjs.map +1 -1
- package/dist/private/TagGroup.js +1 -0
- package/dist/private/TagGroup.js.map +1 -1
- package/dist/private/TagGroup.mjs +1 -0
- package/dist/private/TagGroup.mjs.map +1 -1
- package/dist/private/ToggleButton.cjs.map +1 -1
- package/dist/private/ToggleButton.js.map +1 -1
- package/dist/private/ToggleButton.mjs.map +1 -1
- package/dist/private/TokenField.cjs +207 -0
- package/dist/private/TokenField.cjs.map +1 -0
- package/dist/private/TokenField.js +197 -0
- package/dist/private/TokenField.js.map +1 -0
- package/dist/private/TokenField.mjs +195 -0
- package/dist/private/TokenField.mjs.map +1 -0
- package/dist/private/Tooltip.cjs +10 -2
- package/dist/private/Tooltip.cjs.map +1 -1
- package/dist/private/Tooltip.js +10 -2
- package/dist/private/Tooltip.js.map +1 -1
- package/dist/private/Tooltip.mjs +10 -2
- package/dist/private/Tooltip.mjs.map +1 -1
- package/dist/private/Tree.cjs +11 -1
- package/dist/private/Tree.cjs.map +1 -1
- package/dist/private/Tree.js +11 -1
- package/dist/private/Tree.js.map +1 -1
- package/dist/private/Tree.mjs +11 -1
- package/dist/private/Tree.mjs.map +1 -1
- package/dist/private/Virtualizer.cjs +18 -16
- package/dist/private/Virtualizer.cjs.map +1 -1
- package/dist/private/Virtualizer.js +18 -16
- package/dist/private/Virtualizer.js.map +1 -1
- package/dist/private/Virtualizer.mjs +18 -16
- package/dist/private/Virtualizer.mjs.map +1 -1
- package/dist/private/useDragAndDrop.cjs +7 -0
- package/dist/private/useDragAndDrop.cjs.map +1 -1
- package/dist/private/useDragAndDrop.js +7 -0
- package/dist/private/useDragAndDrop.js.map +1 -1
- package/dist/private/useDragAndDrop.mjs +7 -0
- package/dist/private/useDragAndDrop.mjs.map +1 -1
- package/dist/private/utils.cjs.map +1 -1
- package/dist/private/utils.js.map +1 -1
- package/dist/private/utils.mjs.map +1 -1
- package/dist/types/exports/GridList.d.ts +1 -1
- package/dist/types/exports/PreviewTrigger.d.ts +3 -0
- package/dist/types/exports/TokenField.d.ts +5 -0
- package/dist/types/exports/Tree.d.ts +1 -1
- package/dist/types/exports/index.d.ts +7 -2
- package/dist/types/src/ComboBox.d.ts +4 -1
- package/dist/types/src/GridList.d.ts +12 -1
- package/dist/types/src/ListBox.d.ts +1 -1
- package/dist/types/src/Popover.d.ts +7 -0
- package/dist/types/src/PreviewTrigger.d.ts +23 -0
- package/dist/types/src/Select.d.ts +1 -1
- package/dist/types/src/Table.d.ts +24 -0
- package/dist/types/src/TokenField.d.ts +111 -0
- package/dist/types/src/Tree.d.ts +7 -5
- package/dist/types/src/Virtualizer.d.ts +4 -0
- package/dist/types/src/utils.d.ts +19 -5
- package/i18n/ar-AE.js +1 -1
- package/i18n/ar-AE.mjs +1 -1
- package/i18n/bg-BG.js +1 -1
- package/i18n/bg-BG.mjs +1 -1
- package/i18n/cs-CZ.js +1 -1
- package/i18n/cs-CZ.mjs +1 -1
- package/i18n/da-DK.js +1 -1
- package/i18n/da-DK.mjs +1 -1
- package/i18n/de-DE.js +1 -1
- package/i18n/de-DE.mjs +1 -1
- package/i18n/el-GR.js +1 -1
- package/i18n/el-GR.mjs +1 -1
- package/i18n/en-US.js +1 -1
- package/i18n/en-US.mjs +1 -1
- package/i18n/es-ES.js +1 -1
- package/i18n/es-ES.mjs +1 -1
- package/i18n/et-EE.js +1 -1
- package/i18n/et-EE.mjs +1 -1
- package/i18n/fi-FI.js +1 -1
- package/i18n/fi-FI.mjs +1 -1
- package/i18n/fr-FR.js +1 -1
- package/i18n/fr-FR.mjs +1 -1
- package/i18n/he-IL.js +1 -1
- package/i18n/he-IL.mjs +1 -1
- package/i18n/hr-HR.js +1 -1
- package/i18n/hr-HR.mjs +1 -1
- package/i18n/hu-HU.js +1 -1
- package/i18n/hu-HU.mjs +1 -1
- package/i18n/it-IT.js +1 -1
- package/i18n/it-IT.mjs +1 -1
- package/i18n/ja-JP.js +1 -1
- package/i18n/ja-JP.mjs +1 -1
- package/i18n/ko-KR.js +1 -1
- package/i18n/ko-KR.mjs +1 -1
- package/i18n/lt-LT.js +1 -1
- package/i18n/lt-LT.mjs +1 -1
- package/i18n/lv-LV.js +1 -1
- package/i18n/lv-LV.mjs +1 -1
- package/i18n/nb-NO.js +1 -1
- package/i18n/nb-NO.mjs +1 -1
- package/i18n/nl-NL.js +1 -1
- package/i18n/nl-NL.mjs +1 -1
- package/i18n/pl-PL.js +1 -1
- package/i18n/pl-PL.mjs +1 -1
- package/i18n/pt-BR.js +1 -1
- package/i18n/pt-BR.mjs +1 -1
- package/i18n/pt-PT.js +1 -1
- package/i18n/pt-PT.mjs +1 -1
- package/i18n/ro-RO.js +1 -1
- package/i18n/ro-RO.mjs +1 -1
- package/i18n/ru-RU.js +1 -1
- package/i18n/ru-RU.mjs +1 -1
- package/i18n/sk-SK.js +1 -1
- package/i18n/sk-SK.mjs +1 -1
- package/i18n/sl-SI.js +1 -1
- package/i18n/sl-SI.mjs +1 -1
- package/i18n/sr-SP.js +1 -1
- package/i18n/sr-SP.mjs +1 -1
- package/i18n/sv-SE.js +1 -1
- package/i18n/sv-SE.mjs +1 -1
- package/i18n/tr-TR.js +1 -1
- package/i18n/tr-TR.mjs +1 -1
- package/i18n/uk-UA.js +1 -1
- package/i18n/uk-UA.mjs +1 -1
- package/i18n/zh-CN.js +1 -1
- package/i18n/zh-CN.mjs +1 -1
- package/i18n/zh-TW.js +1 -1
- package/i18n/zh-TW.mjs +1 -1
- package/package.json +32 -31
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
var $048d76b84370f141$exports = require("./utils.cjs");
|
|
2
|
+
var $433949643203e332$exports = require("./Autocomplete.cjs");
|
|
3
|
+
var $d5d46822336ca1e1$exports = require("./Label.cjs");
|
|
4
|
+
var $cab7d9a238d19c33$exports = require("./Text.cjs");
|
|
5
|
+
var $4P2rL$reactariaprivatecollectionsHidden = require("react-aria/private/collections/Hidden");
|
|
6
|
+
var $4P2rL$reactariafilterDOMProps = require("react-aria/filterDOMProps");
|
|
7
|
+
var $4P2rL$reactariauseHover = require("react-aria/useHover");
|
|
8
|
+
var $4P2rL$reactariamergeProps = require("react-aria/mergeProps");
|
|
9
|
+
var $4P2rL$reactariamergeRefs = require("react-aria/mergeRefs");
|
|
10
|
+
var $4P2rL$react = require("react");
|
|
11
|
+
var $4P2rL$reactstatelyuseTokenFieldState = require("react-stately/useTokenFieldState");
|
|
12
|
+
var $4P2rL$reactariauseFocusRing = require("react-aria/useFocusRing");
|
|
13
|
+
var $4P2rL$reactariauseObjectRef = require("react-aria/useObjectRef");
|
|
14
|
+
var $4P2rL$reactariauseTokenField = require("react-aria/useTokenField");
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
function $parcel$interopDefault(a) {
|
|
18
|
+
return a && a.__esModule ? a.default : a;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function $parcel$export(e, n, v, s) {
|
|
22
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
$parcel$export(module.exports, "TokenFieldContext", function () { return $95baf1bfb6adc271$export$24532e5e37c56ff2; });
|
|
26
|
+
$parcel$export(module.exports, "TokenField", function () { return $95baf1bfb6adc271$export$e4550c392cbe69d7; });
|
|
27
|
+
$parcel$export(module.exports, "TokenInput", function () { return $95baf1bfb6adc271$export$4ddf413e820cfcc4; });
|
|
28
|
+
$parcel$export(module.exports, "Token", function () { return $95baf1bfb6adc271$export$50792b0e93539fde; });
|
|
29
|
+
/*
|
|
30
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
31
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
32
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
33
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
34
|
+
*
|
|
35
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
36
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
37
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
38
|
+
* governing permissions and limitations under the License.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
const $95baf1bfb6adc271$export$24532e5e37c56ff2 = /*#__PURE__*/ (0, $4P2rL$react.createContext)(null);
|
|
54
|
+
const $95baf1bfb6adc271$var$TokenInputContext = /*#__PURE__*/ (0, $4P2rL$react.createContext)(null);
|
|
55
|
+
const $95baf1bfb6adc271$export$e4550c392cbe69d7 = /*#__PURE__*/ (0, $4P2rL$reactariaprivatecollectionsHidden.createHideableComponent)(function TokenField(props, ref) {
|
|
56
|
+
[props, ref] = (0, $048d76b84370f141$exports.useContextProps)(props, ref, $95baf1bfb6adc271$export$24532e5e37c56ff2);
|
|
57
|
+
let [labelRef, label] = (0, $048d76b84370f141$exports.useSlot)(!props['aria-label'] && !props['aria-labelledby']);
|
|
58
|
+
let fieldCtx = (0, $048d76b84370f141$exports.useSlottedContext)((0, $433949643203e332$exports.FieldInputContext), props.slot);
|
|
59
|
+
let { value: _autocompleteValue, onChange: onAutocompleteChange, ref: autocompleteRef, ...autocompleteProps } = fieldCtx ?? {};
|
|
60
|
+
let inputRef = (0, $4P2rL$reactariauseObjectRef.useObjectRef)(autocompleteRef);
|
|
61
|
+
let isDisabled = props.isDisabled || false;
|
|
62
|
+
let isReadOnly = props.isReadOnly || false;
|
|
63
|
+
let state = (0, $4P2rL$reactstatelyuseTokenFieldState.useTokenFieldState)({
|
|
64
|
+
...props,
|
|
65
|
+
onChange: (value)=>{
|
|
66
|
+
props.onChange?.(value);
|
|
67
|
+
onAutocompleteChange?.(value.toString());
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
let { tokenFieldProps: tokenFieldProps, labelProps: labelProps, descriptionProps: descriptionProps } = (0, $4P2rL$reactariauseTokenField.useTokenField)({
|
|
71
|
+
...props,
|
|
72
|
+
label: // @ts-ignore - not a public prop, used to determine if slot is present
|
|
73
|
+
label,
|
|
74
|
+
role: props.role || autocompleteProps['role'] || 'textbox'
|
|
75
|
+
}, state, inputRef);
|
|
76
|
+
let renderProps = (0, $048d76b84370f141$exports.useRenderProps)({
|
|
77
|
+
...props,
|
|
78
|
+
values: {
|
|
79
|
+
isDisabled: isDisabled,
|
|
80
|
+
isReadOnly: isReadOnly
|
|
81
|
+
},
|
|
82
|
+
defaultClassName: 'react-aria-TokenField'
|
|
83
|
+
});
|
|
84
|
+
let DOMProps = (0, $4P2rL$reactariafilterDOMProps.filterDOMProps)(props, {
|
|
85
|
+
global: true
|
|
86
|
+
});
|
|
87
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($4P2rL$react))).createElement((0, $048d76b84370f141$exports.dom).div, {
|
|
88
|
+
...DOMProps,
|
|
89
|
+
...renderProps,
|
|
90
|
+
ref: ref,
|
|
91
|
+
slot: props.slot || undefined,
|
|
92
|
+
"data-disabled": isDisabled || undefined,
|
|
93
|
+
"data-readonly": isReadOnly || undefined
|
|
94
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($4P2rL$react))).createElement((0, $048d76b84370f141$exports.Provider), {
|
|
95
|
+
values: [
|
|
96
|
+
[
|
|
97
|
+
(0, $d5d46822336ca1e1$exports.LabelContext),
|
|
98
|
+
{
|
|
99
|
+
...labelProps,
|
|
100
|
+
elementType: 'span',
|
|
101
|
+
ref: labelRef
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
[
|
|
105
|
+
(0, $cab7d9a238d19c33$exports.TextContext),
|
|
106
|
+
{
|
|
107
|
+
slots: {
|
|
108
|
+
description: descriptionProps
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
[
|
|
113
|
+
$95baf1bfb6adc271$var$TokenInputContext,
|
|
114
|
+
{
|
|
115
|
+
tokenFieldProps: tokenFieldProps,
|
|
116
|
+
state: state,
|
|
117
|
+
isDisabled: isDisabled,
|
|
118
|
+
isReadOnly: isReadOnly,
|
|
119
|
+
autocompleteProps: autocompleteProps,
|
|
120
|
+
ref: inputRef
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
]
|
|
124
|
+
}, renderProps.children));
|
|
125
|
+
});
|
|
126
|
+
const $95baf1bfb6adc271$export$4ddf413e820cfcc4 = /*#__PURE__*/ (0, $4P2rL$react.forwardRef)(function TokenInput(props, forwardedRef) {
|
|
127
|
+
let { tokenFieldProps: tokenFieldProps, state: state, isDisabled: isDisabled = false, isReadOnly: isReadOnly = false, autocompleteProps: autocompleteProps, ref: contextRef } = (0, $4P2rL$react.useContext)($95baf1bfb6adc271$var$TokenInputContext);
|
|
128
|
+
let ref = (0, $4P2rL$react.useMemo)(()=>(0, $4P2rL$reactariamergeRefs.mergeRefs)(contextRef, forwardedRef), [
|
|
129
|
+
contextRef,
|
|
130
|
+
forwardedRef
|
|
131
|
+
]);
|
|
132
|
+
let { children: children, ...domProps } = props;
|
|
133
|
+
let { isHovered: isHovered, hoverProps: hoverProps } = (0, $4P2rL$reactariauseHover.useHover)(domProps);
|
|
134
|
+
let { isFocused: isFocused, isFocusVisible: isFocusVisible, focusProps: focusProps } = (0, $4P2rL$reactariauseFocusRing.useFocusRing)();
|
|
135
|
+
let renderProps = (0, $048d76b84370f141$exports.useRenderProps)({
|
|
136
|
+
...domProps,
|
|
137
|
+
defaultClassName: 'react-aria-TokenInput',
|
|
138
|
+
values: {
|
|
139
|
+
isHovered: isHovered,
|
|
140
|
+
isFocused: isFocused,
|
|
141
|
+
isFocusVisible: isFocusVisible,
|
|
142
|
+
isDisabled: isDisabled,
|
|
143
|
+
isReadOnly: isReadOnly
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
let DOMProps = (0, $4P2rL$reactariafilterDOMProps.filterDOMProps)(domProps, {
|
|
147
|
+
global: true
|
|
148
|
+
});
|
|
149
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($4P2rL$react))).createElement((0, $048d76b84370f141$exports.dom).div, {
|
|
150
|
+
...(0, $4P2rL$reactariamergeProps.mergeProps)(DOMProps, renderProps, focusProps, hoverProps, tokenFieldProps, autocompleteProps),
|
|
151
|
+
ref: ref,
|
|
152
|
+
"data-focused": isFocused || undefined,
|
|
153
|
+
"data-focus-visible": isFocusVisible || undefined,
|
|
154
|
+
"data-disabled": isDisabled || undefined,
|
|
155
|
+
"data-readonly": isReadOnly || undefined,
|
|
156
|
+
style: {
|
|
157
|
+
...renderProps.style,
|
|
158
|
+
...tokenFieldProps?.style
|
|
159
|
+
}
|
|
160
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($4P2rL$react))).createElement($95baf1bfb6adc271$var$CompositionRenderBlocker, {
|
|
161
|
+
isComposing: state.isComposing
|
|
162
|
+
}, state.value.segments.map((v, i)=>{
|
|
163
|
+
switch(v.type){
|
|
164
|
+
case 'token':
|
|
165
|
+
{
|
|
166
|
+
let token = children(v);
|
|
167
|
+
return(// Wrap tokens in zero-width spaces so the cursor is placed correctly.
|
|
168
|
+
/*#__PURE__*/ (0, ($parcel$interopDefault($4P2rL$react))).createElement("span", {
|
|
169
|
+
key: i
|
|
170
|
+
}, '\u200b', token, '\u200b'));
|
|
171
|
+
}
|
|
172
|
+
case 'text':
|
|
173
|
+
return v.text;
|
|
174
|
+
}
|
|
175
|
+
}), state.value.segments.at(-1)?.text.endsWith('\n') && /*#__PURE__*/ (0, ($parcel$interopDefault($4P2rL$react))).createElement("br", null)));
|
|
176
|
+
});
|
|
177
|
+
const $95baf1bfb6adc271$export$50792b0e93539fde = /*#__PURE__*/ (0, $4P2rL$react.forwardRef)(function Token(props, ref) {
|
|
178
|
+
let { isDisabled: isDisabled } = (0, $4P2rL$react.useContext)($95baf1bfb6adc271$var$TokenInputContext);
|
|
179
|
+
let objectRef = (0, $4P2rL$reactariauseObjectRef.useObjectRef)(ref);
|
|
180
|
+
let { tokenProps: tokenProps, isSelected: isSelected } = (0, $4P2rL$reactariauseTokenField.useToken)(props, {}, objectRef);
|
|
181
|
+
let renderProps = (0, $048d76b84370f141$exports.useRenderProps)({
|
|
182
|
+
...props,
|
|
183
|
+
defaultClassName: 'react-aria-Token',
|
|
184
|
+
values: {
|
|
185
|
+
isSelected: isSelected,
|
|
186
|
+
isDisabled: isDisabled
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
let DOMProps = (0, $4P2rL$reactariafilterDOMProps.filterDOMProps)(props, {
|
|
190
|
+
global: true
|
|
191
|
+
});
|
|
192
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($4P2rL$react))).createElement((0, $048d76b84370f141$exports.dom).span, {
|
|
193
|
+
ref: objectRef,
|
|
194
|
+
...(0, $4P2rL$reactariamergeProps.mergeProps)(DOMProps, renderProps, tokenProps),
|
|
195
|
+
"data-selected": isSelected || undefined,
|
|
196
|
+
"data-disabled": isDisabled || undefined,
|
|
197
|
+
style: {
|
|
198
|
+
...renderProps.style,
|
|
199
|
+
...tokenProps.style
|
|
200
|
+
}
|
|
201
|
+
}, renderProps.children);
|
|
202
|
+
});
|
|
203
|
+
// Prevents React from re-rendering during composition events.
|
|
204
|
+
const $95baf1bfb6adc271$var$CompositionRenderBlocker = /*#__PURE__*/ (0, $4P2rL$react.memo)(({ children: children })=>children, (prevProps, nextProps)=>nextProps.isComposing ? true : prevProps.children === nextProps.children);
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
//# sourceMappingURL=TokenField.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AA0IM,MAAM,0DAAoB,CAAA,GAAA,0BAAY,EAAiD;AAC9F,MAAM,wDAAoB,CAAA,GAAA,0BAAY,EAAiC;AAMhE,MAAM,4CAAa,WAAW,GAAG,CAAA,GAAA,gEAAsB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,MAAM,+DAA2B,CAAA,GAAA,iBAAG,EAClC,CAAC,YAAC,QAAQ,EAAoD,GAAK,UACnE,CAAC,WAAW,YACV,UAAU,WAAW,GAAG,OAAO,UAAU,QAAQ,KAAK,UAAU,QAAQ","sources":["packages/react-aria-components/src/TokenField.tsx"],"sourcesContent":["/*\n * Copyright 2026 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 {AriaTokenFieldProps} from 'react-aria/useTokenField';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RenderProps,\n SlotProps,\n StyleRenderProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldInputContext} from './Autocomplete';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {forwardRefType, GlobalDOMAttributes} from '@react-types/shared';\nimport {HoverProps, useHover} from 'react-aria/useHover';\nimport {LabelContext} from './Label';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport React, {\n createContext,\n ForwardedRef,\n forwardRef,\n HTMLAttributes,\n memo,\n RefObject,\n useContext,\n useMemo\n} from 'react';\nimport {TextContext} from './Text';\nimport {\n TokenFieldState,\n TokenFieldValue,\n TokenSegment,\n useTokenFieldState\n} from 'react-stately/useTokenFieldState';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {useToken, useTokenField} from 'react-aria/useTokenField';\n\nexport interface TokenFieldRenderProps {\n /**\n * Whether the token field is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the token field is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n}\n\nexport interface TokenFieldProps<T extends TokenFieldValue = TokenFieldValue>\n extends\n AriaTokenFieldProps<T>,\n RenderProps<TokenFieldRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-TokenField'\n */\n className?: ClassNameOrFunction<TokenFieldRenderProps>;\n}\n\nexport interface TokenInputRenderProps {\n /**\n * Whether the token input is currently hovered with a mouse.\n *\n * @selector [data-hovered]\n */\n isHovered: boolean;\n /**\n * Whether the token input is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the token input is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the token input is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the token input is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n}\n\nexport interface TokenInputProps<T extends TokenFieldValue = TokenFieldValue>\n extends\n HoverProps,\n StyleRenderProps<TokenInputRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * A function that renders a token for each segment in the token field.\n */\n children: (\n segment: TokenSegment<T extends TokenFieldValue<infer V> ? V : never>\n ) => React.ReactElement;\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-TokenInput'\n */\n className?: ClassNameOrFunction<TokenInputRenderProps>;\n}\n\ninterface TokenInputContextValue<T extends TokenFieldValue = TokenFieldValue> {\n tokenFieldProps: HTMLAttributes<HTMLDivElement>;\n state: TokenFieldState<T>;\n isDisabled: boolean;\n isReadOnly: boolean;\n autocompleteProps?: HTMLAttributes<HTMLDivElement>;\n ref: RefObject<HTMLDivElement | null>;\n}\n\nexport const TokenFieldContext = createContext<ContextValue<TokenFieldProps, HTMLDivElement>>(null);\nconst TokenInputContext = createContext<TokenInputContextValue | null>(null);\n\n/**\n * A token field allows users to enter text with inline tokens. Use it to build AI prompt fields,\n * tag inputs, structured search fields, mention inputs, and multi-select comboboxes.\n */\nexport const TokenField = /*#__PURE__*/ createHideableComponent(function TokenField<\n T extends TokenFieldValue = TokenFieldValue\n>(props: TokenFieldProps<T>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, TokenFieldContext);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n\n let fieldCtx = useSlottedContext(FieldInputContext, props.slot);\n let {\n value: _autocompleteValue,\n onChange: onAutocompleteChange,\n ref: autocompleteRef,\n ...autocompleteProps\n } = fieldCtx ?? {};\n let inputRef = useObjectRef(autocompleteRef);\n\n let isDisabled = props.isDisabled || false;\n let isReadOnly = props.isReadOnly || false;\n\n let state = useTokenFieldState<T>({\n ...props,\n onChange: (value: T) => {\n props.onChange?.(value);\n onAutocompleteChange?.(value.toString());\n }\n });\n\n let {tokenFieldProps, labelProps, descriptionProps} = useTokenField(\n {\n ...props,\n // @ts-ignore - not a public prop, used to determine if slot is present\n label,\n role: props.role || autocompleteProps['role'] || 'textbox'\n },\n state,\n inputRef\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: {\n isDisabled,\n isReadOnly\n },\n defaultClassName: 'react-aria-TokenField'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.div\n {...DOMProps}\n {...renderProps}\n ref={ref}\n slot={props.slot || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}>\n <Provider\n values={[\n [LabelContext, {...labelProps, elementType: 'span', ref: labelRef}],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps\n }\n }\n ],\n [\n TokenInputContext,\n {\n tokenFieldProps,\n state: state as any,\n isDisabled,\n isReadOnly,\n autocompleteProps: autocompleteProps as HTMLAttributes<HTMLDivElement>,\n ref: inputRef as RefObject<HTMLDivElement | null>\n }\n ]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n\n/**\n * A token input represents the editable area within a token field.\n */\nexport const TokenInput = /*#__PURE__*/ (forwardRef as forwardRefType)(function TokenInput<\n T extends TokenFieldValue = TokenFieldValue\n>(props: TokenInputProps<T>, forwardedRef: ForwardedRef<HTMLDivElement | null>) {\n let {\n tokenFieldProps,\n state,\n isDisabled = false,\n isReadOnly = false,\n autocompleteProps,\n ref: contextRef\n } = useContext(TokenInputContext)!;\n let ref = useMemo(() => mergeRefs(contextRef, forwardedRef), [contextRef, forwardedRef]);\n let {children, ...domProps} = props;\n\n let {isHovered, hoverProps} = useHover(domProps);\n let {isFocused, isFocusVisible, focusProps} = useFocusRing();\n\n let renderProps = useRenderProps({\n ...domProps,\n defaultClassName: 'react-aria-TokenInput',\n values: {\n isHovered,\n isFocused,\n isFocusVisible,\n isDisabled,\n isReadOnly\n }\n });\n\n let DOMProps = filterDOMProps(domProps, {global: true});\n\n return (\n <dom.div\n {...mergeProps(\n DOMProps,\n renderProps,\n focusProps,\n hoverProps,\n tokenFieldProps,\n autocompleteProps\n )}\n ref={ref}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n style={{...renderProps.style, ...tokenFieldProps?.style}}>\n <CompositionRenderBlocker isComposing={state.isComposing}>\n {state.value.segments.map((v, i) => {\n switch (v.type) {\n case 'token': {\n let token = children(v);\n return (\n // Wrap tokens in zero-width spaces so the cursor is placed correctly.\n <span key={i}>\n {'\\u200b'}\n {token}\n {'\\u200b'}\n </span>\n );\n }\n case 'text':\n return v.text;\n }\n })}\n {/* Force cursor to the next line if the last segment ends with a newline. */}\n {state.value.segments.at(-1)?.text.endsWith('\\n') && <br />}\n </CompositionRenderBlocker>\n </dom.div>\n );\n});\n\nexport interface TokenRenderProps {\n /**\n * Whether the token is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the token is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n}\n\nexport interface TokenProps\n extends RenderProps<TokenRenderProps, 'span'>, GlobalDOMAttributes<HTMLSpanElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Token'\n */\n className?: ClassNameOrFunction<TokenRenderProps>;\n}\n\n/**\n * A token represents an inline segment within a token field.\n */\nexport const Token = forwardRef(function Token(\n props: TokenProps,\n ref: ForwardedRef<HTMLSpanElement>\n) {\n let {isDisabled} = useContext(TokenInputContext)!;\n let objectRef = useObjectRef(ref);\n let {tokenProps, isSelected} = useToken(props, {}, objectRef);\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-Token',\n values: {\n isSelected,\n isDisabled\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.span\n ref={objectRef}\n {...mergeProps(DOMProps, renderProps, tokenProps)}\n data-selected={isSelected || undefined}\n data-disabled={isDisabled || undefined}\n style={{\n ...renderProps.style,\n ...tokenProps.style\n }}>\n {renderProps.children}\n </dom.span>\n );\n});\n\n// Prevents React from re-rendering during composition events.\nconst CompositionRenderBlocker = memo(\n ({children}: {children: React.ReactNode; isComposing: boolean}) => children,\n (prevProps, nextProps) =>\n nextProps.isComposing ? true : prevProps.children === nextProps.children\n);\n"],"names":[],"version":3,"file":"TokenField.cjs.map"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import {dom as $b7b7a92703138c9b$export$df3a06d6289f983e, Provider as $b7b7a92703138c9b$export$2881499e37b75b9a, useContextProps as $b7b7a92703138c9b$export$29f1550f4b0d4415, useRenderProps as $b7b7a92703138c9b$export$4d86445c2cf5e3, useSlot as $b7b7a92703138c9b$export$9d4c57ee4c6ffdd8, useSlottedContext as $b7b7a92703138c9b$export$fabf2dc03a41866e} from "./utils.js";
|
|
2
|
+
import {FieldInputContext as $8f09b710ef85b337$export$698f465ec27e93df} from "./Autocomplete.js";
|
|
3
|
+
import {LabelContext as $3e4839e5b30e7b17$export$75b6ee27786ba447} from "./Label.js";
|
|
4
|
+
import {TextContext as $20d769b1e2b13352$export$9afb8bc826b033ea} from "./Text.js";
|
|
5
|
+
import {createHideableComponent as $lOx05$createHideableComponent} from "react-aria/private/collections/Hidden";
|
|
6
|
+
import {filterDOMProps as $lOx05$filterDOMProps} from "react-aria/filterDOMProps";
|
|
7
|
+
import {useHover as $lOx05$useHover} from "react-aria/useHover";
|
|
8
|
+
import {mergeProps as $lOx05$mergeProps} from "react-aria/mergeProps";
|
|
9
|
+
import {mergeRefs as $lOx05$mergeRefs} from "react-aria/mergeRefs";
|
|
10
|
+
import $lOx05$react, {createContext as $lOx05$createContext, forwardRef as $lOx05$forwardRef, useContext as $lOx05$useContext, useMemo as $lOx05$useMemo, memo as $lOx05$memo} from "react";
|
|
11
|
+
import {useTokenFieldState as $lOx05$useTokenFieldState} from "react-stately/useTokenFieldState";
|
|
12
|
+
import {useFocusRing as $lOx05$useFocusRing} from "react-aria/useFocusRing";
|
|
13
|
+
import {useObjectRef as $lOx05$useObjectRef} from "react-aria/useObjectRef";
|
|
14
|
+
import {useTokenField as $lOx05$useTokenField, useToken as $lOx05$useToken} from "react-aria/useTokenField";
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
18
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
19
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
20
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
+
*
|
|
22
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
23
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
24
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
25
|
+
* governing permissions and limitations under the License.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
const $0557236f0f66b699$export$24532e5e37c56ff2 = /*#__PURE__*/ (0, $lOx05$createContext)(null);
|
|
41
|
+
const $0557236f0f66b699$var$TokenInputContext = /*#__PURE__*/ (0, $lOx05$createContext)(null);
|
|
42
|
+
const $0557236f0f66b699$export$e4550c392cbe69d7 = /*#__PURE__*/ (0, $lOx05$createHideableComponent)(function TokenField(props, ref) {
|
|
43
|
+
[props, ref] = (0, $b7b7a92703138c9b$export$29f1550f4b0d4415)(props, ref, $0557236f0f66b699$export$24532e5e37c56ff2);
|
|
44
|
+
let [labelRef, label] = (0, $b7b7a92703138c9b$export$9d4c57ee4c6ffdd8)(!props['aria-label'] && !props['aria-labelledby']);
|
|
45
|
+
let fieldCtx = (0, $b7b7a92703138c9b$export$fabf2dc03a41866e)((0, $8f09b710ef85b337$export$698f465ec27e93df), props.slot);
|
|
46
|
+
let { value: _autocompleteValue, onChange: onAutocompleteChange, ref: autocompleteRef, ...autocompleteProps } = fieldCtx !== null && fieldCtx !== void 0 ? fieldCtx : {};
|
|
47
|
+
let inputRef = (0, $lOx05$useObjectRef)(autocompleteRef);
|
|
48
|
+
let isDisabled = props.isDisabled || false;
|
|
49
|
+
let isReadOnly = props.isReadOnly || false;
|
|
50
|
+
let state = (0, $lOx05$useTokenFieldState)({
|
|
51
|
+
...props,
|
|
52
|
+
onChange: (value)=>{
|
|
53
|
+
var _props_onChange;
|
|
54
|
+
(_props_onChange = props.onChange) === null || _props_onChange === void 0 ? void 0 : _props_onChange.call(props, value);
|
|
55
|
+
onAutocompleteChange === null || onAutocompleteChange === void 0 ? void 0 : onAutocompleteChange(value.toString());
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
let { tokenFieldProps: tokenFieldProps, labelProps: labelProps, descriptionProps: descriptionProps } = (0, $lOx05$useTokenField)({
|
|
59
|
+
...props,
|
|
60
|
+
label: // @ts-ignore - not a public prop, used to determine if slot is present
|
|
61
|
+
label,
|
|
62
|
+
role: props.role || autocompleteProps['role'] || 'textbox'
|
|
63
|
+
}, state, inputRef);
|
|
64
|
+
let renderProps = (0, $b7b7a92703138c9b$export$4d86445c2cf5e3)({
|
|
65
|
+
...props,
|
|
66
|
+
values: {
|
|
67
|
+
isDisabled: isDisabled,
|
|
68
|
+
isReadOnly: isReadOnly
|
|
69
|
+
},
|
|
70
|
+
defaultClassName: 'react-aria-TokenField'
|
|
71
|
+
});
|
|
72
|
+
let DOMProps = (0, $lOx05$filterDOMProps)(props, {
|
|
73
|
+
global: true
|
|
74
|
+
});
|
|
75
|
+
return /*#__PURE__*/ (0, $lOx05$react).createElement((0, $b7b7a92703138c9b$export$df3a06d6289f983e).div, {
|
|
76
|
+
...DOMProps,
|
|
77
|
+
...renderProps,
|
|
78
|
+
ref: ref,
|
|
79
|
+
slot: props.slot || undefined,
|
|
80
|
+
"data-disabled": isDisabled || undefined,
|
|
81
|
+
"data-readonly": isReadOnly || undefined
|
|
82
|
+
}, /*#__PURE__*/ (0, $lOx05$react).createElement((0, $b7b7a92703138c9b$export$2881499e37b75b9a), {
|
|
83
|
+
values: [
|
|
84
|
+
[
|
|
85
|
+
(0, $3e4839e5b30e7b17$export$75b6ee27786ba447),
|
|
86
|
+
{
|
|
87
|
+
...labelProps,
|
|
88
|
+
elementType: 'span',
|
|
89
|
+
ref: labelRef
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
[
|
|
93
|
+
(0, $20d769b1e2b13352$export$9afb8bc826b033ea),
|
|
94
|
+
{
|
|
95
|
+
slots: {
|
|
96
|
+
description: descriptionProps
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
[
|
|
101
|
+
$0557236f0f66b699$var$TokenInputContext,
|
|
102
|
+
{
|
|
103
|
+
tokenFieldProps: tokenFieldProps,
|
|
104
|
+
state: state,
|
|
105
|
+
isDisabled: isDisabled,
|
|
106
|
+
isReadOnly: isReadOnly,
|
|
107
|
+
autocompleteProps: autocompleteProps,
|
|
108
|
+
ref: inputRef
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
]
|
|
112
|
+
}, renderProps.children));
|
|
113
|
+
});
|
|
114
|
+
const $0557236f0f66b699$export$4ddf413e820cfcc4 = /*#__PURE__*/ (0, $lOx05$forwardRef)(function TokenInput(props, forwardedRef) {
|
|
115
|
+
var _state_value_segments_at;
|
|
116
|
+
let { tokenFieldProps: tokenFieldProps, state: state, isDisabled: isDisabled = false, isReadOnly: isReadOnly = false, autocompleteProps: autocompleteProps, ref: contextRef } = (0, $lOx05$useContext)($0557236f0f66b699$var$TokenInputContext);
|
|
117
|
+
let ref = (0, $lOx05$useMemo)(()=>(0, $lOx05$mergeRefs)(contextRef, forwardedRef), [
|
|
118
|
+
contextRef,
|
|
119
|
+
forwardedRef
|
|
120
|
+
]);
|
|
121
|
+
let { children: children, ...domProps } = props;
|
|
122
|
+
let { isHovered: isHovered, hoverProps: hoverProps } = (0, $lOx05$useHover)(domProps);
|
|
123
|
+
let { isFocused: isFocused, isFocusVisible: isFocusVisible, focusProps: focusProps } = (0, $lOx05$useFocusRing)();
|
|
124
|
+
let renderProps = (0, $b7b7a92703138c9b$export$4d86445c2cf5e3)({
|
|
125
|
+
...domProps,
|
|
126
|
+
defaultClassName: 'react-aria-TokenInput',
|
|
127
|
+
values: {
|
|
128
|
+
isHovered: isHovered,
|
|
129
|
+
isFocused: isFocused,
|
|
130
|
+
isFocusVisible: isFocusVisible,
|
|
131
|
+
isDisabled: isDisabled,
|
|
132
|
+
isReadOnly: isReadOnly
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
let DOMProps = (0, $lOx05$filterDOMProps)(domProps, {
|
|
136
|
+
global: true
|
|
137
|
+
});
|
|
138
|
+
return /*#__PURE__*/ (0, $lOx05$react).createElement((0, $b7b7a92703138c9b$export$df3a06d6289f983e).div, {
|
|
139
|
+
...(0, $lOx05$mergeProps)(DOMProps, renderProps, focusProps, hoverProps, tokenFieldProps, autocompleteProps),
|
|
140
|
+
ref: ref,
|
|
141
|
+
"data-focused": isFocused || undefined,
|
|
142
|
+
"data-focus-visible": isFocusVisible || undefined,
|
|
143
|
+
"data-disabled": isDisabled || undefined,
|
|
144
|
+
"data-readonly": isReadOnly || undefined,
|
|
145
|
+
style: {
|
|
146
|
+
...renderProps.style,
|
|
147
|
+
...tokenFieldProps === null || tokenFieldProps === void 0 ? void 0 : tokenFieldProps.style
|
|
148
|
+
}
|
|
149
|
+
}, /*#__PURE__*/ (0, $lOx05$react).createElement($0557236f0f66b699$var$CompositionRenderBlocker, {
|
|
150
|
+
isComposing: state.isComposing
|
|
151
|
+
}, state.value.segments.map((v, i)=>{
|
|
152
|
+
switch(v.type){
|
|
153
|
+
case 'token':
|
|
154
|
+
{
|
|
155
|
+
let token = children(v);
|
|
156
|
+
return(// Wrap tokens in zero-width spaces so the cursor is placed correctly.
|
|
157
|
+
/*#__PURE__*/ (0, $lOx05$react).createElement("span", {
|
|
158
|
+
key: i
|
|
159
|
+
}, '\u200b', token, '\u200b'));
|
|
160
|
+
}
|
|
161
|
+
case 'text':
|
|
162
|
+
return v.text;
|
|
163
|
+
}
|
|
164
|
+
}), ((_state_value_segments_at = state.value.segments.at(-1)) === null || _state_value_segments_at === void 0 ? void 0 : _state_value_segments_at.text.endsWith('\n')) && /*#__PURE__*/ (0, $lOx05$react).createElement("br", null)));
|
|
165
|
+
});
|
|
166
|
+
const $0557236f0f66b699$export$50792b0e93539fde = /*#__PURE__*/ (0, $lOx05$forwardRef)(function Token(props, ref) {
|
|
167
|
+
let { isDisabled: isDisabled } = (0, $lOx05$useContext)($0557236f0f66b699$var$TokenInputContext);
|
|
168
|
+
let objectRef = (0, $lOx05$useObjectRef)(ref);
|
|
169
|
+
let { tokenProps: tokenProps, isSelected: isSelected } = (0, $lOx05$useToken)(props, {}, objectRef);
|
|
170
|
+
let renderProps = (0, $b7b7a92703138c9b$export$4d86445c2cf5e3)({
|
|
171
|
+
...props,
|
|
172
|
+
defaultClassName: 'react-aria-Token',
|
|
173
|
+
values: {
|
|
174
|
+
isSelected: isSelected,
|
|
175
|
+
isDisabled: isDisabled
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
let DOMProps = (0, $lOx05$filterDOMProps)(props, {
|
|
179
|
+
global: true
|
|
180
|
+
});
|
|
181
|
+
return /*#__PURE__*/ (0, $lOx05$react).createElement((0, $b7b7a92703138c9b$export$df3a06d6289f983e).span, {
|
|
182
|
+
ref: objectRef,
|
|
183
|
+
...(0, $lOx05$mergeProps)(DOMProps, renderProps, tokenProps),
|
|
184
|
+
"data-selected": isSelected || undefined,
|
|
185
|
+
"data-disabled": isDisabled || undefined,
|
|
186
|
+
style: {
|
|
187
|
+
...renderProps.style,
|
|
188
|
+
...tokenProps.style
|
|
189
|
+
}
|
|
190
|
+
}, renderProps.children);
|
|
191
|
+
});
|
|
192
|
+
// Prevents React from re-rendering during composition events.
|
|
193
|
+
const $0557236f0f66b699$var$CompositionRenderBlocker = /*#__PURE__*/ (0, $lOx05$memo)(({ children: children })=>children, (prevProps, nextProps)=>nextProps.isComposing ? true : prevProps.children === nextProps.children);
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
export {$0557236f0f66b699$export$24532e5e37c56ff2 as TokenFieldContext, $0557236f0f66b699$export$e4550c392cbe69d7 as TokenField, $0557236f0f66b699$export$4ddf413e820cfcc4 as TokenInput, $0557236f0f66b699$export$50792b0e93539fde as Token};
|
|
197
|
+
//# sourceMappingURL=TokenField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;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AAO;QAAC,QAAQ;IAAI;IAElD,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,IAAI;QACP,KAAK;QACJ,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,aAAa,WAAW;QACjD,iBAAe,cAAc;QAC7B,iBAAe,cAAc;QAC7B,OAAO;YACL,GAAG,YAAY,KAAK;YACpB,GAAG,WAAW,KAAK;QACrB;OACC,YAAY,QAAQ;AAG3B;AAEA,8DAA8D;AAC9D,MAAM,+DAA2B,CAAA,GAAA,WAAG,EAClC,CAAC,YAAC,QAAQ,EAAoD,GAAK,UACnE,CAAC,WAAW,YACV,UAAU,WAAW,GAAG,OAAO,UAAU,QAAQ,KAAK,UAAU,QAAQ","sources":["packages/react-aria-components/src/TokenField.tsx"],"sourcesContent":["/*\n * Copyright 2026 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 {AriaTokenFieldProps} from 'react-aria/useTokenField';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RenderProps,\n SlotProps,\n StyleRenderProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldInputContext} from './Autocomplete';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {forwardRefType, GlobalDOMAttributes} from '@react-types/shared';\nimport {HoverProps, useHover} from 'react-aria/useHover';\nimport {LabelContext} from './Label';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport React, {\n createContext,\n ForwardedRef,\n forwardRef,\n HTMLAttributes,\n memo,\n RefObject,\n useContext,\n useMemo\n} from 'react';\nimport {TextContext} from './Text';\nimport {\n TokenFieldState,\n TokenFieldValue,\n TokenSegment,\n useTokenFieldState\n} from 'react-stately/useTokenFieldState';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {useToken, useTokenField} from 'react-aria/useTokenField';\n\nexport interface TokenFieldRenderProps {\n /**\n * Whether the token field is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the token field is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n}\n\nexport interface TokenFieldProps<T extends TokenFieldValue = TokenFieldValue>\n extends\n AriaTokenFieldProps<T>,\n RenderProps<TokenFieldRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-TokenField'\n */\n className?: ClassNameOrFunction<TokenFieldRenderProps>;\n}\n\nexport interface TokenInputRenderProps {\n /**\n * Whether the token input is currently hovered with a mouse.\n *\n * @selector [data-hovered]\n */\n isHovered: boolean;\n /**\n * Whether the token input is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the token input is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the token input is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the token input is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n}\n\nexport interface TokenInputProps<T extends TokenFieldValue = TokenFieldValue>\n extends\n HoverProps,\n StyleRenderProps<TokenInputRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * A function that renders a token for each segment in the token field.\n */\n children: (\n segment: TokenSegment<T extends TokenFieldValue<infer V> ? V : never>\n ) => React.ReactElement;\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-TokenInput'\n */\n className?: ClassNameOrFunction<TokenInputRenderProps>;\n}\n\ninterface TokenInputContextValue<T extends TokenFieldValue = TokenFieldValue> {\n tokenFieldProps: HTMLAttributes<HTMLDivElement>;\n state: TokenFieldState<T>;\n isDisabled: boolean;\n isReadOnly: boolean;\n autocompleteProps?: HTMLAttributes<HTMLDivElement>;\n ref: RefObject<HTMLDivElement | null>;\n}\n\nexport const TokenFieldContext = createContext<ContextValue<TokenFieldProps, HTMLDivElement>>(null);\nconst TokenInputContext = createContext<TokenInputContextValue | null>(null);\n\n/**\n * A token field allows users to enter text with inline tokens. Use it to build AI prompt fields,\n * tag inputs, structured search fields, mention inputs, and multi-select comboboxes.\n */\nexport const TokenField = /*#__PURE__*/ createHideableComponent(function TokenField<\n T extends TokenFieldValue = TokenFieldValue\n>(props: TokenFieldProps<T>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, TokenFieldContext);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n\n let fieldCtx = useSlottedContext(FieldInputContext, props.slot);\n let {\n value: _autocompleteValue,\n onChange: onAutocompleteChange,\n ref: autocompleteRef,\n ...autocompleteProps\n } = fieldCtx ?? {};\n let inputRef = useObjectRef(autocompleteRef);\n\n let isDisabled = props.isDisabled || false;\n let isReadOnly = props.isReadOnly || false;\n\n let state = useTokenFieldState<T>({\n ...props,\n onChange: (value: T) => {\n props.onChange?.(value);\n onAutocompleteChange?.(value.toString());\n }\n });\n\n let {tokenFieldProps, labelProps, descriptionProps} = useTokenField(\n {\n ...props,\n // @ts-ignore - not a public prop, used to determine if slot is present\n label,\n role: props.role || autocompleteProps['role'] || 'textbox'\n },\n state,\n inputRef\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: {\n isDisabled,\n isReadOnly\n },\n defaultClassName: 'react-aria-TokenField'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.div\n {...DOMProps}\n {...renderProps}\n ref={ref}\n slot={props.slot || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}>\n <Provider\n values={[\n [LabelContext, {...labelProps, elementType: 'span', ref: labelRef}],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps\n }\n }\n ],\n [\n TokenInputContext,\n {\n tokenFieldProps,\n state: state as any,\n isDisabled,\n isReadOnly,\n autocompleteProps: autocompleteProps as HTMLAttributes<HTMLDivElement>,\n ref: inputRef as RefObject<HTMLDivElement | null>\n }\n ]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n\n/**\n * A token input represents the editable area within a token field.\n */\nexport const TokenInput = /*#__PURE__*/ (forwardRef as forwardRefType)(function TokenInput<\n T extends TokenFieldValue = TokenFieldValue\n>(props: TokenInputProps<T>, forwardedRef: ForwardedRef<HTMLDivElement | null>) {\n let {\n tokenFieldProps,\n state,\n isDisabled = false,\n isReadOnly = false,\n autocompleteProps,\n ref: contextRef\n } = useContext(TokenInputContext)!;\n let ref = useMemo(() => mergeRefs(contextRef, forwardedRef), [contextRef, forwardedRef]);\n let {children, ...domProps} = props;\n\n let {isHovered, hoverProps} = useHover(domProps);\n let {isFocused, isFocusVisible, focusProps} = useFocusRing();\n\n let renderProps = useRenderProps({\n ...domProps,\n defaultClassName: 'react-aria-TokenInput',\n values: {\n isHovered,\n isFocused,\n isFocusVisible,\n isDisabled,\n isReadOnly\n }\n });\n\n let DOMProps = filterDOMProps(domProps, {global: true});\n\n return (\n <dom.div\n {...mergeProps(\n DOMProps,\n renderProps,\n focusProps,\n hoverProps,\n tokenFieldProps,\n autocompleteProps\n )}\n ref={ref}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n style={{...renderProps.style, ...tokenFieldProps?.style}}>\n <CompositionRenderBlocker isComposing={state.isComposing}>\n {state.value.segments.map((v, i) => {\n switch (v.type) {\n case 'token': {\n let token = children(v);\n return (\n // Wrap tokens in zero-width spaces so the cursor is placed correctly.\n <span key={i}>\n {'\\u200b'}\n {token}\n {'\\u200b'}\n </span>\n );\n }\n case 'text':\n return v.text;\n }\n })}\n {/* Force cursor to the next line if the last segment ends with a newline. */}\n {state.value.segments.at(-1)?.text.endsWith('\\n') && <br />}\n </CompositionRenderBlocker>\n </dom.div>\n );\n});\n\nexport interface TokenRenderProps {\n /**\n * Whether the token is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the token is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n}\n\nexport interface TokenProps\n extends RenderProps<TokenRenderProps, 'span'>, GlobalDOMAttributes<HTMLSpanElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Token'\n */\n className?: ClassNameOrFunction<TokenRenderProps>;\n}\n\n/**\n * A token represents an inline segment within a token field.\n */\nexport const Token = forwardRef(function Token(\n props: TokenProps,\n ref: ForwardedRef<HTMLSpanElement>\n) {\n let {isDisabled} = useContext(TokenInputContext)!;\n let objectRef = useObjectRef(ref);\n let {tokenProps, isSelected} = useToken(props, {}, objectRef);\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-Token',\n values: {\n isSelected,\n isDisabled\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.span\n ref={objectRef}\n {...mergeProps(DOMProps, renderProps, tokenProps)}\n data-selected={isSelected || undefined}\n data-disabled={isDisabled || undefined}\n style={{\n ...renderProps.style,\n ...tokenProps.style\n }}>\n {renderProps.children}\n </dom.span>\n );\n});\n\n// Prevents React from re-rendering during composition events.\nconst CompositionRenderBlocker = memo(\n ({children}: {children: React.ReactNode; isComposing: boolean}) => children,\n (prevProps, nextProps) =>\n nextProps.isComposing ? true : prevProps.children === nextProps.children\n);\n"],"names":[],"version":3,"file":"TokenField.js.map"}
|