react-stately 3.47.0 → 3.49.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 (140) hide show
  1. package/dist/exports/index.cjs +6 -0
  2. package/dist/exports/index.cjs.map +1 -1
  3. package/dist/exports/index.js +5 -1
  4. package/dist/exports/index.js.map +1 -1
  5. package/dist/exports/index.mjs +5 -1
  6. package/dist/exports/index.mjs.map +1 -1
  7. package/dist/exports/useTokenFieldState.cjs +25 -0
  8. package/dist/exports/useTokenFieldState.cjs.map +1 -0
  9. package/dist/exports/useTokenFieldState.js +19 -0
  10. package/dist/exports/useTokenFieldState.js.map +1 -0
  11. package/dist/exports/useTokenFieldState.mjs +19 -0
  12. package/dist/exports/useTokenFieldState.mjs.map +1 -0
  13. package/dist/private/color/Color.cjs.map +1 -1
  14. package/dist/private/color/Color.js.map +1 -1
  15. package/dist/private/color/Color.mjs.map +1 -1
  16. package/dist/private/combobox/useComboBoxState.cjs +2 -1
  17. package/dist/private/combobox/useComboBoxState.cjs.map +1 -1
  18. package/dist/private/combobox/useComboBoxState.js +2 -1
  19. package/dist/private/combobox/useComboBoxState.js.map +1 -1
  20. package/dist/private/combobox/useComboBoxState.mjs +2 -1
  21. package/dist/private/combobox/useComboBoxState.mjs.map +1 -1
  22. package/dist/private/data/useTreeData.cjs +1 -0
  23. package/dist/private/data/useTreeData.cjs.map +1 -1
  24. package/dist/private/data/useTreeData.js +1 -0
  25. package/dist/private/data/useTreeData.js.map +1 -1
  26. package/dist/private/data/useTreeData.mjs +1 -0
  27. package/dist/private/data/useTreeData.mjs.map +1 -1
  28. package/dist/private/datepicker/useDateRangePickerState.cjs +1 -0
  29. package/dist/private/datepicker/useDateRangePickerState.cjs.map +1 -1
  30. package/dist/private/datepicker/useDateRangePickerState.js +1 -0
  31. package/dist/private/datepicker/useDateRangePickerState.js.map +1 -1
  32. package/dist/private/datepicker/useDateRangePickerState.mjs +1 -0
  33. package/dist/private/datepicker/useDateRangePickerState.mjs.map +1 -1
  34. package/dist/private/datepicker/utils.cjs.map +1 -1
  35. package/dist/private/datepicker/utils.js.map +1 -1
  36. package/dist/private/datepicker/utils.mjs.map +1 -1
  37. package/dist/private/form/useFormValidationState.cjs +1 -1
  38. package/dist/private/form/useFormValidationState.cjs.map +1 -1
  39. package/dist/private/form/useFormValidationState.js +1 -1
  40. package/dist/private/form/useFormValidationState.js.map +1 -1
  41. package/dist/private/form/useFormValidationState.mjs +1 -1
  42. package/dist/private/form/useFormValidationState.mjs.map +1 -1
  43. package/dist/private/grid/useGridState.cjs +12 -10
  44. package/dist/private/grid/useGridState.cjs.map +1 -1
  45. package/dist/private/grid/useGridState.js +12 -10
  46. package/dist/private/grid/useGridState.js.map +1 -1
  47. package/dist/private/grid/useGridState.mjs +12 -10
  48. package/dist/private/grid/useGridState.mjs.map +1 -1
  49. package/dist/private/layout/ListLayout.cjs +0 -3
  50. package/dist/private/layout/ListLayout.cjs.map +1 -1
  51. package/dist/private/layout/ListLayout.js +0 -3
  52. package/dist/private/layout/ListLayout.js.map +1 -1
  53. package/dist/private/layout/ListLayout.mjs +0 -3
  54. package/dist/private/layout/ListLayout.mjs.map +1 -1
  55. package/dist/private/menu/useMenuTriggerState.cjs.map +1 -1
  56. package/dist/private/menu/useMenuTriggerState.js.map +1 -1
  57. package/dist/private/menu/useMenuTriggerState.mjs.map +1 -1
  58. package/dist/private/menu/useSubmenuTriggerState.cjs +3 -1
  59. package/dist/private/menu/useSubmenuTriggerState.cjs.map +1 -1
  60. package/dist/private/menu/useSubmenuTriggerState.js +3 -1
  61. package/dist/private/menu/useSubmenuTriggerState.js.map +1 -1
  62. package/dist/private/menu/useSubmenuTriggerState.mjs +3 -1
  63. package/dist/private/menu/useSubmenuTriggerState.mjs.map +1 -1
  64. package/dist/private/overlays/useOverlayTriggerState.cjs +4 -1
  65. package/dist/private/overlays/useOverlayTriggerState.cjs.map +1 -1
  66. package/dist/private/overlays/useOverlayTriggerState.js +5 -2
  67. package/dist/private/overlays/useOverlayTriggerState.js.map +1 -1
  68. package/dist/private/overlays/useOverlayTriggerState.mjs +5 -2
  69. package/dist/private/overlays/useOverlayTriggerState.mjs.map +1 -1
  70. package/dist/private/select/useSelectState.cjs +1 -0
  71. package/dist/private/select/useSelectState.cjs.map +1 -1
  72. package/dist/private/select/useSelectState.js +1 -0
  73. package/dist/private/select/useSelectState.js.map +1 -1
  74. package/dist/private/select/useSelectState.mjs +1 -0
  75. package/dist/private/select/useSelectState.mjs.map +1 -1
  76. package/dist/private/slider/useSliderState.cjs.map +1 -1
  77. package/dist/private/slider/useSliderState.js.map +1 -1
  78. package/dist/private/slider/useSliderState.mjs.map +1 -1
  79. package/dist/private/table/TableUtils.cjs +13 -1
  80. package/dist/private/table/TableUtils.cjs.map +1 -1
  81. package/dist/private/table/TableUtils.js +13 -1
  82. package/dist/private/table/TableUtils.js.map +1 -1
  83. package/dist/private/table/TableUtils.mjs +13 -1
  84. package/dist/private/table/TableUtils.mjs.map +1 -1
  85. package/dist/private/table/useTableState.cjs +1 -0
  86. package/dist/private/table/useTableState.cjs.map +1 -1
  87. package/dist/private/table/useTableState.js +1 -0
  88. package/dist/private/table/useTableState.js.map +1 -1
  89. package/dist/private/table/useTableState.mjs +1 -0
  90. package/dist/private/table/useTableState.mjs.map +1 -1
  91. package/dist/private/tokenfield/TokenFieldValue.cjs +287 -0
  92. package/dist/private/tokenfield/TokenFieldValue.cjs.map +1 -0
  93. package/dist/private/tokenfield/TokenFieldValue.js +285 -0
  94. package/dist/private/tokenfield/TokenFieldValue.js.map +1 -0
  95. package/dist/private/tokenfield/TokenFieldValue.mjs +282 -0
  96. package/dist/private/tokenfield/TokenFieldValue.mjs.map +1 -0
  97. package/dist/private/tokenfield/useTokenFieldState.cjs +37 -0
  98. package/dist/private/tokenfield/useTokenFieldState.cjs.map +1 -0
  99. package/dist/private/tokenfield/useTokenFieldState.js +32 -0
  100. package/dist/private/tokenfield/useTokenFieldState.js.map +1 -0
  101. package/dist/private/tokenfield/useTokenFieldState.mjs +32 -0
  102. package/dist/private/tokenfield/useTokenFieldState.mjs.map +1 -0
  103. package/dist/private/tooltip/useTooltipTriggerState.cjs +18 -6
  104. package/dist/private/tooltip/useTooltipTriggerState.cjs.map +1 -1
  105. package/dist/private/tooltip/useTooltipTriggerState.js +19 -7
  106. package/dist/private/tooltip/useTooltipTriggerState.js.map +1 -1
  107. package/dist/private/tooltip/useTooltipTriggerState.mjs +19 -7
  108. package/dist/private/tooltip/useTooltipTriggerState.mjs.map +1 -1
  109. package/dist/private/virtualizer/ScrollAnchor.cjs +136 -0
  110. package/dist/private/virtualizer/ScrollAnchor.cjs.map +1 -0
  111. package/dist/private/virtualizer/ScrollAnchor.js +132 -0
  112. package/dist/private/virtualizer/ScrollAnchor.js.map +1 -0
  113. package/dist/private/virtualizer/ScrollAnchor.mjs +131 -0
  114. package/dist/private/virtualizer/ScrollAnchor.mjs.map +1 -0
  115. package/dist/private/virtualizer/Virtualizer.cjs +50 -1
  116. package/dist/private/virtualizer/Virtualizer.cjs.map +1 -1
  117. package/dist/private/virtualizer/Virtualizer.js +54 -1
  118. package/dist/private/virtualizer/Virtualizer.js.map +1 -1
  119. package/dist/private/virtualizer/Virtualizer.mjs +50 -1
  120. package/dist/private/virtualizer/Virtualizer.mjs.map +1 -1
  121. package/dist/private/virtualizer/useVirtualizerState.cjs +2 -1
  122. package/dist/private/virtualizer/useVirtualizerState.cjs.map +1 -1
  123. package/dist/private/virtualizer/useVirtualizerState.js +2 -1
  124. package/dist/private/virtualizer/useVirtualizerState.js.map +1 -1
  125. package/dist/private/virtualizer/useVirtualizerState.mjs +2 -1
  126. package/dist/private/virtualizer/useVirtualizerState.mjs.map +1 -1
  127. package/dist/types/exports/index.d.ts +4 -0
  128. package/dist/types/exports/useTokenFieldState.d.ts +4 -0
  129. package/dist/types/src/combobox/useComboBoxState.d.ts +1 -1
  130. package/dist/types/src/menu/useMenuTriggerState.d.ts +1 -1
  131. package/dist/types/src/overlays/useOverlayTriggerState.d.ts +9 -0
  132. package/dist/types/src/table/useTableState.d.ts +7 -0
  133. package/dist/types/src/tokenfield/TokenFieldValue.d.ts +71 -0
  134. package/dist/types/src/tokenfield/useTokenFieldState.d.ts +19 -0
  135. package/dist/types/src/tooltip/useTooltipTriggerState.d.ts +5 -0
  136. package/dist/types/src/virtualizer/ScrollAnchor.d.ts +81 -0
  137. package/dist/types/src/virtualizer/Virtualizer.d.ts +1 -0
  138. package/dist/types/src/virtualizer/types.d.ts +2 -0
  139. package/package.json +5 -5
  140. package/useTokenFieldState/package.json +5 -0
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA;;;;;;;;;;CAUC,GAuBD,IAAA,AAAK,yDAAA;;;WAAA;EAAA;AAYE,MAAM;IAkBD,iBAAiB,QAAyC,EAAQ;QAC1E,MAAM,cAAc,IAAI,CAAC,WAAW;QAIpC,OAAO,IAAI,YAAY;IACzB;IAEA,yEAAyE,GACzE,kBAAkB,aAAuB,EAAQ;QAC/C,IACE,IAAI,CAAC,aAAa,CAAC,KAAK,KAAK,cAAc,KAAK,IAChD,IAAI,CAAC,aAAa,CAAC,MAAM,KAAK,cAAc,MAAM,EAElD,OAAO,IAAI;QAGb,IAAI,SAAS,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ;QAChD,OAAO,aAAa,GAAG;QACvB,OAAO,QAAQ,GAAG,IAAI,CAAC,QAAQ;QAC/B,OAAO,IAAI,GAAG,IAAI,CAAC,IAAI;QACvB,OAAO,YAAY,GAAG,IAAI,CAAC,YAAY;QACvC,OAAO;IACT;IAEQ,aACN,OAAsC,EACtC,MAAc,EACwC;QACtD,IAAI,CAAC,SAAS;YACZ,IAAI,QAAQ,IAAI,CAAC,iBAAiB,CAAC;YACnC,OAAO;gBAAC,SAAS,IAAI,QAAQ;gBAAM,SAAS,IAAI,OAAO;aAAM;QAC/D;QAEA,IAAI,QAAQ,IAAI,KAAK,SACnB,OAAO;YAAC,SAAS,IAAI;gBAAC,GA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,aAAa,KAAK,MAAM;IAC/D,IAAI,QAAQ,GACV,OAAO;IAGT,IAAI,KAAK,OAAO,KAAK,CAAC,QAAQ,CAAC,OAAO,SAAS,IAAI,OAAO,OAAO,MAAM,EAAE,OAAO,KAAK,GAAG;IACxF,IAAI,UAAU,MAAM,IAAI,CAAC,KAAK,KAAK,CAAC,GAAG,OAAO,QAAQ,CAAC;QAChD;IAAP,OAAO,CAAA,qBAAA,cAAA,QAAQ,EAAE,CAAC,CAAC,gBAAZ,kCAAA,YAAgB,KAAK,cAArB,+BAAA,oBAAyB;AAClC;AAEA,SAAS,qCACP,QAA6B,EAC7B,MAA2B,EAC3B,QAAgD;IAEhD,KAAK,IAAI,WAAW,OAAQ;QAC1B,IAAI,QAAQ,IAAI,KAAK,UAAU,QAAQ,IAAI,CAAC,MAAM,KAAK,GACrD;QAGF,IAAI,OAAO,QAAQ,CAAC,SAAS,MAAM,GAAG,EAAE;QACxC,IAAI,QAAQ,KAAK,IAAI,KAAK,UAAU,QAAQ,IAAI,KAAK;YACnD,IAAI,UAAU;gBACZ,IAAI,YAAY,SAAS,KAAK,IAAI,GAAG,QAAQ,IAAI;gBACjD,SAAS,MAAM,CAAC,SAAS,MAAM,GAAG,GAAG,MAAM;YAC7C,OACE,QAAQ,CAAC,SAAS,MAAM,GAAG,EAAE,GAAG;gBAAC,MAAM;gBAAQ,MAAM,KAAK,IAAI,GAAG,QAAQ,IAAI;YAAA;eAE1E,IAAI,YAAY,QAAQ,IAAI,KAAK,QAAQ;YAC9C,IAAI,YAAY,SAAS,QAAQ,IAAI;YACrC,SAAS,IAAI,IAAI;QACnB,OACE,SAAS,IAAI,CAAC;IAElB;IACA,OAAO;AACT","sources":["packages/react-stately/src/tokenfield/TokenFieldValue.ts"],"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\nexport type TokenFieldSegment<T = any> = TextSegment | TokenSegment<T>;\n\nexport interface TextSegment {\n type: 'text';\n text: string;\n}\n\nexport interface TokenSegment<T = any> {\n type: 'token';\n text: string;\n /** An arbitrary value associated with the token. */\n value?: T;\n}\n\nexport interface Position {\n /** Index of the segment in the list. */\n index: number;\n /** Text offset within the segment in UTF-16 code units. */\n offset: number;\n}\n\nenum Direction {\n Forward = 1,\n Backward = -1\n}\n\nexport interface TokenFieldValueOptions {\n caretPosition?: Position | null;\n}\n\n/**\n * A list of segments containing editable text and non-editable tokens.\n */\nexport class TokenFieldValue<T = any> {\n static readonly Direction = Direction;\n\n /** The text and token segments in the list. */\n readonly segments: readonly TokenFieldSegment<T>[];\n /** The caret position. */\n caretPosition: Position = {index: 0, offset: 0};\n // Linked list representing the undo/redo history.\n private previous: this | null = null;\n private next: this | null = null;\n private isCoalescing = true;\n\n /** Create a new list with the given segments. */\n constructor(tokens: readonly TokenFieldSegment<T>[], options?: TokenFieldValueOptions) {\n this.segments = tokens;\n this.caretPosition = options?.caretPosition ?? {index: 0, offset: 0};\n }\n\n protected createFieldValue(segments: readonly TokenFieldSegment<T>[]): this {\n const Constructor = this.constructor as new (\n segments: readonly TokenFieldSegment<T>[],\n options?: TokenFieldValueOptions\n ) => this;\n return new Constructor(segments);\n }\n\n /** Create a new list with the caret position set to the given position. */\n withCaretPosition(caretPosition: Position): this {\n if (\n this.caretPosition.index === caretPosition.index &&\n this.caretPosition.offset === caretPosition.offset\n ) {\n return this;\n }\n\n let result = this.createFieldValue(this.segments);\n result.caretPosition = caretPosition;\n result.previous = this.previous;\n result.next = this.next;\n result.isCoalescing = this.isCoalescing;\n return result;\n }\n\n private splitSegment(\n segment: TokenFieldSegment | undefined,\n offset: number\n ): [TokenFieldSegment | null, TokenFieldSegment | null] {\n if (!segment) {\n let empty = this.createTextSegment('');\n return [offset > 0 ? empty : null, offset > 0 ? null : empty];\n }\n\n if (segment.type === 'token') {\n return [offset > 0 ? {...segment} : null, offset > 0 ? null : {...segment}];\n }\n\n return [\n offset > 0 ? {type: 'text', text: segment.text.slice(0, offset)} : null,\n offset < segment.text.length ? this.createTextSegment(segment.text.slice(offset)) : null\n ];\n }\n\n private createTextSegment(text: string): TextSegment {\n return {type: 'text', text};\n }\n\n protected tokenize(text: string): TokenFieldSegment<T>[] {\n return [this.createTextSegment(text)];\n }\n\n private clampPosition(position: Position): Position {\n if (this.segments.length > 0 && position.index >= this.segments.length) {\n return {\n index: this.segments.length - 1,\n offset: this.segments[this.segments.length - 1].text.length\n };\n }\n\n if (position.index < 0) {\n return {index: 0, offset: 0};\n }\n return position;\n }\n\n /** Replace the text between two positions with new text. */\n replaceRange(start: Position, end: Position, text: string, coalesce = true): this {\n return this.replaceRangeWithSegments(\n start,\n end,\n text.length > 0 ? [this.createTextSegment(text)] : [],\n coalesce\n );\n }\n\n /** Replace the text between two positions with new segments. */\n replaceRangeWithSegments(\n start: Position,\n end: Position,\n insert: TokenFieldSegment<T>[],\n coalesce = true\n ): this {\n start = this.clampPosition(start);\n end = this.clampPosition(end);\n let startSegment = this.segments[start.index];\n let endSegment = this.segments[end.index];\n let [startSplit] = this.splitSegment(startSegment, start.offset);\n let [, endSplit] = this.splitSegment(endSegment, end.offset);\n\n let newSegments = this.segments.slice(0, start.index);\n if (startSplit) {\n appendSegments(newSegments, [startSplit]);\n }\n\n if (insert.length) {\n appendSegments(newSegments, insert, text => this.tokenize(text));\n }\n\n let lastSegment = newSegments[newSegments.length - 1];\n let lastIsText = lastSegment && lastSegment.type === 'text';\n let caret = {\n index: lastIsText ? newSegments.length - 1 : newSegments.length,\n offset: lastIsText ? lastSegment.text.length : 0\n };\n\n if (endSplit) {\n appendSegments(newSegments, [endSplit]);\n }\n\n appendSegments(newSegments, this.segments.slice(end.index + 1));\n\n let segments = this.createFieldValue(newSegments);\n segments.caretPosition = caret;\n segments.isCoalescing = coalesce;\n if (this.isCoalescing && coalesce && this.previous) {\n segments.previous = this.previous;\n segments.previous.next = segments;\n } else {\n segments.previous = this;\n this.caretPosition = end;\n this.next = segments;\n }\n return segments;\n }\n\n /** Find the boundary before or after a position using an Intl.Segmenter. */\n findBoundaryWithSegmenter(\n position: Position,\n segmenter: Intl.Segmenter,\n direction: Direction\n ): Position | null {\n position = this.clampPosition(position);\n for (let i = position.index; i >= 0 && i < this.segments.length; i += direction) {\n let segment = this.segments[i];\n switch (segment.type) {\n case 'token':\n if (\n i !== position.index ||\n (direction === Direction.Backward ? position.offset > 0 : position.offset === 0)\n ) {\n let index = i + direction;\n return {\n index: index >= 0 ? index : 0,\n offset:\n direction === Direction.Backward && index >= 0\n ? this.segments[index].text.length\n : 0\n };\n }\n continue;\n case 'text': {\n let offset = direction === Direction.Backward ? segment.text.length : 0;\n if (i === position.index) {\n offset = position.offset;\n }\n if (direction === Direction.Backward) {\n offset--;\n }\n if (offset < 0 || offset >= segment.text.length) {\n continue;\n }\n\n let part = segmenter.segment(segment.text).containing(offset);\n while (part && part.isWordLike === false) {\n offset += direction;\n part = segmenter.segment(segment.text).containing(offset);\n }\n\n if (part) {\n return {\n index: i,\n offset:\n direction === Direction.Backward ? part.index : part.index + part.segment.length\n };\n }\n continue;\n }\n }\n }\n\n return null;\n }\n\n /** Find a line boundary before or after a position. */\n findLineBoundary(position: Position, direction: Direction): Position | null {\n let res = this.findText(position, direction, '\\n');\n if (res) {\n return res;\n }\n return direction === Direction.Backward\n ? {index: 0, offset: 0}\n : {\n index: this.segments.length - 1,\n offset: this.segments[this.segments.length - 1].text.length\n };\n }\n\n /** Find a string or regular expression match before or after a position. */\n findText(position: Position, direction: Direction, search: string | RegExp): Position | null {\n if (this.segments.length === 0) {\n return null;\n }\n\n for (let i = position.index; i >= 0 && i < this.segments.length; i += direction) {\n let segment = this.segments[i];\n if (segment.type !== 'text') {\n continue;\n }\n let offset = findInText(\n segment.text,\n search,\n direction,\n i === position.index ? position.offset : undefined\n );\n if (offset >= 0) {\n return {\n index: i,\n offset: offset\n };\n }\n }\n\n return null;\n }\n\n /** Delete text at a position using a segmenter. */\n delete(\n position: Position,\n segmenter: Intl.Segmenter,\n direction: Direction,\n coalesce = true\n ): this {\n let boundary = this.findBoundaryWithSegmenter(position, segmenter, direction);\n if (boundary) {\n return this.replaceRange(\n direction === Direction.Backward ? boundary : position,\n direction === Direction.Backward ? position : boundary,\n '',\n coalesce\n );\n }\n\n this.caretPosition = position;\n return this;\n }\n\n /** Delete text to the next or previous line break. */\n deleteLine(position: Position, direction: Direction, coalesce = true): this {\n if (this.segments.length === 0) {\n return this;\n }\n\n let boundary = this.findLineBoundary(position, direction);\n if (boundary) {\n return this.replaceRange(\n direction === Direction.Backward ? boundary : position,\n direction === Direction.Backward ? position : boundary,\n '',\n coalesce\n );\n }\n\n return this;\n }\n\n /** Create a new list containing a subset of the segments. */\n slice(start: Position, end: Position): this {\n start = this.clampPosition(start);\n end = this.clampPosition(end);\n if (start.index === end.index && start.offset === end.offset) {\n return this.createFieldValue([]);\n }\n if (start.index === end.index) {\n let segment = this.segments[start.index];\n if (segment.type === 'text') {\n return this.createFieldValue([\n {type: 'text', text: segment.text.slice(start.offset, end.offset)}\n ]);\n }\n return this.createFieldValue([segment]);\n }\n let startSegment = this.segments[start.index];\n let endSegment = this.segments[end.index];\n let [, startSplit] = this.splitSegment(startSegment, start.offset);\n let [endSplit] = this.splitSegment(endSegment, end.offset);\n\n let result: TokenFieldSegment<T>[] = [];\n if (startSplit) {\n result.push(startSplit);\n }\n result.push(...this.segments.slice(start.index + 1, end.index));\n if (endSplit) {\n result.push(endSplit);\n }\n return this.createFieldValue(result);\n }\n\n /** Convert the list to a string. */\n toString(): string {\n return this.segments.map(seg => seg.text).join('');\n }\n\n /** Returns the previous list in the undo history. */\n undo(): this {\n return this.previous ?? this;\n }\n\n /** Returns the next list in the redo history. */\n redo(): this {\n return this.next ?? this;\n }\n\n /** End coalescing undo/redo history. */\n endCoalescing(): void {\n this.isCoalescing = false;\n }\n}\n\nfunction findInText(\n text: string,\n search: string | RegExp,\n direction: Direction,\n fromOffset?: number\n): number {\n if (typeof search === 'string') {\n if (direction === Direction.Backward) {\n return text.lastIndexOf(search, fromOffset !== undefined ? fromOffset - 1 : text.length - 1);\n }\n return text.indexOf(search, fromOffset ?? 0);\n }\n\n if (direction === Direction.Forward) {\n let start = fromOffset ?? 0;\n let index = text.slice(start).search(search);\n return index >= 0 ? start + index : -1;\n }\n\n let limit = fromOffset !== undefined ? fromOffset : text.length;\n if (limit < 0) {\n return -1;\n }\n\n let re = search.flags.includes('g') ? search : new RegExp(search.source, search.flags + 'g');\n let matches = Array.from(text.slice(0, limit).matchAll(re));\n return matches.at(-1)?.index ?? -1;\n}\n\nfunction appendSegments(\n segments: TokenFieldSegment[],\n insert: TokenFieldSegment[],\n tokenize?: (text: string) => TokenFieldSegment[]\n): TokenFieldSegment[] {\n for (let segment of insert) {\n if (segment.type === 'text' && segment.text.length === 0) {\n continue;\n }\n\n let last = segments[segments.length - 1];\n if (last && last.type === 'text' && segment.type === 'text') {\n if (tokenize) {\n let tokenized = tokenize(last.text + segment.text);\n segments.splice(segments.length - 1, 1, ...tokenized);\n } else {\n segments[segments.length - 1] = {type: 'text', text: last.text + segment.text};\n }\n } else if (tokenize && segment.type === 'text') {\n let tokenized = tokenize(segment.text);\n segments.push(...tokenized);\n } else {\n segments.push(segment);\n }\n }\n return segments;\n}\n"],"names":[],"version":3,"file":"TokenFieldValue.js.map"}
@@ -0,0 +1,282 @@
1
+ /*
2
+ * Copyright 2026 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */ var $4a46f1c4231e5dde$var$Direction = /*#__PURE__*/ function(Direction) {
12
+ Direction[Direction["Forward"] = 1] = "Forward";
13
+ Direction[Direction["Backward"] = -1] = "Backward";
14
+ return Direction;
15
+ }($4a46f1c4231e5dde$var$Direction || {});
16
+ class $4a46f1c4231e5dde$export$f3decd0c2cd2fe2e {
17
+ static{
18
+ this.Direction = $4a46f1c4231e5dde$var$Direction;
19
+ }
20
+ /** Create a new list with the given segments. */ constructor(tokens, options){
21
+ /** The caret position. */ this.caretPosition = {
22
+ index: 0,
23
+ offset: 0
24
+ };
25
+ // Linked list representing the undo/redo history.
26
+ this.previous = null;
27
+ this.next = null;
28
+ this.isCoalescing = true;
29
+ this.segments = tokens;
30
+ this.caretPosition = options?.caretPosition ?? {
31
+ index: 0,
32
+ offset: 0
33
+ };
34
+ }
35
+ createFieldValue(segments) {
36
+ const Constructor = this.constructor;
37
+ return new Constructor(segments);
38
+ }
39
+ /** Create a new list with the caret position set to the given position. */ withCaretPosition(caretPosition) {
40
+ if (this.caretPosition.index === caretPosition.index && this.caretPosition.offset === caretPosition.offset) return this;
41
+ let result = this.createFieldValue(this.segments);
42
+ result.caretPosition = caretPosition;
43
+ result.previous = this.previous;
44
+ result.next = this.next;
45
+ result.isCoalescing = this.isCoalescing;
46
+ return result;
47
+ }
48
+ splitSegment(segment, offset) {
49
+ if (!segment) {
50
+ let empty = this.createTextSegment('');
51
+ return [
52
+ offset > 0 ? empty : null,
53
+ offset > 0 ? null : empty
54
+ ];
55
+ }
56
+ if (segment.type === 'token') return [
57
+ offset > 0 ? {
58
+ ...segment
59
+ } : null,
60
+ offset > 0 ? null : {
61
+ ...segment
62
+ }
63
+ ];
64
+ return [
65
+ offset > 0 ? {
66
+ type: 'text',
67
+ text: segment.text.slice(0, offset)
68
+ } : null,
69
+ offset < segment.text.length ? this.createTextSegment(segment.text.slice(offset)) : null
70
+ ];
71
+ }
72
+ createTextSegment(text) {
73
+ return {
74
+ type: 'text',
75
+ text: text
76
+ };
77
+ }
78
+ tokenize(text) {
79
+ return [
80
+ this.createTextSegment(text)
81
+ ];
82
+ }
83
+ clampPosition(position) {
84
+ if (this.segments.length > 0 && position.index >= this.segments.length) return {
85
+ index: this.segments.length - 1,
86
+ offset: this.segments[this.segments.length - 1].text.length
87
+ };
88
+ if (position.index < 0) return {
89
+ index: 0,
90
+ offset: 0
91
+ };
92
+ return position;
93
+ }
94
+ /** Replace the text between two positions with new text. */ replaceRange(start, end, text, coalesce = true) {
95
+ return this.replaceRangeWithSegments(start, end, text.length > 0 ? [
96
+ this.createTextSegment(text)
97
+ ] : [], coalesce);
98
+ }
99
+ /** Replace the text between two positions with new segments. */ replaceRangeWithSegments(start, end, insert, coalesce = true) {
100
+ start = this.clampPosition(start);
101
+ end = this.clampPosition(end);
102
+ let startSegment = this.segments[start.index];
103
+ let endSegment = this.segments[end.index];
104
+ let [startSplit] = this.splitSegment(startSegment, start.offset);
105
+ let [, endSplit] = this.splitSegment(endSegment, end.offset);
106
+ let newSegments = this.segments.slice(0, start.index);
107
+ if (startSplit) $4a46f1c4231e5dde$var$appendSegments(newSegments, [
108
+ startSplit
109
+ ]);
110
+ if (insert.length) $4a46f1c4231e5dde$var$appendSegments(newSegments, insert, (text)=>this.tokenize(text));
111
+ let lastSegment = newSegments[newSegments.length - 1];
112
+ let lastIsText = lastSegment && lastSegment.type === 'text';
113
+ let caret = {
114
+ index: lastIsText ? newSegments.length - 1 : newSegments.length,
115
+ offset: lastIsText ? lastSegment.text.length : 0
116
+ };
117
+ if (endSplit) $4a46f1c4231e5dde$var$appendSegments(newSegments, [
118
+ endSplit
119
+ ]);
120
+ $4a46f1c4231e5dde$var$appendSegments(newSegments, this.segments.slice(end.index + 1));
121
+ let segments = this.createFieldValue(newSegments);
122
+ segments.caretPosition = caret;
123
+ segments.isCoalescing = coalesce;
124
+ if (this.isCoalescing && coalesce && this.previous) {
125
+ segments.previous = this.previous;
126
+ segments.previous.next = segments;
127
+ } else {
128
+ segments.previous = this;
129
+ this.caretPosition = end;
130
+ this.next = segments;
131
+ }
132
+ return segments;
133
+ }
134
+ /** Find the boundary before or after a position using an Intl.Segmenter. */ findBoundaryWithSegmenter(position, segmenter, direction) {
135
+ position = this.clampPosition(position);
136
+ for(let i = position.index; i >= 0 && i < this.segments.length; i += direction){
137
+ let segment = this.segments[i];
138
+ switch(segment.type){
139
+ case 'token':
140
+ if (i !== position.index || (direction === -1 ? position.offset > 0 : position.offset === 0)) {
141
+ let index = i + direction;
142
+ return {
143
+ index: index >= 0 ? index : 0,
144
+ offset: direction === -1 && index >= 0 ? this.segments[index].text.length : 0
145
+ };
146
+ }
147
+ continue;
148
+ case 'text':
149
+ {
150
+ let offset = direction === -1 ? segment.text.length : 0;
151
+ if (i === position.index) offset = position.offset;
152
+ if (direction === -1) offset--;
153
+ if (offset < 0 || offset >= segment.text.length) continue;
154
+ let part = segmenter.segment(segment.text).containing(offset);
155
+ while(part && part.isWordLike === false){
156
+ offset += direction;
157
+ part = segmenter.segment(segment.text).containing(offset);
158
+ }
159
+ if (part) return {
160
+ index: i,
161
+ offset: direction === -1 ? part.index : part.index + part.segment.length
162
+ };
163
+ continue;
164
+ }
165
+ }
166
+ }
167
+ return null;
168
+ }
169
+ /** Find a line boundary before or after a position. */ findLineBoundary(position, direction) {
170
+ let res = this.findText(position, direction, '\n');
171
+ if (res) return res;
172
+ return direction === -1 ? {
173
+ index: 0,
174
+ offset: 0
175
+ } : {
176
+ index: this.segments.length - 1,
177
+ offset: this.segments[this.segments.length - 1].text.length
178
+ };
179
+ }
180
+ /** Find a string or regular expression match before or after a position. */ findText(position, direction, search) {
181
+ if (this.segments.length === 0) return null;
182
+ for(let i = position.index; i >= 0 && i < this.segments.length; i += direction){
183
+ let segment = this.segments[i];
184
+ if (segment.type !== 'text') continue;
185
+ let offset = $4a46f1c4231e5dde$var$findInText(segment.text, search, direction, i === position.index ? position.offset : undefined);
186
+ if (offset >= 0) return {
187
+ index: i,
188
+ offset: offset
189
+ };
190
+ }
191
+ return null;
192
+ }
193
+ /** Delete text at a position using a segmenter. */ delete(position, segmenter, direction, coalesce = true) {
194
+ let boundary = this.findBoundaryWithSegmenter(position, segmenter, direction);
195
+ if (boundary) return this.replaceRange(direction === -1 ? boundary : position, direction === -1 ? position : boundary, '', coalesce);
196
+ this.caretPosition = position;
197
+ return this;
198
+ }
199
+ /** Delete text to the next or previous line break. */ deleteLine(position, direction, coalesce = true) {
200
+ if (this.segments.length === 0) return this;
201
+ let boundary = this.findLineBoundary(position, direction);
202
+ if (boundary) return this.replaceRange(direction === -1 ? boundary : position, direction === -1 ? position : boundary, '', coalesce);
203
+ return this;
204
+ }
205
+ /** Create a new list containing a subset of the segments. */ slice(start, end) {
206
+ start = this.clampPosition(start);
207
+ end = this.clampPosition(end);
208
+ if (start.index === end.index && start.offset === end.offset) return this.createFieldValue([]);
209
+ if (start.index === end.index) {
210
+ let segment = this.segments[start.index];
211
+ if (segment.type === 'text') return this.createFieldValue([
212
+ {
213
+ type: 'text',
214
+ text: segment.text.slice(start.offset, end.offset)
215
+ }
216
+ ]);
217
+ return this.createFieldValue([
218
+ segment
219
+ ]);
220
+ }
221
+ let startSegment = this.segments[start.index];
222
+ let endSegment = this.segments[end.index];
223
+ let [, startSplit] = this.splitSegment(startSegment, start.offset);
224
+ let [endSplit] = this.splitSegment(endSegment, end.offset);
225
+ let result = [];
226
+ if (startSplit) result.push(startSplit);
227
+ result.push(...this.segments.slice(start.index + 1, end.index));
228
+ if (endSplit) result.push(endSplit);
229
+ return this.createFieldValue(result);
230
+ }
231
+ /** Convert the list to a string. */ toString() {
232
+ return this.segments.map((seg)=>seg.text).join('');
233
+ }
234
+ /** Returns the previous list in the undo history. */ undo() {
235
+ return this.previous ?? this;
236
+ }
237
+ /** Returns the next list in the redo history. */ redo() {
238
+ return this.next ?? this;
239
+ }
240
+ /** End coalescing undo/redo history. */ endCoalescing() {
241
+ this.isCoalescing = false;
242
+ }
243
+ }
244
+ function $4a46f1c4231e5dde$var$findInText(text, search, direction, fromOffset) {
245
+ if (typeof search === 'string') {
246
+ if (direction === -1) return text.lastIndexOf(search, fromOffset !== undefined ? fromOffset - 1 : text.length - 1);
247
+ return text.indexOf(search, fromOffset ?? 0);
248
+ }
249
+ if (direction === 1) {
250
+ let start = fromOffset ?? 0;
251
+ let index = text.slice(start).search(search);
252
+ return index >= 0 ? start + index : -1;
253
+ }
254
+ let limit = fromOffset !== undefined ? fromOffset : text.length;
255
+ if (limit < 0) return -1;
256
+ let re = search.flags.includes('g') ? search : new RegExp(search.source, search.flags + 'g');
257
+ let matches = Array.from(text.slice(0, limit).matchAll(re));
258
+ return matches.at(-1)?.index ?? -1;
259
+ }
260
+ function $4a46f1c4231e5dde$var$appendSegments(segments, insert, tokenize) {
261
+ for (let segment of insert){
262
+ if (segment.type === 'text' && segment.text.length === 0) continue;
263
+ let last = segments[segments.length - 1];
264
+ if (last && last.type === 'text' && segment.type === 'text') {
265
+ if (tokenize) {
266
+ let tokenized = tokenize(last.text + segment.text);
267
+ segments.splice(segments.length - 1, 1, ...tokenized);
268
+ } else segments[segments.length - 1] = {
269
+ type: 'text',
270
+ text: last.text + segment.text
271
+ };
272
+ } else if (tokenize && segment.type === 'text') {
273
+ let tokenized = tokenize(segment.text);
274
+ segments.push(...tokenized);
275
+ } else segments.push(segment);
276
+ }
277
+ return segments;
278
+ }
279
+
280
+
281
+ export {$4a46f1c4231e5dde$export$f3decd0c2cd2fe2e as TokenFieldValue};
282
+ //# sourceMappingURL=TokenFieldValue.mjs.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA;;;;;;;;;;CAUC,GAuBD,IAAA,AAAK,yDAAA;;;WAAA;EAAA;AAYE,MAAM;;aACK,YAAY;;IAW5B,+CAA+C,GAC/C,YAAY,MAAuC,EAAE,OAAgC,CAAE;QARv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,OACE,QAAQ,CAAC,SAAS,MAAM,GAAG,EAAE,GAAG;gBAAC,MAAM;gBAAQ,MAAM,KAAK,IAAI,GAAG,QAAQ,IAAI;YAAA;eAE1E,IAAI,YAAY,QAAQ,IAAI,KAAK,QAAQ;YAC9C,IAAI,YAAY,SAAS,QAAQ,IAAI;YACrC,SAAS,IAAI,IAAI;QACnB,OACE,SAAS,IAAI,CAAC;IAElB;IACA,OAAO;AACT","sources":["packages/react-stately/src/tokenfield/TokenFieldValue.ts"],"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\nexport type TokenFieldSegment<T = any> = TextSegment | TokenSegment<T>;\n\nexport interface TextSegment {\n type: 'text';\n text: string;\n}\n\nexport interface TokenSegment<T = any> {\n type: 'token';\n text: string;\n /** An arbitrary value associated with the token. */\n value?: T;\n}\n\nexport interface Position {\n /** Index of the segment in the list. */\n index: number;\n /** Text offset within the segment in UTF-16 code units. */\n offset: number;\n}\n\nenum Direction {\n Forward = 1,\n Backward = -1\n}\n\nexport interface TokenFieldValueOptions {\n caretPosition?: Position | null;\n}\n\n/**\n * A list of segments containing editable text and non-editable tokens.\n */\nexport class TokenFieldValue<T = any> {\n static readonly Direction = Direction;\n\n /** The text and token segments in the list. */\n readonly segments: readonly TokenFieldSegment<T>[];\n /** The caret position. */\n caretPosition: Position = {index: 0, offset: 0};\n // Linked list representing the undo/redo history.\n private previous: this | null = null;\n private next: this | null = null;\n private isCoalescing = true;\n\n /** Create a new list with the given segments. */\n constructor(tokens: readonly TokenFieldSegment<T>[], options?: TokenFieldValueOptions) {\n this.segments = tokens;\n this.caretPosition = options?.caretPosition ?? {index: 0, offset: 0};\n }\n\n protected createFieldValue(segments: readonly TokenFieldSegment<T>[]): this {\n const Constructor = this.constructor as new (\n segments: readonly TokenFieldSegment<T>[],\n options?: TokenFieldValueOptions\n ) => this;\n return new Constructor(segments);\n }\n\n /** Create a new list with the caret position set to the given position. */\n withCaretPosition(caretPosition: Position): this {\n if (\n this.caretPosition.index === caretPosition.index &&\n this.caretPosition.offset === caretPosition.offset\n ) {\n return this;\n }\n\n let result = this.createFieldValue(this.segments);\n result.caretPosition = caretPosition;\n result.previous = this.previous;\n result.next = this.next;\n result.isCoalescing = this.isCoalescing;\n return result;\n }\n\n private splitSegment(\n segment: TokenFieldSegment | undefined,\n offset: number\n ): [TokenFieldSegment | null, TokenFieldSegment | null] {\n if (!segment) {\n let empty = this.createTextSegment('');\n return [offset > 0 ? empty : null, offset > 0 ? null : empty];\n }\n\n if (segment.type === 'token') {\n return [offset > 0 ? {...segment} : null, offset > 0 ? null : {...segment}];\n }\n\n return [\n offset > 0 ? {type: 'text', text: segment.text.slice(0, offset)} : null,\n offset < segment.text.length ? this.createTextSegment(segment.text.slice(offset)) : null\n ];\n }\n\n private createTextSegment(text: string): TextSegment {\n return {type: 'text', text};\n }\n\n protected tokenize(text: string): TokenFieldSegment<T>[] {\n return [this.createTextSegment(text)];\n }\n\n private clampPosition(position: Position): Position {\n if (this.segments.length > 0 && position.index >= this.segments.length) {\n return {\n index: this.segments.length - 1,\n offset: this.segments[this.segments.length - 1].text.length\n };\n }\n\n if (position.index < 0) {\n return {index: 0, offset: 0};\n }\n return position;\n }\n\n /** Replace the text between two positions with new text. */\n replaceRange(start: Position, end: Position, text: string, coalesce = true): this {\n return this.replaceRangeWithSegments(\n start,\n end,\n text.length > 0 ? [this.createTextSegment(text)] : [],\n coalesce\n );\n }\n\n /** Replace the text between two positions with new segments. */\n replaceRangeWithSegments(\n start: Position,\n end: Position,\n insert: TokenFieldSegment<T>[],\n coalesce = true\n ): this {\n start = this.clampPosition(start);\n end = this.clampPosition(end);\n let startSegment = this.segments[start.index];\n let endSegment = this.segments[end.index];\n let [startSplit] = this.splitSegment(startSegment, start.offset);\n let [, endSplit] = this.splitSegment(endSegment, end.offset);\n\n let newSegments = this.segments.slice(0, start.index);\n if (startSplit) {\n appendSegments(newSegments, [startSplit]);\n }\n\n if (insert.length) {\n appendSegments(newSegments, insert, text => this.tokenize(text));\n }\n\n let lastSegment = newSegments[newSegments.length - 1];\n let lastIsText = lastSegment && lastSegment.type === 'text';\n let caret = {\n index: lastIsText ? newSegments.length - 1 : newSegments.length,\n offset: lastIsText ? lastSegment.text.length : 0\n };\n\n if (endSplit) {\n appendSegments(newSegments, [endSplit]);\n }\n\n appendSegments(newSegments, this.segments.slice(end.index + 1));\n\n let segments = this.createFieldValue(newSegments);\n segments.caretPosition = caret;\n segments.isCoalescing = coalesce;\n if (this.isCoalescing && coalesce && this.previous) {\n segments.previous = this.previous;\n segments.previous.next = segments;\n } else {\n segments.previous = this;\n this.caretPosition = end;\n this.next = segments;\n }\n return segments;\n }\n\n /** Find the boundary before or after a position using an Intl.Segmenter. */\n findBoundaryWithSegmenter(\n position: Position,\n segmenter: Intl.Segmenter,\n direction: Direction\n ): Position | null {\n position = this.clampPosition(position);\n for (let i = position.index; i >= 0 && i < this.segments.length; i += direction) {\n let segment = this.segments[i];\n switch (segment.type) {\n case 'token':\n if (\n i !== position.index ||\n (direction === Direction.Backward ? position.offset > 0 : position.offset === 0)\n ) {\n let index = i + direction;\n return {\n index: index >= 0 ? index : 0,\n offset:\n direction === Direction.Backward && index >= 0\n ? this.segments[index].text.length\n : 0\n };\n }\n continue;\n case 'text': {\n let offset = direction === Direction.Backward ? segment.text.length : 0;\n if (i === position.index) {\n offset = position.offset;\n }\n if (direction === Direction.Backward) {\n offset--;\n }\n if (offset < 0 || offset >= segment.text.length) {\n continue;\n }\n\n let part = segmenter.segment(segment.text).containing(offset);\n while (part && part.isWordLike === false) {\n offset += direction;\n part = segmenter.segment(segment.text).containing(offset);\n }\n\n if (part) {\n return {\n index: i,\n offset:\n direction === Direction.Backward ? part.index : part.index + part.segment.length\n };\n }\n continue;\n }\n }\n }\n\n return null;\n }\n\n /** Find a line boundary before or after a position. */\n findLineBoundary(position: Position, direction: Direction): Position | null {\n let res = this.findText(position, direction, '\\n');\n if (res) {\n return res;\n }\n return direction === Direction.Backward\n ? {index: 0, offset: 0}\n : {\n index: this.segments.length - 1,\n offset: this.segments[this.segments.length - 1].text.length\n };\n }\n\n /** Find a string or regular expression match before or after a position. */\n findText(position: Position, direction: Direction, search: string | RegExp): Position | null {\n if (this.segments.length === 0) {\n return null;\n }\n\n for (let i = position.index; i >= 0 && i < this.segments.length; i += direction) {\n let segment = this.segments[i];\n if (segment.type !== 'text') {\n continue;\n }\n let offset = findInText(\n segment.text,\n search,\n direction,\n i === position.index ? position.offset : undefined\n );\n if (offset >= 0) {\n return {\n index: i,\n offset: offset\n };\n }\n }\n\n return null;\n }\n\n /** Delete text at a position using a segmenter. */\n delete(\n position: Position,\n segmenter: Intl.Segmenter,\n direction: Direction,\n coalesce = true\n ): this {\n let boundary = this.findBoundaryWithSegmenter(position, segmenter, direction);\n if (boundary) {\n return this.replaceRange(\n direction === Direction.Backward ? boundary : position,\n direction === Direction.Backward ? position : boundary,\n '',\n coalesce\n );\n }\n\n this.caretPosition = position;\n return this;\n }\n\n /** Delete text to the next or previous line break. */\n deleteLine(position: Position, direction: Direction, coalesce = true): this {\n if (this.segments.length === 0) {\n return this;\n }\n\n let boundary = this.findLineBoundary(position, direction);\n if (boundary) {\n return this.replaceRange(\n direction === Direction.Backward ? boundary : position,\n direction === Direction.Backward ? position : boundary,\n '',\n coalesce\n );\n }\n\n return this;\n }\n\n /** Create a new list containing a subset of the segments. */\n slice(start: Position, end: Position): this {\n start = this.clampPosition(start);\n end = this.clampPosition(end);\n if (start.index === end.index && start.offset === end.offset) {\n return this.createFieldValue([]);\n }\n if (start.index === end.index) {\n let segment = this.segments[start.index];\n if (segment.type === 'text') {\n return this.createFieldValue([\n {type: 'text', text: segment.text.slice(start.offset, end.offset)}\n ]);\n }\n return this.createFieldValue([segment]);\n }\n let startSegment = this.segments[start.index];\n let endSegment = this.segments[end.index];\n let [, startSplit] = this.splitSegment(startSegment, start.offset);\n let [endSplit] = this.splitSegment(endSegment, end.offset);\n\n let result: TokenFieldSegment<T>[] = [];\n if (startSplit) {\n result.push(startSplit);\n }\n result.push(...this.segments.slice(start.index + 1, end.index));\n if (endSplit) {\n result.push(endSplit);\n }\n return this.createFieldValue(result);\n }\n\n /** Convert the list to a string. */\n toString(): string {\n return this.segments.map(seg => seg.text).join('');\n }\n\n /** Returns the previous list in the undo history. */\n undo(): this {\n return this.previous ?? this;\n }\n\n /** Returns the next list in the redo history. */\n redo(): this {\n return this.next ?? this;\n }\n\n /** End coalescing undo/redo history. */\n endCoalescing(): void {\n this.isCoalescing = false;\n }\n}\n\nfunction findInText(\n text: string,\n search: string | RegExp,\n direction: Direction,\n fromOffset?: number\n): number {\n if (typeof search === 'string') {\n if (direction === Direction.Backward) {\n return text.lastIndexOf(search, fromOffset !== undefined ? fromOffset - 1 : text.length - 1);\n }\n return text.indexOf(search, fromOffset ?? 0);\n }\n\n if (direction === Direction.Forward) {\n let start = fromOffset ?? 0;\n let index = text.slice(start).search(search);\n return index >= 0 ? start + index : -1;\n }\n\n let limit = fromOffset !== undefined ? fromOffset : text.length;\n if (limit < 0) {\n return -1;\n }\n\n let re = search.flags.includes('g') ? search : new RegExp(search.source, search.flags + 'g');\n let matches = Array.from(text.slice(0, limit).matchAll(re));\n return matches.at(-1)?.index ?? -1;\n}\n\nfunction appendSegments(\n segments: TokenFieldSegment[],\n insert: TokenFieldSegment[],\n tokenize?: (text: string) => TokenFieldSegment[]\n): TokenFieldSegment[] {\n for (let segment of insert) {\n if (segment.type === 'text' && segment.text.length === 0) {\n continue;\n }\n\n let last = segments[segments.length - 1];\n if (last && last.type === 'text' && segment.type === 'text') {\n if (tokenize) {\n let tokenized = tokenize(last.text + segment.text);\n segments.splice(segments.length - 1, 1, ...tokenized);\n } else {\n segments[segments.length - 1] = {type: 'text', text: last.text + segment.text};\n }\n } else if (tokenize && segment.type === 'text') {\n let tokenized = tokenize(segment.text);\n segments.push(...tokenized);\n } else {\n segments.push(segment);\n }\n }\n return segments;\n}\n"],"names":[],"version":3,"file":"TokenFieldValue.mjs.map"}
@@ -0,0 +1,37 @@
1
+ var $8b1d61ca9a986fd4$exports = require("./TokenFieldValue.cjs");
2
+ var $14cedf286405cc4b$exports = require("../utils/useControlledState.cjs");
3
+ var $bawsn$react = require("react");
4
+
5
+
6
+ function $parcel$export(e, n, v, s) {
7
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
+ }
9
+
10
+ $parcel$export(module.exports, "useTokenFieldState", function () { return $89e7d699d0a0abe4$export$f2f6e9a6aa7f62e7; });
11
+ /*
12
+ * Copyright 2026 Adobe. All rights reserved.
13
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
+ * you may not use this file except in compliance with the License. You may obtain a copy
15
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software distributed under
18
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
+ * OF ANY KIND, either express or implied. See the License for the specific language
20
+ * governing permissions and limitations under the License.
21
+ */
22
+
23
+
24
+ function $89e7d699d0a0abe4$export$f2f6e9a6aa7f62e7(props) {
25
+ let { value: valueProp, defaultValue: defaultValueProp = new (0, $8b1d61ca9a986fd4$exports.TokenFieldValue)([]), onChange: onChange } = props;
26
+ let [value, setValue] = (0, $14cedf286405cc4b$exports.useControlledState)(valueProp, defaultValueProp, onChange);
27
+ let [isComposing, setComposing] = (0, $bawsn$react.useState)(false);
28
+ return {
29
+ value: value,
30
+ setValue: setValue,
31
+ isComposing: isComposing,
32
+ setComposing: setComposing
33
+ };
34
+ }
35
+
36
+
37
+ //# sourceMappingURL=useTokenFieldState.cjs.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AA0BM,SAAS,0CACd,KAAyB;IAEzB,IAAI,EACF,OAAO,SAAS,EAChB,cAAc,mBAAmB,IAAI,CAAA,GAAA,yCAAc,EAAE,EAAE,CAAC,YACxD,QAAQ,EACT,GAAG;IAEJ,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,4CAAiB,EAAE,WAAkB,kBAAkB;IAC/E,IAAI,CAAC,aAAa,aAAa,GAAG,CAAA,GAAA,qBAAO,EAAE;IAE3C,OAAO;eACL;kBACA;qBACA;sBACA;IACF;AACF","sources":["packages/react-stately/src/tokenfield/useTokenFieldState.ts"],"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 {TokenFieldValue} from './TokenFieldValue';\nimport {useControlledState} from '../utils/useControlledState';\nimport {useState} from 'react';\nimport {ValueBase} from '@react-types/shared';\n\nexport interface TokenFieldProps<\n T extends TokenFieldValue = TokenFieldValue\n> extends ValueBase<T> {}\n\nexport interface TokenFieldState<T extends TokenFieldValue = TokenFieldValue> {\n /** The current value of the token field. */\n value: T;\n /** Sets the value of the token field. */\n setValue: (fn: T | ((value: T) => T)) => void;\n /** Whether the token field is composing. */\n isComposing: boolean;\n /** Sets the composing state of the token field. */\n setComposing: (isComposing: boolean) => void;\n}\n\n/**\n * Provides state management for a token field. Tracks the field value and the\n * composition state.\n */\nexport function useTokenFieldState<T extends TokenFieldValue = TokenFieldValue>(\n props: TokenFieldProps<T>\n): TokenFieldState<T> {\n let {\n value: valueProp,\n defaultValue: defaultValueProp = new TokenFieldValue([]),\n onChange\n } = props;\n\n let [value, setValue] = useControlledState(valueProp as any, defaultValueProp, onChange);\n let [isComposing, setComposing] = useState(false);\n\n return {\n value,\n setValue,\n isComposing,\n setComposing\n };\n}\n"],"names":[],"version":3,"file":"useTokenFieldState.cjs.map"}
@@ -0,0 +1,32 @@
1
+ import {TokenFieldValue as $bb130d0e51bd3001$export$f3decd0c2cd2fe2e} from "./TokenFieldValue.js";
2
+ import {useControlledState as $2a35a170cf8e413e$export$40bfa8c7b0832715} from "../utils/useControlledState.js";
3
+ import {useState as $3aXlP$useState} from "react";
4
+
5
+ /*
6
+ * Copyright 2026 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */
16
+
17
+
18
+ function $0cd81fae0bf3e1e8$export$f2f6e9a6aa7f62e7(props) {
19
+ let { value: valueProp, defaultValue: defaultValueProp = new (0, $bb130d0e51bd3001$export$f3decd0c2cd2fe2e)([]), onChange: onChange } = props;
20
+ let [value, setValue] = (0, $2a35a170cf8e413e$export$40bfa8c7b0832715)(valueProp, defaultValueProp, onChange);
21
+ let [isComposing, setComposing] = (0, $3aXlP$useState)(false);
22
+ return {
23
+ value: value,
24
+ setValue: setValue,
25
+ isComposing: isComposing,
26
+ setComposing: setComposing
27
+ };
28
+ }
29
+
30
+
31
+ export {$0cd81fae0bf3e1e8$export$f2f6e9a6aa7f62e7 as useTokenFieldState};
32
+ //# sourceMappingURL=useTokenFieldState.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AA0BM,SAAS,0CACd,KAAyB;IAEzB,IAAI,EACF,OAAO,SAAS,EAChB,cAAc,mBAAmB,IAAI,CAAA,GAAA,yCAAc,EAAE,EAAE,CAAC,YACxD,QAAQ,EACT,GAAG;IAEJ,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,yCAAiB,EAAE,WAAkB,kBAAkB;IAC/E,IAAI,CAAC,aAAa,aAAa,GAAG,CAAA,GAAA,eAAO,EAAE;IAE3C,OAAO;eACL;kBACA;qBACA;sBACA;IACF;AACF","sources":["packages/react-stately/src/tokenfield/useTokenFieldState.ts"],"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 {TokenFieldValue} from './TokenFieldValue';\nimport {useControlledState} from '../utils/useControlledState';\nimport {useState} from 'react';\nimport {ValueBase} from '@react-types/shared';\n\nexport interface TokenFieldProps<\n T extends TokenFieldValue = TokenFieldValue\n> extends ValueBase<T> {}\n\nexport interface TokenFieldState<T extends TokenFieldValue = TokenFieldValue> {\n /** The current value of the token field. */\n value: T;\n /** Sets the value of the token field. */\n setValue: (fn: T | ((value: T) => T)) => void;\n /** Whether the token field is composing. */\n isComposing: boolean;\n /** Sets the composing state of the token field. */\n setComposing: (isComposing: boolean) => void;\n}\n\n/**\n * Provides state management for a token field. Tracks the field value and the\n * composition state.\n */\nexport function useTokenFieldState<T extends TokenFieldValue = TokenFieldValue>(\n props: TokenFieldProps<T>\n): TokenFieldState<T> {\n let {\n value: valueProp,\n defaultValue: defaultValueProp = new TokenFieldValue([]),\n onChange\n } = props;\n\n let [value, setValue] = useControlledState(valueProp as any, defaultValueProp, onChange);\n let [isComposing, setComposing] = useState(false);\n\n return {\n value,\n setValue,\n isComposing,\n setComposing\n };\n}\n"],"names":[],"version":3,"file":"useTokenFieldState.js.map"}
@@ -0,0 +1,32 @@
1
+ import {TokenFieldValue as $4a46f1c4231e5dde$export$f3decd0c2cd2fe2e} from "./TokenFieldValue.mjs";
2
+ import {useControlledState as $3e6197669829fe11$export$40bfa8c7b0832715} from "../utils/useControlledState.mjs";
3
+ import {useState as $360x8$useState} from "react";
4
+
5
+ /*
6
+ * Copyright 2026 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */
16
+
17
+
18
+ function $df69ee4de894ef40$export$f2f6e9a6aa7f62e7(props) {
19
+ let { value: valueProp, defaultValue: defaultValueProp = new (0, $4a46f1c4231e5dde$export$f3decd0c2cd2fe2e)([]), onChange: onChange } = props;
20
+ let [value, setValue] = (0, $3e6197669829fe11$export$40bfa8c7b0832715)(valueProp, defaultValueProp, onChange);
21
+ let [isComposing, setComposing] = (0, $360x8$useState)(false);
22
+ return {
23
+ value: value,
24
+ setValue: setValue,
25
+ isComposing: isComposing,
26
+ setComposing: setComposing
27
+ };
28
+ }
29
+
30
+
31
+ export {$df69ee4de894ef40$export$f2f6e9a6aa7f62e7 as useTokenFieldState};
32
+ //# sourceMappingURL=useTokenFieldState.mjs.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AA0BM,SAAS,0CACd,KAAyB;IAEzB,IAAI,EACF,OAAO,SAAS,EAChB,cAAc,mBAAmB,IAAI,CAAA,GAAA,yCAAc,EAAE,EAAE,CAAC,YACxD,QAAQ,EACT,GAAG;IAEJ,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,yCAAiB,EAAE,WAAkB,kBAAkB;IAC/E,IAAI,CAAC,aAAa,aAAa,GAAG,CAAA,GAAA,eAAO,EAAE;IAE3C,OAAO;eACL;kBACA;qBACA;sBACA;IACF;AACF","sources":["packages/react-stately/src/tokenfield/useTokenFieldState.ts"],"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 {TokenFieldValue} from './TokenFieldValue';\nimport {useControlledState} from '../utils/useControlledState';\nimport {useState} from 'react';\nimport {ValueBase} from '@react-types/shared';\n\nexport interface TokenFieldProps<\n T extends TokenFieldValue = TokenFieldValue\n> extends ValueBase<T> {}\n\nexport interface TokenFieldState<T extends TokenFieldValue = TokenFieldValue> {\n /** The current value of the token field. */\n value: T;\n /** Sets the value of the token field. */\n setValue: (fn: T | ((value: T) => T)) => void;\n /** Whether the token field is composing. */\n isComposing: boolean;\n /** Sets the composing state of the token field. */\n setComposing: (isComposing: boolean) => void;\n}\n\n/**\n * Provides state management for a token field. Tracks the field value and the\n * composition state.\n */\nexport function useTokenFieldState<T extends TokenFieldValue = TokenFieldValue>(\n props: TokenFieldProps<T>\n): TokenFieldState<T> {\n let {\n value: valueProp,\n defaultValue: defaultValueProp = new TokenFieldValue([]),\n onChange\n } = props;\n\n let [value, setValue] = useControlledState(valueProp as any, defaultValueProp, onChange);\n let [isComposing, setComposing] = useState(false);\n\n return {\n value,\n setValue,\n isComposing,\n setComposing\n };\n}\n"],"names":[],"version":3,"file":"useTokenFieldState.mjs.map"}
@@ -29,6 +29,9 @@ let $aa006296c94ee187$var$globalCooldownTimeout = null;
29
29
  function $aa006296c94ee187$export$4d40659c25ecb50b(props = {}) {
30
30
  let { delay: delay = $aa006296c94ee187$var$TOOLTIP_DELAY, closeDelay: closeDelay = $aa006296c94ee187$var$TOOLTIP_COOLDOWN } = props;
31
31
  let { isOpen: isOpen, open: open, close: close } = (0, $a359060d53fd4d72$exports.useOverlayTriggerState)(props);
32
+ // Whether the current open/close transition should skip its animation. Set when swapping
33
+ // between tooltips during the global warmup period.
34
+ let [shouldSkipAnimation, setIsInstant] = (0, $4ZRdi$react.useState)(false);
32
35
  let id = (0, $4ZRdi$react.useMemo)(()=>`${++$aa006296c94ee187$var$tooltipId}`, []);
33
36
  let closeTimeout = (0, $4ZRdi$react.useRef)(null);
34
37
  let closeCallback = (0, $4ZRdi$react.useRef)(close);
@@ -37,15 +40,18 @@ function $aa006296c94ee187$export$4d40659c25ecb50b(props = {}) {
37
40
  };
38
41
  let closeOpenTooltips = ()=>{
39
42
  for(let hideTooltipId in $aa006296c94ee187$var$tooltips)if (hideTooltipId !== id) {
40
- $aa006296c94ee187$var$tooltips[hideTooltipId](true);
43
+ // Close other open tooltips instantly (no exit animation), since they are being
44
+ // replaced by this one during the warmup period.
45
+ $aa006296c94ee187$var$tooltips[hideTooltipId](true, true);
41
46
  delete $aa006296c94ee187$var$tooltips[hideTooltipId];
42
47
  }
43
48
  };
44
- let showTooltip = ()=>{
49
+ let showTooltip = (instant)=>{
45
50
  if (closeTimeout.current) clearTimeout(closeTimeout.current);
46
51
  closeTimeout.current = null;
47
52
  closeOpenTooltips();
48
53
  ensureTooltipEntry();
54
+ setIsInstant(!!instant);
49
55
  $aa006296c94ee187$var$globalWarmedUp = true;
50
56
  open();
51
57
  if ($aa006296c94ee187$var$globalWarmUpTimeout) {
@@ -57,7 +63,8 @@ function $aa006296c94ee187$export$4d40659c25ecb50b(props = {}) {
57
63
  $aa006296c94ee187$var$globalCooldownTimeout = null;
58
64
  }
59
65
  };
60
- let hideTooltip = (immediate)=>{
66
+ let hideTooltip = (immediate, instant)=>{
67
+ setIsInstant(!!instant);
61
68
  if (immediate || closeDelay <= 0) {
62
69
  if (closeTimeout.current) clearTimeout(closeTimeout.current);
63
70
  closeTimeout.current = null;
@@ -87,9 +94,11 @@ function $aa006296c94ee187$export$4d40659c25ecb50b(props = {}) {
87
94
  $aa006296c94ee187$var$globalWarmUpTimeout = setTimeout(()=>{
88
95
  $aa006296c94ee187$var$globalWarmUpTimeout = null;
89
96
  $aa006296c94ee187$var$globalWarmedUp = true;
90
- showTooltip();
97
+ // First tooltip in a sequence: animate in.
98
+ showTooltip(false);
91
99
  }, delay);
92
- } else if (!isOpen) showTooltip();
100
+ } else if (!isOpen) // Already warmed up: appear instantly without an animation.
101
+ showTooltip(true);
93
102
  };
94
103
  (0, $4ZRdi$react.useEffect)(()=>{
95
104
  closeCallback.current = close;
@@ -107,9 +116,12 @@ function $aa006296c94ee187$export$4d40659c25ecb50b(props = {}) {
107
116
  ]);
108
117
  return {
109
118
  isOpen: isOpen,
119
+ shouldSkipAnimation: shouldSkipAnimation,
110
120
  open: (immediate)=>{
111
121
  if (!immediate && delay > 0 && !closeTimeout.current) warmupTooltip();
112
- else showTooltip();
122
+ else // Immediate opens (e.g. focus, or delay of 0) appear instantly without an animation
123
+ // only if another tooltip is already warmed up.
124
+ showTooltip($aa006296c94ee187$var$globalWarmedUp);
113
125
  },
114
126
  close: hideTooltip
115
127
  };
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AA0CD,MAAM,sCAAgB,MAAM,yDAAyD;AACrF,MAAM,yCAAmB;AAezB,IAAI,iCAAW,CAAC;AAChB,IAAI,kCAAY;AAChB,IAAI,uCAAiB;AACrB,IAAI,4CAA4D;AAChE,IAAI,8CAA8D;AAO3D,SAAS,0CAAuB,QA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K,GAAG,CAAC,wCAAkB;QAE/B;IACF;IAEA,IAAI,gBAAgB;QAClB;QACA;QACA,IAAI,CAAC,UAAU,CAAC,sCAAgB;YAC9B,IAAI,2CACF,aAAa;YAGf,4CAAsB,WAAW;gBAC/B,4CAAsB;gBACtB,uCAAiB;gBACjB;YACF,GAAG;QACL,OAAO,IAAI,CAAC,QACV;IAEJ;IAEA,CAAA,GAAA,sBAAQ,EAAE;QACR,cAAc,OAAO,GAAG;IAC1B,GAAG;QAAC;KAAM;IAEV,CAAA,GAAA,sBAAQ,EAAE;QACR,OAAO;YACL,IAAI,aAAa,OAAO,EACtB,aAAa,aAAa,OAAO;YAEnC,IAAI,UAAU,8BAAQ,CAAC,GAAG;YAC1B,IAAI,SACF,OAAO,8BAAQ,CAAC,GAAG;QAEvB;IACF,GAAG;QAAC;KAAG;IAEP,OAAO;gBACL;QACA,MAAM,CAAA;YACJ,IAAI,CAAC,aAAa,QAAQ,KAAK,CAAC,aAAa,OAAO,EAClD;iBAEA;QAEJ;QACA,OAAO;IACT;AACF","sources":["packages/react-stately/src/tooltip/useTooltipTriggerState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {OverlayTriggerProps, useOverlayTriggerState} from '../overlays/useOverlayTriggerState';\nimport {useEffect, useMemo, useRef} from 'react';\n\nexport interface TooltipTriggerProps extends OverlayTriggerProps {\n /**\n * Whether the tooltip should be disabled, independent from the trigger.\n */\n isDisabled?: boolean;\n\n /**\n * The delay time for the tooltip to show up. [See\n * guidelines](https://spectrum.adobe.com/page/tooltip/#Immediate-or-delayed-appearance).\n *\n * @default 1500\n */\n delay?: number;\n\n /**\n * The delay time for the tooltip to close. [See\n * guidelines](https://spectrum.adobe.com/page/tooltip/#Warmup-and-cooldown).\n *\n * @default 500\n */\n closeDelay?: number;\n\n /**\n * By default, opens for both focus and hover. Can be made to open only for focus.\n *\n * @default 'hover'\n */\n trigger?: 'hover' | 'focus';\n\n /**\n * Whether the tooltip should close when the trigger is pressed.\n *\n * @default true\n */\n shouldCloseOnPress?: boolean;\n}\n\nconst TOOLTIP_DELAY = 1500; // this seems to be a 1.5 second delay, check with design\nconst TOOLTIP_COOLDOWN = 500;\n\nexport interface TooltipTriggerState {\n /** Whether the tooltip is currently showing. */\n isOpen: boolean;\n /**\n * Shows the tooltip. By default, the tooltip becomes visible after a delay\n * depending on a global warmup timer. The `immediate` option shows the\n * tooltip immediately instead.\n */\n open(immediate?: boolean): void;\n /** Hides the tooltip. */\n close(immediate?: boolean): void;\n}\n\nlet tooltips = {};\nlet tooltipId = 0;\nlet globalWarmedUp = false;\nlet globalWarmUpTimeout: ReturnType<typeof setTimeout> | null = null;\nlet globalCooldownTimeout: ReturnType<typeof setTimeout> | null = null;\n\n/**\n * Manages state for a tooltip trigger. Tracks whether the tooltip is open, and provides\n * methods to toggle this state. Ensures only one tooltip is open at a time and controls\n * the delay for showing a tooltip.\n */\nexport function useTooltipTriggerState(props: TooltipTriggerProps = {}): TooltipTriggerState {\n let {delay = TOOLTIP_DELAY, closeDelay = TOOLTIP_COOLDOWN} = props;\n let {isOpen, open, close} = useOverlayTriggerState(props);\n let id = useMemo(() => `${++tooltipId}`, []);\n let closeTimeout = useRef<ReturnType<typeof setTimeout> | null>(null);\n let closeCallback = useRef<() => void>(close);\n\n let ensureTooltipEntry = () => {\n tooltips[id] = hideTooltip;\n };\n\n let closeOpenTooltips = () => {\n for (let hideTooltipId in tooltips) {\n if (hideTooltipId !== id) {\n tooltips[hideTooltipId](true);\n delete tooltips[hideTooltipId];\n }\n }\n };\n\n let showTooltip = () => {\n if (closeTimeout.current) {\n clearTimeout(closeTimeout.current);\n }\n closeTimeout.current = null;\n closeOpenTooltips();\n ensureTooltipEntry();\n globalWarmedUp = true;\n open();\n if (globalWarmUpTimeout) {\n clearTimeout(globalWarmUpTimeout);\n globalWarmUpTimeout = null;\n }\n if (globalCooldownTimeout) {\n clearTimeout(globalCooldownTimeout);\n globalCooldownTimeout = null;\n }\n };\n\n let hideTooltip = (immediate?: boolean) => {\n if (immediate || closeDelay <= 0) {\n if (closeTimeout.current) {\n clearTimeout(closeTimeout.current);\n }\n closeTimeout.current = null;\n closeCallback.current();\n } else if (!closeTimeout.current) {\n closeTimeout.current = setTimeout(() => {\n closeTimeout.current = null;\n closeCallback.current();\n }, closeDelay);\n }\n\n if (globalWarmUpTimeout) {\n clearTimeout(globalWarmUpTimeout);\n globalWarmUpTimeout = null;\n }\n if (globalWarmedUp) {\n if (globalCooldownTimeout) {\n clearTimeout(globalCooldownTimeout);\n }\n globalCooldownTimeout = setTimeout(\n () => {\n delete tooltips[id];\n globalCooldownTimeout = null;\n globalWarmedUp = false;\n },\n Math.max(TOOLTIP_COOLDOWN, closeDelay)\n );\n }\n };\n\n let warmupTooltip = () => {\n closeOpenTooltips();\n ensureTooltipEntry();\n if (!isOpen && !globalWarmedUp) {\n if (globalWarmUpTimeout) {\n clearTimeout(globalWarmUpTimeout);\n }\n\n globalWarmUpTimeout = setTimeout(() => {\n globalWarmUpTimeout = null;\n globalWarmedUp = true;\n showTooltip();\n }, delay);\n } else if (!isOpen) {\n showTooltip();\n }\n };\n\n useEffect(() => {\n closeCallback.current = close;\n }, [close]);\n\n useEffect(() => {\n return () => {\n if (closeTimeout.current) {\n clearTimeout(closeTimeout.current);\n }\n let tooltip = tooltips[id];\n if (tooltip) {\n delete tooltips[id];\n }\n };\n }, [id]);\n\n return {\n isOpen,\n open: immediate => {\n if (!immediate && delay > 0 && !closeTimeout.current) {\n warmupTooltip();\n } else {\n showTooltip();\n }\n },\n close: hideTooltip\n };\n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ltipTriggerState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {OverlayTriggerProps, useOverlayTriggerState} from '../overlays/useOverlayTriggerState';\nimport {useEffect, useMemo, useRef, useState} from 'react';\n\nexport interface TooltipTriggerProps extends OverlayTriggerProps {\n /**\n * Whether the tooltip should be disabled, independent from the trigger.\n */\n isDisabled?: boolean;\n\n /**\n * The delay time for the tooltip to show up. [See\n * guidelines](https://spectrum.adobe.com/page/tooltip/#Immediate-or-delayed-appearance).\n *\n * @default 1500\n */\n delay?: number;\n\n /**\n * The delay time for the tooltip to close. [See\n * guidelines](https://spectrum.adobe.com/page/tooltip/#Warmup-and-cooldown).\n *\n * @default 500\n */\n closeDelay?: number;\n\n /**\n * By default, opens for both focus and hover. Can be made to open only for focus.\n *\n * @default 'hover'\n */\n trigger?: 'hover' | 'focus';\n\n /**\n * Whether the tooltip should close when the trigger is pressed.\n *\n * @default true\n */\n shouldCloseOnPress?: boolean;\n}\n\nconst TOOLTIP_DELAY = 1500; // this seems to be a 1.5 second delay, check with design\nconst TOOLTIP_COOLDOWN = 500;\n\nexport interface TooltipTriggerState {\n /** Whether the tooltip is currently showing. */\n isOpen: boolean;\n /**\n * Whether the tooltip is being shown or hidden without an animation. This is true while the\n * global warmup timer is active, i.e. when quickly moving between tooltips.\n */\n shouldSkipAnimation: boolean;\n /**\n * Shows the tooltip. By default, the tooltip becomes visible after a delay\n * depending on a global warmup timer. The `immediate` option shows the\n * tooltip immediately instead.\n */\n open(immediate?: boolean): void;\n /** Hides the tooltip. */\n close(immediate?: boolean): void;\n}\n\nlet tooltips = {};\nlet tooltipId = 0;\nlet globalWarmedUp = false;\nlet globalWarmUpTimeout: ReturnType<typeof setTimeout> | null = null;\nlet globalCooldownTimeout: ReturnType<typeof setTimeout> | null = null;\n\n/**\n * Manages state for a tooltip trigger. Tracks whether the tooltip is open, and provides\n * methods to toggle this state. Ensures only one tooltip is open at a time and controls\n * the delay for showing a tooltip.\n */\nexport function useTooltipTriggerState(props: TooltipTriggerProps = {}): TooltipTriggerState {\n let {delay = TOOLTIP_DELAY, closeDelay = TOOLTIP_COOLDOWN} = props;\n let {isOpen, open, close} = useOverlayTriggerState(props);\n // Whether the current open/close transition should skip its animation. Set when swapping\n // between tooltips during the global warmup period.\n let [shouldSkipAnimation, setIsInstant] = useState(false);\n let id = useMemo(() => `${++tooltipId}`, []);\n let closeTimeout = useRef<ReturnType<typeof setTimeout> | null>(null);\n let closeCallback = useRef<() => void>(close);\n\n let ensureTooltipEntry = () => {\n tooltips[id] = hideTooltip;\n };\n\n let closeOpenTooltips = () => {\n for (let hideTooltipId in tooltips) {\n if (hideTooltipId !== id) {\n // Close other open tooltips instantly (no exit animation), since they are being\n // replaced by this one during the warmup period.\n tooltips[hideTooltipId](true, true);\n delete tooltips[hideTooltipId];\n }\n }\n };\n\n let showTooltip = (instant?: boolean) => {\n if (closeTimeout.current) {\n clearTimeout(closeTimeout.current);\n }\n closeTimeout.current = null;\n closeOpenTooltips();\n ensureTooltipEntry();\n setIsInstant(!!instant);\n globalWarmedUp = true;\n open();\n if (globalWarmUpTimeout) {\n clearTimeout(globalWarmUpTimeout);\n globalWarmUpTimeout = null;\n }\n if (globalCooldownTimeout) {\n clearTimeout(globalCooldownTimeout);\n globalCooldownTimeout = null;\n }\n };\n\n let hideTooltip = (immediate?: boolean, instant?: boolean) => {\n setIsInstant(!!instant);\n if (immediate || closeDelay <= 0) {\n if (closeTimeout.current) {\n clearTimeout(closeTimeout.current);\n }\n closeTimeout.current = null;\n closeCallback.current();\n } else if (!closeTimeout.current) {\n closeTimeout.current = setTimeout(() => {\n closeTimeout.current = null;\n closeCallback.current();\n }, closeDelay);\n }\n\n if (globalWarmUpTimeout) {\n clearTimeout(globalWarmUpTimeout);\n globalWarmUpTimeout = null;\n }\n if (globalWarmedUp) {\n if (globalCooldownTimeout) {\n clearTimeout(globalCooldownTimeout);\n }\n globalCooldownTimeout = setTimeout(\n () => {\n delete tooltips[id];\n globalCooldownTimeout = null;\n globalWarmedUp = false;\n },\n Math.max(TOOLTIP_COOLDOWN, closeDelay)\n );\n }\n };\n\n let warmupTooltip = () => {\n closeOpenTooltips();\n ensureTooltipEntry();\n if (!isOpen && !globalWarmedUp) {\n if (globalWarmUpTimeout) {\n clearTimeout(globalWarmUpTimeout);\n }\n\n globalWarmUpTimeout = setTimeout(() => {\n globalWarmUpTimeout = null;\n globalWarmedUp = true;\n // First tooltip in a sequence: animate in.\n showTooltip(false);\n }, delay);\n } else if (!isOpen) {\n // Already warmed up: appear instantly without an animation.\n showTooltip(true);\n }\n };\n\n useEffect(() => {\n closeCallback.current = close;\n }, [close]);\n\n useEffect(() => {\n return () => {\n if (closeTimeout.current) {\n clearTimeout(closeTimeout.current);\n }\n let tooltip = tooltips[id];\n if (tooltip) {\n delete tooltips[id];\n }\n };\n }, [id]);\n\n return {\n isOpen,\n shouldSkipAnimation,\n open: immediate => {\n if (!immediate && delay > 0 && !closeTimeout.current) {\n warmupTooltip();\n } else {\n // Immediate opens (e.g. focus, or delay of 0) appear instantly without an animation\n // only if another tooltip is already warmed up.\n showTooltip(globalWarmedUp);\n }\n },\n close: hideTooltip\n };\n}\n"],"names":[],"version":3,"file":"useTooltipTriggerState.cjs.map"}