wj-elements 0.1.114 → 0.1.116

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.
@@ -1276,7 +1276,7 @@ class ColorPicker extends WJElement {
1276
1276
  y: this.colorArea.offsetTop
1277
1277
  };
1278
1278
  }
1279
- disconnectedCallback() {
1279
+ beforeDisconnect() {
1280
1280
  this.init = false;
1281
1281
  }
1282
1282
  getPointerPosition(event2) {
@@ -124,10 +124,6 @@ class Dialog extends WJElement {
124
124
  }
125
125
  afterClose() {
126
126
  }
127
- disconnectedCallback() {
128
- event.removeElement(this.button);
129
- event.removeElement(this.dialog);
130
- }
131
127
  }
132
128
  Dialog.define("wje-dialog", Dialog);
133
129
  export {
@@ -612,6 +612,20 @@ const _WJElement = class _WJElement extends HTMLElement {
612
612
  let parts = name.split("-");
613
613
  return [parts.shift(), ...parts.map((n) => n[0].toUpperCase() + n.slice(1))].join("");
614
614
  }
615
+ checkGetterSetter(obj, property) {
616
+ let descriptor = Object.getOwnPropertyDescriptor(obj, property);
617
+ if (descriptor) {
618
+ return {
619
+ hasGetter: typeof descriptor.get === "function" ? descriptor.get : null,
620
+ hasSetter: typeof descriptor.set === "function" ? descriptor.set : null
621
+ };
622
+ }
623
+ let proto = Object.getPrototypeOf(obj);
624
+ if (proto) {
625
+ return this.checkGetterSetter(proto, property);
626
+ }
627
+ return { hasGetter: null, hasSetter: null };
628
+ }
615
629
  /**
616
630
  * Creates one property on this class for every
617
631
  * HTML property defined on the element
@@ -620,13 +634,10 @@ const _WJElement = class _WJElement extends HTMLElement {
620
634
  let attrs = this.getAttributeNames();
621
635
  attrs.forEach((name) => {
622
636
  const sanitizedName = this.sanitizeName(name);
623
- if (sanitizedName in this)
624
- return;
625
- const protoFunc = Object.getOwnPropertyDescriptors(this.__proto__)[sanitizedName];
626
- const func = Object.getOwnPropertyDescriptors(this)[sanitizedName];
637
+ const { hasGetter, hasSetter } = this.checkGetterSetter(this, sanitizedName);
627
638
  Object.defineProperty(this, sanitizedName, {
628
- set: (protoFunc == null ? void 0 : protoFunc.set) ?? (func == null ? void 0 : func.set) ?? ((value) => this.setAttribute(name, value)),
629
- get: (protoFunc == null ? void 0 : protoFunc.get) ?? (func == null ? void 0 : func.get) ?? (() => this.getAttribute(name))
639
+ set: hasSetter ?? ((value) => this.setAttribute(name, value)),
640
+ get: hasGetter ?? (() => this.getAttribute(name))
630
641
  });
631
642
  });
632
643
  }
@@ -255,7 +255,7 @@ class IconPicker extends WJElement {
255
255
  /**
256
256
  * Called when the component is disconnected.
257
257
  */
258
- disconnectedCallback() {
258
+ beforeDisconnect() {
259
259
  this.init = false;
260
260
  }
261
261
  /**
@@ -192,7 +192,7 @@ class Masonry extends WJElement {
192
192
  /**
193
193
  * Callback for when the element is disconnected.
194
194
  */
195
- disconnectedCallback() {
195
+ beforeDisconnect() {
196
196
  this.unsetSlot.removeEventListener("slotchange", this.onSlotChange);
197
197
  window.removeEventListener("resize", this.onResize);
198
198
  if (this.ro != null) {
package/dist/wje-radio.js CHANGED
@@ -60,7 +60,7 @@ class Radio extends WJElement {
60
60
  event.addListener(this, "click", "wje-radio:input");
61
61
  }
62
62
  }
63
- disconnectedCallback() {
63
+ beforeDisconnect() {
64
64
  event.removeElement(this);
65
65
  }
66
66
  }
@@ -72,7 +72,11 @@ class Select extends WJElement {
72
72
  * @param {string} value - The value to set.
73
73
  */
74
74
  set value(value) {
75
- this.internals.setFormValue(JSON.stringify(value));
75
+ if (Array.isArray(value)) {
76
+ this.internals.setFormValue(JSON.stringify(value));
77
+ } else {
78
+ this.internals.setFormValue(value);
79
+ }
76
80
  }
77
81
  /**
78
82
  * Getter for the value attribute.
@@ -143,7 +143,7 @@ class Textarea extends WJElement {
143
143
  /**
144
144
  * Disconnects the component.
145
145
  */
146
- disconnectedCallback() {
146
+ beforeDisconnect() {
147
147
  this.resizeObserver.unobserve(this.input);
148
148
  }
149
149
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wj-elements",
3
3
  "description": "WebJET Elements is a modern set of user interface tools harnessing the power of web components designed to simplify web application development.",
4
- "version": "0.1.114",
4
+ "version": "0.1.116",
5
5
  "homepage": "https://github.com/lencys/wj-elements",
6
6
  "author": "Lukáš Ondrejček <lukas.ondrejcek@gmail.com>",
7
7
  "license": "MIT",