@wot-ui/ui 1.0.0 → 2.0.0-alpha.4
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 +134 -0
- package/attributes.json +1 -0
- package/changelog.md +63 -0
- package/common/AbortablePromise.ts +28 -0
- package/common/canvasHelper.ts +49 -0
- package/common/clickoutside.ts +25 -0
- package/common/event.ts +8 -0
- package/common/formatDate.ts +68 -0
- package/common/interceptor.ts +43 -0
- package/common/props.ts +53 -0
- package/common/util.ts +836 -0
- package/components/wd-action-sheet/index.scss +232 -0
- package/components/wd-action-sheet/types.ts +155 -0
- package/components/wd-action-sheet/wd-action-sheet.vue +176 -0
- package/components/wd-avatar/index.scss +150 -0
- package/components/wd-avatar/types.ts +98 -0
- package/components/wd-avatar/wd-avatar.vue +184 -0
- package/components/wd-avatar-group/index.scss +11 -0
- package/components/wd-avatar-group/types.ts +61 -0
- package/components/wd-avatar-group/wd-avatar-group.vue +115 -0
- package/components/wd-backtop/index.scss +67 -0
- package/components/wd-backtop/types.ts +66 -0
- package/components/wd-backtop/wd-backtop.vue +57 -0
- package/components/wd-badge/index.scss +116 -0
- package/components/wd-badge/types.ts +94 -0
- package/components/wd-badge/wd-badge.vue +78 -0
- package/components/wd-button/index.scss +436 -0
- package/components/wd-button/types.ts +204 -0
- package/components/wd-button/wd-button.vue +210 -0
- package/components/wd-calendar/index.scss +97 -0
- package/components/wd-calendar/types.ts +221 -0
- package/components/wd-calendar/wd-calendar.vue +339 -0
- package/components/wd-calendar-view/index.scss +41 -0
- package/components/wd-calendar-view/month/index.scss +144 -0
- package/components/wd-calendar-view/month/month.vue +389 -0
- package/components/wd-calendar-view/month/types.ts +70 -0
- package/components/wd-calendar-view/monthPanel/index.scss +84 -0
- package/components/wd-calendar-view/monthPanel/month-panel.vue +541 -0
- package/components/wd-calendar-view/monthPanel/types.ts +151 -0
- package/components/wd-calendar-view/types.ts +166 -0
- package/components/wd-calendar-view/utils.ts +318 -0
- package/components/wd-calendar-view/wd-calendar-view.vue +117 -0
- package/components/wd-calendar-view/year/index.scss +148 -0
- package/components/wd-calendar-view/year/types.ts +74 -0
- package/components/wd-calendar-view/year/year.vue +206 -0
- package/components/wd-calendar-view/yearPanel/index.scss +42 -0
- package/components/wd-calendar-view/yearPanel/types.ts +96 -0
- package/components/wd-calendar-view/yearPanel/year-panel.vue +249 -0
- package/components/wd-card/index.scss +104 -0
- package/components/wd-card/types.ts +47 -0
- package/components/wd-card/wd-card.vue +38 -0
- package/components/wd-cascader/index.scss +154 -0
- package/components/wd-cascader/types.ts +191 -0
- package/components/wd-cascader/wd-cascader.vue +589 -0
- package/components/wd-cell/index.scss +244 -0
- package/components/wd-cell/types.ts +205 -0
- package/components/wd-cell/wd-cell.vue +172 -0
- package/components/wd-cell-group/index.scss +53 -0
- package/components/wd-cell-group/types.ts +97 -0
- package/components/wd-cell-group/wd-cell-group.vue +48 -0
- package/components/wd-checkbox/index.scss +166 -0
- package/components/wd-checkbox/types.ts +118 -0
- package/components/wd-checkbox/wd-checkbox.vue +216 -0
- package/components/wd-checkbox-group/index.scss +5 -0
- package/components/wd-checkbox-group/types.ts +93 -0
- package/components/wd-checkbox-group/wd-checkbox-group.vue +148 -0
- package/components/wd-circle/index.scss +28 -0
- package/components/wd-circle/types.ts +54 -0
- package/components/wd-circle/wd-circle.vue +306 -0
- package/components/wd-col/index.scss +5 -0
- package/components/wd-col/types.ts +16 -0
- package/components/wd-col/wd-col.vue +83 -0
- package/components/wd-collapse/index.scss +71 -0
- package/components/wd-collapse/types.ts +68 -0
- package/components/wd-collapse/wd-collapse.vue +165 -0
- package/components/wd-collapse-item/index.scss +86 -0
- package/components/wd-collapse-item/types.ts +62 -0
- package/components/wd-collapse-item/wd-collapse-item.vue +184 -0
- package/components/wd-config-provider/index.scss +10 -0
- package/components/wd-config-provider/types.ts +2061 -0
- package/components/wd-config-provider/wd-config-provider.vue +61 -0
- package/components/wd-count-down/index.scss +16 -0
- package/components/wd-count-down/types.ts +58 -0
- package/components/wd-count-down/utils.ts +52 -0
- package/components/wd-count-down/wd-count-down.vue +62 -0
- package/components/wd-count-to/index.scss +25 -0
- package/components/wd-count-to/types.ts +121 -0
- package/components/wd-count-to/wd-count-to.vue +126 -0
- package/components/wd-curtain/index.scss +96 -0
- package/components/wd-curtain/types.ts +82 -0
- package/components/wd-curtain/wd-curtain.vue +172 -0
- package/components/wd-datetime-picker/index.scss +133 -0
- package/components/wd-datetime-picker/types.ts +198 -0
- package/components/wd-datetime-picker/wd-datetime-picker.vue +526 -0
- package/components/wd-datetime-picker-view/types.ts +171 -0
- package/components/wd-datetime-picker-view/util.ts +30 -0
- package/components/wd-datetime-picker-view/wd-datetime-picker-view.vue +402 -0
- package/components/wd-dialog/index.scss +281 -0
- package/components/wd-dialog/index.ts +168 -0
- package/components/wd-dialog/types.ts +452 -0
- package/components/wd-dialog/wd-dialog.vue +586 -0
- package/components/wd-divider/index.scss +122 -0
- package/components/wd-divider/types.ts +50 -0
- package/components/wd-divider/wd-divider.vue +54 -0
- package/components/wd-drop-menu/index.scss +90 -0
- package/components/wd-drop-menu/types.ts +38 -0
- package/components/wd-drop-menu/wd-drop-menu.vue +168 -0
- package/components/wd-drop-menu-item/index.scss +96 -0
- package/components/wd-drop-menu-item/types.ts +93 -0
- package/components/wd-drop-menu-item/wd-drop-menu-item.vue +205 -0
- package/components/wd-empty/index.scss +46 -0
- package/components/wd-empty/types.ts +37 -0
- package/components/wd-empty/wd-empty.vue +47 -0
- package/components/wd-fab/index.scss +124 -0
- package/components/wd-fab/types.ts +119 -0
- package/components/wd-fab/wd-fab.vue +322 -0
- package/components/wd-floating-panel/index.scss +73 -0
- package/components/wd-floating-panel/type.ts +32 -0
- package/components/wd-floating-panel/wd-floating-panel.vue +142 -0
- package/components/wd-form/adapters/zod.ts +56 -0
- package/components/wd-form/index.ts +2 -0
- package/components/wd-form/types.ts +133 -0
- package/components/wd-form/wd-form.vue +121 -0
- package/components/wd-form-item/index.scss +26 -0
- package/components/wd-form-item/types.ts +134 -0
- package/components/wd-form-item/wd-form-item.vue +182 -0
- package/components/wd-gap/index.scss +9 -0
- package/components/wd-gap/types.ts +26 -0
- package/components/wd-gap/wd-gap.vue +38 -0
- package/components/wd-grid/index.scss +11 -0
- package/components/wd-grid/types.ts +97 -0
- package/components/wd-grid/wd-grid.vue +48 -0
- package/components/wd-grid-item/index.scss +187 -0
- package/components/wd-grid-item/types.ts +98 -0
- package/components/wd-grid-item/wd-grid-item.vue +295 -0
- package/components/wd-icon/index.scss +46 -0
- package/components/wd-icon/types.ts +44 -0
- package/components/wd-icon/wd-icon.vue +66 -0
- package/components/wd-image-preview/index.scss +94 -0
- package/components/wd-image-preview/index.ts +95 -0
- package/components/wd-image-preview/types.ts +165 -0
- package/components/wd-image-preview/wd-image-preview.vue +233 -0
- package/components/wd-img/index.scss +82 -0
- package/components/wd-img/types.ts +96 -0
- package/components/wd-img/wd-img.vue +91 -0
- package/components/wd-img-cropper/index.scss +259 -0
- package/components/wd-img-cropper/types.ts +101 -0
- package/components/wd-img-cropper/wd-img-cropper.vue +653 -0
- package/components/wd-index-anchor/index.scss +34 -0
- package/components/wd-index-anchor/type.ts +9 -0
- package/components/wd-index-anchor/wd-index-anchor.vue +55 -0
- package/components/wd-index-bar/index.scss +68 -0
- package/components/wd-index-bar/type.ts +23 -0
- package/components/wd-index-bar/wd-index-bar.vue +157 -0
- package/components/wd-input/index.scss +129 -0
- package/components/wd-input/types.ts +165 -0
- package/components/wd-input/wd-input.vue +237 -0
- package/components/wd-input-number/index.scss +233 -0
- package/components/wd-input-number/types.ts +131 -0
- package/components/wd-input-number/wd-input-number.vue +473 -0
- package/components/wd-keyboard/constants.ts +81 -0
- package/components/wd-keyboard/index.scss +104 -0
- package/components/wd-keyboard/key/index.scss +103 -0
- package/components/wd-keyboard/key/index.vue +84 -0
- package/components/wd-keyboard/key/types.ts +44 -0
- package/components/wd-keyboard/types.ts +138 -0
- package/components/wd-keyboard/wd-keyboard.vue +236 -0
- package/components/wd-loading/index.scss +205 -0
- package/components/wd-loading/types.ts +61 -0
- package/components/wd-loading/wd-loading.vue +70 -0
- package/components/wd-loadmore/index.scss +62 -0
- package/components/wd-loadmore/types.ts +42 -0
- package/components/wd-loadmore/wd-loadmore.vue +68 -0
- package/components/wd-navbar/index.scss +96 -0
- package/components/wd-navbar/types.ts +74 -0
- package/components/wd-navbar/wd-navbar.vue +136 -0
- package/components/wd-navbar-capsule/index.scss +70 -0
- package/components/wd-navbar-capsule/types.ts +11 -0
- package/components/wd-navbar-capsule/wd-navbar-capsule.vue +48 -0
- package/components/wd-notice-bar/index.scss +94 -0
- package/components/wd-notice-bar/types.ts +97 -0
- package/components/wd-notice-bar/wd-notice-bar.vue +270 -0
- package/components/wd-notify/index.scss +114 -0
- package/components/wd-notify/index.ts +63 -0
- package/components/wd-notify/types.ts +130 -0
- package/components/wd-notify/wd-notify.vue +162 -0
- package/components/wd-overlay/index.scss +14 -0
- package/components/wd-overlay/types.ts +42 -0
- package/components/wd-overlay/wd-overlay.vue +55 -0
- package/components/wd-pagination/index.scss +71 -0
- package/components/wd-pagination/types.ts +69 -0
- package/components/wd-pagination/wd-pagination.vue +118 -0
- package/components/wd-password-input/index.scss +134 -0
- package/components/wd-password-input/types.ts +42 -0
- package/components/wd-password-input/wd-password-input.vue +51 -0
- package/components/wd-picker/index.scss +72 -0
- package/components/wd-picker/types.ts +141 -0
- package/components/wd-picker/wd-picker.vue +220 -0
- package/components/wd-picker-view/index.scss +93 -0
- package/components/wd-picker-view/types.ts +145 -0
- package/components/wd-picker-view/useSelection.ts +385 -0
- package/components/wd-picker-view/wd-picker-view.vue +227 -0
- package/components/wd-popover/index.scss +117 -0
- package/components/wd-popover/types.ts +106 -0
- package/components/wd-popover/wd-popover.vue +212 -0
- package/components/wd-popup/index.scss +89 -0
- package/components/wd-popup/types.ts +110 -0
- package/components/wd-popup/wd-popup.vue +174 -0
- package/components/wd-progress/index.scss +155 -0
- package/components/wd-progress/types.ts +94 -0
- package/components/wd-progress/wd-progress.vue +249 -0
- package/components/wd-radio/index.scss +189 -0
- package/components/wd-radio/types.ts +64 -0
- package/components/wd-radio/wd-radio.vue +164 -0
- package/components/wd-radio-group/index.scss +5 -0
- package/components/wd-radio-group/types.ts +70 -0
- package/components/wd-radio-group/wd-radio-group.vue +53 -0
- package/components/wd-rate/index.scss +57 -0
- package/components/wd-rate/types.ts +86 -0
- package/components/wd-rate/wd-rate.vue +168 -0
- package/components/wd-resize/index.scss +31 -0
- package/components/wd-resize/types.ts +14 -0
- package/components/wd-resize/wd-resize.vue +157 -0
- package/components/wd-root-portal/wd-root-portal.vue +77 -0
- package/components/wd-row/index.scss +6 -0
- package/components/wd-row/types.ts +36 -0
- package/components/wd-row/wd-row.vue +88 -0
- package/components/wd-search/index.scss +171 -0
- package/components/wd-search/types.ts +107 -0
- package/components/wd-search/wd-search.vue +198 -0
- package/components/wd-segmented/index.scss +155 -0
- package/components/wd-segmented/types.ts +81 -0
- package/components/wd-segmented/wd-segmented.vue +169 -0
- package/components/wd-select-picker/index.scss +72 -0
- package/components/wd-select-picker/types.ts +72 -0
- package/components/wd-select-picker/wd-select-picker.vue +371 -0
- package/components/wd-sidebar/index.scss +25 -0
- package/components/wd-sidebar/types.ts +34 -0
- package/components/wd-sidebar/wd-sidebar.vue +57 -0
- package/components/wd-sidebar-item/index.scss +91 -0
- package/components/wd-sidebar-item/types.ts +28 -0
- package/components/wd-sidebar-item/wd-sidebar-item.vue +118 -0
- package/components/wd-signature/index.scss +42 -0
- package/components/wd-signature/types.ts +295 -0
- package/components/wd-signature/wd-signature.vue +664 -0
- package/components/wd-skeleton/index.scss +112 -0
- package/components/wd-skeleton/types.ts +124 -0
- package/components/wd-skeleton/wd-skeleton.vue +110 -0
- package/components/wd-slide-verify/index.scss +112 -0
- package/components/wd-slide-verify/types.ts +98 -0
- package/components/wd-slide-verify/wd-slide-verify.vue +222 -0
- package/components/wd-slider/index.scss +485 -0
- package/components/wd-slider/types.ts +166 -0
- package/components/wd-slider/wd-slider.vue +529 -0
- package/components/wd-sort-button/index.scss +126 -0
- package/components/wd-sort-button/types.ts +68 -0
- package/components/wd-sort-button/wd-sort-button.vue +67 -0
- package/components/wd-step/index.scss +366 -0
- package/components/wd-step/types.ts +43 -0
- package/components/wd-step/wd-step.vue +181 -0
- package/components/wd-steps/index.scss +7 -0
- package/components/wd-steps/types.ts +50 -0
- package/components/wd-steps/wd-steps.vue +39 -0
- package/components/wd-sticky/index.scss +9 -0
- package/components/wd-sticky/types.ts +13 -0
- package/components/wd-sticky/wd-sticky.vue +192 -0
- package/components/wd-sticky-box/index.scss +6 -0
- package/components/wd-sticky-box/types.ts +20 -0
- package/components/wd-sticky-box/wd-sticky-box.vue +157 -0
- package/components/wd-swipe-action/index.scss +22 -0
- package/components/wd-swipe-action/types.ts +87 -0
- package/components/wd-swipe-action/wd-swipe-action.vue +320 -0
- package/components/wd-swiper/index.scss +69 -0
- package/components/wd-swiper/types.ts +275 -0
- package/components/wd-swiper/wd-swiper.vue +332 -0
- package/components/wd-swiper-nav/index.scss +179 -0
- package/components/wd-swiper-nav/types.ts +42 -0
- package/components/wd-swiper-nav/wd-swiper-nav.vue +42 -0
- package/components/wd-switch/index.scss +177 -0
- package/components/wd-switch/types.ts +93 -0
- package/components/wd-switch/wd-switch.vue +107 -0
- package/components/wd-tab/index.scss +16 -0
- package/components/wd-tab/types.ts +45 -0
- package/components/wd-tab/wd-tab.vue +99 -0
- package/components/wd-tabbar/index.scss +71 -0
- package/components/wd-tabbar/types.ts +79 -0
- package/components/wd-tabbar/wd-tabbar.vue +109 -0
- package/components/wd-tabbar-item/index.scss +50 -0
- package/components/wd-tabbar-item/types.ts +45 -0
- package/components/wd-tabbar-item/wd-tabbar-item.vue +101 -0
- package/components/wd-table/index.scss +128 -0
- package/components/wd-table/types.ts +160 -0
- package/components/wd-table/wd-table.vue +331 -0
- package/components/wd-table-column/index.scss +15 -0
- package/components/wd-table-column/types.ts +81 -0
- package/components/wd-table-column/wd-table-column.vue +198 -0
- package/components/wd-tabs/index.scss +332 -0
- package/components/wd-tabs/types.ts +155 -0
- package/components/wd-tabs/wd-tabs.vue +508 -0
- package/components/wd-tag/index.scss +325 -0
- package/components/wd-tag/types.ts +90 -0
- package/components/wd-tag/wd-tag.vue +158 -0
- package/components/wd-text/index.scss +52 -0
- package/components/wd-text/types.ts +107 -0
- package/components/wd-text/wd-text.vue +141 -0
- package/components/wd-textarea/index.scss +112 -0
- package/components/wd-textarea/types.ts +151 -0
- package/components/wd-textarea/wd-textarea.vue +212 -0
- package/components/wd-toast/index.scss +92 -0
- package/components/wd-toast/index.ts +97 -0
- package/components/wd-toast/types.ts +190 -0
- package/components/wd-toast/wd-toast.vue +158 -0
- package/components/wd-tooltip/index.scss +77 -0
- package/components/wd-tooltip/types.ts +105 -0
- package/components/wd-tooltip/wd-tooltip.vue +169 -0
- package/components/wd-tour/index.scss +106 -0
- package/components/wd-tour/types.ts +268 -0
- package/components/wd-tour/wd-tour.vue +518 -0
- package/components/wd-transition/index.scss +67 -0
- package/components/wd-transition/types.ts +106 -0
- package/components/wd-transition/wd-transition.vue +238 -0
- package/components/wd-upload/index.scss +204 -0
- package/components/wd-upload/types.ts +390 -0
- package/components/wd-upload/wd-upload.vue +565 -0
- package/components/wd-video-preview/index.scss +54 -0
- package/components/wd-video-preview/index.ts +64 -0
- package/components/wd-video-preview/types.ts +66 -0
- package/components/wd-video-preview/wd-video-preview.vue +141 -0
- package/components/wd-watermark/index.scss +21 -0
- package/components/wd-watermark/types.ts +130 -0
- package/components/wd-watermark/wd-watermark.vue +718 -0
- package/components/wot-ui/wot-ui.vue +5 -0
- package/composables/index.ts +16 -0
- package/composables/useCell.ts +34 -0
- package/composables/useChildren.ts +120 -0
- package/composables/useConfigProvider.ts +45 -0
- package/composables/useCountDown.ts +138 -0
- package/composables/useDeviceInfo.ts +136 -0
- package/composables/useLockScroll.ts +37 -0
- package/composables/useParent.ts +51 -0
- package/composables/usePopover.ts +212 -0
- package/composables/useQueue.ts +52 -0
- package/composables/useRaf.ts +37 -0
- package/composables/useTouch.ts +43 -0
- package/composables/useTranslate.ts +12 -0
- package/composables/useUpload.ts +366 -0
- package/global.d.ts +106 -0
- package/index.ts +6 -0
- package/locale/index.ts +32 -0
- package/locale/lang/ar-SA.ts +150 -0
- package/locale/lang/de-DE.ts +150 -0
- package/locale/lang/en-US.ts +150 -0
- package/locale/lang/es-ES.ts +150 -0
- package/locale/lang/fr-FR.ts +150 -0
- package/locale/lang/ja-JP.ts +150 -0
- package/locale/lang/ko-KR.ts +150 -0
- package/locale/lang/pt-PT.ts +150 -0
- package/locale/lang/ru-RU.ts +150 -0
- package/locale/lang/th-TH.ts +150 -0
- package/locale/lang/tr-TR.ts +155 -0
- package/locale/lang/ug-CN.ts +154 -0
- package/locale/lang/vi-VN.ts +89 -0
- package/locale/lang/zh-CN.ts +154 -0
- package/locale/lang/zh-HK.ts +78 -0
- package/locale/lang/zh-TW.ts +78 -0
- package/package.json +1 -11
- package/styles/iconfont/iconfont.scss +1243 -0
- package/styles/mixin/_config.scss +7 -0
- package/styles/mixin/_function.scss +44 -0
- package/styles/mixin/_mixin.scss +473 -0
- package/styles/theme/base/color.scss +210 -0
- package/styles/theme/base/font.scss +13 -0
- package/styles/theme/base/index.scss +8 -0
- package/styles/theme/base/insets.scss +32 -0
- package/styles/theme/base/number.scss +36 -0
- package/styles/theme/base/opacity.scss +9 -0
- package/styles/theme/base/radius.scss +13 -0
- package/styles/theme/base/stroke.scss +9 -0
- package/styles/theme/base/typography.scss +44 -0
- package/styles/theme/dark.scss +101 -0
- package/styles/theme/index.scss +16 -0
- package/styles/theme/light.scss +101 -0
- package/styles/variable.scss +472 -0
- package/tags.json +1 -0
- package/web-types.json +1 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
@use '../../../styles/mixin/mixin.scss' as *;
|
|
2
|
+
@use '../../../styles/variable.scss' as *;
|
|
3
|
+
|
|
4
|
+
// 按键高度
|
|
5
|
+
$keyboard-key-height: var(--wot-keyboard-key-height, $n-48) !default;
|
|
6
|
+
// 按键间距
|
|
7
|
+
$keyboard-key-padding: var(--wot-keyboard-key-padding, $padding-tight) !default;
|
|
8
|
+
// 按键字号
|
|
9
|
+
$keyboard-key-font-size: var(--wot-keyboard-key-font-size, $typography-title-size-extra-large) !default;
|
|
10
|
+
// 按键行高
|
|
11
|
+
$keyboard-key-line-height: var(--wot-keyboard-key-line-height, $typography-title-line--height-size-extra-large) !default;
|
|
12
|
+
// 车牌按键字号
|
|
13
|
+
$keyboard-key-car-font-size: var(--wot-keyboard-key-car-font-size, $typography-title-size-main) !default;
|
|
14
|
+
// 车牌按键行高
|
|
15
|
+
$keyboard-key-car-line-height: var(--wot-keyboard-key-car-line-height, $typography-title-line--height-size-main) !default;
|
|
16
|
+
// 按键字重
|
|
17
|
+
$keyboard-key-font-weight: var(--wot-keyboard-key-font-weight, $font-weight-medium) !default;
|
|
18
|
+
// 按键背景色
|
|
19
|
+
$keyboard-key-bg: var(--wot-keyboard-key-bg, $filled-oppo) !default;
|
|
20
|
+
// 按键圆角
|
|
21
|
+
$keyboard-key-radius: var(--wot-keyboard-key-radius, $radius-main) !default;
|
|
22
|
+
// 按键激活背景色
|
|
23
|
+
$keyboard-key-bg-active: var(--wot-keyboard-key-bg-active, $filled-strong) !default;
|
|
24
|
+
// 删除键字号
|
|
25
|
+
$keyboard-key-delete-font-size: var(--wot-keyboard-key-delete-font-size, $typography-title-size-main) !default;
|
|
26
|
+
// 删除键行高
|
|
27
|
+
$keyboard-key-delete-line-height: var(--wot-keyboard-key-delete-line-height, $typography-title-line--height-size-main) !default;
|
|
28
|
+
// 删除键字重
|
|
29
|
+
$keyboard-key-delete-font-weight: var(--wot-keyboard-key-delete-font-weight, $font-weight-medium) !default;
|
|
30
|
+
// 主按钮文字颜色
|
|
31
|
+
$keyboard-key-primary-color: var(--wot-keyboard-key-primary-color, $base-white) !default;
|
|
32
|
+
// 主按钮背景色
|
|
33
|
+
$keyboard-key-primary-bg: var(--wot-keyboard-key-primary-bg, $primary-6) !default;
|
|
34
|
+
// 主按钮激活背景色
|
|
35
|
+
$keyboard-key-primary-bg-active: var(--wot-keyboard-key-primary-bg-active, $primary-7) !default;
|
|
36
|
+
// 按键图标尺寸
|
|
37
|
+
$keyboard-key-icon-size: var(--wot-keyboard-key-icon-size, $n-22) !default;
|
|
38
|
+
|
|
39
|
+
.wd-key-wrapper {
|
|
40
|
+
position: relative;
|
|
41
|
+
flex: 1;
|
|
42
|
+
flex-basis: 33%;
|
|
43
|
+
box-sizing: border-box;
|
|
44
|
+
padding: 0 $keyboard-key-padding $keyboard-key-padding 0;
|
|
45
|
+
|
|
46
|
+
@include m(wider) {
|
|
47
|
+
flex-basis: 66%;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@include b(key) {
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
justify-content: center;
|
|
55
|
+
height: $keyboard-key-height;
|
|
56
|
+
font-size: $keyboard-key-font-size;
|
|
57
|
+
line-height: $keyboard-key-line-height;
|
|
58
|
+
font-weight: $keyboard-key-font-weight;
|
|
59
|
+
background: $keyboard-key-bg;
|
|
60
|
+
border-radius: $keyboard-key-radius;
|
|
61
|
+
|
|
62
|
+
@include m(active) {
|
|
63
|
+
background: $keyboard-key-bg-active;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@include when(car) {
|
|
67
|
+
font-size: $keyboard-key-car-font-size;
|
|
68
|
+
line-height: $keyboard-key-car-line-height;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@include m(large) {
|
|
72
|
+
position: absolute;
|
|
73
|
+
top: 0;
|
|
74
|
+
right: $keyboard-key-padding;
|
|
75
|
+
bottom: $keyboard-key-padding;
|
|
76
|
+
left: 0;
|
|
77
|
+
height: auto;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@include m(delete, close) {
|
|
81
|
+
font-size: $keyboard-key-delete-font-size;
|
|
82
|
+
line-height: $keyboard-key-delete-line-height;
|
|
83
|
+
font-weight: $keyboard-key-delete-font-weight;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@include m(close) {
|
|
88
|
+
color: $keyboard-key-primary-color;
|
|
89
|
+
background: $keyboard-key-primary-bg;
|
|
90
|
+
|
|
91
|
+
&.wd-key--active {
|
|
92
|
+
background: $keyboard-key-primary-bg-active;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@include edeep(loading-icon) {
|
|
97
|
+
color: $keyboard-key-primary-color;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@include edeep(icon) {
|
|
101
|
+
font-size: $keyboard-key-icon-size;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="`wd-key-wrapper ${wider ? 'wd-key-wrapper--wider' : ''}`" @touchstart="onTouchStart" @touchmove="onTouchMove" @touchend="onTouchEnd">
|
|
3
|
+
<view :class="keyClass">
|
|
4
|
+
<wd-loading custom-class="wd-key__loading-icon" v-if="props.loading" />
|
|
5
|
+
<template v-if="type === 'delete'">
|
|
6
|
+
<template v-if="text">
|
|
7
|
+
{{ text }}
|
|
8
|
+
</template>
|
|
9
|
+
<wd-icon v-else custom-class="wd-key__icon" name="del" size="22px"></wd-icon>
|
|
10
|
+
</template>
|
|
11
|
+
<template v-else-if="type === 'extra'">
|
|
12
|
+
<template v-if="text">
|
|
13
|
+
{{ text }}
|
|
14
|
+
</template>
|
|
15
|
+
<wd-icon v-else custom-class="wd-key__icon" name="keyboard" size="22px"></wd-icon>
|
|
16
|
+
</template>
|
|
17
|
+
<template v-else>{{ text }}</template>
|
|
18
|
+
</view>
|
|
19
|
+
</view>
|
|
20
|
+
</template>
|
|
21
|
+
<script lang="ts">
|
|
22
|
+
export default {
|
|
23
|
+
name: 'wd-key',
|
|
24
|
+
options: {
|
|
25
|
+
// #ifndef MP-TOUTIAO
|
|
26
|
+
virtualHost: true,
|
|
27
|
+
// #endif
|
|
28
|
+
addGlobalClass: true,
|
|
29
|
+
styleIsolation: 'shared'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<script lang="ts" setup>
|
|
35
|
+
import { computed, ref } from 'vue'
|
|
36
|
+
import { useTouch } from '../../../composables/useTouch'
|
|
37
|
+
import { keyProps } from './types'
|
|
38
|
+
|
|
39
|
+
const props = defineProps(keyProps)
|
|
40
|
+
const emit = defineEmits(['press'])
|
|
41
|
+
|
|
42
|
+
const touch = useTouch()
|
|
43
|
+
const active = ref<boolean>(false)
|
|
44
|
+
|
|
45
|
+
const keyClass = computed(() => {
|
|
46
|
+
return `wd-key ${props.large ? 'wd-key--large' : ''} ${props.type === 'delete' ? 'wd-key--delete' : ''} ${
|
|
47
|
+
props.type === 'close' ? 'wd-key--close' : ''
|
|
48
|
+
} ${props.isCar ? 'is-car' : ''} ${active.value ? 'wd-key--active' : ''}`
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 触摸开始事件处理
|
|
53
|
+
* @param {TouchEvent} event 触摸事件对象
|
|
54
|
+
*/
|
|
55
|
+
function onTouchStart(event: TouchEvent) {
|
|
56
|
+
touch.touchStart(event)
|
|
57
|
+
active.value = true
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 触摸移动事件处理
|
|
62
|
+
* @param {TouchEvent} event 触摸事件对象
|
|
63
|
+
*/
|
|
64
|
+
function onTouchMove(event: TouchEvent) {
|
|
65
|
+
touch.touchMove(event)
|
|
66
|
+
if (touch.direction.value) {
|
|
67
|
+
active.value = false
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 触摸结束事件处理
|
|
73
|
+
*/
|
|
74
|
+
function onTouchEnd() {
|
|
75
|
+
if (active.value) {
|
|
76
|
+
active.value = false
|
|
77
|
+
emit('press', props.text, props.type)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<style lang="scss">
|
|
83
|
+
@use './index.scss';
|
|
84
|
+
</style>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ExtractPropTypes } from 'vue'
|
|
2
|
+
import { makeBooleanProp, makeNumericProp, makeStringProp } from '../../../common/props'
|
|
3
|
+
|
|
4
|
+
export type NumberKeyType = '' | 'delete' | 'extra' | 'close'
|
|
5
|
+
|
|
6
|
+
export const keyProps = {
|
|
7
|
+
/**
|
|
8
|
+
* 键盘按键类型
|
|
9
|
+
* 类型:string
|
|
10
|
+
* 可选值:'' | 'delete' | 'extra' | 'close'
|
|
11
|
+
*/
|
|
12
|
+
type: makeStringProp<NumberKeyType>(''),
|
|
13
|
+
/**
|
|
14
|
+
* 按键文本
|
|
15
|
+
* 类型:string | number
|
|
16
|
+
*/
|
|
17
|
+
text: makeNumericProp(''),
|
|
18
|
+
/**
|
|
19
|
+
* 是否占据更宽的空间
|
|
20
|
+
* 类型:boolean
|
|
21
|
+
* 默认值:false
|
|
22
|
+
*/
|
|
23
|
+
wider: makeBooleanProp(false),
|
|
24
|
+
/**
|
|
25
|
+
* 是否是大按键
|
|
26
|
+
* 类型:boolean
|
|
27
|
+
* 默认值:false
|
|
28
|
+
*/
|
|
29
|
+
large: makeBooleanProp(false),
|
|
30
|
+
/**
|
|
31
|
+
* 是否正在加载中
|
|
32
|
+
* 类型:boolean
|
|
33
|
+
* 默认值:false
|
|
34
|
+
*/
|
|
35
|
+
loading: makeBooleanProp(false),
|
|
36
|
+
/**
|
|
37
|
+
* 是否为车牌键盘模式
|
|
38
|
+
* 类型:boolean
|
|
39
|
+
* 默认值:false
|
|
40
|
+
*/
|
|
41
|
+
isCar: makeBooleanProp(false)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type KeyProps = ExtractPropTypes<typeof keyProps>
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { PropType, ExtractPropTypes } from 'vue'
|
|
2
|
+
import { baseProps, makeBooleanProp, makeNumberProp, makeStringProp } from '../../common/props'
|
|
3
|
+
|
|
4
|
+
export type KeyboardMode = 'default' | 'custom' | 'car'
|
|
5
|
+
export type KeyType = '' | 'delete' | 'extra' | 'close'
|
|
6
|
+
export type CarKeyboardLang = 'zh' | 'en'
|
|
7
|
+
|
|
8
|
+
export interface Key {
|
|
9
|
+
/**
|
|
10
|
+
* key文本
|
|
11
|
+
*/
|
|
12
|
+
text?: number | string
|
|
13
|
+
/**
|
|
14
|
+
* key的类型
|
|
15
|
+
*/
|
|
16
|
+
type?: KeyType
|
|
17
|
+
/**
|
|
18
|
+
* 是否占2个key的宽度
|
|
19
|
+
*/
|
|
20
|
+
wider?: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const keyboardProps = {
|
|
24
|
+
...baseProps,
|
|
25
|
+
/**
|
|
26
|
+
* 是否可见
|
|
27
|
+
* 类型:boolean
|
|
28
|
+
* 默认值:false
|
|
29
|
+
*/
|
|
30
|
+
visible: makeBooleanProp(false),
|
|
31
|
+
/**
|
|
32
|
+
* 绑定的值
|
|
33
|
+
* 类型:string
|
|
34
|
+
* 默认值:''
|
|
35
|
+
*/
|
|
36
|
+
modelValue: makeStringProp(''),
|
|
37
|
+
/**
|
|
38
|
+
* 标题
|
|
39
|
+
* 类型:string
|
|
40
|
+
*/
|
|
41
|
+
title: String,
|
|
42
|
+
/**
|
|
43
|
+
* 键盘模式
|
|
44
|
+
* 类型:string
|
|
45
|
+
* 可选值:'default' | 'custom' | 'car'
|
|
46
|
+
* 默认值:'default'
|
|
47
|
+
*/
|
|
48
|
+
mode: makeStringProp<KeyboardMode>('default'),
|
|
49
|
+
/**
|
|
50
|
+
* 层级
|
|
51
|
+
* 类型:number
|
|
52
|
+
* 默认值:100
|
|
53
|
+
*/
|
|
54
|
+
zIndex: makeNumberProp(100),
|
|
55
|
+
/**
|
|
56
|
+
* 最大长度
|
|
57
|
+
* 类型:number
|
|
58
|
+
* 默认值:Infinity
|
|
59
|
+
*/
|
|
60
|
+
maxlength: makeNumberProp(Infinity),
|
|
61
|
+
/**
|
|
62
|
+
* 是否显示删除键
|
|
63
|
+
* 类型:boolean
|
|
64
|
+
* 默认值:true
|
|
65
|
+
*/
|
|
66
|
+
showDeleteKey: makeBooleanProp(true),
|
|
67
|
+
/**
|
|
68
|
+
* 是否随机键盘按键顺序
|
|
69
|
+
* 类型:boolean
|
|
70
|
+
* 默认值:false
|
|
71
|
+
*/
|
|
72
|
+
randomKeyOrder: makeBooleanProp(false),
|
|
73
|
+
/**
|
|
74
|
+
* 确认按钮文本
|
|
75
|
+
* 类型:string
|
|
76
|
+
*/
|
|
77
|
+
closeText: String,
|
|
78
|
+
/**
|
|
79
|
+
* 删除按钮文本
|
|
80
|
+
* 类型:string
|
|
81
|
+
*/
|
|
82
|
+
deleteText: String,
|
|
83
|
+
/**
|
|
84
|
+
* 关闭按钮是否显示加载状态
|
|
85
|
+
* 类型:boolean
|
|
86
|
+
* 默认值:false
|
|
87
|
+
*/
|
|
88
|
+
closeButtonLoading: makeBooleanProp(false),
|
|
89
|
+
/**
|
|
90
|
+
* 是否显示蒙层
|
|
91
|
+
* 类型:boolean
|
|
92
|
+
* 默认值:false
|
|
93
|
+
*/
|
|
94
|
+
modal: makeBooleanProp(false),
|
|
95
|
+
/**
|
|
96
|
+
* 是否在点击外部时收起键盘
|
|
97
|
+
* 类型:boolean
|
|
98
|
+
* 默认值:true
|
|
99
|
+
*/
|
|
100
|
+
hideOnClickOutside: makeBooleanProp(true),
|
|
101
|
+
/**
|
|
102
|
+
* 是否锁定滚动
|
|
103
|
+
* 类型:boolean
|
|
104
|
+
* 默认值:true
|
|
105
|
+
*/
|
|
106
|
+
lockScroll: makeBooleanProp(true),
|
|
107
|
+
/**
|
|
108
|
+
* 是否在底部安全区域内
|
|
109
|
+
* 类型:boolean
|
|
110
|
+
* 默认值:true
|
|
111
|
+
*/
|
|
112
|
+
safeAreaInsetBottom: makeBooleanProp(true),
|
|
113
|
+
/**
|
|
114
|
+
* 额外按键
|
|
115
|
+
* 类型:string | string[]
|
|
116
|
+
*/
|
|
117
|
+
extraKey: [String, Array] as PropType<string | Array<string>>,
|
|
118
|
+
/**
|
|
119
|
+
* 是否从页面中脱离出来,用于解决各种 fixed 失效问题 (H5: teleport, APP: renderjs, 小程序: root-portal)
|
|
120
|
+
* 类型:boolean
|
|
121
|
+
* 默认值:false
|
|
122
|
+
*/
|
|
123
|
+
rootPortal: makeBooleanProp(false),
|
|
124
|
+
/**
|
|
125
|
+
* 车牌键盘语言模式 当mode=car时生效
|
|
126
|
+
* 类型:string
|
|
127
|
+
* 可选值:'zh' | 'en'
|
|
128
|
+
*/
|
|
129
|
+
carLang: String as PropType<CarKeyboardLang>,
|
|
130
|
+
/**
|
|
131
|
+
* 是否自动切换车牌键盘语言 当mode=car且carLang是非受控状态时生效
|
|
132
|
+
* 类型:boolean
|
|
133
|
+
* 默认值:false
|
|
134
|
+
*/
|
|
135
|
+
autoSwitchLang: makeBooleanProp(false)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export type KeyboardProps = ExtractPropTypes<typeof keyboardProps>
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<wd-popup
|
|
3
|
+
v-model="show"
|
|
4
|
+
position="bottom"
|
|
5
|
+
:z-index="zIndex"
|
|
6
|
+
:safe-area-inset-bottom="safeAreaInsetBottom"
|
|
7
|
+
:modal-style="modal ? '' : 'opacity: 0;'"
|
|
8
|
+
:modal="hideOnClickOutside"
|
|
9
|
+
:lockScroll="lockScroll"
|
|
10
|
+
:root-portal="rootPortal"
|
|
11
|
+
@click-modal="handleClose"
|
|
12
|
+
>
|
|
13
|
+
<view :class="`wd-keyboard ${customClass}`" :style="customStyle">
|
|
14
|
+
<view class="wd-keyboard__header" v-if="showHeader">
|
|
15
|
+
<slot name="title" v-if="showTitle">
|
|
16
|
+
<text class="wd-keyboard__title">{{ title }}</text>
|
|
17
|
+
</slot>
|
|
18
|
+
<view class="wd-keyboard__close" hover-class="wd-keyboard__close--hover" v-if="showClose" @click="handleClose">
|
|
19
|
+
<text>{{ closeText }}</text>
|
|
20
|
+
</view>
|
|
21
|
+
</view>
|
|
22
|
+
<template v-if="mode !== 'car'">
|
|
23
|
+
<view class="wd-keyboard__body">
|
|
24
|
+
<view class="wd-keyboard__keys">
|
|
25
|
+
<wd-key v-for="key in keys" :key="key.text" :text="key.text" :type="key.type" :wider="key.wider" @press="handlePress"></wd-key>
|
|
26
|
+
</view>
|
|
27
|
+
<view class="wd-keyboard__sidebar" v-if="mode === 'custom'">
|
|
28
|
+
<wd-key v-if="showDeleteKey" large :text="deleteText" type="delete" @press="handlePress"></wd-key>
|
|
29
|
+
<wd-key large :text="closeText" type="close" :loading="closeButtonLoading" @press="handlePress"></wd-key>
|
|
30
|
+
</view>
|
|
31
|
+
</view>
|
|
32
|
+
</template>
|
|
33
|
+
<template v-if="mode === 'car'">
|
|
34
|
+
<view class="wd-keyboard__body">
|
|
35
|
+
<view class="wd-keyboard__car-keys">
|
|
36
|
+
<wd-key v-for="key in keys" :key="key.text" :text="key.text" :type="key.type" :wider="key.wider" is-car @press="handlePress"></wd-key>
|
|
37
|
+
</view>
|
|
38
|
+
</view>
|
|
39
|
+
</template>
|
|
40
|
+
</view>
|
|
41
|
+
</wd-popup>
|
|
42
|
+
</template>
|
|
43
|
+
<script lang="ts">
|
|
44
|
+
export default {
|
|
45
|
+
name: 'wd-keyboard',
|
|
46
|
+
options: {
|
|
47
|
+
// #ifndef MP-TOUTIAO
|
|
48
|
+
virtualHost: true,
|
|
49
|
+
// #endif
|
|
50
|
+
addGlobalClass: true,
|
|
51
|
+
styleIsolation: 'shared'
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<script lang="ts" setup>
|
|
57
|
+
import { computed, ref, watch, useSlots } from 'vue'
|
|
58
|
+
import wdPopup from '../wd-popup/wd-popup.vue'
|
|
59
|
+
import WdKey from './key/index.vue'
|
|
60
|
+
import { keyboardProps, type Key, type CarKeyboardLang } from './types'
|
|
61
|
+
import type { NumberKeyType } from './key/types'
|
|
62
|
+
import { CAR_KEYBOARD_AREAS, CAR_KEYBOARD_KEYS } from './constants'
|
|
63
|
+
|
|
64
|
+
const props = defineProps(keyboardProps)
|
|
65
|
+
const emit = defineEmits(['update:visible', 'input', 'close', 'delete', 'update:modelValue', 'update:carLang'])
|
|
66
|
+
const slots = useSlots()
|
|
67
|
+
|
|
68
|
+
const show = ref(props.visible)
|
|
69
|
+
watch(
|
|
70
|
+
() => props.visible,
|
|
71
|
+
(newValue) => {
|
|
72
|
+
show.value = newValue
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
const carLang = ref<CarKeyboardLang>('zh')
|
|
77
|
+
const carKeyboardLang = computed({
|
|
78
|
+
get: () => (props.carLang ? props.carLang : carLang.value),
|
|
79
|
+
set: (value: CarKeyboardLang) => {
|
|
80
|
+
carLang.value = value
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
const keys = computed(() => (props.mode !== 'car' ? (props.mode === 'custom' ? genCustomKeys() : genDefaultKeys()) : genCarKeys()))
|
|
85
|
+
|
|
86
|
+
const showClose = computed(() => {
|
|
87
|
+
return props.closeText && (props.mode === 'default' || props.mode === 'car')
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
const showTitle = computed(() => {
|
|
91
|
+
return !!props.title || !!slots.title
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
const showHeader = computed(() => {
|
|
95
|
+
return showTitle.value || showClose.value
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 随机打乱数组的顺序
|
|
100
|
+
* @param {T[]} arr 要打乱顺序的数组
|
|
101
|
+
* @returns {T[]} 打乱顺序后的数组
|
|
102
|
+
*/
|
|
103
|
+
function shuffleArray<T>(arr: T[]): T[] {
|
|
104
|
+
const newArr = [...arr]
|
|
105
|
+
for (let i = newArr.length - 1; i > 0; i--) {
|
|
106
|
+
// 生成一个随机索引 j,范围是 [0, i]
|
|
107
|
+
const j = Math.floor(Math.random() * (i + 1))
|
|
108
|
+
|
|
109
|
+
// 交换索引 i 和 j 处的元素
|
|
110
|
+
;[newArr[i], newArr[j]] = [newArr[j], newArr[i]]
|
|
111
|
+
}
|
|
112
|
+
return newArr
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 生成基础按键(1-9)
|
|
117
|
+
* @returns {Key[]} 基础按键数组
|
|
118
|
+
*/
|
|
119
|
+
function genBasicKeys(): Key[] {
|
|
120
|
+
const keys = Array.from({ length: 9 }, (_, i) => ({ text: i + 1 }))
|
|
121
|
+
|
|
122
|
+
// 如果需要随机顺序,则调用 shuffleArray 方法打乱数组顺序
|
|
123
|
+
return props.randomKeyOrder ? shuffleArray(keys) : keys
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* 生成默认键盘按键
|
|
128
|
+
* @returns {Key[]} 默认键盘按键数组
|
|
129
|
+
*/
|
|
130
|
+
function genDefaultKeys(): Key[] {
|
|
131
|
+
return [
|
|
132
|
+
...genBasicKeys(),
|
|
133
|
+
{ text: props.extraKey as string, type: 'extra' },
|
|
134
|
+
{ text: 0 },
|
|
135
|
+
{
|
|
136
|
+
// 根据条件是否显示删除键的文本和类型
|
|
137
|
+
text: props.showDeleteKey ? props.deleteText : '',
|
|
138
|
+
type: props.showDeleteKey ? 'delete' : ''
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* 生成自定义键盘按键
|
|
145
|
+
* @returns {Key[]} 自定义键盘按键数组
|
|
146
|
+
*/
|
|
147
|
+
function genCustomKeys(): Key[] {
|
|
148
|
+
const keys = genBasicKeys()
|
|
149
|
+
const extraKeys = Array.isArray(props.extraKey) ? props.extraKey : [props.extraKey]
|
|
150
|
+
if (extraKeys.length === 1) {
|
|
151
|
+
// 如果只有一个额外按键,则添加一个宽度较大的数字0和一个额外按键
|
|
152
|
+
keys.push({ text: 0, wider: true }, { text: extraKeys[0], type: 'extra' })
|
|
153
|
+
} else if (extraKeys.length === 2) {
|
|
154
|
+
// 如果有两个额外按键,则添加两个额外按键和一个数字0
|
|
155
|
+
keys.push({ text: extraKeys[0], type: 'extra' }, { text: 0 }, { text: extraKeys[1], type: 'extra' })
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return keys
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* 生成车牌键盘按键
|
|
163
|
+
* @returns {Key[]} 车牌键盘按键数组
|
|
164
|
+
*/
|
|
165
|
+
function genCarKeys(): Array<Key> {
|
|
166
|
+
const [keys, remainKeys] = splitCarKeys()
|
|
167
|
+
return [
|
|
168
|
+
...keys,
|
|
169
|
+
{ text: carKeyboardLang.value === 'zh' ? 'ABC' : '省份', type: 'extra', wider: true },
|
|
170
|
+
...remainKeys,
|
|
171
|
+
{ text: props.deleteText, type: 'delete', wider: true }
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* 分割车牌键盘按键
|
|
177
|
+
* @returns {Array<Array<Key>>} 分割后的按键数组
|
|
178
|
+
*/
|
|
179
|
+
function splitCarKeys(): Array<Array<Key>> {
|
|
180
|
+
const keys = carKeyboardLang.value === 'zh' ? CAR_KEYBOARD_AREAS.map((key) => ({ text: key })) : CAR_KEYBOARD_KEYS.map((key) => ({ text: key }))
|
|
181
|
+
return [keys.slice(0, 30), keys.slice(30)]
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* 处理关闭事件
|
|
186
|
+
*/
|
|
187
|
+
const handleClose = () => {
|
|
188
|
+
emit('close')
|
|
189
|
+
emit('update:visible', false)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* 处理按键点击事件
|
|
194
|
+
* @param {string} text 按键文本
|
|
195
|
+
* @param {NumberKeyType} type 按键类型
|
|
196
|
+
*/
|
|
197
|
+
const handlePress = (text: string, type: NumberKeyType) => {
|
|
198
|
+
if (type === 'extra') {
|
|
199
|
+
if (text === '') {
|
|
200
|
+
return handleClose()
|
|
201
|
+
} else if (text === 'ABC' || text === '省份') {
|
|
202
|
+
const newLang = carKeyboardLang.value === 'zh' ? 'en' : 'zh'
|
|
203
|
+
if (props.carLang) {
|
|
204
|
+
emit('update:carLang', newLang)
|
|
205
|
+
} else {
|
|
206
|
+
carKeyboardLang.value = newLang
|
|
207
|
+
}
|
|
208
|
+
return
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const value = props.modelValue
|
|
213
|
+
if (type === 'delete') {
|
|
214
|
+
emit('delete')
|
|
215
|
+
const newValue = value.slice(0, value.length - 1)
|
|
216
|
+
emit('update:modelValue', newValue)
|
|
217
|
+
if (props.mode === 'car' && newValue.length === 0 && props.autoSwitchLang) {
|
|
218
|
+
carKeyboardLang.value = 'zh'
|
|
219
|
+
}
|
|
220
|
+
} else if (type === 'close') {
|
|
221
|
+
handleClose()
|
|
222
|
+
} else if (value.length < +props.maxlength) {
|
|
223
|
+
emit('input', text)
|
|
224
|
+
const newValue = value + text
|
|
225
|
+
emit('update:modelValue', newValue)
|
|
226
|
+
if (props.mode === 'car' && newValue.length === 1 && props.autoSwitchLang) {
|
|
227
|
+
// 输入第一位(省份)后,自动切换到英文
|
|
228
|
+
carKeyboardLang.value = 'en'
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
</script>
|
|
233
|
+
|
|
234
|
+
<style lang="scss">
|
|
235
|
+
@use './index.scss';
|
|
236
|
+
</style>
|