@shwfed/config 2.3.23 → 2.3.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mcp.mjs +1426 -592
- package/dist/module.json +1 -1
- package/dist/preview/assets/{config-C-EOrL-v.js → config-BYTuKQZr.js} +1 -1
- package/dist/preview/assets/{config-BLxl7ROb.js → config-BoE06fMj.js} +1 -1
- package/dist/preview/assets/{config-BWMtPN22.js → config-CV5P2_b2.js} +1 -1
- package/dist/preview/assets/{config-CJADmi-_.js → config-CVAFGzPb.js} +1 -1
- package/dist/preview/assets/{config-5rB9Rnmf.js → config-CdH0Nxqa.js} +1 -1
- package/dist/preview/assets/{config-pVNUrcvS.js → config-CjlRnKnY.js} +1 -1
- package/dist/preview/assets/{config-DUNvg-mJ.js → config-CrvG15To.js} +1 -1
- package/dist/preview/assets/{config-EtlOM9yx.js → config-DZXC8YJ4.js} +1 -1
- package/dist/preview/assets/{config-f66PEpZ5.js → config-QaYy6DCp.js} +1 -1
- package/dist/preview/assets/{definition.vue_vue_type_script_setup_true_lang-DUu-CoTZ.js → definition.vue_vue_type_script_setup_true_lang-CBPR0zl_.js} +1 -1
- package/dist/preview/assets/{index-CJMxrUKZ.css → index-BCE-G4Ha.css} +1 -1
- package/dist/preview/assets/index-BbnG2cVz.js +643 -0
- package/dist/preview/assets/index-NFKAYzMi.js +1 -0
- package/dist/preview/assets/{runtime-P99-0gRD.js → runtime-1AP_-j3e.js} +1 -1
- package/dist/preview/assets/{runtime-CFPeFbAB.js → runtime-BQiYt6n7.js} +1 -1
- package/dist/preview/assets/{runtime-B9GkQToM.js → runtime-BsiLYYky.js} +1 -1
- package/dist/preview/assets/{runtime-qQ5mJdRv.js → runtime-C-h7PIyx.js} +1 -1
- package/dist/preview/assets/{runtime-DcqfhaaX.js → runtime-CGW3z1YJ.js} +1 -1
- package/dist/preview/assets/{runtime-DoLJtHV2.js → runtime-C_R-VCbd.js} +1 -1
- package/dist/preview/assets/{runtime-CUBGWRtC.js → runtime-DGdEDDUA.js} +1 -1
- package/dist/preview/assets/{runtime-CI38ypkY.js → runtime-DwXjew7j.js} +1 -1
- package/dist/preview/assets/{runtime-C0v-S40R.js → runtime-pM3u8QsQ.js} +1 -1
- package/dist/preview/index.html +2 -2
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-remote/config.d.vue.ts +4 -4
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-remote/config.vue.d.ts +4 -4
- package/dist/runtime/components/table/columns/2026-05-25/com.shwfed.table.column.combobox-multi.remote.options-remote/config.d.vue.ts +4 -4
- package/dist/runtime/components/table/columns/2026-05-25/com.shwfed.table.column.combobox-multi.remote.options-remote/config.vue.d.ts +4 -4
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi/config.d.vue.ts +163 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi/config.vue +699 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi/config.vue.d.ts +163 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi/runtime.d.vue.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi/runtime.vue +368 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi/runtime.vue.d.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi/schema.d.ts +251 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi/schema.js +178 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi.remote/config.d.vue.ts +167 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi.remote/config.vue +732 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi.remote/config.vue.d.ts +167 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi.remote/runtime.d.vue.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi.remote/runtime.vue +402 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi.remote/runtime.vue.d.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi.remote/schema.d.ts +253 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi.remote/schema.js +230 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-single/config.d.vue.ts +163 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-single/config.vue +699 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-single/config.vue.d.ts +163 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-single/runtime.d.vue.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-single/runtime.vue +349 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-single/runtime.vue.d.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-single/schema.d.ts +251 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-single/schema.js +178 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-single.remote/config.d.vue.ts +167 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-single.remote/config.vue +732 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-single.remote/config.vue.d.ts +167 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-single.remote/runtime.d.vue.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-single.remote/runtime.vue +383 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-single.remote/runtime.vue.d.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-single.remote/schema.d.ts +253 -0
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-single.remote/schema.js +230 -0
- package/dist/runtime/components/table/config.vue +40 -0
- package/package.json +1 -1
- package/dist/preview/assets/index-B4xolIUJ.js +0 -643
- package/dist/preview/assets/index-DFYLO8qf.js +0 -1
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { type Value } from './schema.js';
|
|
2
|
+
type __VLS_ModelProps = {
|
|
3
|
+
modelValue: Value;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
|
+
"update:modelValue": (value: {
|
|
7
|
+
readonly size?: number | undefined;
|
|
8
|
+
readonly disabled?: string | undefined;
|
|
9
|
+
readonly type: "com.shwfed.table.column.combobox-multi";
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly title: readonly [{
|
|
12
|
+
readonly locale: "zh";
|
|
13
|
+
readonly message: string;
|
|
14
|
+
}, ...{
|
|
15
|
+
readonly locale: "en" | "ja" | "ko";
|
|
16
|
+
readonly message: string;
|
|
17
|
+
}[]];
|
|
18
|
+
readonly hidden?: string | undefined;
|
|
19
|
+
readonly tooltip?: readonly [{
|
|
20
|
+
readonly locale: "zh";
|
|
21
|
+
readonly message: string;
|
|
22
|
+
}, ...{
|
|
23
|
+
readonly locale: "en" | "ja" | "ko";
|
|
24
|
+
readonly message: string;
|
|
25
|
+
}[]] | undefined;
|
|
26
|
+
readonly compatibilityDate: "2026-05-26";
|
|
27
|
+
readonly groupId?: string | undefined;
|
|
28
|
+
readonly placeholder?: readonly [{
|
|
29
|
+
readonly locale: "zh";
|
|
30
|
+
readonly message: string;
|
|
31
|
+
}, ...{
|
|
32
|
+
readonly locale: "en" | "ja" | "ko";
|
|
33
|
+
readonly message: string;
|
|
34
|
+
}[]] | undefined;
|
|
35
|
+
readonly readonly?: string | undefined;
|
|
36
|
+
readonly grow?: boolean | undefined;
|
|
37
|
+
readonly binding: string;
|
|
38
|
+
readonly derived?: {
|
|
39
|
+
readonly mode: "formula" | "prefill";
|
|
40
|
+
readonly expression: string;
|
|
41
|
+
} | undefined;
|
|
42
|
+
readonly options: {
|
|
43
|
+
readonly kind: "remote";
|
|
44
|
+
readonly request: string;
|
|
45
|
+
readonly options: string;
|
|
46
|
+
readonly optionValue: string;
|
|
47
|
+
readonly optionLabel: readonly [{
|
|
48
|
+
readonly locale: "zh";
|
|
49
|
+
readonly message: string;
|
|
50
|
+
}, ...{
|
|
51
|
+
readonly locale: "en" | "ja" | "ko";
|
|
52
|
+
readonly message: string;
|
|
53
|
+
}[]];
|
|
54
|
+
} | {
|
|
55
|
+
readonly kind: "static";
|
|
56
|
+
readonly items: readonly {
|
|
57
|
+
readonly label: readonly [{
|
|
58
|
+
readonly locale: "zh";
|
|
59
|
+
readonly message: string;
|
|
60
|
+
}, ...{
|
|
61
|
+
readonly locale: "en" | "ja" | "ko";
|
|
62
|
+
readonly message: string;
|
|
63
|
+
}[]];
|
|
64
|
+
readonly id: string;
|
|
65
|
+
readonly tooltip?: readonly [{
|
|
66
|
+
readonly locale: "zh";
|
|
67
|
+
readonly message: string;
|
|
68
|
+
}, ...{
|
|
69
|
+
readonly locale: "en" | "ja" | "ko";
|
|
70
|
+
readonly message: string;
|
|
71
|
+
}[]] | undefined;
|
|
72
|
+
readonly value: {
|
|
73
|
+
readonly value: string;
|
|
74
|
+
readonly kind: "text";
|
|
75
|
+
} | {
|
|
76
|
+
readonly value: number;
|
|
77
|
+
readonly kind: "number";
|
|
78
|
+
};
|
|
79
|
+
}[];
|
|
80
|
+
};
|
|
81
|
+
readonly enableSorting?: boolean | undefined;
|
|
82
|
+
}) => any;
|
|
83
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
|
|
84
|
+
"onUpdate:modelValue"?: ((value: {
|
|
85
|
+
readonly size?: number | undefined;
|
|
86
|
+
readonly disabled?: string | undefined;
|
|
87
|
+
readonly type: "com.shwfed.table.column.combobox-multi";
|
|
88
|
+
readonly id: string;
|
|
89
|
+
readonly title: readonly [{
|
|
90
|
+
readonly locale: "zh";
|
|
91
|
+
readonly message: string;
|
|
92
|
+
}, ...{
|
|
93
|
+
readonly locale: "en" | "ja" | "ko";
|
|
94
|
+
readonly message: string;
|
|
95
|
+
}[]];
|
|
96
|
+
readonly hidden?: string | undefined;
|
|
97
|
+
readonly tooltip?: readonly [{
|
|
98
|
+
readonly locale: "zh";
|
|
99
|
+
readonly message: string;
|
|
100
|
+
}, ...{
|
|
101
|
+
readonly locale: "en" | "ja" | "ko";
|
|
102
|
+
readonly message: string;
|
|
103
|
+
}[]] | undefined;
|
|
104
|
+
readonly compatibilityDate: "2026-05-26";
|
|
105
|
+
readonly groupId?: string | undefined;
|
|
106
|
+
readonly placeholder?: readonly [{
|
|
107
|
+
readonly locale: "zh";
|
|
108
|
+
readonly message: string;
|
|
109
|
+
}, ...{
|
|
110
|
+
readonly locale: "en" | "ja" | "ko";
|
|
111
|
+
readonly message: string;
|
|
112
|
+
}[]] | undefined;
|
|
113
|
+
readonly readonly?: string | undefined;
|
|
114
|
+
readonly grow?: boolean | undefined;
|
|
115
|
+
readonly binding: string;
|
|
116
|
+
readonly derived?: {
|
|
117
|
+
readonly mode: "formula" | "prefill";
|
|
118
|
+
readonly expression: string;
|
|
119
|
+
} | undefined;
|
|
120
|
+
readonly options: {
|
|
121
|
+
readonly kind: "remote";
|
|
122
|
+
readonly request: string;
|
|
123
|
+
readonly options: string;
|
|
124
|
+
readonly optionValue: string;
|
|
125
|
+
readonly optionLabel: readonly [{
|
|
126
|
+
readonly locale: "zh";
|
|
127
|
+
readonly message: string;
|
|
128
|
+
}, ...{
|
|
129
|
+
readonly locale: "en" | "ja" | "ko";
|
|
130
|
+
readonly message: string;
|
|
131
|
+
}[]];
|
|
132
|
+
} | {
|
|
133
|
+
readonly kind: "static";
|
|
134
|
+
readonly items: readonly {
|
|
135
|
+
readonly label: readonly [{
|
|
136
|
+
readonly locale: "zh";
|
|
137
|
+
readonly message: string;
|
|
138
|
+
}, ...{
|
|
139
|
+
readonly locale: "en" | "ja" | "ko";
|
|
140
|
+
readonly message: string;
|
|
141
|
+
}[]];
|
|
142
|
+
readonly id: string;
|
|
143
|
+
readonly tooltip?: readonly [{
|
|
144
|
+
readonly locale: "zh";
|
|
145
|
+
readonly message: string;
|
|
146
|
+
}, ...{
|
|
147
|
+
readonly locale: "en" | "ja" | "ko";
|
|
148
|
+
readonly message: string;
|
|
149
|
+
}[]] | undefined;
|
|
150
|
+
readonly value: {
|
|
151
|
+
readonly value: string;
|
|
152
|
+
readonly kind: "text";
|
|
153
|
+
} | {
|
|
154
|
+
readonly value: number;
|
|
155
|
+
readonly kind: "number";
|
|
156
|
+
};
|
|
157
|
+
}[];
|
|
158
|
+
};
|
|
159
|
+
readonly enableSorting?: boolean | undefined;
|
|
160
|
+
}) => any) | undefined;
|
|
161
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
162
|
+
declare const _default: typeof __VLS_export;
|
|
163
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CellContext } from '@tanstack/vue-table';
|
|
2
|
+
import type { Value } from './schema.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
column: Value;
|
|
5
|
+
ctx: CellContext<unknown, unknown>;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { Icon } from "@iconify/vue";
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
import { watchDebounced } from "@vueuse/core";
|
|
5
|
+
import { computed, ref, watch } from "vue";
|
|
6
|
+
import { useI18n } from "vue-i18n";
|
|
7
|
+
import { cel as _rawCel } from "../../../../../utils/cel";
|
|
8
|
+
import { celBindings, injectCELContext } from "../../../../../utils/cel-context";
|
|
9
|
+
import { getLocalizedText } from "../../../../../share/locale";
|
|
10
|
+
import {
|
|
11
|
+
Command,
|
|
12
|
+
CommandEmpty,
|
|
13
|
+
CommandGroup,
|
|
14
|
+
CommandInput,
|
|
15
|
+
CommandItem,
|
|
16
|
+
CommandList
|
|
17
|
+
} from "../../../../ui/command";
|
|
18
|
+
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "../../../../ui/input-group";
|
|
19
|
+
import { Markdown } from "../../../../ui/markdown";
|
|
20
|
+
import { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from "../../../../ui/popover";
|
|
21
|
+
import { useFormState } from "../../../../form/utils/state";
|
|
22
|
+
import { interpolateMarkdown } from "../../../utils/runtime";
|
|
23
|
+
import { useSharedFetchLayer } from "../../../utils/shared-fetch";
|
|
24
|
+
defineOptions({ name: "ShwfedTableComboboxMultiRendererRuntime" });
|
|
25
|
+
const props = defineProps({
|
|
26
|
+
column: { type: null, required: true },
|
|
27
|
+
ctx: { type: Object, required: true }
|
|
28
|
+
});
|
|
29
|
+
const { locale, t } = useI18n({
|
|
30
|
+
inheritLocale: true,
|
|
31
|
+
messages: {
|
|
32
|
+
zh: {
|
|
33
|
+
"combobox-multi-placeholder": "\u8BF7\u9009\u62E9",
|
|
34
|
+
"combobox-multi-search-placeholder": "\u641C\u7D22\u2026",
|
|
35
|
+
"combobox-multi-empty": "\u65E0\u5339\u914D\u9879",
|
|
36
|
+
"combobox-multi-loading": "\u52A0\u8F7D\u4E2D\u2026"
|
|
37
|
+
},
|
|
38
|
+
en: {
|
|
39
|
+
"combobox-multi-placeholder": "Select\u2026",
|
|
40
|
+
"combobox-multi-search-placeholder": "Search\u2026",
|
|
41
|
+
"combobox-multi-empty": "No matches",
|
|
42
|
+
"combobox-multi-loading": "Loading\u2026"
|
|
43
|
+
},
|
|
44
|
+
ja: {
|
|
45
|
+
"combobox-multi-placeholder": "\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
46
|
+
"combobox-multi-search-placeholder": "\u691C\u7D22\u2026",
|
|
47
|
+
"combobox-multi-empty": "\u4E00\u81F4\u306A\u3057",
|
|
48
|
+
"combobox-multi-loading": "\u8AAD\u307F\u8FBC\u307F\u4E2D\u2026"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const formState = useFormState();
|
|
53
|
+
const inherited = injectCELContext();
|
|
54
|
+
const $cel = (expression, context) => _rawCel(expression, { ...celBindings(inherited), ...context });
|
|
55
|
+
const sharedFetchLayer = useSharedFetchLayer();
|
|
56
|
+
const row = computed(() => props.ctx.row.original);
|
|
57
|
+
const rowIndex = computed(() => props.ctx.row.index);
|
|
58
|
+
const placeholderText = computed(
|
|
59
|
+
() => props.column.placeholder ? getLocalizedText(props.column.placeholder, locale.value) : t("combobox-multi-placeholder")
|
|
60
|
+
);
|
|
61
|
+
function evalBool(expression, label) {
|
|
62
|
+
if (!expression) return false;
|
|
63
|
+
try {
|
|
64
|
+
return Effect.runSync($cel(expression, { row: row.value, index: rowIndex.value })) === true;
|
|
65
|
+
} catch (e) {
|
|
66
|
+
console.error(`[shwfed-table] combobox-multi ${label} failed`, e);
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const isHidden = computed(() => evalBool(props.column.hidden, "hidden"));
|
|
71
|
+
const isDisabled = computed(() => evalBool(props.column.disabled, "disabled"));
|
|
72
|
+
const isReadonly = computed(() => evalBool(props.column.readonly, "readonly"));
|
|
73
|
+
const effectiveReadonly = computed(
|
|
74
|
+
() => isReadonly.value || props.column.derived?.mode === "formula"
|
|
75
|
+
);
|
|
76
|
+
function safeInterpolate(tpl, context) {
|
|
77
|
+
try {
|
|
78
|
+
return interpolateMarkdown(tpl, $cel, context);
|
|
79
|
+
} catch (e) {
|
|
80
|
+
console.error("[shwfed-table] combobox-multi label interpolation failed", e);
|
|
81
|
+
return tpl;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const staticEntries = computed(() => {
|
|
85
|
+
if (props.column.options.kind !== "static") return [];
|
|
86
|
+
return props.column.options.items.map((item) => {
|
|
87
|
+
const labelTpl = getLocalizedText(item.label, locale.value) ?? "";
|
|
88
|
+
const tooltipTpl = item.tooltip ? getLocalizedText(item.tooltip, locale.value) : void 0;
|
|
89
|
+
return {
|
|
90
|
+
key: item.id,
|
|
91
|
+
value: item.value.value,
|
|
92
|
+
label: labelTpl ? safeInterpolate(labelTpl, {}) : "",
|
|
93
|
+
tooltip: tooltipTpl ? safeInterpolate(tooltipTpl, {}) : void 0
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
const remoteJson = ref(null);
|
|
98
|
+
const remoteLoading = ref(false);
|
|
99
|
+
let fetchSeq = 0;
|
|
100
|
+
const requestSignature = computed(() => {
|
|
101
|
+
if (props.column.options.kind !== "remote") return null;
|
|
102
|
+
const expr = props.column.options.request;
|
|
103
|
+
if (!expr) return null;
|
|
104
|
+
try {
|
|
105
|
+
const builder = Effect.runSync(
|
|
106
|
+
$cel(expr, { row: row.value, index: rowIndex.value })
|
|
107
|
+
);
|
|
108
|
+
return JSON.stringify(builder.describe());
|
|
109
|
+
} catch {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
async function fetchOptions() {
|
|
114
|
+
const seq = ++fetchSeq;
|
|
115
|
+
if (props.column.options.kind !== "remote" || requestSignature.value == null) {
|
|
116
|
+
remoteJson.value = null;
|
|
117
|
+
remoteLoading.value = false;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const expr = props.column.options.request;
|
|
121
|
+
remoteLoading.value = true;
|
|
122
|
+
const program = Effect.gen(function* () {
|
|
123
|
+
const builder = yield* $cel(expr, { row: row.value, index: rowIndex.value });
|
|
124
|
+
return yield* builder.json();
|
|
125
|
+
});
|
|
126
|
+
try {
|
|
127
|
+
const result = await Effect.runPromise(Effect.provide(program, sharedFetchLayer));
|
|
128
|
+
if (seq === fetchSeq) remoteJson.value = result;
|
|
129
|
+
} catch {
|
|
130
|
+
if (seq === fetchSeq) remoteJson.value = null;
|
|
131
|
+
} finally {
|
|
132
|
+
if (seq === fetchSeq) remoteLoading.value = false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
watchDebounced(
|
|
136
|
+
requestSignature,
|
|
137
|
+
() => {
|
|
138
|
+
void fetchOptions();
|
|
139
|
+
},
|
|
140
|
+
{ debounce: 200, immediate: true }
|
|
141
|
+
);
|
|
142
|
+
function valueOf(option) {
|
|
143
|
+
if (props.column.options.kind !== "remote") return void 0;
|
|
144
|
+
try {
|
|
145
|
+
return Effect.runSync($cel(props.column.options.optionValue, {
|
|
146
|
+
row: row.value,
|
|
147
|
+
index: rowIndex.value,
|
|
148
|
+
option
|
|
149
|
+
}));
|
|
150
|
+
} catch (e) {
|
|
151
|
+
console.error("[shwfed-table] combobox-multi optionValue failed", e);
|
|
152
|
+
return void 0;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function labelOf(option) {
|
|
156
|
+
if (props.column.options.kind !== "remote") return "";
|
|
157
|
+
const tpl = getLocalizedText(props.column.options.optionLabel, locale.value) ?? "";
|
|
158
|
+
if (!tpl) return "";
|
|
159
|
+
try {
|
|
160
|
+
return interpolateMarkdown(tpl, $cel, { row: row.value, index: rowIndex.value, option });
|
|
161
|
+
} catch (e) {
|
|
162
|
+
console.error("[shwfed-table] combobox-multi optionLabel failed", e);
|
|
163
|
+
return "";
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const remoteEntries = computed(() => {
|
|
167
|
+
if (props.column.options.kind !== "remote") return [];
|
|
168
|
+
let raw;
|
|
169
|
+
try {
|
|
170
|
+
raw = Effect.runSync($cel(props.column.options.options, {
|
|
171
|
+
row: row.value,
|
|
172
|
+
index: rowIndex.value,
|
|
173
|
+
json: remoteJson.value
|
|
174
|
+
}));
|
|
175
|
+
} catch (e) {
|
|
176
|
+
console.error("[shwfed-table] combobox-multi options failed", e);
|
|
177
|
+
return [];
|
|
178
|
+
}
|
|
179
|
+
if (!Array.isArray(raw)) return [];
|
|
180
|
+
return raw.map((option, idx) => ({
|
|
181
|
+
key: String(idx),
|
|
182
|
+
label: labelOf(option),
|
|
183
|
+
value: valueOf(option)
|
|
184
|
+
}));
|
|
185
|
+
});
|
|
186
|
+
const entries = computed(
|
|
187
|
+
() => props.column.options.kind === "static" ? staticEntries.value : remoteEntries.value
|
|
188
|
+
);
|
|
189
|
+
const isLoading = computed(() => props.column.options.kind === "remote" && remoteLoading.value);
|
|
190
|
+
const cellValue = computed(() => {
|
|
191
|
+
const raw = formState.getAt(props.column.binding);
|
|
192
|
+
return Array.isArray(raw) ? raw : [];
|
|
193
|
+
});
|
|
194
|
+
function isEqual(a, b) {
|
|
195
|
+
if (a === b) return true;
|
|
196
|
+
if (a == null || b == null) return false;
|
|
197
|
+
if (typeof a === "object" && typeof b === "object") {
|
|
198
|
+
try {
|
|
199
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
200
|
+
} catch {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
const selectedEntries = computed(() => {
|
|
207
|
+
const list = [];
|
|
208
|
+
for (const v of cellValue.value) {
|
|
209
|
+
const entry = entries.value.find((e) => isEqual(e.value, v));
|
|
210
|
+
if (entry) list.push(entry);
|
|
211
|
+
}
|
|
212
|
+
return list;
|
|
213
|
+
});
|
|
214
|
+
const selectedKeys = computed(() => selectedEntries.value.map((e) => e.key));
|
|
215
|
+
const selectedKeySet = computed(() => new Set(selectedKeys.value));
|
|
216
|
+
const triggerLabel = computed(() => {
|
|
217
|
+
const arr = selectedEntries.value;
|
|
218
|
+
if (arr.length === 0) return "";
|
|
219
|
+
if (arr.length === 1) return arr[0].label;
|
|
220
|
+
return `${arr[0].label} +${arr.length - 1}`;
|
|
221
|
+
});
|
|
222
|
+
const open = ref(false);
|
|
223
|
+
function handleSelect(next) {
|
|
224
|
+
const keys = Array.isArray(next) ? next.filter((k) => typeof k === "string") : [];
|
|
225
|
+
const mapped = [];
|
|
226
|
+
for (const key of keys) {
|
|
227
|
+
const entry = entries.value.find((e) => e.key === key);
|
|
228
|
+
if (entry) mapped.push(entry.value);
|
|
229
|
+
}
|
|
230
|
+
formState.setAt(props.column.binding, mapped);
|
|
231
|
+
}
|
|
232
|
+
const showClear = computed(
|
|
233
|
+
() => !isDisabled.value && selectedEntries.value.length > 0
|
|
234
|
+
);
|
|
235
|
+
function handleClear() {
|
|
236
|
+
formState.setAt(props.column.binding, []);
|
|
237
|
+
open.value = false;
|
|
238
|
+
}
|
|
239
|
+
const hoveredKey = ref(null);
|
|
240
|
+
watch(open, (isOpen) => {
|
|
241
|
+
hoveredKey.value = isOpen ? entries.value[0]?.key ?? null : null;
|
|
242
|
+
});
|
|
243
|
+
const hoveredEntry = computed(
|
|
244
|
+
() => entries.value.find((e) => e.key === hoveredKey.value)
|
|
245
|
+
);
|
|
246
|
+
const hoveredTooltip = computed(() => hoveredEntry.value?.tooltip);
|
|
247
|
+
const anyHasTooltip = computed(
|
|
248
|
+
() => entries.value.some((e) => e.tooltip != null && e.tooltip.length > 0)
|
|
249
|
+
);
|
|
250
|
+
</script>
|
|
251
|
+
|
|
252
|
+
<template>
|
|
253
|
+
<div class="p-[0.125rem] w-full">
|
|
254
|
+
<span
|
|
255
|
+
v-if="isHidden"
|
|
256
|
+
class="block h-7 w-full"
|
|
257
|
+
/>
|
|
258
|
+
<span
|
|
259
|
+
v-else-if="effectiveReadonly"
|
|
260
|
+
class="flex items-center h-7 w-full px-2 text-[0.75rem] text-zinc-700 truncate"
|
|
261
|
+
>
|
|
262
|
+
{{ triggerLabel || "\u2014" }}
|
|
263
|
+
</span>
|
|
264
|
+
<Popover
|
|
265
|
+
v-else
|
|
266
|
+
v-model:open="open"
|
|
267
|
+
>
|
|
268
|
+
<PopoverAnchor as-child>
|
|
269
|
+
<InputGroup
|
|
270
|
+
class="group/combobox-multi h-7 rounded border-zinc-200/30 hover:border-zinc-200 focus-within:border-zinc-200 transition-colors ease-out duration-180"
|
|
271
|
+
:data-disabled="isDisabled ? 'true' : void 0"
|
|
272
|
+
>
|
|
273
|
+
<PopoverTrigger as-child>
|
|
274
|
+
<InputGroupInput
|
|
275
|
+
:model-value="triggerLabel"
|
|
276
|
+
:disabled="isDisabled"
|
|
277
|
+
:placeholder="placeholderText"
|
|
278
|
+
class="h-7 text-[0.75rem] md:text-[0.75rem] px-2 cursor-pointer text-left"
|
|
279
|
+
readonly
|
|
280
|
+
/>
|
|
281
|
+
</PopoverTrigger>
|
|
282
|
+
<InputGroupAddon
|
|
283
|
+
v-if="isLoading"
|
|
284
|
+
align="inline-end"
|
|
285
|
+
class="text-zinc-400"
|
|
286
|
+
>
|
|
287
|
+
<Icon
|
|
288
|
+
icon="fluent:spinner-ios-20-regular"
|
|
289
|
+
class="size-3 animate-spin"
|
|
290
|
+
/>
|
|
291
|
+
</InputGroupAddon>
|
|
292
|
+
<InputGroupAddon
|
|
293
|
+
v-else-if="showClear"
|
|
294
|
+
align="inline-end"
|
|
295
|
+
class="[@media(hover:hover)]:opacity-0 transition-opacity group-hover/combobox-multi:opacity-100 focus-within:opacity-100"
|
|
296
|
+
>
|
|
297
|
+
<InputGroupButton
|
|
298
|
+
size="icon-xs"
|
|
299
|
+
data-slot="combobox-multi-clear"
|
|
300
|
+
class="size-4 text-zinc-500 hover:text-zinc-700"
|
|
301
|
+
tabindex="-1"
|
|
302
|
+
@mousedown.prevent
|
|
303
|
+
@click.stop="handleClear"
|
|
304
|
+
>
|
|
305
|
+
<Icon
|
|
306
|
+
icon="fluent:dismiss-20-regular"
|
|
307
|
+
class="size-3"
|
|
308
|
+
/>
|
|
309
|
+
</InputGroupButton>
|
|
310
|
+
</InputGroupAddon>
|
|
311
|
+
</InputGroup>
|
|
312
|
+
</PopoverAnchor>
|
|
313
|
+
<PopoverContent
|
|
314
|
+
class="w-auto p-0 [&_[data-slot=command-input-wrapper]]:h-7 [&_[data-slot=command-input-wrapper]]:px-2 [&_[data-slot=command-input-wrapper]_svg]:size-3 [&_[data-slot=command-input]]:h-7 [&_[data-slot=command-input]]:py-0 [&_[data-slot=command-input]]:text-[0.75rem] [&_[data-slot=command-item]]:px-2 [&_[data-slot=command-item]]:py-1 [&_[data-slot=command-item]]:text-[0.75rem]"
|
|
315
|
+
:style="{ width: 'var(--reka-popover-trigger-width)' }"
|
|
316
|
+
>
|
|
317
|
+
<Command
|
|
318
|
+
:model-value="selectedKeys"
|
|
319
|
+
:multiple="true"
|
|
320
|
+
:disabled="isDisabled"
|
|
321
|
+
@update:model-value="handleSelect"
|
|
322
|
+
>
|
|
323
|
+
<CommandInput :placeholder="t('combobox-multi-search-placeholder')" />
|
|
324
|
+
<CommandList>
|
|
325
|
+
<div
|
|
326
|
+
v-if="entries.length === 0"
|
|
327
|
+
data-slot="combobox-multi-empty"
|
|
328
|
+
class="py-3 text-center text-[0.75rem] text-zinc-500"
|
|
329
|
+
>
|
|
330
|
+
{{ isLoading ? t("combobox-multi-loading") : t("combobox-multi-empty") }}
|
|
331
|
+
</div>
|
|
332
|
+
<template v-else>
|
|
333
|
+
<CommandEmpty class="py-3 text-center text-[0.75rem] text-zinc-500">
|
|
334
|
+
{{ t("combobox-multi-empty") }}
|
|
335
|
+
</CommandEmpty>
|
|
336
|
+
<CommandGroup>
|
|
337
|
+
<CommandItem
|
|
338
|
+
v-for="entry in entries"
|
|
339
|
+
:key="entry.key"
|
|
340
|
+
:value="entry.key"
|
|
341
|
+
@mouseenter="hoveredKey = entry.key"
|
|
342
|
+
@focus="hoveredKey = entry.key"
|
|
343
|
+
>
|
|
344
|
+
<span class="flex-1"><Markdown :source="entry.label" /></span>
|
|
345
|
+
<Icon
|
|
346
|
+
v-if="selectedKeySet.has(entry.key)"
|
|
347
|
+
icon="fluent:checkmark-20-regular"
|
|
348
|
+
class="size-3 text-zinc-700"
|
|
349
|
+
/>
|
|
350
|
+
</CommandItem>
|
|
351
|
+
</CommandGroup>
|
|
352
|
+
</template>
|
|
353
|
+
</CommandList>
|
|
354
|
+
<div
|
|
355
|
+
v-if="anyHasTooltip && hoveredTooltip"
|
|
356
|
+
class="border-t border-zinc-200 px-2 py-1.5"
|
|
357
|
+
>
|
|
358
|
+
<Markdown
|
|
359
|
+
:source="hoveredTooltip"
|
|
360
|
+
block
|
|
361
|
+
class="prose prose-xs prose-zinc"
|
|
362
|
+
/>
|
|
363
|
+
</div>
|
|
364
|
+
</Command>
|
|
365
|
+
</PopoverContent>
|
|
366
|
+
</Popover>
|
|
367
|
+
</div>
|
|
368
|
+
</template>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CellContext } from '@tanstack/vue-table';
|
|
2
|
+
import type { Value } from './schema.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
column: Value;
|
|
5
|
+
ctx: CellContext<unknown, unknown>;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|