@haiilo/catalyst 6.3.0 → 6.3.1

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.
@@ -4144,16 +4144,16 @@ const CatDatepickerFlat = class {
4144
4144
  this.catChange.emit(undefined);
4145
4145
  }
4146
4146
  }
4147
- onDisabledChanged(value) {
4148
- this.pickr?.set('clickOpens', !value && !this.readonly);
4149
- }
4150
- onReadonlyChanged(value) {
4151
- this.pickr?.set('clickOpens', !value && !this.disabled);
4147
+ onDisabledChanged() {
4148
+ // Dynamically changing 'disabled' value is not working due to a bug in the
4149
+ // library. We thus need to fully recreate the date picker after the value
4150
+ // has been updated.
4151
+ this.pickr?.destroy();
4152
+ this.pickr = undefined;
4153
+ setTimeout(() => (this.pickr = this.initDatepicker(this.input)));
4152
4154
  }
4153
4155
  componentDidLoad() {
4154
- if (this.input) {
4155
- this.pickr = this.initDatepicker(this.input);
4156
- }
4156
+ this.pickr = this.initDatepicker(this.input);
4157
4157
  }
4158
4158
  /**
4159
4159
  * Programmatically move focus to the datepicker. Use this method instead of
@@ -4185,6 +4185,9 @@ const CatDatepickerFlat = class {
4185
4185
  } }));
4186
4186
  }
4187
4187
  initDatepicker(input) {
4188
+ if (this.disabled || this.readonly || !input) {
4189
+ return;
4190
+ }
4188
4191
  return flatpickr(input, getConfig({
4189
4192
  locale: getLocale(of.catI18nRegistry.getLocale()),
4190
4193
  format: getFormat(of.catI18nRegistry.getLocale(), this.mode),
@@ -4200,7 +4203,7 @@ const CatDatepickerFlat = class {
4200
4203
  static get watchers() { return {
4201
4204
  "value": ["onValueChanged"],
4202
4205
  "disabled": ["onDisabledChanged"],
4203
- "readonly": ["onReadonlyChanged"]
4206
+ "readonly": ["onDisabledChanged"]
4204
4207
  }; }
4205
4208
  };
4206
4209
  CatDatepickerFlat.style = catDatepickerCss;
@@ -4229,18 +4232,16 @@ const CatDatepickerInline = class {
4229
4232
  this.catChange.emit(undefined);
4230
4233
  }
4231
4234
  }
4232
- onDisabledChanged(value) {
4235
+ onDisabledChanged() {
4233
4236
  // Dynamically unsetting 'enabled' value to undefined is not working due to
4234
- // a bug in the library. We thus need to fully recreate the date picker.
4237
+ // a bug in the library. We thus need to fully recreate the date picker
4238
+ // after the value has been updated.
4235
4239
  this.pickr?.destroy();
4236
- if (this.input) {
4237
- this.pickr = this.initDatepicker(this.input, value);
4238
- }
4240
+ this.pickr = undefined;
4241
+ setTimeout(() => (this.pickr = this.initDatepicker(this.input)));
4239
4242
  }
4240
4243
  componentDidLoad() {
4241
- if (this.input) {
4242
- this.pickr = this.initDatepicker(this.input, this.disabled);
4243
- }
4244
+ this.pickr = this.initDatepicker(this.input);
4244
4245
  }
4245
4246
  render() {
4246
4247
  return (index.h(index.Host, null, index.h("div", { tabIndex: this.disabled || this.readonly ? -1 : undefined, class: {
@@ -4249,7 +4250,10 @@ const CatDatepickerInline = class {
4249
4250
  'datepicker-readonly': this.readonly
4250
4251
  } }, index.h("input", { ref: el => (this.input = el), value: this.value, disabled: this.disabled, readonly: this.readonly }))));
4251
4252
  }
4252
- initDatepicker(input, disabled) {
4253
+ initDatepicker(input) {
4254
+ if (!input) {
4255
+ return;
4256
+ }
4253
4257
  return flatpickr(input, getConfig({
4254
4258
  locale: getLocale(of.catI18nRegistry.getLocale()),
4255
4259
  format: getFormat(of.catI18nRegistry.getLocale(), this.mode),
@@ -4257,17 +4261,18 @@ const CatDatepickerInline = class {
4257
4261
  min: this.min,
4258
4262
  max: this.max,
4259
4263
  step: this.step,
4260
- disabled,
4264
+ disabled: this.disabled,
4261
4265
  readonly: this.readonly,
4262
4266
  applyChange: value => (this.value = value)
4263
4267
  }, {
4264
- ...(disabled ? { enable: [] } : {}),
4268
+ ...(this.disabled ? { enable: [] } : {}),
4265
4269
  inline: true
4266
4270
  }));
4267
4271
  }
4268
4272
  static get watchers() { return {
4269
4273
  "value": ["onValueChanged"],
4270
- "disabled": ["onDisabledChanged"]
4274
+ "disabled": ["onDisabledChanged"],
4275
+ "readonly": ["onDisabledChanged"]
4271
4276
  }; }
4272
4277
  };
4273
4278
  CatDatepickerInline.style = catDatepickerInlineCss;