@bonprix-ds/internal-components 0.0.2 → 0.1.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/dist/index.d.ts CHANGED
@@ -1,48 +1,117 @@
1
- import { Anchor } from '@bonprix-ds/utils';
2
1
  import { ButtonSize } from '@bonprix-ds/utils';
3
- import { ButtonTypeAttribute } from '@bonprix-ds/utils';
2
+ import { ComponentProps } from 'react';
4
3
  import { default as default_2 } from 'react';
4
+ import { ElementType } from 'react';
5
+ import { FC } from 'react';
5
6
  import { IconType } from '@bonprix-ds/react-icon';
6
7
  import { Ref } from 'react';
8
+ import { ControlGroupProps as SelectionControlGroupProps } from '@bonprix-ds/utils';
7
9
 
8
- declare interface AsButton extends BaseProps {
9
- link?: false;
10
- onClick?: (event: default_2.MouseEvent<HTMLButtonElement>) => void;
11
- type?: ButtonTypeAttribute;
12
- form?: string;
13
- ref?: Ref<HTMLButtonElement>;
14
- rel?: never;
15
- href?: never;
16
- target?: never;
10
+ declare interface AllyIds {
11
+ errorTextId: string;
12
+ helperTextId: string;
17
13
  }
18
14
 
19
- declare interface AsLink extends BaseProps, Anchor {
20
- link: true;
21
- onClick?: (event: default_2.MouseEvent<HTMLAnchorElement>) => void;
22
- ref?: Ref<HTMLAnchorElement>;
23
- type?: never;
24
- form?: never;
25
- }
26
-
27
- export declare const BaseButton: ({ id, children, size, disabled, variant, contentWidth, loading, icon, iconPosition, iconButton, tabIndex, className, componentName, inverted, ...unionProps }: BaseButtonProps) => default_2.JSX.Element;
15
+ export declare const BaseButton: <C extends ElementType = "button">({ children, size, variant, contentWidth, loading, icon, iconPosition, componentName, inverted, component, ...props }: BaseButtonProps<C>) => default_2.JSX.Element;
28
16
 
29
- export declare type BaseButtonProps = AsButton | AsLink;
17
+ export declare type BaseButtonProps<C extends ElementType> = BaseProps & {
18
+ component?: C;
19
+ } & Omit<ComponentProps<C>, keyof BaseProps | "component">;
30
20
 
31
21
  declare interface BaseProps {
32
22
  children: string;
33
- id?: string;
34
23
  size?: ButtonSize;
35
- disabled?: boolean;
36
24
  variant?: "primary" | "secondary" | "tertiary";
37
25
  contentWidth?: boolean;
38
26
  loading?: boolean;
39
27
  icon?: IconType;
40
28
  iconPosition?: "start" | "end";
41
- iconButton?: boolean;
42
- tabIndex?: number;
43
- className?: string;
44
29
  componentName?: "button" | "icon-button" | "badge-icon-button";
45
30
  inverted?: boolean;
46
31
  }
47
32
 
33
+ declare interface BaseProps_2 {
34
+ label: string;
35
+ /** The name of the checkbox. Will be submitted with the form. */
36
+ name: string;
37
+ /** Callback function that is called when the checkbox loses focus. */
38
+ onBlur?: () => void;
39
+ /** The id of the checkbox. */
40
+ id?: string;
41
+ /** Value that will be submitted when the form is submitted. */
42
+ value?: string;
43
+ /** If set to `true`, the checkbox will be marked as required. */
44
+ required?: boolean;
45
+ /** If set to `true`, the checkbox will be disabled. */
46
+ disabled?: boolean;
47
+ /** If set to `true`, the checkbox will be marked as erroneous. */
48
+ error?: boolean;
49
+ errorText?: string;
50
+ helperText?: string;
51
+ /** A reference to the root element of the checkbox. Helpful for intergrating with 3rd party form libraries like react-hook-form. */
52
+ rootRef?: Ref<HTMLInputElement>;
53
+ /** <a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-describedby" target="_blank">ARIA: aria-describedby attribute.</a> */
54
+ describedBy?: string;
55
+ }
56
+
57
+ export declare const CheckboxBase: FC<CheckboxBaseProps & AllyIds>;
58
+
59
+ export declare type CheckboxBaseProps = ControlledInputProps | UncontrolledInputProps;
60
+
61
+ declare interface ControlledInputProps extends BaseProps_2 {
62
+ /** Controls, whether the checkbox is checked or not. Should be used in conjunction with `onChange`. */
63
+ checked: boolean;
64
+ /** Initial value of the checkbox. Should be used for uncontrolled variant of the component. */
65
+ defaultChecked?: never;
66
+ /** Callback function that is called when the checkbox state changes. `checked` should be adjusted appropriately. */
67
+ onChange: (value: boolean) => void;
68
+ }
69
+
70
+ export declare const InputHelperText: FC<InputHelperTextProps>;
71
+
72
+ export declare interface InputHelperTextProps {
73
+ id: string;
74
+ children: string;
75
+ type?: "description" | "error";
76
+ }
77
+
78
+ export declare const InputHelperTextSection: FC<InputHelperTextSectionProps>;
79
+
80
+ export declare interface InputHelperTextSectionProps {
81
+ helperText: string;
82
+ helperTextId: string;
83
+ error: boolean;
84
+ errorText: string;
85
+ errorTextId: string;
86
+ className?: string;
87
+ }
88
+
89
+ export declare const InputWrapper: FC<InputWrapperProps>;
90
+
91
+ export declare interface InputWrapperProps {
92
+ children: default_2.ReactNode;
93
+ id: string;
94
+ labelFloated: boolean;
95
+ disabled: boolean;
96
+ required: boolean;
97
+ componentName: "select" | "password-field" | "text-field" | "search-field" | "textarea";
98
+ label?: string;
99
+ helperText: string;
100
+ helperTextId: string;
101
+ error: boolean;
102
+ errorText: string;
103
+ errorTextId: string;
104
+ labelClassName?: string;
105
+ }
106
+
107
+ export declare const SelectionControlGroup: FC<SelectionControlGroupProps>;
108
+
109
+ export { SelectionControlGroupProps }
110
+
111
+ declare interface UncontrolledInputProps extends BaseProps_2 {
112
+ checked?: never;
113
+ defaultChecked: boolean;
114
+ onChange?: (value: boolean) => void;
115
+ }
116
+
48
117
  export { }