@react-stately/collections 3.10.5 → 3.10.7
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/CollectionBuilder.main.js +194 -0
- package/dist/CollectionBuilder.main.js.map +1 -0
- package/dist/CollectionBuilder.mjs +185 -0
- package/dist/CollectionBuilder.module.js +185 -0
- package/dist/CollectionBuilder.module.js.map +1 -0
- package/dist/Item.main.js +68 -0
- package/dist/Item.main.js.map +1 -0
- package/dist/Item.mjs +59 -0
- package/dist/Item.module.js +59 -0
- package/dist/Item.module.js.map +1 -0
- package/dist/Section.main.js +60 -0
- package/dist/Section.main.js.map +1 -0
- package/dist/Section.mjs +51 -0
- package/dist/Section.module.js +51 -0
- package/dist/Section.module.js.map +1 -0
- package/dist/getChildNodes.main.js +80 -0
- package/dist/getChildNodes.main.js.map +1 -0
- package/dist/getChildNodes.mjs +71 -0
- package/dist/getChildNodes.module.js +71 -0
- package/dist/getChildNodes.module.js.map +1 -0
- package/dist/getItemCount.main.js +35 -0
- package/dist/getItemCount.main.js.map +1 -0
- package/dist/getItemCount.mjs +30 -0
- package/dist/getItemCount.module.js +30 -0
- package/dist/getItemCount.module.js.map +1 -0
- package/dist/import.mjs +6 -407
- package/dist/main.js +16 -421
- package/dist/main.js.map +1 -1
- package/dist/module.js +6 -407
- package/dist/module.js.map +1 -1
- package/dist/useCollection.main.js +44 -0
- package/dist/useCollection.main.js.map +1 -0
- package/dist/useCollection.mjs +39 -0
- package/dist/useCollection.module.js +39 -0
- package/dist/useCollection.module.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var $5Zch8$react = require("react");
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function $parcel$interopDefault(a) {
|
|
5
|
+
return a && a.__esModule ? a.default : a;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function $parcel$export(e, n, v, s) {
|
|
9
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
$parcel$export(module.exports, "Item", () => $c870f3b549c61b6b$export$6d08773d2e66f8f2);
|
|
13
|
+
/*
|
|
14
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
15
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
16
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
17
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
20
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
21
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
22
|
+
* governing permissions and limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
function $c870f3b549c61b6b$var$Item(props) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
$c870f3b549c61b6b$var$Item.getCollectionNode = function* getCollectionNode(props, context) {
|
|
28
|
+
let { childItems: childItems, title: title, children: children } = props;
|
|
29
|
+
let rendered = props.title || props.children;
|
|
30
|
+
let textValue = props.textValue || (typeof rendered === 'string' ? rendered : '') || props['aria-label'] || '';
|
|
31
|
+
// suppressTextValueWarning is used in components like Tabs, which don't have type to select support.
|
|
32
|
+
if (!textValue && !(context === null || context === void 0 ? void 0 : context.suppressTextValueWarning)) console.warn('<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop.');
|
|
33
|
+
yield {
|
|
34
|
+
type: 'item',
|
|
35
|
+
props: props,
|
|
36
|
+
rendered: rendered,
|
|
37
|
+
textValue: textValue,
|
|
38
|
+
'aria-label': props['aria-label'],
|
|
39
|
+
hasChildNodes: $c870f3b549c61b6b$var$hasChildItems(props),
|
|
40
|
+
*childNodes () {
|
|
41
|
+
if (childItems) for (let child of childItems)yield {
|
|
42
|
+
type: 'item',
|
|
43
|
+
value: child
|
|
44
|
+
};
|
|
45
|
+
else if (title) {
|
|
46
|
+
let items = [];
|
|
47
|
+
(0, ($parcel$interopDefault($5Zch8$react))).Children.forEach(children, (child)=>{
|
|
48
|
+
items.push({
|
|
49
|
+
type: 'item',
|
|
50
|
+
element: child
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
yield* items;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
function $c870f3b549c61b6b$var$hasChildItems(props) {
|
|
59
|
+
if (props.hasChildItems != null) return props.hasChildItems;
|
|
60
|
+
if (props.childItems) return true;
|
|
61
|
+
if (props.title && (0, ($parcel$interopDefault($5Zch8$react))).Children.count(props.children) > 0) return true;
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
// We don't want getCollectionNode to show up in the type definition
|
|
65
|
+
let $c870f3b549c61b6b$export$6d08773d2e66f8f2 = $c870f3b549c61b6b$var$Item;
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=Item.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAMD,SAAS,2BAAQ,KAAmB;IAClC,OAAO;AACT;AAEA,2BAAK,iBAAiB,GAAG,UAAU,kBAAqB,KAAmB,EAAE,OAAY;IACvF,IAAI,cAAC,UAAU,SAAE,KAAK,YAAE,QAAQ,EAAC,GAAG;IAEpC,IAAI,WAAW,MAAM,KAAK,IAAI,MAAM,QAAQ;IAC5C,IAAI,YAAY,MAAM,SAAS,IAAK,CAAA,OAAO,aAAa,WAAW,WAAW,EAAC,KAAM,KAAK,CAAC,aAAa,IAAI;IAE5G,qGAAqG;IACrG,IAAI,CAAC,aAAa,EAAC,oBAAA,8BAAA,QAAS,wBAAwB,GAClD,QAAQ,IAAI,CAAC;IAGf,MAAM;QACJ,MAAM;QACN,OAAO;kBACP;mBACA;QACA,cAAc,KAAK,CAAC,aAAa;QACjC,eAAe,oCAAc;QAC7B,CAAC;YACC,IAAI,YACF,KAAK,IAAI,SAAS,WAChB,MAAM;gBACJ,MAAM;gBACN,OAAO;YACT;iBAEG,IAAI,OAAO;gBAChB,IAAI,QAA0B,EAAE;gBAChC,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAA;oBAC/B,MAAM,IAAI,CAAC;wBACT,MAAM;wBACN,SAAS;oBACX;gBACF;gBAEA,OAAO;YACT;QACF;IACF;AACF;AAEA,SAAS,oCAAiB,KAAmB;IAC3C,IAAI,MAAM,aAAa,IAAI,MACzB,OAAO,MAAM,aAAa;IAG5B,IAAI,MAAM,UAAU,EAClB,OAAO;IAGT,IAAI,MAAM,KAAK,IAAI,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,QAAQ,IAAI,GACxD,OAAO;IAGT,OAAO;AACT;AAEA,oEAAoE;AACpE,IAAI,4CAAQ","sources":["packages/@react-stately/collections/src/Item.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 {ItemElement, ItemProps} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {JSX, ReactElement} from 'react';\n\nfunction Item<T>(props: ItemProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nItem.getCollectionNode = function* getCollectionNode<T>(props: ItemProps<T>, context: any): Generator<PartialNode<T>> {\n let {childItems, title, children} = props;\n\n let rendered = props.title || props.children;\n let textValue = props.textValue || (typeof rendered === 'string' ? rendered : '') || props['aria-label'] || '';\n\n // suppressTextValueWarning is used in components like Tabs, which don't have type to select support.\n if (!textValue && !context?.suppressTextValueWarning) {\n console.warn('<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop.');\n }\n\n yield {\n type: 'item',\n props: props,\n rendered,\n textValue,\n 'aria-label': props['aria-label'],\n hasChildNodes: hasChildItems(props),\n *childNodes() {\n if (childItems) {\n for (let child of childItems) {\n yield {\n type: 'item',\n value: child\n };\n }\n } else if (title) {\n let items: PartialNode<T>[] = [];\n React.Children.forEach(children, child => {\n items.push({\n type: 'item',\n element: child as ItemElement<T>\n });\n });\n\n yield* items;\n }\n }\n };\n};\n\nfunction hasChildItems<T>(props: ItemProps<T>) {\n if (props.hasChildItems != null) {\n return props.hasChildItems;\n }\n\n if (props.childItems) {\n return true;\n }\n\n if (props.title && React.Children.count(props.children) > 0) {\n return true;\n }\n\n return false;\n}\n\n// We don't want getCollectionNode to show up in the type definition\nlet _Item = Item as <T>(props: ItemProps<T>) => JSX.Element;\nexport {_Item as Item};\n"],"names":[],"version":3,"file":"Item.main.js.map"}
|
package/dist/Item.mjs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import $6Fm0V$react from "react";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 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 $c1d7fb2ec91bae71$var$Item(props) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
$c1d7fb2ec91bae71$var$Item.getCollectionNode = function* getCollectionNode(props, context) {
|
|
18
|
+
let { childItems: childItems, title: title, children: children } = props;
|
|
19
|
+
let rendered = props.title || props.children;
|
|
20
|
+
let textValue = props.textValue || (typeof rendered === 'string' ? rendered : '') || props['aria-label'] || '';
|
|
21
|
+
// suppressTextValueWarning is used in components like Tabs, which don't have type to select support.
|
|
22
|
+
if (!textValue && !(context === null || context === void 0 ? void 0 : context.suppressTextValueWarning)) console.warn('<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop.');
|
|
23
|
+
yield {
|
|
24
|
+
type: 'item',
|
|
25
|
+
props: props,
|
|
26
|
+
rendered: rendered,
|
|
27
|
+
textValue: textValue,
|
|
28
|
+
'aria-label': props['aria-label'],
|
|
29
|
+
hasChildNodes: $c1d7fb2ec91bae71$var$hasChildItems(props),
|
|
30
|
+
*childNodes () {
|
|
31
|
+
if (childItems) for (let child of childItems)yield {
|
|
32
|
+
type: 'item',
|
|
33
|
+
value: child
|
|
34
|
+
};
|
|
35
|
+
else if (title) {
|
|
36
|
+
let items = [];
|
|
37
|
+
(0, $6Fm0V$react).Children.forEach(children, (child)=>{
|
|
38
|
+
items.push({
|
|
39
|
+
type: 'item',
|
|
40
|
+
element: child
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
yield* items;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
function $c1d7fb2ec91bae71$var$hasChildItems(props) {
|
|
49
|
+
if (props.hasChildItems != null) return props.hasChildItems;
|
|
50
|
+
if (props.childItems) return true;
|
|
51
|
+
if (props.title && (0, $6Fm0V$react).Children.count(props.children) > 0) return true;
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
// We don't want getCollectionNode to show up in the type definition
|
|
55
|
+
let $c1d7fb2ec91bae71$export$6d08773d2e66f8f2 = $c1d7fb2ec91bae71$var$Item;
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
export {$c1d7fb2ec91bae71$export$6d08773d2e66f8f2 as Item};
|
|
59
|
+
//# sourceMappingURL=Item.module.js.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import $6Fm0V$react from "react";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 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 $c1d7fb2ec91bae71$var$Item(props) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
$c1d7fb2ec91bae71$var$Item.getCollectionNode = function* getCollectionNode(props, context) {
|
|
18
|
+
let { childItems: childItems, title: title, children: children } = props;
|
|
19
|
+
let rendered = props.title || props.children;
|
|
20
|
+
let textValue = props.textValue || (typeof rendered === 'string' ? rendered : '') || props['aria-label'] || '';
|
|
21
|
+
// suppressTextValueWarning is used in components like Tabs, which don't have type to select support.
|
|
22
|
+
if (!textValue && !(context === null || context === void 0 ? void 0 : context.suppressTextValueWarning)) console.warn('<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop.');
|
|
23
|
+
yield {
|
|
24
|
+
type: 'item',
|
|
25
|
+
props: props,
|
|
26
|
+
rendered: rendered,
|
|
27
|
+
textValue: textValue,
|
|
28
|
+
'aria-label': props['aria-label'],
|
|
29
|
+
hasChildNodes: $c1d7fb2ec91bae71$var$hasChildItems(props),
|
|
30
|
+
*childNodes () {
|
|
31
|
+
if (childItems) for (let child of childItems)yield {
|
|
32
|
+
type: 'item',
|
|
33
|
+
value: child
|
|
34
|
+
};
|
|
35
|
+
else if (title) {
|
|
36
|
+
let items = [];
|
|
37
|
+
(0, $6Fm0V$react).Children.forEach(children, (child)=>{
|
|
38
|
+
items.push({
|
|
39
|
+
type: 'item',
|
|
40
|
+
element: child
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
yield* items;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
function $c1d7fb2ec91bae71$var$hasChildItems(props) {
|
|
49
|
+
if (props.hasChildItems != null) return props.hasChildItems;
|
|
50
|
+
if (props.childItems) return true;
|
|
51
|
+
if (props.title && (0, $6Fm0V$react).Children.count(props.children) > 0) return true;
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
// We don't want getCollectionNode to show up in the type definition
|
|
55
|
+
let $c1d7fb2ec91bae71$export$6d08773d2e66f8f2 = $c1d7fb2ec91bae71$var$Item;
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
export {$c1d7fb2ec91bae71$export$6d08773d2e66f8f2 as Item};
|
|
59
|
+
//# sourceMappingURL=Item.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAMD,SAAS,2BAAQ,KAAmB;IAClC,OAAO;AACT;AAEA,2BAAK,iBAAiB,GAAG,UAAU,kBAAqB,KAAmB,EAAE,OAAY;IACvF,IAAI,cAAC,UAAU,SAAE,KAAK,YAAE,QAAQ,EAAC,GAAG;IAEpC,IAAI,WAAW,MAAM,KAAK,IAAI,MAAM,QAAQ;IAC5C,IAAI,YAAY,MAAM,SAAS,IAAK,CAAA,OAAO,aAAa,WAAW,WAAW,EAAC,KAAM,KAAK,CAAC,aAAa,IAAI;IAE5G,qGAAqG;IACrG,IAAI,CAAC,aAAa,EAAC,oBAAA,8BAAA,QAAS,wBAAwB,GAClD,QAAQ,IAAI,CAAC;IAGf,MAAM;QACJ,MAAM;QACN,OAAO;kBACP;mBACA;QACA,cAAc,KAAK,CAAC,aAAa;QACjC,eAAe,oCAAc;QAC7B,CAAC;YACC,IAAI,YACF,KAAK,IAAI,SAAS,WAChB,MAAM;gBACJ,MAAM;gBACN,OAAO;YACT;iBAEG,IAAI,OAAO;gBAChB,IAAI,QAA0B,EAAE;gBAChC,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAA;oBAC/B,MAAM,IAAI,CAAC;wBACT,MAAM;wBACN,SAAS;oBACX;gBACF;gBAEA,OAAO;YACT;QACF;IACF;AACF;AAEA,SAAS,oCAAiB,KAAmB;IAC3C,IAAI,MAAM,aAAa,IAAI,MACzB,OAAO,MAAM,aAAa;IAG5B,IAAI,MAAM,UAAU,EAClB,OAAO;IAGT,IAAI,MAAM,KAAK,IAAI,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,QAAQ,IAAI,GACxD,OAAO;IAGT,OAAO;AACT;AAEA,oEAAoE;AACpE,IAAI,4CAAQ","sources":["packages/@react-stately/collections/src/Item.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 {ItemElement, ItemProps} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {JSX, ReactElement} from 'react';\n\nfunction Item<T>(props: ItemProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nItem.getCollectionNode = function* getCollectionNode<T>(props: ItemProps<T>, context: any): Generator<PartialNode<T>> {\n let {childItems, title, children} = props;\n\n let rendered = props.title || props.children;\n let textValue = props.textValue || (typeof rendered === 'string' ? rendered : '') || props['aria-label'] || '';\n\n // suppressTextValueWarning is used in components like Tabs, which don't have type to select support.\n if (!textValue && !context?.suppressTextValueWarning) {\n console.warn('<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop.');\n }\n\n yield {\n type: 'item',\n props: props,\n rendered,\n textValue,\n 'aria-label': props['aria-label'],\n hasChildNodes: hasChildItems(props),\n *childNodes() {\n if (childItems) {\n for (let child of childItems) {\n yield {\n type: 'item',\n value: child\n };\n }\n } else if (title) {\n let items: PartialNode<T>[] = [];\n React.Children.forEach(children, child => {\n items.push({\n type: 'item',\n element: child as ItemElement<T>\n });\n });\n\n yield* items;\n }\n }\n };\n};\n\nfunction hasChildItems<T>(props: ItemProps<T>) {\n if (props.hasChildItems != null) {\n return props.hasChildItems;\n }\n\n if (props.childItems) {\n return true;\n }\n\n if (props.title && React.Children.count(props.children) > 0) {\n return true;\n }\n\n return false;\n}\n\n// We don't want getCollectionNode to show up in the type definition\nlet _Item = Item as <T>(props: ItemProps<T>) => JSX.Element;\nexport {_Item as Item};\n"],"names":[],"version":3,"file":"Item.module.js.map"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var $98hxh$react = require("react");
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function $parcel$interopDefault(a) {
|
|
5
|
+
return a && a.__esModule ? a.default : a;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function $parcel$export(e, n, v, s) {
|
|
9
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
$parcel$export(module.exports, "Section", () => $350f13aa4d8b327c$export$6e2c8f0811a474ce);
|
|
13
|
+
/*
|
|
14
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
15
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
16
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
17
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
20
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
21
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
22
|
+
* governing permissions and limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
function $350f13aa4d8b327c$var$Section(props) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
$350f13aa4d8b327c$var$Section.getCollectionNode = function* getCollectionNode(props) {
|
|
28
|
+
let { children: children, title: title, items: items } = props;
|
|
29
|
+
yield {
|
|
30
|
+
type: 'section',
|
|
31
|
+
props: props,
|
|
32
|
+
hasChildNodes: true,
|
|
33
|
+
rendered: title,
|
|
34
|
+
'aria-label': props['aria-label'],
|
|
35
|
+
*childNodes () {
|
|
36
|
+
if (typeof children === 'function') {
|
|
37
|
+
if (!items) throw new Error('props.children was a function but props.items is missing');
|
|
38
|
+
for (let item of items)yield {
|
|
39
|
+
type: 'item',
|
|
40
|
+
value: item,
|
|
41
|
+
renderer: children
|
|
42
|
+
};
|
|
43
|
+
} else {
|
|
44
|
+
let items = [];
|
|
45
|
+
(0, ($parcel$interopDefault($98hxh$react))).Children.forEach(children, (child)=>{
|
|
46
|
+
items.push({
|
|
47
|
+
type: 'item',
|
|
48
|
+
element: child
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
yield* items;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
// We don't want getCollectionNode to show up in the type definition
|
|
57
|
+
let $350f13aa4d8b327c$export$6e2c8f0811a474ce = $350f13aa4d8b327c$var$Section;
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=Section.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAMD,SAAS,8BAAW,KAAsB;IACxC,OAAO;AACT;AAEA,8BAAQ,iBAAiB,GAAG,UAAU,kBAAqB,KAAsB;IAC/E,IAAI,YAAC,QAAQ,SAAE,KAAK,SAAE,KAAK,EAAC,GAAG;IAC/B,MAAM;QACJ,MAAM;QACN,OAAO;QACP,eAAe;QACf,UAAU;QACV,cAAc,KAAK,CAAC,aAAa;QACjC,CAAC;YACC,IAAI,OAAO,aAAa,YAAY;gBAClC,IAAI,CAAC,OACH,MAAM,IAAI,MAAM;gBAGlB,KAAK,IAAI,QAAQ,MACf,MAAM;oBACJ,MAAM;oBACN,OAAO;oBACP,UAAU;gBACZ;YAEJ,OAAO;gBACL,IAAI,QAA0B,EAAE;gBAChC,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAA;oBAC/B,MAAM,IAAI,CAAC;wBACT,MAAM;wBACN,SAAS;oBACX;gBACF;gBAEA,OAAO;YACT;QACF;IACF;AACF;AAEA,oEAAoE;AACpE,IAAI,4CAAW","sources":["packages/@react-stately/collections/src/Section.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 {PartialNode} from './types';\nimport React, {JSX, ReactElement} from 'react';\nimport {SectionProps} from '@react-types/shared';\n\nfunction Section<T>(props: SectionProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nSection.getCollectionNode = function* getCollectionNode<T>(props: SectionProps<T>): Generator<PartialNode<T>> {\n let {children, title, items} = props;\n yield {\n type: 'section',\n props: props,\n hasChildNodes: true,\n rendered: title,\n 'aria-label': props['aria-label'],\n *childNodes() {\n if (typeof children === 'function') {\n if (!items) {\n throw new Error('props.children was a function but props.items is missing');\n }\n\n for (let item of items) {\n yield {\n type: 'item',\n value: item,\n renderer: children\n };\n }\n } else {\n let items: PartialNode<T>[] = [];\n React.Children.forEach(children, child => {\n items.push({\n type: 'item',\n element: child\n });\n });\n\n yield* items;\n }\n }\n };\n};\n\n// We don't want getCollectionNode to show up in the type definition\nlet _Section = Section as <T>(props: SectionProps<T>) => JSX.Element;\nexport {_Section as Section};\n"],"names":[],"version":3,"file":"Section.main.js.map"}
|
package/dist/Section.mjs
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import $gtysd$react from "react";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 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 $9fc4852771d079eb$var$Section(props) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
$9fc4852771d079eb$var$Section.getCollectionNode = function* getCollectionNode(props) {
|
|
18
|
+
let { children: children, title: title, items: items } = props;
|
|
19
|
+
yield {
|
|
20
|
+
type: 'section',
|
|
21
|
+
props: props,
|
|
22
|
+
hasChildNodes: true,
|
|
23
|
+
rendered: title,
|
|
24
|
+
'aria-label': props['aria-label'],
|
|
25
|
+
*childNodes () {
|
|
26
|
+
if (typeof children === 'function') {
|
|
27
|
+
if (!items) throw new Error('props.children was a function but props.items is missing');
|
|
28
|
+
for (let item of items)yield {
|
|
29
|
+
type: 'item',
|
|
30
|
+
value: item,
|
|
31
|
+
renderer: children
|
|
32
|
+
};
|
|
33
|
+
} else {
|
|
34
|
+
let items = [];
|
|
35
|
+
(0, $gtysd$react).Children.forEach(children, (child)=>{
|
|
36
|
+
items.push({
|
|
37
|
+
type: 'item',
|
|
38
|
+
element: child
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
yield* items;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
// We don't want getCollectionNode to show up in the type definition
|
|
47
|
+
let $9fc4852771d079eb$export$6e2c8f0811a474ce = $9fc4852771d079eb$var$Section;
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
export {$9fc4852771d079eb$export$6e2c8f0811a474ce as Section};
|
|
51
|
+
//# sourceMappingURL=Section.module.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import $gtysd$react from "react";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 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 $9fc4852771d079eb$var$Section(props) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
$9fc4852771d079eb$var$Section.getCollectionNode = function* getCollectionNode(props) {
|
|
18
|
+
let { children: children, title: title, items: items } = props;
|
|
19
|
+
yield {
|
|
20
|
+
type: 'section',
|
|
21
|
+
props: props,
|
|
22
|
+
hasChildNodes: true,
|
|
23
|
+
rendered: title,
|
|
24
|
+
'aria-label': props['aria-label'],
|
|
25
|
+
*childNodes () {
|
|
26
|
+
if (typeof children === 'function') {
|
|
27
|
+
if (!items) throw new Error('props.children was a function but props.items is missing');
|
|
28
|
+
for (let item of items)yield {
|
|
29
|
+
type: 'item',
|
|
30
|
+
value: item,
|
|
31
|
+
renderer: children
|
|
32
|
+
};
|
|
33
|
+
} else {
|
|
34
|
+
let items = [];
|
|
35
|
+
(0, $gtysd$react).Children.forEach(children, (child)=>{
|
|
36
|
+
items.push({
|
|
37
|
+
type: 'item',
|
|
38
|
+
element: child
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
yield* items;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
// We don't want getCollectionNode to show up in the type definition
|
|
47
|
+
let $9fc4852771d079eb$export$6e2c8f0811a474ce = $9fc4852771d079eb$var$Section;
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
export {$9fc4852771d079eb$export$6e2c8f0811a474ce as Section};
|
|
51
|
+
//# sourceMappingURL=Section.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAMD,SAAS,8BAAW,KAAsB;IACxC,OAAO;AACT;AAEA,8BAAQ,iBAAiB,GAAG,UAAU,kBAAqB,KAAsB;IAC/E,IAAI,YAAC,QAAQ,SAAE,KAAK,SAAE,KAAK,EAAC,GAAG;IAC/B,MAAM;QACJ,MAAM;QACN,OAAO;QACP,eAAe;QACf,UAAU;QACV,cAAc,KAAK,CAAC,aAAa;QACjC,CAAC;YACC,IAAI,OAAO,aAAa,YAAY;gBAClC,IAAI,CAAC,OACH,MAAM,IAAI,MAAM;gBAGlB,KAAK,IAAI,QAAQ,MACf,MAAM;oBACJ,MAAM;oBACN,OAAO;oBACP,UAAU;gBACZ;YAEJ,OAAO;gBACL,IAAI,QAA0B,EAAE;gBAChC,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAA;oBAC/B,MAAM,IAAI,CAAC;wBACT,MAAM;wBACN,SAAS;oBACX;gBACF;gBAEA,OAAO;YACT;QACF;IACF;AACF;AAEA,oEAAoE;AACpE,IAAI,4CAAW","sources":["packages/@react-stately/collections/src/Section.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 {PartialNode} from './types';\nimport React, {JSX, ReactElement} from 'react';\nimport {SectionProps} from '@react-types/shared';\n\nfunction Section<T>(props: SectionProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nSection.getCollectionNode = function* getCollectionNode<T>(props: SectionProps<T>): Generator<PartialNode<T>> {\n let {children, title, items} = props;\n yield {\n type: 'section',\n props: props,\n hasChildNodes: true,\n rendered: title,\n 'aria-label': props['aria-label'],\n *childNodes() {\n if (typeof children === 'function') {\n if (!items) {\n throw new Error('props.children was a function but props.items is missing');\n }\n\n for (let item of items) {\n yield {\n type: 'item',\n value: item,\n renderer: children\n };\n }\n } else {\n let items: PartialNode<T>[] = [];\n React.Children.forEach(children, child => {\n items.push({\n type: 'item',\n element: child\n });\n });\n\n yield* items;\n }\n }\n };\n};\n\n// We don't want getCollectionNode to show up in the type definition\nlet _Section = Section as <T>(props: SectionProps<T>) => JSX.Element;\nexport {_Section as Section};\n"],"names":[],"version":3,"file":"Section.module.js.map"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
|
|
2
|
+
function $parcel$export(e, n, v, s) {
|
|
3
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
$parcel$export(module.exports, "getChildNodes", () => $7a155683b0d79a6a$export$1005530eda016c13);
|
|
7
|
+
$parcel$export(module.exports, "getFirstItem", () => $7a155683b0d79a6a$export$fbdeaa6a76694f71);
|
|
8
|
+
$parcel$export(module.exports, "getNthItem", () => $7a155683b0d79a6a$export$5f3398f8733f90e2);
|
|
9
|
+
$parcel$export(module.exports, "getLastItem", () => $7a155683b0d79a6a$export$7475b2c64539e4cf);
|
|
10
|
+
$parcel$export(module.exports, "compareNodeOrder", () => $7a155683b0d79a6a$export$8c434b3a7a4dad6);
|
|
11
|
+
/*
|
|
12
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
13
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
15
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
18
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
19
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
20
|
+
* governing permissions and limitations under the License.
|
|
21
|
+
*/ function $7a155683b0d79a6a$export$1005530eda016c13(node, collection) {
|
|
22
|
+
// New API: call collection.getChildren with the node key.
|
|
23
|
+
if (typeof collection.getChildren === 'function') return collection.getChildren(node.key);
|
|
24
|
+
// Old API: access childNodes directly.
|
|
25
|
+
return node.childNodes;
|
|
26
|
+
}
|
|
27
|
+
function $7a155683b0d79a6a$export$fbdeaa6a76694f71(iterable) {
|
|
28
|
+
return $7a155683b0d79a6a$export$5f3398f8733f90e2(iterable, 0);
|
|
29
|
+
}
|
|
30
|
+
function $7a155683b0d79a6a$export$5f3398f8733f90e2(iterable, index) {
|
|
31
|
+
if (index < 0) return undefined;
|
|
32
|
+
let i = 0;
|
|
33
|
+
for (let item of iterable){
|
|
34
|
+
if (i === index) return item;
|
|
35
|
+
i++;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function $7a155683b0d79a6a$export$7475b2c64539e4cf(iterable) {
|
|
39
|
+
let lastItem = undefined;
|
|
40
|
+
for (let value of iterable)lastItem = value;
|
|
41
|
+
return lastItem;
|
|
42
|
+
}
|
|
43
|
+
function $7a155683b0d79a6a$export$8c434b3a7a4dad6(collection, a, b) {
|
|
44
|
+
// If the two nodes have the same parent, compare their indices.
|
|
45
|
+
if (a.parentKey === b.parentKey) return a.index - b.index;
|
|
46
|
+
// Otherwise, collect all of the ancestors from each node, and find the first one that doesn't match starting from the root.
|
|
47
|
+
// Include the base nodes in case we are comparing nodes of different levels so that we can compare the higher node to the lower level node's
|
|
48
|
+
// ancestor of the same level
|
|
49
|
+
let aAncestors = [
|
|
50
|
+
...$7a155683b0d79a6a$var$getAncestors(collection, a),
|
|
51
|
+
a
|
|
52
|
+
];
|
|
53
|
+
let bAncestors = [
|
|
54
|
+
...$7a155683b0d79a6a$var$getAncestors(collection, b),
|
|
55
|
+
b
|
|
56
|
+
];
|
|
57
|
+
let firstNonMatchingAncestor = aAncestors.slice(0, bAncestors.length).findIndex((a, i)=>a !== bAncestors[i]);
|
|
58
|
+
if (firstNonMatchingAncestor !== -1) {
|
|
59
|
+
// Compare the indices of two children within the common ancestor.
|
|
60
|
+
a = aAncestors[firstNonMatchingAncestor];
|
|
61
|
+
b = bAncestors[firstNonMatchingAncestor];
|
|
62
|
+
return a.index - b.index;
|
|
63
|
+
}
|
|
64
|
+
// If there isn't a non matching ancestor, we might be in a case where one of the nodes is the ancestor of the other.
|
|
65
|
+
if (aAncestors.findIndex((node)=>node === b) >= 0) return 1;
|
|
66
|
+
else if (bAncestors.findIndex((node)=>node === a) >= 0) return -1;
|
|
67
|
+
// 🤷
|
|
68
|
+
return -1;
|
|
69
|
+
}
|
|
70
|
+
function $7a155683b0d79a6a$var$getAncestors(collection, node) {
|
|
71
|
+
let parents = [];
|
|
72
|
+
while((node === null || node === void 0 ? void 0 : node.parentKey) != null){
|
|
73
|
+
node = collection.getItem(node.parentKey);
|
|
74
|
+
parents.unshift(node);
|
|
75
|
+
}
|
|
76
|
+
return parents;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=getChildNodes.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAIM,SAAS,0CAAiB,IAAa,EAAE,UAA+B;IAC7E,0DAA0D;IAC1D,IAAI,OAAO,WAAW,WAAW,KAAK,YACpC,OAAO,WAAW,WAAW,CAAC,KAAK,GAAG;IAGxC,uCAAuC;IACvC,OAAO,KAAK,UAAU;AACxB;AAEO,SAAS,0CAAgB,QAAqB;IACnD,OAAO,0CAAW,UAAU;AAC9B;AAEO,SAAS,0CAAc,QAAqB,EAAE,KAAa;IAChE,IAAI,QAAQ,GACV,OAAO;IAGT,IAAI,IAAI;IACR,KAAK,IAAI,QAAQ,SAAU;QACzB,IAAI,MAAM,OACR,OAAO;QAGT;IACF;AACF;AAEO,SAAS,0CAAe,QAAqB;IAClD,IAAI,WAAW;IACf,KAAK,IAAI,SAAS,SAChB,WAAW;IAGb,OAAO;AACT;AAEO,SAAS,yCAAoB,UAA+B,EAAE,CAAU,EAAE,CAAU;IACzF,gEAAgE;IAChE,IAAI,EAAE,SAAS,KAAK,EAAE,SAAS,EAC7B,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK;IAG1B,4HAA4H;IAC5H,6IAA6I;IAC7I,6BAA6B;IAC7B,IAAI,aAAa;WAAI,mCAAa,YAAY;QAAI;KAAE;IACpD,IAAI,aAAa;WAAI,mCAAa,YAAY;QAAI;KAAE;IACpD,IAAI,2BAA2B,WAAW,KAAK,CAAC,GAAG,WAAW,MAAM,EAAE,SAAS,CAAC,CAAC,GAAG,IAAM,MAAM,UAAU,CAAC,EAAE;IAC7G,IAAI,6BAA6B,IAAI;QACnC,kEAAkE;QAClE,IAAI,UAAU,CAAC,yBAAyB;QACxC,IAAI,UAAU,CAAC,yBAAyB;QACxC,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK;IAC1B;IAEA,qHAAqH;IACrH,IAAI,WAAW,SAAS,CAAC,CAAA,OAAQ,SAAS,MAAM,GAC9C,OAAO;SACF,IAAI,WAAW,SAAS,CAAC,CAAA,OAAQ,SAAS,MAAM,GACrD,OAAO;IAGT,KAAK;IACL,OAAO;AACT;AAEA,SAAS,mCAAgB,UAA+B,EAAE,IAAa;IACrE,IAAI,UAAU,EAAE;IAEhB,MAAO,CAAA,iBAAA,2BAAA,KAAM,SAAS,KAAI,KAAM;QAC9B,OAAO,WAAW,OAAO,CAAC,KAAK,SAAS;QACxC,QAAQ,OAAO,CAAC;IAClB;IAEA,OAAO;AACT","sources":["packages/@react-stately/collections/src/getChildNodes.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 type {Collection, Node} from '@react-types/shared';\n\nexport function getChildNodes<T>(node: Node<T>, collection: Collection<Node<T>>): Iterable<Node<T>> {\n // New API: call collection.getChildren with the node key.\n if (typeof collection.getChildren === 'function') {\n return collection.getChildren(node.key);\n }\n\n // Old API: access childNodes directly.\n return node.childNodes;\n}\n\nexport function getFirstItem<T>(iterable: Iterable<T>): T | undefined {\n return getNthItem(iterable, 0);\n}\n\nexport function getNthItem<T>(iterable: Iterable<T>, index: number): T | undefined {\n if (index < 0) {\n return undefined;\n }\n\n let i = 0;\n for (let item of iterable) {\n if (i === index) {\n return item;\n }\n\n i++;\n }\n}\n\nexport function getLastItem<T>(iterable: Iterable<T>): T | undefined {\n let lastItem = undefined;\n for (let value of iterable) {\n lastItem = value;\n }\n\n return lastItem;\n}\n\nexport function compareNodeOrder<T>(collection: Collection<Node<T>>, a: Node<T>, b: Node<T>) {\n // If the two nodes have the same parent, compare their indices.\n if (a.parentKey === b.parentKey) {\n return a.index - b.index;\n }\n\n // Otherwise, collect all of the ancestors from each node, and find the first one that doesn't match starting from the root.\n // Include the base nodes in case we are comparing nodes of different levels so that we can compare the higher node to the lower level node's\n // ancestor of the same level\n let aAncestors = [...getAncestors(collection, a), a];\n let bAncestors = [...getAncestors(collection, b), b];\n let firstNonMatchingAncestor = aAncestors.slice(0, bAncestors.length).findIndex((a, i) => a !== bAncestors[i]);\n if (firstNonMatchingAncestor !== -1) {\n // Compare the indices of two children within the common ancestor.\n a = aAncestors[firstNonMatchingAncestor];\n b = bAncestors[firstNonMatchingAncestor];\n return a.index - b.index;\n }\n\n // If there isn't a non matching ancestor, we might be in a case where one of the nodes is the ancestor of the other.\n if (aAncestors.findIndex(node => node === b) >= 0) {\n return 1;\n } else if (bAncestors.findIndex(node => node === a) >= 0) {\n return -1;\n }\n\n // 🤷\n return -1;\n}\n\nfunction getAncestors<T>(collection: Collection<Node<T>>, node: Node<T>): Node<T>[] {\n let parents = [];\n\n while (node?.parentKey != null) {\n node = collection.getItem(node.parentKey);\n parents.unshift(node);\n }\n\n return parents;\n}\n"],"names":[],"version":3,"file":"getChildNodes.main.js.map"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/ function $c5a24bc478652b5f$export$1005530eda016c13(node, collection) {
|
|
12
|
+
// New API: call collection.getChildren with the node key.
|
|
13
|
+
if (typeof collection.getChildren === 'function') return collection.getChildren(node.key);
|
|
14
|
+
// Old API: access childNodes directly.
|
|
15
|
+
return node.childNodes;
|
|
16
|
+
}
|
|
17
|
+
function $c5a24bc478652b5f$export$fbdeaa6a76694f71(iterable) {
|
|
18
|
+
return $c5a24bc478652b5f$export$5f3398f8733f90e2(iterable, 0);
|
|
19
|
+
}
|
|
20
|
+
function $c5a24bc478652b5f$export$5f3398f8733f90e2(iterable, index) {
|
|
21
|
+
if (index < 0) return undefined;
|
|
22
|
+
let i = 0;
|
|
23
|
+
for (let item of iterable){
|
|
24
|
+
if (i === index) return item;
|
|
25
|
+
i++;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function $c5a24bc478652b5f$export$7475b2c64539e4cf(iterable) {
|
|
29
|
+
let lastItem = undefined;
|
|
30
|
+
for (let value of iterable)lastItem = value;
|
|
31
|
+
return lastItem;
|
|
32
|
+
}
|
|
33
|
+
function $c5a24bc478652b5f$export$8c434b3a7a4dad6(collection, a, b) {
|
|
34
|
+
// If the two nodes have the same parent, compare their indices.
|
|
35
|
+
if (a.parentKey === b.parentKey) return a.index - b.index;
|
|
36
|
+
// Otherwise, collect all of the ancestors from each node, and find the first one that doesn't match starting from the root.
|
|
37
|
+
// Include the base nodes in case we are comparing nodes of different levels so that we can compare the higher node to the lower level node's
|
|
38
|
+
// ancestor of the same level
|
|
39
|
+
let aAncestors = [
|
|
40
|
+
...$c5a24bc478652b5f$var$getAncestors(collection, a),
|
|
41
|
+
a
|
|
42
|
+
];
|
|
43
|
+
let bAncestors = [
|
|
44
|
+
...$c5a24bc478652b5f$var$getAncestors(collection, b),
|
|
45
|
+
b
|
|
46
|
+
];
|
|
47
|
+
let firstNonMatchingAncestor = aAncestors.slice(0, bAncestors.length).findIndex((a, i)=>a !== bAncestors[i]);
|
|
48
|
+
if (firstNonMatchingAncestor !== -1) {
|
|
49
|
+
// Compare the indices of two children within the common ancestor.
|
|
50
|
+
a = aAncestors[firstNonMatchingAncestor];
|
|
51
|
+
b = bAncestors[firstNonMatchingAncestor];
|
|
52
|
+
return a.index - b.index;
|
|
53
|
+
}
|
|
54
|
+
// If there isn't a non matching ancestor, we might be in a case where one of the nodes is the ancestor of the other.
|
|
55
|
+
if (aAncestors.findIndex((node)=>node === b) >= 0) return 1;
|
|
56
|
+
else if (bAncestors.findIndex((node)=>node === a) >= 0) return -1;
|
|
57
|
+
// 🤷
|
|
58
|
+
return -1;
|
|
59
|
+
}
|
|
60
|
+
function $c5a24bc478652b5f$var$getAncestors(collection, node) {
|
|
61
|
+
let parents = [];
|
|
62
|
+
while((node === null || node === void 0 ? void 0 : node.parentKey) != null){
|
|
63
|
+
node = collection.getItem(node.parentKey);
|
|
64
|
+
parents.unshift(node);
|
|
65
|
+
}
|
|
66
|
+
return parents;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
export {$c5a24bc478652b5f$export$1005530eda016c13 as getChildNodes, $c5a24bc478652b5f$export$fbdeaa6a76694f71 as getFirstItem, $c5a24bc478652b5f$export$5f3398f8733f90e2 as getNthItem, $c5a24bc478652b5f$export$7475b2c64539e4cf as getLastItem, $c5a24bc478652b5f$export$8c434b3a7a4dad6 as compareNodeOrder};
|
|
71
|
+
//# sourceMappingURL=getChildNodes.module.js.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/ function $c5a24bc478652b5f$export$1005530eda016c13(node, collection) {
|
|
12
|
+
// New API: call collection.getChildren with the node key.
|
|
13
|
+
if (typeof collection.getChildren === 'function') return collection.getChildren(node.key);
|
|
14
|
+
// Old API: access childNodes directly.
|
|
15
|
+
return node.childNodes;
|
|
16
|
+
}
|
|
17
|
+
function $c5a24bc478652b5f$export$fbdeaa6a76694f71(iterable) {
|
|
18
|
+
return $c5a24bc478652b5f$export$5f3398f8733f90e2(iterable, 0);
|
|
19
|
+
}
|
|
20
|
+
function $c5a24bc478652b5f$export$5f3398f8733f90e2(iterable, index) {
|
|
21
|
+
if (index < 0) return undefined;
|
|
22
|
+
let i = 0;
|
|
23
|
+
for (let item of iterable){
|
|
24
|
+
if (i === index) return item;
|
|
25
|
+
i++;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function $c5a24bc478652b5f$export$7475b2c64539e4cf(iterable) {
|
|
29
|
+
let lastItem = undefined;
|
|
30
|
+
for (let value of iterable)lastItem = value;
|
|
31
|
+
return lastItem;
|
|
32
|
+
}
|
|
33
|
+
function $c5a24bc478652b5f$export$8c434b3a7a4dad6(collection, a, b) {
|
|
34
|
+
// If the two nodes have the same parent, compare their indices.
|
|
35
|
+
if (a.parentKey === b.parentKey) return a.index - b.index;
|
|
36
|
+
// Otherwise, collect all of the ancestors from each node, and find the first one that doesn't match starting from the root.
|
|
37
|
+
// Include the base nodes in case we are comparing nodes of different levels so that we can compare the higher node to the lower level node's
|
|
38
|
+
// ancestor of the same level
|
|
39
|
+
let aAncestors = [
|
|
40
|
+
...$c5a24bc478652b5f$var$getAncestors(collection, a),
|
|
41
|
+
a
|
|
42
|
+
];
|
|
43
|
+
let bAncestors = [
|
|
44
|
+
...$c5a24bc478652b5f$var$getAncestors(collection, b),
|
|
45
|
+
b
|
|
46
|
+
];
|
|
47
|
+
let firstNonMatchingAncestor = aAncestors.slice(0, bAncestors.length).findIndex((a, i)=>a !== bAncestors[i]);
|
|
48
|
+
if (firstNonMatchingAncestor !== -1) {
|
|
49
|
+
// Compare the indices of two children within the common ancestor.
|
|
50
|
+
a = aAncestors[firstNonMatchingAncestor];
|
|
51
|
+
b = bAncestors[firstNonMatchingAncestor];
|
|
52
|
+
return a.index - b.index;
|
|
53
|
+
}
|
|
54
|
+
// If there isn't a non matching ancestor, we might be in a case where one of the nodes is the ancestor of the other.
|
|
55
|
+
if (aAncestors.findIndex((node)=>node === b) >= 0) return 1;
|
|
56
|
+
else if (bAncestors.findIndex((node)=>node === a) >= 0) return -1;
|
|
57
|
+
// 🤷
|
|
58
|
+
return -1;
|
|
59
|
+
}
|
|
60
|
+
function $c5a24bc478652b5f$var$getAncestors(collection, node) {
|
|
61
|
+
let parents = [];
|
|
62
|
+
while((node === null || node === void 0 ? void 0 : node.parentKey) != null){
|
|
63
|
+
node = collection.getItem(node.parentKey);
|
|
64
|
+
parents.unshift(node);
|
|
65
|
+
}
|
|
66
|
+
return parents;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
export {$c5a24bc478652b5f$export$1005530eda016c13 as getChildNodes, $c5a24bc478652b5f$export$fbdeaa6a76694f71 as getFirstItem, $c5a24bc478652b5f$export$5f3398f8733f90e2 as getNthItem, $c5a24bc478652b5f$export$7475b2c64539e4cf as getLastItem, $c5a24bc478652b5f$export$8c434b3a7a4dad6 as compareNodeOrder};
|
|
71
|
+
//# sourceMappingURL=getChildNodes.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA;;;;;;;;;;CAUC,GAIM,SAAS,0CAAiB,IAAa,EAAE,UAA+B;IAC7E,0DAA0D;IAC1D,IAAI,OAAO,WAAW,WAAW,KAAK,YACpC,OAAO,WAAW,WAAW,CAAC,KAAK,GAAG;IAGxC,uCAAuC;IACvC,OAAO,KAAK,UAAU;AACxB;AAEO,SAAS,0CAAgB,QAAqB;IACnD,OAAO,0CAAW,UAAU;AAC9B;AAEO,SAAS,0CAAc,QAAqB,EAAE,KAAa;IAChE,IAAI,QAAQ,GACV,OAAO;IAGT,IAAI,IAAI;IACR,KAAK,IAAI,QAAQ,SAAU;QACzB,IAAI,MAAM,OACR,OAAO;QAGT;IACF;AACF;AAEO,SAAS,0CAAe,QAAqB;IAClD,IAAI,WAAW;IACf,KAAK,IAAI,SAAS,SAChB,WAAW;IAGb,OAAO;AACT;AAEO,SAAS,yCAAoB,UAA+B,EAAE,CAAU,EAAE,CAAU;IACzF,gEAAgE;IAChE,IAAI,EAAE,SAAS,KAAK,EAAE,SAAS,EAC7B,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK;IAG1B,4HAA4H;IAC5H,6IAA6I;IAC7I,6BAA6B;IAC7B,IAAI,aAAa;WAAI,mCAAa,YAAY;QAAI;KAAE;IACpD,IAAI,aAAa;WAAI,mCAAa,YAAY;QAAI;KAAE;IACpD,IAAI,2BAA2B,WAAW,KAAK,CAAC,GAAG,WAAW,MAAM,EAAE,SAAS,CAAC,CAAC,GAAG,IAAM,MAAM,UAAU,CAAC,EAAE;IAC7G,IAAI,6BAA6B,IAAI;QACnC,kEAAkE;QAClE,IAAI,UAAU,CAAC,yBAAyB;QACxC,IAAI,UAAU,CAAC,yBAAyB;QACxC,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK;IAC1B;IAEA,qHAAqH;IACrH,IAAI,WAAW,SAAS,CAAC,CAAA,OAAQ,SAAS,MAAM,GAC9C,OAAO;SACF,IAAI,WAAW,SAAS,CAAC,CAAA,OAAQ,SAAS,MAAM,GACrD,OAAO;IAGT,KAAK;IACL,OAAO;AACT;AAEA,SAAS,mCAAgB,UAA+B,EAAE,IAAa;IACrE,IAAI,UAAU,EAAE;IAEhB,MAAO,CAAA,iBAAA,2BAAA,KAAM,SAAS,KAAI,KAAM;QAC9B,OAAO,WAAW,OAAO,CAAC,KAAK,SAAS;QACxC,QAAQ,OAAO,CAAC;IAClB;IAEA,OAAO;AACT","sources":["packages/@react-stately/collections/src/getChildNodes.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 type {Collection, Node} from '@react-types/shared';\n\nexport function getChildNodes<T>(node: Node<T>, collection: Collection<Node<T>>): Iterable<Node<T>> {\n // New API: call collection.getChildren with the node key.\n if (typeof collection.getChildren === 'function') {\n return collection.getChildren(node.key);\n }\n\n // Old API: access childNodes directly.\n return node.childNodes;\n}\n\nexport function getFirstItem<T>(iterable: Iterable<T>): T | undefined {\n return getNthItem(iterable, 0);\n}\n\nexport function getNthItem<T>(iterable: Iterable<T>, index: number): T | undefined {\n if (index < 0) {\n return undefined;\n }\n\n let i = 0;\n for (let item of iterable) {\n if (i === index) {\n return item;\n }\n\n i++;\n }\n}\n\nexport function getLastItem<T>(iterable: Iterable<T>): T | undefined {\n let lastItem = undefined;\n for (let value of iterable) {\n lastItem = value;\n }\n\n return lastItem;\n}\n\nexport function compareNodeOrder<T>(collection: Collection<Node<T>>, a: Node<T>, b: Node<T>) {\n // If the two nodes have the same parent, compare their indices.\n if (a.parentKey === b.parentKey) {\n return a.index - b.index;\n }\n\n // Otherwise, collect all of the ancestors from each node, and find the first one that doesn't match starting from the root.\n // Include the base nodes in case we are comparing nodes of different levels so that we can compare the higher node to the lower level node's\n // ancestor of the same level\n let aAncestors = [...getAncestors(collection, a), a];\n let bAncestors = [...getAncestors(collection, b), b];\n let firstNonMatchingAncestor = aAncestors.slice(0, bAncestors.length).findIndex((a, i) => a !== bAncestors[i]);\n if (firstNonMatchingAncestor !== -1) {\n // Compare the indices of two children within the common ancestor.\n a = aAncestors[firstNonMatchingAncestor];\n b = bAncestors[firstNonMatchingAncestor];\n return a.index - b.index;\n }\n\n // If there isn't a non matching ancestor, we might be in a case where one of the nodes is the ancestor of the other.\n if (aAncestors.findIndex(node => node === b) >= 0) {\n return 1;\n } else if (bAncestors.findIndex(node => node === a) >= 0) {\n return -1;\n }\n\n // 🤷\n return -1;\n}\n\nfunction getAncestors<T>(collection: Collection<Node<T>>, node: Node<T>): Node<T>[] {\n let parents = [];\n\n while (node?.parentKey != null) {\n node = collection.getItem(node.parentKey);\n parents.unshift(node);\n }\n\n return parents;\n}\n"],"names":[],"version":3,"file":"getChildNodes.module.js.map"}
|