@arcanejs/toolkit 0.2.1 → 0.3.0
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/dist/backend/components/base.d.mts +4 -1
- package/dist/backend/components/base.d.ts +4 -1
- package/dist/backend/components/base.js +10 -188
- package/dist/backend/components/base.mjs +1 -1
- package/dist/backend/components/button.d.mts +1 -0
- package/dist/backend/components/button.d.ts +1 -0
- package/dist/backend/components/button.js +5 -165
- package/dist/backend/components/button.mjs +2 -2
- package/dist/backend/components/group.d.mts +1 -0
- package/dist/backend/components/group.d.ts +1 -0
- package/dist/backend/components/group.js +7 -281
- package/dist/backend/components/group.mjs +2 -2
- package/dist/backend/components/label.d.mts +1 -0
- package/dist/backend/components/label.d.ts +1 -0
- package/dist/backend/components/label.js +5 -102
- package/dist/backend/components/label.mjs +2 -2
- package/dist/backend/components/rect.d.mts +1 -0
- package/dist/backend/components/rect.d.ts +1 -0
- package/dist/backend/components/rect.js +5 -102
- package/dist/backend/components/rect.mjs +2 -2
- package/dist/backend/components/slider-button.d.mts +1 -0
- package/dist/backend/components/slider-button.d.ts +1 -0
- package/dist/backend/components/slider-button.js +5 -158
- package/dist/backend/components/slider-button.mjs +2 -2
- package/dist/backend/components/switch.d.mts +1 -0
- package/dist/backend/components/switch.d.ts +1 -0
- package/dist/backend/components/switch.js +5 -141
- package/dist/backend/components/switch.mjs +2 -2
- package/dist/backend/components/tabs.d.mts +1 -0
- package/dist/backend/components/tabs.d.ts +1 -0
- package/dist/backend/components/tabs.js +7 -206
- package/dist/backend/components/tabs.mjs +2 -2
- package/dist/backend/components/text-input.d.mts +1 -0
- package/dist/backend/components/text-input.d.ts +1 -0
- package/dist/backend/components/text-input.js +5 -143
- package/dist/backend/components/text-input.mjs +2 -2
- package/dist/backend/components/timeline.d.mts +1 -0
- package/dist/backend/components/timeline.d.ts +1 -0
- package/dist/backend/components/timeline.js +5 -106
- package/dist/backend/components/timeline.mjs +2 -2
- package/dist/backend/util/index.js +5 -41
- package/dist/chunk-3RG5ZIWI.js +10 -0
- package/dist/{chunk-3O4P67DM.mjs → chunk-3Y3HRYLC.mjs} +1 -1
- package/dist/{chunk-HNEUZVCX.mjs → chunk-7ITSSJE2.mjs} +1 -1
- package/dist/chunk-DNCHAOYH.js +42 -0
- package/dist/chunk-DV5WTSFW.js +33 -0
- package/dist/chunk-EABM5X65.js +17 -0
- package/dist/{chunk-ZCHM3JJJ.mjs → chunk-EDTJ75FT.mjs} +4 -3
- package/dist/{chunk-TAZH4BBH.mjs → chunk-EH73E5FP.mjs} +1 -1
- package/dist/{chunk-JW4GXS54.mjs → chunk-H2UQDFTS.mjs} +1 -1
- package/dist/chunk-IW3JCC73.js +44 -0
- package/dist/chunk-J46AJUGE.js +66 -0
- package/dist/{chunk-IXTM35YM.mjs → chunk-NKNDCRUR.mjs} +1 -1
- package/dist/chunk-NZUYU32Z.js +164 -0
- package/dist/{chunk-SOC4TF3J.mjs → chunk-POUQGJN4.mjs} +1 -1
- package/dist/chunk-QUA3NBLD.js +104 -0
- package/dist/{chunk-ZU5H6SVA.mjs → chunk-SMTUN6HG.mjs} +1 -1
- package/dist/chunk-TSC5C5XR.js +29 -0
- package/dist/chunk-WIPEQNWR.js +29 -0
- package/dist/chunk-WXSKMMCV.js +55 -0
- package/dist/{chunk-TQ27Y7F4.mjs → chunk-YIXRQHTA.mjs} +1 -1
- package/dist/chunk-YN3FZMXY.js +59 -0
- package/dist/{chunk-APCR3ITH.mjs → chunk-YYM7PBRN.mjs} +1 -1
- package/dist/frontend.js +0 -3
- package/dist/frontend.js.map +2 -2
- package/dist/index.d.mts +21 -3
- package/dist/index.d.ts +21 -3
- package/dist/index.js +99 -669
- package/dist/index.mjs +28 -24
- package/package.json +5 -5
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3;// src/backend/components/base.ts
|
|
2
|
+
var Base = (_class = class {
|
|
3
|
+
/** @hidden */
|
|
4
|
+
__init() {this.parent = null}
|
|
5
|
+
/** @hidden */
|
|
6
|
+
|
|
7
|
+
/** @hidden */
|
|
8
|
+
|
|
9
|
+
constructor(defaultProps, props) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);
|
|
10
|
+
this.defaultProps = defaultProps;
|
|
11
|
+
this._props = Object.freeze({
|
|
12
|
+
...defaultProps,
|
|
13
|
+
...props
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
__init2() {this.log = () => {
|
|
17
|
+
return _optionalChain([this, 'access', _4 => _4.parent, 'optionalAccess', _5 => _5.log, 'call', _6 => _6()]) || null;
|
|
18
|
+
}}
|
|
19
|
+
get props() {
|
|
20
|
+
return this._props;
|
|
21
|
+
}
|
|
22
|
+
set props(props) {
|
|
23
|
+
this.setProps(props);
|
|
24
|
+
}
|
|
25
|
+
__init3() {this.setProps = (props) => {
|
|
26
|
+
this._props = Object.freeze({
|
|
27
|
+
...this.defaultProps,
|
|
28
|
+
...props
|
|
29
|
+
});
|
|
30
|
+
this.updateTree();
|
|
31
|
+
}}
|
|
32
|
+
__init4() {this.updateProps = (updates) => {
|
|
33
|
+
this._props = Object.freeze({
|
|
34
|
+
...this._props,
|
|
35
|
+
...updates
|
|
36
|
+
});
|
|
37
|
+
this.updateTree();
|
|
38
|
+
}}
|
|
39
|
+
/** @hidden */
|
|
40
|
+
setParent(parent) {
|
|
41
|
+
if (this.parent && this.parent !== parent) {
|
|
42
|
+
this.parent.removeChild(this);
|
|
43
|
+
}
|
|
44
|
+
this.parent = parent;
|
|
45
|
+
}
|
|
46
|
+
/** @hidden */
|
|
47
|
+
updateTree() {
|
|
48
|
+
if (this.parent) this.parent.updateTree();
|
|
49
|
+
}
|
|
50
|
+
/** @hidden */
|
|
51
|
+
handleMessage(_message) {
|
|
52
|
+
}
|
|
53
|
+
routeMessage(_idMap, _message) {
|
|
54
|
+
}
|
|
55
|
+
}, _class);
|
|
56
|
+
var BaseParent = (_class2 = class extends Base {constructor(...args2) { super(...args2); _class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this); }
|
|
57
|
+
/** @hidden */
|
|
58
|
+
__init5() {this.children = []}
|
|
59
|
+
__init6() {this.appendChildren = (...children) => {
|
|
60
|
+
for (const c of children) {
|
|
61
|
+
const newChildren = [...this.children.filter((ch) => ch !== c), c];
|
|
62
|
+
this.validateChildren(newChildren);
|
|
63
|
+
this.children = Object.freeze(newChildren);
|
|
64
|
+
c.setParent(this);
|
|
65
|
+
}
|
|
66
|
+
this.updateTree();
|
|
67
|
+
return children;
|
|
68
|
+
}}
|
|
69
|
+
__init7() {this.appendChild = (child) => {
|
|
70
|
+
this.appendChildren(child);
|
|
71
|
+
return child;
|
|
72
|
+
}}
|
|
73
|
+
__init8() {this.removeChild = (component) => {
|
|
74
|
+
const match = this.children.findIndex((c) => c === component);
|
|
75
|
+
if (match >= 0) {
|
|
76
|
+
const removingChild = this.children[match];
|
|
77
|
+
const newChildren = [
|
|
78
|
+
...this.children.slice(0, match),
|
|
79
|
+
...this.children.slice(match + 1)
|
|
80
|
+
];
|
|
81
|
+
this.validateChildren(newChildren);
|
|
82
|
+
this.children = Object.freeze(newChildren);
|
|
83
|
+
_optionalChain([removingChild, 'optionalAccess', _9 => _9.setParent, 'call', _10 => _10(null)]);
|
|
84
|
+
this.updateTree();
|
|
85
|
+
}
|
|
86
|
+
}}
|
|
87
|
+
__init9() {this.removeAllChildren = () => {
|
|
88
|
+
this.children.map((c) => c.setParent(null));
|
|
89
|
+
this.children = Object.freeze([]);
|
|
90
|
+
this.updateTree();
|
|
91
|
+
}}
|
|
92
|
+
/**
|
|
93
|
+
* Return all children components that messages need to be routed to
|
|
94
|
+
*/
|
|
95
|
+
__init10() {this.getChildren = () => this.children}
|
|
96
|
+
/**
|
|
97
|
+
* TODO: we can do this better, right now it broadcasts the message to all
|
|
98
|
+
* components of the tree
|
|
99
|
+
*
|
|
100
|
+
* @hidden
|
|
101
|
+
*/
|
|
102
|
+
routeMessage(idMap, message) {
|
|
103
|
+
if (idMap.getId(this) === message.componentKey) {
|
|
104
|
+
this.handleMessage(message);
|
|
105
|
+
} else {
|
|
106
|
+
for (const c of this.children) {
|
|
107
|
+
if (idMap.getId(c) === message.componentKey) {
|
|
108
|
+
c.handleMessage(message);
|
|
109
|
+
} else {
|
|
110
|
+
c.routeMessage(idMap, message);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
insertBefore(child, beforeChild) {
|
|
116
|
+
const filteredChildren = this.children.filter((c) => c !== child);
|
|
117
|
+
let match = filteredChildren.findIndex((c) => c === beforeChild);
|
|
118
|
+
if (match === -1) {
|
|
119
|
+
match = filteredChildren.length;
|
|
120
|
+
}
|
|
121
|
+
const newChildren = [
|
|
122
|
+
...filteredChildren.slice(0, match),
|
|
123
|
+
child,
|
|
124
|
+
...filteredChildren.slice(match)
|
|
125
|
+
];
|
|
126
|
+
this.validateChildren(newChildren);
|
|
127
|
+
this.children = Object.freeze(newChildren);
|
|
128
|
+
child.setParent(this);
|
|
129
|
+
this.updateTree();
|
|
130
|
+
}
|
|
131
|
+
}, _class2);
|
|
132
|
+
var EventEmitter = (_class3 = class {constructor() { _class3.prototype.__init11.call(this);_class3.prototype.__init12.call(this);_class3.prototype.__init13.call(this);_class3.prototype.__init14.call(this); }
|
|
133
|
+
__init11() {this.listeners = /* @__PURE__ */ new Map()}
|
|
134
|
+
__init12() {this.addListener = (type, listener) => {
|
|
135
|
+
let set = this.listeners.get(type);
|
|
136
|
+
if (!set) {
|
|
137
|
+
set = /* @__PURE__ */ new Set();
|
|
138
|
+
this.listeners.set(type, set);
|
|
139
|
+
}
|
|
140
|
+
set.add(listener);
|
|
141
|
+
}}
|
|
142
|
+
__init13() {this.removeListener = (type, listener) => {
|
|
143
|
+
_optionalChain([this, 'access', _16 => _16.listeners, 'access', _17 => _17.get, 'call', _18 => _18(type), 'optionalAccess', _19 => _19.delete, 'call', _20 => _20(listener)]);
|
|
144
|
+
}}
|
|
145
|
+
__init14() {this.emit = (type, ...args) => {
|
|
146
|
+
return Promise.all(
|
|
147
|
+
[...this.listeners.get(type) || []].map(
|
|
148
|
+
(l) => new Promise((resolve, reject) => {
|
|
149
|
+
try {
|
|
150
|
+
resolve(l(...args));
|
|
151
|
+
} catch (e) {
|
|
152
|
+
reject(e);
|
|
153
|
+
}
|
|
154
|
+
})
|
|
155
|
+
)
|
|
156
|
+
);
|
|
157
|
+
}}
|
|
158
|
+
}, _class3);
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
exports.Base = Base; exports.BaseParent = BaseParent; exports.EventEmitter = EventEmitter;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class; var _class2;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkNZUYU32Zjs = require('./chunk-NZUYU32Z.js');
|
|
5
|
+
|
|
6
|
+
// src/backend/components/group.ts
|
|
7
|
+
var GROUP_DEFAULT_STYLE = {
|
|
8
|
+
direction: "horizontal"
|
|
9
|
+
};
|
|
10
|
+
var DEFAULT_PROPS = {
|
|
11
|
+
...GROUP_DEFAULT_STYLE,
|
|
12
|
+
title: null,
|
|
13
|
+
labels: null
|
|
14
|
+
};
|
|
15
|
+
var GroupHeader = (_class = class extends _chunkNZUYU32Zjs.BaseParent {constructor(...args) { super(...args); _class.prototype.__init.call(this);_class.prototype.__init2.call(this); }
|
|
16
|
+
__init() {this.validateChildren = () => {
|
|
17
|
+
}}
|
|
18
|
+
/** @hidden */
|
|
19
|
+
__init2() {this.getProtoInfo = (idMap) => ({
|
|
20
|
+
component: "group-header",
|
|
21
|
+
key: idMap.getId(this),
|
|
22
|
+
children: this.getChildren().map((c) => c.getProtoInfo(idMap))
|
|
23
|
+
})}
|
|
24
|
+
}, _class);
|
|
25
|
+
var Group = (_class2 = class extends _chunkNZUYU32Zjs.BaseParent {
|
|
26
|
+
/** @hidden */
|
|
27
|
+
__init3() {this.events = new (0, _chunkNZUYU32Zjs.EventEmitter)()}
|
|
28
|
+
constructor(props) {
|
|
29
|
+
super(DEFAULT_PROPS, props);_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);_class2.prototype.__init11.call(this);_class2.prototype.__init12.call(this);_class2.prototype.__init13.call(this);_class2.prototype.__init14.call(this);_class2.prototype.__init15.call(this);;
|
|
30
|
+
}
|
|
31
|
+
__init4() {this.addListener = this.events.addListener}
|
|
32
|
+
__init5() {this.removeListener = this.events.removeListener}
|
|
33
|
+
__init6() {this.validateChildren = () => {
|
|
34
|
+
}}
|
|
35
|
+
__init7() {this.setOptions = (options) => {
|
|
36
|
+
this.updateProps(options);
|
|
37
|
+
}}
|
|
38
|
+
__init8() {this.setTitle = (title) => {
|
|
39
|
+
this.updateProps({ title });
|
|
40
|
+
}}
|
|
41
|
+
__init9() {this.addLabel = (label) => {
|
|
42
|
+
this.updateProps({ labels: [...this.props.labels || [], label] });
|
|
43
|
+
}}
|
|
44
|
+
__init10() {this.setLabels = (labels) => {
|
|
45
|
+
this.updateProps({ labels });
|
|
46
|
+
}}
|
|
47
|
+
__init11() {this.addHeaderChild = (child) => {
|
|
48
|
+
const header = new GroupHeader({});
|
|
49
|
+
header.appendChild(child);
|
|
50
|
+
this.appendChild(header);
|
|
51
|
+
return child;
|
|
52
|
+
}}
|
|
53
|
+
__init12() {this.removeHeaderChild = (child) => {
|
|
54
|
+
for (const c of this.getChildren()) {
|
|
55
|
+
if (c instanceof GroupHeader) {
|
|
56
|
+
c.removeChild(child);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}}
|
|
60
|
+
__init13() {this.removeAllHeaderChildren = () => {
|
|
61
|
+
for (const child of this.getChildren()) {
|
|
62
|
+
if (child instanceof GroupHeader) {
|
|
63
|
+
child.removeAllChildren();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}}
|
|
67
|
+
/** @hidden */
|
|
68
|
+
__init14() {this.getProtoInfo = (idMap) => {
|
|
69
|
+
const children = [];
|
|
70
|
+
const headers = [];
|
|
71
|
+
for (const c of this.getChildren()) {
|
|
72
|
+
const childProto = c.getProtoInfo(idMap);
|
|
73
|
+
if (childProto.component === "group-header") {
|
|
74
|
+
headers.push(childProto);
|
|
75
|
+
} else {
|
|
76
|
+
children.push(childProto);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
component: "group",
|
|
81
|
+
key: idMap.getId(this),
|
|
82
|
+
title: _nullishCoalesce(this.props.title, () => ( void 0)),
|
|
83
|
+
direction: this.props.direction,
|
|
84
|
+
border: this.props.border,
|
|
85
|
+
wrap: this.props.wrap,
|
|
86
|
+
children,
|
|
87
|
+
headers: headers.length > 0 ? headers : void 0,
|
|
88
|
+
labels: _nullishCoalesce(this.props.labels, () => ( void 0)),
|
|
89
|
+
editableTitle: this.props.editableTitle || false,
|
|
90
|
+
defaultCollapsibleState: this.props.defaultCollapsibleState
|
|
91
|
+
};
|
|
92
|
+
}}
|
|
93
|
+
/** @hidden */
|
|
94
|
+
__init15() {this.handleMessage = (message) => {
|
|
95
|
+
if (message.component === "group") {
|
|
96
|
+
this.events.emit("title-changed", message.title);
|
|
97
|
+
}
|
|
98
|
+
}}
|
|
99
|
+
}, _class2);
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
exports.GroupHeader = GroupHeader; exports.Group = Group;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
var _chunkNZUYU32Zjs = require('./chunk-NZUYU32Z.js');
|
|
4
|
+
|
|
5
|
+
// src/backend/components/label.ts
|
|
6
|
+
var Label = class extends _chunkNZUYU32Zjs.Base {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super({ text: null }, props);
|
|
9
|
+
}
|
|
10
|
+
/** @hidden */
|
|
11
|
+
getProtoInfo(idMap) {
|
|
12
|
+
return {
|
|
13
|
+
component: "label",
|
|
14
|
+
key: idMap.getId(this),
|
|
15
|
+
bold: this.props.bold,
|
|
16
|
+
text: _nullishCoalesce(this.props.text, () => ( ""))
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
setText(text) {
|
|
20
|
+
this.updateProps({
|
|
21
|
+
text
|
|
22
|
+
});
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
exports.Label = Label;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkNZUYU32Zjs = require('./chunk-NZUYU32Z.js');
|
|
4
|
+
|
|
5
|
+
// src/backend/components/rect.ts
|
|
6
|
+
var DEFAULT_PROPS = {
|
|
7
|
+
color: "rgba(0, 0, 0, 0)"
|
|
8
|
+
};
|
|
9
|
+
var Rect = class extends _chunkNZUYU32Zjs.Base {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(DEFAULT_PROPS, props);
|
|
12
|
+
}
|
|
13
|
+
/** @hidden */
|
|
14
|
+
getProtoInfo(idMap) {
|
|
15
|
+
return {
|
|
16
|
+
component: "rect",
|
|
17
|
+
key: idMap.getId(this),
|
|
18
|
+
color: this.props.color
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
setColor(color) {
|
|
22
|
+
this.updateProps({ color });
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
exports.Rect = Rect;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class; var _class2;
|
|
2
|
+
|
|
3
|
+
var _chunkNZUYU32Zjs = require('./chunk-NZUYU32Z.js');
|
|
4
|
+
|
|
5
|
+
// src/backend/components/tabs.ts
|
|
6
|
+
var Tab = (_class = class extends _chunkNZUYU32Zjs.BaseParent {constructor(...args) { super(...args); _class.prototype.__init.call(this);_class.prototype.__init2.call(this); }
|
|
7
|
+
__init() {this.validateChildren = (children) => {
|
|
8
|
+
if (children.length > 1) {
|
|
9
|
+
throw new Error("Tab can only have one child");
|
|
10
|
+
}
|
|
11
|
+
}}
|
|
12
|
+
/** @hidden */
|
|
13
|
+
__init2() {this.getProtoInfo = (idMap) => ({
|
|
14
|
+
component: "tab",
|
|
15
|
+
key: idMap.getId(this),
|
|
16
|
+
name: this.props.name,
|
|
17
|
+
child: this.getChildren().slice(0, 1).map((c) => c.getProtoInfo(idMap))[0]
|
|
18
|
+
})}
|
|
19
|
+
}, _class);
|
|
20
|
+
var Tabs = (_class2 = class extends _chunkNZUYU32Zjs.BaseParent {
|
|
21
|
+
__init3() {this.validateChildren = (children) => {
|
|
22
|
+
for (const child of children) {
|
|
23
|
+
if (!(child instanceof Tab)) {
|
|
24
|
+
throw new Error("Tabs can only have Tab children");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}}
|
|
28
|
+
constructor(props) {
|
|
29
|
+
super({}, { ...props });_class2.prototype.__init3.call(this);;
|
|
30
|
+
}
|
|
31
|
+
addTabs(...tabs) {
|
|
32
|
+
for (const t of tabs) {
|
|
33
|
+
const tab = new Tab({ name: t.name });
|
|
34
|
+
tab.appendChildren(t.component);
|
|
35
|
+
this.appendChild(tab);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
addTab(name, component) {
|
|
39
|
+
this.addTabs({ name, component });
|
|
40
|
+
return component;
|
|
41
|
+
}
|
|
42
|
+
/** @hidden */
|
|
43
|
+
getProtoInfo(idMap) {
|
|
44
|
+
return {
|
|
45
|
+
component: "tabs",
|
|
46
|
+
key: idMap.getId(this),
|
|
47
|
+
tabs: this.getChildren().map((c) => c.getProtoInfo(idMap))
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}, _class2);
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
exports.Tab = Tab; exports.Tabs = Tabs;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkNZUYU32Zjs = require('./chunk-NZUYU32Z.js');
|
|
5
|
+
|
|
6
|
+
// src/backend/components/slider-button.ts
|
|
7
|
+
var DEFAULT_PROPS = {
|
|
8
|
+
value: null,
|
|
9
|
+
min: 0,
|
|
10
|
+
max: 255,
|
|
11
|
+
step: 5,
|
|
12
|
+
mode: "writeBack"
|
|
13
|
+
};
|
|
14
|
+
var SliderButton = (_class = class extends _chunkNZUYU32Zjs.Base {
|
|
15
|
+
/** @hidden */
|
|
16
|
+
__init() {this.events = new (0, _chunkNZUYU32Zjs.EventEmitter)()}
|
|
17
|
+
constructor(props) {
|
|
18
|
+
super(DEFAULT_PROPS, props);_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);;
|
|
19
|
+
}
|
|
20
|
+
__init2() {this.addListener = this.events.addListener}
|
|
21
|
+
__init3() {this.removeListener = this.events.removeListener}
|
|
22
|
+
/** @hidden */
|
|
23
|
+
getProtoInfo(idMap) {
|
|
24
|
+
return {
|
|
25
|
+
component: "slider_button",
|
|
26
|
+
key: idMap.getId(this),
|
|
27
|
+
min: this.props.min,
|
|
28
|
+
max: this.props.max,
|
|
29
|
+
step: this.props.step,
|
|
30
|
+
value: this.props.value
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** @hidden */
|
|
34
|
+
handleMessage(message) {
|
|
35
|
+
if (message.component !== "slider_button") return;
|
|
36
|
+
const newValue = this.sanitizeNumber(message.value);
|
|
37
|
+
if (this.props.value === newValue) return;
|
|
38
|
+
if (this.props.mode === "writeBack") {
|
|
39
|
+
this.updateProps({ value: newValue });
|
|
40
|
+
}
|
|
41
|
+
this.events.emit("change", newValue);
|
|
42
|
+
}
|
|
43
|
+
setValue(value) {
|
|
44
|
+
const newValue = this.sanitizeNumber(value);
|
|
45
|
+
if (newValue === this.props.value) return;
|
|
46
|
+
this.updateProps({ value });
|
|
47
|
+
this.updateTree();
|
|
48
|
+
}
|
|
49
|
+
sanitizeNumber(value) {
|
|
50
|
+
const i = Math.round((value - this.props.min) / this.props.step);
|
|
51
|
+
const v = i * this.props.step + this.props.min;
|
|
52
|
+
const clampedValue = Math.max(this.props.min, Math.min(this.props.max, v));
|
|
53
|
+
return clampedValue;
|
|
54
|
+
}
|
|
55
|
+
}, _class);
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
exports.SliderButton = SliderButton;
|
package/dist/frontend.js
CHANGED
|
@@ -26757,7 +26757,6 @@ body {
|
|
|
26757
26757
|
const onClick = (0, import_react8.useMemo)(
|
|
26758
26758
|
() => () => {
|
|
26759
26759
|
if (!sendMessage) return;
|
|
26760
|
-
console.log("sending message");
|
|
26761
26760
|
sendMessage({
|
|
26762
26761
|
type: "component-message",
|
|
26763
26762
|
componentKey: info.key,
|
|
@@ -27143,7 +27142,6 @@ body {
|
|
|
27143
27142
|
`ws://${window.location.hostname}:${window.location.port}${window.location.pathname}`
|
|
27144
27143
|
);
|
|
27145
27144
|
ws.onmessage = (event) => {
|
|
27146
|
-
console.log("message", event.data);
|
|
27147
27145
|
handleMessage(JSON.parse(event.data));
|
|
27148
27146
|
};
|
|
27149
27147
|
ws.onclose = () => {
|
|
@@ -27165,7 +27163,6 @@ body {
|
|
|
27165
27163
|
(await (socket.current || initializeWebsocket())).send(JSON.stringify(msg));
|
|
27166
27164
|
};
|
|
27167
27165
|
const handleMessage = (msg) => {
|
|
27168
|
-
console.log("handleMessage", msg);
|
|
27169
27166
|
switch (msg.type) {
|
|
27170
27167
|
case "tree-full":
|
|
27171
27168
|
setRoot(msg.root);
|