@oslokommune/punkt-react 20.2.0 → 20.2.2

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 (34) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/components/header/HeaderGlobal.js +148 -146
  3. package/dist/components/header/HeaderService.js +2 -2
  4. package/dist/components/header/types.d.ts +26 -93
  5. package/dist/components/header-menu/HeaderMenu.js +108 -106
  6. package/dist/components/interfaces.d.ts +3 -2
  7. package/dist/components/tabs/TabItem.d.ts +2 -10
  8. package/dist/components/tabs/TabItem.js +62 -60
  9. package/dist/components/tabs/Tabs.d.ts +4 -23
  10. package/dist/components/tabs/Tabs.js +38 -43
  11. package/dist/punkt-react.cjs +1 -1
  12. package/dist/shared-strings/index.d.ts +1 -1
  13. package/dist/shared-strings/nb.d.ts +1 -0
  14. package/dist/shared-strings/nb.js +2 -1
  15. package/dist/shared-strings/resolve.d.ts +9 -0
  16. package/dist/shared-strings/resolve.js +9 -1
  17. package/dist/shared-types/header-footer.d.ts +0 -44
  18. package/dist/shared-types/header.d.ts +214 -10
  19. package/dist/shared-types/header.js +26 -0
  20. package/dist/shared-types/index.d.ts +5 -3
  21. package/dist/shared-types/index.js +24 -22
  22. package/dist/shared-types/tabs.d.ts +66 -0
  23. package/dist/shared-types/tabs.js +12 -0
  24. package/package.json +2 -2
  25. package/src/components/header/HeaderGlobal.test.tsx +82 -0
  26. package/src/components/header/HeaderGlobal.tsx +35 -16
  27. package/src/components/header/HeaderService.tsx +12 -12
  28. package/src/components/header/types.ts +37 -97
  29. package/src/components/header-menu/HeaderMenu.test.tsx +14 -0
  30. package/src/components/header-menu/HeaderMenu.tsx +7 -2
  31. package/src/components/interfaces.ts +3 -2
  32. package/src/components/tabs/TabItem.tsx +18 -12
  33. package/src/components/tabs/Tabs.test.tsx +22 -0
  34. package/src/components/tabs/Tabs.tsx +10 -43
@@ -9,6 +9,6 @@
9
9
  export { nb } from './nb';
10
10
  export { formatString, plural } from './format';
11
11
  export { getPktStrings, resetPktStrings, setPktStrings, subscribePktStrings } from './store';
12
- export { resolveNamespace, resolveStrings } from './resolve';
12
+ export { resolveNamespace, resolveOverride, resolveStrings } from './resolve';
13
13
  export type { IPktStringsProps, TPktStringParams, TPktStrings, TPktStringsNamespace, TPktStringsOverride, TPktStringsShape, TPktStringValue, } from './types';
14
14
  export { consentStrings } from './consent';
@@ -100,6 +100,7 @@ export declare const nb: {
100
100
  changeRepresentation: string;
101
101
  menuLoading: string;
102
102
  menuLoadError: string;
103
+ navAriaLabel: string;
103
104
  };
104
105
  listbox: {
105
106
  searchLabel: string;
@@ -126,7 +126,8 @@ var e = {
126
126
  orgNumber: "Org.nr. {number}",
127
127
  changeRepresentation: "Endre organisasjon",
128
128
  menuLoading: "Laster meny…",
129
- menuLoadError: "Kunne ikke laste meny."
129
+ menuLoadError: "Kunne ikke laste meny.",
130
+ navAriaLabel: "Hovedmeny"
130
131
  },
131
132
  listbox: {
132
133
  searchLabel: "Søk i listen",
@@ -10,3 +10,12 @@ export declare function resolveNamespace<K extends TPktStringsNamespace>(ns: K,
10
10
  * ```
11
11
  */
12
12
  export declare function resolveStrings<NS extends TPktStringsNamespace>(namespaces: readonly NS[], ...layers: Array<TPktStringsOverride | undefined>): Pick<TPktStrings, NS>;
13
+ /**
14
+ * Den overstyrte verdien for én nøkkel, eller `undefined` hvis bare den
15
+ * innebygde teksten finnes. Brukes der en komponent har en annen standardtekst
16
+ * enn katalogen, f.eks. placeholderen i payloaden til den globale headeren, men
17
+ * en overstyring fortsatt skal vinne.
18
+ *
19
+ * Lagene har samme rekkefølge som i `resolveNamespace`.
20
+ */
21
+ export declare function resolveOverride<K extends TPktStringsNamespace, Key extends keyof TPktStrings[K]>(ns: K, key: Key, ...layers: Array<TPktStringsOverride | undefined>): TPktStrings[K][Key] | undefined;
@@ -36,4 +36,12 @@ function s(e, ...t) {
36
36
  for (let r of e) n[r] = o(r, ...t);
37
37
  return n;
38
38
  }
39
- export { o as resolveNamespace, s as resolveStrings };
39
+ function c(e, n, ...r) {
40
+ for (let t of [...r].reverse()) {
41
+ let r = t?.[e]?.[n];
42
+ if (r !== void 0) return r;
43
+ }
44
+ let i = t()[e]?.[n];
45
+ return i === void 0 ? void 0 : i;
46
+ }
47
+ export { o as resolveNamespace, c as resolveOverride, s as resolveStrings };
@@ -14,7 +14,6 @@
14
14
  * `string & {}` escape hatch so additional locales can be added without
15
15
  * a type-level breaking change.
16
16
  */
17
- import type { Representing, TLogOutButtonPlacement, THeaderPosition, THeaderScrollBehavior, User, UserMenuItem } from './header';
18
17
  export type THeaderMenuLocale = 'nb-NO' | 'en-GB' | (string & {});
19
18
  /** Documented locale keys — shared runtime source for specs and Preview dropdowns. */
20
19
  export declare const HEADER_MENU_LOCALES: readonly ['nb-NO', 'en-GB'];
@@ -108,49 +107,6 @@ export interface IPktHeaderMenu<IconType = string> {
108
107
  /** Pixel breakpoint below which sections collapse into accordions. */
109
108
  mobileBreakpoint?: number;
110
109
  }
111
- /**
112
- * Framework-agnostic props for the global (kommune-wide) header
113
- * (`pkt-header-global` / `PktHeaderGlobal`). Elements narrows the
114
- * boolean fields to `Booleanish` and React adds callback/className
115
- * props on top — see each package's `header/types.ts`.
116
- */
117
- export interface IPktHeaderGlobal<IconType = string> {
118
- /** Endpoint to fetch the header/footer payload from. */
119
- dataUrl?: string;
120
- /** Pre-fetched payload. If supplied, the component (and its menu) skips its own fetch. */
121
- data?: THeaderFooterApi<IconType>;
122
- /** Locale key to select from the payload. Defaults to `nb-NO`. */
123
- locale?: THeaderMenuLocale;
124
- /** Logo link URL. When omitted the logo is rendered without a link. */
125
- logoLink?: string;
126
- /** Override the CDN path the logo assets load from. Can also be set
127
- * globally via `window.pktLogoPath`. */
128
- logoPath?: string;
129
- /** Show the search field. Default: true */
130
- showSearch?: boolean;
131
- /** Placeholder for the search field. Falls back to the payload's search placeholder, then 'Søk'. */
132
- searchPlaceholder?: string;
133
- /** Show the contact link (from the payload's `header.contact`). Default: true */
134
- showContact?: boolean;
135
- /** User object for the logged-in user. When set, the user menu is shown. */
136
- user?: User;
137
- /** User menu items. */
138
- userMenu?: UserMenuItem<IconType>[];
139
- /** Representation object. */
140
- representing?: Representing;
141
- /** Allow the user to change representation. */
142
- canChangeRepresentation?: boolean;
143
- /** Logout button placement. */
144
- logOutButtonPlacement?: TLogOutButtonPlacement;
145
- /** Header position. Default: 'fixed' */
146
- position?: THeaderPosition;
147
- /** Scroll behavior. Default: 'hide' */
148
- scrollBehavior?: THeaderScrollBehavior;
149
- /** Width below which the header switches to mobile layout. Default: 768 */
150
- mobileBreakpoint?: number;
151
- /** Width below which the header switches to tablet layout. Default: 1024 */
152
- tabletBreakpoint?: number;
153
- }
154
110
  /** Default URL of the live header/footer endpoint. */
155
111
  export declare const DEFAULT_HEADER_FOOTER_URL = "https://cdn.web.oslo.kommune.no/header-footer/header-footer.json";
156
112
  /** Default logo link for both header variants (unless overridden or hidden). */
@@ -1,16 +1,25 @@
1
1
  /**
2
2
  * header.ts
3
3
  *
4
- * Type definitions for header-related domain models.
5
- * These represent user, organization, and menu item data structures.
4
+ * Type definitions and defaults for the header, shared between
5
+ * @oslokommune/punkt-elements and @oslokommune/punkt-react.
6
+ *
7
+ * The value lists are `as const` arrays rather than plain union types, so the
8
+ * values also exist at runtime and the component spec and Preview can use them
9
+ * directly (`type: [...HEADER_POSITIONS]`). The types are derived from the
10
+ * arrays, so there is a single source.
11
+ *
12
+ * Global-header-specific types and defaults live in `header-footer.ts`.
6
13
  */
14
+ import type { IPktStringsProps } from '../shared-strings';
15
+ import { type THeaderFooterApi, type THeaderMenuLocale } from './header-footer';
7
16
  /**
8
17
  * User object containing information about the logged-in user
9
18
  */
10
19
  export interface User {
11
20
  /** Full name of the user */
12
21
  name: string;
13
- /** Short name or initials (deprecated) */
22
+ /** @deprecated shortname is deprecated and will be removed in a future version */
14
23
  shortname?: string;
15
24
  /** Last login timestamp (ISO string or Date) */
16
25
  lastLoggedIn?: Date | string;
@@ -21,7 +30,7 @@ export interface User {
21
30
  export interface Representing {
22
31
  /** Name of the organization or entity */
23
32
  name: string;
24
- /** Short name or initials (deprecated) */
33
+ /** @deprecated shortname is deprecated and will be removed in a future version */
25
34
  shortname?: string;
26
35
  /** Organization number */
27
36
  orgNumber?: string | number;
@@ -38,6 +47,16 @@ export interface UserMenuItem<IconType = string> {
38
47
  /** Link URL or click handler function */
39
48
  target: string | (() => void);
40
49
  }
50
+ /**
51
+ * Item in the deprecated `userMenuFooter` prop.
52
+ *
53
+ * An alias of {@link UserMenuItem}: React's original type had no `iconName`,
54
+ * while Elements has always accepted full `UserMenuItem`s. The alias keeps
55
+ * both working without narrowing either package.
56
+ *
57
+ * @deprecated Use `userMenu` with `UserMenuItem` instead.
58
+ */
59
+ export type UserMenuFooterItem<IconType = string> = UserMenuItem<IconType>;
41
60
  /**
42
61
  * Internal type for rendering links/buttons (supports both href and onClick)
43
62
  * Base interface for discriminated union
@@ -66,23 +85,208 @@ export type TInternalMenuItem<IconType = string> = InternalMenuLink<IconType> |
66
85
  * Helper to convert UserMenuItem (with target) to internal format
67
86
  */
68
87
  export declare const convertUserMenuItem: <IconType = string>(item: UserMenuItem<IconType>) => TInternalMenuItem<IconType>;
88
+ /**
89
+ * Which header variant `<pkt-header>` / `<PktHeader>` renders: `service` is a
90
+ * customizable header for a single service, `global` is the kommune-wide header.
91
+ * Was defined separately (but identically) in both packages before.
92
+ */
93
+ export declare const HEADER_TYPES: readonly ['service', 'global'];
94
+ export type THeaderType = (typeof HEADER_TYPES)[number];
69
95
  /**
70
96
  * Variant for the slot menu button in tablet/mobile mode
71
97
  */
72
- export type TSlotMenuVariant = 'icon-only' | 'icon-right';
98
+ export declare const SLOT_MENU_VARIANTS: readonly ['icon-only', 'icon-right'];
99
+ export type TSlotMenuVariant = (typeof SLOT_MENU_VARIANTS)[number];
73
100
  /**
74
- * Type for which menu is currently open in the header
101
+ * Which menu is open in the service header
75
102
  */
76
- export type THeaderMenu = 'none' | 'slot' | 'search' | 'user';
103
+ export declare const HEADER_MENUS: readonly ['none', 'slot', 'search', 'user'];
104
+ export type THeaderMenu = (typeof HEADER_MENUS)[number];
77
105
  /**
78
106
  * Placement options for the logout button
79
107
  */
80
- export type TLogOutButtonPlacement = 'userMenu' | 'header' | 'both' | 'none';
108
+ export declare const LOG_OUT_BUTTON_PLACEMENTS: readonly ['userMenu', 'header', 'both', 'none'];
109
+ export type TLogOutButtonPlacement = (typeof LOG_OUT_BUTTON_PLACEMENTS)[number];
81
110
  /**
82
111
  * Position options for the header
83
112
  */
84
- export type THeaderPosition = 'fixed' | 'sticky' | 'relative';
113
+ export declare const HEADER_POSITIONS: readonly ['fixed', 'sticky', 'relative'];
114
+ export type THeaderPosition = (typeof HEADER_POSITIONS)[number];
85
115
  /**
86
116
  * Scroll behavior options for the header
87
117
  */
88
- export type THeaderScrollBehavior = 'hide' | 'none';
118
+ export declare const HEADER_SCROLL_BEHAVIORS: readonly ['hide', 'none'];
119
+ export type THeaderScrollBehavior = (typeof HEADER_SCROLL_BEHAVIORS)[number];
120
+ /**
121
+ * Props both header variants share. Neither component uses this directly: it
122
+ * is the common ground for {@link IPktHeaderServiceBase} and
123
+ * {@link IPktHeaderGlobalBase}, so a shared prop is declared and documented
124
+ * once.
125
+ */
126
+ export interface IPktHeaderCommonBase<IconType = string> extends IPktStringsProps<'header'> {
127
+ /** Logo link URL. Default: `DEFAULT_HEADER_LOGO_LINK`. Set to an empty string to render the logo without a link */
128
+ logoLink?: string;
129
+ /** Override the CDN path for the logo. Can also be set globally via `window.pktLogoPath`. */
130
+ logoPath?: string;
131
+ /** User object for the logged-in user. When set, the user menu is shown */
132
+ user?: User;
133
+ /** User menu items displayed in the dropdown */
134
+ userMenu?: UserMenuItem<IconType>[];
135
+ /** Representation object */
136
+ representing?: Representing;
137
+ /** Whether the user can change representation. Shows the "Endre organisasjon" button. Default: false */
138
+ canChangeRepresentation?: boolean;
139
+ /** Where to show the logout button. Default: 'none' */
140
+ logOutButtonPlacement?: TLogOutButtonPlacement;
141
+ /** Show the search field. Default: false for service, true for global */
142
+ showSearch?: boolean;
143
+ /**
144
+ * Placeholder for the search field. Overrides `header.search` in the string
145
+ * catalogue. Without an override, the service header uses the catalogue and
146
+ * the global header uses the placeholder from the payload.
147
+ * @deprecated Use `strings={{ header: { search: '…' } }}` or `setPktStrings()` instead.
148
+ */
149
+ searchPlaceholder?: string;
150
+ /** Header position. Default: 'fixed' */
151
+ position?: THeaderPosition;
152
+ /** Scroll behavior. 'hide' hides the header on scroll down. Default: 'hide' */
153
+ scrollBehavior?: THeaderScrollBehavior;
154
+ /** Width in pixels below which the header switches to mobile layout. Default: 768 */
155
+ mobileBreakpoint?: number;
156
+ /** Width in pixels below which the header switches to tablet layout. Default: 1280 for service, 1024 for global */
157
+ tabletBreakpoint?: number;
158
+ }
159
+ /**
160
+ * Framework-agnostic props for the service header (`pkt-header-service` /
161
+ * `PktHeaderService`): a customizable header for a single service.
162
+ *
163
+ * Elements narrows the boolean fields to `Booleanish` and adds `hasLogOut`,
164
+ * React adds callbacks, `children`, `className` and the deprecated props.
165
+ */
166
+ export interface IPktHeaderServiceBase<IconType = string> extends IPktHeaderCommonBase<IconType> {
167
+ /** Hide the Oslo logo. Default: false */
168
+ hideLogo?: boolean;
169
+ /** Name of the service displayed in the header */
170
+ serviceName?: string;
171
+ /** Link URL for the service name */
172
+ serviceLink?: string;
173
+ /** Use compact header height. Default: false */
174
+ compact?: boolean;
175
+ /** Controlled value for the search field */
176
+ searchValue?: string;
177
+ /** Which menu is initially open. Default: 'none' */
178
+ openedMenu?: THeaderMenu;
179
+ /** Variant for the slot menu button in tablet/mobile mode. Default: 'icon-only' */
180
+ slotMenuVariant?: TSlotMenuVariant;
181
+ /** Text for the slot menu button. Falls back to `header.menu` in the string catalogue */
182
+ slotMenuText?: string;
183
+ }
184
+ /**
185
+ * Framework-agnostic props for the global (kommune-wide) header
186
+ * (`pkt-header-global` / `PktHeaderGlobal`), whose content comes from the
187
+ * shared header/footer payload.
188
+ *
189
+ * `data` is not generic: the payload's icon names are raw API values that the
190
+ * component maps itself, so only `userMenu` takes `IconType`.
191
+ */
192
+ export interface IPktHeaderGlobalBase<IconType = string> extends IPktHeaderCommonBase<IconType> {
193
+ /** Endpoint to fetch the header/footer payload from. Default: `DEFAULT_HEADER_FOOTER_URL` */
194
+ dataUrl?: string;
195
+ /** Pre-fetched payload. If supplied, the component (and its menu) skips its own fetch. */
196
+ data?: THeaderFooterApi;
197
+ /** Locale key to select from the payload. Default: 'nb-NO' */
198
+ locale?: THeaderMenuLocale;
199
+ /** Show the contact link (from the payload's `header.contact`). Default: true */
200
+ showContact?: boolean;
201
+ }
202
+ /** Props only the global header reads. */
203
+ export type TPktHeaderGlobalOnlyProps = 'dataUrl' | 'data' | 'locale' | 'showContact';
204
+ /**
205
+ * Props for the `pkt-header` / `PktHeader` dispatcher, which renders either
206
+ * variant based on `type`: the service props plus the props only the global
207
+ * header reads.
208
+ *
209
+ * `showSearch` and `tabletBreakpoint` have a different default per variant
210
+ * (false/1280 for service, true/1024 for global). The dispatcher must not set
211
+ * its own default for these, but leave them undefined and let each variant
212
+ * fall back to its own default. A single default here would silently give one
213
+ * of the variants the wrong value.
214
+ */
215
+ export interface IPktHeaderBase<IconType = string> extends IPktHeaderServiceBase<IconType>, Pick<IPktHeaderGlobalBase<IconType>, TPktHeaderGlobalOnlyProps> {
216
+ /** Which header variant to render. Default: 'service' */
217
+ type?: THeaderType;
218
+ }
219
+ /**
220
+ * Props documented in `header.spec.ts`: the dispatcher props, plus props that
221
+ * only exist in one framework and the deprecated props, so SpecList can show
222
+ * them with the right markings.
223
+ */
224
+ export type IHeaderSpecProps = IPktHeaderBase & {
225
+ /** React only. Elements uses the `logo-click` event. */
226
+ logoClick?: (event: MouseEvent) => void;
227
+ /** React only. Elements uses the `service-click` event. */
228
+ serviceClick?: (event: MouseEvent) => void;
229
+ /** Elements only. Tells the element a `log-out` listener is attached. */
230
+ hasLogOut?: boolean;
231
+ /** @deprecated Use `userMenu` instead. */
232
+ userMenuFooter?: UserMenuFooterItem[];
233
+ /** @deprecated Use `userMenu` instead. */
234
+ userOptions?: UserMenuItem[];
235
+ };
236
+ /**
237
+ * Defaults that are the same for both header variants.
238
+ * Spread into `HEADER_SERVICE_DEFAULTS` and `HEADER_GLOBAL_DEFAULTS`, so a
239
+ * shared value can only be changed in one place.
240
+ */
241
+ export declare const HEADER_COMMON_DEFAULTS: {
242
+ readonly logoLink: "https://www.oslo.kommune.no";
243
+ readonly canChangeRepresentation: false;
244
+ readonly logOutButtonPlacement: 'none';
245
+ readonly position: 'fixed';
246
+ readonly scrollBehavior: 'hide';
247
+ readonly mobileBreakpoint: 768;
248
+ };
249
+ /**
250
+ * Defaults for the service header, shared by React and Elements.
251
+ *
252
+ * These used to be hardcoded in each component. `showSearch` and
253
+ * `tabletBreakpoint` differ from the global header, which is why the two
254
+ * variants have separate defaults.
255
+ *
256
+ * Left out on purpose:
257
+ * - `logoPath`: resolved at runtime from `window.pktLogoPath`.
258
+ * - `searchPlaceholder`, `slotMenuText`: fall back to the string catalogue.
259
+ */
260
+ export declare const HEADER_SERVICE_DEFAULTS: {
261
+ readonly logoLink: "https://www.oslo.kommune.no";
262
+ readonly canChangeRepresentation: false;
263
+ readonly logOutButtonPlacement: 'none';
264
+ readonly position: 'fixed';
265
+ readonly scrollBehavior: 'hide';
266
+ readonly mobileBreakpoint: 768;
267
+ readonly type: 'service';
268
+ readonly hideLogo: false;
269
+ readonly compact: false;
270
+ readonly showSearch: false;
271
+ readonly tabletBreakpoint: 1280;
272
+ readonly openedMenu: 'none';
273
+ readonly slotMenuVariant: 'icon-only';
274
+ };
275
+ /**
276
+ * Defaults for the global header, shared by React and Elements.
277
+ *
278
+ * `dataUrl` is left out: when unset, the components fall back to
279
+ * `DEFAULT_HEADER_FOOTER_URL` at fetch time.
280
+ */
281
+ export declare const HEADER_GLOBAL_DEFAULTS: {
282
+ readonly logoLink: "https://www.oslo.kommune.no";
283
+ readonly canChangeRepresentation: false;
284
+ readonly logOutButtonPlacement: 'none';
285
+ readonly position: 'fixed';
286
+ readonly scrollBehavior: 'hide';
287
+ readonly mobileBreakpoint: 768;
288
+ readonly locale: 'nb-NO';
289
+ readonly showSearch: true;
290
+ readonly showContact: true;
291
+ readonly tabletBreakpoint: 1024;
292
+ };
@@ -0,0 +1,26 @@
1
+ import { DEFAULT_HEADER_LOGO_LINK as e } from "./header-footer.js";
2
+ // ../../shared-types/header.ts
3
+ var t = {
4
+ logoLink: e,
5
+ canChangeRepresentation: !1,
6
+ logOutButtonPlacement: "none",
7
+ position: "fixed",
8
+ scrollBehavior: "hide",
9
+ mobileBreakpoint: 768
10
+ }, n = {
11
+ ...t,
12
+ type: "service",
13
+ hideLogo: !1,
14
+ compact: !1,
15
+ showSearch: !1,
16
+ tabletBreakpoint: 1280,
17
+ openedMenu: "none",
18
+ slotMenuVariant: "icon-only"
19
+ }, r = {
20
+ ...t,
21
+ locale: "nb-NO",
22
+ showSearch: !0,
23
+ showContact: !0,
24
+ tabletBreakpoint: 1024
25
+ };
26
+ export { t as HEADER_COMMON_DEFAULTS, r as HEADER_GLOBAL_DEFAULTS, n as HEADER_SERVICE_DEFAULTS };
@@ -5,10 +5,10 @@ export type { TPktSizeBase, TPktSize, TPktInputSize } from './size';
5
5
  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';
6
6
  export { ALERT_SKINS, ALERT_SIZES, ALERT_DEFAULTS, type TAlertSkin, type TAlertSize, type IAlertSpecProps, } from './alert';
7
7
  export type { THeadingLevel, THeadingSize, THeadingWeight } from './heading';
8
- export type { User, Representing, UserMenuItem, InternalMenuItemBase, InternalMenuLink, InternalMenuButton, TInternalMenuItem, TSlotMenuVariant, THeaderMenu, TLogOutButtonPlacement, THeaderPosition, THeaderScrollBehavior, } from './header';
9
- export { convertUserMenuItem } from './header';
8
+ export type { User, Representing, UserMenuItem, UserMenuFooterItem, InternalMenuItemBase, InternalMenuLink, InternalMenuButton, TInternalMenuItem, THeaderType, TSlotMenuVariant, THeaderMenu, TLogOutButtonPlacement, THeaderPosition, THeaderScrollBehavior, IPktHeaderCommonBase, IPktHeaderServiceBase, IPktHeaderGlobalBase, IPktHeaderBase, TPktHeaderGlobalOnlyProps, IHeaderSpecProps, } from './header';
9
+ export { convertUserMenuItem, HEADER_TYPES, SLOT_MENU_VARIANTS, HEADER_MENUS, LOG_OUT_BUTTON_PLACEMENTS, HEADER_POSITIONS, HEADER_SCROLL_BEHAVIORS, HEADER_COMMON_DEFAULTS, HEADER_SERVICE_DEFAULTS, HEADER_GLOBAL_DEFAULTS, } from './header';
10
10
  export { HEADER_MENU_LOCALES, DEFAULT_HEADER_FOOTER_URL, DEFAULT_HEADER_LOGO_LINK, } from './header-footer';
11
- export type { THeaderMenuLocale, IHeaderMenuLink, IHeaderMenuIconLink, IHeaderMenuButton, IHeaderMenuServices, IHeaderMenuSection, IMegaMenu, IHeaderFooter, IHeaderFooterLocaleData, THeaderFooterApi, IPktHeaderMenu, IPktHeaderGlobal, } from './header-footer';
11
+ export type { THeaderMenuLocale, IHeaderMenuLink, IHeaderMenuIconLink, IHeaderMenuButton, IHeaderMenuServices, IHeaderMenuSection, IMegaMenu, IHeaderFooter, IHeaderFooterLocaleData, THeaderFooterApi, IPktHeaderMenu, } from './header-footer';
12
12
  export type { IPktFooterLink, IPktFooterColumn, IPktFooterSocialLink, IPktFooterBase, IPktFooterProps, IPktFooterSimpleProps, IFooterSimpleSpecProps, IFooterSpecProps, } from './footer';
13
13
  export { DEFAULT_FOOTER_PERSONVERN_URL, DEFAULT_FOOTER_TILGJENGELIGHET_URL } from './footer';
14
14
  export { CARD_SKINS, CARD_LIGHT_ONLY_SKINS, CARD_IMAGE_ASPECTS, CARD_TAG_POSITIONS, CARD_TAG_SKIN_OPTIONS, CARD_DEFAULTS, } from './card';
@@ -49,6 +49,8 @@ export type { TPktCounterPosition, IPktInputWrapperBase, IInputWrapperSpecProps,
49
49
  export type { TMessageboxSkin } from './skin';
50
50
  export { TAG_SKINS, TAG_STATES, TAG_TEXT_STYLES, TAG_DEFAULTS } from './tag';
51
51
  export type { TTagSkin, TTagState, TTagTextStyle, IPktTagBase, ITagSpecProps } from './tag';
52
+ export { TABS_DEFAULTS, TAB_ITEM_DEFAULTS } from './tabs';
53
+ export type { IPktTab, IPktTabTag, IPktTabsBase, IPktTabItemBase, ITabsSpecProps, ITabItemSpecProps, } from './tabs';
52
54
  export { MESSAGEBOX_SKINS, MESSAGEBOX_LIGHT_ONLY_SKINS, MESSAGEBOX_DEFAULTS } from './messagebox';
53
55
  export type { IPktMessageboxBase, IMessageboxSpecProps } from './messagebox';
54
56
  export { CALENDAR_DEFAULTS } from './calendar';
@@ -1,25 +1,27 @@
1
1
  import "./size.js";
2
- import { DEFAULT_HEADER_FOOTER_URL as e, DEFAULT_HEADER_LOGO_LINK as t } from "./header-footer.js";
3
- import { DEFAULT_FOOTER_PERSONVERN_URL as n, DEFAULT_FOOTER_TILGJENGELIGHET_URL as r } from "./footer.js";
4
- import { CARD_DEFAULTS as i, CARD_LIGHT_ONLY_SKINS as a } from "./card.js";
5
- import { CHECKBOX_DEFAULTS as o } from "./checkbox.js";
6
- import { RADIOBUTTON_DEFAULTS as s } from "./radiobutton.js";
7
- import { OPTION_GROUP_DEFAULTS as c } from "./option-group.js";
8
- import { CONSENT_DEFAULTS as l } from "./consent.js";
9
- import { ANIMATION_DEFAULT_PATH as u, ICON_DEFAULTS as d } from "./icon.js";
10
- import { LOADER_DEFAULTS as f } from "./loader.js";
11
- import { ACCORDION_LIGHT_ONLY_SKINS as p } from "./accordion.js";
12
- import { BUTTON_DEFAULTS as m } from "./button.js";
13
- import { LINKCARD_LIGHT_ONLY_SKINS as h } from "./linkcard.js";
14
- import { INPUT_WRAPPER_DEFAULTS as g } from "./input-wrapper.js";
15
- import { TEXTAREA_DEFAULTS as _ } from "./textarea.js";
16
- import { TEXTINPUT_DEFAULTS as v } from "./textinput.js";
17
- import { TAG_DEFAULTS as y } from "./tag.js";
18
- import { MESSAGEBOX_DEFAULTS as b, MESSAGEBOX_LIGHT_ONLY_SKINS as x } from "./messagebox.js";
2
+ import { DEFAULT_HEADER_FOOTER_URL as e } from "./header-footer.js";
3
+ import { HEADER_GLOBAL_DEFAULTS as t, HEADER_SERVICE_DEFAULTS as n } from "./header.js";
4
+ import { DEFAULT_FOOTER_PERSONVERN_URL as r, DEFAULT_FOOTER_TILGJENGELIGHET_URL as i } from "./footer.js";
5
+ import { CARD_DEFAULTS as a, CARD_LIGHT_ONLY_SKINS as o } from "./card.js";
6
+ import { CHECKBOX_DEFAULTS as s } from "./checkbox.js";
7
+ import { RADIOBUTTON_DEFAULTS as c } from "./radiobutton.js";
8
+ import { OPTION_GROUP_DEFAULTS as l } from "./option-group.js";
9
+ import { CONSENT_DEFAULTS as u } from "./consent.js";
10
+ import { ANIMATION_DEFAULT_PATH as d, ICON_DEFAULTS as f } from "./icon.js";
11
+ import { LOADER_DEFAULTS as p } from "./loader.js";
12
+ import { ACCORDION_LIGHT_ONLY_SKINS as m } from "./accordion.js";
13
+ import { BUTTON_DEFAULTS as h } from "./button.js";
14
+ import { LINKCARD_LIGHT_ONLY_SKINS as g } from "./linkcard.js";
15
+ import { INPUT_WRAPPER_DEFAULTS as _ } from "./input-wrapper.js";
16
+ import { TEXTAREA_DEFAULTS as v } from "./textarea.js";
17
+ import { TEXTINPUT_DEFAULTS as y } from "./textinput.js";
18
+ import { TAG_DEFAULTS as b } from "./tag.js";
19
+ import { TABS_DEFAULTS as x, TAB_ITEM_DEFAULTS as S } from "./tabs.js";
20
+ import { MESSAGEBOX_DEFAULTS as C, MESSAGEBOX_LIGHT_ONLY_SKINS as w } from "./messagebox.js";
19
21
  import "./calendar.js";
20
- import { DATEPICKER_DEFAULTS as S } from "./datepicker.js";
21
- import { PROGRESSBAR_DEFAULTS as C } from "./progressbar.js";
22
+ import { DATEPICKER_DEFAULTS as T } from "./datepicker.js";
23
+ import { PROGRESSBAR_DEFAULTS as E } from "./progressbar.js";
22
24
  import "./combobox.js";
23
- import { SELECT_DEFAULTS as w } from "./select.js";
24
- import { TABLE_DEFAULTS as T } from "./table.js";
25
- export { p as ACCORDION_LIGHT_ONLY_SKINS, u as ANIMATION_DEFAULT_PATH, m as BUTTON_DEFAULTS, i as CARD_DEFAULTS, a as CARD_LIGHT_ONLY_SKINS, o as CHECKBOX_DEFAULTS, l as CONSENT_DEFAULTS, S as DATEPICKER_DEFAULTS, n as DEFAULT_FOOTER_PERSONVERN_URL, r as DEFAULT_FOOTER_TILGJENGELIGHET_URL, e as DEFAULT_HEADER_FOOTER_URL, t as DEFAULT_HEADER_LOGO_LINK, d as ICON_DEFAULTS, g as INPUT_WRAPPER_DEFAULTS, h as LINKCARD_LIGHT_ONLY_SKINS, f as LOADER_DEFAULTS, b as MESSAGEBOX_DEFAULTS, x as MESSAGEBOX_LIGHT_ONLY_SKINS, c as OPTION_GROUP_DEFAULTS, C as PROGRESSBAR_DEFAULTS, s as RADIOBUTTON_DEFAULTS, w as SELECT_DEFAULTS, T as TABLE_DEFAULTS, y as TAG_DEFAULTS, _ as TEXTAREA_DEFAULTS, v as TEXTINPUT_DEFAULTS };
25
+ import { SELECT_DEFAULTS as D } from "./select.js";
26
+ import { TABLE_DEFAULTS as O } from "./table.js";
27
+ export { m as ACCORDION_LIGHT_ONLY_SKINS, d as ANIMATION_DEFAULT_PATH, h as BUTTON_DEFAULTS, a as CARD_DEFAULTS, o as CARD_LIGHT_ONLY_SKINS, s as CHECKBOX_DEFAULTS, u as CONSENT_DEFAULTS, T as DATEPICKER_DEFAULTS, r as DEFAULT_FOOTER_PERSONVERN_URL, i as DEFAULT_FOOTER_TILGJENGELIGHET_URL, e as DEFAULT_HEADER_FOOTER_URL, t as HEADER_GLOBAL_DEFAULTS, n as HEADER_SERVICE_DEFAULTS, f as ICON_DEFAULTS, _ as INPUT_WRAPPER_DEFAULTS, g as LINKCARD_LIGHT_ONLY_SKINS, p as LOADER_DEFAULTS, C as MESSAGEBOX_DEFAULTS, w as MESSAGEBOX_LIGHT_ONLY_SKINS, l as OPTION_GROUP_DEFAULTS, E as PROGRESSBAR_DEFAULTS, c as RADIOBUTTON_DEFAULTS, D as SELECT_DEFAULTS, O as TABLE_DEFAULTS, x as TABS_DEFAULTS, S as TAB_ITEM_DEFAULTS, b as TAG_DEFAULTS, v as TEXTAREA_DEFAULTS, y as TEXTINPUT_DEFAULTS };
@@ -0,0 +1,66 @@
1
+ /**
2
+ * tabs.ts
3
+ *
4
+ * Shared types and defaults for pkt-tabs and pkt-tab-item.
5
+ * Used by React, Elements, and typed component specs.
6
+ *
7
+ * @remarks React also takes a `tabs` array (`IPktTab[]`) instead of tab item
8
+ * children. Elements only takes `pkt-tab-item` children. Elements widens
9
+ * `ariaLabel` to `string | null`, like the native `ariaLabel` property.
10
+ */
11
+ import type { TTagSkin } from './tag';
12
+ /** The tag on a tab in React's `tabs` array. */
13
+ export interface IPktTabTag {
14
+ text: string;
15
+ skin?: TTagSkin;
16
+ }
17
+ /** One tab in React's `tabs` array. */
18
+ export interface IPktTab {
19
+ text: string;
20
+ href?: string;
21
+ action?: (index: number) => void;
22
+ disabled?: boolean;
23
+ icon?: string;
24
+ controls?: string;
25
+ tag?: IPktTabTag;
26
+ active?: boolean;
27
+ }
28
+ /** Tabs props shared by React, Elements, and typed specs. */
29
+ export interface IPktTabsBase {
30
+ arrowNav?: boolean;
31
+ disableArrowNav?: boolean;
32
+ separatorIconName?: string;
33
+ separatorIconPath?: string;
34
+ togglePanels?: boolean;
35
+ ariaLabel?: string;
36
+ ariaLabelledBy?: string;
37
+ }
38
+ /** Tab item props shared by React, Elements, and typed specs. */
39
+ export interface IPktTabItemBase {
40
+ active?: boolean;
41
+ disabled?: boolean;
42
+ href?: string;
43
+ icon?: string;
44
+ controls?: string;
45
+ tag?: string;
46
+ tagSkin?: TTagSkin;
47
+ index?: number;
48
+ }
49
+ /** Props documented in the tabs spec. */
50
+ export type ITabsSpecProps = Pick<IPktTabsBase, 'arrowNav' | 'disableArrowNav' | 'separatorIconName' | 'separatorIconPath' | 'togglePanels' | 'ariaLabelledBy' | 'ariaLabel'> & {
51
+ /** React only. Elements takes `pkt-tab-item` children. */
52
+ tabs?: IPktTab[];
53
+ };
54
+ /** Props documented in the tab item spec. */
55
+ export type ITabItemSpecProps = Pick<IPktTabItemBase, 'active' | 'disabled' | 'href' | 'icon' | 'tag' | 'tagSkin' | 'index' | 'controls'>;
56
+ export declare const TABS_DEFAULTS: {
57
+ readonly arrowNav: true;
58
+ readonly disableArrowNav: false;
59
+ readonly togglePanels: false;
60
+ };
61
+ export declare const TAB_ITEM_DEFAULTS: {
62
+ readonly active: false;
63
+ readonly disabled: false;
64
+ readonly tagSkin: 'blue';
65
+ readonly index: 0;
66
+ };
@@ -0,0 +1,12 @@
1
+ // ../../shared-types/tabs.ts
2
+ var e = {
3
+ arrowNav: !0,
4
+ disableArrowNav: !1,
5
+ togglePanels: !1
6
+ }, t = {
7
+ active: !1,
8
+ disabled: !1,
9
+ tagSkin: "blue",
10
+ index: 0
11
+ };
12
+ export { e as TABS_DEFAULTS, t as TAB_ITEM_DEFAULTS };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-react",
3
- "version": "20.2.0",
3
+ "version": "20.2.2",
4
4
  "description": "React komponentbibliotek til Punkt, designsystem for Oslo kommune",
5
5
  "homepage": "https://punkt.oslo.kommune.no",
6
6
  "author": "Team Designsystem, Oslo kommune",
@@ -102,5 +102,5 @@
102
102
  "url": "https://github.com/oslokommune/punkt/issues"
103
103
  },
104
104
  "license": "MIT",
105
- "gitHead": "6e2e6b2c2801df3e024106db88fe4916f457b93c"
105
+ "gitHead": "c5d1c30d65671d5a45689d59976f28e67559e732"
106
106
  }