@eva/plugin-ui 2.1.0-beta.1 → 2.1.0-beta.11

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.
@@ -21,6 +21,15 @@ export declare interface CheckBoxParams {
21
21
  checked?: ViewRef;
22
22
  unchecked?: ViewRef;
23
23
  };
24
+ textStyle?: {
25
+ fontFamily?: string;
26
+ fontSize?: number;
27
+ fill?: string | number;
28
+ };
29
+ textOffset?: {
30
+ x?: number;
31
+ y?: number;
32
+ };
24
33
  disabledStyle?: CheckBoxStateStyle;
25
34
  }
26
35
 
@@ -30,7 +39,7 @@ export declare interface CheckBoxStateStyle {
30
39
  }
31
40
 
32
41
  /** 圆形样式 */
33
- export declare interface CircleStyle extends UIStyle {
42
+ export declare interface CircleStyle extends ShapeStyle {
34
43
  x?: number;
35
44
  y?: number;
36
45
  radius: number;
@@ -48,7 +57,13 @@ export declare interface CircularProgressBarParams {
48
57
  fillColor?: number | string;
49
58
  backgroundAlpha?: number;
50
59
  fillAlpha?: number;
60
+ cap?: 'round' | 'butt' | 'square';
51
61
  bindToStore?: string;
62
+ rotation?: number;
63
+ offset?: {
64
+ x?: number;
65
+ y?: number;
66
+ };
52
67
  }
53
68
 
54
69
  export declare const COMPONENT_DEFINITIONS: Record<string, ComponentDefinition>;
@@ -74,6 +89,8 @@ export declare interface ComponentDefinition<TParams = any, TInstance = any> {
74
89
  signalMap?: (component: TParams & Record<string, any>) => Record<string, true | ((...args: any[]) => Record<string, any>)>;
75
90
  /** CHANGE 事件触发,把字段写回 PIXI 实例 */
76
91
  syncOnChange?: (instance: TInstance, component: TParams & Record<string, any>) => void;
92
+ /** Transform.size -> @pixi/ui 实例尺寸同步。未提供时由 UISystem 使用通用 setSize/width/height 策略。 */
93
+ applySize?: (instance: TInstance, size: UiRenderSize, component: TParams & Record<string, any>, context: UiSizeSyncContext) => void;
77
94
  /** ADD 完成后跑(Dialog 挂 content / MaskedFrame 挂 border)*/
78
95
  onAttachedExtra?: (instance: TInstance, component: TParams & Record<string, any>, go: any, game: any) => void;
79
96
  /** 实例方法 mixin(注入到 wrapper class.prototype) */
@@ -84,6 +101,51 @@ export declare function defineUiComponent<TParams = any, TInstance = any>(def: C
84
101
 
85
102
  export declare const Dialog: UiComponentClass<DialogParams>;
86
103
 
104
+ declare interface DialogButtonParams {
105
+ kind?: 'button' | 'fancy';
106
+ text?: string;
107
+ value?: string | number;
108
+ closeOnPress?: boolean;
109
+ reopenDelay?: number;
110
+ width?: number;
111
+ height?: number;
112
+ radius?: number;
113
+ color?: number | string;
114
+ hoverColor?: number | string;
115
+ pressedColor?: number | string;
116
+ disabledColor?: number | string;
117
+ defaultView?: string;
118
+ hoverView?: string;
119
+ pressedView?: string;
120
+ disabledView?: string;
121
+ nineSliceSprite?: [number, number, number, number];
122
+ textStyle?: {
123
+ fontFamily?: string;
124
+ fontSize?: number;
125
+ fill?: string | number;
126
+ fontWeight?: string;
127
+ };
128
+ disabled?: boolean;
129
+ animations?: unknown;
130
+ }
131
+
132
+ declare interface DialogCheckBoxParams {
133
+ text?: string;
134
+ size?: number;
135
+ radius?: number;
136
+ checked?: boolean;
137
+ uncheckedColor?: number | string;
138
+ checkedColor?: number | string;
139
+ strokeColor?: number | string;
140
+ strokeWidth?: number;
141
+ textStyle?: {
142
+ fontFamily?: string;
143
+ fontSize?: number;
144
+ fill?: string | number;
145
+ fontWeight?: string;
146
+ };
147
+ }
148
+
87
149
  export declare interface DialogParams {
88
150
  open?: boolean;
89
151
  title?: string;
@@ -98,6 +160,50 @@ export declare interface DialogParams {
98
160
  contentChildName?: string;
99
161
  nineSliceSprite?: [number, number, number, number];
100
162
  bindToStore?: string;
163
+ titleStyle?: {
164
+ fontFamily?: string;
165
+ fontSize?: number;
166
+ fill?: string | number;
167
+ fontWeight?: string;
168
+ lineHeight?: number;
169
+ dropShadow?: unknown;
170
+ };
171
+ content?: string;
172
+ contentStyle?: {
173
+ fontFamily?: string;
174
+ fontSize?: number;
175
+ fill?: string | number;
176
+ fontWeight?: string;
177
+ align?: 'left' | 'center' | 'right';
178
+ wordWrap?: boolean;
179
+ wordWrapWidth?: number;
180
+ lineHeight?: number;
181
+ dropShadow?: unknown;
182
+ };
183
+ contentButtons?: DialogButtonParams[];
184
+ contentCheckBoxes?: DialogCheckBoxParams[];
185
+ buttons?: DialogButtonParams[];
186
+ buttonList?: {
187
+ elementsMargin?: number;
188
+ type?: ListType;
189
+ padding?: number;
190
+ };
191
+ buttonListOffset?: {
192
+ x?: number;
193
+ y?: number;
194
+ };
195
+ scrollBox?: Partial<ScrollBoxParams> & {
196
+ type?: ListType;
197
+ offset?: {
198
+ x?: number;
199
+ y?: number;
200
+ };
201
+ size?: {
202
+ width?: number;
203
+ height?: number;
204
+ };
205
+ };
206
+ animations?: unknown;
101
207
  }
102
208
 
103
209
  export declare const DoubleSlider: UiComponentClass<DoubleSliderParams>;
@@ -116,12 +222,28 @@ export declare interface DoubleSliderParams {
116
222
  slider1?: ViewRef;
117
223
  slider2?: ViewRef;
118
224
  };
225
+ nineSliceSprite?: {
226
+ bg?: [number, number, number, number];
227
+ fill?: [number, number, number, number];
228
+ };
229
+ fillPaddings?: ProgressBarFillPaddings;
230
+ valueTextStyle?: {
231
+ fontFamily?: string;
232
+ fontSize?: number;
233
+ fill?: string | number;
234
+ };
235
+ valueTextOffset?: {
236
+ x?: number;
237
+ y?: number;
238
+ };
239
+ width?: number;
240
+ height?: number;
119
241
  bindToStore1?: string;
120
242
  bindToStore2?: string;
121
243
  }
122
244
 
123
245
  /** 椭圆样式 */
124
- export declare interface EllipseStyle extends UIStyle {
246
+ export declare interface EllipseStyle extends ShapeStyle {
125
247
  x?: number;
126
248
  y?: number;
127
249
  width: number;
@@ -159,9 +281,44 @@ export declare interface FancyButtonParams {
159
281
  views?: FancyButtonViewRefs;
160
282
  offset?: FancyButtonOffset;
161
283
  textOffset?: FancyButtonOffset;
284
+ iconOffset?: FancyButtonOffset;
162
285
  padding?: number;
163
286
  nineSliceSprite?: [number, number, number, number];
164
287
  selectedTint?: string;
288
+ textStyle?: {
289
+ fontFamily?: string;
290
+ fontSize?: number;
291
+ fill?: string | number;
292
+ fontWeight?: string;
293
+ dropShadow?: unknown;
294
+ };
295
+ textClass?: 'text' | 'html' | 'bitmap';
296
+ bitmapFontName?: string;
297
+ defaultTextScale?: {
298
+ x?: number;
299
+ y?: number;
300
+ } | number;
301
+ defaultIconScale?: {
302
+ x?: number;
303
+ y?: number;
304
+ } | number;
305
+ defaultTextAnchor?: {
306
+ x?: number;
307
+ y?: number;
308
+ } | number;
309
+ defaultIconAnchor?: {
310
+ x?: number;
311
+ y?: number;
312
+ } | number;
313
+ anchor?: number;
314
+ anchorX?: number;
315
+ anchorY?: number;
316
+ scale?: number;
317
+ animations?: unknown;
318
+ contentFittingMode?: 'default' | 'fill' | 'none';
319
+ ignoreRefitting?: boolean;
320
+ width?: number;
321
+ height?: number;
165
322
  }
166
323
 
167
324
  export declare type FancyButtonState = 'default' | 'hover' | 'pressed' | 'disabled' | 'selected';
@@ -171,6 +328,7 @@ export declare interface FancyButtonViewRefs {
171
328
  hover?: ViewRef;
172
329
  pressed?: ViewRef;
173
330
  disabled?: ViewRef;
331
+ icon?: ViewRef;
174
332
  }
175
333
 
176
334
  export declare type FieldKind = 'scalar' | 'shallowMerge' | 'arrayCopy' | 'tuple' | 'opaque';
@@ -188,6 +346,8 @@ export declare interface FieldSpec {
188
346
  export declare interface InlineShape {
189
347
  type: 'rect' | 'roundedRect' | 'circle' | 'ellipse';
190
348
  style: {
349
+ x?: number;
350
+ y?: number;
191
351
  width?: number;
192
352
  height?: number;
193
353
  radius?: number;
@@ -214,6 +374,8 @@ export declare interface InputParams {
214
374
  cleanOnFocus?: boolean;
215
375
  addMask?: boolean;
216
376
  bindToStore?: string;
377
+ width?: number;
378
+ height?: number;
217
379
  }
218
380
 
219
381
  export declare interface InputStyle {
@@ -276,6 +438,8 @@ export declare interface MaskedFrameParams {
276
438
  targetView?: ViewRef;
277
439
  maskView?: ViewRef;
278
440
  borderView?: ViewRef;
441
+ borderWidth?: number;
442
+ borderColor?: number | string;
279
443
  }
280
444
 
281
445
  /**
@@ -287,12 +451,20 @@ export declare class PixiUiComponent<TParams = any> extends Component<TParams> {
287
451
  /** runtime 计数,供 spec / debug 验证(toggleCount / pressCount / hoverCount / ...)*/
288
452
  toggleCount: number;
289
453
  pressCount: number;
454
+ downCount: number;
455
+ upCount: number;
290
456
  hoverCount: number;
457
+ outCount: number;
458
+ upOutCount: number;
291
459
  changeCount: number;
292
460
  updateCount: number;
293
461
  selectCount: number;
462
+ lastSignal: string;
463
+ visualState: string;
294
464
  /** Input 私有 focused */
295
465
  focused: boolean;
466
+ /** DSL/constructor 中显式传入过的字段,用于区分 metadata default 与用户配置。 */
467
+ __evaExplicitFields: Set<string>;
296
468
  /** 由 factory 通过 metadata 注入的动态字段(views / value / checked / ...)*/
297
469
  [key: string]: any;
298
470
  init(p?: TParams): void;
@@ -321,6 +493,8 @@ export declare interface ProgressBarParams {
321
493
  };
322
494
  fillPaddings?: ProgressBarFillPaddings;
323
495
  bindToStore?: string;
496
+ width?: number;
497
+ height?: number;
324
498
  }
325
499
 
326
500
  export declare class RadioGroup extends Component<RadioGroupParams> {
@@ -350,7 +524,7 @@ export declare interface RadioGroupParams {
350
524
  }
351
525
 
352
526
  /** 矩形样式 */
353
- export declare interface RectStyle extends UIStyle {
527
+ export declare interface RectStyle extends ShapeStyle {
354
528
  x?: number;
355
529
  y?: number;
356
530
  width: number;
@@ -367,7 +541,7 @@ export declare interface ResolvedViews {
367
541
  }
368
542
 
369
543
  /** 圆角矩形样式 */
370
- export declare interface RoundedRectStyle extends UIStyle {
544
+ export declare interface RoundedRectStyle extends ShapeStyle {
371
545
  x?: number;
372
546
  y?: number;
373
547
  width: number;
@@ -388,6 +562,16 @@ export declare interface ScrollBoxParams {
388
562
  disableDynamicRendering?: boolean;
389
563
  disableEasing?: boolean;
390
564
  padding?: number;
565
+ vertPadding?: number;
566
+ horPadding?: number;
567
+ topPadding?: number;
568
+ bottomPadding?: number;
569
+ leftPadding?: number;
570
+ rightPadding?: number;
571
+ globalScroll?: boolean;
572
+ shiftScroll?: boolean;
573
+ proximityRange?: number;
574
+ proximityDebounce?: number;
391
575
  inertia?: boolean;
392
576
  inertiaDecay?: number;
393
577
  bounceFactor?: number;
@@ -415,47 +599,36 @@ export declare interface SelectParams {
415
599
  };
416
600
  nineSliceSprite?: [number, number, number, number];
417
601
  bindToStore?: string;
418
- }
419
-
420
- export declare const Slider: UiComponentClass<SliderParams>;
421
-
422
- export declare type SliderOrientation = 'horizontal' | 'vertical';
423
-
424
- export declare interface SliderParams {
425
- enabled?: boolean;
426
- value?: number;
427
- min?: number;
428
- max?: number;
429
- step?: number;
430
- orientation?: SliderOrientation;
431
- showValue?: boolean;
432
- views?: {
433
- bg?: ViewRef;
434
- fill?: ViewRef;
435
- thumb?: ViewRef;
602
+ width?: number;
603
+ height?: number;
604
+ radius?: number;
605
+ visibleItems?: number;
606
+ itemWidth?: number;
607
+ itemHeight?: number;
608
+ itemBackgroundColor?: number | string;
609
+ itemHoverColor?: number | string;
610
+ selectedTextOffset?: {
611
+ x?: number;
612
+ y?: number;
436
613
  };
437
- bindToStore?: string;
438
- }
439
-
440
- export declare const Switcher: UiComponentClass<SwitcherParams>;
441
-
442
- export declare interface SwitcherParams {
443
- active?: number;
444
- views?: ViewRef[];
445
- triggerEvent?: SwitcherTriggerEvent;
446
- bindToStore?: string;
614
+ scrollBox?: Partial<ScrollBoxParams> & {
615
+ offset?: {
616
+ x?: number;
617
+ y?: number;
618
+ };
619
+ };
620
+ textClass?: 'text' | 'html';
621
+ open?: boolean;
447
622
  }
448
623
 
449
- export declare type SwitcherTriggerEvent = 'onPress' | 'onDown' | 'onUp' | 'onHover' | 'onOut';
450
-
451
624
  /**
452
- * UI 组件
625
+ * Shape 组件
453
626
  *
454
627
  * 基于 `@eva/plugin-renderer-graphics` 实现 rect/circle/ellipse/roundedRect 的
455
628
  * 矢量绘制,支持纯色 / linear-gradient 填充与描边。`shapes` 数组允许在同一个
456
629
  * GameObject 上层叠多个形状。
457
630
  */
458
- export declare class UI extends Component<UIParams> {
631
+ declare class Shape extends Component<ShapeParams> {
459
632
  /** 组件名称 */
460
633
  static componentName: string;
461
634
  /** 实例侧 componentName,DSL 序列化时使用 */
@@ -463,7 +636,7 @@ export declare class UI extends Component<UIParams> {
463
636
  private shapes;
464
637
  /** 编辑器 Inspector 元数据,主仓 ComponentInspector 通过静态方法读取 */
465
638
  static getInspectorMetadata(): InspectorFieldMetadata;
466
- init(params?: UIParams): void;
639
+ init(params?: ShapeParams): void;
467
640
  awake(): void;
468
641
  start(): void;
469
642
  /**
@@ -493,17 +666,17 @@ export declare class UI extends Component<UIParams> {
493
666
  private drawEllipse;
494
667
  private drawRoundedRect;
495
668
  /** 追加一个形状 */
496
- addShape(type: UIShapeType, style: RectStyle | CircleStyle | EllipseStyle | RoundedRectStyle): void;
669
+ addShape(type: ShapeType, style: RectStyle | CircleStyle | EllipseStyle | RoundedRectStyle): void;
497
670
  /** 清除所有形状 */
498
671
  clearShapes(): void;
499
672
  /** 更新指定索引的形状 */
500
- updateShape(index: number, type: UIShapeType, style: RectStyle | CircleStyle | EllipseStyle | RoundedRectStyle): void;
673
+ updateShape(index: number, type: ShapeType, style: RectStyle | CircleStyle | EllipseStyle | RoundedRectStyle): void;
501
674
  /** 移除指定索引的形状 */
502
675
  removeShape(index: number): void;
503
676
  /** 获取形状数量 */
504
677
  getShapeCount(): number;
505
678
  /** 获取指定索引的形状(只读视图) */
506
- getShape(index: number): UIShape | null;
679
+ getShape(index: number): ShapeDefinition | null;
507
680
  /** 设置所有形状的透明度 */
508
681
  setAlpha(alpha: number): void;
509
682
  /** 设置所有形状的填充色 */
@@ -511,37 +684,26 @@ export declare class UI extends Component<UIParams> {
511
684
  /** 设置所有形状的描边 */
512
685
  setStroke(stroke: string, lineWidth?: number): void;
513
686
  }
514
-
515
- declare type UiComponentClass<TParams = any> = new () => PixiUiComponent<TParams>;
516
-
517
- /** 兼容别名:历史代码中沿用的 UIComponentParams */
518
- export declare type UIComponentParams = UIParams;
519
-
520
- /** UI 组件参数接口 */
521
- export declare interface UIParams {
522
- componentName?: string;
523
- shapes?: UIShape[];
524
- /** 单形状简化用法:type + style */
525
- type?: UIShapeType;
526
- style?: RectStyle | CircleStyle | EllipseStyle | RoundedRectStyle;
527
- }
687
+ export { Shape }
688
+ export { Shape as UI }
528
689
 
529
690
  /** 单个 shape 描述 */
530
- export declare interface UIShape {
531
- type: UIShapeType;
691
+ export declare interface ShapeDefinition {
692
+ type: ShapeType;
532
693
  style: RectStyle | CircleStyle | EllipseStyle | RoundedRectStyle;
533
694
  }
534
695
 
535
- /** UI 形状类型枚举 */
536
- export declare enum UIShapeType {
537
- RECT = "rect",
538
- CIRCLE = "circle",
539
- ELLIPSE = "ellipse",
540
- ROUNDED_RECT = "roundedRect"
696
+ /** Shape component params */
697
+ export declare interface ShapeParams {
698
+ componentName?: string;
699
+ shapes?: ShapeDefinition[];
700
+ /** 单形状简化用法:type + style */
701
+ type?: ShapeType;
702
+ style?: RectStyle | CircleStyle | EllipseStyle | RoundedRectStyle;
541
703
  }
542
704
 
543
- /** UI 基础样式 */
544
- export declare interface UIStyle {
705
+ /** Shape base style */
706
+ export declare interface ShapeStyle {
545
707
  /** 填充颜色,支持 #RRGGBB / rgb()/rgba() / linear-gradient(...) */
546
708
  fill?: string;
547
709
  /** 描边颜色 */
@@ -552,18 +714,102 @@ export declare interface UIStyle {
552
714
  alpha?: number;
553
715
  }
554
716
 
717
+ /** Shape primitive type enum */
718
+ export declare enum ShapeType {
719
+ RECT = "rect",
720
+ CIRCLE = "circle",
721
+ ELLIPSE = "ellipse",
722
+ ROUNDED_RECT = "roundedRect"
723
+ }
724
+
725
+ export declare const Slider: UiComponentClass<SliderParams>;
726
+
727
+ export declare type SliderOrientation = 'horizontal' | 'vertical';
728
+
729
+ export declare interface SliderParams {
730
+ enabled?: boolean;
731
+ value?: number;
732
+ min?: number;
733
+ max?: number;
734
+ step?: number;
735
+ orientation?: SliderOrientation;
736
+ showValue?: boolean;
737
+ views?: {
738
+ bg?: ViewRef;
739
+ fill?: ViewRef;
740
+ thumb?: ViewRef;
741
+ };
742
+ nineSliceSprite?: {
743
+ bg?: [number, number, number, number];
744
+ fill?: [number, number, number, number];
745
+ };
746
+ fillPaddings?: ProgressBarFillPaddings;
747
+ valueTextStyle?: {
748
+ fontFamily?: string;
749
+ fontSize?: number;
750
+ fill?: string | number;
751
+ };
752
+ valueTextOffset?: {
753
+ x?: number;
754
+ y?: number;
755
+ };
756
+ width?: number;
757
+ height?: number;
758
+ bindToStore?: string;
759
+ }
760
+
761
+ export declare const Switcher: UiComponentClass<SwitcherParams>;
762
+
763
+ export declare interface SwitcherParams {
764
+ active?: number;
765
+ views?: ViewRef[];
766
+ triggerEvent?: SwitcherTriggerEvent | SwitcherTriggerEvent[];
767
+ bindToStore?: string;
768
+ }
769
+
770
+ export declare type SwitcherTriggerEvent = 'onPress' | 'onDown' | 'onUp' | 'onHover' | 'onOut' | 'onUpOut';
771
+
772
+ declare type UiComponentClass<TParams = any> = new () => PixiUiComponent<TParams>;
773
+
774
+ export declare type UIComponentParams = ShapeParams;
775
+
776
+ /** Backward-compatible aliases kept for existing TS imports. */
777
+ export declare type UIParams = ShapeParams;
778
+
779
+ declare interface UiRenderSize {
780
+ width?: number;
781
+ height?: number;
782
+ }
783
+
784
+ export declare type UIShape = ShapeDefinition;
785
+
786
+ /** Backward-compatible enum value alias for existing TypeScript consumers. */
787
+ export declare const UIShapeType: typeof ShapeType;
788
+
789
+ export declare type UIShapeType = ShapeType;
790
+
791
+ declare interface UiSizeSyncContext {
792
+ componentName: string;
793
+ component?: Record<string, any>;
794
+ gameObject?: any;
795
+ source: 'initial-transform' | 'transform-change' | 'component-change';
796
+ }
797
+
798
+ export declare type UIStyle = ShapeStyle;
799
+
555
800
  declare class UISystem extends System {
556
801
  static systemName: string;
557
802
  name: string;
558
803
  /** componentName -> instance map(generic 共享一份) */
559
804
  private instances;
560
805
  private signalCleanups;
806
+ private transformSizeAuthorities;
561
807
  /** 给 RadioGroup 反查 PixiCheckBox 实例用 */
562
808
  private get checkBoxInstances();
563
809
  private radioGroupInstances;
564
810
  update(_e?: any): void;
565
811
  componentChanged(changed: ComponentChanged): void;
566
- private handleUI;
812
+ private handleShape;
567
813
  private handleGeneric;
568
814
  private attachGeneric;
569
815
  private detachGeneric;
@@ -571,6 +817,9 @@ declare class UISystem extends System {
571
817
  private attachRadioGroup;
572
818
  private getInstanceMap;
573
819
  private gameRef;
820
+ private handleTransformSizeChanged;
821
+ private relayoutLayoutInstances;
822
+ private applyTransientTransformSize;
574
823
  }
575
824
  export { UISystem as PluginUiSystem }
576
825
  export { UISystem }
@@ -581,7 +830,7 @@ export { UISystem }
581
830
  * - { entityName: "background" } — 引用同 GameObject 的子 entity 的 PIXI.Container,
582
831
  * 这个 child entity 必须先 ADD,然后我们把它的 Container "借走" 交给 @pixi/ui 实例。
583
832
  * 原 child entity 仍然存在(Transform/逻辑组件还在),只是 PIXI 显示对象被重新 parent。
584
- * - { ui: { type, style } } — 内联 UI shape,生成一个新的 PIXI.Graphics(临时,与 plugin-ui-graphics 不同源)
833
+ * - { shape: { type, style } } — 内联 shape,生成一个新的 PIXI.Graphics(临时,与 Shape 组件不同源)
585
834
  * - { texture: "loading.png" } — 从已加载的 Eva 资源池查 texture,生成 PIXI.Sprite
586
835
  * - { color: 0xRRGGBB, width, height } — 生成纯色矩形 Graphics
587
836
  * - { fallback: <ViewRef> } — 当主 ref 解析失败时使用
@@ -589,6 +838,9 @@ export { UISystem }
589
838
  export declare type ViewRef = {
590
839
  entityName: string;
591
840
  fallback?: ViewRef;
841
+ } | {
842
+ shape: InlineShape;
843
+ fallback?: ViewRef;
592
844
  } | {
593
845
  ui: InlineShape;
594
846
  fallback?: ViewRef;