@nice2dev/ui-core 1.0.10
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/CHANGELOG.md +63 -0
- package/README.md +62 -0
- package/dist/core/NiceInlineHelp.d.ts +69 -0
- package/dist/core/NiceInlineHelp.d.ts.map +1 -0
- package/dist/core/NiceThemeProvider.d.ts +31 -0
- package/dist/core/NiceThemeProvider.d.ts.map +1 -0
- package/dist/core/NiceThemeVariants.d.ts +55 -0
- package/dist/core/NiceThemeVariants.d.ts.map +1 -0
- package/dist/core/NiceUserPreferences.d.ts +304 -0
- package/dist/core/NiceUserPreferences.d.ts.map +1 -0
- package/dist/core/a11y-advanced.d.ts +157 -0
- package/dist/core/a11y-advanced.d.ts.map +1 -0
- package/dist/core/a11y.d.ts +299 -0
- package/dist/core/a11y.d.ts.map +1 -0
- package/dist/core/access-control.d.ts +59 -0
- package/dist/core/access-control.d.ts.map +1 -0
- package/dist/core/adapters.d.ts +178 -0
- package/dist/core/adapters.d.ts.map +1 -0
- package/dist/core/ai.d.ts +191 -0
- package/dist/core/ai.d.ts.map +1 -0
- package/dist/core/animations.d.ts +48 -0
- package/dist/core/animations.d.ts.map +1 -0
- package/dist/core/colorBlind.d.ts +22 -0
- package/dist/core/colorBlind.d.ts.map +1 -0
- package/dist/core/datasource-advanced.d.ts +261 -0
- package/dist/core/datasource-advanced.d.ts.map +1 -0
- package/dist/core/datasource-aggregation.d.ts +221 -0
- package/dist/core/datasource-aggregation.d.ts.map +1 -0
- package/dist/core/datasource-hooks.d.ts +93 -0
- package/dist/core/datasource-hooks.d.ts.map +1 -0
- package/dist/core/datasource-offline.d.ts +201 -0
- package/dist/core/datasource-offline.d.ts.map +1 -0
- package/dist/core/datasource.d.ts +181 -0
- package/dist/core/datasource.d.ts.map +1 -0
- package/dist/core/displayMode.d.ts +46 -0
- package/dist/core/displayMode.d.ts.map +1 -0
- package/dist/core/displayStyle.d.ts +79 -0
- package/dist/core/displayStyle.d.ts.map +1 -0
- package/dist/core/helpContext.d.ts +97 -0
- package/dist/core/helpContext.d.ts.map +1 -0
- package/dist/core/hooks.d.ts +149 -0
- package/dist/core/hooks.d.ts.map +1 -0
- package/dist/core/i18n.d.ts +10 -0
- package/dist/core/i18n.d.ts.map +1 -0
- package/dist/core/i18nDictionaries.d.ts +4 -0
- package/dist/core/i18nDictionaries.d.ts.map +1 -0
- package/dist/core/icons.d.ts +45 -0
- package/dist/core/icons.d.ts.map +1 -0
- package/dist/core/icuMessageFormat.d.ts +10 -0
- package/dist/core/icuMessageFormat.d.ts.map +1 -0
- package/dist/core/leak-detector.d.ts +263 -0
- package/dist/core/leak-detector.d.ts.map +1 -0
- package/dist/core/omniverkTypes.d.ts +164 -0
- package/dist/core/omniverkTypes.d.ts.map +1 -0
- package/dist/core/pluginSystem.d.ts +97 -0
- package/dist/core/pluginSystem.d.ts.map +1 -0
- package/dist/core/profiling.d.ts +276 -0
- package/dist/core/profiling.d.ts.map +1 -0
- package/dist/core/responsive.d.ts +107 -0
- package/dist/core/responsive.d.ts.map +1 -0
- package/dist/core/rtl.d.ts +47 -0
- package/dist/core/rtl.d.ts.map +1 -0
- package/dist/core/sanitizeHtml.d.ts +16 -0
- package/dist/core/sanitizeHtml.d.ts.map +1 -0
- package/dist/core/testing.d.ts +107 -0
- package/dist/core/testing.d.ts.map +1 -0
- package/dist/core/theme.d.ts +213 -0
- package/dist/core/theme.d.ts.map +1 -0
- package/dist/core/themeGallery.d.ts +104 -0
- package/dist/core/themeGallery.d.ts.map +1 -0
- package/dist/core/themePacks.d.ts +53 -0
- package/dist/core/themePacks.d.ts.map +1 -0
- package/dist/core/themePacksExtended.d.ts +59 -0
- package/dist/core/themePacksExtended.d.ts.map +1 -0
- package/dist/core/themePresets.d.ts +10 -0
- package/dist/core/themePresets.d.ts.map +1 -0
- package/dist/core/themeVariants.d.ts +204 -0
- package/dist/core/themeVariants.d.ts.map +1 -0
- package/dist/core/touch.d.ts +208 -0
- package/dist/core/touch.d.ts.map +1 -0
- package/dist/core/traceless.d.ts +461 -0
- package/dist/core/traceless.d.ts.map +1 -0
- package/dist/core/types.d.ts +105 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/useThemeIsDark.d.ts +15 -0
- package/dist/core/useThemeIsDark.d.ts.map +1 -0
- package/dist/index.cjs +128 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +16881 -0
- package/dist/index.mjs.map +1 -0
- package/dist/performance/concurrent.d.ts +190 -0
- package/dist/performance/concurrent.d.ts.map +1 -0
- package/dist/performance/images.d.ts +189 -0
- package/dist/performance/images.d.ts.map +1 -0
- package/dist/performance/index.d.ts +17 -0
- package/dist/performance/index.d.ts.map +1 -0
- package/dist/performance/memory.d.ts +223 -0
- package/dist/performance/memory.d.ts.map +1 -0
- package/dist/performance/virtualization.d.ts +166 -0
- package/dist/performance/virtualization.d.ts.map +1 -0
- package/dist/performance/workers.d.ts +125 -0
- package/dist/performance/workers.d.ts.map +1 -0
- package/dist/viewSchema.d.ts +81 -0
- package/dist/viewSchema.d.ts.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file virtualization.ts
|
|
3
|
+
* @description Nice2Dev Performance — Virtualization Utilities
|
|
4
|
+
*
|
|
5
|
+
* High-performance virtual scrolling for large datasets.
|
|
6
|
+
* Target: 500k rows <1s initial render
|
|
7
|
+
*/
|
|
8
|
+
export interface VirtualScrollConfig {
|
|
9
|
+
/** Total number of items */
|
|
10
|
+
itemCount: number;
|
|
11
|
+
/** Height of each item (or function for variable heights) */
|
|
12
|
+
itemHeight: number | ((index: number) => number);
|
|
13
|
+
/** Height of the visible container */
|
|
14
|
+
containerHeight: number;
|
|
15
|
+
/** Number of items to render outside visible area */
|
|
16
|
+
overscan?: number;
|
|
17
|
+
/** Enable smooth scrolling */
|
|
18
|
+
smoothScroll?: boolean;
|
|
19
|
+
/** Initial scroll offset */
|
|
20
|
+
initialScrollTop?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface VirtualScrollResult {
|
|
23
|
+
/** Items currently in view */
|
|
24
|
+
visibleItems: VirtualItem[];
|
|
25
|
+
/** Total height of all items (for scroll container) */
|
|
26
|
+
totalHeight: number;
|
|
27
|
+
/** Current scroll offset */
|
|
28
|
+
scrollTop: number;
|
|
29
|
+
/** Scroll to specific index */
|
|
30
|
+
scrollToIndex: (index: number, align?: 'start' | 'center' | 'end') => void;
|
|
31
|
+
/** Scroll to specific offset */
|
|
32
|
+
scrollTo: (offset: number) => void;
|
|
33
|
+
/** Handle scroll event */
|
|
34
|
+
onScroll: (e: React.UIEvent<HTMLElement>) => void;
|
|
35
|
+
/** Start index of visible range */
|
|
36
|
+
startIndex: number;
|
|
37
|
+
/** End index of visible range */
|
|
38
|
+
endIndex: number;
|
|
39
|
+
/** Is scrolling */
|
|
40
|
+
isScrolling: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface VirtualItem {
|
|
43
|
+
/** Item index */
|
|
44
|
+
index: number;
|
|
45
|
+
/** Offset from top */
|
|
46
|
+
offset: number;
|
|
47
|
+
/** Item height */
|
|
48
|
+
height: number;
|
|
49
|
+
/** Item key */
|
|
50
|
+
key: string | number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Hook for virtual scrolling with 500k+ items
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```tsx
|
|
57
|
+
* function LargeList() {
|
|
58
|
+
* const { visibleItems, totalHeight, onScroll } = useVirtualScroll({
|
|
59
|
+
* itemCount: 500000,
|
|
60
|
+
* itemHeight: 40,
|
|
61
|
+
* containerHeight: 600,
|
|
62
|
+
* });
|
|
63
|
+
*
|
|
64
|
+
* return (
|
|
65
|
+
* <div style={{ height: 600, overflow: 'auto' }} onScroll={onScroll}>
|
|
66
|
+
* <div style={{ height: totalHeight, position: 'relative' }}>
|
|
67
|
+
* {visibleItems.map(item => (
|
|
68
|
+
* <div
|
|
69
|
+
* key={item.key}
|
|
70
|
+
* style={{
|
|
71
|
+
* position: 'absolute',
|
|
72
|
+
* top: item.offset,
|
|
73
|
+
* height: item.height,
|
|
74
|
+
* }}
|
|
75
|
+
* >
|
|
76
|
+
* Row {item.index}
|
|
77
|
+
* </div>
|
|
78
|
+
* ))}
|
|
79
|
+
* </div>
|
|
80
|
+
* </div>
|
|
81
|
+
* );
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare function useVirtualScroll(config: VirtualScrollConfig): VirtualScrollResult;
|
|
86
|
+
export interface VirtualGridConfig {
|
|
87
|
+
/** Total number of rows */
|
|
88
|
+
rowCount: number;
|
|
89
|
+
/** Total number of columns */
|
|
90
|
+
columnCount: number;
|
|
91
|
+
/** Height of each row */
|
|
92
|
+
rowHeight: number | ((index: number) => number);
|
|
93
|
+
/** Width of each column */
|
|
94
|
+
columnWidth: number | ((index: number) => number);
|
|
95
|
+
/** Height of the visible container */
|
|
96
|
+
containerHeight: number;
|
|
97
|
+
/** Width of the visible container */
|
|
98
|
+
containerWidth: number;
|
|
99
|
+
/** Overscan count */
|
|
100
|
+
overscan?: number;
|
|
101
|
+
}
|
|
102
|
+
export interface VirtualGridCell {
|
|
103
|
+
rowIndex: number;
|
|
104
|
+
columnIndex: number;
|
|
105
|
+
top: number;
|
|
106
|
+
left: number;
|
|
107
|
+
width: number;
|
|
108
|
+
height: number;
|
|
109
|
+
key: string;
|
|
110
|
+
}
|
|
111
|
+
export interface VirtualGridResult {
|
|
112
|
+
visibleCells: VirtualGridCell[];
|
|
113
|
+
totalWidth: number;
|
|
114
|
+
totalHeight: number;
|
|
115
|
+
onScroll: (e: React.UIEvent<HTMLElement>) => void;
|
|
116
|
+
scrollTop: number;
|
|
117
|
+
scrollLeft: number;
|
|
118
|
+
isScrolling: boolean;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Hook for virtual grid with millions of cells
|
|
122
|
+
*/
|
|
123
|
+
export declare function useVirtualGrid(config: VirtualGridConfig): VirtualGridResult;
|
|
124
|
+
export interface WindowedListProps<T> {
|
|
125
|
+
items: T[];
|
|
126
|
+
height: number;
|
|
127
|
+
itemHeight: number;
|
|
128
|
+
renderItem: (item: T, index: number, style: React.CSSProperties) => React.ReactNode;
|
|
129
|
+
overscan?: number;
|
|
130
|
+
className?: string;
|
|
131
|
+
style?: React.CSSProperties;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Pre-configured windowed list for quick usage
|
|
135
|
+
*/
|
|
136
|
+
export declare function useWindowedList<T>(items: T[], height: number, itemHeight: number, overscan?: number): {
|
|
137
|
+
getItemData: (virtualItem: VirtualItem) => T;
|
|
138
|
+
containerStyle: {
|
|
139
|
+
height: number;
|
|
140
|
+
overflow: "auto";
|
|
141
|
+
};
|
|
142
|
+
innerStyle: {
|
|
143
|
+
height: number;
|
|
144
|
+
position: "relative";
|
|
145
|
+
};
|
|
146
|
+
getItemStyle: (item: VirtualItem) => React.CSSProperties;
|
|
147
|
+
/** Items currently in view */
|
|
148
|
+
visibleItems: VirtualItem[];
|
|
149
|
+
/** Total height of all items (for scroll container) */
|
|
150
|
+
totalHeight: number;
|
|
151
|
+
/** Current scroll offset */
|
|
152
|
+
scrollTop: number;
|
|
153
|
+
/** Scroll to specific index */
|
|
154
|
+
scrollToIndex: (index: number, align?: "start" | "center" | "end") => void;
|
|
155
|
+
/** Scroll to specific offset */
|
|
156
|
+
scrollTo: (offset: number) => void;
|
|
157
|
+
/** Handle scroll event */
|
|
158
|
+
onScroll: (e: React.UIEvent<HTMLElement>) => void;
|
|
159
|
+
/** Start index of visible range */
|
|
160
|
+
startIndex: number;
|
|
161
|
+
/** End index of visible range */
|
|
162
|
+
endIndex: number;
|
|
163
|
+
/** Is scrolling */
|
|
164
|
+
isScrolling: boolean;
|
|
165
|
+
};
|
|
166
|
+
//# sourceMappingURL=virtualization.d.ts.map
|
|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ities
|
|
4
|
+
*
|
|
5
|
+
* Offload heavy computations to Web Workers.
|
|
6
|
+
* Keeps main thread responsive during data processing.
|
|
7
|
+
*/
|
|
8
|
+
export interface WorkerTask<T, R> {
|
|
9
|
+
/** Task ID */
|
|
10
|
+
id: string;
|
|
11
|
+
/** Task data */
|
|
12
|
+
data: T;
|
|
13
|
+
/** Resolve function */
|
|
14
|
+
resolve: (result: R) => void;
|
|
15
|
+
/** Reject function */
|
|
16
|
+
reject: (error: Error) => void;
|
|
17
|
+
}
|
|
18
|
+
export interface WorkerPoolConfig {
|
|
19
|
+
/** Number of workers in pool */
|
|
20
|
+
poolSize?: number;
|
|
21
|
+
/** Worker script URL or function */
|
|
22
|
+
workerScript: string | URL | (() => void);
|
|
23
|
+
/** Terminate idle workers after ms */
|
|
24
|
+
idleTimeout?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface WorkerResult<R> {
|
|
27
|
+
/** Result data */
|
|
28
|
+
result: R | null;
|
|
29
|
+
/** Is currently processing */
|
|
30
|
+
isProcessing: boolean;
|
|
31
|
+
/** Error if any */
|
|
32
|
+
error: Error | null;
|
|
33
|
+
/** Execute task */
|
|
34
|
+
execute: (data: unknown) => Promise<R>;
|
|
35
|
+
/** Cancel current task */
|
|
36
|
+
cancel: () => void;
|
|
37
|
+
/** Terminate worker */
|
|
38
|
+
terminate: () => void;
|
|
39
|
+
}
|
|
40
|
+
export interface WorkerMessage<T = unknown, R = unknown> {
|
|
41
|
+
type: 'task' | 'result' | 'error' | 'progress' | 'cancel';
|
|
42
|
+
id: string;
|
|
43
|
+
data?: T;
|
|
44
|
+
result?: R;
|
|
45
|
+
error?: string;
|
|
46
|
+
progress?: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Hook for using a single Web Worker
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```tsx
|
|
53
|
+
* // worker.ts
|
|
54
|
+
* self.onmessage = (e) => {
|
|
55
|
+
* const result = heavyComputation(e.data);
|
|
56
|
+
* self.postMessage({ type: 'result', result });
|
|
57
|
+
* };
|
|
58
|
+
*
|
|
59
|
+
* // Component.tsx
|
|
60
|
+
* function DataProcessor() {
|
|
61
|
+
* const { result, isProcessing, execute } = useWorker({
|
|
62
|
+
* workerScript: new URL('./worker.ts', import.meta.url),
|
|
63
|
+
* });
|
|
64
|
+
*
|
|
65
|
+
* return (
|
|
66
|
+
* <button onClick={() => execute(largeData)}>
|
|
67
|
+
* {isProcessing ? 'Processing...' : 'Process Data'}
|
|
68
|
+
* </button>
|
|
69
|
+
* );
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function useWorker<T = unknown, R = unknown>(config: Omit<WorkerPoolConfig, 'poolSize'>): WorkerResult<R>;
|
|
74
|
+
/**
|
|
75
|
+
* Worker pool for parallel processing
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```tsx
|
|
79
|
+
* function ParallelProcessor() {
|
|
80
|
+
* const pool = useWorkerPool({
|
|
81
|
+
* workerScript: new URL('./worker.ts', import.meta.url),
|
|
82
|
+
* poolSize: 4,
|
|
83
|
+
* });
|
|
84
|
+
*
|
|
85
|
+
* const processAll = async () => {
|
|
86
|
+
* const results = await Promise.all(
|
|
87
|
+
* chunks.map(chunk => pool.execute(chunk))
|
|
88
|
+
* );
|
|
89
|
+
* };
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare function useWorkerPool<T = unknown, R = unknown>(config: WorkerPoolConfig): {
|
|
94
|
+
execute: (data: T) => Promise<R>;
|
|
95
|
+
executeAll: (items: T[]) => Promise<R[]>;
|
|
96
|
+
terminateAll: () => void;
|
|
97
|
+
getStats: () => {
|
|
98
|
+
total: number;
|
|
99
|
+
busy: number;
|
|
100
|
+
idle: number;
|
|
101
|
+
queued: number;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Create an inline worker from a function
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```tsx
|
|
109
|
+
* const sortWorker = createInlineWorker<number[], number[]>((data) => {
|
|
110
|
+
* return data.sort((a, b) => a - b);
|
|
111
|
+
* });
|
|
112
|
+
*
|
|
113
|
+
* function SortButton() {
|
|
114
|
+
* const { execute, result, isProcessing } = useWorker({
|
|
115
|
+
* workerScript: sortWorker,
|
|
116
|
+
* });
|
|
117
|
+
* }
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export declare function createInlineWorker<T, R>(processFn: (data: T) => R): URL;
|
|
121
|
+
/**
|
|
122
|
+
* Helper to extract transferable objects from data
|
|
123
|
+
*/
|
|
124
|
+
export declare function getTransferables(data: unknown): Transferable[];
|
|
125
|
+
//# sourceMappingURL=workers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workers.d.ts","sourceRoot":"","sources":["../../src/performance/workers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,MAAM,WAAW,UAAU,CAAC,CAAC,EAAE,CAAC;IAC9B,cAAc;IACd,EAAE,EAAE,MAAM,CAAC;IACX,gBAAgB;IAChB,IAAI,EAAE,CAAC,CAAC;IACR,uBAAuB;IACvB,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC;IAC7B,sBAAsB;IACtB,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,gBAAgB;IAC/B,gCAAgC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,YAAY,EAAE,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;IAC1C,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,kBAAkB;IAClB,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC;IACjB,8B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AEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,YAAY,EAAE,CAwB9D"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared JSON View Schema — identical view definition format for React ↔ Flutter.
|
|
3
|
+
*
|
|
4
|
+
* Defines the `.ndv.json` (NiceToDev View) format used by both
|
|
5
|
+
* `@nice2dev/ui` (React) and `nice2dev_flutter_ui` (Flutter)
|
|
6
|
+
* to render dynamic, data-driven UIs from a single JSON definition.
|
|
7
|
+
*
|
|
8
|
+
* @module view-schema
|
|
9
|
+
*/
|
|
10
|
+
/** Root document for `.ndv.json` files. */
|
|
11
|
+
export interface NiceViewDocument {
|
|
12
|
+
$schema?: string;
|
|
13
|
+
version: string;
|
|
14
|
+
root: NiceViewNode;
|
|
15
|
+
dataSources?: NiceViewDataSource[];
|
|
16
|
+
theme?: Record<string, unknown>;
|
|
17
|
+
i18n?: Record<string, unknown>;
|
|
18
|
+
metadata?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/** A single UI element in the view tree. */
|
|
21
|
+
export interface NiceViewNode {
|
|
22
|
+
/** Component type (e.g. 'NiceTextInput', 'NiceDataGrid', 'NiceButton'). */
|
|
23
|
+
type: string;
|
|
24
|
+
/** Unique ID for referencing in bindings/events. */
|
|
25
|
+
id?: string;
|
|
26
|
+
/** Static props passed to the component. */
|
|
27
|
+
props?: Record<string, unknown>;
|
|
28
|
+
/** Child nodes. */
|
|
29
|
+
children?: NiceViewNode[];
|
|
30
|
+
/** Data bindings: prop name → data source path (e.g. `{ "value": "form.name" }`). */
|
|
31
|
+
bindings?: Record<string, string>;
|
|
32
|
+
/** Conditional rendering. */
|
|
33
|
+
conditions?: NiceViewCondition;
|
|
34
|
+
/** Repeat/loop configuration. */
|
|
35
|
+
repeat?: NiceViewRepeat;
|
|
36
|
+
/** Event handlers: event name → action. */
|
|
37
|
+
events?: Record<string, unknown>;
|
|
38
|
+
/** Inline style overrides. */
|
|
39
|
+
style?: Record<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
/** Condition for conditional rendering. */
|
|
42
|
+
export interface NiceViewCondition {
|
|
43
|
+
/** Data source field path. */
|
|
44
|
+
field: string;
|
|
45
|
+
/** Operator: eq, neq, gt, gte, lt, lte, contains, empty, notEmpty. */
|
|
46
|
+
operator: 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'contains' | 'empty' | 'notEmpty';
|
|
47
|
+
/** Value to compare against. */
|
|
48
|
+
value: unknown;
|
|
49
|
+
}
|
|
50
|
+
/** Loop configuration: render node N times from a data source collection. */
|
|
51
|
+
export interface NiceViewRepeat {
|
|
52
|
+
/** Data source path to iterate over. */
|
|
53
|
+
source: string;
|
|
54
|
+
/** Variable name for the current item (default: 'item'). */
|
|
55
|
+
itemAs?: string;
|
|
56
|
+
/** Variable name for the current index (default: 'index'). */
|
|
57
|
+
indexAs?: string;
|
|
58
|
+
}
|
|
59
|
+
/** Data source definition for the view. */
|
|
60
|
+
export interface NiceViewDataSource {
|
|
61
|
+
/** Data source identifier. */
|
|
62
|
+
id: string;
|
|
63
|
+
/** Type: 'rest', 'signalr', 'static', 'local'. */
|
|
64
|
+
type: 'rest' | 'signalr' | 'static' | 'local';
|
|
65
|
+
/** REST/SignalR URL. */
|
|
66
|
+
url?: string;
|
|
67
|
+
/** Default data (for type 'static'). */
|
|
68
|
+
defaultData?: unknown;
|
|
69
|
+
/** Auto-refresh flag. */
|
|
70
|
+
autoRefresh?: boolean;
|
|
71
|
+
/** Refresh interval in milliseconds. */
|
|
72
|
+
refreshInterval?: number;
|
|
73
|
+
}
|
|
74
|
+
/** Known component types in the NiceToDev ecosystem (for type-safe view definitions). */
|
|
75
|
+
export declare const NICE_VIEW_COMPONENT_TYPES: readonly ["NiceTextInput", "NiceTextArea", "NiceNumberInput", "NiceDatePicker", "NiceSelect", "NiceCheckbox", "NiceToggle", "NiceRadioGroup", "NiceSlider", "NiceColorPicker", "NiceAutocomplete", "NiceLookup", "NiceCalendar", "NiceDateRangeBox", "NiceTagBox", "NiceRangeSlider", "NiceDropDownBox", "NiceHtmlEditor", "NiceForm", "NiceRating", "NiceOtpInput", "NiceSignaturePad", "NiceMentionInput", "NiceTreeSelect", "NiceMaskedInput", "NiceKnob", "NicePickList", "NiceInlineEdit", "NiceButton", "NiceButtonGroup", "NiceIconButton", "NiceDropDownButton", "NiceSpeedDialAction", "NiceTable", "NiceDataGrid", "NiceList", "NiceTreeView", "NiceTreeList", "NiceCardView", "NiceTileView", "NicePivotGrid", "NiceKanbanBoard", "NiceSpreadsheet", "NiceBadge", "NiceTag", "NiceAvatar", "NiceAvatarGroup", "NiceProgress", "NiceDivider", "NiceTooltip", "NiceSkeleton", "NiceSpinner", "NiceEmpty", "NiceTimeline", "NiceCarousel", "NiceVirtualScroller", "NiceAlert", "NiceModal", "NiceDrawer", "NiceToastContainer", "NiceConfirmDialog", "NiceCookieConsent", "NiceTabs", "NiceAccordion", "NiceBreadcrumb", "NicePagination", "NiceCard", "NiceMenu", "NiceContextMenu", "NiceMultiView", "NiceSplitter", "NiceToolbar", "NiceAppLayout", "NiceBottomNavigation", "NiceDashboardLayout", "NiceDesktop", "NiceConsole", "NiceChart", "NicePieChart", "NicePolarChart", "NiceCircularGauge", "NiceLinearGauge", "NiceBarGauge", "NiceSparkline", "NiceBullet", "NiceFunnel", "NiceSankey", "NiceRangeSelector", "NiceVectorMap", "NiceHeatMap", "NiceTreeMap", "NiceStockChart", "NiceOrganizationChart", "NiceActionSheet", "NicePopover", "NiceLoadPanel", "NiceWindow", "NiceBlockUI", "NiceScheduler", "NiceGantt", "NiceDiagram", "NiceStepper", "NiceBox", "NiceResponsiveBox", "NiceResizable", "NiceScrollView", "NiceChat", "NiceFileUploader", "NiceFileManager", "NiceFilterBuilder", "NiceGallery", "NiceMap", "div", "span", "row", "column", "stack", "container"];
|
|
76
|
+
export type NiceViewComponentType = typeof NICE_VIEW_COMPONENT_TYPES[number];
|
|
77
|
+
/** Validate a NiceViewDocument for structural correctness. */
|
|
78
|
+
export declare function validateViewDocument(doc: NiceViewDocument): string[];
|
|
79
|
+
/** Evaluate a condition against a context map. */
|
|
80
|
+
export declare function evaluateCondition(condition: NiceViewCondition, context: Record<string, unknown>): boolean;
|
|
81
|
+
//# sourceMappingURL=viewSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewSchema.d.ts","sourceRoot":"","sources":["../src/viewSchema.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,2CAA2C;AAC3C,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,YAAY,CAAC;IACnB,WAAW,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAID,4CAA4C;AAC5C,MAAM,WAAW,YAAY;IAC3B,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,mBAAmB;IACnB,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;IAC1B,qFAAqF;IACrF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,6BAA6B;IAC7B,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,iCAAiC;IACjC,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,M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,CAAC,SAAS,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAczG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nice2dev/ui-core",
|
|
3
|
+
"version": "1.0.10",
|
|
4
|
+
"description": "Nice2Dev UI Core — Types, hooks, i18n, a11y, datasource, theme, animations, icons and responsive utilities",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.cjs",
|
|
7
|
+
"module": "dist/index.mjs",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"require": "./dist/index.cjs"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"LICENSE",
|
|
20
|
+
"README.md",
|
|
21
|
+
"CHANGELOG.md"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc -p tsconfig.build.json && vite build",
|
|
25
|
+
"clean": "rimraf dist",
|
|
26
|
+
"typecheck": "tsc --noEmit",
|
|
27
|
+
"prepublishOnly": "npm run build"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@nice2dev/i18n": "^1.0.10",
|
|
31
|
+
"react": ">=17.0.0",
|
|
32
|
+
"react-dom": ">=17.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@nice2dev/i18n": "^1.0.10",
|
|
36
|
+
"@types/react": "^18.2.0",
|
|
37
|
+
"@types/react-dom": "^18.2.0",
|
|
38
|
+
"@vitejs/plugin-react": "^4.3.0",
|
|
39
|
+
"react": "^18.2.0",
|
|
40
|
+
"react-dom": "^18.2.0",
|
|
41
|
+
"rimraf": "^6.0.0",
|
|
42
|
+
"typescript": "^5.3.0",
|
|
43
|
+
"vite": "^6.4.0"
|
|
44
|
+
},
|
|
45
|
+
"author": "NiceToDev <contact@nicetodev.com>",
|
|
46
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "git+https://github.com/NiceToDev/NiceToDev.UI.git",
|
|
50
|
+
"directory": "packages/ui-core"
|
|
51
|
+
},
|
|
52
|
+
"keywords": [
|
|
53
|
+
"react",
|
|
54
|
+
"hooks",
|
|
55
|
+
"i18n",
|
|
56
|
+
"a11y",
|
|
57
|
+
"theme",
|
|
58
|
+
"datasource",
|
|
59
|
+
"nice2dev"
|
|
60
|
+
]
|
|
61
|
+
}
|