react-stately 3.49.0 → 3.50.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.
@@ -1,9 +1,4 @@
1
- import { PartialNode } from './types';
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 { PartialNode } from '../collections/types';
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 { PartialNode } from '../collections/types';
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
- caretPosition?: Position | null;
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 caret position. */
33
- caretPosition: Position;
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
- withCaretPosition(caretPosition: Position): this;
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>[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-stately",
3
- "version": "3.49.0",
3
+ "version": "3.50.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/exports/index.cjs",
@@ -16,6 +16,7 @@
16
16
  "./*": {
17
17
  "source": "./exports/*.ts",
18
18
  "types": "./dist/types/exports/*.d.ts",
19
+ "legacy-module": "./dist/exports/*.js",
19
20
  "import": "./dist/exports/*.mjs",
20
21
  "require": "./dist/exports/*.cjs"
21
22
  }
@@ -37,8 +38,8 @@
37
38
  "url": "https://github.com/adobe/react-spectrum"
38
39
  },
39
40
  "dependencies": {
40
- "@internationalized/date": "^3.12.3",
41
- "@internationalized/number": "^3.6.7",
41
+ "@internationalized/date": "^3.12.4",
42
+ "@internationalized/number": "^3.6.8",
42
43
  "@internationalized/string": "^3.2.10",
43
44
  "@react-types/shared": "^3.36.1",
44
45
  "@swc/helpers": "^0.5.0",
@@ -94,5 +95,5 @@
94
95
  }
95
96
  }
96
97
  },
97
- "gitHead": "5ecb3333001313e83898cd07644227897e3bae1f"
98
+ "gitHead": "0a2a7e68e4d896b3ac46c3647fe48fac9ea3ae2e"
98
99
  }