@navikt/ds-react 5.0.3 → 5.2.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/README.md +1 -1
- package/_docs.json +19 -0
- package/cjs/button/Button.js +10 -1
- package/cjs/date/DateInput.js +1 -1
- package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +14 -3
- package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js +5 -1
- package/cjs/form/combobox/Input/Input.js +3 -1
- package/cjs/form/combobox/Input/inputContext.js +2 -1
- package/cjs/guide-panel/Illustration.js +5 -5
- package/cjs/modal/Modal.js +25 -12
- package/cjs/modal/ModalUtils.js +10 -9
- package/cjs/modal/dialog-polyfill.js +7 -33
- package/esm/button/Button.js +10 -1
- package/esm/button/Button.js.map +1 -1
- package/esm/date/DateInput.js +1 -1
- package/esm/date/DateInput.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js +14 -3
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.d.ts +3 -1
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js +6 -2
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
- package/esm/form/combobox/Input/Input.js +3 -1
- package/esm/form/combobox/Input/Input.js.map +1 -1
- package/esm/form/combobox/Input/inputContext.js +3 -2
- package/esm/form/combobox/Input/inputContext.js.map +1 -1
- package/esm/guide-panel/Illustration.js +5 -5
- package/esm/modal/Modal.d.ts +5 -0
- package/esm/modal/Modal.js +25 -12
- package/esm/modal/Modal.js.map +1 -1
- package/esm/modal/ModalUtils.d.ts +2 -1
- package/esm/modal/ModalUtils.js +9 -8
- package/esm/modal/ModalUtils.js.map +1 -1
- package/esm/modal/dialog-polyfill.d.ts +1 -0
- package/esm/modal/dialog-polyfill.js +6 -33
- package/esm/modal/dialog-polyfill.js.map +1 -1
- package/package.json +2 -2
- package/src/button/Button.tsx +13 -1
- package/src/date/DateInput.tsx +1 -1
- package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +16 -0
- package/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx +10 -2
- package/src/form/combobox/Input/Input.tsx +3 -0
- package/src/form/combobox/Input/inputContext.tsx +2 -2
- package/src/form/combobox/combobox.stories.tsx +49 -0
- package/src/guide-panel/Illustration.tsx +5 -5
- package/src/loader/loader.stories.tsx +2 -2
- package/src/modal/Modal.test.tsx +54 -0
- package/src/modal/Modal.tsx +28 -11
- package/src/modal/ModalUtils.ts +9 -7
- package/src/modal/dialog-polyfill.ts +8 -40
- package/src/modal/modal.stories.tsx +2 -2
- package/src/timeline/timeline.stories.tsx +1 -1
package/README.md
CHANGED
package/_docs.json
CHANGED
|
@@ -5904,6 +5904,25 @@
|
|
|
5904
5904
|
"name": "number | \"medium\" | \"small\" | `${number}${string}`"
|
|
5905
5905
|
}
|
|
5906
5906
|
},
|
|
5907
|
+
"portal": {
|
|
5908
|
+
"defaultValue": null,
|
|
5909
|
+
"description": "Lets you render the modal into a different part of the DOM.\nWill use `rootElement` from `Provider` if defined, otherwise `document.body`.",
|
|
5910
|
+
"name": "portal",
|
|
5911
|
+
"parent": {
|
|
5912
|
+
"fileName": "src/modal/Modal.tsx",
|
|
5913
|
+
"name": "ModalProps"
|
|
5914
|
+
},
|
|
5915
|
+
"declarations": [
|
|
5916
|
+
{
|
|
5917
|
+
"fileName": "src/modal/Modal.tsx",
|
|
5918
|
+
"name": "ModalProps"
|
|
5919
|
+
}
|
|
5920
|
+
],
|
|
5921
|
+
"required": false,
|
|
5922
|
+
"type": {
|
|
5923
|
+
"name": "boolean"
|
|
5924
|
+
}
|
|
5925
|
+
},
|
|
5907
5926
|
"className": {
|
|
5908
5927
|
"defaultValue": null,
|
|
5909
5928
|
"description": "User defined classname for modal",
|
package/cjs/button/Button.js
CHANGED
|
@@ -70,7 +70,16 @@ exports.Button = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
70
70
|
}
|
|
71
71
|
}, [loading, children]);
|
|
72
72
|
const filterProps = (disabled !== null && disabled !== void 0 ? disabled : widthOverride) ? (0, util_1.omit)(rest, ["href"]) : rest;
|
|
73
|
-
return (react_1.default.createElement(Component, Object.assign({}, filterProps, { ref: mergedRef,
|
|
73
|
+
return (react_1.default.createElement(Component, Object.assign({}, (Component !== "button" ? { role: "button" } : {}), filterProps, { ref: mergedRef, onKeyUp: (e) => {
|
|
74
|
+
var _a;
|
|
75
|
+
(_a = filterProps.onKeyUp) === null || _a === void 0 ? void 0 : _a.call(filterProps, e);
|
|
76
|
+
if (e.key === " " &&
|
|
77
|
+
!disabled &&
|
|
78
|
+
!widthOverride &&
|
|
79
|
+
!e.isDefaultPrevented()) {
|
|
80
|
+
e.currentTarget.click();
|
|
81
|
+
}
|
|
82
|
+
}, className: (0, clsx_1.default)(className, "navds-button", `navds-button--${variant}`, `navds-button--${size}`, {
|
|
74
83
|
"navds-button--loading": widthOverride,
|
|
75
84
|
"navds-button--icon-only": !!icon && !children,
|
|
76
85
|
"navds-button--disabled": disabled !== null && disabled !== void 0 ? disabled : widthOverride,
|
package/cjs/date/DateInput.js
CHANGED
|
@@ -75,7 +75,7 @@ const DateInput = (0, react_1.forwardRef)((props, ref) => {
|
|
|
75
75
|
"navds-sr-only": hideLabel,
|
|
76
76
|
}), id: inputDescriptionId, size: size }, description)),
|
|
77
77
|
react_1.default.createElement("div", { className: "navds-date__field-wrapper" },
|
|
78
|
-
react_1.default.createElement("input", Object.assign({ ref: ref }, (0, __1.omit)(rest, ["error", "errorId", "size"]), inputProps, { autoComplete: "off", "aria-controls": ariaId, readOnly: readOnly, className: (0, clsx_1.default)("navds-date__field-input", "navds-text-field__input", "navds-body-short", `navds-body-${size}`), size: 14 })),
|
|
78
|
+
react_1.default.createElement("input", Object.assign({ ref: ref }, (0, __1.omit)(rest, ["error", "errorId", "size"]), inputProps, { autoComplete: "off", "aria-controls": open ? ariaId : undefined, readOnly: readOnly, className: (0, clsx_1.default)("navds-date__field-input", "navds-text-field__input", "navds-body-short", `navds-body-${size}`), size: 14 })),
|
|
79
79
|
react_1.default.createElement("button", { disabled: inputProps.disabled || readOnly, tabIndex: readOnly ? -1 : open ? -1 : 0, onClick: () => onOpen(), type: "button", className: "navds-date__field-button" },
|
|
80
80
|
react_1.default.createElement(aksel_icons_1.CalendarIcon, { pointerEvents: "none", title: open
|
|
81
81
|
? conditionalVariables.iconTitle.close
|
|
@@ -12,14 +12,20 @@ const selectedOptionsContext_1 = require("../SelectedOptions/selectedOptionsCont
|
|
|
12
12
|
const inputContext_1 = require("../Input/inputContext");
|
|
13
13
|
const FilteredOptions = () => {
|
|
14
14
|
const { inputProps: { id }, size, value, } = (0, inputContext_1.useInputContext)();
|
|
15
|
-
const { allowNewValues, isLoading, isListOpen, filteredOptions, filteredOptionsIndex, filteredOptionsRef, isValueNew, toggleIsListOpen, } = (0, filteredOptionsContext_1.useFilteredOptionsContext)();
|
|
15
|
+
const { allowNewValues, isLoading, isListOpen, filteredOptions, filteredOptionsIndex, filteredOptionsRef, isMouseLastUsedInputDevice, setIsMouseLastUsedInputDevice, isValueNew, setFilteredOptionsIndex, toggleIsListOpen, } = (0, filteredOptionsContext_1.useFilteredOptionsContext)();
|
|
16
16
|
const { isMultiSelect, selectedOptions, toggleOption } = (0, selectedOptionsContext_1.useSelectedOptionsContext)();
|
|
17
17
|
return (react_1.default.createElement("ul", { ref: filteredOptionsRef, className: (0, clsx_1.default)("navds-combobox__list", {
|
|
18
18
|
"navds-combobox__list--closed": !isListOpen,
|
|
19
|
+
"navds-combobox__list--with-hover": isMouseLastUsedInputDevice,
|
|
19
20
|
}), id: `${id}-filtered-options`, role: "listbox", tabIndex: -1 },
|
|
20
21
|
isLoading && (react_1.default.createElement("li", { className: "navds-combobox__list-item--loading", role: "option", "aria-selected": false, id: `${id}-is-loading` },
|
|
21
22
|
react_1.default.createElement(__1.Loader, { "aria-label": "S\u00F8ker..." }))),
|
|
22
|
-
isValueNew && allowNewValues && (react_1.default.createElement("li", { tabIndex: -1,
|
|
23
|
+
isValueNew && allowNewValues && (react_1.default.createElement("li", { tabIndex: -1, onMouseMove: () => {
|
|
24
|
+
if (filteredOptionsIndex !== -1) {
|
|
25
|
+
setFilteredOptionsIndex(-1);
|
|
26
|
+
setIsMouseLastUsedInputDevice(true);
|
|
27
|
+
}
|
|
28
|
+
}, onPointerUp: (event) => {
|
|
23
29
|
toggleOption(value, event);
|
|
24
30
|
if (!isMultiSelect && !selectedOptions.includes(value))
|
|
25
31
|
toggleIsListOpen(false);
|
|
@@ -38,7 +44,12 @@ const FilteredOptions = () => {
|
|
|
38
44
|
filteredOptions.map((option, index) => (react_1.default.createElement("li", { className: (0, clsx_1.default)("navds-combobox__list-item", {
|
|
39
45
|
"navds-combobox__list-item--focus": index === filteredOptionsIndex,
|
|
40
46
|
"navds-combobox__list-item--selected": selectedOptions.includes(option),
|
|
41
|
-
}), id: `${id}-option-${option.replace(" ", "-")}`, key: option, tabIndex: -1,
|
|
47
|
+
}), id: `${id}-option-${option.replace(" ", "-")}`, key: option, tabIndex: -1, onMouseMove: () => {
|
|
48
|
+
if (filteredOptionsIndex !== index) {
|
|
49
|
+
setFilteredOptionsIndex(index);
|
|
50
|
+
setIsMouseLastUsedInputDevice(true);
|
|
51
|
+
}
|
|
52
|
+
}, onPointerUp: (event) => {
|
|
42
53
|
toggleOption(option, event);
|
|
43
54
|
if (!isMultiSelect && !selectedOptions.includes(option))
|
|
44
55
|
toggleIsListOpen(false);
|
|
@@ -32,6 +32,7 @@ const clsx_1 = __importDefault(require("clsx"));
|
|
|
32
32
|
const customOptionsContext_1 = require("../customOptionsContext");
|
|
33
33
|
const inputContext_1 = require("../Input/inputContext");
|
|
34
34
|
const usePrevious_1 = __importDefault(require("../../../util/usePrevious"));
|
|
35
|
+
const util_1 = require("../../../util");
|
|
35
36
|
const normalizeText = (text) => typeof text === "string" ? `${text}`.toLowerCase().trim() : "";
|
|
36
37
|
const isPartOfText = (value, text) => normalizeText(text).startsWith(normalizeText(value !== null && value !== void 0 ? value : ""));
|
|
37
38
|
const isValueInList = (value, list) => list === null || list === void 0 ? void 0 : list.find((listItem) => normalizeText(value) === normalizeText(listItem));
|
|
@@ -53,7 +54,8 @@ const FilteredOptionsProvider = ({ children, value: props }) => {
|
|
|
53
54
|
return getMatchingValuesFromList(searchTerm, opts);
|
|
54
55
|
}, [customOptions, externalFilteredOptions, options, searchTerm]);
|
|
55
56
|
const previousSearchTerm = (0, usePrevious_1.default)(searchTerm);
|
|
56
|
-
(0, react_1.
|
|
57
|
+
const [isMouseLastUsedInputDevice, setIsMouseLastUsedInputDevice] = (0, react_1.useState)(false);
|
|
58
|
+
(0, util_1.useClientLayoutEffect)(() => {
|
|
57
59
|
if (shouldAutocomplete &&
|
|
58
60
|
normalizeText(searchTerm) !== "" &&
|
|
59
61
|
((previousSearchTerm === null || previousSearchTerm === void 0 ? void 0 : previousSearchTerm.length) || 0) < searchTerm.length &&
|
|
@@ -193,6 +195,8 @@ const FilteredOptionsProvider = ({ children, value: props }) => {
|
|
|
193
195
|
isListOpen,
|
|
194
196
|
isLoading,
|
|
195
197
|
filteredOptions,
|
|
198
|
+
isMouseLastUsedInputDevice,
|
|
199
|
+
setIsMouseLastUsedInputDevice,
|
|
196
200
|
isValueNew,
|
|
197
201
|
toggleIsListOpen,
|
|
198
202
|
currentOption,
|
|
@@ -47,7 +47,7 @@ const Input = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
47
47
|
var { inputClassName, error, errorId } = _a, rest = __rest(_a, ["inputClassName", "error", "errorId"]);
|
|
48
48
|
const { clearInput, inputProps, onChange, size, value } = (0, inputContext_1.useInputContext)();
|
|
49
49
|
const { selectedOptions, removeSelectedOption, toggleOption, isMultiSelect, } = (0, selectedOptionsContext_1.useSelectedOptionsContext)();
|
|
50
|
-
const { activeDecendantId, allowNewValues, currentOption, filteredOptions, toggleIsListOpen, isListOpen, filteredOptionsIndex, moveFocusUp, moveFocusDown, ariaDescribedBy, moveFocusToInput, moveFocusToEnd, setFilteredOptionsIndex, shouldAutocomplete, } = (0, filteredOptionsContext_1.useFilteredOptionsContext)();
|
|
50
|
+
const { activeDecendantId, allowNewValues, currentOption, filteredOptions, toggleIsListOpen, isListOpen, filteredOptionsIndex, moveFocusUp, moveFocusDown, ariaDescribedBy, moveFocusToInput, moveFocusToEnd, setFilteredOptionsIndex, setIsMouseLastUsedInputDevice, shouldAutocomplete, } = (0, filteredOptionsContext_1.useFilteredOptionsContext)();
|
|
51
51
|
const onEnter = (0, react_1.useCallback)((event) => {
|
|
52
52
|
if (currentOption) {
|
|
53
53
|
event.preventDefault();
|
|
@@ -101,6 +101,7 @@ const Input = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
103
|
const handleKeyDown = (0, react_1.useCallback)((e) => {
|
|
104
|
+
setIsMouseLastUsedInputDevice(false);
|
|
104
105
|
if (e.key === "Backspace") {
|
|
105
106
|
if (value === "") {
|
|
106
107
|
const lastSelectedOption = selectedOptions[selectedOptions.length - 1];
|
|
@@ -131,6 +132,7 @@ const Input = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
131
132
|
isListOpen,
|
|
132
133
|
filteredOptionsIndex,
|
|
133
134
|
moveFocusUp,
|
|
135
|
+
setIsMouseLastUsedInputDevice,
|
|
134
136
|
]);
|
|
135
137
|
const onChangeHandler = (0, react_1.useCallback)((event) => {
|
|
136
138
|
const newValue = event.target.value;
|
|
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.useInputContext = exports.InputContextProvider = void 0;
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
28
|
const useFormField_1 = require("../../useFormField");
|
|
29
|
+
const util_1 = require("../../../util");
|
|
29
30
|
const InputContext = (0, react_1.createContext)({});
|
|
30
31
|
const InputContextProvider = ({ children, value: props }) => {
|
|
31
32
|
const { defaultValue = "", description, disabled, error, errorId, id: externalId, value: externalValue, onChange: externalOnChange, onClear, shouldAutocomplete, size, } = props;
|
|
@@ -60,7 +61,7 @@ const InputContextProvider = ({ children, value: props }) => {
|
|
|
60
61
|
var _a, _b;
|
|
61
62
|
(_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
62
63
|
}, []);
|
|
63
|
-
(0,
|
|
64
|
+
(0, util_1.useClientLayoutEffect)(() => {
|
|
64
65
|
var _a, _b;
|
|
65
66
|
if (shouldAutocomplete && inputRef && value !== searchTerm) {
|
|
66
67
|
(_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange) === null || _b === void 0 ? void 0 : _b.call(_a, searchTerm.length, value.length);
|
|
@@ -26,12 +26,12 @@ const DefaultIllustration = (_a) => {
|
|
|
26
26
|
react_1.default.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M32.8313 30.4421C31.7718 33.868 29.6975 36.7117 27.0391 38.452L27.1752 39.9777L27.1745 40.0397L25.7375 52.6154H16.6236L16.5857 52.3512L14.8238 40.0181L14.8891 38.4756C12.2173 36.7398 10.1312 33.8914 9.06565 30.4564C9.02952 30.4598 8.99291 30.4616 8.95588 30.4616C8.26662 30.4616 7.72058 29.8614 7.72058 29.1343V25.0202C7.72058 24.5328 7.96592 24.1022 8.33526 23.8712C8.9115 16.1905 14.3251 10.1539 20.946 10.1539C27.5491 10.1539 32.9517 16.1579 33.5525 23.8089C33.9838 24.0179 34.2794 24.4845 34.2794 25.0202V29.1343C34.2794 29.8618 33.7341 30.4616 33.0441 30.4616C32.9714 30.4616 32.9003 30.4549 32.8313 30.4421Z", fill: "#F1F1F1" }),
|
|
27
27
|
react_1.default.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M26.7182 38.8777C26.6663 41.624 24.1261 44.4415 21 44.4415C17.8604 44.4415 15.3116 41.5994 15.2813 38.8419C13.6546 39.2527 11.1714 40.4917 9.12177 42.5623C7.13699 44.5674 5.55884 47.5814 5.55884 49.9194V64H36.4412V49.9194C36.4412 47.5766 34.829 44.5575 32.8075 42.5501C30.7861 40.5427 28.3553 39.3204 26.7182 38.8777Z", fill: "#0056B4" }),
|
|
28
28
|
react_1.default.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M15.1786 38.9372C13.6802 39.4793 11.1664 40.6641 9.2647 42.4632C3.70588 41.2308 1.23529 38.3022 1.23529 38.3022C1.23529 38.3022 6.35673 33.325 6.35982 24.6197V24.6105C6.35982 14.4173 11.8831 7.38464 20.9827 7.38464C30.0836 7.38464 35.6068 14.4173 35.6068 24.6105H35.6396C35.6396 33.3219 40.7647 38.3022 40.7647 38.3022C40.7647 38.3022 38.2941 41.2308 32.7353 42.4616L32.7269 42.4632C30.8901 40.7984 28.2262 39.5144 26.7769 38.9715L26.7785 38.971L26.7209 38.3257L26.7521 38.2722C29.4867 36.5294 31.6086 33.5933 32.6316 30.0454C32.7569 30.1148 32.8983 30.1539 33.048 30.1539C33.5601 30.1539 33.9746 29.6984 33.9746 29.1343V25.0202C33.9746 24.5375 33.6712 24.134 33.2628 24.0275C33.2624 24.0219 33.262 24.0164 33.2616 24.0108C20.3323 25.4483 15.6749 16.616 15.2926 16.6154C15.2926 16.6154 10.9987 19.6923 8.94657 23.3506C8.94657 23.3506 8.6338 24.0412 8.63228 24.0644C8.28095 24.2092 8.03035 24.5821 8.03035 25.0202V29.1343C8.03035 29.6984 8.44586 30.1539 8.95693 30.1539C9.07019 30.1539 9.17868 30.1316 9.27895 30.0908C10.3132 33.6404 12.4486 36.5733 15.1961 38.3046L15.2063 38.3257L15.1804 38.9372H15.1786Z", fill: "#D05C4A" }),
|
|
29
|
-
react_1.default.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M16.584 26.9976C15.7859 27.062 15.5625 25.8029 15.803 24.9807C15.8482 24.8249 16.1124 24.1154 16.5802 24.1154C17.0473 24.1154 17.2536 24.5032 17.2823 24.5699C17.6259 25.3715 17.4571 26.9268 16.584 26.9976", fill: "#
|
|
30
|
-
react_1.default.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M25.8405 26.9976C26.6386 27.062 26.862 25.8029 26.6215 24.9807C26.5763 24.8249 26.3121 24.1154 25.8444 24.1154C25.3772 24.1154 25.171 24.5032 25.1423 24.5699C24.7987 25.3715 24.9674 26.9268 25.8405 26.9976", fill: "#
|
|
31
|
-
react_1.default.createElement("path", { d: "M21.5081 28.2384C21.9854 28.157 22.3113 28.2081 22.428 28.3669C22.8687 28.9672 22.7277 29.6023 21.9718 30.1237C21.5744 30.3977 21.0273 30.4942 20.7377 30.3521C20.596 30.2826 20.4304 30.3536 20.3677 30.5106C20.3051 30.6676 20.3691 30.8512 20.5107 30.9207C20.9894 31.1555 21.7255 31.0257 22.268 30.6517C23.2953 29.9431 23.5304 28.8837 22.863 27.9743C22.5805 27.59 22.0806 27.5116 21.4228 27.6239C21.2697 27.65 21.1647 27.8088 21.1883 27.9784C21.2118 28.1481 21.355 28.2645 21.5081 28.2384Z", fill: "#
|
|
32
|
-
react_1.default.createElement("path", { d: "M24.9595 32.3642C24.9315 32.4234 24.8672 32.5367 24.7639 32.686C24.589 32.9386 24.3694 33.1919 24.1027 33.4281C23.3079 34.1319 22.2735 34.5389 20.9568 34.5017C19.673 34.4654 18.6432 34.0647 17.8358 33.4185C17.5393 33.1813 17.2946 32.9272 17.0989 32.6739C16.9836 32.5246 16.9115 32.4114 16.88 32.3523C16.8043 32.2104 16.618 32.152 16.464 32.2218C16.31 32.2917 16.2466 32.4634 16.3224 32.6053C16.3681 32.6908 16.4569 32.8304 16.5927 33.0062C16.8156 33.2948 17.0928 33.5826 17.4283 33.8511C18.3398 34.5805 19.5046 35.0338 20.9378 35.0743C22.4302 35.1165 23.6233 34.6471 24.5333 33.8412C24.8376 33.5717 25.0877 33.2832 25.2878 32.9941C25.4095 32.8183 25.4887 32.6787 25.5291 32.5934C25.5977 32.4485 25.5259 32.2796 25.3686 32.2163C25.2113 32.153 25.0282 32.2192 24.9595 32.3642Z", fill: "#
|
|
29
|
+
react_1.default.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M16.584 26.9976C15.7859 27.062 15.5625 25.8029 15.803 24.9807C15.8482 24.8249 16.1124 24.1154 16.5802 24.1154C17.0473 24.1154 17.2536 24.5032 17.2823 24.5699C17.6259 25.3715 17.4571 26.9268 16.584 26.9976", fill: "#23262a" }),
|
|
30
|
+
react_1.default.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M25.8405 26.9976C26.6386 27.062 26.862 25.8029 26.6215 24.9807C26.5763 24.8249 26.3121 24.1154 25.8444 24.1154C25.3772 24.1154 25.171 24.5032 25.1423 24.5699C24.7987 25.3715 24.9674 26.9268 25.8405 26.9976", fill: "#23262a" }),
|
|
31
|
+
react_1.default.createElement("path", { d: "M21.5081 28.2384C21.9854 28.157 22.3113 28.2081 22.428 28.3669C22.8687 28.9672 22.7277 29.6023 21.9718 30.1237C21.5744 30.3977 21.0273 30.4942 20.7377 30.3521C20.596 30.2826 20.4304 30.3536 20.3677 30.5106C20.3051 30.6676 20.3691 30.8512 20.5107 30.9207C20.9894 31.1555 21.7255 31.0257 22.268 30.6517C23.2953 29.9431 23.5304 28.8837 22.863 27.9743C22.5805 27.59 22.0806 27.5116 21.4228 27.6239C21.2697 27.65 21.1647 27.8088 21.1883 27.9784C21.2118 28.1481 21.355 28.2645 21.5081 28.2384Z", fill: "#23262a" }),
|
|
32
|
+
react_1.default.createElement("path", { d: "M24.9595 32.3642C24.9315 32.4234 24.8672 32.5367 24.7639 32.686C24.589 32.9386 24.3694 33.1919 24.1027 33.4281C23.3079 34.1319 22.2735 34.5389 20.9568 34.5017C19.673 34.4654 18.6432 34.0647 17.8358 33.4185C17.5393 33.1813 17.2946 32.9272 17.0989 32.6739C16.9836 32.5246 16.9115 32.4114 16.88 32.3523C16.8043 32.2104 16.618 32.152 16.464 32.2218C16.31 32.2917 16.2466 32.4634 16.3224 32.6053C16.3681 32.6908 16.4569 32.8304 16.5927 33.0062C16.8156 33.2948 17.0928 33.5826 17.4283 33.8511C18.3398 34.5805 19.5046 35.0338 20.9378 35.0743C22.4302 35.1165 23.6233 34.6471 24.5333 33.8412C24.8376 33.5717 25.0877 33.2832 25.2878 32.9941C25.4095 32.8183 25.4887 32.6787 25.5291 32.5934C25.5977 32.4485 25.5259 32.2796 25.3686 32.2163C25.2113 32.153 25.0282 32.2192 24.9595 32.3642Z", fill: "#23262a" }),
|
|
33
33
|
react_1.default.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M32.1651 58H21.8343C21.3733 58 21 57.621 21 57.153V51.5143C21 51.0462 21.3733 50.6667 21.8343 50.6667H32.1651C32.6261 50.6667 33 51.0462 33 51.5143V57.153C33 57.621 32.6261 58 32.1651 58", fill: "white" }),
|
|
34
|
-
react_1.default.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M27.6207 51.8307H26.5502C26.4709 51.8307 26.407 51.7671 26.407 51.6882V51.5086C26.407 51.4303 26.4709 51.3661 26.5502 51.3661H27.6207C27.7 51.3661 27.764 51.4303 27.764 51.5086V51.6882C27.764 51.7671 27.7 51.8307 27.6207 51.8307", fill: "#
|
|
34
|
+
react_1.default.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M27.6207 51.8307H26.5502C26.4709 51.8307 26.407 51.7671 26.407 51.6882V51.5086C26.407 51.4303 26.4709 51.3661 26.5502 51.3661H27.6207C27.7 51.3661 27.764 51.4303 27.764 51.5086V51.6882C27.764 51.7671 27.7 51.8307 27.6207 51.8307", fill: "#23262a" }),
|
|
35
35
|
react_1.default.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M26.7756 51.6667H27.3958V50H26.7756V51.6667Z", fill: "#6A6A6A" }),
|
|
36
36
|
react_1.default.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M27.1269 56.6651C25.839 56.6651 24.7947 55.6208 24.7947 54.3327C24.7947 53.0444 25.839 52 27.1269 52C28.4153 52 29.4597 53.0444 29.4597 54.3327C29.4597 55.6208 28.4153 56.6651 27.1269 56.6651Z", fill: "#C30000" }),
|
|
37
37
|
react_1.default.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M23.6667 55.3511L24.1434 54.1712H24.6015L24.1254 55.3511H23.6667Z", fill: "#C30000" }),
|
package/cjs/modal/Modal.js
CHANGED
|
@@ -39,15 +39,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
40
|
exports.Modal = void 0;
|
|
41
41
|
const react_1 = __importStar(require("react"));
|
|
42
|
+
const react_dom_1 = require("react-dom");
|
|
43
|
+
const react_2 = require("@floating-ui/react");
|
|
42
44
|
const clsx_1 = __importDefault(require("clsx"));
|
|
43
|
-
const dialog_polyfill_1 =
|
|
45
|
+
const dialog_polyfill_1 = __importStar(require("./dialog-polyfill"));
|
|
44
46
|
const __1 = require("..");
|
|
45
47
|
const ModalBody_1 = __importDefault(require("./ModalBody"));
|
|
46
48
|
const ModalHeader_1 = __importDefault(require("./ModalHeader"));
|
|
47
49
|
const ModalFooter_1 = __importDefault(require("./ModalFooter"));
|
|
48
50
|
const ModalUtils_1 = require("./ModalUtils");
|
|
49
51
|
const ModalContext_1 = require("./ModalContext");
|
|
50
|
-
const needPolyfill = typeof window !== "undefined" && window.HTMLDialogElement === undefined;
|
|
51
52
|
/**
|
|
52
53
|
* A component that displays a modal dialog.
|
|
53
54
|
*
|
|
@@ -95,23 +96,29 @@ const needPolyfill = typeof window !== "undefined" && window.HTMLDialogElement =
|
|
|
95
96
|
* ```
|
|
96
97
|
*/
|
|
97
98
|
exports.Modal = (0, react_1.forwardRef)((_a, ref) => {
|
|
98
|
-
var _b;
|
|
99
|
-
var { header, children, open, onBeforeClose, onCancel, width, className, "aria-labelledby": ariaLabelledby, style } = _a, rest = __rest(_a, ["header", "children", "open", "onBeforeClose", "onCancel", "width", "className", "aria-labelledby", "style"]);
|
|
99
|
+
var _b, _c;
|
|
100
|
+
var { header, children, open, onBeforeClose, onCancel, width, portal, className, "aria-labelledby": ariaLabelledby, style } = _a, rest = __rest(_a, ["header", "children", "open", "onBeforeClose", "onCancel", "width", "portal", "className", "aria-labelledby", "style"]);
|
|
100
101
|
const modalRef = (0, react_1.useRef)(null);
|
|
101
102
|
const mergedRef = (0, react_1.useMemo)(() => (0, __1.mergeRefs)([modalRef, ref]), [ref]);
|
|
102
103
|
const ariaLabelId = (0, __1.useId)();
|
|
104
|
+
const rootElement = (_b = (0, __1.useProvider)()) === null || _b === void 0 ? void 0 : _b.rootElement;
|
|
105
|
+
const portalNode = (0, react_2.useFloatingPortalNode)({ root: rootElement });
|
|
103
106
|
if ((0, react_1.useContext)(ModalContext_1.ModalContext)) {
|
|
104
107
|
console.error("Modals should not be nested");
|
|
105
108
|
}
|
|
106
109
|
(0, react_1.useEffect)(() => {
|
|
107
|
-
|
|
110
|
+
// If using portal, modalRef.current will not be set before portalNode is set.
|
|
111
|
+
// If not using portal, modalRef.current is available first.
|
|
112
|
+
// We check both to avoid activating polyfill twice when not using portal.
|
|
113
|
+
if (dialog_polyfill_1.needPolyfill && modalRef.current && portalNode) {
|
|
108
114
|
dialog_polyfill_1.default.registerDialog(modalRef.current);
|
|
109
115
|
}
|
|
110
|
-
}, [modalRef]);
|
|
116
|
+
}, [modalRef, portalNode]);
|
|
111
117
|
(0, react_1.useEffect)(() => {
|
|
112
118
|
// We need to have this in a useEffect so that the content renders before the modal is displayed,
|
|
113
119
|
// and in case `open` is true initially.
|
|
114
|
-
|
|
120
|
+
// We need to check both modalRef.current and portalNode to make sure the polyfill has been activated.
|
|
121
|
+
if (modalRef.current && portalNode && open !== undefined) {
|
|
115
122
|
if (open && !modalRef.current.open) {
|
|
116
123
|
modalRef.current.showModal();
|
|
117
124
|
}
|
|
@@ -119,11 +126,11 @@ exports.Modal = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
119
126
|
modalRef.current.close();
|
|
120
127
|
}
|
|
121
128
|
}
|
|
122
|
-
}, [modalRef, open]);
|
|
123
|
-
(0, ModalUtils_1.useBodyScrollLock)(modalRef,
|
|
129
|
+
}, [modalRef, portalNode, open]);
|
|
130
|
+
(0, ModalUtils_1.useBodyScrollLock)(modalRef, portalNode);
|
|
124
131
|
const isWidthPreset = typeof width === "string" && ["small", "medium"].includes(width);
|
|
125
|
-
|
|
126
|
-
"navds-modal--polyfilled": needPolyfill,
|
|
132
|
+
const component = (react_1.default.createElement("dialog", Object.assign({ ref: mergedRef, className: (0, clsx_1.default)("navds-modal", className, {
|
|
133
|
+
"navds-modal--polyfilled": dialog_polyfill_1.needPolyfill,
|
|
127
134
|
"navds-modal--autowidth": !width,
|
|
128
135
|
[`navds-modal--${width}`]: isWidthPreset,
|
|
129
136
|
}), style: Object.assign(Object.assign({}, style), (!isWidthPreset ? { width } : {})), onCancel: (event) => {
|
|
@@ -141,10 +148,16 @@ exports.Modal = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
141
148
|
} },
|
|
142
149
|
header && (react_1.default.createElement(ModalHeader_1.default, null,
|
|
143
150
|
header.label && (react_1.default.createElement(__1.Detail, { className: "navds-modal__label" }, header.label)),
|
|
144
|
-
react_1.default.createElement(__1.Heading, { size: (
|
|
151
|
+
react_1.default.createElement(__1.Heading, { size: (_c = header.size) !== null && _c !== void 0 ? _c : "medium", level: "1", id: ariaLabelId },
|
|
145
152
|
react_1.default.createElement("span", { className: "navds-modal__header-icon" }, header.icon),
|
|
146
153
|
header.heading))),
|
|
147
154
|
children)));
|
|
155
|
+
if (portal) {
|
|
156
|
+
if (portalNode)
|
|
157
|
+
return (0, react_dom_1.createPortal)(component, portalNode);
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
return component;
|
|
148
161
|
});
|
|
149
162
|
exports.Modal.Header = ModalHeader_1.default;
|
|
150
163
|
exports.Modal.Body = ModalBody_1.default;
|
package/cjs/modal/ModalUtils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useBodyScrollLock = exports.getCloseHandler = void 0;
|
|
6
|
+
exports.useBodyScrollLock = exports.BODY_CLASS = exports.getCloseHandler = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
function getCloseHandler(modalRef, header, onBeforeClose) {
|
|
9
9
|
if (header && header.closeButton === false)
|
|
@@ -14,18 +14,19 @@ function getCloseHandler(modalRef, header, onBeforeClose) {
|
|
|
14
14
|
return () => { var _a; return (_a = modalRef.current) === null || _a === void 0 ? void 0 : _a.close(); };
|
|
15
15
|
}
|
|
16
16
|
exports.getCloseHandler = getCloseHandler;
|
|
17
|
-
|
|
17
|
+
exports.BODY_CLASS = "navds-modal__document-body";
|
|
18
|
+
function useBodyScrollLock(modalRef, portalNode) {
|
|
18
19
|
react_1.default.useEffect(() => {
|
|
19
|
-
if (!modalRef.current)
|
|
20
|
-
return;
|
|
20
|
+
if (!modalRef.current || !portalNode)
|
|
21
|
+
return; // We check both to avoid running this twice when not using portal
|
|
21
22
|
if (modalRef.current.open)
|
|
22
|
-
document.body.classList.add(
|
|
23
|
+
document.body.classList.add(exports.BODY_CLASS); // In case `open` is true initially
|
|
23
24
|
const observer = new MutationObserver(() => {
|
|
24
25
|
var _a;
|
|
25
26
|
if ((_a = modalRef.current) === null || _a === void 0 ? void 0 : _a.open)
|
|
26
|
-
document.body.classList.add(
|
|
27
|
+
document.body.classList.add(exports.BODY_CLASS);
|
|
27
28
|
else
|
|
28
|
-
document.body.classList.remove(
|
|
29
|
+
document.body.classList.remove(exports.BODY_CLASS);
|
|
29
30
|
});
|
|
30
31
|
observer.observe(modalRef.current, {
|
|
31
32
|
attributes: true,
|
|
@@ -33,8 +34,8 @@ function useBodyScrollLock(modalRef, bodyClass) {
|
|
|
33
34
|
});
|
|
34
35
|
return () => {
|
|
35
36
|
observer.disconnect();
|
|
36
|
-
document.body.classList.remove(
|
|
37
|
+
document.body.classList.remove(exports.BODY_CLASS); // In case modal is unmounted before it's closed
|
|
37
38
|
};
|
|
38
|
-
}, [modalRef,
|
|
39
|
+
}, [modalRef, portalNode]);
|
|
39
40
|
}
|
|
40
41
|
exports.useBodyScrollLock = useBodyScrollLock;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// @ts-nocheck
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.needPolyfill = void 0;
|
|
5
|
+
exports.needPolyfill = typeof window !== "undefined" &&
|
|
6
|
+
(window.HTMLDialogElement === undefined ||
|
|
7
|
+
navigator.userAgent.includes("jsdom"));
|
|
4
8
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
|
5
9
|
//
|
|
6
10
|
// Redistribution and use in source and binary forms, with or without
|
|
@@ -43,31 +47,6 @@ function safeDispatchEvent(target, event) {
|
|
|
43
47
|
}
|
|
44
48
|
return target.dispatchEvent(event);
|
|
45
49
|
}
|
|
46
|
-
/**
|
|
47
|
-
* @param {Element} el to check for stacking context
|
|
48
|
-
* @return {boolean} whether this el or its parents creates a stacking context
|
|
49
|
-
*/
|
|
50
|
-
function createsStackingContext(el) {
|
|
51
|
-
while (el && el !== document.body) {
|
|
52
|
-
var s = window.getComputedStyle(el);
|
|
53
|
-
var invalid = function (k, ok) {
|
|
54
|
-
return !(s[k] === undefined || s[k] === ok);
|
|
55
|
-
};
|
|
56
|
-
if (s.opacity < 1 ||
|
|
57
|
-
invalid("zIndex", "auto") ||
|
|
58
|
-
invalid("transform", "none") ||
|
|
59
|
-
invalid("mixBlendMode", "normal") ||
|
|
60
|
-
invalid("filter", "none") ||
|
|
61
|
-
invalid("perspective", "none") ||
|
|
62
|
-
s["isolation"] === "isolate" ||
|
|
63
|
-
s.position === "fixed" ||
|
|
64
|
-
s.webkitOverflowScrolling === "touch") {
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
el = el.parentElement;
|
|
68
|
-
}
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
50
|
/**
|
|
72
51
|
* Finds the nearest <dialog> from the passed element.
|
|
73
52
|
*
|
|
@@ -409,11 +388,6 @@ dialogPolyfillInfo.prototype = /** @type {HTMLDialogElement.prototype} */ {
|
|
|
409
388
|
if (!dialogPolyfill.dm.pushDialog(this)) {
|
|
410
389
|
throw new Error("Failed to execute 'showModal' on dialog: There are too many open modal dialogs.");
|
|
411
390
|
}
|
|
412
|
-
if (createsStackingContext(this.dialog_.parentElement)) {
|
|
413
|
-
console.warn("A dialog is being shown inside a stacking context. " +
|
|
414
|
-
"This may cause it to be unusable. For more information, see this link: " +
|
|
415
|
-
"https://github.com/GoogleChrome/dialog-polyfill/#stacking-context");
|
|
416
|
-
}
|
|
417
391
|
this.setOpen(true);
|
|
418
392
|
this.openAsModal_ = true;
|
|
419
393
|
// Optionally center vertically, relative to the current viewport.
|
|
@@ -514,7 +488,7 @@ dialogPolyfill.needsCentering = function (dialog) {
|
|
|
514
488
|
* @param {!Element} element to force upgrade
|
|
515
489
|
*/
|
|
516
490
|
dialogPolyfill.forceRegisterDialog = function (element) {
|
|
517
|
-
if (
|
|
491
|
+
if (element.showModal) {
|
|
518
492
|
console.warn("This browser already supports <dialog>, the polyfill " +
|
|
519
493
|
"may not work correctly", element);
|
|
520
494
|
}
|
|
@@ -726,7 +700,7 @@ dialogPolyfill.DialogManager.prototype.removeDialog = function (dpi) {
|
|
|
726
700
|
}
|
|
727
701
|
this.updateStacking();
|
|
728
702
|
};
|
|
729
|
-
if (
|
|
703
|
+
if (exports.needPolyfill) {
|
|
730
704
|
dialogPolyfill.dm = new dialogPolyfill.DialogManager();
|
|
731
705
|
dialogPolyfill.formSubmitter = null;
|
|
732
706
|
dialogPolyfill.imagemapUseValue = null;
|
|
@@ -735,7 +709,7 @@ if (typeof window !== "undefined" && window.HTMLDialogElement === undefined) {
|
|
|
735
709
|
* Installs global handlers, such as click listers and native method overrides. These are needed
|
|
736
710
|
* even if a no dialog is registered, as they deal with <form method="dialog">.
|
|
737
711
|
*/
|
|
738
|
-
if (
|
|
712
|
+
if (exports.needPolyfill) {
|
|
739
713
|
/**
|
|
740
714
|
* If HTMLFormElement translates method="DIALOG" into 'get', then replace the descriptor with
|
|
741
715
|
* one that returns the correct value.
|
package/esm/button/Button.js
CHANGED
|
@@ -41,7 +41,16 @@ export const Button = forwardRef((_a, ref) => {
|
|
|
41
41
|
}
|
|
42
42
|
}, [loading, children]);
|
|
43
43
|
const filterProps = (disabled !== null && disabled !== void 0 ? disabled : widthOverride) ? omit(rest, ["href"]) : rest;
|
|
44
|
-
return (React.createElement(Component, Object.assign({}, filterProps, { ref: mergedRef,
|
|
44
|
+
return (React.createElement(Component, Object.assign({}, (Component !== "button" ? { role: "button" } : {}), filterProps, { ref: mergedRef, onKeyUp: (e) => {
|
|
45
|
+
var _a;
|
|
46
|
+
(_a = filterProps.onKeyUp) === null || _a === void 0 ? void 0 : _a.call(filterProps, e);
|
|
47
|
+
if (e.key === " " &&
|
|
48
|
+
!disabled &&
|
|
49
|
+
!widthOverride &&
|
|
50
|
+
!e.isDefaultPrevented()) {
|
|
51
|
+
e.currentTarget.click();
|
|
52
|
+
}
|
|
53
|
+
}, className: cl(className, "navds-button", `navds-button--${variant}`, `navds-button--${size}`, {
|
|
45
54
|
"navds-button--loading": widthOverride,
|
|
46
55
|
"navds-button--icon-only": !!icon && !children,
|
|
47
56
|
"navds-button--disabled": disabled !== null && disabled !== void 0 ? disabled : widthOverride,
|
package/esm/button/Button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/button/Button.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MA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,SAAS,KAErD,aAAa,CAAC,CAAC,CAAC,CACf,oBAAC,MAAM,IAAC,IAAI,EAAE,IAAI,GAAI,CACvB,CAAC,CAAC,CAAC,CACF;QACG,IAAI,IAAI,YAAY,KAAK,MAAM,IAAI,CAClC,8BAAM,SAAS,EAAC,oBAAoB,IAAE,IAAI,CAAQ,CACnD;QACA,QAAQ,IAAI,CACX,oBAAC,KAAK,IAAC,EAAE,EAAC,MAAM,EAAC,IAAI,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,IAC1D,QAAQ,CACH,CACT;QACA,IAAI,IAAI,YAAY,KAAK,OAAO,IAAI,CACnC,8BAAM,SAAS,EAAC,oBAAoB,IAAE,IAAI,CAAQ,CACnD,CACA,CACJ,CACS,CACb,CAAC;AACJ,CAAC,CACF,CAAC;AAEJ,eAAe,MAAM,CAAC"}
|
package/esm/date/DateInput.js
CHANGED
|
@@ -46,7 +46,7 @@ const DateInput = forwardRef((props, ref) => {
|
|
|
46
46
|
"navds-sr-only": hideLabel,
|
|
47
47
|
}), id: inputDescriptionId, size: size }, description)),
|
|
48
48
|
React.createElement("div", { className: "navds-date__field-wrapper" },
|
|
49
|
-
React.createElement("input", Object.assign({ ref: ref }, omit(rest, ["error", "errorId", "size"]), inputProps, { autoComplete: "off", "aria-controls": ariaId, readOnly: readOnly, className: cl("navds-date__field-input", "navds-text-field__input", "navds-body-short", `navds-body-${size}`), size: 14 })),
|
|
49
|
+
React.createElement("input", Object.assign({ ref: ref }, omit(rest, ["error", "errorId", "size"]), inputProps, { autoComplete: "off", "aria-controls": open ? ariaId : undefined, readOnly: readOnly, className: cl("navds-date__field-input", "navds-text-field__input", "navds-body-short", `navds-body-${size}`), size: 14 })),
|
|
50
50
|
React.createElement("button", { disabled: inputProps.disabled || readOnly, tabIndex: readOnly ? -1 : open ? -1 : 0, onClick: () => onOpen(), type: "button", className: "navds-date__field-button" },
|
|
51
51
|
React.createElement(CalendarIcon, { pointerEvents: "none", title: open
|
|
52
52
|
? conditionalVariables.iconTitle.close
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateInput.js","sourceRoot":"","sources":["../../src/date/DateInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAuB,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1D,OAAO,EAAkB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAyBpD,MAAM,SAAS,GAAG,UAAU,CAAmC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IAC5E,MAAM,EACJ,SAAS,EACT,SAAS,GAAG,KAAK,EACjB,KAAK,EACL,WAAW,EACX,OAAO,GAAG,YAAY,KAEpB,KAAK,EADJ,IAAI,UACL,KAAK,EAPH,6DAOL,CAAQ,CAAC;IAEV,MAAM,mBAAmB,GAAG,OAAO,KAAK,YAAY,CAAC;IAErD,MAAM,oBAAoB,GAAG;QAC3B,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,mBAAmB;QACtE,SAAS,EAAE;YACT,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,mBAAmB;YACnE,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,mBAAmB;SACrE;KACF,CAAC;IAEF,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,mBAAmB,EAAE,CAAC;IAEvD,MAAM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YACF,gCACE,QAAQ,EAAE,UAAU,CAAC,QAAQ,IAAI,QAAQ,EACzC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACvC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,EACvB,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,0BAA0B;gBAEpC,oBAAC,YAAY,IACX,aAAa,EAAC,MAAM,EACpB,KAAK,EACH,IAAI;wBACF,CAAC,CAAC,oBAAoB,CAAC,SAAS,CAAC,KAAK;wBACtC,CAAC,CAAC,oBAAoB,CAAC,SAAS,CAAC,IAAI,GAEzC,CACK,CACL;QACN,6BACE,SAAS,EAAC,yBAAyB,EACnC,EAAE,EAAE,OAAO,mBACG,oBAAoB,eACxB,QAAQ,IAEjB,YAAY,IAAI,oBAAC,YAAY,IAAC,IAAI,EAAE,IAAI,IAAG,KAAK,CAAC,KAAK,CAAgB,CACnE,CACF,CACP,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CACvC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,oBAAC,SAAS,oBAAK,KAAK,IAAE,GAAG,EAAE,GAAG,IAAI,CACnD,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CACxC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,oBAAC,SAAS,oBAAK,KAAK,IAAE,OAAO,EAAC,aAAa,EAAC,GAAG,EAAE,GAAG,IAAI,CACzE,CAAC"}
|
|
@@ -7,14 +7,20 @@ import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsCon
|
|
|
7
7
|
import { useInputContext } from "../Input/inputContext";
|
|
8
8
|
const FilteredOptions = () => {
|
|
9
9
|
const { inputProps: { id }, size, value, } = useInputContext();
|
|
10
|
-
const { allowNewValues, isLoading, isListOpen, filteredOptions, filteredOptionsIndex, filteredOptionsRef, isValueNew, toggleIsListOpen, } = useFilteredOptionsContext();
|
|
10
|
+
const { allowNewValues, isLoading, isListOpen, filteredOptions, filteredOptionsIndex, filteredOptionsRef, isMouseLastUsedInputDevice, setIsMouseLastUsedInputDevice, isValueNew, setFilteredOptionsIndex, toggleIsListOpen, } = useFilteredOptionsContext();
|
|
11
11
|
const { isMultiSelect, selectedOptions, toggleOption } = useSelectedOptionsContext();
|
|
12
12
|
return (React.createElement("ul", { ref: filteredOptionsRef, className: cl("navds-combobox__list", {
|
|
13
13
|
"navds-combobox__list--closed": !isListOpen,
|
|
14
|
+
"navds-combobox__list--with-hover": isMouseLastUsedInputDevice,
|
|
14
15
|
}), id: `${id}-filtered-options`, role: "listbox", tabIndex: -1 },
|
|
15
16
|
isLoading && (React.createElement("li", { className: "navds-combobox__list-item--loading", role: "option", "aria-selected": false, id: `${id}-is-loading` },
|
|
16
17
|
React.createElement(Loader, { "aria-label": "S\u00F8ker..." }))),
|
|
17
|
-
isValueNew && allowNewValues && (React.createElement("li", { tabIndex: -1,
|
|
18
|
+
isValueNew && allowNewValues && (React.createElement("li", { tabIndex: -1, onMouseMove: () => {
|
|
19
|
+
if (filteredOptionsIndex !== -1) {
|
|
20
|
+
setFilteredOptionsIndex(-1);
|
|
21
|
+
setIsMouseLastUsedInputDevice(true);
|
|
22
|
+
}
|
|
23
|
+
}, onPointerUp: (event) => {
|
|
18
24
|
toggleOption(value, event);
|
|
19
25
|
if (!isMultiSelect && !selectedOptions.includes(value))
|
|
20
26
|
toggleIsListOpen(false);
|
|
@@ -33,7 +39,12 @@ const FilteredOptions = () => {
|
|
|
33
39
|
filteredOptions.map((option, index) => (React.createElement("li", { className: cl("navds-combobox__list-item", {
|
|
34
40
|
"navds-combobox__list-item--focus": index === filteredOptionsIndex,
|
|
35
41
|
"navds-combobox__list-item--selected": selectedOptions.includes(option),
|
|
36
|
-
}), id: `${id}-option-${option.replace(" ", "-")}`, key: option, tabIndex: -1,
|
|
42
|
+
}), id: `${id}-option-${option.replace(" ", "-")}`, key: option, tabIndex: -1, onMouseMove: () => {
|
|
43
|
+
if (filteredOptionsIndex !== index) {
|
|
44
|
+
setFilteredOptionsIndex(index);
|
|
45
|
+
setIsMouseLastUsedInputDevice(true);
|
|
46
|
+
}
|
|
47
|
+
}, onPointerUp: (event) => {
|
|
37
48
|
toggleOption(option, event);
|
|
38
49
|
if (!isMultiSelect && !selectedOptions.includes(option))
|
|
39
50
|
toggleIsListOpen(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilteredOptions.js","sourceRoot":"","sources":["../../../../src/form/combobox/FilteredOptions/FilteredOptions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,eAAe,GAAG,GAAG,EAAE;IAC3B,MAAM,EACJ,UAAU,EAAE,EAAE,EAAE,EAAE,EAClB,IAAI,EACJ,KAAK,GACN,GAAG,eAAe,EAAE,CAAC;IACtB,MAAM,EACJ,cAAc,EACd,SAAS,EACT,UAAU,EACV,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,EACV,gBAAgB,GACjB,GAAG,yBAAyB,EAAE,CAAC;IAChC,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,GACpD,yBAAyB,EAAE,CAAC;IAE9B,OAAO,CACL,4BACE,GAAG,EAAE,kBAAkB,EACvB,SAAS,EAAE,EAAE,CAAC,sBAAsB,EAAE;YACpC,8BAA8B,EAAE,CAAC,UAAU;
|
|
1
|
+
{"version":3,"file":"FilteredOptions.js","sourceRoot":"","sources":["../../../../src/form/combobox/FilteredOptions/FilteredOptions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,eAAe,GAAG,GAAG,EAAE;IAC3B,MAAM,EACJ,UAAU,EAAE,EAAE,EAAE,EAAE,EAClB,IAAI,EACJ,KAAK,GACN,GAAG,eAAe,EAAE,CAAC;IACtB,MAAM,EACJ,cAAc,EACd,SAAS,EACT,UAAU,EACV,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,0BAA0B,EAC1B,6BAA6B,EAC7B,UAAU,EACV,uBAAuB,EACvB,gBAAgB,GACjB,GAAG,yBAAyB,EAAE,CAAC;IAChC,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,GACpD,yBAAyB,EAAE,CAAC;IAE9B,OAAO,CACL,4BACE,GAAG,EAAE,kBAAkB,EACvB,SAAS,EAAE,EAAE,CAAC,sBAAsB,EAAE;YACpC,8BAA8B,EAAE,CAAC,UAAU;YAC3C,kCAAkC,EAAE,0BAA0B;SAC/D,CAAC,EACF,EAAE,EAAE,GAAG,EAAE,mBAAmB,EAC5B,IAAI,EAAC,SAAS,EACd,QAAQ,EAAE,CAAC,CAAC;QAEX,SAAS,I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K,EAAE,EAAE,CAAC,CACtC,4BACE,SAAS,EAAE,EAAE,CAAC,2BAA2B,EAAE;gBACzC,kCAAkC,EAAE,KAAK,KAAK,oBAAoB;gBAClE,qCAAqC,EACnC,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC;aACnC,CAAC,EACF,EAAE,EAAE,GAAG,EAAE,WAAW,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAC9C,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,CAAC,CAAC,EACZ,WAAW,EAAE,GAAG,EAAE;gBAChB,IAAI,oBAAoB,KAAK,KAAK,EAAE;oBAClC,uBAAuB,CAAC,KAAK,CAAC,CAAC;oBAC/B,6BAA6B,CAAC,IAAI,CAAC,CAAC;iBACrC;YACH,CAAC,EACD,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;gBACrB,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;gBAC5B,IAAI,CAAC,aAAa,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC;oBACrD,gBAAgB,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC,EACD,IAAI,EAAC,QAAQ,mBACE,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC;YAE/C,oBAAC,SAAS,IAAC,IAAI,EAAE,IAAI,IAAG,MAAM,CAAa;YAC1C,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,oBAAC,aAAa,OAAG,CACnD,CACN,CAAC,CACC,CACN,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { SetStateAction } from "react";
|
|
2
2
|
type FilteredOptionsContextType = {
|
|
3
3
|
activeDecendantId?: string;
|
|
4
4
|
allowNewValues?: boolean;
|
|
@@ -9,6 +9,8 @@ type FilteredOptionsContextType = {
|
|
|
9
9
|
isListOpen: boolean;
|
|
10
10
|
isLoading?: boolean;
|
|
11
11
|
filteredOptions: string[];
|
|
12
|
+
isMouseLastUsedInputDevice: boolean;
|
|
13
|
+
setIsMouseLastUsedInputDevice: React.Dispatch<SetStateAction<boolean>>;
|
|
12
14
|
isValueNew: boolean;
|
|
13
15
|
toggleIsListOpen: (newState?: boolean) => void;
|
|
14
16
|
currentOption: string | null;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React, { useState, useEffect, useMemo, createContext, useContext, useCallback, useRef,
|
|
1
|
+
import React, { useState, useEffect, useMemo, createContext, useContext, useCallback, useRef, } from "react";
|
|
2
2
|
import cl from "clsx";
|
|
3
3
|
import { useCustomOptionsContext } from "../customOptionsContext";
|
|
4
4
|
import { useInputContext } from "../Input/inputContext";
|
|
5
5
|
import usePrevious from "../../../util/usePrevious";
|
|
6
|
+
import { useClientLayoutEffect } from "../../../util";
|
|
6
7
|
const normalizeText = (text) => typeof text === "string" ? `${text}`.toLowerCase().trim() : "";
|
|
7
8
|
const isPartOfText = (value, text) => normalizeText(text).startsWith(normalizeText(value !== null && value !== void 0 ? value : ""));
|
|
8
9
|
const isValueInList = (value, list) => list === null || list === void 0 ? void 0 : list.find((listItem) => normalizeText(value) === normalizeText(listItem));
|
|
@@ -24,7 +25,8 @@ export const FilteredOptionsProvider = ({ children, value: props }) => {
|
|
|
24
25
|
return getMatchingValuesFromList(searchTerm, opts);
|
|
25
26
|
}, [customOptions, externalFilteredOptions, options, searchTerm]);
|
|
26
27
|
const previousSearchTerm = usePrevious(searchTerm);
|
|
27
|
-
|
|
28
|
+
const [isMouseLastUsedInputDevice, setIsMouseLastUsedInputDevice] = useState(false);
|
|
29
|
+
useClientLayoutEffect(() => {
|
|
28
30
|
if (shouldAutocomplete &&
|
|
29
31
|
normalizeText(searchTerm) !== "" &&
|
|
30
32
|
((previousSearchTerm === null || previousSearchTerm === void 0 ? void 0 : previousSearchTerm.length) || 0) < searchTerm.length &&
|
|
@@ -164,6 +166,8 @@ export const FilteredOptionsProvider = ({ children, value: props }) => {
|
|
|
164
166
|
isListOpen,
|
|
165
167
|
isLoading,
|
|
166
168
|
filteredOptions,
|
|
169
|
+
isMouseLastUsedInputDevice,
|
|
170
|
+
setIsMouseLastUsedInputDevice,
|
|
167
171
|
isValueNew,
|
|
168
172
|
toggleIsListOpen,
|
|
169
173
|
currentOption,
|