pixifact 0.1.3

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 (168) hide show
  1. package/README.md +44 -0
  2. package/dist/authoring/ActionRegistry.d.ts +10 -0
  3. package/dist/authoring/ActionRegistry.js +26 -0
  4. package/dist/authoring/ComponentPalette.d.ts +16 -0
  5. package/dist/authoring/ComponentPalette.js +50 -0
  6. package/dist/authoring/DesignToken.d.ts +16 -0
  7. package/dist/authoring/DesignToken.js +33 -0
  8. package/dist/authoring/DiffModel.d.ts +10 -0
  9. package/dist/authoring/DiffModel.js +104 -0
  10. package/dist/authoring/InspectorModel.d.ts +27 -0
  11. package/dist/authoring/InspectorModel.js +139 -0
  12. package/dist/authoring/LogicGraph.d.ts +66 -0
  13. package/dist/authoring/LogicGraph.js +184 -0
  14. package/dist/authoring/OverrideJournal.d.ts +18 -0
  15. package/dist/authoring/OverrideJournal.js +23 -0
  16. package/dist/authoring/PreferenceMemory.d.ts +21 -0
  17. package/dist/authoring/PreferenceMemory.js +39 -0
  18. package/dist/authoring/ProjectConfig.d.ts +20 -0
  19. package/dist/authoring/ProjectConfig.js +78 -0
  20. package/dist/authoring/RuntimePreview.d.ts +11 -0
  21. package/dist/authoring/RuntimePreview.js +25 -0
  22. package/dist/authoring/SceneDocument.d.ts +74 -0
  23. package/dist/authoring/SceneDocument.js +332 -0
  24. package/dist/authoring/SceneProjectState.d.ts +20 -0
  25. package/dist/authoring/SceneProjectState.js +8 -0
  26. package/dist/authoring/SceneSelection.d.ts +11 -0
  27. package/dist/authoring/SceneSelection.js +1 -0
  28. package/dist/authoring/index.d.ts +13 -0
  29. package/dist/authoring/index.js +13 -0
  30. package/dist/commands/Command.d.ts +63 -0
  31. package/dist/commands/Command.js +1 -0
  32. package/dist/commands/CommandStack.d.ts +14 -0
  33. package/dist/commands/CommandStack.js +45 -0
  34. package/dist/commands/applyCommand.d.ts +23 -0
  35. package/dist/commands/applyCommand.js +316 -0
  36. package/dist/commands/index.d.ts +4 -0
  37. package/dist/commands/index.js +4 -0
  38. package/dist/commands/utils.d.ts +17 -0
  39. package/dist/commands/utils.js +77 -0
  40. package/dist/commands/validateCommand.d.ts +12 -0
  41. package/dist/commands/validateCommand.js +285 -0
  42. package/dist/compiler/commands/index.d.ts +109 -0
  43. package/dist/compiler/commands/index.js +492 -0
  44. package/dist/compiler/compileScenes.d.ts +11 -0
  45. package/dist/compiler/compileScenes.js +220 -0
  46. package/dist/compiler/decorators.d.ts +6 -0
  47. package/dist/compiler/decorators.js +79 -0
  48. package/dist/compiler/eventRuntime.d.ts +8 -0
  49. package/dist/compiler/eventRuntime.js +29 -0
  50. package/dist/compiler/index.d.ts +14 -0
  51. package/dist/compiler/index.js +14 -0
  52. package/dist/compiler/pixiNodeSchema.d.ts +39 -0
  53. package/dist/compiler/pixiNodeSchema.js +267 -0
  54. package/dist/compiler/sceneAssetPair.d.ts +11 -0
  55. package/dist/compiler/sceneAssetPair.js +92 -0
  56. package/dist/compiler/scenePartValidation.d.ts +6 -0
  57. package/dist/compiler/scenePartValidation.js +24 -0
  58. package/dist/compiler/sceneRuntime.d.ts +13 -0
  59. package/dist/compiler/sceneRuntime.js +22 -0
  60. package/dist/compiler/sceneValidation.d.ts +48 -0
  61. package/dist/compiler/sceneValidation.js +383 -0
  62. package/dist/compiler/scriptInterfaceExtractor.d.ts +6 -0
  63. package/dist/compiler/scriptInterfaceExtractor.js +258 -0
  64. package/dist/compiler/slotRuntime.d.ts +3 -0
  65. package/dist/compiler/slotRuntime.js +17 -0
  66. package/dist/compiler/spec.d.ts +95 -0
  67. package/dist/compiler/spec.js +1 -0
  68. package/dist/compiler/templateParser.d.ts +2 -0
  69. package/dist/compiler/templateParser.js +302 -0
  70. package/dist/compiler/templateSerializer.d.ts +2 -0
  71. package/dist/compiler/templateSerializer.js +101 -0
  72. package/dist/compiler/typescriptCompiler.d.ts +2 -0
  73. package/dist/compiler/typescriptCompiler.js +494 -0
  74. package/dist/compiler-node/index.d.ts +2 -0
  75. package/dist/compiler-node/index.js +2 -0
  76. package/dist/compiler-node/vite.d.ts +8 -0
  77. package/dist/compiler-node/vite.js +21 -0
  78. package/dist/index.d.ts +6 -0
  79. package/dist/index.js +6 -0
  80. package/dist/nodes/Input.d.ts +91 -0
  81. package/dist/nodes/Input.js +352 -0
  82. package/dist/nodes/Textarea.d.ts +10 -0
  83. package/dist/nodes/Textarea.js +38 -0
  84. package/dist/nodes/components/Button.d.ts +8 -0
  85. package/dist/nodes/components/Button.js +45 -0
  86. package/dist/nodes/components/InputField.d.ts +12 -0
  87. package/dist/nodes/components/InputField.js +53 -0
  88. package/dist/nodes/components/ProgressBar.d.ts +14 -0
  89. package/dist/nodes/components/ProgressBar.js +66 -0
  90. package/dist/nodes/components/ScrollRect.d.ts +23 -0
  91. package/dist/nodes/components/ScrollRect.js +108 -0
  92. package/dist/nodes/components/Selectable.d.ts +32 -0
  93. package/dist/nodes/components/Selectable.js +153 -0
  94. package/dist/nodes/components/index.d.ts +5 -0
  95. package/dist/nodes/components/index.js +5 -0
  96. package/dist/nodes/graphics/Graphic.d.ts +14 -0
  97. package/dist/nodes/graphics/Graphic.js +47 -0
  98. package/dist/nodes/graphics/ImageGraphic.d.ts +9 -0
  99. package/dist/nodes/graphics/ImageGraphic.js +42 -0
  100. package/dist/nodes/graphics/RoundedRectGraphic.d.ts +13 -0
  101. package/dist/nodes/graphics/RoundedRectGraphic.js +65 -0
  102. package/dist/nodes/graphics/TextGraphic.d.ts +13 -0
  103. package/dist/nodes/graphics/TextGraphic.js +70 -0
  104. package/dist/nodes/graphics/index.d.ts +4 -0
  105. package/dist/nodes/graphics/index.js +4 -0
  106. package/dist/nodes/index.d.ts +3 -0
  107. package/dist/nodes/index.js +3 -0
  108. package/dist/runtime/Application.d.ts +15 -0
  109. package/dist/runtime/Application.js +67 -0
  110. package/dist/runtime/GameObject.d.ts +100 -0
  111. package/dist/runtime/GameObject.js +297 -0
  112. package/dist/runtime/GameObjectEvent.d.ts +52 -0
  113. package/dist/runtime/GameObjectEvent.js +38 -0
  114. package/dist/runtime/Transform.d.ts +32 -0
  115. package/dist/runtime/Transform.js +157 -0
  116. package/dist/runtime/component/Component.d.ts +13 -0
  117. package/dist/runtime/component/Component.js +13 -0
  118. package/dist/runtime/component/ComponentRegistry.d.ts +49 -0
  119. package/dist/runtime/component/ComponentRegistry.js +25 -0
  120. package/dist/runtime/component/Flex.d.ts +6 -0
  121. package/dist/runtime/component/Flex.js +15 -0
  122. package/dist/runtime/component/FlexGroup.d.ts +26 -0
  123. package/dist/runtime/component/FlexGroup.js +136 -0
  124. package/dist/runtime/component/GridLayout.d.ts +47 -0
  125. package/dist/runtime/component/GridLayout.js +129 -0
  126. package/dist/runtime/component/Layout.d.ts +104 -0
  127. package/dist/runtime/component/Layout.js +248 -0
  128. package/dist/runtime/component/decorators.d.ts +4 -0
  129. package/dist/runtime/component/decorators.js +52 -0
  130. package/dist/runtime/component/index.d.ts +7 -0
  131. package/dist/runtime/component/index.js +7 -0
  132. package/dist/runtime/graphics/index.d.ts +11 -0
  133. package/dist/runtime/graphics/index.js +29 -0
  134. package/dist/runtime/group/index.d.ts +39 -0
  135. package/dist/runtime/group/index.js +102 -0
  136. package/dist/runtime/image/Image.d.ts +19 -0
  137. package/dist/runtime/image/Image.js +60 -0
  138. package/dist/runtime/image/NineSliceImage.d.ts +23 -0
  139. package/dist/runtime/image/NineSliceImage.js +64 -0
  140. package/dist/runtime/image/index.d.ts +2 -0
  141. package/dist/runtime/image/index.js +2 -0
  142. package/dist/runtime/index.d.ts +9 -0
  143. package/dist/runtime/index.js +9 -0
  144. package/dist/runtime/label/Label.d.ts +11 -0
  145. package/dist/runtime/label/Label.js +26 -0
  146. package/dist/runtime/label/LabelStyle.d.ts +3 -0
  147. package/dist/runtime/label/LabelStyle.js +3 -0
  148. package/dist/runtime/label/index.d.ts +2 -0
  149. package/dist/runtime/label/index.js +2 -0
  150. package/dist/runtime/utils/index.d.ts +1 -0
  151. package/dist/runtime/utils/index.js +1 -0
  152. package/dist/runtime/utils/onlyOnceQueueMicrotask.d.ts +1 -0
  153. package/dist/runtime/utils/onlyOnceQueueMicrotask.js +12 -0
  154. package/dist/runtime/utils/setProps.d.ts +10 -0
  155. package/dist/runtime/utils/setProps.js +17 -0
  156. package/dist/scene/dsl.d.ts +25 -0
  157. package/dist/scene/dsl.js +112 -0
  158. package/dist/scene/index.d.ts +5 -0
  159. package/dist/scene/index.js +5 -0
  160. package/dist/scene/instantiate.d.ts +8 -0
  161. package/dist/scene/instantiate.js +208 -0
  162. package/dist/scene/nodesDsl.d.ts +42 -0
  163. package/dist/scene/nodesDsl.js +169 -0
  164. package/dist/scene/spec.d.ts +100 -0
  165. package/dist/scene/spec.js +1 -0
  166. package/dist/scene/templates.d.ts +21 -0
  167. package/dist/scene/templates.js +239 -0
  168. package/package.json +90 -0
@@ -0,0 +1,91 @@
1
+ import type { FederatedPointerEvent } from "pixi.js";
2
+ import { Graphics, Group, Label, LabelStyle } from "../runtime/index.js";
3
+ export declare class Input extends Group {
4
+ /**
5
+ * 背景样式
6
+ */
7
+ graphics: Graphics;
8
+ /**
9
+ * 使用html标签进行输入处理
10
+ */
11
+ element: HTMLTextAreaElement | HTMLInputElement;
12
+ /**
13
+ * 输入框失去焦点时显示的内容
14
+ */
15
+ valueLabel: Label;
16
+ /**
17
+ * HTML 输入元素对齐的 canvas。默认取文档中的第一个 canvas。
18
+ */
19
+ canvas?: Element;
20
+ private _mask;
21
+ private _value;
22
+ private _destroyed;
23
+ private _isFocused;
24
+ private _textColor;
25
+ private _focusedBorderColor;
26
+ private _blurredBorderColor;
27
+ private readonly _globalTransform;
28
+ protected _isUpdateTransform: boolean;
29
+ set width(val: number);
30
+ get width(): number;
31
+ set height(val: number);
32
+ get height(): number;
33
+ /**
34
+ * 更新mask,条件:1、padding改变 2、宽高改变
35
+ */
36
+ protected updateMask(): void;
37
+ protected _isUpdateElementSize: boolean;
38
+ protected updateElementSize(): void;
39
+ protected updateElementLineHeight(): void;
40
+ protected updateHitArea(): void;
41
+ /**
42
+ * 更新2d变换,位置,缩放,斜切,旋转
43
+ */
44
+ updateTransform(): void;
45
+ private getCanvasOffset;
46
+ private getCanvasView;
47
+ protected _isResize: boolean;
48
+ /**
49
+ * 更新大小
50
+ */
51
+ resize(): void;
52
+ protected createElement(): void;
53
+ render(): void;
54
+ update(): void;
55
+ private handleViewportChange;
56
+ private handleTransformChange;
57
+ private _stokeStyle;
58
+ private _backgroundColor;
59
+ set backgroundColor(val: number);
60
+ set borderColor(val: number);
61
+ set borderSize(val: number);
62
+ protected _labelStyle: LabelStyle;
63
+ set fontFamily(val: string | string[]);
64
+ get fontFamily(): string | string[];
65
+ set fontSize(val: number);
66
+ get fontSize(): number;
67
+ private _isDrawStyle;
68
+ /**
69
+ * 绘制背景样式
70
+ */
71
+ drawStyle(): void;
72
+ protected _padding: number[];
73
+ protected get contentWidth(): number;
74
+ protected get contentHeight(): number;
75
+ set paddingLeft(val: number);
76
+ get paddingLeft(): number;
77
+ set paddingRight(val: number);
78
+ get paddingRight(): number;
79
+ set paddingTop(val: number);
80
+ get paddingTop(): number;
81
+ set paddingBottom(val: number);
82
+ get paddingBottom(): number;
83
+ get value(): string;
84
+ set value(val: string);
85
+ private onFocus;
86
+ focus(event?: FederatedPointerEvent): void;
87
+ private onInput;
88
+ private onBlur;
89
+ blur(): void;
90
+ onDestroy(): void;
91
+ }
@@ -0,0 +1,352 @@
1
+ import { Matrix, Rectangle, Graphics as PIXIGraphics } from "pixi.js";
2
+ import { GameObject, Graphics, Group, Label, LabelStyle } from "../runtime/index.js";
3
+ export class Input extends Group {
4
+ /**
5
+ * 背景样式
6
+ */
7
+ graphics;
8
+ /**
9
+ * 使用html标签进行输入处理
10
+ */
11
+ element;
12
+ /**
13
+ * 输入框失去焦点时显示的内容
14
+ */
15
+ valueLabel;
16
+ /**
17
+ * HTML 输入元素对齐的 canvas。默认取文档中的第一个 canvas。
18
+ */
19
+ canvas;
20
+ _mask;
21
+ _value = '';
22
+ _destroyed = false;
23
+ _isFocused = false;
24
+ _textColor = '#23272a';
25
+ _focusedBorderColor = 0x0000ff;
26
+ _blurredBorderColor = 0x828282;
27
+ _globalTransform = new Matrix();
28
+ _isUpdateTransform = false;
29
+ set width(val) {
30
+ super.width = val;
31
+ this._isResize = true;
32
+ }
33
+ get width() {
34
+ return super.width;
35
+ }
36
+ set height(val) {
37
+ super.height = val;
38
+ this._isResize = true;
39
+ }
40
+ get height() {
41
+ return super.height;
42
+ }
43
+ /**
44
+ * 更新mask,条件:1、padding改变 2、宽高改变
45
+ */
46
+ updateMask() {
47
+ if (!this._mask) {
48
+ return;
49
+ }
50
+ this._mask.x = this.paddingLeft;
51
+ this._mask.y = this.paddingTop;
52
+ this._mask.width = this.contentWidth;
53
+ this._mask.height = this.contentHeight;
54
+ }
55
+ _isUpdateElementSize = false;
56
+ updateElementSize() {
57
+ this._isUpdateElementSize = false;
58
+ this.element.style.width = this.width + 'px';
59
+ this.element.style.height = this.height + 'px';
60
+ this.element.style.padding = this._padding.map((value) => value + 'px').join(' ');
61
+ this.element.style.borderWidth = '0';
62
+ this.element.style.fontSize = this.fontSize + 'px';
63
+ this.updateElementLineHeight();
64
+ this.updateMask();
65
+ }
66
+ updateElementLineHeight() {
67
+ this.element.style.lineHeight = this.contentHeight + 'px';
68
+ }
69
+ updateHitArea() {
70
+ this.display.hitArea = new Rectangle(0, 0, this.width, this.height);
71
+ }
72
+ /**
73
+ * 更新2d变换,位置,缩放,斜切,旋转
74
+ */
75
+ updateTransform() {
76
+ const { a, b, c, d, tx, ty } = this.display.getGlobalTransform(this._globalTransform);
77
+ const offset = this.getCanvasOffset();
78
+ this.element.style.transform = `matrix(${a}, ${b}, ${c}, ${d}, ${tx + offset.x}, ${ty + offset.y})`;
79
+ this.element.style.transformOrigin = `${this.anchorX * 100}% ${this.anchorY * 100}%`;
80
+ this.element.style.opacity = String(this.display.alpha);
81
+ this._isUpdateTransform = false;
82
+ this.updateMask();
83
+ }
84
+ getCanvasOffset() {
85
+ const view = this.getCanvasView();
86
+ if (!view) {
87
+ return { x: 0, y: 0 };
88
+ }
89
+ const rect = view.getBoundingClientRect();
90
+ return { x: rect.left, y: rect.top };
91
+ }
92
+ getCanvasView() {
93
+ return this.canvas ?? document.querySelector('canvas') ?? undefined;
94
+ }
95
+ _isResize = false;
96
+ /**
97
+ * 更新大小
98
+ */
99
+ resize() {
100
+ this._isResize = false;
101
+ this._isUpdateElementSize = true;
102
+ this._isUpdateTransform = true;
103
+ this.updateHitArea();
104
+ this.valueLabel.x = this.paddingLeft;
105
+ this.valueLabel.y = this.paddingTop;
106
+ this._labelStyle.lineHeight = this.contentHeight;
107
+ this.updateMask();
108
+ }
109
+ createElement() {
110
+ const element = document.createElement('input');
111
+ element.type = 'text';
112
+ this.element = element;
113
+ }
114
+ render() {
115
+ const mask = new PIXIGraphics();
116
+ mask.rect(0, 0, 100, 50);
117
+ mask.fill(0x0000ff);
118
+ this.display.addChild(mask);
119
+ this._mask = mask;
120
+ this.createElement();
121
+ this.element.className = 'textarea';
122
+ this.element.style.boxSizing = 'border-box';
123
+ this.element.style.position = 'fixed';
124
+ this.element.style.left = '0';
125
+ this.element.style.top = '0';
126
+ this.element.style.zIndex = '10';
127
+ this.element.style.margin = '0';
128
+ this.element.style.borderStyle = 'solid';
129
+ this.element.style.borderRadius = '0';
130
+ this.element.style.display = 'none';
131
+ this.element.style.color = 'transparent';
132
+ this.element.style.background = 'transparent';
133
+ this.element.style.caretColor = this._textColor;
134
+ this.element.style.outline = 'none';
135
+ this.element.style.padding = '0 6px';
136
+ this.element.style.fontFamily = Array.isArray(this._labelStyle.fontFamily)
137
+ ? this._labelStyle.fontFamily.join(',')
138
+ : this._labelStyle.fontFamily;
139
+ this.element.style.fontSize = this._labelStyle.fontSize + 'px';
140
+ this.element.onfocus = this.onFocus.bind(this);
141
+ this.element.onblur = this.onBlur.bind(this);
142
+ this.element.oninput = this.onInput.bind(this);
143
+ this.fontFamily = this._labelStyle.fontFamily;
144
+ this.fontSize = this._labelStyle.fontSize;
145
+ window.document.body.append(this.element);
146
+ this.graphics = GameObject.instantiate(Graphics, this);
147
+ this.valueLabel = GameObject.instantiate(Label, this, {
148
+ style: this._labelStyle,
149
+ x: this.paddingLeft
150
+ });
151
+ this.valueLabel.display.mask = mask;
152
+ this.value = this._value;
153
+ this.display.eventMode = 'static';
154
+ this.display.interactiveChildren = false;
155
+ this.display.cursor = 'text';
156
+ this.display.on('pointerdown', this.focus, this);
157
+ this.display.once('destroyed', this.onDestroy, this);
158
+ this.emitter.on(GameObject.Event.TRANSFORM_CHANGE, this.handleTransformChange, this);
159
+ window.addEventListener('resize', this.handleViewportChange);
160
+ window.addEventListener('scroll', this.handleViewportChange, true);
161
+ this._isResize = true;
162
+ this._isDrawStyle = true;
163
+ this._isUpdateElementSize = true;
164
+ this._isUpdateTransform = true;
165
+ }
166
+ update() {
167
+ if (this._isResize) {
168
+ this.resize();
169
+ }
170
+ if (this._isDrawStyle) {
171
+ this.drawStyle();
172
+ }
173
+ if (this._isUpdateElementSize) {
174
+ this.updateElementSize();
175
+ }
176
+ if (this._isUpdateTransform || this.element.style.display !== 'none') {
177
+ this.updateTransform();
178
+ }
179
+ }
180
+ handleViewportChange = () => {
181
+ this._isUpdateTransform = true;
182
+ };
183
+ handleTransformChange = () => {
184
+ this._isUpdateTransform = true;
185
+ };
186
+ _stokeStyle = { width: 1, color: this._blurredBorderColor };
187
+ _backgroundColor = 0xffffff;
188
+ set backgroundColor(val) {
189
+ this._backgroundColor = val;
190
+ this._isDrawStyle = true;
191
+ }
192
+ set borderColor(val) {
193
+ this._stokeStyle.color = val;
194
+ this._isDrawStyle = true;
195
+ }
196
+ set borderSize(val) {
197
+ this._stokeStyle.width = val;
198
+ this._isDrawStyle = true;
199
+ }
200
+ _labelStyle = new LabelStyle({
201
+ fontSize: 16,
202
+ lineHeight: 16
203
+ });
204
+ set fontFamily(val) {
205
+ this._labelStyle.fontFamily = val;
206
+ if (this.element) {
207
+ this.element.style.fontFamily = Array.isArray(val) ? val.join(',') : val;
208
+ }
209
+ }
210
+ get fontFamily() {
211
+ return this._labelStyle.fontFamily;
212
+ }
213
+ set fontSize(val) {
214
+ this._labelStyle.fontSize = val;
215
+ if (this.element) {
216
+ this.element.style.fontSize = val + 'px';
217
+ }
218
+ this._isUpdateElementSize = true;
219
+ this._isUpdateTransform = true;
220
+ }
221
+ get fontSize() {
222
+ return this._labelStyle.fontSize;
223
+ }
224
+ _isDrawStyle = true;
225
+ /**
226
+ * 绘制背景样式
227
+ */
228
+ drawStyle() {
229
+ this._isDrawStyle = false;
230
+ this.graphics.clear();
231
+ this.graphics.rect(0, 0, this.width, this.height);
232
+ this.graphics.fill(this._backgroundColor);
233
+ this.graphics.stroke(this._stokeStyle);
234
+ }
235
+ _padding = [0, 6, 0, 6];
236
+ get contentWidth() {
237
+ return Math.max(0, this.width - this.paddingLeft - this.paddingRight);
238
+ }
239
+ get contentHeight() {
240
+ return Math.max(0, this.height - this.paddingTop - this.paddingBottom);
241
+ }
242
+ set paddingLeft(val) {
243
+ this._padding[3] = val;
244
+ this._isResize = true;
245
+ this._isUpdateElementSize = true;
246
+ }
247
+ get paddingLeft() {
248
+ return this._padding[3];
249
+ }
250
+ set paddingRight(val) {
251
+ this._padding[1] = val;
252
+ this._isResize = true;
253
+ this._isUpdateElementSize = true;
254
+ }
255
+ get paddingRight() {
256
+ return this._padding[1];
257
+ }
258
+ set paddingTop(val) {
259
+ this._padding[0] = val;
260
+ this._isResize = true;
261
+ this._isUpdateElementSize = true;
262
+ }
263
+ get paddingTop() {
264
+ return this._padding[0];
265
+ }
266
+ set paddingBottom(val) {
267
+ this._padding[2] = val;
268
+ this._isResize = true;
269
+ this._isUpdateElementSize = true;
270
+ }
271
+ get paddingBottom() {
272
+ return this._padding[2];
273
+ }
274
+ get value() {
275
+ return this._value;
276
+ }
277
+ set value(val) {
278
+ this._value = val;
279
+ if (this.element && this.element.value !== val) {
280
+ this.element.value = val;
281
+ }
282
+ if (this.valueLabel) {
283
+ this.valueLabel.value = val;
284
+ }
285
+ }
286
+ onFocus() {
287
+ this._isFocused = true;
288
+ this.valueLabel.display.visible = false;
289
+ this.element.style.color = this._textColor;
290
+ this.borderColor = this._focusedBorderColor;
291
+ this.borderSize = 2;
292
+ this.emitter.emit('focus');
293
+ }
294
+ focus(event) {
295
+ if (event?.pointerType !== 'touch') {
296
+ event?.preventDefault();
297
+ }
298
+ event?.stopPropagation();
299
+ if (this._isResize) {
300
+ this.resize();
301
+ }
302
+ if (this._isDrawStyle) {
303
+ this.drawStyle();
304
+ }
305
+ if (this._isUpdateElementSize) {
306
+ this.updateElementSize();
307
+ }
308
+ this.updateTransform();
309
+ this.element.style.display = 'block';
310
+ if (!this._destroyed && this.element.isConnected) {
311
+ this.element.focus();
312
+ }
313
+ }
314
+ onInput() {
315
+ this._value = this.element.value;
316
+ }
317
+ onBlur() {
318
+ if (!this._isFocused && this.element.style.display === 'none') {
319
+ return;
320
+ }
321
+ this._isFocused = false;
322
+ this.value = this.element.value;
323
+ this.borderColor = this._blurredBorderColor;
324
+ this.borderSize = 1;
325
+ this.element.style.color = 'transparent';
326
+ this.element.style.display = 'none';
327
+ this.valueLabel.display.visible = true;
328
+ this.emitter.emit('blur');
329
+ }
330
+ blur() {
331
+ this.element.blur();
332
+ if (this._isFocused || this.element.style.display !== 'none') {
333
+ this.onBlur();
334
+ }
335
+ }
336
+ onDestroy() {
337
+ if (this._destroyed) {
338
+ return;
339
+ }
340
+ this._destroyed = true;
341
+ this.display.off('pointerdown', this.focus, this);
342
+ this.emitter.off(GameObject.Event.TRANSFORM_CHANGE, this.handleTransformChange, this);
343
+ window.removeEventListener('resize', this.handleViewportChange);
344
+ window.removeEventListener('scroll', this.handleViewportChange, true);
345
+ if (this.element) {
346
+ this.element.onfocus = null;
347
+ this.element.onblur = null;
348
+ this.element.oninput = null;
349
+ this.element.remove();
350
+ }
351
+ }
352
+ }
@@ -0,0 +1,10 @@
1
+ import { Input } from "./Input.js";
2
+ export declare class Textarea extends Input {
3
+ set lineHeight(val: number);
4
+ get lineHeight(): number;
5
+ protected updateElementLineHeight(): void;
6
+ protected _padding: number[];
7
+ protected createElement(): void;
8
+ render(): void;
9
+ resize(): void;
10
+ }
@@ -0,0 +1,38 @@
1
+ import { Input } from "./Input.js";
2
+ export class Textarea extends Input {
3
+ set lineHeight(val) {
4
+ this._labelStyle.lineHeight = val;
5
+ if (this.element) {
6
+ this.element.style.lineHeight = val + 'px';
7
+ }
8
+ this._isUpdateElementSize = true;
9
+ }
10
+ get lineHeight() {
11
+ return this._labelStyle.lineHeight;
12
+ }
13
+ updateElementLineHeight() {
14
+ this.element.style.lineHeight = this._labelStyle.lineHeight + 'px';
15
+ }
16
+ _padding = [6, 6, 6, 6];
17
+ createElement() {
18
+ this.element = document.createElement('textarea');
19
+ this.element.style.resize = 'none';
20
+ this.element.style.overflow = 'hidden';
21
+ }
22
+ render() {
23
+ super.render();
24
+ this.lineHeight = this._labelStyle.lineHeight;
25
+ this._labelStyle.wordWrap = true;
26
+ this._labelStyle.breakWords = true;
27
+ }
28
+ resize() {
29
+ this._isResize = false;
30
+ this._isUpdateElementSize = true;
31
+ this._isUpdateTransform = true;
32
+ this.updateHitArea();
33
+ this.valueLabel.x = this.paddingLeft;
34
+ this.valueLabel.y = this.paddingTop;
35
+ this._labelStyle.wordWrapWidth = this.contentWidth;
36
+ this.updateMask();
37
+ }
38
+ }
@@ -0,0 +1,8 @@
1
+ import type { FederatedPointerEvent } from "pixi.js";
2
+ import { Selectable } from "./Selectable.js";
3
+ export declare class Button extends Selectable {
4
+ onClick?: string | ((event: FederatedPointerEvent) => void);
5
+ awake(): void;
6
+ private handlePointerTap;
7
+ onDestroy(): void;
8
+ }
@@ -0,0 +1,45 @@
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
+ import { ComponentMeta, Prop } from "../../runtime/index.js";
8
+ import { Selectable } from "./Selectable.js";
9
+ let Button = class Button extends Selectable {
10
+ onClick;
11
+ awake() {
12
+ super.awake();
13
+ this.gameObject.display.on('pointertap', this.handlePointerTap, this);
14
+ }
15
+ handlePointerTap(event) {
16
+ if (!this.interactable) {
17
+ return;
18
+ }
19
+ if (typeof this.onClick === 'function') {
20
+ this.onClick(event);
21
+ }
22
+ this.gameObject.emitter.emit('tap', event);
23
+ }
24
+ onDestroy() {
25
+ this.gameObject.display.off('pointertap', this.handlePointerTap, this);
26
+ super.onDestroy();
27
+ }
28
+ };
29
+ __decorate([
30
+ Prop({
31
+ type: 'event',
32
+ description: 'Action invoked when the button receives a pointer tap.',
33
+ })
34
+ ], Button.prototype, "onClick", void 0);
35
+ Button = __decorate([
36
+ ComponentMeta({
37
+ type: 'ui.Button',
38
+ displayName: 'Button',
39
+ category: 'UI/Interaction',
40
+ icon: 'mouse-pointer',
41
+ description: 'Handles pointer interaction and invokes an action when clicked.',
42
+ disallowMultiple: true,
43
+ })
44
+ ], Button);
45
+ export { Button };
@@ -0,0 +1,12 @@
1
+ import { Component } from "../../runtime/index.js";
2
+ import type { Group } from "../../runtime/index.js";
3
+ import type { TextGraphic } from "../graphics/index.js";
4
+ export declare class InputField extends Component<Group> {
5
+ value: string;
6
+ placeholder: string;
7
+ multiline: boolean;
8
+ textGraphic?: TextGraphic;
9
+ awake(): void;
10
+ setValue(value: string): void;
11
+ applyText(): void;
12
+ }
@@ -0,0 +1,53 @@
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
+ import { Component, ComponentMeta, Prop } from "../../runtime/index.js";
8
+ let InputField = class InputField extends Component {
9
+ value = '';
10
+ placeholder = '';
11
+ multiline = false;
12
+ textGraphic;
13
+ awake() {
14
+ this.applyText();
15
+ }
16
+ setValue(value) {
17
+ this.value = value;
18
+ this.applyText();
19
+ }
20
+ applyText() {
21
+ if (!this.textGraphic) {
22
+ return;
23
+ }
24
+ this.textGraphic.text = this.value || this.placeholder;
25
+ this.textGraphic.setDirty();
26
+ }
27
+ };
28
+ __decorate([
29
+ Prop({ type: 'string', default: '' })
30
+ ], InputField.prototype, "value", void 0);
31
+ __decorate([
32
+ Prop({ type: 'string', default: '' })
33
+ ], InputField.prototype, "placeholder", void 0);
34
+ __decorate([
35
+ Prop({ type: 'boolean', default: false })
36
+ ], InputField.prototype, "multiline", void 0);
37
+ __decorate([
38
+ Prop({
39
+ type: 'componentRef',
40
+ component: 'ui.TextGraphic',
41
+ description: 'Text graphic used to display the current value or placeholder.',
42
+ })
43
+ ], InputField.prototype, "textGraphic", void 0);
44
+ InputField = __decorate([
45
+ ComponentMeta({
46
+ type: 'ui.InputField',
47
+ displayName: 'Input Field',
48
+ category: 'UI/Input',
49
+ description: 'Stores editable text state and can drive text graphic placeholders.',
50
+ disallowMultiple: true,
51
+ })
52
+ ], InputField);
53
+ export { InputField };
@@ -0,0 +1,14 @@
1
+ import { Component } from "../../runtime/index.js";
2
+ import type { Group } from "../../runtime/index.js";
3
+ import type { RoundedRectGraphic } from "../graphics/index.js";
4
+ export declare class ProgressBar extends Component<Group> {
5
+ value: number;
6
+ min: number;
7
+ max: number;
8
+ fillNode?: Group;
9
+ fillGraphic?: RoundedRectGraphic;
10
+ awake(): void;
11
+ setValue(value: number): void;
12
+ applyValue: () => void;
13
+ onDestroy(): void;
14
+ }
@@ -0,0 +1,66 @@
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
+ import { Component, ComponentMeta, GameObject, Prop } from "../../runtime/index.js";
8
+ let ProgressBar = class ProgressBar extends Component {
9
+ value = 0;
10
+ min = 0;
11
+ max = 1;
12
+ fillNode;
13
+ fillGraphic;
14
+ awake() {
15
+ this.gameObject.emitter.on(GameObject.Event.RESIZE, this.applyValue, this);
16
+ this.applyValue();
17
+ }
18
+ setValue(value) {
19
+ this.value = value;
20
+ this.applyValue();
21
+ }
22
+ applyValue = () => {
23
+ const range = this.max - this.min;
24
+ const normalized = range === 0 ? 0 : Math.min(1, Math.max(0, (this.value - this.min) / range));
25
+ if (this.fillNode) {
26
+ this.fillNode.width = this.gameObject.width * normalized;
27
+ this.fillNode.height = this.gameObject.height;
28
+ }
29
+ this.fillGraphic?.setDirty();
30
+ };
31
+ onDestroy() {
32
+ this.gameObject.emitter.off(GameObject.Event.RESIZE, this.applyValue, this);
33
+ }
34
+ };
35
+ __decorate([
36
+ Prop({ type: 'number', default: 0, min: 0, max: 1 })
37
+ ], ProgressBar.prototype, "value", void 0);
38
+ __decorate([
39
+ Prop({ type: 'number', default: 0 })
40
+ ], ProgressBar.prototype, "min", void 0);
41
+ __decorate([
42
+ Prop({ type: 'number', default: 1 })
43
+ ], ProgressBar.prototype, "max", void 0);
44
+ __decorate([
45
+ Prop({
46
+ type: 'nodeRef',
47
+ description: 'Node resized horizontally to represent the current value.',
48
+ })
49
+ ], ProgressBar.prototype, "fillNode", void 0);
50
+ __decorate([
51
+ Prop({
52
+ type: 'componentRef',
53
+ component: 'ui.Graphic',
54
+ description: 'Optional fill graphic redrawn when value changes.',
55
+ })
56
+ ], ProgressBar.prototype, "fillGraphic", void 0);
57
+ ProgressBar = __decorate([
58
+ ComponentMeta({
59
+ type: 'ui.ProgressBar',
60
+ displayName: 'Progress Bar',
61
+ category: 'UI/Display',
62
+ description: 'Controls a fill node or graphic based on a normalized value.',
63
+ disallowMultiple: true,
64
+ })
65
+ ], ProgressBar);
66
+ export { ProgressBar };