Skip to content

Commit 341ae3f

Browse files
authored
chore: Remove CollectionNode default filter behavior and other release API updates (adobe#8761)
* chore: updating CollectionNode filter logic so it doesnt filter by default * rename triggerOrigin to triggerAnchorPoint * add docs for reset/setLocalTimeZone * bold stuff
1 parent dd349ce commit 341ae3f

File tree

19 files changed

+56
-50
lines changed

19 files changed

+56
-50
lines changed

packages/@internationalized/date/docs/CalendarDate.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ let date = parseDate('2022-02-03');
5050

5151
Today's date can be retrieved using the <TypeLink links={docs.links} type={docs.exports.today} /> function. This requires a time zone identifier to be provided, which is used to determine the local date. The <TypeLink links={docs.links} type={docs.exports.getLocalTimeZone} /> function can be used to retrieve the user's current time zone.
5252

53+
**Note:** the local time zone is cached after the first call. You can reset it by calling <TypeLink links={docs.links} type={docs.exports.resetLocalTimeZone} />, or mock it in unit tests by calling <TypeLink links={docs.links} type={docs.exports.setLocalTimeZone} />.
54+
5355
```tsx
5456
import {today, getLocalTimeZone} from '@internationalized/date';
5557

@@ -206,6 +208,8 @@ A `CalendarDate` can be converted to a native JavaScript `Date` object using the
206208

207209
Because a `Date` represents an exact time, a time zone identifier is required to be passed to the `toDate` method. The time of the returned date will be set to midnight in that time zone. The <TypeLink links={docs.links} type={docs.exports.getLocalTimeZone} /> function can be used to retrieve the user's current time zone.
208210

211+
**Note:** the local time zone is cached after the first call. You can reset it by calling <TypeLink links={docs.links} type={docs.exports.resetLocalTimeZone} />, or mock it in unit tests by calling <TypeLink links={docs.links} type={docs.exports.setLocalTimeZone} />.
212+
209213
```tsx
210214
import {getLocalTimeZone} from '@internationalized/date';
211215

packages/@internationalized/date/docs/CalendarDateTime.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ A `CalendarDateTime` can be converted to a native JavaScript `Date` object using
280280

281281
Because a `Date` represents an exact time, a time zone identifier is required to be passed to the `toDate` method. The <TypeLink links={docs.links} type={docs.exports.getLocalTimeZone} /> function can be used to retrieve the user's current time zone.
282282

283+
**Note:** the local time zone is cached after the first call. You can reset it by calling <TypeLink links={docs.links} type={docs.exports.resetLocalTimeZone} />, or mock it in unit tests by calling <TypeLink links={docs.links} type={docs.exports.setLocalTimeZone} />.
284+
283285
```tsx
284286
import {getLocalTimeZone} from '@internationalized/date';
285287

packages/@internationalized/date/docs/ZonedDateTime.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ let date = fromAbsolute(1688023843144, 'America/Los_Angeles');
7676

7777
The current time can be retrieved using the <TypeLink links={docs.links} type={docs.exports.now} /> function. This requires a time zone identifier to be provided, which is used to determine the local time. The <TypeLink links={docs.links} type={docs.exports.getLocalTimeZone} /> function can be used to retrieve the user's current time zone.
7878

79+
**Note:** the local time zone is cached after the first call. You can reset it by calling <TypeLink links={docs.links} type={docs.exports.resetLocalTimeZone} />, or mock it in unit tests by calling <TypeLink links={docs.links} type={docs.exports.setLocalTimeZone} />.
80+
7981
```tsx
8082
import {now, getLocalTimeZone} from '@internationalized/date';
8183

packages/@react-aria/collections/src/BaseCollection.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ export class CollectionNode<T> implements Node<T> {
7171
return node;
7272
}
7373

74+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
75+
filter(collection: BaseCollection<T>, newCollection: BaseCollection<T>, filterFn: FilterFn<T>): CollectionNode<T> | null {
76+
let clone = this.clone();
77+
newCollection.addDescendants(clone, collection);
78+
return clone;
79+
}
80+
}
81+
82+
export class FilterableNode<T> extends CollectionNode<T> {
7483
filter(collection: BaseCollection<T>, newCollection: BaseCollection<T>, filterFn: FilterFn<T>): CollectionNode<T> | null {
7584
let [firstKey, lastKey] = filterChildren(collection, newCollection, this.firstChildKey, filterFn);
7685
let newNode: Mutable<CollectionNode<T>> = this.clone();
@@ -80,26 +89,15 @@ export class CollectionNode<T> implements Node<T> {
8089
}
8190
}
8291

83-
// TODO: naming, but essentially these nodes shouldn't be affected by filtering (BaseNode)?
84-
// Perhaps this filter logic should be in CollectionNode instead and the current logic of CollectionNode's filter should move to Table
85-
export class FilterLessNode<T> extends CollectionNode<T> {
86-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
87-
filter(collection: BaseCollection<T>, newCollection: BaseCollection<T>, filterFn: FilterFn<T>): FilterLessNode<T> | null {
88-
let clone = this.clone();
89-
newCollection.addDescendants(clone, collection);
90-
return clone;
91-
}
92-
}
93-
94-
export class HeaderNode extends FilterLessNode<unknown> {
92+
export class HeaderNode extends CollectionNode<unknown> {
9593
static readonly type = 'header';
9694
}
9795

98-
export class LoaderNode extends FilterLessNode<unknown> {
96+
export class LoaderNode extends CollectionNode<unknown> {
9997
static readonly type = 'loader';
10098
}
10199

102-
export class ItemNode<T> extends CollectionNode<T> {
100+
export class ItemNode<T> extends FilterableNode<T> {
103101
static readonly type = 'item';
104102

105103
filter(collection: BaseCollection<T>, newCollection: BaseCollection<T>, filterFn: FilterFn<T>): ItemNode<T> | null {
@@ -113,7 +111,7 @@ export class ItemNode<T> extends CollectionNode<T> {
113111
}
114112
}
115113

116-
export class SectionNode<T> extends CollectionNode<T> {
114+
export class SectionNode<T> extends FilterableNode<T> {
117115
static readonly type = 'section';
118116

119117
filter(collection: BaseCollection<T>, newCollection: BaseCollection<T>, filterFn: FilterFn<T>): SectionNode<T> | null {

packages/@react-aria/collections/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
export {CollectionBuilder, Collection, createLeafComponent, createBranchComponent} from './CollectionBuilder';
1414
export {createHideableComponent, useIsHidden} from './Hidden';
1515
export {useCachedChildren} from './useCachedChildren';
16-
export {BaseCollection, CollectionNode, ItemNode, SectionNode, FilterLessNode, LoaderNode, HeaderNode} from './BaseCollection';
16+
export {BaseCollection, CollectionNode, ItemNode, SectionNode, FilterableNode, LoaderNode, HeaderNode} from './BaseCollection';
1717

1818
export type {CollectionBuilderProps, CollectionProps} from './CollectionBuilder';
1919
export type {CachedChildrenOptions} from './useCachedChildren';

packages/@react-aria/overlays/src/calculatePosition.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export interface PositionResult {
6767
position: Position,
6868
arrowOffsetLeft?: number,
6969
arrowOffsetTop?: number,
70-
triggerOrigin: {x: number, y: number},
70+
triggerAnchorPoint: {x: number, y: number},
7171
maxHeight: number,
7272
placement: PlacementAxis
7373
}
@@ -450,7 +450,7 @@ export function calculatePositionInternal(
450450
}
451451

452452
let crossOrigin = placement === 'left' || placement === 'top' ? overlaySize[size] : 0;
453-
let triggerOrigin = {
453+
let triggerAnchorPoint = {
454454
x: placement === 'top' || placement === 'bottom' ? origin : crossOrigin,
455455
y: placement === 'left' || placement === 'right' ? origin : crossOrigin
456456
};
@@ -461,7 +461,7 @@ export function calculatePositionInternal(
461461
arrowOffsetLeft: arrowPosition.left,
462462
arrowOffsetTop: arrowPosition.top,
463463
placement,
464-
triggerOrigin
464+
triggerAnchorPoint
465465
};
466466
}
467467

packages/@react-aria/overlays/src/useOverlayPosition.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export interface PositionAria {
7373
/** Placement of the overlay with respect to the overlay trigger. */
7474
placement: PlacementAxis | null,
7575
/** The origin of the target in the overlay's coordinate system. Useful for animations. */
76-
triggerOrigin: {x: number, y: number} | null,
76+
triggerAnchorPoint: {x: number, y: number} | null,
7777
/** Updates the position of the overlay. */
7878
updatePosition(): void
7979
}
@@ -308,7 +308,7 @@ export function useOverlayPosition(props: AriaPositionProps): PositionAria {
308308
}
309309
},
310310
placement: position?.placement ?? null,
311-
triggerOrigin: position?.triggerOrigin ?? null,
311+
triggerAnchorPoint: position?.triggerAnchorPoint ?? null,
312312
arrowProps: {
313313
'aria-hidden': 'true',
314314
role: 'presentation',

packages/@react-aria/overlays/src/usePopover.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export interface PopoverAria {
7474
/** Placement of the popover with respect to the trigger. */
7575
placement: PlacementAxis | null,
7676
/** The origin of the target in the overlay's coordinate system. Useful for animations. */
77-
triggerOrigin: {x: number, y: number} | null
77+
triggerAnchorPoint: {x: number, y: number} | null
7878
}
7979

8080
/**
@@ -106,7 +106,7 @@ export function usePopover(props: AriaPopoverProps, state: OverlayTriggerState):
106106
groupRef ?? popoverRef
107107
);
108108

109-
let {overlayProps: positionProps, arrowProps, placement, triggerOrigin: origin} = useOverlayPosition({
109+
let {overlayProps: positionProps, arrowProps, placement, triggerAnchorPoint: origin} = useOverlayPosition({
110110
...otherProps,
111111
targetRef: triggerRef,
112112
overlayRef: popoverRef,
@@ -133,6 +133,6 @@ export function usePopover(props: AriaPopoverProps, state: OverlayTriggerState):
133133
arrowProps,
134134
underlayProps,
135135
placement,
136-
triggerOrigin: origin
136+
triggerAnchorPoint: origin
137137
};
138138
}

packages/@react-aria/overlays/test/calculatePosition.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ describe('calculatePosition', function () {
128128
arrowOffsetTop: expected[3],
129129
maxHeight,
130130
placement: calculatedPlacement,
131-
triggerOrigin: {
131+
triggerAnchorPoint: {
132132
x: expected[2] ?? (calculatedPlacement === 'left' ? overlaySize.width : 0),
133133
y: expected[3] ?? (calculatedPlacement === 'top' ? Math.min(overlaySize.height, maxHeight) : 0)
134134
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import {createLeafComponent, FilterLessNode} from '@react-aria/collections';
13+
import {CollectionNode, createLeafComponent} from '@react-aria/collections';
1414
import {ReactNode} from 'react';
1515
import {Skeleton} from './Skeleton';
1616

@@ -20,7 +20,7 @@ export interface SkeletonCollectionProps {
2020

2121
let cache = new WeakMap();
2222

23-
class SkeletonNode extends FilterLessNode<unknown> {
23+
class SkeletonNode extends CollectionNode<unknown> {
2424
static readonly type = 'skeleton';
2525
}
2626

0 commit comments

Comments
 (0)