@para-ui/core 5.0.0-beta.12 → 5.0.0-beta.14
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/codemods/modal-onCancel-to-onDismiss.js +69 -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/Cascader.js +188 -180
- 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 +41 -33
- 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 +299 -287
- package/es/ComboSelect/interface.d.ts +6 -3
- 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.d.ts +0 -8
- package/es/DatePicker/generatePicker/generateRangePicker.js +73 -65
- package/es/DatePicker/generatePicker/generateSinglePicker.js +1 -1
- package/es/DatePicker/generatePicker/index.d.ts +11 -4
- 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/Confirm/index.js +81 -75
- package/es/Modal/component.json +277 -0
- package/es/Modal/index.d.ts +97 -6
- package/es/Modal/index.js +174 -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 +74 -63
- 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/Cascader.js +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 +6 -3
- 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.d.ts +0 -8
- package/lib/DatePicker/generatePicker/generateRangePicker.js +1 -1
- package/lib/DatePicker/generatePicker/generateSinglePicker.js +1 -1
- package/lib/DatePicker/generatePicker/index.d.ts +11 -4
- 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/Confirm/index.js +1 -1
- package/lib/Modal/component.json +277 -0
- package/lib/Modal/index.d.ts +97 -6
- 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 +10 -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,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
|
+
}
|
package/lib/InputCode/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export interface InputCodeCardProps extends HelperTextDetailProps {
|
|
|
34
34
|
onFinish?: (val: string) => void;
|
|
35
35
|
/** 重新发送 */
|
|
36
36
|
onReset?: () => Promise<boolean> | boolean;
|
|
37
|
-
[name: string]:
|
|
37
|
+
[name: string]: unknown;
|
|
38
38
|
}
|
|
39
39
|
export interface InputCodeInputProps extends HelperTextDetailProps {
|
|
40
40
|
/** 样式class */
|
|
@@ -66,7 +66,7 @@ export interface InputCodeInputProps extends HelperTextDetailProps {
|
|
|
66
66
|
onChange?: (val: string) => void;
|
|
67
67
|
/** 获取验证码事件 */
|
|
68
68
|
onGetCode?: () => Promise<boolean> | boolean;
|
|
69
|
-
[name: string]:
|
|
69
|
+
[name: string]: unknown;
|
|
70
70
|
}
|
|
71
71
|
type MergedInputCode = {
|
|
72
72
|
Card: typeof InputCodeCard;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "InputLang",
|
|
3
|
+
"category": "Data Entry",
|
|
4
|
+
"description": "多语言输入框,支持多语种内容录入 + 语种切换。内部维护多语对象 `{[langKey]: string}`,通过 typeOutput 控制输出形态(对象 / JSON 字符串)",
|
|
5
|
+
"semantic": {
|
|
6
|
+
"intent": [
|
|
7
|
+
"多语言内容录入",
|
|
8
|
+
"国际化字段管理",
|
|
9
|
+
"翻译数据编辑"
|
|
10
|
+
],
|
|
11
|
+
"useCases": [
|
|
12
|
+
"i18n 产品名 / 标签 / 描述录入",
|
|
13
|
+
"翻译管理后台",
|
|
14
|
+
"多语种 SEO 字段"
|
|
15
|
+
],
|
|
16
|
+
"riskLevel": "normal"
|
|
17
|
+
},
|
|
18
|
+
"keyFormatBehavior": {
|
|
19
|
+
"supportedFormats": "**支持任意字符串作为 langKey**:短码('zh'/'en')、BCP 47('zh-CN'/'en-US'/'ja-JP')、自定义键名都可以。组件**不校验键名格式**,只把 langList 条目当作 value 对象的 key 使用",
|
|
20
|
+
"examples": "// 都合法:\n<InputLang langList={['zh', 'en']} value={{zh: '你好', en: 'Hello'}} />\n<InputLang langList={['zh-CN', 'en-US']} value={{'zh-CN': '你好', 'en-US': 'Hello'}} />\n<InputLang langList={['simplified', 'traditional']} value={{simplified: '你好', traditional: '妳好'}} />",
|
|
21
|
+
"warning": "**value 对象的 key 必须与 langList 字符串/value 字段完全匹配**(区分大小写 + 区分连字符)。例如 langList=['zh-CN'] 但 value={zh: '你好'} 时,InputLang 切到 zh-CN 标签后读不到值"
|
|
22
|
+
},
|
|
23
|
+
"langListDisplayBehavior": {
|
|
24
|
+
"stringMode": "**简写 string[] 模式**:每个字符串既是 value(内部 key)又是 label(弹层显示文本)。例 `langList={['zh-CN', 'en-US']}` 时,弹层切换 tab 显示的是 'zh-CN' / 'en-US' 字符串本身,**不是 '中文' / '英文' 本地化名称**",
|
|
25
|
+
"objectMode": "**对象 `{label, value}[]` 模式**:label 用于弹层显示,value 用于 value 对象的 key。例 `langList={[{label: '中文', value: 'zh-CN'}, {label: 'English', value: 'en-US'}]}`,弹层显示 '中文' / 'English' 友好文本,内部 value 对象用 'zh-CN' / 'en-US' 作 key",
|
|
26
|
+
"useWhen": "纯开发场景(配置 / 调试):用 string[] 简洁。**用户面向场景:用 {label, value}[] 配本地化文本**(string[] 显示原始 key 不友好)"
|
|
27
|
+
},
|
|
28
|
+
"variants": {
|
|
29
|
+
"default": {
|
|
30
|
+
"meaning": "默认样式"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"states": [
|
|
34
|
+
"default",
|
|
35
|
+
"disabled",
|
|
36
|
+
"error"
|
|
37
|
+
],
|
|
38
|
+
"idealProps": {
|
|
39
|
+
"size": {
|
|
40
|
+
"type": "enum",
|
|
41
|
+
"values": [
|
|
42
|
+
"small",
|
|
43
|
+
"medium",
|
|
44
|
+
"large"
|
|
45
|
+
],
|
|
46
|
+
"default": "large",
|
|
47
|
+
"description": "大小"
|
|
48
|
+
},
|
|
49
|
+
"label": {
|
|
50
|
+
"type": "ReactNode",
|
|
51
|
+
"description": "标题"
|
|
52
|
+
},
|
|
53
|
+
"labelTooltip": {
|
|
54
|
+
"type": "LabelTooltipProps",
|
|
55
|
+
"description": "标题旁帮助提示;对象,见 Label 组件 LabelTooltipProps"
|
|
56
|
+
},
|
|
57
|
+
"placeholder": {
|
|
58
|
+
"type": "string",
|
|
59
|
+
"description": "输入值的提示语(非语言键)"
|
|
60
|
+
},
|
|
61
|
+
"placeholderKey": {
|
|
62
|
+
"type": "string",
|
|
63
|
+
"description": "语言键侧的提示语;label='国际化' 模式常配合 placeholder 使用"
|
|
64
|
+
},
|
|
65
|
+
"placeholderValue": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"description": "翻译值侧的提示语"
|
|
68
|
+
},
|
|
69
|
+
"langList": {
|
|
70
|
+
"type": "(string | { label: string; value: string })[]",
|
|
71
|
+
"default": "['zh', 'en']",
|
|
72
|
+
"description": "**支持的语种列表**。两种形态:① 简写 string[] 如 `['zh', 'en']` —— 弹层显示原始 key 字符串(非本地化名);② 对象 `{label, value}[]` 如 `[{label:'中文',value:'zh'}]` —— 弹层显示 label 文本,内部用 value 作 key。**任意字符串都可作 langKey**(短码 / BCP 47 / 自定义,见 keyFormatBehavior)"
|
|
73
|
+
},
|
|
74
|
+
"value": {
|
|
75
|
+
"type": "string | { [name: string]: string }",
|
|
76
|
+
"description": "**受控值,形态由 typeOutput 控制**:typeOutput='object'(默认)→ `{zh:'输入框', en:'...'}` 多语对象;typeOutput='string' → JSON 字符串如 `'{\"zh\":\"输入框\",\"en\":\"...\",\"_i18n\":1}'`。**注:不是 Record<string,string>**(虽然语义上等价,签名是 `{[name]: string}` 索引签名形态),业务用 Record<string,string> 时需要 `as unknown as` 中转"
|
|
77
|
+
},
|
|
78
|
+
"defaultValue": {
|
|
79
|
+
"type": "string | { [name: string]: string }",
|
|
80
|
+
"description": "非受控初始值;形态同 value。可与 langList string[] 简写组合使用(两者正交)"
|
|
81
|
+
},
|
|
82
|
+
"onChange": {
|
|
83
|
+
"type": "(val: string | { [name: string]: string }) => void",
|
|
84
|
+
"description": "值变化回调;val 形态随 typeOutput 变化(string 或对象)。**业务签名 (val: Record<string, string>) => void**:可用 typeof 守卫 + `as unknown as Record<string,string>` 处理"
|
|
85
|
+
},
|
|
86
|
+
"typeOutput": {
|
|
87
|
+
"type": "enum",
|
|
88
|
+
"values": [
|
|
89
|
+
"string",
|
|
90
|
+
"object"
|
|
91
|
+
],
|
|
92
|
+
"default": "object",
|
|
93
|
+
"description": "输出类型;'object' 输出多语对象,'string' 输出 JSON 字符串(含 _i18n 标识位)"
|
|
94
|
+
},
|
|
95
|
+
"required": {
|
|
96
|
+
"type": "boolean",
|
|
97
|
+
"default": "false",
|
|
98
|
+
"description": "是否必填"
|
|
99
|
+
},
|
|
100
|
+
"disabled": {
|
|
101
|
+
"type": "boolean",
|
|
102
|
+
"default": "false",
|
|
103
|
+
"description": "是否禁用"
|
|
104
|
+
},
|
|
105
|
+
"disabledTooltip": {
|
|
106
|
+
"type": "TooltipProps",
|
|
107
|
+
"description": "禁用态 hover 提示。**常用字段**:`title: ReactNode`(提示内容,最常用)、`placement?: 'top'|'bottom'|'left'|'right'|...`(方向)、`arrow?: boolean`(显示箭头)。完整字段见 Tooltip 组件文档"
|
|
108
|
+
},
|
|
109
|
+
"error": {
|
|
110
|
+
"type": "boolean",
|
|
111
|
+
"default": "false",
|
|
112
|
+
"description": "错误态视觉"
|
|
113
|
+
},
|
|
114
|
+
"helperText": {
|
|
115
|
+
"type": "ReactNode",
|
|
116
|
+
"description": "错误文本/辅助文本"
|
|
117
|
+
},
|
|
118
|
+
"hideErrorDom": {
|
|
119
|
+
"type": "boolean | null",
|
|
120
|
+
"description": "true=无错误时不渲染占位;false=都渲染;null=不渲染直接返回 null。见 HelperText 同名 prop"
|
|
121
|
+
},
|
|
122
|
+
"limitLength": {
|
|
123
|
+
"type": "number",
|
|
124
|
+
"description": "输入长度上限"
|
|
125
|
+
},
|
|
126
|
+
"i18n": {
|
|
127
|
+
"type": "boolean",
|
|
128
|
+
"description": "i18n 标识;typeOutput='string' 时默认 true(向输出 JSON 注入 _i18n=1)"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
"commonMisconceptions": {
|
|
132
|
+
"M1": {
|
|
133
|
+
"wrong": "传 langList=['zh-CN', 'en-US'] 但 value={{ zh: '你好', en: 'Hello' }}(value 用短码 key)",
|
|
134
|
+
"result": "InputLang 切换到 'zh-CN' / 'en-US' 标签时读不到 value(因为 value 对象用的是 'zh'/'en' 短码 key) → 显示空内容",
|
|
135
|
+
"fix": "**langList 字符串/value 字段与 value 对象 key 必须完全一致**:要么都用短码(`langList=['zh','en']` + `value={{zh:'',en:''}}`),要么都用 BCP 47(`langList=['zh-CN','en-US']` + `value={{'zh-CN':'','en-US':''}}`)"
|
|
136
|
+
},
|
|
137
|
+
"M2": {
|
|
138
|
+
"wrong": "用 langList=['zh-CN', 'en-US'] 期望弹层显示 '中文' / 'English' 友好文本",
|
|
139
|
+
"result": "**string[] 简写模式弹层显示原始字符串**(显示 'zh-CN' / 'en-US' 而非翻译名)",
|
|
140
|
+
"fix": "用对象形式 `langList={[{label: '中文', value: 'zh-CN'}, {label: 'English', value: 'en-US'}]}` —— label 是显示文本,value 是内部 key"
|
|
141
|
+
},
|
|
142
|
+
"M3": {
|
|
143
|
+
"wrong": "在 onChange 回调签名是 `(val: Record<string, string>) => void` 的业务接口里直接接 InputLang.onChange,期望 TS 自动兼容",
|
|
144
|
+
"result": "**InputLang.onChange 签名是 `(val: string | { [name: string]: string }) => void`**,有 string 联合分支。直接传业务 callback 会因 string 分支不兼容 → TS 报错",
|
|
145
|
+
"fix": "用 typeof 守卫 + cast: `onChange={(val) => { if (typeof val !== 'string') businessCallback(val as unknown as Record<string, string>); }}` 或者用 typeOutput='object' 保证不会出现 string 分支"
|
|
146
|
+
},
|
|
147
|
+
"M4": {
|
|
148
|
+
"wrong": "假设 langList 默认值是空数组",
|
|
149
|
+
"result": "**默认值是 `['zh', 'en']`**(代码 L114 实证)。不传 langList 时 InputLang 仍然显示 zh/en 两个语种 tab",
|
|
150
|
+
"fix": "需要纯空白:显式传 `langList={[]}`(罕见)。需要完全自定义语种:传完整 langList 覆盖默认"
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"do": [
|
|
154
|
+
"**langList 字符串/value 字段与 value 对象 key 一致**(全短码或全 BCP 47,见 M1)",
|
|
155
|
+
"**用户面向场景用对象形式 langList**(配 label 本地化文本,M2)",
|
|
156
|
+
"**业务 callback Record<string,string>**:typeof 守卫 + as unknown as 中转(M3)",
|
|
157
|
+
"**typeOutput 默认 'object'** —— 直接用对象形态;只在需要 JSON 持久化时用 'string'",
|
|
158
|
+
"禁用态配合 disabledTooltip={{title: '已归档,不可编辑'}} 给业务语义化提示"
|
|
159
|
+
],
|
|
160
|
+
"dont": [
|
|
161
|
+
"**不要**让 langList key 与 value 对象 key 不一致 —— 读不到值(M1)",
|
|
162
|
+
"**不要**用 string[] langList 期望本地化显示 —— 显示原始 key(M2)",
|
|
163
|
+
"**不要**直接对接 Record<string,string> 业务 callback —— 联合签名不兼容(M3)",
|
|
164
|
+
"**不要**忘记不传 langList 时默认 ['zh','en'] —— 不是空数组(M4)",
|
|
165
|
+
"语言列表过多(>5)导致下拉过长 —— 考虑分组",
|
|
166
|
+
"忽略默认语言设置"
|
|
167
|
+
],
|
|
168
|
+
"events": {
|
|
169
|
+
"onChange": {
|
|
170
|
+
"signature": "(val: string | { [name: string]: string }) => void",
|
|
171
|
+
"asyncSupported": false,
|
|
172
|
+
"examples": [
|
|
173
|
+
"typeOutput='object'(默认): onChange={(val) => { if (typeof val !== 'string') setState(val as Record<string,string>); }} — 对象形态,{zh:'内容', en:'content'}",
|
|
174
|
+
"typeOutput='string': onChange={(val) => { if (typeof val === 'string') setState(val); }} — JSON 字符串形态,'{\"zh\":\"内容\",\"_i18n\":1}'",
|
|
175
|
+
"弹窗关闭时触发(不是实时):用户在弹窗内修改其他语种值,关闭弹窗后 onChange 才触发一次完整 val"
|
|
176
|
+
],
|
|
177
|
+
"commonMistakes": [
|
|
178
|
+
"onChange 签名写成 (val: Record<string, string>) => void 直接接入——TypeScript 报错,InputLang.onChange 联合 string 分支,需 typeof 守卫",
|
|
179
|
+
"期望每次按键都触发 onChange——主语言(当前展示语言)实时触发,其他语言在弹窗关闭时批量触发一次",
|
|
180
|
+
"typeOutput='string' 时期望 onChange 返回的 val 是纯 JSON——实际含 _i18n 标识位,需 JSON.parse 后 delete _i18n 才是干净数据"
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
"typescriptPitfalls": [
|
|
185
|
+
{
|
|
186
|
+
"issue": "onChange 签名是联合类型,直接接业务 Record<string,string> 回调触发 TS 不兼容",
|
|
187
|
+
"wrong": "const handler = (val: Record<string, string>) => setState(val); <InputLang onChange={handler} /> // 报 TS2322:string 分支和 Record 不兼容",
|
|
188
|
+
"right": "<InputLang onChange={(val) => { if (typeof val !== 'string') setState(val as unknown as Record<string,string>); }} />"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"issue": "value 类型签名是 `string | { [name: string]: string }` 不是 `Record<string, string>`,在 TS 5.x 可能触发 TS2352 直接 as cast 失败",
|
|
192
|
+
"wrong": "const data: Record<string,string> = {zh: '你好'}; <InputLang value={data as { [name: string]: string }} /> // TS5 strict 模式下拒绝结构兼容 as",
|
|
193
|
+
"right": "<InputLang value={data as unknown as { [name: string]: string }} /> // 用 unknown 中转"
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"issue": "langList 默认值是 ['zh', 'en'],不传时已经有两个语种 tab,不是空列表",
|
|
197
|
+
"wrong": "// 期望没有多语切换,不传 langList\n<InputLang value={val} onChange={onChange} /> // 实际显示 zh/en 两个 tab,点击地球图标弹出语种选择",
|
|
198
|
+
"right": "// 需要禁用多语:传 langList={[]}(无弹出语种)或 disabledAdd + disabledDelete + disabledKey 锁定行为"
|
|
199
|
+
}
|
|
200
|
+
],
|
|
201
|
+
"mapping": {
|
|
202
|
+
"realComponent": "InputLang",
|
|
203
|
+
"adapter": null
|
|
204
|
+
}
|
|
205
|
+
}
|
package/lib/InputLang/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./index.css');const u=require("../_virtual/jsx-runtime.js"),r=require("react"),be=require("../TextField/index.js"),he=require("../HelperText/index.js"),me=require("../MultiBox/index.js"),ve=require("../AutoTips/index.js"),je=require("../Popover/index.js"),ye=require("../node_modules/@para-ui/icons/Internet/index.js"),K=require("../Utils/snack-kit-shims.js"),g=require("../GlobalContext/constant.js"),Ce=require("../Hooks/useGlobalProps.js");;/* empty css */const W=f=>{const{className:$,style:z,label:H,labelTooltip:F,size:v="large",placeholder:q,placeholderKey:G,placeholderValue:J,error:L=!1,hideErrorDom:w,helperText:Q="",required:U=!1,popoverClassName:
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./index.css');const u=require("../_virtual/jsx-runtime.js"),r=require("react"),be=require("../TextField/index.js"),he=require("../HelperText/index.js"),me=require("../MultiBox/index.js"),ve=require("../AutoTips/index.js"),je=require("../Popover/index.js"),ye=require("../node_modules/@para-ui/icons/Internet/index.js"),K=require("../Utils/snack-kit-shims.js"),g=require("../GlobalContext/constant.js"),Ce=require("../Hooks/useGlobalProps.js");;/* empty css */const W=f=>{const{className:$,style:z,label:H,labelTooltip:F,size:v="large",placeholder:q,placeholderKey:G,placeholderValue:J,error:L=!1,hideErrorDom:w,helperText:Q="",required:U=!1,popoverClassName:S,value:M,onChange:N,langList:x=["zh","en"],limitLength:E,disabled:O=!1,disabledTooltip:X,defaultLang:j,disabledDelete:_,disabledAdd:Y,disabledKey:R,typeOutput:V="object",i18n:k}=Ce.default(f,"InputLang"),[Z,D]=r.useState(!1),[o,ee]=r.useState(K.GetLanguage()||"zh"),[I,te]=r.useState({}),[b,T]=r.useState({}),[d,A]=r.useState([]),a=r.useRef({lang:o,valueCom:b,langMapping:{},langLabelMapping:{}}),P=r.useRef(null);a.current.lang=o,a.current.disabledDelete=_,a.current.typeOutput=V,a.current.i18n=V==="string"&&k===void 0?!0:k,r.useEffect(()=>{f.defaultValue!==void 0&&y(f.defaultValue)},[]),r.useEffect(()=>{M!==void 0&&y(M)},[M]),r.useEffect(()=>{j!==void 0&&(ee(j),a.current.lang=j,y())},[j]),r.useEffect(()=>{if(x){const e={},t={};for(let l=0,i=x.length;l<i;l++){const n=x[l];typeof n=="string"?(e[n]={label:n,value:n},t[n]={label:n,value:n}):(e[n.value]=n,t[n.label]=n)}a.current.langMapping=e,a.current.langLabelMapping=t,te(e),y()}},[f.langList]);const y=e=>{let t;if(e){try{typeof e=="string"?t=JSON.parse(e):t=e||{}}catch{t={}}a.current.i18n===!0&&(a.current._i18n=t._i18n||1,delete t._i18n)}const l={...t||a.current.valueCom},i=[],n={};if(a.current.disabledDelete){const s=Object.keys(a.current.langMapping)||[];for(let h=0,p=s.length;h<p;h++){const C=a.current.langMapping[s[h]]||{},m=C.value,fe=C.label,xe=l[m];m!==a.current.lang&&(n[m]=!0,i.push({label:fe,value:xe||""}))}}const c=Object.keys(l);for(let s=0,h=c.length;s<h;s++){const p=c[s],C=l[p];if(!n[p]&&p!==a.current.lang){const m=a.current.langMapping[p]||{};i.push({label:m.label||p,value:C||""})}}a.current.valueCom={...l},A(i),T(l)},B=e=>{let t={...e};if(f.value===void 0&&(a.current.valueCom={...t},T(t)),a.current.typeOutput==="string")try{a.current.i18n===!0&&(t._i18n=String(a.current._i18n||1)),t=JSON.stringify(t)}catch{}N&&N(t)},ne=e=>{b[o]=e.target.value;const t={...b};B(t)},le=e=>{A([...e])},ae=(e,t)=>{const l=[],i=K.ArrayToObject("label",d);for(let n=0,c=x.length;n<c;n++){let s=x[n];typeof s=="object"&&(s=s.label),!i[s]&&s!==(I[o]?.label||o)&&l.push({label:s,value:s})}t(l)},se=()=>{D(!0)},re=e=>{if(e)return;D(!1);const t={};t[o]=b[o]||"";for(let l=0,i=d.length;l<i;l++){const n=d[l],c=a.current.langLabelMapping[n.label]?.value||n.label||"";c.trim()!==""&&(t[c]=n.value||"")}B(t)},ie=()=>u.jsxRuntimeExports.jsx("div",{className:"lang-key",children:u.jsxRuntimeExports.jsx(ve.default,{tipMaxWidth:"none",children:I[o]?.label||o})}),oe=r.useMemo(()=>u.jsxRuntimeExports.jsx("div",{className:"lang-list-icon",children:u.jsxRuntimeExports.jsx(ye.Internet,{})}),[]),ue=()=>{let e=`${g.$prefixCls}-input-lang-popover`;return S&&(e+=` ${S}`),Y&&(e+=` ${g.$prefixCls}-input-lang-popover-disabled-add`),_&&(e+=` ${g.$prefixCls}-input-lang-popover-disabled-delete`),e},ce=()=>{if(O===!0)return!0;const e=[];if(R){const t=typeof R=="object";for(let l=0,i=d.length;l<i;l++){const n=d[l].label||"",c=a.current.langLabelMapping[n]||{};t?e.push({[n]:R.indexOf(c.value||n)!==-1}):n.trim()!==""&&e.push({[n]:!0})}}return e},pe=(e,t)=>{const l={};return E&&(l.limitLength=E),l},de=()=>u.jsxRuntimeExports.jsx("div",{className:"input-lang-list",children:u.jsxRuntimeExports.jsx(me.MultiBox,{className:"input-lang-multi-box",size:v,disabled:ce(),value:d,onChange:le,fetchSuggestionsKey:ae,placeholderKey:G,placeholderValue:J||q,valueOtherProps:pe})}),ge=()=>{let e=`${g.$prefixCls}-input-lang`;return v&&(e+=` ${g.$prefixCls}-input-lang-${v}`),L&&(e+=` ${g.$prefixCls}-input-lang-error`),$&&(e+=` ${$}`),e};return u.jsxRuntimeExports.jsxs("div",{className:ge(),style:z,ref:P,children:[u.jsxRuntimeExports.jsx(je.Popover,{placement:"bottom-end",visible:Z,content:de(),onVisibleChange:re,overlayClassName:ue(),maxWidth:"none",overlayInnerStyle:{minWidth:"440px",width:`${P.current?.offsetWidth}px`},children:u.jsxRuntimeExports.jsx(be.TextField,{className:"input-lang-text-field",size:v,error:L,disabled:O,disabledTooltip:X,required:U,label:H,labelTooltip:F,placeholder:q,value:b[o]||"",rightIcon:oe,addonBefore:ie(),hideErrorDom:!0,limitLength:E,onClickIcon:se,onChange:ne})}),u.jsxRuntimeExports.jsx(he.default,{className:"input-lang-error-text",error:L,helperText:Q,hideErrorDom:w})]})};exports.InputLang=W;exports.default=W;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|