@flyanra/vue-core 0.3.0 → 1.0.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.
Files changed (118) hide show
  1. package/dist/types/components/basic/fly-button/FlyButton.types.d.ts +2 -3
  2. package/dist/types/components/basic/typography/FlyCollapseTitleRenderer.vue.d.ts +16 -0
  3. package/dist/types/components/feedback/tooltip/FlyInfoTooltip.vue.d.ts +36 -0
  4. package/dist/types/components/feedback/tooltip/FlyTooltip.vue.d.ts +1 -0
  5. package/dist/types/components/form/form.utils.d.ts +11 -0
  6. package/dist/types/components/form/index.d.ts +5 -0
  7. package/dist/types/components/form/input-renderers/boolean/FlyBoolean.types.d.ts +14 -0
  8. package/dist/types/components/form/input-renderers/boolean/FlyBoolean.vue.d.ts +15 -0
  9. package/dist/types/components/form/input-renderers/date-time/FlyDateTime.types.d.ts +20 -0
  10. package/dist/types/components/form/input-renderers/date-time/FlyDateTime.vue.d.ts +19 -0
  11. package/dist/types/components/form/input-renderers/form-item-renderer/FlyFormItemRenderer.vue.d.ts +19 -0
  12. package/dist/types/components/form/input-renderers/form-item-renderer/index.d.ts +3 -0
  13. package/dist/types/components/form/input-renderers/form-schema-renderer/FlyFormSchemaRenderer.types.d.ts +2 -0
  14. package/dist/types/components/form/input-renderers/form-schema-renderer/FlyFormSchemaRenderer.utils.d.ts +21 -0
  15. package/dist/types/components/form/input-renderers/form-schema-renderer/FlyFormSchemaRenderer.vue.d.ts +17 -0
  16. package/dist/types/components/form/input-renderers/form-schema-renderer/UseFormSchemaRenderer.d.ts +25 -0
  17. package/dist/types/components/form/input-renderers/form-schema.types.d.ts +77 -0
  18. package/dist/types/components/form/input-renderers/input-renderer/FlyInputRenderer.vue.d.ts +18 -0
  19. package/dist/types/components/form/input-renderers/input-renderer/index.d.ts +3 -0
  20. package/dist/types/components/form/input-renderers/input-renderer.types.d.ts +30 -0
  21. package/dist/types/components/form/input-renderers/input-renderer.utils.d.ts +2 -0
  22. package/dist/types/components/form/input-renderers/number/FlyNumber.types.d.ts +13 -0
  23. package/dist/types/components/form/input-renderers/number/FlyNumber.utils.d.ts +1 -0
  24. package/dist/types/components/form/input-renderers/number/FlyNumber.vue.d.ts +19 -0
  25. package/dist/types/components/form/input-renderers/regional-tenant-form-renderer/FlyRegionalTenantFormRenderer.types.d.ts +13 -0
  26. package/dist/types/components/form/input-renderers/regional-tenant-form-renderer/FlyRegionalTenantFormRenderer.vue.d.ts +20 -0
  27. package/dist/types/components/form/input-renderers/select/FlySelect.types.d.ts +22 -0
  28. package/dist/types/components/form/input-renderers/select/FlySelect.utils.d.ts +2 -0
  29. package/dist/types/components/form/input-renderers/select/FlySelect.vue.d.ts +19 -0
  30. package/dist/types/components/form/input-renderers/text/FlyText.types.d.ts +18 -0
  31. package/dist/types/components/form/input-renderers/text/FlyText.vue.d.ts +19 -0
  32. package/dist/types/components/form/input-renderers/value-unit/FlyValueUnit.types.d.ts +23 -0
  33. package/dist/types/components/form/input-renderers/value-unit/FlyValueUnit.vue.d.ts +19 -0
  34. package/dist/types/components/form/input-validators.d.ts +12 -0
  35. package/dist/types/components/general/fly-icon-v2/FlyIconV2.types.d.ts +5 -0
  36. package/dist/types/components/general/fly-icon-v2/FlyIconV2.vue.d.ts +4 -0
  37. package/dist/types/components/general/fly-icon-v2/index.d.ts +4 -0
  38. package/dist/types/components/general/index.d.ts +2 -0
  39. package/dist/types/components/index.d.ts +1 -4
  40. package/dist/types/components/navigation/menu/fly-mini-sidebar/FlyMiniSidebar.types.d.ts +2 -2
  41. package/dist/types/components/navigation/menu/fly-sidebar/FlySidebar.types.d.ts +2 -2
  42. package/dist/types/composables/UseLocaleInjector.d.ts +8 -0
  43. package/dist/types/composables/index.d.ts +1 -0
  44. package/dist/types/utils/pure-functions.d.ts +1 -0
  45. package/dist/types/utils/validators.d.ts +8 -0
  46. package/package.json +26 -8
  47. package/src/components/basic/fly-button/FlyButton.types.ts +2 -3
  48. package/src/components/basic/fly-button/FlyButton.vue +4 -6
  49. package/src/components/basic/typography/FlyCollapseTitleRenderer.vue +46 -0
  50. package/src/components/feedback/tooltip/FlyInfoTooltip.vue +49 -0
  51. package/src/components/feedback/tooltip/FlyTooltip.element.scss +1 -1
  52. package/src/components/feedback/tooltip/FlyTooltip.vue +1 -0
  53. package/src/components/form/form.utils.ts +72 -0
  54. package/src/components/form/index.ts +6 -0
  55. package/src/components/form/input-renderers/boolean/FlyBoolean.scss +1 -0
  56. package/src/components/form/input-renderers/boolean/FlyBoolean.types.ts +16 -0
  57. package/src/components/form/input-renderers/boolean/FlyBoolean.vue +48 -0
  58. package/src/components/form/input-renderers/date-time/FlyDateTime.scss +1 -0
  59. package/src/components/form/input-renderers/date-time/FlyDateTime.types.ts +21 -0
  60. package/src/components/form/input-renderers/date-time/FlyDateTime.vue +85 -0
  61. package/src/components/form/input-renderers/form-item-renderer/FlyFormItemRenderer.scss +4 -0
  62. package/src/components/form/input-renderers/form-item-renderer/FlyFormItemRenderer.vue +48 -0
  63. package/src/components/form/input-renderers/form-item-renderer/index.ts +4 -0
  64. package/src/components/form/input-renderers/form-schema-renderer/FlyFormSchemaRenderer.types.ts +3 -0
  65. package/src/components/form/input-renderers/form-schema-renderer/FlyFormSchemaRenderer.utils.ts +221 -0
  66. package/src/components/form/input-renderers/form-schema-renderer/FlyFormSchemaRenderer.vue +75 -0
  67. package/src/components/form/input-renderers/form-schema-renderer/UseFormSchemaRenderer.ts +97 -0
  68. package/src/components/form/input-renderers/form-schema.types.ts +95 -0
  69. package/src/components/form/input-renderers/input-renderer/FlyInputRenderer.vue +49 -0
  70. package/src/components/form/input-renderers/input-renderer/index.ts +4 -0
  71. package/src/components/form/input-renderers/input-renderer.types.ts +49 -0
  72. package/src/components/form/input-renderers/input-renderer.utils.ts +18 -0
  73. package/src/components/form/input-renderers/number/FlyNumber.scss +1 -0
  74. package/src/components/form/input-renderers/number/FlyNumber.types.ts +13 -0
  75. package/src/components/form/input-renderers/number/FlyNumber.utils.ts +6 -0
  76. package/src/components/form/input-renderers/number/FlyNumber.vue +64 -0
  77. package/src/components/form/input-renderers/regional-tenant-form-renderer/FlyRegionalTenantFormRenderer.types.ts +15 -0
  78. package/src/components/form/input-renderers/regional-tenant-form-renderer/FlyRegionalTenantFormRenderer.vue +99 -0
  79. package/src/components/form/input-renderers/select/FlySelect.scss +1 -0
  80. package/src/components/form/input-renderers/select/FlySelect.types.ts +25 -0
  81. package/src/components/form/input-renderers/select/FlySelect.utils.ts +37 -0
  82. package/src/components/form/input-renderers/select/FlySelect.vue +48 -0
  83. package/src/components/form/input-renderers/text/FlyText.scss +1 -0
  84. package/src/components/form/input-renderers/text/FlyText.types.ts +20 -0
  85. package/src/components/form/input-renderers/text/FlyText.vue +70 -0
  86. package/src/components/form/input-renderers/value-unit/FlyValueUnit.scss +2 -0
  87. package/src/components/form/input-renderers/value-unit/FlyValueUnit.types.ts +28 -0
  88. package/src/components/form/input-renderers/value-unit/FlyValueUnit.vue +102 -0
  89. package/src/components/form/input-validators.ts +99 -0
  90. package/src/components/general/fly-icon-v2/FlyIconV2.types.ts +6 -0
  91. package/src/components/general/fly-icon-v2/FlyIconV2.vue +17 -0
  92. package/src/components/general/fly-icon-v2/index.ts +6 -0
  93. package/src/components/general/index.ts +3 -0
  94. package/src/components/index.ts +2 -6
  95. package/src/components/navigation/menu/fly-mini-sidebar/FlyMiniSidebar.types.ts +2 -2
  96. package/src/components/navigation/menu/fly-mini-sidebar/FlyMiniSidebarItem.vue +2 -2
  97. package/src/components/navigation/menu/fly-sidebar/FlySidebar.types.ts +2 -2
  98. package/src/components/navigation/menu/fly-sidebar/FlySidebar.vue +5 -4
  99. package/src/components/navigation/menu/fly-sidebar/FlySidebarNode.vue +3 -3
  100. package/src/styles/element/mixins/collapse.scss +2 -2
  101. package/src/styles/element/overrides/date-time.scss +11 -0
  102. package/src/styles/element/overrides/form.scss +26 -12
  103. package/src/styles/element/overrides/message-box.scss +2 -0
  104. package/src/styles/element/overrides/radio.scss +2 -0
  105. package/src/styles/element/overrides/select.scss +9 -0
  106. package/dist/types/components/AppButton/AppButton.types.d.ts +0 -8
  107. package/dist/types/components/AppButton/AppButton.vue.d.ts +0 -20
  108. package/dist/types/components/AppButton/index.d.ts +0 -4
  109. package/dist/types/components/AppCard/AppCard.types.d.ts +0 -5
  110. package/dist/types/components/AppCard/AppCard.vue.d.ts +0 -17
  111. package/dist/types/components/AppCard/index.d.ts +0 -4
  112. package/src/components/AppButton/AppButton.element.scss +0 -2
  113. package/src/components/AppButton/AppButton.types.ts +0 -10
  114. package/src/components/AppButton/AppButton.vue +0 -65
  115. package/src/components/AppButton/index.ts +0 -6
  116. package/src/components/AppCard/AppCard.types.ts +0 -5
  117. package/src/components/AppCard/AppCard.vue +0 -58
  118. package/src/components/AppCard/index.ts +0 -6
@@ -0,0 +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
+ }
@@ -0,0 +1,99 @@
1
+ <template>
2
+ <div class="fly-regional-tenant-form-renderer">
3
+ <el-collapse v-if="sections?.length" v-model="activeNames" accordion>
4
+ <el-collapse-item :name="E_CollapsibleSections.mainForm">
5
+ <template #title>
6
+ <FlyCollapseTitleRenderer :title="mainFormTitle" />
7
+ </template>
8
+
9
+ <div style="padding: 1rem">
10
+ <slot></slot>
11
+ </div>
12
+ </el-collapse-item>
13
+
14
+ <template v-for="section in sections">
15
+ <el-collapse-item v-if="section.fields?.length" :key="section.key" :name="section.key">
16
+ <template #title>
17
+ <FlyCollapseTitleRenderer :title="section.title" />
18
+ </template>
19
+ <div style="padding: 1rem">
20
+ <div v-if="section.description" style="margin-bottom: 1.25rem">
21
+ <p style="font-size: 0.875; line-height: 1.25rem">
22
+ {{ t(section.description) }}
23
+ </p>
24
+ </div>
25
+
26
+ <FlyFormSchemaRenderer
27
+ :ref="(el) => setFormRef(el, section.key)"
28
+ v-model="section.modelValue"
29
+ :lookup-data="section.lookupData"
30
+ :form-config="section.fields"
31
+ :column-span="6"
32
+ />
33
+ </div>
34
+ </el-collapse-item>
35
+ </template>
36
+ </el-collapse>
37
+
38
+ <div v-else>
39
+ <slot></slot>
40
+ </div>
41
+ </div>
42
+ </template>
43
+
44
+ <script setup lang="ts">
45
+ import { type ComponentPublicInstance, reactive, ref } from 'vue'
46
+
47
+ import { ElCollapse, ElCollapseItem } from 'element-plus'
48
+
49
+ import { UseLocaleInjector } from '../../../../composables/UseLocaleInjector'
50
+ import '../../../../styles/element/overrides/collapse.scss'
51
+ import FlyCollapseTitleRenderer from '../../../basic/typography/FlyCollapseTitleRenderer.vue'
52
+ import type { T_FlyFormSchemaRendererInstance } from '../form-schema-renderer/FlyFormSchemaRenderer.types'
53
+ import FlyFormSchemaRenderer from '../form-schema-renderer/FlyFormSchemaRenderer.vue'
54
+
55
+ import type { T_TenantRegionalFormProps } from './FlyRegionalTenantFormRenderer.types'
56
+
57
+ enum E_CollapsibleSections {
58
+ mainForm
59
+ }
60
+
61
+ defineProps<T_TenantRegionalFormProps>()
62
+
63
+ const { t } = UseLocaleInjector()
64
+
65
+ const activeNames = ref<string | number>(E_CollapsibleSections.mainForm)
66
+ const formRefs = reactive<{ [K: string]: T_FlyFormSchemaRendererInstance }>({})
67
+
68
+ function setFormRef(formRef: Element | ComponentPublicInstance | null, key: string) {
69
+ if (formRef) {
70
+ formRefs[key] = formRef as T_FlyFormSchemaRendererInstance
71
+ }
72
+ }
73
+
74
+ async function validateForms() {
75
+ const keys = Object.keys(formRefs)
76
+ for (let index = 0; index < keys.length; index++) {
77
+ const element = formRefs[keys[index]]
78
+ const hasErrors = await element?.validateForm()
79
+ if (!hasErrors) continue
80
+ return hasErrors
81
+ }
82
+
83
+ return
84
+ }
85
+
86
+ defineExpose({
87
+ validateForms
88
+ })
89
+ </script>
90
+
91
+ <style lang="scss" scoped>
92
+ @use '../../../../styles/element/mixins/collapse.scss' as el-collapse-mixin;
93
+
94
+ .fly-regional-tenant-form-renderer {
95
+ :deep(.el-collapse) {
96
+ @include el-collapse-mixin.el-collapse-operation-style;
97
+ }
98
+ }
99
+ </style>
@@ -0,0 +1 @@
1
+ @use '../../../../styles/element/overrides/select.scss';
@@ -0,0 +1,25 @@
1
+ export type T_InputSelectValue = string | number | (string | number)[] | undefined
2
+
3
+ export type T_InputLabelValue = {
4
+ label: string
5
+ value: string | number
6
+ }
7
+ export type T_InputSelectOption = T_InputLabelValue | (number | string)
8
+ export type T_InputSelectOptionList = T_InputSelectOption[] | Record<string, T_InputLabelValue>
9
+
10
+ export type T_InputSelectBase = T_InputSelect & {
11
+ type: 'select'
12
+ }
13
+
14
+ export type T_InputSelect = {
15
+ placeholder?: string
16
+ /**
17
+ * Attrs are passed directly to the input element as props
18
+ */
19
+ attrs?: {
20
+ multiple?: boolean
21
+ }
22
+ config?: {
23
+ options: T_InputSelectOptionList
24
+ }
25
+ }
@@ -0,0 +1,37 @@
1
+ import { isArray, isObject } from 'lodash-es'
2
+
3
+ import type {
4
+ T_InputLabelValue,
5
+ T_InputSelectOption,
6
+ T_InputSelectOptionList
7
+ } from './FlySelect.types'
8
+
9
+ export function normalizeSelectOptionsToDict(
10
+ options: T_InputSelectOptionList
11
+ ): Record<string, T_InputLabelValue> {
12
+ // already a dict: Record<string, {label,value}>
13
+ if (!isArray(options)) {
14
+ const out: Record<string, T_InputLabelValue> = {}
15
+ Object.keys(options).forEach((k) => {
16
+ const item = options[k]
17
+ out[String(item.value)] = item
18
+ })
19
+ return out
20
+ }
21
+
22
+ // array: (string|number) OR {label,value}
23
+ const out: Record<string, T_InputLabelValue> = {}
24
+ options.forEach((opt: T_InputSelectOption) => {
25
+ if (isObject(opt)) {
26
+ const lv = opt as T_InputLabelValue
27
+ out[String(lv.value)] = lv
28
+ } else {
29
+ // primitive option => label=value
30
+ out[String(opt)] = {
31
+ label: String(opt),
32
+ value: opt
33
+ }
34
+ }
35
+ })
36
+ return out
37
+ }
@@ -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,70 @@
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, watch } 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
+
57
+ watch(
58
+ () => props.modelValue,
59
+ () => {
60
+ const parsed = castValue(props.modelValue)
61
+
62
+ if (parsed !== props.modelValue) {
63
+ emit('update:modelValue', parsed)
64
+ }
65
+ },
66
+ {
67
+ immediate: true
68
+ }
69
+ )
70
+ </script>
@@ -0,0 +1,2 @@
1
+ @use '../text/FlyText.scss';
2
+ @use '../select/FlySelect.scss';
@@ -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,102 @@
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({
63
+ get: () => {
64
+ const v = getInputDisplayValue(
65
+ props.modelValue?.value,
66
+ valueTypeIsString.value ? 'text' : 'number'
67
+ )
68
+ return v
69
+ },
70
+ set: (v) => {
71
+ emit('update:modelValue', getValue(v))
72
+ }
73
+ })
74
+
75
+ const unitProxy = computed({
76
+ get: () => props.modelValue?.unit ?? undefined,
77
+ set: (u) => {
78
+ emit('update:modelValue', getUnit(u))
79
+ }
80
+ })
81
+
82
+ function ensure(): NonNullable<T_ValueUnitValue> {
83
+ return {
84
+ value: props.modelValue?.value ?? undefined,
85
+ unit: props.modelValue?.unit ?? undefined
86
+ }
87
+ }
88
+
89
+ function getValue(v: string | number) {
90
+ const base = ensure()
91
+ const parsed = valueTypeIsString.value ? v : displayToNumber(v)
92
+
93
+ const next = { ...base, value: parsed }
94
+ return next
95
+ }
96
+
97
+ function getUnit(u: NonNullable<T_ValueUnitValue>['unit']) {
98
+ const base = ensure()
99
+ const next = { ...base, unit: u }
100
+ return next
101
+ }
102
+ </script>
@@ -0,0 +1,99 @@
1
+ import type { FormItemRule } from 'element-plus'
2
+
3
+ import { isNil } from 'lodash-es'
4
+
5
+ import { UseLocaleInjector } from '../../composables/UseLocaleInjector'
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
+ export const requiredField = (
13
+ fieldLabel = 'validation.field',
14
+ trigger: InputTriggers = 'blur',
15
+ useRequiredMessage = true
16
+ ): FormItemRule => {
17
+ return {
18
+ required: true,
19
+ trigger: trigger,
20
+ message: useRequiredMessage ? isRequiredError(fieldLabel) : fieldLabel
21
+ }
22
+ }
23
+
24
+ export const checkInputRangeValidator = (
25
+ validator: ReturnType<typeof checkInputRange>,
26
+ trigger: InputTriggers = 'change'
27
+ ): FormItemRule => ({
28
+ trigger: trigger,
29
+ validator
30
+ })
31
+
32
+ export const requiredFieldNumber = (
33
+ languageKey = 'validation.field',
34
+ trigger: InputTriggers = 'change'
35
+ ): FormItemRule => {
36
+ const { t } = UseLocaleInjector()
37
+
38
+ return {
39
+ type: 'number',
40
+ required: true,
41
+ trigger: trigger,
42
+ message: t
43
+ ? t('validation.fieldMustBeANumber', {
44
+ fieldName: t(languageKey)
45
+ })
46
+ : 'validation.fieldMustBeANumber'
47
+ }
48
+ }
49
+
50
+ export const requiredFieldNumberSelect = (
51
+ label = 'validation.field',
52
+ trigger: InputTriggers = 'blur',
53
+ useRequiredMessage = true
54
+ ): FormItemRule =>
55
+ requiredFieldValueUnit(label, trigger, useRequiredMessage, true, {
56
+ valueType: 'number'
57
+ })
58
+
59
+ export const requiredFieldValueUnit = (
60
+ label = 'validation.field',
61
+ trigger: InputTriggers = 'blur',
62
+ useRequiredMessage = true,
63
+ required = true,
64
+ options: {
65
+ valueType?: 'text' | 'number'
66
+ }
67
+ ): FormItemRule => ({
68
+ required: required,
69
+ trigger: trigger,
70
+ validator: (_rule, value: T_ValueUnitValue, callback) => {
71
+ // used in element form validator
72
+ if (
73
+ (options?.valueType === 'number' &&
74
+ !(
75
+ value &&
76
+ value.unit !== '' &&
77
+ value.value !== '' &&
78
+ !isNil(value.unit) &&
79
+ !isNil(value.value)
80
+ )) ||
81
+ !value
82
+ ) {
83
+ return callback(new Error(useRequiredMessage ? isRequiredError(label) : label))
84
+ }
85
+
86
+ return callback()
87
+ }
88
+ })
89
+
90
+ export const requiredFieldArray = (
91
+ label = 'validation.field',
92
+ trigger: InputTriggers = 'change',
93
+ useRequiredMessage = true
94
+ ): FormItemRule => ({
95
+ type: 'array',
96
+ required: true,
97
+ trigger: trigger,
98
+ message: useRequiredMessage ? isRequiredError(label) : label
99
+ })
@@ -0,0 +1,6 @@
1
+ import { type Component } from 'vue'
2
+
3
+ export type T_FlyIconV2Props = {
4
+ icon: Component
5
+ size?: string | number
6
+ }
@@ -0,0 +1,17 @@
1
+ <template>
2
+ <component
3
+ :is="icon"
4
+ class="fly-icon"
5
+ :style="{
6
+ fontSize: typeof size === 'number' ? `${size}px` : size
7
+ }"
8
+ />
9
+ </template>
10
+
11
+ <script setup lang="ts">
12
+ import type { T_FlyIconV2Props } from './FlyIconV2.types'
13
+
14
+ defineProps<T_FlyIconV2Props>()
15
+ </script>
16
+
17
+ <style lang="scss" scoped></style>
@@ -0,0 +1,6 @@
1
+ import FlyIconV2 from './FlyIconV2.vue'
2
+
3
+ export default FlyIconV2
4
+ export { FlyIconV2 }
5
+
6
+ export type { T_FlyIconV2Props } from './FlyIconV2.types.ts'
@@ -1,2 +1,5 @@
1
1
  export { default as FlyIcon } from './fly-icon'
2
2
  export type * from './fly-icon'
3
+
4
+ export { default as T_FlyIconV2 } from './fly-icon-v2'
5
+ export type * from './fly-icon-v2'
@@ -1,11 +1,7 @@
1
- export { default as AppButton } from './AppButton'
2
- export type * from './AppButton'
3
-
4
- export { default as AppCard } from './AppCard'
5
- export type * from './AppCard'
6
-
7
1
  export * from './navigation'
8
2
 
9
3
  export * from './basic'
10
4
  export * from './feedback'
11
5
  export * from './general'
6
+
7
+ export * from './form'
@@ -1,8 +1,8 @@
1
- import type { T_FlyIconProps } from '../../../general/fly-icon'
1
+ import type { T_FlyIconV2Props } from '../../../general/fly-icon-v2/FlyIconV2.types'
2
2
 
3
3
  export type T_FlyMiniSidebarItem = {
4
4
  key: string | number
5
5
  label: string
6
6
  path: string
7
- icon: T_FlyIconProps
7
+ icon: T_FlyIconV2Props['icon']
8
8
  }
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <router-link :to="menu.path" class="anra-sidebar-item" active-class="anra-sidebar-item--active">
3
3
  <span class="anra-sidebar-item__icon">
4
- <FlyIcon :icon="menu.icon.icon" :type="menu.icon.type" />
4
+ <FlyIconV2 :icon="menu.icon" />
5
5
  </span>
6
6
 
7
7
  <span class="anra-sidebar-item__label">{{ menu.label }}</span>
@@ -9,7 +9,7 @@
9
9
  </template>
10
10
 
11
11
  <script setup lang="ts">
12
- import FlyIcon from '../../../general/fly-icon/FlyIcon.vue'
12
+ import FlyIconV2 from '../../../general/fly-icon-v2/FlyIconV2.vue'
13
13
 
14
14
  import type { T_FlyMiniSidebarItem } from './FlyMiniSidebar.types'
15
15
 
@@ -1,9 +1,9 @@
1
- import type { T_FlyIconProps } from '../../../general/fly-icon/FlyIcon.types'
1
+ import type { T_FlyIconV2Props } from '../../../general'
2
2
 
3
3
  export type T_FlySidebarBase = {
4
4
  index: string
5
5
  label?: string
6
- icon?: T_FlyIconProps
6
+ icon?: T_FlyIconV2Props['icon']
7
7
  disabled?: boolean
8
8
  }
9
9