@arcanejs/toolkit 0.0.2 → 0.1.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.
Files changed (59) hide show
  1. package/dist/backend/components/base.d.mts +2 -0
  2. package/dist/backend/components/base.d.ts +2 -0
  3. package/dist/backend/components/base.js +189 -0
  4. package/dist/backend/components/base.mjs +10 -0
  5. package/dist/backend/components/button.d.mts +30 -0
  6. package/dist/backend/components/button.d.ts +30 -0
  7. package/dist/backend/components/button.js +168 -0
  8. package/dist/backend/components/button.mjs +7 -0
  9. package/dist/backend/components/group.d.mts +51 -0
  10. package/dist/backend/components/group.d.ts +51 -0
  11. package/dist/backend/components/group.js +287 -0
  12. package/dist/backend/components/group.mjs +9 -0
  13. package/dist/backend/components/label.d.mts +21 -0
  14. package/dist/backend/components/label.d.ts +21 -0
  15. package/dist/backend/components/label.js +105 -0
  16. package/dist/backend/components/label.mjs +7 -0
  17. package/dist/backend/components/rect.d.mts +20 -0
  18. package/dist/backend/components/rect.d.ts +20 -0
  19. package/dist/backend/components/rect.js +105 -0
  20. package/dist/backend/components/rect.mjs +7 -0
  21. package/dist/backend/components/slider-button.d.mts +31 -0
  22. package/dist/backend/components/slider-button.d.ts +31 -0
  23. package/dist/backend/components/slider-button.js +161 -0
  24. package/dist/backend/components/slider-button.mjs +7 -0
  25. package/dist/backend/components/switch.d.mts +24 -0
  26. package/dist/backend/components/switch.d.ts +24 -0
  27. package/dist/backend/components/switch.js +144 -0
  28. package/dist/backend/components/switch.mjs +7 -0
  29. package/dist/backend/components/tabs.d.mts +28 -0
  30. package/dist/backend/components/tabs.d.ts +28 -0
  31. package/dist/backend/components/tabs.js +209 -0
  32. package/dist/backend/components/tabs.mjs +9 -0
  33. package/dist/backend/components/text-input.d.mts +26 -0
  34. package/dist/backend/components/text-input.d.ts +26 -0
  35. package/dist/backend/components/text-input.js +146 -0
  36. package/dist/backend/components/text-input.mjs +7 -0
  37. package/dist/backend/components/timeline.d.mts +17 -0
  38. package/dist/backend/components/timeline.d.ts +17 -0
  39. package/dist/backend/components/timeline.js +109 -0
  40. package/dist/backend/components/timeline.mjs +7 -0
  41. package/dist/base-BJAPu0O1.d.mts +234 -0
  42. package/dist/base-BJAPu0O1.d.ts +234 -0
  43. package/dist/chunk-37VNFO5S.mjs +42 -0
  44. package/dist/chunk-3ZBM7Q4A.mjs +55 -0
  45. package/dist/chunk-6LL3X7ZZ.mjs +44 -0
  46. package/dist/chunk-DBW4OPGN.mjs +33 -0
  47. package/dist/chunk-DP3QFYSS.mjs +66 -0
  48. package/dist/chunk-GQZA5K4M.mjs +29 -0
  49. package/dist/chunk-HF77PS7J.mjs +171 -0
  50. package/dist/chunk-HVFTRNLQ.mjs +59 -0
  51. package/dist/chunk-P6X5GIDT.mjs +29 -0
  52. package/dist/chunk-S5DQIYC2.mjs +107 -0
  53. package/dist/frontend.js +26321 -0
  54. package/dist/frontend.js.map +7 -0
  55. package/dist/index.d.mts +75 -1
  56. package/dist/index.d.ts +75 -1
  57. package/dist/index.js +852 -1
  58. package/dist/index.mjs +288 -2
  59. package/package.json +86 -6
@@ -0,0 +1,161 @@
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);
19
+
20
+ // src/backend/components/slider-button.ts
21
+ var slider_button_exports = {};
22
+ __export(slider_button_exports, {
23
+ SliderButton: () => SliderButton
24
+ });
25
+ module.exports = __toCommonJS(slider_button_exports);
26
+
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
+
108
+ // src/backend/components/slider-button.ts
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
+ });
@@ -0,0 +1,7 @@
1
+ import {
2
+ SliderButton
3
+ } from "../../chunk-HVFTRNLQ.mjs";
4
+ import "../../chunk-HF77PS7J.mjs";
5
+ export {
6
+ SliderButton
7
+ };
@@ -0,0 +1,24 @@
1
+ import { e as Base, L as Listenable, I as IDMap, g as Component, d as ClientComponentMessage } from '../../base-BJAPu0O1.mjs';
2
+ import '@arcanejs/diff';
3
+
4
+ type Events = {
5
+ change: (state: 'on' | 'off') => void | Promise<void>;
6
+ };
7
+ type InternalProps = {
8
+ state: 'on' | 'off';
9
+ };
10
+ type Props = Partial<InternalProps>;
11
+ declare class Switch extends Base<InternalProps> implements Listenable<Events> {
12
+ /** @hidden */
13
+ private readonly events;
14
+ constructor(props?: Props);
15
+ addListener: <T extends "change">(type: T, listener: Events[T]) => void;
16
+ removeListener: <T extends "change">(type: T, listener: Events[T]) => void;
17
+ /** @hidden */
18
+ getProtoInfo(idMap: IDMap): Component;
19
+ /** @hidden */
20
+ handleMessage(message: ClientComponentMessage): void;
21
+ setValue(state: 'on' | 'off'): void;
22
+ }
23
+
24
+ export { type Events, type Props, Switch };
@@ -0,0 +1,24 @@
1
+ import { e as Base, L as Listenable, I as IDMap, g as Component, d as ClientComponentMessage } from '../../base-BJAPu0O1.js';
2
+ import '@arcanejs/diff';
3
+
4
+ type Events = {
5
+ change: (state: 'on' | 'off') => void | Promise<void>;
6
+ };
7
+ type InternalProps = {
8
+ state: 'on' | 'off';
9
+ };
10
+ type Props = Partial<InternalProps>;
11
+ declare class Switch extends Base<InternalProps> implements Listenable<Events> {
12
+ /** @hidden */
13
+ private readonly events;
14
+ constructor(props?: Props);
15
+ addListener: <T extends "change">(type: T, listener: Events[T]) => void;
16
+ removeListener: <T extends "change">(type: T, listener: Events[T]) => void;
17
+ /** @hidden */
18
+ getProtoInfo(idMap: IDMap): Component;
19
+ /** @hidden */
20
+ handleMessage(message: ClientComponentMessage): void;
21
+ setValue(state: 'on' | 'off'): void;
22
+ }
23
+
24
+ export { type Events, type Props, Switch };
@@ -0,0 +1,144 @@
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);
19
+
20
+ // src/backend/components/switch.ts
21
+ var switch_exports = {};
22
+ __export(switch_exports, {
23
+ Switch: () => Switch
24
+ });
25
+ module.exports = __toCommonJS(switch_exports);
26
+
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
+
108
+ // src/backend/components/switch.ts
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
+ });
@@ -0,0 +1,7 @@
1
+ import {
2
+ Switch
3
+ } from "../../chunk-37VNFO5S.mjs";
4
+ import "../../chunk-HF77PS7J.mjs";
5
+ export {
6
+ Switch
7
+ };
@@ -0,0 +1,28 @@
1
+ import { B as BaseParent, a as Component, I as IDMap, T as TabComponent, i as TabsComponent } from '../../base-BJAPu0O1.mjs';
2
+ import '@arcanejs/diff';
3
+
4
+ type TabDefinition = {
5
+ name: string;
6
+ component: Component;
7
+ };
8
+ type InternalTabProps = {
9
+ name: string;
10
+ };
11
+ type TabProps = InternalTabProps;
12
+ declare class Tab extends BaseParent<InternalTabProps> {
13
+ validateChildren: (children: Component[]) => void;
14
+ /** @hidden */
15
+ getProtoInfo: (idMap: IDMap) => TabComponent;
16
+ }
17
+ type InternalTabsProps = Record<never, never>;
18
+ type TabsProps = InternalTabsProps;
19
+ declare class Tabs extends BaseParent<InternalTabsProps> {
20
+ validateChildren: (children: Component[]) => void;
21
+ constructor(props?: TabsProps);
22
+ addTabs(...tabs: TabDefinition[]): void;
23
+ addTab<C extends Component>(name: string, component: C): C;
24
+ /** @hidden */
25
+ getProtoInfo(idMap: IDMap): TabsComponent;
26
+ }
27
+
28
+ export { Tab, type TabProps, Tabs, type TabsProps };
@@ -0,0 +1,28 @@
1
+ import { B as BaseParent, a as Component, I as IDMap, T as TabComponent, i as TabsComponent } from '../../base-BJAPu0O1.js';
2
+ import '@arcanejs/diff';
3
+
4
+ type TabDefinition = {
5
+ name: string;
6
+ component: Component;
7
+ };
8
+ type InternalTabProps = {
9
+ name: string;
10
+ };
11
+ type TabProps = InternalTabProps;
12
+ declare class Tab extends BaseParent<InternalTabProps> {
13
+ validateChildren: (children: Component[]) => void;
14
+ /** @hidden */
15
+ getProtoInfo: (idMap: IDMap) => TabComponent;
16
+ }
17
+ type InternalTabsProps = Record<never, never>;
18
+ type TabsProps = InternalTabsProps;
19
+ declare class Tabs extends BaseParent<InternalTabsProps> {
20
+ validateChildren: (children: Component[]) => void;
21
+ constructor(props?: TabsProps);
22
+ addTabs(...tabs: TabDefinition[]): void;
23
+ addTab<C extends Component>(name: string, component: C): C;
24
+ /** @hidden */
25
+ getProtoInfo(idMap: IDMap): TabsComponent;
26
+ }
27
+
28
+ export { Tab, type TabProps, Tabs, type TabsProps };
@@ -0,0 +1,209 @@
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);
19
+
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
+
28
+ // src/backend/components/base.ts
29
+ var Base = class {
30
+ /** @hidden */
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
+ };
158
+
159
+ // src/backend/components/tabs.ts
160
+ var Tab = class extends BaseParent {
161
+ validateChildren = (children) => {
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
+ });
@@ -0,0 +1,9 @@
1
+ import {
2
+ Tab,
3
+ Tabs
4
+ } from "../../chunk-3ZBM7Q4A.mjs";
5
+ import "../../chunk-HF77PS7J.mjs";
6
+ export {
7
+ Tab,
8
+ Tabs
9
+ };
@@ -0,0 +1,26 @@
1
+ import { e as Base, L as Listenable, I as IDMap, g as Component, d as ClientComponentMessage } from '../../base-BJAPu0O1.mjs';
2
+ import '@arcanejs/diff';
3
+
4
+ type Events = {
5
+ change: (value: string) => void | Promise<void>;
6
+ };
7
+ type InternalProps = {
8
+ value: string | null;
9
+ };
10
+ type Props = Partial<InternalProps>;
11
+ declare class TextInput extends Base<InternalProps> implements Listenable<Events> {
12
+ /** @hidden */
13
+ private readonly events;
14
+ constructor(props?: Props);
15
+ addListener: <T extends "change">(type: T, listener: Events[T]) => void;
16
+ removeListener: <T extends "change">(type: T, listener: Events[T]) => void;
17
+ /** @hidden */
18
+ getProtoInfo: (idMap: IDMap) => Component;
19
+ /** @hidden */
20
+ handleMessage: (message: ClientComponentMessage) => void;
21
+ getValue: () => string | null;
22
+ getValidatedValue: <T>(validator: (text: string) => T) => null | T;
23
+ setValue: (value: string) => void;
24
+ }
25
+
26
+ export { type Events, type Props, TextInput };
@@ -0,0 +1,26 @@
1
+ import { e as Base, L as Listenable, I as IDMap, g as Component, d as ClientComponentMessage } from '../../base-BJAPu0O1.js';
2
+ import '@arcanejs/diff';
3
+
4
+ type Events = {
5
+ change: (value: string) => void | Promise<void>;
6
+ };
7
+ type InternalProps = {
8
+ value: string | null;
9
+ };
10
+ type Props = Partial<InternalProps>;
11
+ declare class TextInput extends Base<InternalProps> implements Listenable<Events> {
12
+ /** @hidden */
13
+ private readonly events;
14
+ constructor(props?: Props);
15
+ addListener: <T extends "change">(type: T, listener: Events[T]) => void;
16
+ removeListener: <T extends "change">(type: T, listener: Events[T]) => void;
17
+ /** @hidden */
18
+ getProtoInfo: (idMap: IDMap) => Component;
19
+ /** @hidden */
20
+ handleMessage: (message: ClientComponentMessage) => void;
21
+ getValue: () => string | null;
22
+ getValidatedValue: <T>(validator: (text: string) => T) => null | T;
23
+ setValue: (value: string) => void;
24
+ }
25
+
26
+ export { type Events, type Props, TextInput };