@bloomreach/react-banana-ui 1.14.0 → 1.16.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.
Files changed (32) hide show
  1. package/dist/bloomreach-react-banana-ui.es.js +4405 -3964
  2. package/dist/bloomreach-react-banana-ui.es.js.map +1 -1
  3. package/dist/bloomreach-react-banana-ui.umd.js +18 -18
  4. package/dist/bloomreach-react-banana-ui.umd.js.map +1 -1
  5. package/dist/components/data-display/index.d.ts +1 -0
  6. package/dist/components/data-display/typography/index.d.ts +2 -0
  7. package/dist/components/data-display/typography/typography.d.ts +4 -0
  8. package/dist/components/data-display/typography/typography.qa.stories.d.ts +7 -0
  9. package/dist/components/data-display/typography/typography.stories.d.ts +8 -0
  10. package/dist/components/data-display/typography/typography.types.d.ts +46 -0
  11. package/dist/components/navigation/index.d.ts +1 -0
  12. package/dist/components/navigation/tabs/index.d.ts +4 -0
  13. package/dist/components/navigation/tabs/tab/index.d.ts +2 -0
  14. package/dist/components/navigation/tabs/tab/tab.d.ts +30 -0
  15. package/dist/components/navigation/tabs/tab/tab.types.d.ts +28 -0
  16. package/dist/components/navigation/tabs/tab-list/index.d.ts +2 -0
  17. package/dist/components/navigation/tabs/tab-list/tab-list.d.ts +30 -0
  18. package/dist/components/navigation/tabs/tab-list/tab-list.types.d.ts +16 -0
  19. package/dist/components/navigation/tabs/tab-panel/index.d.ts +2 -0
  20. package/dist/components/navigation/tabs/tab-panel/tab-panel.d.ts +29 -0
  21. package/dist/components/navigation/tabs/tab-panel/tab-panel.types.d.ts +25 -0
  22. package/dist/components/navigation/tabs/tabs/index.d.ts +2 -0
  23. package/dist/components/navigation/tabs/tabs/tabs.d.ts +30 -0
  24. package/dist/components/navigation/tabs/tabs/tabs.types.d.ts +31 -0
  25. package/dist/components/navigation/tabs/tabs.qa.stories.d.ts +6 -0
  26. package/dist/components/navigation/tabs/tabs.stories.d.ts +10 -0
  27. package/dist/style.css +1 -1
  28. package/dist/utils/index.d.ts +1 -0
  29. package/dist/utils/types/index.d.ts +2 -0
  30. package/dist/utils/types/polymorphic-prop.types.d.ts +13 -0
  31. package/dist/utils/types/simplify.d.ts +3 -0
  32. package/package.json +1 -1
@@ -10,3 +10,4 @@ export * from './table-row';
10
10
  export * from './table-sort-label';
11
11
  export * from './table';
12
12
  export * from './tag-group';
13
+ export * from './typography';
@@ -0,0 +1,2 @@
1
+ export { default as Typography } from './typography';
2
+ export type { TypographyProps } from './typography.types';
@@ -0,0 +1,4 @@
1
+ import type { TypographyComponent } from './typography.types';
2
+ import './typography.scss';
3
+ declare const _default: TypographyComponent;
4
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import { Meta } from '@storybook/react';
2
+ import { type Story } from './typography.stories';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ export declare const Basic: Story;
6
+ export declare const AllVariants: Story;
7
+ export declare const AllColors: Story;
@@ -0,0 +1,8 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import Typography from './typography';
3
+ declare const meta: Meta<typeof Typography>;
4
+ export default meta;
5
+ export type Story = StoryObj<typeof Typography>;
6
+ export declare const Basic: Story;
7
+ export declare const AllVariants: Story;
8
+ export declare const AllColors: Story;
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import { PolymorphicComponentPropsWithRef, ResolveRoot, VariantMapping } from '../../../utils';
3
+ interface TypographyInternalProps<Variant extends keyof TypographyVariantMapping | undefined> {
4
+ /**
5
+ * Color of typography element.
6
+ * If `undefined`, the CSS color value will be inherited.
7
+ */
8
+ color?: 'body' | 'subtl' | 'link' | 'success' | 'warning' | 'negative';
9
+ /**
10
+ * Variant of typography.
11
+ * If `undefined`, the CSS font value will be inherited.
12
+ */
13
+ variant?: Variant;
14
+ }
15
+ export type TypographyVariantMapping = VariantMapping<'p'> & {
16
+ link: 'a';
17
+ 'link-small': 'a';
18
+ 'heading-xl': 'h1';
19
+ 'heading-1': 'h1';
20
+ 'heading-2': 'h2';
21
+ 'heading-3': 'h3';
22
+ 'heading-4': 'h4';
23
+ 'heading-5': 'h5';
24
+ text: 'p';
25
+ 'text-bold': 'p';
26
+ 'text-small': 'p';
27
+ 'text-small-bold': 'p';
28
+ 'text-mono': 'code';
29
+ 'text-mono-small': 'code';
30
+ };
31
+ export type TypographyProps<RootElement extends React.ElementType | undefined, Variant extends keyof TypographyVariantMapping | undefined> = PolymorphicComponentPropsWithRef<ResolveRoot<RootElement, Variant, TypographyVariantMapping>, TypographyInternalProps<Variant>>;
32
+ export type TypographyComponent = {
33
+ /**
34
+ * When `as` prop is defined.
35
+ */
36
+ <RootElement extends React.ElementType>(props: {
37
+ as: RootElement;
38
+ } & PolymorphicComponentPropsWithRef<RootElement, TypographyInternalProps<keyof TypographyVariantMapping>>): JSX.Element | null;
39
+ /**
40
+ * When `as` prop is not defined.
41
+ */
42
+ <Variant extends keyof TypographyVariantMapping | undefined>(props: PolymorphicComponentPropsWithRef<Variant extends keyof TypographyVariantMapping ? TypographyVariantMapping[Variant] : TypographyVariantMapping['default'], TypographyInternalProps<Variant>>): JSX.Element | null;
43
+ displayName?: string;
44
+ propTypes?: any;
45
+ };
46
+ export {};
@@ -1 +1,2 @@
1
1
  export * from './pagination';
2
+ export * from './tabs';
@@ -0,0 +1,4 @@
1
+ export * from './tab';
2
+ export * from './tab-list';
3
+ export * from './tab-panel';
4
+ export * from './tabs';
@@ -0,0 +1,2 @@
1
+ export { default as Tab } from './tab';
2
+ export type { TabProps } from './tab.types';
@@ -0,0 +1,30 @@
1
+ /// <reference types="react" />
2
+ import type { TabProps } from './tab.types';
3
+ import './tab.scss';
4
+ /**
5
+ * The tab element itself.
6
+ * Clicking on a tab displays its corresponding panel.
7
+ *
8
+ * ### Usages
9
+ *
10
+ * ```tsx
11
+ * import { Tabs, TabList, Tab, TabPanel } from '@bloomreach/react-banana-ui';
12
+ *
13
+ * export default function MyCustomComponent() {
14
+ * return (
15
+ * <Tabs>
16
+ * <TabList>
17
+ * <Tab value="tab-1">Tab 1</Tab>
18
+ * <Tab value="tab-2" disabled>Tab 2</Tab>
19
+ * <Tab value="tab-3" startIcon={<SomeIcon />}>Tab 3</Tab>
20
+ * </TabList>
21
+ * <TabPanel value="tab-1">Tab 1 content</TabPanel>
22
+ * <TabPanel value="tab-2">Tab 2 content</TabPanel>
23
+ * <TabPanel value="tab-3">Tab 3 content</TabPanel>
24
+ * </Tabs>
25
+ * );
26
+ * }
27
+ * ```
28
+ */
29
+ declare const Tab: import("react").ForwardRefExoticComponent<TabProps & import("react").RefAttributes<Element>>;
30
+ export default Tab;
@@ -0,0 +1,28 @@
1
+ import { ReactNode } from 'react';
2
+ export interface TabProps {
3
+ /**
4
+ * Custom class name for the container of the component.
5
+ */
6
+ className?: string;
7
+ /**
8
+ * The content of the component.
9
+ */
10
+ children?: ReactNode;
11
+ /**
12
+ * If true, the tab is disabled.
13
+ */
14
+ disabled?: boolean;
15
+ /**
16
+ * You can provide your own value.
17
+ * Otherwise, it falls back to the child position index.
18
+ */
19
+ value?: number | string;
20
+ /**
21
+ * Callback fired when the tab is clicked.
22
+ */
23
+ onClick?: (event: React.MouseEvent<Element, MouseEvent>, value?: number | string) => void;
24
+ /**
25
+ * Icon displayed before the content
26
+ */
27
+ startIcon?: ReactNode;
28
+ }
@@ -0,0 +1,2 @@
1
+ export { default as TabList } from './tab-list';
2
+ export type { TabListProps } from './tab-list.types';
@@ -0,0 +1,30 @@
1
+ /// <reference types="react" />
2
+ import type { TabListProps } from './tab-list.types';
3
+ import './tab-list.scss';
4
+ /**
5
+ * The container that houses the tabs.
6
+ * Responsible for handling focus and keyboard navigation between tabs.
7
+ *
8
+ * ### Usages
9
+ *
10
+ * ```tsx
11
+ * import { Tabs, TabList, Tab, TabPanel } from '@bloomreach/react-banana-ui';
12
+ *
13
+ * export default function MyCustomComponent() {
14
+ * return (
15
+ * <Tabs>
16
+ * <TabList variant='primary'>
17
+ * <Tab value="tab-1">Tab 1</Tab>
18
+ * <Tab value="tab-2">Tab 2</Tab>
19
+ * <Tab value="tab-3">Tab 3</Tab>
20
+ * </TabList>
21
+ * <TabPanel value="tab-1">Tab 1 content</TabPanel>
22
+ * <TabPanel value="tab-2">Tab 2 content</TabPanel>
23
+ * <TabPanel value="tab-3">Tab 3 content</TabPanel>
24
+ * </Tabs>
25
+ * );
26
+ * }
27
+ * ```
28
+ */
29
+ declare const TabList: import("react").ForwardRefExoticComponent<TabListProps & import("react").RefAttributes<HTMLDivElement>>;
30
+ export default TabList;
@@ -0,0 +1,16 @@
1
+ import { ReactNode } from 'react';
2
+ export interface TabListProps {
3
+ /**
4
+ * Custom class name for the container of the component.
5
+ */
6
+ className?: string;
7
+ /**
8
+ * The content of the component.
9
+ */
10
+ children?: ReactNode;
11
+ /**
12
+ * Variant of tab.
13
+ * @default 'primary'
14
+ */
15
+ variant?: 'primary' | 'secondary';
16
+ }
@@ -0,0 +1,2 @@
1
+ export { default as TabPanel } from './tab-panel';
2
+ export type { TabPanelProps } from './tab-panel.types';
@@ -0,0 +1,29 @@
1
+ /// <reference types="react" />
2
+ import type { TabPanelProps } from './tab-panel.types';
3
+ import './tab-panel.scss';
4
+ /**
5
+ * The card that hosts the content associated with a tab.
6
+ *
7
+ * ### Usages
8
+ *
9
+ * ```tsx
10
+ * import { Tabs, TabList, Tab, TabPanel } from '@bloomreach/react-banana-ui';
11
+ *
12
+ * export default function MyCustomComponent() {
13
+ * return (
14
+ * <Tabs>
15
+ * <TabList>
16
+ * <Tab value="tab-1">Tab 1</Tab>
17
+ * <Tab value="tab-2">Tab 2</Tab>
18
+ * <Tab value="tab-3">Tab 3</Tab>
19
+ * </TabList>
20
+ * <TabPanel value="tab-1" keepMounted>Tab 1 content</TabPanel>
21
+ * <TabPanel value="tab-2">Tab 2 content</TabPanel>
22
+ * <TabPanel value="tab-3">Tab 3 content</TabPanel>
23
+ * </Tabs>
24
+ * );
25
+ * }
26
+ * ```
27
+ */
28
+ declare const TabPanel: import("react").ForwardRefExoticComponent<TabPanelProps & import("react").RefAttributes<HTMLElement>>;
29
+ export default TabPanel;
@@ -0,0 +1,25 @@
1
+ import { ReactNode } from 'react';
2
+ export interface TabPanelProps {
3
+ /**
4
+ * Custom class name for the container of the component.
5
+ */
6
+ className?: string;
7
+ /**
8
+ * The content of the component.
9
+ */
10
+ children?: ReactNode;
11
+ /**
12
+ * The value of the TabPanel. It will be shown when the Tab with the corresponding value is selected.
13
+ * If not provided, it will fall back to the index of the panel.
14
+ * It is recommended to explicitly provide it, as it's required for the tab panel to be rendered.
15
+ */
16
+ value?: number | string;
17
+ /**
18
+ * Whether to mount the tab panel in the DOM even when it is not currently selected.
19
+ * Inactive tab panels are inert and cannot be interacted with.
20
+ * This prop can be useful in SEO situation or when you want to maximize
21
+ * the responsiveness of the Tab.
22
+ * @default false
23
+ */
24
+ keepMounted?: boolean;
25
+ }
@@ -0,0 +1,2 @@
1
+ export { default as Tabs } from './tabs';
2
+ export type { TabsProps } from './tabs.types';
@@ -0,0 +1,30 @@
1
+ /// <reference types="react" />
2
+ import type { TabsProps } from './tabs.types';
3
+ import './tabs.scss';
4
+ /**
5
+ * The top-level component that wraps the Tabs List and Tab Panel components
6
+ * so that tabs and their panels can communicate with one another.
7
+ *
8
+ * ### Usages
9
+ *
10
+ * ```tsx
11
+ * import { Tabs, TabList, Tab, TabPanel } from '@bloomreach/react-banana-ui';
12
+ *
13
+ * export default function MyCustomComponent() {
14
+ * return (
15
+ * <Tabs defaultValue="tab-1">
16
+ * <TabList>
17
+ * <Tab value="tab-1">Tab 1</Tab>
18
+ * <Tab value="tab-2">Tab 2</Tab>
19
+ * <Tab value="tab-3">Tab 3</Tab>
20
+ * </TabList>
21
+ * <TabPanel value="tab-1">Tab 1 content</TabPanel>
22
+ * <TabPanel value="tab-2">Tab 2 content</TabPanel>
23
+ * <TabPanel value="tab-3">Tab 3 content</TabPanel>
24
+ * </Tabs>
25
+ * );
26
+ * }
27
+ * ```
28
+ */
29
+ declare const Tabs: import("react").ForwardRefExoticComponent<TabsProps & import("react").RefAttributes<HTMLDivElement>>;
30
+ export default Tabs;
@@ -0,0 +1,31 @@
1
+ import { ReactNode } from 'react';
2
+ export interface TabsProps {
3
+ /**
4
+ * Custom class name for the container of the component.
5
+ */
6
+ className?: string;
7
+ /**
8
+ * The content of the component.
9
+ */
10
+ children?: ReactNode;
11
+ /**
12
+ * The default value. Use when the component is not controlled.
13
+ */
14
+ defaultValue?: number | string;
15
+ /**
16
+ * The value of the currently selected Tab.
17
+ * Use when the component is controlled.
18
+ * If you don't want any selected Tab, you can set this prop to null.
19
+ */
20
+ value?: number | string | null;
21
+ /**
22
+ * Callback invoked when new value is being set.
23
+ */
24
+ onChange?: (event: React.MouseEvent<Element, MouseEvent> | React.KeyboardEvent<Element> | React.FocusEvent<Element, Element> | React.SyntheticEvent<Element, Event> | null, value: string | number | null) => void;
25
+ /**
26
+ * If true the selected tab changes on focus.
27
+ * Otherwise it only changes on activation.
28
+ * @default false
29
+ */
30
+ selectionFollowsFocus?: boolean;
31
+ }
@@ -0,0 +1,6 @@
1
+ import { Meta } from '@storybook/react';
2
+ import { type Story } from './tabs.stories';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ export declare const Basic: Story;
6
+ export declare const DifferentVariants: Story;
@@ -0,0 +1,10 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { Tabs } from './tabs';
3
+ declare const meta: Meta<typeof Tabs>;
4
+ export default meta;
5
+ export type Story = StoryObj<typeof Tabs>;
6
+ export declare const Basic: Story;
7
+ export declare const Controlled: Story;
8
+ export declare const PrimaryTab: Story;
9
+ export declare const SecondaryTab: Story;
10
+ export declare const keepMounted: Story;