@typlog/ui 0.14.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/charts.css ADDED
@@ -0,0 +1,161 @@
1
+ @layer components {
2
+ .ui-ChartRoot {
3
+ --vis-font-family: var(--font-family-sans);
4
+ --vis-axis-tick-color: var(--gray-a7);
5
+ --vis-axis-domain-color: var(--gray-a7);
6
+ --vis-axis-grid-color: var(--gray-a3);
7
+ --vis-axis-label-color: var(--gray-11);
8
+ --vis-axis-tick-label-color: var(--gray-11);
9
+ --vis-tooltip-padding: var(--space-3);
10
+ --vis-tooltip-background-color: var(--color-panel-solid);
11
+ --vis-tooltip-border-color: transparent;
12
+ --vis-tooltip-text-color: var(--gray-12);
13
+ --vis-tooltip-box-shadow: var(--shadow-3);
14
+ --vis-tooltip-shadow-color: var(--gray-a5);
15
+ --vis-tooltip-backdrop-filter: blur(8px);
16
+ --vis-color-main: var(--chart-1);
17
+ --vis-color0: var(--chart-1);
18
+ --vis-color1: var(--chart-2);
19
+ --vis-color2: var(--chart-3);
20
+ --vis-color3: var(--chart-4);
21
+ --vis-color4: var(--chart-5);
22
+ --vis-color5: var(--chart-6);
23
+
24
+ display: block;
25
+ box-sizing: border-box;
26
+ width: 100%;
27
+ min-width: 0;
28
+ color: var(--gray-12);
29
+ }
30
+
31
+ .ui-ChartLegend {
32
+ display: flex;
33
+ flex-wrap: wrap;
34
+ gap: var(--space-3) var(--space-5);
35
+ color: var(--gray-11);
36
+ font-size: var(--font-size-2);
37
+ line-height: var(--line-height-2);
38
+ }
39
+
40
+ .ui-ChartLegend:where(.r-orientation-vertical) {
41
+ flex-direction: column;
42
+ gap: var(--space-2);
43
+ }
44
+
45
+ .ui-ChartLegend:where(.r-orientation-horizontal.r-align-center) {
46
+ justify-content: center;
47
+ }
48
+
49
+ .ui-ChartLegend:where(.r-orientation-horizontal.r-align-end) {
50
+ justify-content: flex-end;
51
+ }
52
+
53
+ .ui-ChartLegend:where(.r-orientation-vertical.r-align-center) {
54
+ align-items: center;
55
+ }
56
+
57
+ .ui-ChartLegend:where(.r-orientation-vertical.r-align-end) {
58
+ align-items: flex-end;
59
+ }
60
+
61
+ .ui-ChartLegendItem {
62
+ display: inline-flex;
63
+ align-items: center;
64
+ min-width: 0;
65
+ gap: var(--space-2);
66
+ }
67
+
68
+ .ui-ChartLegendMarker,
69
+ .ui-ChartTooltipIndicator {
70
+ flex: 0 0 auto;
71
+ width: 0.625rem;
72
+ height: 0.625rem;
73
+ border-radius: var(--radius-full);
74
+ }
75
+
76
+ .ui-ChartLegendLabel {
77
+ overflow: hidden;
78
+ text-overflow: ellipsis;
79
+ white-space: nowrap;
80
+ }
81
+
82
+ .ui-ChartTooltip {
83
+ max-width: min(20rem, calc(100vw - var(--space-4)));
84
+ font-size: var(--font-size-2);
85
+ line-height: var(--line-height-2);
86
+ }
87
+
88
+ .ui-ChartTooltipContent {
89
+ display: grid;
90
+ min-width: 8rem;
91
+ gap: var(--space-2);
92
+ }
93
+
94
+ .ui-ChartTooltipLabel {
95
+ color: var(--gray-12);
96
+ font-weight: var(--font-weight-medium);
97
+ }
98
+
99
+ .ui-ChartTooltipItems {
100
+ display: grid;
101
+ gap: var(--space-2);
102
+ }
103
+
104
+ .ui-ChartTooltipItem {
105
+ display: flex;
106
+ align-items: center;
107
+ gap: var(--space-2);
108
+ }
109
+
110
+ .ui-ChartTooltipIcon {
111
+ width: 0.75rem;
112
+ height: 0.75rem;
113
+ color: var(--gray-11);
114
+ }
115
+
116
+ .ui-ChartTooltipIndicator {
117
+ width: 0.625rem;
118
+ height: 0.625rem;
119
+ border: 1px solid var(--chart-tooltip-color);
120
+ border-radius: var(--radius-full);
121
+ background: var(--chart-tooltip-color);
122
+ }
123
+
124
+ .ui-ChartTooltipIndicator:where(.r-indicator-line) {
125
+ align-self: stretch;
126
+ width: 0.1875rem;
127
+ height: auto;
128
+ border-radius: var(--radius-1);
129
+ }
130
+
131
+ .ui-ChartTooltipIndicator:where(.r-indicator-dashed) {
132
+ align-self: stretch;
133
+ width: 0;
134
+ height: auto;
135
+ border-width: 0 0 0 2px;
136
+ border-style: dashed;
137
+ border-radius: 0;
138
+ background: transparent;
139
+ }
140
+
141
+ .ui-ChartTooltipSeries {
142
+ flex: 1 1 auto;
143
+ min-width: 0;
144
+ }
145
+
146
+ .ui-ChartTooltipSeriesLabel {
147
+ overflow: hidden;
148
+ color: var(--gray-11);
149
+ text-overflow: ellipsis;
150
+ white-space: nowrap;
151
+ }
152
+
153
+ .ui-ChartTooltipValue {
154
+ flex: none;
155
+ margin-left: auto;
156
+ color: var(--gray-12);
157
+ font-family: var(--font-family-mono);
158
+ font-weight: var(--font-weight-medium);
159
+ font-variant-numeric: tabular-nums;
160
+ }
161
+ }
package/charts.d.ts ADDED
@@ -0,0 +1,233 @@
1
+ import { AsTag } from 'reka-ui';
2
+ import { Component } from 'vue';
3
+ import { ComponentOptionsMixin } from 'vue';
4
+ import { ComponentProvideOptions } from 'vue';
5
+ import { CrosshairConfigInterface } from '@unovis/ts';
6
+ import { DefineComponent } from 'vue';
7
+ import { Donut } from '@unovis/ts';
8
+ import { GroupedBar } from '@unovis/ts';
9
+ import { IconifyIconBuildResult } from '@iconify/vue';
10
+ import { PrimitiveProps } from 'reka-ui';
11
+ import { PublicProps } from 'vue';
12
+ import { StackedBar } from '@unovis/ts';
13
+ import { TooltipConfigInterface } from '@unovis/ts';
14
+ import { VNode } from 'vue';
15
+
16
+ declare const __VLS_export: __VLS_WithSlots< DefineComponent<ChartRootProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ChartRootProps> & Readonly<{}>, {
17
+ as: AsTag | Component;
18
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>, {
19
+ default?: (props: {
20
+ mounted: boolean;
21
+ }) => any;
22
+ }>;
23
+
24
+ declare const __VLS_export_2: <Datum = unknown>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
25
+ props: PublicProps & __VLS_PrettifyLocal<ChartCrosshairProps<Datum>> & (typeof globalThis extends {
26
+ __VLS_PROPS_FALLBACK: infer P;
27
+ } ? P : {});
28
+ expose: (exposed: {}) => void;
29
+ attrs: any;
30
+ slots: {};
31
+ emit: {};
32
+ }>) => VNode & {
33
+ __ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
34
+ };
35
+
36
+ declare const __VLS_export_3: DefineComponent<ChartTooltipProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ChartTooltipProps> & Readonly<{}>, {
37
+ contentComponent: Component;
38
+ contentProps: Record<string, unknown>;
39
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
40
+
41
+ declare const __VLS_export_4: __VLS_WithSlots_2< DefineComponent<{}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>, {
42
+ default: (props: ChartAreaGradientSlotProps) => any;
43
+ }>;
44
+
45
+ declare const __VLS_export_5: __VLS_WithSlots_3< DefineComponent<ChartTooltipContentProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ChartTooltipContentProps> & Readonly<{}>, {
46
+ indicator: ChartTooltipIndicator;
47
+ config: ChartConfig;
48
+ payload: Record<string, unknown>;
49
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>, {
50
+ default?: (props: {
51
+ items: {
52
+ index: number;
53
+ icon: IconifyIconBuildResult | undefined;
54
+ key: string;
55
+ value: unknown;
56
+ series: ChartSeries;
57
+ }[];
58
+ label: string | undefined;
59
+ }) => any;
60
+ }>;
61
+
62
+ declare const __VLS_export_6: __VLS_WithSlots_4< DefineComponent<ChartLegendProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ChartLegendProps> & Readonly<{}>, {
63
+ as: AsTag | Component;
64
+ orientation: "horizontal" | "vertical";
65
+ align: "start" | "center" | "end";
66
+ ariaLabel: string;
67
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>, {
68
+ item?: (props: {
69
+ key: string;
70
+ series: ChartSeries;
71
+ index: number;
72
+ }) => any;
73
+ } & {
74
+ marker?: (props: {
75
+ key: string;
76
+ series: ChartSeries;
77
+ index: number;
78
+ }) => any;
79
+ }>;
80
+
81
+ declare type __VLS_PrettifyLocal<T> = (T extends any ? {
82
+ [K in keyof T]: T[K];
83
+ } : {
84
+ [K in keyof T as K]: T[K];
85
+ }) & {};
86
+
87
+ declare type __VLS_WithSlots<T, S> = T & {
88
+ new (): {
89
+ $slots: S;
90
+ };
91
+ };
92
+
93
+ declare type __VLS_WithSlots_2<T, S> = T & {
94
+ new (): {
95
+ $slots: S;
96
+ };
97
+ };
98
+
99
+ declare type __VLS_WithSlots_3<T, S> = T & {
100
+ new (): {
101
+ $slots: S;
102
+ };
103
+ };
104
+
105
+ declare type __VLS_WithSlots_4<T, S> = T & {
106
+ new (): {
107
+ $slots: S;
108
+ };
109
+ };
110
+
111
+ export declare const ChartAreaGradient: typeof __VLS_export_4;
112
+
113
+ export declare type ChartAreaGradientColor = (_data: unknown, index: number) => string;
114
+
115
+ export declare interface ChartAreaGradientSlotProps {
116
+ /** SVG definitions to pass to the Unovis container's `svgDefs` prop. */
117
+ svgDefs: string;
118
+ /** Unovis color accessor that resolves each area series to its gradient. */
119
+ color: ChartAreaGradientColor;
120
+ }
121
+
122
+ /** Configuration keyed by the series identifier used by a chart primitive. */
123
+ export declare type ChartConfig = Record<string, ChartSeries>;
124
+
125
+ export declare const ChartCrosshair: typeof __VLS_export_2;
126
+
127
+ /** A Typlog-themed adapter for Unovis' crosshair and its tooltip template. */
128
+ export declare interface ChartCrosshairProps<Datum = unknown> extends /* @vue-ignore */ Omit<CrosshairConfigInterface<Datum>, 'template'> {
129
+ /** Vue component rendered as the crosshair tooltip content. @default ChartTooltipContent */
130
+ contentComponent?: Component;
131
+ /** Props passed to `contentComponent` in addition to payload, config, and x. */
132
+ contentProps?: Record<string, unknown>;
133
+ }
134
+
135
+ export declare const ChartLegend: typeof __VLS_export_6;
136
+
137
+ export declare interface ChartLegendItemSlotProps {
138
+ key: string;
139
+ series: ChartSeries;
140
+ index: number;
141
+ }
142
+
143
+ export declare interface ChartLegendProps extends PrimitiveProps {
144
+ /** Layout direction for legend entries. @default "horizontal" */
145
+ orientation?: 'horizontal' | 'vertical';
146
+ /** Alignment of legend entries within the legend. @default "start" */
147
+ align?: 'start' | 'center' | 'end';
148
+ /** Accessible name for the legend list. @default "Chart legend" */
149
+ ariaLabel?: string;
150
+ }
151
+
152
+ export declare const ChartRoot: typeof __VLS_export;
153
+
154
+ export declare interface ChartRootProps extends PrimitiveProps {
155
+ /** Series metadata used by ChartLegend and ChartTooltip. */
156
+ config: ChartConfig;
157
+ }
158
+
159
+ /** A chart field and its presentation metadata. */
160
+ export declare interface ChartSeries {
161
+ /** Human-readable series name. */
162
+ label: string;
163
+ /** Identifies an x-axis/domain field. Entries default to `series`. */
164
+ role?: ChartSeriesRole;
165
+ /** Optional CSS color. Defaults to the chart palette. */
166
+ color?: string;
167
+ /** Optional Iconify icon name rendered before the series label. */
168
+ icon?: string;
169
+ }
170
+
171
+ /** Determines whether a configured field is the x-axis domain or a data series. */
172
+ export declare type ChartSeriesRole = 'x' | 'series';
173
+
174
+ export declare const ChartTooltip: typeof __VLS_export_3;
175
+
176
+ export declare const ChartTooltipContent: typeof __VLS_export_5;
177
+
178
+ export declare interface ChartTooltipContentProps {
179
+ /** Values keyed by the matching ChartConfig series key. */
180
+ payload?: Record<string, unknown>;
181
+ /** Series metadata. Passed automatically by createChartTooltipTemplate. */
182
+ config?: ChartConfig;
183
+ /** Domain value displayed as the tooltip label. */
184
+ x?: string | number | Date;
185
+ /** Indicator displayed beside each series. @default "dot" */
186
+ indicator?: ChartTooltipIndicator;
187
+ /** Hides the tooltip label. */
188
+ hideLabel?: boolean;
189
+ /** Hides series indicators without removing icons. */
190
+ hideIndicator?: boolean;
191
+ /** Uses a payload or config key instead of the role-x value or crosshair x. */
192
+ labelKey?: string;
193
+ /** Formats the final tooltip label. Priority: hideLabel, labelKey, role-x field, crosshair x. */
194
+ labelFormatter?: (value: string | number | Date) => string;
195
+ /** Formats a series value. */
196
+ valueFormatter?: (value: unknown, key: string) => string;
197
+ }
198
+
199
+ export declare type ChartTooltipIndicator = 'dot' | 'line' | 'dashed' | 'none';
200
+
201
+ export declare type ChartTooltipPrimitive = typeof Donut | typeof GroupedBar | typeof StackedBar;
202
+
203
+ /** A Typlog-themed adapter for Unovis' interactive tooltip. */
204
+ export declare interface ChartTooltipProps extends /* @vue-ignore */ TooltipConfigInterface {
205
+ /** Unovis primitives that should automatically trigger the themed tooltip. */
206
+ targets?: ChartTooltipTarget[];
207
+ /** Vue component rendered as the tooltip content. @default ChartTooltipContent */
208
+ contentComponent?: Component;
209
+ /** Props passed to `contentComponent` in addition to payload, config, and x. */
210
+ contentProps?: Record<string, unknown>;
211
+ }
212
+
213
+ export declare type ChartTooltipTarget = ChartTooltipPrimitive | ChartTooltipTargetDescriptor;
214
+
215
+ /** A supported Unovis primitive that can provide automatic tooltip triggers. */
216
+ export declare interface ChartTooltipTargetDescriptor {
217
+ primitive: ChartTooltipPrimitive;
218
+ /** Maps the primitive's event datum to values keyed by ChartConfig. */
219
+ payload?: (data: any, index: number) => Record<string, unknown>;
220
+ }
221
+
222
+ /** Creates a synchronous Unovis template callback from a Vue tooltip component. */
223
+ export declare function createChartTooltipTemplate(config: ChartConfig, component: Component, props?: Record<string, unknown>): (rawPayload: unknown, x?: string | number | Date) => string;
224
+
225
+ export { }
226
+
227
+
228
+ declare global {
229
+ interface Window {
230
+ turnstile?: TurnstileApi;
231
+ cfTurnstileOnLoad?: () => void;
232
+ }
233
+ }