@bloomreach/react-banana-ui 1.3.0 → 1.5.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.
- package/dist/bloomreach-react-banana-ui.es.js +5927 -4407
- package/dist/bloomreach-react-banana-ui.es.js.map +1 -1
- package/dist/bloomreach-react-banana-ui.umd.js +17 -14
- package/dist/bloomreach-react-banana-ui.umd.js.map +1 -1
- package/dist/components/buttons/button/button.d.ts +3 -2
- package/dist/components/buttons/button/button.stories.d.ts +1 -0
- package/dist/components/buttons/button-group/button-group.d.ts +1 -0
- package/dist/components/buttons/toggle-button/toggle-button.d.ts +1 -0
- package/dist/components/containers/dropdown/dropdown.d.ts +1 -0
- package/dist/components/containers/scroll-region/scroll-region.d.ts +1 -0
- package/dist/components/containers/scroll-view/scroll-view.d.ts +1 -0
- package/dist/components/dropdowns/index.d.ts +1 -0
- package/dist/components/dropdowns/menu/index.d.ts +13 -0
- package/dist/components/dropdowns/menu/menu/index.d.ts +2 -0
- package/dist/components/dropdowns/menu/menu/menu.d.ts +7 -0
- package/dist/components/dropdowns/menu/menu/menu.stories.d.ts +6 -0
- package/dist/components/dropdowns/menu/menu/menu.types.d.ts +11 -0
- package/dist/components/dropdowns/menu/menu-button/index.d.ts +2 -0
- package/dist/components/dropdowns/menu/menu-button/menu-button.d.ts +4 -0
- package/dist/components/dropdowns/menu/menu-button/menu-button.stories.d.ts +6 -0
- package/dist/components/dropdowns/menu/menu-button/menu-button.types.d.ts +3 -0
- package/dist/components/dropdowns/menu/menu-content/index.d.ts +2 -0
- package/dist/components/dropdowns/menu/menu-content/menu-content.d.ts +7 -0
- package/dist/components/dropdowns/menu/menu-content/menu-content.stories.d.ts +10 -0
- package/dist/components/dropdowns/menu/menu-content/menu-content.types.d.ts +12 -0
- package/dist/components/dropdowns/menu/menu-group/index.d.ts +2 -0
- package/dist/components/dropdowns/menu/menu-group/menu-group.d.ts +8 -0
- package/dist/components/dropdowns/menu/menu-group/menu-group.stories.d.ts +6 -0
- package/dist/components/dropdowns/menu/menu-group/menu-group.types.d.ts +6 -0
- package/dist/components/dropdowns/menu/menu-group-label/index.d.ts +2 -0
- package/dist/components/dropdowns/menu/menu-group-label/menu-group-label.d.ts +8 -0
- package/dist/components/dropdowns/menu/menu-group-label/menu-group-label.stories.d.ts +6 -0
- package/dist/components/dropdowns/menu/menu-group-label/menu-group-label.types.d.ts +6 -0
- package/dist/components/dropdowns/menu/menu-item/index.d.ts +2 -0
- package/dist/components/dropdowns/menu/menu-item/menu-item.d.ts +7 -0
- package/dist/components/dropdowns/menu/menu-item/menu-item.stories.d.ts +6 -0
- package/dist/components/dropdowns/menu/menu-item/menu-item.types.d.ts +20 -0
- package/dist/components/dropdowns/menu/menu-separator/index.d.ts +1 -0
- package/dist/components/dropdowns/menu/menu-separator/menu-separator.d.ts +7 -0
- package/dist/components/dropdowns/menu/menu-separator/menu-separator.stories.d.ts +6 -0
- package/dist/components/dropdowns/menu/menu.stories.d.ts +6 -0
- package/dist/components/feedback/alert/alert-title.d.ts +1 -0
- package/dist/components/feedback/alert/alert.d.ts +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/inputs/base-field/base-field.d.ts +7 -4
- package/dist/components/inputs/base-input/base-input.d.ts +1 -0
- package/dist/components/inputs/field-label/field-label.d.ts +46 -0
- package/dist/components/inputs/field-label/index.d.ts +2 -0
- package/dist/components/inputs/index.d.ts +1 -0
- package/dist/components/inputs/internal.d.ts +2 -0
- package/dist/components/inputs/selection/selection.d.ts +1 -0
- package/dist/components/inputs/text-field/text-field.d.ts +1 -0
- package/dist/components/inputs/toggle/index.d.ts +2 -0
- package/dist/components/inputs/toggle/toggle.d.ts +57 -0
- package/dist/components/inputs/toggle-field/index.d.ts +2 -0
- package/dist/components/inputs/toggle-field/toggle-field.d.ts +43 -0
- package/dist/components/inputs/toggle-field/toggle-field.qa.stories.d.ts +5 -0
- package/dist/components/inputs/toggle-field/toggle-field.stories.d.ts +11 -0
- package/dist/components/lists/list-view/list-view.d.ts +1 -0
- package/dist/components/loaders/loader/loader.d.ts +1 -0
- package/dist/components/navigation/pagination/pagination.d.ts +1 -0
- package/dist/components/popovers/modal/modal-body.d.ts +1 -0
- package/dist/components/popovers/modal/modal.d.ts +1 -0
- package/dist/components/popovers/tooltip/tooltip.d.ts +1 -0
- package/dist/setupTests.d.ts +0 -0
- package/dist/style.css +1 -1
- package/package.json +37 -36
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ButtonHTMLAttributes,
|
|
1
|
+
import { ButtonHTMLAttributes, MouseEventHandler, ReactNode } from 'react';
|
|
2
|
+
import './button.scss';
|
|
2
3
|
export interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {
|
|
3
4
|
/**
|
|
4
5
|
* The content of the component.
|
|
@@ -40,7 +41,7 @@ export interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement
|
|
|
40
41
|
/**
|
|
41
42
|
* Callback fired when the component is clicked.
|
|
42
43
|
*/
|
|
43
|
-
onClick?:
|
|
44
|
+
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
44
45
|
/**
|
|
45
46
|
* Icon displayed before the children.
|
|
46
47
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactElement, ForwardedRef, ReactNode, SyntheticEvent } from 'react';
|
|
2
2
|
import { ButtonProps } from '../button/button';
|
|
3
|
+
import './toggle-button.scss';
|
|
3
4
|
export interface ToggleButtonProps<T extends string | number = string> extends Omit<ButtonProps, 'onClick'> {
|
|
4
5
|
/**
|
|
5
6
|
* The content of the component.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './menu';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { Menu } from './menu';
|
|
2
|
+
export { MenuButton } from './menu-button';
|
|
3
|
+
export { MenuContent } from './menu-content';
|
|
4
|
+
export { MenuGroup } from './menu-group';
|
|
5
|
+
export { MenuGroupLabel } from './menu-group-label';
|
|
6
|
+
export { MenuItem } from './menu-item';
|
|
7
|
+
export { MenuSeparator } from './menu-separator';
|
|
8
|
+
export type { MenuProps } from './menu';
|
|
9
|
+
export type { MenuButtonProps } from './menu-button';
|
|
10
|
+
export type { MenuContentProps } from './menu-content';
|
|
11
|
+
export type { MenuGroupProps } from './menu-group';
|
|
12
|
+
export type { MenuGroupLabelProps } from './menu-group-label';
|
|
13
|
+
export type { MenuItemProps } from './menu-item';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SyntheticEvent } from 'react';
|
|
2
|
+
export interface MenuProps {
|
|
3
|
+
/**
|
|
4
|
+
* Allows to control whether the dropdown is open.
|
|
5
|
+
*/
|
|
6
|
+
open?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Callback fired when the component requests to be opened or closed.
|
|
9
|
+
*/
|
|
10
|
+
onOpenChange?: (event: SyntheticEvent | null, open: boolean) => void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { MenuContentProps } from './menu-content.types';
|
|
3
|
+
import './menu-content.scss';
|
|
4
|
+
declare const MenuContent: import("react").ForwardRefExoticComponent<MenuContentProps & {
|
|
5
|
+
children?: import("react").ReactNode;
|
|
6
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
7
|
+
export default MenuContent;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import MenuContent from './menu-content';
|
|
3
|
+
declare const meta: Meta;
|
|
4
|
+
export default meta;
|
|
5
|
+
export type Story = StoryObj<typeof MenuContent>;
|
|
6
|
+
export declare const MenuContentStory: Story;
|
|
7
|
+
export declare const MenuContentTopPlacement: Story;
|
|
8
|
+
export declare const MenuContentRightPlacement: Story;
|
|
9
|
+
export declare const MenuContentBottomPlacement: Story;
|
|
10
|
+
export declare const MenuContentLeftPlacement: Story;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Placement } from '@floating-ui/react';
|
|
2
|
+
export interface MenuContentProps {
|
|
3
|
+
/**
|
|
4
|
+
* Custom class for the component
|
|
5
|
+
*/
|
|
6
|
+
className?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Placement position of the menu dropdownn wrt to trigger.
|
|
9
|
+
* @default 'bottom-end'
|
|
10
|
+
*/
|
|
11
|
+
placement?: Placement;
|
|
12
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import type { MenuGroupProps } from './menu-group.types';
|
|
3
|
+
import './menu-group.scss';
|
|
4
|
+
declare function MenuGroup(props: PropsWithChildren<MenuGroupProps>): JSX.Element;
|
|
5
|
+
declare namespace MenuGroup {
|
|
6
|
+
var displayName: string;
|
|
7
|
+
}
|
|
8
|
+
export default MenuGroup;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import type { MenuGroupLabelProps } from './menu-group-label.types';
|
|
3
|
+
import './menu-group-label.scss';
|
|
4
|
+
declare function MenuGroupLabel(props: PropsWithChildren<MenuGroupLabelProps>): JSX.Element;
|
|
5
|
+
declare namespace MenuGroupLabel {
|
|
6
|
+
var displayName: string;
|
|
7
|
+
}
|
|
8
|
+
export default MenuGroupLabel;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { MenuItemProps } from './menu-item.types';
|
|
3
|
+
import './menu-item.scss';
|
|
4
|
+
declare const MenuItem: import("react").ForwardRefExoticComponent<MenuItemProps & {
|
|
5
|
+
children?: import("react").ReactNode;
|
|
6
|
+
} & import("react").RefAttributes<HTMLUListElement>>;
|
|
7
|
+
export default MenuItem;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MouseEventHandler, ReactNode } from 'react';
|
|
2
|
+
export interface MenuItemProps {
|
|
3
|
+
/**
|
|
4
|
+
* Custom class for the component
|
|
5
|
+
*/
|
|
6
|
+
className?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Event fired on click or selection of an item
|
|
9
|
+
*/
|
|
10
|
+
onClick?: MouseEventHandler<HTMLElement>;
|
|
11
|
+
/**
|
|
12
|
+
* If `true`, the menu item will be disabled.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Icon displayed before the content
|
|
18
|
+
*/
|
|
19
|
+
startIcon?: ReactNode;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as MenuSeparator } from './menu-separator';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import './base-field.scss';
|
|
2
3
|
export interface BaseFieldProps {
|
|
3
4
|
/**
|
|
4
5
|
* Custom class name for the container of this component.
|
|
@@ -8,10 +9,6 @@ export interface BaseFieldProps {
|
|
|
8
9
|
* The control element to render as the main content of the field.
|
|
9
10
|
*/
|
|
10
11
|
control: ReactNode;
|
|
11
|
-
/**
|
|
12
|
-
* The `id` of the `control` element to connect it with `label` in the field.
|
|
13
|
-
*/
|
|
14
|
-
controlId: string;
|
|
15
12
|
/**
|
|
16
13
|
* If `true`, the field will indicate an error.
|
|
17
14
|
*/
|
|
@@ -28,6 +25,11 @@ export interface BaseFieldProps {
|
|
|
28
25
|
* The label content.
|
|
29
26
|
*/
|
|
30
27
|
label?: ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* The position of the label.
|
|
30
|
+
* @default 'block-start'
|
|
31
|
+
*/
|
|
32
|
+
labelPosition?: 'block-start' | 'inline-start' | 'inline-end';
|
|
31
33
|
/**
|
|
32
34
|
* The metadata content.
|
|
33
35
|
*/
|
|
@@ -37,6 +39,7 @@ export interface BaseFieldProps {
|
|
|
37
39
|
*/
|
|
38
40
|
tooltip?: ReactNode;
|
|
39
41
|
}
|
|
42
|
+
export declare const getZeroSpace: () => JSX.Element;
|
|
40
43
|
/**
|
|
41
44
|
* @internal
|
|
42
45
|
* Base component provides the layout for the field which includes:
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import './field-label.scss';
|
|
3
|
+
export interface FieldLabelProps {
|
|
4
|
+
/**
|
|
5
|
+
* Custom class name for the container of the component.
|
|
6
|
+
*/
|
|
7
|
+
className?: string;
|
|
8
|
+
/**
|
|
9
|
+
* The content of the component.
|
|
10
|
+
*/
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* The `id` of the element the label is associated with.
|
|
14
|
+
*/
|
|
15
|
+
htmlFor?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The size of the label.
|
|
18
|
+
* @default 'bold'
|
|
19
|
+
*/
|
|
20
|
+
view?: 'normal' | 'bold';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @internal
|
|
24
|
+
* The `FieldLabel` component renders a label for a form field like `input`, `select`, `textarea`, etc.
|
|
25
|
+
* It has a default bold view and can be changed to a normal view for checkbox, radio or toggle fields.
|
|
26
|
+
* Internally used with the `BaseField` component to render a label for a field.
|
|
27
|
+
* Might be used as a standalone component for custom form fields, check the usage example.
|
|
28
|
+
*
|
|
29
|
+
* ### Usage
|
|
30
|
+
*
|
|
31
|
+
* ```tsx
|
|
32
|
+
* import { FieldLabel } from '@bloomreach/react-banana-ui';
|
|
33
|
+
* import { FieldInput } from '@bloomreach/react-banana-ui';
|
|
34
|
+
*
|
|
35
|
+
* export default function MyCustomLabel() {
|
|
36
|
+
* return (
|
|
37
|
+
* <>
|
|
38
|
+
* <FieldInput id="input" />
|
|
39
|
+
* <FieldLabel htmlFor="input">Write an example of component usage</FieldLabel>
|
|
40
|
+
* </>
|
|
41
|
+
* );
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
declare const FieldLabel: import("react").ForwardRefExoticComponent<FieldLabelProps & import("react").RefAttributes<HTMLLabelElement>>;
|
|
46
|
+
export default FieldLabel;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import './toggle.scss';
|
|
3
|
+
export interface ToggleProps {
|
|
4
|
+
/**
|
|
5
|
+
* If `true`, the toggle is checked.
|
|
6
|
+
*/
|
|
7
|
+
checked?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Custom class name for the container of the component.
|
|
10
|
+
*/
|
|
11
|
+
className?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The state of the toggle when it is initially rendered. Use when you do not need to control its state.
|
|
14
|
+
*/
|
|
15
|
+
defaultChecked?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* When `true`, prevents the user from interacting with the switch.
|
|
18
|
+
*/
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The props applied to the input element.
|
|
22
|
+
*/
|
|
23
|
+
inputProps?: React.InputHTMLAttributes<HTMLInputElement>;
|
|
24
|
+
/**
|
|
25
|
+
* The `name` of the `input` element.
|
|
26
|
+
*/
|
|
27
|
+
name?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Callback fired when the state is changed.
|
|
30
|
+
*/
|
|
31
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
32
|
+
/**
|
|
33
|
+
* If `true`, the component is read only and prevent user to change value.
|
|
34
|
+
*/
|
|
35
|
+
readOnly?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* If `true`, the `input` element is required.
|
|
38
|
+
*/
|
|
39
|
+
required?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Toggle represents an action that changes a state by clicking on it.
|
|
43
|
+
* They are usually used for actions or options that have an immediate effect on the UI.
|
|
44
|
+
* They usually do not need to be confirmed or reviewed.
|
|
45
|
+
*
|
|
46
|
+
* ### Usage
|
|
47
|
+
*
|
|
48
|
+
* ```tsx
|
|
49
|
+
* import { Toggle } from '@bloomreach/react-banana-ui';
|
|
50
|
+
*
|
|
51
|
+
* export default function MyCustomToggle() {
|
|
52
|
+
* return <Toggle name="fieldName" />;
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
declare const Toggle: import("react").ForwardRefExoticComponent<ToggleProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
57
|
+
export default Toggle;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ToggleProps } from '../../internal';
|
|
3
|
+
import './toggle-field.scss';
|
|
4
|
+
export interface ToggleFieldProps extends ToggleProps {
|
|
5
|
+
/**
|
|
6
|
+
* Custom class name for the container of the component.
|
|
7
|
+
*/
|
|
8
|
+
className?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The label content.
|
|
11
|
+
*/
|
|
12
|
+
label?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* Tooltip to display when the field has label.
|
|
15
|
+
*/
|
|
16
|
+
tooltip?: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The toggle field represents an action that changes a state by clicking on it.
|
|
20
|
+
* Usually used for actions or options that have an immediate effect on the UI and
|
|
21
|
+
* do not need to be confirmed or reviewed.
|
|
22
|
+
*
|
|
23
|
+
* ### Usage
|
|
24
|
+
*
|
|
25
|
+
* ```tsx
|
|
26
|
+
* import { ToggleField } from '@bloomreach/react-banana-ui';
|
|
27
|
+
* import { useState } from 'react';
|
|
28
|
+
*
|
|
29
|
+
* export default function AppTheme() {
|
|
30
|
+
* const [isDark, setIsDark] = useState(false);
|
|
31
|
+
*
|
|
32
|
+
* return (
|
|
33
|
+
* <ToggleField
|
|
34
|
+
* label="Dark mode"
|
|
35
|
+
* checked={isDark}
|
|
36
|
+
* onChange={() => setIsDark(!isDark)}
|
|
37
|
+
* />
|
|
38
|
+
* );
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
declare const ToggleField: import("react").ForwardRefExoticComponent<ToggleFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
43
|
+
export default ToggleField;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import ToggleField from './toggle-field';
|
|
3
|
+
declare const meta: Meta<typeof ToggleField>;
|
|
4
|
+
export default meta;
|
|
5
|
+
export type Story = StoryObj<typeof ToggleField>;
|
|
6
|
+
export declare const Basic: Story;
|
|
7
|
+
export declare const WithTooltip: Story;
|
|
8
|
+
export declare const WithoutLabel: Story;
|
|
9
|
+
export declare const Controlled: Story;
|
|
10
|
+
export declare const Disabled: Story;
|
|
11
|
+
export declare const ReadOnly: Story;
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { DOMRectBounds, INestedChildren } from '../../../utils';
|
|
3
3
|
import { ScrollRegion } from '../../containers/scroll-region/scroll-region';
|
|
4
4
|
import { ScrollView } from '../../containers/scroll-view/scroll-view';
|
|
5
|
+
import './list-view.scss';
|
|
5
6
|
export interface IRowProps {
|
|
6
7
|
/** The index of the row to be rendered. */
|
|
7
8
|
index: number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ModalBodyProps } from './modal-types';
|
|
3
|
+
import './modal.scss';
|
|
3
4
|
/**
|
|
4
5
|
* Modal body component is used to render the body section of the modal dialog.
|
|
5
6
|
* Use the `padding` prop to control the padding of the body section, the default is `narrow`.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Placement } from '@floating-ui/react';
|
|
2
2
|
import React, { ReactNode, ReactElement, HTMLAttributes } from 'react';
|
|
3
|
+
import './tooltip.scss';
|
|
3
4
|
export interface TooltipProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
4
5
|
/**
|
|
5
6
|
* Custom class name for the tooltip container
|
|
File without changes
|