athena-ui-js 2.4.1 → 2.5.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 +1128 -1114
- package/docs/styling.md +123 -123
- package/package.json +172 -189
- package/src/athena-ui.js +135 -135
- package/src/libs/config/config.js +66 -66
- package/src/libs/core/i18n.js +2 -0
- package/src/libs/hephaestus/chartGenerator/chartGenerator.js +70 -28
- package/src/libs/hephaestus/dialogGenerator/dialogGenerator.js +5 -2
- package/src/libs/hephaestus/formGenerator/formBuilder.js +86 -5
- package/src/libs/hephaestus/tableGenerator/tableGenerator.js +5 -1
- package/src/res/themes/default/style.css +4 -0
- package/types/libs/config/config.d.ts +3 -3
- package/types/libs/hephaestus/chartGenerator/chartGenerator.d.ts +117 -95
- package/types/libs/hephaestus/dialogGenerator/dialogGenerator.d.ts +122 -120
- package/types/libs/hephaestus/formGenerator/authForms.d.ts +130 -122
- package/types/libs/hephaestus/formGenerator/formBuilder.d.ts +128 -113
- package/types/libs/hephaestus/tableGenerator/tableGenerator.d.ts +129 -123
|
@@ -1,95 +1,117 @@
|
|
|
1
|
-
/** Tick positions (ms) at round times between `from` and `to`, about `count` of them. */
|
|
2
|
-
export function timeTicks(from: any, to: any, count?: number): {
|
|
3
|
-
ticks: number[];
|
|
4
|
-
step: number;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Keeps about `buckets` x positions of a long series: of every bucket the lowest and the highest value stay (in their order),
|
|
8
|
-
* so peaks are not lost. Returns the kept indices.
|
|
9
|
-
*/
|
|
10
|
-
export function decimate(indices: any, values: any, buckets: any): any;
|
|
11
|
-
/**
|
|
12
|
-
* Draws a chart as inline SVG and appends it to its parent.
|
|
13
|
-
*
|
|
14
|
-
* @param {object} options
|
|
15
|
-
* @param {"bar"|"line"|"area"|"sparkline"|"pie"|"donut"} [options.type="bar"]
|
|
16
|
-
* @param {string|Element} [options.parent] element, id or selector, defaults to "wrapper"
|
|
17
|
-
* @param {string} [options.id] id of the svg element
|
|
18
|
-
* @param {string} [options.title] drawn above the chart, and its accessible name
|
|
19
|
-
* @param {string[]} [options.labels] category labels
|
|
20
|
-
* @param {(number|Date|string)[]} [options.times] line and area charts: the time of every value (Date, ms or a date string).
|
|
21
|
-
* The x axis becomes a time axis with ticks at round times, and the points sit at their real distance.
|
|
22
|
-
* @param {{name?: string, data: number[], color?: string}[]} options.series pie / donut / sparkline use the first series only.
|
|
23
|
-
* Colours come from the theme (--series-1 ... --series-8); `color` is an override for one series.
|
|
24
|
-
* @param {number} [options.width=600] (a sparkline: 120)
|
|
25
|
-
* @param {number} [options.height=360] (a sparkline: 32)
|
|
26
|
-
* @param {boolean} [options.legend] default: shown for several series, and for pie / donut. Clicking an entry hides / shows its series.
|
|
27
|
-
* @param {boolean} [options.table=false] adds a "Show as table" section with the values below the chart
|
|
28
|
-
* @param {boolean} [options.zero=true] line charts: false lets the value axis start near the smallest value
|
|
29
|
-
* @param {boolean} [options.zoom=false] line and area charts: drag over the plot to zoom into that range, double click (or the
|
|
30
|
-
* reset button, or 0 / Esc) to zoom out; with the keyboard on the plot: + and - zoom, the arrow keys pan
|
|
31
|
-
* @param {{from: number, to: number}|null} [options.zoomRange] the range in view, in the units of the x axis: milliseconds with
|
|
32
|
-
* `times`, otherwise the index of the point (-0.5 is the left edge of the first point)
|
|
33
|
-
* @param {(range: ({from: number, to: number}|null)) => void} [options.onZoom] called when a person zooms or resets
|
|
34
|
-
* @param {number} [options.maxPoints] `push` keeps at most this many points per series (the oldest are dropped)
|
|
35
|
-
* @param {number[]} [options.hiddenSeries] the series (or slices) that are hidden at the start; a person hides and shows them with the legend, and a redraw keeps that
|
|
36
|
-
* @param {boolean} [options.animate=true] the first drawing animates: bars grow, a line is drawn, slices pop in (not when it is redrawn, and not under reduced motion)
|
|
37
|
-
* @param {boolean} [options.interactive=true] line and area charts: false leaves out the pointer layer (tooltip that follows the pointer, zoom)
|
|
38
|
-
* @
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
1
|
+
/** Tick positions (ms) at round times between `from` and `to`, about `count` of them. */
|
|
2
|
+
export function timeTicks(from: any, to: any, count?: number): {
|
|
3
|
+
ticks: number[];
|
|
4
|
+
step: number;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Keeps about `buckets` x positions of a long series: of every bucket the lowest and the highest value stay (in their order),
|
|
8
|
+
* so peaks are not lost. Returns the kept indices.
|
|
9
|
+
*/
|
|
10
|
+
export function decimate(indices: any, values: any, buckets: any): any;
|
|
11
|
+
/**
|
|
12
|
+
* Draws a chart as inline SVG and appends it to its parent.
|
|
13
|
+
*
|
|
14
|
+
* @param {object} options
|
|
15
|
+
* @param {"bar"|"line"|"area"|"sparkline"|"pie"|"donut"} [options.type="bar"]
|
|
16
|
+
* @param {string|Element} [options.parent] element, id or selector, defaults to "wrapper"
|
|
17
|
+
* @param {string} [options.id] id of the svg element
|
|
18
|
+
* @param {string} [options.title] drawn above the chart, and its accessible name
|
|
19
|
+
* @param {string[]} [options.labels] category labels
|
|
20
|
+
* @param {(number|Date|string)[]} [options.times] line and area charts: the time of every value (Date, ms or a date string).
|
|
21
|
+
* The x axis becomes a time axis with ticks at round times, and the points sit at their real distance.
|
|
22
|
+
* @param {{name?: string, data: number[], color?: string}[]} options.series pie / donut / sparkline use the first series only.
|
|
23
|
+
* Colours come from the theme (--series-1 ... --series-8); `color` is an override for one series.
|
|
24
|
+
* @param {number} [options.width=600] (a sparkline: 120)
|
|
25
|
+
* @param {number} [options.height=360] (a sparkline: 32)
|
|
26
|
+
* @param {boolean} [options.legend] default: shown for several series, and for pie / donut. Clicking an entry hides / shows its series.
|
|
27
|
+
* @param {boolean} [options.table=false] adds a "Show as table" section with the values below the chart
|
|
28
|
+
* @param {boolean} [options.zero=true] line charts: false lets the value axis start near the smallest value
|
|
29
|
+
* @param {boolean} [options.zoom=false] line and area charts: drag over the plot to zoom into that range, double click (or the
|
|
30
|
+
* reset button, or 0 / Esc) to zoom out; with the keyboard on the plot: + and - zoom, the arrow keys pan
|
|
31
|
+
* @param {{from: number, to: number}|null} [options.zoomRange] the range in view, in the units of the x axis: milliseconds with
|
|
32
|
+
* `times`, otherwise the index of the point (-0.5 is the left edge of the first point)
|
|
33
|
+
* @param {(range: ({from: number, to: number}|null)) => void} [options.onZoom] called when a person zooms or resets
|
|
34
|
+
* @param {number} [options.maxPoints] `push` keeps at most this many points per series (the oldest are dropped)
|
|
35
|
+
* @param {number[]} [options.hiddenSeries] the series (or slices) that are hidden at the start; a person hides and shows them with the legend, and a redraw keeps that
|
|
36
|
+
* @param {boolean} [options.animate=true] the first drawing animates: bars grow, a line is drawn, slices pop in (not when it is redrawn, and not under reduced motion)
|
|
37
|
+
* @param {boolean} [options.interactive=true] line and area charts: false leaves out the pointer layer (tooltip that follows the pointer, zoom)
|
|
38
|
+
* @param {boolean} [options.gaps=false] line and area charts: a missing value (null, NaN, undefined) breaks the line, and a point on its own is a dot;
|
|
39
|
+
* without it the line goes on from the value before to the one after
|
|
40
|
+
* @param {{from: (number|Date|string), to: (number|Date|string)}} [options.timeRange] line and area charts with `times`: the range of the time axis, when it is not the one
|
|
41
|
+
* the data covers (the last hour, of which only the last quarter has been measured)
|
|
42
|
+
* @param {(value: number) => string} [options.format] how a value is written: on the axis, in the tooltips and in the table of values (default: whole numbers, otherwise two decimals)
|
|
43
|
+
* @param {(value: number) => string} [options.tickFormat] how the numbers of the value axis are written, when they should not be written like the values (a chart of whole numbers has ticks of 0.2)
|
|
44
|
+
* @param {{top?: number, right?: number, bottom?: number, left?: number}} [options.margin] room around the plot in px (default 40, 20, 50, 55): a chart without a title and a legend does not need the top
|
|
45
|
+
* @param {boolean} [options.responsive=false] the chart is as wide as its parent and follows it when it changes (`height` stays); `width` is only the first guess
|
|
46
|
+
* @returns {(SVGElement & {element: SVGElement, update: (options?: object) => SVGElement, destroy: () => void,
|
|
47
|
+
* zoom: (from: number, to: number) => void, resetZoom: () => void, getZoom: () => ({from: number, to: number}|null),
|
|
48
|
+
* push: (point: {x?: (number|Date|string), label?: string, values: (number|number[])}, config?: {maxPoints?: number}) => void,
|
|
49
|
+
* dataTable: (HTMLElement|null)})|null}
|
|
50
|
+
* the SVG element, which also carries the handle ({ element, update(options), destroy() }) of the other
|
|
51
|
+
* components; null when the options are invalid. `parent` is an element, an id or a selector.
|
|
52
|
+
* `push` adds a point to every series (a number for the first series, or one value per series; `x` is the time with
|
|
53
|
+
* `times`, `label` the category) and draws the chart again at most once per frame, however often it is called.
|
|
54
|
+
*/
|
|
55
|
+
export function generateChart(options?: {
|
|
56
|
+
type?: "bar" | "line" | "area" | "sparkline" | "pie" | "donut";
|
|
57
|
+
parent?: string | Element;
|
|
58
|
+
id?: string;
|
|
59
|
+
title?: string;
|
|
60
|
+
labels?: string[];
|
|
61
|
+
times?: (number | Date | string)[];
|
|
62
|
+
series: {
|
|
63
|
+
name?: string;
|
|
64
|
+
data: number[];
|
|
65
|
+
color?: string;
|
|
66
|
+
}[];
|
|
67
|
+
width?: number;
|
|
68
|
+
height?: number;
|
|
69
|
+
legend?: boolean;
|
|
70
|
+
table?: boolean;
|
|
71
|
+
zero?: boolean;
|
|
72
|
+
zoom?: boolean;
|
|
73
|
+
zoomRange?: {
|
|
74
|
+
from: number;
|
|
75
|
+
to: number;
|
|
76
|
+
} | null;
|
|
77
|
+
onZoom?: (range: ({
|
|
78
|
+
from: number;
|
|
79
|
+
to: number;
|
|
80
|
+
} | null)) => void;
|
|
81
|
+
maxPoints?: number;
|
|
82
|
+
hiddenSeries?: number[];
|
|
83
|
+
animate?: boolean;
|
|
84
|
+
interactive?: boolean;
|
|
85
|
+
gaps?: boolean;
|
|
86
|
+
timeRange?: {
|
|
87
|
+
from: (number | Date | string);
|
|
88
|
+
to: (number | Date | string);
|
|
89
|
+
};
|
|
90
|
+
format?: (value: number) => string;
|
|
91
|
+
tickFormat?: (value: number) => string;
|
|
92
|
+
margin?: {
|
|
93
|
+
top?: number;
|
|
94
|
+
right?: number;
|
|
95
|
+
bottom?: number;
|
|
96
|
+
left?: number;
|
|
97
|
+
};
|
|
98
|
+
responsive?: boolean;
|
|
99
|
+
}): (SVGElement & {
|
|
100
|
+
element: SVGElement;
|
|
101
|
+
update: (options?: object) => SVGElement;
|
|
102
|
+
destroy: () => void;
|
|
103
|
+
zoom: (from: number, to: number) => void;
|
|
104
|
+
resetZoom: () => void;
|
|
105
|
+
getZoom: () => ({
|
|
106
|
+
from: number;
|
|
107
|
+
to: number;
|
|
108
|
+
} | null);
|
|
109
|
+
push: (point: {
|
|
110
|
+
x?: (number | Date | string);
|
|
111
|
+
label?: string;
|
|
112
|
+
values: (number | number[]);
|
|
113
|
+
}, config?: {
|
|
114
|
+
maxPoints?: number;
|
|
115
|
+
}) => void;
|
|
116
|
+
dataTable: (HTMLElement | null);
|
|
117
|
+
}) | null;
|
|
@@ -1,120 +1,122 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Opens a dialog and resolves with the value of the button that was used,
|
|
3
|
-
* or with `null` when it was dismissed (Esc, the close button, a click on the backdrop).
|
|
4
|
-
*
|
|
5
|
-
* @param {object} options
|
|
6
|
-
* @param {string} [options.title]
|
|
7
|
-
* @param {string|Node|Array} [options.content] text is inserted as text, never as HTML
|
|
8
|
-
* @param {{text: string, value?: *, variant?: string, autofocus?: boolean}[]} [options.buttons]
|
|
9
|
-
* @param {boolean} [options.dismissible=true]
|
|
10
|
-
* @param {(value) => (boolean|Promise<boolean>)} [options.beforeClose] return false to keep the dialog open
|
|
11
|
-
* @param {"small"|"medium"|"large"|"full"} [options.size="medium"] width of the dialog (360 / 480 / 720 px / the whole window)
|
|
12
|
-
* @param {string} [options.class] extra CSS class(es) of the dialog element
|
|
13
|
-
* @returns {Promise<*> & {element: HTMLDialogElement, backdrop: HTMLDialogElement, close: (value?) => Promise<void>}}
|
|
14
|
-
* resolves with the pressed button's value; the promise also carries the handle of the open dialog
|
|
15
|
-
*/
|
|
16
|
-
export function showDialog(options?: {
|
|
17
|
-
title?: string;
|
|
18
|
-
content?: string | Node | any[];
|
|
19
|
-
buttons?: {
|
|
20
|
-
text: string;
|
|
21
|
-
value?: any;
|
|
22
|
-
variant?: string;
|
|
23
|
-
autofocus?: boolean;
|
|
24
|
-
}[];
|
|
25
|
-
dismissible?: boolean;
|
|
26
|
-
beforeClose?: (value: any) => (boolean | Promise<boolean>);
|
|
27
|
-
size?: "small" | "medium" | "large" | "full";
|
|
28
|
-
class?: string;
|
|
29
|
-
}): Promise<any> & {
|
|
30
|
-
element: HTMLDialogElement;
|
|
31
|
-
backdrop: HTMLDialogElement;
|
|
32
|
-
close: (value?: any) => Promise<void>;
|
|
33
|
-
};
|
|
34
|
-
/** Message with an OK button. Resolves when it is closed. */
|
|
35
|
-
export function alertDialog(message: any, { title, okText }?: {
|
|
36
|
-
okText?: any;
|
|
37
|
-
}): Promise<void>;
|
|
38
|
-
/** Question with confirm and cancel buttons. Resolves with true / false. See showConfirm for `typeToConfirm`. */
|
|
39
|
-
export function confirmDialog(message: any, options?: {}): Promise<boolean> & {
|
|
40
|
-
element: HTMLElement;
|
|
41
|
-
close: Function;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Asks for a confirmation. Resolves with true when confirmed, false when cancelled or dismissed.
|
|
45
|
-
*
|
|
46
|
-
* @param {object} options
|
|
47
|
-
* @param {string} [options.title]
|
|
48
|
-
* @param {string|Node|Array} options.message
|
|
49
|
-
* @param {string} [options.confirmText]
|
|
50
|
-
* @param {string} [options.cancelText]
|
|
51
|
-
* @param {boolean} [options.danger=false] red confirm button
|
|
52
|
-
* @param {string} [options.typeToConfirm] the person has to type exactly this text before the dialog confirms
|
|
53
|
-
* (for things that cannot be undone: the name of what is deleted)
|
|
54
|
-
* @param {"small"|"medium"|"large"|"full"} [options.size]
|
|
55
|
-
* @returns {Promise<boolean> & {element: HTMLElement, close: Function}}
|
|
56
|
-
*/
|
|
57
|
-
export function showConfirm({ title, message, confirmText, cancelText, danger, typeToConfirm, size }?: {
|
|
58
|
-
title?: string;
|
|
59
|
-
message: string | Node | any[];
|
|
60
|
-
confirmText?: string;
|
|
61
|
-
cancelText?: string;
|
|
62
|
-
danger?: boolean;
|
|
63
|
-
typeToConfirm?: string;
|
|
64
|
-
size?: "small" | "medium" | "large" | "full";
|
|
65
|
-
}): Promise<boolean> & {
|
|
66
|
-
element: HTMLElement;
|
|
67
|
-
close: Function;
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* A dialog that holds a form (see generateForm): validation, Enter submits, the button shows a spinner while it saves.
|
|
71
|
-
* `onSubmit(values, form)` saves. When it throws (or rejects) the message is shown in the dialog and the dialog stays open;
|
|
72
|
-
* `form.setErrors({ field: "message" })` marks single fields, for example with errors of the server. When it returns, the dialog closes.
|
|
73
|
-
*
|
|
74
|
-
* @param {object} options
|
|
75
|
-
* @param {string} [options.title]
|
|
76
|
-
* @param {string} [options.intro] text above the fields
|
|
77
|
-
* @param {string|Node|Array} [options.content] nodes above the fields
|
|
78
|
-
* @param {object[]} options.fields field definitions, see generateField
|
|
79
|
-
* @param {string} [options.submitText]
|
|
80
|
-
* @param {string} [options.cancelText]
|
|
81
|
-
* @param {boolean} [options.danger=false] red submit button
|
|
82
|
-
* @param {"small"|"medium"|"large"|"full"} [options.size]
|
|
83
|
-
* @param {
|
|
84
|
-
* @param {(form: object) => void}
|
|
85
|
-
* @
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* @param {string}
|
|
109
|
-
* @param {
|
|
110
|
-
* @param {string} [options.
|
|
111
|
-
* @param {string} [options.
|
|
112
|
-
* @param {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Opens a dialog and resolves with the value of the button that was used,
|
|
3
|
+
* or with `null` when it was dismissed (Esc, the close button, a click on the backdrop).
|
|
4
|
+
*
|
|
5
|
+
* @param {object} options
|
|
6
|
+
* @param {string} [options.title]
|
|
7
|
+
* @param {string|Node|Array} [options.content] text is inserted as text, never as HTML
|
|
8
|
+
* @param {{text: string, value?: *, variant?: string, autofocus?: boolean}[]} [options.buttons]
|
|
9
|
+
* @param {boolean} [options.dismissible=true]
|
|
10
|
+
* @param {(value) => (boolean|Promise<boolean>)} [options.beforeClose] return false to keep the dialog open
|
|
11
|
+
* @param {"small"|"medium"|"large"|"full"} [options.size="medium"] width of the dialog (360 / 480 / 720 px / the whole window)
|
|
12
|
+
* @param {string} [options.class] extra CSS class(es) of the dialog element
|
|
13
|
+
* @returns {Promise<*> & {element: HTMLDialogElement, backdrop: HTMLDialogElement, close: (value?) => Promise<void>}}
|
|
14
|
+
* resolves with the pressed button's value; the promise also carries the handle of the open dialog
|
|
15
|
+
*/
|
|
16
|
+
export function showDialog(options?: {
|
|
17
|
+
title?: string;
|
|
18
|
+
content?: string | Node | any[];
|
|
19
|
+
buttons?: {
|
|
20
|
+
text: string;
|
|
21
|
+
value?: any;
|
|
22
|
+
variant?: string;
|
|
23
|
+
autofocus?: boolean;
|
|
24
|
+
}[];
|
|
25
|
+
dismissible?: boolean;
|
|
26
|
+
beforeClose?: (value: any) => (boolean | Promise<boolean>);
|
|
27
|
+
size?: "small" | "medium" | "large" | "full";
|
|
28
|
+
class?: string;
|
|
29
|
+
}): Promise<any> & {
|
|
30
|
+
element: HTMLDialogElement;
|
|
31
|
+
backdrop: HTMLDialogElement;
|
|
32
|
+
close: (value?: any) => Promise<void>;
|
|
33
|
+
};
|
|
34
|
+
/** Message with an OK button. Resolves when it is closed. */
|
|
35
|
+
export function alertDialog(message: any, { title, okText }?: {
|
|
36
|
+
okText?: any;
|
|
37
|
+
}): Promise<void>;
|
|
38
|
+
/** Question with confirm and cancel buttons. Resolves with true / false. See showConfirm for `typeToConfirm`. */
|
|
39
|
+
export function confirmDialog(message: any, options?: {}): Promise<boolean> & {
|
|
40
|
+
element: HTMLElement;
|
|
41
|
+
close: Function;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Asks for a confirmation. Resolves with true when confirmed, false when cancelled or dismissed.
|
|
45
|
+
*
|
|
46
|
+
* @param {object} options
|
|
47
|
+
* @param {string} [options.title]
|
|
48
|
+
* @param {string|Node|Array} options.message
|
|
49
|
+
* @param {string} [options.confirmText]
|
|
50
|
+
* @param {string} [options.cancelText]
|
|
51
|
+
* @param {boolean} [options.danger=false] red confirm button
|
|
52
|
+
* @param {string} [options.typeToConfirm] the person has to type exactly this text before the dialog confirms
|
|
53
|
+
* (for things that cannot be undone: the name of what is deleted)
|
|
54
|
+
* @param {"small"|"medium"|"large"|"full"} [options.size]
|
|
55
|
+
* @returns {Promise<boolean> & {element: HTMLElement, close: Function}}
|
|
56
|
+
*/
|
|
57
|
+
export function showConfirm({ title, message, confirmText, cancelText, danger, typeToConfirm, size }?: {
|
|
58
|
+
title?: string;
|
|
59
|
+
message: string | Node | any[];
|
|
60
|
+
confirmText?: string;
|
|
61
|
+
cancelText?: string;
|
|
62
|
+
danger?: boolean;
|
|
63
|
+
typeToConfirm?: string;
|
|
64
|
+
size?: "small" | "medium" | "large" | "full";
|
|
65
|
+
}): Promise<boolean> & {
|
|
66
|
+
element: HTMLElement;
|
|
67
|
+
close: Function;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* A dialog that holds a form (see generateForm): validation, Enter submits, the button shows a spinner while it saves.
|
|
71
|
+
* `onSubmit(values, form)` saves. When it throws (or rejects) the message is shown in the dialog and the dialog stays open;
|
|
72
|
+
* `form.setErrors({ field: "message" })` marks single fields, for example with errors of the server. When it returns, the dialog closes.
|
|
73
|
+
*
|
|
74
|
+
* @param {object} options
|
|
75
|
+
* @param {string} [options.title]
|
|
76
|
+
* @param {string} [options.intro] text above the fields
|
|
77
|
+
* @param {string|Node|Array} [options.content] nodes above the fields
|
|
78
|
+
* @param {object[]} options.fields field definitions, see generateField
|
|
79
|
+
* @param {string} [options.submitText]
|
|
80
|
+
* @param {string} [options.cancelText]
|
|
81
|
+
* @param {boolean} [options.danger=false] red submit button
|
|
82
|
+
* @param {"small"|"medium"|"large"|"full"} [options.size]
|
|
83
|
+
* @param {boolean} [options.nested=false] a field called "soa.host" is `values.soa.host` (see generateForm, which also explains `show`, `label`, `send`, `trim` and `empty` of a field)
|
|
84
|
+
* @param {(values: object, form: object) => (void|Promise)} options.onSubmit
|
|
85
|
+
* @param {(form: object) => void} [options.onReady] called with the form once it is built
|
|
86
|
+
* @returns {Promise<boolean> & {element: HTMLElement, form: object, close: Function}} resolves with true when it was saved, false when dismissed
|
|
87
|
+
*/
|
|
88
|
+
export function showFormDialog({ title, intro, content, fields, submitText, cancelText, danger, size, nested, onSubmit, onReady }?: {
|
|
89
|
+
title?: string;
|
|
90
|
+
intro?: string;
|
|
91
|
+
content?: string | Node | any[];
|
|
92
|
+
fields: object[];
|
|
93
|
+
submitText?: string;
|
|
94
|
+
cancelText?: string;
|
|
95
|
+
danger?: boolean;
|
|
96
|
+
size?: "small" | "medium" | "large" | "full";
|
|
97
|
+
nested?: boolean;
|
|
98
|
+
onSubmit: (values: object, form: object) => (void | Promise<any>);
|
|
99
|
+
onReady?: (form: object) => void;
|
|
100
|
+
}): Promise<boolean> & {
|
|
101
|
+
element: HTMLElement;
|
|
102
|
+
form: object;
|
|
103
|
+
close: Function;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Asks for a text value. Resolves with the entered text, or null when cancelled.
|
|
107
|
+
*
|
|
108
|
+
* @param {string} message
|
|
109
|
+
* @param {object} [options]
|
|
110
|
+
* @param {string} [options.title]
|
|
111
|
+
* @param {string} [options.value] initial value
|
|
112
|
+
* @param {string} [options.placeholder]
|
|
113
|
+
* @param {string} [options.type="text"] input type
|
|
114
|
+
* @param {(value: string) => string} [options.validate] returns an error text, or "" when valid
|
|
115
|
+
*/
|
|
116
|
+
export function promptDialog(message: string, { title, value, placeholder, type, validate, okText, cancelText }?: {
|
|
117
|
+
title?: string;
|
|
118
|
+
value?: string;
|
|
119
|
+
placeholder?: string;
|
|
120
|
+
type?: string;
|
|
121
|
+
validate?: (value: string) => string;
|
|
122
|
+
}): Promise<any>;
|