@react-spectrum/breadcrumbs 3.6.2 → 3.7.1
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 +307 -0
- package/dist/main.js +5 -3
- package/dist/main.js.map +1 -1
- package/dist/module.js +5 -3
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +19 -14
- package/src/BreadcrumbItem.tsx +1 -1
- package/src/Breadcrumbs.tsx +12 -6
package/dist/import.mjs
ADDED
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import "./main.css";
|
|
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, getWrappedElement as $koRP3$getWrappedElement} 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
|
+
|
|
16
|
+
function $parcel$interopDefault(a) {
|
|
17
|
+
return a && a.__esModule ? a.default : a;
|
|
18
|
+
}
|
|
19
|
+
function $parcel$export(e, n, v, s) {
|
|
20
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
21
|
+
}
|
|
22
|
+
/*
|
|
23
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
24
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
25
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
26
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
27
|
+
*
|
|
28
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
29
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
30
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
31
|
+
* governing permissions and limitations under the License.
|
|
32
|
+
*/ /// <reference types="css-module-types" />
|
|
33
|
+
/*
|
|
34
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
35
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
36
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
37
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
38
|
+
*
|
|
39
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
40
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
41
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
42
|
+
* governing permissions and limitations under the License.
|
|
43
|
+
*/
|
|
44
|
+
/*
|
|
45
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
46
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
47
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
48
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
49
|
+
*
|
|
50
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
51
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
52
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
53
|
+
* governing permissions and limitations under the License.
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
var $48e85557f3729e3d$exports = {};
|
|
60
|
+
|
|
61
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs", () => $48e85557f3729e3d$export$8c6320d2db82081f, (v) => $48e85557f3729e3d$export$8c6320d2db82081f = v);
|
|
62
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs-itemSeparator", () => $48e85557f3729e3d$export$f72910e36cd91d1e, (v) => $48e85557f3729e3d$export$f72910e36cd91d1e = v);
|
|
63
|
+
$parcel$export($48e85557f3729e3d$exports, "is-reversed", () => $48e85557f3729e3d$export$a4561bd665abb5db, (v) => $48e85557f3729e3d$export$a4561bd665abb5db = v);
|
|
64
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs-item", () => $48e85557f3729e3d$export$492a5983c5fbf603, (v) => $48e85557f3729e3d$export$492a5983c5fbf603 = v);
|
|
65
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-ActionButton", () => $48e85557f3729e3d$export$53da69f51b770d3, (v) => $48e85557f3729e3d$export$53da69f51b770d3 = v);
|
|
66
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs-itemLink", () => $48e85557f3729e3d$export$5af6a1bcd207d9f6, (v) => $48e85557f3729e3d$export$5af6a1bcd207d9f6 = v);
|
|
67
|
+
$parcel$export($48e85557f3729e3d$exports, "is-hovered", () => $48e85557f3729e3d$export$b8813cd5d7824ce7, (v) => $48e85557f3729e3d$export$b8813cd5d7824ce7 = v);
|
|
68
|
+
$parcel$export($48e85557f3729e3d$exports, "focus-ring", () => $48e85557f3729e3d$export$f39a09f249340e2a, (v) => $48e85557f3729e3d$export$f39a09f249340e2a = v);
|
|
69
|
+
$parcel$export($48e85557f3729e3d$exports, "is-dragged", () => $48e85557f3729e3d$export$8778c911bed6c759, (v) => $48e85557f3729e3d$export$8778c911bed6c759 = v);
|
|
70
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs--small", () => $48e85557f3729e3d$export$e01337e7944312f6, (v) => $48e85557f3729e3d$export$e01337e7944312f6 = v);
|
|
71
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs--medium", () => $48e85557f3729e3d$export$19f957201d941895, (v) => $48e85557f3729e3d$export$19f957201d941895 = v);
|
|
72
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs--multiline", () => $48e85557f3729e3d$export$713961e8e432825b, (v) => $48e85557f3729e3d$export$713961e8e432825b = v);
|
|
73
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Heading--pageTitle", () => $48e85557f3729e3d$export$63e9e087a73f808b, (v) => $48e85557f3729e3d$export$63e9e087a73f808b = v);
|
|
74
|
+
$parcel$export($48e85557f3729e3d$exports, "is-disabled", () => $48e85557f3729e3d$export$d35bc1e505d1ebbf, (v) => $48e85557f3729e3d$export$d35bc1e505d1ebbf = v);
|
|
75
|
+
$parcel$export($48e85557f3729e3d$exports, "is-selected", () => $48e85557f3729e3d$export$1e0fb04f31d3c22a, (v) => $48e85557f3729e3d$export$1e0fb04f31d3c22a = v);
|
|
76
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumb", () => $48e85557f3729e3d$export$45a5316056cfac3c, (v) => $48e85557f3729e3d$export$45a5316056cfac3c = v);
|
|
77
|
+
var $48e85557f3729e3d$export$8c6320d2db82081f;
|
|
78
|
+
var $48e85557f3729e3d$export$f72910e36cd91d1e;
|
|
79
|
+
var $48e85557f3729e3d$export$a4561bd665abb5db;
|
|
80
|
+
var $48e85557f3729e3d$export$492a5983c5fbf603;
|
|
81
|
+
var $48e85557f3729e3d$export$53da69f51b770d3;
|
|
82
|
+
var $48e85557f3729e3d$export$5af6a1bcd207d9f6;
|
|
83
|
+
var $48e85557f3729e3d$export$b8813cd5d7824ce7;
|
|
84
|
+
var $48e85557f3729e3d$export$f39a09f249340e2a;
|
|
85
|
+
var $48e85557f3729e3d$export$8778c911bed6c759;
|
|
86
|
+
var $48e85557f3729e3d$export$e01337e7944312f6;
|
|
87
|
+
var $48e85557f3729e3d$export$19f957201d941895;
|
|
88
|
+
var $48e85557f3729e3d$export$713961e8e432825b;
|
|
89
|
+
var $48e85557f3729e3d$export$63e9e087a73f808b;
|
|
90
|
+
var $48e85557f3729e3d$export$d35bc1e505d1ebbf;
|
|
91
|
+
var $48e85557f3729e3d$export$1e0fb04f31d3c22a;
|
|
92
|
+
var $48e85557f3729e3d$export$45a5316056cfac3c;
|
|
93
|
+
$48e85557f3729e3d$export$8c6320d2db82081f = "spectrum-Breadcrumbs_3fe6e8";
|
|
94
|
+
$48e85557f3729e3d$export$f72910e36cd91d1e = "spectrum-Breadcrumbs-itemSeparator_3fe6e8";
|
|
95
|
+
$48e85557f3729e3d$export$a4561bd665abb5db = "is-reversed_3fe6e8";
|
|
96
|
+
$48e85557f3729e3d$export$492a5983c5fbf603 = "spectrum-Breadcrumbs-item_3fe6e8";
|
|
97
|
+
$48e85557f3729e3d$export$53da69f51b770d3 = "spectrum-ActionButton_3fe6e8";
|
|
98
|
+
$48e85557f3729e3d$export$5af6a1bcd207d9f6 = "spectrum-Breadcrumbs-itemLink_3fe6e8";
|
|
99
|
+
$48e85557f3729e3d$export$b8813cd5d7824ce7 = "is-hovered_3fe6e8";
|
|
100
|
+
$48e85557f3729e3d$export$f39a09f249340e2a = "focus-ring_3fe6e8";
|
|
101
|
+
$48e85557f3729e3d$export$8778c911bed6c759 = "is-dragged_3fe6e8";
|
|
102
|
+
$48e85557f3729e3d$export$e01337e7944312f6 = "spectrum-Breadcrumbs--small_3fe6e8";
|
|
103
|
+
$48e85557f3729e3d$export$19f957201d941895 = "spectrum-Breadcrumbs--medium_3fe6e8";
|
|
104
|
+
$48e85557f3729e3d$export$713961e8e432825b = "spectrum-Breadcrumbs--multiline_3fe6e8";
|
|
105
|
+
$48e85557f3729e3d$export$63e9e087a73f808b = "spectrum-Heading--pageTitle_3fe6e8";
|
|
106
|
+
$48e85557f3729e3d$export$d35bc1e505d1ebbf = "is-disabled_3fe6e8";
|
|
107
|
+
$48e85557f3729e3d$export$1e0fb04f31d3c22a = "is-selected_3fe6e8";
|
|
108
|
+
$48e85557f3729e3d$export$45a5316056cfac3c = "spectrum-Breadcrumb_3fe6e8";
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
function $2bfa2c84c665c457$export$c13f210c706eb549(props) {
|
|
115
|
+
let { children: children , isCurrent: isCurrent , isDisabled: isDisabled } = props;
|
|
116
|
+
let { direction: direction } = (0, $koRP3$useLocale)();
|
|
117
|
+
let ref = (0, $koRP3$useRef)(null);
|
|
118
|
+
let { itemProps: itemProps } = (0, $koRP3$useBreadcrumbItem)({
|
|
119
|
+
...props,
|
|
120
|
+
elementType: typeof children === "string" ? "span" : "a"
|
|
121
|
+
}, ref);
|
|
122
|
+
let { hoverProps: hoverProps , isHovered: isHovered } = (0, $koRP3$useHover)(props);
|
|
123
|
+
let element = /*#__PURE__*/ (0, $koRP3$react).cloneElement((0, $koRP3$getWrappedElement)(children), {
|
|
124
|
+
...(0, $koRP3$mergeProps)(itemProps, hoverProps),
|
|
125
|
+
ref: ref,
|
|
126
|
+
className: (0, $koRP3$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$exports))), "spectrum-Breadcrumbs-itemLink", {
|
|
127
|
+
"is-disabled": !isCurrent && isDisabled,
|
|
128
|
+
"is-hovered": isHovered
|
|
129
|
+
})
|
|
130
|
+
});
|
|
131
|
+
return /*#__PURE__*/ (0, $koRP3$react).createElement((0, $koRP3$Fragment), null, /*#__PURE__*/ (0, $koRP3$react).createElement((0, $koRP3$FocusRing), {
|
|
132
|
+
focusRingClass: (0, $koRP3$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$exports))), "focus-ring")
|
|
133
|
+
}, element), isCurrent === false && /*#__PURE__*/ (0, $koRP3$react).createElement((0, $koRP3$spectrumiconsuiChevronRightSmall), {
|
|
134
|
+
UNSAFE_className: (0, $koRP3$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$exports))), "spectrum-Breadcrumbs-itemSeparator", {
|
|
135
|
+
"is-reversed": direction === "rtl"
|
|
136
|
+
})
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
const $2adaf67aabd3300b$var$MIN_VISIBLE_ITEMS = 1;
|
|
151
|
+
const $2adaf67aabd3300b$var$MAX_VISIBLE_ITEMS = 4;
|
|
152
|
+
function $2adaf67aabd3300b$var$Breadcrumbs(props, ref) {
|
|
153
|
+
props = (0, $koRP3$useProviderProps)(props);
|
|
154
|
+
let { size: size = "L" , isMultiline: isMultiline , children: children , showRoot: showRoot , isDisabled: isDisabled , onAction: onAction , autoFocusCurrent: autoFocusCurrent , ...otherProps } = props;
|
|
155
|
+
// Not using React.Children.toArray because it mutates the key prop.
|
|
156
|
+
let childArray = [];
|
|
157
|
+
(0, $koRP3$react).Children.forEach(children, (child)=>{
|
|
158
|
+
if (/*#__PURE__*/ (0, $koRP3$react).isValidElement(child)) childArray.push(child);
|
|
159
|
+
});
|
|
160
|
+
let domRef = (0, $koRP3$useDOMRef)(ref);
|
|
161
|
+
let listRef = (0, $koRP3$useRef)(null);
|
|
162
|
+
let [visibleItems, setVisibleItems] = (0, $koRP3$useValueEffect)(childArray.length);
|
|
163
|
+
let { navProps: navProps } = (0, $koRP3$useBreadcrumbs)(props);
|
|
164
|
+
let { styleProps: styleProps } = (0, $koRP3$useStyleProps)(otherProps);
|
|
165
|
+
let updateOverflow = (0, $koRP3$useCallback)(()=>{
|
|
166
|
+
let computeVisibleItems = (visibleItems)=>{
|
|
167
|
+
// Refs can be null at runtime.
|
|
168
|
+
let currListRef = listRef.current;
|
|
169
|
+
if (!currListRef) return visibleItems;
|
|
170
|
+
let listItems = Array.from(currListRef.children);
|
|
171
|
+
if (listItems.length <= 0) return visibleItems;
|
|
172
|
+
let containerWidth = currListRef.offsetWidth;
|
|
173
|
+
let isShowingMenu = childArray.length > visibleItems;
|
|
174
|
+
let calculatedWidth = 0;
|
|
175
|
+
let newVisibleItems = 0;
|
|
176
|
+
let maxVisibleItems = $2adaf67aabd3300b$var$MAX_VISIBLE_ITEMS;
|
|
177
|
+
if (showRoot) {
|
|
178
|
+
calculatedWidth += listItems.shift().offsetWidth;
|
|
179
|
+
newVisibleItems++;
|
|
180
|
+
}
|
|
181
|
+
if (isShowingMenu) {
|
|
182
|
+
calculatedWidth += listItems.shift().offsetWidth;
|
|
183
|
+
maxVisibleItems--;
|
|
184
|
+
}
|
|
185
|
+
if (showRoot && calculatedWidth >= containerWidth) newVisibleItems--;
|
|
186
|
+
// TODO: what if multiline and only one breadcrumb??
|
|
187
|
+
if (isMultiline) {
|
|
188
|
+
listItems.pop();
|
|
189
|
+
newVisibleItems++;
|
|
190
|
+
} else if (listItems.length > 0) {
|
|
191
|
+
// Ensure the last breadcrumb isn't truncated when we measure it.
|
|
192
|
+
let last = listItems.pop();
|
|
193
|
+
last.style.overflow = "visible";
|
|
194
|
+
calculatedWidth += last.offsetWidth;
|
|
195
|
+
if (calculatedWidth < containerWidth) newVisibleItems++;
|
|
196
|
+
last.style.overflow = "";
|
|
197
|
+
}
|
|
198
|
+
for (let breadcrumb of listItems.reverse()){
|
|
199
|
+
calculatedWidth += breadcrumb.offsetWidth;
|
|
200
|
+
if (calculatedWidth < containerWidth) newVisibleItems++;
|
|
201
|
+
}
|
|
202
|
+
return Math.max($2adaf67aabd3300b$var$MIN_VISIBLE_ITEMS, Math.min(maxVisibleItems, newVisibleItems));
|
|
203
|
+
};
|
|
204
|
+
setVisibleItems(function*() {
|
|
205
|
+
// Update to show all items.
|
|
206
|
+
yield childArray.length;
|
|
207
|
+
// Measure, and update to show the items that fit.
|
|
208
|
+
let newVisibleItems = computeVisibleItems(childArray.length);
|
|
209
|
+
yield newVisibleItems;
|
|
210
|
+
// If the number of items is less than the number of children,
|
|
211
|
+
// then update again to ensure that the menu fits.
|
|
212
|
+
if (newVisibleItems < childArray.length && newVisibleItems > 1) yield computeVisibleItems(newVisibleItems);
|
|
213
|
+
});
|
|
214
|
+
}, [
|
|
215
|
+
childArray.length,
|
|
216
|
+
setVisibleItems,
|
|
217
|
+
showRoot,
|
|
218
|
+
isMultiline
|
|
219
|
+
]);
|
|
220
|
+
(0, $koRP3$useResizeObserver)({
|
|
221
|
+
ref: domRef,
|
|
222
|
+
onResize: updateOverflow
|
|
223
|
+
});
|
|
224
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
225
|
+
(0, $koRP3$useLayoutEffect)(updateOverflow, [
|
|
226
|
+
children
|
|
227
|
+
]);
|
|
228
|
+
let contents = childArray;
|
|
229
|
+
if (childArray.length > visibleItems) {
|
|
230
|
+
let selectedItem = childArray[childArray.length - 1];
|
|
231
|
+
var _selectedItem_key;
|
|
232
|
+
let selectedKey = (_selectedItem_key = selectedItem.key) !== null && _selectedItem_key !== void 0 ? _selectedItem_key : childArray.length - 1;
|
|
233
|
+
let onMenuAction = (key)=>{
|
|
234
|
+
// Don't fire onAction when clicking on the last item
|
|
235
|
+
if (key !== selectedKey && onAction) onAction(key);
|
|
236
|
+
};
|
|
237
|
+
let menuItem = /*#__PURE__*/ (0, $koRP3$react).createElement((0, $2bfa2c84c665c457$export$c13f210c706eb549), {
|
|
238
|
+
key: "menu"
|
|
239
|
+
}, /*#__PURE__*/ (0, $koRP3$react).createElement((0, $koRP3$MenuTrigger), null, /*#__PURE__*/ (0, $koRP3$react).createElement((0, $koRP3$ActionButton), {
|
|
240
|
+
"aria-label": "…",
|
|
241
|
+
isQuiet: true,
|
|
242
|
+
isDisabled: isDisabled
|
|
243
|
+
}, /*#__PURE__*/ (0, $koRP3$react).createElement((0, $koRP3$spectrumiconsuiFolderBreadcrumb), null)), /*#__PURE__*/ (0, $koRP3$react).createElement((0, $koRP3$Menu), {
|
|
244
|
+
selectionMode: "single",
|
|
245
|
+
selectedKeys: [
|
|
246
|
+
selectedKey
|
|
247
|
+
],
|
|
248
|
+
onAction: onMenuAction
|
|
249
|
+
}, childArray)));
|
|
250
|
+
contents = [
|
|
251
|
+
menuItem
|
|
252
|
+
];
|
|
253
|
+
let breadcrumbs = [
|
|
254
|
+
...childArray
|
|
255
|
+
];
|
|
256
|
+
let endItems = visibleItems;
|
|
257
|
+
if (showRoot && visibleItems > 1) {
|
|
258
|
+
let rootItem = breadcrumbs.shift();
|
|
259
|
+
if (rootItem) contents.unshift(rootItem);
|
|
260
|
+
endItems--;
|
|
261
|
+
}
|
|
262
|
+
contents.push(...breadcrumbs.slice(-endItems));
|
|
263
|
+
}
|
|
264
|
+
let lastIndex = contents.length - 1;
|
|
265
|
+
let breadcrumbItems = contents.map((child, index)=>{
|
|
266
|
+
let isCurrent = index === lastIndex;
|
|
267
|
+
var _child_key;
|
|
268
|
+
let key = (_child_key = child.key) !== null && _child_key !== void 0 ? _child_key : index;
|
|
269
|
+
let onPress = ()=>{
|
|
270
|
+
if (onAction) onAction(key);
|
|
271
|
+
};
|
|
272
|
+
return /*#__PURE__*/ (0, $koRP3$react).createElement("li", {
|
|
273
|
+
key: index,
|
|
274
|
+
className: (0, $koRP3$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$exports))), "spectrum-Breadcrumbs-item")
|
|
275
|
+
}, /*#__PURE__*/ (0, $koRP3$react).createElement((0, $2bfa2c84c665c457$export$c13f210c706eb549), {
|
|
276
|
+
key: key,
|
|
277
|
+
isCurrent: isCurrent,
|
|
278
|
+
isDisabled: isDisabled,
|
|
279
|
+
onPress: onPress,
|
|
280
|
+
autoFocus: isCurrent && autoFocusCurrent
|
|
281
|
+
}, child.props.children));
|
|
282
|
+
});
|
|
283
|
+
return /*#__PURE__*/ (0, $koRP3$react).createElement("nav", {
|
|
284
|
+
...styleProps,
|
|
285
|
+
...navProps,
|
|
286
|
+
ref: domRef
|
|
287
|
+
}, /*#__PURE__*/ (0, $koRP3$react).createElement("ul", {
|
|
288
|
+
ref: listRef,
|
|
289
|
+
className: (0, $koRP3$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$exports))), "spectrum-Breadcrumbs", {
|
|
290
|
+
"spectrum-Breadcrumbs--small": size === "S",
|
|
291
|
+
"spectrum-Breadcrumbs--medium": size === "M",
|
|
292
|
+
"spectrum-Breadcrumbs--multiline": isMultiline,
|
|
293
|
+
"spectrum-Breadcrumbs--showRoot": showRoot,
|
|
294
|
+
"is-disabled": isDisabled
|
|
295
|
+
}, styleProps.className)
|
|
296
|
+
}, breadcrumbItems));
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Breadcrumbs show hierarchy and navigational context for a user’s location within an application.
|
|
300
|
+
*/ let $2adaf67aabd3300b$export$2dc68d50d56fbbd = /*#__PURE__*/ (0, $koRP3$react).forwardRef($2adaf67aabd3300b$var$Breadcrumbs);
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
export {$2adaf67aabd3300b$export$2dc68d50d56fbbd as Breadcrumbs, $37781313afe0968e$re_export$Item as Item};
|
|
307
|
+
//# sourceMappingURL=module.js.map
|
package/dist/main.js
CHANGED
|
@@ -117,7 +117,7 @@ $3292ef9f328419fc$export$45a5316056cfac3c = "spectrum-Breadcrumb_3fe6e8";
|
|
|
117
117
|
function $d90ab02c74e9be0c$export$c13f210c706eb549(props) {
|
|
118
118
|
let { children: children , isCurrent: isCurrent , isDisabled: isDisabled } = props;
|
|
119
119
|
let { direction: direction } = (0, $8bWUw$reactariai18n.useLocale)();
|
|
120
|
-
let ref = (0, $8bWUw$react.useRef)();
|
|
120
|
+
let ref = (0, $8bWUw$react.useRef)(null);
|
|
121
121
|
let { itemProps: itemProps } = (0, $8bWUw$reactariabreadcrumbs.useBreadcrumbItem)({
|
|
122
122
|
...props,
|
|
123
123
|
elementType: typeof children === "string" ? "span" : "a"
|
|
@@ -169,8 +169,9 @@ function $299bf776d9162a05$var$Breadcrumbs(props, ref) {
|
|
|
169
169
|
let computeVisibleItems = (visibleItems)=>{
|
|
170
170
|
// Refs can be null at runtime.
|
|
171
171
|
let currListRef = listRef.current;
|
|
172
|
-
if (!currListRef) return;
|
|
172
|
+
if (!currListRef) return visibleItems;
|
|
173
173
|
let listItems = Array.from(currListRef.children);
|
|
174
|
+
if (listItems.length <= 0) return visibleItems;
|
|
174
175
|
let containerWidth = currListRef.offsetWidth;
|
|
175
176
|
let isShowingMenu = childArray.length > visibleItems;
|
|
176
177
|
let calculatedWidth = 0;
|
|
@@ -257,7 +258,8 @@ function $299bf776d9162a05$var$Breadcrumbs(props, ref) {
|
|
|
257
258
|
];
|
|
258
259
|
let endItems = visibleItems;
|
|
259
260
|
if (showRoot && visibleItems > 1) {
|
|
260
|
-
|
|
261
|
+
let rootItem = breadcrumbs.shift();
|
|
262
|
+
if (rootItem) contents.unshift(rootItem);
|
|
261
263
|
endItems--;
|
|
262
264
|
}
|
|
263
265
|
contents.push(...breadcrumbs.slice(-endItems));
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GACD,0CAA0C;ACX1C;;;;;;;;;;CA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aAAa;WACvB,MAAM,KAAK,CAAC,QAAQ;IAI7B;IAEA,qBACE,0DAAC;QACE,GAAG,UAAU;QACb,GAAG,QAAQ;QACZ,KAAK;qBACL,0DAAC;QACC,KAAK;QACL,WACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,yDAAM,OAAD,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,sCAAI,EAAE,UAAU,CAAC;;AD9NpC","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} from '@react-types/shared';\nimport FolderBreadcrumb from '@spectrum-icons/ui/FolderBreadcrumb';\nimport {Menu, MenuTrigger} from '@react-spectrum/menu';\nimport React, {Key, 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, useValueEffect} from '@react-aria/utils';\nimport {useProviderProps} from '@react-spectrum/provider';\nimport {useResizeObserver} from '@react-aria/utils';\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 => {\n if (React.isValidElement(child)) {\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) => {\n // Refs can be null at runtime.\n let currListRef: HTMLUListElement | null = listRef.current;\n if (!currListRef) {\n return;\n }\n\n let listItems = Array.from(currListRef.children) as HTMLLIElement[];\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().offsetWidth;\n newVisibleItems++;\n }\n\n if (isShowingMenu) {\n calculatedWidth += listItems.shift().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();\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 // eslint-disable-next-line react-hooks/exhaustive-deps\n useLayoutEffect(updateOverflow, [children]);\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\">\n <MenuTrigger>\n <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 contents.unshift(breadcrumbs.shift());\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 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, getWrappedElement} 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\nexport function BreadcrumbItem(props: BreadcrumbItemProps) {\n let {\n children,\n isCurrent,\n isDisabled\n } = props;\n\n let {direction} = useLocale();\n let ref = useRef();\n let {itemProps} = useBreadcrumbItem({\n ...props,\n elementType: typeof children === 'string' ? 'span' : 'a'\n }, ref);\n let {hoverProps, isHovered} = useHover(props);\n\n let element = React.cloneElement(\n getWrappedElement(children),\n {\n ...mergeProps(itemProps, hoverProps),\n ref,\n className:\n classNames(\n styles,\n 'spectrum-Breadcrumbs-itemLink',\n {\n 'is-disabled': !isCurrent && isDisabled,\n 'is-hovered': isHovered\n }\n )\n }\n );\n\n return (\n <Fragment>\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')}>\n {element}\n </FocusRing>\n {isCurrent === false &&\n <ChevronRightSmall\n UNSAFE_className={\n classNames(\n styles,\n 'spectrum-Breadcrumbs-itemSeparator',\n {\n 'is-reversed': direction === 'rtl'\n }\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":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GACD,0CAA0C;ACX1C;;;;;;;;;;CAUC,GACD;ACXA;;;;;;;;;;CAUC,GAED;;;;;;;;;;;;;;;;;;;;;;;ACZA,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;AAfA,4CAAyC;AACzC,4CAAuD;AACvD,4CAAgC;AAChC,4CAA8C;AAC9C,2CAA0C;AAC1C,4CAAkD;AAClD,4CAA+B;AAC/B,4CAA+B;AAC/B,4CAA+B;AAC/B,4CAAgD;AAChD,4CAAiD;AACjD,4CAAoD;AACpD,4CAAgD;AAChD,4CAAgC;AAChC,4CAAgC;AAChC,4CAAwC;;;;;;ADQjC,SAAS,0CAAe,KAA0B,EAAE;IACzD,IAAI,YACF,SAAQ,aACR,UAAS,cACT,WAAU,EACX,GAAG;IAEJ,IAAI,aAAC,UAAS,EAAC,GAAG,CAAA,GAAA,8BAAS,AAAD;IAC1B,IAAI,MAAM,CAAA,GAAA,mBAAK,EAAE,IAAI;IACrB,IAAI,aAAC,UAAS,EAAC,GAAG,CAAA,GAAA,6CAAiB,AAAD,EAAE;QAClC,GAAG,KAAK;QACR,aAAa,OAAO,aAAa,WAAW,SAAS,GAAG;IAC1D,GAAG;IACH,IAAI,cAAC,WAAU,aAAE,UAAS,EAAC,GAAG,CAAA,GAAA,qCAAQ,AAAD,EAAE;IAEvC,IAAI,wBAAU,CAAA,GAAA,sCAAI,EAAE,YAAY,CAC9B,CAAA,GAAA,2CAAiB,AAAD,EA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AAU;QACnD,IAAI,YAAY,UAAU;YAChB;QAAV,IAAI,MAAM,CAAA,aAAA,MAAM,GAAG,cAAT,wBAAA,aAAa,KAAK;QAC5B,IAAI,UAAU,IAAM;YAClB,IAAI,UACF,SAAS;QAEb;QAEA,qBACE,0DAAC;YACC,KAAK;YACL,WACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,gEAAM,AAAD,GACL;yBAGJ,0DAAC,CAAA,GAAA,yCAAa;YACZ,KAAK;YACL,WAAW;YACX,YAAY;YACZ,SAAS;YACT,WAAW,aAAa;WACvB,MAAM,KAAK,CAAC,QAAQ;IAI7B;IAEA,qBACE,0DAAC;QACE,GAAG,UAAU;QACb,GAAG,QAAQ;QACZ,KAAK;qBACL,0DAAC;QACC,KAAK;QACL,WACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,yDAAM,OAAD,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,sCAAI,EAAE,UAAU,CAAC;;ADpOpC","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} from '@react-types/shared';\nimport FolderBreadcrumb from '@spectrum-icons/ui/FolderBreadcrumb';\nimport {Menu, MenuTrigger} from '@react-spectrum/menu';\nimport React, {Key, 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, useValueEffect} from '@react-aria/utils';\nimport {useProviderProps} from '@react-spectrum/provider';\nimport {useResizeObserver} from '@react-aria/utils';\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 => {\n if (React.isValidElement(child)) {\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 // eslint-disable-next-line react-hooks/exhaustive-deps\n useLayoutEffect(updateOverflow, [children]);\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\">\n <MenuTrigger>\n <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 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, getWrappedElement} 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\nexport function BreadcrumbItem(props: BreadcrumbItemProps) {\n let {\n children,\n isCurrent,\n isDisabled\n } = props;\n\n let {direction} = useLocale();\n let ref = useRef(null);\n let {itemProps} = useBreadcrumbItem({\n ...props,\n elementType: typeof children === 'string' ? 'span' : 'a'\n }, ref);\n let {hoverProps, isHovered} = useHover(props);\n\n let element = React.cloneElement(\n getWrappedElement(children),\n {\n ...mergeProps(itemProps, hoverProps),\n ref,\n className:\n classNames(\n styles,\n 'spectrum-Breadcrumbs-itemLink',\n {\n 'is-disabled': !isCurrent && isDisabled,\n 'is-hovered': isHovered\n }\n )\n }\n );\n\n return (\n <Fragment>\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')}>\n {element}\n </FocusRing>\n {isCurrent === false &&\n <ChevronRightSmall\n UNSAFE_className={\n classNames(\n styles,\n 'spectrum-Breadcrumbs-itemSeparator',\n {\n 'is-reversed': direction === 'rtl'\n }\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":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -114,7 +114,7 @@ $48e85557f3729e3d$export$45a5316056cfac3c = "spectrum-Breadcrumb_3fe6e8";
|
|
|
114
114
|
function $2bfa2c84c665c457$export$c13f210c706eb549(props) {
|
|
115
115
|
let { children: children , isCurrent: isCurrent , isDisabled: isDisabled } = props;
|
|
116
116
|
let { direction: direction } = (0, $koRP3$useLocale)();
|
|
117
|
-
let ref = (0, $koRP3$useRef)();
|
|
117
|
+
let ref = (0, $koRP3$useRef)(null);
|
|
118
118
|
let { itemProps: itemProps } = (0, $koRP3$useBreadcrumbItem)({
|
|
119
119
|
...props,
|
|
120
120
|
elementType: typeof children === "string" ? "span" : "a"
|
|
@@ -166,8 +166,9 @@ function $2adaf67aabd3300b$var$Breadcrumbs(props, ref) {
|
|
|
166
166
|
let computeVisibleItems = (visibleItems)=>{
|
|
167
167
|
// Refs can be null at runtime.
|
|
168
168
|
let currListRef = listRef.current;
|
|
169
|
-
if (!currListRef) return;
|
|
169
|
+
if (!currListRef) return visibleItems;
|
|
170
170
|
let listItems = Array.from(currListRef.children);
|
|
171
|
+
if (listItems.length <= 0) return visibleItems;
|
|
171
172
|
let containerWidth = currListRef.offsetWidth;
|
|
172
173
|
let isShowingMenu = childArray.length > visibleItems;
|
|
173
174
|
let calculatedWidth = 0;
|
|
@@ -254,7 +255,8 @@ function $2adaf67aabd3300b$var$Breadcrumbs(props, ref) {
|
|
|
254
255
|
];
|
|
255
256
|
let endItems = visibleItems;
|
|
256
257
|
if (showRoot && visibleItems > 1) {
|
|
257
|
-
|
|
258
|
+
let rootItem = breadcrumbs.shift();
|
|
259
|
+
if (rootItem) contents.unshift(rootItem);
|
|
258
260
|
endItems--;
|
|
259
261
|
}
|
|
260
262
|
contents.push(...breadcrumbs.slice(-endItems));
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GACD,0CAA0C;ACX1C;;;;;;;;;;CAUC,GACD;ACXA;;;;;;;;;;CAUC,GAED;;;;;;;;;;;;;;;;;;;;;;;ACZA,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;AAfA,4CAAyC;AACzC,4CAAuD;AACvD,4CAAgC;AAChC,4CAA8C;AAC9C,2CAA0C;AAC1C,4CAAkD;AAClD,4CAA+B;AAC/B,4CAA+B;AAC/B,4CAA+B;AAC/B,4CAAgD;AAChD,4CAAiD;AACjD,4CAAoD;AACpD,4CAAgD;AAChD,4CAAgC;AAChC,4CAAgC;AAChC,4CAAwC;;;;;;ADQjC,SAAS,0CAAe,KAA0B,EAAE;IACzD,IAAI,YACF,SAAQ,aACR,UAAS,cACT,WAAU,EACX,GAAG;IAEJ,IAAI,aAAC,UAAS,EAAC,GAAG,CAAA,GAAA,gBA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AAW;QACjC,IAAI,WAAW;QACf,IAAI,YAAY,eAAe,GAAG;YAChC,SAAS,OAAO,CAAC,YAAY,KAAK;YAClC;QACF,CAAC;QACD,SAAS,IAAI,IAAI,YAAY,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,YAAY,SAAS,MAAM,GAAG;IAClC,IAAI,kBAAkB,SAAS,GAAG,CAAC,CAAC,OAAO,QAAU;QACnD,IAAI,YAAY,UAAU;YAChB;QAAV,IAAI,MAAM,CAAA,aAAA,MAAM,GAAG,cAAT,wBAAA,aAAa,KAAK;QAC5B,IAAI,UAAU,IAAM;YAClB,IAAI,UACF,SAAS;QAEb;QAEA,qBACE,gCAAC;YACC,KAAK;YACL,WACE,CAAA,GAAA,iBAAS,EACP,CAAA,GAAA,gEAAM,AAAD,GACL;yBAGJ,gCAAC,CAAA,GAAA,yCAAa;YACZ,KAAK;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,yDAAM,OAAD,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;;AD9NpC","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} from '@react-types/shared';\nimport FolderBreadcrumb from '@spectrum-icons/ui/FolderBreadcrumb';\nimport {Menu, MenuTrigger} from '@react-spectrum/menu';\nimport React, {Key, 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, useValueEffect} from '@react-aria/utils';\nimport {useProviderProps} from '@react-spectrum/provider';\nimport {useResizeObserver} from '@react-aria/utils';\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 => {\n if (React.isValidElement(child)) {\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) => {\n // Refs can be null at runtime.\n let currListRef: HTMLUListElement | null = listRef.current;\n if (!currListRef) {\n return;\n }\n\n let listItems = Array.from(currListRef.children) as HTMLLIElement[];\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().offsetWidth;\n newVisibleItems++;\n }\n\n if (isShowingMenu) {\n calculatedWidth += listItems.shift().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();\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 // eslint-disable-next-line react-hooks/exhaustive-deps\n useLayoutEffect(updateOverflow, [children]);\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\">\n <MenuTrigger>\n <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 contents.unshift(breadcrumbs.shift());\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 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, getWrappedElement} 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\nexport function BreadcrumbItem(props: BreadcrumbItemProps) {\n let {\n children,\n isCurrent,\n isDisabled\n } = props;\n\n let {direction} = useLocale();\n let ref = useRef();\n let {itemProps} = useBreadcrumbItem({\n ...props,\n elementType: typeof children === 'string' ? 'span' : 'a'\n }, ref);\n let {hoverProps, isHovered} = useHover(props);\n\n let element = React.cloneElement(\n getWrappedElement(children),\n {\n ...mergeProps(itemProps, hoverProps),\n ref,\n className:\n classNames(\n styles,\n 'spectrum-Breadcrumbs-itemLink',\n {\n 'is-disabled': !isCurrent && isDisabled,\n 'is-hovered': isHovered\n }\n )\n }\n );\n\n return (\n <Fragment>\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')}>\n {element}\n </FocusRing>\n {isCurrent === false &&\n <ChevronRightSmall\n UNSAFE_className={\n classNames(\n styles,\n 'spectrum-Breadcrumbs-itemSeparator',\n {\n 'is-reversed': direction === 'rtl'\n }\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;ACX1C;;;;;;;;;;CAUC,GACD;ACXA;;;;;;;;;;CAUC,GAED;;;;;;;;;;;;;;;;;;;;;;;ACZA,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;AAfA,4CAAyC;AACzC,4CAAuD;AACvD,4CAAgC;AAChC,4CAA8C;AAC9C,2CAA0C;AAC1C,4CAAkD;AAClD,4CAA+B;AAC/B,4CAA+B;AAC/B,4CAA+B;AAC/B,4CAAgD;AAChD,4CAAiD;AAC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;AAEA;;CAEC,GACD,IAAI,yDAAe,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC;;ADpOpC","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} from '@react-types/shared';\nimport FolderBreadcrumb from '@spectrum-icons/ui/FolderBreadcrumb';\nimport {Menu, MenuTrigger} from '@react-spectrum/menu';\nimport React, {Key, 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, useValueEffect} from '@react-aria/utils';\nimport {useProviderProps} from '@react-spectrum/provider';\nimport {useResizeObserver} from '@react-aria/utils';\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 => {\n if (React.isValidElement(child)) {\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 // eslint-disable-next-line react-hooks/exhaustive-deps\n useLayoutEffect(updateOverflow, [children]);\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\">\n <MenuTrigger>\n <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 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, getWrappedElement} 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\nexport function BreadcrumbItem(props: BreadcrumbItemProps) {\n let {\n children,\n isCurrent,\n isDisabled\n } = props;\n\n let {direction} = useLocale();\n let ref = useRef(null);\n let {itemProps} = useBreadcrumbItem({\n ...props,\n elementType: typeof children === 'string' ? 'span' : 'a'\n }, ref);\n let {hoverProps, isHovered} = useHover(props);\n\n let element = React.cloneElement(\n getWrappedElement(children),\n {\n ...mergeProps(itemProps, hoverProps),\n ref,\n className:\n classNames(\n styles,\n 'spectrum-Breadcrumbs-itemLink',\n {\n 'is-disabled': !isCurrent && isDisabled,\n 'is-hovered': isHovered\n }\n )\n }\n );\n\n return (\n <Fragment>\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')}>\n {element}\n </FocusRing>\n {isCurrent === false &&\n <ChevronRightSmall\n UNSAFE_className={\n classNames(\n styles,\n 'spectrum-Breadcrumbs-itemSeparator',\n {\n 'is-reversed': direction === 'rtl'\n }\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"}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;
|
|
1
|
+
{"mappings":";;AC6OA;;GAEG;AACH,OAAA,IAAI,6JAA4C,CAAC;ACnOjD,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"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/breadcrumbs",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.1",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"module": "dist/module.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
"types": "./dist/types.d.ts",
|
|
10
|
+
"import": "./dist/import.mjs",
|
|
11
|
+
"require": "./dist/main.js"
|
|
12
|
+
},
|
|
8
13
|
"types": "dist/types.d.ts",
|
|
9
14
|
"source": "src/index.ts",
|
|
10
15
|
"files": [
|
|
@@ -31,18 +36,18 @@
|
|
|
31
36
|
"url": "https://github.com/adobe/react-spectrum"
|
|
32
37
|
},
|
|
33
38
|
"dependencies": {
|
|
34
|
-
"@react-aria/breadcrumbs": "^3.
|
|
35
|
-
"@react-aria/focus": "^3.
|
|
36
|
-
"@react-aria/i18n": "^3.
|
|
37
|
-
"@react-aria/interactions": "^3.
|
|
38
|
-
"@react-aria/utils": "^3.
|
|
39
|
-
"@react-spectrum/button": "^3.
|
|
40
|
-
"@react-spectrum/menu": "^3.
|
|
41
|
-
"@react-spectrum/utils": "^3.
|
|
42
|
-
"@react-stately/collections": "^3.
|
|
43
|
-
"@react-types/breadcrumbs": "^3.
|
|
44
|
-
"@react-types/shared": "^3.
|
|
45
|
-
"@spectrum-icons/ui": "^3.
|
|
39
|
+
"@react-aria/breadcrumbs": "^3.5.0",
|
|
40
|
+
"@react-aria/focus": "^3.11.0",
|
|
41
|
+
"@react-aria/i18n": "^3.7.0",
|
|
42
|
+
"@react-aria/interactions": "^3.14.0",
|
|
43
|
+
"@react-aria/utils": "^3.15.0",
|
|
44
|
+
"@react-spectrum/button": "^3.12.0",
|
|
45
|
+
"@react-spectrum/menu": "^3.10.1",
|
|
46
|
+
"@react-spectrum/utils": "^3.9.0",
|
|
47
|
+
"@react-stately/collections": "^3.6.0",
|
|
48
|
+
"@react-types/breadcrumbs": "^3.5.0",
|
|
49
|
+
"@react-types/shared": "^3.17.0",
|
|
50
|
+
"@spectrum-icons/ui": "^3.5.0",
|
|
46
51
|
"@swc/helpers": "^0.4.14"
|
|
47
52
|
},
|
|
48
53
|
"devDependencies": {
|
|
@@ -56,5 +61,5 @@
|
|
|
56
61
|
"publishConfig": {
|
|
57
62
|
"access": "public"
|
|
58
63
|
},
|
|
59
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "e00dfc4ca2961753b8b1037d209992adb86a0ea7"
|
|
60
65
|
}
|
package/src/BreadcrumbItem.tsx
CHANGED
|
@@ -29,7 +29,7 @@ export function BreadcrumbItem(props: BreadcrumbItemProps) {
|
|
|
29
29
|
} = props;
|
|
30
30
|
|
|
31
31
|
let {direction} = useLocale();
|
|
32
|
-
let ref = useRef();
|
|
32
|
+
let ref = useRef(null);
|
|
33
33
|
let {itemProps} = useBreadcrumbItem({
|
|
34
34
|
...props,
|
|
35
35
|
elementType: typeof children === 'string' ? 'span' : 'a'
|
package/src/Breadcrumbs.tsx
CHANGED
|
@@ -56,14 +56,17 @@ function Breadcrumbs<T>(props: SpectrumBreadcrumbsProps<T>, ref: DOMRef) {
|
|
|
56
56
|
let {styleProps} = useStyleProps(otherProps);
|
|
57
57
|
|
|
58
58
|
let updateOverflow = useCallback(() => {
|
|
59
|
-
let computeVisibleItems = (visibleItems: number) => {
|
|
59
|
+
let computeVisibleItems = (visibleItems: number): number => {
|
|
60
60
|
// Refs can be null at runtime.
|
|
61
61
|
let currListRef: HTMLUListElement | null = listRef.current;
|
|
62
62
|
if (!currListRef) {
|
|
63
|
-
return;
|
|
63
|
+
return visibleItems;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
let listItems = Array.from(currListRef.children) as HTMLLIElement[];
|
|
67
|
+
if (listItems.length <= 0) {
|
|
68
|
+
return visibleItems;
|
|
69
|
+
}
|
|
67
70
|
let containerWidth = currListRef.offsetWidth;
|
|
68
71
|
let isShowingMenu = childArray.length > visibleItems;
|
|
69
72
|
let calculatedWidth = 0;
|
|
@@ -71,12 +74,12 @@ function Breadcrumbs<T>(props: SpectrumBreadcrumbsProps<T>, ref: DOMRef) {
|
|
|
71
74
|
let maxVisibleItems = MAX_VISIBLE_ITEMS;
|
|
72
75
|
|
|
73
76
|
if (showRoot) {
|
|
74
|
-
calculatedWidth += listItems.shift().offsetWidth;
|
|
77
|
+
calculatedWidth += (listItems.shift() as HTMLLIElement).offsetWidth;
|
|
75
78
|
newVisibleItems++;
|
|
76
79
|
}
|
|
77
80
|
|
|
78
81
|
if (isShowingMenu) {
|
|
79
|
-
calculatedWidth += listItems.shift().offsetWidth;
|
|
82
|
+
calculatedWidth += (listItems.shift() as HTMLLIElement).offsetWidth;
|
|
80
83
|
maxVisibleItems--;
|
|
81
84
|
}
|
|
82
85
|
|
|
@@ -91,7 +94,7 @@ function Breadcrumbs<T>(props: SpectrumBreadcrumbsProps<T>, ref: DOMRef) {
|
|
|
91
94
|
} else {
|
|
92
95
|
if (listItems.length > 0) {
|
|
93
96
|
// Ensure the last breadcrumb isn't truncated when we measure it.
|
|
94
|
-
let last = listItems.pop();
|
|
97
|
+
let last = (listItems.pop() as HTMLLIElement);
|
|
95
98
|
last.style.overflow = 'visible';
|
|
96
99
|
|
|
97
100
|
calculatedWidth += last.offsetWidth;
|
|
@@ -165,7 +168,10 @@ function Breadcrumbs<T>(props: SpectrumBreadcrumbsProps<T>, ref: DOMRef) {
|
|
|
165
168
|
let breadcrumbs = [...childArray];
|
|
166
169
|
let endItems = visibleItems;
|
|
167
170
|
if (showRoot && visibleItems > 1) {
|
|
168
|
-
|
|
171
|
+
let rootItem = breadcrumbs.shift();
|
|
172
|
+
if (rootItem) {
|
|
173
|
+
contents.unshift(rootItem);
|
|
174
|
+
}
|
|
169
175
|
endItems--;
|
|
170
176
|
}
|
|
171
177
|
contents.push(...breadcrumbs.slice(-endItems));
|