@movk/nuxt 1.4.1 → 1.5.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/README.en.md +308 -0
- package/README.md +4 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -2
- package/dist/runtime/components/AutoForm.d.vue.ts +1 -1
- package/dist/runtime/components/AutoForm.vue.d.ts +1 -1
- package/dist/runtime/components/ColorChooser.d.vue.ts +1 -1
- package/dist/runtime/components/ColorChooser.vue.d.ts +1 -1
- package/dist/runtime/components/DataTable.d.vue.ts +1 -1
- package/dist/runtime/components/DataTable.vue.d.ts +1 -1
- package/dist/runtime/components/DatePicker.d.vue.ts +1 -1
- package/dist/runtime/components/DatePicker.vue.d.ts +1 -1
- package/dist/runtime/components/PillGroup.d.vue.ts +1 -1
- package/dist/runtime/components/PillGroup.vue.d.ts +1 -1
- package/dist/runtime/components/Popconfirm.d.vue.ts +1 -1
- package/dist/runtime/components/Popconfirm.vue.d.ts +1 -1
- package/dist/runtime/components/SearchForm.d.vue.ts +1 -1
- package/dist/runtime/components/SearchForm.vue.d.ts +1 -1
- package/dist/runtime/components/Tree.d.vue.ts +1 -1
- package/dist/runtime/components/Tree.vue +4 -3
- package/dist/runtime/components/Tree.vue.d.ts +1 -1
- package/dist/runtime/components/input/AsPhoneNumberInput.d.vue.ts +1 -1
- package/dist/runtime/components/input/AsPhoneNumberInput.vue.d.ts +1 -1
- package/dist/runtime/components/input/WithCharacterLimit.d.vue.ts +1 -1
- package/dist/runtime/components/input/WithCharacterLimit.vue.d.ts +1 -1
- package/dist/runtime/components/input/WithClear.d.vue.ts +1 -1
- package/dist/runtime/components/input/WithClear.vue.d.ts +1 -1
- package/dist/runtime/components/input/WithCopy.d.vue.ts +1 -1
- package/dist/runtime/components/input/WithCopy.vue.d.ts +1 -1
- package/dist/runtime/components/input/WithFloatingLabel.d.vue.ts +1 -1
- package/dist/runtime/components/input/WithFloatingLabel.vue.d.ts +1 -1
- package/dist/runtime/components/input/WithPasswordToggle.d.vue.ts +1 -1
- package/dist/runtime/components/input/WithPasswordToggle.vue.d.ts +1 -1
- package/dist/runtime/composables/useApiFetch.d.ts +4 -1
- package/dist/runtime/composables/useApiFetch.js +14 -2
- package/dist/runtime/composables/useTheme.js +3 -3
- package/dist/runtime/domains/api/deep-to-value.d.ts +9 -0
- package/dist/runtime/domains/api/deep-to-value.js +11 -0
- package/dist/runtime/domains/api/interceptors/compose.d.ts +24 -0
- package/dist/runtime/domains/api/interceptors/compose.js +18 -0
- package/dist/runtime/domains/auto-form/controls.d.ts +11 -90
- package/dist/runtime/domains/auto-form/controls.js +0 -2
- package/dist/runtime/domains/data-table/columns/resize.d.ts +4 -0
- package/dist/runtime/domains/data-table/columns/resize.js +134 -0
- package/dist/runtime/domains/data-table/columns/resolve-data-column.js +3 -46
- package/dist/runtime/domains/data-table/columns/resolve-special-columns.js +2 -1
- package/dist/runtime/domains/data-table/columns/style.d.ts +1 -0
- package/dist/runtime/domains/data-table/columns/style.js +22 -5
- package/dist/runtime/domains/data-table/components/Pagination.d.vue.ts +1 -1
- package/dist/runtime/domains/data-table/components/Pagination.vue.d.ts +1 -1
- package/dist/runtime/domains/theme/theme-icons.d.ts +9 -0
- package/dist/runtime/domains/theme/theme-icons.js +7 -0
- package/dist/runtime/domains/tree/components/TreeToolbar.vue +1 -1
- package/dist/runtime/plugins/api.factory.js +9 -3
- package/dist/runtime/plugins/theme.js +2 -2
- package/dist/runtime/types/auto-form/zod-factory.d.ts +20 -5
- package/dist/runtime/types/components/date-picker.d.ts +3 -0
- package/dist/runtime/types/components/index.d.ts +0 -1
- package/dist/runtime/types/components/tree.d.ts +1 -0
- package/dist/runtime/vue/plugins/theme.js +2 -2
- package/dist/shared/{nuxt.CXM2nhP4.mjs → nuxt.DJKBap-S.mjs} +0 -28
- package/dist/unplugin.mjs +1 -1
- package/dist/vite.mjs +1 -1
- package/package.json +13 -13
- package/dist/runtime/components/StarRating.d.vue.ts +0 -52
- package/dist/runtime/components/StarRating.vue +0 -238
- package/dist/runtime/components/StarRating.vue.d.ts +0 -52
- package/dist/runtime/types/components/star-rating.d.ts +0 -55
- package/dist/runtime/types/components/star-rating.js +0 -0
|
@@ -22,7 +22,7 @@ declare const __VLS_export: <T extends InputValue>(__VLS_props: NonNullable<Awai
|
|
|
22
22
|
slots: OmitByKey<InputSlots, "trailing">;
|
|
23
23
|
emit: (((evt: "blur", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "copy", value: string) => void) & ((evt: "update:modelValue", value: T) => void)) & ((event: "update:modelValue", value: T | undefined) => void);
|
|
24
24
|
}>) => import("vue").VNode & {
|
|
25
|
-
__ctx?: Awaited<typeof __VLS_setup
|
|
25
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
26
26
|
};
|
|
27
27
|
declare const _default: typeof __VLS_export;
|
|
28
28
|
export default _default;
|
|
@@ -22,7 +22,7 @@ declare const __VLS_export: <T extends InputValue>(__VLS_props: NonNullable<Awai
|
|
|
22
22
|
slots: OmitByKey<InputSlots, "default" | "trailing">;
|
|
23
23
|
emit: (((evt: "clear") => void) & ((evt: "blur", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "update:modelValue", value: T) => void)) & ((event: "update:modelValue", value: T | undefined) => void);
|
|
24
24
|
}>) => import("vue").VNode & {
|
|
25
|
-
__ctx?: Awaited<typeof __VLS_setup
|
|
25
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
26
26
|
};
|
|
27
27
|
declare const _default: typeof __VLS_export;
|
|
28
28
|
export default _default;
|
|
@@ -22,7 +22,7 @@ declare const __VLS_export: <T extends InputValue>(__VLS_props: NonNullable<Awai
|
|
|
22
22
|
slots: OmitByKey<InputSlots, "default" | "trailing">;
|
|
23
23
|
emit: (((evt: "clear") => void) & ((evt: "blur", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "update:modelValue", value: T) => void)) & ((event: "update:modelValue", value: T | undefined) => void);
|
|
24
24
|
}>) => import("vue").VNode & {
|
|
25
|
-
__ctx?: Awaited<typeof __VLS_setup
|
|
25
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
26
26
|
};
|
|
27
27
|
declare const _default: typeof __VLS_export;
|
|
28
28
|
export default _default;
|
|
@@ -21,7 +21,7 @@ declare const __VLS_export: <T extends InputValue>(__VLS_props: NonNullable<Awai
|
|
|
21
21
|
slots: OmitByKey<InputSlots, "trailing">;
|
|
22
22
|
emit: (((evt: "blur", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "update:modelValue", value: T) => void)) & ((event: "update:modelValue", value: T | undefined) => void);
|
|
23
23
|
}>) => import("vue").VNode & {
|
|
24
|
-
__ctx?: Awaited<typeof __VLS_setup
|
|
24
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
25
25
|
};
|
|
26
26
|
declare const _default: typeof __VLS_export;
|
|
27
27
|
export default _default;
|
|
@@ -21,7 +21,7 @@ declare const __VLS_export: <T extends InputValue>(__VLS_props: NonNullable<Awai
|
|
|
21
21
|
slots: OmitByKey<InputSlots, "trailing">;
|
|
22
22
|
emit: (((evt: "blur", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "update:modelValue", value: T) => void)) & ((event: "update:modelValue", value: T | undefined) => void);
|
|
23
23
|
}>) => import("vue").VNode & {
|
|
24
|
-
__ctx?: Awaited<typeof __VLS_setup
|
|
24
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
25
25
|
};
|
|
26
26
|
declare const _default: typeof __VLS_export;
|
|
27
27
|
export default _default;
|
|
@@ -38,13 +38,16 @@ import type { UseApiFetchOptions, UseApiFetchReturn } from '../types/api';
|
|
|
38
38
|
* // 跳过解包,拿原始响应(与 skipBusinessCheck 正交)
|
|
39
39
|
* const { data } = await useApiFetch<ApiResponse>('/external', { skipUnwrap: true })
|
|
40
40
|
*
|
|
41
|
-
* // 用户自定义 hooks
|
|
41
|
+
* // 用户自定义 hooks:与内置拦截器组合(内置先执行),不会覆盖认证/业务校验/解包/Toast
|
|
42
42
|
* const { data } = await useApiFetch('/users', {
|
|
43
43
|
* onResponse({ response }) {
|
|
44
44
|
* // response._data 已是解包后的业务数据(除非传入 skipUnwrap: true)
|
|
45
|
+
* // 仅业务成功时触发;返回值被 ofetch 忽略,副作用专用
|
|
45
46
|
* console.log('自定义处理:', response._data)
|
|
46
47
|
* }
|
|
47
48
|
* })
|
|
49
|
+
*
|
|
50
|
+
* // 变形输出请用 transform 或直接消费自动解包后的 data,而非在 onResponse 中 return
|
|
48
51
|
* ```
|
|
49
52
|
*/
|
|
50
53
|
export declare function useApiFetch<T = unknown, DataT = T>(url: NitroFetchRequest | (() => NitroFetchRequest), options?: UseApiFetchOptions<T, DataT>): UseApiFetchReturn<DataT>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { computed, toValue } from "vue";
|
|
2
2
|
import { useNuxtApp, useFetch } from "#app";
|
|
3
3
|
import { buildApiFetchKey } from "../domains/api/fetch-key.js";
|
|
4
|
+
import { deepToValue } from "../domains/api/deep-to-value.js";
|
|
5
|
+
import { composeHook, getInterceptors } from "../domains/api/interceptors/compose.js";
|
|
4
6
|
export function useApiFetch(url, options = {}) {
|
|
5
7
|
const { $api } = useNuxtApp();
|
|
6
8
|
const {
|
|
@@ -11,6 +13,15 @@ export function useApiFetch(url, options = {}) {
|
|
|
11
13
|
...fetchOptions
|
|
12
14
|
} = options;
|
|
13
15
|
const apiInstance = endpoint ? $api.use(endpoint) : $api;
|
|
16
|
+
const movk = getInterceptors(apiInstance);
|
|
17
|
+
const composedHooks = movk ? {
|
|
18
|
+
onRequest: composeHook(movk.onRequest, fetchOptions.onRequest),
|
|
19
|
+
onResponse: composeHook(movk.onResponse, fetchOptions.onResponse),
|
|
20
|
+
onResponseError: composeHook(movk.onResponseError, fetchOptions.onResponseError)
|
|
21
|
+
} : {};
|
|
22
|
+
const definedHooks = Object.fromEntries(
|
|
23
|
+
Object.entries(composedHooks).filter(([, value]) => value !== void 0)
|
|
24
|
+
);
|
|
14
25
|
const fetchKey = computed(() => {
|
|
15
26
|
const userKey = toValue(fetchOptions.key);
|
|
16
27
|
if (userKey) return userKey;
|
|
@@ -21,12 +32,13 @@ export function useApiFetch(url, options = {}) {
|
|
|
21
32
|
toast,
|
|
22
33
|
method: toValue(fetchOptions.method),
|
|
23
34
|
url: typeof url === "function" ? url() : url,
|
|
24
|
-
query:
|
|
25
|
-
body:
|
|
35
|
+
query: deepToValue(fetchOptions.query),
|
|
36
|
+
body: deepToValue(fetchOptions.body)
|
|
26
37
|
});
|
|
27
38
|
});
|
|
28
39
|
return useFetch(url, {
|
|
29
40
|
...fetchOptions,
|
|
41
|
+
...definedHooks,
|
|
30
42
|
key: fetchKey,
|
|
31
43
|
$fetch: apiInstance,
|
|
32
44
|
context: { toast, skipBusinessCheck, skipUnwrap }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useAppConfig, useColorMode, useSiteConfig } from "#imports";
|
|
2
|
-
import { themeIcons } from "../domains/theme/theme-icons.js";
|
|
2
|
+
import { resolveThemeIcons, themeIcons } from "../domains/theme/theme-icons.js";
|
|
3
3
|
import { omit, kebabCase } from "@movk/core";
|
|
4
4
|
import { useLocalStorage } from "@vueuse/core";
|
|
5
5
|
import colors from "tailwindcss/colors";
|
|
@@ -67,7 +67,7 @@ export function useTheme() {
|
|
|
67
67
|
},
|
|
68
68
|
set(option) {
|
|
69
69
|
_iconSet.value = option;
|
|
70
|
-
ui.icons =
|
|
70
|
+
ui.icons = resolveThemeIcons(option, ui.icons);
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
73
|
const modes = computed(() => [
|
|
@@ -172,7 +172,7 @@ export function useTheme() {
|
|
|
172
172
|
_radius.value = movk?.radius ?? defaultConfig.radius;
|
|
173
173
|
_font.value = movk?.font ?? defaultConfig.font;
|
|
174
174
|
_iconSet.value = defaultIcon;
|
|
175
|
-
ui.icons =
|
|
175
|
+
ui.icons = resolveThemeIcons(defaultIcon, ui.icons);
|
|
176
176
|
_blackAsPrimary.value = movk?.blackAsPrimary ?? defaultConfig.blackAsPrimary;
|
|
177
177
|
}
|
|
178
178
|
return {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 递归解包嵌套 ref,产出纯值结构
|
|
3
|
+
*
|
|
4
|
+
* @description Vue 的 toValue 仅解包顶层 ref,不会解包普通对象 / 数组内部的嵌套 ref。
|
|
5
|
+
* useApiFetch 的 query / body 常写成 `{ key: ref }`(Nuxt useFetch 允许字段为 ref),
|
|
6
|
+
* 若仅浅解包,buildApiFetchKey 序列化时会把 Ref 对象本身计入,导致不同值派生出相同 key 而缓存碰撞。
|
|
7
|
+
* 仅对纯对象 / 数组递归;Date / File / FormData 等非纯对象原样返回,避免破坏与栈溢出。
|
|
8
|
+
*/
|
|
9
|
+
export declare function deepToValue(value: unknown): unknown;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { toValue } from "vue";
|
|
2
|
+
export function deepToValue(value) {
|
|
3
|
+
const resolved = toValue(value);
|
|
4
|
+
if (Array.isArray(resolved)) return resolved.map(deepToValue);
|
|
5
|
+
if (resolved !== null && typeof resolved === "object" && Object.getPrototypeOf(resolved) === Object.prototype) {
|
|
6
|
+
return Object.fromEntries(
|
|
7
|
+
Object.entries(resolved).map(([k, v]) => [k, deepToValue(v)])
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
return resolved;
|
|
11
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { $Fetch } from 'nitropack/types';
|
|
2
|
+
import type { FetchHook } from 'ofetch';
|
|
3
|
+
/**
|
|
4
|
+
* 单端点的 movk 内置拦截器集合
|
|
5
|
+
* @description 由 api.factory 在创建 $fetch 实例时挂到实例上,供 useApiFetch 在用户传入同名钩子时组合复用
|
|
6
|
+
*/
|
|
7
|
+
export interface MovkInterceptors {
|
|
8
|
+
onRequest: FetchHook;
|
|
9
|
+
onResponse: FetchHook;
|
|
10
|
+
onResponseError: FetchHook;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 把 movk 内置拦截器以非枚举符号挂到 $fetch 实例
|
|
14
|
+
* @description 符号键不进入 ApiInstance 公共类型,强转集中于此
|
|
15
|
+
*/
|
|
16
|
+
export declare function attachInterceptors(instance: $Fetch, interceptors: MovkInterceptors): void;
|
|
17
|
+
/** 读取实例上挂载的 movk 内置拦截器 */
|
|
18
|
+
export declare function getInterceptors(instance: $Fetch): MovkInterceptors | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* 组合 movk 内置钩子与用户钩子为数组(movk 先执行)
|
|
21
|
+
* @description 用户未传钩子时返回 undefined,让 ofetch 沿用实例 default(不覆盖);
|
|
22
|
+
* 用户传入时返回 `[movkHook, ...userHooks]`,使用户钩子拿到 movk 处理后的上下文
|
|
23
|
+
*/
|
|
24
|
+
export declare function composeHook<H>(movkHook: H, userHook: H | H[] | undefined): H[] | undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const MOVK_INTERCEPTORS = Symbol("movk:interceptors");
|
|
2
|
+
export function attachInterceptors(instance, interceptors) {
|
|
3
|
+
Object.defineProperty(instance, MOVK_INTERCEPTORS, {
|
|
4
|
+
value: interceptors,
|
|
5
|
+
enumerable: false,
|
|
6
|
+
configurable: true
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
export function getInterceptors(instance) {
|
|
10
|
+
return instance[MOVK_INTERCEPTORS];
|
|
11
|
+
}
|
|
12
|
+
function toArray(value) {
|
|
13
|
+
return Array.isArray(value) ? value : [value];
|
|
14
|
+
}
|
|
15
|
+
export function composeHook(movkHook, userHook) {
|
|
16
|
+
if (userHook === void 0) return void 0;
|
|
17
|
+
return [movkHook, ...toArray(userHook)];
|
|
18
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IsComponent } from '@movk/core';
|
|
2
2
|
import type { AutoFormControl, _Unset } from '../../types/auto-form/controls';
|
|
3
3
|
import type { InputProps, InputSlots, TextareaProps, TextareaSlots } from '@nuxt/ui';
|
|
4
|
+
import type { CalendarDateControlProps } from '../../types/components/date-picker';
|
|
4
5
|
import { UInput, UTextarea } from '#components';
|
|
5
6
|
export declare function defineControl<C extends IsComponent, P = _Unset, S = _Unset>(e: AutoFormControl<C, P, S>): AutoFormControl<C, P, S>;
|
|
6
7
|
declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
@@ -76,7 +77,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
76
77
|
slots: import("@movk/core").OmitByKey<InputSlots, "trailing">;
|
|
77
78
|
emit: (((evt: "clear") => void) & ((evt: "blur", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "update:modelValue", value: T) => void)) & ((event: "update:modelValue", value: T | undefined) => void);
|
|
78
79
|
}>) => import("vue").VNode & {
|
|
79
|
-
__ctx?: Awaited<typeof __VLS_setup
|
|
80
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
80
81
|
};
|
|
81
82
|
readonly withPasswordToggle: <T extends import("@nuxt/ui").InputValue>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: {
|
|
82
83
|
slots: import("@movk/core").OmitByKey<InputSlots, "trailing">;
|
|
@@ -140,7 +141,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
140
141
|
slots: import("@movk/core").OmitByKey<InputSlots, "trailing">;
|
|
141
142
|
emit: (((evt: "blur", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "update:modelValue", value: T) => void)) & ((event: "update:modelValue", value: T | undefined) => void);
|
|
142
143
|
}>) => import("vue").VNode & {
|
|
143
|
-
__ctx?: Awaited<typeof __VLS_setup
|
|
144
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
144
145
|
};
|
|
145
146
|
readonly withCopy: <T extends import("@nuxt/ui").InputValue>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: {
|
|
146
147
|
slots: import("@movk/core").OmitByKey<InputSlots, "trailing">;
|
|
@@ -207,7 +208,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
207
208
|
slots: import("@movk/core").OmitByKey<InputSlots, "trailing">;
|
|
208
209
|
emit: (((evt: "blur", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "copy", value: string) => void) & ((evt: "update:modelValue", value: T) => void)) & ((event: "update:modelValue", value: T | undefined) => void);
|
|
209
210
|
}>) => import("vue").VNode & {
|
|
210
|
-
__ctx?: Awaited<typeof __VLS_setup
|
|
211
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
211
212
|
};
|
|
212
213
|
readonly withCharacterLimit: <T extends import("@nuxt/ui").InputValue>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: {
|
|
213
214
|
slots: import("@movk/core").OmitByKey<InputSlots, "trailing">;
|
|
@@ -272,7 +273,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
272
273
|
slots: import("@movk/core").OmitByKey<InputSlots, "trailing">;
|
|
273
274
|
emit: (((evt: "blur", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "update:modelValue", value: T) => void)) & ((event: "update:modelValue", value: T | undefined) => void);
|
|
274
275
|
}>) => import("vue").VNode & {
|
|
275
|
-
__ctx?: Awaited<typeof __VLS_setup
|
|
276
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
276
277
|
};
|
|
277
278
|
readonly withFloatingLabel: <T extends import("@nuxt/ui").InputValue>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: {
|
|
278
279
|
slots: import("@movk/core").OmitByKey<InputSlots, "default" | "trailing">;
|
|
@@ -339,7 +340,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
339
340
|
slots: import("@movk/core").OmitByKey<InputSlots, "default" | "trailing">;
|
|
340
341
|
emit: (((evt: "clear") => void) & ((evt: "blur", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "update:modelValue", value: T) => void)) & ((event: "update:modelValue", value: T | undefined) => void);
|
|
341
342
|
}>) => import("vue").VNode & {
|
|
342
|
-
__ctx?: Awaited<typeof __VLS_setup
|
|
343
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
343
344
|
};
|
|
344
345
|
readonly asPhoneNumberInput: <T extends import("@nuxt/ui").InputValue>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: {
|
|
345
346
|
slots: import("@movk/core").OmitByKey<InputSlots, "leading">;
|
|
@@ -404,7 +405,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
404
405
|
slots: import("@movk/core").OmitByKey<InputSlots, "leading">;
|
|
405
406
|
emit: (((evt: "blur", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "update:modelValue", value: T) => void)) & ((event: "update:modelValue", value: T | undefined) => void);
|
|
406
407
|
}>) => import("vue").VNode & {
|
|
407
|
-
__ctx?: Awaited<typeof __VLS_setup
|
|
408
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
408
409
|
};
|
|
409
410
|
readonly textarea: any;
|
|
410
411
|
readonly switch: any;
|
|
@@ -416,87 +417,6 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
416
417
|
readonly inputTags: any;
|
|
417
418
|
readonly pinInput: any;
|
|
418
419
|
readonly listbox: any;
|
|
419
|
-
readonly starRating: {
|
|
420
|
-
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("../../types").StarRatingProps & {
|
|
421
|
-
ui?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("@nuxt/schema").AppConfig, "starRating">["slots"];
|
|
422
|
-
} & {
|
|
423
|
-
modelValue?: number;
|
|
424
|
-
}> & Readonly<{
|
|
425
|
-
onChange?: ((value: number) => any) | undefined;
|
|
426
|
-
"onUpdate:modelValue"?: ((value: number) => any) | undefined;
|
|
427
|
-
onHover?: ((value: number | null) => any) | undefined;
|
|
428
|
-
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
429
|
-
change: (value: number) => any;
|
|
430
|
-
"update:modelValue": (value: number) => any;
|
|
431
|
-
hover: (value: number | null) => any;
|
|
432
|
-
}, import("vue").PublicProps, {
|
|
433
|
-
max: number;
|
|
434
|
-
showBadge: boolean;
|
|
435
|
-
emptyIcon: import("@nuxt/ui").IconProps["name"];
|
|
436
|
-
filledIcon: import("@nuxt/ui").IconProps["name"];
|
|
437
|
-
halfIcon: import("@nuxt/ui").IconProps["name"];
|
|
438
|
-
}, false, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
439
|
-
P: {};
|
|
440
|
-
B: {};
|
|
441
|
-
D: {};
|
|
442
|
-
C: {};
|
|
443
|
-
M: {};
|
|
444
|
-
Defaults: {};
|
|
445
|
-
}, Readonly<import("../../types").StarRatingProps & {
|
|
446
|
-
ui?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("@nuxt/schema").AppConfig, "starRating">["slots"];
|
|
447
|
-
} & {
|
|
448
|
-
modelValue?: number;
|
|
449
|
-
}> & Readonly<{
|
|
450
|
-
onChange?: ((value: number) => any) | undefined;
|
|
451
|
-
"onUpdate:modelValue"?: ((value: number) => any) | undefined;
|
|
452
|
-
onHover?: ((value: number | null) => any) | undefined;
|
|
453
|
-
}>, {}, {}, {}, {}, {
|
|
454
|
-
max: number;
|
|
455
|
-
showBadge: boolean;
|
|
456
|
-
emptyIcon: import("@nuxt/ui").IconProps["name"];
|
|
457
|
-
filledIcon: import("@nuxt/ui").IconProps["name"];
|
|
458
|
-
halfIcon: import("@nuxt/ui").IconProps["name"];
|
|
459
|
-
}>;
|
|
460
|
-
__isFragment?: never;
|
|
461
|
-
__isTeleport?: never;
|
|
462
|
-
__isSuspense?: never;
|
|
463
|
-
} & import("vue").ComponentOptionsBase<Readonly<import("../../types").StarRatingProps & {
|
|
464
|
-
ui?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("@nuxt/schema").AppConfig, "starRating">["slots"];
|
|
465
|
-
} & {
|
|
466
|
-
modelValue?: number;
|
|
467
|
-
}> & Readonly<{
|
|
468
|
-
onChange?: ((value: number) => any) | undefined;
|
|
469
|
-
"onUpdate:modelValue"?: ((value: number) => any) | undefined;
|
|
470
|
-
onHover?: ((value: number | null) => any) | undefined;
|
|
471
|
-
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
472
|
-
change: (value: number) => any;
|
|
473
|
-
"update:modelValue": (value: number) => any;
|
|
474
|
-
hover: (value: number | null) => any;
|
|
475
|
-
}, string, {
|
|
476
|
-
max: number;
|
|
477
|
-
showBadge: boolean;
|
|
478
|
-
emptyIcon: import("@nuxt/ui").IconProps["name"];
|
|
479
|
-
filledIcon: import("@nuxt/ui").IconProps["name"];
|
|
480
|
-
halfIcon: import("@nuxt/ui").IconProps["name"];
|
|
481
|
-
}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
482
|
-
$slots: {
|
|
483
|
-
prefix?: (props: {
|
|
484
|
-
value: number;
|
|
485
|
-
max: number;
|
|
486
|
-
}) => any;
|
|
487
|
-
} & {
|
|
488
|
-
badge?: (props: {
|
|
489
|
-
value: number;
|
|
490
|
-
max: number;
|
|
491
|
-
label: string;
|
|
492
|
-
}) => any;
|
|
493
|
-
} & {
|
|
494
|
-
suffix?: (props: {
|
|
495
|
-
value: number;
|
|
496
|
-
max: number;
|
|
497
|
-
}) => any;
|
|
498
|
-
};
|
|
499
|
-
});
|
|
500
420
|
readonly colorChooser: <M extends "click" | "hover">(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: {
|
|
501
421
|
slots: import("../../types").ColorChooserSlots;
|
|
502
422
|
attrs: any;
|
|
@@ -534,6 +454,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
534
454
|
modal?: boolean | undefined;
|
|
535
455
|
openDelay?: number | undefined;
|
|
536
456
|
closeDelay?: number | undefined;
|
|
457
|
+
enableTouch?: boolean | undefined;
|
|
537
458
|
modelValue?: string | undefined;
|
|
538
459
|
onClear?: (() => any) | undefined;
|
|
539
460
|
onChange?: ((value: string | undefined) => any) | undefined;
|
|
@@ -549,7 +470,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
549
470
|
slots: import("../../types").ColorChooserSlots;
|
|
550
471
|
emit: (((evt: "clear") => void) & ((evt: "change", value: string | undefined) => void) & ((evt: "copy", value: string) => void) & ((evt: "update:modelValue", value: string | undefined) => void) & ((evt: "update:open", open: boolean) => void) & ((evt: "format-change", format: import("../../types").ColorFormat) => void)) & ((event: "update:modelValue", value: string | undefined) => void);
|
|
551
472
|
}>) => import("vue").VNode & {
|
|
552
|
-
__ctx?: Awaited<typeof __VLS_setup
|
|
473
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
553
474
|
};
|
|
554
475
|
readonly slideVerify: {
|
|
555
476
|
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("../../types").SlideVerifyProps & {
|
|
@@ -670,12 +591,12 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
670
591
|
slots: import("../../types").PillGroupSlots<T, VK, M>;
|
|
671
592
|
emit: (((evt: "blur", event: FocusEvent) => void) & ((evt: "change", value: import("@nuxt/ui").GetModelValue<T, VK, M, undefined>) => void) & ((evt: "focus", event: FocusEvent) => void) & ((evt: "select", payload: import("../../types").PillSelectPayload<T>) => void) & ((evt: "update:modelValue", value: import("@nuxt/ui").GetModelValue<T, VK, M, undefined>) => void)) & ((event: "update:modelValue", value: import("@nuxt/ui").GetModelValue<T, VK, M> | undefined) => void);
|
|
672
593
|
}>) => import("vue").VNode & {
|
|
673
|
-
__ctx?: Awaited<typeof __VLS_setup
|
|
594
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
674
595
|
};
|
|
675
596
|
};
|
|
676
597
|
type DefaultControlComponents = typeof DEFAULT_CONTROL_COMPONENTS;
|
|
677
598
|
type DefaultControlMap = {
|
|
678
|
-
readonly [K in keyof DefaultControlComponents]: K extends 'string' ? AutoFormControl<typeof UInput, InputProps, InputSlots> : K extends 'textarea' ? AutoFormControl<typeof UTextarea, TextareaProps, TextareaSlots> : AutoFormControl<DefaultControlComponents[K]>;
|
|
599
|
+
readonly [K in keyof DefaultControlComponents]: K extends 'string' ? AutoFormControl<typeof UInput, InputProps, InputSlots> : K extends 'textarea' ? AutoFormControl<typeof UTextarea, TextareaProps, TextareaSlots> : K extends 'calendarDate' ? AutoFormControl<DefaultControlComponents[K], CalendarDateControlProps> : AutoFormControl<DefaultControlComponents[K]>;
|
|
679
600
|
};
|
|
680
601
|
export declare const DEFAULT_CONTROLS: DefaultControlMap;
|
|
681
602
|
export {};
|
|
@@ -6,7 +6,6 @@ import AsPhoneNumberInput from "../../components/input/AsPhoneNumberInput.vue";
|
|
|
6
6
|
import WithFloatingLabel from "../../components/input/WithFloatingLabel.vue";
|
|
7
7
|
import DatePicker from "../../components/DatePicker.vue";
|
|
8
8
|
import ColorChooser from "../../components/ColorChooser.vue";
|
|
9
|
-
import StarRating from "../../components/StarRating.vue";
|
|
10
9
|
import SlideVerify from "../../components/SlideVerify.vue";
|
|
11
10
|
import PillGroup from "../../components/PillGroup.vue";
|
|
12
11
|
import {
|
|
@@ -66,7 +65,6 @@ const DEFAULT_CONTROL_COMPONENTS = {
|
|
|
66
65
|
inputTags: UInputTags,
|
|
67
66
|
pinInput: UPinInput,
|
|
68
67
|
listbox: UListbox,
|
|
69
|
-
starRating: StarRating,
|
|
70
68
|
colorChooser: ColorChooser,
|
|
71
69
|
slideVerify: SlideVerify,
|
|
72
70
|
pillGroup: PillGroup
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { HeaderContext } from '@tanstack/vue-table';
|
|
2
|
+
import type { VNode } from 'vue';
|
|
3
|
+
import type { DataTableProps } from '../../../types/data-table/component';
|
|
4
|
+
export declare function buildResizeHandle<T>(ctx: HeaderContext<T, unknown>, options: DataTableProps<T>): VNode;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { h } from "vue";
|
|
2
|
+
import { clampSize } from "./style.js";
|
|
3
|
+
const DRAG_THRESHOLD = 2;
|
|
4
|
+
const HANDLE_STYLE = {
|
|
5
|
+
position: "absolute",
|
|
6
|
+
insetBlock: "0",
|
|
7
|
+
right: "0",
|
|
8
|
+
width: "14px",
|
|
9
|
+
cursor: "col-resize",
|
|
10
|
+
display: "flex",
|
|
11
|
+
alignItems: "center",
|
|
12
|
+
justifyContent: "flex-end",
|
|
13
|
+
zIndex: "15",
|
|
14
|
+
touchAction: "none",
|
|
15
|
+
userSelect: "none"
|
|
16
|
+
};
|
|
17
|
+
const BADGE_STYLE = {
|
|
18
|
+
position: "absolute",
|
|
19
|
+
top: "50%",
|
|
20
|
+
right: "0",
|
|
21
|
+
transform: "translateY(-50%)",
|
|
22
|
+
marginRight: "6px",
|
|
23
|
+
padding: "2px 6px",
|
|
24
|
+
borderRadius: "4px",
|
|
25
|
+
backgroundColor: "var(--ui-primary)",
|
|
26
|
+
color: "var(--ui-text-inverted)",
|
|
27
|
+
fontSize: "12px",
|
|
28
|
+
fontWeight: "500",
|
|
29
|
+
lineHeight: "1",
|
|
30
|
+
whiteSpace: "nowrap",
|
|
31
|
+
fontVariantNumeric: "tabular-nums",
|
|
32
|
+
pointerEvents: "none",
|
|
33
|
+
zIndex: "20"
|
|
34
|
+
};
|
|
35
|
+
function lineStyle(active) {
|
|
36
|
+
return {
|
|
37
|
+
width: active ? "2px" : "1px",
|
|
38
|
+
height: "60%",
|
|
39
|
+
marginRight: "3px",
|
|
40
|
+
borderRadius: "1px",
|
|
41
|
+
backgroundColor: active ? "var(--ui-primary)" : "var(--ui-border-accented)",
|
|
42
|
+
opacity: active ? "1" : "0.6",
|
|
43
|
+
transition: "background-color 0.15s, width 0.15s, opacity 0.15s"
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function highlightLine(handle, active) {
|
|
47
|
+
const line = handle?.firstElementChild;
|
|
48
|
+
if (line) Object.assign(line.style, lineStyle(active));
|
|
49
|
+
}
|
|
50
|
+
function clientXOf(e) {
|
|
51
|
+
return "touches" in e ? e.touches[0]?.clientX : e.clientX;
|
|
52
|
+
}
|
|
53
|
+
function startResize(ctx, options, e) {
|
|
54
|
+
const id = ctx.column.id;
|
|
55
|
+
const th = e.currentTarget?.closest("th");
|
|
56
|
+
const startWidth = th ? th.getBoundingClientRect().width : ctx.column.getSize();
|
|
57
|
+
const startX = clientXOf(e) ?? 0;
|
|
58
|
+
const min = ctx.column.columnDef.minSize ?? 20;
|
|
59
|
+
const max = ctx.column.columnDef.maxSize ?? Number.MAX_SAFE_INTEGER;
|
|
60
|
+
const liveMode = (options.columnResizeMode ?? "onChange") === "onChange";
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
let moved = false;
|
|
63
|
+
let lastX = startX;
|
|
64
|
+
let rafId = 0;
|
|
65
|
+
const widthAt = (x) => clampSize(Math.round(startWidth + (x - startX)), min, max);
|
|
66
|
+
const apply = () => {
|
|
67
|
+
rafId = 0;
|
|
68
|
+
ctx.table.setColumnSizing((prev) => ({ ...prev, [id]: widthAt(lastX) }));
|
|
69
|
+
};
|
|
70
|
+
const freezeLeftColumns = () => {
|
|
71
|
+
const tr = th?.closest("tr");
|
|
72
|
+
const headers = ctx.table.getHeaderGroups().at(-1)?.headers ?? [];
|
|
73
|
+
const draggedIndex = headers.findIndex((hd) => hd.column.id === id);
|
|
74
|
+
if (!tr || draggedIndex <= 0) return;
|
|
75
|
+
const ths = Array.from(tr.querySelectorAll(":scope > th"));
|
|
76
|
+
const frozen = {};
|
|
77
|
+
for (let i = 0; i < draggedIndex; i++) {
|
|
78
|
+
const el = ths[i];
|
|
79
|
+
const hd = headers[i];
|
|
80
|
+
if (el && hd) frozen[hd.column.id] = Math.round(el.getBoundingClientRect().width);
|
|
81
|
+
}
|
|
82
|
+
if (Object.keys(frozen).length) ctx.table.setColumnSizing((prev) => ({ ...prev, ...frozen }));
|
|
83
|
+
};
|
|
84
|
+
const stop = () => {
|
|
85
|
+
window.removeEventListener("mousemove", onMove);
|
|
86
|
+
window.removeEventListener("mouseup", onEnd);
|
|
87
|
+
window.removeEventListener("touchmove", onMove);
|
|
88
|
+
window.removeEventListener("touchend", onEnd);
|
|
89
|
+
};
|
|
90
|
+
const onMove = (ev) => {
|
|
91
|
+
const x = clientXOf(ev);
|
|
92
|
+
if (typeof x !== "number") return;
|
|
93
|
+
if (!moved) {
|
|
94
|
+
if (Math.abs(x - startX) <= DRAG_THRESHOLD) return;
|
|
95
|
+
moved = true;
|
|
96
|
+
freezeLeftColumns();
|
|
97
|
+
ctx.table.setColumnSizingInfo((prev) => ({ ...prev, isResizingColumn: id }));
|
|
98
|
+
}
|
|
99
|
+
lastX = x;
|
|
100
|
+
if (liveMode && !rafId) rafId = requestAnimationFrame(apply);
|
|
101
|
+
};
|
|
102
|
+
const onEnd = (ev) => {
|
|
103
|
+
if (rafId) cancelAnimationFrame(rafId);
|
|
104
|
+
if (moved) {
|
|
105
|
+
const x = clientXOf(ev);
|
|
106
|
+
if (typeof x === "number") lastX = x;
|
|
107
|
+
ctx.table.setColumnSizing((prev) => ({ ...prev, [id]: widthAt(lastX) }));
|
|
108
|
+
ctx.table.setColumnSizingInfo((prev) => ({ ...prev, isResizingColumn: false }));
|
|
109
|
+
}
|
|
110
|
+
stop();
|
|
111
|
+
};
|
|
112
|
+
window.addEventListener("mousemove", onMove);
|
|
113
|
+
window.addEventListener("mouseup", onEnd);
|
|
114
|
+
window.addEventListener("touchmove", onMove);
|
|
115
|
+
window.addEventListener("touchend", onEnd);
|
|
116
|
+
}
|
|
117
|
+
export function buildResizeHandle(ctx, options) {
|
|
118
|
+
const isResizing = ctx.column.getIsResizing();
|
|
119
|
+
return h("div", {
|
|
120
|
+
style: HANDLE_STYLE,
|
|
121
|
+
onMousedown: (e) => startResize(ctx, options, e),
|
|
122
|
+
onTouchstart: (e) => startResize(ctx, options, e),
|
|
123
|
+
onClick: (e) => e.stopPropagation(),
|
|
124
|
+
onMouseenter: (e) => {
|
|
125
|
+
if (!isResizing) highlightLine(e.currentTarget, true);
|
|
126
|
+
},
|
|
127
|
+
onMouseleave: (e) => {
|
|
128
|
+
if (!isResizing) highlightLine(e.currentTarget, false);
|
|
129
|
+
}
|
|
130
|
+
}, [
|
|
131
|
+
h("div", { style: lineStyle(isResizing) }),
|
|
132
|
+
isResizing ? h("div", { style: BADGE_STYLE }, `${Math.round(ctx.column.getSize())}px`) : null
|
|
133
|
+
]);
|
|
134
|
+
}
|
|
@@ -3,6 +3,7 @@ import { resolveCallbackValue, resolveColumnFlag, resolveTemplate } from "./util
|
|
|
3
3
|
import DataTableCellTooltip from "../components/CellTooltip.vue";
|
|
4
4
|
import { UButton } from "#components";
|
|
5
5
|
import { applyBaseState, buildClassMeta, makeColumnStyle, resolveAlignClass } from "./style.js";
|
|
6
|
+
import { buildResizeHandle } from "./resize.js";
|
|
6
7
|
function buildDataCellRenderer(col, options) {
|
|
7
8
|
const maybeTooltip = col.tooltip !== void 0 ? !!col.tooltip : !!options.tooltip;
|
|
8
9
|
const maybeTruncate = col.truncate !== void 0 ? !!col.truncate : !!options.truncate;
|
|
@@ -110,53 +111,9 @@ export function renderHeaderActions(ctx, col, options, label, sortable, pinable,
|
|
|
110
111
|
if (sortable) actions.push(buildSortAction(col, options));
|
|
111
112
|
const leading = actions.filter((a) => a.position === "leading").map((a) => a.render(ctx));
|
|
112
113
|
const trailing = actions.filter((a) => a.position === "trailing").map((a) => a.render(ctx));
|
|
113
|
-
const
|
|
114
|
-
const id = ctx.column.id;
|
|
115
|
-
const seeded = !(id in ctx.table.getState().columnSizing);
|
|
116
|
-
if (seeded) {
|
|
117
|
-
const th = e.currentTarget?.closest("th");
|
|
118
|
-
const w = th ? Math.round(th.getBoundingClientRect().width) : 0;
|
|
119
|
-
if (w > 0) ctx.table.setColumnSizing((prev) => ({ ...prev, [id]: w }));
|
|
120
|
-
}
|
|
121
|
-
ctx.header.getResizeHandler()(e);
|
|
122
|
-
if (!seeded) return;
|
|
123
|
-
const startX = "touches" in e ? e.touches[0]?.clientX ?? 0 : e.clientX;
|
|
124
|
-
let moved = false;
|
|
125
|
-
const onMove = (ev) => {
|
|
126
|
-
const x = "touches" in ev ? ev.touches[0]?.clientX : ev.clientX;
|
|
127
|
-
if (typeof x === "number" && Math.abs(x - startX) > 2) moved = true;
|
|
128
|
-
};
|
|
129
|
-
const onEnd = () => {
|
|
130
|
-
if (!moved) {
|
|
131
|
-
ctx.table.setColumnSizing(
|
|
132
|
-
(prev) => Object.fromEntries(Object.entries(prev).filter(([key]) => key !== id))
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
window.removeEventListener("mousemove", onMove);
|
|
136
|
-
window.removeEventListener("mouseup", onEnd);
|
|
137
|
-
window.removeEventListener("touchmove", onMove);
|
|
138
|
-
window.removeEventListener("touchend", onEnd);
|
|
139
|
-
};
|
|
140
|
-
window.addEventListener("mousemove", onMove);
|
|
141
|
-
window.addEventListener("mouseup", onEnd);
|
|
142
|
-
window.addEventListener("touchmove", onMove);
|
|
143
|
-
window.addEventListener("touchend", onEnd);
|
|
144
|
-
};
|
|
145
|
-
const resizeHandle = resizable ? h("div", {
|
|
146
|
-
class: "absolute top-0 bottom-0 right-0 w-4 -mr-2 cursor-col-resize select-none touch-none flex items-center justify-center group/resize",
|
|
147
|
-
onMousedown: startResize,
|
|
148
|
-
onTouchstart: startResize,
|
|
149
|
-
onClick: (e) => e.stopPropagation()
|
|
150
|
-
}, [
|
|
151
|
-
h("div", {
|
|
152
|
-
class: [
|
|
153
|
-
"h-full transition-colors",
|
|
154
|
-
ctx.column.getIsResizing() ? "w-0.5 bg-primary" : "w-px opacity-50 group-hover:opacity-100 bg-(--ui-border-accented) group-hover/resize:w-0.5 group-hover/resize:bg-primary"
|
|
155
|
-
].join(" ")
|
|
156
|
-
})
|
|
157
|
-
]) : null;
|
|
114
|
+
const resizeHandle = resizable ? buildResizeHandle(ctx, options) : null;
|
|
158
115
|
const labelNode = isVNode(label) ? label : h("span", { class: "truncate" }, String(label ?? ""));
|
|
159
|
-
return h("div", { class: "flex items-center gap-1
|
|
116
|
+
return h("div", { class: "flex items-center gap-1 group" }, [
|
|
160
117
|
...leading,
|
|
161
118
|
labelNode,
|
|
162
119
|
...trailing,
|
|
@@ -27,10 +27,11 @@ function buildSpecialColumnDef(col, type, ctx, render) {
|
|
|
27
27
|
const defaults = SPECIAL_COLUMN_DEFAULTS[type];
|
|
28
28
|
const { options, density } = ctx;
|
|
29
29
|
const { id } = defaults;
|
|
30
|
+
const hasExplicitBounds = col.minSize != null || col.maxSize != null;
|
|
30
31
|
const resolvedSize = applyBaseState(
|
|
31
32
|
id,
|
|
32
33
|
col.fixed ?? defaults.fixed,
|
|
33
|
-
col.size ?? defaults.size,
|
|
34
|
+
col.size ?? (hasExplicitBounds ? void 0 : defaults.size),
|
|
34
35
|
ctx
|
|
35
36
|
);
|
|
36
37
|
if (col.visibility === false) ctx.visibility[id] = false;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Cell, ColumnMeta, Header } from '@tanstack/vue-table';
|
|
2
2
|
import type { ResolveContext } from './constants';
|
|
3
|
+
export declare function clampSize(n: number, min: number, max: number): number;
|
|
3
4
|
export declare function resolveColumnSize<T>(ctx: Header<T, unknown> | Cell<T, unknown>): Record<string, string>;
|
|
4
5
|
export declare function makeColumnStyle<T>(align?: 'left' | 'center' | 'right'): {
|
|
5
6
|
th: (ctx: Header<T, unknown>) => Record<string, string>;
|