@shwfed/config 2.0.3 → 2.1.0

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.
Files changed (31) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/components/config/blocks/2026-05-17/{com.shwfed.block.chart.line → com.shwfed.block.chart.xy}/config.d.vue.ts +16 -6
  3. package/dist/runtime/components/config/blocks/2026-05-17/{com.shwfed.block.chart.line → com.shwfed.block.chart.xy}/config.vue +263 -76
  4. package/dist/runtime/components/config/blocks/2026-05-17/{com.shwfed.block.chart.line → com.shwfed.block.chart.xy}/config.vue.d.ts +16 -6
  5. package/dist/runtime/components/config/blocks/2026-05-17/{com.shwfed.block.chart.line → com.shwfed.block.chart.xy}/runtime.d.vue.ts +16 -6
  6. package/dist/runtime/components/config/blocks/2026-05-17/{com.shwfed.block.chart.line → com.shwfed.block.chart.xy}/runtime.vue +104 -12
  7. package/dist/runtime/components/config/blocks/2026-05-17/{com.shwfed.block.chart.line → com.shwfed.block.chart.xy}/runtime.vue.d.ts +16 -6
  8. package/dist/runtime/components/config/blocks/2026-05-17/{com.shwfed.block.chart.line → com.shwfed.block.chart.xy}/schema.d.ts +51 -15
  9. package/dist/runtime/components/config/blocks/2026-05-17/{com.shwfed.block.chart.line → com.shwfed.block.chart.xy}/schema.js +67 -22
  10. package/dist/runtime/components/form/fields/2026-05-18/com.shwfed.form.field.table/config.d.vue.ts +131 -0
  11. package/dist/runtime/components/form/fields/2026-05-18/com.shwfed.form.field.table/config.vue +170 -0
  12. package/dist/runtime/components/form/fields/2026-05-18/com.shwfed.form.field.table/config.vue.d.ts +131 -0
  13. package/dist/runtime/components/form/fields/2026-05-18/com.shwfed.form.field.table/runtime.d.vue.ts +8 -0
  14. package/dist/runtime/components/form/fields/2026-05-18/com.shwfed.form.field.table/runtime.vue +52 -0
  15. package/dist/runtime/components/form/fields/2026-05-18/com.shwfed.form.field.table/runtime.vue.d.ts +8 -0
  16. package/dist/runtime/components/form/fields/2026-05-18/com.shwfed.form.field.table/schema.d.ts +112 -0
  17. package/dist/runtime/components/form/fields/2026-05-18/com.shwfed.form.field.table/schema.js +44 -0
  18. package/dist/runtime/components/form/schema.d.ts +10 -0
  19. package/dist/runtime/components/form/schema.js +6 -2
  20. package/dist/runtime/components/table/config.d.vue.ts +11 -1
  21. package/dist/runtime/components/table/config.vue +4 -0
  22. package/dist/runtime/components/table/config.vue.d.ts +11 -1
  23. package/dist/runtime/components/table/index.d.vue.ts +4 -0
  24. package/dist/runtime/components/table/index.vue +28 -2
  25. package/dist/runtime/components/table/index.vue.d.ts +4 -0
  26. package/dist/runtime/components/table/schema.d.ts +12 -0
  27. package/dist/runtime/components/table/schema.js +6 -1
  28. package/dist/runtime/vendor/cel-js/PROMPT.md +6 -2
  29. package/dist/runtime/vendor/cel-js/lib/http-builder.d.ts +7 -1
  30. package/dist/runtime/vendor/cel-js/lib/http-builder.js +28 -5
  31. package/package.json +1 -1
@@ -4,12 +4,23 @@ import { useI18n } from "vue-i18n";
4
4
  import { Effect, Option } from "effect";
5
5
  import { Fetch } from "fx-fetch";
6
6
  import { CurveType } from "@unovis/ts";
7
- import { VisAxis, VisBulletLegend, VisCrosshair, VisLine, VisTooltip, VisXYContainer } from "@unovis/vue";
7
+ import {
8
+ VisArea,
9
+ VisAxis,
10
+ VisBulletLegend,
11
+ VisCrosshair,
12
+ VisGroupedBar,
13
+ VisLine,
14
+ VisScatter,
15
+ VisStackedBar,
16
+ VisTooltip,
17
+ VisXYContainer
18
+ } from "@unovis/vue";
8
19
  import { Markdown } from "../../../../ui/markdown";
9
20
  import { cel } from "../../../../../utils/cel";
10
21
  import { celBindings, injectCELContext } from "../../../../../utils/cel-context";
11
22
  import { getLocalizedText } from "../../../../../share/locale";
12
- defineOptions({ name: "ShwfedBlockChartLineRuntime" });
23
+ defineOptions({ name: "ShwfedBlockChartXyRuntime" });
13
24
  const block = defineModel("block", { type: null, ...{ required: true } });
14
25
  const { locale } = useI18n();
15
26
  const inheritedContext = injectCELContext();
@@ -39,7 +50,7 @@ const PALETTE = [
39
50
  "#9c755f",
40
51
  "#bab0ac"
41
52
  ];
42
- const lineColors = computed(
53
+ const seriesColors = computed(
43
54
  () => block.value.y.map(
44
55
  (s, i) => s.color && s.color.length > 0 ? s.color : PALETTE[i % PALETTE.length]
45
56
  )
@@ -67,7 +78,7 @@ async function fetchAll() {
67
78
  try {
68
79
  out[ds.name] = await Effect.runPromise(Effect.provide(program, Fetch.layer));
69
80
  } catch (e) {
70
- console.warn("[shwfed-chart-line] data source failed", ds.name, e);
81
+ console.warn("[shwfed-chart-xy] data source failed", ds.name, e);
71
82
  failed.push(ds.name);
72
83
  out[ds.name] = [];
73
84
  }
@@ -104,10 +115,22 @@ function evalList(expression, ctx) {
104
115
  return [];
105
116
  }
106
117
  }
118
+ function evalNumber(expression, ctx) {
119
+ try {
120
+ return toY(Effect.runSync(cel(expression, ctx)));
121
+ } catch {
122
+ return void 0;
123
+ }
124
+ }
125
+ const dataCtx = computed(() => ({
126
+ ...baseContext(),
127
+ ...dataValues.value
128
+ }));
107
129
  const chartData = computed(() => {
108
- const ctx = { ...baseContext(), ...dataValues.value };
130
+ const ctx = dataCtx.value;
109
131
  const xRaw = evalList(block.value.x, ctx);
110
132
  const yLists = block.value.y.map((s) => evalList(s.value, ctx));
133
+ const sizeLists = block.value.y.map((s) => s.size ? evalList(s.size, ctx) : null);
111
134
  const xMode = xRaw.length === 0 ? "ordinal" : xRaw.every((v) => v instanceof Date) ? "time" : xRaw.every((v) => isFiniteNum(v)) ? "number" : "ordinal";
112
135
  const xLabels = /* @__PURE__ */ new Map();
113
136
  const records = xRaw.map((xv, i) => {
@@ -118,19 +141,53 @@ const chartData = computed(() => {
118
141
  yLists.forEach((list, k) => {
119
142
  rec[`y${k}`] = toY(list[i]);
120
143
  });
144
+ sizeLists.forEach((list, k) => {
145
+ if (list) rec[`sz${k}`] = toY(list[i]);
146
+ });
121
147
  return rec;
122
148
  });
123
149
  return { records, xMode, xLabels };
124
150
  });
151
+ const seriesDash = computed(
152
+ () => block.value.y.map((s) => {
153
+ if (!s.dash) return void 0;
154
+ const arr = evalList(s.dash, dataCtx.value).filter(isFiniteNum);
155
+ return arr.length > 0 ? arr : void 0;
156
+ })
157
+ );
158
+ const seriesWidth = computed(
159
+ () => block.value.y.map((s) => s.width ? evalNumber(s.width, dataCtx.value) : void 0)
160
+ );
125
161
  const xAccessor = (d) => d.__x;
126
162
  const yAccessors = computed(
127
163
  () => block.value.y.map((_, k) => (d) => d[`y${k}`])
128
164
  );
165
+ const sizeAccessors = computed(
166
+ () => block.value.y.map((s, k) => s.size ? (d) => d[`sz${k}`] : void 0)
167
+ );
168
+ const seriesEntries = computed(
169
+ () => block.value.y.map((s, k) => ({ k, s, color: seriesColors.value[k] }))
170
+ );
171
+ const lineSeries = computed(() => seriesEntries.value.filter((e) => e.s.chart === "line"));
172
+ const areaSeries = computed(() => seriesEntries.value.filter((e) => e.s.chart === "area"));
173
+ const scatterSeries = computed(() => seriesEntries.value.filter((e) => e.s.chart === "scatter"));
174
+ function barGroup(chart) {
175
+ const entries = seriesEntries.value.filter((e) => e.s.chart === chart);
176
+ return {
177
+ entries,
178
+ accessors: entries.map((e) => yAccessors.value[e.k]),
179
+ colors: entries.map((e) => e.color),
180
+ // One width per merged component — take it from the first such series.
181
+ width: entries[0] ? seriesWidth.value[entries[0].k] : void 0
182
+ };
183
+ }
184
+ const groupedBars = computed(() => barGroup("groupedBar"));
185
+ const stackedBars = computed(() => barGroup("stackedBar"));
129
186
  const legendItems = computed(() => {
130
187
  const items = [];
131
188
  block.value.y.forEach((s, i) => {
132
189
  const label = seriesLabel(s);
133
- if (label) items.push({ name: label, color: lineColors.value[i] });
190
+ if (label) items.push({ name: label, color: seriesColors.value[i] });
134
191
  });
135
192
  return items;
136
193
  });
@@ -165,7 +222,7 @@ function crosshairTemplate(d) {
165
222
  if (!label) return;
166
223
  const v = d[`y${k}`];
167
224
  rows.push(
168
- `<div style="display:flex;align-items:center;gap:6px;padding:1px 0"><span style="width:8px;height:8px;border-radius:9999px;background:${lineColors.value[k]}"></span><span style="color:#3f3f46">${escapeHtml(label)}</span><span style="margin-left:auto;font-variant-numeric:tabular-nums;color:#18181b">${v === void 0 ? "\u2014" : formatNumber(v)}</span></div>`
225
+ `<div style="display:flex;align-items:center;gap:6px;padding:1px 0"><span style="width:8px;height:8px;border-radius:9999px;background:${seriesColors.value[k]}"></span><span style="color:#3f3f46">${escapeHtml(label)}</span><span style="margin-left:auto;font-variant-numeric:tabular-nums;color:#18181b">${v === void 0 ? "\u2014" : formatNumber(v)}</span></div>`
169
226
  );
170
227
  });
171
228
  const lines = rows.join("");
@@ -193,12 +250,47 @@ const placeholder = computed(() => {
193
250
  :margin="{ top: 8, right: 16, bottom: 4, left: 8 }"
194
251
  class="min-h-0 flex-1"
195
252
  >
253
+ <VisStackedBar
254
+ v-if="stackedBars.entries.length > 0"
255
+ :x="xAccessor"
256
+ :y="stackedBars.accessors"
257
+ :color="stackedBars.colors"
258
+ :bar-width="stackedBars.width"
259
+ />
260
+ <VisGroupedBar
261
+ v-if="groupedBars.entries.length > 0"
262
+ :x="xAccessor"
263
+ :y="groupedBars.accessors"
264
+ :color="groupedBars.colors"
265
+ :group-width="groupedBars.width"
266
+ />
267
+ <VisArea
268
+ v-for="e in areaSeries"
269
+ :key="e.s.id"
270
+ :x="xAccessor"
271
+ :y="yAccessors[e.k]"
272
+ :color="e.color"
273
+ :line="true"
274
+ :line-color="e.s.lineColor || e.color"
275
+ :line-width="e.s.lineWidth"
276
+ />
196
277
  <VisLine
278
+ v-for="e in lineSeries"
279
+ :key="e.s.id"
197
280
  :x="xAccessor"
198
- :y="yAccessors"
199
- :color="lineColors"
200
- :curve-type="CURVE[block.curveType]"
201
- :line-width="block.lineWidth"
281
+ :y="yAccessors[e.k]"
282
+ :color="e.color"
283
+ :curve-type="CURVE[e.s.curveType]"
284
+ :line-width="e.s.lineWidth"
285
+ :line-dash-array="seriesDash[e.k]"
286
+ />
287
+ <VisScatter
288
+ v-for="e in scatterSeries"
289
+ :key="e.s.id"
290
+ :x="xAccessor"
291
+ :y="yAccessors[e.k]"
292
+ :color="e.color"
293
+ :size="sizeAccessors[e.k]"
202
294
  />
203
295
  <VisAxis
204
296
  type="x"
@@ -211,7 +303,7 @@ const placeholder = computed(() => {
211
303
  <VisCrosshair
212
304
  :x="xAccessor"
213
305
  :y="yAccessors"
214
- :color="lineColors"
306
+ :color="seriesColors"
215
307
  :template="crosshairTemplate"
216
308
  />
217
309
  <VisTooltip />
@@ -4,7 +4,7 @@ type __VLS_ModelProps = {
4
4
  };
5
5
  declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
6
  "update:block": (value: {
7
- readonly type: "com.shwfed.block.chart.line";
7
+ readonly type: "com.shwfed.block.chart.xy";
8
8
  readonly id: string;
9
9
  readonly caption?: readonly [{
10
10
  readonly locale: "zh";
@@ -22,9 +22,16 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
22
22
  readonly locale: "en" | "ja" | "ko";
23
23
  readonly message: string;
24
24
  }[]] | undefined;
25
+ readonly size?: string | undefined;
25
26
  readonly id: string;
26
27
  readonly color?: string | undefined;
28
+ readonly width?: string | undefined;
27
29
  readonly value: string;
30
+ readonly chart: "area" | "line" | "groupedBar" | "scatter" | "stackedBar";
31
+ readonly curveType: "linear" | "step" | "monotoneX" | "natural" | "basis" | "cardinal" | "catmullRom" | "stepAfter" | "stepBefore";
32
+ readonly lineWidth: number;
33
+ readonly dash?: string | undefined;
34
+ readonly lineColor?: string | undefined;
28
35
  }[];
29
36
  readonly displayName?: string | undefined;
30
37
  readonly compatibilityDate: "2026-05-17";
@@ -34,12 +41,10 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
34
41
  readonly id: string;
35
42
  readonly request?: string | undefined;
36
43
  }[];
37
- readonly curveType: "linear" | "step" | "monotoneX" | "natural" | "basis" | "cardinal" | "catmullRom" | "stepAfter" | "stepBefore";
38
- readonly lineWidth: number;
39
44
  }) => any;
40
45
  }, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
41
46
  "onUpdate:block"?: ((value: {
42
- readonly type: "com.shwfed.block.chart.line";
47
+ readonly type: "com.shwfed.block.chart.xy";
43
48
  readonly id: string;
44
49
  readonly caption?: readonly [{
45
50
  readonly locale: "zh";
@@ -57,9 +62,16 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
57
62
  readonly locale: "en" | "ja" | "ko";
58
63
  readonly message: string;
59
64
  }[]] | undefined;
65
+ readonly size?: string | undefined;
60
66
  readonly id: string;
61
67
  readonly color?: string | undefined;
68
+ readonly width?: string | undefined;
62
69
  readonly value: string;
70
+ readonly chart: "area" | "line" | "groupedBar" | "scatter" | "stackedBar";
71
+ readonly curveType: "linear" | "step" | "monotoneX" | "natural" | "basis" | "cardinal" | "catmullRom" | "stepAfter" | "stepBefore";
72
+ readonly lineWidth: number;
73
+ readonly dash?: string | undefined;
74
+ readonly lineColor?: string | undefined;
63
75
  }[];
64
76
  readonly displayName?: string | undefined;
65
77
  readonly compatibilityDate: "2026-05-17";
@@ -69,8 +81,6 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
69
81
  readonly id: string;
70
82
  readonly request?: string | undefined;
71
83
  }[];
72
- readonly curveType: "linear" | "step" | "monotoneX" | "natural" | "basis" | "cardinal" | "catmullRom" | "stepAfter" | "stepBefore";
73
- readonly lineWidth: number;
74
84
  }) => any) | undefined;
75
85
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
76
86
  declare const _default: typeof __VLS_export;
@@ -3,11 +3,11 @@ import type { Environment } from '../../../../../vendor/cel-js/lib/index.js';
3
3
  export { getStructFieldDescription, getStructFieldTitle } from '../../../../table/utils/schema-meta.js';
4
4
  type AnySchema = Schema.Schema<any, any, never>;
5
5
  type Configure = (env: Environment) => void;
6
- export declare const type: "com.shwfed.block.chart.line";
6
+ export declare const type: "com.shwfed.block.chart.xy";
7
7
  export declare const compatibilityDate: "2026-05-17";
8
8
  export declare const metadata: {
9
- readonly name: "折线图";
10
- readonly icon: "fluent:data-line-20-regular";
9
+ readonly name: "图表";
10
+ readonly icon: "fluent:chart-multiple-20-regular";
11
11
  readonly w: {
12
12
  readonly initial: 20;
13
13
  readonly min: 8;
@@ -20,6 +20,7 @@ export declare const metadata: {
20
20
  };
21
21
  };
22
22
  export declare const CurveType: Schema.Literal<["linear", "monotoneX", "natural", "basis", "cardinal", "catmullRom", "step", "stepAfter", "stepBefore"]>;
23
+ export declare const ChartType: Schema.Literal<["line", "area", "groupedBar", "scatter", "stackedBar"]>;
23
24
  /**
24
25
  * A named data source. Exported so the config editor can read field
25
26
  * `title` / `description` annotations without rebuilding the whole schema.
@@ -31,8 +32,10 @@ export declare function dataSourceSchema(configure: Configure): Schema.Struct<{
31
32
  data: Schema.Schema<string, string, never>;
32
33
  }>;
33
34
  /**
34
- * One Y series. Exported so the config editor can read field
35
- * `title` / `description` annotations off it.
35
+ * One Y series. A flat struct: `chart` selects how the series renders, and the
36
+ * variant-specific fields below it apply only to the matching chart type
37
+ * (others are ignored at render time). Exported so the config editor can read
38
+ * field `title` / `description` annotations off it.
36
39
  */
37
40
  export declare function ySeriesSchema(configure: Configure): Schema.Struct<{
38
41
  id: Schema.refine<string, typeof Schema.String>;
@@ -44,10 +47,23 @@ export declare function ySeriesSchema(configure: Configure): Schema.Struct<{
44
47
  locale: Schema.Literal<["ja", "en", "ko"]>;
45
48
  message: Schema.SchemaClass<string, string, never>;
46
49
  }>]>>;
50
+ chart: Schema.optionalWith<Schema.Literal<["line", "area", "groupedBar", "scatter", "stackedBar"]>, {
51
+ default: () => "line";
52
+ }>;
47
53
  color: Schema.optional<typeof Schema.String>;
54
+ curveType: Schema.optionalWith<Schema.Literal<["linear", "monotoneX", "natural", "basis", "cardinal", "catmullRom", "step", "stepAfter", "stepBefore"]>, {
55
+ default: () => "monotoneX";
56
+ }>;
57
+ lineWidth: Schema.optionalWith<Schema.filter<typeof Schema.Number>, {
58
+ default: () => number;
59
+ }>;
60
+ dash: Schema.optional<Schema.Schema<string, string, never>>;
61
+ lineColor: Schema.optional<typeof Schema.String>;
62
+ width: Schema.optional<Schema.Schema<string, string, never>>;
63
+ size: Schema.optional<Schema.Schema<string, string, never>>;
48
64
  }>;
49
65
  export declare function schema(configure: Configure, _blockRef?: AnySchema): Schema.refine<{
50
- readonly type: "com.shwfed.block.chart.line";
66
+ readonly type: "com.shwfed.block.chart.xy";
51
67
  readonly id: string;
52
68
  readonly caption?: readonly [{
53
69
  readonly locale: "zh";
@@ -65,9 +81,16 @@ export declare function schema(configure: Configure, _blockRef?: AnySchema): Sch
65
81
  readonly locale: "en" | "ja" | "ko";
66
82
  readonly message: string;
67
83
  }[]] | undefined;
84
+ readonly size?: string | undefined;
68
85
  readonly id: string;
69
86
  readonly color?: string | undefined;
87
+ readonly width?: string | undefined;
70
88
  readonly value: string;
89
+ readonly chart: "area" | "line" | "groupedBar" | "scatter" | "stackedBar";
90
+ readonly curveType: "linear" | "step" | "monotoneX" | "natural" | "basis" | "cardinal" | "catmullRom" | "stepAfter" | "stepBefore";
91
+ readonly lineWidth: number;
92
+ readonly dash?: string | undefined;
93
+ readonly lineColor?: string | undefined;
71
94
  }[];
72
95
  readonly displayName?: string | undefined;
73
96
  readonly compatibilityDate: "2026-05-17";
@@ -77,11 +100,9 @@ export declare function schema(configure: Configure, _blockRef?: AnySchema): Sch
77
100
  readonly id: string;
78
101
  readonly request?: string | undefined;
79
102
  }[];
80
- readonly curveType: "linear" | "step" | "monotoneX" | "natural" | "basis" | "cardinal" | "catmullRom" | "stepAfter" | "stepBefore";
81
- readonly lineWidth: number;
82
103
  }, Schema.Struct<{
83
104
  id: Schema.refine<string, typeof Schema.String>;
84
- type: Schema.tag<"com.shwfed.block.chart.line">;
105
+ type: Schema.tag<"com.shwfed.block.chart.xy">;
85
106
  compatibilityDate: Schema.tag<"2026-05-17">;
86
107
  displayName: Schema.optional<Schema.SchemaClass<string, string, never>>;
87
108
  caption: Schema.optional<Schema.TupleType<readonly [Schema.Struct<{
@@ -106,9 +127,16 @@ export declare function schema(configure: Configure, _blockRef?: AnySchema): Sch
106
127
  readonly locale: "en" | "ja" | "ko";
107
128
  readonly message: string;
108
129
  }[]] | undefined;
130
+ readonly size?: string | undefined;
109
131
  readonly id: string;
110
132
  readonly color?: string | undefined;
133
+ readonly width?: string | undefined;
111
134
  readonly value: string;
135
+ readonly chart: "area" | "line" | "groupedBar" | "scatter" | "stackedBar";
136
+ readonly curveType: "linear" | "step" | "monotoneX" | "natural" | "basis" | "cardinal" | "catmullRom" | "stepAfter" | "stepBefore";
137
+ readonly lineWidth: number;
138
+ readonly dash?: string | undefined;
139
+ readonly lineColor?: string | undefined;
112
140
  }[], Schema.Array$<Schema.Struct<{
113
141
  id: Schema.refine<string, typeof Schema.String>;
114
142
  value: Schema.Schema<string, string, never>;
@@ -119,16 +147,24 @@ export declare function schema(configure: Configure, _blockRef?: AnySchema): Sch
119
147
  locale: Schema.Literal<["ja", "en", "ko"]>;
120
148
  message: Schema.SchemaClass<string, string, never>;
121
149
  }>]>>;
150
+ chart: Schema.optionalWith<Schema.Literal<["line", "area", "groupedBar", "scatter", "stackedBar"]>, {
151
+ default: () => "line";
152
+ }>;
122
153
  color: Schema.optional<typeof Schema.String>;
154
+ curveType: Schema.optionalWith<Schema.Literal<["linear", "monotoneX", "natural", "basis", "cardinal", "catmullRom", "step", "stepAfter", "stepBefore"]>, {
155
+ default: () => "monotoneX";
156
+ }>;
157
+ lineWidth: Schema.optionalWith<Schema.filter<typeof Schema.Number>, {
158
+ default: () => number;
159
+ }>;
160
+ dash: Schema.optional<Schema.Schema<string, string, never>>;
161
+ lineColor: Schema.optional<typeof Schema.String>;
162
+ width: Schema.optional<Schema.Schema<string, string, never>>;
163
+ size: Schema.optional<Schema.Schema<string, string, never>>;
123
164
  }>>>;
124
- curveType: Schema.optionalWith<Schema.Literal<["linear", "monotoneX", "natural", "basis", "cardinal", "catmullRom", "step", "stepAfter", "stepBefore"]>, {
125
- default: () => "monotoneX";
126
- }>;
127
- lineWidth: Schema.optionalWith<Schema.filter<typeof Schema.Number>, {
128
- default: () => number;
129
- }>;
130
165
  }>>;
131
166
  export declare function defaultBody(): Record<string, unknown>;
132
167
  export type Value = Schema.Schema.Type<ReturnType<typeof schema>>;
133
168
  export type YSeriesValue = Value['y'][number];
134
169
  export type DataSourceValue = Value['dataSources'][number];
170
+ export type ChartTypeValue = Schema.Schema.Type<typeof ChartType>;
@@ -2,11 +2,11 @@ import { Schema } from "effect";
2
2
  import { Expression } from "../../../../../share/expression.js";
3
3
  import { Locale } from "../../../../../share/locale.js";
4
4
  export { getStructFieldDescription, getStructFieldTitle } from "../../../../table/utils/schema-meta.js";
5
- export const type = "com.shwfed.block.chart.line";
5
+ export const type = "com.shwfed.block.chart.xy";
6
6
  export const compatibilityDate = "2026-05-17";
7
7
  export const metadata = {
8
- name: "\u6298\u7EBF\u56FE",
9
- icon: "fluent:data-line-20-regular",
8
+ name: "\u56FE\u8868",
9
+ icon: "fluent:chart-multiple-20-regular",
10
10
  w: { initial: 20, min: 8, max: Infinity },
11
11
  h: { initial: 9, min: 5, max: Infinity }
12
12
  };
@@ -21,7 +21,15 @@ export const CurveType = Schema.Literal(
21
21
  "stepAfter",
22
22
  "stepBefore"
23
23
  );
24
+ export const ChartType = Schema.Literal(
25
+ "line",
26
+ "area",
27
+ "groupedBar",
28
+ "scatter",
29
+ "stackedBar"
30
+ );
24
31
  const isListType = (t) => t === "dyn" || t.startsWith("list") || t.startsWith("optional");
32
+ const isNumberType = (t) => t === "dyn" || t === "number" || t.startsWith("optional");
25
33
  function listExpression(configure) {
26
34
  return Expression({
27
35
  configure,
@@ -29,6 +37,13 @@ function listExpression(configure) {
29
37
  unlistedVariablesAreDyn: true
30
38
  });
31
39
  }
40
+ function numberExpression(configure) {
41
+ return Expression({
42
+ configure,
43
+ resultType: isNumberType,
44
+ unlistedVariablesAreDyn: true
45
+ });
46
+ }
32
47
  export function dataSourceSchema(configure) {
33
48
  const CelRequest = Expression({
34
49
  configure: (env) => {
@@ -75,11 +90,48 @@ export function ySeriesSchema(configure) {
75
90
  title: "\u6807\u7B7E",
76
91
  description: "\u56FE\u4F8B\u4E0E\u63D0\u793A\u6846\u4E2D\u663E\u793A\u7684\u7CFB\u5217\u540D\uFF1B\u7559\u7A7A\u5219\u7528\u8868\u8FBE\u5F0F\u539F\u6587"
77
92
  }),
93
+ chart: Schema.optionalWith(ChartType, { default: () => "line" }).annotations({
94
+ title: "\u56FE\u8868\u7C7B\u578B",
95
+ description: "\u8BE5\u7CFB\u5217\u7684\u6E32\u67D3\u65B9\u5F0F\uFF1A\u6298\u7EBF / \u9762\u79EF / \u5206\u7EC4\u67F1 / \u6563\u70B9 / \u5806\u53E0\u67F1"
96
+ }),
78
97
  color: Schema.optional(Schema.String).annotations({
79
98
  title: "\u989C\u8272",
80
- description: "\u7EBF\u6761\u989C\u8272\uFF08CSS \u989C\u8272\u503C\uFF09\uFF1B\u7559\u7A7A\u5219\u6309\u8C03\u8272\u677F\u81EA\u52A8\u53D6\u8272"
99
+ description: "\u7CFB\u5217\u4E3B\u8272\uFF08CSS \u989C\u8272\u503C\uFF09\u2014\u2014\u6298\u7EBF\u63CF\u8FB9 / \u9762\u79EF\u586B\u5145 / \u67F1\u4F53 / \u6563\u70B9\uFF1B\u7559\u7A7A\u5219\u6309\u8C03\u8272\u677F\u81EA\u52A8\u53D6\u8272"
100
+ }),
101
+ // line
102
+ curveType: Schema.optionalWith(CurveType, { default: () => "monotoneX" }).annotations({
103
+ title: "\u66F2\u7EBF\u7C7B\u578B",
104
+ description: "\u6298\u7EBF\u5728\u76F8\u90BB\u6570\u636E\u70B9\u4E4B\u95F4\u7684\u63D2\u503C\u65B9\u5F0F\uFF08\u5BF9\u5E94 unovis `CurveType`\uFF09\uFF1B\u4EC5\u6298\u7EBF\u7C7B\u578B\u751F\u6548"
105
+ }),
106
+ // line / area
107
+ lineWidth: Schema.optionalWith(
108
+ Schema.Number.pipe(Schema.positive()),
109
+ { default: () => 2 }
110
+ ).annotations({
111
+ title: "\u7EBF\u5BBD",
112
+ description: "\u7EBF\u6761\u5BBD\u5EA6\uFF08\u50CF\u7D20\uFF09\uFF1B\u6298\u7EBF\u7C7B\u578B\u4E3A\u6298\u7EBF\u672C\u8EAB\uFF0C\u9762\u79EF\u7C7B\u578B\u4E3A\u9876\u90E8\u63CF\u8FB9\u7EBF"
113
+ }),
114
+ // line
115
+ dash: Schema.optional(listExpression(configure)).annotations({
116
+ title: "\u865A\u7EBF",
117
+ description: "\u8FD4\u56DE\u4E00\u4E2A\u6570\u5B57\u5217\u8868\u4F5C\u4E3A\u300C\u7EBF\u6BB5 / \u7A7A\u767D\u300D\u865A\u7EBF\u6A21\u5F0F\uFF08\u5982 `[4, 4]`\uFF09\uFF1B\u7559\u7A7A\u4E3A\u5B9E\u7EBF\u3002\u4EC5\u6298\u7EBF\u7C7B\u578B\u751F\u6548"
118
+ }),
119
+ // area
120
+ lineColor: Schema.optional(Schema.String).annotations({
121
+ title: "\u63CF\u8FB9\u989C\u8272",
122
+ description: "\u9762\u79EF\u56FE\u9876\u90E8\u63CF\u8FB9\u7EBF\u989C\u8272\uFF08CSS \u989C\u8272\u503C\uFF09\uFF1B\u7559\u7A7A\u5219\u4E0E\u586B\u5145\u540C\u8272\u3002\u4EC5\u9762\u79EF\u7C7B\u578B\u751F\u6548"
123
+ }),
124
+ // groupedBar / stackedBar
125
+ width: Schema.optional(numberExpression(configure)).annotations({
126
+ title: "\u67F1\u5BBD",
127
+ description: "\u8FD4\u56DE\u67F1 / \u67F1\u7EC4\u5BBD\u5EA6\uFF08\u50CF\u7D20\uFF09\u7684 CEL \u8868\u8FBE\u5F0F\uFF1B\u7559\u7A7A\u5219\u81EA\u52A8\u3002\u4EC5\u5206\u7EC4\u67F1\u3001\u5806\u53E0\u67F1\u7C7B\u578B\u751F\u6548"
128
+ }),
129
+ // scatter
130
+ size: Schema.optional(listExpression(configure)).annotations({
131
+ title: "\u70B9\u5927\u5C0F",
132
+ description: "\u8FD4\u56DE\u6BCF\u4E2A\u70B9\u76F4\u5F84\uFF08\u50CF\u7D20\uFF09\u7684\u6570\u5B57\u5217\u8868\uFF0C\u4E0E Y \u6309\u4E0B\u6807\u5BF9\u9F50\uFF1B\u7559\u7A7A\u5219\u7528\u9ED8\u8BA4\u5927\u5C0F\u3002\u4EC5\u6563\u70B9\u7C7B\u578B\u751F\u6548"
81
133
  })
82
- }).annotations({ title: "Y \u7CFB\u5217", description: "\u4E00\u4E2A Y \u7CFB\u5217\u5BF9\u5E94\u4E00\u6761\u6298\u7EBF" });
134
+ }).annotations({ title: "Y \u7CFB\u5217", description: "\u4E00\u4E2A Y \u7CFB\u5217\uFF0C\u53EF\u72EC\u7ACB\u9009\u62E9\u56FE\u8868\u7C7B\u578B" });
83
135
  }
84
136
  export function schema(configure, _blockRef) {
85
137
  return Schema.Struct({
@@ -104,18 +156,7 @@ export function schema(configure, _blockRef) {
104
156
  }),
105
157
  y: Schema.Array(ySeriesSchema(configure)).pipe(Schema.minItems(1)).annotations({
106
158
  title: "Y",
107
- description: "\u6BCF\u4E2A\u7CFB\u5217\u753B\u4E00\u6761\u7EBF\uFF0C\u8FD4\u56DE\u7684\u5217\u8868\u4E0E X \u6309\u4E0B\u6807\u5BF9\u9F50\uFF1B\u81F3\u5C11\u914D\u7F6E\u4E00\u6761"
108
- }),
109
- curveType: Schema.optionalWith(CurveType, { default: () => "monotoneX" }).annotations({
110
- title: "\u66F2\u7EBF\u7C7B\u578B",
111
- description: "\u6298\u7EBF\u5728\u76F8\u90BB\u6570\u636E\u70B9\u4E4B\u95F4\u7684\u63D2\u503C\u65B9\u5F0F\uFF08\u5BF9\u5E94 unovis `CurveType`\uFF09"
112
- }),
113
- lineWidth: Schema.optionalWith(
114
- Schema.Number.pipe(Schema.positive()),
115
- { default: () => 2 }
116
- ).annotations({
117
- title: "\u7EBF\u5BBD",
118
- description: "\u6298\u7EBF\u5BBD\u5EA6\uFF08\u50CF\u7D20\uFF09"
159
+ description: "\u6BCF\u4E2A\u7CFB\u5217\u4E00\u6761\u6570\u636E\uFF0C\u6309\u6240\u9009\u56FE\u8868\u7C7B\u578B\u6E32\u67D3\uFF0C\u8FD4\u56DE\u7684\u5217\u8868\u4E0E X \u6309\u4E0B\u6807\u5BF9\u9F50\uFF1B\u81F3\u5C11\u914D\u7F6E\u4E00\u6761"
119
160
  })
120
161
  }).pipe(
121
162
  Schema.filter((value) => {
@@ -127,16 +168,20 @@ export function schema(configure, _blockRef) {
127
168
  return true;
128
169
  })
129
170
  ).annotations({
130
- title: "\u6298\u7EBF\u56FE\u5757",
131
- description: "\u4ECE\u547D\u540D\u6570\u636E\u6E90\u53D6\u6570\uFF0C\u628A X / Y \u5217\u8868\u6E32\u67D3\u4E3A\u6298\u7EBF\u56FE"
171
+ title: "XY \u56FE\u8868\u5757",
172
+ description: "\u4ECE\u547D\u540D\u6570\u636E\u6E90\u53D6\u6570\uFF0C\u628A X / Y \u5217\u8868\u6E32\u67D3\u4E3A\u6298\u7EBF / \u9762\u79EF / \u67F1 / \u6563\u70B9\u56FE"
132
173
  });
133
174
  }
134
175
  export function defaultBody() {
135
176
  return {
136
177
  dataSources: [],
137
178
  x: "[]",
138
- y: [{ id: crypto.randomUUID(), value: "[]" }],
139
- curveType: "monotoneX",
140
- lineWidth: 2
179
+ y: [{
180
+ id: crypto.randomUUID(),
181
+ value: "[]",
182
+ chart: "line",
183
+ curveType: "monotoneX",
184
+ lineWidth: 2
185
+ }]
141
186
  };
142
187
  }