@react-spectrum/breadcrumbs 3.2.5 → 3.3.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 +127 -124
- package/dist/main.js.map +1 -1
- package/dist/module.js +113 -110
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +14 -14
- 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 $b3ff5736da6bbffa$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 $e4fb3abd98f85208$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 $e4fb3abd98f85208$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 $e4fb3abd98f85208$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,34 +201,34 @@ function $e4fb3abd98f85208$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;
|
|
218
217
|
if (childArray.length > visibleItems1) {
|
|
219
218
|
let selectedItem = childArray[childArray.length - 1];
|
|
220
|
-
|
|
219
|
+
var _key;
|
|
220
|
+
let selectedKey = (_key = selectedItem.key) !== null && _key !== void 0 ? _key : childArray.length - 1;
|
|
221
221
|
let onMenuAction = (key)=>{
|
|
222
222
|
// Don't fire onAction when clicking on the last item
|
|
223
223
|
if (key !== selectedKey && onAction) onAction(key);
|
|
224
224
|
};
|
|
225
|
-
let menuItem = /*#__PURE__*/ ($parcel$interopDefault($
|
|
225
|
+
let menuItem = /*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).createElement($d90ab02c74e9be0c$export$c13f210c706eb549, {
|
|
226
226
|
key: "menu"
|
|
227
|
-
}, /*#__PURE__*/ ($parcel$interopDefault($
|
|
227
|
+
}, /*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).createElement($8bWUw$reactspectrummenu.MenuTrigger, null, /*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).createElement($8bWUw$reactspectrumbutton.ActionButton, {
|
|
228
228
|
"aria-label": "…",
|
|
229
229
|
isQuiet: true,
|
|
230
230
|
isDisabled: isDisabled
|
|
231
|
-
}, /*#__PURE__*/ ($parcel$interopDefault($
|
|
231
|
+
}, /*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).createElement(($parcel$interopDefault($8bWUw$spectrumiconsuiFolderBreadcrumb)), null)), /*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).createElement($8bWUw$reactspectrummenu.Menu, {
|
|
232
232
|
selectionMode: "single",
|
|
233
233
|
selectedKeys: [
|
|
234
234
|
selectedKey
|
|
@@ -251,26 +251,29 @@ function $e4fb3abd98f85208$var$Breadcrumbs(props, ref) {
|
|
|
251
251
|
let lastIndex = contents.length - 1;
|
|
252
252
|
let breadcrumbItems = contents.map((child, index)=>{
|
|
253
253
|
let isCurrent = index === lastIndex;
|
|
254
|
-
|
|
254
|
+
var _key;
|
|
255
|
+
let key = (_key = child.key) !== null && _key !== void 0 ? _key : index;
|
|
255
256
|
let onPress = ()=>{
|
|
256
257
|
if (onAction) onAction(key);
|
|
257
258
|
};
|
|
258
|
-
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, {
|
|
259
263
|
key: key,
|
|
260
|
-
className: $mvOWt$reactspectrumutils.classNames((/*@__PURE__*/$parcel$interopDefault($e406fe8ae3922b89$exports)), 'spectrum-Breadcrumbs-item')
|
|
261
|
-
}, /*#__PURE__*/ ($parcel$interopDefault($mvOWt$react)).createElement($b3ff5736da6bbffa$export$c13f210c706eb549, {
|
|
262
264
|
isCurrent: isCurrent,
|
|
263
265
|
isDisabled: isDisabled,
|
|
264
|
-
onPress: onPress
|
|
266
|
+
onPress: onPress,
|
|
267
|
+
autoFocus: isCurrent && autoFocusCurrent
|
|
265
268
|
}, child.props.children)));
|
|
266
269
|
});
|
|
267
|
-
return(/*#__PURE__*/ ($parcel$interopDefault($
|
|
270
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).createElement("nav", {
|
|
268
271
|
...styleProps,
|
|
269
272
|
...navProps,
|
|
270
273
|
ref: domRef
|
|
271
|
-
}, /*#__PURE__*/ ($parcel$interopDefault($
|
|
274
|
+
}, /*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).createElement("ul", {
|
|
272
275
|
ref: listRef,
|
|
273
|
-
className: $
|
|
276
|
+
className: $8bWUw$reactspectrumutils.classNames((/*@__PURE__*/$parcel$interopDefault($3292ef9f328419fc$exports)), 'spectrum-Breadcrumbs', {
|
|
274
277
|
'spectrum-Breadcrumbs--small': size === 'S',
|
|
275
278
|
'spectrum-Breadcrumbs--medium': size === 'M',
|
|
276
279
|
'spectrum-Breadcrumbs--multiline': isMultiline,
|
|
@@ -281,11 +284,11 @@ function $e4fb3abd98f85208$var$Breadcrumbs(props, ref) {
|
|
|
281
284
|
}
|
|
282
285
|
/**
|
|
283
286
|
* Breadcrumbs show hierarchy and navigational context for a user’s location within an application.
|
|
284
|
-
*/ let $
|
|
287
|
+
*/ let $299bf776d9162a05$export$2dc68d50d56fbbd = /*#__PURE__*/ ($parcel$interopDefault($8bWUw$react)).forwardRef($299bf776d9162a05$var$Breadcrumbs);
|
|
285
288
|
|
|
286
289
|
|
|
287
290
|
|
|
288
|
-
$parcel$exportWildcard(module.exports, $
|
|
291
|
+
$parcel$exportWildcard(module.exports, $299bf776d9162a05$exports);
|
|
289
292
|
|
|
290
293
|
|
|
291
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;AACx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6B,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 ...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,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T,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,oEACH,CAAE;YACD,GAAG,EAAE,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 $5c319d6d9e7d47c6$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 $ad142e6c7f8dd846$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 $ad142e6c7f8dd846$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 $ad142e6c7f8dd846$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,34 +183,34 @@ function $ad142e6c7f8dd846$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;
|
|
200
199
|
if (childArray.length > visibleItems1) {
|
|
201
200
|
let selectedItem = childArray[childArray.length - 1];
|
|
202
|
-
|
|
201
|
+
var _key;
|
|
202
|
+
let selectedKey = (_key = selectedItem.key) !== null && _key !== void 0 ? _key : childArray.length - 1;
|
|
203
203
|
let onMenuAction = (key)=>{
|
|
204
204
|
// Don't fire onAction when clicking on the last item
|
|
205
205
|
if (key !== selectedKey && onAction) onAction(key);
|
|
206
206
|
};
|
|
207
|
-
let menuItem = /*#__PURE__*/ $
|
|
207
|
+
let menuItem = /*#__PURE__*/ $koRP3$react.createElement($2bfa2c84c665c457$export$c13f210c706eb549, {
|
|
208
208
|
key: "menu"
|
|
209
|
-
}, /*#__PURE__*/ $
|
|
209
|
+
}, /*#__PURE__*/ $koRP3$react.createElement($koRP3$MenuTrigger, null, /*#__PURE__*/ $koRP3$react.createElement($koRP3$ActionButton, {
|
|
210
210
|
"aria-label": "…",
|
|
211
211
|
isQuiet: true,
|
|
212
212
|
isDisabled: isDisabled
|
|
213
|
-
}, /*#__PURE__*/ $
|
|
213
|
+
}, /*#__PURE__*/ $koRP3$react.createElement($koRP3$spectrumiconsuiFolderBreadcrumb, null)), /*#__PURE__*/ $koRP3$react.createElement($koRP3$Menu, {
|
|
214
214
|
selectionMode: "single",
|
|
215
215
|
selectedKeys: [
|
|
216
216
|
selectedKey
|
|
@@ -233,26 +233,29 @@ function $ad142e6c7f8dd846$var$Breadcrumbs(props, ref) {
|
|
|
233
233
|
let lastIndex = contents.length - 1;
|
|
234
234
|
let breadcrumbItems = contents.map((child, index)=>{
|
|
235
235
|
let isCurrent = index === lastIndex;
|
|
236
|
-
|
|
236
|
+
var _key;
|
|
237
|
+
let key = (_key = child.key) !== null && _key !== void 0 ? _key : index;
|
|
237
238
|
let onPress = ()=>{
|
|
238
239
|
if (onAction) onAction(key);
|
|
239
240
|
};
|
|
240
|
-
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, {
|
|
241
245
|
key: key,
|
|
242
|
-
className: $2OMIA$classNames((/*@__PURE__*/$parcel$interopDefault($031ef6a0f075eadb$exports)), 'spectrum-Breadcrumbs-item')
|
|
243
|
-
}, /*#__PURE__*/ $2OMIA$react.createElement($5c319d6d9e7d47c6$export$c13f210c706eb549, {
|
|
244
246
|
isCurrent: isCurrent,
|
|
245
247
|
isDisabled: isDisabled,
|
|
246
|
-
onPress: onPress
|
|
248
|
+
onPress: onPress,
|
|
249
|
+
autoFocus: isCurrent && autoFocusCurrent
|
|
247
250
|
}, child.props.children)));
|
|
248
251
|
});
|
|
249
|
-
return(/*#__PURE__*/ $
|
|
252
|
+
return(/*#__PURE__*/ $koRP3$react.createElement("nav", {
|
|
250
253
|
...styleProps,
|
|
251
254
|
...navProps,
|
|
252
255
|
ref: domRef
|
|
253
|
-
}, /*#__PURE__*/ $
|
|
256
|
+
}, /*#__PURE__*/ $koRP3$react.createElement("ul", {
|
|
254
257
|
ref: listRef,
|
|
255
|
-
className: $
|
|
258
|
+
className: $koRP3$classNames((/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$exports)), 'spectrum-Breadcrumbs', {
|
|
256
259
|
'spectrum-Breadcrumbs--small': size === 'S',
|
|
257
260
|
'spectrum-Breadcrumbs--medium': size === 'M',
|
|
258
261
|
'spectrum-Breadcrumbs--multiline': isMultiline,
|
|
@@ -263,11 +266,11 @@ function $ad142e6c7f8dd846$var$Breadcrumbs(props, ref) {
|
|
|
263
266
|
}
|
|
264
267
|
/**
|
|
265
268
|
* Breadcrumbs show hierarchy and navigational context for a user’s location within an application.
|
|
266
|
-
*/ let $
|
|
269
|
+
*/ let $2adaf67aabd3300b$export$2dc68d50d56fbbd = /*#__PURE__*/ $koRP3$react.forwardRef($2adaf67aabd3300b$var$Breadcrumbs);
|
|
267
270
|
|
|
268
271
|
|
|
269
272
|
|
|
270
273
|
|
|
271
274
|
|
|
272
|
-
export {$
|
|
275
|
+
export {$37781313afe0968e$re_export$Item as Item, $2adaf67aabd3300b$export$2dc68d50d56fbbd as Breadcrumbs};
|
|
273
276
|
//# sourceMappingURL=module.js.map
|
package/dist/module.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;AACp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B,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,y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EACN,CAA2B;oDAG9B,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,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 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.3.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -32,18 +32,18 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.6.2",
|
|
35
|
-
"@react-aria/breadcrumbs": "^3.1.
|
|
36
|
-
"@react-aria/focus": "^3.5.
|
|
37
|
-
"@react-aria/i18n": "^3.3.
|
|
38
|
-
"@react-aria/interactions": "^3.8.
|
|
39
|
-
"@react-aria/utils": "^3.
|
|
40
|
-
"@react-spectrum/button": "^3.7.
|
|
41
|
-
"@react-spectrum/menu": "^3.6.
|
|
42
|
-
"@react-spectrum/utils": "^3.6.
|
|
43
|
-
"@react-stately/collections": "^3.3.
|
|
44
|
-
"@react-types/breadcrumbs": "^3.
|
|
45
|
-
"@react-types/shared": "^3.
|
|
46
|
-
"@spectrum-icons/ui": "^3.2.
|
|
35
|
+
"@react-aria/breadcrumbs": "^3.1.10",
|
|
36
|
+
"@react-aria/focus": "^3.5.5",
|
|
37
|
+
"@react-aria/i18n": "^3.3.9",
|
|
38
|
+
"@react-aria/interactions": "^3.8.4",
|
|
39
|
+
"@react-aria/utils": "^3.12.0",
|
|
40
|
+
"@react-spectrum/button": "^3.7.4",
|
|
41
|
+
"@react-spectrum/menu": "^3.6.4",
|
|
42
|
+
"@react-spectrum/utils": "^3.6.8",
|
|
43
|
+
"@react-stately/collections": "^3.3.8",
|
|
44
|
+
"@react-types/breadcrumbs": "^3.3.0",
|
|
45
|
+
"@react-types/shared": "^3.12.0",
|
|
46
|
+
"@spectrum-icons/ui": "^3.2.6"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@adobe/spectrum-css-temp": "3.0.0-alpha.1"
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "6a503b715e0dbbf92038cd7f08b1bcdde4c78e82"
|
|
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>
|