@haiilo/catalyst 6.3.2 → 6.3.3

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.
Files changed (50) hide show
  1. package/dist/catalyst/catalyst.esm.js +1 -1
  2. package/dist/catalyst/p-2ecedf97.entry.js +10 -0
  3. package/dist/catalyst/p-2ecedf97.entry.js.map +1 -0
  4. package/dist/catalyst/scss/_snippets/_form-label.scss +12 -4
  5. package/dist/cjs/cat-alert_26.cjs.entry.js +45 -45
  6. package/dist/cjs/cat-alert_26.cjs.entry.js.map +1 -1
  7. package/dist/collection/components/cat-datepicker/cat-datepicker.js +2 -11
  8. package/dist/collection/components/cat-datepicker/cat-datepicker.js.map +1 -1
  9. package/dist/collection/components/cat-dropdown/cat-dropdown.js +20 -20
  10. package/dist/collection/components/cat-dropdown/cat-dropdown.js.map +1 -1
  11. package/dist/collection/components/cat-input/cat-input.css +24 -8
  12. package/dist/collection/components/cat-input/cat-input.js +2 -2
  13. package/dist/collection/components/cat-input/cat-input.js.map +1 -1
  14. package/dist/collection/components/cat-select/cat-select.css +24 -8
  15. package/dist/collection/components/cat-select/cat-select.js +3 -6
  16. package/dist/collection/components/cat-select/cat-select.js.map +1 -1
  17. package/dist/collection/components/cat-select/cat-select.spec.js +1 -1
  18. package/dist/collection/components/cat-select/cat-select.spec.js.map +1 -1
  19. package/dist/collection/components/cat-select-demo/cat-select-demo.js +1 -1
  20. package/dist/collection/components/cat-select-demo/cat-select-demo.js.map +1 -1
  21. package/dist/collection/components/cat-tabs/cat-tabs.js +1 -1
  22. package/dist/collection/components/cat-tabs/cat-tabs.js.map +1 -1
  23. package/dist/collection/components/cat-textarea/cat-textarea.css +24 -8
  24. package/dist/collection/components/cat-textarea/cat-textarea.js +1 -1
  25. package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
  26. package/dist/collection/scss/_snippets/_form-label.scss +12 -4
  27. package/dist/collection/utils/find-closest.js +13 -0
  28. package/dist/collection/utils/find-closest.js.map +1 -0
  29. package/dist/components/cat-datepicker.js +14 -11
  30. package/dist/components/cat-datepicker.js.map +1 -1
  31. package/dist/components/cat-dropdown2.js +20 -20
  32. package/dist/components/cat-dropdown2.js.map +1 -1
  33. package/dist/components/cat-input2.js +3 -3
  34. package/dist/components/cat-input2.js.map +1 -1
  35. package/dist/components/cat-select-demo.js +1 -1
  36. package/dist/components/cat-select-demo.js.map +1 -1
  37. package/dist/components/cat-select2.js +4 -7
  38. package/dist/components/cat-select2.js.map +1 -1
  39. package/dist/components/cat-tabs.js +1 -1
  40. package/dist/components/cat-tabs.js.map +1 -1
  41. package/dist/components/cat-textarea.js +2 -2
  42. package/dist/components/cat-textarea.js.map +1 -1
  43. package/dist/esm/cat-alert_26.entry.js +45 -45
  44. package/dist/esm/cat-alert_26.entry.js.map +1 -1
  45. package/dist/types/components/cat-datepicker/cat-datepicker.d.ts +0 -1
  46. package/dist/types/components/cat-dropdown/cat-dropdown.d.ts +1 -0
  47. package/dist/types/utils/find-closest.d.ts +5 -0
  48. package/package.json +2 -2
  49. package/dist/catalyst/p-2257ac13.entry.js +0 -10
  50. package/dist/catalyst/p-2257ac13.entry.js.map +0 -1
@@ -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;EA2JD,cAAc,CAAC,KAAa;IAC1B,IAAI,KAAK,EAAE;MACT,IAAI,CAAC,KAAK,EAAE,OAAO,CAA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AE,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,sBAAsB,EAAE,EAAE,GAAG,sBAAsB,EAAE,GAAG,IAAI,CAAC,sBAAsB,EAAE;MACrF,WAAW,EAAE,KAAK,KAAK,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;KAC3C,CAAC,CACH,CAAC;GACH;EAEO,WAAW,CAAC,QAAgB,EAAE,OAA6B;IACjE,IAAI,OAAO,YAAY,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;MAC3D,OAAO,OAAO,CAAC;KAChB;;IAGD,MAAM,WAAW,GACf,OAAO,YAAY,UAAU;QACzB,OAAO,CAAC,IAAI;QACZ,OAAO,CAAC,aAAa,IAAK,OAAO,CAAC,WAAW,EAAiB,CAAC,IAAI,CAAC;IAC1E,OAAO,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAI,CAAC;GACrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","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 * Attributes that will be added to the rendered HTML datepicker element.\n */\n @Prop() nativePickerAttributes?: { [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 // avoid dropdown closing if datepicker is part of a dropdown\n const withinDropdown = !!this.findClosest('cat-dropdown', input);\n const nativePickerAttributes: { [key: string]: string } = withinDropdown ? { 'data-dropdown-no-close': '' } : {};\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 nativePickerAttributes: { ...nativePickerAttributes, ...this.nativePickerAttributes },\n applyChange: value => (this.value = value)\n })\n );\n }\n\n private findClosest(selector: string, element: Element | ShadowRoot): Element | null {\n if (element instanceof Element && element.matches(selector)) {\n return element;\n }\n\n // Search in parent element or Shadow DOM host\n const nextElement =\n element instanceof ShadowRoot\n ? element.host\n : element.parentElement || (element.getRootNode() as ShadowRoot).host;\n return nextElement ? this.findClosest(selector, nextElement) : null;\n }\n}\n"],"version":3}
1
+ {"file":"cat-datepicker.js","mappings":";;;;;;;;AAAA;;;;SAIgB,WAAW,CAAC,QAAgB,EAAE,OAA6B;EACzE,IAAI,OAAO,YAAY,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;IAC3D,OAAO,OAAO,CAAC;GAChB;;EAGD,MAAM,WAAW,GACf,OAAO,YAAY,UAAU,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,aAAa,IAAK,OAAO,CAAC,WAAW,EAAiB,CAAC,IAAI,CAAC;EACrH,OAAO,WAAW,GAAG,WAAW,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAI,CAAC;AACjE;;ACbA,MAAM,gBAAgB,GAAG,sGAAsG;;MCelH,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;EA2JD,cAAc,CAAC,KAAa;IAC1B,IAAI,KAAK,EAAE;MACT,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;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E,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,sBAAsB,EAAE,EAAE,GAAG,sBAAsB,EAAE,GAAG,IAAI,CAAC,sBAAsB,EAAE;MACrF,WAAW,EAAE,KAAK,KAAK,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;KAC3C,CAAC,CACH,CAAC;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["i18n"],"sources":["src/utils/find-closest.ts","src/components/cat-datepicker/cat-datepicker.scss?tag=cat-datepicker&encapsulation=shadow","src/components/cat-datepicker/cat-datepicker.tsx"],"sourcesContent":["/**\n * Find the closest parent element matching the given selector while traversing\n * up the DOM tree (including Shadow DOM).\n */\nexport function findClosest(selector: string, element: Element | ShadowRoot): Element | null {\n if (element instanceof Element && element.matches(selector)) {\n return element;\n }\n\n // Search in parent element or Shadow DOM host\n const nextElement =\n element instanceof ShadowRoot ? element.host : element.parentElement || (element.getRootNode() as ShadowRoot).host;\n return nextElement ? findClosest(selector, nextElement) : null;\n}\n","@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 { findClosest } from '../../utils/find-closest';\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 * Attributes that will be added to the rendered HTML datepicker element.\n */\n @Prop() nativePickerAttributes?: { [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 // avoid dropdown closing if datepicker is part of a dropdown\n const withinDropdown = !!findClosest('cat-dropdown', input);\n const nativePickerAttributes: { [key: string]: string } = withinDropdown ? { 'data-dropdown-no-close': '' } : {};\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 nativePickerAttributes: { ...nativePickerAttributes, ...this.nativePickerAttributes },\n applyChange: value => (this.value = value)\n })\n );\n }\n}\n"],"version":3}
@@ -1512,7 +1512,7 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1512
1512
  this.overflow = false;
1513
1513
  }
1514
1514
  clickHandler(event) {
1515
- // we need to delay the initialization of the trigger until first,
1515
+ // we need to delay the initialization of the trigger until first
1516
1516
  // interaction because the element might still be hidden (and thus not
1517
1517
  // tabbable) if contained in another Stencil web component
1518
1518
  if (!this.trigger) {
@@ -1520,10 +1520,14 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1520
1520
  this.toggle();
1521
1521
  }
1522
1522
  // hide dropdown on button clicks inside the dropdown content
1523
+ const path = event.composedPath();
1523
1524
  if (!this.noAutoClose &&
1524
- event.composedPath().includes(this.content) &&
1525
- event.target instanceof Element &&
1526
- event.target.slot !== 'trigger') {
1525
+ // check if click was inside of the dropdown content
1526
+ path.includes(this.content) &&
1527
+ // check if click was not on a trigger for a sub-dropdown
1528
+ event.target?.slot !== 'trigger' &&
1529
+ // check if click was not an element marked with data-dropdown-no-close
1530
+ !path.slice(0, path.indexOf(this.content)).find(el => this.hasAttribute(el, 'data-dropdown-no-close'))) {
1527
1531
  this.close();
1528
1532
  }
1529
1533
  }
@@ -1537,8 +1541,8 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1537
1541
  * Opens the dropdown.
1538
1542
  */
1539
1543
  async open() {
1540
- if (this.isOpen === null) {
1541
- return; // busy
1544
+ if (this.isOpen === null || this.isOpen) {
1545
+ return; // busy or open
1542
1546
  }
1543
1547
  this.isOpen = null;
1544
1548
  this.content.style.display = 'block';
@@ -1555,18 +1559,11 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1555
1559
  getShadowRoot: true
1556
1560
  },
1557
1561
  allowOutsideClick: true,
1558
- clickOutsideDeactivates: event => {
1559
- const shouldClose = !this.noAutoClose &&
1560
- !event.composedPath().includes(this.content) &&
1561
- !event
1562
- .composedPath()
1563
- .find(el => el instanceof HTMLElement && el.hasAttribute('data-dropdown-no-close')) &&
1564
- (!this.trigger || !event.composedPath().includes(this.trigger));
1565
- if (shouldClose) {
1566
- this.close();
1567
- }
1568
- return shouldClose;
1569
- },
1562
+ clickOutsideDeactivates: event => !this.noAutoClose &&
1563
+ // check if click was outside of the dropdown content
1564
+ !event.composedPath().includes(this.content) &&
1565
+ // check if click was not on an element marked with data-dropdown-no-close
1566
+ !event.composedPath().find(el => this.hasAttribute(el, 'data-dropdown-no-close')),
1570
1567
  onPostDeactivate: () => this.close()
1571
1568
  });
1572
1569
  this.trap.activate();
@@ -1576,8 +1573,8 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1576
1573
  * Closes the dropdown.
1577
1574
  */
1578
1575
  async close() {
1579
- if (this.isOpen === null) {
1580
- return; // busy
1576
+ if (!this.isOpen) {
1577
+ return; // busy or closed
1581
1578
  }
1582
1579
  this.isOpen = null;
1583
1580
  this.content.classList.remove('show');
@@ -1668,6 +1665,9 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1668
1665
  });
1669
1666
  }
1670
1667
  }
1668
+ hasAttribute(elem, attr) {
1669
+ return elem instanceof HTMLElement && elem.hasAttribute(attr);
1670
+ }
1671
1671
  static get style() { return catDropdownCss; }
1672
1672
  }, [1, "cat-dropdown", {
1673
1673
  "placement": [1],