@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.
Files changed (35) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/components/accordion/Accordion.d.ts +2 -12
  3. package/dist/components/accordion/AccordionItem.d.ts +2 -8
  4. package/dist/components/alert/Alert.d.ts +4 -3
  5. package/dist/components/backlink/BackLink.d.ts +3 -13
  6. package/dist/components/breadcrumbs/Breadcrumbs.d.ts +7 -16
  7. package/dist/components/fileupload/FileUpload.d.ts +9 -64
  8. package/dist/components/index.d.ts +1 -1
  9. package/dist/components/link/Link.d.ts +2 -6
  10. package/dist/punkt-react.cjs +1 -1
  11. package/dist/punkt-react.js +1208 -1203
  12. package/dist/shared-strings/index.d.ts +1 -1
  13. package/dist/shared-strings/nb.d.ts +3 -0
  14. package/dist/shared-strings/types.d.ts +11 -0
  15. package/dist/shared-types/accordion.d.ts +58 -0
  16. package/dist/shared-types/alert.d.ts +20 -0
  17. package/dist/shared-types/aria.d.ts +2 -1
  18. package/dist/shared-types/backlink.d.ts +23 -0
  19. package/dist/shared-types/breadcrumbs.d.ts +33 -0
  20. package/dist/shared-types/fileupload.d.ts +56 -2
  21. package/dist/shared-types/footer.d.ts +10 -0
  22. package/dist/shared-types/form-field.d.ts +45 -0
  23. package/dist/shared-types/header-footer.d.ts +2 -0
  24. package/dist/shared-types/index.d.ts +15 -5
  25. package/dist/shared-types/render-link.d.ts +22 -0
  26. package/dist/shared-types/skin.d.ts +2 -9
  27. package/package.json +2 -2
  28. package/src/components/accordion/Accordion.tsx +2 -12
  29. package/src/components/accordion/AccordionItem.tsx +2 -8
  30. package/src/components/alert/Alert.tsx +12 -5
  31. package/src/components/backlink/BackLink.tsx +7 -16
  32. package/src/components/breadcrumbs/Breadcrumbs.tsx +14 -16
  33. package/src/components/fileupload/FileUpload.tsx +25 -68
  34. package/src/components/index.ts +1 -1
  35. package/src/components/link/Link.tsx +2 -6
package/CHANGELOG.md CHANGED
@@ -5,6 +5,23 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
5
5
 
6
6
  ---
7
7
 
8
+ ## [18.1.0](https://github.com/oslokommune/punkt/compare/18.0.0...18.1.0) (2026-08-31)
9
+
10
+ ### ⚠ BREAKING CHANGES
11
+ Ingen
12
+
13
+ ### Features
14
+ Ingen
15
+
16
+ ### Bug Fixes
17
+ Ingen
18
+
19
+ ### Chores
20
+ Ingen
21
+
22
+ ---
23
+
24
+
8
25
  ## [18.0.0](https://github.com/oslokommune/punkt/compare/17.1.3...18.0.0) (2026-08-27)
9
26
 
10
27
  ### ⚠ BREAKING CHANGES
@@ -1,18 +1,8 @@
1
1
  import { ReactNode } from 'react';
2
- import { TAccordionSkin } from '../../shared-types';
2
+ import { IPktAccordionBase, TAccordionSkin } from '../../shared-types';
3
3
  export type TPktAccordionSkin = TAccordionSkin;
4
- export interface IPktAccordion {
5
- compact?: boolean;
6
- /**
7
- * @default skin: "borderless"
8
- */
9
- skin?: TPktAccordionSkin;
10
- /**
11
- * @description A unique identifier to connect the accordion with a heading
12
- */
13
- ariaLabelledBy?: string;
4
+ export interface IPktAccordion extends IPktAccordionBase {
14
5
  children?: ReactNode;
15
- name?: string;
16
6
  className?: string;
17
7
  }
18
8
  export declare const useAccordionContext: () => {
@@ -1,15 +1,9 @@
1
1
  import { MouseEvent, ReactNode, SyntheticEvent } from 'react';
2
- import { TAccordionSkin } from '../../shared-types';
2
+ import { IPktAccordionItemBase, TAccordionSkin } from '../../shared-types';
3
3
  export type TPktAccordionSkin = TAccordionSkin;
4
- export interface IPktAccordionItem {
5
- defaultOpen?: boolean;
6
- id: string;
4
+ export interface IPktAccordionItem extends Omit<IPktAccordionItemBase, 'title'> {
7
5
  title: string | ReactNode;
8
- skin?: TPktAccordionSkin;
9
- compact?: boolean;
10
- isOpen?: boolean;
11
6
  children?: ReactNode;
12
- name?: string;
13
7
  className?: string;
14
8
  onClick?: (e: MouseEvent<HTMLDetailsElement>) => void;
15
9
  onToggle?: (e: SyntheticEvent<HTMLDetailsElement>) => void;
@@ -1,6 +1,7 @@
1
1
  import { FC, HTMLAttributes, ReactNode } from 'react';
2
- import { TAlertRole, TAlertSkin, TAriaLive } from '../../shared-types';
3
- export interface IPktAlert extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
2
+ import { TAlertRole, TAlertSkin, TAlertSize, TAriaLive } from '../../shared-types';
3
+ import { IPktStringsProps } from '../../shared-strings';
4
+ export interface IPktAlert extends Omit<HTMLAttributes<HTMLDivElement>, 'title'>, IPktStringsProps {
4
5
  skin?: TAlertSkin;
5
6
  closeAlert?: boolean;
6
7
  title?: ReactNode;
@@ -16,7 +17,7 @@ export interface IPktAlert extends Omit<HTMLAttributes<HTMLDivElement>, 'title'>
16
17
  *
17
18
  * @default medium
18
19
  */
19
- size?: 'medium' | 'small' | 'xsmall';
20
+ size?: TAlertSize;
20
21
  onClose?: (e: CustomEvent) => void;
21
22
  }
22
23
  export type { TAlertSkin };
@@ -1,17 +1,7 @@
1
1
  import { AnchorHTMLAttributes, ReactNode, Ref } from 'react';
2
- import { TPktStringsOverride } from '../../shared-strings';
3
- export interface IPktBackLink extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> {
4
- /** Overstyrer tekster for denne komponenten. */
5
- strings?: TPktStringsOverride;
6
- href?: string;
7
- text?: string;
8
- ariaLabel?: string;
9
- renderLink?: (args: {
10
- href: string;
11
- className: string;
12
- children: ReactNode;
13
- props: AnchorHTMLAttributes<HTMLAnchorElement>;
14
- }) => ReactNode;
2
+ import { IPktBackLinkBase, TRenderLink } from '../../shared-types';
3
+ export interface IPktBackLink extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>, IPktBackLinkBase {
4
+ renderLink?: TRenderLink<ReactNode, AnchorHTMLAttributes<HTMLAnchorElement>>;
15
5
  ref?: Ref<HTMLElement>;
16
6
  }
17
7
  export declare const PktBackLink: import('react').ForwardRefExoticComponent<Omit<IPktBackLink, "ref"> & import('react').RefAttributes<HTMLElement>>;
@@ -1,19 +1,10 @@
1
1
  import { AnchorHTMLAttributes, ReactNode } from 'react';
2
- import { TPktStringsOverride } from '../../shared-strings';
3
- export interface IBreadcrumbs {
4
- text: string;
5
- href: string;
6
- }
7
- export interface IPktBreadcrumbs extends AnchorHTMLAttributes<HTMLAnchorElement> {
8
- /** Overstyrer tekster for denne komponenten. */
9
- strings?: TPktStringsOverride;
10
- breadcrumbs: IBreadcrumbs[];
11
- navigationType?: 'router' | 'anchor';
12
- renderLink?: (args: {
13
- href: string;
14
- className: string;
15
- children: ReactNode;
16
- props: AnchorHTMLAttributes<HTMLAnchorElement>;
17
- }) => ReactNode;
2
+ import { IBreadcrumb, IPktBreadcrumbsBase, TBreadcrumbsNavigationType, TRenderLink } from '../../shared-types';
3
+ export type { IBreadcrumb };
4
+ /** @deprecated Use `IBreadcrumb`. */
5
+ export type IBreadcrumbs = IBreadcrumb;
6
+ export interface IPktBreadcrumbs extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'children'>, IPktBreadcrumbsBase {
7
+ navigationType?: TBreadcrumbsNavigationType;
8
+ renderLink?: TRenderLink<ReactNode, AnchorHTMLAttributes<HTMLAnchorElement>>;
18
9
  }
19
10
  export declare const PktBreadcrumbs: import('react').ForwardRefExoticComponent<IPktBreadcrumbs & import('react').RefAttributes<HTMLAnchorElement>>;
@@ -1,86 +1,31 @@
1
1
  import { FC, HTMLAttributes, InputHTMLAttributes, ReactNode } from 'react';
2
+ import { IPktFileUploadBase } from '../../shared-types';
2
3
  import { ItemRenderers } from './QueueDisplay';
3
- import { FileItem, TFileItemList, TFileTransfer, TFileValidateDetail, TItemRenderer, TQueueItemOperation, TUploadStrategy } from './types';
4
- import { TPktStringsOverride } from '../../shared-strings';
4
+ import { FileItem, TFileItemList, TFileTransfer, TItemRenderer, TQueueItemOperation } from './types';
5
5
  export { formatFileSize, parseFileSize } from '../../shared-utils/fileupload';
6
6
  /**
7
7
  * Shared props for `PktFileUpload` (both `form` and `custom` strategies).
8
8
  */
9
- interface IBaseFileUploadProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'checked' | 'size' | 'type' | 'value' | 'onChange' | 'width' | 'defaultValue'> {
9
+ interface IBaseFileUploadProps extends Omit<IPktFileUploadBase, 'helptext' | 'helptextDropdown' | 'itemRenderer' | 'extraOperations' | 'value' | 'defaultValue' | 'onFilesChanged' | 'onFileUploadRequested'>, Omit<InputHTMLAttributes<HTMLInputElement>, 'checked' | 'size' | 'type' | 'value' | 'onChange' | 'width' | 'defaultValue' | 'name'> {
10
10
  /** Called with the next file list when files are added/removed/updated. */
11
11
  onFilesChanged?: (files: TFileItemList) => void;
12
- /** Allow selecting/dropping multiple files. */
13
- multiple?: boolean;
14
- /** Controlled value (recommended). */
15
- value?: TFileItemList;
16
- /** Upload mode. Defaults to `"form"`. */
17
- uploadStrategy?: TUploadStrategy;
18
- /** Field name. Used for native input (`form`) or hidden ID inputs (`custom`). */
19
- name: string;
20
- /** Enable comment operation (disabled automatically in thumbnail view). */
21
- addCommentsEnabled?: boolean;
22
- /** Enable rename operation (disabled automatically in thumbnail view). */
23
- renameFilesEnabled?: boolean;
24
- /** Renderer for queue items (`filename`, `thumbnail`, or custom function). */
25
- itemRenderer?: keyof typeof ItemRenderers | TItemRenderer;
26
- /** Number of trailing characters to keep when truncating long filenames. */
27
- truncateTail?: number;
28
12
  /**
29
13
  * Called immediately when a file is added in `uploadStrategy="custom"`.
30
14
  * Use it to start uploading the file and update `transfers`.
31
15
  */
32
16
  onFileUploadRequested?: (fileItem: FileItem) => void;
17
+ /** Controlled value (recommended). */
18
+ value?: TFileItemList;
33
19
  /** Uncontrolled initial value (use either `value` or `defaultValue`, not both). */
34
20
  defaultValue?: TFileItemList;
35
- /** Extra operations appended after built-ins (rename/comment). */
36
- extraOperations?: Array<TQueueItemOperation>;
37
- /** Stretch to full container width (drop zone + queue). */
38
- fullwidth?: boolean;
39
- /** Allowed formats for built-in validation (extensions like `pdf`, or MIME patterns like `image/*`). */
40
- allowedFormats?: string[];
41
- /** Custom message for invalid format. Use `{formats}` placeholder. */
42
- formatErrorMessage?: string;
43
- /** Max file size (e.g. `"5MB"` or bytes). */
44
- maxFileSize?: string | number;
45
- /** Custom message for size validation. Use `{maxSize}` placeholder. */
46
- sizeErrorMessage?: string;
47
- /** Optional additional validation hook (runs after built-in format/size checks). Return string to block. */
48
- onFileValidation?: (file: File) => string | null;
49
- /**
50
- * Low-level validation escape hatch — Lit parity with the `file-validate` CustomEvent.
51
- * Receives a detail object whose `errorMessage` can be mutated; set it to reject the file.
52
- */
53
- onFileValidate?: (detail: TFileValidateDetail) => void;
54
- /** External/programmatic error message shown under the component. */
55
- errorMessage?: string;
56
- /** External error flag (combined with internal validation errors). */
57
- hasError?: boolean;
58
- /** Disable the whole component (no interaction). */
59
- disabled?: boolean;
60
- /** Optional label/title (wraps the component in `PktInputWrapper`). */
61
- label?: string;
21
+ /** Renderer for queue items (`filename`, `thumbnail`, or custom function). */
22
+ itemRenderer?: keyof typeof ItemRenderers | TItemRenderer;
62
23
  /** Help text under the label. */
63
24
  helptext?: string | ReactNode;
64
25
  /** Expandable help text (dropdown). */
65
26
  helptextDropdown?: string | ReactNode;
66
- /** Button label for expandable help text. */
67
- helptextDropdownButton?: string;
68
- /** Shows an "optional" tag. */
69
- optionalTag?: boolean;
70
- /** Label text for the optional tag. */
71
- optionalText?: string;
72
- /** Shows a "required" tag. */
73
- requiredTag?: boolean;
74
- /** Label text for the required tag. */
75
- requiredText?: string;
76
- /** Extra tag next to the label. */
77
- tagText?: string | null;
78
- /** Marks the upload as required. Native validation is used in `form`; submit validation in `custom`. */
79
- required?: boolean;
80
- /** Overstyrer tekster for denne komponenten. */
81
- strings?: TPktStringsOverride;
82
- /** Enable image preview modal (only applies to thumbnail renderer). */
83
- enableImagePreview?: boolean;
27
+ /** Extra operations appended after built-ins (rename/comment). */
28
+ extraOperations?: Array<TQueueItemOperation>;
84
29
  }
85
30
  interface IFileInputFileUploadProps extends IBaseFileUploadProps, Omit<HTMLAttributes<HTMLInputElement>, 'value' | 'onChange' | 'defaultValue'> {
86
31
  uploadStrategy?: 'form';
@@ -55,4 +55,4 @@ export * from './types';
55
55
  export { PktStringsProvider } from './strings/PktStringsProvider';
56
56
  export type { IPktStringsProvider } from './strings/PktStringsProvider';
57
57
  export { getPktStrings, nb as pktStringsNb, resetPktStrings, setPktStrings, subscribePktStrings, } from '../shared-strings';
58
- export type { TPktStrings, TPktStringsNamespace, TPktStringsOverride } from '../shared-strings';
58
+ export type { TPktStrings, TPktStringsNamespace, TPktStringsOverride, IPktStringsProps } from '../shared-strings';
@@ -1,4 +1,5 @@
1
1
  import { AnchorHTMLAttributes, FC, LinkHTMLAttributes, ReactNode } from 'react';
2
+ import { TRenderLink } from '../../shared-types';
2
3
  interface IPktLink extends LinkHTMLAttributes<HTMLAnchorElement> {
3
4
  href?: string;
4
5
  iconName?: string | undefined;
@@ -6,12 +7,7 @@ interface IPktLink extends LinkHTMLAttributes<HTMLAnchorElement> {
6
7
  iconPosition?: string | undefined;
7
8
  external?: boolean;
8
9
  target?: string | undefined;
9
- renderLink?: (args: {
10
- href: string;
11
- className: string;
12
- children: ReactNode;
13
- props: AnchorHTMLAttributes<HTMLAnchorElement>;
14
- }) => ReactNode;
10
+ renderLink?: TRenderLink<ReactNode, AnchorHTMLAttributes<HTMLAnchorElement>>;
15
11
  }
16
12
  export declare const PktLink: FC<IPktLink>;
17
13
  export {};