@shwfed/config 2.2.0 → 2.2.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/runtime/components/form/FormUnitRenderer.d.vue.ts +9 -0
- package/dist/runtime/components/form/FormUnitRenderer.vue +117 -0
- package/dist/runtime/components/form/FormUnitRenderer.vue.d.ts +9 -0
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.number/config.d.vue.ts +2 -0
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.number/config.vue +31 -0
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.number/config.vue.d.ts +2 -0
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.number/runtime.vue +12 -2
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.number/schema.d.ts +1 -0
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.number/schema.js +4 -0
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.numberrange/config.d.vue.ts +2 -0
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.numberrange/config.vue +31 -0
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.numberrange/config.vue.d.ts +2 -0
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.numberrange/runtime.vue +16 -8
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.numberrange/schema.d.ts +1 -0
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.numberrange/schema.js +4 -0
- 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 +1 -1
- 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.vue +7 -104
- 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-20/com.shwfed.form.field.collapsible/config.d.vue.ts +53 -0
- package/dist/runtime/components/form/fields/2026-05-20/com.shwfed.form.field.collapsible/config.vue +130 -0
- package/dist/runtime/components/form/fields/2026-05-20/com.shwfed.form.field.collapsible/config.vue.d.ts +53 -0
- package/dist/runtime/components/form/fields/2026-05-20/com.shwfed.form.field.collapsible/runtime.d.vue.ts +8 -0
- package/dist/runtime/components/form/fields/2026-05-20/com.shwfed.form.field.collapsible/runtime.vue +107 -0
- package/dist/runtime/components/form/fields/2026-05-20/com.shwfed.form.field.collapsible/runtime.vue.d.ts +8 -0
- package/dist/runtime/components/form/fields/2026-05-20/com.shwfed.form.field.collapsible/schema.d.ts +54 -0
- package/dist/runtime/components/form/fields/2026-05-20/com.shwfed.form.field.collapsible/schema.js +47 -0
- package/dist/runtime/components/form/index.vue +16 -108
- package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.number/runtime.vue +1 -0
- package/dist/runtime/plugins/i18n/index.js +8 -2
- package/dist/runtime/vendor/cel-js/CLAUDE.md +3 -1
- package/dist/runtime/vendor/cel-js/PROMPT.md +20 -0
- package/dist/runtime/vendor/cel-js/lib/http-builder.d.ts +2 -0
- package/dist/runtime/vendor/cel-js/lib/http-builder.js +24 -3
- package/dist/runtime/vendor/cel-js/lib/operators.js +139 -11
- package/dist/runtime/vendor/cel-js/lib/parser.d.ts +2 -1
- package/dist/runtime/vendor/cel-js/lib/parser.js +20 -3
- package/dist/runtime/vendor/cel-js/lib/serialize.js +5 -1
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FieldValue, FormUnitValue } from './schema.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
unit: FormUnitValue;
|
|
4
|
+
evaluateMedia: (expression: string) => boolean;
|
|
5
|
+
isHidden?: (field: FieldValue) => boolean;
|
|
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,117 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, onMounted, ref, watch } from "vue";
|
|
3
|
+
import { DEFAULT_GAP } from "./schema";
|
|
4
|
+
import { findField } from "./utils/resolve";
|
|
5
|
+
defineOptions({ name: "ShwfedFormUnitRenderer" });
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
unit: { type: Object, required: true },
|
|
8
|
+
evaluateMedia: { type: Function, required: true },
|
|
9
|
+
isHidden: { type: Function, required: false }
|
|
10
|
+
});
|
|
11
|
+
function pickLayout(sets) {
|
|
12
|
+
for (const set of sets) {
|
|
13
|
+
if (!set.media) return set;
|
|
14
|
+
try {
|
|
15
|
+
if (props.evaluateMedia(set.media)) return set;
|
|
16
|
+
} catch (err) {
|
|
17
|
+
console.error(`[shwfed-form] failed to evaluate layout media for ${set.name}:`, err);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return sets[sets.length - 1];
|
|
21
|
+
}
|
|
22
|
+
const activeLayout = ref();
|
|
23
|
+
onMounted(() => {
|
|
24
|
+
activeLayout.value = pickLayout(props.unit.layouts);
|
|
25
|
+
});
|
|
26
|
+
watch(() => props.unit.layouts, (sets) => {
|
|
27
|
+
activeLayout.value = pickLayout(sets);
|
|
28
|
+
}, { deep: false });
|
|
29
|
+
const warnedMissing = /* @__PURE__ */ new Set();
|
|
30
|
+
const placedFields = computed(() => {
|
|
31
|
+
const layout = activeLayout.value?.layout;
|
|
32
|
+
if (!layout) return [];
|
|
33
|
+
const out = [];
|
|
34
|
+
for (const field of props.unit.fields) {
|
|
35
|
+
const placement = layout.placements[field.id];
|
|
36
|
+
if (!placement) continue;
|
|
37
|
+
if (props.isHidden?.(field)) continue;
|
|
38
|
+
const entry = findField(field.type, field.compatibilityDate);
|
|
39
|
+
if (!entry) {
|
|
40
|
+
const key = `${field.type}@${field.compatibilityDate}`;
|
|
41
|
+
if (!warnedMissing.has(key)) {
|
|
42
|
+
warnedMissing.add(key);
|
|
43
|
+
console.warn(`[shwfed-form] no registered field type for ${key}`);
|
|
44
|
+
}
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
out.push({ field, placement, entry });
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
});
|
|
51
|
+
function cellStyle(placement) {
|
|
52
|
+
const [[x1, y1], [x2, y2]] = placement.area;
|
|
53
|
+
const parts = [`grid-column: ${x1} / ${x2}`, `grid-row: ${y1} / ${y2}`, "min-width: 0"];
|
|
54
|
+
const h = placement.h && placement.h !== "stretch" ? placement.h : null;
|
|
55
|
+
const v = placement.v && placement.v !== "stretch" ? placement.v : null;
|
|
56
|
+
if (h || v) {
|
|
57
|
+
parts.push("display: flex");
|
|
58
|
+
const toFlex = (a) => a === "start" ? "flex-start" : a === "end" ? "flex-end" : "center";
|
|
59
|
+
if (h) parts.push(`justify-content: ${toFlex(h)}`);
|
|
60
|
+
if (v) parts.push(`align-items: ${toFlex(v)}`);
|
|
61
|
+
}
|
|
62
|
+
return parts.join("; ");
|
|
63
|
+
}
|
|
64
|
+
const gridStyle = computed(() => {
|
|
65
|
+
const l = activeLayout.value?.layout;
|
|
66
|
+
if (!l) return "";
|
|
67
|
+
const colTemplate = `repeat(${l.columns}, minmax(0, 1fr))`;
|
|
68
|
+
let rowTemplate = "";
|
|
69
|
+
if (l.rows) {
|
|
70
|
+
const grows = Array.from({ length: l.rows }, () => false);
|
|
71
|
+
for (const p of placedFields.value) {
|
|
72
|
+
if (!p.entry.metadata.h.grow) continue;
|
|
73
|
+
const [[, y1], [, y2]] = p.placement.area;
|
|
74
|
+
const lo = Math.max(1, y1);
|
|
75
|
+
const hi = Math.min(l.rows, y2 - 1);
|
|
76
|
+
for (let r = lo; r <= hi; r++) grows[r - 1] = true;
|
|
77
|
+
}
|
|
78
|
+
rowTemplate = grows.map((g) => g ? "auto" : "minmax(auto, 1fr)").join(" ");
|
|
79
|
+
}
|
|
80
|
+
const gap = `calc(${l.gap ?? DEFAULT_GAP} * 0.25rem)`;
|
|
81
|
+
const colGap = l.columns > 1 ? `min(${gap}, calc(100% / ${l.columns - 1}))` : gap;
|
|
82
|
+
const parts = [
|
|
83
|
+
"display: grid",
|
|
84
|
+
`grid-template-columns: ${colTemplate}`,
|
|
85
|
+
rowTemplate ? `grid-template-rows: ${rowTemplate}` : "",
|
|
86
|
+
`column-gap: ${colGap}`,
|
|
87
|
+
`row-gap: ${gap}`,
|
|
88
|
+
l.style ?? ""
|
|
89
|
+
].filter(Boolean);
|
|
90
|
+
return parts.join("; ");
|
|
91
|
+
});
|
|
92
|
+
const rendered = computed(
|
|
93
|
+
() => placedFields.value.map((p) => ({
|
|
94
|
+
key: p.field.id,
|
|
95
|
+
style: cellStyle(p.placement),
|
|
96
|
+
component: p.entry.runtime,
|
|
97
|
+
fieldId: p.field.id,
|
|
98
|
+
config: p.field
|
|
99
|
+
}))
|
|
100
|
+
);
|
|
101
|
+
</script>
|
|
102
|
+
|
|
103
|
+
<template>
|
|
104
|
+
<div :style="gridStyle">
|
|
105
|
+
<div
|
|
106
|
+
v-for="r in rendered"
|
|
107
|
+
:key="r.key"
|
|
108
|
+
:style="r.style"
|
|
109
|
+
>
|
|
110
|
+
<component
|
|
111
|
+
:is="r.component"
|
|
112
|
+
:field-id="r.fieldId"
|
|
113
|
+
:config="r.config"
|
|
114
|
+
/>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
</template>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FieldValue, FormUnitValue } from './schema.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
unit: FormUnitValue;
|
|
4
|
+
evaluateMedia: (expression: string) => boolean;
|
|
5
|
+
isHidden?: (field: FieldValue) => boolean;
|
|
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/form/fields/2026-04-28/com.shwfed.form.field.number/config.d.vue.ts
CHANGED
|
@@ -43,6 +43,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
|
|
|
43
43
|
} | undefined;
|
|
44
44
|
readonly precision?: number | undefined;
|
|
45
45
|
readonly roundingMode?: "round" | "floor" | "ceil" | undefined;
|
|
46
|
+
readonly valueAsString?: boolean | undefined;
|
|
46
47
|
}) => any;
|
|
47
48
|
}, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
|
|
48
49
|
"onUpdate:modelValue"?: ((value: {
|
|
@@ -85,6 +86,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
|
|
|
85
86
|
} | undefined;
|
|
86
87
|
readonly precision?: number | undefined;
|
|
87
88
|
readonly roundingMode?: "round" | "floor" | "ceil" | undefined;
|
|
89
|
+
readonly valueAsString?: boolean | undefined;
|
|
88
90
|
}) => any) | undefined;
|
|
89
91
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
90
92
|
declare const _default: typeof __VLS_export;
|
package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.number/config.vue
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
SelectTrigger,
|
|
27
27
|
SelectValue
|
|
28
28
|
} from "../../../../ui/select";
|
|
29
|
+
import { Switch } from "../../../../ui/switch";
|
|
29
30
|
import { getStructFieldDescription, getStructFieldTitle } from "../../../schema";
|
|
30
31
|
import { DEFAULT_FIELD_ORIENTATION, FIELD_ORIENTATION_OPTIONS } from "../../../utils/common";
|
|
31
32
|
import { schema } from "./schema";
|
|
@@ -76,6 +77,14 @@ function onStepChange(v) {
|
|
|
76
77
|
value.value = { ...value.value, step: v };
|
|
77
78
|
}
|
|
78
79
|
}
|
|
80
|
+
function onValueAsStringChange(next) {
|
|
81
|
+
if (next) {
|
|
82
|
+
value.value = { ...value.value, valueAsString: true };
|
|
83
|
+
} else {
|
|
84
|
+
const { valueAsString: _omit, ...rest } = value.value;
|
|
85
|
+
value.value = rest;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
79
88
|
</script>
|
|
80
89
|
|
|
81
90
|
<template>
|
|
@@ -300,6 +309,28 @@ function onStepChange(v) {
|
|
|
300
309
|
</Field>
|
|
301
310
|
</div>
|
|
302
311
|
|
|
312
|
+
<Field orientation="vertical">
|
|
313
|
+
<FieldLabel class="text-xs text-zinc-500">
|
|
314
|
+
<template
|
|
315
|
+
v-if="fieldDescription('valueAsString')"
|
|
316
|
+
#tooltip
|
|
317
|
+
>
|
|
318
|
+
<Markdown
|
|
319
|
+
:source="fieldDescription('valueAsString')"
|
|
320
|
+
block
|
|
321
|
+
class="prose prose-sm prose-zinc"
|
|
322
|
+
/>
|
|
323
|
+
</template>
|
|
324
|
+
{{ fieldTitle("valueAsString") }}
|
|
325
|
+
</FieldLabel>
|
|
326
|
+
<div>
|
|
327
|
+
<Switch
|
|
328
|
+
:model-value="value.valueAsString ?? false"
|
|
329
|
+
@update:model-value="onValueAsStringChange"
|
|
330
|
+
/>
|
|
331
|
+
</div>
|
|
332
|
+
</Field>
|
|
333
|
+
|
|
303
334
|
<div class="grid grid-cols-2 gap-3">
|
|
304
335
|
<Field orientation="vertical">
|
|
305
336
|
<FieldLabel class="text-xs text-zinc-500">
|
package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.number/config.vue.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
|
|
|
43
43
|
} | undefined;
|
|
44
44
|
readonly precision?: number | undefined;
|
|
45
45
|
readonly roundingMode?: "round" | "floor" | "ceil" | undefined;
|
|
46
|
+
readonly valueAsString?: boolean | undefined;
|
|
46
47
|
}) => any;
|
|
47
48
|
}, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
|
|
48
49
|
"onUpdate:modelValue"?: ((value: {
|
|
@@ -85,6 +86,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
|
|
|
85
86
|
} | undefined;
|
|
86
87
|
readonly precision?: number | undefined;
|
|
87
88
|
readonly roundingMode?: "round" | "floor" | "ceil" | undefined;
|
|
89
|
+
readonly valueAsString?: boolean | undefined;
|
|
88
90
|
}) => any) | undefined;
|
|
89
91
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
90
92
|
declare const _default: typeof __VLS_export;
|
package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.number/runtime.vue
CHANGED
|
@@ -62,8 +62,18 @@ const formatOptions = computed(() => ({
|
|
|
62
62
|
}));
|
|
63
63
|
const { draft, commit } = useFieldValue({
|
|
64
64
|
binding: () => props.config.binding,
|
|
65
|
-
fromState: (raw) =>
|
|
66
|
-
|
|
65
|
+
fromState: (raw) => {
|
|
66
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return raw;
|
|
67
|
+
if (typeof raw === "string" && raw.length > 0) {
|
|
68
|
+
const n = Number(raw);
|
|
69
|
+
return Number.isFinite(n) ? n : void 0;
|
|
70
|
+
}
|
|
71
|
+
return void 0;
|
|
72
|
+
},
|
|
73
|
+
toState: (next) => {
|
|
74
|
+
if (typeof next !== "number" || !Number.isFinite(next)) return null;
|
|
75
|
+
return props.config.valueAsString ? String(next) : next;
|
|
76
|
+
}
|
|
67
77
|
});
|
|
68
78
|
function applyRounding(n, precision, mode) {
|
|
69
79
|
const factor = 10 ** precision;
|
package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.number/schema.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ export declare function schema(configure: (env: Environment) => void): Schema.St
|
|
|
49
49
|
precision: Schema.optional<Schema.refine<number, Schema.filter<typeof Schema.Number>>>;
|
|
50
50
|
roundingMode: Schema.optional<Schema.Literal<["round", "floor", "ceil"]>>;
|
|
51
51
|
step: Schema.optional<Schema.refine<number, typeof Schema.Number>>;
|
|
52
|
+
valueAsString: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
52
53
|
min: Schema.optional<Schema.Schema<string, string, never>>;
|
|
53
54
|
max: Schema.optional<Schema.Schema<string, string, never>>;
|
|
54
55
|
id: Schema.refine<string, typeof Schema.String>;
|
package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.number/schema.js
CHANGED
|
@@ -55,6 +55,10 @@ export function schema(configure) {
|
|
|
55
55
|
title: "\u6B65\u957F",
|
|
56
56
|
description: "\u53D6\u503C\u7684\u6700\u5C0F\u6B65\u957F\uFF1B\u7559\u7A7A\u65F6\u4E0D\u9650\u5236\uFF08\u4EFB\u610F\u7CBE\u5EA6\uFF09"
|
|
57
57
|
})),
|
|
58
|
+
valueAsString: Schema.optional(Schema.Boolean.annotations({
|
|
59
|
+
title: "\u4EE5\u5B57\u7B26\u4E32\u8BFB\u5199",
|
|
60
|
+
description: "\u5F00\u542F\u540E\u8868\u5355\u72B6\u6001\u4EE5\u5B57\u7B26\u4E32\u5F62\u5F0F\u5B58\u50A8\u8BE5\u503C\uFF08\u9002\u7528\u4E8E\u540E\u7AEF\u4F7F\u7528 `DECIMAL` / `BIGINT` \u7B49\u9700\u8981\u539F\u6837\u56DE\u4F20\u7684\u5B57\u6BB5\uFF09\uFF1B\u5173\u95ED\u65F6\u82E5\u8BFB\u5230\u7684\u662F\u6570\u503C\u5B57\u7B26\u4E32\u4E5F\u4F1A\u88AB\u89E3\u6790\uFF0C\u4F46\u5199\u56DE\u4ECD\u4E3A\u6570\u503C\u3002\u6CE8\u610F\uFF1A\u8F93\u5165\u65F6\u4ECD\u7ECF\u8FC7 JavaScript \u6D6E\u70B9\u6570\uFF0C\u4EC5\u80FD\u5728\u300C\u88C5\u8F7D-\u56DE\u4F20\u300D\u672A\u7F16\u8F91\u573A\u666F\u4E0B\u4FDD\u7559\u7CBE\u5EA6"
|
|
61
|
+
})),
|
|
58
62
|
min: Schema.optional(CelNumber.annotations({
|
|
59
63
|
title: "\u6700\u5C0F\u503C",
|
|
60
64
|
description: "\u5141\u8BB8\u8F93\u5165\u7684\u6700\u5C0F\u503C\u8868\u8FBE\u5F0F\uFF1B\u7559\u7A7A\u65F6\u4E0D\u9650\u5236\u4E0B\u9650"
|
|
@@ -51,6 +51,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
|
|
|
51
51
|
readonly precision?: number | undefined;
|
|
52
52
|
readonly roundingMode?: "round" | "floor" | "ceil" | undefined;
|
|
53
53
|
readonly rangeSeparatorIcon?: string | undefined;
|
|
54
|
+
readonly valueAsString?: boolean | undefined;
|
|
54
55
|
}) => any;
|
|
55
56
|
}, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
|
|
56
57
|
"onUpdate:modelValue"?: ((value: {
|
|
@@ -101,6 +102,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
|
|
|
101
102
|
readonly precision?: number | undefined;
|
|
102
103
|
readonly roundingMode?: "round" | "floor" | "ceil" | undefined;
|
|
103
104
|
readonly rangeSeparatorIcon?: string | undefined;
|
|
105
|
+
readonly valueAsString?: boolean | undefined;
|
|
104
106
|
}) => any) | undefined;
|
|
105
107
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
106
108
|
declare const _default: typeof __VLS_export;
|
package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.numberrange/config.vue
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
SelectTrigger,
|
|
29
29
|
SelectValue
|
|
30
30
|
} from "../../../../ui/select";
|
|
31
|
+
import { Switch } from "../../../../ui/switch";
|
|
31
32
|
import { getStructFieldDescription, getStructFieldTitle } from "../../../schema";
|
|
32
33
|
import { DEFAULT_FIELD_ORIENTATION, FIELD_ORIENTATION_OPTIONS } from "../../../utils/common";
|
|
33
34
|
import { schema } from "./schema";
|
|
@@ -112,6 +113,14 @@ function setSeparatorIcon(next) {
|
|
|
112
113
|
value.value = { ...value.value, rangeSeparatorIcon: trimmed };
|
|
113
114
|
}
|
|
114
115
|
}
|
|
116
|
+
function onValueAsStringChange(next) {
|
|
117
|
+
if (next) {
|
|
118
|
+
value.value = { ...value.value, valueAsString: true };
|
|
119
|
+
} else {
|
|
120
|
+
const { valueAsString: _omit, ...rest } = value.value;
|
|
121
|
+
value.value = rest;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
115
124
|
</script>
|
|
116
125
|
|
|
117
126
|
<template>
|
|
@@ -468,6 +477,28 @@ function setSeparatorIcon(next) {
|
|
|
468
477
|
@update:model-value="setSeparatorIcon"
|
|
469
478
|
/>
|
|
470
479
|
</Field>
|
|
480
|
+
|
|
481
|
+
<Field orientation="vertical">
|
|
482
|
+
<FieldLabel class="text-xs text-zinc-500">
|
|
483
|
+
<template
|
|
484
|
+
v-if="fieldDescription('valueAsString')"
|
|
485
|
+
#tooltip
|
|
486
|
+
>
|
|
487
|
+
<Markdown
|
|
488
|
+
:source="fieldDescription('valueAsString')"
|
|
489
|
+
block
|
|
490
|
+
class="prose prose-sm prose-zinc"
|
|
491
|
+
/>
|
|
492
|
+
</template>
|
|
493
|
+
{{ fieldTitle("valueAsString") }}
|
|
494
|
+
</FieldLabel>
|
|
495
|
+
<div>
|
|
496
|
+
<Switch
|
|
497
|
+
:model-value="value.valueAsString ?? false"
|
|
498
|
+
@update:model-value="onValueAsStringChange"
|
|
499
|
+
/>
|
|
500
|
+
</div>
|
|
501
|
+
</Field>
|
|
471
502
|
</div>
|
|
472
503
|
|
|
473
504
|
<div class="grid grid-cols-3 gap-3">
|
|
@@ -51,6 +51,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
|
|
|
51
51
|
readonly precision?: number | undefined;
|
|
52
52
|
readonly roundingMode?: "round" | "floor" | "ceil" | undefined;
|
|
53
53
|
readonly rangeSeparatorIcon?: string | undefined;
|
|
54
|
+
readonly valueAsString?: boolean | undefined;
|
|
54
55
|
}) => any;
|
|
55
56
|
}, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
|
|
56
57
|
"onUpdate:modelValue"?: ((value: {
|
|
@@ -101,6 +102,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
|
|
|
101
102
|
readonly precision?: number | undefined;
|
|
102
103
|
readonly roundingMode?: "round" | "floor" | "ceil" | undefined;
|
|
103
104
|
readonly rangeSeparatorIcon?: string | undefined;
|
|
105
|
+
readonly valueAsString?: boolean | undefined;
|
|
104
106
|
}) => any) | undefined;
|
|
105
107
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
106
108
|
declare const _default: typeof __VLS_export;
|
package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.numberrange/runtime.vue
CHANGED
|
@@ -63,15 +63,23 @@ const formatOptions = computed(() => ({
|
|
|
63
63
|
useGrouping: false,
|
|
64
64
|
maximumFractionDigits: 20
|
|
65
65
|
}));
|
|
66
|
+
function asNumber(raw) {
|
|
67
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return raw;
|
|
68
|
+
if (typeof raw === "string" && raw.length > 0) {
|
|
69
|
+
const n = Number(raw);
|
|
70
|
+
return Number.isFinite(n) ? n : void 0;
|
|
71
|
+
}
|
|
72
|
+
return void 0;
|
|
73
|
+
}
|
|
66
74
|
function asRange(raw) {
|
|
67
75
|
if (!Array.isArray(raw) || raw.length !== 2) return void 0;
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
if (
|
|
76
|
+
const a = asNumber(raw[0]);
|
|
77
|
+
const b = asNumber(raw[1]);
|
|
78
|
+
if (a == null || b == null) return void 0;
|
|
71
79
|
return [a, b];
|
|
72
80
|
}
|
|
73
|
-
function
|
|
74
|
-
return
|
|
81
|
+
function shape(n) {
|
|
82
|
+
return props.config.valueAsString ? String(n) : n;
|
|
75
83
|
}
|
|
76
84
|
const uncontrolled = ref(void 0);
|
|
77
85
|
const model = computed({
|
|
@@ -91,11 +99,11 @@ const model = computed({
|
|
|
91
99
|
return;
|
|
92
100
|
}
|
|
93
101
|
if (typeof binding === "string") {
|
|
94
|
-
setAt(binding, next
|
|
102
|
+
setAt(binding, next ? [shape(next[0]), shape(next[1])] : null);
|
|
95
103
|
return;
|
|
96
104
|
}
|
|
97
|
-
setAt(binding[0], next
|
|
98
|
-
setAt(binding[1], next
|
|
105
|
+
setAt(binding[0], next ? shape(next[0]) : null);
|
|
106
|
+
setAt(binding[1], next ? shape(next[1]) : null);
|
|
99
107
|
}
|
|
100
108
|
});
|
|
101
109
|
const localStart = ref(model.value?.[0]);
|
package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.numberrange/schema.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ export declare function schema(configure: (env: Environment) => void): Schema.St
|
|
|
56
56
|
precision: Schema.optional<Schema.refine<number, Schema.filter<typeof Schema.Number>>>;
|
|
57
57
|
roundingMode: Schema.optional<Schema.Literal<["round", "floor", "ceil"]>>;
|
|
58
58
|
step: Schema.optional<Schema.refine<number, typeof Schema.Number>>;
|
|
59
|
+
valueAsString: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
59
60
|
min: Schema.optional<Schema.Schema<string, string, never>>;
|
|
60
61
|
max: Schema.optional<Schema.Schema<string, string, never>>;
|
|
61
62
|
rangeSeparatorIcon: Schema.optional<Schema.refine<string, typeof Schema.String>>;
|
package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.numberrange/schema.js
CHANGED
|
@@ -66,6 +66,10 @@ export function schema(configure) {
|
|
|
66
66
|
title: "\u6B65\u957F",
|
|
67
67
|
description: "\u53D6\u503C\u7684\u6700\u5C0F\u6B65\u957F\uFF1B\u7559\u7A7A\u65F6\u4E0D\u9650\u5236\uFF08\u4EFB\u610F\u7CBE\u5EA6\uFF09"
|
|
68
68
|
})),
|
|
69
|
+
valueAsString: Schema.optional(Schema.Boolean.annotations({
|
|
70
|
+
title: "\u4EE5\u5B57\u7B26\u4E32\u8BFB\u5199",
|
|
71
|
+
description: "\u5F00\u542F\u540E\u8868\u5355\u72B6\u6001\u4EE5\u5B57\u7B26\u4E32\u5F62\u5F0F\u5B58\u50A8\u4E24\u7AEF\u7684\u503C\uFF08\u9002\u7528\u4E8E\u540E\u7AEF\u4F7F\u7528 `DECIMAL` / `BIGINT` \u7B49\u9700\u8981\u539F\u6837\u56DE\u4F20\u7684\u5B57\u6BB5\uFF09\uFF1B\u5173\u95ED\u65F6\u82E5\u8BFB\u5230\u7684\u662F\u6570\u503C\u5B57\u7B26\u4E32\u4E5F\u4F1A\u88AB\u89E3\u6790\uFF0C\u4F46\u5199\u56DE\u4ECD\u4E3A\u6570\u503C\u3002\u6CE8\u610F\uFF1A\u8F93\u5165\u65F6\u4ECD\u7ECF\u8FC7 JavaScript \u6D6E\u70B9\u6570\uFF0C\u4EC5\u80FD\u5728\u300C\u88C5\u8F7D-\u56DE\u4F20\u300D\u672A\u7F16\u8F91\u573A\u666F\u4E0B\u4FDD\u7559\u7CBE\u5EA6"
|
|
72
|
+
})),
|
|
69
73
|
min: Schema.optional(CelNumber.annotations({
|
|
70
74
|
title: "\u6700\u5C0F\u503C",
|
|
71
75
|
description: "\u5141\u8BB8\u8F93\u5165\u7684\u6700\u5C0F\u503C\u8868\u8FBE\u5F0F\uFF1B\u540C\u65F6\u4F5C\u7528\u4E8E\u8D77\u59CB\u4E0E\u7ED3\u675F\u8F93\u5165"
|
package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/config.d.vue.ts
CHANGED
|
@@ -33,7 +33,6 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
|
|
|
33
33
|
readonly compatibilityDate: "2026-05-13";
|
|
34
34
|
readonly min?: number | undefined;
|
|
35
35
|
readonly max?: number | undefined;
|
|
36
|
-
readonly binding?: string | undefined;
|
|
37
36
|
readonly unit: Readonly<{
|
|
38
37
|
fields: ReadonlyArray<import("../../../schema.js").FieldValue>;
|
|
39
38
|
layouts: readonly Readonly<{
|
|
@@ -42,6 +41,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
|
|
|
42
41
|
layout: import("../../../schema.js").LayoutValue;
|
|
43
42
|
}>[];
|
|
44
43
|
}>;
|
|
44
|
+
readonly binding?: string | undefined;
|
|
45
45
|
readonly addLabel?: readonly [{
|
|
46
46
|
readonly locale: "zh";
|
|
47
47
|
readonly message: string;
|
|
@@ -89,7 +89,6 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
|
|
|
89
89
|
readonly compatibilityDate: "2026-05-13";
|
|
90
90
|
readonly min?: number | undefined;
|
|
91
91
|
readonly max?: number | undefined;
|
|
92
|
-
readonly binding?: string | undefined;
|
|
93
92
|
readonly unit: Readonly<{
|
|
94
93
|
fields: ReadonlyArray<import("../../../schema.js").FieldValue>;
|
|
95
94
|
layouts: readonly Readonly<{
|
|
@@ -98,6 +97,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
|
|
|
98
97
|
layout: import("../../../schema.js").LayoutValue;
|
|
99
98
|
}>[];
|
|
100
99
|
}>;
|
|
100
|
+
readonly binding?: string | undefined;
|
|
101
101
|
readonly addLabel?: readonly [{
|
|
102
102
|
readonly locale: "zh";
|
|
103
103
|
readonly message: string;
|
package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/config.vue
CHANGED
|
@@ -96,7 +96,7 @@ const reorderable = computed({
|
|
|
96
96
|
:field-cel-scope="FIELD_CEL_SCOPE"
|
|
97
97
|
>
|
|
98
98
|
<template #extras-pane>
|
|
99
|
-
<div class="flex flex-col gap-3
|
|
99
|
+
<div class="flex flex-col gap-3">
|
|
100
100
|
<div class="grid grid-cols-2 gap-3">
|
|
101
101
|
<Field orientation="vertical">
|
|
102
102
|
<FieldLabel class="text-xs text-zinc-500">
|
package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/config.vue.d.ts
CHANGED
|
@@ -33,7 +33,6 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
|
|
|
33
33
|
readonly compatibilityDate: "2026-05-13";
|
|
34
34
|
readonly min?: number | undefined;
|
|
35
35
|
readonly max?: number | undefined;
|
|
36
|
-
readonly binding?: string | undefined;
|
|
37
36
|
readonly unit: Readonly<{
|
|
38
37
|
fields: ReadonlyArray<import("../../../schema.js").FieldValue>;
|
|
39
38
|
layouts: readonly Readonly<{
|
|
@@ -42,6 +41,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
|
|
|
42
41
|
layout: import("../../../schema.js").LayoutValue;
|
|
43
42
|
}>[];
|
|
44
43
|
}>;
|
|
44
|
+
readonly binding?: string | undefined;
|
|
45
45
|
readonly addLabel?: readonly [{
|
|
46
46
|
readonly locale: "zh";
|
|
47
47
|
readonly message: string;
|
|
@@ -89,7 +89,6 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
|
|
|
89
89
|
readonly compatibilityDate: "2026-05-13";
|
|
90
90
|
readonly min?: number | undefined;
|
|
91
91
|
readonly max?: number | undefined;
|
|
92
|
-
readonly binding?: string | undefined;
|
|
93
92
|
readonly unit: Readonly<{
|
|
94
93
|
fields: ReadonlyArray<import("../../../schema.js").FieldValue>;
|
|
95
94
|
layouts: readonly Readonly<{
|
|
@@ -98,6 +97,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
|
|
|
98
97
|
layout: import("../../../schema.js").LayoutValue;
|
|
99
98
|
}>[];
|
|
100
99
|
}>;
|
|
100
|
+
readonly binding?: string | undefined;
|
|
101
101
|
readonly addLabel?: readonly [{
|
|
102
102
|
readonly locale: "zh";
|
|
103
103
|
readonly message: string;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { cel as _rawCel } from "../../../../../utils/cel";
|
|
3
3
|
import { Effect } from "effect";
|
|
4
|
-
import { computed, onMounted, ref, watch } from "vue";
|
|
5
4
|
import { celBindings, injectCELContext, provideCELContext } from "../../../../../utils/cel-context";
|
|
6
|
-
import
|
|
5
|
+
import FormUnitRenderer from "../../../FormUnitRenderer.vue";
|
|
7
6
|
import { useDerived, useDerivedQuiescence } from "../../../utils/derived";
|
|
8
|
-
import { findField } from "../../../utils/resolve";
|
|
9
7
|
import { provideFormState } from "../../../utils/state";
|
|
10
8
|
defineOptions({ name: "ShwfedListFieldRow" });
|
|
11
9
|
const state = defineModel({ type: Object, ...{ required: true } });
|
|
@@ -37,109 +35,14 @@ useDerived({
|
|
|
37
35
|
formState,
|
|
38
36
|
quiescence: useDerivedQuiescence()
|
|
39
37
|
});
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
if (!set.media) return set;
|
|
43
|
-
try {
|
|
44
|
-
if (Effect.runSync($cel(set.media))) return set;
|
|
45
|
-
} catch (err) {
|
|
46
|
-
console.error(`[shwfed-form] list field: failed to evaluate layout media for ${set.name}:`, err);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return sets[sets.length - 1];
|
|
50
|
-
}
|
|
51
|
-
const activeLayout = ref();
|
|
52
|
-
onMounted(() => {
|
|
53
|
-
activeLayout.value = pickLayout(props.unit.layouts);
|
|
54
|
-
});
|
|
55
|
-
watch(() => props.unit.layouts, (sets) => {
|
|
56
|
-
activeLayout.value = pickLayout(sets);
|
|
57
|
-
}, { deep: false });
|
|
58
|
-
const warnedMissing = /* @__PURE__ */ new Set();
|
|
59
|
-
const placedFields = computed(() => {
|
|
60
|
-
const layout = activeLayout.value?.layout;
|
|
61
|
-
if (!layout) return [];
|
|
62
|
-
const out = [];
|
|
63
|
-
for (const field of props.unit.fields) {
|
|
64
|
-
const placement = layout.placements[field.id];
|
|
65
|
-
if (!placement) continue;
|
|
66
|
-
const entry = findField(field.type, field.compatibilityDate);
|
|
67
|
-
if (!entry) {
|
|
68
|
-
const key = `${field.type}@${field.compatibilityDate}`;
|
|
69
|
-
if (!warnedMissing.has(key)) {
|
|
70
|
-
warnedMissing.add(key);
|
|
71
|
-
console.warn(`[shwfed-form] list field: no registered field type for ${key}`);
|
|
72
|
-
}
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
out.push({ field, placement, entry });
|
|
76
|
-
}
|
|
77
|
-
return out;
|
|
78
|
-
});
|
|
79
|
-
const gridStyle = computed(() => {
|
|
80
|
-
const l = activeLayout.value?.layout;
|
|
81
|
-
if (!l) return "";
|
|
82
|
-
const colTemplate = `repeat(${l.columns}, minmax(0, 1fr))`;
|
|
83
|
-
let rowTemplate = "";
|
|
84
|
-
if (l.rows) {
|
|
85
|
-
const grows = Array.from({ length: l.rows }, () => false);
|
|
86
|
-
for (const p of placedFields.value) {
|
|
87
|
-
if (!p.entry.metadata.h.grow) continue;
|
|
88
|
-
const [[, y1], [, y2]] = p.placement.area;
|
|
89
|
-
const lo = Math.max(1, y1);
|
|
90
|
-
const hi = Math.min(l.rows, y2 - 1);
|
|
91
|
-
for (let r = lo; r <= hi; r++) grows[r - 1] = true;
|
|
92
|
-
}
|
|
93
|
-
rowTemplate = grows.map((g) => g ? "auto" : "minmax(auto, 1fr)").join(" ");
|
|
94
|
-
}
|
|
95
|
-
const gap = `calc(${l.gap ?? DEFAULT_GAP} * 0.25rem)`;
|
|
96
|
-
const colGap = l.columns > 1 ? `min(${gap}, calc(100% / ${l.columns - 1}))` : gap;
|
|
97
|
-
const parts = [
|
|
98
|
-
"display: grid",
|
|
99
|
-
`grid-template-columns: ${colTemplate}`,
|
|
100
|
-
rowTemplate ? `grid-template-rows: ${rowTemplate}` : "",
|
|
101
|
-
`column-gap: ${colGap}`,
|
|
102
|
-
`row-gap: ${gap}`,
|
|
103
|
-
l.style ?? ""
|
|
104
|
-
].filter(Boolean);
|
|
105
|
-
return parts.join("; ");
|
|
106
|
-
});
|
|
107
|
-
function cellStyle(placement) {
|
|
108
|
-
const [[x1, y1], [x2, y2]] = placement.area;
|
|
109
|
-
const parts = [`grid-column: ${x1} / ${x2}`, `grid-row: ${y1} / ${y2}`, "min-width: 0"];
|
|
110
|
-
const h = placement.h && placement.h !== "stretch" ? placement.h : null;
|
|
111
|
-
const v = placement.v && placement.v !== "stretch" ? placement.v : null;
|
|
112
|
-
if (h || v) {
|
|
113
|
-
parts.push("display: flex");
|
|
114
|
-
const toFlex = (a) => a === "start" ? "flex-start" : a === "end" ? "flex-end" : "center";
|
|
115
|
-
if (h) parts.push(`justify-content: ${toFlex(h)}`);
|
|
116
|
-
if (v) parts.push(`align-items: ${toFlex(v)}`);
|
|
117
|
-
}
|
|
118
|
-
return parts.join("; ");
|
|
38
|
+
function evaluateMedia(expression) {
|
|
39
|
+
return Effect.runSync($cel(expression));
|
|
119
40
|
}
|
|
120
|
-
const rendered = computed(
|
|
121
|
-
() => placedFields.value.map((p) => ({
|
|
122
|
-
key: p.field.id,
|
|
123
|
-
style: cellStyle(p.placement),
|
|
124
|
-
component: p.entry.runtime,
|
|
125
|
-
fieldId: p.field.id,
|
|
126
|
-
config: p.field
|
|
127
|
-
}))
|
|
128
|
-
);
|
|
129
41
|
</script>
|
|
130
42
|
|
|
131
43
|
<template>
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
:style="r.style"
|
|
137
|
-
>
|
|
138
|
-
<component
|
|
139
|
-
:is="r.component"
|
|
140
|
-
:field-id="r.fieldId"
|
|
141
|
-
:config="r.config"
|
|
142
|
-
/>
|
|
143
|
-
</div>
|
|
144
|
-
</div>
|
|
44
|
+
<FormUnitRenderer
|
|
45
|
+
:unit="unit"
|
|
46
|
+
:evaluate-media="evaluateMedia"
|
|
47
|
+
/>
|
|
145
48
|
</template>
|
package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/schema.d.ts
CHANGED
|
@@ -47,11 +47,11 @@ export declare function schema(configure: (env: Environment) => void): Schema.re
|
|
|
47
47
|
readonly compatibilityDate: "2026-05-13";
|
|
48
48
|
readonly min?: number | undefined;
|
|
49
49
|
readonly max?: number | undefined;
|
|
50
|
-
readonly binding?: string | undefined;
|
|
51
50
|
readonly unit: Readonly<{
|
|
52
51
|
fields: ReadonlyArray<import("../../../schema.js").FieldValue>;
|
|
53
52
|
layouts: ReadonlyArray<import("../../../schema.js").LayoutSetValue>;
|
|
54
53
|
}>;
|
|
54
|
+
readonly binding?: string | undefined;
|
|
55
55
|
readonly addLabel?: readonly [{
|
|
56
56
|
readonly locale: "zh";
|
|
57
57
|
readonly message: string;
|