react-magma-dom 4.11.0-next.8 → 4.11.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/Alert/index.d.ts +4 -0
- package/dist/components/AlertBase/index.d.ts +3 -0
- package/dist/components/Banner/index.d.ts +4 -0
- package/dist/components/Combobox/ComboboxInput.d.ts +1 -0
- package/dist/components/DatePicker/CalendarDay.d.ts +0 -3
- package/dist/components/DatePicker/DateField/DateFieldInput.d.ts +23 -0
- package/dist/components/DatePicker/DateField/StyledDateFieldInput.d.ts +25 -0
- package/dist/components/DatePicker/DateField/useDateField.d.ts +28 -0
- package/dist/components/DatePicker/index.d.ts +6 -1
- package/dist/components/DatePicker/utils.d.ts +2 -0
- package/dist/components/LoadingIndicator/index.d.ts +3 -3
- package/dist/components/NavTabs/NavTabs.d.ts +4 -2
- package/dist/components/Pagination/utils.d.ts +10 -0
- package/dist/components/Popover/Popover.d.ts +7 -1
- package/dist/components/Select/SelectAnnouncer.d.ts +5 -0
- package/dist/components/Select/SelectContainer.d.ts +1 -0
- package/dist/components/Select/index.d.ts +4 -0
- package/dist/components/Select/utils.d.ts +1 -0
- package/dist/components/Spinner/index.d.ts +4 -0
- package/dist/components/TimePicker/TimePicker.d.ts +10 -0
- package/dist/components/TreeView/TreeItem.d.ts +5 -1
- package/dist/components/TreeView/TreeItemContext.d.ts +0 -1
- package/dist/components/TreeView/TreeItemHierarchyContext.d.ts +15 -0
- package/dist/components/TreeView/TreeView.d.ts +12 -0
- package/dist/components/TreeView/TreeViewConfigContext.d.ts +18 -0
- package/dist/components/TreeView/TreeViewExpansionContext.d.ts +8 -0
- package/dist/components/TreeView/TreeViewSelectionContext.d.ts +25 -0
- package/dist/components/TreeView/index.d.ts +3 -0
- package/dist/components/TreeView/treeViewReducer.d.ts +94 -0
- package/dist/components/TreeView/useTreeItem.d.ts +6 -2
- package/dist/components/TreeView/useTreeView.d.ts +26 -13
- package/dist/components/TreeView/utils.d.ts +6 -5
- package/dist/esm/index.js +14993 -13017
- package/dist/esm/index.js.map +1 -1
- package/dist/i18n/interface.d.ts +6 -1
- package/dist/properties.json +2421 -223
- package/dist/react-magma-dom.cjs.development.js +8328 -6767
- package/dist/react-magma-dom.cjs.development.js.map +1 -1
- package/dist/react-magma-dom.cjs.production.min.js +1 -1
- package/dist/react-magma-dom.cjs.production.min.js.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/package.json +4 -3
|
@@ -18,6 +18,10 @@ export interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
18
18
|
* @default false
|
|
19
19
|
*/
|
|
20
20
|
isDismissible?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Reference to the dismiss button element
|
|
23
|
+
*/
|
|
24
|
+
dismissibleButtonRef?: React.Ref<HTMLButtonElement>;
|
|
21
25
|
isInverse?: boolean;
|
|
22
26
|
/**
|
|
23
27
|
* Action that fires when the close button is clicked (required when isDismissible is true)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { IconProps } from 'react-magma-icons';
|
|
3
|
+
import { I18nInterface } from '../..';
|
|
3
4
|
export declare const VARIANT_ICON: {
|
|
4
5
|
[name: string]: React.FunctionComponent<IconProps>;
|
|
5
6
|
};
|
|
@@ -18,6 +19,7 @@ export interface AlertBaseProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
18
19
|
isExiting?: boolean;
|
|
19
20
|
isDismissed?: boolean;
|
|
20
21
|
isDismissible?: boolean;
|
|
22
|
+
dismissibleButtonRef?: React.Ref<HTMLButtonElement>;
|
|
21
23
|
isInverse?: boolean;
|
|
22
24
|
isPaused?: boolean;
|
|
23
25
|
isToast?: boolean;
|
|
@@ -39,4 +41,5 @@ export declare const AdditionalContentWrapper: import("@emotion/styled").StyledC
|
|
|
39
41
|
theme?: import("@emotion/react").Theme;
|
|
40
42
|
as?: React.ElementType<any>;
|
|
41
43
|
}, React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
44
|
+
export declare function getAriaLabelIcon(variant: string, i18n: I18nInterface): string;
|
|
42
45
|
export declare const AlertBase: React.ForwardRefExoticComponent<AlertBaseProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -21,6 +21,10 @@ export interface BannerProps extends AlertProps {
|
|
|
21
21
|
* @default false
|
|
22
22
|
*/
|
|
23
23
|
isDismissible?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Reference to the dismiss button element
|
|
26
|
+
*/
|
|
27
|
+
dismissibleButtonRef?: React.Ref<HTMLButtonElement>;
|
|
24
28
|
isInverse?: boolean;
|
|
25
29
|
}
|
|
26
30
|
export declare const Banner: React.ForwardRefExoticComponent<BannerProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -23,6 +23,7 @@ interface ComboboxInputProps<T> {
|
|
|
23
23
|
onInputKeyUp?: (event: any) => void;
|
|
24
24
|
placeholder?: string;
|
|
25
25
|
selectedItems?: React.ReactNode;
|
|
26
|
+
selectedItem?: React.ReactNode;
|
|
26
27
|
setReference?: (node: ReferenceType) => void;
|
|
27
28
|
toggleButtonRef?: React.Ref<HTMLButtonElement>;
|
|
28
29
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
interface CalendarDayProps {
|
|
3
3
|
day: Date;
|
|
4
|
-
dayFocusable?: boolean;
|
|
5
|
-
isInverse?: boolean;
|
|
6
|
-
onDateChange?: (day: Date, event: React.SyntheticEvent) => void;
|
|
7
4
|
}
|
|
8
5
|
export declare const CalendarDay: React.FunctionComponent<CalendarDayProps>;
|
|
9
6
|
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ReferenceType } from '@floating-ui/react-dom';
|
|
3
|
+
import { FormFieldContainerBaseProps } from '../../FormFieldContainer';
|
|
4
|
+
export interface DateFieldInputProps extends Omit<FormFieldContainerBaseProps, 'inputSize' | 'fieldId'> {
|
|
5
|
+
id?: string;
|
|
6
|
+
dateFormat?: string;
|
|
7
|
+
inputStyle?: React.CSSProperties;
|
|
8
|
+
labelText: React.ReactNode;
|
|
9
|
+
onIconClick?: (event: React.MouseEvent) => void;
|
|
10
|
+
setReference?: (node: ReferenceType) => void;
|
|
11
|
+
iconRef?: React.RefObject<HTMLButtonElement>;
|
|
12
|
+
isClearable?: boolean;
|
|
13
|
+
iconAriaLabel?: string;
|
|
14
|
+
inputRef?: React.RefObject<HTMLDivElement>;
|
|
15
|
+
inputValue: Date | string;
|
|
16
|
+
handleDateChange?: (day: Date, event: any) => void;
|
|
17
|
+
onClearDate?: () => void;
|
|
18
|
+
onIconKeyDown?: (event: React.KeyboardEvent) => void;
|
|
19
|
+
onInputBlur?: (event: React.FocusEvent) => void;
|
|
20
|
+
onInputFocus?: (event: React.FocusEvent) => void;
|
|
21
|
+
required?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const DateFieldInput: React.FunctionComponent<DateFieldInputProps>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ThemeInterface } from '../../../theme/magma';
|
|
3
|
+
export declare const InputsContainer: import("@emotion/styled").StyledComponent<{
|
|
4
|
+
theme?: import("@emotion/react").Theme;
|
|
5
|
+
as?: import("react").ElementType<any>;
|
|
6
|
+
} & {
|
|
7
|
+
hasError?: boolean;
|
|
8
|
+
isInverse?: boolean;
|
|
9
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
10
|
+
export declare const IconWrapper: import("@emotion/styled").StyledComponent<{
|
|
11
|
+
theme?: import("@emotion/react").Theme;
|
|
12
|
+
as?: import("react").ElementType<any>;
|
|
13
|
+
} & {
|
|
14
|
+
theme: ThemeInterface;
|
|
15
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
16
|
+
export declare const IsClearableContainer: import("@emotion/styled").StyledComponent<{
|
|
17
|
+
theme?: import("@emotion/react").Theme;
|
|
18
|
+
as?: import("react").ElementType<any>;
|
|
19
|
+
} & {
|
|
20
|
+
theme: ThemeInterface;
|
|
21
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
22
|
+
export declare const DateFieldInputContainer: import("@emotion/styled").StyledComponent<{
|
|
23
|
+
theme?: import("@emotion/react").Theme;
|
|
24
|
+
as?: import("react").ElementType<any>;
|
|
25
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface UseDateFieldProps {
|
|
3
|
+
dateFormat: string;
|
|
4
|
+
}
|
|
5
|
+
export declare enum InputDateFields {
|
|
6
|
+
Day = "day",
|
|
7
|
+
Month = "month",
|
|
8
|
+
Year = "year"
|
|
9
|
+
}
|
|
10
|
+
export declare function useDateField(props: UseDateFieldProps): {
|
|
11
|
+
allMonthNames: any[];
|
|
12
|
+
month: string;
|
|
13
|
+
day: string;
|
|
14
|
+
year: string;
|
|
15
|
+
fieldRefs: Record<string, React.RefObject<HTMLInputElement>>;
|
|
16
|
+
fieldOrder: string[];
|
|
17
|
+
handleMonthChange: (event: React.ChangeEvent<HTMLInputElement>, hasMonthLongFormat: boolean) => void;
|
|
18
|
+
handleDayChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
19
|
+
handleYearChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
20
|
+
handleFieldKeyDown: (event: React.KeyboardEvent, fieldKey: string, hasMonthLongFormat?: boolean) => void;
|
|
21
|
+
setMonthValue: React.Dispatch<React.SetStateAction<string>>;
|
|
22
|
+
setDayValue: React.Dispatch<React.SetStateAction<string>>;
|
|
23
|
+
setYearValue: React.Dispatch<React.SetStateAction<string>>;
|
|
24
|
+
onClear: () => void;
|
|
25
|
+
formatWithLeadingZero: (value: number, maxValue?: number, isYearField?: boolean) => string;
|
|
26
|
+
getIndexMonth: (prefix: string) => number[];
|
|
27
|
+
};
|
|
28
|
+
export declare type UseDateFieldReturn = ReturnType<typeof useDateField>;
|
|
@@ -56,7 +56,7 @@ export interface DatePickerProps extends Omit<React.InputHTMLAttributes<HTMLInpu
|
|
|
56
56
|
*/
|
|
57
57
|
minDate?: Date;
|
|
58
58
|
/**
|
|
59
|
-
* Text for input placeholder
|
|
59
|
+
* Text for input placeholder. If isDateFieldInput is true, this will be ignored.
|
|
60
60
|
*/
|
|
61
61
|
placeholder?: string;
|
|
62
62
|
/**
|
|
@@ -72,6 +72,11 @@ export interface DatePickerProps extends Omit<React.InputHTMLAttributes<HTMLInpu
|
|
|
72
72
|
* Value of the date input, used when setting the date value externally
|
|
73
73
|
*/
|
|
74
74
|
value?: Date;
|
|
75
|
+
/**
|
|
76
|
+
* If true, the DatePicker will use the DateFieldInput component for input
|
|
77
|
+
* @default false
|
|
78
|
+
*/
|
|
79
|
+
isDateFieldInput?: boolean;
|
|
75
80
|
/**
|
|
76
81
|
* Event fired in multiple instances when internal values are changed and can be used as a generic state change event
|
|
77
82
|
*/
|
|
@@ -12,3 +12,5 @@ export declare function getCurrentMonthAndYear(date: Date, locale: Locale): {
|
|
|
12
12
|
};
|
|
13
13
|
export declare function setMonthForDate(prevDate: any, numberMonth: number): Date;
|
|
14
14
|
export declare function setYearForDate(prevDate: any, numberYear: number): Date;
|
|
15
|
+
export declare const MAX_YEAR = 2099;
|
|
16
|
+
export declare const MIN_YEAR = 1900;
|
|
@@ -5,12 +5,12 @@ export interface LoadingIndicatorProps extends React.HTMLAttributes<HTMLDivEleme
|
|
|
5
5
|
*/
|
|
6
6
|
css?: any;
|
|
7
7
|
/**
|
|
8
|
-
* Message displayed for the first
|
|
8
|
+
* Message displayed for the first 5 seconds
|
|
9
9
|
* @default "Loading..."
|
|
10
10
|
*/
|
|
11
11
|
message1?: string;
|
|
12
12
|
/**
|
|
13
|
-
* Message displayed
|
|
13
|
+
* Message displayed after 5 seconds
|
|
14
14
|
* @default "Thank you for your patience. Still loading..."
|
|
15
15
|
*/
|
|
16
16
|
message2?: string;
|
|
@@ -20,7 +20,7 @@ export interface LoadingIndicatorProps extends React.HTMLAttributes<HTMLDivEleme
|
|
|
20
20
|
*/
|
|
21
21
|
message3?: string;
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Value between 0 and 100 representing the percentage of progress
|
|
24
24
|
* @default 0
|
|
25
25
|
*/
|
|
26
26
|
percentage?: number;
|
|
@@ -2,7 +2,9 @@ import * as React from 'react';
|
|
|
2
2
|
import { TabsBorderPosition, TabsIconPosition, TabsProps } from '../Tabs';
|
|
3
3
|
import { Omit } from '../../utils';
|
|
4
4
|
import { TabsOrientation, TabsTextTransform } from '../Tabs/shared';
|
|
5
|
-
export
|
|
5
|
+
export interface NavTabsProps extends Omit<TabsProps, 'onChange'> {
|
|
6
|
+
'aria-label'?: string;
|
|
7
|
+
}
|
|
6
8
|
interface NavTabsContextInterface {
|
|
7
9
|
borderPosition?: TabsBorderPosition;
|
|
8
10
|
iconPosition?: TabsIconPosition;
|
|
@@ -12,5 +14,5 @@ interface NavTabsContextInterface {
|
|
|
12
14
|
textTransform?: TabsTextTransform;
|
|
13
15
|
}
|
|
14
16
|
export declare const NavTabsContext: React.Context<NavTabsContextInterface>;
|
|
15
|
-
export declare const NavTabs: React.ForwardRefExoticComponent<(
|
|
17
|
+
export declare const NavTabs: React.ForwardRefExoticComponent<(NavTabsProps & import("../Tabs").HorizontalTabsProps & React.RefAttributes<HTMLDivElement>) | (NavTabsProps & import("../Tabs").VerticalTabsProps & React.RefAttributes<HTMLDivElement>)>;
|
|
16
18
|
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface PaginationI18n {
|
|
2
|
+
ofLabel: string;
|
|
3
|
+
pageNumberLabel: string;
|
|
4
|
+
pageLabel: string;
|
|
5
|
+
pagesLabel: string;
|
|
6
|
+
selectedLabel: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const paginationLabel: (count: number, pagination: PaginationI18n) => string;
|
|
9
|
+
export declare const pageAriaLabel: (selectedPage: number, count: number, pagination: PaginationI18n) => string;
|
|
10
|
+
export {};
|
|
@@ -85,6 +85,12 @@ export interface PopoverProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
85
85
|
* @default PopoverAlignment.center
|
|
86
86
|
*/
|
|
87
87
|
alignment?: PopoverAlignment;
|
|
88
|
+
/**
|
|
89
|
+
* If true, the popover trigger will take the full width of its container.
|
|
90
|
+
* This allows buttons with isFullWidth prop to render at full width.
|
|
91
|
+
* @default false
|
|
92
|
+
*/
|
|
93
|
+
isFullWidth?: boolean;
|
|
88
94
|
}
|
|
89
95
|
export interface PopoverContextInterface {
|
|
90
96
|
floatingStyles?: React.CSSProperties;
|
|
@@ -109,8 +115,8 @@ export interface PopoverContextInterface {
|
|
|
109
115
|
hasPointer?: boolean;
|
|
110
116
|
focusTrap?: boolean;
|
|
111
117
|
hasActiveElements?: boolean;
|
|
118
|
+
isFullWidth?: boolean;
|
|
112
119
|
}
|
|
113
120
|
export declare const PopoverContext: React.Context<PopoverContextInterface>;
|
|
114
121
|
export declare function hasActiveElementsChecker(ref: any): boolean;
|
|
115
|
-
export declare function isElementInteractive(element: EventTarget | null): boolean;
|
|
116
122
|
export declare const Popover: React.ForwardRefExoticComponent<PopoverProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -11,6 +11,7 @@ export declare const SelectContainerElement: import("@emotion/styled").StyledCom
|
|
|
11
11
|
}, React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
12
12
|
interface SelectContainerInterface<T> {
|
|
13
13
|
additionalContent?: React.ReactNode;
|
|
14
|
+
ariaLabel?: string;
|
|
14
15
|
children: React.ReactNode[];
|
|
15
16
|
containerStyle?: React.CSSProperties;
|
|
16
17
|
descriptionId?: string;
|
|
@@ -107,6 +107,10 @@ export interface SelectProps<T extends SelectOptions> extends UseSelectProps<T>,
|
|
|
107
107
|
* Id of the element that describes the select trigger button
|
|
108
108
|
*/
|
|
109
109
|
ariaDescribedBy?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Aria label for the select trigger button
|
|
112
|
+
*/
|
|
113
|
+
ariaLabel?: string;
|
|
110
114
|
/**
|
|
111
115
|
* @internal
|
|
112
116
|
*/
|
|
@@ -25,5 +25,9 @@ export interface SpinnerProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
|
25
25
|
* @internal
|
|
26
26
|
*/
|
|
27
27
|
testId?: string;
|
|
28
|
+
/**
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
hasMessage?: boolean;
|
|
28
32
|
}
|
|
29
33
|
export declare const Spinner: React.ForwardRefExoticComponent<SpinnerProps & React.RefAttributes<HTMLSpanElement>>;
|
|
@@ -7,6 +7,11 @@ export interface TimePickerProps extends UseTimePickerProps {
|
|
|
7
7
|
*/
|
|
8
8
|
inputStyle?: React.CSSProperties;
|
|
9
9
|
}
|
|
10
|
+
interface StyledNumInputProps {
|
|
11
|
+
isFocused?: boolean;
|
|
12
|
+
isInverse?: boolean;
|
|
13
|
+
size?: number;
|
|
14
|
+
}
|
|
10
15
|
export declare const getInputColor: (isInverse: boolean, isFocused: boolean, theme: ThemeInterface) => string;
|
|
11
16
|
export declare const Divider: import("@emotion/styled").StyledComponent<{
|
|
12
17
|
theme?: import("@emotion/react").Theme;
|
|
@@ -15,4 +20,9 @@ export declare const Divider: import("@emotion/styled").StyledComponent<{
|
|
|
15
20
|
isInverse?: boolean;
|
|
16
21
|
isFocused?: boolean;
|
|
17
22
|
}, React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
23
|
+
export declare const StyledNumInput: import("@emotion/styled").StyledComponent<{
|
|
24
|
+
theme?: import("@emotion/react").Theme;
|
|
25
|
+
as?: React.ElementType<any>;
|
|
26
|
+
} & StyledNumInputProps, React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, {}>;
|
|
18
27
|
export declare const TimePicker: React.ForwardRefExoticComponent<TimePickerProps & React.RefAttributes<HTMLInputElement>>;
|
|
28
|
+
export {};
|
|
@@ -2,4 +2,8 @@ import * as React from 'react';
|
|
|
2
2
|
import { UseTreeItemProps } from './useTreeItem';
|
|
3
3
|
export interface TreeItemProps extends UseTreeItemProps {
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Memoized TreeItem component
|
|
7
|
+
* Only re-renders when relevant props change, improving performance for large trees
|
|
8
|
+
*/
|
|
9
|
+
export declare const TreeItem: React.MemoExoticComponent<React.ForwardRefExoticComponent<TreeItemProps & React.RefAttributes<HTMLLIElement>>>;
|
|
@@ -3,7 +3,6 @@ import { IndeterminateCheckboxStatus } from '../IndeterminateCheckbox';
|
|
|
3
3
|
interface TreeItemContextInterface {
|
|
4
4
|
itemId?: string;
|
|
5
5
|
expanded: boolean;
|
|
6
|
-
setExpanded: React.Dispatch<React.SetStateAction<boolean>>;
|
|
7
6
|
checkedStatus: IndeterminateCheckboxStatus;
|
|
8
7
|
checkboxChangeHandler: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
9
8
|
hasOwnTreeItems: boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Context for passing hierarchy information to TreeItems without cloneElement
|
|
4
|
+
* This reduces the overhead of React.cloneElement by providing depth and position
|
|
5
|
+
* information through context instead
|
|
6
|
+
*/
|
|
7
|
+
interface TreeItemHierarchyContextInterface {
|
|
8
|
+
depth: number;
|
|
9
|
+
parentDepth: number;
|
|
10
|
+
isTopLevel: boolean;
|
|
11
|
+
index: number;
|
|
12
|
+
isVirtualized?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const TreeItemHierarchyContext: React.Context<TreeItemHierarchyContextInterface>;
|
|
15
|
+
export {};
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { UseTreeViewProps } from './useTreeView';
|
|
3
3
|
export interface TreeViewProps extends Omit<React.HTMLAttributes<HTMLUListElement>, 'children'>, UseTreeViewProps {
|
|
4
|
+
/**
|
|
5
|
+
* Enable virtualization for better performance with large trees.
|
|
6
|
+
* @default false
|
|
7
|
+
*/
|
|
8
|
+
enableVirtualization?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Height of the TreeView container in pixels.
|
|
11
|
+
* REQUIRED when enableVirtualization is true.
|
|
12
|
+
* Without a fixed height, virtualization cannot calculate the viewport properly.
|
|
13
|
+
* @example height={400}
|
|
14
|
+
*/
|
|
15
|
+
height?: number;
|
|
4
16
|
}
|
|
5
17
|
export declare const TreeView: React.ForwardRefExoticComponent<TreeViewProps & React.RefAttributes<HTMLUListElement>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TreeViewSelectable } from './types';
|
|
3
|
+
export interface ExpandIconInterface {
|
|
4
|
+
size?: number;
|
|
5
|
+
color?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface TreeViewConfigContextInterface {
|
|
8
|
+
hasIcons: boolean;
|
|
9
|
+
selectable: TreeViewSelectable;
|
|
10
|
+
checkParents: boolean;
|
|
11
|
+
checkChildren: boolean;
|
|
12
|
+
isTopLevelSelectable?: boolean;
|
|
13
|
+
selectParents?: boolean;
|
|
14
|
+
expandIconStyles?: ExpandIconInterface;
|
|
15
|
+
registerTreeItem: (itemRefArray: React.MutableRefObject<React.MutableRefObject<Element>[]>, itemRef: React.MutableRefObject<Element>) => void;
|
|
16
|
+
treeItemRefArray?: React.MutableRefObject<React.MutableRefObject<Element>[]>;
|
|
17
|
+
}
|
|
18
|
+
export declare const TreeViewConfigContext: React.Context<TreeViewConfigContextInterface>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface TreeViewExpansionContextInterface {
|
|
3
|
+
expandedSet: Set<string>;
|
|
4
|
+
handleExpandedChange: (event: React.SyntheticEvent, expandedItemId: string) => void;
|
|
5
|
+
onExpandedChange?: (event: React.SyntheticEvent, expandedItems: Array<string>) => void;
|
|
6
|
+
initialExpandedItems: Array<string>;
|
|
7
|
+
}
|
|
8
|
+
export declare const TreeViewExpansionContext: React.Context<TreeViewExpansionContextInterface>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TreeViewSelectable } from './types';
|
|
3
|
+
import { IndeterminateCheckboxStatus } from '../IndeterminateCheckbox';
|
|
4
|
+
export interface TreeItemSelectedInterface {
|
|
5
|
+
itemId?: string;
|
|
6
|
+
checkedStatus: IndeterminateCheckboxStatus;
|
|
7
|
+
isDisabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface TreeViewItemInterface {
|
|
10
|
+
itemId?: string;
|
|
11
|
+
parentId?: string | null;
|
|
12
|
+
icon?: React.ReactNode;
|
|
13
|
+
checkedStatus: IndeterminateCheckboxStatus;
|
|
14
|
+
hasOwnTreeItems: boolean;
|
|
15
|
+
isDisabled?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface TreeViewSelectionContextInterface {
|
|
18
|
+
items: TreeViewItemInterface[];
|
|
19
|
+
selectedItems: Array<TreeItemSelectedInterface>;
|
|
20
|
+
selectItem: (data: Pick<TreeViewItemInterface, 'itemId' | 'checkedStatus'>) => void;
|
|
21
|
+
onSelectedItemChange?: (selectedItems: Array<TreeItemSelectedInterface>) => void;
|
|
22
|
+
selectable: TreeViewSelectable;
|
|
23
|
+
itemToFocus?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare const TreeViewSelectionContext: React.Context<TreeViewSelectionContextInterface>;
|
|
@@ -5,3 +5,6 @@ export * from './useTreeView';
|
|
|
5
5
|
export * from './utils';
|
|
6
6
|
export * from './types';
|
|
7
7
|
export { TreeItemSelectedInterface, TreeViewApi } from './useTreeView';
|
|
8
|
+
export * from './TreeViewSelectionContext';
|
|
9
|
+
export * from './TreeViewExpansionContext';
|
|
10
|
+
export * from './TreeViewConfigContext';
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { IndeterminateCheckboxStatus } from '../IndeterminateCheckbox';
|
|
2
|
+
import { TreeViewItemInterface } from './TreeViewContext';
|
|
3
|
+
/**
|
|
4
|
+
* TreeView State Shape
|
|
5
|
+
* Consolidates all state managed by the TreeView component
|
|
6
|
+
*/
|
|
7
|
+
export interface TreeViewState {
|
|
8
|
+
/** Array of all tree items with their metadata */
|
|
9
|
+
items: TreeViewItemInterface[];
|
|
10
|
+
/** Set of expanded item IDs for O(1) lookup */
|
|
11
|
+
expandedSet: Set<string>;
|
|
12
|
+
/** Flag indicating if items need to be updated (for showAll functionality) */
|
|
13
|
+
itemsNeedUpdate: boolean | null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* TreeView Action Types
|
|
17
|
+
* Defines all possible state mutations
|
|
18
|
+
*/
|
|
19
|
+
export declare type TreeViewAction = {
|
|
20
|
+
type: 'SELECT_ITEM';
|
|
21
|
+
payload: {
|
|
22
|
+
itemId: string;
|
|
23
|
+
checkedStatus?: IndeterminateCheckboxStatus;
|
|
24
|
+
selectable: string;
|
|
25
|
+
checkChildren: boolean;
|
|
26
|
+
checkParents: boolean;
|
|
27
|
+
isTopLevelSelectable: boolean;
|
|
28
|
+
};
|
|
29
|
+
} | {
|
|
30
|
+
type: 'SELECT_ALL';
|
|
31
|
+
payload: {
|
|
32
|
+
checkChildren: boolean;
|
|
33
|
+
checkParents: boolean;
|
|
34
|
+
isTopLevelSelectable: boolean;
|
|
35
|
+
};
|
|
36
|
+
} | {
|
|
37
|
+
type: 'CLEAR_ALL';
|
|
38
|
+
payload: {
|
|
39
|
+
checkChildren: boolean;
|
|
40
|
+
checkParents: boolean;
|
|
41
|
+
isTopLevelSelectable: boolean;
|
|
42
|
+
};
|
|
43
|
+
} | {
|
|
44
|
+
type: 'TOGGLE_EXPAND';
|
|
45
|
+
payload: {
|
|
46
|
+
itemId: string | string[];
|
|
47
|
+
};
|
|
48
|
+
} | {
|
|
49
|
+
type: 'EXPAND_ALL';
|
|
50
|
+
payload: {
|
|
51
|
+
expandableIds: string[];
|
|
52
|
+
};
|
|
53
|
+
} | {
|
|
54
|
+
type: 'COLLAPSE_ALL';
|
|
55
|
+
} | {
|
|
56
|
+
type: 'SET_ITEMS';
|
|
57
|
+
payload: {
|
|
58
|
+
items: TreeViewItemInterface[];
|
|
59
|
+
};
|
|
60
|
+
} | {
|
|
61
|
+
type: 'ADD_ITEM';
|
|
62
|
+
payload: {
|
|
63
|
+
newItem: TreeViewItemInterface;
|
|
64
|
+
checkParents: boolean;
|
|
65
|
+
selectable: string;
|
|
66
|
+
};
|
|
67
|
+
} | {
|
|
68
|
+
type: 'UPDATE_ITEMS_DISABLED_STATE';
|
|
69
|
+
payload: {
|
|
70
|
+
updatedItems: TreeViewItemInterface[];
|
|
71
|
+
};
|
|
72
|
+
} | {
|
|
73
|
+
type: 'TRIGGER_ITEMS_UPDATE';
|
|
74
|
+
} | {
|
|
75
|
+
type: 'COMPLETE_ITEMS_UPDATE';
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* TreeView Reducer
|
|
79
|
+
* Pure function that handles all state transitions
|
|
80
|
+
*
|
|
81
|
+
* State Transitions:
|
|
82
|
+
* - SELECT_ITEM: Updates item selection based on selectable mode (single/multi)
|
|
83
|
+
* - SELECT_ALL: Selects all items in multi-select mode
|
|
84
|
+
* - CLEAR_ALL: Clears all selections
|
|
85
|
+
* - TOGGLE_EXPAND: Toggles expansion state of one or more items
|
|
86
|
+
* - EXPAND_ALL: Expands all expandable items
|
|
87
|
+
* - COLLAPSE_ALL: Collapses all items
|
|
88
|
+
* - SET_ITEMS: Replaces entire items array (used for initialization and updates)
|
|
89
|
+
* - ADD_ITEM: Adds a new item to the tree
|
|
90
|
+
* - UPDATE_ITEMS_DISABLED_STATE: Updates disabled state of items
|
|
91
|
+
* - TRIGGER_ITEMS_UPDATE: Flags that items need updating (for showAll)
|
|
92
|
+
* - COMPLETE_ITEMS_UPDATE: Clears the update flag
|
|
93
|
+
*/
|
|
94
|
+
export declare function treeViewReducer(state: TreeViewState, action: TreeViewAction): TreeViewState;
|
|
@@ -62,6 +62,11 @@ export interface UseTreeItemProps extends React.HTMLAttributes<HTMLLIElement> {
|
|
|
62
62
|
* Style properties for the tree item
|
|
63
63
|
*/
|
|
64
64
|
treeItemStyles?: React.CSSProperties;
|
|
65
|
+
/**
|
|
66
|
+
* @internal
|
|
67
|
+
* Used in virtualization to indicate this item has TreeItem children.
|
|
68
|
+
*/
|
|
69
|
+
hasTreeItemChildren?: boolean;
|
|
65
70
|
}
|
|
66
71
|
export declare const checkedStatusToBoolean: (status: IndeterminateCheckboxStatus) => boolean;
|
|
67
72
|
export declare function useTreeItem(props: UseTreeItemProps, forwardedRef: any): {
|
|
@@ -74,8 +79,7 @@ export declare function useTreeItem(props: UseTreeItemProps, forwardedRef: any):
|
|
|
74
79
|
itemId: string;
|
|
75
80
|
parentDepth: number;
|
|
76
81
|
ref: (node: any) => void;
|
|
77
|
-
selectedItems: import("./
|
|
78
|
-
setExpanded: React.Dispatch<React.SetStateAction<boolean>>;
|
|
82
|
+
selectedItems: import("./TreeViewSelectionContext").TreeItemSelectedInterface[];
|
|
79
83
|
treeItemChildren: (string | number | {} | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any>) | (new (props: any) => React.Component<any, any, any>)> | Iterable<React.ReactNode> | React.ReactPortal)[];
|
|
80
84
|
isDisabled: boolean;
|
|
81
85
|
};
|
|
@@ -95,6 +95,13 @@ export interface UseTreeViewProps {
|
|
|
95
95
|
* @default TreeViewSelectable.single
|
|
96
96
|
*/
|
|
97
97
|
selectable?: TreeViewSelectable;
|
|
98
|
+
/**
|
|
99
|
+
* When enabled (default), parent items (folders) can be selected in TreeViewSelectable.single mode.
|
|
100
|
+
* When disabled, parent items will only expand/collapse on click and won't trigger selection or onClick.
|
|
101
|
+
* Child items (leaves) can always be selected regardless of this setting.
|
|
102
|
+
* @default true
|
|
103
|
+
*/
|
|
104
|
+
selectParents?: boolean;
|
|
98
105
|
/**
|
|
99
106
|
* @internal
|
|
100
107
|
*/
|
|
@@ -112,24 +119,30 @@ interface ExpandIconStylesProps {
|
|
|
112
119
|
color?: string;
|
|
113
120
|
}
|
|
114
121
|
export declare function useTreeView(props: UseTreeViewProps): {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
122
|
+
selectionContextValue: {
|
|
123
|
+
items: TreeViewItemInterface[];
|
|
124
|
+
selectedItems: TreeViewItemInterface[];
|
|
125
|
+
selectItem: ({ itemId, checkedStatus, }: Pick<TreeViewItemInterface, 'itemId'> & Partial<Pick<TreeViewItemInterface, 'checkedStatus'>>) => void;
|
|
118
126
|
onSelectedItemChange: (selectedItems: TreeItemSelectedInterface[]) => void;
|
|
119
|
-
onExpandedChange: (event: React.SyntheticEvent<Element, Event>, expandedItems: string[]) => void;
|
|
120
127
|
selectable: TreeViewSelectable;
|
|
121
|
-
|
|
128
|
+
itemToFocus: string;
|
|
129
|
+
};
|
|
130
|
+
expansionContextValue: {
|
|
131
|
+
expandedSet: Set<string>;
|
|
132
|
+
handleExpandedChange: (event: React.SyntheticEvent, itemId: string | string[]) => void;
|
|
133
|
+
onExpandedChange: (event: React.SyntheticEvent<Element, Event>, expandedItems: string[]) => void;
|
|
122
134
|
initialExpandedItems: any[];
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
135
|
+
};
|
|
136
|
+
configContextValue: {
|
|
137
|
+
hasIcons: any;
|
|
138
|
+
selectable: TreeViewSelectable;
|
|
126
139
|
checkParents: boolean;
|
|
127
|
-
|
|
128
|
-
selectItem: ({ itemId, checkedStatus, }: Pick<TreeViewItemInterface, 'itemId'> & Partial<Pick<TreeViewItemInterface, 'checkedStatus'>>) => void;
|
|
129
|
-
handleExpandedChange: (event: React.SyntheticEvent, itemId: string | string[]) => void;
|
|
130
|
-
expandedSet: Set<string>;
|
|
131
|
-
expandIconStyles: ExpandIconStylesProps;
|
|
140
|
+
checkChildren: boolean;
|
|
132
141
|
isTopLevelSelectable: boolean;
|
|
142
|
+
selectParents: boolean;
|
|
143
|
+
expandIconStyles: ExpandIconStylesProps;
|
|
144
|
+
registerTreeItem: (refArray: React.MutableRefObject<React.MutableRefObject<Element>[]>, ref: React.MutableRefObject<Element>) => void;
|
|
145
|
+
treeItemRefArray: React.MutableRefObject<React.MutableRefObject<Element>[]>;
|
|
133
146
|
};
|
|
134
147
|
};
|
|
135
148
|
export declare type UseTreeViewReturn = ReturnType<typeof useTreeView>;
|