@entur/menu 4.1.19 → 4.1.21
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/CHANGELOG.md +680 -0
- package/dist/menu.cjs.development.js +204 -146
- package/dist/menu.cjs.development.js.map +1 -1
- package/dist/menu.cjs.production.min.js +1 -1
- package/dist/menu.cjs.production.min.js.map +1 -1
- package/dist/menu.esm.js +204 -146
- package/dist/menu.esm.js.map +1 -1
- package/dist/styles.css +26 -2
- package/package.json +15 -23
package/dist/menu.esm.js
CHANGED
|
@@ -11,8 +11,8 @@ import { IconButton } from '@entur/button';
|
|
|
11
11
|
|
|
12
12
|
var BreadcrumbNavigation = function BreadcrumbNavigation(_ref) {
|
|
13
13
|
var _ref$ariaLabel = _ref['aria-label'],
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
ariaLabel = _ref$ariaLabel === void 0 ? 'Brødsmulesti' : _ref$ariaLabel,
|
|
15
|
+
children = _ref.children;
|
|
16
16
|
return React.createElement("nav", {
|
|
17
17
|
"aria-label": ariaLabel
|
|
18
18
|
}, React.createElement("ol", {
|
|
@@ -28,26 +28,32 @@ function _extends() {
|
|
|
28
28
|
_extends = Object.assign || function (target) {
|
|
29
29
|
for (var i = 1; i < arguments.length; i++) {
|
|
30
30
|
var source = arguments[i];
|
|
31
|
+
|
|
31
32
|
for (var key in source) {
|
|
32
33
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
33
34
|
target[key] = source[key];
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
}
|
|
38
|
+
|
|
37
39
|
return target;
|
|
38
40
|
};
|
|
41
|
+
|
|
39
42
|
return _extends.apply(this, arguments);
|
|
40
43
|
}
|
|
44
|
+
|
|
41
45
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
42
46
|
if (source == null) return {};
|
|
43
47
|
var target = {};
|
|
44
48
|
var sourceKeys = Object.keys(source);
|
|
45
49
|
var key, i;
|
|
50
|
+
|
|
46
51
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
47
52
|
key = sourceKeys[i];
|
|
48
53
|
if (excluded.indexOf(key) >= 0) continue;
|
|
49
54
|
target[key] = source[key];
|
|
50
55
|
}
|
|
56
|
+
|
|
51
57
|
return target;
|
|
52
58
|
}
|
|
53
59
|
|
|
@@ -55,9 +61,10 @@ var _excluded$8 = ["className", "isCurrent", "as"];
|
|
|
55
61
|
var defaultElement$1 = 'a';
|
|
56
62
|
var BreadcrumbItem = function BreadcrumbItem(_ref) {
|
|
57
63
|
var className = _ref.className,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
isCurrent = _ref.isCurrent,
|
|
65
|
+
as = _ref.as,
|
|
66
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
|
|
67
|
+
|
|
61
68
|
var Element = as || defaultElement$1;
|
|
62
69
|
return React.createElement(React.Fragment, null, React.createElement("li", {
|
|
63
70
|
className: classNames('eds-breadcrumb__item', className)
|
|
@@ -76,13 +83,15 @@ var BreadcrumbItem = function BreadcrumbItem(_ref) {
|
|
|
76
83
|
var _excluded$7 = ["className", "children", "size"];
|
|
77
84
|
var SideNavigation = function SideNavigation(_ref) {
|
|
78
85
|
var className = _ref.className,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
children = _ref.children,
|
|
87
|
+
_ref$size = _ref.size,
|
|
88
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
89
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
90
|
+
|
|
83
91
|
if (!children || !React.Children.count(children)) {
|
|
84
92
|
return null;
|
|
85
93
|
}
|
|
94
|
+
|
|
86
95
|
return React.createElement("ul", _extends({
|
|
87
96
|
className: classNames('eds-side-navigation', {
|
|
88
97
|
'eds-side-navigation--small': size === 'small'
|
|
@@ -90,18 +99,21 @@ var SideNavigation = function SideNavigation(_ref) {
|
|
|
90
99
|
}, rest), children);
|
|
91
100
|
};
|
|
92
101
|
/** This is required to check that the Menu */
|
|
102
|
+
|
|
93
103
|
SideNavigation.__IS_ENTUR_MENU__ = true;
|
|
94
104
|
|
|
95
105
|
function useControllableProp(_ref) {
|
|
96
106
|
var prop = _ref.prop,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
107
|
+
_ref$updater = _ref.updater,
|
|
108
|
+
updater = _ref$updater === void 0 ? function () {
|
|
109
|
+
return undefined;
|
|
110
|
+
} : _ref$updater,
|
|
111
|
+
defaultValue = _ref.defaultValue;
|
|
112
|
+
|
|
102
113
|
var _useState = useState(defaultValue),
|
|
103
|
-
|
|
104
|
-
|
|
114
|
+
internalState = _useState[0],
|
|
115
|
+
setInternalState = _useState[1];
|
|
116
|
+
|
|
105
117
|
useEffect(function () {
|
|
106
118
|
if (prop !== undefined) {
|
|
107
119
|
setInternalState(prop);
|
|
@@ -113,24 +125,26 @@ function useControllableProp(_ref) {
|
|
|
113
125
|
var _excluded$6 = ["className", "children", "size", "collapsed", "onCollapseToggle", "collapsibleButtonPosition", "openSideMenuAriaLabel", "closeSideMenuAriaLabel"];
|
|
114
126
|
var CollapsibleSideNavigation = function CollapsibleSideNavigation(_ref) {
|
|
115
127
|
var className = _ref.className,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
children = _ref.children,
|
|
129
|
+
size = _ref.size,
|
|
130
|
+
collapsible = _ref.collapsed,
|
|
131
|
+
onCollapseToggle = _ref.onCollapseToggle,
|
|
132
|
+
_ref$collapsibleButto = _ref.collapsibleButtonPosition,
|
|
133
|
+
collapsibleButtonPosition = _ref$collapsibleButto === void 0 ? '50%' : _ref$collapsibleButto,
|
|
134
|
+
_ref$openSideMenuAria = _ref.openSideMenuAriaLabel,
|
|
135
|
+
openSideMenuAriaLabel = _ref$openSideMenuAria === void 0 ? 'Åpne sidemeny' : _ref$openSideMenuAria,
|
|
136
|
+
_ref$closeSideMenuAri = _ref.closeSideMenuAriaLabel,
|
|
137
|
+
closeSideMenuAriaLabel = _ref$closeSideMenuAri === void 0 ? 'Lukk sidemeny' : _ref$closeSideMenuAri,
|
|
138
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
139
|
+
|
|
127
140
|
var _useControllableProp = useControllableProp({
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
141
|
+
prop: collapsible,
|
|
142
|
+
defaultValue: false,
|
|
143
|
+
updater: onCollapseToggle
|
|
144
|
+
}),
|
|
145
|
+
collapsedMenu = _useControllableProp[0],
|
|
146
|
+
setCollapsedMenu = _useControllableProp[1];
|
|
147
|
+
|
|
134
148
|
return React.createElement(SideNavigationContext.Provider, {
|
|
135
149
|
value: {
|
|
136
150
|
isCollapsed: collapsedMenu
|
|
@@ -160,16 +174,19 @@ var SideNavigationContext = /*#__PURE__*/React.createContext({
|
|
|
160
174
|
});
|
|
161
175
|
var useSideNavigationContext = function useSideNavigationContext() {
|
|
162
176
|
var context = React.useContext(SideNavigationContext);
|
|
177
|
+
|
|
163
178
|
if (!context) {
|
|
164
179
|
console.error('Error reading SideNavigationContext. Please contact maintainer of @entur/menu');
|
|
165
180
|
}
|
|
181
|
+
|
|
166
182
|
return context;
|
|
167
183
|
};
|
|
168
184
|
|
|
169
185
|
var useShowDelayedLabel = function useShowDelayedLabel(isCollapsed) {
|
|
170
186
|
var _useState = useState(true),
|
|
171
|
-
|
|
172
|
-
|
|
187
|
+
showLabel = _useState[0],
|
|
188
|
+
setShowLabel = _useState[1];
|
|
189
|
+
|
|
173
190
|
var hideDelay = 50;
|
|
174
191
|
var showDelay = 200;
|
|
175
192
|
useEffect(function () {
|
|
@@ -178,11 +195,13 @@ var useShowDelayedLabel = function useShowDelayedLabel(isCollapsed) {
|
|
|
178
195
|
setShowLabel(false);
|
|
179
196
|
}, hideDelay);
|
|
180
197
|
}
|
|
198
|
+
|
|
181
199
|
if (!isCollapsed) {
|
|
182
200
|
setTimeout(function () {
|
|
183
201
|
setShowLabel(true);
|
|
184
202
|
}, showDelay);
|
|
185
203
|
}
|
|
204
|
+
|
|
186
205
|
return function () {
|
|
187
206
|
return undefined;
|
|
188
207
|
};
|
|
@@ -191,37 +210,46 @@ var useShowDelayedLabel = function useShowDelayedLabel(isCollapsed) {
|
|
|
191
210
|
};
|
|
192
211
|
|
|
193
212
|
var _excluded$5 = ["className", "active", "subMenu", "icon", "children", "as"],
|
|
194
|
-
|
|
195
|
-
|
|
213
|
+
_excluded2$1 = ["children"],
|
|
214
|
+
_excluded3$1 = ["active", "disabled", "children", "forceExpandSubMenus", "as"];
|
|
215
|
+
|
|
196
216
|
function isActiveRecursively(child) {
|
|
197
217
|
if (!child.props) {
|
|
198
218
|
return false;
|
|
199
219
|
}
|
|
220
|
+
|
|
200
221
|
if (child.props.active) {
|
|
201
222
|
return true;
|
|
202
223
|
}
|
|
224
|
+
|
|
203
225
|
if (!child.props.children) {
|
|
204
226
|
return false;
|
|
205
227
|
}
|
|
228
|
+
|
|
206
229
|
return React.Children.toArray(child.props.children).some(function (child) {
|
|
207
230
|
return isActiveRecursively(child);
|
|
208
231
|
});
|
|
209
232
|
}
|
|
233
|
+
|
|
210
234
|
var defaultElementBaseItem = 'a';
|
|
211
235
|
var BaseSideNavigationItem = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
212
236
|
var className = _ref.className,
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
237
|
+
_ref$active = _ref.active,
|
|
238
|
+
active = _ref$active === void 0 ? false : _ref$active,
|
|
239
|
+
subMenu = _ref.subMenu,
|
|
240
|
+
icon = _ref.icon,
|
|
241
|
+
children = _ref.children,
|
|
242
|
+
as = _ref.as,
|
|
243
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
244
|
+
|
|
220
245
|
var Element = as || defaultElementBaseItem;
|
|
246
|
+
|
|
221
247
|
var _useSideNavigationCon = useSideNavigationContext(),
|
|
222
|
-
|
|
248
|
+
isCollapsed = _useSideNavigationCon.isCollapsed;
|
|
249
|
+
|
|
223
250
|
var _useShowDelayedLabel = useShowDelayedLabel(isCollapsed),
|
|
224
|
-
|
|
251
|
+
showLabel = _useShowDelayedLabel[0];
|
|
252
|
+
|
|
225
253
|
return React.createElement("li", {
|
|
226
254
|
className: classNames('eds-side-navigation__item', className)
|
|
227
255
|
}, React.createElement(Element, _extends({
|
|
@@ -235,7 +263,8 @@ var BaseSideNavigationItem = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
|
235
263
|
});
|
|
236
264
|
var DisabledSideNavigationItem = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
237
265
|
var children = _ref2.children,
|
|
238
|
-
|
|
266
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2$1);
|
|
267
|
+
|
|
239
268
|
return React.createElement(BaseSideNavigationItem, _extends({
|
|
240
269
|
as: "button",
|
|
241
270
|
disabled: true,
|
|
@@ -246,11 +275,12 @@ var DisabledSideNavigationItem = /*#__PURE__*/React.forwardRef(function (_ref2,
|
|
|
246
275
|
var defaultElementItem = 'a';
|
|
247
276
|
var SideNavigationItem = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
248
277
|
var active = _ref3.active,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
278
|
+
disabled = _ref3.disabled,
|
|
279
|
+
children = _ref3.children,
|
|
280
|
+
forceExpandSubMenus = _ref3.forceExpandSubMenus,
|
|
281
|
+
as = _ref3.as,
|
|
282
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded3$1);
|
|
283
|
+
|
|
254
284
|
var Element = as || defaultElementItem;
|
|
255
285
|
var childrenArray = React.Children.toArray(children);
|
|
256
286
|
var subMenu = childrenArray.find(function (child) {
|
|
@@ -259,11 +289,13 @@ var SideNavigationItem = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
|
259
289
|
var label = subMenu ? childrenArray.filter(function (child) {
|
|
260
290
|
return child !== subMenu;
|
|
261
291
|
}) : children;
|
|
292
|
+
|
|
262
293
|
if (disabled) {
|
|
263
294
|
return React.createElement(DisabledSideNavigationItem, _extends({
|
|
264
295
|
ref: ref
|
|
265
296
|
}, rest), label);
|
|
266
297
|
}
|
|
298
|
+
|
|
267
299
|
if (!subMenu) {
|
|
268
300
|
return React.createElement(BaseSideNavigationItem, _extends({
|
|
269
301
|
as: Element,
|
|
@@ -271,6 +303,7 @@ var SideNavigationItem = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
|
271
303
|
ref: ref
|
|
272
304
|
}, rest), label);
|
|
273
305
|
}
|
|
306
|
+
|
|
274
307
|
var isExpanded = forceExpandSubMenus || isActiveRecursively({
|
|
275
308
|
props: {
|
|
276
309
|
children: children,
|
|
@@ -289,25 +322,29 @@ var SideNavigationItem = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
|
289
322
|
var _excluded$4 = ["defaultOpen", "open", "onToggle", "className", "children", "title", "icon"];
|
|
290
323
|
var SideNavigationGroup = function SideNavigationGroup(_ref) {
|
|
291
324
|
var _ref$defaultOpen = _ref.defaultOpen,
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
325
|
+
defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen,
|
|
326
|
+
open = _ref.open,
|
|
327
|
+
onToggle = _ref.onToggle,
|
|
328
|
+
className = _ref.className,
|
|
329
|
+
children = _ref.children,
|
|
330
|
+
title = _ref.title,
|
|
331
|
+
icon = _ref.icon,
|
|
332
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
333
|
+
|
|
300
334
|
var _useControllableProp = useControllableProp({
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
335
|
+
prop: open,
|
|
336
|
+
updater: onToggle,
|
|
337
|
+
defaultValue: defaultOpen
|
|
338
|
+
}),
|
|
339
|
+
isOpen = _useControllableProp[0],
|
|
340
|
+
setOpen = _useControllableProp[1];
|
|
341
|
+
|
|
307
342
|
var _useSideNavigationCon = useSideNavigationContext(),
|
|
308
|
-
|
|
343
|
+
isCollapsed = _useSideNavigationCon.isCollapsed;
|
|
344
|
+
|
|
309
345
|
var _useShowDelayedLabel = useShowDelayedLabel(isCollapsed),
|
|
310
|
-
|
|
346
|
+
showLabel = _useShowDelayedLabel[0];
|
|
347
|
+
|
|
311
348
|
return React.createElement("div", _extends({
|
|
312
349
|
className: classNames('eds-side-navigation-group', className)
|
|
313
350
|
}, rest), React.createElement("button", {
|
|
@@ -331,10 +368,11 @@ var _excluded$3 = ["active", "className", "as"];
|
|
|
331
368
|
var defaultElement = 'a';
|
|
332
369
|
var TopNavigationItem = function TopNavigationItem(_ref) {
|
|
333
370
|
var _ref$active = _ref.active,
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
371
|
+
active = _ref$active === void 0 ? false : _ref$active,
|
|
372
|
+
className = _ref.className,
|
|
373
|
+
as = _ref.as,
|
|
374
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
375
|
+
|
|
338
376
|
var Element = as || defaultElement;
|
|
339
377
|
return React.createElement(Element, _extends({
|
|
340
378
|
className: classNames(['eds-top-navigation-item', className, {
|
|
@@ -345,12 +383,12 @@ var TopNavigationItem = function TopNavigationItem(_ref) {
|
|
|
345
383
|
|
|
346
384
|
var PaginationPage = function PaginationPage(_ref) {
|
|
347
385
|
var children = _ref.children,
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
386
|
+
className = _ref.className,
|
|
387
|
+
selected = _ref.selected,
|
|
388
|
+
disabled = _ref.disabled,
|
|
389
|
+
onClick = _ref.onClick,
|
|
390
|
+
ariaLabel = _ref['aria-label'],
|
|
391
|
+
ariaDescribedby = _ref['aria-describedby'];
|
|
354
392
|
return React.createElement("button", {
|
|
355
393
|
className: classNames('eds-pagination__page', {
|
|
356
394
|
'eds-pagination__page--selected': selected
|
|
@@ -368,29 +406,35 @@ var PaginationPage = function PaginationPage(_ref) {
|
|
|
368
406
|
|
|
369
407
|
var PaginationInput = function PaginationInput(_ref) {
|
|
370
408
|
var currentPage = _ref.currentPage,
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
409
|
+
pageCount = _ref.pageCount,
|
|
410
|
+
_ref$label = _ref.label,
|
|
411
|
+
label = _ref$label === void 0 ? 'Gå til side' : _ref$label,
|
|
412
|
+
onPageChange = _ref.onPageChange;
|
|
413
|
+
|
|
375
414
|
var _React$useState = React.useState(String(currentPage)),
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
415
|
+
input = _React$useState[0],
|
|
416
|
+
setInput = _React$useState[1]; // If the currentPage prop changes, we want to reset the input field
|
|
417
|
+
|
|
418
|
+
|
|
379
419
|
React.useEffect(function () {
|
|
380
420
|
setInput(String(currentPage));
|
|
381
421
|
}, [currentPage]);
|
|
422
|
+
|
|
382
423
|
var handleSubmit = function handleSubmit(e) {
|
|
383
424
|
e.preventDefault();
|
|
384
425
|
e.stopPropagation();
|
|
385
426
|
var pageNumber = Number(input);
|
|
427
|
+
|
|
386
428
|
if (pageNumber === currentPage) {
|
|
387
429
|
return;
|
|
388
430
|
}
|
|
431
|
+
|
|
389
432
|
if (Number.isNaN(pageNumber)) {
|
|
390
433
|
pageNumber = currentPage;
|
|
391
434
|
setInput(String(currentPage));
|
|
392
435
|
return;
|
|
393
436
|
}
|
|
437
|
+
|
|
394
438
|
if (pageNumber > pageCount) {
|
|
395
439
|
pageNumber = pageCount;
|
|
396
440
|
setInput(String(pageCount));
|
|
@@ -398,11 +442,14 @@ var PaginationInput = function PaginationInput(_ref) {
|
|
|
398
442
|
pageNumber = 1;
|
|
399
443
|
setInput(String(1));
|
|
400
444
|
}
|
|
445
|
+
|
|
401
446
|
onPageChange(pageNumber);
|
|
402
447
|
};
|
|
448
|
+
|
|
403
449
|
var handleChange = function handleChange(e) {
|
|
404
450
|
setInput(e.target.value);
|
|
405
451
|
};
|
|
452
|
+
|
|
406
453
|
return React.createElement("form", {
|
|
407
454
|
onSubmit: handleSubmit,
|
|
408
455
|
noValidate: true,
|
|
@@ -421,15 +468,16 @@ var PaginationInput = function PaginationInput(_ref) {
|
|
|
421
468
|
};
|
|
422
469
|
|
|
423
470
|
var _excluded$2 = ["children", "className", "button", "position"],
|
|
424
|
-
|
|
425
|
-
|
|
471
|
+
_excluded2 = ["children", "className", "onSelect", "disabled", "as"],
|
|
472
|
+
_excluded3 = ["children", "as", "className", "onSelect", "disabled"];
|
|
426
473
|
var OverflowMenu = function OverflowMenu(_ref) {
|
|
427
474
|
var children = _ref.children,
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
475
|
+
className = _ref.className,
|
|
476
|
+
button = _ref.button,
|
|
477
|
+
_ref$position = _ref.position,
|
|
478
|
+
position = _ref$position === void 0 ? 'right' : _ref$position,
|
|
479
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
480
|
+
|
|
433
481
|
return React.createElement("div", null, React.createElement(Menu, null, !button ? React.createElement(IconButton, _extends({
|
|
434
482
|
as: MenuButton,
|
|
435
483
|
className: classNames(className, 'eds-overflow-menu__menu-button')
|
|
@@ -449,12 +497,13 @@ var OverflowMenu = function OverflowMenu(_ref) {
|
|
|
449
497
|
};
|
|
450
498
|
var OverflowMenuItem = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
451
499
|
var children = _ref2.children,
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
500
|
+
className = _ref2.className,
|
|
501
|
+
onSelect = _ref2.onSelect,
|
|
502
|
+
disabled = _ref2.disabled,
|
|
503
|
+
_ref2$as = _ref2.as,
|
|
504
|
+
as = _ref2$as === void 0 ? 'div' : _ref2$as,
|
|
505
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
506
|
+
|
|
458
507
|
return React.createElement(MenuItem, _extends({
|
|
459
508
|
className: classNames('eds-overflow-menu__item', {
|
|
460
509
|
'eds-overflow-menu__item--disabled': disabled
|
|
@@ -467,12 +516,13 @@ var OverflowMenuItem = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
467
516
|
});
|
|
468
517
|
var OverflowMenuLink = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
469
518
|
var children = _ref3.children,
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
519
|
+
_ref3$as = _ref3.as,
|
|
520
|
+
as = _ref3$as === void 0 ? 'a' : _ref3$as,
|
|
521
|
+
className = _ref3.className,
|
|
522
|
+
onSelect = _ref3.onSelect,
|
|
523
|
+
disabled = _ref3.disabled,
|
|
524
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
525
|
+
|
|
476
526
|
return React.createElement(MenuLink, _extends({
|
|
477
527
|
as: as,
|
|
478
528
|
className: classNames('eds-overflow-menu__item', {
|
|
@@ -487,41 +537,44 @@ var OverflowMenuLink = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
|
487
537
|
var _excluded$1 = ["className", "currentPage", "inputLabel", "onPageChange", "pageCount", "pageLabel", "previousPageLabel", "currentPageLabelForScreenreader", "showInput", "numberOfResults", "resultsPerPage", "resultsPerPageOptions", "onResultsPerPageChange", "showNumberOfResultsLabel", "nextPageLabel", "showingResultsLabel", "hideNextButton", "hidePrevButton"];
|
|
488
538
|
var Pagination = function Pagination(_ref) {
|
|
489
539
|
var className = _ref.className,
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
540
|
+
currentPage = _ref.currentPage,
|
|
541
|
+
inputLabel = _ref.inputLabel,
|
|
542
|
+
onPageChange = _ref.onPageChange,
|
|
543
|
+
pageCount = _ref.pageCount,
|
|
544
|
+
_ref$pageLabel = _ref.pageLabel,
|
|
545
|
+
pageLabel = _ref$pageLabel === void 0 ? function (pageNumber) {
|
|
546
|
+
return "G\xE5 til side " + pageNumber;
|
|
547
|
+
} : _ref$pageLabel,
|
|
548
|
+
_ref$previousPageLabe = _ref.previousPageLabel,
|
|
549
|
+
previousPageLabel = _ref$previousPageLabe === void 0 ? 'Gå til forrige side' : _ref$previousPageLabe,
|
|
550
|
+
_ref$currentPageLabel = _ref.currentPageLabelForScreenreader,
|
|
551
|
+
currentPageLabelForScreenreader = _ref$currentPageLabel === void 0 ? 'Nåværende side:' : _ref$currentPageLabel,
|
|
552
|
+
showInput = _ref.showInput,
|
|
553
|
+
numberOfResults = _ref.numberOfResults,
|
|
554
|
+
resultsPerPage = _ref.resultsPerPage,
|
|
555
|
+
_ref$resultsPerPageOp = _ref.resultsPerPageOptions,
|
|
556
|
+
resultsPerPageOptions = _ref$resultsPerPageOp === void 0 ? [10, 25, 50] : _ref$resultsPerPageOp,
|
|
557
|
+
onResultsPerPageChange = _ref.onResultsPerPageChange,
|
|
558
|
+
_ref$showNumberOfResu = _ref.showNumberOfResultsLabel,
|
|
559
|
+
showNumberOfResultsLabel = _ref$showNumberOfResu === void 0 ? 'Vis' : _ref$showNumberOfResu,
|
|
560
|
+
_ref$nextPageLabel = _ref.nextPageLabel,
|
|
561
|
+
nextPageLabel = _ref$nextPageLabel === void 0 ? 'Gå til neste side' : _ref$nextPageLabel,
|
|
562
|
+
_ref$showingResultsLa = _ref.showingResultsLabel,
|
|
563
|
+
showingResultsLabel = _ref$showingResultsLa === void 0 ? function (minPage, maxPage, pageCount) {
|
|
564
|
+
return "Viser resultat " + minPage + " - " + maxPage + " av " + pageCount;
|
|
565
|
+
} : _ref$showingResultsLa,
|
|
566
|
+
_ref$hideNextButton = _ref.hideNextButton,
|
|
567
|
+
hideNextButton = _ref$hideNextButton === void 0 ? false : _ref$hideNextButton,
|
|
568
|
+
_ref$hidePrevButton = _ref.hidePrevButton,
|
|
569
|
+
hidePrevButton = _ref$hidePrevButton === void 0 ? false : _ref$hidePrevButton,
|
|
570
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
571
|
+
|
|
521
572
|
var isContrast = useContrast();
|
|
573
|
+
|
|
522
574
|
var _useState = useState([]),
|
|
523
|
-
|
|
524
|
-
|
|
575
|
+
listedEntries = _useState[0],
|
|
576
|
+
setListedEntries = _useState[1];
|
|
577
|
+
|
|
525
578
|
var paginationId = useRandomId('eds-pagination');
|
|
526
579
|
var isFirstPostSelected = currentPage === 1;
|
|
527
580
|
var isLastPostSelected = currentPage === pageCount;
|
|
@@ -530,6 +583,7 @@ var Pagination = function Pagination(_ref) {
|
|
|
530
583
|
var onlyTrailingEllipsis = !noEllipsis && pageCount - currentPage <= 3;
|
|
531
584
|
useEffect(function () {
|
|
532
585
|
if (pageCount < 1) return;
|
|
586
|
+
|
|
533
587
|
if (noEllipsis) {
|
|
534
588
|
setListedEntries(Array(pageCount).fill(null).map(function (_, i) {
|
|
535
589
|
return i + 1;
|
|
@@ -543,9 +597,11 @@ var Pagination = function Pagination(_ref) {
|
|
|
543
597
|
setListedEntries([1, '…', currentPage - 1, currentPage, currentPage + 1, '…', pageCount]);
|
|
544
598
|
}
|
|
545
599
|
}, [noEllipsis, onlyLeadingEllipsis, onlyTrailingEllipsis, currentPage, pageCount]);
|
|
600
|
+
|
|
546
601
|
if (pageCount < 1) {
|
|
547
602
|
return null;
|
|
548
603
|
}
|
|
604
|
+
|
|
549
605
|
return React.createElement("div", _extends({
|
|
550
606
|
className: classNames('eds-pagination', className)
|
|
551
607
|
}, rest), resultsPerPage && numberOfResults && React.createElement("div", {
|
|
@@ -606,6 +662,7 @@ var Pagination = function Pagination(_ref) {
|
|
|
606
662
|
id: paginationId
|
|
607
663
|
}, currentPageLabelForScreenreader, " ", currentPage));
|
|
608
664
|
};
|
|
665
|
+
|
|
609
666
|
var Ellipsis = function Ellipsis() {
|
|
610
667
|
return React.createElement("span", {
|
|
611
668
|
className: "eds-pagination__ellipsis",
|
|
@@ -616,14 +673,15 @@ var Ellipsis = function Ellipsis() {
|
|
|
616
673
|
var _excluded = ["className", "onStepClick", "steps", "activeIndex", "interactive", "showStepperIndex"];
|
|
617
674
|
var Stepper = function Stepper(_ref) {
|
|
618
675
|
var className = _ref.className,
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
676
|
+
onStepClick = _ref.onStepClick,
|
|
677
|
+
steps = _ref.steps,
|
|
678
|
+
activeIndex = _ref.activeIndex,
|
|
679
|
+
_ref$interactive = _ref.interactive,
|
|
680
|
+
interactive = _ref$interactive === void 0 ? false : _ref$interactive,
|
|
681
|
+
_ref$showStepperIndex = _ref.showStepperIndex,
|
|
682
|
+
showStepperIndex = _ref$showStepperIndex === void 0 ? true : _ref$showStepperIndex,
|
|
683
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
684
|
+
|
|
627
685
|
var Element = interactive ? 'button' : 'div';
|
|
628
686
|
return React.createElement("div", _extends({
|
|
629
687
|
className: classNames('eds-stepper', className)
|
|
@@ -656,7 +714,7 @@ var Stepper = function Stepper(_ref) {
|
|
|
656
714
|
}, {
|
|
657
715
|
'eds-stepper__item__label--active': isActive
|
|
658
716
|
})
|
|
659
|
-
}, showStepperIndex && i + 1 + '.
|
|
717
|
+
}, showStepperIndex && i + 1 + '.', " ", step));
|
|
660
718
|
}));
|
|
661
719
|
};
|
|
662
720
|
|