muigui 0.0.17 → 0.0.20

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.
@@ -1,4 +1,4 @@
1
- /* muigui@0.0.17, license MIT */
1
+ /* muigui@0.0.20, license MIT */
2
2
  var css = {
3
3
  default: `
4
4
  .muigui {
@@ -85,6 +85,7 @@ var css = {
85
85
  font-size: var(--font-size);
86
86
  box-sizing: border-box;
87
87
  line-height: 100%;
88
+ white-space: nowrap;
88
89
  }
89
90
  .muigui * {
90
91
  box-sizing: inherit;
@@ -288,7 +289,7 @@ var css = {
288
289
  }
289
290
  .muigui-closed>.muigui-open-container>* {
290
291
  transition: all 0.1s ease-out;
291
- margin-top: -100%;
292
+ margin-top: -1000%;
292
293
  }
293
294
 
294
295
  /* ---- popdown ---- */
@@ -1208,11 +1209,13 @@ class Button extends Controller {
1208
1209
  }
1209
1210
  name(name) {
1210
1211
  this.#buttonElem.textContent = name;
1212
+ return this;
1211
1213
  }
1212
1214
  setOptions(options) {
1213
1215
  copyExistingProperties(this.#options, options);
1214
1216
  const {name} = this.#options;
1215
1217
  this.#buttonElem.textContent = name;
1218
+ return this;
1216
1219
  }
1217
1220
  }
1218
1221
 
@@ -2620,6 +2623,9 @@ class Canvas extends LabelController {
2620
2623
  get canvas() {
2621
2624
  return this.#canvasElem;
2622
2625
  }
2626
+ listen() {
2627
+ return this;
2628
+ }
2623
2629
  }
2624
2630
 
2625
2631
  class ColorView extends EditView {
@@ -2761,6 +2767,12 @@ class Container extends Controller {
2761
2767
  this.#childDestController = this.#childDestController.parent;
2762
2768
  return this;
2763
2769
  }
2770
+ listen() {
2771
+ this.#controllers.forEach(c => {
2772
+ c.listen();
2773
+ });
2774
+ return this;
2775
+ }
2764
2776
  }
2765
2777
 
2766
2778
  class Folder extends Container {
@@ -3269,11 +3281,22 @@ class Row extends Layout {
3269
3281
  }
3270
3282
  }
3271
3283
 
3284
+ function camelCaseToSnakeCase(id) {
3285
+ return id
3286
+ .replace(/(.)([A-Z][a-z]+)/g, '$1_$2')
3287
+ .replace(/([a-z0-9])([A-Z])/g, '$1_$2')
3288
+ .toLowerCase();
3289
+ }
3290
+
3291
+ function prepName(name) {
3292
+ return camelCaseToSnakeCase(name.toString()).replaceAll('_', ' ');
3293
+ }
3294
+
3272
3295
  class GUIFolder extends Folder {
3273
3296
  add(object, property, ...args) {
3274
3297
  const controller = object instanceof Controller
3275
3298
  ? object
3276
- : createController(object, property, ...args);
3299
+ : createController(object, property, ...args).name(prepName(property));
3277
3300
  return this.addController(controller);
3278
3301
  }
3279
3302
  addCanvas(name) {
@@ -3282,9 +3305,13 @@ class GUIFolder extends Folder {
3282
3305
  addColor(object, property, options = {}) {
3283
3306
  const value = object[property];
3284
3307
  if (hasAlpha(options.format || guessFormat(value))) {
3285
- return this.addController(new ColorChooser(object, property, options));
3308
+ return this
3309
+ .addController(new ColorChooser(object, property, options))
3310
+ .name(prepName(property));
3286
3311
  } else {
3287
- return this.addController(new Color(object, property, options));
3312
+ return this
3313
+ .addController(new Color(object, property, options))
3314
+ .name(prepName(property));
3288
3315
  }
3289
3316
  }
3290
3317
  addDivider() {
@@ -3298,7 +3325,7 @@ class GUIFolder extends Folder {
3298
3325
  }
3299
3326
  addButton(name, fn) {
3300
3327
  const o = {fn};
3301
- return this.add(o, 'fn').name(name);
3328
+ return this.add(o, 'fn').name(prepName(name));
3302
3329
  }
3303
3330
  }
3304
3331