@vortexm/vjt 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/LICENSE +21 -0
- package/README.md +82 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +7073 -0
- package/dist/lib/action-runtime.d.ts +78 -0
- package/dist/lib/default-styles.d.ts +2 -0
- package/dist/lib/dom-state.d.ts +45 -0
- package/dist/lib/layout.d.ts +11 -0
- package/dist/lib/logging.d.ts +1 -0
- package/dist/lib/network.d.ts +29 -0
- package/dist/lib/references.d.ts +25 -0
- package/dist/lib/render.d.ts +3 -0
- package/dist/lib/resource-manager.d.ts +25 -0
- package/dist/lib/types.d.ts +144 -0
- package/dist/lib/widgets/adaptive-layout.d.ts +10 -0
- package/dist/lib/widgets/bindings.d.ts +33 -0
- package/dist/lib/widgets/button.d.ts +11 -0
- package/dist/lib/widgets/checkbox.d.ts +11 -0
- package/dist/lib/widgets/combobox.d.ts +9 -0
- package/dist/lib/widgets/conditional-container.d.ts +21 -0
- package/dist/lib/widgets/container-layout.d.ts +39 -0
- package/dist/lib/widgets/context-menu.d.ts +14 -0
- package/dist/lib/widgets/context.d.ts +58 -0
- package/dist/lib/widgets/delegation.d.ts +30 -0
- package/dist/lib/widgets/edit.d.ts +12 -0
- package/dist/lib/widgets/grid-view.d.ts +9 -0
- package/dist/lib/widgets/image.d.ts +7 -0
- package/dist/lib/widgets/link.d.ts +10 -0
- package/dist/lib/widgets/list.d.ts +9 -0
- package/dist/lib/widgets/listbox.d.ts +9 -0
- package/dist/lib/widgets/md-text.d.ts +9 -0
- package/dist/lib/widgets/modal-window.d.ts +15 -0
- package/dist/lib/widgets/overlay-container.d.ts +11 -0
- package/dist/lib/widgets/panel.d.ts +9 -0
- package/dist/lib/widgets/radio-group.d.ts +9 -0
- package/dist/lib/widgets/splitter.d.ts +6 -0
- package/dist/lib/widgets/spoiler.d.ts +9 -0
- package/dist/lib/widgets/static-text.d.ts +10 -0
- package/dist/lib/widgets/tabs.d.ts +10 -0
- package/dist/lib/widgets/textarea.d.ts +10 -0
- package/dist/lib/widgets/ui-reference.d.ts +9 -0
- package/package.json +61 -0
- package/vjt-styles.css +756 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ActionDefinition, ActionMap, DescriptionNode, WidgetEventName, WidgetState } from './types.js';
|
|
2
|
+
export type ActionExecutionContext = {
|
|
3
|
+
currentValue: unknown;
|
|
4
|
+
responseValue?: unknown;
|
|
5
|
+
pointer?: {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
} | null;
|
|
9
|
+
};
|
|
10
|
+
type ActionRuntimeOptions = {
|
|
11
|
+
actionsMap: ActionMap;
|
|
12
|
+
actionFunctions: Record<string, () => unknown>;
|
|
13
|
+
nodeById: Map<string, DescriptionNode>;
|
|
14
|
+
stateById: Map<string, WidgetState>;
|
|
15
|
+
rerenderRoot: () => Promise<void>;
|
|
16
|
+
dispatchWidgetEvent: (node: DescriptionNode, eventName: WidgetEventName, key: string, inputValue?: unknown, pointer?: {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
} | null) => Promise<void>;
|
|
20
|
+
executeRequest: (requestName: string, currentValue: unknown) => Promise<unknown>;
|
|
21
|
+
resolveReference: (reference: string, currentValue: unknown, responseValue: unknown) => unknown;
|
|
22
|
+
assignReference: (reference: string, inputValue: unknown, currentValue: unknown) => void;
|
|
23
|
+
resolveMappedValue: (template: unknown, currentValue: unknown, responseValue: unknown) => unknown;
|
|
24
|
+
setWidgetEnabled: (widgetId: string, enabled: boolean) => void;
|
|
25
|
+
clearWidget: (widgetId: string) => void;
|
|
26
|
+
setUiReference: (widgetId: string, resourceRef: string) => void;
|
|
27
|
+
refreshWidgetTree: (widgetId: string) => Promise<void>;
|
|
28
|
+
renderWidgetTree: (widgetId: string) => Promise<void>;
|
|
29
|
+
getContextMenuPosition: (menuId: string, pointer?: {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
} | null) => {
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
};
|
|
36
|
+
setActiveContextMenu: (menu: {
|
|
37
|
+
id: string;
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
} | null) => void;
|
|
41
|
+
setActiveModalId: (modalId: string | null) => void;
|
|
42
|
+
closeModal: (modalId?: string | null) => void;
|
|
43
|
+
getInlineActions: (node: DescriptionNode) => ActionDefinition[] | undefined;
|
|
44
|
+
isWidgetEnabled: (node: DescriptionNode, key: string) => boolean;
|
|
45
|
+
};
|
|
46
|
+
export declare class ActionRuntime {
|
|
47
|
+
private readonly actionsMap;
|
|
48
|
+
private readonly actionFunctions;
|
|
49
|
+
private readonly nodeById;
|
|
50
|
+
private readonly stateById;
|
|
51
|
+
private readonly rerenderRoot;
|
|
52
|
+
private readonly dispatchWidgetEventImpl;
|
|
53
|
+
private readonly executeRequest;
|
|
54
|
+
private readonly resolveReference;
|
|
55
|
+
private readonly assignReference;
|
|
56
|
+
private readonly resolveMappedValue;
|
|
57
|
+
private readonly setWidgetEnabled;
|
|
58
|
+
private readonly clearWidget;
|
|
59
|
+
private readonly setUiReference;
|
|
60
|
+
private readonly refreshWidgetTree;
|
|
61
|
+
private readonly renderWidgetTree;
|
|
62
|
+
private readonly getContextMenuPosition;
|
|
63
|
+
private readonly setActiveContextMenu;
|
|
64
|
+
private readonly setActiveModalId;
|
|
65
|
+
private readonly closeModal;
|
|
66
|
+
private readonly getInlineActions;
|
|
67
|
+
private readonly isWidgetEnabled;
|
|
68
|
+
constructor(options: ActionRuntimeOptions);
|
|
69
|
+
dispatchWidgetEvent(node: DescriptionNode, eventName: WidgetEventName, key: string, inputValue?: unknown, pointer?: {
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
72
|
+
} | null): Promise<void>;
|
|
73
|
+
runActions(actions: ActionDefinition[], inputValue: unknown, context: ActionExecutionContext): Promise<unknown>;
|
|
74
|
+
getInlineActionsForNode(node: DescriptionNode): ActionDefinition[] | undefined;
|
|
75
|
+
private runSingleAction;
|
|
76
|
+
private executeAction;
|
|
77
|
+
}
|
|
78
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { DescriptionNode, ListElementContext, WidgetState } from './types.js';
|
|
2
|
+
export type PreservedElementState = {
|
|
3
|
+
activeId: string | null;
|
|
4
|
+
values: Map<string, string>;
|
|
5
|
+
checked: Map<string, boolean>;
|
|
6
|
+
windowScroll: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
scrollPositions: Array<{
|
|
11
|
+
id?: string;
|
|
12
|
+
widgetKey?: string;
|
|
13
|
+
top: number;
|
|
14
|
+
left: number;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
17
|
+
export declare function isElementInsidePendingResetModal(element: HTMLElement, pendingResetModalIds: Set<string>): boolean;
|
|
18
|
+
export declare function captureElementState(root: HTMLElement, pendingResetModalIds: Set<string>, stateByKey: Map<string, WidgetState>): PreservedElementState;
|
|
19
|
+
export declare function restoreElementState(root: HTMLElement, state: PreservedElementState): void;
|
|
20
|
+
export declare function adjustContextMenuPosition(root: HTMLElement, activeContextMenu: {
|
|
21
|
+
id: string;
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
} | null): {
|
|
25
|
+
id: string;
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
} | null;
|
|
29
|
+
export declare function updatePointerFromMouseEvent(event: MouseEvent): {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
};
|
|
33
|
+
export declare function getListElementContextFromElement(element: HTMLElement, stateByKey: Map<string, WidgetState>): ListElementContext | null;
|
|
34
|
+
export declare function getActionInputValueForElement(element: HTMLElement, node: DescriptionNode, stateByKey: Map<string, WidgetState>): unknown;
|
|
35
|
+
export declare function getContextMenuPosition(menuId: string, pointer: {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
} | null, lastPointer: {
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
}, nodeById: Map<string, DescriptionNode>): {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
};
|
|
45
|
+
export declare function redispatchUnderlyingClick(root: HTMLElement | null, clientX: number, clientY: number): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { WidgetState } from './types.js';
|
|
2
|
+
import type { ConditionExpression } from './widgets/conditional-container.js';
|
|
3
|
+
import type { CellConstraints, ContainerCell, ContainerLayoutNode } from './widgets/container-layout.js';
|
|
4
|
+
export declare function resolveCellSpaces(children: ContainerCell[] | undefined): number[];
|
|
5
|
+
export declare function getResolvedContainerSpaces(node: ContainerLayoutNode, state: WidgetState): number[];
|
|
6
|
+
export declare function buildCellBoxStyle(cell: CellConstraints, axis: 'horizontal' | 'vertical' | 'grid', space?: number): string;
|
|
7
|
+
export declare function buildSwellBoxStyle(maySwellHorizontally: unknown, maySwellVertically: unknown, normalizeBoolean: (value: unknown, fallback: boolean) => boolean, options?: {
|
|
8
|
+
horizontallyScrollable?: boolean;
|
|
9
|
+
verticallyScrollable?: boolean;
|
|
10
|
+
}): string[];
|
|
11
|
+
export declare function evaluateConditionExpression(expression: ConditionExpression, currentValue: unknown, resolveReference: (reference: string, currentValue: unknown, responseValue: unknown) => unknown): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function logRuntimeError(scope: string, error: unknown, details?: Record<string, unknown>): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ActionDefinition, PrimitiveRequestType, RequestMap, RequestSchema, SseConfig } from './types.js';
|
|
2
|
+
type ActionRunner = (actions: ActionDefinition[], inputValue: unknown, context: {
|
|
3
|
+
currentValue: unknown;
|
|
4
|
+
responseValue?: unknown;
|
|
5
|
+
}) => Promise<unknown>;
|
|
6
|
+
type NetworkRuntimeOptions = {
|
|
7
|
+
requestsMap: RequestMap;
|
|
8
|
+
sseConfigs: SseConfig[];
|
|
9
|
+
backendUrl?: string;
|
|
10
|
+
eventSources: EventSource[];
|
|
11
|
+
runActions: ActionRunner;
|
|
12
|
+
rerenderRoot: () => Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
export declare class NetworkRuntime {
|
|
15
|
+
private readonly requestsMap;
|
|
16
|
+
private readonly sseConfigs;
|
|
17
|
+
private readonly backendUrl?;
|
|
18
|
+
private readonly eventSources;
|
|
19
|
+
private readonly runActions;
|
|
20
|
+
private readonly rerenderRoot;
|
|
21
|
+
constructor(options: NetworkRuntimeOptions);
|
|
22
|
+
connectSseStreams(): void;
|
|
23
|
+
executeRequest(requestName: string, currentValue: unknown): Promise<unknown>;
|
|
24
|
+
buildSchemaValue(schema: RequestSchema, currentValue: unknown, responseValue: unknown): Promise<unknown>;
|
|
25
|
+
private stringifyPrimitive;
|
|
26
|
+
coercePrimitiveSchemaValue(type: PrimitiveRequestType, value: unknown): unknown;
|
|
27
|
+
private handleSseEvent;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DescriptionNode, GridViewNode, ListNode, ListElementContext, WidgetState } from './types.js';
|
|
2
|
+
type ReferenceRuntimeHost = {
|
|
3
|
+
readonly stateById: Map<string, WidgetState>;
|
|
4
|
+
readonly stateByKey: Map<string, WidgetState>;
|
|
5
|
+
readonly nodeById: Map<string, DescriptionNode>;
|
|
6
|
+
readonly nodeByKey: Map<string, DescriptionNode>;
|
|
7
|
+
getAppValue: (name: string) => unknown;
|
|
8
|
+
setAppValue: (name: string, value: unknown) => void;
|
|
9
|
+
ensureWidgetState: (node: DescriptionNode, key: string) => WidgetState;
|
|
10
|
+
resolveItemNodeKey: (node: DescriptionNode, listKey: string, index: number, fallbackPath: string) => string;
|
|
11
|
+
indexListElementNodes: (listNode: ListNode | GridViewNode, element: DescriptionNode, index: number) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare class ReferenceRuntime {
|
|
14
|
+
private readonly host;
|
|
15
|
+
constructor(host: ReferenceRuntimeHost);
|
|
16
|
+
resolveReference(reference: string, currentValue: unknown, responseValue: unknown): unknown;
|
|
17
|
+
resolveCurrentReference(reference: string, currentValue: unknown): unknown;
|
|
18
|
+
readWidgetField(state: WidgetState, field: string): unknown;
|
|
19
|
+
assignReference(reference: string, inputValue: unknown, _currentValue: unknown): void;
|
|
20
|
+
clearListElementState(listKey: string): void;
|
|
21
|
+
resolveMappedValue(template: unknown, currentValue: unknown, responseValue: unknown): unknown;
|
|
22
|
+
isListElementContext(value: unknown): value is ListElementContext;
|
|
23
|
+
findNamedWidget(node: DescriptionNode | undefined, name: string): DescriptionNode | null;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DescriptionNode, MountJsonOptions, RenderJsonOptions } from './types.js';
|
|
2
|
+
export declare function renderJson(description: DescriptionNode, options?: RenderJsonOptions): string;
|
|
3
|
+
export declare function renderApp(root: HTMLElement, description: DescriptionNode, options?: MountJsonOptions): () => void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ActionMap, DescriptionNode, I18nMap, RequestMap, SseConfig, StyleMap } from './types.js';
|
|
2
|
+
export type ResourceManagerInput = {
|
|
3
|
+
ui?: Record<string, DescriptionNode>;
|
|
4
|
+
actions?: ActionMap;
|
|
5
|
+
requests?: RequestMap;
|
|
6
|
+
sse?: Record<string, SseConfig>;
|
|
7
|
+
i18n?: I18nMap;
|
|
8
|
+
styles?: StyleMap;
|
|
9
|
+
};
|
|
10
|
+
export declare class ResourceManager {
|
|
11
|
+
private readonly ui;
|
|
12
|
+
private actions;
|
|
13
|
+
private requests;
|
|
14
|
+
private sse;
|
|
15
|
+
private i18n;
|
|
16
|
+
private styles;
|
|
17
|
+
constructor(input?: ResourceManagerInput);
|
|
18
|
+
getUi(name: string): DescriptionNode | null;
|
|
19
|
+
setUi(name: string, description: DescriptionNode): void;
|
|
20
|
+
getActionsMap(): ActionMap;
|
|
21
|
+
getRequestsMap(): RequestMap;
|
|
22
|
+
getSseConfigs(): SseConfig[];
|
|
23
|
+
getI18n(): I18nMap;
|
|
24
|
+
getStyleMap(): StyleMap;
|
|
25
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
export type Theme = 'light' | 'dark';
|
|
2
|
+
export type LayoutType = 'vertical' | 'horizontal' | 'grid';
|
|
3
|
+
export type TextAlign = 'left' | 'center' | 'right';
|
|
4
|
+
export type VerticalAlign = 'top' | 'center' | 'bottom';
|
|
5
|
+
export type HeadingTag = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
6
|
+
export type WidgetEventName = 'onClick' | 'onUserValueChange' | 'onRefresh';
|
|
7
|
+
export type PrimitiveRequestType = 'int' | 'float' | 'boolean' | 'string';
|
|
8
|
+
export type ActionDefinition = {
|
|
9
|
+
action: string;
|
|
10
|
+
andThen?: ActionDefinition[];
|
|
11
|
+
args?: unknown;
|
|
12
|
+
};
|
|
13
|
+
export type RequestSchema = {
|
|
14
|
+
type: 'object';
|
|
15
|
+
name?: string;
|
|
16
|
+
source?: ActionDefinition[];
|
|
17
|
+
properties?: RequestSchema[];
|
|
18
|
+
} | {
|
|
19
|
+
type: 'array';
|
|
20
|
+
name?: string;
|
|
21
|
+
source?: ActionDefinition[];
|
|
22
|
+
elements: RequestSchema;
|
|
23
|
+
} | {
|
|
24
|
+
type: PrimitiveRequestType;
|
|
25
|
+
name?: string;
|
|
26
|
+
source?: ActionDefinition[];
|
|
27
|
+
maxLength?: number;
|
|
28
|
+
regexp?: string;
|
|
29
|
+
};
|
|
30
|
+
export type RequestDefinition = {
|
|
31
|
+
name: string;
|
|
32
|
+
url?: string;
|
|
33
|
+
request: RequestSchema;
|
|
34
|
+
response?: RequestSchema;
|
|
35
|
+
onResponse?: ActionDefinition[];
|
|
36
|
+
};
|
|
37
|
+
export type SseEventDefinition = {
|
|
38
|
+
name: string;
|
|
39
|
+
message?: RequestSchema;
|
|
40
|
+
onEvent?: ActionDefinition[];
|
|
41
|
+
};
|
|
42
|
+
export type SseConfig = {
|
|
43
|
+
url: string;
|
|
44
|
+
events?: SseEventDefinition[];
|
|
45
|
+
};
|
|
46
|
+
type WidgetEvents = Partial<Record<WidgetEventName, ActionDefinition[]>>;
|
|
47
|
+
export type BaseNode = {
|
|
48
|
+
id?: string;
|
|
49
|
+
name?: string;
|
|
50
|
+
style?: string | string[];
|
|
51
|
+
css?: string;
|
|
52
|
+
enabled?: boolean | string;
|
|
53
|
+
events?: WidgetEvents;
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
};
|
|
56
|
+
import type { AdaptiveLayoutNode } from './widgets/adaptive-layout.js';
|
|
57
|
+
import type { ButtonNode } from './widgets/button.js';
|
|
58
|
+
import type { CheckboxNode } from './widgets/checkbox.js';
|
|
59
|
+
import type { ComboboxNode } from './widgets/combobox.js';
|
|
60
|
+
import type { ConditionExpression, ConditionalContainerNode } from './widgets/conditional-container.js';
|
|
61
|
+
import type { CellConstraints, ContainerCell, ContainerLayoutNode } from './widgets/container-layout.js';
|
|
62
|
+
import type { ContextMenuNode } from './widgets/context-menu.js';
|
|
63
|
+
import type { EditNode } from './widgets/edit.js';
|
|
64
|
+
import type { GridViewNode } from './widgets/grid-view.js';
|
|
65
|
+
import type { ImageNode } from './widgets/image.js';
|
|
66
|
+
import type { LinkNode } from './widgets/link.js';
|
|
67
|
+
import type { ListNode } from './widgets/list.js';
|
|
68
|
+
import type { ListboxNode } from './widgets/listbox.js';
|
|
69
|
+
import type { MdTextNode } from './widgets/md-text.js';
|
|
70
|
+
import type { ModalWindowNode } from './widgets/modal-window.js';
|
|
71
|
+
import type { OverlayContainerNode, OverlayLayer } from './widgets/overlay-container.js';
|
|
72
|
+
import type { PanelNode } from './widgets/panel.js';
|
|
73
|
+
import type { RadioGroupNode } from './widgets/radio-group.js';
|
|
74
|
+
import type { SpoilerNode } from './widgets/spoiler.js';
|
|
75
|
+
import type { SplitterNode } from './widgets/splitter.js';
|
|
76
|
+
import type { StaticTextNode } from './widgets/static-text.js';
|
|
77
|
+
import type { TabsNode } from './widgets/tabs.js';
|
|
78
|
+
import type { TextareaNode } from './widgets/textarea.js';
|
|
79
|
+
import type { UiReferenceNode } from './widgets/ui-reference.js';
|
|
80
|
+
import type { ResourceManager } from './resource-manager.js';
|
|
81
|
+
export type DescriptionNode = AdaptiveLayoutNode | ContainerLayoutNode | ConditionalContainerNode | ListNode | GridViewNode | ListboxNode | ComboboxNode | PanelNode | StaticTextNode | MdTextNode | EditNode | TextareaNode | ButtonNode | CheckboxNode | ImageNode | LinkNode | RadioGroupNode | SplitterNode | OverlayContainerNode | TabsNode | SpoilerNode | UiReferenceNode | ContextMenuNode | ModalWindowNode;
|
|
82
|
+
export type StyleMap = Record<string, string>;
|
|
83
|
+
export type I18nMap = Record<string, Record<string, string>>;
|
|
84
|
+
export type ActionMap = Record<string, ActionDefinition[]>;
|
|
85
|
+
export type RequestMap = Record<string, RequestDefinition>;
|
|
86
|
+
export type SseConfigInput = SseConfig | SseConfig[];
|
|
87
|
+
export type WidgetState = {
|
|
88
|
+
key: string;
|
|
89
|
+
widget: DescriptionNode['widget'];
|
|
90
|
+
id?: string;
|
|
91
|
+
name?: string;
|
|
92
|
+
currentRef?: string;
|
|
93
|
+
text?: string;
|
|
94
|
+
url?: string;
|
|
95
|
+
placeholder?: string;
|
|
96
|
+
enabled?: boolean;
|
|
97
|
+
editable?: boolean;
|
|
98
|
+
checked?: boolean;
|
|
99
|
+
condition?: boolean;
|
|
100
|
+
elements?: DescriptionNode[];
|
|
101
|
+
selected?: number;
|
|
102
|
+
borderVisible?: boolean;
|
|
103
|
+
rowSize?: number;
|
|
104
|
+
listboxElements?: Array<Record<string, unknown>>;
|
|
105
|
+
comboboxElements?: Array<Record<string, unknown>>;
|
|
106
|
+
layoutSpaces?: number[];
|
|
107
|
+
modalWidth?: number;
|
|
108
|
+
modalHeight?: number;
|
|
109
|
+
activeTab?: number;
|
|
110
|
+
isHidden?: boolean;
|
|
111
|
+
};
|
|
112
|
+
export type RuntimeSnapshot = {
|
|
113
|
+
stateByKey: Array<[string, WidgetState]>;
|
|
114
|
+
activeModalId: string | null;
|
|
115
|
+
activeContextMenu: {
|
|
116
|
+
id: string;
|
|
117
|
+
x: number;
|
|
118
|
+
y: number;
|
|
119
|
+
} | null;
|
|
120
|
+
};
|
|
121
|
+
export type ListElementContext = {
|
|
122
|
+
kind: 'list-element';
|
|
123
|
+
listId: string;
|
|
124
|
+
index: number;
|
|
125
|
+
descriptor: DescriptionNode;
|
|
126
|
+
};
|
|
127
|
+
export type RenderJsonOptions = {
|
|
128
|
+
styleMap?: StyleMap;
|
|
129
|
+
i18n?: I18nMap;
|
|
130
|
+
language?: string;
|
|
131
|
+
theme?: Theme;
|
|
132
|
+
actionsMap?: ActionMap;
|
|
133
|
+
requestsMap?: RequestMap;
|
|
134
|
+
sseConfigs?: SseConfigInput;
|
|
135
|
+
actionFunctions?: Record<string, () => unknown>;
|
|
136
|
+
backendUrl?: string;
|
|
137
|
+
resourceManager?: ResourceManager;
|
|
138
|
+
runtimeSnapshot?: RuntimeSnapshot;
|
|
139
|
+
onRuntimeSnapshot?: (snapshot: RuntimeSnapshot) => void;
|
|
140
|
+
};
|
|
141
|
+
export type MountJsonOptions = RenderJsonOptions & {
|
|
142
|
+
afterRender?: (root: HTMLElement) => void;
|
|
143
|
+
};
|
|
144
|
+
export type { AdaptiveLayoutNode, ButtonNode, CellConstraints, CheckboxNode, ComboboxNode, ConditionExpression, ConditionalContainerNode, ContainerCell, ContainerLayoutNode, ContextMenuNode, EditNode, GridViewNode, ImageNode, LinkNode, ListNode, ListboxNode, MdTextNode, ModalWindowNode, OverlayContainerNode, OverlayLayer, PanelNode, RadioGroupNode, SpoilerNode, SplitterNode, StaticTextNode, TabsNode, TextareaNode, UiReferenceNode };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BaseNode, DescriptionNode } from '../types.js';
|
|
2
|
+
import type { WidgetRenderer } from './context.js';
|
|
3
|
+
export type AdaptiveLayoutNode = BaseNode & {
|
|
4
|
+
widget: 'adaptive-layout';
|
|
5
|
+
maySwellHorizontally?: boolean | string;
|
|
6
|
+
maySwellVertically?: boolean | string;
|
|
7
|
+
desktop?: DescriptionNode;
|
|
8
|
+
mobile?: DescriptionNode;
|
|
9
|
+
};
|
|
10
|
+
export declare const renderAdaptiveLayout: WidgetRenderer<AdaptiveLayoutNode>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { DescriptionNode, WidgetState } from '../types.js';
|
|
2
|
+
type BindingEnvironment = {
|
|
3
|
+
nodeByKey: Map<string, DescriptionNode>;
|
|
4
|
+
stateByKey: Map<string, WidgetState>;
|
|
5
|
+
lastPointer: {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
};
|
|
9
|
+
setLastPointer: (pointer: {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
}) => void;
|
|
13
|
+
updatePointerFromEvent: (event: MouseEvent) => void;
|
|
14
|
+
updateOwningListElementDescriptor: (element: HTMLElement, mutate: (descriptor: DescriptionNode) => void) => void;
|
|
15
|
+
dispatchWidgetEvent: (node: DescriptionNode, eventName: 'onClick' | 'onUserValueChange', key: string, inputValue?: unknown, pointer?: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
} | null) => Promise<void>;
|
|
19
|
+
rerenderRoot: () => Promise<void>;
|
|
20
|
+
getInlineActions: (node: DescriptionNode) => Array<{
|
|
21
|
+
action: string;
|
|
22
|
+
andThen?: unknown[];
|
|
23
|
+
args?: unknown;
|
|
24
|
+
}> | undefined;
|
|
25
|
+
getActionInputValueForElement: (element: HTMLElement, node: DescriptionNode) => unknown;
|
|
26
|
+
createDateValidator: (format: string) => (value: string) => string;
|
|
27
|
+
getDefaultDateFormat: () => string;
|
|
28
|
+
parseSteppedValue: (input: HTMLInputElement) => number | null;
|
|
29
|
+
formatSteppedValue: (kind: string, value: number) => string;
|
|
30
|
+
};
|
|
31
|
+
export declare function bindWidgetInputBehavior(root: HTMLElement, env: BindingEnvironment): void;
|
|
32
|
+
export declare function bindWidgetEvents(root: HTMLElement, env: BindingEnvironment): void;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ActionDefinition, BaseNode } from '../types.js';
|
|
2
|
+
import type { WidgetRenderer } from './context.js';
|
|
3
|
+
export type ButtonNode = BaseNode & {
|
|
4
|
+
widget: 'button';
|
|
5
|
+
text?: string;
|
|
6
|
+
enabled?: boolean | string;
|
|
7
|
+
type?: 'button' | 'submit';
|
|
8
|
+
color?: 'bright' | 'regular';
|
|
9
|
+
actions?: ActionDefinition[];
|
|
10
|
+
};
|
|
11
|
+
export declare const renderButton: WidgetRenderer<ButtonNode>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BaseNode, HeadingTag } from '../types.js';
|
|
2
|
+
import type { WidgetRenderer } from './context.js';
|
|
3
|
+
export type CheckboxNode = BaseNode & {
|
|
4
|
+
widget: 'checkbox';
|
|
5
|
+
type?: 'switch' | 'check';
|
|
6
|
+
text?: string;
|
|
7
|
+
checked?: boolean | string;
|
|
8
|
+
enabled?: boolean | string;
|
|
9
|
+
heading?: HeadingTag;
|
|
10
|
+
};
|
|
11
|
+
export declare const renderCheckbox: WidgetRenderer<CheckboxNode>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BaseNode } from '../types.js';
|
|
2
|
+
import type { WidgetRenderer } from './context.js';
|
|
3
|
+
export type ComboboxNode = BaseNode & {
|
|
4
|
+
widget: 'combobox';
|
|
5
|
+
size?: number;
|
|
6
|
+
selected?: number | string;
|
|
7
|
+
elements?: Array<Record<string, unknown>>;
|
|
8
|
+
};
|
|
9
|
+
export declare const renderCombobox: WidgetRenderer<ComboboxNode>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BaseNode, DescriptionNode } from '../types.js';
|
|
2
|
+
import type { WidgetRenderer } from './context.js';
|
|
3
|
+
export type ConditionExpression = {
|
|
4
|
+
equals: {
|
|
5
|
+
left: unknown;
|
|
6
|
+
right: unknown;
|
|
7
|
+
};
|
|
8
|
+
} | {
|
|
9
|
+
and: ConditionExpression[];
|
|
10
|
+
} | {
|
|
11
|
+
or: ConditionExpression[];
|
|
12
|
+
};
|
|
13
|
+
export type ConditionalContainerNode = BaseNode & {
|
|
14
|
+
widget: 'conditional-container';
|
|
15
|
+
maySwellHorizontally?: boolean | string;
|
|
16
|
+
maySwellVertically?: boolean | string;
|
|
17
|
+
condition?: boolean | string | ConditionExpression;
|
|
18
|
+
default?: DescriptionNode;
|
|
19
|
+
alternative?: DescriptionNode;
|
|
20
|
+
};
|
|
21
|
+
export declare const renderConditionalContainer: WidgetRenderer<ConditionalContainerNode>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { BaseNode, DescriptionNode, LayoutType } from '../types.js';
|
|
2
|
+
import type { WidgetRenderer } from './context.js';
|
|
3
|
+
export type CellConstraints = {
|
|
4
|
+
space?: number | string;
|
|
5
|
+
minWidthPx?: number | string;
|
|
6
|
+
maxWidthPx?: number | string;
|
|
7
|
+
minHeightPx?: number | string;
|
|
8
|
+
maxHeightPx?: number | string;
|
|
9
|
+
marginTopPx?: number | string;
|
|
10
|
+
marginRightPx?: number | string;
|
|
11
|
+
marginBottomPx?: number | string;
|
|
12
|
+
marginLeftPx?: number | string;
|
|
13
|
+
};
|
|
14
|
+
export type ContainerCell = CellConstraints & {
|
|
15
|
+
child?: DescriptionNode;
|
|
16
|
+
};
|
|
17
|
+
type GridColumn = {
|
|
18
|
+
child?: DescriptionNode;
|
|
19
|
+
};
|
|
20
|
+
type GridRow = {
|
|
21
|
+
space?: number | string;
|
|
22
|
+
columns?: GridColumn[];
|
|
23
|
+
};
|
|
24
|
+
export type ContainerLayoutNode = BaseNode & {
|
|
25
|
+
widget: 'container-layout';
|
|
26
|
+
type?: LayoutType;
|
|
27
|
+
cellsVisible?: boolean | string;
|
|
28
|
+
verticallyScrollable?: boolean | string;
|
|
29
|
+
horizontallyScrollable?: boolean | string;
|
|
30
|
+
maySwellHorizontally?: boolean | string;
|
|
31
|
+
maySwellVertically?: boolean | string;
|
|
32
|
+
children?: ContainerCell[];
|
|
33
|
+
grid?: {
|
|
34
|
+
columnWidth?: Array<number | string>;
|
|
35
|
+
rows?: GridRow[];
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export declare const renderContainerLayout: WidgetRenderer<ContainerLayoutNode>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ActionDefinition, BaseNode } from '../types.js';
|
|
2
|
+
import type { WidgetRenderEnvironment } from './context.js';
|
|
3
|
+
export type ContextMenuNode = BaseNode & {
|
|
4
|
+
widget: 'context-menu';
|
|
5
|
+
items?: Array<{
|
|
6
|
+
name: string;
|
|
7
|
+
actions?: ActionDefinition[];
|
|
8
|
+
}>;
|
|
9
|
+
};
|
|
10
|
+
export declare function renderContextMenuOverlay(env: WidgetRenderEnvironment, menu: {
|
|
11
|
+
id: string;
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
}): string;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { DescriptionNode, EditNode, ListElementContext, WidgetState } from '../types.js';
|
|
2
|
+
import type { AdaptiveLayoutNode } from './adaptive-layout.js';
|
|
3
|
+
import type { ButtonNode } from './button.js';
|
|
4
|
+
import type { CheckboxNode } from './checkbox.js';
|
|
5
|
+
import type { ComboboxNode } from './combobox.js';
|
|
6
|
+
import type { ConditionalContainerNode } from './conditional-container.js';
|
|
7
|
+
import type { ContainerCell, ContainerLayoutNode } from './container-layout.js';
|
|
8
|
+
import type { ContextMenuNode } from './context-menu.js';
|
|
9
|
+
import type { GridViewNode } from './grid-view.js';
|
|
10
|
+
import type { ImageNode } from './image.js';
|
|
11
|
+
import type { LinkNode } from './link.js';
|
|
12
|
+
import type { ListNode } from './list.js';
|
|
13
|
+
import type { ListboxNode } from './listbox.js';
|
|
14
|
+
import type { MdTextNode } from './md-text.js';
|
|
15
|
+
import type { ModalWindowNode } from './modal-window.js';
|
|
16
|
+
import type { OverlayContainerNode } from './overlay-container.js';
|
|
17
|
+
import type { PanelNode } from './panel.js';
|
|
18
|
+
import type { RadioGroupNode } from './radio-group.js';
|
|
19
|
+
import type { SpoilerNode } from './spoiler.js';
|
|
20
|
+
import type { SplitterNode } from './splitter.js';
|
|
21
|
+
import type { StaticTextNode } from './static-text.js';
|
|
22
|
+
import type { TabsNode } from './tabs.js';
|
|
23
|
+
import type { TextareaNode } from './textarea.js';
|
|
24
|
+
import type { UiReferenceNode } from './ui-reference.js';
|
|
25
|
+
export type WidgetRenderEnvironment = {
|
|
26
|
+
readonly activeContextMenu: {
|
|
27
|
+
id: string;
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
} | null;
|
|
31
|
+
readonly activeModalId: string | null;
|
|
32
|
+
readonly nodeById: Map<string, DescriptionNode>;
|
|
33
|
+
escapeHtml: (value: unknown) => string;
|
|
34
|
+
buildStyleString: (node: DescriptionNode) => string;
|
|
35
|
+
resolveI18nValue: (value: string | undefined) => string;
|
|
36
|
+
getUiResource: (ref: string) => DescriptionNode | null;
|
|
37
|
+
resolveReference: (reference: string, currentValue: unknown, responseValue: unknown) => unknown;
|
|
38
|
+
buildWidgetDataAttributes: (key: string, node: DescriptionNode) => string;
|
|
39
|
+
ensureWidgetState: (node: DescriptionNode, key: string) => WidgetState;
|
|
40
|
+
renderNode: (node: DescriptionNode | undefined, path: string, itemContext: ListElementContext | null) => string;
|
|
41
|
+
resolveItemNodeKey: (node: DescriptionNode, listKey: string, index: number, fallbackPath: string) => string;
|
|
42
|
+
resolveNodeKey: (node: DescriptionNode, fallbackPath: string) => string;
|
|
43
|
+
indexListElementNodes: (listNode: ListNode | GridViewNode, element: DescriptionNode, index: number) => void;
|
|
44
|
+
normalizeBoolean: (value: unknown, fallback: boolean) => boolean;
|
|
45
|
+
toFiniteNumber: (value: unknown) => number | null;
|
|
46
|
+
getDateFormat: (node: EditNode) => string;
|
|
47
|
+
isStepperEdit: (node: EditNode) => boolean;
|
|
48
|
+
getResolvedContainerSpaces: (node: ContainerLayoutNode, state: WidgetState) => number[];
|
|
49
|
+
buildCellBoxStyle: (cell: ContainerCell, axis: 'horizontal' | 'vertical' | 'grid', space?: number) => string;
|
|
50
|
+
buildSwellBoxStyle: (maySwellHorizontally: unknown, maySwellVertically: unknown, options?: {
|
|
51
|
+
horizontallyScrollable?: boolean;
|
|
52
|
+
verticallyScrollable?: boolean;
|
|
53
|
+
}) => string[];
|
|
54
|
+
evaluateConditionExpression: (expression: unknown, currentValue: unknown) => boolean;
|
|
55
|
+
isMobileViewport: () => boolean;
|
|
56
|
+
};
|
|
57
|
+
export type WidgetRenderer<T extends DescriptionNode> = (env: WidgetRenderEnvironment, node: T, state: WidgetState, key: string, path: string, itemContext: ListElementContext | null) => string;
|
|
58
|
+
export type { AdaptiveLayoutNode, ButtonNode, CheckboxNode, ComboboxNode, ConditionalContainerNode, ContainerCell, ContainerLayoutNode, ContextMenuNode, DescriptionNode, EditNode, GridViewNode, ImageNode, LinkNode, ListElementContext, ListNode, ListboxNode, MdTextNode, ModalWindowNode, OverlayContainerNode, PanelNode, RadioGroupNode, SpoilerNode, SplitterNode, StaticTextNode, TabsNode, TextareaNode, UiReferenceNode, WidgetState };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ActionDefinition, DescriptionNode, WidgetState } from '../types.js';
|
|
2
|
+
type DelegationEnvironment = {
|
|
3
|
+
nodeById: Map<string, DescriptionNode>;
|
|
4
|
+
nodeByKey: Map<string, DescriptionNode>;
|
|
5
|
+
stateByKey: Map<string, WidgetState>;
|
|
6
|
+
getLastPointer: () => {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
setActiveContextMenu: (menu: {
|
|
11
|
+
id: string;
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
} | null) => void;
|
|
15
|
+
isWidgetEnabled: (node: DescriptionNode, key: string) => boolean;
|
|
16
|
+
startSplitterDrag: (layoutKey: string, axis: 'horizontal' | 'vertical', splitterIndex: number, startPointer: number) => void;
|
|
17
|
+
getSplitterDragAxis: () => 'horizontal' | 'vertical' | null;
|
|
18
|
+
updateSplitterDrag: (clientPosition: number) => void;
|
|
19
|
+
stopSplitterDrag: () => void;
|
|
20
|
+
hasSplitterDrag: () => boolean;
|
|
21
|
+
closeModal: (modalId: string | null) => void;
|
|
22
|
+
rerenderRoot: () => Promise<void>;
|
|
23
|
+
redispatchUnderlyingClick: (clientX: number, clientY: number) => void;
|
|
24
|
+
runActions: (actions: ActionDefinition[], inputValue: unknown, context: {
|
|
25
|
+
currentValue: unknown;
|
|
26
|
+
responseValue?: unknown;
|
|
27
|
+
}) => Promise<unknown>;
|
|
28
|
+
};
|
|
29
|
+
export declare function bindDelegatedUi(root: HTMLElement, env: DelegationEnvironment): void;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BaseNode } from '../types.js';
|
|
2
|
+
import type { WidgetRenderer } from './context.js';
|
|
3
|
+
export type EditNode = BaseNode & {
|
|
4
|
+
widget: 'edit';
|
|
5
|
+
text?: string;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
enabled?: boolean | string;
|
|
8
|
+
editable?: boolean | string;
|
|
9
|
+
type?: 'string' | 'number' | 'float' | 'date' | 'password';
|
|
10
|
+
format?: 'yyyy-MM-dd' | 'dd.MM.yyyy';
|
|
11
|
+
};
|
|
12
|
+
export declare const renderEdit: WidgetRenderer<EditNode>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BaseNode, DescriptionNode } from '../types.js';
|
|
2
|
+
import type { WidgetRenderer } from './context.js';
|
|
3
|
+
export type GridViewNode = BaseNode & {
|
|
4
|
+
widget: 'grid-view';
|
|
5
|
+
rowSize?: number | string;
|
|
6
|
+
size?: number;
|
|
7
|
+
elements?: DescriptionNode[];
|
|
8
|
+
};
|
|
9
|
+
export declare const renderGridView: WidgetRenderer<GridViewNode>;
|