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
package/types/athena-ui.d.ts
CHANGED
|
@@ -1,99 +1,103 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Loads the theme, waits for the page and generates the layout.
|
|
3
|
-
*
|
|
4
|
-
* @param {object} [options]
|
|
5
|
-
* @param {{id?: number, href?: string}} [options.theme] registered theme id or custom stylesheet
|
|
6
|
-
* @param {object} [options.config] settings overriding the defaults (and the global appConfig)
|
|
7
|
-
* @param {Function} [options.nav] navigation callback (falls back to the global nav)
|
|
8
|
-
* @param {Function} [options.login] login callback (falls back to the global login)
|
|
9
|
-
* @param {Function} [options.register] registration callback (falls back to the global register)
|
|
10
|
-
* @param {Function} [options.lostPassword] lost password callback (falls back to the global lostPassword)
|
|
11
|
-
* @param {Function} [options.changePassword] change password callback (falls back to the global changePassword)
|
|
12
|
-
* @param {object} [options.menuItems] { headerMenu, footerMenu } (falls back to the global menuItems)
|
|
13
|
-
* @returns {Promise<object>} the effective configuration
|
|
14
|
-
*/
|
|
15
|
-
export function init(options?: {
|
|
16
|
-
theme?: {
|
|
17
|
-
id?: number;
|
|
18
|
-
href?: string;
|
|
19
|
-
};
|
|
20
|
-
config?: object;
|
|
21
|
-
nav?: Function;
|
|
22
|
-
login?: Function;
|
|
23
|
-
register?: Function;
|
|
24
|
-
lostPassword?: Function;
|
|
25
|
-
changePassword?: Function;
|
|
26
|
-
menuItems?: object;
|
|
27
|
-
}): Promise<object>;
|
|
28
|
-
/**
|
|
29
|
-
* Starts Athena UI inside an element of your page instead of the body, so it can be one part of a larger page (or of several apps).
|
|
30
|
-
* It does what init() does (settings, language, theme, hooks), and the layout (container, header, wrapper, footer) is generated into
|
|
31
|
-
* `root`. The parts follow the settings: `config: { generateHeader: false, generateFooter: false }` leaves only the wrapper, which is where
|
|
32
|
-
* the components go by default (the element with the id "wrapper"). One app per page: the parts have fixed ids.
|
|
33
|
-
*
|
|
34
|
-
* @param {object} options the options of init(), and
|
|
35
|
-
* @param {string|Element} options.root the element to build into (an element, an id or a selector)
|
|
36
|
-
* @returns {Promise<{element: HTMLElement, container: HTMLElement, header: HTMLElement|null, wrapper: HTMLElement|null, footer: HTMLElement|null,
|
|
37
|
-
* config: object, update: Function, destroy: Function}>}
|
|
38
|
-
*/
|
|
39
|
-
export function createApp(options?: {
|
|
40
|
-
root: string | Element;
|
|
41
|
-
}): Promise<{
|
|
42
|
-
element: HTMLElement;
|
|
43
|
-
container: HTMLElement;
|
|
44
|
-
header: HTMLElement | null;
|
|
45
|
-
wrapper: HTMLElement | null;
|
|
46
|
-
footer: HTMLElement | null;
|
|
47
|
-
config: object;
|
|
48
|
-
update: Function;
|
|
49
|
-
destroy: Function;
|
|
50
|
-
}>;
|
|
51
|
-
/**
|
|
52
|
-
* Switches the theme at runtime: { id } of a registered theme or { href } of a stylesheet.
|
|
53
|
-
* @returns {Promise<object>} the applied theme
|
|
54
|
-
*/
|
|
55
|
-
export function setTheme(selected: any): Promise<object>;
|
|
56
|
-
export { default as Cookies } from "./libs/core/cookies.js";
|
|
57
|
-
export * from "./libs/core/elementGenerator.js";
|
|
58
|
-
export * from "./libs/core/controls.js";
|
|
59
|
-
export * from "./libs/core/hungarianControls.js";
|
|
60
|
-
export * from "./libs/hephaestus/LayoutGenerator/basicLayoutGenerator.js";
|
|
61
|
-
export * from "./libs/hephaestus/LayoutGenerator/headerContentGenerator.js";
|
|
62
|
-
export * from "./libs/hephaestus/LayoutGenerator/wrapperContentGenerator.js";
|
|
63
|
-
export * from "./libs/hephaestus/LayoutGenerator/footerContentGenerator.js";
|
|
64
|
-
export * from "./libs/hephaestus/MenuGenerator/basicMenuGenerator.js";
|
|
65
|
-
export * from "./libs/hephaestus/MenuGenerator/menuGenerator.js";
|
|
66
|
-
export * from "./libs/hephaestus/formGenerator/loginFormGenerator.js";
|
|
67
|
-
export * from "./libs/hephaestus/formGenerator/registrationFormGenerator.js";
|
|
68
|
-
export * from "./libs/hephaestus/formGenerator/lostPasswordFormGenerator.js";
|
|
69
|
-
export * from "./libs/hephaestus/chartGenerator/chartGenerator.js";
|
|
70
|
-
export * from "./libs/hephaestus/tableGenerator/tableGenerator.js";
|
|
71
|
-
export * from "./libs/hephaestus/formGenerator/changePasswordFormGenerator.js";
|
|
72
|
-
export * from "./libs/hephaestus/formGenerator/formBuilder.js";
|
|
73
|
-
export * from "./libs/hephaestus/formGenerator/authForms.js";
|
|
74
|
-
export * from "./libs/hephaestus/feedbackGenerator/feedbackGenerator.js";
|
|
75
|
-
export * from "./libs/hephaestus/dialogGenerator/dialogGenerator.js";
|
|
76
|
-
export * from "./libs/hephaestus/navigationGenerator/navigationGenerator.js";
|
|
77
|
-
export * from "./libs/hephaestus/componentGenerator/componentGenerator.js";
|
|
78
|
-
export * from "./libs/hephaestus/inputGenerator/inputGenerator.js";
|
|
79
|
-
export * from "./libs/hephaestus/inputGenerator/dropZoneGenerator.js";
|
|
80
|
-
export * from "./libs/hephaestus/inputGenerator/richTextGenerator.js";
|
|
81
|
-
export * from "./libs/core/sanitize.js";
|
|
82
|
-
export * from "./libs/hephaestus/router/router.js";
|
|
83
|
-
export * from "./libs/hephaestus/auth/session.js";
|
|
84
|
-
export * from "./libs/hephaestus/auth/authState.js";
|
|
85
|
-
export * from "./libs/core/i18n.js";
|
|
86
|
-
export * from "./libs/core/validation.js";
|
|
87
|
-
export * from "./libs/core/csv.js";
|
|
88
|
-
export * from "./libs/core/dateRange.js";
|
|
89
|
-
export * from "./libs/core/format.js";
|
|
90
|
-
export * from "./libs/core/motion.js";
|
|
91
|
-
export * from "./libs/hephaestus/widgetGrid/widgetGrid.js";
|
|
92
|
-
export * from "./libs/core/gridLayout.js";
|
|
93
|
-
export * from "./libs/hephaestus/
|
|
94
|
-
export * from "./libs/
|
|
95
|
-
export * from "./libs/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
export
|
|
99
|
-
export
|
|
1
|
+
/**
|
|
2
|
+
* Loads the theme, waits for the page and generates the layout.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} [options]
|
|
5
|
+
* @param {{id?: number, href?: string}} [options.theme] registered theme id or custom stylesheet
|
|
6
|
+
* @param {object} [options.config] settings overriding the defaults (and the global appConfig)
|
|
7
|
+
* @param {Function} [options.nav] navigation callback (falls back to the global nav)
|
|
8
|
+
* @param {Function} [options.login] login callback (falls back to the global login)
|
|
9
|
+
* @param {Function} [options.register] registration callback (falls back to the global register)
|
|
10
|
+
* @param {Function} [options.lostPassword] lost password callback (falls back to the global lostPassword)
|
|
11
|
+
* @param {Function} [options.changePassword] change password callback (falls back to the global changePassword)
|
|
12
|
+
* @param {object} [options.menuItems] { headerMenu, footerMenu } (falls back to the global menuItems)
|
|
13
|
+
* @returns {Promise<object>} the effective configuration
|
|
14
|
+
*/
|
|
15
|
+
export function init(options?: {
|
|
16
|
+
theme?: {
|
|
17
|
+
id?: number;
|
|
18
|
+
href?: string;
|
|
19
|
+
};
|
|
20
|
+
config?: object;
|
|
21
|
+
nav?: Function;
|
|
22
|
+
login?: Function;
|
|
23
|
+
register?: Function;
|
|
24
|
+
lostPassword?: Function;
|
|
25
|
+
changePassword?: Function;
|
|
26
|
+
menuItems?: object;
|
|
27
|
+
}): Promise<object>;
|
|
28
|
+
/**
|
|
29
|
+
* Starts Athena UI inside an element of your page instead of the body, so it can be one part of a larger page (or of several apps).
|
|
30
|
+
* It does what init() does (settings, language, theme, hooks), and the layout (container, header, wrapper, footer) is generated into
|
|
31
|
+
* `root`. The parts follow the settings: `config: { generateHeader: false, generateFooter: false }` leaves only the wrapper, which is where
|
|
32
|
+
* the components go by default (the element with the id "wrapper"). One app per page: the parts have fixed ids.
|
|
33
|
+
*
|
|
34
|
+
* @param {object} options the options of init(), and
|
|
35
|
+
* @param {string|Element} options.root the element to build into (an element, an id or a selector)
|
|
36
|
+
* @returns {Promise<{element: HTMLElement, container: HTMLElement, header: HTMLElement|null, wrapper: HTMLElement|null, footer: HTMLElement|null,
|
|
37
|
+
* config: object, update: Function, destroy: Function}>}
|
|
38
|
+
*/
|
|
39
|
+
export function createApp(options?: {
|
|
40
|
+
root: string | Element;
|
|
41
|
+
}): Promise<{
|
|
42
|
+
element: HTMLElement;
|
|
43
|
+
container: HTMLElement;
|
|
44
|
+
header: HTMLElement | null;
|
|
45
|
+
wrapper: HTMLElement | null;
|
|
46
|
+
footer: HTMLElement | null;
|
|
47
|
+
config: object;
|
|
48
|
+
update: Function;
|
|
49
|
+
destroy: Function;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Switches the theme at runtime: { id } of a registered theme or { href } of a stylesheet.
|
|
53
|
+
* @returns {Promise<object>} the applied theme
|
|
54
|
+
*/
|
|
55
|
+
export function setTheme(selected: any): Promise<object>;
|
|
56
|
+
export { default as Cookies } from "./libs/core/cookies.js";
|
|
57
|
+
export * from "./libs/core/elementGenerator.js";
|
|
58
|
+
export * from "./libs/core/controls.js";
|
|
59
|
+
export * from "./libs/core/hungarianControls.js";
|
|
60
|
+
export * from "./libs/hephaestus/LayoutGenerator/basicLayoutGenerator.js";
|
|
61
|
+
export * from "./libs/hephaestus/LayoutGenerator/headerContentGenerator.js";
|
|
62
|
+
export * from "./libs/hephaestus/LayoutGenerator/wrapperContentGenerator.js";
|
|
63
|
+
export * from "./libs/hephaestus/LayoutGenerator/footerContentGenerator.js";
|
|
64
|
+
export * from "./libs/hephaestus/MenuGenerator/basicMenuGenerator.js";
|
|
65
|
+
export * from "./libs/hephaestus/MenuGenerator/menuGenerator.js";
|
|
66
|
+
export * from "./libs/hephaestus/formGenerator/loginFormGenerator.js";
|
|
67
|
+
export * from "./libs/hephaestus/formGenerator/registrationFormGenerator.js";
|
|
68
|
+
export * from "./libs/hephaestus/formGenerator/lostPasswordFormGenerator.js";
|
|
69
|
+
export * from "./libs/hephaestus/chartGenerator/chartGenerator.js";
|
|
70
|
+
export * from "./libs/hephaestus/tableGenerator/tableGenerator.js";
|
|
71
|
+
export * from "./libs/hephaestus/formGenerator/changePasswordFormGenerator.js";
|
|
72
|
+
export * from "./libs/hephaestus/formGenerator/formBuilder.js";
|
|
73
|
+
export * from "./libs/hephaestus/formGenerator/authForms.js";
|
|
74
|
+
export * from "./libs/hephaestus/feedbackGenerator/feedbackGenerator.js";
|
|
75
|
+
export * from "./libs/hephaestus/dialogGenerator/dialogGenerator.js";
|
|
76
|
+
export * from "./libs/hephaestus/navigationGenerator/navigationGenerator.js";
|
|
77
|
+
export * from "./libs/hephaestus/componentGenerator/componentGenerator.js";
|
|
78
|
+
export * from "./libs/hephaestus/inputGenerator/inputGenerator.js";
|
|
79
|
+
export * from "./libs/hephaestus/inputGenerator/dropZoneGenerator.js";
|
|
80
|
+
export * from "./libs/hephaestus/inputGenerator/richTextGenerator.js";
|
|
81
|
+
export * from "./libs/core/sanitize.js";
|
|
82
|
+
export * from "./libs/hephaestus/router/router.js";
|
|
83
|
+
export * from "./libs/hephaestus/auth/session.js";
|
|
84
|
+
export * from "./libs/hephaestus/auth/authState.js";
|
|
85
|
+
export * from "./libs/core/i18n.js";
|
|
86
|
+
export * from "./libs/core/validation.js";
|
|
87
|
+
export * from "./libs/core/csv.js";
|
|
88
|
+
export * from "./libs/core/dateRange.js";
|
|
89
|
+
export * from "./libs/core/format.js";
|
|
90
|
+
export * from "./libs/core/motion.js";
|
|
91
|
+
export * from "./libs/hephaestus/widgetGrid/widgetGrid.js";
|
|
92
|
+
export * from "./libs/core/gridLayout.js";
|
|
93
|
+
export * from "./libs/hephaestus/codeGenerator/codeGenerator.js";
|
|
94
|
+
export * from "./libs/hephaestus/codeGenerator/codeEditor.js";
|
|
95
|
+
export * from "./libs/core/codeLanguages.js";
|
|
96
|
+
export * from "./libs/core/codeDiff.js";
|
|
97
|
+
export * from "./libs/hephaestus/modalGenerator/modalGenerator.js";
|
|
98
|
+
export * from "./libs/core/theme.js";
|
|
99
|
+
export * from "./libs/hephaestus/componentGenerator/themePicker.js";
|
|
100
|
+
import config from "./libs/config/config.js";
|
|
101
|
+
import { loadScript } from "./libs/hephaestus/hephaestus.js";
|
|
102
|
+
export { config, loadScript };
|
|
103
|
+
export { el, setContent, resolveElement, asHandle, createSafeBuilder } from "./libs/core/dom.js";
|
package/types/code.d.ts
ADDED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function applyConfig(...sources: any[]): {
|
|
2
|
-
version: "2.
|
|
2
|
+
version: "2.4.1";
|
|
3
3
|
container_class: "container";
|
|
4
4
|
header_class: "header-container";
|
|
5
5
|
header_menu_class: "header-menu menu";
|
|
@@ -32,7 +32,7 @@ export function applyConfig(...sources: any[]): {
|
|
|
32
32
|
export function withBorder(className: any): any;
|
|
33
33
|
export const BORDERED_CLASS: "default-cointainer-bordered";
|
|
34
34
|
export const defaults: Readonly<{
|
|
35
|
-
version: "2.
|
|
35
|
+
version: "2.4.1";
|
|
36
36
|
container_class: "container";
|
|
37
37
|
header_class: "header-container";
|
|
38
38
|
header_menu_class: "header-menu menu";
|
|
@@ -64,7 +64,7 @@ export const defaults: Readonly<{
|
|
|
64
64
|
}>;
|
|
65
65
|
export default config;
|
|
66
66
|
declare namespace config {
|
|
67
|
-
let version: "2.
|
|
67
|
+
let version: "2.4.1";
|
|
68
68
|
let container_class: "container";
|
|
69
69
|
let header_class: "header-container";
|
|
70
70
|
let header_menu_class: "header-menu menu";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The difference between two lists of lines, as operations in order. `a` and `b` are indexes into the two lists.
|
|
3
|
+
* When the two lists differ by more than `maxEdits` lines the result is coarse (everything removed, then everything added) instead of slow.
|
|
4
|
+
*
|
|
5
|
+
* @param {string[]} oldLines
|
|
6
|
+
* @param {string[]} newLines
|
|
7
|
+
* @param {{maxEdits?: number}} [options]
|
|
8
|
+
* @returns {DiffOp[]}
|
|
9
|
+
*/
|
|
10
|
+
export function diffLines(oldLines: string[], newLines: string[], { maxEdits }?: {
|
|
11
|
+
maxEdits?: number;
|
|
12
|
+
}): DiffOp[];
|
|
13
|
+
/**
|
|
14
|
+
* Groups the operations into hunks that show `context` unchanged lines around each change (Infinity: everything is one hunk).
|
|
15
|
+
* @returns {{ops: DiffOp[], skippedBefore: number}[]} `skippedBefore` is the number of unchanged lines left out before the hunk
|
|
16
|
+
*/
|
|
17
|
+
export function hunksOf(ops: any, context?: number): {
|
|
18
|
+
ops: DiffOp[];
|
|
19
|
+
skippedBefore: number;
|
|
20
|
+
}[];
|
|
21
|
+
export function splitLines(text: any): string[];
|
|
22
|
+
export type DiffOp = {
|
|
23
|
+
type: "equal";
|
|
24
|
+
a: number;
|
|
25
|
+
b: number;
|
|
26
|
+
} | {
|
|
27
|
+
type: "remove";
|
|
28
|
+
a: number;
|
|
29
|
+
} | {
|
|
30
|
+
type: "add";
|
|
31
|
+
b: number;
|
|
32
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** Registers a language (and its aliases). */
|
|
2
|
+
export function registerLanguage(language: any): void;
|
|
3
|
+
/**
|
|
4
|
+
* Splits text into tokens: [{ type, text }]. `type` is null for plain text. Concatenating the texts gives the input back.
|
|
5
|
+
* An unknown language, or a text that is too long, gives one plain token.
|
|
6
|
+
*/
|
|
7
|
+
export function tokenize(text: any, language: any): any[];
|
|
8
|
+
export function getLanguage(name: any): any;
|
|
9
|
+
export function getLanguages(): any[];
|
|
10
|
+
/** The token types the default theme gives a colour to: the classes are `tok-<type>`. */
|
|
11
|
+
export const TOKEN_TYPES: string[];
|
|
12
|
+
/**
|
|
13
|
+
* A language: an ordered list of rules. The text is scanned once; at every position the first rule that matches wins.
|
|
14
|
+
*/
|
|
15
|
+
export type CodeLanguage = {
|
|
16
|
+
name: string;
|
|
17
|
+
/**
|
|
18
|
+
* shown in the label of a code block (default: the name)
|
|
19
|
+
*/
|
|
20
|
+
label?: string;
|
|
21
|
+
/**
|
|
22
|
+
* other names ("js" for "javascript")
|
|
23
|
+
*/
|
|
24
|
+
aliases?: string[];
|
|
25
|
+
/**
|
|
26
|
+
* `type` becomes the class `tok-<type>`;
|
|
27
|
+
* the pattern must use non-capturing groups only; `inner` splits a match into smaller tokens (a tag into name and attributes)
|
|
28
|
+
*/
|
|
29
|
+
rules: {
|
|
30
|
+
type: string;
|
|
31
|
+
pattern: RegExp;
|
|
32
|
+
inner?: (text: string) => {
|
|
33
|
+
type: string | null;
|
|
34
|
+
text: string;
|
|
35
|
+
}[];
|
|
36
|
+
}[];
|
|
37
|
+
/**
|
|
38
|
+
* the rules are case-insensitive (SQL)
|
|
39
|
+
*/
|
|
40
|
+
ignoreCase?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* ^ and $ match at every line (YAML, C# preprocessor lines)
|
|
43
|
+
*/
|
|
44
|
+
multiline?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* used by the editor to comment lines ("//")
|
|
47
|
+
*/
|
|
48
|
+
lineComment?: string;
|
|
49
|
+
blockComment?: [string, string];
|
|
50
|
+
/**
|
|
51
|
+
* characters the editor closes: ["()", "[]", "{}", "\"\"", "''"]
|
|
52
|
+
*/
|
|
53
|
+
pairs?: string[];
|
|
54
|
+
/**
|
|
55
|
+
* a line that matches this makes the next line one level deeper (/[{(\[:]\s*$/)
|
|
56
|
+
*/
|
|
57
|
+
indentAfter?: RegExp;
|
|
58
|
+
};
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
/** Puts an item inside the columns and inside its size limits ({ min: {w, h}, max: {w, h} }). */
|
|
2
|
-
export function clampItem(item: any, columns: any, { min, max }?: {
|
|
3
|
-
min?: {};
|
|
4
|
-
max?: {};
|
|
5
|
-
}): any;
|
|
6
|
-
/**
|
|
7
|
-
* Gravity: every item that is not locked moves up as far as it can (locked items stay where they are).
|
|
8
|
-
* @returns {object[]} new items, in the order of the argument
|
|
9
|
-
*/
|
|
10
|
-
export function compact(items: any): object[];
|
|
11
|
-
/**
|
|
12
|
-
* Sets the place of one item (clamped), pushes the others out of its way and, unless `compactItems` is false, lets everything fall upwards.
|
|
13
|
-
* @param {object[]} items
|
|
14
|
-
* @param {string} id
|
|
15
|
-
* @param {{x?: number, y?: number, w?: number, h?: number}} place the new place; missing values stay as they are
|
|
16
|
-
* @param {number} columns
|
|
17
|
-
* @param {object} [options]
|
|
18
|
-
* @param {{min?: object, max?: object}} [options.limits] size limits of this item
|
|
19
|
-
* @param {boolean} [options.compactItems=true]
|
|
20
|
-
* @returns {object[]|null} the new layout, or null when it is not possible (a locked item is in the way, or the item is locked)
|
|
21
|
-
*/
|
|
22
|
-
export function placeItem(items: object[], id: string, place: {
|
|
23
|
-
x?: number;
|
|
24
|
-
y?: number;
|
|
25
|
-
w?: number;
|
|
26
|
-
h?: number;
|
|
27
|
-
}, columns: number, { limits, compactItems }?: {
|
|
28
|
-
limits?: {
|
|
29
|
-
min?: object;
|
|
30
|
-
max?: object;
|
|
31
|
-
};
|
|
32
|
-
compactItems?: boolean;
|
|
33
|
-
}): object[] | null;
|
|
34
|
-
/** The first free place of the size w x h (rows grow without end). */
|
|
35
|
-
export function findFreeSpot(items: any, w: any, h: any, columns: any): {
|
|
36
|
-
x: number;
|
|
37
|
-
y: number;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Makes any list of items a valid layout for `columns`: inside the columns, without overlaps, compact. Items keep their order of reading
|
|
41
|
-
* (top to bottom, left to right). Used for loaded layouts and for a breakpoint that has no layout of its own.
|
|
42
|
-
*/
|
|
43
|
-
export function normalize(items: any, columns: any, limitsOf?: () => {}): any[];
|
|
44
|
-
export function collides(a: any, b: any): boolean;
|
|
45
|
-
export function rowsOf(items: any): any;
|
|
1
|
+
/** Puts an item inside the columns and inside its size limits ({ min: {w, h}, max: {w, h} }). */
|
|
2
|
+
export function clampItem(item: any, columns: any, { min, max }?: {
|
|
3
|
+
min?: {};
|
|
4
|
+
max?: {};
|
|
5
|
+
}): any;
|
|
6
|
+
/**
|
|
7
|
+
* Gravity: every item that is not locked moves up as far as it can (locked items stay where they are).
|
|
8
|
+
* @returns {object[]} new items, in the order of the argument
|
|
9
|
+
*/
|
|
10
|
+
export function compact(items: any): object[];
|
|
11
|
+
/**
|
|
12
|
+
* Sets the place of one item (clamped), pushes the others out of its way and, unless `compactItems` is false, lets everything fall upwards.
|
|
13
|
+
* @param {object[]} items
|
|
14
|
+
* @param {string} id
|
|
15
|
+
* @param {{x?: number, y?: number, w?: number, h?: number}} place the new place; missing values stay as they are
|
|
16
|
+
* @param {number} columns
|
|
17
|
+
* @param {object} [options]
|
|
18
|
+
* @param {{min?: object, max?: object}} [options.limits] size limits of this item
|
|
19
|
+
* @param {boolean} [options.compactItems=true]
|
|
20
|
+
* @returns {object[]|null} the new layout, or null when it is not possible (a locked item is in the way, or the item is locked)
|
|
21
|
+
*/
|
|
22
|
+
export function placeItem(items: object[], id: string, place: {
|
|
23
|
+
x?: number;
|
|
24
|
+
y?: number;
|
|
25
|
+
w?: number;
|
|
26
|
+
h?: number;
|
|
27
|
+
}, columns: number, { limits, compactItems }?: {
|
|
28
|
+
limits?: {
|
|
29
|
+
min?: object;
|
|
30
|
+
max?: object;
|
|
31
|
+
};
|
|
32
|
+
compactItems?: boolean;
|
|
33
|
+
}): object[] | null;
|
|
34
|
+
/** The first free place of the size w x h (rows grow without end). */
|
|
35
|
+
export function findFreeSpot(items: any, w: any, h: any, columns: any): {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Makes any list of items a valid layout for `columns`: inside the columns, without overlaps, compact. Items keep their order of reading
|
|
41
|
+
* (top to bottom, left to right). Used for loaded layouts and for a breakpoint that has no layout of its own.
|
|
42
|
+
*/
|
|
43
|
+
export function normalize(items: any, columns: any, limitsOf?: () => {}): any[];
|
|
44
|
+
export function collides(a: any, b: any): boolean;
|
|
45
|
+
export function rowsOf(items: any): any;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A code editor.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} options
|
|
5
|
+
* @param {string|HTMLElement} options.element the container
|
|
6
|
+
* @param {string} [options.value]
|
|
7
|
+
* @param {string|object} [options.language] "js", "json", ... or a language object (see registerLanguage)
|
|
8
|
+
* @param {boolean} [options.readOnly=false]
|
|
9
|
+
* @param {boolean} [options.lineNumbers=true]
|
|
10
|
+
* @param {boolean} [options.wrap=false] soft wrap
|
|
11
|
+
* @param {number} [options.tabSize=4]
|
|
12
|
+
* @param {boolean} [options.insertSpaces=true] Tab inserts spaces (false: a tab character)
|
|
13
|
+
* @param {boolean} [options.statusBar=true] line and column, and the message of a marker
|
|
14
|
+
* @param {string} [options.label] accessible name of the editor
|
|
15
|
+
* @param {number} [options.maxHighlightLength=300000] longer texts are shown without highlighting (and without line numbers) to stay fast
|
|
16
|
+
* @param {{line: number, message: string, level?: "error"|"warning"|"info"}[]} [options.markers] lint markers (lines count from 1)
|
|
17
|
+
* @param {{from: number, to: number}[]} [options.readOnlyRanges] lines (1-based, inclusive) that cannot be changed
|
|
18
|
+
* @param {(context: {value: string, position: number, line: number, lineText: string, prefix: string, explicit: boolean, language: string}) => (Array<{label: string, insert?: string, detail?: string}>|Promise<Array>)} [options.provideCompletions]
|
|
19
|
+
* @param {boolean} [options.autoComplete=true] with provideCompletions: suggest while typing (otherwise only with Ctrl+Space)
|
|
20
|
+
* @param {(value: string, reason: string) => void} [options.onChange] after every change made by typing, undo, redo, replace ... (not after setValue)
|
|
21
|
+
* @returns the handle: { element, textarea, getValue, setValue, focus, getSelection, setSelection, insertText, setLanguage, setReadOnly, setWrap, setMarkers,
|
|
22
|
+
* setReadOnlyRanges, undo, redo, canUndo, canRedo, openFind, closeFind, toggleComment, destroy }
|
|
23
|
+
*/
|
|
24
|
+
export function createCodeEditor(options?: {
|
|
25
|
+
element: string | HTMLElement;
|
|
26
|
+
value?: string;
|
|
27
|
+
language?: string | object;
|
|
28
|
+
readOnly?: boolean;
|
|
29
|
+
lineNumbers?: boolean;
|
|
30
|
+
wrap?: boolean;
|
|
31
|
+
tabSize?: number;
|
|
32
|
+
insertSpaces?: boolean;
|
|
33
|
+
statusBar?: boolean;
|
|
34
|
+
label?: string;
|
|
35
|
+
maxHighlightLength?: number;
|
|
36
|
+
markers?: {
|
|
37
|
+
line: number;
|
|
38
|
+
message: string;
|
|
39
|
+
level?: "error" | "warning" | "info";
|
|
40
|
+
}[];
|
|
41
|
+
readOnlyRanges?: {
|
|
42
|
+
from: number;
|
|
43
|
+
to: number;
|
|
44
|
+
}[];
|
|
45
|
+
provideCompletions?: (context: {
|
|
46
|
+
value: string;
|
|
47
|
+
position: number;
|
|
48
|
+
line: number;
|
|
49
|
+
lineText: string;
|
|
50
|
+
prefix: string;
|
|
51
|
+
explicit: boolean;
|
|
52
|
+
language: string;
|
|
53
|
+
}) => (Array<{
|
|
54
|
+
label: string;
|
|
55
|
+
insert?: string;
|
|
56
|
+
detail?: string;
|
|
57
|
+
}> | Promise<any[]>);
|
|
58
|
+
autoComplete?: boolean;
|
|
59
|
+
onChange?: (value: string, reason: string) => void;
|
|
60
|
+
}): any;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/** Splits tokens at the line breaks: an array (one entry per line) of arrays of { type, text }. */
|
|
2
|
+
export function tokensToLines(tokens: any): any[][];
|
|
3
|
+
/** The nodes of one line: text nodes and <span class="tok-..."> (a span has one class and one text node). */
|
|
4
|
+
export function lineNodes(tokens: any): any;
|
|
5
|
+
/**
|
|
6
|
+
* Writes the highlighted lines of a text into a <code> element (replacing what is there). The editor uses it too.
|
|
7
|
+
*
|
|
8
|
+
* @param {HTMLElement} code
|
|
9
|
+
* @param {string} text
|
|
10
|
+
* @param {string|object} [language] a name or alias ("js"), or a language object; unknown: plain text
|
|
11
|
+
* @param {object} [options]
|
|
12
|
+
* @param {Array<number|string>} [options.highlightLines] line numbers (1-based) or ranges ("5-8") that get a background
|
|
13
|
+
* @returns {number} the number of lines
|
|
14
|
+
*/
|
|
15
|
+
export function renderCode(code: HTMLElement, text: string, language?: string | object, { highlightLines }?: {
|
|
16
|
+
highlightLines?: Array<number | string>;
|
|
17
|
+
}): number;
|
|
18
|
+
/**
|
|
19
|
+
* Highlights read-only code: a `<pre class="athena-code"><code>` element.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} text
|
|
22
|
+
* @param {string|object} [language] "js", "ts", "json", "html", "css", "sql", "sh", "yaml", "c#", "python" or a language you registered
|
|
23
|
+
* @param {object} [options]
|
|
24
|
+
* @param {boolean} [options.lineNumbers=false]
|
|
25
|
+
* @param {Array<number|string>} [options.highlightLines]
|
|
26
|
+
* @param {boolean} [options.wrap=false] long lines wrap instead of scrolling
|
|
27
|
+
* @param {string} [options.label] accessible name of the code
|
|
28
|
+
* @returns {HTMLPreElement}
|
|
29
|
+
*/
|
|
30
|
+
export function highlightCode(text: string, language?: string | object, { lineNumbers, highlightLines, wrap, label }?: {
|
|
31
|
+
lineNumbers?: boolean;
|
|
32
|
+
highlightLines?: Array<number | string>;
|
|
33
|
+
wrap?: boolean;
|
|
34
|
+
label?: string;
|
|
35
|
+
}): HTMLPreElement;
|
|
36
|
+
/**
|
|
37
|
+
* A code block: a label with the language, a copy button and the highlighted code.
|
|
38
|
+
*
|
|
39
|
+
* @param {object} options
|
|
40
|
+
* @param {string|HTMLElement} [options.parent]
|
|
41
|
+
* @param {string} options.code
|
|
42
|
+
* @param {string|object} [options.language]
|
|
43
|
+
* @param {string} [options.title] shown in the header instead of the language
|
|
44
|
+
* @param {boolean} [options.lineNumbers=false]
|
|
45
|
+
* @param {Array<number|string>} [options.highlightLines]
|
|
46
|
+
* @param {boolean} [options.copy=true] the copy button
|
|
47
|
+
* @param {boolean} [options.wrap=false]
|
|
48
|
+
* @param {string} [options.id]
|
|
49
|
+
* @returns {{element: HTMLElement, getCode: () => string, setCode: (code: string, language?: string|object) => void, copy: () => Promise<boolean>, destroy: Function}}
|
|
50
|
+
*/
|
|
51
|
+
export function generateCodeBlock({ parent, code, language, title, lineNumbers, highlightLines, copy, wrap, id }?: {
|
|
52
|
+
parent?: string | HTMLElement;
|
|
53
|
+
code: string;
|
|
54
|
+
language?: string | object;
|
|
55
|
+
title?: string;
|
|
56
|
+
lineNumbers?: boolean;
|
|
57
|
+
highlightLines?: Array<number | string>;
|
|
58
|
+
copy?: boolean;
|
|
59
|
+
wrap?: boolean;
|
|
60
|
+
id?: string;
|
|
61
|
+
}): {
|
|
62
|
+
element: HTMLElement;
|
|
63
|
+
getCode: () => string;
|
|
64
|
+
setCode: (code: string, language?: string | object) => void;
|
|
65
|
+
copy: () => Promise<boolean>;
|
|
66
|
+
destroy: Function;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* A view of the difference between two texts, with highlighted code on both sides.
|
|
70
|
+
*
|
|
71
|
+
* @param {object} options
|
|
72
|
+
* @param {string|HTMLElement} [options.parent]
|
|
73
|
+
* @param {string} [options.original]
|
|
74
|
+
* @param {string} [options.modified]
|
|
75
|
+
* @param {string|object} [options.language]
|
|
76
|
+
* @param {"unified"|"split"} [options.mode="unified"]
|
|
77
|
+
* @param {number} [options.context=3] unchanged lines kept around a change (Infinity: all of them); a button shows the rest
|
|
78
|
+
* @param {string} [options.originalLabel]
|
|
79
|
+
* @param {string} [options.modifiedLabel]
|
|
80
|
+
* @returns {{element: HTMLElement, setTexts: (original: string, modified: string) => void, setMode: (mode: string) => void, getStats: () => {added: number, removed: number}}}
|
|
81
|
+
*/
|
|
82
|
+
export function createDiffView({ parent, original, modified, language, mode, context, originalLabel, modifiedLabel }?: {
|
|
83
|
+
parent?: string | HTMLElement;
|
|
84
|
+
original?: string;
|
|
85
|
+
modified?: string;
|
|
86
|
+
language?: string | object;
|
|
87
|
+
mode?: "unified" | "split";
|
|
88
|
+
context?: number;
|
|
89
|
+
originalLabel?: string;
|
|
90
|
+
modifiedLabel?: string;
|
|
91
|
+
}): {
|
|
92
|
+
element: HTMLElement;
|
|
93
|
+
setTexts: (original: string, modified: string) => void;
|
|
94
|
+
setMode: (mode: string) => void;
|
|
95
|
+
getStats: () => {
|
|
96
|
+
added: number;
|
|
97
|
+
removed: number;
|
|
98
|
+
};
|
|
99
|
+
};
|