@entur/menu 5.2.1-beta.3 → 5.2.1-beta.5
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/BreadcrumbItem.d.ts +19 -0
- package/dist/BreadcrumbNavigation.d.ts +11 -0
- package/dist/CollapsibleSideNavigation.d.ts +27 -0
- package/dist/OverflowMenu.d.ts +55 -0
- package/dist/Pagination.d.ts +69 -0
- package/dist/PaginationInput.d.ts +8 -0
- package/dist/PaginationPage.d.ts +17 -0
- package/dist/SideNavigation.d.ts +16 -0
- package/dist/SideNavigationGroup.d.ts +20 -0
- package/dist/SideNavigationItem.d.ts +33 -0
- package/dist/Stepper.d.ts +39 -0
- package/dist/TopNavigationItem.d.ts +21 -0
- package/dist/index.d.ts +11 -352
- package/dist/index.js +8 -0
- package/dist/menu.cjs.development.js +793 -0
- package/dist/menu.cjs.development.js.map +1 -0
- package/dist/menu.cjs.production.min.js +2 -0
- package/dist/menu.cjs.production.min.js.map +1 -0
- package/dist/menu.esm.js +669 -712
- package/dist/menu.esm.js.map +1 -1
- package/dist/styles.css +697 -668
- package/dist/useControllableProp.d.ts +6 -0
- package/dist/useShowDelayedLabel.d.ts +1 -0
- package/package.json +20 -30
- package/dist/menu.cjs.js +0 -820
- package/dist/menu.cjs.js.map +0 -1
package/dist/menu.esm.js
CHANGED
|
@@ -1,318 +1,347 @@
|
|
|
1
|
-
import { useOnClickOutside, useOnEscape, getNodeText, useRandomId, warnAboutMissingStyles } from
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return
|
|
1
|
+
import { useOnClickOutside, useOnEscape, getNodeText, useRandomId, warnAboutMissingStyles } from '@entur/utils';
|
|
2
|
+
import React, { useState, useEffect, useRef, cloneElement, useContext } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { RightArrowIcon, MenuIcon, LeftArrowIcon, VerticalDotsIcon, DownArrowIcon } from '@entur/icons';
|
|
5
|
+
import { useFloating, offset, flip, shift, autoUpdate, 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';
|
|
9
|
+
import { VisuallyHidden } from '@entur/a11y';
|
|
10
|
+
import { Label } from '@entur/typography';
|
|
11
|
+
import { ExpandArrow, BaseExpand } from '@entur/expand';
|
|
12
|
+
|
|
13
|
+
var BreadcrumbNavigation = function BreadcrumbNavigation(_ref) {
|
|
14
|
+
var _ref$ariaLabel = _ref['aria-label'],
|
|
15
|
+
ariaLabel = _ref$ariaLabel === void 0 ? 'Brødsmulesti' : _ref$ariaLabel,
|
|
16
|
+
children = _ref.children;
|
|
17
|
+
return React.createElement("nav", {
|
|
18
|
+
"aria-label": ariaLabel
|
|
19
|
+
}, React.createElement("ol", {
|
|
20
|
+
className: "eds-breadcrumbs"
|
|
21
|
+
}, React.Children.map(children, function (child, index) {
|
|
22
|
+
// @ts-expect-error should check if children are correct but for now it is only mentioned in the documentation
|
|
18
23
|
return React.cloneElement(child, {
|
|
19
24
|
isCurrent: index + 1 === React.Children.count(children)
|
|
20
25
|
});
|
|
21
|
-
})
|
|
26
|
+
})));
|
|
22
27
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
)
|
|
50
|
-
|
|
28
|
+
|
|
29
|
+
function _extends() {
|
|
30
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
31
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
32
|
+
var t = arguments[e];
|
|
33
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
34
|
+
}
|
|
35
|
+
return n;
|
|
36
|
+
}, _extends.apply(null, arguments);
|
|
37
|
+
}
|
|
38
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
39
|
+
if (null == r) return {};
|
|
40
|
+
var t = {};
|
|
41
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
42
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
43
|
+
t[n] = r[n];
|
|
44
|
+
}
|
|
45
|
+
return t;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var _excluded$8 = ["className", "isCurrent", "as"];
|
|
49
|
+
var defaultElement$1 = 'a';
|
|
50
|
+
var BreadcrumbItem = function BreadcrumbItem(_ref) {
|
|
51
|
+
var className = _ref.className,
|
|
52
|
+
isCurrent = _ref.isCurrent,
|
|
53
|
+
as = _ref.as,
|
|
54
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
|
|
55
|
+
var Element = as || defaultElement$1;
|
|
56
|
+
return React.createElement(React.Fragment, null, React.createElement("li", {
|
|
57
|
+
className: classNames('eds-breadcrumb__item', className)
|
|
58
|
+
}, React.createElement(Element, _extends({
|
|
59
|
+
"aria-current": isCurrent ? 'page' : undefined,
|
|
60
|
+
className: classNames('eds-breadcrumb__link', {
|
|
61
|
+
'eds-breadcrumb__link--current': isCurrent
|
|
62
|
+
})
|
|
63
|
+
}, rest))), !isCurrent && React.createElement(RightArrowIcon, {
|
|
64
|
+
className: "eds-breadcrumb__separator",
|
|
65
|
+
inline: true,
|
|
66
|
+
role: "presentation"
|
|
67
|
+
}));
|
|
51
68
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
69
|
+
|
|
70
|
+
function useControllableProp(_ref) {
|
|
71
|
+
var prop = _ref.prop,
|
|
72
|
+
_ref$updater = _ref.updater,
|
|
73
|
+
updater = _ref$updater === void 0 ? function () {
|
|
74
|
+
return undefined;
|
|
75
|
+
} : _ref$updater,
|
|
76
|
+
defaultValue = _ref.defaultValue;
|
|
77
|
+
var _useState = useState(defaultValue),
|
|
78
|
+
internalState = _useState[0],
|
|
79
|
+
setInternalState = _useState[1];
|
|
80
|
+
useEffect(function () {
|
|
81
|
+
if (prop !== undefined) {
|
|
60
82
|
setInternalState(prop);
|
|
61
83
|
}
|
|
62
84
|
}, [prop]);
|
|
63
|
-
return prop ===
|
|
85
|
+
return prop === undefined ? [internalState, setInternalState] : [prop, updater];
|
|
64
86
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
className: classNames(
|
|
91
|
-
"eds-side-navigation",
|
|
92
|
-
{ "eds-side-navigation--small": size === "small" },
|
|
93
|
-
{ "eds-side-navigation--collapsed": collapsedMenu },
|
|
94
|
-
className
|
|
95
|
-
),
|
|
96
|
-
...rest,
|
|
97
|
-
children: [
|
|
98
|
-
children,
|
|
99
|
-
/* @__PURE__ */ jsx(
|
|
100
|
-
"button",
|
|
101
|
-
{
|
|
102
|
-
className: "eds-side-navigation__collapse-button",
|
|
103
|
-
onClick: () => setCollapsedMenu(!collapsedMenu),
|
|
104
|
-
style: { top: `${collapsibleButtonPosition}` },
|
|
105
|
-
children: collapsedMenu ? /* @__PURE__ */ jsx(MenuIcon, { "aria-label": openSideMenuAriaLabel }) : /* @__PURE__ */ jsx(LeftArrowIcon, { "aria-label": closeSideMenuAriaLabel })
|
|
106
|
-
}
|
|
107
|
-
)
|
|
108
|
-
]
|
|
109
|
-
}
|
|
110
|
-
)
|
|
87
|
+
|
|
88
|
+
var _excluded$7 = ["className", "children", "size", "collapsed", "onCollapseToggle", "collapsibleButtonPosition", "openSideMenuAriaLabel", "closeSideMenuAriaLabel"];
|
|
89
|
+
var CollapsibleSideNavigation = function CollapsibleSideNavigation(_ref) {
|
|
90
|
+
var className = _ref.className,
|
|
91
|
+
children = _ref.children,
|
|
92
|
+
size = _ref.size,
|
|
93
|
+
collapsible = _ref.collapsed,
|
|
94
|
+
onCollapseToggle = _ref.onCollapseToggle,
|
|
95
|
+
_ref$collapsibleButto = _ref.collapsibleButtonPosition,
|
|
96
|
+
collapsibleButtonPosition = _ref$collapsibleButto === void 0 ? '50%' : _ref$collapsibleButto,
|
|
97
|
+
_ref$openSideMenuAria = _ref.openSideMenuAriaLabel,
|
|
98
|
+
openSideMenuAriaLabel = _ref$openSideMenuAria === void 0 ? 'Åpne sidemeny' : _ref$openSideMenuAria,
|
|
99
|
+
_ref$closeSideMenuAri = _ref.closeSideMenuAriaLabel,
|
|
100
|
+
closeSideMenuAriaLabel = _ref$closeSideMenuAri === void 0 ? 'Lukk sidemeny' : _ref$closeSideMenuAri,
|
|
101
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
102
|
+
var _useControllableProp = useControllableProp({
|
|
103
|
+
prop: collapsible,
|
|
104
|
+
defaultValue: false,
|
|
105
|
+
updater: onCollapseToggle
|
|
106
|
+
}),
|
|
107
|
+
collapsedMenu = _useControllableProp[0],
|
|
108
|
+
setCollapsedMenu = _useControllableProp[1];
|
|
109
|
+
return React.createElement(SideNavigationContext.Provider, {
|
|
110
|
+
value: {
|
|
111
|
+
isCollapsed: collapsedMenu
|
|
111
112
|
}
|
|
112
|
-
|
|
113
|
+
}, React.createElement("ul", _extends({
|
|
114
|
+
className: classNames('eds-side-navigation', {
|
|
115
|
+
'eds-side-navigation--small': size === 'small'
|
|
116
|
+
}, {
|
|
117
|
+
'eds-side-navigation--collapsed': collapsedMenu
|
|
118
|
+
}, className)
|
|
119
|
+
}, rest), children, React.createElement("button", {
|
|
120
|
+
className: "eds-side-navigation__collapse-button",
|
|
121
|
+
onClick: function onClick() {
|
|
122
|
+
return setCollapsedMenu(!collapsedMenu);
|
|
123
|
+
},
|
|
124
|
+
style: {
|
|
125
|
+
top: "" + collapsibleButtonPosition
|
|
126
|
+
}
|
|
127
|
+
}, collapsedMenu ? React.createElement(MenuIcon, {
|
|
128
|
+
"aria-label": openSideMenuAriaLabel
|
|
129
|
+
}) : React.createElement(LeftArrowIcon, {
|
|
130
|
+
"aria-label": closeSideMenuAriaLabel
|
|
131
|
+
}))));
|
|
113
132
|
};
|
|
114
|
-
|
|
133
|
+
var SideNavigationContext = /*#__PURE__*/React.createContext({
|
|
115
134
|
isCollapsed: false
|
|
116
135
|
});
|
|
117
|
-
|
|
118
|
-
|
|
136
|
+
var useSideNavigationContext = function useSideNavigationContext() {
|
|
137
|
+
var context = React.useContext(SideNavigationContext);
|
|
119
138
|
if (!context) {
|
|
120
|
-
console.error(
|
|
121
|
-
"Error reading SideNavigationContext. Please contact maintainer of @entur/menu"
|
|
122
|
-
);
|
|
139
|
+
console.error('Error reading SideNavigationContext. Please contact maintainer of @entur/menu');
|
|
123
140
|
}
|
|
124
141
|
return context;
|
|
125
142
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
143
|
+
|
|
144
|
+
var _excluded$6 = ["children", "className", "button", "buttonIcon", "placement", "aria-label"],
|
|
145
|
+
_excluded2$1 = ["children", "className", "onSelect", "href", "disabled", "as"];
|
|
146
|
+
var SelectContext = /*#__PURE__*/React.createContext({});
|
|
147
|
+
var OverflowMenu = function OverflowMenu(_ref) {
|
|
148
|
+
var children = _ref.children,
|
|
149
|
+
className = _ref.className,
|
|
150
|
+
button = _ref.button,
|
|
151
|
+
buttonIcon = _ref.buttonIcon,
|
|
152
|
+
_ref$placement = _ref.placement,
|
|
153
|
+
placement = _ref$placement === void 0 ? 'bottom-start' : _ref$placement,
|
|
154
|
+
_ref$ariaLabel = _ref['aria-label'],
|
|
155
|
+
ariaLabel = _ref$ariaLabel === void 0 ? 'åpne valgmeny' : _ref$ariaLabel,
|
|
156
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
157
|
+
var _useState = useState(false),
|
|
158
|
+
isOpen = _useState[0],
|
|
159
|
+
setIsOpen = _useState[1];
|
|
160
|
+
var _useState2 = useState(null),
|
|
161
|
+
activeIndex = _useState2[0],
|
|
162
|
+
setActiveIndex = _useState2[1];
|
|
163
|
+
var listRef = useRef([]);
|
|
164
|
+
var labelsRef = useRef([]);
|
|
165
|
+
var _useFloating = useFloating({
|
|
166
|
+
placement: standardisePlacement(
|
|
144
167
|
// check for left is added for backwards compatibility
|
|
145
|
-
rest.position ===
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
168
|
+
rest.position === 'left' ? 'bottom-end' : placement),
|
|
169
|
+
open: isOpen,
|
|
170
|
+
onOpenChange: setIsOpen,
|
|
171
|
+
middleware: [offset(space.extraSmall2), flip(), shift({
|
|
172
|
+
padding: space.extraSmall
|
|
173
|
+
})]
|
|
174
|
+
}),
|
|
175
|
+
refs = _useFloating.refs,
|
|
176
|
+
floatingStyles = _useFloating.floatingStyles,
|
|
177
|
+
context = _useFloating.context,
|
|
178
|
+
elements = _useFloating.elements,
|
|
179
|
+
update = _useFloating.update;
|
|
180
|
+
// Since we use CSS instead of conditional rendering when hiding dropdownlist
|
|
181
|
+
// we can't use the whileElementsMounted option and need to handle
|
|
182
|
+
// cleanup ourselves. See https://floating-ui.com/docs/autoupdate
|
|
183
|
+
useEffect(function () {
|
|
156
184
|
if (isOpen && elements.reference && elements.floating) {
|
|
157
|
-
|
|
185
|
+
var cleanup = autoUpdate(elements.reference, elements.floating, update);
|
|
158
186
|
return cleanup;
|
|
159
187
|
}
|
|
160
188
|
}, [isOpen, elements, update]);
|
|
161
|
-
|
|
162
|
-
listRef,
|
|
163
|
-
activeIndex,
|
|
189
|
+
var listNav = useListNavigation(context, {
|
|
190
|
+
listRef: listRef,
|
|
191
|
+
activeIndex: activeIndex,
|
|
164
192
|
onNavigate: setActiveIndex
|
|
165
193
|
});
|
|
166
|
-
|
|
194
|
+
var typeahead = useTypeahead(context, {
|
|
167
195
|
listRef: labelsRef,
|
|
168
|
-
activeIndex,
|
|
169
|
-
onMatch: (index)
|
|
196
|
+
activeIndex: activeIndex,
|
|
197
|
+
onMatch: function onMatch(index) {
|
|
198
|
+
return isOpen && setActiveIndex(index);
|
|
199
|
+
}
|
|
170
200
|
});
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
)
|
|
175
|
-
|
|
201
|
+
var role = useRole(context, {
|
|
202
|
+
role: 'menu'
|
|
203
|
+
});
|
|
204
|
+
var _useInteractions = useInteractions([listNav, typeahead, role]),
|
|
205
|
+
getReferenceProps = _useInteractions.getReferenceProps,
|
|
206
|
+
getFloatingProps = _useInteractions.getFloatingProps,
|
|
207
|
+
getItemProps = _useInteractions.getItemProps;
|
|
208
|
+
var closeMenuAndReturnFocus = function closeMenuAndReturnFocus() {
|
|
209
|
+
var _refs$reference$curre;
|
|
176
210
|
setIsOpen(false);
|
|
177
|
-
|
|
211
|
+
// @ts-expect-error the reference element is actually focusable
|
|
212
|
+
(_refs$reference$curre = refs.reference.current) == null || _refs$reference$curre.focus == null || _refs$reference$curre.focus();
|
|
178
213
|
};
|
|
179
|
-
useOnClickOutside([refs.floating, refs.reference], ()
|
|
214
|
+
useOnClickOutside([refs.floating, refs.reference], function () {
|
|
215
|
+
return setIsOpen(false);
|
|
216
|
+
});
|
|
180
217
|
useOnEscape(refs.floating, closeMenuAndReturnFocus);
|
|
181
218
|
useOnEscape(refs.reference, closeMenuAndReturnFocus);
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
activeIndex,
|
|
185
|
-
getItemProps,
|
|
186
|
-
closeMenuAndReturnFocus
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
})
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
className: "eds-overflow-menu__menu-list"
|
|
222
|
-
}),
|
|
223
|
-
children: /* @__PURE__ */ jsx(FloatingList, { elementsRef: listRef, labelsRef, children })
|
|
224
|
-
}
|
|
225
|
-
) })
|
|
226
|
-
] });
|
|
219
|
+
var selectContext = React.useMemo(function () {
|
|
220
|
+
return {
|
|
221
|
+
activeIndex: activeIndex,
|
|
222
|
+
getItemProps: getItemProps,
|
|
223
|
+
closeMenuAndReturnFocus: closeMenuAndReturnFocus
|
|
224
|
+
};
|
|
225
|
+
}, [activeIndex, getItemProps, closeMenuAndReturnFocus]);
|
|
226
|
+
var _buttonIcon = buttonIcon != null ? buttonIcon : React.createElement(VerticalDotsIcon, null);
|
|
227
|
+
return React.createElement(React.Fragment, null, !button ? React.createElement(IconButton, _extends({
|
|
228
|
+
ref: refs.setReference
|
|
229
|
+
}, getReferenceProps({
|
|
230
|
+
onClick: function onClick() {
|
|
231
|
+
return setIsOpen(!isOpen);
|
|
232
|
+
},
|
|
233
|
+
className: className,
|
|
234
|
+
'aria-label': ariaLabel,
|
|
235
|
+
type: 'button'
|
|
236
|
+
}), rest), _buttonIcon) : cloneElement(button, _extends({
|
|
237
|
+
ref: refs.setReference
|
|
238
|
+
}, getReferenceProps({
|
|
239
|
+
onClick: function onClick() {
|
|
240
|
+
return setIsOpen(!isOpen);
|
|
241
|
+
},
|
|
242
|
+
className: className,
|
|
243
|
+
'aria-label': ariaLabel,
|
|
244
|
+
type: 'button'
|
|
245
|
+
}), rest)), React.createElement(SelectContext.Provider, {
|
|
246
|
+
value: selectContext
|
|
247
|
+
}, React.createElement("div", _extends({
|
|
248
|
+
ref: refs.setFloating,
|
|
249
|
+
style: _extends({}, floatingStyles, {
|
|
250
|
+
display: isOpen ? 'initial' : 'none'
|
|
251
|
+
})
|
|
252
|
+
}, getFloatingProps({
|
|
253
|
+
className: 'eds-overflow-menu__menu-list'
|
|
254
|
+
})), React.createElement(FloatingList, {
|
|
255
|
+
elementsRef: listRef,
|
|
256
|
+
labelsRef: labelsRef
|
|
257
|
+
}, children))));
|
|
227
258
|
};
|
|
228
|
-
|
|
229
|
-
children,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
children
|
|
270
|
-
}
|
|
271
|
-
);
|
|
259
|
+
var OverflowMenuItem = function OverflowMenuItem(_ref2) {
|
|
260
|
+
var children = _ref2.children,
|
|
261
|
+
className = _ref2.className,
|
|
262
|
+
_ref2$onSelect = _ref2.onSelect,
|
|
263
|
+
onSelect = _ref2$onSelect === void 0 ? function () {
|
|
264
|
+
return undefined;
|
|
265
|
+
} : _ref2$onSelect,
|
|
266
|
+
href = _ref2.href,
|
|
267
|
+
disabled = _ref2.disabled,
|
|
268
|
+
as = _ref2.as,
|
|
269
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2$1);
|
|
270
|
+
var _useContext = useContext(SelectContext),
|
|
271
|
+
activeIndex = _useContext.activeIndex,
|
|
272
|
+
getItemProps = _useContext.getItemProps,
|
|
273
|
+
closeMenuAndReturnFocus = _useContext.closeMenuAndReturnFocus;
|
|
274
|
+
var _useListItem = useListItem({
|
|
275
|
+
label: !disabled ? 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 = as != null ? as : isLink ? 'a' : 'button';
|
|
282
|
+
return React.createElement(Element, _extends({
|
|
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
|
+
type: Element === 'button' ? 'button' : undefined,
|
|
290
|
+
"aria-disabled": disabled,
|
|
291
|
+
"aria-selected": isHighlighted
|
|
292
|
+
}, getItemProps({
|
|
293
|
+
onClick: isLink || disabled ? undefined : function () {
|
|
294
|
+
onSelect();
|
|
295
|
+
closeMenuAndReturnFocus();
|
|
296
|
+
},
|
|
297
|
+
href: disabled ? undefined : href,
|
|
298
|
+
tabIndex: isHighlighted ? 0 : -1
|
|
299
|
+
}), rest), children);
|
|
272
300
|
};
|
|
273
|
-
|
|
274
|
-
return
|
|
301
|
+
var OverflowMenuLink = function OverflowMenuLink(props) {
|
|
302
|
+
return React.createElement(OverflowMenuItem, _extends({}, props));
|
|
275
303
|
};
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
"button",
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
className
|
|
292
|
-
),
|
|
304
|
+
|
|
305
|
+
var PaginationPage = function PaginationPage(_ref) {
|
|
306
|
+
var children = _ref.children,
|
|
307
|
+
className = _ref.className,
|
|
308
|
+
selected = _ref.selected,
|
|
309
|
+
disabled = _ref.disabled,
|
|
310
|
+
onClick = _ref.onClick,
|
|
311
|
+
ariaLabel = _ref['aria-label'],
|
|
312
|
+
ariaDescribedby = _ref['aria-describedby'];
|
|
313
|
+
return React.createElement("button", {
|
|
314
|
+
className: classNames('eds-pagination__controls__page', {
|
|
315
|
+
'eds-pagination__controls__page--selected': selected
|
|
316
|
+
}, {
|
|
317
|
+
'eds-pagination__controls__page--disabled': disabled
|
|
318
|
+
}, className),
|
|
293
319
|
disabled: selected || disabled,
|
|
294
320
|
type: "button",
|
|
295
|
-
onClick,
|
|
321
|
+
onClick: onClick,
|
|
296
322
|
"aria-label": ariaLabel,
|
|
297
323
|
"aria-describedby": ariaDescribedby,
|
|
298
|
-
"aria-current": selected ?
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
currentPage,
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
324
|
+
"aria-current": selected ? 'page' : false
|
|
325
|
+
}, children);
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
var PaginationInput = function PaginationInput(_ref) {
|
|
329
|
+
var currentPage = _ref.currentPage,
|
|
330
|
+
pageCount = _ref.pageCount,
|
|
331
|
+
_ref$label = _ref.label,
|
|
332
|
+
label = _ref$label === void 0 ? 'Gå til side' : _ref$label,
|
|
333
|
+
onPageChange = _ref.onPageChange;
|
|
334
|
+
var _React$useState = React.useState(String(currentPage)),
|
|
335
|
+
input = _React$useState[0],
|
|
336
|
+
setInput = _React$useState[1];
|
|
337
|
+
// If the currentPage prop changes, we want to reset the input field
|
|
338
|
+
React.useEffect(function () {
|
|
310
339
|
setInput(String(currentPage));
|
|
311
340
|
}, [currentPage]);
|
|
312
|
-
|
|
341
|
+
var handleSubmit = function handleSubmit(e) {
|
|
313
342
|
e.preventDefault();
|
|
314
343
|
e.stopPropagation();
|
|
315
|
-
|
|
344
|
+
var pageNumber = Number(input);
|
|
316
345
|
if (pageNumber === currentPage) {
|
|
317
346
|
return;
|
|
318
347
|
}
|
|
@@ -330,232 +359,210 @@ const PaginationInput = ({
|
|
|
330
359
|
}
|
|
331
360
|
onPageChange(pageNumber);
|
|
332
361
|
};
|
|
333
|
-
|
|
362
|
+
var handleChange = function handleChange(e) {
|
|
334
363
|
setInput(e.target.value);
|
|
335
364
|
};
|
|
336
|
-
return
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
365
|
+
return React.createElement("form", {
|
|
366
|
+
onSubmit: handleSubmit,
|
|
367
|
+
noValidate: true,
|
|
368
|
+
"aria-label": "form"
|
|
369
|
+
}, React.createElement("label", {
|
|
370
|
+
className: "eds-pagination__controls__input__wrapper"
|
|
371
|
+
}, React.createElement("span", {
|
|
372
|
+
className: "eds-pagination__controls__input__label"
|
|
373
|
+
}, label), React.createElement("input", {
|
|
374
|
+
type: "number",
|
|
375
|
+
max: pageCount,
|
|
376
|
+
className: "eds-pagination__controls__input__field",
|
|
377
|
+
value: input,
|
|
378
|
+
onChange: handleChange
|
|
379
|
+
})));
|
|
349
380
|
};
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
+
|
|
382
|
+
var _excluded$5 = ["className", "currentPage", "inputLabel", "onPageChange", "pageCount", "pageLabel", "previousPageLabel", "currentPageLabelForScreenreader", "lastPageLabelForScreenreader", "showInput", "numberOfResults", "resultsPerPage", "resultsPerPageOptions", "onResultsPerPageChange", "showNumberOfResultsLabel", "nextPageLabel", "showingResultsLabel", "changeNumberOfResultsLabelForScreenreader", "hideNextButton", "hidePrevButton"];
|
|
383
|
+
var Pagination = function Pagination(_ref) {
|
|
384
|
+
var className = _ref.className,
|
|
385
|
+
currentPage = _ref.currentPage,
|
|
386
|
+
inputLabel = _ref.inputLabel,
|
|
387
|
+
onPageChange = _ref.onPageChange,
|
|
388
|
+
pageCount = _ref.pageCount,
|
|
389
|
+
_ref$pageLabel = _ref.pageLabel,
|
|
390
|
+
pageLabel = _ref$pageLabel === void 0 ? function (pageNumber) {
|
|
391
|
+
return "G\xE5 til side " + pageNumber;
|
|
392
|
+
} : _ref$pageLabel,
|
|
393
|
+
_ref$previousPageLabe = _ref.previousPageLabel,
|
|
394
|
+
previousPageLabel = _ref$previousPageLabe === void 0 ? 'Gå til forrige side' : _ref$previousPageLabe,
|
|
395
|
+
_ref$currentPageLabel = _ref.currentPageLabelForScreenreader,
|
|
396
|
+
currentPageLabelForScreenreader = _ref$currentPageLabel === void 0 ? 'Nåværende side:' : _ref$currentPageLabel,
|
|
397
|
+
_ref$lastPageLabelFor = _ref.lastPageLabelForScreenreader,
|
|
398
|
+
lastPageLabelForScreenreader = _ref$lastPageLabelFor === void 0 ? ', siste side' : _ref$lastPageLabelFor,
|
|
399
|
+
showInput = _ref.showInput,
|
|
400
|
+
numberOfResults = _ref.numberOfResults,
|
|
401
|
+
resultsPerPage = _ref.resultsPerPage,
|
|
402
|
+
_ref$resultsPerPageOp = _ref.resultsPerPageOptions,
|
|
403
|
+
resultsPerPageOptions = _ref$resultsPerPageOp === void 0 ? [10, 25, 50] : _ref$resultsPerPageOp,
|
|
404
|
+
onResultsPerPageChange = _ref.onResultsPerPageChange,
|
|
405
|
+
_ref$showNumberOfResu = _ref.showNumberOfResultsLabel,
|
|
406
|
+
showNumberOfResultsLabel = _ref$showNumberOfResu === void 0 ? 'Vis' : _ref$showNumberOfResu,
|
|
407
|
+
_ref$nextPageLabel = _ref.nextPageLabel,
|
|
408
|
+
nextPageLabel = _ref$nextPageLabel === void 0 ? 'Gå til neste side' : _ref$nextPageLabel,
|
|
409
|
+
_ref$showingResultsLa = _ref.showingResultsLabel,
|
|
410
|
+
showingResultsLabel = _ref$showingResultsLa === void 0 ? function (minPage, maxPage, pageCount) {
|
|
411
|
+
return "Viser resultat " + minPage + "\u2013" + maxPage + " av " + pageCount;
|
|
412
|
+
} : _ref$showingResultsLa,
|
|
413
|
+
_ref$changeNumberOfRe = _ref.changeNumberOfResultsLabelForScreenreader,
|
|
414
|
+
changeNumberOfResultsLabelForScreenreader = _ref$changeNumberOfRe === void 0 ? "Viser " + resultsPerPage + " resultater. Trykk for \xE5 endre antall. \xC5pner en flervalgsmeny." : _ref$changeNumberOfRe,
|
|
415
|
+
_ref$hideNextButton = _ref.hideNextButton,
|
|
416
|
+
hideNextButton = _ref$hideNextButton === void 0 ? false : _ref$hideNextButton,
|
|
417
|
+
_ref$hidePrevButton = _ref.hidePrevButton,
|
|
418
|
+
hidePrevButton = _ref$hidePrevButton === void 0 ? false : _ref$hidePrevButton,
|
|
419
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
420
|
+
var _useState = useState([]),
|
|
421
|
+
listedEntries = _useState[0],
|
|
422
|
+
setListedEntries = _useState[1];
|
|
423
|
+
var paginationId = useRandomId('eds-pagination');
|
|
424
|
+
var isFirstPostSelected = currentPage === 1;
|
|
425
|
+
var isLastPostSelected = currentPage === pageCount;
|
|
426
|
+
var noEllipsis = pageCount <= 7;
|
|
427
|
+
var onlyLeadingEllipsis = !noEllipsis && currentPage < 5;
|
|
428
|
+
var onlyTrailingEllipsis = !noEllipsis && pageCount - currentPage <= 3;
|
|
429
|
+
useEffect(function () {
|
|
381
430
|
if (pageCount < 1) return;
|
|
382
431
|
if (noEllipsis) {
|
|
383
|
-
setListedEntries(
|
|
384
|
-
|
|
385
|
-
);
|
|
432
|
+
setListedEntries(Array(pageCount).fill(null).map(function (_, i) {
|
|
433
|
+
return i + 1;
|
|
434
|
+
}));
|
|
386
435
|
} else if (onlyLeadingEllipsis) {
|
|
387
|
-
setListedEntries([1, 2, 3, 4, 5,
|
|
436
|
+
setListedEntries([1, 2, 3, 4, 5, '…', pageCount]);
|
|
388
437
|
} else if (onlyTrailingEllipsis) {
|
|
389
|
-
setListedEntries([
|
|
390
|
-
1,
|
|
391
|
-
"…",
|
|
392
|
-
pageCount - 4,
|
|
393
|
-
pageCount - 3,
|
|
394
|
-
pageCount - 2,
|
|
395
|
-
pageCount - 1,
|
|
396
|
-
pageCount
|
|
397
|
-
]);
|
|
438
|
+
setListedEntries([1, '…', pageCount - 4, pageCount - 3, pageCount - 2, pageCount - 1, pageCount]);
|
|
398
439
|
} else {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
"…",
|
|
402
|
-
currentPage - 1,
|
|
403
|
-
currentPage,
|
|
404
|
-
currentPage + 1,
|
|
405
|
-
"…",
|
|
406
|
-
pageCount
|
|
407
|
-
]);
|
|
440
|
+
// leading and trailing ellipsis
|
|
441
|
+
setListedEntries([1, '…', currentPage - 1, currentPage, currentPage + 1, '…', pageCount]);
|
|
408
442
|
}
|
|
409
|
-
}, [
|
|
410
|
-
noEllipsis,
|
|
411
|
-
onlyLeadingEllipsis,
|
|
412
|
-
onlyTrailingEllipsis,
|
|
413
|
-
currentPage,
|
|
414
|
-
pageCount
|
|
415
|
-
]);
|
|
443
|
+
}, [noEllipsis, onlyLeadingEllipsis, onlyTrailingEllipsis, currentPage, pageCount]);
|
|
416
444
|
if (pageCount < 1) {
|
|
417
445
|
return null;
|
|
418
446
|
}
|
|
419
|
-
return
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
entry
|
|
485
|
-
)
|
|
486
|
-
),
|
|
487
|
-
!hideNextButton && /* @__PURE__ */ jsx(
|
|
488
|
-
PaginationPage,
|
|
489
|
-
{
|
|
490
|
-
onClick: () => onPageChange(currentPage + 1),
|
|
491
|
-
"aria-label": nextPageLabel,
|
|
492
|
-
"aria-describedby": paginationId,
|
|
493
|
-
disabled: isLastPostSelected,
|
|
494
|
-
children: /* @__PURE__ */ jsx(RightArrowIcon, { "aria-hidden": "true" })
|
|
495
|
-
}
|
|
496
|
-
),
|
|
497
|
-
showInput && /* @__PURE__ */ jsx(
|
|
498
|
-
PaginationInput,
|
|
499
|
-
{
|
|
500
|
-
pageCount,
|
|
501
|
-
currentPage,
|
|
502
|
-
onPageChange,
|
|
503
|
-
label: inputLabel
|
|
504
|
-
}
|
|
505
|
-
)
|
|
506
|
-
] }),
|
|
507
|
-
/* @__PURE__ */ jsxs(VisuallyHidden, { id: paginationId, children: [
|
|
508
|
-
currentPageLabelForScreenreader,
|
|
509
|
-
" ",
|
|
510
|
-
currentPage
|
|
511
|
-
] })
|
|
512
|
-
]
|
|
513
|
-
}
|
|
514
|
-
);
|
|
447
|
+
return React.createElement("nav", _extends({
|
|
448
|
+
className: classNames('eds-pagination', className),
|
|
449
|
+
"aria-label": "Paginering"
|
|
450
|
+
}, rest), resultsPerPage && numberOfResults && React.createElement("div", {
|
|
451
|
+
className: "eds-pagination__results"
|
|
452
|
+
}, onResultsPerPageChange && React.createElement(React.Fragment, null, React.createElement(Label, {
|
|
453
|
+
as: "p",
|
|
454
|
+
"aria-hidden": "true"
|
|
455
|
+
}, showNumberOfResultsLabel), React.createElement(OverflowMenu, {
|
|
456
|
+
className: "eds-pagination__results__change-number-of-results",
|
|
457
|
+
buttonIcon: React.createElement(React.Fragment, null, resultsPerPage, ' ', React.createElement(DownArrowIcon, {
|
|
458
|
+
className: "eds-pagination__results__change-number-of-results__arrow",
|
|
459
|
+
"aria-hidden": "true"
|
|
460
|
+
})),
|
|
461
|
+
"aria-label": changeNumberOfResultsLabelForScreenreader,
|
|
462
|
+
placement: "bottom-end"
|
|
463
|
+
}, resultsPerPageOptions.map(function (option, key) {
|
|
464
|
+
return React.createElement(OverflowMenuItem, {
|
|
465
|
+
key: key,
|
|
466
|
+
onSelect: function onSelect() {
|
|
467
|
+
return onResultsPerPageChange(option);
|
|
468
|
+
}
|
|
469
|
+
}, option);
|
|
470
|
+
}))), React.createElement(Label, {
|
|
471
|
+
as: "p"
|
|
472
|
+
}, showingResultsLabel((currentPage - 1) * resultsPerPage + 1, currentPage * resultsPerPage > numberOfResults ? numberOfResults : currentPage * resultsPerPage, numberOfResults))), React.createElement("div", {
|
|
473
|
+
className: "eds-pagination__controls"
|
|
474
|
+
}, !hidePrevButton && React.createElement(PaginationPage, {
|
|
475
|
+
onClick: function onClick() {
|
|
476
|
+
return onPageChange(currentPage - 1);
|
|
477
|
+
},
|
|
478
|
+
"aria-label": previousPageLabel,
|
|
479
|
+
"aria-describedby": paginationId,
|
|
480
|
+
disabled: isFirstPostSelected
|
|
481
|
+
}, React.createElement(LeftArrowIcon, {
|
|
482
|
+
"aria-hidden": "true"
|
|
483
|
+
})), listedEntries.map(function (entry, index) {
|
|
484
|
+
return entry === '…' ? React.createElement(Ellipsis, {
|
|
485
|
+
key: "ellipsis-" + index
|
|
486
|
+
}) : React.createElement(PaginationPage, {
|
|
487
|
+
selected: entry === currentPage,
|
|
488
|
+
onClick: function onClick() {
|
|
489
|
+
return onPageChange(entry);
|
|
490
|
+
},
|
|
491
|
+
"aria-label": "" + pageLabel(entry) + (entry === pageCount ? lastPageLabelForScreenreader : ''),
|
|
492
|
+
"aria-describedby": entry !== currentPage ? paginationId : undefined,
|
|
493
|
+
key: entry
|
|
494
|
+
}, entry);
|
|
495
|
+
}), !hideNextButton && React.createElement(PaginationPage, {
|
|
496
|
+
onClick: function onClick() {
|
|
497
|
+
return onPageChange(currentPage + 1);
|
|
498
|
+
},
|
|
499
|
+
"aria-label": nextPageLabel,
|
|
500
|
+
"aria-describedby": paginationId,
|
|
501
|
+
disabled: isLastPostSelected
|
|
502
|
+
}, React.createElement(RightArrowIcon, {
|
|
503
|
+
"aria-hidden": "true"
|
|
504
|
+
})), showInput && React.createElement(PaginationInput, {
|
|
505
|
+
pageCount: pageCount,
|
|
506
|
+
currentPage: currentPage,
|
|
507
|
+
onPageChange: onPageChange,
|
|
508
|
+
label: inputLabel
|
|
509
|
+
})), React.createElement(VisuallyHidden, {
|
|
510
|
+
id: paginationId
|
|
511
|
+
}, currentPageLabelForScreenreader, " ", currentPage));
|
|
515
512
|
};
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
513
|
+
var Ellipsis = function Ellipsis() {
|
|
514
|
+
return React.createElement("span", {
|
|
515
|
+
className: "eds-pagination__controls__page__ellipsis",
|
|
516
|
+
"aria-hidden": "true"
|
|
517
|
+
}, "\u2026");
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
var _excluded$4 = ["className", "children", "size"];
|
|
521
|
+
var SideNavigation = function SideNavigation(_ref) {
|
|
522
|
+
var className = _ref.className,
|
|
523
|
+
children = _ref.children,
|
|
524
|
+
_ref$size = _ref.size,
|
|
525
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
526
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
523
527
|
if (!children || !React.Children.count(children)) {
|
|
524
528
|
return null;
|
|
525
529
|
}
|
|
526
|
-
return
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
{ "eds-side-navigation--small": size === "small" },
|
|
532
|
-
className
|
|
533
|
-
),
|
|
534
|
-
...rest,
|
|
535
|
-
children
|
|
536
|
-
}
|
|
537
|
-
);
|
|
530
|
+
return React.createElement("ul", _extends({
|
|
531
|
+
className: classNames('eds-side-navigation', {
|
|
532
|
+
'eds-side-navigation--small': size === 'small'
|
|
533
|
+
}, className)
|
|
534
|
+
}, rest), children);
|
|
538
535
|
};
|
|
536
|
+
/** This is required to check that the Menu */
|
|
539
537
|
SideNavigation.__IS_ENTUR_MENU__ = true;
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
538
|
+
|
|
539
|
+
var useShowDelayedLabel = function useShowDelayedLabel(isCollapsed) {
|
|
540
|
+
var _useState = useState(true),
|
|
541
|
+
showLabel = _useState[0],
|
|
542
|
+
setShowLabel = _useState[1];
|
|
543
|
+
var hideDelay = 50;
|
|
544
|
+
var showDelay = 200;
|
|
545
|
+
useEffect(function () {
|
|
545
546
|
if (isCollapsed) {
|
|
546
|
-
setTimeout(()
|
|
547
|
+
setTimeout(function () {
|
|
547
548
|
setShowLabel(false);
|
|
548
549
|
}, hideDelay);
|
|
549
550
|
}
|
|
550
551
|
if (!isCollapsed) {
|
|
551
|
-
setTimeout(()
|
|
552
|
+
setTimeout(function () {
|
|
552
553
|
setShowLabel(true);
|
|
553
554
|
}, showDelay);
|
|
554
555
|
}
|
|
555
|
-
return ()
|
|
556
|
+
return function () {
|
|
557
|
+
return undefined;
|
|
558
|
+
};
|
|
556
559
|
}, [isCollapsed]);
|
|
557
560
|
return [showLabel];
|
|
558
561
|
};
|
|
562
|
+
|
|
563
|
+
var _excluded$3 = ["className", "active", "subMenu", "icon", "children", "as"],
|
|
564
|
+
_excluded2 = ["children"],
|
|
565
|
+
_excluded3 = ["active", "disabled", "children", "forceExpandSubMenus", "as"];
|
|
559
566
|
function isActiveRecursively(child) {
|
|
560
567
|
if (!child.props) {
|
|
561
568
|
return false;
|
|
@@ -566,255 +573,205 @@ function isActiveRecursively(child) {
|
|
|
566
573
|
if (!child.props.children) {
|
|
567
574
|
return false;
|
|
568
575
|
}
|
|
569
|
-
return React.Children.toArray(child.props.children).some(
|
|
570
|
-
|
|
571
|
-
);
|
|
576
|
+
return React.Children.toArray(child.props.children).some(function (child) {
|
|
577
|
+
return isActiveRecursively(child);
|
|
578
|
+
});
|
|
572
579
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
active = false,
|
|
578
|
-
subMenu,
|
|
579
|
-
icon,
|
|
580
|
-
children,
|
|
581
|
-
as,
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
),
|
|
604
|
-
subMenu
|
|
605
|
-
] });
|
|
606
|
-
}
|
|
607
|
-
);
|
|
608
|
-
const DisabledSideNavigationItem = React.forwardRef(({ children, ...rest }, ref) => /* @__PURE__ */ jsx(
|
|
609
|
-
BaseSideNavigationItem,
|
|
610
|
-
{
|
|
580
|
+
var defaultElementBaseItem = 'a';
|
|
581
|
+
var BaseSideNavigationItem = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
582
|
+
var className = _ref.className,
|
|
583
|
+
_ref$active = _ref.active,
|
|
584
|
+
active = _ref$active === void 0 ? false : _ref$active,
|
|
585
|
+
subMenu = _ref.subMenu,
|
|
586
|
+
icon = _ref.icon,
|
|
587
|
+
children = _ref.children,
|
|
588
|
+
as = _ref.as,
|
|
589
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
590
|
+
var Element = as || defaultElementBaseItem;
|
|
591
|
+
var _useSideNavigationCon = useSideNavigationContext(),
|
|
592
|
+
isCollapsed = _useSideNavigationCon.isCollapsed;
|
|
593
|
+
var _useShowDelayedLabel = useShowDelayedLabel(isCollapsed),
|
|
594
|
+
showLabel = _useShowDelayedLabel[0];
|
|
595
|
+
return React.createElement("li", {
|
|
596
|
+
className: classNames('eds-side-navigation__item', className)
|
|
597
|
+
}, React.createElement(Element, _extends({
|
|
598
|
+
className: classNames('eds-side-navigation__click-target', {
|
|
599
|
+
'eds-side-navigation__click-target--active': active
|
|
600
|
+
}),
|
|
601
|
+
"aria-label": isCollapsed ? children : undefined,
|
|
602
|
+
"aria-current": active ? 'page' : undefined,
|
|
603
|
+
ref: ref
|
|
604
|
+
}, rest), icon, showLabel && children), subMenu);
|
|
605
|
+
});
|
|
606
|
+
var DisabledSideNavigationItem = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
607
|
+
var children = _ref2.children,
|
|
608
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
609
|
+
return React.createElement(BaseSideNavigationItem, _extends({
|
|
611
610
|
as: "button",
|
|
612
611
|
disabled: true,
|
|
613
612
|
"aria-disabled": true,
|
|
614
|
-
ref,
|
|
615
|
-
type: "button"
|
|
616
|
-
|
|
617
|
-
|
|
613
|
+
ref: ref,
|
|
614
|
+
type: "button"
|
|
615
|
+
}, rest), children);
|
|
616
|
+
});
|
|
617
|
+
var defaultElementItem = 'a';
|
|
618
|
+
var SideNavigationItem = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
619
|
+
var active = _ref3.active,
|
|
620
|
+
disabled = _ref3.disabled,
|
|
621
|
+
children = _ref3.children,
|
|
622
|
+
forceExpandSubMenus = _ref3.forceExpandSubMenus,
|
|
623
|
+
as = _ref3.as,
|
|
624
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
625
|
+
var Element = as || defaultElementItem;
|
|
626
|
+
var childrenArray = React.Children.toArray(children);
|
|
627
|
+
var subMenu = childrenArray.find(function (child) {
|
|
628
|
+
return child && child.type && child.type.__IS_ENTUR_MENU__;
|
|
629
|
+
});
|
|
630
|
+
var label = subMenu ? childrenArray.filter(function (child) {
|
|
631
|
+
return child !== subMenu;
|
|
632
|
+
}) : children;
|
|
633
|
+
if (disabled) {
|
|
634
|
+
return React.createElement(DisabledSideNavigationItem, _extends({
|
|
635
|
+
ref: ref
|
|
636
|
+
}, rest), label);
|
|
618
637
|
}
|
|
619
|
-
)
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
children,
|
|
626
|
-
forceExpandSubMenus,
|
|
627
|
-
as,
|
|
628
|
-
...rest
|
|
629
|
-
}, ref) => {
|
|
630
|
-
const Element = as || defaultElementItem;
|
|
631
|
-
const childrenArray = React.Children.toArray(children);
|
|
632
|
-
const subMenu = childrenArray.find(
|
|
633
|
-
(child) => child && child.type && child.type.__IS_ENTUR_MENU__
|
|
634
|
-
);
|
|
635
|
-
const label = subMenu ? childrenArray.filter((child) => child !== subMenu) : children;
|
|
636
|
-
if (disabled) {
|
|
637
|
-
return /* @__PURE__ */ jsx(DisabledSideNavigationItem, { ref, ...rest, children: label });
|
|
638
|
-
}
|
|
639
|
-
if (!subMenu) {
|
|
640
|
-
return /* @__PURE__ */ jsx(
|
|
641
|
-
BaseSideNavigationItem,
|
|
642
|
-
{
|
|
643
|
-
as: Element,
|
|
644
|
-
active,
|
|
645
|
-
ref,
|
|
646
|
-
...rest,
|
|
647
|
-
children: label
|
|
648
|
-
}
|
|
649
|
-
);
|
|
650
|
-
}
|
|
651
|
-
const isExpanded = forceExpandSubMenus || isActiveRecursively({ props: { children, active } });
|
|
652
|
-
return /* @__PURE__ */ jsx(
|
|
653
|
-
BaseSideNavigationItem,
|
|
654
|
-
{
|
|
655
|
-
active,
|
|
656
|
-
subMenu: isExpanded && subMenu,
|
|
657
|
-
"aria-expanded": isExpanded,
|
|
658
|
-
as: Element,
|
|
659
|
-
ref,
|
|
660
|
-
...rest,
|
|
661
|
-
children: label
|
|
662
|
-
}
|
|
663
|
-
);
|
|
638
|
+
if (!subMenu) {
|
|
639
|
+
return React.createElement(BaseSideNavigationItem, _extends({
|
|
640
|
+
as: Element,
|
|
641
|
+
active: active,
|
|
642
|
+
ref: ref
|
|
643
|
+
}, rest), label);
|
|
664
644
|
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
onToggle,
|
|
670
|
-
className,
|
|
671
|
-
children,
|
|
672
|
-
title,
|
|
673
|
-
icon,
|
|
674
|
-
...rest
|
|
675
|
-
}) => {
|
|
676
|
-
const [isOpen, setOpen] = useControllableProp({
|
|
677
|
-
prop: open,
|
|
678
|
-
updater: onToggle,
|
|
679
|
-
defaultValue: defaultOpen
|
|
680
|
-
});
|
|
681
|
-
const { isCollapsed } = useSideNavigationContext();
|
|
682
|
-
const [showLabel] = useShowDelayedLabel(isCollapsed);
|
|
683
|
-
return /* @__PURE__ */ jsxs(
|
|
684
|
-
"div",
|
|
685
|
-
{
|
|
686
|
-
className: classNames("eds-side-navigation-group", className),
|
|
687
|
-
...rest,
|
|
688
|
-
children: [
|
|
689
|
-
/* @__PURE__ */ jsxs(
|
|
690
|
-
"button",
|
|
691
|
-
{
|
|
692
|
-
onClick: () => setOpen(!isOpen),
|
|
693
|
-
type: "button",
|
|
694
|
-
className: "eds-side-navigation-group__trigger",
|
|
695
|
-
"aria-label": `${title}, utvidbar meny, ${isOpen ? "åpen" : "lukket"}`,
|
|
696
|
-
children: [
|
|
697
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
698
|
-
icon && /* @__PURE__ */ jsx("span", { className: "eds-side-navigation-group__trigger-icon", children: icon }),
|
|
699
|
-
showLabel && title
|
|
700
|
-
] }),
|
|
701
|
-
showLabel && /* @__PURE__ */ jsx(
|
|
702
|
-
ExpandArrow,
|
|
703
|
-
{
|
|
704
|
-
open: isOpen,
|
|
705
|
-
className: "eds-side-navigation-group__expand-icon"
|
|
706
|
-
}
|
|
707
|
-
)
|
|
708
|
-
]
|
|
709
|
-
}
|
|
710
|
-
),
|
|
711
|
-
/* @__PURE__ */ jsx(
|
|
712
|
-
BaseExpand,
|
|
713
|
-
{
|
|
714
|
-
className: "eds-side-navigation-group__expand-content",
|
|
715
|
-
open: isOpen,
|
|
716
|
-
children
|
|
717
|
-
}
|
|
718
|
-
)
|
|
719
|
-
]
|
|
645
|
+
var isExpanded = forceExpandSubMenus || isActiveRecursively({
|
|
646
|
+
props: {
|
|
647
|
+
children: children,
|
|
648
|
+
active: active
|
|
720
649
|
}
|
|
721
|
-
);
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
) }, step);
|
|
772
|
-
})
|
|
773
|
-
}
|
|
774
|
-
);
|
|
650
|
+
});
|
|
651
|
+
return React.createElement(BaseSideNavigationItem, _extends({
|
|
652
|
+
active: active,
|
|
653
|
+
subMenu: isExpanded && subMenu,
|
|
654
|
+
"aria-expanded": isExpanded,
|
|
655
|
+
as: Element,
|
|
656
|
+
ref: ref
|
|
657
|
+
}, rest), label);
|
|
658
|
+
});
|
|
659
|
+
|
|
660
|
+
var _excluded$2 = ["defaultOpen", "open", "onToggle", "className", "children", "title", "icon"];
|
|
661
|
+
var SideNavigationGroup = function SideNavigationGroup(_ref) {
|
|
662
|
+
var _ref$defaultOpen = _ref.defaultOpen,
|
|
663
|
+
defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen,
|
|
664
|
+
open = _ref.open,
|
|
665
|
+
onToggle = _ref.onToggle,
|
|
666
|
+
className = _ref.className,
|
|
667
|
+
children = _ref.children,
|
|
668
|
+
title = _ref.title,
|
|
669
|
+
icon = _ref.icon,
|
|
670
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
671
|
+
var _useControllableProp = useControllableProp({
|
|
672
|
+
prop: open,
|
|
673
|
+
updater: onToggle,
|
|
674
|
+
defaultValue: defaultOpen
|
|
675
|
+
}),
|
|
676
|
+
isOpen = _useControllableProp[0],
|
|
677
|
+
setOpen = _useControllableProp[1];
|
|
678
|
+
var _useSideNavigationCon = useSideNavigationContext(),
|
|
679
|
+
isCollapsed = _useSideNavigationCon.isCollapsed;
|
|
680
|
+
var _useShowDelayedLabel = useShowDelayedLabel(isCollapsed),
|
|
681
|
+
showLabel = _useShowDelayedLabel[0];
|
|
682
|
+
return React.createElement("div", _extends({
|
|
683
|
+
className: classNames('eds-side-navigation-group', className)
|
|
684
|
+
}, rest), React.createElement("button", {
|
|
685
|
+
onClick: function onClick() {
|
|
686
|
+
return setOpen(!isOpen);
|
|
687
|
+
},
|
|
688
|
+
type: "button",
|
|
689
|
+
className: "eds-side-navigation-group__trigger",
|
|
690
|
+
"aria-label": title + ", utvidbar meny, " + (isOpen ? 'åpen' : 'lukket')
|
|
691
|
+
}, React.createElement("span", null, icon && React.createElement("span", {
|
|
692
|
+
className: "eds-side-navigation-group__trigger-icon"
|
|
693
|
+
}, icon), showLabel && title), showLabel && React.createElement(ExpandArrow, {
|
|
694
|
+
open: isOpen,
|
|
695
|
+
className: "eds-side-navigation-group__expand-icon"
|
|
696
|
+
})), React.createElement(BaseExpand, {
|
|
697
|
+
className: "eds-side-navigation-group__expand-content",
|
|
698
|
+
open: isOpen
|
|
699
|
+
}, children));
|
|
775
700
|
};
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
701
|
+
|
|
702
|
+
var _excluded$1 = ["activeIndex", "className", "interactive", "onStepClick", "showStepperIndex", "steps", "ariaLabelStep", "ariaLabelOf", "ariaLabelCompleted", "ariaLabelSummary"];
|
|
703
|
+
var Stepper = function Stepper(_ref) {
|
|
704
|
+
var activeIndex = _ref.activeIndex,
|
|
705
|
+
className = _ref.className,
|
|
706
|
+
_ref$interactive = _ref.interactive,
|
|
707
|
+
interactive = _ref$interactive === void 0 ? false : _ref$interactive,
|
|
708
|
+
onStepClick = _ref.onStepClick,
|
|
709
|
+
_ref$showStepperIndex = _ref.showStepperIndex,
|
|
710
|
+
showStepperIndex = _ref$showStepperIndex === void 0 ? true : _ref$showStepperIndex,
|
|
711
|
+
steps = _ref.steps,
|
|
712
|
+
_ref$ariaLabelStep = _ref.ariaLabelStep,
|
|
713
|
+
ariaLabelStep = _ref$ariaLabelStep === void 0 ? 'Steg' : _ref$ariaLabelStep,
|
|
714
|
+
_ref$ariaLabelOf = _ref.ariaLabelOf,
|
|
715
|
+
ariaLabelOf = _ref$ariaLabelOf === void 0 ? 'av' : _ref$ariaLabelOf,
|
|
716
|
+
_ref$ariaLabelComplet = _ref.ariaLabelCompleted,
|
|
717
|
+
ariaLabelCompleted = _ref$ariaLabelComplet === void 0 ? 'fullført' : _ref$ariaLabelComplet,
|
|
718
|
+
_ref$ariaLabelSummary = _ref.ariaLabelSummary,
|
|
719
|
+
ariaLabelSummary = _ref$ariaLabelSummary === void 0 ? "Stegindikator med " + steps.length + " steg, du er p\xE5 steg " + (activeIndex + 1) + " " + steps[activeIndex] + "," : _ref$ariaLabelSummary,
|
|
720
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
721
|
+
return React.createElement("ol", _extends({
|
|
722
|
+
className: classNames('eds-stepper', className),
|
|
723
|
+
"aria-label": ariaLabelSummary
|
|
724
|
+
}, rest), steps.map(function (step, i) {
|
|
725
|
+
var isCurrent = i === activeIndex;
|
|
726
|
+
var isInteractive = interactive && activeIndex > i;
|
|
727
|
+
var Element = isInteractive ? 'button' : 'div';
|
|
728
|
+
var isCompleted = activeIndex > i;
|
|
729
|
+
var currentStepSummary = ariaLabelStep + " " + (i + 1) + " " + ariaLabelOf + " " + steps.length + ", " + step + " " + (isCompleted ? ", " + ariaLabelCompleted : '');
|
|
730
|
+
var props = isInteractive ? {
|
|
731
|
+
onClick: function onClick() {
|
|
732
|
+
return onStepClick == null ? void 0 : onStepClick(i);
|
|
733
|
+
}
|
|
734
|
+
} : {};
|
|
735
|
+
return React.createElement("li", {
|
|
736
|
+
key: step,
|
|
737
|
+
className: "eds-stepper__step__wrapper"
|
|
738
|
+
}, React.createElement(Element, _extends({
|
|
739
|
+
className: classNames('eds-stepper__step', {
|
|
740
|
+
'eds-stepper__step--active': isCurrent
|
|
741
|
+
}, {
|
|
742
|
+
'eds-stepper__step--completed': isCompleted
|
|
743
|
+
}, {
|
|
744
|
+
'eds-stepper__step--interactive': isInteractive
|
|
745
|
+
}),
|
|
746
|
+
"aria-current": isCurrent ? 'step' : undefined,
|
|
747
|
+
type: Element === 'button' ? 'button' : undefined
|
|
748
|
+
}, props), React.createElement("div", {
|
|
749
|
+
className: "eds-stepper__step__line",
|
|
750
|
+
"aria-hidden": true
|
|
751
|
+
}), React.createElement("span", {
|
|
752
|
+
className: "eds-stepper__step__label",
|
|
753
|
+
"aria-hidden": true
|
|
754
|
+
}, showStepperIndex && i + 1 + '.', " ", step), React.createElement(VisuallyHidden, null, currentStepSummary)));
|
|
755
|
+
}));
|
|
795
756
|
};
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
);
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
OverflowMenuLink,
|
|
812
|
-
Pagination,
|
|
813
|
-
SideNavigation,
|
|
814
|
-
SideNavigationGroup,
|
|
815
|
-
SideNavigationItem,
|
|
816
|
-
Stepper,
|
|
817
|
-
TopNavigationItem,
|
|
818
|
-
useSideNavigationContext
|
|
757
|
+
|
|
758
|
+
var _excluded = ["active", "className", "as"];
|
|
759
|
+
var defaultElement = 'a';
|
|
760
|
+
var TopNavigationItem = function TopNavigationItem(_ref) {
|
|
761
|
+
var _ref$active = _ref.active,
|
|
762
|
+
active = _ref$active === void 0 ? false : _ref$active,
|
|
763
|
+
className = _ref.className,
|
|
764
|
+
as = _ref.as,
|
|
765
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
766
|
+
var Element = as || defaultElement;
|
|
767
|
+
return React.createElement(Element, _extends({
|
|
768
|
+
className: classNames(['eds-top-navigation-item', className, {
|
|
769
|
+
'eds-top-navigation-item--active': active
|
|
770
|
+
}])
|
|
771
|
+
}, rest));
|
|
819
772
|
};
|
|
773
|
+
|
|
774
|
+
warnAboutMissingStyles('menu', 'expand', 'icons', 'typography', 'button', 'layout', 'a11y');
|
|
775
|
+
|
|
776
|
+
export { BreadcrumbItem, BreadcrumbNavigation, CollapsibleSideNavigation, OverflowMenu, OverflowMenuItem, OverflowMenuLink, Pagination, SideNavigation, SideNavigationGroup, SideNavigationItem, Stepper, TopNavigationItem, useSideNavigationContext };
|
|
820
777
|
//# sourceMappingURL=menu.esm.js.map
|