@oslokommune/punkt-react 19.1.0 → 19.3.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.
@@ -17,4 +17,10 @@ export type IAlertSpecProps = {
17
17
  ariaLive?: TAriaLive;
18
18
  size?: TAlertSize;
19
19
  closeAlert?: boolean;
20
+ /** @deprecated Bruk `size` i stedet. Uten eksplisitt `size` gir compact størrelsen 'small'. */
21
+ compact?: boolean;
22
+ };
23
+ /** Default for the deprecated `compact` prop — single source of truth for both frameworks. */
24
+ export declare const ALERT_DEFAULTS: {
25
+ readonly compact: false;
20
26
  };
@@ -0,0 +1,52 @@
1
+ /**
2
+ * checkbox.ts
3
+ *
4
+ * Type definitions for pkt-checkbox.
5
+ * Used by React, Elements, and typed component specs.
6
+ */
7
+ import type { IPktStringsProps } from '../shared-strings';
8
+ import type { IFormFieldErrorProps, IFormFieldLabelProps, ITagOptionalRequiredProps } from './form-field';
9
+ /** Checkbox label placement — shared runtime source for types, specs, and Preview. */
10
+ export declare const CHECKBOX_LABEL_POSITIONS: readonly ['right', 'left'];
11
+ export type TCheckboxLabelPosition = (typeof CHECKBOX_LABEL_POSITIONS)[number];
12
+ /**
13
+ * Checkbox props shared by React and Elements.
14
+ *
15
+ * @remarks React requires `id` and widens `checkHelptext` to `ReactNode`.
16
+ * Elements accepts booleanish strings for `checked`/`indeterminate`.
17
+ */
18
+ export interface IPktCheckboxBase extends IFormFieldLabelProps, Pick<IFormFieldErrorProps, 'disabled' | 'hasError'>, ITagOptionalRequiredProps, IPktStringsProps<'forms'> {
19
+ id?: string;
20
+ name?: string;
21
+ form?: string;
22
+ value?: string;
23
+ checkHelptext?: string;
24
+ defaultChecked?: boolean;
25
+ checked?: boolean;
26
+ indeterminate?: boolean;
27
+ hasTile?: boolean;
28
+ isSwitch?: boolean;
29
+ hideLabel?: boolean;
30
+ labelPosition?: TCheckboxLabelPosition;
31
+ }
32
+ /**
33
+ * Documented Checkbox props (subset of `IPktCheckboxBase`).
34
+ * Used for typed component specs in documentation.
35
+ */
36
+ export type ICheckboxSpecProps = Pick<IPktCheckboxBase, 'label' | 'checkHelptext' | 'name' | 'form' | 'value' | 'id' | 'defaultChecked' | 'checked' | 'indeterminate' | 'hasTile' | 'disabled' | 'hasError' | 'isSwitch' | 'labelPosition' | 'hideLabel' | 'requiredTag' | 'requiredText' | 'optionalTag' | 'optionalText' | 'tagText'>;
37
+ /**
38
+ * Default values for pkt-checkbox. Single source of truth for both frameworks.
39
+ * `checked` is intentionally absent — React must keep it `undefined` to stay uncontrolled.
40
+ */
41
+ export declare const CHECKBOX_DEFAULTS: {
42
+ readonly defaultChecked: false;
43
+ readonly indeterminate: false;
44
+ readonly hasTile: false;
45
+ readonly disabled: false;
46
+ readonly hasError: false;
47
+ readonly isSwitch: false;
48
+ readonly hideLabel: false;
49
+ readonly labelPosition: 'right';
50
+ readonly requiredTag: false;
51
+ readonly optionalTag: false;
52
+ };
@@ -89,17 +89,29 @@ export interface IPktFooterProps<IconType = string> extends IPktFooterBase<IconT
89
89
  export interface IPktFooterSimpleProps<IconType = string> extends IPktFooterBase<IconType> {
90
90
  /** Custom links shown as a compact row in the secondary (grey) footer. */
91
91
  links?: IPktFooterLink[];
92
+ /**
93
+ * @deprecated The privacy link now comes from the global footer's payload.
94
+ * Only rendered (in the secondary footer) when explicitly set to a
95
+ * non-default value.
96
+ */
97
+ personvernOgInfoLink?: string;
98
+ /**
99
+ * @deprecated The accessibility link now comes from the global footer's
100
+ * payload. Only rendered (in the secondary footer) when explicitly set
101
+ * to a non-default value.
102
+ */
103
+ tilgjengelighetLink?: string;
92
104
  }
93
105
  /**
94
106
  * Documented FooterSimple props (subset of `IPktFooterSimpleProps`).
95
107
  * Used for typed component specs in documentation.
96
108
  */
97
- export type IFooterSimpleSpecProps = Pick<IPktFooterSimpleProps, 'links' | 'skipGlobal' | 'data' | 'dataUrl' | 'locale' | 'openLinksInNewTab' | 'includeConsent' | 'googleAnalyticsId' | 'hotjarId'>;
109
+ export type IFooterSimpleSpecProps = Pick<IPktFooterSimpleProps, 'links' | 'skipGlobal' | 'data' | 'dataUrl' | 'locale' | 'openLinksInNewTab' | 'includeConsent' | 'googleAnalyticsId' | 'hotjarId' | 'personvernOgInfoLink' | 'tilgjengelighetLink'>;
98
110
  /**
99
111
  * Documented Footer props (subset of `IPktFooterProps`).
100
112
  * Used for typed component specs in documentation.
101
113
  */
102
- export type IFooterSpecProps = Pick<IPktFooterProps, 'columns' | 'skipGlobal' | 'data' | 'dataUrl' | 'locale' | 'openLinksInNewTab' | 'includeConsent' | 'googleAnalyticsId' | 'hotjarId'>;
114
+ export type IFooterSpecProps = Pick<IPktFooterProps, 'columns' | 'skipGlobal' | 'data' | 'dataUrl' | 'locale' | 'openLinksInNewTab' | 'includeConsent' | 'googleAnalyticsId' | 'hotjarId' | 'columnOne' | 'columnTwo' | 'personvernOgInfoLink' | 'tilgjengelighetLink' | 'socialLinks'>;
103
115
  /** Historical defaults for the deprecated link props — used to detect explicit overrides. */
104
116
  export declare const DEFAULT_FOOTER_PERSONVERN_URL = "https://www.oslo.kommune.no/personvern-og-informasjonskapsler/";
105
117
  export declare const DEFAULT_FOOTER_TILGJENGELIGHET_URL = "https://www.oslo.kommune.no/tilgjengelighet/";
@@ -1,7 +1,7 @@
1
1
  export type { Booleanish } from './booleanish';
2
2
  export { booleanishConverter, nullableBooleanishConverter } from './booleanish';
3
3
  export { ARIA_LIVE_VALUES, type TAriaBoolean, type TAriaBooleanMixed, type TAriaCurrent, type TAriaHasPopup, type TAriaInvalid, type TAriaLive, type TAriaRelevant, type TAriaSort, type TAriaAutoComplete, type TAriaOrientation, type IAriaAttributes, type TAlertRole, } from './aria';
4
- export { ALERT_SKINS, ALERT_SIZES, type TAlertSkin, type TAlertSize, type IAlertSpecProps, } from './alert';
4
+ export { ALERT_SKINS, ALERT_SIZES, ALERT_DEFAULTS, type TAlertSkin, type TAlertSize, type IAlertSpecProps, } from './alert';
5
5
  export type { THeadingLevel, THeadingSize, THeadingWeight } from './heading';
6
6
  export type { User, Representing, UserMenuItem, InternalMenuItemBase, InternalMenuLink, InternalMenuButton, TInternalMenuItem, TSlotMenuVariant, THeaderMenu, TLogOutButtonPlacement, THeaderPosition, THeaderScrollBehavior, } from './header';
7
7
  export { convertUserMenuItem } from './header';
@@ -11,6 +11,8 @@ export type { IPktFooterLink, IPktFooterColumn, IPktFooterSocialLink, IPktFooter
11
11
  export { DEFAULT_FOOTER_PERSONVERN_URL, DEFAULT_FOOTER_TILGJENGELIGHET_URL } from './footer';
12
12
  export { CARD_SKINS, CARD_PADDINGS, CARD_IMAGE_SHAPES, CARD_IMAGE_ASPECTS, CARD_TAG_POSITIONS, CARD_TAG_SKIN_OPTIONS, CARD_DEFAULTS } from './card';
13
13
  export type { TCardSkin, TCardPadding, TCardImageShape, TCardImageAspect, TCardTagPosition, ICardTag, ICardImage, IPktCardBase, ICardSpecProps, } from './card';
14
+ export { CHECKBOX_LABEL_POSITIONS, CHECKBOX_DEFAULTS } from './checkbox';
15
+ export type { TCheckboxLabelPosition, IPktCheckboxBase, ICheckboxSpecProps } from './checkbox';
14
16
  export { LAYOUT_DIRECTIONS } from './layout';
15
17
  export type { TLayout, TVerticalPosition, THorizontalPosition, TPosition, TPositionWithCenter, } from './layout';
16
18
  export type { THTMLButtonType, TSelectionMode } from './form';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-react",
3
- "version": "19.1.0",
3
+ "version": "19.3.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": "bd527643a5ec58336f592a065ba7d7037d8597be"
104
+ "gitHead": "bad204d129d7788ce278eb48ba697806a86babe4"
105
105
  }
@@ -10,29 +10,14 @@ import {
10
10
  } from 'react'
11
11
  import { usePktStrings } from '../../hooks/usePktStrings'
12
12
  import { useGeneratedId } from '../../hooks/useGeneratedId'
13
- import type { IPktStringsProps } from 'shared-strings'
13
+ import { CHECKBOX_DEFAULTS, type IPktCheckboxBase } from 'shared-types'
14
14
 
15
- export interface IPktCheckbox extends InputHTMLAttributes<HTMLInputElement>, IPktStringsProps<'forms'> {
15
+ export interface IPktCheckbox
16
+ extends
17
+ Omit<IPktCheckboxBase, 'id' | 'checkHelptext'>,
18
+ Omit<InputHTMLAttributes<HTMLInputElement>, keyof IPktCheckboxBase> {
16
19
  id: string
17
- hasTile?: boolean
18
- disabled?: boolean
19
- label?: string
20
20
  checkHelptext?: ReactNode | ReactNode[] | string
21
- hasError?: boolean
22
- defaultChecked?: boolean
23
- checked?: boolean
24
- indeterminate?: boolean
25
- value?: string
26
- isSwitch?: boolean
27
- hideLabel?: boolean
28
- labelPosition?: 'right' | 'left'
29
- optionalTag?: boolean
30
- /** @deprecated Bruk `strings={{ forms: { optional: '…' } }}` eller `setPktStrings()`. */
31
- optionalText?: string
32
- requiredTag?: boolean
33
- /** @deprecated Bruk `strings={{ forms: { required: '…' } }}` eller `setPktStrings()`. */
34
- requiredText?: string
35
- tagText?: string | null
36
21
  onChange?: ChangeEventHandler<HTMLInputElement>
37
22
  }
38
23
 
@@ -40,15 +25,15 @@ export const PktCheckbox = forwardRef(
40
25
  (
41
26
  {
42
27
  id: idProp,
43
- hasTile = false,
44
- disabled = false,
28
+ hasTile = CHECKBOX_DEFAULTS.hasTile,
29
+ disabled = CHECKBOX_DEFAULTS.disabled,
45
30
  label,
46
31
  checkHelptext,
47
- hasError = false,
32
+ hasError = CHECKBOX_DEFAULTS.hasError,
48
33
  className,
49
- isSwitch = false,
50
- hideLabel = false,
51
- labelPosition = 'right',
34
+ isSwitch = CHECKBOX_DEFAULTS.isSwitch,
35
+ hideLabel = CHECKBOX_DEFAULTS.hideLabel,
36
+ labelPosition = CHECKBOX_DEFAULTS.labelPosition,
52
37
  defaultChecked,
53
38
  checked,
54
39
  indeterminate,
@@ -16,18 +16,6 @@ import { FooterGlobal, useGlobalFooterData, type TFooterConsentConfig } from '..
16
16
  export interface IPktFooterSimple
17
17
  extends IPktFooterSimpleProps<string>, TFooterConsentConfig, Omit<HTMLAttributes<HTMLElement>, 'children'> {
18
18
  onDataError?: (error: Error) => void
19
- /**
20
- * @deprecated The privacy link now comes from the global footer's payload.
21
- * Only rendered (in the secondary footer) when explicitly set to a
22
- * non-default value.
23
- */
24
- personvernOgInfoLink?: string
25
- /**
26
- * @deprecated The accessibility link now comes from the global footer's
27
- * payload. Only rendered (in the secondary footer) when explicitly set
28
- * to a non-default value.
29
- */
30
- tilgjengelighetLink?: string
31
19
  }
32
20
 
33
21
  const SimpleLink: FC<{ link: IPktFooterLink; openLinksInNewTab: boolean }> = ({ link, openLinksInNewTab }) => {