smoothly 1.0.0-alpha.175 → 1.0.0-alpha.176

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.
@@ -8258,7 +8258,7 @@ const SmoothlyForm = class {
8258
8258
  this.prevent = true;
8259
8259
  this.changed = false;
8260
8260
  }
8261
- listen(property, listener) {
8261
+ listenChanged(property, listener) {
8262
8262
  var _a;
8263
8263
  var _b;
8264
8264
  ((_a = (_b = this.listeners)[property]) !== null && _a !== void 0 ? _a : (_b[property] = [])).push(listener);
@@ -8949,7 +8949,7 @@ const SmoothlyInput = class {
8949
8949
  this.initialValue = undefined;
8950
8950
  this.changed = false;
8951
8951
  }
8952
- listen(property, listener) {
8952
+ listenChanged(property, listener) {
8953
8953
  this.listener[property] = listener;
8954
8954
  listener(this);
8955
8955
  }
@@ -8988,6 +8988,10 @@ const SmoothlyInput = class {
8988
8988
  this.changed = Boolean(this.value);
8989
8989
  (_b = (_a = this.listener).changed) === null || _b === void 0 ? void 0 : _b.call(_a, this);
8990
8990
  }
8991
+ watchingReadonly() {
8992
+ var _a, _b;
8993
+ (_b = (_a = this.listener).changed) === null || _b === void 0 ? void 0 : _b.call(_a, this);
8994
+ }
8991
8995
  onCurrency() {
8992
8996
  this.state = Object.assign(Object.assign({}, this.state), { value: this.newState({ value: this.formatter.toString(this.value), selection: this.state.selection }).value, pattern: this.newState({ value: this.formatter.toString(this.value), selection: this.state.selection }).pattern });
8993
8997
  }
@@ -9168,6 +9172,7 @@ const SmoothlyInput = class {
9168
9172
  static get watchers() { return {
9169
9173
  "type": ["typeChange"],
9170
9174
  "value": ["valueWatcher"],
9175
+ "readonly": ["watchingReadonly"],
9171
9176
  "currency": ["onCurrency"]
9172
9177
  }; }
9173
9178
  };
@@ -9218,7 +9223,7 @@ SmoothlyInputCheckbox.style = styleCss$N;
9218
9223
  var Changeable;
9219
9224
  (function (Changeable) {
9220
9225
  function is(value) {
9221
- return value && typeof value == "object" && typeof value.changed == "boolean" && typeof value.listen == "function";
9226
+ return (value && typeof value == "object" && typeof value.changed == "boolean" && typeof value.listenChanged == "function");
9222
9227
  }
9223
9228
  Changeable.is = is;
9224
9229
  })(Changeable || (Changeable = {}));
@@ -9243,12 +9248,20 @@ const SmoothlyInputClear = class {
9243
9248
  if (Clearable.is(parent)) {
9244
9249
  this.parent = parent;
9245
9250
  if (Changeable.is(parent))
9246
- parent.listen("changed", async (p) => {
9251
+ parent.listenChanged("changed", async (p) => {
9247
9252
  if (p instanceof SmoothlyForm)
9248
- this.disabled = !p.changed;
9249
- if (p instanceof SmoothlyInput)
9253
+ this.disabled = p.readonly ? true : !p.changed;
9254
+ if (p instanceof SmoothlyInput) {
9250
9255
  this.display = p.changed;
9256
+ this.disabled = p.readonly ? true : !p.changed;
9257
+ }
9251
9258
  });
9259
+ if (Editable.type.is(parent)) {
9260
+ parent.listenReadonly &&
9261
+ parent.listenReadonly("readonly", async (p) => {
9262
+ this.disabled = p.readonly;
9263
+ });
9264
+ }
9252
9265
  }
9253
9266
  });
9254
9267
  }
@@ -9451,7 +9464,7 @@ const SmoothlyInputDemo = class {
9451
9464
  console.log("smoothlyInput", event.detail);
9452
9465
  }
9453
9466
  render() {
9454
- return (index.h(index.Host, null, index.h("h2", null, "Editable form and Input"), index.h("smoothly-form", { looks: "grid", readonly: true }, index.h("smoothly-input", { name: "First Name", value: "John" }, "First name"), index.h("smoothly-input", { name: "Last name", value: "Doe" }, "Last name"), index.h("smoothly-input", { type: "phone", name: "Phone", value: "777888999" }, "Phone"), index.h("smoothly-input-edit", { fill: "default", type: "button", color: "tertiary", slot: "submit", size: "icon", shape: "rounded" }, index.h("smoothly-icon", { name: "create-outline", fill: "solid" }))), index.h("h2", null, "Color"), index.h("smoothly-form", { looks: "border" }, index.h("smoothly-input-color", { name: "color" })), index.h("h2", null, "Range"), index.h("smoothly-form", { looks: "border" }, index.h("smoothly-input-range", { step: 1, name: "range", outputSide: "right" }, "Select and so"), index.h("smoothly-input-range", { step: 1, name: "range2" }, "Select with really really long label", index.h("smoothly-icon", { name: "checkmark-circle", slot: "start" }), index.h("smoothly-input-clear", { size: "icon", slot: "end" }, index.h("smoothly-icon", { name: "close" }))), index.h("smoothly-input-range", { step: 1, name: "range3" }, "Select")), index.h("h2", null, "Duration"), index.h("smoothly-form", { looks: "border" }, index.h("smoothly-input", { name: "duration", type: "duration", placeholder: "hh:mm", value: this.duration, onSmoothlyInput: e => {
9467
+ return (index.h(index.Host, null, index.h("h2", null, "Editable form and Input"), index.h("smoothly-form", { looks: "grid", readonly: true }, index.h("smoothly-input", { name: "First Name", value: "John" }, "First name"), index.h("smoothly-input", { name: "Last name", value: "Doe" }, "Last name", index.h("smoothly-input-clear", { size: "icon", slot: "end" }, index.h("smoothly-icon", { name: "close" }))), index.h("smoothly-input", { type: "phone", name: "Phone", value: "777888999" }, "Phone"), index.h("smoothly-input-edit", { fill: "default", type: "button", color: "tertiary", slot: "submit", size: "icon", shape: "rounded" }, index.h("smoothly-icon", { name: "create-outline", fill: "solid" })), index.h("smoothly-input-clear", { fill: "default", type: "form", color: "danger", slot: "submit", size: "icon", shape: "rounded" }, index.h("smoothly-icon", { name: "trash-outline", fill: "solid" }))), index.h("h2", null, "Color"), index.h("smoothly-form", { looks: "border" }, index.h("smoothly-input-color", { name: "color" })), index.h("h2", null, "Range"), index.h("smoothly-form", { looks: "border" }, index.h("smoothly-input-range", { step: 1, name: "range", outputSide: "right" }, "Select and so"), index.h("smoothly-input-range", { step: 1, name: "range2" }, "Select with really really long label", index.h("smoothly-icon", { name: "checkmark-circle", slot: "start" }), index.h("smoothly-input-clear", { size: "icon", slot: "end" }, index.h("smoothly-icon", { name: "close" }))), index.h("smoothly-input-range", { step: 1, name: "range3" }, "Select")), index.h("h2", null, "Duration"), index.h("smoothly-form", { looks: "border" }, index.h("smoothly-input", { name: "duration", type: "duration", placeholder: "hh:mm", value: this.duration, onSmoothlyInput: e => {
9455
9468
  const duration = e.detail.duration;
9456
9469
  console.log("event duration", duration);
9457
9470
  this.duration = duration;