@h-ai/ui 1.0.0-beta.1 → 1.0.0-beta.11

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 (48) hide show
  1. package/README.en.md +30 -4
  2. package/README.ja.md +30 -4
  3. package/README.md +30 -4
  4. package/auto-import.d.ts +4 -0
  5. package/auto-import.js +5 -0
  6. package/dist/components/compounds/ToastContainer.svelte +14 -3
  7. package/dist/components/scenes/ai/document-download.js +4 -2
  8. package/dist/components/scenes/ai/editor-markdown-extensions.js +3 -2
  9. package/dist/components/scenes/ai/highlight.js +15 -0
  10. package/dist/components/scenes/ai/markdown-parse.js +50 -23
  11. package/dist/components/scenes/app/ThemeSelector.svelte +1 -1
  12. package/dist/components/scenes/charts/Chart.svelte +43 -20
  13. package/dist/components/scenes/charts/Chart.svelte.d.ts +0 -1
  14. package/dist/components/scenes/charts/ChartLoadError.svelte +13 -0
  15. package/dist/components/scenes/charts/ChartLoadError.svelte.d.ts +6 -0
  16. package/dist/components/scenes/charts/DashboardGrid.svelte +34 -0
  17. package/dist/components/scenes/charts/DashboardGrid.svelte.d.ts +15 -0
  18. package/dist/components/scenes/charts/MetricCard.svelte +52 -0
  19. package/dist/components/scenes/charts/MetricCard.svelte.d.ts +15 -0
  20. package/dist/components/scenes/charts/ReportCard.svelte +48 -0
  21. package/dist/components/scenes/charts/ReportCard.svelte.d.ts +15 -0
  22. package/dist/components/scenes/charts/chart-presets.d.ts +15 -0
  23. package/dist/components/scenes/charts/chart-presets.js +19 -0
  24. package/dist/components/scenes/charts/chart-types.d.ts +13 -2
  25. package/dist/components/scenes/charts/dashboard-types.d.ts +79 -0
  26. package/dist/components/scenes/charts/dashboard-types.js +1 -0
  27. package/dist/components/scenes/charts/index.d.ts +6 -2
  28. package/dist/components/scenes/charts/index.js +4 -1
  29. package/dist/components/scenes/charts/renderers/AreaChart.svelte +1 -0
  30. package/dist/components/scenes/charts/renderers/AreaChart.svelte.d.ts +1 -0
  31. package/dist/components/scenes/charts/renderers/BarChart.svelte +1 -0
  32. package/dist/components/scenes/charts/renderers/BarChart.svelte.d.ts +1 -0
  33. package/dist/components/scenes/charts/renderers/LineChart.svelte +1 -0
  34. package/dist/components/scenes/charts/renderers/LineChart.svelte.d.ts +1 -0
  35. package/dist/components/scenes/charts/renderers/PieChart.svelte +1 -0
  36. package/dist/components/scenes/charts/renderers/PieChart.svelte.d.ts +1 -0
  37. package/dist/components/scenes/charts/renderers/ScatterChart.svelte +1 -0
  38. package/dist/components/scenes/charts/renderers/ScatterChart.svelte.d.ts +1 -0
  39. package/dist/messages/en-US.json +7 -1
  40. package/dist/messages/ja-JP.json +7 -1
  41. package/dist/messages/zh-CN.json +7 -1
  42. package/dist/styles/eye-care.css +55 -0
  43. package/dist/styles/theme.css +1 -0
  44. package/dist/theme-config.d.ts +1 -1
  45. package/dist/theme-config.js +2 -1
  46. package/dist/toast.svelte.js +13 -4
  47. package/dist/types.d.ts +1 -1
  48. package/package.json +2 -2
@@ -0,0 +1,6 @@
1
+ type $$ComponentProps = {
2
+ onretry: () => void;
3
+ };
4
+ declare const ChartLoadError: import("svelte").Component<$$ComponentProps, {}, "">;
5
+ type ChartLoadError = ReturnType<typeof ChartLoadError>;
6
+ export default ChartLoadError;
@@ -0,0 +1,34 @@
1
+ <!--
2
+ @component DashboardGrid
3
+ 使用容器查询适配看板,不依赖视口宽度或图形引擎。
4
+ @example
5
+ ```ts
6
+ import { mount, unmount } from 'svelte'
7
+ import { DashboardGrid } from '@h-ai/ui'
8
+ const component = mount(DashboardGrid, { target: document.body, props: { label: 'Reports', columns: 2 } })
9
+ await unmount(component)
10
+ ```
11
+ -->
12
+ <script lang='ts'>
13
+ import type { DashboardGridProps } from './dashboard-types.js'
14
+ import { cn, getDataAttributes } from '../../../utils.js'
15
+
16
+ const { label, columns = 2, children, class: className = '', ...restProps }: DashboardGridProps = $props()
17
+ </script>
18
+
19
+ <div {...getDataAttributes(restProps)} role='group' aria-label={label} class={cn('hai-dashboard-grid min-w-0', className)} style={`--hai-dashboard-columns: ${columns}; --hai-dashboard-medium-columns: ${Math.min(columns, 2)};`}>
20
+ <div class='hai-dashboard-grid__items'>
21
+ {#if children}{@render children()}{/if}
22
+ </div>
23
+ </div>
24
+
25
+ <style>
26
+ .hai-dashboard-grid { container: hai-dashboard / inline-size; }
27
+ .hai-dashboard-grid__items { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
28
+ @container hai-dashboard (min-width: 40rem) {
29
+ .hai-dashboard-grid__items { grid-template-columns: repeat(var(--hai-dashboard-medium-columns), minmax(0, 1fr)); }
30
+ }
31
+ @container hai-dashboard (min-width: 64rem) {
32
+ .hai-dashboard-grid__items { grid-template-columns: repeat(var(--hai-dashboard-columns), minmax(0, 1fr)); }
33
+ }
34
+ </style>
@@ -0,0 +1,15 @@
1
+ import type { DashboardGridProps } from './dashboard-types.js';
2
+ /**
3
+ * DashboardGrid
4
+ * 使用容器查询适配看板,不依赖视口宽度或图形引擎。
5
+ * @example
6
+ * ```ts
7
+ * import { mount, unmount } from 'svelte'
8
+ * import { DashboardGrid } from '@h-ai/ui'
9
+ * const component = mount(DashboardGrid, { target: document.body, props: { label: 'Reports', columns: 2 } })
10
+ * await unmount(component)
11
+ * ```
12
+ */
13
+ declare const DashboardGrid: import("svelte").Component<DashboardGridProps, {}, "">;
14
+ type DashboardGrid = ReturnType<typeof DashboardGrid>;
15
+ export default DashboardGrid;
@@ -0,0 +1,52 @@
1
+ <!--
2
+ @component MetricCard
3
+ 指标卡不依赖图形引擎;可通过 children 按需补充迷你趋势图。
4
+ @example
5
+ ```ts
6
+ import { mount, unmount } from 'svelte'
7
+ import { MetricCard } from '@h-ai/ui'
8
+ const component = mount(MetricCard, { target: document.body, props: { title: 'Revenue', value: '128,430', trend: 12.8, trendLabel: 'vs previous month', trendTone: 'success' } })
9
+ await unmount(component)
10
+ ```
11
+ -->
12
+ <script lang='ts'>
13
+ import type { MetricCardProps } from './dashboard-types.js'
14
+ import { getUILocale, uiM } from '../../../messages.js'
15
+ import { cn, getDataAttributes } from '../../../utils.js'
16
+ import Card from '../../compounds/Card.svelte'
17
+
18
+ const { title, value, unit = '', trend, trendLabel = '', trendTone = 'neutral', description = '', loading = false, children, class: className = '', ...restProps }: MetricCardProps = $props()
19
+ const hasValue = $derived(value != null && (typeof value !== 'number' || Number.isFinite(value)))
20
+ const hasTrend = $derived(typeof trend === 'number' && Number.isFinite(trend))
21
+ const direction = $derived((trend ?? 0) > 0 ? 'up' : (trend ?? 0) < 0 ? 'down' : 'flat')
22
+ const trendText = $derived(new Intl.NumberFormat(getUILocale(), { style: 'percent', maximumFractionDigits: 1, signDisplay: 'exceptZero' }).format((trend ?? 0) / 100))
23
+ const toneClass = { success: 'text-success', warning: 'text-warning', error: 'text-error', neutral: 'text-base-content' }
24
+ </script>
25
+
26
+ <Card {...getDataAttributes(restProps)} class={cn('hai-metric-card min-w-0', className)} shadow={false}>
27
+ <div aria-busy={loading} class='flex min-w-0 flex-col gap-2'>
28
+ <h2 class='text-sm font-medium text-base-content/80'>{title}</h2>
29
+ {#if loading}
30
+ <div role='status' aria-label={uiM('chart_loading')} class='skeleton h-9 w-32'></div>
31
+ {:else}
32
+ <div class='flex min-w-0 flex-wrap items-baseline gap-x-2'>
33
+ <span class='break-words text-3xl font-semibold tracking-tight tabular-nums'>{hasValue ? value : '—'}</span>
34
+ {#if unit && hasValue}<span class='text-sm text-base-content/80'>{unit}</span>{/if}
35
+ </div>
36
+ {#if hasTrend}
37
+ <div class='flex flex-wrap items-center gap-x-2 gap-y-1 text-sm'>
38
+ <span data-trend-direction={direction} class={cn('inline-flex items-center gap-1 font-medium tabular-nums', toneClass[trendTone])}>
39
+ <svg aria-hidden='true' viewBox='0 0 20 20' class='size-4 shrink-0' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'>
40
+ <path d={direction === 'up' ? 'M3 14 8 9 12 12 17 5 M12 5h5v5' : direction === 'down' ? 'M3 6 8 11 12 8 17 15 M12 15h5v-5' : 'M3 10h14 m-4 -4 4 4 -4 4'}></path>
41
+ </svg>
42
+ <span class='sr-only'>{uiM(direction === 'up' ? 'metric_increase' : direction === 'down' ? 'metric_decrease' : 'metric_unchanged')}</span>
43
+ {trendText}
44
+ </span>
45
+ {#if trendLabel}<span class='text-base-content/80'>{trendLabel}</span>{/if}
46
+ </div>
47
+ {/if}
48
+ {#if children}{@render children()}{/if}
49
+ {/if}
50
+ {#if description}<p class='break-words text-xs text-base-content/80'>{description}</p>{/if}
51
+ </div>
52
+ </Card>
@@ -0,0 +1,15 @@
1
+ import type { MetricCardProps } from './dashboard-types.js';
2
+ /**
3
+ * MetricCard
4
+ * 指标卡不依赖图形引擎;可通过 children 按需补充迷你趋势图。
5
+ * @example
6
+ * ```ts
7
+ * import { mount, unmount } from 'svelte'
8
+ * import { MetricCard } from '@h-ai/ui'
9
+ * const component = mount(MetricCard, { target: document.body, props: { title: 'Revenue', value: '128,430', trend: 12.8, trendLabel: 'vs previous month', trendTone: 'success' } })
10
+ * await unmount(component)
11
+ * ```
12
+ */
13
+ declare const MetricCard: import("svelte").Component<MetricCardProps, {}, "">;
14
+ type MetricCard = ReturnType<typeof MetricCard>;
15
+ export default MetricCard;
@@ -0,0 +1,48 @@
1
+ <!--
2
+ @component ReportCard
3
+ 复用 Card 的报表容器,内容插槽不限制 LayerChart 图形能力。
4
+ @example
5
+ ```ts
6
+ import { mount, unmount } from 'svelte'
7
+ import { ReportCard } from '@h-ai/ui'
8
+ const component = mount(ReportCard, { target: document.body, props: { title: 'Revenue', empty: true } })
9
+ await unmount(component)
10
+ ```
11
+ -->
12
+ <script lang='ts'>
13
+ import type { ReportCardProps } from './dashboard-types.js'
14
+ import { uiM } from '../../../messages.js'
15
+ import { cn, getDataAttributes } from '../../../utils.js'
16
+ import Card from '../../compounds/Card.svelte'
17
+
18
+ const { title, description = '', actions, children, footer, loading = false, empty = false, minHeight = 240, class: className = '', ...restProps }: ReportCardProps = $props()
19
+ const titleId = $props.id()
20
+ </script>
21
+
22
+ <Card {...getDataAttributes(restProps)} class={cn('hai-report-card min-w-0', className)} shadow={false}>
23
+ {#snippet header()}
24
+ <div class='flex w-full min-w-0 flex-wrap items-start justify-between gap-3'>
25
+ <div class='min-w-0'>
26
+ <h2 id={titleId} class='break-words text-sm font-semibold'>{title}</h2>
27
+ {#if description}<p class='mt-1 break-words text-xs font-normal text-base-content/80'>{description}</p>{/if}
28
+ </div>
29
+ {#if actions}<div class='flex shrink-0 flex-wrap gap-2 font-normal'>{@render actions()}</div>{/if}
30
+ </div>
31
+ {/snippet}
32
+ <section aria-labelledby={titleId} aria-busy={loading} class='min-w-0' style={`min-height: ${Math.max(0, minHeight)}px;`}>
33
+ {#if loading || empty}
34
+ <div class='flex items-center justify-center' style={`min-height: ${Math.max(0, minHeight)}px;`}>
35
+ {#if loading}
36
+ <span role='status' class='loading loading-spinner loading-md text-primary' aria-label={uiM('chart_loading')}></span>
37
+ {:else}
38
+ <p class='text-sm text-base-content/80'>{uiM('chart_empty')}</p>
39
+ {/if}
40
+ </div>
41
+ {:else if children}
42
+ {@render children()}
43
+ {/if}
44
+ </section>
45
+ {#if footer}
46
+ <div class='min-w-0 border-t border-base-300 pt-3 text-xs text-base-content/80'>{@render footer()}</div>
47
+ {/if}
48
+ </Card>
@@ -0,0 +1,15 @@
1
+ import type { ReportCardProps } from './dashboard-types.js';
2
+ /**
3
+ * ReportCard
4
+ * 复用 Card 的报表容器,内容插槽不限制 LayerChart 图形能力。
5
+ * @example
6
+ * ```ts
7
+ * import { mount, unmount } from 'svelte'
8
+ * import { ReportCard } from '@h-ai/ui'
9
+ * const component = mount(ReportCard, { target: document.body, props: { title: 'Revenue', empty: true } })
10
+ * await unmount(component)
11
+ * ```
12
+ */
13
+ declare const ReportCard: import("svelte").Component<ReportCardProps, {}, "">;
14
+ type ReportCard = ReturnType<typeof ReportCard>;
15
+ export default ReportCard;
@@ -0,0 +1,15 @@
1
+ /** @h-ai/ui — 常用图表预设,仅定义默认值,调用方原生配置优先。 @module chart-presets */
2
+ import type { ChartPreset, ChartType } from './chart-types.js';
3
+ /**
4
+ * 解析预设,不读取或转换业务数据。
5
+ * @param preset - 可选预设名称。
6
+ * @returns 图形类型及可被调用方覆盖的默认属性。
7
+ * @example 模块内部上下文
8
+ * ```ts
9
+ * const preset = resolveChartPreset('donut')
10
+ * ```
11
+ */
12
+ export declare function resolveChartPreset(preset?: ChartPreset): {
13
+ type?: ChartType;
14
+ props: Record<string, unknown>;
15
+ };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * 解析预设,不读取或转换业务数据。
3
+ * @param preset - 可选预设名称。
4
+ * @returns 图形类型及可被调用方覆盖的默认属性。
5
+ * @example 模块内部上下文
6
+ * ```ts
7
+ * const preset = resolveChartPreset('donut')
8
+ * ```
9
+ */
10
+ export function resolveChartPreset(preset) {
11
+ switch (preset) {
12
+ case 'grouped-bar': return { type: 'bar', props: { seriesLayout: 'group', axis: true, grid: true, legend: true } };
13
+ case 'stacked-bar': return { type: 'bar', props: { seriesLayout: 'stack', axis: true, grid: true, legend: true } };
14
+ case 'stacked-area': return { type: 'area', props: { seriesLayout: 'stack', axis: true, grid: true, legend: true } };
15
+ case 'donut': return { type: 'pie', props: { innerRadius: 0.65, legend: true } };
16
+ case 'sparkline': return { type: 'line', props: { axis: false, grid: false, legend: false, points: false, padding: { top: 4, right: 0, bottom: 4, left: 0 }, height: 64 } };
17
+ default: return { props: {} };
18
+ }
19
+ }
@@ -43,6 +43,15 @@ export type ChartAccessor = string | number | ((item: ChartDataItem) => unknown)
43
43
  * ```
44
44
  */
45
45
  export type ChartType = 'bar' | 'line' | 'area' | 'pie' | 'scatter';
46
+ /**
47
+ * 常用图形的可覆盖默认配置;无需同时传 type。
48
+ * @example
49
+ * ```ts
50
+ * import type { ChartPreset } from '@h-ai/ui'
51
+ * const preset: ChartPreset = 'donut'
52
+ * ```
53
+ */
54
+ export type ChartPreset = 'grouped-bar' | 'stacked-bar' | 'stacked-area' | 'donut' | 'sparkline';
46
55
  /**
47
56
  * Chart 预设高度档位;具体像素值在 Chart.svelte 中固定映射。
48
57
  *
@@ -116,8 +125,10 @@ export interface ChartSeries {
116
125
  * ```
117
126
  */
118
127
  export interface ChartProps extends DataAttributes {
119
- /** 选择内部 LayerChart 高阶组件;必填。 */
120
- type: ChartType;
128
+ /** 选择内部 LayerChart 高阶组件;优先于 preset 的图形类型,未指定时默认 line。 */
129
+ type?: ChartType;
130
+ /** 常用图表预设;原生属性覆盖预设默认值。 */
131
+ preset?: ChartPreset;
121
132
  /** 图表数据源;空数组会触发内置空态。 */
122
133
  data: ChartDataItem[];
123
134
  /** x 轴字段名;饼图中默认映射为 key 和 label。 */
@@ -0,0 +1,79 @@
1
+ /** @h-ai/ui — 轻量看板组件契约。 @module dashboard-types */
2
+ import type { Snippet } from 'svelte';
3
+ import type { DataAttributes } from '../../../types.js';
4
+ /**
5
+ * 指标卡展示数据;百分比变化由业务计算,正负方向与业务好坏分别表达。
6
+ * @example
7
+ * ```ts
8
+ * import type { MetricCardProps } from '@h-ai/ui'
9
+ * const metric: MetricCardProps = { title: 'Revenue', value: '128,430', unit: 'CNY', trend: 12.8, trendLabel: 'vs previous month', trendTone: 'success' }
10
+ * ```
11
+ */
12
+ export interface MetricCardProps extends DataAttributes {
13
+ /** 指标名称,由应用提供翻译。 */
14
+ title: string;
15
+ /** 已格式化文本或数值;缺失和非有限数显示占位符,零值正常显示。 */
16
+ value?: string | number | null;
17
+ /** 单位文本。 */
18
+ unit?: string;
19
+ /** 变化百分数,例如 12.8 表示 +12.8%,不是 0.128。 */
20
+ trend?: number;
21
+ /** 比较基准,例如“较上月”。 */
22
+ trendLabel?: string;
23
+ /** 业务语义色;默认 neutral,下降也可以是 success。 */
24
+ trendTone?: 'success' | 'warning' | 'error' | 'neutral';
25
+ /** 辅助说明。 */
26
+ description?: string;
27
+ /** 加载时隐藏旧数值及趋势内容。 */
28
+ loading?: boolean;
29
+ /** 可选趋势图或其他补充内容;未提供时不加载图形引擎。 */
30
+ children?: Snippet;
31
+ /** 外层样式。 */
32
+ class?: string;
33
+ }
34
+ /**
35
+ * 报表卡片负责布局和状态,children 可放统一 Chart 或任意 LayerChart 原生组件。
36
+ * @example
37
+ * ```ts
38
+ * import type { ReportCardProps } from '@h-ai/ui'
39
+ * const report: ReportCardProps = { title: 'Revenue trend', description: 'Monthly totals', loading: false }
40
+ * ```
41
+ */
42
+ export interface ReportCardProps extends DataAttributes {
43
+ /** 卡片标题。 */
44
+ title: string;
45
+ /** 标题下的说明。 */
46
+ description?: string;
47
+ /** 标题旁的操作区域。 */
48
+ actions?: Snippet;
49
+ /** 报表或原生图形内容。 */
50
+ children?: Snippet;
51
+ /** 可选页脚。 */
52
+ footer?: Snippet;
53
+ /** 加载状态;保留卡片高度,不挂载图形。 */
54
+ loading?: boolean;
55
+ /** 空态;不挂载图形。 */
56
+ empty?: boolean;
57
+ /** 状态区域的最小高度,默认 240 像素。 */
58
+ minHeight?: number;
59
+ /** 外层样式。 */
60
+ class?: string;
61
+ }
62
+ /**
63
+ * 看板的响应式网格,按容器宽度收拢,children 保持 DOM 阅读顺序。
64
+ * @example
65
+ * ```ts
66
+ * import type { DashboardGridProps } from '@h-ai/ui'
67
+ * const grid: DashboardGridProps = { label: 'Key metrics', columns: 4 }
68
+ * ```
69
+ */
70
+ export interface DashboardGridProps extends DataAttributes {
71
+ /** 网格的无障碍名称。 */
72
+ label: string;
73
+ /** 宽容器列数;窄容器一列,中等容器最多两列。 */
74
+ columns?: 1 | 2 | 3 | 4;
75
+ /** 指标卡或报表卡。 */
76
+ children?: Snippet;
77
+ /** 外层样式。 */
78
+ class?: string;
79
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,8 +1,12 @@
1
1
  /**
2
2
  * @h-ai/ui — 图表场景组件
3
3
  *
4
- * 仅导出统一 Chart 入口和公共类型;内部 renderer 不对外暴露。
4
+ * 导出统一 Chart、轻量看板组件和公共类型;内部 renderer 不对外暴露。
5
5
  * @module index
6
6
  */
7
- export type { ChartDataItem, ChartLineVariant, ChartProps, ChartSeries, ChartSize, ChartTooltipMode, ChartType } from './chart-types.js';
7
+ export type { ChartDataItem, ChartLineVariant, ChartPreset, ChartProps, ChartSeries, ChartSize, ChartTooltipMode, ChartType } from './chart-types.js';
8
8
  export { default as Chart } from './Chart.svelte';
9
+ export type { DashboardGridProps, MetricCardProps, ReportCardProps } from './dashboard-types.js';
10
+ export { default as DashboardGrid } from './DashboardGrid.svelte';
11
+ export { default as MetricCard } from './MetricCard.svelte';
12
+ export { default as ReportCard } from './ReportCard.svelte';
@@ -1,7 +1,10 @@
1
1
  /**
2
2
  * @h-ai/ui — 图表场景组件
3
3
  *
4
- * 仅导出统一 Chart 入口和公共类型;内部 renderer 不对外暴露。
4
+ * 导出统一 Chart、轻量看板组件和公共类型;内部 renderer 不对外暴露。
5
5
  * @module index
6
6
  */
7
7
  export { default as Chart } from './Chart.svelte';
8
+ export { default as DashboardGrid } from './DashboardGrid.svelte';
9
+ export { default as MetricCard } from './MetricCard.svelte';
10
+ export { default as ReportCard } from './ReportCard.svelte';
@@ -10,6 +10,7 @@
10
10
  import type { AreaChartProps } from 'layerchart'
11
11
  import type { ChartDataItem } from '../chart-types.js'
12
12
  import { AreaChart as LayerAreaChart } from 'layerchart'
13
+ import 'layerchart/daisyui-5.css'
13
14
 
14
15
  /** 透传给 LayerChart AreaChart 的全部原生属性。 */
15
16
  const { ...props }: AreaChartProps<ChartDataItem> = $props()
@@ -1,5 +1,6 @@
1
1
  import type { AreaChartProps } from 'layerchart';
2
2
  import type { ChartDataItem } from '../chart-types.js';
3
+ import 'layerchart/daisyui-5.css';
3
4
  declare const AreaChart: import("svelte").Component<AreaChartProps<ChartDataItem>, {}, "">;
4
5
  type AreaChart = ReturnType<typeof AreaChart>;
5
6
  export default AreaChart;
@@ -10,6 +10,7 @@
10
10
  import type { BarChartProps } from 'layerchart'
11
11
  import type { ChartDataItem } from '../chart-types.js'
12
12
  import { BarChart as LayerBarChart } from 'layerchart'
13
+ import 'layerchart/daisyui-5.css'
13
14
 
14
15
  /** 透传给 LayerChart BarChart 的全部原生属性。 */
15
16
  const { ...props }: BarChartProps<ChartDataItem> = $props()
@@ -1,5 +1,6 @@
1
1
  import type { BarChartProps } from 'layerchart';
2
2
  import type { ChartDataItem } from '../chart-types.js';
3
+ import 'layerchart/daisyui-5.css';
3
4
  declare const BarChart: import("svelte").Component<BarChartProps<ChartDataItem>, {}, "">;
4
5
  type BarChart = ReturnType<typeof BarChart>;
5
6
  export default BarChart;
@@ -16,6 +16,7 @@
16
16
  ChartTooltipMode,
17
17
  } from '../chart-types.js'
18
18
  import { LineChart as LayerLineChart } from 'layerchart'
19
+ import 'layerchart/daisyui-5.css'
19
20
 
20
21
  /**
21
22
  * 分段折线图单个数据点,保留展示标签与数值。
@@ -1,5 +1,6 @@
1
1
  import type { LineChartProps } from 'layerchart';
2
2
  import type { ChartDataItem, ChartLineVariant, ChartTooltipMode } from '../chart-types.js';
3
+ import 'layerchart/daisyui-5.css';
3
4
  /**
4
5
  * LineChart 组件的属性契约;通过公开组件配置使用。
5
6
  *
@@ -10,6 +10,7 @@
10
10
  import type { PieChartProps } from 'layerchart'
11
11
  import type { ChartDataItem } from '../chart-types.js'
12
12
  import { PieChart as LayerPieChart } from 'layerchart'
13
+ import 'layerchart/daisyui-5.css'
13
14
 
14
15
  /** 透传给 LayerChart PieChart 的全部原生属性。 */
15
16
  const { ...props }: PieChartProps<ChartDataItem> = $props()
@@ -1,5 +1,6 @@
1
1
  import type { PieChartProps } from 'layerchart';
2
2
  import type { ChartDataItem } from '../chart-types.js';
3
+ import 'layerchart/daisyui-5.css';
3
4
  declare const PieChart: import("svelte").Component<PieChartProps<ChartDataItem>, {}, "">;
4
5
  type PieChart = ReturnType<typeof PieChart>;
5
6
  export default PieChart;
@@ -10,6 +10,7 @@
10
10
  import type { ScatterChartProps } from 'layerchart'
11
11
  import type { ChartDataItem } from '../chart-types.js'
12
12
  import { ScatterChart as LayerScatterChart } from 'layerchart'
13
+ import 'layerchart/daisyui-5.css'
13
14
 
14
15
  /** 透传给 LayerChart ScatterChart 的全部原生属性。 */
15
16
  const { ...props }: ScatterChartProps<ChartDataItem> = $props()
@@ -1,5 +1,6 @@
1
1
  import type { ScatterChartProps } from 'layerchart';
2
2
  import type { ChartDataItem } from '../chart-types.js';
3
+ import 'layerchart/daisyui-5.css';
3
4
  declare const ScatterChart: import("svelte").Component<ScatterChartProps<ChartDataItem>, {}, "">;
4
5
  type ScatterChart = ReturnType<typeof ScatterChart>;
5
6
  export default ScatterChart;
@@ -517,7 +517,13 @@
517
517
  "filter_bar_collapse": "Collapse filters",
518
518
  "filter_bar_active": "Active filters: {count}",
519
519
  "theme_formal": "Formal",
520
+ "theme_eye_care": "Eye care",
520
521
  "keyboard_submit_enter": "Press Enter in a single-line field to submit",
521
522
  "request_access_denied": "The access policy blocked this request. Check the address, network and permitted hours. Contact your administrator for help.",
522
- "auth_error_account_unavailable": "This account is unavailable. Contact your administrator to check its status and expiry."
523
+ "auth_error_account_unavailable": "This account is unavailable. Contact your administrator to check its status and expiry.",
524
+ "chart_load_failed": "Unable to load the chart. Please retry.",
525
+ "chart_retry": "Refresh page to retry",
526
+ "metric_increase": "Increase",
527
+ "metric_decrease": "Decrease",
528
+ "metric_unchanged": "Unchanged"
523
529
  }
@@ -517,7 +517,13 @@
517
517
  "filter_bar_collapse": "絞り込みを折りたたむ",
518
518
  "filter_bar_active": "適用中の条件:{count}件",
519
519
  "theme_formal": "ビジネス(角丸なし)",
520
+ "theme_eye_care": "目にやさしい",
520
521
  "keyboard_submit_enter": "1行の入力欄で Enter を押して送信",
521
522
  "request_access_denied": "アクセス制限により、このリクエストは許可されませんでした。アクセス先、ネットワーク、許可時間帯を確認してください。必要な場合は管理者にお問い合わせください。",
522
- "auth_error_account_unavailable": "現在このアカウントは利用できません。状態と有効期限を管理者に確認してください。"
523
+ "auth_error_account_unavailable": "現在このアカウントは利用できません。状態と有効期限を管理者に確認してください。",
524
+ "chart_load_failed": "グラフを読み込めませんでした。再試行してください。",
525
+ "chart_retry": "ページを更新して再試行",
526
+ "metric_increase": "増加",
527
+ "metric_decrease": "減少",
528
+ "metric_unchanged": "変化なし"
523
529
  }
@@ -517,7 +517,13 @@
517
517
  "filter_bar_collapse": "收起筛选",
518
518
  "filter_bar_active": "已启用 {count} 项筛选",
519
519
  "theme_formal": "简洁商务",
520
+ "theme_eye_care": "护眼",
520
521
  "keyboard_submit_enter": "在单行输入框中按 Enter 提交",
521
522
  "request_access_denied": "当前请求未通过访问策略检查。请确认访问地址、网络或允许的时段;如需帮助,请联系管理员。",
522
- "auth_error_account_unavailable": "账号当前无法使用,请联系管理员确认账号状态及有效期。"
523
+ "auth_error_account_unavailable": "账号当前无法使用,请联系管理员确认账号状态及有效期。",
524
+ "chart_load_failed": "图表加载失败,请重试",
525
+ "chart_retry": "刷新页面重试",
526
+ "metric_increase": "上升",
527
+ "metric_decrease": "下降",
528
+ "metric_unchanged": "持平"
523
529
  }
@@ -0,0 +1,55 @@
1
+ /* 护眼主题:暖绿色背景搭配深色文字,减少大面积纯白并保留清晰对比。 */
2
+ [data-theme='eye-care'] {
3
+ color-scheme: light;
4
+ color: #25362a;
5
+ background-color: #e8f0df;
6
+ --color-base-100: #e8f0df;
7
+ --color-base-200: #dfe8d4;
8
+ --color-base-300: #c9d7bd;
9
+ --color-base-content: #25362a;
10
+ --color-primary: #365e3d;
11
+ --color-primary-content: #f6f5e9;
12
+ --color-secondary: #545b3e;
13
+ --color-secondary-content: #f6f5e9;
14
+ --color-accent: #3c625c;
15
+ --color-accent-content: #f6f5e9;
16
+ --color-neutral: #334139;
17
+ --color-neutral-content: #f6f5e9;
18
+ --color-info: #315d71;
19
+ --color-info-content: #f6f5e9;
20
+ --color-success: #356039;
21
+ --color-success-content: #f6f5e9;
22
+ --color-warning: #73551e;
23
+ --color-warning-content: #f6f5e9;
24
+ --color-error: #91423c;
25
+ --color-error-content: #f6f5e9;
26
+ --radius-selector: 0.375rem;
27
+ --radius-field: 0.5rem;
28
+ --radius-box: 0.75rem;
29
+ --size-selector: 0.25rem;
30
+ --size-field: 0.25rem;
31
+ --border: 1px;
32
+ --depth: 0;
33
+ --noise: 0;
34
+ --hai-focus-color: #365e3d;
35
+ }
36
+
37
+ /* 次要文字与占位符在各层浅色背景上保持可读。 */
38
+ [data-theme='eye-care'] :is([class^='text-base-content/'], [class*=' text-base-content/']),
39
+ [data-theme='eye-care'] .table th {
40
+ color: #4c5d47;
41
+ }
42
+
43
+ [data-theme='eye-care'] :is([class^='border-base-content/'], [class*=' border-base-content/']) {
44
+ border-color: #63785c;
45
+ }
46
+
47
+ [data-theme='eye-care'] :is(input, textarea)::placeholder {
48
+ color: #4c5d47;
49
+ opacity: 1;
50
+ }
51
+
52
+ [data-theme='eye-care'] :focus-visible {
53
+ outline: 2px solid var(--hai-focus-color);
54
+ outline-offset: 2px;
55
+ }
@@ -14,6 +14,7 @@
14
14
  @import './design-tokens.css';
15
15
  @import './high-contrast.css';
16
16
  @import './formal.css';
17
+ @import './eye-care.css';
17
18
 
18
19
  :root {
19
20
  --hai-theme-color-default: #5765f0;
@@ -59,7 +59,7 @@ export interface ThemeGroup {
59
59
  themes: ThemeInfo[];
60
60
  }
61
61
  /**
62
- * 精选 DaisyUI 主题及 UI 共享样式提供的高对比、直角商务主题。
62
+ * 精选 DaisyUI 主题及 UI 共享样式提供的高对比、直角商务与护眼主题。
63
63
  *
64
64
  * @example
65
65
  * ```ts
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { readStoredValue, writeStoredValue } from './internal/browser-safety.js';
8
8
  /**
9
- * 精选 DaisyUI 主题及 UI 共享样式提供的高对比、直角商务主题。
9
+ * 精选 DaisyUI 主题及 UI 共享样式提供的高对比、直角商务与护眼主题。
10
10
  *
11
11
  * @example
12
12
  * ```ts
@@ -24,6 +24,7 @@ export const THEMES = [
24
24
  { id: 'winter', name: 'Winter', dark: false, primaryColor: '#047aff', bgColor: '#ffffff' },
25
25
  { id: 'nord', name: 'Nord', dark: false, primaryColor: '#5e81ac', bgColor: '#eceff4' },
26
26
  { id: 'formal', name: 'Formal', dark: false, primaryColor: '#123d70', bgColor: '#ffffff' },
27
+ { id: 'eye-care', name: 'Eye care', dark: false, primaryColor: '#365e3d', bgColor: '#e8f0df' },
27
28
  // 暗色主题
28
29
  { id: 'dark', name: 'Dark', dark: true, primaryColor: '#661ae6', bgColor: '#1d232a' },
29
30
  { id: 'dracula', name: 'Dracula', dark: true, primaryColor: '#ff79c6', bgColor: '#282a36' },
@@ -9,10 +9,19 @@ import { untrack } from 'svelte';
9
9
  /** 兼容安全错误消息中的追踪编号,将排查信息从用户说明中分离。 */
10
10
  function normalizeMessage(message, explicitTraceId) {
11
11
  let traceId = explicitTraceId && /^[\w.:-]{1,128}$/.test(explicitTraceId) ? explicitTraceId : undefined;
12
- const readable = message.replace(/\s*\(traceId: ([\w.:-]{1,128})\)/g, (_, embedded) => {
13
- traceId ??= embedded;
14
- return '';
15
- }).trim();
12
+ const parts = [];
13
+ let cursor = 0;
14
+ // 先找固定标记,再移除相邻空白;无标记的长空白不会从每个字符重新回溯。
15
+ for (const match of message.matchAll(/\(traceId: ([\w.:-]{1,128})\)/g)) {
16
+ let end = match.index;
17
+ while (end > cursor && message[end - 1].trim() === '')
18
+ end--;
19
+ parts.push(message.slice(cursor, end));
20
+ cursor = match.index + match[0].length;
21
+ traceId ??= match[1];
22
+ }
23
+ parts.push(message.slice(cursor));
24
+ const readable = parts.join('').trim();
16
25
  return { message: readable || core.i18n.coreM('core_errorInternal'), traceId };
17
26
  }
18
27
  /**
package/dist/types.d.ts CHANGED
@@ -27,7 +27,7 @@ export type DataAttributeValue = string | number | boolean | null | undefined;
27
27
  export interface DataAttributes {
28
28
  [key: `data-${string}`]: DataAttributeValue;
29
29
  }
30
- export type { ChartDataItem, ChartProps, ChartSeries, ChartSize, ChartType } from './components/scenes/charts/chart-types.js';
30
+ export type { ChartDataItem, ChartPreset, ChartProps, ChartSeries, ChartSize, ChartType } from './components/scenes/charts/chart-types.js';
31
31
  /**
32
32
  * 基础变体类型
33
33
  *