@olenbetong/appframe-ds 1.1.0 → 1.3.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/CHANGELOG.md +18 -0
- package/package.json +8 -7
- package/scripts/copyAssets.mjs +23 -51
- package/src/AfLookup/Lookup.css +4 -0
- package/src/AfLookup/Lookup.tsx +24 -2
- package/src/cutoff/CutOffPicker.css +12 -0
- package/src/cutoff/CutOffPicker.tsx +165 -0
- package/src/cutoff/context.tsx +194 -0
- package/src/cutoff/dsCutOffDates.ts +21 -0
- package/src/cutoff/index.ts +4 -0
- package/src/cutoff/utils.test.ts +59 -0
- package/src/cutoff/utils.ts +276 -0
- package/src/grid/GridEditLookup.css +12 -0
- package/src/grid/GridEditLookup.tsx +121 -0
- package/src/grid/index.tsx +19 -0
- package/src/grid/useAfServerAggregation.test.ts +68 -0
- package/src/grid/useAfServerAggregation.ts +13 -0
- package/src/index.ts +2 -0
- package/src/layout/PageContainer.css +21 -2
- package/src/layout/PageContainer.tsx +18 -2
- package/src/layout/ResponsiveDialog.css +86 -0
- package/src/layout/ResponsiveDialog.tsx +55 -0
- package/src/layout/index.tsx +1 -0
- package/src/link/Link.tsx +23 -0
- package/src/link/index.ts +1 -0
- package/src/page/PageTitle.css +5 -0
- package/src/page/PageTitle.tsx +21 -0
- package/src/page/index.ts +1 -0
|
@@ -3,9 +3,25 @@ import "./PageContainer.css";
|
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import type React from "react";
|
|
5
5
|
|
|
6
|
+
export type PageContainerMaxWidth = "xs" | "sm" | "md" | "lg" | "xl" | false;
|
|
7
|
+
|
|
6
8
|
export type PageContainerProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
7
9
|
fullHeight?: boolean;
|
|
8
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Predefined max-width of the content, on the MUI `Container` scale (`xs`/`sm` 36rem,
|
|
12
|
+
* `md` 48rem, `lg` 64rem, `xl` 80rem, plus the gutters). The content stays against the
|
|
13
|
+
* leading edge, as the MUI-era `PageContainer` did; `Page.Block`/`Container` centre it.
|
|
14
|
+
* @default max-width: 100%
|
|
15
|
+
*/
|
|
16
|
+
maxWidth?: PageContainerMaxWidth;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const maxWidthClassName: Record<Exclude<PageContainerMaxWidth, false>, string> = {
|
|
20
|
+
xs: "ObPageContainer-text",
|
|
21
|
+
sm: "ObPageContainer-text",
|
|
22
|
+
md: "ObPageContainer-md",
|
|
23
|
+
lg: "ObPageContainer-lg",
|
|
24
|
+
xl: "ObPageContainer-xl",
|
|
9
25
|
};
|
|
10
26
|
|
|
11
27
|
/**
|
|
@@ -17,7 +33,7 @@ export type PageContainerProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
17
33
|
export function PageContainer({ children, className, fullHeight, maxWidth, ...props }: PageContainerProps) {
|
|
18
34
|
return (
|
|
19
35
|
<div className={clsx("ObPageContainer-root", fullHeight && "ObPageContainer-fullHeight")}>
|
|
20
|
-
<div className={clsx("ObPageContainer-inner", className)} {...props}>
|
|
36
|
+
<div className={clsx("ObPageContainer-inner", maxWidth && maxWidthClassName[maxWidth], className)} {...props}>
|
|
21
37
|
{children}
|
|
22
38
|
</div>
|
|
23
39
|
</div>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Width-limited on large screens, full-screen below the next MUI breakpoint up:
|
|
3
|
+
* xs (444px) fills below 600px, sm (600px) below 900px, md (900px) below 1200px,
|
|
4
|
+
* lg (1200px) below 1536px, xl (1536px) below 1920px, none always.
|
|
5
|
+
*/
|
|
6
|
+
@layer ds {
|
|
7
|
+
.ObResponsiveDialog-root {
|
|
8
|
+
width: 100%;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.ObResponsiveDialog-root[data-max-width="xs"] {
|
|
12
|
+
max-width: 444px;
|
|
13
|
+
}
|
|
14
|
+
.ObResponsiveDialog-root[data-max-width="sm"] {
|
|
15
|
+
max-width: 600px;
|
|
16
|
+
}
|
|
17
|
+
.ObResponsiveDialog-root[data-max-width="md"] {
|
|
18
|
+
max-width: 900px;
|
|
19
|
+
}
|
|
20
|
+
.ObResponsiveDialog-root[data-max-width="lg"] {
|
|
21
|
+
max-width: 1200px;
|
|
22
|
+
}
|
|
23
|
+
.ObResponsiveDialog-root[data-max-width="xl"] {
|
|
24
|
+
max-width: 1536px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.ObResponsiveDialog-root[data-max-width="none"] {
|
|
28
|
+
max-width: none;
|
|
29
|
+
width: 100vw;
|
|
30
|
+
height: 100dvh;
|
|
31
|
+
max-height: none;
|
|
32
|
+
margin: 0;
|
|
33
|
+
border-radius: 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@media (max-width: 599.98px) {
|
|
37
|
+
.ObResponsiveDialog-root[data-max-width="xs"] {
|
|
38
|
+
max-width: none;
|
|
39
|
+
width: 100vw;
|
|
40
|
+
height: 100dvh;
|
|
41
|
+
max-height: none;
|
|
42
|
+
margin: 0;
|
|
43
|
+
border-radius: 0;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
@media (max-width: 899.98px) {
|
|
47
|
+
.ObResponsiveDialog-root[data-max-width="sm"] {
|
|
48
|
+
max-width: none;
|
|
49
|
+
width: 100vw;
|
|
50
|
+
height: 100dvh;
|
|
51
|
+
max-height: none;
|
|
52
|
+
margin: 0;
|
|
53
|
+
border-radius: 0;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
@media (max-width: 1199.98px) {
|
|
57
|
+
.ObResponsiveDialog-root[data-max-width="md"] {
|
|
58
|
+
max-width: none;
|
|
59
|
+
width: 100vw;
|
|
60
|
+
height: 100dvh;
|
|
61
|
+
max-height: none;
|
|
62
|
+
margin: 0;
|
|
63
|
+
border-radius: 0;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
@media (max-width: 1535.98px) {
|
|
67
|
+
.ObResponsiveDialog-root[data-max-width="lg"] {
|
|
68
|
+
max-width: none;
|
|
69
|
+
width: 100vw;
|
|
70
|
+
height: 100dvh;
|
|
71
|
+
max-height: none;
|
|
72
|
+
margin: 0;
|
|
73
|
+
border-radius: 0;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
@media (max-width: 1919.98px) {
|
|
77
|
+
.ObResponsiveDialog-root[data-max-width="xl"] {
|
|
78
|
+
max-width: none;
|
|
79
|
+
width: 100vw;
|
|
80
|
+
height: 100dvh;
|
|
81
|
+
max-height: none;
|
|
82
|
+
margin: 0;
|
|
83
|
+
border-radius: 0;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +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
|
+
}
|
package/src/layout/index.tsx
CHANGED
|
@@ -0,0 +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
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Link.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "./PageTitle.css";
|
|
2
|
+
|
|
3
|
+
import { Heading, type HeadingProps } from "@digdir/designsystemet-react";
|
|
4
|
+
import clsx from "clsx";
|
|
5
|
+
|
|
6
|
+
export type PageTitleProps = Omit<HeadingProps, "level"> & {
|
|
7
|
+
/** Heading level; the page's title is an `h1` unless the page already has one. */
|
|
8
|
+
level?: HeadingProps["level"];
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The title at the top of a page's content: a Designsystemet `Heading`, `h1`, medium size.
|
|
13
|
+
*
|
|
14
|
+
* Equivalent of `PageTitle` in `@olenbetong/appframe-mui`, which portalled the title into
|
|
15
|
+
* the app bar on small screens. On the 2026 templates the site draws the toolbar and the app
|
|
16
|
+
* title lives there as breadcrumbs, so the page title is simply the first heading of the
|
|
17
|
+
* content.
|
|
18
|
+
*/
|
|
19
|
+
export function PageTitle({ className, level = 1, "data-size": size = "md", ...props }: PageTitleProps) {
|
|
20
|
+
return <Heading level={level} data-size={size} className={clsx("ObPageTitle-root", className)} {...props} />;
|
|
21
|
+
}
|
package/src/page/index.ts
CHANGED