react-stately 3.49.0 → 3.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/useTokenFieldState.cjs.map +1 -1
- package/dist/exports/useTokenFieldState.js.map +1 -1
- package/dist/exports/useTokenFieldState.mjs.map +1 -1
- package/dist/private/calendar/useCalendarState.cjs +2 -1
- package/dist/private/calendar/useCalendarState.cjs.map +1 -1
- package/dist/private/calendar/useCalendarState.js +3 -2
- package/dist/private/calendar/useCalendarState.js.map +1 -1
- package/dist/private/calendar/useCalendarState.mjs +3 -2
- package/dist/private/calendar/useCalendarState.mjs.map +1 -1
- package/dist/private/color/Color.cjs +5 -3
- package/dist/private/color/Color.cjs.map +1 -1
- package/dist/private/color/Color.js +5 -3
- package/dist/private/color/Color.js.map +1 -1
- package/dist/private/color/Color.mjs +5 -3
- package/dist/private/color/Color.mjs.map +1 -1
- package/dist/private/combobox/useComboBoxState.cjs +15 -1
- package/dist/private/combobox/useComboBoxState.cjs.map +1 -1
- package/dist/private/combobox/useComboBoxState.js +16 -2
- package/dist/private/combobox/useComboBoxState.js.map +1 -1
- package/dist/private/combobox/useComboBoxState.mjs +16 -2
- package/dist/private/combobox/useComboBoxState.mjs.map +1 -1
- package/dist/private/data/useTreeData.cjs +7 -2
- package/dist/private/data/useTreeData.cjs.map +1 -1
- package/dist/private/data/useTreeData.js +9 -2
- package/dist/private/data/useTreeData.js.map +1 -1
- package/dist/private/data/useTreeData.mjs +7 -2
- package/dist/private/data/useTreeData.mjs.map +1 -1
- package/dist/private/layout/ListLayout.cjs +4 -0
- package/dist/private/layout/ListLayout.cjs.map +1 -1
- package/dist/private/layout/ListLayout.js +4 -0
- package/dist/private/layout/ListLayout.js.map +1 -1
- package/dist/private/layout/ListLayout.mjs +4 -0
- package/dist/private/layout/ListLayout.mjs.map +1 -1
- package/dist/private/tokenfield/TokenFieldValue.cjs +45 -15
- package/dist/private/tokenfield/TokenFieldValue.cjs.map +1 -1
- package/dist/private/tokenfield/TokenFieldValue.js +45 -17
- package/dist/private/tokenfield/TokenFieldValue.js.map +1 -1
- package/dist/private/tokenfield/TokenFieldValue.mjs +46 -16
- package/dist/private/tokenfield/TokenFieldValue.mjs.map +1 -1
- package/dist/private/tooltip/useTooltipTriggerState.cjs.map +1 -1
- package/dist/private/tooltip/useTooltipTriggerState.js.map +1 -1
- package/dist/private/tooltip/useTooltipTriggerState.mjs.map +1 -1
- package/dist/private/utils/useControlledState.cjs +1 -1
- package/dist/private/utils/useControlledState.cjs.map +1 -1
- package/dist/private/utils/useControlledState.js +1 -1
- package/dist/private/utils/useControlledState.js.map +1 -1
- package/dist/private/utils/useControlledState.mjs +1 -1
- package/dist/private/utils/useControlledState.mjs.map +1 -1
- package/dist/types/exports/useTokenFieldState.d.ts +1 -1
- package/dist/types/src/collections/Item.d.ts +1 -6
- package/dist/types/src/collections/Section.d.ts +1 -6
- package/dist/types/src/table/Cell.d.ts +0 -5
- package/dist/types/src/table/Column.d.ts +0 -7
- package/dist/types/src/table/Row.d.ts +0 -6
- package/dist/types/src/table/TableBody.d.ts +1 -6
- package/dist/types/src/table/TableHeader.d.ts +1 -7
- package/dist/types/src/tokenfield/TokenFieldValue.d.ts +27 -4
- package/dist/types/src/tooltip/useTooltipTriggerState.d.ts +2 -2
- package/package.json +6 -5
|
@@ -1 +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;QARvF,wBAAwB,QACxB,gBAA0B;YAAC,OAAO;YAAG,QAAQ;QAAC;QAC9C,kDAAkD;aAC1C,WAAwB;aACxB,OAAoB;aACpB,eAAe;QAIrB,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,aAAa,GAAG,SAAS,iBAAiB;YAAC,OAAO;YAAG,QAAQ;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I,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":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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\n/** Represents a text selection in a TokenField. */\nexport class SelectedRange {\n /** The anchor position. */\n anchor: Position;\n /** The current (i.e. caret) position. */\n current: Position;\n\n /**\n * Creates a new selection range. If only a single position is provided, the selection is\n * collapsed.\n */\n constructor(anchor: Position, current: Position = anchor) {\n this.anchor = anchor;\n this.current = current;\n }\n\n /** Whether the selection is collapsed to a single caret position. */\n get isCollapsed() {\n return this.anchor.index === this.current.index && this.anchor.offset === this.current.offset;\n }\n\n /** The side of the selection closest to the start of the value. */\n get start() {\n return compare(this.anchor, this.current) < 0 ? this.anchor : this.current;\n }\n\n /** The side of the selection closest to the end of the value. */\n get end() {\n return compare(this.anchor, this.current) < 0 ? this.current : this.anchor;\n }\n\n /** Returns whether this selection is equal to another. */\n isEqual(other: SelectedRange) {\n if (this === other) {\n return true;\n }\n return (\n this.anchor.index === other.anchor.index &&\n this.anchor.offset === other.anchor.offset &&\n this.current.index === other.current.index &&\n this.current.offset === other.current.offset\n );\n }\n}\n\nfunction compare(a: Position, b: Position) {\n if (a.index === b.index) {\n return a.offset - b.offset;\n }\n\n return a.index - b.index;\n}\n\nenum Direction {\n Forward = 1,\n Backward = -1\n}\n\nexport interface TokenFieldValueOptions {\n selectedRange?: SelectedRange | 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 static readonly SelectedRange = SelectedRange;\n\n /** The text and token segments in the list. */\n readonly segments: readonly TokenFieldSegment<T>[];\n /** The selected range. */\n selectedRange: SelectedRange;\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.selectedRange = options?.selectedRange ?? new SelectedRange({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 get caretPosition(): Position {\n return this.selectedRange.current;\n }\n\n /** Create a new list with the caret position set to the given position. */\n withSelectedRange(selectedRange: SelectedRange): this {\n if (this.selectedRange.isEqual(selectedRange)) {\n return this;\n }\n\n let result = this.createFieldValue(this.segments);\n result.selectedRange = selectedRange;\n result.previous = this.previous;\n result.next = this.next;\n result.isCoalescing = this.isCoalescing;\n return result;\n }\n\n withCaretPosition(position: Position): this {\n return this.withSelectedRange(new SelectedRange(position));\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.selectedRange = new SelectedRange(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.selectedRange = new SelectedRange(start, 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 return this.withSelectedRange(new SelectedRange(position));\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.withSelectedRange(new SelectedRange(position));\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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AA0CD,MAAM,sCAAgB,MAAM,yDAAyD;AACrF,MAAM,yCAAmB;AAoBzB,IAAI,iCAAW,CAAC;AAChB,IAAI,kCAAY;AAChB,IAAI,uCAAiB;AACrB,IAAI,4CAA4D;AAChE,IAAI,8CAA8D;AAO3D,SAAS,0CAAuB,QAA6B,CAAC,CAAC;IACpE,IAAI,SAAC,QAAQ,iDAAe,aAAa,wCAAiB,GAAG;IAC7D,IAAI,UAAC,MAAM,QAAE,IAAI,SAAE,KAAK,EAAC,GAAG,CAAA,GAAA,gDAAqB,EAAE;IACnD,yFAAyF;IACzF,oDAAoD;IACpD,IAAI,CAAC,qBAAqB,aAAa,GAAG,CAAA,GAAA,qBAAO,EAAE;IACnD,IAAI,KAAK,CAAA,GAAA,oBAAM,EAAE,IAAM,GAAG,EAAE,iCAAW,EAAE,EAAE;IAC3C,IAAI,eAAe,CAAA,GAAA,mBAAK,EAAwC;IAChE,IAAI,gBAAgB,CAAA,GAAA,mBAAK,EAAc;IAEvC,IAAI,qBAAqB;QACvB,8BAAQ,CAAC,GAAG,GAAG;IACjB;IAEA,IAAI,oBAAoB;QACtB,IAAK,IAAI,iBAAiB,+BACxB,IAAI,kBAAkB,IAAI;YACxB,gFAAgF;YAChF,iDAAiD;YACjD,8BAAQ,CAAC,cAAc,CAAC,MAAM;YAC9B,OAAO,8BAAQ,CAAC,cAAc;QAChC;IAEJ;IAEA,IAAI,cAAc,CAAC;QACjB,IAAI,aAAa,OAAO,EACtB,aAAa,aAAa,OAAO;QAEnC,aAAa,OAAO,GAAG;QACvB;QACA;QACA,aAAa,CAAC,CAAC;QACf,uCAAiB;QACjB;QACA,IAAI,2CAAqB;YACvB,aAAa;YACb,4C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,oFAAoF;YACpF,gDAAgD;YAChD,YAAY;QAEhB;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, 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/
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AA0CD,MAAM,sCAAgB,MAAM,yDAAyD;AACrF,MAAM,yCAAmB;AAoBzB,IAAI,iCAAW,CAAC;AAChB,IAAI,kCAAY;AAChB,IAAI,uCAAiB;AACrB,IAAI,4CAA4D;AAChE,IAAI,8CAA8D;AAO3D,SAAS,0CAAuB,QAA6B,CAAC,CAAC;IACpE,IAAI,SAAC,QAAQ,iDAAe,aAAa,wCAAiB,GAAG;IAC7D,IAAI,UAAC,MAAM,QAAE,IAAI,SAAE,KAAK,EAAC,GAAG,CAAA,GAAA,gDAAqB,EAAE;IACnD,yFAAyF;IACzF,oDAAoD;IACpD,IAAI,CAAC,qBAAqB,aAAa,GAAG,CAAA,GAAA,qBAAO,EAAE;IACnD,IAAI,KAAK,CAAA,GAAA,oBAAM,EAAE,IAAM,GAAG,EAAE,iCAAW,EAAE,EAAE;IAC3C,IAAI,eAAe,CAA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gBACtB,uCAAiB;gBACjB,2CAA2C;gBAC3C,YAAY;YACd,GAAG;QACL,OAAO,IAAI,CAAC,QACV,4DAA4D;QAC5D,YAAY;IAEhB;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;6BACA;QACA,MAAM,CAAA;YACJ,IAAI,CAAC,aAAa,QAAQ,KAAK,CAAC,aAAa,OAAO,EAClD;iBAEA,oFAAoF;YACpF,gDAAgD;YAChD,YAAY;QAEhB;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, 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/web/rsp/components/tooltip#behaviors).\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/web/rsp/components/tooltip#behaviors).\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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AA0CD,MAAM,sCAAgB,MAAM,yDAAyD;AACrF,MAAM,yCAAmB;AAoBzB,IAAI,iCAAW,CAAC;AAChB,IAAI,kCAAY;AAChB,IAAI,uCAAiB;AACrB,IAAI,4CAA4D;AAChE,IAAI,8CAA8D;AAO3D,SAAS,0CAAuB,QAA6B,CAAC,CAAC;IACpE,IAAI,SAAC,QAAQ,iDAAe,aAAa,wCAAiB,GAAG;IAC7D,IAAI,UAAC,MAAM,QAAE,IAAI,SAAE,KAAK,EAAC,GAAG,CAAA,GAAA,yCAAqB,EAAE;IACnD,yFAAyF;IACzF,oDAAoD;IACpD,IAAI,CAAC,qBAAqB,aAAa,GAAG,CAAA,GAAA,eAAO,EAAE;IACnD,IAAI,KAAK,CAAA,GAAA,cAAM,EAAE,IAAM,GAAG,EAAE,iCAAW,EAAE,EAAE;IAC3C,IAAI,eAAe,CAAA,GAAA,aAAK,EAAwC;IAChE,IAAI,gBAAgB,CAAA,GAAA,aAAK,EAAc;IAEvC,IAAI,qBAAqB;QACvB,8BAAQ,CAAC,GAAG,GAAG;IACjB;IAEA,IAAI,oBAAoB;QACtB,IAAK,IAAI,iBAAiB,+BACxB,IAAI,kBAAkB,IAAI;YACxB,gFAAgF;YAChF,iDAAiD;YACjD,8BA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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;6BACA;QACA,MAAM,CAAA;YACJ,IAAI,CAAC,aAAa,QAAQ,KAAK,CAAC,aAAa,OAAO,EAClD;iBAEA,oFAAoF;YACpF,gDAAgD;YAChD,YAAY;QAEhB;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, 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/
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AA0CD,MAAM,sCAAgB,MAAM,yDAAyD;AACrF,MAAM,yCAAmB;AAoBzB,IAAI,iCAAW,CAAC;AAChB,IAAI,kCAAY;AAChB,IAAI,uCAAiB;AACrB,IAAI,4CAA4D;AAChE,IAAI,8CAA8D;AAO3D,SAAS,0CAAuB,QAA6B,CAAC,CAAC;IACpE,IAAI,SAAC,QAAQ,iDAAe,aAAa,wCAAiB,GAAG;IAC7D,IAAI,UAAC,MAAM,Q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B,WACtB;gBACE,OAAO,8BAAQ,CAAC,GAAG;gBACnB,8CAAwB;gBACxB,uCAAiB;YACnB,GACA,KAAK,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,2CAA2C;gBAC3C,YAAY;YACd,GAAG;QACL,OAAO,IAAI,CAAC,QACV,4DAA4D;QAC5D,YAAY;IAEhB;IAEA,CAAA,GAAA,gBAAQ,EAAE;QACR,cAAc,OAAO,GAAG;IAC1B,GAAG;QAAC;KAAM;IAEV,CAAA,GAAA,gBAAQ,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;6BACA;QACA,MAAM,CAAA;YACJ,IAAI,CAAC,aAAa,QAAQ,KAAK,CAAC,aAAa,OAAO,EAClD;iBAEA,oFAAoF;YACpF,gDAAgD;YAChD,YAAY;QAEhB;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, 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/web/rsp/components/tooltip#behaviors).\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/web/rsp/components/tooltip#behaviors).\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.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AA0CD,MAAM,sCAAgB,MAAM,yDAAyD;AACrF,MAAM,yCAAmB;AAoBzB,IAAI,iCAAW,CAAC;AAChB,IAAI,kCAAY;AAChB,IAAI,uCAAiB;AACrB,IAAI,4CAA4D;AAChE,IAAI,8CAA8D;AAO3D,SAAS,0CAAuB,QAA6B,CAAC,CAAC;IACpE,IAAI,SAAC,QAAQ,iDAAe,aAAa,wCAAiB,GAAG;IAC7D,IAAI,UAAC,MAAM,QAAE,IAAI,SAAE,KAAK,EAAC,GAAG,CAAA,GAAA,yCAAqB,EAAE;IACnD,yFAAyF;IACzF,oDAAoD;IACpD,IAAI,CAAC,qBAAqB,aAAa,GAAG,CAAA,GAAA,eAAO,EAAE;IACnD,IAAI,KAAK,CAAA,GAAA,cAAM,EAAE,IAAM,GAAG,EAAE,iCAAW,EAAE,EAAE;IAC3C,IAAI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4CAAsB;gBACtB,uCAAiB;gBACjB,2CAA2C;gBAC3C,YAAY;YACd,GAAG;QACL,OAAO,IAAI,CAAC,QACV,4DAA4D;QAC5D,YAAY;IAEhB;IAEA,CAAA,GAAA,gBAAQ,EAAE;QACR,cAAc,OAAO,GAAG;IAC1B,GAAG;QAAC;KAAM;IAEV,CAAA,GAAA,gBAAQ,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;6BACA;QACA,MAAM,CAAA;YACJ,IAAI,CAAC,aAAa,QAAQ,KAAK,CAAC,aAAa,OAAO,EAClD;iBAEA,oFAAoF;YACpF,gDAAgD;YAChD,YAAY;QAEhB;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, 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/
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AA0CD,MAAM,sCAAgB,MAAM,yDAAyD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AG;YACvB,cAAc,OAAO;QACvB,OAAO,IAAI,CAAC,aAAa,OAAO,EAC9B,aAAa,OAAO,GAAG,WAAW;YAChC,aAAa,OAAO,GAAG;YACvB,cAAc,OAAO;QACvB,GAAG;QAGL,IAAI,2CAAqB;YACvB,aAAa;YACb,4CAAsB;QACxB;QACA,IAAI,sCAAgB;YAClB,IAAI,6CACF,aAAa;YAEf,8CAAwB,WACtB;gBACE,OAAO,8BAAQ,CAAC,GAAG;gBACnB,8CAAwB;gBACxB,uCAAiB;YACnB,GACA,KAAK,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,2CAA2C;gBAC3C,YAAY;YACd,GAAG;QACL,OAAO,IAAI,CAAC,QACV,4DAA4D;QAC5D,YAAY;IAEhB;IAEA,CAAA,GAAA,gBAAQ,EAAE;QACR,cAAc,OAAO,GAAG;IAC1B,GAAG;QAAC;KAAM;IAEV,CAAA,GAAA,gBAAQ,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;6BACA;QACA,MAAM,CAAA;YACJ,IAAI,CAAC,aAAa,QAAQ,KAAK,CAAC,aAAa,OAAO,EAClD;iBAEA,oFAAoF;YACpF,gDAAgD;YAChD,YAAY;QAEhB;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, 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/web/rsp/components/tooltip#behaviors).\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/web/rsp/components/tooltip#behaviors).\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.mjs.map"}
|
|
@@ -22,7 +22,7 @@ $parcel$export(module.exports, "useControlledState", function () { return $14ced
|
|
|
22
22
|
* governing permissions and limitations under the License.
|
|
23
23
|
*/
|
|
24
24
|
// Use the earliest effect possible to reset the ref below.
|
|
25
|
-
const $14cedf286405cc4b$var$useEarlyEffect = typeof document !== 'undefined' ? (0, ($parcel$interopDefault($hngmi$react)))['useInsertionEffect'] ?? (0, ($parcel$interopDefault($hngmi$react))).useLayoutEffect : ()=>{};
|
|
25
|
+
const $14cedf286405cc4b$var$useEarlyEffect = typeof document !== 'undefined' || parseInt((0, ($parcel$interopDefault($hngmi$react))).version, 10) >= 19 ? (0, ($parcel$interopDefault($hngmi$react)))['useInsertionEffect'] ?? (0, ($parcel$interopDefault($hngmi$react))).useLayoutEffect : ()=>{};
|
|
26
26
|
function $14cedf286405cc4b$export$40bfa8c7b0832715(value, defaultValue, onChange) {
|
|
27
27
|
// Store the value in both state and a ref. The state value will only be used when uncontrolled.
|
|
28
28
|
// The ref is used to track the most current value, which is passed to the function setState callback.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAID,2DAA2D;AAC3D,MAAM,uCACJ,OAAO,aAAa,
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAID,2DAA2D;AAC3D,MAAM,uCACJ,OAAO,aAAa,eAAe,SAAS,CAAA,GAAA,sCAAI,EAAE,OAAO,EAAE,OAAO,KAC7D,CAAA,GAAA,sCAAI,CAAC,CAAC,qBAAqB,IAAI,CAAA,GAAA,sCAAI,EAAE,eAAe,GACrD,KAAO;AAYN,SAAS,0CACd,KAAQ,EACR,YAAe,EACf,QAAyC;IAEzC,gGAAgG;IAChG,sGAAsG;IACtG,IAAI,CAAC,YAAY,cAAc,GAAG,CAAA,GAAA,qBAAO,EAAE,SAAS;IACpD,IAAI,WAAW,CAAA,GAAA,mBAAK,EAAE;IAEtB,IAAI,kBAAkB,CAAA,GAAA,mBAAK,EAAE,UAAU;IACvC,IAAI,eAAe,UAAU;IAC7B,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,gBAAgB,gBAAgB,OAAO;QAC3C,IAAI,kBAAkB,gBAAgB,QAAQ,GAAG,CAAC,QAAQ,KAAK,cAC7D,QAAQ,IAAI,CACV,CAAC,+BAA+B,EAAE,gBAAgB,eAAe,eAAe,IAAI,EAAE,eAAe,eAAe,eAAe,CAAC,CAAC;QAGzI,gBAAgB,OAAO,GAAG;IAC5B,GAAG;QAAC;KAAa;IAEjB,0DAA0D;IAC1D,6DAA6D;IAC7D,4FAA4F;IAC5F,IAAI,eAAe,eAAe,QAAQ;IAC1C,qCAAe;QACb,SAAS,OAAO,GAAG;IACrB;IAEA,IAAI,GAAG,YAAY,GAAG,CAAA,GAAA,uBAAS,EAAE,IAAO,CAAA,CAAC,CAAA,GAAI,CAAC;IAC9C,IAAI,WAAW,CAAA,GAAA,wBAAU,EACvB,CAAC,OAA0B,GAAG;QAC5B,4DAA4D;QAC5D,IAAI,WAAW,OAAO,UAAU,aAAa,MAAM,SAAS,OAAO,IAAI;QACvE,IAAI,CAAC,OAAO,EAAE,CAAC,SAAS,OAAO,EAAE,WAAW;YAC1C,+EAA+E;YAC/E,SAAS,OAAO,GAAG;YAEnB,cAAc;YAEd,6GAA6G;YAC7G;YAEA,sFAAsF;YACtF,6DAA6D;YAC7D,WAAW,aAAa;QAC1B;IACF,GACA;QAAC;KAAS;IAGZ,OAAO;QAAC;QAAc;KAAS;AACjC","sources":["packages/react-stately/src/utils/useControlledState.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 React, {SetStateAction, useCallback, useEffect, useReducer, useRef, useState} from 'react';\n\n// Use the earliest effect possible to reset the ref below.\nconst useEarlyEffect: typeof React.useLayoutEffect =\n typeof document !== 'undefined' || parseInt(React.version, 10) >= 19\n ? (React['useInsertionEffect'] ?? React.useLayoutEffect)\n : () => {};\n\nexport function useControlledState<T, C = T>(\n value: Exclude<T, undefined>,\n defaultValue: Exclude<T, undefined> | undefined,\n onChange?: (v: C, ...args: any[]) => void\n): [T, (value: SetStateAction<T>, ...args: any[]) => void];\nexport function useControlledState<T, C = T>(\n value: Exclude<T, undefined> | undefined,\n defaultValue: Exclude<T, undefined>,\n onChange?: (v: C, ...args: any[]) => void\n): [T, (value: SetStateAction<T>, ...args: any[]) => void];\nexport function useControlledState<T, C = T>(\n value: T,\n defaultValue: T,\n onChange?: (v: C, ...args: any[]) => void\n): [T, (value: SetStateAction<T>, ...args: any[]) => void] {\n // Store the value in both state and a ref. The state value will only be used when uncontrolled.\n // The ref is used to track the most current value, which is passed to the function setState callback.\n let [stateValue, setStateValue] = useState(value || defaultValue);\n let valueRef = useRef(stateValue);\n\n let isControlledRef = useRef(value !== undefined);\n let isControlled = value !== undefined;\n useEffect(() => {\n let wasControlled = isControlledRef.current;\n if (wasControlled !== isControlled && process.env.NODE_ENV !== 'production') {\n console.warn(\n `WARN: A component changed from ${wasControlled ? 'controlled' : 'uncontrolled'} to ${isControlled ? 'controlled' : 'uncontrolled'}.`\n );\n }\n isControlledRef.current = isControlled;\n }, [isControlled]);\n\n // After each render, update the ref to the current value.\n // This ensures that the setState callback argument is reset.\n // Note: the effect should not have any dependencies so that controlled values always reset.\n let currentValue = isControlled ? value : stateValue;\n useEarlyEffect(() => {\n valueRef.current = currentValue;\n });\n\n let [, forceUpdate] = useReducer(() => ({}), {});\n let setValue = useCallback(\n (value: SetStateAction<T>, ...args: any[]) => {\n // @ts-ignore - TS doesn't know that T cannot be a function.\n let newValue = typeof value === 'function' ? value(valueRef.current) : value;\n if (!Object.is(valueRef.current, newValue)) {\n // Update the ref so that the next setState callback has the most recent value.\n valueRef.current = newValue;\n\n setStateValue(newValue);\n\n // Always trigger a re-render, even when controlled, so that the layout effect above runs to reset the value.\n forceUpdate();\n\n // Trigger onChange. Note that if setState is called multiple times in a single event,\n // onChange will be called for each one instead of only once.\n onChange?.(newValue, ...args);\n }\n },\n [onChange]\n );\n\n return [currentValue, setValue];\n}\n"],"names":[],"version":3,"file":"useControlledState.cjs.map"}
|
|
@@ -13,7 +13,7 @@ import $mLnuJ$react, {useState as $mLnuJ$useState, useRef as $mLnuJ$useRef, useE
|
|
|
13
13
|
*/
|
|
14
14
|
var $2a35a170cf8e413e$var$_React_useInsertionEffect;
|
|
15
15
|
// Use the earliest effect possible to reset the ref below.
|
|
16
|
-
const $2a35a170cf8e413e$var$useEarlyEffect = typeof document !== 'undefined' ? ($2a35a170cf8e413e$var$_React_useInsertionEffect = (0, $mLnuJ$react)['useInsertionEffect']) !== null && $2a35a170cf8e413e$var$_React_useInsertionEffect !== void 0 ? $2a35a170cf8e413e$var$_React_useInsertionEffect : (0, $mLnuJ$react).useLayoutEffect : ()=>{};
|
|
16
|
+
const $2a35a170cf8e413e$var$useEarlyEffect = typeof document !== 'undefined' || parseInt((0, $mLnuJ$react).version, 10) >= 19 ? ($2a35a170cf8e413e$var$_React_useInsertionEffect = (0, $mLnuJ$react)['useInsertionEffect']) !== null && $2a35a170cf8e413e$var$_React_useInsertionEffect !== void 0 ? $2a35a170cf8e413e$var$_React_useInsertionEffect : (0, $mLnuJ$react).useLayoutEffect : ()=>{};
|
|
17
17
|
function $2a35a170cf8e413e$export$40bfa8c7b0832715(value, defaultValue, onChange) {
|
|
18
18
|
// Store the value in both state and a ref. The state value will only be used when uncontrolled.
|
|
19
19
|
// The ref is used to track the most current value, which is passed to the function setState callback.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AAAA;;;;;;;;;;CAUC;IAOM;AAHP,2DAA2D;AAC3D,MAAM,uCACJ,OAAO,aAAa,
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC;IAOM;AAHP,2DAA2D;AAC3D,MAAM,uCACJ,OAAO,aAAa,eAAe,SAAS,CAAA,GAAA,YAAI,EAAE,OAAO,EAAE,OAAO,KAC7D,CAAA,kDAAA,CAAA,GAAA,YAAI,CAAC,CAAC,qBAAqB,cAA3B,6DAAA,kDAA+B,CAAA,GAAA,YAAI,EAAE,eAAe,GACrD,KAAO;AAYN,SAAS,0CAC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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 React, {SetStateAction, useCallback, useEffect, useReducer, useRef, useState} from 'react';\n\n// Use the earliest effect possible to reset the ref below.\nconst useEarlyEffect: typeof React.useLayoutEffect =\n typeof document !== 'undefined' || parseInt(React.version, 10) >= 19\n ? (React['useInsertionEffect'] ?? React.useLayoutEffect)\n : () => {};\n\nexport function useControlledState<T, C = T>(\n value: Exclude<T, undefined>,\n defaultValue: Exclude<T, undefined> | undefined,\n onChange?: (v: C, ...args: any[]) => void\n): [T, (value: SetStateAction<T>, ...args: any[]) => void];\nexport function useControlledState<T, C = T>(\n value: Exclude<T, undefined> | undefined,\n defaultValue: Exclude<T, undefined>,\n onChange?: (v: C, ...args: any[]) => void\n): [T, (value: SetStateAction<T>, ...args: any[]) => void];\nexport function useControlledState<T, C = T>(\n value: T,\n defaultValue: T,\n onChange?: (v: C, ...args: any[]) => void\n): [T, (value: SetStateAction<T>, ...args: any[]) => void] {\n // Store the value in both state and a ref. The state value will only be used when uncontrolled.\n // The ref is used to track the most current value, which is passed to the function setState callback.\n let [stateValue, setStateValue] = useState(value || defaultValue);\n let valueRef = useRef(stateValue);\n\n let isControlledRef = useRef(value !== undefined);\n let isControlled = value !== undefined;\n useEffect(() => {\n let wasControlled = isControlledRef.current;\n if (wasControlled !== isControlled && process.env.NODE_ENV !== 'production') {\n console.warn(\n `WARN: A component changed from ${wasControlled ? 'controlled' : 'uncontrolled'} to ${isControlled ? 'controlled' : 'uncontrolled'}.`\n );\n }\n isControlledRef.current = isControlled;\n }, [isControlled]);\n\n // After each render, update the ref to the current value.\n // This ensures that the setState callback argument is reset.\n // Note: the effect should not have any dependencies so that controlled values always reset.\n let currentValue = isControlled ? value : stateValue;\n useEarlyEffect(() => {\n valueRef.current = currentValue;\n });\n\n let [, forceUpdate] = useReducer(() => ({}), {});\n let setValue = useCallback(\n (value: SetStateAction<T>, ...args: any[]) => {\n // @ts-ignore - TS doesn't know that T cannot be a function.\n let newValue = typeof value === 'function' ? value(valueRef.current) : value;\n if (!Object.is(valueRef.current, newValue)) {\n // Update the ref so that the next setState callback has the most recent value.\n valueRef.current = newValue;\n\n setStateValue(newValue);\n\n // Always trigger a re-render, even when controlled, so that the layout effect above runs to reset the value.\n forceUpdate();\n\n // Trigger onChange. Note that if setState is called multiple times in a single event,\n // onChange will be called for each one instead of only once.\n onChange?.(newValue, ...args);\n }\n },\n [onChange]\n );\n\n return [currentValue, setValue];\n}\n"],"names":[],"version":3,"file":"useControlledState.js.map"}
|
|
@@ -12,7 +12,7 @@ import $1CcWn$react, {useState as $1CcWn$useState, useRef as $1CcWn$useRef, useE
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
// Use the earliest effect possible to reset the ref below.
|
|
15
|
-
const $3e6197669829fe11$var$useEarlyEffect = typeof document !== 'undefined' ? (0, $1CcWn$react)['useInsertionEffect'] ?? (0, $1CcWn$react).useLayoutEffect : ()=>{};
|
|
15
|
+
const $3e6197669829fe11$var$useEarlyEffect = typeof document !== 'undefined' || parseInt((0, $1CcWn$react).version, 10) >= 19 ? (0, $1CcWn$react)['useInsertionEffect'] ?? (0, $1CcWn$react).useLayoutEffect : ()=>{};
|
|
16
16
|
function $3e6197669829fe11$export$40bfa8c7b0832715(value, defaultValue, onChange) {
|
|
17
17
|
// Store the value in both state and a ref. The state value will only be used when uncontrolled.
|
|
18
18
|
// The ref is used to track the most current value, which is passed to the function setState callback.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAID,2DAA2D;AAC3D,MAAM,uCACJ,OAAO,aA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E,SAAS,OAAO,GAAG;YAEnB,cAAc;YAEd,6GAA6G;YAC7G;YAEA,sFAAsF;YACtF,6DAA6D;YAC7D,WAAW,aAAa;QAC1B;IACF,GACA;QAAC;KAAS;IAGZ,OAAO;QAAC;QAAc;KAAS;AACjC","sources":["packages/react-stately/src/utils/useControlledState.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 React, {SetStateAction, useCallback, useEffect, useReducer, useRef, useState} from 'react';\n\n// Use the earliest effect possible to reset the ref below.\nconst useEarlyEffect: typeof React.useLayoutEffect =\n typeof document !== 'undefined' || parseInt(React.version, 10) >= 19\n ? (React['useInsertionEffect'] ?? React.useLayoutEffect)\n : () => {};\n\nexport function useControlledState<T, C = T>(\n value: Exclude<T, undefined>,\n defaultValue: Exclude<T, undefined> | undefined,\n onChange?: (v: C, ...args: any[]) => void\n): [T, (value: SetStateAction<T>, ...args: any[]) => void];\nexport function useControlledState<T, C = T>(\n value: Exclude<T, undefined> | undefined,\n defaultValue: Exclude<T, undefined>,\n onChange?: (v: C, ...args: any[]) => void\n): [T, (value: SetStateAction<T>, ...args: any[]) => void];\nexport function useControlledState<T, C = T>(\n value: T,\n defaultValue: T,\n onChange?: (v: C, ...args: any[]) => void\n): [T, (value: SetStateAction<T>, ...args: any[]) => void] {\n // Store the value in both state and a ref. The state value will only be used when uncontrolled.\n // The ref is used to track the most current value, which is passed to the function setState callback.\n let [stateValue, setStateValue] = useState(value || defaultValue);\n let valueRef = useRef(stateValue);\n\n let isControlledRef = useRef(value !== undefined);\n let isControlled = value !== undefined;\n useEffect(() => {\n let wasControlled = isControlledRef.current;\n if (wasControlled !== isControlled && process.env.NODE_ENV !== 'production') {\n console.warn(\n `WARN: A component changed from ${wasControlled ? 'controlled' : 'uncontrolled'} to ${isControlled ? 'controlled' : 'uncontrolled'}.`\n );\n }\n isControlledRef.current = isControlled;\n }, [isControlled]);\n\n // After each render, update the ref to the current value.\n // This ensures that the setState callback argument is reset.\n // Note: the effect should not have any dependencies so that controlled values always reset.\n let currentValue = isControlled ? value : stateValue;\n useEarlyEffect(() => {\n valueRef.current = currentValue;\n });\n\n let [, forceUpdate] = useReducer(() => ({}), {});\n let setValue = useCallback(\n (value: SetStateAction<T>, ...args: any[]) => {\n // @ts-ignore - TS doesn't know that T cannot be a function.\n let newValue = typeof value === 'function' ? value(valueRef.current) : value;\n if (!Object.is(valueRef.current, newValue)) {\n // Update the ref so that the next setState callback has the most recent value.\n valueRef.current = newValue;\n\n setStateValue(newValue);\n\n // Always trigger a re-render, even when controlled, so that the layout effect above runs to reset the value.\n forceUpdate();\n\n // Trigger onChange. Note that if setState is called multiple times in a single event,\n // onChange will be called for each one instead of only once.\n onChange?.(newValue, ...args);\n }\n },\n [onChange]\n );\n\n return [currentValue, setValue];\n}\n"],"names":[],"version":3,"file":"useControlledState.mjs.map"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { useTokenFieldState } from '../src/tokenfield/useTokenFieldState';
|
|
2
2
|
export { TokenFieldValue } from '../src/tokenfield/TokenFieldValue';
|
|
3
3
|
export type { TokenFieldProps, TokenFieldState } from '../src/tokenfield/useTokenFieldState';
|
|
4
|
-
export type { TokenFieldSegment, TokenSegment, TextSegment, Position, TokenFieldValueOptions } from '../src/tokenfield/TokenFieldValue';
|
|
4
|
+
export type { TokenFieldSegment, TokenSegment, TextSegment, Position, SelectedRange, TokenFieldValueOptions } from '../src/tokenfield/TokenFieldValue';
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { ItemProps } from '@react-types/shared';
|
|
2
|
-
import {
|
|
3
|
-
import { JSX, ReactElement } from 'react';
|
|
4
|
-
declare function Item<T>(props: ItemProps<T>): ReactElement | null;
|
|
5
|
-
declare namespace Item {
|
|
6
|
-
var getCollectionNode: <T>(props: ItemProps<T>, context: any) => Generator<PartialNode<T>, any, any>;
|
|
7
|
-
}
|
|
2
|
+
import { JSX } from 'react';
|
|
8
3
|
declare let _Item: <T>(props: ItemProps<T>) => JSX.Element;
|
|
9
4
|
export { _Item as Item };
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { JSX, ReactElement } from 'react';
|
|
1
|
+
import { JSX } from 'react';
|
|
3
2
|
import { SectionProps } from '@react-types/shared';
|
|
4
|
-
declare function Section<T>(props: SectionProps<T>): ReactElement | null;
|
|
5
|
-
declare namespace Section {
|
|
6
|
-
var getCollectionNode: <T>(props: SectionProps<T>) => Generator<PartialNode<T>, any, any>;
|
|
7
|
-
}
|
|
8
3
|
declare let _Section: <T>(props: SectionProps<T>) => JSX.Element;
|
|
9
4
|
export { _Section as Section };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { JSX, ReactElement, ReactNode } from 'react';
|
|
2
2
|
import { Key } from '@react-types/shared';
|
|
3
|
-
import { PartialNode } from '../collections/types';
|
|
4
3
|
export interface CellProps {
|
|
5
4
|
/** The contents of the cell. */
|
|
6
5
|
children: ReactNode;
|
|
@@ -11,10 +10,6 @@ export interface CellProps {
|
|
|
11
10
|
}
|
|
12
11
|
export type CellElement = ReactElement<CellProps>;
|
|
13
12
|
export type CellRenderer = (columnKey: Key) => CellElement;
|
|
14
|
-
declare function Cell(props: CellProps): ReactElement | null;
|
|
15
|
-
declare namespace Cell {
|
|
16
|
-
var getCollectionNode: <T>(props: CellProps) => Generator<PartialNode<T>, any, any>;
|
|
17
|
-
}
|
|
18
13
|
/**
|
|
19
14
|
* A Cell represents the value of a single Column within a Table Row.
|
|
20
15
|
*/
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { CollectionBuilderContext } from './useTableState';
|
|
2
|
-
import { GridNode } from '../grid/GridCollection';
|
|
3
|
-
import { PartialNode } from '../collections/types';
|
|
4
1
|
import { JSX, ReactElement, ReactNode } from 'react';
|
|
5
2
|
/** Widths that result in a constant pixel value for the same Table width. */
|
|
6
3
|
export type ColumnStaticSize = number | `${number}` | `${number}%`;
|
|
@@ -41,10 +38,6 @@ export interface ColumnProps<T> {
|
|
|
41
38
|
/** A string representation of the column's contents, used for accessibility announcements. */
|
|
42
39
|
textValue?: string;
|
|
43
40
|
}
|
|
44
|
-
declare function Column<T>(props: ColumnProps<T>): ReactElement | null;
|
|
45
|
-
declare namespace Column {
|
|
46
|
-
var getCollectionNode: <T>(props: ColumnProps<T>, context: CollectionBuilderContext<T>) => Generator<PartialNode<T>, void, GridNode<T>[]>;
|
|
47
|
-
}
|
|
48
41
|
/**
|
|
49
42
|
* A Column represents a field of each item within a Table. Columns may also contain nested
|
|
50
43
|
* Column elements to represent column groups. Nested columns can be statically defined as
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { CellElement, CellRenderer } from './Cell';
|
|
2
|
-
import { CollectionBuilderContext } from './useTableState';
|
|
3
2
|
import { LinkDOMProps } from '@react-types/shared';
|
|
4
|
-
import { PartialNode } from '../collections/types';
|
|
5
3
|
import { JSX, ReactElement } from 'react';
|
|
6
4
|
export type RowElement<T> = ReactElement<RowProps<T>>;
|
|
7
5
|
export interface RowProps<T> extends LinkDOMProps {
|
|
@@ -19,10 +17,6 @@ export interface RowProps<T> extends LinkDOMProps {
|
|
|
19
17
|
/** A string representation of the row's contents, used for features like typeahead. */
|
|
20
18
|
textValue?: string;
|
|
21
19
|
}
|
|
22
|
-
declare function Row<T>(props: RowProps<T>): ReactElement | null;
|
|
23
|
-
declare namespace Row {
|
|
24
|
-
var getCollectionNode: <T>(props: RowProps<T>, context: CollectionBuilderContext<T>) => Generator<PartialNode<T>, any, any>;
|
|
25
|
-
}
|
|
26
20
|
/**
|
|
27
21
|
* A Row represents a single item in a Table and contains Cell elements for each column.
|
|
28
22
|
* Cells can be statically defined as children, or generated dynamically using a function
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AsyncLoadable, LoadingState } from '@react-types/shared';
|
|
2
|
-
import {
|
|
3
|
-
import { JSX, ReactElement } from 'react';
|
|
2
|
+
import { JSX } from 'react';
|
|
4
3
|
import { RowElement } from './Row';
|
|
5
4
|
export interface TableBodyProps<T> extends Omit<AsyncLoadable, 'isLoading'> {
|
|
6
5
|
/** The contents of the table body. Supports static items or a function for dynamic rendering. */
|
|
@@ -10,10 +9,6 @@ export interface TableBodyProps<T> extends Omit<AsyncLoadable, 'isLoading'> {
|
|
|
10
9
|
/** The current loading state of the table. */
|
|
11
10
|
loadingState?: LoadingState;
|
|
12
11
|
}
|
|
13
|
-
declare function TableBody<T>(props: TableBodyProps<T>): ReactElement | null;
|
|
14
|
-
declare namespace TableBody {
|
|
15
|
-
var getCollectionNode: <T>(props: TableBodyProps<T>) => Generator<PartialNode<T>, any, any>;
|
|
16
|
-
}
|
|
17
12
|
/**
|
|
18
13
|
* A TableBody is a container for the Row elements of a Table. Rows can be statically defined as
|
|
19
14
|
* children, or generated dynamically using a function based on the data passed to the `items`
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { CollectionBuilderContext } from './useTableState';
|
|
2
1
|
import { ColumnElement, ColumnRenderer } from './Column';
|
|
3
|
-
import {
|
|
4
|
-
import { JSX, ReactElement } from 'react';
|
|
2
|
+
import { JSX } from 'react';
|
|
5
3
|
export interface TableHeaderProps<T> {
|
|
6
4
|
/** A list of table columns. */
|
|
7
5
|
columns?: readonly T[];
|
|
@@ -11,10 +9,6 @@ export interface TableHeaderProps<T> {
|
|
|
11
9
|
*/
|
|
12
10
|
children: ColumnElement<T> | ColumnElement<T>[] | ColumnRenderer<T>;
|
|
13
11
|
}
|
|
14
|
-
declare function TableHeader<T>(props: TableHeaderProps<T>): ReactElement | null;
|
|
15
|
-
declare namespace TableHeader {
|
|
16
|
-
var getCollectionNode: <T>(props: TableHeaderProps<T>, context: CollectionBuilderContext<T>) => Generator<PartialNode<T>, void, any>;
|
|
17
|
-
}
|
|
18
12
|
/**
|
|
19
13
|
* A TableHeader is a container for the Column elements in a Table. Columns can be statically
|
|
20
14
|
* defined as children, or generated dynamically using a function based on the data passed to the
|
|
@@ -15,30 +15,53 @@ export interface Position {
|
|
|
15
15
|
/** Text offset within the segment in UTF-16 code units. */
|
|
16
16
|
offset: number;
|
|
17
17
|
}
|
|
18
|
+
/** Represents a text selection in a TokenField. */
|
|
19
|
+
export declare class SelectedRange {
|
|
20
|
+
/** The anchor position. */
|
|
21
|
+
anchor: Position;
|
|
22
|
+
/** The current (i.e. caret) position. */
|
|
23
|
+
current: Position;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new selection range. If only a single position is provided, the selection is
|
|
26
|
+
* collapsed.
|
|
27
|
+
*/
|
|
28
|
+
constructor(anchor: Position, current?: Position);
|
|
29
|
+
/** Whether the selection is collapsed to a single caret position. */
|
|
30
|
+
get isCollapsed(): boolean;
|
|
31
|
+
/** The side of the selection closest to the start of the value. */
|
|
32
|
+
get start(): Position;
|
|
33
|
+
/** The side of the selection closest to the end of the value. */
|
|
34
|
+
get end(): Position;
|
|
35
|
+
/** Returns whether this selection is equal to another. */
|
|
36
|
+
isEqual(other: SelectedRange): boolean;
|
|
37
|
+
}
|
|
18
38
|
declare enum Direction {
|
|
19
39
|
Forward = 1,
|
|
20
40
|
Backward = -1
|
|
21
41
|
}
|
|
22
42
|
export interface TokenFieldValueOptions {
|
|
23
|
-
|
|
43
|
+
selectedRange?: SelectedRange | null;
|
|
24
44
|
}
|
|
25
45
|
/**
|
|
26
46
|
* A list of segments containing editable text and non-editable tokens.
|
|
27
47
|
*/
|
|
28
48
|
export declare class TokenFieldValue<T = any> {
|
|
29
49
|
static readonly Direction: typeof Direction;
|
|
50
|
+
static readonly SelectedRange: typeof SelectedRange;
|
|
30
51
|
/** The text and token segments in the list. */
|
|
31
52
|
readonly segments: readonly TokenFieldSegment<T>[];
|
|
32
|
-
/** The
|
|
33
|
-
|
|
53
|
+
/** The selected range. */
|
|
54
|
+
selectedRange: SelectedRange;
|
|
34
55
|
private previous;
|
|
35
56
|
private next;
|
|
36
57
|
private isCoalescing;
|
|
37
58
|
/** Create a new list with the given segments. */
|
|
38
59
|
constructor(tokens: readonly TokenFieldSegment<T>[], options?: TokenFieldValueOptions);
|
|
39
60
|
protected createFieldValue(segments: readonly TokenFieldSegment<T>[]): this;
|
|
61
|
+
get caretPosition(): Position;
|
|
40
62
|
/** Create a new list with the caret position set to the given position. */
|
|
41
|
-
|
|
63
|
+
withSelectedRange(selectedRange: SelectedRange): this;
|
|
64
|
+
withCaretPosition(position: Position): this;
|
|
42
65
|
private splitSegment;
|
|
43
66
|
private createTextSegment;
|
|
44
67
|
protected tokenize(text: string): TokenFieldSegment<T>[];
|
|
@@ -6,14 +6,14 @@ export interface TooltipTriggerProps extends OverlayTriggerProps {
|
|
|
6
6
|
isDisabled?: boolean;
|
|
7
7
|
/**
|
|
8
8
|
* The delay time for the tooltip to show up. [See
|
|
9
|
-
* guidelines](https://spectrum.adobe.com/
|
|
9
|
+
* guidelines](https://spectrum.adobe.com/web/rsp/components/tooltip#behaviors).
|
|
10
10
|
*
|
|
11
11
|
* @default 1500
|
|
12
12
|
*/
|
|
13
13
|
delay?: number;
|
|
14
14
|
/**
|
|
15
15
|
* The delay time for the tooltip to close. [See
|
|
16
|
-
* guidelines](https://spectrum.adobe.com/
|
|
16
|
+
* guidelines](https://spectrum.adobe.com/web/rsp/components/tooltip#behaviors).
|
|
17
17
|
*
|
|
18
18
|
* @default 500
|
|
19
19
|
*/
|