@will-ui/vue 1.0.0
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/LICENSE +21 -0
- package/README.md +48 -0
- package/TAILWIND.md +282 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/components/audioPlayer/AudioPlayer.d.ts +123 -0
- package/dist/components/audioPlayer/AudioPlayer.js +375 -0
- package/dist/components/audioPlayer/AudioPlayer.js.map +1 -0
- package/dist/components/audioPlayer/index.d.ts +2 -0
- package/dist/components/audioPlayer/style/index.css +1 -0
- package/dist/components/btn/Btn.d.ts +45 -0
- package/dist/components/btn/Btn.js +165 -0
- package/dist/components/btn/Btn.js.map +1 -0
- package/dist/components/btn/config.d.ts +33 -0
- package/dist/components/btn/config.js +20 -0
- package/dist/components/btn/config.js.map +1 -0
- package/dist/components/btn/context.d.ts +12 -0
- package/dist/components/btn/context.js +6 -0
- package/dist/components/btn/context.js.map +1 -0
- package/dist/components/btn/index.d.ts +5 -0
- package/dist/components/btn/style/index.css +1 -0
- package/dist/components/btnGroup/BtnGroup.d.ts +46 -0
- package/dist/components/btnGroup/BtnGroup.js +43 -0
- package/dist/components/btnGroup/BtnGroup.js.map +1 -0
- package/dist/components/btnGroup/config.d.ts +14 -0
- package/dist/components/btnGroup/config.js +11 -0
- package/dist/components/btnGroup/config.js.map +1 -0
- package/dist/components/btnGroup/index.d.ts +3 -0
- package/dist/components/btnGroup/style/index.css +1 -0
- package/dist/components/cascade/Cascade.d.ts +1957 -0
- package/dist/components/cascade/Cascade.js +283 -0
- package/dist/components/cascade/Cascade.js.map +1 -0
- package/dist/components/cascade/config.d.ts +30 -0
- package/dist/components/cascade/config.js +18 -0
- package/dist/components/cascade/config.js.map +1 -0
- package/dist/components/cascade/index.d.ts +3 -0
- package/dist/components/cascade/style/index.css +1 -0
- package/dist/components/checkbox/Checkbox.d.ts +241 -0
- package/dist/components/checkbox/Checkbox.js +182 -0
- package/dist/components/checkbox/Checkbox.js.map +1 -0
- package/dist/components/checkbox/config.d.ts +18 -0
- package/dist/components/checkbox/config.js +11 -0
- package/dist/components/checkbox/config.js.map +1 -0
- package/dist/components/checkbox/index.d.ts +3 -0
- package/dist/components/checkbox/style/index.css +1 -0
- package/dist/components/choose/Choose.d.ts +1016 -0
- package/dist/components/choose/Choose.js +402 -0
- package/dist/components/choose/Choose.js.map +1 -0
- package/dist/components/choose/config.d.ts +37 -0
- package/dist/components/choose/config.js +21 -0
- package/dist/components/choose/config.js.map +1 -0
- package/dist/components/choose/index.d.ts +3 -0
- package/dist/components/choose/injectionKey.d.ts +12 -0
- package/dist/components/choose/injectionKey.js +11 -0
- package/dist/components/choose/injectionKey.js.map +1 -0
- package/dist/components/choose/style/index.css +1 -0
- package/dist/components/choose2/Choose2.d.ts +1711 -0
- package/dist/components/choose2/Choose2.js +403 -0
- package/dist/components/choose2/Choose2.js.map +1 -0
- package/dist/components/choose2/config.d.ts +37 -0
- package/dist/components/choose2/config.js +20 -0
- package/dist/components/choose2/config.js.map +1 -0
- package/dist/components/choose2/index.d.ts +3 -0
- package/dist/components/choose2/style/index.css +1 -0
- package/dist/components/chooseItem/ChooseItem.d.ts +46 -0
- package/dist/components/chooseItem/ChooseItem.js +72 -0
- package/dist/components/chooseItem/ChooseItem.js.map +1 -0
- package/dist/components/chooseItem/config.d.ts +12 -0
- package/dist/components/chooseItem/config.js +9 -0
- package/dist/components/chooseItem/config.js.map +1 -0
- package/dist/components/chooseItem/index.d.ts +3 -0
- package/dist/components/chooseItem/style/index.css +1 -0
- package/dist/components/circleProgress/CircleProgress.d.ts +83 -0
- package/dist/components/circleProgress/CircleProgress.js +108 -0
- package/dist/components/circleProgress/CircleProgress.js.map +1 -0
- package/dist/components/circleProgress/index.d.ts +1 -0
- package/dist/components/circleProgress/style/index.css +1 -0
- package/dist/components/close/Close.d.ts +114 -0
- package/dist/components/close/Close.js +82 -0
- package/dist/components/close/Close.js.map +1 -0
- package/dist/components/close/index.d.ts +1 -0
- package/dist/components/close/style/index.css +1 -0
- package/dist/components/colorPicker/ColorPicker.d.ts +138 -0
- package/dist/components/colorPicker/ColorPicker.js +404 -0
- package/dist/components/colorPicker/ColorPicker.js.map +1 -0
- package/dist/components/colorPicker/config.d.ts +24 -0
- package/dist/components/colorPicker/config.js +14 -0
- package/dist/components/colorPicker/config.js.map +1 -0
- package/dist/components/colorPicker/index.d.ts +4 -0
- package/dist/components/colorPicker/style/index.css +1 -0
- package/dist/components/confirm/index.d.ts +73 -0
- package/dist/components/confirm/index.js +177 -0
- package/dist/components/confirm/index.js.map +1 -0
- package/dist/components/confirm/src/style/index.css +1 -0
- package/dist/components/copy/Copy.d.ts +28 -0
- package/dist/components/copy/Copy.js +110 -0
- package/dist/components/copy/Copy.js.map +1 -0
- package/dist/components/copy/config.d.ts +25 -0
- package/dist/components/copy/config.js +13 -0
- package/dist/components/copy/config.js.map +1 -0
- package/dist/components/copy/index.d.ts +5 -0
- package/dist/components/copy/spawnCopyToast.d.ts +13 -0
- package/dist/components/copy/spawnCopyToast.js +150 -0
- package/dist/components/copy/spawnCopyToast.js.map +1 -0
- package/dist/components/copy/style/index.css +1 -0
- package/dist/components/cornerEars/CornerEars.d.ts +24 -0
- package/dist/components/cornerEars/CornerEars.js +108 -0
- package/dist/components/cornerEars/CornerEars.js.map +1 -0
- package/dist/components/cornerEars/cornerGeometry.d.ts +8 -0
- package/dist/components/cornerEars/cornerGeometry.js +63 -0
- package/dist/components/cornerEars/cornerGeometry.js.map +1 -0
- package/dist/components/cornerEars/index.d.ts +2 -0
- package/dist/components/cornerEars/style/index.css +1 -0
- package/dist/components/date/DatePanel.js +398 -0
- package/dist/components/date/DatePanel.js.map +1 -0
- package/dist/components/date/DatePicker.d.ts +226 -0
- package/dist/components/date/DatePicker.js +349 -0
- package/dist/components/date/DatePicker.js.map +1 -0
- package/dist/components/date/Days.d.ts +44 -0
- package/dist/components/date/Days.js +93 -0
- package/dist/components/date/Days.js.map +1 -0
- package/dist/components/date/Months.d.ts +32 -0
- package/dist/components/date/Months.js +87 -0
- package/dist/components/date/Months.js.map +1 -0
- package/dist/components/date/QuickDate.d.ts +24 -0
- package/dist/components/date/QuickDate.js +48 -0
- package/dist/components/date/QuickDate.js.map +1 -0
- package/dist/components/date/Years.d.ts +38 -0
- package/dist/components/date/Years.js +85 -0
- package/dist/components/date/Years.js.map +1 -0
- package/dist/components/date/_use/quickDate.d.ts +4 -0
- package/dist/components/date/_use/quickDate.js +30 -0
- package/dist/components/date/_use/quickDate.js.map +1 -0
- package/dist/components/date/_use/useDateModules.d.ts +37 -0
- package/dist/components/date/_use/useDateModules.js +100 -0
- package/dist/components/date/_use/useDateModules.js.map +1 -0
- package/dist/components/date/config.d.ts +32 -0
- package/dist/components/date/config.js +18 -0
- package/dist/components/date/config.js.map +1 -0
- package/dist/components/date/index.d.ts +3 -0
- package/dist/components/date/style/index.css +1 -0
- package/dist/components/date/types.d.ts +32 -0
- package/dist/components/drawer/Drawer.d.ts +332 -0
- package/dist/components/drawer/Drawer.js +329 -0
- package/dist/components/drawer/Drawer.js.map +1 -0
- package/dist/components/drawer/config.d.ts +28 -0
- package/dist/components/drawer/config.js +16 -0
- package/dist/components/drawer/config.js.map +1 -0
- package/dist/components/drawer/index.d.ts +3 -0
- package/dist/components/drawer/src/style/drawer.css +1 -0
- package/dist/components/ellipsis/Ellipsis.d.ts +74 -0
- package/dist/components/ellipsis/Ellipsis.js +103 -0
- package/dist/components/ellipsis/Ellipsis.js.map +1 -0
- package/dist/components/ellipsis/index.d.ts +1 -0
- package/dist/components/ellipsis/style/index.css +1 -0
- package/dist/components/empty/Empty.d.ts +92 -0
- package/dist/components/empty/Empty.js +85 -0
- package/dist/components/empty/Empty.js.map +1 -0
- package/dist/components/empty/config.d.ts +23 -0
- package/dist/components/empty/config.js +14 -0
- package/dist/components/empty/config.js.map +1 -0
- package/dist/components/empty/index.d.ts +3 -0
- package/dist/components/empty/style/index.css +1 -0
- package/dist/components/empty/type.d.ts +9 -0
- package/dist/components/equalizer/Equalizer.d.ts +62 -0
- package/dist/components/equalizer/Equalizer.js +56 -0
- package/dist/components/equalizer/Equalizer.js.map +1 -0
- package/dist/components/equalizer/index.d.ts +1 -0
- package/dist/components/equalizer/style/index.css +1 -0
- package/dist/components/fallback/Fallback.d.ts +44 -0
- package/dist/components/fallback/Fallback.js +55 -0
- package/dist/components/fallback/Fallback.js.map +1 -0
- package/dist/components/fallback/index.d.ts +1 -0
- package/dist/components/fallback/style/index.css +1 -0
- package/dist/components/form/Form.d.ts +169 -0
- package/dist/components/form/Form.js +235 -0
- package/dist/components/form/Form.js.map +1 -0
- package/dist/components/form/_use/formRules.d.ts +18 -0
- package/dist/components/form/_use/formRules.js +80 -0
- package/dist/components/form/_use/formRules.js.map +1 -0
- package/dist/components/form/config.d.ts +35 -0
- package/dist/components/form/config.js +20 -0
- package/dist/components/form/config.js.map +1 -0
- package/dist/components/form/context.d.ts +34 -0
- package/dist/components/form/context.js +8 -0
- package/dist/components/form/context.js.map +1 -0
- package/dist/components/form/index.d.ts +3 -0
- package/dist/components/form/style/index.css +1 -0
- package/dist/components/formItem/FormItem.d.ts +144 -0
- package/dist/components/formItem/FormItem.js +218 -0
- package/dist/components/formItem/FormItem.js.map +1 -0
- package/dist/components/formItem/config.d.ts +21 -0
- package/dist/components/formItem/config.js +12 -0
- package/dist/components/formItem/config.js.map +1 -0
- package/dist/components/formItem/context.d.ts +22 -0
- package/dist/components/formItem/context.js +8 -0
- package/dist/components/formItem/context.js.map +1 -0
- package/dist/components/formItem/index.d.ts +3 -0
- package/dist/components/formItem/style/index.css +1 -0
- package/dist/components/icon/Icon.d.ts +117 -0
- package/dist/components/icon/Icon.js +116 -0
- package/dist/components/icon/Icon.js.map +1 -0
- package/dist/components/icon/config.d.ts +28 -0
- package/dist/components/icon/config.js +16 -0
- package/dist/components/icon/config.js.map +1 -0
- package/dist/components/icon/index.d.ts +4 -0
- package/dist/components/icon/style/index.css +1 -0
- package/dist/components/icon/type.d.ts +16 -0
- package/dist/components/image/Image.d.ts +21 -0
- package/dist/components/image/Image.js +68 -0
- package/dist/components/image/Image.js.map +1 -0
- package/dist/components/image/config.d.ts +21 -0
- package/dist/components/image/config.js +11 -0
- package/dist/components/image/config.js.map +1 -0
- package/dist/components/image/index.d.ts +4 -0
- package/dist/components/image/style/index.css +1 -0
- package/dist/components/index.d.ts +79 -0
- package/dist/components/index.js +124 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/layer/Layer.d.ts +410 -0
- package/dist/components/layer/Layer.js +557 -0
- package/dist/components/layer/Layer.js.map +1 -0
- package/dist/components/layer/index.d.ts +2 -0
- package/dist/components/layer/injectionKey.d.ts +5 -0
- package/dist/components/layer/injectionKey.js +6 -0
- package/dist/components/layer/injectionKey.js.map +1 -0
- package/dist/components/layer/style/index.css +1 -0
- package/dist/components/lcdFont/LcdFont.d.ts +126 -0
- package/dist/components/lcdFont/LcdFont.js +232 -0
- package/dist/components/lcdFont/LcdFont.js.map +1 -0
- package/dist/components/lcdFont/config.d.ts +43 -0
- package/dist/components/lcdFont/config.js +41 -0
- package/dist/components/lcdFont/config.js.map +1 -0
- package/dist/components/lcdFont/format.d.ts +8 -0
- package/dist/components/lcdFont/format.js +39 -0
- package/dist/components/lcdFont/format.js.map +1 -0
- package/dist/components/lcdFont/index.d.ts +5 -0
- package/dist/components/lcdFont/segments.d.ts +32 -0
- package/dist/components/lcdFont/segments.js +326 -0
- package/dist/components/lcdFont/segments.js.map +1 -0
- package/dist/components/lcdFont/style/index.css +1 -0
- package/dist/components/lcdFont/type.d.ts +26 -0
- package/dist/components/list/List.d.ts +480 -0
- package/dist/components/list/List.js +289 -0
- package/dist/components/list/List.js.map +1 -0
- package/dist/components/list/config.d.ts +3 -0
- package/dist/components/list/index.d.ts +3 -0
- package/dist/components/list/style/index.css +1 -0
- package/dist/components/loading/Loading.d.ts +97 -0
- package/dist/components/loading/Loading.js +124 -0
- package/dist/components/loading/Loading.js.map +1 -0
- package/dist/components/loading/config.d.ts +22 -0
- package/dist/components/loading/config.js +13 -0
- package/dist/components/loading/config.js.map +1 -0
- package/dist/components/loading/index.d.ts +3 -0
- package/dist/components/loading/style/index.css +1 -0
- package/dist/components/loading/type.d.ts +13 -0
- package/dist/components/mask/Mask.d.ts +79 -0
- package/dist/components/mask/Mask.js +82 -0
- package/dist/components/mask/Mask.js.map +1 -0
- package/dist/components/mask/config.d.ts +21 -0
- package/dist/components/mask/config.js +14 -0
- package/dist/components/mask/config.js.map +1 -0
- package/dist/components/mask/index.d.ts +3 -0
- package/dist/components/mask/style/mask.css +1 -0
- package/dist/components/match/Match copy.d.ts +1600 -0
- package/dist/components/match/Match.d.ts +1621 -0
- package/dist/components/match/Match.js +343 -0
- package/dist/components/match/Match.js.map +1 -0
- package/dist/components/match/config.d.ts +29 -0
- package/dist/components/match/config.js +17 -0
- package/dist/components/match/config.js.map +1 -0
- package/dist/components/match/index.d.ts +3 -0
- package/dist/components/match/style/index.css +1 -0
- package/dist/components/modal/Modal.d.ts +460 -0
- package/dist/components/modal/Modal.js +297 -0
- package/dist/components/modal/Modal.js.map +1 -0
- package/dist/components/modal/config.d.ts +33 -0
- package/dist/components/modal/config.js +19 -0
- package/dist/components/modal/config.js.map +1 -0
- package/dist/components/modal/index.d.ts +3 -0
- package/dist/components/modal/style/index.css +1 -0
- package/dist/components/notice/Notice.d.ts +137 -0
- package/dist/components/notice/Notice.js +192 -0
- package/dist/components/notice/Notice.js.map +1 -0
- package/dist/components/notice/index.d.ts +51 -0
- package/dist/components/notice/index.js +243 -0
- package/dist/components/notice/index.js.map +1 -0
- package/dist/components/notice/src/_util/index.d.ts +11 -0
- package/dist/components/notice/src/_util/index.js +50 -0
- package/dist/components/notice/src/_util/index.js.map +1 -0
- package/dist/components/notice/src/style/index.css +1 -0
- package/dist/components/notice/types.d.ts +98 -0
- package/dist/components/number/Number copy.d.ts +966 -0
- package/dist/components/number/Number.d.ts +1034 -0
- package/dist/components/number/Number.js +241 -0
- package/dist/components/number/Number.js.map +1 -0
- package/dist/components/number/config.d.ts +26 -0
- package/dist/components/number/config.js +15 -0
- package/dist/components/number/config.js.map +1 -0
- package/dist/components/number/index.d.ts +3 -0
- package/dist/components/number/style/index.css +1 -0
- package/dist/components/pagination/index.d.ts +3 -0
- package/dist/components/pagination/src/Pagination.d.ts +2830 -0
- package/dist/components/pagination/src/Pagination.js +288 -0
- package/dist/components/pagination/src/Pagination.js.map +1 -0
- package/dist/components/pagination/src/config.d.ts +25 -0
- package/dist/components/pagination/src/config.js +20 -0
- package/dist/components/pagination/src/config.js.map +1 -0
- package/dist/components/pagination/src/style/index.css +1 -0
- package/dist/components/picture/Picture.d.ts +18 -0
- package/dist/components/picture/Picture.js +254 -0
- package/dist/components/picture/Picture.js.map +1 -0
- package/dist/components/picture/PictureToolbar.d.ts +29 -0
- package/dist/components/picture/PictureToolbar.js +97 -0
- package/dist/components/picture/PictureToolbar.js.map +1 -0
- package/dist/components/picture/PictureViewport.d.ts +47 -0
- package/dist/components/picture/PictureViewport.js +203 -0
- package/dist/components/picture/PictureViewport.js.map +1 -0
- package/dist/components/picture/config.d.ts +16 -0
- package/dist/components/picture/config.js +16 -0
- package/dist/components/picture/config.js.map +1 -0
- package/dist/components/picture/index.d.ts +5 -0
- package/dist/components/picture/pictureFlip.d.ts +16 -0
- package/dist/components/picture/pictureFlip.js +103 -0
- package/dist/components/picture/pictureFlip.js.map +1 -0
- package/dist/components/picture/style/index.css +1 -0
- package/dist/components/progress/Progress.d.ts +94 -0
- package/dist/components/progress/Progress.js +112 -0
- package/dist/components/progress/Progress.js.map +1 -0
- package/dist/components/progress/index.d.ts +1 -0
- package/dist/components/progress/style/index.css +1 -0
- package/dist/components/radio/Radio.d.ts +112 -0
- package/dist/components/radio/Radio.js +130 -0
- package/dist/components/radio/Radio.js.map +1 -0
- package/dist/components/radio/config.d.ts +29 -0
- package/dist/components/radio/config.js +18 -0
- package/dist/components/radio/config.js.map +1 -0
- package/dist/components/radio/index.d.ts +3 -0
- package/dist/components/radio/style/index.css +1 -0
- package/dist/components/scrollbar/Scrollbar.d.ts +93 -0
- package/dist/components/scrollbar/Scrollbar.js +515 -0
- package/dist/components/scrollbar/Scrollbar.js.map +1 -0
- package/dist/components/scrollbar/index.d.ts +1 -0
- package/dist/components/scrollbar/style/index.css +1 -0
- package/dist/components/sheet/Sheet.d.ts +1448 -0
- package/dist/components/sheet/Sheet.js +592 -0
- package/dist/components/sheet/Sheet.js.map +1 -0
- package/dist/components/sheet/_cell.d.ts +181 -0
- package/dist/components/sheet/_cell.js +132 -0
- package/dist/components/sheet/_cell.js.map +1 -0
- package/dist/components/sheet/_props.d.ts +170 -0
- package/dist/components/sheet/_props.js +183 -0
- package/dist/components/sheet/_props.js.map +1 -0
- package/dist/components/sheet/_row.d.ts +2 -0
- package/dist/components/sheet/_row.js +14 -0
- package/dist/components/sheet/_row.js.map +1 -0
- package/dist/components/sheet/_tbody.d.ts +348 -0
- package/dist/components/sheet/_tbody.js +255 -0
- package/dist/components/sheet/_tbody.js.map +1 -0
- package/dist/components/sheet/_tfoot.d.ts +195 -0
- package/dist/components/sheet/_tfoot.js +78 -0
- package/dist/components/sheet/_tfoot.js.map +1 -0
- package/dist/components/sheet/_thead.d.ts +529 -0
- package/dist/components/sheet/_thead.js +148 -0
- package/dist/components/sheet/_thead.js.map +1 -0
- package/dist/components/sheet/_use.d.ts +38 -0
- package/dist/components/sheet/_use.js +493 -0
- package/dist/components/sheet/_use.js.map +1 -0
- package/dist/components/sheet/_util.d.ts +34 -0
- package/dist/components/sheet/_util.js +111 -0
- package/dist/components/sheet/_util.js.map +1 -0
- package/dist/components/sheet/index.d.ts +1 -0
- package/dist/components/sheet/style/index.css +1 -0
- package/dist/components/slideDown/SlideDown.d.ts +62 -0
- package/dist/components/slideDown/SlideDown.js +128 -0
- package/dist/components/slideDown/SlideDown.js.map +1 -0
- package/dist/components/slideDown/index.d.ts +1 -0
- package/dist/components/slider/Slider.d.ts +1726 -0
- package/dist/components/slider/Slider.js +471 -0
- package/dist/components/slider/Slider.js.map +1 -0
- package/dist/components/slider/index.d.ts +1 -0
- package/dist/components/slider/style/index.css +1 -0
- package/dist/components/svgIcon/SvgIcon.d.ts +37 -0
- package/dist/components/svgIcon/SvgIcon.js +78 -0
- package/dist/components/svgIcon/SvgIcon.js.map +1 -0
- package/dist/components/svgIcon/index.d.ts +3 -0
- package/dist/components/svgIcon/style/index.css +1 -0
- package/dist/components/switch/Switch.d.ts +105 -0
- package/dist/components/switch/Switch.js +158 -0
- package/dist/components/switch/Switch.js.map +1 -0
- package/dist/components/switch/config.d.ts +16 -0
- package/dist/components/switch/config.js +11 -0
- package/dist/components/switch/config.js.map +1 -0
- package/dist/components/switch/index.d.ts +1 -0
- package/dist/components/switch/style/index.css +1 -0
- package/dist/components/tab/Tab.d.ts +113 -0
- package/dist/components/tab/Tab.js +485 -0
- package/dist/components/tab/Tab.js.map +1 -0
- package/dist/components/tab/index.d.ts +2 -0
- package/dist/components/tab/style/index.css +1 -0
- package/dist/components/textarea/Textarea.d.ts +37 -0
- package/dist/components/textarea/Textarea.js +193 -0
- package/dist/components/textarea/Textarea.js.map +1 -0
- package/dist/components/textarea/config.d.ts +30 -0
- package/dist/components/textarea/config.js +16 -0
- package/dist/components/textarea/config.js.map +1 -0
- package/dist/components/textarea/index.d.ts +4 -0
- package/dist/components/textarea/style/index.css +1 -0
- package/dist/components/time/Dial.js +7 -0
- package/dist/components/time/Dial.js.map +1 -0
- package/dist/components/time/Dial.vue_vue_type_script_setup_true_lang.js +178 -0
- package/dist/components/time/Dial.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/time/TimePicker.d.ts +1301 -0
- package/dist/components/time/TimePicker.js +162 -0
- package/dist/components/time/TimePicker.js.map +1 -0
- package/dist/components/time/_use/useTimeModules.d.ts +1 -0
- package/dist/components/time/index.d.ts +1 -0
- package/dist/components/time/style/dial.css +1 -0
- package/dist/components/time/style/index.css +1 -0
- package/dist/components/toggle/Toggle.d.ts +140 -0
- package/dist/components/toggle/Toggle.js +209 -0
- package/dist/components/toggle/Toggle.js.map +1 -0
- package/dist/components/toggle/index.d.ts +1 -0
- package/dist/components/toggle/style/index.css +1 -0
- package/dist/components/toggle/style/scale.css +1 -0
- package/dist/components/toggle/style/translate.css +1 -0
- package/dist/components/tooltip/Tooltip.d.ts +536 -0
- package/dist/components/tooltip/Tooltip.js +51 -0
- package/dist/components/tooltip/Tooltip.js.map +1 -0
- package/dist/components/tooltip/index.d.ts +1 -0
- package/dist/components/tooltip/style/index.css +1 -0
- package/dist/components/tree/Tree.d.ts +187 -0
- package/dist/components/tree/Tree.js +229 -0
- package/dist/components/tree/Tree.js.map +1 -0
- package/dist/components/tree/TreeItem.d.ts +86 -0
- package/dist/components/tree/TreeItem.js +152 -0
- package/dist/components/tree/TreeItem.js.map +1 -0
- package/dist/components/tree/TreeList.d.ts +86 -0
- package/dist/components/tree/TreeList.js +52 -0
- package/dist/components/tree/TreeList.js.map +1 -0
- package/dist/components/tree/_use/treeState.d.ts +45 -0
- package/dist/components/tree/_use/treeState.js +417 -0
- package/dist/components/tree/_use/treeState.js.map +1 -0
- package/dist/components/tree/config.d.ts +27 -0
- package/dist/components/tree/config.js +16 -0
- package/dist/components/tree/config.js.map +1 -0
- package/dist/components/tree/index.d.ts +4 -0
- package/dist/components/tree/style/index.css +1 -0
- package/dist/components/tree-choose/TreeChoose.d.ts +833 -0
- package/dist/components/tree-choose/TreeChoose.js +320 -0
- package/dist/components/tree-choose/TreeChoose.js.map +1 -0
- package/dist/components/tree-choose/config.d.ts +41 -0
- package/dist/components/tree-choose/config.js +19 -0
- package/dist/components/tree-choose/config.js.map +1 -0
- package/dist/components/tree-choose/index.d.ts +4 -0
- package/dist/components/tree-choose/style/index.css +1 -0
- package/dist/components/trigger/Trigger.d.ts +921 -0
- package/dist/components/trigger/Trigger.js +105 -0
- package/dist/components/trigger/Trigger.js.map +1 -0
- package/dist/components/trigger/index.d.ts +1 -0
- package/dist/components/trigger/style/index.css +2 -0
- package/dist/components/upload/Upload.d.ts +249 -0
- package/dist/components/upload/Upload.js +342 -0
- package/dist/components/upload/Upload.js.map +1 -0
- package/dist/components/upload/config.d.ts +39 -0
- package/dist/components/upload/config.js +21 -0
- package/dist/components/upload/config.js.map +1 -0
- package/dist/components/upload/index.d.ts +4 -0
- package/dist/components/upload/style/index.css +1 -0
- package/dist/components/upload/types.d.ts +47 -0
- package/dist/components/virtual/Virtual.d.ts +57 -0
- package/dist/components/virtual/Virtual.js +62 -0
- package/dist/components/virtual/Virtual.js.map +1 -0
- package/dist/components/virtual/Virtual/345/216/237/347/211/210.d.ts +44 -0
- package/dist/components/virtual/index.d.ts +4 -0
- package/dist/components/virtual/style/index.css +1 -0
- package/dist/components/virtual/useVirtualList.d.ts +50 -0
- package/dist/components/virtual/useVirtualList.js +376 -0
- package/dist/components/virtual/useVirtualList.js.map +1 -0
- package/dist/components/write/Write.d.ts +532 -0
- package/dist/components/write/Write.js +228 -0
- package/dist/components/write/Write.js.map +1 -0
- package/dist/components/write/index.d.ts +1 -0
- package/dist/components/write/style/index.css +1 -0
- package/dist/config/dictionary.d.ts +21 -0
- package/dist/config/dictionary.js +28 -0
- package/dist/config/dictionary.js.map +1 -0
- package/dist/config/i18n.d.ts +22 -0
- package/dist/config/i18n.js +53 -0
- package/dist/config/i18n.js.map +1 -0
- package/dist/config/plugin.d.ts +88 -0
- package/dist/config/plugin.js +13 -0
- package/dist/config/plugin.js.map +1 -0
- package/dist/config/types.d.ts +56 -0
- package/dist/directives/clickOutside.d.ts +10 -0
- package/dist/directives/clickOutside.js +69 -0
- package/dist/directives/clickOutside.js.map +1 -0
- package/dist/directives/index.d.ts +3 -0
- package/dist/directives/index.js +13 -0
- package/dist/directives/index.js.map +1 -0
- package/dist/directives/loading.d.ts +19 -0
- package/dist/directives/loading.js +64 -0
- package/dist/directives/loading.js.map +1 -0
- package/dist/index.d.ts +127 -0
- package/dist/index.js +91 -0
- package/dist/locales/de-DE/index.d.ts +144 -0
- package/dist/locales/de-DE/index.js +140 -0
- package/dist/locales/de-DE/index.js.map +1 -0
- package/dist/locales/en-US/index.d.ts +144 -0
- package/dist/locales/en-US/index.js +140 -0
- package/dist/locales/en-US/index.js.map +1 -0
- package/dist/locales/index.d.ts +3 -0
- package/dist/locales/zh-CN/index.d.ts +144 -0
- package/dist/locales/zh-CN/index.js +140 -0
- package/dist/locales/zh-CN/index.js.map +1 -0
- package/dist/plugin.d.ts +6 -0
- package/dist/plugin.js +38 -0
- package/dist/plugin.js.map +1 -0
- package/dist/styles/index.css +49 -0
- package/dist/theme/_transition.css +169 -0
- package/dist/theme/index.css +5 -0
- package/dist/theme/tokens/_base.css +7 -0
- package/dist/theme/tokens/_common.css +37 -0
- package/dist/theme/tokens/_scrollbar.css +53 -0
- package/dist/theme/tokens/_size.css +18 -0
- package/dist/theme/tokens/_text.css +16 -0
- package/dist/theme/tokens/_var.css +1087 -0
- package/dist/theme/tokens/components/audioPlayer.css +542 -0
- package/dist/theme/tokens/components/btn.css +253 -0
- package/dist/theme/tokens/components/btnGroup.css +68 -0
- package/dist/theme/tokens/components/cascade.css +77 -0
- package/dist/theme/tokens/components/checkbox.css +100 -0
- package/dist/theme/tokens/components/choose.css +175 -0
- package/dist/theme/tokens/components/choose2.css +242 -0
- package/dist/theme/tokens/components/chooseItem.css +54 -0
- package/dist/theme/tokens/components/circleProgress.css +61 -0
- package/dist/theme/tokens/components/close.css +12 -0
- package/dist/theme/tokens/components/colorPicker.css +404 -0
- package/dist/theme/tokens/components/confirm.css +128 -0
- package/dist/theme/tokens/components/copy.css +80 -0
- package/dist/theme/tokens/components/cornerEars.css +102 -0
- package/dist/theme/tokens/components/date/days.css +79 -0
- package/dist/theme/tokens/components/date/index.css +249 -0
- package/dist/theme/tokens/components/date/months.css +68 -0
- package/dist/theme/tokens/components/drawer.css +189 -0
- package/dist/theme/tokens/components/ellipsis.css +46 -0
- package/dist/theme/tokens/components/empty.css +24 -0
- package/dist/theme/tokens/components/equalizer.css +51 -0
- package/dist/theme/tokens/components/fallback.css +4 -0
- package/dist/theme/tokens/components/form.css +50 -0
- package/dist/theme/tokens/components/formItem.css +194 -0
- package/dist/theme/tokens/components/icon.css +41 -0
- package/dist/theme/tokens/components/image.css +70 -0
- package/dist/theme/tokens/components/layer.css +190 -0
- package/dist/theme/tokens/components/lcdFont.css +121 -0
- package/dist/theme/tokens/components/list.css +97 -0
- package/dist/theme/tokens/components/loading.css +64 -0
- package/dist/theme/tokens/components/mask.css +26 -0
- package/dist/theme/tokens/components/match.css +119 -0
- package/dist/theme/tokens/components/modal.css +136 -0
- package/dist/theme/tokens/components/notice.css +264 -0
- package/dist/theme/tokens/components/number.css +150 -0
- package/dist/theme/tokens/components/pagination.css +215 -0
- package/dist/theme/tokens/components/picture.css +299 -0
- package/dist/theme/tokens/components/progress.css +101 -0
- package/dist/theme/tokens/components/radio.css +183 -0
- package/dist/theme/tokens/components/scrollbar.css +160 -0
- package/dist/theme/tokens/components/sheet.css +518 -0
- package/dist/theme/tokens/components/slider.css +171 -0
- package/dist/theme/tokens/components/svgIcon.css +6 -0
- package/dist/theme/tokens/components/switch.css +67 -0
- package/dist/theme/tokens/components/tab.css +215 -0
- package/dist/theme/tokens/components/textarea.css +109 -0
- package/dist/theme/tokens/components/time/dial.css +123 -0
- package/dist/theme/tokens/components/time/index.css +29 -0
- package/dist/theme/tokens/components/toggle/index.css +14 -0
- package/dist/theme/tokens/components/toggle/scale.css +34 -0
- package/dist/theme/tokens/components/toggle/translate.css +41 -0
- package/dist/theme/tokens/components/tooltip.css +77 -0
- package/dist/theme/tokens/components/tree-choose.css +154 -0
- package/dist/theme/tokens/components/tree.css +172 -0
- package/dist/theme/tokens/components/trigger.css +90 -0
- package/dist/theme/tokens/components/upload.css +302 -0
- package/dist/theme/tokens/components/virtual.css +6 -0
- package/dist/theme/tokens/components/write.css +155 -0
- package/dist/theme/tokens/iconfont/iconfont.css +103 -0
- package/dist/theme/tokens/iconfont/iconfont.ttf +0 -0
- package/dist/theme/tokens/iconfont/iconfont.woff +0 -0
- package/dist/theme/tokens/iconfont/iconfont.woff2 +0 -0
- package/dist/theme/tokens/index.css +19 -0
- package/dist/use/index.d.ts +34 -0
- package/dist/use/toggle/types.d.ts +27 -0
- package/dist/use/toggle/useToggle.d.ts +22 -0
- package/dist/use/toggle/useToggleArray.d.ts +14 -0
- package/dist/use/toggle/useToggleArray.js +36 -0
- package/dist/use/toggle/useToggleArray.js.map +1 -0
- package/dist/use/toggle/useToggleCycle.d.ts +11 -0
- package/dist/use/toggle/useToggleCycle.js +88 -0
- package/dist/use/toggle/useToggleCycle.js.map +1 -0
- package/dist/use/toggle/useToggleMap.d.ts +10 -0
- package/dist/use/toggle/useToggleObject.d.ts +13 -0
- package/dist/use/useAudioPlayer.d.ts +160 -0
- package/dist/use/useAudioPlayer.js +799 -0
- package/dist/use/useAudioPlayer.js.map +1 -0
- package/dist/use/useBoundingClientRect.d.ts +14 -0
- package/dist/use/useBoundingClientRect.js +54 -0
- package/dist/use/useBoundingClientRect.js.map +1 -0
- package/dist/use/useChildComponentsCollector.js +30 -0
- package/dist/use/useChildComponentsCollector.js.map +1 -0
- package/dist/use/useComponentClass.d.ts +1 -0
- package/dist/use/useComponentClass.js +6 -0
- package/dist/use/useComponentClass.js.map +1 -0
- package/dist/use/useComponentConfig.d.ts +10 -0
- package/dist/use/useComponentConfig.js +31 -0
- package/dist/use/useComponentConfig.js.map +1 -0
- package/dist/use/useCount.d.ts +13 -0
- package/dist/use/useCount.js +36 -0
- package/dist/use/useCount.js.map +1 -0
- package/dist/use/useDate.d.ts +53 -0
- package/dist/use/useDate.js +280 -0
- package/dist/use/useDate.js.map +1 -0
- package/dist/use/useDelay.d.ts +5 -0
- package/dist/use/useDelay.js +38 -0
- package/dist/use/useDelay.js.map +1 -0
- package/dist/use/useDrag.d.ts +17 -0
- package/dist/use/useElement.d.ts +15 -0
- package/dist/use/useElement.js +41 -0
- package/dist/use/useElement.js.map +1 -0
- package/dist/use/useEscStack.d.ts +14 -0
- package/dist/use/useEscStack.js +62 -0
- package/dist/use/useEscStack.js.map +1 -0
- package/dist/use/useEvent.d.ts +9 -0
- package/dist/use/useEvent.js +43 -0
- package/dist/use/useEvent.js.map +1 -0
- package/dist/use/useFormItem.d.ts +9 -0
- package/dist/use/useFormItem.js +20 -0
- package/dist/use/useFormItem.js.map +1 -0
- package/dist/use/useGlobalZIndex.d.ts +6 -0
- package/dist/use/useGlobalZIndex.js +28 -0
- package/dist/use/useGlobalZIndex.js.map +1 -0
- package/dist/use/useMouse.d.ts +15 -0
- package/dist/use/useMouse.js +36 -0
- package/dist/use/useMouse.js.map +1 -0
- package/dist/use/useMousePositionInElement.d.ts +6 -0
- package/dist/use/useMousePositionInElement.js +27 -0
- package/dist/use/useMousePositionInElement.js.map +1 -0
- package/dist/use/useParentNode.d.ts +3 -0
- package/dist/use/useParentNode.js +25 -0
- package/dist/use/useParentNode.js.map +1 -0
- package/dist/use/usePercentDrag.d.ts +20 -0
- package/dist/use/usePercentDrag.js +59 -0
- package/dist/use/usePercentDrag.js.map +1 -0
- package/dist/use/usePictureViewport.d.ts +57 -0
- package/dist/use/usePictureViewport.js +229 -0
- package/dist/use/usePictureViewport.js.map +1 -0
- package/dist/use/useRequest.d.ts +7 -0
- package/dist/use/useRequest.js +31 -0
- package/dist/use/useRequest.js.map +1 -0
- package/dist/use/useScaleFromPoint.d.ts +57 -0
- package/dist/use/useScaleFromPoint.js +325 -0
- package/dist/use/useScaleFromPoint.js.map +1 -0
- package/dist/use/useScroll.d.ts +9 -0
- package/dist/use/useScroll.js +60 -0
- package/dist/use/useScroll.js.map +1 -0
- package/dist/use/useSearch.d.ts +11 -0
- package/dist/use/useSearch.js +65 -0
- package/dist/use/useSearch.js.map +1 -0
- package/dist/use/useSlot.d.ts +10 -0
- package/dist/use/useSlot.js +57 -0
- package/dist/use/useSlot.js.map +1 -0
- package/dist/use/useTabIndex.d.ts +1 -0
- package/dist/use/useTabIndex.js +18 -0
- package/dist/use/useTabIndex.js.map +1 -0
- package/dist/use/useUII18n.js +26 -0
- package/dist/use/useUII18n.js.map +1 -0
- package/dist/use/useUpload.d.ts +49 -0
- package/dist/use/useUpload.js +396 -0
- package/dist/use/useUpload.js.map +1 -0
- package/dist/use/useVisibleResize.d.ts +6 -0
- package/dist/use/useVisibleResize.js +77 -0
- package/dist/use/useVisibleResize.js.map +1 -0
- package/dist/util/calc.d.ts +40 -0
- package/dist/util/calc.js +239 -0
- package/dist/util/calc.js.map +1 -0
- package/dist/util/colors.d.ts +78 -0
- package/dist/util/colors.js +320 -0
- package/dist/util/colors.js.map +1 -0
- package/dist/util/cssVars.d.ts +62 -0
- package/dist/util/cssVars.js +170 -0
- package/dist/util/cssVars.js.map +1 -0
- package/dist/util/dom.d.ts +65 -0
- package/dist/util/dom.js +212 -0
- package/dist/util/dom.js.map +1 -0
- package/dist/util/index.d.ts +5 -0
- package/dist/util/tools.d.ts +54 -0
- package/dist/util/tools.js +90 -0
- package/dist/util/tools.js.map +1 -0
- package/dist/util/vnode.d.ts +2 -0
- package/package.json +88 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import Icon_default from "../icon/Icon.js";
|
|
2
|
+
import { getBoundingClientRect } from "../../util/dom.js";
|
|
3
|
+
import { mergeStyle, propColorToCssVars, propSizeToCssVars, toCssVarsStyle } from "../../util/cssVars.js";
|
|
4
|
+
import Close_default from "../close/Close.js";
|
|
5
|
+
import { Transition, computed, createVNode, defineComponent, getCurrentInstance, onMounted, onUnmounted, ref, watch } from "vue";
|
|
6
|
+
//#region components/notice/Notice.tsx
|
|
7
|
+
var TYPE_ICON_MAP = {
|
|
8
|
+
info: "w-icon-warning",
|
|
9
|
+
success: "w-icon-duihao",
|
|
10
|
+
warning: "w-icon-warning",
|
|
11
|
+
error: "w-icon-close-fill"
|
|
12
|
+
};
|
|
13
|
+
/** 退场前锁死当前高度,好让 height → 0 能过渡 */
|
|
14
|
+
function lockLeaveHeight(el) {
|
|
15
|
+
const h = getBoundingClientRect(el).height;
|
|
16
|
+
if (h > 0) {
|
|
17
|
+
el.style.setProperty("--__notice-item-height", `${h}px`);
|
|
18
|
+
el.style.height = `${h}px`;
|
|
19
|
+
el.offsetHeight;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
var Notice_default = /* @__PURE__ */ defineComponent({
|
|
23
|
+
inheritAttrs: false,
|
|
24
|
+
name: "Notice",
|
|
25
|
+
props: {
|
|
26
|
+
show: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: false
|
|
29
|
+
},
|
|
30
|
+
placement: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: "top-end"
|
|
33
|
+
},
|
|
34
|
+
duration: {
|
|
35
|
+
type: Number,
|
|
36
|
+
default: 4500
|
|
37
|
+
},
|
|
38
|
+
manual: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: false
|
|
41
|
+
},
|
|
42
|
+
showClose: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: true
|
|
45
|
+
},
|
|
46
|
+
type: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: "default"
|
|
49
|
+
},
|
|
50
|
+
title: { type: [
|
|
51
|
+
String,
|
|
52
|
+
Object,
|
|
53
|
+
Function
|
|
54
|
+
] },
|
|
55
|
+
icon: {
|
|
56
|
+
type: [
|
|
57
|
+
String,
|
|
58
|
+
Boolean,
|
|
59
|
+
Object,
|
|
60
|
+
Function
|
|
61
|
+
],
|
|
62
|
+
default: void 0
|
|
63
|
+
},
|
|
64
|
+
itemClass: { type: [
|
|
65
|
+
String,
|
|
66
|
+
Object,
|
|
67
|
+
Array
|
|
68
|
+
] },
|
|
69
|
+
itemStyle: { type: Object },
|
|
70
|
+
hoverKeep: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
default: true
|
|
73
|
+
},
|
|
74
|
+
color: {
|
|
75
|
+
type: String,
|
|
76
|
+
default: void 0
|
|
77
|
+
},
|
|
78
|
+
/** 实例尺度(px)→ `--w-prop-notice-size` */
|
|
79
|
+
size: {
|
|
80
|
+
type: Number,
|
|
81
|
+
default: void 0
|
|
82
|
+
},
|
|
83
|
+
/** 实例 CSS 变量 */
|
|
84
|
+
cssVars: {
|
|
85
|
+
type: Object,
|
|
86
|
+
default: void 0
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
emits: [
|
|
90
|
+
"update:show",
|
|
91
|
+
"after-enter",
|
|
92
|
+
"after-leave",
|
|
93
|
+
"close",
|
|
94
|
+
"get-uid",
|
|
95
|
+
"closing"
|
|
96
|
+
],
|
|
97
|
+
setup(props, { emit, slots, expose }) {
|
|
98
|
+
const ins = getCurrentInstance();
|
|
99
|
+
const visible = ref(props.show);
|
|
100
|
+
let timer = null;
|
|
101
|
+
const isManual = computed(() => props.manual || !props.duration || props.duration <= 0);
|
|
102
|
+
function clearTimer() {
|
|
103
|
+
if (timer != null) {
|
|
104
|
+
clearTimeout(timer);
|
|
105
|
+
timer = null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function startTimer() {
|
|
109
|
+
clearTimer();
|
|
110
|
+
if (isManual.value) return;
|
|
111
|
+
timer = setTimeout(() => {
|
|
112
|
+
visible.value = false;
|
|
113
|
+
}, props.duration);
|
|
114
|
+
}
|
|
115
|
+
function close() {
|
|
116
|
+
if (!visible.value) return;
|
|
117
|
+
emit("closing");
|
|
118
|
+
clearTimer();
|
|
119
|
+
visible.value = false;
|
|
120
|
+
}
|
|
121
|
+
emit("close", close);
|
|
122
|
+
emit("get-uid", ins?.uid);
|
|
123
|
+
watch(() => props.show, (s) => {
|
|
124
|
+
visible.value = s;
|
|
125
|
+
});
|
|
126
|
+
watch(visible, (v) => {
|
|
127
|
+
emit("update:show", v);
|
|
128
|
+
if (v) startTimer();
|
|
129
|
+
else clearTimer();
|
|
130
|
+
});
|
|
131
|
+
onMounted(() => {
|
|
132
|
+
visible.value = true;
|
|
133
|
+
});
|
|
134
|
+
onUnmounted(() => {
|
|
135
|
+
clearTimer();
|
|
136
|
+
});
|
|
137
|
+
expose({ close });
|
|
138
|
+
function renderIcon() {
|
|
139
|
+
const { icon, type } = props;
|
|
140
|
+
if (icon === false) return null;
|
|
141
|
+
if (typeof icon === "function") return createVNode("div", { "class": "w-notice-icon" }, [icon()]);
|
|
142
|
+
if (icon !== void 0 && icon !== true && typeof icon !== "string") return createVNode("div", { "class": "w-notice-icon" }, [icon]);
|
|
143
|
+
const name = typeof icon === "string" ? icon : type !== "default" ? TYPE_ICON_MAP[type] : "";
|
|
144
|
+
if (!name) return null;
|
|
145
|
+
return createVNode("div", { "class": "w-notice-icon" }, [createVNode(Icon_default, { "name": name }, null)]);
|
|
146
|
+
}
|
|
147
|
+
function onMouseEnter() {
|
|
148
|
+
if (props.hoverKeep && !isManual.value) clearTimer();
|
|
149
|
+
}
|
|
150
|
+
function onMouseLeave() {
|
|
151
|
+
if (props.hoverKeep && !isManual.value && visible.value) startTimer();
|
|
152
|
+
}
|
|
153
|
+
return () => {
|
|
154
|
+
const style = mergeStyle(toCssVarsStyle({
|
|
155
|
+
...propSizeToCssVars("notice", props.size),
|
|
156
|
+
...propColorToCssVars("notice", props.color),
|
|
157
|
+
...props.cssVars
|
|
158
|
+
}), props.itemStyle);
|
|
159
|
+
return createVNode(Transition, {
|
|
160
|
+
"name": "w-notice-transition",
|
|
161
|
+
"onBefore-leave": (el) => {
|
|
162
|
+
lockLeaveHeight(el);
|
|
163
|
+
},
|
|
164
|
+
"onAfter-enter": (el) => {
|
|
165
|
+
emit("after-enter", el);
|
|
166
|
+
},
|
|
167
|
+
"onAfter-leave": (el) => {
|
|
168
|
+
emit("after-leave", el, ins?.uid);
|
|
169
|
+
}
|
|
170
|
+
}, { default: () => [visible.value && createVNode("div", {
|
|
171
|
+
"class": [
|
|
172
|
+
"w-notice-item",
|
|
173
|
+
`w-notice-item--${props.placement}`,
|
|
174
|
+
`w-notice-item--${props.type}`,
|
|
175
|
+
props.itemClass
|
|
176
|
+
],
|
|
177
|
+
"style": style,
|
|
178
|
+
"role": "alert",
|
|
179
|
+
"onMouseenter": onMouseEnter,
|
|
180
|
+
"onMouseleave": onMouseLeave
|
|
181
|
+
}, [createVNode("div", { "class": "w-notice-inner" }, [renderIcon(), createVNode("div", { "class": "w-notice-body" }, [props.title != null && props.title !== false && createVNode("div", { "class": "w-notice-title" }, [props.title]), createVNode("div", { "class": "w-notice-content" }, [slots.default?.()])])]), props.showClose && createVNode(Close_default, {
|
|
182
|
+
"name": "w-icon-close-fill",
|
|
183
|
+
"class": "w-notice-close",
|
|
184
|
+
"onClick": close
|
|
185
|
+
}, null)])] });
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
//#endregion
|
|
190
|
+
export { Notice_default as default };
|
|
191
|
+
|
|
192
|
+
//# sourceMappingURL=Notice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Notice.js","names":["defineComponent","getCurrentInstance","onMounted","onUnmounted","ref","Transition","watch","computed","createVNode","_createVNode","Icon","getBoundingClientRect","mergeStyle","propColorToCssVars","propSizeToCssVars","toCssVarsStyle","Close","TYPE_ICON_MAP","info","success","warning","error","lockLeaveHeight","el","h","height","style","setProperty","offsetHeight","inheritAttrs","name","props","show","type","Boolean","default","placement","String","duration","Number","manual","showClose","title","Object","Function","icon","undefined","itemClass","Array","itemStyle","hoverKeep","color","size","cssVars","emits","setup","emit","slots","expose","ins","visible","timer","isManual","clearTimer","clearTimeout","startTimer","value","setTimeout","close","uid","s","v","renderIcon","onMouseEnter","onMouseLeave"],"sources":["../../../components/notice/Notice.tsx"],"sourcesContent":["import {\r\n defineComponent,\r\n getCurrentInstance,\r\n onMounted,\r\n onUnmounted,\r\n ref,\r\n Transition,\r\n watch,\r\n computed,\r\n} from 'vue'\r\nimport type { PropType, CSSProperties, VNodeChild } from 'vue'\r\nimport Icon from '../icon'\r\nimport { getBoundingClientRect, mergeStyle, propColorToCssVars, propSizeToCssVars, toCssVarsStyle, type CssVars } from '../../util'\r\nimport Close from '../close'\r\nimport type { NoticePlacementType, NoticeType } from './types'\r\n\r\nconst TYPE_ICON_MAP: Record<Exclude<NoticeType, 'default'>, string> = {\r\n info: 'w-icon-warning',\r\n success: 'w-icon-duihao',\r\n warning: 'w-icon-warning',\r\n error: 'w-icon-close-fill',\r\n}\r\n\r\n/** 退场前锁死当前高度,好让 height → 0 能过渡 */\r\nfunction lockLeaveHeight(el: HTMLElement) {\r\n const h = getBoundingClientRect(el).height\r\n if (h > 0) {\r\n el.style.setProperty('--__notice-item-height', `${h}px`)\r\n el.style.height = `${h}px`\r\n void el.offsetHeight\r\n }\r\n}\r\n\r\nexport default defineComponent({\r\n inheritAttrs: false,\r\n name: 'Notice',\r\n props: {\r\n show: { type: Boolean, default: false },\r\n placement: {\r\n type: String as PropType<NoticePlacementType>,\r\n default: 'top-end',\r\n },\r\n duration: { type: Number, default: 4500 },\r\n manual: { type: Boolean, default: false },\r\n showClose: { type: Boolean, default: true },\r\n type: {\r\n type: String as PropType<NoticeType>,\r\n default: 'default',\r\n },\r\n title: { type: [String, Object, Function] as PropType<VNodeChild> },\r\n icon: {\r\n type: [String, Boolean, Object, Function] as PropType<\r\n string | boolean | VNodeChild | (() => VNodeChild)\r\n >,\r\n default: undefined,\r\n },\r\n itemClass: { type: [String, Object, Array] as PropType<any> },\r\n itemStyle: {\r\n type: Object as PropType<CSSProperties | Record<string, string>>,\r\n },\r\n hoverKeep: { type: Boolean, default: true },\r\n color: { type: String, default: undefined },\r\n /** 实例尺度(px)→ `--w-prop-notice-size` */\r\n size: { type: Number, default: undefined },\r\n /** 实例 CSS 变量 */\r\n cssVars: { type: Object as PropType<CssVars>, default: undefined },\r\n },\r\n emits: ['update:show', 'after-enter', 'after-leave', 'close', 'get-uid', 'closing'],\r\n setup(props, { emit, slots, expose }) {\r\n const ins = getCurrentInstance()\r\n const visible = ref(props.show)\r\n let timer: ReturnType<typeof setTimeout> | null = null\r\n\r\n const isManual = computed(\r\n () => props.manual || !props.duration || props.duration <= 0,\r\n )\r\n\r\n function clearTimer() {\r\n if (timer != null) {\r\n clearTimeout(timer)\r\n timer = null\r\n }\r\n }\r\n\r\n function startTimer() {\r\n clearTimer()\r\n if (isManual.value) return\r\n timer = setTimeout(() => {\r\n visible.value = false\r\n }, props.duration)\r\n }\r\n\r\n function close() {\r\n if (!visible.value) return\r\n emit('closing')\r\n clearTimer()\r\n visible.value = false\r\n }\r\n\r\n emit('close', close)\r\n emit('get-uid', ins?.uid as number)\r\n\r\n watch(\r\n () => props.show,\r\n (s) => {\r\n visible.value = s\r\n },\r\n )\r\n\r\n watch(visible, (v) => {\r\n emit('update:show', v)\r\n if (v) {\r\n startTimer()\r\n } else {\r\n clearTimer()\r\n }\r\n })\r\n\r\n onMounted(() => {\r\n visible.value = true\r\n })\r\n\r\n onUnmounted(() => {\r\n clearTimer()\r\n })\r\n\r\n expose({ close })\r\n\r\n function renderIcon() {\r\n const { icon, type } = props\r\n if (icon === false) return null\r\n\r\n if (typeof icon === 'function') {\r\n return <div class=\"w-notice-icon\">{(icon as () => VNodeChild)()}</div>\r\n }\r\n\r\n if (icon !== undefined && icon !== true && typeof icon !== 'string') {\r\n return <div class=\"w-notice-icon\">{icon}</div>\r\n }\r\n\r\n const name =\r\n typeof icon === 'string'\r\n ? icon\r\n : type !== 'default'\r\n ? TYPE_ICON_MAP[type]\r\n : ''\r\n\r\n if (!name) return null\r\n\r\n return (\r\n <div class=\"w-notice-icon\">\r\n <Icon name={name} />\r\n </div>\r\n )\r\n }\r\n\r\n function onMouseEnter() {\r\n if (props.hoverKeep && !isManual.value) clearTimer()\r\n }\r\n\r\n function onMouseLeave() {\r\n if (props.hoverKeep && !isManual.value && visible.value) startTimer()\r\n }\r\n\r\n return () => {\r\n const style = mergeStyle(\r\n toCssVarsStyle({\r\n ...propSizeToCssVars('notice', props.size),\r\n ...propColorToCssVars('notice', props.color),\r\n ...props.cssVars,\r\n }),\r\n props.itemStyle as Record<string, string> | undefined,\r\n )\r\n\r\n return (\r\n <Transition\r\n name=\"w-notice-transition\"\r\n onBefore-leave={(el: Element) => {\r\n lockLeaveHeight(el as HTMLElement)\r\n }}\r\n onAfter-enter={(el: Element) => {\r\n emit('after-enter', el as HTMLElement)\r\n }}\r\n onAfter-leave={(el: Element) => {\r\n emit('after-leave', el as HTMLElement, ins?.uid)\r\n }}>\r\n {visible.value && (\r\n <div\r\n class={[\r\n 'w-notice-item',\r\n `w-notice-item--${props.placement}`,\r\n `w-notice-item--${props.type}`,\r\n props.itemClass,\r\n ]}\r\n style={style}\r\n role=\"alert\"\r\n onMouseenter={onMouseEnter}\r\n onMouseleave={onMouseLeave}>\r\n <div class=\"w-notice-inner\">\r\n {renderIcon()}\r\n <div class=\"w-notice-body\">\r\n {props.title != null && props.title !== false && (\r\n <div class=\"w-notice-title\">{props.title as any}</div>\r\n )}\r\n <div class=\"w-notice-content\">{slots.default?.()}</div>\r\n </div>\r\n </div>\r\n {props.showClose && (\r\n <Close\r\n name=\"w-icon-close-fill\"\r\n class=\"w-notice-close\"\r\n onClick={close}\r\n />\r\n )}\r\n </div>\r\n )}\r\n </Transition>\r\n )\r\n }\r\n },\r\n})\r\n\r\nexport type {\r\n NoticePlacementType,\r\n NoticeOptions,\r\n NoticeType,\r\n} from './types'\r\n"],"mappings":";;;;;;AAgBA,IAAMiB,gBAAgE;CACpEC,MAAM;CACNC,SAAS;CACTC,SAAS;CACTC,OAAO;AACT;;AAGA,SAASC,gBAAgBC,IAAiB;CACxC,MAAMC,IAAIb,sBAAsBY,EAAE,CAAC,CAACE;CACpC,IAAID,IAAI,GAAG;EACTD,GAAGG,MAAMC,YAAY,0BAA0B,GAAGH,EAAC,GAAI;EACvDD,GAAGG,MAAMD,SAAS,GAAGD,EAAC;EACtB,GAAQI;CACV;AACF;AAEA,IAAA,iBAAe5B,gCAAgB;CAC7B6B,cAAc;CACdC,MAAM;CACNC,OAAO;EACLC,MAAM;GAAEC,MAAMC;GAASC,SAAS;EAAM;EACtCC,WAAW;GACTH,MAAMI;GACNF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mB,UAAUkB,MAAMoB,KAAK;IAC3C,GAAGpB,MAAMsB;GACX,CAAC,GACDtB,MAAMkB,SACR;GAEA,OAAAxC,YAAAJ,YAAA;IAAA,QAAA;IAAA,mBAGqBkB,OAAgB;KAC/BD,gBAAgBC,EAAiB;IACnC;IAAC,kBACeA,OAAgB;KAC9BiC,KAAK,eAAejC,EAAiB;IACvC;IAAC,kBACeA,OAAgB;KAC9BiC,KAAK,eAAejC,IAAmBoC,KAAKU,GAAG;IACjD;GAAC,GAAA,EAAAlC,eAAA,CACAyB,QAAQM,SAAKzD,YAAA,OAAA;IAAA,SAEH;KACL;KACA,kBAAkBsB,MAAMK;KACxB,kBAAkBL,MAAME;KACxBF,MAAMgB;IAAS;IAChB,SACMrB;IAAK,QAAA;IAAA,gBAEE+C;IAAY,gBACZC;GAAY,GAAA,CAAAjE,YAAA,OAAA,EAAA,SAAA,iBAAA,GAAA,CAEvB+D,WAAW,GAAC/D,YAAA,OAAA,EAAA,SAAA,gBAAA,GAAA,CAEVsB,MAAMW,SAAS,QAAQX,MAAMW,UAAU,SAAKjC,YAAA,OAAA,EAAA,SAAA,iBAAA,GAAA,CACdsB,MAAMW,KAAK,CAAA,GACzCjC,YAAA,OAAA,EAAA,SAAA,mBAAA,GAAA,CAC8BgD,MAAMtB,UAAU,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,GAGnDJ,MAAMU,aAAShC,YAAAO,eAAA;IAAA,QAAA;IAAA,SAAA;IAAA,WAIHoD;GAAK,GAAA,IAAA,CAEjB,CAAA,CAEJ,EAAA,CAAA;EAGP;CACF;AACF,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { NoticeOptions, NoticeGlobalConfig, NoticeInstance, NoticeShortcut } from './types';
|
|
3
|
+
export type { NoticeOptions, NoticeGlobalConfig, NoticeInstance, NoticeApi, NoticeContent, NoticeClose, NoticePlacementType, NoticeType, NoticeShortcut, } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* 运行时 / 全局默认配置
|
|
6
|
+
* 也可通过 `app.use(UI, { components: { Notice: {...} } })` 注入
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* config({ placement: 'bottom-end', duration: 2500, maxCount: 3 })
|
|
10
|
+
*/
|
|
11
|
+
declare function config(options?: NoticeGlobalConfig): void;
|
|
12
|
+
/**
|
|
13
|
+
* 打开通知。返回实例,优先用 `instance.close()` 关闭。
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const n = open({ content: '已保存', duration: 3000 })
|
|
17
|
+
* n.close()
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // 同 key 会立刻替换旧通知(适合上传进度)
|
|
21
|
+
* open({ key: 'upload', content: '30%', manual: true })
|
|
22
|
+
* open({ key: 'upload', content: '完成', duration: 2000 })
|
|
23
|
+
*/
|
|
24
|
+
declare function open(options: NoticeOptions): NoticeInstance;
|
|
25
|
+
/**
|
|
26
|
+
* 关闭指定通知(带动画)。更推荐直接 `instance.close()`。
|
|
27
|
+
*/
|
|
28
|
+
declare function close(app: App): void;
|
|
29
|
+
/** 关闭全部通知(带动画) */
|
|
30
|
+
declare function closeAll(): void;
|
|
31
|
+
declare const success: NoticeShortcut;
|
|
32
|
+
declare const info: NoticeShortcut;
|
|
33
|
+
declare const warning: NoticeShortcut;
|
|
34
|
+
declare const error: NoticeShortcut;
|
|
35
|
+
/**
|
|
36
|
+
* Vue 插件安装:挂载 `$notice`,并读取 UI 全局 `components.Notice` 配置
|
|
37
|
+
*/
|
|
38
|
+
declare function install(app: App): void;
|
|
39
|
+
declare const NoticePlugin: {
|
|
40
|
+
install: typeof install;
|
|
41
|
+
open: typeof open;
|
|
42
|
+
close: typeof close;
|
|
43
|
+
closeAll: typeof closeAll;
|
|
44
|
+
config: typeof config;
|
|
45
|
+
success: NoticeShortcut;
|
|
46
|
+
info: NoticeShortcut;
|
|
47
|
+
warning: NoticeShortcut;
|
|
48
|
+
error: NoticeShortcut;
|
|
49
|
+
};
|
|
50
|
+
export default NoticePlugin;
|
|
51
|
+
export { open, close, closeAll, config, success, info, warning, error };
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { UI_CONFIG_KEY } from "../../config/plugin.js";
|
|
2
|
+
import Notice_default from "./Notice.js";
|
|
3
|
+
import { clearNoticeWrapper, createNoticeWrapper } from "./src/_util/index.js";
|
|
4
|
+
import { createApp, createVNode } from "vue";
|
|
5
|
+
import "./src/style/index.css";
|
|
6
|
+
//#region components/notice/index.ts
|
|
7
|
+
var NoticeAppMap = /* @__PURE__ */ new Map();
|
|
8
|
+
var NoticeKeyMap = /* @__PURE__ */ new Map();
|
|
9
|
+
var hostApp = null;
|
|
10
|
+
var defaultOptions = {
|
|
11
|
+
placement: "top-end",
|
|
12
|
+
duration: 4500,
|
|
13
|
+
manual: false,
|
|
14
|
+
showClose: true,
|
|
15
|
+
type: "default",
|
|
16
|
+
hoverKeep: true
|
|
17
|
+
};
|
|
18
|
+
var globalConfig = {};
|
|
19
|
+
/**
|
|
20
|
+
* 运行时 / 全局默认配置
|
|
21
|
+
* 也可通过 `app.use(UI, { components: { Notice: {...} } })` 注入
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* config({ placement: 'bottom-end', duration: 2500, maxCount: 3 })
|
|
25
|
+
*/
|
|
26
|
+
function config(options = {}) {
|
|
27
|
+
globalConfig = {
|
|
28
|
+
...globalConfig,
|
|
29
|
+
...options
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function getMergedOptions(options) {
|
|
33
|
+
return {
|
|
34
|
+
...defaultOptions,
|
|
35
|
+
...globalConfig,
|
|
36
|
+
...options
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function runAfterClose(record) {
|
|
40
|
+
if (!record || record.afterCloseCalled) return;
|
|
41
|
+
record.afterCloseCalled = true;
|
|
42
|
+
record.afterClose?.();
|
|
43
|
+
}
|
|
44
|
+
function inheritAppContext(notice) {
|
|
45
|
+
if (!hostApp) return;
|
|
46
|
+
notice._context.provides = Object.create(hostApp._context.provides);
|
|
47
|
+
}
|
|
48
|
+
function enforceMaxCount(placement) {
|
|
49
|
+
const maxCount = globalConfig.maxCount;
|
|
50
|
+
if (!maxCount || maxCount <= 0) return;
|
|
51
|
+
const samePlacement = [];
|
|
52
|
+
NoticeAppMap.forEach((record) => {
|
|
53
|
+
if (record.noticeWrapper.classList.contains(`w-notice--${placement}`)) samePlacement.push(record);
|
|
54
|
+
});
|
|
55
|
+
const overflow = samePlacement.length + 1 - maxCount;
|
|
56
|
+
if (overflow <= 0) return;
|
|
57
|
+
samePlacement.slice(0, overflow).forEach((record) => {
|
|
58
|
+
record.close();
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/** 跳过退场动画立刻拆掉(同 key 替换用,避免新旧叠动画) */
|
|
62
|
+
function destroyImmediate(uid) {
|
|
63
|
+
const record = NoticeAppMap.get(uid);
|
|
64
|
+
if (!record) return;
|
|
65
|
+
_destroy(record.noticeWrapper, record.itemWrapper, record.app, uid);
|
|
66
|
+
if (NoticeAppMap.size === 0) clearNoticeWrapper();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 打开通知。返回实例,优先用 `instance.close()` 关闭。
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* const n = open({ content: '已保存', duration: 3000 })
|
|
73
|
+
* n.close()
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* // 同 key 会立刻替换旧通知(适合上传进度)
|
|
77
|
+
* open({ key: 'upload', content: '30%', manual: true })
|
|
78
|
+
* open({ key: 'upload', content: '完成', duration: 2000 })
|
|
79
|
+
*/
|
|
80
|
+
function open(options) {
|
|
81
|
+
const { placement = defaultOptions.placement, manual, duration, content, showClose, afterClose, onClose, type, title, icon, class: itemClass, style: itemStyle, wrapperClass, wrapperStyle, offset, zIndex, key, hoverKeep, color, size, cssVars } = getMergedOptions(options);
|
|
82
|
+
if (key !== void 0 && NoticeKeyMap.has(key)) destroyImmediate(NoticeKeyMap.get(key));
|
|
83
|
+
enforceMaxCount(placement);
|
|
84
|
+
const itemWrapper = document.createElement("div");
|
|
85
|
+
const noticeWrapper = createNoticeWrapper(placement, {
|
|
86
|
+
offset: offset ?? globalConfig.offset,
|
|
87
|
+
zIndex: zIndex ?? globalConfig.zIndex,
|
|
88
|
+
wrapperClass: wrapperClass ?? globalConfig.wrapperClass,
|
|
89
|
+
wrapperStyle: wrapperStyle || globalConfig.wrapperStyle
|
|
90
|
+
});
|
|
91
|
+
const closeRef = { current: () => {} };
|
|
92
|
+
let notice;
|
|
93
|
+
const vm = createVNode(Notice_default, {
|
|
94
|
+
placement,
|
|
95
|
+
manual,
|
|
96
|
+
duration,
|
|
97
|
+
showClose,
|
|
98
|
+
type,
|
|
99
|
+
title,
|
|
100
|
+
icon,
|
|
101
|
+
itemClass: itemClass ?? globalConfig.class,
|
|
102
|
+
itemStyle: itemStyle ?? globalConfig.style,
|
|
103
|
+
hoverKeep,
|
|
104
|
+
color,
|
|
105
|
+
size,
|
|
106
|
+
cssVars,
|
|
107
|
+
onClosing: () => {
|
|
108
|
+
onClose?.();
|
|
109
|
+
},
|
|
110
|
+
"onAfter-leave": (_el, uid) => {
|
|
111
|
+
const record = NoticeAppMap.get(uid);
|
|
112
|
+
_destroy(noticeWrapper, itemWrapper, notice, uid);
|
|
113
|
+
runAfterClose(record);
|
|
114
|
+
if (NoticeAppMap.size === 0) clearNoticeWrapper();
|
|
115
|
+
},
|
|
116
|
+
onClose: (closeFn) => {
|
|
117
|
+
closeRef.current = closeFn;
|
|
118
|
+
},
|
|
119
|
+
"onGet-uid": (uid) => {
|
|
120
|
+
NoticeAppMap.set(uid, {
|
|
121
|
+
noticeWrapper,
|
|
122
|
+
itemWrapper,
|
|
123
|
+
close: () => closeRef.current(),
|
|
124
|
+
afterClose,
|
|
125
|
+
key,
|
|
126
|
+
app: notice
|
|
127
|
+
});
|
|
128
|
+
if (key !== void 0) NoticeKeyMap.set(key, uid);
|
|
129
|
+
}
|
|
130
|
+
}, { default: () => {
|
|
131
|
+
if (typeof content === "function") return content(() => closeRef.current());
|
|
132
|
+
return content;
|
|
133
|
+
} });
|
|
134
|
+
notice = createApp(vm);
|
|
135
|
+
inheritAppContext(notice);
|
|
136
|
+
notice.close = () => close(notice);
|
|
137
|
+
notice.mount(itemWrapper);
|
|
138
|
+
noticeWrapper.appendChild(itemWrapper);
|
|
139
|
+
return notice;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* 关闭指定通知(带动画)。更推荐直接 `instance.close()`。
|
|
143
|
+
*/
|
|
144
|
+
function close(app) {
|
|
145
|
+
const uid = app._instance?.uid;
|
|
146
|
+
if (uid === void 0) return;
|
|
147
|
+
const record = NoticeAppMap.get(uid);
|
|
148
|
+
if (!record) return;
|
|
149
|
+
record.close();
|
|
150
|
+
}
|
|
151
|
+
/** 关闭全部通知(带动画) */
|
|
152
|
+
function closeAll() {
|
|
153
|
+
Array.from(NoticeAppMap.values()).forEach((record) => {
|
|
154
|
+
record.close();
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
function isPlainOptions(input) {
|
|
158
|
+
if (input == null || typeof input !== "object" || Array.isArray(input) || input.__v_isVNode) return false;
|
|
159
|
+
return [
|
|
160
|
+
"content",
|
|
161
|
+
"title",
|
|
162
|
+
"placement",
|
|
163
|
+
"duration",
|
|
164
|
+
"manual",
|
|
165
|
+
"showClose",
|
|
166
|
+
"class",
|
|
167
|
+
"style",
|
|
168
|
+
"icon",
|
|
169
|
+
"key",
|
|
170
|
+
"wrapperClass",
|
|
171
|
+
"wrapperStyle",
|
|
172
|
+
"offset",
|
|
173
|
+
"zIndex",
|
|
174
|
+
"hoverKeep",
|
|
175
|
+
"color",
|
|
176
|
+
"size",
|
|
177
|
+
"cssVars",
|
|
178
|
+
"afterClose",
|
|
179
|
+
"onClose"
|
|
180
|
+
].some((k) => k in input);
|
|
181
|
+
}
|
|
182
|
+
function createShortcut(type) {
|
|
183
|
+
return (content, options) => {
|
|
184
|
+
if (isPlainOptions(content)) return open({
|
|
185
|
+
...content,
|
|
186
|
+
type,
|
|
187
|
+
content: content.content ?? ""
|
|
188
|
+
});
|
|
189
|
+
return open({
|
|
190
|
+
...options,
|
|
191
|
+
type,
|
|
192
|
+
content
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
var success = createShortcut("success");
|
|
197
|
+
var info = createShortcut("info");
|
|
198
|
+
var warning = createShortcut("warning");
|
|
199
|
+
var error = createShortcut("error");
|
|
200
|
+
/**
|
|
201
|
+
* Vue 插件安装:挂载 `$notice`,并读取 UI 全局 `components.Notice` 配置
|
|
202
|
+
*/
|
|
203
|
+
function install(app) {
|
|
204
|
+
hostApp = app;
|
|
205
|
+
const noticeCfg = app._context.provides[UI_CONFIG_KEY]?.components?.Notice;
|
|
206
|
+
if (noticeCfg) config(noticeCfg);
|
|
207
|
+
const api = {
|
|
208
|
+
open,
|
|
209
|
+
close,
|
|
210
|
+
closeAll,
|
|
211
|
+
config,
|
|
212
|
+
success,
|
|
213
|
+
info,
|
|
214
|
+
warning,
|
|
215
|
+
error
|
|
216
|
+
};
|
|
217
|
+
app.config.globalProperties.$notice = api;
|
|
218
|
+
}
|
|
219
|
+
function _destroy(noticeWrapper, wrapper, app_notice, uid) {
|
|
220
|
+
const id = uid ?? app_notice._instance?.uid;
|
|
221
|
+
if (id !== void 0) {
|
|
222
|
+
const record = NoticeAppMap.get(id);
|
|
223
|
+
if (record?.key !== void 0 && NoticeKeyMap.get(record.key) === id) NoticeKeyMap.delete(record.key);
|
|
224
|
+
NoticeAppMap.delete(id);
|
|
225
|
+
}
|
|
226
|
+
app_notice.unmount();
|
|
227
|
+
if (wrapper.parentNode) noticeWrapper.removeChild(wrapper);
|
|
228
|
+
}
|
|
229
|
+
var NoticePlugin = {
|
|
230
|
+
install,
|
|
231
|
+
open,
|
|
232
|
+
close,
|
|
233
|
+
closeAll,
|
|
234
|
+
config,
|
|
235
|
+
success,
|
|
236
|
+
info,
|
|
237
|
+
warning,
|
|
238
|
+
error
|
|
239
|
+
};
|
|
240
|
+
//#endregion
|
|
241
|
+
export { close, closeAll, config, NoticePlugin as default, error, info, open, success, warning };
|
|
242
|
+
|
|
243
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../components/notice/index.ts"],"sourcesContent":["import type { App } from 'vue'\r\nimport { createVNode, createApp } from 'vue'\r\nimport MainNotice from './Notice'\r\nimport { createNoticeWrapper, clearNoticeWrapper } from './src/_util/index'\r\nimport { UI_CONFIG_KEY, type UIPluginConfig } from '../../config/plugin'\r\nimport type {\r\n NoticeOptions,\r\n NoticeGlobalConfig,\r\n NoticeInstance,\r\n NoticeApi,\r\n NoticeContent,\r\n NoticeShortcut,\r\n NoticeType,\r\n} from './types'\r\n\r\nexport type {\r\n NoticeOptions,\r\n NoticeGlobalConfig,\r\n NoticeInstance,\r\n NoticeApi,\r\n NoticeContent,\r\n NoticeClose,\r\n NoticePlacementType,\r\n NoticeType,\r\n NoticeShortcut,\r\n} from './types'\r\n\r\ninterface NoticeRecord {\r\n noticeWrapper: HTMLElement\r\n itemWrapper: HTMLElement\r\n close: () => void\r\n afterClose?: () => void\r\n afterCloseCalled?: boolean\r\n key?: string | number\r\n app: App\r\n}\r\n\r\nconst NoticeAppMap = new Map<number, NoticeRecord>()\r\nconst NoticeKeyMap = new Map<string | number, number>()\r\n\r\nlet hostApp: App | null = null\r\n\r\nconst defaultOptions: Required<\r\n Pick<\r\n NoticeOptions,\r\n | 'placement'\r\n | 'duration'\r\n | 'manual'\r\n | 'showClose'\r\n | 'type'\r\n | 'hoverKeep'\r\n >\r\n> = {\r\n placement: 'top-end',\r\n duration: 4500,\r\n manual: false,\r\n showClose: true,\r\n type: 'default',\r\n hoverKeep: true,\r\n}\r\n\r\nlet globalConfig: NoticeGlobalConfig = {}\r\n\r\n/**\r\n * 运行时 / 全局默认配置\r\n * 也可通过 `app.use(UI, { components: { Notice: {...} } })` 注入\r\n *\r\n * @example\r\n * config({ placement: 'bottom-end', duration: 2500, maxCount: 3 })\r\n */\r\nfunction config(options: NoticeGlobalConfig = {}): void {\r\n globalConfig = { ...globalConfig, ...options }\r\n}\r\n\r\nfunction getMergedOptions(options: NoticeOptions): NoticeOptions {\r\n return {\r\n ...defaultOptions,\r\n ...globalConfig,\r\n ...options,\r\n }\r\n}\r\n\r\nfunction runAfterClose(record?: NoticeRecord) {\r\n if (!record || record.afterCloseCalled) return\r\n record.afterCloseCalled = true\r\n record.afterClose?.()\r\n}\r\n\r\nfunction inheritAppContext(notice: App) {\r\n if (!hostApp) return\r\n notice._context.provides = Object.create(hostApp._context.provides)\r\n}\r\n\r\nfunction enforceMaxCount(placement: string) {\r\n const maxCount = globalConfig.maxCount\r\n if (!maxCount || maxCount <= 0) return\r\n\r\n const samePlacement: NoticeRecord[] = []\r\n NoticeAppMap.forEach((record) => {\r\n if (record.noticeWrapper.classList.contains(`w-notice--${placement}`)) {\r\n samePlacement.push(record)\r\n }\r\n })\r\n\r\n const overflow = samePlacement.length + 1 - maxCount\r\n if (overflow <= 0) return\r\n\r\n samePlacement.slice(0, overflow).forEach((record) => {\r\n record.close()\r\n })\r\n}\r\n\r\n/** 跳过退场动画立刻拆掉(同 key 替换用,避免新旧叠动画) */\r\nfunction destroyImmediate(uid: number) {\r\n const record = NoticeAppMap.get(uid)\r\n if (!record) return\r\n _destroy(record.noticeWrapper, record.itemWrapper, record.app, uid)\r\n if (NoticeAppMap.size === 0) {\r\n clearNoticeWrapper()\r\n }\r\n}\r\n\r\n/**\r\n * 打开通知。返回实例,优先用 `instance.close()` 关闭。\r\n *\r\n * @example\r\n * const n = open({ content: '已保存', duration: 3000 })\r\n * n.close()\r\n *\r\n * @example\r\n * // 同 key 会立刻替换旧通知(适合上传进度)\r\n * open({ key: 'upload', content: '30%', manual: true })\r\n * open({ key: 'upload', content: '完成', duration: 2000 })\r\n */\r\nfunction open(options: NoticeOptions): NoticeInstance {\r\n const merged = getMergedOptions(options)\r\n const {\r\n placement = defaultOptions.placement,\r\n manual,\r\n duration,\r\n content,\r\n showClose,\r\n afterClose,\r\n onClose,\r\n type,\r\n title,\r\n icon,\r\n class: itemClass,\r\n style: itemStyle,\r\n wrapperClass,\r\n wrapperStyle,\r\n offset,\r\n zIndex,\r\n key,\r\n hoverKeep,\r\n color,\r\n size,\r\n cssVars,\r\n } = merged\r\n\r\n if (key !== undefined && NoticeKeyMap.has(key)) {\r\n destroyImmediate(NoticeKeyMap.get(key)!)\r\n }\r\n\r\n enforceMaxCount(placement)\r\n\r\n const itemWrapper = document.createElement('div')\r\n const noticeWrapper = createNoticeWrapper(placement, {\r\n offset: offset ?? globalConfig.offset,\r\n zIndex: zIndex ?? globalConfig.zIndex,\r\n wrapperClass: wrapperClass ?? globalConfig.wrapperClass,\r\n wrapperStyle: (wrapperStyle ||\r\n globalConfig.wrapperStyle) as Record<string, string>,\r\n })\r\n\r\n const closeRef: { current: () => void } = {\r\n current: () => {},\r\n }\r\n\r\n let notice!: NoticeInstance\r\n\r\n const vm = createVNode(\r\n MainNotice,\r\n {\r\n placement,\r\n manual,\r\n duration,\r\n showClose,\r\n type,\r\n title,\r\n icon,\r\n itemClass: itemClass ?? globalConfig.class,\r\n itemStyle: itemStyle ?? globalConfig.style,\r\n hoverKeep,\r\n color,\r\n size,\r\n cssVars,\r\n onClosing: () => {\r\n onClose?.()\r\n },\r\n 'onAfter-leave': (_el: HTMLElement, uid: number) => {\r\n const record = NoticeAppMap.get(uid)\r\n _destroy(noticeWrapper, itemWrapper, notice, uid)\r\n runAfterClose(record)\r\n if (NoticeAppMap.size === 0) {\r\n clearNoticeWrapper()\r\n }\r\n },\r\n onClose: (closeFn: () => void) => {\r\n closeRef.current = closeFn\r\n },\r\n 'onGet-uid': (uid: number) => {\r\n NoticeAppMap.set(uid, {\r\n noticeWrapper,\r\n itemWrapper,\r\n close: () => closeRef.current(),\r\n afterClose,\r\n key,\r\n app: notice,\r\n })\r\n if (key !== undefined) {\r\n NoticeKeyMap.set(key, uid)\r\n }\r\n },\r\n },\r\n {\r\n default: () => {\r\n if (typeof content === 'function') {\r\n return content(() => closeRef.current())\r\n }\r\n return content\r\n },\r\n },\r\n )\r\n\r\n notice = createApp(vm) as NoticeInstance\r\n inheritAppContext(notice)\r\n notice.close = () => close(notice)\r\n notice.mount(itemWrapper)\r\n noticeWrapper.appendChild(itemWrapper)\r\n\r\n return notice\r\n}\r\n\r\n/**\r\n * 关闭指定通知(带动画)。更推荐直接 `instance.close()`。\r\n */\r\nfunction close(app: App): void {\r\n const uid = app._instance?.uid\r\n if (uid === undefined) return\r\n const record = NoticeAppMap.get(uid)\r\n if (!record) return\r\n record.close()\r\n}\r\n\r\n/** 关闭全部通知(带动画) */\r\nfunction closeAll(): void {\r\n const list = Array.from(NoticeAppMap.values())\r\n list.forEach((record) => {\r\n record.close()\r\n })\r\n}\r\n\r\nfunction isPlainOptions(\r\n input: NoticeContent | (Omit<NoticeOptions, 'type'> & { content?: NoticeContent }),\r\n): input is Omit<NoticeOptions, 'type'> & { content?: NoticeContent } {\r\n if (\r\n input == null ||\r\n typeof input !== 'object' ||\r\n Array.isArray(input) ||\r\n (input as any).__v_isVNode\r\n ) {\r\n return false\r\n }\r\n const keys = [\r\n 'content',\r\n 'title',\r\n 'placement',\r\n 'duration',\r\n 'manual',\r\n 'showClose',\r\n 'class',\r\n 'style',\r\n 'icon',\r\n 'key',\r\n 'wrapperClass',\r\n 'wrapperStyle',\r\n 'offset',\r\n 'zIndex',\r\n 'hoverKeep',\r\n 'color',\r\n 'size',\r\n 'cssVars',\r\n 'afterClose',\r\n 'onClose',\r\n ]\r\n return keys.some((k) => k in (input as object))\r\n}\r\n\r\nfunction createShortcut(type: NoticeType): NoticeShortcut {\r\n return (content, options) => {\r\n if (isPlainOptions(content)) {\r\n return open({\r\n ...content,\r\n type,\r\n content: (content.content ?? '') as NoticeContent,\r\n })\r\n }\r\n return open({\r\n ...options,\r\n type,\r\n content: content as NoticeContent,\r\n })\r\n }\r\n}\r\n\r\nconst success = createShortcut('success')\r\nconst info = createShortcut('info')\r\nconst warning = createShortcut('warning')\r\nconst error = createShortcut('error')\r\n\r\n/**\r\n * Vue 插件安装:挂载 `$notice`,并读取 UI 全局 `components.Notice` 配置\r\n */\r\nfunction install(app: App): void {\r\n hostApp = app\r\n\r\n const uiConfig = app._context.provides[UI_CONFIG_KEY as any] as\r\n | UIPluginConfig\r\n | undefined\r\n const noticeCfg = uiConfig?.components?.Notice as NoticeGlobalConfig | undefined\r\n if (noticeCfg) {\r\n config(noticeCfg)\r\n }\r\n\r\n const api: NoticeApi = {\r\n open,\r\n close,\r\n closeAll,\r\n config,\r\n success,\r\n info,\r\n warning,\r\n error,\r\n }\r\n\r\n app.config.globalProperties.$notice = api\r\n}\r\n\r\nfunction _destroy(\r\n noticeWrapper: HTMLElement,\r\n wrapper: HTMLElement,\r\n app_notice: App,\r\n uid?: number,\r\n): void {\r\n const id = uid ?? app_notice._instance?.uid\r\n if (id !== undefined) {\r\n const record = NoticeAppMap.get(id)\r\n if (\r\n record?.key !== undefined &&\r\n NoticeKeyMap.get(record.key) === id\r\n ) {\r\n NoticeKeyMap.delete(record.key)\r\n }\r\n NoticeAppMap.delete(id)\r\n }\r\n app_notice.unmount()\r\n if (wrapper.parentNode) {\r\n noticeWrapper.removeChild(wrapper)\r\n }\r\n}\r\n\r\nconst NoticePlugin = {\r\n install,\r\n open,\r\n close,\r\n closeAll,\r\n config,\r\n success,\r\n info,\r\n warning,\r\n error,\r\n}\r\n\r\nexport default NoticePlugin\r\nexport { open, close, closeAll, config, success, info, warning, error }\r\n\r\nimport './src/style/index.css'\r\n"],"mappings":";;;;;;AAqCA,IAAM,+BAAe,IAAI,IAA0B;AACnD,IAAM,+BAAe,IAAI,IAA6B;AAEtD,IAAI,UAAsB;AAE1B,IAAM,iBAUF;CACF,WAA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aAAa,IAAI,OAAO,GAAG,MAAM,IAEjC,aAAa,OAAO,OAAO,GAAG;EAEhC,aAAa,OAAO,EAAE;CACxB;CACA,WAAW,QAAQ;CACnB,IAAI,QAAQ,YACV,cAAc,YAAY,OAAO;AAErC;AAEA,IAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NoticePlacementType } from '../types';
|
|
2
|
+
declare function createNoticeWrapper(placement: NoticePlacementType | string, options?: {
|
|
3
|
+
offset?: number | string;
|
|
4
|
+
zIndex?: number;
|
|
5
|
+
wrapperClass?: any;
|
|
6
|
+
wrapperStyle?: Record<string, string>;
|
|
7
|
+
}): HTMLElement;
|
|
8
|
+
declare function removeNoticeWrapper(el: HTMLElement): void;
|
|
9
|
+
declare function clearNoticeWrapper(): void;
|
|
10
|
+
declare function getWrapperCount(placement?: string): number;
|
|
11
|
+
export { createNoticeWrapper, removeNoticeWrapper, clearNoticeWrapper, getWrapperCount, };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import useGlobalZIndex from "../../../../use/useGlobalZIndex.js";
|
|
2
|
+
//#region components/notice/src/_util/index.ts
|
|
3
|
+
var WRAPPERS = {};
|
|
4
|
+
function normalizeOffset(offset) {
|
|
5
|
+
if (offset === void 0 || offset === null || offset === "") return void 0;
|
|
6
|
+
return typeof offset === "number" ? `${offset}px` : String(offset);
|
|
7
|
+
}
|
|
8
|
+
function applyWrapperStyle(el, options) {
|
|
9
|
+
const { offset, zIndex, wrapperClass, wrapperStyle } = options || {};
|
|
10
|
+
if (wrapperClass) {
|
|
11
|
+
const extra = Array.isArray(wrapperClass) ? wrapperClass.filter(Boolean).join(" ") : typeof wrapperClass === "string" ? wrapperClass : Object.keys(wrapperClass).filter((k) => wrapperClass[k]).join(" ");
|
|
12
|
+
el.getAttribute("data-base-class") || el.className;
|
|
13
|
+
if (!el.getAttribute("data-base-class")) el.setAttribute("data-base-class", el.className);
|
|
14
|
+
el.className = `${el.getAttribute("data-base-class")} ${extra}`.trim();
|
|
15
|
+
}
|
|
16
|
+
if (wrapperStyle) Object.assign(el.style, wrapperStyle);
|
|
17
|
+
const offsetValue = normalizeOffset(offset);
|
|
18
|
+
if (offsetValue) el.style.setProperty("--w-notice-offset", offsetValue);
|
|
19
|
+
if (typeof zIndex === "number") el.style.zIndex = String(zIndex);
|
|
20
|
+
}
|
|
21
|
+
function createNoticeWrapper(placement, options) {
|
|
22
|
+
const { zIndex, add } = useGlobalZIndex();
|
|
23
|
+
if (placement in WRAPPERS) {
|
|
24
|
+
const el = WRAPPERS[placement];
|
|
25
|
+
el.style.zIndex = options?.zIndex != null ? String(options.zIndex) : String(add());
|
|
26
|
+
applyWrapperStyle(el, options);
|
|
27
|
+
return el;
|
|
28
|
+
}
|
|
29
|
+
const el = document.createElement("div");
|
|
30
|
+
const id = `notice_container_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`;
|
|
31
|
+
const klass = `w-notice w-notice--${placement}`;
|
|
32
|
+
el.id = id;
|
|
33
|
+
el.className = klass;
|
|
34
|
+
el.setAttribute("data-base-class", klass);
|
|
35
|
+
el.style.zIndex = options?.zIndex != null ? String(options.zIndex) : String(zIndex.value);
|
|
36
|
+
applyWrapperStyle(el, options);
|
|
37
|
+
WRAPPERS[placement] = el;
|
|
38
|
+
document.body.appendChild(el);
|
|
39
|
+
return el;
|
|
40
|
+
}
|
|
41
|
+
function clearNoticeWrapper() {
|
|
42
|
+
for (const p in WRAPPERS) if (WRAPPERS[p]) {
|
|
43
|
+
if (WRAPPERS[p].parentNode) document.body.removeChild(WRAPPERS[p]);
|
|
44
|
+
delete WRAPPERS[p];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { clearNoticeWrapper, createNoticeWrapper };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../components/notice/src/_util/index.ts"],"sourcesContent":["import useGlobalZIndex from '../../../../use/useGlobalZIndex'\r\nimport type { NoticePlacementType } from '../types'\r\n\r\ninterface WrapperType {\r\n [k: string]: HTMLElement\r\n}\r\n\r\nlet WRAPPERS: WrapperType = {}\r\n\r\nfunction normalizeOffset(offset?: number | string) {\r\n if (offset === undefined || offset === null || offset === '') return undefined\r\n return typeof offset === 'number' ? `${offset}px` : String(offset)\r\n}\r\n\r\nfunction applyWrapperStyle(\r\n el: HTMLElement,\r\n options?: {\r\n offset?: number | string\r\n zIndex?: number\r\n wrapperClass?: any\r\n wrapperStyle?: Record<string, string>\r\n },\r\n) {\r\n const { offset, zIndex, wrapperClass, wrapperStyle } = options || {}\r\n\r\n if (wrapperClass) {\r\n const extra = Array.isArray(wrapperClass)\r\n ? wrapperClass.filter(Boolean).join(' ')\r\n : typeof wrapperClass === 'string'\r\n ? wrapperClass\r\n : Object.keys(wrapperClass)\r\n .filter((k) => (wrapperClass as Record<string, boolean>)[k])\r\n .join(' ')\r\n const base = el.getAttribute('data-base-class') || el.className\r\n if (!el.getAttribute('data-base-class')) {\r\n el.setAttribute('data-base-class', el.className)\r\n }\r\n el.className = `${el.getAttribute('data-base-class')} ${extra}`.trim()\r\n }\r\n\r\n if (wrapperStyle) {\r\n Object.assign(el.style, wrapperStyle)\r\n }\r\n\r\n const offsetValue = normalizeOffset(offset)\r\n if (offsetValue) {\r\n el.style.setProperty('--w-notice-offset', offsetValue)\r\n }\r\n\r\n if (typeof zIndex === 'number') {\r\n el.style.zIndex = String(zIndex)\r\n }\r\n}\r\n\r\nfunction createNoticeWrapper(\r\n placement: NoticePlacementType | string,\r\n options?: {\r\n offset?: number | string\r\n zIndex?: number\r\n wrapperClass?: any\r\n wrapperStyle?: Record<string, string>\r\n },\r\n) {\r\n const { zIndex, add } = useGlobalZIndex()\r\n\r\n if (placement in WRAPPERS) {\r\n const el = WRAPPERS[placement]\r\n el.style.zIndex =\r\n options?.zIndex != null ? String(options.zIndex) : String(add())\r\n applyWrapperStyle(el, options)\r\n return el\r\n }\r\n\r\n const el = document.createElement('div')\r\n const id = `notice_container_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`\r\n const klass = `w-notice w-notice--${placement}`\r\n el.id = id\r\n el.className = klass\r\n el.setAttribute('data-base-class', klass)\r\n el.style.zIndex =\r\n options?.zIndex != null ? String(options.zIndex) : String(zIndex.value)\r\n applyWrapperStyle(el, options)\r\n WRAPPERS[placement] = el\r\n document.body.appendChild(el)\r\n return el\r\n}\r\n\r\nfunction removeNoticeWrapper(el: HTMLElement) {\r\n let p = ''\r\n for (const pla in WRAPPERS) {\r\n if (WRAPPERS[pla] === el) {\r\n p = pla\r\n }\r\n }\r\n if (p) {\r\n if (el.parentNode) {\r\n document.body.removeChild(el)\r\n }\r\n delete WRAPPERS[p]\r\n }\r\n}\r\n\r\nfunction clearNoticeWrapper() {\r\n for (const p in WRAPPERS) {\r\n if (WRAPPERS[p]) {\r\n if (WRAPPERS[p].parentNode) {\r\n document.body.removeChild(WRAPPERS[p])\r\n }\r\n delete WRAPPERS[p]\r\n }\r\n }\r\n}\r\n\r\nfunction getWrapperCount(placement?: string) {\r\n if (placement) {\r\n const el = WRAPPERS[placement]\r\n return el ? el.childElementCount : 0\r\n }\r\n return Object.values(WRAPPERS).reduce((n, el) => n + el.childElementCount, 0)\r\n}\r\n\r\nexport {\r\n createNoticeWrapper,\r\n removeNoticeWrapper,\r\n clearNoticeWrapper,\r\n getWrapperCount,\r\n}\r\n"],"mappings":";;AAOA,IAAI,WAAwB,CAAC;AAE7B,SAAS,gBAAgB,QAA0B;CACjD,IAAI,WAAW,KAAA,KAAa,WAAW,QAAQ,WAAW,IAAI,OAAO,KAAA;CACrE,OAAO,OAAO,WAAW,WAAW,GAAG,OAAO,MAAM,OAAO,MAAM;AACnE;AAEA,SAAS,kBACP,IACA,SAMA;CACA,MAAM,EAAE,QAAQ,QAAQ,cAAc,iBAAiB,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