@byyuurin/ui 0.1.0 → 0.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/LICENSE +20 -20
- package/README.md +5 -3
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -2
- package/dist/runtime/components/Accordion.vue +41 -41
- package/dist/runtime/components/Accordion.vue.d.ts +11 -7
- package/dist/runtime/components/Alert.vue +63 -63
- package/dist/runtime/components/Alert.vue.d.ts +4 -4
- package/dist/runtime/components/App.vue +11 -10
- package/dist/runtime/components/App.vue.d.ts +11 -7
- package/dist/runtime/components/Avatar.vue +29 -29
- package/dist/runtime/components/Avatar.vue.d.ts +4 -3
- package/dist/runtime/components/AvatarGroup.vue +4 -4
- package/dist/runtime/components/AvatarGroup.vue.d.ts +1 -1
- package/dist/runtime/components/Badge.vue +32 -32
- package/dist/runtime/components/Badge.vue.d.ts +2 -2
- package/dist/runtime/components/Breadcrumb.vue +49 -49
- package/dist/runtime/components/Breadcrumb.vue.d.ts +10 -6
- package/dist/runtime/components/Button.vue +52 -51
- package/dist/runtime/components/Button.vue.d.ts +1 -1
- package/dist/runtime/components/Calendar.vue +75 -77
- package/dist/runtime/components/Calendar.vue.d.ts +16 -12
- package/dist/runtime/components/Card.vue +41 -41
- package/dist/runtime/components/Card.vue.d.ts +1 -1
- package/dist/runtime/components/Carousel.vue +85 -66
- package/dist/runtime/components/Carousel.vue.d.ts +14 -10
- package/dist/runtime/components/Checkbox.vue +46 -46
- package/dist/runtime/components/Checkbox.vue.d.ts +4 -3
- package/dist/runtime/components/CheckboxGroup.vue +131 -0
- package/dist/runtime/components/CheckboxGroup.vue.d.ts +93 -0
- package/dist/runtime/components/Chip.vue +15 -15
- package/dist/runtime/components/Chip.vue.d.ts +2 -2
- package/dist/runtime/components/Collapsible.vue +14 -14
- package/dist/runtime/components/Collapsible.vue.d.ts +2 -2
- package/dist/runtime/components/Drawer.vue +76 -76
- package/dist/runtime/components/Drawer.vue.d.ts +6 -6
- package/dist/runtime/components/DropdownMenu.vue +28 -28
- package/dist/runtime/components/DropdownMenu.vue.d.ts +17 -9
- package/dist/runtime/components/DropdownMenuContent.vue +152 -153
- package/dist/runtime/components/DropdownMenuContent.vue.d.ts +11 -7
- package/dist/runtime/components/FieldGroup.vue +3 -3
- package/dist/runtime/components/FieldGroup.vue.d.ts +2 -2
- package/dist/runtime/components/Form.vue +9 -9
- package/dist/runtime/components/Form.vue.d.ts +13 -8
- package/dist/runtime/components/FormField.vue +39 -38
- package/dist/runtime/components/FormField.vue.d.ts +7 -2
- package/dist/runtime/components/Icon.vue +2 -2
- package/dist/runtime/components/Icon.vue.d.ts +1 -1
- package/dist/runtime/components/Input.vue +48 -48
- package/dist/runtime/components/Input.vue.d.ts +16 -12
- package/dist/runtime/components/InputNumber.vue +48 -50
- package/dist/runtime/components/InputNumber.vue.d.ts +128 -129
- package/dist/runtime/components/InputTags.vue +156 -0
- package/dist/runtime/components/InputTags.vue.d.ts +90 -0
- package/dist/runtime/components/Kbd.vue +3 -3
- package/dist/runtime/components/Kbd.vue.d.ts +2 -2
- package/dist/runtime/components/Link.vue +26 -25
- package/dist/runtime/components/Link.vue.d.ts +16 -6
- package/dist/runtime/components/LinkBase.vue +3 -3
- package/dist/runtime/components/LinkBase.vue.d.ts +2 -2
- package/dist/runtime/components/Marquee.vue +38 -0
- package/dist/runtime/components/Marquee.vue.d.ts +54 -0
- package/dist/runtime/components/Modal.vue +74 -74
- package/dist/runtime/components/Modal.vue.d.ts +6 -6
- package/dist/runtime/components/NavigationMenu.vue +243 -234
- package/dist/runtime/components/NavigationMenu.vue.d.ts +53 -14
- package/dist/runtime/components/OverlayProvider.vue +9 -9
- package/dist/runtime/components/Pagination.vue +47 -47
- package/dist/runtime/components/Pagination.vue.d.ts +4 -4
- package/dist/runtime/components/PinInput.vue +23 -23
- package/dist/runtime/components/PinInput.vue.d.ts +14 -10
- package/dist/runtime/components/Popover.vue +22 -22
- package/dist/runtime/components/Popover.vue.d.ts +11 -7
- package/dist/runtime/components/Progress.vue +25 -25
- package/dist/runtime/components/Progress.vue.d.ts +2 -2
- package/dist/runtime/components/RadioGroup.vue +50 -50
- package/dist/runtime/components/RadioGroup.vue.d.ts +13 -9
- package/dist/runtime/components/ScrollArea.vue +32 -32
- package/dist/runtime/components/ScrollArea.vue.d.ts +2 -2
- package/dist/runtime/components/Select.vue +299 -148
- package/dist/runtime/components/Select.vue.d.ts +103 -123
- package/dist/runtime/components/Separator.vue +30 -30
- package/dist/runtime/components/Separator.vue.d.ts +2 -2
- package/dist/runtime/components/Skeleton.vue +11 -11
- package/dist/runtime/components/Skeleton.vue.d.ts +2 -2
- package/dist/runtime/components/Slider.vue +25 -25
- package/dist/runtime/components/Slider.vue.d.ts +11 -7
- package/dist/runtime/components/Stepper.vue +116 -0
- package/dist/runtime/components/Stepper.vue.d.ts +83 -0
- package/dist/runtime/components/Switch.vue +30 -30
- package/dist/runtime/components/Switch.vue.d.ts +4 -3
- package/dist/runtime/components/Table.vue +188 -166
- package/dist/runtime/components/Table.vue.d.ts +27 -22
- package/dist/runtime/components/Tabs.vue +74 -74
- package/dist/runtime/components/Tabs.vue.d.ts +12 -8
- package/dist/runtime/components/Textarea.vue +47 -47
- package/dist/runtime/components/Textarea.vue.d.ts +16 -11
- package/dist/runtime/components/Timeline.vue +102 -0
- package/dist/runtime/components/Timeline.vue.d.ts +78 -0
- package/dist/runtime/components/Toast.vue +93 -93
- package/dist/runtime/components/Toast.vue.d.ts +5 -5
- package/dist/runtime/components/ToastProvider.vue +29 -29
- package/dist/runtime/components/ToastProvider.vue.d.ts +3 -3
- package/dist/runtime/components/Tooltip.vue +24 -25
- package/dist/runtime/components/Tooltip.vue.d.ts +2 -2
- package/dist/runtime/components/Tree.vue +241 -0
- package/dist/runtime/components/Tree.vue.d.ts +121 -0
- package/dist/runtime/composables/defineShortcuts.d.ts +1 -0
- package/dist/runtime/composables/defineShortcuts.js +44 -8
- package/dist/runtime/composables/useLocale.d.ts +12 -0
- package/dist/runtime/locale/en.d.ts +6 -0
- package/dist/runtime/locale/en.js +6 -0
- package/dist/runtime/locale/zh_tw.d.ts +6 -0
- package/dist/runtime/locale/zh_tw.js +6 -0
- package/dist/runtime/types/html.d.ts +8 -0
- package/dist/runtime/types/html.js +0 -0
- package/dist/runtime/types/index.d.ts +7 -0
- package/dist/runtime/types/index.js +7 -0
- package/dist/runtime/types/input.d.ts +5 -5
- package/dist/runtime/types/locale.d.ts +6 -0
- package/dist/runtime/types/unocss.d.ts +4 -4
- package/dist/runtime/types/utils.d.ts +9 -6
- package/dist/runtime/utils/index.d.ts +3 -3
- package/dist/runtime/utils/link.d.ts +2 -1
- package/dist/runtime/utils/link.js +40 -29
- package/dist/runtime/vue/components/Icon.vue +2 -2
- package/dist/runtime/vue/components/Icon.vue.d.ts +1 -1
- package/dist/runtime/vue/components/Link.vue +7 -12
- package/dist/runtime/vue/components/Link.vue.d.ts +11 -40
- package/dist/setup.d.mts +1 -1
- package/dist/shared/{ui.CzIlLITK.mjs → ui.9kQouwss.mjs} +5 -3
- package/dist/shared/{ui.DpbffTXs.d.mts → ui.D8Bg1HWt.d.mts} +2 -0
- package/dist/shared/{ui.DSyJHSTk.mjs → ui.DpkP12cX.mjs} +784 -84
- package/dist/unocss.mjs +1 -1
- package/dist/unplugin.d.mts +1 -1
- package/dist/unplugin.mjs +2 -2
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +2 -2
- package/package.json +29 -29
- package/vue-plugin.d.ts +5 -5
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { VariantProps } from '@byyuurin/ui-kit';
|
|
2
|
+
import type { StepperRootEmits, StepperRootProps } from 'reka-ui';
|
|
3
|
+
import theme from '#build/ui/stepper';
|
|
4
|
+
import type { ComponentBaseProps, ComponentUIProps, IconProps } from '../types';
|
|
5
|
+
import type { DynamicSlots, StaticSlot } from '../types/utils';
|
|
6
|
+
export interface StepperItem extends ComponentBaseProps {
|
|
7
|
+
slot?: string;
|
|
8
|
+
value?: string | number;
|
|
9
|
+
title?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
icon?: IconProps['name'];
|
|
12
|
+
content?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
ui?: Pick<ComponentUIProps<typeof theme>, 'item' | 'container' | 'trigger' | 'indicator' | 'icon' | 'separator' | 'wrapper' | 'title' | 'description'>;
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}
|
|
17
|
+
type ThemeVariants = VariantProps<typeof theme>;
|
|
18
|
+
export interface StepperProps<T extends StepperItem = StepperItem> extends ComponentBaseProps, Pick<StepperRootProps, 'linear'> {
|
|
19
|
+
/**
|
|
20
|
+
* The element or component this component should render as.
|
|
21
|
+
* @default "div"
|
|
22
|
+
*/
|
|
23
|
+
as?: StepperRootProps['as'];
|
|
24
|
+
items?: T[];
|
|
25
|
+
/** @default "md" */
|
|
26
|
+
size?: ThemeVariants['size'];
|
|
27
|
+
/** @default "primary" */
|
|
28
|
+
color?: ThemeVariants['color'];
|
|
29
|
+
/** @default "horizontal" */
|
|
30
|
+
orientation?: ThemeVariants['orientation'];
|
|
31
|
+
defaultValue?: string | number;
|
|
32
|
+
modelValue?: string | number;
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
ui?: ComponentUIProps<typeof theme>;
|
|
35
|
+
}
|
|
36
|
+
export type StepperEmits<T extends StepperItem = StepperItem> = Omit<StepperRootEmits, 'update:modelValue'> & {
|
|
37
|
+
next: [value: T];
|
|
38
|
+
prev: [value: T];
|
|
39
|
+
};
|
|
40
|
+
export type StepperSlots<T extends StepperItem = StepperItem> = {
|
|
41
|
+
indicator: StaticSlot<{
|
|
42
|
+
item: T;
|
|
43
|
+
ui: ComponentUIProps<typeof theme>;
|
|
44
|
+
}>;
|
|
45
|
+
title: StaticSlot<{
|
|
46
|
+
item: T;
|
|
47
|
+
}>;
|
|
48
|
+
description: StaticSlot<{
|
|
49
|
+
item: T;
|
|
50
|
+
}>;
|
|
51
|
+
content: StaticSlot<{
|
|
52
|
+
item: T;
|
|
53
|
+
}>;
|
|
54
|
+
} & DynamicSlots<T>;
|
|
55
|
+
declare const _default: typeof __VLS_export;
|
|
56
|
+
export default _default;
|
|
57
|
+
declare const __VLS_export: <T extends StepperItem>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
58
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<(StepperProps<T> & {
|
|
59
|
+
modelValue?: string | number;
|
|
60
|
+
}) & {
|
|
61
|
+
onPrev?: ((value: T) => any) | undefined;
|
|
62
|
+
onNext?: ((value: T) => any) | undefined;
|
|
63
|
+
"onUpdate:modelValue"?: ((value: string | number | undefined) => any) | undefined;
|
|
64
|
+
}> & (typeof globalThis extends {
|
|
65
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
66
|
+
} ? P : {});
|
|
67
|
+
expose: (exposed: import("vue").ShallowUnwrapRef<{
|
|
68
|
+
next(): void;
|
|
69
|
+
prev(): void;
|
|
70
|
+
hasNext: import("vue").ComputedRef<boolean>;
|
|
71
|
+
hasPrev: import("vue").ComputedRef<boolean>;
|
|
72
|
+
}>) => void;
|
|
73
|
+
attrs: any;
|
|
74
|
+
slots: StepperSlots<T>;
|
|
75
|
+
emit: (((evt: "prev", value: T) => void) & ((evt: "next", value: T) => void)) & ((evt: "update:modelValue", value: string | number | undefined) => void);
|
|
76
|
+
}>) => import("vue").VNode & {
|
|
77
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
78
|
+
};
|
|
79
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
80
|
+
[K in keyof T]: T[K];
|
|
81
|
+
} : {
|
|
82
|
+
[K in keyof T as K]: T[K];
|
|
83
|
+
}) & {};
|
|
@@ -58,34 +58,34 @@ function onUpdate(value) {
|
|
|
58
58
|
</script>
|
|
59
59
|
|
|
60
60
|
<template>
|
|
61
|
-
<Primitive :as="props.as" :class="ui.root({ class: [props.ui?.root, props.class] })" data-part="root">
|
|
62
|
-
<div :class="ui.container({ class: props.ui?.container })" data-part="container">
|
|
63
|
-
<SwitchRoot
|
|
64
|
-
v-bind="{ id, ...rootProps, ...ariaAttrs, name }"
|
|
65
|
-
v-model="modelValue"
|
|
66
|
-
:disabled="disabled || props.loading"
|
|
67
|
-
:class="ui.base({ class: props.ui?.base })"
|
|
68
|
-
data-part="base"
|
|
69
|
-
@update:model-value="onUpdate"
|
|
70
|
-
>
|
|
71
|
-
<SwitchThumb :class="ui.thumb({ class: props.ui?.thumb })" data-part="thumb">
|
|
72
|
-
<Icon v-if="props.loading" :name="props.loadingIcon || appConfig.ui.icons.loading" :class="ui.icon({ class: props.ui?.icon, checked: true, unchecked: true })" data-part="icon" />
|
|
73
|
-
<template v-else>
|
|
74
|
-
<Icon v-if="props.checkedIcon" :name="props.checkedIcon" :class="ui.icon({ class: props.ui?.icon, checked: true })" data-part="icon" />
|
|
75
|
-
<Icon v-if="props.uncheckedIcon" :name="props.uncheckedIcon" :class="ui.icon({ class: props.ui?.icon, unchecked: true })" data-part="icon" />
|
|
76
|
-
</template>
|
|
77
|
-
</SwitchThumb>
|
|
78
|
-
</SwitchRoot>
|
|
79
|
-
</div>
|
|
80
|
-
<div v-if="props.label || !!slots.label || (props.description || !!slots.description)" :class="ui.wrapper({ class: props.ui?.wrapper })" data-part="wrapper">
|
|
81
|
-
<Label v-if="props.label || !!slots.label" :for="id" :class="ui.label({ class: props.ui?.label })" data-part="label">
|
|
82
|
-
<slot name="label" :label="props.label">{{ props.label }}</slot>
|
|
83
|
-
</Label>
|
|
84
|
-
<p v-if="props.description || !!slots.description" :class="ui.description({ class: props.ui?.description })" data-part="description">
|
|
85
|
-
<slot name="description" :description="props.description">
|
|
86
|
-
{{ props.description }}
|
|
87
|
-
</slot>
|
|
88
|
-
</p>
|
|
89
|
-
</div>
|
|
90
|
-
</Primitive>
|
|
61
|
+
<Primitive :as="props.as" :class="ui.root({ class: [props.ui?.root, props.class] })" data-part="root">
|
|
62
|
+
<div :class="ui.container({ class: props.ui?.container })" data-part="container">
|
|
63
|
+
<SwitchRoot
|
|
64
|
+
v-bind="{ id, ...rootProps, ...ariaAttrs, name }"
|
|
65
|
+
v-model="modelValue"
|
|
66
|
+
:disabled="disabled || props.loading"
|
|
67
|
+
:class="ui.base({ class: props.ui?.base })"
|
|
68
|
+
data-part="base"
|
|
69
|
+
@update:model-value="onUpdate"
|
|
70
|
+
>
|
|
71
|
+
<SwitchThumb :class="ui.thumb({ class: props.ui?.thumb })" data-part="thumb">
|
|
72
|
+
<Icon v-if="props.loading" :name="props.loadingIcon || appConfig.ui.icons.loading" :class="ui.icon({ class: props.ui?.icon, checked: true, unchecked: true })" data-part="icon" />
|
|
73
|
+
<template v-else>
|
|
74
|
+
<Icon v-if="props.checkedIcon" :name="props.checkedIcon" :class="ui.icon({ class: props.ui?.icon, checked: true })" data-part="icon" />
|
|
75
|
+
<Icon v-if="props.uncheckedIcon" :name="props.uncheckedIcon" :class="ui.icon({ class: props.ui?.icon, unchecked: true })" data-part="icon" />
|
|
76
|
+
</template>
|
|
77
|
+
</SwitchThumb>
|
|
78
|
+
</SwitchRoot>
|
|
79
|
+
</div>
|
|
80
|
+
<div v-if="props.label || !!slots.label || (props.description || !!slots.description)" :class="ui.wrapper({ class: props.ui?.wrapper })" data-part="wrapper">
|
|
81
|
+
<Label v-if="props.label || !!slots.label" :for="id" :class="ui.label({ class: props.ui?.label })" data-part="label">
|
|
82
|
+
<slot name="label" :label="props.label">{{ props.label }}</slot>
|
|
83
|
+
</Label>
|
|
84
|
+
<p v-if="props.description || !!slots.description" :class="ui.description({ class: props.ui?.description })" data-part="description">
|
|
85
|
+
<slot name="description" :description="props.description">
|
|
86
|
+
{{ props.description }}
|
|
87
|
+
</slot>
|
|
88
|
+
</p>
|
|
89
|
+
</div>
|
|
90
|
+
</Primitive>
|
|
91
91
|
</template>
|
|
@@ -2,9 +2,10 @@ import type { VariantProps } from '@byyuurin/ui-kit';
|
|
|
2
2
|
import type { SwitchRootProps } from 'reka-ui';
|
|
3
3
|
import theme from '#build/ui/switch';
|
|
4
4
|
import type { ComponentBaseProps, ComponentUIProps, IconProps } from '../types';
|
|
5
|
+
import type { ButtonHTMLAttributes } from '../types/html';
|
|
5
6
|
import type { StaticSlot } from '../types/utils';
|
|
6
7
|
type ThemeVariants = VariantProps<typeof theme>;
|
|
7
|
-
export interface SwitchProps extends ComponentBaseProps, Pick<SwitchRootProps, 'disabled' | 'id' | 'name' | 'required' | 'value' | 'defaultValue'> {
|
|
8
|
+
export interface SwitchProps extends ComponentBaseProps, Pick<SwitchRootProps, 'disabled' | 'id' | 'name' | 'required' | 'value' | 'defaultValue'>, /** @vue-ignore */ Omit<ButtonHTMLAttributes, 'type' | 'disabled' | 'value' | 'name'> {
|
|
8
9
|
/**
|
|
9
10
|
* The element or component this component should render as.
|
|
10
11
|
* @default "div"
|
|
@@ -42,6 +43,8 @@ export interface SwitchSlots {
|
|
|
42
43
|
description?: string;
|
|
43
44
|
}>;
|
|
44
45
|
}
|
|
46
|
+
declare const _default: typeof __VLS_export;
|
|
47
|
+
export default _default;
|
|
45
48
|
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<SwitchProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
46
49
|
change: (event: Event) => any;
|
|
47
50
|
"update:modelValue": (value: boolean) => any;
|
|
@@ -49,8 +52,6 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<Switch
|
|
|
49
52
|
onChange?: ((event: Event) => any) | undefined;
|
|
50
53
|
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
51
54
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, SwitchSlots>;
|
|
52
|
-
declare const _default: typeof __VLS_export;
|
|
53
|
-
export default _default;
|
|
54
55
|
type __VLS_WithSlots<T, S> = T & {
|
|
55
56
|
new (): {
|
|
56
57
|
$slots: S;
|
|
@@ -5,9 +5,9 @@ import theme from "#build/ui/table";
|
|
|
5
5
|
<script setup>
|
|
6
6
|
import { FlexRender, getCoreRowModel, getExpandedRowModel, getFilteredRowModel, getSortedRowModel, useVueTable } from "@tanstack/vue-table";
|
|
7
7
|
import { useVirtualizer } from "@tanstack/vue-virtual";
|
|
8
|
-
import { createReusableTemplate,
|
|
8
|
+
import { createReusableTemplate, reactivePick } from "@vueuse/core";
|
|
9
9
|
import { defu } from "defu";
|
|
10
|
-
import { Primitive } from "reka-ui";
|
|
10
|
+
import { Primitive, useForwardProps } from "reka-ui";
|
|
11
11
|
import { upperFirst } from "scule";
|
|
12
12
|
import { computed, ref, shallowRef, toRef, watch } from "vue";
|
|
13
13
|
import { useAppConfig } from "#imports";
|
|
@@ -90,19 +90,19 @@ const [DefineRowTemplate, ReuseRowTemplate] = createReusableTemplate({
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
|
-
const globalFilterState = defineModel("globalFilter", { type: String
|
|
94
|
-
const columnFiltersState = defineModel("columnFilters", { type: Array
|
|
95
|
-
const columnOrderState = defineModel("columnOrder", { type: Array
|
|
96
|
-
const columnVisibilityState = defineModel("columnVisibility", { type: Object
|
|
97
|
-
const columnPinningState = defineModel("columnPinning", { type: Object
|
|
98
|
-
const columnSizingState = defineModel("columnSizing", { type: Object
|
|
99
|
-
const columnSizingInfoState = defineModel("columnSizingInfo", { type: Object
|
|
100
|
-
const rowSelectionState = defineModel("rowSelection", { type: Object
|
|
101
|
-
const rowPinningState = defineModel("rowPinning", { type: Object
|
|
102
|
-
const sortingState = defineModel("sorting", { type: Array
|
|
103
|
-
const groupingState = defineModel("grouping", { type: Array
|
|
104
|
-
const expandedState = defineModel("expanded", { type: [Boolean, Object]
|
|
105
|
-
const paginationState = defineModel("pagination", { type: Object
|
|
93
|
+
const globalFilterState = defineModel("globalFilter", { type: String });
|
|
94
|
+
const columnFiltersState = defineModel("columnFilters", { type: Array });
|
|
95
|
+
const columnOrderState = defineModel("columnOrder", { type: Array });
|
|
96
|
+
const columnVisibilityState = defineModel("columnVisibility", { type: Object });
|
|
97
|
+
const columnPinningState = defineModel("columnPinning", { type: Object });
|
|
98
|
+
const columnSizingState = defineModel("columnSizing", { type: Object });
|
|
99
|
+
const columnSizingInfoState = defineModel("columnSizingInfo", { type: Object });
|
|
100
|
+
const rowSelectionState = defineModel("rowSelection", { type: Object });
|
|
101
|
+
const rowPinningState = defineModel("rowPinning", { type: Object });
|
|
102
|
+
const sortingState = defineModel("sorting", { type: Array });
|
|
103
|
+
const groupingState = defineModel("grouping", { type: Array });
|
|
104
|
+
const expandedState = defineModel("expanded", { type: [Boolean, Object] });
|
|
105
|
+
const paginationState = defineModel("pagination", { type: Object });
|
|
106
106
|
const rootRef = shallowRef();
|
|
107
107
|
const tableRef = shallowRef(null);
|
|
108
108
|
const data = ref(props.data ?? []);
|
|
@@ -138,41 +138,44 @@ const hasFooter = computed(() => {
|
|
|
138
138
|
}
|
|
139
139
|
return hasFooterRecursive(columns.value);
|
|
140
140
|
});
|
|
141
|
+
const tableProps = useForwardProps(reactivePick(props, "_features", "autoResetAll", "debugAll", "debugCells", "debugColumns", "debugHeaders", "debugRows", "debugTable", "defaultColumn", "getRowId", "getSubRows", "initialState", "mergeOptions", "renderFallbackValue"));
|
|
141
142
|
const tableApi = useVueTable({
|
|
142
|
-
...
|
|
143
|
-
data
|
|
143
|
+
...tableProps.value,
|
|
144
|
+
get data() {
|
|
145
|
+
return data.value;
|
|
146
|
+
},
|
|
144
147
|
get columns() {
|
|
145
148
|
return columns.value;
|
|
146
149
|
},
|
|
147
150
|
meta: meta.value,
|
|
148
151
|
getCoreRowModel: getCoreRowModel(),
|
|
149
152
|
...props.globalFilterOptions,
|
|
150
|
-
onGlobalFilterChange: (updaterOrValue) => valueUpdater(updaterOrValue, globalFilterState),
|
|
153
|
+
...globalFilterState.value !== void 0 && { onGlobalFilterChange: (updaterOrValue) => valueUpdater(updaterOrValue, globalFilterState) },
|
|
151
154
|
...props.columnFiltersOptions,
|
|
152
155
|
getFilteredRowModel: getFilteredRowModel(),
|
|
153
|
-
onColumnFiltersChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnFiltersState),
|
|
154
|
-
onColumnOrderChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnOrderState),
|
|
156
|
+
...columnFiltersState.value !== void 0 && { onColumnFiltersChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnFiltersState) },
|
|
157
|
+
...columnOrderState.value !== void 0 && { onColumnOrderChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnOrderState) },
|
|
155
158
|
...props.visibilityOptions,
|
|
156
|
-
onColumnVisibilityChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnVisibilityState),
|
|
159
|
+
...columnVisibilityState.value !== void 0 && { onColumnVisibilityChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnVisibilityState) },
|
|
157
160
|
...props.columnPinningOptions,
|
|
158
|
-
onColumnPinningChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnPinningState),
|
|
161
|
+
...columnPinningState.value !== void 0 && { onColumnPinningChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnPinningState) },
|
|
159
162
|
...props.columnSizingOptions,
|
|
160
|
-
onColumnSizingChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnSizingState),
|
|
161
|
-
onColumnSizingInfoChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnSizingInfoState),
|
|
163
|
+
...columnSizingState.value !== void 0 && { onColumnSizingChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnSizingState) },
|
|
164
|
+
...columnSizingInfoState.value !== void 0 && { onColumnSizingInfoChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnSizingInfoState) },
|
|
162
165
|
...props.rowSelectionOptions,
|
|
163
|
-
onRowSelectionChange: (updaterOrValue) => valueUpdater(updaterOrValue, rowSelectionState),
|
|
166
|
+
...rowSelectionState.value !== void 0 && { onRowSelectionChange: (updaterOrValue) => valueUpdater(updaterOrValue, rowSelectionState) },
|
|
164
167
|
...props.rowPinningOptions,
|
|
165
|
-
onRowPinningChange: (updaterOrValue) => valueUpdater(updaterOrValue, rowPinningState),
|
|
168
|
+
...rowPinningState.value !== void 0 && { onRowPinningChange: (updaterOrValue) => valueUpdater(updaterOrValue, rowPinningState) },
|
|
166
169
|
...props.sortingOptions,
|
|
167
170
|
getSortedRowModel: getSortedRowModel(),
|
|
168
|
-
onSortingChange: (updaterOrValue) => valueUpdater(updaterOrValue, sortingState),
|
|
171
|
+
...sortingState.value !== void 0 && { onSortingChange: (updaterOrValue) => valueUpdater(updaterOrValue, sortingState) },
|
|
169
172
|
...props.groupingOptions,
|
|
170
|
-
onGroupingChange: (updaterOrValue) => valueUpdater(updaterOrValue, groupingState),
|
|
173
|
+
...groupingState.value !== void 0 && { onGroupingChange: (updaterOrValue) => valueUpdater(updaterOrValue, groupingState) },
|
|
171
174
|
...props.expandedOptions,
|
|
172
175
|
getExpandedRowModel: getExpandedRowModel(),
|
|
173
|
-
onExpandedChange: (updaterOrValue) => valueUpdater(updaterOrValue, expandedState),
|
|
176
|
+
...expandedState.value !== void 0 && { onExpandedChange: (updaterOrValue) => valueUpdater(updaterOrValue, expandedState) },
|
|
174
177
|
...props.paginationOptions,
|
|
175
|
-
onPaginationChange: (updaterOrValue) => valueUpdater(updaterOrValue, paginationState),
|
|
178
|
+
...paginationState.value !== void 0 && { onPaginationChange: (updaterOrValue) => valueUpdater(updaterOrValue, paginationState) },
|
|
176
179
|
...props.facetedOptions,
|
|
177
180
|
state: {
|
|
178
181
|
get globalFilter() {
|
|
@@ -262,6 +265,15 @@ function resolveValue(prop, arg) {
|
|
|
262
265
|
}
|
|
263
266
|
return prop;
|
|
264
267
|
}
|
|
268
|
+
function getColumnStyles(column) {
|
|
269
|
+
const styles = {};
|
|
270
|
+
const pinned = column.getIsPinned();
|
|
271
|
+
if (pinned === "left")
|
|
272
|
+
styles.left = `${column.getStart("left")}px`;
|
|
273
|
+
else if (pinned === "right")
|
|
274
|
+
styles.right = `${column.getAfter("right")}px`;
|
|
275
|
+
return styles;
|
|
276
|
+
}
|
|
265
277
|
watch(() => props.data, () => {
|
|
266
278
|
data.value = props.data ? [...props.data] : [];
|
|
267
279
|
}, props.watchOptions);
|
|
@@ -285,168 +297,178 @@ defineExpose({
|
|
|
285
297
|
</script>
|
|
286
298
|
|
|
287
299
|
<template>
|
|
288
|
-
<DefineRowTemplate v-slot="{ row, style }">
|
|
289
|
-
<tr
|
|
290
|
-
:role="props.onSelect ? 'button' : void 0"
|
|
291
|
-
:tabindex="props.onSelect ? 0 : void 0"
|
|
300
|
+
<DefineRowTemplate v-slot="{ row, style }">
|
|
301
|
+
<tr
|
|
302
|
+
:role="props.onSelect ? 'button' : void 0"
|
|
303
|
+
:tabindex="props.onSelect ? 0 : void 0"
|
|
292
304
|
:class="ui.tr({
|
|
293
305
|
class: [
|
|
294
306
|
props.ui?.tr,
|
|
295
307
|
resolveValue(tableApi.options.meta?.class?.tr, row)
|
|
296
308
|
]
|
|
297
|
-
})"
|
|
298
|
-
:data-selected="row.getIsSelected()"
|
|
299
|
-
:data-selectable="!!props.onSelect || !!props.onHover || !!props.onContextmenu"
|
|
300
|
-
:data-expanded="row.getIsExpanded()"
|
|
301
|
-
data-part="tr"
|
|
302
|
-
:style="[resolveValue(tableApi.options.meta?.style?.tr, row), style]"
|
|
303
|
-
@click="onRowSelect($event, row)"
|
|
304
|
-
@pointerenter="onRowHover($event, row)"
|
|
305
|
-
@pointerleave="onRowHover($event, null)"
|
|
306
|
-
@contextmenu="onRowContextmenu($event, row)"
|
|
307
|
-
>
|
|
308
|
-
<td
|
|
309
|
-
v-for="cell in row.getVisibleCells()"
|
|
310
|
-
:key="cell.id"
|
|
311
|
-
:colspan="resolveValue(cell.column.columnDef.meta?.colspan?.td, cell)"
|
|
312
|
-
:rowspan="resolveValue(cell.column.columnDef.meta?.rowspan?.td, cell)"
|
|
309
|
+
})"
|
|
310
|
+
:data-selected="row.getIsSelected()"
|
|
311
|
+
:data-selectable="!!props.onSelect || !!props.onHover || !!props.onContextmenu"
|
|
312
|
+
:data-expanded="row.getIsExpanded()"
|
|
313
|
+
data-part="tr"
|
|
314
|
+
:style="[resolveValue(tableApi.options.meta?.style?.tr, row), style]"
|
|
315
|
+
@click="onRowSelect($event, row)"
|
|
316
|
+
@pointerenter="onRowHover($event, row)"
|
|
317
|
+
@pointerleave="onRowHover($event, null)"
|
|
318
|
+
@contextmenu="onRowContextmenu($event, row)"
|
|
319
|
+
>
|
|
320
|
+
<td
|
|
321
|
+
v-for="cell in row.getVisibleCells()"
|
|
322
|
+
:key="cell.id"
|
|
323
|
+
:colspan="resolveValue(cell.column.columnDef.meta?.colspan?.td, cell)"
|
|
324
|
+
:rowspan="resolveValue(cell.column.columnDef.meta?.rowspan?.td, cell)"
|
|
313
325
|
:class="ui.td({
|
|
314
326
|
class: [
|
|
315
327
|
props.ui?.td,
|
|
316
328
|
resolveValue(cell.column.columnDef.meta?.class?.td, cell)
|
|
317
329
|
],
|
|
318
330
|
pinned: !!cell.column.getIsPinned()
|
|
319
|
-
})"
|
|
320
|
-
:data-pinned="cell.column.getIsPinned()"
|
|
321
|
-
data-part="td"
|
|
322
|
-
:style="
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
:
|
|
353
|
-
:
|
|
331
|
+
})"
|
|
332
|
+
:data-pinned="cell.column.getIsPinned()"
|
|
333
|
+
data-part="td"
|
|
334
|
+
:style="[
|
|
335
|
+
getColumnStyles(cell.column),
|
|
336
|
+
resolveValue(cell.column.columnDef.meta?.style?.td, cell)
|
|
337
|
+
]"
|
|
338
|
+
>
|
|
339
|
+
<slot :name="`${cell.column.id}-cell`" v-bind="cell.getContext()">
|
|
340
|
+
<FlexRender :render="cell.column.columnDef.cell" :props="cell.getContext()" />
|
|
341
|
+
</slot>
|
|
342
|
+
</td>
|
|
343
|
+
</tr>
|
|
344
|
+
|
|
345
|
+
<tr v-if="row.getIsExpanded()" :class="ui.tr({ class: props.ui?.tr })" data-part="tr">
|
|
346
|
+
<td :colspan="row.getAllCells().length" :class="ui.td({ class: props.ui?.td })" data-part="td">
|
|
347
|
+
<slot name="expanded" :row="row"></slot>
|
|
348
|
+
</td>
|
|
349
|
+
</tr>
|
|
350
|
+
</DefineRowTemplate>
|
|
351
|
+
|
|
352
|
+
<DefineTableTemplate>
|
|
353
|
+
<table ref="tableRef" :class="ui.base({ class: props.ui?.base })" data-part="base">
|
|
354
|
+
<caption v-if="caption || !!slots.caption" :class="ui.caption({ class: [props.ui?.caption] })" data-part="caption">
|
|
355
|
+
<slot name="caption">
|
|
356
|
+
{{ caption }}
|
|
357
|
+
</slot>
|
|
358
|
+
</caption>
|
|
359
|
+
|
|
360
|
+
<thead :class="ui.thead({ class: [props.ui?.thead] })" data-part="thead">
|
|
361
|
+
<tr v-for="headerGroup in tableApi.getHeaderGroups()" :key="headerGroup.id" :class="ui.tr({ class: [props.ui?.tr] })" data-part="tr">
|
|
362
|
+
<th
|
|
363
|
+
v-for="header in headerGroup.headers"
|
|
364
|
+
:key="header.id"
|
|
365
|
+
:data-pinned="header.column.getIsPinned()"
|
|
366
|
+
:scope="header.colSpan > 1 ? 'colgroup' : 'col'"
|
|
367
|
+
:colspan="header.colSpan > 1 ? header.colSpan : void 0"
|
|
368
|
+
:rowspan="header.rowSpan > 1 ? header.rowSpan : void 0"
|
|
354
369
|
:class="ui.th({
|
|
355
370
|
class: [
|
|
356
371
|
props.ui?.th,
|
|
357
372
|
resolveValue(header.column.columnDef.meta?.class?.th, header)
|
|
358
373
|
],
|
|
359
374
|
pinned: !!header.column.getIsPinned()
|
|
360
|
-
})"
|
|
361
|
-
data-part="th"
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
<
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
375
|
+
})"
|
|
376
|
+
data-part="th"
|
|
377
|
+
:style="[
|
|
378
|
+
getColumnStyles(header.column),
|
|
379
|
+
resolveValue(header.column.columnDef.meta?.style?.th, header)
|
|
380
|
+
]"
|
|
381
|
+
>
|
|
382
|
+
<slot :name="`${header.id}-header`" v-bind="header.getContext()">
|
|
383
|
+
<FlexRender v-if="!header.isPlaceholder" :render="header.column.columnDef.header" :props="header.getContext()" />
|
|
384
|
+
</slot>
|
|
385
|
+
</th>
|
|
386
|
+
</tr>
|
|
387
|
+
|
|
388
|
+
<tr :class="ui.separator({ class: [props.ui?.separator] })" data-part="separator"></tr>
|
|
389
|
+
</thead>
|
|
390
|
+
|
|
391
|
+
<tbody :class="ui.tbody({ class: [props.ui?.tbody] })" data-part="tbody">
|
|
392
|
+
<slot name="body-top"></slot>
|
|
393
|
+
|
|
394
|
+
<template v-if="rows.length">
|
|
395
|
+
<template v-if="virtualizer">
|
|
396
|
+
<template v-for="(virtualRow, index) in virtualizer.getVirtualItems()" :key="rows[virtualRow.index]?.id">
|
|
397
|
+
<ReuseRowTemplate
|
|
398
|
+
:row="rows[virtualRow.index]"
|
|
380
399
|
:style="{
|
|
381
400
|
height: `${virtualRow.size}px`,
|
|
382
401
|
transform: `translateY(${virtualRow.start - index * virtualRow.size}px)`
|
|
383
|
-
}"
|
|
384
|
-
/>
|
|
385
|
-
</template>
|
|
386
|
-
</template>
|
|
387
|
-
|
|
388
|
-
<template v-else>
|
|
389
|
-
<ReuseRowTemplate v-for="row in rows" :key="row.id" :row="row" />
|
|
390
|
-
</template>
|
|
391
|
-
</template>
|
|
392
|
-
|
|
393
|
-
<tr v-else-if="props.loading && !!slots.loading">
|
|
394
|
-
<td :colspan="tableApi.getAllLeafColumns().length" :class="ui.loading({ class: props.ui?.loading })" data-part="loading">
|
|
395
|
-
<slot name="loading"></slot>
|
|
396
|
-
</td>
|
|
397
|
-
</tr>
|
|
398
|
-
|
|
399
|
-
<tr v-else>
|
|
400
|
-
<td :colspan="tableApi.getAllLeafColumns().length" :class="ui.empty({ class: props.ui?.empty })" data-part="empty">
|
|
401
|
-
<slot name="empty">
|
|
402
|
-
{{ props.empty || t("table.noData") }}
|
|
403
|
-
</slot>
|
|
404
|
-
</td>
|
|
405
|
-
</tr>
|
|
406
|
-
|
|
407
|
-
<slot name="body-bottom"></slot>
|
|
408
|
-
</tbody>
|
|
409
|
-
|
|
410
|
-
<tfoot
|
|
411
|
-
v-if="hasFooter"
|
|
412
|
-
:class="ui.tfoot({ class: props.ui?.tfoot })"
|
|
413
|
-
data-part="tfoot"
|
|
402
|
+
}"
|
|
403
|
+
/>
|
|
404
|
+
</template>
|
|
405
|
+
</template>
|
|
406
|
+
|
|
407
|
+
<template v-else>
|
|
408
|
+
<ReuseRowTemplate v-for="row in rows" :key="row.id" :row="row" />
|
|
409
|
+
</template>
|
|
410
|
+
</template>
|
|
411
|
+
|
|
412
|
+
<tr v-else-if="props.loading && !!slots.loading">
|
|
413
|
+
<td :colspan="tableApi.getAllLeafColumns().length" :class="ui.loading({ class: props.ui?.loading })" data-part="loading">
|
|
414
|
+
<slot name="loading"></slot>
|
|
415
|
+
</td>
|
|
416
|
+
</tr>
|
|
417
|
+
|
|
418
|
+
<tr v-else>
|
|
419
|
+
<td :colspan="tableApi.getAllLeafColumns().length" :class="ui.empty({ class: props.ui?.empty })" data-part="empty">
|
|
420
|
+
<slot name="empty">
|
|
421
|
+
{{ props.empty || t("table.noData") }}
|
|
422
|
+
</slot>
|
|
423
|
+
</td>
|
|
424
|
+
</tr>
|
|
425
|
+
|
|
426
|
+
<slot name="body-bottom"></slot>
|
|
427
|
+
</tbody>
|
|
428
|
+
|
|
429
|
+
<tfoot
|
|
430
|
+
v-if="hasFooter"
|
|
431
|
+
:class="ui.tfoot({ class: props.ui?.tfoot })"
|
|
432
|
+
data-part="tfoot"
|
|
414
433
|
:style="virtualizer ? {
|
|
415
434
|
transform: `translateY(${virtualizer.getTotalSize() - virtualizer.getVirtualItems().length * virtualizerProps.estimateSize}px)`
|
|
416
|
-
} : void 0"
|
|
417
|
-
>
|
|
418
|
-
<tr :class="ui.separator({ class: props.ui?.separator })" data-part="separator"></tr>
|
|
419
|
-
|
|
420
|
-
<tr v-for="footerGroup in tableApi.getFooterGroups()" :key="footerGroup.id" :class="ui.tr({ class: props.ui?.tr })" data-part="tr">
|
|
421
|
-
<th
|
|
422
|
-
v-for="header in footerGroup.headers"
|
|
423
|
-
:key="header.id"
|
|
424
|
-
:data-pinned="header.column.getIsPinned()"
|
|
425
|
-
:colspan="header.colSpan > 1 ? header.colSpan : void 0"
|
|
426
|
-
:rowspan="header.rowSpan > 1 ? header.rowSpan : void 0"
|
|
435
|
+
} : void 0"
|
|
436
|
+
>
|
|
437
|
+
<tr :class="ui.separator({ class: props.ui?.separator })" data-part="separator"></tr>
|
|
438
|
+
|
|
439
|
+
<tr v-for="footerGroup in tableApi.getFooterGroups()" :key="footerGroup.id" :class="ui.tr({ class: props.ui?.tr })" data-part="tr">
|
|
440
|
+
<th
|
|
441
|
+
v-for="header in footerGroup.headers"
|
|
442
|
+
:key="header.id"
|
|
443
|
+
:data-pinned="header.column.getIsPinned()"
|
|
444
|
+
:colspan="header.colSpan > 1 ? header.colSpan : void 0"
|
|
445
|
+
:rowspan="header.rowSpan > 1 ? header.rowSpan : void 0"
|
|
427
446
|
:class="ui.th({
|
|
428
447
|
class: [
|
|
429
448
|
props.ui?.th,
|
|
430
449
|
resolveValue(header.column.columnDef.meta?.class?.th, header)
|
|
431
450
|
],
|
|
432
451
|
pinned: !!header.column.getIsPinned()
|
|
433
|
-
})"
|
|
434
|
-
data-part="th"
|
|
435
|
-
:style="
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
<
|
|
451
|
-
|
|
452
|
+
})"
|
|
453
|
+
data-part="th"
|
|
454
|
+
:style="[
|
|
455
|
+
getColumnStyles(header.column),
|
|
456
|
+
resolveValue(header.column.columnDef.meta?.style?.th, header)
|
|
457
|
+
]"
|
|
458
|
+
>
|
|
459
|
+
<slot :name="`${header.id}-footer`" v-bind="header.getContext()">
|
|
460
|
+
<FlexRender v-if="!header.isPlaceholder" :render="header.column.columnDef.footer" :props="header.getContext()" />
|
|
461
|
+
</slot>
|
|
462
|
+
</th>
|
|
463
|
+
</tr>
|
|
464
|
+
</tfoot>
|
|
465
|
+
</table>
|
|
466
|
+
</DefineTableTemplate>
|
|
467
|
+
|
|
468
|
+
<Primitive ref="rootRef" :as="props.as" v-bind="$attrs" :class="ui.root({ class: [props.ui?.root, props.class] })" data-part="root">
|
|
469
|
+
<div v-if="virtualizer" :style="{ height: `${virtualizer.getTotalSize()}px` }">
|
|
470
|
+
<ReuseTableTemplate />
|
|
471
|
+
</div>
|
|
472
|
+
<ReuseTableTemplate v-else />
|
|
473
|
+
</Primitive>
|
|
452
474
|
</template>
|