@react-spectrum/breadcrumbs 3.2.6 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +123 -122
- package/dist/main.js.map +1 -1
- package/dist/module.js +109 -108
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/Breadcrumbs.tsx +16 -11
package/dist/main.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
require("./main.css");
|
|
2
|
-
var $
|
|
3
|
-
var $
|
|
4
|
-
var $
|
|
5
|
-
var $
|
|
6
|
-
var $
|
|
7
|
-
var $
|
|
8
|
-
var $
|
|
9
|
-
var $
|
|
10
|
-
var $
|
|
11
|
-
var $
|
|
12
|
-
var $
|
|
13
|
-
var $
|
|
14
|
-
var $
|
|
2
|
+
var $8bWUw$reactstatelycollections = require("@react-stately/collections");
|
|
3
|
+
var $8bWUw$reactspectrumbutton = require("@react-spectrum/button");
|
|
4
|
+
var $8bWUw$reactspectrumutils = require("@react-spectrum/utils");
|
|
5
|
+
var $8bWUw$spectrumiconsuiFolderBreadcrumb = require("@spectrum-icons/ui/FolderBreadcrumb");
|
|
6
|
+
var $8bWUw$reactspectrummenu = require("@react-spectrum/menu");
|
|
7
|
+
var $8bWUw$react = require("react");
|
|
8
|
+
var $8bWUw$reactariabreadcrumbs = require("@react-aria/breadcrumbs");
|
|
9
|
+
var $8bWUw$reactariautils = require("@react-aria/utils");
|
|
10
|
+
var $8bWUw$reactspectrumprovider = require("@react-spectrum/provider");
|
|
11
|
+
var $8bWUw$spectrumiconsuiChevronRightSmall = require("@spectrum-icons/ui/ChevronRightSmall");
|
|
12
|
+
var $8bWUw$reactariafocus = require("@react-aria/focus");
|
|
13
|
+
var $8bWUw$reactariainteractions = require("@react-aria/interactions");
|
|
14
|
+
var $8bWUw$reactariai18n = require("@react-aria/i18n");
|
|
15
15
|
|
|
16
16
|
function $parcel$export(e, n, v, s) {
|
|
17
17
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
@@ -36,92 +36,92 @@ function $parcel$interopDefault(a) {
|
|
|
36
36
|
return a && a.__esModule ? a.default : a;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
$parcel$export(module.exports, "Item", () => $
|
|
40
|
-
var $
|
|
41
|
-
|
|
42
|
-
$parcel$export($
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var $
|
|
50
|
-
|
|
51
|
-
$parcel$export($
|
|
52
|
-
$parcel$export($
|
|
53
|
-
$parcel$export($
|
|
54
|
-
$parcel$export($
|
|
55
|
-
$parcel$export($
|
|
56
|
-
$parcel$export($
|
|
57
|
-
$parcel$export($
|
|
58
|
-
$parcel$export($
|
|
59
|
-
$parcel$export($
|
|
60
|
-
$parcel$export($
|
|
61
|
-
$parcel$export($
|
|
62
|
-
$parcel$export($
|
|
63
|
-
$parcel$export($
|
|
64
|
-
$parcel$export($
|
|
65
|
-
$parcel$export($
|
|
66
|
-
$parcel$export($
|
|
67
|
-
var $
|
|
68
|
-
var $
|
|
69
|
-
var $
|
|
70
|
-
var $
|
|
71
|
-
var $
|
|
72
|
-
var $
|
|
73
|
-
var $
|
|
74
|
-
var $
|
|
75
|
-
var $
|
|
76
|
-
var $
|
|
77
|
-
var $
|
|
78
|
-
var $
|
|
79
|
-
var $
|
|
80
|
-
var $
|
|
81
|
-
var $
|
|
82
|
-
var $
|
|
83
|
-
$
|
|
84
|
-
$
|
|
85
|
-
$
|
|
86
|
-
$
|
|
87
|
-
$
|
|
88
|
-
$
|
|
89
|
-
$
|
|
90
|
-
$
|
|
91
|
-
$
|
|
92
|
-
$
|
|
93
|
-
$
|
|
94
|
-
$
|
|
95
|
-
$
|
|
96
|
-
$
|
|
97
|
-
$
|
|
98
|
-
$
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
function $
|
|
39
|
+
$parcel$export(module.exports, "Item", () => $8bWUw$reactstatelycollections.Item);
|
|
40
|
+
var $299bf776d9162a05$exports = {};
|
|
41
|
+
|
|
42
|
+
$parcel$export($299bf776d9162a05$exports, "Breadcrumbs", () => $299bf776d9162a05$export$2dc68d50d56fbbd);
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
var $3292ef9f328419fc$exports = {};
|
|
50
|
+
|
|
51
|
+
$parcel$export($3292ef9f328419fc$exports, "spectrum-Breadcrumbs", () => $3292ef9f328419fc$export$8c6320d2db82081f, (v) => $3292ef9f328419fc$export$8c6320d2db82081f = v);
|
|
52
|
+
$parcel$export($3292ef9f328419fc$exports, "spectrum-Breadcrumbs-itemSeparator", () => $3292ef9f328419fc$export$f72910e36cd91d1e, (v) => $3292ef9f328419fc$export$f72910e36cd91d1e = v);
|
|
53
|
+
$parcel$export($3292ef9f328419fc$exports, "is-reversed", () => $3292ef9f328419fc$export$a4561bd665abb5db, (v) => $3292ef9f328419fc$export$a4561bd665abb5db = v);
|
|
54
|
+
$parcel$export($3292ef9f328419fc$exports, "spectrum-Breadcrumbs-item", () => $3292ef9f328419fc$export$492a5983c5fbf603, (v) => $3292ef9f328419fc$export$492a5983c5fbf603 = v);
|
|
55
|
+
$parcel$export($3292ef9f328419fc$exports, "spectrum-ActionButton", () => $3292ef9f328419fc$export$53da69f51b770d3, (v) => $3292ef9f328419fc$export$53da69f51b770d3 = v);
|
|
56
|
+
$parcel$export($3292ef9f328419fc$exports, "spectrum-Breadcrumbs-itemLink", () => $3292ef9f328419fc$export$5af6a1bcd207d9f6, (v) => $3292ef9f328419fc$export$5af6a1bcd207d9f6 = v);
|
|
57
|
+
$parcel$export($3292ef9f328419fc$exports, "is-hovered", () => $3292ef9f328419fc$export$b8813cd5d7824ce7, (v) => $3292ef9f328419fc$export$b8813cd5d7824ce7 = v);
|
|
58
|
+
$parcel$export($3292ef9f328419fc$exports, "focus-ring", () => $3292ef9f328419fc$export$f39a09f249340e2a, (v) => $3292ef9f328419fc$export$f39a09f249340e2a = v);
|
|
59
|
+
$parcel$export($3292ef9f328419fc$exports, "is-dragged", () => $3292ef9f328419fc$export$8778c911bed6c759, (v) => $3292ef9f328419fc$export$8778c911bed6c759 = v);
|
|
60
|
+
$parcel$export($3292ef9f328419fc$exports, "spectrum-Breadcrumbs--small", () => $3292ef9f328419fc$export$e01337e7944312f6, (v) => $3292ef9f328419fc$export$e01337e7944312f6 = v);
|
|
61
|
+
$parcel$export($3292ef9f328419fc$exports, "spectrum-Breadcrumbs--medium", () => $3292ef9f328419fc$export$19f957201d941895, (v) => $3292ef9f328419fc$export$19f957201d941895 = v);
|
|
62
|
+
$parcel$export($3292ef9f328419fc$exports, "spectrum-Breadcrumbs--multiline", () => $3292ef9f328419fc$export$713961e8e432825b, (v) => $3292ef9f328419fc$export$713961e8e432825b = v);
|
|
63
|
+
$parcel$export($3292ef9f328419fc$exports, "spectrum-Heading--pageTitle", () => $3292ef9f328419fc$export$63e9e087a73f808b, (v) => $3292ef9f328419fc$export$63e9e087a73f808b = v);
|
|
64
|
+
$parcel$export($3292ef9f328419fc$exports, "is-disabled", () => $3292ef9f328419fc$export$d35bc1e505d1ebbf, (v) => $3292ef9f328419fc$export$d35bc1e505d1ebbf = v);
|
|
65
|
+
$parcel$export($3292ef9f328419fc$exports, "is-selected", () => $3292ef9f328419fc$export$1e0fb04f31d3c22a, (v) => $3292ef9f328419fc$export$1e0fb04f31d3c22a = v);
|
|
66
|
+
$parcel$export($3292ef9f328419fc$exports, "spectrum-Breadcrumb", () => $3292ef9f328419fc$export$45a5316056cfac3c, (v) => $3292ef9f328419fc$export$45a5316056cfac3c = v);
|
|
67
|
+
var $3292ef9f328419fc$export$8c6320d2db82081f;
|
|
68
|
+
var $3292ef9f328419fc$export$f72910e36cd91d1e;
|
|
69
|
+
var $3292ef9f328419fc$export$a4561bd665abb5db;
|
|
70
|
+
var $3292ef9f328419fc$export$492a5983c5fbf603;
|
|
71
|
+
var $3292ef9f328419fc$export$53da69f51b770d3;
|
|
72
|
+
var $3292ef9f328419fc$export$5af6a1bcd207d9f6;
|
|
73
|
+
var $3292ef9f328419fc$export$b8813cd5d7824ce7;
|
|
74
|
+
var $3292ef9f328419fc$export$f39a09f249340e2a;
|
|
75
|
+
var $3292ef9f328419fc$export$8778c911bed6c759;
|
|
76
|
+
var $3292ef9f328419fc$export$e01337e7944312f6;
|
|
77
|
+
var $3292ef9f328419fc$export$19f957201d941895;
|
|
78
|
+
var $3292ef9f328419fc$export$713961e8e432825b;
|
|
79
|
+
var $3292ef9f328419fc$export$63e9e087a73f808b;
|
|
80
|
+
var $3292ef9f328419fc$export$d35bc1e505d1ebbf;
|
|
81
|
+
var $3292ef9f328419fc$export$1e0fb04f31d3c22a;
|
|
82
|
+
var $3292ef9f328419fc$export$45a5316056cfac3c;
|
|
83
|
+
$3292ef9f328419fc$export$8c6320d2db82081f = "spectrum-Breadcrumbs_3fe6e8";
|
|
84
|
+
$3292ef9f328419fc$export$f72910e36cd91d1e = "spectrum-Breadcrumbs-itemSeparator_3fe6e8";
|
|
85
|
+
$3292ef9f328419fc$export$a4561bd665abb5db = "is-reversed_3fe6e8";
|
|
86
|
+
$3292ef9f328419fc$export$492a5983c5fbf603 = "spectrum-Breadcrumbs-item_3fe6e8";
|
|
87
|
+
$3292ef9f328419fc$export$53da69f51b770d3 = "spectrum-ActionButton_3fe6e8";
|
|
88
|
+
$3292ef9f328419fc$export$5af6a1bcd207d9f6 = "spectrum-Breadcrumbs-itemLink_3fe6e8";
|
|
89
|
+
$3292ef9f328419fc$export$b8813cd5d7824ce7 = "is-hovered_3fe6e8";
|
|
90
|
+
$3292ef9f328419fc$export$f39a09f249340e2a = "focus-ring_3fe6e8";
|
|
91
|
+
$3292ef9f328419fc$export$8778c911bed6c759 = "is-dragged_3fe6e8";
|
|
92
|
+
$3292ef9f328419fc$export$e01337e7944312f6 = "spectrum-Breadcrumbs--small_3fe6e8";
|
|
93
|
+
$3292ef9f328419fc$export$19f957201d941895 = "spectrum-Breadcrumbs--medium_3fe6e8";
|
|
94
|
+
$3292ef9f328419fc$export$713961e8e432825b = "spectrum-Breadcrumbs--multiline_3fe6e8";
|
|
95
|
+
$3292ef9f328419fc$export$63e9e087a73f808b = "spectrum-Heading--pageTitle_3fe6e8";
|
|
96
|
+
$3292ef9f328419fc$export$d35bc1e505d1ebbf = "is-disabled_3fe6e8";
|
|
97
|
+
$3292ef9f328419fc$export$1e0fb04f31d3c22a = "is-selected_3fe6e8";
|
|
98
|
+
$3292ef9f328419fc$export$45a5316056cfac3c = "spectrum-Breadcrumb_3fe6e8";
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
function $d90ab02c74e9be0c$export$c13f210c706eb549(props) {
|
|
105
105
|
let { children: children , isCurrent: isCurrent , isDisabled: isDisabled } = props;
|
|
106
|
-
let { direction: direction } = $
|
|
107
|
-
let ref = $
|
|
108
|
-
let { itemProps: itemProps } = $
|
|
106
|
+
let { direction: direction } = $8bWUw$reactariai18n.useLocale();
|
|
107
|
+
let ref = $8bWUw$react.useRef();
|
|
108
|
+
let { itemProps: itemProps } = $8bWUw$reactariabreadcrumbs.useBreadcrumbItem({
|
|
109
109
|
...props,
|
|
110
110
|
elementType: typeof children === 'string' ? 'span' : 'a'
|
|
111
111
|
}, ref);
|
|
112
|
-
let { hoverProps: hoverProps , isHovered: isHovered } = $
|
|
113
|
-
let element = /*#__PURE__*/ ($parcel$interopDefault($
|
|
114
|
-
...$
|
|
112
|
+
let { hoverProps: hoverProps , isHovered: isHovered } = $8bWUw$reactariainteractions.useHover(props);
|
|
113
|
+
let element = /*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).cloneElement($8bWUw$reactspectrumutils.getWrappedElement(children), {
|
|
114
|
+
...$8bWUw$reactariautils.mergeProps(itemProps, hoverProps),
|
|
115
115
|
ref: ref,
|
|
116
|
-
className: $
|
|
116
|
+
className: $8bWUw$reactspectrumutils.classNames((/*@__PURE__*/$parcel$interopDefault($3292ef9f328419fc$exports)), 'spectrum-Breadcrumbs-itemLink', {
|
|
117
117
|
'is-disabled': !isCurrent && isDisabled,
|
|
118
118
|
'is-hovered': isHovered
|
|
119
119
|
})
|
|
120
120
|
});
|
|
121
|
-
return(/*#__PURE__*/ ($parcel$interopDefault($
|
|
122
|
-
focusRingClass: $
|
|
123
|
-
}, element), isCurrent === false && /*#__PURE__*/ ($parcel$interopDefault($
|
|
124
|
-
UNSAFE_className: $
|
|
121
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).createElement($8bWUw$react.Fragment, null, /*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).createElement($8bWUw$reactariafocus.FocusRing, {
|
|
122
|
+
focusRingClass: $8bWUw$reactspectrumutils.classNames((/*@__PURE__*/$parcel$interopDefault($3292ef9f328419fc$exports)), 'focus-ring')
|
|
123
|
+
}, element), isCurrent === false && /*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).createElement(($parcel$interopDefault($8bWUw$spectrumiconsuiChevronRightSmall)), {
|
|
124
|
+
UNSAFE_className: $8bWUw$reactspectrumutils.classNames((/*@__PURE__*/$parcel$interopDefault($3292ef9f328419fc$exports)), 'spectrum-Breadcrumbs-itemSeparator', {
|
|
125
125
|
'is-reversed': direction === 'rtl'
|
|
126
126
|
})
|
|
127
127
|
})));
|
|
@@ -137,22 +137,22 @@ function $01a6adf6454cb0d0$export$c13f210c706eb549(props) {
|
|
|
137
137
|
|
|
138
138
|
|
|
139
139
|
|
|
140
|
-
const $
|
|
141
|
-
const $
|
|
142
|
-
function $
|
|
143
|
-
props = $
|
|
144
|
-
let { size: size = 'L' , isMultiline: isMultiline , children: children , showRoot: showRoot , isDisabled: isDisabled , onAction: onAction , ...otherProps } = props;
|
|
140
|
+
const $299bf776d9162a05$var$MIN_VISIBLE_ITEMS = 1;
|
|
141
|
+
const $299bf776d9162a05$var$MAX_VISIBLE_ITEMS = 4;
|
|
142
|
+
function $299bf776d9162a05$var$Breadcrumbs(props, ref) {
|
|
143
|
+
props = $8bWUw$reactspectrumprovider.useProviderProps(props);
|
|
144
|
+
let { size: size = 'L' , isMultiline: isMultiline , children: children , showRoot: showRoot , isDisabled: isDisabled , onAction: onAction , autoFocusCurrent: autoFocusCurrent , ...otherProps } = props;
|
|
145
145
|
// Not using React.Children.toArray because it mutates the key prop.
|
|
146
146
|
let childArray = [];
|
|
147
|
-
($parcel$interopDefault($
|
|
148
|
-
if (/*#__PURE__*/ ($parcel$interopDefault($
|
|
147
|
+
($parcel$interopDefault($8bWUw$react)).Children.forEach(children, (child)=>{
|
|
148
|
+
if (/*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).isValidElement(child)) childArray.push(child);
|
|
149
149
|
});
|
|
150
|
-
let domRef = $
|
|
151
|
-
let listRef = $
|
|
152
|
-
let [visibleItems1, setVisibleItems] = $
|
|
153
|
-
let { navProps: navProps } = $
|
|
154
|
-
let { styleProps: styleProps } = $
|
|
155
|
-
let updateOverflow = $
|
|
150
|
+
let domRef = $8bWUw$reactspectrumutils.useDOMRef(ref);
|
|
151
|
+
let listRef = $8bWUw$react.useRef(null);
|
|
152
|
+
let [visibleItems1, setVisibleItems] = $8bWUw$reactariautils.useValueEffect(childArray.length);
|
|
153
|
+
let { navProps: navProps } = $8bWUw$reactariabreadcrumbs.useBreadcrumbs(props);
|
|
154
|
+
let { styleProps: styleProps } = $8bWUw$reactspectrumutils.useStyleProps(otherProps);
|
|
155
|
+
let updateOverflow = $8bWUw$react.useCallback(()=>{
|
|
156
156
|
let computeVisibleItems = (visibleItems)=>{
|
|
157
157
|
// Refs can be null at runtime.
|
|
158
158
|
let currListRef = listRef.current;
|
|
@@ -162,7 +162,7 @@ function $ce45029bf0c8e0f0$var$Breadcrumbs(props, ref) {
|
|
|
162
162
|
let isShowingMenu = childArray.length > visibleItems;
|
|
163
163
|
let calculatedWidth = 0;
|
|
164
164
|
let newVisibleItems = 0;
|
|
165
|
-
let maxVisibleItems = $
|
|
165
|
+
let maxVisibleItems = $299bf776d9162a05$var$MAX_VISIBLE_ITEMS;
|
|
166
166
|
if (showRoot) {
|
|
167
167
|
calculatedWidth += listItems.shift().offsetWidth;
|
|
168
168
|
newVisibleItems++;
|
|
@@ -176,7 +176,7 @@ function $ce45029bf0c8e0f0$var$Breadcrumbs(props, ref) {
|
|
|
176
176
|
if (isMultiline) {
|
|
177
177
|
listItems.pop();
|
|
178
178
|
newVisibleItems++;
|
|
179
|
-
} else {
|
|
179
|
+
} else if (listItems.length > 0) {
|
|
180
180
|
// Ensure the last breadcrumb isn't truncated when we measure it.
|
|
181
181
|
let last = listItems.pop();
|
|
182
182
|
last.style.overflow = 'visible';
|
|
@@ -188,7 +188,7 @@ function $ce45029bf0c8e0f0$var$Breadcrumbs(props, ref) {
|
|
|
188
188
|
calculatedWidth += breadcrumb.offsetWidth;
|
|
189
189
|
if (calculatedWidth < containerWidth) newVisibleItems++;
|
|
190
190
|
}
|
|
191
|
-
return Math.max($
|
|
191
|
+
return Math.max($299bf776d9162a05$var$MIN_VISIBLE_ITEMS, Math.min(maxVisibleItems, newVisibleItems));
|
|
192
192
|
};
|
|
193
193
|
setVisibleItems(function*() {
|
|
194
194
|
// Update to show all items.
|
|
@@ -201,17 +201,16 @@ function $ce45029bf0c8e0f0$var$Breadcrumbs(props, ref) {
|
|
|
201
201
|
if (newVisibleItems < childArray.length && newVisibleItems > 1) yield computeVisibleItems(newVisibleItems);
|
|
202
202
|
});
|
|
203
203
|
}, [
|
|
204
|
-
|
|
205
|
-
children,
|
|
204
|
+
childArray.length,
|
|
206
205
|
setVisibleItems,
|
|
207
206
|
showRoot,
|
|
208
207
|
isMultiline
|
|
209
208
|
]);
|
|
210
|
-
$
|
|
209
|
+
$8bWUw$reactariautils.useResizeObserver({
|
|
211
210
|
ref: domRef,
|
|
212
211
|
onResize: updateOverflow
|
|
213
212
|
});
|
|
214
|
-
$
|
|
213
|
+
$8bWUw$reactariautils.useLayoutEffect(updateOverflow, [
|
|
215
214
|
children
|
|
216
215
|
]);
|
|
217
216
|
let contents = childArray;
|
|
@@ -223,13 +222,13 @@ function $ce45029bf0c8e0f0$var$Breadcrumbs(props, ref) {
|
|
|
223
222
|
// Don't fire onAction when clicking on the last item
|
|
224
223
|
if (key !== selectedKey && onAction) onAction(key);
|
|
225
224
|
};
|
|
226
|
-
let menuItem = /*#__PURE__*/ ($parcel$interopDefault($
|
|
225
|
+
let menuItem = /*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).createElement($d90ab02c74e9be0c$export$c13f210c706eb549, {
|
|
227
226
|
key: "menu"
|
|
228
|
-
}, /*#__PURE__*/ ($parcel$interopDefault($
|
|
227
|
+
}, /*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).createElement($8bWUw$reactspectrummenu.MenuTrigger, null, /*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).createElement($8bWUw$reactspectrumbutton.ActionButton, {
|
|
229
228
|
"aria-label": "…",
|
|
230
229
|
isQuiet: true,
|
|
231
230
|
isDisabled: isDisabled
|
|
232
|
-
}, /*#__PURE__*/ ($parcel$interopDefault($
|
|
231
|
+
}, /*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).createElement(($parcel$interopDefault($8bWUw$spectrumiconsuiFolderBreadcrumb)), null)), /*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).createElement($8bWUw$reactspectrummenu.Menu, {
|
|
233
232
|
selectionMode: "single",
|
|
234
233
|
selectedKeys: [
|
|
235
234
|
selectedKey
|
|
@@ -257,22 +256,24 @@ function $ce45029bf0c8e0f0$var$Breadcrumbs(props, ref) {
|
|
|
257
256
|
let onPress = ()=>{
|
|
258
257
|
if (onAction) onAction(key);
|
|
259
258
|
};
|
|
260
|
-
return(/*#__PURE__*/ ($parcel$interopDefault($
|
|
259
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).createElement("li", {
|
|
260
|
+
key: index,
|
|
261
|
+
className: $8bWUw$reactspectrumutils.classNames((/*@__PURE__*/$parcel$interopDefault($3292ef9f328419fc$exports)), 'spectrum-Breadcrumbs-item')
|
|
262
|
+
}, /*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).createElement($d90ab02c74e9be0c$export$c13f210c706eb549, {
|
|
261
263
|
key: key,
|
|
262
|
-
className: $6zINN$reactspectrumutils.classNames((/*@__PURE__*/$parcel$interopDefault($7d405af0aae01906$exports)), 'spectrum-Breadcrumbs-item')
|
|
263
|
-
}, /*#__PURE__*/ ($parcel$interopDefault($6zINN$react)).createElement($01a6adf6454cb0d0$export$c13f210c706eb549, {
|
|
264
264
|
isCurrent: isCurrent,
|
|
265
265
|
isDisabled: isDisabled,
|
|
266
|
-
onPress: onPress
|
|
266
|
+
onPress: onPress,
|
|
267
|
+
autoFocus: isCurrent && autoFocusCurrent
|
|
267
268
|
}, child.props.children)));
|
|
268
269
|
});
|
|
269
|
-
return(/*#__PURE__*/ ($parcel$interopDefault($
|
|
270
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).createElement("nav", {
|
|
270
271
|
...styleProps,
|
|
271
272
|
...navProps,
|
|
272
273
|
ref: domRef
|
|
273
|
-
}, /*#__PURE__*/ ($parcel$interopDefault($
|
|
274
|
+
}, /*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).createElement("ul", {
|
|
274
275
|
ref: listRef,
|
|
275
|
-
className: $
|
|
276
|
+
className: $8bWUw$reactspectrumutils.classNames((/*@__PURE__*/$parcel$interopDefault($3292ef9f328419fc$exports)), 'spectrum-Breadcrumbs', {
|
|
276
277
|
'spectrum-Breadcrumbs--small': size === 'S',
|
|
277
278
|
'spectrum-Breadcrumbs--medium': size === 'M',
|
|
278
279
|
'spectrum-Breadcrumbs--multiline': isMultiline,
|
|
@@ -283,11 +284,11 @@ function $ce45029bf0c8e0f0$var$Breadcrumbs(props, ref) {
|
|
|
283
284
|
}
|
|
284
285
|
/**
|
|
285
286
|
* Breadcrumbs show hierarchy and navigational context for a user’s location within an application.
|
|
286
|
-
*/ let $
|
|
287
|
+
*/ let $299bf776d9162a05$export$2dc68d50d56fbbd = /*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).forwardRef($299bf776d9162a05$var$Breadcrumbs);
|
|
287
288
|
|
|
288
289
|
|
|
289
290
|
|
|
290
|
-
$parcel$exportWildcard(module.exports, $
|
|
291
|
+
$parcel$exportWildcard(module.exports, $299bf776d9162a05$exports);
|
|
291
292
|
|
|
292
293
|
|
|
293
294
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AGAA,GAAsC;AACtC,GAAoD;AACpD,GAA6B;AAC7B,GAA2C;AAC3C,GAAuC;AACvC,GAA+C;AAC/C,GAA4B;AAC5B,GAA4B;AAC5B,GAA4B;AAC5B,GAA6C;AAC7C,GAA8C;AAC9C,GAAiD;AACjD,GAA6C;AAC7C,GAA6B;AAC7B,GAA6B;AAC7B,GAAqC;AAfrC,yCAAsC,GAAG,CAA6B;AACtE,yCAAoD,GAAG,CAA2C;AAClG,yCAA6B,GAAG,CAAoB;AACpD,yCAA2C,GAAG,CAAkC;AAChF,wCAAuC,GAAG,CAA8B;AACxE,yCAA+C,GAAG,CAAsC;AACxF,yCAA4B,GAAG,CAAmB;AAClD,yCAA4B,GAAG,CAAmB;AAClD,yCAA4B,GAAG,CAAmB;AAClD,yCAA6C,GAAG,CAAoC;AACpF,yCAA8C,GAAG,CAAqC;AACtF,yCAAiD,GAAG,CAAwC;AAC5F,yCAA6C,GAAG,CAAoC;AACpF,yCAA6B,GAAG,CAAoB;AACpD,yCAA6B,GAAG,CAAoB;AACpD,yCAAqC,GAAG,CAA4B;;;;;;SDQpD,yCAAc,CAAC,K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AAe;AAIxB,CAAC;AAED,EAEG,AAFH;;CAEG,AAFH,EAEG,CACH,GAAG,CAAC,wCAAY,iBAAG,sCAAK,CAAC,UAAU,CAAC,iCAAW","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\n/// <reference types=\"css-module-types\" />\n\nexport * from './Breadcrumbs';\nexport {Item} from '@react-stately/collections';\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 ...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 // 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 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 }, [listRef, children, setVisibleItems, showRoot, isMultiline]);\n\n useResizeObserver({ref: domRef, onResize: updateOverflow});\n\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={key}\n className={\n classNames(\n styles,\n 'spectrum-Breadcrumbs-item'\n )\n }>\n <BreadcrumbItem\n isCurrent={isCurrent}\n isDisabled={isDisabled}\n onPress={onPress}>\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AGAA,GAAsC;AACtC,GAAoD;AACpD,GAA6B;AAC7B,GAA2C;AAC3C,GAAuC;AACvC,GAA+C;AAC/C,GAA4B;AAC5B,GAA4B;AAC5B,GAA4B;AAC5B,GAA6C;AAC7C,GAA8C;AAC9C,GAAiD;AACjD,GAA6C;AAC7C,GAA6B;AAC7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,KAAK;YACV,SAAS,EACP,oCAAU,CACR,gEAAM,EACN,CAA2B;8EAG9B,yCAAc;YACb,GAAG,EAAE,GAAG;YACR,SAAS,EAAE,SAAS;YACpB,UAAU,EAAE,UAAU;YACtB,OAAO,EAAE,OAAO;YAChB,SAAS,EAAE,SAAS,IAAI,gBAAgB;WACvC,KAAK,CAAC,KAAK,CAAC,QAAQ;IAI7B,CAAC;IAED,MAAM,oEACH,CAAG;WACE,UAAU;WACV,QAAQ;QACZ,GAAG,EAAE,MAAM;0EACV,CAAE;QACD,GAAG,EAAE,OAAO;QACZ,SAAS,EACP,oCAAU,CACR,gEAAM,EACN,CAAsB,uBACtB,CAAC;YACC,CAA6B,8BAAE,IAAI,KAAK,CAAG;YAC3C,CAA8B,+BAAE,IAAI,KAAK,CAAG;YAC5C,CAAiC,kCAAE,WAAW;YAC9C,CAAgC,iCAAE,QAAQ;YAC1C,CAAa,cAAE,UAAU;QAC3B,CAAC,EACD,UAAU,CAAC,SAAS;OAGvB,eAAe;AAIxB,CAAC;AAED,EAEG,AAFH;;CAEG,AAFH,EAEG,CACH,GAAG,CAAC,wCAAY,iBAAG,sCAAK,CAAC,UAAU,CAAC,iCAAW","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\n/// <reference types=\"css-module-types\" />\n\nexport * from './Breadcrumbs';\nexport {Item} from '@react-stately/collections';\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 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"}
|
package/dist/module.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import "./main.css";
|
|
2
|
-
import {Item as $
|
|
3
|
-
import {ActionButton as $
|
|
4
|
-
import {useDOMRef as $
|
|
5
|
-
import $
|
|
6
|
-
import {MenuTrigger as $
|
|
7
|
-
import $
|
|
8
|
-
import {useBreadcrumbs as $
|
|
9
|
-
import {useValueEffect as $
|
|
10
|
-
import {useProviderProps as $
|
|
11
|
-
import $
|
|
12
|
-
import {FocusRing as $
|
|
13
|
-
import {useHover as $
|
|
14
|
-
import {useLocale as $
|
|
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
15
|
|
|
16
16
|
function $parcel$interopDefault(a) {
|
|
17
17
|
return a && a.__esModule ? a.default : a;
|
|
@@ -19,91 +19,91 @@ function $parcel$interopDefault(a) {
|
|
|
19
19
|
function $parcel$export(e, n, v, s) {
|
|
20
20
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
21
21
|
}
|
|
22
|
-
var $
|
|
22
|
+
var $2adaf67aabd3300b$exports = {};
|
|
23
23
|
|
|
24
|
-
$parcel$export($
|
|
24
|
+
$parcel$export($2adaf67aabd3300b$exports, "Breadcrumbs", () => $2adaf67aabd3300b$export$2dc68d50d56fbbd);
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
var $
|
|
31
|
+
var $48e85557f3729e3d$exports = {};
|
|
32
32
|
|
|
33
|
-
$parcel$export($
|
|
34
|
-
$parcel$export($
|
|
35
|
-
$parcel$export($
|
|
36
|
-
$parcel$export($
|
|
37
|
-
$parcel$export($
|
|
38
|
-
$parcel$export($
|
|
39
|
-
$parcel$export($
|
|
40
|
-
$parcel$export($
|
|
41
|
-
$parcel$export($
|
|
42
|
-
$parcel$export($
|
|
43
|
-
$parcel$export($
|
|
44
|
-
$parcel$export($
|
|
45
|
-
$parcel$export($
|
|
46
|
-
$parcel$export($
|
|
47
|
-
$parcel$export($
|
|
48
|
-
$parcel$export($
|
|
49
|
-
var $
|
|
50
|
-
var $
|
|
51
|
-
var $
|
|
52
|
-
var $
|
|
53
|
-
var $
|
|
54
|
-
var $
|
|
55
|
-
var $
|
|
56
|
-
var $
|
|
57
|
-
var $
|
|
58
|
-
var $
|
|
59
|
-
var $
|
|
60
|
-
var $
|
|
61
|
-
var $
|
|
62
|
-
var $
|
|
63
|
-
var $
|
|
64
|
-
var $
|
|
65
|
-
$
|
|
66
|
-
$
|
|
67
|
-
$
|
|
68
|
-
$
|
|
69
|
-
$
|
|
70
|
-
$
|
|
71
|
-
$
|
|
72
|
-
$
|
|
73
|
-
$
|
|
74
|
-
$
|
|
75
|
-
$
|
|
76
|
-
$
|
|
77
|
-
$
|
|
78
|
-
$
|
|
79
|
-
$
|
|
80
|
-
$
|
|
33
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs", () => $48e85557f3729e3d$export$8c6320d2db82081f, (v) => $48e85557f3729e3d$export$8c6320d2db82081f = v);
|
|
34
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs-itemSeparator", () => $48e85557f3729e3d$export$f72910e36cd91d1e, (v) => $48e85557f3729e3d$export$f72910e36cd91d1e = v);
|
|
35
|
+
$parcel$export($48e85557f3729e3d$exports, "is-reversed", () => $48e85557f3729e3d$export$a4561bd665abb5db, (v) => $48e85557f3729e3d$export$a4561bd665abb5db = v);
|
|
36
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs-item", () => $48e85557f3729e3d$export$492a5983c5fbf603, (v) => $48e85557f3729e3d$export$492a5983c5fbf603 = v);
|
|
37
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-ActionButton", () => $48e85557f3729e3d$export$53da69f51b770d3, (v) => $48e85557f3729e3d$export$53da69f51b770d3 = v);
|
|
38
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs-itemLink", () => $48e85557f3729e3d$export$5af6a1bcd207d9f6, (v) => $48e85557f3729e3d$export$5af6a1bcd207d9f6 = v);
|
|
39
|
+
$parcel$export($48e85557f3729e3d$exports, "is-hovered", () => $48e85557f3729e3d$export$b8813cd5d7824ce7, (v) => $48e85557f3729e3d$export$b8813cd5d7824ce7 = v);
|
|
40
|
+
$parcel$export($48e85557f3729e3d$exports, "focus-ring", () => $48e85557f3729e3d$export$f39a09f249340e2a, (v) => $48e85557f3729e3d$export$f39a09f249340e2a = v);
|
|
41
|
+
$parcel$export($48e85557f3729e3d$exports, "is-dragged", () => $48e85557f3729e3d$export$8778c911bed6c759, (v) => $48e85557f3729e3d$export$8778c911bed6c759 = v);
|
|
42
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs--small", () => $48e85557f3729e3d$export$e01337e7944312f6, (v) => $48e85557f3729e3d$export$e01337e7944312f6 = v);
|
|
43
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs--medium", () => $48e85557f3729e3d$export$19f957201d941895, (v) => $48e85557f3729e3d$export$19f957201d941895 = v);
|
|
44
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs--multiline", () => $48e85557f3729e3d$export$713961e8e432825b, (v) => $48e85557f3729e3d$export$713961e8e432825b = v);
|
|
45
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Heading--pageTitle", () => $48e85557f3729e3d$export$63e9e087a73f808b, (v) => $48e85557f3729e3d$export$63e9e087a73f808b = v);
|
|
46
|
+
$parcel$export($48e85557f3729e3d$exports, "is-disabled", () => $48e85557f3729e3d$export$d35bc1e505d1ebbf, (v) => $48e85557f3729e3d$export$d35bc1e505d1ebbf = v);
|
|
47
|
+
$parcel$export($48e85557f3729e3d$exports, "is-selected", () => $48e85557f3729e3d$export$1e0fb04f31d3c22a, (v) => $48e85557f3729e3d$export$1e0fb04f31d3c22a = v);
|
|
48
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumb", () => $48e85557f3729e3d$export$45a5316056cfac3c, (v) => $48e85557f3729e3d$export$45a5316056cfac3c = v);
|
|
49
|
+
var $48e85557f3729e3d$export$8c6320d2db82081f;
|
|
50
|
+
var $48e85557f3729e3d$export$f72910e36cd91d1e;
|
|
51
|
+
var $48e85557f3729e3d$export$a4561bd665abb5db;
|
|
52
|
+
var $48e85557f3729e3d$export$492a5983c5fbf603;
|
|
53
|
+
var $48e85557f3729e3d$export$53da69f51b770d3;
|
|
54
|
+
var $48e85557f3729e3d$export$5af6a1bcd207d9f6;
|
|
55
|
+
var $48e85557f3729e3d$export$b8813cd5d7824ce7;
|
|
56
|
+
var $48e85557f3729e3d$export$f39a09f249340e2a;
|
|
57
|
+
var $48e85557f3729e3d$export$8778c911bed6c759;
|
|
58
|
+
var $48e85557f3729e3d$export$e01337e7944312f6;
|
|
59
|
+
var $48e85557f3729e3d$export$19f957201d941895;
|
|
60
|
+
var $48e85557f3729e3d$export$713961e8e432825b;
|
|
61
|
+
var $48e85557f3729e3d$export$63e9e087a73f808b;
|
|
62
|
+
var $48e85557f3729e3d$export$d35bc1e505d1ebbf;
|
|
63
|
+
var $48e85557f3729e3d$export$1e0fb04f31d3c22a;
|
|
64
|
+
var $48e85557f3729e3d$export$45a5316056cfac3c;
|
|
65
|
+
$48e85557f3729e3d$export$8c6320d2db82081f = "spectrum-Breadcrumbs_3fe6e8";
|
|
66
|
+
$48e85557f3729e3d$export$f72910e36cd91d1e = "spectrum-Breadcrumbs-itemSeparator_3fe6e8";
|
|
67
|
+
$48e85557f3729e3d$export$a4561bd665abb5db = "is-reversed_3fe6e8";
|
|
68
|
+
$48e85557f3729e3d$export$492a5983c5fbf603 = "spectrum-Breadcrumbs-item_3fe6e8";
|
|
69
|
+
$48e85557f3729e3d$export$53da69f51b770d3 = "spectrum-ActionButton_3fe6e8";
|
|
70
|
+
$48e85557f3729e3d$export$5af6a1bcd207d9f6 = "spectrum-Breadcrumbs-itemLink_3fe6e8";
|
|
71
|
+
$48e85557f3729e3d$export$b8813cd5d7824ce7 = "is-hovered_3fe6e8";
|
|
72
|
+
$48e85557f3729e3d$export$f39a09f249340e2a = "focus-ring_3fe6e8";
|
|
73
|
+
$48e85557f3729e3d$export$8778c911bed6c759 = "is-dragged_3fe6e8";
|
|
74
|
+
$48e85557f3729e3d$export$e01337e7944312f6 = "spectrum-Breadcrumbs--small_3fe6e8";
|
|
75
|
+
$48e85557f3729e3d$export$19f957201d941895 = "spectrum-Breadcrumbs--medium_3fe6e8";
|
|
76
|
+
$48e85557f3729e3d$export$713961e8e432825b = "spectrum-Breadcrumbs--multiline_3fe6e8";
|
|
77
|
+
$48e85557f3729e3d$export$63e9e087a73f808b = "spectrum-Heading--pageTitle_3fe6e8";
|
|
78
|
+
$48e85557f3729e3d$export$d35bc1e505d1ebbf = "is-disabled_3fe6e8";
|
|
79
|
+
$48e85557f3729e3d$export$1e0fb04f31d3c22a = "is-selected_3fe6e8";
|
|
80
|
+
$48e85557f3729e3d$export$45a5316056cfac3c = "spectrum-Breadcrumb_3fe6e8";
|
|
81
81
|
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
|
|
85
85
|
|
|
86
|
-
function $
|
|
86
|
+
function $2bfa2c84c665c457$export$c13f210c706eb549(props) {
|
|
87
87
|
let { children: children , isCurrent: isCurrent , isDisabled: isDisabled } = props;
|
|
88
|
-
let { direction: direction } = $
|
|
89
|
-
let ref = $
|
|
90
|
-
let { itemProps: itemProps } = $
|
|
88
|
+
let { direction: direction } = $koRP3$useLocale();
|
|
89
|
+
let ref = $koRP3$useRef();
|
|
90
|
+
let { itemProps: itemProps } = $koRP3$useBreadcrumbItem({
|
|
91
91
|
...props,
|
|
92
92
|
elementType: typeof children === 'string' ? 'span' : 'a'
|
|
93
93
|
}, ref);
|
|
94
|
-
let { hoverProps: hoverProps , isHovered: isHovered } = $
|
|
95
|
-
let element = /*#__PURE__*/ $
|
|
96
|
-
...$
|
|
94
|
+
let { hoverProps: hoverProps , isHovered: isHovered } = $koRP3$useHover(props);
|
|
95
|
+
let element = /*#__PURE__*/ $koRP3$react.cloneElement($koRP3$getWrappedElement(children), {
|
|
96
|
+
...$koRP3$mergeProps(itemProps, hoverProps),
|
|
97
97
|
ref: ref,
|
|
98
|
-
className: $
|
|
98
|
+
className: $koRP3$classNames((/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$exports)), 'spectrum-Breadcrumbs-itemLink', {
|
|
99
99
|
'is-disabled': !isCurrent && isDisabled,
|
|
100
100
|
'is-hovered': isHovered
|
|
101
101
|
})
|
|
102
102
|
});
|
|
103
|
-
return(/*#__PURE__*/ $
|
|
104
|
-
focusRingClass: $
|
|
105
|
-
}, element), isCurrent === false && /*#__PURE__*/ $
|
|
106
|
-
UNSAFE_className: $
|
|
103
|
+
return(/*#__PURE__*/ $koRP3$react.createElement($koRP3$Fragment, null, /*#__PURE__*/ $koRP3$react.createElement($koRP3$FocusRing, {
|
|
104
|
+
focusRingClass: $koRP3$classNames((/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$exports)), 'focus-ring')
|
|
105
|
+
}, element), isCurrent === false && /*#__PURE__*/ $koRP3$react.createElement($koRP3$spectrumiconsuiChevronRightSmall, {
|
|
106
|
+
UNSAFE_className: $koRP3$classNames((/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$exports)), 'spectrum-Breadcrumbs-itemSeparator', {
|
|
107
107
|
'is-reversed': direction === 'rtl'
|
|
108
108
|
})
|
|
109
109
|
})));
|
|
@@ -119,22 +119,22 @@ function $0a7d4924239a1c00$export$c13f210c706eb549(props) {
|
|
|
119
119
|
|
|
120
120
|
|
|
121
121
|
|
|
122
|
-
const $
|
|
123
|
-
const $
|
|
124
|
-
function $
|
|
125
|
-
props = $
|
|
126
|
-
let { size: size = 'L' , isMultiline: isMultiline , children: children , showRoot: showRoot , isDisabled: isDisabled , onAction: onAction , ...otherProps } = props;
|
|
122
|
+
const $2adaf67aabd3300b$var$MIN_VISIBLE_ITEMS = 1;
|
|
123
|
+
const $2adaf67aabd3300b$var$MAX_VISIBLE_ITEMS = 4;
|
|
124
|
+
function $2adaf67aabd3300b$var$Breadcrumbs(props, ref) {
|
|
125
|
+
props = $koRP3$useProviderProps(props);
|
|
126
|
+
let { size: size = 'L' , isMultiline: isMultiline , children: children , showRoot: showRoot , isDisabled: isDisabled , onAction: onAction , autoFocusCurrent: autoFocusCurrent , ...otherProps } = props;
|
|
127
127
|
// Not using React.Children.toArray because it mutates the key prop.
|
|
128
128
|
let childArray = [];
|
|
129
|
-
$
|
|
130
|
-
if (/*#__PURE__*/ $
|
|
129
|
+
$koRP3$react.Children.forEach(children, (child)=>{
|
|
130
|
+
if (/*#__PURE__*/ $koRP3$react.isValidElement(child)) childArray.push(child);
|
|
131
131
|
});
|
|
132
|
-
let domRef = $
|
|
133
|
-
let listRef = $
|
|
134
|
-
let [visibleItems1, setVisibleItems] = $
|
|
135
|
-
let { navProps: navProps } = $
|
|
136
|
-
let { styleProps: styleProps } = $
|
|
137
|
-
let updateOverflow = $
|
|
132
|
+
let domRef = $koRP3$useDOMRef(ref);
|
|
133
|
+
let listRef = $koRP3$useRef(null);
|
|
134
|
+
let [visibleItems1, setVisibleItems] = $koRP3$useValueEffect(childArray.length);
|
|
135
|
+
let { navProps: navProps } = $koRP3$useBreadcrumbs(props);
|
|
136
|
+
let { styleProps: styleProps } = $koRP3$useStyleProps(otherProps);
|
|
137
|
+
let updateOverflow = $koRP3$useCallback(()=>{
|
|
138
138
|
let computeVisibleItems = (visibleItems)=>{
|
|
139
139
|
// Refs can be null at runtime.
|
|
140
140
|
let currListRef = listRef.current;
|
|
@@ -144,7 +144,7 @@ function $017653b257c6ca18$var$Breadcrumbs(props, ref) {
|
|
|
144
144
|
let isShowingMenu = childArray.length > visibleItems;
|
|
145
145
|
let calculatedWidth = 0;
|
|
146
146
|
let newVisibleItems = 0;
|
|
147
|
-
let maxVisibleItems = $
|
|
147
|
+
let maxVisibleItems = $2adaf67aabd3300b$var$MAX_VISIBLE_ITEMS;
|
|
148
148
|
if (showRoot) {
|
|
149
149
|
calculatedWidth += listItems.shift().offsetWidth;
|
|
150
150
|
newVisibleItems++;
|
|
@@ -158,7 +158,7 @@ function $017653b257c6ca18$var$Breadcrumbs(props, ref) {
|
|
|
158
158
|
if (isMultiline) {
|
|
159
159
|
listItems.pop();
|
|
160
160
|
newVisibleItems++;
|
|
161
|
-
} else {
|
|
161
|
+
} else if (listItems.length > 0) {
|
|
162
162
|
// Ensure the last breadcrumb isn't truncated when we measure it.
|
|
163
163
|
let last = listItems.pop();
|
|
164
164
|
last.style.overflow = 'visible';
|
|
@@ -170,7 +170,7 @@ function $017653b257c6ca18$var$Breadcrumbs(props, ref) {
|
|
|
170
170
|
calculatedWidth += breadcrumb.offsetWidth;
|
|
171
171
|
if (calculatedWidth < containerWidth) newVisibleItems++;
|
|
172
172
|
}
|
|
173
|
-
return Math.max($
|
|
173
|
+
return Math.max($2adaf67aabd3300b$var$MIN_VISIBLE_ITEMS, Math.min(maxVisibleItems, newVisibleItems));
|
|
174
174
|
};
|
|
175
175
|
setVisibleItems(function*() {
|
|
176
176
|
// Update to show all items.
|
|
@@ -183,17 +183,16 @@ function $017653b257c6ca18$var$Breadcrumbs(props, ref) {
|
|
|
183
183
|
if (newVisibleItems < childArray.length && newVisibleItems > 1) yield computeVisibleItems(newVisibleItems);
|
|
184
184
|
});
|
|
185
185
|
}, [
|
|
186
|
-
|
|
187
|
-
children,
|
|
186
|
+
childArray.length,
|
|
188
187
|
setVisibleItems,
|
|
189
188
|
showRoot,
|
|
190
189
|
isMultiline
|
|
191
190
|
]);
|
|
192
|
-
$
|
|
191
|
+
$koRP3$useResizeObserver({
|
|
193
192
|
ref: domRef,
|
|
194
193
|
onResize: updateOverflow
|
|
195
194
|
});
|
|
196
|
-
$
|
|
195
|
+
$koRP3$useLayoutEffect(updateOverflow, [
|
|
197
196
|
children
|
|
198
197
|
]);
|
|
199
198
|
let contents = childArray;
|
|
@@ -205,13 +204,13 @@ function $017653b257c6ca18$var$Breadcrumbs(props, ref) {
|
|
|
205
204
|
// Don't fire onAction when clicking on the last item
|
|
206
205
|
if (key !== selectedKey && onAction) onAction(key);
|
|
207
206
|
};
|
|
208
|
-
let menuItem = /*#__PURE__*/ $
|
|
207
|
+
let menuItem = /*#__PURE__*/ $koRP3$react.createElement($2bfa2c84c665c457$export$c13f210c706eb549, {
|
|
209
208
|
key: "menu"
|
|
210
|
-
}, /*#__PURE__*/ $
|
|
209
|
+
}, /*#__PURE__*/ $koRP3$react.createElement($koRP3$MenuTrigger, null, /*#__PURE__*/ $koRP3$react.createElement($koRP3$ActionButton, {
|
|
211
210
|
"aria-label": "…",
|
|
212
211
|
isQuiet: true,
|
|
213
212
|
isDisabled: isDisabled
|
|
214
|
-
}, /*#__PURE__*/ $
|
|
213
|
+
}, /*#__PURE__*/ $koRP3$react.createElement($koRP3$spectrumiconsuiFolderBreadcrumb, null)), /*#__PURE__*/ $koRP3$react.createElement($koRP3$Menu, {
|
|
215
214
|
selectionMode: "single",
|
|
216
215
|
selectedKeys: [
|
|
217
216
|
selectedKey
|
|
@@ -239,22 +238,24 @@ function $017653b257c6ca18$var$Breadcrumbs(props, ref) {
|
|
|
239
238
|
let onPress = ()=>{
|
|
240
239
|
if (onAction) onAction(key);
|
|
241
240
|
};
|
|
242
|
-
return(/*#__PURE__*/ $
|
|
241
|
+
return(/*#__PURE__*/ $koRP3$react.createElement("li", {
|
|
242
|
+
key: index,
|
|
243
|
+
className: $koRP3$classNames((/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$exports)), 'spectrum-Breadcrumbs-item')
|
|
244
|
+
}, /*#__PURE__*/ $koRP3$react.createElement($2bfa2c84c665c457$export$c13f210c706eb549, {
|
|
243
245
|
key: key,
|
|
244
|
-
className: $5Ji3d$classNames((/*@__PURE__*/$parcel$interopDefault($2512255f54f395b7$exports)), 'spectrum-Breadcrumbs-item')
|
|
245
|
-
}, /*#__PURE__*/ $5Ji3d$react.createElement($0a7d4924239a1c00$export$c13f210c706eb549, {
|
|
246
246
|
isCurrent: isCurrent,
|
|
247
247
|
isDisabled: isDisabled,
|
|
248
|
-
onPress: onPress
|
|
248
|
+
onPress: onPress,
|
|
249
|
+
autoFocus: isCurrent && autoFocusCurrent
|
|
249
250
|
}, child.props.children)));
|
|
250
251
|
});
|
|
251
|
-
return(/*#__PURE__*/ $
|
|
252
|
+
return(/*#__PURE__*/ $koRP3$react.createElement("nav", {
|
|
252
253
|
...styleProps,
|
|
253
254
|
...navProps,
|
|
254
255
|
ref: domRef
|
|
255
|
-
}, /*#__PURE__*/ $
|
|
256
|
+
}, /*#__PURE__*/ $koRP3$react.createElement("ul", {
|
|
256
257
|
ref: listRef,
|
|
257
|
-
className: $
|
|
258
|
+
className: $koRP3$classNames((/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$exports)), 'spectrum-Breadcrumbs', {
|
|
258
259
|
'spectrum-Breadcrumbs--small': size === 'S',
|
|
259
260
|
'spectrum-Breadcrumbs--medium': size === 'M',
|
|
260
261
|
'spectrum-Breadcrumbs--multiline': isMultiline,
|
|
@@ -265,11 +266,11 @@ function $017653b257c6ca18$var$Breadcrumbs(props, ref) {
|
|
|
265
266
|
}
|
|
266
267
|
/**
|
|
267
268
|
* Breadcrumbs show hierarchy and navigational context for a user’s location within an application.
|
|
268
|
-
*/ let $
|
|
269
|
+
*/ let $2adaf67aabd3300b$export$2dc68d50d56fbbd = /*#__PURE__*/ $koRP3$react.forwardRef($2adaf67aabd3300b$var$Breadcrumbs);
|
|
269
270
|
|
|
270
271
|
|
|
271
272
|
|
|
272
273
|
|
|
273
274
|
|
|
274
|
-
export {$
|
|
275
|
+
export {$37781313afe0968e$re_export$Item as Item, $2adaf67aabd3300b$export$2dc68d50d56fbbd as Breadcrumbs};
|
|
275
276
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
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nB,GAAG,CAAC,GAAG,IAAG,IAAS,GAAT,KAAK,CAAC,GAAG,cAAT,IAAS,cAAT,IAAS,GAAI,KAAK;QAC5B,GAAG,CAAC,OAAO,OAAS,CAAC;YACnB,EAAE,EAAE,QAAQ,EACV,QAAQ,CAAC,GAAG;QAEhB,CAAC;QAED,MAAM,0CACH,CAAE;YACD,GAAG,EAAE,GAAG;YACR,SAAS,EACP,iBAAU,CACR,gEAAM,EACN,CAA2B;oDAG9B,yCAAc;YACb,SAAS,EAAE,SAAS;YACpB,UAAU,EAAE,UAAU;YACtB,OAAO,EAAE,OAAO;WACf,KAAK,CAAC,KAAK,CAAC,QAAQ;IAI7B,CAAC;IAED,MAAM,0CACH,CAAG;WACE,UAAU;WACV,QAAQ;QACZ,GAAG,EAAE,MAAM;gDACV,CAAE;QACD,GAAG,EAAE,OAAO;QACZ,SAAS,EACP,iBAAU,CACR,gEAAM,EACN,CAAsB,uBACtB,CAAC;YACC,CAA6B,8BAAE,IAAI,KAAK,CAAG;YAC3C,CAA8B,+BAAE,IAAI,KAAK,CAAG;YAC5C,CAAiC,kCAAE,WAAW;YAC9C,CAAgC,iCAAE,QAAQ;YAC1C,CAAa,cAAE,UAAU;QAC3B,CAAC,EACD,UAAU,CAAC,SAAS;OAGvB,eAAe;AAIxB,CAAC;AAED,EAEG,AAFH;;CAEG,AAFH,EAEG,CACH,GAAG,CAAC,wCAAY,iBAAG,YAAK,CAAC,UAAU,CAAC,iCAAW","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\n/// <reference types=\"css-module-types\" />\n\nexport * from './Breadcrumbs';\nexport {Item} from '@react-stately/collections';\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 ...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 // 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 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 }, [listRef, children, setVisibleItems, showRoot, isMultiline]);\n\n useResizeObserver({ref: domRef, onResize: updateOverflow});\n\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={key}\n className={\n classNames(\n styles,\n 'spectrum-Breadcrumbs-item'\n )\n }>\n <BreadcrumbItem\n isCurrent={isCurrent}\n isDisabled={isDisabled}\n onPress={onPress}>\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AGAA,GAAsC;AACtC,GAAoD;AACpD,GAA6B;AAC7B,GAA2C;AAC3C,GAAuC;AACvC,GAA+C;AAC/C,GAA4B;AAC5B,GAA4B;AAC5B,GAA4B;AAC5B,GAA6C;AAC7C,GAA8C;AAC9C,GAAiD;AACjD,GAA6C;AAC7C,GAA6B;AAC7B,GAA6B;AAC7B,GAAqC;AAfrC,yCAAsC,GAAG,CAA6B;AACtE,yCAAoD,GAAG,CAA2C;AAClG,yCAA6B,GAAG,CAAoB;AACpD,yCAA2C,GAAG,CAAkC;AAChF,wCAAuC,GAAG,CAA8B;AACxE,yCAA+C,GAAG,CAAsC;AACxF,yCAA4B,GAAG,CAAmB;AAClD,yCAA4B,GAAG,CAAmB;AAClD,yCAA4B,GAAG,CAAmB;AAClD,yCAA6C,GAAG,CAAoC;AACpF,yCAA8C,GAAG,CAAqC;AACtF,yCAAiD,GAAG,CAAwC;AAC5F,yCAA6C,GAAG,CAAoC;AACpF,yCAA6B,GAAG,CAAoB;AACpD,yCAA6B,GAAG,CAAoB;AACpD,yCAAqC,GAAG,C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AAE,IAAI,KAAK,CAAG;YAC5C,CAAiC,kCAAE,WAAW;YAC9C,CAAgC,iCAAE,QAAQ;YAC1C,CAAa,cAAE,UAAU;QAC3B,CAAC,EACD,UAAU,CAAC,SAAS;OAGvB,eAAe;AAIxB,CAAC;AAED,EAEG,AAFH;;CAEG,AAFH,EAEG,CACH,GAAG,CAAC,wCAAY,iBAAG,YAAK,CAAC,UAAU,CAAC,iCAAW","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\n/// <reference types=\"css-module-types\" />\n\nexport * from './Breadcrumbs';\nexport {Item} from '@react-stately/collections';\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 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"}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;
|
|
1
|
+
{"mappings":";;ACsOA;;GAEG;AACH,OAAA,IAAI,6JAA4C,CAAC;AC1NjD,OAAO,EAAC,IAAI,EAAC,MAAM,4BAA4B,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\n/// <reference types=\"css-module-types\" />\n\nexport * from './Breadcrumbs';\nexport {Item} from '@react-stately/collections';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/breadcrumbs",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -32,29 +32,29 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.6.2",
|
|
35
|
-
"@react-aria/breadcrumbs": "^3.
|
|
36
|
-
"@react-aria/focus": "^3.
|
|
37
|
-
"@react-aria/i18n": "^3.
|
|
38
|
-
"@react-aria/interactions": "^3.
|
|
39
|
-
"@react-aria/utils": "^3.
|
|
40
|
-
"@react-spectrum/button": "^3.
|
|
41
|
-
"@react-spectrum/menu": "^3.
|
|
42
|
-
"@react-spectrum/utils": "^3.
|
|
43
|
-
"@react-stately/collections": "^3.
|
|
44
|
-
"@react-types/breadcrumbs": "^3.
|
|
45
|
-
"@react-types/shared": "^3.
|
|
46
|
-
"@spectrum-icons/ui": "^3.
|
|
35
|
+
"@react-aria/breadcrumbs": "^3.2.0",
|
|
36
|
+
"@react-aria/focus": "^3.6.0",
|
|
37
|
+
"@react-aria/i18n": "^3.4.0",
|
|
38
|
+
"@react-aria/interactions": "^3.9.0",
|
|
39
|
+
"@react-aria/utils": "^3.13.0",
|
|
40
|
+
"@react-spectrum/button": "^3.8.0",
|
|
41
|
+
"@react-spectrum/menu": "^3.7.0",
|
|
42
|
+
"@react-spectrum/utils": "^3.7.0",
|
|
43
|
+
"@react-stately/collections": "^3.4.0",
|
|
44
|
+
"@react-types/breadcrumbs": "^3.4.0",
|
|
45
|
+
"@react-types/shared": "^3.13.0",
|
|
46
|
+
"@spectrum-icons/ui": "^3.3.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@adobe/spectrum-css-temp": "3.0.0-alpha.1"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@react-spectrum/provider": "^3.0.0",
|
|
53
|
-
"react": "^16.8.0 || ^17.0.0-rc.1",
|
|
54
|
-
"react-dom": "^16.8.0 || ^17.0.0-rc.1"
|
|
53
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0",
|
|
54
|
+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
|
55
55
|
},
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "8f921ec5094e7c2b3c301bcb6133372e35a2052b"
|
|
60
60
|
}
|
package/src/Breadcrumbs.tsx
CHANGED
|
@@ -35,6 +35,7 @@ function Breadcrumbs<T>(props: SpectrumBreadcrumbsProps<T>, ref: DOMRef) {
|
|
|
35
35
|
showRoot,
|
|
36
36
|
isDisabled,
|
|
37
37
|
onAction,
|
|
38
|
+
autoFocusCurrent,
|
|
38
39
|
...otherProps
|
|
39
40
|
} = props;
|
|
40
41
|
|
|
@@ -88,16 +89,18 @@ function Breadcrumbs<T>(props: SpectrumBreadcrumbsProps<T>, ref: DOMRef) {
|
|
|
88
89
|
listItems.pop();
|
|
89
90
|
newVisibleItems++;
|
|
90
91
|
} else {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
if (listItems.length > 0) {
|
|
93
|
+
// Ensure the last breadcrumb isn't truncated when we measure it.
|
|
94
|
+
let last = listItems.pop();
|
|
95
|
+
last.style.overflow = 'visible';
|
|
94
96
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
calculatedWidth += last.offsetWidth;
|
|
98
|
+
if (calculatedWidth < containerWidth) {
|
|
99
|
+
newVisibleItems++;
|
|
100
|
+
}
|
|
99
101
|
|
|
100
|
-
|
|
102
|
+
last.style.overflow = '';
|
|
103
|
+
}
|
|
101
104
|
}
|
|
102
105
|
|
|
103
106
|
for (let breadcrumb of listItems.reverse()) {
|
|
@@ -124,7 +127,7 @@ function Breadcrumbs<T>(props: SpectrumBreadcrumbsProps<T>, ref: DOMRef) {
|
|
|
124
127
|
yield computeVisibleItems(newVisibleItems);
|
|
125
128
|
}
|
|
126
129
|
});
|
|
127
|
-
}, [
|
|
130
|
+
}, [childArray.length, setVisibleItems, showRoot, isMultiline]);
|
|
128
131
|
|
|
129
132
|
useResizeObserver({ref: domRef, onResize: updateOverflow});
|
|
130
133
|
|
|
@@ -179,7 +182,7 @@ function Breadcrumbs<T>(props: SpectrumBreadcrumbsProps<T>, ref: DOMRef) {
|
|
|
179
182
|
|
|
180
183
|
return (
|
|
181
184
|
<li
|
|
182
|
-
key={
|
|
185
|
+
key={index}
|
|
183
186
|
className={
|
|
184
187
|
classNames(
|
|
185
188
|
styles,
|
|
@@ -187,9 +190,11 @@ function Breadcrumbs<T>(props: SpectrumBreadcrumbsProps<T>, ref: DOMRef) {
|
|
|
187
190
|
)
|
|
188
191
|
}>
|
|
189
192
|
<BreadcrumbItem
|
|
193
|
+
key={key}
|
|
190
194
|
isCurrent={isCurrent}
|
|
191
195
|
isDisabled={isDisabled}
|
|
192
|
-
onPress={onPress}
|
|
196
|
+
onPress={onPress}
|
|
197
|
+
autoFocus={isCurrent && autoFocusCurrent}>
|
|
193
198
|
{child.props.children}
|
|
194
199
|
</BreadcrumbItem>
|
|
195
200
|
</li>
|