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