@flyanra/vue-core 1.2.0 → 1.3.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/dist/types/composables/index.d.ts +4 -3
- package/dist/types/composables/useFeatureGate/index.d.ts +1 -0
- package/dist/types/composables/useFeatureGate/useFeatureGate.d.ts +6 -0
- package/dist/types/composables/useFormHider/index.d.ts +1 -0
- package/dist/types/composables/useFormHider/useFormHider.d.ts +8 -0
- package/dist/types/composables/useLocaleInjector/index.d.ts +2 -0
- package/dist/types/composables/useSidebarActiveIndex/index.d.ts +1 -0
- package/dist/types/composables/{useSidebarActiveIndex.d.ts → useSidebarActiveIndex/useSidebarActiveIndex.d.ts} +1 -1
- package/package.json +158 -158
- package/src/components/basic/fly-button/FlyButton.types.ts +28 -28
- package/src/components/basic/fly-button/FlyButton.vue +178 -178
- package/src/components/basic/typography/FlyCollapseTitleRenderer.vue +46 -46
- package/src/components/feedback/tooltip/FlyInfoTooltip.vue +49 -49
- package/src/components/feedback/tooltip/FlyTooltip.element.scss +4 -4
- package/src/components/feedback/tooltip/FlyTooltip.vue +60 -60
- package/src/components/form/form.utils.ts +72 -72
- package/src/components/form/index.ts +6 -6
- package/src/components/form/input-renderers/boolean/FlyBoolean.vue +48 -48
- package/src/components/form/input-renderers/form-item-renderer/FlyFormItemRenderer.vue +48 -48
- package/src/components/form/input-renderers/form-item-renderer/index.ts +4 -4
- package/src/components/form/input-renderers/form-schema-renderer/FlyFormSchemaRenderer.types.ts +3 -3
- package/src/components/form/input-renderers/form-schema-renderer/FlyFormSchemaRenderer.utils.ts +221 -221
- package/src/components/form/input-renderers/form-schema-renderer/FlyFormSchemaRenderer.vue +75 -75
- package/src/components/form/input-renderers/form-schema-renderer/UseFormSchemaRenderer.ts +97 -97
- package/src/components/form/input-renderers/input-renderer/FlyInputRenderer.vue +49 -49
- package/src/components/form/input-renderers/input-renderer/index.ts +4 -4
- package/src/components/form/input-renderers/input-renderer.utils.ts +18 -18
- package/src/components/form/input-renderers/number/FlyNumber.vue +64 -64
- package/src/components/form/input-renderers/regional-tenant-form-renderer/FlyRegionalTenantFormRenderer.types.ts +15 -15
- package/src/components/form/input-renderers/regional-tenant-form-renderer/FlyRegionalTenantFormRenderer.vue +99 -99
- package/src/components/form/input-renderers/select/FlySelect.scss +1 -1
- package/src/components/form/input-renderers/select/FlySelect.utils.ts +37 -37
- package/src/components/form/input-renderers/text/FlyText.vue +70 -70
- package/src/components/form/input-renderers/value-unit/FlyValueUnit.vue +102 -102
- package/src/components/form/input-validators.ts +99 -99
- package/src/components/general/fly-icon-v2/FlyIconV2.types.ts +6 -6
- package/src/components/general/fly-icon-v2/FlyIconV2.vue +17 -17
- package/src/components/general/fly-icon-v2/index.ts +6 -6
- package/src/components/general/index.ts +5 -5
- package/src/components/index.ts +7 -7
- package/src/components/navigation/menu/fly-mini-sidebar/FlyMiniSidebar.types.ts +8 -8
- package/src/components/navigation/menu/fly-mini-sidebar/FlyMiniSidebarItem.vue +55 -55
- package/src/components/navigation/menu/fly-sidebar/FlySidebar.types.ts +49 -49
- package/src/components/navigation/menu/fly-sidebar/FlySidebar.vue +146 -146
- package/src/components/navigation/menu/fly-sidebar/FlySidebarNode.vue +47 -47
- package/src/composables/index.ts +4 -4
- package/src/composables/useFeatureGate/index.ts +1 -0
- package/src/composables/useFeatureGate/useFeatureGate.ts +19 -0
- package/src/composables/useFormHider/index.ts +1 -0
- package/src/composables/useFormHider/useFormHider.ts +37 -0
- package/src/composables/{UseLocaleInjector.ts → useLocaleInjector/UseLocaleInjector.ts} +37 -37
- package/src/composables/useLocaleInjector/index.ts +2 -0
- package/src/composables/useSidebarActiveIndex/index.ts +1 -0
- package/src/composables/{useSidebarActiveIndex.ts → useSidebarActiveIndex/useSidebarActiveIndex.ts} +103 -103
- package/src/styles/_scss-tokens.scss +71 -71
- package/src/styles/element/mixins/collapse.scss +61 -61
- package/src/styles/element/overrides/form.scss +121 -121
- package/src/styles/element/overrides/message-box.scss +2 -2
- package/src/styles/element/overrides/radio.scss +2 -2
- package/src/styles/element/overrides/select.scss +9 -9
- package/src/styles/index.scss +1 -1
- package/src/styles/tokens.scss +1 -0
- package/src/utils/index.ts +2 -2
- package/src/utils/pure-functions.ts +15 -15
- package/src/utils/validators.ts +81 -81
- /package/dist/types/composables/{UseLocaleInjector.d.ts → useLocaleInjector/UseLocaleInjector.d.ts} +0 -0
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
import { type Ref, computed, ref, watch } from 'vue'
|
|
2
|
-
|
|
3
|
-
import type { FormInstance } from 'element-plus'
|
|
4
|
-
|
|
5
|
-
import { defaultsDeep } from 'lodash-es'
|
|
6
|
-
|
|
7
|
-
import { genericFormValidator } from '../../form.utils'
|
|
8
|
-
import type { T_FormSchemaLookupData, T_InputSchema } from '../form-schema.types'
|
|
9
|
-
import type { T_FormSchemaRendererConfig, T_InputRendererBase } from '../input-renderer.types'
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
generateInputFromFormSchema,
|
|
13
|
-
getValidatorsFromInputFields
|
|
14
|
-
} from './FlyFormSchemaRenderer.utils'
|
|
15
|
-
|
|
16
|
-
export type T_FormSchemaRendererProps = {
|
|
17
|
-
formConfig: T_InputSchema[]
|
|
18
|
-
lookupData?: T_FormSchemaLookupData
|
|
19
|
-
modelValue?: Record<string, unknown>
|
|
20
|
-
disabled?: boolean
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type T_FormSchemaRendererEmits = {
|
|
24
|
-
(e: 'update:modelValue', value: T_FormSchemaRendererProps['modelValue']): void
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
type ConfigFormCompArgs = {
|
|
28
|
-
formRef: Ref<FormInstance | undefined>
|
|
29
|
-
props: T_FormSchemaRendererProps
|
|
30
|
-
emit: T_FormSchemaRendererEmits
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function UseFormSchemaRenderer(args: ConfigFormCompArgs) {
|
|
34
|
-
const fallbackForm = {}
|
|
35
|
-
|
|
36
|
-
const formProxy = computed<Record<string, unknown>>({
|
|
37
|
-
get: () => args.props.modelValue || fallbackForm,
|
|
38
|
-
set: (val) => args.emit('update:modelValue', val)
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
const generatedForm = ref<T_FormSchemaRendererConfig>()
|
|
42
|
-
const dynamicFormGenerated = ref(false)
|
|
43
|
-
|
|
44
|
-
const dynamicValidators = computed(() => {
|
|
45
|
-
const validators =
|
|
46
|
-
generatedForm.value && getValidatorsFromInputFields(generatedForm.value.inputs)
|
|
47
|
-
|
|
48
|
-
return validators || {}
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
async function validateForm() {
|
|
52
|
-
return args.formRef.value && genericFormValidator(args.formRef.value)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function generateDynamicForm() {
|
|
56
|
-
try {
|
|
57
|
-
if (dynamicFormGenerated.value) return
|
|
58
|
-
|
|
59
|
-
const inputs: T_InputRendererBase[] = []
|
|
60
|
-
const baseForm: T_FormSchemaRendererConfig['baseForm'] = {}
|
|
61
|
-
|
|
62
|
-
args.props.formConfig.forEach((f) => {
|
|
63
|
-
const i = generateInputFromFormSchema(f, args.props.lookupData)
|
|
64
|
-
if (i) {
|
|
65
|
-
inputs.push(i)
|
|
66
|
-
baseForm[i.key] = f.default_value
|
|
67
|
-
}
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
dynamicFormGenerated.value = true
|
|
71
|
-
|
|
72
|
-
defaultsDeep(args.props.modelValue, baseForm)
|
|
73
|
-
|
|
74
|
-
generatedForm.value = { inputs, baseForm }
|
|
75
|
-
} catch (error) {
|
|
76
|
-
console.error(error)
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
watch(
|
|
81
|
-
() => args.props.formConfig,
|
|
82
|
-
() => {
|
|
83
|
-
dynamicFormGenerated.value = false
|
|
84
|
-
generateDynamicForm()
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
immediate: true
|
|
88
|
-
}
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
return {
|
|
92
|
-
dynamicValidators,
|
|
93
|
-
formProxy,
|
|
94
|
-
generatedForm,
|
|
95
|
-
validateForm
|
|
96
|
-
}
|
|
97
|
-
}
|
|
1
|
+
import { type Ref, computed, ref, watch } from 'vue'
|
|
2
|
+
|
|
3
|
+
import type { FormInstance } from 'element-plus'
|
|
4
|
+
|
|
5
|
+
import { defaultsDeep } from 'lodash-es'
|
|
6
|
+
|
|
7
|
+
import { genericFormValidator } from '../../form.utils'
|
|
8
|
+
import type { T_FormSchemaLookupData, T_InputSchema } from '../form-schema.types'
|
|
9
|
+
import type { T_FormSchemaRendererConfig, T_InputRendererBase } from '../input-renderer.types'
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
generateInputFromFormSchema,
|
|
13
|
+
getValidatorsFromInputFields
|
|
14
|
+
} from './FlyFormSchemaRenderer.utils'
|
|
15
|
+
|
|
16
|
+
export type T_FormSchemaRendererProps = {
|
|
17
|
+
formConfig: T_InputSchema[]
|
|
18
|
+
lookupData?: T_FormSchemaLookupData
|
|
19
|
+
modelValue?: Record<string, unknown>
|
|
20
|
+
disabled?: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type T_FormSchemaRendererEmits = {
|
|
24
|
+
(e: 'update:modelValue', value: T_FormSchemaRendererProps['modelValue']): void
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type ConfigFormCompArgs = {
|
|
28
|
+
formRef: Ref<FormInstance | undefined>
|
|
29
|
+
props: T_FormSchemaRendererProps
|
|
30
|
+
emit: T_FormSchemaRendererEmits
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function UseFormSchemaRenderer(args: ConfigFormCompArgs) {
|
|
34
|
+
const fallbackForm = {}
|
|
35
|
+
|
|
36
|
+
const formProxy = computed<Record<string, unknown>>({
|
|
37
|
+
get: () => args.props.modelValue || fallbackForm,
|
|
38
|
+
set: (val) => args.emit('update:modelValue', val)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const generatedForm = ref<T_FormSchemaRendererConfig>()
|
|
42
|
+
const dynamicFormGenerated = ref(false)
|
|
43
|
+
|
|
44
|
+
const dynamicValidators = computed(() => {
|
|
45
|
+
const validators =
|
|
46
|
+
generatedForm.value && getValidatorsFromInputFields(generatedForm.value.inputs)
|
|
47
|
+
|
|
48
|
+
return validators || {}
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
async function validateForm() {
|
|
52
|
+
return args.formRef.value && genericFormValidator(args.formRef.value)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function generateDynamicForm() {
|
|
56
|
+
try {
|
|
57
|
+
if (dynamicFormGenerated.value) return
|
|
58
|
+
|
|
59
|
+
const inputs: T_InputRendererBase[] = []
|
|
60
|
+
const baseForm: T_FormSchemaRendererConfig['baseForm'] = {}
|
|
61
|
+
|
|
62
|
+
args.props.formConfig.forEach((f) => {
|
|
63
|
+
const i = generateInputFromFormSchema(f, args.props.lookupData)
|
|
64
|
+
if (i) {
|
|
65
|
+
inputs.push(i)
|
|
66
|
+
baseForm[i.key] = f.default_value
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
dynamicFormGenerated.value = true
|
|
71
|
+
|
|
72
|
+
defaultsDeep(args.props.modelValue, baseForm)
|
|
73
|
+
|
|
74
|
+
generatedForm.value = { inputs, baseForm }
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error(error)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
watch(
|
|
81
|
+
() => args.props.formConfig,
|
|
82
|
+
() => {
|
|
83
|
+
dynamicFormGenerated.value = false
|
|
84
|
+
generateDynamicForm()
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
immediate: true
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
dynamicValidators,
|
|
93
|
+
formProxy,
|
|
94
|
+
generatedForm,
|
|
95
|
+
validateForm
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div style="width: 100%">
|
|
3
|
-
<component
|
|
4
|
-
:is="map[input.type]"
|
|
5
|
-
:model-value="modelValue"
|
|
6
|
-
:input="input"
|
|
7
|
-
@change="(v: unknown) => emit('change', v)"
|
|
8
|
-
@update:model-value="(v: unknown) => emit('update:modelValue', v)"
|
|
9
|
-
@blur="emit('blur')"
|
|
10
|
-
@focus="emit('focus')"
|
|
11
|
-
/>
|
|
12
|
-
</div>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<script setup lang="ts">
|
|
16
|
-
import FlyBoolean from '../boolean/FlyBoolean.vue'
|
|
17
|
-
import FlyDateTime from '../date-time/FlyDateTime.vue'
|
|
18
|
-
import type {
|
|
19
|
-
T_DynamicInputComponent,
|
|
20
|
-
T_InputRendererBase,
|
|
21
|
-
T_InputTypes
|
|
22
|
-
} from '../input-renderer.types'
|
|
23
|
-
import FlyNumber from '../number/FlyNumber.vue'
|
|
24
|
-
import FlySelect from '../select/FlySelect.vue'
|
|
25
|
-
import FlyText from '../text/FlyText.vue'
|
|
26
|
-
import FlyValueUnit from '../value-unit/FlyValueUnit.vue'
|
|
27
|
-
|
|
28
|
-
const emit = defineEmits<{
|
|
29
|
-
(e: 'update:modelValue', v: unknown): void
|
|
30
|
-
(e: 'change', v: unknown): void
|
|
31
|
-
(e: 'blur'): void
|
|
32
|
-
(e: 'focus'): void
|
|
33
|
-
}>()
|
|
34
|
-
|
|
35
|
-
defineProps<{
|
|
36
|
-
modelValue?: unknown
|
|
37
|
-
input: T_InputRendererBase
|
|
38
|
-
}>()
|
|
39
|
-
|
|
40
|
-
const map: Record<T_InputTypes, T_DynamicInputComponent> = {
|
|
41
|
-
text: FlyText,
|
|
42
|
-
textarea: FlyText,
|
|
43
|
-
number: FlyNumber,
|
|
44
|
-
valueUnit: FlyValueUnit,
|
|
45
|
-
select: FlySelect,
|
|
46
|
-
boolean: FlyBoolean,
|
|
47
|
-
dateTime: FlyDateTime
|
|
48
|
-
}
|
|
49
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div style="width: 100%">
|
|
3
|
+
<component
|
|
4
|
+
:is="map[input.type]"
|
|
5
|
+
:model-value="modelValue"
|
|
6
|
+
:input="input"
|
|
7
|
+
@change="(v: unknown) => emit('change', v)"
|
|
8
|
+
@update:model-value="(v: unknown) => emit('update:modelValue', v)"
|
|
9
|
+
@blur="emit('blur')"
|
|
10
|
+
@focus="emit('focus')"
|
|
11
|
+
/>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
import FlyBoolean from '../boolean/FlyBoolean.vue'
|
|
17
|
+
import FlyDateTime from '../date-time/FlyDateTime.vue'
|
|
18
|
+
import type {
|
|
19
|
+
T_DynamicInputComponent,
|
|
20
|
+
T_InputRendererBase,
|
|
21
|
+
T_InputTypes
|
|
22
|
+
} from '../input-renderer.types'
|
|
23
|
+
import FlyNumber from '../number/FlyNumber.vue'
|
|
24
|
+
import FlySelect from '../select/FlySelect.vue'
|
|
25
|
+
import FlyText from '../text/FlyText.vue'
|
|
26
|
+
import FlyValueUnit from '../value-unit/FlyValueUnit.vue'
|
|
27
|
+
|
|
28
|
+
const emit = defineEmits<{
|
|
29
|
+
(e: 'update:modelValue', v: unknown): void
|
|
30
|
+
(e: 'change', v: unknown): void
|
|
31
|
+
(e: 'blur'): void
|
|
32
|
+
(e: 'focus'): void
|
|
33
|
+
}>()
|
|
34
|
+
|
|
35
|
+
defineProps<{
|
|
36
|
+
modelValue?: unknown
|
|
37
|
+
input: T_InputRendererBase
|
|
38
|
+
}>()
|
|
39
|
+
|
|
40
|
+
const map: Record<T_InputTypes, T_DynamicInputComponent> = {
|
|
41
|
+
text: FlyText,
|
|
42
|
+
textarea: FlyText,
|
|
43
|
+
number: FlyNumber,
|
|
44
|
+
valueUnit: FlyValueUnit,
|
|
45
|
+
select: FlySelect,
|
|
46
|
+
boolean: FlyBoolean,
|
|
47
|
+
dateTime: FlyDateTime
|
|
48
|
+
}
|
|
49
|
+
</script>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import FlyInputRenderer from './FlyInputRenderer.vue'
|
|
2
|
-
|
|
3
|
-
export default FlyInputRenderer
|
|
4
|
-
export { FlyInputRenderer }
|
|
1
|
+
import FlyInputRenderer from './FlyInputRenderer.vue'
|
|
2
|
+
|
|
3
|
+
export default FlyInputRenderer
|
|
4
|
+
export { FlyInputRenderer }
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { isNil } from 'lodash-es'
|
|
2
|
-
|
|
3
|
-
import type { T_InputTypes } from './input-renderer.types'
|
|
4
|
-
|
|
5
|
-
export function getInputDisplayValue(v: unknown, inputType: T_InputTypes) {
|
|
6
|
-
switch (inputType) {
|
|
7
|
-
case 'number':
|
|
8
|
-
if (isNil(v)) return ''
|
|
9
|
-
return Number(v)
|
|
10
|
-
|
|
11
|
-
case 'text':
|
|
12
|
-
default:
|
|
13
|
-
if (isNil(v)) {
|
|
14
|
-
return ''
|
|
15
|
-
}
|
|
16
|
-
return String(v)
|
|
17
|
-
}
|
|
18
|
-
}
|
|
1
|
+
import { isNil } from 'lodash-es'
|
|
2
|
+
|
|
3
|
+
import type { T_InputTypes } from './input-renderer.types'
|
|
4
|
+
|
|
5
|
+
export function getInputDisplayValue(v: unknown, inputType: T_InputTypes) {
|
|
6
|
+
switch (inputType) {
|
|
7
|
+
case 'number':
|
|
8
|
+
if (isNil(v)) return ''
|
|
9
|
+
return Number(v)
|
|
10
|
+
|
|
11
|
+
case 'text':
|
|
12
|
+
default:
|
|
13
|
+
if (isNil(v)) {
|
|
14
|
+
return ''
|
|
15
|
+
}
|
|
16
|
+
return String(v)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-input
|
|
3
|
-
v-model.number="inputProxy"
|
|
4
|
-
style="width: 100%"
|
|
5
|
-
type="number"
|
|
6
|
-
v-bind="input?.attrs"
|
|
7
|
-
:placeholder="input?.placeholder"
|
|
8
|
-
@change="(val) => emit('change', displayToNumber(val))"
|
|
9
|
-
@blur="() => emit('blur')"
|
|
10
|
-
@focus="() => emit('focus')"
|
|
11
|
-
>
|
|
12
|
-
</el-input>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<script setup lang="ts">
|
|
16
|
-
import { computed, watch } from 'vue'
|
|
17
|
-
|
|
18
|
-
import { ElInput } from 'element-plus'
|
|
19
|
-
|
|
20
|
-
import { getInputDisplayValue } from '../input-renderer.utils'
|
|
21
|
-
|
|
22
|
-
import './FlyNumber.scss'
|
|
23
|
-
import type { T_InputNumber, T_InputTextValues } from './FlyNumber.types'
|
|
24
|
-
import { displayToNumber } from './FlyNumber.utils'
|
|
25
|
-
|
|
26
|
-
const emit = defineEmits<{
|
|
27
|
-
(e: 'update:modelValue', v: T_InputTextValues): void
|
|
28
|
-
(e: 'change', v: T_InputTextValues): void
|
|
29
|
-
(e: 'blur'): void
|
|
30
|
-
(e: 'focus'): void
|
|
31
|
-
}>()
|
|
32
|
-
|
|
33
|
-
const props = defineProps<{
|
|
34
|
-
modelValue?: unknown
|
|
35
|
-
input?: T_InputNumber
|
|
36
|
-
}>()
|
|
37
|
-
|
|
38
|
-
const inputProxy = computed({
|
|
39
|
-
get: () => {
|
|
40
|
-
return getInputDisplayValue(props.modelValue, 'number')
|
|
41
|
-
},
|
|
42
|
-
set: (v) => {
|
|
43
|
-
const parsed = displayToNumber(v)
|
|
44
|
-
|
|
45
|
-
emit('update:modelValue', parsed)
|
|
46
|
-
emit('change', parsed)
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
watch(
|
|
51
|
-
() => props.modelValue,
|
|
52
|
-
() => {
|
|
53
|
-
const parsed = displayToNumber(props.modelValue)
|
|
54
|
-
|
|
55
|
-
if (parsed !== props.modelValue) {
|
|
56
|
-
emit('update:modelValue', parsed)
|
|
57
|
-
emit('change', parsed)
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
immediate: true
|
|
62
|
-
}
|
|
63
|
-
)
|
|
64
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<el-input
|
|
3
|
+
v-model.number="inputProxy"
|
|
4
|
+
style="width: 100%"
|
|
5
|
+
type="number"
|
|
6
|
+
v-bind="input?.attrs"
|
|
7
|
+
:placeholder="input?.placeholder"
|
|
8
|
+
@change="(val) => emit('change', displayToNumber(val))"
|
|
9
|
+
@blur="() => emit('blur')"
|
|
10
|
+
@focus="() => emit('focus')"
|
|
11
|
+
>
|
|
12
|
+
</el-input>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
import { computed, watch } from 'vue'
|
|
17
|
+
|
|
18
|
+
import { ElInput } from 'element-plus'
|
|
19
|
+
|
|
20
|
+
import { getInputDisplayValue } from '../input-renderer.utils'
|
|
21
|
+
|
|
22
|
+
import './FlyNumber.scss'
|
|
23
|
+
import type { T_InputNumber, T_InputTextValues } from './FlyNumber.types'
|
|
24
|
+
import { displayToNumber } from './FlyNumber.utils'
|
|
25
|
+
|
|
26
|
+
const emit = defineEmits<{
|
|
27
|
+
(e: 'update:modelValue', v: T_InputTextValues): void
|
|
28
|
+
(e: 'change', v: T_InputTextValues): void
|
|
29
|
+
(e: 'blur'): void
|
|
30
|
+
(e: 'focus'): void
|
|
31
|
+
}>()
|
|
32
|
+
|
|
33
|
+
const props = defineProps<{
|
|
34
|
+
modelValue?: unknown
|
|
35
|
+
input?: T_InputNumber
|
|
36
|
+
}>()
|
|
37
|
+
|
|
38
|
+
const inputProxy = computed({
|
|
39
|
+
get: () => {
|
|
40
|
+
return getInputDisplayValue(props.modelValue, 'number')
|
|
41
|
+
},
|
|
42
|
+
set: (v) => {
|
|
43
|
+
const parsed = displayToNumber(v)
|
|
44
|
+
|
|
45
|
+
emit('update:modelValue', parsed)
|
|
46
|
+
emit('change', parsed)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
watch(
|
|
51
|
+
() => props.modelValue,
|
|
52
|
+
() => {
|
|
53
|
+
const parsed = displayToNumber(props.modelValue)
|
|
54
|
+
|
|
55
|
+
if (parsed !== props.modelValue) {
|
|
56
|
+
emit('update:modelValue', parsed)
|
|
57
|
+
emit('change', parsed)
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
immediate: true
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
</script>
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { T_FormSchemaLookupData, T_InputSchema } from '../form-schema.types'
|
|
2
|
-
|
|
3
|
-
export type T_TenantRegionalFormSection = {
|
|
4
|
-
key: string
|
|
5
|
-
fields: T_InputSchema[]
|
|
6
|
-
title: string
|
|
7
|
-
description?: string
|
|
8
|
-
lookupData?: T_FormSchemaLookupData
|
|
9
|
-
modelValue?: Record<string, unknown>
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type T_TenantRegionalFormProps = {
|
|
13
|
-
mainFormTitle: string
|
|
14
|
-
sections?: T_TenantRegionalFormSection[]
|
|
15
|
-
}
|
|
1
|
+
import type { T_FormSchemaLookupData, T_InputSchema } from '../form-schema.types'
|
|
2
|
+
|
|
3
|
+
export type T_TenantRegionalFormSection = {
|
|
4
|
+
key: string
|
|
5
|
+
fields: T_InputSchema[]
|
|
6
|
+
title: string
|
|
7
|
+
description?: string
|
|
8
|
+
lookupData?: T_FormSchemaLookupData
|
|
9
|
+
modelValue?: Record<string, unknown>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type T_TenantRegionalFormProps = {
|
|
13
|
+
mainFormTitle: string
|
|
14
|
+
sections?: T_TenantRegionalFormSection[]
|
|
15
|
+
}
|