@h-ai/ui 1.0.0-beta.2 → 1.0.0-beta.21
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 +252 -70
- package/README.ja.md +251 -69
- package/README.md +253 -72
- package/auto-import.d.ts +5 -0
- package/auto-import.js +242 -65
- package/dist/components/compounds/Accordion.svelte +6 -2
- package/dist/components/compounds/BottomNav.svelte +14 -2
- package/dist/components/compounds/Card.svelte +3 -1
- package/dist/components/compounds/Combobox.svelte +41 -5
- package/dist/components/compounds/DataTable.svelte +28 -8
- package/dist/components/compounds/DatePicker.svelte +6 -1
- package/dist/components/compounds/Drawer.svelte +12 -4
- package/dist/components/compounds/Dropdown.svelte +135 -59
- package/dist/components/compounds/Empty.svelte +10 -2
- package/dist/components/compounds/FormField.svelte +10 -2
- package/dist/components/compounds/JsonViewer.svelte +18 -6
- package/dist/components/compounds/Modal.svelte +8 -2
- package/dist/components/compounds/Pagination.svelte +22 -7
- package/dist/components/compounds/Popover.svelte +93 -12
- package/dist/components/compounds/Steps.svelte +24 -8
- package/dist/components/compounds/SwipeCell.svelte +3 -1
- package/dist/components/compounds/TableToolbar.svelte +32 -9
- package/dist/components/compounds/Tabs.svelte +25 -5
- package/dist/components/compounds/TagInput.svelte +2 -0
- package/dist/components/compounds/Timeline.svelte +6 -2
- package/dist/components/compounds/ToastContainer.svelte +41 -10
- package/dist/components/compounds/Tooltip.svelte +1 -1
- package/dist/components/compounds/Tooltip.svelte.d.ts +1 -1
- package/dist/components/control-size.js +48 -8
- package/dist/components/primitives/Avatar.svelte +9 -3
- package/dist/components/primitives/BareInput.svelte +3 -1
- package/dist/components/primitives/Button.svelte +6 -2
- package/dist/components/primitives/Checkbox.svelte +5 -0
- package/dist/components/primitives/IconButton.svelte +3 -1
- package/dist/components/primitives/Input.svelte +19 -3
- package/dist/components/primitives/Radio.svelte +4 -1
- package/dist/components/primitives/Range.svelte +3 -1
- package/dist/components/primitives/Rating.svelte +9 -3
- package/dist/components/primitives/Select.svelte +21 -5
- package/dist/components/primitives/Tag.svelte +6 -10
- package/dist/components/primitives/Textarea.svelte +14 -2
- package/dist/components/scenes/ai/AiDocumentEditor.svelte +40 -12
- package/dist/components/scenes/ai/document-download.js +6 -2
- package/dist/components/scenes/ai/document-parse.js +24 -8
- package/dist/components/scenes/ai/editor-markdown-extensions.js +9 -3
- package/dist/components/scenes/ai/highlight.js +18 -1
- package/dist/components/scenes/ai/markdown-parse.js +81 -28
- package/dist/components/scenes/ai/mermaid-render.js +13 -1
- package/dist/components/scenes/ai/safe-html.js +9 -3
- package/dist/components/scenes/ai/table/AiTableEditor.svelte +27 -9
- package/dist/components/scenes/app/FeedbackDetail.svelte +102 -24
- package/dist/components/scenes/app/FeedbackForm.svelte +70 -16
- package/dist/components/scenes/app/FeedbackList.svelte +138 -21
- package/dist/components/scenes/app/FeedbackRecorder.svelte +18 -5
- package/dist/components/scenes/app/FeedbackReplay.svelte +15 -3
- package/dist/components/scenes/app/FeedbackScreenshot.svelte +64 -13
- package/dist/components/scenes/app/LanguageSwitch.svelte +6 -2
- package/dist/components/scenes/app/SettingsLayout.svelte +3 -1
- package/dist/components/scenes/app/ThemeSelector.svelte +29 -5
- package/dist/components/scenes/app/ThemeToggle.svelte +6 -2
- package/dist/components/scenes/app/WorkspaceLayout.svelte +1 -1
- package/dist/components/scenes/app/feedback-functions.js +6 -2
- package/dist/components/scenes/charts/Chart.svelte +55 -21
- 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 +69 -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 +56 -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 +39 -12
- 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/components/scenes/code/CodeWorkspace.svelte +946 -0
- package/dist/components/scenes/code/CodeWorkspace.svelte.d.ts +21 -0
- package/dist/components/scenes/code/CodeWorkspaceEditor.svelte +737 -0
- package/dist/components/scenes/code/CodeWorkspaceEditor.svelte.d.ts +37 -0
- package/dist/components/scenes/code/CodeWorkspaceGutter.svelte +246 -0
- package/dist/components/scenes/code/CodeWorkspaceGutter.svelte.d.ts +23 -0
- package/dist/components/scenes/code/CodeWorkspaceSearch.svelte +234 -0
- package/dist/components/scenes/code/CodeWorkspaceSearch.svelte.d.ts +23 -0
- package/dist/components/scenes/code/CodeWorkspaceTree.svelte +519 -0
- package/dist/components/scenes/code/CodeWorkspaceTree.svelte.d.ts +26 -0
- package/dist/components/scenes/code/code-editor.d.ts +12 -0
- package/dist/components/scenes/code/code-editor.js +93 -0
- package/dist/components/scenes/code/code-types.d.ts +346 -0
- package/dist/components/scenes/code/code-types.js +1 -0
- package/dist/components/scenes/code/index.d.ts +2 -0
- package/dist/components/scenes/code/index.js +1 -0
- package/dist/components/scenes/code/workers/css.worker.d.ts +1 -0
- package/dist/components/scenes/code/workers/css.worker.js +1 -0
- package/dist/components/scenes/code/workers/editor.worker.d.ts +1 -0
- package/dist/components/scenes/code/workers/editor.worker.js +1 -0
- package/dist/components/scenes/code/workers/html.worker.d.ts +1 -0
- package/dist/components/scenes/code/workers/html.worker.js +1 -0
- package/dist/components/scenes/code/workers/json.worker.d.ts +1 -0
- package/dist/components/scenes/code/workers/json.worker.js +1 -0
- package/dist/components/scenes/code/workers/ts.worker.d.ts +1 -0
- package/dist/components/scenes/code/workers/ts.worker.js +1 -0
- package/dist/components/scenes/crud/CrudDetailDrawer.svelte +6 -2
- package/dist/components/scenes/crud/CrudDetailPanel.svelte +6 -2
- package/dist/components/scenes/crud/CrudEditPanel.svelte +41 -12
- package/dist/components/scenes/crud/CrudPage.svelte +34 -9
- package/dist/components/scenes/crud/crud-controller.svelte.js +23 -8
- package/dist/components/scenes/crud/crud-form-validation.js +27 -9
- package/dist/components/scenes/crypto/EncryptedInput.svelte +9 -3
- package/dist/components/scenes/error/error-presets.js +30 -5
- package/dist/components/scenes/guide/GuideHostContent.svelte +7 -1
- package/dist/components/scenes/guide/HelpCenter.svelte +23 -4
- package/dist/components/scenes/iam/AgreementNotice.svelte +9 -3
- package/dist/components/scenes/iam/AuthPanel.svelte +74 -16
- package/dist/components/scenes/iam/ChangePasswordForm.svelte +6 -2
- package/dist/components/scenes/iam/ForgotPasswordForm.svelte +9 -3
- package/dist/components/scenes/iam/LoginForm.svelte +32 -8
- package/dist/components/scenes/iam/PasswordInput.svelte +50 -12
- package/dist/components/scenes/iam/RegisterForm.svelte +11 -3
- package/dist/components/scenes/iam/ResetPasswordForm.svelte +6 -2
- package/dist/components/scenes/iam/SensitiveOperationsForm.svelte +3 -1
- package/dist/components/scenes/iam/SessionRecoveryDialog.svelte +4 -1
- package/dist/components/scenes/iam/UserProfile.svelte +41 -14
- package/dist/components/scenes/iam/auth-captcha.js +9 -2
- package/dist/components/scenes/iam/auth-error-message.d.ts +2 -2
- package/dist/components/scenes/iam/auth-error-message.js +16 -3
- package/dist/components/scenes/iam/password-utils.js +9 -2
- package/dist/components/scenes/iam/sensitive-actions.svelte.js +4 -1
- package/dist/components/scenes/index.d.ts +1 -0
- package/dist/components/scenes/index.js +2 -0
- package/dist/components/scenes/storage/FileList.svelte +3 -1
- package/dist/components/scenes/storage/FileUpload.svelte +7 -2
- package/dist/components/scenes/types.d.ts +2 -2
- package/dist/guide-storage.js +12 -4
- package/dist/guide.svelte.js +59 -16
- package/dist/i18n.svelte.js +9 -3
- package/dist/internal/dialog-focus.d.ts +19 -0
- package/dist/internal/dialog-focus.js +104 -4
- package/dist/internal/form-validation.svelte.js +46 -15
- package/dist/internal/icon-safety.js +6 -2
- package/dist/message.svelte.js +6 -2
- package/dist/messagebox.svelte.js +6 -2
- package/dist/messages/en-US.json +60 -1
- package/dist/messages/ja-JP.json +60 -1
- package/dist/messages/zh-CN.json +60 -1
- package/dist/styles/eye-care.css +55 -0
- package/dist/styles/global.css +16 -0
- package/dist/styles/theme.css +1 -0
- package/dist/theme-config.d.ts +1 -1
- package/dist/theme-config.js +136 -21
- package/dist/toast.svelte.js +14 -3
- package/dist/types.d.ts +3 -3
- package/dist/utils.js +6 -2
- package/package.json +25 -19
|
@@ -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,56 @@
|
|
|
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 {
|
|
13
|
+
type: 'bar',
|
|
14
|
+
props: {
|
|
15
|
+
seriesLayout: 'group',
|
|
16
|
+
axis: true,
|
|
17
|
+
grid: true,
|
|
18
|
+
legend: true,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
case 'stacked-bar': return {
|
|
22
|
+
type: 'bar',
|
|
23
|
+
props: {
|
|
24
|
+
seriesLayout: 'stack',
|
|
25
|
+
axis: true,
|
|
26
|
+
grid: true,
|
|
27
|
+
legend: true,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
case 'stacked-area': return {
|
|
31
|
+
type: 'area',
|
|
32
|
+
props: {
|
|
33
|
+
seriesLayout: 'stack',
|
|
34
|
+
axis: true,
|
|
35
|
+
grid: true,
|
|
36
|
+
legend: true,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
case 'donut': return {
|
|
40
|
+
type: 'pie',
|
|
41
|
+
props: { innerRadius: 0.65, legend: true },
|
|
42
|
+
};
|
|
43
|
+
case 'sparkline': return {
|
|
44
|
+
type: 'line',
|
|
45
|
+
props: {
|
|
46
|
+
axis: false,
|
|
47
|
+
grid: false,
|
|
48
|
+
legend: false,
|
|
49
|
+
points: false,
|
|
50
|
+
padding: { top: 4, right: 0, bottom: 4, left: 0 },
|
|
51
|
+
height: 64,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
default: return { props: {} };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -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;
|
|
@@ -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
|
* 分段折线图单个数据点,保留展示标签与数值。
|
|
@@ -215,9 +216,13 @@
|
|
|
215
216
|
* @returns 有限数字,无法转换时返回 0
|
|
216
217
|
*/
|
|
217
218
|
function toFiniteNumber(value: unknown): number {
|
|
218
|
-
const numberValue = typeof value === 'number'
|
|
219
|
+
const numberValue = typeof value === 'number'
|
|
220
|
+
? value
|
|
221
|
+
: Number(value)
|
|
219
222
|
|
|
220
|
-
return Number.isFinite(numberValue)
|
|
223
|
+
return Number.isFinite(numberValue)
|
|
224
|
+
? numberValue
|
|
225
|
+
: 0
|
|
221
226
|
}
|
|
222
227
|
|
|
223
228
|
/**
|
|
@@ -247,7 +252,15 @@
|
|
|
247
252
|
* @returns CSS 颜色值或变量
|
|
248
253
|
*/
|
|
249
254
|
function getSeriesColor(item: ChartSeries, index: number): string {
|
|
250
|
-
return item.color ?? `var(--color-${[
|
|
255
|
+
return item.color ?? `var(--color-${[
|
|
256
|
+
'primary',
|
|
257
|
+
'secondary',
|
|
258
|
+
'accent',
|
|
259
|
+
'success',
|
|
260
|
+
'warning',
|
|
261
|
+
'error',
|
|
262
|
+
'info',
|
|
263
|
+
][index % 7]})`
|
|
251
264
|
}
|
|
252
265
|
|
|
253
266
|
/**
|
|
@@ -274,17 +287,27 @@
|
|
|
274
287
|
|
|
275
288
|
if (Array.isArray(yAccessor)) {
|
|
276
289
|
return yAccessor.map((accessor, index) => ({
|
|
277
|
-
key: typeof accessor === 'string'
|
|
278
|
-
|
|
290
|
+
key: typeof accessor === 'string'
|
|
291
|
+
? accessor
|
|
292
|
+
: `series-${index}`,
|
|
293
|
+
label: typeof accessor === 'string'
|
|
294
|
+
? accessor
|
|
295
|
+
: `series-${index + 1}`,
|
|
279
296
|
value: accessor,
|
|
280
297
|
}))
|
|
281
298
|
}
|
|
282
299
|
|
|
283
|
-
return [
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
300
|
+
return [
|
|
301
|
+
{
|
|
302
|
+
key: typeof yAccessor === 'string'
|
|
303
|
+
? yAccessor
|
|
304
|
+
: 'value',
|
|
305
|
+
label: typeof yAccessor === 'string'
|
|
306
|
+
? yAccessor
|
|
307
|
+
: 'value',
|
|
308
|
+
value: yAccessor,
|
|
309
|
+
},
|
|
310
|
+
]
|
|
288
311
|
}
|
|
289
312
|
|
|
290
313
|
/**
|
|
@@ -322,7 +345,9 @@
|
|
|
322
345
|
function getSegmentedLineMax(items: SegmentedLineSeries[]): number {
|
|
323
346
|
const maxValue = Math.max(...items.flatMap(item => item.points.map(point => point.value)))
|
|
324
347
|
|
|
325
|
-
return maxValue > 0
|
|
348
|
+
return maxValue > 0
|
|
349
|
+
? maxValue
|
|
350
|
+
: 1
|
|
326
351
|
}
|
|
327
352
|
|
|
328
353
|
/**
|
|
@@ -405,7 +430,9 @@
|
|
|
405
430
|
const currentDistance = Math.abs(point.x - pointerX)
|
|
406
431
|
const bestDistance = Math.abs((primaryCoordinates[bestIndex]?.x ?? point.x) - pointerX)
|
|
407
432
|
|
|
408
|
-
return currentDistance < bestDistance
|
|
433
|
+
return currentDistance < bestDistance
|
|
434
|
+
? index
|
|
435
|
+
: bestIndex
|
|
409
436
|
}, 0)
|
|
410
437
|
const nearestPoint = primaryCoordinates[nearestIndex]
|
|
411
438
|
if (nearestPoint)
|
|
@@ -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;
|