@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
|
@@ -1,161 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
SliderButton: () => SliderButton
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(slider_button_exports);
|
|
3
|
+
var _chunkYN3FZMXYjs = require('../../chunk-YN3FZMXY.js');
|
|
4
|
+
require('../../chunk-NZUYU32Z.js');
|
|
5
|
+
require('../../chunk-3RG5ZIWI.js');
|
|
26
6
|
|
|
27
|
-
// src/backend/components/base.ts
|
|
28
|
-
var Base = class {
|
|
29
|
-
/** @hidden */
|
|
30
|
-
parent = null;
|
|
31
|
-
/** @hidden */
|
|
32
|
-
defaultProps;
|
|
33
|
-
/** @hidden */
|
|
34
|
-
_props;
|
|
35
|
-
constructor(defaultProps, props) {
|
|
36
|
-
this.defaultProps = defaultProps;
|
|
37
|
-
this._props = Object.freeze({
|
|
38
|
-
...defaultProps,
|
|
39
|
-
...props
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
get props() {
|
|
43
|
-
return this._props;
|
|
44
|
-
}
|
|
45
|
-
set props(props) {
|
|
46
|
-
this.setProps(props);
|
|
47
|
-
}
|
|
48
|
-
setProps = (props) => {
|
|
49
|
-
this._props = Object.freeze({
|
|
50
|
-
...this.defaultProps,
|
|
51
|
-
...props
|
|
52
|
-
});
|
|
53
|
-
this.updateTree();
|
|
54
|
-
};
|
|
55
|
-
updateProps = (updates) => {
|
|
56
|
-
this._props = Object.freeze({
|
|
57
|
-
...this._props,
|
|
58
|
-
...updates
|
|
59
|
-
});
|
|
60
|
-
this.updateTree();
|
|
61
|
-
};
|
|
62
|
-
/** @hidden */
|
|
63
|
-
setParent(parent) {
|
|
64
|
-
if (this.parent && this.parent !== parent) {
|
|
65
|
-
this.parent.removeChild(this);
|
|
66
|
-
}
|
|
67
|
-
this.parent = parent;
|
|
68
|
-
}
|
|
69
|
-
/** @hidden */
|
|
70
|
-
updateTree() {
|
|
71
|
-
if (this.parent) this.parent.updateTree();
|
|
72
|
-
}
|
|
73
|
-
/** @hidden */
|
|
74
|
-
handleMessage(message) {
|
|
75
|
-
console.log("Component Received Message:", message);
|
|
76
|
-
}
|
|
77
|
-
routeMessage(_idMap, _message) {
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
var EventEmitter = class {
|
|
81
|
-
listeners = /* @__PURE__ */ new Map();
|
|
82
|
-
addListener = (type, listener) => {
|
|
83
|
-
let set = this.listeners.get(type);
|
|
84
|
-
if (!set) {
|
|
85
|
-
set = /* @__PURE__ */ new Set();
|
|
86
|
-
this.listeners.set(type, set);
|
|
87
|
-
}
|
|
88
|
-
set.add(listener);
|
|
89
|
-
};
|
|
90
|
-
removeListener = (type, listener) => {
|
|
91
|
-
this.listeners.get(type)?.delete(listener);
|
|
92
|
-
};
|
|
93
|
-
emit = (type, ...args) => {
|
|
94
|
-
return Promise.all(
|
|
95
|
-
[...this.listeners.get(type) || []].map(
|
|
96
|
-
(l) => new Promise((resolve, reject) => {
|
|
97
|
-
try {
|
|
98
|
-
resolve(l(...args));
|
|
99
|
-
} catch (e) {
|
|
100
|
-
reject(e);
|
|
101
|
-
}
|
|
102
|
-
})
|
|
103
|
-
)
|
|
104
|
-
);
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
7
|
|
|
108
|
-
|
|
109
|
-
var DEFAULT_PROPS = {
|
|
110
|
-
value: null,
|
|
111
|
-
min: 0,
|
|
112
|
-
max: 255,
|
|
113
|
-
step: 5,
|
|
114
|
-
mode: "writeBack"
|
|
115
|
-
};
|
|
116
|
-
var SliderButton = class extends Base {
|
|
117
|
-
/** @hidden */
|
|
118
|
-
events = new EventEmitter();
|
|
119
|
-
constructor(props) {
|
|
120
|
-
super(DEFAULT_PROPS, props);
|
|
121
|
-
}
|
|
122
|
-
addListener = this.events.addListener;
|
|
123
|
-
removeListener = this.events.removeListener;
|
|
124
|
-
/** @hidden */
|
|
125
|
-
getProtoInfo(idMap) {
|
|
126
|
-
return {
|
|
127
|
-
component: "slider_button",
|
|
128
|
-
key: idMap.getId(this),
|
|
129
|
-
min: this.props.min,
|
|
130
|
-
max: this.props.max,
|
|
131
|
-
step: this.props.step,
|
|
132
|
-
value: this.props.value
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
/** @hidden */
|
|
136
|
-
handleMessage(message) {
|
|
137
|
-
if (message.component !== "slider_button") return;
|
|
138
|
-
const newValue = this.sanitizeNumber(message.value);
|
|
139
|
-
if (this.props.value === newValue) return;
|
|
140
|
-
if (this.props.mode === "writeBack") {
|
|
141
|
-
this.updateProps({ value: newValue });
|
|
142
|
-
}
|
|
143
|
-
this.events.emit("change", newValue);
|
|
144
|
-
}
|
|
145
|
-
setValue(value) {
|
|
146
|
-
const newValue = this.sanitizeNumber(value);
|
|
147
|
-
if (newValue === this.props.value) return;
|
|
148
|
-
this.updateProps({ value });
|
|
149
|
-
this.updateTree();
|
|
150
|
-
}
|
|
151
|
-
sanitizeNumber(value) {
|
|
152
|
-
const i = Math.round((value - this.props.min) / this.props.step);
|
|
153
|
-
const v = i * this.props.step + this.props.min;
|
|
154
|
-
const clampedValue = Math.max(this.props.min, Math.min(this.props.max, v));
|
|
155
|
-
return clampedValue;
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
159
|
-
0 && (module.exports = {
|
|
160
|
-
SliderButton
|
|
161
|
-
});
|
|
8
|
+
exports.SliderButton = _chunkYN3FZMXYjs.SliderButton;
|
|
@@ -1,144 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Switch: () => Switch
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(switch_exports);
|
|
3
|
+
var _chunkDNCHAOYHjs = require('../../chunk-DNCHAOYH.js');
|
|
4
|
+
require('../../chunk-NZUYU32Z.js');
|
|
5
|
+
require('../../chunk-3RG5ZIWI.js');
|
|
26
6
|
|
|
27
|
-
// src/backend/components/base.ts
|
|
28
|
-
var Base = class {
|
|
29
|
-
/** @hidden */
|
|
30
|
-
parent = null;
|
|
31
|
-
/** @hidden */
|
|
32
|
-
defaultProps;
|
|
33
|
-
/** @hidden */
|
|
34
|
-
_props;
|
|
35
|
-
constructor(defaultProps, props) {
|
|
36
|
-
this.defaultProps = defaultProps;
|
|
37
|
-
this._props = Object.freeze({
|
|
38
|
-
...defaultProps,
|
|
39
|
-
...props
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
get props() {
|
|
43
|
-
return this._props;
|
|
44
|
-
}
|
|
45
|
-
set props(props) {
|
|
46
|
-
this.setProps(props);
|
|
47
|
-
}
|
|
48
|
-
setProps = (props) => {
|
|
49
|
-
this._props = Object.freeze({
|
|
50
|
-
...this.defaultProps,
|
|
51
|
-
...props
|
|
52
|
-
});
|
|
53
|
-
this.updateTree();
|
|
54
|
-
};
|
|
55
|
-
updateProps = (updates) => {
|
|
56
|
-
this._props = Object.freeze({
|
|
57
|
-
...this._props,
|
|
58
|
-
...updates
|
|
59
|
-
});
|
|
60
|
-
this.updateTree();
|
|
61
|
-
};
|
|
62
|
-
/** @hidden */
|
|
63
|
-
setParent(parent) {
|
|
64
|
-
if (this.parent && this.parent !== parent) {
|
|
65
|
-
this.parent.removeChild(this);
|
|
66
|
-
}
|
|
67
|
-
this.parent = parent;
|
|
68
|
-
}
|
|
69
|
-
/** @hidden */
|
|
70
|
-
updateTree() {
|
|
71
|
-
if (this.parent) this.parent.updateTree();
|
|
72
|
-
}
|
|
73
|
-
/** @hidden */
|
|
74
|
-
handleMessage(message) {
|
|
75
|
-
console.log("Component Received Message:", message);
|
|
76
|
-
}
|
|
77
|
-
routeMessage(_idMap, _message) {
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
var EventEmitter = class {
|
|
81
|
-
listeners = /* @__PURE__ */ new Map();
|
|
82
|
-
addListener = (type, listener) => {
|
|
83
|
-
let set = this.listeners.get(type);
|
|
84
|
-
if (!set) {
|
|
85
|
-
set = /* @__PURE__ */ new Set();
|
|
86
|
-
this.listeners.set(type, set);
|
|
87
|
-
}
|
|
88
|
-
set.add(listener);
|
|
89
|
-
};
|
|
90
|
-
removeListener = (type, listener) => {
|
|
91
|
-
this.listeners.get(type)?.delete(listener);
|
|
92
|
-
};
|
|
93
|
-
emit = (type, ...args) => {
|
|
94
|
-
return Promise.all(
|
|
95
|
-
[...this.listeners.get(type) || []].map(
|
|
96
|
-
(l) => new Promise((resolve, reject) => {
|
|
97
|
-
try {
|
|
98
|
-
resolve(l(...args));
|
|
99
|
-
} catch (e) {
|
|
100
|
-
reject(e);
|
|
101
|
-
}
|
|
102
|
-
})
|
|
103
|
-
)
|
|
104
|
-
);
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
7
|
|
|
108
|
-
|
|
109
|
-
var DEFAULT_PROPS = {
|
|
110
|
-
state: "off"
|
|
111
|
-
};
|
|
112
|
-
var Switch = class extends Base {
|
|
113
|
-
/** @hidden */
|
|
114
|
-
events = new EventEmitter();
|
|
115
|
-
constructor(props) {
|
|
116
|
-
super(DEFAULT_PROPS, props);
|
|
117
|
-
}
|
|
118
|
-
addListener = this.events.addListener;
|
|
119
|
-
removeListener = this.events.removeListener;
|
|
120
|
-
/** @hidden */
|
|
121
|
-
getProtoInfo(idMap) {
|
|
122
|
-
return {
|
|
123
|
-
component: "switch",
|
|
124
|
-
key: idMap.getId(this),
|
|
125
|
-
state: this.props.state
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
/** @hidden */
|
|
129
|
-
handleMessage(message) {
|
|
130
|
-
if (message.component === "switch") {
|
|
131
|
-
const state = this.props.state === "on" ? "off" : "on";
|
|
132
|
-
this.updateProps({ state });
|
|
133
|
-
this.events.emit("change", state);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
setValue(state) {
|
|
137
|
-
if (state === this.props.state) return;
|
|
138
|
-
this.updateProps({ state });
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
142
|
-
0 && (module.exports = {
|
|
143
|
-
Switch
|
|
144
|
-
});
|
|
8
|
+
exports.Switch = _chunkDNCHAOYHjs.Switch;
|
|
@@ -1,209 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
19
2
|
|
|
20
|
-
// src/backend/components/tabs.ts
|
|
21
|
-
var tabs_exports = {};
|
|
22
|
-
__export(tabs_exports, {
|
|
23
|
-
Tab: () => Tab,
|
|
24
|
-
Tabs: () => Tabs
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(tabs_exports);
|
|
27
3
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
parent = null;
|
|
32
|
-
/** @hidden */
|
|
33
|
-
defaultProps;
|
|
34
|
-
/** @hidden */
|
|
35
|
-
_props;
|
|
36
|
-
constructor(defaultProps, props) {
|
|
37
|
-
this.defaultProps = defaultProps;
|
|
38
|
-
this._props = Object.freeze({
|
|
39
|
-
...defaultProps,
|
|
40
|
-
...props
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
get props() {
|
|
44
|
-
return this._props;
|
|
45
|
-
}
|
|
46
|
-
set props(props) {
|
|
47
|
-
this.setProps(props);
|
|
48
|
-
}
|
|
49
|
-
setProps = (props) => {
|
|
50
|
-
this._props = Object.freeze({
|
|
51
|
-
...this.defaultProps,
|
|
52
|
-
...props
|
|
53
|
-
});
|
|
54
|
-
this.updateTree();
|
|
55
|
-
};
|
|
56
|
-
updateProps = (updates) => {
|
|
57
|
-
this._props = Object.freeze({
|
|
58
|
-
...this._props,
|
|
59
|
-
...updates
|
|
60
|
-
});
|
|
61
|
-
this.updateTree();
|
|
62
|
-
};
|
|
63
|
-
/** @hidden */
|
|
64
|
-
setParent(parent) {
|
|
65
|
-
if (this.parent && this.parent !== parent) {
|
|
66
|
-
this.parent.removeChild(this);
|
|
67
|
-
}
|
|
68
|
-
this.parent = parent;
|
|
69
|
-
}
|
|
70
|
-
/** @hidden */
|
|
71
|
-
updateTree() {
|
|
72
|
-
if (this.parent) this.parent.updateTree();
|
|
73
|
-
}
|
|
74
|
-
/** @hidden */
|
|
75
|
-
handleMessage(message) {
|
|
76
|
-
console.log("Component Received Message:", message);
|
|
77
|
-
}
|
|
78
|
-
routeMessage(_idMap, _message) {
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
var BaseParent = class extends Base {
|
|
82
|
-
/** @hidden */
|
|
83
|
-
children = [];
|
|
84
|
-
appendChildren = (...children) => {
|
|
85
|
-
for (const c of children) {
|
|
86
|
-
const newChildren = [...this.children.filter((ch) => ch !== c), c];
|
|
87
|
-
this.validateChildren(newChildren);
|
|
88
|
-
this.children = Object.freeze(newChildren);
|
|
89
|
-
c.setParent(this);
|
|
90
|
-
}
|
|
91
|
-
this.updateTree();
|
|
92
|
-
return children;
|
|
93
|
-
};
|
|
94
|
-
appendChild = (child) => {
|
|
95
|
-
this.appendChildren(child);
|
|
96
|
-
return child;
|
|
97
|
-
};
|
|
98
|
-
removeChild = (component) => {
|
|
99
|
-
const match = this.children.findIndex((c) => c === component);
|
|
100
|
-
if (match >= 0) {
|
|
101
|
-
const removingChild = this.children[match];
|
|
102
|
-
const newChildren = [
|
|
103
|
-
...this.children.slice(0, match),
|
|
104
|
-
...this.children.slice(match + 1)
|
|
105
|
-
];
|
|
106
|
-
this.validateChildren(newChildren);
|
|
107
|
-
this.children = Object.freeze(newChildren);
|
|
108
|
-
removingChild?.setParent(null);
|
|
109
|
-
this.updateTree();
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
removeAllChildren = () => {
|
|
113
|
-
this.children.map((c) => c.setParent(null));
|
|
114
|
-
this.children = Object.freeze([]);
|
|
115
|
-
this.updateTree();
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* Return all children components that messages need to be routed to
|
|
119
|
-
*/
|
|
120
|
-
getChildren = () => this.children;
|
|
121
|
-
/**
|
|
122
|
-
* TODO: we can do this better, right now it broadcasts the message to all
|
|
123
|
-
* components of the tree
|
|
124
|
-
*
|
|
125
|
-
* @hidden
|
|
126
|
-
*/
|
|
127
|
-
routeMessage(idMap, message) {
|
|
128
|
-
if (idMap.getId(this) === message.componentKey) {
|
|
129
|
-
this.handleMessage(message);
|
|
130
|
-
} else {
|
|
131
|
-
for (const c of this.children) {
|
|
132
|
-
if (idMap.getId(c) === message.componentKey) {
|
|
133
|
-
c.handleMessage(message);
|
|
134
|
-
} else {
|
|
135
|
-
c.routeMessage(idMap, message);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
insertBefore(child, beforeChild) {
|
|
141
|
-
const filteredChildren = this.children.filter((c) => c !== child);
|
|
142
|
-
let match = filteredChildren.findIndex((c) => c === beforeChild);
|
|
143
|
-
console.log("match", match);
|
|
144
|
-
if (match === -1) {
|
|
145
|
-
match = filteredChildren.length;
|
|
146
|
-
}
|
|
147
|
-
const newChildren = [
|
|
148
|
-
...filteredChildren.slice(0, match),
|
|
149
|
-
child,
|
|
150
|
-
...filteredChildren.slice(match)
|
|
151
|
-
];
|
|
152
|
-
this.validateChildren(newChildren);
|
|
153
|
-
this.children = Object.freeze(newChildren);
|
|
154
|
-
child.setParent(this);
|
|
155
|
-
this.updateTree();
|
|
156
|
-
}
|
|
157
|
-
};
|
|
4
|
+
var _chunkWXSKMMCVjs = require('../../chunk-WXSKMMCV.js');
|
|
5
|
+
require('../../chunk-NZUYU32Z.js');
|
|
6
|
+
require('../../chunk-3RG5ZIWI.js');
|
|
158
7
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (children.length > 1) {
|
|
163
|
-
throw new Error("Tab can only have one child");
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
/** @hidden */
|
|
167
|
-
getProtoInfo = (idMap) => ({
|
|
168
|
-
component: "tab",
|
|
169
|
-
key: idMap.getId(this),
|
|
170
|
-
name: this.props.name,
|
|
171
|
-
child: this.getChildren().slice(0, 1).map((c) => c.getProtoInfo(idMap))[0]
|
|
172
|
-
});
|
|
173
|
-
};
|
|
174
|
-
var Tabs = class extends BaseParent {
|
|
175
|
-
validateChildren = (children) => {
|
|
176
|
-
for (const child of children) {
|
|
177
|
-
if (!(child instanceof Tab)) {
|
|
178
|
-
throw new Error("Tabs can only have Tab children");
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
constructor(props) {
|
|
183
|
-
super({}, { ...props });
|
|
184
|
-
}
|
|
185
|
-
addTabs(...tabs) {
|
|
186
|
-
for (const t of tabs) {
|
|
187
|
-
const tab = new Tab({ name: t.name });
|
|
188
|
-
tab.appendChildren(t.component);
|
|
189
|
-
this.appendChild(tab);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
addTab(name, component) {
|
|
193
|
-
this.addTabs({ name, component });
|
|
194
|
-
return component;
|
|
195
|
-
}
|
|
196
|
-
/** @hidden */
|
|
197
|
-
getProtoInfo(idMap) {
|
|
198
|
-
return {
|
|
199
|
-
component: "tabs",
|
|
200
|
-
key: idMap.getId(this),
|
|
201
|
-
tabs: this.getChildren().map((c) => c.getProtoInfo(idMap))
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
206
|
-
0 && (module.exports = {
|
|
207
|
-
Tab,
|
|
208
|
-
Tabs
|
|
209
|
-
});
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.Tab = _chunkWXSKMMCVjs.Tab; exports.Tabs = _chunkWXSKMMCVjs.Tabs;
|