@xen-orchestra/web-core 0.31.1 → 0.33.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/lib/assets/css/_colors.pcss +8 -0
- package/lib/components/button-group/VtsButtonGroup.vue +5 -1
- package/lib/components/menu/MenuList.vue +1 -2
- package/lib/components/menu/MenuTrigger.vue +5 -11
- package/lib/components/modal/VtsModal.vue +82 -0
- package/lib/components/modal/VtsModalButton.vue +36 -0
- package/lib/components/modal/VtsModalCancelButton.vue +37 -0
- package/lib/components/modal/VtsModalConfirmButton.vue +21 -0
- package/lib/components/modal/VtsModalList.vue +34 -0
- package/lib/components/object-icon/VtsObjectIcon.vue +3 -8
- package/lib/components/status/VtsStatus.vue +66 -0
- package/lib/components/task/VtsQuickTaskList.vue +17 -5
- package/lib/components/tree/VtsTreeItem.vue +2 -2
- package/lib/components/ui/breadcrumb/UiBreadcrumb.vue +79 -0
- package/lib/components/ui/button/UiButton.vue +13 -67
- package/lib/components/ui/modal/UiModal.vue +164 -0
- package/lib/components/ui/quick-task-item/UiQuickTaskItem.vue +2 -2
- package/lib/composables/context.composable.ts +3 -5
- package/lib/composables/link-component.composable.ts +3 -2
- package/lib/composables/pagination.composable.ts +3 -2
- package/lib/composables/tree-filter.composable.ts +5 -3
- package/lib/icons/fa-icons.ts +13 -1
- package/lib/icons/index.ts +17 -0
- package/lib/locales/cs.json +60 -2
- package/lib/locales/de.json +40 -2
- package/lib/locales/en.json +27 -1
- package/lib/locales/es.json +51 -5
- package/lib/locales/fa.json +10 -10
- package/lib/locales/fr.json +28 -2
- package/lib/locales/it.json +4 -0
- package/lib/locales/nl.json +64 -14
- package/lib/locales/pt_BR.json +3 -3
- package/lib/locales/ru.json +41 -2
- package/lib/locales/sv.json +55 -1
- package/lib/locales/uk.json +4 -4
- package/lib/packages/collection/use-collection.ts +3 -2
- package/lib/packages/form-select/use-form-option-controller.ts +3 -2
- package/lib/packages/form-select/use-form-select.ts +8 -7
- package/lib/packages/menu/action.ts +4 -3
- package/lib/packages/menu/link.ts +5 -4
- package/lib/packages/menu/router-link.ts +3 -2
- package/lib/packages/menu/toggle-target.ts +3 -2
- package/lib/packages/modal/ModalProvider.vue +17 -0
- package/lib/packages/modal/README.md +253 -0
- package/lib/packages/modal/create-modal-opener.ts +103 -0
- package/lib/packages/modal/modal.store.ts +22 -0
- package/lib/packages/modal/types.ts +92 -0
- package/lib/packages/modal/use-modal.ts +53 -0
- package/lib/packages/progress/use-progress.ts +4 -3
- package/lib/packages/table/README.md +336 -0
- package/lib/packages/table/apply-extensions.ts +26 -0
- package/lib/packages/table/define-columns.ts +62 -0
- package/lib/packages/table/define-renderer/define-table-cell-renderer.ts +27 -0
- package/lib/packages/table/define-renderer/define-table-renderer.ts +47 -0
- package/lib/packages/table/define-renderer/define-table-row-renderer.ts +29 -0
- package/lib/packages/table/define-renderer/define-table-section-renderer.ts +29 -0
- package/lib/packages/table/define-table/define-multi-source-table.ts +39 -0
- package/lib/packages/table/define-table/define-table.ts +13 -0
- package/lib/packages/table/define-table/define-typed-table.ts +18 -0
- package/lib/packages/table/index.ts +11 -0
- package/lib/packages/table/transform-sources.ts +13 -0
- package/lib/packages/table/types/extensions.ts +16 -0
- package/lib/packages/table/types/index.ts +47 -0
- package/lib/packages/table/types/table-cell.ts +18 -0
- package/lib/packages/table/types/table-row.ts +20 -0
- package/lib/packages/table/types/table-section.ts +19 -0
- package/lib/packages/table/types/table.ts +28 -0
- package/lib/packages/threshold/use-threshold.ts +4 -3
- package/lib/types/vue-virtual-scroller.d.ts +101 -0
- package/lib/utils/injection-keys.util.ts +3 -0
- package/lib/utils/progress.util.ts +2 -1
- package/lib/utils/to-computed.util.ts +15 -0
- package/package.json +3 -2
- package/lib/components/backup-state/VtsBackupState.vue +0 -37
- package/lib/components/connection-status/VtsConnectionStatus.vue +0 -36
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { TableCellVNode } from '.'
|
|
2
|
+
import { reactive, computed } from 'vue'
|
|
3
|
+
|
|
4
|
+
export function defineColumns<
|
|
5
|
+
TSource,
|
|
6
|
+
TColumns extends Record<
|
|
7
|
+
string,
|
|
8
|
+
| {
|
|
9
|
+
header: (arg: THeaderArg) => TableCellVNode
|
|
10
|
+
body: (source: TSource, arg: TBodyArg) => TableCellVNode
|
|
11
|
+
}
|
|
12
|
+
| undefined
|
|
13
|
+
>,
|
|
14
|
+
TColumnName extends Extract<keyof TColumns, string>,
|
|
15
|
+
THeaderArg = undefined,
|
|
16
|
+
TBodyArg = undefined,
|
|
17
|
+
>(
|
|
18
|
+
config: TColumns &
|
|
19
|
+
Record<
|
|
20
|
+
string,
|
|
21
|
+
| {
|
|
22
|
+
header: (arg: THeaderArg) => TableCellVNode
|
|
23
|
+
body: (source: TSource, arg: TBodyArg) => TableCellVNode
|
|
24
|
+
}
|
|
25
|
+
| undefined
|
|
26
|
+
>
|
|
27
|
+
) {
|
|
28
|
+
const columnNames = Object.keys(config).filter(key => config[key] !== undefined) as TColumnName[]
|
|
29
|
+
|
|
30
|
+
const hiddenColumnNames = reactive(new Set()) as Set<TColumnName>
|
|
31
|
+
|
|
32
|
+
const visibleColumnNames = computed(() => columnNames.filter(name => !hiddenColumnNames.has(name)))
|
|
33
|
+
|
|
34
|
+
const visibleColumns = computed(() => visibleColumnNames.value.map(name => config[name]!))
|
|
35
|
+
|
|
36
|
+
const visibleColumnsCount = computed(() => visibleColumnNames.value.length)
|
|
37
|
+
|
|
38
|
+
type GetHeaderCells = THeaderArg extends undefined
|
|
39
|
+
? (arg?: THeaderArg) => TableCellVNode[]
|
|
40
|
+
: (arg: THeaderArg) => TableCellVNode[]
|
|
41
|
+
|
|
42
|
+
type GetBodyCells = TBodyArg extends undefined
|
|
43
|
+
? (source: TSource, arg?: TBodyArg) => TableCellVNode[]
|
|
44
|
+
: (source: TSource, arg: TBodyArg) => TableCellVNode[]
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
getHeaderCells: ((arg?: THeaderArg) =>
|
|
48
|
+
visibleColumns.value.map(column => column.header(arg as THeaderArg))) as GetHeaderCells,
|
|
49
|
+
|
|
50
|
+
getBodyCells: ((source: TSource, arg?: TBodyArg) =>
|
|
51
|
+
visibleColumns.value.map(column => column.body(source, arg as TBodyArg))) as GetBodyCells,
|
|
52
|
+
|
|
53
|
+
toggleColumn: (name: TColumnName, forcedValue = !hiddenColumnNames.has(name)) => {
|
|
54
|
+
if (forcedValue) {
|
|
55
|
+
hiddenColumnNames.add(name)
|
|
56
|
+
} else {
|
|
57
|
+
hiddenColumnNames.delete(name)
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
visibleColumnsCount,
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type VNode, defineAsyncComponent, h } from 'vue'
|
|
2
|
+
import {
|
|
3
|
+
type TableCellRenderer,
|
|
4
|
+
type TableCellVNode,
|
|
5
|
+
type Extensions,
|
|
6
|
+
applyExtensions,
|
|
7
|
+
type ComponentLoader,
|
|
8
|
+
type PropsOverride,
|
|
9
|
+
} from '..'
|
|
10
|
+
|
|
11
|
+
export function defineTableCellRenderer<
|
|
12
|
+
TComponentProps extends Record<string, any>,
|
|
13
|
+
TExtensions extends Extensions<TComponentProps>,
|
|
14
|
+
TPropsConfig extends Record<string, any>,
|
|
15
|
+
>(config: {
|
|
16
|
+
component: ComponentLoader<TComponentProps>
|
|
17
|
+
props?: (config: TPropsConfig) => PropsOverride<TComponentProps>
|
|
18
|
+
extensions?: TExtensions
|
|
19
|
+
}): TableCellRenderer<TComponentProps, TExtensions, TPropsConfig> {
|
|
20
|
+
const component = defineAsyncComponent(config.component)
|
|
21
|
+
|
|
22
|
+
return function RenderCell(renderConfig) {
|
|
23
|
+
const extension = applyExtensions(config, renderConfig)
|
|
24
|
+
|
|
25
|
+
return h(component, extension.props) satisfies VNode as TableCellVNode
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type VNode, defineAsyncComponent, h } from 'vue'
|
|
2
|
+
import {
|
|
3
|
+
applyExtensions,
|
|
4
|
+
type ComponentLoader,
|
|
5
|
+
type PropsOverride,
|
|
6
|
+
type Extensions,
|
|
7
|
+
type TableRenderer,
|
|
8
|
+
type TableVNode,
|
|
9
|
+
} from '..'
|
|
10
|
+
|
|
11
|
+
export function defineTableRenderer<
|
|
12
|
+
TComponentProps extends Record<string, any>,
|
|
13
|
+
TExtensions extends Extensions<TComponentProps>,
|
|
14
|
+
TPropsConfig extends Record<string, any>,
|
|
15
|
+
>(config: {
|
|
16
|
+
component: ComponentLoader<TComponentProps>
|
|
17
|
+
props?: (config: TPropsConfig) => PropsOverride<TComponentProps>
|
|
18
|
+
extensions?: TExtensions
|
|
19
|
+
}): TableRenderer<TComponentProps, TExtensions, TPropsConfig> {
|
|
20
|
+
const component = defineAsyncComponent(config.component)
|
|
21
|
+
|
|
22
|
+
return function RenderTable(renderConfig) {
|
|
23
|
+
const { thead, tbody } = renderConfig
|
|
24
|
+
|
|
25
|
+
const renderThead =
|
|
26
|
+
typeof thead === 'function'
|
|
27
|
+
? thead
|
|
28
|
+
: 'cells' in thead && thead.cells
|
|
29
|
+
? () => h('thead', {}, h('tr', {}, { default: () => thead.cells() }))
|
|
30
|
+
: 'rows' in thead && thead.rows
|
|
31
|
+
? () => h('thead', {}, { default: () => thead.rows() })
|
|
32
|
+
: () => undefined
|
|
33
|
+
|
|
34
|
+
const renderTbody =
|
|
35
|
+
typeof tbody === 'function'
|
|
36
|
+
? tbody
|
|
37
|
+
: 'rows' in tbody && tbody.rows
|
|
38
|
+
? () => h('tbody', {}, { default: () => tbody.rows() })
|
|
39
|
+
: () => undefined
|
|
40
|
+
|
|
41
|
+
const extension = applyExtensions(config, renderConfig)
|
|
42
|
+
|
|
43
|
+
return h(component, extension.props, () => {
|
|
44
|
+
return [renderThead(), renderTbody()]
|
|
45
|
+
}) satisfies VNode as TableVNode
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type VNode, defineAsyncComponent, h } from 'vue'
|
|
2
|
+
import {
|
|
3
|
+
applyExtensions,
|
|
4
|
+
type TableRowRenderer,
|
|
5
|
+
type TableRowVNode,
|
|
6
|
+
type Extensions,
|
|
7
|
+
type ComponentLoader,
|
|
8
|
+
type PropsOverride,
|
|
9
|
+
} from '..'
|
|
10
|
+
|
|
11
|
+
export function defineRowRenderer<
|
|
12
|
+
TComponentProps extends Record<string, any>,
|
|
13
|
+
TExtensions extends Extensions<TComponentProps>,
|
|
14
|
+
TPropsConfig extends Record<string, any>,
|
|
15
|
+
>(config: {
|
|
16
|
+
component: ComponentLoader<TComponentProps>
|
|
17
|
+
props?: (config: TPropsConfig) => PropsOverride<TComponentProps>
|
|
18
|
+
extensions?: TExtensions
|
|
19
|
+
}): TableRowRenderer<TComponentProps, TExtensions, TPropsConfig> {
|
|
20
|
+
const component = defineAsyncComponent(config.component)
|
|
21
|
+
|
|
22
|
+
return function RenderRow(renderConfig): TableRowVNode {
|
|
23
|
+
const extension = applyExtensions(config, renderConfig)
|
|
24
|
+
|
|
25
|
+
return h(component, extension.props, {
|
|
26
|
+
default: () => renderConfig.cells(),
|
|
27
|
+
}) satisfies VNode as TableRowVNode
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type VNode, defineAsyncComponent, h } from 'vue'
|
|
2
|
+
import {
|
|
3
|
+
applyExtensions,
|
|
4
|
+
type TableSectionRenderer,
|
|
5
|
+
type TableSectionVNode,
|
|
6
|
+
type Extensions,
|
|
7
|
+
type ComponentLoader,
|
|
8
|
+
type PropsOverride,
|
|
9
|
+
} from '..'
|
|
10
|
+
|
|
11
|
+
export function defineSectionRenderer<
|
|
12
|
+
TComponentProps extends Record<string, any>,
|
|
13
|
+
TExtensions extends Extensions<TComponentProps>,
|
|
14
|
+
TPropsConfig extends Record<string, any>,
|
|
15
|
+
>(config: {
|
|
16
|
+
component: ComponentLoader<TComponentProps>
|
|
17
|
+
props?: (config: TPropsConfig) => PropsOverride<TComponentProps>
|
|
18
|
+
extensions?: TExtensions
|
|
19
|
+
}): TableSectionRenderer<TComponentProps, TExtensions, TPropsConfig> {
|
|
20
|
+
const component = defineAsyncComponent(config.component)
|
|
21
|
+
|
|
22
|
+
return function RenderSection(renderConfig): TableSectionVNode {
|
|
23
|
+
const extension = applyExtensions(config, renderConfig)
|
|
24
|
+
|
|
25
|
+
return h(component, extension.props, {
|
|
26
|
+
default: () => renderConfig.rows(),
|
|
27
|
+
}) satisfies VNode as TableSectionVNode
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type MaybeRefOrGetter } from 'vue'
|
|
2
|
+
import { type Sources, type TransformProperty, transformSources } from '..'
|
|
3
|
+
|
|
4
|
+
export function defineMultiSourceTable<
|
|
5
|
+
TSources extends Record<string, Sources>,
|
|
6
|
+
TConfig extends Record<string, unknown> = Record<string, unknown>,
|
|
7
|
+
>(setup: (sources: TSources, config: TConfig) => any) {
|
|
8
|
+
return function useTable<
|
|
9
|
+
TUseSources extends {
|
|
10
|
+
[K in keyof TSources]: any
|
|
11
|
+
},
|
|
12
|
+
TTransforms extends {
|
|
13
|
+
[K in keyof TSources]: TSources[K] extends Sources<infer T>
|
|
14
|
+
? TransformProperty<T, TUseSources[K], K & string>[K & string]
|
|
15
|
+
: never
|
|
16
|
+
},
|
|
17
|
+
>(
|
|
18
|
+
sources: {
|
|
19
|
+
[K in keyof TUseSources]: MaybeRefOrGetter<TUseSources[K][]>
|
|
20
|
+
},
|
|
21
|
+
config: TConfig &
|
|
22
|
+
(Record<keyof TTransforms, undefined> extends TTransforms
|
|
23
|
+
? { transform?: Partial<TTransforms> }
|
|
24
|
+
: {
|
|
25
|
+
transform: { [K in keyof TTransforms as undefined extends TTransforms[K] ? K : never]?: TTransforms[K] } & {
|
|
26
|
+
[K in keyof TTransforms as undefined extends TTransforms[K] ? never : K]: TTransforms[K]
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
) {
|
|
30
|
+
const transformedSources = Object.fromEntries(
|
|
31
|
+
Object.entries(sources).map(([key, value]) => [
|
|
32
|
+
key,
|
|
33
|
+
transformSources(value, (config.transform as any)?.[key as any]),
|
|
34
|
+
])
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
return setup(transformedSources as TSources, config)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type MaybeRefOrGetter } from 'vue'
|
|
2
|
+
import { type Sources, type TableVNode, type TransformProperty, transformSources } from '..'
|
|
3
|
+
|
|
4
|
+
export function defineTable<TSource, TConfig extends Record<string, unknown> = Record<string, unknown>>(
|
|
5
|
+
setup: (sources: Sources<TSource>, config: TConfig) => () => TableVNode
|
|
6
|
+
) {
|
|
7
|
+
return function useTable<TUseSource>(
|
|
8
|
+
sources: MaybeRefOrGetter<TUseSource[]>,
|
|
9
|
+
config: TConfig & TransformProperty<TSource, TUseSource>
|
|
10
|
+
) {
|
|
11
|
+
return setup(transformSources<TSource>(sources, config?.transform), config)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type MaybeRefOrGetter } from 'vue'
|
|
2
|
+
import { type Sources, type TransformProperty, transformSources } from '..'
|
|
3
|
+
|
|
4
|
+
export function defineTypedTable<
|
|
5
|
+
TTypedSource extends { type: string; data: Sources },
|
|
6
|
+
TConfig extends Record<string, unknown> = Record<string, unknown>,
|
|
7
|
+
>(setup: (typedSource: TTypedSource, config: TConfig) => any) {
|
|
8
|
+
return function useTable<
|
|
9
|
+
TUseSource,
|
|
10
|
+
const TType extends TTypedSource['type'],
|
|
11
|
+
TSource extends TTypedSource extends { type: TType; data: Sources<infer TSource> } ? TSource : never,
|
|
12
|
+
>(type: TType, sources: MaybeRefOrGetter<TUseSource[]>, config: TConfig & TransformProperty<TSource, TUseSource>) {
|
|
13
|
+
return setup(
|
|
14
|
+
{ type, data: transformSources<TSource>(sources, config.transform) } as unknown as TTypedSource,
|
|
15
|
+
config
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './apply-extensions'
|
|
2
|
+
export * from './define-renderer/define-table-cell-renderer'
|
|
3
|
+
export * from './define-renderer/define-table-row-renderer'
|
|
4
|
+
export * from './define-columns'
|
|
5
|
+
export * from './define-table/define-multi-source-table'
|
|
6
|
+
export * from './define-table/define-table'
|
|
7
|
+
export * from './define-renderer/define-table-renderer'
|
|
8
|
+
export * from './define-renderer/define-table-section-renderer'
|
|
9
|
+
export * from './define-table/define-typed-table'
|
|
10
|
+
export * from './transform-sources'
|
|
11
|
+
export * from './types'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useArrayMap } from '@vueuse/shared'
|
|
2
|
+
import { type MaybeRefOrGetter, type ComputedRef, computed, toValue } from 'vue'
|
|
3
|
+
|
|
4
|
+
export function transformSources<TSource>(
|
|
5
|
+
sources: MaybeRefOrGetter<any[]>,
|
|
6
|
+
transformer?: (source: any, index: number) => any
|
|
7
|
+
) {
|
|
8
|
+
return transformer
|
|
9
|
+
? (useArrayMap(sources, (source, index) => ({ ...source, ...transformer!(source, index) })) as ComputedRef<
|
|
10
|
+
TSource[]
|
|
11
|
+
>)
|
|
12
|
+
: (computed(() => toValue(sources)) as unknown as ComputedRef<TSource[]>)
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PropsOverride, Renderer } from '.'
|
|
2
|
+
|
|
3
|
+
export type Extension<
|
|
4
|
+
TConfig extends Record<string, any> = Record<string, any>,
|
|
5
|
+
TComponentProps extends Record<string, any> = Record<string, any>,
|
|
6
|
+
> = (config: TConfig) => { props: PropsOverride<TComponentProps> }
|
|
7
|
+
|
|
8
|
+
export type Extensions<TComponentProps extends Record<string, any>> = Record<string, Extension<any, TComponentProps>>
|
|
9
|
+
|
|
10
|
+
export type ExtensionConfig<
|
|
11
|
+
TRenderer extends Renderer<any, any, any>,
|
|
12
|
+
TExtensionName extends keyof $Extensions,
|
|
13
|
+
$Extensions extends Record<string, any> = TRenderer extends Renderer<any, infer TExtensions, any>
|
|
14
|
+
? { [K in keyof TExtensions]: Parameters<TExtensions[K]>[0] }
|
|
15
|
+
: never,
|
|
16
|
+
> = $Extensions[TExtensionName]
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Extensions, TableRenderer, TableCellRenderer, TableRowRenderer, TableSectionRenderer } from '.'
|
|
2
|
+
import type { ComputedRef } from 'vue'
|
|
3
|
+
|
|
4
|
+
export * from './table-cell'
|
|
5
|
+
export * from './table-row'
|
|
6
|
+
export * from './extensions'
|
|
7
|
+
export * from './table'
|
|
8
|
+
export * from './table-section'
|
|
9
|
+
|
|
10
|
+
export type ComponentLoader<TProps> = () => Promise<{
|
|
11
|
+
default: abstract new () => {
|
|
12
|
+
$props: TProps
|
|
13
|
+
}
|
|
14
|
+
}>
|
|
15
|
+
|
|
16
|
+
export type PropsOverride<TComponentProps> = Partial<TComponentProps> & Record<string, any>
|
|
17
|
+
|
|
18
|
+
export type Renderer<
|
|
19
|
+
TComponentProps extends Record<string, any>,
|
|
20
|
+
TExtensions extends Extensions<TComponentProps>,
|
|
21
|
+
TPropsConfig extends Record<string, any>,
|
|
22
|
+
> =
|
|
23
|
+
| TableRenderer<TComponentProps, TExtensions, TPropsConfig>
|
|
24
|
+
| TableSectionRenderer<TComponentProps, TExtensions, TPropsConfig>
|
|
25
|
+
| TableRowRenderer<TComponentProps, TExtensions, TPropsConfig>
|
|
26
|
+
| TableCellRenderer<TComponentProps, TExtensions, TPropsConfig>
|
|
27
|
+
|
|
28
|
+
export type Sources<T = any> = ComputedRef<T[]>
|
|
29
|
+
|
|
30
|
+
export type TransformProperty<
|
|
31
|
+
TSource,
|
|
32
|
+
TUseSource,
|
|
33
|
+
TPropertyName extends string = 'transform',
|
|
34
|
+
> = TUseSource extends TSource
|
|
35
|
+
? { [K in TPropertyName]?: (source: TUseSource, index: number) => Partial<TSource> }
|
|
36
|
+
: {
|
|
37
|
+
[K in TPropertyName]: (
|
|
38
|
+
source: TUseSource,
|
|
39
|
+
index: number
|
|
40
|
+
) => Partial<TSource> & {
|
|
41
|
+
[K in keyof TSource as K extends keyof TUseSource
|
|
42
|
+
? TUseSource[K] extends TSource[K]
|
|
43
|
+
? never
|
|
44
|
+
: K
|
|
45
|
+
: K]: TSource[K]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Branded } from '@core/types/utility.type'
|
|
2
|
+
import type { PropsOverride, Extensions } from '.'
|
|
3
|
+
import type { VNode } from 'vue'
|
|
4
|
+
|
|
5
|
+
export type TableCellVNode = Branded<'CellVNode', VNode>
|
|
6
|
+
|
|
7
|
+
export type TableCellVNodes = TableCellVNode | TableCellVNodes[]
|
|
8
|
+
|
|
9
|
+
export type TableCellRenderer<
|
|
10
|
+
TComponentProps extends Record<string, any>,
|
|
11
|
+
TExtensions extends Extensions<TComponentProps>,
|
|
12
|
+
TPropsConfig extends Record<string, any>,
|
|
13
|
+
> = (
|
|
14
|
+
renderConfig: {
|
|
15
|
+
extensions?: { [K in keyof TExtensions]?: Parameters<TExtensions[K]>[0] }
|
|
16
|
+
props?: PropsOverride<TComponentProps>
|
|
17
|
+
} & TPropsConfig
|
|
18
|
+
) => TableCellVNode
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Branded } from '@core/types/utility.type'
|
|
2
|
+
import type { PropsOverride, Extensions, TableCellVNodes } from '.'
|
|
3
|
+
import type { VNode } from 'vue'
|
|
4
|
+
|
|
5
|
+
export type TableRowVNode = Branded<'RowVNode', VNode>
|
|
6
|
+
|
|
7
|
+
export type TableRowVNodes = TableRowVNode | TableRowVNodes[]
|
|
8
|
+
|
|
9
|
+
export type TableRowRenderer<
|
|
10
|
+
TComponentProps extends Record<string, any>,
|
|
11
|
+
TExtensions extends Extensions<TComponentProps>,
|
|
12
|
+
TPropsConfig extends Record<string, any>,
|
|
13
|
+
> = (
|
|
14
|
+
renderConfig: {
|
|
15
|
+
extensions?: { [K in keyof TExtensions]?: Parameters<TExtensions[K]>[0] }
|
|
16
|
+
key: string | number
|
|
17
|
+
props?: PropsOverride<TComponentProps>
|
|
18
|
+
cells: () => TableCellVNodes
|
|
19
|
+
} & TPropsConfig
|
|
20
|
+
) => TableRowVNode
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Branded } from '@core/types/utility.type'
|
|
2
|
+
import type { PropsOverride, Extensions, TableRowVNodes } from '.'
|
|
3
|
+
import type { VNode } from 'vue'
|
|
4
|
+
|
|
5
|
+
export type TableSectionVNode = Branded<'SectionVNode', VNode>
|
|
6
|
+
|
|
7
|
+
export type TableSectionVNodes = TableSectionVNode | TableSectionVNodes[]
|
|
8
|
+
|
|
9
|
+
export type TableSectionRenderer<
|
|
10
|
+
TComponentProps extends Record<string, any>,
|
|
11
|
+
TExtensions extends Extensions<TComponentProps>,
|
|
12
|
+
TPropsConfig extends Record<string, any>,
|
|
13
|
+
> = (
|
|
14
|
+
renderConfig: {
|
|
15
|
+
extensions?: { [K in keyof TExtensions]?: Parameters<TExtensions[K]>[0] }
|
|
16
|
+
rows: () => TableRowVNodes
|
|
17
|
+
props?: PropsOverride<TComponentProps>
|
|
18
|
+
} & TPropsConfig
|
|
19
|
+
) => TableSectionVNode
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Branded } from '@core/types/utility.type'
|
|
2
|
+
import type {
|
|
3
|
+
TableCellVNodes,
|
|
4
|
+
PropsOverride,
|
|
5
|
+
TableRowVNodes,
|
|
6
|
+
TableSectionVNode,
|
|
7
|
+
TableSectionVNodes,
|
|
8
|
+
Extensions,
|
|
9
|
+
} from '.'
|
|
10
|
+
import type { VNode } from 'vue'
|
|
11
|
+
|
|
12
|
+
export type TableVNode = Branded<'TableVNode', VNode>
|
|
13
|
+
|
|
14
|
+
export type TableRenderer<
|
|
15
|
+
TComponentProps extends Record<string, any>,
|
|
16
|
+
TExtensions extends Extensions<TComponentProps>,
|
|
17
|
+
TPropsConfig extends Record<string, any>,
|
|
18
|
+
> = (
|
|
19
|
+
renderConfig: {
|
|
20
|
+
extensions?: { [K in keyof TExtensions]?: Parameters<TExtensions[K]>[0] }
|
|
21
|
+
props?: PropsOverride<TComponentProps>
|
|
22
|
+
thead:
|
|
23
|
+
| (() => TableSectionVNode)
|
|
24
|
+
| { rows: () => TableRowVNodes; cells?: never }
|
|
25
|
+
| { rows?: never; cells: () => TableCellVNodes }
|
|
26
|
+
tbody: (() => TableSectionVNodes) | { rows: () => TableRowVNodes }
|
|
27
|
+
} & TPropsConfig
|
|
28
|
+
) => TableVNode
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { ThresholdConfig, ThresholdResult } from '@core/packages/threshold/type.ts'
|
|
2
|
-
import {
|
|
2
|
+
import { toComputed } from '@core/utils/to-computed.util'
|
|
3
|
+
import { computed, type ComputedRef, type MaybeRefOrGetter } from 'vue'
|
|
3
4
|
|
|
4
5
|
export function useThreshold<TPayload>(
|
|
5
6
|
rawCurrentValue: MaybeRefOrGetter<number>,
|
|
6
7
|
rawConfig: MaybeRefOrGetter<ThresholdConfig<TPayload>>
|
|
7
8
|
): ComputedRef<ThresholdResult<TPayload>> {
|
|
8
|
-
const currentValue =
|
|
9
|
+
const currentValue = toComputed(rawCurrentValue)
|
|
9
10
|
|
|
10
|
-
const config =
|
|
11
|
+
const config = toComputed(rawConfig)
|
|
11
12
|
|
|
12
13
|
return computed(
|
|
13
14
|
() =>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
declare module 'vue-virtual-scroller' {
|
|
2
|
+
import { type ObjectEmitsOptions, type PublicProps, type SetupContext, type SlotsType, type VNode } from 'vue'
|
|
3
|
+
|
|
4
|
+
interface RecycleScrollerProps<T> {
|
|
5
|
+
items: readonly T[]
|
|
6
|
+
direction?: 'vertical' | 'horizontal'
|
|
7
|
+
itemSize?: number | null
|
|
8
|
+
gridItems?: number
|
|
9
|
+
itemSecondarySize?: number
|
|
10
|
+
minItemSize?: number
|
|
11
|
+
sizeField?: string
|
|
12
|
+
typeField?: string
|
|
13
|
+
keyField?: keyof T
|
|
14
|
+
pageMode?: boolean
|
|
15
|
+
prerender?: number
|
|
16
|
+
buffer?: number
|
|
17
|
+
emitUpdate?: boolean
|
|
18
|
+
updateInterval?: number
|
|
19
|
+
listClass?: string
|
|
20
|
+
itemClass?: string
|
|
21
|
+
listTag?: string
|
|
22
|
+
itemTag?: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface DynamicScrollerProps<T> extends RecycleScrollerProps<T> {
|
|
26
|
+
minItemSize: number
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface RecycleScrollerEmitOptions extends ObjectEmitsOptions {
|
|
30
|
+
resize: () => void
|
|
31
|
+
visible: () => void
|
|
32
|
+
hidden: () => void
|
|
33
|
+
update: (startIndex: number, endIndex: number, visibleStartIndex: number, visibleEndIndex: number) => void
|
|
34
|
+
'scroll-start': () => void
|
|
35
|
+
'scroll-end': () => void
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface RecycleScrollerSlotProps<T> {
|
|
39
|
+
item: T
|
|
40
|
+
index: number
|
|
41
|
+
active: boolean
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface RecycleScrollerSlots<T> {
|
|
45
|
+
default(slotProps: RecycleScrollerSlotProps<T>): unknown
|
|
46
|
+
before(): unknown
|
|
47
|
+
empty(): unknown
|
|
48
|
+
after(): unknown
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface RecycleScrollerInstance {
|
|
52
|
+
getScroll(): { start: number; end: number }
|
|
53
|
+
scrollToItem(index: number): void
|
|
54
|
+
scrollToPosition(position: number): void
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const RecycleScroller: <T>(
|
|
58
|
+
props: RecycleScrollerProps<T> & PublicProps,
|
|
59
|
+
ctx?: SetupContext<RecycleScrollerEmitOptions, SlotsType<RecycleScrollerSlots<T>>>,
|
|
60
|
+
expose?: (exposed: RecycleScrollerInstance) => void
|
|
61
|
+
) => VNode & {
|
|
62
|
+
__ctx?: {
|
|
63
|
+
props: RecycleScrollerProps<T> & PublicProps
|
|
64
|
+
expose(exposed: RecycleScrollerInstance): void
|
|
65
|
+
slots: RecycleScrollerSlots<T>
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const DynamicScroller: <T>(
|
|
70
|
+
props: DynamicScrollerProps<T> & PublicProps,
|
|
71
|
+
ctx?: SetupContext<RecycleScrollerEmitOptions, SlotsType<RecycleScrollerSlots<T>>>,
|
|
72
|
+
expose?: (exposed: RecycleScrollerInstance) => void
|
|
73
|
+
) => VNode & {
|
|
74
|
+
__ctx?: {
|
|
75
|
+
props: DynamicScrollerProps<T> & PublicProps
|
|
76
|
+
expose(exposed: RecycleScrollerInstance): void
|
|
77
|
+
slots: RecycleScrollerSlots<T>
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
interface DynamicScrollerItemProps<T> {
|
|
82
|
+
item: T
|
|
83
|
+
active: boolean
|
|
84
|
+
sizeDependencies?: unknown[]
|
|
85
|
+
watchData?: boolean
|
|
86
|
+
tag?: string
|
|
87
|
+
emitResize?: boolean
|
|
88
|
+
onResize?: () => void
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface DynamicScrollerItemEmitOptions extends ObjectEmitsOptions {
|
|
92
|
+
resize: () => void
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export const DynamicScrollerItem: <T>(
|
|
96
|
+
props: DynamicScrollerItemProps<T> & PublicProps,
|
|
97
|
+
ctx?: SetupContext<DynamicScrollerItemEmitOptions>
|
|
98
|
+
) => VNode
|
|
99
|
+
|
|
100
|
+
export function IdState(options?: { idProp?: (value: any) => unknown }): ComponentOptionsMixin
|
|
101
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { InputWrapperController } from '@core/components/input-wrapper/VtsInputWrapper.vue'
|
|
2
|
+
import type { ModalAccent } from '@core/components/ui/modal/UiModal.vue'
|
|
2
3
|
import type { ValueFormatter } from '@core/types/chart'
|
|
3
4
|
import type { ComputedRef, InjectionKey, Ref } from 'vue'
|
|
4
5
|
|
|
@@ -21,3 +22,5 @@ export const IK_MENU_TELEPORTED = Symbol('IK_MENU_TELEPORTED') as InjectionKey<b
|
|
|
21
22
|
export const IK_DISABLED = Symbol('IK_DISABLED') as InjectionKey<ComputedRef<boolean>>
|
|
22
23
|
|
|
23
24
|
export const IK_INPUT_WRAPPER_CONTROLLER = Symbol('IK_INPUT_WRAPPER_CONTROLLER') as InjectionKey<InputWrapperController>
|
|
25
|
+
|
|
26
|
+
export const IK_MODAL_ACCENT = Symbol('IK_MODAL_ACCENT') as InjectionKey<ComputedRef<ModalAccent>>
|
|
@@ -8,6 +8,7 @@ import type { ThresholdConfig } from '@core/packages/threshold/type.ts'
|
|
|
8
8
|
import { formatSize } from '@core/utils/size.util.ts'
|
|
9
9
|
import { computed, type ComputedRef, type MaybeRefOrGetter, type Reactive, toValue } from 'vue'
|
|
10
10
|
import { useI18n } from 'vue-i18n'
|
|
11
|
+
import { toComputed } from './to-computed.util'
|
|
11
12
|
|
|
12
13
|
export function defaultProgressThresholds(tooltip?: string): ThresholdConfig<ProgressBarThresholdPayload> {
|
|
13
14
|
return {
|
|
@@ -42,7 +43,7 @@ export function useProgressToLegend(
|
|
|
42
43
|
) {
|
|
43
44
|
const { n } = useI18n()
|
|
44
45
|
|
|
45
|
-
const type =
|
|
46
|
+
const type = toComputed(rawType)
|
|
46
47
|
|
|
47
48
|
function toLegend(label: string, progress: Progress | Reactive<Progress>): ProgressBarLegend | undefined {
|
|
48
49
|
switch (type.value) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { computed, toValue, type ComputedRef, type MaybeRefOrGetter } from 'vue'
|
|
2
|
+
|
|
3
|
+
export function toComputed<TValue>(value: MaybeRefOrGetter<TValue>): ComputedRef<TValue>
|
|
4
|
+
|
|
5
|
+
export function toComputed<TValue>(
|
|
6
|
+
value: MaybeRefOrGetter<TValue | undefined>,
|
|
7
|
+
defaultValue: MaybeRefOrGetter<TValue>
|
|
8
|
+
): ComputedRef<TValue>
|
|
9
|
+
|
|
10
|
+
export function toComputed<TValue>(
|
|
11
|
+
value: MaybeRefOrGetter<TValue>,
|
|
12
|
+
defaultValue?: MaybeRefOrGetter<TValue>
|
|
13
|
+
): ComputedRef<TValue | undefined> {
|
|
14
|
+
return computed(() => toValue(value) ?? toValue(defaultValue))
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xen-orchestra/web-core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.33.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"exports": {
|
|
7
7
|
"./*": {
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"ndjson-readablestream": "^1.3.0",
|
|
30
30
|
"placement.js": "^1.0.0-beta.5",
|
|
31
31
|
"simple-icons": "^14.14.0",
|
|
32
|
-
"vue-echarts": "^6.6.8"
|
|
32
|
+
"vue-echarts": "^6.6.8",
|
|
33
|
+
"vue-virtual-scroller": "^2.0.0-beta.8"
|
|
33
34
|
},
|
|
34
35
|
"peerDependencies": {
|
|
35
36
|
"pinia": "^3.0.1",
|