@wodecorp/openui-vue-dashboard-library 0.1.0 → 0.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/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
+ import { AreaChart, BarChart, LineChart, PieChart, ScatterChart, ThemeProvider as ThemeProvider$1 } from "@wodecorp/openui-vue-ui";
1
2
  import { computed, defineComponent, h, inject, onScopeDispose, provide, ref, shallowRef, toValue, useId, watch, watchEffect } from "vue";
2
3
  import { createLibrary, defineComponent as defineComponent$1, reactive, tagSchemaId, useStateField } from "@wodecorp/openui-vue-lang";
3
4
  import { z } from "zod/v4";
4
- import { AreaChart, BarChart, LineChart, PieChart, ScatterChart } from "@wodecorp/openui-vue-ui";
5
5
  import { geoAlbersUsa, geoNaturalEarth1, geoPath } from "d3-geo";
6
6
  import { feature } from "topojson-client";
7
7
  // src/components/defaultThemes.ts
@@ -199,6 +199,7 @@ const ThemeProvider = defineComponent({
199
199
  darkTheme: Object
200
200
  },
201
201
  setup(props, { slots }) {
202
+ const scope = `openui-dashboard-theme-${useId().replace(/[^a-zA-Z0-9-_]/g, "")}`;
202
203
  const parent = inject(ThemeContext, null);
203
204
  const mode = computed(() => props.mode ?? parent?.mode.value ?? "light");
204
205
  const style = computed(() => {
@@ -213,12 +214,16 @@ const ThemeProvider = defineComponent({
213
214
  style
214
215
  });
215
216
  return () => h("div", {
217
+ class: scope,
216
218
  "data-dashboard-mode": mode.value,
217
219
  style: {
218
220
  display: "contents",
219
221
  ...style.value
220
222
  }
221
- }, slots.default?.());
223
+ }, [h(ThemeProvider$1, {
224
+ mode: mode.value,
225
+ cssSelector: `.${scope}`
226
+ }, { default: () => slots.default?.() })]);
222
227
  }
223
228
  });
224
229
  const DashboardTheme = defineComponent({
@@ -828,6 +833,11 @@ const BarsImpl = defineComponent({
828
833
  });
829
834
  const stacked = p.props.stacked === true || p.props.stacked === "percent";
830
835
  const orientation = p.props.orientation === "vertical" ? "vertical" : "horizontal";
836
+ const palette = [];
837
+ seriesList.forEach((s, i) => {
838
+ palette.push(seriesColor(i));
839
+ if (compare.enabled.value && s.previous?.length) palette.push(MUTED_COLOR);
840
+ });
831
841
  return h("div", {
832
842
  ...p.bindSource?.() ?? {},
833
843
  class: "openui-dashboard-bars",
@@ -846,7 +856,7 @@ const BarsImpl = defineComponent({
846
856
  categoryKey: "__cat",
847
857
  orientation,
848
858
  variant: stacked ? "stacked" : "grouped",
849
- customPalette: seriesList.map((_, i) => seriesColor(i)),
859
+ customPalette: palette,
850
860
  isAnimationActive: false
851
861
  })]), refs.length ? h("div", { style: {
852
862
  display: "flex",
@@ -999,7 +1009,29 @@ const DumbbellComponent = defineComponent$1({
999
1009
  gap: "14px",
1000
1010
  fontSize: "11px",
1001
1011
  color: "var(--openui-dashboard-ink-muted)"
1002
- } }, [h("span", null, `○ ${props.beforeLabel ?? "Before"}`), h("span", null, `● ${props.afterLabel ?? "After"}`)]), ...labels.map((label, i) => {
1012
+ } }, [h("span", { style: {
1013
+ display: "inline-flex",
1014
+ alignItems: "center",
1015
+ gap: "5px"
1016
+ } }, [h("span", { style: {
1017
+ width: "8px",
1018
+ height: "8px",
1019
+ borderRadius: "999px",
1020
+ border: `2px solid ${MUTED_COLOR}`,
1021
+ background: "var(--openui-dashboard-surface)",
1022
+ boxSizing: "border-box",
1023
+ display: "inline-block"
1024
+ } }), props.beforeLabel ?? "Before"]), h("span", { style: {
1025
+ display: "inline-flex",
1026
+ alignItems: "center",
1027
+ gap: "5px"
1028
+ } }, [h("span", { style: {
1029
+ width: "8px",
1030
+ height: "8px",
1031
+ borderRadius: "999px",
1032
+ background: props.goodWhen === "neutral" ? seriesColor(0) : "var(--openui-dashboard-good-mark)",
1033
+ display: "inline-block"
1034
+ } }), props.afterLabel ?? "After"])]), ...labels.map((label, i) => {
1003
1035
  const b = before[i] ?? 0;
1004
1036
  const a = after[i] ?? 0;
1005
1037
  const delta = computeDelta(a, b, props.format);
@@ -1397,17 +1429,18 @@ const SegmentedBarComponent = defineComponent$1({
1397
1429
  background: p.label === "Other" ? MUTED_COLOR : seriesColor(i)
1398
1430
  }
1399
1431
  }))), h("div", { style: {
1400
- display: "grid",
1401
- gridTemplateColumns: "repeat(auto-fit, minmax(140px, 1fr))",
1402
- gap: "8px",
1432
+ display: "flex",
1433
+ flexWrap: "wrap",
1434
+ alignItems: "center",
1435
+ gap: "8px 20px",
1403
1436
  fontSize: "12px"
1404
1437
  } }, all.map((p, i) => h("div", {
1405
1438
  key: p.label + i,
1406
1439
  style: {
1407
- display: "flex",
1440
+ display: "inline-flex",
1408
1441
  alignItems: "center",
1409
- justifyContent: "space-between",
1410
- gap: "6px"
1442
+ gap: "6px",
1443
+ whiteSpace: "nowrap"
1411
1444
  }
1412
1445
  }, [h("span", { style: {
1413
1446
  display: "inline-flex",
@@ -1419,11 +1452,13 @@ const SegmentedBarComponent = defineComponent$1({
1419
1452
  height: "8px",
1420
1453
  borderRadius: "2px",
1421
1454
  background: p.label === "Other" ? MUTED_COLOR : seriesColor(i),
1422
- display: "inline-block"
1455
+ display: "inline-block",
1456
+ flexShrink: 0
1423
1457
  } }), p.label]), h("span", { style: {
1424
1458
  fontVariantNumeric: "tabular-nums",
1459
+ fontWeight: 500,
1425
1460
  color: "var(--openui-dashboard-ink-secondary)"
1426
- } }, `${formatValue(p.value, props.format)} · ${(p.value / total * 100).toFixed(0)}%`)])))]);
1461
+ } }, props.format === "percent" ? formatValue(p.value, props.format) : `${formatValue(p.value, props.format)} · ${(p.value / total * 100).toFixed(0)}%`)])))]);
1427
1462
  }
1428
1463
  });
1429
1464
  // src/lib/composition/Treemap/schema.ts
@@ -1464,6 +1499,7 @@ const TreemapComponent = defineComponent$1({
1464
1499
  }, items.map((item, idx) => {
1465
1500
  const share = item.value / total * 100;
1466
1501
  const colorIdx = item.group ? Math.max(0, groupOrder.indexOf(item.group)) : idx;
1502
+ const textColor = colorIdx % 8 === 2 ? "#0f172a" : "#ffffff";
1467
1503
  return h("div", {
1468
1504
  key: item.label + idx,
1469
1505
  title: `${item.label}${item.group ? ` (${item.group})` : ""}: ${formatValue(item.value, props.format)} (${share.toFixed(1)}%)`,
@@ -1473,7 +1509,7 @@ const TreemapComponent = defineComponent$1({
1473
1509
  padding: "8px",
1474
1510
  borderRadius: "6px",
1475
1511
  background: seriesColor(colorIdx),
1476
- color: "#ffffff",
1512
+ color: textColor,
1477
1513
  display: "flex",
1478
1514
  flexDirection: "column",
1479
1515
  justifyContent: "space-between",
@@ -1722,9 +1758,9 @@ const ChipFilterImpl = defineComponent({
1722
1758
  fontSize: "12px",
1723
1759
  fontWeight: active ? 600 : 500,
1724
1760
  cursor: "pointer",
1725
- background: active ? "var(--openui-dashboard-accent)" : "var(--openui-dashboard-neutral-soft)",
1726
- color: active ? "var(--openui-dashboard-accent-ink)" : "var(--openui-dashboard-ink)",
1727
- border: "1px solid transparent"
1761
+ background: active ? "color-mix(in srgb, var(--openui-dashboard-series-1) 14%, var(--openui-dashboard-surface))" : "var(--openui-dashboard-neutral-soft)",
1762
+ color: active ? "var(--openui-dashboard-series-1)" : "var(--openui-dashboard-ink)",
1763
+ border: active ? "1px solid color-mix(in srgb, var(--openui-dashboard-series-1) 36%, transparent)" : "1px solid transparent"
1728
1764
  }
1729
1765
  }, opt.label ?? opt.value);
1730
1766
  })]);
@@ -1737,6 +1773,55 @@ const ChipFilterComponent = defineComponent$1({
1737
1773
  description: "Pills for 2–6 segments; one is always selected. value takes the $variable that holds the selected option's value. In a FilterBar for a dashboard-wide segment, or in a Card's controls to switch that card's breakdown (leave label out there: the card title names it).",
1738
1774
  component: ChipFilterImpl
1739
1775
  });
1776
+ // src/lib/filters/styledSelect.ts
1777
+ function renderStyledSelect(opts) {
1778
+ return h("span", {
1779
+ class: "openui-dashboard-select-wrap",
1780
+ style: {
1781
+ position: "relative",
1782
+ display: "inline-flex",
1783
+ alignItems: "center"
1784
+ }
1785
+ }, [h("select", {
1786
+ id: opts.id,
1787
+ value: opts.value,
1788
+ class: "openui-dashboard-select",
1789
+ style: {
1790
+ appearance: "none",
1791
+ WebkitAppearance: "none",
1792
+ padding: "5px 28px 5px 10px",
1793
+ borderRadius: "var(--openui-dashboard-radius-sm)",
1794
+ border: "1px solid var(--openui-dashboard-border-strong)",
1795
+ background: "var(--openui-dashboard-surface)",
1796
+ color: "var(--openui-dashboard-ink)",
1797
+ fontSize: "12px",
1798
+ lineHeight: "1.4",
1799
+ cursor: "pointer"
1800
+ },
1801
+ onChange: (e) => opts.onChange(e.target.value)
1802
+ }, opts.options.map((opt) => h("option", {
1803
+ key: opt.value,
1804
+ value: opt.value
1805
+ }, opt.label ?? opt.value))), h("svg", {
1806
+ width: "12",
1807
+ height: "12",
1808
+ viewBox: "0 0 12 12",
1809
+ fill: "none",
1810
+ "aria-hidden": "true",
1811
+ style: {
1812
+ position: "absolute",
1813
+ right: "9px",
1814
+ pointerEvents: "none",
1815
+ color: "var(--openui-dashboard-ink-muted)"
1816
+ }
1817
+ }, [h("path", {
1818
+ d: "M3 4.5L6 7.5L9 4.5",
1819
+ stroke: "currentColor",
1820
+ "stroke-width": "1.5",
1821
+ "stroke-linecap": "round",
1822
+ "stroke-linejoin": "round"
1823
+ })])]);
1824
+ }
1740
1825
  // src/lib/filters/CompareToggle/schema.ts
1741
1826
  const compareTogglePropsSchema = z.object({
1742
1827
  label: z.string().optional(),
@@ -1781,6 +1866,7 @@ const CompareToggleImpl = defineComponent({
1781
1866
  label: p.props.label || "Previous period"
1782
1867
  }];
1783
1868
  const current = field.isReactive ? String(field.value ?? (compare.enabled.value ? opts[0].value : "off")) : compare.enabled.value ? opts[0].value : "off";
1869
+ const isZh = typeof document !== "undefined" && document.documentElement.lang.toLowerCase().startsWith("zh");
1784
1870
  return h("label", {
1785
1871
  ...p.bindSource?.() ?? {},
1786
1872
  class: "openui-dashboard-compare-toggle",
@@ -1791,19 +1877,14 @@ const CompareToggleImpl = defineComponent({
1791
1877
  fontSize: "12px",
1792
1878
  color: "var(--openui-dashboard-ink-secondary)"
1793
1879
  }
1794
- }, [h("span", null, "Compare"), h("select", {
1880
+ }, [h("span", null, isZh ? "对比" : "Compare"), renderStyledSelect({
1795
1881
  id,
1796
1882
  value: current,
1797
- style: {
1798
- padding: "4px 8px",
1799
- borderRadius: "var(--openui-dashboard-radius-sm)",
1800
- border: "1px solid var(--openui-dashboard-border-strong)",
1801
- background: "var(--openui-dashboard-surface)",
1802
- color: "var(--openui-dashboard-ink)",
1803
- fontSize: "12px"
1804
- },
1805
- onChange: (e) => {
1806
- const next = e.target.value;
1883
+ options: [{
1884
+ value: "off",
1885
+ label: isZh ? "关闭" : "None"
1886
+ }, ...opts],
1887
+ onChange: (next) => {
1807
1888
  if (field.isReactive) field.setValue(next);
1808
1889
  if (next === "off") compare.setEnabled(false);
1809
1890
  else {
@@ -1812,10 +1893,7 @@ const CompareToggleImpl = defineComponent({
1812
1893
  compare.setEnabled(true);
1813
1894
  }
1814
1895
  }
1815
- }, [h("option", { value: "off" }, "None"), ...opts.map((opt) => h("option", {
1816
- key: opt.value,
1817
- value: opt.value
1818
- }, opt.label ?? opt.value))])]);
1896
+ })]);
1819
1897
  };
1820
1898
  }
1821
1899
  });
@@ -1883,21 +1961,11 @@ const DateRangeFilterImpl = defineComponent({
1883
1961
  fontSize: "12px",
1884
1962
  color: "var(--openui-dashboard-ink-secondary)"
1885
1963
  }
1886
- }, [p.props.label ? h("span", null, p.props.label) : null, h("select", {
1964
+ }, [p.props.label ? h("span", null, p.props.label) : null, renderStyledSelect({
1887
1965
  value: current,
1888
- style: {
1889
- padding: "4px 8px",
1890
- borderRadius: "var(--openui-dashboard-radius-sm)",
1891
- border: "1px solid var(--openui-dashboard-border-strong)",
1892
- background: "var(--openui-dashboard-surface)",
1893
- color: "var(--openui-dashboard-ink)",
1894
- fontSize: "12px"
1895
- },
1896
- onChange: (e) => field.setValue(e.target.value)
1897
- }, opts.map((opt) => h("option", {
1898
- key: opt.value,
1899
- value: opt.value
1900
- }, opt.label ?? opt.value)))]);
1966
+ options: opts,
1967
+ onChange: (next) => field.setValue(next)
1968
+ })]);
1901
1969
  };
1902
1970
  }
1903
1971
  });
@@ -1934,7 +2002,8 @@ const MultiSelectFilterImpl = defineComponent({
1934
2002
  return () => {
1935
2003
  const opts = Array.isArray(p.props.options) ? p.props.options : [];
1936
2004
  const selected = Array.isArray(field.value) ? field.value : [];
1937
- const summary = selected.length === 0 ? `${p.props.label}: All` : `${p.props.label} (${selected.length})`;
2005
+ const isZh = typeof document !== "undefined" && document.documentElement.lang.toLowerCase().startsWith("zh");
2006
+ const summary = selected.length === 0 ? isZh ? `${p.props.label}:全部` : `${p.props.label}: All` : `${p.props.label} (${selected.length})`;
1938
2007
  return h("div", {
1939
2008
  ...p.bindSource?.() ?? {},
1940
2009
  class: "openui-dashboard-multiselect-filter",
@@ -1944,20 +2013,41 @@ const MultiSelectFilterImpl = defineComponent({
1944
2013
  }
1945
2014
  }, [h("button", {
1946
2015
  type: "button",
2016
+ class: "openui-dashboard-select",
1947
2017
  "aria-expanded": open.value,
1948
2018
  onClick: () => {
1949
2019
  open.value = !open.value;
1950
2020
  },
1951
2021
  style: {
1952
- padding: "4px 10px",
2022
+ display: "inline-flex",
2023
+ alignItems: "center",
2024
+ gap: "8px",
2025
+ padding: "5px 10px",
1953
2026
  borderRadius: "var(--openui-dashboard-radius-sm)",
1954
2027
  border: "1px solid var(--openui-dashboard-border-strong)",
1955
2028
  background: "var(--openui-dashboard-surface)",
1956
2029
  color: "var(--openui-dashboard-ink)",
1957
2030
  fontSize: "12px",
2031
+ lineHeight: "1.4",
1958
2032
  cursor: "pointer"
1959
2033
  }
1960
- }, summary), open.value ? h("div", { style: {
2034
+ }, [h("span", null, summary), h("svg", {
2035
+ width: "12",
2036
+ height: "12",
2037
+ viewBox: "0 0 12 12",
2038
+ fill: "none",
2039
+ "aria-hidden": "true",
2040
+ style: {
2041
+ color: "var(--openui-dashboard-ink-muted)",
2042
+ flexShrink: 0
2043
+ }
2044
+ }, [h("path", {
2045
+ d: "M3 4.5L6 7.5L9 4.5",
2046
+ stroke: "currentColor",
2047
+ "stroke-width": "1.5",
2048
+ "stroke-linecap": "round",
2049
+ "stroke-linejoin": "round"
2050
+ })])]), open.value ? h("div", { style: {
1961
2051
  position: "absolute",
1962
2052
  top: "calc(100% + 4px)",
1963
2053
  left: 0,
@@ -1985,6 +2075,7 @@ const MultiSelectFilterImpl = defineComponent({
1985
2075
  }, [h("input", {
1986
2076
  type: "checkbox",
1987
2077
  checked,
2078
+ style: { accentColor: "var(--openui-dashboard-accent)" },
1988
2079
  onChange: () => {
1989
2080
  const next = checked ? selected.filter((v) => v !== opt.value) : [...selected, opt.value];
1990
2081
  field.setValue(next);
@@ -2102,21 +2193,11 @@ const SelectFilterImpl = defineComponent({
2102
2193
  fontSize: "12px",
2103
2194
  color: "var(--openui-dashboard-ink-secondary)"
2104
2195
  }
2105
- }, [p.props.label ? h("span", null, p.props.label) : null, h("select", {
2196
+ }, [p.props.label ? h("span", null, p.props.label) : null, renderStyledSelect({
2106
2197
  value: current,
2107
- style: {
2108
- padding: "4px 8px",
2109
- borderRadius: "var(--openui-dashboard-radius-sm)",
2110
- border: "1px solid var(--openui-dashboard-border-strong)",
2111
- background: "var(--openui-dashboard-surface)",
2112
- color: "var(--openui-dashboard-ink)",
2113
- fontSize: "12px"
2114
- },
2115
- onChange: (e) => field.setValue(e.target.value)
2116
- }, opts.map((opt) => h("option", {
2117
- key: opt.value,
2118
- value: opt.value
2119
- }, opt.label ?? opt.value)))]);
2198
+ options: opts,
2199
+ onChange: (next) => field.setValue(next)
2200
+ })]);
2120
2201
  };
2121
2202
  }
2122
2203
  });
@@ -2152,11 +2233,12 @@ const filters = {
2152
2233
  display: "flex",
2153
2234
  flexWrap: "wrap",
2154
2235
  alignItems: "center",
2155
- gap: "10px",
2156
- padding: "10px 14px",
2157
- borderRadius: "var(--openui-dashboard-radius-md)",
2236
+ gap: "12px 18px",
2237
+ padding: "10px 16px",
2238
+ borderRadius: "var(--openui-dashboard-radius)",
2158
2239
  background: "var(--openui-dashboard-surface)",
2159
- border: "1px solid var(--openui-dashboard-border)"
2240
+ border: "1px solid var(--openui-dashboard-border)",
2241
+ boxShadow: "var(--openui-dashboard-shadow)"
2160
2242
  }
2161
2243
  }, [renderNode(props.filters)])
2162
2244
  }),
@@ -2265,6 +2347,7 @@ const FunnelImpl = defineComponent({
2265
2347
  const labels = toStrings(p.props.labels);
2266
2348
  const values = toNumbers(p.props.values).map((v) => Math.max(0, v ?? 0));
2267
2349
  const first = values[0] || 1;
2350
+ const isZh = typeof document !== "undefined" && /^zh\b/i.test(document.documentElement.lang || "");
2268
2351
  return h("div", {
2269
2352
  ...p.bindSource?.() ?? {},
2270
2353
  class: "openui-dashboard-funnel",
@@ -2292,7 +2375,7 @@ const FunnelImpl = defineComponent({
2292
2375
  color: "var(--openui-dashboard-ink-secondary)",
2293
2376
  cursor: "pointer"
2294
2377
  }
2295
- }, basis.value === "step" ? "Rate: step-to-step" : "Rate: from start")]), ...labels.map((label, i) => {
2378
+ }, basis.value === "step" ? isZh ? "转化率:环比" : "Rate: step-to-step" : isZh ? "转化率:累计" : "Rate: from start")]), ...labels.map((label, i) => {
2296
2379
  const val = values[i] ?? 0;
2297
2380
  const prevStep = i === 0 ? first : values[i - 1] || 1;
2298
2381
  const rate = basis.value === "step" ? val / prevStep * 100 : val / first * 100;
@@ -2488,7 +2571,11 @@ const GeoMapImpl = defineComponent({
2488
2571
  width: "100%",
2489
2572
  alignItems: "start"
2490
2573
  }
2491
- }, [h("svg", {
2574
+ }, [h("div", { style: {
2575
+ display: "flex",
2576
+ flexDirection: "column",
2577
+ gap: "8px"
2578
+ } }, [h("svg", {
2492
2579
  viewBox: "0 0 560 340",
2493
2580
  role: "img",
2494
2581
  "aria-label": `${p.props.region.toUpperCase()} choropleth map`,
@@ -2501,7 +2588,7 @@ const GeoMapImpl = defineComponent({
2501
2588
  const name = shape.properties?.name ?? "";
2502
2589
  const match = byKey.get(name.toLowerCase());
2503
2590
  const d = pathGen(shape) ?? void 0;
2504
- const fill = match ? sequentialColor(match.value, min, max).background : "var(--openui-dashboard-map-land)";
2591
+ const fill = match ? sequentialColor(match.value, min * .5, max).background : "var(--openui-dashboard-map-land)";
2505
2592
  const active = hovered.value && hovered.value === name.toLowerCase();
2506
2593
  return h("path", {
2507
2594
  key: name || idx,
@@ -2516,7 +2603,22 @@ const GeoMapImpl = defineComponent({
2516
2603
  hovered.value = null;
2517
2604
  }
2518
2605
  });
2519
- })), h("div", { style: {
2606
+ })), entries.length > 1 ? h("div", { style: {
2607
+ display: "flex",
2608
+ alignItems: "center",
2609
+ gap: "8px",
2610
+ fontSize: "11px",
2611
+ color: "var(--openui-dashboard-ink-muted)"
2612
+ } }, [
2613
+ h("span", { style: { fontVariantNumeric: "tabular-nums" } }, formatValue(min, p.props.format)),
2614
+ h("div", { style: {
2615
+ flex: "0 1 120px",
2616
+ height: "6px",
2617
+ borderRadius: "999px",
2618
+ background: "linear-gradient(90deg, var(--openui-dashboard-seq-2), var(--openui-dashboard-seq-5), var(--openui-dashboard-seq-9))"
2619
+ } }),
2620
+ h("span", { style: { fontVariantNumeric: "tabular-nums" } }, formatValue(max, p.props.format))
2621
+ ]) : null]), h("div", { style: {
2520
2622
  display: "flex",
2521
2623
  flexDirection: "column",
2522
2624
  gap: "6px",
@@ -2632,18 +2734,23 @@ const PointMapImpl = defineComponent({
2632
2734
  "stroke-width": .6
2633
2735
  })), ...points.map((pt, idx) => {
2634
2736
  if (!pt.xy) return null;
2635
- const r = 4 + Math.sqrt(pt.val / maxVal) * 14;
2737
+ const r = 4 + Math.sqrt(pt.val / maxVal) * 10;
2636
2738
  const colorIdx = pt.group ? Math.max(0, groupOrder.indexOf(pt.group)) : 0;
2637
- return h("circle", {
2638
- key: `pt-${idx}`,
2739
+ return h("g", { key: `pt-${idx}` }, [h("circle", {
2639
2740
  cx: pt.xy[0],
2640
2741
  cy: pt.xy[1],
2641
2742
  r,
2642
2743
  fill: seriesColor(colorIdx),
2643
- opacity: .78,
2744
+ opacity: .82,
2644
2745
  stroke: "var(--openui-dashboard-surface)",
2645
- "stroke-width": 1.2
2646
- });
2746
+ "stroke-width": 1.5
2747
+ }), idx < 8 ? h("text", {
2748
+ x: pt.xy[0] + r + 4,
2749
+ y: pt.xy[1] + 3,
2750
+ fill: "var(--openui-dashboard-ink)",
2751
+ "font-size": 10,
2752
+ "font-weight": 500
2753
+ }, pt.label) : null]);
2647
2754
  })]), h("div", { style: {
2648
2755
  display: "flex",
2649
2756
  flexDirection: "column",
@@ -2651,18 +2758,35 @@ const PointMapImpl = defineComponent({
2651
2758
  maxHeight: "320px",
2652
2759
  overflowY: "auto",
2653
2760
  fontSize: "12px"
2654
- } }, points.map((pt, idx) => h("div", {
2655
- key: pt.label + idx,
2656
- style: {
2657
- display: "flex",
2658
- justifyContent: "space-between",
2659
- gap: "8px"
2660
- }
2661
- }, [h("span", { style: { color: "var(--openui-dashboard-ink)" } }, pt.label), h("span", { style: {
2662
- fontWeight: 600,
2663
- fontVariantNumeric: "tabular-nums",
2664
- color: "var(--openui-dashboard-ink-secondary)"
2665
- } }, formatValue(pt.val, p.props.format))])))]);
2761
+ } }, points.map((pt, idx) => {
2762
+ const colorIdx = pt.group ? Math.max(0, groupOrder.indexOf(pt.group)) : 0;
2763
+ return h("div", {
2764
+ key: pt.label + idx,
2765
+ style: {
2766
+ display: "flex",
2767
+ alignItems: "center",
2768
+ justifyContent: "space-between",
2769
+ gap: "8px",
2770
+ padding: "3px 4px"
2771
+ }
2772
+ }, [h("span", { style: {
2773
+ display: "inline-flex",
2774
+ alignItems: "center",
2775
+ gap: "6px",
2776
+ color: "var(--openui-dashboard-ink)"
2777
+ } }, [h("span", { style: {
2778
+ width: "8px",
2779
+ height: "8px",
2780
+ borderRadius: "999px",
2781
+ background: seriesColor(colorIdx),
2782
+ display: "inline-block",
2783
+ flexShrink: 0
2784
+ } }), pt.label]), h("span", { style: {
2785
+ fontWeight: 600,
2786
+ fontVariantNumeric: "tabular-nums",
2787
+ color: "var(--openui-dashboard-ink-secondary)"
2788
+ } }, formatValue(pt.val, p.props.format))]);
2789
+ }))]);
2666
2790
  };
2667
2791
  }
2668
2792
  });
@@ -2906,6 +3030,13 @@ const TONE_COLOR$1 = {
2906
3030
  info: "var(--openui-dashboard-info)",
2907
3031
  neutral: "var(--openui-dashboard-ink-muted)"
2908
3032
  };
3033
+ const TONE_BG = {
3034
+ good: "var(--openui-dashboard-good-soft)",
3035
+ bad: "var(--openui-dashboard-bad-soft)",
3036
+ warning: "var(--openui-dashboard-warning-soft)",
3037
+ info: "var(--openui-dashboard-info-soft)",
3038
+ neutral: "var(--openui-dashboard-neutral-soft)"
3039
+ };
2909
3040
  function renderInlineChart(chartNode, currentValue, compareEnabled) {
2910
3041
  if (!chartNode || typeof chartNode !== "object") return null;
2911
3042
  const { typeName, props } = chartNode;
@@ -2937,6 +3068,7 @@ function renderInlineChart(chartNode, currentValue, compareEnabled) {
2937
3068
  const prevPath = compareEnabled && prev.length ? mkPath(prev) : "";
2938
3069
  return h("svg", {
2939
3070
  viewBox: "0 0 120 30",
3071
+ preserveAspectRatio: "none",
2940
3072
  style: {
2941
3073
  width: "100%",
2942
3074
  height: "30px",
@@ -2947,12 +3079,14 @@ function renderInlineChart(chartNode, currentValue, compareEnabled) {
2947
3079
  fill: "none",
2948
3080
  stroke: MUTED_COLOR,
2949
3081
  "stroke-width": 1.2,
2950
- "stroke-dasharray": "3 3"
3082
+ "stroke-dasharray": "3 3",
3083
+ "vector-effect": "non-scaling-stroke"
2951
3084
  }) : null, mainPath ? h("path", {
2952
3085
  d: mainPath,
2953
3086
  fill: "none",
2954
3087
  stroke: seriesColor(0),
2955
- "stroke-width": 1.8
3088
+ "stroke-width": 1.8,
3089
+ "vector-effect": "non-scaling-stroke"
2956
3090
  }) : null]);
2957
3091
  }
2958
3092
  if (typeName === "Progress") {
@@ -3038,21 +3172,35 @@ const KpiImpl = defineComponent({
3038
3172
  ...bind?.() ?? {},
3039
3173
  class: "openui-dashboard-kpi",
3040
3174
  style: {
3041
- padding: "16px",
3042
- borderRadius: "var(--openui-dashboard-radius-md)",
3175
+ padding: "16px 18px",
3176
+ borderRadius: "var(--openui-dashboard-radius)",
3043
3177
  background: "var(--openui-dashboard-surface)",
3044
3178
  border: "1px solid var(--openui-dashboard-border)",
3179
+ boxShadow: "var(--openui-dashboard-shadow)",
3045
3180
  display: "flex",
3046
3181
  flexDirection: "column",
3047
- gap: "6px",
3182
+ gap: "8px",
3048
3183
  minWidth: 0
3049
3184
  }
3050
3185
  }, [
3051
3186
  h("div", { style: {
3052
- fontSize: "12px",
3187
+ display: "flex",
3188
+ alignItems: "center",
3189
+ justifyContent: "space-between",
3190
+ gap: "8px"
3191
+ } }, [h("span", { style: {
3192
+ fontSize: "12.5px",
3053
3193
  fontWeight: 500,
3054
3194
  color: "var(--openui-dashboard-ink-secondary)"
3055
- } }, p.props.label),
3195
+ } }, p.props.label), delta && compare.enabled.value ? h("span", { style: {
3196
+ fontSize: "11.5px",
3197
+ fontWeight: 600,
3198
+ fontVariantNumeric: "tabular-nums",
3199
+ padding: "2px 7px",
3200
+ borderRadius: "999px",
3201
+ background: TONE_BG[tone] ?? TONE_BG.neutral,
3202
+ color: TONE_COLOR$1[tone]
3203
+ } }, delta.text) : null]),
3056
3204
  h("div", {
3057
3205
  ...bind?.("value") ?? {},
3058
3206
  style: {
@@ -3061,31 +3209,24 @@ const KpiImpl = defineComponent({
3061
3209
  gap: "8px",
3062
3210
  flexWrap: "wrap"
3063
3211
  }
3064
- }, [
3065
- p.props.tone && typeof p.props.value === "string" ? h("span", { style: {
3066
- width: "8px",
3067
- height: "8px",
3068
- borderRadius: "999px",
3069
- background: TONE_COLOR$1[p.props.tone] ?? TONE_COLOR$1.neutral,
3070
- display: "inline-block"
3071
- } }) : null,
3072
- h("span", { style: {
3073
- fontSize: "24px",
3074
- fontWeight: 650,
3075
- letterSpacing: "-0.02em",
3076
- fontVariantNumeric: "tabular-nums",
3077
- color: "var(--openui-dashboard-ink)"
3078
- } }, typeof p.props.value === "number" ? formatValue(p.props.value, p.props.format) : p.props.value ?? "—"),
3079
- delta ? h("span", { style: {
3080
- fontSize: "12px",
3081
- fontWeight: 500,
3082
- fontVariantNumeric: "tabular-nums",
3083
- color: TONE_COLOR$1[tone]
3084
- } }, delta.text) : null
3085
- ]),
3212
+ }, [p.props.tone && typeof p.props.value === "string" ? h("span", { style: {
3213
+ width: "8px",
3214
+ height: "8px",
3215
+ borderRadius: "999px",
3216
+ background: TONE_COLOR$1[p.props.tone] ?? TONE_COLOR$1.neutral,
3217
+ display: "inline-block"
3218
+ } }) : null, h("span", { style: {
3219
+ fontSize: "26px",
3220
+ fontWeight: 650,
3221
+ letterSpacing: "-0.025em",
3222
+ lineHeight: 1.15,
3223
+ fontVariantNumeric: "tabular-nums",
3224
+ color: "var(--openui-dashboard-ink)"
3225
+ } }, typeof p.props.value === "number" ? formatValue(p.props.value, p.props.format) : p.props.value ?? "—")]),
3086
3226
  p.props.hint ? h("div", { style: {
3087
- fontSize: "11px",
3088
- color: "var(--openui-dashboard-ink-muted)"
3227
+ fontSize: "12px",
3228
+ color: "var(--openui-dashboard-ink-muted)",
3229
+ lineHeight: 1.4
3089
3230
  } }, p.props.hint) : null,
3090
3231
  p.props.chart ? renderInlineChart(p.props.chart, numVal, compare.enabled.value) : null
3091
3232
  ]);
@@ -3112,7 +3253,7 @@ const KpisComponent = defineComponent$1({
3112
3253
  class: "openui-dashboard-kpis",
3113
3254
  style: {
3114
3255
  display: "grid",
3115
- gridTemplateColumns: "repeat(auto-fit, minmax(180px, 1fr))",
3256
+ gridTemplateColumns: "repeat(auto-fit, minmax(155px, 1fr))",
3116
3257
  gap: "var(--openui-dashboard-space-sm)",
3117
3258
  width: "100%"
3118
3259
  }
@@ -3223,6 +3364,7 @@ const CohortsImpl = defineComponent({
3223
3364
  const nums = grid.cells.flat().filter((v) => typeof v === "number");
3224
3365
  const min = nums.length ? Math.min(0, ...nums) : 0;
3225
3366
  const max = nums.length ? Math.max(...nums) : 100;
3367
+ const isZh = typeof document !== "undefined" && /^zh\b/i.test(document.documentElement.lang || "");
3226
3368
  return h("div", {
3227
3369
  ...p.bindSource?.() ?? {},
3228
3370
  class: "openui-dashboard-cohorts",
@@ -3251,12 +3393,13 @@ const CohortsImpl = defineComponent({
3251
3393
  style: {
3252
3394
  padding: "2px 8px",
3253
3395
  borderRadius: "999px",
3254
- border: "1px solid var(--openui-dashboard-border-strong)",
3255
- background: show.value === mode ? "var(--openui-dashboard-accent)" : "var(--openui-dashboard-surface)",
3256
- color: show.value === mode ? "var(--openui-dashboard-accent-ink)" : "var(--openui-dashboard-ink-secondary)",
3396
+ border: show.value === mode ? "1px solid color-mix(in srgb, var(--openui-dashboard-series-1) 36%, transparent)" : "1px solid var(--openui-dashboard-border-strong)",
3397
+ background: show.value === mode ? "color-mix(in srgb, var(--openui-dashboard-series-1) 14%, var(--openui-dashboard-surface))" : "var(--openui-dashboard-surface)",
3398
+ color: show.value === mode ? "var(--openui-dashboard-series-1)" : "var(--openui-dashboard-ink-secondary)",
3399
+ fontWeight: show.value === mode ? 600 : 500,
3257
3400
  cursor: "pointer"
3258
3401
  }
3259
- }, mode === "none" ? "Hide" : mode === "percent" ? "Percent" : "Count"))]), h("table", { style: {
3402
+ }, mode === "none" ? isZh ? "隐藏数值" : "Hide" : mode === "percent" ? isZh ? "百分比" : "Percent" : isZh ? "人数" : "Count"))]), h("table", { style: {
3260
3403
  width: "100%",
3261
3404
  borderCollapse: "separate",
3262
3405
  borderSpacing: "3px",
@@ -3266,12 +3409,12 @@ const CohortsImpl = defineComponent({
3266
3409
  textAlign: "left",
3267
3410
  color: "var(--openui-dashboard-ink-muted)",
3268
3411
  fontWeight: 500
3269
- } }, "Cohort"),
3412
+ } }, isZh ? "同期群" : "Cohort"),
3270
3413
  sizeByCohort.size ? h("th", { style: {
3271
3414
  textAlign: "right",
3272
3415
  color: "var(--openui-dashboard-ink-muted)",
3273
3416
  fontWeight: 500
3274
- } }, "Size") : null,
3417
+ } }, isZh ? "规模" : "Size") : null,
3275
3418
  ...grid.columns.map((col) => h("th", {
3276
3419
  key: col,
3277
3420
  style: {
@@ -3751,62 +3894,74 @@ const TableImpl = defineComponent({
3751
3894
  color: "var(--openui-dashboard-ink)"
3752
3895
  }
3753
3896
  }, [renderCell(col, cIdx, col.values?.[rIdx])]))))),
3754
- p.props.totals ? h("tfoot", null, h("tr", { style: {
3755
- borderTop: "1px solid var(--openui-dashboard-border-strong)",
3756
- fontWeight: 600
3757
- } }, cols.map((col, cIdx) => {
3758
- if (cIdx === 0 && !col.total) return h("td", {
3759
- key: cIdx,
3760
- style: { padding: "8px 10px" }
3761
- }, "Total");
3762
- if (!col.total) return h("td", { key: cIdx });
3763
- const nums = indices.map((i) => col.values?.[i]).filter((v) => typeof v === "number" && Number.isFinite(v));
3764
- const val = nums.length === 0 ? null : col.total === "average" ? nums.reduce((a, b) => a + b, 0) / nums.length : nums.reduce((a, b) => a + b, 0);
3765
- return h("td", {
3766
- key: cIdx,
3767
- style: {
3768
- padding: "8px 10px",
3769
- textAlign: "right",
3770
- fontVariantNumeric: "tabular-nums"
3771
- }
3772
- }, formatValue(val, col.format));
3773
- }))) : null
3774
- ]), totalPages > 1 ? h("div", { style: {
3775
- display: "flex",
3776
- justifyContent: "space-between",
3777
- alignItems: "center",
3778
- fontSize: "12px",
3779
- color: "var(--openui-dashboard-ink-muted)"
3780
- } }, [h("span", null, `Page ${safePage + 1} of ${totalPages} (${indices.length} rows)`), h("div", { style: {
3781
- display: "flex",
3782
- gap: "6px"
3783
- } }, [h("button", {
3784
- type: "button",
3785
- disabled: safePage <= 0,
3786
- onClick: () => {
3787
- page.value = Math.max(0, safePage - 1);
3788
- },
3789
- style: {
3790
- padding: "4px 8px",
3791
- borderRadius: "6px",
3792
- border: "1px solid var(--openui-dashboard-border-strong)",
3793
- background: "var(--openui-dashboard-surface)",
3794
- cursor: "pointer"
3795
- }
3796
- }, "Prev"), h("button", {
3797
- type: "button",
3798
- disabled: safePage >= totalPages - 1,
3799
- onClick: () => {
3800
- page.value = Math.min(totalPages - 1, safePage + 1);
3801
- },
3802
- style: {
3803
- padding: "4px 8px",
3804
- borderRadius: "6px",
3805
- border: "1px solid var(--openui-dashboard-border-strong)",
3806
- background: "var(--openui-dashboard-surface)",
3807
- cursor: "pointer"
3808
- }
3809
- }, "Next")])]) : null]);
3897
+ p.props.totals ? (() => {
3898
+ const isZh = typeof document !== "undefined" && /^zh\b/i.test(document.documentElement.lang || "");
3899
+ return h("tfoot", null, h("tr", { style: {
3900
+ borderTop: "1px solid var(--openui-dashboard-border-strong)",
3901
+ background: "var(--openui-dashboard-surface-subtle)",
3902
+ fontWeight: 600,
3903
+ color: "var(--openui-dashboard-ink)"
3904
+ } }, cols.map((col, cIdx) => {
3905
+ if (cIdx === 0 && !col.total) return h("td", {
3906
+ key: cIdx,
3907
+ style: { padding: "8px 10px" }
3908
+ }, isZh ? "合计" : "Total");
3909
+ if (!col.total) return h("td", { key: cIdx });
3910
+ const nums = indices.map((i) => col.values?.[i]).filter((v) => typeof v === "number" && Number.isFinite(v));
3911
+ const val = nums.length === 0 ? null : col.total === "average" ? nums.reduce((a, b) => a + b, 0) / nums.length : nums.reduce((a, b) => a + b, 0);
3912
+ return h("td", {
3913
+ key: cIdx,
3914
+ style: {
3915
+ padding: "8px 10px",
3916
+ textAlign: "right",
3917
+ fontVariantNumeric: "tabular-nums"
3918
+ }
3919
+ }, formatValue(val, col.format));
3920
+ })));
3921
+ })() : null
3922
+ ]), totalPages > 1 ? (() => {
3923
+ const isZh = typeof document !== "undefined" && /^zh\b/i.test(document.documentElement.lang || "");
3924
+ return h("div", { style: {
3925
+ display: "flex",
3926
+ justifyContent: "space-between",
3927
+ alignItems: "center",
3928
+ fontSize: "12px",
3929
+ color: "var(--openui-dashboard-ink-muted)"
3930
+ } }, [h("span", null, isZh ? `第 ${safePage + 1} / ${totalPages} 页(共 ${indices.length} 条)` : `Page ${safePage + 1} of ${totalPages} (${indices.length} rows)`), h("div", { style: {
3931
+ display: "flex",
3932
+ gap: "6px"
3933
+ } }, [h("button", {
3934
+ type: "button",
3935
+ disabled: safePage <= 0,
3936
+ onClick: () => {
3937
+ page.value = Math.max(0, safePage - 1);
3938
+ },
3939
+ style: {
3940
+ padding: "4px 8px",
3941
+ borderRadius: "6px",
3942
+ border: "1px solid var(--openui-dashboard-border-strong)",
3943
+ background: "var(--openui-dashboard-surface)",
3944
+ color: "var(--openui-dashboard-ink)",
3945
+ opacity: safePage <= 0 ? .45 : 1,
3946
+ cursor: safePage <= 0 ? "not-allowed" : "pointer"
3947
+ }
3948
+ }, isZh ? "上一页" : "Prev"), h("button", {
3949
+ type: "button",
3950
+ disabled: safePage >= totalPages - 1,
3951
+ onClick: () => {
3952
+ page.value = Math.min(totalPages - 1, safePage + 1);
3953
+ },
3954
+ style: {
3955
+ padding: "4px 8px",
3956
+ borderRadius: "6px",
3957
+ border: "1px solid var(--openui-dashboard-border-strong)",
3958
+ background: "var(--openui-dashboard-surface)",
3959
+ color: "var(--openui-dashboard-ink)",
3960
+ opacity: safePage >= totalPages - 1 ? .45 : 1,
3961
+ cursor: safePage >= totalPages - 1 ? "not-allowed" : "pointer"
3962
+ }
3963
+ }, isZh ? "下一页" : "Next")])]);
3964
+ })() : null]);
3810
3965
  };
3811
3966
  }
3812
3967
  });
@@ -3970,8 +4125,12 @@ const statusTimelinePropsSchema = z.object({
3970
4125
  // src/lib/trends/StatusTimeline/index.ts
3971
4126
  const STATE_COLOR = {
3972
4127
  good: "var(--openui-dashboard-good-mark)",
4128
+ ok: "var(--openui-dashboard-good-mark)",
4129
+ up: "var(--openui-dashboard-good-mark)",
3973
4130
  warning: "var(--openui-dashboard-warning-mark)",
3974
- bad: "var(--openui-dashboard-bad-mark)"
4131
+ degraded: "var(--openui-dashboard-warning-mark)",
4132
+ bad: "var(--openui-dashboard-bad-mark)",
4133
+ down: "var(--openui-dashboard-bad-mark)"
3975
4134
  };
3976
4135
  const StatusTimelineComponent = defineComponent$1({
3977
4136
  name: "StatusTimeline",
@@ -3979,6 +4138,7 @@ const StatusTimelineComponent = defineComponent$1({
3979
4138
  description: "Uptime per service over time: one strip per service, one cell per period. labels, periods and states have one entry per cell: its service, its period and its state, as query rows give them: StatusTimeline(s.rows.service, s.rows.day, s.rows.state). A state is \"good\" (up), \"warning\" (degraded) or \"bad\" (down), or null for no data; the legend names them Up, Degraded and Down.",
3980
4139
  component: ({ props, bindSource }) => {
3981
4140
  const grid = toGrid(props.labels, props.periods, props.states);
4141
+ const isZh = typeof document !== "undefined" && /^zh\b/i.test(document.documentElement.lang || "");
3982
4142
  return h("div", {
3983
4143
  ...bindSource?.() ?? {},
3984
4144
  class: "openui-dashboard-status-timeline",
@@ -4007,7 +4167,7 @@ const StatusTimelineComponent = defineComponent$1({
4007
4167
  const state = grid.cells[rIdx]?.[cIdx] ?? null;
4008
4168
  return h("div", {
4009
4169
  key: period,
4010
- title: `${service} · ${period}: ${state ?? "No data"}`,
4170
+ title: `${service} · ${period}: ${state ?? (isZh ? "无数据" : "No data")}`,
4011
4171
  style: {
4012
4172
  height: "18px",
4013
4173
  borderRadius: "3px",
@@ -4020,9 +4180,9 @@ const StatusTimelineComponent = defineComponent$1({
4020
4180
  fontSize: "11px",
4021
4181
  color: "var(--openui-dashboard-ink-muted)"
4022
4182
  } }, [
4023
- ["Up", STATE_COLOR.good],
4024
- ["Degraded", STATE_COLOR.warning],
4025
- ["Down", STATE_COLOR.bad]
4183
+ [isZh ? "正常" : "Up", STATE_COLOR.good],
4184
+ [isZh ? "降级" : "Degraded", STATE_COLOR.warning],
4185
+ [isZh ? "故障" : "Down", STATE_COLOR.bad]
4026
4186
  ].map(([label, color]) => h("span", {
4027
4187
  key: label,
4028
4188
  style: {
@@ -4103,7 +4263,11 @@ const TimeSeriesImpl = defineComponent({
4103
4263
  }
4104
4264
  return row;
4105
4265
  });
4106
- const palette = seriesList.map((_, i) => seriesColor(i));
4266
+ const palette = [];
4267
+ seriesList.forEach((s, i) => {
4268
+ palette.push(seriesColor(i));
4269
+ if (compare.enabled.value && s.previous?.length) palette.push(MUTED_COLOR);
4270
+ });
4107
4271
  const stacked = p.props.stacked === true || p.props.stacked === "percent";
4108
4272
  const chartType = p.props.type ?? "line";
4109
4273
  const chartVNode = chartType === "bar" ? h(BarChart, {
@@ -4435,8 +4599,9 @@ const SectionComponent = defineComponent$1({
4435
4599
  gap: "2px"
4436
4600
  } }, [props.title ? h("h2", { style: {
4437
4601
  margin: 0,
4438
- fontSize: "17px",
4602
+ fontSize: "19px",
4439
4603
  fontWeight: 650,
4604
+ letterSpacing: "-0.02em",
4440
4605
  color: "var(--openui-dashboard-ink)"
4441
4606
  } }, props.title) : null, props.description ? h("p", { style: {
4442
4607
  margin: 0,