@flyanra/vue-core 0.3.0 → 0.4.1
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 -128
- 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 -0
- package/src/components/feedback/index.ts +2 -2
- package/src/components/feedback/tooltip/FlyInfoTooltip.vue +48 -0
- 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 -59
- package/src/components/feedback/tooltip/index.ts +6 -6
- package/src/components/form/form.utils.ts +57 -0
- package/src/components/form/index.ts +0 -0
- package/src/components/form/input-renderers/boolean/FlyBoolean.scss +1 -0
- package/src/components/form/input-renderers/boolean/FlyBoolean.types.ts +16 -0
- package/src/components/form/input-renderers/boolean/FlyBoolean.vue +35 -0
- package/src/components/form/input-renderers/date-time/FlyDateTime.scss +1 -0
- package/src/components/form/input-renderers/date-time/FlyDateTime.types.ts +21 -0
- package/src/components/form/input-renderers/date-time/FlyDateTime.vue +85 -0
- package/src/components/form/input-renderers/form-item-renderer/FlyFormItemRenderer.scss +4 -0
- package/src/components/form/input-renderers/form-item-renderer/FlyFormItemRenderer.vue +48 -0
- package/src/components/form/input-renderers/form-schema-renderer/FlyFormSchemaRenderer.types.ts +3 -0
- package/src/components/form/input-renderers/form-schema-renderer/FlyFormSchemaRenderer.utils.ts +246 -0
- package/src/components/form/input-renderers/form-schema-renderer/FlyFormSchemaRenderer.vue +75 -0
- package/src/components/form/input-renderers/form-schema-renderer/UseFormSchemaRenderer.ts +97 -0
- package/src/components/form/input-renderers/form-schema.types.ts +95 -0
- package/src/components/form/input-renderers/input-renderer/FlyInputRenderer.vue +49 -0
- package/src/components/form/input-renderers/input-renderer.types.ts +49 -0
- package/src/components/form/input-renderers/input-renderer.utils.ts +18 -0
- package/src/components/form/input-renderers/number/FlyNumber.scss +1 -0
- package/src/components/form/input-renderers/number/FlyNumber.types.ts +13 -0
- package/src/components/form/input-renderers/number/FlyNumber.utils.ts +6 -0
- package/src/components/form/input-renderers/number/FlyNumber.vue +48 -0
- package/src/components/form/input-renderers/regional-tenant-form-renderer/FlyRegionalTenantFormRenderer.types.ts +15 -0
- package/src/components/form/input-renderers/regional-tenant-form-renderer/FlyRegionalTenantFormRenderer.vue +99 -0
- package/src/components/form/input-renderers/select/FlySelect.scss +9 -0
- package/src/components/form/input-renderers/select/FlySelect.types.ts +25 -0
- package/src/components/form/input-renderers/select/FlySelect.utils.ts +37 -0
- package/src/components/form/input-renderers/select/FlySelect.vue +48 -0
- package/src/components/form/input-renderers/text/FlyText.scss +1 -0
- package/src/components/form/input-renderers/text/FlyText.types.ts +20 -0
- package/src/components/form/input-renderers/text/FlyText.vue +56 -0
- package/src/components/form/input-renderers/value-unit/FlyValueUnit.scss +2 -0
- package/src/components/form/input-renderers/value-unit/FlyValueUnit.types.ts +28 -0
- package/src/components/form/input-renderers/value-unit/FlyValueUnit.vue +101 -0
- package/src/components/form/input-validators.ts +121 -0
- 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 -11
- 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 -0
- 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 +107 -107
- package/src/styles/element/overrides/message.scss +39 -39
- package/src/styles/element/overrides/notification.scss +46 -46
- package/src/styles/element/overrides/segmented.scss +17 -17
- 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/AppButton/AppButton.types.d.ts +0 -8
- package/dist/types/components/AppButton/AppButton.vue.d.ts +0 -20
- package/dist/types/components/AppButton/index.d.ts +0 -4
- package/dist/types/components/AppCard/AppCard.types.d.ts +0 -5
- package/dist/types/components/AppCard/AppCard.vue.d.ts +0 -17
- package/dist/types/components/AppCard/index.d.ts +0 -4
- 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/feedback/index.d.ts +0 -2
- package/dist/types/components/feedback/tooltip/FlyTooltip.types.d.ts +0 -4
- package/dist/types/components/feedback/tooltip/FlyTooltip.vue.d.ts +0 -16
- package/dist/types/components/feedback/tooltip/index.d.ts +0 -4
- 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 -8
- 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/index.d.ts +0 -1
- package/dist/types/types/index.d.ts +0 -1
- package/src/components/AppButton/AppButton.element.scss +0 -2
- package/src/components/AppButton/AppButton.types.ts +0 -10
- package/src/components/AppButton/AppButton.vue +0 -65
- package/src/components/AppButton/index.ts +0 -6
- package/src/components/AppCard/AppCard.types.ts +0 -5
- package/src/components/AppCard/AppCard.vue +0 -58
- package/src/components/AppCard/index.ts +0 -6
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-select
|
|
3
|
+
v-model="inputProxy"
|
|
4
|
+
style="width: 100%"
|
|
5
|
+
v-bind="input?.attrs"
|
|
6
|
+
filterable
|
|
7
|
+
:placeholder="input?.placeholder && input?.placeholder"
|
|
8
|
+
clearable
|
|
9
|
+
@change="(val) => emit('change', val)"
|
|
10
|
+
@blur="() => emit('blur')"
|
|
11
|
+
@focus="() => emit('focus')"
|
|
12
|
+
>
|
|
13
|
+
<el-option v-for="unit in options" :key="unit.value" :value="unit.value" :label="unit.label" />
|
|
14
|
+
</el-select>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup lang="ts">
|
|
18
|
+
import { computed } from 'vue'
|
|
19
|
+
|
|
20
|
+
import { ElOption, ElSelect } from 'element-plus'
|
|
21
|
+
|
|
22
|
+
import './FlySelect.scss'
|
|
23
|
+
import type { T_InputSelect, T_InputSelectValue } from './FlySelect.types'
|
|
24
|
+
import { normalizeSelectOptionsToDict } from './FlySelect.utils'
|
|
25
|
+
|
|
26
|
+
const emit = defineEmits<{
|
|
27
|
+
(e: 'update:modelValue', v: T_InputSelectValue): void
|
|
28
|
+
(e: 'change', v: T_InputSelectValue): void
|
|
29
|
+
(e: 'blur'): void
|
|
30
|
+
(e: 'focus'): void
|
|
31
|
+
}>()
|
|
32
|
+
|
|
33
|
+
const props = defineProps<{
|
|
34
|
+
modelValue?: T_InputSelectValue
|
|
35
|
+
input?: T_InputSelect
|
|
36
|
+
}>()
|
|
37
|
+
|
|
38
|
+
const options = computed(() => normalizeSelectOptionsToDict(props.input?.config?.options || []))
|
|
39
|
+
|
|
40
|
+
const inputProxy = computed({
|
|
41
|
+
get: () => {
|
|
42
|
+
return props.modelValue
|
|
43
|
+
},
|
|
44
|
+
set: (v) => {
|
|
45
|
+
emit('update:modelValue', v)
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@use 'element-plus/theme-chalk/src/input.scss';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type T_InputTextValues = string | number | undefined
|
|
2
|
+
|
|
3
|
+
export type T_InputTextBase = T_InputText & {
|
|
4
|
+
type: 'text' | 'textarea'
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type T_InputText = {
|
|
8
|
+
placeholder?: string
|
|
9
|
+
/**
|
|
10
|
+
* Attrs are passed directly to the input element as props
|
|
11
|
+
*/
|
|
12
|
+
attrs?: {
|
|
13
|
+
minlength?: number
|
|
14
|
+
maxlength?: number
|
|
15
|
+
showWordLimit?: boolean
|
|
16
|
+
type?: string
|
|
17
|
+
rows?: number
|
|
18
|
+
}
|
|
19
|
+
mask?: string // example ###-###.@ - uses Maska: https://github.com/beholdr/maska
|
|
20
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-input
|
|
3
|
+
v-model="inputProxy"
|
|
4
|
+
v-maska="inputType === 'text' ? input?.mask : undefined"
|
|
5
|
+
style="width: 100%"
|
|
6
|
+
:type="inputType"
|
|
7
|
+
v-bind="input?.attrs"
|
|
8
|
+
:placeholder="input?.placeholder"
|
|
9
|
+
show-word-limit
|
|
10
|
+
@change="(val) => emit('change', castValue(val))"
|
|
11
|
+
@blur="() => emit('blur')"
|
|
12
|
+
@focus="() => emit('focus')"
|
|
13
|
+
>
|
|
14
|
+
</el-input>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup lang="ts">
|
|
18
|
+
import { computed } from 'vue'
|
|
19
|
+
|
|
20
|
+
import { ElInput } from 'element-plus'
|
|
21
|
+
|
|
22
|
+
import { vMaska } from 'maska/vue'
|
|
23
|
+
|
|
24
|
+
import { getInputDisplayValue } from '../input-renderer.utils'
|
|
25
|
+
|
|
26
|
+
import './FlyText.scss'
|
|
27
|
+
import type { T_InputText, T_InputTextValues } from './FlyText.types'
|
|
28
|
+
|
|
29
|
+
const emit = defineEmits<{
|
|
30
|
+
(e: 'update:modelValue', v: T_InputTextValues): void
|
|
31
|
+
(e: 'change', v: T_InputTextValues): void
|
|
32
|
+
(e: 'blur'): void
|
|
33
|
+
(e: 'focus'): void
|
|
34
|
+
}>()
|
|
35
|
+
|
|
36
|
+
const props = defineProps<{
|
|
37
|
+
modelValue?: T_InputTextValues
|
|
38
|
+
input?: T_InputText
|
|
39
|
+
}>()
|
|
40
|
+
|
|
41
|
+
const inputType = computed(() => props.input?.attrs?.type || 'text')
|
|
42
|
+
|
|
43
|
+
const inputProxy = computed({
|
|
44
|
+
get: () => {
|
|
45
|
+
return getInputDisplayValue(props.modelValue, 'text')
|
|
46
|
+
},
|
|
47
|
+
set: (v) => {
|
|
48
|
+
const parsed = castValue(v)
|
|
49
|
+
emit('update:modelValue', parsed)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
function castValue(v: unknown) {
|
|
54
|
+
return v ? String(v) : ''
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { T_InputNumber } from '../number/FlyNumber.types'
|
|
2
|
+
import type { T_InputSelect, T_InputSelectOptionList } from '../select/FlySelect.types'
|
|
3
|
+
import type { T_InputText } from '../text/FlyText.types'
|
|
4
|
+
|
|
5
|
+
export type T_ValueUnitValue =
|
|
6
|
+
| {
|
|
7
|
+
unit: string | number | undefined
|
|
8
|
+
value: string | number | undefined
|
|
9
|
+
}
|
|
10
|
+
| undefined
|
|
11
|
+
|
|
12
|
+
export type T_InputValueUnitBase = T_InputValueUnit & {
|
|
13
|
+
type: 'valueUnit'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type T_InputValueUnit = {
|
|
17
|
+
placeholder?: string
|
|
18
|
+
unitPlaceholder?: string
|
|
19
|
+
/**
|
|
20
|
+
* Attrs are passed directly to the input element as props
|
|
21
|
+
*/
|
|
22
|
+
attrs?: T_InputText['attrs'] | T_InputNumber['attrs']
|
|
23
|
+
unitsAttr?: T_InputSelect['attrs']
|
|
24
|
+
config?: {
|
|
25
|
+
valueType?: 'text' | 'number' // defaults to number
|
|
26
|
+
options: T_InputSelectOptionList
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-input
|
|
3
|
+
v-model="valueProxy"
|
|
4
|
+
style="width: 100%"
|
|
5
|
+
:type="valueTypeIsString ? 'text' : 'number'"
|
|
6
|
+
v-bind="input?.attrs"
|
|
7
|
+
:placeholder="input?.placeholder"
|
|
8
|
+
@change="(v) => emit('change', getValue(v))"
|
|
9
|
+
@blur="() => emit('blur')"
|
|
10
|
+
@focus="() => emit('focus')"
|
|
11
|
+
>
|
|
12
|
+
<template #append>
|
|
13
|
+
<el-select
|
|
14
|
+
v-bind="input?.unitsAttr"
|
|
15
|
+
v-model="unitProxy"
|
|
16
|
+
style="width: 100px"
|
|
17
|
+
filterable
|
|
18
|
+
:placeholder="input?.unitPlaceholder"
|
|
19
|
+
@change="(v) => emit('change', getUnit(v))"
|
|
20
|
+
@blur="() => emit('blur')"
|
|
21
|
+
@focus="() => emit('focus')"
|
|
22
|
+
>
|
|
23
|
+
<el-option
|
|
24
|
+
v-for="unit in options"
|
|
25
|
+
:key="unit.value"
|
|
26
|
+
:value="unit.value"
|
|
27
|
+
:label="unit.label"
|
|
28
|
+
/>
|
|
29
|
+
</el-select>
|
|
30
|
+
</template>
|
|
31
|
+
</el-input>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script setup lang="ts">
|
|
35
|
+
import { computed } from 'vue'
|
|
36
|
+
|
|
37
|
+
import { ElInput, ElOption, ElSelect } from 'element-plus'
|
|
38
|
+
|
|
39
|
+
import { getInputDisplayValue } from '../input-renderer.utils'
|
|
40
|
+
import { displayToNumber } from '../number/FlyNumber.utils'
|
|
41
|
+
import { normalizeSelectOptionsToDict } from '../select/FlySelect.utils'
|
|
42
|
+
|
|
43
|
+
import './FlyValueUnit.scss'
|
|
44
|
+
import type { T_InputValueUnit, T_ValueUnitValue } from './FlyValueUnit.types'
|
|
45
|
+
|
|
46
|
+
const emit = defineEmits<{
|
|
47
|
+
(e: 'update:modelValue', v: T_ValueUnitValue): void
|
|
48
|
+
(e: 'change', v: T_ValueUnitValue): void
|
|
49
|
+
(e: 'blur'): void
|
|
50
|
+
(e: 'focus'): void
|
|
51
|
+
}>()
|
|
52
|
+
|
|
53
|
+
const props = defineProps<{
|
|
54
|
+
modelValue?: T_ValueUnitValue
|
|
55
|
+
input?: T_InputValueUnit
|
|
56
|
+
}>()
|
|
57
|
+
|
|
58
|
+
const options = computed(() => normalizeSelectOptionsToDict(props.input?.config?.options || []))
|
|
59
|
+
|
|
60
|
+
const valueTypeIsString = computed(() => props.input?.config?.valueType === 'text')
|
|
61
|
+
|
|
62
|
+
const valueProxy = computed<string>({
|
|
63
|
+
get: () => {
|
|
64
|
+
return getInputDisplayValue(
|
|
65
|
+
props.modelValue?.value,
|
|
66
|
+
valueTypeIsString.value ? 'text' : 'number'
|
|
67
|
+
)
|
|
68
|
+
},
|
|
69
|
+
set: (v) => {
|
|
70
|
+
emit('update:modelValue', getValue(v))
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
const unitProxy = computed({
|
|
75
|
+
get: () => props.modelValue?.unit ?? undefined,
|
|
76
|
+
set: (u) => {
|
|
77
|
+
emit('update:modelValue', getUnit(u))
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
function ensure(): NonNullable<T_ValueUnitValue> {
|
|
82
|
+
return {
|
|
83
|
+
value: props.modelValue?.value ?? undefined,
|
|
84
|
+
unit: props.modelValue?.unit ?? undefined
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function getValue(v: string) {
|
|
89
|
+
const base = ensure()
|
|
90
|
+
const parsed = valueTypeIsString.value ? v : displayToNumber(v)
|
|
91
|
+
|
|
92
|
+
const next = { ...base, value: parsed }
|
|
93
|
+
return next
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function getUnit(u: NonNullable<T_ValueUnitValue>['unit']) {
|
|
97
|
+
const base = ensure()
|
|
98
|
+
const next = { ...base, unit: u }
|
|
99
|
+
return next
|
|
100
|
+
}
|
|
101
|
+
</script>
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { FormItemRule } from 'element-plus'
|
|
2
|
+
|
|
3
|
+
import { isNil } from 'lodash'
|
|
4
|
+
import type { Composer } from 'vue-i18n'
|
|
5
|
+
|
|
6
|
+
import { type checkInputRange, isRequiredError } from '../../utils/validators'
|
|
7
|
+
|
|
8
|
+
import type { T_ValueUnitValue } from './input-renderers/value-unit/FlyValueUnit.types'
|
|
9
|
+
|
|
10
|
+
type InputTriggers = 'blur' | 'change'
|
|
11
|
+
|
|
12
|
+
// type Validator = (
|
|
13
|
+
// languageKey?: string,
|
|
14
|
+
// trigger?: InputTriggers,
|
|
15
|
+
// useRequiredMessage?: boolean,
|
|
16
|
+
// required?: boolean,
|
|
17
|
+
// options?: {
|
|
18
|
+
// valueType?: 'text' | 'number'
|
|
19
|
+
// },
|
|
20
|
+
// composer?: Composer
|
|
21
|
+
// ) => FormItemRule
|
|
22
|
+
|
|
23
|
+
export const requiredField = (
|
|
24
|
+
fieldLabel = 'validation.field',
|
|
25
|
+
trigger: InputTriggers = 'blur',
|
|
26
|
+
useRequiredMessage = true,
|
|
27
|
+
composer?: Composer
|
|
28
|
+
): FormItemRule => {
|
|
29
|
+
return {
|
|
30
|
+
required: true,
|
|
31
|
+
trigger: trigger,
|
|
32
|
+
message: useRequiredMessage ? isRequiredError(fieldLabel, composer) : fieldLabel
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const checkInputRangeValidator = (
|
|
37
|
+
validator: ReturnType<typeof checkInputRange>,
|
|
38
|
+
trigger: InputTriggers = 'change'
|
|
39
|
+
): FormItemRule => ({
|
|
40
|
+
trigger: trigger,
|
|
41
|
+
validator
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
export const requiredFieldNumber = (
|
|
45
|
+
languageKey = 'validation.field',
|
|
46
|
+
trigger: InputTriggers = 'change',
|
|
47
|
+
composer?: Composer
|
|
48
|
+
): FormItemRule => {
|
|
49
|
+
const t = composer?.t
|
|
50
|
+
return {
|
|
51
|
+
type: 'number',
|
|
52
|
+
required: true,
|
|
53
|
+
trigger: trigger,
|
|
54
|
+
message: t
|
|
55
|
+
? t('validation.fieldMustBeANumber', {
|
|
56
|
+
fieldName: t(languageKey)
|
|
57
|
+
})
|
|
58
|
+
: 'validation.fieldMustBeANumber'
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const requiredFieldNumberSelect = (
|
|
63
|
+
label = 'validation.field',
|
|
64
|
+
trigger: InputTriggers = 'blur',
|
|
65
|
+
useRequiredMessage = true,
|
|
66
|
+
composer?: Composer
|
|
67
|
+
): FormItemRule =>
|
|
68
|
+
requiredFieldValueUnit(
|
|
69
|
+
label,
|
|
70
|
+
trigger,
|
|
71
|
+
useRequiredMessage,
|
|
72
|
+
true,
|
|
73
|
+
{
|
|
74
|
+
valueType: 'number'
|
|
75
|
+
},
|
|
76
|
+
composer
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
export const requiredFieldValueUnit = (
|
|
80
|
+
label = 'validation.field',
|
|
81
|
+
trigger: InputTriggers = 'blur',
|
|
82
|
+
useRequiredMessage = true,
|
|
83
|
+
required = true,
|
|
84
|
+
options: {
|
|
85
|
+
valueType?: 'text' | 'number'
|
|
86
|
+
},
|
|
87
|
+
composer?: Composer
|
|
88
|
+
): FormItemRule => ({
|
|
89
|
+
required: required,
|
|
90
|
+
trigger: trigger,
|
|
91
|
+
validator: (_rule, value: T_ValueUnitValue, callback) => {
|
|
92
|
+
// used in element form validator
|
|
93
|
+
if (
|
|
94
|
+
(options?.valueType === 'number' &&
|
|
95
|
+
!(
|
|
96
|
+
value &&
|
|
97
|
+
value.unit !== '' &&
|
|
98
|
+
value.value !== '' &&
|
|
99
|
+
!isNil(value.unit) &&
|
|
100
|
+
!isNil(value.value)
|
|
101
|
+
)) ||
|
|
102
|
+
!value
|
|
103
|
+
) {
|
|
104
|
+
return callback(new Error(useRequiredMessage ? isRequiredError(label, composer) : label))
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return callback()
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
export const requiredFieldArray = (
|
|
112
|
+
label = 'validation.field',
|
|
113
|
+
trigger: InputTriggers = 'change',
|
|
114
|
+
useRequiredMessage = true,
|
|
115
|
+
composer?: Composer
|
|
116
|
+
): FormItemRule => ({
|
|
117
|
+
type: 'array',
|
|
118
|
+
required: true,
|
|
119
|
+
trigger: trigger,
|
|
120
|
+
message: useRequiredMessage ? isRequiredError(label, composer) : label
|
|
121
|
+
})
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { type Component } from 'vue'
|
|
2
|
-
|
|
3
|
-
export type T_FlyIconTypes = 'mdi' | 'ri'
|
|
4
|
-
|
|
5
|
-
export type T_FlyIcon =
|
|
6
|
-
| string // mdi:home
|
|
7
|
-
| Component // RiHomeLine, EP icons, etc.
|
|
8
|
-
|
|
9
|
-
export type T_FlyIconProps = {
|
|
10
|
-
type?: T_FlyIconTypes
|
|
11
|
-
icon: T_FlyIcon
|
|
12
|
-
}
|
|
1
|
+
import { type Component } from 'vue'
|
|
2
|
+
|
|
3
|
+
export type T_FlyIconTypes = 'mdi' | 'ri'
|
|
4
|
+
|
|
5
|
+
export type T_FlyIcon =
|
|
6
|
+
| string // mdi:home
|
|
7
|
+
| Component // RiHomeLine, EP icons, etc.
|
|
8
|
+
|
|
9
|
+
export type T_FlyIconProps = {
|
|
10
|
+
type?: T_FlyIconTypes
|
|
11
|
+
icon: T_FlyIcon
|
|
12
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<i class="fly-icon">
|
|
3
|
-
<svg-icon v-if="iconType === 'mdi'" :type="iconType" :path="icon as string" />
|
|
4
|
-
<component :is="icon" v-else-if="iconType === 'ri'" />
|
|
5
|
-
</i>
|
|
6
|
-
</template>
|
|
7
|
-
|
|
8
|
-
<script setup lang="ts">
|
|
9
|
-
import { computed } from 'vue'
|
|
10
|
-
|
|
11
|
-
import SvgIcon from '@jamescoyle/vue-icon'
|
|
12
|
-
|
|
13
|
-
import type { T_FlyIconProps } from './FlyIcon.types.ts'
|
|
14
|
-
|
|
15
|
-
type Props = T_FlyIconProps
|
|
16
|
-
|
|
17
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
18
|
-
type: 'mdi'
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
const iconType = computed(() => props.type || 'mdi')
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
<style lang="scss" scoped></style>
|
|
1
|
+
<template>
|
|
2
|
+
<i class="fly-icon">
|
|
3
|
+
<svg-icon v-if="iconType === 'mdi'" :type="iconType" :path="icon as string" />
|
|
4
|
+
<component :is="icon" v-else-if="iconType === 'ri'" />
|
|
5
|
+
</i>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script setup lang="ts">
|
|
9
|
+
import { computed } from 'vue'
|
|
10
|
+
|
|
11
|
+
import SvgIcon from '@jamescoyle/vue-icon'
|
|
12
|
+
|
|
13
|
+
import type { T_FlyIconProps } from './FlyIcon.types.ts'
|
|
14
|
+
|
|
15
|
+
type Props = T_FlyIconProps
|
|
16
|
+
|
|
17
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
18
|
+
type: 'mdi'
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
const iconType = computed(() => props.type || 'mdi')
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<style lang="scss" scoped></style>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import FlyIcon from './FlyIcon.vue'
|
|
2
|
-
|
|
3
|
-
export default FlyIcon
|
|
4
|
-
export { FlyIcon }
|
|
5
|
-
|
|
6
|
-
export type { T_FlyIconProps } from './FlyIcon.types.ts'
|
|
1
|
+
import FlyIcon from './FlyIcon.vue'
|
|
2
|
+
|
|
3
|
+
export default FlyIcon
|
|
4
|
+
export { FlyIcon }
|
|
5
|
+
|
|
6
|
+
export type { T_FlyIconProps } from './FlyIcon.types.ts'
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as FlyIcon } from './fly-icon'
|
|
2
|
-
export type * from './fly-icon'
|
|
1
|
+
export { default as FlyIcon } from './fly-icon'
|
|
2
|
+
export type * from './fly-icon'
|
package/src/components/index.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
export * from './navigation'
|
|
8
|
-
|
|
9
|
-
export * from './basic'
|
|
10
|
-
export * from './feedback'
|
|
11
|
-
export * from './general'
|
|
1
|
+
export * from './navigation'
|
|
2
|
+
|
|
3
|
+
export * from './basic'
|
|
4
|
+
export * from './feedback'
|
|
5
|
+
export * from './general'
|