@haiilo/catalyst 10.29.0 → 10.30.0
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.
- package/dist/catalyst/catalyst.css +3 -1
- package/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/index.esm.js +1 -1
- package/dist/catalyst/p-41a50f19.entry.js +10 -0
- package/dist/catalyst/p-41a50f19.entry.js.map +1 -0
- package/dist/catalyst/{p-e5aee21d.js → p-9500d6fb.js} +1 -1
- package/dist/catalyst/{p-e5aee21d.js.map → p-9500d6fb.js.map} +1 -1
- package/dist/catalyst/scss/core/_notification.scss +4 -1
- package/dist/catalyst/scss/utils/_elevation.mixins.scss +8 -2
- package/dist/cjs/cat-alert_30.cjs.entry.js +266 -176
- package/dist/cjs/cat-alert_30.cjs.entry.js.map +1 -1
- package/dist/cjs/catalyst.cjs.js +1 -1
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{of-aaee31a6.js → of-958251e4.js} +1 -1
- package/dist/cjs/{of-aaee31a6.js.map → of-958251e4.js.map} +1 -1
- package/dist/collection/components/cat-button/cat-button.css +1 -1
- package/dist/collection/components/cat-date/cat-date.js +8 -7
- package/dist/collection/components/cat-date/cat-date.js.map +1 -1
- package/dist/collection/components/cat-date-inline/cat-date-inline.js +10 -8
- package/dist/collection/components/cat-date-inline/cat-date-inline.js.map +1 -1
- package/dist/collection/components/cat-date-inline/cat-date-locale.js +2 -4
- package/dist/collection/components/cat-date-inline/cat-date-locale.js.map +1 -1
- package/dist/collection/components/cat-datepicker/cat-datepicker.js +9 -8
- package/dist/collection/components/cat-datepicker/cat-datepicker.js.map +1 -1
- package/dist/collection/components/cat-dropdown/cat-dropdown.js +1 -1
- package/dist/collection/components/cat-select/cat-select.js +1 -1
- package/dist/collection/components/cat-textarea/cat-textarea.js +21 -3
- package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
- package/dist/collection/components/cat-time/cat-time.js +8 -7
- package/dist/collection/components/cat-time/cat-time.js.map +1 -1
- package/dist/collection/components/cat-tooltip/cat-tooltip.css +18 -9
- package/dist/collection/scss/core/_notification.scss +4 -1
- package/dist/collection/scss/utils/_elevation.mixins.scss +8 -2
- package/dist/components/cat-button2.js +1 -1
- package/dist/components/cat-button2.js.map +1 -1
- package/dist/components/cat-date-inline2.js +12 -12
- package/dist/components/cat-date-inline2.js.map +1 -1
- package/dist/components/cat-date.js +3 -3
- package/dist/components/cat-date.js.map +1 -1
- package/dist/components/cat-datepicker.js +4 -4
- package/dist/components/cat-datepicker.js.map +1 -1
- package/dist/components/cat-dropdown2.js +169 -118
- package/dist/components/cat-dropdown2.js.map +1 -1
- package/dist/components/cat-textarea.js +5 -3
- package/dist/components/cat-textarea.js.map +1 -1
- package/dist/components/cat-time.js +3 -3
- package/dist/components/cat-time.js.map +1 -1
- package/dist/components/cat-tooltip.js +1 -1
- package/dist/components/cat-tooltip.js.map +1 -1
- package/dist/components/floating-ui.dom.esm.js +67 -29
- package/dist/components/floating-ui.dom.esm.js.map +1 -1
- package/dist/components/loglevel.js.map +1 -1
- package/dist/esm/cat-alert_30.entry.js +266 -176
- package/dist/esm/cat-alert_30.entry.js.map +1 -1
- package/dist/esm/catalyst.js +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{of-acb1f3a9.js → of-e4ec2eb4.js} +1 -1
- package/dist/esm/{of-acb1f3a9.js.map → of-e4ec2eb4.js.map} +1 -1
- package/dist/types/components/cat-date/cat-date.d.ts +1 -1
- package/dist/types/components/cat-datepicker/cat-datepicker.d.ts +1 -1
- package/dist/types/components/cat-textarea/cat-textarea.d.ts +4 -0
- package/dist/types/components/cat-time/cat-time.d.ts +1 -1
- package/dist/types/components.d.ts +11 -3
- package/package.json +8 -8
- package/dist/catalyst/p-bb8516c7.entry.js +0 -10
- package/dist/catalyst/p-bb8516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D,WAAW,EAAE,KAAK,KAAK,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;SAC3C,CAAC,CACH,CAAC;KACH;IAEO,cAAc,CAAC,SAA6B,EAAE,eAAwC;QAC5F,IAAI,eAAe,EAAE;YACnB,eAAe,CAAC,eAAmC,EAAE,SAAS,CAAC,iBAAiB,EAAE;gBAChF,QAAQ,EAAE,OAAO;gBACjB,SAAS,EAAG,IAAI,CAAC,QAAsB,IAAI,cAAc;gBACzD,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC;aACrB,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE;gBAC1B,IAAI,SAAS,CAAC,iBAAiB,EAAE;oBAC/B,SAAS,CAAC,iBAAiB,CAAC,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;oBAC1D,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE;wBAC/C,IAAI,EAAE,GAAG,CAAC,IAAI;wBACd,GAAG,EAAE,GAAG,CAAC,IAAI;wBACb,QAAQ,EAAE,OAAO;qBAClB,CAAC,CAAC;iBACJ;aACF,CAAC,CAAC;SACJ;KACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","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@import '~flatpickr/dist/flatpickr.css';\n@import 'vendor/flatpickr';\n\n:host {\n display: flex;\n}\n\n:host([hidden]) {\n display: none;\n}\n\ncat-input {\n flex: 1 1 auto;\n margin: 0;\n}\n","import { Component, Element, Event, EventEmitter, Method, Prop, State, 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';\nimport { autoUpdate, computePosition, flip, Placement, ReferenceElement } from '@floating-ui/dom';\nimport { BaseOptions } from 'flatpickr/dist/types/options';\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 _calendarWrapper?: HTMLDivElement;\n private get input(): HTMLInputElement | undefined {\n return this._input?.shadowRoot?.querySelector('input') ?? undefined;\n }\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n @State() hasSlottedHint = false;\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 * Instead of body, appends the calendar to the cat-datepicker element instead\n */\n @Prop() attachToElement = false;\n\n /**\n * Where the calendar is rendered relative to the input vertically and horizontally.\n * In the format of \"[vertical] [horizontal]\". Vertical can be auto, above or below (required).\n * Horizontal can be left, center or right.\n * If @attachToElement is passed the value should be in Placement format\n */\n @Prop() position?: BaseOptions['position'] | Placement;\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 change with the given delay in milliseconds or immediately on blur.\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 if (this.mode !== 'daterange' || value.includes(' - ')) {\n this.catChange.emit(value);\n }\n } else {\n this.pickr?.clear(false);\n this.catChange.emit(undefined);\n }\n }\n\n @Watch('disabled')\n @Watch('readonly')\n @Watch('mode')\n onDisabledChanged() {\n // Dynamically changing config 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(() => {\n this.input ? (this.input.disabled = this.disabled) : null;\n this.pickr = this.initDatepicker(this.input);\n });\n }\n\n componentDidLoad() {\n this.pickr = this.initDatepicker(this.input);\n }\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n this.hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n }\n\n @Watch('min')\n @Watch('max')\n onMinChanged() {\n this.pickr?.set('minDate', this.min);\n this.pickr?.set('maxDate', this.max);\n if (this.value && !this.pickr?.selectedDates?.length) {\n // Dynamically changing 'minDate' or 'maxDate' does not emit a change if\n // the value is cleared due to an invalid date.\n this.pickr?.clear();\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 >\n {this.hasSlottedLabel && (\n <span slot=\"label\">\n <slot name=\"label\"></slot>\n </span>\n )}\n {this.hasSlottedHint && (\n <span slot=\"hint\">\n <slot name=\"hint\"></slot>\n </span>\n )}\n </cat-input>,\n <div ref={el => (this._calendarWrapper = el)} class=\"datepicker-wrapper\"></div>\n ];\n }\n\n private initDatepicker(input?: HTMLInputElement): flatpickr.Instance | undefined {\n if (!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 appendTo: this.attachToElement ? this._calendarWrapper : undefined,\n nativePickerAttributes: { ...nativePickerAttributes, ...this.nativePickerAttributes },\n // flatpickr has open bug about incorrect positioning when appendTo is used,\n // we have to use custom logic to calculate position\n // https://github.com/flatpickr/flatpickr/issues/1619\n position: this.attachToElement\n ? (flatpickr, positionElement) => {\n this.updatePosition(flatpickr, positionElement);\n }\n : (this.position as BaseOptions['position']) || undefined,\n onReady: (_dates, _dateStr, flatpickr) => {\n autoUpdate(input, flatpickr.calendarContainer, () => this.updatePosition(flatpickr, flatpickr._input));\n },\n applyChange: value => (this.value = value)\n })\n );\n }\n\n private updatePosition(flatpickr: flatpickr.Instance, positionElement: HTMLElement | undefined): void {\n if (positionElement) {\n computePosition(positionElement as ReferenceElement, flatpickr.calendarContainer, {\n strategy: 'fixed',\n placement: (this.position as Placement) || 'bottom-start',\n middleware: [flip()]\n }).then(({ x, y, placement }) => {\n if (flatpickr.calendarContainer) {\n flatpickr.calendarContainer.dataset.placement = placement;\n Object.assign(flatpickr.calendarContainer.style, {\n left: `${x}px`,\n top: `${y}px`,\n position: 'fixed'\n });\n }\n });\n }\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"cat-datepicker.js","mappings":";;;;;;;;;AAAA,MAAM,gBAAgB,GAAG,m5vBAAm5vB,CAAC;AAC76vB,4BAAe,gBAAgB;;MCgBlB,iBAAiB;;;;;;;;+BAUD,KAAK;8BAEN,KAAK;8BAKmE,UAAU;0BAKvF,KAAK;4BAKH,KAAK;yBAKR,KAAK;wBAKN,KAAK;;;yBAeJ,KAAK;;qBAUT,EAAE;2BAKI,KAAK;;;oBAeO,MAAM;;;;;wBAyBrB,KAAK;wBAKL,KAAK;oBAKT,CAAC;+BAKU,KAAK;;;;2BA8BS,CAAC;;;;IApJzC,IAAY,KAAK;QACf,OAAO,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,OAAO,CAAC,IAAI,SAAS,CAAC;KACrE;IA8KD,cAAc,CAAC,KAAa;QAC1B,IAAI,KAAK,EAAE;YACT,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAClC,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;gBACtD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAC5B;SACF;a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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","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@import '~flatpickr/dist/flatpickr.css';\n@import 'vendor/flatpickr';\n\n:host {\n display: flex;\n}\n\n:host([hidden]) {\n display: none;\n}\n\ncat-input {\n flex: 1 1 auto;\n margin: 0;\n}\n","import { Component, Element, Event, EventEmitter, Method, Prop, State, 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';\nimport { autoUpdate, computePosition, flip, Placement, ReferenceElement } from '@floating-ui/dom';\nimport { BaseOptions } from 'flatpickr/dist/types/options';\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 _calendarWrapper?: HTMLDivElement;\n private get input(): HTMLInputElement | undefined {\n return this._input?.shadowRoot?.querySelector('input') ?? undefined;\n }\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n @State() hasSlottedHint = false;\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 = 'off';\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 * Instead of body, appends the calendar to the cat-datepicker element instead\n */\n @Prop() attachToElement = false;\n\n /**\n * Where the calendar is rendered relative to the input vertically and horizontally.\n * In the format of \"[vertical] [horizontal]\". Vertical can be auto, above or below (required).\n * Horizontal can be left, center or right.\n * If @attachToElement is passed the value should be in Placement format\n */\n @Prop() position?: BaseOptions['position'] | Placement;\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 change with the given delay in milliseconds or immediately on blur.\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 if (this.mode !== 'daterange' || value.includes(' - ')) {\n this.catChange.emit(value);\n }\n } else {\n this.pickr?.clear(false);\n this.catChange.emit(undefined);\n }\n }\n\n @Watch('disabled')\n @Watch('readonly')\n @Watch('mode')\n onDisabledChanged() {\n // Dynamically changing config 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(() => {\n this.input ? (this.input.disabled = this.disabled) : null;\n this.pickr = this.initDatepicker(this.input);\n });\n }\n\n componentDidLoad() {\n this.pickr = this.initDatepicker(this.input);\n }\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n this.hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n }\n\n @Watch('min')\n @Watch('max')\n onMinChanged() {\n this.pickr?.set('minDate', this.min);\n this.pickr?.set('maxDate', this.max);\n if (this.value && !this.pickr?.selectedDates?.length) {\n // Dynamically changing 'minDate' or 'maxDate' does not emit a change if\n // the value is cleared due to an invalid date.\n this.pickr?.clear();\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 >\n {this.hasSlottedLabel && (\n <span slot=\"label\">\n <slot name=\"label\"></slot>\n </span>\n )}\n {this.hasSlottedHint && (\n <span slot=\"hint\">\n <slot name=\"hint\"></slot>\n </span>\n )}\n </cat-input>,\n <div ref={el => (this._calendarWrapper = el)} class=\"datepicker-wrapper\"></div>\n ];\n }\n\n private initDatepicker(input?: HTMLInputElement): flatpickr.Instance | undefined {\n if (!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 appendTo: this.attachToElement ? this._calendarWrapper : undefined,\n nativePickerAttributes: { ...nativePickerAttributes, ...this.nativePickerAttributes },\n // flatpickr has open bug about incorrect positioning when appendTo is used,\n // we have to use custom logic to calculate position\n // https://github.com/flatpickr/flatpickr/issues/1619\n position: this.attachToElement\n ? (flatpickr, positionElement) => {\n this.updatePosition(flatpickr, positionElement);\n }\n : (this.position as BaseOptions['position']) || undefined,\n onReady: (_dates, _dateStr, flatpickr) => {\n autoUpdate(input, flatpickr.calendarContainer, () => this.updatePosition(flatpickr, flatpickr._input));\n },\n applyChange: value => (this.value = value)\n })\n );\n }\n\n private updatePosition(flatpickr: flatpickr.Instance, positionElement: HTMLElement | undefined): void {\n if (positionElement) {\n computePosition(positionElement as ReferenceElement, flatpickr.calendarContainer, {\n strategy: 'fixed',\n placement: (this.position as Placement) || 'bottom-start',\n middleware: [flip()]\n }).then(({ x, y, placement }) => {\n if (flatpickr.calendarContainer) {\n flatpickr.calendarContainer.dataset.placement = placement;\n Object.assign(flatpickr.calendarContainer.style, {\n left: `${x}px`,\n top: `${y}px`,\n position: 'fixed'\n });\n }\n });\n }\n }\n}\n"],"version":3}
|
|
@@ -8,10 +8,32 @@ import { t as tabbable, a as focusable, i as isTabbable, g as getTabIndex, b as
|
|
|
8
8
|
const timeTransitionS = 125;
|
|
9
9
|
|
|
10
10
|
/*!
|
|
11
|
-
* focus-trap 7.
|
|
11
|
+
* focus-trap 7.6.4
|
|
12
12
|
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
function _arrayLikeToArray(r, a) {
|
|
16
|
+
(null == a || a > r.length) && (a = r.length);
|
|
17
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
18
|
+
return n;
|
|
19
|
+
}
|
|
20
|
+
function _arrayWithoutHoles(r) {
|
|
21
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
22
|
+
}
|
|
23
|
+
function _defineProperty(e, r, t) {
|
|
24
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
25
|
+
value: t,
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true
|
|
29
|
+
}) : e[r] = t, e;
|
|
30
|
+
}
|
|
31
|
+
function _iterableToArray(r) {
|
|
32
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
33
|
+
}
|
|
34
|
+
function _nonIterableSpread() {
|
|
35
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
36
|
+
}
|
|
15
37
|
function ownKeys(e, r) {
|
|
16
38
|
var t = Object.keys(e);
|
|
17
39
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -25,7 +47,7 @@ function ownKeys(e, r) {
|
|
|
25
47
|
function _objectSpread2(e) {
|
|
26
48
|
for (var r = 1; r < arguments.length; r++) {
|
|
27
49
|
var t = null != arguments[r] ? arguments[r] : {};
|
|
28
|
-
r % 2 ? ownKeys(Object(t),
|
|
50
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
29
51
|
_defineProperty(e, r, t[r]);
|
|
30
52
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
31
53
|
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
@@ -33,33 +55,29 @@ function _objectSpread2(e) {
|
|
|
33
55
|
}
|
|
34
56
|
return e;
|
|
35
57
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
if (key in obj) {
|
|
39
|
-
Object.defineProperty(obj, key, {
|
|
40
|
-
value: value,
|
|
41
|
-
enumerable: true,
|
|
42
|
-
configurable: true,
|
|
43
|
-
writable: true
|
|
44
|
-
});
|
|
45
|
-
} else {
|
|
46
|
-
obj[key] = value;
|
|
47
|
-
}
|
|
48
|
-
return obj;
|
|
58
|
+
function _toConsumableArray(r) {
|
|
59
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
49
60
|
}
|
|
50
|
-
function _toPrimitive(
|
|
51
|
-
if (
|
|
52
|
-
var
|
|
53
|
-
if (
|
|
54
|
-
var
|
|
55
|
-
if (
|
|
61
|
+
function _toPrimitive(t, r) {
|
|
62
|
+
if ("object" != typeof t || !t) return t;
|
|
63
|
+
var e = t[Symbol.toPrimitive];
|
|
64
|
+
if (undefined !== e) {
|
|
65
|
+
var i = e.call(t, r || "default");
|
|
66
|
+
if ("object" != typeof i) return i;
|
|
56
67
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
57
68
|
}
|
|
58
|
-
return (
|
|
69
|
+
return ("string" === r ? String : Number)(t);
|
|
59
70
|
}
|
|
60
|
-
function _toPropertyKey(
|
|
61
|
-
var
|
|
62
|
-
return
|
|
71
|
+
function _toPropertyKey(t) {
|
|
72
|
+
var i = _toPrimitive(t, "string");
|
|
73
|
+
return "symbol" == typeof i ? i : i + "";
|
|
74
|
+
}
|
|
75
|
+
function _unsupportedIterableToArray(r, a) {
|
|
76
|
+
if (r) {
|
|
77
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
78
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
79
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : undefined;
|
|
80
|
+
}
|
|
63
81
|
}
|
|
64
82
|
|
|
65
83
|
var activeFocusTraps = {
|
|
@@ -67,7 +85,7 @@ var activeFocusTraps = {
|
|
|
67
85
|
if (trapStack.length > 0) {
|
|
68
86
|
var activeTrap = trapStack[trapStack.length - 1];
|
|
69
87
|
if (activeTrap !== trap) {
|
|
70
|
-
activeTrap.
|
|
88
|
+
activeTrap._setPausedState(true);
|
|
71
89
|
}
|
|
72
90
|
}
|
|
73
91
|
var trapIndex = trapStack.indexOf(trap);
|
|
@@ -84,8 +102,8 @@ var activeFocusTraps = {
|
|
|
84
102
|
if (trapIndex !== -1) {
|
|
85
103
|
trapStack.splice(trapIndex, 1);
|
|
86
104
|
}
|
|
87
|
-
if (trapStack.length > 0) {
|
|
88
|
-
trapStack[trapStack.length - 1].
|
|
105
|
+
if (trapStack.length > 0 && !trapStack[trapStack.length - 1]._isManuallyPaused()) {
|
|
106
|
+
trapStack[trapStack.length - 1]._setPausedState(false);
|
|
89
107
|
}
|
|
90
108
|
}
|
|
91
109
|
};
|
|
@@ -93,10 +111,10 @@ var isSelectableInput = function isSelectableInput(node) {
|
|
|
93
111
|
return node.tagName && node.tagName.toLowerCase() === 'input' && typeof node.select === 'function';
|
|
94
112
|
};
|
|
95
113
|
var isEscapeEvent = function isEscapeEvent(e) {
|
|
96
|
-
return (e === null || e ===
|
|
114
|
+
return (e === null || e === undefined ? undefined : e.key) === 'Escape' || (e === null || e === undefined ? undefined : e.key) === 'Esc' || (e === null || e === undefined ? undefined : e.keyCode) === 27;
|
|
97
115
|
};
|
|
98
116
|
var isTabEvent = function isTabEvent(e) {
|
|
99
|
-
return (e === null || e ===
|
|
117
|
+
return (e === null || e === undefined ? undefined : e.key) === 'Tab' || (e === null || e === undefined ? undefined : e.keyCode) === 9;
|
|
100
118
|
};
|
|
101
119
|
|
|
102
120
|
// checks for TAB by default
|
|
@@ -112,22 +130,6 @@ var delay = function delay(fn) {
|
|
|
112
130
|
return setTimeout(fn, 0);
|
|
113
131
|
};
|
|
114
132
|
|
|
115
|
-
// Array.find/findIndex() are not supported on IE; this replicates enough
|
|
116
|
-
// of Array.findIndex() for our needs
|
|
117
|
-
var findIndex = function findIndex(arr, fn) {
|
|
118
|
-
var idx = -1;
|
|
119
|
-
arr.every(function (value, i) {
|
|
120
|
-
if (fn(value)) {
|
|
121
|
-
idx = i;
|
|
122
|
-
return false; // break
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return true; // next
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
return idx;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
133
|
/**
|
|
132
134
|
* Get an option's value when it could be a plain value, or a handler that provides
|
|
133
135
|
* the value.
|
|
@@ -139,7 +141,7 @@ var valueOrHandler = function valueOrHandler(value) {
|
|
|
139
141
|
for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
140
142
|
params[_key - 1] = arguments[_key];
|
|
141
143
|
}
|
|
142
|
-
return typeof value === 'function' ? value.apply(
|
|
144
|
+
return typeof value === 'function' ? value.apply(undefined, params) : value;
|
|
143
145
|
};
|
|
144
146
|
var getActualTarget = function getActualTarget(event) {
|
|
145
147
|
// NOTE: If the trap is _inside_ a shadow DOM, event.target will always be the
|
|
@@ -158,8 +160,8 @@ var internalTrapStack = [];
|
|
|
158
160
|
var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
159
161
|
// SSR: a live trap shouldn't be created in this type of environment so this
|
|
160
162
|
// should be safe code to execute if the `document` option isn't specified
|
|
161
|
-
var doc = (userOptions === null || userOptions ===
|
|
162
|
-
var trapStack = (userOptions === null || userOptions ===
|
|
163
|
+
var doc = (userOptions === null || userOptions === undefined ? undefined : userOptions.document) || document;
|
|
164
|
+
var trapStack = (userOptions === null || userOptions === undefined ? undefined : userOptions.trapStack) || internalTrapStack;
|
|
163
165
|
var config = _objectSpread2({
|
|
164
166
|
returnFocusOnDeactivate: true,
|
|
165
167
|
escapeDeactivates: true,
|
|
@@ -199,6 +201,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
199
201
|
mostRecentlyFocusedNode: null,
|
|
200
202
|
active: false,
|
|
201
203
|
paused: false,
|
|
204
|
+
manuallyPaused: false,
|
|
202
205
|
// timer ID for when delayInitialFocus is true and initial focus in this trap
|
|
203
206
|
// has been delayed during activation
|
|
204
207
|
delayInitialFocusTimer: undefined,
|
|
@@ -230,18 +233,18 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
230
233
|
* if the element isn't found.
|
|
231
234
|
*/
|
|
232
235
|
var findContainerIndex = function findContainerIndex(element, event) {
|
|
233
|
-
var composedPath = typeof (event === null || event ===
|
|
236
|
+
var composedPath = typeof (event === null || event === undefined ? undefined : event.composedPath) === 'function' ? event.composedPath() : undefined;
|
|
234
237
|
// NOTE: search `containerGroups` because it's possible a group contains no tabbable
|
|
235
238
|
// nodes, but still contains focusable nodes (e.g. if they all have `tabindex=-1`)
|
|
236
239
|
// and we still need to find the element in there
|
|
237
240
|
return state.containerGroups.findIndex(function (_ref) {
|
|
238
241
|
var container = _ref.container,
|
|
239
242
|
tabbableNodes = _ref.tabbableNodes;
|
|
240
|
-
return container.contains(element) || (
|
|
243
|
+
return container.contains(element) || (// fall back to explicit tabbable search which will take into consideration any
|
|
241
244
|
// web components if the `tabbableOptions.getShadowRoot` option was used for
|
|
242
245
|
// the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
|
|
243
246
|
// look inside web components even if open)
|
|
244
|
-
composedPath === null || composedPath ===
|
|
247
|
+
composedPath === null || composedPath === undefined ? undefined : composedPath.includes(container)) || tabbableNodes.find(function (node) {
|
|
245
248
|
return node === element;
|
|
246
249
|
});
|
|
247
250
|
});
|
|
@@ -253,25 +256,31 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
253
256
|
* (if a node is explicitly NOT given), or a function that returns any of these
|
|
254
257
|
* values.
|
|
255
258
|
* @param {string} optionName
|
|
256
|
-
* @
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
259
|
+
* @param {Object} options
|
|
260
|
+
* @param {boolean} [options.hasFallback] True if the option could be a selector string
|
|
261
|
+
* and the option allows for a fallback scenario in the case where the selector is
|
|
262
|
+
* valid but does not match a node (i.e. the queried node doesn't exist in the DOM).
|
|
263
|
+
* @param {Array} [options.params] Params to pass to the option if it's a function.
|
|
264
|
+
* @returns {undefined | null | false | HTMLElement | SVGElement} Returns
|
|
265
|
+
* `undefined` if the option is not specified; `null` if the option didn't resolve
|
|
266
|
+
* to a node but `options.hasFallback=true`, `false` if the option resolved to `false`
|
|
267
|
+
* (node explicitly not given); otherwise, the resolved DOM node.
|
|
260
268
|
* @throws {Error} If the option is set, not `false`, and is not, or does not
|
|
261
|
-
* resolve to a node.
|
|
269
|
+
* resolve to a node, unless the option is a selector string and `options.hasFallback=true`.
|
|
262
270
|
*/
|
|
263
271
|
var getNodeForOption = function getNodeForOption(optionName) {
|
|
272
|
+
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
273
|
+
_ref2$hasFallback = _ref2.hasFallback,
|
|
274
|
+
hasFallback = _ref2$hasFallback === undefined ? false : _ref2$hasFallback,
|
|
275
|
+
_ref2$params = _ref2.params,
|
|
276
|
+
params = _ref2$params === undefined ? [] : _ref2$params;
|
|
264
277
|
var optionValue = config[optionName];
|
|
265
278
|
if (typeof optionValue === 'function') {
|
|
266
|
-
|
|
267
|
-
params[_key2 - 1] = arguments[_key2];
|
|
268
|
-
}
|
|
269
|
-
optionValue = optionValue.apply(void 0, params);
|
|
279
|
+
optionValue = optionValue.apply(undefined, _toConsumableArray(params));
|
|
270
280
|
}
|
|
271
281
|
if (optionValue === true) {
|
|
272
282
|
optionValue = undefined; // use default value
|
|
273
283
|
}
|
|
274
|
-
|
|
275
284
|
if (!optionValue) {
|
|
276
285
|
if (optionValue === undefined || optionValue === false) {
|
|
277
286
|
return optionValue;
|
|
@@ -283,21 +292,31 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
283
292
|
var node = optionValue; // could be HTMLElement, SVGElement, or non-empty string at this point
|
|
284
293
|
|
|
285
294
|
if (typeof optionValue === 'string') {
|
|
286
|
-
|
|
295
|
+
try {
|
|
296
|
+
node = doc.querySelector(optionValue); // resolve to node, or null if fails
|
|
297
|
+
} catch (err) {
|
|
298
|
+
throw new Error("`".concat(optionName, "` appears to be an invalid selector; error=\"").concat(err.message, "\""));
|
|
299
|
+
}
|
|
287
300
|
if (!node) {
|
|
288
|
-
|
|
301
|
+
if (!hasFallback) {
|
|
302
|
+
throw new Error("`".concat(optionName, "` as selector refers to no known node"));
|
|
303
|
+
}
|
|
304
|
+
// else, `node` MUST be `null` because that's what `Document.querySelector()` returns
|
|
305
|
+
// if the selector is valid but doesn't match anything
|
|
289
306
|
}
|
|
290
307
|
}
|
|
291
308
|
return node;
|
|
292
309
|
};
|
|
293
310
|
var getInitialFocusNode = function getInitialFocusNode() {
|
|
294
|
-
var node = getNodeForOption('initialFocus'
|
|
311
|
+
var node = getNodeForOption('initialFocus', {
|
|
312
|
+
hasFallback: true
|
|
313
|
+
});
|
|
295
314
|
|
|
296
315
|
// false explicitly indicates we want no initialFocus at all
|
|
297
316
|
if (node === false) {
|
|
298
317
|
return false;
|
|
299
318
|
}
|
|
300
|
-
if (node === undefined || !isFocusable(node, config.tabbableOptions)) {
|
|
319
|
+
if (node === undefined || node && !isFocusable(node, config.tabbableOptions)) {
|
|
301
320
|
// option not specified nor focusable: use fallback options
|
|
302
321
|
if (findContainerIndex(doc.activeElement) >= 0) {
|
|
303
322
|
node = doc.activeElement;
|
|
@@ -308,6 +327,10 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
308
327
|
// NOTE: `fallbackFocus` option function cannot return `false` (not supported)
|
|
309
328
|
node = firstTabbableNode || getNodeForOption('fallbackFocus');
|
|
310
329
|
}
|
|
330
|
+
} else if (node === null) {
|
|
331
|
+
// option is a VALID selector string that doesn't yield a node: use the `fallbackFocus`
|
|
332
|
+
// option instead of the default behavior when the option isn't specified at all
|
|
333
|
+
node = getNodeForOption('fallbackFocus');
|
|
311
334
|
}
|
|
312
335
|
if (!node) {
|
|
313
336
|
throw new Error('Your focus-trap needs to have at least one focusable element');
|
|
@@ -417,25 +440,25 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
417
440
|
*
|
|
418
441
|
* @returns {HTMLElement} The element that currently has the focus
|
|
419
442
|
**/
|
|
420
|
-
var
|
|
443
|
+
var _getActiveElement = function getActiveElement(el) {
|
|
421
444
|
var activeElement = el.activeElement;
|
|
422
445
|
if (!activeElement) {
|
|
423
446
|
return;
|
|
424
447
|
}
|
|
425
448
|
if (activeElement.shadowRoot && activeElement.shadowRoot.activeElement !== null) {
|
|
426
|
-
return
|
|
449
|
+
return _getActiveElement(activeElement.shadowRoot);
|
|
427
450
|
}
|
|
428
451
|
return activeElement;
|
|
429
452
|
};
|
|
430
|
-
var
|
|
453
|
+
var _tryFocus = function tryFocus(node) {
|
|
431
454
|
if (node === false) {
|
|
432
455
|
return;
|
|
433
456
|
}
|
|
434
|
-
if (node ===
|
|
457
|
+
if (node === _getActiveElement(document)) {
|
|
435
458
|
return;
|
|
436
459
|
}
|
|
437
460
|
if (!node || !node.focus) {
|
|
438
|
-
|
|
461
|
+
_tryFocus(getInitialFocusNode());
|
|
439
462
|
return;
|
|
440
463
|
}
|
|
441
464
|
node.focus({
|
|
@@ -448,7 +471,9 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
448
471
|
}
|
|
449
472
|
};
|
|
450
473
|
var getReturnFocusNode = function getReturnFocusNode(previousActiveElement) {
|
|
451
|
-
var node = getNodeForOption('setReturnFocus',
|
|
474
|
+
var node = getNodeForOption('setReturnFocus', {
|
|
475
|
+
params: [previousActiveElement]
|
|
476
|
+
});
|
|
452
477
|
return node ? node : node === false ? false : previousActiveElement;
|
|
453
478
|
};
|
|
454
479
|
|
|
@@ -463,11 +488,11 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
463
488
|
* @returns {Node|undefined} The next node, or `undefined` if a next node couldn't be
|
|
464
489
|
* determined given the current state of the trap.
|
|
465
490
|
*/
|
|
466
|
-
var findNextNavNode = function findNextNavNode(
|
|
467
|
-
var target =
|
|
468
|
-
event =
|
|
469
|
-
|
|
470
|
-
isBackward =
|
|
491
|
+
var findNextNavNode = function findNextNavNode(_ref3) {
|
|
492
|
+
var target = _ref3.target,
|
|
493
|
+
event = _ref3.event,
|
|
494
|
+
_ref3$isBackward = _ref3.isBackward,
|
|
495
|
+
isBackward = _ref3$isBackward === undefined ? false : _ref3$isBackward;
|
|
471
496
|
target = target || getActualTarget(event);
|
|
472
497
|
updateTabbableNodes();
|
|
473
498
|
var destinationNode = null;
|
|
@@ -491,8 +516,8 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
491
516
|
// REVERSE
|
|
492
517
|
|
|
493
518
|
// is the target the first tabbable node in a group?
|
|
494
|
-
var startOfGroupIndex =
|
|
495
|
-
var firstTabbableNode =
|
|
519
|
+
var startOfGroupIndex = state.tabbableGroups.findIndex(function (_ref4) {
|
|
520
|
+
var firstTabbableNode = _ref4.firstTabbableNode;
|
|
496
521
|
return target === firstTabbableNode;
|
|
497
522
|
});
|
|
498
523
|
if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
|
|
@@ -520,8 +545,8 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
520
545
|
// FORWARD
|
|
521
546
|
|
|
522
547
|
// is the target the last tabbable node in a group?
|
|
523
|
-
var lastOfGroupIndex =
|
|
524
|
-
var lastTabbableNode =
|
|
548
|
+
var lastOfGroupIndex = state.tabbableGroups.findIndex(function (_ref5) {
|
|
549
|
+
var lastTabbableNode = _ref5.lastTabbableNode;
|
|
525
550
|
return target === lastTabbableNode;
|
|
526
551
|
});
|
|
527
552
|
if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
|
|
@@ -679,9 +704,9 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
679
704
|
});
|
|
680
705
|
}
|
|
681
706
|
if (nextNode) {
|
|
682
|
-
|
|
707
|
+
_tryFocus(nextNode);
|
|
683
708
|
} else {
|
|
684
|
-
|
|
709
|
+
_tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
|
|
685
710
|
}
|
|
686
711
|
}
|
|
687
712
|
state.recentNavEvent = undefined; // clear
|
|
@@ -706,19 +731,21 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
706
731
|
// to where it normally would
|
|
707
732
|
event.preventDefault();
|
|
708
733
|
}
|
|
709
|
-
|
|
734
|
+
_tryFocus(destinationNode);
|
|
710
735
|
}
|
|
711
736
|
// else, let the browser take care of [shift+]tab and move the focus
|
|
712
737
|
};
|
|
738
|
+
var checkTabKey = function checkTabKey(event) {
|
|
739
|
+
if (config.isKeyForward(event) || config.isKeyBackward(event)) {
|
|
740
|
+
checkKeyNav(event, config.isKeyBackward(event));
|
|
741
|
+
}
|
|
742
|
+
};
|
|
713
743
|
|
|
714
|
-
|
|
744
|
+
// we use a different event phase for the Escape key to allow canceling the event and checking for this in escapeDeactivates
|
|
745
|
+
var checkEscapeKey = function checkEscapeKey(event) {
|
|
715
746
|
if (isEscapeEvent(event) && valueOrHandler(config.escapeDeactivates, event) !== false) {
|
|
716
747
|
event.preventDefault();
|
|
717
748
|
trap.deactivate();
|
|
718
|
-
return;
|
|
719
|
-
}
|
|
720
|
-
if (config.isKeyForward(event) || config.isKeyBackward(event)) {
|
|
721
|
-
checkKeyNav(event, config.isKeyBackward(event));
|
|
722
749
|
}
|
|
723
750
|
};
|
|
724
751
|
var checkClick = function checkClick(e) {
|
|
@@ -751,8 +778,8 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
751
778
|
// Delay ensures that the focused element doesn't capture the event
|
|
752
779
|
// that caused the focus trap activation.
|
|
753
780
|
state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function () {
|
|
754
|
-
|
|
755
|
-
}) :
|
|
781
|
+
_tryFocus(getInitialFocusNode());
|
|
782
|
+
}) : _tryFocus(getInitialFocusNode());
|
|
756
783
|
doc.addEventListener('focusin', checkFocusIn, true);
|
|
757
784
|
doc.addEventListener('mousedown', checkPointerDown, {
|
|
758
785
|
capture: true,
|
|
@@ -766,10 +793,11 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
766
793
|
capture: true,
|
|
767
794
|
passive: false
|
|
768
795
|
});
|
|
769
|
-
doc.addEventListener('keydown',
|
|
796
|
+
doc.addEventListener('keydown', checkTabKey, {
|
|
770
797
|
capture: true,
|
|
771
798
|
passive: false
|
|
772
799
|
});
|
|
800
|
+
doc.addEventListener('keydown', checkEscapeKey);
|
|
773
801
|
return trap;
|
|
774
802
|
};
|
|
775
803
|
var removeListeners = function removeListeners() {
|
|
@@ -780,7 +808,8 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
780
808
|
doc.removeEventListener('mousedown', checkPointerDown, true);
|
|
781
809
|
doc.removeEventListener('touchstart', checkPointerDown, true);
|
|
782
810
|
doc.removeEventListener('click', checkClick, true);
|
|
783
|
-
doc.removeEventListener('keydown',
|
|
811
|
+
doc.removeEventListener('keydown', checkTabKey, true);
|
|
812
|
+
doc.removeEventListener('keydown', checkEscapeKey);
|
|
784
813
|
return trap;
|
|
785
814
|
};
|
|
786
815
|
|
|
@@ -799,7 +828,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
799
828
|
// If the currently focused is removed then browsers will move focus to the
|
|
800
829
|
// <body> element. If this happens, try to move focus back into the trap.
|
|
801
830
|
if (isFocusedNodeRemoved) {
|
|
802
|
-
|
|
831
|
+
_tryFocus(getInitialFocusNode());
|
|
803
832
|
}
|
|
804
833
|
};
|
|
805
834
|
|
|
@@ -845,14 +874,14 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
845
874
|
state.active = true;
|
|
846
875
|
state.paused = false;
|
|
847
876
|
state.nodeFocusedBeforeActivation = doc.activeElement;
|
|
848
|
-
onActivate === null || onActivate ===
|
|
877
|
+
onActivate === null || onActivate === undefined || onActivate();
|
|
849
878
|
var finishActivation = function finishActivation() {
|
|
850
879
|
if (checkCanFocusTrap) {
|
|
851
880
|
updateTabbableNodes();
|
|
852
881
|
}
|
|
853
882
|
addListeners();
|
|
854
883
|
updateObservedNodes();
|
|
855
|
-
onPostActivate === null || onPostActivate ===
|
|
884
|
+
onPostActivate === null || onPostActivate === undefined || onPostActivate();
|
|
856
885
|
};
|
|
857
886
|
if (checkCanFocusTrap) {
|
|
858
887
|
checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
|
|
@@ -881,13 +910,13 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
881
910
|
var onPostDeactivate = getOption(options, 'onPostDeactivate');
|
|
882
911
|
var checkCanReturnFocus = getOption(options, 'checkCanReturnFocus');
|
|
883
912
|
var returnFocus = getOption(options, 'returnFocus', 'returnFocusOnDeactivate');
|
|
884
|
-
onDeactivate === null || onDeactivate ===
|
|
913
|
+
onDeactivate === null || onDeactivate === undefined || onDeactivate();
|
|
885
914
|
var finishDeactivation = function finishDeactivation() {
|
|
886
915
|
delay(function () {
|
|
887
916
|
if (returnFocus) {
|
|
888
|
-
|
|
917
|
+
_tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
|
|
889
918
|
}
|
|
890
|
-
onPostDeactivate === null || onPostDeactivate ===
|
|
919
|
+
onPostDeactivate === null || onPostDeactivate === undefined || onPostDeactivate();
|
|
891
920
|
});
|
|
892
921
|
};
|
|
893
922
|
if (returnFocus && checkCanReturnFocus) {
|
|
@@ -898,31 +927,21 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
898
927
|
return this;
|
|
899
928
|
},
|
|
900
929
|
pause: function pause(pauseOptions) {
|
|
901
|
-
if (
|
|
930
|
+
if (!state.active) {
|
|
902
931
|
return this;
|
|
903
932
|
}
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
state.paused = true;
|
|
907
|
-
onPause === null || onPause === void 0 || onPause();
|
|
908
|
-
removeListeners();
|
|
909
|
-
updateObservedNodes();
|
|
910
|
-
onPostPause === null || onPostPause === void 0 || onPostPause();
|
|
911
|
-
return this;
|
|
933
|
+
state.manuallyPaused = true;
|
|
934
|
+
return this._setPausedState(true, pauseOptions);
|
|
912
935
|
},
|
|
913
936
|
unpause: function unpause(unpauseOptions) {
|
|
914
|
-
if (!state.
|
|
937
|
+
if (!state.active) {
|
|
915
938
|
return this;
|
|
916
939
|
}
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
addListeners();
|
|
923
|
-
updateObservedNodes();
|
|
924
|
-
onPostUnpause === null || onPostUnpause === void 0 || onPostUnpause();
|
|
925
|
-
return this;
|
|
940
|
+
state.manuallyPaused = false;
|
|
941
|
+
if (trapStack[trapStack.length - 1] !== this) {
|
|
942
|
+
return this;
|
|
943
|
+
}
|
|
944
|
+
return this._setPausedState(false, unpauseOptions);
|
|
926
945
|
},
|
|
927
946
|
updateContainerElements: function updateContainerElements(containerElements) {
|
|
928
947
|
var elementsAsArray = [].concat(containerElements).filter(Boolean);
|
|
@@ -936,6 +955,38 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
936
955
|
return this;
|
|
937
956
|
}
|
|
938
957
|
};
|
|
958
|
+
Object.defineProperties(trap, {
|
|
959
|
+
_isManuallyPaused: {
|
|
960
|
+
value: function value() {
|
|
961
|
+
return state.manuallyPaused;
|
|
962
|
+
}
|
|
963
|
+
},
|
|
964
|
+
_setPausedState: {
|
|
965
|
+
value: function value(paused, options) {
|
|
966
|
+
if (state.paused === paused) {
|
|
967
|
+
return this;
|
|
968
|
+
}
|
|
969
|
+
state.paused = paused;
|
|
970
|
+
if (paused) {
|
|
971
|
+
var onPause = getOption(options, 'onPause');
|
|
972
|
+
var onPostPause = getOption(options, 'onPostPause');
|
|
973
|
+
onPause === null || onPause === undefined || onPause();
|
|
974
|
+
removeListeners();
|
|
975
|
+
updateObservedNodes();
|
|
976
|
+
onPostPause === null || onPostPause === undefined || onPostPause();
|
|
977
|
+
} else {
|
|
978
|
+
var onUnpause = getOption(options, 'onUnpause');
|
|
979
|
+
var onPostUnpause = getOption(options, 'onPostUnpause');
|
|
980
|
+
onUnpause === null || onUnpause === undefined || onUnpause();
|
|
981
|
+
updateTabbableNodes();
|
|
982
|
+
addListeners();
|
|
983
|
+
updateObservedNodes();
|
|
984
|
+
onPostUnpause === null || onPostUnpause === undefined || onPostUnpause();
|
|
985
|
+
}
|
|
986
|
+
return this;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
});
|
|
939
990
|
|
|
940
991
|
// initialize container elements
|
|
941
992
|
trap.updateContainerElements(elements);
|