verstak 0.24.502 → 0.91.25002
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/build/dist/source/api.d.ts +1 -1
- package/build/dist/source/api.js +1 -1
- package/build/dist/source/core/El.d.ts +78 -0
- package/build/dist/source/core/El.js +32 -0
- package/build/dist/source/{html/El.d.ts → core/ElDriver.d.ts} +1 -77
- package/build/dist/source/{html/El.js → core/ElDriver.js} +9 -40
- package/build/dist/source/core/Elements.d.ts +42 -0
- package/build/dist/source/{html → core}/Elements.js +31 -26
- package/build/dist/source/{html → core}/SplitViewMath.d.ts +1 -1
- package/build/dist/source/{html/HtmlDriver.d.ts → core/WebDriver.d.ts} +6 -5
- package/build/dist/source/{html/HtmlDriver.js → core/WebDriver.js} +8 -8
- package/build/dist/source/core/api.d.ts +7 -0
- package/build/dist/source/core/api.js +7 -0
- package/build/dist/source/express/Button.v.d.ts +8 -0
- package/build/dist/source/express/Button.v.js +39 -0
- package/build/dist/source/express/Field.v.d.ts +16 -0
- package/build/dist/source/express/Field.v.js +118 -0
- package/build/dist/source/express/Icon.v.d.ts +3 -0
- package/build/dist/source/express/Icon.v.js +14 -0
- package/build/dist/source/express/Image.v.d.ts +6 -0
- package/build/dist/source/express/Image.v.js +18 -0
- package/build/dist/source/express/Markdown.v.d.ts +1 -0
- package/build/dist/source/express/Markdown.v.js +18 -0
- package/build/dist/source/express/Spinner.v.d.ts +9 -0
- package/build/dist/source/express/Spinner.v.js +23 -0
- package/build/dist/source/express/Theme.d.ts +34 -0
- package/build/dist/source/express/Theme.js +30 -0
- package/build/dist/source/express/Toggle.v.d.ts +8 -0
- package/build/dist/source/express/Toggle.v.js +40 -0
- package/build/dist/source/express/api.d.ts +9 -0
- package/build/dist/source/express/api.js +9 -0
- package/build/dist/source/express/common/Utils.d.ts +5 -0
- package/build/dist/source/express/common/Utils.js +26 -0
- package/build/dist/source/express/theme/Button.s.d.ts +11 -0
- package/build/dist/source/express/theme/Button.s.js +49 -0
- package/build/dist/source/express/theme/Field.s.d.ts +13 -0
- package/build/dist/source/express/theme/Field.s.js +68 -0
- package/build/dist/source/express/theme/Icon.s.d.ts +7 -0
- package/build/dist/source/express/theme/Icon.s.js +26 -0
- package/build/dist/source/express/theme/Styling.d.ts +16 -0
- package/build/dist/source/express/theme/Styling.js +20 -0
- package/build/dist/source/express/theme/Toggle.s.d.ts +11 -0
- package/build/dist/source/express/theme/Toggle.s.js +48 -0
- package/build/dist/source/html/DraggableArea.view.d.ts +2 -2
- package/build/dist/source/html/DraggableArea.view.js +2 -2
- package/build/dist/source/html/HtmlApiExt.d.ts +2 -2
- package/build/dist/source/html/HtmlApiExt.js +2 -2
- package/build/dist/source/html/HtmlElements.d.ts +2 -4
- package/build/dist/source/html/HtmlElements.js +2 -6
- package/build/dist/source/html/api.d.ts +0 -19
- package/build/dist/source/html/api.js +0 -19
- package/build/dist/source/{html/sensors → sensors}/FocusSensor.js +1 -1
- package/build/dist/source/{html → sensors}/Handlers.d.ts +3 -3
- package/build/dist/source/{html → sensors}/Handlers.js +5 -5
- package/build/dist/source/{html/sensors → sensors}/ResizeSensor.d.ts +1 -1
- package/build/dist/source/{html/sensors → sensors}/WindowSensor.js +1 -1
- package/build/dist/source/sensors/api.d.ts +13 -0
- package/build/dist/source/sensors/api.js +13 -0
- package/package.json +21 -9
- package/build/dist/source/html/Elements.d.ts +0 -39
- package/build/dist/source/{html → core}/ElUtils.d.ts +0 -0
- package/build/dist/source/{html → core}/ElUtils.js +0 -0
- package/build/dist/source/{html → core}/Sizes.d.ts +0 -0
- package/build/dist/source/{html → core}/Sizes.js +0 -0
- package/build/dist/source/{html → core}/SplitViewMath.js +1 -1
- /package/build/dist/source/{html/sensors → sensors}/BasePointerSensor.d.ts +0 -0
- /package/build/dist/source/{html/sensors → sensors}/BasePointerSensor.js +0 -0
- /package/build/dist/source/{html/sensors → sensors}/ButtonSensor.d.ts +0 -0
- /package/build/dist/source/{html/sensors → sensors}/ButtonSensor.js +0 -0
- /package/build/dist/source/{html/sensors → sensors}/DataForSensor.d.ts +0 -0
- /package/build/dist/source/{html/sensors → sensors}/DataForSensor.js +0 -0
- /package/build/dist/source/{html/sensors → sensors}/FocusSensor.d.ts +0 -0
- /package/build/dist/source/{html/sensors → sensors}/HoverSensor.d.ts +0 -0
- /package/build/dist/source/{html/sensors → sensors}/HoverSensor.js +0 -0
- /package/build/dist/source/{html/sensors → sensors}/HtmlDragSensor.d.ts +0 -0
- /package/build/dist/source/{html/sensors → sensors}/HtmlDragSensor.js +0 -0
- /package/build/dist/source/{html/sensors → sensors}/HtmlElementSensor.d.ts +0 -0
- /package/build/dist/source/{html/sensors → sensors}/HtmlElementSensor.js +0 -0
- /package/build/dist/source/{html/sensors → sensors}/HtmlSensors.d.ts +0 -0
- /package/build/dist/source/{html/sensors → sensors}/HtmlSensors.js +0 -0
- /package/build/dist/source/{html/sensors → sensors}/KeyboardSensor.d.ts +0 -0
- /package/build/dist/source/{html/sensors → sensors}/KeyboardSensor.js +0 -0
- /package/build/dist/source/{html/sensors → sensors}/PointerSensor.d.ts +0 -0
- /package/build/dist/source/{html/sensors → sensors}/PointerSensor.js +0 -0
- /package/build/dist/source/{html/sensors → sensors}/ResizeSensor.js +0 -0
- /package/build/dist/source/{html/sensors → sensors}/ScrollSensor.d.ts +0 -0
- /package/build/dist/source/{html/sensors → sensors}/ScrollSensor.js +0 -0
- /package/build/dist/source/{html/sensors → sensors}/Sensor.d.ts +0 -0
- /package/build/dist/source/{html/sensors → sensors}/Sensor.js +0 -0
- /package/build/dist/source/{html/sensors → sensors}/WheelSensor.d.ts +0 -0
- /package/build/dist/source/{html/sensors → sensors}/WheelSensor.js +0 -0
- /package/build/dist/source/{html/sensors → sensors}/WindowSensor.d.ts +0 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Mode, ReactiveNode } from "reactronic";
|
|
2
|
+
import { Panel, Note, OnFocus, rowBreak, Handling, KeyboardModifiers, Horizontal, Vertical } from "verstak";
|
|
3
|
+
import { observableModel } from "./common/Utils.js";
|
|
4
|
+
import { Theme } from "./Theme.js";
|
|
5
|
+
import { Icon } from "./Icon.v.js";
|
|
6
|
+
export function Field(declaration) {
|
|
7
|
+
return (Panel(ReactiveNode.withBasis(declaration, {
|
|
8
|
+
mode: Mode.autonomous,
|
|
9
|
+
preparation: el => {
|
|
10
|
+
var _a;
|
|
11
|
+
(_a = el.model) !== null && _a !== void 0 ? _a : (el.model = composeFieldModel());
|
|
12
|
+
el.native.dataForSensor.focus = el.model;
|
|
13
|
+
},
|
|
14
|
+
script: el => {
|
|
15
|
+
const m = el.model;
|
|
16
|
+
const theme = Theme.current.field;
|
|
17
|
+
el.useStylingPreset(theme.main);
|
|
18
|
+
if (m.icon)
|
|
19
|
+
Icon(m.icon, {
|
|
20
|
+
script: (el, base) => {
|
|
21
|
+
base();
|
|
22
|
+
el.useStylingPreset(theme.icon);
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
FieldInput(m, theme);
|
|
26
|
+
FieldPopup(m, theme);
|
|
27
|
+
},
|
|
28
|
+
})));
|
|
29
|
+
}
|
|
30
|
+
export function composeFieldModel(props) {
|
|
31
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
32
|
+
return observableModel({
|
|
33
|
+
icon: props === null || props === void 0 ? void 0 : props.icon,
|
|
34
|
+
text: (_a = props === null || props === void 0 ? void 0 : props.text) !== null && _a !== void 0 ? _a : "",
|
|
35
|
+
options: (_b = props === null || props === void 0 ? void 0 : props.options) !== null && _b !== void 0 ? _b : [],
|
|
36
|
+
selected: props === null || props === void 0 ? void 0 : props.selected,
|
|
37
|
+
multiSelected: (_c = props === null || props === void 0 ? void 0 : props.multiSelected) !== null && _c !== void 0 ? _c : new Set(),
|
|
38
|
+
position: (_d = props === null || props === void 0 ? void 0 : props.position) !== null && _d !== void 0 ? _d : 0,
|
|
39
|
+
isMultiLineText: (_e = props === null || props === void 0 ? void 0 : props.isMultiLineText) !== null && _e !== void 0 ? _e : false,
|
|
40
|
+
isEditMode: (_f = props === null || props === void 0 ? void 0 : props.isEditMode) !== null && _f !== void 0 ? _f : false,
|
|
41
|
+
isHotText: (_g = props === null || props === void 0 ? void 0 : props.isHotText) !== null && _g !== void 0 ? _g : false,
|
|
42
|
+
inputStyle: (_h = props === null || props === void 0 ? void 0 : props.inputStyle) !== null && _h !== void 0 ? _h : "",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function FieldInput(model, s) {
|
|
46
|
+
return (Note(model.text, false, {
|
|
47
|
+
key: FieldInput.name,
|
|
48
|
+
preparation: (el, base) => {
|
|
49
|
+
const e = el.native;
|
|
50
|
+
el.useStylingPreset(s.input);
|
|
51
|
+
el.horizontally = Horizontal.stretch;
|
|
52
|
+
el.vertically = Vertical.stretch;
|
|
53
|
+
e.tabIndex = 0;
|
|
54
|
+
e.contentEditable = "true";
|
|
55
|
+
e.dataForSensor.focus = model;
|
|
56
|
+
base();
|
|
57
|
+
},
|
|
58
|
+
script: el => {
|
|
59
|
+
const e = el.native;
|
|
60
|
+
if (!model.isEditMode)
|
|
61
|
+
e.innerText = model.text;
|
|
62
|
+
Handling(() => {
|
|
63
|
+
const keyboard = e.sensors.keyboard;
|
|
64
|
+
if (keyboard.down) {
|
|
65
|
+
if (isApplyKey(model, keyboard))
|
|
66
|
+
selectAllAndPreventDefault(e, keyboard);
|
|
67
|
+
}
|
|
68
|
+
if (keyboard.up) {
|
|
69
|
+
if (isApplyKey(model, keyboard)) {
|
|
70
|
+
selectAllAndPreventDefault(e, keyboard);
|
|
71
|
+
model.text = e.innerText;
|
|
72
|
+
}
|
|
73
|
+
else if (model.isHotText)
|
|
74
|
+
model.text = e.innerText;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
OnFocus(e, model);
|
|
78
|
+
},
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
function FieldPopup(model, s) {
|
|
82
|
+
return (Panel({
|
|
83
|
+
key: FieldPopup.name,
|
|
84
|
+
script: el => {
|
|
85
|
+
el.useStylingPreset(s.popup);
|
|
86
|
+
Handling(() => model.position = el.native.sensors.scroll.y);
|
|
87
|
+
const visible = el.overlayVisible = model.isEditMode;
|
|
88
|
+
if (visible) {
|
|
89
|
+
const options = model.options;
|
|
90
|
+
if (options.length > 0) {
|
|
91
|
+
for (const x of model.options) {
|
|
92
|
+
rowBreak();
|
|
93
|
+
Note(x, false, {
|
|
94
|
+
key: x,
|
|
95
|
+
preparation: el => {
|
|
96
|
+
el.contentWrapping = false;
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else
|
|
102
|
+
Note("(nothing)", false, { key: "(nothing)" });
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
function isApplyKey(m, keyboard) {
|
|
108
|
+
const modifiers = keyboard.modifiers;
|
|
109
|
+
return keyboard.down === "Enter" && (!m.isMultiLineText || (modifiers & KeyboardModifiers.ctrlShiftMeta) > 0);
|
|
110
|
+
}
|
|
111
|
+
function selectAllAndPreventDefault(e, keyboard) {
|
|
112
|
+
const range = document.createRange();
|
|
113
|
+
range.selectNodeContents(e);
|
|
114
|
+
const sel = window.getSelection();
|
|
115
|
+
sel === null || sel === void 0 ? void 0 : sel.removeAllRanges();
|
|
116
|
+
sel === null || sel === void 0 ? void 0 : sel.addRange(range);
|
|
117
|
+
keyboard.preventDefault = true;
|
|
118
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Mode, ReactiveNode } from "reactronic";
|
|
2
|
+
import { Panel } from "verstak";
|
|
3
|
+
import { Theme } from "./Theme.js";
|
|
4
|
+
export function Icon(name, declaration) {
|
|
5
|
+
return (Panel(ReactiveNode.withBasis(declaration, {
|
|
6
|
+
mode: Mode.autonomous,
|
|
7
|
+
triggers: { name },
|
|
8
|
+
script: el => {
|
|
9
|
+
const theme = Theme.current.icon;
|
|
10
|
+
el.useStylingPreset(name);
|
|
11
|
+
el.useStylingPreset(theme.main);
|
|
12
|
+
},
|
|
13
|
+
})));
|
|
14
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ReactiveNodeDecl, ReactiveNode } from "reactronic";
|
|
2
|
+
import { El } from "verstak";
|
|
3
|
+
export type ImageModel = {
|
|
4
|
+
source?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function Image(declaration?: ReactiveNodeDecl<El<HTMLElement, ImageModel>>): ReactiveNode<El<HTMLElement, ImageModel>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Mode, ReactiveNode } from "reactronic";
|
|
2
|
+
import { Panel } from "verstak";
|
|
3
|
+
import { observableModel } from "./common/Utils.js";
|
|
4
|
+
export function Image(declaration) {
|
|
5
|
+
return (Panel(ReactiveNode.withBasis(declaration, {
|
|
6
|
+
mode: Mode.autonomous,
|
|
7
|
+
preparation: el => {
|
|
8
|
+
var _a;
|
|
9
|
+
(_a = el.model) !== null && _a !== void 0 ? _a : (el.model = observableModel({ source: undefined }));
|
|
10
|
+
},
|
|
11
|
+
script: el => {
|
|
12
|
+
const m = el.model;
|
|
13
|
+
el.style.backgroundImage = `url(${m.source})`;
|
|
14
|
+
el.style.backgroundSize = "contain";
|
|
15
|
+
el.style.backgroundRepeat = "no-repeat";
|
|
16
|
+
},
|
|
17
|
+
})));
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Markdown(content: string): import("reactronic").ReactiveNode<import("verstak").El<HTMLElement, void>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Note } from "verstak";
|
|
2
|
+
import Md from "markdown-it";
|
|
3
|
+
import * as prism from "prismjs";
|
|
4
|
+
export function Markdown(content) {
|
|
5
|
+
return (Note(md.render(content), true, {
|
|
6
|
+
preparation: (el, base) => {
|
|
7
|
+
el.contentWrapping = true;
|
|
8
|
+
base();
|
|
9
|
+
},
|
|
10
|
+
}));
|
|
11
|
+
}
|
|
12
|
+
const md = new Md({
|
|
13
|
+
html: true,
|
|
14
|
+
highlight: (str, lang, attrs) => {
|
|
15
|
+
const highlighted = prism.highlight(str, prism.languages[lang], lang);
|
|
16
|
+
return `<pre class="language-${lang}"><code>${highlighted}</code></pre>`;
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactiveNodeDecl, ReactiveNode } from "reactronic";
|
|
2
|
+
import { El } from "verstak";
|
|
3
|
+
import { ValuesOrRefs } from "./common/Utils.js";
|
|
4
|
+
export type SpinnerModel = {
|
|
5
|
+
active: boolean;
|
|
6
|
+
color: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function Spinner(declaration?: ReactiveNodeDecl<El<HTMLElement, SpinnerModel>>): ReactiveNode<El<HTMLElement, SpinnerModel>>;
|
|
9
|
+
export declare function composeSpinnerModel<T>(props?: Partial<ValuesOrRefs<SpinnerModel>>): SpinnerModel;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Mode, ReactiveNode } from "reactronic";
|
|
2
|
+
import { Panel, Note } from "verstak";
|
|
3
|
+
import { observableModel } from "./common/Utils.js";
|
|
4
|
+
export function Spinner(declaration) {
|
|
5
|
+
return (Panel(ReactiveNode.withBasis(declaration, {
|
|
6
|
+
mode: Mode.autonomous,
|
|
7
|
+
preparation: el => {
|
|
8
|
+
var _a;
|
|
9
|
+
(_a = el.model) !== null && _a !== void 0 ? _a : (el.model = composeSpinnerModel());
|
|
10
|
+
},
|
|
11
|
+
script: el => {
|
|
12
|
+
const m = el.model;
|
|
13
|
+
m.active && Note("loading...");
|
|
14
|
+
},
|
|
15
|
+
})));
|
|
16
|
+
}
|
|
17
|
+
export function composeSpinnerModel(props) {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
return observableModel({
|
|
20
|
+
active: (_a = props === null || props === void 0 ? void 0 : props.active) !== null && _a !== void 0 ? _a : false,
|
|
21
|
+
color: (_b = props === null || props === void 0 ? void 0 : props.color) !== null && _b !== void 0 ? _b : "",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AbstractTheme } from "./theme/Styling.js";
|
|
2
|
+
import { ButtonStyling, DefaultButtonStyling } from "./theme/Button.s.js";
|
|
3
|
+
import { FieldStyling, DefaultFieldStyling } from "./theme/Field.s.js";
|
|
4
|
+
import { IconStyling, DefaultIconStyling } from "./theme/Icon.s.js";
|
|
5
|
+
import { ToggleStyling, DefaultToggleStyling } from "./theme/Toggle.s.js";
|
|
6
|
+
export { type ButtonStyling, type DefaultButtonStyling } from "./theme/Button.s.js";
|
|
7
|
+
export { type FieldStyling, type DefaultFieldStyling } from "./theme/Field.s.js";
|
|
8
|
+
export { type IconStyling, type DefaultIconStyling } from "./theme/Icon.s.js";
|
|
9
|
+
export { type ToggleStyling, type DefaultToggleStyling } from "./theme/Toggle.s.js";
|
|
10
|
+
export type VerstakExpressTheme = AbstractTheme & {
|
|
11
|
+
readonly button: ButtonStyling;
|
|
12
|
+
readonly field: FieldStyling;
|
|
13
|
+
readonly icon: IconStyling;
|
|
14
|
+
readonly toggle: ToggleStyling;
|
|
15
|
+
};
|
|
16
|
+
export declare class Theme implements VerstakExpressTheme {
|
|
17
|
+
private static readonly gCurrent;
|
|
18
|
+
static get current(): VerstakExpressTheme;
|
|
19
|
+
static set current(value: VerstakExpressTheme);
|
|
20
|
+
name: string;
|
|
21
|
+
fillColor: string;
|
|
22
|
+
textColor: string;
|
|
23
|
+
positiveColor: string;
|
|
24
|
+
negativeColor: string;
|
|
25
|
+
borderRadius: string;
|
|
26
|
+
outlineWidth: string;
|
|
27
|
+
outlineColor: string;
|
|
28
|
+
outlinePadding: string;
|
|
29
|
+
shadow: string;
|
|
30
|
+
button: DefaultButtonStyling;
|
|
31
|
+
field: DefaultFieldStyling;
|
|
32
|
+
icon: DefaultIconStyling;
|
|
33
|
+
toggle: DefaultToggleStyling;
|
|
34
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Transaction, ReactiveNodeVariable, Isolation } from "reactronic";
|
|
2
|
+
import { DefaultButtonStyling } from "./theme/Button.s.js";
|
|
3
|
+
import { DefaultFieldStyling } from "./theme/Field.s.js";
|
|
4
|
+
import { DefaultIconStyling } from "./theme/Icon.s.js";
|
|
5
|
+
import { DefaultToggleStyling } from "./theme/Toggle.s.js";
|
|
6
|
+
export class Theme {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.name = "Default Gost Theme";
|
|
9
|
+
this.fillColor = "white";
|
|
10
|
+
this.textColor = "black";
|
|
11
|
+
this.positiveColor = "green";
|
|
12
|
+
this.negativeColor = "red";
|
|
13
|
+
this.borderRadius = "0.35rem";
|
|
14
|
+
this.outlineWidth = "1px";
|
|
15
|
+
this.outlineColor = "rgba(127, 127, 127, 0.5)";
|
|
16
|
+
this.outlinePadding = "0.25em";
|
|
17
|
+
this.shadow = "0.1rem 0.1rem 0.5rem 0 rgba(127, 127, 127, 0.5)";
|
|
18
|
+
this.button = new DefaultButtonStyling(this);
|
|
19
|
+
this.field = new DefaultFieldStyling(this);
|
|
20
|
+
this.icon = new DefaultIconStyling(this);
|
|
21
|
+
this.toggle = new DefaultToggleStyling(this);
|
|
22
|
+
}
|
|
23
|
+
static get current() {
|
|
24
|
+
return Theme.gCurrent.value;
|
|
25
|
+
}
|
|
26
|
+
static set current(value) {
|
|
27
|
+
Theme.gCurrent.value = value;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
Theme.gCurrent = new ReactiveNodeVariable(Transaction.run({ isolation: Isolation.disjoinFromOuterTransaction }, () => new Theme()));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactiveNodeDecl, ReactiveNode } from "reactronic";
|
|
2
|
+
import { El } from "verstak";
|
|
3
|
+
export type ToggleModel = {
|
|
4
|
+
label?: string;
|
|
5
|
+
checked?: boolean;
|
|
6
|
+
color?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function Toggle(declaration?: ReactiveNodeDecl<El<HTMLElement, ToggleModel>>): ReactiveNode<El<HTMLElement, ToggleModel>>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Transaction, Mode, ReactiveNode } from "reactronic";
|
|
2
|
+
import { Panel, Note } from "verstak";
|
|
3
|
+
import { observableModel } from "./common/Utils.js";
|
|
4
|
+
import { Theme } from "./Theme.js";
|
|
5
|
+
import { Icon } from "./Icon.v.js";
|
|
6
|
+
export function Toggle(declaration) {
|
|
7
|
+
return (Panel(ReactiveNode.withBasis(declaration, {
|
|
8
|
+
mode: Mode.autonomous,
|
|
9
|
+
preparation: el => {
|
|
10
|
+
var _a;
|
|
11
|
+
(_a = el.model) !== null && _a !== void 0 ? _a : (el.model = observableModel({
|
|
12
|
+
label: ReactiveNode.key,
|
|
13
|
+
checked: true,
|
|
14
|
+
color: "green"
|
|
15
|
+
}));
|
|
16
|
+
el.native.onclick = () => Transaction.run(null, () => el.model.checked = !el.model.checked);
|
|
17
|
+
},
|
|
18
|
+
script: el => {
|
|
19
|
+
const m = el.model;
|
|
20
|
+
const theme = Theme.current;
|
|
21
|
+
const toggleTheme = theme.toggle;
|
|
22
|
+
el.useStylingPreset(toggleTheme.main);
|
|
23
|
+
Icon(`fa-solid fa-toggle-${m.checked ? "on" : "off"}`, {
|
|
24
|
+
script: (el, base) => {
|
|
25
|
+
var _a;
|
|
26
|
+
base();
|
|
27
|
+
el.useStylingPreset(toggleTheme.icon);
|
|
28
|
+
el.style.color = m.checked ? ((_a = theme.positiveColor) !== null && _a !== void 0 ? _a : "") : "";
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
if (m.label)
|
|
32
|
+
Note(m.label, false, {
|
|
33
|
+
script: (el, base) => {
|
|
34
|
+
base();
|
|
35
|
+
el.useStylingPreset(toggleTheme.label);
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
})));
|
|
40
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./Button.v.js";
|
|
2
|
+
export * from "./Field.v.js";
|
|
3
|
+
export * from "./Icon.v.js";
|
|
4
|
+
export * from "./Image.v.js";
|
|
5
|
+
export * from "./Spinner.v.js";
|
|
6
|
+
export * from "./Toggle.v.js";
|
|
7
|
+
export * from "./Markdown.v.js";
|
|
8
|
+
export * from "./Theme.js";
|
|
9
|
+
export { observableModel } from "./common/Utils.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./Button.v.js";
|
|
2
|
+
export * from "./Field.v.js";
|
|
3
|
+
export * from "./Icon.v.js";
|
|
4
|
+
export * from "./Image.v.js";
|
|
5
|
+
export * from "./Spinner.v.js";
|
|
6
|
+
export * from "./Toggle.v.js";
|
|
7
|
+
export * from "./Markdown.v.js";
|
|
8
|
+
export * from "./Theme.js";
|
|
9
|
+
export { observableModel } from "./common/Utils.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ObservableObject, Ref, Transaction, Isolation } from "reactronic";
|
|
2
|
+
export function observableModel(modelProps) {
|
|
3
|
+
return Transaction.run({ isolation: Isolation.disjoinFromOuterTransaction }, () => new ObservableComposition(modelProps));
|
|
4
|
+
}
|
|
5
|
+
class ObservableComposition extends ObservableObject {
|
|
6
|
+
constructor(composition) {
|
|
7
|
+
super();
|
|
8
|
+
convertValuesToFieldsAndRefsToGetSet(this, composition);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function convertValuesToFieldsAndRefsToGetSet(target, composition) {
|
|
12
|
+
for (const key in composition) {
|
|
13
|
+
const x = composition[key];
|
|
14
|
+
if (x instanceof Ref) {
|
|
15
|
+
Object.defineProperty(target, key, {
|
|
16
|
+
get() { return x.variable; },
|
|
17
|
+
set(v) { x.variable = v; return true; },
|
|
18
|
+
enumerable: true,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const t = target;
|
|
23
|
+
t[key] = x;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Styling } from "./Styling.js";
|
|
2
|
+
export type ButtonStyling = {
|
|
3
|
+
main: string;
|
|
4
|
+
icon: string;
|
|
5
|
+
label: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class DefaultButtonStyling extends Styling implements ButtonStyling {
|
|
8
|
+
get main(): string;
|
|
9
|
+
get icon(): string;
|
|
10
|
+
get label(): string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { cached } from "reactronic";
|
|
11
|
+
import { css } from "@emotion/css";
|
|
12
|
+
import { Styling } from "./Styling.js";
|
|
13
|
+
export class DefaultButtonStyling extends Styling {
|
|
14
|
+
get main() {
|
|
15
|
+
return css `
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
border-radius: ${this.$.borderRadius};
|
|
18
|
+
user-select: none;
|
|
19
|
+
`;
|
|
20
|
+
}
|
|
21
|
+
get icon() {
|
|
22
|
+
return css `
|
|
23
|
+
min-width: auto;
|
|
24
|
+
margin-left: ${this.$.outlinePadding};
|
|
25
|
+
margin-right: ${this.$.outlinePadding};
|
|
26
|
+
`;
|
|
27
|
+
}
|
|
28
|
+
get label() {
|
|
29
|
+
return css `
|
|
30
|
+
margin-left: ${this.$.outlinePadding};
|
|
31
|
+
margin-right: ${this.$.outlinePadding};
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
__decorate([
|
|
36
|
+
cached,
|
|
37
|
+
__metadata("design:type", String),
|
|
38
|
+
__metadata("design:paramtypes", [])
|
|
39
|
+
], DefaultButtonStyling.prototype, "main", null);
|
|
40
|
+
__decorate([
|
|
41
|
+
cached,
|
|
42
|
+
__metadata("design:type", String),
|
|
43
|
+
__metadata("design:paramtypes", [])
|
|
44
|
+
], DefaultButtonStyling.prototype, "icon", null);
|
|
45
|
+
__decorate([
|
|
46
|
+
cached,
|
|
47
|
+
__metadata("design:type", String),
|
|
48
|
+
__metadata("design:paramtypes", [])
|
|
49
|
+
], DefaultButtonStyling.prototype, "label", null);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Styling } from "./Styling.js";
|
|
2
|
+
export type FieldStyling = {
|
|
3
|
+
main: string;
|
|
4
|
+
icon: string;
|
|
5
|
+
input: string;
|
|
6
|
+
popup: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class DefaultFieldStyling extends Styling implements FieldStyling {
|
|
9
|
+
get main(): string;
|
|
10
|
+
get icon(): string;
|
|
11
|
+
get input(): string;
|
|
12
|
+
get popup(): string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { cached } from "reactronic";
|
|
11
|
+
import { css } from "@emotion/css";
|
|
12
|
+
import { Styling } from "./Styling.js";
|
|
13
|
+
export class DefaultFieldStyling extends Styling {
|
|
14
|
+
get main() {
|
|
15
|
+
return css `
|
|
16
|
+
border-radius: ${this.$.borderRadius};
|
|
17
|
+
outline: ${this.$.outlineWidth} solid ${this.$.outlineColor};
|
|
18
|
+
outline-offset: -${this.$.outlineWidth};
|
|
19
|
+
`;
|
|
20
|
+
}
|
|
21
|
+
get icon() {
|
|
22
|
+
return css `
|
|
23
|
+
margin-left: ${this.$.outlinePadding};
|
|
24
|
+
min-width: 1.25em;
|
|
25
|
+
text-align: center;
|
|
26
|
+
color: ${this.$.outlineColor};
|
|
27
|
+
`;
|
|
28
|
+
}
|
|
29
|
+
get input() {
|
|
30
|
+
return css `
|
|
31
|
+
padding: ${this.$.outlinePadding};
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
34
|
+
get popup() {
|
|
35
|
+
return css `
|
|
36
|
+
border-radius: ${this.$.borderRadius};
|
|
37
|
+
outline: ${this.$.outlineWidth} solid ${this.$.outlineColor};
|
|
38
|
+
outline-offset: -${this.$.outlineWidth};
|
|
39
|
+
padding: ${this.$.outlinePadding};
|
|
40
|
+
background-color: ${this.$.fillColor};
|
|
41
|
+
margin-top: -${this.$.outlineWidth};
|
|
42
|
+
margin-bottom: -${this.$.outlineWidth};
|
|
43
|
+
box-shadow: ${this.$.shadow};
|
|
44
|
+
overflow: scroll;
|
|
45
|
+
height: 4rem;
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
__decorate([
|
|
50
|
+
cached,
|
|
51
|
+
__metadata("design:type", String),
|
|
52
|
+
__metadata("design:paramtypes", [])
|
|
53
|
+
], DefaultFieldStyling.prototype, "main", null);
|
|
54
|
+
__decorate([
|
|
55
|
+
cached,
|
|
56
|
+
__metadata("design:type", String),
|
|
57
|
+
__metadata("design:paramtypes", [])
|
|
58
|
+
], DefaultFieldStyling.prototype, "icon", null);
|
|
59
|
+
__decorate([
|
|
60
|
+
cached,
|
|
61
|
+
__metadata("design:type", String),
|
|
62
|
+
__metadata("design:paramtypes", [])
|
|
63
|
+
], DefaultFieldStyling.prototype, "input", null);
|
|
64
|
+
__decorate([
|
|
65
|
+
cached,
|
|
66
|
+
__metadata("design:type", String),
|
|
67
|
+
__metadata("design:paramtypes", [])
|
|
68
|
+
], DefaultFieldStyling.prototype, "popup", null);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { cached } from "reactronic";
|
|
11
|
+
import { css } from "@emotion/css";
|
|
12
|
+
import { Styling } from "./Styling.js";
|
|
13
|
+
export class DefaultIconStyling extends Styling {
|
|
14
|
+
get main() {
|
|
15
|
+
return css `
|
|
16
|
+
min-width: 1.25em;
|
|
17
|
+
min-height: auto;
|
|
18
|
+
text-align: center;
|
|
19
|
+
`;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
__decorate([
|
|
23
|
+
cached,
|
|
24
|
+
__metadata("design:type", String),
|
|
25
|
+
__metadata("design:paramtypes", [])
|
|
26
|
+
], DefaultIconStyling.prototype, "main", null);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ObservableObject } from "reactronic";
|
|
2
|
+
export type AbstractTheme = {
|
|
3
|
+
fillColor: string;
|
|
4
|
+
textColor: string;
|
|
5
|
+
positiveColor: string;
|
|
6
|
+
negativeColor: string;
|
|
7
|
+
borderRadius: string;
|
|
8
|
+
outlineWidth: string;
|
|
9
|
+
outlineColor: string;
|
|
10
|
+
outlinePadding: string;
|
|
11
|
+
shadow: string;
|
|
12
|
+
};
|
|
13
|
+
export declare class Styling extends ObservableObject {
|
|
14
|
+
protected readonly $: AbstractTheme;
|
|
15
|
+
constructor($: AbstractTheme);
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { ObservableObject, raw } from "reactronic";
|
|
11
|
+
export class Styling extends ObservableObject {
|
|
12
|
+
constructor($) {
|
|
13
|
+
super();
|
|
14
|
+
this.$ = $;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
__decorate([
|
|
18
|
+
raw,
|
|
19
|
+
__metadata("design:type", Object)
|
|
20
|
+
], Styling.prototype, "$", void 0);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Styling } from "./Styling.js";
|
|
2
|
+
export type ToggleStyling = {
|
|
3
|
+
main: string;
|
|
4
|
+
icon: string;
|
|
5
|
+
label: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class DefaultToggleStyling extends Styling implements ToggleStyling {
|
|
8
|
+
get main(): string;
|
|
9
|
+
get icon(): string;
|
|
10
|
+
get label(): string;
|
|
11
|
+
}
|