@oslokommune/punkt-react 19.18.3 → 19.19.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.
@@ -23,6 +23,8 @@ export { CONSENT_TRIGGER_TYPES, CONSENT_TRIGGER_TYPE_OPTIONS, CONSENT_DEFAULTS }
23
23
  export type { TPktConsentTriggerType, IConsentItem, IConsentValue, ICookieConsentEvent, TConsentDetailsMap, TCookieEventHandler, ICookieEvents, ICookieBannerApi, IPktConsentBase, IConsentSpecProps, } from './consent';
24
24
  export { ANIMATION_DEFAULT_PATH, ICON_DEFAULT_PATH, ICON_SIZE_CLASSES, ICON_DEFAULTS } from './icon';
25
25
  export type { TIconSizeClass, IPktIconBase, IIconSpecProps } from './icon';
26
+ export { LOADER_VARIANTS, LOADER_DEFAULTS } from './loader';
27
+ export type { TPktLoaderVariant, IPktLoaderBase, ILoaderSpecProps } from './loader';
26
28
  export { LAYOUT_DIRECTIONS } from './layout';
27
29
  export type { TLayout, TVerticalPosition, THorizontalPosition, TPosition, TPositionWithCenter, } from './layout';
28
30
  export type { THTMLButtonType, TSelectionMode } from './form';
@@ -7,12 +7,13 @@ import { RADIOBUTTON_DEFAULTS as o } from "./radiobutton.js";
7
7
  import { OPTION_GROUP_DEFAULTS as s } from "./option-group.js";
8
8
  import { CONSENT_DEFAULTS as c } from "./consent.js";
9
9
  import { ANIMATION_DEFAULT_PATH as l, ICON_DEFAULTS as u } from "./icon.js";
10
- import { ACCORDION_LIGHT_ONLY_SKINS as d } from "./accordion.js";
11
- import { INPUT_WRAPPER_DEFAULTS as f } from "./input-wrapper.js";
12
- import { TEXTAREA_DEFAULTS as p } from "./textarea.js";
13
- import { MESSAGEBOX_DEFAULTS as m } from "./messagebox.js";
10
+ import { LOADER_DEFAULTS as d } from "./loader.js";
11
+ import { ACCORDION_LIGHT_ONLY_SKINS as f } from "./accordion.js";
12
+ import { INPUT_WRAPPER_DEFAULTS as p } from "./input-wrapper.js";
13
+ import { TEXTAREA_DEFAULTS as m } from "./textarea.js";
14
+ import { MESSAGEBOX_DEFAULTS as h } from "./messagebox.js";
14
15
  import "./calendar.js";
15
16
  import "./combobox.js";
16
- import { SELECT_DEFAULTS as h } from "./select.js";
17
- import { TABLE_DEFAULTS as g } from "./table.js";
18
- export { d as ACCORDION_LIGHT_ONLY_SKINS, l as ANIMATION_DEFAULT_PATH, i as CARD_DEFAULTS, a as CHECKBOX_DEFAULTS, c 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, u as ICON_DEFAULTS, f as INPUT_WRAPPER_DEFAULTS, m as MESSAGEBOX_DEFAULTS, s as OPTION_GROUP_DEFAULTS, o as RADIOBUTTON_DEFAULTS, h as SELECT_DEFAULTS, g as TABLE_DEFAULTS, p as TEXTAREA_DEFAULTS };
17
+ import { SELECT_DEFAULTS as g } from "./select.js";
18
+ import { TABLE_DEFAULTS as _ } from "./table.js";
19
+ export { f as ACCORDION_LIGHT_ONLY_SKINS, l as ANIMATION_DEFAULT_PATH, i as CARD_DEFAULTS, a as CHECKBOX_DEFAULTS, c 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, u as ICON_DEFAULTS, p as INPUT_WRAPPER_DEFAULTS, d as LOADER_DEFAULTS, h as MESSAGEBOX_DEFAULTS, s as OPTION_GROUP_DEFAULTS, o as RADIOBUTTON_DEFAULTS, g as SELECT_DEFAULTS, _ as TABLE_DEFAULTS, m as TEXTAREA_DEFAULTS };
@@ -0,0 +1,48 @@
1
+ import type { TPktSizeBase } from './size';
2
+ /** Loader variants — shared runtime source for types, specs, and Preview. */
3
+ export declare const LOADER_VARIANTS: readonly ['rainbow', 'blue', 'shapes'];
4
+ export type TPktLoaderVariant = (typeof LOADER_VARIANTS)[number];
5
+ export interface IPktLoaderBase {
6
+ /**
7
+ * Tid i millisekunder før loader vises. Nyttig når lastetiden kan være
8
+ * så kort at loader ikke trengs.
9
+ */
10
+ delay?: number;
11
+ /**
12
+ * Vises loader inline eller som blokk.
13
+ */
14
+ inline?: boolean;
15
+ /**
16
+ * Styrer om loader eller barnenoder vises. Når `false` vises barnenoder.
17
+ */
18
+ isLoading?: boolean;
19
+ /**
20
+ * Meldingstekst som vises sammen med loader.
21
+ */
22
+ message?: string | null;
23
+ /**
24
+ * Størrelse på loader. Standard er "medium".
25
+ */
26
+ size?: TPktSizeBase;
27
+ /**
28
+ * Loader-variant. Standard er "rainbow". "shapes" er Oslo-bølgene, "blue" en blå spinner.
29
+ */
30
+ variant?: TPktLoaderVariant;
31
+ /**
32
+ * Overstyrer stien til loader-animasjoner.
33
+ */
34
+ loadingAnimationPath?: string;
35
+ }
36
+ /**
37
+ * Documented Loader props (subset of `IPktLoaderBase`).
38
+ * Used for typed component specs in documentation.
39
+ */
40
+ export type ILoaderSpecProps = Pick<IPktLoaderBase, 'message' | 'size' | 'variant' | 'delay' | 'inline' | 'isLoading' | 'loadingAnimationPath'>;
41
+ export declare const LOADER_DEFAULTS: {
42
+ readonly delay: 0;
43
+ readonly inline: false;
44
+ readonly isLoading: true;
45
+ readonly message: any;
46
+ readonly size: 'medium';
47
+ readonly variant: 'rainbow';
48
+ };
@@ -0,0 +1,11 @@
1
+ //#region ../../shared-types/loader.ts
2
+ var e = {
3
+ delay: 0,
4
+ inline: !1,
5
+ isLoading: !0,
6
+ message: null,
7
+ size: "medium",
8
+ variant: "rainbow"
9
+ };
10
+ //#endregion
11
+ export { e as LOADER_DEFAULTS };
@@ -8,13 +8,14 @@
8
8
  /**
9
9
  * Visual skins for pkt-table — shared runtime source for types, specs, and Preview.
10
10
  */
11
- export declare const TABLE_SKINS: readonly ['basic', 'zebra-blue'];
12
- export type TPktTableSkin = (typeof TABLE_SKINS)[number];
11
+ export declare const TABLE_SKINS: readonly ['basic', 'zebra'];
12
+ export type TPktTableSkin = (typeof TABLE_SKINS)[number] | 'zebra-blue';
13
13
  /**
14
14
  * Table props shared by React and typed component specs.
15
15
  */
16
16
  export interface IPktTableBase {
17
17
  compact?: boolean;
18
+ /** `'zebra-blue'` er deprecated og fjernes i en kommende versjon. Bruk `'zebra'`. */
18
19
  skin?: TPktTableSkin;
19
20
  responsiveView?: boolean;
20
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-react",
3
- "version": "19.18.3",
3
+ "version": "19.19.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": "^19.14.2",
46
- "@oslokommune/punkt-css": "^19.16.2",
45
+ "@oslokommune/punkt-assets": "^19.19.0",
46
+ "@oslokommune/punkt-css": "^19.19.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": "f09029c699dc13de6b5a631caa1616e1a6f36e00"
106
+ "gitHead": "44fc3d8f067708fc6704966219994891e9d5f9b3"
107
107
  }
@@ -2,7 +2,13 @@
2
2
 
3
3
  import classNames from 'classnames'
4
4
  import { forwardRef, HTMLAttributes, ReactNode, useEffect, useState } from 'react'
5
- import { ANIMATION_DEFAULT_PATH, type TPktSizeBase } from 'shared-types'
5
+ import {
6
+ ANIMATION_DEFAULT_PATH,
7
+ LOADER_DEFAULTS,
8
+ type IPktLoaderBase,
9
+ type TPktLoaderVariant,
10
+ type TPktSizeBase,
11
+ } from 'shared-types'
6
12
 
7
13
  import { PktIcon } from '../icon/Icon'
8
14
 
@@ -16,39 +22,10 @@ if (typeof window !== 'undefined') {
16
22
  window.pktAnimationPath = window.pktAnimationPath || ANIMATION_DEFAULT_PATH
17
23
  }
18
24
 
19
- export type TPktLoaderVariant = 'blue' | 'rainbow' | 'shapes'
25
+ export type { TPktLoaderVariant }
20
26
  export type TPktLoaderSize = TPktSizeBase
21
27
 
22
- export interface IPktLoader extends HTMLAttributes<HTMLDivElement> {
23
- /**
24
- * Tid i millisekunder før loader vises. Nyttig når lastetiden kan være
25
- * så kort at loader ikke trengs.
26
- */
27
- delay?: number
28
- /**
29
- * Vises loader inline eller som blokk.
30
- */
31
- inline?: boolean
32
- /**
33
- * Styrer om loader eller barnenoder vises. Når `false` vises barnenoder.
34
- */
35
- isLoading?: boolean
36
- /**
37
- * Meldingstekst som vises sammen med loader.
38
- */
39
- message?: string | null
40
- /**
41
- * Størrelse på loader. Standard er "medium".
42
- */
43
- size?: TPktLoaderSize
44
- /**
45
- * Loader-variant. Standard er "rainbow". "shapes" er Oslo-bølgene, "blue" en blå spinner.
46
- */
47
- variant?: TPktLoaderVariant
48
- /**
49
- * Overstyrer stien til loader-animasjoner.
50
- */
51
- loadingAnimationPath?: string
28
+ export interface IPktLoader extends IPktLoaderBase, HTMLAttributes<HTMLDivElement> {
52
29
  children?: ReactNode
53
30
  }
54
31
 
@@ -65,12 +42,12 @@ const variantIcon = (variant: TPktLoaderVariant): string => {
65
42
 
66
43
  export const PktLoader = forwardRef<HTMLDivElement, IPktLoader>(function PktLoader(
67
44
  {
68
- delay = 0,
69
- inline = false,
70
- isLoading = true,
71
- message = null,
72
- size = 'medium',
73
- variant = 'rainbow',
45
+ delay = LOADER_DEFAULTS.delay,
46
+ inline = LOADER_DEFAULTS.inline,
47
+ isLoading = LOADER_DEFAULTS.isLoading,
48
+ message = LOADER_DEFAULTS.message,
49
+ size = LOADER_DEFAULTS.size,
50
+ variant = LOADER_DEFAULTS.variant,
74
51
  loadingAnimationPath = typeof window !== 'undefined' ? window.pktAnimationPath : ANIMATION_DEFAULT_PATH,
75
52
  className,
76
53
  children,
@@ -24,7 +24,7 @@ export interface IPktStep {
24
24
 
25
25
  const incompleteStepSVG = (
26
26
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none">
27
- <circle cx="12" cy="12" r="7" style={{ fill: 'var(--pkt-color-brand-neutrals-300, #CCC)' }} />
27
+ <circle cx="12" cy="12" r="7" fill="#CCC" />
28
28
  </svg>
29
29
  )
30
30
 
@@ -2,6 +2,7 @@ import '@testing-library/jest-dom'
2
2
 
3
3
  import { render, screen } from '@testing-library/react'
4
4
  import { axe, toHaveNoViolations } from 'jest-axe'
5
+ import { vi } from 'vitest'
5
6
 
6
7
  import { PktTable } from './Table'
7
8
  import { PktTableBody } from './TableBody'
@@ -39,9 +40,9 @@ describe('<PktTable />', () => {
39
40
  expect(screen.getByText('Table data 2')).toBeInTheDocument()
40
41
  })
41
42
 
42
- test('renders correctly with skin "zebra-blue" and compact set to true', () => {
43
+ test('renders correctly with skin "zebra" and compact set to true', () => {
43
44
  render(
44
- <PktTable skin="zebra-blue" compact>
45
+ <PktTable skin="zebra" compact>
45
46
  <PktTableHeader>
46
47
  <PktTableRow>
47
48
  <PktTableHeaderCell>Header 1</PktTableHeaderCell>
@@ -59,6 +60,46 @@ describe('<PktTable />', () => {
59
60
 
60
61
  // Assert that the component applies the props correctly
61
62
  expect(screen.getByTestId('pkt-table')).toHaveClass('pkt-table--compact')
62
- expect(screen.getByTestId('pkt-table')).toHaveClass('pkt-table--zebra-blue')
63
+ expect(screen.getByTestId('pkt-table')).toHaveClass('pkt-table--zebra')
64
+ expect(screen.getByTestId('pkt-table')).not.toHaveClass('pkt-table--zebra-blue')
65
+ })
66
+
67
+ describe('deprecated skin "zebra-blue"', () => {
68
+ afterEach(() => vi.restoreAllMocks())
69
+
70
+ test('renders both the zebra and the zebra-blue class', () => {
71
+ vi.spyOn(console, 'warn').mockImplementation(() => {})
72
+ render(
73
+ <PktTable skin="zebra-blue">
74
+ <PktTableBody>
75
+ <PktTableRow>
76
+ <PktTableDataCell>Table data</PktTableDataCell>
77
+ </PktTableRow>
78
+ </PktTableBody>
79
+ </PktTable>,
80
+ )
81
+
82
+ expect(screen.getByTestId('pkt-table')).toHaveClass('pkt-table--zebra')
83
+ expect(screen.getByTestId('pkt-table')).toHaveClass('pkt-table--zebra-blue')
84
+ })
85
+
86
+ test('warns once, however many tables use it', async () => {
87
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
88
+ vi.resetModules()
89
+ const { PktTable: FreshTable } = await import('./Table')
90
+ render(
91
+ <>
92
+ <FreshTable skin="zebra-blue">
93
+ <tbody />
94
+ </FreshTable>
95
+ <FreshTable skin="zebra-blue">
96
+ <tbody />
97
+ </FreshTable>
98
+ </>,
99
+ )
100
+
101
+ expect(warn).toHaveBeenCalledTimes(1)
102
+ expect(warn).toHaveBeenCalledWith(expect.stringContaining('skin="zebra"'))
103
+ })
63
104
  })
64
105
  })
@@ -9,6 +9,8 @@ export interface IPktTable extends IPktTableBase, HTMLAttributes<HTMLTableElemen
9
9
  children: ReactNode
10
10
  }
11
11
 
12
+ let hasWarnedZebraBlue = false
13
+
12
14
  export const PktTable = ({
13
15
  className,
14
16
  compact = TABLE_DEFAULTS.compact,
@@ -17,6 +19,14 @@ export const PktTable = ({
17
19
  children,
18
20
  ...props
19
21
  }: IPktTable) => {
22
+ if (skin === 'zebra-blue' && !hasWarnedZebraBlue) {
23
+ hasWarnedZebraBlue = true
24
+ // eslint-disable-next-line no-console
25
+ console.warn(
26
+ 'PktTable: skin="zebra-blue" is deprecated and will be removed in a future version. Please use skin="zebra" instead.',
27
+ )
28
+ }
29
+
20
30
  return (
21
31
  <table
22
32
  data-testid="pkt-table"
@@ -24,6 +34,7 @@ export const PktTable = ({
24
34
  'pkt-table--responsive': responsiveView,
25
35
  'pkt-table--compact': compact,
26
36
  'pkt-table--basic': skin === 'basic',
37
+ 'pkt-table--zebra': skin === 'zebra' || skin === 'zebra-blue',
27
38
  'pkt-table--zebra-blue': skin === 'zebra-blue',
28
39
  })}
29
40
  role="table"