@navikt/ds-react 6.17.0 → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/form/combobox/FilteredOptions/filtered-options-util.js +1 -3
- package/cjs/form/combobox/FilteredOptions/filtered-options-util.js.map +1 -1
- package/cjs/form/error-summary/ErrorSummary.d.ts +4 -3
- package/cjs/form/error-summary/ErrorSummary.js +12 -8
- package/cjs/form/error-summary/ErrorSummary.js.map +1 -1
- package/cjs/form/error-summary/ErrorSummaryItem.d.ts +1 -1
- package/cjs/form/error-summary/ErrorSummaryItem.js +2 -1
- package/cjs/form/error-summary/ErrorSummaryItem.js.map +1 -1
- package/cjs/provider/i18n/LanguageProvider.d.ts +26 -0
- package/cjs/provider/i18n/LanguageProvider.js +54 -0
- package/cjs/provider/i18n/LanguageProvider.js.map +1 -0
- package/cjs/tooltip/Tooltip.d.ts +8 -2
- package/cjs/tooltip/Tooltip.js +11 -8
- package/cjs/tooltip/Tooltip.js.map +1 -1
- package/cjs/util/i18n/i18n.context.d.ts +1 -2
- package/cjs/util/i18n/i18n.context.js +3 -7
- package/cjs/util/i18n/i18n.context.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/filtered-options-util.js +1 -3
- package/esm/form/combobox/FilteredOptions/filtered-options-util.js.map +1 -1
- package/esm/form/error-summary/ErrorSummary.d.ts +4 -3
- package/esm/form/error-summary/ErrorSummary.js +14 -10
- package/esm/form/error-summary/ErrorSummary.js.map +1 -1
- package/esm/form/error-summary/ErrorSummaryItem.d.ts +1 -1
- package/esm/form/error-summary/ErrorSummaryItem.js +2 -1
- package/esm/form/error-summary/ErrorSummaryItem.js.map +1 -1
- package/esm/provider/i18n/LanguageProvider.d.ts +26 -0
- package/esm/provider/i18n/LanguageProvider.js +23 -0
- package/esm/provider/i18n/LanguageProvider.js.map +1 -0
- package/esm/tooltip/Tooltip.d.ts +8 -2
- package/esm/tooltip/Tooltip.js +12 -9
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/esm/util/i18n/i18n.context.d.ts +1 -2
- package/esm/util/i18n/i18n.context.js +4 -4
- package/esm/util/i18n/i18n.context.js.map +1 -1
- package/package.json +3 -3
- package/src/form/combobox/FilteredOptions/filtered-options-util.test.ts +18 -0
- package/src/form/combobox/FilteredOptions/filtered-options-util.ts +1 -3
- package/src/form/error-summary/ErrorSummary.tsx +23 -13
- package/src/form/error-summary/ErrorSummaryItem.tsx +10 -8
- package/src/provider/i18n/LanguageProvider.tsx +49 -0
- package/src/tooltip/Tooltip.tsx +26 -15
- package/src/util/i18n/i18n.context.test.tsx +9 -6
- package/src/util/i18n/i18n.context.ts +5 -11
|
@@ -7,9 +7,7 @@ const getFirstValueStartingWith = (text, list) => {
|
|
|
7
7
|
return list.find((listItem) => normalizeText(listItem.label).startsWith(text.toLocaleLowerCase()));
|
|
8
8
|
};
|
|
9
9
|
const getFilteredOptionsId = (comboboxId) => `${comboboxId}-filtered-options`;
|
|
10
|
-
const getOptionId = (comboboxId, option) => `${comboboxId
|
|
11
|
-
.replace(" ", "-")
|
|
12
|
-
.toLocaleLowerCase()}`;
|
|
10
|
+
const getOptionId = (comboboxId, option) => `${comboboxId}-option-${option}`.replace(/\s/g, "-").toLocaleLowerCase();
|
|
13
11
|
const getAddNewOptionId = (comboboxId) => `${comboboxId}-combobox-new-option`;
|
|
14
12
|
const getIsLoadingId = (comboboxId) => `${comboboxId}-is-loading`;
|
|
15
13
|
const getNoHitsId = (comboboxId) => `${comboboxId}-no-hits`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filtered-options-util.js","sourceRoot":"","sources":["../../../../src/form/combobox/FilteredOptions/filtered-options-util.ts"],"names":[],"mappings":";;AAEA,MAAM,aAAa,GAAG,CAAC,IAAY,EAAU,EAAE,CAC7C,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,E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|
|
|
1
1
|
import React, { HTMLAttributes } from "react";
|
|
2
|
-
import
|
|
3
|
-
export interface ErrorSummaryProps extends HTMLAttributes<HTMLDivElement> {
|
|
2
|
+
import ErrorSummaryItem from "./ErrorSummaryItem";
|
|
3
|
+
export interface ErrorSummaryProps extends Omit<HTMLAttributes<HTMLDivElement>, "tabIndex"> {
|
|
4
4
|
/**
|
|
5
5
|
* Collection of `ErrorSummary.Item`.
|
|
6
6
|
*/
|
|
@@ -12,6 +12,7 @@ export interface ErrorSummaryProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
12
12
|
size?: "medium" | "small";
|
|
13
13
|
/**
|
|
14
14
|
* Heading above links.
|
|
15
|
+
* @default "Du må rette disse feilene før du kan fortsette:"
|
|
15
16
|
*/
|
|
16
17
|
heading?: React.ReactNode;
|
|
17
18
|
/**
|
|
@@ -33,7 +34,7 @@ interface ErrorSummaryComponent extends React.ForwardRefExoticComponent<ErrorSum
|
|
|
33
34
|
* </ErrorSummary.Item>
|
|
34
35
|
* ```
|
|
35
36
|
*/
|
|
36
|
-
Item:
|
|
37
|
+
Item: typeof ErrorSummaryItem;
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
39
40
|
* A component that displays a summary of errors.
|
|
@@ -41,6 +41,7 @@ exports.ErrorSummary = void 0;
|
|
|
41
41
|
const clsx_1 = __importDefault(require("clsx"));
|
|
42
42
|
const react_1 = __importStar(require("react"));
|
|
43
43
|
const typography_1 = require("../../typography");
|
|
44
|
+
const composeEventHandlers_1 = require("../../util/composeEventHandlers");
|
|
44
45
|
const hooks_1 = require("../../util/hooks");
|
|
45
46
|
const ErrorSummaryItem_1 = __importDefault(require("./ErrorSummaryItem"));
|
|
46
47
|
/**
|
|
@@ -62,16 +63,19 @@ const ErrorSummaryItem_1 = __importDefault(require("./ErrorSummaryItem"));
|
|
|
62
63
|
* ```
|
|
63
64
|
*/
|
|
64
65
|
exports.ErrorSummary = (0, react_1.forwardRef)((_a, ref) => {
|
|
65
|
-
var { children, className, size = "medium", headingTag = "h2", heading } = _a, rest = __rest(_a, ["children", "className", "size", "headingTag", "heading"]);
|
|
66
|
+
var { children, className, size = "medium", headingTag = "h2", heading = "Du må rette disse feilene før du kan fortsette:" } = _a, rest = __rest(_a, ["children", "className", "size", "headingTag", "heading"]);
|
|
66
67
|
const headingId = (0, hooks_1.useId)();
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
const sectionRef = (0, react_1.useRef)(null);
|
|
69
|
+
const headingRef = (0, react_1.useRef)(null);
|
|
70
|
+
const mergedRef = (0, hooks_1.useMergeRefs)(ref, sectionRef);
|
|
71
|
+
return (react_1.default.createElement("section", Object.assign({ ref: mergedRef }, rest, { className: (0, clsx_1.default)(className, "navds-error-summary", `navds-error-summary--${size}`), tabIndex: -1, "aria-live": "polite", "aria-relevant": "all", "aria-labelledby": headingId, onFocus: (0, composeEventHandlers_1.composeEventHandlers)(rest.onFocus, (event) => {
|
|
72
|
+
var _a;
|
|
73
|
+
if (event.target === sectionRef.current) {
|
|
74
|
+
(_a = headingRef === null || headingRef === void 0 ? void 0 : headingRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
72
75
|
}
|
|
73
|
-
|
|
74
|
-
})
|
|
76
|
+
}) }),
|
|
77
|
+
react_1.default.createElement(typography_1.Heading, { className: "navds-error-summary__heading", as: headingTag, size: "small", id: headingId, ref: headingRef, tabIndex: -1 }, heading),
|
|
78
|
+
react_1.default.createElement(typography_1.BodyShort, { as: "ul", size: size, className: "navds-error-summary__list" }, children)));
|
|
75
79
|
});
|
|
76
80
|
exports.ErrorSummary.Item = ErrorSummaryItem_1.default;
|
|
77
81
|
exports.default = exports.ErrorSummary;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorSummary.js","sourceRoot":"","sources":["../../../src/form/error-summary/ErrorSummary.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AC,oBAAO,IACN,SAAS,EAAC,8BAA8B,EACxC,EAAE,EAAE,UAAU,EACd,IAAI,EAAC,OAAO,EACZ,EAAE,EAAE,SAAS,EACb,GAAG,EAAE,UAAU,EACf,QAAQ,EAAE,CAAC,CAAC,IAEX,OAAO,CACA;QACV,8BAAC,sBAAS,IAAC,EAAE,EAAC,IAAI,EAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAC,2BAA2B,IACjE,QAAQ,CACC,CACJ,CACX,CAAC;AACJ,CAAC,CACuB,CAAC;AAE3B,oBAAY,CAAC,IAAI,GAAG,0BAAgB,CAAC;AAErC,kBAAe,oBAAY,CAAC"}
|
|
@@ -10,6 +10,6 @@ export interface ErrorSummaryItemProps extends React.AnchorHTMLAttributes<HTMLAn
|
|
|
10
10
|
*/
|
|
11
11
|
href?: string;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
type ErrorSummaryItemType = OverridableComponent<ErrorSummaryItemProps, HTMLAnchorElement>;
|
|
14
14
|
export declare const ErrorSummaryItem: ErrorSummaryItemType;
|
|
15
15
|
export default ErrorSummaryItem;
|
|
@@ -42,7 +42,8 @@ const clsx_1 = __importDefault(require("clsx"));
|
|
|
42
42
|
const react_1 = __importStar(require("react"));
|
|
43
43
|
exports.ErrorSummaryItem = (0, react_1.forwardRef)((_a, ref) => {
|
|
44
44
|
var { children, as: Component = "a", className } = _a, rest = __rest(_a, ["children", "as", "className"]);
|
|
45
|
-
return (react_1.default.createElement(
|
|
45
|
+
return (react_1.default.createElement("li", null,
|
|
46
|
+
react_1.default.createElement(Component, Object.assign({}, rest, { ref: ref, className: (0, clsx_1.default)(className, "navds-error-summary__item", "navds-link") }), children)));
|
|
46
47
|
});
|
|
47
48
|
exports.default = exports.ErrorSummaryItem;
|
|
48
49
|
//# sourceMappingURL=ErrorSummaryItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorSummaryItem.js","sourceRoot":"","sources":["../../../src/form/error-summary/ErrorSummaryItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAsB;AACtB,+CAA0C;AAoB7B,QAAA,gBAAgB,GAAyB,IAAA,kBAAU,EAC9D,CAAC,EAAqD,EAAE,GAAG,EAAE,EAAE;QAA9D,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,GAAG,GAAG,EAAE,SAAS,OAAW,EAAN,IAAI,cAAnD,+BAAqD,CAAF;IAClD,OAAO,CACL,8BAAC,SAAS,oBACJ,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,IAAA,cAAE,EAAC,SAAS,EAAE,2BAA2B,EAAE,YAAY,CAAC,KAElE,QAAQ,CACC,
|
|
1
|
+
{"version":3,"file":"ErrorSummaryItem.js","sourceRoot":"","sources":["../../../src/form/error-summary/ErrorSummaryItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAsB;AACtB,+CAA0C;AAoB7B,QAAA,gBAAgB,GAAyB,IAAA,kBAAU,EAC9D,CAAC,EAAqD,EAAE,GAAG,EAAE,EAAE;QAA9D,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,GAAG,GAAG,EAAE,SAAS,OAAW,EAAN,IAAI,cAAnD,+BAAqD,CAAF;IAClD,OAAO,CACL;QACE,8BAAC,SAAS,oBACJ,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,IAAA,cAAE,EAAC,SAAS,EAAE,2BAA2B,EAAE,YAAY,CAAC,KAElE,QAAQ,CACC,CACT,CACN,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,kBAAe,wBAAgB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TranslationDictionary } from "../../util/i18n/i18n.types";
|
|
3
|
+
export interface LanguageProviderContextType {
|
|
4
|
+
/**
|
|
5
|
+
* Merged with the default language translations object (officially provided translations).
|
|
6
|
+
*/
|
|
7
|
+
translations: TranslationDictionary | TranslationDictionary[];
|
|
8
|
+
}
|
|
9
|
+
export declare const LanguageProviderContext: React.Context<LanguageProviderContextType>;
|
|
10
|
+
export interface LanguageProviderProps {
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
translations?: TranslationDictionary | TranslationDictionary[];
|
|
13
|
+
}
|
|
14
|
+
export declare const useProvider: () => LanguageProviderContextType;
|
|
15
|
+
/**
|
|
16
|
+
* @private Feature is under development and should not be used in any applications.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```jsx
|
|
20
|
+
* <UNSAFE_AkselLanguageProvider translations={{...}}>
|
|
21
|
+
* {app}
|
|
22
|
+
* </UNSAFE_AkselLanguageProvider>
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare const UNSAFE_AkselLanguageProvider: ({ children, translations, }: LanguageProviderProps) => React.JSX.Element;
|
|
26
|
+
export default UNSAFE_AkselLanguageProvider;
|
|
@@ -0,0 +1,54 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.UNSAFE_AkselLanguageProvider = exports.useProvider = exports.LanguageProviderContext = void 0;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const nb_1 = __importDefault(require("../../util/i18n/locales/nb"));
|
|
32
|
+
exports.LanguageProviderContext = (0, react_1.createContext)({
|
|
33
|
+
translations: nb_1.default,
|
|
34
|
+
});
|
|
35
|
+
const useProvider = () => (0, react_1.useContext)(exports.LanguageProviderContext);
|
|
36
|
+
exports.useProvider = useProvider;
|
|
37
|
+
/**
|
|
38
|
+
* @private Feature is under development and should not be used in any applications.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```jsx
|
|
42
|
+
* <UNSAFE_AkselLanguageProvider translations={{...}}>
|
|
43
|
+
* {app}
|
|
44
|
+
* </UNSAFE_AkselLanguageProvider>
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
const UNSAFE_AkselLanguageProvider = ({ children, translations, }) => {
|
|
48
|
+
return (react_1.default.createElement(exports.LanguageProviderContext.Provider, { value: {
|
|
49
|
+
translations: translations !== null && translations !== void 0 ? translations : nb_1.default,
|
|
50
|
+
} }, children));
|
|
51
|
+
};
|
|
52
|
+
exports.UNSAFE_AkselLanguageProvider = UNSAFE_AkselLanguageProvider;
|
|
53
|
+
exports.default = exports.UNSAFE_AkselLanguageProvider;
|
|
54
|
+
//# sourceMappingURL=LanguageProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LanguageProvider.js","sourceRoot":"","sources":["../../../src/provider/i18n/LanguageProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAyD;AAEzD,oEAA4C;AAS/B,QAAA,uBAAuB,GAClC,IAAA,qBAAa,EAA8B;IACzC,YAAY,EAAE,YAAE;CACjB,CAAC,CAAC;AAOE,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,IAAA,kBAAU,EAAC,+BAAuB,CAAC,CAAC;AAAxD,QAAA,WAAW,eAA6C;AAErE;;;;;;;;;GASG;AACI,MAAM,4BAA4B,GAAG,CAAC,EAC3C,QAAQ,EACR,YAAY,GACU,EAAE,EAAE;IAC1B,OAAO,CACL,8BAAC,+BAAuB,CAAC,QAAQ,IAC/B,KAAK,EAAE;YACL,YAAY,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,YAAE;SACjC,IAEA,QAAQ,CACwB,CACpC,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,4BAA4B,gCAavC;AAEF,kBAAe,oCAA4B,CAAC"}
|
package/cjs/tooltip/Tooltip.d.ts
CHANGED
|
@@ -59,6 +59,12 @@ export interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
59
59
|
* List of Keyboard-keys for shortcuts.
|
|
60
60
|
*/
|
|
61
61
|
keys?: string[];
|
|
62
|
+
/**
|
|
63
|
+
* When false, Tooltip labels the element, and child-elements content will be ignored by screen-readers.
|
|
64
|
+
* When true, content is added as additional information to the child element.
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
describesChild?: boolean;
|
|
62
68
|
}
|
|
63
69
|
/**
|
|
64
70
|
* A component that displays a tooltip when the user hovers over its child element.
|
|
@@ -67,9 +73,9 @@ export interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
67
73
|
* @see 🏷️ {@link TooltipProps}
|
|
68
74
|
*
|
|
69
75
|
* @example
|
|
70
|
-
* ```jsx
|
|
76
|
+
* ```jsx Tooltip as only form of labeling
|
|
71
77
|
* <Tooltip content="Skriv ut dokument">
|
|
72
|
-
* <Button icon={<PrinterLargeIcon
|
|
78
|
+
* <Button icon={<PrinterLargeIcon aria-hidden />} />
|
|
73
79
|
* </Tooltip>
|
|
74
80
|
* ```
|
|
75
81
|
*/
|
package/cjs/tooltip/Tooltip.js
CHANGED
|
@@ -43,6 +43,7 @@ const clsx_1 = __importDefault(require("clsx"));
|
|
|
43
43
|
const react_2 = __importStar(require("react"));
|
|
44
44
|
const Modal_context_1 = require("../modal/Modal.context");
|
|
45
45
|
const portal_1 = require("../portal");
|
|
46
|
+
const Slot_1 = require("../slot/Slot");
|
|
46
47
|
const typography_1 = require("../typography");
|
|
47
48
|
const hooks_1 = require("../util/hooks");
|
|
48
49
|
const useControllableState_1 = require("../util/hooks/useControllableState");
|
|
@@ -54,14 +55,14 @@ const useMergeRefs_1 = require("../util/hooks/useMergeRefs");
|
|
|
54
55
|
* @see 🏷️ {@link TooltipProps}
|
|
55
56
|
*
|
|
56
57
|
* @example
|
|
57
|
-
* ```jsx
|
|
58
|
+
* ```jsx Tooltip as only form of labeling
|
|
58
59
|
* <Tooltip content="Skriv ut dokument">
|
|
59
|
-
* <Button icon={<PrinterLargeIcon
|
|
60
|
+
* <Button icon={<PrinterLargeIcon aria-hidden />} />
|
|
60
61
|
* </Tooltip>
|
|
61
62
|
* ```
|
|
62
63
|
*/
|
|
63
64
|
exports.Tooltip = (0, react_2.forwardRef)((_a, ref) => {
|
|
64
|
-
var { children, className, arrow: _arrow = true, placement: _placement = "top", open, defaultOpen = false, onOpenChange, offset: _offset, content, delay = 150, id, keys, maxChar = 80 } = _a, rest = __rest(_a, ["children", "className", "arrow", "placement", "open", "defaultOpen", "onOpenChange", "offset", "content", "delay", "id", "keys", "maxChar"]);
|
|
65
|
+
var { children, className, arrow: _arrow = true, placement: _placement = "top", open, defaultOpen = false, onOpenChange, offset: _offset, content, delay = 150, id, keys, maxChar = 80, describesChild = false } = _a, rest = __rest(_a, ["children", "className", "arrow", "placement", "open", "defaultOpen", "onOpenChange", "offset", "content", "delay", "id", "keys", "maxChar", "describesChild"]);
|
|
65
66
|
const [_open, _setOpen] = (0, useControllableState_1.useControllableState)({
|
|
66
67
|
defaultValue: defaultOpen,
|
|
67
68
|
value: open,
|
|
@@ -95,7 +96,6 @@ exports.Tooltip = (0, react_2.forwardRef)((_a, ref) => {
|
|
|
95
96
|
]);
|
|
96
97
|
const ariaId = (0, hooks_1.useId)(id);
|
|
97
98
|
const mergedRef = (0, useMergeRefs_1.useMergeRefs)(ref, refs.setFloating);
|
|
98
|
-
const childMergedRef = (0, useMergeRefs_1.useMergeRefs)(children.ref, refs.setReference);
|
|
99
99
|
if (!children ||
|
|
100
100
|
(children === null || children === void 0 ? void 0 : children.type) === react_2.default.Fragment ||
|
|
101
101
|
children === react_2.default.Fragment) {
|
|
@@ -106,10 +106,13 @@ exports.Tooltip = (0, react_2.forwardRef)((_a, ref) => {
|
|
|
106
106
|
_open &&
|
|
107
107
|
console.warn(`Because of strict accessibility concers we encourage all Tooltips to have less than 80 characters. Can be overwritten with the maxChar-prop\n\nLength:${content.length}\nTooltip-content: ${content}`);
|
|
108
108
|
}
|
|
109
|
+
const labelProps = describesChild
|
|
110
|
+
? _open
|
|
111
|
+
? { "aria-describedby": ariaId }
|
|
112
|
+
: { title: content }
|
|
113
|
+
: { "aria-label": content };
|
|
109
114
|
return (react_2.default.createElement(react_2.default.Fragment, null,
|
|
110
|
-
|
|
111
|
-
? (0, clsx_1.default)(ariaId, children === null || children === void 0 ? void 0 : children.props["aria-describedby"])
|
|
112
|
-
: children === null || children === void 0 ? void 0 : children.props["aria-describedby"] }))),
|
|
115
|
+
react_2.default.createElement(Slot_1.Slot, Object.assign({ ref: refs.setReference }, getReferenceProps(), labelProps, { "aria-keyshortcuts": keys ? keys.join("+") : undefined }), children),
|
|
113
116
|
react_2.default.createElement(portal_1.Portal, { rootElement: rootElement, asChild: true }, _open && (react_2.default.createElement("div", Object.assign({}, getFloatingProps(Object.assign(Object.assign({}, rest), { ref: mergedRef, style: {
|
|
114
117
|
position: strategy,
|
|
115
118
|
top: y !== null && y !== void 0 ? y : 0,
|
|
@@ -117,7 +120,7 @@ exports.Tooltip = (0, react_2.forwardRef)((_a, ref) => {
|
|
|
117
120
|
visibility: referenceHidden ? "hidden" : "visible",
|
|
118
121
|
}, role: "tooltip", id: ariaId, className: (0, clsx_1.default)("navds-tooltip", "navds-detail navds-detail--small", className) })), { "data-side": placement }),
|
|
119
122
|
content,
|
|
120
|
-
keys && (react_2.default.createElement("span", { className: "navds-tooltip__keys" }, keys.map((key) => (react_2.default.createElement(typography_1.Detail, { as: "kbd", key: key, className: "navds-tooltip__key" }, key))))),
|
|
123
|
+
keys && (react_2.default.createElement("span", { className: "navds-tooltip__keys", "aria-hidden": true }, keys.map((key) => (react_2.default.createElement(typography_1.Detail, { as: "kbd", key: key, className: "navds-tooltip__key" }, key))))),
|
|
121
124
|
_arrow && (react_2.default.createElement("div", { ref: (node) => {
|
|
122
125
|
arrowRef.current = node;
|
|
123
126
|
}, className: "navds-tooltip__arrow", style: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAY4B;AAC5B,gDAAsB;AACtB,+
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAY4B;AAC5B,gDAAsB;AACtB,+CAAkE;AAClE,0DAAyD;AACzD,sCAAmC;AACnC,uCAAoC;AACpC,8CAAuC;AACvC,yCAAsC;AACtC,6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C,EAClC,SAAS,CACV,IACD,iBACS,SAAS;YAEnB,OAAO;YACP,IAAI,IAAI,CACP,wCAAM,SAAS,EAAC,qBAAqB,yBAClC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CACjB,8BAAC,mBAAM,IAAC,EAAE,EAAC,KAAK,EAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAC,oBAAoB,IACtD,GAAG,CACG,CACV,CAAC,CACG,CACR;YACA,MAAM,IAAI,CACT,uCACE,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;oBACZ,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;gBAC1B,CAAC,EACD,SAAS,EAAC,sBAAsB,EAChC,KAAK,EAAE;oBACL,IAAI,EAAE,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,CAAC,CAAC,EAAE;oBACzC,GAAG,EAAE,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,CAAC,CAAC,EAAE;oBACxC,KAAK,EAAE,EAAE;oBACT,MAAM,EAAE,EAAE;oBACV,CAAC;wBACC,GAAG,EAAE,QAAQ;wBACb,KAAK,EAAE,MAAM;wBACb,MAAM,EAAE,KAAK;wBACb,IAAI,EAAE,OAAO;qBACd,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ;iBACxB,GACD,CACH,CACG,CACP,CACM,CACR,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,kBAAe,eAAO,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Component, ComponentTranslation
|
|
1
|
+
import { Component, ComponentTranslation } from "./i18n.types";
|
|
2
2
|
import nb from "./locales/nb";
|
|
3
|
-
export declare const I18nContext: import("react").Context<TranslationDictionary | TranslationDictionary[]>;
|
|
4
3
|
type NestedKeyOf<ObjectType extends object> = {
|
|
5
4
|
[Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}.${NestedKeyOf<ObjectType[Key]>}` : `${Key}`;
|
|
6
5
|
}[keyof ObjectType & (string | number)];
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.I18nContext = void 0;
|
|
7
3
|
exports.useI18n = useI18n;
|
|
8
4
|
const react_1 = require("react");
|
|
5
|
+
const LanguageProvider_1 = require("../../provider/i18n/LanguageProvider");
|
|
9
6
|
const get_1 = require("./get");
|
|
10
|
-
const nb_1 = __importDefault(require("./locales/nb"));
|
|
11
7
|
/**
|
|
12
8
|
* https://regex101.com/r/LYKWi3/1
|
|
13
9
|
*/
|
|
14
10
|
const REPLACE_REGEX = /{[^}]*}/g;
|
|
15
|
-
exports.I18nContext = (0, react_1.createContext)(nb_1.default);
|
|
16
11
|
function useI18n(componentName, ...local) {
|
|
17
|
-
const
|
|
12
|
+
const languageProviderContext = (0, react_1.useContext)(LanguageProvider_1.LanguageProviderContext);
|
|
13
|
+
const i18n = languageProviderContext.translations;
|
|
18
14
|
/**
|
|
19
15
|
* https://github.com/Shopify/polaris/blob/2115f9ba2f5bcbf2ad15745233501bff2db81ecf/polaris-react/src/utilities/i18n/I18n.ts#L24
|
|
20
16
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.context.js","sourceRoot":"","sources":["../../../src/util/i18n/i18n.context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"i18n.context.js","sourceRoot":"","sources":["../../../src/util/i18n/i18n.context.ts"],"names":[],"mappings":";;AAkBA,0BA0CC;AA5DD,iCAAmC;AACnC,2EAA+E;AAC/E,+BAA4B;AAI5B;;GAEG;AACH,MAAM,aAAa,GAAG,UAAU,CAAC;AASjC,SAAgB,OAAO,CACrB,aAAgB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= (text, list) => {
|
|
|
5
5
|
return list.find((listItem) => normalizeText(listItem.label).startsWith(text.toLocaleLowerCase()));
|
|
6
6
|
};
|
|
7
7
|
const getFilteredOptionsId = (comboboxId) => `${comboboxId}-filtered-options`;
|
|
8
|
-
const getOptionId = (comboboxId, option) => `${comboboxId
|
|
9
|
-
.replace(" ", "-")
|
|
10
|
-
.toLocaleLowerCase()}`;
|
|
8
|
+
const getOptionId = (comboboxId, option) => `${comboboxId}-option-${option}`.replace(/\s/g, "-").toLocaleLowerCase();
|
|
11
9
|
const getAddNewOptionId = (comboboxId) => `${comboboxId}-combobox-new-option`;
|
|
12
10
|
const getIsLoadingId = (comboboxId) => `${comboboxId}-is-loading`;
|
|
13
11
|
const getNoHitsId = (comboboxId) => `${comboboxId}-no-hits`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filtered-options-util.js","sourceRoot":"","sources":["../../../../src/form/combobox/FilteredOptions/filtered-options-util.ts"],"names":[],"mappings":"AAEA,MAAM,aAAa,GAAG,CAAC,IAAY,EAAU,EAAE,CAC7C,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAElE,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,IAAY,EAAE,EAAE,CACnD,aAAa,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC,CAAC,CAAC;AAE3D,MAAM,yBAAyB,GAAG,CAAC,KAAa,EAAE,IAAsB,EAAE,EAAE,CAC1E,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AAEjE,MAAM,yBAAyB,GAAG,CAAC,IAAY,EAAE,IAAsB,EAAE,EAAE;IACzE,OAA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AC,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAAC,UAAkB,EAAE,EAAE,CAClD,GAAG,UAAU,mBAAmB,CAAC;AAEnC,MAAM,WAAW,GAAG,CAAC,UAAkB,EAAE,MAAc,EAAE,EAAE,CACzD,GAAG,UAAU,WAAW,MAAM,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,iBAAiB,EAAE,CAAC;AAE3E,MAAM,iBAAiB,GAAG,CAAC,UAAkB,EAAE,EAAE,CAC/C,GAAG,UAAU,sBAAsB,CAAC;AAEtC,MAAM,cAAc,GAAG,CAAC,UAAkB,EAAE,EAAE,CAAC,GAAG,UAAU,aAAa,CAAC;AAE1E,MAAM,WAAW,GAAG,CAAC,UAAkB,EAAE,EAAE,CAAC,GAAG,UAAU,UAAU,CAAC;AAEpE,MAAM,uBAAuB,GAAG,CAAC,UAAkB,EAAE,EAAE,CACrD,GAAG,UAAU,uBAAuB,CAAC;AAEvC,eAAe;IACb,aAAa;IACb,YAAY;IACZ,yBAAyB;IACzB,oBAAoB;IACpB,iBAAiB;IACjB,WAAW;IACX,cAAc;IACd,WAAW;IACX,uBAAuB;IACvB,yBAAyB;CAC1B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { HTMLAttributes } from "react";
|
|
2
|
-
import
|
|
3
|
-
export interface ErrorSummaryProps extends HTMLAttributes<HTMLDivElement> {
|
|
2
|
+
import ErrorSummaryItem from "./ErrorSummaryItem.js";
|
|
3
|
+
export interface ErrorSummaryProps extends Omit<HTMLAttributes<HTMLDivElement>, "tabIndex"> {
|
|
4
4
|
/**
|
|
5
5
|
* Collection of `ErrorSummary.Item`.
|
|
6
6
|
*/
|
|
@@ -12,6 +12,7 @@ export interface ErrorSummaryProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
12
12
|
size?: "medium" | "small";
|
|
13
13
|
/**
|
|
14
14
|
* Heading above links.
|
|
15
|
+
* @default "Du må rette disse feilene før du kan fortsette:"
|
|
15
16
|
*/
|
|
16
17
|
heading?: React.ReactNode;
|
|
17
18
|
/**
|
|
@@ -33,7 +34,7 @@ interface ErrorSummaryComponent extends React.ForwardRefExoticComponent<ErrorSum
|
|
|
33
34
|
* </ErrorSummary.Item>
|
|
34
35
|
* ```
|
|
35
36
|
*/
|
|
36
|
-
Item:
|
|
37
|
+
Item: typeof ErrorSummaryItem;
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
39
40
|
* A component that displays a summary of errors.
|
|
@@ -10,9 +10,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import cl from "clsx";
|
|
13
|
-
import React, { forwardRef,
|
|
13
|
+
import React, { forwardRef, useRef } from "react";
|
|
14
14
|
import { BodyShort, Heading } from "../../typography/index.js";
|
|
15
|
-
import {
|
|
15
|
+
import { composeEventHandlers } from "../../util/composeEventHandlers.js";
|
|
16
|
+
import { useId, useMergeRefs } from "../../util/hooks/index.js";
|
|
16
17
|
import ErrorSummaryItem from "./ErrorSummaryItem.js";
|
|
17
18
|
/**
|
|
18
19
|
* A component that displays a summary of errors.
|
|
@@ -33,16 +34,19 @@ import ErrorSummaryItem from "./ErrorSummaryItem.js";
|
|
|
33
34
|
* ```
|
|
34
35
|
*/
|
|
35
36
|
export const ErrorSummary = forwardRef((_a, ref) => {
|
|
36
|
-
var { children, className, size = "medium", headingTag = "h2", heading } = _a, rest = __rest(_a, ["children", "className", "size", "headingTag", "heading"]);
|
|
37
|
+
var { children, className, size = "medium", headingTag = "h2", heading = "Du må rette disse feilene før du kan fortsette:" } = _a, rest = __rest(_a, ["children", "className", "size", "headingTag", "heading"]);
|
|
37
38
|
const headingId = useId();
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
const sectionRef = useRef(null);
|
|
40
|
+
const headingRef = useRef(null);
|
|
41
|
+
const mergedRef = useMergeRefs(ref, sectionRef);
|
|
42
|
+
return (React.createElement("section", Object.assign({ ref: mergedRef }, rest, { className: cl(className, "navds-error-summary", `navds-error-summary--${size}`), tabIndex: -1, "aria-live": "polite", "aria-relevant": "all", "aria-labelledby": headingId, onFocus: composeEventHandlers(rest.onFocus, (event) => {
|
|
43
|
+
var _a;
|
|
44
|
+
if (event.target === sectionRef.current) {
|
|
45
|
+
(_a = headingRef === null || headingRef === void 0 ? void 0 : headingRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
43
46
|
}
|
|
44
|
-
|
|
45
|
-
})
|
|
47
|
+
}) }),
|
|
48
|
+
React.createElement(Heading, { className: "navds-error-summary__heading", as: headingTag, size: "small", id: headingId, ref: headingRef, tabIndex: -1 }, heading),
|
|
49
|
+
React.createElement(BodyShort, { as: "ul", size: size, className: "navds-error-summary__list" }, children)));
|
|
46
50
|
});
|
|
47
51
|
ErrorSummary.Item = ErrorSummaryItem;
|
|
48
52
|
export default ErrorSummary;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorSummary.js","sourceRoot":"","sources":["../../../src/form/error-summary/ErrorSummary.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAkB,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"ErrorSummary.js","sourceRoot":"","sources":["../../../src/form/error-summary/ErrorSummary.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAkB,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,gBAAgB,MAAM,oBAAoB,CAAC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CACJ,CACX,CAAC;AACJ,CAAC,CACuB,CAAC;AAE3B,YAAY,CAAC,IAAI,GAAG,gBAAgB,CAAC;AAErC,eAAe,YAAY,CAAC"}
|
|
@@ -10,6 +10,6 @@ export interface ErrorSummaryItemProps extends React.AnchorHTMLAttributes<HTMLAn
|
|
|
10
10
|
*/
|
|
11
11
|
href?: string;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
type ErrorSummaryItemType = OverridableComponent<ErrorSummaryItemProps, HTMLAnchorElement>;
|
|
14
14
|
export declare const ErrorSummaryItem: ErrorSummaryItemType;
|
|
15
15
|
export default ErrorSummaryItem;
|
|
@@ -13,7 +13,8 @@ import cl from "clsx";
|
|
|
13
13
|
import React, { forwardRef } from "react";
|
|
14
14
|
export const ErrorSummaryItem = forwardRef((_a, ref) => {
|
|
15
15
|
var { children, as: Component = "a", className } = _a, rest = __rest(_a, ["children", "as", "className"]);
|
|
16
|
-
return (React.createElement(
|
|
16
|
+
return (React.createElement("li", null,
|
|
17
|
+
React.createElement(Component, Object.assign({}, rest, { ref: ref, className: cl(className, "navds-error-summary__item", "navds-link") }), children)));
|
|
17
18
|
});
|
|
18
19
|
export default ErrorSummaryItem;
|
|
19
20
|
//# sourceMappingURL=ErrorSummaryItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorSummaryItem.js","sourceRoot":"","sources":["../../../src/form/error-summary/ErrorSummaryItem.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAoB1C,MAAM,CAAC,MAAM,gBAAgB,GAAyB,UAAU,CAC9D,CAAC,EAAqD,EAAE,GAAG,EAAE,EAAE;QAA9D,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,GAAG,GAAG,EAAE,SAAS,OAAW,EAAN,IAAI,cAAnD,+BAAqD,CAAF;IAClD,OAAO,CACL,oBAAC,SAAS,oBACJ,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,2BAA2B,EAAE,YAAY,CAAC,KAElE,QAAQ,CACC,
|
|
1
|
+
{"version":3,"file":"ErrorSummaryItem.js","sourceRoot":"","sources":["../../../src/form/error-summary/ErrorSummaryItem.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAoB1C,MAAM,CAAC,MAAM,gBAAgB,GAAyB,UAAU,CAC9D,CAAC,EAAqD,EAAE,GAAG,EAAE,EAAE;QAA9D,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,GAAG,GAAG,EAAE,SAAS,OAAW,EAAN,IAAI,cAAnD,+BAAqD,CAAF;IAClD,OAAO,CACL;QACE,oBAAC,SAAS,oBACJ,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,2BAA2B,EAAE,YAAY,CAAC,KAElE,QAAQ,CACC,CACT,CACN,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TranslationDictionary } from "../../util/i18n/i18n.types.js";
|
|
3
|
+
export interface LanguageProviderContextType {
|
|
4
|
+
/**
|
|
5
|
+
* Merged with the default language translations object (officially provided translations).
|
|
6
|
+
*/
|
|
7
|
+
translations: TranslationDictionary | TranslationDictionary[];
|
|
8
|
+
}
|
|
9
|
+
export declare const LanguageProviderContext: React.Context<LanguageProviderContextType>;
|
|
10
|
+
export interface LanguageProviderProps {
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
translations?: TranslationDictionary | TranslationDictionary[];
|
|
13
|
+
}
|
|
14
|
+
export declare const useProvider: () => LanguageProviderContextType;
|
|
15
|
+
/**
|
|
16
|
+
* @private Feature is under development and should not be used in any applications.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```jsx
|
|
20
|
+
* <UNSAFE_AkselLanguageProvider translations={{...}}>
|
|
21
|
+
* {app}
|
|
22
|
+
* </UNSAFE_AkselLanguageProvider>
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare const UNSAFE_AkselLanguageProvider: ({ children, translations, }: LanguageProviderProps) => React.JSX.Element;
|
|
26
|
+
export default UNSAFE_AkselLanguageProvider;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { createContext, useContext } from "react";
|
|
2
|
+
import nb from "../../util/i18n/locales/nb.js";
|
|
3
|
+
export const LanguageProviderContext = createContext({
|
|
4
|
+
translations: nb,
|
|
5
|
+
});
|
|
6
|
+
export const useProvider = () => useContext(LanguageProviderContext);
|
|
7
|
+
/**
|
|
8
|
+
* @private Feature is under development and should not be used in any applications.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```jsx
|
|
12
|
+
* <UNSAFE_AkselLanguageProvider translations={{...}}>
|
|
13
|
+
* {app}
|
|
14
|
+
* </UNSAFE_AkselLanguageProvider>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export const UNSAFE_AkselLanguageProvider = ({ children, translations, }) => {
|
|
18
|
+
return (React.createElement(LanguageProviderContext.Provider, { value: {
|
|
19
|
+
translations: translations !== null && translations !== void 0 ? translations : nb,
|
|
20
|
+
} }, children));
|
|
21
|
+
};
|
|
22
|
+
export default UNSAFE_AkselLanguageProvider;
|
|
23
|
+
//# sourceMappingURL=LanguageProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LanguageProvider.js","sourceRoot":"","sources":["../../../src/provider/i18n/LanguageProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAS5C,MAAM,CAAC,MAAM,uBAAuB,GAClC,aAAa,CAA8B;IACzC,YAAY,EAAE,EAAE;CACjB,CAAC,CAAC;AAOL,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAC;AAErE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,EAC3C,QAAQ,EACR,YAAY,GACU,EAAE,EAAE;IAC1B,OAAO,CACL,oBAAC,uBAAuB,CAAC,QAAQ,IAC/B,KAAK,EAAE;YACL,YAAY,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE;SACjC,IAEA,QAAQ,CACwB,CACpC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,4BAA4B,CAAC"}
|
package/esm/tooltip/Tooltip.d.ts
CHANGED
|
@@ -59,6 +59,12 @@ export interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
59
59
|
* List of Keyboard-keys for shortcuts.
|
|
60
60
|
*/
|
|
61
61
|
keys?: string[];
|
|
62
|
+
/**
|
|
63
|
+
* When false, Tooltip labels the element, and child-elements content will be ignored by screen-readers.
|
|
64
|
+
* When true, content is added as additional information to the child element.
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
describesChild?: boolean;
|
|
62
68
|
}
|
|
63
69
|
/**
|
|
64
70
|
* A component that displays a tooltip when the user hovers over its child element.
|
|
@@ -67,9 +73,9 @@ export interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
67
73
|
* @see 🏷️ {@link TooltipProps}
|
|
68
74
|
*
|
|
69
75
|
* @example
|
|
70
|
-
* ```jsx
|
|
76
|
+
* ```jsx Tooltip as only form of labeling
|
|
71
77
|
* <Tooltip content="Skriv ut dokument">
|
|
72
|
-
* <Button icon={<PrinterLargeIcon
|
|
78
|
+
* <Button icon={<PrinterLargeIcon aria-hidden />} />
|
|
73
79
|
* </Tooltip>
|
|
74
80
|
* ```
|
|
75
81
|
*/
|
package/esm/tooltip/Tooltip.js
CHANGED
|
@@ -11,9 +11,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { autoUpdate, arrow as flArrow, flip, offset, safePolygon, shift, useDismiss, useFloating, useFocus, useHover, useInteractions, } from "@floating-ui/react";
|
|
13
13
|
import cl from "clsx";
|
|
14
|
-
import React, {
|
|
14
|
+
import React, { forwardRef, useRef } from "react";
|
|
15
15
|
import { useModalContext } from "../modal/Modal.context.js";
|
|
16
16
|
import { Portal } from "../portal/index.js";
|
|
17
|
+
import { Slot } from "../slot/Slot.js";
|
|
17
18
|
import { Detail } from "../typography/index.js";
|
|
18
19
|
import { useId } from "../util/hooks/index.js";
|
|
19
20
|
import { useControllableState } from "../util/hooks/useControllableState.js";
|
|
@@ -25,14 +26,14 @@ import { useMergeRefs } from "../util/hooks/useMergeRefs.js";
|
|
|
25
26
|
* @see 🏷️ {@link TooltipProps}
|
|
26
27
|
*
|
|
27
28
|
* @example
|
|
28
|
-
* ```jsx
|
|
29
|
+
* ```jsx Tooltip as only form of labeling
|
|
29
30
|
* <Tooltip content="Skriv ut dokument">
|
|
30
|
-
* <Button icon={<PrinterLargeIcon
|
|
31
|
+
* <Button icon={<PrinterLargeIcon aria-hidden />} />
|
|
31
32
|
* </Tooltip>
|
|
32
33
|
* ```
|
|
33
34
|
*/
|
|
34
35
|
export const Tooltip = forwardRef((_a, ref) => {
|
|
35
|
-
var { children, className, arrow: _arrow = true, placement: _placement = "top", open, defaultOpen = false, onOpenChange, offset: _offset, content, delay = 150, id, keys, maxChar = 80 } = _a, rest = __rest(_a, ["children", "className", "arrow", "placement", "open", "defaultOpen", "onOpenChange", "offset", "content", "delay", "id", "keys", "maxChar"]);
|
|
36
|
+
var { children, className, arrow: _arrow = true, placement: _placement = "top", open, defaultOpen = false, onOpenChange, offset: _offset, content, delay = 150, id, keys, maxChar = 80, describesChild = false } = _a, rest = __rest(_a, ["children", "className", "arrow", "placement", "open", "defaultOpen", "onOpenChange", "offset", "content", "delay", "id", "keys", "maxChar", "describesChild"]);
|
|
36
37
|
const [_open, _setOpen] = useControllableState({
|
|
37
38
|
defaultValue: defaultOpen,
|
|
38
39
|
value: open,
|
|
@@ -66,7 +67,6 @@ export const Tooltip = forwardRef((_a, ref) => {
|
|
|
66
67
|
]);
|
|
67
68
|
const ariaId = useId(id);
|
|
68
69
|
const mergedRef = useMergeRefs(ref, refs.setFloating);
|
|
69
|
-
const childMergedRef = useMergeRefs(children.ref, refs.setReference);
|
|
70
70
|
if (!children ||
|
|
71
71
|
(children === null || children === void 0 ? void 0 : children.type) === React.Fragment ||
|
|
72
72
|
children === React.Fragment) {
|
|
@@ -77,10 +77,13 @@ export const Tooltip = forwardRef((_a, ref) => {
|
|
|
77
77
|
_open &&
|
|
78
78
|
console.warn(`Because of strict accessibility concers we encourage all Tooltips to have less than 80 characters. Can be overwritten with the maxChar-prop\n\nLength:${content.length}\nTooltip-content: ${content}`);
|
|
79
79
|
}
|
|
80
|
+
const labelProps = describesChild
|
|
81
|
+
? _open
|
|
82
|
+
? { "aria-describedby": ariaId }
|
|
83
|
+
: { title: content }
|
|
84
|
+
: { "aria-label": content };
|
|
80
85
|
return (React.createElement(React.Fragment, null,
|
|
81
|
-
|
|
82
|
-
? cl(ariaId, children === null || children === void 0 ? void 0 : children.props["aria-describedby"])
|
|
83
|
-
: children === null || children === void 0 ? void 0 : children.props["aria-describedby"] }))),
|
|
86
|
+
React.createElement(Slot, Object.assign({ ref: refs.setReference }, getReferenceProps(), labelProps, { "aria-keyshortcuts": keys ? keys.join("+") : undefined }), children),
|
|
84
87
|
React.createElement(Portal, { rootElement: rootElement, asChild: true }, _open && (React.createElement("div", Object.assign({}, getFloatingProps(Object.assign(Object.assign({}, rest), { ref: mergedRef, style: {
|
|
85
88
|
position: strategy,
|
|
86
89
|
top: y !== null && y !== void 0 ? y : 0,
|
|
@@ -88,7 +91,7 @@ export const Tooltip = forwardRef((_a, ref) => {
|
|
|
88
91
|
visibility: referenceHidden ? "hidden" : "visible",
|
|
89
92
|
}, role: "tooltip", id: ariaId, className: cl("navds-tooltip", "navds-detail navds-detail--small", className) })), { "data-side": placement }),
|
|
90
93
|
content,
|
|
91
|
-
keys && (React.createElement("span", { className: "navds-tooltip__keys" }, keys.map((key) => (React.createElement(Detail, { as: "kbd", key: key, className: "navds-tooltip__key" }, key))))),
|
|
94
|
+
keys && (React.createElement("span", { className: "navds-tooltip__keys", "aria-hidden": true }, keys.map((key) => (React.createElement(Detail, { as: "kbd", key: key, className: "navds-tooltip__key" }, key))))),
|
|
92
95
|
_arrow && (React.createElement("div", { ref: (node) => {
|
|
93
96
|
arrowRef.current = node;
|
|
94
97
|
}, className: "navds-tooltip__arrow", style: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EACL,UAAU,EACV,KAAK,IAAI,OAAO,EAChB,IAAI,EACJ,MAAM,EACN,WAAW,EACX,KAAK,EACL,UAAU,EACV,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAkB,
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EACL,UAAU,EACV,KAAK,IAAI,OAAO,EAChB,IAAI,EACJ,MAAM,EACN,WAAW,EACX,KAAK,EACL,UAAU,EACV,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAkB,UAAU,EA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
|
-
import { Component, ComponentTranslation
|
|
1
|
+
import { Component, ComponentTranslation } from "./i18n.types.js";
|
|
2
2
|
import nb from "./locales/nb.js";
|
|
3
|
-
export declare const I18nContext: import("react").Context<TranslationDictionary | TranslationDictionary[]>;
|
|
4
3
|
type NestedKeyOf<ObjectType extends object> = {
|
|
5
4
|
[Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}.${NestedKeyOf<ObjectType[Key]>}` : `${Key}`;
|
|
6
5
|
}[keyof ObjectType & (string | number)];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { LanguageProviderContext } from "../../provider/i18n/LanguageProvider.js";
|
|
2
3
|
import { get } from "./get.js";
|
|
3
|
-
import nb from "./locales/nb.js";
|
|
4
4
|
/**
|
|
5
5
|
* https://regex101.com/r/LYKWi3/1
|
|
6
6
|
*/
|
|
7
7
|
const REPLACE_REGEX = /{[^}]*}/g;
|
|
8
|
-
export const I18nContext = createContext(nb);
|
|
9
8
|
export function useI18n(componentName, ...local) {
|
|
10
|
-
const
|
|
9
|
+
const languageProviderContext = useContext(LanguageProviderContext);
|
|
10
|
+
const i18n = languageProviderContext.translations;
|
|
11
11
|
/**
|
|
12
12
|
* https://github.com/Shopify/polaris/blob/2115f9ba2f5bcbf2ad15745233501bff2db81ecf/polaris-react/src/utilities/i18n/I18n.ts#L24
|
|
13
13
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.context.js","sourceRoot":"","sources":["../../../src/util/i18n/i18n.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"i18n.context.js","sourceRoot":"","sources":["../../../src/util/i18n/i18n.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,G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,CAAC;IACd,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"description": "React components from the Norwegian Labour and Welfare Administration.",
|
|
5
5
|
"author": "Aksel, a team part of the Norwegian Labour and Welfare Administration.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -594,8 +594,8 @@
|
|
|
594
594
|
"dependencies": {
|
|
595
595
|
"@floating-ui/react": "0.25.4",
|
|
596
596
|
"@floating-ui/react-dom": "^2.0.9",
|
|
597
|
-
"@navikt/aksel-icons": "^
|
|
598
|
-
"@navikt/ds-tokens": "^
|
|
597
|
+
"@navikt/aksel-icons": "^7.0.1",
|
|
598
|
+
"@navikt/ds-tokens": "^7.0.1",
|
|
599
599
|
"clsx": "^2.1.0",
|
|
600
600
|
"date-fns": "^3.0.0",
|
|
601
601
|
"react-day-picker": "8.10.0"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { describe } from "vitest";
|
|
2
|
+
import filteredOptionsUtil from "./filtered-options-util";
|
|
3
|
+
|
|
4
|
+
describe("filtered options util", () => {
|
|
5
|
+
describe("getOptionId", () => {
|
|
6
|
+
it("should return the correct id", () => {
|
|
7
|
+
expect(filteredOptionsUtil.getOptionId("combobox", "option")).toBe(
|
|
8
|
+
"combobox-option-option",
|
|
9
|
+
);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("should return the correct id with spaces", () => {
|
|
13
|
+
expect(
|
|
14
|
+
filteredOptionsUtil.getOptionId("combobox", "option with spaces"),
|
|
15
|
+
).toBe("combobox-option-option-with-spaces");
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -19,9 +19,7 @@ const getFilteredOptionsId = (comboboxId: string) =>
|
|
|
19
19
|
`${comboboxId}-filtered-options`;
|
|
20
20
|
|
|
21
21
|
const getOptionId = (comboboxId: string, option: string) =>
|
|
22
|
-
`${comboboxId
|
|
23
|
-
.replace(" ", "-")
|
|
24
|
-
.toLocaleLowerCase()}`;
|
|
22
|
+
`${comboboxId}-option-${option}`.replace(/\s/g, "-").toLocaleLowerCase();
|
|
25
23
|
|
|
26
24
|
const getAddNewOptionId = (comboboxId: string) =>
|
|
27
25
|
`${comboboxId}-combobox-new-option`;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
|
-
import React, { HTMLAttributes, forwardRef,
|
|
2
|
+
import React, { HTMLAttributes, forwardRef, useRef } from "react";
|
|
3
3
|
import { BodyShort, Heading } from "../../typography";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
4
|
+
import { composeEventHandlers } from "../../util/composeEventHandlers";
|
|
5
|
+
import { useId, useMergeRefs } from "../../util/hooks";
|
|
6
|
+
import ErrorSummaryItem from "./ErrorSummaryItem";
|
|
6
7
|
|
|
7
|
-
export interface ErrorSummaryProps
|
|
8
|
+
export interface ErrorSummaryProps
|
|
9
|
+
extends Omit<HTMLAttributes<HTMLDivElement>, "tabIndex"> {
|
|
8
10
|
/**
|
|
9
11
|
* Collection of `ErrorSummary.Item`.
|
|
10
12
|
*/
|
|
@@ -16,6 +18,7 @@ export interface ErrorSummaryProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
16
18
|
size?: "medium" | "small";
|
|
17
19
|
/**
|
|
18
20
|
* Heading above links.
|
|
21
|
+
* @default "Du må rette disse feilene før du kan fortsette:"
|
|
19
22
|
*/
|
|
20
23
|
heading?: React.ReactNode;
|
|
21
24
|
/**
|
|
@@ -41,7 +44,7 @@ interface ErrorSummaryComponent
|
|
|
41
44
|
* </ErrorSummary.Item>
|
|
42
45
|
* ```
|
|
43
46
|
*/
|
|
44
|
-
Item:
|
|
47
|
+
Item: typeof ErrorSummaryItem;
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
/**
|
|
@@ -69,16 +72,21 @@ export const ErrorSummary = forwardRef<HTMLDivElement, ErrorSummaryProps>(
|
|
|
69
72
|
className,
|
|
70
73
|
size = "medium",
|
|
71
74
|
headingTag = "h2",
|
|
72
|
-
heading,
|
|
75
|
+
heading = "Du må rette disse feilene før du kan fortsette:",
|
|
73
76
|
...rest
|
|
74
77
|
},
|
|
75
78
|
ref,
|
|
76
79
|
) => {
|
|
77
80
|
const headingId = useId();
|
|
78
81
|
|
|
82
|
+
const sectionRef = useRef<HTMLDivElement>(null);
|
|
83
|
+
const headingRef = useRef<HTMLHeadingElement>(null);
|
|
84
|
+
|
|
85
|
+
const mergedRef = useMergeRefs(ref, sectionRef);
|
|
86
|
+
|
|
79
87
|
return (
|
|
80
88
|
<section
|
|
81
|
-
ref={
|
|
89
|
+
ref={mergedRef}
|
|
82
90
|
{...rest}
|
|
83
91
|
className={cl(
|
|
84
92
|
className,
|
|
@@ -89,22 +97,24 @@ export const ErrorSummary = forwardRef<HTMLDivElement, ErrorSummaryProps>(
|
|
|
89
97
|
aria-live="polite"
|
|
90
98
|
aria-relevant="all"
|
|
91
99
|
aria-labelledby={headingId}
|
|
100
|
+
onFocus={composeEventHandlers(rest.onFocus, (event) => {
|
|
101
|
+
if (event.target === sectionRef.current) {
|
|
102
|
+
headingRef?.current?.focus();
|
|
103
|
+
}
|
|
104
|
+
})}
|
|
92
105
|
>
|
|
93
106
|
<Heading
|
|
94
107
|
className="navds-error-summary__heading"
|
|
95
108
|
as={headingTag}
|
|
96
109
|
size="small"
|
|
97
110
|
id={headingId}
|
|
111
|
+
ref={headingRef}
|
|
112
|
+
tabIndex={-1}
|
|
98
113
|
>
|
|
99
114
|
{heading}
|
|
100
115
|
</Heading>
|
|
101
116
|
<BodyShort as="ul" size={size} className="navds-error-summary__list">
|
|
102
|
-
{
|
|
103
|
-
if (!isValidElement(child)) {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
return <li key={child.toString()}>{child}</li>;
|
|
107
|
-
})}
|
|
117
|
+
{children}
|
|
108
118
|
</BodyShort>
|
|
109
119
|
</section>
|
|
110
120
|
);
|
|
@@ -14,7 +14,7 @@ export interface ErrorSummaryItemProps
|
|
|
14
14
|
href?: string;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
type ErrorSummaryItemType = OverridableComponent<
|
|
18
18
|
ErrorSummaryItemProps,
|
|
19
19
|
HTMLAnchorElement
|
|
20
20
|
>;
|
|
@@ -22,13 +22,15 @@ export type ErrorSummaryItemType = OverridableComponent<
|
|
|
22
22
|
export const ErrorSummaryItem: ErrorSummaryItemType = forwardRef(
|
|
23
23
|
({ children, as: Component = "a", className, ...rest }, ref) => {
|
|
24
24
|
return (
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
<li>
|
|
26
|
+
<Component
|
|
27
|
+
{...rest}
|
|
28
|
+
ref={ref}
|
|
29
|
+
className={cl(className, "navds-error-summary__item", "navds-link")}
|
|
30
|
+
>
|
|
31
|
+
{children}
|
|
32
|
+
</Component>
|
|
33
|
+
</li>
|
|
32
34
|
);
|
|
33
35
|
},
|
|
34
36
|
);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React, { createContext, useContext } from "react";
|
|
2
|
+
import { TranslationDictionary } from "../../util/i18n/i18n.types";
|
|
3
|
+
import nb from "../../util/i18n/locales/nb";
|
|
4
|
+
|
|
5
|
+
export interface LanguageProviderContextType {
|
|
6
|
+
/**
|
|
7
|
+
* Merged with the default language translations object (officially provided translations).
|
|
8
|
+
*/
|
|
9
|
+
translations: TranslationDictionary | TranslationDictionary[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const LanguageProviderContext =
|
|
13
|
+
createContext<LanguageProviderContextType>({
|
|
14
|
+
translations: nb,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export interface LanguageProviderProps {
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
translations?: TranslationDictionary | TranslationDictionary[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const useProvider = () => useContext(LanguageProviderContext);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @private Feature is under development and should not be used in any applications.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```jsx
|
|
29
|
+
* <UNSAFE_AkselLanguageProvider translations={{...}}>
|
|
30
|
+
* {app}
|
|
31
|
+
* </UNSAFE_AkselLanguageProvider>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export const UNSAFE_AkselLanguageProvider = ({
|
|
35
|
+
children,
|
|
36
|
+
translations,
|
|
37
|
+
}: LanguageProviderProps) => {
|
|
38
|
+
return (
|
|
39
|
+
<LanguageProviderContext.Provider
|
|
40
|
+
value={{
|
|
41
|
+
translations: translations ?? nb,
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</LanguageProviderContext.Provider>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default UNSAFE_AkselLanguageProvider;
|
package/src/tooltip/Tooltip.tsx
CHANGED
|
@@ -12,9 +12,10 @@ import {
|
|
|
12
12
|
useInteractions,
|
|
13
13
|
} from "@floating-ui/react";
|
|
14
14
|
import cl from "clsx";
|
|
15
|
-
import React, { HTMLAttributes,
|
|
15
|
+
import React, { HTMLAttributes, forwardRef, useRef } from "react";
|
|
16
16
|
import { useModalContext } from "../modal/Modal.context";
|
|
17
17
|
import { Portal } from "../portal";
|
|
18
|
+
import { Slot } from "../slot/Slot";
|
|
18
19
|
import { Detail } from "../typography";
|
|
19
20
|
import { useId } from "../util/hooks";
|
|
20
21
|
import { useControllableState } from "../util/hooks/useControllableState";
|
|
@@ -80,6 +81,12 @@ export interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
80
81
|
* List of Keyboard-keys for shortcuts.
|
|
81
82
|
*/
|
|
82
83
|
keys?: string[];
|
|
84
|
+
/**
|
|
85
|
+
* When false, Tooltip labels the element, and child-elements content will be ignored by screen-readers.
|
|
86
|
+
* When true, content is added as additional information to the child element.
|
|
87
|
+
* @default false
|
|
88
|
+
*/
|
|
89
|
+
describesChild?: boolean;
|
|
83
90
|
}
|
|
84
91
|
|
|
85
92
|
/**
|
|
@@ -89,9 +96,9 @@ export interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
89
96
|
* @see 🏷️ {@link TooltipProps}
|
|
90
97
|
*
|
|
91
98
|
* @example
|
|
92
|
-
* ```jsx
|
|
99
|
+
* ```jsx Tooltip as only form of labeling
|
|
93
100
|
* <Tooltip content="Skriv ut dokument">
|
|
94
|
-
* <Button icon={<PrinterLargeIcon
|
|
101
|
+
* <Button icon={<PrinterLargeIcon aria-hidden />} />
|
|
95
102
|
* </Tooltip>
|
|
96
103
|
* ```
|
|
97
104
|
*/
|
|
@@ -111,6 +118,7 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
|
|
|
111
118
|
id,
|
|
112
119
|
keys,
|
|
113
120
|
maxChar = 80,
|
|
121
|
+
describesChild = false,
|
|
114
122
|
...rest
|
|
115
123
|
},
|
|
116
124
|
ref,
|
|
@@ -164,7 +172,6 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
|
|
|
164
172
|
const ariaId = useId(id);
|
|
165
173
|
|
|
166
174
|
const mergedRef = useMergeRefs(ref, refs.setFloating);
|
|
167
|
-
const childMergedRef = useMergeRefs(children.ref, refs.setReference);
|
|
168
175
|
|
|
169
176
|
if (
|
|
170
177
|
!children ||
|
|
@@ -184,18 +191,22 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
|
|
|
184
191
|
);
|
|
185
192
|
}
|
|
186
193
|
|
|
194
|
+
const labelProps = describesChild
|
|
195
|
+
? _open
|
|
196
|
+
? { "aria-describedby": ariaId }
|
|
197
|
+
: { title: content }
|
|
198
|
+
: { "aria-label": content };
|
|
199
|
+
|
|
187
200
|
return (
|
|
188
201
|
<>
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
getReferenceProps(
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}),
|
|
198
|
-
)}
|
|
202
|
+
<Slot
|
|
203
|
+
ref={refs.setReference}
|
|
204
|
+
{...getReferenceProps()}
|
|
205
|
+
{...labelProps}
|
|
206
|
+
aria-keyshortcuts={keys ? keys.join("+") : undefined}
|
|
207
|
+
>
|
|
208
|
+
{children}
|
|
209
|
+
</Slot>
|
|
199
210
|
<Portal rootElement={rootElement} asChild>
|
|
200
211
|
{_open && (
|
|
201
212
|
<div
|
|
@@ -220,7 +231,7 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
|
|
|
220
231
|
>
|
|
221
232
|
{content}
|
|
222
233
|
{keys && (
|
|
223
|
-
<span className="navds-tooltip__keys">
|
|
234
|
+
<span className="navds-tooltip__keys" aria-hidden>
|
|
224
235
|
{keys.map((key) => (
|
|
225
236
|
<Detail as="kbd" key={key} className="navds-tooltip__key">
|
|
226
237
|
{key}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { renderHook } from "@testing-library/react";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { describe, expect, test } from "vitest";
|
|
4
|
-
import
|
|
4
|
+
import UNSAFE_AkselLanguageProvider from "../../provider/i18n/LanguageProvider";
|
|
5
|
+
import { useI18n } from "./i18n.context";
|
|
5
6
|
|
|
6
7
|
describe("useI18n", () => {
|
|
7
8
|
test("should throw error if key is not found", () => {
|
|
@@ -15,7 +16,9 @@ describe("useI18n", () => {
|
|
|
15
16
|
const i18n = { FileUpload: { item: { uploading: "Test translation" } } };
|
|
16
17
|
const { result } = renderHook(() => useI18n("FileUpload"), {
|
|
17
18
|
wrapper: ({ children }) => (
|
|
18
|
-
<
|
|
19
|
+
<UNSAFE_AkselLanguageProvider translations={i18n}>
|
|
20
|
+
{children}
|
|
21
|
+
</UNSAFE_AkselLanguageProvider>
|
|
19
22
|
),
|
|
20
23
|
});
|
|
21
24
|
const translate = result.current;
|
|
@@ -29,9 +32,9 @@ describe("useI18n", () => {
|
|
|
29
32
|
const i18n2 = { FileUpload: { item: { uploading: "Wrong translation" } } };
|
|
30
33
|
const { result } = renderHook(() => useI18n("FileUpload"), {
|
|
31
34
|
wrapper: ({ children }) => (
|
|
32
|
-
<
|
|
35
|
+
<UNSAFE_AkselLanguageProvider translations={[i18n1, i18n2]}>
|
|
33
36
|
{children}
|
|
34
|
-
</
|
|
37
|
+
</UNSAFE_AkselLanguageProvider>
|
|
35
38
|
),
|
|
36
39
|
});
|
|
37
40
|
const translate = result.current;
|
|
@@ -45,9 +48,9 @@ describe("useI18n", () => {
|
|
|
45
48
|
};
|
|
46
49
|
const { result } = renderHook(() => useI18n("FileUpload"), {
|
|
47
50
|
wrapper: ({ children }) => (
|
|
48
|
-
<
|
|
51
|
+
<UNSAFE_AkselLanguageProvider translations={[i18n1, i18n2]}>
|
|
49
52
|
{children}
|
|
50
|
-
</
|
|
53
|
+
</UNSAFE_AkselLanguageProvider>
|
|
51
54
|
),
|
|
52
55
|
});
|
|
53
56
|
const translate = result.current;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { LanguageProviderContext } from "../../provider/i18n/LanguageProvider";
|
|
2
3
|
import { get } from "./get";
|
|
3
|
-
import {
|
|
4
|
-
Component,
|
|
5
|
-
ComponentTranslation,
|
|
6
|
-
TranslationDictionary,
|
|
7
|
-
} from "./i18n.types";
|
|
4
|
+
import { Component, ComponentTranslation } from "./i18n.types";
|
|
8
5
|
import nb from "./locales/nb";
|
|
9
6
|
|
|
10
7
|
/**
|
|
@@ -12,10 +9,6 @@ import nb from "./locales/nb";
|
|
|
12
9
|
*/
|
|
13
10
|
const REPLACE_REGEX = /{[^}]*}/g;
|
|
14
11
|
|
|
15
|
-
export const I18nContext = createContext<
|
|
16
|
-
TranslationDictionary | TranslationDictionary[]
|
|
17
|
-
>(nb);
|
|
18
|
-
|
|
19
12
|
/* https://dev.to/pffigueiredo/typescript-utility-keyof-nested-object-2pa3 */
|
|
20
13
|
type NestedKeyOf<ObjectType extends object> = {
|
|
21
14
|
[Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object
|
|
@@ -27,7 +20,8 @@ export function useI18n<T extends Component>(
|
|
|
27
20
|
componentName: T,
|
|
28
21
|
...local: (ComponentTranslation<T> | undefined)[]
|
|
29
22
|
) {
|
|
30
|
-
const
|
|
23
|
+
const languageProviderContext = useContext(LanguageProviderContext);
|
|
24
|
+
const i18n = languageProviderContext.translations;
|
|
31
25
|
|
|
32
26
|
/**
|
|
33
27
|
* https://github.com/Shopify/polaris/blob/2115f9ba2f5bcbf2ad15745233501bff2db81ecf/polaris-react/src/utilities/i18n/I18n.ts#L24
|