@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
@@ -1,2 +1,4 @@
1
1
  export type { SectionProps } from './Section';
2
2
  export { default } from './Section';
3
+ export { default as SectionGroup } from './SectionGroup';
4
+ export type { SectionGroupProps } from './SectionGroup';
package/Section/index.js CHANGED
@@ -1 +1,2 @@
1
1
  export { default } from './Section.js';
2
+ export { default as SectionGroup } from './SectionGroup.js';
@@ -1,4 +1,4 @@
1
- import { DropdownOption, DropdownType } from '@mezzanine-ui/core/dropdown/dropdown';
1
+ import { DropdownLoadingPosition, DropdownOption, DropdownType } from '@mezzanine-ui/core/dropdown/dropdown';
2
2
  import { SelectInputSize } from '@mezzanine-ui/core/select';
3
3
  import { FormElementFocusHandlers } from '../Form';
4
4
  import { SelectTriggerInputProps, SelectTriggerProps, SelectValue } from './typings';
@@ -59,6 +59,28 @@ export interface SelectBaseProps extends Omit<SelectTriggerProps, 'active' | 'in
59
59
  * @default true
60
60
  */
61
61
  globalPortal?: boolean;
62
+ /**
63
+ * Whether the dropdown is in a loading state.
64
+ * @default false
65
+ */
66
+ loading?: boolean;
67
+ /**
68
+ * The position of the loading indicator.
69
+ * @default 'bottom'
70
+ */
71
+ loadingPosition?: DropdownLoadingPosition;
72
+ /**
73
+ * The text displayed while loading.
74
+ */
75
+ loadingText?: string;
76
+ /**
77
+ * Callback fired when the dropdown list leaves the bottom.
78
+ */
79
+ onLeaveBottom?: () => void;
80
+ /**
81
+ * Callback fired when the dropdown list reaches the bottom.
82
+ */
83
+ onReachBottom?: () => void;
62
84
  }
63
85
  export type SelectMultipleProps = SelectBaseProps & {
64
86
  /**
@@ -107,5 +129,37 @@ export type SelectSingleProps = SelectBaseProps & {
107
129
  value?: SelectValue | null;
108
130
  };
109
131
  export type SelectProps = SelectMultipleProps | SelectSingleProps;
132
+ /**
133
+ * 下拉選擇元件,支援單選與多選兩種模式。
134
+ *
135
+ * 透過 `mode` 切換 `single`(單選,預設)或 `multiple`(多選,以標籤呈現已選項目)。
136
+ * 傳入 `options` 陣列即可自動建立下拉選單;多選模式下若 options 含有 `children` 巢狀結構,
137
+ * 會自動切換為樹狀選取(`type: 'tree'`)並為所有選項加上勾選框。
138
+ * 支援 `clearable`、`readOnly`、`loading` 狀態,以及透過 `renderValue` 自訂顯示文字。
139
+ *
140
+ * @example
141
+ * ```tsx
142
+ * import Select from '@mezzanine-ui/react/Select';
143
+ *
144
+ * const options = [
145
+ * { id: '1', name: '選項一' },
146
+ * { id: '2', name: '選項二' },
147
+ * { id: '3', name: '選項三' },
148
+ * ];
149
+ *
150
+ * // 單選
151
+ * <Select options={options} placeholder="請選擇" onChange={(val) => console.log(val)} />
152
+ *
153
+ * // 多選
154
+ * <Select mode="multiple" options={options} placeholder="可多選" onChange={(vals) => console.log(vals)} />
155
+ *
156
+ * // 帶搜尋功能(搭配 AutoComplete)
157
+ * <Select options={options} clearable placeholder="選擇或搜尋" />
158
+ * ```
159
+ *
160
+ * @see {@link AutoComplete} 支援自由輸入文字的搜尋下拉元件
161
+ * @see {@link Dropdown} Select 底層使用的下拉清單容器元件
162
+ * @see {@link useSelectValueControl} 用於在受控模式下管理選取值的 Hook
163
+ */
110
164
  declare const Select: import("react").ForwardRefExoticComponent<SelectProps & import("react").RefAttributes<HTMLDivElement>>;
111
165
  export default Select;
package/Select/Select.js CHANGED
@@ -11,9 +11,44 @@ import { FormControlContext } from '../Form/FormControlContext.js';
11
11
  import Dropdown from '../Dropdown/Dropdown.js';
12
12
  import cx from 'clsx';
13
13
 
14
+ /**
15
+ * 下拉選擇元件,支援單選與多選兩種模式。
16
+ *
17
+ * 透過 `mode` 切換 `single`(單選,預設)或 `multiple`(多選,以標籤呈現已選項目)。
18
+ * 傳入 `options` 陣列即可自動建立下拉選單;多選模式下若 options 含有 `children` 巢狀結構,
19
+ * 會自動切換為樹狀選取(`type: 'tree'`)並為所有選項加上勾選框。
20
+ * 支援 `clearable`、`readOnly`、`loading` 狀態,以及透過 `renderValue` 自訂顯示文字。
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * import Select from '@mezzanine-ui/react/Select';
25
+ *
26
+ * const options = [
27
+ * { id: '1', name: '選項一' },
28
+ * { id: '2', name: '選項二' },
29
+ * { id: '3', name: '選項三' },
30
+ * ];
31
+ *
32
+ * // 單選
33
+ * <Select options={options} placeholder="請選擇" onChange={(val) => console.log(val)} />
34
+ *
35
+ * // 多選
36
+ * <Select mode="multiple" options={options} placeholder="可多選" onChange={(vals) => console.log(vals)} />
37
+ *
38
+ * // 帶搜尋功能(搭配 AutoComplete)
39
+ * <Select options={options} clearable placeholder="選擇或搜尋" />
40
+ * ```
41
+ *
42
+ * @see {@link AutoComplete} 支援自由輸入文字的搜尋下拉元件
43
+ * @see {@link Dropdown} Select 底層使用的下拉清單容器元件
44
+ * @see {@link useSelectValueControl} 用於在受控模式下管理選取值的 Hook
45
+ */
14
46
  const Select = forwardRef(function Select(props, ref) {
15
47
  const { disabled: disabledFromFormControl, fullWidth: fullWidthFromFormControl, required: requiredFromFormControl, severity, } = useContext(FormControlContext) || {};
16
- const { className, clearable = false, defaultValue, disabled = disabledFromFormControl || false, error = severity === 'error' || false, fullWidth = fullWidthFromFormControl || false, inputProps, inputRef, menuMaxHeight, mode = 'single', onBlur, onChange: onChangeProp, onClear: onClearProp, onFocus, onScroll, options: optionsProp, placeholder = '', prefix, readOnly = false, renderValue, required = requiredFromFormControl || false, size, suffixActionIcon, type = 'default', value: valueProp, dropdownZIndex, globalPortal = true, } = props;
48
+ const { className, clearable = false, defaultValue, disabled = disabledFromFormControl || false, error = severity === 'error' || false, fullWidth = fullWidthFromFormControl || false, inputProps, inputRef, loading = false, loadingPosition = 'bottom', loadingText, menuMaxHeight, mode = 'single', onBlur, onChange: onChangeProp, onClear: onClearProp, onFocus, onLeaveBottom, onReachBottom, onScroll, options: optionsProp, placeholder = '', prefix, readOnly = false, renderValue, required = requiredFromFormControl || false, overflowStrategy, size, suffixActionIcon, type = 'default', value: valueProp, dropdownZIndex, globalPortal = true, } = props;
49
+ const dropdownStatus = loading
50
+ ? 'loading'
51
+ : undefined;
17
52
  const [open, toggleOpen] = useState(false);
18
53
  const onOpen = useCallback(() => {
19
54
  // Prevent opening when readOnly is true
@@ -221,7 +256,7 @@ const Select = forwardRef(function Select(props, ref) {
221
256
  onChange,
222
257
  value,
223
258
  }), [onChange, value]);
224
- return (jsx(SelectControlContext.Provider, { value: context, children: jsx("div", { ref: nodeRef, className: cx(selectClasses.host, fullWidth && selectClasses.hostFullWidth, mode && selectClasses.hostMode(mode)), children: jsx(Dropdown, { disabled: readOnly || disabled, maxHeight: menuMaxHeight, mode: mode, onScroll: onScroll, onSelect: handleDropdownSelect, onVisibilityChange: handleVisibilityChange, open: readOnly ? false : open, options: options, sameWidth: true, type: dropdownType, value: dropdownValue, zIndex: dropdownZIndex, globalPortal: globalPortal, children: jsx(SelectTrigger, { ref: composedRef, active: !readOnly && open, className: className, clearable: clearable, disabled: disabled, error: error, fullWidth: fullWidth, inputRef: inputRef, mode: mode, onTagClose: onChange, onClear: onClear, onKeyDown: onKeyDownTextField, prefix: prefix, readOnly: readOnly, ...(mode === 'single' && renderValue ? { renderValue } : {}), required: required, inputProps: resolvedInputProps, size: size, suffixActionIcon: suffixActionIcon, value: value === null ? undefined : value, placeholder: getPlaceholder() }) }) }) }));
259
+ return (jsx(SelectControlContext.Provider, { value: context, children: jsx("div", { ref: nodeRef, className: cx(selectClasses.host, fullWidth && selectClasses.hostFullWidth, mode && selectClasses.hostMode(mode)), children: jsx(Dropdown, { disabled: readOnly || disabled, globalPortal: globalPortal, loadingPosition: loadingPosition, loadingText: loadingText, maxHeight: menuMaxHeight, mode: mode, onLeaveBottom: onLeaveBottom, onReachBottom: onReachBottom, onScroll: onScroll, onSelect: handleDropdownSelect, onVisibilityChange: handleVisibilityChange, open: readOnly ? false : open, options: options, sameWidth: true, status: dropdownStatus, type: dropdownType, value: dropdownValue, zIndex: dropdownZIndex, children: jsx(SelectTrigger, { ref: composedRef, active: !readOnly && open, className: className, clearable: clearable, disabled: disabled, error: error, fullWidth: fullWidth, inputRef: inputRef, mode: mode, onTagClose: onChange, onClear: onClear, onKeyDown: onKeyDownTextField, prefix: prefix, readOnly: readOnly, ...(mode === 'single' && renderValue ? { renderValue } : {}), required: required, inputProps: resolvedInputProps, overflowStrategy: overflowStrategy, size: size, suffixActionIcon: suffixActionIcon, value: value === null ? undefined : value, placeholder: getPlaceholder() }) }) }) }));
225
260
  });
226
261
 
227
262
  export { Select as default };
@@ -4,11 +4,15 @@ import Icon, { IconProps } from '../Icon';
4
4
  import { TextFieldProps } from '../TextField';
5
5
  import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
6
6
  export interface SelectValue<T = string> {
7
+ /** 選項的唯一識別值。 */
7
8
  id: T;
9
+ /** 選項的顯示文字。 */
8
10
  name: string;
9
11
  }
10
12
  export interface SelectControl<T = string> {
13
+ /** 當前選取的值,單選為 SelectValue | null,多選為 SelectValue[]。 */
11
14
  value: SelectValue<T>[] | SelectValue<T> | null;
15
+ /** 選取變更時的回呼函式。 */
12
16
  onChange: (v: SelectValue<T> | null) => SelectValue<T>[] | SelectValue<T> | null;
13
17
  }
14
18
  export type SelectTriggerInputProps = Omit<NativeElementPropsWithoutKeyAndRef<'input'>, 'autoComplete' | 'children' | 'defaultValue' | 'disabled' | 'required' | 'type' | 'value' | `aria-${'autocomplete' | 'disabled' | 'haspopup' | 'multiline' | 'required'}`>;
@@ -59,7 +63,12 @@ export interface SelectTriggerBaseProps extends Omit<TextFieldProps, 'active' |
59
63
  * @default false
60
64
  */
61
65
  required?: boolean;
66
+ /** 觸發器輸入框中的搜尋/篩選文字,用於過濾下拉選項。 */
62
67
  searchText?: string;
68
+ /**
69
+ * 多選模式下是否在已選標籤後顯示文字輸入框,啟用行內搜尋。
70
+ * @default false
71
+ */
63
72
  showTextInputAfterTags?: boolean;
64
73
  /** Suffix icon click event handler */
65
74
  suffixAction?: VoidFunction;
@@ -1,8 +1,8 @@
1
- import { ChangeEventHandler, MouseEvent, Ref } from 'react';
1
+ import { CSSProperties, ChangeEventHandler, MouseEvent, Ref } from 'react';
2
2
  import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
3
- import { SelectionDirection, SelectionImageObjectFit, SelectionType } from '@mezzanine-ui/core/selection';
3
+ import { SelectionCardDirection, SelectionCardImageObjectFit, SelectionCardType } from '@mezzanine-ui/core/selection-card';
4
4
  import type { IconDefinition } from '@mezzanine-ui/icons';
5
- export interface SelectionPropsBase extends Omit<NativeElementPropsWithoutKeyAndRef<'label'>, 'onChange'> {
5
+ export interface SelectionCardPropsBase extends Omit<NativeElementPropsWithoutKeyAndRef<'label'>, 'onChange'> {
6
6
  /**
7
7
  * Whether the selection is checked.
8
8
  */
@@ -16,7 +16,7 @@ export interface SelectionPropsBase extends Omit<NativeElementPropsWithoutKeyAnd
16
16
  * The type of selection.
17
17
  * @default 'radio'
18
18
  */
19
- selector: SelectionType;
19
+ selector: SelectionCardType;
20
20
  /**
21
21
  * If true, selection will be disabled
22
22
  * @default false
@@ -26,7 +26,7 @@ export interface SelectionPropsBase extends Omit<NativeElementPropsWithoutKeyAnd
26
26
  * The direction of selection.
27
27
  * @default 'horizontal'
28
28
  */
29
- direction?: SelectionDirection;
29
+ direction?: SelectionCardDirection;
30
30
  /**
31
31
  * The image of selection. Supports image URL.
32
32
  */
@@ -35,7 +35,7 @@ export interface SelectionPropsBase extends Omit<NativeElementPropsWithoutKeyAnd
35
35
  * The object fit of selection image.
36
36
  * @default 'cover'
37
37
  */
38
- imageObjectFit?: SelectionImageObjectFit;
38
+ imageObjectFit?: SelectionCardImageObjectFit;
39
39
  /**
40
40
  * The custom icon of selection.
41
41
  */
@@ -54,10 +54,22 @@ export interface SelectionPropsBase extends Omit<NativeElementPropsWithoutKeyAnd
54
54
  * The accessible text of selection.
55
55
  */
56
56
  text: string;
57
+ /**
58
+ * The max width of the text element.
59
+ * @example '112px' // 8 Chinese characters at 14px
60
+ * @example '168px' // 24 English letters at 14px
61
+ */
62
+ textMaxWidth?: CSSProperties['maxWidth'];
57
63
  /**
58
64
  * The accessible description of selection.
59
65
  */
60
66
  supportingText?: string;
67
+ /**
68
+ * The max width of the supporting text element.
69
+ * @example '144px' // 12 Chinese characters at 12px
70
+ * @example '216px' // 36 English letters at 12px
71
+ */
72
+ supportingTextMaxWidth?: CSSProperties['maxWidth'];
61
73
  /**
62
74
  * Whether the selection is readonly.
63
75
  * @default false
@@ -76,7 +88,7 @@ export interface SelectionPropsBase extends Omit<NativeElementPropsWithoutKeyAnd
76
88
  * @important When using with react-hook-form's `register`, pass the ref through this prop:
77
89
  * ```tsx
78
90
  * const { register } = useForm();
79
- * <Selection inputRef={register('fieldName').ref} name="fieldName" />
91
+ * <SelectionCard inputRef={register('fieldName').ref} name="fieldName" />
80
92
  * ```
81
93
  */
82
94
  inputRef?: Ref<HTMLInputElement>;
@@ -85,14 +97,14 @@ export interface SelectionPropsBase extends Omit<NativeElementPropsWithoutKeyAnd
85
97
  */
86
98
  onChange?: ChangeEventHandler<HTMLInputElement>;
87
99
  }
88
- export interface SelectionProps extends SelectionPropsBase {
100
+ export interface SelectionCardProps extends SelectionCardPropsBase {
89
101
  /**
90
102
  * Callback when the selection is clicked.
91
103
  */
92
104
  onClick?: (event: MouseEvent<HTMLLabelElement>) => void;
93
105
  }
94
106
  /**
95
- * The react component for `mezzanine` selection.
107
+ * The react component for `mezzanine` selection card.
96
108
  */
97
- declare const Selection: import("react").ForwardRefExoticComponent<SelectionProps & import("react").RefAttributes<HTMLLabelElement>>;
98
- export default Selection;
109
+ declare const SelectionCard: import("react").ForwardRefExoticComponent<SelectionCardProps & import("react").RefAttributes<HTMLLabelElement>>;
110
+ export default SelectionCard;
@@ -2,19 +2,19 @@
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { forwardRef, useId, useMemo } from 'react';
4
4
  import Typography from '../Typography/Typography.js';
5
- import { selectionClasses } from '@mezzanine-ui/core/selection';
5
+ import { selectionCardClasses } from '@mezzanine-ui/core/selection-card';
6
6
  import { FileIcon } from '@mezzanine-ui/icons';
7
7
  import Icon from '../Icon/Icon.js';
8
8
  import cx from 'clsx';
9
9
 
10
- // Icon size constant for Selection component
10
+ // Icon size constant for SelectionCard component
11
11
  // Note: This value is component-specific and doesn't have a corresponding design token
12
12
  const SELECTION_ICON_SIZE = 26;
13
13
  /**
14
- * The react component for `mezzanine` selection.
14
+ * The react component for `mezzanine` selection card.
15
15
  */
16
- const Selection = forwardRef(function Selection(props, ref) {
17
- const { checked: checkedProp, className, defaultChecked = false, disabled = false, direction = 'horizontal', id, image, imageObjectFit = 'cover', inputRef: inputRefProp, name, onChange: onChangeProp, readonly = false, selector = 'radio', supportingText, text, value, customIcon, onClick, ...rest } = props;
16
+ const SelectionCard = forwardRef(function SelectionCard(props, ref) {
17
+ const { checked: checkedProp, className, defaultChecked = false, disabled = false, direction = 'horizontal', id, image, imageObjectFit = 'cover', inputRef: inputRefProp, name, onChange: onChangeProp, readonly = false, selector = 'radio', supportingText, supportingTextMaxWidth, text, textMaxWidth, value, customIcon, onClick, ...rest } = props;
18
18
  const generatedId = useId();
19
19
  const inputId = id !== null && id !== void 0 ? id : generatedId;
20
20
  const textId = useMemo(() => `${inputId}-text`, [inputId]);
@@ -25,22 +25,22 @@ const Selection = forwardRef(function Selection(props, ref) {
25
25
  };
26
26
  const haveImage = useMemo(() => Boolean(image && typeof image === 'string' && image.trim().length > 0), [image]);
27
27
  if (!text) {
28
- console.error('Selection: `text` (title) is required.');
28
+ console.error('SelectionCard: `text` (title) is required.');
29
29
  return null;
30
30
  }
31
31
  if (!supportingText) {
32
- console.warn('Selection: `supportingText` is optional but strongly recommended for better accessibility.');
32
+ console.warn('SelectionCard: `supportingText` is optional but strongly recommended for better accessibility.');
33
33
  }
34
- return (jsxs("label", { ...rest, ref: ref, htmlFor: inputId, className: cx(selectionClasses.host, selectionClasses.direction(direction), {
35
- [selectionClasses.disabled]: disabled,
36
- [selectionClasses.readonly]: readonly,
37
- }, className), ...(disabled && { 'aria-disabled': true }), ...(onClick && { onClick }), children: [jsxs("div", { className: selectionClasses.container, children: [haveImage
38
- ? jsx("img", { src: image, alt: text, className: selectionClasses.selectionImage, style: { objectFit: imageObjectFit } })
39
- : jsx(Icon, { "aria-hidden": "true", className: selectionClasses.icon, color: "neutral-solid", icon: customIcon || FileIcon, size: SELECTION_ICON_SIZE }), jsxs("div", { className: selectionClasses.content, children: [jsx(Typography, { className: selectionClasses.text, color: "text-neutral-solid", display: "block", ellipsis: true, id: textId, variant: "body-highlight", children: text }), supportingText && (jsx(Typography, { className: selectionClasses.supportingText, color: "text-neutral", display: "block", ellipsis: true, id: supportingTextId, variant: "caption", children: supportingText }))] })] }), !readonly && (jsx("input", { ref: inputRefProp, type: selector, name: name, id: inputId, className: selectionClasses.input, disabled: disabled, ...(checkedProp !== undefined
34
+ return (jsxs("label", { ...rest, ref: ref, htmlFor: inputId, className: cx(selectionCardClasses.host, selectionCardClasses.direction(direction), {
35
+ [selectionCardClasses.disabled]: disabled,
36
+ [selectionCardClasses.readonly]: readonly,
37
+ }, className), ...(disabled && { 'aria-disabled': true }), ...(onClick && { onClick }), children: [jsxs("div", { className: selectionCardClasses.container, children: [haveImage
38
+ ? jsx("img", { src: image, alt: text, className: selectionCardClasses.selectionImage, style: { objectFit: imageObjectFit } })
39
+ : jsx(Icon, { "aria-hidden": "true", className: selectionCardClasses.icon, color: "neutral-solid", icon: customIcon || FileIcon, size: SELECTION_ICON_SIZE }), jsxs("div", { className: selectionCardClasses.content, children: [jsx(Typography, { className: selectionCardClasses.text, color: "text-neutral-solid", display: "block", ellipsis: true, id: textId, style: textMaxWidth !== undefined ? { maxWidth: textMaxWidth } : undefined, variant: "body-highlight", children: text }), supportingText && (jsx(Typography, { className: selectionCardClasses.supportingText, color: "text-neutral", display: "block", ellipsis: true, id: supportingTextId, style: supportingTextMaxWidth !== undefined ? { maxWidth: supportingTextMaxWidth } : undefined, variant: "caption", children: supportingText }))] })] }), !readonly && (jsx("input", { ref: inputRefProp, type: selector, name: name, id: inputId, className: selectionCardClasses.input, disabled: disabled, ...(checkedProp !== undefined
40
40
  ? { checked: checkedProp }
41
41
  : { defaultChecked }), value: value, onChange: onInputChange, ...(isRadioOrCheckbox && checkedProp !== undefined
42
42
  ? { 'aria-checked': checkedProp }
43
43
  : {}), "aria-labelledby": textId, "aria-describedby": supportingText ? supportingTextId : undefined }))] }));
44
44
  });
45
45
 
46
- export { Selection as default };
46
+ export { SelectionCard as default };
@@ -0,0 +1,28 @@
1
+ import { ComponentProps, ReactElement } from 'react';
2
+ import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
3
+ import SelectionCard, { SelectionCardProps } from './SelectionCard';
4
+ export interface SelectionCardGroupBaseProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'children'> {
5
+ /**
6
+ * The class name of the selection group.
7
+ */
8
+ className?: string;
9
+ }
10
+ export interface SelectionCardGroupProps extends SelectionCardGroupBaseProps {
11
+ /**
12
+ * The selections in the group.
13
+ * Only SelectionCard components are allowed.
14
+ * When provided, will take priority over selections prop.
15
+ */
16
+ children?: ReactElement<ComponentProps<typeof SelectionCard>> | ReactElement<ComponentProps<typeof SelectionCard>>[];
17
+ /**
18
+ * The selections array.
19
+ * When provided, SelectionCard components will be automatically rendered.
20
+ * Will be ignored if children is provided.
21
+ */
22
+ selections?: SelectionCardProps[];
23
+ }
24
+ /**
25
+ * The react component for `mezzanine` selection card group.
26
+ */
27
+ declare const SelectionCardGroup: import("react").ForwardRefExoticComponent<SelectionCardGroupProps & import("react").RefAttributes<HTMLDivElement>>;
28
+ export default SelectionCardGroup;
@@ -0,0 +1,12 @@
1
+ import { PropsWithoutRef, ReactElement, RefAttributes } from 'react';
2
+ import SelectionCard, { SelectionCardProps, SelectionCardPropsBase } from './SelectionCard';
3
+ export type { SelectionCardDirection, SelectionCardType, } from '@mezzanine-ui/core/selection-card';
4
+ export type { SelectionCardProps, SelectionCardPropsBase };
5
+ /**
6
+ * @remark
7
+ * Add type alias here for parsable to react docgen typescript.
8
+ */
9
+ type GenericSelectionCard = (props: PropsWithoutRef<SelectionCardProps> & RefAttributes<HTMLLabelElement>) => ReactElement<any>;
10
+ export { SelectionCard };
11
+ declare const _default: GenericSelectionCard;
12
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import SelectionCard from './SelectionCard.js';
2
+
3
+
4
+
5
+ export { SelectionCard, SelectionCard as default };
@@ -8,7 +8,25 @@ export interface SeparatorProps extends NativeElementPropsWithoutKeyAndRef<'hr'>
8
8
  orientation?: SeparatorOrientation;
9
9
  }
10
10
  /**
11
- * The react component for `mezzanine` separator.
11
+ * 水平或垂直分隔線元件。
12
+ *
13
+ * 以 `<hr>` 元素為基礎,透過 `orientation` prop 切換水平與垂直方向。
14
+ * 垂直方向時會自動設置 `aria-orientation="vertical"` 以符合無障礙規範。
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * import Separator from '@mezzanine-ui/react/Separator';
19
+ *
20
+ * // 水平分隔線(預設)
21
+ * <Separator />
22
+ *
23
+ * // 垂直分隔線
24
+ * <div style={{ display: 'flex', alignItems: 'center' }}>
25
+ * <span>左側內容</span>
26
+ * <Separator orientation="vertical" />
27
+ * <span>右側內容</span>
28
+ * </div>
29
+ * ```
12
30
  */
13
31
  declare const Separator: import("react").ForwardRefExoticComponent<SeparatorProps & import("react").RefAttributes<HTMLHRElement>>;
14
32
  export default Separator;
@@ -4,7 +4,25 @@ import { forwardRef } from 'react';
4
4
  import cx from 'clsx';
5
5
 
6
6
  /**
7
- * The react component for `mezzanine` separator.
7
+ * 水平或垂直分隔線元件。
8
+ *
9
+ * 以 `<hr>` 元素為基礎,透過 `orientation` prop 切換水平與垂直方向。
10
+ * 垂直方向時會自動設置 `aria-orientation="vertical"` 以符合無障礙規範。
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * import Separator from '@mezzanine-ui/react/Separator';
15
+ *
16
+ * // 水平分隔線(預設)
17
+ * <Separator />
18
+ *
19
+ * // 垂直分隔線
20
+ * <div style={{ display: 'flex', alignItems: 'center' }}>
21
+ * <span>左側內容</span>
22
+ * <Separator orientation="vertical" />
23
+ * <span>右側內容</span>
24
+ * </div>
25
+ * ```
8
26
  */
9
27
  const Separator = forwardRef(function Separator(props, ref) {
10
28
  const { className, orientation = 'horizontal', ...rest } = props;
@@ -39,9 +39,13 @@ export interface SliderBaseProps extends Omit<NativeElementPropsWithoutKeyAndRef
39
39
  withTick?: number | number[];
40
40
  }
41
41
  export type SliderWithInputProps = SliderBaseProps & {
42
+ /** 此配置下不適用。 */
42
43
  onPrefixIconClick?: never;
44
+ /** 此配置下不適用。 */
43
45
  onSuffixIconClick?: never;
46
+ /** 此配置下不適用。 */
44
47
  prefixIcon?: never;
48
+ /** 此配置下不適用。 */
45
49
  suffixIcon?: never;
46
50
  /**
47
51
  * Whether to show input box to allow user to input value.
@@ -68,14 +72,20 @@ export type SliderWithIconProps = SliderBaseProps & {
68
72
  withInput?: never;
69
73
  };
70
74
  export type SliderWithoutAddonsProps = SliderBaseProps & {
75
+ /** 此配置下不適用。 */
71
76
  onPrefixIconClick?: never;
77
+ /** 此配置下不適用。 */
72
78
  onSuffixIconClick?: never;
79
+ /** 此配置下不適用。 */
73
80
  prefixIcon?: never;
81
+ /** 此配置下不適用。 */
74
82
  suffixIcon?: never;
83
+ /** 此配置下不適用。 */
75
84
  withInput?: never;
76
85
  };
77
86
  export type SliderAddonProps = SliderWithInputProps | SliderWithIconProps | SliderWithoutAddonsProps;
78
87
  export type SingleSliderProps = SliderAddonProps & {
88
+ /** 滑桿值變更時的回呼函式。 */
79
89
  onChange?: (value: SingleSliderValue) => void;
80
90
  /**
81
91
  * The value of the slider.
@@ -83,6 +93,7 @@ export type SingleSliderProps = SliderAddonProps & {
83
93
  value: UseSingleSliderProps['value'];
84
94
  };
85
95
  export type RangeSliderProps = SliderAddonProps & {
96
+ /** 範圍滑桿值變更時的回呼函式,回傳 [min, max] 元組。 */
86
97
  onChange?: (value: RangeSliderValue) => void;
87
98
  /**
88
99
  * The value of the slider.
@@ -27,5 +27,26 @@ export interface UseSliderResult {
27
27
  handlePress: (e: any, index?: number | undefined) => void;
28
28
  railRef: RefObject<HTMLDivElement | null>;
29
29
  }
30
+ /**
31
+ * 管理 Slider 拖曳互動與 CSS 變數計算的 Hook。
32
+ *
33
+ * 支援單值(`SingleSliderValue`)與範圍值(`RangeSliderValue`)兩種模式,
34
+ * 處理滑鼠/觸控拖曳事件並計算出對應的 CSS 自訂屬性供樣式使用。
35
+ *
36
+ * @example
37
+ * ```tsx
38
+ * import { useSlider } from '@mezzanine-ui/react';
39
+ *
40
+ * const { cssVars, handlePress, handleClickTrackOrRail, railRef } = useSlider({
41
+ * min: 0,
42
+ * max: 100,
43
+ * step: 1,
44
+ * value: sliderValue,
45
+ * onChange: (v) => setSliderValue(v),
46
+ * });
47
+ * ```
48
+ *
49
+ * @see {@link Slider} 搭配的元件
50
+ */
30
51
  export declare function useSlider(props: UseRangeSliderProps): UseSliderResult;
31
52
  export declare function useSlider(props: UseSingleSliderProps): UseSliderResult;
package/Spin/Spin.d.ts CHANGED
@@ -1,8 +1,14 @@
1
- import { IconProps } from '../Icon';
2
1
  import { BackdropProps } from '../Backdrop';
3
2
  import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
4
3
  import { GeneralSize } from '@mezzanine-ui/system/size';
5
4
  export interface SpinProps extends NativeElementPropsWithoutKeyAndRef<'div'> {
5
+ /**
6
+ * Custom color for the spinner arc animation.
7
+ * Sets the `--mzn-spin--color` CSS variable on the ring element.
8
+ * Accepts any valid CSS color value.
9
+ * @default palette icon brand color
10
+ */
11
+ color?: string;
6
12
  /**
7
13
  * Customize description content
8
14
  */
@@ -21,15 +27,18 @@ export interface SpinProps extends NativeElementPropsWithoutKeyAndRef<'div'> {
21
27
  * @default false
22
28
  */
23
29
  stretch?: boolean;
24
- /**
25
- * Custom icon props
26
- */
27
- iconProps?: Omit<IconProps, 'icon' | 'spin'>;
28
30
  /**
29
31
  * Whether Spin is loading.
30
32
  * @default false
31
33
  */
32
34
  loading?: boolean;
35
+ /**
36
+ * Custom color for the spinner track (the non-animated ring background).
37
+ * Sets the `--mzn-spin--track-color` CSS variable on the ring element.
38
+ * Accepts any valid CSS color value.
39
+ * @default transparent
40
+ */
41
+ trackColor?: string;
33
42
  /**
34
43
  * Custom backdrop props (only display when nested children)
35
44
  */
package/Spin/Spin.js CHANGED
@@ -1,24 +1,22 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { forwardRef, useRef } from 'react';
3
- import { SpinnerIcon } from '@mezzanine-ui/icons';
4
3
  import { iconClasses } from '@mezzanine-ui/core/spin';
5
4
  import { useComposeRefs } from '../hooks/useComposeRefs.js';
6
- import Icon from '../Icon/Icon.js';
7
5
  import Backdrop from '../Backdrop/Backdrop.js';
8
6
  import cx from 'clsx';
9
7
 
10
8
  const Spin = forwardRef(function Spin(props, ref) {
11
9
  const hostRef = useRef(null);
12
- const { children, className, description, descriptionClassName, stretch = false, size = 'main', iconProps = {}, loading = false, backdropProps = {}, } = props;
13
- const { className: iconClassName, color: iconColor, size: iconSize, style: iconStyle, ...iconPropsRest } = iconProps;
10
+ const { children, className, color, description, descriptionClassName, stretch = false, size = 'main', loading = false, trackColor, backdropProps = {}, } = props;
14
11
  const isNestedPattern = typeof children !== 'undefined';
15
12
  const composedHostRef = useComposeRefs([ref, hostRef]);
13
+ const ringVars = {
14
+ ...(color && { '--mzn-spin--color': color }),
15
+ ...(trackColor && { '--mzn-spin--track-color': trackColor }),
16
+ };
16
17
  const spinElement = loading ? (jsxs("div", { ref: isNestedPattern ? null : ref, className: cx(iconClasses.spin, iconClasses.size(size), {
17
18
  [iconClasses.stretch]: stretch,
18
- }), children: [jsx(Icon, { ...iconPropsRest, className: cx(iconClasses.icon, iconClassName), color: iconColor, icon: SpinnerIcon, spin: true, style: {
19
- ...(iconSize ? { fontSize: `${iconSize}px` } : {}),
20
- ...(iconStyle || {}),
21
- } }), description ? (jsx("span", { className: cx(iconClasses.description, descriptionClassName), children: description })) : null] })) : null;
19
+ }), children: [jsx("span", { className: iconClasses.spinnerRing, style: ringVars, children: jsx("span", { className: iconClasses.spinnerTail }) }), description ? (jsx("span", { className: cx(iconClasses.description, descriptionClassName), children: description })) : null] })) : null;
22
20
  if (isNestedPattern) {
23
21
  return (jsxs("div", { ref: composedHostRef, className: cx(iconClasses.host, {
24
22
  [iconClasses.stretch]: stretch,
@@ -1,6 +1,39 @@
1
1
  import { StepperProps } from './typings';
2
2
  /**
3
- * The react component for `mezzanine` stepper.
3
+ * 步驟進度指示器元件,以線性流程呈現多個步驟的完成狀態。
4
+ *
5
+ * 子元件必須為 `<Step />` 元件;`currentStep` 控制當前進行中的步驟(零基索引),
6
+ * 之前的步驟自動標記為已完成,之後的步驟為待處理。支援 `horizontal`(水平)與
7
+ * `vertical`(垂直)排列,以及 `number`(數字)與 `dot`(圓點)兩種指示器樣式。
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * import Stepper from '@mezzanine-ui/react/Stepper';
12
+ * import Step from '@mezzanine-ui/react/Step';
13
+ *
14
+ * // 水平數字步驟條
15
+ * <Stepper currentStep={1}>
16
+ * <Step title="填寫資料" description="請輸入基本資訊" />
17
+ * <Step title="確認內容" description="核對填寫資料" />
18
+ * <Step title="完成送出" />
19
+ * </Stepper>
20
+ *
21
+ * // 垂直圓點步驟條
22
+ * <Stepper currentStep={0} orientation="vertical" type="dot">
23
+ * <Step title="步驟一" />
24
+ * <Step title="步驟二" />
25
+ * <Step title="步驟三" />
26
+ * </Stepper>
27
+ *
28
+ * // 監聽步驟變化
29
+ * <Stepper currentStep={step} onStepChange={(idx) => console.log('step:', idx)}>
30
+ * <Step title="A" />
31
+ * <Step title="B" />
32
+ * <Step title="C" />
33
+ * </Stepper>
34
+ * ```
35
+ *
36
+ * @see {@link useStepper} 管理步驟狀態的 hook
4
37
  */
5
38
  declare const Stepper: import("react").ForwardRefExoticComponent<StepperProps & import("react").RefAttributes<HTMLDivElement>>;
6
39
  export default Stepper;
@@ -5,7 +5,40 @@ import { useStepDistance } from './useStepDistance.js';
5
5
  import cx from 'clsx';
6
6
 
7
7
  /**
8
- * The react component for `mezzanine` stepper.
8
+ * 步驟進度指示器元件,以線性流程呈現多個步驟的完成狀態。
9
+ *
10
+ * 子元件必須為 `<Step />` 元件;`currentStep` 控制當前進行中的步驟(零基索引),
11
+ * 之前的步驟自動標記為已完成,之後的步驟為待處理。支援 `horizontal`(水平)與
12
+ * `vertical`(垂直)排列,以及 `number`(數字)與 `dot`(圓點)兩種指示器樣式。
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * import Stepper from '@mezzanine-ui/react/Stepper';
17
+ * import Step from '@mezzanine-ui/react/Step';
18
+ *
19
+ * // 水平數字步驟條
20
+ * <Stepper currentStep={1}>
21
+ * <Step title="填寫資料" description="請輸入基本資訊" />
22
+ * <Step title="確認內容" description="核對填寫資料" />
23
+ * <Step title="完成送出" />
24
+ * </Stepper>
25
+ *
26
+ * // 垂直圓點步驟條
27
+ * <Stepper currentStep={0} orientation="vertical" type="dot">
28
+ * <Step title="步驟一" />
29
+ * <Step title="步驟二" />
30
+ * <Step title="步驟三" />
31
+ * </Stepper>
32
+ *
33
+ * // 監聽步驟變化
34
+ * <Stepper currentStep={step} onStepChange={(idx) => console.log('step:', idx)}>
35
+ * <Step title="A" />
36
+ * <Step title="B" />
37
+ * <Step title="C" />
38
+ * </Stepper>
39
+ * ```
40
+ *
41
+ * @see {@link useStepper} 管理步驟狀態的 hook
9
42
  */
10
43
  const Stepper = forwardRef(function Stepper(props, ref) {
11
44
  const { children, className, currentStep = 0, onStepChange, orientation = 'horizontal', type = 'number', ...rest } = props;