phaser-wind 0.6.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/dist/components/column/column.d.ts +88 -0
- package/dist/components/column/column.d.ts.map +1 -0
- package/dist/components/column/column.js +143 -0
- package/dist/components/column/column.js.map +1 -0
- package/dist/components/column/column.spec.d.ts +2 -0
- package/dist/components/column/column.spec.d.ts.map +1 -0
- package/dist/components/column/column.spec.js +114 -0
- package/dist/components/column/column.spec.js.map +1 -0
- package/dist/components/column/index.d.ts +2 -0
- package/dist/components/column/index.d.ts.map +1 -0
- package/dist/components/column/index.js +2 -0
- package/dist/components/column/index.js.map +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +4 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/layout/index.d.ts +2 -0
- package/dist/components/layout/index.d.ts.map +1 -0
- package/dist/components/layout/index.js +2 -0
- package/dist/components/layout/index.js.map +1 -0
- package/dist/components/layout/layout-utils.d.ts +13 -0
- package/dist/components/layout/layout-utils.d.ts.map +1 -0
- package/dist/components/layout/layout-utils.js +96 -0
- package/dist/components/layout/layout-utils.js.map +1 -0
- package/dist/components/layout/layout-utils.spec.d.ts +2 -0
- package/dist/components/layout/layout-utils.spec.d.ts.map +1 -0
- package/dist/components/layout/layout-utils.spec.js +70 -0
- package/dist/components/layout/layout-utils.spec.js.map +1 -0
- package/dist/components/row/index.d.ts +2 -0
- package/dist/components/row/index.d.ts.map +1 -0
- package/dist/components/row/index.js +2 -0
- package/dist/components/row/index.js.map +1 -0
- package/dist/components/row/row.d.ts +87 -0
- package/dist/components/row/row.d.ts.map +1 -0
- package/dist/components/row/row.js +146 -0
- package/dist/components/row/row.js.map +1 -0
- package/dist/components/row/row.spec.d.ts +2 -0
- package/dist/components/row/row.spec.d.ts.map +1 -0
- package/dist/components/row/row.spec.js +114 -0
- package/dist/components/row/row.spec.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/phaser-wind.js +1619 -0
- package/dist/phaser-wind.min.js +1 -0
- package/dist/test-setup.d.ts +2 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/dist/test-setup.js +35 -0
- package/dist/test-setup.js.map +1 -0
- package/dist/theme/theme-manager.d.ts.map +1 -1
- package/dist/theme/theme-manager.js +1 -1
- package/dist/theme/theme-manager.js.map +1 -1
- package/dist/utils/__tests__/merge.test.d.ts +2 -0
- package/dist/utils/__tests__/merge.test.d.ts.map +1 -0
- package/dist/utils/__tests__/merge.test.js +433 -0
- package/dist/utils/__tests__/merge.test.js.map +1 -0
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/merge.d.ts +24 -0
- package/dist/utils/merge.d.ts.map +1 -0
- package/dist/utils/merge.js +79 -0
- package/dist/utils/merge.js.map +1 -0
- package/package.json +9 -6
- package/dist/components/column.d.ts +0 -2
- package/dist/components/column.d.ts.map +0 -1
- package/dist/components/column.js +0 -2
- package/dist/components/column.js.map +0 -1
|
@@ -0,0 +1,1619 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('phaser')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'phaser'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.PhaserWind = {}, global.Phaser));
|
|
5
|
+
})(this, (function (exports, phaser) { 'use strict';
|
|
6
|
+
|
|
7
|
+
/******************************************************************************
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
9
|
+
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
+
***************************************************************************** */
|
|
21
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
22
|
+
|
|
23
|
+
var extendStatics = function(d, b) {
|
|
24
|
+
extendStatics = Object.setPrototypeOf ||
|
|
25
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
26
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
27
|
+
return extendStatics(d, b);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function __extends(d, b) {
|
|
31
|
+
if (typeof b !== "function" && b !== null)
|
|
32
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
33
|
+
extendStatics(d, b);
|
|
34
|
+
function __() { this.constructor = d; }
|
|
35
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var __assign = function() {
|
|
39
|
+
__assign = Object.assign || function __assign(t) {
|
|
40
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
41
|
+
s = arguments[i];
|
|
42
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
43
|
+
}
|
|
44
|
+
return t;
|
|
45
|
+
};
|
|
46
|
+
return __assign.apply(this, arguments);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
function __spreadArray(to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
60
|
+
var e = new Error(message);
|
|
61
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/** Default gap between elements in pixels */
|
|
65
|
+
var DEFAULT_GAP = 8;
|
|
66
|
+
/** Measures the display width of a game object, with fallbacks */
|
|
67
|
+
var getDisplayWidthOf = function (child) {
|
|
68
|
+
var _a;
|
|
69
|
+
var childTyped = child;
|
|
70
|
+
// Check if it's a Container-like object (has list property and width/height)
|
|
71
|
+
if (child && typeof child === 'object' && 'list' in child && Array.isArray(child.list)) {
|
|
72
|
+
if (typeof childTyped.displayWidth === 'number' && childTyped.displayWidth > 0) {
|
|
73
|
+
return childTyped.displayWidth;
|
|
74
|
+
}
|
|
75
|
+
if (typeof childTyped.width === 'number' && childTyped.width > 0) {
|
|
76
|
+
return childTyped.width;
|
|
77
|
+
}
|
|
78
|
+
var container = child;
|
|
79
|
+
if (typeof container.displayWidth === 'number' && container.displayWidth > 0) {
|
|
80
|
+
return container.displayWidth;
|
|
81
|
+
}
|
|
82
|
+
if (typeof container.width === 'number' && container.width > 0) {
|
|
83
|
+
if (typeof container.scale === 'number' && container.scale > 0) {
|
|
84
|
+
return container.width / container.scale;
|
|
85
|
+
}
|
|
86
|
+
return container.width;
|
|
87
|
+
}
|
|
88
|
+
var w = 0;
|
|
89
|
+
for (var _i = 0, _b = container.list; _i < _b.length; _i++) {
|
|
90
|
+
var sub = _b[_i];
|
|
91
|
+
var size = getDisplayWidthOf(sub);
|
|
92
|
+
w = Math.max(w, size);
|
|
93
|
+
}
|
|
94
|
+
return w;
|
|
95
|
+
}
|
|
96
|
+
if (typeof childTyped.displayWidth === 'number') {
|
|
97
|
+
return childTyped.displayWidth;
|
|
98
|
+
}
|
|
99
|
+
if (typeof childTyped.width === 'number') {
|
|
100
|
+
return childTyped.width;
|
|
101
|
+
}
|
|
102
|
+
var bounds = (_a = childTyped.getBounds) === null || _a === void 0 ? void 0 : _a.call(childTyped);
|
|
103
|
+
return bounds ? bounds.width : 0;
|
|
104
|
+
};
|
|
105
|
+
/** Measures the display height of a game object, with fallbacks */
|
|
106
|
+
var getDisplayHeightOf = function (child) {
|
|
107
|
+
var _a;
|
|
108
|
+
var childTyped = child;
|
|
109
|
+
// Check if it's a Container-like object (has list property and width/height)
|
|
110
|
+
if (child && typeof child === 'object' && 'list' in child && Array.isArray(child.list)) {
|
|
111
|
+
if (typeof childTyped.displayHeight === 'number' && childTyped.displayHeight > 0) {
|
|
112
|
+
return childTyped.displayHeight;
|
|
113
|
+
}
|
|
114
|
+
if (typeof childTyped.height === 'number' && childTyped.height > 0) {
|
|
115
|
+
return childTyped.height;
|
|
116
|
+
}
|
|
117
|
+
var container = child;
|
|
118
|
+
if (typeof container.displayHeight === 'number' && container.displayHeight > 0) {
|
|
119
|
+
return container.displayHeight;
|
|
120
|
+
}
|
|
121
|
+
if (typeof container.height === 'number' && container.height > 0) {
|
|
122
|
+
if (typeof container.scale === 'number' && container.scale > 0) {
|
|
123
|
+
return container.height / container.scale;
|
|
124
|
+
}
|
|
125
|
+
return container.height;
|
|
126
|
+
}
|
|
127
|
+
var h = 0;
|
|
128
|
+
for (var _i = 0, _b = container.list; _i < _b.length; _i++) {
|
|
129
|
+
var sub = _b[_i];
|
|
130
|
+
var size = getDisplayHeightOf(sub);
|
|
131
|
+
h = Math.max(h, size);
|
|
132
|
+
}
|
|
133
|
+
return h;
|
|
134
|
+
}
|
|
135
|
+
if (typeof childTyped.displayHeight === 'number') {
|
|
136
|
+
return childTyped.displayHeight;
|
|
137
|
+
}
|
|
138
|
+
if (typeof childTyped.height === 'number') {
|
|
139
|
+
return childTyped.height;
|
|
140
|
+
}
|
|
141
|
+
var bounds = (_a = childTyped.getBounds) === null || _a === void 0 ? void 0 : _a.call(childTyped);
|
|
142
|
+
return bounds ? bounds.height : 0;
|
|
143
|
+
};
|
|
144
|
+
/** Returns normalized origin (0..1) for a game object */
|
|
145
|
+
var getNormalizedOriginOf = function (child) {
|
|
146
|
+
var width = getDisplayWidthOf(child);
|
|
147
|
+
var height = getDisplayHeightOf(child);
|
|
148
|
+
var childTyped = child;
|
|
149
|
+
var ox = typeof childTyped.originX === 'number' ? childTyped.originX : undefined;
|
|
150
|
+
var oy = typeof childTyped.originY === 'number' ? childTyped.originY : undefined;
|
|
151
|
+
if (ox === undefined &&
|
|
152
|
+
typeof childTyped.displayOriginX === 'number' &&
|
|
153
|
+
width > 0) {
|
|
154
|
+
ox = childTyped.displayOriginX / width;
|
|
155
|
+
}
|
|
156
|
+
if (oy === undefined &&
|
|
157
|
+
typeof childTyped.displayOriginY === 'number' &&
|
|
158
|
+
height > 0) {
|
|
159
|
+
oy = childTyped.displayOriginY / height;
|
|
160
|
+
}
|
|
161
|
+
return { x: ox !== null && ox !== void 0 ? ox : 0.5, y: oy !== null && oy !== void 0 ? oy : 0.5 };
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Column is a layout container that stacks children vertically with a gap.
|
|
166
|
+
* The container position (x, y) represents the center of the whole column.
|
|
167
|
+
*/
|
|
168
|
+
var Column = /** @class */ (function (_super) {
|
|
169
|
+
__extends(Column, _super);
|
|
170
|
+
/**
|
|
171
|
+
* Creates a new Column container
|
|
172
|
+
* @param params Configuration parameters for the column
|
|
173
|
+
*/
|
|
174
|
+
function Column(_a) {
|
|
175
|
+
var scene = _a.scene, x = _a.x, y = _a.y, _b = _a.gap, gap = _b === void 0 ? DEFAULT_GAP : _b, _c = _a.align, align = _c === void 0 ? 'center' : _c, _d = _a.children, children = _d === void 0 ? [] : _d, _e = _a.verticalOrigin, verticalOrigin = _e === void 0 ? 'center' : _e;
|
|
176
|
+
var _this = _super.call(this, scene, x, y) || this;
|
|
177
|
+
_this.gap = gap;
|
|
178
|
+
_this.align = align;
|
|
179
|
+
_this.verticalOrigin = verticalOrigin;
|
|
180
|
+
if (children.length > 0) {
|
|
181
|
+
_this.add(children);
|
|
182
|
+
}
|
|
183
|
+
_this.layout();
|
|
184
|
+
return _this;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Sets the spacing between children and relayouts
|
|
188
|
+
* @param gap Gap in pixels between elements
|
|
189
|
+
*/
|
|
190
|
+
Column.prototype.setGap = function (gap) {
|
|
191
|
+
this.gap = gap;
|
|
192
|
+
this.layout();
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Sets the horizontal alignment and relayouts
|
|
196
|
+
* @param align New horizontal alignment
|
|
197
|
+
*/
|
|
198
|
+
Column.prototype.setAlign = function (align) {
|
|
199
|
+
this.align = align;
|
|
200
|
+
this.layout();
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Adds a child game object to the column
|
|
204
|
+
* @param child Game object to add
|
|
205
|
+
* @param relayout Whether to relayout after adding (default: true)
|
|
206
|
+
* @returns This column instance for chaining
|
|
207
|
+
*/
|
|
208
|
+
Column.prototype.addChild = function (child, relayout) {
|
|
209
|
+
if (relayout === void 0) { relayout = true; }
|
|
210
|
+
this.add(child);
|
|
211
|
+
if (relayout)
|
|
212
|
+
this.layout();
|
|
213
|
+
return this;
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* Adds multiple children to the column
|
|
217
|
+
* @param children Array of game objects to add
|
|
218
|
+
* @param relayout Whether to relayout after adding (default: true)
|
|
219
|
+
* @returns This column instance for chaining
|
|
220
|
+
*/
|
|
221
|
+
Column.prototype.addChildren = function (children, relayout) {
|
|
222
|
+
if (relayout === void 0) { relayout = true; }
|
|
223
|
+
if (children.length > 0)
|
|
224
|
+
this.add(children);
|
|
225
|
+
if (relayout)
|
|
226
|
+
this.layout();
|
|
227
|
+
return this;
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Recomputes children's positions and updates this container size
|
|
231
|
+
* Positions are calculated based on alignment, origins and gaps
|
|
232
|
+
*/
|
|
233
|
+
Column.prototype.layout = function () {
|
|
234
|
+
var _this = this;
|
|
235
|
+
var children = this.list;
|
|
236
|
+
if (children.length === 0) {
|
|
237
|
+
// Reset size when empty
|
|
238
|
+
this.setSize(0, 0);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
// Measure sizes and origins
|
|
242
|
+
var entries = children.map(function (child) { return ({
|
|
243
|
+
child: child,
|
|
244
|
+
width: _this.getDisplayWidth(child),
|
|
245
|
+
height: _this.getDisplayHeight(child),
|
|
246
|
+
origin: _this.getNormalizedOrigin(child),
|
|
247
|
+
}); });
|
|
248
|
+
var maxWidth = entries.reduce(function (m, s) { return Math.max(m, s.width); }, 0);
|
|
249
|
+
var totalHeight = entries.reduce(function (sum, s) { return sum + s.height; }, 0) + this.gap * (entries.length - 1);
|
|
250
|
+
// Determine top of content based on verticalOrigin
|
|
251
|
+
var contentTopY = this.verticalOrigin === 'top' ? 0 : this.verticalOrigin === 'center' ? -totalHeight / 2 : -totalHeight;
|
|
252
|
+
// Walk from top to bottom, aligning considering each child's origin
|
|
253
|
+
var cursorTopY = contentTopY;
|
|
254
|
+
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
255
|
+
var _a = entries_1[_i], child = _a.child, width = _a.width, height = _a.height, origin_1 = _a.origin;
|
|
256
|
+
// Horizontal alignment: align left/right edges or centers correctly using origin
|
|
257
|
+
var x = 0;
|
|
258
|
+
if (this.align === 'left') {
|
|
259
|
+
// place child's left edge at content left
|
|
260
|
+
x = -maxWidth / 2 + origin_1.x * width;
|
|
261
|
+
}
|
|
262
|
+
else if (this.align === 'right') {
|
|
263
|
+
// place child's right edge at content right
|
|
264
|
+
x = maxWidth / 2 - (1 - origin_1.x) * width;
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
// center alignment: center of child at 0 accounting for origin
|
|
268
|
+
x = (origin_1.x - 0.5) * width;
|
|
269
|
+
}
|
|
270
|
+
// Vertical position so that child's top is at cursorTopY
|
|
271
|
+
var y = cursorTopY + origin_1.y * height;
|
|
272
|
+
child.setPosition(x, y);
|
|
273
|
+
cursorTopY += height + this.gap;
|
|
274
|
+
}
|
|
275
|
+
// Update this container size to match content bounds
|
|
276
|
+
this.setSize(maxWidth, totalHeight);
|
|
277
|
+
};
|
|
278
|
+
/**
|
|
279
|
+
* Gets the display width of a game object
|
|
280
|
+
* @param child GameObject to measure
|
|
281
|
+
* @returns Display width in pixels
|
|
282
|
+
*/
|
|
283
|
+
Column.prototype.getDisplayWidth = function (child) {
|
|
284
|
+
return getDisplayWidthOf(child);
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* Gets the display height of a game object
|
|
288
|
+
* @param child GameObject to measure
|
|
289
|
+
* @returns Display height in pixels
|
|
290
|
+
*/
|
|
291
|
+
Column.prototype.getDisplayHeight = function (child) {
|
|
292
|
+
return getDisplayHeightOf(child);
|
|
293
|
+
};
|
|
294
|
+
/**
|
|
295
|
+
* Gets the normalized origin point of a game object
|
|
296
|
+
* @param child GameObject to get origin from
|
|
297
|
+
* @returns Object with normalized x,y coordinates of the origin point
|
|
298
|
+
*/
|
|
299
|
+
Column.prototype.getNormalizedOrigin = function (child) {
|
|
300
|
+
return getNormalizedOriginOf(child);
|
|
301
|
+
};
|
|
302
|
+
return Column;
|
|
303
|
+
}(phaser.GameObjects.Container));
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Row is a layout container that arranges children horizontally with a gap.
|
|
307
|
+
* The container position (x, y) represents the center of the whole row.
|
|
308
|
+
*/
|
|
309
|
+
var Row = /** @class */ (function (_super) {
|
|
310
|
+
__extends(Row, _super);
|
|
311
|
+
/**
|
|
312
|
+
* Creates a new Row container
|
|
313
|
+
* @param params Configuration parameters for the row
|
|
314
|
+
*/
|
|
315
|
+
function Row(_a) {
|
|
316
|
+
var scene = _a.scene, x = _a.x, y = _a.y, _b = _a.gap, gap = _b === void 0 ? DEFAULT_GAP : _b, _c = _a.align, align = _c === void 0 ? 'center' : _c, _d = _a.children, children = _d === void 0 ? [] : _d, _e = _a.horizontalOrigin, horizontalOrigin = _e === void 0 ? 'center' : _e;
|
|
317
|
+
var _this = _super.call(this, scene, x, y) || this;
|
|
318
|
+
_this.gap = gap;
|
|
319
|
+
_this.align = align;
|
|
320
|
+
_this.horizontalOrigin = horizontalOrigin;
|
|
321
|
+
if (children.length > 0) {
|
|
322
|
+
_this.add(children);
|
|
323
|
+
}
|
|
324
|
+
_this.layout();
|
|
325
|
+
return _this;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Sets the gap between elements and updates layout
|
|
329
|
+
* @param gap Gap size in pixels
|
|
330
|
+
*/
|
|
331
|
+
Row.prototype.setGap = function (gap) {
|
|
332
|
+
this.gap = gap;
|
|
333
|
+
this.layout();
|
|
334
|
+
};
|
|
335
|
+
/**
|
|
336
|
+
* Sets the vertical alignment and updates layout
|
|
337
|
+
* @param align New vertical alignment
|
|
338
|
+
*/
|
|
339
|
+
Row.prototype.setAlign = function (align) {
|
|
340
|
+
this.align = align;
|
|
341
|
+
this.layout();
|
|
342
|
+
};
|
|
343
|
+
/**
|
|
344
|
+
* Adds a single child to the row
|
|
345
|
+
* @param child GameObject to add
|
|
346
|
+
* @param relayout Whether to update layout after adding
|
|
347
|
+
* @returns This row instance for chaining
|
|
348
|
+
*/
|
|
349
|
+
Row.prototype.addChild = function (child, relayout) {
|
|
350
|
+
if (relayout === void 0) { relayout = true; }
|
|
351
|
+
this.add(child);
|
|
352
|
+
if (relayout) {
|
|
353
|
+
this.layout();
|
|
354
|
+
}
|
|
355
|
+
return this;
|
|
356
|
+
};
|
|
357
|
+
/**
|
|
358
|
+
* Adds multiple children to the row
|
|
359
|
+
* @param children Array of GameObjects to add
|
|
360
|
+
* @param relayout Whether to update layout after adding
|
|
361
|
+
* @returns This row instance for chaining
|
|
362
|
+
*/
|
|
363
|
+
Row.prototype.addChildren = function (children, relayout) {
|
|
364
|
+
if (relayout === void 0) { relayout = true; }
|
|
365
|
+
if (children.length > 0)
|
|
366
|
+
this.add(children);
|
|
367
|
+
if (relayout)
|
|
368
|
+
this.layout();
|
|
369
|
+
return this;
|
|
370
|
+
};
|
|
371
|
+
/**
|
|
372
|
+
* Recomputes children's positions and updates this container size
|
|
373
|
+
*/
|
|
374
|
+
Row.prototype.layout = function () {
|
|
375
|
+
var _this = this;
|
|
376
|
+
var children = this.list;
|
|
377
|
+
if (children.length === 0) {
|
|
378
|
+
this.setSize(0, 0);
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
// Measure sizes and origins
|
|
382
|
+
var entries = children.map(function (child) { return ({
|
|
383
|
+
child: child,
|
|
384
|
+
width: _this.getDisplayWidth(child),
|
|
385
|
+
height: _this.getDisplayHeight(child),
|
|
386
|
+
origin: _this.getNormalizedOrigin(child),
|
|
387
|
+
}); });
|
|
388
|
+
var maxHeight = entries.reduce(function (m, s) { return Math.max(m, s.height); }, 0);
|
|
389
|
+
var totalWidth = entries.reduce(function (sum, s) { return sum + s.width; }, 0) +
|
|
390
|
+
this.gap * (entries.length - 1);
|
|
391
|
+
// Determine left of content based on horizontalOrigin
|
|
392
|
+
var contentLeftX = this.horizontalOrigin === 'left'
|
|
393
|
+
? 0
|
|
394
|
+
: this.horizontalOrigin === 'center'
|
|
395
|
+
? -totalWidth / 2
|
|
396
|
+
: -totalWidth;
|
|
397
|
+
// Walk left to right, aligning considering each child's origin
|
|
398
|
+
var cursorLeftX = contentLeftX;
|
|
399
|
+
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
400
|
+
var _a = entries_1[_i], child = _a.child, width = _a.width, height = _a.height, origin_1 = _a.origin;
|
|
401
|
+
// Vertical alignment: align top/bottom edges or centers correctly using origin
|
|
402
|
+
var y = 0;
|
|
403
|
+
if (this.align === 'top') {
|
|
404
|
+
// place child's top edge at content top
|
|
405
|
+
y = -maxHeight / 2 + origin_1.y * height;
|
|
406
|
+
}
|
|
407
|
+
else if (this.align === 'bottom') {
|
|
408
|
+
// place child's bottom edge at content bottom
|
|
409
|
+
y = maxHeight / 2 - (1 - origin_1.y) * height;
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
// center alignment
|
|
413
|
+
y = (origin_1.y - 0.5) * height;
|
|
414
|
+
}
|
|
415
|
+
// Horizontal position so that child's left is at cursorLeftX
|
|
416
|
+
var x = cursorLeftX + origin_1.x * width;
|
|
417
|
+
child.setPosition(x, y);
|
|
418
|
+
cursorLeftX += width + this.gap;
|
|
419
|
+
}
|
|
420
|
+
this.setSize(totalWidth, maxHeight);
|
|
421
|
+
};
|
|
422
|
+
/**
|
|
423
|
+
* Gets the display width of a game object
|
|
424
|
+
* @param child GameObject to measure
|
|
425
|
+
* @returns Display width in pixels
|
|
426
|
+
*/
|
|
427
|
+
Row.prototype.getDisplayWidth = function (child) {
|
|
428
|
+
return getDisplayWidthOf(child);
|
|
429
|
+
};
|
|
430
|
+
/**
|
|
431
|
+
* Gets the display height of a game object
|
|
432
|
+
* @param child GameObject to measure
|
|
433
|
+
* @returns Display height in pixels
|
|
434
|
+
*/
|
|
435
|
+
Row.prototype.getDisplayHeight = function (child) {
|
|
436
|
+
return getDisplayHeightOf(child);
|
|
437
|
+
};
|
|
438
|
+
/**
|
|
439
|
+
* Gets the normalized origin point of a game object
|
|
440
|
+
* @param child GameObject to get origin from
|
|
441
|
+
* @returns Object with normalized x,y coordinates of the origin point
|
|
442
|
+
*/
|
|
443
|
+
Row.prototype.getNormalizedOrigin = function (child) {
|
|
444
|
+
return getNormalizedOriginOf(child);
|
|
445
|
+
};
|
|
446
|
+
return Row;
|
|
447
|
+
}(phaser.GameObjects.Container));
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Deep merge utility function that recursively merges objects
|
|
451
|
+
* Similar to lodash.merge but implemented natively
|
|
452
|
+
*/
|
|
453
|
+
/**
|
|
454
|
+
* Checks if a value is a plain object (not array, null, or other types)
|
|
455
|
+
*/
|
|
456
|
+
var isPlainObject = function (value) {
|
|
457
|
+
return (value !== null &&
|
|
458
|
+
typeof value === 'object' &&
|
|
459
|
+
!Array.isArray(value) &&
|
|
460
|
+
Object.prototype.toString.call(value) === '[object Object]');
|
|
461
|
+
};
|
|
462
|
+
/**
|
|
463
|
+
* Deep clone utility function that creates new references for all nested objects
|
|
464
|
+
* @param obj - The object to clone
|
|
465
|
+
* @returns A deep clone of the object with new references
|
|
466
|
+
*/
|
|
467
|
+
var deepClone = function (obj) {
|
|
468
|
+
if (obj === null || typeof obj !== 'object') {
|
|
469
|
+
return obj;
|
|
470
|
+
}
|
|
471
|
+
if (Array.isArray(obj)) {
|
|
472
|
+
return obj.map(function (item) { return deepClone(item); });
|
|
473
|
+
}
|
|
474
|
+
if (isPlainObject(obj)) {
|
|
475
|
+
var cloned = {};
|
|
476
|
+
for (var key in obj) {
|
|
477
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
478
|
+
cloned[key] = deepClone(obj[key]);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return cloned;
|
|
482
|
+
}
|
|
483
|
+
return obj;
|
|
484
|
+
};
|
|
485
|
+
/**
|
|
486
|
+
* Deep merge multiple objects into the first one
|
|
487
|
+
* @param target - The target object to merge into
|
|
488
|
+
* @param sources - Source objects to merge from
|
|
489
|
+
* @returns The merged object
|
|
490
|
+
*/
|
|
491
|
+
var merge = function (target) {
|
|
492
|
+
var sources = [];
|
|
493
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
494
|
+
sources[_i - 1] = arguments[_i];
|
|
495
|
+
}
|
|
496
|
+
if (!isPlainObject(target)) {
|
|
497
|
+
return target;
|
|
498
|
+
}
|
|
499
|
+
// Start with a deep clone of the target
|
|
500
|
+
var result = deepClone(target);
|
|
501
|
+
for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) {
|
|
502
|
+
var source = sources_1[_a];
|
|
503
|
+
if (!isPlainObject(source)) {
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
// Deep clone the source to ensure we create new references
|
|
507
|
+
var clonedSource = deepClone(source);
|
|
508
|
+
for (var key in clonedSource) {
|
|
509
|
+
if (Object.prototype.hasOwnProperty.call(clonedSource, key)) {
|
|
510
|
+
var sourceValue = clonedSource[key];
|
|
511
|
+
var targetValue = result[key];
|
|
512
|
+
if (isPlainObject(sourceValue) && isPlainObject(targetValue)) {
|
|
513
|
+
result[key] = merge(targetValue, sourceValue);
|
|
514
|
+
}
|
|
515
|
+
else if (sourceValue !== undefined) {
|
|
516
|
+
result[key] = sourceValue;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return result;
|
|
522
|
+
};
|
|
523
|
+
/**
|
|
524
|
+
* Deep merge that creates a new object without mutating the original
|
|
525
|
+
* @param target - The target object
|
|
526
|
+
* @param sources - Source objects to merge from
|
|
527
|
+
* @returns A new merged object
|
|
528
|
+
*/
|
|
529
|
+
var mergeDeep = function (target) {
|
|
530
|
+
var sources = [];
|
|
531
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
532
|
+
sources[_i - 1] = arguments[_i];
|
|
533
|
+
}
|
|
534
|
+
return merge.apply(void 0, __spreadArray([{}, target], sources, false));
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
/* eslint-disable security/detect-unsafe-regex */
|
|
538
|
+
/**
|
|
539
|
+
* Checks if a string is a valid CSS color value
|
|
540
|
+
* @param color - The color string to validate
|
|
541
|
+
* @returns True if the color string is valid, false otherwise
|
|
542
|
+
*
|
|
543
|
+
* Supports the following formats:
|
|
544
|
+
* - Hex colors (#RRGGBB or #RGB)
|
|
545
|
+
* - RGB colors (rgb(r, g, b))
|
|
546
|
+
* - RGBA colors (rgba(r, g, b, a))
|
|
547
|
+
* - OKLCH colors (oklch(l c h [/ a]))
|
|
548
|
+
*/
|
|
549
|
+
var isValidColor = function (color) {
|
|
550
|
+
if (typeof color !== 'string') {
|
|
551
|
+
return false;
|
|
552
|
+
}
|
|
553
|
+
var trimmedColor = color.trim();
|
|
554
|
+
if (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(trimmedColor)) {
|
|
555
|
+
return true;
|
|
556
|
+
}
|
|
557
|
+
if (/^rgb\(\s*(\d{1,3}%?)\s*,\s*(\d{1,3}%?)\s*,\s*(\d{1,3}%?)\s*\)$/.test(trimmedColor)) {
|
|
558
|
+
return true;
|
|
559
|
+
}
|
|
560
|
+
if (/^rgba\(\s*(\d{1,3}%?)\s*,\s*(\d{1,3}%?)\s*,\s*(\d{1,3}%?)\s*,\s*([01]|0?\.\d+)\s*\)$/.test(trimmedColor)) {
|
|
561
|
+
return true;
|
|
562
|
+
}
|
|
563
|
+
if (/^oklch\(\s*(\d*\.?\d+%?)\s+(\d*\.?\d+)\s+(\d*\.?\d+)(?:\s*\/\s*([01]|0?\.\d+))?\s*\)$/.test(trimmedColor)) {
|
|
564
|
+
return true;
|
|
565
|
+
}
|
|
566
|
+
return false;
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
// https://github.com/tailwindlabs/tailwindcss/blob/main/packages/tailwindcss/src/compat/colors.ts
|
|
570
|
+
var palette = {
|
|
571
|
+
black: '#000',
|
|
572
|
+
white: '#fff',
|
|
573
|
+
slate: {
|
|
574
|
+
'50': 'rgb(248, 250, 252)',
|
|
575
|
+
'100': 'rgb(241, 245, 249)',
|
|
576
|
+
'200': 'rgb(226, 232, 240)',
|
|
577
|
+
'300': 'rgb(203, 213, 225)',
|
|
578
|
+
'400': 'rgb(148, 163, 184)',
|
|
579
|
+
'500': 'rgb(100, 116, 139)',
|
|
580
|
+
'600': 'rgb(71, 85, 105)',
|
|
581
|
+
'700': 'rgb(51, 65, 85)',
|
|
582
|
+
'800': 'rgb(30, 41, 59)',
|
|
583
|
+
'900': 'rgb(15, 23, 42)',
|
|
584
|
+
'950': 'rgb(2, 6, 23)',
|
|
585
|
+
},
|
|
586
|
+
gray: {
|
|
587
|
+
'50': 'rgb(249, 250, 251)',
|
|
588
|
+
'100': 'rgb(243, 244, 246)',
|
|
589
|
+
'200': 'rgb(229, 231, 235)',
|
|
590
|
+
'300': 'rgb(209, 213, 219)',
|
|
591
|
+
'400': 'rgb(156, 163, 175)',
|
|
592
|
+
'500': 'rgb(107, 114, 128)',
|
|
593
|
+
'600': 'rgb(75, 85, 99)',
|
|
594
|
+
'700': 'rgb(55, 65, 81)',
|
|
595
|
+
'800': 'rgb(31, 41, 55)',
|
|
596
|
+
'900': 'rgb(17, 24, 39)',
|
|
597
|
+
'950': 'rgb(3, 7, 18)',
|
|
598
|
+
},
|
|
599
|
+
zinc: {
|
|
600
|
+
'50': 'rgb(250, 250, 250)',
|
|
601
|
+
'100': 'rgb(244, 244, 245)',
|
|
602
|
+
'200': 'rgb(228, 228, 231)',
|
|
603
|
+
'300': 'rgb(212, 212, 216)',
|
|
604
|
+
'400': 'rgb(161, 161, 170)',
|
|
605
|
+
'500': 'rgb(113, 113, 122)',
|
|
606
|
+
'600': 'rgb(82, 82, 91)',
|
|
607
|
+
'700': 'rgb(63, 63, 70)',
|
|
608
|
+
'800': 'rgb(39, 39, 42)',
|
|
609
|
+
'900': 'rgb(24, 24, 27)',
|
|
610
|
+
'950': 'rgb(9, 9, 11)',
|
|
611
|
+
},
|
|
612
|
+
neutral: {
|
|
613
|
+
'50': 'rgb(250, 250, 250)',
|
|
614
|
+
'100': 'rgb(245, 245, 245)',
|
|
615
|
+
'200': 'rgb(229, 229, 229)',
|
|
616
|
+
'300': 'rgb(212, 212, 212)',
|
|
617
|
+
'400': 'rgb(163, 163, 163)',
|
|
618
|
+
'500': 'rgb(115, 115, 115)',
|
|
619
|
+
'600': 'rgb(82, 82, 82)',
|
|
620
|
+
'700': 'rgb(64, 64, 64)',
|
|
621
|
+
'800': 'rgb(38, 38, 38)',
|
|
622
|
+
'900': 'rgb(23, 23, 23)',
|
|
623
|
+
'950': 'rgb(10, 10, 10)',
|
|
624
|
+
},
|
|
625
|
+
stone: {
|
|
626
|
+
'50': 'rgb(250, 250, 249)',
|
|
627
|
+
'100': 'rgb(245, 245, 244)',
|
|
628
|
+
'200': 'rgb(231, 229, 228)',
|
|
629
|
+
'300': 'rgb(214, 211, 209)',
|
|
630
|
+
'400': 'rgb(168, 162, 158)',
|
|
631
|
+
'500': 'rgb(120, 113, 108)',
|
|
632
|
+
'600': 'rgb(87, 83, 78)',
|
|
633
|
+
'700': 'rgb(68, 64, 60)',
|
|
634
|
+
'800': 'rgb(41, 37, 36)',
|
|
635
|
+
'900': 'rgb(28, 25, 23)',
|
|
636
|
+
'950': 'rgb(12, 10, 9)',
|
|
637
|
+
},
|
|
638
|
+
red: {
|
|
639
|
+
'50': 'rgb(254, 242, 242)',
|
|
640
|
+
'100': 'rgb(254, 226, 226)',
|
|
641
|
+
'200': 'rgb(254, 202, 202)',
|
|
642
|
+
'300': 'rgb(252, 165, 165)',
|
|
643
|
+
'400': 'rgb(248, 113, 113)',
|
|
644
|
+
'500': 'rgb(239, 68, 68)',
|
|
645
|
+
'600': 'rgb(220, 38, 38)',
|
|
646
|
+
'700': 'rgb(185, 28, 28)',
|
|
647
|
+
'800': 'rgb(153, 27, 27)',
|
|
648
|
+
'900': 'rgb(127, 29, 29)',
|
|
649
|
+
'950': 'rgb(69, 10, 10)',
|
|
650
|
+
},
|
|
651
|
+
orange: {
|
|
652
|
+
'50': 'rgb(255, 247, 237)',
|
|
653
|
+
'100': 'rgb(255, 237, 213)',
|
|
654
|
+
'200': 'rgb(254, 215, 170)',
|
|
655
|
+
'300': 'rgb(253, 186, 116)',
|
|
656
|
+
'400': 'rgb(251, 146, 60)',
|
|
657
|
+
'500': 'rgb(249, 115, 22)',
|
|
658
|
+
'600': 'rgb(234, 88, 12)',
|
|
659
|
+
'700': 'rgb(194, 65, 12)',
|
|
660
|
+
'800': 'rgb(154, 52, 18)',
|
|
661
|
+
'900': 'rgb(124, 45, 18)',
|
|
662
|
+
'950': 'rgb(67, 20, 7)',
|
|
663
|
+
},
|
|
664
|
+
amber: {
|
|
665
|
+
'50': 'rgb(255, 251, 235)',
|
|
666
|
+
'100': 'rgb(254, 243, 199)',
|
|
667
|
+
'200': 'rgb(253, 230, 138)',
|
|
668
|
+
'300': 'rgb(252, 211, 77)',
|
|
669
|
+
'400': 'rgb(251, 191, 36)',
|
|
670
|
+
'500': 'rgb(245, 158, 11)',
|
|
671
|
+
'600': 'rgb(217, 119, 6)',
|
|
672
|
+
'700': 'rgb(180, 83, 9)',
|
|
673
|
+
'800': 'rgb(146, 64, 14)',
|
|
674
|
+
'900': 'rgb(120, 53, 15)',
|
|
675
|
+
'950': 'rgb(69, 26, 3)',
|
|
676
|
+
},
|
|
677
|
+
yellow: {
|
|
678
|
+
'50': 'rgb(254, 252, 232)',
|
|
679
|
+
'100': 'rgb(254, 249, 195)',
|
|
680
|
+
'200': 'rgb(254, 240, 138)',
|
|
681
|
+
'300': 'rgb(253, 224, 71)',
|
|
682
|
+
'400': 'rgb(250, 204, 21)',
|
|
683
|
+
'500': 'rgb(234, 179, 8)',
|
|
684
|
+
'600': 'rgb(202, 138, 4)',
|
|
685
|
+
'700': 'rgb(161, 98, 7)',
|
|
686
|
+
'800': 'rgb(133, 77, 14)',
|
|
687
|
+
'900': 'rgb(113, 63, 18)',
|
|
688
|
+
'950': 'rgb(66, 32, 6)',
|
|
689
|
+
},
|
|
690
|
+
lime: {
|
|
691
|
+
'50': 'rgb(247, 254, 231)',
|
|
692
|
+
'100': 'rgb(236, 252, 203)',
|
|
693
|
+
'200': 'rgb(217, 249, 157)',
|
|
694
|
+
'300': 'rgb(190, 242, 100)',
|
|
695
|
+
'400': 'rgb(163, 230, 53)',
|
|
696
|
+
'500': 'rgb(132, 204, 22)',
|
|
697
|
+
'600': 'rgb(101, 163, 13)',
|
|
698
|
+
'700': 'rgb(77, 124, 15)',
|
|
699
|
+
'800': 'rgb(63, 98, 18)',
|
|
700
|
+
'900': 'rgb(54, 83, 20)',
|
|
701
|
+
'950': 'rgb(26, 46, 5)',
|
|
702
|
+
},
|
|
703
|
+
green: {
|
|
704
|
+
'50': 'rgb(240, 253, 244)',
|
|
705
|
+
'100': 'rgb(220, 252, 231)',
|
|
706
|
+
'200': 'rgb(187, 247, 208)',
|
|
707
|
+
'300': 'rgb(134, 239, 172)',
|
|
708
|
+
'400': 'rgb(74, 222, 128)',
|
|
709
|
+
'500': 'rgb(34, 197, 94)',
|
|
710
|
+
'600': 'rgb(22, 163, 74)',
|
|
711
|
+
'700': 'rgb(21, 128, 61)',
|
|
712
|
+
'800': 'rgb(22, 101, 52)',
|
|
713
|
+
'900': 'rgb(20, 83, 45)',
|
|
714
|
+
'950': 'rgb(5, 46, 22)',
|
|
715
|
+
},
|
|
716
|
+
emerald: {
|
|
717
|
+
'50': 'rgb(236, 253, 245)',
|
|
718
|
+
'100': 'rgb(209, 250, 229)',
|
|
719
|
+
'200': 'rgb(167, 243, 208)',
|
|
720
|
+
'300': 'rgb(110, 231, 183)',
|
|
721
|
+
'400': 'rgb(52, 211, 153)',
|
|
722
|
+
'500': 'rgb(16, 185, 129)',
|
|
723
|
+
'600': 'rgb(5, 150, 105)',
|
|
724
|
+
'700': 'rgb(4, 120, 87)',
|
|
725
|
+
'800': 'rgb(6, 95, 70)',
|
|
726
|
+
'900': 'rgb(6, 78, 59)',
|
|
727
|
+
'950': 'rgb(2, 44, 34)',
|
|
728
|
+
},
|
|
729
|
+
teal: {
|
|
730
|
+
'50': 'rgb(240, 253, 250)',
|
|
731
|
+
'100': 'rgb(204, 251, 241)',
|
|
732
|
+
'200': 'rgb(153, 246, 228)',
|
|
733
|
+
'300': 'rgb(94, 234, 212)',
|
|
734
|
+
'400': 'rgb(45, 212, 191)',
|
|
735
|
+
'500': 'rgb(20, 184, 166)',
|
|
736
|
+
'600': 'rgb(13, 148, 136)',
|
|
737
|
+
'700': 'rgb(15, 118, 110)',
|
|
738
|
+
'800': 'rgb(17, 94, 89)',
|
|
739
|
+
'900': 'rgb(19, 78, 74)',
|
|
740
|
+
'950': 'rgb(4, 47, 46)',
|
|
741
|
+
},
|
|
742
|
+
cyan: {
|
|
743
|
+
'50': 'rgb(236, 254, 255)',
|
|
744
|
+
'100': 'rgb(207, 250, 254)',
|
|
745
|
+
'200': 'rgb(165, 243, 252)',
|
|
746
|
+
'300': 'rgb(103, 232, 249)',
|
|
747
|
+
'400': 'rgb(34, 211, 238)',
|
|
748
|
+
'500': 'rgb(6, 182, 212)',
|
|
749
|
+
'600': 'rgb(8, 145, 178)',
|
|
750
|
+
'700': 'rgb(14, 116, 144)',
|
|
751
|
+
'800': 'rgb(21, 94, 117)',
|
|
752
|
+
'900': 'rgb(22, 78, 99)',
|
|
753
|
+
'950': 'rgb(8, 51, 68)',
|
|
754
|
+
},
|
|
755
|
+
sky: {
|
|
756
|
+
'50': 'rgb(240, 249, 255)',
|
|
757
|
+
'100': 'rgb(224, 242, 254)',
|
|
758
|
+
'200': 'rgb(186, 230, 253)',
|
|
759
|
+
'300': 'rgb(125, 211, 252)',
|
|
760
|
+
'400': 'rgb(56, 189, 248)',
|
|
761
|
+
'500': 'rgb(14, 165, 233)',
|
|
762
|
+
'600': 'rgb(2, 132, 199)',
|
|
763
|
+
'700': 'rgb(3, 105, 161)',
|
|
764
|
+
'800': 'rgb(7, 89, 133)',
|
|
765
|
+
'900': 'rgb(12, 74, 110)',
|
|
766
|
+
'950': 'rgb(8, 47, 73)',
|
|
767
|
+
},
|
|
768
|
+
blue: {
|
|
769
|
+
'50': 'rgb(239, 246, 255)',
|
|
770
|
+
'100': 'rgb(219, 234, 254)',
|
|
771
|
+
'200': 'rgb(191, 219, 254)',
|
|
772
|
+
'300': 'rgb(147, 197, 253)',
|
|
773
|
+
'400': 'rgb(96, 165, 250)',
|
|
774
|
+
'500': 'rgb(59, 130, 246)',
|
|
775
|
+
'600': 'rgb(37, 99, 235)',
|
|
776
|
+
'700': 'rgb(29, 78, 216)',
|
|
777
|
+
'800': 'rgb(30, 64, 175)',
|
|
778
|
+
'900': 'rgb(30, 58, 138)',
|
|
779
|
+
'950': 'rgb(23, 37, 84)',
|
|
780
|
+
},
|
|
781
|
+
indigo: {
|
|
782
|
+
'50': 'rgb(238, 242, 255)',
|
|
783
|
+
'100': 'rgb(224, 231, 255)',
|
|
784
|
+
'200': 'rgb(199, 210, 254)',
|
|
785
|
+
'300': 'rgb(165, 180, 252)',
|
|
786
|
+
'400': 'rgb(129, 140, 248)',
|
|
787
|
+
'500': 'rgb(99, 102, 241)',
|
|
788
|
+
'600': 'rgb(79, 70, 229)',
|
|
789
|
+
'700': 'rgb(67, 56, 202)',
|
|
790
|
+
'800': 'rgb(55, 48, 163)',
|
|
791
|
+
'900': 'rgb(49, 46, 129)',
|
|
792
|
+
'950': 'rgb(30, 27, 75)',
|
|
793
|
+
},
|
|
794
|
+
violet: {
|
|
795
|
+
'50': 'rgb(245, 243, 255)',
|
|
796
|
+
'100': 'rgb(237, 233, 254)',
|
|
797
|
+
'200': 'rgb(221, 214, 254)',
|
|
798
|
+
'300': 'rgb(196, 181, 253)',
|
|
799
|
+
'400': 'rgb(167, 139, 250)',
|
|
800
|
+
'500': 'rgb(139, 92, 246)',
|
|
801
|
+
'600': 'rgb(124, 58, 237)',
|
|
802
|
+
'700': 'rgb(109, 40, 217)',
|
|
803
|
+
'800': 'rgb(91, 33, 182)',
|
|
804
|
+
'900': 'rgb(76, 29, 149)',
|
|
805
|
+
'950': 'rgb(46, 16, 101)',
|
|
806
|
+
},
|
|
807
|
+
purple: {
|
|
808
|
+
'50': 'rgb(250, 245, 255)',
|
|
809
|
+
'100': 'rgb(243, 232, 255)',
|
|
810
|
+
'200': 'rgb(233, 213, 255)',
|
|
811
|
+
'300': 'rgb(216, 180, 254)',
|
|
812
|
+
'400': 'rgb(192, 132, 252)',
|
|
813
|
+
'500': 'rgb(168, 85, 247)',
|
|
814
|
+
'600': 'rgb(147, 51, 234)',
|
|
815
|
+
'700': 'rgb(126, 34, 206)',
|
|
816
|
+
'800': 'rgb(107, 33, 168)',
|
|
817
|
+
'900': 'rgb(88, 28, 135)',
|
|
818
|
+
'950': 'rgb(59, 7, 100)',
|
|
819
|
+
},
|
|
820
|
+
fuchsia: {
|
|
821
|
+
'50': 'rgb(253, 244, 255)',
|
|
822
|
+
'100': 'rgb(250, 232, 255)',
|
|
823
|
+
'200': 'rgb(245, 208, 254)',
|
|
824
|
+
'300': 'rgb(240, 171, 252)',
|
|
825
|
+
'400': 'rgb(232, 121, 249)',
|
|
826
|
+
'500': 'rgb(217, 70, 239)',
|
|
827
|
+
'600': 'rgb(192, 38, 211)',
|
|
828
|
+
'700': 'rgb(162, 28, 175)',
|
|
829
|
+
'800': 'rgb(134, 25, 143)',
|
|
830
|
+
'900': 'rgb(112, 26, 117)',
|
|
831
|
+
'950': 'rgb(74, 4, 78)',
|
|
832
|
+
},
|
|
833
|
+
pink: {
|
|
834
|
+
'50': 'rgb(253, 242, 248)',
|
|
835
|
+
'100': 'rgb(252, 231, 243)',
|
|
836
|
+
'200': 'rgb(251, 207, 232)',
|
|
837
|
+
'300': 'rgb(249, 168, 212)',
|
|
838
|
+
'400': 'rgb(244, 114, 182)',
|
|
839
|
+
'500': 'rgb(236, 72, 153)',
|
|
840
|
+
'600': 'rgb(219, 39, 119)',
|
|
841
|
+
'700': 'rgb(190, 24, 93)',
|
|
842
|
+
'800': 'rgb(157, 23, 77)',
|
|
843
|
+
'900': 'rgb(131, 24, 67)',
|
|
844
|
+
'950': 'rgb(80, 7, 36)',
|
|
845
|
+
},
|
|
846
|
+
rose: {
|
|
847
|
+
'50': 'rgb(255, 241, 242)',
|
|
848
|
+
'100': 'rgb(255, 228, 230)',
|
|
849
|
+
'200': 'rgb(254, 205, 211)',
|
|
850
|
+
'300': 'rgb(253, 164, 175)',
|
|
851
|
+
'400': 'rgb(251, 113, 133)',
|
|
852
|
+
'500': 'rgb(244, 63, 94)',
|
|
853
|
+
'600': 'rgb(225, 29, 72)',
|
|
854
|
+
'700': 'rgb(190, 18, 60)',
|
|
855
|
+
'800': 'rgb(159, 18, 57)',
|
|
856
|
+
'900': 'rgb(136, 19, 55)',
|
|
857
|
+
'950': 'rgb(76, 5, 25)',
|
|
858
|
+
},
|
|
859
|
+
};
|
|
860
|
+
|
|
861
|
+
/** Regular expression to match RGB color format */
|
|
862
|
+
var RGB_REGEX = /rgb\((\d+),\s*(\d+),\s*(\d+)\)/;
|
|
863
|
+
/**
|
|
864
|
+
* Convert hex color value to number
|
|
865
|
+
* @param hexValue - Hex color value (e.g., '#ff0000')
|
|
866
|
+
* @returns Number representation of hex color
|
|
867
|
+
*/
|
|
868
|
+
var convertHexToNumber = function (hexValue) {
|
|
869
|
+
var hex = hexValue.slice(1);
|
|
870
|
+
if (hex.length === 3) {
|
|
871
|
+
var r = parseInt(hex[0] + hex[0], 16);
|
|
872
|
+
var g = parseInt(hex[1] + hex[1], 16);
|
|
873
|
+
var b = parseInt(hex[2] + hex[2], 16);
|
|
874
|
+
return (r << 16) + (g << 8) + b;
|
|
875
|
+
}
|
|
876
|
+
return parseInt(hex, 16);
|
|
877
|
+
};
|
|
878
|
+
/**
|
|
879
|
+
* Convert RGB color value to number
|
|
880
|
+
* @param rgbValue - RGB color value (e.g., 'rgb(255, 0, 0)')
|
|
881
|
+
* @returns Number representation of RGB color
|
|
882
|
+
* @throws {Error} If RGB format is invalid
|
|
883
|
+
*/
|
|
884
|
+
var convertRgbToNumber = function (rgbValue) {
|
|
885
|
+
var matches = rgbValue.match(RGB_REGEX);
|
|
886
|
+
if (!matches) {
|
|
887
|
+
throw new Error("Invalid RGB format: ".concat(rgbValue));
|
|
888
|
+
}
|
|
889
|
+
var r = parseInt(matches[1]);
|
|
890
|
+
var g = parseInt(matches[2]);
|
|
891
|
+
var b = parseInt(matches[3]);
|
|
892
|
+
return (r << 16) + (g << 8) + b;
|
|
893
|
+
};
|
|
894
|
+
/**
|
|
895
|
+
* Convert color value to number
|
|
896
|
+
* @param colorValue - Color value (e.g., '#ff0000' or 'rgb(255, 0, 0)')
|
|
897
|
+
* @returns Number representation of color
|
|
898
|
+
*/
|
|
899
|
+
var convertColorValueToNumber = function (colorValue) {
|
|
900
|
+
if (colorValue.startsWith('#')) {
|
|
901
|
+
return convertHexToNumber(colorValue);
|
|
902
|
+
}
|
|
903
|
+
return convertRgbToNumber(colorValue);
|
|
904
|
+
};
|
|
905
|
+
/**
|
|
906
|
+
* Factory that creates a color utility API based on the provided theme colors
|
|
907
|
+
* @param themeColors - Theme colors configuration
|
|
908
|
+
* @returns Color utility API instance
|
|
909
|
+
*/
|
|
910
|
+
/**
|
|
911
|
+
* Create a color API bound to an optional theme colors map.
|
|
912
|
+
* If a key exists in `themeColors`, it will be resolved to a palette token and then to RGB/Hex.
|
|
913
|
+
*
|
|
914
|
+
* @typeParam T - Theme colors map
|
|
915
|
+
* @param themeColors - Optional map of theme color tokens
|
|
916
|
+
* @example
|
|
917
|
+
* const c = createColor({ primary: 'blue-500' });
|
|
918
|
+
* c.rgb('primary'); // rgb(59, 130, 246)
|
|
919
|
+
*/
|
|
920
|
+
var createColor = function (themeColors) {
|
|
921
|
+
/**
|
|
922
|
+
* Get color value from theme configuration
|
|
923
|
+
* @param key - Color token or theme color key
|
|
924
|
+
* @returns Color value from theme or null if not found
|
|
925
|
+
*/
|
|
926
|
+
var getValueFromTheme = function (key) {
|
|
927
|
+
if (themeColors && key in themeColors) {
|
|
928
|
+
return themeColors[key];
|
|
929
|
+
}
|
|
930
|
+
return null;
|
|
931
|
+
};
|
|
932
|
+
/**
|
|
933
|
+
* Get RGB string representation of a color
|
|
934
|
+
* @param color - Color token, theme color key or valid color string
|
|
935
|
+
* @returns RGB color string
|
|
936
|
+
* @throws {Error} If color token is not found
|
|
937
|
+
*/
|
|
938
|
+
var rgb = function (color) {
|
|
939
|
+
var _a;
|
|
940
|
+
// Runtime supports direct CSS strings for flexibility, but
|
|
941
|
+
// the public type restricts to palette tokens or theme keys.
|
|
942
|
+
if (typeof color === 'string' && isValidColor(color)) {
|
|
943
|
+
return color;
|
|
944
|
+
}
|
|
945
|
+
var colorFromTheme = getValueFromTheme(color);
|
|
946
|
+
if (colorFromTheme) {
|
|
947
|
+
return rgb(colorFromTheme);
|
|
948
|
+
}
|
|
949
|
+
var parts = color.split('-');
|
|
950
|
+
if (parts.length === 2) {
|
|
951
|
+
var colorKey = parts[0];
|
|
952
|
+
var shade = parts[1];
|
|
953
|
+
var colorValue_1 = (_a = palette[colorKey]) === null || _a === void 0 ? void 0 : _a[shade];
|
|
954
|
+
if (!colorValue_1) {
|
|
955
|
+
if (isValidColor(color)) {
|
|
956
|
+
return color;
|
|
957
|
+
}
|
|
958
|
+
throw new Error("Color token \"".concat(colorKey, "-").concat(shade, "\" not found"));
|
|
959
|
+
}
|
|
960
|
+
return colorValue_1;
|
|
961
|
+
}
|
|
962
|
+
var colorValue = palette[color];
|
|
963
|
+
if (!colorValue) {
|
|
964
|
+
if (isValidColor(color)) {
|
|
965
|
+
return color;
|
|
966
|
+
}
|
|
967
|
+
throw new Error("Color token \"".concat(color, "\" not found"));
|
|
968
|
+
}
|
|
969
|
+
return colorValue;
|
|
970
|
+
};
|
|
971
|
+
/**
|
|
972
|
+
* Get hex number representation of a color
|
|
973
|
+
* @param color - Color token, theme color key or valid color string
|
|
974
|
+
* @returns Hex color number
|
|
975
|
+
* @throws {Error} If color token is not found
|
|
976
|
+
*/
|
|
977
|
+
var hex = function (color) {
|
|
978
|
+
var _a;
|
|
979
|
+
// See note in rgb()
|
|
980
|
+
if (typeof color === 'string' && isValidColor(color)) {
|
|
981
|
+
return convertColorValueToNumber(color);
|
|
982
|
+
}
|
|
983
|
+
var colorFromTheme = getValueFromTheme(color);
|
|
984
|
+
if (colorFromTheme) {
|
|
985
|
+
return hex(colorFromTheme);
|
|
986
|
+
}
|
|
987
|
+
var parts = color.split('-');
|
|
988
|
+
if (parts.length === 2) {
|
|
989
|
+
var colorKey = parts[0];
|
|
990
|
+
var shade = parts[1];
|
|
991
|
+
var colorValue = (_a = palette[colorKey]) === null || _a === void 0 ? void 0 : _a[shade];
|
|
992
|
+
if (!colorValue) {
|
|
993
|
+
if (isValidColor(color)) {
|
|
994
|
+
return convertColorValueToNumber(color);
|
|
995
|
+
}
|
|
996
|
+
throw new Error("Color token \"".concat(colorKey, "-").concat(shade, "\" not found"));
|
|
997
|
+
}
|
|
998
|
+
return convertColorValueToNumber(colorValue);
|
|
999
|
+
}
|
|
1000
|
+
var colorToConvert = palette[color];
|
|
1001
|
+
if (isValidColor(colorToConvert)) {
|
|
1002
|
+
return convertColorValueToNumber(colorToConvert);
|
|
1003
|
+
}
|
|
1004
|
+
throw new Error("Color token \"".concat(color, "\" not found"));
|
|
1005
|
+
};
|
|
1006
|
+
var api = {
|
|
1007
|
+
rgb: rgb,
|
|
1008
|
+
hex: hex,
|
|
1009
|
+
black: function () { return rgb('black'); },
|
|
1010
|
+
white: function () { return rgb('white'); },
|
|
1011
|
+
slate: function (shade) { return rgb("slate-".concat(shade)); },
|
|
1012
|
+
gray: function (shade) { return rgb("gray-".concat(shade)); },
|
|
1013
|
+
zinc: function (shade) { return rgb("zinc-".concat(shade)); },
|
|
1014
|
+
neutral: function (shade) { return rgb("neutral-".concat(shade)); },
|
|
1015
|
+
stone: function (shade) { return rgb("stone-".concat(shade)); },
|
|
1016
|
+
red: function (shade) { return rgb("red-".concat(shade)); },
|
|
1017
|
+
orange: function (shade) { return rgb("orange-".concat(shade)); },
|
|
1018
|
+
amber: function (shade) { return rgb("amber-".concat(shade)); },
|
|
1019
|
+
yellow: function (shade) { return rgb("yellow-".concat(shade)); },
|
|
1020
|
+
lime: function (shade) { return rgb("lime-".concat(shade)); },
|
|
1021
|
+
green: function (shade) { return rgb("green-".concat(shade)); },
|
|
1022
|
+
emerald: function (shade) { return rgb("emerald-".concat(shade)); },
|
|
1023
|
+
teal: function (shade) { return rgb("teal-".concat(shade)); },
|
|
1024
|
+
cyan: function (shade) { return rgb("cyan-".concat(shade)); },
|
|
1025
|
+
sky: function (shade) { return rgb("sky-".concat(shade)); },
|
|
1026
|
+
blue: function (shade) { return rgb("blue-".concat(shade)); },
|
|
1027
|
+
indigo: function (shade) { return rgb("indigo-".concat(shade)); },
|
|
1028
|
+
violet: function (shade) { return rgb("violet-".concat(shade)); },
|
|
1029
|
+
purple: function (shade) { return rgb("purple-".concat(shade)); },
|
|
1030
|
+
fuchsia: function (shade) { return rgb("fuchsia-".concat(shade)); },
|
|
1031
|
+
pink: function (shade) { return rgb("pink-".concat(shade)); },
|
|
1032
|
+
rose: function (shade) { return rgb("rose-".concat(shade)); },
|
|
1033
|
+
blackHex: function () { return hex('black'); },
|
|
1034
|
+
whiteHex: function () { return hex('white'); },
|
|
1035
|
+
slateHex: function (shade) { return hex("slate-".concat(shade)); },
|
|
1036
|
+
grayHex: function (shade) { return hex("gray-".concat(shade)); },
|
|
1037
|
+
zincHex: function (shade) { return hex("zinc-".concat(shade)); },
|
|
1038
|
+
neutralHex: function (shade) { return hex("neutral-".concat(shade)); },
|
|
1039
|
+
stoneHex: function (shade) { return hex("stone-".concat(shade)); },
|
|
1040
|
+
redHex: function (shade) { return hex("red-".concat(shade)); },
|
|
1041
|
+
orangeHex: function (shade) { return hex("orange-".concat(shade)); },
|
|
1042
|
+
amberHex: function (shade) { return hex("amber-".concat(shade)); },
|
|
1043
|
+
yellowHex: function (shade) { return hex("yellow-".concat(shade)); },
|
|
1044
|
+
limeHex: function (shade) { return hex("lime-".concat(shade)); },
|
|
1045
|
+
greenHex: function (shade) { return hex("green-".concat(shade)); },
|
|
1046
|
+
emeraldHex: function (shade) { return hex("emerald-".concat(shade)); },
|
|
1047
|
+
tealHex: function (shade) { return hex("teal-".concat(shade)); },
|
|
1048
|
+
cyanHex: function (shade) { return hex("cyan-".concat(shade)); },
|
|
1049
|
+
skyHex: function (shade) { return hex("sky-".concat(shade)); },
|
|
1050
|
+
blueHex: function (shade) { return hex("blue-".concat(shade)); },
|
|
1051
|
+
indigoHex: function (shade) { return hex("indigo-".concat(shade)); },
|
|
1052
|
+
violetHex: function (shade) { return hex("violet-".concat(shade)); },
|
|
1053
|
+
purpleHex: function (shade) { return hex("purple-".concat(shade)); },
|
|
1054
|
+
fuchsiaHex: function (shade) { return hex("fuchsia-".concat(shade)); },
|
|
1055
|
+
pinkHex: function (shade) { return hex("pink-".concat(shade)); },
|
|
1056
|
+
roseHex: function (shade) { return hex("rose-".concat(shade)); },
|
|
1057
|
+
};
|
|
1058
|
+
return api;
|
|
1059
|
+
};
|
|
1060
|
+
/**
|
|
1061
|
+
* Convenience instance using only the default palette tokens (no theme).
|
|
1062
|
+
*
|
|
1063
|
+
* @example
|
|
1064
|
+
* Color.rgb('emerald-400')
|
|
1065
|
+
* Color.hex('black')
|
|
1066
|
+
*/
|
|
1067
|
+
// eslint-disable-next-line no-redeclare
|
|
1068
|
+
var Color = createColor({});
|
|
1069
|
+
|
|
1070
|
+
/**
|
|
1071
|
+
* Default mapping of font size keys to their pixel values in pixels
|
|
1072
|
+
*/
|
|
1073
|
+
/** Default font-size scale mapping (in pixels). */
|
|
1074
|
+
var fontSizeMap = {
|
|
1075
|
+
xs: 12,
|
|
1076
|
+
sm: 14,
|
|
1077
|
+
base: 16,
|
|
1078
|
+
lg: 18,
|
|
1079
|
+
xl: 20,
|
|
1080
|
+
'2xl': 24,
|
|
1081
|
+
'3xl': 30,
|
|
1082
|
+
'4xl': 36,
|
|
1083
|
+
'5xl': 48,
|
|
1084
|
+
'6xl': 60,
|
|
1085
|
+
'7xl': 72,
|
|
1086
|
+
'8xl': 96,
|
|
1087
|
+
'9xl': 128,
|
|
1088
|
+
};
|
|
1089
|
+
/**
|
|
1090
|
+
* Creates a font size conversion API with optional custom font sizes
|
|
1091
|
+
* @template T - Optional custom font size map type
|
|
1092
|
+
* @param themeFontSizes - Optional custom font size mappings to extend defaults
|
|
1093
|
+
* @returns Font size conversion API
|
|
1094
|
+
*/
|
|
1095
|
+
/**
|
|
1096
|
+
* Create a font-size API bound to an optional custom map.
|
|
1097
|
+
* @example
|
|
1098
|
+
* const f = createFontSize({ xxl: 28 });
|
|
1099
|
+
* f.css('xxl'); // '28px'
|
|
1100
|
+
*/
|
|
1101
|
+
var createFontSize = function (themeFontSizes) {
|
|
1102
|
+
var fontmap = __assign(__assign({}, fontSizeMap), themeFontSizes);
|
|
1103
|
+
return {
|
|
1104
|
+
px: function (key) {
|
|
1105
|
+
var value = fontmap[key];
|
|
1106
|
+
if (typeof value === 'number') {
|
|
1107
|
+
return value;
|
|
1108
|
+
}
|
|
1109
|
+
return 0;
|
|
1110
|
+
},
|
|
1111
|
+
rem: function (key) {
|
|
1112
|
+
var value = fontmap[key];
|
|
1113
|
+
if (typeof value === 'number') {
|
|
1114
|
+
return value / 16;
|
|
1115
|
+
}
|
|
1116
|
+
return 0;
|
|
1117
|
+
},
|
|
1118
|
+
css: function (key) {
|
|
1119
|
+
var value = fontmap[key];
|
|
1120
|
+
if (typeof value === 'number') {
|
|
1121
|
+
return "".concat(value, "px");
|
|
1122
|
+
}
|
|
1123
|
+
return '0px';
|
|
1124
|
+
},
|
|
1125
|
+
};
|
|
1126
|
+
};
|
|
1127
|
+
// Convenience instance using default font sizes (no theme)
|
|
1128
|
+
var FontSize = createFontSize(undefined);
|
|
1129
|
+
|
|
1130
|
+
var fontMap = {
|
|
1131
|
+
primary: 'Inter, system-ui, sans-serif',
|
|
1132
|
+
secondary: 'Roboto, Arial, sans-serif',
|
|
1133
|
+
monospace: 'Fira Code, Consolas, monospace',
|
|
1134
|
+
display: 'Poppins, Inter, sans-serif',
|
|
1135
|
+
};
|
|
1136
|
+
var createFont = function (fonts, fontSizes) {
|
|
1137
|
+
var map = __assign(__assign({}, fontMap), fonts);
|
|
1138
|
+
var fontSizeApi = createFontSize(fontSizes);
|
|
1139
|
+
var getFamily = function (key) {
|
|
1140
|
+
if (key.includes('.')) {
|
|
1141
|
+
var _a = key.split('.'), short = _a[1];
|
|
1142
|
+
if (short && typeof map[short] === 'string') {
|
|
1143
|
+
return map[short];
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
return typeof map[key] === 'string' ? map[key] : key;
|
|
1147
|
+
};
|
|
1148
|
+
return {
|
|
1149
|
+
size: function (key) {
|
|
1150
|
+
var _a;
|
|
1151
|
+
return (_a = fontSizeApi.px(key)) !== null && _a !== void 0 ? _a : 0;
|
|
1152
|
+
},
|
|
1153
|
+
format: function (_a) {
|
|
1154
|
+
var _b;
|
|
1155
|
+
var size = _a.size, family = _a.family;
|
|
1156
|
+
var sizePx = (_b = fontSizeApi.px(size)) !== null && _b !== void 0 ? _b : 0;
|
|
1157
|
+
return "".concat(sizePx, "px '").concat(getFamily(family), "'");
|
|
1158
|
+
},
|
|
1159
|
+
family: function (key) { return getFamily(key); },
|
|
1160
|
+
getAvailableFonts: function () {
|
|
1161
|
+
return Array.from(new Set(__spreadArray(__spreadArray([], Object.keys(fontMap), true), Object.keys(map), true)));
|
|
1162
|
+
},
|
|
1163
|
+
};
|
|
1164
|
+
};
|
|
1165
|
+
|
|
1166
|
+
/**
|
|
1167
|
+
* Mapping of radius keys to their pixel values
|
|
1168
|
+
*/
|
|
1169
|
+
/** Default radius scale mapping (in pixels). */
|
|
1170
|
+
var radiusMap = {
|
|
1171
|
+
none: 0,
|
|
1172
|
+
sm: 2,
|
|
1173
|
+
default: 4,
|
|
1174
|
+
md: 6,
|
|
1175
|
+
lg: 8,
|
|
1176
|
+
xl: 12,
|
|
1177
|
+
'2xl': 16,
|
|
1178
|
+
'3xl': 24,
|
|
1179
|
+
full: 9999,
|
|
1180
|
+
};
|
|
1181
|
+
/**
|
|
1182
|
+
* Create a radius API bound to an optional theme radius map.
|
|
1183
|
+
* @example
|
|
1184
|
+
* const r = createRadius({ card: 12 });
|
|
1185
|
+
* r.css('card'); // '12px'
|
|
1186
|
+
*/
|
|
1187
|
+
var createRadius = function (themeRadius) {
|
|
1188
|
+
var map = __assign(__assign({}, radiusMap), themeRadius);
|
|
1189
|
+
var get = function (key) {
|
|
1190
|
+
return typeof map[key] === 'number' ? map[key] : 0;
|
|
1191
|
+
};
|
|
1192
|
+
return {
|
|
1193
|
+
px: function (key) {
|
|
1194
|
+
return get(key);
|
|
1195
|
+
},
|
|
1196
|
+
rem: function (key) {
|
|
1197
|
+
return get(key) / 16;
|
|
1198
|
+
},
|
|
1199
|
+
css: function (key) {
|
|
1200
|
+
return "".concat(get(key), "px");
|
|
1201
|
+
},
|
|
1202
|
+
};
|
|
1203
|
+
};
|
|
1204
|
+
/** Convenience instance using default radius map (no theme). */
|
|
1205
|
+
var Radius = createRadius(undefined);
|
|
1206
|
+
|
|
1207
|
+
/** Default shadow presets. */
|
|
1208
|
+
var defaultShadowMap = {
|
|
1209
|
+
sm: { blur: 2, offsetX: 1, offsetY: 1, alpha: 0.15 },
|
|
1210
|
+
md: { blur: 4, offsetX: 2, offsetY: 2, alpha: 0.2 },
|
|
1211
|
+
lg: { blur: 6, offsetX: 4, offsetY: 4, alpha: 0.25 },
|
|
1212
|
+
xl: { blur: 8, offsetX: 6, offsetY: 6, alpha: 0.3 },
|
|
1213
|
+
'2xl': { blur: 12, offsetX: 8, offsetY: 8, alpha: 0.35 },
|
|
1214
|
+
inner: { blur: 4, offsetX: -2, offsetY: -2, alpha: 0.2 },
|
|
1215
|
+
};
|
|
1216
|
+
/**
|
|
1217
|
+
* Create a shadow API bound to an optional effects map.
|
|
1218
|
+
* @example
|
|
1219
|
+
* const sh = createShadow({ glow: { blur: 8, offsetX: 0, offsetY: 0, alpha: .6 } });
|
|
1220
|
+
* sh.get('glow');
|
|
1221
|
+
*/
|
|
1222
|
+
var createShadow = function (effects) {
|
|
1223
|
+
var map = __assign(__assign({}, defaultShadowMap), effects);
|
|
1224
|
+
var getConfig = function (key) {
|
|
1225
|
+
var cfg = map[key];
|
|
1226
|
+
if (cfg && typeof cfg === 'object')
|
|
1227
|
+
return cfg;
|
|
1228
|
+
return defaultShadowMap['md'];
|
|
1229
|
+
};
|
|
1230
|
+
return {
|
|
1231
|
+
get: function (key) { return getConfig(key); },
|
|
1232
|
+
};
|
|
1233
|
+
};
|
|
1234
|
+
/** Convenience instance using default shadows (no theme). */
|
|
1235
|
+
var Shadow = createShadow(undefined);
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* Spacing scale mapping following Tailwind's spacing scale.
|
|
1239
|
+
* Values are in pixels, with a base unit of 4px (1 = 4px).
|
|
1240
|
+
*/
|
|
1241
|
+
var spacingMap = {
|
|
1242
|
+
'0': 0,
|
|
1243
|
+
px: 1,
|
|
1244
|
+
'0.5': 2,
|
|
1245
|
+
'1': 4,
|
|
1246
|
+
'1.5': 6,
|
|
1247
|
+
'2': 8,
|
|
1248
|
+
'2.5': 10,
|
|
1249
|
+
'3': 12,
|
|
1250
|
+
'3.5': 14,
|
|
1251
|
+
'4': 16,
|
|
1252
|
+
'5': 20,
|
|
1253
|
+
'6': 24,
|
|
1254
|
+
'7': 28,
|
|
1255
|
+
'8': 32,
|
|
1256
|
+
'9': 36,
|
|
1257
|
+
'10': 40,
|
|
1258
|
+
'11': 44,
|
|
1259
|
+
'12': 48,
|
|
1260
|
+
'14': 56,
|
|
1261
|
+
'16': 64,
|
|
1262
|
+
'20': 80,
|
|
1263
|
+
'24': 96,
|
|
1264
|
+
'28': 112,
|
|
1265
|
+
'32': 128,
|
|
1266
|
+
'36': 144,
|
|
1267
|
+
'40': 160,
|
|
1268
|
+
'44': 176,
|
|
1269
|
+
'48': 192,
|
|
1270
|
+
'52': 208,
|
|
1271
|
+
'56': 224,
|
|
1272
|
+
'60': 240,
|
|
1273
|
+
'64': 256,
|
|
1274
|
+
'72': 288,
|
|
1275
|
+
'80': 320,
|
|
1276
|
+
'96': 384,
|
|
1277
|
+
};
|
|
1278
|
+
/**
|
|
1279
|
+
* Create a spacing API bound to an optional theme spacing map.
|
|
1280
|
+
* @example
|
|
1281
|
+
* const s = createSpacing({ gutter: 24 });
|
|
1282
|
+
* s.px('gutter'); // 24
|
|
1283
|
+
*/
|
|
1284
|
+
var createSpacing = function (themeSpacing) {
|
|
1285
|
+
var map = __assign(__assign({}, spacingMap), themeSpacing);
|
|
1286
|
+
var get = function (key) {
|
|
1287
|
+
return typeof map[key] === 'number' ? map[key] : 0;
|
|
1288
|
+
};
|
|
1289
|
+
return {
|
|
1290
|
+
px: function (key) {
|
|
1291
|
+
return get(key);
|
|
1292
|
+
},
|
|
1293
|
+
rem: function (key) {
|
|
1294
|
+
return get(key) / 16;
|
|
1295
|
+
},
|
|
1296
|
+
css: function (key) {
|
|
1297
|
+
return "".concat(get(key), "px");
|
|
1298
|
+
},
|
|
1299
|
+
};
|
|
1300
|
+
};
|
|
1301
|
+
/** Convenience instance using default spacing map (no theme). */
|
|
1302
|
+
var Spacing = createSpacing(undefined);
|
|
1303
|
+
|
|
1304
|
+
/**
|
|
1305
|
+
* Example theme configurations with structured design tokens
|
|
1306
|
+
*/
|
|
1307
|
+
var defaultLightTheme = {
|
|
1308
|
+
fonts: {
|
|
1309
|
+
primary: 'Inter, system-ui, sans-serif',
|
|
1310
|
+
secondary: 'Roboto, Arial, sans-serif',
|
|
1311
|
+
monospace: 'Fira Code, Consolas, monospace',
|
|
1312
|
+
display: 'Poppins, Inter, sans-serif',
|
|
1313
|
+
},
|
|
1314
|
+
fontSizes: __assign({}, fontSizeMap),
|
|
1315
|
+
colors: {
|
|
1316
|
+
// Primary colors
|
|
1317
|
+
primary: 'blue-600',
|
|
1318
|
+
secondary: 'gray-600',
|
|
1319
|
+
// Semantic colors
|
|
1320
|
+
success: 'green-500',
|
|
1321
|
+
warning: 'yellow-500',
|
|
1322
|
+
error: 'red-500',
|
|
1323
|
+
info: 'blue-400',
|
|
1324
|
+
// Background colors
|
|
1325
|
+
background: 'white',
|
|
1326
|
+
// Text colors
|
|
1327
|
+
text: 'gray-900',
|
|
1328
|
+
// UI elements
|
|
1329
|
+
shadow: 'black',
|
|
1330
|
+
overlay: 'black',
|
|
1331
|
+
},
|
|
1332
|
+
spacing: __assign({}, spacingMap),
|
|
1333
|
+
typography: {
|
|
1334
|
+
heading: {
|
|
1335
|
+
fontSize: '2xl',
|
|
1336
|
+
fontFamily: 'fonts.display',
|
|
1337
|
+
fontWeight: 600,
|
|
1338
|
+
lineHeight: 1.2,
|
|
1339
|
+
},
|
|
1340
|
+
'heading-large': {
|
|
1341
|
+
fontSize: '4xl',
|
|
1342
|
+
fontFamily: 'fonts.display',
|
|
1343
|
+
fontWeight: 700,
|
|
1344
|
+
lineHeight: 1.1,
|
|
1345
|
+
},
|
|
1346
|
+
body: {
|
|
1347
|
+
fontSize: 'base',
|
|
1348
|
+
fontFamily: 'fonts.primary',
|
|
1349
|
+
fontWeight: 400,
|
|
1350
|
+
lineHeight: 1.5,
|
|
1351
|
+
},
|
|
1352
|
+
caption: {
|
|
1353
|
+
fontSize: 'sm',
|
|
1354
|
+
fontFamily: 'fonts.primary',
|
|
1355
|
+
fontWeight: 400,
|
|
1356
|
+
lineHeight: 1.4,
|
|
1357
|
+
},
|
|
1358
|
+
},
|
|
1359
|
+
// TODO: Check this implementation
|
|
1360
|
+
effects: {
|
|
1361
|
+
'shadow-sm': {
|
|
1362
|
+
blur: 2,
|
|
1363
|
+
offsetY: 1,
|
|
1364
|
+
color: 'colors.shadow',
|
|
1365
|
+
alpha: 0.05,
|
|
1366
|
+
},
|
|
1367
|
+
'shadow-md': {
|
|
1368
|
+
blur: 4,
|
|
1369
|
+
offsetY: 2,
|
|
1370
|
+
color: 'colors.shadow',
|
|
1371
|
+
alpha: 0.1,
|
|
1372
|
+
},
|
|
1373
|
+
'shadow-lg': {
|
|
1374
|
+
blur: 8,
|
|
1375
|
+
offsetY: 4,
|
|
1376
|
+
color: 'colors.shadow',
|
|
1377
|
+
alpha: 0.1,
|
|
1378
|
+
},
|
|
1379
|
+
},
|
|
1380
|
+
custom: {},
|
|
1381
|
+
};
|
|
1382
|
+
var defaultDarkTheme = {
|
|
1383
|
+
fonts: {
|
|
1384
|
+
primary: 'Inter, system-ui, sans-serif',
|
|
1385
|
+
secondary: 'Roboto, Arial, sans-serif',
|
|
1386
|
+
monospace: 'Fira Code, Consolas, monospace',
|
|
1387
|
+
display: 'Poppins, Inter, sans-serif',
|
|
1388
|
+
},
|
|
1389
|
+
fontSizes: __assign({}, fontSizeMap),
|
|
1390
|
+
radius: __assign({}, radiusMap),
|
|
1391
|
+
colors: {
|
|
1392
|
+
// Primary colors
|
|
1393
|
+
primary: 'blue-400',
|
|
1394
|
+
secondary: 'gray-400',
|
|
1395
|
+
// Semantic colors
|
|
1396
|
+
success: 'green-400',
|
|
1397
|
+
warning: 'yellow-400',
|
|
1398
|
+
error: 'red-400',
|
|
1399
|
+
info: 'blue-300',
|
|
1400
|
+
// Background colors
|
|
1401
|
+
background: 'gray-900',
|
|
1402
|
+
// Text colors
|
|
1403
|
+
text: 'white',
|
|
1404
|
+
// UI elements
|
|
1405
|
+
shadow: 'black',
|
|
1406
|
+
overlay: 'black',
|
|
1407
|
+
},
|
|
1408
|
+
spacing: __assign({}, spacingMap),
|
|
1409
|
+
typography: {
|
|
1410
|
+
heading: {
|
|
1411
|
+
fontSize: '2xl',
|
|
1412
|
+
fontFamily: 'fonts.display',
|
|
1413
|
+
fontWeight: 600,
|
|
1414
|
+
lineHeight: 1.2,
|
|
1415
|
+
},
|
|
1416
|
+
'heading-large': {
|
|
1417
|
+
fontSize: '4xl',
|
|
1418
|
+
fontFamily: 'fonts.display',
|
|
1419
|
+
fontWeight: 700,
|
|
1420
|
+
lineHeight: 1.1,
|
|
1421
|
+
},
|
|
1422
|
+
body: {
|
|
1423
|
+
fontSize: 'base',
|
|
1424
|
+
fontFamily: 'fonts.primary',
|
|
1425
|
+
fontWeight: 400,
|
|
1426
|
+
lineHeight: 1.5,
|
|
1427
|
+
},
|
|
1428
|
+
caption: {
|
|
1429
|
+
fontSize: 'sm',
|
|
1430
|
+
fontFamily: 'fonts.primary',
|
|
1431
|
+
fontWeight: 400,
|
|
1432
|
+
lineHeight: 1.4,
|
|
1433
|
+
},
|
|
1434
|
+
},
|
|
1435
|
+
effects: {
|
|
1436
|
+
'shadow-sm': {
|
|
1437
|
+
blur: 2,
|
|
1438
|
+
offsetY: 1,
|
|
1439
|
+
color: 'colors.shadow',
|
|
1440
|
+
alpha: 0.1,
|
|
1441
|
+
},
|
|
1442
|
+
'shadow-md': {
|
|
1443
|
+
blur: 4,
|
|
1444
|
+
offsetY: 2,
|
|
1445
|
+
color: 'colors.shadow',
|
|
1446
|
+
alpha: 0.15,
|
|
1447
|
+
},
|
|
1448
|
+
'shadow-lg': {
|
|
1449
|
+
blur: 8,
|
|
1450
|
+
offsetY: 4,
|
|
1451
|
+
color: 'colors.shadow',
|
|
1452
|
+
alpha: 0.2,
|
|
1453
|
+
},
|
|
1454
|
+
},
|
|
1455
|
+
custom: {},
|
|
1456
|
+
};
|
|
1457
|
+
|
|
1458
|
+
var createTheme = function (theme) {
|
|
1459
|
+
return merge({}, defaultLightTheme, theme);
|
|
1460
|
+
};
|
|
1461
|
+
|
|
1462
|
+
var PHASER_WIND_KEY = 'pw';
|
|
1463
|
+
/**
|
|
1464
|
+
* Phaser Wind Plugin class that manages theme configuration
|
|
1465
|
+
* @extends Plugins.BasePlugin
|
|
1466
|
+
*/
|
|
1467
|
+
var PhaserWindPlugin = /** @class */ (function (_super) {
|
|
1468
|
+
__extends(PhaserWindPlugin, _super);
|
|
1469
|
+
/**
|
|
1470
|
+
* Creates an instance of PhaserWindPlugin
|
|
1471
|
+
* @param pluginManager - Phaser plugin manager instance
|
|
1472
|
+
*/
|
|
1473
|
+
function PhaserWindPlugin(pluginManager) {
|
|
1474
|
+
var _this = _super.call(this, pluginManager) || this;
|
|
1475
|
+
_this.colorInstance = null;
|
|
1476
|
+
_this.fontSizeInstance = null;
|
|
1477
|
+
_this.spacingInstance = null;
|
|
1478
|
+
_this.radiusInstance = null;
|
|
1479
|
+
_this.fontInstance = null;
|
|
1480
|
+
_this.shadowInstance = null;
|
|
1481
|
+
_this.theme = defaultLightTheme;
|
|
1482
|
+
return _this;
|
|
1483
|
+
}
|
|
1484
|
+
/**
|
|
1485
|
+
* Initializes the plugin with theme configuration
|
|
1486
|
+
* @param theme - Custom theme configuration
|
|
1487
|
+
* @param darkMode - Whether to use dark mode theme when no custom theme provided
|
|
1488
|
+
* @example
|
|
1489
|
+
* ```typescript
|
|
1490
|
+
* const game = new Phaser.Game({
|
|
1491
|
+
* plugins: {
|
|
1492
|
+
* global: [
|
|
1493
|
+
* {
|
|
1494
|
+
* key: PHASER_WIND_KEY,
|
|
1495
|
+
* plugin: PhaserWindPlugin,
|
|
1496
|
+
* mapping: PHASER_WIND_KEY,
|
|
1497
|
+
* data: { theme: defaultLightTheme }
|
|
1498
|
+
* },
|
|
1499
|
+
* ],
|
|
1500
|
+
* },
|
|
1501
|
+
* });
|
|
1502
|
+
* ```
|
|
1503
|
+
*/
|
|
1504
|
+
PhaserWindPlugin.prototype.init = function (_a) {
|
|
1505
|
+
var theme = _a.theme, _b = _a.darkMode, darkMode = _b === void 0 ? false : _b;
|
|
1506
|
+
if (!theme) {
|
|
1507
|
+
this.theme = darkMode
|
|
1508
|
+
? defaultDarkTheme
|
|
1509
|
+
: defaultLightTheme;
|
|
1510
|
+
return;
|
|
1511
|
+
}
|
|
1512
|
+
else {
|
|
1513
|
+
this.theme = theme;
|
|
1514
|
+
}
|
|
1515
|
+
this.colorInstance = createColor(this.theme.colors);
|
|
1516
|
+
this.fontSizeInstance = createFontSize(this.theme.fontSizes);
|
|
1517
|
+
this.spacingInstance = createSpacing(this.theme.spacing);
|
|
1518
|
+
this.radiusInstance = createRadius(this.theme.radius);
|
|
1519
|
+
this.fontInstance = createFont(this.theme.fonts, this.theme.fontSizes);
|
|
1520
|
+
this.shadowInstance = createShadow(this.theme.effects);
|
|
1521
|
+
};
|
|
1522
|
+
/**
|
|
1523
|
+
* Returns the current theme configuration
|
|
1524
|
+
* @returns Current BaseThemeConfig
|
|
1525
|
+
*/
|
|
1526
|
+
PhaserWindPlugin.prototype.getTheme = function () {
|
|
1527
|
+
return this.theme;
|
|
1528
|
+
};
|
|
1529
|
+
Object.defineProperty(PhaserWindPlugin.prototype, "color", {
|
|
1530
|
+
get: function () {
|
|
1531
|
+
return this.colorInstance;
|
|
1532
|
+
},
|
|
1533
|
+
enumerable: false,
|
|
1534
|
+
configurable: true
|
|
1535
|
+
});
|
|
1536
|
+
Object.defineProperty(PhaserWindPlugin.prototype, "fontSize", {
|
|
1537
|
+
get: function () {
|
|
1538
|
+
return this.fontSizeInstance;
|
|
1539
|
+
},
|
|
1540
|
+
enumerable: false,
|
|
1541
|
+
configurable: true
|
|
1542
|
+
});
|
|
1543
|
+
Object.defineProperty(PhaserWindPlugin.prototype, "spacing", {
|
|
1544
|
+
get: function () {
|
|
1545
|
+
return this.spacingInstance;
|
|
1546
|
+
},
|
|
1547
|
+
enumerable: false,
|
|
1548
|
+
configurable: true
|
|
1549
|
+
});
|
|
1550
|
+
Object.defineProperty(PhaserWindPlugin.prototype, "radius", {
|
|
1551
|
+
get: function () {
|
|
1552
|
+
return this.radiusInstance;
|
|
1553
|
+
},
|
|
1554
|
+
enumerable: false,
|
|
1555
|
+
configurable: true
|
|
1556
|
+
});
|
|
1557
|
+
Object.defineProperty(PhaserWindPlugin.prototype, "font", {
|
|
1558
|
+
get: function () {
|
|
1559
|
+
return this.fontInstance;
|
|
1560
|
+
},
|
|
1561
|
+
enumerable: false,
|
|
1562
|
+
configurable: true
|
|
1563
|
+
});
|
|
1564
|
+
Object.defineProperty(PhaserWindPlugin.prototype, "shadow", {
|
|
1565
|
+
get: function () {
|
|
1566
|
+
return this.shadowInstance;
|
|
1567
|
+
},
|
|
1568
|
+
enumerable: false,
|
|
1569
|
+
configurable: true
|
|
1570
|
+
});
|
|
1571
|
+
return PhaserWindPlugin;
|
|
1572
|
+
}(phaser.Plugins.BasePlugin));
|
|
1573
|
+
|
|
1574
|
+
var SceneWithPhaserWind = /** @class */ (function (_super) {
|
|
1575
|
+
__extends(SceneWithPhaserWind, _super);
|
|
1576
|
+
/**
|
|
1577
|
+
*
|
|
1578
|
+
* @param config The scene key or scene specific configuration settings.
|
|
1579
|
+
*/
|
|
1580
|
+
function SceneWithPhaserWind(config) {
|
|
1581
|
+
return _super.call(this, config) || this;
|
|
1582
|
+
}
|
|
1583
|
+
return SceneWithPhaserWind;
|
|
1584
|
+
}(Phaser.Scene));
|
|
1585
|
+
|
|
1586
|
+
exports.Color = Color;
|
|
1587
|
+
exports.Column = Column;
|
|
1588
|
+
exports.DEFAULT_GAP = DEFAULT_GAP;
|
|
1589
|
+
exports.FontSize = FontSize;
|
|
1590
|
+
exports.PHASER_WIND_KEY = PHASER_WIND_KEY;
|
|
1591
|
+
exports.PhaserWindPlugin = PhaserWindPlugin;
|
|
1592
|
+
exports.Radius = Radius;
|
|
1593
|
+
exports.Row = Row;
|
|
1594
|
+
exports.SceneWithPhaserWind = SceneWithPhaserWind;
|
|
1595
|
+
exports.Shadow = Shadow;
|
|
1596
|
+
exports.Spacing = Spacing;
|
|
1597
|
+
exports.createColor = createColor;
|
|
1598
|
+
exports.createFont = createFont;
|
|
1599
|
+
exports.createFontSize = createFontSize;
|
|
1600
|
+
exports.createRadius = createRadius;
|
|
1601
|
+
exports.createShadow = createShadow;
|
|
1602
|
+
exports.createSpacing = createSpacing;
|
|
1603
|
+
exports.createTheme = createTheme;
|
|
1604
|
+
exports.defaultDarkTheme = defaultDarkTheme;
|
|
1605
|
+
exports.defaultLightTheme = defaultLightTheme;
|
|
1606
|
+
exports.defaultShadowMap = defaultShadowMap;
|
|
1607
|
+
exports.fontMap = fontMap;
|
|
1608
|
+
exports.fontSizeMap = fontSizeMap;
|
|
1609
|
+
exports.getDisplayHeightOf = getDisplayHeightOf;
|
|
1610
|
+
exports.getDisplayWidthOf = getDisplayWidthOf;
|
|
1611
|
+
exports.getNormalizedOriginOf = getNormalizedOriginOf;
|
|
1612
|
+
exports.isValidColor = isValidColor;
|
|
1613
|
+
exports.merge = merge;
|
|
1614
|
+
exports.mergeDeep = mergeDeep;
|
|
1615
|
+
exports.palette = palette;
|
|
1616
|
+
exports.radiusMap = radiusMap;
|
|
1617
|
+
exports.spacingMap = spacingMap;
|
|
1618
|
+
|
|
1619
|
+
}));
|