@oslokommune/punkt-react 19.9.1 → 19.10.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.
@@ -13,6 +13,8 @@ export { CARD_SKINS, CARD_PADDINGS, CARD_IMAGE_SHAPES, CARD_IMAGE_ASPECTS, CARD_
13
13
  export type { TCardSkin, TCardPadding, TCardImageShape, TCardImageAspect, TCardTagPosition, ICardTag, ICardImage, IPktCardBase, ICardSpecProps, } from './card';
14
14
  export { CHECKBOX_LABEL_POSITIONS, CHECKBOX_DEFAULTS } from './checkbox';
15
15
  export type { TCheckboxLabelPosition, IPktCheckboxBase, ICheckboxSpecProps } from './checkbox';
16
+ export { RADIOBUTTON_DEFAULTS } from './radiobutton';
17
+ export type { IPktRadioButtonBase, IRadioButtonSpecProps } from './radiobutton';
16
18
  export { OPTION_GROUP_DEFAULTS } from './option-group';
17
19
  export type { IPktOptionGroupBase, IPktRadioGroupBase, IPktCheckboxGroupBase, IRadioGroupSpecProps, ICheckboxGroupSpecProps, } from './option-group';
18
20
  export { CONSENT_TRIGGER_TYPES, CONSENT_TRIGGER_TYPE_OPTIONS, CONSENT_DEFAULTS } from './consent';
@@ -0,0 +1,46 @@
1
+ /**
2
+ * radiobutton.ts
3
+ *
4
+ * Type definitions for pkt-radiobutton.
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
+ import type { TPktInputSize } from './size';
10
+ /**
11
+ * Radio button props shared by React and Elements.
12
+ *
13
+ * @remarks React requires `id`, `name` and `label`, and widens `checkHelptext` to `ReactNode`.
14
+ * Elements widens `label` and `checkHelptext` to `| null` (Lit uses `null` for an unset
15
+ * attribute), accepts booleanish strings for `checked`, and omits `form`, which is a getter
16
+ * returning the associated `HTMLFormElement`, not the form id.
17
+ */
18
+ export interface IPktRadioButtonBase 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
+ hasTile?: boolean;
27
+ inputSize?: TPktInputSize;
28
+ }
29
+ /**
30
+ * Documented RadioButton props (subset of `IPktRadioButtonBase`).
31
+ * Used for typed component specs in documentation.
32
+ */
33
+ export type IRadioButtonSpecProps = Pick<IPktRadioButtonBase, 'id' | 'name' | 'form' | 'label' | 'checked' | 'defaultChecked' | 'hasTile' | 'inputSize' | 'disabled' | 'checkHelptext' | 'value' | 'hasError' | 'requiredTag' | 'requiredText' | 'optionalTag' | 'optionalText' | 'tagText'>;
34
+ /**
35
+ * Default values for pkt-radiobutton. Single source of truth for both frameworks.
36
+ * `checked` is intentionally absent — React must keep it `undefined` to stay uncontrolled.
37
+ * `inputSize` is intentionally absent — unset inherits the size from the surrounding input-wrapper.
38
+ */
39
+ export declare const RADIOBUTTON_DEFAULTS: {
40
+ readonly defaultChecked: false;
41
+ readonly hasTile: false;
42
+ readonly disabled: false;
43
+ readonly hasError: false;
44
+ readonly requiredTag: false;
45
+ readonly optionalTag: false;
46
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-react",
3
- "version": "19.9.1",
3
+ "version": "19.10.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": "c6f5dcb88eab44820e4f1610fe79a2756d098e2b"
104
+ "gitHead": "e7b45bcbcce849fbbb59cc06934a1cb57ae7473a"
105
105
  }
@@ -15,9 +15,7 @@ import { CHECKBOX_DEFAULTS, type IPktCheckboxBase } from 'shared-types'
15
15
  import { useCheckboxGroupContext } from '../checkboxgroup/CheckboxGroupContext'
16
16
 
17
17
  export interface IPktCheckbox
18
- extends
19
- Omit<IPktCheckboxBase, 'id' | 'checkHelptext'>,
20
- Omit<InputHTMLAttributes<HTMLInputElement>, keyof IPktCheckboxBase> {
18
+ extends Omit<IPktCheckboxBase, 'checkHelptext'>, Omit<InputHTMLAttributes<HTMLInputElement>, keyof IPktCheckboxBase> {
21
19
  id: string
22
20
  checkHelptext?: ReactNode | ReactNode[] | string
23
21
  onChange?: ChangeEventHandler<HTMLInputElement>
@@ -10,29 +10,16 @@ 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'
14
- import type { TPktInputSize } from 'shared-types'
13
+ import { RADIOBUTTON_DEFAULTS, type IPktRadioButtonBase } from 'shared-types'
15
14
  import { useRadioGroupContext } from '../radiogroup/RadioGroupContext'
16
15
 
17
- export interface IPktRadioButton extends InputHTMLAttributes<HTMLInputElement>, IPktStringsProps<'forms'> {
16
+ export interface IPktRadioButton
17
+ extends
18
+ Omit<IPktRadioButtonBase, 'checkHelptext'>,
19
+ Omit<InputHTMLAttributes<HTMLInputElement>, keyof IPktRadioButtonBase> {
18
20
  id: string
19
- name?: string
20
21
  label: string
21
- hasTile?: boolean
22
- inputSize?: TPktInputSize
23
- disabled?: boolean
24
22
  checkHelptext?: ReactNode | ReactNode[] | string
25
- defaultChecked?: boolean
26
- checked?: boolean
27
- hasError?: boolean
28
- value?: string
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
23
  onChange?: ChangeEventHandler<HTMLInputElement>
37
24
  }
38
25
 
@@ -43,11 +30,11 @@ export const PktRadioButton = forwardRef(
43
30
  name,
44
31
  label,
45
32
  className,
46
- hasTile = false,
33
+ hasTile = RADIOBUTTON_DEFAULTS.hasTile,
47
34
  inputSize,
48
- disabled = false,
35
+ disabled = RADIOBUTTON_DEFAULTS.disabled,
49
36
  checkHelptext,
50
- hasError = false,
37
+ hasError = RADIOBUTTON_DEFAULTS.hasError,
51
38
  defaultChecked,
52
39
  checked,
53
40
  optionalTag,