dibk-designsystemet 1.0.0-rc.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.
@@ -0,0 +1,280 @@
1
+ export * from '@digdir/designsystemet-react';
2
+ import * as react from 'react';
3
+ import { SVGProps, ComponentPropsWithoutRef, ReactNode, ElementType } from 'react';
4
+
5
+ interface DibkLogoProps extends SVGProps<SVGSVGElement> {
6
+ /** "full" = roofline mark + wordmark; "mark" = roofline only. */
7
+ variant?: "full" | "mark";
8
+ }
9
+ /**
10
+ * DIBK brand mark. `full` renders the roofline mark + "Direktoratet for
11
+ * byggkvalitet" wordmark; `mark` renders the roofline only. Color is inherited
12
+ * via currentColor (navy by default; set color to recolor, e.g. white on navy).
13
+ */
14
+ declare const DibkLogo: react.ForwardRefExoticComponent<Omit<DibkLogoProps, "ref"> & react.RefAttributes<SVGSVGElement>>;
15
+
16
+ /** A highlighted shortcut shown in the top bar beside the menu toggle. */
17
+ interface DibkHeaderShortcut {
18
+ label: string;
19
+ href: string;
20
+ }
21
+ interface DibkHeaderProps extends ComponentPropsWithoutRef<"header"> {
22
+ /** Whether the mega-menu is open (controls the Meny toggle state). */
23
+ menuOpen?: boolean;
24
+ onMenuToggle?: () => void;
25
+ /** id of the menu panel the Meny toggle controls (wired to aria-controls). */
26
+ menuPanelId?: string;
27
+ onSearchToggle?: () => void;
28
+ /**
29
+ * Render the "Søk" button. Defaults to true. Set false in apps whose search
30
+ * lives elsewhere (e.g. a page hero) so the header shows only "Meny".
31
+ */
32
+ search?: boolean;
33
+ /**
34
+ * Highlighted shortcut links rendered before Søk/Meny. On narrow viewports
35
+ * they collapse; reach them through the menu instead.
36
+ */
37
+ shortcuts?: DibkHeaderShortcut[];
38
+ /**
39
+ * Account/login control rendered rightmost in the bar, after Søk/Meny. Unlike
40
+ * shortcuts it does not collapse on narrow viewports, so sign-in state stays
41
+ * visible. The app owns the content (login button, avatar dropdown, ...).
42
+ */
43
+ account?: ReactNode;
44
+ /** Optional brand link target (logo href). */
45
+ homeHref?: string;
46
+ /**
47
+ * Component used to render the brand and shortcut links (receives `href`).
48
+ * Pass a router Link adapter for client-side navigation; defaults to `a`.
49
+ */
50
+ linkComponent?: ElementType;
51
+ }
52
+ /**
53
+ * DIBK top bar: roofline logo (linking home) on the left; an optional "Søk"
54
+ * button and the "Meny" (hamburger) toggle on the right. The toggle is a
55
+ * disclosure control for the menu panel: it swaps to
56
+ * "Lukk" + X while open and announces state via aria-expanded/aria-controls.
57
+ * Search and menu state are owned by the caller.
58
+ */
59
+ declare const DibkHeader: react.ForwardRefExoticComponent<DibkHeaderProps & react.RefAttributes<HTMLElement>>;
60
+
61
+ interface DibkMegaMenuProps extends ComponentPropsWithoutRef<"div"> {
62
+ open: boolean;
63
+ onClose: () => void;
64
+ /** Render the built-in search field (default true). Set false in apps whose
65
+ * search lives elsewhere, mirroring DibkHeader's `search`. */
66
+ search?: boolean;
67
+ /** Placeholder for the built-in search field (default "Søk"). */
68
+ searchPlaceholder?: string;
69
+ /** Fired when the built-in search field is submitted. */
70
+ onSearchSubmit?: (query: string) => void;
71
+ /** Optional hint line inside the search widget, under the field
72
+ * (e.g. "Søk etter f.eks. rekkverk eller bruksendring"). */
73
+ searchHint?: ReactNode;
74
+ }
75
+ /**
76
+ * DIBK navigation panel: a full-width disclosure that expands in document flow
77
+ * below the header: the page content is pushed down and the header stays
78
+ * visible. The header's Meny button owns the open state and
79
+ * references the panel via aria-expanded/aria-controls; this component renders
80
+ * the panel content: an optional large underline search field, then `children`
81
+ * (the caller owns the content layout). Escape closes the panel and hands
82
+ * focus back to the toggle.
83
+ */
84
+ declare const DibkMegaMenu: react.ForwardRefExoticComponent<DibkMegaMenuProps & react.RefAttributes<HTMLDivElement>>;
85
+
86
+ interface DibkIconLinkItem {
87
+ label: string;
88
+ href: string;
89
+ icon?: ReactNode;
90
+ description?: ReactNode;
91
+ /** Mark the item login-gated: renders a padlock after the label (with screen-reader text). */
92
+ locked?: boolean;
93
+ }
94
+ interface DibkIconLinkListProps extends ComponentPropsWithoutRef<"ul"> {
95
+ items: DibkIconLinkItem[];
96
+ /** Number of columns the list flows into. */
97
+ columns?: 1 | 2 | 3;
98
+ /** Render the chevron before each label (default true). Drop it where the
99
+ * list reads as a panel of shortcuts rather than a navigation list. */
100
+ chevron?: boolean;
101
+ /**
102
+ * Component used to render the item links (receives `href`). Pass a router
103
+ * Link adapter for client-side navigation; defaults to `a`.
104
+ */
105
+ linkComponent?: ElementType;
106
+ }
107
+ declare const DibkIconLinkList: react.ForwardRefExoticComponent<DibkIconLinkListProps & react.RefAttributes<HTMLUListElement>>;
108
+
109
+ interface DibkMenuSectionProps extends Omit<ComponentPropsWithoutRef<"section">, "title"> {
110
+ /** Section heading (24px semibold navy beside a 40px icon). */
111
+ title: ReactNode;
112
+ /** Make the title itself a link (section titles point at landing pages). */
113
+ href?: string;
114
+ /** 40x40 illustration beside the title. */
115
+ icon?: ReactNode;
116
+ /** The section's links. */
117
+ items: DibkIconLinkItem[];
118
+ /**
119
+ * Component used to render the links (receives `href`). Pass a router Link
120
+ * adapter for client-side navigation; defaults to `a`.
121
+ */
122
+ linkComponent?: ElementType;
123
+ }
124
+ /**
125
+ * One section of the DIBK menu panel: an optional 40px
126
+ * icon + a title row, then an indented chevron-link list. Stack sections
127
+ * inside `.dibk-megamenu__column` wrappers for the two-column menu layout.
128
+ */
129
+ declare const DibkMenuSection: react.ForwardRefExoticComponent<DibkMenuSectionProps & react.RefAttributes<HTMLElement>>;
130
+
131
+ interface DibkSearchProps extends Omit<ComponentPropsWithoutRef<"form">, "onSubmit" | "onChange"> {
132
+ /** Placeholder text; also the input's accessible name. */
133
+ placeholder?: string;
134
+ /** Optional hint line under the field (e.g. example searches). */
135
+ hint?: ReactNode;
136
+ /** Controlled value. Omit (with onValueChange) for uncontrolled use. */
137
+ value?: string;
138
+ onValueChange?: (value: string) => void;
139
+ /** Fired with the query when the form submits (Enter or the magnifier). */
140
+ onSearch?: (query: string) => void;
141
+ /** Fired when the clear button empties the field. */
142
+ onClear?: () => void;
143
+ inputId?: string;
144
+ }
145
+ /**
146
+ * The DIBK search widget: an underline-only field with an inline
147
+ * magnifier, sitting in a quiet panel that turns white with a ring on
148
+ * hover/focus. Wraps Designsystemet's `Search` and renders its own `<form>`
149
+ * (DS `Search` is a plain div; Enter-to-submit needs a real form).
150
+ */
151
+ declare const DibkSearch: react.ForwardRefExoticComponent<DibkSearchProps & react.RefAttributes<HTMLFormElement>>;
152
+
153
+ interface DibkFooterProps extends ComponentPropsWithoutRef<"footer"> {
154
+ /** Optional app-specific content shown above the static bottom bar. */
155
+ children?: ReactNode;
156
+ }
157
+ /**
158
+ * The DIBK footer: an optional app-specific content area on top, then a static
159
+ * bottom bar carrying the standard legal links (left) and the brand mark (right).
160
+ */
161
+ declare const DibkFooter: react.ForwardRefExoticComponent<DibkFooterProps & react.RefAttributes<HTMLElement>>;
162
+
163
+ interface DibkSectionHeaderProps extends Omit<ComponentPropsWithoutRef<"div">, "title"> {
164
+ title: ReactNode;
165
+ /** Large two-tone icon shown above/beside the title. */
166
+ icon?: ReactNode;
167
+ description?: ReactNode;
168
+ }
169
+ declare const DibkSectionHeader: react.ForwardRefExoticComponent<DibkSectionHeaderProps & react.RefAttributes<HTMLDivElement>>;
170
+
171
+ interface DibkFeedbackWidgetProps extends ComponentPropsWithoutRef<"div"> {
172
+ /** Defaults to "Fant du det du lette etter?". */
173
+ question?: string;
174
+ onAnswer?: (answer: "ja" | "nei") => void;
175
+ }
176
+ declare const DibkFeedbackWidget: react.ForwardRefExoticComponent<DibkFeedbackWidgetProps & react.RefAttributes<HTMLDivElement>>;
177
+
178
+ /** One menu section: title (+ optional icon/landing link) and its links. */
179
+ type DibkMenuColumnSection = Pick<DibkMenuSectionProps, "title" | "href" | "icon" | "items">;
180
+ interface DibkAppShellProps extends Omit<ComponentPropsWithoutRef<"div">, "title"> {
181
+ /** App name shown beside the logo, with a subtle divider. */
182
+ title?: ReactNode;
183
+ /** Logo link target. */
184
+ homeHref?: string;
185
+ /** Render the header's "Søk" button (default true). */
186
+ search?: boolean;
187
+ /** Called when the header's Søk toggle is clicked. */
188
+ onSearchToggle?: () => void;
189
+ /** Highlighted shortcut links shown in the top bar beside the menu toggle. */
190
+ shortcuts?: DibkHeaderShortcut[];
191
+ /** Account/login control shown in the top bar (see DibkHeader's `account`). */
192
+ account?: ReactNode;
193
+ /** Mega-menu heading (default "Meny"). Visually hidden when `menuColumns` is
194
+ * used (the section titles carry the visual structure instead). */
195
+ menuHeading?: string;
196
+ /** Mega-menu navigation links, as a flat list under the menu heading. Ignored
197
+ * when `menuColumns` is provided. */
198
+ menuItems?: DibkIconLinkItem[];
199
+ /** Two-column menu layout: each column a stack of titled sections.
200
+ * Takes precedence over `menuItems`. */
201
+ menuColumns?: [DibkMenuColumnSection[], DibkMenuColumnSection[]];
202
+ /** Optional content below the menu links (e.g. an account/login row). */
203
+ menuExtra?: ReactNode;
204
+ /** Optional app-specific content shown above the footer's static bottom bar. */
205
+ footerContent?: ReactNode;
206
+ /**
207
+ * Component used for the header's brand/shortcut links and the menu items
208
+ * (receives `href`). Pass a router Link adapter for client-side navigation;
209
+ * defaults to `a`.
210
+ */
211
+ linkComponent?: ElementType;
212
+ }
213
+ /**
214
+ * The DIBK page frame: header (logo + app title + menu toggle), mega-menu,
215
+ * the routed content in the canonical container, and the footer. Owns the
216
+ * menu open/close state. The content sits in a `--dibk-container-max` container
217
+ * so it lines up edge-to-edge with the header and footer - apps don't manage
218
+ * their own page width.
219
+ */
220
+ declare const DibkAppShell: react.ForwardRefExoticComponent<DibkAppShellProps & react.RefAttributes<HTMLDivElement>>;
221
+
222
+ interface DibkAccountMenuProps extends Omit<ComponentPropsWithoutRef<"button">, "name" | "value"> {
223
+ /** The signed-in user's display name (drives the initials, heading and aria-label). */
224
+ name: string;
225
+ email?: string;
226
+ /** Role shown as a small tag under the email (e.g. "Redaktør"). */
227
+ roleLabel?: ReactNode;
228
+ /** Renders a "Logg ut" item that calls this. */
229
+ onLogout?: () => void;
230
+ /** Extra Dropdown.Item entries, listed before Logg ut. */
231
+ children?: ReactNode;
232
+ }
233
+ /** Header account control for a signed-in user: an initials avatar that opens a
234
+ small account dropdown (name, email, role, Logg ut). Designed for the app
235
+ shell's `account` slot; the app decides *whether* the user is signed in and
236
+ what the fields are - this component only renders them. */
237
+ declare const DibkAccountMenu: react.ForwardRefExoticComponent<DibkAccountMenuProps & react.RefAttributes<HTMLButtonElement>>;
238
+ interface DibkMenuLoginProps extends ComponentPropsWithoutRef<"button"> {
239
+ }
240
+ /** "Logg inn" row for the mega-menu's `menuExtra` slot, the anonymous counterpart
241
+ to DibkAccountMenu. The app renders it only for signed-out visitors and wires
242
+ the click to its sign-in flow. */
243
+ declare const DibkMenuLogin: react.ForwardRefExoticComponent<DibkMenuLoginProps & react.RefAttributes<HTMLButtonElement>>;
244
+
245
+ interface DibkCopyButtonProps extends ComponentPropsWithoutRef<"button"> {
246
+ /** The text placed on the clipboard. */
247
+ value: string;
248
+ /** Accessible name for the button ("Kopier" when omitted). */
249
+ ariaLabel?: string;
250
+ }
251
+ /** A square navy "Kopier" button that flips to "✓ Kopiert!" for ~1.7s after a copy. */
252
+ declare const DibkCopyButton: react.ForwardRefExoticComponent<DibkCopyButtonProps & react.RefAttributes<HTMLButtonElement>>;
253
+ interface DibkCopyIconButtonProps extends ComponentPropsWithoutRef<"button"> {
254
+ /** The text placed on the clipboard. */
255
+ value: string;
256
+ /** Accessible name for the button. */
257
+ ariaLabel?: string;
258
+ /** Glyph size in px; the hit area comes from padding, not the glyph. */
259
+ size?: number;
260
+ }
261
+ /** Quiet icon-only sibling of DibkCopyButton: a muted clipboard glyph that turns
262
+ into a green ✓ after copying. For places where a full button would shout
263
+ (e.g. beside body text). */
264
+ declare const DibkCopyIconButton: react.ForwardRefExoticComponent<DibkCopyIconButtonProps & react.RefAttributes<HTMLButtonElement>>;
265
+
266
+ interface DibkCodeBlockProps extends ComponentPropsWithoutRef<"div"> {
267
+ /** Label shown in the bar above the code. */
268
+ label: string;
269
+ /** The value the Kopier button copies (and shows, unless `display` is set). */
270
+ value: string;
271
+ /** Text to show when it should differ from the copied value. */
272
+ display?: string;
273
+ /** Toggles the Kopier button; turn off for illustrative blocks that shouldn't be pasted. */
274
+ copyable?: boolean;
275
+ }
276
+ /** A labelled code block: a label bar over a monospace `<pre>`, with an optional
277
+ Kopier button. Wraps long lines (URLs, JSON) rather than only scrolling. */
278
+ declare const DibkCodeBlock: react.ForwardRefExoticComponent<DibkCodeBlockProps & react.RefAttributes<HTMLDivElement>>;
279
+
280
+ export { DibkAccountMenu, type DibkAccountMenuProps, DibkAppShell, type DibkAppShellProps, DibkCodeBlock, type DibkCodeBlockProps, DibkCopyButton, type DibkCopyButtonProps, DibkCopyIconButton, type DibkCopyIconButtonProps, DibkFeedbackWidget, type DibkFeedbackWidgetProps, DibkFooter, type DibkFooterProps, DibkHeader, type DibkHeaderProps, type DibkHeaderShortcut, type DibkIconLinkItem, DibkIconLinkList, type DibkIconLinkListProps, DibkLogo, type DibkLogoProps, DibkMegaMenu, type DibkMegaMenuProps, type DibkMenuColumnSection, DibkMenuLogin, type DibkMenuLoginProps, DibkMenuSection, type DibkMenuSectionProps, DibkSearch, type DibkSearchProps, DibkSectionHeader, type DibkSectionHeaderProps };