@mezzanine-ui/react 1.0.0-beta.6 → 1.0.0-beta.7
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/Accordion/Accordion.d.ts +23 -1
- package/Accordion/Accordion.js +59 -11
- package/Accordion/AccordionActions.d.ts +13 -0
- package/Accordion/AccordionActions.js +24 -0
- package/Accordion/AccordionContent.d.ts +9 -0
- package/Accordion/{AccordionDetails.js → AccordionContent.js} +4 -6
- package/Accordion/AccordionControlContext.d.ts +2 -2
- package/Accordion/AccordionGroup.d.ts +10 -0
- package/Accordion/AccordionGroup.js +26 -0
- package/Accordion/AccordionTitle.d.ts +14 -0
- package/Accordion/AccordionTitle.js +56 -0
- package/Accordion/index.d.ts +8 -4
- package/Accordion/index.js +4 -2
- package/AutoComplete/AutoComplete.d.ts +20 -6
- package/AutoComplete/AutoComplete.js +118 -30
- package/Backdrop/Backdrop.js +15 -19
- package/Calendar/CalendarDays.js +1 -1
- package/Card/BaseCard.d.ts +11 -0
- package/Card/BaseCard.js +48 -0
- package/Card/BaseCardSkeleton.d.ts +14 -0
- package/Card/BaseCardSkeleton.js +18 -0
- package/Card/CardGroup.d.ts +47 -0
- package/Card/CardGroup.js +147 -0
- package/Card/FourThumbnailCard.d.ts +14 -0
- package/Card/FourThumbnailCard.js +73 -0
- package/Card/FourThumbnailCardSkeleton.d.ts +14 -0
- package/Card/FourThumbnailCardSkeleton.js +20 -0
- package/Card/QuickActionCard.d.ts +12 -0
- package/Card/QuickActionCard.js +23 -0
- package/Card/QuickActionCardSkeleton.d.ts +14 -0
- package/Card/QuickActionCardSkeleton.js +18 -0
- package/Card/SingleThumbnailCard.d.ts +13 -0
- package/Card/SingleThumbnailCard.js +44 -0
- package/Card/SingleThumbnailCardSkeleton.d.ts +19 -0
- package/Card/SingleThumbnailCardSkeleton.js +18 -0
- package/Card/Thumbnail.d.ts +12 -0
- package/Card/Thumbnail.js +18 -0
- package/Card/ThumbnailCardInfo.d.ts +34 -0
- package/Card/ThumbnailCardInfo.js +43 -0
- package/Card/index.d.ts +43 -4
- package/Card/index.js +19 -2
- package/Card/typings.d.ts +442 -0
- package/Checkbox/Checkbox.d.ts +8 -0
- package/Checkbox/Checkbox.js +3 -2
- package/Checkbox/CheckboxGroup.js +1 -1
- package/ContentHeader/ContentHeader.d.ts +22 -70
- package/ContentHeader/ContentHeader.js +1 -1
- package/ContentHeader/ContentHeaderResponsive.d.ts +9 -0
- package/ContentHeader/ContentHeaderResponsive.js +7 -0
- package/ContentHeader/utils.d.ts +3 -3
- package/ContentHeader/utils.js +66 -20
- package/Cropper/Cropper.d.ts +66 -0
- package/Cropper/Cropper.js +115 -0
- package/Cropper/CropperElement.d.ts +10 -0
- package/Cropper/CropperElement.js +892 -0
- package/Cropper/index.d.ts +18 -0
- package/Cropper/index.js +8 -0
- package/Cropper/tools.d.ts +90 -0
- package/Cropper/tools.js +143 -0
- package/Cropper/typings.d.ts +69 -0
- package/Cropper/utils/cropper-calculations.d.ts +39 -0
- package/Cropper/utils/cropper-calculations.js +95 -0
- package/DateTimePicker/DateTimePicker.d.ts +1 -1
- package/DateTimePicker/DateTimePicker.js +14 -1
- package/Dropdown/Dropdown.d.ts +7 -1
- package/Dropdown/Dropdown.js +31 -14
- package/Dropdown/DropdownItem.d.ts +7 -1
- package/Dropdown/DropdownItem.js +36 -6
- package/Dropdown/DropdownItemCard.js +2 -1
- package/FloatingButton/FloatingButton.d.ts +21 -0
- package/FloatingButton/FloatingButton.js +18 -0
- package/FloatingButton/index.d.ts +2 -0
- package/FloatingButton/index.js +1 -0
- package/Form/FormField.d.ts +21 -10
- package/Form/FormField.js +12 -4
- package/Input/Input.js +9 -2
- package/Message/Message.js +1 -1
- package/MultipleDatePicker/MultipleDatePicker.js +2 -2
- package/Navigation/NavigationHeader.js +1 -1
- package/Picker/FormattedInput.d.ts +1 -1
- package/Picker/FormattedInput.js +2 -1
- package/Picker/PickerTriggerWithSeparator.d.ts +10 -0
- package/Picker/PickerTriggerWithSeparator.js +2 -2
- package/Picker/useDateInputFormatter.d.ts +6 -0
- package/Picker/useDateInputFormatter.js +4 -1
- package/Select/Select.d.ts +2 -8
- package/Select/Select.js +12 -33
- package/Select/SelectTrigger.js +21 -7
- package/Select/index.d.ts +0 -4
- package/Select/index.js +0 -2
- package/Select/typings.d.ts +0 -4
- package/Select/useSelectTriggerTags.d.ts +1 -1
- package/Select/useSelectTriggerTags.js +9 -6
- package/Separator/Separator.d.ts +14 -0
- package/Separator/Separator.js +17 -0
- package/Separator/index.d.ts +2 -0
- package/Separator/index.js +1 -0
- package/Table/utils/useTableRowSelection.js +6 -0
- package/Tag/TagGroup.d.ts +4 -2
- package/Tag/TagGroup.js +7 -4
- package/TextField/TextField.d.ts +1 -1
- package/TextField/TextField.js +63 -9
- package/TimePanel/TimePanelColumn.js +19 -12
- package/index.d.ts +27 -28
- package/index.js +23 -25
- package/package.json +4 -4
- package/Accordion/AccordionDetails.d.ts +0 -9
- package/Accordion/AccordionSummary.d.ts +0 -18
- package/Accordion/AccordionSummary.js +0 -51
- package/Alert/Alert.d.ts +0 -20
- package/Alert/Alert.js +0 -18
- package/Alert/index.d.ts +0 -3
- package/Alert/index.js +0 -1
- package/Card/Card.d.ts +0 -51
- package/Card/Card.js +0 -20
- package/Card/CardActions.d.ts +0 -34
- package/Card/CardActions.js +0 -15
- package/ConfirmActions/ConfirmActions.d.ts +0 -46
- package/ConfirmActions/ConfirmActions.js +0 -15
- package/ConfirmActions/index.d.ts +0 -2
- package/ConfirmActions/index.js +0 -1
- package/Select/Option.d.ts +0 -18
- package/Select/Option.js +0 -45
- package/Select/TreeSelect.d.ts +0 -72
- package/Select/TreeSelect.js +0 -205
- package/Tree/Tree.d.ts +0 -70
- package/Tree/Tree.js +0 -139
- package/Tree/TreeNode.d.ts +0 -40
- package/Tree/TreeNode.js +0 -50
- package/Tree/TreeNodeList.d.ts +0 -24
- package/Tree/TreeNodeList.js +0 -28
- package/Tree/getTreeNodeEntities.d.ts +0 -11
- package/Tree/getTreeNodeEntities.js +0 -92
- package/Tree/index.d.ts +0 -13
- package/Tree/index.js +0 -7
- package/Tree/toggleValue.d.ts +0 -4
- package/Tree/toggleValue.js +0 -19
- package/Tree/traverseTree.d.ts +0 -2
- package/Tree/traverseTree.js +0 -11
- package/Tree/typings.d.ts +0 -16
- package/Tree/useTreeExpandedValue.d.ts +0 -14
- package/Tree/useTreeExpandedValue.js +0 -33
package/Select/typings.d.ts
CHANGED
|
@@ -7,10 +7,6 @@ export interface SelectValue<T = string> {
|
|
|
7
7
|
id: T;
|
|
8
8
|
name: string;
|
|
9
9
|
}
|
|
10
|
-
export interface TreeSelectOption<T = string> extends SelectValue<T> {
|
|
11
|
-
dynamicChildrenFetching?: boolean;
|
|
12
|
-
siblings?: TreeSelectOption<T>[];
|
|
13
|
-
}
|
|
14
10
|
export interface SelectControl<T = string> {
|
|
15
11
|
value: SelectValue<T>[] | SelectValue<T> | null;
|
|
16
12
|
onChange: (v: SelectValue<T> | null) => SelectValue<T>[] | SelectValue<T> | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useState, useRef, useCallback, useLayoutEffect, useEffect } from 'react';
|
|
3
2
|
import { selectClasses } from '@mezzanine-ui/core/select';
|
|
3
|
+
import { useState, useRef, useCallback, useLayoutEffect, useEffect } from 'react';
|
|
4
4
|
import Tag from '../Tag/Tag.js';
|
|
5
5
|
|
|
6
6
|
const fakeTagClassName = 'mzn-select-trigger__fake-tag';
|
|
@@ -16,22 +16,25 @@ function useSelectTriggerTags(props) {
|
|
|
16
16
|
const { containerRef, tagsRef, value = [], size, enabled = false } = props;
|
|
17
17
|
const [takeCount, setTakeCount] = useState(value.length);
|
|
18
18
|
const fakeContainerRef = useRef(null);
|
|
19
|
+
const updateTakeCount = useCallback((nextCount) => {
|
|
20
|
+
setTakeCount((prevCount) => prevCount === nextCount ? prevCount : nextCount);
|
|
21
|
+
}, []);
|
|
19
22
|
const measure = useCallback(() => {
|
|
20
23
|
var _a, _b;
|
|
21
24
|
if (!enabled) {
|
|
22
|
-
|
|
25
|
+
updateTakeCount(value.length);
|
|
23
26
|
return;
|
|
24
27
|
}
|
|
25
28
|
const container = (_a = containerRef.current) !== null && _a !== void 0 ? _a : tagsRef.current;
|
|
26
29
|
const fakeContainer = fakeContainerRef.current;
|
|
27
30
|
if (!container || !fakeContainer) {
|
|
28
|
-
|
|
31
|
+
// Keep current takeCount when refs are temporarily unavailable to avoid flicker.
|
|
29
32
|
return;
|
|
30
33
|
}
|
|
31
34
|
const fakeTags = Array.from(fakeContainer.getElementsByClassName(fakeTagClassName));
|
|
32
35
|
const fakeEllipsis = fakeContainer.getElementsByClassName(fakeEllipsisClassName)[0];
|
|
33
36
|
if (!fakeTags.length) {
|
|
34
|
-
|
|
37
|
+
// Keep current takeCount until fake tags are ready in DOM.
|
|
35
38
|
return;
|
|
36
39
|
}
|
|
37
40
|
const computedStyleTarget = (_b = tagsRef.current) !== null && _b !== void 0 ? _b : container;
|
|
@@ -56,8 +59,8 @@ function useSelectTriggerTags(props) {
|
|
|
56
59
|
consumedWidth += tagWidth;
|
|
57
60
|
nextCount = i + 1;
|
|
58
61
|
}
|
|
59
|
-
|
|
60
|
-
}, [containerRef, enabled, tagsRef, value.length]);
|
|
62
|
+
updateTakeCount(nextCount);
|
|
63
|
+
}, [containerRef, enabled, tagsRef, updateTakeCount, value.length]);
|
|
61
64
|
useLayoutEffect(() => {
|
|
62
65
|
measure();
|
|
63
66
|
}, [value, size, enabled, measure]);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SeparatorOrientation } from '@mezzanine-ui/core/separator';
|
|
2
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
3
|
+
export interface SeparatorProps extends NativeElementPropsWithoutKeyAndRef<'hr'> {
|
|
4
|
+
/**
|
|
5
|
+
* The orientation of the separator.
|
|
6
|
+
* @default 'horizontal'
|
|
7
|
+
*/
|
|
8
|
+
orientation?: SeparatorOrientation;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The react component for `mezzanine` separator.
|
|
12
|
+
*/
|
|
13
|
+
declare const Separator: import("react").ForwardRefExoticComponent<SeparatorProps & import("react").RefAttributes<HTMLHRElement>>;
|
|
14
|
+
export default Separator;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { separatorClasses } from '@mezzanine-ui/core/separator';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import cx from 'clsx';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The react component for `mezzanine` separator.
|
|
8
|
+
*/
|
|
9
|
+
const Separator = forwardRef(function Separator(props, ref) {
|
|
10
|
+
const { className, orientation = 'horizontal', ...rest } = props;
|
|
11
|
+
return (jsx("hr", { ...rest, "aria-orientation": orientation === 'vertical' ? 'vertical' : undefined, ref: ref, className: cx(separatorClasses.host, {
|
|
12
|
+
[separatorClasses.horizontal]: orientation === 'horizontal',
|
|
13
|
+
[separatorClasses.vertical]: orientation === 'vertical',
|
|
14
|
+
}, className) }));
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export { Separator as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Separator.js';
|
|
@@ -20,6 +20,12 @@ function useTableRowSelection(props) {
|
|
|
20
20
|
? subData.map((subRow) => getRowKey(subRow))
|
|
21
21
|
: undefined;
|
|
22
22
|
}
|
|
23
|
+
if (!selectedRow) {
|
|
24
|
+
// trigger select all or deselect all, need to find subKeys for all selected rows
|
|
25
|
+
return (subData === null || subData === void 0 ? void 0 : subData.length)
|
|
26
|
+
? subData.map((subRow) => getRowKey(subRow))
|
|
27
|
+
: undefined;
|
|
28
|
+
}
|
|
23
29
|
return (_a = prev.find((item) => item.key === pk)) === null || _a === void 0 ? void 0 : _a.subKeys;
|
|
24
30
|
})();
|
|
25
31
|
return {
|
package/Tag/TagGroup.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
3
|
-
import Tag, { TagProps } from '../Tag';
|
|
4
2
|
import OverflowCounterTag, { OverflowCounterTagProps } from '../OverflowTooltip/OverflowCounterTag';
|
|
3
|
+
import Tag, { TagProps } from '../Tag';
|
|
4
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
5
5
|
import { TransitionImplementationChildProps } from '../Transition';
|
|
6
6
|
type TagElement = ReactElement<TagProps & TransitionImplementationChildProps, typeof Tag>;
|
|
7
7
|
type OverflowCounterTagElement = ReactElement<OverflowCounterTagProps & TransitionImplementationChildProps, typeof OverflowCounterTag>;
|
|
8
8
|
type TagGroupChild = TagElement | OverflowCounterTagElement;
|
|
9
9
|
export type TagGroupProps = Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'children'> & {
|
|
10
10
|
children: TagGroupChild | TagGroupChild[];
|
|
11
|
+
transition?: 'fade' | 'none';
|
|
11
12
|
};
|
|
12
13
|
declare const TagGroup: import("react").ForwardRefExoticComponent<Omit<NativeElementPropsWithoutKeyAndRef<"div">, "children"> & {
|
|
13
14
|
children: TagGroupChild | TagGroupChild[];
|
|
15
|
+
transition?: "fade" | "none";
|
|
14
16
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
15
17
|
export default TagGroup;
|
package/Tag/TagGroup.js
CHANGED
|
@@ -2,8 +2,8 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { forwardRef, Children, isValidElement, createElement } from 'react';
|
|
3
3
|
import OverflowCounterTag from '../OverflowTooltip/OverflowCounterTag.js';
|
|
4
4
|
import { tagClasses } from '@mezzanine-ui/core/tag';
|
|
5
|
-
import { TransitionGroup } from 'react-transition-group';
|
|
6
5
|
import { MOTION_EASING, MOTION_DURATION } from '@mezzanine-ui/system/motion';
|
|
6
|
+
import { TransitionGroup } from 'react-transition-group';
|
|
7
7
|
import Fade from '../Transition/Fade.js';
|
|
8
8
|
import Tag from './Tag.js';
|
|
9
9
|
import cx from 'clsx';
|
|
@@ -20,7 +20,7 @@ const fadeProps = {
|
|
|
20
20
|
exit: MOTION_EASING.standard,
|
|
21
21
|
},
|
|
22
22
|
};
|
|
23
|
-
const TagGroup = forwardRef(function TagGroup({ className, children, ...rest }, ref) {
|
|
23
|
+
const TagGroup = forwardRef(function TagGroup({ className, children, transition = 'none', ...rest }, ref) {
|
|
24
24
|
const hasInvalidChild = Children.toArray(children).some((child) => {
|
|
25
25
|
if (!isTagElement(child) && !isOverflowCounterElement(child)) {
|
|
26
26
|
console.error('<TagGroup> only accepts <Tag> or <OverflowCounterTag>');
|
|
@@ -31,11 +31,14 @@ const TagGroup = forwardRef(function TagGroup({ className, children, ...rest },
|
|
|
31
31
|
if (hasInvalidChild) {
|
|
32
32
|
return null;
|
|
33
33
|
}
|
|
34
|
-
return (jsx("div", { ...rest, ref: ref, className: cx(tagClasses.group, className), children: jsx(TransitionGroup, { component: null, children: Children.map(children, (child, index) => {
|
|
34
|
+
return (jsx("div", { ...rest, ref: ref, className: cx(tagClasses.group, className), children: transition === 'fade' ? (jsx(TransitionGroup, { component: null, children: Children.map(children, (child, index) => {
|
|
35
35
|
var _a;
|
|
36
36
|
return (createElement(Fade, { ...fadeProps, key: (_a = child.key) !== null && _a !== void 0 ? _a : index },
|
|
37
37
|
jsx("span", { children: child })));
|
|
38
|
-
}) })
|
|
38
|
+
}) })) : (Children.map(children, (child, index) => {
|
|
39
|
+
var _a;
|
|
40
|
+
return (jsx("span", { children: child }, (_a = child.key) !== null && _a !== void 0 ? _a : index));
|
|
41
|
+
})) }));
|
|
39
42
|
});
|
|
40
43
|
|
|
41
44
|
export { TagGroup as default };
|
package/TextField/TextField.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MouseEventHandler, ReactNode } from 'react';
|
|
2
1
|
import { TextFieldSize } from '@mezzanine-ui/core/text-field';
|
|
2
|
+
import { MouseEventHandler, ReactNode } from 'react';
|
|
3
3
|
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
4
4
|
/**
|
|
5
5
|
* Padding info provided to children function
|
package/TextField/TextField.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { forwardRef, useState, useRef, useEffect } from 'react';
|
|
4
3
|
import { textFieldClasses } from '@mezzanine-ui/core/text-field';
|
|
5
|
-
import {
|
|
4
|
+
import { forwardRef, useState, useRef, useEffect } from 'react';
|
|
6
5
|
import ClearActions from '../ClearActions/ClearActions.js';
|
|
7
6
|
import { useComposeRefs } from '../hooks/useComposeRefs.js';
|
|
7
|
+
import { useTextFieldControl } from './useTextFieldControl.js';
|
|
8
8
|
import cx from 'clsx';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -13,7 +13,11 @@ import cx from 'clsx';
|
|
|
13
13
|
const TextField = forwardRef(function TextField(props, ref) {
|
|
14
14
|
const { active = false, children, className, clearable = false, disabled, error = false, fullWidth = true, onClear, onClick: onClickProps, onKeyDown: onKeyDownProps, prefix, readonly, role: roleProp, size = 'main', suffix, typing: typingProp, warning, ...rest } = props;
|
|
15
15
|
const [isTyping, setIsTyping] = useState(false);
|
|
16
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
17
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
18
|
+
const [hasValue, setHasValue] = useState(false);
|
|
16
19
|
const containerRef = useRef(null);
|
|
20
|
+
const checkValueRef = useRef(null);
|
|
17
21
|
const hostRef = useComposeRefs([ref, containerRef]);
|
|
18
22
|
const typing = disabled || readonly
|
|
19
23
|
? false
|
|
@@ -21,27 +25,67 @@ const TextField = forwardRef(function TextField(props, ref) {
|
|
|
21
25
|
? typingProp
|
|
22
26
|
: isTyping;
|
|
23
27
|
useEffect(() => {
|
|
24
|
-
if (typingProp !== undefined || disabled || readonly)
|
|
25
|
-
return;
|
|
26
28
|
const container = containerRef.current;
|
|
27
29
|
if (!container)
|
|
28
30
|
return;
|
|
29
31
|
const input = container.querySelector('input, textarea');
|
|
30
32
|
if (!input)
|
|
31
33
|
return;
|
|
34
|
+
const checkValue = () => {
|
|
35
|
+
// 檢查值是否為空(包括空字符串和只有空白字符)
|
|
36
|
+
const value = (input.value || '').trim();
|
|
37
|
+
setHasValue(value.length > 0);
|
|
38
|
+
};
|
|
39
|
+
// 保存 checkValue 函數到 ref,以便在 onClear 後可以立即調用
|
|
40
|
+
checkValueRef.current = checkValue;
|
|
32
41
|
const handleInput = () => {
|
|
33
42
|
setIsTyping(true);
|
|
43
|
+
checkValue();
|
|
44
|
+
};
|
|
45
|
+
const handleFocus = () => {
|
|
46
|
+
setIsFocused(true);
|
|
47
|
+
checkValue();
|
|
34
48
|
};
|
|
35
49
|
const handleBlur = () => {
|
|
36
50
|
setIsTyping(false);
|
|
51
|
+
setIsFocused(false);
|
|
52
|
+
checkValue();
|
|
53
|
+
};
|
|
54
|
+
const handleMouseEnter = () => {
|
|
55
|
+
checkValue(); // 在 hover 時也檢查值,確保狀態正確
|
|
56
|
+
setIsHovered(true);
|
|
57
|
+
};
|
|
58
|
+
const handleMouseLeave = () => {
|
|
59
|
+
setIsHovered(false);
|
|
37
60
|
};
|
|
38
|
-
|
|
39
|
-
|
|
61
|
+
// 初始化檢查值
|
|
62
|
+
checkValue();
|
|
63
|
+
// 監聽輸入框事件(用於 typing 狀態)
|
|
64
|
+
if (typingProp === undefined && !disabled && !readonly) {
|
|
65
|
+
input.addEventListener('input', handleInput, false);
|
|
66
|
+
input.addEventListener('mousedown', handleInput, false);
|
|
67
|
+
}
|
|
68
|
+
// 監聽 focus/blur 事件
|
|
69
|
+
input.addEventListener('focus', handleFocus, false);
|
|
40
70
|
input.addEventListener('blur', handleBlur, false);
|
|
71
|
+
// 監聽 hover 事件(在容器上)
|
|
72
|
+
container.addEventListener('mouseenter', handleMouseEnter, false);
|
|
73
|
+
container.addEventListener('mouseleave', handleMouseLeave, false);
|
|
74
|
+
// 監聽值變化(適用於受控組件)
|
|
75
|
+
input.addEventListener('input', checkValue, false);
|
|
76
|
+
input.addEventListener('change', checkValue, false);
|
|
41
77
|
return () => {
|
|
42
|
-
|
|
43
|
-
|
|
78
|
+
if (typingProp === undefined && !disabled && !readonly) {
|
|
79
|
+
input.removeEventListener('input', handleInput, false);
|
|
80
|
+
input.removeEventListener('mousedown', handleInput, false);
|
|
81
|
+
}
|
|
82
|
+
input.removeEventListener('focus', handleFocus, false);
|
|
44
83
|
input.removeEventListener('blur', handleBlur, false);
|
|
84
|
+
container.removeEventListener('mouseenter', handleMouseEnter, false);
|
|
85
|
+
container.removeEventListener('mouseleave', handleMouseLeave, false);
|
|
86
|
+
input.removeEventListener('input', checkValue, false);
|
|
87
|
+
input.removeEventListener('change', checkValue, false);
|
|
88
|
+
checkValueRef.current = null;
|
|
45
89
|
};
|
|
46
90
|
}, [typingProp, disabled, readonly]);
|
|
47
91
|
const { role, onClick, onKeyDown } = useTextFieldControl({
|
|
@@ -49,6 +93,9 @@ const TextField = forwardRef(function TextField(props, ref) {
|
|
|
49
93
|
onKeyDown: onKeyDownProps,
|
|
50
94
|
});
|
|
51
95
|
const isChildrenFunction = typeof children === 'function';
|
|
96
|
+
const shouldShowClearable = clearable &&
|
|
97
|
+
hasValue &&
|
|
98
|
+
(isHovered || typing || isFocused);
|
|
52
99
|
const paddingInfo = {
|
|
53
100
|
paddingClassName: cx(textFieldClasses.inputPadding, size === 'main' ? textFieldClasses.inputPaddingMain : textFieldClasses.inputPaddingSub),
|
|
54
101
|
};
|
|
@@ -71,9 +118,16 @@ const TextField = forwardRef(function TextField(props, ref) {
|
|
|
71
118
|
[textFieldClasses.typing]: typing,
|
|
72
119
|
[textFieldClasses.active]: active,
|
|
73
120
|
[textFieldClasses.warning]: warning,
|
|
74
|
-
}, className), children: [prefix && jsx("div", { className: textFieldClasses.prefix, children: prefix }), renderedChildren, clearable && (jsx(ClearActions, { type: "clearable", className: textFieldClasses.clearIcon,
|
|
121
|
+
}, className), children: [prefix && jsx("div", { className: textFieldClasses.prefix, children: prefix }), renderedChildren, clearable && (jsx(ClearActions, { type: "clearable", className: textFieldClasses.clearIcon, style: {
|
|
122
|
+
opacity: shouldShowClearable ? 1 : 0,
|
|
123
|
+
pointerEvents: shouldShowClearable ? 'auto' : 'none',
|
|
124
|
+
}, onClick: (event) => {
|
|
75
125
|
if (!disabled && !readonly && onClear) {
|
|
76
126
|
onClear(event);
|
|
127
|
+
requestAnimationFrame(() => {
|
|
128
|
+
var _a;
|
|
129
|
+
(_a = checkValueRef.current) === null || _a === void 0 ? void 0 : _a.call(checkValueRef);
|
|
130
|
+
});
|
|
77
131
|
}
|
|
78
132
|
}, onMouseDown: (event) => event.preventDefault(), tabIndex: -1 })), suffix && jsx("div", { className: textFieldClasses.suffix, children: suffix })] }));
|
|
79
133
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { timePanelClasses } from '@mezzanine-ui/core/time-panel';
|
|
3
3
|
import { forwardRef, useRef, useCallback, useEffect } from 'react';
|
|
4
4
|
import { getNumericCSSVariablePixelValue } from '../utils/get-css-variable-value.js';
|
|
@@ -16,22 +16,29 @@ const TimePanelColumn = forwardRef(function TimePanelColumn(props, ref) {
|
|
|
16
16
|
onChange === null || onChange === void 0 ? void 0 : onChange(unit);
|
|
17
17
|
}, [onChange]);
|
|
18
18
|
const preferSmoothScrollRef = useRef(true);
|
|
19
|
-
|
|
19
|
+
const onScrollToTarget = useCallback((element) => {
|
|
20
20
|
const activeIndex = units.findIndex(({ value }) => value === activeUnit);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
26
|
-
}
|
|
21
|
+
element.scrollTo({
|
|
22
|
+
behavior: preferSmoothScrollRef.current ? 'auto' : 'smooth',
|
|
23
|
+
top: activeIndex * cellHeight,
|
|
24
|
+
});
|
|
27
25
|
preferSmoothScrollRef.current = false;
|
|
28
26
|
}, [activeUnit, cellHeight, units]);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (viewportRef.current) {
|
|
29
|
+
onScrollToTarget(viewportRef.current);
|
|
30
|
+
}
|
|
31
|
+
}, [onScrollToTarget]);
|
|
29
32
|
const handleViewportReady = useCallback((viewport) => {
|
|
30
33
|
viewportRef.current = viewport;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
onScrollToTarget(viewport);
|
|
35
|
+
}, [onScrollToTarget]);
|
|
36
|
+
// Number of padding cells needed for centering (3 cells above and below the center position)
|
|
37
|
+
const paddingCellCount = 3;
|
|
38
|
+
const placeholders = Array.from({ length: paddingCellCount }, (_, i) => (jsx("div", { className: timePanelClasses.columnPlaceholder, style: { height: cellHeight }, "aria-hidden": true }, `placeholder-${i}`)));
|
|
39
|
+
return (jsx("div", { ref: ref, className: timePanelClasses.column, children: jsxs(Scrollbar, { maxHeight: cellHeight * 7, onViewportReady: handleViewportReady, children: [placeholders, units.map((unit) => (jsx("button", { type: "button", className: cx(timePanelClasses.button, timePanelClasses.columnButton, {
|
|
40
|
+
[timePanelClasses.buttonActive]: unit.value === activeUnit,
|
|
41
|
+
}), onClick: getChangeHandler(unit), children: unit.label }, unit.value))), placeholders] }) }));
|
|
35
42
|
});
|
|
36
43
|
|
|
37
44
|
export { TimePanelColumn as default };
|
package/index.d.ts
CHANGED
|
@@ -37,8 +37,12 @@ export * from './Form/useSwitchControlValue';
|
|
|
37
37
|
*/
|
|
38
38
|
export { default as Button, ButtonGroup } from './Button';
|
|
39
39
|
export type { ButtonComponent, ButtonGroupChild, ButtonGroupOrientation, ButtonGroupProps, ButtonProps, ButtonPropsBase, ButtonSize, ButtonVariant, } from './Button';
|
|
40
|
+
export { default as Cropper } from './Cropper';
|
|
41
|
+
export type { CropperComponent, CropperProps, CropperPropsBase, CropperSize, } from './Cropper';
|
|
40
42
|
export { default as Icon } from './Icon';
|
|
41
43
|
export type { IconColor, IconProps } from './Icon';
|
|
44
|
+
export { default as Separator } from './Separator';
|
|
45
|
+
export type { SeparatorProps } from './Separator';
|
|
42
46
|
export { default as Typography } from './Typography';
|
|
43
47
|
export type { TypographyAlign, TypographyColor, TypographyComponent, TypographyDisplay, TypographyProps, TypographySemanticType, } from './Typography';
|
|
44
48
|
/**
|
|
@@ -57,20 +61,18 @@ export type { PageFooterProps } from './PageFooter';
|
|
|
57
61
|
export { default as PageHeader } from './PageHeader';
|
|
58
62
|
export type { PageHeaderProps } from './PageHeader';
|
|
59
63
|
export { Step, default as Stepper, useStepper } from './Stepper';
|
|
60
|
-
export type {
|
|
64
|
+
export type { StepProps, StepperProps } from './Stepper';
|
|
61
65
|
export { default as Tab, TabItem } from './Tab';
|
|
62
66
|
export type { TabItemProps, TabProps, TabsChild } from './Tab';
|
|
63
67
|
/**
|
|
64
68
|
* Data Display
|
|
65
69
|
*/
|
|
66
|
-
export { default as Accordion,
|
|
67
|
-
export type {
|
|
70
|
+
export { default as Accordion, AccordionActions, AccordionContent, AccordionGroup, AccordionTitle, } from './Accordion';
|
|
71
|
+
export type { AccordionActionsProps, AccordionContentProps, AccordionGroupProps, AccordionProps, AccordionTitleProps, } from './Accordion';
|
|
68
72
|
export { default as Badge, BadgeContainer } from './Badge';
|
|
69
73
|
export type { BadgeProps } from './Badge';
|
|
70
|
-
export {
|
|
71
|
-
export type {
|
|
72
|
-
export { default as Card, CardActions } from './Card';
|
|
73
|
-
export type { CardActionsProps, CardProps } from './Card';
|
|
74
|
+
export { BaseCardGeneric as BaseCard, BaseCardSkeleton, CardGroup, FourThumbnailCardGeneric as FourThumbnailCard, FourThumbnailCardSkeleton, QuickActionCardGeneric as QuickActionCard, QuickActionCardSkeleton, SingleThumbnailCardGeneric as SingleThumbnailCard, SingleThumbnailCardSkeleton, ThumbnailGeneric as Thumbnail, } from './Card';
|
|
75
|
+
export type { BaseCardActionProps, BaseCardActionVariant, BaseCardComponent, BaseCardComponentProps, BaseCardDefaultProps, BaseCardOverflowProps, BaseCardProps, BaseCardPropsCommon, BaseCardSkeletonProps, BaseCardToggleProps, BaseCardType, CardGroupLoadingType, CardGroupProps, FourThumbnailCardActionProps, FourThumbnailCardComponent, FourThumbnailCardComponentProps, FourThumbnailCardDefaultProps, FourThumbnailCardOverflowProps, FourThumbnailCardProps, FourThumbnailCardPropsCommon, FourThumbnailCardSkeletonProps, FourThumbnailCardType, QuickActionCardComponent, QuickActionCardComponentProps, QuickActionCardMode, QuickActionCardProps, QuickActionCardPropsCommon, QuickActionCardSkeletonProps, QuickActionCardWithIconProps, QuickActionCardWithTitleProps, SingleThumbnailCardActionProps, SingleThumbnailCardComponent, SingleThumbnailCardComponentProps, SingleThumbnailCardDefaultProps, SingleThumbnailCardOverflowProps, SingleThumbnailCardProps, SingleThumbnailCardPropsCommon, SingleThumbnailCardSkeletonProps, SingleThumbnailCardType, ThumbnailCardInfoProps, ThumbnailComponent, ThumbnailComponentProps, ThumbnailPropsBase, } from './Card';
|
|
74
76
|
export { Description, DescriptionContent, DescriptionGroup, DescriptionTitle, } from './Description';
|
|
75
77
|
export type { DescriptionContentProps, DescriptionGroupProps, DescriptionProps, DescriptionTitleProps, } from './Description';
|
|
76
78
|
export { default as Empty } from './Empty';
|
|
@@ -79,13 +81,13 @@ export { OverflowCounterTag } from './OverflowTooltip';
|
|
|
79
81
|
export type { OverflowCounterTagProps } from './OverflowTooltip';
|
|
80
82
|
export { default as Pagination, PaginationItem, PaginationJumper, PaginationPageSize, usePagination, } from './Pagination';
|
|
81
83
|
export type { PaginationItemProps, PaginationItemType, PaginationJumperProps, PaginationPageSizeProps, PaginationProps, } from './Pagination';
|
|
82
|
-
export {
|
|
84
|
+
export { default as Section } from './Section';
|
|
85
|
+
export type { SectionProps } from './Section';
|
|
86
|
+
export { default as Table, TableContext, TableDataContext, TableSuperContext, getCellAlignClass, getRowKey, useTableContext, useTableDataContext, useTableDataSource, useTableRowSelection, useTableSuperContext, type ColumnAlign, type FixedType, type HighlightMode, type SortOrder, type TableActionItem, type TableActions, type TableActionsBase, type TableActionsWithMinWidth, type TableBaseProps, type TableBulkActions, type TableBulkGeneralAction, type TableBulkOverflowAction, type TableCollectable, type TableColumn, type TableColumnBase, type TableColumnBaseWithMinWidthRequired, type TableColumnTitleMenu, type TableColumnWithDataIndex, type TableColumnWithDataIndexAndMinWidth, type TableColumnWithMinWidth, type TableColumnWithRender, type TableColumnWithRenderAndMinWidth, type TableContextValue, type TableDataContextValue, type TableDataSource, type TableDataSourceWithId, type TableDataSourceWithKey, type TableDraggable, type TableDraggableOnlyProps, type TableExpandable, type TableExpansionState, type TableNoDragOrPinProps, type TableNonResizableProps, type TableNonVirtualizedProps, type TablePinnableOnlyProps, type TableProps, type TableRecord, type TableResizableProps, type TableResizedColumnState, type TableRowSelection, type TableRowSelectionBase, type TableRowSelectionCheckbox, type TableRowSelectionRadio, type TableScroll, type TableSelectionMode, type TableSelectionState, type TableSize, type TableSortingState, type TableToggleable, type TableTransitionState, type TableVirtualizedProps, type UpdateDataSourceOptions, type UseTableDataSourceOptions, } from './Table';
|
|
83
87
|
export { default as Tag, TagGroup } from './Tag';
|
|
84
88
|
export type { TagGroupProps, TagProps, TagSize } from './Tag';
|
|
85
89
|
export { default as Tooltip } from './Tooltip';
|
|
86
90
|
export type { TooltipProps } from './Tooltip';
|
|
87
|
-
export { getTreeNodeEntities, toggleValue, toggleValueWithStatusControl, traverseTree, default as Tree, TreeNode, TreeNodeList, uniqueArray, useTreeExpandedValue, } from './Tree';
|
|
88
|
-
export type { GetTreeNodeEntitiesProps, TreeExpandControl, TreeNodeData, TreeNodeElementProps, TreeNodeEntities, TreeNodeEntity, TreeNodeListElementProps, TreeNodeListProps, TreeNodeProp, TreeNodeProps, TreeNodeRefs, TreeNodeRefsShape, TreeProps, UseTreeExpandedValueProps, } from './Tree';
|
|
89
91
|
/**
|
|
90
92
|
* Data Entry
|
|
91
93
|
*/
|
|
@@ -101,20 +103,20 @@ export { default as DateTimePicker } from './DateTimePicker';
|
|
|
101
103
|
export type { DateTimePickerProps } from './DateTimePicker';
|
|
102
104
|
export { DateTimeRangePicker } from './DateTimeRangePicker';
|
|
103
105
|
export type { DateTimeRangePickerProps, DateTimeRangePickerValue, } from './DateTimeRangePicker';
|
|
104
|
-
export {
|
|
105
|
-
export type { MultipleDatePickerDateValue, MultipleDatePickerProps, MultipleDatePickerTriggerProps, UseMultipleDatePickerValueProps, UseMultipleDatePickerValueReturn, } from './MultipleDatePicker';
|
|
106
|
-
export { FormControlContext, FormField, FormHintText, FormLabel } from './Form';
|
|
107
|
-
export { FilterArea, FilterLine, Filter } from './FilterArea';
|
|
106
|
+
export { Filter, FilterArea, FilterLine } from './FilterArea';
|
|
108
107
|
export type { FilterAreaProps, FilterLineProps, FilterProps, } from './FilterArea';
|
|
108
|
+
export { FormControlContext, FormField, FormHintText, FormLabel } from './Form';
|
|
109
109
|
export type { FormControl, FormFieldProps, FormHintTextProps, FormLabelProps, } from './Form';
|
|
110
110
|
export { default as Input } from './Input';
|
|
111
|
-
export type { ActionInputProps, BaseInputProps, ClearableInput, InputBaseProps, InputProps, InputSize, InputStrength, NumberInput, NumberInputProps, PasswordInputProps, SearchInputProps, SelectInputProps,
|
|
111
|
+
export type { ActionInputProps, BaseInputProps, ClearableInput, CurrencyInputProps, InputBaseProps, InputProps, InputSize, InputStrength, NumberInput, NumberInputProps, PasswordInputProps, SearchInputProps, SelectInputProps, WithAffixInputProps, WithPasswordStrengthIndicator, } from './Input';
|
|
112
|
+
export { default as MultipleDatePicker, MultipleDatePickerTrigger, useMultipleDatePickerValue, } from './MultipleDatePicker';
|
|
113
|
+
export type { MultipleDatePickerDateValue, MultipleDatePickerProps, MultipleDatePickerTriggerProps, UseMultipleDatePickerValueProps, UseMultipleDatePickerValueReturn, } from './MultipleDatePicker';
|
|
112
114
|
export { PickerTrigger, RangePickerTrigger, usePickerDocumentEventClose, usePickerValue, useTabKeyClose, } from './Picker';
|
|
113
115
|
export type { PickerTriggerProps, RangePickerTriggerProps, UsePickerDocumentEventCloseProps, UsePickerValueProps, } from './Picker';
|
|
114
116
|
export { default as Radio, RadioGroup } from './Radio';
|
|
115
117
|
export type { RadioGroupOrientation, RadioGroupProps, RadioProps, RadioSize, } from './Radio';
|
|
116
|
-
export {
|
|
117
|
-
export type { OptionGroupProps,
|
|
118
|
+
export { OptionGroup, default as Select, SelectControlContext, SelectTrigger, SelectTriggerTags, } from './Select';
|
|
119
|
+
export type { OptionGroupProps, SelectControl, SelectProps, SelectTriggerInputProps, SelectTriggerProps, SelectTriggerTagsProps, SelectValue, } from './Select';
|
|
118
120
|
export { default as Selection } from './Selection';
|
|
119
121
|
export type { SelectionProps, SelectionPropsBase } from './Selection';
|
|
120
122
|
export { default as Slider, useSlider } from './Slider';
|
|
@@ -125,20 +127,15 @@ export { default as TextField } from './TextField';
|
|
|
125
127
|
export type { TextFieldAffixProps, TextFieldBaseProps, TextFieldInteractiveStateProps, TextFieldPaddingInfo, TextFieldProps, TextFieldSize, } from './TextField';
|
|
126
128
|
export { default as TimePicker, TimePickerPanel } from './TimePicker';
|
|
127
129
|
export type { TimePickerPanelProps, TimePickerProps } from './TimePicker';
|
|
128
|
-
export { default as TimeRangePicker } from './TimeRangePicker';
|
|
130
|
+
export { default as TimeRangePicker, useTimeRangePickerValue, } from './TimeRangePicker';
|
|
129
131
|
export type { TimeRangePickerProps, TimeRangePickerValue, UseTimeRangePickerValueProps, } from './TimeRangePicker';
|
|
130
|
-
export { useTimeRangePickerValue } from './TimeRangePicker';
|
|
131
132
|
export { default as Switch } from './Toggle';
|
|
132
133
|
export type { ToggleProps as SwitchProps, ToggleSize as SwitchSize, } from './Toggle';
|
|
133
|
-
export { Upload,
|
|
134
|
-
export type {
|
|
134
|
+
export { Upload, UploadItem, UploadPictureCard, Uploader } from './Upload';
|
|
135
|
+
export type { UploadFile, UploadItemProps, UploadPictureCardProps, UploadProps, UploaderProps, } from './Upload';
|
|
135
136
|
/**
|
|
136
137
|
* Feedback
|
|
137
138
|
*/
|
|
138
|
-
export { default as Alert } from './Alert';
|
|
139
|
-
export type { AlertProps, AlertSeverity } from './Alert';
|
|
140
|
-
export { default as ConfirmActions } from './ConfirmActions';
|
|
141
|
-
export type { ConfirmActionsProps } from './ConfirmActions';
|
|
142
139
|
export { default as Message } from './Message';
|
|
143
140
|
export type { MessageData, MessageSeverity, MessageType } from './Message';
|
|
144
141
|
export { default as Modal, ModalBodyForVerification, ModalFooter, ModalHeader, useModalContainer, } from './Modal';
|
|
@@ -158,12 +155,14 @@ export type { ResultStateActions, ResultStateProps } from './ResultState';
|
|
|
158
155
|
/**
|
|
159
156
|
* Others
|
|
160
157
|
*/
|
|
158
|
+
export { default as AlertBanner } from './AlertBanner';
|
|
159
|
+
export type { AlertBannerProps } from './AlertBanner';
|
|
161
160
|
export { default as Anchor, AnchorGroup } from './Anchor';
|
|
162
161
|
export type { AnchorGroupProps, AnchorProps } from './Anchor';
|
|
163
162
|
export { default as Backdrop } from './Backdrop';
|
|
164
163
|
export type { BackdropProps } from './Backdrop';
|
|
165
|
-
export { default as
|
|
166
|
-
export type {
|
|
164
|
+
export { default as FloatingButton } from './FloatingButton';
|
|
165
|
+
export type { FloatingButtonProps } from './FloatingButton';
|
|
167
166
|
/**
|
|
168
167
|
* Utility
|
|
169
168
|
*/
|
|
@@ -195,4 +194,4 @@ export { default as DropdownItemCard } from './Dropdown/DropdownItemCard';
|
|
|
195
194
|
export type { DropdownItemCardProps } from './Dropdown/DropdownItemCard';
|
|
196
195
|
export { default as DropdownStatus } from './Dropdown/DropdownStatus';
|
|
197
196
|
export type { DropdownStatusProps } from './Dropdown/DropdownStatus';
|
|
198
|
-
export type { DropdownCheckPosition, DropdownInputPosition, DropdownItemLevel, DropdownItemSharedProps, DropdownItemValidate, DropdownMode, DropdownOption, DropdownOptionFlat, DropdownOptionGrouped,
|
|
197
|
+
export type { DropdownCheckPosition, DropdownInputPosition, DropdownItemLevel, DropdownItemSharedProps, DropdownItemValidate, DropdownMode, DropdownOption, DropdownOptionFlat, DropdownOptionGrouped, DropdownOptionTree, DropdownOptionsByType, DropdownStatus as DropdownStatusType, DropdownType, } from '@mezzanine-ui/core/dropdown';
|