@shwfed/config 2.3.24 → 2.3.26
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 +1059 -634
- package/dist/module.json +1 -1
- package/dist/preview/assets/{config-CWZxlCMJ.js → config-BATy87wV.js} +1 -1
- package/dist/preview/assets/{config-Bi9uFh4Y.js → config-BkimX91E.js} +1 -1
- package/dist/preview/assets/{config-CBHKrOP5.js → config-CO2iovZD.js} +1 -1
- package/dist/preview/assets/{config-DYAEfkYR.js → config-Cm9t0CvW.js} +1 -1
- package/dist/preview/assets/{config-B-6Htwv0.js → config-DPFHMkHc.js} +1 -1
- package/dist/preview/assets/{config-B2KjxFl5.js → config-DgZ4NYoA.js} +1 -1
- package/dist/preview/assets/{config-D5Kfssb7.js → config-Dzqe6v-x.js} +1 -1
- package/dist/preview/assets/{config-B3at5Bue.js → config-u1rl9w2L.js} +1 -1
- package/dist/preview/assets/{config-CaZpOvHG.js → config-ypYLVfRE.js} +1 -1
- package/dist/preview/assets/{definition.vue_vue_type_script_setup_true_lang-8BVrrrak.js → definition.vue_vue_type_script_setup_true_lang-CliXxe84.js} +1 -1
- package/dist/preview/assets/index-6rM4rqXR.js +1 -0
- package/dist/preview/assets/{index-CJMxrUKZ.css → index-BCE-G4Ha.css} +1 -1
- package/dist/preview/assets/index-wBVA0mNO.js +643 -0
- package/dist/preview/assets/{runtime-CoRrnGx1.js → runtime-BR6-W3u_.js} +1 -1
- package/dist/preview/assets/{runtime-CEP42oTV.js → runtime-BTROwcw4.js} +1 -1
- package/dist/preview/assets/{runtime-CRHn61GX.js → runtime-B_FMZ5eD.js} +1 -1
- package/dist/preview/assets/{runtime-C1iENPNJ.js → runtime-CTpsTb-X.js} +1 -1
- package/dist/preview/assets/{runtime-Hvzx1ucy.js → runtime-Cj0kLSqP.js} +1 -1
- package/dist/preview/assets/{runtime-C5CCMnHt.js → runtime-D1xLbTQ9.js} +1 -1
- package/dist/preview/assets/{runtime-jrsJfwMb.js → runtime-Dsx8Y56q.js} +1 -1
- package/dist/preview/assets/{runtime-CqciI2ST.js → runtime-Dtc1ETUF.js} +1 -1
- package/dist/preview/assets/{runtime-aBsBSCeg.js → runtime-T_tUqLxO.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 +2 -2
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-remote/config.vue.d.ts +2 -2
- package/dist/runtime/components/table/columns/2026-05-25/com.shwfed.table.column.combobox-multi/runtime.vue +1 -0
- package/dist/runtime/components/table/columns/2026-05-25/com.shwfed.table.column.combobox-multi.remote.options-remote/config.d.vue.ts +2 -2
- package/dist/runtime/components/table/columns/2026-05-25/com.shwfed.table.column.combobox-multi.remote.options-remote/config.vue.d.ts +2 -2
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi/config.d.vue.ts +26 -26
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi/config.vue +4 -14
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi/config.vue.d.ts +26 -26
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi/schema.d.ts +27 -1
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi/schema.js +14 -11
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi.remote/config.d.vue.ts +26 -26
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi.remote/config.vue +4 -12
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi.remote/config.vue.d.ts +26 -26
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi.remote/runtime.vue +45 -12
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi.remote/schema.d.ts +27 -1
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi.remote/schema.js +14 -11
- 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-B3wadvvl.js +0 -1
- package/dist/preview/assets/index-DTsYYECD.js +0 -643
|
@@ -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-single";
|
|
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-single";
|
|
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,349 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { Icon } from "@iconify/vue";
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
import { watchDebounced } from "@vueuse/core";
|
|
5
|
+
import { computed, nextTick, 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: "ShwfedTableComboboxSingleRendererRuntime" });
|
|
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-single-placeholder": "\u8BF7\u9009\u62E9",
|
|
34
|
+
"combobox-single-search-placeholder": "\u641C\u7D22\u2026",
|
|
35
|
+
"combobox-single-empty": "\u65E0\u5339\u914D\u9879",
|
|
36
|
+
"combobox-single-loading": "\u52A0\u8F7D\u4E2D\u2026"
|
|
37
|
+
},
|
|
38
|
+
en: {
|
|
39
|
+
"combobox-single-placeholder": "Select\u2026",
|
|
40
|
+
"combobox-single-search-placeholder": "Search\u2026",
|
|
41
|
+
"combobox-single-empty": "No matches",
|
|
42
|
+
"combobox-single-loading": "Loading\u2026"
|
|
43
|
+
},
|
|
44
|
+
ja: {
|
|
45
|
+
"combobox-single-placeholder": "\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
46
|
+
"combobox-single-search-placeholder": "\u691C\u7D22\u2026",
|
|
47
|
+
"combobox-single-empty": "\u4E00\u81F4\u306A\u3057",
|
|
48
|
+
"combobox-single-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-single-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-single ${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-single 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-single 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-single 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-single 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(() => formState.getAt(props.column.binding));
|
|
191
|
+
function isEqual(a, b) {
|
|
192
|
+
if (a === b) return true;
|
|
193
|
+
if (a == null || b == null) return false;
|
|
194
|
+
if (typeof a === "object" && typeof b === "object") {
|
|
195
|
+
try {
|
|
196
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
197
|
+
} catch {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
const selectedEntry = computed(
|
|
204
|
+
() => entries.value.find((entry) => isEqual(entry.value, cellValue.value))
|
|
205
|
+
);
|
|
206
|
+
const selectedKey = computed(() => selectedEntry.value?.key);
|
|
207
|
+
const selectedLabel = computed(() => selectedEntry.value?.label ?? "");
|
|
208
|
+
const open = ref(false);
|
|
209
|
+
function handleSelect(key) {
|
|
210
|
+
if (typeof key !== "string") return;
|
|
211
|
+
const entry = entries.value.find((e) => e.key === key);
|
|
212
|
+
if (!entry) return;
|
|
213
|
+
formState.setAt(props.column.binding, entry.value);
|
|
214
|
+
void nextTick().then(() => {
|
|
215
|
+
open.value = false;
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
const showClear = computed(
|
|
219
|
+
() => !isDisabled.value && selectedEntry.value !== void 0
|
|
220
|
+
);
|
|
221
|
+
function handleClear() {
|
|
222
|
+
formState.setAt(props.column.binding, null);
|
|
223
|
+
open.value = false;
|
|
224
|
+
}
|
|
225
|
+
const hoveredKey = ref(null);
|
|
226
|
+
watch(open, (isOpen) => {
|
|
227
|
+
hoveredKey.value = isOpen ? entries.value[0]?.key ?? null : null;
|
|
228
|
+
});
|
|
229
|
+
const hoveredEntry = computed(
|
|
230
|
+
() => entries.value.find((e) => e.key === hoveredKey.value)
|
|
231
|
+
);
|
|
232
|
+
const hoveredTooltip = computed(() => hoveredEntry.value?.tooltip);
|
|
233
|
+
const anyHasTooltip = computed(
|
|
234
|
+
() => entries.value.some((e) => e.tooltip != null && e.tooltip.length > 0)
|
|
235
|
+
);
|
|
236
|
+
</script>
|
|
237
|
+
|
|
238
|
+
<template>
|
|
239
|
+
<div class="p-[0.125rem] w-full">
|
|
240
|
+
<span
|
|
241
|
+
v-if="isHidden"
|
|
242
|
+
class="block h-7 w-full"
|
|
243
|
+
/>
|
|
244
|
+
<span
|
|
245
|
+
v-else-if="effectiveReadonly"
|
|
246
|
+
class="flex items-center h-7 w-full px-2 text-[0.75rem] text-zinc-700 truncate"
|
|
247
|
+
>
|
|
248
|
+
{{ selectedLabel || "\u2014" }}
|
|
249
|
+
</span>
|
|
250
|
+
<Popover
|
|
251
|
+
v-else
|
|
252
|
+
v-model:open="open"
|
|
253
|
+
>
|
|
254
|
+
<PopoverAnchor as-child>
|
|
255
|
+
<InputGroup
|
|
256
|
+
class="group/combobox-single h-7 rounded border-zinc-200/30 hover:border-zinc-200 focus-within:border-zinc-200 transition-colors ease-out duration-180"
|
|
257
|
+
:data-disabled="isDisabled ? 'true' : void 0"
|
|
258
|
+
>
|
|
259
|
+
<PopoverTrigger as-child>
|
|
260
|
+
<InputGroupInput
|
|
261
|
+
:model-value="selectedLabel"
|
|
262
|
+
:disabled="isDisabled"
|
|
263
|
+
:placeholder="placeholderText"
|
|
264
|
+
class="h-7 text-[0.75rem] md:text-[0.75rem] px-2 cursor-pointer text-left"
|
|
265
|
+
readonly
|
|
266
|
+
/>
|
|
267
|
+
</PopoverTrigger>
|
|
268
|
+
<InputGroupAddon
|
|
269
|
+
v-if="isLoading"
|
|
270
|
+
align="inline-end"
|
|
271
|
+
class="text-zinc-400"
|
|
272
|
+
>
|
|
273
|
+
<Icon
|
|
274
|
+
icon="fluent:spinner-ios-20-regular"
|
|
275
|
+
class="size-3 animate-spin"
|
|
276
|
+
/>
|
|
277
|
+
</InputGroupAddon>
|
|
278
|
+
<InputGroupAddon
|
|
279
|
+
v-else-if="showClear"
|
|
280
|
+
align="inline-end"
|
|
281
|
+
class="[@media(hover:hover)]:opacity-0 transition-opacity group-hover/combobox-single:opacity-100 focus-within:opacity-100"
|
|
282
|
+
>
|
|
283
|
+
<InputGroupButton
|
|
284
|
+
size="icon-xs"
|
|
285
|
+
data-slot="combobox-single-clear"
|
|
286
|
+
class="size-4 text-zinc-500 hover:text-zinc-700"
|
|
287
|
+
tabindex="-1"
|
|
288
|
+
@mousedown.prevent
|
|
289
|
+
@click.stop="handleClear"
|
|
290
|
+
>
|
|
291
|
+
<Icon
|
|
292
|
+
icon="fluent:dismiss-20-regular"
|
|
293
|
+
class="size-3"
|
|
294
|
+
/>
|
|
295
|
+
</InputGroupButton>
|
|
296
|
+
</InputGroupAddon>
|
|
297
|
+
</InputGroup>
|
|
298
|
+
</PopoverAnchor>
|
|
299
|
+
<PopoverContent
|
|
300
|
+
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]"
|
|
301
|
+
:style="{ width: 'var(--reka-popover-trigger-width)' }"
|
|
302
|
+
>
|
|
303
|
+
<Command
|
|
304
|
+
:model-value="selectedKey"
|
|
305
|
+
:disabled="isDisabled"
|
|
306
|
+
selection-behavior="toggle"
|
|
307
|
+
@update:model-value="handleSelect"
|
|
308
|
+
>
|
|
309
|
+
<CommandInput :placeholder="t('combobox-single-search-placeholder')" />
|
|
310
|
+
<CommandList>
|
|
311
|
+
<div
|
|
312
|
+
v-if="entries.length === 0"
|
|
313
|
+
data-slot="combobox-single-empty"
|
|
314
|
+
class="py-3 text-center text-[0.75rem] text-zinc-500"
|
|
315
|
+
>
|
|
316
|
+
{{ isLoading ? t("combobox-single-loading") : t("combobox-single-empty") }}
|
|
317
|
+
</div>
|
|
318
|
+
<template v-else>
|
|
319
|
+
<CommandEmpty class="py-3 text-center text-[0.75rem] text-zinc-500">
|
|
320
|
+
{{ t("combobox-single-empty") }}
|
|
321
|
+
</CommandEmpty>
|
|
322
|
+
<CommandGroup>
|
|
323
|
+
<CommandItem
|
|
324
|
+
v-for="entry in entries"
|
|
325
|
+
:key="entry.key"
|
|
326
|
+
:value="entry.key"
|
|
327
|
+
@mouseenter="hoveredKey = entry.key"
|
|
328
|
+
@focus="hoveredKey = entry.key"
|
|
329
|
+
>
|
|
330
|
+
<span class="flex-1"><Markdown :source="entry.label" /></span>
|
|
331
|
+
</CommandItem>
|
|
332
|
+
</CommandGroup>
|
|
333
|
+
</template>
|
|
334
|
+
</CommandList>
|
|
335
|
+
<div
|
|
336
|
+
v-if="anyHasTooltip && hoveredTooltip"
|
|
337
|
+
class="border-t border-zinc-200 px-2 py-1.5"
|
|
338
|
+
>
|
|
339
|
+
<Markdown
|
|
340
|
+
:source="hoveredTooltip"
|
|
341
|
+
block
|
|
342
|
+
class="prose prose-xs prose-zinc"
|
|
343
|
+
/>
|
|
344
|
+
</div>
|
|
345
|
+
</Command>
|
|
346
|
+
</PopoverContent>
|
|
347
|
+
</Popover>
|
|
348
|
+
</div>
|
|
349
|
+
</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;
|