@h-ai/ui 1.0.0-beta.7 → 1.0.0-beta.9
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/README.en.md +22 -1
- package/README.ja.md +22 -1
- package/README.md +22 -1
- package/auto-import.d.ts +4 -0
- package/auto-import.js +5 -0
- package/dist/components/scenes/charts/Chart.svelte +43 -20
- package/dist/components/scenes/charts/Chart.svelte.d.ts +0 -1
- package/dist/components/scenes/charts/ChartLoadError.svelte +13 -0
- package/dist/components/scenes/charts/ChartLoadError.svelte.d.ts +6 -0
- package/dist/components/scenes/charts/DashboardGrid.svelte +34 -0
- package/dist/components/scenes/charts/DashboardGrid.svelte.d.ts +15 -0
- package/dist/components/scenes/charts/MetricCard.svelte +52 -0
- package/dist/components/scenes/charts/MetricCard.svelte.d.ts +15 -0
- package/dist/components/scenes/charts/ReportCard.svelte +48 -0
- package/dist/components/scenes/charts/ReportCard.svelte.d.ts +15 -0
- package/dist/components/scenes/charts/chart-presets.d.ts +15 -0
- package/dist/components/scenes/charts/chart-presets.js +19 -0
- package/dist/components/scenes/charts/chart-types.d.ts +13 -2
- package/dist/components/scenes/charts/dashboard-types.d.ts +79 -0
- package/dist/components/scenes/charts/dashboard-types.js +1 -0
- package/dist/components/scenes/charts/index.d.ts +6 -2
- package/dist/components/scenes/charts/index.js +4 -1
- package/dist/components/scenes/charts/renderers/AreaChart.svelte +1 -0
- package/dist/components/scenes/charts/renderers/AreaChart.svelte.d.ts +1 -0
- package/dist/components/scenes/charts/renderers/BarChart.svelte +1 -0
- package/dist/components/scenes/charts/renderers/BarChart.svelte.d.ts +1 -0
- package/dist/components/scenes/charts/renderers/LineChart.svelte +1 -0
- package/dist/components/scenes/charts/renderers/LineChart.svelte.d.ts +1 -0
- package/dist/components/scenes/charts/renderers/PieChart.svelte +1 -0
- package/dist/components/scenes/charts/renderers/PieChart.svelte.d.ts +1 -0
- package/dist/components/scenes/charts/renderers/ScatterChart.svelte +1 -0
- package/dist/components/scenes/charts/renderers/ScatterChart.svelte.d.ts +1 -0
- package/dist/messages/en-US.json +6 -1
- package/dist/messages/ja-JP.json +6 -1
- package/dist/messages/zh-CN.json +6 -1
- package/dist/types.d.ts +1 -1
- package/package.json +2 -2
package/README.en.md
CHANGED
|
@@ -299,7 +299,7 @@ Text controls validate on blur after input and update errors as input is correct
|
|
|
299
299
|
| ------------ | ----------- | ----------------------------------------------- |
|
|
300
300
|
| `PageHeader` | Page header | `title`, `description`; supports `actions` slot |
|
|
301
301
|
|
|
302
|
-
#### Scenes (
|
|
302
|
+
#### Scenes (47)
|
|
303
303
|
|
|
304
304
|
##### Guide (2)
|
|
305
305
|
|
|
@@ -407,6 +407,27 @@ Defaults match `@h-ai/crypto`: `SM4` for encrypted inputs, `SM3` for hashes, and
|
|
|
407
407
|
|
|
408
408
|
##### Charts
|
|
409
409
|
|
|
410
|
+
Lightweight dashboards use `MetricCard` (value, unit and percentage change), `ReportCard` (heading, actions, content, loading/empty states), and `DashboardGrid` (one, two or more columns based on container width). MetricCard alone does not load a chart engine. `trend={12.8}` means +12.8%; `trendTone` expresses business meaning independently, so a decrease can be success. Missing and non-finite values show “—”; zero remains visible.
|
|
411
|
+
|
|
412
|
+
`Chart` supports `preset`: `grouped-bar`, `stacked-bar`, `stacked-area`, `donut`, and `sparkline`. Presets supply defaults; explicit `type` and native props take precedence, such as `innerRadius={0.8}` overriding the donut radius. Other LayerChart props and snippets continue to pass through.
|
|
413
|
+
|
|
414
|
+
Renderers load dynamically by type. SSR reserves height and shows a loading placeholder; drawing starts after browser mount. Loading and empty charts do not load renderers. Prefer the public charts entry for dashboard-only consumers. For advanced charts, place native LayerChart components in ReportCard children, beyond Chart's five types. Declare a compatible `layerchart` dependency and use its actual public entries such as `layerchart/svg` or `layerchart/hierarchy`. Load advanced components dynamically when needed; see the admin native ArcChart example.
|
|
415
|
+
|
|
416
|
+
```svelte
|
|
417
|
+
<script lang="ts">
|
|
418
|
+
import { Chart, DashboardGrid, MetricCard, ReportCard } from '@h-ai/ui/components/scenes/charts/index'
|
|
419
|
+
const data = [{ month: 'Jan', revenue: 42, cost: 24 }, { month: 'Feb', revenue: 58, cost: 31 }]
|
|
420
|
+
</script>
|
|
421
|
+
|
|
422
|
+
<DashboardGrid label="Key metrics" columns={4}>
|
|
423
|
+
<MetricCard title="Revenue" value="128,430" unit="CNY" trend={12.8} trendTone="success" trendLabel="vs previous month" />
|
|
424
|
+
</DashboardGrid>
|
|
425
|
+
<ReportCard title="Revenue and cost">
|
|
426
|
+
<Chart preset="grouped-bar" {data} x="month" y={['revenue', 'cost']} />
|
|
427
|
+
</ReportCard>
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
|
|
410
431
|
`Chart type='line'` uses LayerChart's native line chart by default. For monitoring dashboards with segmented lines, points, nearest-point hover, and vertical reference lines, use `lineVariant='segmented-point'`:
|
|
411
432
|
|
|
412
433
|
```svelte
|
package/README.ja.md
CHANGED
|
@@ -299,7 +299,7 @@ components/
|
|
|
299
299
|
| -------------- | -------------- | ---------------------------------------------- |
|
|
300
300
|
| `PageHeader` | ページヘッダー | `title`, `description`、`actions` スロット対応 |
|
|
301
301
|
|
|
302
|
-
#### Scenes:用途別コンポーネント(
|
|
302
|
+
#### Scenes:用途別コンポーネント(47)
|
|
303
303
|
|
|
304
304
|
##### Guide:案内・ヘルプ(2)
|
|
305
305
|
|
|
@@ -407,6 +407,27 @@ components/
|
|
|
407
407
|
|
|
408
408
|
##### Charts:グラフ
|
|
409
409
|
|
|
410
|
+
軽量ダッシュボードには `MetricCard`(値・単位・変化率)、`ReportCard`(見出し・操作・内容・読み込み/空状態)、`DashboardGrid`(コンテナー幅に応じた一列・二列・複数列)を使います。指標カードだけではグラフエンジンを読み込みません。`trend={12.8}` は +12.8% を意味します。`trendTone` は業務上の意味を別に表すため、減少も success にできます。欠損値・非有限数は「—」、ゼロはそのまま表示します。
|
|
411
|
+
|
|
412
|
+
`Chart` の `preset` は `grouped-bar`、`stacked-bar`、`stacked-area`、`donut`、`sparkline` です。明示的な `type` とネイティブ属性が既定値より優先されます。例として `innerRadius={0.8}` でドーナツの内径を変更できます。他の LayerChart 属性と snippet も引き続き転送されます。
|
|
413
|
+
|
|
414
|
+
レンダラーは種類別に動的読み込みします。SSR は高さを確保してプレースホルダーを表示し、ブラウザのマウント後に描画します。読み込み中・空データではレンダラーを取得しません。看板だけを使う場合は公開 charts エントリを推奨します。高度な図形は ReportCard の children にネイティブ LayerChart 部品を置けます。Chart の五種類に制限されません。互換性のある `layerchart` を明示的依存に追加し、`layerchart/svg` や `layerchart/hierarchy` など実際の公開エントリを使います。高度な部品も必要時に動的読み込みできます。admin の ArcChart 例を参照してください。
|
|
415
|
+
|
|
416
|
+
```svelte
|
|
417
|
+
<script lang="ts">
|
|
418
|
+
import { Chart, DashboardGrid, MetricCard, ReportCard } from '@h-ai/ui/components/scenes/charts/index'
|
|
419
|
+
const data = [{ month: 'Jan', revenue: 42, cost: 24 }, { month: 'Feb', revenue: 58, cost: 31 }]
|
|
420
|
+
</script>
|
|
421
|
+
|
|
422
|
+
<DashboardGrid label="Key metrics" columns={4}>
|
|
423
|
+
<MetricCard title="Revenue" value="128,430" unit="CNY" trend={12.8} trendTone="success" trendLabel="vs previous month" />
|
|
424
|
+
</DashboardGrid>
|
|
425
|
+
<ReportCard title="Revenue and cost">
|
|
426
|
+
<Chart preset="grouped-bar" {data} x="month" y={['revenue', 'cost']} />
|
|
427
|
+
</ReportCard>
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
|
|
410
431
|
`Chart type='line'` は既定で LayerChart の折れ線を使います。監視画面で分割線・点・最寄りの点への hover・縦基準線が必要な場合は `lineVariant='segmented-point'` を使います:
|
|
411
432
|
|
|
412
433
|
```svelte
|
package/README.md
CHANGED
|
@@ -299,7 +299,7 @@ components/
|
|
|
299
299
|
| ------------ | -------- | ------------------------------------------- |
|
|
300
300
|
| `PageHeader` | 页面头部 | `title`, `description`,支持 `actions` 插槽 |
|
|
301
301
|
|
|
302
|
-
#### 场景组件 Scenes(
|
|
302
|
+
#### 场景组件 Scenes(47 个)
|
|
303
303
|
|
|
304
304
|
##### Guide 引导与帮助(2 个)
|
|
305
305
|
|
|
@@ -406,6 +406,27 @@ components/
|
|
|
406
406
|
|
|
407
407
|
##### Charts 图表
|
|
408
408
|
|
|
409
|
+
轻量看板由 `MetricCard`(数值、单位、百分比变化)、`ReportCard`(标题、操作、内容、加载/空态)和 `DashboardGrid`(按容器宽度收拢为一/二/多列)组成。指标卡自身不加载图形引擎;`trend={12.8}` 表示 +12.8%,`trendTone` 独立表达业务好坏,下降也可以是 success。缺失或非有限数显示“—”,零值正常显示。
|
|
410
|
+
|
|
411
|
+
`Chart` 新增 `preset`:`grouped-bar`、`stacked-bar`、`stacked-area`、`donut`、`sparkline`。预设补默认图形类型和配置,显式 `type` 及原生属性优先;例如 `innerRadius={0.8}` 覆盖环形默认半径。其他 LayerChart 属性与 snippet 继续透传。
|
|
412
|
+
|
|
413
|
+
按类型动态加载渲染器;SSR 保留高度并显示加载占位,浏览器挂载后绘制。加载态和空数据不加载渲染器。只需要看板组件时优先使用公开 charts 入口。高级图形通过 `ReportCard` 的 children 使用原生 LayerChart,不受 Chart 的五种类型限制;应用需显式依赖兼容的 `layerchart`,按需使用 `layerchart/svg`、`layerchart/hierarchy` 等实际公开入口。用动态组件加载控制高级图形的加载时机,见 admin 的原生 ArcChart 示例。
|
|
414
|
+
|
|
415
|
+
```svelte
|
|
416
|
+
<script lang="ts">
|
|
417
|
+
import { Chart, DashboardGrid, MetricCard, ReportCard } from '@h-ai/ui/components/scenes/charts/index'
|
|
418
|
+
const data = [{ month: 'Jan', revenue: 42, cost: 24 }, { month: 'Feb', revenue: 58, cost: 31 }]
|
|
419
|
+
</script>
|
|
420
|
+
|
|
421
|
+
<DashboardGrid label="Key metrics" columns={4}>
|
|
422
|
+
<MetricCard title="Revenue" value="128,430" unit="CNY" trend={12.8} trendTone="success" trendLabel="vs previous month" />
|
|
423
|
+
</DashboardGrid>
|
|
424
|
+
<ReportCard title="Revenue and cost">
|
|
425
|
+
<Chart preset="grouped-bar" {data} x="month" y={['revenue', 'cost']} />
|
|
426
|
+
</ReportCard>
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
|
|
409
430
|
`Chart type='line'` 默认透传 LayerChart 原生折线图;需要监控看板常见的“分段线 + 圆点 + 最近点 hover + 竖向参考线”时,使用 `lineVariant='segmented-point'`:
|
|
410
431
|
|
|
411
432
|
```svelte
|
package/auto-import.d.ts
CHANGED
|
@@ -16,6 +16,10 @@ type AutoImportHaiUiPreprocessor = {
|
|
|
16
16
|
export function autoImportHaiUi(): AutoImportHaiUiPreprocessor
|
|
17
17
|
|
|
18
18
|
declare global {
|
|
19
|
+
const Chart: typeof import('@h-ai/ui')['Chart']
|
|
20
|
+
const DashboardGrid: typeof import('@h-ai/ui')['DashboardGrid']
|
|
21
|
+
const MetricCard: typeof import('@h-ai/ui')['MetricCard']
|
|
22
|
+
const ReportCard: typeof import('@h-ai/ui')['ReportCard']
|
|
19
23
|
const GuideHost: typeof import('@h-ai/ui')['GuideHost']
|
|
20
24
|
const HelpCenter: typeof import('@h-ai/ui')['HelpCenter']
|
|
21
25
|
// primitives
|
package/auto-import.js
CHANGED
|
@@ -20,18 +20,16 @@
|
|
|
20
20
|
-->
|
|
21
21
|
<script lang='ts'>
|
|
22
22
|
import type { ChartProps, ChartSeries, ChartType } from './chart-types.js'
|
|
23
|
+
import { onMount } from 'svelte'
|
|
23
24
|
import { uiM } from '../../../messages.js'
|
|
24
25
|
import { cn, getDataAttributes } from '../../../utils.js'
|
|
26
|
+
import { resolveChartPreset } from './chart-presets.js'
|
|
25
27
|
import { DAISYUI_CHART_COLORS, resolveChartColors } from './chart-theme.js'
|
|
26
|
-
import
|
|
27
|
-
import BarChart from './renderers/BarChart.svelte'
|
|
28
|
-
import LineChart from './renderers/LineChart.svelte'
|
|
29
|
-
import PieChart from './renderers/PieChart.svelte'
|
|
30
|
-
import ScatterChart from './renderers/ScatterChart.svelte'
|
|
31
|
-
import 'layerchart/daisyui-5.css'
|
|
28
|
+
import ChartLoadError from './ChartLoadError.svelte'
|
|
32
29
|
|
|
33
30
|
const {
|
|
34
|
-
type,
|
|
31
|
+
type: requestedType,
|
|
32
|
+
preset,
|
|
35
33
|
data = [],
|
|
36
34
|
x,
|
|
37
35
|
y,
|
|
@@ -46,8 +44,24 @@
|
|
|
46
44
|
...restProps
|
|
47
45
|
}: ChartProps = $props()
|
|
48
46
|
|
|
47
|
+
const presetConfig = $derived(resolveChartPreset(preset))
|
|
48
|
+
const type = $derived(requestedType ?? presetConfig.type ?? 'line')
|
|
49
|
+
const nativeProps = $derived({ ...presetConfig.props, ...restProps })
|
|
49
50
|
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
50
51
|
|
|
52
|
+
// 仅浏览器挂载且确有数据时加载对应图形;Svelte await 自动丢弃过期 Promise 的结果。
|
|
53
|
+
const renderers = {
|
|
54
|
+
bar: () => import('./renderers/BarChart.svelte'),
|
|
55
|
+
line: () => import('./renderers/LineChart.svelte'),
|
|
56
|
+
area: () => import('./renderers/AreaChart.svelte'),
|
|
57
|
+
pie: () => import('./renderers/PieChart.svelte'),
|
|
58
|
+
scatter: () => import('./renderers/ScatterChart.svelte'),
|
|
59
|
+
}
|
|
60
|
+
let mounted = $state(false)
|
|
61
|
+
onMount(() => {
|
|
62
|
+
mounted = true
|
|
63
|
+
})
|
|
64
|
+
|
|
51
65
|
const chartSizeHeights: Record<NonNullable<ChartProps['size']>, number> = {
|
|
52
66
|
sm: 200,
|
|
53
67
|
md: 300,
|
|
@@ -58,10 +72,11 @@
|
|
|
58
72
|
|
|
59
73
|
/** 图表可视高度优先尊重 LayerChart 原生 height,未传时使用 @h-ai/ui 的 size 预设。 */
|
|
60
74
|
const chartHeight = $derived(
|
|
61
|
-
typeof
|
|
75
|
+
typeof nativeProps.height === 'number' ? nativeProps.height : chartSizeHeights[size],
|
|
62
76
|
)
|
|
63
77
|
|
|
64
78
|
const isEmpty = $derived(empty || data.length === 0)
|
|
79
|
+
const rendererPromise = $derived(mounted && !loading && !isEmpty ? renderers[type]() : undefined)
|
|
65
80
|
const hasHeader = $derived(Boolean(title || description))
|
|
66
81
|
|
|
67
82
|
const rootClass = $derived(
|
|
@@ -112,7 +127,7 @@
|
|
|
112
127
|
data,
|
|
113
128
|
height: chartHeight,
|
|
114
129
|
cRange: DAISYUI_CHART_COLORS,
|
|
115
|
-
...
|
|
130
|
+
...nativeProps,
|
|
116
131
|
orientation,
|
|
117
132
|
series: resolvedSeries,
|
|
118
133
|
x,
|
|
@@ -126,7 +141,7 @@
|
|
|
126
141
|
label: x,
|
|
127
142
|
value: pieValue,
|
|
128
143
|
cRange: DAISYUI_CHART_COLORS,
|
|
129
|
-
...
|
|
144
|
+
...nativeProps,
|
|
130
145
|
series: resolvedSeries,
|
|
131
146
|
})
|
|
132
147
|
</script>
|
|
@@ -148,16 +163,24 @@
|
|
|
148
163
|
<span class='loading loading-spinner loading-md text-primary' aria-label={uiM('chart_loading')}></span>
|
|
149
164
|
{:else if isEmpty}
|
|
150
165
|
<p class='text-sm text-base-content/50'>{uiM('chart_empty')}</p>
|
|
151
|
-
{:else if
|
|
152
|
-
<
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
{:else
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
166
|
+
{:else if !mounted}
|
|
167
|
+
<div class='flex h-full items-center justify-center' role='status' aria-label={uiM('chart_loading')}>
|
|
168
|
+
<span class='loading loading-spinner loading-md text-primary'></span>
|
|
169
|
+
</div>
|
|
170
|
+
{:else}
|
|
171
|
+
{#await rendererPromise}
|
|
172
|
+
<div class='flex h-full items-center justify-center' role='status' aria-label={uiM('chart_loading')}>
|
|
173
|
+
<span class='loading loading-spinner loading-md text-primary'></span>
|
|
174
|
+
</div>
|
|
175
|
+
{:then renderer}
|
|
176
|
+
{#if renderer}
|
|
177
|
+
{@const Renderer = renderer.default}
|
|
178
|
+
<Renderer {...(type === 'pie' ? pieLayerProps : cartesianLayerProps)} />
|
|
179
|
+
{/if}
|
|
180
|
+
{:catch}
|
|
181
|
+
<!-- 浏览器可能缓存失败的模块请求;刷新文档后才能可靠重试同一资源。 -->
|
|
182
|
+
<ChartLoadError onretry={() => window.location.reload()} />
|
|
183
|
+
{/await}
|
|
161
184
|
{/if}
|
|
162
185
|
</div>
|
|
163
186
|
</div>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- 图形模块加载失败时使用统一 Toast,原位保留重试操作。 -->
|
|
2
|
+
<script lang='ts'>
|
|
3
|
+
import { uiM } from '../../../messages.js'
|
|
4
|
+
import { useToastFeedback } from '../../../toast.svelte.js'
|
|
5
|
+
import Button from '../../primitives/Button.svelte'
|
|
6
|
+
/** 重试由 Chart 重新创建本次动态导入。 */
|
|
7
|
+
const { onretry }: { onretry: () => void } = $props()
|
|
8
|
+
useToastFeedback(() => uiM('chart_load_failed'))
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<div class='flex h-full items-center justify-center'>
|
|
12
|
+
<Button onclick={onretry} size='sm'>{uiM('chart_retry')}</Button>
|
|
13
|
+
</div>
|
|
@@ -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
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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;
|
|
@@ -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;
|
package/dist/messages/en-US.json
CHANGED
|
@@ -519,5 +519,10 @@
|
|
|
519
519
|
"theme_formal": "Formal",
|
|
520
520
|
"keyboard_submit_enter": "Press Enter in a single-line field to submit",
|
|
521
521
|
"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."
|
|
522
|
+
"auth_error_account_unavailable": "This account is unavailable. Contact your administrator to check its status and expiry.",
|
|
523
|
+
"chart_load_failed": "Unable to load the chart. Please retry.",
|
|
524
|
+
"chart_retry": "Refresh page to retry",
|
|
525
|
+
"metric_increase": "Increase",
|
|
526
|
+
"metric_decrease": "Decrease",
|
|
527
|
+
"metric_unchanged": "Unchanged"
|
|
523
528
|
}
|
package/dist/messages/ja-JP.json
CHANGED
|
@@ -519,5 +519,10 @@
|
|
|
519
519
|
"theme_formal": "ビジネス(角丸なし)",
|
|
520
520
|
"keyboard_submit_enter": "1行の入力欄で Enter を押して送信",
|
|
521
521
|
"request_access_denied": "アクセス制限により、このリクエストは許可されませんでした。アクセス先、ネットワーク、許可時間帯を確認してください。必要な場合は管理者にお問い合わせください。",
|
|
522
|
-
"auth_error_account_unavailable": "現在このアカウントは利用できません。状態と有効期限を管理者に確認してください。"
|
|
522
|
+
"auth_error_account_unavailable": "現在このアカウントは利用できません。状態と有効期限を管理者に確認してください。",
|
|
523
|
+
"chart_load_failed": "グラフを読み込めませんでした。再試行してください。",
|
|
524
|
+
"chart_retry": "ページを更新して再試行",
|
|
525
|
+
"metric_increase": "増加",
|
|
526
|
+
"metric_decrease": "減少",
|
|
527
|
+
"metric_unchanged": "変化なし"
|
|
523
528
|
}
|
package/dist/messages/zh-CN.json
CHANGED
|
@@ -519,5 +519,10 @@
|
|
|
519
519
|
"theme_formal": "简洁商务",
|
|
520
520
|
"keyboard_submit_enter": "在单行输入框中按 Enter 提交",
|
|
521
521
|
"request_access_denied": "当前请求未通过访问策略检查。请确认访问地址、网络或允许的时段;如需帮助,请联系管理员。",
|
|
522
|
-
"auth_error_account_unavailable": "账号当前无法使用,请联系管理员确认账号状态及有效期。"
|
|
522
|
+
"auth_error_account_unavailable": "账号当前无法使用,请联系管理员确认账号状态及有效期。",
|
|
523
|
+
"chart_load_failed": "图表加载失败,请重试",
|
|
524
|
+
"chart_retry": "刷新页面重试",
|
|
525
|
+
"metric_increase": "上升",
|
|
526
|
+
"metric_decrease": "下降",
|
|
527
|
+
"metric_unchanged": "持平"
|
|
523
528
|
}
|
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
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-ai/ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.9",
|
|
5
5
|
"description": "Hai Framework UI component library for Svelte 5 Runes.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"svelte": "./dist/index.js",
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"svelte": "^5.57.2"
|
|
125
125
|
},
|
|
126
126
|
"dependencies": {
|
|
127
|
-
"@h-ai/core": "1.0.0-beta.
|
|
127
|
+
"@h-ai/core": "1.0.0-beta.9",
|
|
128
128
|
"@internationalized/date": "^3.12.4",
|
|
129
129
|
"@rrweb/replay": "^2.1.7",
|
|
130
130
|
"@shikijs/langs": "^4.5.0",
|