@shwfed/config 2.1.0 → 2.1.1
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/runtime/components/form/ai/fields-button.d.vue.ts +13 -0
- package/dist/runtime/components/form/ai/fields-button.vue +458 -0
- package/dist/runtime/components/form/ai/fields-button.vue.d.ts +13 -0
- package/dist/runtime/components/form/ai/fields-task.md +71 -0
- package/dist/runtime/components/form/config.d.vue.ts +1 -1
- package/dist/runtime/components/form/config.vue +4 -36
- package/dist/runtime/components/form/config.vue.d.ts +1 -1
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.daterange/config.d.vue.ts +18 -18
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.daterange/config.vue.d.ts +18 -18
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.datetime/config.d.vue.ts +4 -4
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.datetime/config.vue.d.ts +4 -4
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.datetimerange/config.d.vue.ts +22 -22
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.datetimerange/config.vue.d.ts +22 -22
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.time/config.d.vue.ts +2 -2
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.time/config.vue.d.ts +2 -2
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.timerange/config.d.vue.ts +4 -4
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.timerange/config.vue.d.ts +4 -4
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.numberrange/config.d.vue.ts +12 -12
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.numberrange/config.vue +87 -11
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.numberrange/config.vue.d.ts +12 -12
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.numberrange/runtime.vue +18 -6
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.numberrange/schema.d.ts +1 -1
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.numberrange/schema.js +11 -4
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.switch/config.d.vue.ts +10 -10
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.switch/config.vue.d.ts +10 -10
- package/dist/runtime/components/form/fields/2026-05-12/com.shwfed.form.field.upload/config.d.vue.ts +12 -12
- package/dist/runtime/components/form/fields/2026-05-12/com.shwfed.form.field.upload/config.vue.d.ts +12 -12
- package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/config.d.vue.ts +2 -2
- package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/config.vue +15 -0
- package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/config.vue.d.ts +2 -2
- package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/row.d.vue.ts +1 -0
- package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/row.vue +13 -4
- package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/row.vue.d.ts +1 -0
- package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/runtime.vue +1 -0
- package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/schema.d.ts +1 -1
- package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/schema.js +5 -1
- package/dist/runtime/components/form/index.vue +5 -4
- package/dist/runtime/components/form/unit-config.d.vue.ts +16 -0
- package/dist/runtime/components/form/unit-config.vue +30 -3
- package/dist/runtime/components/form/unit-config.vue.d.ts +16 -0
- package/dist/runtime/components/form/utils/cel-scope.d.ts +13 -0
- package/dist/runtime/components/form/utils/cel-scope.js +32 -0
- package/dist/runtime/components/form/utils/schema-meta.d.ts +13 -0
- package/dist/runtime/components/form/utils/schema-meta.js +15 -0
- package/dist/runtime/components/table/ai/columns-task.md +10 -1
- package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.markdown/config.vue +2 -2
- package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.markdown/runtime.vue +14 -4
- package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.markdown/schema.js +3 -2
- package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.text/config.vue +2 -2
- package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.text/runtime.vue +14 -4
- package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.text/schema.js +3 -2
- package/dist/runtime/components/table/utils/shared.d.ts +2 -1
- package/dist/runtime/components/ui/date-range-picker/DateRangePickerDateTimePanel.d.vue.ts +1 -1
- package/dist/runtime/components/ui/date-range-picker/DateRangePickerDateTimePanel.vue.d.ts +1 -1
- package/dist/runtime/components/ui/date-range-picker/DateRangePickerTimeInput.d.vue.ts +1 -1
- package/dist/runtime/components/ui/date-range-picker/DateRangePickerTimeInput.vue.d.ts +1 -1
- package/dist/runtime/share/expression.d.ts +1 -2
- package/dist/runtime/share/slot-renderer.vue +7 -6
- package/dist/runtime/vendor/cel-js/CLAUDE.md +1 -1
- package/dist/runtime/vendor/cel-js/PROMPT.md +6 -1
- package/dist/runtime/vendor/cel-js/lib/http-builder.d.ts +3 -2
- package/dist/runtime/vendor/cel-js/lib/http-builtins.d.ts +4 -3
- package/dist/runtime/vendor/cel-js/lib/http-builtins.js +4 -0
- package/package.json +1 -1
|
@@ -167,15 +167,16 @@ const gridStyle = computed(() => {
|
|
|
167
167
|
const hi = Math.min(l.rows, y2 - 1);
|
|
168
168
|
for (let r = lo; r <= hi; r++) grows[r - 1] = true;
|
|
169
169
|
}
|
|
170
|
-
rowTemplate = grows.map((g) => g ? "auto" : "minmax(
|
|
170
|
+
rowTemplate = grows.map((g) => g ? "auto" : "minmax(auto, 1fr)").join(" ");
|
|
171
171
|
}
|
|
172
|
+
const gap = `calc(${l.gap ?? DEFAULT_GAP} * 0.25rem)`;
|
|
173
|
+
const colGap = l.columns > 1 ? `min(${gap}, calc(100% / ${l.columns - 1}))` : gap;
|
|
172
174
|
const parts = [
|
|
173
175
|
"display: grid",
|
|
174
176
|
`grid-template-columns: ${colTemplate}`,
|
|
175
177
|
rowTemplate ? `grid-template-rows: ${rowTemplate}` : "",
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
`gap: calc(${l.gap ?? DEFAULT_GAP} * 0.25rem)`,
|
|
178
|
+
`column-gap: ${colGap}`,
|
|
179
|
+
`row-gap: ${gap}`,
|
|
179
180
|
l.style ?? ""
|
|
180
181
|
].filter(Boolean);
|
|
181
182
|
return parts.join("; ");
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { type CELContext } from '../../utils/cel-context.js';
|
|
1
2
|
import type { FieldValue, FormUnitValue } from './schema.js';
|
|
3
|
+
import type { Environment } from '../../vendor/cel-js/lib/index.js';
|
|
2
4
|
export type UnitExtra = {
|
|
3
5
|
id: string;
|
|
4
6
|
label: string;
|
|
@@ -17,6 +19,20 @@ type __VLS_Props = {
|
|
|
17
19
|
* v-model — hosts read which extra is active via `selection.value`.
|
|
18
20
|
*/
|
|
19
21
|
extras?: ReadonlyArray<UnitExtra>;
|
|
22
|
+
/**
|
|
23
|
+
* Host-registered CEL variables. Forwarded to the drilled field-list's
|
|
24
|
+
* "AI 生成字段" button so the model can advertise host variables in
|
|
25
|
+
* generated expressions. Absent → only `form` / `now` are in scope.
|
|
26
|
+
*/
|
|
27
|
+
configure?: (env: Environment) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Extra CEL variables in scope for the unit's *field* editors — the list
|
|
30
|
+
* field passes `item` (the current row). Advertised to every drilled field
|
|
31
|
+
* config's ExpressionEditor via `provideCELContext` below; the host's own
|
|
32
|
+
* `extras-pane` slot is excluded, since slotted content injects through the
|
|
33
|
+
* host component, above this provide.
|
|
34
|
+
*/
|
|
35
|
+
fieldCelScope?: CELContext;
|
|
20
36
|
};
|
|
21
37
|
type __VLS_Slots = {
|
|
22
38
|
/** Pane content for the currently-selected extra. Receives `{ id }`. */
|
|
@@ -6,7 +6,8 @@ import { computed, inject, onBeforeUnmount, provide, ref, useTemplateRef, watch
|
|
|
6
6
|
import { toast } from "vue-sonner";
|
|
7
7
|
import {
|
|
8
8
|
celBindings,
|
|
9
|
-
injectCELContext
|
|
9
|
+
injectCELContext,
|
|
10
|
+
provideCELContext
|
|
10
11
|
} from "../../utils/cel-context";
|
|
11
12
|
import { findFreePlacement, normalizeLayoutSet } from "../../share/layout";
|
|
12
13
|
import { getLocalizedText } from "../../share/locale";
|
|
@@ -20,13 +21,16 @@ import { Button } from "../ui/button";
|
|
|
20
21
|
import { ScrollArea } from "../ui/scroll-area";
|
|
21
22
|
import { Separator } from "../ui/separator";
|
|
22
23
|
import { FIELDS, findField } from "./utils/resolve";
|
|
24
|
+
import ShwfedFormAiFieldsButton from "./ai/fields-button.vue";
|
|
23
25
|
defineOptions({ name: "ShwfedFormUnitConfig" });
|
|
24
26
|
const unit = defineModel({ type: Object, ...{ required: true } });
|
|
25
27
|
const selection = defineModel("selection", { type: Object, ...{
|
|
26
28
|
default: () => ({ kind: "layout" })
|
|
27
29
|
} });
|
|
28
|
-
defineProps({
|
|
29
|
-
extras: { type: Array, required: false }
|
|
30
|
+
const props = defineProps({
|
|
31
|
+
extras: { type: Array, required: false },
|
|
32
|
+
configure: { type: Function, required: false },
|
|
33
|
+
fieldCelScope: { type: Object, required: false }
|
|
30
34
|
});
|
|
31
35
|
defineSlots();
|
|
32
36
|
const activeLayoutIndex = ref(0);
|
|
@@ -40,6 +44,7 @@ function popOne() {
|
|
|
40
44
|
const breadcrumbExt = inject(BREADCRUMB_EXTENSION_KEY, null);
|
|
41
45
|
const fullPane = ref(false);
|
|
42
46
|
provide(FORM_FIELD_LAYOUT_KEY, { fullPane });
|
|
47
|
+
provideCELContext(props.fieldCelScope ?? {});
|
|
43
48
|
const takeover = inject(SIDEBAR_TAKEOVER_KEY, null);
|
|
44
49
|
const takeoverTarget = computed(() => takeover?.target.value ?? null);
|
|
45
50
|
const activeFieldId = computed(() => {
|
|
@@ -171,6 +176,16 @@ function removeFields(ids) {
|
|
|
171
176
|
stack.value = stack.value.slice(0, -1);
|
|
172
177
|
}
|
|
173
178
|
}
|
|
179
|
+
function applyAiFields(generated) {
|
|
180
|
+
const valid = generated.filter(
|
|
181
|
+
(f) => !!findField(f.type, f.compatibilityDate)
|
|
182
|
+
);
|
|
183
|
+
if (valid.length === 0) return;
|
|
184
|
+
unit.value = {
|
|
185
|
+
...unit.value,
|
|
186
|
+
fields: [...unit.value.fields, ...valid]
|
|
187
|
+
};
|
|
188
|
+
}
|
|
174
189
|
function updateActiveField(next) {
|
|
175
190
|
const id = activeFieldId.value;
|
|
176
191
|
if (!id) return;
|
|
@@ -311,6 +326,12 @@ function isExtraActive(id) {
|
|
|
311
326
|
</button>
|
|
312
327
|
</div>
|
|
313
328
|
</ScrollArea>
|
|
329
|
+
|
|
330
|
+
<ShwfedFormAiFieldsButton
|
|
331
|
+
:configure="configure"
|
|
332
|
+
:fields="unit.fields"
|
|
333
|
+
@apply="applyAiFields"
|
|
334
|
+
/>
|
|
314
335
|
</template>
|
|
315
336
|
</Teleport>
|
|
316
337
|
|
|
@@ -388,6 +409,12 @@ function isExtraActive(id) {
|
|
|
388
409
|
</button>
|
|
389
410
|
</div>
|
|
390
411
|
</ScrollArea>
|
|
412
|
+
|
|
413
|
+
<ShwfedFormAiFieldsButton
|
|
414
|
+
:configure="configure"
|
|
415
|
+
:fields="unit.fields"
|
|
416
|
+
@apply="applyAiFields"
|
|
417
|
+
/>
|
|
391
418
|
</template>
|
|
392
419
|
</div>
|
|
393
420
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { type CELContext } from '../../utils/cel-context.js';
|
|
1
2
|
import type { FieldValue, FormUnitValue } from './schema.js';
|
|
3
|
+
import type { Environment } from '../../vendor/cel-js/lib/index.js';
|
|
2
4
|
export type UnitExtra = {
|
|
3
5
|
id: string;
|
|
4
6
|
label: string;
|
|
@@ -17,6 +19,20 @@ type __VLS_Props = {
|
|
|
17
19
|
* v-model — hosts read which extra is active via `selection.value`.
|
|
18
20
|
*/
|
|
19
21
|
extras?: ReadonlyArray<UnitExtra>;
|
|
22
|
+
/**
|
|
23
|
+
* Host-registered CEL variables. Forwarded to the drilled field-list's
|
|
24
|
+
* "AI 生成字段" button so the model can advertise host variables in
|
|
25
|
+
* generated expressions. Absent → only `form` / `now` are in scope.
|
|
26
|
+
*/
|
|
27
|
+
configure?: (env: Environment) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Extra CEL variables in scope for the unit's *field* editors — the list
|
|
30
|
+
* field passes `item` (the current row). Advertised to every drilled field
|
|
31
|
+
* config's ExpressionEditor via `provideCELContext` below; the host's own
|
|
32
|
+
* `extras-pane` slot is excluded, since slotted content injects through the
|
|
33
|
+
* host component, above this provide.
|
|
34
|
+
*/
|
|
35
|
+
fieldCelScope?: CELContext;
|
|
20
36
|
};
|
|
21
37
|
type __VLS_Slots = {
|
|
22
38
|
/** Pane content for the currently-selected extra. Receives `{ id }`. */
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Environment } from '../../../vendor/cel-js/lib/index.js';
|
|
2
|
+
import type { CELContext } from '../../../utils/cel-context.js';
|
|
3
|
+
/**
|
|
4
|
+
* Builds the CEL variable scope advertised to a form's expression editors and
|
|
5
|
+
* AI assists. Seeds the form-wide `form` / `now` live variables, then probes a
|
|
6
|
+
* throwaway `Environment` with the host's `configure` to surface any
|
|
7
|
+
* host-registered variables (their type / label / description).
|
|
8
|
+
*
|
|
9
|
+
* Values are left `undefined` — this scope is for designer-time advertising
|
|
10
|
+
* and prompt rendering, never evaluation. Extracted from `form/config.vue` so
|
|
11
|
+
* the field-list AI button can reuse the exact same scope.
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildFormCelScope(configure: (env: Environment) => void): CELContext;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Environment } from "../../../vendor/cel-js/lib/index.js";
|
|
2
|
+
export function buildFormCelScope(configure) {
|
|
3
|
+
const probe = new Environment({ unlistedVariablesAreDyn: false });
|
|
4
|
+
const baseline = new Set(probe.getDefinitions().variables.map((v) => v.name));
|
|
5
|
+
configure(probe);
|
|
6
|
+
const out = {
|
|
7
|
+
form: {
|
|
8
|
+
type: "dyn",
|
|
9
|
+
label: "\u8868\u5355\u503C",
|
|
10
|
+
description: "\u5F53\u524D\u8868\u5355\u72B6\u6001",
|
|
11
|
+
value: void 0
|
|
12
|
+
},
|
|
13
|
+
// Mirrors the runtime `now` binding in `form/index.vue`. Editors and
|
|
14
|
+
// prompts never evaluate, so we leave `value` undefined.
|
|
15
|
+
now: {
|
|
16
|
+
type: "Date",
|
|
17
|
+
label: "now",
|
|
18
|
+
description: "\u5F53\u524D\u65E5\u671F/\u65F6\u95F4",
|
|
19
|
+
value: void 0
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
for (const v of probe.getDefinitions().variables) {
|
|
23
|
+
if (baseline.has(v.name)) continue;
|
|
24
|
+
out[v.name] = {
|
|
25
|
+
type: v.type,
|
|
26
|
+
label: v.label ?? v.name,
|
|
27
|
+
description: v.description ?? void 0,
|
|
28
|
+
value: void 0
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
@@ -2,4 +2,17 @@ import { type Schema } from 'effect';
|
|
|
2
2
|
type AnySchema = Schema.Schema<any, any, any>;
|
|
3
3
|
export declare function getStructFieldTitle(schema: AnySchema, fieldName: string): string | undefined;
|
|
4
4
|
export declare function getStructFieldDescription(schema: AnySchema, fieldName: string): string | undefined;
|
|
5
|
+
export type StructFieldInfo = {
|
|
6
|
+
name: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
optional: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Lists a struct schema's property signatures, pairing each with its `@title` /
|
|
13
|
+
* `@description` annotation and optionality. Used to auto-derive the per-field
|
|
14
|
+
* documentation surfaced to the AI field generator — a new field folder becomes
|
|
15
|
+
* discoverable with zero edits there. Returns `[]` for non-struct schemas.
|
|
16
|
+
*/
|
|
17
|
+
export declare function listStructFields(schema: AnySchema): StructFieldInfo[];
|
|
5
18
|
export {};
|
|
@@ -46,3 +46,18 @@ export function getStructFieldTitle(schema, fieldName) {
|
|
|
46
46
|
export function getStructFieldDescription(schema, fieldName) {
|
|
47
47
|
return getFieldAnnotation(schema, fieldName, SchemaAST.getDescriptionAnnotation);
|
|
48
48
|
}
|
|
49
|
+
export function listStructFields(schema) {
|
|
50
|
+
const tl = getTypeLiteral(schema.ast);
|
|
51
|
+
if (!tl) return [];
|
|
52
|
+
return tl.propertySignatures.map((ps) => {
|
|
53
|
+
const name = String(ps.name);
|
|
54
|
+
const title = getStructFieldTitle(schema, name);
|
|
55
|
+
const description = getStructFieldDescription(schema, name);
|
|
56
|
+
return {
|
|
57
|
+
name,
|
|
58
|
+
...title !== void 0 ? { title } : {},
|
|
59
|
+
...description !== void 0 ? { description } : {},
|
|
60
|
+
optional: ps.isOptional
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
}
|
|
@@ -4,7 +4,7 @@ The `columns` array is a **full replacement**: whatever you emit becomes the ent
|
|
|
4
4
|
|
|
5
5
|
# Hard rules
|
|
6
6
|
|
|
7
|
-
1. **NEVER**
|
|
7
|
+
1. **NEVER add** a new column with `type === "com.shwfed.table.column.actions"`. Action columns are wired by a separate registry — you cannot synthesize one, and a fabricated actions column will be rejected and you will be retried. The **one exception**: if the current configuration already contains an actions column, echo it back verbatim (same `id`, `type`, `compatibilityDate`, and all fields) in its render position. Never invent an actions column the user merely describes when none already exists.
|
|
8
8
|
2. **ONLY** emit a column with `type === "com.shwfed.table.column.markdown"` when the user **explicitly** asks for markdown / rich content / formatted body / 富文本 / Markdown. Otherwise prefer `com.shwfed.table.column.text`.
|
|
9
9
|
3. **NEVER** set `enableSorting: true`. Client-side sorting is rarely the right call in practice (paginated/server-driven data, mixed types, etc.) and the user should opt in manually. Omit the field or set it to `false`.
|
|
10
10
|
4. **NEVER** wrap the `accessor` in type coercions (`string(...)`, `int(...)`, `double(...)`) and **NEVER** supply a default via `.orValue(...)`. Emit the bare optional access — e.g. `row.?name`, `row.?age`. Coercion and defaults make it impossible for the user to distinguish real data from filler, which is actively harmful.
|
|
@@ -41,4 +41,13 @@ Always use optional access (`row.?field`) rather than `row.field` to avoid runti
|
|
|
41
41
|
|
|
42
42
|
If the user gives a sample response, derive accessors directly from its shape. Otherwise, infer field names from the user's prose (e.g. "show name and email" → `row.?name`, `row.?email`).
|
|
43
43
|
|
|
44
|
+
# Rendering recipes
|
|
45
|
+
|
|
46
|
+
**Boolean / `0`-`1` values.** When a field is a boolean or a `0`/`1` flag (e.g. `enabled`, `isActive`, a `0/1` status), render it with `com.shwfed.table.column.icon` rather than `text` — a green check / red cross reads far faster than the literal `true` or `1`. Build both the `accessor` and the `color` as CEL ternaries on the condition:
|
|
47
|
+
|
|
48
|
+
- `accessor`: `<condition> ? 'fluent:checkmark-20-filled' : 'fluent:dismiss-20-filled'`
|
|
49
|
+
- `color`: `<condition> ? '#00c950' : '#fb2c36'`
|
|
50
|
+
|
|
51
|
+
where `<condition>` is a bare optional-access test — `row.?enabled == true` for a boolean field, `row.?status == 1` for a `0/1` field. This is a comparison, not a coercion, so hard rule 4 still holds: do not wrap in `string(...)`/`int(...)` or add `.orValue(...)`.
|
|
52
|
+
|
|
44
53
|
The current configuration (existing data source + columns) is appended to the user prompt under `Current configuration`. Use it only to (a) reuse existing column `id`s where the user's described column clearly corresponds to an existing one, and (b) inform field shapes (e.g. response keys). Do **not** copy columns forward that the user did not describe — the user's prompt is the source of truth for which columns should exist.
|
package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.markdown/config.vue
CHANGED
|
@@ -154,8 +154,8 @@ const copyExpressionModel = computed({
|
|
|
154
154
|
</FieldLabel>
|
|
155
155
|
<ExpressionEditor
|
|
156
156
|
v-model="copyExpressionModel"
|
|
157
|
-
placeholder="如 row.name"
|
|
158
|
-
result-type="string"
|
|
157
|
+
placeholder="如 row.name 或 row.?name"
|
|
158
|
+
:result-type="['string', 'optional']"
|
|
159
159
|
class="min-h-10"
|
|
160
160
|
/>
|
|
161
161
|
</Field>
|
|
@@ -24,12 +24,22 @@ const rendered = computed(() => {
|
|
|
24
24
|
const isEmpty = computed(() => rendered.value.trim().length === 0);
|
|
25
25
|
const align = computed(() => isEmpty.value ? "center" : props.column.align ?? "left");
|
|
26
26
|
const justifyClass = computed(() => JUSTIFY_CLASS[align.value] ?? JUSTIFY_CLASS.left);
|
|
27
|
-
const
|
|
27
|
+
const copyText = computed(() => {
|
|
28
|
+
const { copyExpression } = props.column;
|
|
29
|
+
if (!copyExpression) return void 0;
|
|
30
|
+
try {
|
|
31
|
+
const value = Effect.runSync($cel(copyExpression, celBindings(celContext)));
|
|
32
|
+
return value === void 0 || value === null ? void 0 : String(value);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
console.error("[shwfed-table] markdown copy expression failed", e);
|
|
35
|
+
return void 0;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const showCopy = computed(() => copyText.value !== void 0 && !isEmpty.value);
|
|
28
39
|
const onCopy = async () => {
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
40
|
+
const text = copyText.value;
|
|
41
|
+
if (text === void 0) return;
|
|
31
42
|
try {
|
|
32
|
-
const text = String(Effect.runSync($cel(column.copyExpression, celBindings(celContext))));
|
|
33
43
|
await navigator.clipboard.writeText(text);
|
|
34
44
|
} catch (e) {
|
|
35
45
|
console.error("[shwfed-table] markdown copy failed", e);
|
package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.markdown/schema.js
CHANGED
|
@@ -7,8 +7,9 @@ export const metadata = {
|
|
|
7
7
|
name: "MD",
|
|
8
8
|
icon: "fluent:markdown-20-regular"
|
|
9
9
|
};
|
|
10
|
+
const isCopyExpressionType = (t) => t === "string" || t === "dyn" || t.startsWith("optional");
|
|
10
11
|
export function schema(configure) {
|
|
11
|
-
const cel = CelRowAccess(configure, { resultType:
|
|
12
|
+
const cel = CelRowAccess(configure, { resultType: isCopyExpressionType });
|
|
12
13
|
const localeMarkdown = LocaleMarkdownWithRow(configure);
|
|
13
14
|
return Schema.Struct({
|
|
14
15
|
type: Schema.Literal(type),
|
|
@@ -34,7 +35,7 @@ export function schema(configure) {
|
|
|
34
35
|
}),
|
|
35
36
|
copyExpression: Schema.optional(cel.annotations({
|
|
36
37
|
title: "\u590D\u5236\u8868\u8FBE\u5F0F",
|
|
37
|
-
description: "\u590D\u5236\u503C\u7684 CEL \u8868\u8FBE\u5F0F"
|
|
38
|
+
description: "\u590D\u5236\u503C\u7684 CEL \u8868\u8FBE\u5F0F\uFF1B\u53EF\u8FD4\u56DE optional\uFF08\u5982 `row.?field`\uFF09\uFF0C\u4E3A\u7A7A\u65F6\u4E0D\u663E\u793A\u590D\u5236\u6309\u94AE"
|
|
38
39
|
}))
|
|
39
40
|
}).annotations({ title: "MarkdownRenderer", description: "MD" });
|
|
40
41
|
}
|
package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.text/config.vue
CHANGED
|
@@ -188,8 +188,8 @@ const copyExpressionModel = computed({
|
|
|
188
188
|
</FieldLabel>
|
|
189
189
|
<ExpressionEditor
|
|
190
190
|
v-model="copyExpressionModel"
|
|
191
|
-
placeholder="如 row.name"
|
|
192
|
-
result-type="string"
|
|
191
|
+
placeholder="如 row.name 或 row.?name"
|
|
192
|
+
:result-type="['string', 'optional']"
|
|
193
193
|
class="min-h-10"
|
|
194
194
|
/>
|
|
195
195
|
</Field>
|
package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.text/runtime.vue
CHANGED
|
@@ -16,12 +16,22 @@ const rawValue = computed(() => props.ctx.cell.getValue());
|
|
|
16
16
|
const isMissing = computed(() => rawValue.value === void 0 || rawValue.value === null);
|
|
17
17
|
const align = computed(() => isMissing.value ? "center" : props.column.align ?? "left");
|
|
18
18
|
const justifyClass = computed(() => JUSTIFY_CLASS[align.value] ?? JUSTIFY_CLASS.left);
|
|
19
|
-
const
|
|
19
|
+
const copyText = computed(() => {
|
|
20
|
+
const { copyExpression } = props.column;
|
|
21
|
+
if (!copyExpression) return void 0;
|
|
22
|
+
try {
|
|
23
|
+
const value = Effect.runSync($cel(copyExpression, celBindings(celContext)));
|
|
24
|
+
return value === void 0 || value === null ? void 0 : String(value);
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.error("[shwfed-table] text copy expression failed", e);
|
|
27
|
+
return void 0;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const showCopy = computed(() => copyText.value !== void 0 && !isMissing.value && rawValue.value !== "");
|
|
20
31
|
const onCopy = async () => {
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
32
|
+
const text = copyText.value;
|
|
33
|
+
if (text === void 0) return;
|
|
23
34
|
try {
|
|
24
|
-
const text = String(Effect.runSync($cel(column.copyExpression, celBindings(celContext))));
|
|
25
35
|
await navigator.clipboard.writeText(text);
|
|
26
36
|
} catch (e) {
|
|
27
37
|
console.error("[shwfed-table] text copy failed", e);
|
package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.text/schema.js
CHANGED
|
@@ -6,8 +6,9 @@ export const metadata = {
|
|
|
6
6
|
name: "\u6587\u672C",
|
|
7
7
|
icon: "fluent:text-field-20-regular"
|
|
8
8
|
};
|
|
9
|
+
const isCopyExpressionType = (t) => t === "string" || t === "dyn" || t.startsWith("optional");
|
|
9
10
|
export function schema(configure) {
|
|
10
|
-
const cel = CelRowAccess(configure, { resultType:
|
|
11
|
+
const cel = CelRowAccess(configure, { resultType: isCopyExpressionType });
|
|
11
12
|
return Schema.Struct({
|
|
12
13
|
type: Schema.Literal(type),
|
|
13
14
|
compatibilityDate: Schema.Literal(compatibilityDate),
|
|
@@ -22,7 +23,7 @@ export function schema(configure) {
|
|
|
22
23
|
),
|
|
23
24
|
copyExpression: Schema.optional(cel.annotations({
|
|
24
25
|
title: "\u590D\u5236\u8868\u8FBE\u5F0F",
|
|
25
|
-
description: "\u590D\u5236\u503C\u7684 CEL \u8868\u8FBE\u5F0F\uFF0C\u5B58\u5728\u65F6\u542F\u7528\u590D\u5236\u529F\u80FD"
|
|
26
|
+
description: "\u590D\u5236\u503C\u7684 CEL \u8868\u8FBE\u5F0F\uFF0C\u5B58\u5728\u65F6\u542F\u7528\u590D\u5236\u529F\u80FD\uFF1B\u53EF\u8FD4\u56DE optional\uFF08\u5982 `row.?field`\uFF09\uFF0C\u4E3A\u7A7A\u65F6\u4E0D\u663E\u793A\u590D\u5236\u6309\u94AE"
|
|
26
27
|
}))
|
|
27
28
|
}).annotations({ title: "TextRenderer", description: "\u6587\u672C\u6E32\u67D3\u5668" });
|
|
28
29
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
2
|
import type { Environment } from '../../../vendor/cel-js/lib/index.js';
|
|
3
|
+
import { type ResultType } from '../../../share/expression.js';
|
|
3
4
|
export declare const Align: Schema.Literal<["left", "center", "right"]>;
|
|
4
5
|
export declare function columnIdentityFields(): {
|
|
5
6
|
id: Schema.refine<string, typeof Schema.String>;
|
|
@@ -29,7 +30,7 @@ export declare function columnFields(configure: (env: Environment) => void): {
|
|
|
29
30
|
};
|
|
30
31
|
export declare function registerRowVariablesIfAbsent(env: Environment): void;
|
|
31
32
|
export declare function CelRowAccess(configure: (env: Environment) => void, options?: {
|
|
32
|
-
resultType?:
|
|
33
|
+
resultType?: ResultType;
|
|
33
34
|
}): Schema.Schema<string, string, never>;
|
|
34
35
|
export declare function LocaleMarkdownWithRow(configure: (env: Environment) => void): Schema.filter<Schema.TupleType<readonly [Schema.Struct<{
|
|
35
36
|
locale: Schema.Literal<["zh"]>;
|
|
@@ -14,10 +14,10 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
14
14
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
15
15
|
"onUpdate:modelValue"?: ((args_0: DateRange | undefined) => any) | undefined;
|
|
16
16
|
}>, {
|
|
17
|
+
rangeSeparatorIcon: string;
|
|
17
18
|
numberOfMonths: number;
|
|
18
19
|
granularity: "hour" | "minute" | "second";
|
|
19
20
|
hourCycle: 12 | 24;
|
|
20
|
-
rangeSeparatorIcon: string;
|
|
21
21
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
22
22
|
declare const _default: typeof __VLS_export;
|
|
23
23
|
export default _default;
|
|
@@ -14,10 +14,10 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
14
14
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
15
15
|
"onUpdate:modelValue"?: ((args_0: DateRange | undefined) => any) | undefined;
|
|
16
16
|
}>, {
|
|
17
|
+
rangeSeparatorIcon: string;
|
|
17
18
|
numberOfMonths: number;
|
|
18
19
|
granularity: "hour" | "minute" | "second";
|
|
19
20
|
hourCycle: 12 | 24;
|
|
20
|
-
rangeSeparatorIcon: string;
|
|
21
21
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
22
22
|
declare const _default: typeof __VLS_export;
|
|
23
23
|
export default _default;
|
|
@@ -24,11 +24,11 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
24
24
|
"onUpdate:endValue"?: ((args_0: Time | undefined) => any) | undefined;
|
|
25
25
|
}>, {
|
|
26
26
|
size: "sm" | "md" | "lg";
|
|
27
|
+
rangeSeparatorIcon: string;
|
|
27
28
|
granularity: "hour" | "minute" | "second";
|
|
28
29
|
hourCycle: 12 | 24;
|
|
29
30
|
clearable: boolean;
|
|
30
31
|
clearIcon: string;
|
|
31
|
-
rangeSeparatorIcon: string;
|
|
32
32
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
33
33
|
declare const _default: typeof __VLS_export;
|
|
34
34
|
export default _default;
|
|
@@ -24,11 +24,11 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
24
24
|
"onUpdate:endValue"?: ((args_0: Time | undefined) => any) | undefined;
|
|
25
25
|
}>, {
|
|
26
26
|
size: "sm" | "md" | "lg";
|
|
27
|
+
rangeSeparatorIcon: string;
|
|
27
28
|
granularity: "hour" | "minute" | "second";
|
|
28
29
|
hourCycle: 12 | 24;
|
|
29
30
|
clearable: boolean;
|
|
30
31
|
clearIcon: string;
|
|
31
|
-
rangeSeparatorIcon: string;
|
|
32
32
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
33
33
|
declare const _default: typeof __VLS_export;
|
|
34
34
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
2
|
import { Environment } from '../vendor/cel-js/lib/index.js';
|
|
3
3
|
import { Locale } from './locale.js';
|
|
4
|
-
type ResultType = string | string[] | ((type: string) => boolean);
|
|
4
|
+
export type ResultType = string | string[] | ((type: string) => boolean);
|
|
5
5
|
export declare function Expression(options: {
|
|
6
6
|
configure: (env: Environment) => void;
|
|
7
7
|
resultType?: ResultType;
|
|
@@ -19,4 +19,3 @@ export declare function Markdown(options: {
|
|
|
19
19
|
export declare function LocaleMarkdown(options: {
|
|
20
20
|
configure: (env: Environment) => void;
|
|
21
21
|
}): Schema.filter<typeof Locale>;
|
|
22
|
-
export {};
|
|
@@ -35,14 +35,15 @@ watch(() => props.slotValue.layouts, (sets) => {
|
|
|
35
35
|
const gridStyle = computed(() => {
|
|
36
36
|
const l = activeLayout.value?.layout;
|
|
37
37
|
if (!l) return "";
|
|
38
|
-
const tracks = (n) => `repeat(${n}, minmax(
|
|
38
|
+
const tracks = (n, min) => `repeat(${n}, minmax(${min}, 1fr))`;
|
|
39
|
+
const gap = `calc(${l.gap ?? DEFAULT_GAP} * 0.25rem)`;
|
|
40
|
+
const colGap = l.columns > 1 ? `min(${gap}, calc(100% / ${l.columns - 1}))` : gap;
|
|
39
41
|
const parts = [
|
|
40
42
|
"display: grid",
|
|
41
|
-
`grid-template-columns: ${tracks(l.columns)}`,
|
|
42
|
-
l.rows ? `grid-template-rows: ${tracks(l.rows)}` : "",
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
`gap: calc(${l.gap ?? DEFAULT_GAP} * 0.25rem)`,
|
|
43
|
+
`grid-template-columns: ${tracks(l.columns, "0")}`,
|
|
44
|
+
l.rows ? `grid-template-rows: ${tracks(l.rows, "auto")}` : "",
|
|
45
|
+
`column-gap: ${colGap}`,
|
|
46
|
+
`row-gap: ${gap}`,
|
|
46
47
|
l.style ?? ""
|
|
47
48
|
].filter(Boolean);
|
|
48
49
|
return parts.join("; ");
|
|
@@ -20,7 +20,7 @@ The `homogeneousAggregateLiterals` and `enableOptionalTypes` environment options
|
|
|
20
20
|
|
|
21
21
|
The custom `Optional` class has been replaced with Effect's `Option` type (`import { Option } from 'effect'`). Internal helpers `optionalOf(value)` and `optionalValue(opt)` in `optional.js` handle the CEL-specific semantics (treating `undefined` as `None`, throwing `EvaluationError` on missing value access).
|
|
22
22
|
|
|
23
|
-
An `http` built-in has been added (`http-builtins.ts`, `http-builder.ts`) — not from upstream. It registers the `http` constant and the `http` / `HttpRequest` types on `globalRegistry`, so `http.get(url).header(...).body(...)` expressions type-check and evaluate in every `Environment`. A CEL expression
|
|
23
|
+
An `http` built-in has been added (`http-builtins.ts`, `http-builder.ts`) — not from upstream. It registers the `http` constant and the `http` / `HttpRequest` types on `globalRegistry`, so `http.get(url).header(...).body(...)` expressions type-check and evaluate in every `Environment`. A CEL expression builds an `HttpRequestBuilder`; the terminal `HttpRequest.file(): File` method issues the request and evaluates to the downloaded `File`, while `.json()` is dispatched by the host on the builder value (it is not a CEL method). Endpoints must be absolute URLs — there is no base-URL resolution. Depends on `fx-fetch`.
|
|
24
24
|
|
|
25
25
|
## Architecture
|
|
26
26
|
|
|
@@ -197,7 +197,7 @@ location.param("id") // first value when a param repeats
|
|
|
197
197
|
|
|
198
198
|
## HTTP
|
|
199
199
|
|
|
200
|
-
Build HTTP requests using the `http` builder. CEL
|
|
200
|
+
Build HTTP requests using the `http` builder. A CEL expression *describes* a request; calling `.file()` on it issues the request and evaluates to the downloaded `File`. Any other request is handed to the host to dispatch — there is no way to read a JSON or text response from CEL.
|
|
201
201
|
|
|
202
202
|
**URLs must be absolute** — pass a full `https://…` URL. There is no base URL, so relative paths like `/api/users` will not resolve.
|
|
203
203
|
|
|
@@ -236,6 +236,11 @@ http.post("https://api.example.com/users")
|
|
|
236
236
|
.header("Content-Type", "application/json")
|
|
237
237
|
.body({"name": "Alice", "channel": query.?channel})
|
|
238
238
|
|
|
239
|
+
// Download the response as a File. Unlike the chainable methods above,
|
|
240
|
+
// .file() is terminal — it issues the request and the expression evaluates
|
|
241
|
+
// to a File (filename from the Content-Disposition header, else the URL path):
|
|
242
|
+
http.get("https://api.example.com/files/report.pdf").file()
|
|
243
|
+
|
|
239
244
|
// Full example — the expression returns an HttpRequest; the host sends it:
|
|
240
245
|
http.post("https://api.example.com/users")
|
|
241
246
|
.header("Content-Type", "application/json")
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `HttpRequestBuilder` — the value an `http.*` CEL expression evaluates to.
|
|
3
3
|
*
|
|
4
|
-
* A local (non-upstream) extension. CEL
|
|
5
|
-
*
|
|
4
|
+
* A local (non-upstream) extension. A CEL expression builds and *describes* a
|
|
5
|
+
* request; `.file()` is exposed as a CEL method and evaluates to the downloaded
|
|
6
|
+
* `File`, while `.json()` is dispatched by the host on the returned builder.
|
|
6
7
|
*
|
|
7
8
|
* Endpoints are used verbatim — there is no base-URL resolution, so callers
|
|
8
9
|
* must pass absolute URLs.
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* HTTP built-ins for CEL — a local (non-upstream) extension.
|
|
3
3
|
*
|
|
4
4
|
* Registers the `http` / `HttpRequest` types, the `http` constant, and the
|
|
5
|
-
* request-builder functions on the registry.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* request-builder functions on the registry. `http.get(url).header(...).body(...)`
|
|
6
|
+
* builds an `HttpRequestBuilder`; the terminal `.file()` method issues the
|
|
7
|
+
* request and evaluates to the downloaded `File`. `.json()` is *not* a CEL
|
|
8
|
+
* method — the host dispatches that on the returned builder value.
|
|
8
9
|
*
|
|
9
10
|
* Wired into `globalRegistry` at module load (see `evaluator.ts`), so every
|
|
10
11
|
* `Environment` gets HTTP for free — both type-checking and evaluation.
|