@babylonlabs-io/core-ui 1.25.0 → 1.26.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.
@@ -12,6 +12,7 @@ export interface AccordionProps {
12
12
  onChange?: (expanded: boolean) => void;
13
13
  className?: string;
14
14
  disabled?: boolean;
15
+ fluid?: boolean;
15
16
  }
16
- export declare function Accordion({ expanded: isExpanded, defaultExpanded, onChange, className, disabled, children, }: PropsWithChildren<AccordionProps>): import("react/jsx-runtime").JSX.Element;
17
+ export declare function Accordion({ expanded: isExpanded, defaultExpanded, onChange, className, disabled, fluid, children, }: PropsWithChildren<AccordionProps>): import("react/jsx-runtime").JSX.Element;
17
18
  export {};
@@ -6,7 +6,7 @@ export const Context = createContext({
6
6
  disabled: false,
7
7
  expanded: false,
8
8
  });
9
- export function Accordion({ expanded: isExpanded, defaultExpanded, onChange, className, disabled = false, children, }) {
9
+ export function Accordion({ expanded: isExpanded, defaultExpanded, onChange, className, disabled = false, fluid = false, children, }) {
10
10
  const [expanded = false, setExpanded] = useControlledState({
11
11
  value: isExpanded,
12
12
  defaultValue: defaultExpanded,
@@ -21,5 +21,5 @@ export function Accordion({ expanded: isExpanded, defaultExpanded, onChange, cla
21
21
  expanded: expanded && !disabled,
22
22
  toggle: !disabled ? handleToggle : undefined,
23
23
  }), [defaultExpanded, expanded, disabled, handleToggle]);
24
- return (_jsx(Context.Provider, { value: context, children: _jsx("div", { className: twJoin("bbn-accordion", disabled && "bbn-accordion-disabled", className), children: children }) }));
24
+ return (_jsx(Context.Provider, { value: context, children: _jsx("div", { className: twJoin("bbn-accordion", disabled && "bbn-accordion-disabled", fluid && "bbn-accordion-fluid", className), children: children }) }));
25
25
  }
@@ -1,8 +1,10 @@
1
1
  import { type PropsWithChildren, type ReactNode } from "react";
2
+ import { IconButtonProps } from "@/components/Button";
2
3
  interface AccordionSummaryProps {
3
4
  renderIcon?: (expanded: boolean) => ReactNode;
4
5
  className?: string;
5
6
  iconClassName?: string;
7
+ iconProps?: IconButtonProps;
6
8
  }
7
- export declare function AccordionSummary({ className, iconClassName, children, renderIcon, }: PropsWithChildren<AccordionSummaryProps>): import("react/jsx-runtime").JSX.Element;
9
+ export declare function AccordionSummary({ className, iconClassName, iconProps, children, renderIcon, }: PropsWithChildren<AccordionSummaryProps>): import("react/jsx-runtime").JSX.Element;
8
10
  export {};
@@ -3,8 +3,8 @@ import { useContext } from "react";
3
3
  import { twJoin } from "tailwind-merge";
4
4
  import { IconButton } from "@/components/Button";
5
5
  import { Context } from "../Accordion";
6
- export function AccordionSummary({ className, iconClassName, children, renderIcon = () => null, }) {
6
+ export function AccordionSummary({ className, iconClassName, iconProps, children, renderIcon = () => null, }) {
7
7
  const { expanded, toggle } = useContext(Context);
8
8
  const icon = renderIcon(expanded);
9
- return (_jsxs("div", { className: twJoin("bbn-accordion-summary", className), onClick: toggle, children: [children, icon && _jsx(IconButton, { className: twJoin("bbn-accordion-icon", iconClassName), children: icon })] }));
9
+ return (_jsxs("div", { className: twJoin("bbn-accordion-summary", className), onClick: toggle, children: [children, icon && _jsx(IconButton, { className: twJoin("bbn-accordion-icon", iconClassName), ...iconProps, children: icon })] }));
10
10
  }
@@ -1,4 +1,10 @@
1
- import { DetailedHTMLProps, HTMLAttributes } from "react";
1
+ import { type DetailedHTMLProps, type HTMLAttributes } from "react";
2
2
  import "./IconButton.css";
3
- export type IconButtonProps = DetailedHTMLProps<HTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
4
- export declare const IconButton: ({ className, ...restProps }: IconButtonProps) => import("react/jsx-runtime").JSX.Element;
3
+ type ButtonProps = Omit<DetailedHTMLProps<HTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "size">;
4
+ export interface IconButtonProps extends ButtonProps {
5
+ className?: string;
6
+ variant?: "outlined" | "contained";
7
+ size?: "small" | "medium" | "large";
8
+ }
9
+ export declare const IconButton: import("react").ForwardRefExoticComponent<Omit<IconButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
10
+ export {};
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
2
3
  import { twJoin } from "tailwind-merge";
3
4
  import "./IconButton.css";
4
- export const IconButton = ({ className, ...restProps }) => {
5
- return _jsx("button", { ...restProps, className: twJoin("bbn-btn-icon", className) });
6
- };
5
+ export const IconButton = forwardRef(({ variant = "outlined", size = "large", className, ...restProps }, ref) => {
6
+ return (_jsx("button", { ...restProps, ref: ref, className: twJoin("bbn-btn-icon", `bbn-btn-icon-${variant}`, `bbn-btn-icon-${size}`, className) }));
7
+ });
@@ -4,3 +4,9 @@ declare const meta: Meta<typeof IconButton>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof meta>;
6
6
  export declare const Default: Story;
7
+ export declare const OutlinedSmall: Story;
8
+ export declare const OutlinedMedium: Story;
9
+ export declare const OutlinedLarge: Story;
10
+ export declare const ContainedSmall: Story;
11
+ export declare const ContainedMedium: Story;
12
+ export declare const ContainedLarge: Story;
@@ -11,3 +11,45 @@ export const Default = {
11
11
  children: _jsx(RiCloseLargeLine, { size: 24 }),
12
12
  },
13
13
  };
14
+ export const OutlinedSmall = {
15
+ args: {
16
+ size: "small",
17
+ variant: "outlined",
18
+ children: _jsx(RiCloseLargeLine, { size: 20 }),
19
+ },
20
+ };
21
+ export const OutlinedMedium = {
22
+ args: {
23
+ size: "medium",
24
+ variant: "outlined",
25
+ children: _jsx(RiCloseLargeLine, { size: 22 }),
26
+ },
27
+ };
28
+ export const OutlinedLarge = {
29
+ args: {
30
+ size: "large",
31
+ variant: "outlined",
32
+ children: _jsx(RiCloseLargeLine, { size: 24 }),
33
+ },
34
+ };
35
+ export const ContainedSmall = {
36
+ args: {
37
+ size: "small",
38
+ variant: "contained",
39
+ children: _jsx(RiCloseLargeLine, { size: 20 }),
40
+ },
41
+ };
42
+ export const ContainedMedium = {
43
+ args: {
44
+ size: "medium",
45
+ variant: "contained",
46
+ children: _jsx(RiCloseLargeLine, { size: 22 }),
47
+ },
48
+ };
49
+ export const ContainedLarge = {
50
+ args: {
51
+ size: "large",
52
+ variant: "contained",
53
+ children: _jsx(RiCloseLargeLine, { size: 24 }),
54
+ },
55
+ };
@@ -3,6 +3,6 @@ import { forwardRef } from "react";
3
3
  import { twJoin } from "tailwind-merge";
4
4
  import "./Input.css";
5
5
  export const Input = forwardRef(({ className, prefix, suffix, disabled = false, state = "default", ...props }, ref) => {
6
- return (_jsxs("div", { className: twJoin("bbn-input", disabled && "bbn-input-disabled", `bbn-input-${state}`), children: [prefix && _jsx("div", { className: "bbn-input-prefix", children: prefix }), _jsx("input", { ref: ref, className: twJoin("bbn-input-field", className), disabled: disabled, ...props }), suffix && _jsx("div", { className: "bbn-input-suffix", children: suffix })] }));
6
+ return (_jsxs("div", { className: twJoin("bbn-input", `bbn-input-${state}`, disabled && "bbn-input-disabled", suffix && "bbn-input-has-suffix"), children: [prefix && _jsx("div", { className: "bbn-input-prefix", children: prefix }), _jsx("input", { ref: ref, className: twJoin("bbn-input-field", className), disabled: disabled, ...props }), suffix && _jsx("div", { className: "bbn-input-suffix", children: suffix })] }));
7
7
  });
8
8
  Input.displayName = "Input";
@@ -1,6 +1,8 @@
1
1
  import type { CSSProperties, ReactNode } from "react";
2
- export declare const SubSection: ({ children, style, className, }: {
2
+ import "./SubSection.css";
3
+ export declare const SubSection: ({ children, style, variant, className, }: {
3
4
  children: ReactNode;
4
5
  style?: CSSProperties;
6
+ variant?: "outlined" | "contained";
5
7
  className?: string;
6
8
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,4 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { twJoin } from "tailwind-merge";
3
- export const SubSection = ({ children, style, className, }) => (_jsx("div", { className: twJoin("flex rounded bg-secondary-highlight p-4 text-accent-primary", className), style: style, children: children }));
3
+ import "./SubSection.css";
4
+ export const SubSection = ({ children, style, variant = "contained", className, }) => (_jsx("div", { className: twJoin("bbn-subsection", `bbn-subsection-${variant}`, className), style: style, children: children }));
@@ -9,7 +9,7 @@ import "./Table.css";
9
9
  import { useControlledState } from "@/hooks/useControlledState";
10
10
  import { useTableSort } from "@/hooks/useTableSort";
11
11
  import { Row } from "./components/Row";
12
- function TableBase({ data, columns, className, wrapperClassName, hasMore = false, loading = false, onLoadMore, onRowSelect, isRowSelectable, selectedRow: selectedRowProp, defaultSelectedRow, onSelectedRowChange, ...restProps }, ref) {
12
+ function TableBase({ data, columns, className, wrapperClassName, fluid = false, hasMore = false, loading = false, onLoadMore, onRowSelect, isRowSelectable, selectedRow: selectedRowProp, defaultSelectedRow, onSelectedRowChange, ...restProps }, ref) {
13
13
  const tableRef = useRef(null);
14
14
  useImperativeHandle(ref, () => tableRef.current, []);
15
15
  const { sortStates, handleColumnSort, sortedData } = useTableSort(data, columns);
@@ -34,7 +34,10 @@ function TableBase({ data, columns, className, wrapperClassName, hasMore = false
34
34
  onColumnSort: handleColumnSort,
35
35
  onRowSelect: handleRowSelect,
36
36
  }), [sortedData, columns, sortStates, handleColumnSort, handleRowSelect]);
37
- return (_jsx(TableContext.Provider, { value: contextValue, children: _jsx("div", { ref: tableRef, className: twJoin("bbn-table-wrapper", wrapperClassName), children: _jsxs("table", { className: twJoin("bbn-table", className), ...restProps, children: [_jsx("thead", { className: twJoin("bbn-table-header", isScrolledTop && "scrolled-top"), children: _jsx("tr", { children: columns.map((column) => (_jsx(Column, { className: column.headerClassName, name: column.key, sorter: column.sorter, frozen: column.frozen, showFrozenShadow: (column.frozen === 'left' && isLeftScrolled) ||
37
+ const isHeadVisible = useMemo(() => {
38
+ return columns.some((column) => column.header && column.header !== '');
39
+ }, [columns]);
40
+ return (_jsx(TableContext.Provider, { value: contextValue, children: _jsx("div", { ref: tableRef, className: twJoin("bbn-table-wrapper", fluid && "bbn-table-wrapper-fluid", wrapperClassName), children: _jsxs("table", { className: twJoin("bbn-table", fluid && "bbn-table-fluid", className), ...restProps, children: [_jsx("thead", { className: twJoin("bbn-table-header", isScrolledTop && "scrolled-top", !isHeadVisible && "hidden"), children: _jsx("tr", { children: columns.map((column) => (_jsx(Column, { className: column.headerClassName, name: column.key, sorter: column.sorter, frozen: column.frozen, showFrozenShadow: (column.frozen === 'left' && isLeftScrolled) ||
38
41
  (column.frozen === 'right' && isRightScrolled), children: column.header }, column.key))) }) }), _jsx("tbody", { className: "bbn-table-body", children: sortedData.map((row) => (_jsx(Row, { row: row, columns: columns, isSelected: selectedRow === row.id, isSelectable: isRowSelectable ? isRowSelectable(row) : true, onSelect: handleRowSelect, isLeftScrolled: isLeftScrolled, isRightScrolled: isRightScrolled }, row.id))) })] }) }) }));
39
42
  }
40
43
  export const Table = forwardRef(TableBase);
@@ -6,3 +6,4 @@ type Story = StoryObj<typeof meta>;
6
6
  export declare const Default: Story;
7
7
  export declare const FrozenColumns: Story;
8
8
  export declare const ControlledSelection: Story;
9
+ export declare const HeaderVisibility: Story;
@@ -202,3 +202,9 @@ export const ControlledSelection = {
202
202
  return (_jsxs("div", { className: "space-y-4", children: [_jsx(Select, { value: selectedId ?? "", options: selectOptions, onSelect: (value) => handleSelect(value), placeholder: "Select a provider" }), _jsx("div", { className: "h-[150px]", children: _jsx(Table, { data: data, columns: columns, selectedRow: selectedId, onSelectedRowChange: setSelectedId, onRowSelect: handleRowSelect }) }), selectedProvider && (_jsxs("div", { className: "rounded bg-primary-contrast p-4", children: ["Selected Provider: ", selectedProvider.name, " (Commission: ", selectedProvider.commission, "%)"] }))] }));
203
203
  },
204
204
  };
205
+ export const HeaderVisibility = {
206
+ render: () => {
207
+ const noHeaderColumns = columns.map((col) => ({ ...col, header: "" }));
208
+ return (_jsxs("div", { className: "space-y-6", children: [_jsxs("div", { className: "space-y-2", children: [_jsx("div", { children: "With header" }), _jsx(Table, { data: data, columns: columns })] }), _jsxs("div", { className: "space-y-2", children: [_jsx("div", { children: "Without header (hidden)" }), _jsx(Table, { data: data, columns: noHeaderColumns })] })] }));
209
+ },
210
+ };
@@ -16,6 +16,7 @@ export type TableProps<T extends TableData> = ControlledTableProps & {
16
16
  columns: ColumnProps<T>[];
17
17
  className?: string;
18
18
  wrapperClassName?: string;
19
+ fluid?: boolean;
19
20
  hasMore?: boolean;
20
21
  loading?: boolean;
21
22
  onLoadMore?: () => void;