@juicemantics/veloiq-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.
@@ -0,0 +1,474 @@
1
+ import * as React$1 from 'react';
2
+ import React__default, { PropsWithChildren } from 'react';
3
+ import { ListProps, ShowProps } from '@refinedev/antd';
4
+ import * as _refinedev_core from '@refinedev/core';
5
+ import { AuthProvider, AccessControlProvider } from '@refinedev/core';
6
+ import * as axios from 'axios';
7
+ import * as react_jsx_runtime from 'react/jsx-runtime';
8
+ import * as _tanstack_query_core from '@tanstack/query-core';
9
+ import * as antd from 'antd';
10
+
11
+ interface LayoutWrapperProps {
12
+ children?: React__default.ReactNode;
13
+ /** Logo element or image URL shown in header and sider. */
14
+ logo?: React__default.ReactNode | string;
15
+ /** App name shown next to the logo when the sider is expanded. */
16
+ appTitle?: string;
17
+ /** Optional extra items added to the user dropdown (before logout). */
18
+ extraUserMenuItems?: Array<{
19
+ key: string;
20
+ label: React__default.ReactNode;
21
+ icon?: React__default.ReactNode;
22
+ onClick?: () => void;
23
+ }>;
24
+ }
25
+ declare const LayoutWrapper: React__default.FC<LayoutWrapperProps>;
26
+
27
+ declare const MultiPaneLayout: React__default.FC<{
28
+ children: React__default.ReactNode;
29
+ }>;
30
+
31
+ declare const StandardShow: React__default.FC<ShowProps>;
32
+ declare const StandardList: React__default.FC<ListProps>;
33
+
34
+ interface HierarchyViewProps {
35
+ resource: string;
36
+ recordId: number;
37
+ fallback?: React__default.ReactNode;
38
+ }
39
+ declare const HierarchyView: React__default.FC<HierarchyViewProps>;
40
+
41
+ declare const GlobalSearch: React__default.FC;
42
+
43
+ declare const CustomSider: React__default.FC<{
44
+ collapsed?: boolean;
45
+ logo?: React__default.ReactNode | string;
46
+ appTitle?: string;
47
+ }>;
48
+
49
+ declare const HorizontalMenu: React__default.FC;
50
+
51
+ type ExecutableHtmlProps = {
52
+ html?: string;
53
+ htmlChunks?: string[];
54
+ resetToken?: string;
55
+ style?: React__default.CSSProperties;
56
+ mode?: "inline" | "iframe";
57
+ minHeight?: number;
58
+ title?: string;
59
+ inheritTypography?: boolean;
60
+ inheritTabRowBackground?: boolean;
61
+ fontSizeOverride?: string;
62
+ };
63
+ declare const ExecutableHtml: React__default.FC<ExecutableHtmlProps>;
64
+
65
+ /**
66
+ * Renders Plotly HTML inline (no iframe) by:
67
+ * 1. Stripping Plotly CDN <script> tags (Plotly.js is loaded globally once)
68
+ * 2. Making card button IDs unique per instance to avoid DOM ID conflicts
69
+ * 3. Injecting the remaining HTML via dangerouslySetInnerHTML
70
+ * 4. Executing any inline <script> tags after render
71
+ */
72
+ declare const InlinePlotlyHtml: React__default.FC<{
73
+ html: string;
74
+ style?: React__default.CSSProperties;
75
+ }>;
76
+
77
+ interface VisibilityCondition {
78
+ field: string;
79
+ operator: "eq" | "ne" | "in" | "not_in" | "truthy" | "falsy" | "gt" | "lt" | "gte" | "lte" | "ilike";
80
+ value?: any;
81
+ }
82
+ interface FieldDef {
83
+ key: string;
84
+ label: string;
85
+ type: "string" | "number" | "boolean" | "date" | "datetime" | "time" | "image_url";
86
+ isPk?: boolean;
87
+ required?: boolean;
88
+ reference?: string;
89
+ referencePath?: string;
90
+ optionLabel?: string;
91
+ options?: {
92
+ label: string;
93
+ value: any;
94
+ }[];
95
+ optionsUrl?: string;
96
+ valueColors?: Record<string, string>;
97
+ default?: any;
98
+ defaultValue?: any;
99
+ default_value?: any;
100
+ description?: string;
101
+ constraints?: string[];
102
+ formula?: string;
103
+ readOnly?: boolean;
104
+ unique?: boolean;
105
+ nullable?: boolean;
106
+ /** Roles allowed to read this field (absent = all roles). Emitted by veloiq_field(read_roles=…). */
107
+ readRoles?: string[];
108
+ /** Roles allowed to write this field (absent = all roles). Emitted by veloiq_field(write_roles=…). */
109
+ writeRoles?: string[];
110
+ }
111
+ interface MillerLeafConfig {
112
+ relationPath: string;
113
+ targetKey: string;
114
+ otherKey: string;
115
+ resource: string;
116
+ resourcePath?: string;
117
+ }
118
+ interface RelationDef {
119
+ resource: string;
120
+ resourcePath?: string;
121
+ targetKey: string;
122
+ label: string;
123
+ otherKey?: string;
124
+ otherResource?: string;
125
+ otherResourcePath?: string;
126
+ relationName?: string;
127
+ polymorphicType?: string;
128
+ isRecursive?: boolean;
129
+ minItems?: number;
130
+ maxItems?: number;
131
+ showViewType?: "table" | "editable-table" | "editable-list" | "list" | "csv" | "gallery" | "calendar" | "primary" | "totals-details" | "tree" | "tree-details";
132
+ editViewType?: "table" | "editable-table" | "editable-list" | "list" | "csv" | "gallery" | "calendar" | "primary" | "totals-details" | "tree" | "tree-details";
133
+ showViewTypeFromCsv?: boolean;
134
+ editViewTypeFromCsv?: boolean;
135
+ showCustomPageName?: string;
136
+ editCustomPageName?: string;
137
+ showTab?: string;
138
+ editTab?: string;
139
+ description?: string;
140
+ millerLeafResource?: string;
141
+ millerLeafResourcePath?: string;
142
+ millerLeafRelationPath?: string;
143
+ millerLeafTargetKey?: string;
144
+ millerLeafOtherKey?: string;
145
+ millerLeafConfigs?: MillerLeafConfig[];
146
+ }
147
+ interface ModelDef {
148
+ name: string;
149
+ label: string;
150
+ module?: string;
151
+ fields: FieldDef[];
152
+ relations?: RelationDef[];
153
+ hideInMenu?: boolean;
154
+ resource?: string;
155
+ description?: string;
156
+ pkField?: string;
157
+ listViewType?: "table" | "gallery" | "calendar" | "totals-details";
158
+ }
159
+ type PrimaryShowRendererProps = {
160
+ model: ModelDef;
161
+ id: string | number;
162
+ allModels: ModelDef[];
163
+ viewName?: string;
164
+ };
165
+ declare const PrimaryShowContext: React__default.Context<React__default.ComponentType<PrimaryShowRendererProps> | null>;
166
+ type RelationViewType = "table" | "editable-table" | "editable-list" | "list" | "csv" | "gallery" | "calendar" | "primary" | "totals-details" | "tree" | "tree-details";
167
+ interface BulkActionDef {
168
+ key: string;
169
+ label: string;
170
+ icon?: React__default.ReactNode;
171
+ /** Called once per selected record during bulk execution. */
172
+ onExecuteOne: (record: any) => Promise<void>;
173
+ }
174
+ interface ViewConfigRow {
175
+ view_type: string;
176
+ subject_name: string;
177
+ relation_name: string;
178
+ object_name: string;
179
+ form_type: string;
180
+ section: string;
181
+ section_id?: string | null;
182
+ section_grid_row?: number | null;
183
+ section_grid_col?: number | null;
184
+ tab_name?: string | null;
185
+ vid?: string;
186
+ show_vid?: string;
187
+ edit_vid?: string;
188
+ showVid?: string;
189
+ editVid?: string;
190
+ limit?: number | null;
191
+ row?: number | null;
192
+ column?: number | null;
193
+ show_label?: boolean;
194
+ reload?: boolean;
195
+ html_format?: string;
196
+ attribute_or_relation_type: "attribute" | "relation" | "nlsentence";
197
+ nl_sentence_eid?: number | null;
198
+ nl_sentence_title?: string | null;
199
+ name: string;
200
+ visibility_condition?: VisibilityCondition | null;
201
+ read_only_in_edit?: boolean;
202
+ }
203
+
204
+ declare const useMetadataModal: (model: ModelDef, allModels?: ModelDef[]) => {
205
+ metadataButton: react_jsx_runtime.JSX.Element;
206
+ metadataModal: react_jsx_runtime.JSX.Element;
207
+ };
208
+
209
+ declare const useShowEditableForm: (resource: string, id?: string | number) => {
210
+ formProps: antd.FormProps<{}>;
211
+ saveButtonProps: antd.ButtonProps & {
212
+ onClick: () => void;
213
+ };
214
+ queryResult: _tanstack_query_core.QueryObserverResult<_refinedev_core.GetOneResponse<_refinedev_core.BaseRecord>, _refinedev_core.HttpError>;
215
+ record: _refinedev_core.BaseRecord | undefined;
216
+ recordId: any;
217
+ };
218
+
219
+ declare const buildShowTabFormOptions: (formProps: any, model: ModelDef | undefined, allModels?: ModelDef[]) => {
220
+ formProps: any;
221
+ effectiveFields: FieldDef[];
222
+ };
223
+
224
+ declare const ShowFooterButtons: React__default.FC<{
225
+ model: ModelDef;
226
+ allModels?: ModelDef[];
227
+ recordId: any;
228
+ saveButtonProps: any;
229
+ }>;
230
+
231
+ declare const ModelHeading: React__default.FC<{
232
+ model: Pick<ModelDef, "name" | "label" | "resource"> & {
233
+ module?: string;
234
+ };
235
+ title: React__default.ReactNode;
236
+ actionLabel?: string;
237
+ }>;
238
+
239
+ declare const useShowActionsPreferences: (model: ModelDef, allModels?: ModelDef[], record?: any, saveButtonProps?: any) => {
240
+ actionsState: {
241
+ showActions: boolean;
242
+ showCreate: boolean;
243
+ };
244
+ headerButtons: ({ defaultButtons }: {
245
+ defaultButtons: React__default.ReactNode;
246
+ }) => react_jsx_runtime.JSX.Element;
247
+ };
248
+
249
+ declare const ReferenceField: React__default.FC<{
250
+ id: string | number;
251
+ resource: string;
252
+ onLabel?: (label: string) => void;
253
+ }>;
254
+
255
+ declare const DynamicShow: React__default.FC<{
256
+ model: ModelDef;
257
+ allModels?: ModelDef[];
258
+ idOverride?: string;
259
+ embedded?: boolean;
260
+ }>;
261
+
262
+ interface JourneyCallbacks$1 {
263
+ onSave: (record: any) => void;
264
+ onCancel: () => void;
265
+ }
266
+ declare const DynamicCreate: React__default.FC<{
267
+ model: ModelDef;
268
+ allModels?: ModelDef[];
269
+ journeyCallbacks?: JourneyCallbacks$1;
270
+ injectedValues?: Record<string, any>;
271
+ }>;
272
+
273
+ interface JourneyCallbacks {
274
+ onSave: (record: any) => void;
275
+ onCancel: () => void;
276
+ }
277
+ declare const DynamicEdit: React__default.FC<{
278
+ model: ModelDef;
279
+ allModels?: ModelDef[];
280
+ topContent?: React__default.ReactNode;
281
+ extraHeaderButtons?: React__default.ReactNode;
282
+ journeyCallbacks?: JourneyCallbacks;
283
+ idOverride?: string;
284
+ }>;
285
+
286
+ declare const useStandardShowTabs: (model: ModelDef | undefined, record: any, allModels: ModelDef[], actionsState?: {
287
+ showActions: boolean;
288
+ showCreate: boolean;
289
+ }, editForm?: {
290
+ formProps?: any;
291
+ effectiveFields?: FieldDef[];
292
+ }, overrideConfigRows?: ViewConfigRow[]) => {
293
+ key: string;
294
+ label: React__default.ReactNode;
295
+ children: React__default.ReactNode;
296
+ }[];
297
+
298
+ declare const renderRelationBlock: ({ rel, relationModel, relatedModel, record, mode, parentResource, allModels, showLabel, showActions, showCreate, relationViewTypeDefaults, labelStyle, valueStyle, fieldLayoutStyle, }: {
299
+ rel: RelationDef;
300
+ relationModel: ModelDef;
301
+ relatedModel?: ModelDef;
302
+ record: any;
303
+ mode: "show" | "edit";
304
+ parentResource: string;
305
+ allModels?: ModelDef[];
306
+ showLabel?: boolean;
307
+ showActions?: boolean;
308
+ showCreate?: boolean;
309
+ relationViewTypeDefaults?: {
310
+ show: RelationViewType;
311
+ edit: RelationViewType;
312
+ };
313
+ labelStyle?: React__default.CSSProperties;
314
+ valueStyle?: React__default.CSSProperties;
315
+ fieldLayoutStyle?: React__default.CSSProperties;
316
+ }) => react_jsx_runtime.JSX.Element;
317
+
318
+ declare const DynamicList: React__default.FC<{
319
+ model: ModelDef;
320
+ allModels?: ModelDef[];
321
+ filter?: any;
322
+ relationConfig?: RelationDef;
323
+ isEmbedded?: boolean;
324
+ showActions?: boolean;
325
+ showCreate?: boolean;
326
+ layoutPreferenceType?: "ShowLayout" | "EditLayout";
327
+ listViewType?: "table" | "gallery" | "calendar" | "totals-details";
328
+ rowSelection?: any;
329
+ extraHeaderButtons?: React__default.ReactNode;
330
+ bulkActions?: BulkActionDef[];
331
+ }>;
332
+
333
+ /**
334
+ * Refine AuthProvider implementation for VeloIQ.
335
+ *
336
+ * Uses JWT Bearer tokens stored in localStorage. The backend issues
337
+ * tokens via ``POST /auth/login`` and validates them on every
338
+ * request through its auth middleware.
339
+ */
340
+
341
+ declare const authProvider: AuthProvider;
342
+
343
+ /**
344
+ * Refine AccessControlProvider for VeloIQ.
345
+ *
346
+ * Three-layer permission model (mirrors the backend):
347
+ * Layer 1 — Role global permissions (fetched from /auth/roles on login,
348
+ * stored as jm_role_permissions in localStorage).
349
+ * Layer 2 — Model-level exceptions (fetched from /auth/resource-permissions
350
+ * on login, stored as jm_resource_permissions).
351
+ * Layer 3 — Field-level exceptions (readRoles/writeRoles emitted by the
352
+ * schema generator into FieldDef; handled by CanAccess wrappers).
353
+ *
354
+ * Falls back to built-in Admin/Manager/Viewer defaults when the cached
355
+ * permissions are absent (e.g. on first load before a login).
356
+ */
357
+
358
+ declare const accessControlProvider: AccessControlProvider;
359
+
360
+ /**
361
+ * Axios HTTP client with automatic Bearer token injection.
362
+ *
363
+ * Passed to the ``@refinedev/simple-rest`` data provider so that every
364
+ * API request includes the JWT from localStorage.
365
+ */
366
+ declare const httpClient: axios.AxiosInstance;
367
+
368
+ declare const API_URL = "/api";
369
+
370
+ declare const AllModelsProvider: React__default.FC<{
371
+ models: ModelDef[];
372
+ children: React__default.ReactNode;
373
+ }>;
374
+ declare const useAllModels: () => ModelDef[];
375
+
376
+ declare const ColorModeContext: React$1.Context<{
377
+ mode: "light" | "dark";
378
+ setMode: (mode: "light" | "dark") => void;
379
+ }>;
380
+
381
+ declare const ColorModeContextProvider: React.FC<PropsWithChildren>;
382
+
383
+ interface PaneNavigationValue {
384
+ isInMultiPane: boolean;
385
+ paneIndex: number;
386
+ openDetail: (resource: string, id: string | number) => void;
387
+ }
388
+ declare const PaneNavigationContext: React$1.Context<PaneNavigationValue | null>;
389
+ declare const usePaneNavigation: () => PaneNavigationValue | null;
390
+
391
+ interface ResourceContextValue {
392
+ allResources: any[];
393
+ allSystemModels: any[];
394
+ }
395
+ declare const ResourceContext: React$1.Context<ResourceContextValue>;
396
+
397
+ interface LoginPageProps {
398
+ /** App title shown on the login card. Defaults to "VeloIQ". */
399
+ appTitle?: string;
400
+ /** Logo element or image URL shown above the title. */
401
+ logo?: React__default.ReactNode | string;
402
+ }
403
+ declare const LoginPage: React__default.FC<LoginPageProps>;
404
+
405
+ type ShortcutDef = {
406
+ key: string;
407
+ ctrl?: boolean;
408
+ shift?: boolean;
409
+ handler: () => void;
410
+ /** Set to false to allow default browser behavior. Defaults to true. */
411
+ preventDefault?: boolean;
412
+ /** If true, the shortcut will NOT fire when a modal is open. Defaults to true for Escape. */
413
+ skipWhenModalOpen?: boolean;
414
+ };
415
+ declare function useKeyboardShortcuts(shortcuts: ShortcutDef[]): void;
416
+
417
+ interface ResourceDef {
418
+ name: string;
419
+ list: string;
420
+ create: string;
421
+ edit: string;
422
+ show: string;
423
+ meta: {
424
+ canDelete: boolean;
425
+ label: string;
426
+ hide?: boolean;
427
+ parent?: string;
428
+ icon?: React.ReactNode;
429
+ };
430
+ }
431
+ /**
432
+ * Convert a module's ModelDef array into Refine resource definitions.
433
+ * Pass the module name to group models under a shared parent resource.
434
+ * Always prepends a parent group entry so Refine renders a clean module
435
+ * label (not the raw "module:X" string).
436
+ */
437
+ declare function generateResources(models: ModelDef[], moduleName: string, options?: {
438
+ icon?: React.ReactNode;
439
+ hideRelations?: boolean;
440
+ moduleLabel?: string;
441
+ }): ResourceDef[];
442
+
443
+ /**
444
+ * Drop-in replacement for ``fetch()`` that injects the JWT Bearer token
445
+ * from localStorage into the ``Authorization`` header.
446
+ *
447
+ * Existing custom_show / custom_edit pages that use raw ``fetch()`` can
448
+ * switch to this wrapper so requests are authenticated.
449
+ */
450
+ declare const authenticatedFetch: (url: string, options?: RequestInit) => Promise<Response>;
451
+
452
+ type ModelTone = {
453
+ solid: string;
454
+ soft: string;
455
+ softer: string;
456
+ text: string;
457
+ border: string;
458
+ shadow: string;
459
+ };
460
+ declare const setColorSchemas: (schemas: {
461
+ modulesColorSchema?: string;
462
+ modelsColorSchema?: string;
463
+ plainColorBaseHex?: string;
464
+ }) => void;
465
+ declare const normalizeToneKey: (value?: string) => string;
466
+ declare const getModelTone: (modelLike?: string | {
467
+ resource?: string;
468
+ name?: string;
469
+ label?: string;
470
+ }, darkMode?: boolean) => ModelTone;
471
+
472
+ declare const authSystemModels: ModelDef[];
473
+
474
+ export { API_URL, AllModelsProvider, type BulkActionDef, ColorModeContext, ColorModeContextProvider, CustomSider, DynamicCreate, DynamicEdit, DynamicList, DynamicShow, ExecutableHtml, type FieldDef, GlobalSearch, HierarchyView, HorizontalMenu, InlinePlotlyHtml, LayoutWrapper, type LayoutWrapperProps, LoginPage, type LoginPageProps, type MillerLeafConfig, type ModelDef, ModelHeading, MultiPaneLayout, PaneNavigationContext, PrimaryShowContext, type PrimaryShowRendererProps, ReferenceField, type RelationDef, ResourceContext, type ResourceDef, ShowFooterButtons, StandardList, StandardShow, type ViewConfigRow, accessControlProvider, authProvider, authSystemModels, authenticatedFetch, buildShowTabFormOptions, generateResources, getModelTone, httpClient, normalizeToneKey, renderRelationBlock, setColorSchemas, useAllModels, useKeyboardShortcuts, useMetadataModal, usePaneNavigation, useShowActionsPreferences, useShowEditableForm, useStandardShowTabs };