perfect-gui 4.12.0 → 4.12.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.
@@ -49,7 +49,7 @@ export default /* css */ `
49
49
  position: absolute;
50
50
  top: -25%;
51
51
  left: 0;
52
- height: 150%;
52
+ height: 100%;
53
53
  background: var(--color-accent);
54
54
  width: 0;
55
55
  }
@@ -59,8 +59,8 @@ export default /* css */ `
59
59
  }
60
60
 
61
61
  .p-gui__slider-handle {
62
- width: 15px;
63
- height: 8px;
62
+ width: 9px;
63
+ height: 9px;
64
64
  position: absolute;
65
65
  top: 50%;
66
66
  left: 0;
@@ -0,0 +1,34 @@
1
+ export default /* css */ `
2
+ .p-gui__toggle {
3
+ color: var(--color-text-dark);
4
+ transition: var(--transition) background, var(--transition) color;
5
+ }
6
+
7
+ .p-gui__toggle:hover {
8
+ background: rgba(255, 255, 255, .1);
9
+ color: var(--color-text-light);
10
+ }
11
+
12
+ .p-gui__folder .p-gui__toggle {
13
+ margin-inline: 0;
14
+ }
15
+
16
+ .p-gui__toggle-checkbox {
17
+ width: 10px;
18
+ height: 10px;
19
+ background-color: rgba(255, 255, 255, 0.1);
20
+ position: absolute;
21
+ top: 0;
22
+ right: 10px;
23
+ bottom: 0;
24
+ margin: auto;
25
+ border-radius: 2px;
26
+ pointer-events: none;
27
+ transition: .5s all ease;
28
+ }
29
+
30
+ .p-gui__toggle-checkbox--active {
31
+ background-color: #ddd;
32
+ box-shadow: 0 0 5px #ddd;
33
+ }
34
+ `;
@@ -1,7 +1,7 @@
1
1
  import _button from "./_button.css.js"
2
2
  import _slider from "./_slider.css.js"
3
3
  import _list from "./_list.css.js"
4
- import _switch from "./_switch.css.js"
4
+ import _toggle from "./_toggle.css.js"
5
5
  import _color from "./_color.css.js"
6
6
  import _vector2 from "./_vector2.css.js"
7
7
  import _image from "./_image.css.js"
@@ -16,7 +16,7 @@ export default function( position_type ) {
16
16
  return /* css */`
17
17
  .p-gui {
18
18
  --main-border-radius: 3px;
19
- --color-bg: #121212;
19
+ --color-bg: #161616;
20
20
  --color-border: #222222;
21
21
  --color-border-2: transparent;
22
22
  --color-text-light: #ffffff;
@@ -117,7 +117,7 @@ export default function( position_type ) {
117
117
 
118
118
  .p-gui__slider,
119
119
  .p-gui__button,
120
- .p-gui__switch,
120
+ .p-gui__toggle,
121
121
  .p-gui__list,
122
122
  .p-gui__vector2,
123
123
  .p-gui__color {
@@ -134,7 +134,7 @@ export default function( position_type ) {
134
134
 
135
135
  .p-gui__slider:hover,
136
136
  .p-gui__button:hover,
137
- .p-gui__switch:hover,
137
+ .p-gui__toggle:hover,
138
138
  .p-gui__list:hover,
139
139
  .p-gui__vector2:hover,
140
140
  .p-gui__color:hover {
@@ -147,7 +147,7 @@ export default function( position_type ) {
147
147
 
148
148
  ${ _list }
149
149
 
150
- ${ _switch }
150
+ ${ _toggle }
151
151
 
152
152
  ${ _slider }
153
153
 
package/vite.config.js CHANGED
@@ -5,7 +5,8 @@ export default defineConfig({
5
5
  build: {
6
6
  lib: {
7
7
  entry: resolve(__dirname, "src/index.js"),
8
- name: "Perfect GUI"
8
+ name: "Perfect GUI",
9
+ formats: ["es"]
9
10
  },
10
11
  minify: true
11
12
  },
@@ -1,536 +0,0 @@
1
- (function(y,A){typeof exports=="object"&&typeof module<"u"?module.exports=A():typeof define=="function"&&define.amd?define(A):(y=typeof globalThis<"u"?globalThis:y||self,y["Perfect GUI"]=A())})(this,function(){"use strict";class y{constructor(e,t={},i){if(this.parent=e,this.propReferences=[],typeof t!="object")throw Error(`[GUI] slider() first parameter must be an object. Received: ${typeof t}.`);let l=typeof t.label=="string"&&t.label||" ";this.isObject=!1;let s=null;this.obj=t.obj,this.prop=t.prop;let o=typeof t.value=="number"?t.value:null;if(this.min=t.min??0,this.max=t.max??1,this.step=t.step||(this.max-this.min)/100,this.decimals=this.parent._countDecimals(this.step),this.callback=typeof i=="function"?i:null,o!==null)(this.prop!=null||this.obj!=null)&&console.warn('[GUI] slider() "obj" and "prop" parameters are ignored when a "value" parameter is used.');else if(this.prop!=null&&this.obj!=null){if(typeof this.prop!="string")throw Error(`[GUI] slider() "prop" parameter must be an string. Received: ${typeof this.prop}.`);if(typeof this.obj!="object")throw Error(`[GUI] slider() "obj" parameter must be an object. Received: ${typeof this.obj}.`);l==" "&&(l=this.prop),s=this.propReferences.push(this.obj[this.prop])-1,this.isObject=!0}else(this.prop!=null&&this.obj==null||this.prop==null&&this.obj!=null)&&console.warn('[GUI] slider() "obj" and "prop" parameters must be used together.'),o=(this.max-this.min)/2;const r=typeof t.tooltip=="string"?t.tooltip:t.tooltip===!0?l:null;this.imageContainer=null;const n=document.createElement("div");n.className="p-gui__slider",r&&n.setAttribute("title",r);const c=document.createElement("div");c.className="p-gui__slider-name",c.textContent=l,n.append(c),this.ctrlDiv=document.createElement("div"),this.ctrlDiv.className="p-gui__slider-ctrl",this.ctrlDiv.setAttribute("type","range"),this.ctrlDiv.setAttribute("min",this.min),this.ctrlDiv.setAttribute("max",this.max),n.append(this.ctrlDiv);const a=document.createElement("div");return a.className="p-gui__slider-bar",this.ctrlDiv.append(a),this.handle=document.createElement("div"),this.handle.className="p-gui__slider-handle",this.ctrlDiv.append(this.handle),this.filling=document.createElement("div"),this.filling.className="p-gui__slider-filling",a.append(this.filling),this.valueInput=document.createElement("input"),this.valueInput.className="p-gui__slider-value",this.valueInput.value=this.isObject?this.obj[this.prop]:o,n.append(this.valueInput),setTimeout(()=>{const d=this.handle.offsetWidth;this.handle.position=this._mapLinear(this.valueInput.value,this.min,this.max,d/2,88-d/2),this.handle.position=Math.min(this.handle.position,88-d/2),this.handle.position=Math.max(this.handle.position,d/2),this.handle.style.transform=`translate(-50%, -50%) translateX(${this.handle.position}px)`,this.filling.style.width=`${this.handle.position}px`},0),this.valueInput.addEventListener("change",()=>{this._updateHandlePositionFromValue(),this._triggerCallbacks()}),this.ctrlDiv.addEventListener("pointerdown",d=>{this.ctrlDiv.pointerDown=!0,this.ctrlDiv.prevPosition=d.clientX,this._updateHandlePositionFromPointer(d,!0)}),window.addEventListener("pointerup",d=>{this.ctrlDiv.pointerDown=!1}),window.addEventListener("pointermove",d=>{this.ctrlDiv.pointerDown&&(this.ctrlDiv.pointerDelta=d.clientX-this.ctrlDiv.prevPosition,this._updateHandlePositionFromPointer(d))}),this.isObject&&Object.defineProperty(this.obj,this.prop,{set:d=>{this.propReferences[s]=d,this.valueInput.value=d,this._updateHandlePositionFromValue(),this.callback&&this.callback(parseFloat(this.valueInput.value))},get:()=>this.propReferences[s]}),n}_updateHandlePositionFromPointer(e,t=!1){const i=this.ctrlDiv.offsetWidth,l=this.handle.offsetWidth,s=e.clientX-this.ctrlDiv.prevPosition,o=parseFloat(this.valueInput.value);let r;t?r=e.offsetX:r=this.handle.position+s,r=Math.max(l/2,Math.min(r,i-l/2));let n=this.min+(this.max-this.min)*(r-l/2)/(i-l);n>o?n=this._quantizeFloor(n,this.step):n=this._quantizeCeil(n,this.step),n=parseFloat(n.toFixed(9));const c=parseFloat((o+this.step).toFixed(9)),a=parseFloat((o-this.step).toFixed(9));(n>=c||n<=a)&&(n=n.toFixed(this.decimals),this.valueInput.value=n,this.ctrlDiv.prevPosition=e.clientX,this.handle.style.transform=`translate(-50%, -50%) translateX(${r}px)`,this.handle.position=r,this.filling.style.width=this.handle.position+"px",this._triggerCallbacks())}_updateHandlePositionFromValue(){const e=this.ctrlDiv.offsetWidth,t=this.handle.offsetWidth;let i=this._mapLinear(this.valueInput.value,this.min,this.max,t/2,e-t/2);i=Math.max(t/2,Math.min(i,e-t/2)),this.handle.style.transform=`translate(-50%, -50%) translateX(${i}px)`,this.handle.position=i,this.filling.style.width=this.handle.position+"px"}_triggerCallbacks(){this.isObject?this.obj[this.prop]=parseFloat(this.valueInput.value):this.callback&&this.callback(parseFloat(this.valueInput.value)),this.parent.onUpdate?this.parent.onUpdate():this.parent.isFolder&&this.parent.firstParent.onUpdate&&this.parent.firstParent.onUpdate()}_mapLinear(e,t,i,l,s){return l+(e-t)*(s-l)/(i-t)}_quantize(e,t){return t*Math.round(e/t)}_quantizeCeil(e,t){return t*Math.ceil(e/t)}_quantizeFloor(e,t){return t*Math.floor(e/t)}}const A=`
2
- .p-gui__button {
3
- background: var(--color-accent);
4
- text-align: center;
5
- color: var(--color-bg);
6
- border: none;
7
- border: 1px solid transparent;
8
- box-sizing: border-box;
9
- transition: var(--transition) background, var(--transition) border-color;
10
- }
11
-
12
- .p-gui__button:hover {
13
- background: var(--color-accent-hover);
14
- border-color: rgba(255, 255, 255, 0.2);
15
- }
16
-
17
- .p-gui__folder .p-gui__button {
18
- margin-inline: 0;
19
- }
20
- `,O=`
21
- .p-gui__slider {
22
- position: relative;
23
- min-height: 14px;
24
- display: flex;
25
- align-items: center;
26
- justify-content: space-between;
27
- gap: 10px;
28
- color: var(--color-text-dark);
29
- transition: color var(--transition);
30
- padding: 3px;
31
- }
32
-
33
- .p-gui__slider:hover {
34
- color: var(--color-text-light);
35
- }
36
-
37
- .p-gui__slider-name {
38
- width: 50%;
39
- text-overflow: ellipsis;
40
- overflow: hidden;
41
- }
42
-
43
- .p-gui__slider-ctrl {
44
- -webkit-appearance: none;
45
- padding: 0;
46
- font: inherit;
47
- outline: none;
48
- box-sizing: border-box;
49
- cursor: pointer;
50
- position: relative;
51
- right: 0;
52
- height: 14px;
53
- margin: 0 0 0 auto;
54
- width: 37%;
55
- }
56
-
57
- .p-gui__slider-bar {
58
- position: absolute;
59
- top: 50%;
60
- left: 0;
61
- height: 2px;
62
- background: rgba(255, 255, 255, .2);
63
- width: 100%;
64
- transform: translateY(-50%);
65
- }
66
-
67
- .p-gui__slider-filling {
68
- position: absolute;
69
- top: -25%;
70
- left: 0;
71
- height: 150%;
72
- background: var(--color-accent);
73
- width: 0;
74
- }
75
-
76
- .p-gui__slider:hover .p-gui__slider-filling {
77
- background: var(--color-accent-hover);
78
- }
79
-
80
- .p-gui__slider-handle {
81
- width: 15px;
82
- height: 8px;
83
- position: absolute;
84
- top: 50%;
85
- left: 0;
86
- border-radius: 2px;
87
- transform: translate(-50%, -50%);
88
- pointer-events: none;
89
- background: var(--color-text-dark);
90
- box-shadow: 0 0 2px rgba(0, 0, 0, .5);
91
- }
92
-
93
- .p-gui__slider:hover .p-gui__slider-handle {
94
- background: var(--color-text-light);
95
- }
96
-
97
- .p-gui__slider-value {
98
- display: inline-block;
99
- right: 7px;
100
- width: 13%;
101
- border: none;
102
- color: white;
103
- border-radius: 2px;
104
- background: rgba(255, 255, 255, 0.1);
105
- padding: 2px 4px;
106
- color: inherit;
107
- }
108
-
109
- .p-gui__slider-value:focus {
110
- outline: none;
111
- }
112
- `,$=`
113
- .p-gui__list {
114
- cursor: default;
115
- color: var(--color-text-dark);
116
- transition: var(--transition) color;
117
- }
118
-
119
- .p-gui__list:hover {
120
- color: var(--color-text-light);
121
- }
122
-
123
- .p-gui__list-dropdown {
124
- background: rgba(255, 255, 255,.05);
125
- color: white;
126
- padding: 0 12px 0 5px;
127
- top: 0px;
128
- }
129
-
130
- .p-gui__list-dropdown {
131
- position: absolute;
132
- right: 5px;
133
- top: 0;
134
- bottom: 0;
135
- margin: auto;
136
- height: calc(100% - 4px);
137
- cursor: pointer;
138
- border-radius: 3px;
139
- border: 1px solid var(--color-border-2);
140
- outline: none;
141
-
142
- option {
143
- background: white;
144
- color: black;
145
- }
146
- }
147
-
148
- .p-gui__list-dropdown:hover {
149
- background: rgba(255, 255, 255, .1);
150
- }
151
- `,D=`
152
- .p-gui__switch {
153
- background: rgba(255, 255, 255, .05);
154
- color: var(--color-text-dark);
155
- transition: var(--transition) background, var(--transition) color;
156
- }
157
-
158
- .p-gui__switch:hover {
159
- background: rgba(255, 255, 255, .1);
160
- color: var(--color-text-light);
161
- }
162
-
163
- .p-gui__folder .p-gui__switch {
164
- margin-inline: 0;
165
- }
166
-
167
- .p-gui__switch-checkbox {
168
- width: 5px;
169
- height: 5px;
170
- background-color: rgba(0, 0, 0, .5);
171
- border: 1px solid grey;
172
- position: absolute;
173
- top: 0;
174
- right: 10px;
175
- bottom: 0;
176
- margin: auto;
177
- border-radius: 50%;
178
- pointer-events: none;
179
- }
180
-
181
- .p-gui__switch-checkbox--active {
182
- background-color: #00ff89;
183
- box-shadow: 0 0 7px #00ff89;
184
- }
185
- `,F=`
186
- .p-gui__color {
187
- cursor: default;
188
- color: var(--color-text-dark);
189
- transition: var(--transition) color;
190
- }
191
-
192
- .p-gui__color:hover {
193
- color: var(--color-text-light);
194
- }
195
-
196
- .p-gui__color-picker {
197
- position: absolute;
198
- right: 5px;
199
- top: 0;
200
- bottom: 0;
201
- margin: auto;
202
- height: calc(100% - 4px);
203
- cursor: pointer;
204
- border-radius: 3px;
205
- border: 1px solid var(--color-border-2);
206
- outline: none;
207
- -webkit-appearance: none;
208
- padding: 0;
209
- background-color: transparent;
210
- border: 1px solid #222222;
211
- overflow: hidden;
212
- }
213
-
214
- .p-gui__color-picker::-webkit-color-swatch-wrapper {
215
- padding: 0;
216
- }
217
- .p-gui__color-picker::-webkit-color-swatch {
218
- border: none;
219
- }
220
- `,L=`
221
- .p-gui__vector2 {
222
- background: transparent;
223
- aspect-ratio: 1;
224
- padding-bottom: 0;
225
- color: var(--color-text-dark);
226
- }
227
-
228
- .p-gui__vector2:hover {
229
- color: var(--color-text-light);
230
- }
231
-
232
- .p-gui__vector2-area {
233
- position: relative;
234
- background: rgba(0, 0, 0, .3);
235
- margin-top: 8px;
236
- width: 100%;
237
- height: calc(100% - 28px);
238
- touch-action: none;
239
- }
240
-
241
- .p-gui__vector2-line {
242
- position: absolute;
243
- background: white;
244
- opacity: .3;
245
- pointer-events: none;
246
- }
247
-
248
- .p-gui__vector2-line-x {
249
- width: 100%;
250
- height: 1px;
251
- left: 0;
252
- top: 50%;
253
- transform: translateY(-50%);
254
- }
255
-
256
- .p-gui__vector2-line-y {
257
- width: 1px;
258
- height: 100%;
259
- top: 0;
260
- left: 50%;
261
- transform: translateX(-50%);
262
- }
263
-
264
- .p-gui__vector2-dot {
265
- position: absolute;
266
- top: 0;
267
- left: 0;
268
- width: 8px;
269
- height: 8px;
270
- border-radius: 50%;
271
- background: #d5d5d5;
272
- border: 2px solid #ff9999;
273
- transform: translate(-50%, -50%);
274
- pointer-events: none;
275
- }
276
-
277
- .p-gui__vector-value {
278
- display: inline-block;
279
- right: 7px;
280
- position: absolute;
281
- }
282
- `,H=`
283
- .p-gui__image-container {
284
- width: 100%;
285
- padding: 3px;
286
- display: flex;
287
- justify-content: flex-start;
288
- flex-wrap: wrap;
289
- box-sizing: border-box;
290
- }
291
-
292
- .p-gui__image {
293
- background-size: cover;
294
- cursor: pointer;
295
- position: relative;
296
- margin: 1px 2.5px 19px 2.5px;
297
- border-radius: var(--main-border-radius);
298
- flex: 0 0 calc(33.333% - 5px);
299
- height: 90px;
300
- background-position: center;
301
- color: var(--color-text-dark);
302
- transition: var(--transition) color;
303
- }
304
-
305
- .p-gui__image:hover {
306
- color: var(--color-text-light);
307
- }
308
-
309
- .p-gui__image::after {
310
- position: absolute;
311
- top: 0;
312
- left: 0;
313
- width: 100%;
314
- height: 100%;
315
- content: '';
316
- border: 1px solid transparent;
317
- box-sizing: border-box;
318
- border-radius: var(--main-border-radius);
319
- transition: var(--transition) border-color;
320
- }
321
- .p-gui__image--selected::after {
322
- border-color: #06FF89;
323
- }
324
-
325
- .p-gui__image-text {
326
- position: absolute;
327
- bottom: -15px;
328
- text-shadow: 0 -1px 0 #111;
329
- white-space: nowrap;
330
- width: 100%;
331
- overflow: hidden;
332
- text-overflow: ellipsis;
333
-
334
- }
335
- `,N=`
336
- .p-gui__folder {
337
- width: 100%;
338
- position: relative;
339
- background: #333333;
340
- overflow: auto;
341
- margin-bottom: 2px;
342
- display: flex;
343
- flex-wrap: wrap;
344
- border: 1px solid var(--color-border-2);
345
- padding: 0 2px 0 3px;
346
- border-radius: var(--main-border-radius);
347
- box-sizing: border-box;
348
- border-left: 1px solid #bbbbbb;
349
- }
350
-
351
- .p-gui__folder--first {
352
- margin-top: 0;
353
- }
354
-
355
- .p-gui__folder--closed {
356
- height: 25px;
357
- overflow: hidden;
358
- }
359
-
360
- .p-gui__folder-header {
361
- padding: 5px 3px;
362
- background-color: rgba(0, 0, 0, .5);
363
- color: white;
364
- cursor: pointer;
365
- width: 100%;
366
- margin: 0 -2px 2px -3px;
367
- }
368
-
369
- .p-gui__folder-header:hover {
370
- background-color: rgba(0, 0, 0, .75);
371
- }
372
-
373
- .p-gui__folder-arrow {
374
- width: 8px;
375
- height: 8px;
376
- display: inline-block;
377
- background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAHlBMVEUAAAD///////////////////////////////////8kfJuVAAAACXRSTlMA9Z1fCdMo1yxEJnA0AAAAK0lEQVQI12PABlRgjKkJUMZMYRhjpgqMAZSEMICSaIzpDWiKhdENhEhgAgATSg5jyWnYewAAAABJRU5ErkJggg==);
378
- background-size: contain;
379
- margin-right: 5px;
380
- transform: rotate(90deg)
381
- }
382
-
383
- .p-gui__folder--closed .p-gui__folder-arrow {
384
- transform: rotate(0deg);
385
- }
386
- `;function M(C){return`
387
- .p-gui {
388
- --main-border-radius: 3px;
389
- --color-bg: #121212;
390
- --color-border: #222222;
391
- --color-border-2: transparent;
392
- --color-text-light: #ffffff;
393
- --color-text-dark: #bbbbbb;
394
- --color-accent: #bbbbbb;
395
- --color-accent-hover: #dddddd;
396
- --transition: .1s linear;
397
-
398
- position: ${C};
399
- top: 0;
400
- left: 0;
401
- transform: translate3d(0,0,0);
402
- padding-top: 21px;
403
- padding-inline: 3px;
404
- background: var(--color-bg);
405
- display: block;
406
- justify-content: center;
407
- flex-wrap: wrap;
408
- font-family: "Arial Rounded MT Bold", Arial, sans-serif;
409
- width: 290px;
410
- overflow: auto;
411
- box-shadow: 0 0 2px black;
412
- box-sizing: border-box;
413
- z-index: 99999;
414
- user-select: none;
415
- cursor: auto;
416
- border-radius: var(--main-border-radius);
417
- border: 1px solid var(--color-border);
418
- line-height: normal;
419
- transition: var(--transition) opacity;
420
- }
421
-
422
- .p-gui:hover {
423
- opacity: 1!important;
424
- }
425
-
426
- .p-gui * {
427
- font-size: 11px;
428
- }
429
-
430
- .p-gui::-webkit-scrollbar,
431
- .p-gui *::-webkit-scrollbar {
432
- width: 10px;
433
- }
434
-
435
- .p-gui::-webkit-scrollbar-track,
436
- .p-gui *::-webkit-scrollbar-track {
437
- background: #2f2f2f;
438
- border-radius: 3px;
439
- }
440
-
441
- .p-gui::-webkit-scrollbar-thumb,
442
- .p-gui *::-webkit-scrollbar-thumb {
443
- background: #757576;
444
- border-radius: 10px;
445
- box-sizing: border-box;
446
- border: 1px solid #2f2f2f;
447
- }
448
-
449
- .p-gui--collapsed {
450
- height: 0;
451
- padding: 21px 10px 0 10px;
452
- overflow: hidden;
453
- }
454
-
455
- .p-gui__header {
456
- position: absolute;
457
- top: 0;
458
- left: 0;
459
- width: 100%;
460
- height: 20px;
461
- background-color: rgba(0, 0, 0, .8);
462
- cursor: grab;
463
- color: grey;
464
- font-size: 10px;
465
- line-height: 20px;
466
- padding-left: 12px;
467
- box-sizing: border-box;
468
- touch-action: none;
469
- }
470
-
471
- .p-gui__header-close {
472
- width: 20px;
473
- height: 20px;
474
- position: absolute;
475
- top: 0;
476
- right: 5px;
477
- cursor: pointer;
478
- background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUAQMAAAC3R49OAAAABlBMVEUAAAD///+l2Z/dAAAAAXRSTlMAQObYZgAAABFJREFUCNdjIAb8//8BjIkAAOrOBd3TR0jRAAAAAElFTkSuQmCC);
479
- background-size: 50% 50%;
480
- background-position: center;
481
- background-repeat: no-repeat;
482
- }
483
-
484
- .p-gui--collapsed .p-gui__header-close {
485
- background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUAQMAAAC3R49OAAAABlBMVEUAAAD///+l2Z/dAAAAAXRSTlMAQObYZgAAABVJREFUCNdjYEhgIIj///8AwsSoBQD43QydY5mb0QAAAABJRU5ErkJggg==);
486
- }
487
-
488
- .p-gui__slider,
489
- .p-gui__button,
490
- .p-gui__switch,
491
- .p-gui__list,
492
- .p-gui__vector2,
493
- .p-gui__color {
494
- width: 100%;
495
- padding: 5px 3px;
496
- cursor: pointer;
497
- position: relative;
498
- box-sizing: border-box;
499
- margin-block: 3px;
500
- border: 1px solid var(--color-border-2);
501
- border-radius: var(--main-border-radius);
502
- transition: var(--transition) border-color;
503
- }
504
-
505
- .p-gui__slider:hover,
506
- .p-gui__button:hover,
507
- .p-gui__switch:hover,
508
- .p-gui__list:hover,
509
- .p-gui__vector2:hover,
510
- .p-gui__color:hover {
511
- border-color: rgba(255,255,255,.2);
512
- }
513
-
514
- ${A}
515
-
516
- ${H}
517
-
518
- ${$}
519
-
520
- ${D}
521
-
522
- ${O}
523
-
524
- ${F}
525
-
526
- ${L}
527
-
528
- ${N}
529
- `}class E{constructor(e={}){if(this.firstParent=this,e.container?(this.container=typeof e.container=="string"?document.querySelector(e.container):e.container,this.position_type="absolute"):(this.container=document.body,this.position_type="fixed"),this.propReferences=[],this.folders=[],e.isFolder){this._folderConstructor(e.folderOptions);return}typeof e.onUpdate=="function"&&(this.onUpdate=e.onUpdate),this.label=e!=null&&typeof e.label=="string"?e.label:"",this.backgroundColor=e.color||null,this.opacity=e.opacity||1,this.container==document.body?this.maxHeight=window.innerHeight:this.maxHeight=Math.min(this.container.clientHeight,window.innerHeight),e.maxHeight&&(this.initMaxHeight=e.maxHeight,this.maxHeight=Math.min(this.initMaxHeight,this.maxHeight)),this.screenCorner=this._parseScreenCorner(e.position),window.perfectGUI||(window.perfectGUI={}),window.perfectGUI.instanceCounter==null?window.perfectGUI.instanceCounter=0:window.perfectGUI.instanceCounter++,this.instanceId=window.perfectGUI.instanceCounter,this.wrapperWidth=e.width||290,this.stylesheet=document.createElement("style"),this.stylesheet.setAttribute("type","text/css"),this.stylesheet.setAttribute("id","lm-gui-stylesheet"),document.head.append(this.stylesheet),this.instanceId==0&&this._addStyles(`${M(this.position_type)}`),this._styleInstance(),this._addWrapper(),this.wrapper.setAttribute("data-corner-x",this.screenCorner.x),this.wrapper.setAttribute("data-corner-y",this.screenCorner.y),e.autoRepositioning!=!1&&window.addEventListener("resize",this._handleResize.bind(this)),this._handleResize(),this.hasBeenDragged=!1,e.draggable==!0&&this._makeDraggable(),this.closed=!1,e.closed&&this.toggleClose()}_styleInstance(){let e=this._getScrollbarWidth(this.container);if(this.screenCorner.x=="left"?this.xOffset=0:this.xOffset=this.container.clientWidth-this.wrapperWidth-e,this.instanceId>0){let t=this.container.querySelectorAll(".p-gui");for(let i=0;i<t.length;i++)this.screenCorner.y==t[i].dataset.cornerY&&(this.screenCorner.x=="left"&&t[i].dataset.cornerX=="left"?this.xOffset+=t[i].offsetWidth:this.screenCorner.x=="right"&&t[i].dataset.cornerX=="right"&&(this.xOffset-=t[i].offsetWidth))}this.yOffset=0,this.position={prevX:this.xOffset,prevY:this.yOffset,x:this.xOffset,y:this.yOffset},this._addStyles(`#p-gui-${this.instanceId} {
530
- width: ${this.wrapperWidth}px;
531
- max-height: ${this.maxHeight}px;
532
- transform: translate3d(${this.xOffset}px,${this.yOffset}px,0);
533
- ${this.screenCorner.y=="top"?"":"top: auto; bottom: 0;"}
534
- ${this.backgroundColor?"background: "+this.backgroundColor+";":""}
535
- opacity: ${this.opacity};
536
- }`)}_folderConstructor(e){this.wrapper=e.wrapper,this.isFolder=!0,this.parent=e.parent,this.firstParent=e.firstParent}_parseScreenCorner(e){let t={x:"right",y:"top"};return e==null||(typeof e!="string"&&console.error("[perfect-gui] Position must be a string."),e.includes("left")&&(t.x="left"),e.includes("bottom")&&(t.y="bottom")),t}_getScrollbarWidth(e){return e===document.body?window.innerWidth-document.documentElement.clientWidth:e.offsetWidth-e.clientWidth}_handleResize(){if(this.container==document.body?this.maxHeight=window.innerHeight:this.maxHeight=Math.min(this.container.clientHeight,window.innerHeight),this.initMaxHeight&&(this.maxHeight=Math.min(this.initMaxHeight,this.maxHeight)),this.wrapper.style.maxHeight=this.maxHeight+"px",this.hasBeenDragged)return;let e=this._getScrollbarWidth(this.container);if(this.xOffset=this.screenCorner.x=="left"?0:this.container.clientWidth-this.wrapperWidth-e,this.instanceId>0){let t=this.container.querySelectorAll(`.p-gui:not(#${this.wrapper.id}):not([data-dragged])`);for(let i=0;i<t.length&&!(parseInt(t[i].id.replace("p-gui-",""))>this.instanceId);i++)this.screenCorner.y==t[i].dataset.cornerY&&(this.screenCorner.x=="left"&&t[i].dataset.cornerX=="left"?this.xOffset+=t[i].offsetWidth:this.screenCorner.x=="right"&&t[i].dataset.cornerX=="right"&&(this.xOffset-=t[i].offsetWidth))}this.position={prevX:this.xOffset,prevY:this.yOffset,x:this.xOffset,y:this.yOffset},this.wrapper.style.transform=`translate3d(${this.position.x}px, ${this.position.y}px, 0)`}_addStyles(e){this.stylesheet.innerHTML+=e}_addWrapper(){this.wrapper=document.createElement("div"),this.wrapper.id="p-gui-"+this.instanceId,this.wrapper.className="p-gui",this.wrapper.setAttribute("data-lenis-prevent",""),this.container.append(this.wrapper),this.header=document.createElement("div"),this.header.className="p-gui__header",this.header.textContent=this.label,this.header.style=`${this.backgroundColor?"border-color: "+this.backgroundColor+";":""}`,this.wrapper.append(this.header);const e=document.createElement("div");e.className="p-gui__header-close",e.addEventListener("click",this.toggleClose.bind(this)),this.header.append(e)}button(e,t){let i="";typeof e!="string"?typeof e=="object"&&(e!=null&&e.hasOwnProperty("label"))?i=e.label==""?" ":e.label:i=" ":i=e==""?" ":e;const l=typeof e.tooltip=="string"?e.tooltip:e.tooltip===!0?i:null;this.imageContainer=null;const s=document.createElement("div");s.className="p-gui__button",s.textContent=i,l&&s.setAttribute("title",l),s.addEventListener("click",()=>{t&&t(),this.onUpdate?this.onUpdate():this.isFolder&&this.firstParent.onUpdate&&this.firstParent.onUpdate()}),this.wrapper.append(s),typeof e.color=="string"&&(s.style.setProperty("--color-accent",e.color),s.style.setProperty("--color-accent-hover",e.hoverColor||e.color))}image(e={},t){if(typeof e!="object")throw Error(`[GUI] image() first parameter must be an object. Received: ${typeof e}.`);let i;if(typeof e.path=="string")i=e.path;else throw typeof e.path==null?Error("[GUI] image() path must be provided."):Error("[GUI] image() path must be a string.");let l=i.replace(/^.*[\\\/]/,""),s;e.label==null?s=l:s=typeof e.label=="string"&&e.label||" ";const o=typeof e.tooltip=="string"?e.tooltip:e.tooltip===!0?s:null,r=e.selected===!0,n=e.selectionBorder!==!1;let c="";e.width&&(typeof e.width=="number"&&(e.width+="px"),c+=`flex: 0 0 calc(${e.width} - 5px); `),e.height&&(typeof e.height=="number"&&(e.height+="px"),c+=`height: ${e.height}; `),this.imageContainer||(this.imageContainer=document.createElement("div"),this.imageContainer.className="p-gui__image-container",this.wrapper.append(this.imageContainer));const a=document.createElement("div");a.className="p-gui__image",a.style="background-image: url("+i+"); "+c,o&&a.setAttribute("title",o),this.imageContainer.append(a),r&&n&&a.classList.add("p-gui__image--selected");const d=document.createElement("div");return d.className="p-gui__image-text",d.textContent=s,a.append(d),a.addEventListener("click",()=>{let p=a.parentElement.querySelectorAll(".p-gui__image--selected");for(let h=0;h<p.length;h++)p[h].classList.remove("p-gui__image--selected");n&&a.classList.add("p-gui__image--selected"),typeof t=="function"&&t({path:i,text:s}),this.onUpdate?this.onUpdate():this.isFolder&&this.firstParent.onUpdate&&this.firstParent.onUpdate()}),a}slider(e={},t){const i=new y(this,e,t);this.wrapper.append(i)}toggle(e={},t){if(typeof e!="object")throw Error(`[GUI] toggle() first parameter must be an object. Received: ${typeof e}.`);let i=typeof e.label=="string"&&e.label||" ",l=!1,s=null,o=e.obj,r=e.prop,n=typeof e.value=="boolean"?e.value:null;if(n!==null)(r!=null||o!=null)&&console.warn('[GUI] toggle() "obj" and "prop" parameters are ignored when a "value" parameter is used.');else if(r!=null&&o!=null){if(typeof r!="string")throw Error(`[GUI] toggle() "prop" parameter must be an string. Received: ${typeof r}.`);if(typeof o!="object")throw Error(`[GUI] toggle() "obj" parameter must be an object. Received: ${typeof o}.`);i==" "&&(i=r),s=this.propReferences.push(o[r])-1,l=!0}else(r!=null&&o==null||r==null&&o==null)&&console.warn('[GUI] toggle() "obj" and "prop" parameters must be used together.');const c=typeof e.tooltip=="string"?e.tooltip:e.tooltip===!0?i:null;this.imageContainer=null;const a=document.createElement("div");a.textContent=i,a.className="p-gui__switch",c&&a.setAttribute("title",c),this.wrapper.append(a),a.addEventListener("click",h=>{const u=h.target.childNodes[1];let f=!0;u.classList.contains("p-gui__switch-checkbox--active")&&(f=!1),u.classList.toggle("p-gui__switch-checkbox--active"),l?o[r]=f:typeof t=="function"&&t(f),this.onUpdate?this.onUpdate():this.isFolder&&this.firstParent.onUpdate&&this.firstParent.onUpdate()});let d=(()=>l?o[r]?" p-gui__switch-checkbox--active":"":n?" p-gui__switch-checkbox--active":"")();const p=document.createElement("div");p.className="p-gui__switch-checkbox"+d,a.append(p),l&&Object.defineProperty(o,r,{set:h=>{this.propReferences[s]=h,h?p.classList.add("p-gui__switch-checkbox--active"):p.classList.remove("p-gui__switch-checkbox--active"),typeof t=="function"&&t(h)},get:()=>this.propReferences[s]})}list(e={},t){if(typeof e!="object")throw Error(`[GUI] list() first parameter must be an object. Received: ${typeof e}.`);let i=typeof e.label=="string"?e.label:" ",l=!1,s=null,o=e.obj,r=e.prop,n=Array.isArray(e.values)?e.values:null,c,a=typeof n[0]!="string";const d=typeof e.tooltip=="string"?e.tooltip:e.tooltip===!0?i:null;if(t=typeof t=="function"?t:null,e.value!==void 0||e.value===void 0&&o===void 0&&r===void 0)(r!=null||o!=null)&&console.warn('[GUI] list() "obj" and "prop" parameters are ignored when a "value" parameter is used.'),c=(()=>{if(!n)return null;if(typeof e.value=="string")return n.indexOf(e.value);if(typeof e.value=="number")return e.value})();else if(r!=null&&o!=null){if(typeof r!="string")throw Error(`[GUI] list() "prop" parameter must be an string. Received: ${typeof r}.`);if(typeof o!="object")throw Error(`[GUI] list() "obj" parameter must be an object. Received: ${typeof o}.`);c=(()=>{if(!n)return null;if(typeof o[r]=="string")return a?n.find(u=>u.value===o[r]).value:n.indexOf(o[r]);if(typeof o[r]=="number")return a?n.find(u=>u.value===o[r]).value:o[r]})(),s=this.propReferences.push(o[r])-1,l=!0}else(r!=null&&o==null||r==null&&o==null)&&console.warn('[GUI] list() "obj" and "prop" parameters must be used together.');this.imageContainer=null;let p=document.createElement("div");p.className="p-gui__list",p.textContent=i,d&&p.setAttribute("title",d),this.wrapper.append(p);let h=document.createElement("select");p.append(h),h.className="p-gui__list-dropdown",h.addEventListener("change",u=>{l?o[r]=u.target.value:t&&t(u.target.value),this.onUpdate?this.onUpdate():this.isFolder&&this.firstParent.onUpdate&&this.firstParent.onUpdate()}),n&&n.forEach((u,f)=>{const g=a?u.label:u,x=a?u.value:u;let v=document.createElement("option");v.setAttribute("value",x),v.textContent=g,h.append(v),(!a&&c==f||a&&c==x)&&v.setAttribute("selected","")}),l&&Object.defineProperty(o,r,{set:u=>{let f,g,x;a?(x=n.find(m=>m.value==u),g=(x==null?void 0:x.value)||n[0].value,f=n.indexOf(x)):(typeof u=="string"&&(f=n.indexOf(u),g=u),typeof u=="number"&&(f=u,g=n[u])),this.propReferences[s]=a?g:u;const v=h.querySelector("[selected]");v&&v.removeAttribute("selected"),h.querySelectorAll("option")[f].setAttribute("selected",""),typeof t=="function"&&t(a?x:g,f)},get:()=>this.propReferences[s]})}color(e={},t){if(typeof e!="object")throw Error(`[GUI] color() first parameter must be an object. Received: ${typeof e}.`);let i=typeof e.label=="string"&&e.label||" ",l=!1,s=null,o=e.obj,r=e.prop,n;const c=typeof e.tooltip=="string"?e.tooltip:e.tooltip===!0?i:null;if(typeof e.value=="string"&&(e.value.length!=7||e.value[0]!="#"?console.error(`[GUI] color() 'value' parameter must be an hexadecimal string in the format "#ffffff". Received: "${e.value}".`):n=e.value),n||(n="#000000"),e.value!==void 0)(r!=null||o!=null)&&console.warn('[GUI] color() "obj" and "prop" parameters are ignored when a "value" parameter is used.');else if(r!=null&&o!=null){if(typeof r!="string")throw Error(`[GUI] color() "prop" parameter must be an string. Received: ${typeof r}.`);if(typeof o!="object")throw Error(`[GUI] color() "obj" parameter must be an object. Received: ${typeof o}.`);i==" "&&(i=r),s=this.propReferences.push(o[r])-1,l=!0}else(r!=null&&o==null||r==null&&o==null)&&console.warn('[GUI] color() "obj" and "prop" parameters must be used together.');this.imageContainer=null;const a=document.createElement("div");a.className="p-gui__color",a.textContent=i,c&&a.setAttribute("title",c),this.wrapper.append(a);const d=document.createElement("input");d.className="p-gui__color-picker",d.setAttribute("type","color"),d.value=n,a.append(d),typeof t=="function"&&d.addEventListener("input",()=>{l?o[r]=d.value:typeof t=="function"&&t(d.value),this.onUpdate?this.onUpdate():this.isFolder&&this.firstParent.onUpdate&&this.firstParent.onUpdate()}),l&&Object.defineProperty(o,r,{set:p=>{this.propReferences[s]=p,d.value=p,typeof t=="function"&&t(p)},get:()=>this.propReferences[s]})}vector2(e={},t){if(typeof e!="object")throw Error(`[GUI] vector2() first parameter must be an object. Received: ${typeof e}.`);let i=typeof e.label=="string"&&e.label||" ";const l=e.x.min??0,s=e.x.max??1,o=e.y.min??0,r=e.y.max??1,n=e.x.step||(s-l)/100,c=e.y.step||(r-o)/100,a=this._countDecimals(n),d=this._countDecimals(c),p=e.x.obj,h=e.x.prop,u=this.propReferences.push(p[h])-1,f=e.y.obj,g=e.y.prop,x=this.propReferences.push(f[g])-1,v=typeof e.tooltip=="string"?e.tooltip:e.tooltip===!0?i:null;t=typeof t=="function"?t:null,this.imageContainer=null;const m=document.createElement("div");m.className="p-gui__vector2",m.textContent=i,v&&m.setAttribute("title",v),this.wrapper.append(m);const k=document.createElement("div");k.className="p-gui__vector-value",k.textContent=p[h]+", "+f[g],m.append(k);const b=document.createElement("div");b.className="p-gui__vector2-area",m.append(b),b.addEventListener("click",_=>{const j=parseFloat(this._mapLinear(_.offsetX,0,b.clientWidth,l,s)),I=parseFloat(this._mapLinear(_.offsetY,0,b.clientHeight,r,o));p[h]=j.toFixed(a),f[g]=I.toFixed(d),t&&t(p[h],p[g]),this.onUpdate?this.onUpdate():this.isFolder&&this.firstParent.onUpdate&&this.firstParent.onUpdate()});let U=!1;b.addEventListener("pointerdown",_=>{U=!0}),b.addEventListener("pointerup",()=>{U=!1}),b.addEventListener("pointermove",_=>{if(U){const j=parseFloat(this._mapLinear(_.offsetX,0,b.clientWidth,l,s)),I=parseFloat(this._mapLinear(_.offsetY,0,b.clientHeight,r,o));p[h]=j.toFixed(a),f[g]=I.toFixed(d),t&&t(p[h],p[g]),this.onUpdate?this.onUpdate():this.isFolder&&this.firstParent.onUpdate&&this.firstParent.onUpdate()}});const R=document.createElement("div");R.className="p-gui__vector2-line p-gui__vector2-line-x",b.append(R);const P=document.createElement("div");P.className="p-gui__vector2-line p-gui__vector2-line-y",b.append(P);const w=document.createElement("div");w.className="p-gui__vector2-dot",b.append(w),w.style.left=this._mapLinear(p[h],l,s,0,b.clientWidth)+"px",w.style.top=this._mapLinear(f[g],o,r,b.clientHeight,0)+"px",Object.defineProperty(p,h,{set:_=>{this.propReferences[u]=_,w.style.left=this._mapLinear(_,l,s,0,b.clientWidth)+"px",k.textContent=String(_)+", "+f[g]},get:()=>this.propReferences[u]}),Object.defineProperty(f,g,{set:_=>{this.propReferences[x]=_,w.style.top=this._mapLinear(_,o,r,b.clientHeight,0)+"px",k.textContent=p[h]+", "+String(_)},get:()=>this.propReferences[x]})}folder(e={}){let t=typeof e.closed=="boolean"?e.closed:!1,i=e.label||"",l=e.color||null,s=e.maxHeight||null;this.imageContainer=null;let o="p-gui__folder";this.folders.length==0&&(o+=" p-gui__folder--first"),t&&(o+=" p-gui__folder--closed");let r=l?`background-color: ${l};`:"";r+=s?`max-height: ${s}px;`:"";const n=document.createElement("div");n.className=o,n.style=r,this.wrapper.append(n);const c=document.createElement("div");c.innerHTML=`<span class="p-gui__folder-arrow"></span>${i}`,c.className="p-gui__folder-header",n.append(c),c.addEventListener("click",()=>{n.classList.toggle("p-gui__folder--closed")});let a=new E({isFolder:!0,folderOptions:{wrapper:n,parent:this,firstParent:this.firstParent}});return this.folders.push(a),a}_makeDraggable(){var e=this;this.header.addEventListener("pointerdown",t),this.header.addEventListener("pointerup",l);function t(s){s.preventDefault(),e.position.initX=e.position.x,e.position.initY=e.position.y,e.position.prevX=s.clientX,e.position.prevY=s.clientY,document.addEventListener("pointermove",i)}function i(s){s.preventDefault(),e.hasBeenDragged||(e.hasBeenDragged=!0,e.wrapper.setAttribute("data-dragged","true")),e.position.x=e.position.initX+s.clientX-e.position.prevX,e.position.y=e.position.initY+s.clientY-e.position.prevY,e.wrapper.style.transform="translate3d("+e.position.x+"px,"+e.position.y+"px,0)"}function l(s){document.removeEventListener("pointermove",i)}}toggleClose(){this.closed=!this.closed,this.closed?(this.previousInnerScroll=this.wrapper.scrollTop,this.wrapper.scrollTo(0,0)):this.wrapper.scrollTo(0,this.previousInnerScroll),this.wrapper.classList.toggle("p-gui--collapsed")}kill(){this.wrapper.remove()}_mapLinear(e,t,i,l,s){return l+(e-t)*(s-l)/(i-t)}_countDecimals(e){const t=e.toString(),i=t.indexOf(".");return i===-1?0:t.length-i-1}static registerPlugin(e){for(let t in e)E.prototype[t]=e[t]}}return E});