@mezzanine-ui/react 1.0.0-alpha.0 → 1.0.0-beta.1
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/Breadcrumb/Breadcrumb.js +40 -12
- package/Breadcrumb/typings.d.ts +8 -3
- package/Drawer/Drawer.d.ts +47 -6
- package/Drawer/Drawer.js +36 -11
- package/Dropdown/Dropdown.d.ts +116 -15
- package/Dropdown/Dropdown.js +235 -32
- package/Dropdown/DropdownAction.d.ts +50 -0
- package/Dropdown/DropdownAction.js +26 -0
- package/Dropdown/DropdownItem.d.ts +60 -0
- package/Dropdown/DropdownItem.js +318 -0
- package/Dropdown/DropdownItemCard.d.ts +96 -0
- package/Dropdown/DropdownItemCard.js +115 -0
- package/Dropdown/DropdownStatus.d.ts +22 -0
- package/Dropdown/dropdownKeydownHandler.d.ts +15 -0
- package/Dropdown/highlightText.d.ts +9 -0
- package/Dropdown/highlightText.js +32 -0
- package/Dropdown/index.d.ts +1 -1
- package/Empty/Empty.js +26 -3
- package/Empty/typings.d.ts +16 -7
- package/Navigation/Navigation.d.ts +11 -17
- package/Navigation/Navigation.js +58 -41
- package/Navigation/NavigationFooter.d.ts +10 -0
- package/Navigation/NavigationFooter.js +26 -0
- package/Navigation/NavigationHeader.d.ts +8 -0
- package/Navigation/NavigationHeader.js +13 -0
- package/Navigation/NavigationIconButton.d.ts +15 -0
- package/Navigation/NavigationIconButton.js +12 -0
- package/Navigation/NavigationOption.d.ts +35 -0
- package/Navigation/NavigationOption.js +60 -0
- package/Navigation/NavigationOptionCategory.d.ts +6 -0
- package/Navigation/NavigationOptionCategory.js +12 -0
- package/Navigation/NavigationUserMenu.d.ts +8 -0
- package/Navigation/NavigationUserMenu.js +18 -0
- package/Navigation/context.d.ts +13 -0
- package/Navigation/context.js +7 -0
- package/Navigation/index.d.ts +12 -6
- package/Navigation/index.js +6 -3
- package/Navigation/useCurrentPathname.d.ts +1 -0
- package/Navigation/useCurrentPathname.js +14 -0
- package/PageHeader/PageHeader.d.ts +5 -1
- package/PageHeader/PageHeader.js +8 -3
- package/PageToolbar/PageToolbar.d.ts +73 -26
- package/PageToolbar/PageToolbar.js +10 -101
- package/PageToolbar/utils.d.ts +23 -0
- package/PageToolbar/utils.js +165 -0
- package/Pagination/PaginationItem.js +1 -3
- package/Pagination/usePagination.js +0 -18
- package/Radio/Radio.d.ts +36 -3
- package/Radio/Radio.js +21 -11
- package/Radio/RadioGroup.d.ts +36 -7
- package/Radio/RadioGroup.js +5 -4
- package/Radio/RadioGroupContext.d.ts +2 -1
- package/Radio/index.d.ts +3 -3
- package/Slider/useSlider.js +1 -1
- package/Tab/Tab.d.ts +32 -0
- package/Tab/Tab.js +57 -0
- package/Tab/TabItem.d.ts +27 -0
- package/Tab/TabItem.js +18 -0
- package/Tab/index.d.ts +4 -0
- package/Tab/index.js +2 -0
- package/Table/Table.d.ts +75 -94
- package/Table/Table.js +216 -161
- package/Table/TableContext.d.ts +114 -51
- package/Table/TableContext.js +21 -3
- package/Table/components/TableBody.d.ts +5 -0
- package/Table/components/TableBody.js +102 -0
- package/Table/components/TableCell.d.ts +17 -0
- package/Table/components/TableCell.js +74 -0
- package/Table/components/TableColGroup.d.ts +4 -0
- package/Table/components/TableColGroup.js +206 -0
- package/Table/components/TableDragHandleCell.d.ts +9 -0
- package/Table/components/TableDragHandleCell.js +37 -0
- package/Table/components/TableExpandCell.d.ts +11 -0
- package/Table/components/TableExpandCell.js +44 -0
- package/Table/components/TableExpandedRow.d.ts +9 -0
- package/Table/components/TableExpandedRow.js +46 -0
- package/Table/components/TableHeader.d.ts +4 -0
- package/Table/components/TableHeader.js +125 -0
- package/Table/components/TablePagination.d.ts +3 -0
- package/Table/components/TablePagination.js +11 -0
- package/Table/components/TableResizeHandle.d.ts +13 -0
- package/Table/components/TableResizeHandle.js +115 -0
- package/Table/components/TableRow.d.ts +12 -0
- package/Table/components/TableRow.js +126 -0
- package/Table/components/TableSelectionCell.d.ts +13 -0
- package/Table/components/TableSelectionCell.js +35 -0
- package/Table/components/index.d.ts +10 -0
- package/Table/components/index.js +10 -0
- package/Table/hooks/index.d.ts +9 -0
- package/Table/hooks/index.js +8 -0
- package/Table/hooks/typings.d.ts +14 -0
- package/Table/hooks/useTableColumns.d.ts +8 -0
- package/Table/hooks/useTableColumns.js +91 -0
- package/Table/hooks/useTableDataSource.d.ts +57 -0
- package/Table/hooks/useTableDataSource.js +183 -0
- package/Table/hooks/useTableExpansion.d.ts +7 -0
- package/Table/hooks/useTableExpansion.js +52 -0
- package/Table/hooks/useTableFixedOffsets.d.ts +29 -0
- package/Table/hooks/useTableFixedOffsets.js +241 -0
- package/Table/hooks/useTableScroll.d.ts +12 -0
- package/Table/hooks/useTableScroll.js +58 -0
- package/Table/hooks/useTableSelection.d.ts +7 -0
- package/Table/hooks/useTableSelection.js +94 -0
- package/Table/hooks/useTableSorting.d.ts +6 -0
- package/Table/hooks/useTableSorting.js +32 -0
- package/Table/hooks/useTableVirtualization.d.ts +22 -0
- package/Table/hooks/useTableVirtualization.js +115 -0
- package/Table/index.d.ts +7 -10
- package/Table/index.js +22 -6
- package/Table/utils/index.d.ts +2 -0
- package/Table/utils/index.js +1 -0
- package/Table/utils/useTableRowSelection.d.ts +18 -0
- package/Table/utils/useTableRowSelection.js +63 -0
- package/_internal/InputCheck/InputCheck.d.ts +15 -1
- package/_internal/InputCheck/InputCheck.js +6 -2
- package/_internal/InputCheck/InputCheckGroup.d.ts +11 -1
- package/_internal/InputCheck/InputCheckGroup.js +4 -2
- package/_internal/SlideFadeOverlay/SlideFadeOverlay.d.ts +1 -1
- package/_internal/SlideFadeOverlay/SlideFadeOverlay.js +1 -1
- package/hooks/useElementHeight.d.ts +8 -0
- package/hooks/useElementHeight.js +41 -0
- package/index.d.ts +9 -7
- package/index.js +6 -11
- package/package.json +6 -4
- package/utils/flatten-children.d.ts +12 -0
- package/utils/flatten-children.js +37 -0
- package/utils/get-css-variable-value.d.ts +1 -0
- package/utils/get-css-variable-value.js +4 -1
- package/Navigation/NavigationContext.d.ts +0 -5
- package/Navigation/NavigationContext.js +0 -8
- package/Navigation/NavigationItem.d.ts +0 -31
- package/Navigation/NavigationItem.js +0 -23
- package/Navigation/NavigationSubMenu.d.ts +0 -22
- package/Navigation/NavigationSubMenu.js +0 -50
- package/Table/TableBody.d.ts +0 -10
- package/Table/TableBody.js +0 -31
- package/Table/TableBodyRow.d.ts +0 -11
- package/Table/TableBodyRow.js +0 -65
- package/Table/TableCell.d.ts +0 -19
- package/Table/TableCell.js +0 -24
- package/Table/TableExpandedTable.d.ts +0 -11
- package/Table/TableExpandedTable.js +0 -29
- package/Table/TableHeader.d.ts +0 -3
- package/Table/TableHeader.js +0 -36
- package/Table/draggable/useTableDraggable.d.ts +0 -14
- package/Table/draggable/useTableDraggable.js +0 -64
- package/Table/editable/TableEditRenderWrapper.d.ts +0 -7
- package/Table/editable/TableEditRenderWrapper.js +0 -16
- package/Table/expandable/TableExpandable.d.ts +0 -27
- package/Table/expandable/TableExpandable.js +0 -24
- package/Table/pagination/TablePagination.d.ts +0 -10
- package/Table/pagination/TablePagination.js +0 -26
- package/Table/pagination/useTablePagination.d.ts +0 -8
- package/Table/pagination/useTablePagination.js +0 -30
- package/Table/refresh/TableRefresh.d.ts +0 -10
- package/Table/refresh/TableRefresh.js +0 -22
- package/Table/rowSelection/TableRowSelection.d.ts +0 -18
- package/Table/rowSelection/TableRowSelection.js +0 -93
- package/Table/rowSelection/useTableRowSelection.d.ts +0 -6
- package/Table/rowSelection/useTableRowSelection.js +0 -53
- package/Table/sorting/TableSortingIcon.d.ts +0 -10
- package/Table/sorting/TableSortingIcon.js +0 -33
- package/Table/sorting/useTableSorting.d.ts +0 -11
- package/Table/sorting/useTableSorting.js +0 -121
- package/Table/useTableFetchMore.d.ts +0 -10
- package/Table/useTableFetchMore.js +0 -50
- package/Table/useTableLoading.d.ts +0 -5
- package/Table/useTableLoading.js +0 -19
- package/Table/useTableScroll.d.ts +0 -592
- package/Table/useTableScroll.js +0 -296
- package/Tabs/Tab.d.ts +0 -18
- package/Tabs/Tab.js +0 -16
- package/Tabs/TabPane.d.ts +0 -14
- package/Tabs/TabPane.js +0 -19
- package/Tabs/Tabs.d.ts +0 -39
- package/Tabs/Tabs.js +0 -52
- package/Tabs/index.d.ts +0 -6
- package/Tabs/index.js +0 -3
- package/Tabs/useTabsOverflow.d.ts +0 -8
- package/Tabs/useTabsOverflow.js +0 -62
package/Radio/Radio.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { forwardRef, useContext } from 'react';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef, useContext, useState } from 'react';
|
|
4
4
|
import { radioClasses } from '@mezzanine-ui/core/radio';
|
|
5
5
|
import InputCheck from '../_internal/InputCheck/InputCheck.js';
|
|
6
6
|
import { useRadioControlValue } from '../Form/useRadioControlValue.js';
|
|
7
7
|
import { RadioGroupContext } from './RadioGroupContext.js';
|
|
8
|
-
import
|
|
9
|
-
import
|
|
8
|
+
import Icon from '../Icon/Icon.js';
|
|
9
|
+
import Input from '../Input/Input.js';
|
|
10
10
|
import cx from 'clsx';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* The react component for `mezzanine` radio.
|
|
14
14
|
*/
|
|
15
15
|
const Radio = forwardRef(function Radio(props, ref) {
|
|
16
|
-
|
|
17
|
-
const { disabled: disabledFromFormControl, severity } = useContext(FormControlContext) || {};
|
|
16
|
+
var _a, _b;
|
|
18
17
|
const radioGroup = useContext(RadioGroupContext);
|
|
19
|
-
const { disabled: disabledFromGroup, name: nameFromGroup, size: sizeFromGroup, } = radioGroup || {};
|
|
20
|
-
const { checked: checkedProp, children, defaultChecked, disabled =
|
|
18
|
+
const { disabled: disabledFromGroup, name: nameFromGroup, size: sizeFromGroup, type: typeFromGroup, } = radioGroup || {};
|
|
19
|
+
const { checked: checkedProp, className, children, defaultChecked, disabled = disabledFromGroup || false, error = false, icon, hint, inputProps, onChange: onChangeProp, size = sizeFromGroup || 'main', type = typeFromGroup || 'radio', value, withInputConfig, ...rest } = props;
|
|
21
20
|
const { id: inputId, name = nameFromGroup, ...restInputProps } = inputProps || {};
|
|
22
21
|
const [checked, onChange] = useRadioControlValue({
|
|
23
22
|
checked: checkedProp,
|
|
@@ -26,9 +25,20 @@ const Radio = forwardRef(function Radio(props, ref) {
|
|
|
26
25
|
radioGroup,
|
|
27
26
|
value,
|
|
28
27
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
const [focused, setFocused] = useState(false);
|
|
29
|
+
return (jsxs("div", { ref: ref, className: cx(radioClasses.wrapper, className), children: [jsx(InputCheck, { ...rest, control: jsxs("span", { className: cx(radioClasses.host, radioClasses.size(size), {
|
|
30
|
+
[radioClasses.segmented]: type === 'segment',
|
|
31
|
+
[radioClasses.checked]: checked,
|
|
32
|
+
[radioClasses.focused]: focused,
|
|
33
|
+
[radioClasses.error]: error,
|
|
34
|
+
}), children: [type === 'segment' && (jsxs("span", { className: cx(radioClasses.segmentedContainer, {
|
|
35
|
+
[radioClasses.segmentedContainerHaveMinWidth]: !!children,
|
|
36
|
+
[radioClasses.segmentedContainerWithIconText]: !!children && !!icon,
|
|
37
|
+
}), children: [icon && jsx(Icon, { icon: icon, size: 16 }), children] })), jsx("input", { ...restInputProps, "aria-checked": checked, "aria-disabled": disabled, checked: checked, disabled: disabled, id: inputId, onChange: onChange, onFocus: () => {
|
|
38
|
+
setFocused(true);
|
|
39
|
+
}, onBlur: () => {
|
|
40
|
+
setFocused(false);
|
|
41
|
+
}, name: name, type: "radio", value: value })] }), disabled: disabled, error: error, focused: focused, hint: hint, htmlFor: inputId, segmentedStyle: type === 'segment', size: size, children: type === 'radio' && children }), type === 'radio' && withInputConfig && (jsx("div", { style: { width: (_a = withInputConfig.width) !== null && _a !== void 0 ? _a : 120 }, children: jsx(Input, { ...withInputConfig, variant: "base", placeholder: (_b = withInputConfig.placeholder) !== null && _b !== void 0 ? _b : 'Placeholder' }) }))] }));
|
|
32
42
|
});
|
|
33
43
|
|
|
34
44
|
export { Radio as default };
|
package/Radio/RadioGroup.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RadioSize } from '@mezzanine-ui/core/radio';
|
|
2
2
|
import { ChangeEventHandler, ReactNode } from 'react';
|
|
3
3
|
import { InputCheckGroupProps } from '../_internal/InputCheck/InputCheckGroup';
|
|
4
|
-
|
|
4
|
+
import { RadioNormalProps, RadioSegmentProps } from './Radio';
|
|
5
|
+
export interface RadioGroupNormalOption extends Pick<RadioNormalProps, 'disabled' | 'error' | 'icon' | 'hint' | 'withInputConfig'> {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string | number;
|
|
8
|
+
}
|
|
9
|
+
export interface RadioGroupSegmentOption extends Pick<RadioSegmentProps, 'disabled' | 'error' | 'icon' | 'hint' | 'withInputConfig'> {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string | number;
|
|
12
|
+
}
|
|
13
|
+
export interface RadioGroupBaseProps extends Omit<InputCheckGroupProps, 'onChange' | 'type'> {
|
|
5
14
|
/**
|
|
6
15
|
* The radios in radio group.
|
|
7
16
|
*/
|
|
@@ -25,11 +34,6 @@ export interface RadioGroupProps extends Omit<InputCheckGroupProps, 'onChange'>
|
|
|
25
34
|
* Will be passed to each radios but composing both instead of overriding.
|
|
26
35
|
*/
|
|
27
36
|
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
28
|
-
/**
|
|
29
|
-
* The options of radio group.
|
|
30
|
-
* Will be ignored if children passed.
|
|
31
|
-
*/
|
|
32
|
-
options?: RadioGroupOption[];
|
|
33
37
|
/**
|
|
34
38
|
* The size of radio group.
|
|
35
39
|
* Control the size of radios in group if size not passed to radio.
|
|
@@ -40,6 +44,31 @@ export interface RadioGroupProps extends Omit<InputCheckGroupProps, 'onChange'>
|
|
|
40
44
|
*/
|
|
41
45
|
value?: string;
|
|
42
46
|
}
|
|
47
|
+
export interface RadioGroupNormalProps extends RadioGroupBaseProps {
|
|
48
|
+
/**
|
|
49
|
+
* The options of radio group.
|
|
50
|
+
* Will be ignored if children passed.
|
|
51
|
+
*/
|
|
52
|
+
options?: RadioGroupNormalOption[];
|
|
53
|
+
/**
|
|
54
|
+
* The type of radio group.
|
|
55
|
+
* Control the type of radios in group if type not passed to radio.
|
|
56
|
+
*/
|
|
57
|
+
type?: 'radio';
|
|
58
|
+
}
|
|
59
|
+
export interface RadioGroupSegmentProps extends RadioGroupBaseProps {
|
|
60
|
+
/**
|
|
61
|
+
* The options of radio group.
|
|
62
|
+
* Will be ignored if children passed.
|
|
63
|
+
*/
|
|
64
|
+
options?: RadioGroupSegmentOption[];
|
|
65
|
+
/**
|
|
66
|
+
* The type of radio group.
|
|
67
|
+
* Control the type of radios in group if type not passed to radio.
|
|
68
|
+
*/
|
|
69
|
+
type: 'segment';
|
|
70
|
+
}
|
|
71
|
+
export type RadioGroupProps = RadioGroupNormalProps | RadioGroupSegmentProps;
|
|
43
72
|
/**
|
|
44
73
|
* The react component for `mezzanine` radio group.
|
|
45
74
|
*/
|
package/Radio/RadioGroup.js
CHANGED
|
@@ -9,7 +9,7 @@ import Radio from './Radio.js';
|
|
|
9
9
|
* The react component for `mezzanine` radio group.
|
|
10
10
|
*/
|
|
11
11
|
const RadioGroup = forwardRef(function RadioGroup(props, ref) {
|
|
12
|
-
const { children: childrenProp, defaultValue, disabled, name, options = [], onChange: onChangeProp, size, value: valueProp, ...rest } = props;
|
|
12
|
+
const { children: childrenProp, defaultValue, disabled, name, options = [], onChange: onChangeProp, size, type, value: valueProp, ...rest } = props;
|
|
13
13
|
const [value, onChange] = useInputControlValue({
|
|
14
14
|
defaultValue,
|
|
15
15
|
onChange: onChangeProp,
|
|
@@ -20,11 +20,12 @@ const RadioGroup = forwardRef(function RadioGroup(props, ref) {
|
|
|
20
20
|
name,
|
|
21
21
|
onChange,
|
|
22
22
|
size,
|
|
23
|
+
type,
|
|
23
24
|
value,
|
|
24
|
-
}), [disabled, name, onChange, size, value]);
|
|
25
|
+
}), [disabled, name, onChange, size, type, value]);
|
|
25
26
|
const children = childrenProp ||
|
|
26
|
-
options.map((option) => (jsx(Radio, { disabled: option.disabled, value: option.
|
|
27
|
-
return (jsx(RadioGroupContext.Provider, { value: context, children: jsx(InputCheckGroup, { ...rest, ref: ref, role: "radiogroup", children: children }) }));
|
|
27
|
+
options.map((option) => (jsx(Radio, { disabled: option.disabled, error: option.error, hint: option.hint, value: option.id, withInputConfig: option.withInputConfig, children: option.name }, option.id)));
|
|
28
|
+
return (jsx(RadioGroupContext.Provider, { value: context, children: jsx(InputCheckGroup, { ...rest, ref: ref, role: "radiogroup", segmentedStyle: type === 'segment', size: size, children: children }) }));
|
|
28
29
|
});
|
|
29
30
|
|
|
30
31
|
export { RadioGroup as default };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { RadioSize } from '@mezzanine-ui/core/radio';
|
|
1
|
+
import { RadioSize, RadioType } from '@mezzanine-ui/core/radio';
|
|
2
2
|
import { RadioGroupControlContextValue } from '../Form/useRadioControlValue';
|
|
3
3
|
export interface RadioGroupContextValue extends RadioGroupControlContextValue {
|
|
4
4
|
disabled?: boolean;
|
|
5
5
|
name?: string;
|
|
6
6
|
size?: RadioSize;
|
|
7
|
+
type?: RadioType;
|
|
7
8
|
}
|
|
8
9
|
export declare const RadioGroupContext: import("react").Context<RadioGroupContextValue | undefined>;
|
package/Radio/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type { RadioSize,
|
|
2
|
-
export type { RadioProps } from './Radio';
|
|
1
|
+
export type { RadioSize, RadioGroupOrientation, } from '@mezzanine-ui/core/radio';
|
|
2
|
+
export type { RadioNormalProps, RadioSegmentProps, RadioProps } from './Radio';
|
|
3
3
|
export { default } from './Radio';
|
|
4
|
-
export type { RadioGroupProps } from './RadioGroup';
|
|
4
|
+
export type { RadioGroupNormalOption, RadioGroupSegmentOption, RadioGroupProps, } from './RadioGroup';
|
|
5
5
|
export { default as RadioGroup } from './RadioGroup';
|
package/Slider/useSlider.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isRangeSlider, fixRangeSliderValue, fixSingleSliderValue, toSliderCssVars, getPercentage,
|
|
1
|
+
import { isRangeSlider, fixRangeSliderValue, fixSingleSliderValue, toSliderCssVars, getPercentage, sortSliderValue, findClosetValueIndex, getSliderRect, getValueFromClientX, roundToStep } from '@mezzanine-ui/core/slider';
|
|
2
2
|
import { useRef, useState } from 'react';
|
|
3
3
|
import { useDocumentEvents } from '../hooks/useDocumentEvents.js';
|
|
4
4
|
|
package/Tab/Tab.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Key, ReactElement } from 'react';
|
|
2
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
3
|
+
import { TabItemProps } from './TabItem';
|
|
4
|
+
export type TabsChild = ReactElement<TabItemProps>;
|
|
5
|
+
export interface TabProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'onChange' | 'children'> {
|
|
6
|
+
/**
|
|
7
|
+
* Current TabItem's index
|
|
8
|
+
*/
|
|
9
|
+
activeKey?: Key;
|
|
10
|
+
/**
|
|
11
|
+
* The TabItems in tab
|
|
12
|
+
*/
|
|
13
|
+
children: TabsChild | TabsChild[];
|
|
14
|
+
/**
|
|
15
|
+
* Initial active TabItem's key, if activeKey is not set.
|
|
16
|
+
*/
|
|
17
|
+
defaultActiveKey?: Key;
|
|
18
|
+
/**
|
|
19
|
+
* The direction of tab
|
|
20
|
+
* @default 'horizontal'
|
|
21
|
+
*/
|
|
22
|
+
direction?: 'horizontal' | 'vertical';
|
|
23
|
+
/**
|
|
24
|
+
* The change event handler of Tab
|
|
25
|
+
*/
|
|
26
|
+
onChange?: (activeKey: Key, index: number) => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The react component for `mezzanine` tab.
|
|
30
|
+
*/
|
|
31
|
+
declare const Tab: import("react").ForwardRefExoticComponent<TabProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
32
|
+
export default Tab;
|
package/Tab/Tab.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef, useState, useRef, Children, cloneElement, useLayoutEffect } from 'react';
|
|
3
|
+
import { tabClasses } from '@mezzanine-ui/core/tab';
|
|
4
|
+
import TabItem from './TabItem.js';
|
|
5
|
+
import cx from 'clsx';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The react component for `mezzanine` tab.
|
|
9
|
+
*/
|
|
10
|
+
const Tab = forwardRef(function Tab(props, ref) {
|
|
11
|
+
const { activeKey: activeKeyProp, children, className, defaultActiveKey = 0, onChange, direction = 'horizontal', ...rest } = props;
|
|
12
|
+
const [activeKeyInternal, setActiveKey] = useState(defaultActiveKey);
|
|
13
|
+
const activeKey = activeKeyProp !== null && activeKeyProp !== void 0 ? activeKeyProp : activeKeyInternal;
|
|
14
|
+
const activeTabItemRef = useRef(null);
|
|
15
|
+
const tabItems = Children.map(children, (tabItem, index) => {
|
|
16
|
+
var _a;
|
|
17
|
+
if (!tabItem || tabItem.type !== TabItem) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const key = (_a = tabItem.key) !== null && _a !== void 0 ? _a : index;
|
|
21
|
+
const active = activeKey === key;
|
|
22
|
+
return cloneElement(tabItem, {
|
|
23
|
+
key,
|
|
24
|
+
active,
|
|
25
|
+
ref: active ? activeTabItemRef : undefined,
|
|
26
|
+
onClick: (event) => {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
if (!active) {
|
|
29
|
+
setActiveKey(key);
|
|
30
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(key, index);
|
|
31
|
+
}
|
|
32
|
+
(_b = (_a = tabItem.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
// get active TabItem left and width for activeBar position
|
|
37
|
+
const [activeBarStyle, setActiveBarStyle] = useState({
|
|
38
|
+
'--active-bar-length': '0px',
|
|
39
|
+
'--active-bar-shift': '0px',
|
|
40
|
+
});
|
|
41
|
+
useLayoutEffect(() => {
|
|
42
|
+
const activeTabElement = activeTabItemRef.current;
|
|
43
|
+
if (activeTabElement) {
|
|
44
|
+
const { offsetLeft, offsetWidth, offsetTop, offsetHeight } = activeTabElement;
|
|
45
|
+
setActiveBarStyle({
|
|
46
|
+
'--active-bar-length': direction === 'horizontal' ? `${offsetWidth}px` : `${offsetHeight}px`,
|
|
47
|
+
'--active-bar-shift': direction === 'horizontal' ? `${offsetLeft}px` : `${offsetTop}px`,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}, [activeKey, direction]);
|
|
51
|
+
return (jsxs("div", { ...rest, ref: ref, className: cx(tabClasses.host, {
|
|
52
|
+
[tabClasses.tabHorizontal]: direction === 'horizontal',
|
|
53
|
+
[tabClasses.tabVertical]: direction === 'vertical',
|
|
54
|
+
}, className), children: [tabItems, jsx("div", { className: tabClasses.tabActiveBar, style: activeBarStyle })] }));
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export { Tab as default };
|
package/Tab/TabItem.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
2
|
+
import { IconDefinition } from '@mezzanine-ui/icons';
|
|
3
|
+
export interface TabItemProps extends NativeElementPropsWithoutKeyAndRef<'button'> {
|
|
4
|
+
/**
|
|
5
|
+
* Whether the tab item is active.
|
|
6
|
+
* Controlled by `<Tab />`.
|
|
7
|
+
*/
|
|
8
|
+
active?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* The badge count to display on the tab item.
|
|
11
|
+
*/
|
|
12
|
+
badgeCount?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the tab item is disabled.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The icon to display on the tab item.
|
|
20
|
+
*/
|
|
21
|
+
icon?: IconDefinition;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The react component for `mezzanine` tab.
|
|
25
|
+
*/
|
|
26
|
+
declare const TabItem: import("react").ForwardRefExoticComponent<TabItemProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
27
|
+
export default TabItem;
|
package/Tab/TabItem.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { tabClasses } from '@mezzanine-ui/core/tab';
|
|
4
|
+
import Icon from '../Icon/Icon.js';
|
|
5
|
+
import Badge from '../Badge/Badge.js';
|
|
6
|
+
import cx from 'clsx';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The react component for `mezzanine` tab.
|
|
10
|
+
*/
|
|
11
|
+
const TabItem = forwardRef(function TabItem(props, ref) {
|
|
12
|
+
const { active, badgeCount, children, className, disabled = false, icon, ...rest } = props;
|
|
13
|
+
return (jsxs("button", { ...rest, "aria-disabled": disabled, className: cx(tabClasses.tabItem, {
|
|
14
|
+
[tabClasses.tabItemActive]: active,
|
|
15
|
+
}, className), disabled: disabled, ref: ref, type: "button", children: [icon && jsx(Icon, { className: tabClasses.tabItemIcon, icon: icon, size: 16 }), children, badgeCount !== undefined && (jsx(Badge, { className: tabClasses.tabItemBadge, count: badgeCount, variant: active ? 'count-brand' : 'count-inactive' }))] }));
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export { TabItem as default };
|
package/Tab/index.d.ts
ADDED
package/Tab/index.js
ADDED
package/Table/Table.d.ts
CHANGED
|
@@ -1,110 +1,91 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
bodyClassName?: string;
|
|
10
|
-
/**
|
|
11
|
-
* customized body row className
|
|
12
|
-
*/
|
|
13
|
-
bodyRowClassName?: string | ((source: T) => string);
|
|
14
|
-
/**
|
|
15
|
-
* Columns of table <br />
|
|
16
|
-
* `column.render` allowed customizing the column body cell rendering. <br />
|
|
17
|
-
* `column.renderTitle` allowed customizing the column header cell rendering. <br />
|
|
18
|
-
* `column.sorter` is the sorting method that you want to apply to your column. <br />
|
|
19
|
-
* `column.onSorted` is the callback triggered whenever sort icon clicked.
|
|
20
|
-
*/
|
|
1
|
+
import { TableSize, type HighlightMode, type TableColumn, type TableDataSource, type TableDraggable, type TableExpandable, type TableRowSelection, type TableScroll } from '@mezzanine-ui/core/table';
|
|
2
|
+
import type { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
3
|
+
import { type TableTransitionState } from './TableContext';
|
|
4
|
+
import { TablePaginationProps } from './components/TablePagination';
|
|
5
|
+
import type { EmptyProps } from '../Empty';
|
|
6
|
+
export interface TableBaseProps<T extends TableDataSource = TableDataSource> extends Omit<NativeElementPropsWithoutKeyAndRef<'table'>, 'children' | 'draggable' | 'summary' | 'onChange'> {
|
|
7
|
+
/** Column configuration */
|
|
21
8
|
columns: TableColumn<T>[];
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
components?: TableComponents;
|
|
26
|
-
/**
|
|
27
|
-
* Data record array to be displayed. <br />
|
|
28
|
-
* Notice that each source should contain `key` or `id` prop as data primary key.
|
|
29
|
-
*/
|
|
30
|
-
dataSource: TableDataSource[];
|
|
31
|
-
/**
|
|
32
|
-
* Draggable table row. This feature allows sort items by mouse dragging. Not supported when `fetchMore` is enabled and also buggy when use finger touch (mobile device).
|
|
33
|
-
* When `draggable.enabled` is true, draggable will be enabled.
|
|
34
|
-
* `draggable.onDragEnd` return new dataSource for you
|
|
35
|
-
*/
|
|
36
|
-
draggable?: TableDraggable;
|
|
37
|
-
/**
|
|
38
|
-
* props exported from `<Empty />` component.
|
|
39
|
-
*/
|
|
9
|
+
/** Data source */
|
|
10
|
+
dataSource: T[];
|
|
11
|
+
/** Props for Empty component when no data */
|
|
40
12
|
emptyProps?: EmptyProps;
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
expandable?: Omit<TableExpandable<T>, 'expandedRowRender'> & {
|
|
46
|
-
expandedRowRender(record: T): ReactNode | ExpandRowBySources;
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* customized header className
|
|
50
|
-
*/
|
|
51
|
-
headerClassName?: string;
|
|
52
|
-
/**
|
|
53
|
-
* Whether table is loading or not
|
|
13
|
+
/** Expandable row configuration */
|
|
14
|
+
expandable?: TableExpandable<T>;
|
|
15
|
+
/** Highlight mode for hover effects
|
|
16
|
+
* @default 'row'
|
|
54
17
|
*/
|
|
18
|
+
highlight?: HighlightMode;
|
|
19
|
+
/** Loading state */
|
|
55
20
|
loading?: boolean;
|
|
21
|
+
/** Number of rows to display when loading */
|
|
22
|
+
loadingRowsCount?: number;
|
|
56
23
|
/**
|
|
57
|
-
*
|
|
58
|
-
* @default '資料載入中...'
|
|
24
|
+
* Whether the table is nested inside an expanded row content area
|
|
59
25
|
*/
|
|
60
|
-
|
|
26
|
+
nested?: boolean;
|
|
27
|
+
/** Pagination configuration */
|
|
28
|
+
pagination?: TablePaginationProps;
|
|
61
29
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
30
|
+
* Whether columns are resizable by user interaction
|
|
31
|
+
* @default false
|
|
64
32
|
*/
|
|
65
|
-
|
|
33
|
+
resizable?: boolean;
|
|
66
34
|
/**
|
|
67
|
-
*
|
|
68
|
-
* `rowSelection.selectedRowKey` is the dataSource keys that are currently selected. <br />
|
|
69
|
-
* `rowSelection.onChange` is the callback when selection changed. <br />
|
|
70
|
-
* `rowSelection.actions` are the actions that you want to do for selected data.
|
|
35
|
+
* Row height preset token.
|
|
71
36
|
*/
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
37
|
+
rowHeightPreset?: 'base' | 'condensed' | 'detailed' | 'roomy';
|
|
38
|
+
/** Row selection configuration */
|
|
39
|
+
rowSelection?: TableRowSelection<T>;
|
|
40
|
+
/** Show header row */
|
|
41
|
+
showHeader?: boolean;
|
|
42
|
+
/** Custom size variant
|
|
43
|
+
* @default 'main'
|
|
78
44
|
*/
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
*
|
|
45
|
+
size?: TableSize;
|
|
46
|
+
/** Whether to enable sticky header
|
|
47
|
+
* @default true
|
|
82
48
|
*/
|
|
83
|
-
|
|
49
|
+
sticky?: boolean;
|
|
50
|
+
/** Transition state for row add/remove animations (from useTableDataSource hook) */
|
|
51
|
+
transitionState?: TableTransitionState;
|
|
84
52
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Props when virtualized scrolling is enabled.
|
|
55
|
+
* Draggable is not allowed in this mode.
|
|
56
|
+
*/
|
|
57
|
+
export interface TableVirtualizedProps<T extends TableDataSource = TableDataSource> extends TableBaseProps<T> {
|
|
58
|
+
/** Draggable row configuration - not available when virtualized is enabled */
|
|
59
|
+
draggable?: never;
|
|
60
|
+
/** Scroll configuration with virtualized enabled */
|
|
61
|
+
scroll: TableScroll & {
|
|
62
|
+
virtualized: true;
|
|
63
|
+
y: number | string;
|
|
64
|
+
};
|
|
95
65
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Props when virtualized scrolling is disabled or not specified.
|
|
68
|
+
* Draggable is allowed in this mode.
|
|
69
|
+
*/
|
|
70
|
+
export interface TableNonVirtualizedProps<T extends TableDataSource = TableDataSource> extends TableBaseProps<T> {
|
|
71
|
+
/** Draggable row configuration */
|
|
72
|
+
draggable?: TableDraggable<T>;
|
|
73
|
+
/** Scroll configuration for scrolling (virtualized defaults to false) */
|
|
74
|
+
scroll?: TableScroll & {
|
|
75
|
+
virtualized?: false;
|
|
76
|
+
};
|
|
107
77
|
}
|
|
108
|
-
|
|
109
|
-
|
|
78
|
+
/**
|
|
79
|
+
* TableProps - discriminated union to ensure draggable and virtualized
|
|
80
|
+
* scrolling are mutually exclusive at the type level.
|
|
81
|
+
*/
|
|
82
|
+
export type TableProps<T extends TableDataSource = TableDataSource> = TableVirtualizedProps<T> | TableNonVirtualizedProps<T>;
|
|
83
|
+
/**
|
|
84
|
+
* Table is a high-performance data table component with support for
|
|
85
|
+
* virtual scrolling, column resizing, fixed columns, row selection,
|
|
86
|
+
* sorting, expandable rows, and drag-and-drop row reordering.
|
|
87
|
+
*/
|
|
88
|
+
export declare const Table: <T extends TableDataSource = TableDataSource>(props: TableProps<T> & {
|
|
89
|
+
ref?: React.ForwardedRef<HTMLDivElement>;
|
|
90
|
+
}) => React.ReactElement;
|
|
110
91
|
export default Table;
|