@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.
Files changed (213) hide show
  1. package/Accordion/Accordion.d.ts +36 -0
  2. package/Accordion/Accordion.js +37 -1
  3. package/AlertBanner/AlertBanner.d.ts +30 -1
  4. package/AlertBanner/AlertBanner.js +56 -12
  5. package/AutoComplete/AutoComplete.d.ts +75 -11
  6. package/AutoComplete/AutoComplete.js +145 -25
  7. package/AutoComplete/AutoCompleteInside.d.ts +54 -0
  8. package/AutoComplete/AutoCompleteInside.js +17 -0
  9. package/AutoComplete/useAutoCompleteKeyboard.d.ts +2 -1
  10. package/AutoComplete/useAutoCompleteKeyboard.js +4 -1
  11. package/Backdrop/Backdrop.d.ts +33 -1
  12. package/Backdrop/Backdrop.js +33 -1
  13. package/Badge/Badge.d.ts +26 -1
  14. package/Badge/Badge.js +26 -1
  15. package/Badge/typings.d.ts +15 -0
  16. package/Breadcrumb/BreadcrumbDropdown.d.ts +1 -1
  17. package/Breadcrumb/BreadcrumbOverflowMenuDropdown.d.ts +1 -1
  18. package/Breadcrumb/typings.d.ts +1 -1
  19. package/Button/Button.d.ts +26 -1
  20. package/Button/Button.js +33 -5
  21. package/COMPONENTS.md +267 -0
  22. package/Calendar/useCalendarControls.d.ts +18 -0
  23. package/Calendar/useCalendarControls.js +18 -0
  24. package/Card/FourThumbnailCard.js +1 -1
  25. package/Card/SingleThumbnailCard.js +1 -1
  26. package/Checkbox/Checkbox.d.ts +30 -1
  27. package/Checkbox/Checkbox.js +54 -4
  28. package/Checkbox/CheckboxGroup.d.ts +39 -1
  29. package/Checkbox/CheckboxGroup.js +49 -3
  30. package/Cropper/Cropper.d.ts +2 -2
  31. package/Cropper/Cropper.js +2 -3
  32. package/Cropper/CropperElement.js +1 -1
  33. package/Cropper/utils/cropper-calculations.d.ts +1 -1
  34. package/Cropper/utils/cropper-calculations.js +16 -14
  35. package/DatePicker/DatePicker.d.ts +36 -2
  36. package/DatePicker/DatePicker.js +36 -2
  37. package/DateRangePicker/useDateRangePickerValue.d.ts +24 -0
  38. package/DateRangePicker/useDateRangePickerValue.js +24 -0
  39. package/Description/Description.d.ts +1 -1
  40. package/Description/Description.js +1 -1
  41. package/Description/DescriptionTitle.d.ts +6 -1
  42. package/Description/DescriptionTitle.js +2 -2
  43. package/Drawer/Drawer.d.ts +78 -33
  44. package/Drawer/Drawer.js +72 -34
  45. package/Dropdown/Dropdown.d.ts +63 -1
  46. package/Dropdown/Dropdown.js +203 -9
  47. package/Dropdown/DropdownItem.d.ts +26 -2
  48. package/Dropdown/DropdownItem.js +91 -43
  49. package/Dropdown/DropdownItemCard.d.ts +3 -2
  50. package/Dropdown/DropdownItemCard.js +8 -5
  51. package/Dropdown/DropdownStatus.d.ts +2 -2
  52. package/Dropdown/DropdownStatus.js +3 -2
  53. package/Dropdown/dropdownKeydownHandler.d.ts +6 -0
  54. package/Dropdown/dropdownKeydownHandler.js +14 -7
  55. package/Empty/icons/EmptyMainInitialDataIcon.js +1 -1
  56. package/Empty/icons/EmptyMainNotificationIcon.js +1 -1
  57. package/Empty/icons/EmptyMainResultIcon.js +1 -1
  58. package/Empty/icons/EmptyMainSystemIcon.js +1 -1
  59. package/FilterArea/Filter.d.ts +25 -2
  60. package/FilterArea/Filter.js +43 -2
  61. package/FilterArea/FilterArea.d.ts +43 -4
  62. package/FilterArea/FilterArea.js +39 -4
  63. package/FilterArea/FilterAreaContext.d.ts +6 -0
  64. package/FilterArea/FilterAreaContext.js +6 -0
  65. package/FilterArea/FilterLine.d.ts +19 -0
  66. package/FilterArea/FilterLine.js +19 -0
  67. package/FilterArea/index.d.ts +2 -2
  68. package/FilterArea/index.js +1 -1
  69. package/Form/FormField.d.ts +43 -2
  70. package/Form/FormField.js +40 -3
  71. package/Form/typings.d.ts +2 -0
  72. package/Form/useAutoCompleteValueControl.d.ts +20 -0
  73. package/Form/useAutoCompleteValueControl.js +20 -0
  74. package/Form/useCheckboxControlValue.d.ts +19 -0
  75. package/Form/useCheckboxControlValue.js +19 -0
  76. package/Form/useControlValueState.d.ts +16 -0
  77. package/Form/useControlValueState.js +16 -0
  78. package/Form/useCustomControlValue.d.ts +17 -0
  79. package/Form/useCustomControlValue.js +17 -0
  80. package/Form/useInputControlValue.d.ts +19 -0
  81. package/Form/useInputControlValue.js +19 -0
  82. package/Form/useInputWithClearControlValue.d.ts +20 -0
  83. package/Form/useInputWithClearControlValue.js +20 -0
  84. package/Form/useRadioControlValue.d.ts +19 -0
  85. package/Form/useRadioControlValue.js +19 -0
  86. package/Form/useSelectValueControl.d.ts +19 -0
  87. package/Form/useSelectValueControl.js +19 -0
  88. package/Form/useSwitchControlValue.d.ts +18 -0
  89. package/Form/useSwitchControlValue.js +18 -0
  90. package/Icon/Icon.d.ts +23 -1
  91. package/Icon/Icon.js +23 -1
  92. package/Input/Input.d.ts +31 -1
  93. package/Input/Input.js +31 -1
  94. package/Input/SpinnerButton/SpinnerButton.js +1 -1
  95. package/Message/Message.d.ts +56 -6
  96. package/Message/Message.js +59 -52
  97. package/Modal/Modal.d.ts +76 -4
  98. package/Modal/Modal.js +117 -6
  99. package/Modal/ModalBodyForVerification.js +3 -1
  100. package/Modal/ModalFooter.d.ts +21 -6
  101. package/Modal/ModalHeader.d.ts +50 -11
  102. package/Modal/ModalHeader.js +1 -1
  103. package/Modal/index.d.ts +1 -1
  104. package/Navigation/Navigation.js +20 -11
  105. package/Navigation/NavigationHeader.js +2 -1
  106. package/Navigation/NavigationIconButton.d.ts +8 -0
  107. package/Navigation/NavigationIconButton.js +2 -2
  108. package/Navigation/NavigationOption.js +6 -3
  109. package/Navigation/NavigationOverflowMenu.js +9 -6
  110. package/Navigation/NavigationUserMenu.js +3 -1
  111. package/Navigation/context.d.ts +1 -0
  112. package/NotificationCenter/NotificationCenter.d.ts +59 -9
  113. package/NotificationCenter/NotificationCenter.js +150 -54
  114. package/NotificationCenter/NotificationCenterDrawer.d.ts +56 -6
  115. package/NotificationCenter/NotificationCenterDrawer.js +6 -8
  116. package/NotificationCenter/index.d.ts +1 -1
  117. package/OverflowTooltip/OverflowTooltip.js +46 -5
  118. package/PageFooter/PageFooter.d.ts +1 -1
  119. package/PageFooter/PageFooter.js +8 -16
  120. package/Pagination/Pagination.d.ts +38 -1
  121. package/Pagination/Pagination.js +38 -1
  122. package/Pagination/PaginationPageSize.js +1 -1
  123. package/Pagination/usePagination.d.ts +20 -0
  124. package/Pagination/usePagination.js +20 -0
  125. package/Progress/Progress.d.ts +24 -1
  126. package/Progress/Progress.js +24 -1
  127. package/README.md +82 -0
  128. package/Radio/Radio.d.ts +35 -1
  129. package/Radio/Radio.js +50 -12
  130. package/Radio/RadioGroup.d.ts +2 -2
  131. package/Radio/RadioGroupContext.d.ts +3 -2
  132. package/Section/SectionGroup.d.ts +20 -0
  133. package/Section/SectionGroup.js +16 -0
  134. package/Section/index.d.ts +2 -0
  135. package/Section/index.js +1 -0
  136. package/Select/Select.d.ts +55 -1
  137. package/Select/Select.js +37 -2
  138. package/Select/typings.d.ts +9 -0
  139. package/{Selection/Selection.d.ts → SelectionCard/SelectionCard.d.ts} +23 -11
  140. package/{Selection/Selection.js → SelectionCard/SelectionCard.js} +14 -14
  141. package/SelectionCard/SelectionCardGroup.d.ts +28 -0
  142. package/SelectionCard/index.d.ts +12 -0
  143. package/SelectionCard/index.js +5 -0
  144. package/Separator/Separator.d.ts +19 -1
  145. package/Separator/Separator.js +19 -1
  146. package/Slider/Slider.d.ts +11 -0
  147. package/Slider/useSlider.d.ts +21 -0
  148. package/Spin/Spin.d.ts +14 -5
  149. package/Spin/Spin.js +6 -8
  150. package/Stepper/Stepper.d.ts +34 -1
  151. package/Stepper/Stepper.js +34 -1
  152. package/Stepper/useStepper.d.ts +18 -0
  153. package/Stepper/useStepper.js +18 -0
  154. package/Tab/Tab.d.ts +33 -1
  155. package/Tab/Tab.js +33 -1
  156. package/Table/Table.d.ts +51 -3
  157. package/Table/Table.js +52 -4
  158. package/Table/hooks/useTableDataSource.d.ts +4 -4
  159. package/Table/hooks/useTableDataSource.js +1 -1
  160. package/Tag/Tag.d.ts +27 -1
  161. package/Tag/Tag.js +27 -1
  162. package/Tag/typings.d.ts +28 -0
  163. package/Textarea/Textarea.d.ts +28 -1
  164. package/Textarea/Textarea.js +25 -1
  165. package/TimePicker/TimePicker.js +1 -1
  166. package/TimeRangePicker/TimeRangePicker.js +1 -1
  167. package/Toggle/Toggle.d.ts +34 -1
  168. package/Toggle/Toggle.js +34 -1
  169. package/Tooltip/Tooltip.d.ts +39 -1
  170. package/Tooltip/Tooltip.js +39 -1
  171. package/Tooltip/useDelayMouseEnterLeave.d.ts +17 -0
  172. package/Tooltip/useDelayMouseEnterLeave.js +17 -0
  173. package/Typography/Typography.d.ts +23 -1
  174. package/Typography/Typography.js +23 -1
  175. package/Upload/Upload.d.ts +13 -7
  176. package/Upload/Upload.js +55 -20
  177. package/Upload/UploadItem.d.ts +3 -3
  178. package/Upload/UploadItem.js +11 -8
  179. package/Upload/UploadPictureCard.d.ts +5 -0
  180. package/Upload/UploadPictureCard.js +10 -6
  181. package/Upload/Uploader.d.ts +32 -31
  182. package/Upload/Uploader.js +10 -9
  183. package/hooks/useClickAway.d.ts +16 -0
  184. package/hooks/useClickAway.js +16 -0
  185. package/hooks/useComposeRefs.d.ts +15 -0
  186. package/hooks/useComposeRefs.js +15 -0
  187. package/hooks/useDocumentEscapeKeyDown.d.ts +15 -0
  188. package/hooks/useDocumentEscapeKeyDown.js +15 -0
  189. package/hooks/useDocumentEvents.d.ts +16 -0
  190. package/hooks/useDocumentEvents.js +16 -0
  191. package/hooks/useDocumentTabKeyDown.d.ts +15 -0
  192. package/hooks/useDocumentTabKeyDown.js +15 -0
  193. package/hooks/useIsomorphicLayoutEffect.d.ts +16 -0
  194. package/hooks/useIsomorphicLayoutEffect.js +16 -0
  195. package/hooks/useLastCallback.d.ts +15 -0
  196. package/hooks/useLastCallback.js +15 -0
  197. package/hooks/useLastValue.d.ts +18 -0
  198. package/hooks/useLastValue.js +18 -0
  199. package/hooks/usePreviousValue.d.ts +14 -0
  200. package/hooks/usePreviousValue.js +14 -0
  201. package/hooks/useScrollLock.d.ts +6 -4
  202. package/hooks/useScrollLock.js +6 -4
  203. package/hooks/useTopStack.d.ts +17 -0
  204. package/hooks/useTopStack.js +17 -0
  205. package/hooks/useWindowWidth.d.ts +14 -0
  206. package/hooks/useWindowWidth.js +14 -0
  207. package/index.d.ts +6 -4
  208. package/index.js +3 -2
  209. package/llms.txt +200 -0
  210. package/package.json +5 -4
  211. package/Selection/SelectionGroup.d.ts +0 -28
  212. package/Selection/index.d.ts +0 -12
  213. package/Selection/index.js +0 -5
@@ -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;
@@ -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
- * The react component for `mezzanine` alert banner.
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
- * The react component for `mezzanine` alert banner.
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
- setIsExiting(true);
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 && !isExiting && nodeRef.current) {
58
- // Force reflow to ensure initial state is applied
59
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
60
- nodeRef.current.offsetHeight;
61
- // Trigger entering animation in next frame
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
- setIsEntering(true);
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, isExiting]);
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), isExiting && alertBannerClasses.exiting, isEntering && !isExiting && alertBannerClasses.entering, 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] })] }));
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
- * insert callback whenever insert icon is clicked
90
- * receives the text to insert and current options, returns the updated options array
91
- * should remove previously created but unselected options
92
- * The returned options will be used to update the component's options prop
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 when addable mode has unselected created items.
182
- * Receives the cleaned options (unselected created items already removed).
183
- * Use this to update your options state.
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
- * The AutoComplete component for react. <br />
247
- * Note that if you need search for ONLY given options, not included your typings,
248
- * should considering using the `Select` component with `onSearch` prop.
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;