@depup/react-aria-components 1.20.0-depup.0 → 1.21.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.
Files changed (127) hide show
  1. package/NavigationTree/package.json +5 -0
  2. package/README.md +2 -2
  3. package/changes.json +1 -1
  4. package/dist/exports/Menu.cjs +1 -0
  5. package/dist/exports/Menu.cjs.map +1 -1
  6. package/dist/exports/Menu.js +2 -2
  7. package/dist/exports/Menu.js.map +1 -1
  8. package/dist/exports/Menu.mjs +2 -2
  9. package/dist/exports/Menu.mjs.map +1 -1
  10. package/dist/exports/NavigationTree.cjs +37 -0
  11. package/dist/exports/NavigationTree.cjs.map +1 -0
  12. package/dist/exports/NavigationTree.js +25 -0
  13. package/dist/exports/NavigationTree.js.map +1 -0
  14. package/dist/exports/NavigationTree.mjs +25 -0
  15. package/dist/exports/NavigationTree.mjs.map +1 -0
  16. package/dist/exports/index.cjs +13 -0
  17. package/dist/exports/index.cjs.map +1 -1
  18. package/dist/exports/index.js +6 -2
  19. package/dist/exports/index.js.map +1 -1
  20. package/dist/exports/index.mjs +6 -2
  21. package/dist/exports/index.mjs.map +1 -1
  22. package/dist/private/Checkbox.cjs.map +1 -1
  23. package/dist/private/Checkbox.js.map +1 -1
  24. package/dist/private/Checkbox.mjs.map +1 -1
  25. package/dist/private/Dialog.cjs +6 -0
  26. package/dist/private/Dialog.cjs.map +1 -1
  27. package/dist/private/Dialog.js +6 -0
  28. package/dist/private/Dialog.js.map +1 -1
  29. package/dist/private/Dialog.mjs +6 -0
  30. package/dist/private/Dialog.mjs.map +1 -1
  31. package/dist/private/GridList.cjs.map +1 -1
  32. package/dist/private/GridList.js.map +1 -1
  33. package/dist/private/GridList.mjs.map +1 -1
  34. package/dist/private/ListBox.cjs.map +1 -1
  35. package/dist/private/ListBox.js.map +1 -1
  36. package/dist/private/ListBox.mjs.map +1 -1
  37. package/dist/private/Menu.cjs +55 -0
  38. package/dist/private/Menu.cjs.map +1 -1
  39. package/dist/private/Menu.js +56 -2
  40. package/dist/private/Menu.js.map +1 -1
  41. package/dist/private/Menu.mjs +56 -2
  42. package/dist/private/Menu.mjs.map +1 -1
  43. package/dist/private/NavigationTree.cjs +272 -0
  44. package/dist/private/NavigationTree.cjs.map +1 -0
  45. package/dist/private/NavigationTree.js +258 -0
  46. package/dist/private/NavigationTree.js.map +1 -0
  47. package/dist/private/NavigationTree.mjs +257 -0
  48. package/dist/private/NavigationTree.mjs.map +1 -0
  49. package/dist/private/RadioGroup.cjs.map +1 -1
  50. package/dist/private/RadioGroup.js.map +1 -1
  51. package/dist/private/RadioGroup.mjs.map +1 -1
  52. package/dist/private/Switch.cjs +8 -2
  53. package/dist/private/Switch.cjs.map +1 -1
  54. package/dist/private/Switch.js +9 -3
  55. package/dist/private/Switch.js.map +1 -1
  56. package/dist/private/Switch.mjs +9 -3
  57. package/dist/private/Switch.mjs.map +1 -1
  58. package/dist/private/Table.cjs.map +1 -1
  59. package/dist/private/Table.js.map +1 -1
  60. package/dist/private/Table.mjs.map +1 -1
  61. package/dist/private/Text.cjs +3 -1
  62. package/dist/private/Text.cjs.map +1 -1
  63. package/dist/private/Text.js +4 -2
  64. package/dist/private/Text.js.map +1 -1
  65. package/dist/private/Text.mjs +4 -2
  66. package/dist/private/Text.mjs.map +1 -1
  67. package/dist/private/TokenField.cjs +30 -2
  68. package/dist/private/TokenField.cjs.map +1 -1
  69. package/dist/private/TokenField.js +30 -2
  70. package/dist/private/TokenField.js.map +1 -1
  71. package/dist/private/TokenField.mjs +30 -2
  72. package/dist/private/TokenField.mjs.map +1 -1
  73. package/dist/private/Tree.cjs.map +1 -1
  74. package/dist/private/Tree.js.map +1 -1
  75. package/dist/private/Tree.mjs.map +1 -1
  76. package/dist/private/TreeDropTargetDelegate.cjs +11 -6
  77. package/dist/private/TreeDropTargetDelegate.cjs.map +1 -1
  78. package/dist/private/TreeDropTargetDelegate.js +11 -6
  79. package/dist/private/TreeDropTargetDelegate.js.map +1 -1
  80. package/dist/private/TreeDropTargetDelegate.mjs +11 -6
  81. package/dist/private/TreeDropTargetDelegate.mjs.map +1 -1
  82. package/dist/types/exports/Menu.d.ts +2 -2
  83. package/dist/types/exports/NavigationTree.d.ts +8 -0
  84. package/dist/types/exports/index.d.ts +7 -3
  85. package/dist/types/src/Breadcrumbs.d.ts +2 -2
  86. package/dist/types/src/Button.d.ts +1 -1
  87. package/dist/types/src/Calendar.d.ts +6 -6
  88. package/dist/types/src/Checkbox.d.ts +8 -8
  89. package/dist/types/src/Collection.d.ts +1 -1
  90. package/dist/types/src/ComboBox.d.ts +2 -2
  91. package/dist/types/src/DateField.d.ts +4 -4
  92. package/dist/types/src/DatePicker.d.ts +2 -2
  93. package/dist/types/src/Dialog.d.ts +2 -2
  94. package/dist/types/src/Disclosure.d.ts +2 -2
  95. package/dist/types/src/GridList.d.ts +6 -6
  96. package/dist/types/src/Group.d.ts +1 -1
  97. package/dist/types/src/Header.d.ts +1 -1
  98. package/dist/types/src/Input.d.ts +1 -1
  99. package/dist/types/src/Label.d.ts +1 -1
  100. package/dist/types/src/Link.d.ts +1 -1
  101. package/dist/types/src/ListBox.d.ts +5 -5
  102. package/dist/types/src/Menu.d.ts +25 -6
  103. package/dist/types/src/Meter.d.ts +1 -1
  104. package/dist/types/src/Modal.d.ts +2 -2
  105. package/dist/types/src/NavigationTree.d.ts +80 -0
  106. package/dist/types/src/NumberField.d.ts +1 -1
  107. package/dist/types/src/OverlayArrow.d.ts +1 -1
  108. package/dist/types/src/Popover.d.ts +1 -1
  109. package/dist/types/src/RadioGroup.d.ts +8 -8
  110. package/dist/types/src/SearchField.d.ts +1 -1
  111. package/dist/types/src/Select.d.ts +2 -2
  112. package/dist/types/src/Separator.d.ts +1 -1
  113. package/dist/types/src/Slider.d.ts +5 -5
  114. package/dist/types/src/Switch.d.ts +7 -7
  115. package/dist/types/src/Table.d.ts +8 -8
  116. package/dist/types/src/Tabs.d.ts +5 -5
  117. package/dist/types/src/TagGroup.d.ts +3 -3
  118. package/dist/types/src/Text.d.ts +1 -1
  119. package/dist/types/src/TextField.d.ts +1 -1
  120. package/dist/types/src/Toast.d.ts +3 -3
  121. package/dist/types/src/ToggleButton.d.ts +1 -1
  122. package/dist/types/src/ToggleButtonGroup.d.ts +1 -1
  123. package/dist/types/src/TokenField.d.ts +2 -2
  124. package/dist/types/src/Toolbar.d.ts +1 -1
  125. package/dist/types/src/Tooltip.d.ts +1 -1
  126. package/dist/types/src/Tree.d.ts +6 -6
  127. package/package.json +8 -7
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AASM,MAAM,0DAAc,CAAA,GAAA,oBAAY,EAAwC,CAAC;AAEzE,MAAM,0DAAO,CAAA,GAAA,iBAAS,EAAE,SAAS,KAAK,KAAgB,EAAE,GAA8B;IAC3F,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,eAAC,cAAc,QAAQ,GAAG,UAAS,GAAG;IAC1C,IAAI,cAAc,CAAA,GAAA,yCAAE,CAAC,CAAC,YAAY;IAClC,aAAa;IACb,qBAAO,gCAAC;QAAY,WAAU;QAAmB,GAAG,QAAQ;QAAE,KAAK;;AACrE","sources":["packages/react-aria-components/src/Text.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 {ContextValue, dom, DOMRenderProps, useContextProps} from './utils';\nimport React, {createContext, ForwardedRef, forwardRef, HTMLAttributes} from 'react';\n\nexport interface TextProps extends HTMLAttributes<HTMLElement>, DOMRenderProps<any, any> {\n elementType?: string;\n}\n\nexport const TextContext = createContext<ContextValue<TextProps, HTMLElement>>({});\n\nexport const Text = forwardRef(function Text(props: TextProps, ref: ForwardedRef<HTMLElement>) {\n [props, ref] = useContextProps(props, ref, TextContext);\n let {elementType = 'span', ...domProps} = props;\n let ElementType = dom[elementType];\n // @ts-ignore\n return <ElementType className=\"react-aria-Text\" {...domProps} ref={ref} />;\n});\n"],"names":[],"version":3,"file":"Text.js.map"}
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AASM,MAAM,0DAAc,CAAA,GAAA,oBAAY,EAAwC,CAAC;AAEzE,MAAM,4CAAO,WAAW,GAAG,CAAA,GAAA,8BAAsB,EAAE,SAAS,KACjE,KAAgB,EAChB,GAA8B;IAE9B,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAE3C,IAAI,eAAC,cAAc,QAAQ,GAAG,UAAS,GAAG;IAC1C,IAAI,cAAc,CAAA,GAAA,yCAAE,CAAC,CAAC,YAAY;IAClC,aAAa;IACb,qBAAO,gCAAC;QAAY,WAAU;QAAmB,GAAG,QAAQ;QAAE,KAAK;;AACrE","sources":["packages/react-aria-components/src/Text.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 */\nimport {ContextValue, dom, DOMRenderProps, useContextProps} from './utils';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport React, {createContext, ForwardedRef, HTMLAttributes} from 'react';\n\nexport interface TextProps extends HTMLAttributes<HTMLElement>, DOMRenderProps<any, any> {\n elementType?: string;\n}\n\nexport const TextContext = createContext<ContextValue<TextProps, HTMLElement>>({});\n\nexport const Text = /*#__PURE__*/ createHideableComponent(function Text(\n props: TextProps,\n ref: ForwardedRef<HTMLElement>\n) {\n [props, ref] = useContextProps(props, ref, TextContext);\n\n let {elementType = 'span', ...domProps} = props;\n let ElementType = dom[elementType];\n // @ts-ignore\n return <ElementType className=\"react-aria-Text\" {...domProps} ref={ref} />;\n});\n"],"names":[],"version":3,"file":"Text.js.map"}
@@ -1,5 +1,6 @@
1
1
  import {dom as $7230ffa83bc0c2cf$export$df3a06d6289f983e, useContextProps as $7230ffa83bc0c2cf$export$29f1550f4b0d4415} from "./utils.mjs";
2
- import $cGkLv$react, {createContext as $cGkLv$createContext, forwardRef as $cGkLv$forwardRef} from "react";
2
+ import {createHideableComponent as $cGkLv$createHideableComponent} from "react-aria/private/collections/Hidden";
3
+ import $cGkLv$react, {createContext as $cGkLv$createContext} from "react";
3
4
 
4
5
  /*
5
6
  * Copyright 2022 Adobe. All rights reserved.
@@ -13,8 +14,9 @@ import $cGkLv$react, {createContext as $cGkLv$createContext, forwardRef as $cGkL
13
14
  * governing permissions and limitations under the License.
14
15
  */
15
16
 
17
+
16
18
  const $efe09c6d1c304b50$export$9afb8bc826b033ea = /*#__PURE__*/ (0, $cGkLv$createContext)({});
17
- const $efe09c6d1c304b50$export$5f1af8db9871e1d6 = /*#__PURE__*/ (0, $cGkLv$forwardRef)(function Text(props, ref) {
19
+ const $efe09c6d1c304b50$export$5f1af8db9871e1d6 = /*#__PURE__*/ (0, $cGkLv$createHideableComponent)(function Text(props, ref) {
18
20
  [props, ref] = (0, $7230ffa83bc0c2cf$export$29f1550f4b0d4415)(props, ref, $efe09c6d1c304b50$export$9afb8bc826b033ea);
19
21
  let { elementType: elementType = 'span', ...domProps } = props;
20
22
  let ElementType = (0, $7230ffa83bc0c2cf$export$df3a06d6289f983e)[elementType];
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AASM,MAAM,0DAAc,CAAA,GAAA,oBAAY,EAAwC,CAAC;AAEzE,MAAM,0DAAO,CAAA,GAAA,iBAAS,EAAE,SAAS,KAAK,KAAgB,EAAE,GAA8B;IAC3F,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,eAAC,cAAc,QAAQ,GAAG,UAAS,GAAG;IAC1C,IAAI,cAAc,CAAA,GAAA,yCAAE,CAAC,CAAC,YAAY;IAClC,aAAa;IACb,qBAAO,gCAAC;QAAY,WAAU;QAAmB,GAAG,QAAQ;QAAE,KAAK;;AACrE","sources":["packages/react-aria-components/src/Text.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 {ContextValue, dom, DOMRenderProps, useContextProps} from './utils';\nimport React, {createContext, ForwardedRef, forwardRef, HTMLAttributes} from 'react';\n\nexport interface TextProps extends HTMLAttributes<HTMLElement>, DOMRenderProps<any, any> {\n elementType?: string;\n}\n\nexport const TextContext = createContext<ContextValue<TextProps, HTMLElement>>({});\n\nexport const Text = forwardRef(function Text(props: TextProps, ref: ForwardedRef<HTMLElement>) {\n [props, ref] = useContextProps(props, ref, TextContext);\n let {elementType = 'span', ...domProps} = props;\n let ElementType = dom[elementType];\n // @ts-ignore\n return <ElementType className=\"react-aria-Text\" {...domProps} ref={ref} />;\n});\n"],"names":[],"version":3,"file":"Text.mjs.map"}
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AASM,MAAM,0DAAc,CAAA,GAAA,oBAAY,EAAwC,CAAC;AAEzE,MAAM,4CAAO,WAAW,GAAG,CAAA,GAAA,8BAAsB,EAAE,SAAS,KACjE,KAAgB,EAChB,GAA8B;IAE9B,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAE3C,IAAI,eAAC,cAAc,QAAQ,GAAG,UAAS,GAAG;IAC1C,IAAI,cAAc,CAAA,GAAA,yCAAE,CAAC,CAAC,YAAY;IAClC,aAAa;IACb,qBAAO,gCAAC;QAAY,WAAU;QAAmB,GAAG,QAAQ;QAAE,KAAK;;AACrE","sources":["packages/react-aria-components/src/Text.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 */\nimport {ContextValue, dom, DOMRenderProps, useContextProps} from './utils';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport React, {createContext, ForwardedRef, HTMLAttributes} from 'react';\n\nexport interface TextProps extends HTMLAttributes<HTMLElement>, DOMRenderProps<any, any> {\n elementType?: string;\n}\n\nexport const TextContext = createContext<ContextValue<TextProps, HTMLElement>>({});\n\nexport const Text = /*#__PURE__*/ createHideableComponent(function Text(\n props: TextProps,\n ref: ForwardedRef<HTMLElement>\n) {\n [props, ref] = useContextProps(props, ref, TextContext);\n\n let {elementType = 'span', ...domProps} = props;\n let ElementType = dom[elementType];\n // @ts-ignore\n return <ElementType className=\"react-aria-Text\" {...domProps} ref={ref} />;\n});\n"],"names":[],"version":3,"file":"Text.mjs.map"}
@@ -5,11 +5,13 @@ var $cab7d9a238d19c33$exports = require("./Text.cjs");
5
5
  var $4P2rL$reactariaprivatecollectionsHidden = require("react-aria/private/collections/Hidden");
6
6
  var $4P2rL$reactariafilterDOMProps = require("react-aria/filterDOMProps");
7
7
  var $4P2rL$reactariauseHover = require("react-aria/useHover");
8
+ var $4P2rL$reactariaprivateutilsdomHelpers = require("react-aria/private/utils/domHelpers");
8
9
  var $4P2rL$reactariamergeProps = require("react-aria/mergeProps");
9
10
  var $4P2rL$reactariamergeRefs = require("react-aria/mergeRefs");
10
11
  var $4P2rL$react = require("react");
11
12
  var $4P2rL$reactstatelyuseTokenFieldState = require("react-stately/useTokenFieldState");
12
13
  var $4P2rL$reactariauseFocusRing = require("react-aria/useFocusRing");
14
+ var $4P2rL$reactariaprivateutilsuseLayoutEffect = require("react-aria/private/utils/useLayoutEffect");
13
15
  var $4P2rL$reactariauseObjectRef = require("react-aria/useObjectRef");
14
16
  var $4P2rL$reactariauseTokenField = require("react-aria/useTokenField");
15
17
 
@@ -50,6 +52,8 @@ $parcel$export(module.exports, "Token", function () { return $95baf1bfb6adc271$e
50
52
 
51
53
 
52
54
 
55
+
56
+
53
57
  const $95baf1bfb6adc271$export$24532e5e37c56ff2 = /*#__PURE__*/ (0, $4P2rL$react.createContext)(null);
54
58
  const $95baf1bfb6adc271$var$TokenInputContext = /*#__PURE__*/ (0, $4P2rL$react.createContext)(null);
55
59
  const $95baf1bfb6adc271$export$e4550c392cbe69d7 = /*#__PURE__*/ (0, $4P2rL$reactariaprivatecollectionsHidden.createHideableComponent)(function TokenField(props, ref) {
@@ -146,9 +150,13 @@ const $95baf1bfb6adc271$export$4ddf413e820cfcc4 = /*#__PURE__*/ (0, $4P2rL$react
146
150
  let DOMProps = (0, $4P2rL$reactariafilterDOMProps.filterDOMProps)(domProps, {
147
151
  global: true
148
152
  });
153
+ let objectRef = (0, $4P2rL$reactariauseObjectRef.useObjectRef)(ref);
154
+ (0, $4P2rL$reactariaprivateutilsuseLayoutEffect.useLayoutEffect)(()=>$95baf1bfb6adc271$var$insertSelectionStyle(objectRef), [
155
+ objectRef
156
+ ]);
149
157
  return /*#__PURE__*/ (0, ($parcel$interopDefault($4P2rL$react))).createElement((0, $048d76b84370f141$exports.dom).div, {
150
158
  ...(0, $4P2rL$reactariamergeProps.mergeProps)(DOMProps, renderProps, focusProps, hoverProps, tokenFieldProps, autocompleteProps),
151
- ref: ref,
159
+ ref: objectRef,
152
160
  "data-focused": isFocused || undefined,
153
161
  "data-focus-visible": isFocusVisible || undefined,
154
162
  "data-disabled": isDisabled || undefined,
@@ -166,7 +174,8 @@ const $95baf1bfb6adc271$export$4ddf413e820cfcc4 = /*#__PURE__*/ (0, $4P2rL$react
166
174
  let token = children(v);
167
175
  return(// Wrap tokens in zero-width spaces so the cursor is placed correctly.
168
176
  /*#__PURE__*/ (0, ($parcel$interopDefault($4P2rL$react))).createElement("span", {
169
- key: i
177
+ key: i,
178
+ "data-react-aria-token": true
170
179
  }, '\u200b', token, '\u200b'));
171
180
  }
172
181
  case 'text':
@@ -202,6 +211,25 @@ const $95baf1bfb6adc271$export$50792b0e93539fde = /*#__PURE__*/ (0, $4P2rL$react
202
211
  });
203
212
  // Prevents React from re-rendering during composition events.
204
213
  const $95baf1bfb6adc271$var$CompositionRenderBlocker = /*#__PURE__*/ (0, $4P2rL$react.memo)(({ children: children })=>children, (prevProps, nextProps)=>nextProps.isComposing ? true : prevProps.children === nextProps.children);
214
+ // Inserts a stylesheet into the document / shadow root that hides the native text selection on tokens.
215
+ function $95baf1bfb6adc271$var$insertSelectionStyle(ref) {
216
+ if (typeof CSSStyleSheet !== 'function' || !ref || !ref.current) return;
217
+ let root = ref.current.getRootNode();
218
+ if (!(0, $4P2rL$reactariaprivateutilsdomHelpers.isDocument)(root) && !(0, $4P2rL$reactariaprivateutilsdomHelpers.isShadowRoot)(root)) return;
219
+ if (!root.adoptedStyleSheets) return;
220
+ // Skip if we already inserted it.
221
+ let sym = Symbol.for('react-aria-token-style');
222
+ if (root.adoptedStyleSheets.some((s)=>s[sym])) return;
223
+ let style = new CSSStyleSheet();
224
+ style[sym] = true;
225
+ // Firefox ignores completely transparent selection colors, so use a nearly transparent color instead.
226
+ style.replaceSync('[data-react-aria-token]::selection,[data-react-aria-token]>*::selection{background:#ffffff01}');
227
+ root.adoptedStyleSheets.push(style);
228
+ return ()=>{
229
+ let index = root.adoptedStyleSheets.indexOf(style);
230
+ if (index >= 0) root.adoptedStyleSheets.splice(index, 1);
231
+ };
232
+ }
205
233
 
206
234
 
207
235
  //# sourceMappingURL=TokenField.cjs.map
@@ -1 +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,EAAE,SAAS,WAEvE,KAAyB,EAAE,GAAiC;IAC5D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,CAAC,UAAU,MAAM,GAAG,CAAA,GAAA,iCAAM,EAAE,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB;IAEjF,IAAI,WAAW,CAAA,GAAA,2CAAgB,EAAE,CAAA,GAAA,2CAAgB,GAAG,MAAM,IAAI;IAC9D,IAAI,EACF,OAAO,kBAAkB,EACzB,UAAU,oBAAoB,EAC9B,KAAK,eAAe,EACpB,GAAG,mBACJ,GAAG,YAAY,CAAC;IACjB,IAAI,WAAW,CAAA,GAAA,yCAAW,EAAE;IAE5B,IAAI,aAAa,MAAM,UAAU,IAAI;IACrC,IAAI,aAAa,MAAM,UAAU,IAAI;IAErC,IAAI,QAAQ,CAAA,GAAA,wDAAiB,EAAK;QAChC,GAAG,KAAK;QACR,UAAU,CAAC;YACT,MAAM,QAAQ,GAAG;YACjB,uBAAuB,MAAM,QAAQ;QACvC;IACF;IAEA,IAAI,mBAAC,eAAe,c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,UAAU,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,sCAAO,EAAE,OAAO,CAAC,GAAG;IAEnD,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,QAAQ;wBACN;wBACA;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,6CAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAElD,qBACE,0DAAC,CAAA,GAAA,6BAAE,EAAE,IAAI;QACP,KAAK;QACJ,GAAG,CAAA,GAAA,qCAAS,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,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"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;AA4IM,MAAM,0DAAoB,CAAA,GAAA,0BAAY,EAAiD;AAC9F,MAAM,wDAAoB,CAAA,GAAA,0BAAY,EAAiC;AAMhE,MAAM,4CAAa,WAAW,GAAG,CAAA,GAAA,gEAAsB,EAAE,SAAS,WAEvE,KAAyB,EAAE,GAAiC;IAC5D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,CAAC,UAAU,MAAM,GAAG,CAAA,GAAA,iCAAM,EAAE,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB;IAEjF,IAAI,WAAW,CAAA,GAAA,2CAAgB,EAAE,CAAA,GAAA,2CAAgB,GAAG,MAAM,IAAI;IAC9D,IAAI,EACF,OAAO,kBAAkB,EACzB,UAAU,oBAAoB,EAC9B,KAAK,eAAe,EACpB,GAAG,mBACJ,GAAG,YAAY,CAAC;IACjB,IAAI,WAAW,CAAA,GAAA,yCAAW,EAAE;IAE5B,IAAI,aAAa,MAAM,UAAU,IAAI;IACrC,IAAI,aAAa,MAAM,UAAU,IAAI;IAErC,IAAI,QAAQ,CAAA,GAAA,wDAAiB,EAAK;QAChC,GAAG,KAAK;QACR,UAAU,CAAC;YACT,MAAM,QAAQ,GAAG;YACjB,uBAAuB,MAAM,QAAQ;QACvC;IACF;IAEA,IA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AGF,IAAI,QAAQ,IAAI;IAChB,KAAK,CAAC,IAAI,GAAG;IACb,sGAAsG;IACtG,MAAM,WAAW,CACf;IAEF,KAAK,kBAAkB,CAAC,IAAI,CAAC;IAE7B,OAAO;QACL,IAAI,QAAQ,KAAK,kBAAkB,CAAC,OAAO,CAAC;QAC5C,IAAI,SAAS,GACX,KAAK,kBAAkB,CAAC,MAAM,CAAC,OAAO;IAE1C;AACF","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 {isDocument, isShadowRoot} from 'react-aria/private/utils/domHelpers';\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 {useLayoutEffect} from 'react-aria/private/utils/useLayoutEffect';\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 let objectRef = useObjectRef(ref);\n useLayoutEffect(() => insertSelectionStyle(objectRef), [objectRef]);\n\n return (\n <dom.div\n {...mergeProps(\n DOMProps,\n renderProps,\n focusProps,\n hoverProps,\n tokenFieldProps,\n autocompleteProps\n )}\n ref={objectRef}\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} data-react-aria-token>\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\n// Inserts a stylesheet into the document / shadow root that hides the native text selection on tokens.\nfunction insertSelectionStyle(ref: RefObject<HTMLDivElement | null> | null) {\n if (typeof CSSStyleSheet !== 'function' || !ref || !ref.current) {\n return;\n }\n\n let root = ref.current.getRootNode();\n if (!isDocument(root) && !isShadowRoot(root)) {\n return;\n }\n\n if (!root.adoptedStyleSheets) {\n return;\n }\n\n // Skip if we already inserted it.\n let sym = Symbol.for('react-aria-token-style');\n if (root.adoptedStyleSheets.some(s => s[sym])) {\n return;\n }\n\n let style = new CSSStyleSheet();\n style[sym] = true;\n // Firefox ignores completely transparent selection colors, so use a nearly transparent color instead.\n style.replaceSync(\n '[data-react-aria-token]::selection,[data-react-aria-token]>*::selection{background:#ffffff01}'\n );\n root.adoptedStyleSheets.push(style);\n\n return () => {\n let index = root.adoptedStyleSheets.indexOf(style);\n if (index >= 0) {\n root.adoptedStyleSheets.splice(index, 1);\n }\n };\n}\n"],"names":[],"version":3,"file":"TokenField.cjs.map"}
@@ -5,11 +5,13 @@ import {TextContext as $20d769b1e2b13352$export$9afb8bc826b033ea} from "./Text.j
5
5
  import {createHideableComponent as $lOx05$createHideableComponent} from "react-aria/private/collections/Hidden";
6
6
  import {filterDOMProps as $lOx05$filterDOMProps} from "react-aria/filterDOMProps";
7
7
  import {useHover as $lOx05$useHover} from "react-aria/useHover";
8
+ import {isDocument as $lOx05$isDocument, isShadowRoot as $lOx05$isShadowRoot} from "react-aria/private/utils/domHelpers";
8
9
  import {mergeProps as $lOx05$mergeProps} from "react-aria/mergeProps";
9
10
  import {mergeRefs as $lOx05$mergeRefs} from "react-aria/mergeRefs";
10
11
  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
12
  import {useTokenFieldState as $lOx05$useTokenFieldState} from "react-stately/useTokenFieldState";
12
13
  import {useFocusRing as $lOx05$useFocusRing} from "react-aria/useFocusRing";
14
+ import {useLayoutEffect as $lOx05$useLayoutEffect} from "react-aria/private/utils/useLayoutEffect";
13
15
  import {useObjectRef as $lOx05$useObjectRef} from "react-aria/useObjectRef";
14
16
  import {useTokenField as $lOx05$useTokenField, useToken as $lOx05$useToken} from "react-aria/useTokenField";
15
17
 
@@ -37,6 +39,8 @@ import {useTokenField as $lOx05$useTokenField, useToken as $lOx05$useToken} from
37
39
 
38
40
 
39
41
 
42
+
43
+
40
44
  const $0557236f0f66b699$export$24532e5e37c56ff2 = /*#__PURE__*/ (0, $lOx05$createContext)(null);
41
45
  const $0557236f0f66b699$var$TokenInputContext = /*#__PURE__*/ (0, $lOx05$createContext)(null);
42
46
  const $0557236f0f66b699$export$e4550c392cbe69d7 = /*#__PURE__*/ (0, $lOx05$createHideableComponent)(function TokenField(props, ref) {
@@ -135,9 +139,13 @@ const $0557236f0f66b699$export$4ddf413e820cfcc4 = /*#__PURE__*/ (0, $lOx05$forwa
135
139
  let DOMProps = (0, $lOx05$filterDOMProps)(domProps, {
136
140
  global: true
137
141
  });
142
+ let objectRef = (0, $lOx05$useObjectRef)(ref);
143
+ (0, $lOx05$useLayoutEffect)(()=>$0557236f0f66b699$var$insertSelectionStyle(objectRef), [
144
+ objectRef
145
+ ]);
138
146
  return /*#__PURE__*/ (0, $lOx05$react).createElement((0, $b7b7a92703138c9b$export$df3a06d6289f983e).div, {
139
147
  ...(0, $lOx05$mergeProps)(DOMProps, renderProps, focusProps, hoverProps, tokenFieldProps, autocompleteProps),
140
- ref: ref,
148
+ ref: objectRef,
141
149
  "data-focused": isFocused || undefined,
142
150
  "data-focus-visible": isFocusVisible || undefined,
143
151
  "data-disabled": isDisabled || undefined,
@@ -155,7 +163,8 @@ const $0557236f0f66b699$export$4ddf413e820cfcc4 = /*#__PURE__*/ (0, $lOx05$forwa
155
163
  let token = children(v);
156
164
  return(// Wrap tokens in zero-width spaces so the cursor is placed correctly.
157
165
  /*#__PURE__*/ (0, $lOx05$react).createElement("span", {
158
- key: i
166
+ key: i,
167
+ "data-react-aria-token": true
159
168
  }, '\u200b', token, '\u200b'));
160
169
  }
161
170
  case 'text':
@@ -191,6 +200,25 @@ const $0557236f0f66b699$export$50792b0e93539fde = /*#__PURE__*/ (0, $lOx05$forwa
191
200
  });
192
201
  // Prevents React from re-rendering during composition events.
193
202
  const $0557236f0f66b699$var$CompositionRenderBlocker = /*#__PURE__*/ (0, $lOx05$memo)(({ children: children })=>children, (prevProps, nextProps)=>nextProps.isComposing ? true : prevProps.children === nextProps.children);
203
+ // Inserts a stylesheet into the document / shadow root that hides the native text selection on tokens.
204
+ function $0557236f0f66b699$var$insertSelectionStyle(ref) {
205
+ if (typeof CSSStyleSheet !== 'function' || !ref || !ref.current) return;
206
+ let root = ref.current.getRootNode();
207
+ if (!(0, $lOx05$isDocument)(root) && !(0, $lOx05$isShadowRoot)(root)) return;
208
+ if (!root.adoptedStyleSheets) return;
209
+ // Skip if we already inserted it.
210
+ let sym = Symbol.for('react-aria-token-style');
211
+ if (root.adoptedStyleSheets.some((s)=>s[sym])) return;
212
+ let style = new CSSStyleSheet();
213
+ style[sym] = true;
214
+ // Firefox ignores completely transparent selection colors, so use a nearly transparent color instead.
215
+ style.replaceSync('[data-react-aria-token]::selection,[data-react-aria-token]>*::selection{background:#ffffff01}');
216
+ root.adoptedStyleSheets.push(style);
217
+ return ()=>{
218
+ let index = root.adoptedStyleSheets.indexOf(style);
219
+ if (index >= 0) root.adoptedStyleSheets.splice(index, 1);
220
+ };
221
+ }
194
222
 
195
223
 
196
224
  export {$0557236f0f66b699$export$24532e5e37c56ff2 as TokenFieldContext, $0557236f0f66b699$export$e4550c392cbe69d7 as TokenField, $0557236f0f66b699$export$4ddf413e820cfcc4 as TokenInput, $0557236f0f66b699$export$50792b0e93539fde as Token};
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AA0IM,MAAM,0DAAoB,CAAA,GAAA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A,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":[],"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AAkB,CAAC,OAAO,CAAC;QAC5C,IAAI,SAAS,GACX,KAAK,kBAAkB,CAAC,MAAM,CAAC,OAAO;IAE1C;AACF","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 {isDocument, isShadowRoot} from 'react-aria/private/utils/domHelpers';\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 {useLayoutEffect} from 'react-aria/private/utils/useLayoutEffect';\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 let objectRef = useObjectRef(ref);\n useLayoutEffect(() => insertSelectionStyle(objectRef), [objectRef]);\n\n return (\n <dom.div\n {...mergeProps(\n DOMProps,\n renderProps,\n focusProps,\n hoverProps,\n tokenFieldProps,\n autocompleteProps\n )}\n ref={objectRef}\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} data-react-aria-token>\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\n// Inserts a stylesheet into the document / shadow root that hides the native text selection on tokens.\nfunction insertSelectionStyle(ref: RefObject<HTMLDivElement | null> | null) {\n if (typeof CSSStyleSheet !== 'function' || !ref || !ref.current) {\n return;\n }\n\n let root = ref.current.getRootNode();\n if (!isDocument(root) && !isShadowRoot(root)) {\n return;\n }\n\n if (!root.adoptedStyleSheets) {\n return;\n }\n\n // Skip if we already inserted it.\n let sym = Symbol.for('react-aria-token-style');\n if (root.adoptedStyleSheets.some(s => s[sym])) {\n return;\n }\n\n let style = new CSSStyleSheet();\n style[sym] = true;\n // Firefox ignores completely transparent selection colors, so use a nearly transparent color instead.\n style.replaceSync(\n '[data-react-aria-token]::selection,[data-react-aria-token]>*::selection{background:#ffffff01}'\n );\n root.adoptedStyleSheets.push(style);\n\n return () => {\n let index = root.adoptedStyleSheets.indexOf(style);\n if (index >= 0) {\n root.adoptedStyleSheets.splice(index, 1);\n }\n };\n}\n"],"names":[],"version":3,"file":"TokenField.js.map"}
@@ -5,11 +5,13 @@ import {TextContext as $efe09c6d1c304b50$export$9afb8bc826b033ea} from "./Text.m
5
5
  import {createHideableComponent as $iRP3W$createHideableComponent} from "react-aria/private/collections/Hidden";
6
6
  import {filterDOMProps as $iRP3W$filterDOMProps} from "react-aria/filterDOMProps";
7
7
  import {useHover as $iRP3W$useHover} from "react-aria/useHover";
8
+ import {isDocument as $iRP3W$isDocument, isShadowRoot as $iRP3W$isShadowRoot} from "react-aria/private/utils/domHelpers";
8
9
  import {mergeProps as $iRP3W$mergeProps} from "react-aria/mergeProps";
9
10
  import {mergeRefs as $iRP3W$mergeRefs} from "react-aria/mergeRefs";
10
11
  import $iRP3W$react, {createContext as $iRP3W$createContext, forwardRef as $iRP3W$forwardRef, useContext as $iRP3W$useContext, useMemo as $iRP3W$useMemo, memo as $iRP3W$memo} from "react";
11
12
  import {useTokenFieldState as $iRP3W$useTokenFieldState} from "react-stately/useTokenFieldState";
12
13
  import {useFocusRing as $iRP3W$useFocusRing} from "react-aria/useFocusRing";
14
+ import {useLayoutEffect as $iRP3W$useLayoutEffect} from "react-aria/private/utils/useLayoutEffect";
13
15
  import {useObjectRef as $iRP3W$useObjectRef} from "react-aria/useObjectRef";
14
16
  import {useTokenField as $iRP3W$useTokenField, useToken as $iRP3W$useToken} from "react-aria/useTokenField";
15
17
 
@@ -37,6 +39,8 @@ import {useTokenField as $iRP3W$useTokenField, useToken as $iRP3W$useToken} from
37
39
 
38
40
 
39
41
 
42
+
43
+
40
44
  const $45dd9fe7ca53fba4$export$24532e5e37c56ff2 = /*#__PURE__*/ (0, $iRP3W$createContext)(null);
41
45
  const $45dd9fe7ca53fba4$var$TokenInputContext = /*#__PURE__*/ (0, $iRP3W$createContext)(null);
42
46
  const $45dd9fe7ca53fba4$export$e4550c392cbe69d7 = /*#__PURE__*/ (0, $iRP3W$createHideableComponent)(function TokenField(props, ref) {
@@ -133,9 +137,13 @@ const $45dd9fe7ca53fba4$export$4ddf413e820cfcc4 = /*#__PURE__*/ (0, $iRP3W$forwa
133
137
  let DOMProps = (0, $iRP3W$filterDOMProps)(domProps, {
134
138
  global: true
135
139
  });
140
+ let objectRef = (0, $iRP3W$useObjectRef)(ref);
141
+ (0, $iRP3W$useLayoutEffect)(()=>$45dd9fe7ca53fba4$var$insertSelectionStyle(objectRef), [
142
+ objectRef
143
+ ]);
136
144
  return /*#__PURE__*/ (0, $iRP3W$react).createElement((0, $7230ffa83bc0c2cf$export$df3a06d6289f983e).div, {
137
145
  ...(0, $iRP3W$mergeProps)(DOMProps, renderProps, focusProps, hoverProps, tokenFieldProps, autocompleteProps),
138
- ref: ref,
146
+ ref: objectRef,
139
147
  "data-focused": isFocused || undefined,
140
148
  "data-focus-visible": isFocusVisible || undefined,
141
149
  "data-disabled": isDisabled || undefined,
@@ -153,7 +161,8 @@ const $45dd9fe7ca53fba4$export$4ddf413e820cfcc4 = /*#__PURE__*/ (0, $iRP3W$forwa
153
161
  let token = children(v);
154
162
  return(// Wrap tokens in zero-width spaces so the cursor is placed correctly.
155
163
  /*#__PURE__*/ (0, $iRP3W$react).createElement("span", {
156
- key: i
164
+ key: i,
165
+ "data-react-aria-token": true
157
166
  }, '\u200b', token, '\u200b'));
158
167
  }
159
168
  case 'text':
@@ -189,6 +198,25 @@ const $45dd9fe7ca53fba4$export$50792b0e93539fde = /*#__PURE__*/ (0, $iRP3W$forwa
189
198
  });
190
199
  // Prevents React from re-rendering during composition events.
191
200
  const $45dd9fe7ca53fba4$var$CompositionRenderBlocker = /*#__PURE__*/ (0, $iRP3W$memo)(({ children: children })=>children, (prevProps, nextProps)=>nextProps.isComposing ? true : prevProps.children === nextProps.children);
201
+ // Inserts a stylesheet into the document / shadow root that hides the native text selection on tokens.
202
+ function $45dd9fe7ca53fba4$var$insertSelectionStyle(ref) {
203
+ if (typeof CSSStyleSheet !== 'function' || !ref || !ref.current) return;
204
+ let root = ref.current.getRootNode();
205
+ if (!(0, $iRP3W$isDocument)(root) && !(0, $iRP3W$isShadowRoot)(root)) return;
206
+ if (!root.adoptedStyleSheets) return;
207
+ // Skip if we already inserted it.
208
+ let sym = Symbol.for('react-aria-token-style');
209
+ if (root.adoptedStyleSheets.some((s)=>s[sym])) return;
210
+ let style = new CSSStyleSheet();
211
+ style[sym] = true;
212
+ // Firefox ignores completely transparent selection colors, so use a nearly transparent color instead.
213
+ style.replaceSync('[data-react-aria-token]::selection,[data-react-aria-token]>*::selection{background:#ffffff01}');
214
+ root.adoptedStyleSheets.push(style);
215
+ return ()=>{
216
+ let index = root.adoptedStyleSheets.indexOf(style);
217
+ if (index >= 0) root.adoptedStyleSheets.splice(index, 1);
218
+ };
219
+ }
192
220
 
193
221
 
194
222
  export {$45dd9fe7ca53fba4$export$24532e5e37c56ff2 as TokenFieldContext, $45dd9fe7ca53fba4$export$e4550c392cbe69d7 as TokenField, $45dd9fe7ca53fba4$export$4ddf413e820cfcc4 as TokenInput, $45dd9fe7ca53fba4$export$50792b0e93539fde as Token};
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AA0IM,MAAM,0DAAoB,CAAA,GAAA,oBAAY,EAAiD;AAC9F,MAAM,wDAAoB,CAAA,GAAA,oBAAY,EAAi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ACrB;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.mjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;AA4IM,MAAM,0DAAoB,CAAA,GAAA,oBAAY,EAAiD;AAC9F,MAAM,wDAAoB,CAAA,GAAA,oBAAY,EAAiC;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,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;AAG5E,uGAAuG;AACvG,SAAS,2CAAqB,GAA4C;IACxE,IAAI,OAAO,kBAAkB,cAAc,CAAC,OAAO,CAAC,IAAI,OAAO,EAC7D;IAGF,IAAI,OAAO,IAAI,OAAO,CAAC,WAAW;IAClC,IAAI,CAAC,CAAA,GAAA,iBAAS,EAAE,SAAS,CAAC,CAAA,GAAA,mBAAW,EAAE,OACrC;IAGF,IAAI,CAAC,KAAK,kBAAkB,EAC1B;IAGF,kCAAkC;IAClC,IAAI,MAAM,OAAO,GAAG,CAAC;IACrB,IAAI,KAAK,kBAAkB,CAAC,IAAI,CAAC,CAAA,IAAK,CAAC,CAAC,IAAI,GAC1C;IAGF,IAAI,QAAQ,IAAI;IAChB,KAAK,CAAC,IAAI,GAAG;IACb,sGAAsG;IACtG,MAAM,WAAW,CACf;IAEF,KAAK,kBAAkB,CAAC,IAAI,CAAC;IAE7B,OAAO;QACL,IAAI,QAAQ,KAAK,kBAAkB,CAAC,OAAO,CAAC;QAC5C,IAAI,SAAS,GACX,KAAK,kBAAkB,CAAC,MAAM,CAAC,OAAO;IAE1C;AACF","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 {isDocument, isShadowRoot} from 'react-aria/private/utils/domHelpers';\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 {useLayoutEffect} from 'react-aria/private/utils/useLayoutEffect';\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 let objectRef = useObjectRef(ref);\n useLayoutEffect(() => insertSelectionStyle(objectRef), [objectRef]);\n\n return (\n <dom.div\n {...mergeProps(\n DOMProps,\n renderProps,\n focusProps,\n hoverProps,\n tokenFieldProps,\n autocompleteProps\n )}\n ref={objectRef}\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} data-react-aria-token>\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\n// Inserts a stylesheet into the document / shadow root that hides the native text selection on tokens.\nfunction insertSelectionStyle(ref: RefObject<HTMLDivElement | null> | null) {\n if (typeof CSSStyleSheet !== 'function' || !ref || !ref.current) {\n return;\n }\n\n let root = ref.current.getRootNode();\n if (!isDocument(root) && !isShadowRoot(root)) {\n return;\n }\n\n if (!root.adoptedStyleSheets) {\n return;\n }\n\n // Skip if we already inserted it.\n let sym = Symbol.for('react-aria-token-style');\n if (root.adoptedStyleSheets.some(s => s[sym])) {\n return;\n }\n\n let style = new CSSStyleSheet();\n style[sym] = true;\n // Firefox ignores completely transparent selection colors, so use a nearly transparent color instead.\n style.replaceSync(\n '[data-react-aria-token]::selection,[data-react-aria-token]>*::selection{background:#ffffff01}'\n );\n root.adoptedStyleSheets.push(style);\n\n return () => {\n let index = root.adoptedStyleSheets.indexOf(style);\n if (index >= 0) {\n root.adoptedStyleSheets.splice(index, 1);\n }\n };\n}\n"],"names":[],"version":3,"file":"TokenField.mjs.map"}