Skip to content

Commit 9b3385a

Browse files
authored
chore: Api audit (#7843)
* bring back UNSTABLE for TreeLoadingIndicator * make status light children optional * fix spelling * only expose enterKeyHint through TextField and SearchField * revert useTreeData additions
1 parent f28f1f4 commit 9b3385a

File tree

13 files changed

+46
-118
lines changed

13 files changed

+46
-118
lines changed

packages/@react-aria/textfield/src/useTextField.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ export interface AriaTextFieldOptions<T extends TextFieldIntrinsicElements> exte
8181
* Controls whether inputted text is automatically capitalized and, if so, in what manner.
8282
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autocapitalize).
8383
*/
84-
autoCapitalize?: 'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters'
84+
autoCapitalize?: 'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters',
85+
/**
86+
* An enumerated attribute that defines what action label or icon to preset for the enter key on virtual keyboards. See [https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint].
87+
*/
88+
enterKeyHint?: string
8589
}
8690

8791
/**

packages/@react-spectrum/s2/src/Menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export interface MenuTriggerProps extends AriaMenuTriggerProps {
7272
shouldFlip?: boolean
7373
}
7474

75-
export interface MenuProps<T> extends Omit<AriaMenuProps<T>, 'children' | 'style' | 'className' | 'dependencies'>, StyleProps {
75+
export interface MenuProps<T> extends Omit<AriaMenuProps<T>, 'children' | 'style' | 'className' | 'dependencies' | 'renderEmptyState'>, StyleProps {
7676
/**
7777
* The size of the Menu.
7878
*

packages/@react-spectrum/s2/src/StatusLight.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export interface StatusLightProps extends StatusLightStyleProps, DOMProps, AriaL
4040
/**
4141
* The content to display as the label.
4242
*/
43-
children: ReactNode,
43+
children?: ReactNode,
4444
/**
4545
* An accessibility role for the status light. Should be set when the status
4646
* can change at runtime, and no more than one status light will update simultaneously.

packages/@react-stately/data/docs/useTreeData.mdx

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -182,33 +182,6 @@ tree.move('Sam', 'Animals', 1);
182182
tree.move('Sam', null, 1);
183183
```
184184

185-
### Move before
186-
An alias to move
187-
188-
```tsx
189-
// Move an item within the same parent
190-
tree.moveBefore('Sam', 'People', 0);
191-
192-
// Move an item to a different parent
193-
tree.moveBefore('Sam', 'Animals', 1);
194-
195-
// Move an item to the root
196-
tree.moveBefore('Sam', null, 1);
197-
```
198-
199-
### Move after
200-
201-
```tsx
202-
// Move an item within the same parent
203-
tree.moveAfter('Sam', 'People', 0);
204-
205-
// Move an item to a different parent
206-
tree.moveAfter('Sam', 'Animals', 1);
207-
208-
// Move an item to the root
209-
tree.moveAfter('Sam', null, 1);
210-
```
211-
212185
### Updating items
213186

214187
```tsx

packages/@react-stately/data/src/useTreeData.ts

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,6 @@ export interface TreeData<T extends object> {
107107
*/
108108
move(key: Key, toParentKey: Key | null, index: number): void,
109109

110-
/**
111-
* Moves an item before a node within the tree.
112-
* @param key - The key of the item to move.
113-
* @param toParentKey - The key of the new parent to insert into. `null` for the root.
114-
* @param index - The index within the new parent to insert before.
115-
*/
116-
moveBefore(key: Key, toParentKey: Key | null, index: number): void,
117-
118-
/**
119-
* Moves an item after a node within the tree.
120-
* @param key - The key of the item to move.
121-
* @param toParentKey - The key of the new parent to insert into. `null` for the root.
122-
* @param index - The index within the new parent to insert after.
123-
*/
124-
moveAfter(key: Key, toParentKey: Key | null, index: number): void,
125-
126110
/**
127111
* Updates an item in the tree.
128112
* @param key - The key of the item to update.
@@ -389,50 +373,6 @@ export function useTreeData<T extends object>(options: TreeOptions<T>): TreeData
389373
}), newMap);
390374
});
391375
},
392-
moveBefore(key: Key, toParentKey: Key | null, index: number) {
393-
this.move(key, toParentKey, index);
394-
},
395-
moveAfter(key: Key, toParentKey: Key | null, index: number) {
396-
setItems(({items, nodeMap: originalMap}) => {
397-
let node = originalMap.get(key);
398-
if (!node) {
399-
return {items, nodeMap: originalMap};
400-
}
401-
402-
let {items: newItems, nodeMap: newMap} = updateTree(items, key, () => null, originalMap);
403-
404-
const movedNode = {
405-
...node,
406-
parentKey: toParentKey
407-
};
408-
409-
const afterIndex = items.length === index ? index : index + 1;
410-
// If parentKey is null, insert into the root.
411-
if (toParentKey == null) {
412-
newMap.set(movedNode.key, movedNode);
413-
return {items: [
414-
...newItems.slice(0, afterIndex),
415-
movedNode,
416-
...newItems.slice(afterIndex)
417-
], nodeMap: newMap};
418-
}
419-
420-
// Otherwise, update the parent node and its ancestors.
421-
return updateTree(newItems, toParentKey, parentNode => {
422-
const c = [
423-
...parentNode.children!.slice(0, afterIndex),
424-
movedNode,
425-
...parentNode.children!.slice(afterIndex)
426-
];
427-
return {
428-
key: parentNode.key,
429-
parentKey: parentNode.parentKey,
430-
value: parentNode.value,
431-
children: c
432-
};
433-
}, newMap);
434-
});
435-
},
436376
update(oldKey: Key, newValue: T) {
437377
setItems(({items, nodeMap: originalMap}) => updateTree(items, oldKey, oldNode => {
438378
let node: TreeNode<T> = {

packages/@react-stately/data/test/useTreeData.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ describe('useTreeData', function () {
685685
useTreeData({initialItems, getChildren, getKey})
686686
);
687687
act(() => {
688-
result.current.moveBefore('Eli', null, 0);
688+
result.current.move('Eli', null, 0);
689689
});
690690
expect(result.current.items[0].key).toEqual('Eli');
691691
expect(result.current.items[1].key).toEqual('David');
@@ -700,7 +700,7 @@ describe('useTreeData', function () {
700700
useTreeData({initialItems, getChildren, getKey})
701701
);
702702
act(() => {
703-
result.current.moveBefore('Eli', 'David', 1);
703+
result.current.move('Eli', 'David', 1);
704704
});
705705
expect(result.current.items[0].key).toEqual('David');
706706
expect(result.current.items[0].children[0].key).toEqual('John');
@@ -716,7 +716,7 @@ describe('useTreeData', function () {
716716
);
717717

718718
act(() => {
719-
result.current.moveAfter('Eli', 'David', 1);
719+
result.current.move('Eli', 'David', 2);
720720
});
721721
expect(result.current.items[0].key).toEqual('David');
722722

@@ -734,7 +734,7 @@ describe('useTreeData', function () {
734734
);
735735

736736
act(() => {
737-
result.current.moveAfter('Eli', 'David', 100);
737+
result.current.move('Eli', 'David', 101);
738738
});
739739
expect(result.current.items[0].key).toEqual('David');
740740

packages/@react-types/searchfield/src/index.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,10 @@ export interface SearchFieldProps extends TextFieldProps {
2121
onClear?: () => void
2222
}
2323

24-
export interface AriaSearchFieldProps extends SearchFieldProps, AriaTextFieldProps {}
24+
export interface AriaSearchFieldProps extends SearchFieldProps, AriaTextFieldProps {
25+
/**
26+
* An enumerated attribute that defines what action label or icon to preset for the enter key on virtual keyboards. See [https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint].
27+
*/
28+
enterKeyHint?: string
29+
}
2530
export interface SpectrumSearchFieldProps extends SpectrumTextInputBase, Omit<AriaSearchFieldProps, 'isInvalid' | 'validationState'>, SpectrumTextFieldProps {}

packages/@react-types/shared/src/dom.d.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,7 @@ export interface TextInputDOMProps extends DOMProps, InputDOMProps, TextInputDOM
176176
/**
177177
* An enumerated attribute that defines whether the element may be checked for spelling errors. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/spellcheck).
178178
*/
179-
spellCheck?: string,
180-
181-
/**
182-
* An enumerated attribute that defines what action label or icon to preset for the enter key on virtual keyboards. See [https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint].
183-
*/
184-
enterKeyHint?: string
179+
spellCheck?: string
185180
}
186181

187182
/**

packages/@react-types/textfield/src/index.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ export interface AriaTextFieldProps<T = HTMLInputElement> extends TextFieldProps
4444
/** Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. */
4545
'aria-haspopup'?: boolean | 'false' | 'true' | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog',
4646
/** Identifies the element (or elements) whose contents or presence are controlled by the current element. */
47-
'aria-controls'?: string
47+
'aria-controls'?: string,
48+
/**
49+
* An enumerated attribute that defines what action label or icon to preset for the enter key on virtual keyboards. See [https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint].
50+
*/
51+
enterKeyHint?: string
52+
4853
}
4954

5055
interface SpectrumTextFieldBaseProps {

packages/react-aria-components/src/Table.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -988,12 +988,12 @@ export const TableBody = /*#__PURE__*/ createBranchComponent('tablebody', <T ext
988988

989989
export interface RowRenderProps extends ItemRenderProps {
990990
/** Whether the row's children have keyboard focus. */
991-
isFocusVisibleWithin: boolean
991+
isFocusVisibleWithin: boolean,
992+
/** The unique id of the row. */
993+
id?: Key
992994
}
993995

994996
export interface RowProps<T> extends StyleRenderProps<RowRenderProps>, LinkDOMProps, HoverEvents {
995-
/** The unique id of the row. */
996-
id?: Key,
997997
/** A list of columns used when dynamically rendering cells. */
998998
columns?: Iterable<T>,
999999
/** The cells within the row. Supports static items or a function for dynamic rendering. */
@@ -1010,7 +1010,9 @@ export interface RowProps<T> extends StyleRenderProps<RowRenderProps>, LinkDOMPr
10101010
* Handler that is called when a user performs an action on the row. The exact user event depends on
10111011
* the collection's `selectionBehavior` prop and the interaction modality.
10121012
*/
1013-
onAction?: () => void
1013+
onAction?: () => void,
1014+
/** The unique id of the row. */
1015+
id?: Key
10141016
}
10151017

10161018
/**
@@ -1087,7 +1089,8 @@ export const Row = /*#__PURE__*/ createBranchComponent(
10871089
selectionBehavior: state.selectionManager.selectionBehavior,
10881090
isDragging,
10891091
isDropTarget: dropIndicator?.isDropTarget,
1090-
isFocusVisibleWithin
1092+
isFocusVisibleWithin,
1093+
id: item.key
10911094
}
10921095
});
10931096

@@ -1178,12 +1181,14 @@ export interface CellRenderProps {
11781181
* Whether the cell is currently hovered with a mouse.
11791182
* @selector [data-hovered]
11801183
*/
1181-
isHovered: boolean
1184+
isHovered: boolean,
1185+
/**
1186+
* The unique id of the cell.
1187+
**/
1188+
id?: Key
11821189
}
11831190

11841191
export interface CellProps extends RenderProps<CellRenderProps> {
1185-
/** The unique id of the cell. */
1186-
id?: Key,
11871192
/** A string representation of the cell's contents, used for features like typeahead. */
11881193
textValue?: string,
11891194
/** Indicates how many columns the data cell spans. */
@@ -1217,7 +1222,8 @@ export const Cell = /*#__PURE__*/ createLeafComponent('cell', (props: CellProps,
12171222
isFocused,
12181223
isFocusVisible,
12191224
isPressed,
1220-
isHovered
1225+
isHovered,
1226+
id: cell.key
12211227
}
12221228
});
12231229

0 commit comments

Comments
 (0)