diff --git a/packages/uni-components/dist/components.js b/packages/uni-components/dist/components.js index e31f989a3c3e441db2c08d1034c18553260ebf5d..1544a1d7a4752b5af46841295e8d7fd387b435bf 100644 --- a/packages/uni-components/dist/components.js +++ b/packages/uni-components/dist/components.js @@ -1,5 +1,5 @@ -import { defineComponent, createVNode, mergeProps, getCurrentInstance, provide, watch, onUnmounted, ref, inject, onBeforeUnmount, resolveComponent, Text, isVNode, Fragment, onMounted, computed } from "vue"; -import { hasOwn, isPlainObject, extend } from "@vue/shared"; +import { createElementVNode, defineComponent, createVNode, mergeProps, getCurrentInstance, provide, watch, onUnmounted, ref, inject, onBeforeUnmount, Text, isVNode, Fragment, onMounted, computed } from "vue"; +import { hasOwn, extend, isPlainObject } from "@vue/shared"; import { cacheStringFunction } from "@dcloudio/uni-shared"; const OPEN_TYPES = [ "navigate", @@ -97,6 +97,9 @@ function useHoverClass(props2) { } return {}; } +function createNVueTextVNode(text, attrs) { + return createElementVNode("u-text", extend({ appendAsTree: true }, attrs), text); +} const navigatorStyles = [{ "navigator-hover": { backgroundColor: "rgba(0,0,0,0.1)", @@ -506,13 +509,13 @@ var Button = defineComponent({ const wrapSlots = () => { if (!slots.default) return []; - const _slots = slots.default(); - return _slots.map((slot) => { - if (slot.type === Text) { - return createVNode("text", null, [slot]); - } - return slot; - }); + const vnodes = slots.default(); + if (vnodes.length === 1 && vnodes[0].type === Text) { + return [createNVueTextVNode(vnodes[0].children, { + class: "ub-t " + _getClass("-t") + })]; + } + return vnodes; }; return () => { return createVNode("div", mergeProps({ @@ -522,7 +525,7 @@ var Button = defineComponent({ hoverClass: _getHoverClass("") }), { "onClick": onClick - }), [props2.loading ? createVNode(resolveComponent("loading-indicator"), mergeProps({ + }), [props2.loading ? createVNode("loading-indicator", mergeProps({ "class": ["ub-loading", `ub-${TYPES[type]}-loading`] }, { arrow: "false", @@ -1338,6 +1341,7 @@ function useMovableViewState(props2, trigger, rootRef) { return false; } _updateScale(_scale, true); + _updateOldScale(_scale); } function _setScaleValue(scale) { if (!props2.scale) { @@ -1345,6 +1349,7 @@ function useMovableViewState(props2, trigger, rootRef) { } scale = _adjustScale(scale); _updateScale(scale, true); + _updateOldScale(scale); return scale; } function __handleTouchStart() { @@ -1540,6 +1545,9 @@ function useMovableViewState(props2, trigger, rootRef) { } } } + function _updateOldScale(scale) { + _oldScale = scale; + } function _adjustScale(scale) { scale = Math.max(0.5, scaleMinNumber.value, scale); scale = Math.min(10, scaleMaxNumber.value, scale); @@ -1653,6 +1661,7 @@ function useMovableViewState(props2, trigger, rootRef) { let x = limitXY.x; let y = limitXY.y; _setTransform(x, y, scale, "", true); + _updateOldScale(scale); } onMounted(() => { useTouchtrack((event) => { diff --git a/packages/uni-components/src/nvue/button/index.tsx b/packages/uni-components/src/nvue/button/index.tsx index b00cf4f73f76529e3f3bc85da7fd2aeddcf71d69..ecfca1219ff193337ec9af3f194d607e33e6bd6c 100644 --- a/packages/uni-components/src/nvue/button/index.tsx +++ b/packages/uni-components/src/nvue/button/index.tsx @@ -1,7 +1,7 @@ import { inject, onBeforeUnmount, ref, defineComponent, Text } from 'vue' import { uniLabelKey, UniLabelCtx } from '../label' import { useListeners } from '../../helpers/useListeners' -import { useHoverClass } from '../utils' +import { createNVueTextVNode, useHoverClass } from '../utils' import { buttonProps } from '../../components/button' import { extend } from '@vue/shared' @@ -256,13 +256,15 @@ export default defineComponent({ const wrapSlots = () => { if (!slots.default) return [] - const _slots = slots.default() - return _slots.map((slot) => { - if (slot.type === Text) { - return {slot} - } - return slot - }) + const vnodes = slots.default() + if (vnodes.length === 1 && vnodes[0].type === Text) { + return [ + createNVueTextVNode(vnodes[0].children as string, { + class: 'ub-t ' + _getClass('-t'), + }), + ] + } + return vnodes } return () => { diff --git a/packages/uni-components/src/nvue/utils.ts b/packages/uni-components/src/nvue/utils.ts index cc359c67957799fa4831845680b260c939f1ca25..9d6ea5ac6e4b88c67a788bc66c98df44ab868a81 100644 --- a/packages/uni-components/src/nvue/utils.ts +++ b/packages/uni-components/src/nvue/utils.ts @@ -1,4 +1,5 @@ -import { hasOwn } from '@vue/shared' +import { createElementVNode } from 'vue' +import { extend, hasOwn } from '@vue/shared' interface HoverProps { hoverClass?: string @@ -22,3 +23,14 @@ export function useHoverClass(props: HoverProps) { } return {} } + +export function createNVueTextVNode( + text: string, + attrs?: Record +) { + return createElementVNode( + 'u-text', + extend({ appendAsTree: true }, attrs), + text + ) +} diff --git a/packages/uni-components/vite.config.ts b/packages/uni-components/vite.config.ts index b998aa348401a85af06f71229be1bf4207bf5b7b..4c1fa4bc3806296d35b1ef34860654a6ecdb8231 100644 --- a/packages/uni-components/vite.config.ts +++ b/packages/uni-components/vite.config.ts @@ -2,6 +2,7 @@ import path from 'path' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' +import { isAppNVueNativeTag } from '@dcloudio/uni-shared' function resolve(file: string) { return path.resolve(__dirname, file) @@ -47,5 +48,5 @@ export default defineConfig({ }, }, }, - plugins: [vue(), vueJsx({})], + plugins: [vue(), vueJsx({ isCustomElement: isAppNVueNativeTag })], }) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 59ccaa43a6b05f5816d1bf34b919a60a29deb70c..887a4f67ba2a07259f53fe3a838c6a9ade0c02ee 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5343,8 +5343,8 @@ packages: engines: {node: '>= 0.6'} /fs-extra/10.0.0: - resolution: {integrity: sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==, tarball: fs-extra/-/fs-extra-10.0.0.tgz} - engines: {node: '>=10'} + resolution: {integrity: sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==} + engines: {node: '>=12'} dependencies: at-least-node: 1.0.0 graceful-fs: 4.2.8