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