Skip to content

Commit c44e95d

Browse files
committedJun 26, 2024·
releases 4.0.36
1 parent 5fbe5a4 commit c44e95d

File tree

7 files changed

+92
-34
lines changed

7 files changed

+92
-34
lines changed
 

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vxe-pc-ui",
3-
"version": "4.0.35",
3+
"version": "4.0.36",
44
"description": "A vue based PC component library",
55
"scripts": {
66
"update": "npm install --legacy-peer-deps",

‎packages/form-design/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
import { App } from 'vue'
22
import { VxeUI } from '@vxe-ui/core'
33
import VxeFormDesignComponent from './src/form-design'
4+
import { useWidgetView } from './src/use'
45
import { dynamicApp } from '../dynamics'
56
import './render'
67

8+
import { FormDesignExport } from '../../types'
9+
710
export const VxeFormDesign = Object.assign({}, VxeFormDesignComponent, {
811
install (app: App) {
912
app.component(VxeFormDesignComponent.name as string, VxeFormDesignComponent)
1013
}
1114
})
1215

16+
const formDesign: FormDesignExport = {
17+
useWidgetView
18+
}
19+
1320
dynamicApp.component(VxeFormDesignComponent.name as string, VxeFormDesignComponent)
1421
VxeUI.component(VxeFormDesignComponent)
22+
VxeUI.formDesign = formDesign
1523

1624
export const FormDesign = VxeFormDesign
1725
export default VxeFormDesign

‎packages/form-design/src/use.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { computed } from 'vue'
2+
3+
import type { VxeFormDesignDefines } from '../../../types'
4+
5+
export function useWidgetView <T = any> (props: {
6+
renderOpts: any
7+
renderParams: any
8+
}) {
9+
const currWidget = computed<VxeFormDesignDefines.WidgetObjItem<T>>(() => {
10+
const { renderParams } = props
11+
return renderParams.widget
12+
})
13+
14+
const widgetModel = computed({
15+
get () {
16+
const { renderParams } = props
17+
const { $formView, widget } = renderParams
18+
return $formView ? $formView.getItemValue(widget) : null
19+
},
20+
set (value) {
21+
const { renderParams } = props
22+
const { $formView, widget } = renderParams
23+
if ($formView) {
24+
$formView.setItemValue(widget, value)
25+
}
26+
}
27+
})
28+
29+
return {
30+
currWidget,
31+
widgetModel
32+
}
33+
}

‎packages/number-input/src/number-input.ts

+29-31
Original file line numberDiff line numberDiff line change
@@ -583,37 +583,35 @@ export default defineComponent({
583583
const { inputValue } = reactData
584584
const suffixSlot = slots.suffix
585585
const isClearable = computeIsClearable.value
586-
return isClearable || suffixSlot || suffixIcon
587-
? h('div', {
588-
class: ['vxe-number-input--suffix', {
589-
'is--clear': isClearable && !disabled && !(inputValue === '' || XEUtils.eqNull(inputValue))
590-
}]
591-
}, [
592-
isClearable
593-
? h('div', {
594-
class: 'vxe-number-input--clear-icon',
595-
onClick: clearValueEvent
596-
}, [
597-
h('i', {
598-
class: getIcon().INPUT_CLEAR
599-
})
600-
])
601-
: createCommentVNode(),
602-
renderExtraSuffixIcon(),
603-
suffixSlot || suffixIcon
604-
? h('div', {
605-
class: 'vxe-number-input--suffix-icon',
606-
onClick: clickSuffixEvent
607-
}, suffixSlot
608-
? getSlotVNs(suffixSlot({}))
609-
: [
610-
h('i', {
611-
class: suffixIcon
612-
})
613-
])
614-
: createCommentVNode()
615-
])
616-
: null
586+
return h('div', {
587+
class: ['vxe-number-input--suffix', {
588+
'is--clear': isClearable && !disabled && !(inputValue === '' || XEUtils.eqNull(inputValue))
589+
}]
590+
}, [
591+
isClearable
592+
? h('div', {
593+
class: 'vxe-number-input--clear-icon',
594+
onClick: clearValueEvent
595+
}, [
596+
h('i', {
597+
class: getIcon().INPUT_CLEAR
598+
})
599+
])
600+
: createCommentVNode(),
601+
renderExtraSuffixIcon(),
602+
suffixSlot || suffixIcon
603+
? h('div', {
604+
class: 'vxe-number-input--suffix-icon',
605+
onClick: clickSuffixEvent
606+
}, suffixSlot
607+
? getSlotVNs(suffixSlot({}))
608+
: [
609+
h('i', {
610+
class: suffixIcon
611+
})
612+
])
613+
: createCommentVNode()
614+
])
617615
}
618616

619617
const renderExtraSuffixIcon = () => {

‎packages/textarea/src/textarea.ts

+5
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ export default defineComponent({
202202
updateAutoTxt()
203203
})
204204

205+
watch(computeSizeOpts, () => {
206+
updateAutoTxt()
207+
handleResize()
208+
})
209+
205210
nextTick(() => {
206211
const { autosize } = props
207212
if (autosize) {

‎types/components/form-design.d.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { RenderFunction, SetupContext, Ref, ComponentPublicInstance, DefineComponent, UnwrapNestedRefs } from 'vue'
2-
import { defineVxeComponent, VxeComponentBaseOptions, VxeComponentEventParams, VxeComponentSizeType, ValueOf } from '@vxe-ui/core'
1+
import { RenderFunction, SetupContext, Ref, ComputedRef, WritableComputedRef, ComponentPublicInstance, DefineComponent, UnwrapNestedRefs } from 'vue'
2+
import { defineVxeComponent, VxeComponentBaseOptions, VxeComponentEventParams, VxeComponentSizeType, ValueOf, VxeGlobalRendererHandles } from '@vxe-ui/core'
33
import { VxeFormPropTypes } from '../components/form'
44

55
/* eslint-disable no-use-before-define,@typescript-eslint/ban-types */
@@ -176,5 +176,15 @@ export namespace VxeFormDesignSlotTypes {}
176176
export interface VxeFormDesignSlots {
177177
}
178178

179+
export interface FormDesignExport {
180+
useWidgetView<T = any>(props: {
181+
renderOpts: any
182+
renderParams: any
183+
}): {
184+
currWidget: ComputedRef<VxeFormDesignDefines.WidgetObjItem<T>>,
185+
widgetModel: WritableComputedRef<any>
186+
}
187+
}
188+
179189
export const FormDesign: typeof VxeFormDesign
180190
export default VxeFormDesign

‎types/ui/index.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { DrawerController } from '../components/drawer'
55
import { VxePrintDefines } from '../components/print'
66
import { VxeUploadDefines } from '../components/upload'
77
import { VxeImageDefines } from '../components/image'
8+
import { FormDesignExport } from '../components/form-design'
89

910
/**
1011
* 已废弃,请使用 setConfig
@@ -48,6 +49,9 @@ declare module '@vxe-ui/core' {
4849
modal: ModalController
4950
drawer: DrawerController
5051
dynamicApp: App<Element>
52+
53+
formDesign: FormDesignExport
54+
5155
print: VxePrintDefines.PrintFunction
5256
saveFile: VxeUploadDefines.SaveFileFunction
5357
readFile: VxeUploadDefines.ReadFileFunction

0 commit comments

Comments
 (0)
Please sign in to comment.