@para-ui/core 5.0.0-beta.12 → 5.0.0-beta.13
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/AGENTS.md +315 -0
- package/AlignBox/component.json +89 -0
- package/Anchor/component.json +130 -0
- package/Argv/component.json +216 -0
- package/AutoBox/component.json +133 -0
- package/AutoButton/component.json +109 -0
- package/AutoTips/component.json +121 -0
- package/Badge/component.json +92 -0
- package/Breadcrumbs/component.json +142 -0
- package/Button/component.json +168 -0
- package/ButtonGroup/component.json +132 -0
- package/Card/component.json +162 -0
- package/Carousel/component.json +142 -0
- package/Cascader/component.json +196 -0
- package/Checkbox/component.json +138 -0
- package/CheckboxGroup/component.json +152 -0
- package/CodeEditor/component.json +189 -0
- package/Collapse/component.json +166 -0
- package/CollapseBox/component.json +84 -0
- package/CollapseLayout/component.json +155 -0
- package/ColorPicker/component.json +142 -0
- package/ComboSelect/component.json +181 -0
- package/Container/component.json +111 -0
- package/ContentBox/component.json +81 -0
- package/CopyText/component.json +118 -0
- package/CycleSelector/component.json +98 -0
- package/DatePicker/component.json +192 -0
- package/Descriptions/component.json +142 -0
- package/Desktop/component.json +171 -0
- package/DragVerify/component.json +114 -0
- package/Drawer/component.json +200 -0
- package/Dropdown/component.json +147 -0
- package/DynamicMultiBox/component.json +278 -0
- package/Empty/component.json +123 -0
- package/FieldForm/component.json +196 -0
- package/Form/component.json +161 -0
- package/FormItem/component.json +171 -0
- package/FunctionModal/component.json +197 -0
- package/Help/component.json +118 -0
- package/HelperText/component.json +126 -0
- package/Image/component.json +165 -0
- package/InputCode/component.json +191 -0
- package/InputLang/component.json +205 -0
- package/InputNumber/component.json +162 -0
- package/Label/component.json +126 -0
- package/Loading/component.json +91 -0
- package/Menu/component.json +180 -0
- package/Message/component.json +246 -0
- package/Modal/component.json +277 -0
- package/MultiBox/component.json +216 -0
- package/Notification/component.json +184 -0
- package/OperateBtn/component.json +134 -0
- package/PageHeader/component.json +112 -0
- package/Pagination/component.json +181 -0
- package/PasswordRules/component.json +105 -0
- package/PopConfirm/component.json +227 -0
- package/PopMenu/component.json +131 -0
- package/Popover/component.json +165 -0
- package/Progress/component.json +161 -0
- package/Prompt/component.json +144 -0
- package/Querying/component.json +96 -0
- package/QuickReply/component.json +129 -0
- package/Radio/component.json +136 -0
- package/RadioGroup/component.json +149 -0
- package/RangeInput/component.json +198 -0
- package/Result/component.json +104 -0
- package/ScrollBar/component.json +115 -0
- package/Search/component.json +177 -0
- package/Select/component.json +244 -0
- package/SelectInput/component.json +184 -0
- package/Selector/component.json +203 -0
- package/SelectorPicker/component.json +179 -0
- package/SingleBox/component.json +151 -0
- package/Slider/component.json +181 -0
- package/SortBox/component.json +108 -0
- package/Status/component.json +104 -0
- package/Stepper/component.json +129 -0
- package/Switch/component.json +207 -0
- package/Table/component.json +547 -0
- package/Tabs/component.json +227 -0
- package/Tag/component.json +221 -0
- package/TextEditor/component.json +186 -0
- package/TextField/component.json +290 -0
- package/TimePicker/component.json +176 -0
- package/Timeline/component.json +110 -0
- package/Title/component.json +156 -0
- package/ToggleButton/component.json +153 -0
- package/Tooltip/component.json +176 -0
- package/Transfer/component.json +157 -0
- package/Tree/component.json +512 -0
- package/Upload/component.json +450 -0
- package/ai-workflows/01-crud-list-multi-drawer.md +278 -0
- package/ai-workflows/02-rbac-operation-buttons.md +290 -0
- package/ai-workflows/03-complex-form-async-cascade.md +350 -0
- package/ai-workflows/04-array-field-form.md +281 -0
- package/ai-workflows/05-popconfirm-async-message-queue.md +333 -0
- package/ai-workflows/06-modal-drawer-form-workflow.md +385 -0
- package/ai-workflows/07-search-filter-table-trio.md +387 -0
- package/ai-workflows/08-table-advanced-features.md +365 -0
- package/ai-workflows/09-batch-operation-export-progress.md +367 -0
- package/ai-workflows/10-cross-component-state-coordination.md +412 -0
- package/es/AlignBox/component.json +89 -0
- package/es/AlignBox/index.css +1 -1
- package/es/AlignBox/index.d.ts +6 -2
- package/es/AlignBox/index.js +1 -1
- package/es/AlignBox/style/index.css +1 -1
- package/es/Anchor/anchorMenu/index.d.ts +2 -1
- package/es/Anchor/anchorMenu/index.js +36 -33
- package/es/Anchor/component.json +130 -0
- package/es/Anchor/index.js +50 -47
- package/es/Anchor/type.d.ts +8 -4
- package/es/Argv/component.json +216 -0
- package/es/Argv/index.d.ts +5 -6
- package/es/AutoBox/component.json +133 -0
- package/es/AutoBox/index.d.ts +3 -3
- package/es/AutoBox/index.js +1 -1
- package/es/AutoBox/protal.d.ts +2 -2
- package/es/AutoBox/protal.js +32 -29
- package/es/AutoButton/component.json +109 -0
- package/es/AutoButton/index.js +1 -1
- package/es/AutoTips/autoTipsMultiline/index.d.ts +1 -1
- package/es/AutoTips/autoTipsMultiline/index.js +1 -1
- package/es/AutoTips/component.json +121 -0
- package/es/Badge/component.json +92 -0
- package/es/Breadcrumbs/component.json +142 -0
- package/es/Breadcrumbs/index.js +1 -1
- package/es/Button/SplitButton.d.ts +2 -2
- package/es/Button/component.json +168 -0
- package/es/Button/index.js +44 -44
- package/es/ButtonGroup/component.json +132 -0
- package/es/ButtonGroup/index.d.ts +1 -1
- package/es/Card/component.json +162 -0
- package/es/Card/index.d.ts +2 -2
- package/es/Card/index.js +2 -2
- package/es/Carousel/component.json +142 -0
- package/es/Carousel/index.d.ts +1 -1
- package/es/Cascader/component.json +196 -0
- package/es/Cascader/hooks/useEntities.js +7 -7
- package/es/Cascader/interface.d.ts +1 -0
- package/es/Cascader/utils/commonUtil.d.ts +1 -1
- package/es/Cascader/utils/commonUtil.js +16 -16
- package/es/Cascader/utils/treeUtil.d.ts +14 -5
- package/es/Cascader/utils/treeUtil.js +1 -1
- package/es/Checkbox/component.json +138 -0
- package/es/CheckboxGroup/component.json +152 -0
- package/es/CodeEditor/component.json +189 -0
- package/es/CodeEditor/index.d.ts +10 -9
- package/es/Collapse/component.json +166 -0
- package/es/Collapse/index.d.ts +1 -1
- package/es/Collapse/index.js +23 -22
- package/es/CollapseBox/component.json +84 -0
- package/es/CollapseLayout/component.json +155 -0
- package/es/ColorPicker/component.json +142 -0
- package/es/ComboSelect/component.json +181 -0
- package/es/ComboSelect/index.js +73 -68
- package/es/ComboSelect/interface.d.ts +2 -2
- package/es/ComboSelect/utils.d.ts +3 -3
- package/es/ComboSelect/utils.js +1 -1
- package/es/Container/component.json +111 -0
- package/es/ContentBox/component.json +81 -0
- package/es/CopyText/component.json +118 -0
- package/es/CycleSelector/component.json +98 -0
- package/es/CycleSelector/index.js +14 -13
- package/es/DatePicker/component.json +192 -0
- package/es/DatePicker/generatePicker/generateRangePicker.js +10 -10
- package/es/DatePicker/generatePicker/generateSinglePicker.js +1 -1
- package/es/Descriptions/component.json +142 -0
- package/es/Descriptions/index.d.ts +1 -1
- package/es/Desktop/component.json +171 -0
- package/es/DragVerify/component.json +114 -0
- package/es/DragVerify/index.js +19 -19
- package/es/Drawer/component.json +200 -0
- package/es/Drawer/index.js +86 -86
- package/es/Drawer/interface.d.ts +1 -1
- package/es/Drawer/util.d.ts +1 -6
- package/es/Drawer/util.js +9 -6
- package/es/Dropdown/component.json +147 -0
- package/es/DynamicMultiBox/component.json +278 -0
- package/es/DynamicMultiBox/formItem.d.ts +1 -1
- package/es/DynamicMultiBox/rowForm.d.ts +2 -2
- package/es/Empty/component.json +123 -0
- package/es/Empty/index.css +1 -1
- package/es/Empty/index.d.ts +2 -2
- package/es/Empty/index.js +27 -26
- package/es/Empty/style/index.css +1 -1
- package/es/FieldForm/FieldFormItem/MemoInput.d.ts +2 -2
- package/es/FieldForm/FieldFormItem/index.d.ts +6 -6
- package/es/FieldForm/Form.d.ts +2 -2
- package/es/FieldForm/FormList.d.ts +2 -2
- package/es/FieldForm/component.json +196 -0
- package/es/FieldForm/context.d.ts +5 -1
- package/es/FieldForm/context.js +2 -2
- package/es/FieldForm/hooks/useForm.d.ts +4 -3
- package/es/FieldForm/hooks/useFormInstance.d.ts +1 -1
- package/es/FieldForm/hooks/useFormItemStatus.d.ts +9 -5
- package/es/FieldForm/hooks/useFormItemStatus.js +2 -2
- package/es/FieldForm/hooks/useItemRef.d.ts +1 -1
- package/es/FieldForm/hooks/useItemRef.js +6 -6
- package/es/Form/component.json +161 -0
- package/es/Form/index.d.ts +52 -49
- package/es/FormItem/compoments/defaultCompoments/index.d.ts +5 -5
- package/es/FormItem/compoments/defaultCompoments/index.js +12 -11
- package/es/FormItem/compoments/formCheckboxGroup/index.d.ts +2 -2
- package/es/FormItem/compoments/formFile/index.js +8 -8
- package/es/FormItem/compoments/formRadioGroup/index.d.ts +1 -1
- package/es/FormItem/compoments/formSelect/index.d.ts +1 -1
- package/es/FormItem/component.json +171 -0
- package/es/FormItem/index.d.ts +5 -5
- package/es/FormItem/index.js +23 -23
- package/es/FormItem/itemType.js +1 -1
- package/es/FunctionModal/component.json +197 -0
- package/es/FunctionModal/dialog.d.ts +1 -1
- package/es/FunctionModal/modalContext.d.ts +4 -1
- package/es/Help/component.json +118 -0
- package/es/HelperText/component.json +126 -0
- package/es/Image/component.json +165 -0
- package/es/InputCode/component.json +191 -0
- package/es/InputCode/index.d.ts +2 -2
- package/es/InputLang/component.json +205 -0
- package/es/InputLang/index.js +1 -1
- package/es/InputNumber/component.json +162 -0
- package/es/Label/component.json +126 -0
- package/es/Label/index.d.ts +2 -2
- package/es/Loading/component.json +91 -0
- package/es/Menu/component.json +180 -0
- package/es/Message/component.json +246 -0
- package/es/Message/index.d.ts +2 -2
- package/es/Message/index.js +2 -2
- package/es/Modal/Confirm/index.d.ts +1 -1
- package/es/Modal/component.json +277 -0
- package/es/Modal/index.d.ts +85 -5
- package/es/Modal/index.js +159 -122
- package/es/Modal/interface.d.ts +1 -0
- package/es/MultiBox/component.json +216 -0
- package/es/MultiBox/index.js +19 -14
- package/es/Notification/component.json +184 -0
- package/es/OperateBtn/component.json +134 -0
- package/es/OperateBtn/index.d.ts +3 -3
- package/es/PageHeader/component.json +112 -0
- package/es/Pagination/component.json +181 -0
- package/es/Pagination/index.js +15 -15
- package/es/PasswordRules/component.json +105 -0
- package/es/PasswordRules/index.d.ts +4 -4
- package/es/PopConfirm/component.json +227 -0
- package/es/PopConfirm/index.d.ts +1 -1
- package/es/PopConfirm/index.js +1 -1
- package/es/PopMenu/component.json +131 -0
- package/es/PopMenu/hooks.d.ts +1 -1
- package/es/PopMenu/index.js +8 -8
- package/es/Popover/component.json +165 -0
- package/es/Popover/index.js +1 -1
- package/es/Progress/component.json +161 -0
- package/es/Prompt/component.json +144 -0
- package/es/Querying/component.json +96 -0
- package/es/Querying/index.css +1 -1
- package/es/Querying/index.d.ts +2 -2
- package/es/Querying/index.js +20 -19
- package/es/Querying/style/index.css +1 -1
- package/es/QuickReply/component.json +129 -0
- package/es/QuickReply/index.d.ts +1 -1
- package/es/Radio/component.json +136 -0
- package/es/RadioGroup/component.json +149 -0
- package/es/RangeInput/component.json +198 -0
- package/es/RangeInput/index.js +1 -1
- package/es/Result/component.json +104 -0
- package/es/ScrollBar/component.json +115 -0
- package/es/Search/component.json +177 -0
- package/es/Search/index.d.ts +1 -1
- package/es/Select/component.json +244 -0
- package/es/Select/index.js +113 -113
- package/es/SelectInput/component.json +184 -0
- package/es/Selector/component.json +203 -0
- package/es/Selector/index.js +28 -27
- package/es/Selector/interface.d.ts +1 -1
- package/es/Selector/selectorMain/index.js +2 -2
- package/es/Selector/selectorNode/index.js +1 -1
- package/es/Selector/util.d.ts +2 -2
- package/es/SelectorPicker/component.json +179 -0
- package/es/SelectorPicker/index.d.ts +5 -5
- package/es/SelectorPicker/index.js +15 -15
- package/es/SingleBox/component.json +151 -0
- package/es/SingleBox/index.d.ts +2 -2
- package/es/Slider/component.json +181 -0
- package/es/SortBox/component.json +108 -0
- package/es/Status/component.json +104 -0
- package/es/Stepper/component.json +129 -0
- package/es/Stepper/index.d.ts +2 -2
- package/es/Switch/component.json +207 -0
- package/es/Switch/index.css +1 -1
- package/es/Switch/index.d.ts +3 -2
- package/es/Switch/index.js +60 -59
- package/es/Switch/style/index.css +1 -1
- package/es/Table/component.json +547 -0
- package/es/Table/index.d.ts +2 -2
- package/es/Table/index.js +414 -414
- package/es/Table/interface.d.ts +6 -0
- package/es/Tabs/component.json +227 -0
- package/es/Tag/component.json +221 -0
- package/es/Tag/index.css +1 -1
- package/es/Tag/index.d.ts +1 -1
- package/es/Tag/index.js +20 -20
- package/es/Tag/style/index.css +1 -1
- package/es/TextEditor/component.json +186 -0
- package/es/TextEditor/index.d.ts +5 -5
- package/es/TextField/component.json +290 -0
- package/es/TextField/index.d.ts +2 -2
- package/es/TimePicker/component.json +176 -0
- package/es/Timeline/component.json +110 -0
- package/es/Title/component.json +156 -0
- package/es/ToggleButton/component.json +153 -0
- package/es/Tooltip/component.json +176 -0
- package/es/Tooltip/index.js +58 -53
- package/es/Tooltip/interface.d.ts +14 -1
- package/es/Tooltip/utils.js +6 -6
- package/es/Transfer/component.json +157 -0
- package/es/Tree/component.json +512 -0
- package/es/Upload/component.json +450 -0
- package/es/Utils/type.d.ts +0 -2
- package/es/index.d.ts +2 -0
- package/es/index.js +1 -1
- package/es/locale/en_US.d.ts +361 -0
- package/es/locale/en_US.js +364 -0
- package/es/locale/index.d.ts +1 -723
- package/es/locale/index2.js +10 -0
- package/es/locale/zh_CN.d.ts +361 -0
- package/es/locale/zh_CN.js +364 -0
- package/lib/AlignBox/component.json +89 -0
- package/lib/AlignBox/index.css +1 -1
- package/lib/AlignBox/index.d.ts +6 -2
- package/lib/AlignBox/index.js +1 -1
- package/lib/AlignBox/style/index.css +1 -1
- package/lib/Anchor/anchorMenu/index.d.ts +2 -1
- package/lib/Anchor/anchorMenu/index.js +1 -1
- package/lib/Anchor/component.json +130 -0
- package/lib/Anchor/index.js +1 -1
- package/lib/Anchor/type.d.ts +8 -4
- package/lib/Argv/component.json +216 -0
- package/lib/Argv/index.d.ts +5 -6
- package/lib/AutoBox/component.json +133 -0
- package/lib/AutoBox/index.d.ts +3 -3
- package/lib/AutoBox/index.js +1 -1
- package/lib/AutoBox/protal.d.ts +2 -2
- package/lib/AutoBox/protal.js +1 -1
- package/lib/AutoButton/component.json +109 -0
- package/lib/AutoButton/index.js +1 -1
- package/lib/AutoTips/autoTipsMultiline/index.d.ts +1 -1
- package/lib/AutoTips/autoTipsMultiline/index.js +1 -1
- package/lib/AutoTips/component.json +121 -0
- package/lib/Badge/component.json +92 -0
- package/lib/Breadcrumbs/component.json +142 -0
- package/lib/Breadcrumbs/index.js +1 -1
- package/lib/Button/SplitButton.d.ts +2 -2
- package/lib/Button/component.json +168 -0
- package/lib/Button/index.js +1 -1
- package/lib/ButtonGroup/component.json +132 -0
- package/lib/ButtonGroup/index.d.ts +1 -1
- package/lib/Card/component.json +162 -0
- package/lib/Card/index.d.ts +2 -2
- package/lib/Card/index.js +1 -1
- package/lib/Carousel/component.json +142 -0
- package/lib/Carousel/index.d.ts +1 -1
- package/lib/Cascader/component.json +196 -0
- package/lib/Cascader/hooks/useEntities.js +1 -1
- package/lib/Cascader/interface.d.ts +1 -0
- package/lib/Cascader/utils/commonUtil.d.ts +1 -1
- package/lib/Cascader/utils/commonUtil.js +1 -1
- package/lib/Cascader/utils/treeUtil.d.ts +14 -5
- package/lib/Cascader/utils/treeUtil.js +1 -1
- package/lib/Checkbox/component.json +138 -0
- package/lib/CheckboxGroup/component.json +152 -0
- package/lib/CodeEditor/component.json +189 -0
- package/lib/CodeEditor/index.d.ts +10 -9
- package/lib/Collapse/component.json +166 -0
- package/lib/Collapse/index.d.ts +1 -1
- package/lib/Collapse/index.js +1 -1
- package/lib/CollapseBox/component.json +84 -0
- package/lib/CollapseLayout/component.json +155 -0
- package/lib/ColorPicker/component.json +142 -0
- package/lib/ComboSelect/component.json +181 -0
- package/lib/ComboSelect/index.js +1 -1
- package/lib/ComboSelect/interface.d.ts +2 -2
- package/lib/ComboSelect/utils.d.ts +3 -3
- package/lib/ComboSelect/utils.js +1 -1
- package/lib/Container/component.json +111 -0
- package/lib/ContentBox/component.json +81 -0
- package/lib/CopyText/component.json +118 -0
- package/lib/CycleSelector/component.json +98 -0
- package/lib/CycleSelector/index.js +1 -1
- package/lib/DatePicker/component.json +192 -0
- package/lib/DatePicker/generatePicker/generateRangePicker.js +1 -1
- package/lib/DatePicker/generatePicker/generateSinglePicker.js +1 -1
- package/lib/Descriptions/component.json +142 -0
- package/lib/Descriptions/index.d.ts +1 -1
- package/lib/Desktop/component.json +171 -0
- package/lib/DragVerify/component.json +114 -0
- package/lib/DragVerify/index.js +1 -1
- package/lib/Drawer/component.json +200 -0
- package/lib/Drawer/index.js +1 -1
- package/lib/Drawer/interface.d.ts +1 -1
- package/lib/Drawer/util.d.ts +1 -6
- package/lib/Drawer/util.js +1 -1
- package/lib/Dropdown/component.json +147 -0
- package/lib/DynamicMultiBox/component.json +278 -0
- package/lib/DynamicMultiBox/formItem.d.ts +1 -1
- package/lib/DynamicMultiBox/rowForm.d.ts +2 -2
- package/lib/Empty/component.json +123 -0
- package/lib/Empty/index.css +1 -1
- package/lib/Empty/index.d.ts +2 -2
- package/lib/Empty/index.js +1 -1
- package/lib/Empty/style/index.css +1 -1
- package/lib/FieldForm/FieldFormItem/MemoInput.d.ts +2 -2
- package/lib/FieldForm/FieldFormItem/index.d.ts +6 -6
- package/lib/FieldForm/Form.d.ts +2 -2
- package/lib/FieldForm/FormList.d.ts +2 -2
- package/lib/FieldForm/component.json +196 -0
- package/lib/FieldForm/context.d.ts +5 -1
- package/lib/FieldForm/context.js +1 -1
- package/lib/FieldForm/hooks/useForm.d.ts +4 -3
- package/lib/FieldForm/hooks/useFormInstance.d.ts +1 -1
- package/lib/FieldForm/hooks/useFormItemStatus.d.ts +9 -5
- package/lib/FieldForm/hooks/useFormItemStatus.js +1 -1
- package/lib/FieldForm/hooks/useItemRef.d.ts +1 -1
- package/lib/FieldForm/hooks/useItemRef.js +1 -1
- package/lib/Form/component.json +161 -0
- package/lib/Form/index.d.ts +52 -49
- package/lib/FormItem/compoments/defaultCompoments/index.d.ts +5 -5
- package/lib/FormItem/compoments/defaultCompoments/index.js +1 -1
- package/lib/FormItem/compoments/formCheckboxGroup/index.d.ts +2 -2
- package/lib/FormItem/compoments/formFile/index.js +1 -1
- package/lib/FormItem/compoments/formRadioGroup/index.d.ts +1 -1
- package/lib/FormItem/compoments/formSelect/index.d.ts +1 -1
- package/lib/FormItem/component.json +171 -0
- package/lib/FormItem/index.d.ts +5 -5
- package/lib/FormItem/index.js +1 -1
- package/lib/FormItem/itemType.js +1 -1
- package/lib/FunctionModal/component.json +197 -0
- package/lib/FunctionModal/dialog.d.ts +1 -1
- package/lib/FunctionModal/modalContext.d.ts +4 -1
- package/lib/Help/component.json +118 -0
- package/lib/HelperText/component.json +126 -0
- package/lib/Image/component.json +165 -0
- package/lib/InputCode/component.json +191 -0
- package/lib/InputCode/index.d.ts +2 -2
- package/lib/InputLang/component.json +205 -0
- package/lib/InputLang/index.js +1 -1
- package/lib/InputNumber/component.json +162 -0
- package/lib/Label/component.json +126 -0
- package/lib/Label/index.d.ts +2 -2
- package/lib/Loading/component.json +91 -0
- package/lib/Menu/component.json +180 -0
- package/lib/Message/component.json +246 -0
- package/lib/Message/index.d.ts +2 -2
- package/lib/Message/index.js +1 -1
- package/lib/Modal/Confirm/index.d.ts +1 -1
- package/lib/Modal/component.json +277 -0
- package/lib/Modal/index.d.ts +85 -5
- package/lib/Modal/index.js +1 -1
- package/lib/Modal/interface.d.ts +1 -0
- package/lib/MultiBox/component.json +216 -0
- package/lib/MultiBox/index.js +1 -1
- package/lib/Notification/component.json +184 -0
- package/lib/OperateBtn/component.json +134 -0
- package/lib/OperateBtn/index.d.ts +3 -3
- package/lib/PageHeader/component.json +112 -0
- package/lib/Pagination/component.json +181 -0
- package/lib/Pagination/index.js +1 -1
- package/lib/PasswordRules/component.json +105 -0
- package/lib/PasswordRules/index.d.ts +4 -4
- package/lib/PopConfirm/component.json +227 -0
- package/lib/PopConfirm/index.d.ts +1 -1
- package/lib/PopConfirm/index.js +1 -1
- package/lib/PopMenu/component.json +131 -0
- package/lib/PopMenu/hooks.d.ts +1 -1
- package/lib/PopMenu/index.js +1 -1
- package/lib/Popover/component.json +165 -0
- package/lib/Popover/index.js +1 -1
- package/lib/Progress/component.json +161 -0
- package/lib/Prompt/component.json +144 -0
- package/lib/Querying/component.json +96 -0
- package/lib/Querying/index.css +1 -1
- package/lib/Querying/index.d.ts +2 -2
- package/lib/Querying/index.js +1 -1
- package/lib/Querying/style/index.css +1 -1
- package/lib/QuickReply/component.json +129 -0
- package/lib/QuickReply/index.d.ts +1 -1
- package/lib/Radio/component.json +136 -0
- package/lib/RadioGroup/component.json +149 -0
- package/lib/RangeInput/component.json +198 -0
- package/lib/RangeInput/index.js +1 -1
- package/lib/Result/component.json +104 -0
- package/lib/ScrollBar/component.json +115 -0
- package/lib/Search/component.json +177 -0
- package/lib/Search/index.d.ts +1 -1
- package/lib/Select/component.json +244 -0
- package/lib/Select/index.js +1 -1
- package/lib/SelectInput/component.json +184 -0
- package/lib/Selector/component.json +203 -0
- package/lib/Selector/index.js +1 -1
- package/lib/Selector/interface.d.ts +1 -1
- package/lib/Selector/selectorMain/index.js +1 -1
- package/lib/Selector/selectorNode/index.js +1 -1
- package/lib/Selector/util.d.ts +2 -2
- package/lib/SelectorPicker/component.json +179 -0
- package/lib/SelectorPicker/index.d.ts +5 -5
- package/lib/SelectorPicker/index.js +1 -1
- package/lib/SingleBox/component.json +151 -0
- package/lib/SingleBox/index.d.ts +2 -2
- package/lib/Slider/component.json +181 -0
- package/lib/SortBox/component.json +108 -0
- package/lib/Status/component.json +104 -0
- package/lib/Stepper/component.json +129 -0
- package/lib/Stepper/index.d.ts +2 -2
- package/lib/Switch/component.json +207 -0
- package/lib/Switch/index.css +1 -1
- package/lib/Switch/index.d.ts +3 -2
- package/lib/Switch/index.js +1 -1
- package/lib/Switch/style/index.css +1 -1
- package/lib/Table/component.json +547 -0
- package/lib/Table/index.d.ts +2 -2
- package/lib/Table/index.js +1 -1
- package/lib/Table/interface.d.ts +6 -0
- package/lib/Tabs/component.json +227 -0
- package/lib/Tag/component.json +221 -0
- package/lib/Tag/index.css +1 -1
- package/lib/Tag/index.d.ts +1 -1
- package/lib/Tag/index.js +1 -1
- package/lib/Tag/style/index.css +1 -1
- package/lib/TextEditor/component.json +186 -0
- package/lib/TextEditor/index.d.ts +5 -5
- package/lib/TextField/component.json +290 -0
- package/lib/TextField/index.d.ts +2 -2
- package/lib/TimePicker/component.json +176 -0
- package/lib/Timeline/component.json +110 -0
- package/lib/Title/component.json +156 -0
- package/lib/ToggleButton/component.json +153 -0
- package/lib/Tooltip/component.json +176 -0
- package/lib/Tooltip/index.js +1 -1
- package/lib/Tooltip/interface.d.ts +14 -1
- package/lib/Tooltip/utils.js +1 -1
- package/lib/Transfer/component.json +157 -0
- package/lib/Tree/component.json +512 -0
- package/lib/Upload/component.json +450 -0
- package/lib/Utils/type.d.ts +0 -2
- package/lib/index.d.ts +2 -0
- package/lib/index.js +1 -1
- package/lib/locale/en_US.d.ts +361 -0
- package/lib/locale/en_US.js +2 -0
- package/lib/locale/index.d.ts +1 -723
- package/lib/locale/index2.js +2 -0
- package/lib/locale/zh_CN.d.ts +361 -0
- package/lib/locale/zh_CN.js +2 -0
- package/package.json +9 -3
- /package/es/{Utils/Hooks → Hooks}/useResizeObserver.d.ts +0 -0
- /package/es/{Utils/Hooks → Hooks}/useResizeObserver.js +0 -0
- /package/lib/{Utils/Hooks → Hooks}/useResizeObserver.d.ts +0 -0
- /package/lib/{Utils/Hooks → Hooks}/useResizeObserver.js +0 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Help",
|
|
3
|
+
"category": "Data Display",
|
|
4
|
+
"description": "帮助提示图标组件,hover 触发 Tooltip 展示帮助信息;默认渲染问号图标,支持自定义触发节点",
|
|
5
|
+
"semantic": {
|
|
6
|
+
"intent": [
|
|
7
|
+
"帮助说明",
|
|
8
|
+
"提示信息"
|
|
9
|
+
],
|
|
10
|
+
"useCases": [
|
|
11
|
+
"字段说明",
|
|
12
|
+
"功能提示",
|
|
13
|
+
"操作指引"
|
|
14
|
+
],
|
|
15
|
+
"riskLevel": "low"
|
|
16
|
+
},
|
|
17
|
+
"variants": {
|
|
18
|
+
"default": {
|
|
19
|
+
"meaning": "默认样式"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"states": [
|
|
23
|
+
"default"
|
|
24
|
+
],
|
|
25
|
+
"idealProps": {
|
|
26
|
+
"title": {
|
|
27
|
+
"type": "NonNullable<ReactNode>",
|
|
28
|
+
"description": "弹层内容(任意 ReactNode)。**⚠️ 类型严格 NonNullable<ReactNode> 排除 null/undefined**;外层 props 用 `React.ReactNode` 直传会撞 TS2322。正确写法:① title={text ?? ''} 兜底 ② props 字段类型收窄为 NonNullable<ReactNode> ③ 父组件提前 narrow。长度为 0 的字符串不显示弹层"
|
|
29
|
+
},
|
|
30
|
+
"children": {
|
|
31
|
+
"type": "ReactNode",
|
|
32
|
+
"description": "自定义触发图标/节点;不传则内置渲染问号图标 <HelpIcon /> 作为默认触发(hover 触发,不支持 click)"
|
|
33
|
+
},
|
|
34
|
+
"placement": {
|
|
35
|
+
"type": "enum",
|
|
36
|
+
"values": [
|
|
37
|
+
"top",
|
|
38
|
+
"top-start",
|
|
39
|
+
"top-end",
|
|
40
|
+
"bottom",
|
|
41
|
+
"bottom-start",
|
|
42
|
+
"bottom-end",
|
|
43
|
+
"left",
|
|
44
|
+
"left-start",
|
|
45
|
+
"left-end",
|
|
46
|
+
"right",
|
|
47
|
+
"right-start",
|
|
48
|
+
"right-end"
|
|
49
|
+
],
|
|
50
|
+
"default": "top-start",
|
|
51
|
+
"description": "弹层位置:12 档(4 边方位 × 3 对齐)。仅指定方向时推荐用基础值(top/bottom/left/right,中心对齐)"
|
|
52
|
+
},
|
|
53
|
+
"arrow": {
|
|
54
|
+
"type": "boolean",
|
|
55
|
+
"default": true,
|
|
56
|
+
"description": "是否显示指向箭头(连接到触发图标的小三角)"
|
|
57
|
+
},
|
|
58
|
+
"className": {
|
|
59
|
+
"type": "string",
|
|
60
|
+
"description": "外层 <span> 的 className"
|
|
61
|
+
},
|
|
62
|
+
"style": {
|
|
63
|
+
"type": "React.CSSProperties",
|
|
64
|
+
"description": "外层 <span> 的 style"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"trigger": {
|
|
68
|
+
"method": "hover",
|
|
69
|
+
"description": "触发方式继承自 Tooltip 默认行为:hover 触发元素显示,移开收起;**不支持配置为 click**(需点击场景请用 Popover)"
|
|
70
|
+
},
|
|
71
|
+
"do": [
|
|
72
|
+
"在复杂字段旁提供帮助图标,title 保持简洁(< 50 字)",
|
|
73
|
+
"帮助内容简洁明了",
|
|
74
|
+
"需要点击触发场景时改用 Popover 组件",
|
|
75
|
+
"title 可能为空字符串时组件不渲染 Tooltip 弹层——利用此行为动态控制提示是否出现"
|
|
76
|
+
],
|
|
77
|
+
"dont": [
|
|
78
|
+
"过度使用帮助图标——每行超过 2 个会造成视觉噪音",
|
|
79
|
+
"帮助内容过长(> 100 字)——改用 Drawer/Modal 展示详情"
|
|
80
|
+
],
|
|
81
|
+
"events": {
|
|
82
|
+
"onHover": {
|
|
83
|
+
"signature": "继承自 Tooltip TooltipProps(onOpen / onClose)",
|
|
84
|
+
"asyncSupported": false,
|
|
85
|
+
"examples": [
|
|
86
|
+
"Help 自身没有独立事件——交互由底层 Tooltip 管理(hover in → show, hover out → hide)",
|
|
87
|
+
"需要监听 Tooltip 开关状态:透传 Tooltip 的 onOpen/onClose prop(通过 ...restProps 传入)",
|
|
88
|
+
"需要 click 触发:改用 Popover 组件,不要在 Help children 上绑 onClick 期望触发 Tooltip 逻辑"
|
|
89
|
+
],
|
|
90
|
+
"commonMistakes": [
|
|
91
|
+
"给 children 添加 onClick 期望触发提示弹层——Help 底层 Tooltip 默认 hover,click 不会触发",
|
|
92
|
+
"期望 Help 有 visible/open 受控 prop——请直接用 Tooltip 组件并传自定义 children",
|
|
93
|
+
"期望 title='' 也显示弹层——空字符串 title 不弹出 Tooltip(Tooltip 内部空 title 行为)"
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"typescriptPitfalls": [
|
|
98
|
+
{
|
|
99
|
+
"issue": "title 类型是 NonNullable<ReactNode>,父组件直传 ReactNode 类型时会触发 TS2322",
|
|
100
|
+
"wrong": "const tip: React.ReactNode = getTooltip(); <Help title={tip} /> // TS2322: Type 'ReactNode' not assignable to NonNullable<ReactNode>(含 null/undefined 分支)",
|
|
101
|
+
"right": "const tip = getTooltip(); <Help title={tip ?? ''} /> // 用 ?? '' 兜底,确保不为 null/undefined"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"issue": "Help 继承 TooltipProps(Omit children),不能直接传 Tooltip 专有 props 会被 TS 拦截",
|
|
105
|
+
"wrong": "<Help title='说明' disableHoverListener /> // disableHoverListener 不在 HelpProps 里,TS 报错",
|
|
106
|
+
"right": "<Help title='说明' /> // 需要关闭 hover:改用 Tooltip 直接封装;Help 不支持所有 TooltipProps 的覆盖"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"issue": "HelpProps extends Omit<TooltipProps, 'children'>,children 被重新声明为 ReactNode(可选),不接受 multiple children",
|
|
110
|
+
"wrong": "<Help title='说明'><span>图标</span><span>附加</span></Help> // 多子节点在 span wrapper 内合法,但语义上只用单个节点",
|
|
111
|
+
"right": "<Help title='说明'><span>自定义图标</span></Help> // 单个节点作为 trigger"
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
"mapping": {
|
|
115
|
+
"realComponent": "Help",
|
|
116
|
+
"adapter": null
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "HelperText",
|
|
3
|
+
"category": "Data Display",
|
|
4
|
+
"description": "表单字段下方的辅助文本(校验错误 / 提示信息)。简单原子组件,核心交互只有 3 个 prop:error 控样式,helperText 给文案,hideErrorDom 控渲染策略",
|
|
5
|
+
"semantic": {
|
|
6
|
+
"intent": [
|
|
7
|
+
"表单字段错误提示",
|
|
8
|
+
"输入框辅助说明",
|
|
9
|
+
"字段下方的灰色提示文案"
|
|
10
|
+
],
|
|
11
|
+
"useCases": [
|
|
12
|
+
"TextField / FieldForm.Item 下方的校验提示",
|
|
13
|
+
"Form 字段的 hint 文案",
|
|
14
|
+
"条件性错误信息显示"
|
|
15
|
+
],
|
|
16
|
+
"riskLevel": "low"
|
|
17
|
+
},
|
|
18
|
+
"protocolSummary": "**三态 hideErrorDom 真值表**(组件渲染策略):\n| hideErrorDom | error=false | error=true |\n|---|---|---|\n| **true** (默认推荐) | 不渲染 (return null) | 渲染 <p>(红色错误样式) |\n| **false** | 渲染 <p>(中性样式,helperText 即使为空也占位) | 渲染 <p>(红色错误样式) |\n| **null** | 不渲染 (return null,无视 error) | 不渲染 (return null,无视 error) |\n\n**默认值**:hideErrorDom 默认是 **false**(都渲染,占位)。**null 是一种'禁用整个组件'的快捷写法**——传 null 时无论 error 真假都不渲染",
|
|
19
|
+
"states": [
|
|
20
|
+
"default",
|
|
21
|
+
"error"
|
|
22
|
+
],
|
|
23
|
+
"variants": {
|
|
24
|
+
"default": {
|
|
25
|
+
"meaning": "默认样式(无 variant 切换)"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"idealProps": {
|
|
29
|
+
"error": {
|
|
30
|
+
"type": "boolean",
|
|
31
|
+
"default": false,
|
|
32
|
+
"description": "是否处于错误态。error=true 时给 <p> 加上 `.paraui-v4-helper-text-error` 类(红色文字样式);error=false 时只有基础 `.paraui-v4-helper-text` 类(中性灰色样式)"
|
|
33
|
+
},
|
|
34
|
+
"helperText": {
|
|
35
|
+
"type": "ReactNode",
|
|
36
|
+
"description": "渲染在 <p> 内的内容。可以是字符串、JSX 或 undefined。**不影响是否渲染**——只要 hideErrorDom 不是 null + 不是 (hideErrorDom=true && !error),<p> 都会渲染(即使 helperText 为 undefined / 空字符串)"
|
|
37
|
+
},
|
|
38
|
+
"hideErrorDom": {
|
|
39
|
+
"type": "boolean | null",
|
|
40
|
+
"default": false,
|
|
41
|
+
"description": "**渲染策略三态**(见 protocolSummary 真值表):\n- **true** = 没有错误时不渲染(节省 DOM,error=true 时正常渲染)——表单常用,只在出错时才占位\n- **false**(默认) = 都渲染(error=true 红字,error=false 中性占位,即使 helperText 为空也占用 line-height 的高度,**保留布局稳定**)\n- **null** = 永不渲染(无论 error 真假都 return null,等于禁用组件)"
|
|
42
|
+
},
|
|
43
|
+
"className": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"description": "外层 <p> 的 className(追加,不覆盖内置 prefix 类)"
|
|
46
|
+
},
|
|
47
|
+
"style": {
|
|
48
|
+
"type": "React.CSSProperties",
|
|
49
|
+
"description": "外层 <p> 的 style"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"commonMisconceptions": {
|
|
53
|
+
"M1": {
|
|
54
|
+
"wrong": "把 hideErrorDom 当 'error 为 false 时不渲染' 的开关 —— 期望 hideErrorDom=false 时 error=false 也不渲染",
|
|
55
|
+
"result": "hideErrorDom=false 时即使 error=false 也会渲染 <p>(中性样式 + 空内容,占用 line-height 高度,**这是为了表单布局稳定**)",
|
|
56
|
+
"fix": "想要无错误就完全不渲染:用 hideErrorDom=true(推荐)。想要无错误时根本不挂载组件:用 hideErrorDom=null 或父层条件渲染 `{error && <HelperText error helperText={msg} />}`"
|
|
57
|
+
},
|
|
58
|
+
"M2": {
|
|
59
|
+
"wrong": "认为 helperText 控制是否渲染 —— 期望 helperText 为空字符串 / undefined 时 <p> 不渲染",
|
|
60
|
+
"result": "helperText 只控制 <p> 内的内容,不控制是否渲染。空 helperText + hideErrorDom=false 会渲染空白 <p>(仍占 line-height 高度)",
|
|
61
|
+
"fix": "想根据 helperText 空否决定渲染:用 hideErrorDom=true(error=false 时不渲染),或父层条件渲染"
|
|
62
|
+
},
|
|
63
|
+
"M3": {
|
|
64
|
+
"wrong": "认为 hideErrorDom=null 只在 error=false 时生效 —— 期望 hideErrorDom=null && error=true 时还会渲染错误",
|
|
65
|
+
"result": "**hideErrorDom=null 时优先级最高,直接 return null,无视 error**——传 null 就完全屏蔽组件",
|
|
66
|
+
"fix": "条件性禁用错误显示:用动态 hideErrorDom={ shouldHide ? null : false } 切换;只在错误时显示:用 hideErrorDom=true(默认推荐)"
|
|
67
|
+
},
|
|
68
|
+
"M4": {
|
|
69
|
+
"wrong": "error=false 时给特殊 helperText 颜色(成功绿 / 警告黄)期望 HelperText 自动配色",
|
|
70
|
+
"result": "**HelperText 只有两态样式**:error=true 红色错误 + error=false 中性灰色。没有 success / warning variant",
|
|
71
|
+
"fix": "需要多状态色:用 className 自定义,或换更通用的 Tip / Alert 组件"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"completeExample": "// 三态 hideErrorDom × error 真假演示\nimport React, { useState } from 'react';\nimport HelperText from '@para-ui/core/HelperText';\nimport TextField from '@para-ui/core/TextField';\n\nconst Demo: React.FC = () => {\n const [value, setValue] = useState('');\n const error = value.length > 0 && value.length < 6;\n return (\n <div>\n <TextField\n value={value}\n onChange={e => setValue(e.target.value)}\n placeholder='输入至少 6 位'\n />\n {/* 推荐:hideErrorDom=true,无错误时不渲染,布局可能跳动 */}\n <HelperText\n error={error}\n helperText={error ? '至少 6 位' : ''}\n hideErrorDom={true}\n />\n {/* 布局稳定:hideErrorDom=false,无错误时占位 */}\n <HelperText\n error={error}\n helperText={error ? '至少 6 位' : '至少 6 位(无错时占位)'}\n hideErrorDom={false}\n />\n {/* 禁用组件:hideErrorDom=null,永不渲染 */}\n <HelperText\n error={true}\n helperText='永不显示'\n hideErrorDom={null}\n />\n </div>\n );\n};\nexport default Demo;",
|
|
75
|
+
"do": [
|
|
76
|
+
"**默认推荐**:用 `hideErrorDom=true`(只在 error=true 时渲染),节省 DOM",
|
|
77
|
+
"**布局稳定优先**(避免出错时整体跳动):用 `hideErrorDom=false`(默认值),即使 error=false 也占 line-height 高度",
|
|
78
|
+
"**整组屏蔽**:用 `hideErrorDom={null}`(等价于不挂载组件)",
|
|
79
|
+
"在 TextField / FieldForm.Item 下方使用,作为校验反馈通道",
|
|
80
|
+
"helperText 文案保持简短(< 30 字),长错误信息考虑用 Alert 组件"
|
|
81
|
+
],
|
|
82
|
+
"dont": [
|
|
83
|
+
"**不要**期望 hideErrorDom=false 时空 helperText 不渲染——会渲染空白 <p>(M1/M2)",
|
|
84
|
+
"**不要**期望 hideErrorDom=null + error=true 时仍渲染——null 优先级最高(M3)",
|
|
85
|
+
"**不要**用 HelperText 做 success / warning 提示——只有 error 一种着色态(M4)",
|
|
86
|
+
"错误信息过长(>30 字)不要塞 HelperText——换 Alert / Tip",
|
|
87
|
+
"同一字段同时显示多个错误信息——合并成一条"
|
|
88
|
+
],
|
|
89
|
+
"events": {
|
|
90
|
+
"render": {
|
|
91
|
+
"signature": "无事件 prop——HelperText 是纯展示组件",
|
|
92
|
+
"asyncSupported": false,
|
|
93
|
+
"examples": [
|
|
94
|
+
"HelperText 本身不触发任何事件;渲染控制完全由 error/hideErrorDom/helperText 三个 prop 驱动",
|
|
95
|
+
"配合外层 TextField 的 onBlur:onBlur={() => setError(validate(value))} → <HelperText error={!!error} helperText={error} hideErrorDom={true} />",
|
|
96
|
+
"父组件主动清除错误:setError('') 后 error=false,hideErrorDom=true 时 HelperText 不渲染,布局收起"
|
|
97
|
+
],
|
|
98
|
+
"commonMistakes": [
|
|
99
|
+
"期望给 HelperText 传 onClick 或 onClose 回调——HelperText 是纯展示 <p> 节点,无交互",
|
|
100
|
+
"传 onChange/onInput 期望监听文本变化——helperText 是静态展示内容,不是输入框",
|
|
101
|
+
"期望 HelperText 自动监听父组件 error 状态——需父组件主动把 error state 传给 error prop"
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"typescriptPitfalls": [
|
|
106
|
+
{
|
|
107
|
+
"issue": "hideErrorDom 类型是 boolean | null,传 undefined 等同于不传(默认 false),不等于 null 的行为",
|
|
108
|
+
"wrong": "const hide: boolean | undefined = getHide(); <HelperText hideErrorDom={hide} /> // undefined 时按 false 处理(都渲染),不是 null(禁用)",
|
|
109
|
+
"right": "const hide = getHide(); <HelperText hideErrorDom={hide ?? false} /> // 明确兜底,或用 null 显式禁用:hideErrorDom={shouldHide ? null : false}"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"issue": "helperText 类型是 ReactNode,传 false 是合法 ReactNode 但不渲染——可能造成混淆",
|
|
113
|
+
"wrong": "const msg: string | false = getMsg(); <HelperText helperText={msg} /> // msg=false 时 React 不渲染 false,但 <p> 仍然渲染(空白占位)",
|
|
114
|
+
"right": "const msg = getMsg(); <HelperText helperText={msg || ''} error={!!msg} hideErrorDom={true} /> // 用 hideErrorDom=true 避免空白占位"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"issue": "HelperText 的 error prop 默认 false——不传 error 时始终以中性灰色样式渲染,不显示红色",
|
|
118
|
+
"wrong": "<HelperText helperText='格式不正确' /> // 没传 error=true,文字显示为灰色而非红色错误样式",
|
|
119
|
+
"right": "<HelperText error={true} helperText='格式不正确' /> // 必须显式传 error={true} 才触发红色错误样式"
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
"mapping": {
|
|
123
|
+
"realComponent": "HelperText",
|
|
124
|
+
"adapter": null
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Image",
|
|
3
|
+
"category": "Data Display",
|
|
4
|
+
"description": "图片组件,基于 rc-image 封装。支持点击预览(放大 / 旋转 / 翻转 / 切换 / 关闭)、加载失败 fallback、占位 placeholder、PreviewGroup 多图轮播。**Props 继承自 rc-image ImageProps,包含所有原生 <img> 属性 + 预览/失败/占位扩展字段**",
|
|
5
|
+
"semantic": {
|
|
6
|
+
"intent": [
|
|
7
|
+
"图片展示",
|
|
8
|
+
"点击预览大图",
|
|
9
|
+
"多图轮播预览组"
|
|
10
|
+
],
|
|
11
|
+
"useCases": [
|
|
12
|
+
"产品详情图(单图 + 预览)",
|
|
13
|
+
"图片墙 / 相册(多图 + PreviewGroup 轮播)",
|
|
14
|
+
"用户头像(disabled preview)",
|
|
15
|
+
"需要 fallback 的弱网场景"
|
|
16
|
+
],
|
|
17
|
+
"riskLevel": "low"
|
|
18
|
+
},
|
|
19
|
+
"protocolSummary": "**3 个核心 import 入口**:\n1. `import Image from '@para-ui/core/Image'` (默认) 或 `import { Image } from '@para-ui/core'` (barrel)\n2. `Image.PreviewGroup` —— 复合组件,包裹多张 <Image> 实现轮播预览\n3. `import type { ImageProps } from '@para-ui/core/Image'` —— TS 类型\n\n**Props 来源**:Props 继承自 rc-image 的 ImageProps,**包含全部原生 <img> HTML 属性**(width / height / alt / src / loading 等)+ 4 个 rc-image 扩展字段(preview / fallback / placeholder / onError)。para-ui 在此基础上加了 `prefix-cls` 配置和默认 preview icons / mask",
|
|
20
|
+
"variants": {
|
|
21
|
+
"default": {
|
|
22
|
+
"meaning": "默认样式(无 variant 切换;尺寸用 width/height 控)"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"states": [
|
|
26
|
+
"loading",
|
|
27
|
+
"loaded",
|
|
28
|
+
"error"
|
|
29
|
+
],
|
|
30
|
+
"idealProps": {
|
|
31
|
+
"src": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "图片地址(透传给底层 <img>)"
|
|
34
|
+
},
|
|
35
|
+
"alt": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "替代文本(透传给底层 <img>,无障碍 + 加载失败前显示)"
|
|
38
|
+
},
|
|
39
|
+
"width": {
|
|
40
|
+
"type": "string | number",
|
|
41
|
+
"description": "图片宽度(透传给底层 <img>;数字默认 px,字符串可带单位)"
|
|
42
|
+
},
|
|
43
|
+
"height": {
|
|
44
|
+
"type": "string | number",
|
|
45
|
+
"description": "图片高度"
|
|
46
|
+
},
|
|
47
|
+
"preview": {
|
|
48
|
+
"type": "boolean | PreviewType",
|
|
49
|
+
"default": true,
|
|
50
|
+
"description": "**预览开关 + 配置**:\n- `true`(默认): 点击图片触发全屏预览(支持放大/旋转/翻转/重置/关闭,icons 已内置)\n- `false`: 关闭预览(点击图片无反应,适合纯展示 / 头像)\n- `{ mask?: ReactNode, getContainer?: () => HTMLElement, ... }`: 对象形式,自定义遮罩/挂载容器等(透传 rc-image PreviewType)"
|
|
51
|
+
},
|
|
52
|
+
"fallback": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"description": "**加载失败时显示的图片 URL**。底层 <img> onError 自动切换,无需手动传 onError"
|
|
55
|
+
},
|
|
56
|
+
"placeholder": {
|
|
57
|
+
"type": "ReactNode",
|
|
58
|
+
"description": "**加载中占位**(可以是文字 / 骨架屏 / 旋转图标 / Spin 组件等任意 JSX)。仅在 loading 阶段渲染"
|
|
59
|
+
},
|
|
60
|
+
"onError": {
|
|
61
|
+
"type": "(event: React.SyntheticEvent<HTMLImageElement>) => void",
|
|
62
|
+
"description": "原生 <img> onError 事件透传。**注意**:fallback 已经在 rc-image 内部监听 onError 自动切换 src,通常不需要再传 onError(除非有额外逻辑)"
|
|
63
|
+
},
|
|
64
|
+
"className": {
|
|
65
|
+
"type": "string",
|
|
66
|
+
"description": "应用到 <img> 元素的 className(不是外层 wrapper)"
|
|
67
|
+
},
|
|
68
|
+
"rootClassName": {
|
|
69
|
+
"type": "string",
|
|
70
|
+
"description": "应用到外层 wrapper <div> 的 className"
|
|
71
|
+
},
|
|
72
|
+
"style": {
|
|
73
|
+
"type": "React.CSSProperties",
|
|
74
|
+
"description": "<img> 元素的 style(数字 width/height 也可写在 style 里)"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"subComponents": {
|
|
78
|
+
"Image.PreviewGroup": {
|
|
79
|
+
"import": "// 通过 Image 复合属性访问: <Image.PreviewGroup>...</Image.PreviewGroup>",
|
|
80
|
+
"purpose": "多张 Image 包裹在一起实现轮播预览(打开任一张图后,可左右切换浏览组内其他图)",
|
|
81
|
+
"props": "GroupConsumerProps (来自 rc-image),preview 字段同 Image.preview"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"commonMisconceptions": {
|
|
85
|
+
"M1": {
|
|
86
|
+
"wrong": "认为 preview prop 需要配合 onPreview 回调或外部 Modal 才能工作: `<Image src={url} onPreview={...} />`",
|
|
87
|
+
"result": "Image **没有 onPreview prop** —— 预览功能完全内置(rc-image 内部弹层 + 内置 icons)。传 onPreview 会被 TS 忽略",
|
|
88
|
+
"fix": "只要 preview=true(默认),点击图片自动弹出预览。需要自定义遮罩内容用 `preview={{ mask: <CustomMask /> }}` 对象形式"
|
|
89
|
+
},
|
|
90
|
+
"M2": {
|
|
91
|
+
"wrong": "想关闭预览写 `<Image src={url} preview={null} />` 或 `preview={undefined}`",
|
|
92
|
+
"result": "**只有显式 `preview={false}` 才关闭预览** —— null/undefined 都被当作 truthy(走默认 true 分支)",
|
|
93
|
+
"fix": "关闭预览:`preview={false}`(布尔字面量)。条件性关闭:`preview={shouldDisable ? false : true}`"
|
|
94
|
+
},
|
|
95
|
+
"M3": {
|
|
96
|
+
"wrong": "为加载失败 fallback 手动写 onError 切换 src: `<Image src={url} onError={e => e.target.src = fallbackUrl} />`",
|
|
97
|
+
"result": "可以工作但**冗余且容易出 bug**(setState 时机问题、TS 类型问题)",
|
|
98
|
+
"fix": "用 fallback prop:`<Image src={url} fallback={'/img/broken.png'} />` —— rc-image 内部 onError 自动切换"
|
|
99
|
+
},
|
|
100
|
+
"M4": {
|
|
101
|
+
"wrong": "认为 Image 只接受 component.json idealProps 列出的 4 个字段(src / alt / preview / fallback),width/height/style 不接受",
|
|
102
|
+
"result": "Image 实际继承 rc-image 的 ImageProps,**全部原生 <img> 属性都接受**(width/height/loading/decoding/crossOrigin/referrerPolicy/sizes/srcSet 等)",
|
|
103
|
+
"fix": "需要的 img 属性直接传即可。component.json idealProps 是常用字段,不是完整 props 清单"
|
|
104
|
+
},
|
|
105
|
+
"M5": {
|
|
106
|
+
"wrong": "用 PreviewGroup 时给每张 Image 单独设 preview prop: `<Image.PreviewGroup>{imgs.map(u => <Image src={u} preview />)}</Image.PreviewGroup>`",
|
|
107
|
+
"result": "可以工作,但 PreviewGroup 自己的 preview prop 才是统一控制入口。单个 Image 的 preview 在 Group 上下文中会被合并",
|
|
108
|
+
"fix": "推荐:`<Image.PreviewGroup preview={{ ...sharedConfig }}>{imgs.map(u => <Image src={u} />)}</Image.PreviewGroup>` —— 组级配置一次写,所有图共享"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"completeExample": "// 1. 基本单图 + 预览\nimport Image from '@para-ui/core/Image';\n\nconst BasicDemo = () => (\n <Image\n src='https://example.com/photo.jpg'\n alt='示例图片'\n width={200}\n height={150}\n fallback='https://example.com/broken.png'\n />\n);\n\n// 2. 多图轮播组 (PreviewGroup)\nconst GalleryDemo = () => (\n <Image.PreviewGroup>\n <Image src='https://example.com/1.jpg' width={120} />\n <Image src='https://example.com/2.jpg' width={120} />\n <Image src='https://example.com/3.jpg' width={120} />\n </Image.PreviewGroup>\n);\n\n// 3. 关闭预览的头像\nconst AvatarDemo = () => (\n <Image\n src='https://example.com/avatar.jpg'\n alt='用户头像'\n width={48}\n height={48}\n preview={false} // 头像通常不需要预览\n style={{ borderRadius: '50%' }}\n />\n);\n\n// 4. 加载占位 + 失败 fallback\nconst RobustDemo = () => (\n <Image\n src='https://maybe-slow.example.com/photo.jpg'\n alt='可能慢的图'\n width={300}\n height={200}\n placeholder={<div style={{ background: '#eee', width: 300, height: 200 }}>加载中...</div>}\n fallback='/img/default-broken.png'\n />\n);",
|
|
112
|
+
"do": [
|
|
113
|
+
"**单图预览**:`<Image src={url} preview />` 即可(默认 preview=true,无需配置)",
|
|
114
|
+
"**多图轮播**:用 `<Image.PreviewGroup>` 包裹,自动支持左右切换",
|
|
115
|
+
"**关闭预览**:必须显式传 `preview={false}`(头像 / 装饰图 / 纯展示)",
|
|
116
|
+
"**加载失败兜底**:用 `fallback` prop 而不是手动写 onError(M3)",
|
|
117
|
+
"需要的原生 img 属性(width/height/loading 等)直接传(M4)"
|
|
118
|
+
],
|
|
119
|
+
"dont": [
|
|
120
|
+
"**不要**写 onPreview / showPreview prop——它不存在,预览完全内置(M1)",
|
|
121
|
+
"**不要**用 preview={null} / preview={undefined} 关预览——只有 false 生效(M2)",
|
|
122
|
+
"**不要**手动写 onError 实现 fallback——用 fallback prop(M3)",
|
|
123
|
+
"**不要**以为 Image 只接受 idealProps 4 字段——它继承全部原生 img + rc-image 字段(M4)",
|
|
124
|
+
"**不要**在 PreviewGroup 内给每张图独立设 preview——用 Group 级别配置(M5)",
|
|
125
|
+
"忽略 alt(无障碍 + SEO + 失败前显示)",
|
|
126
|
+
"不设置 width/height(避免布局跳动)"
|
|
127
|
+
],
|
|
128
|
+
"events": {
|
|
129
|
+
"onError": {
|
|
130
|
+
"signature": "(event: React.SyntheticEvent<HTMLImageElement>) => void",
|
|
131
|
+
"asyncSupported": false,
|
|
132
|
+
"examples": [
|
|
133
|
+
"onError={(e) => console.error('图片加载失败', e)} — 用于上报/监控,通常配合 fallback 使用",
|
|
134
|
+
"只需要兜底图不需要监听:直接用 fallback prop,不需要手写 onError",
|
|
135
|
+
"需要额外逻辑(如记录 404 url):onError={(e) => { reportBrokenImage(src); }} 和 fallback='/broken.png' 共存"
|
|
136
|
+
],
|
|
137
|
+
"commonMistakes": [
|
|
138
|
+
"手写 onError 切换 src: onError={(e) => (e.target as HTMLImageElement).src = fallbackUrl} — 冗余且有 setState 时机问题,用 fallback prop 替代",
|
|
139
|
+
"期望 onError 在 preview 打开时大图失败触发——onError 绑定在缩略图 <img> 上,预览大图的错误无法捕获",
|
|
140
|
+
"传了 fallback 又传 onError 期望双重兜底——fallback 内部会先触发 onError 切换 src,自定义 onError 也会同时触发,注意不要重复处理"
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"typescriptPitfalls": [
|
|
145
|
+
{
|
|
146
|
+
"issue": "preview={null} 或 preview={undefined} 不会关闭预览——只有 preview={false} 才关闭",
|
|
147
|
+
"wrong": "const noPreview = null; <Image src={url} preview={noPreview} /> // null 被视为 truthy 条件的对象分支,预览仍开启",
|
|
148
|
+
"right": "<Image src={url} preview={false} /> // 布尔字面量 false,或条件写法: preview={shouldDisable ? false : true}"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"issue": "Image 的 props 继承自 rc-image ImageProps,不是自定义 Props 类型,部分原生 img 属性可能有类型差异",
|
|
152
|
+
"wrong": "import { ImageProps } from '@para-ui/core'; const props: ImageProps = { onLoad: () => {} }; // onLoad 在 rc-image 里类型和原生 img 略有差异",
|
|
153
|
+
"right": "import type { ImageProps } from '@para-ui/core/Image'; // 从子路径导入精确类型,避免 barrel 导出类型不一致"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"issue": "Image.PreviewGroup 是复合属性,不能从 @para-ui/core 直接解构",
|
|
157
|
+
"wrong": "import { Image, ImagePreviewGroup } from '@para-ui/core'; <ImagePreviewGroup> // ImagePreviewGroup 不是导出名",
|
|
158
|
+
"right": "import Image from '@para-ui/core/Image'; <Image.PreviewGroup> // 通过复合组件访问"
|
|
159
|
+
}
|
|
160
|
+
],
|
|
161
|
+
"mapping": {
|
|
162
|
+
"realComponent": "Image",
|
|
163
|
+
"adapter": null
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "InputCode",
|
|
3
|
+
"category": "Data Entry",
|
|
4
|
+
"description": "验证码输入组件,分两个子组件:InputCode.Card(独立多格卡片/下划线样式)+ InputCode.Input(含获取验证码按钮的一行式输入框)。两者均支持受控/非受控、倒计时、错误提示",
|
|
5
|
+
"semantic": {
|
|
6
|
+
"intent": [
|
|
7
|
+
"安全验证",
|
|
8
|
+
"验证码输入"
|
|
9
|
+
],
|
|
10
|
+
"useCases": [
|
|
11
|
+
"短信验证",
|
|
12
|
+
"邮箱验证",
|
|
13
|
+
"双因素认证"
|
|
14
|
+
],
|
|
15
|
+
"riskLevel": "high"
|
|
16
|
+
},
|
|
17
|
+
"protocolSummary": "**两个子组件差异对比**:\n- `InputCode.Card`:多格卡片式(每格一个字符),type='card'|'underline',value/onChange 是 string[],onFinish 在最后一格输入完成时触发,onReset 重新发送(返回 Promise<boolean>,true 才启动倒计时)\n- `InputCode.Input`:一体式(带获取验证码按钮),type='btnIntegrated'|'btnSplit',value/onChange 是 string(整串),onGetCode 点击获取验证码按钮时触发(返回 Promise<boolean>,true 才启动倒计时)\n\n**import 方式**: `import { InputCode } from '@para-ui/core'`,然后用 `<InputCode.Card />` 或 `<InputCode.Input />`",
|
|
18
|
+
"variants": {
|
|
19
|
+
"card": {
|
|
20
|
+
"meaning": "卡片样式(InputCode.Card type='card')"
|
|
21
|
+
},
|
|
22
|
+
"underline": {
|
|
23
|
+
"meaning": "下划线样式(InputCode.Card type='underline')"
|
|
24
|
+
},
|
|
25
|
+
"btnIntegrated": {
|
|
26
|
+
"meaning": "按钮与输入框合一(InputCode.Input type='btnIntegrated')"
|
|
27
|
+
},
|
|
28
|
+
"btnSplit": {
|
|
29
|
+
"meaning": "按钮与输入框分离(InputCode.Input type='btnSplit')"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"states": [
|
|
33
|
+
"default",
|
|
34
|
+
"error",
|
|
35
|
+
"countdown"
|
|
36
|
+
],
|
|
37
|
+
"subComponents": {
|
|
38
|
+
"InputCode.Card": {
|
|
39
|
+
"description": "多格卡片/下划线验证码输入;每格一字符,自动聚焦下一格,支持粘贴",
|
|
40
|
+
"props": "InputCodeCardProps",
|
|
41
|
+
"keyProps": "cardNumber(格数,默认6), type('card'|'underline'), value(string[]), onChange((val:string[])=>void), onFinish((val:string)=>void), onReset(()=>Promise<boolean>|boolean), refreshCountdown(触发倒计时), countdown(秒数), sendText(倒计时区域标题)"
|
|
42
|
+
},
|
|
43
|
+
"InputCode.Input": {
|
|
44
|
+
"description": "一行式验证码输入框 + 获取验证码按钮;value 是整串字符串",
|
|
45
|
+
"props": "InputCodeInputProps",
|
|
46
|
+
"keyProps": "type('btnIntegrated'|'btnSplit'), value(string), onChange((val:string)=>void), onGetCode(()=>Promise<boolean>|boolean), countdown(秒数), getCodeWidth(获取验证码按钮宽度), inputProps(TextField透传), label, required"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"idealProps": {
|
|
50
|
+
"cardNumber": {
|
|
51
|
+
"type": "number",
|
|
52
|
+
"default": 6,
|
|
53
|
+
"description": "(InputCode.Card)验证码格数"
|
|
54
|
+
},
|
|
55
|
+
"size": {
|
|
56
|
+
"type": "enum",
|
|
57
|
+
"values": [
|
|
58
|
+
"small",
|
|
59
|
+
"medium",
|
|
60
|
+
"large"
|
|
61
|
+
],
|
|
62
|
+
"default": "large",
|
|
63
|
+
"description": "大小"
|
|
64
|
+
},
|
|
65
|
+
"type": {
|
|
66
|
+
"type": "enum",
|
|
67
|
+
"values": [
|
|
68
|
+
"card",
|
|
69
|
+
"underline",
|
|
70
|
+
"btnIntegrated",
|
|
71
|
+
"btnSplit"
|
|
72
|
+
],
|
|
73
|
+
"default": "card",
|
|
74
|
+
"description": "样式类型:Card 子组件用 card/underline,Input 子组件用 btnIntegrated/btnSplit"
|
|
75
|
+
},
|
|
76
|
+
"value": {
|
|
77
|
+
"type": "string[] (Card) | string (Input)",
|
|
78
|
+
"description": "受控值:Card 是 string[](每格一项),Input 是 string(完整验证码串)"
|
|
79
|
+
},
|
|
80
|
+
"onChange": {
|
|
81
|
+
"type": "(val: string[]) => void (Card) | (val: string) => void (Input)",
|
|
82
|
+
"description": "值变化回调;类型随子组件不同"
|
|
83
|
+
},
|
|
84
|
+
"onFinish": {
|
|
85
|
+
"type": "(val: string) => void",
|
|
86
|
+
"description": "(InputCode.Card)最后一格输入完成时触发,val 是所有格拼接的完整字符串"
|
|
87
|
+
},
|
|
88
|
+
"onReset": {
|
|
89
|
+
"type": "() => Promise<boolean> | boolean",
|
|
90
|
+
"description": "(InputCode.Card)点击重新发送时触发;返回 true 才启动倒计时"
|
|
91
|
+
},
|
|
92
|
+
"onGetCode": {
|
|
93
|
+
"type": "() => Promise<boolean> | boolean",
|
|
94
|
+
"description": "(InputCode.Input)点击获取验证码按钮时触发;返回 true 才启动倒计时"
|
|
95
|
+
},
|
|
96
|
+
"countdown": {
|
|
97
|
+
"type": "number",
|
|
98
|
+
"default": 60,
|
|
99
|
+
"description": "倒计时秒数"
|
|
100
|
+
},
|
|
101
|
+
"refreshCountdown": {
|
|
102
|
+
"type": "number | undefined",
|
|
103
|
+
"description": "(InputCode.Card)变更为非 undefined 时触发倒计时重置;通常传递递增计数器触发"
|
|
104
|
+
},
|
|
105
|
+
"error": {
|
|
106
|
+
"type": "boolean",
|
|
107
|
+
"default": false,
|
|
108
|
+
"description": "错误态"
|
|
109
|
+
},
|
|
110
|
+
"helperText": {
|
|
111
|
+
"type": "ReactNode",
|
|
112
|
+
"description": "错误提示文案"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"do": [
|
|
116
|
+
"自动聚焦下一个输入框(InputCode.Card 内置行为)",
|
|
117
|
+
"支持粘贴完整验证码(InputCode.Card 自动拆分到各格)",
|
|
118
|
+
"验证码位数与后端接口保持一致,通过 cardNumber 配置",
|
|
119
|
+
"onReset/onGetCode 配合接口请求:return await sendSMS() 成功才启动倒计时"
|
|
120
|
+
],
|
|
121
|
+
"dont": [
|
|
122
|
+
"验证码位数与后端不一致——cardNumber 默认 6,后端 4 位时必须显式传 cardNumber={4}",
|
|
123
|
+
"没有倒计时限制——必须配置 countdown + onReset/onGetCode 防止频繁请求",
|
|
124
|
+
"Card 和 Input 子组件混用 value 类型——Card 是 string[],Input 是 string,混用导致类型错误"
|
|
125
|
+
],
|
|
126
|
+
"events": {
|
|
127
|
+
"onChange": {
|
|
128
|
+
"signature": "(val: string[]) => void (Card) | (val: string) => void (Input)",
|
|
129
|
+
"asyncSupported": false,
|
|
130
|
+
"examples": [
|
|
131
|
+
"InputCode.Card: onChange={(val) => setCode(val)} — val 是 string[],如 ['1','2','3','4','5','6']",
|
|
132
|
+
"InputCode.Input: onChange={(val) => setCode(val)} — val 是整串字符串,如 '123456'",
|
|
133
|
+
"受控模式:需同时传 value 和 onChange,否则输入会被重置"
|
|
134
|
+
],
|
|
135
|
+
"commonMistakes": [
|
|
136
|
+
"Card 子组件把 onChange 当 string 类型使用——Card.onChange 是 (val: string[]) => void 而不是 (val: string) => void",
|
|
137
|
+
"只传 onChange 不传 value 期望半受控——两者都传或都不传,半受控(有 onChange 无 value)在 rc 体系里行为不稳定",
|
|
138
|
+
"期望 onChange 在初始化时触发——组件 mount 时不触发 onChange,只在用户输入/粘贴时触发"
|
|
139
|
+
]
|
|
140
|
+
},
|
|
141
|
+
"onFinish": {
|
|
142
|
+
"signature": "(val: string) => void",
|
|
143
|
+
"asyncSupported": false,
|
|
144
|
+
"examples": [
|
|
145
|
+
"onFinish={(code) => verifyCode(code)} — 最后一格输入完成时触发,val 是 cardNumber 个字符拼接的字符串",
|
|
146
|
+
"onFinish={(code) => { if (code.length === cardNumber) submit(code); }} — 可在回调里额外校验长度",
|
|
147
|
+
"onFinish 不在 InputCode.Input 上——Input 子组件无 onFinish,需自己判断 onChange 的 val.length === 期望长度"
|
|
148
|
+
],
|
|
149
|
+
"commonMistakes": [
|
|
150
|
+
"在 InputCode.Input 上找 onFinish——Input 子组件没有 onFinish prop,只有 onChange",
|
|
151
|
+
"期望 onFinish 触发时验证码一定全填——用户可能粘贴后再清除,建议在 onFinish 里再次校验 val.length",
|
|
152
|
+
"传了 value 受控但 onFinish 里直接调接口不等 onChange 更新——受控模式 onChange 触发后父组件需更新 value,onFinish 里的 val 是当前内部状态"
|
|
153
|
+
]
|
|
154
|
+
},
|
|
155
|
+
"onReset": {
|
|
156
|
+
"signature": "() => Promise<boolean> | boolean",
|
|
157
|
+
"asyncSupported": true,
|
|
158
|
+
"examples": [
|
|
159
|
+
"onReset={async () => { const ok = await sendSMS(); return ok; }} — 返回 true 时启动倒计时,false 时不启动",
|
|
160
|
+
"onReset={() => true} — 测试用,直接返回 true 立即启动倒计时",
|
|
161
|
+
"onReset={async () => { try { await api.resend(); return true; } catch { return false; } }} — 接口失败时返回 false 不重置倒计时"
|
|
162
|
+
],
|
|
163
|
+
"commonMistakes": [
|
|
164
|
+
"onReset 没有 return 值——隐式返回 undefined,被当作 falsy,倒计时不启动",
|
|
165
|
+
"在 InputCode.Input 上传 onReset——Input 子组件的对应 prop 是 onGetCode,不是 onReset",
|
|
166
|
+
"期望 onReset 触发时自动清空验证码格——src 不自动清空 value,需父组件在 onReset 里手动 setValue(new Array(cardNumber).fill(''))"
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
"typescriptPitfalls": [
|
|
171
|
+
{
|
|
172
|
+
"issue": "InputCode.Card 和 InputCode.Input 的 value/onChange 类型不同,不能共用同一个 state",
|
|
173
|
+
"wrong": "const [code, setCode] = useState<string>(''); <InputCode.Card value={code} onChange={setCode} /> // Card value 是 string[],TS2322",
|
|
174
|
+
"right": "const [code, setCode] = useState<string[]>([]); <InputCode.Card value={code} onChange={setCode} /> // Card 用 string[]"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"issue": "onReset/onGetCode 返回类型是 Promise<boolean> | boolean,必须有明确返回值",
|
|
178
|
+
"wrong": "onReset={async () => { await sendSMS(); }} // 没有 return,隐式 undefined,倒计时不启动",
|
|
179
|
+
"right": "onReset={async () => { await sendSMS(); return true; }} // 明确 return true 才启动倒计时"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"issue": "refreshCountdown 触发倒计时的是「值变化」不是「变成非 undefined」,传固定值无效",
|
|
183
|
+
"wrong": "// 用 boolean 控制:refreshCountdown={shouldRefresh ? 1 : undefined} // 只在第一次 undefined→1 时触发,第二次不变",
|
|
184
|
+
"right": "const [counter, setCounter] = useState(0); // 每次重置递增\nonReset={async () => { setCounter(c => c+1); return true; }}\n<InputCode.Card refreshCountdown={counter} />"
|
|
185
|
+
}
|
|
186
|
+
],
|
|
187
|
+
"mapping": {
|
|
188
|
+
"realComponent": "InputCode",
|
|
189
|
+
"adapter": null
|
|
190
|
+
}
|
|
191
|
+
}
|