@mezzanine-ui/react 1.0.0-rc.5 → 1.0.0-rc.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 +36 -0
- package/Accordion/Accordion.js +37 -1
- package/AlertBanner/AlertBanner.d.ts +30 -1
- package/AlertBanner/AlertBanner.js +56 -12
- package/AutoComplete/AutoComplete.d.ts +75 -11
- package/AutoComplete/AutoComplete.js +145 -25
- package/AutoComplete/AutoCompleteInside.d.ts +54 -0
- package/AutoComplete/AutoCompleteInside.js +17 -0
- package/AutoComplete/useAutoCompleteKeyboard.d.ts +2 -1
- package/AutoComplete/useAutoCompleteKeyboard.js +4 -1
- package/Backdrop/Backdrop.d.ts +33 -1
- package/Backdrop/Backdrop.js +33 -1
- package/Badge/Badge.d.ts +26 -1
- package/Badge/Badge.js +26 -1
- package/Badge/typings.d.ts +15 -0
- package/Breadcrumb/BreadcrumbDropdown.d.ts +1 -1
- package/Breadcrumb/BreadcrumbOverflowMenuDropdown.d.ts +1 -1
- package/Breadcrumb/typings.d.ts +1 -1
- package/Button/Button.d.ts +26 -1
- package/Button/Button.js +33 -5
- package/COMPONENTS.md +267 -0
- package/Calendar/useCalendarControls.d.ts +18 -0
- package/Calendar/useCalendarControls.js +18 -0
- package/Card/FourThumbnailCard.js +1 -1
- package/Card/SingleThumbnailCard.js +1 -1
- package/Checkbox/Checkbox.d.ts +30 -1
- package/Checkbox/Checkbox.js +54 -4
- package/Checkbox/CheckboxGroup.d.ts +39 -1
- package/Checkbox/CheckboxGroup.js +49 -3
- package/Cropper/Cropper.d.ts +2 -2
- package/Cropper/Cropper.js +2 -3
- package/Cropper/CropperElement.js +1 -1
- package/Cropper/utils/cropper-calculations.d.ts +1 -1
- package/Cropper/utils/cropper-calculations.js +16 -14
- package/DatePicker/DatePicker.d.ts +36 -2
- package/DatePicker/DatePicker.js +36 -2
- package/DateRangePicker/useDateRangePickerValue.d.ts +24 -0
- package/DateRangePicker/useDateRangePickerValue.js +24 -0
- package/Description/Description.d.ts +1 -1
- package/Description/Description.js +1 -1
- package/Description/DescriptionTitle.d.ts +6 -1
- package/Description/DescriptionTitle.js +2 -2
- package/Drawer/Drawer.d.ts +78 -33
- package/Drawer/Drawer.js +72 -34
- package/Dropdown/Dropdown.d.ts +63 -1
- package/Dropdown/Dropdown.js +203 -9
- package/Dropdown/DropdownItem.d.ts +26 -2
- package/Dropdown/DropdownItem.js +91 -43
- package/Dropdown/DropdownItemCard.d.ts +3 -2
- package/Dropdown/DropdownItemCard.js +8 -5
- package/Dropdown/DropdownStatus.d.ts +2 -2
- package/Dropdown/DropdownStatus.js +3 -2
- package/Dropdown/dropdownKeydownHandler.d.ts +6 -0
- package/Dropdown/dropdownKeydownHandler.js +14 -7
- package/Empty/icons/EmptyMainInitialDataIcon.js +1 -1
- package/Empty/icons/EmptyMainNotificationIcon.js +1 -1
- package/Empty/icons/EmptyMainResultIcon.js +1 -1
- package/Empty/icons/EmptyMainSystemIcon.js +1 -1
- package/FilterArea/Filter.d.ts +25 -2
- package/FilterArea/Filter.js +43 -2
- package/FilterArea/FilterArea.d.ts +43 -4
- package/FilterArea/FilterArea.js +39 -4
- package/FilterArea/FilterAreaContext.d.ts +6 -0
- package/FilterArea/FilterAreaContext.js +6 -0
- package/FilterArea/FilterLine.d.ts +19 -0
- package/FilterArea/FilterLine.js +19 -0
- package/FilterArea/index.d.ts +2 -2
- package/FilterArea/index.js +1 -1
- package/Form/FormField.d.ts +43 -2
- package/Form/FormField.js +40 -3
- package/Form/typings.d.ts +2 -0
- package/Form/useAutoCompleteValueControl.d.ts +20 -0
- package/Form/useAutoCompleteValueControl.js +20 -0
- package/Form/useCheckboxControlValue.d.ts +19 -0
- package/Form/useCheckboxControlValue.js +19 -0
- package/Form/useControlValueState.d.ts +16 -0
- package/Form/useControlValueState.js +16 -0
- package/Form/useCustomControlValue.d.ts +17 -0
- package/Form/useCustomControlValue.js +17 -0
- package/Form/useInputControlValue.d.ts +19 -0
- package/Form/useInputControlValue.js +19 -0
- package/Form/useInputWithClearControlValue.d.ts +20 -0
- package/Form/useInputWithClearControlValue.js +20 -0
- package/Form/useRadioControlValue.d.ts +19 -0
- package/Form/useRadioControlValue.js +19 -0
- package/Form/useSelectValueControl.d.ts +19 -0
- package/Form/useSelectValueControl.js +19 -0
- package/Form/useSwitchControlValue.d.ts +18 -0
- package/Form/useSwitchControlValue.js +18 -0
- package/Icon/Icon.d.ts +23 -1
- package/Icon/Icon.js +23 -1
- package/Input/Input.d.ts +31 -1
- package/Input/Input.js +31 -1
- package/Input/SpinnerButton/SpinnerButton.js +1 -1
- package/Message/Message.d.ts +56 -6
- package/Message/Message.js +59 -52
- package/Modal/Modal.d.ts +76 -4
- package/Modal/Modal.js +117 -6
- package/Modal/ModalBodyForVerification.js +3 -1
- package/Modal/ModalFooter.d.ts +21 -6
- package/Modal/ModalHeader.d.ts +50 -11
- package/Modal/ModalHeader.js +1 -1
- package/Modal/index.d.ts +1 -1
- package/Navigation/Navigation.js +20 -11
- package/Navigation/NavigationHeader.js +2 -1
- package/Navigation/NavigationIconButton.d.ts +8 -0
- package/Navigation/NavigationIconButton.js +2 -2
- package/Navigation/NavigationOption.js +6 -3
- package/Navigation/NavigationOverflowMenu.js +9 -6
- package/Navigation/NavigationUserMenu.js +3 -1
- package/Navigation/context.d.ts +1 -0
- package/NotificationCenter/NotificationCenter.d.ts +59 -9
- package/NotificationCenter/NotificationCenter.js +150 -54
- package/NotificationCenter/NotificationCenterDrawer.d.ts +56 -6
- package/NotificationCenter/NotificationCenterDrawer.js +6 -8
- package/NotificationCenter/index.d.ts +1 -1
- package/OverflowTooltip/OverflowTooltip.js +46 -5
- package/PageFooter/PageFooter.d.ts +1 -1
- package/PageFooter/PageFooter.js +8 -16
- package/Pagination/Pagination.d.ts +38 -1
- package/Pagination/Pagination.js +38 -1
- package/Pagination/PaginationPageSize.js +1 -1
- package/Pagination/usePagination.d.ts +20 -0
- package/Pagination/usePagination.js +20 -0
- package/Progress/Progress.d.ts +24 -1
- package/Progress/Progress.js +24 -1
- package/README.md +82 -0
- package/Radio/Radio.d.ts +35 -1
- package/Radio/Radio.js +50 -12
- package/Radio/RadioGroup.d.ts +2 -2
- package/Radio/RadioGroupContext.d.ts +3 -2
- package/Section/SectionGroup.d.ts +20 -0
- package/Section/SectionGroup.js +16 -0
- package/Section/index.d.ts +2 -0
- package/Section/index.js +1 -0
- package/Select/Select.d.ts +55 -1
- package/Select/Select.js +37 -2
- package/Select/typings.d.ts +9 -0
- package/{Selection/Selection.d.ts → SelectionCard/SelectionCard.d.ts} +23 -11
- package/{Selection/Selection.js → SelectionCard/SelectionCard.js} +14 -14
- package/SelectionCard/SelectionCardGroup.d.ts +28 -0
- package/SelectionCard/index.d.ts +12 -0
- package/SelectionCard/index.js +5 -0
- package/Separator/Separator.d.ts +19 -1
- package/Separator/Separator.js +19 -1
- package/Slider/Slider.d.ts +11 -0
- package/Slider/useSlider.d.ts +21 -0
- package/Spin/Spin.d.ts +14 -5
- package/Spin/Spin.js +6 -8
- package/Stepper/Stepper.d.ts +34 -1
- package/Stepper/Stepper.js +34 -1
- package/Stepper/useStepper.d.ts +18 -0
- package/Stepper/useStepper.js +18 -0
- package/Tab/Tab.d.ts +33 -1
- package/Tab/Tab.js +33 -1
- package/Table/Table.d.ts +51 -3
- package/Table/Table.js +52 -4
- package/Table/hooks/useTableDataSource.d.ts +4 -4
- package/Table/hooks/useTableDataSource.js +1 -1
- package/Tag/Tag.d.ts +27 -1
- package/Tag/Tag.js +27 -1
- package/Tag/typings.d.ts +28 -0
- package/Textarea/Textarea.d.ts +28 -1
- package/Textarea/Textarea.js +25 -1
- package/TimePicker/TimePicker.js +1 -1
- package/TimeRangePicker/TimeRangePicker.js +1 -1
- package/Toggle/Toggle.d.ts +34 -1
- package/Toggle/Toggle.js +34 -1
- package/Tooltip/Tooltip.d.ts +39 -1
- package/Tooltip/Tooltip.js +39 -1
- package/Tooltip/useDelayMouseEnterLeave.d.ts +17 -0
- package/Tooltip/useDelayMouseEnterLeave.js +17 -0
- package/Typography/Typography.d.ts +23 -1
- package/Typography/Typography.js +23 -1
- package/Upload/Upload.d.ts +13 -7
- package/Upload/Upload.js +55 -20
- package/Upload/UploadItem.d.ts +3 -3
- package/Upload/UploadItem.js +11 -8
- package/Upload/UploadPictureCard.d.ts +5 -0
- package/Upload/UploadPictureCard.js +10 -6
- package/Upload/Uploader.d.ts +32 -31
- package/Upload/Uploader.js +10 -9
- package/hooks/useClickAway.d.ts +16 -0
- package/hooks/useClickAway.js +16 -0
- package/hooks/useComposeRefs.d.ts +15 -0
- package/hooks/useComposeRefs.js +15 -0
- package/hooks/useDocumentEscapeKeyDown.d.ts +15 -0
- package/hooks/useDocumentEscapeKeyDown.js +15 -0
- package/hooks/useDocumentEvents.d.ts +16 -0
- package/hooks/useDocumentEvents.js +16 -0
- package/hooks/useDocumentTabKeyDown.d.ts +15 -0
- package/hooks/useDocumentTabKeyDown.js +15 -0
- package/hooks/useIsomorphicLayoutEffect.d.ts +16 -0
- package/hooks/useIsomorphicLayoutEffect.js +16 -0
- package/hooks/useLastCallback.d.ts +15 -0
- package/hooks/useLastCallback.js +15 -0
- package/hooks/useLastValue.d.ts +18 -0
- package/hooks/useLastValue.js +18 -0
- package/hooks/usePreviousValue.d.ts +14 -0
- package/hooks/usePreviousValue.js +14 -0
- package/hooks/useScrollLock.d.ts +6 -4
- package/hooks/useScrollLock.js +6 -4
- package/hooks/useTopStack.d.ts +17 -0
- package/hooks/useTopStack.js +17 -0
- package/hooks/useWindowWidth.d.ts +14 -0
- package/hooks/useWindowWidth.js +14 -0
- package/index.d.ts +6 -4
- package/index.js +3 -2
- package/llms.txt +200 -0
- package/package.json +5 -4
- package/Selection/SelectionGroup.d.ts +0 -28
- package/Selection/index.d.ts +0 -12
- package/Selection/index.js +0 -5
package/Accordion/Accordion.d.ts
CHANGED
|
@@ -41,5 +41,41 @@ export interface AccordionProps extends Omit<NativeElementPropsWithoutKeyAndRef<
|
|
|
41
41
|
*/
|
|
42
42
|
actions?: AccordionTitleProps['actions'];
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* 手風琴元件,提供可展開/收合的內容區塊。
|
|
46
|
+
*
|
|
47
|
+
* 可透過 `title` prop 快速設定標題文字,或以 `AccordionTitle` 子元件進行客製化;
|
|
48
|
+
* 內容區域使用 `AccordionContent` 子元件包裹。支援受控(`expanded`)與非受控
|
|
49
|
+
* (`defaultExpanded`)兩種模式,以及 `size` 控制整體尺寸,`actions` 可在標題右側
|
|
50
|
+
* 插入操作按鈕(僅限 `Button` 或 `Dropdown`)。
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```tsx
|
|
54
|
+
* import Accordion from '@mezzanine-ui/react/Accordion';
|
|
55
|
+
* import AccordionTitle from '@mezzanine-ui/react/AccordionTitle';
|
|
56
|
+
* import AccordionContent from '@mezzanine-ui/react/AccordionContent';
|
|
57
|
+
*
|
|
58
|
+
* // 使用 title prop(最簡單的方式)
|
|
59
|
+
* <Accordion title="常見問題">
|
|
60
|
+
* <p>這裡是問題的詳細說明內容。</p>
|
|
61
|
+
* </Accordion>
|
|
62
|
+
*
|
|
63
|
+
* // 使用子元件客製化
|
|
64
|
+
* <Accordion defaultExpanded>
|
|
65
|
+
* <AccordionTitle>進階設定</AccordionTitle>
|
|
66
|
+
* <AccordionContent>
|
|
67
|
+
* <p>展開後顯示的內容。</p>
|
|
68
|
+
* </AccordionContent>
|
|
69
|
+
* </Accordion>
|
|
70
|
+
*
|
|
71
|
+
* // 受控模式
|
|
72
|
+
* const [expanded, setExpanded] = useState(false);
|
|
73
|
+
* <Accordion expanded={expanded} onChange={setExpanded} title="收費方案">
|
|
74
|
+
* <p>詳細收費說明。</p>
|
|
75
|
+
* </Accordion>
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @see {@link AccordionGroup} 管理多個手風琴的群組元件
|
|
79
|
+
*/
|
|
44
80
|
declare const Accordion: React.ForwardRefExoticComponent<AccordionProps & React.RefAttributes<HTMLDivElement>>;
|
|
45
81
|
export default Accordion;
|
package/Accordion/Accordion.js
CHANGED
|
@@ -46,6 +46,42 @@ const resolveChildren = (children) => {
|
|
|
46
46
|
content,
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* 手風琴元件,提供可展開/收合的內容區塊。
|
|
51
|
+
*
|
|
52
|
+
* 可透過 `title` prop 快速設定標題文字,或以 `AccordionTitle` 子元件進行客製化;
|
|
53
|
+
* 內容區域使用 `AccordionContent` 子元件包裹。支援受控(`expanded`)與非受控
|
|
54
|
+
* (`defaultExpanded`)兩種模式,以及 `size` 控制整體尺寸,`actions` 可在標題右側
|
|
55
|
+
* 插入操作按鈕(僅限 `Button` 或 `Dropdown`)。
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* import Accordion from '@mezzanine-ui/react/Accordion';
|
|
60
|
+
* import AccordionTitle from '@mezzanine-ui/react/AccordionTitle';
|
|
61
|
+
* import AccordionContent from '@mezzanine-ui/react/AccordionContent';
|
|
62
|
+
*
|
|
63
|
+
* // 使用 title prop(最簡單的方式)
|
|
64
|
+
* <Accordion title="常見問題">
|
|
65
|
+
* <p>這裡是問題的詳細說明內容。</p>
|
|
66
|
+
* </Accordion>
|
|
67
|
+
*
|
|
68
|
+
* // 使用子元件客製化
|
|
69
|
+
* <Accordion defaultExpanded>
|
|
70
|
+
* <AccordionTitle>進階設定</AccordionTitle>
|
|
71
|
+
* <AccordionContent>
|
|
72
|
+
* <p>展開後顯示的內容。</p>
|
|
73
|
+
* </AccordionContent>
|
|
74
|
+
* </Accordion>
|
|
75
|
+
*
|
|
76
|
+
* // 受控模式
|
|
77
|
+
* const [expanded, setExpanded] = useState(false);
|
|
78
|
+
* <Accordion expanded={expanded} onChange={setExpanded} title="收費方案">
|
|
79
|
+
* <p>詳細收費說明。</p>
|
|
80
|
+
* </Accordion>
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @see {@link AccordionGroup} 管理多個手風琴的群組元件
|
|
84
|
+
*/
|
|
49
85
|
const Accordion = forwardRef(function Accordion(props, ref) {
|
|
50
86
|
const { actions, children: childrenProp, className, defaultExpanded = false, disabled = false, expanded: expandedProp, onChange, size = 'main', title, ...rest } = props;
|
|
51
87
|
const [expanded, toggleExpanded] = useState(defaultExpanded !== null && defaultExpanded !== void 0 ? defaultExpanded : false);
|
|
@@ -70,7 +106,7 @@ const Accordion = forwardRef(function Accordion(props, ref) {
|
|
|
70
106
|
toggleExpanded: onToggleExpanded,
|
|
71
107
|
});
|
|
72
108
|
}, [disabled, expandedProp, expanded, onToggleExpanded, resolvedTitle]);
|
|
73
|
-
return (jsx("div", { ...rest, ref: ref, className: cx(accordionClasses.host, accordionClasses.size(size), className), children: jsxs(AccordionControlContext.Provider, { value: contextValue, children: [title ? (jsx(AccordionTitle, { actions: actions, children: title })) : (resolvedTitle), jsx(Fade, { duration: {
|
|
109
|
+
return (jsx("div", { ...rest, ref: ref, className: cx(accordionClasses.host, accordionClasses.size(size), { [accordionClasses.hostDisabled]: disabled }, className), children: jsxs(AccordionControlContext.Provider, { value: contextValue, children: [title ? (jsx(AccordionTitle, { actions: actions, children: title })) : (resolvedTitle), jsx(Fade, { duration: {
|
|
74
110
|
enter: MOTION_DURATION.moderate,
|
|
75
111
|
exit: MOTION_DURATION.moderate,
|
|
76
112
|
}, easing: {
|
|
@@ -86,7 +86,36 @@ export type AlertBannerType = ((props: AlertBannerData) => ReactElement | null)
|
|
|
86
86
|
key?: Key;
|
|
87
87
|
}) => Key>;
|
|
88
88
|
/**
|
|
89
|
-
*
|
|
89
|
+
* 頁面層級的橫幅式警示訊息元件。
|
|
90
|
+
*
|
|
91
|
+
* 預設透過 `Portal` 渲染至 `alert` layer,支援 `info`、`warning`、`error` 三種嚴重程度。
|
|
92
|
+
* 提供最多 2 個操作按鈕與關閉按鈕,並在顯示及關閉時套用進入/離開動畫。
|
|
93
|
+
* 也可透過靜態方法 `AlertBanner.info()`、`AlertBanner.warning()`、`AlertBanner.error()` 以命令式方式觸發。
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```tsx
|
|
97
|
+
* import AlertBanner from '@mezzanine-ui/react/AlertBanner';
|
|
98
|
+
*
|
|
99
|
+
* // 基本用法(JSX)
|
|
100
|
+
* <AlertBanner severity="info" message="系統將於今晚進行維護" />
|
|
101
|
+
*
|
|
102
|
+
* // 帶有操作按鈕
|
|
103
|
+
* <AlertBanner
|
|
104
|
+
* severity="warning"
|
|
105
|
+
* message="您有未儲存的變更"
|
|
106
|
+
* actions={[
|
|
107
|
+
* { content: '儲存', onClick: handleSave },
|
|
108
|
+
* { content: '捨棄', onClick: handleDiscard },
|
|
109
|
+
* ]}
|
|
110
|
+
* />
|
|
111
|
+
*
|
|
112
|
+
* // 命令式呼叫
|
|
113
|
+
* AlertBanner.error('操作失敗,請稍後再試');
|
|
114
|
+
* AlertBanner.info('資料已更新', { closable: true });
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* @see {@link InlineMessage} 行內訊息元件
|
|
118
|
+
* @see {@link Message} 全域提示訊息元件
|
|
90
119
|
*/
|
|
91
120
|
export declare const AlertBannerComponent: import("react").ForwardRefExoticComponent<AlertBannerProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
92
121
|
declare const AlertBanner: AlertBannerType;
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { useCallback, forwardRef, useState, useRef, useEffect } from 'react';
|
|
4
4
|
import { alertBannerIcons, alertBannerClasses, alertBannerGroupClasses } from '@mezzanine-ui/core/alert-banner';
|
|
5
|
+
import { MOTION_EASING } from '@mezzanine-ui/system/motion';
|
|
5
6
|
import Button from '../Button/Button.js';
|
|
6
7
|
import ClearActions from '../ClearActions/ClearActions.js';
|
|
7
8
|
import { useComposeRefs } from '../hooks/useComposeRefs.js';
|
|
9
|
+
import { reflow } from '../Transition/reflow.js';
|
|
8
10
|
import Icon from '../Icon/Icon.js';
|
|
9
11
|
import Portal from '../Portal/Portal.js';
|
|
10
12
|
import cx from 'clsx';
|
|
@@ -29,18 +31,53 @@ function sortAlertNotifiers(notifiers) {
|
|
|
29
31
|
});
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
|
-
*
|
|
34
|
+
* 頁面層級的橫幅式警示訊息元件。
|
|
35
|
+
*
|
|
36
|
+
* 預設透過 `Portal` 渲染至 `alert` layer,支援 `info`、`warning`、`error` 三種嚴重程度。
|
|
37
|
+
* 提供最多 2 個操作按鈕與關閉按鈕,並在顯示及關閉時套用進入/離開動畫。
|
|
38
|
+
* 也可透過靜態方法 `AlertBanner.info()`、`AlertBanner.warning()`、`AlertBanner.error()` 以命令式方式觸發。
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* import AlertBanner from '@mezzanine-ui/react/AlertBanner';
|
|
43
|
+
*
|
|
44
|
+
* // 基本用法(JSX)
|
|
45
|
+
* <AlertBanner severity="info" message="系統將於今晚進行維護" />
|
|
46
|
+
*
|
|
47
|
+
* // 帶有操作按鈕
|
|
48
|
+
* <AlertBanner
|
|
49
|
+
* severity="warning"
|
|
50
|
+
* message="您有未儲存的變更"
|
|
51
|
+
* actions={[
|
|
52
|
+
* { content: '儲存', onClick: handleSave },
|
|
53
|
+
* { content: '捨棄', onClick: handleDiscard },
|
|
54
|
+
* ]}
|
|
55
|
+
* />
|
|
56
|
+
*
|
|
57
|
+
* // 命令式呼叫
|
|
58
|
+
* AlertBanner.error('操作失敗,請稍後再試');
|
|
59
|
+
* AlertBanner.info('資料已更新', { closable: true });
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @see {@link InlineMessage} 行內訊息元件
|
|
63
|
+
* @see {@link Message} 全域提示訊息元件
|
|
33
64
|
*/
|
|
34
65
|
const AlertBannerComponent = forwardRef(function AlertBanner(props, ref) {
|
|
35
66
|
var _a;
|
|
36
67
|
const { actions, className, closable = true, disablePortal = false, icon, message, onClose, severity, ...rest } = props;
|
|
37
68
|
const [visible, setVisible] = useState(true);
|
|
38
|
-
const [isExiting, setIsExiting] = useState(false);
|
|
39
|
-
const [isEntering, setIsEntering] = useState(false);
|
|
40
69
|
const nodeRef = useRef(null);
|
|
70
|
+
const wrapperRef = useRef(null);
|
|
41
71
|
const composedRef = useComposeRefs([ref, nodeRef]);
|
|
42
72
|
const handleClose = useCallback(() => {
|
|
43
|
-
|
|
73
|
+
const wrapper = wrapperRef.current;
|
|
74
|
+
if (wrapper) {
|
|
75
|
+
wrapper.style.height = `${wrapper.scrollHeight}px`;
|
|
76
|
+
wrapper.style.overflow = 'hidden';
|
|
77
|
+
reflow(wrapper);
|
|
78
|
+
wrapper.style.transition = `height 250ms ${MOTION_EASING.exit}`;
|
|
79
|
+
wrapper.style.height = '0px';
|
|
80
|
+
}
|
|
44
81
|
setTimeout(() => {
|
|
45
82
|
setVisible(false);
|
|
46
83
|
if (onClose) {
|
|
@@ -54,16 +91,23 @@ const AlertBannerComponent = forwardRef(function AlertBanner(props, ref) {
|
|
|
54
91
|
}
|
|
55
92
|
}, [actions]);
|
|
56
93
|
useEffect(() => {
|
|
57
|
-
if (visible &&
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
94
|
+
if (visible && nodeRef.current && wrapperRef.current) {
|
|
95
|
+
const wrapper = wrapperRef.current;
|
|
96
|
+
const inner = nodeRef.current;
|
|
97
|
+
wrapper.style.height = '0px';
|
|
98
|
+
wrapper.style.overflow = 'hidden';
|
|
99
|
+
reflow(wrapper);
|
|
62
100
|
requestAnimationFrame(() => {
|
|
63
|
-
|
|
101
|
+
wrapper.style.transition = `height 250ms ${MOTION_EASING.entrance}`;
|
|
102
|
+
wrapper.style.height = `${inner.scrollHeight}px`;
|
|
103
|
+
setTimeout(() => {
|
|
104
|
+
wrapper.style.height = 'auto';
|
|
105
|
+
wrapper.style.overflow = 'visible';
|
|
106
|
+
wrapper.style.transition = '';
|
|
107
|
+
}, 250);
|
|
64
108
|
});
|
|
65
109
|
}
|
|
66
|
-
}, [visible
|
|
110
|
+
}, [visible]);
|
|
67
111
|
if (!visible) {
|
|
68
112
|
return null;
|
|
69
113
|
}
|
|
@@ -77,7 +121,7 @@ const AlertBannerComponent = forwardRef(function AlertBanner(props, ref) {
|
|
|
77
121
|
}) })) : null;
|
|
78
122
|
const clearActionsArea = showCloseButton ? (jsx(ClearActions, { className: alertBannerClasses.close, onClick: handleClose, type: "standard", variant: "inverse" })) : null;
|
|
79
123
|
const { maxCount: _maxCount, instanceKey: _instanceKey, ...restProps } = rest;
|
|
80
|
-
const content = (jsxs("div", { ...restProps, ref: composedRef, "aria-live": "polite", className: cx(alertBannerClasses.host, alertBannerClasses.severity(severity),
|
|
124
|
+
const content = (jsx("div", { ref: wrapperRef, className: alertBannerClasses.wrapper, children: jsxs("div", { ...restProps, ref: composedRef, "aria-live": "polite", className: cx(alertBannerClasses.host, alertBannerClasses.severity(severity), className), role: "status", children: [jsxs("div", { className: alertBannerClasses.body, children: [jsx(Icon, { className: alertBannerClasses.icon, icon: resolvedIcon }), jsx("span", { className: alertBannerClasses.message, children: message })] }), jsxs("div", { className: alertBannerClasses.controls, children: [actionsArea, clearActionsArea] })] }) }));
|
|
81
125
|
if (disablePortal) {
|
|
82
126
|
return content;
|
|
83
127
|
}
|
|
@@ -21,6 +21,8 @@ export interface AutoCompleteBaseProps extends Omit<SelectTriggerProps, 'active'
|
|
|
21
21
|
asyncData?: boolean;
|
|
22
22
|
/**
|
|
23
23
|
* Whether to clear search text when leaving the textfield/dropdown scope.
|
|
24
|
+
* When `false`, typed text persists after blur. In `single` mode, a clearable
|
|
25
|
+
* icon will appear if the user has typed text without selecting an option.
|
|
24
26
|
* @default true
|
|
25
27
|
*/
|
|
26
28
|
clearSearchText?: boolean;
|
|
@@ -46,7 +48,10 @@ export interface AutoCompleteBaseProps extends Omit<SelectTriggerProps, 'active'
|
|
|
46
48
|
*/
|
|
47
49
|
id?: string;
|
|
48
50
|
/**
|
|
49
|
-
* The position of the input.
|
|
51
|
+
* The position of the search input relative to the dropdown.
|
|
52
|
+
* - `'outside'`: input is always visible above the dropdown (default trigger layout).
|
|
53
|
+
* - `'inside'`: input is rendered inside the dropdown panel; the trigger shows only
|
|
54
|
+
* the selected value(s) and opens the dropdown on click.
|
|
50
55
|
* @default 'outside'
|
|
51
56
|
*/
|
|
52
57
|
inputPosition?: DropdownInputPosition;
|
|
@@ -86,10 +91,10 @@ export interface AutoCompleteBaseProps extends Omit<SelectTriggerProps, 'active'
|
|
|
86
91
|
*/
|
|
87
92
|
name?: string;
|
|
88
93
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
94
|
+
* Callback fired when the user confirms a new item creation.
|
|
95
|
+
* Receives the typed text and the current options array; must return the updated options array.
|
|
96
|
+
* Use this to append the new item to your options state.
|
|
97
|
+
* Required when `addable` is true; omitting it will disable the creation feature.
|
|
93
98
|
*/
|
|
94
99
|
onInsert?(text: string, currentOptions: SelectValue[]): SelectValue[];
|
|
95
100
|
/**
|
|
@@ -178,9 +183,10 @@ export interface AutoCompleteBaseProps extends Omit<SelectTriggerProps, 'active'
|
|
|
178
183
|
*/
|
|
179
184
|
onLeaveBottom?: () => void;
|
|
180
185
|
/**
|
|
181
|
-
* Called on blur
|
|
182
|
-
*
|
|
183
|
-
*
|
|
186
|
+
* Called when the dropdown closes (on blur or Escape) and `addable` mode has
|
|
187
|
+
* items that were created but never selected.
|
|
188
|
+
* Receives the cleaned options array with unselected created items already removed.
|
|
189
|
+
* Use this to sync your options state and strip the dangling created entries.
|
|
184
190
|
* Only called when `addable` is true and there are unselected created items.
|
|
185
191
|
*/
|
|
186
192
|
onRemoveCreated?(cleanedOptions: SelectValue[]): void;
|
|
@@ -243,9 +249,67 @@ export type AutoCompleteSingleProps = AutoCompleteBaseProps & {
|
|
|
243
249
|
};
|
|
244
250
|
export type AutoCompleteProps = AutoCompleteMultipleProps | AutoCompleteSingleProps;
|
|
245
251
|
/**
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
252
|
+
* 自動完成輸入元件,在使用者輸入時即時顯示符合的下拉選項。
|
|
253
|
+
*
|
|
254
|
+
* 支援 `single`(單選)與 `multiple`(多選標籤)兩種模式;`inputPosition` 控制搜尋輸入框
|
|
255
|
+
* 位於下拉選單外(`'outside'`,預設)或內(`'inside'`)。設定 `addable` 與 `onInsert`
|
|
256
|
+
* 可讓使用者動態建立不在選項清單中的項目。`asyncData` 搭配 `onSearch` 可實現非同步搜尋,
|
|
257
|
+
* 輸入時觸發 debounce 查詢並顯示 loading 狀態。若僅需從固定選項中搜尋,請改用 `Select` 元件。
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```tsx
|
|
261
|
+
* import AutoComplete from '@mezzanine-ui/react/AutoComplete';
|
|
262
|
+
*
|
|
263
|
+
* // 單選基本用法
|
|
264
|
+
* <AutoComplete
|
|
265
|
+
* mode="single"
|
|
266
|
+
* options={[{ id: '1', name: 'Apple' }, { id: '2', name: 'Banana' }]}
|
|
267
|
+
* value={selected}
|
|
268
|
+
* onChange={setSelected}
|
|
269
|
+
* placeholder="請搜尋..."
|
|
270
|
+
* />
|
|
271
|
+
*
|
|
272
|
+
* // 多選模式
|
|
273
|
+
* <AutoComplete
|
|
274
|
+
* mode="multiple"
|
|
275
|
+
* options={options}
|
|
276
|
+
* value={selectedList}
|
|
277
|
+
* onChange={setSelectedList}
|
|
278
|
+
* />
|
|
279
|
+
*
|
|
280
|
+
* // 搜尋框置於下拉選單內(inside 模式)
|
|
281
|
+
* <AutoComplete
|
|
282
|
+
* mode="multiple"
|
|
283
|
+
* inputPosition="inside"
|
|
284
|
+
* options={options}
|
|
285
|
+
* value={selectedList}
|
|
286
|
+
* onChange={setSelectedList}
|
|
287
|
+
* />
|
|
288
|
+
*
|
|
289
|
+
* // 非同步搜尋
|
|
290
|
+
* <AutoComplete
|
|
291
|
+
* mode="single"
|
|
292
|
+
* asyncData
|
|
293
|
+
* options={asyncOptions}
|
|
294
|
+
* onSearch={async (text) => { const res = await fetchOptions(text); setAsyncOptions(res); }}
|
|
295
|
+
* value={selected}
|
|
296
|
+
* onChange={setSelected}
|
|
297
|
+
* />
|
|
298
|
+
*
|
|
299
|
+
* // 可新增選項
|
|
300
|
+
* <AutoComplete
|
|
301
|
+
* mode="multiple"
|
|
302
|
+
* addable
|
|
303
|
+
* options={options}
|
|
304
|
+
* onInsert={(text, current) => [...current, { id: text, name: text }]}
|
|
305
|
+
* value={selectedList}
|
|
306
|
+
* onChange={setSelectedList}
|
|
307
|
+
* />
|
|
308
|
+
* ```
|
|
309
|
+
*
|
|
310
|
+
* @see {@link Select} 從固定選項清單中選取時使用
|
|
311
|
+
* @see {@link Input} 純文字輸入欄位
|
|
312
|
+
* @see {@link useAutoCompleteValueControl} 管理 AutoComplete 內部值狀態的 hook
|
|
249
313
|
*/
|
|
250
314
|
declare const AutoComplete: import("react").ForwardRefExoticComponent<AutoCompleteProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
251
315
|
export default AutoComplete;
|