@lax-wp/design-system 0.2.10 → 0.3.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/components/button/Button.d.ts +25 -0
- package/dist/components/buttons/more-button/MoreButton.d.ts +58 -0
- package/dist/components/buttons/more-button/index.d.ts +2 -0
- package/dist/components/buttons/tab-drag-overlay/TabDragOverlay.d.ts +12 -0
- package/dist/components/data-display/modal/Modal.d.ts +5 -17
- package/dist/components/data-display/resizable-sidebar/ResizableSidebar.d.ts +0 -6
- package/dist/components/feedback/confirmation-modal/ConfirmationModal.d.ts +56 -0
- package/dist/components/feedback/toast/Toast.d.ts +1 -1
- package/dist/components/navigation/tab-switch/Children.d.ts +3 -0
- package/dist/components/navigation/tab-switch/TabSwitch.d.ts +11 -0
- package/dist/components/navigation/tab-switch/index.d.ts +4 -0
- package/dist/components/navigation/tab-switch/types.d.ts +51 -0
- package/dist/components/navigation/tab-switch/useResolveTo.d.ts +2 -0
- package/dist/components/navigation/tabs/DropableWrapper.d.ts +27 -0
- package/dist/components/navigation/tabs/SortableTab.d.ts +27 -0
- package/dist/components/navigation/tabs/Tabs.d.ts +155 -0
- package/dist/components/navigation/tabs/index.d.ts +5 -0
- package/dist/components/navigation/tabs/types.d.ts +108 -0
- package/dist/design-system.css +1 -1
- package/dist/index.d.ts +17 -6
- package/dist/index.es.js +32343 -21487
- package/dist/index.umd.js +145 -80
- package/package.json +12 -2
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ItemType } from 'antd/es/menu/interface';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface IButtonProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
isLoading?: boolean;
|
|
8
|
+
primary?: boolean;
|
|
9
|
+
title?: string;
|
|
10
|
+
id: string;
|
|
11
|
+
status?: IButtonStatus;
|
|
12
|
+
appearance?: IButtonAppearance;
|
|
13
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
14
|
+
onKeyDown?: (event: React.KeyboardEvent<HTMLButtonElement>) => void;
|
|
15
|
+
badge?: string | number;
|
|
16
|
+
type?: 'button' | 'submit' | 'reset';
|
|
17
|
+
options?: ItemType[];
|
|
18
|
+
tooltip?: string;
|
|
19
|
+
tooltipPlacement?: 'top' | 'bottom' | 'left' | 'right';
|
|
20
|
+
theme?: 'light' | 'dark';
|
|
21
|
+
}
|
|
22
|
+
export type IButtonStatus = 'secondary-neutral' | 'primary' | 'secondary' | 'error' | 'warning' | 'success' | 'error-secondary' | 'cancel' | 'no-background' | 'publish' | 'default';
|
|
23
|
+
export type IButtonAppearance = 'filled' | 'outline' | 'ghost' | 'dashed';
|
|
24
|
+
declare const Button: React.FC<IButtonProps>;
|
|
25
|
+
export default Button;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { TSuffixRecord } from '../../navigation/tab-switch';
|
|
3
|
+
/**
|
|
4
|
+
* Available tab variants
|
|
5
|
+
*/
|
|
6
|
+
export type TabVariant = 'default' | 'secondary' | 'switch';
|
|
7
|
+
/**
|
|
8
|
+
* Size variants for the MoreButton
|
|
9
|
+
*/
|
|
10
|
+
export type MoreButtonSize = 'sm' | 'md' | 'lg';
|
|
11
|
+
/**
|
|
12
|
+
* Props for the MoreButton component
|
|
13
|
+
*/
|
|
14
|
+
export interface MoreButtonProps {
|
|
15
|
+
/** The visual variant of the button */
|
|
16
|
+
variant: TabVariant;
|
|
17
|
+
/** Size of the button */
|
|
18
|
+
size: MoreButtonSize;
|
|
19
|
+
/** ID of the tab that is currently being dragged over */
|
|
20
|
+
draggingOver: string | null;
|
|
21
|
+
/** Title text for the button */
|
|
22
|
+
title: string;
|
|
23
|
+
/** Whether the more dropdown is currently shown */
|
|
24
|
+
showMoreDropdown: boolean;
|
|
25
|
+
/** Handler for showing/hiding the more dropdown */
|
|
26
|
+
handleShowMoreDropdown: () => void;
|
|
27
|
+
/** ID of the currently selected tab */
|
|
28
|
+
selectedId: string;
|
|
29
|
+
/** Record of suffix values to display on tabs */
|
|
30
|
+
suffixRecord: TSuffixRecord;
|
|
31
|
+
/** Additional CSS classes */
|
|
32
|
+
className?: string;
|
|
33
|
+
/** Icon to display */
|
|
34
|
+
icon?: ReactNode;
|
|
35
|
+
/** Color theme of the button */
|
|
36
|
+
color?: 'light' | 'dark';
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* MoreButton component for tab navigation
|
|
40
|
+
*
|
|
41
|
+
* Used to display a "More" button that can show additional tabs in a dropdown.
|
|
42
|
+
* Integrates with TabSwitch component for consistent tab behavior.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* <MoreButton
|
|
47
|
+
* variant="default"
|
|
48
|
+
* size="md"
|
|
49
|
+
* draggingOver={null}
|
|
50
|
+
* title="More..."
|
|
51
|
+
* showMoreDropdown={false}
|
|
52
|
+
* handleShowMoreDropdown={() => setShowDropdown(!showDropdown)}
|
|
53
|
+
* selectedId="tab1"
|
|
54
|
+
* suffixRecord={{}}
|
|
55
|
+
* />
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare const MoreButton: React.FC<MoreButtonProps>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TResolveToConfig, TSize, TSuffixRecord, TabVariant } from '../../navigation/tab-switch/types';
|
|
2
|
+
export interface TabDragOverlayProps {
|
|
3
|
+
draggingTab: string;
|
|
4
|
+
suffixRecord: TSuffixRecord;
|
|
5
|
+
linkConfig?: TResolveToConfig;
|
|
6
|
+
size?: TSize;
|
|
7
|
+
parentContainer: string;
|
|
8
|
+
variant: TabVariant;
|
|
9
|
+
selectedId: string;
|
|
10
|
+
}
|
|
11
|
+
declare const TabDragOverlay: React.FC<TabDragOverlayProps>;
|
|
12
|
+
export default TabDragOverlay;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { type ModalProps as AntDModalProps } from "antd";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
/**
|
|
4
|
-
* Modal
|
|
4
|
+
* Custom props extending Ant Design Modal props
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
7
|
-
/**
|
|
8
|
-
* Props for the Modal component
|
|
9
|
-
*/
|
|
10
|
-
export interface ModalProps extends Omit<AntDModalProps, "title" | "footer"> {
|
|
6
|
+
export interface ModalProps extends AntDModalProps {
|
|
11
7
|
/** Whether to show only the body content without header */
|
|
12
8
|
onlyBody?: boolean;
|
|
13
9
|
/** Whether to add spacing to the body */
|
|
@@ -30,24 +26,16 @@ export interface ModalProps extends Omit<AntDModalProps, "title" | "footer"> {
|
|
|
30
26
|
noPadding?: boolean;
|
|
31
27
|
/** Close handler */
|
|
32
28
|
onClose?: () => void;
|
|
33
|
-
/** Modal title - can be string or ReactNode */
|
|
34
|
-
title?: string | ReactNode;
|
|
35
|
-
/** Footer content */
|
|
36
|
-
footer?: ReactNode;
|
|
37
|
-
/** Modal size */
|
|
38
|
-
size?: ModalSize;
|
|
39
29
|
}
|
|
40
30
|
/**
|
|
41
31
|
* Modal component for displaying overlay content
|
|
42
32
|
*
|
|
43
33
|
* @example
|
|
44
34
|
* ```tsx
|
|
45
|
-
* <Modal open={isOpen}
|
|
35
|
+
* <Modal open={isOpen} onCancel={() => setIsOpen(false)} title="Example Modal">
|
|
46
36
|
* <p>Modal content goes here</p>
|
|
47
37
|
* </Modal>
|
|
48
38
|
* ```
|
|
49
39
|
*/
|
|
50
|
-
export declare const Modal:
|
|
51
|
-
|
|
52
|
-
displayName: string;
|
|
53
|
-
};
|
|
40
|
+
export declare const Modal: (props: ModalProps) => import("react").ReactPortal;
|
|
41
|
+
export default Modal;
|
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
* Sidebar placement options
|
|
3
3
|
*/
|
|
4
4
|
export type ResizableSidebarPlacement = "left" | "right";
|
|
5
|
-
/**
|
|
6
|
-
* Theme options for the sidebar
|
|
7
|
-
*/
|
|
8
|
-
export type ResizableSidebarTheme = "light" | "dark";
|
|
9
5
|
/**
|
|
10
6
|
* Props for the ResizableSidebar component
|
|
11
7
|
*/
|
|
@@ -48,7 +44,5 @@ export interface ResizableSidebarProps {
|
|
|
48
44
|
mainSidebarCollapsedWidth?: number;
|
|
49
45
|
/** Height offset for navbar */
|
|
50
46
|
navbarHeight?: number;
|
|
51
|
-
/** Theme for styling */
|
|
52
|
-
theme?: ResizableSidebarTheme;
|
|
53
47
|
}
|
|
54
48
|
export declare const ResizableSidebar: import("react").ForwardRefExoticComponent<ResizableSidebarProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type IButtonStatus } from '../../button/Button';
|
|
3
|
+
export interface ConfirmationModalProps {
|
|
4
|
+
/** Child element that triggers the popup when clicked (optional) */
|
|
5
|
+
children?: React.ReactElement;
|
|
6
|
+
/** Callback when cancel is triggered */
|
|
7
|
+
onCancel?: (closeByIcon?: boolean) => void;
|
|
8
|
+
/** Callback when OK is clicked */
|
|
9
|
+
onOk: () => void;
|
|
10
|
+
/** Title of the confirmation popup */
|
|
11
|
+
title: string;
|
|
12
|
+
/** Content/message of the confirmation popup */
|
|
13
|
+
content: string;
|
|
14
|
+
/** Footer configuration */
|
|
15
|
+
footer?: {
|
|
16
|
+
/** Justify content alignment (e.g., 'justify-end', 'justify-center') */
|
|
17
|
+
justify?: string;
|
|
18
|
+
/** Text for OK button */
|
|
19
|
+
okText?: string;
|
|
20
|
+
/** Text for cancel button */
|
|
21
|
+
cancelText?: string;
|
|
22
|
+
/** Button style for OK button */
|
|
23
|
+
okBtnType?: IButtonStatus;
|
|
24
|
+
/** Button style for cancel button */
|
|
25
|
+
cancelBtnType?: IButtonStatus;
|
|
26
|
+
};
|
|
27
|
+
/** Async handler that receives a callback with error status */
|
|
28
|
+
async?: (cb: ({ error }: {
|
|
29
|
+
error: boolean;
|
|
30
|
+
}) => void) => Promise<void>;
|
|
31
|
+
/** Width of the modal in pixels */
|
|
32
|
+
width?: number;
|
|
33
|
+
/** Control visibility from outside */
|
|
34
|
+
isVisibleOutside?: boolean;
|
|
35
|
+
/** Whether clicking children can open the popup */
|
|
36
|
+
ableToConfirmByChildren?: boolean;
|
|
37
|
+
/** Container element ID for portal rendering */
|
|
38
|
+
parentContainer?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* ConfirmationModal component for displaying confirmation dialogs
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* <ConfirmationModal
|
|
46
|
+
* title="Delete Item"
|
|
47
|
+
* content="Are you sure you want to delete this item?"
|
|
48
|
+
* onOk={() => console.log('Confirmed')}
|
|
49
|
+
* onCancel={() => console.log('Cancelled')}
|
|
50
|
+
* >
|
|
51
|
+
* <button>Delete</button>
|
|
52
|
+
* </ConfirmationModal>
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare const ConfirmationModal: React.FC<ConfirmationModalProps>;
|
|
56
|
+
export default ConfirmationModal;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TSwitchProps, TTypeKey } from './types';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
type TProps<T extends TTypeKey> = TSwitchProps<T> & {
|
|
4
|
+
iconsOnly?: boolean;
|
|
5
|
+
draggingTab?: boolean;
|
|
6
|
+
disableAnimation?: boolean;
|
|
7
|
+
tabOptions?: ReactNode;
|
|
8
|
+
color?: string;
|
|
9
|
+
};
|
|
10
|
+
declare const TabSwitch: <T extends TTypeKey>(props: TProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default TabSwitch;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import type { LinkProps } from 'react-router-dom';
|
|
3
|
+
export type THtmlButton = HTMLAttributes<HTMLButtonElement>;
|
|
4
|
+
export type THtmlAnchor = HTMLAttributes<HTMLAnchorElement>;
|
|
5
|
+
export type TBaseLinkProps = LinkProps & HTMLAttributes<HTMLAnchorElement>;
|
|
6
|
+
export type TChildrenElement = JSX.Element | JSX.Element[];
|
|
7
|
+
export type TChildren = string | TChildrenElement | null;
|
|
8
|
+
export type TSize = 'sm' | 'md' | 'lg';
|
|
9
|
+
export type TabVariant = 'default' | 'secondary' | 'switch';
|
|
10
|
+
export type TSuffixRecord<T extends string = string, V = string | number> = Record<T, V>;
|
|
11
|
+
export type TResolveToConfig = {
|
|
12
|
+
key: string;
|
|
13
|
+
defaultLink: string;
|
|
14
|
+
resolver?(title?: string): string;
|
|
15
|
+
onResolve?(searchParams?: URLSearchParams): void;
|
|
16
|
+
};
|
|
17
|
+
export type TPassedProps<T extends string = string> = {
|
|
18
|
+
linkConfig?: TResolveToConfig;
|
|
19
|
+
size?: TSize;
|
|
20
|
+
suffixRecord?: TSuffixRecord<T>;
|
|
21
|
+
title?: T;
|
|
22
|
+
};
|
|
23
|
+
export type TSharedProps = TPassedProps & {
|
|
24
|
+
onClick?(): void;
|
|
25
|
+
size?: TSize;
|
|
26
|
+
classValue: string;
|
|
27
|
+
selectedClassValue: string;
|
|
28
|
+
textClassValue: string;
|
|
29
|
+
isSelected?: boolean;
|
|
30
|
+
selectedId?: string;
|
|
31
|
+
icon?: ReactNode;
|
|
32
|
+
};
|
|
33
|
+
export type TChildrenProps = Pick<TSharedProps, 'isSelected' | 'selectedClassValue' | 'textClassValue' | 'selectedId'> & {
|
|
34
|
+
children: TChildren;
|
|
35
|
+
disableAnimation?: boolean;
|
|
36
|
+
color?: string;
|
|
37
|
+
};
|
|
38
|
+
export declare const TYPES: readonly ["link", "button"];
|
|
39
|
+
export type TTypeKey = (typeof TYPES)[number];
|
|
40
|
+
export type TParentSharedProps = Pick<TSharedProps, 'classValue'>;
|
|
41
|
+
export type TLinkProps = TBaseLinkProps & TParentSharedProps;
|
|
42
|
+
export type TButtonProps = THtmlButton & TParentSharedProps;
|
|
43
|
+
export type TSwitchProps<T extends TTypeKey = 'button'> = {
|
|
44
|
+
link: TLinkProps & TSharedProps;
|
|
45
|
+
button: TButtonProps & TSharedProps;
|
|
46
|
+
activeTab: string;
|
|
47
|
+
iconsOnly: boolean;
|
|
48
|
+
draggingTab?: boolean;
|
|
49
|
+
disableAnimation?: boolean;
|
|
50
|
+
tabOptions?: ReactNode;
|
|
51
|
+
}[T];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Props for DropableWrapper component
|
|
4
|
+
*/
|
|
5
|
+
type DropableWrapperProps = {
|
|
6
|
+
/** Children to render */
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/** Unique identifier for the droppable area */
|
|
9
|
+
id: string;
|
|
10
|
+
/** Whether the droppable area is enabled */
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* DropableWrapper component
|
|
15
|
+
*
|
|
16
|
+
* Wrapper component that creates a droppable area using @dnd-kit/core.
|
|
17
|
+
* Used to create drop zones for draggable items.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <DropableWrapper id="drop-zone-1">
|
|
22
|
+
* <div>Drop area content</div>
|
|
23
|
+
* </DropableWrapper>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare const DropableWrapper: ({ children, id, enabled, }: DropableWrapperProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Props for SortableTab component
|
|
4
|
+
*/
|
|
5
|
+
type SortableTabProps = {
|
|
6
|
+
/** Unique identifier for the tab */
|
|
7
|
+
title: string;
|
|
8
|
+
/** Children to render */
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/** Whether the tab is currently being dragged */
|
|
11
|
+
isDragging?: boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* SortableTab component
|
|
15
|
+
*
|
|
16
|
+
* Wrapper component that makes a tab draggable and sortable using @dnd-kit/sortable.
|
|
17
|
+
* Shows a visual indicator when the tab is being dragged.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <SortableTab title="Tab 1" isDragging={false}>
|
|
22
|
+
* <div>Tab content</div>
|
|
23
|
+
* </SortableTab>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare const SortableTab: ({ title, children, isDragging }: SortableTabProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import type { CommonContextProps, SetTabSettingsAction, TabSettingSelector, TabUtilServices, TBaseTabProps, TPassedProps, TSuffixRecord } from './types';
|
|
2
|
+
import type { ReactNode, ComponentType } from 'react';
|
|
3
|
+
import type { OptionButtonProps } from '../../buttons/option-button/OptionButton';
|
|
4
|
+
/**
|
|
5
|
+
* Components that need to be provided from the consuming application
|
|
6
|
+
*/
|
|
7
|
+
export interface TabsExternalComponents {
|
|
8
|
+
/** SearchBar component */
|
|
9
|
+
SearchBar: ComponentType<{
|
|
10
|
+
id: string;
|
|
11
|
+
value: string;
|
|
12
|
+
classValues?: string;
|
|
13
|
+
onChange: (value: string) => void;
|
|
14
|
+
}>;
|
|
15
|
+
/** OptionButton component */
|
|
16
|
+
OptionButton: ComponentType<OptionButtonProps & {
|
|
17
|
+
suffixRecord?: TSuffixRecord;
|
|
18
|
+
highlight?: string;
|
|
19
|
+
truncateText?: boolean;
|
|
20
|
+
}>;
|
|
21
|
+
/** Tooltip component */
|
|
22
|
+
Tooltip: ComponentType<{
|
|
23
|
+
title: string;
|
|
24
|
+
color?: string;
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
}>;
|
|
27
|
+
/** Icons */
|
|
28
|
+
icons: {
|
|
29
|
+
MoreVerticalIcon: ComponentType<{
|
|
30
|
+
size?: number;
|
|
31
|
+
className?: string;
|
|
32
|
+
}>;
|
|
33
|
+
PinIcon: ComponentType<{
|
|
34
|
+
fill?: string;
|
|
35
|
+
height?: number;
|
|
36
|
+
width?: number;
|
|
37
|
+
}>;
|
|
38
|
+
UnpinIcon: ComponentType<any>;
|
|
39
|
+
FiArrowDown: ComponentType<{
|
|
40
|
+
size?: number;
|
|
41
|
+
className?: string;
|
|
42
|
+
}>;
|
|
43
|
+
FiArrowUp: ComponentType<{
|
|
44
|
+
size?: number;
|
|
45
|
+
className?: string;
|
|
46
|
+
}>;
|
|
47
|
+
FiArrowUpRight: ComponentType<{
|
|
48
|
+
size?: number;
|
|
49
|
+
className?: string;
|
|
50
|
+
}>;
|
|
51
|
+
MdContentCopy: ComponentType<{
|
|
52
|
+
size?: number;
|
|
53
|
+
className?: string;
|
|
54
|
+
}>;
|
|
55
|
+
RemoveRedEyeRounded: ComponentType<{
|
|
56
|
+
sx?: any;
|
|
57
|
+
}>;
|
|
58
|
+
EditIcon: ComponentType<any>;
|
|
59
|
+
Trash: ComponentType<{
|
|
60
|
+
size?: number;
|
|
61
|
+
fill?: string;
|
|
62
|
+
}>;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Props for the Tabs component
|
|
67
|
+
*/
|
|
68
|
+
export type TabsProps<T extends string> = TBaseTabProps<T> & TPassedProps & {
|
|
69
|
+
/** Unique key for storing tab settings */
|
|
70
|
+
tabKey?: string;
|
|
71
|
+
/** Show all items without overflow handling */
|
|
72
|
+
showAllItems?: boolean;
|
|
73
|
+
/** Enable copy link functionality */
|
|
74
|
+
copyLink?: boolean;
|
|
75
|
+
/** Disable tab animations */
|
|
76
|
+
disableAnimation?: boolean;
|
|
77
|
+
/** Container element ID for portals */
|
|
78
|
+
parentContainer?: string;
|
|
79
|
+
/** Fit content width */
|
|
80
|
+
fitContentWidth?: boolean;
|
|
81
|
+
/** Height class for switch variant */
|
|
82
|
+
height?: string;
|
|
83
|
+
/** Callback when tab is deleted */
|
|
84
|
+
onDelete?: (name: T) => void;
|
|
85
|
+
/** Callback when tab is edited */
|
|
86
|
+
onEdit?: (name: T) => void;
|
|
87
|
+
/** Allow pinning tabs */
|
|
88
|
+
allowPin?: boolean;
|
|
89
|
+
/** Sort tabs alphabetically */
|
|
90
|
+
sortAlphabetically?: boolean;
|
|
91
|
+
/** Right section configuration */
|
|
92
|
+
rightSection?: {
|
|
93
|
+
className?: string;
|
|
94
|
+
width: number;
|
|
95
|
+
component: React.ReactNode;
|
|
96
|
+
};
|
|
97
|
+
/** Color theme */
|
|
98
|
+
color?: string;
|
|
99
|
+
/** Context props from CommonContext */
|
|
100
|
+
contextProps?: CommonContextProps;
|
|
101
|
+
/** Redux selector for tab settings */
|
|
102
|
+
selectTabSetting?: TabSettingSelector;
|
|
103
|
+
/** Redux action to set tab settings */
|
|
104
|
+
setTabSettingsAction?: SetTabSettingsAction;
|
|
105
|
+
/** Utility services for API calls */
|
|
106
|
+
utilServices?: TabUtilServices;
|
|
107
|
+
/** Dispatch function from Redux */
|
|
108
|
+
dispatch?: (action: any) => void;
|
|
109
|
+
/** System messages utility */
|
|
110
|
+
systemMessages?: {
|
|
111
|
+
copyToClipboard: (text: string) => string;
|
|
112
|
+
};
|
|
113
|
+
/** Number formatting utility */
|
|
114
|
+
formatNumber?: (value: number, locale: string, decimals: number, useGrouping: boolean) => string;
|
|
115
|
+
/** Random hex string generator */
|
|
116
|
+
randomHexString?: (length: number) => string;
|
|
117
|
+
/** Event listener hook */
|
|
118
|
+
useEventListener?: (event: string, handler: () => void) => void;
|
|
119
|
+
/** External components required by Tabs */
|
|
120
|
+
components: TabsExternalComponents;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Tabs Component
|
|
124
|
+
*
|
|
125
|
+
* A comprehensive tab navigation component with drag-and-drop, pinning, hiding,
|
|
126
|
+
* and overflow handling capabilities.
|
|
127
|
+
*
|
|
128
|
+
* Features:
|
|
129
|
+
* - Multiple variants: default, secondary, switch
|
|
130
|
+
* - Drag and drop reordering
|
|
131
|
+
* - Tab pinning
|
|
132
|
+
* - Tab hiding/showing
|
|
133
|
+
* - Overflow handling with "More" dropdown
|
|
134
|
+
* - Responsive design
|
|
135
|
+
* - Suffix badges
|
|
136
|
+
* - Custom icons
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```tsx
|
|
140
|
+
* <Tabs
|
|
141
|
+
* tabs={['Tab 1', 'Tab 2', 'Tab 3']}
|
|
142
|
+
* activeTab="Tab 1"
|
|
143
|
+
* onTabClick={(tab) => console.log(tab)}
|
|
144
|
+
* variant="default"
|
|
145
|
+
* draggable={true}
|
|
146
|
+
* components={{
|
|
147
|
+
* SearchBar,
|
|
148
|
+
* OptionButton,
|
|
149
|
+
* Tooltip,
|
|
150
|
+
* icons: { ... }
|
|
151
|
+
* }}
|
|
152
|
+
* />
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
export declare const Tabs: <T extends string>({ variant, linkConfig, tabs, activeTab, onTabClick, suffixRecord, isLoading, size, className, draggable, tabKey, parentContainer, showAllItems, copyLink, isDisabled, color, iconsOnly, tabIcons, height, fullWidth, fitContentWidth, onDelete, onEdit, allowPin, sortAlphabetically, rightSection, contextProps, selectTabSetting, setTabSettingsAction, utilServices, dispatch, systemMessages, formatNumber, randomHexString, useEventListener, components, }: TabsProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Tabs } from './Tabs';
|
|
2
|
+
export type { TabsProps, TabsExternalComponents } from './Tabs';
|
|
3
|
+
export { SortableTab } from './SortableTab';
|
|
4
|
+
export { DropableWrapper } from './DropableWrapper';
|
|
5
|
+
export type { Tab, TBaseTabProps, TPassedProps, TSuffixRecord, TSize, TabVariant, TResolveToConfig, TabSetting, TabUtilServices, TabSettingSelector, SetTabSettingsAction, CommonContextProps, } from './types';
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { TResolveToConfig, TSuffixRecord, TSize, TabVariant } from '../tab-switch/types';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a tab item with its configuration
|
|
5
|
+
*/
|
|
6
|
+
export type Tab<T extends string> = {
|
|
7
|
+
/** Name/ID of the tab */
|
|
8
|
+
name: T;
|
|
9
|
+
/** Whether this is a default tab */
|
|
10
|
+
is_default: boolean;
|
|
11
|
+
/** Whether the tab is hidden */
|
|
12
|
+
is_hidden: boolean;
|
|
13
|
+
/** Whether the tab is pinned */
|
|
14
|
+
is_pinned?: boolean;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Base props for tab components
|
|
18
|
+
*/
|
|
19
|
+
export type TBaseTabProps<T extends string> = {
|
|
20
|
+
/** Array of tab names */
|
|
21
|
+
tabs: readonly T[];
|
|
22
|
+
/** Initially hidden tabs */
|
|
23
|
+
initialHiddenTabs?: readonly T[];
|
|
24
|
+
/** Currently active tab */
|
|
25
|
+
activeTab: T;
|
|
26
|
+
/** Callback when a tab is clicked */
|
|
27
|
+
onTabClick?(id: T): void;
|
|
28
|
+
/** Count values for each tab */
|
|
29
|
+
counts?: Record<T, number>;
|
|
30
|
+
/** Whether tabs are disabled */
|
|
31
|
+
isDisabled?: boolean;
|
|
32
|
+
/** Icon elements for each tab */
|
|
33
|
+
tabIcons?: Record<string, ReactNode>;
|
|
34
|
+
/** Loading state */
|
|
35
|
+
isLoading?: boolean;
|
|
36
|
+
/** Additional CSS classes */
|
|
37
|
+
className?: string;
|
|
38
|
+
/** Title for the tabs */
|
|
39
|
+
title?: string;
|
|
40
|
+
/** Show only icons without text */
|
|
41
|
+
iconsOnly?: boolean;
|
|
42
|
+
/** Enable drag and drop */
|
|
43
|
+
draggable?: boolean;
|
|
44
|
+
/** Visual variant of tabs */
|
|
45
|
+
variant?: TabVariant;
|
|
46
|
+
/** Full width tabs */
|
|
47
|
+
fullWidth?: boolean;
|
|
48
|
+
/** Color theme */
|
|
49
|
+
color?: 'light' | 'dark';
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Props passed through tab components
|
|
53
|
+
*/
|
|
54
|
+
export type TPassedProps<T extends string = string> = {
|
|
55
|
+
/** Link configuration */
|
|
56
|
+
linkConfig?: TResolveToConfig;
|
|
57
|
+
/** Size variant */
|
|
58
|
+
size?: TSize;
|
|
59
|
+
/** Suffix values to display on tabs */
|
|
60
|
+
suffixRecord?: TSuffixRecord<T>;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Tab settings data from API
|
|
64
|
+
*/
|
|
65
|
+
export type TabSetting = {
|
|
66
|
+
tab_type: string;
|
|
67
|
+
tab_items: Tab<string>[];
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Utility services for tab settings
|
|
71
|
+
*/
|
|
72
|
+
export type TabUtilServices = {
|
|
73
|
+
/** Upsert tab settings to backend */
|
|
74
|
+
UpsertTabSettings: (data: {
|
|
75
|
+
tab_type?: string;
|
|
76
|
+
tab_items: Tab<string>[];
|
|
77
|
+
}) => Promise<void>;
|
|
78
|
+
/** Get tab settings from backend */
|
|
79
|
+
GetTabSettings: () => Promise<{
|
|
80
|
+
status: string;
|
|
81
|
+
data: TabSetting[];
|
|
82
|
+
}>;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Redux selector for tab settings
|
|
86
|
+
*/
|
|
87
|
+
export type TabSettingSelector = (tabKey?: string) => TabSetting | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Redux action to set tab settings
|
|
90
|
+
*/
|
|
91
|
+
export type SetTabSettingsAction = (data: TabSetting[]) => {
|
|
92
|
+
type: string;
|
|
93
|
+
payload: TabSetting[];
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Props from CommonContext
|
|
97
|
+
*/
|
|
98
|
+
export type CommonContextProps = {
|
|
99
|
+
/** Whether document view is shown */
|
|
100
|
+
isShowDocument?: boolean;
|
|
101
|
+
/** Whether sidebar is expanded */
|
|
102
|
+
isExpanded?: boolean;
|
|
103
|
+
/** Disable actions handler */
|
|
104
|
+
setDisableActions?: (disabled: boolean) => void;
|
|
105
|
+
/** Whether authoring view is shown */
|
|
106
|
+
isShowAuthoring?: boolean;
|
|
107
|
+
};
|
|
108
|
+
export type { TResolveToConfig, TSuffixRecord, TSize, TabVariant } from '../tab-switch/types';
|