litos-ui 0.21.0 → 0.23.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/README.md +121 -15
- package/README.zh-CN.md +155 -0
- package/lib/base.d.ts +1 -0
- package/lib/base.js +1 -1
- package/lib/button/index.js +4 -4
- package/lib/{style-gKR_qwzm.js → button/index.less_inline.js} +2 -3
- package/lib/button/style.js +8 -2
- package/lib/calendar/index.js +140 -2
- package/lib/calendar/index.less_inline.js +4 -0
- package/lib/calendar/langs.js +12 -0
- package/lib/card/index.js +64 -2
- package/lib/card/index.less_inline.js +4 -0
- package/lib/carousel/index.js +257 -2
- package/lib/carousel/index.less_inline.js +4 -0
- package/lib/carousel/item.js +15 -2
- package/lib/carousel/item.less_inline.js +4 -0
- package/lib/carousel/timer.js +19 -0
- package/lib/check/check.d.ts +1 -0
- package/lib/check/check.js +117 -0
- package/lib/check/check.less_inline.js +4 -0
- package/lib/check/checkbox.js +18 -2
- package/lib/{checkbox-DhGHJXwI.js → check/checkbox.less_inline.js} +2 -14
- package/lib/check/checkbox_group.js +1 -1
- package/lib/check/index.d.ts +1 -0
- package/lib/{check-DFlwStH9.js → check/index.js} +10 -9
- package/lib/check/index.less_inline.js +4 -0
- package/lib/check/radio.js +15 -2
- package/lib/{radio-C9NPQWGI.js → check/radio.less_inline.js} +2 -11
- package/lib/check/radio_group.js +1 -1
- package/lib/collapse/index.js +103 -2
- package/lib/collapse/index.less_inline.js +4 -0
- package/lib/collapse/item.d.ts +1 -0
- package/lib/collapse/item.js +118 -2
- package/lib/collapse/item.less_inline.js +4 -0
- package/lib/collapse/types.d.ts +1 -0
- package/lib/color_picker/index.js +42 -2
- package/lib/color_picker/index.less_inline.js +4 -0
- package/lib/date_picker/index.js +100 -3
- package/lib/date_picker/index.less_inline.js +4 -0
- package/lib/date_picker_ori/index.js +121 -2
- package/lib/date_picker_ori/index.less_inline.js +4 -0
- package/lib/description_panel/index.js +54 -2
- package/lib/description_panel/index.less_inline.js +4 -0
- package/lib/dialog/dialog_box.js +10 -10
- package/lib/{dialog_container_style-C1s0aBf7.js → dialog/dialog_container.css_inline.js} +2 -3
- package/lib/dialog/dialog_container.d.ts +1 -0
- package/lib/dialog/dialog_container.js +71 -60
- package/lib/dialog/dialog_container_style.js +8 -2
- package/lib/dialog/index.d.ts +1 -0
- package/lib/dialog/index.js +11 -6
- package/lib/entries/base.d.ts +2 -0
- package/lib/entries/base.js +2 -0
- package/lib/entries/button.d.ts +2 -0
- package/lib/entries/button.js +6 -0
- package/lib/entries/calendar.d.ts +2 -0
- package/lib/entries/calendar.js +6 -0
- package/lib/entries/card.d.ts +2 -0
- package/lib/entries/card.js +6 -0
- package/lib/entries/carousel-item.d.ts +2 -0
- package/lib/entries/carousel-item.js +6 -0
- package/lib/entries/carousel.d.ts +5 -0
- package/lib/entries/carousel.js +6 -0
- package/lib/entries/checkbox-group.d.ts +3 -0
- package/lib/entries/checkbox-group.js +6 -0
- package/lib/entries/checkbox.d.ts +2 -0
- package/lib/entries/checkbox.js +6 -0
- package/lib/entries/collapse-item.d.ts +3 -0
- package/lib/entries/collapse-item.js +6 -0
- package/lib/entries/collapse.d.ts +3 -0
- package/lib/entries/collapse.js +6 -0
- package/lib/entries/color-picker.d.ts +3 -0
- package/lib/entries/color-picker.js +6 -0
- package/lib/entries/date-picker-ori.d.ts +2 -0
- package/lib/entries/date-picker-ori.js +6 -0
- package/lib/entries/date-picker.d.ts +9 -0
- package/lib/entries/date-picker.js +6 -0
- package/lib/entries/description-panel.d.ts +4 -0
- package/lib/entries/description-panel.js +6 -0
- package/lib/entries/dialog-box.d.ts +6 -0
- package/lib/entries/dialog-box.js +2 -0
- package/lib/entries/dialog-container.d.ts +4 -0
- package/lib/entries/dialog-container.js +6 -0
- package/lib/entries/dialog.d.ts +3 -0
- package/lib/entries/dialog.js +2 -0
- package/lib/entries/form-item.d.ts +2 -0
- package/lib/entries/form-item.js +6 -0
- package/lib/entries/form.d.ts +3 -0
- package/lib/entries/form.js +6 -0
- package/lib/entries/icon-arrow-down.d.ts +2 -0
- package/lib/entries/icon-arrow-down.js +6 -0
- package/lib/entries/icon-arrow-left.d.ts +2 -0
- package/lib/entries/icon-arrow-left.js +6 -0
- package/lib/entries/icon-arrow-right.d.ts +2 -0
- package/lib/entries/icon-arrow-right.js +6 -0
- package/lib/entries/icon-arrow-up.d.ts +2 -0
- package/lib/entries/icon-arrow-up.js +6 -0
- package/lib/entries/icon-base.d.ts +2 -0
- package/lib/entries/icon-base.js +6 -0
- package/lib/entries/icon-calendar.d.ts +2 -0
- package/lib/entries/icon-calendar.js +6 -0
- package/lib/entries/icon-caret-bottom.d.ts +2 -0
- package/lib/entries/icon-caret-bottom.js +6 -0
- package/lib/entries/icon-caret-top.d.ts +2 -0
- package/lib/entries/icon-caret-top.js +6 -0
- package/lib/entries/icon-close-filled.d.ts +2 -0
- package/lib/entries/icon-close-filled.js +6 -0
- package/lib/entries/icon-close.d.ts +2 -0
- package/lib/entries/icon-close.js +6 -0
- package/lib/entries/icon-copy.d.ts +2 -0
- package/lib/entries/icon-copy.js +6 -0
- package/lib/entries/icon-d-arrow-left.d.ts +2 -0
- package/lib/entries/icon-d-arrow-left.js +6 -0
- package/lib/entries/icon-d-arrow-right.d.ts +2 -0
- package/lib/entries/icon-d-arrow-right.js +6 -0
- package/lib/entries/icon-delete.d.ts +2 -0
- package/lib/entries/icon-delete.js +6 -0
- package/lib/entries/icon-eye-outline.d.ts +2 -0
- package/lib/entries/icon-eye-outline.js +6 -0
- package/lib/entries/icon-font-icon.d.ts +2 -0
- package/lib/entries/icon-font-icon.js +6 -0
- package/lib/entries/icon-info.d.ts +2 -0
- package/lib/entries/icon-info.js +6 -0
- package/lib/entries/icon-loading.d.ts +2 -0
- package/lib/entries/icon-loading.js +6 -0
- package/lib/entries/icon-minus.d.ts +2 -0
- package/lib/entries/icon-minus.js +6 -0
- package/lib/entries/icon-moon.d.ts +2 -0
- package/lib/entries/icon-moon.js +6 -0
- package/lib/entries/icon-more.d.ts +2 -0
- package/lib/entries/icon-more.js +6 -0
- package/lib/entries/icon-picture.d.ts +2 -0
- package/lib/entries/icon-picture.js +6 -0
- package/lib/entries/icon-plus.d.ts +2 -0
- package/lib/entries/icon-plus.js +6 -0
- package/lib/entries/icon-reduction.d.ts +2 -0
- package/lib/entries/icon-reduction.js +6 -0
- package/lib/entries/icon-refresh-left.d.ts +2 -0
- package/lib/entries/icon-refresh-left.js +6 -0
- package/lib/entries/icon-refresh-right.d.ts +2 -0
- package/lib/entries/icon-refresh-right.js +6 -0
- package/lib/entries/icon-refresh.d.ts +2 -0
- package/lib/entries/icon-refresh.js +6 -0
- package/lib/entries/icon-search.d.ts +2 -0
- package/lib/entries/icon-search.js +6 -0
- package/lib/entries/icon-select.d.ts +2 -0
- package/lib/entries/icon-select.js +6 -0
- package/lib/entries/icon-sort.d.ts +2 -0
- package/lib/entries/icon-sort.js +6 -0
- package/lib/entries/icon-success.d.ts +2 -0
- package/lib/entries/icon-success.js +6 -0
- package/lib/entries/icon-sun.d.ts +2 -0
- package/lib/entries/icon-sun.js +6 -0
- package/lib/entries/icon-theme-default.d.ts +2 -0
- package/lib/entries/icon-theme-default.js +6 -0
- package/lib/entries/icon-warn.d.ts +2 -0
- package/lib/entries/icon-warn.js +6 -0
- package/lib/entries/icon-zoom-in.d.ts +2 -0
- package/lib/entries/icon-zoom-in.js +6 -0
- package/lib/entries/icon-zoom-out.d.ts +2 -0
- package/lib/entries/icon-zoom-out.js +6 -0
- package/lib/entries/image-preview.d.ts +10 -0
- package/lib/entries/image-preview.js +6 -0
- package/lib/entries/image.d.ts +2 -0
- package/lib/entries/image.js +6 -0
- package/lib/entries/input-number.d.ts +2 -0
- package/lib/entries/input-number.js +6 -0
- package/lib/entries/input.d.ts +2 -0
- package/lib/entries/input.js +6 -0
- package/lib/entries/list.d.ts +3 -0
- package/lib/entries/list.js +6 -0
- package/lib/entries/loading.d.ts +2 -0
- package/lib/entries/loading.js +2 -0
- package/lib/entries/mask.d.ts +2 -0
- package/lib/entries/mask.js +6 -0
- package/lib/entries/md-input.d.ts +2 -0
- package/lib/entries/md-input.js +6 -0
- package/lib/entries/menu.d.ts +3 -0
- package/lib/entries/menu.js +6 -0
- package/lib/entries/message.d.ts +6 -0
- package/lib/entries/message.js +2 -0
- package/lib/entries/modal-box.d.ts +6 -0
- package/lib/entries/modal-box.js +2 -0
- package/lib/entries/modal.d.ts +4 -0
- package/lib/entries/modal.js +6 -0
- package/lib/entries/notification-box.d.ts +2 -0
- package/lib/entries/notification-box.js +2 -0
- package/lib/entries/notification.d.ts +2 -0
- package/lib/entries/notification.js +2 -0
- package/lib/entries/page-header.d.ts +4 -0
- package/lib/entries/page-header.js +6 -0
- package/lib/entries/pagination.d.ts +9 -0
- package/lib/entries/pagination.js +6 -0
- package/lib/entries/polygon.d.ts +2 -0
- package/lib/entries/polygon.js +6 -0
- package/lib/entries/popconfirm.d.ts +3 -0
- package/lib/entries/popconfirm.js +2 -0
- package/lib/entries/popover.d.ts +1 -0
- package/lib/entries/popover.js +2 -0
- package/lib/entries/qrcode.d.ts +2 -0
- package/lib/entries/qrcode.js +6 -0
- package/lib/entries/radio-group.d.ts +3 -0
- package/lib/entries/radio-group.js +6 -0
- package/lib/entries/radio.d.ts +2 -0
- package/lib/entries/radio.js +6 -0
- package/lib/entries/select-ori.d.ts +2 -0
- package/lib/entries/select-ori.js +6 -0
- package/lib/entries/select.d.ts +4 -0
- package/lib/entries/select.js +6 -0
- package/lib/entries/space.d.ts +2 -0
- package/lib/entries/space.js +6 -0
- package/lib/entries/switch.d.ts +2 -0
- package/lib/entries/switch.js +6 -0
- package/lib/entries/tabbar-item.d.ts +2 -0
- package/lib/entries/tabbar-item.js +6 -0
- package/lib/entries/tabbar.d.ts +3 -0
- package/lib/entries/tabbar.js +6 -0
- package/lib/entries/table.d.ts +3 -0
- package/lib/entries/table.js +6 -0
- package/lib/entries/tabs.d.ts +3 -0
- package/lib/entries/tabs.js +2 -0
- package/lib/entries/tag.d.ts +2 -0
- package/lib/entries/tag.js +6 -0
- package/lib/entries/theme-color.d.ts +3 -0
- package/lib/entries/theme-color.js +6 -0
- package/lib/entries/theme.d.ts +9 -0
- package/lib/entries/theme.js +6 -0
- package/lib/entries/transition.d.ts +1 -0
- package/lib/entries/transition.js +2 -0
- package/lib/entries/upload.d.ts +3 -0
- package/lib/entries/upload.js +6 -0
- package/lib/entries/utils.d.ts +1 -0
- package/lib/entries/utils.js +2 -0
- package/lib/form/form_inner.d.ts +1 -0
- package/lib/{form_inner-Cnwb6f_Q.js → form/form_inner.js} +9 -9
- package/lib/form/form_item.d.ts +2 -1
- package/lib/form/form_item.js +148 -2
- package/lib/form/form_item.less_inline.js +4 -0
- package/lib/form/index.d.ts +3 -2
- package/lib/form/index.js +191 -2
- package/lib/form/index.less_inline.js +4 -0
- package/lib/icon/base.js +1 -1
- package/lib/icon/delete.d.ts +5 -0
- package/lib/icon/delete.js +10 -0
- package/lib/icon/eye_outline.d.ts +6 -0
- package/lib/icon/eye_outline.js +13 -0
- package/lib/icon/icon_style.js +8 -2
- package/lib/{icon_style-J7iiDS_a.js → icon/index.less_inline.js} +2 -3
- package/lib/icon/minus.d.ts +5 -0
- package/lib/icon/minus.js +10 -0
- package/lib/icon/picture.d.ts +5 -0
- package/lib/icon/picture.js +10 -0
- package/lib/icon/plus.d.ts +5 -0
- package/lib/icon/plus.js +10 -0
- package/lib/image/image_preview.js +91 -2
- package/lib/image/image_preview.less_inline.js +4 -0
- package/lib/image/index.js +163 -2
- package/lib/image/index.less_inline.js +4 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +48 -40
- package/lib/input/index.js +4 -4
- package/lib/{input-DUBlLEXS.js → input/index.less_inline.js} +1 -1
- package/lib/{input_inner-x4GfLGjj.js → input/input_inner.less_inline.js} +1 -1
- package/lib/input_number/index.js +3 -3
- package/lib/{style-C5wUmE2b.js → input_number/index.less_inline.js} +2 -3
- package/lib/input_number/style.js +8 -2
- package/lib/list/index.js +52 -2
- package/lib/list/index.less_inline.js +4 -0
- package/lib/loading/index.js +1 -1
- package/lib/mask/index.d.ts +1 -1
- package/lib/mask/index.js +109 -2
- package/lib/mask/index.less_inline.js +4 -0
- package/lib/md_input/index.js +59 -2
- package/lib/md_input/index.less_inline.js +4 -0
- package/lib/menu/index.js +275 -2
- package/lib/menu/index.less_inline.js +4 -0
- package/lib/message/index.js +1 -1
- package/lib/modal/index.js +199 -2
- package/lib/modal/index.less_inline.js +4 -0
- package/lib/modal/modal_box.js +21 -22
- package/lib/notification/index.d.ts +171 -0
- package/lib/notification/index.js +326 -0
- package/lib/notification/index.less_inline.js +4 -0
- package/lib/notification/notification_box.d.ts +40 -0
- package/lib/notification/notification_box.js +57 -0
- package/lib/notification/placement.d.ts +49 -0
- package/lib/notification/placement.js +48 -0
- package/lib/notification/style.d.ts +2 -0
- package/lib/notification/style.js +8 -0
- package/lib/page_header/index.js +100 -2
- package/lib/page_header/index.less_inline.js +4 -0
- package/lib/pagination/index.js +214 -2
- package/lib/pagination/index.less_inline.js +4 -0
- package/lib/polygon/index.js +21 -2
- package/lib/{polygon-DhhovlrG.js → polygon/index.less_inline.js} +2 -18
- package/lib/qrcode/index.js +65 -2
- package/lib/qrcode/index.less_inline.js +4 -0
- package/lib/select/index.js +355 -3
- package/lib/select/index.less_inline.js +4 -0
- package/lib/select_ori/index.js +58 -2
- package/lib/select_ori/index.less_inline.js +4 -0
- package/lib/space/index.js +40 -2
- package/lib/space/index.less_inline.js +4 -0
- package/lib/{animation-Bo4jbSGK.js → styles/animation/index.css_inline.js} +2 -3
- package/lib/styles/animation/index.js +8 -2
- package/lib/{mask-Ox6CoyFB.js → styles/mask/index.css_inline.js} +2 -3
- package/lib/styles/mask/index.js +8 -2
- package/lib/switch/index.js +51 -2
- package/lib/switch/index.less_inline.js +4 -0
- package/lib/tabbar/index.js +97 -2
- package/lib/tabbar/index.less_inline.js +4 -0
- package/lib/tabbar/item.js +61 -2
- package/lib/tabbar/item.less_inline.js +4 -0
- package/lib/table/index.js +234 -2
- package/lib/table/index.less_inline.js +4 -0
- package/lib/tabs/index.js +1 -1
- package/lib/tag/index.js +75 -2
- package/lib/tag/index.less_inline.js +4 -0
- package/lib/theme/index.js +86 -2
- package/lib/theme/index.less_inline.js +4 -0
- package/lib/theme/theme_color.js +1 -1
- package/lib/upload/index.d.ts +170 -0
- package/lib/upload/index.js +848 -0
- package/lib/upload/index.less_inline.js +4 -0
- package/lib/upload/style.d.ts +2 -0
- package/lib/upload/style.js +8 -0
- package/lib/utils/context_provide.d.ts +1 -0
- package/lib/utils/context_provide.js +1 -1
- package/lib/utils/event.d.ts +30 -0
- package/lib/utils/index.d.ts +3 -0
- package/lib/utils/index.js +1 -1
- package/lib/utils/popover.js +1 -1
- package/lib/utils/signal_types.d.ts +5 -0
- package/lib/utils/transition.d.ts +28 -0
- package/lib/utils/transition.js +1 -1
- package/package.json +39 -18
- package/styles/animation.css +2 -2
- package/styles/container.css +8 -8
- package/styles/dark.css +21 -1
- package/styles/datepicker.css +9 -9
- package/styles/dialog.css +7 -7
- package/styles/loading.css +17 -17
- package/styles/message.css +9 -9
- package/styles/modal_box.css +3 -3
- package/styles/notification.css +17 -0
- package/styles/popover.css +11 -14
- package/styles/reset.css +13 -15
- package/styles/scrollbar.css +5 -5
- package/styles/select.css +6 -6
- package/styles/tabs.css +3 -3
- package/styles/theme-coral.css +35 -0
- package/styles/theme-jade.css +35 -0
- package/styles/theme-tangerine.css +35 -0
- package/styles/transition.css +1 -1
- package/styles/vars.css +7 -7
- package/lib/calendar-CvlUsN6w.js +0 -146
- package/lib/card-3DM-lJQV.js +0 -63
- package/lib/carousel-DvkZ1YXq.js +0 -276
- package/lib/check-doQ2ZpQj.js +0 -117
- package/lib/collapse-B6-Rn05A.js +0 -102
- package/lib/color_picker-0a-IGZY9.js +0 -41
- package/lib/date_picker-BDN2PAz5.js +0 -99
- package/lib/date_picker_ori-BXFs1eET.js +0 -120
- package/lib/description_panel--AKXBzLL.js +0 -53
- package/lib/esm-DAha108i.js +0 -270
- package/lib/form-DJxvBiLy.js +0 -190
- package/lib/form_item-BqPMRABd.js +0 -147
- package/lib/image-CVQai6NX.js +0 -162
- package/lib/image_preview-DfQAKSJH.js +0 -90
- package/lib/item-CQ2Sknbz.js +0 -14
- package/lib/item-DI6mQXtB.js +0 -117
- package/lib/item-D_ZOPXuE.js +0 -60
- package/lib/list-MG8PRzos.js +0 -51
- package/lib/mask-Bx-yNIJv.js +0 -108
- package/lib/md_input-BX3bujz8.js +0 -58
- package/lib/menu-DKscK5mw.js +0 -274
- package/lib/modal-Cwi3qlEf.js +0 -198
- package/lib/page_header-ujV3pncE.js +0 -99
- package/lib/pagination-aRbGd3Rf.js +0 -213
- package/lib/qrcode-Dip8uLSA.js +0 -64
- package/lib/select-BZMDj5VE.js +0 -354
- package/lib/select_ori-C7sUZxen.js +0 -57
- package/lib/space-CKuTk0YB.js +0 -39
- package/lib/switch-wh2-ivty.js +0 -50
- package/lib/tabbar-CBXK-_AV.js +0 -96
- package/lib/table-BQxMD2Ae.js +0 -233
- package/lib/tag-Di1z9PoZ.js +0 -74
- package/lib/theme-CLbBS-in.js +0 -85
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region src/components/modal/index.less?inline
|
|
2
|
+
var e = ":host{display:none}:host(.open){display:block}.l-modal-mask{z-index:var(--l-modal-zindex,100)}.l-modal-wrapper{width:100%;height:100%;z-index:calc(var(--l-modal-zindex,100) + 1);position:fixed;top:0;left:0}.l-modal{--l-modal-translate:translate3d(0, 80px, 0);border-radius:var(--l-modal-border-radius,5px);width:var(--l-modal-width,27%);opacity:1;transform:var(--l-modal-translate) scale3d(1, 1, 1);background-color:#fff;margin:auto;transition:opacity .3s,transform .3s;position:relative;box-shadow:0 0 8px #0000001a}.l-modal-header{padding:var(--l-modal-header-padding,10px);border-bottom:1px solid var(--l-modal-line-color,#0000000f);align-items:center;gap:5px;font-size:16px;font-weight:600;display:flex}.l-modal-footer{padding:var(--l-modal-footer-padding,10px);border-top:1px solid var(--l-modal-line-color,#0000000f);justify-content:flex-end;gap:10px;display:flex}.l-modal-container{padding:var(--l-modal-container-padding,15px 10px);font-size:14px}.l-btn-modal-close{--l-form-control-height:auto;position:absolute}.l-modal-close1{top:8px;right:5px}.l-modal-close1::part(default){border:none;width:auto;height:auto;padding:5px;font-size:16px}.l-modal-close2{top:-10px;right:-10px}.l-modal-close2::part(default){background-color:#fff;width:20px;height:20px;padding:0}.mask-transition-enter-from,.mask-transition-leave-to{opacity:0}.modal-transition-enter-from,.modal-transition-leave-to{transform:translate(0,0)scale3d(0,0,0)}.l-modal--mobile{border-radius:10px}.l-modal--mobile .l-modal-header{text-align:center;border-bottom-color:#0000;justify-content:center;padding:20px 10px 5px;display:flex}.l-modal--mobile .l-modal-container{--l-modal-container-padding:5px 15px 20px;text-align:center}.l-modal--mobile .l-modal-footer{text-align:center;justify-content:stretch;align-items:stretch;gap:0;height:50px;padding:0;display:flex}.l-modal--mobile .l-modal-footer-btn{flex-grow:1;height:100%}.l-modal--mobile .l-modal-footer-btn+.l-modal-footer-btn{border-left:1px solid var(--l-modal-line-color,#0000000f)}.l-modal--middle{--l-modal-translate:translate3d(0, -50%, 0);top:50%}.l-modal--bottom{--l-modal-translate:translate3d(0, -100%, 0);border-bottom-right-radius:0;border-bottom-left-radius:0;width:100%;top:100%}@media screen and (width<=768px){:host{--l-modal-width:80%}}";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { e as default };
|
package/lib/modal/modal_box.js
CHANGED
|
@@ -2,10 +2,10 @@ import { regist as e } from "../utils/index.js";
|
|
|
2
2
|
import t from "../icon/info.js";
|
|
3
3
|
import n from "../button/index.js";
|
|
4
4
|
import r from "../icon/close.js";
|
|
5
|
-
import
|
|
5
|
+
import i from "../form/form_item.js";
|
|
6
6
|
import a from "../input/index.js";
|
|
7
|
-
import
|
|
8
|
-
import { $$ as s, $one as c, on as l } from "
|
|
7
|
+
import o from "./index.js";
|
|
8
|
+
import { $$ as s, $one as c, on as l } from "utilane/browser";
|
|
9
9
|
//#region src/components/modal/modal_box.ts
|
|
10
10
|
function u(e, t, n, r = "alert") {
|
|
11
11
|
return new Promise((i) => {
|
|
@@ -34,27 +34,26 @@ function u(e, t, n, r = "alert") {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
function d(t, i, a) {
|
|
37
|
-
|
|
37
|
+
e([
|
|
38
|
+
r,
|
|
38
39
|
n,
|
|
39
|
-
o
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return u(i || "提示", t, n, "alert");
|
|
50
|
-
});
|
|
40
|
+
o
|
|
41
|
+
]);
|
|
42
|
+
let s = {
|
|
43
|
+
showCancel: !1,
|
|
44
|
+
close: 0,
|
|
45
|
+
maskClosable: !1,
|
|
46
|
+
icon: void 0,
|
|
47
|
+
...a
|
|
48
|
+
};
|
|
49
|
+
return u(i || "提示", t, s, "alert").then((e) => e === !0);
|
|
51
50
|
}
|
|
52
51
|
function f(i, a, c) {
|
|
53
52
|
e([
|
|
54
|
-
n,
|
|
55
|
-
o,
|
|
56
53
|
r,
|
|
57
|
-
t
|
|
54
|
+
t,
|
|
55
|
+
n,
|
|
56
|
+
o
|
|
58
57
|
]);
|
|
59
58
|
let l = {
|
|
60
59
|
showCancel: !0,
|
|
@@ -67,12 +66,12 @@ function f(i, a, c) {
|
|
|
67
66
|
}
|
|
68
67
|
function p(s, c, l) {
|
|
69
68
|
e([
|
|
70
|
-
n,
|
|
71
|
-
o,
|
|
72
69
|
r,
|
|
73
70
|
t,
|
|
74
71
|
i,
|
|
75
|
-
a
|
|
72
|
+
a,
|
|
73
|
+
n,
|
|
74
|
+
o
|
|
76
75
|
]);
|
|
77
76
|
let d = {
|
|
78
77
|
showCancel: !0,
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import BaseComponent from "../base";
|
|
2
|
+
import type { NotificationPlacement } from "./placement";
|
|
3
|
+
export type { NotificationPlacement };
|
|
4
|
+
/** 通知状态类型 */
|
|
5
|
+
export type NotificationType = "info" | "success" | "error" | "warning";
|
|
6
|
+
/** 命令式调用配置 */
|
|
7
|
+
export interface NotificationOptions {
|
|
8
|
+
/** 自定义通知 id, 不传则自动生成 */
|
|
9
|
+
id?: string;
|
|
10
|
+
/** 标题 */
|
|
11
|
+
title?: string;
|
|
12
|
+
/** 消息内容, 支持 HTML 字符串 */
|
|
13
|
+
message?: string;
|
|
14
|
+
/** 状态类型, 默认: `info` */
|
|
15
|
+
type?: NotificationType;
|
|
16
|
+
/** 显示方位, 默认: `topRight` */
|
|
17
|
+
placement?: NotificationPlacement;
|
|
18
|
+
/** 自动关闭时间(毫秒), 设置为 `0` 时不自动关闭, 默认: `4500` */
|
|
19
|
+
duration?: number;
|
|
20
|
+
/** 是否显示关闭按钮, 默认: `true` */
|
|
21
|
+
closable?: boolean;
|
|
22
|
+
/** 是否显示状态图标, 默认: `true` */
|
|
23
|
+
showIcon?: boolean;
|
|
24
|
+
/** 通知宽度, 数字会自动转换为 `px` */
|
|
25
|
+
width?: string | number;
|
|
26
|
+
/** 距离视口边缘的距离(px), 默认: `16` */
|
|
27
|
+
offset?: number;
|
|
28
|
+
/** 层级, 默认: `2000` */
|
|
29
|
+
zIndex?: number;
|
|
30
|
+
/** 同一个方位最多同时显示的通知数量, `0` 表示不限制 */
|
|
31
|
+
maxCount?: number;
|
|
32
|
+
/** 行动点按钮文本, 用于给出用户下一步的操作 */
|
|
33
|
+
action?: string;
|
|
34
|
+
/** 自定义类名, 多个使用空格分隔 */
|
|
35
|
+
customClass?: string;
|
|
36
|
+
/** 关闭后的回调 */
|
|
37
|
+
onClose?: (id: string) => void;
|
|
38
|
+
/** 点击行动点的回调 */
|
|
39
|
+
onAction?: (id: string) => void;
|
|
40
|
+
}
|
|
41
|
+
type NotificationState = {
|
|
42
|
+
open: boolean;
|
|
43
|
+
type: NotificationType;
|
|
44
|
+
title: string;
|
|
45
|
+
message: string;
|
|
46
|
+
placement: NotificationPlacement;
|
|
47
|
+
duration: number;
|
|
48
|
+
closable: boolean;
|
|
49
|
+
showIcon: boolean;
|
|
50
|
+
width: string;
|
|
51
|
+
offset: number;
|
|
52
|
+
zIndex: number;
|
|
53
|
+
maxCount: number;
|
|
54
|
+
action: string;
|
|
55
|
+
customClass: string;
|
|
56
|
+
};
|
|
57
|
+
export default class Notification extends BaseComponent<NotificationState> {
|
|
58
|
+
static baseName: string;
|
|
59
|
+
/** 关闭后是否从文档中移除, 命令式 API 创建的通知为 `true` */
|
|
60
|
+
removeOnClose: boolean;
|
|
61
|
+
/** 当前是否显示 */
|
|
62
|
+
private _visible;
|
|
63
|
+
/** 自动关闭定时器 */
|
|
64
|
+
private _timer?;
|
|
65
|
+
/** 定时器开始时间 */
|
|
66
|
+
private _startTime;
|
|
67
|
+
/** 剩余自动关闭时间 */
|
|
68
|
+
private _remaining;
|
|
69
|
+
/** 已经应用到宿主节点上的自定义类名 */
|
|
70
|
+
private _appliedClasses;
|
|
71
|
+
/** 取消当前进行中的动画 */
|
|
72
|
+
private _cancelAnimation?;
|
|
73
|
+
/** 监听内容尺寸变化, 尺寸变化时重新排布 */
|
|
74
|
+
private _resizeObserver?;
|
|
75
|
+
private $icon?;
|
|
76
|
+
private $title?;
|
|
77
|
+
private $titleText?;
|
|
78
|
+
private $message?;
|
|
79
|
+
private $messageText?;
|
|
80
|
+
private $actionWrap?;
|
|
81
|
+
private $actionBtn?;
|
|
82
|
+
private $actionSlot?;
|
|
83
|
+
private $closeBtn?;
|
|
84
|
+
constructor();
|
|
85
|
+
/** 距离视口边缘的距离(px) */
|
|
86
|
+
get notificationOffset(): number;
|
|
87
|
+
/** 与相邻通知的间距(px) */
|
|
88
|
+
get notificationGap(): number;
|
|
89
|
+
/** 当前显示方位 */
|
|
90
|
+
get placement(): NotificationPlacement;
|
|
91
|
+
get open(): boolean;
|
|
92
|
+
set open(value: boolean);
|
|
93
|
+
static get observedAttributes(): string[];
|
|
94
|
+
protected attributeChanged(name: string, _oldValue: string, newValue: string): void;
|
|
95
|
+
protected updateDOM(changedProps: Set<string>): void;
|
|
96
|
+
disconnectedCallback(): void;
|
|
97
|
+
render_v2(): {
|
|
98
|
+
styleSheets: CSSStyleSheet[];
|
|
99
|
+
template: HTMLElement;
|
|
100
|
+
};
|
|
101
|
+
afterInit(): void;
|
|
102
|
+
beforeDestroy(): void;
|
|
103
|
+
render(): HTMLElement;
|
|
104
|
+
/** 显示通知 */
|
|
105
|
+
show(): void;
|
|
106
|
+
/** 关闭通知 */
|
|
107
|
+
close(): void;
|
|
108
|
+
private _initRefs;
|
|
109
|
+
private _bindEvents;
|
|
110
|
+
private _unbindEvents;
|
|
111
|
+
private _syncAll;
|
|
112
|
+
/** 同步状态图标 */
|
|
113
|
+
private _syncIcon;
|
|
114
|
+
/** 同步标题与内容 */
|
|
115
|
+
private _syncSections;
|
|
116
|
+
/**
|
|
117
|
+
* 同步内容区域
|
|
118
|
+
* @param $wrap 区域节点
|
|
119
|
+
* @param $text 通过属性渲染的内容节点
|
|
120
|
+
* @param value 属性值
|
|
121
|
+
* @param asText 是否按照纯文本渲染, 否则按照 HTML 渲染
|
|
122
|
+
*/
|
|
123
|
+
private _syncSection;
|
|
124
|
+
/** 同步行动点 */
|
|
125
|
+
private _syncActions;
|
|
126
|
+
/** 同步关闭按钮 */
|
|
127
|
+
private _syncClose;
|
|
128
|
+
/** 同步宽度 */
|
|
129
|
+
private _syncWidth;
|
|
130
|
+
/** 同步偏移与层级 */
|
|
131
|
+
private _syncOffset;
|
|
132
|
+
/** 同步自定义类名 */
|
|
133
|
+
private _syncCustomClass;
|
|
134
|
+
/** 插槽中是否存在有效内容(忽略空白文本) */
|
|
135
|
+
private _hasSlotContent;
|
|
136
|
+
/** 方位变化时重新排布 */
|
|
137
|
+
private _updatePlacement;
|
|
138
|
+
private _toggleOpen;
|
|
139
|
+
private _show;
|
|
140
|
+
private _hide;
|
|
141
|
+
/** 超出同一方位的最大数量时, 关闭最早的通知 */
|
|
142
|
+
private _enforceMaxCount;
|
|
143
|
+
/**
|
|
144
|
+
* 入场动画
|
|
145
|
+
*
|
|
146
|
+
* 先应用起始状态(此时还没有过渡), 再开启过渡并移除起始状态,
|
|
147
|
+
* 避免从已显示状态反向过渡。
|
|
148
|
+
*/
|
|
149
|
+
private _enter;
|
|
150
|
+
/** 离场动画 */
|
|
151
|
+
private _leave;
|
|
152
|
+
/** 过渡时长(毫秒) */
|
|
153
|
+
private _transitionDuration;
|
|
154
|
+
/** 监听指定属性的过渡结束, 同时提供兜底处理 */
|
|
155
|
+
private _onceTransitionEnd;
|
|
156
|
+
private _cancelPendingAnimation;
|
|
157
|
+
/** 内容尺寸变化时重新排布 */
|
|
158
|
+
private _observeSize;
|
|
159
|
+
private _unobserveSize;
|
|
160
|
+
private _startTimer;
|
|
161
|
+
private _clearTimer;
|
|
162
|
+
/** 鼠标悬浮时暂停自动关闭 */
|
|
163
|
+
private _pauseTimer;
|
|
164
|
+
/** 鼠标移出时继续自动关闭 */
|
|
165
|
+
private _resumeTimer;
|
|
166
|
+
private _handleMouseEnter;
|
|
167
|
+
private _handleMouseLeave;
|
|
168
|
+
private _handleCloseClick;
|
|
169
|
+
private _handleActionClick;
|
|
170
|
+
private _handleSlotChange;
|
|
171
|
+
}
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import e from "../base.js";
|
|
2
|
+
import { kebabToCamel as t, parseAttrValue as n, unitNumberStr as r } from "../utils/index.js";
|
|
3
|
+
import { DEFAULT_ZINDEX as i, getGroupSize as a, getOldestNotification as o, layoutGroup as s, normalizePlacement as c, registerNotification as l, unregisterNotification as u } from "./placement.js";
|
|
4
|
+
import d from "./style.js";
|
|
5
|
+
import { $$ as f, $one as p, off as m, on as h } from "utilane/browser";
|
|
6
|
+
//#region src/components/notification/index.ts
|
|
7
|
+
var g = {
|
|
8
|
+
info: "info",
|
|
9
|
+
success: "success",
|
|
10
|
+
error: "close-filled",
|
|
11
|
+
warning: "warn"
|
|
12
|
+
}, _ = class extends e {
|
|
13
|
+
static baseName = "notification";
|
|
14
|
+
removeOnClose = !1;
|
|
15
|
+
_visible = !1;
|
|
16
|
+
_timer;
|
|
17
|
+
_startTime = 0;
|
|
18
|
+
_remaining = 0;
|
|
19
|
+
_appliedClasses = [];
|
|
20
|
+
_cancelAnimation;
|
|
21
|
+
_resizeObserver;
|
|
22
|
+
$icon;
|
|
23
|
+
$title;
|
|
24
|
+
$titleText;
|
|
25
|
+
$message;
|
|
26
|
+
$messageText;
|
|
27
|
+
$actionWrap;
|
|
28
|
+
$actionBtn;
|
|
29
|
+
$actionSlot;
|
|
30
|
+
$closeBtn;
|
|
31
|
+
constructor() {
|
|
32
|
+
super(), this.version = 2, this._state = {
|
|
33
|
+
open: !1,
|
|
34
|
+
type: "info",
|
|
35
|
+
title: "",
|
|
36
|
+
message: "",
|
|
37
|
+
placement: "topRight",
|
|
38
|
+
duration: 0,
|
|
39
|
+
closable: !0,
|
|
40
|
+
showIcon: !0,
|
|
41
|
+
width: "",
|
|
42
|
+
offset: 16,
|
|
43
|
+
zIndex: i,
|
|
44
|
+
maxCount: 0,
|
|
45
|
+
action: "",
|
|
46
|
+
customClass: ""
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
get notificationOffset() {
|
|
50
|
+
return this._state.offset;
|
|
51
|
+
}
|
|
52
|
+
get notificationGap() {
|
|
53
|
+
let e = parseFloat(getComputedStyle(this).getPropertyValue("--l-notification-gap"));
|
|
54
|
+
return Number.isFinite(e) ? e : 16;
|
|
55
|
+
}
|
|
56
|
+
get placement() {
|
|
57
|
+
return this._state.placement;
|
|
58
|
+
}
|
|
59
|
+
get open() {
|
|
60
|
+
return this._state.open;
|
|
61
|
+
}
|
|
62
|
+
set open(e) {
|
|
63
|
+
e ? this.show() : this.close();
|
|
64
|
+
}
|
|
65
|
+
static get observedAttributes() {
|
|
66
|
+
return [
|
|
67
|
+
"open",
|
|
68
|
+
"type",
|
|
69
|
+
"title",
|
|
70
|
+
"message",
|
|
71
|
+
"placement",
|
|
72
|
+
"duration",
|
|
73
|
+
"closable",
|
|
74
|
+
"show-icon",
|
|
75
|
+
"width",
|
|
76
|
+
"offset",
|
|
77
|
+
"z-index",
|
|
78
|
+
"max-count",
|
|
79
|
+
"action",
|
|
80
|
+
"custom-class"
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
attributeChanged(e, i, a) {
|
|
84
|
+
switch (e) {
|
|
85
|
+
case "type":
|
|
86
|
+
this._state.type = a || "info";
|
|
87
|
+
break;
|
|
88
|
+
case "title":
|
|
89
|
+
this._state.title = a || "";
|
|
90
|
+
break;
|
|
91
|
+
case "message":
|
|
92
|
+
this._state.message = a || "";
|
|
93
|
+
break;
|
|
94
|
+
case "action":
|
|
95
|
+
this._state.action = a || "";
|
|
96
|
+
break;
|
|
97
|
+
case "custom-class":
|
|
98
|
+
this._state.customClass = a || "";
|
|
99
|
+
break;
|
|
100
|
+
case "placement":
|
|
101
|
+
this._state.placement = c(a);
|
|
102
|
+
break;
|
|
103
|
+
case "width":
|
|
104
|
+
this._state.width = r(a) || "";
|
|
105
|
+
break;
|
|
106
|
+
case "duration":
|
|
107
|
+
case "offset":
|
|
108
|
+
case "z-index":
|
|
109
|
+
case "max-count":
|
|
110
|
+
this._state[t(e)] = Number(a) || 0;
|
|
111
|
+
break;
|
|
112
|
+
case "open":
|
|
113
|
+
case "closable":
|
|
114
|
+
case "show-icon": this._state[t(e)] = n(a, !1, e);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
updateDOM(e) {
|
|
118
|
+
(e.has("type") || e.has("show-icon")) && this._syncIcon(), (e.has("title") || e.has("message")) && this._syncSections(), e.has("action") && this._syncActions(), e.has("closable") && this._syncClose(), e.has("width") && this._syncWidth(), e.has("custom-class") && this._syncCustomClass(), (e.has("offset") || e.has("z-index")) && this._syncOffset(), e.has("placement") && this._updatePlacement(), e.has("duration") && this._visible && this._startTimer(), e.has("open") && this._toggleOpen();
|
|
119
|
+
}
|
|
120
|
+
disconnectedCallback() {
|
|
121
|
+
super.disconnectedCallback(), u(this), this._cancelPendingAnimation(), this._unobserveSize(), this._clearTimer(), this._visible = !1;
|
|
122
|
+
}
|
|
123
|
+
render_v2() {
|
|
124
|
+
return this._changedProperties.clear(), {
|
|
125
|
+
styleSheets: [d],
|
|
126
|
+
template: this.render()
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
afterInit() {
|
|
130
|
+
this._initRefs(), this._bindEvents(), this._syncAll(), this._state.open ? this._visible ? this._startTimer() : this._show() : (this._visible = !1, this.setAttribute("hidden", ""));
|
|
131
|
+
}
|
|
132
|
+
beforeDestroy() {
|
|
133
|
+
this._unbindEvents();
|
|
134
|
+
}
|
|
135
|
+
render() {
|
|
136
|
+
let e = f("div", {
|
|
137
|
+
class: "l-notification",
|
|
138
|
+
part: "default"
|
|
139
|
+
});
|
|
140
|
+
e.appendChild(f("div", {
|
|
141
|
+
class: "l-notification-icon",
|
|
142
|
+
part: "icon"
|
|
143
|
+
}));
|
|
144
|
+
let t = f("div", { class: "l-notification-content" });
|
|
145
|
+
return t.innerHTML = [
|
|
146
|
+
"<div class=\"l-notification-title\" part=\"title\">",
|
|
147
|
+
"<span class=\"l-notification-title-text\"></span>",
|
|
148
|
+
"<slot name=\"title\"></slot>",
|
|
149
|
+
"</div>",
|
|
150
|
+
"<div class=\"l-notification-message\" part=\"message\">",
|
|
151
|
+
"<span class=\"l-notification-message-text\"></span>",
|
|
152
|
+
"<slot></slot>",
|
|
153
|
+
"</div>",
|
|
154
|
+
"<div class=\"l-notification-actions\" part=\"actions\">",
|
|
155
|
+
"<button type=\"button\" class=\"l-notification-action\" part=\"action\"></button>",
|
|
156
|
+
"<slot name=\"action\"></slot>",
|
|
157
|
+
"</div>"
|
|
158
|
+
].join(""), e.appendChild(t), e.appendChild(f("button", {
|
|
159
|
+
class: "l-notification-close",
|
|
160
|
+
part: "close",
|
|
161
|
+
type: "button",
|
|
162
|
+
"aria-label": "关闭",
|
|
163
|
+
innerHTML: "<l-close-icon></l-close-icon>"
|
|
164
|
+
})), e;
|
|
165
|
+
}
|
|
166
|
+
show() {
|
|
167
|
+
this._state.open = !0, this._toggleOpen();
|
|
168
|
+
}
|
|
169
|
+
close() {
|
|
170
|
+
this._state.open = !1, this._toggleOpen();
|
|
171
|
+
}
|
|
172
|
+
_initRefs() {
|
|
173
|
+
let e = this.root;
|
|
174
|
+
this.$icon = p(".l-notification-icon", e), this.$title = p(".l-notification-title", e), this.$titleText = p(".l-notification-title-text", e), this.$message = p(".l-notification-message", e), this.$messageText = p(".l-notification-message-text", e), this.$actionWrap = p(".l-notification-actions", e), this.$actionBtn = p(".l-notification-action", e), this.$actionSlot = p("slot[name=\"action\"]", e), this.$closeBtn = p(".l-notification-close", e);
|
|
175
|
+
}
|
|
176
|
+
_bindEvents() {
|
|
177
|
+
h(this, "mouseenter", this._handleMouseEnter), h(this, "mouseleave", this._handleMouseLeave), this.$closeBtn && h(this.$closeBtn, "click", this._handleCloseClick), this.$actionBtn && h(this.$actionBtn, "click", this._handleActionClick), this.root.querySelectorAll("slot").forEach((e) => {
|
|
178
|
+
h(e, "slotchange", this._handleSlotChange);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
_unbindEvents() {
|
|
182
|
+
m(this, "mouseenter", this._handleMouseEnter), m(this, "mouseleave", this._handleMouseLeave), this.$closeBtn && m(this.$closeBtn, "click", this._handleCloseClick), this.$actionBtn && m(this.$actionBtn, "click", this._handleActionClick), this.root.querySelectorAll("slot").forEach((e) => {
|
|
183
|
+
m(e, "slotchange", this._handleSlotChange);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
_syncAll() {
|
|
187
|
+
this._syncIcon(), this._syncSections(), this._syncActions(), this._syncClose(), this._syncWidth(), this._syncOffset(), this._syncCustomClass();
|
|
188
|
+
}
|
|
189
|
+
_syncIcon() {
|
|
190
|
+
let e = this.$icon;
|
|
191
|
+
if (!e) return;
|
|
192
|
+
let t = g[this._state.type] || g.info;
|
|
193
|
+
e.dataset.icon !== t && (e.dataset.icon = t, e.innerHTML = `<l-${t}-icon></l-${t}-icon>`), e.toggleAttribute("hidden", !this._state.showIcon);
|
|
194
|
+
}
|
|
195
|
+
_syncSections() {
|
|
196
|
+
this._syncSection(this.$title, this.$titleText, this._state.title, !0), this._syncSection(this.$message, this.$messageText, this._state.message, !1);
|
|
197
|
+
}
|
|
198
|
+
_syncSection(e, t, n = "", r = !1) {
|
|
199
|
+
if (!e || !t) return;
|
|
200
|
+
r ? t.textContent = n : t.innerHTML = n;
|
|
201
|
+
let i = e.querySelector("slot"), a = this._hasSlotContent(i), o = n !== "";
|
|
202
|
+
t.toggleAttribute("hidden", a || !o), e.toggleAttribute("hidden", !(a || o));
|
|
203
|
+
}
|
|
204
|
+
_syncActions() {
|
|
205
|
+
let e = this.$actionWrap, t = this.$actionBtn;
|
|
206
|
+
if (!e || !t) return;
|
|
207
|
+
let n = this._state.action;
|
|
208
|
+
t.textContent = n;
|
|
209
|
+
let r = this._hasSlotContent(this.$actionSlot);
|
|
210
|
+
t.toggleAttribute("hidden", r || n === ""), e.toggleAttribute("hidden", !(r || n !== ""));
|
|
211
|
+
}
|
|
212
|
+
_syncClose() {
|
|
213
|
+
this.$closeBtn && this.$closeBtn.toggleAttribute("hidden", !this._state.closable);
|
|
214
|
+
}
|
|
215
|
+
_syncWidth() {
|
|
216
|
+
this._state.width ? this.style.setProperty("--l-notification-width", this._state.width) : this.style.removeProperty("--l-notification-width");
|
|
217
|
+
}
|
|
218
|
+
_syncOffset() {
|
|
219
|
+
this.style.setProperty("--l-notification-offset", `${this._state.offset}px`), this.style.setProperty("--l-notification-zindex", `${this._state.zIndex}`), this._visible && s(this._state.placement);
|
|
220
|
+
}
|
|
221
|
+
_syncCustomClass() {
|
|
222
|
+
for (let e of this._appliedClasses) this.classList.remove(e);
|
|
223
|
+
this._appliedClasses = this._state.customClass ? this._state.customClass.split(/\s+/).filter(Boolean) : [];
|
|
224
|
+
for (let e of this._appliedClasses) this.classList.add(e);
|
|
225
|
+
}
|
|
226
|
+
_hasSlotContent(e) {
|
|
227
|
+
return e ? e.assignedNodes().some((e) => e.nodeType !== 3 || (e.textContent || "").trim() !== "") : !1;
|
|
228
|
+
}
|
|
229
|
+
_updatePlacement() {
|
|
230
|
+
this._visible && l(this, this._state.placement);
|
|
231
|
+
}
|
|
232
|
+
_toggleOpen() {
|
|
233
|
+
this.rendered && (this._state.open ? this._show() : this._hide());
|
|
234
|
+
}
|
|
235
|
+
_show() {
|
|
236
|
+
this._visible || (this._visible = !0, this.removeAttribute("hidden"), l(this, this._state.placement), this._observeSize(), this._enter(), this._startTimer(), this._enforceMaxCount());
|
|
237
|
+
}
|
|
238
|
+
_hide() {
|
|
239
|
+
this._visible && (this._visible = !1, this._clearTimer(), this._unobserveSize(), u(this), this.emit("close", { detail: { id: this.id } }), this._leave(() => {
|
|
240
|
+
this.removeOnClose ? this.remove() : this.setAttribute("hidden", "");
|
|
241
|
+
}));
|
|
242
|
+
}
|
|
243
|
+
_enforceMaxCount() {
|
|
244
|
+
let e = this._state.maxCount;
|
|
245
|
+
if (e <= 0) return;
|
|
246
|
+
let t = this._state.placement;
|
|
247
|
+
for (; a(t) > e;) {
|
|
248
|
+
let e = o(t);
|
|
249
|
+
if (!e || e === this) break;
|
|
250
|
+
e.close();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
_enter() {
|
|
254
|
+
this.classList.add("l-notification-enter"), this.offsetHeight, this.classList.add("l-notification-enter-active"), this.classList.remove("l-notification-enter"), this._onceTransitionEnd("opacity", () => {
|
|
255
|
+
this.classList.remove("l-notification-enter-active");
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
_leave(e) {
|
|
259
|
+
this.classList.add("l-notification-leave-active"), this.offsetHeight, this.classList.add("l-notification-leave"), this._onceTransitionEnd("opacity", () => {
|
|
260
|
+
this.classList.remove("l-notification-leave-active"), this.classList.remove("l-notification-leave"), e();
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
_transitionDuration() {
|
|
264
|
+
let e = (getComputedStyle(this).transitionDuration || "").split(",")[0].trim(), t = parseFloat(e);
|
|
265
|
+
return t ? e.endsWith("ms") ? t : t * 1e3 : 300;
|
|
266
|
+
}
|
|
267
|
+
_onceTransitionEnd(e, t) {
|
|
268
|
+
this._cancelPendingAnimation();
|
|
269
|
+
let n = !1, r = 0, i = (t) => {
|
|
270
|
+
let n = t;
|
|
271
|
+
n.target === this && n.propertyName === e && a();
|
|
272
|
+
}, a = () => {
|
|
273
|
+
n || (n = !0, this.removeEventListener("transitionend", i), clearTimeout(r), this._cancelAnimation = void 0, t());
|
|
274
|
+
};
|
|
275
|
+
this._cancelAnimation = () => {
|
|
276
|
+
n = !0, this.removeEventListener("transitionend", i), clearTimeout(r), this._cancelAnimation = void 0;
|
|
277
|
+
}, this.addEventListener("transitionend", i), r = window.setTimeout(a, this._transitionDuration() + 100);
|
|
278
|
+
}
|
|
279
|
+
_cancelPendingAnimation() {
|
|
280
|
+
let e = this._cancelAnimation;
|
|
281
|
+
e && (this._cancelAnimation = void 0, e());
|
|
282
|
+
}
|
|
283
|
+
_observeSize() {
|
|
284
|
+
this._resizeObserver || typeof ResizeObserver > "u" || (this._resizeObserver = new ResizeObserver(() => {
|
|
285
|
+
this._visible && s(this._state.placement);
|
|
286
|
+
}), this._resizeObserver.observe(this));
|
|
287
|
+
}
|
|
288
|
+
_unobserveSize() {
|
|
289
|
+
this._resizeObserver &&= (this._resizeObserver.disconnect(), void 0);
|
|
290
|
+
}
|
|
291
|
+
_startTimer() {
|
|
292
|
+
this._clearTimer();
|
|
293
|
+
let e = this._state.duration;
|
|
294
|
+
e <= 0 || (this._remaining = e, this._startTime = Date.now(), this._timer = window.setTimeout(() => {
|
|
295
|
+
this._timer = void 0, this.close();
|
|
296
|
+
}, e));
|
|
297
|
+
}
|
|
298
|
+
_clearTimer() {
|
|
299
|
+
this._timer != null && (clearTimeout(this._timer), this._timer = void 0), this._remaining = 0;
|
|
300
|
+
}
|
|
301
|
+
_pauseTimer() {
|
|
302
|
+
this._timer != null && (clearTimeout(this._timer), this._timer = void 0, this._remaining = Math.max(0, this._remaining - (Date.now() - this._startTime)));
|
|
303
|
+
}
|
|
304
|
+
_resumeTimer() {
|
|
305
|
+
this._timer != null || this._remaining <= 0 || (this._startTime = Date.now(), this._timer = window.setTimeout(() => {
|
|
306
|
+
this._timer = void 0, this.close();
|
|
307
|
+
}, this._remaining));
|
|
308
|
+
}
|
|
309
|
+
_handleMouseEnter = () => {
|
|
310
|
+
this._pauseTimer();
|
|
311
|
+
};
|
|
312
|
+
_handleMouseLeave = () => {
|
|
313
|
+
this._resumeTimer();
|
|
314
|
+
};
|
|
315
|
+
_handleCloseClick = (e) => {
|
|
316
|
+
e.stopPropagation(), this.close();
|
|
317
|
+
};
|
|
318
|
+
_handleActionClick = () => {
|
|
319
|
+
this.emit("action", { detail: { id: this.id } });
|
|
320
|
+
};
|
|
321
|
+
_handleSlotChange = () => {
|
|
322
|
+
this._syncSections(), this._syncActions();
|
|
323
|
+
};
|
|
324
|
+
};
|
|
325
|
+
//#endregion
|
|
326
|
+
export { _ as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region src/components/notification/index.less?inline
|
|
2
|
+
var e = ":host{--l-notification-width:330px;--l-notification-gap:16px;--l-notification-offset:16px;--l-notification-zindex:2000;--l-notification-padding:16px;--l-notification-radius:8px;--l-notification-background:#fff;--l-notification-shadow:0 6px 16px 0 #00000014, 0 3px 6px -4px #0000001f, 0 9px 28px 8px #0000000d;--l-notification-title-color:#000000e0;--l-notification-message-color:#000000a6;--l-notification-icon-size:22px;--l-notification-anim-duration:.3s;--l-notification-enter-offset:-20px;--l-notification-color:var(--l-primary-color,#007bff);--l-notification-action-hover-background:#0000000a;--l-notification-close-hover-background:#0000000f;z-index:var(--l-notification-zindex,2000);width:var(--l-notification-width);box-sizing:border-box;max-width:calc(100vw - 32px);color:var(--l-notification-title-color);transition:top var(--l-notification-anim-duration) ease, bottom var(--l-notification-anim-duration) ease;font-size:14px;line-height:1.5715;position:fixed}:host([placement=topLeft]),:host([placement=bottomLeft]){left:var(--l-notification-offset,16px);right:auto}:host([placement=topRight]),:host([placement=bottomRight]){right:var(--l-notification-offset,16px);left:auto}:host([placement=bottomLeft]),:host([placement=bottomRight]){--l-notification-enter-offset:20px}:host([hidden]){display:none}:host([type=info]){--l-notification-color:var(--l-primary-color,#007bff)}:host([type=success]){--l-notification-color:var(--l-success-color,#52c41a)}:host([type=error]){--l-notification-color:var(--l-error-color,#f5222d)}:host([type=warning]){--l-notification-color:var(--l-warning-color,#faad14)}:host(.l-notification-enter),:host(.l-notification-leave){opacity:0;transform:translateY(var(--l-notification-enter-offset)) scale(.95)}:host(.l-notification-enter-active),:host(.l-notification-leave-active){transition:top var(--l-notification-anim-duration) ease, bottom var(--l-notification-anim-duration) ease, opacity var(--l-notification-anim-duration) ease, transform var(--l-notification-anim-duration) ease}.l-notification{padding:var(--l-notification-padding);background:var(--l-notification-background);border-radius:var(--l-notification-radius);box-shadow:var(--l-notification-shadow);border-left:4px solid var(--l-notification-color);box-sizing:border-box;align-items:flex-start;gap:10px;display:flex;position:relative}.l-notification-icon{height:calc(var(--l-notification-icon-size) * 1.4);font-size:var(--l-notification-icon-size);color:var(--l-notification-color);flex:none;justify-content:center;align-items:center;display:inline-flex}.l-notification-content{flex:1;min-width:0}.l-notification-title{color:var(--l-notification-title-color);word-break:break-word;margin-bottom:4px;font-size:16px;font-weight:500}.l-notification-message{color:var(--l-notification-message-color);word-break:break-word}.l-notification-message-text{display:block}.l-notification-actions{align-items:center;gap:8px;margin-top:12px;display:flex}.l-notification-action{border:1px solid var(--l-notification-color);border-radius:var(--l-border-radius,3px);height:28px;color:var(--l-notification-color);cursor:pointer;background:0 0;justify-content:center;align-items:center;padding:0 12px;font-size:14px;line-height:1;transition:opacity .3s,background-color .3s;display:inline-flex}.l-notification-action:hover{opacity:.8;background:var(--l-notification-action-hover-background)}.l-notification-close{width:22px;height:22px;color:var(--l-notification-message-color);cursor:pointer;background:0 0;border:none;border-radius:4px;flex:none;justify-content:center;align-items:center;margin-left:auto;padding:0;font-size:14px;transition:color .3s,background-color .3s;display:inline-flex}.l-notification-close:hover{color:var(--l-notification-title-color);background:var(--l-notification-close-hover-background)}.l-notification-title[hidden],.l-notification-message[hidden],.l-notification-actions[hidden],.l-notification-icon[hidden],.l-notification-close[hidden],.l-notification-title-text[hidden],.l-notification-message-text[hidden]{display:none}";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { e as default };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { NotificationOptions, NotificationType, NotificationPlacement } from "./index";
|
|
2
|
+
export type { NotificationOptions, NotificationType, NotificationPlacement } from "./index";
|
|
3
|
+
/**
|
|
4
|
+
* 设置全局默认配置, 之后创建的通知都会使用该配置
|
|
5
|
+
* @param option 配置项
|
|
6
|
+
*/
|
|
7
|
+
declare function configNotification(option: NotificationOptions): void;
|
|
8
|
+
/**
|
|
9
|
+
* 创建一条通知
|
|
10
|
+
* @param option 通知内容或配置项
|
|
11
|
+
* @param type 状态类型, 会覆盖配置项中的 `type`
|
|
12
|
+
* @returns 通知 id, 可以配合 `NotificationBox.close` 手动关闭
|
|
13
|
+
*/
|
|
14
|
+
declare function showNotification(option: string | NotificationOptions, type?: NotificationType): string;
|
|
15
|
+
/**
|
|
16
|
+
* 关闭指定 id 的通知
|
|
17
|
+
* @param id 通知 id
|
|
18
|
+
*/
|
|
19
|
+
declare function closeNotification(id: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* 关闭所有通知
|
|
22
|
+
* @param placement 只关闭指定方位的通知, 不传递则关闭所有方位
|
|
23
|
+
*/
|
|
24
|
+
declare function closeAllNotification(placement?: NotificationPlacement): void;
|
|
25
|
+
declare function info(option: string | NotificationOptions): string;
|
|
26
|
+
declare function success(option: string | NotificationOptions): string;
|
|
27
|
+
declare function error(option: string | NotificationOptions): string;
|
|
28
|
+
declare function warning(option: string | NotificationOptions): string;
|
|
29
|
+
declare const _default: {
|
|
30
|
+
show: typeof showNotification;
|
|
31
|
+
info: typeof info;
|
|
32
|
+
success: typeof success;
|
|
33
|
+
error: typeof error;
|
|
34
|
+
warning: typeof warning;
|
|
35
|
+
warn: typeof warning;
|
|
36
|
+
close: typeof closeNotification;
|
|
37
|
+
closeAll: typeof closeAllNotification;
|
|
38
|
+
config: typeof configNotification;
|
|
39
|
+
};
|
|
40
|
+
export default _default;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useId as e } from "../utils/index.js";
|
|
2
|
+
import { normalizePlacement as t } from "./placement.js";
|
|
3
|
+
import { on as n } from "utilane/browser";
|
|
4
|
+
//#region src/components/notification/notification_box.ts
|
|
5
|
+
var r = "l-notification", i = 4500, a = {};
|
|
6
|
+
function o(e) {
|
|
7
|
+
a = {
|
|
8
|
+
...a,
|
|
9
|
+
...e
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function s(o, s) {
|
|
13
|
+
if (!customElements.get(r)) throw Error("Register Notification before calling NotificationBox methods.");
|
|
14
|
+
let c = {
|
|
15
|
+
...a,
|
|
16
|
+
...typeof o == "string" ? { message: o } : o
|
|
17
|
+
};
|
|
18
|
+
s && (c.type = s);
|
|
19
|
+
let l = c.id || e(), u = t(c.placement), d = document.createElement(r);
|
|
20
|
+
return d.id = l, d.removeOnClose = !0, d.setAttribute("open", ""), d.setAttribute("type", c.type || "info"), d.setAttribute("placement", u), c.title != null && d.setAttribute("title", c.title), c.message != null && d.setAttribute("message", c.message), d.setAttribute("duration", `${c.duration ?? i}`), c.closable === !1 && d.setAttribute("closable", "false"), c.showIcon === !1 && d.setAttribute("show-icon", "false"), c.width != null && d.setAttribute("width", `${c.width}`), c.offset != null && d.setAttribute("offset", `${c.offset}`), c.zIndex != null && d.setAttribute("z-index", `${c.zIndex}`), c.maxCount != null && d.setAttribute("max-count", `${c.maxCount}`), c.action && d.setAttribute("action", c.action), c.customClass && d.setAttribute("custom-class", c.customClass), c.onClose && n(d, "close", () => c.onClose?.(l)), c.onAction && n(d, "action", () => c.onAction?.(l)), document.body.appendChild(d), l;
|
|
21
|
+
}
|
|
22
|
+
function c(e) {
|
|
23
|
+
let t = document.getElementById(e);
|
|
24
|
+
t && typeof t.close == "function" && t.close();
|
|
25
|
+
}
|
|
26
|
+
function l(e) {
|
|
27
|
+
let n = e ? [t(e)] : void 0, i = document.querySelectorAll(r);
|
|
28
|
+
for (let e of Array.from(i)) {
|
|
29
|
+
let t = e;
|
|
30
|
+
typeof t.close == "function" && (n && !n.includes(t.placement) || t.close());
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function u(e) {
|
|
34
|
+
return s(e, "info");
|
|
35
|
+
}
|
|
36
|
+
function d(e) {
|
|
37
|
+
return s(e, "success");
|
|
38
|
+
}
|
|
39
|
+
function f(e) {
|
|
40
|
+
return s(e, "error");
|
|
41
|
+
}
|
|
42
|
+
function p(e) {
|
|
43
|
+
return s(e, "warning");
|
|
44
|
+
}
|
|
45
|
+
var m = {
|
|
46
|
+
show: s,
|
|
47
|
+
info: u,
|
|
48
|
+
success: d,
|
|
49
|
+
error: f,
|
|
50
|
+
warning: p,
|
|
51
|
+
warn: p,
|
|
52
|
+
close: c,
|
|
53
|
+
closeAll: l,
|
|
54
|
+
config: o
|
|
55
|
+
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { m as default };
|