acdr-ui/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-message-box/wd-message-box.js.map

1 line
12 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{"version":3,"file":"wd-message-box.js","sources":["../../../../../../../node_modules/wot-design-uni/components/wd-message-box/wd-message-box.vue","../../../../../../../uniComponent:/RDovQXBwL1dvcmsvYWRkci9hY2RyLXVpL25vZGVfbW9kdWxlcy93b3QtZGVzaWduLXVuaS9jb21wb25lbnRzL3dkLW1lc3NhZ2UtYm94L3dkLW1lc3NhZ2UtYm94LnZ1ZQ"],"sourcesContent":["<template>\n <view>\n <wd-popup\n transition=\"zoom-in\"\n v-model=\"show\"\n :close-on-click-modal=\"closeOnClickModal\"\n :lazy-render=\"lazyRender\"\n custom-class=\"wd-message-box\"\n @click-modal=\"toggleModal('modal')\"\n :z-index=\"zIndex\"\n :duration=\"200\"\n >\n <view :class=\"rootClass\">\n <view :class=\"bodyClass\">\n <view v-if=\"title\" class=\"wd-message-box__title\">\n {{ title }}\n </view>\n <view class=\"wd-message-box__content\">\n <template v-if=\"type === 'prompt'\">\n <wd-input v-model=\"inputValue\" :type=\"inputType\" size=\"large\" :placeholder=\"inputPlaceholder || '请输入'\" @input=\"inputValChange\" />\n <view v-if=\"showErr\" class=\"wd-message-box__input-error\">\n {{ inputError || translate('inputNoValidate') }}\n </view>\n </template>\n <slot>{{ msg }}</slot>\n </view>\n </view>\n <view :class=\"`wd-message-box__actions ${showCancelButton ? 'wd-message-box__flex' : 'wd-message-box__block'}`\">\n <wd-button type=\"info\" block v-if=\"showCancelButton\" custom-style=\"margin-right: 16px;\" @click=\"toggleModal('cancel')\">\n {{ cancelButtonText || translate('cancel') }}\n </wd-button>\n <wd-button block @click=\"toggleModal('confirm')\">\n {{ confirmButtonText || translate('confirm') }}\n </wd-button>\n </view>\n </view>\n </wd-popup>\n </view>\n</template>\n<script lang=\"ts\">\nexport default {\n name: 'wd-message-box',\n options: {\n virtualHost: true,\n addGlobalClass: true,\n styleIsolation: 'shared'\n }\n}\n</script>\n\n<script lang=\"ts\" setup>\nimport { computed, inject, ref, watch } from 'vue'\nimport {\n messageBoxProps,\n type InputValidate,\n type MessageBeforeConfirmOption,\n type MessageOptions,\n type MessageResult,\n type MessageType\n} from './types'\nimport { defaultOptions, messageDefaultOptionKey } from '.'\nimport { isDef, isFunction } from '../common/util'\nimport { useTranslate } from '../composables/useTranslate'\n\nconst props = defineProps(messageBoxProps)\n\nconst { translate } = useTranslate('message-box')\n\nconst rootClass = computed(() => {\n return `wd-message-box__container ${props.customClass}`\n})\n\nconst bodyClass = computed(() => {\n return `wd-message-box__body ${!title.value ? 'is-no-title' : ''} ${type.value === 'prompt' ? 'is-prompt' : ''}`\n})\n\nconst messageOptionKey = props.selector ? messageDefaultOptionKey + props.selector : messageDefaultOptionKey\nconst messageOption = inject(messageOptionKey, ref<MessageOptions>(defaultOptions)) // message选项\n\n/**\n * 消息文案\n */\nconst msg = ref<string>('')\nlet onConfirm: ((res: MessageResult) => void) | null = null\nlet onCancel: ((res: MessageResult) => void) | null = null\nlet beforeConfirm: ((options: MessageBeforeConfirmOption) => void) | null = null\nconst show = ref<boolean>(false)\n/**\n * 标题\n */\nconst title = ref<string>('')\n/**\n * 是否展示取消按钮\n */\nconst showCancelButton = ref<boolean>(false)\n/**\n * 是否支持点击蒙层进行关闭点击蒙层回调传入的action为'modal'\n */\nconst closeOnClickModal = ref<boolean>(true)\n/**\n * 确定按钮文案\n */\nconst confirmButtonText = ref<string>('')\n/**\n * 取消按钮文案\n */\nconst cancelButtonText = ref<string>('')\n\n/**\n * 弹框类型\n */\nconst type = ref<MessageType>('alert')\n\n/**\n * 当type为prompt时输入框类型\n */\nconst inputType = ref<string>('text')\n\n/**\n * 当type为prompt时输入框初始值\n */\nconst inputValue = ref<string | number>('')\n\n/**\n * 当type为prompt时输入框placeholder\n */\nconst inputPlaceholder = ref<string>('')\n\n/**\n * 当type为prompt时输入框正则校验点击确定按钮时进行校验\n */\nconst inputPattern = ref<RegExp>()\n\n/**\n * 当type为prompt时输入框校验函数点击确定按钮时进行校验\n */\nlet inputValidate: InputValidate | null = null\n\n/**\n * 当type为prompt时输入框检验不通过时的错误提示文案\n */\nconst inputError = ref<string>('')\nconst showErr = ref<boolean>(false)\n/**\n * 弹窗层级\n */\nconst zIndex = ref<number>(99)\n/**\n * 弹层内容懒渲染,触发展示时才渲染内容\n */\nconst lazyRender = ref<boolean>(true)\n\n// 监听options变化展示\nwatch(\n () => messageOption.value,\n (newVal: MessageOptions) => {\n reset(newVal)\n },\n {\n deep: true,\n immediate: true\n }\n)\n\nwatch(\n () => show.value,\n (newValue) => {\n resetErr(newValue)\n },\n {\n deep: true,\n immediate: true\n }\n)\n\n/**\n * 点击操作\n * @param action\n */\nfunction toggleModal(action: 'confirm' | 'cancel' | 'modal') {\n if (action === 'modal' && !closeOnClickModal.value) {\n return\n }\n if (type.value === 'prompt' && action === 'confirm' && !validate()) {\n return\n }\n switch (action) {\n case 'confirm':\n if (beforeConfirm) {\n beforeConfirm({\n resolve: (isPass) => {\n if (isPass) {\n handleConfirm({\n action: action,\n value: inputValue.value\n })\n }\n }\n })\n } else {\n handleConfirm({\n action: action,\n value: inputValue.value\n })\n }\n break\n case 'cancel':\n handleCancel({\n action: action\n })\n break\n default:\n handleCancel({\n action: 'modal'\n })\n break\n }\n}\n\n/**\n * 确认回调\n * @param result\n */\nfunction handleConfirm(result: MessageResult) {\n show.value = false\n if (isFunction(onConfirm)) {\n onConfirm(result)\n }\n}\n\n/**\n * 取消回调\n * @param result\n */\nfunction handleCancel(result: MessageResult) {\n show.value = false\n if (isFunction(onCancel)) {\n onCancel(result)\n }\n}\n\n/**\n * @description 如果存在校验规则行为,则进行判断校验是否通过规则。默认不存在校验直接铜鼓。\n * @return {Boolean} 是否通过校验\n */\nfunction validate() {\n if (inputPattern.value && !inputPattern.value.test(String(inputValue.value))) {\n showErr.value = true\n return false\n }\n if (typeof inputValidate === 'function') {\n const validateResult = inputValidate(inputValue.value)\n if (!validateResult) {\n showErr.value = true\n return false\n }\n }\n showErr.value = false\n return true\n}\n/**\n * @description show关闭时销毁错误提示\n * @param val\n */\nfunction resetErr(val: boolean) {\n if (val === false) {\n showErr.value = false\n }\n}\nfunction inputValChange(value: string | number) {\n if (value === '') {\n showErr.value = false\n return\n }\n inputValue.value = value\n}\n\n/**\n * 重置message选项值\n * @param option message选项值\n */\nfunction reset(option: MessageOptions) {\n if (option) {\n title.value = isDef(option.title) ? option.title : ''\n showCancelButton.value = isDef(option.showCancelButton) ? option.showCancelButton : false\n show.value = option.show!\n closeOnClickModal.value = option.closeOnClickModal!\n confirmButtonText.value = option.confirmButtonText!\n cancelButtonText.value = option.cancelButtonText!\n msg.value = option.msg!\n type.value = option.type!\n inputType.value = option.inputType!\n inputValue.value = option.inputValue!\n inputPlaceholder.value = option.inputPlaceholder!\n inputPattern.value = option.inputPattern!\n inputValidate = option.inputValidate!\n onConfirm = (option as any).onConfirm\n onCancel = (option as any).onCancel\n beforeConfirm = option.beforeConfirm!\n inputError.value = option.inputError!\n showErr.value = option.showErr!\n zIndex.value = option.zIndex!\n lazyRender.value = option.lazyRender!\n }\n}\n</script>\n\n<style lang=\"scss\" scoped>\n@import './index.scss';\n</style>\n","import Component from 'D:/App/Work/addr/acdr-ui/node_modules/wot-design-uni/components/wd-message-box/wd-message-box.vue'\nwx.createComponent(Component)"],"names":["useTranslate","computed","messageDefaultOptionKey","inject","ref","defaultOptions","watch","isFunction","isDef"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAA,cAAe;AAAA,EACb,MAAM;AAAA,EACN,SAAS;AAAA,IACP,aAAa;AAAA,IACb,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,EAClB;AACF;;;;AAiBA,UAAM,QAAQ;AAEd,UAAM,EAAE,UAAA,IAAcA,cAAA,aAAa,aAAa;AAE1C,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