@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.
@@ -45,16 +45,16 @@ export class CatDatepickerFlat {
45
45
  this.catChange.emit(undefined);
46
46
  }
47
47
  }
48
- onDisabledChanged(value) {
49
- this.pickr?.set('clickOpens', !value && !this.readonly);
50
- }
51
- onReadonlyChanged(value) {
52
- this.pickr?.set('clickOpens', !value && !this.disabled);
48
+ onDisabledChanged() {
49
+ // Dynamically changing 'disabled' value is not working due to a bug in the
50
+ // library. We thus need to fully recreate the date picker after the value
51
+ // has been updated.
52
+ this.pickr?.destroy();
53
+ this.pickr = undefined;
54
+ setTimeout(() => (this.pickr = this.initDatepicker(this.input)));
53
55
  }
54
56
  componentDidLoad() {
55
- if (this.input) {
56
- this.pickr = this.initDatepicker(this.input);
57
- }
57
+ this.pickr = this.initDatepicker(this.input);
58
58
  }
59
59
  /**
60
60
  * Programmatically move focus to the datepicker. Use this method instead of
@@ -86,6 +86,9 @@ export class CatDatepickerFlat {
86
86
  } }));
87
87
  }
88
88
  initDatepicker(input) {
89
+ if (this.disabled || this.readonly || !input) {
90
+ return;
91
+ }
89
92
  return flatpickr(input, getConfig({
90
93
  locale: getLocale(i18n.getLocale()),
91
94
  format: getFormat(i18n.getLocale(), this.mode),
@@ -679,7 +682,7 @@ export class CatDatepickerFlat {
679
682
  "methodName": "onDisabledChanged"
680
683
  }, {
681
684
  "propName": "readonly",
682
- "methodName": "onReadonlyChanged"
685
+ "methodName": "onDisabledChanged"
683
686
  }];
684
687
  }
685
688
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cat-datepicker.js","sourceRoot":"","sources":["../../../src/components/cat-datepicker/cat-datepicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACvF,OAAO,S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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Event, EventEmitter, Method, Prop, Watch, h } from '@stencil/core';\nimport flatpickr from 'flatpickr';\nimport { ErrorMap } from '../cat-form-hint/cat-form-hint';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\nimport { getConfig } from './cat-datepicker.config';\nimport { getFormat } from './cat-datepicker.format';\nimport { getLocale } from './cat-datepicker.locale';\nimport { CatDatepickerMode } from './cat-datepicker.mode';\n\n@Component({\n tag: 'cat-datepicker',\n styleUrl: 'cat-datepicker.scss',\n shadow: true\n})\nexport class CatDatepickerFlat {\n private pickr?: flatpickr.Instance;\n private _input?: HTMLCatInputElement;\n private get input(): HTMLInputElement | undefined {\n return this._input?.shadowRoot?.querySelector('input') ?? undefined;\n }\n\n /**\n * Whether the label need a marker to shown if the input is required or optional.\n */\n @Prop() requiredMarker: 'none' | 'required' | 'optional' | 'none!' | 'optional!' | 'required!' = 'optional';\n\n /**\n * Whether the label is on top or left.\n */\n @Prop() horizontal = false;\n\n /**\n * Hint for form autofill feature.\n */\n @Prop() autoComplete?: string;\n\n /**\n * Whether the input should show a clear button.\n */\n @Prop() clearable = false;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * Optional hint text(s) to be displayed with the input.\n */\n @Prop() hint?: string | string[];\n\n /**\n * The name of an icon to be displayed in the input.\n */\n @Prop() icon?: string;\n\n /**\n * Display the icon on the right.\n */\n @Prop() iconRight = false;\n\n /**\n * A unique identifier for the input.\n */\n @Prop() identifier?: string;\n\n /**\n * The label for the input.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * A maximum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() max?: string;\n\n /**\n * A minimum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() min?: string;\n\n /**\n * The mode of the datepicker, to select a date, time, both, a date range or a week number.\n */\n @Prop() mode: CatDatepickerMode = 'date';\n\n /**\n * The name of the form control. Submitted with the form as part of a name/value pair.\n */\n @Prop() name?: string;\n\n /**\n * The placeholder text to display within the input.\n */\n @Prop() placeholder?: string;\n\n /**\n * A textual prefix to be displayed in the input.\n */\n @Prop() textPrefix?: string;\n\n /**\n * A textual suffix to be displayed in the input.\n */\n @Prop() textSuffix?: string;\n\n /**\n * The value is not editable.\n */\n @Prop() readonly = false;\n\n /**\n * A value is required or must be check for the form to be submittable.\n */\n @Prop() required = false;\n\n /**\n * The step size to use when changing the time.\n */\n @Prop() step = 5;\n\n /**\n * The value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z or as a week number string.\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * The validation errors for this input. Will render a hint under the input\n * with the translated error message(s) `error.${key}`. If an object is\n * passed, the keys will be used as error keys and the values translation\n * parameters.\n * If the value is `true`, the input will be marked as invalid without any\n * hints under the input.\n */\n @Prop() errors?: boolean | string[] | ErrorMap;\n\n /**\n * Fine-grained control over when the errors are shown. Can be `false` to\n * never show errors, `true` to show errors on blur, or a number to show\n * errors on change with the given delay in milliseconds.\n */\n @Prop() errorUpdate: boolean | number = 0;\n\n /**\n * Attributes that will be added to the native HTML input element.\n */\n @Prop() nativeAttributes?: { [key: string]: string };\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\n\n /**\n * Emitted when the input received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n @Watch('value')\n onValueChanged(value: string) {\n if (value) {\n this.pickr?.setDate(value, false);\n this.catChange.emit(value);\n } else {\n this.pickr?.clear(false);\n this.catChange.emit(undefined);\n }\n }\n\n @Watch('disabled')\n onDisabledChanged(value: boolean) {\n this.pickr?.set('clickOpens', !value && !this.readonly);\n }\n\n @Watch('readonly')\n onReadonlyChanged(value: boolean) {\n this.pickr?.set('clickOpens', !value && !this.disabled);\n }\n\n componentDidLoad() {\n if (this.input) {\n this.pickr = this.initDatepicker(this.input);\n }\n }\n\n /**\n * Programmatically move focus to the datepicker. Use this method instead of\n * `input.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async doFocus(options?: FocusOptions): Promise<void> {\n this._input?.doFocus(options);\n }\n\n /**\n * Programmatically remove focus from the datepicker. Use this method instead of\n * `input.blur()`.\n */\n @Method()\n async doBlur(): Promise<void> {\n this._input?.doBlur();\n }\n\n render() {\n return (\n <cat-input\n ref={el => (this._input = el)}\n requiredMarker={this.requiredMarker}\n horizontal={this.horizontal}\n autoComplete={this.autoComplete}\n clearable={this.clearable}\n disabled={this.disabled}\n hint={this.hint}\n icon={this.icon}\n iconRight={this.iconRight}\n identifier={this.identifier}\n label={this.label}\n labelHidden={this.labelHidden}\n name={this.name}\n placeholder={this.placeholder}\n textPrefix={this.textPrefix}\n textSuffix={this.textSuffix}\n readonly={this.readonly}\n required={this.required}\n value={this.value}\n errors={this.errors}\n errorUpdate={this.errorUpdate}\n nativeAttributes={this.nativeAttributes}\n onCatChange={e => {\n e.stopPropagation();\n this.value = e.detail || undefined;\n }}\n onCatFocus={e => {\n e.stopPropagation();\n this.catFocus.emit(e.detail);\n }}\n onCatBlur={e => {\n e.stopPropagation();\n this.catBlur.emit(e.detail);\n }}\n ></cat-input>\n );\n }\n\n private initDatepicker(input: HTMLInputElement): flatpickr.Instance {\n return flatpickr(\n input,\n getConfig({\n locale: getLocale(i18n.getLocale()),\n format: getFormat(i18n.getLocale(), this.mode),\n mode: this.mode,\n min: this.min,\n max: this.max,\n step: this.step,\n disabled: this.disabled,\n readonly: this.readonly,\n applyChange: value => (this.value = value)\n })\n );\n }\n}\n"]}
1
+ {"version":3,"file":"cat-datepicker.js","sourceRoot":"","sources":["../../../src/components/cat-datepicker/cat-datepicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACvF,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,eAAe,IAAI,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAQpD,MAAM,OAAO,iBAAiB;;0BAUqE,UAAU;sBAKtF,KAAK;;qBAUN,KAAK;oBAKN,KAAK;;;qBAeJ,KAAK;;iBAUT,EAAE;uBAKI,KAAK;;;gBAeO,MAAM;;;;;oBAyBrB,KAAK;oBAKL,KAAK;gBAKT,CAAC;;;uBAsBwB,CAAC;;;EAjIzC,IAAY,KAAK;IACf,OAAO,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,OAAO,CAAC,IAAI,SAAS,CAAC;EACtE,CAAC;EAsJD,cAAc,CAAC,KAAa;IAC1B,IAAI,KAAK,EAAE;MACT,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,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CAAC;MACnC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC;MAC9C,IAAI,EAAE,IAAI,CAAC,IAAI;MACf,GAAG,EAAE,IAAI,CAAC,GAAG;MACb,GAAG,EAAE,IAAI,CAAC,GAAG;MACb,IAAI,EAAE,IAAI,CAAC,IAAI;MACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;MACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;MACvB,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;KAC3C,CAAC,CACH,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Event, EventEmitter, Method, Prop, Watch, h } from '@stencil/core';\nimport flatpickr from 'flatpickr';\nimport { ErrorMap } from '../cat-form-hint/cat-form-hint';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\nimport { getConfig } from './cat-datepicker.config';\nimport { getFormat } from './cat-datepicker.format';\nimport { getLocale } from './cat-datepicker.locale';\nimport { CatDatepickerMode } from './cat-datepicker.mode';\n\n@Component({\n tag: 'cat-datepicker',\n styleUrl: 'cat-datepicker.scss',\n shadow: true\n})\nexport class CatDatepickerFlat {\n private pickr?: flatpickr.Instance;\n private _input?: HTMLCatInputElement;\n private get input(): HTMLInputElement | undefined {\n return this._input?.shadowRoot?.querySelector('input') ?? undefined;\n }\n\n /**\n * Whether the label need a marker to shown if the input is required or optional.\n */\n @Prop() requiredMarker: 'none' | 'required' | 'optional' | 'none!' | 'optional!' | 'required!' = 'optional';\n\n /**\n * Whether the label is on top or left.\n */\n @Prop() horizontal = false;\n\n /**\n * Hint for form autofill feature.\n */\n @Prop() autoComplete?: string;\n\n /**\n * Whether the input should show a clear button.\n */\n @Prop() clearable = false;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * Optional hint text(s) to be displayed with the input.\n */\n @Prop() hint?: string | string[];\n\n /**\n * The name of an icon to be displayed in the input.\n */\n @Prop() icon?: string;\n\n /**\n * Display the icon on the right.\n */\n @Prop() iconRight = false;\n\n /**\n * A unique identifier for the input.\n */\n @Prop() identifier?: string;\n\n /**\n * The label for the input.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * A maximum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() max?: string;\n\n /**\n * A minimum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() min?: string;\n\n /**\n * The mode of the datepicker, to select a date, time, both, a date range or a week number.\n */\n @Prop() mode: CatDatepickerMode = 'date';\n\n /**\n * The name of the form control. Submitted with the form as part of a name/value pair.\n */\n @Prop() name?: string;\n\n /**\n * The placeholder text to display within the input.\n */\n @Prop() placeholder?: string;\n\n /**\n * A textual prefix to be displayed in the input.\n */\n @Prop() textPrefix?: string;\n\n /**\n * A textual suffix to be displayed in the input.\n */\n @Prop() textSuffix?: string;\n\n /**\n * The value is not editable.\n */\n @Prop() readonly = false;\n\n /**\n * A value is required or must be check for the form to be submittable.\n */\n @Prop() required = false;\n\n /**\n * The step size to use when changing the time.\n */\n @Prop() step = 5;\n\n /**\n * The value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z or as a week number string.\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * The validation errors for this input. Will render a hint under the input\n * with the translated error message(s) `error.${key}`. If an object is\n * passed, the keys will be used as error keys and the values translation\n * parameters.\n * If the value is `true`, the input will be marked as invalid without any\n * hints under the input.\n */\n @Prop() errors?: boolean | string[] | ErrorMap;\n\n /**\n * Fine-grained control over when the errors are shown. Can be `false` to\n * never show errors, `true` to show errors on blur, or a number to show\n * errors on change with the given delay in milliseconds.\n */\n @Prop() errorUpdate: boolean | number = 0;\n\n /**\n * Attributes that will be added to the native HTML input element.\n */\n @Prop() nativeAttributes?: { [key: string]: string };\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\n\n /**\n * Emitted when the input received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n @Watch('value')\n onValueChanged(value: string) {\n if (value) {\n this.pickr?.setDate(value, false);\n this.catChange.emit(value);\n } else {\n this.pickr?.clear(false);\n this.catChange.emit(undefined);\n }\n }\n\n @Watch('disabled')\n @Watch('readonly')\n onDisabledChanged() {\n // Dynamically changing 'disabled' value is not working due to a bug in the\n // library. We thus need to fully recreate the date picker after the value\n // has been updated.\n this.pickr?.destroy();\n this.pickr = undefined;\n setTimeout(() => (this.pickr = this.initDatepicker(this.input)));\n }\n\n componentDidLoad() {\n this.pickr = this.initDatepicker(this.input);\n }\n\n /**\n * Programmatically move focus to the datepicker. Use this method instead of\n * `input.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async doFocus(options?: FocusOptions): Promise<void> {\n this._input?.doFocus(options);\n }\n\n /**\n * Programmatically remove focus from the datepicker. Use this method instead of\n * `input.blur()`.\n */\n @Method()\n async doBlur(): Promise<void> {\n this._input?.doBlur();\n }\n\n render() {\n return (\n <cat-input\n ref={el => (this._input = el)}\n requiredMarker={this.requiredMarker}\n horizontal={this.horizontal}\n autoComplete={this.autoComplete}\n clearable={this.clearable}\n disabled={this.disabled}\n hint={this.hint}\n icon={this.icon}\n iconRight={this.iconRight}\n identifier={this.identifier}\n label={this.label}\n labelHidden={this.labelHidden}\n name={this.name}\n placeholder={this.placeholder}\n textPrefix={this.textPrefix}\n textSuffix={this.textSuffix}\n readonly={this.readonly}\n required={this.required}\n value={this.value}\n errors={this.errors}\n errorUpdate={this.errorUpdate}\n nativeAttributes={this.nativeAttributes}\n onCatChange={e => {\n e.stopPropagation();\n this.value = e.detail || undefined;\n }}\n onCatFocus={e => {\n e.stopPropagation();\n this.catFocus.emit(e.detail);\n }}\n onCatBlur={e => {\n e.stopPropagation();\n this.catBlur.emit(e.detail);\n }}\n ></cat-input>\n );\n }\n\n private initDatepicker(input?: HTMLInputElement): flatpickr.Instance | undefined {\n if (this.disabled || this.readonly || !input) {\n return;\n }\n\n return flatpickr(\n input,\n getConfig({\n locale: getLocale(i18n.getLocale()),\n format: getFormat(i18n.getLocale(), this.mode),\n mode: this.mode,\n min: this.min,\n max: this.max,\n step: this.step,\n disabled: this.disabled,\n readonly: this.readonly,\n applyChange: value => (this.value = value)\n })\n );\n }\n}\n"]}
@@ -24,18 +24,16 @@ export class CatDatepickerInline {
24
24
  this.catChange.emit(undefined);
25
25
  }
26
26
  }
27
- onDisabledChanged(value) {
27
+ onDisabledChanged() {
28
28
  // Dynamically unsetting 'enabled' value to undefined is not working due to
29
- // a bug in the library. We thus need to fully recreate the date picker.
29
+ // a bug in the library. We thus need to fully recreate the date picker
30
+ // after the value has been updated.
30
31
  this.pickr?.destroy();
31
- if (this.input) {
32
- this.pickr = this.initDatepicker(this.input, value);
33
- }
32
+ this.pickr = undefined;
33
+ setTimeout(() => (this.pickr = this.initDatepicker(this.input)));
34
34
  }
35
35
  componentDidLoad() {
36
- if (this.input) {
37
- this.pickr = this.initDatepicker(this.input, this.disabled);
38
- }
36
+ this.pickr = this.initDatepicker(this.input);
39
37
  }
40
38
  render() {
41
39
  return (h(Host, null, h("div", { tabIndex: this.disabled || this.readonly ? -1 : undefined, class: {
@@ -44,7 +42,10 @@ export class CatDatepickerInline {
44
42
  'datepicker-readonly': this.readonly
45
43
  } }, h("input", { ref: el => (this.input = el), value: this.value, disabled: this.disabled, readonly: this.readonly }))));
46
44
  }
47
- initDatepicker(input, disabled) {
45
+ initDatepicker(input) {
46
+ if (!input) {
47
+ return;
48
+ }
48
49
  return flatpickr(input, getConfig({
49
50
  locale: getLocale(i18n.getLocale()),
50
51
  format: getFormat(i18n.getLocale(), this.mode),
@@ -52,11 +53,11 @@ export class CatDatepickerInline {
52
53
  min: this.min,
53
54
  max: this.max,
54
55
  step: this.step,
55
- disabled,
56
+ disabled: this.disabled,
56
57
  readonly: this.readonly,
57
58
  applyChange: value => (this.value = value)
58
59
  }, {
59
- ...(disabled ? { enable: [] } : {}),
60
+ ...(this.disabled ? { enable: [] } : {}),
60
61
  inline: true
61
62
  }));
62
63
  }
@@ -230,6 +231,9 @@ export class CatDatepickerInline {
230
231
  }, {
231
232
  "propName": "disabled",
232
233
  "methodName": "onDisabledChanged"
234
+ }, {
235
+ "propName": "readonly",
236
+ "methodName": "onDisabledChanged"
233
237
  }];
234
238
  }
235
239
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cat-datepicker-inline.js","sourceRoot":"","sources":["../../../src/components/cat-datepicker-inline/cat-datepicker-inline.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,IAAI,EAAE,IAAI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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Event, EventEmitter, Host, Prop, Watch, h } from '@stencil/core';\nimport flatpickr from 'flatpickr';\nimport { getConfig } from '../cat-datepicker/cat-datepicker.config';\nimport { getFormat } from '../cat-datepicker/cat-datepicker.format';\nimport { getLocale } from '../cat-datepicker/cat-datepicker.locale';\nimport { CatDatepickerMode } from '../cat-datepicker/cat-datepicker.mode';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\n\n@Component({\n tag: 'cat-datepicker-inline',\n styleUrl: 'cat-datepicker-inline.scss',\n shadow: true\n})\nexport class CatDatepickerInline {\n private pickr?: flatpickr.Instance;\n private input?: HTMLInputElement;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * A maximum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() max?: string;\n\n /**\n * A minimum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() min?: string;\n\n /**\n * The mode of the datepicker, to select a date, time, both, a date range or a week number.\n */\n @Prop() mode: CatDatepickerMode = 'date';\n\n /**\n * The value is not editable.\n */\n @Prop() readonly = false;\n\n /**\n * The step size to use when changing the time.\n */\n @Prop() step = 5;\n\n /**\n * The value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z or as a week number string.\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\n\n @Watch('value')\n onValueChanged(value: string) {\n if (value) {\n this.pickr?.setDate(value, false);\n this.catChange.emit(value);\n } else {\n this.pickr?.clear(false);\n this.catChange.emit(undefined);\n }\n }\n\n @Watch('disabled')\n onDisabledChanged(value: boolean) {\n // Dynamically unsetting 'enabled' value to undefined is not working due to\n // a bug in the library. We thus need to fully recreate the date picker.\n this.pickr?.destroy();\n if (this.input) {\n this.pickr = this.initDatepicker(this.input, value);\n }\n }\n\n componentDidLoad() {\n if (this.input) {\n this.pickr = this.initDatepicker(this.input, this.disabled);\n }\n }\n\n render() {\n return (\n <Host>\n <div\n tabIndex={this.disabled || this.readonly ? -1 : undefined}\n class={{\n 'datepicker-wrapper': true,\n 'datepicker-disabled': this.disabled,\n 'datepicker-readonly': this.readonly\n }}\n >\n <input\n ref={el => (this.input = el)}\n value={this.value}\n disabled={this.disabled}\n readonly={this.readonly}\n ></input>\n </div>\n </Host>\n );\n }\n\n private initDatepicker(input: HTMLInputElement, disabled: boolean): flatpickr.Instance {\n return flatpickr(\n input,\n getConfig(\n {\n locale: getLocale(i18n.getLocale()),\n format: getFormat(i18n.getLocale(), this.mode),\n mode: this.mode,\n min: this.min,\n max: this.max,\n step: this.step,\n disabled,\n readonly: this.readonly,\n applyChange: value => (this.value = value)\n },\n {\n ...(disabled ? { enable: [] } : {}),\n inline: true\n }\n )\n );\n }\n}\n"]}
1
+ {"version":3,"file":"cat-datepicker-inline.js","sourceRoot":"","sources":["../../../src/components/cat-datepicker-inline/cat-datepicker-inline.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,eAAe,IAAI,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAOxE,MAAM,OAAO,mBAAmB;;oBAOX,KAAK;;;gBAeU,MAAM;oBAKrB,KAAK;gBAKT,CAAC;;;EAahB,cAAc,CAAC,KAAa;IAC1B,IAAI,KAAK,EAAE;MACT,IAAI,CAAC,KAAK,EAAE,OAAO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AE;MACV,OAAO;KACR;IAED,OAAO,SAAS,CACd,KAAK,EACL,SAAS,CACP;MACE,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;MACnC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC;MAC9C,IAAI,EAAE,IAAI,CAAC,IAAI;MACf,GAAG,EAAE,IAAI,CAAC,GAAG;MACb,GAAG,EAAE,IAAI,CAAC,GAAG;MACb,IAAI,EAAE,IAAI,CAAC,IAAI;MACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;MACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;MACvB,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;KAC3C,EACD;MACE,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;MACxC,MAAM,EAAE,IAAI;KACb,CACF,CACF,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Event, EventEmitter, Host, Prop, Watch, h } from '@stencil/core';\nimport flatpickr from 'flatpickr';\nimport { getConfig } from '../cat-datepicker/cat-datepicker.config';\nimport { getFormat } from '../cat-datepicker/cat-datepicker.format';\nimport { getLocale } from '../cat-datepicker/cat-datepicker.locale';\nimport { CatDatepickerMode } from '../cat-datepicker/cat-datepicker.mode';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\n\n@Component({\n tag: 'cat-datepicker-inline',\n styleUrl: 'cat-datepicker-inline.scss',\n shadow: true\n})\nexport class CatDatepickerInline {\n private pickr?: flatpickr.Instance;\n private input?: HTMLInputElement;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * A maximum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() max?: string;\n\n /**\n * A minimum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() min?: string;\n\n /**\n * The mode of the datepicker, to select a date, time, both, a date range or a week number.\n */\n @Prop() mode: CatDatepickerMode = 'date';\n\n /**\n * The value is not editable.\n */\n @Prop() readonly = false;\n\n /**\n * The step size to use when changing the time.\n */\n @Prop() step = 5;\n\n /**\n * The value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z or as a week number string.\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\n\n @Watch('value')\n onValueChanged(value: string) {\n if (value) {\n this.pickr?.setDate(value, false);\n this.catChange.emit(value);\n } else {\n this.pickr?.clear(false);\n this.catChange.emit(undefined);\n }\n }\n\n @Watch('disabled')\n @Watch('readonly')\n onDisabledChanged() {\n // Dynamically unsetting 'enabled' value to undefined is not working due to\n // a bug in the library. We thus need to fully recreate the date picker\n // after the value has been updated.\n this.pickr?.destroy();\n this.pickr = undefined;\n setTimeout(() => (this.pickr = this.initDatepicker(this.input)));\n }\n\n componentDidLoad() {\n this.pickr = this.initDatepicker(this.input);\n }\n\n render() {\n return (\n <Host>\n <div\n tabIndex={this.disabled || this.readonly ? -1 : undefined}\n class={{\n 'datepicker-wrapper': true,\n 'datepicker-disabled': this.disabled,\n 'datepicker-readonly': this.readonly\n }}\n >\n <input\n ref={el => (this.input = el)}\n value={this.value}\n disabled={this.disabled}\n readonly={this.readonly}\n ></input>\n </div>\n </Host>\n );\n }\n\n private initDatepicker(input?: HTMLInputElement): flatpickr.Instance | undefined {\n if (!input) {\n return;\n }\n\n return flatpickr(\n input,\n getConfig(\n {\n locale: getLocale(i18n.getLocale()),\n format: getFormat(i18n.getLocale(), this.mode),\n mode: this.mode,\n min: this.min,\n max: this.max,\n step: this.step,\n disabled: this.disabled,\n readonly: this.readonly,\n applyChange: value => (this.value = value)\n },\n {\n ...(this.disabled ? { enable: [] } : {}),\n inline: true\n }\n )\n );\n }\n}\n"]}
@@ -28,18 +28,16 @@ const CatDatepickerInline$1 = /*@__PURE__*/ proxyCustomElement(class CatDatepick
28
28
  this.catChange.emit(undefined);
29
29
  }
30
30
  }
31
- onDisabledChanged(value) {
31
+ onDisabledChanged() {
32
32
  // Dynamically unsetting 'enabled' value to undefined is not working due to
33
- // a bug in the library. We thus need to fully recreate the date picker.
33
+ // a bug in the library. We thus need to fully recreate the date picker
34
+ // after the value has been updated.
34
35
  this.pickr?.destroy();
35
- if (this.input) {
36
- this.pickr = this.initDatepicker(this.input, value);
37
- }
36
+ this.pickr = undefined;
37
+ setTimeout(() => (this.pickr = this.initDatepicker(this.input)));
38
38
  }
39
39
  componentDidLoad() {
40
- if (this.input) {
41
- this.pickr = this.initDatepicker(this.input, this.disabled);
42
- }
40
+ this.pickr = this.initDatepicker(this.input);
43
41
  }
44
42
  render() {
45
43
  return (h(Host, null, h("div", { tabIndex: this.disabled || this.readonly ? -1 : undefined, class: {
@@ -48,7 +46,10 @@ const CatDatepickerInline$1 = /*@__PURE__*/ proxyCustomElement(class CatDatepick
48
46
  'datepicker-readonly': this.readonly
49
47
  } }, h("input", { ref: el => (this.input = el), value: this.value, disabled: this.disabled, readonly: this.readonly }))));
50
48
  }
51
- initDatepicker(input, disabled) {
49
+ initDatepicker(input) {
50
+ if (!input) {
51
+ return;
52
+ }
52
53
  return flatpickr(input, getConfig({
53
54
  locale: getLocale(catI18nRegistry.getLocale()),
54
55
  format: getFormat(catI18nRegistry.getLocale(), this.mode),
@@ -56,17 +57,18 @@ const CatDatepickerInline$1 = /*@__PURE__*/ proxyCustomElement(class CatDatepick
56
57
  min: this.min,
57
58
  max: this.max,
58
59
  step: this.step,
59
- disabled,
60
+ disabled: this.disabled,
60
61
  readonly: this.readonly,
61
62
  applyChange: value => (this.value = value)
62
63
  }, {
63
- ...(disabled ? { enable: [] } : {}),
64
+ ...(this.disabled ? { enable: [] } : {}),
64
65
  inline: true
65
66
  }));
66
67
  }
67
68
  static get watchers() { return {
68
69
  "value": ["onValueChanged"],
69
- "disabled": ["onDisabledChanged"]
70
+ "disabled": ["onDisabledChanged"],
71
+ "readonly": ["onDisabledChanged"]
70
72
  }; }
71
73
  static get style() { return catDatepickerInlineCss; }
72
74
  }, [1, "cat-datepicker-inline", {
@@ -1 +1 @@
1
- {"file":"cat-datepicker-inline.js","mappings":";;;;AAAA,MAAM,sBAAsB,GAAG,2hyBAA2hyB;;MCa7iyBA,qBAAmB;;;;;;oBAOX,KAAK;;;gBAeU,MAAM;oBAKrB,KAAK;gBAKT,CAAC;;;EAahB,cAAc,CAAC,KAAa;IAC1B,IAAI,KAAK,EAAE;MACT,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;MAClC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KAC5B;SAAM;MACL,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;MACzB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;KAChC;GACF;EAGD,iBAAiB,CAAC,KAAc;;;IAG9B,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC;IACtB,IAAI,IAAI,CAAC,KAAK,EAAE;MACd,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;KACrD;GACF;EAED,gBAAgB;IACd,IAAI,IAAI,CAAC,KAAK,EAAE;MACd,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC7D;GACF;EAED,MAAM;IACJ,QACE,EAAC,IAAI,QACH,WACE,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,GAAG,SAAS,EACzD,KAAK,EAAE;QACL,oBAAoB,EAAE,IAAI;QAC1B,qBAAqB,EAAE,IAAI,CAAC,QAAQ;QACpC,qBAAqB,EAAE,IAAI,CAAC,QAAQ;OACrC,IAED,aACE,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,EAC5B,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ,GAChB,CACL,CACD,EACP;GACH;EAEO,cAAc,CAAC,KAAuB,EAAE,QAAiB;IAC/D,OAAO,SAAS,CACd,KAAK,EACL,SAAS,CACP;MACE,MAAM,EAAE,SAAS,CAACC,eAAI,CAAC,SAAS,EAAE,CAAC;MACnC,MAAM,EAAE,SAAS,CAACA,eAAI,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC;MAC9C,IAAI,EAAE,IAAI,CAAC,IAAI;MACf,GAAG,EAAE,IAAI,CAAC,GAAG;MACb,GAAG,EAAE,IAAI,CAAC,GAAG;MACb,IAAI,EAAE,IAAI,CAAC,IAAI;MACf,QAAQ;MACR,QAAQ,EAAE,IAAI,CAAC,QAAQ;MACvB,WAAW,EAAE,KAAK,KAAK,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;KAC3C,EACD;MACE,IAAI,QAAQ,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC;MACnC,MAAM,EAAE,IAAI;KACb,CACF,CACF,CAAC;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["CatDatepickerInline","i18n"],"sources":["src/components/cat-datepicker-inline/cat-datepicker-inline.scss?tag=cat-datepicker-inline&encapsulation=shadow","src/components/cat-datepicker-inline/cat-datepicker-inline.tsx"],"sourcesContent":["@use 'variables' as *;\n@use 'mixins' as *;\n\n@import '~flatpickr/dist/flatpickr.css';\n@import '../styles/vendor/flatpickr';\n\n:host {\n display: inline-flex;\n margin-bottom: $cat-body-margin-bottom;\n\n > div {\n display: flex;\n }\n}\n\n:host([hidden]) {\n display: none;\n}\n\n.datepicker-disabled,\n.datepicker-readonly {\n .flatpickr-days,\n .flatpickr-time {\n pointer-events: none;\n }\n}\n\n.datepicker-disabled {\n .flatpickr-days {\n opacity: 0.75;\n }\n .flatpickr-time {\n input,\n .flatpickr-time-separator,\n .flatpickr-am-pm {\n color: cat-token('color.ui.font.muted');\n opacity: 0.75;\n }\n }\n}\n\ninput {\n display: none;\n}\n\n.flatpickr-calendar {\n box-shadow: unset;\n background: unset;\n}\n","import { Component, Event, EventEmitter, Host, Prop, Watch, h } from '@stencil/core';\nimport flatpickr from 'flatpickr';\nimport { getConfig } from '../cat-datepicker/cat-datepicker.config';\nimport { getFormat } from '../cat-datepicker/cat-datepicker.format';\nimport { getLocale } from '../cat-datepicker/cat-datepicker.locale';\nimport { CatDatepickerMode } from '../cat-datepicker/cat-datepicker.mode';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\n\n@Component({\n tag: 'cat-datepicker-inline',\n styleUrl: 'cat-datepicker-inline.scss',\n shadow: true\n})\nexport class CatDatepickerInline {\n private pickr?: flatpickr.Instance;\n private input?: HTMLInputElement;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * A maximum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() max?: string;\n\n /**\n * A minimum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() min?: string;\n\n /**\n * The mode of the datepicker, to select a date, time, both, a date range or a week number.\n */\n @Prop() mode: CatDatepickerMode = 'date';\n\n /**\n * The value is not editable.\n */\n @Prop() readonly = false;\n\n /**\n * The step size to use when changing the time.\n */\n @Prop() step = 5;\n\n /**\n * The value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z or as a week number string.\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\n\n @Watch('value')\n onValueChanged(value: string) {\n if (value) {\n this.pickr?.setDate(value, false);\n this.catChange.emit(value);\n } else {\n this.pickr?.clear(false);\n this.catChange.emit(undefined);\n }\n }\n\n @Watch('disabled')\n onDisabledChanged(value: boolean) {\n // Dynamically unsetting 'enabled' value to undefined is not working due to\n // a bug in the library. We thus need to fully recreate the date picker.\n this.pickr?.destroy();\n if (this.input) {\n this.pickr = this.initDatepicker(this.input, value);\n }\n }\n\n componentDidLoad() {\n if (this.input) {\n this.pickr = this.initDatepicker(this.input, this.disabled);\n }\n }\n\n render() {\n return (\n <Host>\n <div\n tabIndex={this.disabled || this.readonly ? -1 : undefined}\n class={{\n 'datepicker-wrapper': true,\n 'datepicker-disabled': this.disabled,\n 'datepicker-readonly': this.readonly\n }}\n >\n <input\n ref={el => (this.input = el)}\n value={this.value}\n disabled={this.disabled}\n readonly={this.readonly}\n ></input>\n </div>\n </Host>\n );\n }\n\n private initDatepicker(input: HTMLInputElement, disabled: boolean): flatpickr.Instance {\n return flatpickr(\n input,\n getConfig(\n {\n locale: getLocale(i18n.getLocale()),\n format: getFormat(i18n.getLocale(), this.mode),\n mode: this.mode,\n min: this.min,\n max: this.max,\n step: this.step,\n disabled,\n readonly: this.readonly,\n applyChange: value => (this.value = value)\n },\n {\n ...(disabled ? { enable: [] } : {}),\n inline: true\n }\n )\n );\n }\n}\n"],"version":3}
1
+ {"file":"cat-datepicker-inline.js","mappings":";;;;AAAA,MAAM,sBAAsB,GAAG,2hyBAA2hyB;;MCa7iyBA,qBAAmB;;;;;;oBAOX,KAAK;;;gBAeU,MAAM;oBAKrB,KAAK;gBAKT,CAAC;;;EAahB,cAAc,CAAC,KAAa;IAC1B,IAAI,KAA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I,CAAC,SAAS,EAAE,CAAC;MACnC,MAAM,EAAE,SAAS,CAACA,eAAI,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC;MAC9C,IAAI,EAAE,IAAI,CAAC,IAAI;MACf,GAAG,EAAE,IAAI,CAAC,GAAG;MACb,GAAG,EAAE,IAAI,CAAC,GAAG;MACb,IAAI,EAAE,IAAI,CAAC,IAAI;MACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;MACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;MACvB,WAAW,EAAE,KAAK,KAAK,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;KAC3C,EACD;MACE,IAAI,IAAI,CAAC,QAAQ,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC;MACxC,MAAM,EAAE,IAAI;KACb,CACF,CACF,CAAC;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["CatDatepickerInline","i18n"],"sources":["src/components/cat-datepicker-inline/cat-datepicker-inline.scss?tag=cat-datepicker-inline&encapsulation=shadow","src/components/cat-datepicker-inline/cat-datepicker-inline.tsx"],"sourcesContent":["@use 'variables' as *;\n@use 'mixins' as *;\n\n@import '~flatpickr/dist/flatpickr.css';\n@import '../styles/vendor/flatpickr';\n\n:host {\n display: inline-flex;\n margin-bottom: $cat-body-margin-bottom;\n\n > div {\n display: flex;\n }\n}\n\n:host([hidden]) {\n display: none;\n}\n\n.datepicker-disabled,\n.datepicker-readonly {\n .flatpickr-days,\n .flatpickr-time {\n pointer-events: none;\n }\n}\n\n.datepicker-disabled {\n .flatpickr-days {\n opacity: 0.75;\n }\n .flatpickr-time {\n input,\n .flatpickr-time-separator,\n .flatpickr-am-pm {\n color: cat-token('color.ui.font.muted');\n opacity: 0.75;\n }\n }\n}\n\ninput {\n display: none;\n}\n\n.flatpickr-calendar {\n box-shadow: unset;\n background: unset;\n}\n","import { Component, Event, EventEmitter, Host, Prop, Watch, h } from '@stencil/core';\nimport flatpickr from 'flatpickr';\nimport { getConfig } from '../cat-datepicker/cat-datepicker.config';\nimport { getFormat } from '../cat-datepicker/cat-datepicker.format';\nimport { getLocale } from '../cat-datepicker/cat-datepicker.locale';\nimport { CatDatepickerMode } from '../cat-datepicker/cat-datepicker.mode';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\n\n@Component({\n tag: 'cat-datepicker-inline',\n styleUrl: 'cat-datepicker-inline.scss',\n shadow: true\n})\nexport class CatDatepickerInline {\n private pickr?: flatpickr.Instance;\n private input?: HTMLInputElement;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * A maximum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() max?: string;\n\n /**\n * A minimum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() min?: string;\n\n /**\n * The mode of the datepicker, to select a date, time, both, a date range or a week number.\n */\n @Prop() mode: CatDatepickerMode = 'date';\n\n /**\n * The value is not editable.\n */\n @Prop() readonly = false;\n\n /**\n * The step size to use when changing the time.\n */\n @Prop() step = 5;\n\n /**\n * The value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z or as a week number string.\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\n\n @Watch('value')\n onValueChanged(value: string) {\n if (value) {\n this.pickr?.setDate(value, false);\n this.catChange.emit(value);\n } else {\n this.pickr?.clear(false);\n this.catChange.emit(undefined);\n }\n }\n\n @Watch('disabled')\n @Watch('readonly')\n onDisabledChanged() {\n // Dynamically unsetting 'enabled' value to undefined is not working due to\n // a bug in the library. We thus need to fully recreate the date picker\n // after the value has been updated.\n this.pickr?.destroy();\n this.pickr = undefined;\n setTimeout(() => (this.pickr = this.initDatepicker(this.input)));\n }\n\n componentDidLoad() {\n this.pickr = this.initDatepicker(this.input);\n }\n\n render() {\n return (\n <Host>\n <div\n tabIndex={this.disabled || this.readonly ? -1 : undefined}\n class={{\n 'datepicker-wrapper': true,\n 'datepicker-disabled': this.disabled,\n 'datepicker-readonly': this.readonly\n }}\n >\n <input\n ref={el => (this.input = el)}\n value={this.value}\n disabled={this.disabled}\n readonly={this.readonly}\n ></input>\n </div>\n </Host>\n );\n }\n\n private initDatepicker(input?: HTMLInputElement): flatpickr.Instance | undefined {\n if (!input) {\n return;\n }\n\n return flatpickr(\n input,\n getConfig(\n {\n locale: getLocale(i18n.getLocale()),\n format: getFormat(i18n.getLocale(), this.mode),\n mode: this.mode,\n min: this.min,\n max: this.max,\n step: this.step,\n disabled: this.disabled,\n readonly: this.readonly,\n applyChange: value => (this.value = value)\n },\n {\n ...(this.disabled ? { enable: [] } : {}),\n inline: true\n }\n )\n );\n }\n}\n"],"version":3}
@@ -55,16 +55,16 @@ const CatDatepickerFlat = /*@__PURE__*/ proxyCustomElement(class CatDatepickerFl
55
55
  this.catChange.emit(undefined);
56
56
  }
57
57
  }
58
- onDisabledChanged(value) {
59
- this.pickr?.set('clickOpens', !value && !this.readonly);
60
- }
61
- onReadonlyChanged(value) {
62
- this.pickr?.set('clickOpens', !value && !this.disabled);
58
+ onDisabledChanged() {
59
+ // Dynamically changing 'disabled' value is not working due to a bug in the
60
+ // library. We thus need to fully recreate the date picker after the value
61
+ // has been updated.
62
+ this.pickr?.destroy();
63
+ this.pickr = undefined;
64
+ setTimeout(() => (this.pickr = this.initDatepicker(this.input)));
63
65
  }
64
66
  componentDidLoad() {
65
- if (this.input) {
66
- this.pickr = this.initDatepicker(this.input);
67
- }
67
+ this.pickr = this.initDatepicker(this.input);
68
68
  }
69
69
  /**
70
70
  * Programmatically move focus to the datepicker. Use this method instead of
@@ -96,6 +96,9 @@ const CatDatepickerFlat = /*@__PURE__*/ proxyCustomElement(class CatDatepickerFl
96
96
  } }));
97
97
  }
98
98
  initDatepicker(input) {
99
+ if (this.disabled || this.readonly || !input) {
100
+ return;
101
+ }
99
102
  return flatpickr(input, getConfig({
100
103
  locale: getLocale(catI18nRegistry.getLocale()),
101
104
  format: getFormat(catI18nRegistry.getLocale(), this.mode),
@@ -111,7 +114,7 @@ const CatDatepickerFlat = /*@__PURE__*/ proxyCustomElement(class CatDatepickerFl
111
114
  static get watchers() { return {
112
115
  "value": ["onValueChanged"],
113
116
  "disabled": ["onDisabledChanged"],
114
- "readonly": ["onReadonlyChanged"]
117
+ "readonly": ["onDisabledChanged"]
115
118
  }; }
116
119
  static get style() { return catDatepickerCss; }
117
120
  }, [1, "cat-datepicker", {
@@ -1 +1 @@
1
- {"file":"cat-datepicker.js","mappings":";;;;;;;;AAAA,MAAM,gBAAgB,GAAG,sGAAsG;;MCclH,iBAAiB;;;;;;;;0BAUqE,UAAU;sBAKtF,KAAK;;qBAUN,KAAK;oBAKN,KAAK;;;qBAeJ,KAAK;;iBAUT,EAAE;uBAKI,KAAK;;;gBAeO,MAAM;;;;;oBAyBrB,KAAK;oBAKL,KAAK;gBAKT,CAAC;;;uBAsBwB,CAAC;;;EAjIzC,IAAY,KAAK;IACf,OAAO,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,OAAO,CAAC,IAAI,SAAS,CAAC;GACrE;EAsJD,cAAc,CAAC,KAAa;IAC1B,IAAI,KAAK,EAAE;MACT,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;MAClC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KAC5B;SAAM;MACL,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;MACzB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;KAChC;GACF;EAGD,iBAAiB,CAAC,KAAc;IAC9B,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,YAAY,EAAE,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;GACzD;EAGD,iBAAiB,CAAC,KAAc;IA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,WAAW,EAAE,IAAI,CAAC,WAAW,EAC7B,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EACvC,WAAW,EAAE,CAAC;QACZ,CAAC,CAAC,eAAe,EAAE,CAAC;QACpB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,MAAM,IAAI,SAAS,CAAC;OACpC,EACD,UAAU,EAAE,CAAC;QACX,CAAC,CAAC,eAAe,EAAE,CAAC;QACpB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;OAC9B,EACD,SAAS,EAAE,CAAC;QACV,CAAC,CAAC,eAAe,EAAE,CAAC;QACpB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;OAC7B,GACU,EACb;GACH;EAEO,cAAc,CAAC,KAAuB;IAC5C,OAAO,SAAS,CACd,KAAK,EACL,SAAS,CAAC;MACR,MAAM,EAAE,SAAS,CAACA,eAAI,CAAC,SAAS,EAAE,CAAC;MACnC,MAAM,EAAE,SAAS,CAACA,eAAI,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC;MAC9C,IAAI,EAAE,IAAI,CAAC,IAAI;MACf,GAAG,EAAE,IAAI,CAAC,GAAG;MACb,GAAG,EAAE,IAAI,CAAC,GAAG;MACb,IAAI,EAAE,IAAI,CAAC,IAAI;MACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;MACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;MACvB,WAAW,EAAE,KAAK,KAAK,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;KAC3C,CAAC,CACH,CAAC;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["i18n"],"sources":["src/components/cat-datepicker/cat-datepicker.scss?tag=cat-datepicker&encapsulation=shadow","src/components/cat-datepicker/cat-datepicker.tsx"],"sourcesContent":["@use 'variables' as *;\n@use 'mixins' as *;\n\n:host {\n display: flex;\n margin-bottom: $cat-body-margin-bottom;\n}\n\n:host([hidden]) {\n display: none;\n}\n\ncat-input {\n flex: 1 1 auto;\n margin: 0;\n}\n","import { Component, Event, EventEmitter, Method, Prop, Watch, h } from '@stencil/core';\nimport flatpickr from 'flatpickr';\nimport { ErrorMap } from '../cat-form-hint/cat-form-hint';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\nimport { getConfig } from './cat-datepicker.config';\nimport { getFormat } from './cat-datepicker.format';\nimport { getLocale } from './cat-datepicker.locale';\nimport { CatDatepickerMode } from './cat-datepicker.mode';\n\n@Component({\n tag: 'cat-datepicker',\n styleUrl: 'cat-datepicker.scss',\n shadow: true\n})\nexport class CatDatepickerFlat {\n private pickr?: flatpickr.Instance;\n private _input?: HTMLCatInputElement;\n private get input(): HTMLInputElement | undefined {\n return this._input?.shadowRoot?.querySelector('input') ?? undefined;\n }\n\n /**\n * Whether the label need a marker to shown if the input is required or optional.\n */\n @Prop() requiredMarker: 'none' | 'required' | 'optional' | 'none!' | 'optional!' | 'required!' = 'optional';\n\n /**\n * Whether the label is on top or left.\n */\n @Prop() horizontal = false;\n\n /**\n * Hint for form autofill feature.\n */\n @Prop() autoComplete?: string;\n\n /**\n * Whether the input should show a clear button.\n */\n @Prop() clearable = false;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * Optional hint text(s) to be displayed with the input.\n */\n @Prop() hint?: string | string[];\n\n /**\n * The name of an icon to be displayed in the input.\n */\n @Prop() icon?: string;\n\n /**\n * Display the icon on the right.\n */\n @Prop() iconRight = false;\n\n /**\n * A unique identifier for the input.\n */\n @Prop() identifier?: string;\n\n /**\n * The label for the input.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * A maximum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() max?: string;\n\n /**\n * A minimum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() min?: string;\n\n /**\n * The mode of the datepicker, to select a date, time, both, a date range or a week number.\n */\n @Prop() mode: CatDatepickerMode = 'date';\n\n /**\n * The name of the form control. Submitted with the form as part of a name/value pair.\n */\n @Prop() name?: string;\n\n /**\n * The placeholder text to display within the input.\n */\n @Prop() placeholder?: string;\n\n /**\n * A textual prefix to be displayed in the input.\n */\n @Prop() textPrefix?: string;\n\n /**\n * A textual suffix to be displayed in the input.\n */\n @Prop() textSuffix?: string;\n\n /**\n * The value is not editable.\n */\n @Prop() readonly = false;\n\n /**\n * A value is required or must be check for the form to be submittable.\n */\n @Prop() required = false;\n\n /**\n * The step size to use when changing the time.\n */\n @Prop() step = 5;\n\n /**\n * The value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z or as a week number string.\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * The validation errors for this input. Will render a hint under the input\n * with the translated error message(s) `error.${key}`. If an object is\n * passed, the keys will be used as error keys and the values translation\n * parameters.\n * If the value is `true`, the input will be marked as invalid without any\n * hints under the input.\n */\n @Prop() errors?: boolean | string[] | ErrorMap;\n\n /**\n * Fine-grained control over when the errors are shown. Can be `false` to\n * never show errors, `true` to show errors on blur, or a number to show\n * errors on change with the given delay in milliseconds.\n */\n @Prop() errorUpdate: boolean | number = 0;\n\n /**\n * Attributes that will be added to the native HTML input element.\n */\n @Prop() nativeAttributes?: { [key: string]: string };\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\n\n /**\n * Emitted when the input received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n @Watch('value')\n onValueChanged(value: string) {\n if (value) {\n this.pickr?.setDate(value, false);\n this.catChange.emit(value);\n } else {\n this.pickr?.clear(false);\n this.catChange.emit(undefined);\n }\n }\n\n @Watch('disabled')\n onDisabledChanged(value: boolean) {\n this.pickr?.set('clickOpens', !value && !this.readonly);\n }\n\n @Watch('readonly')\n onReadonlyChanged(value: boolean) {\n this.pickr?.set('clickOpens', !value && !this.disabled);\n }\n\n componentDidLoad() {\n if (this.input) {\n this.pickr = this.initDatepicker(this.input);\n }\n }\n\n /**\n * Programmatically move focus to the datepicker. Use this method instead of\n * `input.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async doFocus(options?: FocusOptions): Promise<void> {\n this._input?.doFocus(options);\n }\n\n /**\n * Programmatically remove focus from the datepicker. Use this method instead of\n * `input.blur()`.\n */\n @Method()\n async doBlur(): Promise<void> {\n this._input?.doBlur();\n }\n\n render() {\n return (\n <cat-input\n ref={el => (this._input = el)}\n requiredMarker={this.requiredMarker}\n horizontal={this.horizontal}\n autoComplete={this.autoComplete}\n clearable={this.clearable}\n disabled={this.disabled}\n hint={this.hint}\n icon={this.icon}\n iconRight={this.iconRight}\n identifier={this.identifier}\n label={this.label}\n labelHidden={this.labelHidden}\n name={this.name}\n placeholder={this.placeholder}\n textPrefix={this.textPrefix}\n textSuffix={this.textSuffix}\n readonly={this.readonly}\n required={this.required}\n value={this.value}\n errors={this.errors}\n errorUpdate={this.errorUpdate}\n nativeAttributes={this.nativeAttributes}\n onCatChange={e => {\n e.stopPropagation();\n this.value = e.detail || undefined;\n }}\n onCatFocus={e => {\n e.stopPropagation();\n this.catFocus.emit(e.detail);\n }}\n onCatBlur={e => {\n e.stopPropagation();\n this.catBlur.emit(e.detail);\n }}\n ></cat-input>\n );\n }\n\n private initDatepicker(input: HTMLInputElement): flatpickr.Instance {\n return flatpickr(\n input,\n getConfig({\n locale: getLocale(i18n.getLocale()),\n format: getFormat(i18n.getLocale(), this.mode),\n mode: this.mode,\n min: this.min,\n max: this.max,\n step: this.step,\n disabled: this.disabled,\n readonly: this.readonly,\n applyChange: value => (this.value = value)\n })\n );\n }\n}\n"],"version":3}
1
+ {"file":"cat-datep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,MAAM,CAAC,CAAC;OAC7B,GACU,EACb;GACH;EAEO,cAAc,CAAC,KAAwB;IAC7C,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,KAAK,EAAE;MAC5C,OAAO;KACR;IAED,OAAO,SAAS,CACd,KAAK,EACL,SAAS,CAAC;MACR,MAAM,EAAE,SAAS,CAACA,eAAI,CAAC,SAAS,EAAE,CAAC;MACnC,MAAM,EAAE,SAAS,CAACA,eAAI,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC;MAC9C,IAAI,EAAE,IAAI,CAAC,IAAI;MACf,GAAG,EAAE,IAAI,CAAC,GAAG;MACb,GAAG,EAAE,IAAI,CAAC,GAAG;MACb,IAAI,EAAE,IAAI,CAAC,IAAI;MACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;MACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;MACvB,WAAW,EAAE,KAAK,KAAK,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;KAC3C,CAAC,CACH,CAAC;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["i18n"],"sources":["src/components/cat-datepicker/cat-datepicker.scss?tag=cat-datepicker&encapsulation=shadow","src/components/cat-datepicker/cat-datepicker.tsx"],"sourcesContent":["@use 'variables' as *;\n@use 'mixins' as *;\n\n:host {\n display: flex;\n margin-bottom: $cat-body-margin-bottom;\n}\n\n:host([hidden]) {\n display: none;\n}\n\ncat-input {\n flex: 1 1 auto;\n margin: 0;\n}\n","import { Component, Event, EventEmitter, Method, Prop, Watch, h } from '@stencil/core';\nimport flatpickr from 'flatpickr';\nimport { ErrorMap } from '../cat-form-hint/cat-form-hint';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\nimport { getConfig } from './cat-datepicker.config';\nimport { getFormat } from './cat-datepicker.format';\nimport { getLocale } from './cat-datepicker.locale';\nimport { CatDatepickerMode } from './cat-datepicker.mode';\n\n@Component({\n tag: 'cat-datepicker',\n styleUrl: 'cat-datepicker.scss',\n shadow: true\n})\nexport class CatDatepickerFlat {\n private pickr?: flatpickr.Instance;\n private _input?: HTMLCatInputElement;\n private get input(): HTMLInputElement | undefined {\n return this._input?.shadowRoot?.querySelector('input') ?? undefined;\n }\n\n /**\n * Whether the label need a marker to shown if the input is required or optional.\n */\n @Prop() requiredMarker: 'none' | 'required' | 'optional' | 'none!' | 'optional!' | 'required!' = 'optional';\n\n /**\n * Whether the label is on top or left.\n */\n @Prop() horizontal = false;\n\n /**\n * Hint for form autofill feature.\n */\n @Prop() autoComplete?: string;\n\n /**\n * Whether the input should show a clear button.\n */\n @Prop() clearable = false;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * Optional hint text(s) to be displayed with the input.\n */\n @Prop() hint?: string | string[];\n\n /**\n * The name of an icon to be displayed in the input.\n */\n @Prop() icon?: string;\n\n /**\n * Display the icon on the right.\n */\n @Prop() iconRight = false;\n\n /**\n * A unique identifier for the input.\n */\n @Prop() identifier?: string;\n\n /**\n * The label for the input.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * A maximum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() max?: string;\n\n /**\n * A minimum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() min?: string;\n\n /**\n * The mode of the datepicker, to select a date, time, both, a date range or a week number.\n */\n @Prop() mode: CatDatepickerMode = 'date';\n\n /**\n * The name of the form control. Submitted with the form as part of a name/value pair.\n */\n @Prop() name?: string;\n\n /**\n * The placeholder text to display within the input.\n */\n @Prop() placeholder?: string;\n\n /**\n * A textual prefix to be displayed in the input.\n */\n @Prop() textPrefix?: string;\n\n /**\n * A textual suffix to be displayed in the input.\n */\n @Prop() textSuffix?: string;\n\n /**\n * The value is not editable.\n */\n @Prop() readonly = false;\n\n /**\n * A value is required or must be check for the form to be submittable.\n */\n @Prop() required = false;\n\n /**\n * The step size to use when changing the time.\n */\n @Prop() step = 5;\n\n /**\n * The value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z or as a week number string.\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * The validation errors for this input. Will render a hint under the input\n * with the translated error message(s) `error.${key}`. If an object is\n * passed, the keys will be used as error keys and the values translation\n * parameters.\n * If the value is `true`, the input will be marked as invalid without any\n * hints under the input.\n */\n @Prop() errors?: boolean | string[] | ErrorMap;\n\n /**\n * Fine-grained control over when the errors are shown. Can be `false` to\n * never show errors, `true` to show errors on blur, or a number to show\n * errors on change with the given delay in milliseconds.\n */\n @Prop() errorUpdate: boolean | number = 0;\n\n /**\n * Attributes that will be added to the native HTML input element.\n */\n @Prop() nativeAttributes?: { [key: string]: string };\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\n\n /**\n * Emitted when the input received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n @Watch('value')\n onValueChanged(value: string) {\n if (value) {\n this.pickr?.setDate(value, false);\n this.catChange.emit(value);\n } else {\n this.pickr?.clear(false);\n this.catChange.emit(undefined);\n }\n }\n\n @Watch('disabled')\n @Watch('readonly')\n onDisabledChanged() {\n // Dynamically changing 'disabled' value is not working due to a bug in the\n // library. We thus need to fully recreate the date picker after the value\n // has been updated.\n this.pickr?.destroy();\n this.pickr = undefined;\n setTimeout(() => (this.pickr = this.initDatepicker(this.input)));\n }\n\n componentDidLoad() {\n this.pickr = this.initDatepicker(this.input);\n }\n\n /**\n * Programmatically move focus to the datepicker. Use this method instead of\n * `input.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async doFocus(options?: FocusOptions): Promise<void> {\n this._input?.doFocus(options);\n }\n\n /**\n * Programmatically remove focus from the datepicker. Use this method instead of\n * `input.blur()`.\n */\n @Method()\n async doBlur(): Promise<void> {\n this._input?.doBlur();\n }\n\n render() {\n return (\n <cat-input\n ref={el => (this._input = el)}\n requiredMarker={this.requiredMarker}\n horizontal={this.horizontal}\n autoComplete={this.autoComplete}\n clearable={this.clearable}\n disabled={this.disabled}\n hint={this.hint}\n icon={this.icon}\n iconRight={this.iconRight}\n identifier={this.identifier}\n label={this.label}\n labelHidden={this.labelHidden}\n name={this.name}\n placeholder={this.placeholder}\n textPrefix={this.textPrefix}\n textSuffix={this.textSuffix}\n readonly={this.readonly}\n required={this.required}\n value={this.value}\n errors={this.errors}\n errorUpdate={this.errorUpdate}\n nativeAttributes={this.nativeAttributes}\n onCatChange={e => {\n e.stopPropagation();\n this.value = e.detail || undefined;\n }}\n onCatFocus={e => {\n e.stopPropagation();\n this.catFocus.emit(e.detail);\n }}\n onCatBlur={e => {\n e.stopPropagation();\n this.catBlur.emit(e.detail);\n }}\n ></cat-input>\n );\n }\n\n private initDatepicker(input?: HTMLInputElement): flatpickr.Instance | undefined {\n if (this.disabled || this.readonly || !input) {\n return;\n }\n\n return flatpickr(\n input,\n getConfig({\n locale: getLocale(i18n.getLocale()),\n format: getFormat(i18n.getLocale(), this.mode),\n mode: this.mode,\n min: this.min,\n max: this.max,\n step: this.step,\n disabled: this.disabled,\n readonly: this.readonly,\n applyChange: value => (this.value = value)\n })\n );\n }\n}\n"],"version":3}
@@ -4140,16 +4140,16 @@ const CatDatepickerFlat = class {
4140
4140
  this.catChange.emit(undefined);
4141
4141
  }
4142
4142
  }
4143
- onDisabledChanged(value) {
4144
- this.pickr?.set('clickOpens', !value && !this.readonly);
4145
- }
4146
- onReadonlyChanged(value) {
4147
- this.pickr?.set('clickOpens', !value && !this.disabled);
4143
+ onDisabledChanged() {
4144
+ // Dynamically changing 'disabled' value is not working due to a bug in the
4145
+ // library. We thus need to fully recreate the date picker after the value
4146
+ // has been updated.
4147
+ this.pickr?.destroy();
4148
+ this.pickr = undefined;
4149
+ setTimeout(() => (this.pickr = this.initDatepicker(this.input)));
4148
4150
  }
4149
4151
  componentDidLoad() {
4150
- if (this.input) {
4151
- this.pickr = this.initDatepicker(this.input);
4152
- }
4152
+ this.pickr = this.initDatepicker(this.input);
4153
4153
  }
4154
4154
  /**
4155
4155
  * Programmatically move focus to the datepicker. Use this method instead of
@@ -4181,6 +4181,9 @@ const CatDatepickerFlat = class {
4181
4181
  } }));
4182
4182
  }
4183
4183
  initDatepicker(input) {
4184
+ if (this.disabled || this.readonly || !input) {
4185
+ return;
4186
+ }
4184
4187
  return flatpickr(input, getConfig({
4185
4188
  locale: getLocale(catI18nRegistry.getLocale()),
4186
4189
  format: getFormat(catI18nRegistry.getLocale(), this.mode),
@@ -4196,7 +4199,7 @@ const CatDatepickerFlat = class {
4196
4199
  static get watchers() { return {
4197
4200
  "value": ["onValueChanged"],
4198
4201
  "disabled": ["onDisabledChanged"],
4199
- "readonly": ["onReadonlyChanged"]
4202
+ "readonly": ["onDisabledChanged"]
4200
4203
  }; }
4201
4204
  };
4202
4205
  CatDatepickerFlat.style = catDatepickerCss;
@@ -4225,18 +4228,16 @@ const CatDatepickerInline = class {
4225
4228
  this.catChange.emit(undefined);
4226
4229
  }
4227
4230
  }
4228
- onDisabledChanged(value) {
4231
+ onDisabledChanged() {
4229
4232
  // Dynamically unsetting 'enabled' value to undefined is not working due to
4230
- // a bug in the library. We thus need to fully recreate the date picker.
4233
+ // a bug in the library. We thus need to fully recreate the date picker
4234
+ // after the value has been updated.
4231
4235
  this.pickr?.destroy();
4232
- if (this.input) {
4233
- this.pickr = this.initDatepicker(this.input, value);
4234
- }
4236
+ this.pickr = undefined;
4237
+ setTimeout(() => (this.pickr = this.initDatepicker(this.input)));
4235
4238
  }
4236
4239
  componentDidLoad() {
4237
- if (this.input) {
4238
- this.pickr = this.initDatepicker(this.input, this.disabled);
4239
- }
4240
+ this.pickr = this.initDatepicker(this.input);
4240
4241
  }
4241
4242
  render() {
4242
4243
  return (h(Host, null, h("div", { tabIndex: this.disabled || this.readonly ? -1 : undefined, class: {
@@ -4245,7 +4246,10 @@ const CatDatepickerInline = class {
4245
4246
  'datepicker-readonly': this.readonly
4246
4247
  } }, h("input", { ref: el => (this.input = el), value: this.value, disabled: this.disabled, readonly: this.readonly }))));
4247
4248
  }
4248
- initDatepicker(input, disabled) {
4249
+ initDatepicker(input) {
4250
+ if (!input) {
4251
+ return;
4252
+ }
4249
4253
  return flatpickr(input, getConfig({
4250
4254
  locale: getLocale(catI18nRegistry.getLocale()),
4251
4255
  format: getFormat(catI18nRegistry.getLocale(), this.mode),
@@ -4253,17 +4257,18 @@ const CatDatepickerInline = class {
4253
4257
  min: this.min,
4254
4258
  max: this.max,
4255
4259
  step: this.step,
4256
- disabled,
4260
+ disabled: this.disabled,
4257
4261
  readonly: this.readonly,
4258
4262
  applyChange: value => (this.value = value)
4259
4263
  }, {
4260
- ...(disabled ? { enable: [] } : {}),
4264
+ ...(this.disabled ? { enable: [] } : {}),
4261
4265
  inline: true
4262
4266
  }));
4263
4267
  }
4264
4268
  static get watchers() { return {
4265
4269
  "value": ["onValueChanged"],
4266
- "disabled": ["onDisabledChanged"]
4270
+ "disabled": ["onDisabledChanged"],
4271
+ "readonly": ["onDisabledChanged"]
4267
4272
  }; }
4268
4273
  };
4269
4274
  CatDatepickerInline.style = catDatepickerInlineCss;