Compare commits

...
Author SHA1 Message Date
github-actions[bot] b9ff90b895 Version Packages 2026-11-24 13:40:46 +00:00
Magdalini Fotiadou 0458f60e74 fix(Switch): renders readOnly icon in fieldset header instead of each switch element (#5583) 2026-11-24 14:39:44 +01:00
Ken 0bf810cc91 chore(deps): Upgrade analytic events 2026-11-24 09:38:10 +01:00
Ken 6e84c5ce79 feat(mcp): Added base tokens to MCP-server (#5572) 2026-11-24 09:29:48 +01:00
github-actions[bot] 21c119448f Version Packages (#5566)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-23 16:09:25 +01:00
Ken 07a2d99798 fix(DataGrid): Temp removed topContent and bottomContent props (#5579) 2026-11-23 15:42:09 +01:00
Halvor Haugan d31d7a54a3 chore(deps): sync versions of @babel/preset-env 2026-11-23 15:29:14 +01:00
Halvor Haugan 1c8e767038 feat(Sanity): set outdated threshold to 365 days (#5580) 2026-11-23 15:25:00 +01:00
KenandHalvor Haugan 2245e16b15 fix(DataGrid): Change overflow to min height/width on datagrid root (#5568)
Co-authored-by: Halvor Haugan <83693529+HalvorHaugan@users.noreply.github.com>
2026-11-23 14:57:36 +01:00
Ken 9c0a933b38 fix(vscode): Improve watcherExclude settings 2026-11-23 13:20:58 +01:00
dependabot[bot]andKen a1c75c0ed7 ⬆️ Bump the sanity group with 7 updates (#5574)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ken <ken.aleksander@gmail.com>
2026-11-23 13:07:17 +01:00
dependabot[bot] cd1abf54b5 ⬆️ Bump @vitejs/plugin-react from 6.2.1 to 6.3.0 (#5576)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-23 13:03:32 +01:00
dependabot[bot] d13727b130 ⬆️ Bump the storybook group with 8 updates (#5575)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-23 13:02:53 +01:00
dependabot[bot] b92ef1b486 ⬆️ Bump @google-cloud/bigquery from 9.5.0 to 9.6.1 (#5577)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-23 13:00:58 +01:00
dependabot[bot] 6a01e3dac4 ⬆️ Bump @babel/preset-env from 7.29.7 to 7.29.14 (#5578)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-23 13:00:23 +01:00
Ken 7dbf1d5382 fix(DataGrid): Focus is no longer locked inside table when using useTableKeyboardNav 2026-11-20 21:50:40 +01:00
47 changed files with 1047 additions and 434 deletions

No files matched your search

-5
View File
@@ -1,5 +0,0 @@
---
"@navikt/ds-react": patch
---
Button: Preserve keyboard modifiers during native Space activation.
+10 -3
View File
@@ -2,10 +2,17 @@
"cssVariables.lookupFiles": ["@navikt/core/tokens/dist/tokens.css"],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/**": true,
"**/.yarn/**": true,
"**/dist": true,
"**/esm": true,
"**/cjs": true
"**/dist/**": true,
"**/esm/**": true,
"**/cjs/**": true,
"**/lib/**": true,
"**/@navikt/aksel-icons/src/**": true,
"**/.next/**": true,
"**/storybook-static/**": true
},
"playwright.reuseBrowser": true,
"js/ts.tsdk.path": "node_modules/typescript/lib",
+4
View File
@@ -1,5 +1,9 @@
# @navikt/aksel-icons
## 8.23.2
## 8.23.1
## 8.23.0
### Minor Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/aksel-icons",
"version": "8.23.0",
"version": "8.23.2",
"author": "Aksel | Nav",
"homepage": "https://aksel.nav.no/ikoner",
"repository": {
+4
View File
@@ -1,5 +1,9 @@
# @navikt/aksel-stylelint
## 8.23.2
## 8.23.1
## 8.23.0
### Patch Changes
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/aksel-stylelint",
"version": "8.23.0",
"version": "8.23.2",
"type": "module",
"engines": {
"node": ">=18.12.0"
@@ -43,8 +43,8 @@
"dev": "yarn watch:lint"
},
"devDependencies": {
"@navikt/ds-css": "^8.23.0",
"@navikt/ds-tokens": "^8.23.0",
"@navikt/ds-css": "^8.23.2",
"@navikt/ds-tokens": "^8.23.2",
"concurrently": "10.0.6",
"postcss-selector-parser": "^7.1.7",
"postcss-value-parser": "^4.2.0",
+4
View File
@@ -1,5 +1,9 @@
# @navikt/aksel
## 8.23.2
## 8.23.1
## 8.23.0
## 8.22.1
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/aksel",
"version": "8.23.0",
"version": "8.23.2",
"description": "Aksel command line interface. Codemods and other utilities for Aksel users.",
"author": "Aksel | Nav designsystem team",
"license": "MIT",
+8
View File
@@ -1,5 +1,13 @@
# @navikt/ds-css
## 8.23.2
## 8.23.1
### Patch Changes
- DataGrid: Change `overflow:hidden` to `min-height:0` and `min-width:0` on root ([#5568](https://github.com/navikt/aksel/pull/5568))
## 8.23.0
## 8.22.1
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/ds-css",
"version": "8.23.0",
"version": "8.23.2",
"description": "CSS for Nav Designsystem",
"author": "Aksel | Nav designsystem team",
"keywords": [
@@ -32,7 +32,7 @@
"css:get-version": "node config/get-version.js"
},
"devDependencies": {
"@navikt/ds-tokens": "^8.23.0",
"@navikt/ds-tokens": "^8.23.2",
"browserslist": "^4.28.7",
"esbuild": "^0.28.2",
"fast-glob": "3.3.3",
+4 -1
View File
@@ -6,7 +6,10 @@
display: flex;
flex-direction: column;
width: 100%;
overflow: hidden;
/* Makes DataGridRoot shrink inside a height-limited flex container */
min-width: 0;
min-height: 0;
}
.aksel-data-table__frame {
+24
View File
@@ -1,5 +1,29 @@
# @navikt/ds-react
## 8.23.2
### Patch Changes
- Switch:  `<Switch />` elements inside a `<Fieldset />` with `readOnly` now share a single padlock in the group legend instead of displaying one per switch. Each switch retains screen-reader text indicating its read-only state, and standalone switches keep their individual padlocks. ([#5583](https://github.com/navikt/aksel/pull/5583))
- Updated dependencies []:
- @navikt/ds-tokens@8.23.2
- @navikt/aksel-icons@8.23.2
## 8.23.1
### Patch Changes
- DataGrid: Keyboard navigation in table no longer prevents shift+tabbing away from the table ([`7dbf1d5`](https://github.com/navikt/aksel/commit/7dbf1d5382367837b1f43fc76ca57d986218b64d))
- Button: Preserve keyboard modifiers during native Space activation. ([#5564](https://github.com/navikt/aksel/pull/5564))
- DataGrid.Table: Temporarily removed `topContent` and `bottomContent` props. ([#5579](https://github.com/navikt/aksel/pull/5579))
- Updated dependencies []:
- @navikt/ds-tokens@8.23.1
- @navikt/aksel-icons@8.23.1
## 8.23.0
### Patch Changes
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/ds-react",
"version": "8.23.0",
"version": "8.23.2",
"description": "React components from the Norwegian Labour and Welfare Administration.",
"author": "Aksel, a team part of the Norwegian Labour and Welfare Administration.",
"license": "MIT",
@@ -788,8 +788,8 @@
"dependencies": {
"@floating-ui/react": "0.27.20",
"@floating-ui/react-dom": "^2.1.9",
"@navikt/aksel-icons": "^8.23.0",
"@navikt/ds-tokens": "^8.23.0",
"@navikt/aksel-icons": "^8.23.2",
"@navikt/ds-tokens": "^8.23.2",
"date-fns": "^4.0.0",
"react-day-picker": "10.0.2"
},
@@ -59,6 +59,7 @@ export const Attachments: Story = {
table content scrolls.
</BodyShort>
</VStack>
<Content />
<div
style={{
overflow: "hidden",
@@ -69,8 +70,8 @@ export const Attachments: Story = {
>
<DataGrid columns={getColDefs(overflow)} data={getData(overflow)}>
<DataGrid.Table
topContent={<Content />}
bottomContent={<Content />}
// topContent={<Content />}
// bottomContent={<Content />}
stickyHeader
/>
</DataGrid>
@@ -22,6 +22,7 @@ type UseTableKeyboardNavOptions = {
function useTableKeyboardNav({ enabled }: UseTableKeyboardNavOptions) {
const [tableRef, setTableRef] = useState<HTMLTableElement | null>(null);
const [isFocusWithin, setIsFocusWithin] = useState(false);
const { getTableGrid, activeCell, setActiveCell } = useGridCache(
tableRef,
enabled,
@@ -122,6 +123,7 @@ function useTableKeyboardNav({ enabled }: UseTableKeyboardNavOptions) {
* Make sure td/th elements have tabIndex={-1} so they can receive focus on click
*/
const handleTableFocusIn = useEventCallback((event: FocusEvent): void => {
setIsFocusWithin(true);
const target = event.target as Element | null;
if (tableRef && target === tableRef) {
@@ -146,6 +148,15 @@ function useTableKeyboardNav({ enabled }: UseTableKeyboardNavOptions) {
}
});
const handleTableFocusOut = useEventCallback((event: FocusEvent): void => {
if (
!(event.relatedTarget instanceof Node) ||
!tableRef?.contains(event.relatedTarget)
) {
setIsFocusWithin(false);
}
});
/**
* Attach event listeners for keyboard navigation and focus management.
*/
@@ -156,16 +167,27 @@ function useTableKeyboardNav({ enabled }: UseTableKeyboardNavOptions) {
tableRef.addEventListener("keydown", handleTableKeyDown);
tableRef.addEventListener("focusin", handleTableFocusIn);
tableRef.addEventListener("focusout", handleTableFocusOut);
return () => {
tableRef.removeEventListener("keydown", handleTableKeyDown);
tableRef.removeEventListener("focusin", handleTableFocusIn);
tableRef.removeEventListener("focusout", handleTableFocusOut);
};
}, [tableRef, handleTableKeyDown, handleTableFocusIn, enabled]);
}, [
tableRef,
handleTableKeyDown,
handleTableFocusIn,
handleTableFocusOut,
enabled,
]);
return {
/* Table should only have tabIndex until the focus is moved inside and is enabled */
tabIndex: enabled ? 0 : undefined,
/*
* Table should only have tabIndex until the focus is moved inside and is enabled
* This allows focus to "escape" the table and move to other elements on the page.
*/
tabIndex: enabled ? (isFocusWithin ? -1 : 0) : undefined,
setTableRef,
};
}
@@ -138,14 +138,16 @@ interface DataGridTableProps<T> extends React.HTMLAttributes<HTMLTableElement> {
* @default "row"
*/
selectionTrigger?: "row" | "control";
/* TODO: Temp removed to better integrate with plugins API */
/**
* Content to render above the table, outside its scrollable area.
*/
topContent?: React.ReactNode;
//topContent?: React.ReactNode;
/**
* Content to render below the table, outside its scrollable area.
*/
bottomContent?: React.ReactNode;
//bottomContent?: React.ReactNode;
}
const DataGridTableInternal = forwardRef<
@@ -169,8 +171,6 @@ const DataGridTableInternal = forwardRef<
subRows,
sorting,
selectionTrigger = "row",
topContent,
bottomContent,
...rest
}: DataGridTableProps<unknown>,
forwardedRef,
@@ -211,31 +211,31 @@ const DataGridTableInternal = forwardRef<
const tableId = useId(id);
const hasTopContent = topContent != null && topContent !== false;
const hasBottomContent = bottomContent != null && bottomContent !== false;
let attachmentPosition: "top" | "bottom" | "both" | undefined;
// const hasTopContent = topContent != null && topContent !== false;
// const hasBottomContent = bottomContent != null && bottomContent !== false;
// let attachmentPosition: "top" | "bottom" | "both" | undefined;
/* TODO: Need to figure out how to handle this since settings is provided from root, not table itself */
const truncateContent = tableSettings?.truncateContent ?? layout !== "auto";
if (hasTopContent && hasBottomContent) {
attachmentPosition = "both";
} else if (hasTopContent) {
attachmentPosition = "top";
} else if (hasBottomContent) {
attachmentPosition = "bottom";
}
// if (hasTopContent && hasBottomContent) {
// attachmentPosition = "both";
// } else if (hasTopContent) {
// attachmentPosition = "top";
// } else if (hasBottomContent) {
// attachmentPosition = "bottom";
// }
return (
<div
className="aksel-data-table__frame"
data-attachments={attachmentPosition}
// data-attachments={attachmentPosition}
>
{hasTopContent && (
{/* {hasTopContent && (
<div className="aksel-data-table__attachment" data-attachment="top">
{topContent}
</div>
)}
)} */}
<DataTableContextProvider
layout={layout}
@@ -314,14 +314,14 @@ const DataGridTableInternal = forwardRef<
</table>
</TableElementWrapper>
</DataTableContextProvider>
{hasBottomContent && (
{/* {hasBottomContent && (
<div
className="aksel-data-table__attachment"
data-attachment="bottom"
>
{bottomContent}
</div>
)}
)} */}
</div>
);
},
@@ -1,6 +1,7 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import React from "react";
import { renderStoriesForChromatic } from "../../utils/renderStoriesForChromatic";
import { Fieldset } from "../fieldset";
import Switch from "./Switch";
export default {
@@ -125,6 +126,15 @@ export const Readonly: Story = {
parameters: { controls: { disable: true } },
};
export const ReadonlyGroup: Story = {
render: () => (
<Fieldset legend="Notifikasjoner" readOnly>
<Switch defaultChecked>SMS</Switch>
<Switch>E-post</Switch>
</Fieldset>
),
};
export const ColorRole: Story = {
render: () => (
<div className="colgap" data-color="brand-magenta">
@@ -158,6 +168,7 @@ export const Chromatic = renderStoriesForChromatic(
Disabled,
HideLabel,
Readonly,
ReadonlyGroup,
ColorRole,
},
Switch,
+19 -2
View File
@@ -1,9 +1,16 @@
import React, { type InputHTMLAttributes, forwardRef, useState } from "react";
import React, {
type InputHTMLAttributes,
forwardRef,
useContext,
useState,
} from "react";
import { Loader } from "../../loader";
import { BodyShort } from "../../typography";
import { omit } from "../../utils-external";
import { cl } from "../../utils/helpers";
import { useI18n } from "../../utils/i18n/i18n.hooks";
import { ReadOnlyIconWithTitle } from "../ReadOnlyIcon";
import { FieldsetContext } from "../fieldset/context";
import { type FormFieldProps, useFormField } from "../useFormField";
export interface SwitchProps
@@ -122,7 +129,7 @@ export const Switch = forwardRef<HTMLInputElement, SwitchProps>(
})}
>
<BodyShort as="span" size={size} className="aksel-switch__label">
{readOnly && <ReadOnlyIconWithTitle />}
{readOnly && <ReadOnlyIcon />}
{children}
</BodyShort>
{description && (
@@ -141,6 +148,16 @@ export const Switch = forwardRef<HTMLInputElement, SwitchProps>(
},
);
const ReadOnlyIcon = () => {
const fieldset = useContext(FieldsetContext);
const readOnlyText = useI18n("global")("readOnly");
if (fieldset?.readOnly) {
return <span className="aksel-sr-only">{readOnlyText}</span>;
}
return <ReadOnlyIconWithTitle />;
};
const SwitchIcon = ({
size,
checked,
+4
View File
@@ -1,5 +1,9 @@
# @navikt/ds-tailwind
## 8.23.2
## 8.23.1
## 8.23.0
## 8.22.1
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/ds-tailwind",
"version": "8.23.0",
"version": "8.23.2",
"description": "Tailwind config based on @navikt/ds-tokens",
"author": "Aksel | Nav designsystem team",
"keywords": [
@@ -28,7 +28,7 @@
},
"homepage": "https://aksel.nav.no/grunnleggende/kode/tailwind/",
"devDependencies": {
"@navikt/ds-tokens": "^8.23.0",
"@navikt/ds-tokens": "^8.23.2",
"@types/node": "^24.10.9",
"tailwindcss": "^4.3.3",
"tsx": "^4.23.15",
+4
View File
@@ -1,5 +1,9 @@
# @navikt/ds-tokens
## 8.23.2
## 8.23.1
## 8.23.0
## 8.22.1
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/ds-tokens",
"version": "8.23.0",
"version": "8.23.2",
"description": "Design-tokens for Nav designsystem",
"author": "Aksel | Nav designsystem team",
"keywords": [
+20
View File
@@ -1,5 +1,25 @@
# Changelog
## 8.23.2
### @navikt/ds-react
- Switch:  `<Switch />` elements inside a `<Fieldset />` with `readOnly` now share a single padlock in the group legend instead of displaying one per switch. Each switch retains screen-reader text indicating its read-only state, and standalone switches keep their individual padlocks. ([#5583](https://github.com/navikt/aksel/pull/5583))
## 8.23.1
### @navikt/ds-css
- DataGrid: Change `overflow:hidden` to `min-height:0` and `min-width:0` on root ([#5568](https://github.com/navikt/aksel/pull/5568))
### @navikt/ds-react
- DataGrid: Keyboard navigation in table no longer prevents shift+tabbing away from the table ([`7dbf1d5`](https://github.com/navikt/aksel/commit/7dbf1d5382367837b1f43fc76ca57d986218b64d))
- Button: Preserve keyboard modifiers during native Space activation. ([#5564](https://github.com/navikt/aksel/pull/5564))
- DataGrid.Table: Temporarily removed `topContent` and `bottomContent` props. ([#5579](https://github.com/navikt/aksel/pull/5579))
## 8.23.0
### @navikt/aksel-icons
+6 -6
View File
@@ -11,11 +11,11 @@
"sanity:update": "yarn workspace website update:sanity"
},
"dependencies": {
"@navikt/aksel": "^8.23.0",
"@navikt/aksel-icons": "^8.23.0",
"@navikt/ds-css": "^8.23.0",
"@navikt/ds-react": "^8.23.0",
"@navikt/ds-tailwind": "^8.23.0",
"@navikt/ds-tokens": "^8.23.0"
"@navikt/aksel": "^8.23.2",
"@navikt/aksel-icons": "^8.23.2",
"@navikt/ds-css": "^8.23.2",
"@navikt/ds-react": "^8.23.2",
"@navikt/ds-tailwind": "^8.23.2",
"@navikt/ds-tokens": "^8.23.2"
}
}
+7 -7
View File
@@ -17,12 +17,12 @@
"dependencies": {
"@portabletext/react": "^8.0.1",
"@sanity/client": "7.27.0",
"@sanity/code-input": "7.3.8",
"@sanity/color-input": "6.1.8",
"@sanity/code-input": "7.3.16",
"@sanity/color-input": "6.1.10",
"@sanity/image-url": "2.1.1",
"@sanity/locale-nb-no": "1.1.39",
"@sanity/preview-url-secret": "4.1.5",
"@sanity/table": "3.1.20",
"@sanity/table": "3.1.21",
"@sanity/vision": "6.17.0",
"date-fns": "^4.0.0",
"lodash": "4.18.1",
@@ -31,15 +31,15 @@
"react-rx": "^5.1.1",
"rxjs": "^7.8.2",
"sanity": "6.17.0",
"sanity-plugin-iframe-pane": "5.0.41",
"sanity-plugin-media": "6.1.8",
"sanity-plugin-iframe-pane": "5.0.43",
"sanity-plugin-media": "6.6.3",
"sanity-plugin-references": "1.2.0",
"styled-components": "6.6.0",
"swr": "^2.4.2"
},
"devDependencies": {
"@sanity/blueprints": "0.28.0",
"@sanity/export": "7.0.3",
"@sanity/blueprints": "0.34.1",
"@sanity/export": "7.1.1",
"@sanity/functions": "1.11.0",
"@sanity/schema": "6.17.0",
"@types/lodash": "4.17.25",
@@ -11,7 +11,7 @@ export const locations: DocumentLocationResolver = (params, context) => {
const doc$ = context.documentStore.listenQuery(
`*[(_type != $type && references($id)) || _id == $id && _type in $articleTypes ]{_type, slug, title, heading, "tema": undertema[]->tema->title}`,
{ id: params.id, type: params.type, articleTypes: validTypes },
{ perspective: "previewDrafts" },
{ perspective: "drafts" },
) as Observable<
| {
_type: string;
+8 -1
View File
@@ -6,4 +6,11 @@ if (process.env.LOCAL_DATASET_OVERRIDE === "development") {
SANITY_DATASET = "development";
}
export { SANITY_API_VERSION, SANITY_DATASET, SANITY_PROJECT_ID };
const DEFAULT_OUTDATED_THRESHOLD = 365;
export {
SANITY_API_VERSION,
SANITY_DATASET,
SANITY_PROJECT_ID,
DEFAULT_OUTDATED_THRESHOLD,
};
@@ -1,4 +1,4 @@
import { differenceInDays, differenceInMonths, format } from "date-fns";
import { differenceInDays, format } from "date-fns";
import { type ComponentType, useState } from "react";
import {
type ObjectFieldProps,
@@ -8,8 +8,11 @@ import {
useFormValue,
} from "sanity";
import { HourglassBottomFilledIcon } from "@navikt/aksel-icons";
import { BodyLong, Box, Button, InfoCard } from "@navikt/ds-react";
import { SANITY_API_VERSION } from "../../sanity.env";
import { BodyLong, Button, InfoCard } from "@navikt/ds-react";
import {
DEFAULT_OUTDATED_THRESHOLD,
SANITY_API_VERSION,
} from "../../sanity.env";
const UpdateInfoInput: ComponentType<ObjectInputProps> = (props) => {
const { onChange, readOnly } = props;
@@ -45,37 +48,31 @@ const UpdateInfoInput: ComponentType<ObjectInputProps> = (props) => {
};
return (
<Box marginBlock="space-16 space-0">
<Button
size="small"
variant="primary"
loading={updating}
onClick={handleUpdate}
disabled={readOnly}
data-color="neutral"
>
Oppdater godkjenningsdato
</Button>
</Box>
<Button
size="small"
variant="primary"
loading={updating}
onClick={handleUpdate}
disabled={readOnly}
data-color="neutral"
>
Oppdater godkjenningsdato
</Button>
);
};
const UpdateInfo: ComponentType<ObjectFieldProps> = (props) => {
const articleType = useFormValue(["_type"]);
const verified = useFormValue(["updateInfo", "lastVerified"]);
if (typeof verified !== "string") {
return null;
}
// oxlint-disable-next-line react/purity -- Age relative to now is intended.
const diff = differenceInMonths(new Date(), new Date(verified));
// oxlint-disable-next-line react/purity -- Age relative to now is intended.
const diffInDays = differenceInDays(new Date(), new Date(verified));
const outDated = diff >= (articleType === "aksel_artikkel" ? 12 : 6);
const outdated = diffInDays >= DEFAULT_OUTDATED_THRESHOLD;
if (!outDated) {
if (!outdated) {
return null;
}
@@ -91,10 +88,8 @@ const UpdateInfo: ComponentType<ObjectFieldProps> = (props) => {
Artikkelen trenger ny godkjenning. Les gjennom og oppdater innholdet,
for så å oppdatere godkjenningsdatoen.
</BodyLong>
<BodyLong size="small">
{articleType === "aksel_artikkel"
? "En God praksis-artikkel regnes som utdatert etter 12 måneder."
: "En Designsystem-artikkel regnes som utdatert etter 6 måneder."}
<BodyLong size="small" spacing>
En artikkel regnes som utdatert etter 12 måneder.
</BodyLong>
{props.children}
</InfoCard.Content>
@@ -16,7 +16,7 @@ export const GrunnleggendeArtikkel = defineType({
name: "ds_artikkel",
type: "document",
groups: SanityTabGroups,
...artikkelPreview("Grunnleggende", 6),
...artikkelPreview("Grunnleggende"),
renderMembers: (members) => {
return [
...members,
@@ -18,7 +18,7 @@ export const KomponentArtikkel = defineType({
name: "komponent_artikkel",
type: "document",
groups: SanityTabGroups,
...artikkelPreview("Komponenter", 6),
...artikkelPreview("Komponenter"),
renderMembers: (members) => {
return [
...members,
@@ -1,14 +1,18 @@
import { differenceInMonths } from "date-fns";
import { differenceInDays } from "date-fns";
import { HourglassBottomFilledIcon } from "@navikt/aksel-icons";
import { DEFAULT_OUTDATED_THRESHOLD } from "../../../sanity.env";
const isAfter = (date: string, threshold: number) =>
differenceInMonths(new Date(), new Date(date)) >= threshold;
differenceInDays(new Date(), new Date(date)) >= threshold;
/**
* @param _type document type
* @param threshold number of months before article is considered outdated in **months**
* @param threshold number of days before article is considered outdated
*/
export const artikkelPreview = (_type: string, threshold: number = 12) => {
export const artikkelPreview = (
_type: string,
threshold: number = DEFAULT_OUTDATED_THRESHOLD,
) => {
return {
preview: {
select: {
@@ -16,7 +16,7 @@ export const TemplatesArtikkel = defineType({
name: "templates_artikkel",
type: "document",
groups: SanityTabGroups,
...artikkelPreview("Mønster/Maler", 6),
...artikkelPreview("Mønster/Maler"),
renderMembers: (members) => {
return [
...members,
@@ -1,7 +1,7 @@
import type { ComponentType } from "react";
import type { StructureBuilder } from "sanity/structure";
import { FileXMarkIcon, HouseIcon } from "@navikt/aksel-icons";
import { SANITY_API_VERSION } from "../sanity.env";
import { DEFAULT_OUTDATED_THRESHOLD, SANITY_API_VERSION } from "../sanity.env";
import type { AllArticleDocumentsT } from "../schema/schema.config";
type ArticleDocumentType = AllArticleDocumentsT;
@@ -55,7 +55,7 @@ export function listDraftArticles(
export function listOutdatedArticles(
S: StructureBuilder,
type: ArticleDocumentType,
threshold: number = 365,
threshold: number = DEFAULT_OUTDATED_THRESHOLD,
) {
return S.listItem({
id: `article_${type}_outdated`,
@@ -65,7 +65,7 @@ export function listOutdatedArticles(
S.documentTypeList(type)
.title("Artikler")
.filter(
`_type == $type && (dateTime(updateInfo.lastVerified + "T00:00:00Z") < dateTime(now()) - 60*60*24*$threshold) && ${IS_PUBLISHED}`,
`_type == $type && (dateTime(updateInfo.lastVerified + "T00:00:00Z") < dateTime(now()) - 60*60*24*$threshold)`,
)
.apiVersion(SANITY_API_VERSION)
.params({ type, threshold })
@@ -19,7 +19,7 @@ export function grunnleggendeStructure(S: StructureBuilder) {
landingssideItem(S, "grunnleggende_landingsside"),
S.divider(),
listDraftArticles(S, "ds_artikkel"),
listOutdatedArticles(S, "ds_artikkel", 180),
listOutdatedArticles(S, "ds_artikkel"),
S.divider(),
...categoryPanes(
@@ -19,7 +19,7 @@ export function komponenterStructure(S: StructureBuilder) {
landingssideItem(S, "komponenter_landingsside"),
S.divider(),
listDraftArticles(S, "komponent_artikkel"),
listOutdatedArticles(S, "komponent_artikkel", 180),
listOutdatedArticles(S, "komponent_artikkel"),
S.divider(),
...categoryPanes(
@@ -19,7 +19,7 @@ export function monsterStructure(S: StructureBuilder) {
landingssideItem(S, "templates_landingsside"),
S.divider(),
listDraftArticles(S, "templates_artikkel"),
listOutdatedArticles(S, "templates_artikkel", 180),
listOutdatedArticles(S, "templates_artikkel"),
S.divider(),
...categoryPanes(
@@ -1,4 +1,5 @@
import { differenceInMonths, isSameDay } from "date-fns";
import { DEFAULT_OUTDATED_THRESHOLD } from "aksel-sanity-studio/env";
import { differenceInDays, isSameDay } from "date-fns";
import type { Metadata } from "next";
import { type PortableTextBlock, stegaClean } from "next-sanity";
import { draftMode } from "next/headers";
@@ -177,11 +178,11 @@ async function CachedArticle({
pageData?.updateInfo?.lastVerified ??
pageData?.publishedAt ??
pageData?._updatedAt;
// oxlint-disable-next-line react/purity -- Server Component, rendered once per request.
const outdated = differenceInMonths(new Date(), new Date(verifiedDate)) >= 12;
const writers = getValidRenderArray(pageData.writers);
const diffInDays = differenceInDays(new Date(), new Date(verifiedDate));
const outdated = diffInDays >= DEFAULT_OUTDATED_THRESHOLD;
const writers = getValidRenderArray(pageData.writers);
const undertema = getValidRenderArray(pageData.undertema);
const relevanteArtikler = getValidRenderArray(pageData.relevante_artikler);
+2 -2
View File
@@ -31,7 +31,7 @@
"cp:assets:with-playroom": "yarn cp:playroom && yarn cp:assets"
},
"dependencies": {
"@navikt/analytics-types": "0.0.9",
"@navikt/analytics-types": "0.0.13",
"@navikt/next-logger": "5.0.2",
"@navikt/oasis": "4.2.2",
"@portabletext/react": "^8.0.1",
@@ -73,7 +73,7 @@
"@babel/core": "^7.19.0",
"@babel/parser": "^7.27.5",
"@babel/traverse": "^7.27.4",
"@google-cloud/bigquery": "^9.5.0",
"@google-cloud/bigquery": "^9.6.1",
"@playwright/test": "1.61.1",
"@portabletext/block-tools": "^6.0.7",
"@portabletext/markdown": "^2.5.1",
@@ -1,4 +1,4 @@
import { Switch, VStack } from "@navikt/ds-react";
import { Fieldset, Switch, VStack } from "@navikt/ds-react";
import { withDsExample } from "@/web/examples/withDsExample";
const Example = () => {
@@ -8,6 +8,10 @@ const Example = () => {
<Switch readOnly checked>
Slå på notifikasjoner
</Switch>
<Fieldset legend="Hvordan ønsker du å bli varslet?" readOnly>
<Switch>E-post</Switch>
<Switch defaultChecked>SMS</Switch>
</Fieldset>
</VStack>
);
};
@@ -22,5 +26,5 @@ export const Demo = {
export const args: ExampleArgsT = {
index: 98,
desc: "Readonly-attributtet gjør at tilstanden ikke kan endres. Til forskjell fra `disabled` vil brukere fortsatt kunne tabbe til feltet, og verdien vil inkluderes når skjemaet sendes inn.",
desc: "Readonly-attributtet gjør at tilstanden ikke kan endres. Til forskjell fra `disabled` vil brukere fortsatt kunne tabbe til feltet, og verdien vil inkluderes når skjemaet sendes inn. Sett `readOnly` på `Fieldset` for å låse hele gruppen.",
};
+4 -4
View File
@@ -11,9 +11,9 @@
"preview": "vite preview"
},
"dependencies": {
"@navikt/aksel-icons": "^8.23.0",
"@navikt/ds-css": "^8.23.0",
"@navikt/ds-react": "^8.23.0",
"@navikt/aksel-icons": "^8.23.2",
"@navikt/ds-css": "^8.23.2",
"@navikt/ds-react": "^8.23.2",
"fuse.js": "7.4.2",
"react": "19.3.1",
"react-dom": "19.3.1"
@@ -25,7 +25,7 @@
"@types/node": "^24.10.9",
"@types/react": "19.2.14",
"@types/react-dom": "19.2.3",
"@vitejs/plugin-react": "^6.2.1",
"@vitejs/plugin-react": "^6.3.0",
"typescript": "6.0.3",
"vite": "^8.3.5",
"vite-plugin-singlefile": "^2.3.4"
+3 -3
View File
@@ -19,9 +19,9 @@
"devDependencies": {
"@modelcontextprotocol/inspector": "^2.11.0",
"@modelcontextprotocol/sdk": "^1.32.0",
"@navikt/aksel": "^8.23.0",
"@navikt/aksel-icons": "^8.23.0",
"@navikt/ds-tokens": "^8.23.0",
"@navikt/aksel": "^8.23.2",
"@navikt/aksel-icons": "^8.23.2",
"@navikt/ds-tokens": "^8.23.2",
"@sanity/client": "7.27.0",
"@types/express": "^5.0.3",
"@types/node": "^24.10.9",
@@ -28,6 +28,13 @@ describe("Resources", () => {
// Should NOT have verbose fields like rawValue, jsValue, etc.
expect(firstToken).not.toHaveProperty("rawValue");
expect(firstToken).not.toHaveProperty("jsValue");
// Should include dynamic data-color base tokens without duplicating names
const names = tokenList.map((t: { name: string }) => t.name);
expect(new Set(names).size).toBe(names.length);
expect(names).toContain("text-default");
expect(names).toContain("bg-soft");
expect(names).toContain("border-default");
});
test("should have proper metadata", () => {
@@ -1,9 +1,33 @@
import { tokens } from "@navikt/ds-tokens/token_docs";
import {
type TokenDocT,
tokens as dsTokens,
} from "@navikt/ds-tokens/token_docs";
import type { McpResource } from "../types.js";
const URI = "aksel-tokens://catalog";
const MIME_TYPE = "application/json";
type ThemedBaseCategory = {
category: "backgroundColor" | "textColor" | "borderColor";
categoryTitle: "Bakgrunnsfarger" | "Tekstfarger" | "Kantlinjefarger";
};
type ThemedBaseToken = {
name: string;
value: string;
cssValue: string;
resolvesTo: string;
defaultRole: "accent";
comment: string;
type: "themed-role";
category: ThemedBaseCategory["category"];
categoryTitle: ThemedBaseCategory["categoryTitle"];
role: "themed-role";
modifier: string;
};
type CatalogToken = TokenDocT | ThemedBaseToken;
type TokenSummary = {
name: string;
comment?: string;
@@ -11,6 +35,74 @@ type TokenSummary = {
type: string;
};
const themedBaseCategories: Record<
"bg" | "text" | "border",
ThemedBaseCategory
> = {
bg: { category: "backgroundColor", categoryTitle: "Bakgrunnsfarger" },
text: { category: "textColor", categoryTitle: "Tekstfarger" },
border: { category: "borderColor", categoryTitle: "Kantlinjefarger" },
};
/**
* Dynamic CSS-only base tokens emitted per `[data-color="<role>"]` by
* `@navikt/ds-tokens` (`semantic-themed-base.tokens.ts`), which are not
* included in `@navikt/ds-tokens/token_docs` or JS/SCSS/LESS exports.
*/
const themedBaseSpecs: ReadonlyArray<{
prefix: "bg" | "text" | "border";
modifier: string;
resolvesSuffix?: string;
}> = [
{ prefix: "bg", modifier: "soft" },
{ prefix: "bg", modifier: "softA" },
{ prefix: "bg", modifier: "moderate" },
{ prefix: "bg", modifier: "moderateA" },
{ prefix: "bg", modifier: "moderate-hover" },
{ prefix: "bg", modifier: "moderate-hoverA" },
{ prefix: "bg", modifier: "moderate-pressed" },
{ prefix: "bg", modifier: "moderate-pressedA" },
{ prefix: "bg", modifier: "strong" },
{ prefix: "bg", modifier: "strong-hover" },
{ prefix: "bg", modifier: "strong-pressed" },
{ prefix: "text", modifier: "default", resolvesSuffix: "" },
{ prefix: "text", modifier: "subtle" },
{ prefix: "text", modifier: "decoration" },
{ prefix: "text", modifier: "contrast" },
{ prefix: "border", modifier: "default", resolvesSuffix: "" },
{ prefix: "border", modifier: "subtle" },
{ prefix: "border", modifier: "subtleA" },
{ prefix: "border", modifier: "strong" },
];
const themedBaseTokens: ThemedBaseToken[] = themedBaseSpecs.map(
({ prefix, modifier, resolvesSuffix }) => {
const name = `${prefix}-${modifier}`;
const suffix =
resolvesSuffix === undefined ? `-${modifier}` : resolvesSuffix;
const resolvesTo = `var(--ax-${prefix}-<color>${suffix})`;
const exampleNeutral = `${prefix}-neutral${suffix}`;
const exampleAccent = `${prefix}-accent${suffix}`;
const { category, categoryTitle } = themedBaseCategories[prefix];
return {
name,
value: `var(--ax-${name})`,
cssValue: `var(--ax-${name})`,
resolvesTo,
defaultRole: "accent",
comment: `Dynamic CSS-only base token scoped by data-color (defaults to 'accent' on :root). Resolves to ${resolvesTo}. Not exported in JS/SCSS/LESS; use explicit role tokens (e.g. ${exampleNeutral}, ${exampleAccent}) for static usage.`,
type: "themed-role",
category,
categoryTitle,
role: "themed-role",
modifier,
};
},
);
const tokens: CatalogToken[] = [...dsTokens, ...themedBaseTokens];
const tokenSummary: TokenSummary[] = tokens.map((token) => ({
name: token.name,
comment: token.comment,
@@ -38,4 +130,4 @@ const tokensCatalogResource: McpResource = {
};
export { tokensCatalogResource, tokens, tokenSummary };
export type { TokenSummary };
export type { CatalogToken, ThemedBaseToken, TokenSummary };
+39
View File
@@ -162,6 +162,45 @@ describe("Tools", () => {
expect(token).toHaveProperty("jsValue");
});
test("should fetch details for dynamic data-color base tokens without JS/SCSS/LESS accessors", async () => {
const textDefault = JSON.parse(
await getTokenDetailsTool.callback({ tokenName: "text-default" }),
);
expect(textDefault).toMatchObject({
name: "text-default",
cssValue: "var(--ax-text-default)",
resolvesTo: "var(--ax-text-<color>)",
defaultRole: "accent",
type: "themed-role",
category: "textColor",
});
expect(textDefault).not.toHaveProperty("jsValue");
expect(textDefault).not.toHaveProperty("scssValue");
expect(textDefault).not.toHaveProperty("lessValue");
const bgSoft = JSON.parse(
await getTokenDetailsTool.callback({ tokenName: "bg-soft" }),
);
expect(bgSoft).toMatchObject({
name: "bg-soft",
cssValue: "var(--ax-bg-soft)",
resolvesTo: "var(--ax-bg-<color>-soft)",
type: "themed-role",
category: "backgroundColor",
});
const borderDefault = JSON.parse(
await getTokenDetailsTool.callback({ tokenName: "border-default" }),
);
expect(borderDefault).toMatchObject({
name: "border-default",
cssValue: "var(--ax-border-default)",
resolvesTo: "var(--ax-border-<color>)",
type: "themed-role",
category: "borderColor",
});
});
test("should return error with suggestions for similar tokens", async () => {
const result = await getTokenDetailsTool.callback({
tokenName: "shadow",
+4 -4
View File
@@ -9,7 +9,7 @@
"sync-imports": "tsx --tsconfig ./scripts/tsconfig.json ./scripts/generate-imports.ts"
},
"devDependencies": {
"@babel/preset-env": "^7.29.0",
"@babel/preset-env": "^7.29.14",
"@babel/preset-react": "^7.28.5",
"@babel/preset-typescript": "^7.28.5",
"@types/node": "^24.10.9",
@@ -20,9 +20,9 @@
"typescript": "6.0.3"
},
"dependencies": {
"@navikt/aksel-icons": "^8.23.0",
"@navikt/ds-css": "^8.23.0",
"@navikt/ds-react": "^8.23.0",
"@navikt/aksel-icons": "^8.23.2",
"@navikt/ds-css": "^8.23.2",
"@navikt/ds-react": "^8.23.2",
"react": "19.3.1"
}
}
+8 -8
View File
@@ -76,12 +76,12 @@
"@actions/core": "^3.0.1",
"@changesets/cli": "2.31.1",
"@github-ui/storybook-addon-performance-panel": "^1.3.1",
"@storybook/addon-a11y": "^10.6.3",
"@storybook/addon-docs": "^10.6.3",
"@storybook/addon-themes": "^10.6.3",
"@storybook/addon-vitest": "^10.6.3",
"@storybook/nextjs-vite": "^10.6.3",
"@storybook/react-vite": "^10.6.3",
"@storybook/addon-a11y": "^10.6.7",
"@storybook/addon-docs": "^10.6.7",
"@storybook/addon-themes": "^10.6.7",
"@storybook/addon-vitest": "^10.6.7",
"@storybook/nextjs-vite": "^10.6.7",
"@storybook/react-vite": "^10.6.7",
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
"@types/node": "^24.10.9",
@@ -94,7 +94,7 @@
"cross-env": "^10.1.0",
"eslint": "^9.39.2",
"eslint-plugin-aksel-local": "*",
"eslint-plugin-storybook": "^10.6.3",
"eslint-plugin-storybook": "^10.6.7",
"eslint-plugin-testing-library": "^7.16.0",
"fast-glob": "3.3.3",
"husky": "^9.1.7",
@@ -105,7 +105,7 @@
"react": "19.3.1",
"react-docgen-typescript": "2.4.0",
"react-dom": "19.3.1",
"storybook": "^10.6.3",
"storybook": "^10.6.7",
"stylelint": "^17.15.0",
"stylelint-config-standard": "^40.0.0",
"stylelint-declaration-block-no-ignored-properties": "^3.0.0",
+640 -304
View File
File diff suppressed because it is too large. Load diff