@navikt/ds-react 6.14.0 → 6.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/form/combobox/FilteredOptions/AddNewOption.d.ts +3 -0
- package/cjs/form/combobox/FilteredOptions/AddNewOption.js +41 -0
- package/cjs/form/combobox/FilteredOptions/AddNewOption.js.map +1 -0
- package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +13 -57
- package/cjs/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/FilteredOptionsItem.d.ts +6 -0
- package/cjs/form/combobox/FilteredOptions/FilteredOptionsItem.js +43 -0
- package/cjs/form/combobox/FilteredOptions/FilteredOptionsItem.js.map +1 -0
- package/cjs/form/combobox/FilteredOptions/LoadingMessage.d.ts +3 -0
- package/cjs/form/combobox/FilteredOptions/LoadingMessage.js +16 -0
- package/cjs/form/combobox/FilteredOptions/LoadingMessage.js.map +1 -0
- package/cjs/form/combobox/FilteredOptions/MaxSelectedMessage.d.ts +3 -0
- package/cjs/form/combobox/FilteredOptions/MaxSelectedMessage.js +20 -0
- package/cjs/form/combobox/FilteredOptions/MaxSelectedMessage.js.map +1 -0
- package/cjs/form/combobox/FilteredOptions/NoSearchHitsMessage.d.ts +3 -0
- package/cjs/form/combobox/FilteredOptions/NoSearchHitsMessage.js +14 -0
- package/cjs/form/combobox/FilteredOptions/NoSearchHitsMessage.js.map +1 -0
- package/cjs/form/combobox/Input/Input.d.ts +1 -0
- package/cjs/form/combobox/Input/Input.js +3 -2
- package/cjs/form/combobox/Input/Input.js.map +1 -1
- package/cjs/form/combobox/Input/InputController.js +1 -1
- package/cjs/form/combobox/Input/InputController.js.map +1 -1
- package/cjs/overlays/floating-menu/Menu.d.ts +106 -0
- package/cjs/overlays/floating-menu/Menu.js +593 -0
- package/cjs/overlays/floating-menu/Menu.js.map +1 -0
- package/cjs/overlays/floating-menu/parts/FocusScope.d.ts +22 -0
- package/cjs/overlays/floating-menu/parts/FocusScope.js +89 -0
- package/cjs/overlays/floating-menu/parts/FocusScope.js.map +1 -0
- package/cjs/overlays/floating-menu/parts/RovingFocus.d.ts +9 -0
- package/cjs/overlays/floating-menu/parts/RovingFocus.js +112 -0
- package/cjs/overlays/floating-menu/parts/RovingFocus.js.map +1 -0
- package/cjs/overlays/floating-menu/parts/SlottedDivElement.d.ts +7 -0
- package/cjs/overlays/floating-menu/parts/SlottedDivElement.js +46 -0
- package/cjs/overlays/floating-menu/parts/SlottedDivElement.js.map +1 -0
- package/cjs/util/composeEventHandlers.d.ts +1 -1
- package/esm/form/combobox/FilteredOptions/AddNewOption.d.ts +3 -0
- package/esm/form/combobox/FilteredOptions/AddNewOption.js +36 -0
- package/esm/form/combobox/FilteredOptions/AddNewOption.js.map +1 -0
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js +13 -57
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/FilteredOptionsItem.d.ts +6 -0
- package/esm/form/combobox/FilteredOptions/FilteredOptionsItem.js +38 -0
- package/esm/form/combobox/FilteredOptions/FilteredOptionsItem.js.map +1 -0
- package/esm/form/combobox/FilteredOptions/LoadingMessage.d.ts +3 -0
- package/esm/form/combobox/FilteredOptions/LoadingMessage.js +11 -0
- package/esm/form/combobox/FilteredOptions/LoadingMessage.js.map +1 -0
- package/esm/form/combobox/FilteredOptions/MaxSelectedMessage.d.ts +3 -0
- package/esm/form/combobox/FilteredOptions/MaxSelectedMessage.js +15 -0
- package/esm/form/combobox/FilteredOptions/MaxSelectedMessage.js.map +1 -0
- package/esm/form/combobox/FilteredOptions/NoSearchHitsMessage.d.ts +3 -0
- package/esm/form/combobox/FilteredOptions/NoSearchHitsMessage.js +9 -0
- package/esm/form/combobox/FilteredOptions/NoSearchHitsMessage.js.map +1 -0
- package/esm/form/combobox/Input/Input.d.ts +1 -0
- package/esm/form/combobox/Input/Input.js +3 -2
- package/esm/form/combobox/Input/Input.js.map +1 -1
- package/esm/form/combobox/Input/InputController.js +1 -1
- package/esm/form/combobox/Input/InputController.js.map +1 -1
- package/esm/overlays/floating-menu/Menu.d.ts +106 -0
- package/esm/overlays/floating-menu/Menu.js +551 -0
- package/esm/overlays/floating-menu/Menu.js.map +1 -0
- package/esm/overlays/floating-menu/parts/FocusScope.d.ts +22 -0
- package/esm/overlays/floating-menu/parts/FocusScope.js +63 -0
- package/esm/overlays/floating-menu/parts/FocusScope.js.map +1 -0
- package/esm/overlays/floating-menu/parts/RovingFocus.d.ts +9 -0
- package/esm/overlays/floating-menu/parts/RovingFocus.js +86 -0
- package/esm/overlays/floating-menu/parts/RovingFocus.js.map +1 -0
- package/esm/overlays/floating-menu/parts/SlottedDivElement.d.ts +7 -0
- package/esm/overlays/floating-menu/parts/SlottedDivElement.js +20 -0
- package/esm/overlays/floating-menu/parts/SlottedDivElement.js.map +1 -0
- package/esm/util/composeEventHandlers.d.ts +1 -1
- package/package.json +3 -3
- package/src/form/combobox/FilteredOptions/AddNewOption.tsx +63 -0
- package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +11 -121
- package/src/form/combobox/FilteredOptions/FilteredOptionsItem.tsx +73 -0
- package/src/form/combobox/FilteredOptions/LoadingMessage.tsx +20 -0
- package/src/form/combobox/FilteredOptions/MaxSelectedMessage.tsx +27 -0
- package/src/form/combobox/FilteredOptions/NoSearchHitsMessage.tsx +19 -0
- package/src/form/combobox/Input/Input.tsx +4 -2
- package/src/form/combobox/Input/InputController.tsx +1 -0
- package/src/overlays/floating-menu/Menu.tsx +1177 -0
- package/src/overlays/floating-menu/parts/FocusScope.tsx +84 -0
- package/src/overlays/floating-menu/parts/RovingFocus.tsx +121 -0
- package/src/overlays/floating-menu/parts/SlottedDivElement.tsx +17 -0
- package/src/util/composeEventHandlers.ts +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
interface FocusScopeProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/**
|
|
4
|
+
* Event handler called on mount, unless the component already has focus. Used for auto-focusing.
|
|
5
|
+
* Can be prevented.
|
|
6
|
+
*/
|
|
7
|
+
onMountHandler?: (event: Event) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Event handler called on unmount. Used for auto-focusing.
|
|
10
|
+
* Can be prevented.
|
|
11
|
+
*/
|
|
12
|
+
onUnmountHandler?: (event: Event) => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* FocusScope manages focus on mount and unmount of container.
|
|
16
|
+
* This is used to better handle autofocus of elements when mounted and unmounted.
|
|
17
|
+
* Example usage:
|
|
18
|
+
* - Focus first item in a list when mounted
|
|
19
|
+
* - Focus a button when unmounted
|
|
20
|
+
*/
|
|
21
|
+
declare const FocusScope: React.ForwardRefExoticComponent<FocusScopeProps & React.RefAttributes<HTMLDivElement>>;
|
|
22
|
+
export { FocusScope, type FocusScopeProps };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.FocusScope = void 0;
|
|
38
|
+
const React = __importStar(require("react"));
|
|
39
|
+
const react_1 = require("react");
|
|
40
|
+
const Slot_1 = require("../../../slot/Slot");
|
|
41
|
+
const hooks_1 = require("../../../util/hooks");
|
|
42
|
+
const AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount";
|
|
43
|
+
const AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount";
|
|
44
|
+
const EVENT_OPTIONS = { bubbles: false, cancelable: true };
|
|
45
|
+
/**
|
|
46
|
+
* FocusScope manages focus on mount and unmount of container.
|
|
47
|
+
* This is used to better handle autofocus of elements when mounted and unmounted.
|
|
48
|
+
* Example usage:
|
|
49
|
+
* - Focus first item in a list when mounted
|
|
50
|
+
* - Focus a button when unmounted
|
|
51
|
+
*/
|
|
52
|
+
const FocusScope = (0, react_1.forwardRef)((_a, ref) => {
|
|
53
|
+
var { onMountHandler: onMountHandlerCallback, onUnmountHandler: onUnmountHandlerCallback } = _a, rest = __rest(_a, ["onMountHandler", "onUnmountHandler"]);
|
|
54
|
+
const [container, setContainer] = (0, react_1.useState)(null);
|
|
55
|
+
const onMountHandler = (0, hooks_1.useCallbackRef)(onMountHandlerCallback);
|
|
56
|
+
const onUnmountHandler = (0, hooks_1.useCallbackRef)(onUnmountHandlerCallback);
|
|
57
|
+
const composedRefs = (0, hooks_1.useMergeRefs)(ref, setContainer);
|
|
58
|
+
(0, react_1.useEffect)(() => {
|
|
59
|
+
var _a;
|
|
60
|
+
if (!container)
|
|
61
|
+
return;
|
|
62
|
+
const ownerDocument = (_a = container.ownerDocument) !== null && _a !== void 0 ? _a : globalThis === null || globalThis === void 0 ? void 0 : globalThis.document;
|
|
63
|
+
const hasFocus = container.contains(ownerDocument.activeElement);
|
|
64
|
+
if (!hasFocus) {
|
|
65
|
+
const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
|
|
66
|
+
container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountHandler);
|
|
67
|
+
container.dispatchEvent(mountEvent);
|
|
68
|
+
}
|
|
69
|
+
return () => {
|
|
70
|
+
container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountHandler);
|
|
71
|
+
/**
|
|
72
|
+
* https://github.com/facebook/react/issues/17894
|
|
73
|
+
* As usual when dealing with focus and useEffect,
|
|
74
|
+
* we need to defer the focus to the next event-loop
|
|
75
|
+
* setTimeout makes sure the code is ran after the next render-cycle
|
|
76
|
+
*/
|
|
77
|
+
setTimeout(() => {
|
|
78
|
+
const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
|
|
79
|
+
container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountHandler);
|
|
80
|
+
container.dispatchEvent(unmountEvent);
|
|
81
|
+
// we need to remove the listener after we `dispatchEvent`
|
|
82
|
+
container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountHandler);
|
|
83
|
+
}, 0);
|
|
84
|
+
};
|
|
85
|
+
}, [container, onMountHandler, onUnmountHandler]);
|
|
86
|
+
return React.createElement(Slot_1.Slot, Object.assign({ tabIndex: -1 }, rest, { ref: composedRefs }));
|
|
87
|
+
});
|
|
88
|
+
exports.FocusScope = FocusScope;
|
|
89
|
+
//# sourceMappingURL=FocusScope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FocusScope.js","sourceRoot":"","sources":["../../../../src/overlays/floating-menu/parts/FocusScope.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAC/B,iCAAwD;AACxD,6CAA0C;AAC1C,+CAAmE;AAEnE,MAAM,kBAAkB,GAAG,6BAA6B,CAAC;AACzD,MAAM,oBAAoB,GAAG,+BAA+B,CAAC;AAC7D,MAAM,aAAa,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;AAe3D;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,IAAA,kBAAU,EAC3B,CACE,EAIC,EACD,GAAG,EACH,EAAE;QANF,EACE,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,EAAE,wBAAwB,OAE3C,EADI,IAAI,cAHT,sCAIC,CADQ;IAIT,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAqB,IAAI,CAAC,CAAC;IACrE,MAAM,cAAc,GAAG,IAAA,sBAAc,EAAC,sBAAsB,CAAC,CAAC;IAC9D,MAAM,gBAAgB,GAAG,IAAA,sBAAc,EAAC,wBAAwB,CAAC,CAAC;IAElE,MAAM,YAAY,GAAG,IAAA,oBAAY,EAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAErD,IAAA,iBAAS,EAAC,GAAG,EAAE;;QACb,IAAI,CAAC,SAAS;YAAE,OAAO;QAEvB,MAAM,aAAa,GAAG,MAAA,SAAS,CAAC,aAAa,mCAAI,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,CAAC;QACtE,MAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAEjE,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,UAAU,GAAG,IAAI,WAAW,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;YACtE,SAAS,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC;YAC/D,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QACtC,CAAC;QAED,OAAO,GAAG,EAAE;YACV,SAAS,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC;YAElE;;;;;eAKG;YACH,UAAU,CAAC,GAAG,EAAE;gBACd,MAAM,YAAY,GAAG,IAAI,WAAW,CAClC,oBAAoB,EACpB,aAAa,CACd,CAAC;gBACF,SAAS,CAAC,gBAAgB,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC;gBACnE,SAAS,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;gBAEtC,0DAA0D;gBAC1D,SAAS,CAAC,mBAAmB,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC;YACxE,CAAC,EAAE,CAAC,CAAC,CAAC;QACR,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,SAAS,EAAE,cAAc,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAElD,OAAO,oBAAC,WAAI,kBAAC,QAAQ,EAAE,CAAC,CAAC,IAAM,IAAI,IAAE,GAAG,EAAE,YAAY,IAAI,CAAC;AAC7D,CAAC,CACF,CAAC;AAEO,gCAAU"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DescendantsManager } from "../../../util/hooks/descendants/descendant";
|
|
3
|
+
interface RovingFocusProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "tabIndex"> {
|
|
4
|
+
asChild?: boolean;
|
|
5
|
+
descendants: DescendantsManager<HTMLDivElement, object>;
|
|
6
|
+
onEntryFocus?: (event: Event) => void;
|
|
7
|
+
}
|
|
8
|
+
declare const RovingFocus: React.ForwardRefExoticComponent<RovingFocusProps & React.RefAttributes<HTMLDivElement>>;
|
|
9
|
+
export { RovingFocus, type RovingFocusProps };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.RovingFocus = void 0;
|
|
38
|
+
const react_1 = __importStar(require("react"));
|
|
39
|
+
const Slot_1 = require("../../../slot/Slot");
|
|
40
|
+
const composeEventHandlers_1 = require("../../../util/composeEventHandlers");
|
|
41
|
+
const hooks_1 = require("../../../util/hooks");
|
|
42
|
+
const ENTRY_FOCUS = "rovingFocusGroup.onEntryFocus";
|
|
43
|
+
const EVENT_OPTIONS = { bubbles: false, cancelable: true };
|
|
44
|
+
const RovingFocus = (0, react_1.forwardRef)((_a, ref) => {
|
|
45
|
+
var { children, asChild, descendants, onKeyDown, onEntryFocus, onMouseDown, onFocus } = _a, rest = __rest(_a, ["children", "asChild", "descendants", "onKeyDown", "onEntryFocus", "onMouseDown", "onFocus"]);
|
|
46
|
+
const _ref = react_1.default.useRef(null);
|
|
47
|
+
const composedRefs = (0, hooks_1.useMergeRefs)(ref, _ref);
|
|
48
|
+
const handleEntryFocus = (0, hooks_1.useCallbackRef)(onEntryFocus);
|
|
49
|
+
const isMouseFocusRef = (0, react_1.useRef)(false);
|
|
50
|
+
(0, react_1.useEffect)(() => {
|
|
51
|
+
const node = _ref.current;
|
|
52
|
+
if (node) {
|
|
53
|
+
node.addEventListener(ENTRY_FOCUS, handleEntryFocus);
|
|
54
|
+
return () => node.removeEventListener(ENTRY_FOCUS, handleEntryFocus);
|
|
55
|
+
}
|
|
56
|
+
}, [handleEntryFocus]);
|
|
57
|
+
const handleKeyDown = (0, react_1.useCallback)((event) => {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
const loop = false;
|
|
60
|
+
const ownerDocument = (_b = (_a = _ref === null || _ref === void 0 ? void 0 : _ref.current) === null || _a === void 0 ? void 0 : _a.ownerDocument) !== null && _b !== void 0 ? _b : globalThis === null || globalThis === void 0 ? void 0 : globalThis.document;
|
|
61
|
+
const idx = descendants
|
|
62
|
+
.values()
|
|
63
|
+
.findIndex((x) => x.node.isSameNode(ownerDocument.activeElement));
|
|
64
|
+
const nextItem = () => {
|
|
65
|
+
var _a;
|
|
66
|
+
const next = descendants.nextEnabled(idx, loop);
|
|
67
|
+
next && ((_a = next.node) === null || _a === void 0 ? void 0 : _a.focus());
|
|
68
|
+
};
|
|
69
|
+
const prevItem = () => {
|
|
70
|
+
var _a;
|
|
71
|
+
const prev = descendants.prevEnabled(idx, loop);
|
|
72
|
+
prev && ((_a = prev.node) === null || _a === void 0 ? void 0 : _a.focus());
|
|
73
|
+
};
|
|
74
|
+
const firstItem = () => {
|
|
75
|
+
var _a;
|
|
76
|
+
const first = descendants.firstEnabled();
|
|
77
|
+
first && ((_a = first.node) === null || _a === void 0 ? void 0 : _a.focus());
|
|
78
|
+
};
|
|
79
|
+
const lastItem = () => {
|
|
80
|
+
var _a;
|
|
81
|
+
const last = descendants.lastEnabled();
|
|
82
|
+
last && ((_a = last.node) === null || _a === void 0 ? void 0 : _a.focus());
|
|
83
|
+
};
|
|
84
|
+
const keyMap = {
|
|
85
|
+
ArrowUp: prevItem,
|
|
86
|
+
ArrowDown: nextItem,
|
|
87
|
+
Home: firstItem,
|
|
88
|
+
End: lastItem,
|
|
89
|
+
};
|
|
90
|
+
const action = keyMap[event.key];
|
|
91
|
+
if (action) {
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
action(event);
|
|
94
|
+
}
|
|
95
|
+
}, [descendants]);
|
|
96
|
+
const Comp = asChild ? Slot_1.Slot : "div";
|
|
97
|
+
return (react_1.default.createElement(Comp, Object.assign({ ref: composedRefs }, rest, { tabIndex: descendants.enabledCount() === 0 ? -1 : 0, style: Object.assign({ outline: "none" }, rest.style), onKeyDown: (0, composeEventHandlers_1.composeEventHandlers)(onKeyDown, handleKeyDown), onMouseDown: (0, composeEventHandlers_1.composeEventHandlers)(onMouseDown, () => {
|
|
98
|
+
isMouseFocusRef.current = true;
|
|
99
|
+
}), onFocus: (0, composeEventHandlers_1.composeEventHandlers)(onFocus, (event) => {
|
|
100
|
+
var _a;
|
|
101
|
+
if (event.target === event.currentTarget) {
|
|
102
|
+
const entryFocusEvent = new CustomEvent(ENTRY_FOCUS, EVENT_OPTIONS);
|
|
103
|
+
event.currentTarget.dispatchEvent(entryFocusEvent);
|
|
104
|
+
if (!entryFocusEvent.defaultPrevented) {
|
|
105
|
+
(_a = descendants.firstEnabled()) === null || _a === void 0 ? void 0 : _a.node.focus({ preventScroll: true });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
isMouseFocusRef.current = false;
|
|
109
|
+
}) }), children));
|
|
110
|
+
});
|
|
111
|
+
exports.RovingFocus = RovingFocus;
|
|
112
|
+
//# sourceMappingURL=RovingFocus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RovingFocus.js","sourceRoot":"","sources":["../../../../src/overlays/floating-menu/parts/RovingFocus.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA0E;AAC1E,6CAA0C;AAC1C,6EAA0E;AAC1E,+CAAmE;AAUnE,MAAM,WAAW,GAAG,+BAA+B,CAAC;AACpD,MAAM,aAAa,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;AAE3D,MAAM,WAAW,GAAG,IAAA,kBAAU,EAC5B,CACE,EASmB,EACnB,GAAG,EACH,EAAE;QAXF,EACE,QAAQ,EACR,OAAO,EACP,WAAW,EACX,SAAS,EACT,YAAY,EACZ,WAAW,EACX,OAAO,OAEU,EADd,IAAI,cART,6FASC,CADQ;IAIT,MAAM,IAAI,GAAG,eAA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K,GACvC,SAAS,EAAE,IAAA,2CAAoB,EAAC,SAAS,EAAE,aAAa,CAAC,EACzD,WAAW,EAAE,IAAA,2CAAoB,EAAC,WAAW,EAAE,GAAG,EAAE;YAClD,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC;QACjC,CAAC,CAAC,EACF,OAAO,EAAE,IAAA,2CAAoB,EAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;;YAC/C,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,aAAa,EAAE,CAAC;gBACzC,MAAM,eAAe,GAAG,IAAI,WAAW,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;gBACpE,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;gBAEnD,IAAI,CAAC,eAAe,CAAC,gBAAgB,EAAE,CAAC;oBACtC,MAAA,WAAW,CAAC,YAAY,EAAE,0CAAE,IAAI,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;gBAClE,CAAC;YACH,CAAC;YAED,eAAe,CAAC,OAAO,GAAG,KAAK,CAAC;QAClC,CAAC,CAAC,KAED,QAAQ,CACJ,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEO,kCAAW"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface SlottedDivProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
asChild?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare const SlottedDivElement: React.ForwardRefExoticComponent<SlottedDivProps & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
type SlottedDivElementRef = React.ElementRef<typeof SlottedDivElement>;
|
|
7
|
+
export { SlottedDivElement, type SlottedDivElementRef, type SlottedDivProps };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.SlottedDivElement = void 0;
|
|
38
|
+
const react_1 = __importStar(require("react"));
|
|
39
|
+
const Slot_1 = require("../../../slot/Slot");
|
|
40
|
+
const SlottedDivElement = (0, react_1.forwardRef)((_a, forwardedRef) => {
|
|
41
|
+
var { asChild } = _a, rest = __rest(_a, ["asChild"]);
|
|
42
|
+
const Comp = asChild ? Slot_1.Slot : "div";
|
|
43
|
+
return react_1.default.createElement(Comp, Object.assign({}, rest, { ref: forwardedRef }));
|
|
44
|
+
});
|
|
45
|
+
exports.SlottedDivElement = SlottedDivElement;
|
|
46
|
+
//# sourceMappingURL=SlottedDivElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlottedDivElement.js","sourceRoot":"","sources":["../../../../src/overlays/floating-menu/parts/SlottedDivElement.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA0C;AAC1C,6CAA0C;AAM1C,MAAM,iBAAiB,GAAG,IAAA,kBAAU,EAClC,CAAC,EAAoB,EAAE,YAAY,EAAE,EAAE;QAAtC,EAAE,OAAO,OAAW,EAAN,IAAI,cAAlB,WAAoB,CAAF;IACjB,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,WAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACpC,OAAO,8BAAC,IAAI,oBAAK,IAAI,IAAE,GAAG,EAAE,YAAY,IAAI,CAAC;AAC/C,CAAC,CACF,CAAC;AAIO,8CAAiB"}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Utility to consistently call original eventhandler, often from props and internal eventhandler
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export declare function composeEventHandlers<T extends React.SyntheticEvent>(originalEventHandler?: (event: T) => void, ourEventHandler?: (event: T) => void, { checkForDefaultPrevented }?: {
|
|
5
|
+
export declare function composeEventHandlers<T extends React.SyntheticEvent | Event>(originalEventHandler?: (event: T) => void, ourEventHandler?: (event: T) => void, { checkForDefaultPrevented }?: {
|
|
6
6
|
checkForDefaultPrevented?: boolean | undefined;
|
|
7
7
|
}): (event: T) => void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import cl from "clsx";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { PlusIcon } from "@navikt/aksel-icons";
|
|
4
|
+
import { BodyShort, Label } from "../../../typography/index.js";
|
|
5
|
+
import { useInputContext } from "../Input/Input.context.js";
|
|
6
|
+
import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext.js";
|
|
7
|
+
import { isInList, toComboboxOption } from "../combobox-utils.js";
|
|
8
|
+
import filteredOptionsUtil from "./filtered-options-util.js";
|
|
9
|
+
import { useFilteredOptionsContext } from "./filteredOptionsContext.js";
|
|
10
|
+
const AddNewOption = () => {
|
|
11
|
+
const { inputProps: { id }, size, value, } = useInputContext();
|
|
12
|
+
const { setIsMouseLastUsedInputDevice, toggleIsListOpen, activeDecendantId, virtualFocus, } = useFilteredOptionsContext();
|
|
13
|
+
const { isMultiSelect, selectedOptions, toggleOption } = useSelectedOptionsContext();
|
|
14
|
+
return (React.createElement("li", { tabIndex: -1, onMouseMove: () => {
|
|
15
|
+
if (activeDecendantId !== filteredOptionsUtil.getAddNewOptionId(id)) {
|
|
16
|
+
virtualFocus.moveFocusToElement(filteredOptionsUtil.getAddNewOptionId(id));
|
|
17
|
+
setIsMouseLastUsedInputDevice(true);
|
|
18
|
+
}
|
|
19
|
+
}, onPointerUp: (event) => {
|
|
20
|
+
toggleOption(toComboboxOption(value), event);
|
|
21
|
+
if (!isMultiSelect && !isInList(value, selectedOptions))
|
|
22
|
+
toggleIsListOpen(false);
|
|
23
|
+
}, id: filteredOptionsUtil.getAddNewOptionId(id), className: cl("navds-combobox__list-item navds-combobox__list-item--new-option", {
|
|
24
|
+
"navds-combobox__list-item--new-option--focus": activeDecendantId === filteredOptionsUtil.getAddNewOptionId(id),
|
|
25
|
+
}), role: "option", "aria-selected": false },
|
|
26
|
+
React.createElement(PlusIcon, { "aria-hidden": true }),
|
|
27
|
+
React.createElement(BodyShort, { size: size },
|
|
28
|
+
"Legg til",
|
|
29
|
+
" ",
|
|
30
|
+
React.createElement(Label, { as: "span", size: size },
|
|
31
|
+
"\u201C",
|
|
32
|
+
value,
|
|
33
|
+
"\u201D"))));
|
|
34
|
+
};
|
|
35
|
+
export default AddNewOption;
|
|
36
|
+
//# sourceMappingURL=AddNewOption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AddNewOption.js","sourceRoot":"","sources":["../../../../src/form/combobox/FilteredOptions/AddNewOption.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,mBAAmB,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE,MAAM,YAAY,GAAG,GAAG,EAAE;IACxB,MAAM,EACJ,UAAU,EAAE,EAAE,EAAE,EAAE,EAClB,IAAI,EACJ,KAAK,GACN,GAAG,eAAe,EAAE,CAAC;IACtB,MAAM,EACJ,6BAA6B,EAC7B,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,GACb,GAAG,yBAAyB,EAAE,CAAC;IAChC,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,GACpD,yBAAyB,EAAE,CAAC;IAC9B,OAAO,CACL,4BACE,QAAQ,EAAE,CAAC,CAAC,EACZ,WAAW,EAAE,GAAG,EAAE;YAChB,IAAI,iBAAiB,KAAK,mBAAmB,CAAC,iBAAiB,CAAC,EAAE,CAAC,EAAE,CAAC;gBACpE,YAAY,CAAC,kBAAkB,CAC7B,mBAAmB,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAC1C,CAAC;gBACF,6BAA6B,CAAC,IAAI,CAAC,CAAC;YACtC,CAAC;QACH,CAAC,EACD,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;YACrB,YAAY,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;YAC7C,IAAI,CAAC,aAAa,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;gBACrD,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC,EACD,EAAE,EAAE,mBAAmB,CAAC,iBAAiB,CAAC,EAAE,CAAC,EAC7C,SAAS,EAAE,EAAE,CACX,iEAAiE,EACjE;YACE,8CAA8C,EAC5C,iBAAiB,KAAK,mBAAmB,CAAC,iBAAiB,CAAC,EAAE,CAAC;SAClE,CACF,EACD,IAAI,EAAC,QAAQ,mBACE,KAAK;QAEpB,oBAAC,QAAQ,0BAAe;QACxB,oBAAC,SAAS,IAAC,IAAI,EAAE,IAAI;;YACV,GAAG;YACZ,oBAAC,KAAK,IAAC,EAAE,EAAC,MAAM,EAAC,IAAI,EAAE,IAAI;;gBACjB,KAAK;yBACP,CACE,CACT,CACN,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { CheckmarkIcon, PlusIcon } from "@navikt/aksel-icons";
|
|
4
|
-
import { Loader } from "../../../loader/index.js";
|
|
5
|
-
import { BodyShort, Label } from "../../../typography/index.js";
|
|
6
3
|
import { useInputContext } from "../Input/Input.context.js";
|
|
7
4
|
import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext.js";
|
|
8
|
-
import
|
|
5
|
+
import AddNewOption from "./AddNewOption.js";
|
|
6
|
+
import FilteredOptionsItem from "./FilteredOptionsItem.js";
|
|
7
|
+
import LoadingMessage from "./LoadingMessage.js";
|
|
8
|
+
import MaxSelectedMessage from "./MaxSelectedMessage.js";
|
|
9
|
+
import NoSearchHitsMessage from "./NoSearchHitsMessage.js";
|
|
9
10
|
import filteredOptionsUtil from "./filtered-options-util.js";
|
|
10
11
|
import { useFilteredOptionsContext } from "./filteredOptionsContext.js";
|
|
11
12
|
const FilteredOptions = () => {
|
|
12
|
-
|
|
13
|
-
const {
|
|
14
|
-
const {
|
|
15
|
-
const { isMultiSelect, selectedOptions, toggleOption, maxSelected } = useSelectedOptionsContext();
|
|
16
|
-
const isDisabled = (option) => (maxSelected === null || maxSelected === void 0 ? void 0 : maxSelected.isLimitReached) && !isInList(option.value, selectedOptions);
|
|
13
|
+
const { inputProps: { id }, } = useInputContext();
|
|
14
|
+
const { allowNewValues, isLoading, isListOpen, filteredOptions, setFilteredOptionsRef, isMouseLastUsedInputDevice, isValueNew, } = useFilteredOptionsContext();
|
|
15
|
+
const { maxSelected } = useSelectedOptionsContext();
|
|
17
16
|
const shouldRenderNonSelectables = (maxSelected === null || maxSelected === void 0 ? void 0 : maxSelected.isLimitReached) || // Render maxSelected message
|
|
18
17
|
isLoading || // Render loading message
|
|
19
18
|
(!isLoading && filteredOptions.length === 0 && !allowNewValues); // Render no hits message
|
|
@@ -24,55 +23,12 @@ const FilteredOptions = () => {
|
|
|
24
23
|
"navds-combobox__list--with-hover": isMouseLastUsedInputDevice,
|
|
25
24
|
}), id: filteredOptionsUtil.getFilteredOptionsId(id), tabIndex: -1 },
|
|
26
25
|
shouldRenderNonSelectables && (React.createElement("div", { className: "navds-combobox__list_non-selectables", role: "status" },
|
|
27
|
-
(maxSelected === null || maxSelected === void 0 ? void 0 : maxSelected.isLimitReached) &&
|
|
28
|
-
isLoading &&
|
|
29
|
-
|
|
30
|
-
!isLoading && filteredOptions.length === 0 && !allowNewValues && (React.createElement("div", { className: "navds-combobox__list-item--no-options", id: filteredOptionsUtil.getNoHitsId(id) }, "Ingen s\u00F8ketreff")))),
|
|
26
|
+
(maxSelected === null || maxSelected === void 0 ? void 0 : maxSelected.isLimitReached) && React.createElement(MaxSelectedMessage, null),
|
|
27
|
+
isLoading && React.createElement(LoadingMessage, null),
|
|
28
|
+
!isLoading && filteredOptions.length === 0 && !allowNewValues && (React.createElement(NoSearchHitsMessage, null)))),
|
|
31
29
|
shouldRenderFilteredOptionsList && (React.createElement("ul", { ref: setFilteredOptionsRef, role: "listbox", className: "navds-combobox__list-options" },
|
|
32
|
-
isValueNew && !(maxSelected === null || maxSelected === void 0 ? void 0 : maxSelected.isLimitReached) && allowNewValues && (React.createElement(
|
|
33
|
-
|
|
34
|
-
filteredOptionsUtil.getAddNewOptionId(id)) {
|
|
35
|
-
virtualFocus.moveFocusToElement(filteredOptionsUtil.getAddNewOptionId(id));
|
|
36
|
-
setIsMouseLastUsedInputDevice(true);
|
|
37
|
-
}
|
|
38
|
-
}, onPointerUp: (event) => {
|
|
39
|
-
toggleOption(toComboboxOption(value), event);
|
|
40
|
-
if (!isMultiSelect && !isInList(value, selectedOptions))
|
|
41
|
-
toggleIsListOpen(false);
|
|
42
|
-
}, id: filteredOptionsUtil.getAddNewOptionId(id), className: cl("navds-combobox__list-item navds-combobox__list-item--new-option", {
|
|
43
|
-
"navds-combobox__list-item--new-option--focus": activeDecendantId ===
|
|
44
|
-
filteredOptionsUtil.getAddNewOptionId(id),
|
|
45
|
-
}), role: "option", "aria-selected": false },
|
|
46
|
-
React.createElement(PlusIcon, { "aria-hidden": true }),
|
|
47
|
-
React.createElement(BodyShort, { size: size },
|
|
48
|
-
"Legg til",
|
|
49
|
-
" ",
|
|
50
|
-
React.createElement(Label, { as: "span", size: size },
|
|
51
|
-
"\u201C",
|
|
52
|
-
value,
|
|
53
|
-
"\u201D")))),
|
|
54
|
-
filteredOptions.map((option) => (React.createElement("li", { className: cl("navds-combobox__list-item", {
|
|
55
|
-
"navds-combobox__list-item--focus": activeDecendantId ===
|
|
56
|
-
filteredOptionsUtil.getOptionId(id, option.label),
|
|
57
|
-
"navds-combobox__list-item--selected": isInList(option.value, selectedOptions),
|
|
58
|
-
}), "data-no-focus": isDisabled(option) || undefined, id: filteredOptionsUtil.getOptionId(id, option.label), key: option.label, tabIndex: -1, onMouseMove: () => {
|
|
59
|
-
if (activeDecendantId !==
|
|
60
|
-
filteredOptionsUtil.getOptionId(id, option.label)) {
|
|
61
|
-
virtualFocus.moveFocusToElement(filteredOptionsUtil.getOptionId(id, option.label));
|
|
62
|
-
setIsMouseLastUsedInputDevice(true);
|
|
63
|
-
}
|
|
64
|
-
}, onPointerUp: (event) => {
|
|
65
|
-
if (isDisabled(option)) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
toggleOption(option, event);
|
|
69
|
-
if (!isMultiSelect &&
|
|
70
|
-
!isInList(option.value, selectedOptions)) {
|
|
71
|
-
toggleIsListOpen(false);
|
|
72
|
-
}
|
|
73
|
-
}, role: "option", "aria-selected": isInList(option.value, selectedOptions), "aria-disabled": isDisabled(option) || undefined },
|
|
74
|
-
React.createElement(BodyShort, { size: size }, option.label),
|
|
75
|
-
isInList(option.value, selectedOptions) && React.createElement(CheckmarkIcon, null))))))));
|
|
30
|
+
isValueNew && !(maxSelected === null || maxSelected === void 0 ? void 0 : maxSelected.isLimitReached) && allowNewValues && (React.createElement(AddNewOption, null)),
|
|
31
|
+
filteredOptions.map((option) => (React.createElement(FilteredOptionsItem, { key: option.value, option: option })))))));
|
|
76
32
|
};
|
|
77
33
|
export default FilteredOptions;
|
|
78
34
|
//# sourceMappingURL=FilteredOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilteredOptions.js","sourceRoot":"","sources":["../../../../src/form/combobox/FilteredOptions/FilteredOptions.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OA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} from "../../../typography/index.js";
|
|
5
|
+
import { useInputContext } from "../Input/Input.context.js";
|
|
6
|
+
import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext.js";
|
|
7
|
+
import { isInList } from "../combobox-utils.js";
|
|
8
|
+
import filteredOptionsUtil from "./filtered-options-util.js";
|
|
9
|
+
import { useFilteredOptionsContext } from "./filteredOptionsContext.js";
|
|
10
|
+
const FilteredOptionsItem = ({ option }) => {
|
|
11
|
+
const { inputProps: { id }, size, } = useInputContext();
|
|
12
|
+
const { setIsMouseLastUsedInputDevice, toggleIsListOpen, activeDecendantId, virtualFocus, } = useFilteredOptionsContext();
|
|
13
|
+
const { isMultiSelect, maxSelected, selectedOptions, toggleOption } = useSelectedOptionsContext();
|
|
14
|
+
const isDisabled = (_option) => (maxSelected === null || maxSelected === void 0 ? void 0 : maxSelected.isLimitReached) && !isInList(_option.value, selectedOptions);
|
|
15
|
+
return (React.createElement("li", { className: cl("navds-combobox__list-item", {
|
|
16
|
+
"navds-combobox__list-item--focus": activeDecendantId ===
|
|
17
|
+
filteredOptionsUtil.getOptionId(id, option.label),
|
|
18
|
+
"navds-combobox__list-item--selected": isInList(option.value, selectedOptions),
|
|
19
|
+
}), "data-no-focus": isDisabled(option) || undefined, id: filteredOptionsUtil.getOptionId(id, option.label), key: option.label, tabIndex: -1, onMouseMove: () => {
|
|
20
|
+
if (activeDecendantId !==
|
|
21
|
+
filteredOptionsUtil.getOptionId(id, option.label)) {
|
|
22
|
+
virtualFocus.moveFocusToElement(filteredOptionsUtil.getOptionId(id, option.label));
|
|
23
|
+
setIsMouseLastUsedInputDevice(true);
|
|
24
|
+
}
|
|
25
|
+
}, onPointerUp: (event) => {
|
|
26
|
+
if (isDisabled(option)) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
toggleOption(option, event);
|
|
30
|
+
if (!isMultiSelect && !isInList(option.value, selectedOptions)) {
|
|
31
|
+
toggleIsListOpen(false);
|
|
32
|
+
}
|
|
33
|
+
}, role: "option", "aria-selected": isInList(option.value, selectedOptions), "aria-disabled": isDisabled(option) || undefined },
|
|
34
|
+
React.createElement(BodyShort, { size: size }, option.label),
|
|
35
|
+
isInList(option.value, selectedOptions) && React.createElement(CheckmarkIcon, null)));
|
|
36
|
+
};
|
|
37
|
+
export default FilteredOptionsItem;
|
|
38
|
+
//# sourceMappingURL=FilteredOptionsItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilteredOptionsItem.js","sourceRoot":"","sources":["../../../../src/form/combobox/FilteredOptions/FilteredOptionsItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,mBAAmB,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE,MAAM,mBAAmB,GAAG,CAAC,EAAE,MAAM,EAA8B,EAAE,EAAE;IACrE,MAAM,EACJ,UAAU,EAAE,EAAE,EAAE,EAAE,EAClB,IAAI,GACL,GAAG,eAAe,EAAE,CAAC;IACtB,MAAM,EACJ,6BAA6B,EAC7B,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,GACb,GAAG,yBAAyB,EAAE,CAAC;IAChC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,GACjE,yBAAyB,EAAE,CAAC;IAE9B,MAAM,UAAU,GAAG,CAAC,OAAuB,EAAE,EAAE,CAC7C,CAAA,WAAW,aAAX,WAAW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mBACvC,UAAU,CAAC,MAAM,CAAC,IAAI,SAAS;QAE9C,oBAAC,SAAS,IAAC,IAAI,EAAE,IAAI,IAAG,MAAM,CAAC,KAAK,CAAa;QAChD,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,eAAe,CAAC,IAAI,oBAAC,aAAa,OAAG,CAC1D,CACN,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Loader } from "../../../loader/index.js";
|
|
3
|
+
import { useInputContext } from "../Input/Input.context.js";
|
|
4
|
+
import filteredOptionsUtil from "./filtered-options-util.js";
|
|
5
|
+
const LoadingMessage = () => {
|
|
6
|
+
const { inputProps: { id }, } = useInputContext();
|
|
7
|
+
return (React.createElement("div", { className: "navds-combobox__list-item--loading", id: filteredOptionsUtil.getIsLoadingId(id) },
|
|
8
|
+
React.createElement(Loader, { title: "S\u00F8ker..." })));
|
|
9
|
+
};
|
|
10
|
+
export default LoadingMessage;
|
|
11
|
+
//# sourceMappingURL=LoadingMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoadingMessage.js","sourceRoot":"","sources":["../../../../src/form/combobox/FilteredOptions/LoadingMessage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,mBAAmB,MAAM,yBAAyB,CAAC;AAE1D,MAAM,cAAc,GAAG,GAAG,EAAE;IAC1B,MAAM,EACJ,UAAU,EAAE,EAAE,EAAE,EAAE,GACnB,GAAG,eAAe,EAAE,CAAC;IACtB,OAAO,CACL,6BACE,SAAS,EAAC,oCAAoC,EAC9C,EAAE,EAAE,mBAAmB,CAAC,cAAc,CAAC,EAAE,CAAC;QAE1C,oBAAC,MAAM,IAAC,KAAK,EAAC,eAAU,GAAG,CACvB,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useInputContext } from "../Input/Input.context.js";
|
|
3
|
+
import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext.js";
|
|
4
|
+
import filteredOptionsUtil from "./filtered-options-util.js";
|
|
5
|
+
const MaxSelectedMessage = () => {
|
|
6
|
+
var _a;
|
|
7
|
+
const { inputProps: { id }, } = useInputContext();
|
|
8
|
+
const { maxSelected, selectedOptions } = useSelectedOptionsContext();
|
|
9
|
+
if (!maxSelected) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return (React.createElement("div", { className: "navds-combobox__list-item--max-selected", id: filteredOptionsUtil.getMaxSelectedOptionsId(id) }, (_a = maxSelected.message) !== null && _a !== void 0 ? _a : `${selectedOptions.length} av ${maxSelected.limit} er valgt.`));
|
|
13
|
+
};
|
|
14
|
+
export default MaxSelectedMessage;
|
|
15
|
+
//# sourceMappingURL=MaxSelectedMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaxSelectedMessage.js","sourceRoot":"","sources":["../../../../src/form/combobox/FilteredOptions/MaxSelectedMessage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,mBAAmB,MAAM,yBAAyB,CAAC;AAE1D,MAAM,kBAAkB,GAAG,GAAG,EAAE;;IAC9B,MAAM,EACJ,UAAU,EAAE,EAAE,EAAE,EAAE,GACnB,GAAG,eAAe,EAAE,CAAC;IACtB,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,yBAAyB,EAAE,CAAC;IAErE,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,6BACE,SAAS,EAAC,yCAAyC,EACnD,EAAE,EAAE,mBAAmB,CAAC,uBAAuB,CAAC,EAAE,CAAC,IAElD,MAAA,WAAW,CAAC,OAAO,mCAClB,GAAG,eAAe,CAAC,MAAM,OAAO,WAAW,CAAC,KAAK,YAAY,CAC3D,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useInputContext } from "../Input/Input.context.js";
|
|
3
|
+
import filteredOptionsUtil from "./filtered-options-util.js";
|
|
4
|
+
const NoSearchHitsMessage = () => {
|
|
5
|
+
const { inputProps: { id }, } = useInputContext();
|
|
6
|
+
return (React.createElement("div", { className: "navds-combobox__list-item--no-options", id: filteredOptionsUtil.getNoHitsId(id) }, "Ingen s\u00F8ketreff"));
|
|
7
|
+
};
|
|
8
|
+
export default NoSearchHitsMessage;
|
|
9
|
+
//# sourceMappingURL=NoSearchHitsMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoSearchHitsMessage.js","sourceRoot":"","sources":["../../../../src/form/combobox/FilteredOptions/NoSearchHitsMessage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,mBAAmB,MAAM,yBAAyB,CAAC;AAE1D,MAAM,mBAAmB,GAAG,GAAG,EAAE;IAC/B,MAAM,EACJ,UAAU,EAAE,EAAE,EAAE,EAAE,GACnB,GAAG,eAAe,EAAE,CAAC;IACtB,OAAO,CACL,6BACE,SAAS,EAAC,uCAAuC,EACjD,EAAE,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,CAAC,2BAGnC,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -2,6 +2,7 @@ import React, { InputHTMLAttributes } from "react";
|
|
|
2
2
|
interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "value" | "disabled"> {
|
|
3
3
|
ref: React.Ref<HTMLInputElement>;
|
|
4
4
|
inputClassName?: string;
|
|
5
|
+
shouldShowSelectedOptions?: boolean;
|
|
5
6
|
value?: string;
|
|
6
7
|
}
|
|
7
8
|
declare const Input: React.ForwardRefExoticComponent<Omit<InputProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|