@oslokommune/punkt-react 18.0.0 → 18.2.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 +34 -0
- package/dist/components/accordion/Accordion.d.ts +2 -12
- package/dist/components/accordion/AccordionItem.d.ts +2 -8
- package/dist/components/alert/Alert.d.ts +4 -3
- package/dist/components/backlink/BackLink.d.ts +3 -13
- package/dist/components/breadcrumbs/Breadcrumbs.d.ts +7 -16
- package/dist/components/calendar/types.d.ts +2 -4
- package/dist/components/checkbox/Checkbox.d.ts +2 -4
- package/dist/components/combobox/types.d.ts +3 -5
- package/dist/components/datepicker/DateTags.d.ts +2 -3
- package/dist/components/datepicker/types.d.ts +4 -5
- package/dist/components/fileupload/DropZone.d.ts +2 -4
- package/dist/components/fileupload/FileUpload.d.ts +9 -64
- package/dist/components/header/types.d.ts +3 -7
- package/dist/components/index.d.ts +1 -1
- package/dist/components/inputwrapper/InputWrapper.d.ts +2 -4
- package/dist/components/link/Link.d.ts +2 -6
- package/dist/components/radio/RadioButton.d.ts +2 -4
- package/dist/components/searchinput/SearchInput.d.ts +2 -4
- package/dist/components/select/Select.d.ts +2 -4
- package/dist/components/tag/Tag.d.ts +2 -4
- package/dist/components/textarea/Textarea.d.ts +2 -4
- package/dist/components/textinput/Textinput.d.ts +2 -4
- package/dist/components/timepicker/types.d.ts +2 -5
- package/dist/components/timepicker/useTimepickerState.d.ts +1 -1
- package/dist/punkt-react.cjs +1 -1
- package/dist/punkt-react.js +1208 -1203
- package/dist/shared-strings/index.d.ts +1 -1
- package/dist/shared-strings/nb.d.ts +3 -0
- package/dist/shared-strings/types.d.ts +17 -0
- package/dist/shared-types/accordion.d.ts +58 -0
- package/dist/shared-types/alert.d.ts +20 -0
- package/dist/shared-types/aria.d.ts +2 -1
- package/dist/shared-types/backlink.d.ts +23 -0
- package/dist/shared-types/breadcrumbs.d.ts +33 -0
- package/dist/shared-types/fileupload.d.ts +56 -2
- package/dist/shared-types/footer.d.ts +10 -0
- package/dist/shared-types/form-field.d.ts +46 -0
- package/dist/shared-types/header-footer.d.ts +2 -0
- package/dist/shared-types/index.d.ts +15 -5
- package/dist/shared-types/render-link.d.ts +22 -0
- package/dist/shared-types/searchinput.d.ts +2 -1
- package/dist/shared-types/skin.d.ts +2 -9
- package/package.json +2 -2
- package/src/components/accordion/Accordion.tsx +2 -12
- package/src/components/accordion/AccordionItem.tsx +2 -8
- package/src/components/alert/Alert.tsx +12 -5
- package/src/components/backlink/BackLink.tsx +7 -16
- package/src/components/breadcrumbs/Breadcrumbs.tsx +14 -16
- package/src/components/calendar/types.ts +2 -6
- package/src/components/checkbox/Checkbox.tsx +2 -4
- package/src/components/combobox/types.ts +3 -5
- package/src/components/datepicker/DateTags.tsx +2 -4
- package/src/components/datepicker/types.ts +6 -7
- package/src/components/fileupload/DropZone.tsx +3 -4
- package/src/components/fileupload/FileUpload.tsx +25 -68
- package/src/components/header/types.ts +3 -8
- package/src/components/index.ts +1 -1
- package/src/components/inputwrapper/InputWrapper.tsx +2 -4
- package/src/components/link/Link.tsx +2 -6
- package/src/components/radio/RadioButton.tsx +2 -4
- package/src/components/searchinput/SearchInput.tsx +2 -5
- package/src/components/select/Select.tsx +3 -4
- package/src/components/tag/Tag.tsx +2 -5
- package/src/components/textarea/Textarea.tsx +3 -4
- package/src/components/textinput/Textinput.tsx +3 -4
- package/src/components/timepicker/types.ts +2 -6
|
@@ -2,28 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
import { ForwardedRef, forwardRef, type AnchorHTMLAttributes, type ReactNode } from 'react'
|
|
4
4
|
import { Link } from 'react-router-dom'
|
|
5
|
+
import type {
|
|
6
|
+
IBreadcrumb,
|
|
7
|
+
IPktBreadcrumbsBase,
|
|
8
|
+
TBreadcrumbsNavigationType,
|
|
9
|
+
TRenderLink,
|
|
10
|
+
} from 'shared-types'
|
|
5
11
|
|
|
6
12
|
import { PktIcon } from '../icon/Icon'
|
|
7
13
|
import { usePktStrings } from '../../hooks/usePktStrings'
|
|
8
|
-
import type { TPktStringsOverride } from 'shared-strings'
|
|
9
14
|
|
|
10
|
-
export
|
|
11
|
-
text: string
|
|
12
|
-
href: string
|
|
13
|
-
}
|
|
15
|
+
export type { IBreadcrumb }
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
strings?: TPktStringsOverride
|
|
17
|
+
/** @deprecated Use `IBreadcrumb`. */
|
|
18
|
+
export type IBreadcrumbs = IBreadcrumb
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
children: ReactNode
|
|
25
|
-
props: AnchorHTMLAttributes<HTMLAnchorElement>
|
|
26
|
-
}) => ReactNode
|
|
20
|
+
export interface IPktBreadcrumbs
|
|
21
|
+
extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'children'>,
|
|
22
|
+
IPktBreadcrumbsBase {
|
|
23
|
+
navigationType?: TBreadcrumbsNavigationType
|
|
24
|
+
renderLink?: TRenderLink<ReactNode, AnchorHTMLAttributes<HTMLAnchorElement>>
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
export const PktBreadcrumbs = forwardRef(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IDateConstraints, TDateRangeMap } from 'shared-types/calendar'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { IPktStringsProps } from 'shared-strings'
|
|
4
4
|
|
|
5
5
|
/** Datonavn og navigasjonstekster slik kalender-underkomponentene forventer dem. */
|
|
6
6
|
export interface IPktCalendarStrings {
|
|
@@ -23,7 +23,7 @@ export interface PktCalendarHandle {
|
|
|
23
23
|
close: () => void
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export interface IPktCalendar {
|
|
26
|
+
export interface IPktCalendar extends IPktStringsProps<'dates' | 'calendar'> {
|
|
27
27
|
// Selection
|
|
28
28
|
selected?: string[]
|
|
29
29
|
multiple?: boolean
|
|
@@ -42,10 +42,6 @@ export interface IPktCalendar {
|
|
|
42
42
|
currentmonth?: Date | string | null
|
|
43
43
|
today?: string
|
|
44
44
|
|
|
45
|
-
// Localization
|
|
46
|
-
/** Overstyrer tekster for denne komponenten. */
|
|
47
|
-
strings?: TPktStringsOverride
|
|
48
|
-
|
|
49
45
|
// Callbacks
|
|
50
46
|
onDateSelected?: (selected: string[]) => void
|
|
51
47
|
onClose?: () => void
|
|
@@ -9,9 +9,9 @@ import {
|
|
|
9
9
|
useRef,
|
|
10
10
|
} from 'react'
|
|
11
11
|
import { usePktStrings } from '../../hooks/usePktStrings'
|
|
12
|
-
import type {
|
|
12
|
+
import type { IPktStringsProps } from 'shared-strings'
|
|
13
13
|
|
|
14
|
-
export interface IPktCheckbox extends InputHTMLAttributes<HTMLInputElement> {
|
|
14
|
+
export interface IPktCheckbox extends InputHTMLAttributes<HTMLInputElement>, IPktStringsProps<'forms'> {
|
|
15
15
|
id: string
|
|
16
16
|
hasTile?: boolean
|
|
17
17
|
disabled?: boolean
|
|
@@ -31,8 +31,6 @@ export interface IPktCheckbox extends InputHTMLAttributes<HTMLInputElement> {
|
|
|
31
31
|
requiredTag?: boolean
|
|
32
32
|
/** @deprecated Bruk `strings={{ forms: { required: '…' } }}` eller `setPktStrings()`. */
|
|
33
33
|
requiredText?: string
|
|
34
|
-
/** Overstyrer tekster for denne komponenten. */
|
|
35
|
-
strings?: TPktStringsOverride
|
|
36
34
|
tagText?: string | null
|
|
37
35
|
onChange?: ChangeEventHandler<HTMLInputElement>
|
|
38
36
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import type { TPktStringsOverride } from 'shared-strings'
|
|
3
|
+
import type { IPktStringsProps, TPktStringsOverride } from 'shared-strings'
|
|
4
4
|
|
|
5
5
|
import type {
|
|
6
6
|
ChangeEvent,
|
|
@@ -14,7 +14,7 @@ import type {
|
|
|
14
14
|
} from 'react'
|
|
15
15
|
import type { IPktComboboxOption, TPktComboboxDisplayValue, TPktComboboxTagPlacement } from 'shared-types/combobox'
|
|
16
16
|
|
|
17
|
-
export interface IPktCombobox {
|
|
17
|
+
export interface IPktCombobox extends IPktStringsProps<'combobox' | 'listbox' | 'forms' | 'validation'> {
|
|
18
18
|
// Values & options
|
|
19
19
|
value?: string | string[]
|
|
20
20
|
defaultValue?: string | string[]
|
|
@@ -54,8 +54,6 @@ export interface IPktCombobox {
|
|
|
54
54
|
useWrapper?: boolean
|
|
55
55
|
inline?: boolean
|
|
56
56
|
counter?: boolean
|
|
57
|
-
/** Overstyrer tekster for denne komponenten. */
|
|
58
|
-
strings?: TPktStringsOverride
|
|
59
57
|
hasFieldset?: boolean
|
|
60
58
|
inputSize?: 'small' | 'medium' | 'xsmall'
|
|
61
59
|
|
|
@@ -70,7 +68,7 @@ export interface IPktCombobox {
|
|
|
70
68
|
|
|
71
69
|
export interface IComboboxState {
|
|
72
70
|
/** Tekstoverstyring sendt inn på komponenten. */
|
|
73
|
-
strings?: TPktStringsOverride
|
|
71
|
+
strings?: TPktStringsOverride<'combobox' | 'listbox' | 'forms' | 'validation'>
|
|
74
72
|
// Identity
|
|
75
73
|
id: string
|
|
76
74
|
inputId: string
|
|
@@ -3,16 +3,14 @@
|
|
|
3
3
|
import { sortDateStrings, fromISOtoLocal } from 'shared-utils/date-utils'
|
|
4
4
|
import { PktTag } from '../tag/Tag'
|
|
5
5
|
import { usePktStrings } from '../../hooks/usePktStrings'
|
|
6
|
-
import type {
|
|
6
|
+
import type { IPktStringsProps } from 'shared-strings'
|
|
7
7
|
|
|
8
|
-
interface DateTagsProps {
|
|
8
|
+
interface DateTagsProps extends IPktStringsProps<'datepicker'> {
|
|
9
9
|
dates: string[]
|
|
10
10
|
dateformat: string
|
|
11
11
|
idBase: string
|
|
12
|
-
strings?: TPktStringsOverride
|
|
13
12
|
onDateRemoved: (date: string) => void
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
export const DateTags = ({
|
|
17
15
|
dates,
|
|
18
16
|
dateformat,
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import type { TPktStrings, TPktStringsOverride } from 'shared-strings'
|
|
1
|
+
import type { TPktStrings, IPktStringsProps, TPktStringsOverride } from 'shared-strings'
|
|
2
2
|
import type { ChangeEvent, InputHTMLAttributes, ReactNode } from 'react'
|
|
3
3
|
import type { TPktInputSize } from 'shared-types/size'
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export type TDatepickerStrings = 'generic' | 'datepicker' | 'validation' | 'forms' | 'dates' | 'calendar'
|
|
6
|
+
|
|
7
|
+
export interface IPktDatepicker
|
|
8
|
+
extends Omit<InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange'>, IPktStringsProps<TDatepickerStrings> {
|
|
6
9
|
id: string
|
|
7
10
|
label: string
|
|
8
11
|
ariaDescribedby?: string
|
|
@@ -41,10 +44,6 @@ export interface IPktDatepicker extends Omit<InputHTMLAttributes<HTMLInputElemen
|
|
|
41
44
|
tagText?: string
|
|
42
45
|
useWrapper?: boolean
|
|
43
46
|
|
|
44
|
-
// Localization
|
|
45
|
-
/** Overstyrer tekster for denne komponenten. */
|
|
46
|
-
strings?: TPktStringsOverride
|
|
47
|
-
|
|
48
47
|
// Events
|
|
49
48
|
onChange?: (e: ChangeEvent<HTMLInputElement>) => void
|
|
50
49
|
onValueChange?: (values: string[]) => void
|
|
@@ -106,7 +105,7 @@ export interface IDatepickerState {
|
|
|
106
105
|
isIOSDevice: boolean
|
|
107
106
|
strings: Pick<TPktStrings, 'generic' | 'datepicker' | 'validation'>
|
|
108
107
|
/** Rå tekstoverstyring, til videresending til underkomponenter. */
|
|
109
|
-
stringsOverride?: TPktStringsOverride
|
|
108
|
+
stringsOverride?: TPktStringsOverride<TDatepickerStrings>
|
|
110
109
|
inputClasses: string
|
|
111
110
|
buttonClasses: string
|
|
112
111
|
rangeLabelClasses: string
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import { PktIcon } from '../icon/Icon'
|
|
17
17
|
import { FileItem, TFileItemList, TUploadStrategy } from './types'
|
|
18
18
|
import { usePktStrings } from '../../hooks/usePktStrings'
|
|
19
|
-
import type {
|
|
19
|
+
import type { IPktStringsProps } from 'shared-strings'
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Props for the internal `DropZone` building block.
|
|
@@ -27,9 +27,8 @@ import type { TPktStringsOverride } from 'shared-strings'
|
|
|
27
27
|
* - optionally rendering hidden inputs with file IDs when `uploadStrategy="custom"`
|
|
28
28
|
*/
|
|
29
29
|
interface IDropZoneProps
|
|
30
|
-
extends Omit<InputHTMLAttributes<HTMLInputElement>, 'checked' | 'size' | 'type' | 'value' | 'onChange' | 'width'
|
|
31
|
-
|
|
32
|
-
strings?: TPktStringsOverride
|
|
30
|
+
extends Omit<InputHTMLAttributes<HTMLInputElement>, 'checked' | 'size' | 'type' | 'value' | 'onChange' | 'width'>,
|
|
31
|
+
IPktStringsProps<'fileupload'> {
|
|
33
32
|
/** Called with `FileItem`s created from dropped/selected files. */
|
|
34
33
|
onFilesAdded?: (files: TFileItemList) => void
|
|
35
34
|
/** Used for the native input `id` and related label/ARIA wiring. */
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
useState,
|
|
28
28
|
} from 'react'
|
|
29
29
|
|
|
30
|
+
import { type IPktFileUploadBase } from 'shared-types'
|
|
30
31
|
import {
|
|
31
32
|
countFileTransferStates,
|
|
32
33
|
resolveAcceptAttribute,
|
|
@@ -51,95 +52,51 @@ import {
|
|
|
51
52
|
TItemRenderer,
|
|
52
53
|
PktFileUploadContext,
|
|
53
54
|
TQueueItemOperation,
|
|
54
|
-
TUploadStrategy,
|
|
55
55
|
} from './types'
|
|
56
56
|
import { usePktStrings } from '../../hooks/usePktStrings'
|
|
57
|
-
import { formatString, plural
|
|
57
|
+
import { formatString, plural } from 'shared-strings'
|
|
58
58
|
|
|
59
|
-
// Re-export for external use
|
|
60
59
|
export { formatFileSize, parseFileSize } from 'shared-utils/fileupload'
|
|
61
60
|
|
|
62
61
|
/**
|
|
63
62
|
* Shared props for `PktFileUpload` (both `form` and `custom` strategies).
|
|
64
63
|
*/
|
|
65
|
-
interface IBaseFileUploadProps
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
interface IBaseFileUploadProps
|
|
65
|
+
extends
|
|
66
|
+
Omit<
|
|
67
|
+
IPktFileUploadBase,
|
|
68
|
+
| 'helptext'
|
|
69
|
+
| 'helptextDropdown'
|
|
70
|
+
| 'itemRenderer'
|
|
71
|
+
| 'extraOperations'
|
|
72
|
+
| 'value'
|
|
73
|
+
| 'defaultValue'
|
|
74
|
+
| 'onFilesChanged'
|
|
75
|
+
| 'onFileUploadRequested'
|
|
76
|
+
>,
|
|
77
|
+
Omit<
|
|
78
|
+
InputHTMLAttributes<HTMLInputElement>,
|
|
79
|
+
'checked' | 'size' | 'type' | 'value' | 'onChange' | 'width' | 'defaultValue' | 'name'
|
|
80
|
+
> {
|
|
69
81
|
/** Called with the next file list when files are added/removed/updated. */
|
|
70
82
|
onFilesChanged?: (files: TFileItemList) => void
|
|
71
|
-
/** Allow selecting/dropping multiple files. */
|
|
72
|
-
multiple?: boolean
|
|
73
|
-
/** Controlled value (recommended). */
|
|
74
|
-
value?: TFileItemList
|
|
75
|
-
/** Upload mode. Defaults to `"form"`. */
|
|
76
|
-
uploadStrategy?: TUploadStrategy
|
|
77
|
-
/** Field name. Used for native input (`form`) or hidden ID inputs (`custom`). */
|
|
78
|
-
name: string
|
|
79
|
-
/** Enable comment operation (disabled automatically in thumbnail view). */
|
|
80
|
-
addCommentsEnabled?: boolean
|
|
81
|
-
/** Enable rename operation (disabled automatically in thumbnail view). */
|
|
82
|
-
renameFilesEnabled?: boolean
|
|
83
|
-
/** Renderer for queue items (`filename`, `thumbnail`, or custom function). */
|
|
84
|
-
itemRenderer?: keyof typeof ItemRenderers | TItemRenderer
|
|
85
|
-
/** Number of trailing characters to keep when truncating long filenames. */
|
|
86
|
-
truncateTail?: number
|
|
87
83
|
/**
|
|
88
84
|
* Called immediately when a file is added in `uploadStrategy="custom"`.
|
|
89
85
|
* Use it to start uploading the file and update `transfers`.
|
|
90
86
|
*/
|
|
91
87
|
onFileUploadRequested?: (fileItem: FileItem) => void
|
|
88
|
+
/** Controlled value (recommended). */
|
|
89
|
+
value?: TFileItemList
|
|
92
90
|
/** Uncontrolled initial value (use either `value` or `defaultValue`, not both). */
|
|
93
91
|
defaultValue?: TFileItemList
|
|
94
|
-
/**
|
|
95
|
-
|
|
96
|
-
/** Stretch to full container width (drop zone + queue). */
|
|
97
|
-
fullwidth?: boolean
|
|
98
|
-
/** Allowed formats for built-in validation (extensions like `pdf`, or MIME patterns like `image/*`). */
|
|
99
|
-
allowedFormats?: string[]
|
|
100
|
-
/** Custom message for invalid format. Use `{formats}` placeholder. */
|
|
101
|
-
formatErrorMessage?: string
|
|
102
|
-
/** Max file size (e.g. `"5MB"` or bytes). */
|
|
103
|
-
maxFileSize?: string | number
|
|
104
|
-
/** Custom message for size validation. Use `{maxSize}` placeholder. */
|
|
105
|
-
sizeErrorMessage?: string
|
|
106
|
-
/** Optional additional validation hook (runs after built-in format/size checks). Return string to block. */
|
|
107
|
-
onFileValidation?: (file: File) => string | null
|
|
108
|
-
/**
|
|
109
|
-
* Low-level validation escape hatch — Lit parity with the `file-validate` CustomEvent.
|
|
110
|
-
* Receives a detail object whose `errorMessage` can be mutated; set it to reject the file.
|
|
111
|
-
*/
|
|
112
|
-
onFileValidate?: (detail: TFileValidateDetail) => void
|
|
113
|
-
/** External/programmatic error message shown under the component. */
|
|
114
|
-
errorMessage?: string
|
|
115
|
-
/** External error flag (combined with internal validation errors). */
|
|
116
|
-
hasError?: boolean
|
|
117
|
-
/** Disable the whole component (no interaction). */
|
|
118
|
-
disabled?: boolean
|
|
119
|
-
/** Optional label/title (wraps the component in `PktInputWrapper`). */
|
|
120
|
-
label?: string
|
|
92
|
+
/** Renderer for queue items (`filename`, `thumbnail`, or custom function). */
|
|
93
|
+
itemRenderer?: keyof typeof ItemRenderers | TItemRenderer
|
|
121
94
|
/** Help text under the label. */
|
|
122
95
|
helptext?: string | ReactNode
|
|
123
96
|
/** Expandable help text (dropdown). */
|
|
124
97
|
helptextDropdown?: string | ReactNode
|
|
125
|
-
/**
|
|
126
|
-
|
|
127
|
-
/** Shows an "optional" tag. */
|
|
128
|
-
optionalTag?: boolean
|
|
129
|
-
/** Label text for the optional tag. */
|
|
130
|
-
optionalText?: string
|
|
131
|
-
/** Shows a "required" tag. */
|
|
132
|
-
requiredTag?: boolean
|
|
133
|
-
/** Label text for the required tag. */
|
|
134
|
-
requiredText?: string
|
|
135
|
-
/** Extra tag next to the label. */
|
|
136
|
-
tagText?: string | null
|
|
137
|
-
/** Marks the upload as required. Native validation is used in `form`; submit validation in `custom`. */
|
|
138
|
-
required?: boolean
|
|
139
|
-
/** Overstyrer tekster for denne komponenten. */
|
|
140
|
-
strings?: TPktStringsOverride
|
|
141
|
-
/** Enable image preview modal (only applies to thumbnail renderer). */
|
|
142
|
-
enableImagePreview?: boolean
|
|
98
|
+
/** Extra operations appended after built-ins (rename/comment). */
|
|
99
|
+
extraOperations?: Array<TQueueItemOperation>
|
|
143
100
|
}
|
|
144
101
|
|
|
145
102
|
interface IFileInputFileUploadProps
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
THeaderMenuLocale,
|
|
10
10
|
IPktHeaderGlobal as ISharedPktHeaderGlobal,
|
|
11
11
|
} from 'shared-types'
|
|
12
|
-
import type {
|
|
12
|
+
import type { IPktStringsProps } from 'shared-strings'
|
|
13
13
|
|
|
14
14
|
export type {
|
|
15
15
|
THeaderMenu,
|
|
@@ -53,10 +53,7 @@ export interface UserMenuFooterItem {
|
|
|
53
53
|
target: string | (() => void)
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
export interface IPktHeader {
|
|
57
|
-
/** Overstyrer tekster for denne komponenten. */
|
|
58
|
-
strings?: TPktStringsOverride
|
|
59
|
-
|
|
56
|
+
export interface IPktHeader extends IPktStringsProps<'header'> {
|
|
60
57
|
children?: ReactNode
|
|
61
58
|
/** Additional CSS class name(s) to apply to the header */
|
|
62
59
|
className?: string
|
|
@@ -130,9 +127,7 @@ export interface IPktHeader {
|
|
|
130
127
|
* Extends the framework-agnostic {@link ISharedPktHeaderGlobal} base
|
|
131
128
|
* (in shared-types) with React-specific callbacks and DOM props.
|
|
132
129
|
*/
|
|
133
|
-
export interface IPktHeaderGlobal extends ISharedPktHeaderGlobal {
|
|
134
|
-
/** Overstyrer tekster for denne komponenten. */
|
|
135
|
-
strings?: TPktStringsOverride
|
|
130
|
+
export interface IPktHeaderGlobal extends ISharedPktHeaderGlobal, IPktStringsProps<'header'> {
|
|
136
131
|
/** Additional CSS class name(s) to apply to the header */
|
|
137
132
|
className?: string
|
|
138
133
|
/** Set dark mode on the header */
|
package/src/components/index.ts
CHANGED
|
@@ -61,4 +61,4 @@ export {
|
|
|
61
61
|
setPktStrings,
|
|
62
62
|
subscribePktStrings,
|
|
63
63
|
} from 'shared-strings'
|
|
64
|
-
export type { TPktStrings, TPktStringsNamespace, TPktStringsOverride } from 'shared-strings'
|
|
64
|
+
export type { TPktStrings, TPktStringsNamespace, TPktStringsOverride, IPktStringsProps } from 'shared-strings'
|
|
@@ -4,12 +4,12 @@ import { ForwardedRef, forwardRef, type ReactNode, RefAttributes } from 'react'
|
|
|
4
4
|
|
|
5
5
|
import { useFocusModality } from '../../hooks/useFocusModality'
|
|
6
6
|
import { usePktStrings } from '../../hooks/usePktStrings'
|
|
7
|
-
import { formatString, type
|
|
7
|
+
import { formatString, type IPktStringsProps } from 'shared-strings'
|
|
8
8
|
import { counterStatusId, isCounterExceeded } from 'shared-utils/forms/described-by'
|
|
9
9
|
import { PktAlert } from '../alert/Alert'
|
|
10
10
|
import { PktHelptext } from '../helptext/Helptext'
|
|
11
11
|
|
|
12
|
-
export interface IPktInputWrapper extends RefAttributes<HTMLElement> {
|
|
12
|
+
export interface IPktInputWrapper extends RefAttributes<HTMLElement>, IPktStringsProps<'forms' | 'validation'> {
|
|
13
13
|
forId: string
|
|
14
14
|
label: string
|
|
15
15
|
helptext?: string | ReactNode
|
|
@@ -38,8 +38,6 @@ export interface IPktInputWrapper extends RefAttributes<HTMLElement> {
|
|
|
38
38
|
role?: string
|
|
39
39
|
counterPosition?: 'top' | 'bottom'
|
|
40
40
|
size?: 'small' | 'medium' | 'xsmall'
|
|
41
|
-
/** Overstyrer tekster for denne komponenten. */
|
|
42
|
-
strings?: TPktStringsOverride
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
export const PktInputWrapper = forwardRef(
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
import { AnchorHTMLAttributes, FC, LinkHTMLAttributes, ReactNode } from 'react'
|
|
5
|
+
import type { TRenderLink } from 'shared-types'
|
|
5
6
|
|
|
6
7
|
import { PktIcon } from '../icon/Icon'
|
|
7
8
|
|
|
@@ -12,12 +13,7 @@ interface IPktLink extends LinkHTMLAttributes<HTMLAnchorElement> {
|
|
|
12
13
|
iconPosition?: string | undefined
|
|
13
14
|
external?: boolean
|
|
14
15
|
target?: string | undefined
|
|
15
|
-
renderLink?:
|
|
16
|
-
href: string
|
|
17
|
-
className: string
|
|
18
|
-
children: ReactNode
|
|
19
|
-
props: AnchorHTMLAttributes<HTMLAnchorElement>
|
|
20
|
-
}) => ReactNode
|
|
16
|
+
renderLink?: TRenderLink<ReactNode, AnchorHTMLAttributes<HTMLAnchorElement>>
|
|
21
17
|
}
|
|
22
18
|
|
|
23
19
|
export const PktLink: FC<IPktLink> = ({
|
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
ReactNode,
|
|
8
8
|
} from 'react'
|
|
9
9
|
import { usePktStrings } from '../../hooks/usePktStrings'
|
|
10
|
-
import type {
|
|
10
|
+
import type { IPktStringsProps } from 'shared-strings'
|
|
11
11
|
|
|
12
|
-
export interface IPktRadioButton extends InputHTMLAttributes<HTMLInputElement> {
|
|
12
|
+
export interface IPktRadioButton extends InputHTMLAttributes<HTMLInputElement>, IPktStringsProps<'forms'> {
|
|
13
13
|
id: string
|
|
14
14
|
name: string
|
|
15
15
|
label: string
|
|
@@ -26,8 +26,6 @@ export interface IPktRadioButton extends InputHTMLAttributes<HTMLInputElement> {
|
|
|
26
26
|
requiredTag?: boolean
|
|
27
27
|
/** @deprecated Bruk `strings={{ forms: { required: '…' } }}` eller `setPktStrings()`. */
|
|
28
28
|
requiredText?: string
|
|
29
|
-
/** Overstyrer tekster for denne komponenten. */
|
|
30
|
-
strings?: TPktStringsOverride
|
|
31
29
|
tagText?: string | null
|
|
32
30
|
onChange?: ChangeEventHandler<HTMLInputElement>
|
|
33
31
|
}
|
|
@@ -7,7 +7,7 @@ import type { IPktSearchInputSuggestion } from 'shared-types/searchinput'
|
|
|
7
7
|
import { useFocusModality } from '../../hooks/useFocusModality'
|
|
8
8
|
import { PktButton } from '../button/Button'
|
|
9
9
|
import { usePktStrings } from '../../hooks/usePktStrings'
|
|
10
|
-
import type {
|
|
10
|
+
import type { IPktStringsProps } from 'shared-strings'
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* React suggestion item: portable fields from {@link IPktSearchInputSuggestion}
|
|
@@ -19,10 +19,7 @@ export type PktSearchInputSuggestion = Omit<IPktSearchInputSuggestion, 'title' |
|
|
|
19
19
|
onClick?: () => void
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
interface ISearch extends HTMLProps<HTMLInputElement> {
|
|
23
|
-
/** Overstyrer tekster for denne komponenten. */
|
|
24
|
-
strings?: TPktStringsOverride
|
|
25
|
-
|
|
22
|
+
interface ISearch extends HTMLProps<HTMLInputElement>, IPktStringsProps<'searchinput'> {
|
|
26
23
|
appearance?: 'local' | 'local-with-button' | 'global'
|
|
27
24
|
inputSize?: 'small' | 'medium' | 'xsmall'
|
|
28
25
|
disabled?: boolean
|
|
@@ -4,13 +4,12 @@ import { ForwardedRef, forwardRef, ReactNode, SelectHTMLAttributes } from 'react
|
|
|
4
4
|
|
|
5
5
|
import { PktInputWrapper } from '../inputwrapper/InputWrapper'
|
|
6
6
|
import { describedByIds } from 'shared-utils/forms/described-by'
|
|
7
|
-
import type {
|
|
7
|
+
import type { IPktStringsProps } from 'shared-strings'
|
|
8
8
|
|
|
9
9
|
export type { IPktSelectOption, TSelectOption } from 'shared-types/select'
|
|
10
10
|
|
|
11
|
-
export interface IPktSelectProps
|
|
12
|
-
|
|
13
|
-
strings?: TPktStringsOverride
|
|
11
|
+
export interface IPktSelectProps
|
|
12
|
+
extends SelectHTMLAttributes<HTMLSelectElement>, IPktStringsProps<'forms' | 'validation'> {
|
|
14
13
|
ariaDescribedby?: string
|
|
15
14
|
ariaLabelledby?: string
|
|
16
15
|
children?: ReactNode | ReactNode[]
|
|
@@ -18,12 +18,9 @@ import type { TTagSkin } from 'shared-types'
|
|
|
18
18
|
|
|
19
19
|
import { PktIcon } from '../icon/Icon'
|
|
20
20
|
import { usePktStrings } from '../../hooks/usePktStrings'
|
|
21
|
-
import { formatString, type
|
|
22
|
-
|
|
23
|
-
interface BasePktTagProps {
|
|
24
|
-
/** Overstyrer tekster for denne komponenten. */
|
|
25
|
-
strings?: TPktStringsOverride
|
|
21
|
+
import { formatString, type IPktStringsProps } from 'shared-strings'
|
|
26
22
|
|
|
23
|
+
interface BasePktTagProps extends IPktStringsProps<'tag'> {
|
|
27
24
|
skin?: TTagSkin
|
|
28
25
|
textStyle?: 'normal-text' | 'thin-text'
|
|
29
26
|
size?: 'small' | 'medium' | 'large'
|
|
@@ -14,11 +14,10 @@ import {
|
|
|
14
14
|
import { PktInputWrapper } from '../inputwrapper/InputWrapper'
|
|
15
15
|
import { TPktInputSize } from 'shared-types/size'
|
|
16
16
|
import { describedByIds } from 'shared-utils/forms/described-by'
|
|
17
|
-
import type {
|
|
17
|
+
import type { IPktStringsProps } from 'shared-strings'
|
|
18
18
|
|
|
19
|
-
export interface IPktTextarea
|
|
20
|
-
|
|
21
|
-
strings?: TPktStringsOverride
|
|
19
|
+
export interface IPktTextarea
|
|
20
|
+
extends TextareaHTMLAttributes<HTMLTextAreaElement>, IPktStringsProps<'forms' | 'validation'> {
|
|
22
21
|
id: string
|
|
23
22
|
ariaDescribedby?: string
|
|
24
23
|
ariaLabelledby?: string
|
|
@@ -14,11 +14,10 @@ import {
|
|
|
14
14
|
import { PktIcon } from '../icon/Icon'
|
|
15
15
|
import { PktInputWrapper } from '../inputwrapper/InputWrapper'
|
|
16
16
|
import { describedByIds } from 'shared-utils/forms/described-by'
|
|
17
|
-
import type {
|
|
17
|
+
import type { IPktStringsProps } from 'shared-strings'
|
|
18
18
|
|
|
19
|
-
export interface IPktTextinput
|
|
20
|
-
|
|
21
|
-
strings?: TPktStringsOverride
|
|
19
|
+
export interface IPktTextinput
|
|
20
|
+
extends InputHTMLAttributes<HTMLInputElement>, IPktStringsProps<'forms' | 'validation'> {
|
|
22
21
|
id: string
|
|
23
22
|
ariaDescribedby?: string
|
|
24
23
|
ariaLabelledby?: string
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IPktStringsProps } from 'shared-strings'
|
|
2
2
|
import type { ChangeEvent, FocusEvent, InputHTMLAttributes, ReactNode } from 'react'
|
|
3
3
|
import { TPktInputSize } from 'shared-types/size'
|
|
4
4
|
|
|
@@ -11,7 +11,7 @@ import { TPktInputSize } from 'shared-types/size'
|
|
|
11
11
|
export interface IPktTimepicker extends Omit<
|
|
12
12
|
InputHTMLAttributes<HTMLInputElement>,
|
|
13
13
|
'value' | 'onChange' | 'onInput' | 'min' | 'max' | 'step' | 'onFocus' | 'onBlur'
|
|
14
|
-
> {
|
|
14
|
+
>, IPktStringsProps<'timepicker' | 'forms' | 'validation'> {
|
|
15
15
|
/** Unique id; used for hour, minute, popup, and hidden input ids. */
|
|
16
16
|
id: string
|
|
17
17
|
|
|
@@ -94,10 +94,6 @@ export interface IPktTimepicker extends Omit<
|
|
|
94
94
|
/** Passed through to InputWrapper as `aria-describedby`. */
|
|
95
95
|
ariaDescribedby?: string
|
|
96
96
|
|
|
97
|
-
/** Copy for hours, minutes, buttons, and popup. */
|
|
98
|
-
/** Overstyrer tekster for denne komponenten. */
|
|
99
|
-
strings?: TPktStringsOverride
|
|
100
|
-
|
|
101
97
|
/** Change event from the hidden input (`e.target.value` is `HH:MM`). In React, `onChange` already fires on input. */
|
|
102
98
|
onChange?: (e: ChangeEvent<HTMLInputElement>) => void
|
|
103
99
|
|