@oslokommune/punkt-react 18.6.1 → 18.7.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,86 @@
1
+ /**
2
+ * card.ts
3
+ *
4
+ * Type definitions for pkt-card.
5
+ * Used by React, Elements, and typed component specs.
6
+ */
7
+ import type { THeadingLevel } from './heading';
8
+ import type { TLayout } from './layout';
9
+ import type { TTagSkin } from './skin';
10
+ /** Card skin variants — shared runtime source for types, specs, and Preview. */
11
+ export declare const CARD_SKINS: readonly ['outlined', 'outlined-beige', 'gray', 'blue', 'beige', 'green'];
12
+ export type TCardSkin = (typeof CARD_SKINS)[number];
13
+ /** Card padding variants — shared runtime source for types, specs, and Preview. */
14
+ export declare const CARD_PADDINGS: readonly ['none', 'default'];
15
+ export type TCardPadding = (typeof CARD_PADDINGS)[number];
16
+ /** Card image shape variants — shared runtime source for types, specs, and Preview. */
17
+ export declare const CARD_IMAGE_SHAPES: readonly ['square', 'round'];
18
+ export type TCardImageShape = (typeof CARD_IMAGE_SHAPES)[number];
19
+ /** Card image aspect-ratio overrides — shared runtime source for types, specs, and Preview. */
20
+ export declare const CARD_IMAGE_ASPECTS: readonly ['auto', '1-1', '4-3', '3-2', '16-9', '19-10'];
21
+ export type TCardImageAspect = (typeof CARD_IMAGE_ASPECTS)[number];
22
+ /** Card tag-row placement — shared runtime source for types, specs, and Preview. */
23
+ export declare const CARD_TAG_POSITIONS: readonly ['top', 'bottom'];
24
+ export type TCardTagPosition = (typeof CARD_TAG_POSITIONS)[number];
25
+ /**
26
+ * Curated tag skins offered for Card's `tags` prop in Preview/docs.
27
+ * `ICardTag.skin` itself stays the full `TTagSkin` union — this is a
28
+ * documented/recommended subset, not a type restriction.
29
+ */
30
+ export declare const CARD_TAG_SKIN_OPTIONS: readonly ['blue', 'green', 'red', 'yellow'];
31
+ /** One tag rendered in Card's tag row. */
32
+ export interface ICardTag {
33
+ skin?: TTagSkin;
34
+ iconName?: string;
35
+ ariaLabel?: string;
36
+ text: string;
37
+ }
38
+ /** Card's `image` prop. */
39
+ export interface ICardImage {
40
+ src: string;
41
+ alt?: string;
42
+ }
43
+ /** Card props shared by React and Elements. */
44
+ export interface IPktCardBase {
45
+ ariaLabel?: string;
46
+ metaLead?: string | null;
47
+ metaTrail?: string | null;
48
+ layout?: TLayout;
49
+ heading?: string;
50
+ headingLevel?: THeadingLevel;
51
+ image?: ICardImage;
52
+ imageShape?: TCardImageShape;
53
+ imageAspect?: TCardImageAspect;
54
+ restrictImageHeight?: boolean;
55
+ clickCardLink?: string | null;
56
+ openLinkInNewTab?: boolean;
57
+ borderOnHover?: boolean;
58
+ zoom?: boolean;
59
+ padding?: TCardPadding;
60
+ skin?: TCardSkin;
61
+ subheading?: string;
62
+ tagPosition?: TCardTagPosition;
63
+ tags?: ICardTag[];
64
+ }
65
+ /**
66
+ * Documented Card props (subset of `IPktCardBase`).
67
+ * Used for typed component specs in documentation. Every Card prop is
68
+ * shared between React and Elements — there are no reactOnly/elementsOnly
69
+ * props or events on this component.
70
+ */
71
+ export type ICardSpecProps = Pick<IPktCardBase, 'ariaLabel' | 'metaLead' | 'metaTrail' | 'layout' | 'heading' | 'headingLevel' | 'image' | 'imageShape' | 'imageAspect' | 'restrictImageHeight' | 'clickCardLink' | 'openLinkInNewTab' | 'borderOnHover' | 'zoom' | 'padding' | 'skin' | 'subheading' | 'tagPosition' | 'tags'>;
72
+ /**
73
+ * Default values for pkt-card. Single source of truth for both frameworks
74
+ */
75
+ export declare const CARD_DEFAULTS: {
76
+ readonly headingLevel: 3;
77
+ readonly layout: 'vertical';
78
+ readonly skin: 'outlined';
79
+ readonly padding: 'default';
80
+ readonly tagPosition: 'top';
81
+ readonly openLinkInNewTab: false;
82
+ readonly borderOnHover: true;
83
+ readonly zoom: false;
84
+ readonly imageShape: 'square';
85
+ readonly restrictImageHeight: false;
86
+ };
@@ -9,6 +9,9 @@ export { HEADER_MENU_LOCALES, DEFAULT_HEADER_FOOTER_URL, DEFAULT_HEADER_LOGO_LIN
9
9
  export type { THeaderMenuLocale, IHeaderMenuLink, IHeaderMenuIconLink, IHeaderMenuButton, IHeaderMenuServices, IHeaderMenuSection, IMegaMenu, IHeaderFooter, IHeaderFooterLocaleData, THeaderFooterApi, IPktHeaderMenu, IPktHeaderGlobal, } from './header-footer';
10
10
  export type { IPktFooterLink, IPktFooterColumn, IPktFooterSocialLink, IPktFooterBase, IPktFooterProps, IPktFooterSimpleProps, IFooterSimpleSpecProps, IFooterSpecProps, } from './footer';
11
11
  export { DEFAULT_FOOTER_PERSONVERN_URL, DEFAULT_FOOTER_TILGJENGELIGHET_URL } from './footer';
12
+ export { CARD_SKINS, CARD_PADDINGS, CARD_IMAGE_SHAPES, CARD_IMAGE_ASPECTS, CARD_TAG_POSITIONS, CARD_TAG_SKIN_OPTIONS, CARD_DEFAULTS } from './card';
13
+ export type { TCardSkin, TCardPadding, TCardImageShape, TCardImageAspect, TCardTagPosition, ICardTag, ICardImage, IPktCardBase, ICardSpecProps, } from './card';
14
+ export { LAYOUT_DIRECTIONS } from './layout';
12
15
  export type { TLayout, TVerticalPosition, THorizontalPosition, TPosition, TPositionWithCenter, } from './layout';
13
16
  export type { THTMLButtonType, TSelectionMode } from './form';
14
17
  export type { TPktInputSize, TSize3, TSize5, TSize7 } from './size';
@@ -24,7 +27,7 @@ export type { TBreadcrumbsNavigationType, IBreadcrumb, IBreadcrumbItem, IBreadcr
24
27
  export type { IRenderLink, TRenderLink } from './render-link';
25
28
  export type { IPktStringsProps } from '../shared-strings';
26
29
  export type { IHelptextProps, ITagOptionalRequiredProps, IFormFieldLabelProps, IFormFieldErrorProps, IFormFieldCommonProps, TFormFieldCommonSpecKeys, } from './form-field';
27
- export type { TMessageboxSkin, TCardSkin, TTagSkin } from './skin';
30
+ export type { TMessageboxSkin, TTagSkin } from './skin';
28
31
  export { CALENDAR_DEFAULTS } from './calendar';
29
32
  export type { IPktCalendarBase, ICalendarSpecProps, IDateConstraints, ICalendarGridDimensions, IGridCellPosition, TDateRangeMap, ISelectionState, ISelectionOptions, } from './calendar';
30
33
  export type { IDatepickerStrings } from './datepicker';
@@ -7,7 +7,8 @@
7
7
  /**
8
8
  * Layout direction - vertical or horizontal orientation
9
9
  */
10
- export type TLayout = 'vertical' | 'horizontal';
10
+ export declare const LAYOUT_DIRECTIONS: readonly ['vertical', 'horizontal'];
11
+ export type TLayout = (typeof LAYOUT_DIRECTIONS)[number];
11
12
  /**
12
13
  * Generic positioning type for top/bottom placement
13
14
  */
@@ -7,14 +7,11 @@
7
7
  */
8
8
  export { ALERT_SKINS, type TAlertSkin } from './alert';
9
9
  export { ACCORDION_SKINS, type TAccordionSkin } from './accordion';
10
+ export { CARD_SKINS, type TCardSkin } from './card';
10
11
  /**
11
12
  * Messagebox component skin variants
12
13
  */
13
14
  export type TMessageboxSkin = 'beige' | 'blue' | 'red' | 'green';
14
- /**
15
- * Card component skin variants
16
- */
17
- export type TCardSkin = 'outlined' | 'outlined-beige' | 'gray' | 'beige' | 'green' | 'blue';
18
15
  /**
19
16
  * Tag component skin variants
20
17
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-react",
3
- "version": "18.6.1",
3
+ "version": "18.7.1",
4
4
  "description": "React komponentbibliotek til Punkt, et designsystem laget av Oslo Origo",
5
5
  "homepage": "https://punkt.oslo.kommune.no",
6
6
  "author": "Team Designsystem, Oslo Origo",
@@ -33,19 +33,14 @@
33
33
  "test": "vitest run",
34
34
  "test:watch": "vitest"
35
35
  },
36
- "dependencies": {
37
- "classnames": "^2.5.1",
38
- "prettier": "^3.8.4",
39
- "react-hook-form": "^7.79.0"
40
- },
41
36
  "devDependencies": {
42
37
  "@babel/plugin-transform-private-property-in-object": "^7.27.1",
43
38
  "@eslint-react/eslint-plugin": "^5.9.0",
44
39
  "@eslint/compat": "^2.1.0",
45
40
  "@eslint/eslintrc": "^3.3.5",
46
41
  "@eslint/js": "^10.0.1",
47
- "@oslokommune/punkt-assets": "^18.5.1",
48
- "@oslokommune/punkt-css": "^18.5.1",
42
+ "@oslokommune/punkt-assets": "^18.7.1",
43
+ "@oslokommune/punkt-css": "^18.7.1",
49
44
  "@testing-library/jest-dom": "^6.9.1",
50
45
  "@testing-library/react": "^16.3.2",
51
46
  "@testing-library/user-event": "^14.6.1",
@@ -54,6 +49,7 @@
54
49
  "@types/react": "^19.2.17",
55
50
  "@types/react-dom": "^19.2.3",
56
51
  "@vitejs/plugin-react": "^6.0.2",
52
+ "classnames": "^2.5.1",
57
53
  "eslint": "^10.5.0",
58
54
  "eslint-config-prettier": "^10.1.8",
59
55
  "eslint-plugin-prettier": "^5.5.6",
@@ -62,7 +58,9 @@
62
58
  "globals": "^17.6.0",
63
59
  "jest-axe": "^10.0.0",
64
60
  "jsdom": "^29.1.1",
65
- "react-router-dom": "^6.30.6",
61
+ "prettier": "^3.8.4",
62
+ "react-hook-form": "^7.79.0",
63
+ "react-router-dom": "^7.18.3",
66
64
  "sass": "^1.101.0",
67
65
  "typescript": "^7.0.2",
68
66
  "typescript-eslint": "^8.61.1",
@@ -102,5 +100,5 @@
102
100
  "url": "https://github.com/oslokommune/punkt/issues"
103
101
  },
104
102
  "license": "MIT",
105
- "gitHead": "8d641683796be69cb519cfe8ca021731d165e8f1"
103
+ "gitHead": "b9a5110dfcbbda5ade917339741350805b8a0152"
106
104
  }
@@ -2,45 +2,14 @@
2
2
 
3
3
  import classNames from 'classnames'
4
4
  import { forwardRef, HTMLAttributes, ReactNode, Ref } from 'react'
5
- import type { TCardSkin, TLayout, TTagSkin } from 'shared-types'
5
+ import { CARD_DEFAULTS, type IPktCardBase, type TCardSkin, type TLayout } from 'shared-types'
6
6
 
7
7
  import { PktHeading } from '../heading/Heading'
8
8
  import { PktTag } from '../tag/Tag'
9
9
 
10
10
  export type { TCardSkin, TLayout }
11
- type TCardPadding = 'none' | 'default'
12
- type TCardImageShape = 'square' | 'round'
13
- type TCardImageAspect = 'auto' | '1-1' | '4-3' | '3-2' | '16-9' | '19-10'
14
- type TCardTagPosition = 'top' | 'bottom'
15
- type THeadingLevel = 1 | 2 | 3 | 4 | 5 | 6
16
11
 
17
- interface ICardTag {
18
- skin?: TTagSkin
19
- iconName?: string
20
- ariaLabel?: string
21
- text: string
22
- }
23
-
24
- export interface IPktCard extends Omit<HTMLAttributes<HTMLElement>, 'title'> {
25
- ariaLabel?: string
26
- metaLead?: string | null
27
- borderOnHover?: boolean
28
- zoom?: boolean
29
- metaTrail?: string | null
30
- layout?: TLayout
31
- heading?: string
32
- headingLevel?: THeadingLevel
33
- image?: { src: string; alt: string }
34
- imageShape?: TCardImageShape
35
- imageAspect?: TCardImageAspect
36
- restrictImageHeight?: boolean
37
- clickCardLink?: string | null
38
- padding?: TCardPadding
39
- openLinkInNewTab?: boolean
40
- skin?: TCardSkin
41
- subheading?: string
42
- tagPosition?: TCardTagPosition
43
- tags?: ICardTag[]
12
+ export interface IPktCard extends IPktCardBase, Omit<HTMLAttributes<HTMLElement>, 'title'> {
44
13
  children?: ReactNode
45
14
  ref?: Ref<HTMLElement>
46
15
  }
@@ -52,22 +21,22 @@ export const PktCard = forwardRef<HTMLElement, IPktCard>(
52
21
  className,
53
22
  ariaLabel,
54
23
  metaLead,
55
- borderOnHover = true,
24
+ borderOnHover = CARD_DEFAULTS.borderOnHover,
56
25
  metaTrail,
57
- layout = 'vertical',
26
+ layout = CARD_DEFAULTS.layout,
58
27
  heading = '',
59
- headingLevel = 3,
28
+ headingLevel = CARD_DEFAULTS.headingLevel,
60
29
  image,
61
- imageShape = 'square',
30
+ imageShape = CARD_DEFAULTS.imageShape,
62
31
  imageAspect,
63
- restrictImageHeight = false,
32
+ restrictImageHeight = CARD_DEFAULTS.restrictImageHeight,
64
33
  clickCardLink,
65
- padding = 'default',
66
- openLinkInNewTab = false,
67
- skin = 'outlined',
34
+ padding = CARD_DEFAULTS.padding,
35
+ openLinkInNewTab = CARD_DEFAULTS.openLinkInNewTab,
36
+ skin = CARD_DEFAULTS.skin,
68
37
  subheading = '',
69
- tagPosition = 'top',
70
- zoom = false,
38
+ tagPosition = CARD_DEFAULTS.tagPosition,
39
+ zoom = CARD_DEFAULTS.zoom,
71
40
  tags = [],
72
41
  ...props
73
42
  },