@oslokommune/punkt-react 19.20.0 → 20.0.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 +59 -0
- package/README.md +3 -2
- package/dist/components/card/Card.js +77 -70
- package/dist/components/checkbox/Checkbox.js +1 -1
- package/dist/components/inputwrapper/InputWrapper.js +1 -1
- package/dist/components/link/Link.d.ts +0 -1
- package/dist/components/link/Link.js +10 -12
- package/dist/components/linkcard/LinkCard.d.ts +1 -1
- package/dist/components/linkcard/LinkCard.js +23 -20
- package/dist/components/messagebox/Messagebox.js +29 -28
- package/dist/components/radio/RadioButton.js +1 -1
- package/dist/components/tag/Tag.d.ts +2 -1
- package/dist/components/tag/Tag.js +37 -35
- package/dist/punkt-react.cjs +1 -1
- package/dist/shared-types/card.d.ts +5 -17
- package/dist/shared-types/card.js +9 -8
- package/dist/shared-types/combobox.d.ts +3 -3
- package/dist/shared-types/icon.d.ts +2 -2
- package/dist/shared-types/icon.js +1 -1
- package/dist/shared-types/index.d.ts +9 -8
- package/dist/shared-types/index.js +17 -16
- package/dist/shared-types/linkcard.d.ts +7 -4
- package/dist/shared-types/linkcard.js +9 -0
- package/dist/shared-types/messagebox.d.ts +4 -2
- package/dist/shared-types/messagebox.js +8 -3
- package/dist/shared-types/skin.d.ts +8 -2
- package/package.json +4 -4
- package/src/components/button/Button.test.tsx +1 -1
- package/src/components/card/Card.test.tsx +78 -43
- package/src/components/card/Card.tsx +17 -24
- package/src/components/checkbox/Checkbox.tsx +1 -1
- package/src/components/inputwrapper/InputWrapper.tsx +1 -1
- package/src/components/link/Link.test.tsx +9 -21
- package/src/components/link/Link.tsx +0 -4
- package/src/components/linkcard/LinkCard.test.tsx +20 -9
- package/src/components/linkcard/LinkCard.tsx +5 -11
- package/src/components/messagebox/Messagebox.test.tsx +10 -1
- package/src/components/messagebox/Messagebox.tsx +11 -2
- package/src/components/radio/RadioButton.tsx +1 -1
- package/src/components/tag/Tag.test.tsx +21 -0
- package/src/components/tag/Tag.tsx +6 -2
|
@@ -8,14 +8,10 @@ import type { THeadingLevel } from './heading';
|
|
|
8
8
|
import type { TLayout } from './layout';
|
|
9
9
|
import type { TTagSkin } from './skin';
|
|
10
10
|
/** Card skin variants — shared runtime source for types, specs, and Preview. */
|
|
11
|
-
export declare const CARD_SKINS: readonly ['
|
|
11
|
+
export declare const CARD_SKINS: readonly ['gray', 'outlined', 'transparent', 'white', 'blue', 'green', 'beige'];
|
|
12
12
|
export type TCardSkin = (typeof CARD_SKINS)[number];
|
|
13
|
-
/**
|
|
14
|
-
export declare const
|
|
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];
|
|
13
|
+
/** Skins without a dark variant. The card gets `data-mode="light"` and stays in light mode. */
|
|
14
|
+
export declare const CARD_LIGHT_ONLY_SKINS: readonly TCardSkin[];
|
|
19
15
|
/** Card image aspect-ratio overrides — shared runtime source for types, specs, and Preview. */
|
|
20
16
|
export declare const CARD_IMAGE_ASPECTS: readonly ['auto', '1-1', '4-3', '3-2', '16-9', '19-10'];
|
|
21
17
|
export type TCardImageAspect = (typeof CARD_IMAGE_ASPECTS)[number];
|
|
@@ -49,14 +45,10 @@ export interface IPktCardBase {
|
|
|
49
45
|
heading?: string;
|
|
50
46
|
headingLevel?: THeadingLevel;
|
|
51
47
|
image?: ICardImage;
|
|
52
|
-
imageShape?: TCardImageShape;
|
|
53
48
|
imageAspect?: TCardImageAspect;
|
|
54
|
-
restrictImageHeight?: boolean;
|
|
55
49
|
clickCardLink?: string | null;
|
|
56
50
|
openLinkInNewTab?: boolean;
|
|
57
|
-
borderOnHover?: boolean;
|
|
58
51
|
zoom?: boolean;
|
|
59
|
-
padding?: TCardPadding;
|
|
60
52
|
skin?: TCardSkin;
|
|
61
53
|
subheading?: string;
|
|
62
54
|
tagPosition?: TCardTagPosition;
|
|
@@ -68,19 +60,15 @@ export interface IPktCardBase {
|
|
|
68
60
|
* shared between React and Elements — there are no reactOnly/elementsOnly
|
|
69
61
|
* props or events on this component.
|
|
70
62
|
*/
|
|
71
|
-
export type ICardSpecProps = Pick<IPktCardBase, 'ariaLabel' | 'metaLead' | 'metaTrail' | 'layout' | 'heading' | 'headingLevel' | 'image' | '
|
|
63
|
+
export type ICardSpecProps = Pick<IPktCardBase, 'ariaLabel' | 'metaLead' | 'metaTrail' | 'layout' | 'heading' | 'headingLevel' | 'image' | 'imageAspect' | 'clickCardLink' | 'openLinkInNewTab' | 'zoom' | 'skin' | 'subheading' | 'tagPosition' | 'tags'>;
|
|
72
64
|
/**
|
|
73
65
|
* Default values for pkt-card. Single source of truth for both frameworks
|
|
74
66
|
*/
|
|
75
67
|
export declare const CARD_DEFAULTS: {
|
|
76
68
|
readonly headingLevel: 3;
|
|
77
69
|
readonly layout: 'vertical';
|
|
78
|
-
readonly skin: '
|
|
79
|
-
readonly padding: 'default';
|
|
70
|
+
readonly skin: 'gray';
|
|
80
71
|
readonly tagPosition: 'top';
|
|
81
72
|
readonly openLinkInNewTab: false;
|
|
82
|
-
readonly borderOnHover: true;
|
|
83
73
|
readonly zoom: false;
|
|
84
|
-
readonly imageShape: 'square';
|
|
85
|
-
readonly restrictImageHeight: false;
|
|
86
74
|
};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
//#region ../../shared-types/card.ts
|
|
2
|
-
var e =
|
|
2
|
+
var e = [
|
|
3
|
+
"white",
|
|
4
|
+
"blue",
|
|
5
|
+
"green",
|
|
6
|
+
"beige"
|
|
7
|
+
], t = {
|
|
3
8
|
headingLevel: 3,
|
|
4
9
|
layout: "vertical",
|
|
5
|
-
skin: "
|
|
6
|
-
padding: "default",
|
|
10
|
+
skin: "gray",
|
|
7
11
|
tagPosition: "top",
|
|
8
12
|
openLinkInNewTab: !1,
|
|
9
|
-
|
|
10
|
-
zoom: !1,
|
|
11
|
-
imageShape: "square",
|
|
12
|
-
restrictImageHeight: !1
|
|
13
|
+
zoom: !1
|
|
13
14
|
};
|
|
14
15
|
//#endregion
|
|
15
|
-
export {
|
|
16
|
+
export { t as CARD_DEFAULTS, e as CARD_LIGHT_ONLY_SKINS };
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
* Used by both Elements and React implementations,
|
|
6
6
|
* the shared combobox helper functions, and typed component specs.
|
|
7
7
|
*/
|
|
8
|
+
import { type TTagSkin } from './skin';
|
|
8
9
|
import type { IFormFieldErrorProps, IFormFieldLabelProps, IHelptextProps, ITagOptionalRequiredProps } from './form-field';
|
|
9
10
|
import type { TPktInputSize } from './size';
|
|
10
11
|
/**
|
|
11
12
|
* Tag skin colors available for combobox option tags.
|
|
12
|
-
* Matches the TTagSkin values from the tag component.
|
|
13
13
|
*/
|
|
14
|
-
export declare const COMBOBOX_TAG_SKINS: readonly [
|
|
15
|
-
export type TPktComboboxTagSkin =
|
|
14
|
+
export declare const COMBOBOX_TAG_SKINS: readonly ["gray", "gray-light", "blue-dark", "blue", "blue-light", "blue-pale", "green", "green-light", "red", "red-light", "yellow", "yellow-light", "beige", "beige-light"];
|
|
15
|
+
export type TPktComboboxTagSkin = TTagSkin;
|
|
16
16
|
/**
|
|
17
17
|
* Represents a single option in a combobox or listbox.
|
|
18
18
|
*/
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { Booleanish } from './booleanish';
|
|
8
8
|
/** Default CDN path for icons. Overridden globally by `window.pktIconPath`. */
|
|
9
|
-
export declare const ICON_DEFAULT_PATH = "https://
|
|
9
|
+
export declare const ICON_DEFAULT_PATH = "https://cdn.ikoner.oslo.kommune.no/icons/";
|
|
10
10
|
/** Default CDN path for loading animations. Overridden globally by `window.pktAnimationPath`. */
|
|
11
11
|
export declare const ANIMATION_DEFAULT_PATH = "https://punkt-cdn.oslo.kommune.no/latest/animations/";
|
|
12
12
|
/** Icon size modifier classes — shared runtime source for types, specs, and Preview. */
|
|
@@ -37,5 +37,5 @@ export type IIconSpecProps = Pick<IPktIconBase, 'name' | 'path' | 'ariaHidden' |
|
|
|
37
37
|
*/
|
|
38
38
|
export declare const ICON_DEFAULTS: {
|
|
39
39
|
readonly name: '';
|
|
40
|
-
readonly path: "https://
|
|
40
|
+
readonly path: "https://cdn.ikoner.oslo.kommune.no/icons/";
|
|
41
41
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region ../../shared-types/icon.ts
|
|
2
|
-
var e = "https://
|
|
2
|
+
var e = "https://cdn.ikoner.oslo.kommune.no/icons/", t = "https://punkt-cdn.oslo.kommune.no/latest/animations/", n = {
|
|
3
3
|
name: "",
|
|
4
4
|
path: e
|
|
5
5
|
};
|
|
@@ -11,8 +11,8 @@ export { HEADER_MENU_LOCALES, DEFAULT_HEADER_FOOTER_URL, DEFAULT_HEADER_LOGO_LIN
|
|
|
11
11
|
export type { THeaderMenuLocale, IHeaderMenuLink, IHeaderMenuIconLink, IHeaderMenuButton, IHeaderMenuServices, IHeaderMenuSection, IMegaMenu, IHeaderFooter, IHeaderFooterLocaleData, THeaderFooterApi, IPktHeaderMenu, IPktHeaderGlobal, } from './header-footer';
|
|
12
12
|
export type { IPktFooterLink, IPktFooterColumn, IPktFooterSocialLink, IPktFooterBase, IPktFooterProps, IPktFooterSimpleProps, IFooterSimpleSpecProps, IFooterSpecProps, } from './footer';
|
|
13
13
|
export { DEFAULT_FOOTER_PERSONVERN_URL, DEFAULT_FOOTER_TILGJENGELIGHET_URL } from './footer';
|
|
14
|
-
export { CARD_SKINS,
|
|
15
|
-
export type { TCardSkin,
|
|
14
|
+
export { CARD_SKINS, CARD_LIGHT_ONLY_SKINS, CARD_IMAGE_ASPECTS, CARD_TAG_POSITIONS, CARD_TAG_SKIN_OPTIONS, CARD_DEFAULTS, } from './card';
|
|
15
|
+
export type { TCardSkin, TCardImageAspect, TCardTagPosition, ICardTag, ICardImage, IPktCardBase, ICardSpecProps, } from './card';
|
|
16
16
|
export { CHECKBOX_LABEL_POSITIONS, CHECKBOX_DEFAULTS } from './checkbox';
|
|
17
17
|
export type { TCheckboxLabelPosition, IPktCheckboxBase, ICheckboxSpecProps } from './checkbox';
|
|
18
18
|
export { RADIOBUTTON_DEFAULTS } from './radiobutton';
|
|
@@ -33,8 +33,8 @@ export type { TAccordionSkin, IPktAccordionBase, IPktAccordionItemBase, IAccordi
|
|
|
33
33
|
export { BUTTON_SIZES, BUTTON_SKINS, BUTTON_COLORS, BUTTON_VARIANTS, BUTTON_STATES } from './button';
|
|
34
34
|
export type { TPktButtonSize, TPktButtonSkin, TPktButtonColor, TPktButtonVariant, TPktButtonState, IPktButtonBase, IButtonSpecProps, } from './button';
|
|
35
35
|
export type { IPktBackLinkBase, IBacklinkSpecProps } from './backlink';
|
|
36
|
-
export { LINKCARD_SKINS } from './linkcard';
|
|
37
|
-
export type { TLinkCardSkin, IPktLinkCardBase, ILinkcardSpecProps } from './linkcard';
|
|
36
|
+
export { LINKCARD_SKINS, LINKCARD_LIGHT_ONLY_SKINS } from './linkcard';
|
|
37
|
+
export type { TLinkCardSkin, TDeprecatedLinkCardSkin, IPktLinkCardBase, ILinkcardSpecProps, } from './linkcard';
|
|
38
38
|
export { BREADCRUMBS_NAVIGATION_TYPES } from './breadcrumbs';
|
|
39
39
|
export type { TBreadcrumbsNavigationType, IBreadcrumb, IBreadcrumbItem, IBreadcrumbs, IPktBreadcrumbsBase, IBreadcrumbsSpecProps, } from './breadcrumbs';
|
|
40
40
|
export type { IRenderLink, TRenderLink } from './render-link';
|
|
@@ -46,9 +46,10 @@ export type { IPktTextareaBase, ITextareaSpecProps } from './textarea';
|
|
|
46
46
|
export { TEXTINPUT_DEFAULTS, TEXTINPUT_TYPES } from './textinput';
|
|
47
47
|
export type { TPktTextinputType, IPktTextinputBase, ITextinputSpecProps } from './textinput';
|
|
48
48
|
export type { TPktCounterPosition, IPktInputWrapperBase, IInputWrapperSpecProps, } from './input-wrapper';
|
|
49
|
-
export
|
|
50
|
-
export {
|
|
51
|
-
export
|
|
49
|
+
export { TAG_SKINS, TAG_STATES } from './skin';
|
|
50
|
+
export type { TMessageboxSkin, TTagSkin, TTagState } from './skin';
|
|
51
|
+
export { MESSAGEBOX_SKINS, MESSAGEBOX_LIGHT_ONLY_SKINS, MESSAGEBOX_DEFAULTS } from './messagebox';
|
|
52
|
+
export type { IPktMessageboxBase, IMessageboxSpecProps } from './messagebox';
|
|
52
53
|
export { CALENDAR_DEFAULTS } from './calendar';
|
|
53
54
|
export type { IPktCalendarBase, ICalendarSpecProps, IDateConstraints, ICalendarGridDimensions, IGridCellPosition, TDateRangeMap, ISelectionState, ISelectionOptions, } from './calendar';
|
|
54
55
|
export type { IDatepickerStrings } from './datepicker';
|
|
@@ -57,7 +58,7 @@ export type { ITimepickerStrings } from './timepicker';
|
|
|
57
58
|
export { defaultTimepickerStrings } from './timepicker';
|
|
58
59
|
export { PROGRESSBAR_DEFAULTS, PROGRESSBAR_ROLES, PROGRESSBAR_SKINS, PROGRESSBAR_STATUS_PLACEMENTS, PROGRESSBAR_STATUS_TYPES, PROGRESSBAR_TITLE_POSITIONS, } from './progressbar';
|
|
59
60
|
export type { IPktProgressbarBase, IProgressbarSpecProps, TProgressbarRole, TProgressbarSkin, TProgressbarStatusPlacement, TProgressbarStatusType, TProgressbarTitlePosition, } from './progressbar';
|
|
60
|
-
export {
|
|
61
|
+
export { COMBOBOX_DISPLAY_VALUES, COMBOBOX_TAG_PLACEMENTS, COMBOBOX_DEFAULTS } from './combobox';
|
|
61
62
|
export type { IPktComboboxOption, TPktComboboxTagSkin, TPktComboboxDisplayValue, TPktComboboxTagPlacement, IPktComboboxBase, IComboboxSpecProps, } from './combobox';
|
|
62
63
|
export { SELECT_DEFAULTS } from './select';
|
|
63
64
|
export type { IPktSelectOption, TSelectOption, IPktSelectBase, ISelectSpecProps } from './select';
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import "./size.js";
|
|
2
2
|
import { DEFAULT_HEADER_FOOTER_URL as e, DEFAULT_HEADER_LOGO_LINK as t } from "./header-footer.js";
|
|
3
3
|
import { DEFAULT_FOOTER_PERSONVERN_URL as n, DEFAULT_FOOTER_TILGJENGELIGHET_URL as r } from "./footer.js";
|
|
4
|
-
import { CARD_DEFAULTS as i } from "./card.js";
|
|
5
|
-
import { CHECKBOX_DEFAULTS as
|
|
6
|
-
import { RADIOBUTTON_DEFAULTS as
|
|
7
|
-
import { OPTION_GROUP_DEFAULTS as
|
|
8
|
-
import { CONSENT_DEFAULTS as
|
|
9
|
-
import { ANIMATION_DEFAULT_PATH as
|
|
10
|
-
import { LOADER_DEFAULTS as
|
|
11
|
-
import { ACCORDION_LIGHT_ONLY_SKINS as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
4
|
+
import { CARD_DEFAULTS as i, CARD_LIGHT_ONLY_SKINS as a } from "./card.js";
|
|
5
|
+
import { CHECKBOX_DEFAULTS as o } from "./checkbox.js";
|
|
6
|
+
import { RADIOBUTTON_DEFAULTS as s } from "./radiobutton.js";
|
|
7
|
+
import { OPTION_GROUP_DEFAULTS as c } from "./option-group.js";
|
|
8
|
+
import { CONSENT_DEFAULTS as l } from "./consent.js";
|
|
9
|
+
import { ANIMATION_DEFAULT_PATH as u, ICON_DEFAULTS as d } from "./icon.js";
|
|
10
|
+
import { LOADER_DEFAULTS as f } from "./loader.js";
|
|
11
|
+
import { ACCORDION_LIGHT_ONLY_SKINS as p } from "./accordion.js";
|
|
12
|
+
import { LINKCARD_LIGHT_ONLY_SKINS as m } from "./linkcard.js";
|
|
13
|
+
import { INPUT_WRAPPER_DEFAULTS as h } from "./input-wrapper.js";
|
|
14
|
+
import { TEXTAREA_DEFAULTS as g } from "./textarea.js";
|
|
15
|
+
import { TEXTINPUT_DEFAULTS as _ } from "./textinput.js";
|
|
16
|
+
import { MESSAGEBOX_DEFAULTS as v, MESSAGEBOX_LIGHT_ONLY_SKINS as y } from "./messagebox.js";
|
|
16
17
|
import "./calendar.js";
|
|
17
|
-
import { PROGRESSBAR_DEFAULTS as
|
|
18
|
+
import { PROGRESSBAR_DEFAULTS as b } from "./progressbar.js";
|
|
18
19
|
import "./combobox.js";
|
|
19
|
-
import { SELECT_DEFAULTS as
|
|
20
|
-
import { TABLE_DEFAULTS as
|
|
21
|
-
export {
|
|
20
|
+
import { SELECT_DEFAULTS as x } from "./select.js";
|
|
21
|
+
import { TABLE_DEFAULTS as S } from "./table.js";
|
|
22
|
+
export { p as ACCORDION_LIGHT_ONLY_SKINS, u as ANIMATION_DEFAULT_PATH, i as CARD_DEFAULTS, a as CARD_LIGHT_ONLY_SKINS, o as CHECKBOX_DEFAULTS, l as CONSENT_DEFAULTS, n as DEFAULT_FOOTER_PERSONVERN_URL, r as DEFAULT_FOOTER_TILGJENGELIGHET_URL, e as DEFAULT_HEADER_FOOTER_URL, t as DEFAULT_HEADER_LOGO_LINK, d as ICON_DEFAULTS, h as INPUT_WRAPPER_DEFAULTS, m as LINKCARD_LIGHT_ONLY_SKINS, f as LOADER_DEFAULTS, v as MESSAGEBOX_DEFAULTS, y as MESSAGEBOX_LIGHT_ONLY_SKINS, c as OPTION_GROUP_DEFAULTS, b as PROGRESSBAR_DEFAULTS, s as RADIOBUTTON_DEFAULTS, x as SELECT_DEFAULTS, S as TABLE_DEFAULTS, g as TEXTAREA_DEFAULTS, _ as TEXTINPUT_DEFAULTS };
|
|
@@ -6,8 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { IPktStringsProps } from '../shared-strings';
|
|
8
8
|
/** LinkCard skin variants — shared runtime source for types, specs, and Preview. */
|
|
9
|
-
export declare const LINKCARD_SKINS: readonly ['
|
|
10
|
-
|
|
9
|
+
export declare const LINKCARD_SKINS: readonly ['gray', 'outlined', 'transparent', 'white', 'blue', 'green', 'beige'];
|
|
10
|
+
/** @deprecated Old names that still work: `normal` is `transparent`, `gray-outline` is `outlined`. */
|
|
11
|
+
export type TDeprecatedLinkCardSkin = 'normal' | 'gray-outline';
|
|
12
|
+
export type TLinkCardSkin = (typeof LINKCARD_SKINS)[number] | TDeprecatedLinkCardSkin;
|
|
13
|
+
/** Skins without a dark variant. The link card gets `data-mode="light"` and stays in light mode. */
|
|
14
|
+
export declare const LINKCARD_LIGHT_ONLY_SKINS: readonly TLinkCardSkin[];
|
|
11
15
|
/** Shared LinkCard props for React, Elements, and typed specs. */
|
|
12
16
|
export type IPktLinkCardBase = IPktStringsProps<'linkcard'> & {
|
|
13
17
|
title?: string;
|
|
@@ -15,10 +19,9 @@ export type IPktLinkCardBase = IPktStringsProps<'linkcard'> & {
|
|
|
15
19
|
skin?: TLinkCardSkin;
|
|
16
20
|
iconName?: string;
|
|
17
21
|
openInNewTab?: boolean;
|
|
18
|
-
external?: boolean;
|
|
19
22
|
};
|
|
20
23
|
/**
|
|
21
24
|
* Documented LinkCard props (subset of `IPktLinkCardBase`).
|
|
22
25
|
* Used for typed component specs in documentation.
|
|
23
26
|
*/
|
|
24
|
-
export type ILinkcardSpecProps = Pick<IPktLinkCardBase, 'title' | 'href' | 'skin' | 'iconName' | 'openInNewTab'
|
|
27
|
+
export type ILinkcardSpecProps = Pick<IPktLinkCardBase, 'title' | 'href' | 'skin' | 'iconName' | 'openInNewTab'>;
|
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
* Used by React, Elements, and typed component specs.
|
|
6
6
|
*/
|
|
7
7
|
/** Messagebox skin variants — shared runtime source for types, specs, and Preview. */
|
|
8
|
-
export declare const MESSAGEBOX_SKINS: readonly ['beige', 'blue', 'red', 'green'];
|
|
8
|
+
export declare const MESSAGEBOX_SKINS: readonly ['gray', 'beige', 'blue', 'red', 'green'];
|
|
9
9
|
export type TMessageboxSkin = (typeof MESSAGEBOX_SKINS)[number];
|
|
10
|
+
/** Skins without a dark variant. The messagebox gets `data-mode="light"` and stays in light mode. */
|
|
11
|
+
export declare const MESSAGEBOX_LIGHT_ONLY_SKINS: readonly TMessageboxSkin[];
|
|
10
12
|
/**
|
|
11
13
|
* Messagebox props shared by React and Elements.
|
|
12
14
|
*
|
|
@@ -26,7 +28,7 @@ export interface IPktMessageboxBase {
|
|
|
26
28
|
export type IMessageboxSpecProps = Pick<IPktMessageboxBase, 'title' | 'skin' | 'compact' | 'closable'>;
|
|
27
29
|
/** Default values for pkt-messagebox. Single source of truth for both frameworks. */
|
|
28
30
|
export declare const MESSAGEBOX_DEFAULTS: {
|
|
29
|
-
readonly skin: '
|
|
31
|
+
readonly skin: 'gray';
|
|
30
32
|
readonly compact: false;
|
|
31
33
|
readonly closable: false;
|
|
32
34
|
};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
//#region ../../shared-types/messagebox.ts
|
|
2
|
-
var e =
|
|
3
|
-
|
|
2
|
+
var e = [
|
|
3
|
+
"beige",
|
|
4
|
+
"blue",
|
|
5
|
+
"red",
|
|
6
|
+
"green"
|
|
7
|
+
], t = {
|
|
8
|
+
skin: "gray",
|
|
4
9
|
compact: !1,
|
|
5
10
|
closable: !1
|
|
6
11
|
};
|
|
7
12
|
//#endregion
|
|
8
|
-
export {
|
|
13
|
+
export { t as MESSAGEBOX_DEFAULTS, e as MESSAGEBOX_LIGHT_ONLY_SKINS };
|
|
@@ -10,6 +10,12 @@ export { ACCORDION_SKINS, type TAccordionSkin } from './accordion';
|
|
|
10
10
|
export { CARD_SKINS, type TCardSkin } from './card';
|
|
11
11
|
export { MESSAGEBOX_SKINS, type TMessageboxSkin } from './messagebox';
|
|
12
12
|
/**
|
|
13
|
-
* Tag component skin variants
|
|
13
|
+
* Tag component skin variants — shared runtime source for types, specs and demo pages.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export declare const TAG_SKINS: readonly ['gray', 'gray-light', 'blue-dark', 'blue', 'blue-light', 'blue-pale', 'green', 'green-light', 'red', 'red-light', 'yellow', 'yellow-light', 'beige', 'beige-light'];
|
|
16
|
+
export type TTagSkin = (typeof TAG_SKINS)[number];
|
|
17
|
+
/**
|
|
18
|
+
* Forces a tag into a visual state without the user interacting with it.
|
|
19
|
+
*/
|
|
20
|
+
export declare const TAG_STATES: readonly ['hover', 'focus', 'active'];
|
|
21
|
+
export type TTagState = (typeof TAG_STATES)[number];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "20.0.0",
|
|
4
4
|
"description": "React komponentbibliotek til Punkt, designsystem for Oslo kommune",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo kommune",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"@eslint/compat": "^2.1.0",
|
|
43
43
|
"@eslint/eslintrc": "^3.3.5",
|
|
44
44
|
"@eslint/js": "^10.0.1",
|
|
45
|
-
"@oslokommune/punkt-assets": "^
|
|
46
|
-
"@oslokommune/punkt-css": "^
|
|
45
|
+
"@oslokommune/punkt-assets": "^20.0.0",
|
|
46
|
+
"@oslokommune/punkt-css": "^20.0.0",
|
|
47
47
|
"@testing-library/jest-dom": "^7.0.1",
|
|
48
48
|
"@testing-library/react": "^16.3.2",
|
|
49
49
|
"@testing-library/user-event": "^14.6.1",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
104
104
|
},
|
|
105
105
|
"license": "MIT",
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "8a73041756098b52bdb8e9f6448bb1a96184e3c9"
|
|
107
107
|
}
|
|
@@ -153,7 +153,7 @@ describe('PktButton icon paths', () => {
|
|
|
153
153
|
|
|
154
154
|
const icon = document.querySelector('.pkt-btn__icon:not(.pkt-btn__spinner)') as HTMLElement & { path?: string }
|
|
155
155
|
// When not provided, path uses PktIcon's default
|
|
156
|
-
expect(icon?.dataset.path).toBe('https://
|
|
156
|
+
expect(icon?.dataset.path).toBe('https://cdn.ikoner.oslo.kommune.no/icons/')
|
|
157
157
|
})
|
|
158
158
|
|
|
159
159
|
test('passes secondIconPath to second PktIcon when provided', () => {
|
|
@@ -19,7 +19,11 @@ describe('PktCard', () => {
|
|
|
19
19
|
})
|
|
20
20
|
|
|
21
21
|
test('renders content in children', () => {
|
|
22
|
-
const { container } = render(
|
|
22
|
+
const { container } = render(
|
|
23
|
+
<PktCard>
|
|
24
|
+
<p>Test content here</p>
|
|
25
|
+
</PktCard>,
|
|
26
|
+
)
|
|
23
27
|
const content = container.querySelector('.pkt-card__content')
|
|
24
28
|
expect(content).toBeInTheDocument()
|
|
25
29
|
expect(content?.textContent).toContain('Test content here')
|
|
@@ -39,7 +43,11 @@ describe('PktCard', () => {
|
|
|
39
43
|
|
|
40
44
|
test('forwards ref correctly', () => {
|
|
41
45
|
const ref = createRef<HTMLDivElement>()
|
|
42
|
-
const { unmount } = render(
|
|
46
|
+
const { unmount } = render(
|
|
47
|
+
<PktCard ref={ref} heading="Test">
|
|
48
|
+
innhold
|
|
49
|
+
</PktCard>,
|
|
50
|
+
)
|
|
43
51
|
expect(ref.current).toBeInstanceOf(HTMLElement)
|
|
44
52
|
unmount()
|
|
45
53
|
expect(ref.current).toBeNull()
|
|
@@ -50,14 +58,14 @@ describe('PktCard', () => {
|
|
|
50
58
|
test('applies default properties correctly', () => {
|
|
51
59
|
const { container } = render(<PktCard>innhold</PktCard>)
|
|
52
60
|
const article = container.querySelector('article')
|
|
53
|
-
expect(article).toHaveClass('pkt-card--
|
|
61
|
+
expect(article).toHaveClass('pkt-card--gray')
|
|
54
62
|
expect(article).toHaveClass('pkt-card--vertical')
|
|
55
|
-
expect(article).toHaveClass('pkt-card--
|
|
56
|
-
expect(article).
|
|
63
|
+
expect(article).not.toHaveClass('pkt-card--clickable')
|
|
64
|
+
expect(article).not.toHaveAttribute('data-mode')
|
|
57
65
|
})
|
|
58
66
|
|
|
59
67
|
test('applies different skin properties correctly', () => {
|
|
60
|
-
const skins = ['
|
|
68
|
+
const skins = ['gray', 'outlined', 'transparent', 'white', 'blue', 'green', 'beige'] as const
|
|
61
69
|
for (const skin of skins) {
|
|
62
70
|
const { container, unmount } = render(<PktCard skin={skin}>innhold</PktCard>)
|
|
63
71
|
const article = container.querySelector('article')
|
|
@@ -76,20 +84,18 @@ describe('PktCard', () => {
|
|
|
76
84
|
}
|
|
77
85
|
})
|
|
78
86
|
|
|
79
|
-
test('
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const article = container.querySelector('article')
|
|
84
|
-
expect(article).toHaveClass(`pkt-card--padding-${padding}`)
|
|
87
|
+
test('keeps light-only skins in light mode', () => {
|
|
88
|
+
for (const skin of ['white', 'blue', 'green', 'beige'] as const) {
|
|
89
|
+
const { container, unmount } = render(<PktCard skin={skin}>innhold</PktCard>)
|
|
90
|
+
expect(container.querySelector('article')).toHaveAttribute('data-mode', 'light')
|
|
85
91
|
unmount()
|
|
86
92
|
}
|
|
87
|
-
})
|
|
88
93
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
for (const skin of ['gray', 'outlined', 'transparent'] as const) {
|
|
95
|
+
const { container, unmount } = render(<PktCard skin={skin}>innhold</PktCard>)
|
|
96
|
+
expect(container.querySelector('article')).not.toHaveAttribute('data-mode')
|
|
97
|
+
unmount()
|
|
98
|
+
}
|
|
93
99
|
})
|
|
94
100
|
|
|
95
101
|
test('supports custom className', () => {
|
|
@@ -117,7 +123,9 @@ describe('PktCard', () => {
|
|
|
117
123
|
|
|
118
124
|
test('applies correct heading level', () => {
|
|
119
125
|
const { container } = render(
|
|
120
|
-
<PktCard heading="Test" headingLevel={2}>
|
|
126
|
+
<PktCard heading="Test" headingLevel={2}>
|
|
127
|
+
innhold
|
|
128
|
+
</PktCard>,
|
|
121
129
|
)
|
|
122
130
|
const heading = container.querySelector('h2.pkt-card__heading')
|
|
123
131
|
expect(heading).toBeInTheDocument()
|
|
@@ -148,7 +156,9 @@ describe('PktCard', () => {
|
|
|
148
156
|
|
|
149
157
|
test('renders as link card when clickCardLink provided', () => {
|
|
150
158
|
const { container } = render(
|
|
151
|
-
<PktCard heading="Test Title" clickCardLink="/test-url">
|
|
159
|
+
<PktCard heading="Test Title" clickCardLink="/test-url">
|
|
160
|
+
innhold
|
|
161
|
+
</PktCard>,
|
|
152
162
|
)
|
|
153
163
|
const linkHeading = container.querySelector('.pkt-card__link-heading')
|
|
154
164
|
const link = container.querySelector('.pkt-card__link')
|
|
@@ -159,11 +169,26 @@ describe('PktCard', () => {
|
|
|
159
169
|
|
|
160
170
|
const article = container.querySelector('article')
|
|
161
171
|
expect(article?.getAttribute('aria-label')).toBe('Test Title lenkekort')
|
|
172
|
+
expect(article).toHaveClass('pkt-card--clickable')
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
test('renders an arrow after the link in the heading', () => {
|
|
176
|
+
const { container } = render(
|
|
177
|
+
<PktCard heading="Test Title" clickCardLink="/test-url">
|
|
178
|
+
innhold
|
|
179
|
+
</PktCard>,
|
|
180
|
+
)
|
|
181
|
+
const icon = container.querySelector('.pkt-card__link-heading > .pkt-card__link-icon')
|
|
182
|
+
expect(icon).toBeInTheDocument()
|
|
183
|
+
expect(icon?.getAttribute('name')).toBe('arrow-link')
|
|
184
|
+
expect(icon?.previousElementSibling).toHaveClass('pkt-card__link')
|
|
162
185
|
})
|
|
163
186
|
|
|
164
187
|
test('does not render plain heading when clickCardLink is set', () => {
|
|
165
188
|
const { container } = render(
|
|
166
|
-
<PktCard heading="Test" clickCardLink="/test">
|
|
189
|
+
<PktCard heading="Test" clickCardLink="/test">
|
|
190
|
+
innhold
|
|
191
|
+
</PktCard>,
|
|
167
192
|
)
|
|
168
193
|
const headings = container.querySelectorAll('.pkt-card__heading')
|
|
169
194
|
// Should only have the link heading, not both
|
|
@@ -173,7 +198,9 @@ describe('PktCard', () => {
|
|
|
173
198
|
|
|
174
199
|
test('handles openLinkInNewTab correctly', () => {
|
|
175
200
|
const { container } = render(
|
|
176
|
-
<PktCard heading="Test" clickCardLink="/test" openLinkInNewTab>
|
|
201
|
+
<PktCard heading="Test" clickCardLink="/test" openLinkInNewTab>
|
|
202
|
+
innhold
|
|
203
|
+
</PktCard>,
|
|
177
204
|
)
|
|
178
205
|
const link = container.querySelector('.pkt-card__link')
|
|
179
206
|
expect(link?.getAttribute('target')).toBe('_blank')
|
|
@@ -182,7 +209,9 @@ describe('PktCard', () => {
|
|
|
182
209
|
|
|
183
210
|
test('applies correct aria-label for link cards with custom ariaLabel', () => {
|
|
184
211
|
const { container } = render(
|
|
185
|
-
<PktCard clickCardLink="/test" ariaLabel="Custom aria label">
|
|
212
|
+
<PktCard clickCardLink="/test" ariaLabel="Custom aria label">
|
|
213
|
+
innhold
|
|
214
|
+
</PktCard>,
|
|
186
215
|
)
|
|
187
216
|
const article = container.querySelector('article')
|
|
188
217
|
expect(article?.getAttribute('aria-label')).toBe('Custom aria label')
|
|
@@ -191,9 +220,7 @@ describe('PktCard', () => {
|
|
|
191
220
|
|
|
192
221
|
describe('Image functionality', () => {
|
|
193
222
|
test('renders image when provided', () => {
|
|
194
|
-
const { container } = render(
|
|
195
|
-
<PktCard image={{ src: '/test-image.jpg', alt: 'Test image' }}>innhold</PktCard>,
|
|
196
|
-
)
|
|
223
|
+
const { container } = render(<PktCard image={{ src: '/test-image.jpg', alt: 'Test image' }}>innhold</PktCard>)
|
|
197
224
|
const imageDiv = container.querySelector('.pkt-card__image')
|
|
198
225
|
const img = imageDiv?.querySelector('img')
|
|
199
226
|
expect(imageDiv).toBeInTheDocument()
|
|
@@ -208,16 +235,16 @@ describe('PktCard', () => {
|
|
|
208
235
|
expect(imageDiv).not.toBeInTheDocument()
|
|
209
236
|
})
|
|
210
237
|
|
|
211
|
-
test('applies
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
238
|
+
test('applies image aspect class only when imageAspect is set', () => {
|
|
239
|
+
const { container, rerender } = render(<PktCard image={{ src: '/test.jpg', alt: 'Test' }}>innhold</PktCard>)
|
|
240
|
+
expect(Array.from(container.querySelector('.pkt-card__image')?.classList ?? [])).toEqual(['pkt-card__image'])
|
|
241
|
+
|
|
242
|
+
rerender(
|
|
243
|
+
<PktCard image={{ src: '/test.jpg', alt: 'Test' }} imageAspect="16-9">
|
|
244
|
+
innhold
|
|
245
|
+
</PktCard>,
|
|
246
|
+
)
|
|
247
|
+
expect(container.querySelector('.pkt-card__image')).toHaveClass('pkt-card__image-aspect-16-9')
|
|
221
248
|
})
|
|
222
249
|
})
|
|
223
250
|
|
|
@@ -245,7 +272,9 @@ describe('PktCard', () => {
|
|
|
245
272
|
for (const position of positions) {
|
|
246
273
|
const tags = [{ text: 'Test Tag' }]
|
|
247
274
|
const { container, unmount } = render(
|
|
248
|
-
<PktCard tags={tags} tagPosition={position}>
|
|
275
|
+
<PktCard tags={tags} tagPosition={position}>
|
|
276
|
+
innhold
|
|
277
|
+
</PktCard>,
|
|
249
278
|
)
|
|
250
279
|
const tagsContainer = container.querySelector('.pkt-card__tags')
|
|
251
280
|
expect(tagsContainer).toHaveClass(`pkt-card__tags-${position}`)
|
|
@@ -263,7 +292,9 @@ describe('PktCard', () => {
|
|
|
263
292
|
describe('Metadata functionality', () => {
|
|
264
293
|
test('renders metadata when provided', () => {
|
|
265
294
|
const { container } = render(
|
|
266
|
-
<PktCard metaLead="Author Name" metaTrail="2023-12-01">
|
|
295
|
+
<PktCard metaLead="Author Name" metaTrail="2023-12-01">
|
|
296
|
+
innhold
|
|
297
|
+
</PktCard>,
|
|
267
298
|
)
|
|
268
299
|
const metadata = container.querySelector('.pkt-card__metadata')
|
|
269
300
|
const metaLead = metadata?.querySelector('.pkt-card__metadata-lead')
|
|
@@ -313,7 +344,9 @@ describe('PktCard', () => {
|
|
|
313
344
|
</PktCard>,
|
|
314
345
|
)
|
|
315
346
|
const article = container.querySelector('article')
|
|
316
|
-
|
|
347
|
+
expect(article?.children).toHaveLength(1)
|
|
348
|
+
expect(article?.firstElementChild).toHaveClass('pkt-card__container')
|
|
349
|
+
const children = Array.from(article?.firstElementChild?.children || [])
|
|
317
350
|
|
|
318
351
|
// Image first, then wrapper
|
|
319
352
|
expect(children[0]).toHaveClass('pkt-card__image')
|
|
@@ -331,11 +364,11 @@ describe('PktCard', () => {
|
|
|
331
364
|
test('places tags at bottom when tagPosition is bottom', () => {
|
|
332
365
|
const tags = [{ text: 'Test Tag' }]
|
|
333
366
|
const { container } = render(
|
|
334
|
-
<PktCard heading="Test Title" tags={tags} tagPosition="bottom">
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
container.querySelector('.pkt-card__wrapper')?.children || [],
|
|
367
|
+
<PktCard heading="Test Title" tags={tags} tagPosition="bottom">
|
|
368
|
+
innhold
|
|
369
|
+
</PktCard>,
|
|
338
370
|
)
|
|
371
|
+
const wrapperChildren = Array.from(container.querySelector('.pkt-card__wrapper')?.children || [])
|
|
339
372
|
|
|
340
373
|
// Order: header, content, tags (bottom)
|
|
341
374
|
expect(wrapperChildren[0]).toHaveClass('pkt-card__header')
|
|
@@ -353,7 +386,9 @@ describe('PktCard', () => {
|
|
|
353
386
|
|
|
354
387
|
test('applies custom aria-label', () => {
|
|
355
388
|
const { container } = render(
|
|
356
|
-
<PktCard heading="Test" ariaLabel="Custom accessible label">
|
|
389
|
+
<PktCard heading="Test" ariaLabel="Custom accessible label">
|
|
390
|
+
innhold
|
|
391
|
+
</PktCard>,
|
|
357
392
|
)
|
|
358
393
|
const article = container.querySelector('article')
|
|
359
394
|
expect(article?.getAttribute('aria-label')).toBe('Custom accessible label')
|