@vandenberghinc/volt 1.1.5 → 1.1.7
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 +127 -76
- package/backend/dist/cjs/endpoint.d.ts +23 -9
- package/backend/dist/cjs/endpoint.js +98 -21
- 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 +127 -76
- package/backend/dist/esm/endpoint.d.ts +23 -9
- package/backend/dist/esm/endpoint.js +99 -22
- 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 +128 -77
- 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 +1 -1
- 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 +163 -152
- package/backend/src/endpoint.ts +123 -31
- 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 +397 -415
- package/frontend/dist/elements/base.js +565 -328
- 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 -338
- 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 +4 -2
- 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 +4 -3
- 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 +8 -8
- 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
|
@@ -9,7 +9,7 @@ import { Elements } from "../elements/module.js";
|
|
|
9
9
|
// ---------------------------------------------------------
|
|
10
10
|
// Mutex class.
|
|
11
11
|
|
|
12
|
-
export class
|
|
12
|
+
export class Mutex {
|
|
13
13
|
locked: boolean;
|
|
14
14
|
queue: Array<() => void>;
|
|
15
15
|
|
|
@@ -54,6 +54,4 @@ export class MutexType {
|
|
|
54
54
|
this.locked = false;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export const Mutex = Elements.wrapper(MutexType);
|
|
57
|
+
}
|
|
@@ -20,7 +20,7 @@ import { Spacer } from "../ui/spacer"
|
|
|
20
20
|
import { Link } from "../ui/link"
|
|
21
21
|
import { CheckBox } from "../ui/checkbox"
|
|
22
22
|
import { Form } from "../ui/form"
|
|
23
|
-
import {
|
|
23
|
+
import { YesNoPopupElement, YesNoPopup } from "../ui/popup"
|
|
24
24
|
|
|
25
25
|
// Declare global variables or external libraries if necessary.
|
|
26
26
|
// @todo import paddle here not using scripts
|
|
@@ -412,7 +412,7 @@ const Payments = {
|
|
|
412
412
|
if (this._sign_in_redirect != null && !User.is_authenticated()) {
|
|
413
413
|
Utils.redirect(this._sign_in_redirect);
|
|
414
414
|
}
|
|
415
|
-
const response = await Utils.
|
|
415
|
+
const response = await Utils.request_v1({
|
|
416
416
|
method: "POST",
|
|
417
417
|
url: "/volt/payments/init",
|
|
418
418
|
data: {
|
|
@@ -1494,7 +1494,7 @@ const Payments = {
|
|
|
1494
1494
|
.font_weight("bold")
|
|
1495
1495
|
.on_click(() => {
|
|
1496
1496
|
document.body.appendChild(
|
|
1497
|
-
|
|
1497
|
+
YesNoPopup({
|
|
1498
1498
|
title: "Request Refund",
|
|
1499
1499
|
text: `You are about to request a refund for payment <span style='border-radius: 7px; background: ${style.bg_1}; padding: 1px 4px; font-size: 0.9em;'>${payment.id}</span>, do you wish to proceed?`,
|
|
1500
1500
|
no: "No",
|
|
@@ -1521,7 +1521,7 @@ const Payments = {
|
|
|
1521
1521
|
.color(style.fg_1)
|
|
1522
1522
|
.border_bottom("4px solid #E8454E")
|
|
1523
1523
|
// .leading()
|
|
1524
|
-
.parent<
|
|
1524
|
+
.parent<YesNoPopupElement>()
|
|
1525
1525
|
.title
|
|
1526
1526
|
.color(style.fg)
|
|
1527
1527
|
// .width("fit-content")
|
|
@@ -1533,13 +1533,13 @@ const Payments = {
|
|
|
1533
1533
|
// .ellipsis_overflow(true)
|
|
1534
1534
|
// .color(style.fg_1)
|
|
1535
1535
|
.center()
|
|
1536
|
-
.parent<
|
|
1536
|
+
.parent<YesNoPopupElement>()
|
|
1537
1537
|
.text
|
|
1538
1538
|
.color(style.fg_1)
|
|
1539
1539
|
.font_size(style.font_size)
|
|
1540
1540
|
.margin_left(10)
|
|
1541
1541
|
.center()
|
|
1542
|
-
.parent<
|
|
1542
|
+
.parent<YesNoPopupElement>()
|
|
1543
1543
|
.image
|
|
1544
1544
|
.padding(10)
|
|
1545
1545
|
.mask_color(style.bg)
|
|
@@ -1547,7 +1547,7 @@ const Payments = {
|
|
|
1547
1547
|
.background("#E8454E")
|
|
1548
1548
|
.frame(40, 40)
|
|
1549
1549
|
.box_shadow('0 0 0 4px #E8454E50')
|
|
1550
|
-
.parent<
|
|
1550
|
+
.parent<YesNoPopupElement>()
|
|
1551
1551
|
.no_button
|
|
1552
1552
|
.padding(10, 0)
|
|
1553
1553
|
.font_size(style.font_size)
|
|
@@ -1556,7 +1556,7 @@ const Payments = {
|
|
|
1556
1556
|
.border(1, style.divider_bg)
|
|
1557
1557
|
.hover_brightness(...style.button.hover_brightness as [any, any])
|
|
1558
1558
|
.box_shadow('0px 0px 5px #00000030')
|
|
1559
|
-
.parent<
|
|
1559
|
+
.parent<YesNoPopupElement>()
|
|
1560
1560
|
.yes_button
|
|
1561
1561
|
.padding(10, 0)
|
|
1562
1562
|
.font_size(style.font_size)
|
|
@@ -1565,7 +1565,7 @@ const Payments = {
|
|
|
1565
1565
|
.border(1, style.divider_bg)
|
|
1566
1566
|
.hover_brightness(...style.button.hover_brightness as [any, any])
|
|
1567
1567
|
.box_shadow('0px 0px 5px #00000030')
|
|
1568
|
-
.parent<
|
|
1568
|
+
.parent<YesNoPopupElement>()
|
|
1569
1569
|
);
|
|
1570
1570
|
}),
|
|
1571
1571
|
!container.is_refunding ? null : RingLoader()
|
|
@@ -2518,7 +2518,7 @@ const Payments = {
|
|
|
2518
2518
|
if (this._products !== undefined) {
|
|
2519
2519
|
return resolve(this._products);
|
|
2520
2520
|
}
|
|
2521
|
-
Utils.
|
|
2521
|
+
Utils.request_v1({
|
|
2522
2522
|
method: "GET",
|
|
2523
2523
|
url: "/volt/payments/products",
|
|
2524
2524
|
})
|
|
@@ -2587,7 +2587,7 @@ const Payments = {
|
|
|
2587
2587
|
* @desc: The id of the payment.
|
|
2588
2588
|
*/
|
|
2589
2589
|
get_payment: async function(id: string): Promise<any> {
|
|
2590
|
-
return Utils.
|
|
2590
|
+
return Utils.request_v1({
|
|
2591
2591
|
method: "GET",
|
|
2592
2592
|
url: "/volt/payments/payment",
|
|
2593
2593
|
data: {
|
|
@@ -2630,7 +2630,7 @@ const Payments = {
|
|
|
2630
2630
|
limit = null,
|
|
2631
2631
|
status = null,
|
|
2632
2632
|
} = {}): Promise<any> {
|
|
2633
|
-
return Utils.
|
|
2633
|
+
return Utils.request_v1({
|
|
2634
2634
|
method: "GET",
|
|
2635
2635
|
url: "/volt/payments/payments",
|
|
2636
2636
|
data: {
|
|
@@ -2661,7 +2661,7 @@ const Payments = {
|
|
|
2661
2661
|
days = 30,
|
|
2662
2662
|
limit = null,
|
|
2663
2663
|
} = {}): Promise<any> {
|
|
2664
|
-
return Utils.
|
|
2664
|
+
return Utils.request_v1({
|
|
2665
2665
|
method: "GET",
|
|
2666
2666
|
url: "/volt/payments/payments/refundable",
|
|
2667
2667
|
data: {
|
|
@@ -2691,7 +2691,7 @@ const Payments = {
|
|
|
2691
2691
|
days = 30,
|
|
2692
2692
|
limit = null,
|
|
2693
2693
|
} = {}): Promise<any> {
|
|
2694
|
-
return Utils.
|
|
2694
|
+
return Utils.request_v1({
|
|
2695
2695
|
method: "GET",
|
|
2696
2696
|
url: "/volt/payments/payments/refunded",
|
|
2697
2697
|
data: {
|
|
@@ -2721,7 +2721,7 @@ const Payments = {
|
|
|
2721
2721
|
days = null,
|
|
2722
2722
|
limit = null,
|
|
2723
2723
|
} = {}): Promise<any> {
|
|
2724
|
-
return Utils.
|
|
2724
|
+
return Utils.request_v1({
|
|
2725
2725
|
method: "GET",
|
|
2726
2726
|
url: "/volt/payments/payments/refunding",
|
|
2727
2727
|
data: {
|
|
@@ -2755,7 +2755,7 @@ const Payments = {
|
|
|
2755
2755
|
* @desc: The refund reason.
|
|
2756
2756
|
*/
|
|
2757
2757
|
create_refund: async function(payment: number | string, line_items: any[] | null = null, reason: string = "refund"): Promise<any> {
|
|
2758
|
-
return Utils.
|
|
2758
|
+
return Utils.request_v1({
|
|
2759
2759
|
method: "POST",
|
|
2760
2760
|
url: "/volt/payments/refund",
|
|
2761
2761
|
data: {
|
|
@@ -2781,7 +2781,7 @@ const Payments = {
|
|
|
2781
2781
|
* @desc: The product id.
|
|
2782
2782
|
*/
|
|
2783
2783
|
cancel_subscription: async function(product: string): Promise<any> {
|
|
2784
|
-
return Utils.
|
|
2784
|
+
return Utils.request_v1({
|
|
2785
2785
|
method: "DELETE",
|
|
2786
2786
|
url: "/volt/payments/subscription",
|
|
2787
2787
|
data: {
|
|
@@ -2804,7 +2804,7 @@ const Payments = {
|
|
|
2804
2804
|
* @desc: The product id.
|
|
2805
2805
|
*/
|
|
2806
2806
|
is_subscribed: async function(product: string): Promise<any> {
|
|
2807
|
-
return Utils.
|
|
2807
|
+
return Utils.request_v1({
|
|
2808
2808
|
method: "GET",
|
|
2809
2809
|
url: "/volt/payments/subscribed",
|
|
2810
2810
|
data: {
|
|
@@ -2822,7 +2822,7 @@ const Payments = {
|
|
|
2822
2822
|
* @desc: Get the active subscriptions of the authenticated user.
|
|
2823
2823
|
*/
|
|
2824
2824
|
get_active_subscriptions: async function(): Promise<any> {
|
|
2825
|
-
return Utils.
|
|
2825
|
+
return Utils.request_v1({
|
|
2826
2826
|
method: "GET",
|
|
2827
2827
|
url: "/volt/payments/active_subscriptions",
|
|
2828
2828
|
});
|
|
@@ -2987,4 +2987,5 @@ const Payments = {
|
|
|
2987
2987
|
};
|
|
2988
2988
|
|
|
2989
2989
|
// Exports.
|
|
2990
|
-
export { Payments };
|
|
2990
|
+
export { Payments };
|
|
2991
|
+
export { Payments as payments }; // also export as lowercase for compatibility.
|
|
@@ -8,8 +8,6 @@
|
|
|
8
8
|
* And beware that `vlib` will be replaced with `vweb`.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { Colors } from "./colors.js"
|
|
12
|
-
|
|
13
11
|
// Types for scheme validation
|
|
14
12
|
type SchemeType = string | Function | (string | Function)[];
|
|
15
13
|
|
|
@@ -496,7 +494,9 @@ export const Scheme = {
|
|
|
496
494
|
if (last !== -1) {
|
|
497
495
|
stack = stack.slice(last);
|
|
498
496
|
}
|
|
499
|
-
|
|
497
|
+
const color_end = "\u001b[0m";
|
|
498
|
+
const color_yellow = "\u001b[33m";
|
|
499
|
+
console.warn(`${color_end}[Scheme.verify] ${color_yellow}Warning${color_end}: Attribute "callback" is deprecated and replaced by attribute "verify" and will be removed in future versions.\n${stack.join('\n')}`);
|
|
500
500
|
|
|
501
501
|
// Still proceed as normal.
|
|
502
502
|
const err = scheme_item.callback(object[key], object, key);
|
|
@@ -725,6 +725,7 @@ export const Scheme = {
|
|
|
725
725
|
return err;
|
|
726
726
|
}
|
|
727
727
|
} as const;
|
|
728
|
+
export { Scheme as SchemeType }; // also export as lowercase for compatibility.
|
|
728
729
|
|
|
729
730
|
// Add type for extended Error with json property
|
|
730
731
|
declare global {
|
|
@@ -85,7 +85,7 @@ const Support = {
|
|
|
85
85
|
detailed?: string;
|
|
86
86
|
attachments?: { [fileName: string]: any };
|
|
87
87
|
} = {}) {
|
|
88
|
-
return Utils.
|
|
88
|
+
return Utils.request_v1({
|
|
89
89
|
method: "POST",
|
|
90
90
|
url: "/volt/support/submit",
|
|
91
91
|
data: data,
|
|
@@ -107,7 +107,7 @@ const Support = {
|
|
|
107
107
|
* @type: string
|
|
108
108
|
*/
|
|
109
109
|
get_pin() {
|
|
110
|
-
return Utils.
|
|
110
|
+
return Utils.request_v1({
|
|
111
111
|
method: "GET",
|
|
112
112
|
url: "/volt/support/pin",
|
|
113
113
|
});
|
|
@@ -116,3 +116,4 @@ const Support = {
|
|
|
116
116
|
|
|
117
117
|
// Export.
|
|
118
118
|
export { Support };
|
|
119
|
+
export { Support as support }; // also export as lowercase for compatibility.
|
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Author: Daan van den Bergh
|
|
3
|
+
* Copyright: © 2022 - 2024 Daan van den Bergh.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Imports.
|
|
7
|
+
import { Color } from "./color.js"
|
|
8
|
+
import { Themes as ThemesModule } from "./themes.js"
|
|
9
|
+
|
|
10
|
+
// Types.
|
|
11
|
+
type ThemeAttributeName = string;
|
|
12
|
+
type ThemeId = "dark" | "light";
|
|
13
|
+
const ThemeIdList = ["dark", "light"] as const;
|
|
14
|
+
type ThemesOptions<ThemeOptions extends {}> = { dark: ThemeOptions, light: ThemeOptions };
|
|
15
|
+
type OnActivateCallback<ThemeOptions extends {}> = (themes_class: Theme<ThemeOptions>, active_id: ThemeId) => void;
|
|
16
|
+
|
|
17
|
+
// Themes class.
|
|
18
|
+
/* @docs:
|
|
19
|
+
@nav: Frontend
|
|
20
|
+
@chapter: Themes
|
|
21
|
+
@note: The `ThemesClass` is also initializable under function `Themes`.
|
|
22
|
+
@desc:
|
|
23
|
+
A themes class to efficiently style the site using themes.
|
|
24
|
+
|
|
25
|
+
The constructor arguments must be a theme style per theme name. Every theme variable should exist in all themes or it may cause undefined behaviour. The theme name that is passed first will be the active theme by default.
|
|
26
|
+
```
|
|
27
|
+
Theme("main-theme", {
|
|
28
|
+
light: {
|
|
29
|
+
text_fg: "#000000",
|
|
30
|
+
},
|
|
31
|
+
dark: {
|
|
32
|
+
text_fg: "#FFFFFF",
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
When theme attributes are retrieved, by default they will be the active theme's attribute as a css variable. So this can be passed to an element.
|
|
38
|
+
However, some element functions do not accept css variables, in this case the `value()` function can be used to retrieve the raw value. Do not forget to apply an `on_theme_update()` callback on the elements where you use this.
|
|
39
|
+
*/
|
|
40
|
+
export class Theme<ThemeOptions extends {}> {
|
|
41
|
+
|
|
42
|
+
// helper: union of all keys across all themes
|
|
43
|
+
|
|
44
|
+
// Attributes.
|
|
45
|
+
public active_id!: ThemeId;
|
|
46
|
+
public active!: ThemeOptions;
|
|
47
|
+
public _attrs: string[];
|
|
48
|
+
public _css_vars: Record<string, string | String>;
|
|
49
|
+
public _id: string;
|
|
50
|
+
public _on_activate_callback?: OnActivateCallback<ThemeOptions>;
|
|
51
|
+
|
|
52
|
+
constructor(
|
|
53
|
+
id: string,
|
|
54
|
+
themes: ThemesOptions<ThemeOptions>,
|
|
55
|
+
) {
|
|
56
|
+
|
|
57
|
+
// Attributes.
|
|
58
|
+
this._attrs = [];
|
|
59
|
+
this._css_vars = {};
|
|
60
|
+
this._id = id;
|
|
61
|
+
|
|
62
|
+
// Assign themes.
|
|
63
|
+
Object.keys(themes).iterate((theme) => {
|
|
64
|
+
|
|
65
|
+
// Initialize.
|
|
66
|
+
const theme_style = themes[theme] as Record<string, any>;
|
|
67
|
+
this[theme] = theme_style;
|
|
68
|
+
|
|
69
|
+
// Activate first theme.
|
|
70
|
+
if (this.active_id === undefined) {
|
|
71
|
+
this.active_id = theme as ThemeId;
|
|
72
|
+
this.active = theme_style as any;
|
|
73
|
+
Object.keys(this.active as any).iterate((id) => {
|
|
74
|
+
document.documentElement.style.setProperty(`--${this._id}_${id}`, (this.active as any)[id] ?? "");
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Initialize attr funcs.
|
|
79
|
+
Object.keys(theme_style).iterate((id) => {
|
|
80
|
+
this._add_attr(id, theme as ThemeId);
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
// Ensure type.
|
|
85
|
+
if (this.active_id == null || this.active == null) {
|
|
86
|
+
throw new Error("No themes were specified in parameter \"themes\".");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Initialize a specific theme.
|
|
92
|
+
* @note This function should be called after the constructor to ensure the most recent theme is activated, argument "id" can be left undefined.
|
|
93
|
+
*/
|
|
94
|
+
initialize(id?: ThemeId): this {
|
|
95
|
+
if (id == null) {
|
|
96
|
+
id = (localStorage.getItem(this._id) ?? undefined) as any;
|
|
97
|
+
}
|
|
98
|
+
if (id != null && ThemeIdList.includes(id as any)) {
|
|
99
|
+
this.activate(id);
|
|
100
|
+
}
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// ---------------------------------------------------------------------
|
|
105
|
+
// Theme selection methods.
|
|
106
|
+
|
|
107
|
+
/** Get full active theme id. */
|
|
108
|
+
get id(): string {
|
|
109
|
+
return `${this._id}.${String(this.active_id)}`
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Get cached active subtheme id.
|
|
113
|
+
get_active_id_cached(): string {
|
|
114
|
+
return localStorage.getItem(this._id) ?? "";
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Activate a theme.
|
|
118
|
+
activate(id: ThemeId, apply_theme_update: boolean = true): this {
|
|
119
|
+
if (ThemeIdList.includes(id) === false || (this as any)[id] === undefined) {
|
|
120
|
+
throw Error(`Theme "${id as string}" does not exist.`);
|
|
121
|
+
}
|
|
122
|
+
this.active_id = id;
|
|
123
|
+
this.active = (this as any)[id];
|
|
124
|
+
Object.keys(this.active as any).iterate((id) => {
|
|
125
|
+
document.documentElement.style.setProperty(`--${this._id}_${id}`, (this.active as any)[id] ?? "");
|
|
126
|
+
});
|
|
127
|
+
if (this._on_activate_callback != null) {
|
|
128
|
+
this._on_activate_callback(this, this.active_id);
|
|
129
|
+
}
|
|
130
|
+
if (apply_theme_update) {
|
|
131
|
+
ThemesModule.apply_theme_update();
|
|
132
|
+
}
|
|
133
|
+
localStorage.setItem(this._id, String(this.active_id));
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Set an on activate callback.
|
|
138
|
+
on_activate(): OnActivateCallback<ThemeOptions> | undefined;
|
|
139
|
+
on_activate(callback: OnActivateCallback<ThemeOptions>): this;
|
|
140
|
+
on_activate(callback?: OnActivateCallback<ThemeOptions>): this | OnActivateCallback<ThemeOptions> | undefined {
|
|
141
|
+
if (callback == null) { return this._on_activate_callback; }
|
|
142
|
+
this._on_activate_callback = callback;
|
|
143
|
+
return this;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Toggle themes.
|
|
147
|
+
toggle(apply_theme_update: boolean = true): this {
|
|
148
|
+
const other: ThemeId = this.active_id === "dark" ? "light" : "dark";
|
|
149
|
+
this.activate(other, apply_theme_update);
|
|
150
|
+
return this;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// ---------------------------------------------------------------------
|
|
154
|
+
// Adding values.
|
|
155
|
+
|
|
156
|
+
// Add a new attribute.
|
|
157
|
+
_add_attr(id: string, theme?: ThemeId): void {
|
|
158
|
+
if (theme == null) {
|
|
159
|
+
this._css_vars[id] = `var(--${this._id}_${id})`;
|
|
160
|
+
} else {
|
|
161
|
+
const theme_style = (this as any)[theme];
|
|
162
|
+
if (
|
|
163
|
+
typeof theme_style[id] === "string" &&
|
|
164
|
+
(
|
|
165
|
+
theme_style[id].indexOf("linear-gradient") !== -1 ||
|
|
166
|
+
theme_style[id].indexOf("radial-gradient") !== -1
|
|
167
|
+
)
|
|
168
|
+
) {
|
|
169
|
+
theme_style[id] = new String(theme_style[id]);
|
|
170
|
+
theme_style[id]._is_gradient = true;
|
|
171
|
+
this._css_vars[id] = new String(`var(--${this._id}_${id})`);
|
|
172
|
+
(this._css_vars[id] as any)._is_gradient = true;
|
|
173
|
+
} else {
|
|
174
|
+
this._css_vars[id] = `var(--${this._id}_${id})`;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
Object.defineProperty(this, id, {
|
|
178
|
+
get: function () {
|
|
179
|
+
return this._css_vars[id];
|
|
180
|
+
},
|
|
181
|
+
set: function (v: any) {
|
|
182
|
+
// only for support this does not work however.
|
|
183
|
+
// document.documentElement.style.setProperty(`--${this._id}_${id}`, (this.active as any)[id] ?? "");
|
|
184
|
+
// return this;
|
|
185
|
+
},
|
|
186
|
+
enumerable: true,
|
|
187
|
+
configurable: true,
|
|
188
|
+
});
|
|
189
|
+
this._attrs.append(id);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Assign a new value.
|
|
193
|
+
set(theme: ThemeId, key: string, value: any): this {
|
|
194
|
+
|
|
195
|
+
// Update theme.
|
|
196
|
+
const theme_style = (this as any)[theme];
|
|
197
|
+
if (typeof value === "string" && (value.indexOf("linear-gradient") !== -1 || value.indexOf("radial-gradient") !== -1)) {
|
|
198
|
+
theme_style[key] = new String(value);
|
|
199
|
+
theme_style[key]._is_gradient = true;
|
|
200
|
+
this._css_vars[key] = new String(`var(--${this._id}_${key})`);
|
|
201
|
+
(this._css_vars[key] as any)._is_gradient = true;
|
|
202
|
+
} else {
|
|
203
|
+
theme_style[key] = value;
|
|
204
|
+
this._css_vars[key] = `var(--${this._id}_${key})`;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Set property.
|
|
208
|
+
if (this.active_id === theme) {
|
|
209
|
+
document.documentElement.style.setProperty(`--${this._id}_${key}`, (this.active as any)[key] ?? "");
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Response.
|
|
213
|
+
return this;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
get raw(): ThemeOptions {
|
|
217
|
+
return this.active;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Get raw value.
|
|
221
|
+
value(id: ThemeAttributeName): any {
|
|
222
|
+
if (this.active === undefined) { return; }
|
|
223
|
+
return this.active![id];
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// ---------------------------------------------------------------------
|
|
227
|
+
// Color manipulation methods.
|
|
228
|
+
|
|
229
|
+
// Create a new color for each theme.
|
|
230
|
+
create<T = string>(id: string, create_theme_value: (theme_id: ThemeId, theme: ThemeOptions) => T): void {
|
|
231
|
+
|
|
232
|
+
// Already created.
|
|
233
|
+
if (this._css_vars[id]) {
|
|
234
|
+
throw new Error(`Color "${id}" already exists.`);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Iterate.
|
|
238
|
+
let index = 0;
|
|
239
|
+
for (const theme_id of ThemeIdList) {
|
|
240
|
+
const theme = (this as any)[theme_id];
|
|
241
|
+
const value = create_theme_value(theme_id, theme);
|
|
242
|
+
theme[id] = value;
|
|
243
|
+
|
|
244
|
+
// Add attribute to document on first call.
|
|
245
|
+
if (index === 0) {
|
|
246
|
+
this._add_attr(id);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Set property.
|
|
250
|
+
if (this.active_id === theme_id) {
|
|
251
|
+
document.documentElement.style.setProperty(`--${this._id}_${id}`, theme[id]);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Incr index
|
|
255
|
+
++index;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Auto darken lighten a color from the theme
|
|
261
|
+
* Safe to call multiple times, caching is implemented.
|
|
262
|
+
*
|
|
263
|
+
* @warning The input color must be a hex / rgb(a) string.
|
|
264
|
+
* @param theme_attr The name of the original theme color.
|
|
265
|
+
* @param percent Percentage between 0. and 1.0.
|
|
266
|
+
*/
|
|
267
|
+
auto_darken_lighten(
|
|
268
|
+
theme_attr: ThemeAttributeName,
|
|
269
|
+
percent: number = 0.5,
|
|
270
|
+
reversed: boolean = false,
|
|
271
|
+
) {
|
|
272
|
+
let full_id = `${String(theme_attr)}_adl_${percent}`;
|
|
273
|
+
full_id = full_id.replaceAll(".", "_");
|
|
274
|
+
if (this._css_vars[full_id]) {
|
|
275
|
+
return this._css_vars[full_id] as string;
|
|
276
|
+
}
|
|
277
|
+
const process = reversed === true ? (x => x < 0.5) : (x => x > 0.5)
|
|
278
|
+
this.create(full_id, (theme_id, theme) => {
|
|
279
|
+
if (!theme[theme_attr]) {
|
|
280
|
+
throw new Error(`Theme attribute "${String(theme_attr)}" does not exist.`);
|
|
281
|
+
}
|
|
282
|
+
return new Color(theme[theme_attr]).auto_darken_lighten(percent, process).str()
|
|
283
|
+
});
|
|
284
|
+
return this._css_vars[full_id] as string;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Opacity.
|
|
288
|
+
// Opacity must be a number `0.0` till `1.0`, and may also be an object with opacity pet theme `{dark: 0.2, light: 0.35}`.
|
|
289
|
+
opacity(theme_attr: ThemeAttributeName, opacity: number = 1.0): string {
|
|
290
|
+
|
|
291
|
+
// Create full id.
|
|
292
|
+
let full_id;
|
|
293
|
+
if (typeof opacity === "number") {
|
|
294
|
+
full_id = `${String(theme_attr)}_opac_${opacity}`;
|
|
295
|
+
} else {
|
|
296
|
+
full_id = `${String(theme_attr)}_opac_${Object.values(opacity).join("_")}`;
|
|
297
|
+
}
|
|
298
|
+
full_id = full_id.replaceAll(".", "_");
|
|
299
|
+
|
|
300
|
+
// Already created.
|
|
301
|
+
if (this._css_vars[full_id]) {
|
|
302
|
+
return this._css_vars[full_id] as string;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Iterate.
|
|
306
|
+
let index = 0;
|
|
307
|
+
for (const theme_id of ThemeIdList) {
|
|
308
|
+
const theme = this[theme_id];
|
|
309
|
+
|
|
310
|
+
// Checks.
|
|
311
|
+
if (theme[theme_attr] == null) {
|
|
312
|
+
console.error(new Error(`Theme attribute "${String(theme_attr)}" does not exist.`));
|
|
313
|
+
return "";
|
|
314
|
+
}
|
|
315
|
+
if (theme[theme_attr]._is_gradient) {
|
|
316
|
+
console.error(new Error(`Unable to set the opacity on gradient color "${String(theme_attr)}".`));
|
|
317
|
+
return "";
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Create new color.
|
|
321
|
+
let theme_opac = opacity;
|
|
322
|
+
if (typeof theme_opac === "object") {
|
|
323
|
+
theme_opac = theme_opac[theme_attr];
|
|
324
|
+
if (theme_opac === undefined) {
|
|
325
|
+
console.error(new Error(`Unable to find the opacity on for theme id "${theme_attr}".`));
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
theme[full_id] = new Color(theme[theme_attr]).opacity(theme_opac).rgb();
|
|
329
|
+
|
|
330
|
+
// Add css var.
|
|
331
|
+
if (index === 0) {
|
|
332
|
+
this._add_attr(full_id);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// Set property.
|
|
336
|
+
if (this.active_id === theme_id) {
|
|
337
|
+
document.documentElement.style.setProperty(`--${this._id}_${full_id}`, theme[full_id]);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// Incr index
|
|
341
|
+
++index;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
return this._css_vars[full_id] as string;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// ---------------------------------------------------------------------
|
|
348
|
+
// Font size manipulation methods.
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Create a new value by multiplying a numeric attribute.
|
|
352
|
+
* @warning argument `id` should be the name of a numeric theme attribute.
|
|
353
|
+
* @param theme_attr The name of a numeric attribute
|
|
354
|
+
* @param x The number by which to multiply the attribute, `attribute * x`.
|
|
355
|
+
*/
|
|
356
|
+
multiply(theme_attr: ThemeAttributeName, x: number = 1.0): string {
|
|
357
|
+
let full_id = `${String(theme_attr)}_fsr_${x}`;
|
|
358
|
+
full_id = full_id.replaceAll(".", "_");
|
|
359
|
+
if (this._css_vars[full_id]) {
|
|
360
|
+
return this._css_vars[full_id] as string;
|
|
361
|
+
}
|
|
362
|
+
const process = (x => x < 0.5)
|
|
363
|
+
this.create<number>(full_id, (_, theme) => {
|
|
364
|
+
if (!theme[theme_attr]) {
|
|
365
|
+
throw new Error(`Theme attribute "${String(theme_attr)}" does not exist.`);
|
|
366
|
+
}
|
|
367
|
+
if (typeof theme[theme_attr] !== "number") {
|
|
368
|
+
throw new Error(`Theme attribute "${String(theme_attr)}" is not a number.`);
|
|
369
|
+
}
|
|
370
|
+
return theme[theme_attr] * x;
|
|
371
|
+
});
|
|
372
|
+
return this._css_vars[full_id] as string;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// ---------------------------------------------------------------------
|
|
376
|
+
// Animation methods.
|
|
377
|
+
|
|
378
|
+
/** Function to disable all transition attributes on all elements. */
|
|
379
|
+
disable_transitions(): this {
|
|
380
|
+
// const style = document.createElement('style');
|
|
381
|
+
// style.id = '__libris_thme_disable_transitions__';
|
|
382
|
+
// style.innerHTML = `
|
|
383
|
+
// * { transition: none !important; }
|
|
384
|
+
// *::after { transition: none !important; }
|
|
385
|
+
// *::before { transition: none !important; }
|
|
386
|
+
// `.dedent();
|
|
387
|
+
// document.head.appendChild(style);
|
|
388
|
+
|
|
389
|
+
document.body.classList.add("notransition");
|
|
390
|
+
|
|
391
|
+
// Force a reflow to apply the new styles immediately
|
|
392
|
+
// document.head.getBoundingClientRect();
|
|
393
|
+
void document.body.offsetHeight;
|
|
394
|
+
|
|
395
|
+
return this;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/** Function to re-enable all transition attributes on all elements. */
|
|
399
|
+
enable_transitions(delay = 0): this {
|
|
400
|
+
if (delay > 0) {
|
|
401
|
+
setTimeout(() => this.enable_transitions(0), delay);
|
|
402
|
+
return this;
|
|
403
|
+
}
|
|
404
|
+
document.body.classList.remove("notransition");
|
|
405
|
+
// const style = document.getElementById('__libris_thme_disable_transitions__');
|
|
406
|
+
// if (style) {
|
|
407
|
+
// style.remove();
|
|
408
|
+
// }
|
|
409
|
+
document.head.getBoundingClientRect();
|
|
410
|
+
return this;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
export type ExtendTheme<ThemeOptions extends {}> = Theme<ThemeOptions> & ThemeOptions;
|