@oslokommune/punkt-react 18.0.0 → 18.1.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 +17 -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/fileupload/FileUpload.d.ts +9 -64
- package/dist/components/index.d.ts +1 -1
- package/dist/components/link/Link.d.ts +2 -6
- 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 +11 -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 +45 -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/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/fileupload/FileUpload.tsx +25 -68
- package/src/components/index.ts +1 -1
- package/src/components/link/Link.tsx +2 -6
|
@@ -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
|
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'
|
|
@@ -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> = ({
|