dhx-react-suite 1.0.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,551 @@
1
+ import { Context } from 'react';
2
+ import { default as default_2 } from 'react';
3
+ import { JSX as JSX_2 } from 'react/jsx-runtime';
4
+ import { RefObject } from 'react';
5
+
6
+ export declare function Button({ children, variant, size, icon, disabled, onClick, style, className, }: ButtonProps): JSX_2.Element;
7
+
8
+ export declare interface ButtonProps {
9
+ children?: React.ReactNode;
10
+ variant?: ButtonVariant;
11
+ size?: ButtonSize;
12
+ /** Leading icon element */
13
+ icon?: React.ReactNode;
14
+ disabled?: boolean;
15
+ onClick?: () => void;
16
+ style?: React.CSSProperties;
17
+ className?: string;
18
+ }
19
+
20
+ export declare type ButtonSize = "sm" | "md" | "lg";
21
+
22
+ export declare type ButtonVariant = "primary" | "secondary" | "ghost" | "danger";
23
+
24
+ export declare function Calendar({ value, range, timepicker, onChange, style }: CalendarProps): JSX_2.Element;
25
+
26
+ export declare interface CalendarProps {
27
+ value?: Date | [Date, Date] | null;
28
+ range?: boolean;
29
+ timepicker?: boolean;
30
+ onChange?: (value: Date | [Date, Date]) => void;
31
+ style?: React.CSSProperties;
32
+ }
33
+
34
+ export declare function Chart({ type, data, series, scales, legend, height, style }: ChartProps): JSX_2.Element;
35
+
36
+ declare interface ChartLegend {
37
+ halign?: "left" | "center" | "right";
38
+ valign?: "top" | "middle" | "bottom";
39
+ }
40
+
41
+ export declare interface ChartProps {
42
+ type?: ChartType;
43
+ data?: Record<string, unknown>[];
44
+ series?: ChartSeries[];
45
+ scales?: ChartScales;
46
+ legend?: ChartLegend;
47
+ height?: number | string;
48
+ style?: React.CSSProperties;
49
+ }
50
+
51
+ declare interface ChartScales {
52
+ bottom?: {
53
+ text?: string;
54
+ };
55
+ left?: {
56
+ min?: number;
57
+ max?: number;
58
+ };
59
+ }
60
+
61
+ export declare interface ChartSeries {
62
+ id: string;
63
+ value?: string;
64
+ label?: string;
65
+ color?: string;
66
+ fill?: string;
67
+ data?: Record<string, unknown>[];
68
+ xValue?: string;
69
+ yValue?: string;
70
+ }
71
+
72
+ export declare type ChartType = "bar" | "line" | "area" | "pie" | "donut" | "radar" | "scatter";
73
+
74
+ export declare function Colorpicker({ value, onChange, style }: ColorpickerProps): JSX_2.Element;
75
+
76
+ export declare interface ColorpickerProps {
77
+ value?: string;
78
+ onChange?: (hex: string) => void;
79
+ style?: React.CSSProperties;
80
+ }
81
+
82
+ export declare function Combobox({ data, value: valueProp, placeholder, multiselection, label, onChange, style }: ComboboxProps): JSX_2.Element;
83
+
84
+ export declare interface ComboboxItem {
85
+ id?: string;
86
+ value: string;
87
+ count?: number;
88
+ }
89
+
90
+ export declare interface ComboboxProps {
91
+ data?: ComboboxItem[];
92
+ value?: string | string[] | null;
93
+ placeholder?: string;
94
+ multiselection?: boolean;
95
+ label?: string;
96
+ onChange?: (value: string | string[]) => void;
97
+ style?: React.CSSProperties;
98
+ }
99
+
100
+ export declare function ContextMenu({ items, onSelect, children }: ContextMenuProps): JSX_2.Element;
101
+
102
+ export declare interface ContextMenuProps {
103
+ items?: MenuItem[];
104
+ onSelect?: (item: MenuItem) => void;
105
+ children: React.ReactNode;
106
+ }
107
+
108
+ declare function DataView_2({ data, template, itemsInRow, gap, multiselection, onSelect, style }: DataViewProps): JSX_2.Element;
109
+ export { DataView_2 as DataView }
110
+
111
+ export declare interface DataViewItem {
112
+ id?: string | number;
113
+ title?: string;
114
+ value?: string;
115
+ subtitle?: string;
116
+ img?: string;
117
+ [key: string]: unknown;
118
+ }
119
+
120
+ export declare interface DataViewProps {
121
+ data?: DataViewItem[];
122
+ template?: (item: DataViewItem) => string;
123
+ itemsInRow?: number;
124
+ gap?: number;
125
+ multiselection?: boolean;
126
+ onSelect?: (item: DataViewItem) => void;
127
+ style?: React.CSSProperties;
128
+ }
129
+
130
+ export declare function Form({ config, defaultValues, onSubmit, style }: FormProps): JSX_2.Element;
131
+
132
+ export declare interface FormConfig {
133
+ rows?: (FormField | FormField[])[];
134
+ padding?: string | number;
135
+ width?: string | number;
136
+ buttons?: boolean;
137
+ buttonAlign?: "flex-start" | "center" | "flex-end";
138
+ submitText?: string;
139
+ resetButton?: boolean;
140
+ resetText?: string;
141
+ }
142
+
143
+ export declare interface FormField {
144
+ type?: "input" | "textarea" | "select" | "checkbox" | "radio" | "slider" | "combo" | "datepicker" | "timepicker" | "fieldset" | "spacer";
145
+ name: string;
146
+ label?: string;
147
+ placeholder?: string;
148
+ required?: boolean;
149
+ disabled?: boolean;
150
+ value?: unknown;
151
+ inputType?: string;
152
+ icon?: React.ReactNode;
153
+ helpMessage?: string;
154
+ options?: FormFieldOption[];
155
+ data?: {
156
+ id?: string;
157
+ value: string;
158
+ }[];
159
+ multiselection?: boolean;
160
+ min?: number;
161
+ max?: number;
162
+ step?: number;
163
+ range?: boolean;
164
+ height?: number;
165
+ rows?: FormField[];
166
+ padding?: string | number;
167
+ width?: string | number;
168
+ }
169
+
170
+ declare interface FormFieldOption {
171
+ value: string;
172
+ label?: string;
173
+ }
174
+
175
+ export declare interface FormProps {
176
+ config?: FormConfig;
177
+ defaultValues?: Record<string, unknown>;
178
+ onSubmit?: (values: Record<string, unknown>) => void;
179
+ style?: React.CSSProperties;
180
+ }
181
+
182
+ export declare function Grid({ columns, data, height, rowHeight, sortable, resizable, selection, multiselect, onSelect, style }: GridProps): JSX_2.Element;
183
+
184
+ export declare interface GridColumn {
185
+ id: string;
186
+ header?: {
187
+ text: string;
188
+ }[] | string;
189
+ width?: number;
190
+ minWidth?: number;
191
+ sortable?: boolean;
192
+ filterable?: boolean;
193
+ resizable?: boolean;
194
+ align?: "left" | "center" | "right";
195
+ template?: (value: unknown, row: Record<string, unknown>) => React.ReactNode;
196
+ }
197
+
198
+ export declare interface GridProps {
199
+ columns: GridColumn[];
200
+ data?: Record<string, unknown>[];
201
+ height?: string | number;
202
+ rowHeight?: number;
203
+ sortable?: boolean;
204
+ resizable?: boolean;
205
+ selection?: "row" | "cell";
206
+ multiselect?: boolean;
207
+ onSelect?: (row: Record<string, unknown>) => void;
208
+ style?: React.CSSProperties;
209
+ }
210
+
211
+ export declare function Layout({ rows, cols, type, style, children }: LayoutProps): JSX_2.Element;
212
+
213
+ export declare interface LayoutCellConfig {
214
+ id?: string;
215
+ width?: string | number;
216
+ height?: string | number;
217
+ header?: string;
218
+ collapsable?: boolean;
219
+ padding?: string | number;
220
+ html?: string;
221
+ content?: React.ReactNode;
222
+ rows?: LayoutCellConfig[];
223
+ cols?: LayoutCellConfig[];
224
+ }
225
+
226
+ export declare interface LayoutProps {
227
+ rows?: LayoutCellConfig[];
228
+ cols?: LayoutCellConfig[];
229
+ type?: "line" | "space" | "wide";
230
+ style?: React.CSSProperties;
231
+ children?: React.ReactNode;
232
+ }
233
+
234
+ export declare function List({ data, template, keyNavigation, multiselection, editable, height, onSelect, onEdit, style }: ListProps): JSX_2.Element;
235
+
236
+ export declare interface ListItem {
237
+ id?: string | number;
238
+ value?: string;
239
+ [key: string]: unknown;
240
+ }
241
+
242
+ export declare interface ListProps {
243
+ data?: ListItem[];
244
+ template?: (item: ListItem) => string;
245
+ keyNavigation?: boolean;
246
+ multiselection?: boolean;
247
+ editable?: boolean;
248
+ height?: number | string;
249
+ onSelect?: (item: ListItem) => void;
250
+ onEdit?: (item: ListItem, index: number) => void;
251
+ style?: React.CSSProperties;
252
+ }
253
+
254
+ export declare function Menu({ items, label, onSelect, style }: MenuProps): JSX_2.Element;
255
+
256
+ export declare function MenuDropdown({ items, onSelect, style }: MenuDropdownProps): JSX_2.Element;
257
+
258
+ declare interface MenuDropdownProps {
259
+ items: MenuItem[];
260
+ onSelect: (item: MenuItem) => void;
261
+ style?: React.CSSProperties;
262
+ }
263
+
264
+ export declare interface MenuItem {
265
+ id?: string;
266
+ value?: string;
267
+ icon?: React.ReactNode;
268
+ hotkey?: string;
269
+ disabled?: boolean;
270
+ type?: "separator";
271
+ items?: MenuItem[];
272
+ }
273
+
274
+ export declare interface MenuProps {
275
+ items?: MenuItem[];
276
+ label?: string;
277
+ onSelect?: (item: MenuItem) => void;
278
+ style?: React.CSSProperties;
279
+ }
280
+
281
+ declare interface MessageAPI {
282
+ message: (opts: MessageOptions) => number;
283
+ alert: (title: string, opts?: Omit<MessageOptions, "title">) => number;
284
+ confirm: (title: string, cb: (ok: boolean) => void, opts?: Omit<MessageOptions, "title" | "confirm">) => number;
285
+ }
286
+
287
+ export declare const MessageContext: Context<MessageAPI | null>;
288
+
289
+ export declare interface MessageOptions {
290
+ type?: MessageType;
291
+ title?: string;
292
+ text?: string;
293
+ duration?: number;
294
+ confirm?: (ok: boolean) => void;
295
+ }
296
+
297
+ export declare function MessageProvider({ children }: {
298
+ children: React.ReactNode;
299
+ }): JSX_2.Element;
300
+
301
+ export declare type MessageType = "success" | "error" | "warning" | "info";
302
+
303
+ export declare function Navbar({ logo, items, vertical, style }: NavbarProps): JSX_2.Element;
304
+
305
+ export declare interface NavbarItem {
306
+ id?: string;
307
+ type?: "separator" | "spacer" | "input" | "menuItem";
308
+ value?: string;
309
+ icon?: React.ReactNode;
310
+ items?: MenuItem[];
311
+ width?: number;
312
+ placeholder?: string;
313
+ onClick?: () => void;
314
+ }
315
+
316
+ export declare interface NavbarProps {
317
+ logo?: React.ReactNode;
318
+ items?: NavbarItem[];
319
+ vertical?: boolean;
320
+ style?: React.CSSProperties;
321
+ }
322
+
323
+ export declare function Pagination({ total, pageSize, page: pageProp, onChange, style }: PaginationProps): JSX_2.Element;
324
+
325
+ export declare interface PaginationProps {
326
+ total: number;
327
+ pageSize?: number;
328
+ page?: number;
329
+ onChange?: (page: number) => void;
330
+ style?: React.CSSProperties;
331
+ }
332
+
333
+ export declare function Popup({ trigger, children, placement, style }: PopupProps): JSX_2.Element;
334
+
335
+ export declare type PopupPlacement = "bottom-start" | "bottom-end" | "top-start";
336
+
337
+ export declare interface PopupProps {
338
+ trigger: React.ReactNode;
339
+ children?: React.ReactNode;
340
+ placement?: PopupPlacement;
341
+ style?: React.CSSProperties;
342
+ }
343
+
344
+ export declare function Ribbon({ items, onAction, style }: RibbonProps): JSX_2.Element;
345
+
346
+ declare interface RibbonBlock {
347
+ type: "block";
348
+ label?: string;
349
+ direction?: "col" | "row";
350
+ items?: RibbonSubItem[];
351
+ }
352
+
353
+ export declare type RibbonItem = RibbonSubItem | RibbonBlock;
354
+
355
+ export declare interface RibbonProps {
356
+ items?: RibbonItem[];
357
+ onAction?: (id: string, item: RibbonSubItem) => void;
358
+ style?: React.CSSProperties;
359
+ }
360
+
361
+ declare interface RibbonSubItem {
362
+ id?: string;
363
+ type?: "separator" | "sep" | "input" | "selectButton";
364
+ text?: string;
365
+ icon?: React.ReactNode;
366
+ active?: boolean;
367
+ disabled?: boolean;
368
+ tooltip?: string;
369
+ label?: string;
370
+ size?: "large" | "auto";
371
+ placeholder?: string;
372
+ value?: string;
373
+ width?: number;
374
+ items?: {
375
+ value: string;
376
+ }[];
377
+ onClick?: (item: RibbonSubItem) => void;
378
+ onChange?: (value: string) => void;
379
+ }
380
+
381
+ export declare function Sidebar({ items, width, collapsed: collapsedProp, onSelect, header, footer, style }: SidebarProps): JSX_2.Element;
382
+
383
+ export declare interface SidebarItem {
384
+ id: string;
385
+ value?: string;
386
+ icon?: React.ReactNode;
387
+ count?: number;
388
+ type?: "separator" | "customHTML";
389
+ html?: string;
390
+ items?: SidebarItem[];
391
+ }
392
+
393
+ export declare interface SidebarProps {
394
+ items?: SidebarItem[];
395
+ width?: number;
396
+ collapsed?: boolean;
397
+ header?: React.ReactNode;
398
+ footer?: React.ReactNode;
399
+ onSelect?: (item: SidebarItem) => void;
400
+ style?: React.CSSProperties;
401
+ }
402
+
403
+ export declare function Slider({ min, max, step, value: valueProp, range, label, tick, onChange, style }: SliderProps): JSX_2.Element;
404
+
405
+ export declare interface SliderProps {
406
+ min?: number;
407
+ max?: number;
408
+ step?: number;
409
+ value?: number | [number, number];
410
+ range?: boolean;
411
+ label?: string;
412
+ tick?: boolean;
413
+ onChange?: (value: number | [number, number]) => void;
414
+ style?: React.CSSProperties;
415
+ }
416
+
417
+ export declare function Tabbar({ views, mode, tabAlign, closable, disabled, defaultActive, onBeforeChange, onChange, style }: TabbarProps): JSX_2.Element;
418
+
419
+ export declare interface TabbarProps {
420
+ views?: TabView[];
421
+ mode?: "top" | "bottom" | "left" | "right";
422
+ tabAlign?: "left" | "center" | "right";
423
+ closable?: string[];
424
+ disabled?: string[];
425
+ defaultActive?: string;
426
+ onBeforeChange?: (id: string) => boolean | void;
427
+ onChange?: (id: string) => void;
428
+ style?: React.CSSProperties;
429
+ }
430
+
431
+ export declare interface TabView {
432
+ id: string;
433
+ tab: string;
434
+ icon?: React.ReactNode;
435
+ content?: React.ReactNode;
436
+ html?: string;
437
+ }
438
+
439
+ export declare function Timepicker({ value, onChange, style }: TimepickerProps): JSX_2.Element;
440
+
441
+ export declare interface TimepickerProps {
442
+ value?: TimeValue;
443
+ onChange?: (value: TimeValue) => void;
444
+ style?: React.CSSProperties;
445
+ }
446
+
447
+ export declare interface TimeValue {
448
+ h: number;
449
+ m: number;
450
+ ampm: "AM" | "PM";
451
+ }
452
+
453
+ export declare type Tokens = typeof tokens;
454
+
455
+ /**
456
+ * Design Tokens — single source of truth for colours, spacing and typography.
457
+ *
458
+ * @example Override for a dark/custom theme:
459
+ * import { tokens } from "dhx-react-suite";
460
+ * tokens.primary = "#7c3aed";
461
+ */
462
+ export declare const tokens: {
463
+ primary: string;
464
+ primaryDk: string;
465
+ primaryLt: string;
466
+ success: string;
467
+ danger: string;
468
+ warning: string;
469
+ bg: string;
470
+ surface: string;
471
+ border: string;
472
+ borderDk: string;
473
+ text: string;
474
+ textSec: string;
475
+ textMut: string;
476
+ shadow: string;
477
+ shadowLg: string;
478
+ r: string;
479
+ rMd: string;
480
+ font: string;
481
+ };
482
+
483
+ export declare function Toolbar({ items, style }: ToolbarProps): JSX_2.Element;
484
+
485
+ export declare interface ToolbarItem {
486
+ id?: string;
487
+ type?: "separator" | "spacer" | "input" | "select";
488
+ text?: string;
489
+ icon?: React.ReactNode;
490
+ active?: boolean;
491
+ twoState?: boolean;
492
+ disabled?: boolean;
493
+ label?: string;
494
+ placeholder?: string;
495
+ value?: string;
496
+ width?: number;
497
+ options?: {
498
+ value: string;
499
+ label: string;
500
+ }[];
501
+ onClick?: (item: ToolbarItem) => void;
502
+ onChange?: (value: string) => void;
503
+ }
504
+
505
+ export declare interface ToolbarProps {
506
+ items?: ToolbarItem[];
507
+ style?: React.CSSProperties;
508
+ }
509
+
510
+ export declare function Tree({ data, checkbox, editable, onSelect, onCheck, style }: TreeProps): JSX_2.Element;
511
+
512
+ export declare interface TreeNode {
513
+ id: string;
514
+ value?: string;
515
+ count?: number;
516
+ items?: TreeNode[];
517
+ }
518
+
519
+ export declare interface TreeProps {
520
+ data?: TreeNode[];
521
+ checkbox?: boolean;
522
+ editable?: boolean;
523
+ onSelect?: (node: TreeNode) => void;
524
+ onCheck?: (id: string, checked: boolean) => void;
525
+ style?: React.CSSProperties;
526
+ }
527
+
528
+ export declare function useClickOutside(ref: RefObject<HTMLElement>, callback: (event: MouseEvent) => void): void;
529
+
530
+ export declare function useDrag(onDrag: (x: number, y: number) => void): (e: default_2.MouseEvent, originX?: number, originY?: number) => void;
531
+
532
+ export declare function useMessage(): MessageAPI;
533
+
534
+ declare function Window_2({ title, children, width, height, closable, movable, modal, defaultOpen, footer, onClose, style }: WindowProps): JSX_2.Element | null;
535
+ export { Window_2 as Window }
536
+
537
+ export declare interface WindowProps {
538
+ title?: string;
539
+ children?: React.ReactNode;
540
+ width?: number | string;
541
+ height?: number | string;
542
+ closable?: boolean;
543
+ movable?: boolean;
544
+ modal?: boolean;
545
+ defaultOpen?: boolean;
546
+ footer?: React.ReactNode;
547
+ onClose?: () => void;
548
+ style?: React.CSSProperties;
549
+ }
550
+
551
+ export { }
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "dhx-react-suite",
3
+ "version": "1.0.0",
4
+ "description": "23 production-ready React UI components — TypeScript reimplementation of DHTMLX Suite",
5
+ "type": "module",
6
+ "main": "./dist/dhx-react-suite.umd.cjs",
7
+ "module": "./dist/dhx-react-suite.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/dhx-react-suite.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/dhx-react-suite.umd.cjs"
18
+ }
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "README.md"
24
+ ],
25
+ "sideEffects": false,
26
+ "scripts": {
27
+ "dev": "vite",
28
+ "build": "tsc -p tsconfig.build.json && vite build",
29
+ "preview": "vite preview",
30
+ "lint": "eslint src --ext .tsx,.ts",
31
+ "test": "vitest run",
32
+ "test:watch": "vitest",
33
+ "prepublishOnly": "npm run build"
34
+ },
35
+ "peerDependencies": {
36
+ "react": ">=17.0.0",
37
+ "react-dom": ">=17.0.0",
38
+ "recharts": ">=2.0.0"
39
+ },
40
+ "peerDependenciesMeta": {
41
+ "recharts": {
42
+ "optional": true
43
+ }
44
+ },
45
+ "devDependencies": {
46
+ "@testing-library/jest-dom": "^6.4.2",
47
+ "@testing-library/react": "^14.2.2",
48
+ "@types/react": "^18.2.67",
49
+ "@types/react-dom": "^18.2.22",
50
+ "@types/recharts": "^1.8.29",
51
+ "@typescript-eslint/eslint-plugin": "^7.2.0",
52
+ "@typescript-eslint/parser": "^7.2.0",
53
+ "@vitejs/plugin-react": "^4.2.1",
54
+ "@vitest/ui": "^1.4.0",
55
+ "eslint": "^8.57.0",
56
+ "jsdom": "^24.0.0",
57
+ "recharts": "^3.7.0",
58
+ "typescript": "^5.4.2",
59
+ "vite": "^5.1.6",
60
+ "vite-plugin-dts": "^3.7.3",
61
+ "vitest": "^1.4.0"
62
+ },
63
+ "keywords": [
64
+ "react",
65
+ "typescript",
66
+ "ui",
67
+ "components",
68
+ "grid",
69
+ "chart",
70
+ "calendar",
71
+ "form",
72
+ "sidebar"
73
+ ],
74
+ "license": "MIT"
75
+ }