@react-aria/collections 3.0.3 → 3.1.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/import.mjs +7 -5
- package/dist/main.js +20 -18
- package/dist/main.js.map +1 -1
- package/dist/module.js +7 -5
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +8 -0
- package/package.json +14 -15
- package/src/index.ts +8 -7
- package/dist/BaseCollection.main.js +0 -271
- package/dist/BaseCollection.main.js.map +0 -1
- package/dist/BaseCollection.mjs +0 -260
- package/dist/BaseCollection.module.js +0 -260
- package/dist/BaseCollection.module.js.map +0 -1
- package/dist/CollectionBuilder.main.js +0 -242
- package/dist/CollectionBuilder.main.js.map +0 -1
- package/dist/CollectionBuilder.mjs +0 -230
- package/dist/CollectionBuilder.module.js +0 -230
- package/dist/CollectionBuilder.module.js.map +0 -1
- package/dist/Document.main.js +0 -369
- package/dist/Document.main.js.map +0 -1
- package/dist/Document.mjs +0 -364
- package/dist/Document.module.js +0 -364
- package/dist/Document.module.js.map +0 -1
- package/dist/Hidden.main.js +0 -90
- package/dist/Hidden.main.js.map +0 -1
- package/dist/Hidden.mjs +0 -79
- package/dist/Hidden.module.js +0 -79
- package/dist/Hidden.module.js.map +0 -1
- package/dist/types.d.ts +0 -119
- package/dist/types.d.ts.map +0 -1
- package/dist/useCachedChildren.main.js +0 -61
- package/dist/useCachedChildren.main.js.map +0 -1
- package/dist/useCachedChildren.mjs +0 -56
- package/dist/useCachedChildren.module.js +0 -56
- package/dist/useCachedChildren.module.js.map +0 -1
- package/src/BaseCollection.ts +0 -353
- package/src/CollectionBuilder.tsx +0 -265
- package/src/Document.ts +0 -569
- package/src/Hidden.tsx +0 -97
- package/src/useCachedChildren.ts +0 -70
package/dist/Hidden.module.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import $8SdCi$react, {createContext as $8SdCi$createContext, useContext as $8SdCi$useContext, forwardRef as $8SdCi$forwardRef} from "react";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright 2024 Adobe. All rights reserved.
|
|
5
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
-
* governing permissions and limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
// React doesn't understand the <template> element, which doesn't have children like a normal element.
|
|
15
|
-
// It will throw an error during hydration when it expects the firstChild to contain content rendered
|
|
16
|
-
// on the server, when in reality, the browser will have placed this inside the `content` document fragment.
|
|
17
|
-
// This monkey patches the firstChild property for our special hidden template elements to work around this error.
|
|
18
|
-
// does the same for appendChild/removeChild/insertBefore as per the issue below
|
|
19
|
-
// See https://github.com/facebook/react/issues/19932
|
|
20
|
-
if (typeof HTMLTemplateElement !== 'undefined') {
|
|
21
|
-
Object.defineProperty(HTMLTemplateElement.prototype, 'firstChild', {
|
|
22
|
-
configurable: true,
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function() {
|
|
25
|
-
return this.content.firstChild;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(HTMLTemplateElement.prototype, 'appendChild', {
|
|
29
|
-
configurable: true,
|
|
30
|
-
enumerable: true,
|
|
31
|
-
value: function(node) {
|
|
32
|
-
return this.content.appendChild(node);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(HTMLTemplateElement.prototype, 'removeChild', {
|
|
36
|
-
configurable: true,
|
|
37
|
-
enumerable: true,
|
|
38
|
-
value: function(node) {
|
|
39
|
-
return this.content.removeChild(node);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
Object.defineProperty(HTMLTemplateElement.prototype, 'insertBefore', {
|
|
43
|
-
configurable: true,
|
|
44
|
-
enumerable: true,
|
|
45
|
-
value: function(node, child) {
|
|
46
|
-
return this.content.insertBefore(node, child);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
const $f39a9eba43920ace$export$94b6d0abf7d33e8c = /*#__PURE__*/ (0, $8SdCi$createContext)(false);
|
|
51
|
-
function $f39a9eba43920ace$export$8dc98ba7eadeaa56(props) {
|
|
52
|
-
let isHidden = (0, $8SdCi$useContext)($f39a9eba43920ace$export$94b6d0abf7d33e8c);
|
|
53
|
-
if (isHidden) // Don't hide again if we are already hidden.
|
|
54
|
-
return /*#__PURE__*/ (0, $8SdCi$react).createElement((0, $8SdCi$react).Fragment, null, props.children);
|
|
55
|
-
let children = /*#__PURE__*/ (0, $8SdCi$react).createElement($f39a9eba43920ace$export$94b6d0abf7d33e8c.Provider, {
|
|
56
|
-
value: true
|
|
57
|
-
}, props.children);
|
|
58
|
-
// In SSR, portals are not supported by React. Instead, always render into a <template>
|
|
59
|
-
// element, which the browser will never display to the user. In addition, the
|
|
60
|
-
// content is not part of the accessible DOM tree, so it won't affect ids or other accessibility attributes.
|
|
61
|
-
return /*#__PURE__*/ (0, $8SdCi$react).createElement("template", null, children);
|
|
62
|
-
}
|
|
63
|
-
function $f39a9eba43920ace$export$86427a43e3e48ebb(fn) {
|
|
64
|
-
let Wrapper = (props, ref)=>{
|
|
65
|
-
let isHidden = (0, $8SdCi$useContext)($f39a9eba43920ace$export$94b6d0abf7d33e8c);
|
|
66
|
-
if (isHidden) return null;
|
|
67
|
-
return fn(props, ref);
|
|
68
|
-
};
|
|
69
|
-
// @ts-ignore - for react dev tools
|
|
70
|
-
Wrapper.displayName = fn.displayName || fn.name;
|
|
71
|
-
return (0, $8SdCi$forwardRef)(Wrapper);
|
|
72
|
-
}
|
|
73
|
-
function $f39a9eba43920ace$export$b5d7cc18bb8d2b59() {
|
|
74
|
-
return (0, $8SdCi$useContext)($f39a9eba43920ace$export$94b6d0abf7d33e8c);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
export {$f39a9eba43920ace$export$94b6d0abf7d33e8c as HiddenContext, $f39a9eba43920ace$export$8dc98ba7eadeaa56 as Hidden, $f39a9eba43920ace$export$86427a43e3e48ebb as createHideableComponent, $f39a9eba43920ace$export$b5d7cc18bb8d2b59 as useIsHidden};
|
|
79
|
-
//# sourceMappingURL=Hidden.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAKD,sGAAsG;AACtG,qGAAqG;AACrG,4GAA4G;AAC5G,kHAAkH;AAClH,gFAAgF;AAChF,qDAAqD;AACrD,IAAI,OAAO,wBAAwB,aAAa;IAC9C,OAAO,cAAc,CAAC,oBAAoB,SAAS,EAAE,cAAc;QACjE,cAAc;QACd,YAAY;QACZ,KAAK;YACH,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU;QAChC;IACF;IAEA,OAAO,cAAc,CAAC,oBAAoB,SAAS,EAAE,eAAe;QAClE,cAAc;QACd,YAAY;QACZ,OAAO,SAAU,IAAI;YACnB,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;QAClC;IACF;IAEA,OAAO,cAAc,CAAC,oBAAoB,SAAS,EAAE,eAAe;QAClE,cAAc;QACd,YAAY;QACZ,OAAO,SAAU,IAAI;YACnB,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;QAClC;IACF;IAEA,OAAO,cAAc,CAAC,oBAAoB,SAAS,EAAE,gBAAgB;QACnE,cAAc;QACd,YAAY;QACZ,OAAO,SAAU,IAAI,EAAE,KAAK;YAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM;QACzC;IACF;AACF;AAEO,MAAM,0DAAkC,CAAA,GAAA,oBAAY,EAAW;AAE/D,SAAS,0CAAO,KAA4B;IACjD,IAAI,WAAW,CAAA,GAAA,iBAAS,EAAE;IAE1B,IAAI,UACF,6CAA6C;IAC7C,qBAAO,kEAAG,MAAM,QAAQ;IAG1B,IAAI,yBACF,gCAAC,0CAAc,QAAQ;QAAC,OAAA;OACrB,MAAM,QAAQ;IAInB,uFAAuF;IACvF,8EAA8E;IAC9E,4GAA4G;IAC5G,qBAAO,gCAAC,kBAAU;AACpB;AAIO,SAAS,0CAAmC,EAAwD;IACzG,IAAI,UAAU,CAAC,OAAU;QACvB,IAAI,WAAW,CAAA,GAAA,iBAAS,EAAE;QAC1B,IAAI,UACF,OAAO;QAGT,OAAO,GAAG,OAAO;IACnB;IACA,mCAAmC;IACnC,QAAQ,WAAW,GAAG,GAAG,WAAW,IAAI,GAAG,IAAI;IAC/C,OAAO,AAAC,CAAA,GAAA,iBAAS,EAAqB;AACxC;AAGO,SAAS;IACd,OAAO,CAAA,GAAA,iBAAS,EAAE;AACpB","sources":["packages/@react-aria/collections/src/Hidden.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {forwardRefType} from '@react-types/shared';\nimport React, {Context, createContext, forwardRef, JSX, ReactElement, ReactNode, useContext} from 'react';\n\n// React doesn't understand the <template> element, which doesn't have children like a normal element.\n// It will throw an error during hydration when it expects the firstChild to contain content rendered\n// on the server, when in reality, the browser will have placed this inside the `content` document fragment.\n// This monkey patches the firstChild property for our special hidden template elements to work around this error.\n// does the same for appendChild/removeChild/insertBefore as per the issue below\n// See https://github.com/facebook/react/issues/19932\nif (typeof HTMLTemplateElement !== 'undefined') {\n Object.defineProperty(HTMLTemplateElement.prototype, 'firstChild', {\n configurable: true,\n enumerable: true,\n get: function () {\n return this.content.firstChild;\n }\n });\n\n Object.defineProperty(HTMLTemplateElement.prototype, 'appendChild', {\n configurable: true,\n enumerable: true,\n value: function (node) {\n return this.content.appendChild(node);\n }\n });\n\n Object.defineProperty(HTMLTemplateElement.prototype, 'removeChild', {\n configurable: true,\n enumerable: true,\n value: function (node) {\n return this.content.removeChild(node);\n }\n });\n\n Object.defineProperty(HTMLTemplateElement.prototype, 'insertBefore', {\n configurable: true,\n enumerable: true,\n value: function (node, child) {\n return this.content.insertBefore(node, child);\n }\n });\n}\n\nexport const HiddenContext: Context<boolean> = createContext<boolean>(false);\n\nexport function Hidden(props: {children: ReactNode}): JSX.Element {\n let isHidden = useContext(HiddenContext);\n\n if (isHidden) {\n // Don't hide again if we are already hidden.\n return <>{props.children}</>;\n }\n\n let children = (\n <HiddenContext.Provider value>\n {props.children}\n </HiddenContext.Provider>\n );\n\n // In SSR, portals are not supported by React. Instead, always render into a <template>\n // element, which the browser will never display to the user. In addition, the\n // content is not part of the accessible DOM tree, so it won't affect ids or other accessibility attributes.\n return <template>{children}</template>;\n}\n\n/** Creates a component that forwards its ref and returns null if it is in a hidden subtree. */\n// Note: this function is handled specially in the documentation generator. If you change it, you'll need to update DocsTransformer as well.\nexport function createHideableComponent<T, P = {}>(fn: (props: P, ref: React.Ref<T>) => ReactElement | null): (props: P & React.RefAttributes<T>) => ReactElement | null {\n let Wrapper = (props: P, ref: React.Ref<T>) => {\n let isHidden = useContext(HiddenContext);\n if (isHidden) {\n return null;\n }\n\n return fn(props, ref);\n };\n // @ts-ignore - for react dev tools\n Wrapper.displayName = fn.displayName || fn.name;\n return (forwardRef as forwardRefType)(Wrapper);\n}\n\n/** Returns whether the component is in a hidden subtree. */\nexport function useIsHidden(): boolean {\n return useContext(HiddenContext);\n}\n"],"names":[],"version":3,"file":"Hidden.module.js.map"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { Collection as _Collection1, Key, Node } from "@react-types/shared";
|
|
2
|
-
import React, { ReactElement, ReactNode, ForwardedRef, JSX } from "react";
|
|
3
|
-
type FilterFn<T> = (textValue: string, node: Node<T>) => boolean;
|
|
4
|
-
/** An immutable object representing a Node in a Collection. */
|
|
5
|
-
export class CollectionNode<T> implements Node<T> {
|
|
6
|
-
static readonly type: string;
|
|
7
|
-
readonly type: string;
|
|
8
|
-
readonly key: Key;
|
|
9
|
-
readonly value: T | null;
|
|
10
|
-
readonly level: number;
|
|
11
|
-
readonly hasChildNodes: boolean;
|
|
12
|
-
readonly rendered: ReactNode;
|
|
13
|
-
readonly textValue: string;
|
|
14
|
-
readonly 'aria-label'?: string;
|
|
15
|
-
readonly index: number;
|
|
16
|
-
readonly parentKey: Key | null;
|
|
17
|
-
readonly prevKey: Key | null;
|
|
18
|
-
readonly nextKey: Key | null;
|
|
19
|
-
readonly firstChildKey: Key | null;
|
|
20
|
-
readonly lastChildKey: Key | null;
|
|
21
|
-
readonly props: any;
|
|
22
|
-
readonly render?: (node: Node<any>) => ReactElement;
|
|
23
|
-
readonly colSpan: number | null;
|
|
24
|
-
readonly colIndex: number | null;
|
|
25
|
-
constructor(key: Key);
|
|
26
|
-
get childNodes(): Iterable<Node<T>>;
|
|
27
|
-
clone(): this;
|
|
28
|
-
filter(collection: BaseCollection<T>, newCollection: BaseCollection<T>, filterFn: FilterFn<T>): CollectionNode<T> | null;
|
|
29
|
-
}
|
|
30
|
-
export class FilterableNode<T> extends CollectionNode<T> {
|
|
31
|
-
filter(collection: BaseCollection<T>, newCollection: BaseCollection<T>, filterFn: FilterFn<T>): CollectionNode<T> | null;
|
|
32
|
-
}
|
|
33
|
-
export class HeaderNode extends CollectionNode<unknown> {
|
|
34
|
-
static readonly type = "header";
|
|
35
|
-
}
|
|
36
|
-
export class LoaderNode extends CollectionNode<unknown> {
|
|
37
|
-
static readonly type = "loader";
|
|
38
|
-
}
|
|
39
|
-
export class ItemNode<T> extends FilterableNode<T> {
|
|
40
|
-
static readonly type = "item";
|
|
41
|
-
filter(collection: BaseCollection<T>, newCollection: BaseCollection<T>, filterFn: FilterFn<T>): ItemNode<T> | null;
|
|
42
|
-
}
|
|
43
|
-
export class SectionNode<T> extends FilterableNode<T> {
|
|
44
|
-
static readonly type = "section";
|
|
45
|
-
filter(collection: BaseCollection<T>, newCollection: BaseCollection<T>, filterFn: FilterFn<T>): SectionNode<T> | null;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* An immutable Collection implementation. Updates are only allowed
|
|
49
|
-
* when it is not marked as frozen. This can be subclassed to implement
|
|
50
|
-
* custom collection behaviors.
|
|
51
|
-
*/
|
|
52
|
-
export class BaseCollection<T> implements _Collection1<Node<T>> {
|
|
53
|
-
protected keyMap: Map<Key, CollectionNode<T>>;
|
|
54
|
-
protected firstKey: Key | null;
|
|
55
|
-
protected lastKey: Key | null;
|
|
56
|
-
protected frozen: boolean;
|
|
57
|
-
protected itemCount: number;
|
|
58
|
-
get size(): number;
|
|
59
|
-
getKeys(): IterableIterator<Key>;
|
|
60
|
-
[Symbol.iterator](): IterableIterator<Node<T>>;
|
|
61
|
-
getChildren(key: Key): Iterable<Node<T>>;
|
|
62
|
-
getKeyBefore(key: Key): Key | null;
|
|
63
|
-
getKeyAfter(key: Key): Key | null;
|
|
64
|
-
getFirstKey(): Key | null;
|
|
65
|
-
getLastKey(): Key | null;
|
|
66
|
-
getItem(key: Key): Node<T> | null;
|
|
67
|
-
at(): Node<T>;
|
|
68
|
-
clone(): this;
|
|
69
|
-
addNode(node: CollectionNode<T>): void;
|
|
70
|
-
addDescendants(node: CollectionNode<T>, oldCollection: BaseCollection<T>): void;
|
|
71
|
-
removeNode(key: Key): void;
|
|
72
|
-
commit(firstKey: Key | null, lastKey: Key | null, isSSR?: boolean): void;
|
|
73
|
-
filter(filterFn: FilterFn<T>): this;
|
|
74
|
-
}
|
|
75
|
-
export interface CachedChildrenOptions<T> {
|
|
76
|
-
/** Item objects in the collection. */
|
|
77
|
-
items?: Iterable<T>;
|
|
78
|
-
/** The contents of the collection. */
|
|
79
|
-
children?: ReactNode | ((item: T) => ReactNode);
|
|
80
|
-
/** Values that should invalidate the item cache when using dynamic collections. */
|
|
81
|
-
dependencies?: ReadonlyArray<any>;
|
|
82
|
-
/** A scope to prepend to all child item ids to ensure they are unique. */
|
|
83
|
-
idScope?: Key;
|
|
84
|
-
/** Whether to add `id` and `value` props to all child items. */
|
|
85
|
-
addIdAndValue?: boolean;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Maps over a list of items and renders React elements for them. Each rendered item is
|
|
89
|
-
* cached based on object identity, and React keys are generated from the `key` or `id` property.
|
|
90
|
-
*/
|
|
91
|
-
export function useCachedChildren<T extends object>(props: CachedChildrenOptions<T>): ReactNode;
|
|
92
|
-
/** Creates a component that forwards its ref and returns null if it is in a hidden subtree. */
|
|
93
|
-
export function createHideableComponent<T, P = {}>(fn: (props: P, ref: React.Ref<T>) => ReactElement | null): (props: P & React.RefAttributes<T>) => ReactElement | null;
|
|
94
|
-
/** Returns whether the component is in a hidden subtree. */
|
|
95
|
-
export function useIsHidden(): boolean;
|
|
96
|
-
export interface CollectionBuilderProps<C extends BaseCollection<object>> {
|
|
97
|
-
content: ReactNode;
|
|
98
|
-
children: (collection: C) => ReactNode;
|
|
99
|
-
createCollection?: () => C;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Builds a `Collection` from the children provided to the `content` prop, and passes it to the child render prop function.
|
|
103
|
-
*/
|
|
104
|
-
export function CollectionBuilder<C extends BaseCollection<object>>(props: CollectionBuilderProps<C>): ReactElement;
|
|
105
|
-
type CollectionNodeClass<T> = {
|
|
106
|
-
new (key: Key): CollectionNode<T>;
|
|
107
|
-
readonly type: string;
|
|
108
|
-
};
|
|
109
|
-
export function createLeafComponent<T extends object, P extends object, E extends Element>(CollectionNodeClass: CollectionNodeClass<any> | string, render: (props: P, ref: ForwardedRef<E>) => ReactElement | null): (props: P & React.RefAttributes<E>) => ReactElement | null;
|
|
110
|
-
export function createLeafComponent<T extends object, P extends object, E extends Element>(CollectionNodeClass: CollectionNodeClass<any> | string, render: (props: P, ref: ForwardedRef<E>, node: Node<T>) => ReactElement | null): (props: P & React.RefAttributes<E>) => ReactElement | null;
|
|
111
|
-
export function createBranchComponent<T extends object, P extends {
|
|
112
|
-
children?: any;
|
|
113
|
-
}, E extends Element>(CollectionNodeClass: CollectionNodeClass<any> | string, render: (props: P, ref: ForwardedRef<E>, node: Node<T>) => ReactElement | null, useChildren?: (props: P) => ReactNode): (props: P & React.RefAttributes<E>) => ReactElement | null;
|
|
114
|
-
export interface CollectionProps<T> extends CachedChildrenOptions<T> {
|
|
115
|
-
}
|
|
116
|
-
/** A Collection renders a list of items, automatically managing caching and keys. */
|
|
117
|
-
export function Collection<T extends object>(props: CollectionProps<T>): JSX.Element;
|
|
118
|
-
|
|
119
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;AAmBA,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,KAAK,OAAO,CAAC;AAEjE,+DAA+D;AAC/D,4BAA4B,CAAC,CAAE,YAAW,KAAK,CAAC,CAAC;IAC/C,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAQ;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAK;IAC3B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAS;IACxC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAQ;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,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AE,KAAK,CAAC,CAAC,KAAK,YAAY,GAAG,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,MAAM,aAAa,CAAC,CAAC,CAAC,KAAK,YAAY,GAAG,IAAI,CAAC;AAgC/R,sCAAsC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS;IAAC,QAAQ,CAAC,EAAE,GAAG,CAAA;CAAC,EAAE,CAAC,SAAS,OAAO,EAAE,qBAAqB,oBAAoB,GAAG,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,KAAK,YAAY,GAAG,IAAI,EAAE,WAAW,GAAE,CAAC,KAAK,EAAE,CAAC,KAAK,SAAiC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,MAAM,aAAa,CAAC,CAAC,CAAC,KAAK,YAAY,GAAG,IAAI,CASvW;AAMD,iCAAiC,CAAC,CAAE,SAAQ,sBAAsB,CAAC,CAAC;CAAG;AAIvE,qFAAqF;AACrF,2BAA2B,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC,GAAG,IAAI,OAAO,CA2BnF","sources":["packages/@react-aria/collections/src/packages/@react-aria/collections/src/BaseCollection.ts","packages/@react-aria/collections/src/packages/@react-aria/collections/src/Document.ts","packages/@react-aria/collections/src/packages/@react-aria/collections/src/useCachedChildren.ts","packages/@react-aria/collections/src/packages/@react-aria/collections/src/Hidden.tsx","packages/@react-aria/collections/src/packages/@react-aria/collections/src/CollectionBuilder.tsx","packages/@react-aria/collections/src/packages/@react-aria/collections/src/index.ts","packages/@react-aria/collections/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,"/*\n * Copyright 2024 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 {CollectionBuilder, Collection, createLeafComponent, createBranchComponent} from './CollectionBuilder';\nexport {createHideableComponent, useIsHidden} from './Hidden';\nexport {useCachedChildren} from './useCachedChildren';\nexport {BaseCollection, CollectionNode, ItemNode, SectionNode, FilterableNode, LoaderNode, HeaderNode} from './BaseCollection';\n\nexport type {CollectionBuilderProps, CollectionProps} from './CollectionBuilder';\nexport type {CachedChildrenOptions} from './useCachedChildren';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
var $6Tq0m$react = require("react");
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function $parcel$export(e, n, v, s) {
|
|
5
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
$parcel$export(module.exports, "useCachedChildren", () => $245f3f827bea6653$export$727c8fc270210f13);
|
|
9
|
-
/*
|
|
10
|
-
* Copyright 2024 Adobe. All rights reserved.
|
|
11
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
12
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
13
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
-
*
|
|
15
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
16
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
|
-
* governing permissions and limitations under the License.
|
|
19
|
-
*/
|
|
20
|
-
function $245f3f827bea6653$export$727c8fc270210f13(props) {
|
|
21
|
-
let { children: children, items: items, idScope: idScope, addIdAndValue: addIdAndValue, dependencies: dependencies = [] } = props;
|
|
22
|
-
// Invalidate the cache whenever the parent value changes.
|
|
23
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
-
let cache = (0, $6Tq0m$react.useMemo)(()=>new WeakMap(), dependencies);
|
|
25
|
-
return (0, $6Tq0m$react.useMemo)(()=>{
|
|
26
|
-
if (items && typeof children === 'function') {
|
|
27
|
-
let res = [];
|
|
28
|
-
for (let item of items){
|
|
29
|
-
let rendered = cache.get(item);
|
|
30
|
-
if (!rendered) {
|
|
31
|
-
rendered = children(item);
|
|
32
|
-
var _rendered_props_id, _ref;
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
let key = (_ref = (_rendered_props_id = rendered.props.id) !== null && _rendered_props_id !== void 0 ? _rendered_props_id : item.key) !== null && _ref !== void 0 ? _ref : item.id;
|
|
35
|
-
if (key == null) throw new Error('Could not determine key for item');
|
|
36
|
-
if (idScope != null) key = idScope + ':' + key;
|
|
37
|
-
// Note: only works if wrapped Item passes through id...
|
|
38
|
-
rendered = (0, $6Tq0m$react.cloneElement)(rendered, addIdAndValue ? {
|
|
39
|
-
key: key,
|
|
40
|
-
id: key,
|
|
41
|
-
value: item
|
|
42
|
-
} : {
|
|
43
|
-
key: key
|
|
44
|
-
});
|
|
45
|
-
cache.set(item, rendered);
|
|
46
|
-
}
|
|
47
|
-
res.push(rendered);
|
|
48
|
-
}
|
|
49
|
-
return res;
|
|
50
|
-
} else if (typeof children !== 'function') return children;
|
|
51
|
-
}, [
|
|
52
|
-
children,
|
|
53
|
-
items,
|
|
54
|
-
cache,
|
|
55
|
-
idScope,
|
|
56
|
-
addIdAndValue
|
|
57
|
-
]);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
//# sourceMappingURL=useCachedChildren.main.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAsBM,SAAS,0CAAoC,KAA+B;IACjF,IAAI,YAAC,QAAQ,SAAE,KAAK,WAAE,OAAO,iBAAE,aAAa,gBAAE,eAAe,EAAE,EAAC,GAAG;IAEnE,0DAA0D;IAC1D,uDAAuD;IACvD,IAAI,QAAQ,CAAA,GAAA,oBAAM,EAAE,IAAM,IAAI,WAAW;IACzC,OAAO,CAAA,GAAA,oBAAM,EAAE;QACb,IAAI,SAAS,OAAO,aAAa,YAAY;YAC3C,IAAI,MAAsB,EAAE;YAC5B,KAAK,IAAI,QAAQ,MAAO;gBACtB,IAAI,WAAW,MAAM,GAAG,CAAC;gBACzB,IAAI,CAAC,UAAU;oBACb,WAAW,SAAS;wBAEV,oBAAA;oBADV,aAAa;oBACb,IAAI,MAAM,CAAA,OAAA,CAAA,qBAAA,SAAS,KAAK,CAAC,EAAE,cAAjB,gCAAA,qBAAqB,KAAK,GAAG,cAA7B,kBAAA,OAAiC,KAAK,EAAE;oBAElD,IAAI,OAAO,MACT,MAAM,IAAI,MAAM;oBAGlB,IAAI,WAAW,MACb,MAAM,UAAU,MAAM;oBAExB,wDAAwD;oBACxD,WAAW,CAAA,GAAA,yBAAW,EACpB,UACA,gBAAgB;6BAAC;wBAAK,IAAI;wBAAK,OAAO;oBAAI,IAAI;6BAAC;oBAAG;oBAEpD,MAAM,GAAG,CAAC,MAAM;gBAClB;gBACA,IAAI,IAAI,CAAC;YACX;YACA,OAAO;QACT,OAAO,IAAI,OAAO,aAAa,YAC7B,OAAO;IAEX,GAAG;QAAC;QAAU;QAAO;QAAO;QAAS;KAAc;AACrD","sources":["packages/@react-aria/collections/src/useCachedChildren.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {cloneElement, ReactElement, ReactNode, useMemo} from 'react';\nimport {Key} from '@react-types/shared';\n\nexport interface CachedChildrenOptions<T> {\n /** Item objects in the collection. */\n items?: Iterable<T>,\n /** The contents of the collection. */\n children?: ReactNode | ((item: T) => ReactNode),\n /** Values that should invalidate the item cache when using dynamic collections. */\n dependencies?: ReadonlyArray<any>,\n /** A scope to prepend to all child item ids to ensure they are unique. */\n idScope?: Key,\n /** Whether to add `id` and `value` props to all child items. */\n addIdAndValue?: boolean\n}\n\n/**\n * Maps over a list of items and renders React elements for them. Each rendered item is\n * cached based on object identity, and React keys are generated from the `key` or `id` property.\n */\nexport function useCachedChildren<T extends object>(props: CachedChildrenOptions<T>): ReactNode {\n let {children, items, idScope, addIdAndValue, dependencies = []} = props;\n\n // Invalidate the cache whenever the parent value changes.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n let cache = useMemo(() => new WeakMap(), dependencies);\n return useMemo(() => {\n if (items && typeof children === 'function') {\n let res: ReactElement[] = [];\n for (let item of items) {\n let rendered = cache.get(item);\n if (!rendered) {\n rendered = children(item);\n // @ts-ignore\n let key = rendered.props.id ?? item.key ?? item.id;\n\n if (key == null) {\n throw new Error('Could not determine key for item');\n }\n\n if (idScope != null) {\n key = idScope + ':' + key;\n }\n // Note: only works if wrapped Item passes through id...\n rendered = cloneElement(\n rendered,\n addIdAndValue ? {key, id: key, value: item} : {key}\n );\n cache.set(item, rendered);\n }\n res.push(rendered);\n }\n return res;\n } else if (typeof children !== 'function') {\n return children;\n }\n }, [children, items, cache, idScope, addIdAndValue]);\n}\n"],"names":[],"version":3,"file":"useCachedChildren.main.js.map"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {useMemo as $luMFQ$useMemo, cloneElement as $luMFQ$cloneElement} from "react";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright 2024 Adobe. All rights reserved.
|
|
5
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
-
* governing permissions and limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
function $e948873055cbafe4$export$727c8fc270210f13(props) {
|
|
15
|
-
let { children: children, items: items, idScope: idScope, addIdAndValue: addIdAndValue, dependencies: dependencies = [] } = props;
|
|
16
|
-
// Invalidate the cache whenever the parent value changes.
|
|
17
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
18
|
-
let cache = (0, $luMFQ$useMemo)(()=>new WeakMap(), dependencies);
|
|
19
|
-
return (0, $luMFQ$useMemo)(()=>{
|
|
20
|
-
if (items && typeof children === 'function') {
|
|
21
|
-
let res = [];
|
|
22
|
-
for (let item of items){
|
|
23
|
-
let rendered = cache.get(item);
|
|
24
|
-
if (!rendered) {
|
|
25
|
-
rendered = children(item);
|
|
26
|
-
var _rendered_props_id, _ref;
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
let key = (_ref = (_rendered_props_id = rendered.props.id) !== null && _rendered_props_id !== void 0 ? _rendered_props_id : item.key) !== null && _ref !== void 0 ? _ref : item.id;
|
|
29
|
-
if (key == null) throw new Error('Could not determine key for item');
|
|
30
|
-
if (idScope != null) key = idScope + ':' + key;
|
|
31
|
-
// Note: only works if wrapped Item passes through id...
|
|
32
|
-
rendered = (0, $luMFQ$cloneElement)(rendered, addIdAndValue ? {
|
|
33
|
-
key: key,
|
|
34
|
-
id: key,
|
|
35
|
-
value: item
|
|
36
|
-
} : {
|
|
37
|
-
key: key
|
|
38
|
-
});
|
|
39
|
-
cache.set(item, rendered);
|
|
40
|
-
}
|
|
41
|
-
res.push(rendered);
|
|
42
|
-
}
|
|
43
|
-
return res;
|
|
44
|
-
} else if (typeof children !== 'function') return children;
|
|
45
|
-
}, [
|
|
46
|
-
children,
|
|
47
|
-
items,
|
|
48
|
-
cache,
|
|
49
|
-
idScope,
|
|
50
|
-
addIdAndValue
|
|
51
|
-
]);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
export {$e948873055cbafe4$export$727c8fc270210f13 as useCachedChildren};
|
|
56
|
-
//# sourceMappingURL=useCachedChildren.module.js.map
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {useMemo as $luMFQ$useMemo, cloneElement as $luMFQ$cloneElement} from "react";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright 2024 Adobe. All rights reserved.
|
|
5
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
-
* governing permissions and limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
function $e948873055cbafe4$export$727c8fc270210f13(props) {
|
|
15
|
-
let { children: children, items: items, idScope: idScope, addIdAndValue: addIdAndValue, dependencies: dependencies = [] } = props;
|
|
16
|
-
// Invalidate the cache whenever the parent value changes.
|
|
17
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
18
|
-
let cache = (0, $luMFQ$useMemo)(()=>new WeakMap(), dependencies);
|
|
19
|
-
return (0, $luMFQ$useMemo)(()=>{
|
|
20
|
-
if (items && typeof children === 'function') {
|
|
21
|
-
let res = [];
|
|
22
|
-
for (let item of items){
|
|
23
|
-
let rendered = cache.get(item);
|
|
24
|
-
if (!rendered) {
|
|
25
|
-
rendered = children(item);
|
|
26
|
-
var _rendered_props_id, _ref;
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
let key = (_ref = (_rendered_props_id = rendered.props.id) !== null && _rendered_props_id !== void 0 ? _rendered_props_id : item.key) !== null && _ref !== void 0 ? _ref : item.id;
|
|
29
|
-
if (key == null) throw new Error('Could not determine key for item');
|
|
30
|
-
if (idScope != null) key = idScope + ':' + key;
|
|
31
|
-
// Note: only works if wrapped Item passes through id...
|
|
32
|
-
rendered = (0, $luMFQ$cloneElement)(rendered, addIdAndValue ? {
|
|
33
|
-
key: key,
|
|
34
|
-
id: key,
|
|
35
|
-
value: item
|
|
36
|
-
} : {
|
|
37
|
-
key: key
|
|
38
|
-
});
|
|
39
|
-
cache.set(item, rendered);
|
|
40
|
-
}
|
|
41
|
-
res.push(rendered);
|
|
42
|
-
}
|
|
43
|
-
return res;
|
|
44
|
-
} else if (typeof children !== 'function') return children;
|
|
45
|
-
}, [
|
|
46
|
-
children,
|
|
47
|
-
items,
|
|
48
|
-
cache,
|
|
49
|
-
idScope,
|
|
50
|
-
addIdAndValue
|
|
51
|
-
]);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
export {$e948873055cbafe4$export$727c8fc270210f13 as useCachedChildren};
|
|
56
|
-
//# sourceMappingURL=useCachedChildren.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAsBM,SAAS,0CAAoC,KAA+B;IACjF,IAAI,YAAC,QAAQ,SAAE,KAAK,WAAE,OAAO,iBAAE,aAAa,gBAAE,eAAe,EAAE,EAAC,GAAG;IAEnE,0DAA0D;IAC1D,uDAAuD;IACvD,IAAI,QAAQ,CAAA,GAAA,cAAM,EAAE,IAAM,IAAI,WAAW;IACzC,OAAO,CAAA,GAAA,cAAM,EAAE;QACb,IAAI,SAAS,OAAO,aAAa,YAAY;YAC3C,IAAI,MAAsB,EAAE;YAC5B,KAAK,IAAI,QAAQ,MAAO;gBACtB,IAAI,WAAW,MAAM,GAAG,CAAC;gBACzB,IAAI,CAAC,UAAU;oBACb,WAAW,SAAS;wBAEV,oBAAA;oBADV,aAAa;oBACb,IAAI,MAAM,CAAA,OAAA,CAAA,qBAAA,SAAS,KAAK,CAAC,EAAE,cAAjB,gCAAA,qBAAqB,KAAK,GAAG,cAA7B,kBAAA,OAAiC,KAAK,EAAE;oBAElD,IAAI,OAAO,MACT,MAAM,IAAI,MAAM;oBAGlB,IAAI,WAAW,MACb,MAAM,UAAU,MAAM;oBAExB,wDAAwD;oBACxD,WAAW,CAAA,GAAA,mBAAW,EACpB,UACA,gBAAgB;6BAAC;wBAAK,IAAI;wBAAK,OAAO;oBAAI,IAAI;6BAAC;oBAAG;oBAEpD,MAAM,GAAG,CAAC,MAAM;gBAClB;gBACA,IAAI,IAAI,CAAC;YACX;YACA,OAAO;QACT,OAAO,IAAI,OAAO,aAAa,YAC7B,OAAO;IAEX,GAAG;QAAC;QAAU;QAAO;QAAO;QAAS;KAAc;AACrD","sources":["packages/@react-aria/collections/src/useCachedChildren.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {cloneElement, ReactElement, ReactNode, useMemo} from 'react';\nimport {Key} from '@react-types/shared';\n\nexport interface CachedChildrenOptions<T> {\n /** Item objects in the collection. */\n items?: Iterable<T>,\n /** The contents of the collection. */\n children?: ReactNode | ((item: T) => ReactNode),\n /** Values that should invalidate the item cache when using dynamic collections. */\n dependencies?: ReadonlyArray<any>,\n /** A scope to prepend to all child item ids to ensure they are unique. */\n idScope?: Key,\n /** Whether to add `id` and `value` props to all child items. */\n addIdAndValue?: boolean\n}\n\n/**\n * Maps over a list of items and renders React elements for them. Each rendered item is\n * cached based on object identity, and React keys are generated from the `key` or `id` property.\n */\nexport function useCachedChildren<T extends object>(props: CachedChildrenOptions<T>): ReactNode {\n let {children, items, idScope, addIdAndValue, dependencies = []} = props;\n\n // Invalidate the cache whenever the parent value changes.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n let cache = useMemo(() => new WeakMap(), dependencies);\n return useMemo(() => {\n if (items && typeof children === 'function') {\n let res: ReactElement[] = [];\n for (let item of items) {\n let rendered = cache.get(item);\n if (!rendered) {\n rendered = children(item);\n // @ts-ignore\n let key = rendered.props.id ?? item.key ?? item.id;\n\n if (key == null) {\n throw new Error('Could not determine key for item');\n }\n\n if (idScope != null) {\n key = idScope + ':' + key;\n }\n // Note: only works if wrapped Item passes through id...\n rendered = cloneElement(\n rendered,\n addIdAndValue ? {key, id: key, value: item} : {key}\n );\n cache.set(item, rendered);\n }\n res.push(rendered);\n }\n return res;\n } else if (typeof children !== 'function') {\n return children;\n }\n }, [children, items, cache, idScope, addIdAndValue]);\n}\n"],"names":[],"version":3,"file":"useCachedChildren.module.js.map"}
|