@flyanra/vue-core 0.4.0 → 0.4.2
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/README.md +176 -176
- package/package.json +137 -138
- package/src/components/basic/fly-button/FlyButton.element.scss +3 -3
- package/src/components/basic/fly-button/FlyButton.mixins.scss +58 -58
- package/src/components/basic/fly-button/FlyButton.types.ts +29 -29
- package/src/components/basic/fly-button/FlyButton.vue +180 -180
- package/src/components/basic/fly-button/index.ts +11 -11
- package/src/components/basic/index.ts +2 -2
- package/src/components/basic/typography/FlyCollapseTitleRenderer.vue +46 -46
- package/src/components/feedback/index.ts +2 -2
- package/src/components/feedback/tooltip/FlyInfoTooltip.vue +48 -48
- package/src/components/feedback/tooltip/FlyTooltip.element.scss +4 -4
- package/src/components/feedback/tooltip/FlyTooltip.types.ts +5 -5
- package/src/components/feedback/tooltip/FlyTooltip.vue +60 -60
- package/src/components/feedback/tooltip/index.ts +6 -6
- package/src/components/form/form.utils.ts +57 -57
- package/src/components/form/input-renderers/boolean/FlyBoolean.scss +1 -1
- package/src/components/form/input-renderers/boolean/FlyBoolean.types.ts +16 -16
- package/src/components/form/input-renderers/boolean/FlyBoolean.vue +35 -35
- package/src/components/form/input-renderers/date-time/FlyDateTime.scss +1 -1
- package/src/components/form/input-renderers/date-time/FlyDateTime.types.ts +21 -21
- package/src/components/form/input-renderers/date-time/FlyDateTime.vue +85 -85
- package/src/components/form/input-renderers/form-item-renderer/FlyFormItemRenderer.scss +4 -4
- package/src/components/form/input-renderers/form-item-renderer/FlyFormItemRenderer.vue +48 -48
- 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 +246 -246
- 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/form-schema.types.ts +95 -95
- package/src/components/form/input-renderers/input-renderer/FlyInputRenderer.vue +49 -49
- package/src/components/form/input-renderers/input-renderer.types.ts +49 -49
- package/src/components/form/input-renderers/input-renderer.utils.ts +18 -18
- package/src/components/form/input-renderers/number/FlyNumber.scss +1 -1
- package/src/components/form/input-renderers/number/FlyNumber.types.ts +13 -13
- package/src/components/form/input-renderers/number/FlyNumber.utils.ts +6 -6
- package/src/components/form/input-renderers/number/FlyNumber.vue +48 -48
- 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.types.ts +25 -25
- package/src/components/form/input-renderers/select/FlySelect.utils.ts +37 -37
- package/src/components/form/input-renderers/select/FlySelect.vue +48 -48
- package/src/components/form/input-renderers/text/FlyText.scss +1 -1
- package/src/components/form/input-renderers/text/FlyText.types.ts +20 -20
- package/src/components/form/input-renderers/text/FlyText.vue +56 -56
- package/src/components/form/input-renderers/value-unit/FlyValueUnit.scss +2 -2
- package/src/components/form/input-renderers/value-unit/FlyValueUnit.types.ts +28 -28
- package/src/components/form/input-renderers/value-unit/FlyValueUnit.vue +101 -101
- package/src/components/form/input-validators.ts +121 -121
- package/src/components/general/fly-icon/FlyIcon.types.ts +12 -12
- package/src/components/general/fly-icon/FlyIcon.vue +24 -24
- package/src/components/general/fly-icon/index.ts +6 -6
- package/src/components/general/index.ts +2 -2
- package/src/components/index.ts +5 -5
- package/src/components/navigation/fly-steps/FlySteps.element.scss +100 -100
- package/src/components/navigation/fly-steps/FlySteps.types.ts +10 -10
- package/src/components/navigation/fly-steps/FlySteps.vue +30 -30
- package/src/components/navigation/fly-steps/index.ts +6 -6
- package/src/components/navigation/index.ts +2 -2
- package/src/components/navigation/menu/fly-mini-sidebar/FlyMiniSidebar.element.scss +2 -2
- package/src/components/navigation/menu/fly-mini-sidebar/FlyMiniSidebar.types.ts +8 -8
- package/src/components/navigation/menu/fly-mini-sidebar/FlyMiniSidebar.vue +46 -46
- package/src/components/navigation/menu/fly-mini-sidebar/FlyMiniSidebarItem.vue +55 -55
- package/src/components/navigation/menu/fly-mini-sidebar/index.ts +6 -6
- package/src/components/navigation/menu/fly-sidebar/FlySidebar.element.scss +9 -9
- package/src/components/navigation/menu/fly-sidebar/FlySidebar.types.ts +36 -36
- package/src/components/navigation/menu/fly-sidebar/FlySidebar.vue +150 -150
- package/src/components/navigation/menu/fly-sidebar/FlySidebarNode.vue +47 -47
- package/src/components/navigation/menu/fly-sidebar/index.ts +12 -12
- package/src/components/navigation/menu/index.ts +5 -5
- package/src/index.ts +1 -1
- package/src/styles/_scss-tokens.scss +76 -76
- package/src/styles/core/animations.scss +40 -40
- package/src/styles/core/index.scss +36 -36
- package/src/styles/core/scrollbar.scss +36 -36
- package/src/styles/core/typography-utils.scss +9 -9
- package/src/styles/element/common.scss +56 -56
- package/src/styles/element/dark.scss +38 -38
- package/src/styles/element/mixins/collapse.scss +61 -61
- package/src/styles/element/mixins/dialog.scss +101 -101
- package/src/styles/element/overrides/alerts.scss +28 -28
- package/src/styles/element/overrides/badge.scss +6 -6
- package/src/styles/element/overrides/cascader.scss +2 -2
- package/src/styles/element/overrides/collapse.scss +2 -2
- package/src/styles/element/overrides/date-time.scss +11 -11
- package/src/styles/element/overrides/dialog.scss +2 -2
- package/src/styles/element/overrides/dropdown.scss +11 -11
- package/src/styles/element/overrides/form.scss +105 -105
- package/src/styles/element/overrides/message-box.scss +2 -2
- package/src/styles/element/overrides/message.scss +39 -39
- package/src/styles/element/overrides/notification.scss +46 -46
- package/src/styles/element/overrides/radio.scss +2 -2
- package/src/styles/element/overrides/segmented.scss +17 -17
- package/src/styles/element/overrides/select.scss +9 -9
- package/src/styles/element/overrides/table.scss +2 -2
- package/src/styles/element/overrides/tag.scss +19 -19
- package/src/styles/index.d.ts +1 -1
- package/src/styles/index.scss +5 -5
- package/src/styles/mixins/shadows.scss +15 -15
- package/src/styles/tokens.scss +84 -83
- package/dist/types/components/basic/fly-button/FlyButton.types.d.ts +0 -25
- package/dist/types/components/basic/fly-button/FlyButton.vue.d.ts +0 -26
- package/dist/types/components/basic/fly-button/index.d.ts +0 -4
- package/dist/types/components/basic/index.d.ts +0 -2
- package/dist/types/components/basic/typography/FlyCollapseTitleRenderer.vue.d.ts +0 -16
- package/dist/types/components/feedback/index.d.ts +0 -2
- package/dist/types/components/feedback/tooltip/FlyInfoTooltip.vue.d.ts +0 -36
- package/dist/types/components/feedback/tooltip/FlyTooltip.types.d.ts +0 -4
- package/dist/types/components/feedback/tooltip/FlyTooltip.vue.d.ts +0 -17
- package/dist/types/components/feedback/tooltip/index.d.ts +0 -4
- package/dist/types/components/form/form.utils.d.ts +0 -10
- package/dist/types/components/form/index.d.ts +0 -1
- package/dist/types/components/form/input-renderers/boolean/FlyBoolean.types.d.ts +0 -14
- package/dist/types/components/form/input-renderers/boolean/FlyBoolean.vue.d.ts +0 -15
- package/dist/types/components/form/input-renderers/date-time/FlyDateTime.types.d.ts +0 -20
- package/dist/types/components/form/input-renderers/date-time/FlyDateTime.vue.d.ts +0 -19
- package/dist/types/components/form/input-renderers/form-item-renderer/FlyFormItemRenderer.vue.d.ts +0 -19
- package/dist/types/components/form/input-renderers/form-schema-renderer/FlyFormSchemaRenderer.types.d.ts +0 -2
- package/dist/types/components/form/input-renderers/form-schema-renderer/FlyFormSchemaRenderer.utils.d.ts +0 -23
- package/dist/types/components/form/input-renderers/form-schema-renderer/FlyFormSchemaRenderer.vue.d.ts +0 -17
- package/dist/types/components/form/input-renderers/form-schema-renderer/UseFormSchemaRenderer.d.ts +0 -25
- package/dist/types/components/form/input-renderers/form-schema.types.d.ts +0 -77
- package/dist/types/components/form/input-renderers/input-renderer/FlyInputRenderer.vue.d.ts +0 -18
- package/dist/types/components/form/input-renderers/input-renderer.types.d.ts +0 -30
- package/dist/types/components/form/input-renderers/input-renderer.utils.d.ts +0 -2
- package/dist/types/components/form/input-renderers/number/FlyNumber.types.d.ts +0 -13
- package/dist/types/components/form/input-renderers/number/FlyNumber.utils.d.ts +0 -1
- package/dist/types/components/form/input-renderers/number/FlyNumber.vue.d.ts +0 -19
- package/dist/types/components/form/input-renderers/regional-tenant-form-renderer/FlyRegionalTenantFormRenderer.types.d.ts +0 -13
- package/dist/types/components/form/input-renderers/regional-tenant-form-renderer/FlyRegionalTenantFormRenderer.vue.d.ts +0 -20
- package/dist/types/components/form/input-renderers/select/FlySelect.types.d.ts +0 -22
- package/dist/types/components/form/input-renderers/select/FlySelect.utils.d.ts +0 -2
- package/dist/types/components/form/input-renderers/select/FlySelect.vue.d.ts +0 -19
- package/dist/types/components/form/input-renderers/text/FlyText.types.d.ts +0 -18
- package/dist/types/components/form/input-renderers/text/FlyText.vue.d.ts +0 -19
- package/dist/types/components/form/input-renderers/value-unit/FlyValueUnit.types.d.ts +0 -23
- package/dist/types/components/form/input-renderers/value-unit/FlyValueUnit.vue.d.ts +0 -19
- package/dist/types/components/form/input-validators.d.ts +0 -13
- package/dist/types/components/general/fly-icon/FlyIcon.types.d.ts +0 -7
- package/dist/types/components/general/fly-icon/FlyIcon.vue.d.ts +0 -6
- package/dist/types/components/general/fly-icon/index.d.ts +0 -4
- package/dist/types/components/general/index.d.ts +0 -2
- package/dist/types/components/index.d.ts +0 -4
- package/dist/types/components/navigation/fly-steps/FlySteps.types.d.ts +0 -9
- package/dist/types/components/navigation/fly-steps/FlySteps.vue.d.ts +0 -9
- package/dist/types/components/navigation/fly-steps/index.d.ts +0 -4
- package/dist/types/components/navigation/index.d.ts +0 -2
- package/dist/types/components/navigation/menu/fly-mini-sidebar/FlyMiniSidebar.types.d.ts +0 -7
- package/dist/types/components/navigation/menu/fly-mini-sidebar/FlyMiniSidebar.vue.d.ts +0 -8
- package/dist/types/components/navigation/menu/fly-mini-sidebar/FlyMiniSidebarItem.vue.d.ts +0 -7
- package/dist/types/components/navigation/menu/fly-mini-sidebar/index.d.ts +0 -4
- package/dist/types/components/navigation/menu/fly-sidebar/FlySidebar.types.d.ts +0 -29
- package/dist/types/components/navigation/menu/fly-sidebar/FlySidebar.vue.d.ts +0 -8
- package/dist/types/components/navigation/menu/fly-sidebar/FlySidebarNode.vue.d.ts +0 -7
- package/dist/types/components/navigation/menu/fly-sidebar/index.d.ts +0 -4
- package/dist/types/components/navigation/menu/index.d.ts +0 -4
- package/dist/types/composables/UseLocaleInjector.d.ts +0 -6
- package/dist/types/index.d.ts +0 -1
- package/dist/types/types/index.d.ts +0 -1
- package/dist/types/utils/pure-functions.d.ts +0 -1
- package/dist/types/utils/validators.d.ts +0 -9
|
@@ -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'
|
|
6
|
-
|
|
7
|
-
import type { T_FormSchemaLookupData, T_InputSchema } from '../form-schema.types'
|
|
8
|
-
import type { T_FormSchemaRendererConfig, T_InputRendererBase } from '../input-renderer.types'
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
generateInputFromFormSchema,
|
|
12
|
-
genericFormValidator,
|
|
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'
|
|
6
|
+
|
|
7
|
+
import type { T_FormSchemaLookupData, T_InputSchema } from '../form-schema.types'
|
|
8
|
+
import type { T_FormSchemaRendererConfig, T_InputRendererBase } from '../input-renderer.types'
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
generateInputFromFormSchema,
|
|
12
|
+
genericFormValidator,
|
|
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,95 +1,95 @@
|
|
|
1
|
-
import type { T_DateInputTypes } from './date-time/FlyDateTime.types'
|
|
2
|
-
import type { T_InputSelectOption } from './select/FlySelect.types'
|
|
3
|
-
import type { T_ValueUnitValue } from './value-unit/FlyValueUnit.types'
|
|
4
|
-
|
|
5
|
-
export type T_FormSchemaLookupData = Record<string, Array<unknown>>
|
|
6
|
-
|
|
7
|
-
export type T_InputSchema =
|
|
8
|
-
| T_InputSchemaText
|
|
9
|
-
| T_InputSchemaNumber
|
|
10
|
-
| T_InputSchemaBoolean
|
|
11
|
-
| T_InputSchemaSelect
|
|
12
|
-
| T_InputSchemaValueUnit
|
|
13
|
-
| T_InputSchemaDateTime
|
|
14
|
-
|
|
15
|
-
type T_FieldValidationBase = {
|
|
16
|
-
required?: boolean
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
type T_InputSchemaBase<ValidationRules = object> = {
|
|
20
|
-
unique_key: string
|
|
21
|
-
label: string
|
|
22
|
-
tooltip?: string
|
|
23
|
-
placeholder?: string
|
|
24
|
-
validation?: T_FieldValidationBase & ValidationRules
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export type T_InputSchemaText = T_InputSchemaBase<{
|
|
28
|
-
minLength?: number
|
|
29
|
-
maxLength?: number
|
|
30
|
-
}> & {
|
|
31
|
-
type: 'text'
|
|
32
|
-
default_value?: string
|
|
33
|
-
config?: {
|
|
34
|
-
maxLength?: number
|
|
35
|
-
minLength?: number
|
|
36
|
-
type?: string
|
|
37
|
-
rows?: number
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export type T_InputSchemaNumber = T_InputSchemaBase<{
|
|
42
|
-
minLength?: number
|
|
43
|
-
maxLength?: number
|
|
44
|
-
}> & {
|
|
45
|
-
type: 'number'
|
|
46
|
-
default_value?: number
|
|
47
|
-
config?: {
|
|
48
|
-
minLength?: number
|
|
49
|
-
maxLength?: number
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export type T_InputSchemaBoolean = T_InputSchemaBase & {
|
|
54
|
-
type: 'boolean'
|
|
55
|
-
default_value?: boolean
|
|
56
|
-
config?: {
|
|
57
|
-
activeText?: string
|
|
58
|
-
inactiveText?: string
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
type T_SelectOptions =
|
|
63
|
-
| {
|
|
64
|
-
options_config_Lookup_id: string
|
|
65
|
-
options?: never
|
|
66
|
-
}
|
|
67
|
-
| {
|
|
68
|
-
options?: T_InputSelectOption[]
|
|
69
|
-
options_config_Lookup_id?: never
|
|
70
|
-
}
|
|
71
|
-
type T_SelectBase<M extends boolean | undefined> = T_InputSchemaBase & {
|
|
72
|
-
type: 'select'
|
|
73
|
-
config: T_SelectOptions & {
|
|
74
|
-
multiple?: M
|
|
75
|
-
}
|
|
76
|
-
default_value?: M extends true ? (string | number)[] : string | number
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export type T_InputSchemaSelect = T_SelectBase<true> | T_SelectBase<false | undefined>
|
|
80
|
-
|
|
81
|
-
export type T_InputSchemaValueUnit = T_InputSchemaBase & {
|
|
82
|
-
type: 'valueUnit'
|
|
83
|
-
config: T_SelectOptions & {
|
|
84
|
-
valueType?: 'text' | 'number'
|
|
85
|
-
}
|
|
86
|
-
default_value?: T_ValueUnitValue
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export type T_InputSchemaDateTime = T_InputSchemaBase & {
|
|
90
|
-
type: 'dateTime'
|
|
91
|
-
default_value?: string | [string | string]
|
|
92
|
-
config?: {
|
|
93
|
-
inputType: T_DateInputTypes
|
|
94
|
-
}
|
|
95
|
-
}
|
|
1
|
+
import type { T_DateInputTypes } from './date-time/FlyDateTime.types'
|
|
2
|
+
import type { T_InputSelectOption } from './select/FlySelect.types'
|
|
3
|
+
import type { T_ValueUnitValue } from './value-unit/FlyValueUnit.types'
|
|
4
|
+
|
|
5
|
+
export type T_FormSchemaLookupData = Record<string, Array<unknown>>
|
|
6
|
+
|
|
7
|
+
export type T_InputSchema =
|
|
8
|
+
| T_InputSchemaText
|
|
9
|
+
| T_InputSchemaNumber
|
|
10
|
+
| T_InputSchemaBoolean
|
|
11
|
+
| T_InputSchemaSelect
|
|
12
|
+
| T_InputSchemaValueUnit
|
|
13
|
+
| T_InputSchemaDateTime
|
|
14
|
+
|
|
15
|
+
type T_FieldValidationBase = {
|
|
16
|
+
required?: boolean
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type T_InputSchemaBase<ValidationRules = object> = {
|
|
20
|
+
unique_key: string
|
|
21
|
+
label: string
|
|
22
|
+
tooltip?: string
|
|
23
|
+
placeholder?: string
|
|
24
|
+
validation?: T_FieldValidationBase & ValidationRules
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type T_InputSchemaText = T_InputSchemaBase<{
|
|
28
|
+
minLength?: number
|
|
29
|
+
maxLength?: number
|
|
30
|
+
}> & {
|
|
31
|
+
type: 'text'
|
|
32
|
+
default_value?: string
|
|
33
|
+
config?: {
|
|
34
|
+
maxLength?: number
|
|
35
|
+
minLength?: number
|
|
36
|
+
type?: string
|
|
37
|
+
rows?: number
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type T_InputSchemaNumber = T_InputSchemaBase<{
|
|
42
|
+
minLength?: number
|
|
43
|
+
maxLength?: number
|
|
44
|
+
}> & {
|
|
45
|
+
type: 'number'
|
|
46
|
+
default_value?: number
|
|
47
|
+
config?: {
|
|
48
|
+
minLength?: number
|
|
49
|
+
maxLength?: number
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type T_InputSchemaBoolean = T_InputSchemaBase & {
|
|
54
|
+
type: 'boolean'
|
|
55
|
+
default_value?: boolean
|
|
56
|
+
config?: {
|
|
57
|
+
activeText?: string
|
|
58
|
+
inactiveText?: string
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
type T_SelectOptions =
|
|
63
|
+
| {
|
|
64
|
+
options_config_Lookup_id: string
|
|
65
|
+
options?: never
|
|
66
|
+
}
|
|
67
|
+
| {
|
|
68
|
+
options?: T_InputSelectOption[]
|
|
69
|
+
options_config_Lookup_id?: never
|
|
70
|
+
}
|
|
71
|
+
type T_SelectBase<M extends boolean | undefined> = T_InputSchemaBase & {
|
|
72
|
+
type: 'select'
|
|
73
|
+
config: T_SelectOptions & {
|
|
74
|
+
multiple?: M
|
|
75
|
+
}
|
|
76
|
+
default_value?: M extends true ? (string | number)[] : string | number
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type T_InputSchemaSelect = T_SelectBase<true> | T_SelectBase<false | undefined>
|
|
80
|
+
|
|
81
|
+
export type T_InputSchemaValueUnit = T_InputSchemaBase & {
|
|
82
|
+
type: 'valueUnit'
|
|
83
|
+
config: T_SelectOptions & {
|
|
84
|
+
valueType?: 'text' | 'number'
|
|
85
|
+
}
|
|
86
|
+
default_value?: T_ValueUnitValue
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type T_InputSchemaDateTime = T_InputSchemaBase & {
|
|
90
|
+
type: 'dateTime'
|
|
91
|
+
default_value?: string | [string | string]
|
|
92
|
+
config?: {
|
|
93
|
+
inputType: T_DateInputTypes
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -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,49 +1,49 @@
|
|
|
1
|
-
import type { Component } from 'vue'
|
|
2
|
-
|
|
3
|
-
import type { FormItemRule } from 'element-plus'
|
|
4
|
-
|
|
5
|
-
import type { T_InputBoolean, T_InputBooleanBase } from './boolean/FlyBoolean.types'
|
|
6
|
-
import type { T_InputDateTime, T_InputDateTimeBase } from './date-time/FlyDateTime.types'
|
|
7
|
-
import type { T_InputNumber, T_InputNumberBase } from './number/FlyNumber.types'
|
|
8
|
-
import type { T_InputSelect, T_InputSelectBase } from './select/FlySelect.types'
|
|
9
|
-
import type { T_InputText, T_InputTextBase } from './text/FlyText.types'
|
|
10
|
-
import type { T_InputValueUnit, T_InputValueUnitBase } from './value-unit/FlyValueUnit.types'
|
|
11
|
-
|
|
12
|
-
export type T_DynamicInputPropsBase = {
|
|
13
|
-
key: string
|
|
14
|
-
prop?: string // for form validation. falls back to key
|
|
15
|
-
label: string
|
|
16
|
-
tooltip?: string
|
|
17
|
-
columnSpan?: number
|
|
18
|
-
validations?: FormItemRule[]
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type T_InputRendererBase = T_DynamicInputPropsBase & T_SupportedInputTypeBase
|
|
22
|
-
|
|
23
|
-
export type T_SupportedInputTypeBase =
|
|
24
|
-
| T_InputTextBase
|
|
25
|
-
| T_InputBooleanBase
|
|
26
|
-
| T_InputDateTimeBase
|
|
27
|
-
| T_InputNumberBase
|
|
28
|
-
| T_InputSelectBase
|
|
29
|
-
| T_InputValueUnitBase
|
|
30
|
-
|
|
31
|
-
export type T_SupportedInputType =
|
|
32
|
-
| T_InputText
|
|
33
|
-
| T_InputNumber
|
|
34
|
-
| T_InputValueUnit
|
|
35
|
-
| T_InputSelect
|
|
36
|
-
| T_InputBoolean
|
|
37
|
-
| T_InputDateTime
|
|
38
|
-
|
|
39
|
-
export type T_InputTypes = T_SupportedInputTypeBase['type']
|
|
40
|
-
|
|
41
|
-
export type T_DynamicInputComponent = Component<{
|
|
42
|
-
modelValue?: unknown
|
|
43
|
-
input?: T_SupportedInputType
|
|
44
|
-
}>
|
|
45
|
-
|
|
46
|
-
export type T_FormSchemaRendererConfig = {
|
|
47
|
-
inputs: T_InputRendererBase[]
|
|
48
|
-
baseForm: { [K: string]: unknown }
|
|
49
|
-
}
|
|
1
|
+
import type { Component } from 'vue'
|
|
2
|
+
|
|
3
|
+
import type { FormItemRule } from 'element-plus'
|
|
4
|
+
|
|
5
|
+
import type { T_InputBoolean, T_InputBooleanBase } from './boolean/FlyBoolean.types'
|
|
6
|
+
import type { T_InputDateTime, T_InputDateTimeBase } from './date-time/FlyDateTime.types'
|
|
7
|
+
import type { T_InputNumber, T_InputNumberBase } from './number/FlyNumber.types'
|
|
8
|
+
import type { T_InputSelect, T_InputSelectBase } from './select/FlySelect.types'
|
|
9
|
+
import type { T_InputText, T_InputTextBase } from './text/FlyText.types'
|
|
10
|
+
import type { T_InputValueUnit, T_InputValueUnitBase } from './value-unit/FlyValueUnit.types'
|
|
11
|
+
|
|
12
|
+
export type T_DynamicInputPropsBase = {
|
|
13
|
+
key: string
|
|
14
|
+
prop?: string // for form validation. falls back to key
|
|
15
|
+
label: string
|
|
16
|
+
tooltip?: string
|
|
17
|
+
columnSpan?: number
|
|
18
|
+
validations?: FormItemRule[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type T_InputRendererBase = T_DynamicInputPropsBase & T_SupportedInputTypeBase
|
|
22
|
+
|
|
23
|
+
export type T_SupportedInputTypeBase =
|
|
24
|
+
| T_InputTextBase
|
|
25
|
+
| T_InputBooleanBase
|
|
26
|
+
| T_InputDateTimeBase
|
|
27
|
+
| T_InputNumberBase
|
|
28
|
+
| T_InputSelectBase
|
|
29
|
+
| T_InputValueUnitBase
|
|
30
|
+
|
|
31
|
+
export type T_SupportedInputType =
|
|
32
|
+
| T_InputText
|
|
33
|
+
| T_InputNumber
|
|
34
|
+
| T_InputValueUnit
|
|
35
|
+
| T_InputSelect
|
|
36
|
+
| T_InputBoolean
|
|
37
|
+
| T_InputDateTime
|
|
38
|
+
|
|
39
|
+
export type T_InputTypes = T_SupportedInputTypeBase['type']
|
|
40
|
+
|
|
41
|
+
export type T_DynamicInputComponent = Component<{
|
|
42
|
+
modelValue?: unknown
|
|
43
|
+
input?: T_SupportedInputType
|
|
44
|
+
}>
|
|
45
|
+
|
|
46
|
+
export type T_FormSchemaRendererConfig = {
|
|
47
|
+
inputs: T_InputRendererBase[]
|
|
48
|
+
baseForm: { [K: string]: unknown }
|
|
49
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { isNil } from 'lodash'
|
|
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 (v === null || v === undefined) return ''
|
|
9
|
-
return String(v)
|
|
10
|
-
|
|
11
|
-
case 'text':
|
|
12
|
-
default:
|
|
13
|
-
if (isNil(v)) {
|
|
14
|
-
return ''
|
|
15
|
-
}
|
|
16
|
-
return typeof v === 'string' ? v : String(v)
|
|
17
|
-
}
|
|
18
|
-
}
|
|
1
|
+
import { isNil } from 'lodash'
|
|
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 (v === null || v === undefined) return ''
|
|
9
|
+
return String(v)
|
|
10
|
+
|
|
11
|
+
case 'text':
|
|
12
|
+
default:
|
|
13
|
+
if (isNil(v)) {
|
|
14
|
+
return ''
|
|
15
|
+
}
|
|
16
|
+
return typeof v === 'string' ? v : String(v)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@use 'element-plus/theme-chalk/src/input.scss';
|
|
1
|
+
@use 'element-plus/theme-chalk/src/input.scss';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export type T_InputTextValues = string | number | undefined
|
|
2
|
-
|
|
3
|
-
export type T_InputNumberBase = T_InputNumber & {
|
|
4
|
-
type: 'number'
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export type T_InputNumber = {
|
|
8
|
-
placeholder?: string
|
|
9
|
-
/**
|
|
10
|
-
* Attrs are passed directly to the input element as props
|
|
11
|
-
*/
|
|
12
|
-
attrs?: { [K: string]: unknown }
|
|
13
|
-
}
|
|
1
|
+
export type T_InputTextValues = string | number | undefined
|
|
2
|
+
|
|
3
|
+
export type T_InputNumberBase = T_InputNumber & {
|
|
4
|
+
type: 'number'
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type T_InputNumber = {
|
|
8
|
+
placeholder?: string
|
|
9
|
+
/**
|
|
10
|
+
* Attrs are passed directly to the input element as props
|
|
11
|
+
*/
|
|
12
|
+
attrs?: { [K: string]: unknown }
|
|
13
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export function displayToNumber(v: unknown): number | undefined {
|
|
2
|
-
if (v === '' || v === undefined || v === undefined) return undefined
|
|
3
|
-
|
|
4
|
-
const n = Number(v)
|
|
5
|
-
return Number.isNaN(n) ? undefined : n
|
|
6
|
-
}
|
|
1
|
+
export function displayToNumber(v: unknown): number | undefined {
|
|
2
|
+
if (v === '' || v === undefined || v === undefined) return undefined
|
|
3
|
+
|
|
4
|
+
const n = Number(v)
|
|
5
|
+
return Number.isNaN(n) ? undefined : n
|
|
6
|
+
}
|