@olenbetong/appframe-ds 1.8.0 → 1.9.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/CHANGELOG.md +14 -0
- package/package.json +2 -2
- package/src/AfLookup/Lookup.css +16 -1
- package/src/AfLookup/Lookup.tsx +37 -12
- package/src/AfLookup/LookupCombobox.tsx +1 -9
- package/src/AfLookup/LookupEdit.tsx +5 -4
- package/src/AfLookup/LookupGrid.css +3 -2
- package/src/AfLookup/LookupGrid.tsx +8 -4
- package/src/autocomplete/Autocomplete.css +6 -17
- package/src/binding/BoundNumberInput.tsx +42 -42
- package/src/binding/BoundNumericTextField.tsx +102 -102
- package/src/binding/BoundTextField.tsx +49 -49
- package/src/binding/CancelButton.tsx +30 -30
- package/src/binding/CancelIconButton.tsx +30 -30
- package/src/binding/DataEditToolbar.css +23 -23
- package/src/binding/DataEditToolbar.tsx +84 -84
- package/src/binding/DeleteButton.tsx +35 -35
- package/src/binding/DeleteIconButton.tsx +35 -35
- package/src/binding/RefreshButton.tsx +31 -31
- package/src/binding/RefreshIconButton.tsx +33 -33
- package/src/binding/RefreshRowIconButton.tsx +33 -33
- package/src/binding/SaveButton.tsx +37 -37
- package/src/binding/SaveIconButton.tsx +38 -38
- package/src/binding/index.ts +20 -20
- package/src/container/Container.tsx +50 -50
- package/src/container/index.ts +1 -1
- package/src/cutoff/CutOffPicker.css +12 -12
- package/src/cutoff/CutOffPicker.tsx +165 -165
- package/src/cutoff/context.tsx +194 -194
- package/src/cutoff/dsCutOffDates.ts +21 -21
- package/src/cutoff/index.ts +4 -4
- package/src/cutoff/utils.test.ts +59 -59
- package/src/cutoff/utils.ts +276 -276
- package/src/filter/ChipListInput.tsx +79 -79
- package/src/filter/FieldFilterPanel.css +150 -150
- package/src/filter/FieldFilterPanel.tsx +303 -309
- package/src/filter/FilterBuilder.css +152 -152
- package/src/filter/FilterBuilder.test.tsx +153 -153
- package/src/filter/FilterBuilder.tsx +435 -435
- package/src/filter/FilterEditor.css +231 -231
- package/src/filter/FilterEditor.test.tsx +285 -285
- package/src/filter/FilterEditor.tsx +75 -75
- package/src/filter/FilterGroupEditor.tsx +160 -160
- package/src/filter/FilterNameDialog.css +22 -22
- package/src/filter/FilterNameDialog.tsx +81 -81
- package/src/filter/FilterRow.tsx +117 -117
- package/src/filter/FilterShareDialog.css +28 -28
- package/src/filter/FilterShareDialog.tsx +195 -201
- package/src/filter/FilterStringField.tsx +72 -78
- package/src/filter/FilterValueEditor.tsx +239 -239
- package/src/filter/SavedFilterTree.css +107 -107
- package/src/filter/SavedFilterTree.test.tsx +94 -94
- package/src/filter/SavedFilterTree.tsx +218 -218
- package/src/filter/fieldFilter.test.ts +158 -158
- package/src/filter/fieldFilter.ts +139 -139
- package/src/filter/index.ts +27 -27
- package/src/filter/types.ts +38 -38
- package/src/filter/useDistinctValues.test.ts +102 -102
- package/src/filter/useDistinctValues.ts +230 -230
- package/src/global.d.ts +11 -11
- package/src/grid/AfGridColumnsPanel.tsx +4 -7
- package/src/grid/AfGridError.tsx +2 -2
- package/src/grid/AfHeaderFilterCell.tsx +0 -3
- package/src/grid/AfHeaderFilterPanel.tsx +1 -3
- package/src/grid/GridEditLookup.tsx +3 -4
- package/src/grid/Toolbar.tsx +9 -38
- package/src/grid/index.css +44 -0
- package/src/grid/index.tsx +12 -3
- package/src/grid/slots/index.tsx +15 -40
- package/src/grid/useAfGridApi.ts +0 -1
- package/src/grid/useAfPersistedState.ts +4 -8
- package/src/grid/useAfSizeMode.ts +19 -0
- package/src/i18n.ts +13 -13
- package/src/index.ts +14 -14
- package/src/input/NumberInput.tsx +0 -2
- package/src/layout/AppMenu.tsx +74 -74
- package/src/layout/AppMenuDrawer.css +71 -71
- package/src/layout/AppMenuDrawer.tsx +122 -122
- package/src/layout/DialogMotion.css +79 -79
- package/src/layout/ErrorBoundary.tsx +162 -162
- package/src/layout/PageContainer.css +48 -48
- package/src/layout/PageContainer.tsx +41 -41
- package/src/layout/ResponsiveDialog.css +86 -86
- package/src/layout/ResponsiveDialog.tsx +55 -55
- package/src/layout/index.tsx +70 -70
- package/src/link/Link.tsx +23 -23
- package/src/link/index.ts +1 -1
- package/src/list/ItemList.css +2 -1
- package/src/mdi/Mdi.test.tsx +91 -91
- package/src/mdi/Mdi.tsx +141 -141
- package/src/mdi/MdiConfirmCloseDialog.tsx +41 -47
- package/src/mdi/MdiContext.tsx +59 -59
- package/src/mdi/MdiDocumentContext.tsx +60 -60
- package/src/mdi/MdiPanel.tsx +61 -61
- package/src/mdi/MdiRestore.test.tsx +86 -86
- package/src/mdi/MdiTab.tsx +30 -30
- package/src/mdi/controller.test.ts +382 -382
- package/src/mdi/controller.ts +656 -656
- package/src/mdi/dockviewHost.ts +132 -132
- package/src/mdi/fakeHost.ts +200 -200
- package/src/mdi/host.ts +44 -44
- package/src/mdi/ids.test.ts +20 -20
- package/src/mdi/ids.ts +18 -18
- package/src/mdi/index.ts +31 -31
- package/src/mdi/layoutRestore.test.ts +156 -156
- package/src/mdi/layoutRestore.ts +311 -311
- package/src/mdi/layoutSpec.test.ts +143 -143
- package/src/mdi/layoutSpec.ts +214 -214
- package/src/mdi/layoutStore.test.ts +93 -93
- package/src/mdi/layoutStore.ts +99 -99
- package/src/mdi/memorySettingsStore.ts +21 -21
- package/src/mdi/registry.ts +34 -34
- package/src/mdi/testTypes.ts +37 -37
- package/src/mdi/theme.ts +22 -22
- package/src/mdi/types.ts +214 -214
- package/src/page/Page.css +57 -57
- package/src/page/PageBlock.css +64 -64
- package/src/page/PageBlock.tsx +93 -93
- package/src/page/PageHeader.css +88 -88
- package/src/page/PageHeader.tsx +115 -115
- package/src/page/PageTitle.css +5 -5
- package/src/page/PageTitle.tsx +21 -21
- package/src/page/index.ts +4 -4
- package/src/paper/Paper.tsx +52 -52
- package/src/progress/LinearProgress.css +121 -121
- package/src/progress/LinearProgress.tsx +106 -106
- package/src/progress/index.ts +1 -1
- package/src/report-downloader/ReportDownloader.css +67 -67
- package/src/report-downloader/components/StatusItem.tsx +87 -87
- package/src/report-downloader/components/StatusList.tsx +28 -28
- package/src/report-downloader/index.ts +41 -41
- package/src/report-downloader/status.tsx +92 -92
- package/src/sortable/DropIndicator.css +51 -51
- package/src/sortable/DropIndicator.tsx +27 -27
- package/src/sortable/SortableItemList.css +21 -21
- package/src/sortable/SortableItemList.tsx +264 -264
- package/src/sortable/index.ts +8 -8
- package/src/sortable/reorderSortOrder.ts +126 -126
- package/src/sortable/sortOrder.ts +101 -101
- package/src/sortable/types.ts +9 -9
- package/src/sortable/useSortableContainer.ts +53 -53
- package/src/sortable/useSortableItem.ts +95 -95
- package/src/sortable/useSortableList.ts +117 -117
- package/src/test/happy-dom-document-class.ts +24 -24
- package/src/test/setup.ts +27 -27
- package/src/theme/sizeMode.ts +62 -0
- package/src/theme/useDsColorScheme.ts +53 -53
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import "./ResponsiveDialog.css";
|
|
2
|
-
|
|
3
|
-
import { Dialog, type DialogProps, Heading } from "@digdir/designsystemet-react";
|
|
4
|
-
import clsx from "clsx";
|
|
5
|
-
|
|
6
|
-
export type ResponsiveDialogMaxWidth = "xs" | "sm" | "md" | "lg" | "xl" | false;
|
|
7
|
-
|
|
8
|
-
export type ResponsiveDialogProps = Omit<DialogProps, "title" | "open" | "onClose"> & {
|
|
9
|
-
open: boolean;
|
|
10
|
-
onClose?: () => void;
|
|
11
|
-
title?: React.ReactNode;
|
|
12
|
-
/**
|
|
13
|
-
* Width of the dialog on screens wide enough for it, in MUI's breakpoint names (`sm` is
|
|
14
|
-
* 600px, `md` 900px, `lg` 1200px, `xl` 1536px). Below the next breakpoint up the dialog
|
|
15
|
-
* fills the screen. `false` fills the screen always.
|
|
16
|
-
*/
|
|
17
|
-
maxWidth?: ResponsiveDialogMaxWidth;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* A Designsystemet `Dialog` that is a centred, width-limited dialog on large screens and
|
|
22
|
-
* full-screen on small ones - the MUI `Dialog fullScreen` behaviour, decided by CSS media
|
|
23
|
-
* queries rather than a hook. The title goes in the first `Dialog.Block` with the dialog's own
|
|
24
|
-
* close button; put the content and actions in further `Dialog.Block`s.
|
|
25
|
-
*
|
|
26
|
-
* Equivalent of `ResponsiveDialog` in `@olenbetong/appframe-mui`. `onClose` takes no
|
|
27
|
-
* arguments: the dialog closes on the close button, the backdrop and Escape alike.
|
|
28
|
-
*/
|
|
29
|
-
export function ResponsiveDialog({
|
|
30
|
-
children,
|
|
31
|
-
className,
|
|
32
|
-
maxWidth = "sm",
|
|
33
|
-
onClose,
|
|
34
|
-
open,
|
|
35
|
-
title,
|
|
36
|
-
...props
|
|
37
|
-
}: ResponsiveDialogProps) {
|
|
38
|
-
return (
|
|
39
|
-
<Dialog
|
|
40
|
-
closedby="any"
|
|
41
|
-
{...props}
|
|
42
|
-
open={open}
|
|
43
|
-
onClose={onClose}
|
|
44
|
-
className={clsx("ObResponsiveDialog-root", className)}
|
|
45
|
-
data-max-width={maxWidth === false ? "none" : maxWidth}
|
|
46
|
-
>
|
|
47
|
-
{title && (
|
|
48
|
-
<Dialog.Block>
|
|
49
|
-
<Heading data-size="xs">{title}</Heading>
|
|
50
|
-
</Dialog.Block>
|
|
51
|
-
)}
|
|
52
|
-
{children}
|
|
53
|
-
</Dialog>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
1
|
+
import "./ResponsiveDialog.css";
|
|
2
|
+
|
|
3
|
+
import { Dialog, type DialogProps, Heading } from "@digdir/designsystemet-react";
|
|
4
|
+
import clsx from "clsx";
|
|
5
|
+
|
|
6
|
+
export type ResponsiveDialogMaxWidth = "xs" | "sm" | "md" | "lg" | "xl" | false;
|
|
7
|
+
|
|
8
|
+
export type ResponsiveDialogProps = Omit<DialogProps, "title" | "open" | "onClose"> & {
|
|
9
|
+
open: boolean;
|
|
10
|
+
onClose?: () => void;
|
|
11
|
+
title?: React.ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Width of the dialog on screens wide enough for it, in MUI's breakpoint names (`sm` is
|
|
14
|
+
* 600px, `md` 900px, `lg` 1200px, `xl` 1536px). Below the next breakpoint up the dialog
|
|
15
|
+
* fills the screen. `false` fills the screen always.
|
|
16
|
+
*/
|
|
17
|
+
maxWidth?: ResponsiveDialogMaxWidth;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A Designsystemet `Dialog` that is a centred, width-limited dialog on large screens and
|
|
22
|
+
* full-screen on small ones - the MUI `Dialog fullScreen` behaviour, decided by CSS media
|
|
23
|
+
* queries rather than a hook. The title goes in the first `Dialog.Block` with the dialog's own
|
|
24
|
+
* close button; put the content and actions in further `Dialog.Block`s.
|
|
25
|
+
*
|
|
26
|
+
* Equivalent of `ResponsiveDialog` in `@olenbetong/appframe-mui`. `onClose` takes no
|
|
27
|
+
* arguments: the dialog closes on the close button, the backdrop and Escape alike.
|
|
28
|
+
*/
|
|
29
|
+
export function ResponsiveDialog({
|
|
30
|
+
children,
|
|
31
|
+
className,
|
|
32
|
+
maxWidth = "sm",
|
|
33
|
+
onClose,
|
|
34
|
+
open,
|
|
35
|
+
title,
|
|
36
|
+
...props
|
|
37
|
+
}: ResponsiveDialogProps) {
|
|
38
|
+
return (
|
|
39
|
+
<Dialog
|
|
40
|
+
closedby="any"
|
|
41
|
+
{...props}
|
|
42
|
+
open={open}
|
|
43
|
+
onClose={onClose}
|
|
44
|
+
className={clsx("ObResponsiveDialog-root", className)}
|
|
45
|
+
data-max-width={maxWidth === false ? "none" : maxWidth}
|
|
46
|
+
>
|
|
47
|
+
{title && (
|
|
48
|
+
<Dialog.Block>
|
|
49
|
+
<Heading data-size="xs">{title}</Heading>
|
|
50
|
+
</Dialog.Block>
|
|
51
|
+
)}
|
|
52
|
+
{children}
|
|
53
|
+
</Dialog>
|
|
54
|
+
);
|
|
55
|
+
}
|
package/src/layout/index.tsx
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import "./index.css";
|
|
2
|
-
import "./DialogMotion.css";
|
|
3
|
-
|
|
4
|
-
import { useEffect, useState } from "react";
|
|
5
|
-
import type React from "react";
|
|
6
|
-
|
|
7
|
-
import { AppLayoutDesktop } from "./AppLayoutDesktop.js";
|
|
8
|
-
import { AppLayoutMobile } from "./AppLayoutMobile.js";
|
|
9
|
-
import type { AppMenuProps } from "./AppMenu.js";
|
|
10
|
-
|
|
11
|
-
export type AppLayoutProps = {
|
|
12
|
-
AppMenuProps?: AppMenuProps;
|
|
13
|
-
children: React.ReactNode | React.ReactNode[];
|
|
14
|
-
menu?: React.ReactNode | React.ReactNode[];
|
|
15
|
-
/**
|
|
16
|
-
* @deprecated The toolbar is now server-rendered. This prop has no effect.
|
|
17
|
-
*/
|
|
18
|
-
toolbar?: React.ReactNode | React.ReactNode[];
|
|
19
|
-
/**
|
|
20
|
-
* @deprecated The title is now rendered in the server-rendered toolbar. This prop has no effect.
|
|
21
|
-
*/
|
|
22
|
-
title?: React.ReactNode;
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated The toolbar is now server-rendered. This prop has no effect.
|
|
25
|
-
*/
|
|
26
|
-
enableMenuToggle?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Enable partner mode (for partner.olenbetong.no applications).
|
|
29
|
-
* Adds a toggle button to the existing partner header instead of the app bar.
|
|
30
|
-
*/
|
|
31
|
-
partner?: boolean;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
function useIsMobile() {
|
|
35
|
-
let [isMobile, setIsMobile] = useState(() => {
|
|
36
|
-
if (typeof window === "undefined") return false;
|
|
37
|
-
return window.matchMedia("(max-width: 1199px)").matches;
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
let mq = window.matchMedia("(max-width: 1199px)");
|
|
42
|
-
let handler = (e: MediaQueryListEvent) => setIsMobile(e.matches);
|
|
43
|
-
mq.addEventListener("change", handler);
|
|
44
|
-
return () => mq.removeEventListener("change", handler);
|
|
45
|
-
}, []);
|
|
46
|
-
|
|
47
|
-
return isMobile;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export * from "./AppMenu.js";
|
|
51
|
-
export * from "./AppMenuDrawer.js";
|
|
52
|
-
export * from "./AppMenuItem.js";
|
|
53
|
-
export * from "./AppMenuSubheader.js";
|
|
54
|
-
export * from "./constants.js";
|
|
55
|
-
export * from "./ErrorBoundary.js";
|
|
56
|
-
export * from "./PageContainer.js";
|
|
57
|
-
export * from "./ResponsiveDialog.js";
|
|
58
|
-
export * from "./PartnerToggle.js";
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* @deprecated Use the `Page` primitives instead (`Page`, `Page.Header`,
|
|
62
|
-
* `Page.Block`). `<AppLayout menu={...} title={...}>` becomes
|
|
63
|
-
* `<Page layout="app"><Page.Header title={...} menu={...} />...</Page>`.
|
|
64
|
-
*/
|
|
65
|
-
export function AppLayout(props: AppLayoutProps) {
|
|
66
|
-
let isSmall = useIsMobile();
|
|
67
|
-
let Component = isSmall ? AppLayoutMobile : AppLayoutDesktop;
|
|
68
|
-
|
|
69
|
-
return <Component {...props} />;
|
|
70
|
-
}
|
|
1
|
+
import "./index.css";
|
|
2
|
+
import "./DialogMotion.css";
|
|
3
|
+
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
import type React from "react";
|
|
6
|
+
|
|
7
|
+
import { AppLayoutDesktop } from "./AppLayoutDesktop.js";
|
|
8
|
+
import { AppLayoutMobile } from "./AppLayoutMobile.js";
|
|
9
|
+
import type { AppMenuProps } from "./AppMenu.js";
|
|
10
|
+
|
|
11
|
+
export type AppLayoutProps = {
|
|
12
|
+
AppMenuProps?: AppMenuProps;
|
|
13
|
+
children: React.ReactNode | React.ReactNode[];
|
|
14
|
+
menu?: React.ReactNode | React.ReactNode[];
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated The toolbar is now server-rendered. This prop has no effect.
|
|
17
|
+
*/
|
|
18
|
+
toolbar?: React.ReactNode | React.ReactNode[];
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated The title is now rendered in the server-rendered toolbar. This prop has no effect.
|
|
21
|
+
*/
|
|
22
|
+
title?: React.ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated The toolbar is now server-rendered. This prop has no effect.
|
|
25
|
+
*/
|
|
26
|
+
enableMenuToggle?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Enable partner mode (for partner.olenbetong.no applications).
|
|
29
|
+
* Adds a toggle button to the existing partner header instead of the app bar.
|
|
30
|
+
*/
|
|
31
|
+
partner?: boolean;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
function useIsMobile() {
|
|
35
|
+
let [isMobile, setIsMobile] = useState(() => {
|
|
36
|
+
if (typeof window === "undefined") return false;
|
|
37
|
+
return window.matchMedia("(max-width: 1199px)").matches;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
let mq = window.matchMedia("(max-width: 1199px)");
|
|
42
|
+
let handler = (e: MediaQueryListEvent) => setIsMobile(e.matches);
|
|
43
|
+
mq.addEventListener("change", handler);
|
|
44
|
+
return () => mq.removeEventListener("change", handler);
|
|
45
|
+
}, []);
|
|
46
|
+
|
|
47
|
+
return isMobile;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export * from "./AppMenu.js";
|
|
51
|
+
export * from "./AppMenuDrawer.js";
|
|
52
|
+
export * from "./AppMenuItem.js";
|
|
53
|
+
export * from "./AppMenuSubheader.js";
|
|
54
|
+
export * from "./constants.js";
|
|
55
|
+
export * from "./ErrorBoundary.js";
|
|
56
|
+
export * from "./PageContainer.js";
|
|
57
|
+
export * from "./ResponsiveDialog.js";
|
|
58
|
+
export * from "./PartnerToggle.js";
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @deprecated Use the `Page` primitives instead (`Page`, `Page.Header`,
|
|
62
|
+
* `Page.Block`). `<AppLayout menu={...} title={...}>` becomes
|
|
63
|
+
* `<Page layout="app"><Page.Header title={...} menu={...} />...</Page>`.
|
|
64
|
+
*/
|
|
65
|
+
export function AppLayout(props: AppLayoutProps) {
|
|
66
|
+
let isSmall = useIsMobile();
|
|
67
|
+
let Component = isSmall ? AppLayoutMobile : AppLayoutDesktop;
|
|
68
|
+
|
|
69
|
+
return <Component {...props} />;
|
|
70
|
+
}
|
package/src/link/Link.tsx
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { Link as DsLink, type LinkProps as DsLinkProps } from "@digdir/designsystemet-react";
|
|
2
|
-
import { forwardRef } from "react";
|
|
3
|
-
import { Link as RouterLink, type LinkProps as RouterLinkProps } from "react-router";
|
|
4
|
-
|
|
5
|
-
export type LinkProps = Omit<DsLinkProps, "href" | "asChild"> &
|
|
6
|
-
Omit<RouterLinkProps, "to" | "children"> & {
|
|
7
|
-
/** The in-app path, resolved by react-router. */
|
|
8
|
-
href: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* A Designsystemet `Link` that navigates with react-router: `href` is the route, the
|
|
13
|
-
* navigation is a view transition. Equivalent of `Link` in `@olenbetong/appframe-mui`.
|
|
14
|
-
*/
|
|
15
|
-
export const Link = forwardRef<HTMLAnchorElement, LinkProps>(function Link({ href, children, ...props }, ref) {
|
|
16
|
-
return (
|
|
17
|
-
<DsLink asChild>
|
|
18
|
-
<RouterLink viewTransition to={href} {...props} ref={ref}>
|
|
19
|
-
{children}
|
|
20
|
-
</RouterLink>
|
|
21
|
-
</DsLink>
|
|
22
|
-
);
|
|
23
|
-
});
|
|
1
|
+
import { Link as DsLink, type LinkProps as DsLinkProps } from "@digdir/designsystemet-react";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { Link as RouterLink, type LinkProps as RouterLinkProps } from "react-router";
|
|
4
|
+
|
|
5
|
+
export type LinkProps = Omit<DsLinkProps, "href" | "asChild"> &
|
|
6
|
+
Omit<RouterLinkProps, "to" | "children"> & {
|
|
7
|
+
/** The in-app path, resolved by react-router. */
|
|
8
|
+
href: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A Designsystemet `Link` that navigates with react-router: `href` is the route, the
|
|
13
|
+
* navigation is a view transition. Equivalent of `Link` in `@olenbetong/appframe-mui`.
|
|
14
|
+
*/
|
|
15
|
+
export const Link = forwardRef<HTMLAnchorElement, LinkProps>(function Link({ href, children, ...props }, ref) {
|
|
16
|
+
return (
|
|
17
|
+
<DsLink asChild>
|
|
18
|
+
<RouterLink viewTransition to={href} {...props} ref={ref}>
|
|
19
|
+
{children}
|
|
20
|
+
</RouterLink>
|
|
21
|
+
</DsLink>
|
|
22
|
+
);
|
|
23
|
+
});
|
package/src/link/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./Link.js";
|
|
1
|
+
export * from "./Link.js";
|
package/src/list/ItemList.css
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
.ObItemListItemText-secondary {
|
|
28
|
-
|
|
28
|
+
/* Follows the size mode, but never under 0.75rem: at xs the step itself is too small to read. */
|
|
29
|
+
font-size: max(var(--ds-font-size-2, 0.875rem), 0.75rem);
|
|
29
30
|
color: var(--ds-color-neutral-text-subtle, #666);
|
|
30
31
|
}
|
package/src/mdi/Mdi.test.tsx
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
import { act, render, screen } from "@testing-library/react";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { describe, expect, it, vi } from "vitest";
|
|
4
|
-
|
|
5
|
-
import { Mdi } from "./Mdi.js";
|
|
6
|
-
import { MdiProvider, useMdi, useMdiActiveDocument } from "./MdiContext.js";
|
|
7
|
-
import { useMdiDocument } from "./MdiDocumentContext.js";
|
|
8
|
-
import type { MdiApi, MdiDocumentProps, MdiDocumentTypes, MdiLayoutSpec } from "./types.js";
|
|
9
|
-
|
|
10
|
-
vi.mock("@olenbetong/appframe-core", () => ({
|
|
11
|
-
getLocalizedString: (value: string) => value,
|
|
12
|
-
createLocalizer: () => ({
|
|
13
|
-
getLocalizedString: (value: string) => value,
|
|
14
|
-
localize: (parts: TemplateStringsArray) => parts.join(""),
|
|
15
|
-
}),
|
|
16
|
-
}));
|
|
17
|
-
|
|
18
|
-
function Note({ params }: MdiDocumentProps<{ label: string }>) {
|
|
19
|
-
let document = useMdiDocument();
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<div data-testid={document.id}>
|
|
23
|
-
<span>{params.label}</span>
|
|
24
|
-
<button type="button" onClick={() => document.setTitle(`${params.label}!`)}>
|
|
25
|
-
rename
|
|
26
|
-
</button>
|
|
27
|
-
</div>
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function ActiveLabel() {
|
|
32
|
-
let active = useMdiActiveDocument();
|
|
33
|
-
return <output data-testid="active">{active?.id ?? "none"}</output>;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let apiRef: { current: MdiApi | null } = { current: null };
|
|
37
|
-
|
|
38
|
-
function Grab() {
|
|
39
|
-
let api = useMdi();
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
apiRef.current = api;
|
|
42
|
-
});
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const types: MdiDocumentTypes = {
|
|
47
|
-
note: { component: Note, title: (params) => `Note ${params.label as string}` },
|
|
48
|
-
tree: { component: Note, singleton: true, closable: false, title: "Tree" },
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const spec: MdiLayoutSpec = {
|
|
52
|
-
root: {
|
|
53
|
-
direction: "horizontal",
|
|
54
|
-
children: [
|
|
55
|
-
{ tabs: [{ type: "tree", params: { label: "Tree" } }], hideHeader: true },
|
|
56
|
-
{ tabs: [{ type: "note", key: "1", params: { label: "First" } }] },
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
describe("Mdi", () => {
|
|
62
|
-
it("renders the default layout through dockview and exposes the api", async () => {
|
|
63
|
-
render(
|
|
64
|
-
<MdiProvider types={types}>
|
|
65
|
-
<Grab />
|
|
66
|
-
<ActiveLabel />
|
|
67
|
-
<div style={{ width: 800, height: 600 }}>
|
|
68
|
-
<Mdi defaultLayout={spec} />
|
|
69
|
-
</div>
|
|
70
|
-
</MdiProvider>,
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
expect(await screen.findByText("First")).toBeInTheDocument();
|
|
74
|
-
expect(screen.getByTestId("tree")).toBeInTheDocument();
|
|
75
|
-
expect(apiRef.current?.getDocuments().map((document) => document.id)).toEqual(["tree", "note:1"]);
|
|
76
|
-
|
|
77
|
-
await act(async () => {
|
|
78
|
-
apiRef.current!.openDocument({ type: "note", key: "2", params: { label: "Second" } });
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
expect(await screen.findByText("Second")).toBeInTheDocument();
|
|
82
|
-
expect(screen.getByTestId("active")).toHaveTextContent("note:2");
|
|
83
|
-
|
|
84
|
-
await act(async () => {
|
|
85
|
-
await apiRef.current!.close("note:2");
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
expect(screen.queryByText("Second")).not.toBeInTheDocument();
|
|
89
|
-
expect(apiRef.current?.getDocument("tree")?.closable).toBe(false);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
1
|
+
import { act, render, screen } from "@testing-library/react";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { describe, expect, it, vi } from "vitest";
|
|
4
|
+
|
|
5
|
+
import { Mdi } from "./Mdi.js";
|
|
6
|
+
import { MdiProvider, useMdi, useMdiActiveDocument } from "./MdiContext.js";
|
|
7
|
+
import { useMdiDocument } from "./MdiDocumentContext.js";
|
|
8
|
+
import type { MdiApi, MdiDocumentProps, MdiDocumentTypes, MdiLayoutSpec } from "./types.js";
|
|
9
|
+
|
|
10
|
+
vi.mock("@olenbetong/appframe-core", () => ({
|
|
11
|
+
getLocalizedString: (value: string) => value,
|
|
12
|
+
createLocalizer: () => ({
|
|
13
|
+
getLocalizedString: (value: string) => value,
|
|
14
|
+
localize: (parts: TemplateStringsArray) => parts.join(""),
|
|
15
|
+
}),
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
function Note({ params }: MdiDocumentProps<{ label: string }>) {
|
|
19
|
+
let document = useMdiDocument();
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div data-testid={document.id}>
|
|
23
|
+
<span>{params.label}</span>
|
|
24
|
+
<button type="button" onClick={() => document.setTitle(`${params.label}!`)}>
|
|
25
|
+
rename
|
|
26
|
+
</button>
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function ActiveLabel() {
|
|
32
|
+
let active = useMdiActiveDocument();
|
|
33
|
+
return <output data-testid="active">{active?.id ?? "none"}</output>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let apiRef: { current: MdiApi | null } = { current: null };
|
|
37
|
+
|
|
38
|
+
function Grab() {
|
|
39
|
+
let api = useMdi();
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
apiRef.current = api;
|
|
42
|
+
});
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const types: MdiDocumentTypes = {
|
|
47
|
+
note: { component: Note, title: (params) => `Note ${params.label as string}` },
|
|
48
|
+
tree: { component: Note, singleton: true, closable: false, title: "Tree" },
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const spec: MdiLayoutSpec = {
|
|
52
|
+
root: {
|
|
53
|
+
direction: "horizontal",
|
|
54
|
+
children: [
|
|
55
|
+
{ tabs: [{ type: "tree", params: { label: "Tree" } }], hideHeader: true },
|
|
56
|
+
{ tabs: [{ type: "note", key: "1", params: { label: "First" } }] },
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
describe("Mdi", () => {
|
|
62
|
+
it("renders the default layout through dockview and exposes the api", async () => {
|
|
63
|
+
render(
|
|
64
|
+
<MdiProvider types={types}>
|
|
65
|
+
<Grab />
|
|
66
|
+
<ActiveLabel />
|
|
67
|
+
<div style={{ width: 800, height: 600 }}>
|
|
68
|
+
<Mdi defaultLayout={spec} />
|
|
69
|
+
</div>
|
|
70
|
+
</MdiProvider>,
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
expect(await screen.findByText("First")).toBeInTheDocument();
|
|
74
|
+
expect(screen.getByTestId("tree")).toBeInTheDocument();
|
|
75
|
+
expect(apiRef.current?.getDocuments().map((document) => document.id)).toEqual(["tree", "note:1"]);
|
|
76
|
+
|
|
77
|
+
await act(async () => {
|
|
78
|
+
apiRef.current!.openDocument({ type: "note", key: "2", params: { label: "Second" } });
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
expect(await screen.findByText("Second")).toBeInTheDocument();
|
|
82
|
+
expect(screen.getByTestId("active")).toHaveTextContent("note:2");
|
|
83
|
+
|
|
84
|
+
await act(async () => {
|
|
85
|
+
await apiRef.current!.close("note:2");
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
expect(screen.queryByText("Second")).not.toBeInTheDocument();
|
|
89
|
+
expect(apiRef.current?.getDocument("tree")?.closable).toBe(false);
|
|
90
|
+
});
|
|
91
|
+
});
|