@react-spectrum/breadcrumbs 3.9.4 → 3.9.6
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/BreadcrumbItem.main.js +71 -0
- package/dist/BreadcrumbItem.main.js.map +1 -0
- package/dist/BreadcrumbItem.mjs +66 -0
- package/dist/BreadcrumbItem.module.js +66 -0
- package/dist/BreadcrumbItem.module.js.map +1 -0
- package/dist/Breadcrumbs.main.js +207 -0
- package/dist/Breadcrumbs.main.js.map +1 -0
- package/dist/Breadcrumbs.mjs +202 -0
- package/dist/Breadcrumbs.module.js +202 -0
- package/dist/Breadcrumbs.module.js.map +1 -0
- package/dist/breadcrumb_vars_css.main.js +68 -0
- package/dist/breadcrumb_vars_css.main.js.map +1 -0
- package/dist/breadcrumb_vars_css.mjs +70 -0
- package/dist/breadcrumb_vars_css.module.js +70 -0
- package/dist/breadcrumb_vars_css.module.js.map +1 -0
- package/dist/import.mjs +1 -315
- package/dist/main.js +2 -312
- package/dist/main.js.map +1 -1
- package/dist/module.js +1 -315
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/vars.51165b3f.css +337 -0
- package/dist/vars.51165b3f.css.map +1 -0
- package/package.json +14 -14
- package/dist/main.css +0 -1
package/dist/module.js
CHANGED
|
@@ -1,26 +1,6 @@
|
|
|
1
|
-
import "./
|
|
1
|
+
import {Breadcrumbs as $2adaf67aabd3300b$export$2dc68d50d56fbbd} from "./Breadcrumbs.module.js";
|
|
2
2
|
import {Item as $37781313afe0968e$re_export$Item} from "@react-stately/collections";
|
|
3
|
-
import {ActionButton as $koRP3$ActionButton} from "@react-spectrum/button";
|
|
4
|
-
import {useDOMRef as $koRP3$useDOMRef, useStyleProps as $koRP3$useStyleProps, classNames as $koRP3$classNames} from "@react-spectrum/utils";
|
|
5
|
-
import $koRP3$spectrumiconsuiFolderBreadcrumb from "@spectrum-icons/ui/FolderBreadcrumb";
|
|
6
|
-
import {MenuTrigger as $koRP3$MenuTrigger, Menu as $koRP3$Menu} from "@react-spectrum/menu";
|
|
7
|
-
import $koRP3$react, {useRef as $koRP3$useRef, useCallback as $koRP3$useCallback, Fragment as $koRP3$Fragment} from "react";
|
|
8
|
-
import {useBreadcrumbs as $koRP3$useBreadcrumbs, useBreadcrumbItem as $koRP3$useBreadcrumbItem} from "@react-aria/breadcrumbs";
|
|
9
|
-
import {useValueEffect as $koRP3$useValueEffect, useResizeObserver as $koRP3$useResizeObserver, useLayoutEffect as $koRP3$useLayoutEffect, mergeProps as $koRP3$mergeProps} from "@react-aria/utils";
|
|
10
|
-
import {useProviderProps as $koRP3$useProviderProps} from "@react-spectrum/provider";
|
|
11
|
-
import $koRP3$spectrumiconsuiChevronRightSmall from "@spectrum-icons/ui/ChevronRightSmall";
|
|
12
|
-
import {FocusRing as $koRP3$FocusRing} from "@react-aria/focus";
|
|
13
|
-
import {useHover as $koRP3$useHover} from "@react-aria/interactions";
|
|
14
|
-
import {useLocale as $koRP3$useLocale} from "@react-aria/i18n";
|
|
15
3
|
|
|
16
|
-
|
|
17
|
-
function $parcel$interopDefault(a) {
|
|
18
|
-
return a && a.__esModule ? a.default : a;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function $parcel$export(e, n, v, s) {
|
|
22
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
23
|
-
}
|
|
24
4
|
/*
|
|
25
5
|
* Copyright 2020 Adobe. All rights reserved.
|
|
26
6
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -32,300 +12,6 @@ function $parcel$export(e, n, v, s) {
|
|
|
32
12
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
33
13
|
* governing permissions and limitations under the License.
|
|
34
14
|
*/ /// <reference types="css-module-types" />
|
|
35
|
-
/*
|
|
36
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
37
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
38
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
39
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
40
|
-
*
|
|
41
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
42
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
43
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
44
|
-
* governing permissions and limitations under the License.
|
|
45
|
-
*/
|
|
46
|
-
/*
|
|
47
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
48
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
49
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
50
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
51
|
-
*
|
|
52
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
53
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
54
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
55
|
-
* governing permissions and limitations under the License.
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var $48e85557f3729e3d$exports = {};
|
|
62
|
-
|
|
63
|
-
$parcel$export($48e85557f3729e3d$exports, "focus-ring", () => $48e85557f3729e3d$export$f39a09f249340e2a, (v) => $48e85557f3729e3d$export$f39a09f249340e2a = v);
|
|
64
|
-
$parcel$export($48e85557f3729e3d$exports, "i18nFontFamily", () => $48e85557f3729e3d$export$8c4ee2c50c22c514, (v) => $48e85557f3729e3d$export$8c4ee2c50c22c514 = v);
|
|
65
|
-
$parcel$export($48e85557f3729e3d$exports, "is-disabled", () => $48e85557f3729e3d$export$d35bc1e505d1ebbf, (v) => $48e85557f3729e3d$export$d35bc1e505d1ebbf = v);
|
|
66
|
-
$parcel$export($48e85557f3729e3d$exports, "is-dragged", () => $48e85557f3729e3d$export$8778c911bed6c759, (v) => $48e85557f3729e3d$export$8778c911bed6c759 = v);
|
|
67
|
-
$parcel$export($48e85557f3729e3d$exports, "is-hovered", () => $48e85557f3729e3d$export$b8813cd5d7824ce7, (v) => $48e85557f3729e3d$export$b8813cd5d7824ce7 = v);
|
|
68
|
-
$parcel$export($48e85557f3729e3d$exports, "is-reversed", () => $48e85557f3729e3d$export$a4561bd665abb5db, (v) => $48e85557f3729e3d$export$a4561bd665abb5db = v);
|
|
69
|
-
$parcel$export($48e85557f3729e3d$exports, "is-selected", () => $48e85557f3729e3d$export$1e0fb04f31d3c22a, (v) => $48e85557f3729e3d$export$1e0fb04f31d3c22a = v);
|
|
70
|
-
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumb", () => $48e85557f3729e3d$export$45a5316056cfac3c, (v) => $48e85557f3729e3d$export$45a5316056cfac3c = v);
|
|
71
|
-
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs", () => $48e85557f3729e3d$export$8c6320d2db82081f, (v) => $48e85557f3729e3d$export$8c6320d2db82081f = v);
|
|
72
|
-
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs--medium", () => $48e85557f3729e3d$export$19f957201d941895, (v) => $48e85557f3729e3d$export$19f957201d941895 = v);
|
|
73
|
-
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs--multiline", () => $48e85557f3729e3d$export$713961e8e432825b, (v) => $48e85557f3729e3d$export$713961e8e432825b = v);
|
|
74
|
-
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs--small", () => $48e85557f3729e3d$export$e01337e7944312f6, (v) => $48e85557f3729e3d$export$e01337e7944312f6 = v);
|
|
75
|
-
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs-actionButton", () => $48e85557f3729e3d$export$9753a085493f5648, (v) => $48e85557f3729e3d$export$9753a085493f5648 = v);
|
|
76
|
-
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs-item", () => $48e85557f3729e3d$export$492a5983c5fbf603, (v) => $48e85557f3729e3d$export$492a5983c5fbf603 = v);
|
|
77
|
-
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs-itemLink", () => $48e85557f3729e3d$export$5af6a1bcd207d9f6, (v) => $48e85557f3729e3d$export$5af6a1bcd207d9f6 = v);
|
|
78
|
-
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs-itemSeparator", () => $48e85557f3729e3d$export$f72910e36cd91d1e, (v) => $48e85557f3729e3d$export$f72910e36cd91d1e = v);
|
|
79
|
-
$parcel$export($48e85557f3729e3d$exports, "spectrum-FocusRing-ring", () => $48e85557f3729e3d$export$4109102f950813a6, (v) => $48e85557f3729e3d$export$4109102f950813a6 = v);
|
|
80
|
-
$parcel$export($48e85557f3729e3d$exports, "spectrum-FocusRing", () => $48e85557f3729e3d$export$24c7f46a6e3605dd, (v) => $48e85557f3729e3d$export$24c7f46a6e3605dd = v);
|
|
81
|
-
$parcel$export($48e85557f3729e3d$exports, "spectrum-FocusRing--quiet", () => $48e85557f3729e3d$export$2927016961429360, (v) => $48e85557f3729e3d$export$2927016961429360 = v);
|
|
82
|
-
$parcel$export($48e85557f3729e3d$exports, "spectrum-Heading--pageTitle", () => $48e85557f3729e3d$export$63e9e087a73f808b, (v) => $48e85557f3729e3d$export$63e9e087a73f808b = v);
|
|
83
|
-
var $48e85557f3729e3d$export$f39a09f249340e2a;
|
|
84
|
-
var $48e85557f3729e3d$export$8c4ee2c50c22c514;
|
|
85
|
-
var $48e85557f3729e3d$export$d35bc1e505d1ebbf;
|
|
86
|
-
var $48e85557f3729e3d$export$8778c911bed6c759;
|
|
87
|
-
var $48e85557f3729e3d$export$b8813cd5d7824ce7;
|
|
88
|
-
var $48e85557f3729e3d$export$a4561bd665abb5db;
|
|
89
|
-
var $48e85557f3729e3d$export$1e0fb04f31d3c22a;
|
|
90
|
-
var $48e85557f3729e3d$export$45a5316056cfac3c;
|
|
91
|
-
var $48e85557f3729e3d$export$8c6320d2db82081f;
|
|
92
|
-
var $48e85557f3729e3d$export$19f957201d941895;
|
|
93
|
-
var $48e85557f3729e3d$export$713961e8e432825b;
|
|
94
|
-
var $48e85557f3729e3d$export$e01337e7944312f6;
|
|
95
|
-
var $48e85557f3729e3d$export$9753a085493f5648;
|
|
96
|
-
var $48e85557f3729e3d$export$492a5983c5fbf603;
|
|
97
|
-
var $48e85557f3729e3d$export$5af6a1bcd207d9f6;
|
|
98
|
-
var $48e85557f3729e3d$export$f72910e36cd91d1e;
|
|
99
|
-
var $48e85557f3729e3d$export$4109102f950813a6;
|
|
100
|
-
var $48e85557f3729e3d$export$24c7f46a6e3605dd;
|
|
101
|
-
var $48e85557f3729e3d$export$2927016961429360;
|
|
102
|
-
var $48e85557f3729e3d$export$63e9e087a73f808b;
|
|
103
|
-
$48e85557f3729e3d$export$f39a09f249340e2a = `_1gDPVa_focus-ring`;
|
|
104
|
-
$48e85557f3729e3d$export$8c4ee2c50c22c514 = `_1gDPVa_i18nFontFamily`;
|
|
105
|
-
$48e85557f3729e3d$export$d35bc1e505d1ebbf = `_1gDPVa_is-disabled`;
|
|
106
|
-
$48e85557f3729e3d$export$8778c911bed6c759 = `_1gDPVa_is-dragged`;
|
|
107
|
-
$48e85557f3729e3d$export$b8813cd5d7824ce7 = `_1gDPVa_is-hovered`;
|
|
108
|
-
$48e85557f3729e3d$export$a4561bd665abb5db = `_1gDPVa_is-reversed`;
|
|
109
|
-
$48e85557f3729e3d$export$1e0fb04f31d3c22a = `_1gDPVa_is-selected`;
|
|
110
|
-
$48e85557f3729e3d$export$45a5316056cfac3c = `_1gDPVa_spectrum-Breadcrumb`;
|
|
111
|
-
$48e85557f3729e3d$export$8c6320d2db82081f = `_1gDPVa_spectrum-Breadcrumbs`;
|
|
112
|
-
$48e85557f3729e3d$export$19f957201d941895 = `_1gDPVa_spectrum-Breadcrumbs--medium`;
|
|
113
|
-
$48e85557f3729e3d$export$713961e8e432825b = `_1gDPVa_spectrum-Breadcrumbs--multiline`;
|
|
114
|
-
$48e85557f3729e3d$export$e01337e7944312f6 = `_1gDPVa_spectrum-Breadcrumbs--small`;
|
|
115
|
-
$48e85557f3729e3d$export$9753a085493f5648 = `_1gDPVa_spectrum-Breadcrumbs-actionButton`;
|
|
116
|
-
$48e85557f3729e3d$export$492a5983c5fbf603 = `_1gDPVa_spectrum-Breadcrumbs-item`;
|
|
117
|
-
$48e85557f3729e3d$export$5af6a1bcd207d9f6 = `_1gDPVa_spectrum-Breadcrumbs-itemLink`;
|
|
118
|
-
$48e85557f3729e3d$export$f72910e36cd91d1e = `_1gDPVa_spectrum-Breadcrumbs-itemSeparator`;
|
|
119
|
-
$48e85557f3729e3d$export$4109102f950813a6 = `_1gDPVa_spectrum-FocusRing-ring`;
|
|
120
|
-
$48e85557f3729e3d$export$24c7f46a6e3605dd = `_1gDPVa_spectrum-FocusRing ${$48e85557f3729e3d$export$4109102f950813a6}`;
|
|
121
|
-
$48e85557f3729e3d$export$2927016961429360 = `_1gDPVa_spectrum-FocusRing--quiet`;
|
|
122
|
-
$48e85557f3729e3d$export$63e9e087a73f808b = `_1gDPVa_spectrum-Heading--pageTitle`;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
function $2bfa2c84c665c457$export$c13f210c706eb549(props) {
|
|
129
|
-
let { children: children, isCurrent: isCurrent, isDisabled: isDisabled, isMenu: isMenu } = props;
|
|
130
|
-
let { direction: direction } = (0, $koRP3$useLocale)();
|
|
131
|
-
let ref = (0, $koRP3$useRef)(null);
|
|
132
|
-
let ElementType = props.href ? "a" : "span";
|
|
133
|
-
let { itemProps: itemProps } = (0, $koRP3$useBreadcrumbItem)({
|
|
134
|
-
...props,
|
|
135
|
-
elementType: ElementType
|
|
136
|
-
}, ref);
|
|
137
|
-
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $koRP3$useHover)(props);
|
|
138
|
-
// If this item contains a menu button, then it shouldn't be a link.
|
|
139
|
-
if (isMenu) itemProps = {};
|
|
140
|
-
return /*#__PURE__*/ (0, $koRP3$react).createElement((0, $koRP3$Fragment), null, /*#__PURE__*/ (0, $koRP3$react).createElement((0, $koRP3$FocusRing), {
|
|
141
|
-
focusRingClass: (0, $koRP3$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$exports))), "focus-ring")
|
|
142
|
-
}, /*#__PURE__*/ (0, $koRP3$react).createElement(ElementType, {
|
|
143
|
-
...(0, $koRP3$mergeProps)(itemProps, hoverProps),
|
|
144
|
-
ref: ref,
|
|
145
|
-
className: (0, $koRP3$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$exports))), {
|
|
146
|
-
"spectrum-Breadcrumbs-itemLink": !isMenu,
|
|
147
|
-
"is-disabled": !isCurrent && isDisabled,
|
|
148
|
-
"is-hovered": isHovered
|
|
149
|
-
})
|
|
150
|
-
}, children)), /*#__PURE__*/ (0, $koRP3$react).createElement((0, $koRP3$spectrumiconsuiChevronRightSmall), {
|
|
151
|
-
UNSAFE_className: (0, $koRP3$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$exports))), "spectrum-Breadcrumbs-itemSeparator", {
|
|
152
|
-
"is-reversed": direction === "rtl"
|
|
153
|
-
})
|
|
154
|
-
}));
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const $2adaf67aabd3300b$var$MIN_VISIBLE_ITEMS = 1;
|
|
167
|
-
const $2adaf67aabd3300b$var$MAX_VISIBLE_ITEMS = 4;
|
|
168
|
-
function $2adaf67aabd3300b$var$Breadcrumbs(props, ref) {
|
|
169
|
-
props = (0, $koRP3$useProviderProps)(props);
|
|
170
|
-
let { size: size = "L", isMultiline: isMultiline, children: children, showRoot: showRoot, isDisabled: isDisabled, onAction: onAction, autoFocusCurrent: autoFocusCurrent, ...otherProps } = props;
|
|
171
|
-
// Not using React.Children.toArray because it mutates the key prop.
|
|
172
|
-
let childArray = [];
|
|
173
|
-
(0, $koRP3$react).Children.forEach(children, (child, index)=>{
|
|
174
|
-
if (/*#__PURE__*/ (0, $koRP3$react).isValidElement(child)) {
|
|
175
|
-
if (child.key == null) child = /*#__PURE__*/ (0, $koRP3$react).cloneElement(child, {
|
|
176
|
-
key: index
|
|
177
|
-
});
|
|
178
|
-
childArray.push(child);
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
let domRef = (0, $koRP3$useDOMRef)(ref);
|
|
182
|
-
let listRef = (0, $koRP3$useRef)(null);
|
|
183
|
-
let [visibleItems, setVisibleItems] = (0, $koRP3$useValueEffect)(childArray.length);
|
|
184
|
-
let { navProps: navProps } = (0, $koRP3$useBreadcrumbs)(props);
|
|
185
|
-
let { styleProps: styleProps } = (0, $koRP3$useStyleProps)(otherProps);
|
|
186
|
-
let updateOverflow = (0, $koRP3$useCallback)(()=>{
|
|
187
|
-
let computeVisibleItems = (visibleItems)=>{
|
|
188
|
-
// Refs can be null at runtime.
|
|
189
|
-
let currListRef = listRef.current;
|
|
190
|
-
if (!currListRef) return visibleItems;
|
|
191
|
-
let listItems = Array.from(currListRef.children);
|
|
192
|
-
if (listItems.length <= 0) return visibleItems;
|
|
193
|
-
let containerWidth = currListRef.offsetWidth;
|
|
194
|
-
let isShowingMenu = childArray.length > visibleItems;
|
|
195
|
-
let calculatedWidth = 0;
|
|
196
|
-
let newVisibleItems = 0;
|
|
197
|
-
let maxVisibleItems = $2adaf67aabd3300b$var$MAX_VISIBLE_ITEMS;
|
|
198
|
-
if (showRoot) {
|
|
199
|
-
calculatedWidth += listItems.shift().offsetWidth;
|
|
200
|
-
newVisibleItems++;
|
|
201
|
-
}
|
|
202
|
-
if (isShowingMenu) {
|
|
203
|
-
calculatedWidth += listItems.shift().offsetWidth;
|
|
204
|
-
maxVisibleItems--;
|
|
205
|
-
}
|
|
206
|
-
if (showRoot && calculatedWidth >= containerWidth) newVisibleItems--;
|
|
207
|
-
// TODO: what if multiline and only one breadcrumb??
|
|
208
|
-
if (isMultiline) {
|
|
209
|
-
listItems.pop();
|
|
210
|
-
newVisibleItems++;
|
|
211
|
-
} else if (listItems.length > 0) {
|
|
212
|
-
// Ensure the last breadcrumb isn't truncated when we measure it.
|
|
213
|
-
let last = listItems.pop();
|
|
214
|
-
last.style.overflow = "visible";
|
|
215
|
-
calculatedWidth += last.offsetWidth;
|
|
216
|
-
if (calculatedWidth < containerWidth) newVisibleItems++;
|
|
217
|
-
last.style.overflow = "";
|
|
218
|
-
}
|
|
219
|
-
for (let breadcrumb of listItems.reverse()){
|
|
220
|
-
calculatedWidth += breadcrumb.offsetWidth;
|
|
221
|
-
if (calculatedWidth < containerWidth) newVisibleItems++;
|
|
222
|
-
}
|
|
223
|
-
return Math.max($2adaf67aabd3300b$var$MIN_VISIBLE_ITEMS, Math.min(maxVisibleItems, newVisibleItems));
|
|
224
|
-
};
|
|
225
|
-
setVisibleItems(function*() {
|
|
226
|
-
// Update to show all items.
|
|
227
|
-
yield childArray.length;
|
|
228
|
-
// Measure, and update to show the items that fit.
|
|
229
|
-
let newVisibleItems = computeVisibleItems(childArray.length);
|
|
230
|
-
yield newVisibleItems;
|
|
231
|
-
// If the number of items is less than the number of children,
|
|
232
|
-
// then update again to ensure that the menu fits.
|
|
233
|
-
if (newVisibleItems < childArray.length && newVisibleItems > 1) yield computeVisibleItems(newVisibleItems);
|
|
234
|
-
});
|
|
235
|
-
}, [
|
|
236
|
-
childArray.length,
|
|
237
|
-
setVisibleItems,
|
|
238
|
-
showRoot,
|
|
239
|
-
isMultiline
|
|
240
|
-
]);
|
|
241
|
-
(0, $koRP3$useResizeObserver)({
|
|
242
|
-
ref: domRef,
|
|
243
|
-
onResize: updateOverflow
|
|
244
|
-
});
|
|
245
|
-
let lastChildren = (0, $koRP3$useRef)(null);
|
|
246
|
-
(0, $koRP3$useLayoutEffect)(()=>{
|
|
247
|
-
if (children !== lastChildren.current) {
|
|
248
|
-
lastChildren.current = children;
|
|
249
|
-
updateOverflow();
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
let contents = childArray;
|
|
253
|
-
if (childArray.length > visibleItems) {
|
|
254
|
-
let selectedItem = childArray[childArray.length - 1];
|
|
255
|
-
var _selectedItem_key;
|
|
256
|
-
let selectedKey = (_selectedItem_key = selectedItem.key) !== null && _selectedItem_key !== void 0 ? _selectedItem_key : childArray.length - 1;
|
|
257
|
-
let onMenuAction = (key)=>{
|
|
258
|
-
// Don't fire onAction when clicking on the last item
|
|
259
|
-
if (key !== selectedKey && onAction) onAction(key);
|
|
260
|
-
};
|
|
261
|
-
let menuItem = /*#__PURE__*/ (0, $koRP3$react).createElement((0, $2bfa2c84c665c457$export$c13f210c706eb549), {
|
|
262
|
-
key: "menu",
|
|
263
|
-
isMenu: true
|
|
264
|
-
}, /*#__PURE__*/ (0, $koRP3$react).createElement((0, $koRP3$MenuTrigger), null, /*#__PURE__*/ (0, $koRP3$react).createElement((0, $koRP3$ActionButton), {
|
|
265
|
-
UNSAFE_className: (0, $koRP3$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$exports))), "spectrum-Breadcrumbs-actionButton"),
|
|
266
|
-
"aria-label": "\u2026",
|
|
267
|
-
isQuiet: true,
|
|
268
|
-
isDisabled: isDisabled
|
|
269
|
-
}, /*#__PURE__*/ (0, $koRP3$react).createElement((0, $koRP3$spectrumiconsuiFolderBreadcrumb), null)), /*#__PURE__*/ (0, $koRP3$react).createElement((0, $koRP3$Menu), {
|
|
270
|
-
selectionMode: "single",
|
|
271
|
-
selectedKeys: [
|
|
272
|
-
selectedKey
|
|
273
|
-
],
|
|
274
|
-
onAction: onMenuAction
|
|
275
|
-
}, childArray)));
|
|
276
|
-
contents = [
|
|
277
|
-
menuItem
|
|
278
|
-
];
|
|
279
|
-
let breadcrumbs = [
|
|
280
|
-
...childArray
|
|
281
|
-
];
|
|
282
|
-
let endItems = visibleItems;
|
|
283
|
-
if (showRoot && visibleItems > 1) {
|
|
284
|
-
let rootItem = breadcrumbs.shift();
|
|
285
|
-
if (rootItem) contents.unshift(rootItem);
|
|
286
|
-
endItems--;
|
|
287
|
-
}
|
|
288
|
-
contents.push(...breadcrumbs.slice(-endItems));
|
|
289
|
-
}
|
|
290
|
-
let lastIndex = contents.length - 1;
|
|
291
|
-
let breadcrumbItems = contents.map((child, index)=>{
|
|
292
|
-
let isCurrent = index === lastIndex;
|
|
293
|
-
var _child_key;
|
|
294
|
-
let key = (_child_key = child.key) !== null && _child_key !== void 0 ? _child_key : index;
|
|
295
|
-
let onPress = ()=>{
|
|
296
|
-
if (onAction) onAction(key);
|
|
297
|
-
};
|
|
298
|
-
return /*#__PURE__*/ (0, $koRP3$react).createElement("li", {
|
|
299
|
-
key: index,
|
|
300
|
-
className: (0, $koRP3$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$exports))), "spectrum-Breadcrumbs-item")
|
|
301
|
-
}, /*#__PURE__*/ (0, $koRP3$react).createElement((0, $2bfa2c84c665c457$export$c13f210c706eb549), {
|
|
302
|
-
...child.props,
|
|
303
|
-
key: key,
|
|
304
|
-
isCurrent: isCurrent,
|
|
305
|
-
isDisabled: isDisabled,
|
|
306
|
-
onPress: onPress,
|
|
307
|
-
autoFocus: isCurrent && autoFocusCurrent
|
|
308
|
-
}, child.props.children));
|
|
309
|
-
});
|
|
310
|
-
return /*#__PURE__*/ (0, $koRP3$react).createElement("nav", {
|
|
311
|
-
...styleProps,
|
|
312
|
-
...navProps,
|
|
313
|
-
ref: domRef
|
|
314
|
-
}, /*#__PURE__*/ (0, $koRP3$react).createElement("ul", {
|
|
315
|
-
ref: listRef,
|
|
316
|
-
className: (0, $koRP3$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$exports))), "spectrum-Breadcrumbs", {
|
|
317
|
-
"spectrum-Breadcrumbs--small": size === "S",
|
|
318
|
-
"spectrum-Breadcrumbs--medium": size === "M",
|
|
319
|
-
"spectrum-Breadcrumbs--multiline": isMultiline,
|
|
320
|
-
"spectrum-Breadcrumbs--showRoot": showRoot,
|
|
321
|
-
"is-disabled": isDisabled
|
|
322
|
-
}, styleProps.className)
|
|
323
|
-
}, breadcrumbItems));
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* Breadcrumbs show hierarchy and navigational context for a user’s location within an application.
|
|
327
|
-
*/ let $2adaf67aabd3300b$export$2dc68d50d56fbbd = /*#__PURE__*/ (0, $koRP3$react).forwardRef($2adaf67aabd3300b$var$Breadcrumbs);
|
|
328
|
-
|
|
329
15
|
|
|
330
16
|
|
|
331
17
|
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GACD,0CAA0C;ACX1C;;;;;;;;;;CAUC;ACVD;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;;;;;;;;ACVD,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAnBA,4CAA+B,CAAC,kBAAkB,CAAC;AACnD,4CAAmC,CAAC,sBAAsB,CAAC;AAC3D,4CAAgC,CAAC,mBAAmB,CAAC;AACrD,4CAA+B,CAAC,kBAAkB,CAAC;AACnD,4CAA+B,CAAC,kBAAkB,CAAC;AACnD,4CAAgC,CAAC,mBAAmB,CAAC;AACrD,4CAAgC,CAAC,mBAAmB,CAAC;AACrD,4CAAwC,CAAC,2BAA2B,CAAC;AACrE,4CAAyC,CAAC,4BAA4B,CAAC;AACvE,4CAAiD,CAAC,oCAAoC,CAAC;AAC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AK;YACL,WAAW;YACX,YAAY;YACZ,SAAS;YACT,WAAW,aAAa;WACvB,MAAM,KAAK,CAAC,QAAQ;IAI7B;IAEA,qBACE,gCAAC;QACE,GAAG,UAAU;QACb,GAAG,QAAQ;QACZ,KAAK;qBACL,gCAAC;QACC,KAAK;QACL,WACE,CAAA,GAAA,iBAAS,EACP,CAAA,GAAA,gEAAK,GACL,wBACA;YACE,+BAA+B,SAAS;YACxC,gCAAgC,SAAS;YACzC,mCAAmC;YACnC,kCAAkC;YAClC,eAAe;QACjB,GACA,WAAW,SAAS;OAGvB;AAIT;AAEA;;CAEC,GACD,IAAI,yDAAe,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC;","sources":["packages/@react-spectrum/breadcrumbs/src/index.ts","packages/@react-spectrum/breadcrumbs/src/Breadcrumbs.tsx","packages/@react-spectrum/breadcrumbs/src/BreadcrumbItem.tsx","packages/@adobe/spectrum-css-temp/components/breadcrumb/vars.css"],"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/// <reference types=\"css-module-types\" />\nexport {Breadcrumbs} from './Breadcrumbs';\nexport {Item} from '@react-stately/collections';\nexport type {SpectrumBreadcrumbsProps} from '@react-types/breadcrumbs';\n","/*\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 */\nimport {ActionButton} from '@react-spectrum/button';\nimport {BreadcrumbItem} from './BreadcrumbItem';\nimport {classNames, useDOMRef, useStyleProps} from '@react-spectrum/utils';\nimport {DOMRef, Key} from '@react-types/shared';\nimport FolderBreadcrumb from '@spectrum-icons/ui/FolderBreadcrumb';\nimport {Menu, MenuTrigger} from '@react-spectrum/menu';\nimport React, {ReactElement, useCallback, useRef} from 'react';\nimport {SpectrumBreadcrumbsProps} from '@react-types/breadcrumbs';\nimport styles from '@adobe/spectrum-css-temp/components/breadcrumb/vars.css';\nimport {useBreadcrumbs} from '@react-aria/breadcrumbs';\nimport {useLayoutEffect, useResizeObserver, useValueEffect} from '@react-aria/utils';\nimport {useProviderProps} from '@react-spectrum/provider';\n\nconst MIN_VISIBLE_ITEMS = 1;\nconst MAX_VISIBLE_ITEMS = 4;\n\nfunction Breadcrumbs<T>(props: SpectrumBreadcrumbsProps<T>, ref: DOMRef) {\n props = useProviderProps(props);\n let {\n size = 'L',\n isMultiline,\n children,\n showRoot,\n isDisabled,\n onAction,\n autoFocusCurrent,\n ...otherProps\n } = props;\n\n // Not using React.Children.toArray because it mutates the key prop.\n let childArray: ReactElement[] = [];\n React.Children.forEach(children, (child, index) => {\n if (React.isValidElement(child)) {\n if (child.key == null) {\n child = React.cloneElement(child, {key: index});\n }\n childArray.push(child);\n }\n });\n\n let domRef = useDOMRef(ref);\n let listRef = useRef<HTMLUListElement>(null);\n\n let [visibleItems, setVisibleItems] = useValueEffect(childArray.length);\n\n let {navProps} = useBreadcrumbs(props);\n let {styleProps} = useStyleProps(otherProps);\n\n let updateOverflow = useCallback(() => {\n let computeVisibleItems = (visibleItems: number): number => {\n // Refs can be null at runtime.\n let currListRef: HTMLUListElement | null = listRef.current;\n if (!currListRef) {\n return visibleItems;\n }\n\n let listItems = Array.from(currListRef.children) as HTMLLIElement[];\n if (listItems.length <= 0) {\n return visibleItems;\n }\n let containerWidth = currListRef.offsetWidth;\n let isShowingMenu = childArray.length > visibleItems;\n let calculatedWidth = 0;\n let newVisibleItems = 0;\n let maxVisibleItems = MAX_VISIBLE_ITEMS;\n\n if (showRoot) {\n calculatedWidth += (listItems.shift() as HTMLLIElement).offsetWidth;\n newVisibleItems++;\n }\n\n if (isShowingMenu) {\n calculatedWidth += (listItems.shift() as HTMLLIElement).offsetWidth;\n maxVisibleItems--;\n }\n\n if (showRoot && calculatedWidth >= containerWidth) {\n newVisibleItems--;\n }\n\n // TODO: what if multiline and only one breadcrumb??\n if (isMultiline) {\n listItems.pop();\n newVisibleItems++;\n } else {\n if (listItems.length > 0) {\n // Ensure the last breadcrumb isn't truncated when we measure it.\n let last = (listItems.pop() as HTMLLIElement);\n last.style.overflow = 'visible';\n\n calculatedWidth += last.offsetWidth;\n if (calculatedWidth < containerWidth) {\n newVisibleItems++;\n }\n\n last.style.overflow = '';\n }\n }\n\n for (let breadcrumb of listItems.reverse()) {\n calculatedWidth += breadcrumb.offsetWidth;\n if (calculatedWidth < containerWidth) {\n newVisibleItems++;\n }\n }\n\n return Math.max(MIN_VISIBLE_ITEMS, Math.min(maxVisibleItems, newVisibleItems));\n };\n\n setVisibleItems(function *() {\n // Update to show all items.\n yield childArray.length;\n\n // Measure, and update to show the items that fit.\n let newVisibleItems = computeVisibleItems(childArray.length);\n yield newVisibleItems;\n\n // If the number of items is less than the number of children,\n // then update again to ensure that the menu fits.\n if (newVisibleItems < childArray.length && newVisibleItems > 1) {\n yield computeVisibleItems(newVisibleItems);\n }\n });\n }, [childArray.length, setVisibleItems, showRoot, isMultiline]);\n\n useResizeObserver({ref: domRef, onResize: updateOverflow});\n\n let lastChildren = useRef<typeof children | null>(null);\n useLayoutEffect(() => {\n if (children !== lastChildren.current) {\n lastChildren.current = children;\n updateOverflow();\n }\n });\n\n let contents = childArray;\n if (childArray.length > visibleItems) {\n let selectedItem = childArray[childArray.length - 1];\n let selectedKey = selectedItem.key ?? childArray.length - 1;\n let onMenuAction = (key: Key) => {\n // Don't fire onAction when clicking on the last item\n if (key !== selectedKey && onAction) {\n onAction(key);\n }\n };\n\n let menuItem = (\n <BreadcrumbItem key=\"menu\" isMenu>\n <MenuTrigger>\n <ActionButton\n UNSAFE_className={classNames(styles, 'spectrum-Breadcrumbs-actionButton')}\n aria-label=\"…\"\n isQuiet\n isDisabled={isDisabled}>\n <FolderBreadcrumb />\n </ActionButton>\n <Menu selectionMode=\"single\" selectedKeys={[selectedKey]} onAction={onMenuAction}>\n {childArray}\n </Menu>\n </MenuTrigger>\n </BreadcrumbItem>\n );\n\n contents = [menuItem];\n let breadcrumbs = [...childArray];\n let endItems = visibleItems;\n if (showRoot && visibleItems > 1) {\n let rootItem = breadcrumbs.shift();\n if (rootItem) {\n contents.unshift(rootItem);\n }\n endItems--;\n }\n contents.push(...breadcrumbs.slice(-endItems));\n }\n\n let lastIndex = contents.length - 1;\n let breadcrumbItems = contents.map((child, index) => {\n let isCurrent = index === lastIndex;\n let key = child.key ?? index;\n let onPress = () => {\n if (onAction) {\n onAction(key);\n }\n };\n\n return (\n <li\n key={index}\n className={\n classNames(\n styles,\n 'spectrum-Breadcrumbs-item'\n )\n }>\n <BreadcrumbItem\n {...child.props}\n key={key}\n isCurrent={isCurrent}\n isDisabled={isDisabled}\n onPress={onPress}\n autoFocus={isCurrent && autoFocusCurrent}>\n {child.props.children}\n </BreadcrumbItem>\n </li>\n );\n });\n\n return (\n <nav\n {...styleProps}\n {...navProps}\n ref={domRef}>\n <ul\n ref={listRef}\n className={\n classNames(\n styles,\n 'spectrum-Breadcrumbs',\n {\n 'spectrum-Breadcrumbs--small': size === 'S',\n 'spectrum-Breadcrumbs--medium': size === 'M',\n 'spectrum-Breadcrumbs--multiline': isMultiline,\n 'spectrum-Breadcrumbs--showRoot': showRoot,\n 'is-disabled': isDisabled\n },\n styleProps.className\n )\n }>\n {breadcrumbItems}\n </ul>\n </nav>\n );\n}\n\n/**\n * Breadcrumbs show hierarchy and navigational context for a user’s location within an application.\n */\nlet _Breadcrumbs = React.forwardRef(Breadcrumbs);\nexport {_Breadcrumbs as Breadcrumbs};\n","/*\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 {BreadcrumbItemProps} from '@react-types/breadcrumbs';\nimport ChevronRightSmall from '@spectrum-icons/ui/ChevronRightSmall';\nimport {classNames} from '@react-spectrum/utils';\nimport {FocusRing} from '@react-aria/focus';\nimport {mergeProps} from '@react-aria/utils';\nimport React, {Fragment, useRef} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/breadcrumb/vars.css';\nimport {useBreadcrumbItem} from '@react-aria/breadcrumbs';\nimport {useHover} from '@react-aria/interactions';\nimport {useLocale} from '@react-aria/i18n';\n\ninterface SpectrumBreadcrumbItemProps extends BreadcrumbItemProps {\n isMenu?: boolean\n}\n\nexport function BreadcrumbItem(props: SpectrumBreadcrumbItemProps) {\n let {\n children,\n isCurrent,\n isDisabled,\n isMenu\n } = props;\n\n let {direction} = useLocale();\n let ref = useRef(null);\n let ElementType: React.ElementType = props.href ? 'a' : 'span';\n let {itemProps} = useBreadcrumbItem({\n ...props,\n elementType: ElementType\n }, ref);\n let {hoverProps, isHovered} = useHover(props);\n\n // If this item contains a menu button, then it shouldn't be a link.\n if (isMenu) {\n itemProps = {};\n }\n\n return (\n <Fragment>\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')}>\n <ElementType\n {...mergeProps(itemProps, hoverProps)}\n ref={ref}\n className={\n classNames(\n styles,\n {\n 'spectrum-Breadcrumbs-itemLink': !isMenu,\n 'is-disabled': !isCurrent && isDisabled,\n 'is-hovered': isHovered\n }\n )\n }>\n {children}\n </ElementType>\n </FocusRing>\n <ChevronRightSmall\n UNSAFE_className={\n classNames(\n styles,\n 'spectrum-Breadcrumbs-itemSeparator',\n {\n 'is-reversed': direction === 'rtl'\n }\n )\n } />\n </Fragment>\n );\n}\n","/*\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\n@import './index.css';\n@import './skin.css';\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC,GACD,0CAA0C","sources":["packages/@react-spectrum/breadcrumbs/src/index.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/// <reference types=\"css-module-types\" />\nexport {Breadcrumbs} from './Breadcrumbs';\nexport {Item} from '@react-stately/collections';\nexport type {SpectrumBreadcrumbsProps} from '@react-types/breadcrumbs';\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { SpectrumBreadcrumbsProps } from "@react-types/breadcrumbs";
|
|
3
|
+
import { DOMRefValue } from "@react-types/shared";
|
|
3
4
|
/**
|
|
4
5
|
* Breadcrumbs show hierarchy and navigational context for a user’s location within an application.
|
|
5
6
|
*/
|
|
6
|
-
export let Breadcrumbs: React.ForwardRefExoticComponent<SpectrumBreadcrumbsProps<unknown> & React.RefAttributes<
|
|
7
|
+
export let Breadcrumbs: React.ForwardRefExoticComponent<SpectrumBreadcrumbsProps<unknown> & React.RefAttributes<DOMRefValue<HTMLElement>>>;
|
|
7
8
|
export { Item } from '@react-stately/collections';
|
|
8
9
|
export type { SpectrumBreadcrumbsProps } from '@react-types/breadcrumbs';
|
|
9
10
|
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;ACsPA;;GAEG;AACH,OAAA,IAAI,+HAA4C,CAAC;AC5OjD,OAAO,EAAC,IAAI,EAAC,MAAM,4BAA4B,CAAC;AAChD,YAAY,EAAC,wBAAwB,EAAC,MAAM,0BAA0B,CAAC","sources":["packages/@react-spectrum/breadcrumbs/src/packages/@react-spectrum/breadcrumbs/src/BreadcrumbItem.tsx","packages/@react-spectrum/breadcrumbs/src/packages/@react-spectrum/breadcrumbs/src/Breadcrumbs.tsx","packages/@react-spectrum/breadcrumbs/src/packages/@react-spectrum/breadcrumbs/src/index.ts","packages/@react-spectrum/breadcrumbs/src/index.ts"],"sourcesContent":[null,null,null,"/*\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/// <reference types=\"css-module-types\" />\nexport {Breadcrumbs} from './Breadcrumbs';\nexport {Item} from '@react-stately/collections';\nexport type {SpectrumBreadcrumbsProps} from '@react-types/breadcrumbs';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|