@oslokommune/punkt-react 19.7.0 → 19.8.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.
@@ -34,7 +34,9 @@ export type { TBreadcrumbsNavigationType, IBreadcrumb, IBreadcrumbItem, IBreadcr
34
34
  export type { IRenderLink, TRenderLink } from './render-link';
35
35
  export type { IPktStringsProps } from '../shared-strings';
36
36
  export type { IHelptextProps, ITagOptionalRequiredProps, IFormFieldLabelProps, IFormFieldErrorProps, IFormFieldCommonProps, TFormFieldCommonSpecKeys, } from './form-field';
37
- export type { TMessageboxSkin, TTagSkin } from './skin';
37
+ export type { TTagSkin } from './skin';
38
+ export { MESSAGEBOX_SKINS, MESSAGEBOX_DEFAULTS } from './messagebox';
39
+ export type { TMessageboxSkin, IPktMessageboxBase, IMessageboxSpecProps } from './messagebox';
38
40
  export { CALENDAR_DEFAULTS } from './calendar';
39
41
  export type { IPktCalendarBase, ICalendarSpecProps, IDateConstraints, ICalendarGridDimensions, IGridCellPosition, TDateRangeMap, ISelectionState, ISelectionOptions, } from './calendar';
40
42
  export type { IDatepickerStrings } from './datepicker';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * messagebox.ts
3
+ *
4
+ * Type definitions for pkt-messagebox.
5
+ * Used by React, Elements, and typed component specs.
6
+ */
7
+ /** Messagebox skin variants — shared runtime source for types, specs, and Preview. */
8
+ export declare const MESSAGEBOX_SKINS: readonly ['beige', 'blue', 'red', 'green'];
9
+ export type TMessageboxSkin = (typeof MESSAGEBOX_SKINS)[number];
10
+ /**
11
+ * Messagebox props shared by React and Elements.
12
+ *
13
+ * @remarks React widens `title` to `ReactNode` and adds `onClose`.
14
+ * Elements dispatches a `close` event instead (and `on-close` for legacy Vue setups).
15
+ */
16
+ export interface IPktMessageboxBase {
17
+ skin?: TMessageboxSkin;
18
+ title?: string;
19
+ compact?: boolean;
20
+ closable?: boolean;
21
+ }
22
+ /**
23
+ * Documented Messagebox props (subset of `IPktMessageboxBase`).
24
+ * Used for typed component specs in documentation.
25
+ */
26
+ export type IMessageboxSpecProps = Pick<IPktMessageboxBase, 'title' | 'skin' | 'compact' | 'closable'>;
27
+ /** Default values for pkt-messagebox. Single source of truth for both frameworks. */
28
+ export declare const MESSAGEBOX_DEFAULTS: {
29
+ readonly skin: 'beige';
30
+ readonly compact: false;
31
+ readonly closable: false;
32
+ };
@@ -8,10 +8,7 @@
8
8
  export { ALERT_SKINS, type TAlertSkin } from './alert';
9
9
  export { ACCORDION_SKINS, type TAccordionSkin } from './accordion';
10
10
  export { CARD_SKINS, type TCardSkin } from './card';
11
- /**
12
- * Messagebox component skin variants
13
- */
14
- export type TMessageboxSkin = 'beige' | 'blue' | 'red' | 'green';
11
+ export { MESSAGEBOX_SKINS, type TMessageboxSkin } from './messagebox';
15
12
  /**
16
13
  * Tag component skin variants
17
14
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-react",
3
- "version": "19.7.0",
3
+ "version": "19.8.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",
@@ -101,5 +101,5 @@
101
101
  "url": "https://github.com/oslokommune/punkt/issues"
102
102
  },
103
103
  "license": "MIT",
104
- "gitHead": "f5f319f536d0fcbd3943ed6e191d887112e3c192"
104
+ "gitHead": "aac1152f60412d31e67493d4813afebe5dcea8bb"
105
105
  }
@@ -13,7 +13,7 @@ describe('Messagebox', () => {
13
13
  it('render with defaults', async () => {
14
14
  const { messageBox } = render(<PktMessagebox />)
15
15
 
16
- expect(messageBox.className).toEqual('pkt-messagebox')
16
+ expect(messageBox.className).toEqual('pkt-messagebox pkt-messagebox--beige')
17
17
  })
18
18
 
19
19
  it('render with skin', async () => {
@@ -3,28 +3,29 @@
3
3
  import classNames from 'classnames'
4
4
  import { createRef, FC, HTMLAttributes, ReactNode, useCallback, useState } from 'react'
5
5
  import type { IPktStringsProps } from 'shared-strings'
6
- import type { TMessageboxSkin } from 'shared-types'
6
+ import { MESSAGEBOX_DEFAULTS, type IPktMessageboxBase, type TMessageboxSkin } from 'shared-types'
7
7
 
8
8
  import { usePktStrings } from '../../hooks/usePktStrings'
9
9
  import { PktIcon } from '../icon/Icon'
10
10
 
11
11
  export type { TMessageboxSkin }
12
12
 
13
- export interface IPktMessagebox extends Omit<HTMLAttributes<HTMLDivElement>, 'title'>, IPktStringsProps<'generic'> {
14
- skin?: TMessageboxSkin
13
+ export interface IPktMessagebox
14
+ extends
15
+ Omit<IPktMessageboxBase, 'title'>,
16
+ Omit<HTMLAttributes<HTMLDivElement>, 'title'>,
17
+ IPktStringsProps<'generic'> {
15
18
  title?: ReactNode
16
- compact?: boolean
17
- closable?: boolean
18
19
  onClose?: () => void
19
20
  }
20
21
 
21
22
  export const PktMessagebox: FC<IPktMessagebox> = ({
22
23
  children,
23
24
  className,
24
- skin,
25
+ skin = MESSAGEBOX_DEFAULTS.skin,
25
26
  title,
26
- compact,
27
- closable,
27
+ compact = MESSAGEBOX_DEFAULTS.compact,
28
+ closable = MESSAGEBOX_DEFAULTS.closable,
28
29
  onClose,
29
30
  strings,
30
31
  ...props