@norges-domstoler/dds-components 3.1.0 → 4.0.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.
@@ -1,4 +1,3 @@
1
- import { AnchorHTMLAttributes } from 'react';
2
- import { TypographyProps } from '../Typography';
3
- export declare type BreadcrumbProps = TypographyProps & AnchorHTMLAttributes<HTMLAnchorElement>;
4
- export declare const Breadcrumb: import("react").ForwardRefExoticComponent<BreadcrumbProps & import("react").RefAttributes<HTMLAnchorElement>>;
1
+ import { AnchorHTMLAttributes, HTMLAttributes } from 'react';
2
+ export declare type BreadcrumbProps = HTMLAttributes<HTMLSpanElement> | AnchorHTMLAttributes<HTMLAnchorElement>;
3
+ export declare const Breadcrumb: import("react").ForwardRefExoticComponent<BreadcrumbProps & import("react").RefAttributes<HTMLElement>>;
@@ -2,7 +2,7 @@
2
2
  import { SelectProps } from './Select';
3
3
  declare const _default: {
4
4
  title: string;
5
- component: <TOption, IsMulti extends boolean = false>({ id, label, errorMessage, tip, required, readOnly, options, isMulti, value, defaultValue, width, closeMenuOnSelect, className, style, isDisabled, isClearable, placeholder, ...rest }: SelectProps<TOption, IsMulti>, ref: ((instance: import("react-select").SelectInstance<TOption, IsMulti, import("react-select").GroupBase<TOption>> | null) => void) | import("react").MutableRefObject<import("react-select").SelectInstance<TOption, IsMulti, import("react-select").GroupBase<TOption>> | null> | null) => JSX.Element;
5
+ component: <TOption extends Record<string, unknown>, IsMulti extends boolean = false>({ id, label, errorMessage, tip, required, readOnly, options, isMulti, value, defaultValue, width, closeMenuOnSelect, className, style, isDisabled, isClearable, placeholder, ...rest }: SelectProps<TOption, IsMulti>, ref: ((instance: import("react-select").SelectInstance<TOption, IsMulti, import("react-select").GroupBase<TOption>> | null) => void) | import("react").MutableRefObject<import("react-select").SelectInstance<TOption, IsMulti, import("react-select").GroupBase<TOption>> | null> | null) => JSX.Element;
6
6
  argTypes: {
7
7
  label: {
8
8
  control: {
@@ -1,8 +1,15 @@
1
1
  import { Property } from 'csstype';
2
2
  import React from 'react';
3
3
  import { GroupBase, Props as ReactSelectProps, SelectInstance } from 'react-select';
4
+ import { WithRequiredIf } from '../../types/utils';
5
+ export declare type SelectOption<TValue = unknown> = {
6
+ label: string | number;
7
+ value: TValue;
8
+ };
9
+ export declare const createSelectOptions: <TValue extends string | number>(...args: TValue[]) => SelectOption<TValue>[];
4
10
  export declare function searchFilter(text: string, search: string): boolean;
5
- export declare type SelectProps<TOption, IsMulti extends boolean> = {
11
+ declare type WrappedReactSelectProps<TOption extends Record<string, unknown>, IsMulti extends boolean, Group extends GroupBase<TOption>> = WithRequiredIf<TOption extends SelectOption ? false : true, ReactSelectProps<TOption, IsMulti, Group>, 'getOptionLabel' | 'getOptionValue'>;
12
+ export declare type SelectProps<TOption extends Record<string, unknown>, IsMulti extends boolean> = {
6
13
  /**Ledetekst for nedtrekkslisten. */
7
14
  label?: string;
8
15
  /**Gir required styling. **OBS!** støtter ikke DOM `required` attributt. */
@@ -19,7 +26,7 @@ export declare type SelectProps<TOption, IsMulti extends boolean> = {
19
26
  className?: string;
20
27
  /** Inline styling. */
21
28
  style?: React.CSSProperties;
22
- } & ReactSelectProps<TOption, IsMulti, GroupBase<TOption>>;
29
+ } & WrappedReactSelectProps<TOption, IsMulti, GroupBase<TOption>>;
23
30
  declare type ForwardRefType<TOption, IsMulti extends boolean> = React.ForwardedRef<SelectInstance<TOption, IsMulti, GroupBase<TOption>>>;
24
- export declare const Select: <TOption, IsMulti extends boolean = false>({ id, label, errorMessage, tip, required, readOnly, options, isMulti, value, defaultValue, width, closeMenuOnSelect, className, style, isDisabled, isClearable, placeholder, ...rest }: SelectProps<TOption, IsMulti>, ref: ForwardRefType<TOption, IsMulti>) => JSX.Element;
31
+ export declare const Select: <TOption extends Record<string, unknown>, IsMulti extends boolean = false>({ id, label, errorMessage, tip, required, readOnly, options, isMulti, value, defaultValue, width, closeMenuOnSelect, className, style, isDisabled, isClearable, placeholder, ...rest }: SelectProps<TOption, IsMulti>, ref: ForwardRefType<TOption, IsMulti>) => JSX.Element;
25
32
  export {};
@@ -1,8 +1,8 @@
1
1
  /// <reference types="react" />
2
- import { SelectProps } from '.';
2
+ import { SelectOption, SelectProps } from '.';
3
3
  declare const _default: {
4
4
  title: string;
5
- component: <TOption, IsMulti extends boolean = false>({ id, label, errorMessage, tip, required, readOnly, options, isMulti, value, defaultValue, width, closeMenuOnSelect, className, style, isDisabled, isClearable, placeholder, ...rest }: SelectProps<TOption, IsMulti>, ref: ((instance: import("react-select").SelectInstance<TOption, IsMulti, import("react-select").GroupBase<TOption>> | null) => void) | import("react").MutableRefObject<import("react-select").SelectInstance<TOption, IsMulti, import("react-select").GroupBase<TOption>> | null> | null) => JSX.Element;
5
+ component: <TOption extends Record<string, unknown>, IsMulti extends boolean = false>({ id, label, errorMessage, tip, required, readOnly, options, isMulti, value, defaultValue, width, closeMenuOnSelect, className, style, isDisabled, isClearable, placeholder, ...rest }: SelectProps<TOption, IsMulti>, ref: ((instance: import("react-select").SelectInstance<TOption, IsMulti, import("react-select").GroupBase<TOption>> | null) => void) | import("react").MutableRefObject<import("react-select").SelectInstance<TOption, IsMulti, import("react-select").GroupBase<TOption>> | null> | null) => JSX.Element;
6
6
  argTypes: {
7
7
  label: {
8
8
  control: {
@@ -62,11 +62,7 @@ declare const _default: {
62
62
  };
63
63
  };
64
64
  export default _default;
65
- declare type Option = {
66
- label: string;
67
- value: string;
68
- };
69
- declare type SingleSelectProps = SelectProps<Option, false>;
65
+ declare type SingleSelectProps = SelectProps<SelectOption, false>;
70
66
  export declare const Overview: (args: SingleSelectProps) => JSX.Element;
71
67
  export declare const Default: (args: SingleSelectProps) => JSX.Element;
72
68
  export declare const WithLabel: (args: SingleSelectProps) => JSX.Element;
@@ -9,7 +9,7 @@ export declare type TagProps = BaseComponentProps<HTMLSpanElement, {
9
9
  }>;
10
10
  export declare const Tag: import("react").ForwardRefExoticComponent<{
11
11
  htmlProps?: import("react").HTMLAttributes<HTMLSpanElement> | undefined;
12
- } & Pick<import("react").HTMLAttributes<HTMLSpanElement>, "className" | "id"> & {
12
+ } & Pick<import("react").HTMLAttributes<HTMLSpanElement>, "id" | "className"> & {
13
13
  /**Tekst som vises i `<Tag />.` */
14
14
  text?: string | undefined;
15
15
  /**Formål med status eller kategorisering. Påvirker styling. */
@@ -1,6 +1,7 @@
1
1
  import { ElementType, PropsWithChildren, HTMLAttributes, AnchorHTMLAttributes } from 'react';
2
2
  import { CSSObject } from 'styled-components';
3
3
  import { TextColor, OtherTypographyType, AnchorTypographyType, LabelTypographyType } from './Typography.types';
4
+ import { BaseComponentProps } from '../../types';
4
5
  export declare function isTextColor(color: string): color is TextColor;
5
6
  export declare const getTextColor: (color: TextColor | string) => string;
6
7
  export declare type TypographyInteractionProps = {
@@ -22,24 +23,25 @@ declare type BaseTypographyProps = PropsWithChildren<{
22
23
  underline?: boolean;
23
24
  /**Støtte for å enkelt kunne endre på hover- og active-styling. Bruk `@dds-design-tokens` til farger osv. */
24
25
  interactionProps?: TypographyInteractionProps;
25
- }>;
26
- declare type AnchorTypographyProps = BaseTypographyProps & {
27
- /**Styling basert på det typografiske utvalget definert i Figma. Returnerer default HTML tag for hver type. **OBS!** Ved bruk av `'a'` er det flere tilgjengelige props, se under. */
28
- typographyType?: AnchorTypographyType;
26
+ }> & Pick<HTMLAttributes<HTMLElement>, 'style'>;
27
+ declare type AnchorTypographyProps = BaseComponentProps<HTMLAnchorElement, BaseTypographyProps & {
29
28
  href?: string | undefined;
30
29
  /** Spesifiserer om lenka er ekstern ved `typographyType='a'` eller `as='a'`.*/
31
30
  externalLink?: boolean;
32
31
  /**nativ `target`-prop ved `typographyType='a'`. */
33
32
  target?: string;
34
- } & AnchorHTMLAttributes<HTMLAnchorElement>;
35
- declare type LabelTypographyProps = BaseTypographyProps & {
33
+ }, AnchorHTMLAttributes<HTMLAnchorElement>>;
34
+ declare type LabelTypographyProps = BaseComponentProps<HTMLLabelElement, BaseTypographyProps, HTMLAttributes<HTMLLabelElement>>;
35
+ declare type OtherTypographyProps = BaseComponentProps<HTMLElement, BaseTypographyProps, HTMLAttributes<HTMLElement>>;
36
+ export declare type TypographyProps = ({
37
+ /**Styling basert på det typografiske utvalget definert i Figma. Returnerer default HTML tag for hver type. **OBS!** Ved bruk av `'a'` er det flere tilgjengelige props, se under. */
38
+ typographyType?: AnchorTypographyType;
39
+ } & AnchorTypographyProps) | ({
36
40
  /**Styling basert på det typografiske utvalget definert i Figma. Returnerer default HTML tag for hver type. **OBS!** Ved bruk av `'a'` er det flere tilgjengelige props, se under. */
37
41
  typographyType?: LabelTypographyType;
38
- } & HTMLAttributes<HTMLLabelElement>;
39
- declare type OtherTypographyProps = BaseTypographyProps & {
42
+ } & LabelTypographyProps) | ({
40
43
  /**Styling basert på det typografiske utvalget definert i Figma. Returnerer default HTML tag for hver type. **OBS!** Ved bruk av `'a'` er det flere tilgjengelige props, se under. */
41
44
  typographyType?: OtherTypographyType;
42
- } & HTMLAttributes<HTMLLabelElement>;
43
- export declare type TypographyProps = AnchorTypographyProps | LabelTypographyProps | OtherTypographyProps;
45
+ } & OtherTypographyProps);
44
46
  export declare const Typography: import("react").ForwardRefExoticComponent<TypographyProps & import("react").RefAttributes<HTMLElement>>;
45
47
  export {};