@dashboard-designer/ui 0.1.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/README.md +32 -0
- package/dist/index.d.ts +195 -0
- package/dist/index.js +4946 -0
- package/dist/styles.css +2628 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @dashboard-designer/ui
|
|
2
|
+
|
|
3
|
+
Embeddable React dashboard designer and viewer.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @dashboard-designer/ui @dashboard-designer/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { DashboardDesigner, DashboardViewer } from '@dashboard-designer/ui';
|
|
15
|
+
import '@dashboard-designer/ui/styles.css';
|
|
16
|
+
|
|
17
|
+
<DashboardDesigner
|
|
18
|
+
apiBaseUrl="https://your-api.example.com"
|
|
19
|
+
auth={{ mode: 'anonymous' }} // or { mode: 'token', token }
|
|
20
|
+
locale="en"
|
|
21
|
+
onSave={(dashboard) => console.log(dashboard)}
|
|
22
|
+
/>
|
|
23
|
+
|
|
24
|
+
<DashboardViewer
|
|
25
|
+
dashboard={dashboardJson}
|
|
26
|
+
apiBaseUrl="https://your-api.example.com"
|
|
27
|
+
auth={{ mode: 'anonymous' }}
|
|
28
|
+
locale="es"
|
|
29
|
+
/>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Requires the `@dashboard-designer/server` API for query execution and connection secrets.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import react__default from 'react';
|
|
3
|
+
import { Dashboard, AuthConfig, User, EmbedTokenRequest, EmbedTokenResponse, ConnectionConfig, ExecuteQueryRequest, QueryResult, DashboardAclEntry, DashboardPermission, DashboardVersionMeta, DashboardVersion, Widget, FilterDef, WidgetType } from '@dashboard-designer/core';
|
|
4
|
+
export { AuthConfig, ConnectionConfig, Dashboard, FilterDef, Widget } from '@dashboard-designer/core';
|
|
5
|
+
import * as i18next from 'i18next';
|
|
6
|
+
export { default as i18n } from 'i18next';
|
|
7
|
+
import * as lucide_react from 'lucide-react';
|
|
8
|
+
import { LucideIcon } from 'lucide-react';
|
|
9
|
+
|
|
10
|
+
interface DashboardDesignerProps {
|
|
11
|
+
dashboard?: Dashboard;
|
|
12
|
+
apiBaseUrl: string;
|
|
13
|
+
auth: AuthConfig;
|
|
14
|
+
locale?: string;
|
|
15
|
+
onChange?: (dashboard: Dashboard) => void;
|
|
16
|
+
onSave?: (dashboard: Dashboard) => void;
|
|
17
|
+
readOnly?: boolean;
|
|
18
|
+
/** When set, shows Edit / Done in the dashboard toolbar. */
|
|
19
|
+
onToggleEdit?: () => void;
|
|
20
|
+
}
|
|
21
|
+
declare function DashboardDesigner({ dashboard: initial, apiBaseUrl, auth, locale, onChange, onSave, readOnly, onToggleEdit, }: DashboardDesignerProps): react__default.JSX.Element;
|
|
22
|
+
|
|
23
|
+
interface DashboardViewerProps {
|
|
24
|
+
dashboard: Dashboard;
|
|
25
|
+
apiBaseUrl: string;
|
|
26
|
+
auth: AuthConfig;
|
|
27
|
+
locale?: string;
|
|
28
|
+
}
|
|
29
|
+
/** Read-only dashboard renderer for embeds / published views. */
|
|
30
|
+
declare function DashboardViewer({ dashboard, apiBaseUrl, auth, locale }: DashboardViewerProps): react__default.JSX.Element;
|
|
31
|
+
|
|
32
|
+
declare class DashboardApiClient {
|
|
33
|
+
apiBaseUrl: string;
|
|
34
|
+
auth: AuthConfig;
|
|
35
|
+
constructor(apiBaseUrl: string, auth: AuthConfig);
|
|
36
|
+
private headers;
|
|
37
|
+
private req;
|
|
38
|
+
login(email: string, password: string): Promise<{
|
|
39
|
+
token: string;
|
|
40
|
+
user: User;
|
|
41
|
+
}>;
|
|
42
|
+
me(): Promise<{
|
|
43
|
+
user: User;
|
|
44
|
+
}>;
|
|
45
|
+
createEmbedToken(body: EmbedTokenRequest): Promise<EmbedTokenResponse>;
|
|
46
|
+
listConnections(): Promise<{
|
|
47
|
+
connections: ConnectionConfig[];
|
|
48
|
+
}>;
|
|
49
|
+
saveConnection(connection: ConnectionConfig): Promise<{
|
|
50
|
+
connection: ConnectionConfig;
|
|
51
|
+
}>;
|
|
52
|
+
testConnection(id: string): Promise<{
|
|
53
|
+
ok: boolean;
|
|
54
|
+
}>;
|
|
55
|
+
listTables(connectionId: string): Promise<{
|
|
56
|
+
tables: string[];
|
|
57
|
+
}>;
|
|
58
|
+
listColumns(connectionId: string, table: string): Promise<{
|
|
59
|
+
columns: Array<{
|
|
60
|
+
name: string;
|
|
61
|
+
type: string;
|
|
62
|
+
}>;
|
|
63
|
+
}>;
|
|
64
|
+
executeQuery(body: ExecuteQueryRequest): Promise<{
|
|
65
|
+
result: QueryResult;
|
|
66
|
+
sql: string;
|
|
67
|
+
}>;
|
|
68
|
+
listDashboards(): Promise<{
|
|
69
|
+
dashboards: Array<{
|
|
70
|
+
id: string;
|
|
71
|
+
title: string;
|
|
72
|
+
updatedAt: string;
|
|
73
|
+
allowAnonymous: boolean;
|
|
74
|
+
}>;
|
|
75
|
+
}>;
|
|
76
|
+
getDashboard(id: string): Promise<{
|
|
77
|
+
dashboard: Dashboard;
|
|
78
|
+
}>;
|
|
79
|
+
saveDashboard(dashboard: Dashboard, allowAnonymous?: boolean, message?: string): Promise<{
|
|
80
|
+
dashboard: Dashboard;
|
|
81
|
+
} | {
|
|
82
|
+
dashboard: Dashboard;
|
|
83
|
+
}>;
|
|
84
|
+
getDashboardAcl(dashboardId: string): Promise<{
|
|
85
|
+
acl: DashboardAclEntry[];
|
|
86
|
+
ownerId?: string;
|
|
87
|
+
canManage: boolean;
|
|
88
|
+
}>;
|
|
89
|
+
setDashboardAcl(dashboardId: string, entries: Array<{
|
|
90
|
+
userId: string;
|
|
91
|
+
permission: DashboardPermission;
|
|
92
|
+
}>): Promise<{
|
|
93
|
+
acl: DashboardAclEntry[];
|
|
94
|
+
}>;
|
|
95
|
+
listDashboardVersions(dashboardId: string): Promise<{
|
|
96
|
+
versions: DashboardVersionMeta[];
|
|
97
|
+
}>;
|
|
98
|
+
getDashboardVersion(dashboardId: string, versionId: string): Promise<{
|
|
99
|
+
version: DashboardVersion;
|
|
100
|
+
}>;
|
|
101
|
+
restoreDashboardVersion(dashboardId: string, versionId: string): Promise<{
|
|
102
|
+
dashboard: Dashboard;
|
|
103
|
+
version: DashboardVersionMeta;
|
|
104
|
+
}>;
|
|
105
|
+
listUsers(): Promise<{
|
|
106
|
+
users: User[];
|
|
107
|
+
}>;
|
|
108
|
+
createUser(input: {
|
|
109
|
+
email: string;
|
|
110
|
+
name: string;
|
|
111
|
+
password: string;
|
|
112
|
+
role: string;
|
|
113
|
+
locale?: string;
|
|
114
|
+
}): Promise<{
|
|
115
|
+
user: User;
|
|
116
|
+
}>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
interface ChartRendererProps {
|
|
120
|
+
widget: Widget;
|
|
121
|
+
data?: QueryResult;
|
|
122
|
+
locale?: string;
|
|
123
|
+
currency?: string;
|
|
124
|
+
timeZone?: string;
|
|
125
|
+
/** Dashboard / theme chart palette (falls back to defaults). */
|
|
126
|
+
chartColors?: string[];
|
|
127
|
+
loading?: boolean;
|
|
128
|
+
onDrillDown?: (payload: Record<string, unknown>) => void;
|
|
129
|
+
/** Current list-box selection (empty = All). */
|
|
130
|
+
listboxSelection?: Array<string | number>;
|
|
131
|
+
onListboxSelectionChange?: (values: Array<string | number>) => void;
|
|
132
|
+
}
|
|
133
|
+
declare function ChartRenderer({ widget, data, locale, currency, loading, onDrillDown, listboxSelection, onListboxSelectionChange, chartColors, }: ChartRendererProps): react__default.JSX.Element;
|
|
134
|
+
|
|
135
|
+
interface FilterBarProps {
|
|
136
|
+
filters: FilterDef[];
|
|
137
|
+
onChange: (filters: FilterDef[]) => void;
|
|
138
|
+
title?: string;
|
|
139
|
+
hint?: string;
|
|
140
|
+
editable?: boolean;
|
|
141
|
+
/** When set, field is chosen from this column list instead of free text. */
|
|
142
|
+
fieldOptions?: string[];
|
|
143
|
+
fieldPlaceholder?: string;
|
|
144
|
+
fieldEmptyLabel?: string;
|
|
145
|
+
fieldDisabled?: boolean;
|
|
146
|
+
/** Hide the built-in header (e.g. when embedded in a popover). */
|
|
147
|
+
hideHeader?: boolean;
|
|
148
|
+
/** Applied to newly added filters (where = row-level, having = aggregated). */
|
|
149
|
+
defaultClause?: 'where' | 'having';
|
|
150
|
+
}
|
|
151
|
+
declare function FilterBar({ filters, onChange, title, hint, editable, fieldOptions, fieldPlaceholder, fieldEmptyLabel, fieldDisabled, hideHeader, defaultClause, }: FilterBarProps): react__default.JSX.Element;
|
|
152
|
+
|
|
153
|
+
declare function ensureI18n(locale?: string): i18next.i18n;
|
|
154
|
+
|
|
155
|
+
interface SearchableSelectProps {
|
|
156
|
+
id?: string;
|
|
157
|
+
options: string[];
|
|
158
|
+
value: string[];
|
|
159
|
+
onChange: (value: string[]) => void;
|
|
160
|
+
placeholder?: string;
|
|
161
|
+
multiple?: boolean;
|
|
162
|
+
disabled?: boolean;
|
|
163
|
+
emptyLabel?: string;
|
|
164
|
+
}
|
|
165
|
+
declare function SearchableSelect({ id, options, value, onChange, placeholder, multiple, disabled, emptyLabel, }: SearchableSelectProps): react__default.JSX.Element;
|
|
166
|
+
|
|
167
|
+
interface FieldHelpProps {
|
|
168
|
+
/** Help text shown in the tooltip. */
|
|
169
|
+
text: string;
|
|
170
|
+
/** Optional accessible name; defaults to "Help". */
|
|
171
|
+
label?: string;
|
|
172
|
+
}
|
|
173
|
+
/** Compact help icon with a portal tooltip that stays fully on-screen. */
|
|
174
|
+
declare function FieldHelp({ text, label }: FieldHelpProps): react__default.JSX.Element | null;
|
|
175
|
+
interface FieldLabelProps {
|
|
176
|
+
htmlFor?: string;
|
|
177
|
+
children: react__default.ReactNode;
|
|
178
|
+
/** Help / usage description for this field. */
|
|
179
|
+
help?: string;
|
|
180
|
+
className?: string;
|
|
181
|
+
}
|
|
182
|
+
/** Field label with an optional inline help icon. */
|
|
183
|
+
declare function FieldLabel({ htmlFor, children, help, className }: FieldLabelProps): react__default.JSX.Element;
|
|
184
|
+
|
|
185
|
+
declare const ICON_SIZE = 16;
|
|
186
|
+
declare const chartTypeIcon: Record<WidgetType, LucideIcon>;
|
|
187
|
+
declare const navIcon: {
|
|
188
|
+
readonly dashboards: react.ForwardRefExoticComponent<Omit<lucide_react.LucideProps, "ref"> & react.RefAttributes<SVGSVGElement>>;
|
|
189
|
+
readonly designer: react.ForwardRefExoticComponent<Omit<lucide_react.LucideProps, "ref"> & react.RefAttributes<SVGSVGElement>>;
|
|
190
|
+
readonly viewer: react.ForwardRefExoticComponent<Omit<lucide_react.LucideProps, "ref"> & react.RefAttributes<SVGSVGElement>>;
|
|
191
|
+
readonly connections: react.ForwardRefExoticComponent<Omit<lucide_react.LucideProps, "ref"> & react.RefAttributes<SVGSVGElement>>;
|
|
192
|
+
readonly users: react.ForwardRefExoticComponent<Omit<lucide_react.LucideProps, "ref"> & react.RefAttributes<SVGSVGElement>>;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export { ChartRenderer, DashboardApiClient, DashboardDesigner, type DashboardDesignerProps, DashboardViewer, type DashboardViewerProps, FieldHelp, type FieldHelpProps, FieldLabel, type FieldLabelProps, FilterBar, ICON_SIZE, SearchableSelect, type SearchableSelectProps, chartTypeIcon, ensureI18n, navIcon };
|