@shwfed/config 2.3.18 → 2.3.20
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 +964 -587
- package/dist/module.json +1 -1
- package/dist/preview/assets/{config-C8Y4mJbo.js → config-BvTObql_.js} +1 -1
- package/dist/preview/assets/{config-CGjY6-4G.js → config-BxK2md1E.js} +1 -1
- package/dist/preview/assets/config-C1OAS71Y.js +1 -0
- package/dist/preview/assets/{config-D9mrL0UY.js → config-DRcqCBNE.js} +1 -1
- package/dist/preview/assets/{config-CR-ypZys.js → config-DWBLNB9W.js} +1 -1
- package/dist/preview/assets/{config-Cs3k3BuR.js → config-DYoY63Mh.js} +1 -1
- package/dist/preview/assets/{config-DRy0SpMq.js → config-DqfJ6g2l.js} +1 -1
- package/dist/preview/assets/{config-qmkDiyXK.js → config-DzmdQg_R.js} +1 -1
- package/dist/preview/assets/{config-eopfzGON.js → config-RpiYusco.js} +1 -1
- package/dist/preview/assets/{definition.vue_vue_type_script_setup_true_lang-BakGkJ_w.js → definition.vue_vue_type_script_setup_true_lang-C1rBrqyI.js} +1 -1
- package/dist/preview/assets/index--tX2oFUp.js +643 -0
- package/dist/preview/assets/index-De3_lDfy.js +1 -0
- package/dist/preview/assets/{index-BUyz4nJb.css → index-DomLsyPH.css} +1 -1
- package/dist/preview/assets/runtime-BkoWPDvV.js +1 -0
- package/dist/preview/assets/{runtime-C2q2Mp8_.js → runtime-Cr5yIEMV.js} +1 -1
- package/dist/preview/assets/{runtime-DQcKN5I_.js → runtime-DOg6e_3A.js} +1 -1
- package/dist/preview/assets/runtime-DTh936s0.js +1 -0
- package/dist/preview/assets/{runtime-BvJjQaAU.js → runtime-Hiqp76SC.js} +1 -1
- package/dist/preview/assets/runtime-_Z4Jlev8.js +1 -0
- package/dist/preview/assets/runtime-_bbVL50J.js +1 -0
- package/dist/preview/assets/{runtime-B1Lqn7iS.js → runtime-euPIe4uC.js} +1 -1
- package/dist/preview/assets/runtime-m4H1rd-d.js +1 -0
- package/dist/preview/index.html +2 -2
- package/dist/runtime/components/actions/buttons/2026-05-24/com.shwfed.actions.button.state.write/config.d.vue.ts +27 -0
- package/dist/runtime/components/actions/buttons/2026-05-24/com.shwfed.actions.button.state.write/config.vue +68 -0
- package/dist/runtime/components/actions/buttons/2026-05-24/com.shwfed.actions.button.state.write/config.vue.d.ts +27 -0
- package/dist/runtime/components/actions/buttons/2026-05-24/com.shwfed.actions.button.state.write/runtime.d.vue.ts +8 -0
- package/dist/runtime/components/actions/buttons/2026-05-24/com.shwfed.actions.button.state.write/runtime.vue +53 -0
- package/dist/runtime/components/actions/buttons/2026-05-24/com.shwfed.actions.button.state.write/runtime.vue.d.ts +8 -0
- package/dist/runtime/components/actions/buttons/2026-05-24/com.shwfed.actions.button.state.write/schema.d.ts +18 -0
- package/dist/runtime/components/actions/buttons/2026-05-24/com.shwfed.actions.button.state.write/schema.js +35 -0
- package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/row.vue +1 -1
- package/dist/runtime/components/form/utils/state.d.ts +25 -1
- package/dist/runtime/components/form/utils/state.js +4 -1
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-remote/config.d.vue.ts +109 -0
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-remote/config.vue +426 -0
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-remote/config.vue.d.ts +109 -0
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-remote/runtime.d.vue.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-remote/runtime.vue +337 -0
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-remote/runtime.vue.d.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-remote/schema.d.ts +85 -0
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-remote/schema.js +146 -0
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-static/config.d.vue.ts +137 -0
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-static/config.vue +586 -0
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-static/config.vue.d.ts +137 -0
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-static/runtime.d.vue.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-static/runtime.vue +268 -0
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-static/runtime.vue.d.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-static/schema.d.ts +126 -0
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-static/schema.js +124 -0
- package/dist/runtime/components/table/config.vue +3 -0
- package/dist/runtime/components/table/index.vue +2 -0
- package/dist/runtime/components/table/row-provider.vue +1 -1
- package/dist/runtime/components/table/utils/shared-fetch.d.ts +30 -0
- package/dist/runtime/components/table/utils/shared-fetch.js +42 -0
- package/dist/runtime/components/ui/calendar/Calendar.vue +9 -4
- package/dist/runtime/components/ui/date-range-picker/DateRangePickerMonthPanel.vue +4 -1
- package/dist/runtime/components/ui/date-range-picker/DateRangePickerYearPanel.vue +4 -1
- package/dist/runtime/components/ui/range-calendar/RangeCalendar.vue +3 -1
- package/package.json +1 -1
- package/dist/preview/assets/index-Bsbk3Okp.js +0 -1
- package/dist/preview/assets/index-Dz_SnGc9.js +0 -639
- package/dist/preview/assets/runtime-C-3DIGFz.js +0 -1
- package/dist/preview/assets/runtime-CdELhC3y.js +0 -1
- package/dist/preview/assets/runtime-D8OAMic8.js +0 -1
- package/dist/preview/assets/runtime-DQvlwOZl.js +0 -1
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { Icon } from "@iconify/vue";
|
|
3
|
+
import { watchDebounced } from "@vueuse/core";
|
|
4
|
+
import { Effect } from "effect";
|
|
5
|
+
import { Fetch } from "fx-fetch";
|
|
6
|
+
import { toast } from "vue-sonner";
|
|
7
|
+
import { computed, nextTick, ref, watch } from "vue";
|
|
8
|
+
import { useI18n } from "vue-i18n";
|
|
9
|
+
import { cel as _rawCel } from "../../../../../utils/cel";
|
|
10
|
+
import { celBindings, injectCELContext } from "../../../../../utils/cel-context";
|
|
11
|
+
import { getLocalizedText } from "../../../../../share/locale";
|
|
12
|
+
import { dispatchTriggers, useEventChannel } from "../../../../../share/event-bus";
|
|
13
|
+
import {
|
|
14
|
+
Command,
|
|
15
|
+
CommandEmpty,
|
|
16
|
+
CommandGroup,
|
|
17
|
+
CommandInput,
|
|
18
|
+
CommandItem,
|
|
19
|
+
CommandList
|
|
20
|
+
} from "../../../../ui/command";
|
|
21
|
+
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "../../../../ui/input-group";
|
|
22
|
+
import { Markdown } from "../../../../ui/markdown";
|
|
23
|
+
import { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from "../../../../ui/popover";
|
|
24
|
+
import { interpolateMarkdown } from "../../../utils/runtime";
|
|
25
|
+
import { useSharedFetchLayer } from "../../../utils/shared-fetch";
|
|
26
|
+
defineOptions({ name: "ShwfedTableComboboxSingleRemoteOptionsRemoteRuntime" });
|
|
27
|
+
const props = defineProps({
|
|
28
|
+
column: { type: null, required: true },
|
|
29
|
+
ctx: { type: Object, required: true }
|
|
30
|
+
});
|
|
31
|
+
const { locale, t } = useI18n({
|
|
32
|
+
inheritLocale: true,
|
|
33
|
+
messages: {
|
|
34
|
+
zh: {
|
|
35
|
+
"combobox-single-placeholder": "\u8BF7\u9009\u62E9",
|
|
36
|
+
"combobox-single-search-placeholder": "\u641C\u7D22\u2026",
|
|
37
|
+
"combobox-single-empty": "\u65E0\u5339\u914D\u9879",
|
|
38
|
+
"combobox-single-loading": "\u52A0\u8F7D\u4E2D\u2026"
|
|
39
|
+
},
|
|
40
|
+
en: {
|
|
41
|
+
"combobox-single-placeholder": "Select\u2026",
|
|
42
|
+
"combobox-single-search-placeholder": "Search\u2026",
|
|
43
|
+
"combobox-single-empty": "No matches",
|
|
44
|
+
"combobox-single-loading": "Loading\u2026"
|
|
45
|
+
},
|
|
46
|
+
ja: {
|
|
47
|
+
"combobox-single-placeholder": "\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
48
|
+
"combobox-single-search-placeholder": "\u691C\u7D22\u2026",
|
|
49
|
+
"combobox-single-empty": "\u4E00\u81F4\u306A\u3057",
|
|
50
|
+
"combobox-single-loading": "\u8AAD\u307F\u8FBC\u307F\u4E2D\u2026"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const inherited = injectCELContext();
|
|
55
|
+
const $cel = (expression, context) => _rawCel(expression, { ...celBindings(inherited), ...context });
|
|
56
|
+
const eventChannel = useEventChannel();
|
|
57
|
+
const sharedFetchLayer = useSharedFetchLayer();
|
|
58
|
+
const row = computed(() => props.ctx.row.original);
|
|
59
|
+
const rowIndex = computed(() => props.ctx.row.index);
|
|
60
|
+
const placeholderText = computed(
|
|
61
|
+
() => props.column.placeholder ? getLocalizedText(props.column.placeholder, locale.value) : t("combobox-single-placeholder")
|
|
62
|
+
);
|
|
63
|
+
function evalBool(expression, label) {
|
|
64
|
+
if (!expression) return false;
|
|
65
|
+
try {
|
|
66
|
+
return Effect.runSync($cel(expression, { row: row.value, index: rowIndex.value })) === true;
|
|
67
|
+
} catch (e) {
|
|
68
|
+
console.error(`[shwfed-table] combobox-single.remote.options-remote ${label} failed`, e);
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const isHidden = computed(() => evalBool(props.column.hidden, "hidden"));
|
|
73
|
+
const isDisabledByConfig = computed(() => evalBool(props.column.disabled, "disabled"));
|
|
74
|
+
const isReadonly = computed(() => evalBool(props.column.readonly, "readonly"));
|
|
75
|
+
const isInteractive = computed(() => !!props.column.onChange);
|
|
76
|
+
const pending = ref(false);
|
|
77
|
+
const json = ref(null);
|
|
78
|
+
const isLoading = ref(false);
|
|
79
|
+
const requestSignature = computed(() => {
|
|
80
|
+
const expr = props.column.request;
|
|
81
|
+
if (!expr) return null;
|
|
82
|
+
try {
|
|
83
|
+
const builder = Effect.runSync(
|
|
84
|
+
$cel(expr, { row: row.value, index: rowIndex.value })
|
|
85
|
+
);
|
|
86
|
+
return JSON.stringify(builder.describe());
|
|
87
|
+
} catch {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
let fetchSeq = 0;
|
|
92
|
+
async function fetchOptions() {
|
|
93
|
+
const seq = ++fetchSeq;
|
|
94
|
+
if (requestSignature.value == null) {
|
|
95
|
+
json.value = null;
|
|
96
|
+
isLoading.value = false;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const expr = props.column.request;
|
|
100
|
+
isLoading.value = true;
|
|
101
|
+
const program = Effect.gen(function* () {
|
|
102
|
+
const builder = yield* $cel(expr, { row: row.value, index: rowIndex.value });
|
|
103
|
+
return yield* builder.json();
|
|
104
|
+
});
|
|
105
|
+
try {
|
|
106
|
+
const result = await Effect.runPromise(Effect.provide(program, sharedFetchLayer));
|
|
107
|
+
if (seq === fetchSeq) json.value = result;
|
|
108
|
+
} catch {
|
|
109
|
+
if (seq === fetchSeq) json.value = null;
|
|
110
|
+
} finally {
|
|
111
|
+
if (seq === fetchSeq) isLoading.value = false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
watchDebounced(
|
|
115
|
+
requestSignature,
|
|
116
|
+
() => {
|
|
117
|
+
void fetchOptions();
|
|
118
|
+
},
|
|
119
|
+
{ debounce: 200, immediate: true }
|
|
120
|
+
);
|
|
121
|
+
function valueOf(option) {
|
|
122
|
+
try {
|
|
123
|
+
return Effect.runSync($cel(props.column.optionValue, {
|
|
124
|
+
row: row.value,
|
|
125
|
+
index: rowIndex.value,
|
|
126
|
+
option
|
|
127
|
+
}));
|
|
128
|
+
} catch (e) {
|
|
129
|
+
console.error("[shwfed-table] combobox-single.remote.options-remote optionValue failed", e);
|
|
130
|
+
return void 0;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function labelOf(option) {
|
|
134
|
+
const tpl = getLocalizedText(props.column.optionLabel, locale.value) ?? "";
|
|
135
|
+
if (!tpl) return "";
|
|
136
|
+
try {
|
|
137
|
+
return interpolateMarkdown(tpl, $cel, { row: row.value, index: rowIndex.value, option });
|
|
138
|
+
} catch (e) {
|
|
139
|
+
console.error("[shwfed-table] combobox-single.remote.options-remote optionLabel failed", e);
|
|
140
|
+
return "";
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const entries = computed(() => {
|
|
144
|
+
let raw;
|
|
145
|
+
try {
|
|
146
|
+
raw = Effect.runSync($cel(props.column.options, {
|
|
147
|
+
row: row.value,
|
|
148
|
+
index: rowIndex.value,
|
|
149
|
+
json: json.value
|
|
150
|
+
}));
|
|
151
|
+
} catch (e) {
|
|
152
|
+
console.error("[shwfed-table] combobox-single.remote.options-remote options failed", e);
|
|
153
|
+
return [];
|
|
154
|
+
}
|
|
155
|
+
if (!Array.isArray(raw)) return [];
|
|
156
|
+
return raw.map((option, idx) => ({
|
|
157
|
+
key: String(idx),
|
|
158
|
+
label: labelOf(option),
|
|
159
|
+
value: valueOf(option)
|
|
160
|
+
}));
|
|
161
|
+
});
|
|
162
|
+
const cellValue = computed(() => props.ctx.cell.getValue());
|
|
163
|
+
function isEqual(a, b) {
|
|
164
|
+
if (a === b) return true;
|
|
165
|
+
if (a == null || b == null) return false;
|
|
166
|
+
if (typeof a === "object" && typeof b === "object") {
|
|
167
|
+
try {
|
|
168
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
169
|
+
} catch {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
const selectedEntry = computed(
|
|
176
|
+
() => entries.value.find((entry) => isEqual(entry.value, cellValue.value))
|
|
177
|
+
);
|
|
178
|
+
const selectedKey = computed(() => selectedEntry.value?.key);
|
|
179
|
+
const selectedLabel = computed(() => selectedEntry.value?.label ?? "");
|
|
180
|
+
const open = ref(false);
|
|
181
|
+
const isDisabled = computed(
|
|
182
|
+
() => !isInteractive.value || isDisabledByConfig.value || pending.value
|
|
183
|
+
);
|
|
184
|
+
async function submit(next) {
|
|
185
|
+
const { onChange, successMessage } = props.column;
|
|
186
|
+
if (!onChange) return;
|
|
187
|
+
pending.value = true;
|
|
188
|
+
const program = Effect.gen(function* () {
|
|
189
|
+
const builder = yield* $cel(onChange, {
|
|
190
|
+
row: row.value,
|
|
191
|
+
index: rowIndex.value,
|
|
192
|
+
value: next
|
|
193
|
+
});
|
|
194
|
+
return yield* builder.json();
|
|
195
|
+
});
|
|
196
|
+
try {
|
|
197
|
+
const body = await Effect.runPromise(Effect.provide(program, Fetch.layer));
|
|
198
|
+
if (successMessage) {
|
|
199
|
+
try {
|
|
200
|
+
const message = Effect.runSync($cel(successMessage, { json: body }));
|
|
201
|
+
if (message) toast.success(message);
|
|
202
|
+
} catch (e) {
|
|
203
|
+
console.error("[shwfed-table] combobox-single.remote.options-remote successMessage failed", e);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
await Effect.runPromise(dispatchTriggers(eventChannel, props.column.triggers));
|
|
207
|
+
} catch (e) {
|
|
208
|
+
console.error("[shwfed-table] combobox-single.remote.options-remote onChange failed", e);
|
|
209
|
+
toast.error("\u8BF7\u6C42\u5931\u8D25");
|
|
210
|
+
} finally {
|
|
211
|
+
pending.value = false;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function handleSelect(key) {
|
|
215
|
+
if (typeof key !== "string") return;
|
|
216
|
+
const entry = entries.value.find((e) => e.key === key);
|
|
217
|
+
if (!entry) return;
|
|
218
|
+
void nextTick().then(() => {
|
|
219
|
+
open.value = false;
|
|
220
|
+
});
|
|
221
|
+
void submit(entry.value);
|
|
222
|
+
}
|
|
223
|
+
const showClear = computed(
|
|
224
|
+
() => !isDisabled.value && selectedEntry.value !== void 0
|
|
225
|
+
);
|
|
226
|
+
function handleClear() {
|
|
227
|
+
open.value = false;
|
|
228
|
+
void submit(null);
|
|
229
|
+
}
|
|
230
|
+
const hoveredKey = ref(null);
|
|
231
|
+
watch(open, (isOpen) => {
|
|
232
|
+
hoveredKey.value = isOpen ? entries.value[0]?.key ?? null : null;
|
|
233
|
+
});
|
|
234
|
+
</script>
|
|
235
|
+
|
|
236
|
+
<template>
|
|
237
|
+
<div class="p-[0.125rem] w-full">
|
|
238
|
+
<span
|
|
239
|
+
v-if="isHidden"
|
|
240
|
+
class="block h-7 w-full"
|
|
241
|
+
/>
|
|
242
|
+
<span
|
|
243
|
+
v-else-if="isReadonly || !isInteractive"
|
|
244
|
+
class="flex items-center h-7 w-full px-2 text-[0.75rem] text-zinc-700 truncate"
|
|
245
|
+
>
|
|
246
|
+
{{ selectedLabel || "\u2014" }}
|
|
247
|
+
</span>
|
|
248
|
+
<Popover
|
|
249
|
+
v-else
|
|
250
|
+
v-model:open="open"
|
|
251
|
+
>
|
|
252
|
+
<PopoverAnchor as-child>
|
|
253
|
+
<InputGroup
|
|
254
|
+
class="group/combobox-single-remote h-7 rounded border-zinc-200/30 hover:border-zinc-200 focus-within:border-zinc-200 transition-colors ease-out duration-180"
|
|
255
|
+
:data-disabled="isDisabled ? 'true' : void 0"
|
|
256
|
+
>
|
|
257
|
+
<PopoverTrigger as-child>
|
|
258
|
+
<InputGroupInput
|
|
259
|
+
:model-value="selectedLabel"
|
|
260
|
+
:disabled="isDisabled"
|
|
261
|
+
:placeholder="placeholderText"
|
|
262
|
+
class="h-7 text-[0.75rem] md:text-[0.75rem] px-2 cursor-pointer text-left"
|
|
263
|
+
readonly
|
|
264
|
+
/>
|
|
265
|
+
</PopoverTrigger>
|
|
266
|
+
<InputGroupAddon
|
|
267
|
+
v-if="pending || isLoading"
|
|
268
|
+
align="inline-end"
|
|
269
|
+
class="text-zinc-400"
|
|
270
|
+
>
|
|
271
|
+
<Icon
|
|
272
|
+
icon="fluent:spinner-ios-20-regular"
|
|
273
|
+
class="size-3 animate-spin"
|
|
274
|
+
/>
|
|
275
|
+
</InputGroupAddon>
|
|
276
|
+
<InputGroupAddon
|
|
277
|
+
v-else-if="showClear"
|
|
278
|
+
align="inline-end"
|
|
279
|
+
class="[@media(hover:hover)]:opacity-0 transition-opacity group-hover/combobox-single-remote:opacity-100 focus-within:opacity-100"
|
|
280
|
+
>
|
|
281
|
+
<InputGroupButton
|
|
282
|
+
size="icon-xs"
|
|
283
|
+
data-slot="combobox-single-remote-clear"
|
|
284
|
+
class="size-4 text-zinc-500 hover:text-zinc-700"
|
|
285
|
+
tabindex="-1"
|
|
286
|
+
@mousedown.prevent
|
|
287
|
+
@click.stop="handleClear"
|
|
288
|
+
>
|
|
289
|
+
<Icon
|
|
290
|
+
icon="fluent:dismiss-20-regular"
|
|
291
|
+
class="size-3"
|
|
292
|
+
/>
|
|
293
|
+
</InputGroupButton>
|
|
294
|
+
</InputGroupAddon>
|
|
295
|
+
</InputGroup>
|
|
296
|
+
</PopoverAnchor>
|
|
297
|
+
<PopoverContent
|
|
298
|
+
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]"
|
|
299
|
+
:style="{ width: 'var(--reka-popover-trigger-width)' }"
|
|
300
|
+
>
|
|
301
|
+
<Command
|
|
302
|
+
:model-value="selectedKey"
|
|
303
|
+
:disabled="isDisabled"
|
|
304
|
+
selection-behavior="toggle"
|
|
305
|
+
@update:model-value="handleSelect"
|
|
306
|
+
>
|
|
307
|
+
<CommandInput :placeholder="t('combobox-single-search-placeholder')" />
|
|
308
|
+
<CommandList>
|
|
309
|
+
<div
|
|
310
|
+
v-if="entries.length === 0"
|
|
311
|
+
data-slot="combobox-single-remote-empty"
|
|
312
|
+
class="py-3 text-center text-[0.75rem] text-zinc-500"
|
|
313
|
+
>
|
|
314
|
+
{{ isLoading ? t("combobox-single-loading") : t("combobox-single-empty") }}
|
|
315
|
+
</div>
|
|
316
|
+
<template v-else>
|
|
317
|
+
<CommandEmpty class="py-3 text-center text-[0.75rem] text-zinc-500">
|
|
318
|
+
{{ t("combobox-single-empty") }}
|
|
319
|
+
</CommandEmpty>
|
|
320
|
+
<CommandGroup>
|
|
321
|
+
<CommandItem
|
|
322
|
+
v-for="entry in entries"
|
|
323
|
+
:key="entry.key"
|
|
324
|
+
:value="entry.key"
|
|
325
|
+
@mouseenter="hoveredKey = entry.key"
|
|
326
|
+
@focus="hoveredKey = entry.key"
|
|
327
|
+
>
|
|
328
|
+
<Markdown :source="entry.label" />
|
|
329
|
+
</CommandItem>
|
|
330
|
+
</CommandGroup>
|
|
331
|
+
</template>
|
|
332
|
+
</CommandList>
|
|
333
|
+
</Command>
|
|
334
|
+
</PopoverContent>
|
|
335
|
+
</Popover>
|
|
336
|
+
</div>
|
|
337
|
+
</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;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
import type { ColumnDef } from '@tanstack/vue-table';
|
|
3
|
+
import type { Environment } from '../../../../../vendor/cel-js/lib/index.js';
|
|
4
|
+
import type { ColumnDefDeps } from '../../../utils/resolve.js';
|
|
5
|
+
export declare const type: "com.shwfed.table.column.combobox-single.remote.options-remote";
|
|
6
|
+
export declare const compatibilityDate: "2026-05-24";
|
|
7
|
+
export declare const metadata: {
|
|
8
|
+
readonly name: "下拉单选(远程·远程选项)";
|
|
9
|
+
readonly icon: "fluent:cloud-arrow-down-20-regular";
|
|
10
|
+
};
|
|
11
|
+
export declare const OPTION_VAR: {
|
|
12
|
+
readonly type: "dyn";
|
|
13
|
+
readonly label: "当前选项";
|
|
14
|
+
readonly description: "`选项` 表达式产出的数组中迭代到的单个元素";
|
|
15
|
+
};
|
|
16
|
+
export declare const JSON_VAR: {
|
|
17
|
+
readonly type: "dyn";
|
|
18
|
+
readonly label: "HTTP 响应体";
|
|
19
|
+
readonly description: "HTTP 响应体(已解析 JSON);请求失败或尚未完成时为 `null`";
|
|
20
|
+
};
|
|
21
|
+
export declare function schema(configure: (env: Environment) => void): Schema.Struct<{
|
|
22
|
+
placeholder: Schema.optional<Schema.TupleType<readonly [Schema.Struct<{
|
|
23
|
+
locale: Schema.Literal<["zh"]>;
|
|
24
|
+
message: Schema.SchemaClass<string, string, never>;
|
|
25
|
+
}>], [Schema.Struct<{
|
|
26
|
+
locale: Schema.Literal<["ja", "en", "ko"]>;
|
|
27
|
+
message: Schema.SchemaClass<string, string, never>;
|
|
28
|
+
}>]>>;
|
|
29
|
+
hidden: Schema.optional<Schema.Schema<string, string, never>>;
|
|
30
|
+
disabled: Schema.optional<Schema.Schema<string, string, never>>;
|
|
31
|
+
readonly: Schema.optional<Schema.Schema<string, string, never>>;
|
|
32
|
+
request: Schema.Schema<string, string, never>;
|
|
33
|
+
options: Schema.Schema<string, string, never>;
|
|
34
|
+
optionValue: Schema.optionalWith<Schema.Schema<string, string, never>, {
|
|
35
|
+
default: () => string;
|
|
36
|
+
}>;
|
|
37
|
+
optionLabel: Schema.optionalWith<Schema.refine<readonly [{
|
|
38
|
+
readonly locale: "zh";
|
|
39
|
+
readonly message: string;
|
|
40
|
+
}, ...{
|
|
41
|
+
readonly locale: "en" | "ja" | "ko";
|
|
42
|
+
readonly message: string;
|
|
43
|
+
}[]], Schema.TupleType<readonly [Schema.Struct<{
|
|
44
|
+
locale: Schema.Literal<["zh"]>;
|
|
45
|
+
message: Schema.SchemaClass<string, string, never>;
|
|
46
|
+
}>], [Schema.Struct<{
|
|
47
|
+
locale: Schema.Literal<["ja", "en", "ko"]>;
|
|
48
|
+
message: Schema.SchemaClass<string, string, never>;
|
|
49
|
+
}>]>>, {
|
|
50
|
+
default: () => readonly [{
|
|
51
|
+
readonly locale: "zh";
|
|
52
|
+
readonly message: "";
|
|
53
|
+
}];
|
|
54
|
+
}>;
|
|
55
|
+
onChange: Schema.optional<Schema.Schema<string, string, never>>;
|
|
56
|
+
successMessage: Schema.optional<Schema.Schema<string, string, never>>;
|
|
57
|
+
triggers: Schema.optional<Schema.Array$<Schema.Struct<{
|
|
58
|
+
target: Schema.refine<string, typeof Schema.String>;
|
|
59
|
+
operation: Schema.SchemaClass<string, string, never>;
|
|
60
|
+
}>>>;
|
|
61
|
+
title: Schema.TupleType<readonly [Schema.Struct<{
|
|
62
|
+
locale: Schema.Literal<["zh"]>;
|
|
63
|
+
message: Schema.SchemaClass<string, string, never>;
|
|
64
|
+
}>], [Schema.Struct<{
|
|
65
|
+
locale: Schema.Literal<["ja", "en", "ko"]>;
|
|
66
|
+
message: Schema.SchemaClass<string, string, never>;
|
|
67
|
+
}>]>;
|
|
68
|
+
accessor: Schema.Schema<string, string, never>;
|
|
69
|
+
enableSorting: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
70
|
+
size: Schema.optional<Schema.refine<number, Schema.filter<typeof Schema.Number>>>;
|
|
71
|
+
grow: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
72
|
+
tooltip: Schema.optional<Schema.TupleType<readonly [Schema.Struct<{
|
|
73
|
+
locale: Schema.Literal<["zh"]>;
|
|
74
|
+
message: Schema.SchemaClass<string, string, never>;
|
|
75
|
+
}>], [Schema.Struct<{
|
|
76
|
+
locale: Schema.Literal<["ja", "en", "ko"]>;
|
|
77
|
+
message: Schema.SchemaClass<string, string, never>;
|
|
78
|
+
}>]>>;
|
|
79
|
+
id: Schema.refine<string, typeof Schema.String>;
|
|
80
|
+
groupId: Schema.optional<typeof Schema.UUID>;
|
|
81
|
+
type: Schema.Literal<["com.shwfed.table.column.combobox-single.remote.options-remote"]>;
|
|
82
|
+
compatibilityDate: Schema.Literal<["2026-05-24"]>;
|
|
83
|
+
}>;
|
|
84
|
+
export type Value = Schema.Schema.Type<ReturnType<typeof schema>>;
|
|
85
|
+
export declare function toColumnDef(value: Value, { getLocaleText, $cel, inheritedContext }: ColumnDefDeps): Partial<ColumnDef<unknown, unknown>>;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { Expression, LocaleMarkdown } from "../../../../../share/expression.js";
|
|
3
|
+
import { Locale } from "../../../../../share/locale.js";
|
|
4
|
+
import { Triggers } from "../../../../../share/event-bus.js";
|
|
5
|
+
import {
|
|
6
|
+
CelRowAccess,
|
|
7
|
+
columnFields,
|
|
8
|
+
registerRowVariablesIfAbsent
|
|
9
|
+
} from "../../../utils/shared.js";
|
|
10
|
+
export const type = "com.shwfed.table.column.combobox-single.remote.options-remote";
|
|
11
|
+
export const compatibilityDate = "2026-05-24";
|
|
12
|
+
export const metadata = {
|
|
13
|
+
name: "\u4E0B\u62C9\u5355\u9009\uFF08\u8FDC\u7A0B\xB7\u8FDC\u7A0B\u9009\u9879\uFF09",
|
|
14
|
+
icon: "fluent:cloud-arrow-down-20-regular"
|
|
15
|
+
};
|
|
16
|
+
export const OPTION_VAR = {
|
|
17
|
+
type: "dyn",
|
|
18
|
+
label: "\u5F53\u524D\u9009\u9879",
|
|
19
|
+
description: "`\u9009\u9879` \u8868\u8FBE\u5F0F\u4EA7\u51FA\u7684\u6570\u7EC4\u4E2D\u8FED\u4EE3\u5230\u7684\u5355\u4E2A\u5143\u7D20"
|
|
20
|
+
};
|
|
21
|
+
export const JSON_VAR = {
|
|
22
|
+
type: "dyn",
|
|
23
|
+
label: "HTTP \u54CD\u5E94\u4F53",
|
|
24
|
+
description: "HTTP \u54CD\u5E94\u4F53\uFF08\u5DF2\u89E3\u6790 JSON\uFF09\uFF1B\u8BF7\u6C42\u5931\u8D25\u6216\u5C1A\u672A\u5B8C\u6210\u65F6\u4E3A `null`"
|
|
25
|
+
};
|
|
26
|
+
const isListType = (actual) => actual === "dyn" || actual.startsWith("list");
|
|
27
|
+
export function schema(configure) {
|
|
28
|
+
const CelBool = CelRowAccess(configure, { resultType: "bool" });
|
|
29
|
+
const CelRequest = Expression({
|
|
30
|
+
configure: (env) => {
|
|
31
|
+
configure(env);
|
|
32
|
+
registerRowVariablesIfAbsent(env);
|
|
33
|
+
},
|
|
34
|
+
resultType: "HttpRequest"
|
|
35
|
+
});
|
|
36
|
+
const CelOptions = Expression({
|
|
37
|
+
configure: (env) => {
|
|
38
|
+
configure(env);
|
|
39
|
+
registerRowVariablesIfAbsent(env);
|
|
40
|
+
env.registerVariable("json", JSON_VAR.type, { description: JSON_VAR.description });
|
|
41
|
+
},
|
|
42
|
+
resultType: isListType
|
|
43
|
+
});
|
|
44
|
+
const CelOptionValue = Expression({
|
|
45
|
+
configure: (env) => {
|
|
46
|
+
configure(env);
|
|
47
|
+
registerRowVariablesIfAbsent(env);
|
|
48
|
+
env.registerVariable("option", OPTION_VAR.type, { description: OPTION_VAR.description });
|
|
49
|
+
},
|
|
50
|
+
resultType: "dyn"
|
|
51
|
+
});
|
|
52
|
+
const LocaleOptionLabel = LocaleMarkdown({
|
|
53
|
+
configure: (env) => {
|
|
54
|
+
configure(env);
|
|
55
|
+
registerRowVariablesIfAbsent(env);
|
|
56
|
+
env.registerVariable("option", OPTION_VAR.type, { description: OPTION_VAR.description });
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const CelOnChange = Expression({
|
|
60
|
+
configure: (env) => {
|
|
61
|
+
configure(env);
|
|
62
|
+
registerRowVariablesIfAbsent(env);
|
|
63
|
+
env.registerVariable("value", "dyn", { description: "\u7528\u6237\u9009\u4E2D\u7684\u65B0\u503C\uFF08\u4E0E\u6240\u9009\u9879\u7684 `value` \u4E00\u81F4\uFF1B\u6E05\u7A7A\u65F6\u4E3A `null`\uFF09" });
|
|
64
|
+
},
|
|
65
|
+
resultType: "HttpRequest"
|
|
66
|
+
});
|
|
67
|
+
const CelMessage = Expression({
|
|
68
|
+
configure: (env) => {
|
|
69
|
+
configure(env);
|
|
70
|
+
env.registerVariable("json", "dyn", { description: "HTTP \u54CD\u5E94\u4F53\uFF08\u5DF2\u89E3\u6790 JSON\uFF09" });
|
|
71
|
+
},
|
|
72
|
+
resultType: "string"
|
|
73
|
+
});
|
|
74
|
+
return Schema.Struct({
|
|
75
|
+
type: Schema.Literal(type),
|
|
76
|
+
compatibilityDate: Schema.Literal(compatibilityDate),
|
|
77
|
+
...columnFields(configure),
|
|
78
|
+
placeholder: Schema.optional(Locale.annotations({
|
|
79
|
+
title: "\u5360\u4F4D\u7B26",
|
|
80
|
+
description: "\u672A\u9009\u4E2D\u4EFB\u4F55\u9009\u9879\u65F6\u8F93\u5165\u6846\u4E2D\u7684\u5360\u4F4D\u6587\u672C"
|
|
81
|
+
})),
|
|
82
|
+
hidden: Schema.optional(CelBool.annotations({
|
|
83
|
+
title: "\u9690\u85CF\u6761\u4EF6",
|
|
84
|
+
description: "\u8FD4\u56DE `true` \u65F6\u8BE5\u884C\u7684\u4E0B\u62C9\u6846\u4E0D\u6E32\u67D3\uFF08\u5176\u4F59\u884C\u4E0D\u53D7\u5F71\u54CD\uFF09"
|
|
85
|
+
})),
|
|
86
|
+
disabled: Schema.optional(CelBool.annotations({
|
|
87
|
+
title: "\u7981\u7528\u6761\u4EF6",
|
|
88
|
+
description: "\u8FD4\u56DE `true` \u65F6\u4E0B\u62C9\u6846\u4ECD\u7136\u6E32\u67D3\u4F46\u4E0D\u53EF\u9009\u62E9"
|
|
89
|
+
})),
|
|
90
|
+
readonly: Schema.optional(CelBool.annotations({
|
|
91
|
+
title: "\u53EA\u8BFB\u6761\u4EF6",
|
|
92
|
+
description: "\u8FD4\u56DE `true` \u65F6\u4EC5\u4EE5\u7EAF\u6587\u672C\u5C55\u793A\u5F53\u524D\u9009\u9879\u7684\u6807\u7B7E"
|
|
93
|
+
})),
|
|
94
|
+
request: CelRequest.annotations({
|
|
95
|
+
title: "\u8BF7\u6C42",
|
|
96
|
+
description: "\u8FD4\u56DE `HttpRequest` \u7684 CEL \u8868\u8FBE\u5F0F\uFF1B\u53EF\u8BBF\u95EE `row` \u4E0E `index`\u3002\u76F8\u540C\u7B7E\u540D\u7684\u8BF7\u6C42\u4F1A\u5728\u8BE5\u8868\u683C\u5185\u81EA\u52A8\u53BB\u91CD"
|
|
97
|
+
}),
|
|
98
|
+
options: CelOptions.annotations({
|
|
99
|
+
title: "\u9009\u9879",
|
|
100
|
+
description: "\u4ECE HTTP \u54CD\u5E94\u4F53\u63D0\u53D6\u9009\u9879\u6570\u7EC4\u7684 CEL \u8868\u8FBE\u5F0F\uFF1B\u53EF\u8BBF\u95EE `row`\u3001`index` \u4E0E `json`\u3002\u4F8B\uFF1A`json.data`"
|
|
101
|
+
}),
|
|
102
|
+
optionValue: Schema.optionalWith(CelOptionValue.annotations({
|
|
103
|
+
title: "\u9009\u9879\u503C",
|
|
104
|
+
description: "\u4ECE\u5F53\u524D `option` \u63D0\u53D6\u5199\u5165\u503C\u7684 CEL\uFF1B\u4F8B\uFF1A`option.value`"
|
|
105
|
+
}), { default: () => "option" }),
|
|
106
|
+
optionLabel: Schema.optionalWith(LocaleOptionLabel.annotations({
|
|
107
|
+
title: "\u9009\u9879\u6807\u7B7E",
|
|
108
|
+
description: "\u6BCF\u4E2A\u9009\u9879\u5C55\u793A\u7684\u672C\u5730\u5316\u6587\u672C\uFF0C\u652F\u6301 `{{ string(option.foo) }}` \u63D2\u503C"
|
|
109
|
+
}), { default: () => [{ locale: "zh", message: "" }] }),
|
|
110
|
+
onChange: Schema.optional(CelOnChange.annotations({
|
|
111
|
+
title: "\u5207\u6362\u8BF7\u6C42",
|
|
112
|
+
description: "\u7528\u6237\u9009\u62E9\u540E\u7ACB\u5373\u6C42\u503C\u5E76\u53D1\u8D77\u7684 HTTP \u8BF7\u6C42\uFF1B`value` \u4E3A\u65B0\u503C\u3002\u672A\u914D\u7F6E\u65F6\u4E0B\u62C9\u6846\u53EA\u8BFB"
|
|
113
|
+
})),
|
|
114
|
+
successMessage: Schema.optional(CelMessage.annotations({
|
|
115
|
+
title: "\u6210\u529F\u6D88\u606F",
|
|
116
|
+
description: "\u8BF7\u6C42\u6210\u529F\u540E\u5F39\u51FA\u7684 toast \u5185\u5BB9\uFF1B\u672A\u914D\u7F6E\u5219\u9759\u9ED8"
|
|
117
|
+
})),
|
|
118
|
+
triggers: Schema.optional(Triggers.annotations({
|
|
119
|
+
title: "\u6210\u529F\u540E\u89E6\u53D1",
|
|
120
|
+
description: "\u8BF7\u6C42\u6210\u529F\u540E\u6309\u5217\u8868\u987A\u5E8F\u5192\u6CE1\u7684\u64CD\u4F5C\u8BF7\u6C42\uFF1B\u672A\u914D\u7F6E\u5219\u4EC0\u4E48\u90FD\u4E0D\u505A"
|
|
121
|
+
}))
|
|
122
|
+
}).annotations({
|
|
123
|
+
title: "ComboboxSingleRemoteOptionsRemoteRenderer",
|
|
124
|
+
description: "\u4E0B\u62C9\u5355\u9009\u6E32\u67D3\u5668\uFF08\u8FDC\u7A0B\u5199\u5165\xB7\u8FDC\u7A0B\u9009\u9879\uFF09"
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
export function toColumnDef(value, { getLocaleText, $cel, inheritedContext }) {
|
|
128
|
+
return {
|
|
129
|
+
header: getLocaleText(value.title),
|
|
130
|
+
accessorFn: (row, index) => {
|
|
131
|
+
try {
|
|
132
|
+
return Effect.runSync($cel(value.accessor, { ...inheritedContext, row, index }));
|
|
133
|
+
} catch (e) {
|
|
134
|
+
console.error("[shwfed-table] combobox-single.remote.options-remote accessor failed", e);
|
|
135
|
+
return void 0;
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
enableSorting: value.enableSorting ?? false,
|
|
139
|
+
sortingFn: "basic",
|
|
140
|
+
size: value.size,
|
|
141
|
+
meta: {
|
|
142
|
+
grow: value.grow ?? false,
|
|
143
|
+
tooltip: getLocaleText(value.tooltip)
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|