@sebgroup/green-react 2.5.1 → 2.6.1

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/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@sebgroup/green-react",
3
- "version": "2.5.1",
3
+ "version": "2.6.1",
4
4
  "peerDependencies": {
5
5
  "react": "^17 || ^18",
6
6
  "react-dom": "^17 || ^18"
7
7
  },
8
8
  "dependencies": {
9
- "@sebgroup/green-core": "^1.2.3",
10
- "@sebgroup/chlorophyll": "^2.2.2",
11
- "@sebgroup/extract": "^2.1.0",
9
+ "@sebgroup/green-core": "^1.2.4",
10
+ "@sebgroup/chlorophyll": "^2.3.0",
11
+ "@sebgroup/extract": "^2.1.1",
12
12
  "classnames": "^2.3.2"
13
13
  },
14
14
  "description": "React components built on top of @sebgroup/chlorophyll.",
@@ -1,14 +1,14 @@
1
- import { MouseEventHandler, ReactNode } from 'react';
2
- import { ButtonSize, ButtonType, ButtonVariant } from '@sebgroup/extract';
3
- export interface ButtonProps {
4
- children?: ReactNode;
5
- type?: ButtonType;
1
+ import { ButtonHTMLAttributes, DetailedHTMLProps } from 'react';
2
+ import { ButtonSize, ButtonVariant } from '@sebgroup/extract';
3
+ export interface ButtonProps extends DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> {
4
+ /** Button styling. Available options: 'primary', 'secondary', 'ghost' and 'tertiary'. */
6
5
  variant?: ButtonVariant;
6
+ /** Styling button as active or not */
7
7
  active?: boolean;
8
- onClick?: MouseEventHandler<HTMLButtonElement>;
9
- disabled?: boolean;
8
+ /** Button size. Available options: 'small' and 'large'. */
10
9
  size?: ButtonSize;
10
+ /** Renders as a `data-testid` attribute on the `<button>` element, useful in testing scenarios. */
11
11
  testId?: string;
12
12
  }
13
- export declare function Button({ children, variant, onClick, disabled, active, type, size, testId }: ButtonProps): import("react/jsx-runtime").JSX.Element;
13
+ export declare function Button({ className, variant, active, type, size, testId, ...otherProps }: ButtonProps): import("react/jsx-runtime").JSX.Element;
14
14
  export default Button;
@@ -3,9 +3,11 @@ import { ButtonVariant } from '@sebgroup/extract';
3
3
  import { ButtonProps } from '../button/button';
4
4
  interface ButtonGroupProps {
5
5
  children: ReactElement<ButtonProps> | ReactElement<ButtonProps>[];
6
+ /** Class names passed to the child elements */
7
+ className?: string;
6
8
  selectedIndex?: number;
7
9
  variant?: ButtonVariant;
8
10
  id?: string;
9
11
  }
10
- export declare const ButtonGroup: ({ children, selectedIndex, variant, id, }: ButtonGroupProps) => import("react/jsx-runtime").JSX.Element;
12
+ export declare const ButtonGroup: ({ children, className, selectedIndex, variant, id, }: ButtonGroupProps) => import("react/jsx-runtime").JSX.Element;
11
13
  export default ButtonGroup;
@@ -0,0 +1,15 @@
1
+ import { IValidator } from '@sebgroup/extract';
2
+ import { FormEventHandler, HTMLProps } from 'react';
3
+ export interface CheckboxProps extends HTMLProps<HTMLInputElement> {
4
+ /** Use this prop to control the checked state of the checkbox */
5
+ checked?: boolean;
6
+ /** The label of the checkbox */
7
+ label?: string;
8
+ /** A test id that will be placed in the `data-testid` attribute on the input element */
9
+ testId?: string;
10
+ /** An object used to render the validation status for the component */
11
+ validator?: IValidator;
12
+ /** A handler function that takes the event and can act on it */
13
+ onChange?: FormEventHandler<HTMLInputElement>;
14
+ }
15
+ export declare const Checkbox: ({ label, onChange, validator, testId, ...props }: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,12 @@
1
1
  export * from './button/button';
2
2
  export * from './iconButton/iconButton';
3
3
  export * from './buttonGroup/buttonGroup';
4
+ export * from './checkbox/checkbox';
4
5
  export * from './form';
5
6
  export * from './formItems';
6
7
  export * from './group/group';
7
8
  export * from './input/input';
8
9
  export * from './text/text';
10
+ export * from './radioButton/radioButton';
9
11
  export * from './radioButton/radioGroup';
10
12
  export * from './textarea/textarea';
@@ -1,10 +1,26 @@
1
- import React, { InputHTMLAttributes } from 'react';
2
- import { IValidator } from '@sebgroup/extract';
3
- import { CheckboxProps, NumberInputProps, RadioButtonProps, TextInputProps } from '../types';
4
- export declare type Renderer = (type: string, props: InputHTMLAttributes<HTMLInputElement>, onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void, onChangeInput?: (value: string) => string, label?: string, info?: string | React.ReactNode, validator?: IValidator, expandableInfo?: React.ReactNode, expandableInfoButtonLabel?: string, testId?: string) => JSX.Element;
5
- export declare const RenderInput: Renderer;
6
- export declare const TextInput: ({ label, info, testId, onChange, onChangeInput, validator, expandableInfo, expandableInfoButtonLabel, ...props }: TextInputProps) => JSX.Element;
7
- export declare const EmailInput: ({ label, info, onChange, onChangeInput, validator, testId, ...props }: TextInputProps) => JSX.Element;
8
- export declare const NumberInput: ({ label, info, onChange, onChangeInput, validator, expandableInfo, expandableInfoButtonLabel, testId, ...props }: NumberInputProps) => JSX.Element;
9
- export declare const Checkbox: ({ label, onChange, validator, testId, ...props }: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
10
- export declare const RadioButton: React.ForwardRefExoticComponent<Omit<RadioButtonProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
1
+ import { DetailedHTMLProps, InputHTMLAttributes, ReactNode } from 'react';
2
+ import { IExpandableInformation, IValidator } from '@sebgroup/extract';
3
+ export interface InputProps extends IExpandableInformation, DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> {
4
+ /** Data test id used for finding elements in test */
5
+ testId?: string;
6
+ /** Format value on change */
7
+ formatter?: (value: string) => string;
8
+ /** Extra describing text, below the label */
9
+ info?: ReactNode;
10
+ /** Label describing the input */
11
+ label?: string;
12
+ /** Text on the right side of the input, used for unit such as 'kr' or '%' */
13
+ unit?: string;
14
+ /** Validation object */
15
+ validator?: IValidator;
16
+ /** Value of input */
17
+ value?: string | number;
18
+ /** Function called when input value changes */
19
+ onChangeInput?: (value: string) => string;
20
+ }
21
+ export declare const Input: ({ "aria-describedby": ariaDescribedBy, autoComplete, children, className, testId: dataTestId, expandableInfo, expandableInfoButtonLabel, formatter, id, label, info, onChange, unit, role, validator, onChangeInput, value, ...props }: InputProps) => import("react/jsx-runtime").JSX.Element;
22
+ export declare const TextInput: (props: Omit<InputProps, 'type'>) => import("react/jsx-runtime").JSX.Element;
23
+ export declare const EmailInput: (props: Omit<InputProps, 'type'>) => import("react/jsx-runtime").JSX.Element;
24
+ export declare const NumberInput: (props: Omit<InputProps, 'type'>) => import("react/jsx-runtime").JSX.Element;
25
+ export { RadioButton } from '../radioButton/radioButton';
26
+ export { Checkbox } from '../checkbox/checkbox';
@@ -0,0 +1,9 @@
1
+ import { HTMLProps } from 'react';
2
+ import { IValidator } from '@sebgroup/extract';
3
+ export interface RadioButtonProps extends HTMLProps<HTMLInputElement> {
4
+ label: string;
5
+ testId?: string;
6
+ validator?: IValidator;
7
+ value: string;
8
+ }
9
+ export declare const RadioButton: import("react").ForwardRefExoticComponent<Omit<RadioButtonProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { IValidator, IExpandableInformation, ILabelAndLabelInformation } from '@sebgroup/extract';
3
3
  export interface RadioGroupProps extends IExpandableInformation, ILabelAndLabelInformation {
4
+ label?: string;
4
5
  title?: string;
5
6
  valueSelected?: string;
6
7
  description?: string;
@@ -11,5 +12,5 @@ export interface RadioGroupProps extends IExpandableInformation, ILabelAndLabelI
11
12
  name?: string;
12
13
  horizontal?: boolean;
13
14
  }
14
- export declare const RadioGroup: ({ defaultSelected, valueSelected, label, title, labelInformation, description, expandableInfo, expandableInfoButtonLabel, validator, onChangeRadio, onChange, name, horizontal, children, }: React.PropsWithChildren<RadioGroupProps>) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const RadioGroup: ({ defaultSelected, valueSelected, label, title, labelInformation, description, expandableInfo, expandableInfoButtonLabel, validator, onChangeRadio, onChange, name: propName, horizontal, children, }: React.PropsWithChildren<RadioGroupProps>) => import("react/jsx-runtime").JSX.Element;
15
16
  export default RadioGroup;
@@ -1,10 +1,15 @@
1
- /// <reference types="react" />
2
- import { IExpandableInformation, ILabelAndLabelInformation, IValidator } from '@sebgroup/extract';
3
- export interface ITextAreaProps extends IExpandableInformation, ILabelAndLabelInformation, React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement> {
1
+ import { IExpandableInformation, IValidator } from '@sebgroup/extract';
2
+ import { DetailedHTMLProps, ReactNode } from 'react';
3
+ export interface ITextAreaProps extends IExpandableInformation, DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement> {
4
+ /** Data test id used for finding elements in test */
5
+ testId?: string;
6
+ /** Label describing the textarea */
4
7
  label: string;
5
- info?: string;
8
+ /** Extra describing text, below the label */
9
+ info?: ReactNode;
10
+ /** Validation object */
6
11
  validator?: IValidator | undefined;
12
+ /** Value of textarea */
7
13
  value?: string;
8
- 'data-testid'?: string;
9
14
  }
10
- export declare const TextArea: import("react").MemoExoticComponent<({ autoComplete, expandableInfo, expandableInfoButtonLabel, id, label, info, onChange, role, rows, validator, value, "data-testid": dataTestId, ...props }: ITextAreaProps) => import("react/jsx-runtime").JSX.Element>;
15
+ export declare const TextArea: ({ "aria-describedby": ariaDescribedBy, autoComplete, className, expandableInfo, expandableInfoButtonLabel, id, label, info, onChange, role, rows, validator, value, testId: dataTestId, maxLength, ...props }: ITextAreaProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,12 +1,13 @@
1
1
  import { IExpandableInformation, ILabelAndLabelInformation, IValidator } from '@sebgroup/extract';
2
- import React, { ReactNode } from 'react';
3
- interface FormItemProps extends IExpandableInformation, ILabelAndLabelInformation {
2
+ import React, { PropsWithChildren } from 'react';
3
+ interface FormItemProps extends IExpandableInformation, ILabelAndLabelInformation, PropsWithChildren {
4
4
  onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
5
5
  onChangeInput?: (value: string) => string;
6
6
  validator?: IValidator;
7
7
  inputId?: string;
8
- children: ReactNode;
9
8
  role?: string;
9
+ /** Intended to use together with TextArea to show character counter. */
10
+ rightAlignedFooterInfo?: string;
10
11
  }
11
- export declare const FormItem: ({ expandableInfo, label, labelInformation, validator, inputId, children, expandableInfoButtonLabel, role, }: FormItemProps) => import("react/jsx-runtime").JSX.Element;
12
+ export declare const FormItem: ({ expandableInfo, label, labelInformation, validator, inputId, children, expandableInfoButtonLabel, role, rightAlignedFooterInfo, }: FormItemProps) => import("react/jsx-runtime").JSX.Element;
12
13
  export {};
@@ -1,16 +1,24 @@
1
- import { ReactNode } from 'react';
2
- export interface InPageWizardStepCardProps {
1
+ import { PropsWithChildren, ReactNode } from 'react';
2
+ export interface InPageWizardStepCardProps extends PropsWithChildren {
3
+ /** Sub title for the title indicating 'Step X of Y'. */
3
4
  stepText: string;
5
+ /** Title of the step. */
4
6
  title: string;
7
+ /** Text on edit button. */
5
8
  editBtnText?: string;
6
- nextBtnText: string;
9
+ /** Text on next button. */
10
+ nextBtnText?: string;
11
+ /** Icon for next button. */
7
12
  nextBtnIcon?: ReactNode;
8
- stepStatus: WizardStepStatus;
13
+ /** Status for the step.*/
14
+ stepStatus: 'NotStarted' | 'IsActive' | 'IsComplete';
15
+ /** Force hiding of footer, regardless of state. */
9
16
  hideFooter?: boolean;
10
- children: React.ReactNode;
11
- onNextClick: () => void;
17
+ /** Event for click on next button. */
18
+ onNextClick?: () => void;
19
+ /** Event for click on edit button. */
12
20
  onEditClick?: () => void;
21
+ /** Testid for testing. */
13
22
  dataTestid?: string;
14
23
  }
15
- export declare type WizardStepStatus = 'NotStarted' | 'IsActive' | 'IsComplete';
16
- export declare const InPageWizardStepCard: (props: InPageWizardStepCardProps) => import("react/jsx-runtime").JSX.Element;
24
+ export declare const InPageWizardStepCard: ({ editBtnText, onNextClick, stepStatus, stepText, title, children, dataTestid, hideFooter, nextBtnIcon, nextBtnText, onEditClick, }: InPageWizardStepCardProps) => import("react/jsx-runtime").JSX.Element;
@@ -3,5 +3,5 @@ import { ButtonVariant } from '@sebgroup/extract';
3
3
  interface LinkProps extends HTMLProps<HTMLAnchorElement> {
4
4
  button?: boolean | ButtonVariant;
5
5
  }
6
- export declare const Link: ({ button, children, ...props }: PropsWithChildren<LinkProps>) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const Link: ({ button, children, className, role, ...otherProps }: PropsWithChildren<LinkProps>) => import("react/jsx-runtime").JSX.Element;
7
7
  export default Link;
@@ -1,6 +1,6 @@
1
1
  import { ModalType, Size } from '@sebgroup/extract';
2
2
  import { MouseEvent, ReactNode } from 'react';
3
- declare type ModalEventListener = (event: MouseEvent<HTMLButtonElement>) => unknown;
3
+ declare type ModalEventListener = (event: MouseEvent<HTMLButtonElement> | null) => unknown;
4
4
  export interface ModalProps {
5
5
  type?: ModalType;
6
6
  header?: string;
@@ -1,27 +0,0 @@
1
- import { IValidator, IExpandableInformation } from '@sebgroup/extract';
2
- import { HTMLProps } from 'react';
3
- export interface TextInputProps extends HTMLProps<HTMLInputElement>, IExpandableInformation {
4
- type?: 'text' | 'email' | 'number';
5
- label?: string;
6
- info?: string;
7
- testId?: string;
8
- validator?: IValidator;
9
- onChangeInput?: (value: string) => string;
10
- }
11
- export interface NumberInputProps extends TextInputProps {
12
- testId?: string;
13
- min?: number;
14
- max?: number;
15
- step?: number;
16
- }
17
- export interface CheckboxProps extends HTMLProps<HTMLInputElement> {
18
- testId?: string;
19
- validator?: IValidator;
20
- }
21
- export interface RadioButtonProps extends HTMLProps<HTMLInputElement> {
22
- label: string;
23
- testId?: string;
24
- validator?: string;
25
- value: string;
26
- }
27
- export declare type InputListener<T> = (newValue?: T) => unknown;