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,7 +1,7 @@
1
1
  export default class Button extends Controller {
2
2
  constructor(object: any, property: any, options?: {});
3
- name(name: any): void;
4
- setOptions(options: any): void;
3
+ name(name: any): this;
4
+ setOptions(options: any): this;
5
5
  #private;
6
6
  }
7
7
  import Controller from './Controller.js';
@@ -1,6 +1,7 @@
1
1
  export default class Canvas extends LabelController {
2
2
  constructor(name: any);
3
3
  get canvas(): HTMLElement;
4
+ listen(): this;
4
5
  #private;
5
6
  }
6
7
  import LabelController from './LabelController.js';
@@ -8,6 +8,7 @@ export default class Container extends Controller {
8
8
  addController(controller: any): any;
9
9
  pushContainer(container: any): any;
10
10
  popContainer(): this;
11
+ listen(): this;
11
12
  #private;
12
13
  }
13
14
  import Controller from './Controller.js';
@@ -1,4 +1,4 @@
1
- /* muigui@0.0.17, license MIT */
1
+ /* muigui@0.0.20, license MIT */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -91,6 +91,7 @@
91
91
  font-size: var(--font-size);
92
92
  box-sizing: border-box;
93
93
  line-height: 100%;
94
+ white-space: nowrap;
94
95
  }
95
96
  .muigui * {
96
97
  box-sizing: inherit;
@@ -294,7 +295,7 @@
294
295
  }
295
296
  .muigui-closed>.muigui-open-container>* {
296
297
  transition: all 0.1s ease-out;
297
- margin-top: -100%;
298
+ margin-top: -1000%;
298
299
  }
299
300
 
300
301
  /* ---- popdown ---- */
@@ -1214,11 +1215,13 @@
1214
1215
  }
1215
1216
  name(name) {
1216
1217
  this.#buttonElem.textContent = name;
1218
+ return this;
1217
1219
  }
1218
1220
  setOptions(options) {
1219
1221
  copyExistingProperties(this.#options, options);
1220
1222
  const {name} = this.#options;
1221
1223
  this.#buttonElem.textContent = name;
1224
+ return this;
1222
1225
  }
1223
1226
  }
1224
1227
 
@@ -2626,6 +2629,9 @@
2626
2629
  get canvas() {
2627
2630
  return this.#canvasElem;
2628
2631
  }
2632
+ listen() {
2633
+ return this;
2634
+ }
2629
2635
  }
2630
2636
 
2631
2637
  class ColorView extends EditView {
@@ -2767,6 +2773,12 @@
2767
2773
  this.#childDestController = this.#childDestController.parent;
2768
2774
  return this;
2769
2775
  }
2776
+ listen() {
2777
+ this.#controllers.forEach(c => {
2778
+ c.listen();
2779
+ });
2780
+ return this;
2781
+ }
2770
2782
  }
2771
2783
 
2772
2784
  class Folder extends Container {
@@ -3275,11 +3287,22 @@
3275
3287
  }
3276
3288
  }
3277
3289
 
3290
+ function camelCaseToSnakeCase(id) {
3291
+ return id
3292
+ .replace(/(.)([A-Z][a-z]+)/g, '$1_$2')
3293
+ .replace(/([a-z0-9])([A-Z])/g, '$1_$2')
3294
+ .toLowerCase();
3295
+ }
3296
+
3297
+ function prepName(name) {
3298
+ return camelCaseToSnakeCase(name.toString()).replaceAll('_', ' ');
3299
+ }
3300
+
3278
3301
  class GUIFolder extends Folder {
3279
3302
  add(object, property, ...args) {
3280
3303
  const controller = object instanceof Controller
3281
3304
  ? object
3282
- : createController(object, property, ...args);
3305
+ : createController(object, property, ...args).name(prepName(property));
3283
3306
  return this.addController(controller);
3284
3307
  }
3285
3308
  addCanvas(name) {
@@ -3288,9 +3311,13 @@
3288
3311
  addColor(object, property, options = {}) {
3289
3312
  const value = object[property];
3290
3313
  if (hasAlpha(options.format || guessFormat(value))) {
3291
- return this.addController(new ColorChooser(object, property, options));
3314
+ return this
3315
+ .addController(new ColorChooser(object, property, options))
3316
+ .name(prepName(property));
3292
3317
  } else {
3293
- return this.addController(new Color(object, property, options));
3318
+ return this
3319
+ .addController(new Color(object, property, options))
3320
+ .name(prepName(property));
3294
3321
  }
3295
3322
  }
3296
3323
  addDivider() {
@@ -3304,7 +3331,7 @@
3304
3331
  }
3305
3332
  addButton(name, fn) {
3306
3333
  const o = {fn};
3307
- return this.add(o, 'fn').name(name);
3334
+ return this.add(o, 'fn').name(prepName(name));
3308
3335
  }
3309
3336
  }
3310
3337