@oslokommune/punkt-react 19.2.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.
- package/CHANGELOG.md +5 -0
- package/dist/components/checkbox/Checkbox.d.ts +2 -20
- package/dist/punkt-react.cjs +1 -1
- package/dist/punkt-react.js +546 -535
- package/dist/shared-types/checkbox.d.ts +52 -0
- package/dist/shared-types/index.d.ts +2 -0
- package/package.json +2 -2
- package/src/components/checkbox/Checkbox.tsx +11 -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
|
+
};
|
|
@@ -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.
|
|
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": "
|
|
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
|
|
13
|
+
import { CHECKBOX_DEFAULTS, type IPktCheckboxBase } from 'shared-types'
|
|
14
14
|
|
|
15
|
-
export interface IPktCheckbox
|
|
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 =
|
|
44
|
-
disabled =
|
|
28
|
+
hasTile = CHECKBOX_DEFAULTS.hasTile,
|
|
29
|
+
disabled = CHECKBOX_DEFAULTS.disabled,
|
|
45
30
|
label,
|
|
46
31
|
checkHelptext,
|
|
47
|
-
hasError =
|
|
32
|
+
hasError = CHECKBOX_DEFAULTS.hasError,
|
|
48
33
|
className,
|
|
49
|
-
isSwitch =
|
|
50
|
-
hideLabel =
|
|
51
|
-
labelPosition =
|
|
34
|
+
isSwitch = CHECKBOX_DEFAULTS.isSwitch,
|
|
35
|
+
hideLabel = CHECKBOX_DEFAULTS.hideLabel,
|
|
36
|
+
labelPosition = CHECKBOX_DEFAULTS.labelPosition,
|
|
52
37
|
defaultChecked,
|
|
53
38
|
checked,
|
|
54
39
|
indeterminate,
|