@rb-games/core 0.1.3 → 0.1.4

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/ui/index.js CHANGED
@@ -2,7 +2,7 @@ import { Align, Flow } from '../chunk-FOZO6TLY.js';
2
2
  import { getNestedValue } from '../chunk-5BLUF2HG.js';
3
3
  import { require_lodash } from '../chunk-NAQG7TMS.js';
4
4
  import { __commonJS, __toESM } from '../chunk-G3PMV62Z.js';
5
- import { Rectangle, Color, Texture, Sprite, Graphics, Container, Text, ColorMatrixFilter, Assets } from 'pixi.js';
5
+ import { Rectangle, Color, Texture, Sprite, Graphics, Container, Text, Assets, ColorMatrixFilter } from 'pixi.js';
6
6
 
7
7
  // ../../node_modules/eventemitter3/index.js
8
8
  var require_eventemitter3 = __commonJS({
@@ -170,34 +170,25 @@ var import_index = __toESM(require_eventemitter3(), 1);
170
170
 
171
171
  // ui/behaviors/ButtonBehavior.ts
172
172
  var ButtonBehavior = class _ButtonBehavior extends import_index.default {
173
- _view = null;
174
- _enabled = true;
175
- _isPressed = false;
176
- _isHolding = false;
177
- _pointerDownOnThis = false;
178
- _isOver = false;
179
- // 👈 isOver added
180
- _holdTimer = null;
181
- _holdInterval = null;
182
- _holdDelay;
183
- _holdIntervalTime;
184
- _cursor = "pointer";
185
- // Toggle properties
186
- _isToggle = false;
187
- _selected = false;
188
- _allowHoldWhenToggle = false;
189
- _holdMode;
190
- // Track if events are bound to current view
191
- _eventsBound = false;
192
- // Static factory methods
193
- static withView(view, options = {}) {
194
- const button = new _ButtonBehavior(options);
195
- button.attachView(view);
196
- return button;
197
- }
198
173
  // Method overloads - now only takes options
199
174
  constructor(options = {}) {
200
175
  super();
176
+ this._view = null;
177
+ this._enabled = true;
178
+ this._isPressed = false;
179
+ this._isHolding = false;
180
+ this._pointerDownOnThis = false;
181
+ this._isOver = false;
182
+ // 👈 isOver added
183
+ this._holdTimer = null;
184
+ this._holdInterval = null;
185
+ this._cursor = "pointer";
186
+ // Toggle properties
187
+ this._isToggle = false;
188
+ this._selected = false;
189
+ this._allowHoldWhenToggle = false;
190
+ // Track if events are bound to current view
191
+ this._eventsBound = false;
201
192
  this._holdDelay = options.holdDelay || 500;
202
193
  this._holdIntervalTime = options.holdInterval || 100;
203
194
  this._holdMode = options.holdMode ?? "none";
@@ -209,6 +200,12 @@ var ButtonBehavior = class _ButtonBehavior extends import_index.default {
209
200
  this.attachView(options.view);
210
201
  }
211
202
  }
203
+ // Static factory methods
204
+ static withView(view, options = {}) {
205
+ const button = new _ButtonBehavior(options);
206
+ button.attachView(view);
207
+ return button;
208
+ }
212
209
  // View Management Methods
213
210
  attachView(view) {
214
211
  if (this._view === view) return;
@@ -553,45 +550,26 @@ var ButtonBehavior = class _ButtonBehavior extends import_index.default {
553
550
  }
554
551
  };
555
552
  var ScrollbarBehavior = class _ScrollbarBehavior extends import_index.default {
556
- _trackView = null;
557
- _knobView = null;
558
- _enabled = true;
559
- _isDragging = false;
560
- _dragStartPosition = 0;
561
- _dragStartValue = 0;
562
- _dragOffset = 0;
563
- // Configuration
564
- _orientation;
565
- _min;
566
- _max;
567
- _value;
568
- _step;
569
- _margin;
570
- // Wheel options
571
- _wheelStep;
572
- _enableWheel;
573
- // Cursor options
574
- _trackCursor;
575
- _knobCursor;
576
- // Track if events are bound
577
- _eventsBound = false;
578
- // Arrow function event handlers for proper cleanup
579
- _onTrackPointerDown = (event) => this._handleTrackPointerDown(event);
580
- _onKnobPointerDown = (event) => this._handleKnobPointerDown(event);
581
- _onKnobPointerUp = (event) => this._handleKnobPointerUp(event);
582
- _onKnobPointerUpOutside = (event) => this._handleKnobPointerUp(event);
583
- _onGlobalPointerMove = (event) => this._handleGlobalPointerMove(event);
584
- _onTrackWheel = (event) => this._handleWheel(event);
585
- _onKnobWheel = (event) => this._handleWheel(event);
586
- // Static factory methods
587
- static withViews(trackView, knobView, options = {}) {
588
- const scrollbar = new _ScrollbarBehavior(options);
589
- scrollbar.attachViews(trackView, knobView);
590
- return scrollbar;
591
- }
592
553
  constructor(options = {}) {
593
554
  var _a, _b;
594
555
  super();
556
+ this._trackView = null;
557
+ this._knobView = null;
558
+ this._enabled = true;
559
+ this._isDragging = false;
560
+ this._dragStartPosition = 0;
561
+ this._dragStartValue = 0;
562
+ this._dragOffset = 0;
563
+ // Track if events are bound
564
+ this._eventsBound = false;
565
+ // Arrow function event handlers for proper cleanup
566
+ this._onTrackPointerDown = (event) => this._handleTrackPointerDown(event);
567
+ this._onKnobPointerDown = (event) => this._handleKnobPointerDown(event);
568
+ this._onKnobPointerUp = (event) => this._handleKnobPointerUp(event);
569
+ this._onKnobPointerUpOutside = (event) => this._handleKnobPointerUp(event);
570
+ this._onGlobalPointerMove = (event) => this._handleGlobalPointerMove(event);
571
+ this._onTrackWheel = (event) => this._handleWheel(event);
572
+ this._onKnobWheel = (event) => this._handleWheel(event);
595
573
  this._orientation = options.orientation || "horizontal";
596
574
  this._margin = {
597
575
  start: ((_a = options.margin) == null ? void 0 : _a.start) || 0,
@@ -606,6 +584,12 @@ var ScrollbarBehavior = class _ScrollbarBehavior extends import_index.default {
606
584
  this._trackCursor = options.trackCursor || "pointer";
607
585
  this._knobCursor = options.knobCursor || "grab";
608
586
  }
587
+ // Static factory methods
588
+ static withViews(trackView, knobView, options = {}) {
589
+ const scrollbar = new _ScrollbarBehavior(options);
590
+ scrollbar.attachViews(trackView, knobView);
591
+ return scrollbar;
592
+ }
609
593
  // View Management Methods
610
594
  attachTrackView(trackView) {
611
595
  if (this._trackView === trackView) return;
@@ -1041,12 +1025,12 @@ var ScrollbarBehavior = class _ScrollbarBehavior extends import_index.default {
1041
1025
 
1042
1026
  // ui/behaviors/InputBehavior.ts
1043
1027
  var InputBehavior = class extends import_index.default {
1044
- _domInput;
1045
- _state;
1046
- _options;
1047
- _view = null;
1048
1028
  constructor(options = {}) {
1049
1029
  super();
1030
+ this._view = null;
1031
+ this._onViewPointerDown = () => {
1032
+ this.activateView();
1033
+ };
1050
1034
  this._options = options;
1051
1035
  const guid = "input-" + Math.random().toString(36).slice(2, 11);
1052
1036
  if (options.multiline) {
@@ -1111,9 +1095,6 @@ var InputBehavior = class extends import_index.default {
1111
1095
  this._view.on("pointerdown", this._onViewPointerDown);
1112
1096
  this.updateDomPosition();
1113
1097
  }
1114
- _onViewPointerDown = () => {
1115
- this.activateView();
1116
- };
1117
1098
  detachView() {
1118
1099
  if (this._view) {
1119
1100
  this._view.off("pointerdown", this._onViewPointerDown);
@@ -1182,16 +1163,24 @@ var import_lodash2 = __toESM(require_lodash(), 1);
1182
1163
  var import_lodash = __toESM(require_lodash(), 1);
1183
1164
  var SKIN = Symbol("skinData");
1184
1165
  function Skinable(Base) {
1185
- class SkinableClass extends Base {
1186
- [SKIN] = null;
1187
- // Optional hook implementable by subclasses
1188
- skinApply;
1166
+ var _a, _b;
1167
+ class SkinableClass extends (_b = Base, _a = SKIN, _b) {
1168
+ constructor() {
1169
+ super(...arguments);
1170
+ this[_a] = null;
1171
+ }
1172
+ /**
1173
+ * Prototype hook for subclasses. Must be a method, not a class field:
1174
+ * `skinApply?: (...) => void` is compiled to `this.skinApply = undefined`,
1175
+ * which shadows the subclass override and silently skips skin application.
1176
+ */
1177
+ skinApply(_skin) {
1178
+ }
1189
1179
  setSkinData(data, opts = {}) {
1190
- var _a, _b;
1191
1180
  const { mergeWithExisting = false } = opts;
1192
1181
  if (data === null) {
1193
1182
  this[SKIN] = null;
1194
- (_a = this.skinApply) == null ? void 0 : _a.call(this, null);
1183
+ this.skinApply(null);
1195
1184
  return;
1196
1185
  }
1197
1186
  const current = this[SKIN];
@@ -1200,13 +1189,12 @@ function Skinable(Base) {
1200
1189
  } else {
1201
1190
  this[SKIN] = (0, import_lodash.merge)({}, data);
1202
1191
  }
1203
- (_b = this.skinApply) == null ? void 0 : _b.call(this, this[SKIN] ?? null);
1192
+ this.skinApply(this[SKIN] ?? null);
1204
1193
  }
1205
1194
  getSkinData() {
1206
1195
  return this[SKIN];
1207
1196
  }
1208
- // Subclasses should implement:
1209
- // protected skinApply?(skin: TSkinData | null): void
1197
+ // Subclasses override skinApply(skin) to apply visual properties.
1210
1198
  }
1211
1199
  return SkinableClass;
1212
1200
  }
@@ -2025,38 +2013,36 @@ function resolveSpriteTextAlignment(container, ctx) {
2025
2013
  }
2026
2014
 
2027
2015
  // ui/components/spriteText/SpriteText.ts
2028
- var SpriteText = class _SpriteText extends Skinable(Container) {
2029
- static globalSkin = defineGlobalSkin();
2030
- _glyphs = [];
2031
- _text = "";
2032
- _fonts = [];
2033
- _font = "";
2034
- _bbcodeEnabled = false;
2035
- _richTextExplicit;
2036
- _bbcodeAliases = {};
2037
- _fontStyles = [];
2038
- _runsOverride = null;
2039
- _tint = 16777215;
2040
- _pivotHorizontal = "center";
2041
- _pivotVertical = "middle";
2042
- _lineAlign = "left";
2043
- _letterSpacing = 0;
2044
- _spaceWidth = 0.5;
2045
- _wordWrap = false;
2046
- _wordWrapWidth = 100;
2047
- _breakWord = false;
2048
- _allowLineBreak = false;
2049
- _kerningEnabled = false;
2050
- _kerningMap = /* @__PURE__ */ new Map();
2051
- _glyphAnchor = { x: 0, y: 0 };
2052
- _glyphMap = {};
2053
- _fixedWidth = false;
2054
- _glyphScale = 1;
2055
- _curveEnabled = false;
2056
- _curveControlXPercent = 0.5;
2057
- _curveControlYPercent = -0.5;
2016
+ var _SpriteText = class _SpriteText extends Skinable(Container) {
2058
2017
  constructor(options = {}) {
2059
2018
  super();
2019
+ this._glyphs = [];
2020
+ this._text = "";
2021
+ this._fonts = [];
2022
+ this._font = "";
2023
+ this._bbcodeEnabled = false;
2024
+ this._bbcodeAliases = {};
2025
+ this._fontStyles = [];
2026
+ this._runsOverride = null;
2027
+ this._tint = 16777215;
2028
+ this._pivotHorizontal = "center";
2029
+ this._pivotVertical = "middle";
2030
+ this._lineAlign = "left";
2031
+ this._letterSpacing = 0;
2032
+ this._spaceWidth = 0.5;
2033
+ this._wordWrap = false;
2034
+ this._wordWrapWidth = 100;
2035
+ this._breakWord = false;
2036
+ this._allowLineBreak = false;
2037
+ this._kerningEnabled = false;
2038
+ this._kerningMap = /* @__PURE__ */ new Map();
2039
+ this._glyphAnchor = { x: 0, y: 0 };
2040
+ this._glyphMap = {};
2041
+ this._fixedWidth = false;
2042
+ this._glyphScale = 1;
2043
+ this._curveEnabled = false;
2044
+ this._curveControlXPercent = 0.5;
2045
+ this._curveControlYPercent = -0.5;
2060
2046
  if (options.text !== void 0) {
2061
2047
  this._text = options.text;
2062
2048
  }
@@ -2552,23 +2538,22 @@ var SpriteText = class _SpriteText extends Skinable(Container) {
2552
2538
  }
2553
2539
  }
2554
2540
  };
2541
+ _SpriteText.globalSkin = defineGlobalSkin();
2542
+ var SpriteText = _SpriteText;
2555
2543
 
2556
2544
  // ui/components/ButtonComp.ts
2557
- var ButtonComp = class _ButtonComp extends Skinable(Container) {
2558
- _buttonBehaviors;
2559
- _background;
2560
- _placeHolder;
2561
- _icon;
2562
- _labelText = null;
2563
- _buttonLabel = "";
2564
- _iconTextures = null;
2565
- _currentState = "up";
2566
- _enabled = true;
2567
- _effects = /* @__PURE__ */ new Map();
2568
- _previousState;
2569
- _stateDataCache = /* @__PURE__ */ new Map();
2545
+ var _ButtonComp = class _ButtonComp extends Skinable(Container) {
2570
2546
  constructor(options = {}) {
2571
2547
  super({ label: options.label });
2548
+ this._labelText = null;
2549
+ this._buttonLabel = "";
2550
+ this._iconTextures = null;
2551
+ this._currentState = "up";
2552
+ this._enabled = true;
2553
+ this._effects = /* @__PURE__ */ new Map();
2554
+ this._stateDataCache = /* @__PURE__ */ new Map();
2555
+ this._lastLayout = null;
2556
+ this._lastPlaceHolderLayout = null;
2572
2557
  this.eventMode = "static";
2573
2558
  this._background = new Graphics();
2574
2559
  this._placeHolder = new Container({ label: "placeHolder" });
@@ -2599,12 +2584,6 @@ var ButtonComp = class _ButtonComp extends Skinable(Container) {
2599
2584
  this.updateVisualState();
2600
2585
  this.notifyEffectsStateChange();
2601
2586
  }
2602
- _lastLayout = null;
2603
- _lastPlaceHolderLayout = null;
2604
- _lastBackgroundConfig;
2605
- _lastIconConfig;
2606
- _lastTextConfig;
2607
- _lastZIndex;
2608
2587
  updateVisualState() {
2609
2588
  const currentStateData = this.getCurrentStateData();
2610
2589
  if (!currentStateData) return;
@@ -2686,19 +2665,6 @@ var ButtonComp = class _ButtonComp extends Skinable(Container) {
2686
2665
  this._stateDataCache.set(state, { base, background, textConfig, icon, layout, placeHolderLayout, zIndex });
2687
2666
  }
2688
2667
  }
2689
- static stateFallbackChain = {
2690
- // Normal flow: up -> over -> down
2691
- up: ["up"],
2692
- over: ["up", "over"],
2693
- down: ["up", "over", "down"],
2694
- // Selected flow: selected_up -> selected_over -> selected_down
2695
- selected_up: ["up", "selected_up"],
2696
- selected_over: ["up", "selected_up", "selected_over"],
2697
- selected_down: ["up", "selected_up", "selected_over", "selected_down"],
2698
- // Disabled states
2699
- disabled: ["up", "disabled"],
2700
- selected_disabled: ["up", "selected_up", "selected_disabled"]
2701
- };
2702
2668
  getCurrentStateData() {
2703
2669
  return this._stateDataCache.get(this._currentState) ?? null;
2704
2670
  }
@@ -2945,18 +2911,28 @@ var ButtonComp = class _ButtonComp extends Skinable(Container) {
2945
2911
  return this._buttonBehaviors;
2946
2912
  }
2947
2913
  };
2914
+ _ButtonComp.stateFallbackChain = {
2915
+ // Normal flow: up -> over -> down
2916
+ up: ["up"],
2917
+ over: ["up", "over"],
2918
+ down: ["up", "over", "down"],
2919
+ // Selected flow: selected_up -> selected_over -> selected_down
2920
+ selected_up: ["up", "selected_up"],
2921
+ selected_over: ["up", "selected_up", "selected_over"],
2922
+ selected_down: ["up", "selected_up", "selected_over", "selected_down"],
2923
+ // Disabled states
2924
+ disabled: ["up", "disabled"],
2925
+ selected_disabled: ["up", "selected_up", "selected_disabled"]
2926
+ };
2927
+ var ButtonComp = _ButtonComp;
2948
2928
 
2949
2929
  // ui/components/InputComp.ts
2950
2930
  var import_lodash3 = __toESM(require_lodash(), 1);
2951
2931
  var InputComp = class extends Skinable(Container) {
2952
- _background;
2953
- _textMask;
2954
- _textLabel;
2955
- _behavior;
2956
- _currentState = "up";
2957
- _isFocused = false;
2958
2932
  constructor(options = {}) {
2959
2933
  super();
2934
+ this._currentState = "up";
2935
+ this._isFocused = false;
2960
2936
  this.eventMode = "static";
2961
2937
  this._background = new Graphics();
2962
2938
  this._textLabel = new Text({
@@ -3089,15 +3065,11 @@ var InputComp = class extends Skinable(Container) {
3089
3065
  // ui/components/SliderComp.ts
3090
3066
  var import_lodash4 = __toESM(require_lodash(), 1);
3091
3067
  var SliderComp = class extends Skinable(Container) {
3092
- _slider;
3093
- _trackContainer;
3094
- _progressContainer;
3095
- _knobContainer;
3096
- _currentState = "up";
3097
- _progressGraphics = null;
3098
- _progressConfig = null;
3099
3068
  constructor(options = {}) {
3100
3069
  super();
3070
+ this._currentState = "up";
3071
+ this._progressGraphics = null;
3072
+ this._progressConfig = null;
3101
3073
  this.layout = true;
3102
3074
  this.eventMode = "passive";
3103
3075
  this._trackContainer = new Container();
@@ -3556,23 +3528,18 @@ function createFlatButtonEffect(options) {
3556
3528
  // ui/components/StepperComp.ts
3557
3529
  var import_lodash5 = __toESM(require_lodash(), 1);
3558
3530
  var StepperComp = class extends Skinable(Container) {
3559
- _minusButton;
3560
- _plusButton;
3561
- _displayContainer;
3562
- _displayBackground;
3563
- _displayText;
3564
- _value = 0;
3565
- _min = 0;
3566
- _max = 100;
3567
- _step = 1;
3568
- _formatFunction = (val) => val.toString();
3569
- _enabled = true;
3570
- _currentState = "up";
3571
- _holdEnabled = true;
3572
- _holdDelay = 500;
3573
- _holdInterval = 100;
3574
3531
  constructor(options = {}) {
3575
3532
  super();
3533
+ this._value = 0;
3534
+ this._min = 0;
3535
+ this._max = 100;
3536
+ this._step = 1;
3537
+ this._formatFunction = (val) => val.toString();
3538
+ this._enabled = true;
3539
+ this._currentState = "up";
3540
+ this._holdEnabled = true;
3541
+ this._holdDelay = 500;
3542
+ this._holdInterval = 100;
3576
3543
  this.layout = true;
3577
3544
  this.eventMode = "passive";
3578
3545
  this._min = options.min ?? 0;
@@ -3850,12 +3817,10 @@ var StepperComp = class extends Skinable(Container) {
3850
3817
  // ui/components/LabelBox.ts
3851
3818
  var import_lodash6 = __toESM(require_lodash(), 1);
3852
3819
  var LabelBox = class extends Skinable(Container) {
3853
- _background;
3854
- _text;
3855
- _currentState = "default";
3856
- _stateDataCache = /* @__PURE__ */ new Map();
3857
3820
  constructor(options = {}) {
3858
3821
  super({ label: options.label });
3822
+ this._currentState = "default";
3823
+ this._stateDataCache = /* @__PURE__ */ new Map();
3859
3824
  this.eventMode = "passive";
3860
3825
  this._background = new Graphics();
3861
3826
  this._text = new Text({
@@ -3950,27 +3915,13 @@ var LabelBox = class extends Skinable(Container) {
3950
3915
  }
3951
3916
  };
3952
3917
  var ListTableComp = class extends Skinable(Container) {
3953
- _columns;
3954
- _tableWidth;
3955
- _tableHeight;
3956
- _rowHeight;
3957
- _headerHeight;
3958
- _rowGap;
3959
- _cellGap;
3960
- _showHeader;
3961
- _showScrollbar;
3962
- _headerContainer;
3963
- _headerCells = [];
3964
- _listContainer;
3965
- _listContent;
3966
- _listMask;
3967
- _scrollbar;
3968
- _data = [];
3969
- _rowViews = [];
3970
- _hoveredRowIndex = -1;
3971
- _scrollValue = 0;
3972
3918
  constructor(options) {
3973
3919
  super();
3920
+ this._headerCells = [];
3921
+ this._data = [];
3922
+ this._rowViews = [];
3923
+ this._hoveredRowIndex = -1;
3924
+ this._scrollValue = 0;
3974
3925
  this.eventMode = "static";
3975
3926
  this._columns = options.columns;
3976
3927
  this._tableWidth = options.tableWidth;