@oslokommune/punkt-react 17.1.3 → 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 (95) hide show
  1. package/CHANGELOG.md +35 -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 -10
  6. package/dist/components/breadcrumbs/Breadcrumbs.d.ts +7 -13
  7. package/dist/components/calendar/types.d.ts +14 -12
  8. package/dist/components/checkbox/Checkbox.d.ts +5 -0
  9. package/dist/components/combobox/types.d.ts +5 -0
  10. package/dist/components/consent/strings.d.ts +1 -85
  11. package/dist/components/datepicker/DateTags.d.ts +2 -2
  12. package/dist/components/datepicker/types.d.ts +6 -3
  13. package/dist/components/fileupload/DropZone.d.ts +3 -0
  14. package/dist/components/fileupload/FileUpload.d.ts +9 -61
  15. package/dist/components/header/types.d.ts +5 -0
  16. package/dist/components/index.d.ts +4 -0
  17. package/dist/components/inputwrapper/InputWrapper.d.ts +6 -0
  18. package/dist/components/link/Link.d.ts +2 -6
  19. package/dist/components/radio/RadioButton.d.ts +5 -0
  20. package/dist/components/searchinput/SearchInput.d.ts +4 -0
  21. package/dist/components/select/Select.d.ts +3 -0
  22. package/dist/components/strings/PktStringsProvider.d.ts +21 -0
  23. package/dist/components/strings/strings-override.test.d.ts +1 -0
  24. package/dist/components/tag/Tag.d.ts +3 -0
  25. package/dist/components/textarea/Textarea.d.ts +3 -0
  26. package/dist/components/textinput/Textinput.d.ts +3 -0
  27. package/dist/components/timepicker/types.d.ts +3 -2
  28. package/dist/components/timepicker/useTimepickerState.d.ts +9 -1
  29. package/dist/punkt-react.cjs +1 -1
  30. package/dist/punkt-react.js +2982 -2757
  31. package/dist/shared-strings/consent.d.ts +71 -0
  32. package/dist/shared-strings/format.d.ts +21 -0
  33. package/dist/shared-strings/index.d.ts +14 -0
  34. package/dist/shared-strings/nb.d.ts +121 -0
  35. package/dist/shared-strings/resolve.d.ts +12 -0
  36. package/dist/shared-strings/store.d.ts +27 -0
  37. package/dist/shared-strings/types.d.ts +40 -0
  38. package/dist/shared-types/accordion.d.ts +58 -0
  39. package/dist/shared-types/alert.d.ts +20 -0
  40. package/dist/shared-types/aria.d.ts +2 -1
  41. package/dist/shared-types/backlink.d.ts +23 -0
  42. package/dist/shared-types/breadcrumbs.d.ts +33 -0
  43. package/dist/shared-types/fileupload.d.ts +55 -28
  44. package/dist/shared-types/footer.d.ts +10 -0
  45. package/dist/shared-types/form-field.d.ts +45 -0
  46. package/dist/shared-types/header-footer.d.ts +2 -0
  47. package/dist/shared-types/index.d.ts +15 -6
  48. package/dist/shared-types/render-link.d.ts +22 -0
  49. package/dist/shared-types/skin.d.ts +2 -9
  50. package/dist/shared-utils/combobox/index.d.ts +1 -0
  51. package/dist/shared-utils/combobox/input-utils.d.ts +2 -1
  52. package/dist/shared-utils/combobox/messages.d.ts +7 -0
  53. package/dist/shared-utils/combobox/option-utils.d.ts +2 -1
  54. package/dist/shared-utils/combobox/selection-manager.d.ts +3 -2
  55. package/package.json +4 -4
  56. package/src/components/accordion/Accordion.tsx +2 -12
  57. package/src/components/accordion/AccordionItem.tsx +2 -8
  58. package/src/components/alert/Alert.tsx +12 -5
  59. package/src/components/backlink/BackLink.tsx +12 -12
  60. package/src/components/breadcrumbs/Breadcrumbs.tsx +19 -15
  61. package/src/components/calendar/Calendar.core.test.tsx +7 -5
  62. package/src/components/calendar/types.ts +14 -34
  63. package/src/components/calendar/useCalendarState.ts +16 -2
  64. package/src/components/checkbox/Checkbox.tsx +20 -4
  65. package/src/components/combobox/Combobox.tsx +1 -0
  66. package/src/components/combobox/Listbox.tsx +4 -2
  67. package/src/components/combobox/types.ts +6 -0
  68. package/src/components/combobox/useComboboxState.ts +15 -8
  69. package/src/components/consent/strings.ts +1 -125
  70. package/src/components/datepicker/DateTags.tsx +4 -3
  71. package/src/components/datepicker/Datepicker.accessibility.test.tsx +2 -2
  72. package/src/components/datepicker/Datepicker.tsx +1 -0
  73. package/src/components/datepicker/DatepickerInputs.tsx +6 -6
  74. package/src/components/datepicker/types.ts +6 -3
  75. package/src/components/datepicker/useDatepickerState.ts +4 -5
  76. package/src/components/fileupload/DropZone.tsx +20 -15
  77. package/src/components/fileupload/FileUpload.test.tsx +37 -0
  78. package/src/components/fileupload/FileUpload.tsx +63 -73
  79. package/src/components/header/HeaderGlobal.tsx +5 -2
  80. package/src/components/header/HeaderService.tsx +12 -7
  81. package/src/components/header/types.ts +6 -0
  82. package/src/components/index.ts +10 -0
  83. package/src/components/inputwrapper/InputWrapper.tsx +28 -6
  84. package/src/components/link/Link.tsx +2 -6
  85. package/src/components/radio/RadioButton.tsx +18 -2
  86. package/src/components/searchinput/SearchInput.tsx +13 -3
  87. package/src/components/select/Select.tsx +5 -0
  88. package/src/components/strings/PktStringsProvider.tsx +38 -0
  89. package/src/components/strings/strings-override.test.tsx +130 -0
  90. package/src/components/tag/Tag.tsx +13 -2
  91. package/src/components/textarea/Textarea.tsx +5 -0
  92. package/src/components/textinput/Textinput.tsx +5 -0
  93. package/src/components/timepicker/Timepicker.tsx +1 -0
  94. package/src/components/timepicker/types.ts +3 -2
  95. package/src/components/timepicker/useTimepickerState.ts +20 -22
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Tekster og informasjonskapsel-oppsett for samtykkedialogen.
3
+ *
4
+ * Denne ligger utenfor `nb.ts` fordi formen er en annen: en liste med
5
+ * informasjonskapsler som hver har egne tekster per språk, ikke et flatt
6
+ * namespace. Den deles av Elements og React slik at de to ikke kommer i utakt.
7
+ */
8
+ export declare const consentStrings: {
9
+ i18n: {
10
+ nb: {
11
+ contentPresentation: {
12
+ title: string;
13
+ description: string[];
14
+ buttons: {
15
+ accept: string;
16
+ reject: string;
17
+ settings: string;
18
+ };
19
+ };
20
+ contentSettings: {
21
+ title: string;
22
+ description: string[];
23
+ buttons: {
24
+ back: string;
25
+ save: string;
26
+ };
27
+ };
28
+ };
29
+ en: {
30
+ contentPresentation: {
31
+ title: string;
32
+ description: string[];
33
+ buttons: {
34
+ accept: string;
35
+ reject: string;
36
+ settings: string;
37
+ };
38
+ };
39
+ contentSettings: {
40
+ title: string;
41
+ description: string[];
42
+ buttons: {
43
+ back: string;
44
+ save: string;
45
+ };
46
+ };
47
+ };
48
+ };
49
+ cookies: {
50
+ name: string;
51
+ defaultValue: boolean;
52
+ i18n: {
53
+ nb: {
54
+ title: string;
55
+ description: string;
56
+ buttons: {
57
+ yes: string;
58
+ no: string;
59
+ };
60
+ };
61
+ en: {
62
+ title: string;
63
+ description: string;
64
+ buttons: {
65
+ yes: string;
66
+ no: string;
67
+ };
68
+ };
69
+ };
70
+ }[];
71
+ };
@@ -0,0 +1,21 @@
1
+ import type { TPktStringParams } from './types';
2
+ /**
3
+ * Setter verdier inn i `{navn}`-plassholdere.
4
+ *
5
+ * ```ts
6
+ * formatString('Verdien må være større enn eller lik {min}.', { min: 5 })
7
+ * // → 'Verdien må være større enn eller lik 5.'
8
+ * ```
9
+ *
10
+ * En plassholder uten tilsvarende verdi blir stående urørt, slik at en ufullstendig
11
+ * overstyring gir synlig, feilsøkbar tekst i stedet for et tomt felt.
12
+ */
13
+ export declare function formatString(template: string, params?: TPktStringParams): string;
14
+ /**
15
+ * Velger entalls- eller flertallsform.
16
+ *
17
+ * ```ts
18
+ * plural(count, s.fileLabelOne, s.fileLabelOther)
19
+ * ```
20
+ */
21
+ export declare function plural(count: number, one: string, other: string): string;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Delt tekstkatalog for Punkt.
3
+ *
4
+ * Alle UI-tekster i designsystemet defineres i `nb.ts` og brukes derfra av både
5
+ * `@oslokommune/punkt-elements` og `@oslokommune/punkt-react`. Konsumenter kan
6
+ * overstyre tekster globalt med `setPktStrings()` eller per komponentinstans via
7
+ * `strings`-propen.
8
+ */
9
+ export { nb } from './nb';
10
+ export { formatString, plural } from './format';
11
+ export { getPktStrings, resetPktStrings, setPktStrings, subscribePktStrings } from './store';
12
+ export { resolveNamespace, resolveStrings } from './resolve';
13
+ export type { IPktStringsProps, TPktStringParams, TPktStrings, TPktStringsNamespace, TPktStringsOverride, TPktStringsShape, TPktStringValue, } from './types';
14
+ export { consentStrings } from './consent';
@@ -0,0 +1,121 @@
1
+ export declare const nb: {
2
+ /** Tekster som går igjen på tvers av flere komponenter. */
3
+ generic: {
4
+ from: string;
5
+ to: string;
6
+ close: string;
7
+ };
8
+ /** Etiketter og hjelpetekst rundt skjemafelt. */
9
+ forms: {
10
+ optional: string;
11
+ required: string;
12
+ readMore: string;
13
+ };
14
+ /** Valideringsmeldinger. Nøkkelnavnene følger `ValidityState` der det finnes et tilsvarende flagg. */
15
+ validation: {
16
+ valueMissing: string;
17
+ typeMismatch: string;
18
+ patternMismatch: string;
19
+ tooShort: string;
20
+ tooLong: string;
21
+ rangeUnderflow: string;
22
+ rangeOverflow: string;
23
+ rangeUnderflowMin: string;
24
+ rangeOverflowMax: string;
25
+ stepMismatch: string;
26
+ timeStepMismatch: string;
27
+ timeStepMismatchHour: string;
28
+ timeStepMismatchHalfHour: string;
29
+ dateUnderflow: string;
30
+ dateOverflow: string;
31
+ counterExceeded: string;
32
+ };
33
+ /** Måneds- og dagsnavn. Listene må ha henholdsvis 12 og 7 elementer. */
34
+ dates: {
35
+ month: string;
36
+ year: string;
37
+ week: string;
38
+ days: string[];
39
+ daysShort: string[];
40
+ months: string[];
41
+ monthsShort: string[];
42
+ };
43
+ calendar: {
44
+ prevMonth: string;
45
+ nextMonth: string;
46
+ };
47
+ datepicker: {
48
+ openPicker: string;
49
+ deleteDate: string;
50
+ };
51
+ timepicker: {
52
+ hours: string;
53
+ minutes: string;
54
+ openPicker: string;
55
+ prevTime: string;
56
+ nextTime: string;
57
+ selectTime: string;
58
+ };
59
+ searchinput: {
60
+ placeholder: string;
61
+ submit: string;
62
+ };
63
+ backlink: {
64
+ label: string;
65
+ };
66
+ breadcrumbs: {
67
+ ariaLabel: string;
68
+ };
69
+ alert: {
70
+ lastUpdated: string;
71
+ };
72
+ tag: {
73
+ remove: string;
74
+ };
75
+ header: {
76
+ search: string;
77
+ menu: string;
78
+ openMenu: string;
79
+ openSearch: string;
80
+ };
81
+ listbox: {
82
+ searchLabel: string;
83
+ searchPlaceholder: string;
84
+ };
85
+ combobox: {
86
+ noResults: string;
87
+ maxSelected: string;
88
+ tooManySelected: string;
89
+ alreadySelected: string;
90
+ valueAdded: string;
91
+ noValidValue: string;
92
+ };
93
+ fileupload: {
94
+ dropZoneDragMultiple: string;
95
+ dropZoneDragSingle: string;
96
+ dropZoneDragMultipleThumbnail: string;
97
+ dropZoneDragSingleThumbnail: string;
98
+ dropZoneDragActiveMultiple: string;
99
+ dropZoneDragActiveSingle: string;
100
+ dropZoneDragActiveMultipleThumbnail: string;
101
+ dropZoneDragActiveSingleThumbnail: string;
102
+ dropZoneOpenFileDialogMultiple: string;
103
+ dropZoneOpenFileDialogSingle: string;
104
+ dropZoneOpenFileDialogMultipleThumbnail: string;
105
+ dropZoneOpenFileDialogSingleThumbnail: string;
106
+ supportedFormatsPrefix: string;
107
+ invalidFormat: string;
108
+ sizeTooLarge: string;
109
+ requiredMissing: string;
110
+ genericValidationRejection: string;
111
+ unknownFilename: string;
112
+ previewFallbackName: string;
113
+ previewImage: string;
114
+ fileLabelOne: string;
115
+ fileLabelOther: string;
116
+ srFileAdded: string;
117
+ srFilesAdded: string;
118
+ srFilesUploadedOfTotal: string;
119
+ srFilesFailedOfTotal: string;
120
+ };
121
+ };
@@ -0,0 +1,12 @@
1
+ import type { TPktStrings, TPktStringsNamespace, TPktStringsOverride } from './types';
2
+ /** Slår opp ett namespace. */
3
+ export declare function resolveNamespace<K extends TPktStringsNamespace>(ns: K, ...layers: Array<TPktStringsOverride | undefined>): TPktStrings[K];
4
+ /**
5
+ * Slår opp flere namespace på én gang.
6
+ *
7
+ * ```ts
8
+ * const s = resolveStrings(['forms', 'validation'], this.strings)
9
+ * s.forms.optional
10
+ * ```
11
+ */
12
+ export declare function resolveStrings<NS extends TPktStringsNamespace>(namespaces: readonly NS[], ...layers: Array<TPktStringsOverride | undefined>): Pick<TPktStrings, NS>;
@@ -0,0 +1,27 @@
1
+ import type { TPktStringsOverride } from './types';
2
+ /**
3
+ * Global tekstoverstyring. Tilstanden ligger på `globalThis` bak en
4
+ * `Symbol.for()`-nøkkel, slik at `punkt-react` og `punkt-elements` deler én og
5
+ * samme store på tvers av modulgrafer.
6
+ */
7
+ type TListener = () => void;
8
+ /**
9
+ * Overstyrer tekster for hele applikasjonen. Kall det én gang ved oppstart.
10
+ * Flere kall merges sammen, namespace for namespace.
11
+ *
12
+ * ```ts
13
+ * setPktStrings({ forms: { optional: 'Frivillig' } })
14
+ * ```
15
+ */
16
+ export declare function setPktStrings(overrides: TPktStringsOverride): void;
17
+ /**
18
+ * Gjeldende globale overstyringer. Identiteten endrer seg ved hvert
19
+ * `setPktStrings()`-kall, så den kan brukes direkte som snapshot i
20
+ * `useSyncExternalStore`.
21
+ */
22
+ export declare function getPktStrings(): TPktStringsOverride;
23
+ /** Nullstiller til de innebygde tekstene. Ment for tester. */
24
+ export declare function resetPktStrings(): void;
25
+ /** Abonnerer på endringer. Returnerer en funksjon som melder av. */
26
+ export declare function subscribePktStrings(listener: TListener): () => void;
27
+ export {};
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Typene for tekstkatalogen. Katalogen er nøyaktig to nivåer dyp:
3
+ * namespace → nøkkel → string | string[].
4
+ */
5
+ import type { nb } from './nb';
6
+ /** En enkelt tekstverdi. Lister brukes for måneds- og dagsnavn. */
7
+ export type TPktStringValue = string | readonly string[];
8
+ /** Formen alle språkbundler må følge. */
9
+ export type TPktStringsShape = Record<string, Record<string, TPktStringValue>>;
10
+ /**
11
+ * Hele katalogen, utledet fra bokmålsbundelen slik at `nb.ts` er det eneste
12
+ * stedet en nøkkel defineres.
13
+ */
14
+ export type TPktStrings = typeof nb;
15
+ /** Navnet på et namespace i katalogen, f.eks. `'forms'` eller `'searchinput'`. */
16
+ export type TPktStringsNamespace = keyof TPktStrings;
17
+ /**
18
+ * Delvis overstyring av katalogen. Generisk over namespace slik at en komponent
19
+ * kan smalne typen til de namespacene den faktisk bruker:
20
+ *
21
+ * ```ts
22
+ * strings?: TPktStringsOverride<'forms' | 'validation' | 'searchinput'>
23
+ * ```
24
+ */
25
+ export type TPktStringsOverride<NS extends TPktStringsNamespace = TPktStringsNamespace> = {
26
+ [K in NS]?: Partial<TPktStrings[K]>;
27
+ };
28
+ /** Verdier som kan settes inn i en `{plassholder}`. */
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 type TAriaLive = 'off' | 'polite' | 'assertive';
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
- export type TUploadStrategy = 'form' | 'custom';
8
- export type TFileUploadItemRenderer = 'filename' | 'thumbnail';
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,30 +52,49 @@ export interface IFilesChangedDetail {
44
52
  reason: TFilesChangedReason;
45
53
  changedFileIds?: string[];
46
54
  }
47
- /** Default Norwegian Bokmål strings used by both implementations. */
48
- export interface IFileUploadStrings {
49
- dropZoneDragMultiple: string;
50
- dropZoneDragSingle: string;
51
- dropZoneDragMultipleThumbnail: string;
52
- dropZoneDragSingleThumbnail: string;
53
- dropZoneDragActiveMultiple: string;
54
- dropZoneDragActiveSingle: string;
55
- dropZoneDragActiveMultipleThumbnail: string;
56
- dropZoneDragActiveSingleThumbnail: string;
57
- dropZoneOpenFileDialogMultiple: string;
58
- dropZoneOpenFileDialogSingle: string;
59
- dropZoneOpenFileDialogMultipleThumbnail: string;
60
- dropZoneOpenFileDialogSingleThumbnail: string;
61
- supportedFormatsPrefix: string;
62
- invalidFormatDefault: (formats: string) => string;
63
- sizeTooLargeDefault: (maxSize: string) => string;
64
- requiredMissing: string;
65
- genericValidationRejection: string;
66
- unknownFilename: string;
67
- fileLabel: (count: number) => string;
68
- srFileAdded: (filename: string) => string;
69
- srFilesAdded: (count: number) => string;
70
- srFilesUploadedOfTotal: (uploaded: number, total: number, label: string) => string;
71
- srFilesFailedOfTotal: (failed: number, total: number, label: string) => string;
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;
72
94
  }
73
- export declare const defaultFileUploadStrings: IFileUploadStrings;
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;