@vandenberghinc/volt 1.1.4 → 1.1.6
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/backend/dist/cjs/database.d.ts +41 -68
- package/backend/dist/cjs/database.js +136 -78
- package/backend/dist/cjs/endpoint.d.ts +23 -9
- package/backend/dist/cjs/endpoint.js +98 -21
- package/backend/dist/cjs/file_watcher.js +2 -2
- package/backend/dist/cjs/frontend.d.ts +0 -2
- package/backend/dist/cjs/frontend.js +9 -9
- package/backend/dist/cjs/image_endpoint.d.ts +3 -1
- package/backend/dist/cjs/image_endpoint.js +2 -1
- package/backend/dist/cjs/payments/paddle.js +10 -2
- package/backend/dist/cjs/plugins/css.d.ts +6 -5
- package/backend/dist/cjs/plugins/css.js +32 -7
- package/backend/dist/cjs/plugins/ts/compiler.d.ts +6 -1
- package/backend/dist/cjs/plugins/ts/compiler.js +26 -2
- package/backend/dist/cjs/plugins/ts/preprocessing.js +5 -3
- package/backend/dist/cjs/server.d.ts +7 -13
- package/backend/dist/cjs/server.js +184 -303
- package/backend/dist/cjs/status.d.ts +1 -0
- package/backend/dist/cjs/status.js +2 -1
- package/backend/dist/cjs/stream.d.ts +5 -3
- package/backend/dist/cjs/stream.js +13 -4
- package/backend/dist/cjs/users.d.ts +1 -1
- package/backend/dist/cjs/users.js +87 -72
- package/backend/dist/cjs/utils.d.ts +17 -9
- package/backend/dist/cjs/utils.js +22 -64
- package/backend/dist/cjs/view.d.ts +2 -2
- package/backend/dist/cjs/view.js +38 -40
- package/backend/dist/cjs/volt.d.ts +3 -2
- package/backend/dist/cjs/volt.js +2 -2
- package/backend/dist/css/volt.css +5 -0
- package/backend/dist/esm/database.d.ts +41 -68
- package/backend/dist/esm/database.js +137 -79
- package/backend/dist/esm/endpoint.d.ts +23 -9
- package/backend/dist/esm/endpoint.js +99 -22
- package/backend/dist/esm/file_watcher.js +2 -2
- package/backend/dist/esm/frontend.d.ts +0 -2
- package/backend/dist/esm/frontend.js +9 -9
- package/backend/dist/esm/image_endpoint.d.ts +3 -1
- package/backend/dist/esm/image_endpoint.js +2 -1
- package/backend/dist/esm/payments/paddle.js +11 -3
- package/backend/dist/esm/plugins/css.d.ts +6 -5
- package/backend/dist/esm/plugins/css.js +32 -6
- package/backend/dist/esm/plugins/ts/compiler.d.ts +6 -1
- package/backend/dist/esm/plugins/ts/compiler.js +26 -2
- package/backend/dist/esm/plugins/ts/preprocessing.js +5 -3
- package/backend/dist/esm/server.d.ts +7 -13
- package/backend/dist/esm/server.js +182 -301
- package/backend/dist/esm/status.d.ts +1 -0
- package/backend/dist/esm/status.js +1 -0
- package/backend/dist/esm/stream.d.ts +5 -3
- package/backend/dist/esm/stream.js +13 -4
- package/backend/dist/esm/users.d.ts +1 -1
- package/backend/dist/esm/users.js +87 -72
- package/backend/dist/esm/utils.d.ts +17 -9
- package/backend/dist/esm/utils.js +21 -62
- package/backend/dist/esm/view.d.ts +2 -2
- package/backend/dist/esm/view.js +38 -40
- package/backend/dist/esm/volt.d.ts +3 -2
- package/backend/dist/esm/volt.js +2 -1
- package/backend/dist/esm-dev/blacklist.js +1 -1
- package/backend/dist/esm-dev/cli.js +2 -2
- package/backend/dist/esm-dev/database.d.ts +41 -68
- package/backend/dist/esm-dev/database.js +138 -80
- package/backend/dist/esm-dev/endpoint.d.ts +23 -9
- package/backend/dist/esm-dev/endpoint.js +100 -23
- package/backend/dist/esm-dev/file_watcher.js +3 -3
- package/backend/dist/esm-dev/frontend.d.ts +0 -2
- package/backend/dist/esm-dev/frontend.js +9 -9
- package/backend/dist/esm-dev/image_endpoint.d.ts +3 -1
- package/backend/dist/esm-dev/image_endpoint.js +2 -1
- package/backend/dist/esm-dev/logger.js +1 -1
- package/backend/dist/esm-dev/payments/paddle.js +12 -4
- package/backend/dist/esm-dev/plugins/css.d.ts +6 -5
- package/backend/dist/esm-dev/plugins/css.js +33 -7
- package/backend/dist/esm-dev/plugins/ts/compiler.d.ts +6 -1
- package/backend/dist/esm-dev/plugins/ts/compiler.js +27 -3
- package/backend/dist/esm-dev/plugins/ts/preprocessing.js +7 -5
- package/backend/dist/esm-dev/rate_limit.js +1 -1
- package/backend/dist/esm-dev/server.d.ts +7 -13
- package/backend/dist/esm-dev/server.js +184 -303
- package/backend/dist/esm-dev/status.d.ts +1 -0
- package/backend/dist/esm-dev/status.js +1 -0
- package/backend/dist/esm-dev/stream.d.ts +5 -3
- package/backend/dist/esm-dev/stream.js +13 -4
- package/backend/dist/esm-dev/users.d.ts +1 -1
- package/backend/dist/esm-dev/users.js +88 -73
- package/backend/dist/esm-dev/utils.d.ts +17 -9
- package/backend/dist/esm-dev/utils.js +22 -63
- package/backend/dist/esm-dev/view.d.ts +2 -2
- package/backend/dist/esm-dev/view.js +39 -41
- package/backend/dist/esm-dev/volt.d.ts +3 -2
- package/backend/dist/esm-dev/volt.js +2 -1
- package/backend/src/database.ts +173 -155
- package/backend/src/endpoint.ts +123 -31
- package/backend/src/file_watcher.ts +2 -2
- package/backend/src/frontend.ts +9 -8
- package/backend/src/image_endpoint.ts +4 -0
- package/backend/src/payments/paddle.ts +11 -3
- package/backend/src/plugins/css.ts +36 -8
- package/backend/src/plugins/ts/compiler.ts +37 -1
- package/backend/src/plugins/ts/preprocessing.ts +5 -3
- package/backend/src/server.ts +167 -306
- package/backend/src/status.ts +1 -0
- package/backend/src/stream.ts +28 -8
- package/backend/src/users.ts +87 -72
- package/backend/src/utils.ts +58 -25
- package/backend/src/view.ts +30 -28
- package/backend/src/{volt.js → volt.ts} +2 -1
- package/backend/tsconfig.cjs.json +3 -3
- package/backend/tsconfig.esm.json +3 -3
- package/frontend/dist/elements/base.d.ts +414 -432
- package/frontend/dist/elements/base.js +566 -329
- package/frontend/dist/elements/module.d.ts +26 -12
- package/frontend/dist/elements/module.js +69 -32
- package/frontend/dist/elements/register_element.d.ts +3 -0
- package/frontend/dist/elements/register_element.js +22 -0
- package/frontend/dist/modules/auth.d.ts +1 -0
- package/frontend/dist/modules/auth.js +6 -5
- package/frontend/dist/modules/color.d.ts +159 -0
- package/frontend/dist/modules/color.js +315 -0
- package/frontend/dist/modules/colors.d.ts +1 -26
- package/frontend/dist/modules/colors.js +417 -340
- package/frontend/dist/modules/cookies.d.ts +1 -0
- package/frontend/dist/modules/cookies.js +1 -0
- package/frontend/dist/modules/events.d.ts +1 -0
- package/frontend/dist/modules/events.js +1 -0
- package/frontend/dist/modules/google.d.ts +1 -0
- package/frontend/dist/modules/google.js +1 -0
- package/frontend/dist/modules/meta.d.ts +1 -0
- package/frontend/dist/modules/meta.js +1 -0
- package/frontend/dist/modules/mutex.d.ts +1 -2
- package/frontend/dist/modules/mutex.js +3 -4
- package/frontend/dist/modules/paddle.d.ts +1 -0
- package/frontend/dist/modules/paddle.js +14 -13
- package/frontend/dist/modules/scheme.d.ts +1 -0
- package/frontend/dist/modules/scheme.js +5 -3
- package/frontend/dist/modules/statics.d.ts +1 -0
- package/frontend/dist/modules/statics.js +1 -0
- package/frontend/dist/modules/support.d.ts +1 -0
- package/frontend/dist/modules/support.js +3 -2
- package/frontend/dist/modules/theme.d.ts +56 -0
- package/frontend/dist/{ui → modules}/theme.js +186 -75
- package/frontend/dist/modules/themes.d.ts +1 -1
- package/frontend/dist/modules/themes.js +1 -0
- package/frontend/dist/modules/user.d.ts +1 -0
- package/frontend/dist/modules/user.js +11 -10
- package/frontend/dist/modules/utils.d.ts +23 -2
- package/frontend/dist/modules/utils.js +93 -1
- package/frontend/dist/types/gradient.js +4 -0
- package/frontend/dist/ui/border_button.d.ts +0 -25
- package/frontend/dist/ui/border_button.js +50 -51
- package/frontend/dist/ui/button.d.ts +0 -21
- package/frontend/dist/ui/button.js +41 -46
- package/frontend/dist/ui/canvas.js +15 -15
- package/frontend/dist/ui/checkbox.d.ts +3 -17
- package/frontend/dist/ui/checkbox.js +36 -30
- package/frontend/dist/ui/code.d.ts +15 -82
- package/frontend/dist/ui/code.js +150 -125
- package/frontend/dist/ui/color.d.ts +0 -1
- package/frontend/dist/ui/color.js +1 -1
- package/frontend/dist/ui/context_menu.d.ts +4 -2
- package/frontend/dist/ui/context_menu.js +16 -17
- package/frontend/dist/ui/css.js +2 -0
- package/frontend/dist/ui/divider.d.ts +0 -7
- package/frontend/dist/ui/divider.js +21 -25
- package/frontend/dist/ui/dropdown.d.ts +13 -7
- package/frontend/dist/ui/dropdown.js +65 -30
- package/frontend/dist/ui/for_each.d.ts +0 -5
- package/frontend/dist/ui/for_each.js +17 -22
- package/frontend/dist/ui/form.d.ts +17 -12
- package/frontend/dist/ui/form.js +21 -18
- package/frontend/dist/ui/frame_modes.d.ts +9 -12
- package/frontend/dist/ui/frame_modes.js +8 -10
- package/frontend/dist/ui/google_map.d.ts +0 -11
- package/frontend/dist/ui/google_map.js +23 -28
- package/frontend/dist/ui/gradient.d.ts +0 -5
- package/frontend/dist/ui/gradient.js +17 -22
- package/frontend/dist/ui/image.d.ts +27 -58
- package/frontend/dist/ui/image.js +99 -93
- package/frontend/dist/ui/input.d.ts +20 -97
- package/frontend/dist/ui/input.js +192 -170
- package/frontend/dist/ui/link.d.ts +0 -18
- package/frontend/dist/ui/link.js +42 -48
- package/frontend/dist/ui/list.js +36 -37
- package/frontend/dist/ui/loader_button.d.ts +4 -19
- package/frontend/dist/ui/loader_button.js +35 -37
- package/frontend/dist/ui/loaders.d.ts +0 -8
- package/frontend/dist/ui/loaders.js +20 -25
- package/frontend/dist/ui/popup.d.ts +11 -8
- package/frontend/dist/ui/popup.js +183 -24
- package/frontend/dist/ui/pseudo.d.ts +3 -3
- package/frontend/dist/ui/pseudo.js +14 -17
- package/frontend/dist/ui/scroller.d.ts +10 -48
- package/frontend/dist/ui/scroller.js +306 -300
- package/frontend/dist/ui/slider.d.ts +9 -3
- package/frontend/dist/ui/slider.js +31 -17
- package/frontend/dist/ui/spacer.d.ts +0 -9
- package/frontend/dist/ui/spacer.js +21 -26
- package/frontend/dist/ui/span.js +13 -15
- package/frontend/dist/ui/stack.d.ts +14 -75
- package/frontend/dist/ui/stack.js +166 -169
- package/frontend/dist/ui/steps.d.ts +10 -23
- package/frontend/dist/ui/steps.js +47 -34
- package/frontend/dist/ui/style.d.ts +4 -3
- package/frontend/dist/ui/style.js +13 -18
- package/frontend/dist/ui/switch.d.ts +10 -4
- package/frontend/dist/ui/switch.js +24 -16
- package/frontend/dist/ui/table.d.ts +0 -23
- package/frontend/dist/ui/table.js +113 -119
- package/frontend/dist/ui/tabs.d.ts +3 -19
- package/frontend/dist/ui/tabs.js +35 -29
- package/frontend/dist/ui/text.d.ts +0 -8
- package/frontend/dist/ui/text.js +20 -25
- package/frontend/dist/ui/title.d.ts +0 -15
- package/frontend/dist/ui/title.js +39 -45
- package/frontend/dist/ui/ui.d.ts +0 -2
- package/frontend/dist/ui/ui.js +0 -2
- package/frontend/dist/ui/view.d.ts +3 -17
- package/frontend/dist/ui/view.js +27 -32
- package/frontend/dist/volt.d.ts +2 -1
- package/frontend/dist/volt.js +3 -1
- package/frontend/examples/dashboard/dashboard.ts +774 -0
- package/frontend/examples/theme/theme.ts +58 -0
- package/frontend/src/css/volt.css +5 -0
- package/frontend/src/elements/base.ts +767 -545
- package/frontend/src/elements/module.ts +90 -29
- package/frontend/src/elements/register_element.ts +24 -0
- package/frontend/src/modules/auth.ts +7 -6
- package/frontend/src/modules/color.ts +348 -0
- package/frontend/src/modules/colors.ts +468 -449
- package/frontend/src/modules/cookies.ts +1 -0
- package/frontend/src/modules/events.ts +1 -0
- package/frontend/src/modules/google.ts +1 -0
- package/frontend/src/modules/meta.ts +2 -1
- package/frontend/src/modules/mutex.ts +2 -4
- package/frontend/src/modules/paddle.ts +21 -20
- package/frontend/src/modules/scheme.ts +5 -4
- package/frontend/src/modules/statics.ts +2 -1
- package/frontend/src/modules/support.ts +3 -2
- package/frontend/src/modules/theme.ts +413 -0
- package/frontend/src/modules/themes.ts +2 -1
- package/frontend/src/modules/user.ts +12 -11
- package/frontend/src/modules/utils.ts +125 -2
- package/frontend/src/ui/border_button.ts +41 -37
- package/frontend/src/ui/button.ts +33 -32
- package/frontend/src/ui/canvas.ts +5 -2
- package/frontend/src/ui/checkbox.ts +21 -22
- package/frontend/src/ui/code.ts +92 -86
- package/frontend/src/ui/context_menu.ts +7 -5
- package/frontend/src/ui/css.ts +1 -1
- package/frontend/src/ui/divider.ts +15 -10
- package/frontend/src/ui/dropdown.ts +38 -21
- package/frontend/src/ui/for_each.ts +9 -8
- package/frontend/src/ui/form.ts +26 -21
- package/frontend/src/ui/frame_modes.ts +13 -17
- package/frontend/src/ui/google_map.ts +15 -13
- package/frontend/src/ui/gradient.ts +9 -8
- package/frontend/src/ui/image.ts +108 -86
- package/frontend/src/ui/input.ts +145 -144
- package/frontend/src/ui/link.ts +25 -23
- package/frontend/src/ui/list.ts +12 -6
- package/frontend/src/ui/loader_button.ts +26 -25
- package/frontend/src/ui/loaders.ts +12 -11
- package/frontend/src/ui/popup.ts +168 -14
- package/frontend/src/ui/pseudo.ts +5 -3
- package/frontend/src/ui/scroller.ts +303 -294
- package/frontend/src/ui/slider.ts +15 -10
- package/frontend/src/ui/spacer.ts +14 -11
- package/frontend/src/ui/span.ts +6 -2
- package/frontend/src/ui/stack.ts +196 -183
- package/frontend/src/ui/steps.ts +38 -22
- package/frontend/src/ui/style.ts +7 -4
- package/frontend/src/ui/switch.ts +16 -11
- package/frontend/src/ui/table.ts +42 -34
- package/frontend/src/ui/tabs.ts +20 -19
- package/frontend/src/ui/text.ts +12 -11
- package/frontend/src/ui/title.ts +22 -20
- package/frontend/src/ui/ui.ts +0 -2
- package/frontend/src/ui/view.ts +20 -19
- package/frontend/src/volt.ts +3 -1
- package/frontend/{compile.js → tools/compile.old.js} +2 -2
- package/frontend/tools/embed_scripts.js +69 -0
- package/frontend/tsconfig.json +26 -0
- package/package.json +7 -6
- package/frontend/dist/ui/theme.d.ts +0 -25
- package/frontend/exports.json +0 -1340
- package/frontend/src/modules/date.js +0 -535
- package/frontend/src/ui/color.ts +0 -117
- package/frontend/src/ui/theme.ts +0 -279
- /package/backend/src/{vinc.dev.js → vinc.dev.ts} +0 -0
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// Imports.
|
|
7
|
-
import { Elements } from "../elements/module.js"
|
|
7
|
+
import { Elements, VElementBaseSignature, VElement } from "../elements/module.js"
|
|
8
8
|
import { Utils } from "../modules/utils.js"
|
|
9
9
|
import { VStack, VStackElement, AnchorVStack, AnchorVStackElement, HStack, HStackElement, AnchorHStack, AnchorHStackElement } from "./stack"
|
|
10
10
|
import { ForEach } from "./for_each"
|
|
11
11
|
import { ImageMask, ImageMaskElement } from "./image"
|
|
12
12
|
import { Text } from "./text"
|
|
13
|
+
import { AnyElement } from "./any_element.js"
|
|
13
14
|
|
|
14
15
|
type DropdownCallback = (element: DropdownElement) => void;
|
|
15
16
|
|
|
@@ -95,11 +96,16 @@ type DropdownCallback = (element: DropdownElement) => void;
|
|
|
95
96
|
@type: boolean
|
|
96
97
|
@default: false
|
|
97
98
|
*/
|
|
98
|
-
@Elements.
|
|
99
|
-
|
|
99
|
+
@Elements.create({
|
|
100
|
+
name: "DropdownElement",
|
|
101
|
+
})
|
|
102
|
+
export class DropdownElement extends (VStackElement as any as VElementBaseSignature) {
|
|
103
|
+
|
|
104
|
+
// Static attributes.
|
|
105
|
+
static element_name = "DropdownElement";
|
|
100
106
|
|
|
101
107
|
// @ts-expect-error
|
|
102
|
-
|
|
108
|
+
public target: AnyElement | HTMLElement;
|
|
103
109
|
// @ts-expect-error
|
|
104
110
|
public animate: boolean;
|
|
105
111
|
// @ts-expect-error
|
|
@@ -151,7 +157,7 @@ export class DropdownElement extends VStackElement {
|
|
|
151
157
|
y_offset = undefined,
|
|
152
158
|
content = undefined,
|
|
153
159
|
}: {
|
|
154
|
-
target: HTMLElement,
|
|
160
|
+
target: AnyElement | HTMLElement,
|
|
155
161
|
animate?: boolean,
|
|
156
162
|
duration?: number,
|
|
157
163
|
side?: string,
|
|
@@ -174,12 +180,13 @@ export class DropdownElement extends VStackElement {
|
|
|
174
180
|
on_click?: Function,
|
|
175
181
|
on_click_redirect?: string,
|
|
176
182
|
anchor?: boolean,
|
|
177
|
-
|
|
183
|
+
ellipsis_overflow?: boolean;
|
|
184
|
+
}[],
|
|
178
185
|
}) {
|
|
179
186
|
|
|
180
187
|
// Base.
|
|
181
188
|
super();
|
|
182
|
-
this.
|
|
189
|
+
this._init({
|
|
183
190
|
derived: DropdownElement,
|
|
184
191
|
})
|
|
185
192
|
|
|
@@ -243,7 +250,12 @@ export class DropdownElement extends VStackElement {
|
|
|
243
250
|
.color("white")
|
|
244
251
|
.font_size("inherit")
|
|
245
252
|
.wrap(false)
|
|
246
|
-
|
|
253
|
+
.margin(0)
|
|
254
|
+
.exec(e => {
|
|
255
|
+
if (item.ellipsis_overflow) {
|
|
256
|
+
e.ellipsis_overflow(item.ellipsis_overflow);
|
|
257
|
+
}
|
|
258
|
+
})
|
|
247
259
|
)
|
|
248
260
|
.text_decoration("none")
|
|
249
261
|
.border("none")
|
|
@@ -320,24 +332,29 @@ export class DropdownElement extends VStackElement {
|
|
|
320
332
|
|
|
321
333
|
// Show.
|
|
322
334
|
clearTimeout(this.animation_timeout);
|
|
335
|
+
|
|
323
336
|
this.transition("");
|
|
324
337
|
this._get_frame();
|
|
338
|
+
this.hide();
|
|
325
339
|
this.max_width(this._frame_min_width)
|
|
326
340
|
this.max_height(this._frame_min_height)
|
|
327
341
|
this.opacity(0)
|
|
328
|
-
|
|
329
|
-
this.show()
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
342
|
+
this.transition(this.animate ? `opacity ${this.duration * 0.8}ms ease-in, max-height ${this.duration}ms ease-in-out, max-width ${this.duration}ms ease-in-out` : "").getBoundingClientRect()
|
|
343
|
+
this.show()
|
|
344
|
+
const rect = this.target.getBoundingClientRect();
|
|
345
|
+
this.position(
|
|
346
|
+
rect.top + this.y_offset + (this.below_target ? rect.height : 0),
|
|
347
|
+
this.side !== "left" ? (window.innerWidth - rect.right - this.x_offset) : undefined,
|
|
348
|
+
undefined,
|
|
349
|
+
this.side === "left" ? (rect.left + this.x_offset) : undefined
|
|
350
|
+
)
|
|
351
|
+
this.getBoundingClientRect();
|
|
352
|
+
setTimeout(() => {
|
|
353
|
+
this
|
|
354
|
+
.opacity(1)
|
|
355
|
+
.max_width(this._frame_max_width)
|
|
356
|
+
.max_height(this._frame_max_height)
|
|
357
|
+
}, 25)
|
|
341
358
|
|
|
342
359
|
// Close handler.
|
|
343
360
|
if (this.close_handler == null) {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// Imports.
|
|
7
|
-
import { Elements, VElementTagMap } from "../elements/module.js"
|
|
7
|
+
import { Elements, VElementBaseSignature, VElement, VElementTagMap } from "../elements/module.js"
|
|
8
8
|
|
|
9
9
|
// Marcros.
|
|
10
10
|
type ArrayCallback = ((item: any, index: number, is_last: boolean) => any);
|
|
@@ -16,15 +16,16 @@ type ObjectCallback2 = ((value: any, key: string) => any);
|
|
|
16
16
|
type ObjectCallback3 = ((value: any) => any);
|
|
17
17
|
|
|
18
18
|
// ForEach.
|
|
19
|
-
@Elements.
|
|
19
|
+
@Elements.create({
|
|
20
|
+
name: "ForEachElement",
|
|
21
|
+
default_style: {
|
|
22
|
+
"border": "none",
|
|
23
|
+
"outline": "none",
|
|
24
|
+
"background": "transparent",
|
|
25
|
+
},
|
|
26
|
+
})
|
|
20
27
|
export class ForEachElement extends VElementTagMap.section {
|
|
21
28
|
|
|
22
|
-
static default_style = {
|
|
23
|
-
"border": "none",
|
|
24
|
-
"outline": "none",
|
|
25
|
-
"background": "transparent",
|
|
26
|
-
};
|
|
27
|
-
|
|
28
29
|
// Constructor.
|
|
29
30
|
constructor(items: Array<any>, func: ArrayCallback);
|
|
30
31
|
constructor(items: Array<any>, func: ArrayCallback1);
|
package/frontend/src/ui/form.ts
CHANGED
|
@@ -4,30 +4,35 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// Imports.
|
|
7
|
-
import { Elements, VElement, isVElement } from "../elements/module.js"
|
|
7
|
+
import { Elements, VElementBaseSignature, VElement, isVElement, AppendType } from "../elements/module.js"
|
|
8
|
+
import { AnyElement } from "./any_element.js"
|
|
9
|
+
import { CheckBoxElement } from "./checkbox.js"
|
|
10
|
+
import { ExtendedInputElement, ExtendedSelectElement, InputElement } from "./input.js"
|
|
8
11
|
import { VStack, VStackElement } from "./stack"
|
|
9
12
|
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
export
|
|
13
|
+
// Macros.
|
|
14
|
+
export type OnSubmit<This> = (element: This, data: Record<string, any>) => any;
|
|
15
|
+
export type OnSubmitError<This> = (element: This, error: Error) => any;
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
// Extended input.
|
|
18
|
+
@Elements.create({
|
|
19
|
+
name: "FormElement",
|
|
20
|
+
})
|
|
21
|
+
export class FormElement extends (VStackElement as any as VElementBaseSignature) {
|
|
17
22
|
|
|
18
23
|
// Attributes.
|
|
19
24
|
public _button?: VElement;
|
|
20
|
-
public fields: Record<string,
|
|
21
|
-
public _on_submit?: OnSubmit
|
|
22
|
-
public _on_submit_error?: OnSubmitError
|
|
25
|
+
public fields: Record<string, ExtendedInputElement | ExtendedSelectElement | CheckBoxElement>;
|
|
26
|
+
public _on_submit?: OnSubmit<this>;
|
|
27
|
+
public _on_submit_error?: OnSubmitError<this>;
|
|
23
28
|
public _on_append_callback: (child: any) => void;
|
|
24
29
|
|
|
25
30
|
// Constructor.
|
|
26
|
-
constructor(...children:
|
|
31
|
+
constructor(...children: AppendType[]) {
|
|
27
32
|
|
|
28
33
|
// Initialize super.
|
|
29
34
|
super();
|
|
30
|
-
this.
|
|
35
|
+
this._init({
|
|
31
36
|
derived: FormElement,
|
|
32
37
|
})
|
|
33
38
|
|
|
@@ -40,10 +45,10 @@ export class FormElement extends VStackElement {
|
|
|
40
45
|
this._on_append_callback = (child: any) => {
|
|
41
46
|
|
|
42
47
|
// Initialize field.
|
|
43
|
-
if (child.
|
|
48
|
+
if (child.element_name === "ExtendedInputElement" || child.element_name === "ExtendedSelectElement" || child.element_name === "CheckBoxElement") {
|
|
44
49
|
const id = child.id();
|
|
45
50
|
if (id != null && id !== "") {
|
|
46
|
-
_this.fields[id] = child;
|
|
51
|
+
_this.fields[id] = child as any;
|
|
47
52
|
child.on_input(() => {
|
|
48
53
|
if (child.missing() === true) {
|
|
49
54
|
child.missing(false);
|
|
@@ -54,7 +59,7 @@ export class FormElement extends VStackElement {
|
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
// Initialize button.
|
|
57
|
-
else if (/*_this._button === undefined &&*/ (child.
|
|
62
|
+
else if (/*_this._button === undefined &&*/ (child.element_name === "ButtonElement" || child.element_name === "LoaderButtonElement") && child.on_click() == null) { // && child.attr("submit_button") != "false"
|
|
58
63
|
if (_this._button !== undefined) {
|
|
59
64
|
_this._button.on_click(() => {})
|
|
60
65
|
}
|
|
@@ -184,20 +189,20 @@ export class FormElement extends VStackElement {
|
|
|
184
189
|
|
|
185
190
|
// Set the on submit callback, the params for the callback are `(element, data) => {}`.
|
|
186
191
|
// @ts-expect-error
|
|
187
|
-
on_submit() : undefined | OnSubmit
|
|
192
|
+
on_submit() : undefined | OnSubmit<this>
|
|
188
193
|
// @ts-expect-error
|
|
189
|
-
on_submit(callback: OnSubmit) : this;
|
|
194
|
+
on_submit(callback: OnSubmit<this>) : this;
|
|
190
195
|
// @ts-expect-error
|
|
191
|
-
on_submit(callback?: OnSubmit) : this | undefined | OnSubmit {
|
|
196
|
+
on_submit(callback?: OnSubmit<this>) : this | undefined | OnSubmit<this> {
|
|
192
197
|
if (callback == null) { return this._on_submit; }
|
|
193
198
|
this._on_submit = callback;
|
|
194
199
|
return this;
|
|
195
200
|
}
|
|
196
201
|
|
|
197
202
|
// Set the on submit error callback, the params for the callback are `(element, error) => {}`.
|
|
198
|
-
on_submit_error() : undefined | OnSubmitError
|
|
199
|
-
on_submit_error(callback: OnSubmitError) : this;
|
|
200
|
-
on_submit_error(callback?: OnSubmitError) : this | undefined | OnSubmitError {
|
|
203
|
+
on_submit_error() : undefined | OnSubmitError<this>
|
|
204
|
+
on_submit_error(callback: OnSubmitError<this>) : this;
|
|
205
|
+
on_submit_error(callback?: OnSubmitError<this>) : this | undefined | OnSubmitError<this> {
|
|
201
206
|
if (callback == null) { return this._on_submit_error; }
|
|
202
207
|
this._on_submit_error = callback;
|
|
203
208
|
return this;
|
|
@@ -4,18 +4,16 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// Imports.
|
|
7
|
-
import { Elements } from "../elements/module.js"
|
|
7
|
+
import { Elements, VElementBaseSignature, VElement, AppendType, VBaseElements } from "../elements/module.js"
|
|
8
8
|
|
|
9
9
|
// Nodes type.
|
|
10
|
-
export class
|
|
11
|
-
|
|
10
|
+
export class FrameNodes extends Array<VElement> {
|
|
11
|
+
constructor(...children: VElement[]) {
|
|
12
12
|
super(...children)
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
export const FrameNodes = Elements.wrapper(FrameNodesType);
|
|
16
|
-
export const NullFrameNodes = Elements.create_null(FrameNodesType);
|
|
17
15
|
|
|
18
|
-
type OnSet = (mode: string, nodes:
|
|
16
|
+
type OnSet = (mode: string, nodes: FrameNodes) => any
|
|
19
17
|
|
|
20
18
|
// Frame mode used to switch easily between frames.
|
|
21
19
|
/* @docs:
|
|
@@ -27,10 +25,10 @@ type OnSet = (mode: string, nodes: FrameNodesType) => any
|
|
|
27
25
|
|
|
28
26
|
Afterwards the mode can be set using `MyMode.set("my_mode")`.
|
|
29
27
|
*/
|
|
30
|
-
export class
|
|
28
|
+
export class FrameModes {
|
|
31
29
|
|
|
32
30
|
// Attributes.
|
|
33
|
-
public modes: Record<string,
|
|
31
|
+
public modes: Record<string, FrameNodes> = {};
|
|
34
32
|
public active?: string;
|
|
35
33
|
public _on_set?: OnSet;
|
|
36
34
|
|
|
@@ -40,17 +38,17 @@ export class FrameModesType {
|
|
|
40
38
|
if (this.active == null) {
|
|
41
39
|
this.active = mode;
|
|
42
40
|
}
|
|
43
|
-
this.modes[mode] = FrameNodes();
|
|
41
|
+
this.modes[mode] = new FrameNodes();
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
// Get.
|
|
48
|
-
get(mode: string) :
|
|
46
|
+
get(mode: string) : FrameNodes {
|
|
49
47
|
const nodes = this.modes[mode];
|
|
50
48
|
if (nodes === undefined) {
|
|
51
49
|
throw new Error(`Requested mode "${mode}" does not exist.`);
|
|
52
50
|
}
|
|
53
|
-
return nodes as
|
|
51
|
+
return nodes as FrameNodes;
|
|
54
52
|
}
|
|
55
53
|
|
|
56
54
|
// Set mode.
|
|
@@ -90,14 +88,12 @@ export class FrameModesType {
|
|
|
90
88
|
return this;
|
|
91
89
|
}
|
|
92
90
|
}
|
|
93
|
-
export const FrameModes = Elements.wrapper(FrameModesType);
|
|
94
|
-
export const NullFrameModes = Elements.create_null(FrameModesType);
|
|
95
91
|
|
|
96
92
|
// Extend VElement.
|
|
97
93
|
declare global {
|
|
98
94
|
interface VElementExtensions {
|
|
99
|
-
frame_mode(frame_mode:
|
|
100
|
-
frame_mode(frame_modes:
|
|
95
|
+
frame_mode(frame_mode: FrameNodes): this;
|
|
96
|
+
frame_mode(frame_modes: FrameModes, mode_name: string): this;
|
|
101
97
|
}
|
|
102
98
|
}
|
|
103
99
|
Elements.extend({
|
|
@@ -112,10 +108,10 @@ Elements.extend({
|
|
|
112
108
|
* @return:
|
|
113
109
|
* @description Returns the instance of the element for chaining.
|
|
114
110
|
*/
|
|
115
|
-
frame_mode(this, ...args) {
|
|
111
|
+
frame_mode(this: VElement, ...args) {
|
|
116
112
|
if (args.length === 1) {
|
|
117
113
|
args[0].push(this);
|
|
118
|
-
} else if (args.length === 2 && args[0] instanceof
|
|
114
|
+
} else if (args.length === 2 && args[0] instanceof FrameModes) {
|
|
119
115
|
const frames_mode = args[0];
|
|
120
116
|
const mode_name = args[1];
|
|
121
117
|
if (mode_name !== frames_mode.active) {
|
|
@@ -4,25 +4,27 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// Imports.
|
|
7
|
-
import { Elements, VElementTagMap } from "../elements/module.js"
|
|
7
|
+
import { Elements, VElementBaseSignature, VElement, VElementTagMap } from "../elements/module.js"
|
|
8
8
|
import { Utils } from "../modules/utils.js"
|
|
9
9
|
import { Google } from "../modules/google"
|
|
10
10
|
|
|
11
11
|
// GoogleMap.
|
|
12
|
-
@Elements.
|
|
12
|
+
@Elements.create({
|
|
13
|
+
name: "GoogleMapElement",
|
|
14
|
+
default_style: {
|
|
15
|
+
"border": "0",
|
|
16
|
+
},
|
|
17
|
+
default_attributes: {
|
|
18
|
+
"width": "100%",
|
|
19
|
+
"height": "100%",
|
|
20
|
+
"frameborder": "0",
|
|
21
|
+
"style": "border:0",
|
|
22
|
+
"referrerpolicy": "no-referrer-when-downgrade",
|
|
23
|
+
"allowfullscreen": "true",
|
|
24
|
+
},
|
|
25
|
+
})
|
|
13
26
|
export class GoogleMapElement extends VElementTagMap.iframe {
|
|
14
27
|
|
|
15
|
-
static default_style = {
|
|
16
|
-
"border": "0",
|
|
17
|
-
};
|
|
18
|
-
static default_attributes = {
|
|
19
|
-
"width": "100%",
|
|
20
|
-
"height": "100%",
|
|
21
|
-
"frameborder": "0",
|
|
22
|
-
"style": "border:0",
|
|
23
|
-
"referrerpolicy": "no-referrer-when-downgrade",
|
|
24
|
-
"allowfullscreen": "true",
|
|
25
|
-
};
|
|
26
28
|
|
|
27
29
|
// Constructor.
|
|
28
30
|
constructor({
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// Imports.
|
|
7
|
-
import { Elements, VElementTagMap } from "../elements/module.js"
|
|
7
|
+
import { Elements, VElementBaseSignature, VElement, VElementTagMap } from "../elements/module.js"
|
|
8
8
|
import { Utils } from "../modules/utils.js"
|
|
9
9
|
import { GradientType } from "../types/gradient.js"
|
|
10
10
|
|
|
@@ -13,15 +13,16 @@ export const Gradient = Elements.wrapper(GradientType);
|
|
|
13
13
|
export const NullGradient = Elements.create_null(GradientType);
|
|
14
14
|
|
|
15
15
|
// Gradient border.
|
|
16
|
-
@Elements.
|
|
16
|
+
@Elements.create({
|
|
17
|
+
name: "GradientBorderElement",
|
|
18
|
+
default_style: {
|
|
19
|
+
"--child-border-width": "1px",
|
|
20
|
+
"--child-border-radius": "10px",
|
|
21
|
+
"--child-border-color": "black",
|
|
22
|
+
},
|
|
23
|
+
})
|
|
17
24
|
export class GradientBorderElement extends VElementTagMap.div {
|
|
18
25
|
|
|
19
|
-
static default_style = {
|
|
20
|
-
"--child-border-width": "1px",
|
|
21
|
-
"--child-border-radius": "10px",
|
|
22
|
-
"--child-border-color": "black",
|
|
23
|
-
};
|
|
24
|
-
|
|
25
26
|
// Constructor.
|
|
26
27
|
constructor() {
|
|
27
28
|
|