@mezzanine-ui/react 0.12.4 → 0.12.6
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/AppBar/AppBar.d.ts +2 -2
- package/AppBar/AppBarBrand.d.ts +1 -1
- package/AppBar/AppBarMain.d.ts +1 -1
- package/AppBar/AppBarSupport.d.ts +1 -1
- package/Badge/BadgeContainer.d.ts +1 -1
- package/Button/Button.d.ts +1 -1
- package/Button/ButtonGroup.d.ts +1 -1
- package/Button/IconButton.d.ts +1 -1
- package/Button/index.d.ts +2 -2
- package/Button/index.js +1 -2
- package/Button/typings.d.ts +1 -1
- package/Calendar/CalendarCell.d.ts +1 -2
- package/Calendar/CalendarContext.d.ts +2 -2
- package/Calendar/CalendarControls.d.ts +1 -2
- package/Calendar/CalendarDayOfWeek.d.ts +1 -2
- package/Calendar/CalendarDays.d.ts +1 -2
- package/Calendar/CalendarMonths.d.ts +1 -2
- package/Calendar/CalendarWeeks.d.ts +1 -2
- package/Calendar/CalendarYears.d.ts +1 -2
- package/Calendar/useCalendarControlModifiers.d.ts +2 -2
- package/Form/FormMessage.d.ts +1 -1
- package/Form/typings.d.ts +1 -1
- package/Form/useAutoCompleteValueControl.d.ts +5 -5
- package/Form/useInputWithTagsModeValue.d.ts +1 -1
- package/Form/useSelectValueControl.d.ts +6 -6
- package/Menu/MenuDivider.d.ts +1 -1
- package/Message/Message.d.ts +1 -1
- package/Modal/ModalActions.js +2 -1
- package/Modal/ModalBody.d.ts +1 -1
- package/Modal/ModalFooter.d.ts +1 -1
- package/Navigation/Navigation.d.ts +2 -2
- package/Navigation/NavigationSubMenu.d.ts +2 -2
- package/Notifier/NotifierManager.d.ts +1 -1
- package/Notifier/typings.d.ts +1 -1
- package/Pagination/Pagination.d.ts +1 -1
- package/Pagination/PaginationItem.d.ts +1 -1
- package/Pagination/PaginationJumper.d.ts +1 -1
- package/Pagination/PaginationPageSize.d.ts +1 -1
- package/Picker/usePickerValue.d.ts +1 -1
- package/Popper/Popper.d.ts +2 -2
- package/Select/AutoComplete.d.ts +3 -3
- package/Select/Select.d.ts +3 -3
- package/Select/SelectTrigger.d.ts +5 -5
- package/Slider/Slider.d.ts +4 -4
- package/Table/Table.d.ts +1 -1
- package/Table/editable/TableEditRenderWrapper.d.ts +1 -2
- package/Table/sorting/useTableSorting.d.ts +1 -1
- package/Table/useTableScroll.d.ts +5 -1
- package/Tabs/Tabs.d.ts +1 -1
- package/Transition/Fade.d.ts +1 -1
- package/Transition/SlideFade.d.ts +1 -1
- package/Transition/Transition.d.ts +7 -7
- package/Transition/Zoom.d.ts +1 -1
- package/Tree/TreeNode.d.ts +1 -1
- package/Tree/TreeNodeList.d.ts +1 -1
- package/Tree/typings.d.ts +7 -7
- package/Typography/Typography.d.ts +2 -2
- package/Typography/index.d.ts +1 -1
- package/Typography/index.js +4 -1
- package/Upload/UploadPicture.d.ts +3 -2
- package/Upload/UploadPicture.js +2 -2
- package/Upload/UploadPictureBlock.d.ts +6 -0
- package/Upload/UploadPictureBlock.js +3 -3
- package/Upload/UploadPictureWall.d.ts +4 -3
- package/Upload/UploadPictureWall.js +2 -2
- package/Upload/UploadPictureWallItem.d.ts +3 -2
- package/Upload/UploadPictureWallItem.js +2 -2
- package/hooks/useClickAway.d.ts +3 -3
- package/hooks/useDocumentEscapeKeyDown.d.ts +1 -1
- package/hooks/useDocumentEvents.d.ts +1 -1
- package/hooks/useDocumentTabKeyDown.d.ts +1 -1
- package/package.json +4 -4
- package/utils/composeRefs.d.ts +2 -2
- package/utils/general.d.ts +2 -2
- package/utils/getElement.d.ts +1 -1
- package/utils/jsx-types.d.ts +5 -5
|
@@ -2,7 +2,7 @@ import { Ref } from 'react';
|
|
|
2
2
|
import { TextFieldProps } from '../TextField';
|
|
3
3
|
import { SelectValue } from './typings';
|
|
4
4
|
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
5
|
-
export
|
|
5
|
+
export type SelectTriggerInputProps = Omit<NativeElementPropsWithoutKeyAndRef<'input'>, 'autoComplete' | 'children' | 'defaultValue' | 'disabled' | 'readOnly' | 'required' | 'type' | 'value' | `aria-${'autocomplete' | 'disabled' | 'haspopup' | 'multiline' | 'readonly' | 'required'}`>;
|
|
6
6
|
export interface SelectTriggerBaseProps extends Omit<TextFieldProps, 'active' | 'children' | 'defaultChecked' | 'suffix'> {
|
|
7
7
|
/**
|
|
8
8
|
* Controls the chevron icon layout.
|
|
@@ -51,7 +51,7 @@ export interface SelectTriggerBaseProps extends Omit<TextFieldProps, 'active' |
|
|
|
51
51
|
showTextInputAfterTags?: boolean;
|
|
52
52
|
suffixAction?: VoidFunction;
|
|
53
53
|
}
|
|
54
|
-
export
|
|
54
|
+
export type SelectTriggerMultipleProps = SelectTriggerBaseProps & {
|
|
55
55
|
/**
|
|
56
56
|
* Controls the layout of trigger.
|
|
57
57
|
*/
|
|
@@ -67,7 +67,7 @@ export declare type SelectTriggerMultipleProps = SelectTriggerBaseProps & {
|
|
|
67
67
|
*/
|
|
68
68
|
renderValue?: (value: SelectValue[]) => string;
|
|
69
69
|
};
|
|
70
|
-
export
|
|
70
|
+
export type SelectTriggerSingleProps = SelectTriggerBaseProps & {
|
|
71
71
|
/**
|
|
72
72
|
* Controls the layout of trigger.
|
|
73
73
|
*/
|
|
@@ -83,7 +83,7 @@ export declare type SelectTriggerSingleProps = SelectTriggerBaseProps & {
|
|
|
83
83
|
*/
|
|
84
84
|
renderValue?: (value: SelectValue | null) => string;
|
|
85
85
|
};
|
|
86
|
-
export
|
|
87
|
-
export
|
|
86
|
+
export type SelectTriggerComponentProps = SelectTriggerMultipleProps | SelectTriggerSingleProps;
|
|
87
|
+
export type SelectTriggerProps = Omit<SelectTriggerComponentProps, 'innerRef'>;
|
|
88
88
|
declare const SelectTrigger: import("react").ForwardRefExoticComponent<SelectTriggerProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
89
89
|
export default SelectTrigger;
|
package/Slider/Slider.d.ts
CHANGED
|
@@ -32,16 +32,16 @@ export interface SliderBaseProps extends Omit<NativeElementPropsWithoutKeyAndRef
|
|
|
32
32
|
*/
|
|
33
33
|
innerRef?: Ref<HTMLDivElement>;
|
|
34
34
|
}
|
|
35
|
-
export
|
|
35
|
+
export type SingleSliderProps = SliderBaseProps & {
|
|
36
36
|
onChange?: (value: SingleSliderValue) => void;
|
|
37
37
|
value: UseSingleSliderProps['value'];
|
|
38
38
|
};
|
|
39
|
-
export
|
|
39
|
+
export type RangeSliderProps = SliderBaseProps & {
|
|
40
40
|
onChange?: (value: RangeSliderValue) => void;
|
|
41
41
|
value: UseRangeSliderProps['value'];
|
|
42
42
|
};
|
|
43
|
-
export
|
|
44
|
-
export
|
|
43
|
+
export type SliderComponentProps = SingleSliderProps | RangeSliderProps;
|
|
44
|
+
export type SliderProps = Omit<SliderComponentProps, 'innerRef'>;
|
|
45
45
|
/**
|
|
46
46
|
* The react component for `mezzanine` slider.
|
|
47
47
|
* The outcome will be base on the type of given value.
|
package/Table/Table.d.ts
CHANGED
|
@@ -83,6 +83,6 @@ export interface TableWithPagination<T> extends TableBaseProps<T> {
|
|
|
83
83
|
pagination?: TablePaginationType;
|
|
84
84
|
fetchMore?: undefined;
|
|
85
85
|
}
|
|
86
|
-
export
|
|
86
|
+
export type TableProps<T> = TableWithFetchMore<T> | TableWithPagination<T>;
|
|
87
87
|
declare const Table: import("react").ForwardRefExoticComponent<TableProps<Record<string, unknown>> & import("react").RefAttributes<HTMLDivElement>>;
|
|
88
88
|
export default Table;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { TableColumn, TableDataSource, TableRecord } from '@mezzanine-ui/core/table';
|
|
3
2
|
import { NativeElementPropsWithoutKeyAndRef } from '../../utils/jsx-types';
|
|
4
3
|
export interface EditableBodyCellProps extends NativeElementPropsWithoutKeyAndRef<'div'>, TableColumn<TableRecord<unknown>> {
|
|
5
4
|
rowData: TableDataSource;
|
|
6
5
|
}
|
|
7
|
-
declare function TableEditRenderWrapper({ children, dataIndex, editable, rowData, setCellProps, ...rest }: EditableBodyCellProps): JSX.Element;
|
|
6
|
+
declare function TableEditRenderWrapper({ children, dataIndex, editable, rowData, setCellProps, ...rest }: EditableBodyCellProps): import("react/jsx-runtime").JSX.Element;
|
|
8
7
|
export default TableEditRenderWrapper;
|
|
@@ -2,7 +2,7 @@ import { TableDataSource, TableColumn, TableRecord } from '@mezzanine-ui/core/ta
|
|
|
2
2
|
export interface UseTableSorting {
|
|
3
3
|
dataSource: TableDataSource[];
|
|
4
4
|
}
|
|
5
|
-
export
|
|
5
|
+
export type SortedType = 'desc' | 'asc' | 'none';
|
|
6
6
|
export declare function useTableSorting(props: UseTableSorting): readonly [TableDataSource[], (v: Pick<TableColumn<TableRecord<unknown>>, "dataIndex" | "sorter" | "onSorted">) => void, {
|
|
7
7
|
readonly sortedOn: string;
|
|
8
8
|
readonly sortedType: SortedType;
|
|
@@ -17,6 +17,7 @@ export default function useTableScroll(): readonly [{
|
|
|
17
17
|
suppressContentEditableWarning?: boolean | undefined;
|
|
18
18
|
suppressHydrationWarning?: boolean | undefined;
|
|
19
19
|
accessKey?: string | undefined;
|
|
20
|
+
autoFocus?: boolean | undefined;
|
|
20
21
|
className?: string | undefined;
|
|
21
22
|
contentEditable?: (boolean | "true" | "false") | "inherit" | undefined;
|
|
22
23
|
contextMenu?: string | undefined;
|
|
@@ -36,11 +37,14 @@ export default function useTableScroll(): readonly [{
|
|
|
36
37
|
radioGroup?: string | undefined;
|
|
37
38
|
role?: import("react").AriaRole | undefined;
|
|
38
39
|
about?: string | undefined;
|
|
40
|
+
content?: string | undefined;
|
|
39
41
|
datatype?: string | undefined;
|
|
40
42
|
inlist?: any;
|
|
41
43
|
prefix?: string | undefined;
|
|
42
44
|
property?: string | undefined;
|
|
45
|
+
rel?: string | undefined;
|
|
43
46
|
resource?: string | undefined;
|
|
47
|
+
rev?: string | undefined;
|
|
44
48
|
typeof?: string | undefined;
|
|
45
49
|
vocab?: string | undefined;
|
|
46
50
|
autoCapitalize?: string | undefined;
|
|
@@ -107,7 +111,7 @@ export default function useTableScroll(): readonly [{
|
|
|
107
111
|
'aria-valuetext'?: string | undefined;
|
|
108
112
|
children?: import("react").ReactNode;
|
|
109
113
|
dangerouslySetInnerHTML?: {
|
|
110
|
-
__html: string;
|
|
114
|
+
__html: string | TrustedHTML;
|
|
111
115
|
} | undefined;
|
|
112
116
|
onCopy?: import("react").ClipboardEventHandler<HTMLDivElement> | undefined;
|
|
113
117
|
onCopyCapture?: import("react").ClipboardEventHandler<HTMLDivElement> | undefined;
|
package/Tabs/Tabs.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Key, MouseEvent, ReactElement, ReactNode } from 'react';
|
|
2
2
|
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
3
3
|
import { TabPaneProps } from './TabPane';
|
|
4
|
-
export
|
|
4
|
+
export type TabsChild = ReactElement<TabPaneProps>;
|
|
5
5
|
export interface TabsProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'onChange' | 'children'> {
|
|
6
6
|
/**
|
|
7
7
|
* Current TabPane's index
|
package/Transition/Fade.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TransitionImplementationProps } from './Transition';
|
|
3
|
-
export
|
|
3
|
+
export type FadeProps = TransitionImplementationProps;
|
|
4
4
|
/**
|
|
5
5
|
* The react component for `mezzanine` transition fade.
|
|
6
6
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TransitionImplementationProps } from './Transition';
|
|
3
|
-
export
|
|
3
|
+
export type SlideFadeDirection = 'left' | 'right' | 'up' | 'down';
|
|
4
4
|
export interface SlideFadeProps extends TransitionImplementationProps {
|
|
5
5
|
/**
|
|
6
6
|
* The direction of child element will enter to.
|
|
@@ -2,18 +2,18 @@ import { RefObject, CSSProperties, ReactElement, JSXElementConstructor, Ref } fr
|
|
|
2
2
|
import { TransitionStatus as TransitionState, TransitionChildren } from 'react-transition-group/Transition';
|
|
3
3
|
import { NativeElementTag } from '../utils/jsx-types';
|
|
4
4
|
export { TransitionState };
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type TransitionMode = 'enter' | 'exit';
|
|
6
|
+
export type TransitionDuration = 'auto' | number | {
|
|
7
7
|
[mode in TransitionMode]?: number;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type TransitionEasing = string | {
|
|
10
10
|
[mode in TransitionMode]?: string;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type TransitionDelay = number | {
|
|
13
13
|
[mode in TransitionMode]?: number;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
16
|
-
export
|
|
15
|
+
export type TransitionEnterHandler = (node: HTMLElement, isAppearing: boolean) => void;
|
|
16
|
+
export type TransitionExitHandler = (node: HTMLElement) => void;
|
|
17
17
|
export interface TransitionImplementationChildProps {
|
|
18
18
|
ref?: Ref<HTMLElement>;
|
|
19
19
|
style?: CSSProperties;
|
|
@@ -94,5 +94,5 @@ export interface TransitionImplementationProps extends Omit<TransitionProps, 'ad
|
|
|
94
94
|
/**
|
|
95
95
|
* The react component for `mezzanine` transition.
|
|
96
96
|
*/
|
|
97
|
-
declare function Transition(props: TransitionProps): JSX.Element;
|
|
97
|
+
declare function Transition(props: TransitionProps): import("react/jsx-runtime").JSX.Element;
|
|
98
98
|
export default Transition;
|
package/Transition/Zoom.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TransitionImplementationProps } from './Transition';
|
|
3
|
-
export
|
|
3
|
+
export type ZoomProps = TransitionImplementationProps;
|
|
4
4
|
/**
|
|
5
5
|
* The react component for `mezzanine` transition zoom.
|
|
6
6
|
*/
|
package/Tree/TreeNode.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { TreeNodeValue, TreeSize } from '@mezzanine-ui/core/tree';
|
|
|
3
3
|
import { CollapseProps } from '../Transition';
|
|
4
4
|
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
5
5
|
import { TreeNodeData } from './typings';
|
|
6
|
-
export
|
|
6
|
+
export type TreeNodeElementProps = Omit<NativeElementPropsWithoutKeyAndRef<'li'>, 'children' | 'value' | 'onSelect'>;
|
|
7
7
|
export interface TreeNodeProps extends TreeNodeData, TreeNodeElementProps {
|
|
8
8
|
/**
|
|
9
9
|
* Provided children will be wrapped under `Collapse`.
|
package/Tree/TreeNodeList.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
3
3
|
import { TreeNodeElementProps, TreeNodeProps } from './TreeNode';
|
|
4
4
|
import { TreeNodeData, TreeNodeRefs } from './typings';
|
|
5
|
-
export
|
|
5
|
+
export type TreeNodeListElementProps = Omit<NativeElementPropsWithoutKeyAndRef<'ul'>, 'children' | 'onSelect'>;
|
|
6
6
|
export interface TreeNodeListProps extends TreeNodeListElementProps, Pick<TreeNodeProps, 'multiple' | 'onExpand' | 'onSelect' | 'selectable' | 'size'> {
|
|
7
7
|
/**
|
|
8
8
|
* Given nodes will be passed to `TreeNode` component orderly.
|
package/Tree/typings.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { MutableRefObject, ReactNode } from 'react';
|
|
2
2
|
import { TreeNodeDataShape, TreeNodeEntityShape, TreeNodePropShape, TreeNodeValue } from '@mezzanine-ui/core/tree';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
3
|
+
export type TreeNodeProp = TreeNodePropShape<ReactNode>;
|
|
4
|
+
export type TreeNodeData = TreeNodeDataShape<ReactNode>;
|
|
5
|
+
export type TreeNodeEntity = TreeNodeEntityShape<ReactNode>;
|
|
6
|
+
export type TreeNodeEntities = Map<TreeNodeValue, TreeNodeEntity>;
|
|
7
|
+
export type TreeNodeRefsShape = Record<TreeNodeValue, HTMLLIElement>;
|
|
8
|
+
export type TreeNodeRefs = MutableRefObject<TreeNodeRefsShape | undefined>;
|
|
9
|
+
export type TreeExpandControl = {
|
|
10
10
|
collapse: (value: TreeNodeValue) => void;
|
|
11
11
|
collapseAll: () => void;
|
|
12
12
|
collapseAllFrom: (value: TreeNodeValue) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JSXElementConstructor } from 'react';
|
|
2
2
|
import { TypographyAlign, TypographyColor, TypographyDisplay, TypographyVariant } from '@mezzanine-ui/core/typography';
|
|
3
3
|
import { ComponentOverridableForwardRefComponentPropsFactory } from '../utils/jsx-types';
|
|
4
|
-
export
|
|
4
|
+
export type TypographyComponent = `h${1 | 2 | 3 | 4 | 5 | 6}` | 'p' | 'span' | 'label' | 'div' | 'caption' | 'a' | JSXElementConstructor<any>;
|
|
5
5
|
interface TypographyPropsBase {
|
|
6
6
|
/**
|
|
7
7
|
* The css variable for `text-align`.
|
|
@@ -33,7 +33,7 @@ interface TypographyPropsBase {
|
|
|
33
33
|
*/
|
|
34
34
|
variant?: TypographyVariant;
|
|
35
35
|
}
|
|
36
|
-
export
|
|
36
|
+
export type TypographyProps<C extends TypographyComponent = 'p'> = ComponentOverridableForwardRefComponentPropsFactory<TypographyComponent, C, TypographyPropsBase>;
|
|
37
37
|
/**
|
|
38
38
|
* The react component for `mezzanine` typography.
|
|
39
39
|
*/
|
package/Typography/index.d.ts
CHANGED
|
@@ -6,6 +6,6 @@ export type { TypographyComponent, TypographyProps, };
|
|
|
6
6
|
* @remark
|
|
7
7
|
* Add type alias here for parsable to react docgen typescript.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
type GenericTypography = <C extends TypographyComponent = 'p'>(props: PropsWithoutRef<TypographyProps<C>> & RefAttributes<ElementRef<C>>) => ReactElement;
|
|
10
10
|
declare const _default: GenericTypography;
|
|
11
11
|
export default _default;
|
package/Typography/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Ref } from 'react';
|
|
2
2
|
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
3
|
-
|
|
3
|
+
import { UploadPictureBlockProps } from './UploadPictureBlock';
|
|
4
|
+
export type UploadPictureControl = {
|
|
4
5
|
getData: () => void;
|
|
5
6
|
};
|
|
6
|
-
export interface UploadPictureProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'children' | 'onChange' | 'onError' | 'value'> {
|
|
7
|
+
export interface UploadPictureProps extends Pick<UploadPictureBlockProps, 'defaultUploadErrorLabel' | 'defaultUploadingLabel' | 'defaultUploadLabel'>, Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'children' | 'onChange' | 'onError' | 'value'> {
|
|
7
8
|
/**
|
|
8
9
|
* The accept attributes of native input element.
|
|
9
10
|
* @default 'image/*'
|
package/Upload/UploadPicture.js
CHANGED
|
@@ -5,7 +5,7 @@ import UploadPictureBlock from './UploadPictureBlock.js';
|
|
|
5
5
|
import cx from 'clsx';
|
|
6
6
|
|
|
7
7
|
const UploadPicture = forwardRef(function UploadPicture(props, ref) {
|
|
8
|
-
const { accept = 'image/*', className, controllerRef, defaultValue, disabled = false, onChange, onDelete, onError, onUpload, onUploadSuccess, style, } = props;
|
|
8
|
+
const { accept = 'image/*', className, controllerRef, defaultValue, defaultUploadErrorLabel, defaultUploadingLabel, defaultUploadLabel, disabled = false, onChange, onDelete, onError, onUpload, onUploadSuccess, style, } = props;
|
|
9
9
|
const defaultImageUploader = new ImageUploader(undefined, defaultValue);
|
|
10
10
|
const uploadPictureImageLoader = useRef(defaultImageUploader);
|
|
11
11
|
const onImageUpload = useCallback((files) => {
|
|
@@ -45,7 +45,7 @@ const UploadPicture = forwardRef(function UploadPicture(props, ref) {
|
|
|
45
45
|
useImperativeHandle(controllerRef, () => ({
|
|
46
46
|
getData: () => uploadPictureImageLoader.current.getAll(),
|
|
47
47
|
}));
|
|
48
|
-
return (jsx("div", { ref: ref, className: cx(uploadPictureClasses.host, className), style: style, children: jsx(UploadPictureBlock, { accept: accept, disabled: disabled, imageLoader: uploadPictureImageLoader.current, multiple: false, onDelete: onImageDelete, onUpload: onImageUpload, onValueChange: onChange }) }));
|
|
48
|
+
return (jsx("div", { ref: ref, className: cx(uploadPictureClasses.host, className), style: style, children: jsx(UploadPictureBlock, { accept: accept, defaultUploadErrorLabel: defaultUploadErrorLabel, defaultUploadingLabel: defaultUploadingLabel, defaultUploadLabel: defaultUploadLabel, disabled: disabled, imageLoader: uploadPictureImageLoader.current, multiple: false, onDelete: onImageDelete, onUpload: onImageUpload, onValueChange: onChange }) }));
|
|
49
49
|
});
|
|
50
50
|
var UploadPicture$1 = UploadPicture;
|
|
51
51
|
|
|
@@ -3,6 +3,12 @@ import { ImageUploader } from '@mezzanine-ui/core/upload';
|
|
|
3
3
|
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
4
4
|
export interface UploadPictureBlockProps extends Omit<NativeElementPropsWithoutKeyAndRef<'button'>, 'children' | 'onChange' | 'value'> {
|
|
5
5
|
accept?: string;
|
|
6
|
+
/** @default '上傳錯誤' */
|
|
7
|
+
defaultUploadErrorLabel?: string;
|
|
8
|
+
/** @default '上傳中...' */
|
|
9
|
+
defaultUploadingLabel?: string;
|
|
10
|
+
/** @default '上傳影像' */
|
|
11
|
+
defaultUploadLabel?: string;
|
|
6
12
|
fileHost?: string;
|
|
7
13
|
imageLoader: ImageUploader;
|
|
8
14
|
multiple?: boolean;
|
|
@@ -8,7 +8,7 @@ import Icon from '../Icon/Icon.js';
|
|
|
8
8
|
import cx from 'clsx';
|
|
9
9
|
|
|
10
10
|
const UploadPictureBlock = forwardRef(function UploadPictureBlock(props, ref) {
|
|
11
|
-
const { accept = 'image/*', disabled = false, imageLoader, multiple = false, onDelete, onUpload, onValueChange, fileHost, } = props;
|
|
11
|
+
const { accept = 'image/*', defaultUploadErrorLabel = '上傳錯誤', defaultUploadingLabel = '上傳中...', defaultUploadLabel = '上傳影像', disabled = false, imageLoader, multiple = false, onDelete, onUpload, onValueChange, fileHost, } = props;
|
|
12
12
|
const [previewImage, setPreviewImage] = useState(imageLoader.getPreview() || '');
|
|
13
13
|
const [value, setValue] = useState(imageLoader.getUrl() || '');
|
|
14
14
|
const [percentage, setPercentage] = useState(imageLoader.getPercentage() || 0);
|
|
@@ -73,9 +73,9 @@ const UploadPictureBlock = forwardRef(function UploadPictureBlock(props, ref) {
|
|
|
73
73
|
[uploadPictureBlockClasses.loading]: isLoading,
|
|
74
74
|
[uploadPictureBlockClasses.error]: isError,
|
|
75
75
|
[uploadPictureBlockClasses.disabled]: disabled,
|
|
76
|
-
}), style: style, children: [jsx(UploadInput, { ref: inputRef, accept: accept, disabled: disabled, multiple: multiple, onUpload: onUpload }), isError ? (jsxs("div", { className: uploadPictureBlockClasses.group, children: [jsx(Icon, { icon: TimesIcon }), jsx("span", { className: uploadPictureBlockClasses.status, children:
|
|
76
|
+
}), style: style, children: [jsx(UploadInput, { ref: inputRef, accept: accept, disabled: disabled, multiple: multiple, onUpload: onUpload }), isError ? (jsxs("div", { className: uploadPictureBlockClasses.group, children: [jsx(Icon, { icon: TimesIcon }), jsx("span", { className: uploadPictureBlockClasses.status, children: defaultUploadErrorLabel })] })) : (
|
|
77
77
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
78
|
-
jsx(Fragment, { children: showImage ? (jsxs(Fragment, { children: [jsx("img", { alt: "", src: (value ? `${fileHost || ''}${value}` : previewImage), className: uploadPictureBlockClasses.preview }), isLoading ? (jsxs("div", { className: uploadPictureBlockClasses.group, children: [jsx(Icon, { icon: SpinnerIcon, spin: true }), jsx("span", { className: uploadPictureBlockClasses.status, children:
|
|
78
|
+
jsx(Fragment, { children: showImage ? (jsxs(Fragment, { children: [jsx("img", { alt: "", src: (value ? `${fileHost || ''}${value}` : previewImage), className: uploadPictureBlockClasses.preview }), isLoading ? (jsxs("div", { className: uploadPictureBlockClasses.group, children: [jsx(Icon, { icon: SpinnerIcon, spin: true }), jsx("span", { className: uploadPictureBlockClasses.status, children: defaultUploadingLabel })] })) : null] })) : (jsxs("div", { className: uploadPictureBlockClasses.group, children: [jsx(Icon, { icon: UploadIcon }), jsx("span", { className: uploadPictureBlockClasses.status, children: defaultUploadLabel })] })) })), !disabled && canDeleteImage && (jsx("div", { className: uploadPictureBlockClasses.delete, children: jsx(Icon, { icon: TrashIcon }) }))] }));
|
|
79
79
|
});
|
|
80
80
|
var UploadPictureBlock$1 = UploadPictureBlock;
|
|
81
81
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Ref } from 'react';
|
|
2
2
|
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
3
|
-
|
|
3
|
+
import { UploadPictureWallItemProps } from './UploadPictureWallItem';
|
|
4
|
+
export type UploadPictureWallControl = {
|
|
4
5
|
getAllData: () => void;
|
|
5
6
|
};
|
|
6
|
-
export interface UploadPictureWallBaseProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'children' | 'onChange' | 'onError' | 'value'> {
|
|
7
|
+
export interface UploadPictureWallBaseProps extends Pick<UploadPictureWallItemProps, 'defaultUploadErrorLabel' | 'defaultUploadingLabel' | 'defaultUploadLabel'>, Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'children' | 'onChange' | 'onError' | 'value'> {
|
|
7
8
|
/**
|
|
8
9
|
* The accept attributes of native input element.
|
|
9
10
|
* @default 'image/*'
|
|
@@ -75,6 +76,6 @@ export interface UploadPictureWallMultiUploadProps extends UploadPictureWallBase
|
|
|
75
76
|
onUpload?: undefined;
|
|
76
77
|
parallel?: undefined;
|
|
77
78
|
}
|
|
78
|
-
export
|
|
79
|
+
export type UploadPictureWallProps = UploadPictureWallSingleUploadProps | UploadPictureWallMultiUploadProps;
|
|
79
80
|
declare const UploadPictureWall: import("react").ForwardRefExoticComponent<UploadPictureWallProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
80
81
|
export default UploadPictureWall;
|
|
@@ -9,7 +9,7 @@ import UploadPictureWallItem from './UploadPictureWallItem.js';
|
|
|
9
9
|
import cx from 'clsx';
|
|
10
10
|
|
|
11
11
|
const UploadPictureWall = forwardRef(function UploadPictureWall(props, ref) {
|
|
12
|
-
const { accept = 'image/*', className, controllerRef, defaultValues, disabled = false, fileHost = '', maxLength, multiple = true, onChange, onDelete, onError, onMultiUpload, onUpload, onUploadSuccess, parallel = false, style, } = props;
|
|
12
|
+
const { accept = 'image/*', className, controllerRef, defaultValues, defaultUploadErrorLabel, defaultUploadingLabel, defaultUploadLabel, disabled = false, fileHost = '', maxLength, multiple = true, onChange, onDelete, onError, onMultiUpload, onUpload, onUploadSuccess, parallel = false, style, } = props;
|
|
13
13
|
const [uploadPictureImageLoaders, setUploadPictureImageLoader] = useState(defaultValues ? compact(defaultValues).map((value) => new ImageUploader(undefined, value)) : []);
|
|
14
14
|
const [needUploadImageLoaders, setNeedUploadImageLoaders] = useState([]);
|
|
15
15
|
const [needUploadImageLoaderSets, setNeedUploadImageLoaderSets] = useState([]);
|
|
@@ -150,7 +150,7 @@ const UploadPictureWall = forwardRef(function UploadPictureWall(props, ref) {
|
|
|
150
150
|
useImperativeHandle(controllerRef, () => ({
|
|
151
151
|
getAllData: () => uploadPictureImageLoaders.map((loader) => loader.getAll()),
|
|
152
152
|
}));
|
|
153
|
-
return (jsxs("div", { ref: ref, className: cx(uploadPictureWallClasses.host, className), style: style, children: [loaderList.map((up) => (jsx(UploadPictureWallItem, { accept: accept, disabled: disabled, imageLoader: up, multiple: multiple, onDelete: () => onImageDelete(up.getUid()), fileHost: fileHost }, up.getUid()))), maxLength && loaderList.length >= maxLength ? null : (jsx(UploadPictureWallItem, { accept: accept, disabled: disabled, imageLoader: new ImageUploader(), multiple: multiple, onUpload: onImagesUpload, fileHost: fileHost }))] }));
|
|
153
|
+
return (jsxs("div", { ref: ref, className: cx(uploadPictureWallClasses.host, className), style: style, children: [loaderList.map((up) => (jsx(UploadPictureWallItem, { accept: accept, defaultUploadErrorLabel: defaultUploadErrorLabel, defaultUploadingLabel: defaultUploadingLabel, defaultUploadLabel: defaultUploadLabel, disabled: disabled, imageLoader: up, multiple: multiple, onDelete: () => onImageDelete(up.getUid()), fileHost: fileHost }, up.getUid()))), maxLength && loaderList.length >= maxLength ? null : (jsx(UploadPictureWallItem, { accept: accept, defaultUploadErrorLabel: defaultUploadErrorLabel, defaultUploadingLabel: defaultUploadingLabel, defaultUploadLabel: defaultUploadLabel, disabled: disabled, imageLoader: new ImageUploader(), multiple: multiple, onUpload: onImagesUpload, fileHost: fileHost }))] }));
|
|
154
154
|
});
|
|
155
155
|
var UploadPictureWall$1 = UploadPictureWall;
|
|
156
156
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { MouseEventHandler } from 'react';
|
|
2
2
|
import { ImageUploader } from '@mezzanine-ui/core/upload';
|
|
3
3
|
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
4
|
-
|
|
4
|
+
import { UploadPictureBlockProps } from './UploadPictureBlock';
|
|
5
|
+
export interface UploadPictureWallItemProps extends Pick<UploadPictureBlockProps, 'defaultUploadErrorLabel' | 'defaultUploadingLabel' | 'defaultUploadLabel'>, Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'value' | 'onChange' | 'children'> {
|
|
5
6
|
accept?: string;
|
|
6
7
|
disabled?: boolean;
|
|
7
8
|
fileHost?: string;
|
|
@@ -10,5 +11,5 @@ export interface UploadPictureWallItemProps extends Omit<NativeElementPropsWitho
|
|
|
10
11
|
onDelete?: MouseEventHandler;
|
|
11
12
|
onUpload?: (files: File[]) => void;
|
|
12
13
|
}
|
|
13
|
-
declare const UploadPictureWallItem: (props: UploadPictureWallItemProps) => JSX.Element;
|
|
14
|
+
declare const UploadPictureWallItem: (props: UploadPictureWallItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
15
|
export default UploadPictureWallItem;
|
|
@@ -5,14 +5,14 @@ import UploadPictureBlock from './UploadPictureBlock.js';
|
|
|
5
5
|
import cx from 'clsx';
|
|
6
6
|
|
|
7
7
|
const UploadPictureWallItem = (props) => {
|
|
8
|
-
const { accept, disabled, imageLoader, multiple, onDelete, onUpload, fileHost, } = props;
|
|
8
|
+
const { accept, defaultUploadErrorLabel, defaultUploadingLabel, defaultUploadLabel, disabled, imageLoader, multiple, onDelete, onUpload, fileHost, } = props;
|
|
9
9
|
const loader = useRef(imageLoader);
|
|
10
10
|
useEffect(() => {
|
|
11
11
|
if (!loader.current.getPreview()) {
|
|
12
12
|
loader.current.setPreview();
|
|
13
13
|
}
|
|
14
14
|
}, []);
|
|
15
|
-
return (jsx("div", { className: cx(uploadPictureWallClasses.item), children: jsx(UploadPictureBlock, { accept: accept, disabled: disabled, imageLoader: loader.current, multiple: multiple, onDelete: onDelete, onUpload: onUpload, fileHost: fileHost }) }));
|
|
15
|
+
return (jsx("div", { className: cx(uploadPictureWallClasses.item), children: jsx(UploadPictureBlock, { accept: accept, defaultUploadErrorLabel: defaultUploadErrorLabel, defaultUploadingLabel: defaultUploadingLabel, defaultUploadLabel: defaultUploadLabel, disabled: disabled, imageLoader: loader.current, multiple: multiple, onDelete: onDelete, onUpload: onUpload, fileHost: fileHost }) }));
|
|
16
16
|
};
|
|
17
17
|
var UploadPictureWallItem$1 = UploadPictureWallItem;
|
|
18
18
|
|
package/hooks/useClickAway.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RefObject, DependencyList } from 'react';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
2
|
+
export type ClickAwayEvent = MouseEvent | TouchEvent | PointerEvent;
|
|
3
|
+
export type ClickAwayHandler = (event: ClickAwayEvent) => void;
|
|
4
|
+
export type ClickAwayHandlerFactory = () => ClickAwayHandler | undefined;
|
|
5
5
|
export declare function useClickAway(factory: ClickAwayHandlerFactory, containerRef: RefObject<HTMLElement>, deps?: DependencyList): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DependencyList } from 'react';
|
|
2
|
-
export
|
|
2
|
+
export type DocumentEscapeKeyDownHandlerFactory = () => ((event: KeyboardEvent) => void) | undefined;
|
|
3
3
|
export declare function useDocumentEscapeKeyDown(factory: DocumentEscapeKeyDownHandlerFactory, deps?: DependencyList): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DependencyList } from 'react';
|
|
2
|
-
export
|
|
2
|
+
export type DocumentEventHandlersFactory = () => {
|
|
3
3
|
[event in keyof DocumentEventMap]?: (event: DocumentEventMap[event]) => void;
|
|
4
4
|
} | undefined;
|
|
5
5
|
export declare function useDocumentEvents(factory: DocumentEventHandlersFactory, deps?: DependencyList): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DependencyList } from 'react';
|
|
2
|
-
export
|
|
2
|
+
export type DocumentTabKeyDownHandlerFactory = () => ((event: KeyboardEvent) => void) | undefined;
|
|
3
3
|
export declare function useDocumentTabKeyDown(factory: DocumentTabKeyDownHandlerFactory, deps?: DependencyList): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mezzanine-ui/react",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.6",
|
|
4
4
|
"description": "React components for mezzanine-ui",
|
|
5
5
|
"author": "Mezzanine",
|
|
6
6
|
"repository": {
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"react-dom": "^18.2.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@mezzanine-ui/core": "^0.12.
|
|
35
|
-
"@mezzanine-ui/icons": "^0.12.
|
|
36
|
-
"@mezzanine-ui/system": "^0.12.
|
|
34
|
+
"@mezzanine-ui/core": "^0.12.6",
|
|
35
|
+
"@mezzanine-ui/icons": "^0.12.6",
|
|
36
|
+
"@mezzanine-ui/system": "^0.12.6",
|
|
37
37
|
"@popperjs/core": "^2.11.6",
|
|
38
38
|
"@types/react-transition-group": "^4.4.5",
|
|
39
39
|
"clsx": "^1.2.1",
|
package/utils/composeRefs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ref } from 'react';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type ComposableRef<T> = Ref<T> | null | undefined;
|
|
3
|
+
export type ComposedRef<T> = Extract<Ref<T>, (...args: any[]) => any>;
|
|
4
4
|
/**
|
|
5
5
|
* Compose all refs to single one.
|
|
6
6
|
* It's helpful if you want to use useRef in an forwardRef component.
|
package/utils/general.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type PickRenameMulti<T, R extends {
|
|
2
2
|
[K in keyof R]: K extends keyof T ? PropertyKey : 'Error: key not in T';
|
|
3
3
|
}> = {
|
|
4
4
|
[P in keyof T as P extends keyof R ? R[P] : P]: T[P];
|
|
5
5
|
};
|
|
6
|
-
export
|
|
6
|
+
export type ExtendedProperties<T> = {
|
|
7
7
|
[P in keyof T]: T[P];
|
|
8
8
|
};
|
package/utils/getElement.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
|
-
export
|
|
2
|
+
export type ElementGetter = HTMLElement | (() => HTMLElement) | RefObject<HTMLElement | null> | null;
|
|
3
3
|
export declare function getElement(elementGetter?: ElementGetter): HTMLElement | null;
|
package/utils/jsx-types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef, DetailedHTMLProps, ElementType, JSXElementConstructor, SVGProps } from 'react';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
2
|
+
export type NativeElementTag = keyof JSX.IntrinsicElements;
|
|
3
|
+
export type NativeElementPropsWithoutKeyAndRef<T extends NativeElementTag> = Omit<JSX.IntrinsicElements[T], 'key' | 'ref'>;
|
|
4
|
+
export type NativeElement<T extends NativeElementTag> = JSX.IntrinsicElements[T] extends DetailedHTMLProps<infer _A, infer E> ? E : JSX.IntrinsicElements[T] extends SVGProps<infer E> ? E : unknown;
|
|
5
|
+
export type ComponentPropsWithoutKeyAndRef<T extends ElementType> = Omit<ComponentPropsWithoutRef<T>, 'key'>;
|
|
6
|
+
export type ComponentOverridableForwardRefComponentPropsFactory<VC extends NativeElementTag | JSXElementConstructor<any>, C extends VC, P> = Omit<Omit<ComponentPropsWithoutKeyAndRef<C>, keyof P> & P, 'component'> & {
|
|
7
7
|
/**
|
|
8
8
|
* Override the component used to render.
|
|
9
9
|
*/
|