|
1 |
| -import type { DataField } from "../../common/data/fields.js"; |
2 |
| - |
3 |
| -declare global { |
4 |
| - interface ApplicationConfiguration { |
5 |
| - /** An HTML element identifier used for this Application instance */ |
6 |
| - id: string; |
7 |
| - /** An string discriminator substituted for {id} in the default HTML element identifier for the class */ |
8 |
| - uniqueId: string; |
9 |
| - /** An array of CSS classes to apply to the Application */ |
10 |
| - classes: string[]; |
11 |
| - /** The HTMLElement tag type used for the outer Application frame */ |
12 |
| - tag: string; |
13 |
| - /** Configuration of the window behaviors for this Application */ |
14 |
| - window: ApplicationWindowConfiguration; |
15 |
| - /** Click actions supported by the Application and their event handler functions */ |
16 |
| - actions: Record<string, ApplicationClickAction>; |
17 |
| - /** Configuration used if the application top-level element is a form */ |
18 |
| - form?: ApplicationFormConfiguration; |
19 |
| - /** Default positioning data for the application */ |
20 |
| - position: Partial<ApplicationPosition>; |
21 |
| - } |
22 |
| - |
23 |
| - // todo: ApplicationPosition isn't quite the same as the original. Type it properly, but this will require research |
24 |
| - |
25 |
| - interface ApplicationWindowConfiguration { |
26 |
| - /** |
27 |
| - * Is this Application rendered inside a window frame? |
28 |
| - * @default true |
29 |
| - */ |
30 |
| - frame?: boolean; |
31 |
| - |
32 |
| - /** |
33 |
| - * Can this Application be positioned via JavaScript or only by CSS |
34 |
| - * @default true |
35 |
| - */ |
36 |
| - positioned?: boolean; |
37 |
| - |
38 |
| - /** The window title. Displayed only if the application is framed */ |
39 |
| - title?: string; |
40 |
| - |
41 |
| - /** An optional Font Awesome icon class displayed left of the window title */ |
42 |
| - icon?: string | false; |
43 |
| - |
44 |
| - /** An array of window control entries */ |
45 |
| - controls: ApplicationHeaderControlsEntry[]; |
46 |
| - |
47 |
| - /** |
48 |
| - * Can the window app be minimized by double-clicking on the title |
49 |
| - * @default true |
50 |
| - */ |
51 |
| - minimizable?: boolean; |
52 |
| - |
53 |
| - /** |
54 |
| - * Is this window resizable? |
55 |
| - * @default false |
56 |
| - */ |
57 |
| - resizable?: boolean; |
58 |
| - |
59 |
| - /** |
60 |
| - * A specific tag name to use for the .window-content element |
61 |
| - * @default "section" |
62 |
| - */ |
63 |
| - contentTag?: string; |
64 |
| - |
65 |
| - /** Additional CSS classes to apply to the .window-content element */ |
66 |
| - contentClasses?: string[]; |
67 |
| - } |
68 |
| - |
69 |
| - interface ApplicationFormConfiguration { |
70 |
| - handler: ApplicationFormSubmission; |
71 |
| - submitOnChange: boolean; |
72 |
| - closeOnSubmit: boolean; |
73 |
| - } |
74 |
| - |
75 |
| - interface ApplicationHeaderControlsEntry { |
76 |
| - /** A font-awesome icon class which denotes the control button */ |
77 |
| - icon: string; |
78 |
| - /** The text label for the control button */ |
79 |
| - label: string; |
80 |
| - /** The action name triggered by clicking the control button */ |
81 |
| - action: string; |
82 |
| - /** Is the control button visible for the current client? */ |
83 |
| - visible: boolean; |
84 |
| - } |
85 |
| - |
86 |
| - interface ApplicationConstructorParams { |
87 |
| - position: ApplicationPosition; |
88 |
| - } |
89 |
| - |
90 |
| - interface ApplicationRenderOptions { |
91 |
| - /** |
92 |
| - * Force application rendering. |
93 |
| - * If true, an application which does not yet exist in the DOM is added. |
94 |
| - * If false, only applications which already exist are rendered. |
95 |
| - * @default false |
96 |
| - */ |
97 |
| - force?: boolean; |
98 |
| - /** A specific position at which to render the Application */ |
99 |
| - position?: ApplicationPosition; |
100 |
| - /** Updates to the Application window frame */ |
101 |
| - window?: ApplicationWindowRenderOptions; |
102 |
| - /** |
103 |
| - * Some Application classes, for example the HandlebarsApplication, support re-rendering a subset of application |
104 |
| - * parts instead of the full Application HTML. |
105 |
| - */ |
106 |
| - parts?: string[]; |
107 |
| - /** Is this render the first one for the application? This property is populated automatically. */ |
108 |
| - isFirstRender?: boolean; |
109 |
| - } |
110 |
| - |
111 |
| - interface ApplicationWindowRenderOptions { |
112 |
| - /** Update the window title with a new value? */ |
113 |
| - title: string; |
114 |
| - /** Update the window icon with a new value? */ |
115 |
| - icon: string | false; |
116 |
| - /** Re-render the window controls menu? */ |
117 |
| - controls: boolean; |
118 |
| - } |
119 |
| - |
120 |
| - interface ApplicationClosingOptions { |
121 |
| - /** Whether to animate the close, or perform it instantaneously */ |
122 |
| - animate?: boolean; |
123 |
| - /** Whether the application was closed via keypress. */ |
124 |
| - closeKey?: boolean; |
125 |
| - } |
| 1 | +import type { DataField } from "../../common/data/fields.d.ts"; |
| 2 | + |
| 3 | +export interface ApplicationConfiguration { |
| 4 | + /** An HTML element identifier used for this Application instance */ |
| 5 | + id: string; |
| 6 | + /** An string discriminator substituted for {id} in the default HTML element identifier for the class */ |
| 7 | + uniqueId: string; |
| 8 | + /** An array of CSS classes to apply to the Application */ |
| 9 | + classes: string[]; |
| 10 | + /** The HTMLElement tag type used for the outer Application frame */ |
| 11 | + tag: string; |
| 12 | + /** Configuration of the window behaviors for this Application */ |
| 13 | + window: ApplicationWindowConfiguration; |
| 14 | + /** Click actions supported by the Application and their event handler functions */ |
| 15 | + actions: Record<string, ApplicationClickAction>; |
| 16 | + /** Configuration used if the application top-level element is a form */ |
| 17 | + form?: ApplicationFormConfiguration; |
| 18 | + /** Default positioning data for the application */ |
| 19 | + position: Partial<ApplicationPosition>; |
| 20 | +} |
| 21 | + |
| 22 | +export interface ApplicationWindowConfiguration { |
| 23 | + /** |
| 24 | + * Is this Application rendered inside a window frame? |
| 25 | + * @default true |
| 26 | + */ |
| 27 | + frame?: boolean; |
| 28 | + |
| 29 | + /** |
| 30 | + * Can this Application be positioned via JavaScript or only by CSS |
| 31 | + * @default true |
| 32 | + */ |
| 33 | + positioned?: boolean; |
| 34 | + |
| 35 | + /** The window title. Displayed only if the application is framed */ |
| 36 | + title?: string; |
| 37 | + |
| 38 | + /** An optional Font Awesome icon class displayed left of the window title */ |
| 39 | + icon?: string | false; |
| 40 | + |
| 41 | + /** An array of window control entries */ |
| 42 | + controls: ApplicationHeaderControlsEntry[]; |
126 | 43 |
|
127 | 44 | /**
|
128 |
| - * An on-click action supported by the Application |
129 |
| - * @param event The originating click event |
130 |
| - * @param target The capturing HTML element which defines the [data-action] |
| 45 | + * Can the window app be minimized by double-clicking on the title |
| 46 | + * @default true |
131 | 47 | */
|
132 |
| - type ApplicationClickAction = ( |
133 |
| - event: PointerEvent, |
134 |
| - target: HTMLElement, |
135 |
| - ) => Promise<void>; |
| 48 | + minimizable?: boolean; |
136 | 49 |
|
137 | 50 | /**
|
138 |
| - * A form submission handler method. |
139 |
| - * @param event The originating form submission or input change event |
140 |
| - * @param form The form element that was submitted |
141 |
| - * @param formData Processed data for the submitted form |
| 51 | + * Is this window resizable? |
| 52 | + * @default false |
142 | 53 | */
|
143 |
| - type ApplicationFormSubmission = ( |
144 |
| - event: SubmitEvent | Event, |
145 |
| - form: HTMLFormElement, |
146 |
| - formData: FormDataExtended, |
147 |
| - ) => Promise<void>; |
148 |
| - |
149 |
| - interface ApplicationTab { |
150 |
| - id: string; |
151 |
| - group: string; |
152 |
| - icon: string; |
153 |
| - label: string; |
154 |
| - active: boolean; |
155 |
| - cssClass: string; |
156 |
| - } |
157 |
| - |
158 |
| - interface FormNode { |
159 |
| - fieldset: boolean; |
160 |
| - legend?: string; |
161 |
| - fields?: FormNode[]; |
162 |
| - field?: DataField; |
163 |
| - value?: unknown; |
164 |
| - } |
165 |
| - |
166 |
| - interface FormFooterButton { |
167 |
| - type: string; |
168 |
| - name?: string; |
169 |
| - icon?: string; |
170 |
| - label?: string; |
171 |
| - action?: string; |
172 |
| - cssClass?: string; |
173 |
| - /** @default false */ |
174 |
| - disabled?: boolean; |
175 |
| - } |
| 54 | + resizable?: boolean; |
| 55 | + |
| 56 | + /** |
| 57 | + * A specific tag name to use for the .window-content element |
| 58 | + * @default "section" |
| 59 | + */ |
| 60 | + contentTag?: string; |
| 61 | + |
| 62 | + /** Additional CSS classes to apply to the .window-content element */ |
| 63 | + contentClasses?: string[]; |
| 64 | +} |
| 65 | + |
| 66 | +export interface ApplicationFormConfiguration { |
| 67 | + handler: ApplicationFormSubmission; |
| 68 | + submitOnChange: boolean; |
| 69 | + closeOnSubmit: boolean; |
| 70 | +} |
| 71 | + |
| 72 | +export interface ApplicationHeaderControlsEntry { |
| 73 | + /** A font-awesome icon class which denotes the control button */ |
| 74 | + icon: string; |
| 75 | + /** The text label for the control button */ |
| 76 | + label: string; |
| 77 | + /** The action name triggered by clicking the control button */ |
| 78 | + action: string; |
| 79 | + /** Is the control button visible for the current client? */ |
| 80 | + visible: boolean; |
| 81 | +} |
| 82 | + |
| 83 | +export interface ApplicationConstructorParams { |
| 84 | + position: ApplicationPosition; |
| 85 | +} |
| 86 | + |
| 87 | +export interface ApplicationRenderOptions { |
| 88 | + /** |
| 89 | + * Force application rendering. |
| 90 | + * If true, an application which does not yet exist in the DOM is added. |
| 91 | + * If false, only applications which already exist are rendered. |
| 92 | + * @default false |
| 93 | + */ |
| 94 | + force?: boolean; |
| 95 | + /** A specific position at which to render the Application */ |
| 96 | + position?: ApplicationPosition; |
| 97 | + /** Updates to the Application window frame */ |
| 98 | + window?: ApplicationWindowRenderOptions; |
| 99 | + /** |
| 100 | + * Some Application classes, for example the HandlebarsApplication, support re-rendering a subset of application |
| 101 | + * parts instead of the full Application HTML. |
| 102 | + */ |
| 103 | + parts?: string[]; |
| 104 | + /** Is this render the first one for the application? This property is populated automatically. */ |
| 105 | + isFirstRender?: boolean; |
| 106 | +} |
| 107 | + |
| 108 | +export interface ApplicationWindowRenderOptions { |
| 109 | + /** Update the window title with a new value? */ |
| 110 | + title: string; |
| 111 | + /** Update the window icon with a new value? */ |
| 112 | + icon: string | false; |
| 113 | + /** Re-render the window controls menu? */ |
| 114 | + controls: boolean; |
| 115 | +} |
| 116 | + |
| 117 | +type ApplicationRenderContext = object; |
| 118 | + |
| 119 | +export interface ApplicationClosingOptions { |
| 120 | + /** Whether to animate the close, or perform it instantaneously */ |
| 121 | + animate?: boolean; |
| 122 | + /** Whether the application was closed via keypress. */ |
| 123 | + closeKey?: boolean; |
| 124 | +} |
| 125 | + |
| 126 | +/** |
| 127 | + * An on-click action supported by the Application |
| 128 | + * @param event The originating click event |
| 129 | + * @param target The capturing HTML element which defines the [data-action] |
| 130 | + */ |
| 131 | +export type ApplicationClickAction = ( |
| 132 | + event: PointerEvent, |
| 133 | + target: HTMLElement, |
| 134 | +) => Promise<void>; |
| 135 | + |
| 136 | +/** |
| 137 | + * A form submission handler method. |
| 138 | + * @param event The originating form submission or input change event |
| 139 | + * @param form The form element that was submitted |
| 140 | + * @param formData Processed data for the submitted form |
| 141 | + */ |
| 142 | +export type ApplicationFormSubmission = ( |
| 143 | + event: SubmitEvent | Event, |
| 144 | + form: HTMLFormElement, |
| 145 | + formData: FormDataExtended, |
| 146 | +) => Promise<void>; |
| 147 | + |
| 148 | +export interface ApplicationTab { |
| 149 | + id: string; |
| 150 | + group: string; |
| 151 | + icon: string; |
| 152 | + label: string; |
| 153 | + active: boolean; |
| 154 | + cssClass: string; |
| 155 | +} |
| 156 | + |
| 157 | +export interface FormNode { |
| 158 | + fieldset: boolean; |
| 159 | + legend?: string; |
| 160 | + fields?: FormNode[]; |
| 161 | + field?: DataField; |
| 162 | + value?: unknown; |
| 163 | +} |
| 164 | + |
| 165 | +export interface FormFooterButton { |
| 166 | + type: string; |
| 167 | + name?: string; |
| 168 | + icon?: string; |
| 169 | + label?: string; |
| 170 | + action?: string; |
| 171 | + cssClass?: string; |
| 172 | + /** @default false */ |
| 173 | + disabled?: boolean; |
176 | 174 | }
|
0 commit comments