@navikt/ds-react 7.11.0-alpha.1 → 7.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/chips/Toggle.js +2 -2
- package/cjs/chips/Toggle.js.map +1 -1
- package/cjs/copybutton/CopyButton.d.ts +2 -11
- package/cjs/copybutton/CopyButton.js +16 -4
- package/cjs/copybutton/CopyButton.js.map +1 -1
- package/cjs/form/checkbox/Checkbox.js +1 -0
- package/cjs/form/checkbox/Checkbox.js.map +1 -1
- package/cjs/form/combobox/Combobox.d.ts +1 -1
- package/cjs/form/combobox/Input/InputController.d.ts +1 -1
- package/cjs/form/file-upload/parts/item/Item.js +1 -4
- package/cjs/form/file-upload/parts/item/Item.js.map +1 -1
- package/cjs/form/switch/Switch.js +1 -0
- package/cjs/form/switch/Switch.js.map +1 -1
- package/cjs/internal-header/InternalHeader.js +1 -1
- package/cjs/internal-header/InternalHeader.js.map +1 -1
- package/cjs/list/{ListItem.d.ts → List.Item.d.ts} +1 -1
- package/cjs/list/{ListItem.js → List.Item.js} +3 -3
- package/cjs/list/List.Item.js.map +1 -0
- package/{esm/list/context.d.ts → cjs/list/List.context.d.ts} +1 -1
- package/cjs/list/{context.js → List.context.js} +1 -1
- package/cjs/list/List.context.js.map +1 -0
- package/cjs/list/List.d.ts +2 -2
- package/cjs/list/List.js +19 -5
- package/cjs/list/List.js.map +1 -1
- package/cjs/list/{types.d.ts → List.types.d.ts} +3 -0
- package/cjs/list/{types.js → List.types.js} +1 -1
- package/cjs/list/List.types.js.map +1 -0
- package/cjs/list/index.d.ts +2 -2
- package/cjs/list/index.js +2 -2
- package/cjs/list/index.js.map +1 -1
- package/cjs/overlays/action-menu/ActionMenu.js +2 -2
- package/cjs/table/ColumnHeader.js +1 -1
- package/cjs/table/ColumnHeader.js.map +1 -1
- package/cjs/tabs/Tabs.context.d.ts +1 -1
- package/cjs/tag/Tag.d.ts +1 -1
- package/cjs/tag/Tag.js.map +1 -1
- package/esm/chips/Toggle.js +2 -2
- package/esm/chips/Toggle.js.map +1 -1
- package/esm/copybutton/CopyButton.d.ts +2 -11
- package/esm/copybutton/CopyButton.js +16 -4
- package/esm/copybutton/CopyButton.js.map +1 -1
- package/esm/form/checkbox/Checkbox.js +1 -0
- package/esm/form/checkbox/Checkbox.js.map +1 -1
- package/esm/form/combobox/Combobox.d.ts +1 -1
- package/esm/form/combobox/Input/InputController.d.ts +1 -1
- package/esm/form/file-upload/parts/item/Item.js +2 -5
- package/esm/form/file-upload/parts/item/Item.js.map +1 -1
- package/esm/form/switch/Switch.js +1 -0
- package/esm/form/switch/Switch.js.map +1 -1
- package/esm/internal-header/InternalHeader.js +1 -1
- package/esm/internal-header/InternalHeader.js.map +1 -1
- package/esm/list/{ListItem.d.ts → List.Item.d.ts} +1 -1
- package/esm/list/{ListItem.js → List.Item.js} +2 -2
- package/esm/list/List.Item.js.map +1 -0
- package/{cjs/list/context.d.ts → esm/list/List.context.d.ts} +1 -1
- package/esm/list/{context.js → List.context.js} +1 -1
- package/esm/list/List.context.js.map +1 -0
- package/esm/list/List.d.ts +2 -2
- package/esm/list/List.js +16 -2
- package/esm/list/List.js.map +1 -1
- package/esm/list/{types.d.ts → List.types.d.ts} +3 -0
- package/esm/list/List.types.js +2 -0
- package/esm/list/List.types.js.map +1 -0
- package/esm/list/index.d.ts +2 -2
- package/esm/list/index.js +1 -1
- package/esm/list/index.js.map +1 -1
- package/esm/overlays/action-menu/ActionMenu.js +2 -2
- package/esm/table/ColumnHeader.js +2 -2
- package/esm/table/ColumnHeader.js.map +1 -1
- package/esm/tabs/Tabs.context.d.ts +1 -1
- package/esm/tag/Tag.d.ts +1 -1
- package/esm/tag/Tag.js.map +1 -1
- package/package.json +15 -10
- package/src/chips/Toggle.tsx +2 -2
- package/src/copybutton/CopyButton.tsx +43 -14
- package/src/form/checkbox/Checkbox.tsx +1 -0
- package/src/form/file-upload/parts/item/Item.tsx +3 -8
- package/src/form/switch/Switch.tsx +1 -0
- package/src/internal-header/InternalHeader.tsx +1 -1
- package/src/list/{ListItem.tsx → List.Item.tsx} +2 -2
- package/src/list/{context.ts → List.context.ts} +1 -1
- package/src/list/List.tsx +37 -3
- package/src/list/{types.ts → List.types.ts} +3 -0
- package/src/list/index.ts +2 -2
- package/src/overlays/action-menu/ActionMenu.tsx +2 -2
- package/src/table/ColumnHeader.tsx +4 -4
- package/src/tag/Tag.tsx +9 -7
- package/cjs/list/ListItem.js.map +0 -1
- package/cjs/list/context.js.map +0 -1
- package/cjs/list/types.js.map +0 -1
- package/cjs/modal/types.test-d.d.ts +0 -1
- package/cjs/modal/types.test-d.js +0 -67
- package/cjs/modal/types.test-d.js.map +0 -1
- package/cjs/util/i18n/i18n.context.d.ts +0 -9
- package/cjs/util/i18n/i18n.context.js +0 -54
- package/cjs/util/i18n/i18n.context.js.map +0 -1
- package/esm/list/ListItem.js.map +0 -1
- package/esm/list/context.js.map +0 -1
- package/esm/list/types.js +0 -2
- package/esm/list/types.js.map +0 -1
- package/esm/modal/types.test-d.d.ts +0 -1
- package/esm/modal/types.test-d.js +0 -65
- package/esm/modal/types.test-d.js.map +0 -1
- package/esm/util/i18n/i18n.context.d.ts +0 -9
- package/esm/util/i18n/i18n.context.js +0 -50
- package/esm/util/i18n/i18n.context.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef, useContext } from "react";
|
|
3
3
|
import { BodyLong } from "../typography";
|
|
4
|
-
import { ListContext } from "./context";
|
|
5
|
-
import type { ListItemProps } from "./types";
|
|
4
|
+
import { ListContext } from "./List.context";
|
|
5
|
+
import type { ListItemProps } from "./List.types";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @see 🏷️ {@link ListItemProps}
|
package/src/list/List.tsx
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef, useContext } from "react";
|
|
3
|
+
import { useThemeInternal } from "../theme/Theme";
|
|
3
4
|
import { BodyLong, BodyShort, Heading, HeadingProps } from "../typography";
|
|
4
|
-
import { ListItem } from "./
|
|
5
|
-
import { ListContext } from "./context";
|
|
5
|
+
import { ListItem } from "./List.Item";
|
|
6
|
+
import { ListContext } from "./List.context";
|
|
6
7
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
7
|
-
import type { ListItemProps, ListProps } from "./types";
|
|
8
|
+
import type { ListItemProps, ListProps } from "./List.types";
|
|
8
9
|
|
|
9
10
|
const headingSizeMap: Record<
|
|
10
11
|
Exclude<ListProps["size"], undefined>,
|
|
@@ -56,7 +57,40 @@ export const List = forwardRef<HTMLDivElement, ListProps>(
|
|
|
56
57
|
) => {
|
|
57
58
|
const { size: contextSize } = useContext(ListContext);
|
|
58
59
|
|
|
60
|
+
const themeContext = useThemeInternal(false);
|
|
61
|
+
|
|
59
62
|
const listSize = size ?? contextSize;
|
|
63
|
+
|
|
64
|
+
if (themeContext) {
|
|
65
|
+
if (
|
|
66
|
+
process.env.NODE_ENV !== "production" &&
|
|
67
|
+
(title || description || headingTag)
|
|
68
|
+
) {
|
|
69
|
+
console.warn(
|
|
70
|
+
"List: title, description and headingTag are deprecated and will not work with updated theme for Aksel.",
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<ListContext.Provider
|
|
76
|
+
value={{
|
|
77
|
+
listType: ListTag,
|
|
78
|
+
size: listSize,
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
<BodyLong
|
|
82
|
+
as="div"
|
|
83
|
+
{...rest}
|
|
84
|
+
size={listSize}
|
|
85
|
+
ref={ref}
|
|
86
|
+
className={cl("navds-list", `navds-list--${listSize}`, className)}
|
|
87
|
+
>
|
|
88
|
+
<ListTag role="list">{children}</ListTag>
|
|
89
|
+
</BodyLong>
|
|
90
|
+
</ListContext.Provider>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
60
94
|
return (
|
|
61
95
|
<ListContext.Provider
|
|
62
96
|
value={{
|
|
@@ -7,15 +7,18 @@ export interface ListProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
7
7
|
as?: "ul" | "ol";
|
|
8
8
|
/**
|
|
9
9
|
* List heading title.
|
|
10
|
+
* @deprecated Prop will be removed in future versions.
|
|
10
11
|
*/
|
|
11
12
|
title?: string;
|
|
12
13
|
/**
|
|
13
14
|
* List heading description.
|
|
15
|
+
* @deprecated Prop will be removed in future versions.
|
|
14
16
|
*/
|
|
15
17
|
description?: string;
|
|
16
18
|
/**
|
|
17
19
|
* Allows setting a different HTML h-tag.
|
|
18
20
|
* @default "h3"
|
|
21
|
+
* @deprecated Prop will be removed in future versions.
|
|
19
22
|
*/
|
|
20
23
|
headingTag?: React.ElementType<any>;
|
|
21
24
|
/**
|
package/src/list/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
export { default as List } from "./List";
|
|
3
|
-
export type { ListProps, ListItemProps } from "./types";
|
|
4
|
-
export { default as ListItem } from "./
|
|
3
|
+
export type { ListProps, ListItemProps } from "./List.types";
|
|
4
|
+
export { default as ListItem } from "./List.Item";
|
|
@@ -634,7 +634,7 @@ export const ActionMenuCheckboxItem = forwardRef<
|
|
|
634
634
|
width="24"
|
|
635
635
|
height="24"
|
|
636
636
|
rx="4"
|
|
637
|
-
fill="var(--ax-border-
|
|
637
|
+
fill="var(--ax-border-neutral, var(--a-border-default))"
|
|
638
638
|
/>
|
|
639
639
|
<rect
|
|
640
640
|
x="1"
|
|
@@ -771,7 +771,7 @@ export const ActionMenuRadioItem = forwardRef<
|
|
|
771
771
|
width="24"
|
|
772
772
|
height="24"
|
|
773
773
|
rx="12"
|
|
774
|
-
fill="var(--ax-border-
|
|
774
|
+
fill="var(--ax-border-neutral, var(--a-border-default))"
|
|
775
775
|
/>
|
|
776
776
|
<rect
|
|
777
777
|
x="1"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { forwardRef, useContext } from "react";
|
|
2
2
|
import {
|
|
3
|
-
ArrowDownIcon,
|
|
4
|
-
ArrowUpIcon,
|
|
5
3
|
ArrowsUpDownIcon,
|
|
4
|
+
SortDownIcon,
|
|
5
|
+
SortUpIcon,
|
|
6
6
|
} from "@navikt/aksel-icons";
|
|
7
7
|
import HeaderCell, { HeaderCellProps } from "./HeaderCell";
|
|
8
8
|
import { TableContext } from "./context";
|
|
@@ -58,9 +58,9 @@ export const ColumnHeader: ColumnHeaderType = forwardRef(
|
|
|
58
58
|
{children}
|
|
59
59
|
{context?.sort?.orderBy === sortKey ? (
|
|
60
60
|
context?.sort?.direction === "descending" ? (
|
|
61
|
-
<
|
|
61
|
+
<SortDownIcon aria-hidden />
|
|
62
62
|
) : (
|
|
63
|
-
<
|
|
63
|
+
<SortUpIcon aria-hidden />
|
|
64
64
|
)
|
|
65
65
|
) : (
|
|
66
66
|
<ArrowsUpDownIcon aria-hidden />
|
package/src/tag/Tag.tsx
CHANGED
|
@@ -31,13 +31,15 @@ export interface TagProps extends HTMLAttributes<HTMLSpanElement> {
|
|
|
31
31
|
| "alt2-moderate"
|
|
32
32
|
| "alt3"
|
|
33
33
|
| "alt3-filled"
|
|
34
|
-
| "alt3-moderate"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
| "alt3-moderate";
|
|
35
|
+
|
|
36
|
+
/* Temp hide these until naming is resolved */
|
|
37
|
+
// | "meta-purple"
|
|
38
|
+
// | "meta-purple-filled"
|
|
39
|
+
// | "meta-purple-moderate"
|
|
40
|
+
// | "meta-lime"
|
|
41
|
+
// | "meta-lime-filled"
|
|
42
|
+
// | "meta-lime-moderate";
|
|
41
43
|
/**
|
|
42
44
|
* @default "medium"
|
|
43
45
|
*/
|
package/cjs/list/ListItem.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem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AC,qBAAQ,IAAC,EAAE,EAAC,GAAG,EAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAC,UAAU,IAC3C,KAAK,CACG,CACZ;YACA,QAAQ,CACL,CACH,CACN,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAQ,CAAC,WAAW,GAAG,WAAW,CAAC;AACnC,kBAAe,gBAAQ,CAAC"}
|
package/cjs/list/context.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/list/context.ts"],"names":[],"mappings":";;;AAAA,iCAAsC;AAQzB,QAAA,WAAW,GAAG,IAAA,qBAAa,EAAmB;IACzD,QAAQ,EAAE,IAAI;IACd,IAAI,EAAE,QAAQ;CACf,CAAC,CAAC"}
|
package/cjs/list/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/list/types.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const vitest_1 = require("vitest");
|
|
4
|
-
test("ModalProps works as intended", () => {
|
|
5
|
-
(0, vitest_1.expectTypeOf)({
|
|
6
|
-
header: { heading: "Label" },
|
|
7
|
-
children: "OK",
|
|
8
|
-
}).toMatchTypeOf();
|
|
9
|
-
(0, vitest_1.expectTypeOf)({
|
|
10
|
-
header: { heading: "Label" },
|
|
11
|
-
"aria-label": "Label",
|
|
12
|
-
children: "OK",
|
|
13
|
-
}).toMatchTypeOf();
|
|
14
|
-
(0, vitest_1.expectTypeOf)({
|
|
15
|
-
header: { heading: "Label" },
|
|
16
|
-
"aria-labelledby": "Label",
|
|
17
|
-
children: "OK",
|
|
18
|
-
}).toMatchTypeOf();
|
|
19
|
-
(0, vitest_1.expectTypeOf)({
|
|
20
|
-
"aria-label": "Label",
|
|
21
|
-
children: "OK",
|
|
22
|
-
}).toMatchTypeOf();
|
|
23
|
-
(0, vitest_1.expectTypeOf)({
|
|
24
|
-
"aria-labelledby": "Label",
|
|
25
|
-
children: "OK",
|
|
26
|
-
}).toMatchTypeOf();
|
|
27
|
-
(0, vitest_1.expectTypeOf)({
|
|
28
|
-
"aria-label": "Label",
|
|
29
|
-
open: true,
|
|
30
|
-
onClose: () => null,
|
|
31
|
-
children: "OK",
|
|
32
|
-
}).toMatchTypeOf();
|
|
33
|
-
(0, vitest_1.expectTypeOf)({
|
|
34
|
-
children: "Mangler label",
|
|
35
|
-
}).not.toMatchTypeOf();
|
|
36
|
-
(0, vitest_1.expectTypeOf)({
|
|
37
|
-
open: true,
|
|
38
|
-
children: "Mangler onClose eller label",
|
|
39
|
-
}).not.toMatchTypeOf();
|
|
40
|
-
(0, vitest_1.expectTypeOf)({
|
|
41
|
-
open: true,
|
|
42
|
-
"aria-label": "Label",
|
|
43
|
-
children: "Mangler onClose",
|
|
44
|
-
}).not.toMatchTypeOf();
|
|
45
|
-
(0, vitest_1.expectTypeOf)({
|
|
46
|
-
open: true,
|
|
47
|
-
onClose: () => null,
|
|
48
|
-
children: "Mangler label",
|
|
49
|
-
}).not.toMatchTypeOf();
|
|
50
|
-
(0, vitest_1.expectTypeOf)({
|
|
51
|
-
header: { heading: "Label" },
|
|
52
|
-
open: true,
|
|
53
|
-
children: "Mangler onClose",
|
|
54
|
-
}).not.toMatchTypeOf();
|
|
55
|
-
(0, vitest_1.expectTypeOf)({
|
|
56
|
-
header: { heading: "Label" },
|
|
57
|
-
"aria-label": "Label",
|
|
58
|
-
"aria-labelledby": "Label",
|
|
59
|
-
children: "For mange labels",
|
|
60
|
-
}).not.toMatchTypeOf();
|
|
61
|
-
(0, vitest_1.expectTypeOf)({
|
|
62
|
-
"aria-label": "Label",
|
|
63
|
-
"aria-labelledby": "Label",
|
|
64
|
-
children: "For mange labels",
|
|
65
|
-
}).not.toMatchTypeOf();
|
|
66
|
-
});
|
|
67
|
-
//# sourceMappingURL=types.test-d.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.test-d.js","sourceRoot":"","sources":["../../src/modal/types.test-d.ts"],"names":[],"mappings":";;AAAA,mCAAsC;AAGtC,IAAI,CAAC,8BAA8B,EAAE,GAAG,EAAE;IACxC,IAAA,qBAAY,EAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,IAAA,qBAAY,EAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,YAAY,EAAE,OAAO;QACrB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,IAAA,qBAAY,EAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,iBAAiB,EAAE,OAAO;QAC1B,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,IAAA,qBAAY,EAAC;QACX,YAAY,EAAE,OAAO;QACrB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,IAAA,qBAAY,EAAC;QACX,iBAAiB,EAAE,OAAO;QAC1B,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,IAAA,qBAAY,EAAC;QACX,YAAY,EAAE,OAAO;QACrB,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;QACnB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,IAAA,qBAAY,EAAC;QACX,QAAQ,EAAE,eAAe;KAC1B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,IAAA,qBAAY,EAAC;QACX,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,6BAA6B;KACxC,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,IAAA,qBAAY,EAAC;QACX,IAAI,EAAE,IAAI;QACV,YAAY,EAAE,OAAO;QACrB,QAAQ,EAAE,iBAAiB;KAC5B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,IAAA,qBAAY,EAAC;QACX,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;QACnB,QAAQ,EAAE,eAAe;KAC1B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,IAAA,qBAAY,EAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,iBAAiB;KAC5B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,IAAA,qBAAY,EAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,YAAY,EAAE,OAAO;QACrB,iBAAiB,EAAE,OAAO;QAC1B,QAAQ,EAAE,kBAAkB;KAC7B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,IAAA,qBAAY,EAAC;QACX,YAAY,EAAE,OAAO;QACrB,iBAAiB,EAAE,OAAO;QAC1B,QAAQ,EAAE,kBAAkB;KAC7B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;AACrC,CAAC,CAAC,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Locale } from "date-fns";
|
|
2
|
-
import { Component, ComponentTranslation, Translations } from "./i18n.types";
|
|
3
|
-
type NestedKeyOf<ObjectType extends object> = {
|
|
4
|
-
[Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}.${NestedKeyOf<ObjectType[Key]>}` : `${Key}`;
|
|
5
|
-
}[keyof ObjectType & (string | number)];
|
|
6
|
-
export type TFunction<T extends Component> = (keypath: NestedKeyOf<Translations[T]>, replacements?: Record<string, string | number>) => string;
|
|
7
|
-
export declare function useI18n<T extends Component>(componentName: T, ...localTranslations: (ComponentTranslation<T> | undefined)[]): TFunction<T>;
|
|
8
|
-
export declare function useDateLocale(): Locale;
|
|
9
|
-
export {};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useI18n = useI18n;
|
|
4
|
-
exports.useDateLocale = useDateLocale;
|
|
5
|
-
const Provider_1 = require("../../provider/Provider");
|
|
6
|
-
const get_1 = require("./get");
|
|
7
|
-
/**
|
|
8
|
-
* https://regex101.com/r/LYKWi3/1
|
|
9
|
-
*/
|
|
10
|
-
const REPLACE_REGEX = /{[^}]*}/g;
|
|
11
|
-
function useI18n(componentName, ...localTranslations) {
|
|
12
|
-
const context = (0, Provider_1.useProvider)();
|
|
13
|
-
const contextTranslations = context.translations || [];
|
|
14
|
-
const i18nObjects = [
|
|
15
|
-
...localTranslations,
|
|
16
|
-
...(Array.isArray(contextTranslations)
|
|
17
|
-
? contextTranslations.map((t) => t[componentName])
|
|
18
|
-
: [contextTranslations[componentName]]),
|
|
19
|
-
context.locale[componentName],
|
|
20
|
-
];
|
|
21
|
-
/**
|
|
22
|
-
* https://github.com/Shopify/polaris/blob/2115f9ba2f5bcbf2ad15745233501bff2db81ecf/polaris-react/src/utilities/i18n/I18n.ts#L24
|
|
23
|
-
*/
|
|
24
|
-
const translate = (keypath, replacements) => {
|
|
25
|
-
const text = (0, get_1.get)(keypath, i18nObjects);
|
|
26
|
-
if (replacements) {
|
|
27
|
-
return text.replace(REPLACE_REGEX, (match) => {
|
|
28
|
-
const replacement = match.substring(1, match.length - 1);
|
|
29
|
-
if (replacements[replacement] === undefined) {
|
|
30
|
-
const replacementData = JSON.stringify(replacements);
|
|
31
|
-
throw new Error(`Error translating key '${keypath}'. No replacement syntax ({}) found for key '${replacement}'. The following replacements were passed: '${replacementData}'`);
|
|
32
|
-
}
|
|
33
|
-
return replacements[replacement]; // can also be a number, but JS doesn't mind...
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return text;
|
|
37
|
-
};
|
|
38
|
-
return translate;
|
|
39
|
-
}
|
|
40
|
-
function useDateLocale() {
|
|
41
|
-
const context = (0, Provider_1.useProvider)();
|
|
42
|
-
const contextTranslations = context.translations || [];
|
|
43
|
-
const i18nObjects = Array.isArray(contextTranslations)
|
|
44
|
-
? contextTranslations.map((t) => t.global)
|
|
45
|
-
: [contextTranslations.global];
|
|
46
|
-
i18nObjects.push(context.locale.global);
|
|
47
|
-
for (const obj of i18nObjects) {
|
|
48
|
-
if (obj === null || obj === void 0 ? void 0 : obj.dateLocale) {
|
|
49
|
-
return obj.dateLocale;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
throw new Error("dateLocale not found.");
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=i18n.context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.context.js","sourceRoot":"","sources":["../../../src/util/i18n/i18n.context.ts"],"names":[],"mappings":";;AA2BA,0BAuCC;AAED,sCAcC;AAjFD,sDAAsD;AACtD,+BAA4B;AAQ5B;;GAEG;AACH,MAAM,aAAa,GAAG,UAAU,CAAC;AAcjC,SAAgB,OAAO,CACrB,aAAgB,EAChB,GAAG,iBAA0D;IAE7D,MAAM,OAAO,GAAG,IAAA,sBAAW,GAAE,CAAC;IAC9B,MAAM,mBAAmB,GAAG,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC;IACvD,MAAM,WAAW,GAAwC;QACvD,GAAG,iBAAiB;QACpB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,mBAAmB,CAAC;YACpC,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;YAClD,CAAC,CAAC,CAAC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BAA+B,EAAE,IAAI;gBACrC,iCAAiC,EAAE,CAAC,IAAI;aACzC,CAAC,IAED,IAAI,CAAC,CAAC,CAAC,CACN,IAAI,CACL,CAAC,CAAC,CAAC,CACF,6BACE,KAAK,EAAC,UAAU,EAChB,MAAM,EAAC,UAAU,EACjB,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,uBAElC,SAAS,EAAE,KAAK,EAChB,IAAI,EAAC,KAAK;YAEV,8BAAM,KAAK,EAAC,GAAG,EAAC,MAAM,EAAC,GAAG,EAAC,EAAE,EAAC,GAAG,EAAC,IAAI,EAAC,cAAc,GAAG,CACpD,CACP,CACG,CACP;QAED;YACG,KAAK,IAAI,CACR,oBAAC,QAAQ,IAAC,EAAE,EAAC,GAAG,EAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAC,UAAU,IAC3C,KAAK,CACG,CACZ;YACA,QAAQ,CACL,CACH,CACN,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,QAAQ,CAAC,WAAW,GAAG,WAAW,CAAC;AACnC,eAAe,QAAQ,CAAC"}
|
package/esm/list/context.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/list/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAQtC,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAmB;IACzD,QAAQ,EAAE,IAAI;IACd,IAAI,EAAE,QAAQ;CACf,CAAC,CAAC"}
|
package/esm/list/types.js
DELETED
package/esm/list/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/list/types.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { expectTypeOf } from "vitest";
|
|
2
|
-
test("ModalProps works as intended", () => {
|
|
3
|
-
expectTypeOf({
|
|
4
|
-
header: { heading: "Label" },
|
|
5
|
-
children: "OK",
|
|
6
|
-
}).toMatchTypeOf();
|
|
7
|
-
expectTypeOf({
|
|
8
|
-
header: { heading: "Label" },
|
|
9
|
-
"aria-label": "Label",
|
|
10
|
-
children: "OK",
|
|
11
|
-
}).toMatchTypeOf();
|
|
12
|
-
expectTypeOf({
|
|
13
|
-
header: { heading: "Label" },
|
|
14
|
-
"aria-labelledby": "Label",
|
|
15
|
-
children: "OK",
|
|
16
|
-
}).toMatchTypeOf();
|
|
17
|
-
expectTypeOf({
|
|
18
|
-
"aria-label": "Label",
|
|
19
|
-
children: "OK",
|
|
20
|
-
}).toMatchTypeOf();
|
|
21
|
-
expectTypeOf({
|
|
22
|
-
"aria-labelledby": "Label",
|
|
23
|
-
children: "OK",
|
|
24
|
-
}).toMatchTypeOf();
|
|
25
|
-
expectTypeOf({
|
|
26
|
-
"aria-label": "Label",
|
|
27
|
-
open: true,
|
|
28
|
-
onClose: () => null,
|
|
29
|
-
children: "OK",
|
|
30
|
-
}).toMatchTypeOf();
|
|
31
|
-
expectTypeOf({
|
|
32
|
-
children: "Mangler label",
|
|
33
|
-
}).not.toMatchTypeOf();
|
|
34
|
-
expectTypeOf({
|
|
35
|
-
open: true,
|
|
36
|
-
children: "Mangler onClose eller label",
|
|
37
|
-
}).not.toMatchTypeOf();
|
|
38
|
-
expectTypeOf({
|
|
39
|
-
open: true,
|
|
40
|
-
"aria-label": "Label",
|
|
41
|
-
children: "Mangler onClose",
|
|
42
|
-
}).not.toMatchTypeOf();
|
|
43
|
-
expectTypeOf({
|
|
44
|
-
open: true,
|
|
45
|
-
onClose: () => null,
|
|
46
|
-
children: "Mangler label",
|
|
47
|
-
}).not.toMatchTypeOf();
|
|
48
|
-
expectTypeOf({
|
|
49
|
-
header: { heading: "Label" },
|
|
50
|
-
open: true,
|
|
51
|
-
children: "Mangler onClose",
|
|
52
|
-
}).not.toMatchTypeOf();
|
|
53
|
-
expectTypeOf({
|
|
54
|
-
header: { heading: "Label" },
|
|
55
|
-
"aria-label": "Label",
|
|
56
|
-
"aria-labelledby": "Label",
|
|
57
|
-
children: "For mange labels",
|
|
58
|
-
}).not.toMatchTypeOf();
|
|
59
|
-
expectTypeOf({
|
|
60
|
-
"aria-label": "Label",
|
|
61
|
-
"aria-labelledby": "Label",
|
|
62
|
-
children: "For mange labels",
|
|
63
|
-
}).not.toMatchTypeOf();
|
|
64
|
-
});
|
|
65
|
-
//# sourceMappingURL=types.test-d.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.test-d.js","sourceRoot":"","sources":["../../src/modal/types.test-d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,IAAI,CAAC,8BAA8B,EAAE,GAAG,EAAE;IACxC,YAAY,CAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,YAAY,CAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,YAAY,EAAE,OAAO;QACrB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,YAAY,CAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,iBAAiB,EAAE,OAAO;QAC1B,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,YAAY,CAAC;QACX,YAAY,EAAE,OAAO;QACrB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,YAAY,CAAC;QACX,iBAAiB,EAAE,OAAO;QAC1B,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,YAAY,CAAC;QACX,YAAY,EAAE,O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
|
2
|
-
import { Component, ComponentTranslation, Translations } from "./i18n.types.js";
|
|
3
|
-
type NestedKeyOf<ObjectType extends object> = {
|
|
4
|
-
[Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}.${NestedKeyOf<ObjectType[Key]>}` : `${Key}`;
|
|
5
|
-
}[keyof ObjectType & (string | number)];
|
|
6
|
-
export type TFunction<T extends Component> = (keypath: NestedKeyOf<Translations[T]>, replacements?: Record<string, string | number>) => string;
|
|
7
|
-
export declare function useI18n<T extends Component>(componentName: T, ...localTranslations: (ComponentTranslation<T> | undefined)[]): TFunction<T>;
|
|
8
|
-
export declare function useDateLocale(): Locale;
|
|
9
|
-
export {};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { useProvider } from "../../provider/Provider.js";
|
|
2
|
-
import { get } from "./get.js";
|
|
3
|
-
/**
|
|
4
|
-
* https://regex101.com/r/LYKWi3/1
|
|
5
|
-
*/
|
|
6
|
-
const REPLACE_REGEX = /{[^}]*}/g;
|
|
7
|
-
export function useI18n(componentName, ...localTranslations) {
|
|
8
|
-
const context = useProvider();
|
|
9
|
-
const contextTranslations = context.translations || [];
|
|
10
|
-
const i18nObjects = [
|
|
11
|
-
...localTranslations,
|
|
12
|
-
...(Array.isArray(contextTranslations)
|
|
13
|
-
? contextTranslations.map((t) => t[componentName])
|
|
14
|
-
: [contextTranslations[componentName]]),
|
|
15
|
-
context.locale[componentName],
|
|
16
|
-
];
|
|
17
|
-
/**
|
|
18
|
-
* https://github.com/Shopify/polaris/blob/2115f9ba2f5bcbf2ad15745233501bff2db81ecf/polaris-react/src/utilities/i18n/I18n.ts#L24
|
|
19
|
-
*/
|
|
20
|
-
const translate = (keypath, replacements) => {
|
|
21
|
-
const text = get(keypath, i18nObjects);
|
|
22
|
-
if (replacements) {
|
|
23
|
-
return text.replace(REPLACE_REGEX, (match) => {
|
|
24
|
-
const replacement = match.substring(1, match.length - 1);
|
|
25
|
-
if (replacements[replacement] === undefined) {
|
|
26
|
-
const replacementData = JSON.stringify(replacements);
|
|
27
|
-
throw new Error(`Error translating key '${keypath}'. No replacement syntax ({}) found for key '${replacement}'. The following replacements were passed: '${replacementData}'`);
|
|
28
|
-
}
|
|
29
|
-
return replacements[replacement]; // can also be a number, but JS doesn't mind...
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
return text;
|
|
33
|
-
};
|
|
34
|
-
return translate;
|
|
35
|
-
}
|
|
36
|
-
export function useDateLocale() {
|
|
37
|
-
const context = useProvider();
|
|
38
|
-
const contextTranslations = context.translations || [];
|
|
39
|
-
const i18nObjects = Array.isArray(contextTranslations)
|
|
40
|
-
? contextTranslations.map((t) => t.global)
|
|
41
|
-
: [contextTranslations.global];
|
|
42
|
-
i18nObjects.push(context.locale.global);
|
|
43
|
-
for (const obj of i18nObjects) {
|
|
44
|
-
if (obj === null || obj === void 0 ? void 0 : obj.dateLocale) {
|
|
45
|
-
return obj.dateLocale;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
throw new Error("dateLocale not found.");
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=i18n.context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.context.js","sourceRoot":"","sources":["../../../src/util/i18n/i18n.context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAQ5B;;GAEG;AACH,MAAM,aAAa,GAAG,UAAU,CAAC;AAcjC,MAAM,UAAU,OAAO,CACrB,aAAgB,EAChB,GAAG,iBAA0D;IAE7D,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAC9B,MAAM,mBAAmB,GAAG,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC;IACvD,MAAM,WAAW,GAAwC;QACvD,GAAG,iBAAiB;QACpB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,mBAAmB,CAAC;YACpC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