@oslokommune/punkt-elements
Version:
Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo
42 lines (41 loc) • 1.42 kB
TypeScript
/**
* Types for Search input (`pkt-searchinput` / `PktSearchInput`).
*
* Shared between Elements and React so API contracts and suggestion payloads
* stay aligned. React extends suggestions with `ReactNode` and optional
* `onClick` in the component layer — see `@oslokommune/punkt-react`.
*/
export type TPktSearchInputAppearance = 'local' | 'local-with-button' | 'global';
export type TPktSearchInputMethod = 'get' | 'post' | 'dialog';
/**
* Plain suggestion item (JSON-serializable). Used by Elements and as the
* portable shape for API data and design-token documentation.
*/
export interface IPktSearchInputSuggestion {
title?: string;
text?: string;
href?: string;
/**
* Presentational row only (e.g. «Ingen resultater»). Renders as a non-focusable
* container — not a link or button — and does not emit selection events.
* Ignored when `href` is set (link always wins).
*/
nonInteractive?: boolean;
}
/**
* Public props for the web component (Elements). React mirrors these and adds
* callback props in its wrapper.
*/
export interface IPktSearchInput {
appearance?: TPktSearchInputAppearance;
disabled?: boolean;
fullwidth?: boolean;
id: string;
label?: string;
name?: string;
placeholder?: string;
value?: string;
suggestions?: IPktSearchInputSuggestion[];
action?: string;
method?: TPktSearchInputMethod;
}