@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
|
@@ -10,5 +10,5 @@ export { nb } from './nb';
|
|
|
10
10
|
export { formatString, plural } from './format';
|
|
11
11
|
export { getPktStrings, resetPktStrings, setPktStrings, subscribePktStrings } from './store';
|
|
12
12
|
export { resolveNamespace, resolveStrings } from './resolve';
|
|
13
|
-
export type { TPktStringParams, TPktStrings, TPktStringsNamespace, TPktStringsOverride, TPktStringsShape, TPktStringValue, } from './types';
|
|
13
|
+
export type { IPktStringsProps, TPktStringParams, TPktStrings, TPktStringsNamespace, TPktStringsOverride, TPktStringsShape, TPktStringValue, } from './types';
|
|
14
14
|
export { consentStrings } from './consent';
|
|
@@ -27,3 +27,14 @@ export type TPktStringsOverride<NS extends TPktStringsNamespace = TPktStringsNam
|
|
|
27
27
|
};
|
|
28
28
|
/** Verdier som kan settes inn i en `{plassholder}`. */
|
|
29
29
|
export type TPktStringParams = Record<string, string | number>;
|
|
30
|
+
/**
|
|
31
|
+
* `strings`-propen som alle Punkt-komponenter som viser katalogtekst skal ha.
|
|
32
|
+
* Elements har den på `PktShadowElement`; React-interfaces extender denne slicen.
|
|
33
|
+
*
|
|
34
|
+
* TODO: Consider adding a type parameter for the namespace, so that the strings object can be narrowed to the namespace.
|
|
35
|
+
* f.eks. ÌPktFileUploadProps<'fileupload'|'forms'> for å kunne sette tekster for felt i skjema og valideringsmeldinger.
|
|
36
|
+
*/
|
|
37
|
+
export type IPktStringsProps<NS extends TPktStringsNamespace = TPktStringsNamespace> = {
|
|
38
|
+
/** Overstyrer tekster for denne komponenten. */
|
|
39
|
+
strings?: TPktStringsOverride<NS>;
|
|
40
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* accordion.ts
|
|
3
|
+
*
|
|
4
|
+
* Type definisjoner for pkt-accordion og pkt-accordion-item.
|
|
5
|
+
* Brukes av React, Elements, og typed component specs.
|
|
6
|
+
*
|
|
7
|
+
* @remarks React ekspanderer `title` streng typen til `string`|`ReactNode` på accordion-items.
|
|
8
|
+
* Form-field common props (`IFormFieldCommonProps`) gjelder ikke accordion —
|
|
9
|
+
* bruk `IAccordionVisualProps` for delte visuelle props (`skin`, `compact`).
|
|
10
|
+
*/
|
|
11
|
+
/** Accordion skin varianter — delt runtime source for types, specs, og Preview. */
|
|
12
|
+
export declare const ACCORDION_SKINS: readonly ['borderless', 'outlined', 'beige', 'blue', 'plus-minus'];
|
|
13
|
+
export type TAccordionSkin = (typeof ACCORDION_SKINS)[number];
|
|
14
|
+
/** Visual props delt med pkt-accordion og pkt-accordion-item. */
|
|
15
|
+
export type IAccordionVisualProps = {
|
|
16
|
+
skin?: TAccordionSkin;
|
|
17
|
+
compact?: boolean;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Accordion props delt med React, Elements, og typed specs.
|
|
21
|
+
*/
|
|
22
|
+
export type IPktAccordionBase = IAccordionVisualProps & {
|
|
23
|
+
/** ID of the element that labels the accordion group (`aria-labelledby`). */
|
|
24
|
+
ariaLabelledBy?: string;
|
|
25
|
+
/** Groups accordion items so only one panel is open at a time within the group. */
|
|
26
|
+
name?: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Accordion-item props delt med React, Elements, og typed specs.
|
|
30
|
+
*
|
|
31
|
+
* @remarks Item `skin` / `compact` overrider verdier arvet fra parent-kontekst når satt.
|
|
32
|
+
*/
|
|
33
|
+
export type IPktAccordionItemBase = IAccordionVisualProps & {
|
|
34
|
+
id: string;
|
|
35
|
+
/** Summary label — string in Elements; React may pass `ReactNode`. */
|
|
36
|
+
title: string;
|
|
37
|
+
/** Open on first render (uncontrolled initial state). */
|
|
38
|
+
defaultOpen?: boolean;
|
|
39
|
+
/** Controlled open state — overrides internal toggle state when set. */
|
|
40
|
+
isOpen?: boolean;
|
|
41
|
+
/** Accordion group name — inherits from parent pkt-accordion when omitted. */
|
|
42
|
+
name?: string;
|
|
43
|
+
};
|
|
44
|
+
/** Pkt-accordion props for typed component specs. */
|
|
45
|
+
export type IAccordionSpecProps = Pick<IPktAccordionBase, 'skin' | 'compact' | 'ariaLabelledBy' | 'name'>;
|
|
46
|
+
/** Pkt-accordion-item props for typed component specs. */
|
|
47
|
+
export type IAccordionItemSpecProps = Pick<IPktAccordionItemBase, 'id' | 'title' | 'defaultOpen' | 'isOpen' | 'name' | 'skin' | 'compact'> & {
|
|
48
|
+
/**
|
|
49
|
+
* React-only click handler on the `<details>` element.
|
|
50
|
+
* @remarks Elements has no equivalent — use native DOM events if needed.
|
|
51
|
+
*/
|
|
52
|
+
onClick?: (event: Event) => void;
|
|
53
|
+
/**
|
|
54
|
+
* React-only toggle handler on the `<details>` element.
|
|
55
|
+
* @remarks Elements has no equivalent — use native DOM events if needed.
|
|
56
|
+
*/
|
|
57
|
+
onToggle?: (event: Event) => void;
|
|
58
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TAriaLive } from './aria';
|
|
2
|
+
/** Alert skin variants — shared runtime source for types, specs, and Preview. */
|
|
3
|
+
export declare const ALERT_SKINS: readonly ['info', 'success', 'warning', 'error'];
|
|
4
|
+
export type TAlertSkin = (typeof ALERT_SKINS)[number];
|
|
5
|
+
/** Alert size variants — shared runtime source for types, specs, and Preview. */
|
|
6
|
+
export declare const ALERT_SIZES: readonly ['medium', 'small', 'xsmall'];
|
|
7
|
+
/** Alert size type derived from ALERT_SIZES */
|
|
8
|
+
export type TAlertSize = (typeof ALERT_SIZES)[number];
|
|
9
|
+
/**
|
|
10
|
+
* Documented Alert props (subset of React `IPktAlert` / Elements `IPktAlert`).
|
|
11
|
+
* Used for typed component specs in documentation.
|
|
12
|
+
*/
|
|
13
|
+
export type IAlertSpecProps = {
|
|
14
|
+
title?: string;
|
|
15
|
+
skin?: TAlertSkin;
|
|
16
|
+
date?: string;
|
|
17
|
+
ariaLive?: TAriaLive;
|
|
18
|
+
size?: TAlertSize;
|
|
19
|
+
closeAlert?: boolean;
|
|
20
|
+
};
|
|
@@ -9,7 +9,8 @@ export type TAriaBooleanMixed = TAriaBoolean | 'mixed';
|
|
|
9
9
|
export type TAriaCurrent = TAriaBoolean | 'page' | 'step' | 'location' | 'date' | 'time';
|
|
10
10
|
export type TAriaHasPopup = TAriaBoolean | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog';
|
|
11
11
|
export type TAriaInvalid = TAriaBoolean | 'grammar' | 'spelling';
|
|
12
|
-
export
|
|
12
|
+
export declare const ARIA_LIVE_VALUES: readonly ['off', 'polite', 'assertive'];
|
|
13
|
+
export type TAriaLive = (typeof ARIA_LIVE_VALUES)[number];
|
|
13
14
|
export type TAriaRelevant = 'additions' | 'removals' | 'text' | 'all';
|
|
14
15
|
export type TAriaSort = 'none' | 'ascending' | 'descending' | 'other';
|
|
15
16
|
export type TAriaAutoComplete = 'none' | 'inline' | 'list' | 'both';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* backlink.ts
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for pkt-backlink.
|
|
5
|
+
* Used by React, Elements, and typed component specs.
|
|
6
|
+
*/
|
|
7
|
+
import type { IPktStringsProps } from '../shared-strings';
|
|
8
|
+
import type { TRenderLink } from './render-link';
|
|
9
|
+
/** Shared backlink props for React, Elements, and typed specs. */
|
|
10
|
+
export type IPktBackLinkBase = IPktStringsProps & {
|
|
11
|
+
href?: string;
|
|
12
|
+
text?: string;
|
|
13
|
+
/** @deprecated Bruk `strings={{ backlink: { label: '…' } }}` eller `setPktStrings()`. */
|
|
14
|
+
ariaLabel?: string | null;
|
|
15
|
+
};
|
|
16
|
+
/** Documented props for typed component specs. */
|
|
17
|
+
export type IBacklinkSpecProps = Pick<IPktBackLinkBase, 'href' | 'text' | 'ariaLabel'> & {
|
|
18
|
+
/**
|
|
19
|
+
* React-only custom link renderer (e.g. Next.js Link).
|
|
20
|
+
* @remarks Elements has no equivalent — uses a native `<a>`.
|
|
21
|
+
*/
|
|
22
|
+
renderLink?: TRenderLink;
|
|
23
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* breadcrumbs.ts
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for pkt-breadcrumbs.
|
|
5
|
+
* Used by React, Elements, and typed component specs.
|
|
6
|
+
*/
|
|
7
|
+
import type { IPktStringsProps } from '../shared-strings';
|
|
8
|
+
import type { TRenderLink } from './render-link';
|
|
9
|
+
/** Navigation mode for React `PktBreadcrumbs` (router vs native anchor). */
|
|
10
|
+
export declare const BREADCRUMBS_NAVIGATION_TYPES: readonly ['router', 'anchor'];
|
|
11
|
+
export type TBreadcrumbsNavigationType = (typeof BREADCRUMBS_NAVIGATION_TYPES)[number];
|
|
12
|
+
/** One crumb in a breadcrumbs trail. */
|
|
13
|
+
export type IBreadcrumb = {
|
|
14
|
+
text: string;
|
|
15
|
+
href: string;
|
|
16
|
+
};
|
|
17
|
+
/** @deprecated Use `IBreadcrumb` — former Elements export name. */
|
|
18
|
+
export type IBreadcrumbItem = IBreadcrumb;
|
|
19
|
+
/** @deprecated Use `IBreadcrumb` — former React export name (singular type, plural alias). */
|
|
20
|
+
export type IBreadcrumbs = IBreadcrumb;
|
|
21
|
+
/** Shared breadcrumbs props for React, Elements, and typed specs. */
|
|
22
|
+
export type IPktBreadcrumbsBase = IPktStringsProps & {
|
|
23
|
+
breadcrumbs: IBreadcrumb[];
|
|
24
|
+
};
|
|
25
|
+
/** Documented props for typed component specs. */
|
|
26
|
+
export type IBreadcrumbsSpecProps = Pick<IPktBreadcrumbsBase, 'breadcrumbs'> & {
|
|
27
|
+
navigationType?: TBreadcrumbsNavigationType;
|
|
28
|
+
/**
|
|
29
|
+
* React-only custom link renderer (e.g. Next.js Link).
|
|
30
|
+
* When set, `navigationType` is effectively `router`.
|
|
31
|
+
*/
|
|
32
|
+
renderLink?: TRenderLink;
|
|
33
|
+
};
|
|
@@ -4,8 +4,16 @@
|
|
|
4
4
|
* Type definitions for the fileupload component.
|
|
5
5
|
* Used by both Elements and React implementations.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import type { IFormFieldCommonProps, TFormFieldCommonSpecKeys } from './form-field';
|
|
8
|
+
/** Upload strategy variants — shared runtime source for types, specs, and Preview. */
|
|
9
|
+
export declare const UPLOAD_STRATEGIES: readonly ['form', 'custom'];
|
|
10
|
+
export type TUploadStrategy = (typeof UPLOAD_STRATEGIES)[number];
|
|
11
|
+
/** Queue item renderer variants — shared runtime source for types, specs, and Preview. */
|
|
12
|
+
export declare const FILE_UPLOAD_ITEM_RENDERERS: readonly ['filename', 'thumbnail'];
|
|
13
|
+
export type TFileUploadItemRenderer = (typeof FILE_UPLOAD_ITEM_RENDERERS)[number];
|
|
14
|
+
/** Preview-only upload status display — used in docs demo props. */
|
|
15
|
+
export declare const PREVIEW_UPLOAD_STATUS: readonly ['progressbar', 'text'];
|
|
16
|
+
export type TPreviewUploadStatus = (typeof PREVIEW_UPLOAD_STATUS)[number];
|
|
9
17
|
export type TFilesChangedReason = 'add' | 'remove' | 'update';
|
|
10
18
|
export type TFileValidator = (file: File) => string | null;
|
|
11
19
|
export type TTransferProgress = number | 'done' | 'error' | 'canceled' | 'queued';
|
|
@@ -44,3 +52,49 @@ export interface IFilesChangedDetail {
|
|
|
44
52
|
reason: TFilesChangedReason;
|
|
45
53
|
changedFileIds?: string[];
|
|
46
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Framework-agnostic FileUpload props shared by React, Elements, and typed specs.
|
|
57
|
+
*
|
|
58
|
+
* @remarks React widens `helptext`, `helptextDropdown`, `itemRenderer`, and `extraOperations`
|
|
59
|
+
* in `FileUpload.tsx`. Elements adds `id`, `accept`, and uses events instead of some callbacks.
|
|
60
|
+
*/
|
|
61
|
+
export interface IPktFileUploadBase extends IFormFieldCommonProps {
|
|
62
|
+
/** Field name. Used for native input (`form`) or hidden ID inputs (`custom`). */
|
|
63
|
+
name: string;
|
|
64
|
+
required?: boolean;
|
|
65
|
+
value?: IFileItem[];
|
|
66
|
+
defaultValue?: IFileItem[];
|
|
67
|
+
/** React callback — Elements uses the `files-changed` event instead. */
|
|
68
|
+
onFilesChanged?: (files: IFileItem[]) => void;
|
|
69
|
+
uploadStrategy?: TUploadStrategy;
|
|
70
|
+
multiple?: boolean;
|
|
71
|
+
itemRenderer?: TFileUploadItemRenderer;
|
|
72
|
+
allowedFormats?: string[];
|
|
73
|
+
formatErrorMessage?: string;
|
|
74
|
+
maxFileSize?: string | number;
|
|
75
|
+
onFileValidation?: TFileValidator;
|
|
76
|
+
/**
|
|
77
|
+
* Low-level validation escape hatch — Lit parity with the `file-validate` event.
|
|
78
|
+
* React: callback prop. Elements: listen for `file-validate` and mutate `detail.errorMessage`.
|
|
79
|
+
*/
|
|
80
|
+
onFileValidate?: (detail: IFileValidateDetail) => void;
|
|
81
|
+
sizeErrorMessage?: string;
|
|
82
|
+
addCommentsEnabled?: boolean;
|
|
83
|
+
enableImagePreview?: boolean;
|
|
84
|
+
/** Experimental queue operations — typed per framework in React/Elements. */
|
|
85
|
+
extraOperations?: unknown[];
|
|
86
|
+
fullwidth?: boolean;
|
|
87
|
+
/** React callback — Elements uses the `file-upload-requested` event instead. */
|
|
88
|
+
onFileUploadRequested?: (fileItem: IFileItem) => void;
|
|
89
|
+
/** React callback — Elements uses the `transfer-cancelled` event instead. */
|
|
90
|
+
onTransferCancelled?: (fileItemId: string) => void;
|
|
91
|
+
renameFilesEnabled?: boolean;
|
|
92
|
+
transfers?: IFileTransfer[];
|
|
93
|
+
truncateTail?: number;
|
|
94
|
+
}
|
|
95
|
+
/** Documented props for typed component specs — subset of base + docs-only demo props. */
|
|
96
|
+
export type IFileUploadSpecProps = Pick<IPktFileUploadBase, TFormFieldCommonSpecKeys | 'name' | 'required' | 'value' | 'defaultValue' | 'onFilesChanged' | 'uploadStrategy' | 'multiple' | 'itemRenderer' | 'allowedFormats' | 'formatErrorMessage' | 'maxFileSize' | 'onFileValidation' | 'onFileValidate' | 'sizeErrorMessage' | 'addCommentsEnabled' | 'enableImagePreview' | 'extraOperations' | 'fullwidth' | 'onFileUploadRequested' | 'onTransferCancelled' | 'renameFilesEnabled' | 'transfers' | 'truncateTail'> & {
|
|
97
|
+
previewUploadIntervalMs?: number;
|
|
98
|
+
previewSimulateUploadError?: boolean;
|
|
99
|
+
previewUploadStatus?: TPreviewUploadStatus;
|
|
100
|
+
};
|
|
@@ -90,6 +90,16 @@ export interface IPktFooterSimpleProps<IconType = string> extends IPktFooterBase
|
|
|
90
90
|
/** Custom links shown as a compact row in the secondary (grey) footer. */
|
|
91
91
|
links?: IPktFooterLink[];
|
|
92
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Documented FooterSimple props (subset of `IPktFooterSimpleProps`).
|
|
95
|
+
* Used for typed component specs in documentation.
|
|
96
|
+
*/
|
|
97
|
+
export type IFooterSimpleSpecProps = Pick<IPktFooterSimpleProps, 'links' | 'skipGlobal' | 'data' | 'dataUrl' | 'locale' | 'openLinksInNewTab' | 'includeConsent' | 'googleAnalyticsId' | 'hotjarId'>;
|
|
98
|
+
/**
|
|
99
|
+
* Documented Footer props (subset of `IPktFooterProps`).
|
|
100
|
+
* Used for typed component specs in documentation.
|
|
101
|
+
*/
|
|
102
|
+
export type IFooterSpecProps = Pick<IPktFooterProps, 'columns' | 'skipGlobal' | 'data' | 'dataUrl' | 'locale' | 'openLinksInNewTab' | 'includeConsent' | 'googleAnalyticsId' | 'hotjarId'>;
|
|
93
103
|
/** Historical defaults for the deprecated link props — used to detect explicit overrides. */
|
|
94
104
|
export declare const DEFAULT_FOOTER_PERSONVERN_URL = "https://www.oslo.kommune.no/personvern-og-informasjonskapsler/";
|
|
95
105
|
export declare const DEFAULT_FOOTER_TILGJENGELIGHET_URL = "https://www.oslo.kommune.no/tilgjengelighet/";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* form-field.ts
|
|
3
|
+
*
|
|
4
|
+
* Reusable prop slices for form-field components (input-wrapper, fileupload, etc.).
|
|
5
|
+
* Compose slices into `IFormFieldCommonProps`, then extend with component-specific props.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* IPktInputWrapperBase = IFormFieldCommonProps & { forId, counter, … }
|
|
9
|
+
* IPktFileUploadBase = IFormFieldCommonProps & { name, uploadStrategy, … }
|
|
10
|
+
*/
|
|
11
|
+
import type { IPktStringsProps } from '../shared-strings';
|
|
12
|
+
/** Expandable helptext props used by pkt-input-wrapper and several form controls. */
|
|
13
|
+
export type IHelptextProps = {
|
|
14
|
+
helptext?: string;
|
|
15
|
+
helptextDropdown?: string;
|
|
16
|
+
/** @deprecated Bruk `strings={{ forms: { readMore: '…' } }}` eller `setPktStrings()`. */
|
|
17
|
+
helptextDropdownButton?: string;
|
|
18
|
+
};
|
|
19
|
+
/** Optional/required tag labelling shared by pkt-input-wrapper and form controls. */
|
|
20
|
+
export type ITagOptionalRequiredProps = {
|
|
21
|
+
tagText?: string | null;
|
|
22
|
+
optionalTag?: boolean;
|
|
23
|
+
/** @deprecated Bruk `strings={{ forms: { optional: '…' } }}` eller `setPktStrings()`. */
|
|
24
|
+
optionalText?: string;
|
|
25
|
+
requiredTag?: boolean;
|
|
26
|
+
/** @deprecated Bruk `strings={{ forms: { required: '…' } }}` eller `setPktStrings()`. */
|
|
27
|
+
requiredText?: string;
|
|
28
|
+
};
|
|
29
|
+
/** Label prop shared by pkt-input-wrapper and form controls that use PktInputWrapper. */
|
|
30
|
+
export type IFormFieldLabelProps = {
|
|
31
|
+
label?: string;
|
|
32
|
+
};
|
|
33
|
+
/** Error/disabled state shared by pkt-input-wrapper and form controls. */
|
|
34
|
+
export type IFormFieldErrorProps = {
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
hasError?: boolean;
|
|
37
|
+
errorMessage?: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Shared form-field props — helptext, tags, label, error state, and `strings`.
|
|
41
|
+
* Input-wrapper adds wrapper-only props (forId, counter, inline, …) on top of this.
|
|
42
|
+
*/
|
|
43
|
+
export type IFormFieldCommonProps = IHelptextProps & ITagOptionalRequiredProps & IFormFieldLabelProps & IFormFieldErrorProps & IPktStringsProps;
|
|
44
|
+
/** Keys from `IFormFieldCommonProps` — reuse in `I*SpecProps` Pick unions across form components. */
|
|
45
|
+
export type TFormFieldCommonSpecKeys = keyof IFormFieldCommonProps;
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import type { Representing, TLogOutButtonPlacement, THeaderPosition, THeaderScrollBehavior, User, UserMenuItem } from './header';
|
|
18
18
|
export type THeaderMenuLocale = 'nb-NO' | 'en-GB' | (string & {});
|
|
19
|
+
/** Documented locale keys — shared runtime source for specs and Preview dropdowns. */
|
|
20
|
+
export declare const HEADER_MENU_LOCALES: readonly ['nb-NO', 'en-GB'];
|
|
19
21
|
/** Plain link without an icon. */
|
|
20
22
|
export interface IHeaderMenuLink {
|
|
21
23
|
text: string;
|
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
export type { Booleanish } from './booleanish';
|
|
2
2
|
export { booleanishConverter, nullableBooleanishConverter } from './booleanish';
|
|
3
|
-
export type
|
|
3
|
+
export { ARIA_LIVE_VALUES, type TAriaBoolean, type TAriaBooleanMixed, type TAriaCurrent, type TAriaHasPopup, type TAriaInvalid, type TAriaLive, type TAriaRelevant, type TAriaSort, type TAriaAutoComplete, type TAriaOrientation, type IAriaAttributes, type TAlertRole, } from './aria';
|
|
4
|
+
export { ALERT_SKINS, ALERT_SIZES, type TAlertSkin, type TAlertSize, type IAlertSpecProps, } from './alert';
|
|
4
5
|
export type { THeadingLevel, THeadingSize, THeadingWeight } from './heading';
|
|
5
6
|
export type { User, Representing, UserMenuItem, InternalMenuItemBase, InternalMenuLink, InternalMenuButton, TInternalMenuItem, TSlotMenuVariant, THeaderMenu, TLogOutButtonPlacement, THeaderPosition, THeaderScrollBehavior, } from './header';
|
|
6
7
|
export { convertUserMenuItem } from './header';
|
|
8
|
+
export { HEADER_MENU_LOCALES, DEFAULT_HEADER_FOOTER_URL, DEFAULT_HEADER_LOGO_LINK, } from './header-footer';
|
|
7
9
|
export type { THeaderMenuLocale, IHeaderMenuLink, IHeaderMenuIconLink, IHeaderMenuButton, IHeaderMenuServices, IHeaderMenuSection, IMegaMenu, IHeaderFooter, IHeaderFooterLocaleData, THeaderFooterApi, IPktHeaderMenu, IPktHeaderGlobal, } from './header-footer';
|
|
8
|
-
export {
|
|
9
|
-
export type { IPktFooterLink, IPktFooterColumn, IPktFooterSocialLink, IPktFooterBase, IPktFooterProps, IPktFooterSimpleProps, } from './footer';
|
|
10
|
+
export type { IPktFooterLink, IPktFooterColumn, IPktFooterSocialLink, IPktFooterBase, IPktFooterProps, IPktFooterSimpleProps, IFooterSimpleSpecProps, IFooterSpecProps, } from './footer';
|
|
10
11
|
export { DEFAULT_FOOTER_PERSONVERN_URL, DEFAULT_FOOTER_TILGJENGELIGHET_URL } from './footer';
|
|
11
12
|
export type { TLayout, TVerticalPosition, THorizontalPosition, TPosition, TPositionWithCenter, } from './layout';
|
|
12
13
|
export type { THTMLButtonType, TSelectionMode } from './form';
|
|
13
14
|
export type { TPktInputSize, TSize3, TSize5, TSize7 } from './size';
|
|
14
|
-
export
|
|
15
|
+
export { ACCORDION_SKINS } from './accordion';
|
|
16
|
+
export type { TAccordionSkin, IPktAccordionBase, IPktAccordionItemBase, IAccordionSpecProps, IAccordionItemSpecProps, IAccordionVisualProps, } from './accordion';
|
|
17
|
+
export type { IPktBackLinkBase, IBacklinkSpecProps } from './backlink';
|
|
18
|
+
export { BREADCRUMBS_NAVIGATION_TYPES } from './breadcrumbs';
|
|
19
|
+
export type { TBreadcrumbsNavigationType, IBreadcrumb, IBreadcrumbItem, IBreadcrumbs, IPktBreadcrumbsBase, IBreadcrumbsSpecProps, } from './breadcrumbs';
|
|
20
|
+
export type { IRenderLink, TRenderLink } from './render-link';
|
|
21
|
+
export type { IPktStringsProps } from '../shared-strings';
|
|
22
|
+
export type { IHelptextProps, ITagOptionalRequiredProps, IFormFieldLabelProps, IFormFieldErrorProps, IFormFieldCommonProps, TFormFieldCommonSpecKeys, } from './form-field';
|
|
23
|
+
export type { TMessageboxSkin, TCardSkin, TTagSkin } from './skin';
|
|
15
24
|
export type { IDateConstraints, ICalendarGridDimensions, IGridCellPosition, TDateRangeMap, ISelectionState, ISelectionOptions, } from './calendar';
|
|
16
25
|
export type { IDatepickerStrings } from './datepicker';
|
|
17
26
|
export { defaultSingleStrings, defaultRangeStrings } from './datepicker';
|
|
@@ -21,4 +30,5 @@ export type { TProgressbarRole, TProgressbarSkin, TProgressbarStatusPlacement, T
|
|
|
21
30
|
export type { IPktComboboxOption, TPktComboboxTagSkin, TPktComboboxDisplayValue, TPktComboboxTagPlacement, } from './combobox';
|
|
22
31
|
export type { IPktSelectOption, TSelectOption } from './select';
|
|
23
32
|
export type { TPktSearchInputAppearance, TPktSearchInputMethod, IPktSearchInputSuggestion, IPktSearchInput, } from './searchinput';
|
|
24
|
-
export
|
|
33
|
+
export { UPLOAD_STRATEGIES, FILE_UPLOAD_ITEM_RENDERERS, PREVIEW_UPLOAD_STATUS, } from './fileupload';
|
|
34
|
+
export type { TUploadStrategy as TFileUploadStrategy, TFileUploadItemRenderer, TPreviewUploadStatus, TFilesChangedReason, TFileValidator, TTransferProgress, IFileItem, IFileTransfer, IFileValidateDetail, ITransferCancelledDetail, IFilesChangedDetail, IFileUploadSpecProps, IPktFileUploadBase, } from './fileupload';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* render-link.ts
|
|
3
|
+
*
|
|
4
|
+
* Shared React `renderLink` callback shape used by Link, BackLink, and Breadcrumbs.
|
|
5
|
+
* Elements components do not expose this prop.
|
|
6
|
+
*/
|
|
7
|
+
/** Object passed to a custom link renderer (`renderLink` prop). */
|
|
8
|
+
export type IRenderLink<TChildren = unknown, TAnchorProps = Record<string, unknown>> = {
|
|
9
|
+
href: string;
|
|
10
|
+
className: string;
|
|
11
|
+
/** Link label/content — typically `ReactNode` in `@oslokommune/punkt-react`. */
|
|
12
|
+
children: TChildren;
|
|
13
|
+
/** Remaining anchor attributes spread onto the rendered link. */
|
|
14
|
+
props: TAnchorProps;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* React-only callback to render a custom link component (Next.js Link, React Router, etc.).
|
|
18
|
+
*
|
|
19
|
+
* @typeParam TReturn — Return value / children type (typically `ReactNode`).
|
|
20
|
+
* @typeParam TAnchorProps — Anchor attribute bag passed in `args.props`.
|
|
21
|
+
*/
|
|
22
|
+
export type TRenderLink<TReturn = unknown, TAnchorProps = Record<string, unknown>> = (args: IRenderLink<TReturn, TAnchorProps>) => TReturn;
|
|
@@ -5,19 +5,12 @@
|
|
|
5
5
|
* Only includes skin types that are identical across packages.
|
|
6
6
|
* Component-specific skin types should remain in their respective component files.
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* Used for semantic color coding of alerts (error, success, warning, info)
|
|
11
|
-
*/
|
|
12
|
-
export type TAlertSkin = 'error' | 'success' | 'warning' | 'info';
|
|
8
|
+
export { ALERT_SKINS, type TAlertSkin } from './alert';
|
|
9
|
+
export { ACCORDION_SKINS, type TAccordionSkin } from './accordion';
|
|
13
10
|
/**
|
|
14
11
|
* Messagebox component skin variants
|
|
15
12
|
*/
|
|
16
13
|
export type TMessageboxSkin = 'beige' | 'blue' | 'red' | 'green';
|
|
17
|
-
/**
|
|
18
|
-
* Accordion component skin variants
|
|
19
|
-
*/
|
|
20
|
-
export type TAccordionSkin = 'borderless' | 'outlined' | 'beige' | 'blue' | 'plus-minus';
|
|
21
14
|
/**
|
|
22
15
|
* Card component skin variants
|
|
23
16
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.1.0",
|
|
4
4
|
"description": "React komponentbibliotek til Punkt, et designsystem laget av Oslo Origo",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo Origo",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
103
103
|
},
|
|
104
104
|
"license": "MIT",
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "087459aca13f8ff3a34afc42f8e1cd73900d4896"
|
|
106
106
|
}
|
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import { createContext, forwardRef, ReactNode, useContext } from 'react'
|
|
4
|
-
import type { TAccordionSkin } from 'shared-types'
|
|
4
|
+
import type { IPktAccordionBase, TAccordionSkin } from 'shared-types'
|
|
5
5
|
|
|
6
6
|
export type TPktAccordionSkin = TAccordionSkin
|
|
7
7
|
|
|
8
|
-
export interface IPktAccordion {
|
|
9
|
-
compact?: boolean
|
|
10
|
-
/**
|
|
11
|
-
* @default skin: "borderless"
|
|
12
|
-
*/
|
|
13
|
-
skin?: TPktAccordionSkin
|
|
14
|
-
/**
|
|
15
|
-
* @description A unique identifier to connect the accordion with a heading
|
|
16
|
-
*/
|
|
17
|
-
ariaLabelledBy?: string
|
|
8
|
+
export interface IPktAccordion extends IPktAccordionBase {
|
|
18
9
|
children?: ReactNode
|
|
19
|
-
name?: string
|
|
20
10
|
className?: string
|
|
21
11
|
}
|
|
22
12
|
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import { forwardRef, type MouseEvent, type ReactNode, type SyntheticEvent, useState } from 'react'
|
|
4
|
-
import type { TAccordionSkin } from 'shared-types'
|
|
4
|
+
import type { IPktAccordionItemBase, TAccordionSkin } from 'shared-types'
|
|
5
5
|
|
|
6
6
|
import { PktIcon } from '../icon/Icon'
|
|
7
7
|
import { useAccordionContext } from './Accordion'
|
|
8
8
|
|
|
9
9
|
export type TPktAccordionSkin = TAccordionSkin
|
|
10
10
|
|
|
11
|
-
export interface IPktAccordionItem {
|
|
12
|
-
defaultOpen?: boolean
|
|
13
|
-
id: string
|
|
11
|
+
export interface IPktAccordionItem extends Omit<IPktAccordionItemBase, 'title'> {
|
|
14
12
|
title: string | ReactNode
|
|
15
|
-
skin?: TPktAccordionSkin
|
|
16
|
-
compact?: boolean
|
|
17
|
-
isOpen?: boolean
|
|
18
13
|
children?: ReactNode
|
|
19
|
-
name?: string
|
|
20
14
|
className?: string
|
|
21
15
|
onClick?: (e: MouseEvent<HTMLDetailsElement>) => void
|
|
22
16
|
onToggle?: (e: SyntheticEvent<HTMLDetailsElement>) => void
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
import { FC, HTMLAttributes, ReactElement, ReactNode, useCallback, useState } from 'react'
|
|
5
|
-
import type { TAlertRole, TAlertSkin, TAriaLive } from 'shared-types'
|
|
5
|
+
import type { TAlertRole, TAlertSkin, TAlertSize, TAriaLive } from 'shared-types'
|
|
6
|
+
import { formatString, type IPktStringsProps } from 'shared-strings'
|
|
6
7
|
|
|
7
8
|
import { PktButton } from '../button/Button'
|
|
8
9
|
import { PktIcon } from '../icon/Icon'
|
|
10
|
+
import { usePktStrings } from '../../hooks/usePktStrings'
|
|
9
11
|
|
|
10
|
-
export interface IPktAlert
|
|
12
|
+
export interface IPktAlert
|
|
13
|
+
extends Omit<HTMLAttributes<HTMLDivElement>, 'title'>, IPktStringsProps {
|
|
11
14
|
skin?: TAlertSkin
|
|
12
15
|
closeAlert?: boolean
|
|
13
16
|
title?: ReactNode
|
|
@@ -23,7 +26,7 @@ export interface IPktAlert extends Omit<HTMLAttributes<HTMLDivElement>, 'title'>
|
|
|
23
26
|
*
|
|
24
27
|
* @default medium
|
|
25
28
|
*/
|
|
26
|
-
size?:
|
|
29
|
+
size?: TAlertSize
|
|
27
30
|
onClose?: (e: CustomEvent) => void
|
|
28
31
|
}
|
|
29
32
|
|
|
@@ -41,9 +44,11 @@ export const PktAlert: FC<IPktAlert> = ({
|
|
|
41
44
|
role = 'status',
|
|
42
45
|
skin = 'info' as TAlertSkin,
|
|
43
46
|
className,
|
|
47
|
+
strings,
|
|
44
48
|
...props
|
|
45
49
|
}: IPktAlert): ReactElement => {
|
|
46
50
|
const [isClosed, setIsClosed] = useState(false)
|
|
51
|
+
const s = usePktStrings(['generic', 'alert'], strings)
|
|
47
52
|
|
|
48
53
|
const classes = {
|
|
49
54
|
'pkt-alert': true,
|
|
@@ -87,7 +92,7 @@ export const PktAlert: FC<IPktAlert> = ({
|
|
|
87
92
|
variant="icon-only"
|
|
88
93
|
onClick={onClose}
|
|
89
94
|
>
|
|
90
|
-
<span className="sr-only">
|
|
95
|
+
<span className="sr-only">{s.generic.close}</span>
|
|
91
96
|
</PktButton>
|
|
92
97
|
</div>
|
|
93
98
|
)}
|
|
@@ -95,7 +100,9 @@ export const PktAlert: FC<IPktAlert> = ({
|
|
|
95
100
|
|
|
96
101
|
<div className="pkt-alert__text">{children}</div>
|
|
97
102
|
|
|
98
|
-
{date &&
|
|
103
|
+
{date && (
|
|
104
|
+
<div className="pkt-alert__date">{formatString(s.alert.lastUpdated, { date })}</div>
|
|
105
|
+
)}
|
|
99
106
|
</div>
|
|
100
107
|
</div>
|
|
101
108
|
)
|
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import { AnchorHTMLAttributes, forwardRef, ReactNode, Ref } from 'react'
|
|
4
|
+
import type { IPktBackLinkBase, TRenderLink } from 'shared-types'
|
|
4
5
|
|
|
5
6
|
import { PktIcon } from '../icon/Icon'
|
|
6
7
|
import { usePktStrings } from '../../hooks/usePktStrings'
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
href?: string
|
|
14
|
-
text?: string
|
|
15
|
-
ariaLabel?: string
|
|
16
|
-
renderLink?: (args: {
|
|
17
|
-
href: string
|
|
18
|
-
className: string
|
|
19
|
-
children: ReactNode
|
|
20
|
-
props: AnchorHTMLAttributes<HTMLAnchorElement>
|
|
21
|
-
}) => ReactNode
|
|
8
|
+
|
|
9
|
+
export interface IPktBackLink
|
|
10
|
+
extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>,
|
|
11
|
+
IPktBackLinkBase {
|
|
12
|
+
renderLink?: TRenderLink<ReactNode, AnchorHTMLAttributes<HTMLAnchorElement>>
|
|
22
13
|
ref?: Ref<HTMLElement>
|
|
23
14
|
}
|
|
24
15
|
|
|
@@ -46,7 +37,7 @@ export const PktBackLink = forwardRef<HTMLElement, IPktBackLink>(
|
|
|
46
37
|
const classes = ['pkt-back-link', className].filter(Boolean).join(' ')
|
|
47
38
|
|
|
48
39
|
return (
|
|
49
|
-
<nav className={classes} aria-label={ariaLabel
|
|
40
|
+
<nav className={classes} aria-label={ariaLabel ?? s.backlink.label} ref={ref}>
|
|
50
41
|
{linkRenderer({
|
|
51
42
|
href,
|
|
52
43
|
className: 'pkt-link pkt-link--icon-left',
|
|
@@ -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(
|