@entur/menu 4.2.40 → 5.0.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/OverflowMenu.d.ts +31 -24
- package/dist/index.d.ts +4 -4
- package/dist/menu.cjs.development.js +384 -294
- 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 +387 -297
- package/dist/menu.esm.js.map +1 -1
- package/dist/styles.css +252 -317
- package/package.json +12 -12
package/dist/menu.esm.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { useRandomId, warnAboutMissingStyles } from '@entur/utils';
|
|
2
|
-
import React, { useState, useEffect, cloneElement } from 'react';
|
|
1
|
+
import { useOnClickOutside, useOnEscape, getNodeText, useRandomId, warnAboutMissingStyles } from '@entur/utils';
|
|
2
|
+
import React, { useState, useEffect, useRef, cloneElement, useContext } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import { RightArrowIcon, MenuIcon, LeftArrowIcon, VerticalDotsIcon,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { RightArrowIcon, MenuIcon, LeftArrowIcon, VerticalDotsIcon, DownArrowIcon } from '@entur/icons';
|
|
5
|
+
import { useFloating, autoUpdate, offset, flip, shift, useListNavigation, useTypeahead, useRole, useInteractions, FloatingList, useListItem } from '@floating-ui/react';
|
|
6
|
+
import { IconButton } from '@entur/button';
|
|
7
|
+
import { standardisePlacement } from '@entur/tooltip';
|
|
8
|
+
import { space } from '@entur/tokens';
|
|
7
9
|
import { VisuallyHidden } from '@entur/a11y';
|
|
8
|
-
import { useContrast, Contrast } from '@entur/layout';
|
|
9
10
|
import { Label } from '@entur/typography';
|
|
10
|
-
import {
|
|
11
|
+
import { ExpandArrow, BaseExpand } from '@entur/expand';
|
|
11
12
|
|
|
12
13
|
var BreadcrumbNavigation = function BreadcrumbNavigation(_ref) {
|
|
13
14
|
var _ref$ariaLabel = _ref['aria-label'],
|
|
@@ -74,25 +75,6 @@ var BreadcrumbItem = function BreadcrumbItem(_ref) {
|
|
|
74
75
|
}));
|
|
75
76
|
};
|
|
76
77
|
|
|
77
|
-
var _excluded$7 = ["className", "children", "size"];
|
|
78
|
-
var SideNavigation = function SideNavigation(_ref) {
|
|
79
|
-
var className = _ref.className,
|
|
80
|
-
children = _ref.children,
|
|
81
|
-
_ref$size = _ref.size,
|
|
82
|
-
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
83
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
84
|
-
if (!children || !React.Children.count(children)) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
return React.createElement("ul", _extends({
|
|
88
|
-
className: classNames('eds-side-navigation', {
|
|
89
|
-
'eds-side-navigation--small': size === 'small'
|
|
90
|
-
}, className)
|
|
91
|
-
}, rest), children);
|
|
92
|
-
};
|
|
93
|
-
/** This is required to check that the Menu */
|
|
94
|
-
SideNavigation.__IS_ENTUR_MENU__ = true;
|
|
95
|
-
|
|
96
78
|
function useControllableProp(_ref) {
|
|
97
79
|
var prop = _ref.prop,
|
|
98
80
|
_ref$updater = _ref.updater,
|
|
@@ -111,7 +93,7 @@ function useControllableProp(_ref) {
|
|
|
111
93
|
return prop === undefined ? [internalState, setInternalState] : [prop, updater];
|
|
112
94
|
}
|
|
113
95
|
|
|
114
|
-
var _excluded$
|
|
96
|
+
var _excluded$7 = ["className", "children", "size", "collapsed", "onCollapseToggle", "collapsibleButtonPosition", "openSideMenuAriaLabel", "closeSideMenuAriaLabel"];
|
|
115
97
|
var CollapsibleSideNavigation = function CollapsibleSideNavigation(_ref) {
|
|
116
98
|
var className = _ref.className,
|
|
117
99
|
children = _ref.children,
|
|
@@ -124,7 +106,7 @@ var CollapsibleSideNavigation = function CollapsibleSideNavigation(_ref) {
|
|
|
124
106
|
openSideMenuAriaLabel = _ref$openSideMenuAria === void 0 ? 'Åpne sidemeny' : _ref$openSideMenuAria,
|
|
125
107
|
_ref$closeSideMenuAri = _ref.closeSideMenuAriaLabel,
|
|
126
108
|
closeSideMenuAriaLabel = _ref$closeSideMenuAri === void 0 ? 'Lukk sidemeny' : _ref$closeSideMenuAri,
|
|
127
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
109
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
128
110
|
var _useControllableProp = useControllableProp({
|
|
129
111
|
prop: collapsible,
|
|
130
112
|
defaultValue: false,
|
|
@@ -167,182 +149,155 @@ var useSideNavigationContext = function useSideNavigationContext() {
|
|
|
167
149
|
return context;
|
|
168
150
|
};
|
|
169
151
|
|
|
170
|
-
var
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
var
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
return true;
|
|
203
|
-
}
|
|
204
|
-
if (!child.props.children) {
|
|
205
|
-
return false;
|
|
206
|
-
}
|
|
207
|
-
return React.Children.toArray(child.props.children).some(function (child) {
|
|
208
|
-
return isActiveRecursively(child);
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
var defaultElementBaseItem = 'a';
|
|
212
|
-
var BaseSideNavigationItem = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
213
|
-
var className = _ref.className,
|
|
214
|
-
_ref$active = _ref.active,
|
|
215
|
-
active = _ref$active === void 0 ? false : _ref$active,
|
|
216
|
-
subMenu = _ref.subMenu,
|
|
217
|
-
icon = _ref.icon,
|
|
218
|
-
children = _ref.children,
|
|
219
|
-
as = _ref.as,
|
|
220
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
221
|
-
var Element = as || defaultElementBaseItem;
|
|
222
|
-
var _useSideNavigationCon = useSideNavigationContext(),
|
|
223
|
-
isCollapsed = _useSideNavigationCon.isCollapsed;
|
|
224
|
-
var _useShowDelayedLabel = useShowDelayedLabel(isCollapsed),
|
|
225
|
-
showLabel = _useShowDelayedLabel[0];
|
|
226
|
-
return React.createElement("li", {
|
|
227
|
-
className: classNames('eds-side-navigation__item', className)
|
|
228
|
-
}, React.createElement(Element, _extends({
|
|
229
|
-
className: classNames('eds-side-navigation__click-target', {
|
|
230
|
-
'eds-side-navigation__click-target--active': active
|
|
152
|
+
var _excluded$6 = ["children", "className", "button", "buttonIcon", "placement", "aria-label"],
|
|
153
|
+
_excluded2$1 = ["children", "className", "onSelect", "href", "disabled"],
|
|
154
|
+
_excluded3$1 = ["href"];
|
|
155
|
+
var SelectContext = /*#__PURE__*/React.createContext({});
|
|
156
|
+
var OverflowMenu = function OverflowMenu(_ref) {
|
|
157
|
+
var children = _ref.children,
|
|
158
|
+
className = _ref.className,
|
|
159
|
+
button = _ref.button,
|
|
160
|
+
buttonIcon = _ref.buttonIcon,
|
|
161
|
+
_ref$placement = _ref.placement,
|
|
162
|
+
placement = _ref$placement === void 0 ? 'bottom-start' : _ref$placement,
|
|
163
|
+
_ref$ariaLabel = _ref['aria-label'],
|
|
164
|
+
ariaLabel = _ref$ariaLabel === void 0 ? 'åpne valgmeny' : _ref$ariaLabel,
|
|
165
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
166
|
+
var _useState = useState(false),
|
|
167
|
+
isOpen = _useState[0],
|
|
168
|
+
setIsOpen = _useState[1];
|
|
169
|
+
var _useState2 = useState(null),
|
|
170
|
+
activeIndex = _useState2[0],
|
|
171
|
+
setActiveIndex = _useState2[1];
|
|
172
|
+
var listRef = useRef([]);
|
|
173
|
+
var labelsRef = useRef([]);
|
|
174
|
+
var _useFloating = useFloating({
|
|
175
|
+
whileElementsMounted: autoUpdate,
|
|
176
|
+
placement: standardisePlacement(
|
|
177
|
+
// check for left is added for backwards compatibility
|
|
178
|
+
rest.position === 'left' ? 'bottom-end' : placement),
|
|
179
|
+
open: isOpen,
|
|
180
|
+
onOpenChange: setIsOpen,
|
|
181
|
+
middleware: [offset(space.extraSmall2), flip(), shift({
|
|
182
|
+
padding: space.extraSmall
|
|
183
|
+
})]
|
|
231
184
|
}),
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2$1);
|
|
240
|
-
return React.createElement(BaseSideNavigationItem, _extends({
|
|
241
|
-
as: "button",
|
|
242
|
-
disabled: true,
|
|
243
|
-
"aria-disabled": true,
|
|
244
|
-
ref: ref,
|
|
245
|
-
type: "button"
|
|
246
|
-
}, rest), children);
|
|
247
|
-
});
|
|
248
|
-
var defaultElementItem = 'a';
|
|
249
|
-
var SideNavigationItem = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
250
|
-
var active = _ref3.active,
|
|
251
|
-
disabled = _ref3.disabled,
|
|
252
|
-
children = _ref3.children,
|
|
253
|
-
forceExpandSubMenus = _ref3.forceExpandSubMenus,
|
|
254
|
-
as = _ref3.as,
|
|
255
|
-
rest = _objectWithoutPropertiesLoose(_ref3, _excluded3$1);
|
|
256
|
-
var Element = as || defaultElementItem;
|
|
257
|
-
var childrenArray = React.Children.toArray(children);
|
|
258
|
-
var subMenu = childrenArray.find(function (child) {
|
|
259
|
-
return child && child.type && child.type.__IS_ENTUR_MENU__;
|
|
185
|
+
refs = _useFloating.refs,
|
|
186
|
+
floatingStyles = _useFloating.floatingStyles,
|
|
187
|
+
context = _useFloating.context;
|
|
188
|
+
var listNav = useListNavigation(context, {
|
|
189
|
+
listRef: listRef,
|
|
190
|
+
activeIndex: activeIndex,
|
|
191
|
+
onNavigate: setActiveIndex
|
|
260
192
|
});
|
|
261
|
-
var
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
ref: ref
|
|
267
|
-
}, rest), label);
|
|
268
|
-
}
|
|
269
|
-
if (!subMenu) {
|
|
270
|
-
return React.createElement(BaseSideNavigationItem, _extends({
|
|
271
|
-
as: Element,
|
|
272
|
-
active: active,
|
|
273
|
-
ref: ref
|
|
274
|
-
}, rest), label);
|
|
275
|
-
}
|
|
276
|
-
var isExpanded = forceExpandSubMenus || isActiveRecursively({
|
|
277
|
-
props: {
|
|
278
|
-
children: children,
|
|
279
|
-
active: active
|
|
193
|
+
var typeahead = useTypeahead(context, {
|
|
194
|
+
listRef: labelsRef,
|
|
195
|
+
activeIndex: activeIndex,
|
|
196
|
+
onMatch: function onMatch(index) {
|
|
197
|
+
return isOpen && setActiveIndex(index);
|
|
280
198
|
}
|
|
281
199
|
});
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
var _useShowDelayedLabel = useShowDelayedLabel(isCollapsed),
|
|
312
|
-
showLabel = _useShowDelayedLabel[0];
|
|
313
|
-
return React.createElement("div", _extends({
|
|
314
|
-
className: classNames('eds-side-navigation-group', className)
|
|
315
|
-
}, rest), React.createElement("button", {
|
|
200
|
+
var role = useRole(context, {
|
|
201
|
+
role: 'menu'
|
|
202
|
+
});
|
|
203
|
+
var _useInteractions = useInteractions([listNav, typeahead, role]),
|
|
204
|
+
getReferenceProps = _useInteractions.getReferenceProps,
|
|
205
|
+
getFloatingProps = _useInteractions.getFloatingProps,
|
|
206
|
+
getItemProps = _useInteractions.getItemProps;
|
|
207
|
+
var closeMenuAndReturnFocus = function closeMenuAndReturnFocus() {
|
|
208
|
+
var _refs$reference$curre;
|
|
209
|
+
setIsOpen(false);
|
|
210
|
+
// @ts-expect-error the reference element is actually focusable
|
|
211
|
+
(_refs$reference$curre = refs.reference.current) == null ? void 0 : _refs$reference$curre.focus == null ? void 0 : _refs$reference$curre.focus();
|
|
212
|
+
};
|
|
213
|
+
useOnClickOutside([refs.floating, refs.reference], function () {
|
|
214
|
+
return setIsOpen(false);
|
|
215
|
+
});
|
|
216
|
+
useOnEscape(refs.floating, closeMenuAndReturnFocus);
|
|
217
|
+
useOnEscape(refs.reference, closeMenuAndReturnFocus);
|
|
218
|
+
var selectContext = React.useMemo(function () {
|
|
219
|
+
return {
|
|
220
|
+
activeIndex: activeIndex,
|
|
221
|
+
getItemProps: getItemProps,
|
|
222
|
+
closeMenuAndReturnFocus: closeMenuAndReturnFocus
|
|
223
|
+
};
|
|
224
|
+
}, [activeIndex, getItemProps, closeMenuAndReturnFocus]);
|
|
225
|
+
var _buttonIcon = buttonIcon != null ? buttonIcon : React.createElement(VerticalDotsIcon, null);
|
|
226
|
+
return React.createElement(React.Fragment, null, !button ? React.createElement(IconButton, _extends({
|
|
227
|
+
ref: refs.setReference
|
|
228
|
+
}, getReferenceProps({
|
|
316
229
|
onClick: function onClick() {
|
|
317
|
-
return
|
|
230
|
+
return setIsOpen(!isOpen);
|
|
318
231
|
},
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
232
|
+
className: className,
|
|
233
|
+
'aria-label': ariaLabel
|
|
234
|
+
}), rest), _buttonIcon) : cloneElement(button, _extends({
|
|
235
|
+
ref: refs.setReference
|
|
236
|
+
}, getReferenceProps({
|
|
237
|
+
onClick: function onClick() {
|
|
238
|
+
return setIsOpen(!isOpen);
|
|
239
|
+
},
|
|
240
|
+
className: className,
|
|
241
|
+
'aria-label': ariaLabel
|
|
242
|
+
}), rest)), React.createElement(SelectContext.Provider, {
|
|
243
|
+
value: selectContext
|
|
244
|
+
}, React.createElement("div", _extends({
|
|
245
|
+
ref: refs.setFloating,
|
|
246
|
+
style: _extends({}, floatingStyles, {
|
|
247
|
+
display: isOpen ? 'initial' : 'none'
|
|
248
|
+
})
|
|
249
|
+
}, getFloatingProps({
|
|
250
|
+
className: 'eds-overflow-menu__menu-list'
|
|
251
|
+
})), React.createElement(FloatingList, {
|
|
252
|
+
elementsRef: listRef,
|
|
253
|
+
labelsRef: labelsRef
|
|
254
|
+
}, children))));
|
|
331
255
|
};
|
|
332
|
-
|
|
333
|
-
var
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
256
|
+
var OverflowMenuItem = function OverflowMenuItem(_ref2) {
|
|
257
|
+
var children = _ref2.children,
|
|
258
|
+
className = _ref2.className,
|
|
259
|
+
_ref2$onSelect = _ref2.onSelect,
|
|
260
|
+
onSelect = _ref2$onSelect === void 0 ? function () {
|
|
261
|
+
return undefined;
|
|
262
|
+
} : _ref2$onSelect,
|
|
263
|
+
href = _ref2.href,
|
|
264
|
+
disabled = _ref2.disabled,
|
|
265
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2$1);
|
|
266
|
+
var _useContext = useContext(SelectContext),
|
|
267
|
+
activeIndex = _useContext.activeIndex,
|
|
268
|
+
getItemProps = _useContext.getItemProps,
|
|
269
|
+
closeMenuAndReturnFocus = _useContext.closeMenuAndReturnFocus;
|
|
270
|
+
var _useListItem = useListItem({
|
|
271
|
+
label: !disabled ? getNodeText(children) : null
|
|
272
|
+
}),
|
|
273
|
+
listItemRef = _useListItem.ref,
|
|
274
|
+
index = _useListItem.index;
|
|
275
|
+
var isHighlighted = activeIndex === index;
|
|
276
|
+
var isLink = href !== undefined;
|
|
277
|
+
var Element = isLink ? 'a' : 'button';
|
|
342
278
|
return React.createElement(Element, _extends({
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
279
|
+
ref: listItemRef,
|
|
280
|
+
className: classNames('eds-overflow-menu__item', {
|
|
281
|
+
'eds-overflow-menu__item--disabled': disabled,
|
|
282
|
+
'eds-overflow-menu__item--highlighted': isHighlighted
|
|
283
|
+
}, className),
|
|
284
|
+
role: "menuitem",
|
|
285
|
+
"aria-disabled": disabled,
|
|
286
|
+
"aria-selected": isHighlighted
|
|
287
|
+
}, getItemProps({
|
|
288
|
+
onClick: isLink || disabled ? undefined : function () {
|
|
289
|
+
onSelect();
|
|
290
|
+
closeMenuAndReturnFocus();
|
|
291
|
+
},
|
|
292
|
+
href: disabled ? undefined : href,
|
|
293
|
+
tabIndex: isHighlighted ? 0 : -1
|
|
294
|
+
}), rest), children);
|
|
295
|
+
};
|
|
296
|
+
var OverflowMenuLink = function OverflowMenuLink(_ref3) {
|
|
297
|
+
var href = _ref3.href,
|
|
298
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded3$1);
|
|
299
|
+
return React.createElement(OverflowMenuItem, _extends({
|
|
300
|
+
href: href
|
|
346
301
|
}, rest));
|
|
347
302
|
};
|
|
348
303
|
|
|
@@ -355,10 +310,10 @@ var PaginationPage = function PaginationPage(_ref) {
|
|
|
355
310
|
ariaLabel = _ref['aria-label'],
|
|
356
311
|
ariaDescribedby = _ref['aria-describedby'];
|
|
357
312
|
return React.createElement("button", {
|
|
358
|
-
className: classNames('eds-
|
|
359
|
-
'eds-
|
|
313
|
+
className: classNames('eds-pagination__controls__page', {
|
|
314
|
+
'eds-pagination__controls__page--selected': selected
|
|
360
315
|
}, {
|
|
361
|
-
'eds-
|
|
316
|
+
'eds-pagination__controls__page--disabled': disabled
|
|
362
317
|
}, className),
|
|
363
318
|
disabled: selected || disabled,
|
|
364
319
|
type: "button",
|
|
@@ -411,83 +366,19 @@ var PaginationInput = function PaginationInput(_ref) {
|
|
|
411
366
|
noValidate: true,
|
|
412
367
|
"aria-label": "form"
|
|
413
368
|
}, React.createElement("label", {
|
|
414
|
-
className: "eds-
|
|
369
|
+
className: "eds-pagination__controls__input__wrapper"
|
|
415
370
|
}, React.createElement("span", {
|
|
416
|
-
className: "eds-
|
|
371
|
+
className: "eds-pagination__controls__input__label"
|
|
417
372
|
}, label), React.createElement("input", {
|
|
418
373
|
type: "number",
|
|
419
374
|
max: pageCount,
|
|
420
|
-
className: "eds-
|
|
375
|
+
className: "eds-pagination__controls__input__field",
|
|
421
376
|
value: input,
|
|
422
377
|
onChange: handleChange
|
|
423
378
|
})));
|
|
424
379
|
};
|
|
425
380
|
|
|
426
|
-
var _excluded$
|
|
427
|
-
_excluded2 = ["children", "className", "onSelect", "disabled", "as"],
|
|
428
|
-
_excluded3 = ["children", "as", "className", "onSelect", "disabled"];
|
|
429
|
-
var OverflowMenu = function OverflowMenu(_ref) {
|
|
430
|
-
var children = _ref.children,
|
|
431
|
-
className = _ref.className,
|
|
432
|
-
button = _ref.button,
|
|
433
|
-
_ref$position = _ref.position,
|
|
434
|
-
position = _ref$position === void 0 ? 'right' : _ref$position,
|
|
435
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
436
|
-
return React.createElement("div", null, React.createElement(Menu, null, !button ? React.createElement(IconButton, _extends({
|
|
437
|
-
as: MenuButton,
|
|
438
|
-
className: classNames(className, 'eds-overflow-menu__menu-button')
|
|
439
|
-
}, rest), React.createElement(VerticalDotsIcon, null)) : cloneElement(button, _extends({
|
|
440
|
-
as: MenuButton,
|
|
441
|
-
className: classNames(className, 'eds-overflow-menu__menu-button')
|
|
442
|
-
}, rest)), useContrast() ? React.createElement(Contrast, {
|
|
443
|
-
className: classNames('eds-overflow-menu__menu-list'),
|
|
444
|
-
as: MenuList,
|
|
445
|
-
portal: false
|
|
446
|
-
}, [children]) : React.createElement(MenuList, {
|
|
447
|
-
className: classNames('eds-overflow-menu__menu-list', {
|
|
448
|
-
'eds-overflow-menu__menu-list--left': position === 'left'
|
|
449
|
-
}),
|
|
450
|
-
portal: false
|
|
451
|
-
}, [children])));
|
|
452
|
-
};
|
|
453
|
-
var OverflowMenuItem = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
454
|
-
var children = _ref2.children,
|
|
455
|
-
className = _ref2.className,
|
|
456
|
-
onSelect = _ref2.onSelect,
|
|
457
|
-
disabled = _ref2.disabled,
|
|
458
|
-
_ref2$as = _ref2.as,
|
|
459
|
-
as = _ref2$as === void 0 ? 'div' : _ref2$as,
|
|
460
|
-
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
461
|
-
return React.createElement(MenuItem, _extends({
|
|
462
|
-
className: classNames('eds-overflow-menu__item', {
|
|
463
|
-
'eds-overflow-menu__item--disabled': disabled
|
|
464
|
-
}, className),
|
|
465
|
-
onSelect: onSelect,
|
|
466
|
-
disabled: disabled,
|
|
467
|
-
ref: ref,
|
|
468
|
-
as: as
|
|
469
|
-
}, rest), children);
|
|
470
|
-
});
|
|
471
|
-
var OverflowMenuLink = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
472
|
-
var children = _ref3.children,
|
|
473
|
-
_ref3$as = _ref3.as,
|
|
474
|
-
as = _ref3$as === void 0 ? 'a' : _ref3$as,
|
|
475
|
-
className = _ref3.className,
|
|
476
|
-
onSelect = _ref3.onSelect,
|
|
477
|
-
disabled = _ref3.disabled,
|
|
478
|
-
rest = _objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
479
|
-
return React.createElement(MenuLink, _extends({
|
|
480
|
-
as: as,
|
|
481
|
-
className: classNames('eds-overflow-menu__item', {
|
|
482
|
-
'eds-overflow-menu__item--disabled': disabled
|
|
483
|
-
}, className),
|
|
484
|
-
onSelect: onSelect,
|
|
485
|
-
disabled: disabled,
|
|
486
|
-
ref: ref
|
|
487
|
-
}, rest), children);
|
|
488
|
-
});
|
|
489
|
-
|
|
490
|
-
var _excluded$1 = ["className", "currentPage", "inputLabel", "onPageChange", "pageCount", "pageLabel", "previousPageLabel", "currentPageLabelForScreenreader", "lastPageLabelForScreenreader", "showInput", "numberOfResults", "resultsPerPage", "resultsPerPageOptions", "onResultsPerPageChange", "showNumberOfResultsLabel", "nextPageLabel", "showingResultsLabel", "hideNextButton", "hidePrevButton"];
|
|
381
|
+
var _excluded$5 = ["className", "currentPage", "inputLabel", "onPageChange", "pageCount", "pageLabel", "previousPageLabel", "currentPageLabelForScreenreader", "lastPageLabelForScreenreader", "showInput", "numberOfResults", "resultsPerPage", "resultsPerPageOptions", "onResultsPerPageChange", "showNumberOfResultsLabel", "nextPageLabel", "showingResultsLabel", "changeNumberOfResultsLabelForScreenreader", "hideNextButton", "hidePrevButton"];
|
|
491
382
|
var Pagination = function Pagination(_ref) {
|
|
492
383
|
var className = _ref.className,
|
|
493
384
|
currentPage = _ref.currentPage,
|
|
@@ -518,12 +409,13 @@ var Pagination = function Pagination(_ref) {
|
|
|
518
409
|
showingResultsLabel = _ref$showingResultsLa === void 0 ? function (minPage, maxPage, pageCount) {
|
|
519
410
|
return "Viser resultat " + minPage + "\u2013" + maxPage + " av " + pageCount;
|
|
520
411
|
} : _ref$showingResultsLa,
|
|
412
|
+
_ref$changeNumberOfRe = _ref.changeNumberOfResultsLabelForScreenreader,
|
|
413
|
+
changeNumberOfResultsLabelForScreenreader = _ref$changeNumberOfRe === void 0 ? "Viser " + resultsPerPage + " resultater. Trykk for \xE5 endre antall. \xC5pner en flervalgsmeny." : _ref$changeNumberOfRe,
|
|
521
414
|
_ref$hideNextButton = _ref.hideNextButton,
|
|
522
415
|
hideNextButton = _ref$hideNextButton === void 0 ? false : _ref$hideNextButton,
|
|
523
416
|
_ref$hidePrevButton = _ref.hidePrevButton,
|
|
524
417
|
hidePrevButton = _ref$hidePrevButton === void 0 ? false : _ref$hidePrevButton,
|
|
525
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
526
|
-
var isContrast = useContrast();
|
|
418
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
527
419
|
var _useState = useState([]),
|
|
528
420
|
listedEntries = _useState[0],
|
|
529
421
|
setListedEntries = _useState[1];
|
|
@@ -556,30 +448,26 @@ var Pagination = function Pagination(_ref) {
|
|
|
556
448
|
"aria-label": "Paginering"
|
|
557
449
|
}, rest), resultsPerPage && numberOfResults && React.createElement("div", {
|
|
558
450
|
className: "eds-pagination__results"
|
|
559
|
-
}, onResultsPerPageChange && React.createElement(
|
|
560
|
-
var isOpen = _ref2.isOpen;
|
|
561
|
-
return React.createElement(React.Fragment, null, React.createElement(Label, {
|
|
562
|
-
as: "p",
|
|
563
|
-
"aria-hidden": "true"
|
|
564
|
-
}, showNumberOfResultsLabel), React.createElement(MenuButton, {
|
|
565
|
-
className: classNames('eds-pagination-menu__menu-button', {
|
|
566
|
-
'eds-pagination-menu__menu-button--open': isOpen
|
|
567
|
-
})
|
|
568
|
-
}, React.createElement(VisuallyHidden, null, showNumberOfResultsLabel, " "), resultsPerPage, isOpen ? React.createElement(UpArrowIcon, null) : React.createElement(DownArrowIcon, null)), React.createElement(MenuList, {
|
|
569
|
-
className: classNames('eds-pagination-menu__menu-list', 'eds-overflow-menu__menu-list', {
|
|
570
|
-
'eds-contrast': isContrast
|
|
571
|
-
})
|
|
572
|
-
}, resultsPerPageOptions.map(function (option, key) {
|
|
573
|
-
return React.createElement(OverflowMenuItem, {
|
|
574
|
-
key: key,
|
|
575
|
-
onSelect: function onSelect() {
|
|
576
|
-
return onResultsPerPageChange(option);
|
|
577
|
-
}
|
|
578
|
-
}, option);
|
|
579
|
-
})));
|
|
580
|
-
}), React.createElement(Label, {
|
|
451
|
+
}, onResultsPerPageChange && React.createElement(React.Fragment, null, React.createElement(Label, {
|
|
581
452
|
as: "p",
|
|
582
|
-
|
|
453
|
+
"aria-hidden": "true"
|
|
454
|
+
}, showNumberOfResultsLabel), React.createElement(OverflowMenu, {
|
|
455
|
+
className: "eds-pagination__results__change-number-of-results",
|
|
456
|
+
buttonIcon: React.createElement(React.Fragment, null, resultsPerPage, ' ', React.createElement(DownArrowIcon, {
|
|
457
|
+
className: "eds-pagination__results__change-number-of-results__arrow",
|
|
458
|
+
"aria-hidden": "true"
|
|
459
|
+
})),
|
|
460
|
+
"aria-label": changeNumberOfResultsLabelForScreenreader,
|
|
461
|
+
placement: "bottom-end"
|
|
462
|
+
}, resultsPerPageOptions.map(function (option, key) {
|
|
463
|
+
return React.createElement(OverflowMenuItem, {
|
|
464
|
+
key: key,
|
|
465
|
+
onSelect: function onSelect() {
|
|
466
|
+
return onResultsPerPageChange(option);
|
|
467
|
+
}
|
|
468
|
+
}, option);
|
|
469
|
+
}))), React.createElement(Label, {
|
|
470
|
+
as: "p"
|
|
583
471
|
}, showingResultsLabel((currentPage - 1) * resultsPerPage + 1, currentPage * resultsPerPage > numberOfResults ? numberOfResults : currentPage * resultsPerPage, numberOfResults))), React.createElement("div", {
|
|
584
472
|
className: "eds-pagination__controls"
|
|
585
473
|
}, !hidePrevButton && React.createElement(PaginationPage, {
|
|
@@ -589,7 +477,9 @@ var Pagination = function Pagination(_ref) {
|
|
|
589
477
|
"aria-label": previousPageLabel,
|
|
590
478
|
"aria-describedby": paginationId,
|
|
591
479
|
disabled: isFirstPostSelected
|
|
592
|
-
}, React.createElement(LeftArrowIcon,
|
|
480
|
+
}, React.createElement(LeftArrowIcon, {
|
|
481
|
+
"aria-hidden": "true"
|
|
482
|
+
})), listedEntries.map(function (entry, index) {
|
|
593
483
|
return entry === '…' ? React.createElement(Ellipsis, {
|
|
594
484
|
key: "ellipsis-" + index
|
|
595
485
|
}) : React.createElement(PaginationPage, {
|
|
@@ -608,7 +498,9 @@ var Pagination = function Pagination(_ref) {
|
|
|
608
498
|
"aria-label": nextPageLabel,
|
|
609
499
|
"aria-describedby": paginationId,
|
|
610
500
|
disabled: isLastPostSelected
|
|
611
|
-
}, React.createElement(RightArrowIcon,
|
|
501
|
+
}, React.createElement(RightArrowIcon, {
|
|
502
|
+
"aria-hidden": "true"
|
|
503
|
+
})), showInput && React.createElement(PaginationInput, {
|
|
612
504
|
pageCount: pageCount,
|
|
613
505
|
currentPage: currentPage,
|
|
614
506
|
onPageChange: onPageChange,
|
|
@@ -619,12 +511,194 @@ var Pagination = function Pagination(_ref) {
|
|
|
619
511
|
};
|
|
620
512
|
var Ellipsis = function Ellipsis() {
|
|
621
513
|
return React.createElement("span", {
|
|
622
|
-
className: "eds-
|
|
514
|
+
className: "eds-pagination__controls__page__ellipsis",
|
|
623
515
|
"aria-hidden": "true"
|
|
624
516
|
}, "\u2026");
|
|
625
517
|
};
|
|
626
518
|
|
|
627
|
-
var _excluded = ["
|
|
519
|
+
var _excluded$4 = ["className", "children", "size"];
|
|
520
|
+
var SideNavigation = function SideNavigation(_ref) {
|
|
521
|
+
var className = _ref.className,
|
|
522
|
+
children = _ref.children,
|
|
523
|
+
_ref$size = _ref.size,
|
|
524
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
525
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
526
|
+
if (!children || !React.Children.count(children)) {
|
|
527
|
+
return null;
|
|
528
|
+
}
|
|
529
|
+
return React.createElement("ul", _extends({
|
|
530
|
+
className: classNames('eds-side-navigation', {
|
|
531
|
+
'eds-side-navigation--small': size === 'small'
|
|
532
|
+
}, className)
|
|
533
|
+
}, rest), children);
|
|
534
|
+
};
|
|
535
|
+
/** This is required to check that the Menu */
|
|
536
|
+
SideNavigation.__IS_ENTUR_MENU__ = true;
|
|
537
|
+
|
|
538
|
+
var useShowDelayedLabel = function useShowDelayedLabel(isCollapsed) {
|
|
539
|
+
var _useState = useState(true),
|
|
540
|
+
showLabel = _useState[0],
|
|
541
|
+
setShowLabel = _useState[1];
|
|
542
|
+
var hideDelay = 50;
|
|
543
|
+
var showDelay = 200;
|
|
544
|
+
useEffect(function () {
|
|
545
|
+
if (isCollapsed) {
|
|
546
|
+
setTimeout(function () {
|
|
547
|
+
setShowLabel(false);
|
|
548
|
+
}, hideDelay);
|
|
549
|
+
}
|
|
550
|
+
if (!isCollapsed) {
|
|
551
|
+
setTimeout(function () {
|
|
552
|
+
setShowLabel(true);
|
|
553
|
+
}, showDelay);
|
|
554
|
+
}
|
|
555
|
+
return function () {
|
|
556
|
+
return undefined;
|
|
557
|
+
};
|
|
558
|
+
}, [isCollapsed]);
|
|
559
|
+
return [showLabel];
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
var _excluded$3 = ["className", "active", "subMenu", "icon", "children", "as"],
|
|
563
|
+
_excluded2 = ["children"],
|
|
564
|
+
_excluded3 = ["active", "disabled", "children", "forceExpandSubMenus", "as"];
|
|
565
|
+
function isActiveRecursively(child) {
|
|
566
|
+
if (!child.props) {
|
|
567
|
+
return false;
|
|
568
|
+
}
|
|
569
|
+
if (child.props.active) {
|
|
570
|
+
return true;
|
|
571
|
+
}
|
|
572
|
+
if (!child.props.children) {
|
|
573
|
+
return false;
|
|
574
|
+
}
|
|
575
|
+
return React.Children.toArray(child.props.children).some(function (child) {
|
|
576
|
+
return isActiveRecursively(child);
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
var defaultElementBaseItem = 'a';
|
|
580
|
+
var BaseSideNavigationItem = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
581
|
+
var className = _ref.className,
|
|
582
|
+
_ref$active = _ref.active,
|
|
583
|
+
active = _ref$active === void 0 ? false : _ref$active,
|
|
584
|
+
subMenu = _ref.subMenu,
|
|
585
|
+
icon = _ref.icon,
|
|
586
|
+
children = _ref.children,
|
|
587
|
+
as = _ref.as,
|
|
588
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
589
|
+
var Element = as || defaultElementBaseItem;
|
|
590
|
+
var _useSideNavigationCon = useSideNavigationContext(),
|
|
591
|
+
isCollapsed = _useSideNavigationCon.isCollapsed;
|
|
592
|
+
var _useShowDelayedLabel = useShowDelayedLabel(isCollapsed),
|
|
593
|
+
showLabel = _useShowDelayedLabel[0];
|
|
594
|
+
return React.createElement("li", {
|
|
595
|
+
className: classNames('eds-side-navigation__item', className)
|
|
596
|
+
}, React.createElement(Element, _extends({
|
|
597
|
+
className: classNames('eds-side-navigation__click-target', {
|
|
598
|
+
'eds-side-navigation__click-target--active': active
|
|
599
|
+
}),
|
|
600
|
+
"aria-label": isCollapsed ? children : undefined,
|
|
601
|
+
"aria-current": active ? 'page' : undefined,
|
|
602
|
+
ref: ref
|
|
603
|
+
}, rest), icon, showLabel && children), subMenu);
|
|
604
|
+
});
|
|
605
|
+
var DisabledSideNavigationItem = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
606
|
+
var children = _ref2.children,
|
|
607
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
608
|
+
return React.createElement(BaseSideNavigationItem, _extends({
|
|
609
|
+
as: "button",
|
|
610
|
+
disabled: true,
|
|
611
|
+
"aria-disabled": true,
|
|
612
|
+
ref: ref,
|
|
613
|
+
type: "button"
|
|
614
|
+
}, rest), children);
|
|
615
|
+
});
|
|
616
|
+
var defaultElementItem = 'a';
|
|
617
|
+
var SideNavigationItem = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
618
|
+
var active = _ref3.active,
|
|
619
|
+
disabled = _ref3.disabled,
|
|
620
|
+
children = _ref3.children,
|
|
621
|
+
forceExpandSubMenus = _ref3.forceExpandSubMenus,
|
|
622
|
+
as = _ref3.as,
|
|
623
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
624
|
+
var Element = as || defaultElementItem;
|
|
625
|
+
var childrenArray = React.Children.toArray(children);
|
|
626
|
+
var subMenu = childrenArray.find(function (child) {
|
|
627
|
+
return child && child.type && child.type.__IS_ENTUR_MENU__;
|
|
628
|
+
});
|
|
629
|
+
var label = subMenu ? childrenArray.filter(function (child) {
|
|
630
|
+
return child !== subMenu;
|
|
631
|
+
}) : children;
|
|
632
|
+
if (disabled) {
|
|
633
|
+
return React.createElement(DisabledSideNavigationItem, _extends({
|
|
634
|
+
ref: ref
|
|
635
|
+
}, rest), label);
|
|
636
|
+
}
|
|
637
|
+
if (!subMenu) {
|
|
638
|
+
return React.createElement(BaseSideNavigationItem, _extends({
|
|
639
|
+
as: Element,
|
|
640
|
+
active: active,
|
|
641
|
+
ref: ref
|
|
642
|
+
}, rest), label);
|
|
643
|
+
}
|
|
644
|
+
var isExpanded = forceExpandSubMenus || isActiveRecursively({
|
|
645
|
+
props: {
|
|
646
|
+
children: children,
|
|
647
|
+
active: active
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
return React.createElement(BaseSideNavigationItem, _extends({
|
|
651
|
+
active: active,
|
|
652
|
+
subMenu: isExpanded && subMenu,
|
|
653
|
+
"aria-expanded": isExpanded,
|
|
654
|
+
as: Element,
|
|
655
|
+
ref: ref
|
|
656
|
+
}, rest), label);
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
var _excluded$2 = ["defaultOpen", "open", "onToggle", "className", "children", "title", "icon"];
|
|
660
|
+
var SideNavigationGroup = function SideNavigationGroup(_ref) {
|
|
661
|
+
var _ref$defaultOpen = _ref.defaultOpen,
|
|
662
|
+
defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen,
|
|
663
|
+
open = _ref.open,
|
|
664
|
+
onToggle = _ref.onToggle,
|
|
665
|
+
className = _ref.className,
|
|
666
|
+
children = _ref.children,
|
|
667
|
+
title = _ref.title,
|
|
668
|
+
icon = _ref.icon,
|
|
669
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
670
|
+
var _useControllableProp = useControllableProp({
|
|
671
|
+
prop: open,
|
|
672
|
+
updater: onToggle,
|
|
673
|
+
defaultValue: defaultOpen
|
|
674
|
+
}),
|
|
675
|
+
isOpen = _useControllableProp[0],
|
|
676
|
+
setOpen = _useControllableProp[1];
|
|
677
|
+
var _useSideNavigationCon = useSideNavigationContext(),
|
|
678
|
+
isCollapsed = _useSideNavigationCon.isCollapsed;
|
|
679
|
+
var _useShowDelayedLabel = useShowDelayedLabel(isCollapsed),
|
|
680
|
+
showLabel = _useShowDelayedLabel[0];
|
|
681
|
+
return React.createElement("div", _extends({
|
|
682
|
+
className: classNames('eds-side-navigation-group', className)
|
|
683
|
+
}, rest), React.createElement("button", {
|
|
684
|
+
onClick: function onClick() {
|
|
685
|
+
return setOpen(!isOpen);
|
|
686
|
+
},
|
|
687
|
+
type: "button",
|
|
688
|
+
className: "eds-side-navigation-group__trigger",
|
|
689
|
+
"aria-label": title + ", utvidbar meny, " + (isOpen ? 'åpen' : 'lukket')
|
|
690
|
+
}, React.createElement("span", null, icon && React.createElement("span", {
|
|
691
|
+
className: "eds-side-navigation-group__trigger-icon"
|
|
692
|
+
}, icon), showLabel && title), showLabel && React.createElement(ExpandArrow, {
|
|
693
|
+
open: isOpen,
|
|
694
|
+
className: "eds-side-navigation-group__expand-icon"
|
|
695
|
+
})), React.createElement(BaseExpand, {
|
|
696
|
+
className: "eds-side-navigation-group__expand-content",
|
|
697
|
+
open: isOpen
|
|
698
|
+
}, children));
|
|
699
|
+
};
|
|
700
|
+
|
|
701
|
+
var _excluded$1 = ["activeIndex", "className", "interactive", "onStepClick", "showStepperIndex", "steps", "ariaLabelStep", "ariaLabelOf", "ariaLabelCompleted", "ariaLabelSummary"];
|
|
628
702
|
var Stepper = function Stepper(_ref) {
|
|
629
703
|
var activeIndex = _ref.activeIndex,
|
|
630
704
|
className = _ref.className,
|
|
@@ -642,7 +716,7 @@ var Stepper = function Stepper(_ref) {
|
|
|
642
716
|
ariaLabelCompleted = _ref$ariaLabelComplet === void 0 ? 'fullført' : _ref$ariaLabelComplet,
|
|
643
717
|
_ref$ariaLabelSummary = _ref.ariaLabelSummary,
|
|
644
718
|
ariaLabelSummary = _ref$ariaLabelSummary === void 0 ? "Stegindikator med " + steps.length + " steg, du er p\xE5 steg " + (activeIndex + 1) + " " + steps[activeIndex] + "," : _ref$ariaLabelSummary,
|
|
645
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
719
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
646
720
|
return React.createElement("ol", _extends({
|
|
647
721
|
className: classNames('eds-stepper', className),
|
|
648
722
|
"aria-label": ariaLabelSummary
|
|
@@ -680,6 +754,22 @@ var Stepper = function Stepper(_ref) {
|
|
|
680
754
|
}));
|
|
681
755
|
};
|
|
682
756
|
|
|
757
|
+
var _excluded = ["active", "className", "as"];
|
|
758
|
+
var defaultElement = 'a';
|
|
759
|
+
var TopNavigationItem = function TopNavigationItem(_ref) {
|
|
760
|
+
var _ref$active = _ref.active,
|
|
761
|
+
active = _ref$active === void 0 ? false : _ref$active,
|
|
762
|
+
className = _ref.className,
|
|
763
|
+
as = _ref.as,
|
|
764
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
765
|
+
var Element = as || defaultElement;
|
|
766
|
+
return React.createElement(Element, _extends({
|
|
767
|
+
className: classNames(['eds-top-navigation-item', className, {
|
|
768
|
+
'eds-top-navigation-item--active': active
|
|
769
|
+
}])
|
|
770
|
+
}, rest));
|
|
771
|
+
};
|
|
772
|
+
|
|
683
773
|
warnAboutMissingStyles('menu', 'expand', 'icons', 'typography', 'button', 'layout', 'a11y');
|
|
684
774
|
|
|
685
775
|
export { BreadcrumbItem, BreadcrumbNavigation, CollapsibleSideNavigation, OverflowMenu, OverflowMenuItem, OverflowMenuLink, Pagination, SideNavigation, SideNavigationGroup, SideNavigationItem, Stepper, TopNavigationItem, useSideNavigationContext };
|