@shwfed/config 2.3.0 → 2.3.2
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/module.json +1 -1
- package/dist/module.mjs +2 -0
- package/dist/runtime/components/actions/buttons/2026-05-21/com.shwfed.actions.button.http.download/config.d.vue.ts +61 -0
- package/dist/runtime/components/actions/buttons/2026-05-21/com.shwfed.actions.button.http.download/config.vue +187 -0
- package/dist/runtime/components/actions/buttons/2026-05-21/com.shwfed.actions.button.http.download/config.vue.d.ts +61 -0
- package/dist/runtime/components/actions/buttons/2026-05-21/com.shwfed.actions.button.http.download/runtime.d.vue.ts +8 -0
- package/dist/runtime/components/actions/buttons/2026-05-21/com.shwfed.actions.button.http.download/runtime.vue +62 -0
- package/dist/runtime/components/actions/buttons/2026-05-21/com.shwfed.actions.button.http.download/runtime.vue.d.ts +8 -0
- package/dist/runtime/components/actions/buttons/2026-05-21/com.shwfed.actions.button.http.download/schema.d.ts +40 -0
- package/dist/runtime/components/actions/buttons/2026-05-21/com.shwfed.actions.button.http.download/schema.js +87 -0
- package/dist/runtime/components/config/blocks/2026-05-06/com.shwfed.block.table/config.d.vue.ts +2 -0
- package/dist/runtime/components/config/blocks/2026-05-06/com.shwfed.block.table/config.vue.d.ts +2 -0
- package/dist/runtime/components/config/blocks/2026-05-06/com.shwfed.block.table/runtime.d.vue.ts +2 -0
- package/dist/runtime/components/config/blocks/2026-05-06/com.shwfed.block.table/runtime.vue.d.ts +2 -0
- package/dist/runtime/components/config/blocks/2026-05-06/com.shwfed.block.table/schema.d.ts +2 -0
- package/dist/runtime/components/form/fields/2026-05-18/com.shwfed.form.field.table/config.d.vue.ts +2 -0
- package/dist/runtime/components/form/fields/2026-05-18/com.shwfed.form.field.table/config.vue.d.ts +2 -0
- package/dist/runtime/components/form/fields/2026-05-18/com.shwfed.form.field.table/schema.d.ts +2 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/config.d.vue.ts +10 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/config.vue +310 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/config.vue.d.ts +10 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/runtime.d.vue.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/runtime.vue +81 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/runtime.vue.d.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/schema.d.ts +57 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/schema.js +59 -0
- package/dist/runtime/components/table/columns/2026-05-21/com.shwfed.table.column.drag-handle/config.d.vue.ts +10 -0
- package/dist/runtime/components/table/columns/2026-05-21/com.shwfed.table.column.drag-handle/config.vue +10 -0
- package/dist/runtime/components/table/columns/2026-05-21/com.shwfed.table.column.drag-handle/config.vue.d.ts +10 -0
- package/dist/runtime/components/table/columns/2026-05-21/com.shwfed.table.column.drag-handle/runtime.d.vue.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-21/com.shwfed.table.column.drag-handle/runtime.vue +68 -0
- package/dist/runtime/components/table/columns/2026-05-21/com.shwfed.table.column.drag-handle/runtime.vue.d.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-21/com.shwfed.table.column.drag-handle/schema.d.ts +17 -0
- package/dist/runtime/components/table/columns/2026-05-21/com.shwfed.table.column.drag-handle/schema.js +31 -0
- package/dist/runtime/components/table/config.d.vue.ts +2 -2
- package/dist/runtime/components/table/config.vue +50 -0
- package/dist/runtime/components/table/config.vue.d.ts +2 -2
- package/dist/runtime/components/table/index.d.vue.ts +2 -0
- package/dist/runtime/components/table/index.vue +110 -4
- package/dist/runtime/components/table/index.vue.d.ts +2 -0
- package/dist/runtime/components/table/schema.d.ts +4 -0
- package/dist/runtime/components/table/schema.js +8 -1
- package/dist/runtime/components/table/utils/reorder.d.ts +10 -0
- package/dist/runtime/components/table/utils/reorder.js +8 -0
- package/dist/runtime/components/table/utils/row-key.d.ts +11 -0
- package/dist/runtime/components/table/utils/row-key.js +30 -0
- package/dist/runtime/components/table/utils/row-reorder.d.ts +12 -0
- package/dist/runtime/components/table/utils/row-reorder.js +162 -0
- package/package.json +1 -1
package/dist/runtime/components/form/fields/2026-05-18/com.shwfed.form.field.table/schema.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export declare function schema(configure: (env: Environment) => void): Schema.St
|
|
|
42
42
|
dataSource?: import("../../../../table/schema.js").DataSourceValue;
|
|
43
43
|
actions?: import("../../../../table/schema.js").TableActionsValue;
|
|
44
44
|
query?: import("../../../schema.js").FormConfigValue;
|
|
45
|
+
rowKey?: string;
|
|
45
46
|
cellStyle?: string;
|
|
46
47
|
style?: string;
|
|
47
48
|
pagination?: Schema.Schema.Type<typeof import("../../../../table/schema.js").Pagination>;
|
|
@@ -76,6 +77,7 @@ export declare function schema(configure: (env: Environment) => void): Schema.St
|
|
|
76
77
|
dataSource?: import("../../../../table/schema.js").DataSourceValue;
|
|
77
78
|
actions?: import("../../../../table/schema.js").TableActionsValue;
|
|
78
79
|
query?: import("../../../schema.js").FormConfigValue;
|
|
80
|
+
rowKey?: string;
|
|
79
81
|
cellStyle?: string;
|
|
80
82
|
style?: string;
|
|
81
83
|
pagination?: Schema.Schema.Type<typeof import("../../../../table/schema.js").Pagination>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type __VLS_ModelProps = {
|
|
2
|
+
modelValue: Record<string, any>;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
5
|
+
"update:modelValue": (value: Record<string, any>) => any;
|
|
6
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
|
|
7
|
+
"onUpdate:modelValue"?: ((value: Record<string, any>) => any) | undefined;
|
|
8
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/config.vue
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { Icon } from "@iconify/vue";
|
|
4
|
+
import { ExpressionEditor } from "../../../../ui/expression-editor";
|
|
5
|
+
import { Switch } from "../../../../ui/switch";
|
|
6
|
+
import { Separator } from "../../../../ui/separator";
|
|
7
|
+
import { Field, FieldLabel } from "../../../../ui/field";
|
|
8
|
+
import { Locale } from "../../../../ui/locale";
|
|
9
|
+
import {
|
|
10
|
+
InputGroup,
|
|
11
|
+
InputGroupAddon,
|
|
12
|
+
InputGroupButton,
|
|
13
|
+
InputGroupInput,
|
|
14
|
+
InputGroupNumberField
|
|
15
|
+
} from "../../../../ui/input-group";
|
|
16
|
+
import { getStructFieldDescription, getStructFieldTitle } from "../../../utils/schema-meta";
|
|
17
|
+
import { Markdown } from "../../../../ui/markdown";
|
|
18
|
+
import DerivedValueEditor from "../../../../form/DerivedValueEditor.vue";
|
|
19
|
+
import { schema } from "./schema";
|
|
20
|
+
defineOptions({ name: "ShwfedTableSwitchRendererConfig" });
|
|
21
|
+
const value = defineModel({ type: Object, ...{ required: true } });
|
|
22
|
+
const fieldSchema = schema(() => {
|
|
23
|
+
});
|
|
24
|
+
const fieldTitle = (field) => getStructFieldTitle(fieldSchema, field) ?? field;
|
|
25
|
+
const fieldDescription = (field) => getStructFieldDescription(fieldSchema, field);
|
|
26
|
+
const ROW_VARS = {
|
|
27
|
+
row: { type: "dyn", label: "\u5F53\u524D\u884C\u6570\u636E" },
|
|
28
|
+
index: { type: "number", label: "\u884C\u7D22\u5F15" }
|
|
29
|
+
};
|
|
30
|
+
const bindingText = computed({
|
|
31
|
+
get: () => value.value.binding ?? "",
|
|
32
|
+
set: (v) => {
|
|
33
|
+
const trimmed = v.trim();
|
|
34
|
+
if (trimmed === "") delete value.value.binding;
|
|
35
|
+
else value.value.binding = trimmed;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const hiddenModel = computed({
|
|
39
|
+
get: () => value.value.hidden ?? "",
|
|
40
|
+
set: (v) => {
|
|
41
|
+
if (v === "") delete value.value.hidden;
|
|
42
|
+
else value.value.hidden = v;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
const disabledModel = computed({
|
|
46
|
+
get: () => value.value.disabled ?? "",
|
|
47
|
+
set: (v) => {
|
|
48
|
+
if (v === "") delete value.value.disabled;
|
|
49
|
+
else value.value.disabled = v;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const readonlyModel = computed({
|
|
53
|
+
get: () => value.value.readonly ?? "",
|
|
54
|
+
set: (v) => {
|
|
55
|
+
if (v === "") delete value.value.readonly;
|
|
56
|
+
else value.value.readonly = v;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const derivedModel = computed({
|
|
60
|
+
get: () => value.value.derived,
|
|
61
|
+
set: (v) => {
|
|
62
|
+
if (v == null) delete value.value.derived;
|
|
63
|
+
else value.value.derived = v;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<template>
|
|
69
|
+
<div class="space-y-5">
|
|
70
|
+
<div class="grid grid-cols-2 gap-x-6 gap-y-4">
|
|
71
|
+
<Field orientation="vertical">
|
|
72
|
+
<FieldLabel class="text-xs text-zinc-500">
|
|
73
|
+
<template
|
|
74
|
+
v-if="fieldDescription('title')"
|
|
75
|
+
#tooltip
|
|
76
|
+
>
|
|
77
|
+
<Markdown
|
|
78
|
+
:source="fieldDescription('title')"
|
|
79
|
+
block
|
|
80
|
+
class="prose prose-sm prose-zinc"
|
|
81
|
+
/>
|
|
82
|
+
</template>
|
|
83
|
+
{{ fieldTitle("title") }}
|
|
84
|
+
</FieldLabel>
|
|
85
|
+
<Locale v-model="value.title" />
|
|
86
|
+
</Field>
|
|
87
|
+
<Field orientation="vertical">
|
|
88
|
+
<FieldLabel class="text-xs text-zinc-500">
|
|
89
|
+
<template
|
|
90
|
+
v-if="fieldDescription('tooltip')"
|
|
91
|
+
#tooltip
|
|
92
|
+
>
|
|
93
|
+
<Markdown
|
|
94
|
+
:source="fieldDescription('tooltip')"
|
|
95
|
+
block
|
|
96
|
+
class="prose prose-sm prose-zinc"
|
|
97
|
+
/>
|
|
98
|
+
</template>
|
|
99
|
+
{{ fieldTitle("tooltip") }}
|
|
100
|
+
</FieldLabel>
|
|
101
|
+
<Locale
|
|
102
|
+
v-model="value.tooltip"
|
|
103
|
+
markdown
|
|
104
|
+
/>
|
|
105
|
+
</Field>
|
|
106
|
+
</div>
|
|
107
|
+
<div class="grid grid-cols-2 gap-x-6 gap-y-4">
|
|
108
|
+
<Field orientation="vertical">
|
|
109
|
+
<FieldLabel class="text-xs text-zinc-500">
|
|
110
|
+
<template
|
|
111
|
+
v-if="fieldDescription('binding')"
|
|
112
|
+
#tooltip
|
|
113
|
+
>
|
|
114
|
+
<Markdown
|
|
115
|
+
:source="fieldDescription('binding')"
|
|
116
|
+
block
|
|
117
|
+
class="prose prose-sm prose-zinc"
|
|
118
|
+
/>
|
|
119
|
+
</template>
|
|
120
|
+
{{ fieldTitle("binding") }}
|
|
121
|
+
</FieldLabel>
|
|
122
|
+
<InputGroup>
|
|
123
|
+
<InputGroupInput
|
|
124
|
+
v-model="bindingText"
|
|
125
|
+
placeholder="例:enabled"
|
|
126
|
+
class="font-mono"
|
|
127
|
+
/>
|
|
128
|
+
</InputGroup>
|
|
129
|
+
</Field>
|
|
130
|
+
<Field orientation="vertical">
|
|
131
|
+
<FieldLabel class="text-xs text-zinc-500">
|
|
132
|
+
<template
|
|
133
|
+
v-if="fieldDescription('size')"
|
|
134
|
+
#tooltip
|
|
135
|
+
>
|
|
136
|
+
<Markdown
|
|
137
|
+
:source="fieldDescription('size')"
|
|
138
|
+
block
|
|
139
|
+
class="prose prose-sm prose-zinc"
|
|
140
|
+
/>
|
|
141
|
+
</template>
|
|
142
|
+
{{ fieldTitle("size") }}
|
|
143
|
+
</FieldLabel>
|
|
144
|
+
<InputGroup>
|
|
145
|
+
<InputGroupNumberField
|
|
146
|
+
:model-value="value.size"
|
|
147
|
+
:disabled="value.grow"
|
|
148
|
+
:min="0"
|
|
149
|
+
@update:model-value="(v) => value.size = v"
|
|
150
|
+
/>
|
|
151
|
+
<InputGroupAddon align="inline-end">
|
|
152
|
+
<InputGroupButton
|
|
153
|
+
:variant="value.grow ? 'primary' : 'ghost'"
|
|
154
|
+
size="xs"
|
|
155
|
+
@click="value.grow = !value.grow"
|
|
156
|
+
>
|
|
157
|
+
<Icon :icon="value.grow ? 'fluent:lock-closed-20-regular' : 'fluent:arrow-autofit-width-20-regular'" />
|
|
158
|
+
{{ fieldTitle("grow") }}
|
|
159
|
+
</InputGroupButton>
|
|
160
|
+
</InputGroupAddon>
|
|
161
|
+
</InputGroup>
|
|
162
|
+
</Field>
|
|
163
|
+
<Field orientation="vertical">
|
|
164
|
+
<FieldLabel class="text-xs text-zinc-500">
|
|
165
|
+
<template
|
|
166
|
+
v-if="fieldDescription('trueLabel')"
|
|
167
|
+
#tooltip
|
|
168
|
+
>
|
|
169
|
+
<Markdown
|
|
170
|
+
:source="fieldDescription('trueLabel')"
|
|
171
|
+
block
|
|
172
|
+
class="prose prose-sm prose-zinc"
|
|
173
|
+
/>
|
|
174
|
+
</template>
|
|
175
|
+
{{ fieldTitle("trueLabel") }}
|
|
176
|
+
</FieldLabel>
|
|
177
|
+
<Locale v-model="value.trueLabel" />
|
|
178
|
+
</Field>
|
|
179
|
+
<Field orientation="vertical">
|
|
180
|
+
<FieldLabel class="text-xs text-zinc-500">
|
|
181
|
+
<template
|
|
182
|
+
v-if="fieldDescription('falseLabel')"
|
|
183
|
+
#tooltip
|
|
184
|
+
>
|
|
185
|
+
<Markdown
|
|
186
|
+
:source="fieldDescription('falseLabel')"
|
|
187
|
+
block
|
|
188
|
+
class="prose prose-sm prose-zinc"
|
|
189
|
+
/>
|
|
190
|
+
</template>
|
|
191
|
+
{{ fieldTitle("falseLabel") }}
|
|
192
|
+
</FieldLabel>
|
|
193
|
+
<Locale v-model="value.falseLabel" />
|
|
194
|
+
</Field>
|
|
195
|
+
</div>
|
|
196
|
+
<div class="grid grid-cols-2 gap-x-6 gap-y-4">
|
|
197
|
+
<Field orientation="vertical">
|
|
198
|
+
<FieldLabel class="text-xs text-zinc-500">
|
|
199
|
+
<template
|
|
200
|
+
v-if="fieldDescription('hidden')"
|
|
201
|
+
#tooltip
|
|
202
|
+
>
|
|
203
|
+
<Markdown
|
|
204
|
+
:source="fieldDescription('hidden')"
|
|
205
|
+
block
|
|
206
|
+
class="prose prose-sm prose-zinc"
|
|
207
|
+
/>
|
|
208
|
+
</template>
|
|
209
|
+
{{ fieldTitle("hidden") }}
|
|
210
|
+
</FieldLabel>
|
|
211
|
+
<ExpressionEditor
|
|
212
|
+
v-model="hiddenModel"
|
|
213
|
+
placeholder="例:row.archived"
|
|
214
|
+
result-type="bool"
|
|
215
|
+
:extra-vars="ROW_VARS"
|
|
216
|
+
/>
|
|
217
|
+
</Field>
|
|
218
|
+
<Field orientation="vertical">
|
|
219
|
+
<FieldLabel class="text-xs text-zinc-500">
|
|
220
|
+
<template
|
|
221
|
+
v-if="fieldDescription('disabled')"
|
|
222
|
+
#tooltip
|
|
223
|
+
>
|
|
224
|
+
<Markdown
|
|
225
|
+
:source="fieldDescription('disabled')"
|
|
226
|
+
block
|
|
227
|
+
class="prose prose-sm prose-zinc"
|
|
228
|
+
/>
|
|
229
|
+
</template>
|
|
230
|
+
{{ fieldTitle("disabled") }}
|
|
231
|
+
</FieldLabel>
|
|
232
|
+
<ExpressionEditor
|
|
233
|
+
v-model="disabledModel"
|
|
234
|
+
placeholder="例:row.locked"
|
|
235
|
+
result-type="bool"
|
|
236
|
+
:extra-vars="ROW_VARS"
|
|
237
|
+
/>
|
|
238
|
+
</Field>
|
|
239
|
+
<Field orientation="vertical">
|
|
240
|
+
<FieldLabel class="text-xs text-zinc-500">
|
|
241
|
+
<template
|
|
242
|
+
v-if="fieldDescription('readonly')"
|
|
243
|
+
#tooltip
|
|
244
|
+
>
|
|
245
|
+
<Markdown
|
|
246
|
+
:source="fieldDescription('readonly')"
|
|
247
|
+
block
|
|
248
|
+
class="prose prose-sm prose-zinc"
|
|
249
|
+
/>
|
|
250
|
+
</template>
|
|
251
|
+
{{ fieldTitle("readonly") }}
|
|
252
|
+
</FieldLabel>
|
|
253
|
+
<ExpressionEditor
|
|
254
|
+
v-model="readonlyModel"
|
|
255
|
+
placeholder="例:row.id != null"
|
|
256
|
+
result-type="bool"
|
|
257
|
+
:extra-vars="ROW_VARS"
|
|
258
|
+
/>
|
|
259
|
+
</Field>
|
|
260
|
+
<Field
|
|
261
|
+
orientation="vertical"
|
|
262
|
+
class="col-span-2"
|
|
263
|
+
>
|
|
264
|
+
<FieldLabel class="text-xs text-zinc-500">
|
|
265
|
+
<template
|
|
266
|
+
v-if="fieldDescription('derived')"
|
|
267
|
+
#tooltip
|
|
268
|
+
>
|
|
269
|
+
<Markdown
|
|
270
|
+
:source="fieldDescription('derived')"
|
|
271
|
+
block
|
|
272
|
+
class="prose prose-sm prose-zinc"
|
|
273
|
+
/>
|
|
274
|
+
</template>
|
|
275
|
+
{{ fieldTitle("derived") }}
|
|
276
|
+
</FieldLabel>
|
|
277
|
+
<DerivedValueEditor
|
|
278
|
+
v-model="derivedModel"
|
|
279
|
+
result-type="bool"
|
|
280
|
+
placeholder="例:row.quantity > 0"
|
|
281
|
+
/>
|
|
282
|
+
</Field>
|
|
283
|
+
</div>
|
|
284
|
+
<Separator />
|
|
285
|
+
<div class="flex flex-wrap gap-x-8 gap-y-3">
|
|
286
|
+
<Field
|
|
287
|
+
orientation="horizontal"
|
|
288
|
+
class="w-auto gap-2"
|
|
289
|
+
>
|
|
290
|
+
<Switch
|
|
291
|
+
:model-value="value.enableSorting ?? false"
|
|
292
|
+
@update:model-value="(v) => value.enableSorting = v"
|
|
293
|
+
/>
|
|
294
|
+
<FieldLabel class="text-sm text-zinc-600">
|
|
295
|
+
<template
|
|
296
|
+
v-if="fieldDescription('enableSorting')"
|
|
297
|
+
#tooltip
|
|
298
|
+
>
|
|
299
|
+
<Markdown
|
|
300
|
+
:source="fieldDescription('enableSorting')"
|
|
301
|
+
block
|
|
302
|
+
class="prose prose-sm prose-zinc"
|
|
303
|
+
/>
|
|
304
|
+
</template>
|
|
305
|
+
{{ fieldTitle("enableSorting") }}
|
|
306
|
+
</FieldLabel>
|
|
307
|
+
</Field>
|
|
308
|
+
</div>
|
|
309
|
+
</div>
|
|
310
|
+
</template>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type __VLS_ModelProps = {
|
|
2
|
+
modelValue: Record<string, any>;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
5
|
+
"update:modelValue": (value: Record<string, any>) => any;
|
|
6
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
|
|
7
|
+
"onUpdate:modelValue"?: ((value: Record<string, any>) => any) | undefined;
|
|
8
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
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;
|
package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/runtime.vue
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { computed } from "vue";
|
|
4
|
+
import { useI18n } from "vue-i18n";
|
|
5
|
+
import { cel as _rawCel } from "../../../../../utils/cel";
|
|
6
|
+
import { celBindings, injectCELContext } from "../../../../../utils/cel-context";
|
|
7
|
+
import { getLocalizedText } from "../../../../../share/locale";
|
|
8
|
+
import { Switch } from "../../../../ui/switch";
|
|
9
|
+
import { useFieldValue } from "../../../../form/utils/field-value";
|
|
10
|
+
defineOptions({ name: "ShwfedTableSwitchRendererRuntime" });
|
|
11
|
+
const props = defineProps({
|
|
12
|
+
column: { type: null, required: true },
|
|
13
|
+
ctx: { type: Object, required: true }
|
|
14
|
+
});
|
|
15
|
+
const { locale } = useI18n();
|
|
16
|
+
const inherited = injectCELContext();
|
|
17
|
+
const $cel = (expression, context) => _rawCel(expression, { ...celBindings(inherited), ...context });
|
|
18
|
+
function evalBool(expression, label) {
|
|
19
|
+
if (!expression) return false;
|
|
20
|
+
try {
|
|
21
|
+
return Effect.runSync($cel(expression)) === true;
|
|
22
|
+
} catch (e) {
|
|
23
|
+
console.error(`[shwfed-table] switch ${label} failed`, e);
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const isHidden = computed(() => evalBool(props.column.hidden, "hidden"));
|
|
28
|
+
const isDisabled = computed(() => evalBool(props.column.disabled, "disabled"));
|
|
29
|
+
const isReadonly = computed(() => evalBool(props.column.readonly, "readonly"));
|
|
30
|
+
const effectiveReadonly = computed(
|
|
31
|
+
() => isReadonly.value || props.column.derived?.mode === "formula"
|
|
32
|
+
);
|
|
33
|
+
const trueText = computed(
|
|
34
|
+
() => getLocalizedText(props.column.trueLabel, locale.value) || "\u662F"
|
|
35
|
+
);
|
|
36
|
+
const falseText = computed(
|
|
37
|
+
() => getLocalizedText(props.column.falseLabel, locale.value) || "\u5426"
|
|
38
|
+
);
|
|
39
|
+
const { draft, commit } = useFieldValue({
|
|
40
|
+
binding: () => props.column.binding,
|
|
41
|
+
fromState: (raw) => raw === true,
|
|
42
|
+
toState: (next) => next === true
|
|
43
|
+
});
|
|
44
|
+
function onUpdate(next) {
|
|
45
|
+
draft.value = next;
|
|
46
|
+
commit();
|
|
47
|
+
}
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<template>
|
|
51
|
+
<!--
|
|
52
|
+
Row budget matches the editable text/number cells: 2px outer inset around
|
|
53
|
+
an `h-7` (28px) row — 32px total. The switch is centered inside that row;
|
|
54
|
+
`sm` size (h-3.5) keeps it visually compact against the surrounding cells.
|
|
55
|
+
Every branch (hidden / readonly / editable) is sized identically so rows
|
|
56
|
+
do not jump when a CEL condition flips.
|
|
57
|
+
-->
|
|
58
|
+
<div class="p-[0.125rem] w-full">
|
|
59
|
+
<span
|
|
60
|
+
v-if="isHidden"
|
|
61
|
+
class="block h-7 w-full"
|
|
62
|
+
/>
|
|
63
|
+
<span
|
|
64
|
+
v-else-if="effectiveReadonly"
|
|
65
|
+
class="flex items-center justify-center h-7 w-full px-2 text-[0.75rem] text-zinc-700 truncate"
|
|
66
|
+
>
|
|
67
|
+
{{ draft ? trueText : falseText }}
|
|
68
|
+
</span>
|
|
69
|
+
<span
|
|
70
|
+
v-else
|
|
71
|
+
class="flex items-center justify-center h-7 w-full"
|
|
72
|
+
>
|
|
73
|
+
<Switch
|
|
74
|
+
size="sm"
|
|
75
|
+
:model-value="draft"
|
|
76
|
+
:disabled="isDisabled"
|
|
77
|
+
@update:model-value="onUpdate"
|
|
78
|
+
/>
|
|
79
|
+
</span>
|
|
80
|
+
</div>
|
|
81
|
+
</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;
|
package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/schema.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
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.switch";
|
|
6
|
+
export declare const compatibilityDate: "2026-05-20";
|
|
7
|
+
export declare const metadata: {
|
|
8
|
+
readonly name: "开关";
|
|
9
|
+
readonly icon: "fluent:toggle-left-20-regular";
|
|
10
|
+
};
|
|
11
|
+
export declare function schema(configure: (env: Environment) => void): Schema.Struct<{
|
|
12
|
+
hidden: Schema.optional<Schema.Schema<string, string, never>>;
|
|
13
|
+
disabled: Schema.optional<Schema.Schema<string, string, never>>;
|
|
14
|
+
readonly: Schema.optional<Schema.Schema<string, string, never>>;
|
|
15
|
+
trueLabel: Schema.optional<Schema.TupleType<readonly [Schema.Struct<{
|
|
16
|
+
locale: Schema.Literal<["zh"]>;
|
|
17
|
+
message: Schema.SchemaClass<string, string, never>;
|
|
18
|
+
}>], [Schema.Struct<{
|
|
19
|
+
locale: Schema.Literal<["ja", "en", "ko"]>;
|
|
20
|
+
message: Schema.SchemaClass<string, string, never>;
|
|
21
|
+
}>]>>;
|
|
22
|
+
falseLabel: 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
|
+
derived: Schema.optional<Schema.Struct<{
|
|
30
|
+
mode: Schema.Literal<["formula", "prefill"]>;
|
|
31
|
+
expression: Schema.Schema<string, string, never>;
|
|
32
|
+
}>>;
|
|
33
|
+
title: Schema.TupleType<readonly [Schema.Struct<{
|
|
34
|
+
locale: Schema.Literal<["zh"]>;
|
|
35
|
+
message: Schema.SchemaClass<string, string, never>;
|
|
36
|
+
}>], [Schema.Struct<{
|
|
37
|
+
locale: Schema.Literal<["ja", "en", "ko"]>;
|
|
38
|
+
message: Schema.SchemaClass<string, string, never>;
|
|
39
|
+
}>]>;
|
|
40
|
+
binding: Schema.refine<string, typeof Schema.String>;
|
|
41
|
+
enableSorting: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
42
|
+
size: Schema.optional<Schema.refine<number, Schema.filter<typeof Schema.Number>>>;
|
|
43
|
+
grow: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
44
|
+
tooltip: Schema.optional<Schema.TupleType<readonly [Schema.Struct<{
|
|
45
|
+
locale: Schema.Literal<["zh"]>;
|
|
46
|
+
message: Schema.SchemaClass<string, string, never>;
|
|
47
|
+
}>], [Schema.Struct<{
|
|
48
|
+
locale: Schema.Literal<["ja", "en", "ko"]>;
|
|
49
|
+
message: Schema.SchemaClass<string, string, never>;
|
|
50
|
+
}>]>>;
|
|
51
|
+
id: Schema.refine<string, typeof Schema.String>;
|
|
52
|
+
groupId: Schema.optional<typeof Schema.UUID>;
|
|
53
|
+
type: Schema.Literal<["com.shwfed.table.column.switch"]>;
|
|
54
|
+
compatibilityDate: Schema.Literal<["2026-05-20"]>;
|
|
55
|
+
}>;
|
|
56
|
+
export type Value = Schema.Schema.Type<ReturnType<typeof schema>>;
|
|
57
|
+
export declare function toColumnDef(value: Value, { getLocaleText }: ColumnDefDeps): Partial<ColumnDef<unknown, unknown>>;
|
package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/schema.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { getProperty } from "dot-prop";
|
|
3
|
+
import { Locale } from "../../../../../share/locale.js";
|
|
4
|
+
import { CelRowAccess, derivedRowField, editableColumnFields, editableHeader } from "../../../utils/shared.js";
|
|
5
|
+
export const type = "com.shwfed.table.column.switch";
|
|
6
|
+
export const compatibilityDate = "2026-05-20";
|
|
7
|
+
export const metadata = {
|
|
8
|
+
name: "\u5F00\u5173",
|
|
9
|
+
icon: "fluent:toggle-left-20-regular"
|
|
10
|
+
};
|
|
11
|
+
export function schema(configure) {
|
|
12
|
+
const CelBool = CelRowAccess(configure, { resultType: "bool" });
|
|
13
|
+
return Schema.Struct({
|
|
14
|
+
type: Schema.Literal(type),
|
|
15
|
+
compatibilityDate: Schema.Literal(compatibilityDate),
|
|
16
|
+
...editableColumnFields(),
|
|
17
|
+
hidden: Schema.optional(CelBool.annotations({
|
|
18
|
+
title: "\u9690\u85CF\u6761\u4EF6",
|
|
19
|
+
description: "\u8FD4\u56DE `true` \u65F6\u8BE5\u884C\u7684\u5F00\u5173\u4E0D\u6E32\u67D3\uFF08\u5176\u4F59\u884C\u4E0D\u53D7\u5F71\u54CD\uFF09"
|
|
20
|
+
})),
|
|
21
|
+
disabled: Schema.optional(CelBool.annotations({
|
|
22
|
+
title: "\u7981\u7528\u6761\u4EF6",
|
|
23
|
+
description: "\u8FD4\u56DE `true` \u65F6\u5F00\u5173\u4ECD\u7136\u6E32\u67D3\u4F46\u4E0D\u53EF\u5207\u6362"
|
|
24
|
+
})),
|
|
25
|
+
readonly: Schema.optional(CelBool.annotations({
|
|
26
|
+
title: "\u53EA\u8BFB\u6761\u4EF6",
|
|
27
|
+
description: "\u8FD4\u56DE `true` \u65F6\u4EC5\u4EE5\u7EAF\u6587\u672C\u5C55\u793A\u5F53\u524D\u503C"
|
|
28
|
+
})),
|
|
29
|
+
trueLabel: Schema.optional(Locale.annotations({
|
|
30
|
+
title: "\u5F00\u542F\u6587\u6848",
|
|
31
|
+
description: "\u53EA\u8BFB\u72B6\u6001\u4E0B\uFF0C\u503C\u4E3A `true` \u65F6\u5C55\u793A\u7684\u6587\u672C\uFF1B\u7559\u7A7A\u4F7F\u7528\u9ED8\u8BA4 `\u662F`"
|
|
32
|
+
})),
|
|
33
|
+
falseLabel: Schema.optional(Locale.annotations({
|
|
34
|
+
title: "\u5173\u95ED\u6587\u6848",
|
|
35
|
+
description: "\u53EA\u8BFB\u72B6\u6001\u4E0B\uFF0C\u503C\u4E3A `false` \u65F6\u5C55\u793A\u7684\u6587\u672C\uFF1B\u7559\u7A7A\u4F7F\u7528\u9ED8\u8BA4 `\u5426`"
|
|
36
|
+
})),
|
|
37
|
+
derived: derivedRowField(configure, "bool")
|
|
38
|
+
}).annotations({ title: "SwitchRenderer", description: "\u5F00\u5173\u6E32\u67D3\u5668\uFF08\u53EF\u7F16\u8F91\u3001\u672C\u5730\uFF09" });
|
|
39
|
+
}
|
|
40
|
+
export function toColumnDef(value, { getLocaleText }) {
|
|
41
|
+
return {
|
|
42
|
+
header: editableHeader(getLocaleText(value.title)),
|
|
43
|
+
// `binding` is a dot-prop path (validated non-empty); the cell renderer
|
|
44
|
+
// reads through the same path it writes to. No CEL — accessor is literal.
|
|
45
|
+
accessorFn: (row) => {
|
|
46
|
+
if (!row || typeof row !== "object") return void 0;
|
|
47
|
+
return getProperty(row, value.binding);
|
|
48
|
+
},
|
|
49
|
+
enableSorting: value.enableSorting ?? false,
|
|
50
|
+
// `basic` orders by JS `<` — for booleans that yields `false < true`,
|
|
51
|
+
// which is the obvious grouping. Mirrors the remote switch column.
|
|
52
|
+
sortingFn: "basic",
|
|
53
|
+
size: value.size,
|
|
54
|
+
meta: {
|
|
55
|
+
grow: value.grow ?? false,
|
|
56
|
+
tooltip: getLocaleText(value.tooltip)
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type __VLS_ModelProps = {
|
|
2
|
+
modelValue: Record<string, any>;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
5
|
+
"update:modelValue": (value: Record<string, any>) => any;
|
|
6
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
|
|
7
|
+
"onUpdate:modelValue"?: ((value: Record<string, any>) => any) | undefined;
|
|
8
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type __VLS_ModelProps = {
|
|
2
|
+
modelValue: Record<string, any>;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
5
|
+
"update:modelValue": (value: Record<string, any>) => any;
|
|
6
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
|
|
7
|
+
"onUpdate:modelValue"?: ((value: Record<string, any>) => any) | undefined;
|
|
8
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
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;
|