athena-ui-js 2.3.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -3
- package/docs/styling.md +123 -103
- package/package.json +8 -1
- package/src/athena-ui.js +5 -1
- package/src/code.js +9 -0
- package/src/libs/config/config.js +1 -1
- package/src/libs/core/codeDiff.js +119 -0
- package/src/libs/core/codeLanguages.js +277 -0
- package/src/libs/core/i18n.js +56 -0
- package/src/libs/hephaestus/codeGenerator/codeEditor.js +1037 -0
- package/src/libs/hephaestus/codeGenerator/codeGenerator.js +286 -0
- package/src/libs/hephaestus/widgetGrid/widgetGrid.js +870 -0
- package/src/res/themes/default/style.css +471 -0
- package/src/res/themes/tokens.css +52 -0
- package/types/athena-ui.d.ts +103 -99
- package/types/code.d.ts +4 -0
- package/types/libs/config/config.d.ts +3 -3
- package/types/libs/core/codeDiff.d.ts +32 -0
- package/types/libs/core/codeLanguages.d.ts +58 -0
- package/types/libs/core/gridLayout.d.ts +45 -45
- package/types/libs/hephaestus/codeGenerator/codeEditor.d.ts +60 -0
- package/types/libs/hephaestus/codeGenerator/codeGenerator.d.ts +99 -0
- package/types/libs/hephaestus/widgetGrid/widgetGrid.d.ts +117 -117
- package/types/widgets.d.ts +2 -2
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Registers a type of widget, so grids can create it, load it from a saved layout and show its settings.
|
|
3
|
-
*
|
|
4
|
-
* @param {string} type name of the type, for example "stat" (it is saved in layouts)
|
|
5
|
-
* @param {object} definition
|
|
6
|
-
* @param {(context: WidgetContext) => (void|Function|{update?: Function, destroy?: Function})} definition.render builds the widget into `context.element`;
|
|
7
|
-
* it may return a function (called when the widget goes away) or an object with `update(context)` and `destroy(context)`
|
|
8
|
-
* @param {(context: WidgetContext) => void} [definition.update] called (throttled) when the config or the title changed; without it the widget is rendered again
|
|
9
|
-
* @param {(context: WidgetContext, size: {width: number, height: number}) => void} [definition.resize] called (throttled) when the body changes its size
|
|
10
|
-
* @param {(context: WidgetContext) => void} [definition.destroy] called when the widget is removed or the grid is destroyed
|
|
11
|
-
* @param {object[]|((widget: object) => object[])} [definition.configForm] field definitions (see generateField) of the settings dialog; the field `name` is the key in the config
|
|
12
|
-
* @param {object} [definition.defaultConfig] config of a new widget
|
|
13
|
-
* @param {string} [definition.title] title of a new widget
|
|
14
|
-
* @param {{w: number, h: number}} [definition.defaultSize={w: 3, h: 2}] size in grid cells
|
|
15
|
-
* @param {{w?: number, h?: number}} [definition.minSize]
|
|
16
|
-
* @param {{w?: number, h?: number}} [definition.maxSize]
|
|
17
|
-
*
|
|
18
|
-
* @typedef {object} WidgetContext
|
|
19
|
-
* @property {string} id
|
|
20
|
-
* @property {string} type
|
|
21
|
-
* @property {HTMLElement} element the body of the widget: build into it
|
|
22
|
-
* @property {object} config the current config (read it again in update())
|
|
23
|
-
* @property {string} title
|
|
24
|
-
* @property {{width: number, height: number}} size
|
|
25
|
-
* @property {(title: string) => void} setTitle
|
|
26
|
-
*/
|
|
27
|
-
export function registerWidget(type: string, definition: {
|
|
28
|
-
render: (context: WidgetContext) => (void | Function | {
|
|
29
|
-
update?: Function;
|
|
30
|
-
destroy?: Function;
|
|
31
|
-
});
|
|
32
|
-
update?: (context: WidgetContext) => void;
|
|
33
|
-
resize?: (context: WidgetContext, size: {
|
|
34
|
-
width: number;
|
|
35
|
-
height: number;
|
|
36
|
-
}) => void;
|
|
37
|
-
destroy?: (context: WidgetContext) => void;
|
|
38
|
-
configForm?: object[] | ((widget: object) => object[]);
|
|
39
|
-
defaultConfig?: object;
|
|
40
|
-
title?: string;
|
|
41
|
-
defaultSize?: {
|
|
42
|
-
w: number;
|
|
43
|
-
h: number;
|
|
44
|
-
};
|
|
45
|
-
minSize?: {
|
|
46
|
-
w?: number;
|
|
47
|
-
h?: number;
|
|
48
|
-
};
|
|
49
|
-
maxSize?: {
|
|
50
|
-
w?: number;
|
|
51
|
-
h?: number;
|
|
52
|
-
};
|
|
53
|
-
}): void;
|
|
54
|
-
/** Forgets a widget type. Widgets of it that are in grids stay and are shown as unknown. */
|
|
55
|
-
export function unregisterWidget(type: any): boolean;
|
|
56
|
-
/** The names of the registered widget types. */
|
|
57
|
-
export function getWidgetTypes(): any[];
|
|
58
|
-
/**
|
|
59
|
-
* A grid of widgets.
|
|
60
|
-
*
|
|
61
|
-
* @param {object} options
|
|
62
|
-
* @param {string|HTMLElement} options.element the container
|
|
63
|
-
* @param {number} [options.columns=12] columns when there are no breakpoints
|
|
64
|
-
* @param {number} [options.rowHeight=80] height of a row in px
|
|
65
|
-
* @param {number} [options.gap=12] gap between widgets in px
|
|
66
|
-
* @param {Record<string, {minWidth?: number, columns: number}>} [options.breakpoints] layouts by the width of the container, for example
|
|
67
|
-
* `{ large: { minWidth: 900, columns: 12 }, small: { minWidth: 0, columns: 4 } }`. A breakpoint without a layout of its own is derived from the widest one.
|
|
68
|
-
* @param {object[]} [options.widgets] first widgets: `{ type, title?, config?, x?, y?, w?, h?, locked?, id? }`
|
|
69
|
-
* @param {object} [options.layout] a saved layout (getLayout()), used instead of `widgets`
|
|
70
|
-
* @param {boolean} [options.editable=false] edit mode: move, resize, settings, duplicate, remove
|
|
71
|
-
* @param {boolean} [options.compact=true] widgets fall upwards when there is room (false: they stay where they are put)
|
|
72
|
-
* @param {boolean} [options.animate=true] widgets slide to their new places (never under reduced motion)
|
|
73
|
-
* @param {string} [options.label] accessible name of the dashboard
|
|
74
|
-
* @param {number} [options.maxWidgets=200]
|
|
75
|
-
* @param {(layout: object, reason: string) => void} [options.onChange] called after a change made by the person or by add/remove/...: "move", "resize", "add", "remove", "duplicate", "settings", "lock", "undo", "redo"
|
|
76
|
-
* @returns the handle: { element, addWidget, removeWidget, duplicateWidget, configureWidget, updateWidget, getWidget, getWidgets, lockWidget, setEditable, isEditable,
|
|
77
|
-
* getLayout, setLayout, undo, redo, canUndo, canRedo, getBreakpoint, destroy }
|
|
78
|
-
*/
|
|
79
|
-
export function createWidgetGrid(options?: {
|
|
80
|
-
element: string | HTMLElement;
|
|
81
|
-
columns?: number;
|
|
82
|
-
rowHeight?: number;
|
|
83
|
-
gap?: number;
|
|
84
|
-
breakpoints?: Record<string, {
|
|
85
|
-
minWidth?: number;
|
|
86
|
-
columns: number;
|
|
87
|
-
}>;
|
|
88
|
-
widgets?: object[];
|
|
89
|
-
layout?: object;
|
|
90
|
-
editable?: boolean;
|
|
91
|
-
compact?: boolean;
|
|
92
|
-
animate?: boolean;
|
|
93
|
-
label?: string;
|
|
94
|
-
maxWidgets?: number;
|
|
95
|
-
onChange?: (layout: object, reason: string) => void;
|
|
96
|
-
}): any;
|
|
97
|
-
/**
|
|
98
|
-
* Registers a type of widget, so grids can create it, load it from a saved layout and show its settings.
|
|
99
|
-
*/
|
|
100
|
-
export type WidgetContext = {
|
|
101
|
-
id: string;
|
|
102
|
-
type: string;
|
|
103
|
-
/**
|
|
104
|
-
* the body of the widget: build into it
|
|
105
|
-
*/
|
|
106
|
-
element: HTMLElement;
|
|
107
|
-
/**
|
|
108
|
-
* the current config (read it again in update())
|
|
109
|
-
*/
|
|
110
|
-
config: object;
|
|
111
|
-
title: string;
|
|
112
|
-
size: {
|
|
113
|
-
width: number;
|
|
114
|
-
height: number;
|
|
115
|
-
};
|
|
116
|
-
setTitle: (title: string) => void;
|
|
117
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Registers a type of widget, so grids can create it, load it from a saved layout and show its settings.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} type name of the type, for example "stat" (it is saved in layouts)
|
|
5
|
+
* @param {object} definition
|
|
6
|
+
* @param {(context: WidgetContext) => (void|Function|{update?: Function, destroy?: Function})} definition.render builds the widget into `context.element`;
|
|
7
|
+
* it may return a function (called when the widget goes away) or an object with `update(context)` and `destroy(context)`
|
|
8
|
+
* @param {(context: WidgetContext) => void} [definition.update] called (throttled) when the config or the title changed; without it the widget is rendered again
|
|
9
|
+
* @param {(context: WidgetContext, size: {width: number, height: number}) => void} [definition.resize] called (throttled) when the body changes its size
|
|
10
|
+
* @param {(context: WidgetContext) => void} [definition.destroy] called when the widget is removed or the grid is destroyed
|
|
11
|
+
* @param {object[]|((widget: object) => object[])} [definition.configForm] field definitions (see generateField) of the settings dialog; the field `name` is the key in the config
|
|
12
|
+
* @param {object} [definition.defaultConfig] config of a new widget
|
|
13
|
+
* @param {string} [definition.title] title of a new widget
|
|
14
|
+
* @param {{w: number, h: number}} [definition.defaultSize={w: 3, h: 2}] size in grid cells
|
|
15
|
+
* @param {{w?: number, h?: number}} [definition.minSize]
|
|
16
|
+
* @param {{w?: number, h?: number}} [definition.maxSize]
|
|
17
|
+
*
|
|
18
|
+
* @typedef {object} WidgetContext
|
|
19
|
+
* @property {string} id
|
|
20
|
+
* @property {string} type
|
|
21
|
+
* @property {HTMLElement} element the body of the widget: build into it
|
|
22
|
+
* @property {object} config the current config (read it again in update())
|
|
23
|
+
* @property {string} title
|
|
24
|
+
* @property {{width: number, height: number}} size
|
|
25
|
+
* @property {(title: string) => void} setTitle
|
|
26
|
+
*/
|
|
27
|
+
export function registerWidget(type: string, definition: {
|
|
28
|
+
render: (context: WidgetContext) => (void | Function | {
|
|
29
|
+
update?: Function;
|
|
30
|
+
destroy?: Function;
|
|
31
|
+
});
|
|
32
|
+
update?: (context: WidgetContext) => void;
|
|
33
|
+
resize?: (context: WidgetContext, size: {
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
}) => void;
|
|
37
|
+
destroy?: (context: WidgetContext) => void;
|
|
38
|
+
configForm?: object[] | ((widget: object) => object[]);
|
|
39
|
+
defaultConfig?: object;
|
|
40
|
+
title?: string;
|
|
41
|
+
defaultSize?: {
|
|
42
|
+
w: number;
|
|
43
|
+
h: number;
|
|
44
|
+
};
|
|
45
|
+
minSize?: {
|
|
46
|
+
w?: number;
|
|
47
|
+
h?: number;
|
|
48
|
+
};
|
|
49
|
+
maxSize?: {
|
|
50
|
+
w?: number;
|
|
51
|
+
h?: number;
|
|
52
|
+
};
|
|
53
|
+
}): void;
|
|
54
|
+
/** Forgets a widget type. Widgets of it that are in grids stay and are shown as unknown. */
|
|
55
|
+
export function unregisterWidget(type: any): boolean;
|
|
56
|
+
/** The names of the registered widget types. */
|
|
57
|
+
export function getWidgetTypes(): any[];
|
|
58
|
+
/**
|
|
59
|
+
* A grid of widgets.
|
|
60
|
+
*
|
|
61
|
+
* @param {object} options
|
|
62
|
+
* @param {string|HTMLElement} options.element the container
|
|
63
|
+
* @param {number} [options.columns=12] columns when there are no breakpoints
|
|
64
|
+
* @param {number} [options.rowHeight=80] height of a row in px
|
|
65
|
+
* @param {number} [options.gap=12] gap between widgets in px
|
|
66
|
+
* @param {Record<string, {minWidth?: number, columns: number}>} [options.breakpoints] layouts by the width of the container, for example
|
|
67
|
+
* `{ large: { minWidth: 900, columns: 12 }, small: { minWidth: 0, columns: 4 } }`. A breakpoint without a layout of its own is derived from the widest one.
|
|
68
|
+
* @param {object[]} [options.widgets] first widgets: `{ type, title?, config?, x?, y?, w?, h?, locked?, id? }`
|
|
69
|
+
* @param {object} [options.layout] a saved layout (getLayout()), used instead of `widgets`
|
|
70
|
+
* @param {boolean} [options.editable=false] edit mode: move, resize, settings, duplicate, remove
|
|
71
|
+
* @param {boolean} [options.compact=true] widgets fall upwards when there is room (false: they stay where they are put)
|
|
72
|
+
* @param {boolean} [options.animate=true] widgets slide to their new places (never under reduced motion)
|
|
73
|
+
* @param {string} [options.label] accessible name of the dashboard
|
|
74
|
+
* @param {number} [options.maxWidgets=200]
|
|
75
|
+
* @param {(layout: object, reason: string) => void} [options.onChange] called after a change made by the person or by add/remove/...: "move", "resize", "add", "remove", "duplicate", "settings", "lock", "undo", "redo"
|
|
76
|
+
* @returns the handle: { element, addWidget, removeWidget, duplicateWidget, configureWidget, updateWidget, getWidget, getWidgets, lockWidget, setEditable, isEditable,
|
|
77
|
+
* getLayout, setLayout, undo, redo, canUndo, canRedo, getBreakpoint, destroy }
|
|
78
|
+
*/
|
|
79
|
+
export function createWidgetGrid(options?: {
|
|
80
|
+
element: string | HTMLElement;
|
|
81
|
+
columns?: number;
|
|
82
|
+
rowHeight?: number;
|
|
83
|
+
gap?: number;
|
|
84
|
+
breakpoints?: Record<string, {
|
|
85
|
+
minWidth?: number;
|
|
86
|
+
columns: number;
|
|
87
|
+
}>;
|
|
88
|
+
widgets?: object[];
|
|
89
|
+
layout?: object;
|
|
90
|
+
editable?: boolean;
|
|
91
|
+
compact?: boolean;
|
|
92
|
+
animate?: boolean;
|
|
93
|
+
label?: string;
|
|
94
|
+
maxWidgets?: number;
|
|
95
|
+
onChange?: (layout: object, reason: string) => void;
|
|
96
|
+
}): any;
|
|
97
|
+
/**
|
|
98
|
+
* Registers a type of widget, so grids can create it, load it from a saved layout and show its settings.
|
|
99
|
+
*/
|
|
100
|
+
export type WidgetContext = {
|
|
101
|
+
id: string;
|
|
102
|
+
type: string;
|
|
103
|
+
/**
|
|
104
|
+
* the body of the widget: build into it
|
|
105
|
+
*/
|
|
106
|
+
element: HTMLElement;
|
|
107
|
+
/**
|
|
108
|
+
* the current config (read it again in update())
|
|
109
|
+
*/
|
|
110
|
+
config: object;
|
|
111
|
+
title: string;
|
|
112
|
+
size: {
|
|
113
|
+
width: number;
|
|
114
|
+
height: number;
|
|
115
|
+
};
|
|
116
|
+
setTitle: (title: string) => void;
|
|
117
|
+
};
|
package/types/widgets.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./libs/hephaestus/widgetGrid/widgetGrid.js";
|
|
2
|
-
export * from "./libs/core/gridLayout.js";
|
|
1
|
+
export * from "./libs/hephaestus/widgetGrid/widgetGrid.js";
|
|
2
|
+
export * from "./libs/core/gridLayout.js";
|