@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,146 +1,146 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="fly-sidebar">
|
|
3
|
-
<el-scrollbar :height="height">
|
|
4
|
-
<el-menu
|
|
5
|
-
:default-active="defaultActive"
|
|
6
|
-
:collapse="isCollapsed"
|
|
7
|
-
:router="router"
|
|
8
|
-
popper-class="fly-sidebar-popper"
|
|
9
|
-
>
|
|
10
|
-
<FlySidebarNode v-for="node in menu" :key="node.index" :node="node" />
|
|
11
|
-
</el-menu>
|
|
12
|
-
</el-scrollbar>
|
|
13
|
-
|
|
14
|
-
<div class="fly_sidebar__collapse-trigger" role="button" @click="toggleCollapse">
|
|
15
|
-
<FlyIconV2 :icon="isCollapsed ? IconMdiChevronRight : IconMdiChevronLeft" />
|
|
16
|
-
</div>
|
|
17
|
-
</div>
|
|
18
|
-
</template>
|
|
19
|
-
|
|
20
|
-
<script lang="ts" setup>
|
|
21
|
-
import IconMdiChevronLeft from '~icons/mdi/chevron-left'
|
|
22
|
-
import IconMdiChevronRight from '~icons/mdi/chevron-right'
|
|
23
|
-
|
|
24
|
-
import { ElMenu, ElScrollbar } from 'element-plus'
|
|
25
|
-
|
|
26
|
-
import FlyIconV2 from '../../../general/fly-icon-v2/FlyIconV2.vue'
|
|
27
|
-
|
|
28
|
-
import './FlySidebar.element.scss'
|
|
29
|
-
import type { T_FlySidebarProps } from './FlySidebar.types'
|
|
30
|
-
import FlySidebarNode from './FlySidebarNode.vue'
|
|
31
|
-
|
|
32
|
-
const { router = true, defaultActive, menu, height } = defineProps<T_FlySidebarProps>()
|
|
33
|
-
|
|
34
|
-
const isCollapsed = defineModel<boolean>('collapsed', { default: false })
|
|
35
|
-
|
|
36
|
-
function toggleCollapse() {
|
|
37
|
-
isCollapsed.value = !isCollapsed.value
|
|
38
|
-
}
|
|
39
|
-
</script>
|
|
40
|
-
|
|
41
|
-
<style lang="scss" scoped>
|
|
42
|
-
$radius: 9999px;
|
|
43
|
-
$height: 30px;
|
|
44
|
-
$trigger-height: 20px;
|
|
45
|
-
|
|
46
|
-
.fly-sidebar {
|
|
47
|
-
position: relative;
|
|
48
|
-
display: inline-block;
|
|
49
|
-
height: 100%;
|
|
50
|
-
background-color: var(--el-menu-bg-color);
|
|
51
|
-
border-inline-end: 1px solid var(--anra-border-color);
|
|
52
|
-
|
|
53
|
-
:deep(.el-menu) {
|
|
54
|
-
border-right: 0;
|
|
55
|
-
&.el-menu--vertical {
|
|
56
|
-
--el-menu-item-height: #{$height};
|
|
57
|
-
--el-menu-sub-item-height: calc(var(--el-menu-item-height) - 6px);
|
|
58
|
-
|
|
59
|
-
padding-inline-end: 1rem;
|
|
60
|
-
padding-top: calc(#{$trigger-height} + 10px);
|
|
61
|
-
padding-bottom: 1rem;
|
|
62
|
-
min-height: auto;
|
|
63
|
-
height: 100%;
|
|
64
|
-
|
|
65
|
-
&.el-menu--collapse {
|
|
66
|
-
padding-inline-end: 0.3rem;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
&:not(.el-menu--collapse) {
|
|
70
|
-
width: 200px;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.fly_sidebar__collapse-trigger {
|
|
77
|
-
position: absolute;
|
|
78
|
-
top: 5px;
|
|
79
|
-
inset-inline-end: 0;
|
|
80
|
-
width: calc(#{$trigger-height} + 5px);
|
|
81
|
-
height: $trigger-height;
|
|
82
|
-
display: flex;
|
|
83
|
-
align-items: center;
|
|
84
|
-
justify-content: center;
|
|
85
|
-
border-top: 1px solid var(--anra-border-color);
|
|
86
|
-
border-left: 1px solid var(--anra-border-color);
|
|
87
|
-
border-bottom: 1px solid var(--anra-border-color);
|
|
88
|
-
color: var(--dynamic-light);
|
|
89
|
-
border-start-start-radius: 5px;
|
|
90
|
-
border-end-start-radius: 5px;
|
|
91
|
-
cursor: pointer;
|
|
92
|
-
transition: all 0.2s ease;
|
|
93
|
-
|
|
94
|
-
&:hover {
|
|
95
|
-
background-color: var(--anra-primary);
|
|
96
|
-
color: var(--anra-black);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
</style>
|
|
100
|
-
|
|
101
|
-
<style lang="scss">
|
|
102
|
-
$radius: 9999px;
|
|
103
|
-
$height: 30px;
|
|
104
|
-
|
|
105
|
-
.fly-sidebar .el-menu.el-menu--vertical,
|
|
106
|
-
.fly-sidebar-popper {
|
|
107
|
-
--el-menu-item-height: #{$height};
|
|
108
|
-
--el-menu-sub-item-height: calc(var(--el-menu-item-height) - 2px);
|
|
109
|
-
|
|
110
|
-
& > li:not(:last-child),
|
|
111
|
-
.el-sub-menu .el-menu .el-menu-item {
|
|
112
|
-
margin-bottom: 4px;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.el-sub-menu {
|
|
116
|
-
--el-menu-item-height: #{$height};
|
|
117
|
-
|
|
118
|
-
.el-menu {
|
|
119
|
-
padding-top: 0.25rem;
|
|
120
|
-
padding-bottom: 0.25rem;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
.el-sub-menu__title,
|
|
125
|
-
.el-menu-item {
|
|
126
|
-
border-top-right-radius: $radius;
|
|
127
|
-
border-bottom-right-radius: $radius;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
.el-menu-item.is-active {
|
|
131
|
-
font-weight: 500;
|
|
132
|
-
background-color: var(--anra-primary);
|
|
133
|
-
color: var(--anra-text-on-primary);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
.fly-sidebar {
|
|
138
|
-
--el-menu-base-level-padding: 10px;
|
|
139
|
-
|
|
140
|
-
.el-menu-item [class^='el-icon'],
|
|
141
|
-
.el-sub-menu__title [class^='el-icon']:not(.el-sub-menu__icon-arrow) {
|
|
142
|
-
margin-right: 10px;
|
|
143
|
-
font-size: 15px;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="fly-sidebar">
|
|
3
|
+
<el-scrollbar :height="height">
|
|
4
|
+
<el-menu
|
|
5
|
+
:default-active="defaultActive"
|
|
6
|
+
:collapse="isCollapsed"
|
|
7
|
+
:router="router"
|
|
8
|
+
popper-class="fly-sidebar-popper"
|
|
9
|
+
>
|
|
10
|
+
<FlySidebarNode v-for="node in menu" :key="node.index" :node="node" />
|
|
11
|
+
</el-menu>
|
|
12
|
+
</el-scrollbar>
|
|
13
|
+
|
|
14
|
+
<div class="fly_sidebar__collapse-trigger" role="button" @click="toggleCollapse">
|
|
15
|
+
<FlyIconV2 :icon="isCollapsed ? IconMdiChevronRight : IconMdiChevronLeft" />
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script lang="ts" setup>
|
|
21
|
+
import IconMdiChevronLeft from '~icons/mdi/chevron-left'
|
|
22
|
+
import IconMdiChevronRight from '~icons/mdi/chevron-right'
|
|
23
|
+
|
|
24
|
+
import { ElMenu, ElScrollbar } from 'element-plus'
|
|
25
|
+
|
|
26
|
+
import FlyIconV2 from '../../../general/fly-icon-v2/FlyIconV2.vue'
|
|
27
|
+
|
|
28
|
+
import './FlySidebar.element.scss'
|
|
29
|
+
import type { T_FlySidebarProps } from './FlySidebar.types'
|
|
30
|
+
import FlySidebarNode from './FlySidebarNode.vue'
|
|
31
|
+
|
|
32
|
+
const { router = true, defaultActive, menu, height } = defineProps<T_FlySidebarProps>()
|
|
33
|
+
|
|
34
|
+
const isCollapsed = defineModel<boolean>('collapsed', { default: false })
|
|
35
|
+
|
|
36
|
+
function toggleCollapse() {
|
|
37
|
+
isCollapsed.value = !isCollapsed.value
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<style lang="scss" scoped>
|
|
42
|
+
$radius: 9999px;
|
|
43
|
+
$height: 30px;
|
|
44
|
+
$trigger-height: 20px;
|
|
45
|
+
|
|
46
|
+
.fly-sidebar {
|
|
47
|
+
position: relative;
|
|
48
|
+
display: inline-block;
|
|
49
|
+
height: 100%;
|
|
50
|
+
background-color: var(--el-menu-bg-color);
|
|
51
|
+
border-inline-end: 1px solid var(--anra-border-color);
|
|
52
|
+
|
|
53
|
+
:deep(.el-menu) {
|
|
54
|
+
border-right: 0;
|
|
55
|
+
&.el-menu--vertical {
|
|
56
|
+
--el-menu-item-height: #{$height};
|
|
57
|
+
--el-menu-sub-item-height: calc(var(--el-menu-item-height) - 6px);
|
|
58
|
+
|
|
59
|
+
padding-inline-end: 1rem;
|
|
60
|
+
padding-top: calc(#{$trigger-height} + 10px);
|
|
61
|
+
padding-bottom: 1rem;
|
|
62
|
+
min-height: auto;
|
|
63
|
+
height: 100%;
|
|
64
|
+
|
|
65
|
+
&.el-menu--collapse {
|
|
66
|
+
padding-inline-end: 0.3rem;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&:not(.el-menu--collapse) {
|
|
70
|
+
width: 200px;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.fly_sidebar__collapse-trigger {
|
|
77
|
+
position: absolute;
|
|
78
|
+
top: 5px;
|
|
79
|
+
inset-inline-end: 0;
|
|
80
|
+
width: calc(#{$trigger-height} + 5px);
|
|
81
|
+
height: $trigger-height;
|
|
82
|
+
display: flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
justify-content: center;
|
|
85
|
+
border-top: 1px solid var(--anra-border-color);
|
|
86
|
+
border-left: 1px solid var(--anra-border-color);
|
|
87
|
+
border-bottom: 1px solid var(--anra-border-color);
|
|
88
|
+
color: var(--dynamic-light);
|
|
89
|
+
border-start-start-radius: 5px;
|
|
90
|
+
border-end-start-radius: 5px;
|
|
91
|
+
cursor: pointer;
|
|
92
|
+
transition: all 0.2s ease;
|
|
93
|
+
|
|
94
|
+
&:hover {
|
|
95
|
+
background-color: var(--anra-primary);
|
|
96
|
+
color: var(--anra-black);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
</style>
|
|
100
|
+
|
|
101
|
+
<style lang="scss">
|
|
102
|
+
$radius: 9999px;
|
|
103
|
+
$height: 30px;
|
|
104
|
+
|
|
105
|
+
.fly-sidebar .el-menu.el-menu--vertical,
|
|
106
|
+
.fly-sidebar-popper {
|
|
107
|
+
--el-menu-item-height: #{$height};
|
|
108
|
+
--el-menu-sub-item-height: calc(var(--el-menu-item-height) - 2px);
|
|
109
|
+
|
|
110
|
+
& > li:not(:last-child),
|
|
111
|
+
.el-sub-menu .el-menu .el-menu-item {
|
|
112
|
+
margin-bottom: 4px;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.el-sub-menu {
|
|
116
|
+
--el-menu-item-height: #{$height};
|
|
117
|
+
|
|
118
|
+
.el-menu {
|
|
119
|
+
padding-top: 0.25rem;
|
|
120
|
+
padding-bottom: 0.25rem;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.el-sub-menu__title,
|
|
125
|
+
.el-menu-item {
|
|
126
|
+
border-top-right-radius: $radius;
|
|
127
|
+
border-bottom-right-radius: $radius;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.el-menu-item.is-active {
|
|
131
|
+
font-weight: 500;
|
|
132
|
+
background-color: var(--anra-primary);
|
|
133
|
+
color: var(--anra-text-on-primary);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.fly-sidebar {
|
|
138
|
+
--el-menu-base-level-padding: 10px;
|
|
139
|
+
|
|
140
|
+
.el-menu-item [class^='el-icon'],
|
|
141
|
+
.el-sub-menu__title [class^='el-icon']:not(.el-sub-menu__icon-arrow) {
|
|
142
|
+
margin-right: 10px;
|
|
143
|
+
font-size: 15px;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
</style>
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-menu-item v-if="node.type === 'item'" :index="node.index" :disabled="node.disabled">
|
|
3
|
-
<template v-if="node.icon">
|
|
4
|
-
<i class="el-icon">
|
|
5
|
-
<FlyIconV2 :icon="node.icon" />
|
|
6
|
-
</i>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<template #title>
|
|
10
|
-
{{ node.label }}
|
|
11
|
-
</template>
|
|
12
|
-
</el-menu-item>
|
|
13
|
-
|
|
14
|
-
<el-sub-menu v-else-if="node.type === 'submenu'" :index="node.index">
|
|
15
|
-
<template #title>
|
|
16
|
-
<template v-if="node.icon">
|
|
17
|
-
<i class="el-icon">
|
|
18
|
-
<FlyIconV2 :icon="node.icon" />
|
|
19
|
-
</i>
|
|
20
|
-
</template>
|
|
21
|
-
|
|
22
|
-
<span>{{ node.label }}</span>
|
|
23
|
-
</template>
|
|
24
|
-
|
|
25
|
-
<FlySidebarNode v-for="child in node.children" :key="child.index" :node="child" />
|
|
26
|
-
</el-sub-menu>
|
|
27
|
-
|
|
28
|
-
<el-menu-item-group v-else>
|
|
29
|
-
<template v-if="node.label" #title>
|
|
30
|
-
<span>{{ node.label }}</span>
|
|
31
|
-
</template>
|
|
32
|
-
|
|
33
|
-
<FlySidebarNode v-for="child in node.children" :key="child.index" :node="child" />
|
|
34
|
-
</el-menu-item-group>
|
|
35
|
-
</template>
|
|
36
|
-
|
|
37
|
-
<script lang="ts" setup>
|
|
38
|
-
import { ElMenuItem, ElMenuItemGroup, ElSubMenu } from 'element-plus'
|
|
39
|
-
|
|
40
|
-
import FlyIconV2 from '../../../general/fly-icon-v2/FlyIconV2.vue'
|
|
41
|
-
|
|
42
|
-
import type { T_FlySidebarNode } from './FlySidebar.types'
|
|
43
|
-
|
|
44
|
-
defineProps<{
|
|
45
|
-
node: T_FlySidebarNode
|
|
46
|
-
}>()
|
|
47
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<el-menu-item v-if="node.type === 'item'" :index="node.index" :disabled="node.disabled">
|
|
3
|
+
<template v-if="node.icon">
|
|
4
|
+
<i class="el-icon">
|
|
5
|
+
<FlyIconV2 :icon="node.icon" />
|
|
6
|
+
</i>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<template #title>
|
|
10
|
+
{{ node.label }}
|
|
11
|
+
</template>
|
|
12
|
+
</el-menu-item>
|
|
13
|
+
|
|
14
|
+
<el-sub-menu v-else-if="node.type === 'submenu'" :index="node.index">
|
|
15
|
+
<template #title>
|
|
16
|
+
<template v-if="node.icon">
|
|
17
|
+
<i class="el-icon">
|
|
18
|
+
<FlyIconV2 :icon="node.icon" />
|
|
19
|
+
</i>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<span>{{ node.label }}</span>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<FlySidebarNode v-for="child in node.children" :key="child.index" :node="child" />
|
|
26
|
+
</el-sub-menu>
|
|
27
|
+
|
|
28
|
+
<el-menu-item-group v-else>
|
|
29
|
+
<template v-if="node.label" #title>
|
|
30
|
+
<span>{{ node.label }}</span>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<FlySidebarNode v-for="child in node.children" :key="child.index" :node="child" />
|
|
34
|
+
</el-menu-item-group>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<script lang="ts" setup>
|
|
38
|
+
import { ElMenuItem, ElMenuItemGroup, ElSubMenu } from 'element-plus'
|
|
39
|
+
|
|
40
|
+
import FlyIconV2 from '../../../general/fly-icon-v2/FlyIconV2.vue'
|
|
41
|
+
|
|
42
|
+
import type { T_FlySidebarNode } from './FlySidebar.types'
|
|
43
|
+
|
|
44
|
+
defineProps<{
|
|
45
|
+
node: T_FlySidebarNode
|
|
46
|
+
}>()
|
|
47
|
+
</script>
|
package/src/composables/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
export
|
|
1
|
+
export * from './useLocaleInjector'
|
|
2
|
+
export * from './useSidebarActiveIndex'
|
|
3
|
+
export * from './useFeatureGate'
|
|
4
|
+
export * from './useFormHider'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useFeatureGate'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type MaybeRefOrGetter, computed, toValue } from 'vue'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type T_FeatureGatingConfig,
|
|
5
|
+
type T_GateInput,
|
|
6
|
+
isFeatureAllowedByPriority
|
|
7
|
+
} from '@flyanra/js-utils/utils'
|
|
8
|
+
|
|
9
|
+
export function useFeatureGate(
|
|
10
|
+
configRefs: MaybeRefOrGetter<(T_FeatureGatingConfig | undefined)[]>
|
|
11
|
+
) {
|
|
12
|
+
const allow = <TModuleKey extends string>(gate: T_GateInput<TModuleKey> | undefined) =>
|
|
13
|
+
computed(() => isFeatureAllowedByPriority(toValue(configRefs), gate))
|
|
14
|
+
|
|
15
|
+
const allowNow = <TModuleKey extends string>(gate: T_GateInput<TModuleKey> | undefined) =>
|
|
16
|
+
isFeatureAllowedByPriority(toValue(configRefs), gate)
|
|
17
|
+
|
|
18
|
+
return { allow, allowNow }
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useFormHider'
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type ComputedRef, type MaybeRefOrGetter, computed, toValue } from 'vue'
|
|
2
|
+
|
|
3
|
+
import type { T_FeatureGatingConfig, T_FieldUiRule, T_FormUiConfig } from '@flyanra/js-utils/utils'
|
|
4
|
+
|
|
5
|
+
export function useFormHider<
|
|
6
|
+
TConfig extends T_FeatureGatingConfig,
|
|
7
|
+
TModuleKey extends string,
|
|
8
|
+
TFormKey extends string,
|
|
9
|
+
TFieldKey extends string
|
|
10
|
+
>(configsRef: MaybeRefOrGetter<(TConfig | undefined)[]>, moduleKey: TModuleKey, formKey: TFormKey) {
|
|
11
|
+
const resolved = computed(() => {
|
|
12
|
+
const configs = toValue(configsRef) ?? []
|
|
13
|
+
const fieldRules = new Map<TFieldKey, T_FieldUiRule>()
|
|
14
|
+
|
|
15
|
+
for (const config of configs) {
|
|
16
|
+
if (!config) continue
|
|
17
|
+
const formUi = config?.modules?.[moduleKey]?.ui?.forms?.[formKey] as
|
|
18
|
+
| T_FormUiConfig<TFieldKey>
|
|
19
|
+
| undefined
|
|
20
|
+
if (!formUi?.fields) continue
|
|
21
|
+
|
|
22
|
+
for (const [rawKey, rule] of Object.entries(formUi.fields) as [TFieldKey, T_FieldUiRule][]) {
|
|
23
|
+
const existing = fieldRules.get(rawKey)
|
|
24
|
+
fieldRules.set(rawKey, {
|
|
25
|
+
hidden: existing?.hidden === true || rule.hidden === true
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return { fieldRules }
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const isFieldHidden = (key: TFieldKey): ComputedRef<boolean> =>
|
|
34
|
+
computed(() => resolved.value.fieldRules.get(key)?.hidden === true)
|
|
35
|
+
|
|
36
|
+
return { resolved, isFieldHidden }
|
|
37
|
+
}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { isRef } from 'vue'
|
|
2
|
-
import type { MaybeRef } from 'vue'
|
|
3
|
-
|
|
4
|
-
import { FallbackTranslateFn } from '@flyanra/js-utils/constants'
|
|
5
|
-
import type { Locale } from '@flyanra/js-utils/locales'
|
|
6
|
-
import type { ComposerTranslation } from 'vue-i18n'
|
|
7
|
-
|
|
8
|
-
export type T_LocaleInjector = {
|
|
9
|
-
t: ComposerTranslation
|
|
10
|
-
locale: Locale
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
type I18nLike = {
|
|
14
|
-
t: ComposerTranslation
|
|
15
|
-
locale: MaybeRef<Locale>
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
let _t: ComposerTranslation = FallbackTranslateFn
|
|
19
|
-
let _locale: MaybeRef<Locale> = 'en'
|
|
20
|
-
let _initialized = false
|
|
21
|
-
|
|
22
|
-
export function initLocaleInjector(i18n: I18nLike): void {
|
|
23
|
-
_t = i18n.t
|
|
24
|
-
_locale = i18n.locale
|
|
25
|
-
_initialized = true
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function UseLocaleInjector(): T_LocaleInjector {
|
|
29
|
-
if (!_initialized) {
|
|
30
|
-
console.warn('[vue-core] UseLocaleInjector: call initLocaleInjector() before use.')
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
t: _t,
|
|
35
|
-
locale: isRef(_locale) ? _locale.value : _locale
|
|
36
|
-
}
|
|
37
|
-
}
|
|
1
|
+
import { isRef } from 'vue'
|
|
2
|
+
import type { MaybeRef } from 'vue'
|
|
3
|
+
|
|
4
|
+
import { FallbackTranslateFn } from '@flyanra/js-utils/constants'
|
|
5
|
+
import type { Locale } from '@flyanra/js-utils/locales'
|
|
6
|
+
import type { ComposerTranslation } from 'vue-i18n'
|
|
7
|
+
|
|
8
|
+
export type T_LocaleInjector = {
|
|
9
|
+
t: ComposerTranslation
|
|
10
|
+
locale: Locale
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type I18nLike = {
|
|
14
|
+
t: ComposerTranslation
|
|
15
|
+
locale: MaybeRef<Locale>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let _t: ComposerTranslation = FallbackTranslateFn
|
|
19
|
+
let _locale: MaybeRef<Locale> = 'en'
|
|
20
|
+
let _initialized = false
|
|
21
|
+
|
|
22
|
+
export function initLocaleInjector(i18n: I18nLike): void {
|
|
23
|
+
_t = i18n.t
|
|
24
|
+
_locale = i18n.locale
|
|
25
|
+
_initialized = true
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function UseLocaleInjector(): T_LocaleInjector {
|
|
29
|
+
if (!_initialized) {
|
|
30
|
+
console.warn('[vue-core] UseLocaleInjector: call initLocaleInjector() before use.')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
t: _t,
|
|
35
|
+
locale: isRef(_locale) ? _locale.value : _locale
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useSidebarActiveIndex } from './useSidebarActiveIndex'
|