@bridge-ui/vue 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai/AGENTS.md +1 -1
- package/ai/README.md +1 -1
- package/ai/llms.txt +0 -1
- package/ai/skills/bridge-ui-components/SKILL.md +2 -1
- package/ai/skills/bridge-ui-setup/SKILL.md +8 -8
- package/dist/Actions/Snackbar/BridgeSnackbarItem.vue_vue_type_script_setup_true_lang.js +42 -44
- package/dist/Actions/Snackbar/createBridgeSnackbarApi.js +1 -1
- package/dist/Adapters/index.d.ts +0 -1
- package/dist/Adapters/index.js +1 -2
- package/dist/Components/Accordion/composables/useAccordion.js +1 -1
- package/dist/Components/Autocomplete/composables/useAutocomplete.js +248 -258
- package/dist/Components/Chart/Chart.js +5 -0
- package/dist/Components/Chart/Chart.vue.d.ts +14 -0
- package/dist/Components/Chart/Chart.vue_vue_type_script_setup_true_lang.js +52 -0
- package/dist/Components/Chart/chart.types.d.ts +126 -0
- package/dist/Components/Chart/chartInjectionKey.d.ts +94 -0
- package/dist/Components/Chart/chartInjectionKey.js +10 -0
- package/dist/Components/Chart/composables/useChart.d.ts +40 -0
- package/dist/Components/Chart/composables/useChart.js +344 -0
- package/dist/Components/Chart/echartsChart.d.ts +14 -0
- package/dist/Components/Chart/echartsChart.js +199 -0
- package/dist/Components/Chart/index.d.ts +4 -0
- package/dist/Components/Chart/index.js +4 -0
- package/dist/Components/ChartAxis/ChartAxis.js +5 -0
- package/dist/Components/ChartAxis/ChartAxis.vue.d.ts +7 -0
- package/dist/Components/ChartAxis/ChartAxis.vue_vue_type_script_setup_true_lang.js +30 -0
- package/dist/Components/ChartAxis/chartAxis.types.d.ts +56 -0
- package/dist/Components/ChartAxis/composables/useChartAxis.d.ts +5 -0
- package/dist/Components/ChartAxis/composables/useChartAxis.js +28 -0
- package/dist/Components/ChartAxis/index.d.ts +3 -0
- package/dist/Components/ChartAxis/index.js +3 -0
- package/dist/Components/ChartLegend/ChartLegend.js +5 -0
- package/dist/Components/ChartLegend/ChartLegend.vue.d.ts +6 -0
- package/dist/Components/ChartLegend/ChartLegend.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/Components/ChartLegend/chartLegend.types.d.ts +71 -0
- package/dist/Components/ChartLegend/composables/useChartLegend.d.ts +16 -0
- package/dist/Components/ChartLegend/composables/useChartLegend.js +98 -0
- package/dist/Components/ChartLegend/index.d.ts +3 -0
- package/dist/Components/ChartLegend/index.js +3 -0
- package/dist/Components/ChartSeries/ChartSeries.js +5 -0
- package/dist/Components/ChartSeries/ChartSeries.vue.d.ts +4 -0
- package/dist/Components/ChartSeries/ChartSeries.vue_vue_type_script_setup_true_lang.js +24 -0
- package/dist/Components/ChartSeries/chartSeries.types.d.ts +37 -0
- package/dist/Components/ChartSeries/composables/useChartSeries.d.ts +10 -0
- package/dist/Components/ChartSeries/composables/useChartSeries.js +29 -0
- package/dist/Components/ChartSeries/index.d.ts +3 -0
- package/dist/Components/ChartSeries/index.js +3 -0
- package/dist/Components/ChartTooltip/ChartTooltip.js +5 -0
- package/dist/Components/ChartTooltip/ChartTooltip.vue.d.ts +11 -0
- package/dist/Components/ChartTooltip/ChartTooltip.vue_vue_type_script_setup_true_lang.js +25 -0
- package/dist/Components/ChartTooltip/chartTooltip.types.d.ts +82 -0
- package/dist/Components/ChartTooltip/composables/useChartTooltip.d.ts +15 -0
- package/dist/Components/ChartTooltip/composables/useChartTooltip.js +110 -0
- package/dist/Components/ChartTooltip/index.d.ts +3 -0
- package/dist/Components/ChartTooltip/index.js +3 -0
- package/dist/Components/DataTable/DataTableCellContent.vue.d.ts +1 -5
- package/dist/Components/DataTable/DataTableCellContent.vue_vue_type_script_setup_true_lang.js +24 -25
- package/dist/Components/DataTable/composables/useDataTable.d.ts +1 -1
- package/dist/Components/DataTable/composables/useDataTable.js +76 -74
- package/dist/Components/DataTable/composables/useDataTablePagination.js +1 -1
- package/dist/Components/Drawer/Drawer.vue_vue_type_script_setup_true_lang.js +3 -4
- package/dist/Components/Menu/Menu.vue_vue_type_script_setup_true_lang.js +5 -3
- package/dist/Components/Modal/Modal.vue_vue_type_script_setup_true_lang.js +3 -4
- package/dist/Components/Pagination/composables/usePagination.js +1 -1
- package/dist/Components/RichTextEditor/RichTextEditor.vue.d.ts +1 -1
- package/dist/Components/RichTextEditor/RichTextEditor.vue_vue_type_script_setup_true_lang.js +17 -17
- package/dist/Components/RichTextEditor/composables/useRichTextEditor.d.ts +2 -2
- package/dist/Components/RichTextEditor/composables/useRichTextEditor.js +67 -73
- package/dist/Components/RichTextEditor/richTextEditor.types.d.ts +1 -1
- package/dist/Components/RichTextEditor/tiptapEditor.d.ts +111 -0
- package/dist/Components/RichTextEditor/tiptapEditor.js +121 -0
- package/dist/Components/Select/composables/useSelect.js +147 -157
- package/dist/Components/Snackbar/Snackbar.vue.d.ts +1 -1
- package/dist/Components/Snackbar/Snackbar.vue_vue_type_script_setup_true_lang.js +6 -7
- package/dist/Components/Stepper/composables/useStepper.js +1 -1
- package/dist/Components/Table/composables/useTableCell.d.ts +1 -1
- package/dist/Components/Tabs/composables/useTabs.js +1 -1
- package/dist/Components/ToggleGroup/composables/useToggleGroup.js +3 -3
- package/dist/Components/Tooltip/Tooltip.vue_vue_type_script_setup_true_lang.js +6 -4
- package/dist/augments.d.ts +19 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js +180 -183
- package/dist/theme.css +1 -1
- package/docs/README.md +3 -3
- package/docs/components/BridgeUIProvider.md +0 -17
- package/docs/components/Chart.md +252 -0
- package/docs/components/RichTextEditor.md +2 -23
- package/package.json +27 -6
- package/dist/Adapters/RichText/index.d.ts +0 -1
- package/dist/Adapters/RichText/index.js +0 -2
- package/dist/Adapters/RichText/mockRichTextAdapter.d.ts +0 -5
- package/dist/Adapters/RichText/useRichTextAdapter.d.ts +0 -12
- package/dist/Adapters/RichText/useRichTextAdapter.js +0 -13
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ChartOwnProps, ChartSlots } from './chart.types';
|
|
2
|
+
type __VLS_Slots = ChartSlots;
|
|
3
|
+
declare const __VLS_base: import('vue').DefineComponent<ChartOwnProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ChartOwnProps> & Readonly<{}>, {
|
|
4
|
+
loading: boolean;
|
|
5
|
+
animation: boolean;
|
|
6
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
10
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
11
|
+
new (): {
|
|
12
|
+
$slots: S;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import e from "../Skeleton/Skeleton.js";
|
|
2
|
+
import { useChart as t } from "./composables/useChart.js";
|
|
3
|
+
import { Fragment as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createTextVNode as o, createVNode as s, defineComponent as c, guardReactiveProps as l, mergeProps as u, normalizeProps as d, openBlock as f, renderList as p, renderSlot as m, toDisplayString as h, unref as g, useTemplateRef as _ } from "vue";
|
|
4
|
+
//#region src/Components/Chart/Chart.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var v = { scope: "col" }, y = { scope: "row" }, b = /*@__PURE__*/ c({
|
|
6
|
+
inheritAttrs: !1,
|
|
7
|
+
__name: "Chart",
|
|
8
|
+
props: {
|
|
9
|
+
animation: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
default: void 0
|
|
12
|
+
},
|
|
13
|
+
categories: {},
|
|
14
|
+
classes: {},
|
|
15
|
+
customProps: {},
|
|
16
|
+
height: {},
|
|
17
|
+
loading: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: !1
|
|
20
|
+
},
|
|
21
|
+
palette: {},
|
|
22
|
+
size: {},
|
|
23
|
+
summary: {},
|
|
24
|
+
width: {}
|
|
25
|
+
},
|
|
26
|
+
setup(c) {
|
|
27
|
+
let b = c, x = _("root"), S = _("plot"), C = _("host"), { table: w, isEmpty: T, hostBind: E, plotBind: D, rootBind: O, liveBind: k, emptyBind: A, isLoading: j, tableBind: M, loadingBind: N, announcement: P, emptyMessage: F } = t(b, {
|
|
28
|
+
size: "md",
|
|
29
|
+
height: 280,
|
|
30
|
+
animation: !0
|
|
31
|
+
}, {
|
|
32
|
+
hostRef: C,
|
|
33
|
+
plotRef: S,
|
|
34
|
+
rootRef: x
|
|
35
|
+
});
|
|
36
|
+
return (t, c) => (f(), i("div", u({ ref: "root" }, g(O)), [
|
|
37
|
+
a("div", u({ ref: "plot" }, g(D)), [
|
|
38
|
+
a("div", u({ ref: "host" }, g(E)), null, 16),
|
|
39
|
+
g(j) ? (f(), i("div", d(u({ key: 0 }, g(N))), [m(t.$slots, "loading", {}, () => [s(g(e), { class: "size-full" })])], 16)) : r("", !0),
|
|
40
|
+
g(T) ? (f(), i("div", d(u({ key: 1 }, g(A))), [m(t.$slots, "empty", {}, () => [o(h(g(F)), 1)])], 16)) : r("", !0)
|
|
41
|
+
], 16),
|
|
42
|
+
m(t.$slots, "default"),
|
|
43
|
+
a("table", d(l(g(M))), [a("thead", null, [a("tr", null, [a("th", v, h(g(w).categoryLabel), 1), (f(!0), i(n, null, p(g(w).series, (e) => (f(), i("th", {
|
|
44
|
+
scope: "col",
|
|
45
|
+
key: e.id
|
|
46
|
+
}, h(e.name), 1))), 128))])]), a("tbody", null, [(f(!0), i(n, null, p(g(w).rows, (e) => (f(), i("tr", { key: e.category }, [a("th", y, h(e.category), 1), (f(!0), i(n, null, p(e.values, (e, t) => (f(), i("td", { key: g(w).series[t]?.id ?? t }, h(e), 1))), 128))]))), 128))])], 16),
|
|
47
|
+
a("div", d(l(g(k))), h(g(P)), 17)
|
|
48
|
+
], 16));
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
//#endregion
|
|
52
|
+
export { b as default };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { HTMLAttributes, Slot } from 'vue';
|
|
2
|
+
import { ChartColor, ChartSize } from '@bridge-ui/core/Tokens';
|
|
3
|
+
import { MergeHtmlProps, MergeProps } from '@bridge-ui/core/Utils';
|
|
4
|
+
export interface ChartSizeOverrides {}
|
|
5
|
+
export interface ChartColorOverrides {}
|
|
6
|
+
/**
|
|
7
|
+
* Series color: a Chart color token key (`"primary"`, `"info"`, …) or any
|
|
8
|
+
* CSS color (`"#6366f1"`, `"rgb(0 0 0)"`, `"var(--brand)"`).
|
|
9
|
+
*/
|
|
10
|
+
export type ChartSeriesColor = (string & {}) | MergeProps<ChartColor, ChartColorOverrides>;
|
|
11
|
+
export interface ChartClasses {
|
|
12
|
+
/**
|
|
13
|
+
* Classes merged onto the empty-state overlay.
|
|
14
|
+
*/
|
|
15
|
+
empty?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Classes merged onto the loading overlay.
|
|
18
|
+
*/
|
|
19
|
+
loading?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Classes merged onto the plot area.
|
|
22
|
+
*/
|
|
23
|
+
plot?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Classes merged onto the root.
|
|
26
|
+
*/
|
|
27
|
+
root?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Classes merged onto the data table (screen-reader only).
|
|
30
|
+
*/
|
|
31
|
+
table?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ChartCustomProps {
|
|
34
|
+
/**
|
|
35
|
+
* Props forwarded to the plot area (`role="img"`, keyboard target).
|
|
36
|
+
*
|
|
37
|
+
* @default undefined
|
|
38
|
+
*/
|
|
39
|
+
plot?: HTMLAttributes;
|
|
40
|
+
/**
|
|
41
|
+
* Props forwarded to the root element.
|
|
42
|
+
*
|
|
43
|
+
* @default undefined
|
|
44
|
+
*/
|
|
45
|
+
root?: HTMLAttributes;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Chart root. Compose with `ChartSeries`, `ChartAxis`, `ChartLegend`,
|
|
49
|
+
* and `ChartTooltip`. The plot is drawn by ECharts.
|
|
50
|
+
*/
|
|
51
|
+
export interface ChartOwnProps {
|
|
52
|
+
/**
|
|
53
|
+
* Enables engine transitions. Always off under `prefers-reduced-motion`.
|
|
54
|
+
*
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
animation?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Category labels for the x axis. Each series has one value per category.
|
|
60
|
+
*/
|
|
61
|
+
categories: string[];
|
|
62
|
+
/**
|
|
63
|
+
* Classes for chart parts.
|
|
64
|
+
*
|
|
65
|
+
* @default undefined
|
|
66
|
+
*/
|
|
67
|
+
classes?: ChartClasses;
|
|
68
|
+
/**
|
|
69
|
+
* Extra props for the root and plot parts.
|
|
70
|
+
*
|
|
71
|
+
* @default undefined
|
|
72
|
+
*/
|
|
73
|
+
customProps?: ChartCustomProps;
|
|
74
|
+
/**
|
|
75
|
+
* Plot height (`280` → `280px`, or any CSS length).
|
|
76
|
+
*
|
|
77
|
+
* @default 280
|
|
78
|
+
*/
|
|
79
|
+
height?: number | string;
|
|
80
|
+
/**
|
|
81
|
+
* Shows the loading overlay over the plot.
|
|
82
|
+
*
|
|
83
|
+
* @default false
|
|
84
|
+
*/
|
|
85
|
+
loading?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Series colors used in order when a `ChartSeries` omits `color`.
|
|
88
|
+
*
|
|
89
|
+
* @default ["primary", "info", "success", "warning", "error", "secondary", "dark"]
|
|
90
|
+
*/
|
|
91
|
+
palette?: ChartSeriesColor[];
|
|
92
|
+
/**
|
|
93
|
+
* Density of axis labels, legend, and tooltip.
|
|
94
|
+
*
|
|
95
|
+
* @default "md"
|
|
96
|
+
*/
|
|
97
|
+
size?: MergeProps<ChartSize, ChartSizeOverrides>;
|
|
98
|
+
/**
|
|
99
|
+
* Accessible description of the plot. Defaults to a generated summary
|
|
100
|
+
* (series names and category range).
|
|
101
|
+
*
|
|
102
|
+
* @default undefined
|
|
103
|
+
*/
|
|
104
|
+
summary?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Root width (`480` → `480px`, or any CSS length).
|
|
107
|
+
*
|
|
108
|
+
* @default "100%"
|
|
109
|
+
*/
|
|
110
|
+
width?: number | string;
|
|
111
|
+
}
|
|
112
|
+
export interface ChartSlots {
|
|
113
|
+
/**
|
|
114
|
+
* Chart parts (`ChartSeries`, `ChartAxis`, `ChartLegend`, `ChartTooltip`).
|
|
115
|
+
*/
|
|
116
|
+
default?: Slot<undefined>;
|
|
117
|
+
/**
|
|
118
|
+
* Content shown when there is nothing to plot.
|
|
119
|
+
*/
|
|
120
|
+
empty?: Slot<undefined>;
|
|
121
|
+
/**
|
|
122
|
+
* Content shown while `loading` is true.
|
|
123
|
+
*/
|
|
124
|
+
loading?: Slot<undefined>;
|
|
125
|
+
}
|
|
126
|
+
export type ChartProps = MergeHtmlProps<ChartOwnProps, HTMLAttributes>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { ComputedRef, InjectionKey } from 'vue';
|
|
2
|
+
import { ChartAnchor, ChartAxisPosition, ChartRenderAxis, ChartSeriesEntry, ChartTooltipItem } from '@bridge-ui/core/Domain';
|
|
3
|
+
/**
|
|
4
|
+
* Registered series with its resolved color and legend visibility.
|
|
5
|
+
*/
|
|
6
|
+
export type ChartResolvedSeries = ChartSeriesEntry & {
|
|
7
|
+
/**
|
|
8
|
+
* Whether the series is hidden from the legend toggle.
|
|
9
|
+
*/
|
|
10
|
+
hidden: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Computed CSS color (empty until the first layout pass).
|
|
13
|
+
*/
|
|
14
|
+
resolvedColor: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Shared chart state for `ChartSeries` / `ChartAxis` / `ChartLegend` /
|
|
18
|
+
* `ChartTooltip` descendants.
|
|
19
|
+
*/
|
|
20
|
+
export type ChartContextValue = {
|
|
21
|
+
/**
|
|
22
|
+
* Active category index (pointer or keyboard). `null` when idle.
|
|
23
|
+
*/
|
|
24
|
+
activeIndex: null | number;
|
|
25
|
+
/**
|
|
26
|
+
* Category labels.
|
|
27
|
+
*/
|
|
28
|
+
categories: string[];
|
|
29
|
+
/**
|
|
30
|
+
* Root size (px) used to keep the tooltip inside the chart.
|
|
31
|
+
*/
|
|
32
|
+
getBounds: () => {
|
|
33
|
+
height: number;
|
|
34
|
+
width: number;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Tooltip anchor for a category, relative to the chart root.
|
|
38
|
+
*/
|
|
39
|
+
getTooltipAnchor: (index: number) => null | ChartAnchor;
|
|
40
|
+
/**
|
|
41
|
+
* Emphasizes one series in the plot. `null` clears it.
|
|
42
|
+
*/
|
|
43
|
+
highlightSeries: (id: null | string) => void;
|
|
44
|
+
/**
|
|
45
|
+
* Stable id prefix for chart parts.
|
|
46
|
+
*/
|
|
47
|
+
id: string;
|
|
48
|
+
/**
|
|
49
|
+
* Locale used to format values.
|
|
50
|
+
*/
|
|
51
|
+
locale: string;
|
|
52
|
+
/**
|
|
53
|
+
* Removes axis options registered by `ChartAxis`.
|
|
54
|
+
*/
|
|
55
|
+
removeAxis: (position: ChartAxisPosition) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Removes a series by id.
|
|
58
|
+
*/
|
|
59
|
+
removeSeries: (id: string) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Registered series in mount order, with colors and visibility.
|
|
62
|
+
*/
|
|
63
|
+
series: ChartResolvedSeries[];
|
|
64
|
+
/**
|
|
65
|
+
* Sets axis options (no-op when unchanged).
|
|
66
|
+
*/
|
|
67
|
+
setAxis: (position: ChartAxisPosition, options: Partial<ChartRenderAxis>) => void;
|
|
68
|
+
/**
|
|
69
|
+
* Shows / hides a series by id.
|
|
70
|
+
*/
|
|
71
|
+
toggleSeries: (id: string) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Merged size token classes for legend and tooltip.
|
|
74
|
+
*/
|
|
75
|
+
tokenClasses: {
|
|
76
|
+
legend?: string;
|
|
77
|
+
legendItem?: string;
|
|
78
|
+
swatch?: string;
|
|
79
|
+
tooltip?: string;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Tooltip rows for `activeIndex` (visible series, non-null values).
|
|
83
|
+
*/
|
|
84
|
+
tooltipItems: ChartTooltipItem[];
|
|
85
|
+
/**
|
|
86
|
+
* Adds or replaces a series by `id`, keeping its position (no-op when unchanged).
|
|
87
|
+
*/
|
|
88
|
+
upsertSeries: (entry: ChartSeriesEntry) => void;
|
|
89
|
+
};
|
|
90
|
+
export declare const CHART_INJECTION_KEY: InjectionKey<ComputedRef<ChartContextValue>>;
|
|
91
|
+
/**
|
|
92
|
+
* Injects the nearest `Chart` context. Throws when used outside `Chart`.
|
|
93
|
+
*/
|
|
94
|
+
export declare function useChartContext(): ComputedRef<ChartContextValue>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { inject as e } from "vue";
|
|
2
|
+
//#region src/Components/Chart/chartInjectionKey.ts
|
|
3
|
+
var t = Symbol("bridge-chart");
|
|
4
|
+
function n() {
|
|
5
|
+
let n = e(t, null);
|
|
6
|
+
if (!n) throw Error("Chart components must be used within a Chart");
|
|
7
|
+
return n;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { t as CHART_INJECTION_KEY, n as useChartContext };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { HTMLAttributes, Ref } from 'vue';
|
|
2
|
+
import { LibDefaultsShape, MergeLibDefaults } from '@bridge-ui/core/Utils';
|
|
3
|
+
import { ChartOwnProps } from '../chart.types';
|
|
4
|
+
import { ChartContextValue } from '../chartInjectionKey';
|
|
5
|
+
type ChartRegistryProps = Pick<ChartOwnProps, "size" | "height" | "classes" | "palette" | "animation" | "customProps">;
|
|
6
|
+
type ChartLibDefaults = LibDefaultsShape<ChartOwnProps, "size" | "height" | "animation">;
|
|
7
|
+
type ChartMerged = MergeLibDefaults<ChartRegistryProps, ChartLibDefaults>;
|
|
8
|
+
type ChartElementRef = Readonly<Ref<null | HTMLDivElement>>;
|
|
9
|
+
export declare function useChart(props: ChartOwnProps, libDefaults: ChartLibDefaults, elements: {
|
|
10
|
+
hostRef: ChartElementRef;
|
|
11
|
+
plotRef: ChartElementRef;
|
|
12
|
+
rootRef: ChartElementRef;
|
|
13
|
+
}): {
|
|
14
|
+
table: import('vue').ComputedRef<{
|
|
15
|
+
categoryLabel: string;
|
|
16
|
+
series: {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
}[];
|
|
20
|
+
rows: {
|
|
21
|
+
category: string;
|
|
22
|
+
values: string[];
|
|
23
|
+
}[];
|
|
24
|
+
}>;
|
|
25
|
+
merged: import('vue').ComputedRef<ChartMerged>;
|
|
26
|
+
isEmpty: import('vue').ComputedRef<boolean>;
|
|
27
|
+
summary: import('vue').ComputedRef<string>;
|
|
28
|
+
hostBind: import('vue').ComputedRef<HTMLAttributes>;
|
|
29
|
+
plotBind: import('vue').ComputedRef<HTMLAttributes>;
|
|
30
|
+
rootBind: import('vue').ComputedRef<HTMLAttributes>;
|
|
31
|
+
liveBind: import('vue').ComputedRef<HTMLAttributes>;
|
|
32
|
+
emptyBind: import('vue').ComputedRef<HTMLAttributes>;
|
|
33
|
+
isLoading: import('vue').ComputedRef<boolean>;
|
|
34
|
+
tableBind: import('vue').ComputedRef<HTMLAttributes>;
|
|
35
|
+
loadingBind: import('vue').ComputedRef<HTMLAttributes>;
|
|
36
|
+
announcement: import('vue').ComputedRef<string>;
|
|
37
|
+
contextValue: import('vue').ComputedRef<ChartContextValue>;
|
|
38
|
+
emptyMessage: import('vue').ComputedRef<string>;
|
|
39
|
+
};
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { useResolveMessage as e } from "../../../Adapters/I18n/useI18nAdapter.js";
|
|
2
|
+
import { mergePartBind as t, useBridgeUIComponent as n, useBridgeUIMergedRegistryClasses as r } from "../../../Utils/index.js";
|
|
3
|
+
import { CHART_INJECTION_KEY as i } from "../chartInjectionKey.js";
|
|
4
|
+
import { mountEchartsChart as ee } from "../echartsChart.js";
|
|
5
|
+
import { computed as a, onBeforeUnmount as te, onMounted as ne, provide as re, ref as o, shallowRef as s, useAttrs as ie, useId as ae, watch as c } from "vue";
|
|
6
|
+
import { get as l, isEqual as u, isNil as d, omit as f } from "es-toolkit/compat";
|
|
7
|
+
import { DEFAULT_CHART_HEIGHT as oe, DEFAULT_CHART_PALETTE as se, DEFAULT_CHART_X_AXIS as ce, DEFAULT_CHART_Y_AXIS as le, formatChartAnnouncement as ue, formatChartValue as de, getAdjacentChartIndex as fe, getChartSummaryParams as pe, getChartTableRows as me, getChartTooltipItems as he, isChartEmpty as p, isSameChartAxisOptions as ge, isSameChartSeriesEntry as _e, resolveChartSeriesColor as ve, toChartCssSize as m } from "@bridge-ui/core/Domain";
|
|
8
|
+
import { chartColorProps as ye, chartSizeProps as be, chartThemeProps as xe } from "@bridge-ui/core/Tokens";
|
|
9
|
+
import { cn as h, mergeBridgeUILayeredClasses as g, splitComponentProps as Se } from "@bridge-ui/core/Utils";
|
|
10
|
+
import { observeColorScheme as Ce, prefersReducedMotion as we, readChartTheme as Te, readCssColor as _ } from "@bridge-ui/core/Runtime";
|
|
11
|
+
//#region src/Components/Chart/composables/useChart.ts
|
|
12
|
+
var Ee = [
|
|
13
|
+
"size",
|
|
14
|
+
"width",
|
|
15
|
+
"height",
|
|
16
|
+
"classes",
|
|
17
|
+
"loading",
|
|
18
|
+
"palette",
|
|
19
|
+
"summary",
|
|
20
|
+
"animation",
|
|
21
|
+
"categories",
|
|
22
|
+
"customProps"
|
|
23
|
+
];
|
|
24
|
+
function v(v, De, Oe) {
|
|
25
|
+
let ke = ae(), Ae = ie(), y = `bridge-chart${ke}`, b = e(), { hostRef: x, plotRef: S, rootRef: C } = Oe, w = s(null), T = null, E = null, D = o(0), O = o([]), k = o([]), A = s({
|
|
26
|
+
width: 0,
|
|
27
|
+
height: 0
|
|
28
|
+
}), j = s({}), M = s(null), N = s({
|
|
29
|
+
index: null,
|
|
30
|
+
source: "pointer"
|
|
31
|
+
}), P = s({}), F = a(() => Se({
|
|
32
|
+
bridgeKeys: Ee,
|
|
33
|
+
props: {
|
|
34
|
+
...Ae,
|
|
35
|
+
...v
|
|
36
|
+
}
|
|
37
|
+
})), I = a(() => F.value.componentProps), { bridge: L, merged: R, entry: z } = n({
|
|
38
|
+
libDefaults: De,
|
|
39
|
+
componentName: "Chart",
|
|
40
|
+
props: () => f(I.value, ["palette", "categories"])
|
|
41
|
+
}), B = r({
|
|
42
|
+
entry: z,
|
|
43
|
+
props: () => I.value
|
|
44
|
+
}), V = a(() => L?.global.value.locale ?? "en-US"), H = a(() => R.value.customProps), je = a(() => JSON.stringify(I.value.categories ?? [])), U = a(() => JSON.parse(je.value)), Me = a(() => JSON.stringify(I.value.palette ?? R.value.palette ?? se)), Ne = a(() => JSON.parse(Me.value)), Pe = a(() => g(be, z.value?.tokens?.size)), Fe = a(() => g(ye, z.value?.tokens?.color)), W = a(() => g(xe, z.value?.tokens?.theme)), G = a(() => l(Pe.value, R.value.size)), K = a(() => k.value.map((e, t) => {
|
|
45
|
+
let n = ve({
|
|
46
|
+
index: t,
|
|
47
|
+
color: e.color,
|
|
48
|
+
palette: Ne.value
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
color: n,
|
|
52
|
+
id: e.id,
|
|
53
|
+
className: l(Fe.value, [n, "series"])
|
|
54
|
+
};
|
|
55
|
+
})), q;
|
|
56
|
+
ne(() => {
|
|
57
|
+
q = Ce(() => {
|
|
58
|
+
D.value += 1;
|
|
59
|
+
});
|
|
60
|
+
}), c([
|
|
61
|
+
C,
|
|
62
|
+
D,
|
|
63
|
+
W,
|
|
64
|
+
K,
|
|
65
|
+
() => G.value?.root,
|
|
66
|
+
() => L?.global.value.theme
|
|
67
|
+
], () => {
|
|
68
|
+
let e = C.value;
|
|
69
|
+
if (d(e)) return;
|
|
70
|
+
let t = {};
|
|
71
|
+
K.value.forEach((n) => {
|
|
72
|
+
t[n.id] = d(n.className) ? _(e, { color: n.color }) : _(e, { className: n.className });
|
|
73
|
+
});
|
|
74
|
+
let n = Te(e, {
|
|
75
|
+
axis: W.value.axis ?? "",
|
|
76
|
+
grid: W.value.grid ?? "",
|
|
77
|
+
text: W.value.text ?? ""
|
|
78
|
+
});
|
|
79
|
+
u(j.value, t) || (j.value = t), u(M.value, n) || (M.value = n);
|
|
80
|
+
}, {
|
|
81
|
+
flush: "post",
|
|
82
|
+
immediate: !0
|
|
83
|
+
}), c(S, (e, t, n) => {
|
|
84
|
+
if (d(e)) return;
|
|
85
|
+
let r = () => {
|
|
86
|
+
let t = e.clientWidth, n = e.clientHeight;
|
|
87
|
+
(A.value.width !== t || A.value.height !== n) && (A.value = {
|
|
88
|
+
width: t,
|
|
89
|
+
height: n
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
if (r(), typeof ResizeObserver > "u") return;
|
|
93
|
+
let i = new ResizeObserver(r);
|
|
94
|
+
i.observe(e), n(() => {
|
|
95
|
+
i.disconnect();
|
|
96
|
+
});
|
|
97
|
+
}, {
|
|
98
|
+
flush: "post",
|
|
99
|
+
immediate: !0
|
|
100
|
+
});
|
|
101
|
+
function Ie(e) {
|
|
102
|
+
let t = k.value.findIndex((t) => t.id === e.id);
|
|
103
|
+
if (t === -1) {
|
|
104
|
+
k.value = [...k.value, e];
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (_e(k.value[t], e)) return;
|
|
108
|
+
let n = [...k.value];
|
|
109
|
+
n[t] = e, k.value = n;
|
|
110
|
+
}
|
|
111
|
+
function Le(e) {
|
|
112
|
+
k.value = k.value.filter((t) => t.id !== e);
|
|
113
|
+
}
|
|
114
|
+
function Re(e, t) {
|
|
115
|
+
let n = P.value[e];
|
|
116
|
+
(d(n) || !ge(n, t)) && (P.value = {
|
|
117
|
+
...P.value,
|
|
118
|
+
[e]: t
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function ze(e) {
|
|
122
|
+
P.value = f(P.value, [e]);
|
|
123
|
+
}
|
|
124
|
+
function Be(e) {
|
|
125
|
+
O.value = O.value.includes(e) ? O.value.filter((t) => t !== e) : [...O.value, e];
|
|
126
|
+
}
|
|
127
|
+
function Ve(e) {
|
|
128
|
+
w.value?.highlightSeries(e);
|
|
129
|
+
}
|
|
130
|
+
function He(e) {
|
|
131
|
+
N.value.index !== e && (N.value = {
|
|
132
|
+
index: e,
|
|
133
|
+
source: "pointer"
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
let J = a(() => k.value.map((e) => ({
|
|
137
|
+
...e,
|
|
138
|
+
resolvedColor: j.value[e.id] ?? "",
|
|
139
|
+
hidden: O.value.includes(e.id)
|
|
140
|
+
}))), Y = a(() => J.value.filter((e) => !e.hidden)), Ue = a(() => ({
|
|
141
|
+
...ce,
|
|
142
|
+
...P.value.x
|
|
143
|
+
})), We = a(() => ({
|
|
144
|
+
...le,
|
|
145
|
+
...P.value.y
|
|
146
|
+
})), Ge = a(() => R.value.animation !== !1 && !we()), X = a(() => d(M.value) ? null : {
|
|
147
|
+
theme: M.value,
|
|
148
|
+
xAxis: Ue.value,
|
|
149
|
+
yAxis: We.value,
|
|
150
|
+
animation: Ge.value,
|
|
151
|
+
width: A.value.width,
|
|
152
|
+
categories: U.value,
|
|
153
|
+
height: A.value.height,
|
|
154
|
+
series: Y.value.map((e) => ({
|
|
155
|
+
id: e.id,
|
|
156
|
+
name: e.name,
|
|
157
|
+
type: e.type,
|
|
158
|
+
data: e.data,
|
|
159
|
+
curve: e.curve,
|
|
160
|
+
color: e.resolvedColor
|
|
161
|
+
}))
|
|
162
|
+
}), Z = a(() => !d(x.value) && !d(X.value));
|
|
163
|
+
function Q() {
|
|
164
|
+
w.value?.destroy(), w.value = null, E = null, T?.remove(), T = null;
|
|
165
|
+
}
|
|
166
|
+
c([x, Z], () => {
|
|
167
|
+
Q();
|
|
168
|
+
let e = x.value, t = X.value;
|
|
169
|
+
if (!Z.value || d(e) || d(t)) return;
|
|
170
|
+
let n = document.createElement("div");
|
|
171
|
+
n.className = "absolute inset-0", e.appendChild(n), T = n, w.value = ee({
|
|
172
|
+
...t,
|
|
173
|
+
element: n,
|
|
174
|
+
onActiveIndexChange: He
|
|
175
|
+
}), E = t;
|
|
176
|
+
}, {
|
|
177
|
+
flush: "post",
|
|
178
|
+
immediate: !0
|
|
179
|
+
}), c(X, (e) => {
|
|
180
|
+
let t = w.value;
|
|
181
|
+
d(t) || d(e) || E === e || (E = e, t.update(e));
|
|
182
|
+
}, { flush: "post" }), c(N, (e) => {
|
|
183
|
+
e.source === "keyboard" && w.value?.setActiveIndex(e.index);
|
|
184
|
+
}, { flush: "post" }), te(() => {
|
|
185
|
+
q?.(), Q();
|
|
186
|
+
});
|
|
187
|
+
let $ = a(() => {
|
|
188
|
+
let e = N.value.index;
|
|
189
|
+
return d(e) ? [] : he({
|
|
190
|
+
index: e,
|
|
191
|
+
series: Y.value.map((e) => ({
|
|
192
|
+
...e,
|
|
193
|
+
color: e.resolvedColor
|
|
194
|
+
}))
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
function Ke(e) {
|
|
198
|
+
let t = w.value?.getCategoryAnchor(e), n = S.value;
|
|
199
|
+
return d(t) || d(n) ? null : {
|
|
200
|
+
y: t.y + n.offsetTop,
|
|
201
|
+
x: t.x + n.offsetLeft
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function qe() {
|
|
205
|
+
return {
|
|
206
|
+
width: C.value?.clientWidth ?? 0,
|
|
207
|
+
height: C.value?.clientHeight ?? 0
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
let Je = a(() => ({
|
|
211
|
+
setAxis: Re,
|
|
212
|
+
getBounds: qe,
|
|
213
|
+
removeAxis: ze,
|
|
214
|
+
id: y,
|
|
215
|
+
removeSeries: Le,
|
|
216
|
+
toggleSeries: Be,
|
|
217
|
+
upsertSeries: Ie,
|
|
218
|
+
highlightSeries: Ve,
|
|
219
|
+
getTooltipAnchor: Ke,
|
|
220
|
+
series: J.value,
|
|
221
|
+
locale: V.value,
|
|
222
|
+
categories: U.value,
|
|
223
|
+
activeIndex: N.value.index,
|
|
224
|
+
tooltipItems: $.value,
|
|
225
|
+
tokenClasses: {
|
|
226
|
+
legend: l(G.value, "legend"),
|
|
227
|
+
swatch: l(G.value, "swatch"),
|
|
228
|
+
tooltip: l(G.value, "tooltip"),
|
|
229
|
+
legendItem: l(G.value, "legendItem")
|
|
230
|
+
}
|
|
231
|
+
}));
|
|
232
|
+
re(i, Je);
|
|
233
|
+
let Ye = a(() => I.value.loading === !0), Xe = a(() => !Ye.value && p(k.value)), Ze = a(() => b("No data")), Qe = a(() => d(I.value.summary) ? p(k.value) ? Ze.value : b("Chart with {{count}} series ({{names}}) across {{categories}} categories, from {{first}} to {{last}}.", pe({
|
|
234
|
+
series: k.value,
|
|
235
|
+
categories: U.value
|
|
236
|
+
})) : I.value.summary), $e = a(() => {
|
|
237
|
+
let e = N.value.index;
|
|
238
|
+
return N.value.source !== "keyboard" || d(e) ? "" : ue({
|
|
239
|
+
locale: V.value,
|
|
240
|
+
items: $.value,
|
|
241
|
+
category: U.value[e] ?? ""
|
|
242
|
+
});
|
|
243
|
+
}), et = a(() => ({
|
|
244
|
+
categoryLabel: b("Category"),
|
|
245
|
+
series: k.value.map((e) => ({
|
|
246
|
+
id: e.id,
|
|
247
|
+
name: e.name
|
|
248
|
+
})),
|
|
249
|
+
rows: me({
|
|
250
|
+
series: k.value,
|
|
251
|
+
categories: U.value
|
|
252
|
+
}).map((e) => ({
|
|
253
|
+
category: e.category,
|
|
254
|
+
values: e.values.map((e) => d(e) ? "—" : de(e, V.value))
|
|
255
|
+
}))
|
|
256
|
+
}));
|
|
257
|
+
function tt(e) {
|
|
258
|
+
if (H.value?.plot?.onKeydown?.(e), e.defaultPrevented) return;
|
|
259
|
+
let t = fe({
|
|
260
|
+
key: e.key,
|
|
261
|
+
current: N.value.index,
|
|
262
|
+
count: U.value.length
|
|
263
|
+
});
|
|
264
|
+
t !== void 0 && (e.preventDefault(), N.value = {
|
|
265
|
+
index: t,
|
|
266
|
+
source: "keyboard"
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
function nt(e) {
|
|
270
|
+
H.value?.plot?.onBlur?.(e), N.value.source === "keyboard" && (N.value = {
|
|
271
|
+
index: null,
|
|
272
|
+
source: "keyboard"
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
let rt = a(() => t(f(H.value?.root, ["style"]), f(F.value.inheritedAttrs, ["style"]), {
|
|
276
|
+
role: "figure",
|
|
277
|
+
style: [
|
|
278
|
+
{ width: m(I.value.width, "100%") },
|
|
279
|
+
F.value.inheritedAttrs.style,
|
|
280
|
+
H.value?.root?.style
|
|
281
|
+
],
|
|
282
|
+
class: h({
|
|
283
|
+
"relative flex min-w-0 flex-col gap-3": !0,
|
|
284
|
+
[l(G.value, "root") ?? ""]: !0,
|
|
285
|
+
[l(B.value, "root") ?? ""]: !0
|
|
286
|
+
})
|
|
287
|
+
})), it = a(() => t(f(H.value?.plot, [
|
|
288
|
+
"style",
|
|
289
|
+
"onBlur",
|
|
290
|
+
"onKeydown"
|
|
291
|
+
]), void 0, {
|
|
292
|
+
role: "img",
|
|
293
|
+
tabindex: 0,
|
|
294
|
+
onBlur: nt,
|
|
295
|
+
onKeydown: tt,
|
|
296
|
+
"aria-label": Qe.value,
|
|
297
|
+
style: [{ height: m(R.value.height, `${oe}px`) }, H.value?.plot?.style],
|
|
298
|
+
class: h({
|
|
299
|
+
"relative w-full min-w-0 rounded-md outline-none": !0,
|
|
300
|
+
"focus-visible:ring-2 focus-visible:ring-primary-500/50": !0,
|
|
301
|
+
[l(B.value, "plot") ?? ""]: !0
|
|
302
|
+
})
|
|
303
|
+
})), at = a(() => ({
|
|
304
|
+
"aria-hidden": !0,
|
|
305
|
+
class: "absolute inset-0"
|
|
306
|
+
})), ot = a(() => ({ class: h({
|
|
307
|
+
"absolute inset-0 z-10 flex": !0,
|
|
308
|
+
[l(B.value, "loading") ?? ""]: !0
|
|
309
|
+
}) })), st = a(() => ({ class: h({
|
|
310
|
+
"absolute inset-0 z-10 flex items-center justify-center": !0,
|
|
311
|
+
"text-dark-500 dark:text-dark-400": !0,
|
|
312
|
+
[l(B.value, "empty") ?? ""]: !0
|
|
313
|
+
}) })), ct = a(() => ({
|
|
314
|
+
id: `${y}-table`,
|
|
315
|
+
class: h({
|
|
316
|
+
"sr-only": !0,
|
|
317
|
+
[l(B.value, "table") ?? ""]: !0
|
|
318
|
+
})
|
|
319
|
+
}));
|
|
320
|
+
return {
|
|
321
|
+
table: et,
|
|
322
|
+
merged: R,
|
|
323
|
+
isEmpty: Xe,
|
|
324
|
+
summary: Qe,
|
|
325
|
+
hostBind: at,
|
|
326
|
+
plotBind: it,
|
|
327
|
+
rootBind: rt,
|
|
328
|
+
liveBind: a(() => ({
|
|
329
|
+
role: "status",
|
|
330
|
+
class: "sr-only",
|
|
331
|
+
"aria-atomic": !0,
|
|
332
|
+
"aria-live": "polite"
|
|
333
|
+
})),
|
|
334
|
+
emptyBind: st,
|
|
335
|
+
isLoading: Ye,
|
|
336
|
+
tableBind: ct,
|
|
337
|
+
loadingBind: ot,
|
|
338
|
+
announcement: $e,
|
|
339
|
+
contextValue: Je,
|
|
340
|
+
emptyMessage: Ze
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
//#endregion
|
|
344
|
+
export { v as useChart };
|